Commit 0721cc8b by Shahbaz Youssefi Committed by Commit Bot

Vulkan: No line raster emulation code if extension

A flag is added to the translator to disable generation of Bresenham line raster emulation code when the Bresenham line raster Vulkan extension is present. This is primarily for the sake of conversion of line raster emulation condition to specialization constant: - Avoid dead SPIR-V code in every shader - Avoid ANGLEUniforms being active in every shader stage even if it's not used anywhere but in line raster emulation. - Optimize SPIR-V transformations by both having fewer instructions to iterate through, and to avoid generating line raster patches. - Reduce the severity of anglebug.com/4251 where the location assignment of ANGLEPosition can incorrectly overlap a varying array or struct, by making only platforms without Bresenham extension afflicted by the bug. Bug: angleproject:3394 Change-Id: Ic0ae6ce0392b4eae0cc79cb94bbcd0805b276a31 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1986379Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent f8ae5dc6
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
// Version number for shader translation API. // Version number for shader translation API.
// It is incremented every time the API changes. // It is incremented every time the API changes.
#define ANGLE_SH_VERSION 221 #define ANGLE_SH_VERSION 222
enum ShShaderSpec enum ShShaderSpec
{ {
...@@ -318,6 +318,11 @@ const ShCompileOptions SH_REMOVE_DYNAMIC_INDEXING_OF_SWIZZLED_VECTOR = UINT64_C( ...@@ -318,6 +318,11 @@ const ShCompileOptions SH_REMOVE_DYNAMIC_INDEXING_OF_SWIZZLED_VECTOR = UINT64_C(
// on Windows 7 and earlier. // on Windows 7 and earlier.
const ShCompileOptions SH_DONT_TRANSLATE_UNIFORM_BLOCK_TO_STRUCTUREDBUFFER = UINT64_C(1) << 50; const ShCompileOptions SH_DONT_TRANSLATE_UNIFORM_BLOCK_TO_STRUCTUREDBUFFER = UINT64_C(1) << 50;
// This flag indicates whether Bresenham line raster emulation code should be generated. This
// emulation is necessary if the backend uses a differnet algorithm to draw lines. Currently only
// implemented for the Vulkan backend.
const ShCompileOptions SH_ADD_BRESENHAM_LINE_RASTER_EMULATION = UINT64_C(1) << 51;
// Defines alternate strategies for implementing array index clamping. // Defines alternate strategies for implementing array index clamping.
enum ShArrayIndexClampingStrategy enum ShArrayIndexClampingStrategy
{ {
......
...@@ -870,10 +870,13 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root, ...@@ -870,10 +870,13 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
} }
} }
if (!AddBresenhamEmulationFS(this, sink, root, &getSymbolTable(), driverUniforms, if (compileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION)
usesFragCoord))
{ {
return false; if (!AddBresenhamEmulationFS(this, sink, root, &getSymbolTable(), driverUniforms,
usesFragCoord))
{
return false;
}
} }
bool hasGLFragColor = false; bool hasGLFragColor = false;
...@@ -936,9 +939,12 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root, ...@@ -936,9 +939,12 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
} }
else if (getShaderType() == GL_VERTEX_SHADER) else if (getShaderType() == GL_VERTEX_SHADER)
{ {
if (!AddBresenhamEmulationVS(this, root, &getSymbolTable(), driverUniforms)) if (compileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION)
{ {
return false; if (!AddBresenhamEmulationVS(this, root, &getSymbolTable(), driverUniforms))
{
return false;
}
} }
// Add a macro to declare transform feedback buffers. // Add a macro to declare transform feedback buffers.
......
...@@ -40,6 +40,11 @@ std::shared_ptr<WaitableCompileEvent> ShaderVk::compile(const gl::Context *conte ...@@ -40,6 +40,11 @@ std::shared_ptr<WaitableCompileEvent> ShaderVk::compile(const gl::Context *conte
compileOptions |= SH_CLAMP_POINT_SIZE; compileOptions |= SH_CLAMP_POINT_SIZE;
} }
if (contextVk->getFeatures().basicGLLineRasterization.enabled)
{
compileOptions |= SH_ADD_BRESENHAM_LINE_RASTER_EMULATION;
}
if (contextVk->emulateSeamfulCubeMapSampling()) if (contextVk->emulateSeamfulCubeMapSampling())
{ {
compileOptions |= SH_EMULATE_SEAMFUL_CUBE_MAP_SAMPLING; compileOptions |= SH_EMULATE_SEAMFUL_CUBE_MAP_SAMPLING;
......
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