Commit e6d14cc3 by Cooper Partin Committed by Jamie Madill

Updated instanced pointsprite emulation to be more resilient to driver differences.

Change-Id: I89e5b5a2d2c0363ae07d5ba918187cb0d7056ac5 Reviewed-on: https://chromium-review.googlesource.com/251680Tested-by: 's avatarCooper Partin <coopp@microsoft.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 94463d58
...@@ -386,6 +386,26 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s ...@@ -386,6 +386,26 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s
int semanticIndex = 0; int semanticIndex = 0;
unsigned int inputIndex = 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++) for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{ {
const sh::Attribute &shaderAttribute = shaderAttributes[attributeIndex]; const sh::Attribute &shaderAttribute = shaderAttributes[attributeIndex];
...@@ -451,22 +471,6 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s ...@@ -451,22 +471,6 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s
} }
} }
// 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" std::string replacementHLSL = "struct VS_INPUT\n"
"{\n" + "{\n" +
structHLSL + structHLSL +
......
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