diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h index 0a20a135b..f9bd1314c 100644 --- a/include/GLSLANG/ShaderLang.h +++ b/include/GLSLANG/ShaderLang.h @@ -26,7 +26,7 @@ // Version number for shader translation API. // It is incremented every time the API changes. -#define ANGLE_SH_VERSION 221 +#define ANGLE_SH_VERSION 222 enum ShShaderSpec { @@ -318,6 +318,11 @@ const ShCompileOptions SH_REMOVE_DYNAMIC_INDEXING_OF_SWIZZLED_VECTOR = UINT64_C( // on Windows 7 and earlier. 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. enum ShArrayIndexClampingStrategy { diff --git a/src/compiler/translator/TranslatorVulkan.cpp b/src/compiler/translator/TranslatorVulkan.cpp index 94037949f..1719200e9 100644 --- a/src/compiler/translator/TranslatorVulkan.cpp +++ b/src/compiler/translator/TranslatorVulkan.cpp @@ -870,10 +870,13 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root, } } - if (!AddBresenhamEmulationFS(this, sink, root, &getSymbolTable(), driverUniforms, - usesFragCoord)) + if (compileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION) { - return false; + if (!AddBresenhamEmulationFS(this, sink, root, &getSymbolTable(), driverUniforms, + usesFragCoord)) + { + return false; + } } bool hasGLFragColor = false; @@ -936,9 +939,12 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root, } 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. diff --git a/src/libANGLE/renderer/vulkan/ShaderVk.cpp b/src/libANGLE/renderer/vulkan/ShaderVk.cpp index fc96301f5..d777cd1f5 100644 --- a/src/libANGLE/renderer/vulkan/ShaderVk.cpp +++ b/src/libANGLE/renderer/vulkan/ShaderVk.cpp @@ -40,6 +40,11 @@ std::shared_ptr ShaderVk::compile(const gl::Context *conte compileOptions |= SH_CLAMP_POINT_SIZE; } + if (contextVk->getFeatures().basicGLLineRasterization.enabled) + { + compileOptions |= SH_ADD_BRESENHAM_LINE_RASTER_EMULATION; + } + if (contextVk->emulateSeamfulCubeMapSampling()) { compileOptions |= SH_EMULATE_SEAMFUL_CUBE_MAP_SAMPLING;