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/+/1986379
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Shahbaz Youssefi 2020-01-03 23:26:08 -05:00 коммит произвёл Commit Bot
Родитель f8ae5dc6d7
Коммит 0721cc8ba0
3 изменённых файлов: 22 добавлений и 6 удалений

Просмотреть файл

@ -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
{

Просмотреть файл

@ -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.

Просмотреть файл

@ -40,6 +40,11 @@ std::shared_ptr<WaitableCompileEvent> 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;