Splitting PixelRoutine into PixelProgram and PixelPipeline
This cl splits PixelRoutine into 2 specialized classes:
PixelProgram and PixelPipeline.
In this cl:
- Moved all specialized behavior of PixelRoutine into the
PixelProgram and PixelPipeline classes.
- Inverted hierarchical dependency between PixelRoutine and
QuadRasterizer. QuadRasterizer is now the base class.
- Added a check to PixelProcessor::routine() to either create
a PixelPipeline object or a PixelProgram object.
- Moved a few interpolation related utility functions from
PixelRoutine down to QuadRasterizer.
- Added Registers hierarchy. PixelProgram specific Registers
and PixelPipeline specific Registers are now mutually
exclusive.
- Made the quad functions virtual
- Added a few virtual functions (setBuiltins, ps, alphaTest,
rasterOperation) for Program/Pipeline specific implementations
Bug 20257503
Change-Id: I6abe536a5521d9842f757a8bbb52e3947e3c9250
Reviewed-on: https://swiftshader-review.googlesource.com/3634
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Renderer/QuadRasterizer.cpp b/src/Renderer/QuadRasterizer.cpp
index 543c0ce..a9298d4 100644
--- a/src/Renderer/QuadRasterizer.cpp
+++ b/src/Renderer/QuadRasterizer.cpp
@@ -21,10 +21,23 @@
{
extern bool veryEarlyDepthTest;
extern bool complementaryDepthBuffer;
+ extern bool fullPixelPositionRegister;
extern int clusterCount;
- QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, const PixelShader *pixelShader) : PixelRoutine(state, pixelShader)
+ QuadRasterizer::Registers::Registers()
+ {
+ occlusion = 0;
+
+#if PERF_PROFILE
+ for(int i = 0; i < PERF_TIMERS; i++)
+ {
+ cycles[i] = 0;
+ }
+#endif
+ }
+
+ QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, const PixelShader *pixelShader) : Rasterizer(state), shader(pixelShader)
{
}
@@ -45,7 +58,7 @@
Int cluster(function.arg(2));
Pointer<Byte> data(function.arg(3));
- Registers r(shader);
+ Registers& r = *createRegisters(shader);
r.constants = *Pointer<Pointer<Byte> >(data + OFFSET(DrawData,constants));
r.cluster = cluster;
r.data = data;
@@ -89,6 +102,8 @@
#endif
Return();
+
+ delete &r;
}
routine = function(L"PixelRoutine_%0.8X", state.shaderID);
@@ -317,4 +332,31 @@
}
Until(y >= yMax)
}
+
+ Float4 QuadRasterizer::interpolate(Float4 &x, Float4 &D, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective)
+ {
+ Float4 interpolant = D;
+
+ if(!flat)
+ {
+ interpolant += x * *Pointer<Float4>(planeEquation + OFFSET(PlaneEquation, A), 16);
+
+ if(perspective)
+ {
+ interpolant *= rhw;
+ }
+ }
+
+ return interpolant;
+ }
+
+ bool QuadRasterizer::interpolateZ() const
+ {
+ return state.depthTestActive || state.pixelFogActive() || (shader && shader->vPosDeclared && fullPixelPositionRegister);
+ }
+
+ bool QuadRasterizer::interpolateW() const
+ {
+ return state.perspective || (shader && shader->vPosDeclared && fullPixelPositionRegister);
+ }
}