Commit 93e72f5f by Tobin Ehlis Committed by Commit Bot

Vulkan:Include precision qualifier in GLSL

With this initial implementation, it's possible to get precision qualifier mis-matches in the generated GLSL 4.50. According to the spec this is allowed. From GLSLangSpec 4.50 section 4.7 "Precision and Precision Qualifiers": For the purposes of determining if an output from one shader stage matches an input of the next stage, the precision qualifier need not match. However, when converted to SPIR-V and run through the shader validation any mismatches will cause shader validation errors. Initially just ignoring those errors with this commit. Bug: angleproject:3078 Change-Id: Ia2b04f90f0a7b6b1302c1b1b3e32bcfd8db9ed49 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2057749Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent 8aea6d5a
...@@ -27,6 +27,7 @@ TOutputVulkanGLSL::TOutputVulkanGLSL(TInfoSinkBase &objSink, ...@@ -27,6 +27,7 @@ TOutputVulkanGLSL::TOutputVulkanGLSL(TInfoSinkBase &objSink,
sh::GLenum shaderType, sh::GLenum shaderType,
int shaderVersion, int shaderVersion,
ShShaderOutput output, ShShaderOutput output,
bool forceHighp,
ShCompileOptions compileOptions) ShCompileOptions compileOptions)
: TOutputGLSL(objSink, : TOutputGLSL(objSink,
clampingStrategy, clampingStrategy,
...@@ -39,7 +40,8 @@ TOutputVulkanGLSL::TOutputVulkanGLSL(TInfoSinkBase &objSink, ...@@ -39,7 +40,8 @@ TOutputVulkanGLSL::TOutputVulkanGLSL(TInfoSinkBase &objSink,
compileOptions), compileOptions),
mNextUnusedBinding(0), mNextUnusedBinding(0),
mNextUnusedInputLocation(0), mNextUnusedInputLocation(0),
mNextUnusedOutputLocation(0) mNextUnusedOutputLocation(0),
mForceHighp(forceHighp)
{} {}
void TOutputVulkanGLSL::writeLayoutQualifier(TIntermTyped *variable) void TOutputVulkanGLSL::writeLayoutQualifier(TIntermTyped *variable)
...@@ -168,4 +170,17 @@ void TOutputVulkanGLSL::writeStructType(const TStructure *structure) ...@@ -168,4 +170,17 @@ void TOutputVulkanGLSL::writeStructType(const TStructure *structure)
} }
} }
bool TOutputVulkanGLSL::writeVariablePrecision(TPrecision precision)
{
if (precision == EbpUndefined)
return false;
TInfoSinkBase &out = objSink();
if (mForceHighp)
out << getPrecisionString(EbpHigh);
else
out << getPrecisionString(precision);
return true;
}
} // namespace sh } // namespace sh
...@@ -25,6 +25,7 @@ class TOutputVulkanGLSL : public TOutputGLSL ...@@ -25,6 +25,7 @@ class TOutputVulkanGLSL : public TOutputGLSL
sh::GLenum shaderType, sh::GLenum shaderType,
int shaderVersion, int shaderVersion,
ShShaderOutput output, ShShaderOutput output,
bool forceHighp,
ShCompileOptions compileOptions); ShCompileOptions compileOptions);
void writeStructType(const TStructure *structure); void writeStructType(const TStructure *structure);
...@@ -48,6 +49,7 @@ class TOutputVulkanGLSL : public TOutputGLSL ...@@ -48,6 +49,7 @@ class TOutputVulkanGLSL : public TOutputGLSL
void writeVariableType(const TType &type, void writeVariableType(const TType &type,
const TSymbol *symbol, const TSymbol *symbol,
bool isFunctionArgument) override; bool isFunctionArgument) override;
bool writeVariablePrecision(TPrecision) override;
// Every resource that requires set & binding layout qualifiers is assigned set 0 and an // Every resource that requires set & binding layout qualifiers is assigned set 0 and an
// arbitrary binding when outputting GLSL. Every input/output that requires a location // arbitrary binding when outputting GLSL. Every input/output that requires a location
...@@ -57,6 +59,9 @@ class TOutputVulkanGLSL : public TOutputGLSL ...@@ -57,6 +59,9 @@ class TOutputVulkanGLSL : public TOutputGLSL
uint32_t mNextUnusedBinding; uint32_t mNextUnusedBinding;
uint32_t mNextUnusedInputLocation; uint32_t mNextUnusedInputLocation;
uint32_t mNextUnusedOutputLocation; uint32_t mNextUnusedOutputLocation;
private:
bool mForceHighp;
}; };
} // namespace sh } // namespace sh
...@@ -71,6 +71,7 @@ TOutputVulkanGLSLForMetal::TOutputVulkanGLSLForMetal(TInfoSinkBase &objSink, ...@@ -71,6 +71,7 @@ TOutputVulkanGLSLForMetal::TOutputVulkanGLSLForMetal(TInfoSinkBase &objSink,
shaderType, shaderType,
shaderVersion, shaderVersion,
output, output,
false,
compileOptions) compileOptions)
{} {}
......
...@@ -67,9 +67,10 @@ bool TranslatorMetal::translate(TIntermBlock *root, ...@@ -67,9 +67,10 @@ bool TranslatorMetal::translate(TIntermBlock *root,
PerformanceDiagnostics *perfDiagnostics) PerformanceDiagnostics *perfDiagnostics)
{ {
TInfoSinkBase &sink = getInfoSink().obj; TInfoSinkBase &sink = getInfoSink().obj;
TOutputVulkanGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), TOutputVulkanGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(),
getNameMap(), &getSymbolTable(), getShaderType(), getNameMap(), &getSymbolTable(), getShaderType(),
getShaderVersion(), getOutputType(), compileOptions); getShaderVersion(), getOutputType(), false, compileOptions);
const TVariable *driverUniforms = nullptr; const TVariable *driverUniforms = nullptr;
if (!TranslatorVulkan::translateImpl(root, compileOptions, perfDiagnostics, &driverUniforms, if (!TranslatorVulkan::translateImpl(root, compileOptions, perfDiagnostics, &driverUniforms,
......
...@@ -1008,9 +1008,14 @@ bool TranslatorVulkan::translate(TIntermBlock *root, ...@@ -1008,9 +1008,14 @@ bool TranslatorVulkan::translate(TIntermBlock *root,
{ {
TInfoSinkBase &sink = getInfoSink().obj; TInfoSinkBase &sink = getInfoSink().obj;
TOutputVulkanGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(),
getNameMap(), &getSymbolTable(), getShaderType(), bool precisionEmulation = false;
getShaderVersion(), getOutputType(), compileOptions); if (!emulatePrecisionIfNeeded(root, sink, &precisionEmulation, SH_GLSL_VULKAN_OUTPUT))
return false;
TOutputVulkanGLSL outputGLSL(
sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), &getSymbolTable(),
getShaderType(), getShaderVersion(), getOutputType(), precisionEmulation, compileOptions);
if (!translateImpl(root, compileOptions, perfDiagnostics, nullptr, &outputGLSL)) if (!translateImpl(root, compileOptions, perfDiagnostics, nullptr, &outputGLSL))
{ {
......
...@@ -124,9 +124,9 @@ constexpr const char *kSkippedMessages[] = { ...@@ -124,9 +124,9 @@ constexpr const char *kSkippedMessages[] = {
"VUID-vkDestroySemaphore-semaphore-parameter", "VUID-vkDestroySemaphore-semaphore-parameter",
// http://anglebug.com/4063 // http://anglebug.com/4063
"VUID-VkDeviceCreateInfo-pNext-pNext", "VUID-VkDeviceCreateInfo-pNext-pNext",
"VUID-VkPipelineRasterizationStateCreateInfo-pNext-pNext", "VUID-VkPipelineRasterizationStateCreateInfo-pNext-pNext", "VUID_Undefined",
"VUID_Undefined", // http://anglebug.com/3078
}; "UNASSIGNED-CoreValidation-Shader-InterfaceTypeMismatch"};
// Suppress validation errors that are known // Suppress validation errors that are known
// return "true" if given code/prefix/message is known, else return "false" // return "true" if given code/prefix/message is known, else return "false"
......
...@@ -567,6 +567,14 @@ ...@@ -567,6 +567,14 @@
2830 ANDROID VULKAN : dEQP-GLES3.functional.rasterization.fbo.texture_2d.primitives.lines = FAIL 2830 ANDROID VULKAN : dEQP-GLES3.functional.rasterization.fbo.texture_2d.primitives.lines = FAIL
2830 ANDROID VULKAN : dEQP-GLES3.functional.rasterization.primitives.line* = FAIL 2830 ANDROID VULKAN : dEQP-GLES3.functional.rasterization.primitives.line* = FAIL
2808 ANDROID VULKAN : dEQP-GLES3.functional.shaders.builtin_variable.fragcoord_w = FAIL 2808 ANDROID VULKAN : dEQP-GLES3.functional.shaders.builtin_variable.fragcoord_w = FAIL
3078 ANDROID VULKAN : dEQP-GLES3.functional.shaders.operator.unary_operator.minus.lowp_uint_fragment = FAIL
3078 ANDROID VULKAN : dEQP-GLES3.functional.shaders.operator.unary_operator.minus.lowp_uvec2_fragment = FAIL
3078 ANDROID VULKAN : dEQP-GLES3.functional.shaders.operator.unary_operator.minus.lowp_uvec3_fragment = FAIL
3078 ANDROID VULKAN : dEQP-GLES3.functional.shaders.operator.unary_operator.minus.lowp_uvec4_fragment = FAIL
3078 ANDROID VULKAN : dEQP-GLES3.functional.shaders.operator.unary_operator.minus.mediump_uint_fragment = FAIL
3078 ANDROID VULKAN : dEQP-GLES3.functional.shaders.operator.unary_operator.minus.mediump_uvec2_fragment = FAIL
3078 ANDROID VULKAN : dEQP-GLES3.functional.shaders.operator.unary_operator.minus.mediump_uvec3_fragment = FAIL
3078 ANDROID VULKAN : dEQP-GLES3.functional.shaders.operator.unary_operator.minus.mediump_uvec4_fragment = FAIL
// Pixel driver issues // Pixel driver issues
4024 PIXEL2ORXL VULKAN : dEQP-GLES3.functional.draw.random.5 = SKIP 4024 PIXEL2ORXL VULKAN : dEQP-GLES3.functional.draw.random.5 = SKIP
......
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