Home | History | Annotate | Download | only in Renderer
      1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //    http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #ifndef sw_QuadRasterizer_hpp
     16 #define sw_QuadRasterizer_hpp
     17 
     18 #include "Rasterizer.hpp"
     19 #include "ShaderCore.hpp"
     20 #include "PixelShader.hpp"
     21 
     22 #include "Types.hpp"
     23 
     24 namespace sw
     25 {
     26 	class QuadRasterizer : public Rasterizer
     27 	{
     28 	public:
     29 		QuadRasterizer(const PixelProcessor::State &state, const PixelShader *shader);
     30 		virtual ~QuadRasterizer();
     31 
     32 		void generate();
     33 
     34 	protected:
     35 		Pointer<Byte> constants;
     36 
     37 		Float4 Dz[4];
     38 		Float4 Dw;
     39 		Float4 Dv[MAX_FRAGMENT_INPUTS][4];
     40 		Float4 Df;
     41 
     42 		UInt occlusion;
     43 
     44 #if PERF_PROFILE
     45 		Long cycles[PERF_TIMERS];
     46 #endif
     47 
     48 		virtual void quad(Pointer<Byte> cBuffer[4], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y) = 0;
     49 
     50 		bool interpolateZ() const;
     51 		bool interpolateW() const;
     52 		Float4 interpolate(Float4 &x, Float4 &D, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective);
     53 
     54 		const PixelProcessor::State &state;
     55 		const PixelShader *const shader;
     56 
     57 	private:
     58 		void rasterize(Int &yMin, Int &yMax);
     59 	};
     60 }
     61 
     62 #endif   // sw_QuadRasterizer_hpp
     63