diff options
| author | JMC47 <JMC4789@gmail.com> | 2021-06-01 19:55:54 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-01 19:55:54 -0400 |
| commit | a12865570d7c0eacd77f1bed850772e5f8aea4d9 (patch) | |
| tree | 79952a73a9483307b07967df460ab1859411e5eb /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | 8dc87ef69861b605a51170c782f5a271aa889603 (diff) | |
| parent | c58837964f02a1db64f82fd260c5a554adbc6b81 (diff) | |
Merge pull request #9764 from Pokechu22/amd-opengl-bbox-fix
VideoCommon: Fix bounding box on AMD/OpenGL/Windows
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 16fb7766e9..551fd3dc2d 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -451,20 +451,37 @@ void WritePixelShaderCommonHeader(ShaderCode& out, APIType api_type, if (bounding_box) { + if (api_type == APIType::D3D) + { + out.Write("globallycoherent RWBuffer<int> bbox_data : register(u2);\n" + "#define atomicMin InterlockedMin\n" + "#define atomicMax InterlockedMax"); + } + 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(R"( -#ifdef API_D3D -globallycoherent RWBuffer<int> bbox_data : register(u2); -#define atomicMin InterlockedMin -#define atomicMax InterlockedMax #define bbox_left bbox_data[0] #define bbox_right bbox_data[1] #define bbox_top bbox_data[2] #define bbox_bottom bbox_data[3] -#else -SSBO_BINDING(0) buffer BBox {{ - int bbox_left, bbox_right, bbox_top, bbox_bottom; -}}; -#endif void UpdateBoundingBoxBuffer(int2 min_pos, int2 max_pos) {{ if (bbox_left > min_pos.x) |
