Commit c7a92fdb by Jamie Madill

D3D11: Fix provoking vertex for flat triangle strips.

Triangle strips alternate the provoking vertex based on the primitive, so use the primitive ID in the GS to determine this. This might interact poorly with primitive restart, so we might have to use a slow path for that. BUG=angleproject:754 Change-Id: I4f6f520887d4c4c52d2ad020e6db148607f68325 Reviewed-on: https://chromium-review.googlesource.com/309156 Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 31e60cf2
......@@ -1436,17 +1436,30 @@ std::string DynamicHLSL::generateGeometryShaderHLSL(gl::PrimitiveType primitiveT
shaderStream << preambleString << "\n"
<< "[maxvertexcount(" << maxVertexOutput << ")]\n"
<< "void main(" << inputPT << " GS_INPUT input[" << inputSize << "],"
" inout "
<< outputPT << "Stream<GS_OUTPUT> outStream)\n"
<< "void main(" << inputPT << " GS_INPUT input[" << inputSize << "], ";
if (primitiveType == PRIMITIVE_TRIANGLE_STRIP)
{
shaderStream << "uint primitiveID : SV_PrimitiveID, ";
}
shaderStream << " inout " << outputPT << "Stream<GS_OUTPUT> outStream)\n"
<< "{\n"
<< " GS_OUTPUT output = (GS_OUTPUT)0;\n";
int flatVertexIndex = inputSize - 1;
if (primitiveType == PRIMITIVE_TRIANGLE_STRIP)
{
shaderStream << " uint lastVertexIndex = (primitiveID % 2 == 0 ? 2 : 1);\n";
}
else
{
shaderStream << " uint lastVertexIndex = " << (inputSize - 1) << ";\n";
}
for (int vertexIndex = 0; vertexIndex < inputSize; ++vertexIndex)
{
shaderStream << " copyVertex(output, input[" << vertexIndex << "], input["
<< flatVertexIndex << "]);\n";
shaderStream << " copyVertex(output, input[" << vertexIndex
<< "], input[lastVertexIndex]);\n";
if (!pointSprites)
{
......
......@@ -200,13 +200,6 @@ TEST_P(ProvokingVertexTest, FlatLine)
// Test drawing a simple triangle strip with flat shading, and different valued vertices.
TEST_P(ProvokingVertexTest, FlatTriStrip)
{
// TODO(jmadill): Implement on the D3D back-end.
if (isD3D11())
{
std::cout << "Test disabled on D3D11." << std::endl;
return;
}
GLint vertexData[] = {1, 2, 3, 4, 5, 6};
GLfloat positionData[] = {-1.0f, -1.0f, -1.0f, 1.0f, 0.0f, -1.0f,
0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f};
......
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