Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10760 from tellowkrinkle/std430
VideoCommon: Fix SSBO layout and remove associated "bug"
  • Loading branch information
JMC47 committed Jun 24, 2022
2 parents 0a2aabe + 26529a3 commit ffa3bf8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
Expand Up @@ -790,15 +790,15 @@ void ProgramShaderCache::CreateHeader()
"#define UBO_BINDING(packing, x) layout(packing, binding = x)\n"
"#define SAMPLER_BINDING(x) layout(binding = x)\n"
"#define TEXEL_BUFFER_BINDING(x) layout(binding = x)\n"
"#define SSBO_BINDING(x) layout(binding = x)\n"
"#define SSBO_BINDING(x) layout(std430, binding = x)\n"
"#define IMAGE_BINDING(format, x) layout(format, binding = x)\n" :
"#define ATTRIBUTE_LOCATION(x)\n"
"#define FRAGMENT_OUTPUT_LOCATION(x)\n"
"#define FRAGMENT_OUTPUT_LOCATION_INDEXED(x, y)\n"
"#define UBO_BINDING(packing, x) layout(packing)\n"
"#define SAMPLER_BINDING(x)\n"
"#define TEXEL_BUFFER_BINDING(x)\n"
"#define SSBO_BINDING(x)\n"
"#define SSBO_BINDING(x) layout(std430)\n"
"#define IMAGE_BINDING(format, x) layout(format)\n",
// Input/output blocks are matched by name during program linking
"#define VARYING_LOCATION(x)\n",
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp
Expand Up @@ -49,7 +49,7 @@ static const char SHADER_HEADER[] = R"(
#define UBO_BINDING(packing, x) layout(packing, set = 0, binding = (x - 1))
#define SAMPLER_BINDING(x) layout(set = 1, binding = x)
#define TEXEL_BUFFER_BINDING(x) layout(set = 1, binding = (x + 8))
#define SSBO_BINDING(x) layout(set = 2, binding = x)
#define SSBO_BINDING(x) layout(std430, set = 2, binding = x)
#define INPUT_ATTACHMENT_BINDING(x, y, z) layout(set = x, binding = y, input_attachment_index = z)
#define VARYING_LOCATION(x) layout(location = x)
#define FORCE_EARLY_Z layout(early_fragment_tests) in
Expand Down
2 changes: 0 additions & 2 deletions Source/Core/VideoCommon/DriverDetails.cpp
Expand Up @@ -128,8 +128,6 @@ constexpr BugInfo m_known_bugs[] = {
-1.0, -1.0, true},
{API_VULKAN, OS_ALL, VENDOR_ARM, DRIVER_ARM, Family::UNKNOWN, BUG_BROKEN_VECTOR_BITWISE_AND,
-1.0, -1.0, true},
{API_OPENGL, OS_WINDOWS, VENDOR_ATI, DRIVER_ATI, Family::UNKNOWN, BUG_BROKEN_SSBO_FIELD_ATOMICS,
-1.0, -1.0, true},
{API_VULKAN, OS_OSX, VENDOR_ATI, DRIVER_PORTABILITY, Family::UNKNOWN,
BUG_BROKEN_SUBGROUP_INVOCATION_ID, -1.0, -1.0, true},
{API_OPENGL, OS_ANDROID, VENDOR_ALL, DRIVER_ALL, Family::UNKNOWN,
Expand Down
8 changes: 0 additions & 8 deletions Source/Core/VideoCommon/DriverDetails.h
Expand Up @@ -302,14 +302,6 @@ enum Bug
// Ended version: -1
BUG_BROKEN_VECTOR_BITWISE_AND,

// BUG: Atomic writes to different fields or array elements of an SSBO have no effect, only
// writing to the first field/element works. This causes bounding box emulation to give garbage
// values under OpenGL.
// Affected devices: AMD (Windows)
// Started version: -1
// Ended version: -1
BUG_BROKEN_SSBO_FIELD_ATOMICS,

// BUG: Accessing gl_SubgroupInvocationID causes the Metal shader compiler to crash.
// Affected devices: AMD (macOS)
// Started version: -1
Expand Down
19 changes: 3 additions & 16 deletions Source/Core/VideoCommon/PixelShaderGen.cpp
Expand Up @@ -464,22 +464,9 @@ void WritePixelShaderCommonHeader(ShaderCode& out, APIType api_type,
}
else
{
out.Write("SSBO_BINDING(0) buffer BBox {{\n");

if (DriverDetails::HasBug(DriverDetails::BUG_BROKEN_SSBO_FIELD_ATOMICS))
{
// AMD drivers on Windows seemingly ignore atomic writes to fields or array elements of an
// SSBO other than the first one, but using an int4 seems to work fine
out.Write(" int4 bbox_data;\n");
}
else
{
// The Metal shader compiler fails to compile the atomic instructions when operating on
// individual components of a vector
out.Write(" int bbox_data[4];\n");
}

out.Write("}};");
out.Write("SSBO_BINDING(0) buffer BBox {{\n"
" int bbox_data[4];\n"
"}};");
}

out.Write(R"(
Expand Down

0 comments on commit ffa3bf8

Please sign in to comment.