Commit 7c89d248 by Cooper Partin Committed by Jamie Madill

Reland Fixed FL9_3 shaders that use glPointCoord without glPointSize.

This change fixes a Shader error on FL9_3 that reports Vertex/Pixel Shader linkage signatures between stages being incompatible when glPointCoord is used without glPointSize. Change-Id: I107d06692c5375c07544038f5f4429c1e8d6e313 Reviewed-on: https://chromium-review.googlesource.com/305395Tested-by: 's avatarCooper Partin <coopp@microsoft.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 60ad73dc
...@@ -797,6 +797,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, ...@@ -797,6 +797,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data,
const ShaderD3D *vertexShader = GetImplAs<ShaderD3D>(vertexShaderGL); const ShaderD3D *vertexShader = GetImplAs<ShaderD3D>(vertexShaderGL);
const gl::Shader *fragmentShaderGL = programData.getAttachedFragmentShader(); const gl::Shader *fragmentShaderGL = programData.getAttachedFragmentShader();
const ShaderD3D *fragmentShader = GetImplAs<ShaderD3D>(fragmentShaderGL); const ShaderD3D *fragmentShader = GetImplAs<ShaderD3D>(fragmentShaderGL);
const int shaderModel = mRenderer->getMajorShaderModel();
bool usesMRT = fragmentShader->usesMultipleRenderTargets(); bool usesMRT = fragmentShader->usesMultipleRenderTargets();
bool usesFragCoord = fragmentShader->usesFragCoord(); bool usesFragCoord = fragmentShader->usesFragCoord();
...@@ -804,12 +805,14 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, ...@@ -804,12 +805,14 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data,
bool usesPointSize = vertexShader->usesPointSize(); bool usesPointSize = vertexShader->usesPointSize();
bool useInstancedPointSpriteEmulation = bool useInstancedPointSpriteEmulation =
usesPointSize && mRenderer->getWorkarounds().useInstancedPointSpriteEmulation; usesPointSize && mRenderer->getWorkarounds().useInstancedPointSpriteEmulation;
bool insertDummyPointCoordValue = !usesPointSize && usesPointCoord && shaderModel >= 4;
bool addPointCoord =
(useInstancedPointSpriteEmulation && usesPointCoord) || insertDummyPointCoordValue;
// Validation done in the compiler // Validation done in the compiler
ASSERT(!fragmentShader->usesFragColor() || !fragmentShader->usesFragData()); ASSERT(!fragmentShader->usesFragColor() || !fragmentShader->usesFragData());
// Write the HLSL input/output declarations // Write the HLSL input/output declarations
const int shaderModel = mRenderer->getMajorShaderModel();
const int registersNeeded = registers + (usesFragCoord ? 1 : 0) + (usesPointCoord ? 1 : 0); const int registersNeeded = registers + (usesFragCoord ? 1 : 0) + (usesPointCoord ? 1 : 0);
// Two cases when writing to gl_FragColor and using ESSL 1.0: // Two cases when writing to gl_FragColor and using ESSL 1.0:
...@@ -841,8 +844,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, ...@@ -841,8 +844,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data,
// gl_PointSize to be in VS_OUTPUT and GS_INPUT. Instanced point sprites doesn't need // gl_PointSize to be in VS_OUTPUT and GS_INPUT. Instanced point sprites doesn't need
// gl_PointSize in VS_OUTPUT. // gl_PointSize in VS_OUTPUT.
const SemanticInfo &vertexSemantics = const SemanticInfo &vertexSemantics =
getSemanticInfo(registers, outputPositionFromVS, usesFragCoord, getSemanticInfo(registers, outputPositionFromVS, usesFragCoord, addPointCoord,
(useInstancedPointSpriteEmulation && usesPointCoord),
(!useInstancedPointSpriteEmulation && usesPointSize), false); (!useInstancedPointSpriteEmulation && usesPointSize), false);
storeUserLinkedVaryings(packedVaryings, usesPointSize, linkedVaryings); storeUserLinkedVaryings(packedVaryings, usesPointSize, linkedVaryings);
...@@ -968,6 +970,16 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data, ...@@ -968,6 +970,16 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::Data &data,
} }
} }
// Renderers that enable instanced pointsprite emulation require the vertex shader output member
// gl_PointCoord to be set to a default value if used without gl_PointSize. 0.5,0.5 is the same
// default value used in the generated pixel shader.
if (insertDummyPointCoordValue)
{
ASSERT(!useInstancedPointSpriteEmulation);
vertexStream << "\n"
<< " output.gl_PointCoord = float2(0.5, 0.5);\n";
}
vertexStream << "\n" vertexStream << "\n"
<< " return output;\n" << " return output;\n"
<< "}\n"; << "}\n";
......
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