Commit 3aa46cbd by Nicolas Capens

Use the last triangle vertex for flat shading on OpenGL.

Bug 21559270 Change-Id: I4c2b5eb7076cc459422fbbb397a684c19bd643c2 Reviewed-on: https://swiftshader-review.googlesource.com/3372Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 101e4f0a
...@@ -29,7 +29,7 @@ namespace gl ...@@ -29,7 +29,7 @@ namespace gl
{ {
using namespace sw; using namespace sw;
Device::Device(Context *context) : Renderer(context, true, true, true, true, true), context(context) Device::Device(Context *context) : Renderer(context, OpenGL, true), context(context)
{ {
depthStencil = 0; depthStencil = 0;
renderTarget = 0; renderTarget = 0;
......
...@@ -29,7 +29,7 @@ namespace es1 ...@@ -29,7 +29,7 @@ namespace es1
{ {
using namespace sw; using namespace sw;
Device::Device(Context *context) : Renderer(context, true, true, true, true, true), context(context) Device::Device(Context *context) : Renderer(context, OpenGL, true), context(context)
{ {
depthStencil = 0; depthStencil = 0;
renderTarget = 0; renderTarget = 0;
......
...@@ -29,7 +29,7 @@ namespace es2 ...@@ -29,7 +29,7 @@ namespace es2
{ {
using namespace sw; using namespace sw;
Device::Device(Context *context) : Renderer(context, true, true, true, true, true), context(context) Device::Device(Context *context) : Renderer(context, OpenGL, true), context(context)
{ {
depthStencil = 0; depthStencil = 0;
renderTarget = 0; renderTarget = 0;
......
...@@ -29,7 +29,7 @@ namespace es2 ...@@ -29,7 +29,7 @@ namespace es2
{ {
using namespace sw; using namespace sw;
Device::Device(Context *context) : Renderer(context, true, true, true, true, true), context(context) Device::Device(Context *context) : Renderer(context, OpenGL, true), context(context)
{ {
depthStencil = 0; depthStencil = 0;
renderTarget = 0; renderTarget = 0;
......
...@@ -30,6 +30,7 @@ namespace sw ...@@ -30,6 +30,7 @@ namespace sw
bool symmetricNormalizedDepth = false; // [-1, 1] instead of [0, 1] bool symmetricNormalizedDepth = false; // [-1, 1] instead of [0, 1]
bool booleanFaceRegister = false; bool booleanFaceRegister = false;
bool fullPixelPositionRegister = false; bool fullPixelPositionRegister = false;
bool leadingVertexFirst = false; // Flat shading uses first vertex, else last
bool forceWindowed = false; bool forceWindowed = false;
bool quadLayoutEnabled = false; bool quadLayoutEnabled = false;
......
...@@ -50,6 +50,7 @@ namespace sw ...@@ -50,6 +50,7 @@ namespace sw
extern bool complementaryDepthBuffer; extern bool complementaryDepthBuffer;
extern bool postBlendSRGB; extern bool postBlendSRGB;
extern bool exactColorRounding; extern bool exactColorRounding;
extern bool leadingVertexFirst;
extern TransparencyAntialiasing transparencyAntialiasing; extern TransparencyAntialiasing transparencyAntialiasing;
extern bool forceClearRegisters; extern bool forceClearRegisters;
...@@ -99,12 +100,13 @@ namespace sw ...@@ -99,12 +100,13 @@ namespace sw
deallocate(data); deallocate(data);
} }
Renderer::Renderer(Context *context, bool halfIntegerCoordinates, bool symmetricNormalizedDepth, bool booleanFaceRegister, bool fullPixelPositionRegister, bool exactColorRounding) : context(context), VertexProcessor(context), PixelProcessor(context), SetupProcessor(context), viewport() Renderer::Renderer(Context *context, Conventions conventions, bool exactColorRounding) : context(context), VertexProcessor(context), PixelProcessor(context), SetupProcessor(context), viewport()
{ {
sw::halfIntegerCoordinates = halfIntegerCoordinates; sw::halfIntegerCoordinates = conventions.halfIntegerCoordinates;
sw::symmetricNormalizedDepth = symmetricNormalizedDepth; sw::symmetricNormalizedDepth = conventions.symmetricNormalizedDepth;
sw::booleanFaceRegister = booleanFaceRegister; sw::booleanFaceRegister = conventions.booleanFaceRegister;
sw::fullPixelPositionRegister = fullPixelPositionRegister; sw::fullPixelPositionRegister = conventions.fullPixelPositionRegister;
sw::leadingVertexFirst = conventions.leadingVertexFirst;
sw::exactColorRounding = exactColorRounding; sw::exactColorRounding = exactColorRounding;
setRenderTarget(0, 0); setRenderTarget(0, 0);
......
...@@ -53,6 +53,24 @@ namespace sw ...@@ -53,6 +53,24 @@ namespace sw
extern TranscendentalPrecision rsqPrecision; extern TranscendentalPrecision rsqPrecision;
extern bool perspectiveCorrection; extern bool perspectiveCorrection;
struct Conventions
{
bool halfIntegerCoordinates;
bool symmetricNormalizedDepth;
bool booleanFaceRegister;
bool fullPixelPositionRegister;
bool leadingVertexFirst;
};
static const Conventions OpenGL =
{
true, // halfIntegerCoordinates
true, // symmetricNormalizedDepth
true, // booleanFaceRegister
true, // fullPixelPositionRegister
false // leadingVertexFirst
};
struct Query struct Query
{ {
Query() Query()
...@@ -268,7 +286,7 @@ namespace sw ...@@ -268,7 +286,7 @@ namespace sw
}; };
public: public:
Renderer(Context *context, bool halfIntegerCoordinates, bool symmetricNormalizedDepth, bool booleanFaceRegister, bool fullPixelPositionRegister, bool exactColorRounding); Renderer(Context *context, Conventions conventions, bool exactColorRounding);
virtual ~Renderer(); virtual ~Renderer();
......
...@@ -21,6 +21,7 @@ namespace sw ...@@ -21,6 +21,7 @@ namespace sw
{ {
extern bool complementaryDepthBuffer; extern bool complementaryDepthBuffer;
extern TranscendentalPrecision logPrecision; extern TranscendentalPrecision logPrecision;
extern bool leadingVertexFirst;
SetupRoutine::SetupRoutine(const SetupProcessor::State &state) : state(state) SetupRoutine::SetupRoutine(const SetupProcessor::State &state) : state(state)
{ {
...@@ -546,7 +547,8 @@ namespace sw ...@@ -546,7 +547,8 @@ namespace sw
} }
else else
{ {
Float C = *Pointer<Float>(triangle + OFFSET(Triangle,v0) + attribute); int leadingVertex = leadingVertexFirst ? OFFSET(Triangle,v0) : OFFSET(Triangle,v2);
Float C = *Pointer<Float>(triangle + leadingVertex + attribute);
*Pointer<Float4>(primitive + planeEquation + 0, 16) = Float4(0, 0, 0, 0); *Pointer<Float4>(primitive + planeEquation + 0, 16) = Float4(0, 0, 0, 0);
*Pointer<Float4>(primitive + planeEquation + 16, 16) = Float4(0, 0, 0, 0); *Pointer<Float4>(primitive + planeEquation + 16, 16) = Float4(0, 0, 0, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment