Updated instanced pointsprite emulation to be more resilient to driver differences.
Change-Id: I89e5b5a2d2c0363ae07d5ba918187cb0d7056ac5
Reviewed-on: https://chromium-review.googlesource.com/251680
Tested-by: Cooper Partin <coopp@microsoft.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/DynamicHLSL.cpp b/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
index e4c6dd8..d3fba92 100644
--- a/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
+++ b/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
@@ -386,6 +386,26 @@
int semanticIndex = 0;
unsigned int inputIndex = 0;
+ // If gl_PointSize is used in the shader then pointsprites rendering is expected.
+ // If the renderer does not support Geometry shaders then Instanced PointSprite emulation
+ // must be used.
+ bool usesPointSize = sourceShader.find("GL_USES_POINT_SIZE") != std::string::npos;
+ bool useInstancedPointSpriteEmulation = usesPointSize && mRenderer->getWorkarounds().useInstancedPointSpriteEmulation;
+
+ // Instanced PointSprite emulation requires additional entries in the
+ // VS_INPUT structure to support the vertices that make up the quad vertices.
+ // These values must be in sync with the cooresponding values added during inputlayout creation
+ // in InputLayoutCache::applyVertexBuffers().
+ //
+ // The additional entries must appear first in the VS_INPUT layout because
+ // Windows Phone 8 era devices require per vertex data to physically come
+ // before per instance data in the shader.
+ if (useInstancedPointSpriteEmulation)
+ {
+ structHLSL += " float3 spriteVertexPos : SPRITEPOSITION0;\n";
+ structHLSL += " float2 spriteTexCoord : SPRITETEXCOORD0;\n";
+ }
+
for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{
const sh::Attribute &shaderAttribute = shaderAttributes[attributeIndex];
@@ -451,22 +471,6 @@
}
}
- // If gl_PointSize is used in the shader then pointsprites rendering is expected.
- // If the renderer does not support Geometry shaders then Instanced PointSprite emulation
- // may must be used.
- bool usesPointSize = sourceShader.find("GL_USES_POINT_SIZE") != std::string::npos;
- bool useInstancedPointSpriteEmulation = usesPointSize && mRenderer->getWorkarounds().useInstancedPointSpriteEmulation;
-
- // Instanced PointSprite emulation requires additional entries in the
- // VS_INPUT structure to support the vertices that make up the quad vertices.
- // These values must be in sync with the cooresponding values added during inputlayout creation
- // in InputLayoutCache::applyVertexBuffers().
- if (useInstancedPointSpriteEmulation)
- {
- structHLSL += " float3 spriteVertexPos : SPRITEPOSITION0;\n";
- structHLSL += " float2 spriteTexCoord : SPRITETEXCOORD0;\n";
- }
-
std::string replacementHLSL = "struct VS_INPUT\n"
"{\n" +
structHLSL +