From bac8c2d44147395e31c4d5a2247be1b449139272 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 24 Sep 2016 23:13:17 +1000 Subject: [PATCH] Vulkan: Work around indexed fragment output bug on AMD drivers --- Source/Core/VideoCommon/DriverDetails.cpp | 2 ++ Source/Core/VideoCommon/DriverDetails.h | 8 ++++++++ Source/Core/VideoCommon/PixelShaderGen.cpp | 12 ++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/DriverDetails.cpp b/Source/Core/VideoCommon/DriverDetails.cpp index cf167f7d8d..645360d791 100644 --- a/Source/Core/VideoCommon/DriverDetails.cpp +++ b/Source/Core/VideoCommon/DriverDetails.cpp @@ -84,6 +84,8 @@ static BugInfo m_known_bugs[] = { -1.0, true}, {API_OPENGL, OS_ALL, VENDOR_MESA, DRIVER_I965, Family::UNKNOWN, BUG_BROKENCLIPDISTANCE, -1.0, -1.0, true}, + {API_VULKAN, OS_ALL, VENDOR_ATI, DRIVER_ATI, Family::UNKNOWN, + BUG_BROKEN_FRAGMENT_SHADER_INDEX_DECORATION, -1.0, -1.0, true}, }; static std::map m_bugs; diff --git a/Source/Core/VideoCommon/DriverDetails.h b/Source/Core/VideoCommon/DriverDetails.h index 86a365d578..ebf38886be 100644 --- a/Source/Core/VideoCommon/DriverDetails.h +++ b/Source/Core/VideoCommon/DriverDetails.h @@ -222,6 +222,14 @@ enum Bug // the geometry shader. Current workaround is to make sure the geometry shader always consumes // the gl_ClipDistance inputs from the vertex shader. BUG_BROKENCLIPDISTANCE, + + // Bug: Dual-source outputs from fragment shaders are broken on AMD Vulkan drivers + // Started Version: -1 + // Ended Version: -1 + // Fragment shaders that specify dual-source outputs, via layout(location = 0, index = ...) cause + // the driver to fail to create graphics pipelines. The workaround for this is to specify the + // index as a MRT location instead, or omit the binding completely. + BUG_BROKEN_FRAGMENT_SHADER_INDEX_DECORATION, }; // Initializes our internal vendor, device family, and driver version diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 4038d9329c..e4227e8280 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -517,8 +517,16 @@ ShaderCode GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, APIType ApiType, { if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND) { - out.Write("FRAGMENT_OUTPUT_LOCATION_INDEXED(0, 0) out vec4 ocol0;\n"); - out.Write("FRAGMENT_OUTPUT_LOCATION_INDEXED(0, 1) out vec4 ocol1;\n"); + if (DriverDetails::HasBug(DriverDetails::BUG_BROKEN_FRAGMENT_SHADER_INDEX_DECORATION)) + { + out.Write("FRAGMENT_OUTPUT_LOCATION(0) out vec4 ocol0;\n"); + out.Write("FRAGMENT_OUTPUT_LOCATION(1) out vec4 ocol1;\n"); + } + else + { + out.Write("FRAGMENT_OUTPUT_LOCATION_INDEXED(0, 0) out vec4 ocol0;\n"); + out.Write("FRAGMENT_OUTPUT_LOCATION_INDEXED(0, 1) out vec4 ocol1;\n"); + } } else {