D3D11: Fix basic provoking vertex flat shading cases.
The enables geometry shaders that correct for the flat shading on
provoking vertexes. It does not fix it for triangle strips, or in
conjunction with primitive restart (which is not yet implemented
in D3D11).
Also ensure we do not regress with flat shading enabled and transform
feedback. In cases where we use flat shading, do a double draw call,
first with an untransformed vertex stream, and no geometry shader,
then with the geometry shader enabled.
This also fixes the dEQP fragment output tests with ints.
BUG=angleproject:754
Change-Id: Ib37e8ec32d19db17ea5d4dc88158cdae0c956bfc
Reviewed-on: https://chromium-review.googlesource.com/309155
Tryjob-Request: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/DynamicHLSL.cpp b/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
index 76ed675..32791b2 100644
--- a/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
+++ b/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
@@ -760,12 +760,12 @@
BuiltinInfo glPointSize;
};
-DynamicHLSL::SemanticInfo DynamicHLSL::getSemanticInfo(unsigned int startRegisters,
+DynamicHLSL::SemanticInfo DynamicHLSL::getSemanticInfo(ShaderType shaderType,
+ unsigned int startRegisters,
bool position,
bool fragCoord,
bool pointCoord,
- bool pointSize,
- bool pixelShader) const
+ bool pointSize) const
{
SemanticInfo info;
bool hlsl4 = (mRenderer->getMajorShaderModel() >= 4);
@@ -777,7 +777,7 @@
{
info.dxPosition.enableSystem("SV_Position");
}
- else if (pixelShader)
+ else if (shaderType == SHADER_PIXEL)
{
info.dxPosition.enableSystem("VPOS");
}
@@ -811,7 +811,7 @@
}
// Special case: do not include PSIZE semantic in HLSL 3 pixel shaders
- if (pointSize && (!pixelShader || hlsl4))
+ if (pointSize && (shaderType != SHADER_PIXEL || hlsl4))
{
info.glPointSize.enableSystem("PSIZE");
}
@@ -964,8 +964,8 @@
// gl_PointSize to be in VS_OUTPUT and GS_INPUT. Instanced point sprites doesn't need
// gl_PointSize in VS_OUTPUT.
const SemanticInfo &vertexSemantics =
- getSemanticInfo(registerCount, outputPositionFromVS, usesFragCoord, addPointCoord,
- (!useInstancedPointSpriteEmulation && usesPointSize), false);
+ getSemanticInfo(SHADER_VERTEX, registerCount, outputPositionFromVS, usesFragCoord,
+ addPointCoord, (!useInstancedPointSpriteEmulation && usesPointSize));
storeUserLinkedVaryings(packedVaryings, usesPointSize, linkedVaryings);
storeBuiltinLinkedVaryings(vertexSemantics, linkedVaryings);
@@ -1098,8 +1098,8 @@
pixelStream << fragmentShaderGL->getTranslatedSource();
const SemanticInfo &pixelSemantics =
- getSemanticInfo(registerCount, outputPositionFromVS, usesFragCoord, usesPointCoord,
- (!useInstancedPointSpriteEmulation && usesPointSize), true);
+ getSemanticInfo(SHADER_PIXEL, registerCount, outputPositionFromVS, usesFragCoord,
+ usesPointCoord, (!useInstancedPointSpriteEmulation && usesPointSize));
pixelStream << "struct PS_INPUT\n";
generateVaryingLinkHLSL(*data.caps, usesPointSize, pixelSemantics, packedVaryings, pixelStream);
@@ -1305,9 +1305,9 @@
bool usesPointSize = vertexShader->usesPointSize();
const SemanticInfo &inSemantics =
- getSemanticInfo(registerCount, true, usesFragCoord, false, usesPointSize, false);
- const SemanticInfo &outSemantics =
- getSemanticInfo(registerCount, true, usesFragCoord, usesPointCoord, usesPointSize, false);
+ getSemanticInfo(SHADER_VERTEX, registerCount, true, usesFragCoord, false, usesPointSize);
+ const SemanticInfo &outSemantics = getSemanticInfo(
+ SHADER_GEOMETRY, registerCount, true, usesFragCoord, usesPointCoord, usesPointSize);
std::stringstream preambleStream;
@@ -1317,10 +1317,11 @@
<< "struct GS_OUTPUT\n";
generateVaryingLinkHLSL(*data.caps, usesPointSize, outSemantics, packedVaryings,
preambleStream);
- preambleStream << "\n"
- << "void copyVertex(inout GS_OUTPUT output, GS_INPUT input)\n"
- << "{\n"
- << " output.gl_Position = input.gl_Position;\n";
+ preambleStream
+ << "\n"
+ << "void copyVertex(inout GS_OUTPUT output, GS_INPUT input, GS_INPUT flatinput)\n"
+ << "{\n"
+ << " output.gl_Position = input.gl_Position;\n";
if (usesPointSize)
{
@@ -1329,9 +1330,14 @@
for (const PackedVaryingRegister &varyingRegister : PackedVaryingIterator(packedVaryings))
{
+ const sh::Varying &varying = *packedVaryings[varyingRegister.varyingIndex].varying;
unsigned int registerIndex = varyingRegister.registerIndex(*data.caps, packedVaryings);
preambleStream << " output.v" << registerIndex << " = ";
+ if (varying.interpolation == sh::INTERPOLATION_FLAT)
+ {
+ preambleStream << "flat";
+ }
preambleStream << "input.v" << registerIndex << "; \n";
}
@@ -1436,9 +1442,11 @@
<< "{\n"
<< " GS_OUTPUT output = (GS_OUTPUT)0;\n";
+ int flatVertexIndex = inputSize - 1;
for (int vertexIndex = 0; vertexIndex < inputSize; ++vertexIndex)
{
- shaderStream << " copyVertex(output, input[" << vertexIndex << "]);\n";
+ shaderStream << " copyVertex(output, input[" << vertexIndex << "], input["
+ << flatVertexIndex << "]);\n";
if (!pointSprites)
{