From f097cc3b4e93bcd9b5db73d6be68d21dcfb85955 Mon Sep 17 00:00:00 2001 From: FireNX70 Date: Thu, 13 Jun 2024 00:30:33 +0200 Subject: [PATCH] Tie BinCombined's local_size_x to the coarse tiles' area --- src/GPU3D_Compute.cpp | 5 ++++- src/GPU3D_Compute.h | 1 + src/GPU3D_Compute_shaders.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/GPU3D_Compute.cpp b/src/GPU3D_Compute.cpp index c22a66b9..ecf48544 100644 --- a/src/GPU3D_Compute.cpp +++ b/src/GPU3D_Compute.cpp @@ -57,6 +57,8 @@ bool ComputeRenderer::CompileShader(GLuint& shader, const std::string& source, c shaderSource += std::to_string(TileSize); shaderSource += "\nconst int CoarseTileCountY = "; shaderSource += std::to_string(CoarseTileCountY) + ";"; + shaderSource += "\n#define CoarseTileArea "; + shaderSource += std::to_string(CoarseTileArea); shaderSource += ComputeRendererShaders::Common; shaderSource += source; @@ -330,6 +332,7 @@ void ComputeRenderer::SetRenderSettings(int scale, bool highResolutionCoordinate TileSize = std::min(8 * TileScale, 32); CoarseTileCountY = TileSize < 32 ? 4 : 6; + CoarseTileArea = CoarseTileCountX * CoarseTileCountY; CoarseTileW = CoarseTileCountX * TileSize; CoarseTileH = CoarseTileCountY * TileSize; @@ -959,7 +962,7 @@ void ComputeRenderer::RenderFrame(GPU& gpu) // bin polygons glUseProgram(ShaderBinCombined); - glDispatchCompute(((gpu.GPU3D.RenderNumPolygons + 31) / 32), ScreenWidth/CoarseTileW, ScreenHeight/CoarseTileH); + glDispatchCompute(((gpu.GPU3D.RenderNumPolygons + CoarseTileArea - 1) / CoarseTileArea), ScreenWidth/CoarseTileW, ScreenHeight/CoarseTileH); glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); // calculate list offsets diff --git a/src/GPU3D_Compute.h b/src/GPU3D_Compute.h index 4f944e42..6a5fd499 100644 --- a/src/GPU3D_Compute.h +++ b/src/GPU3D_Compute.h @@ -166,6 +166,7 @@ private: int TileSize; static constexpr int CoarseTileCountX = 8; int CoarseTileCountY; + int CoarseTileArea; int CoarseTileW; int CoarseTileH; diff --git a/src/GPU3D_Compute_shaders.h b/src/GPU3D_Compute_shaders.h index 9fb4aae7..9b319029 100644 --- a/src/GPU3D_Compute_shaders.h +++ b/src/GPU3D_Compute_shaders.h @@ -862,7 +862,7 @@ const std::string BinCombined = XSpanSetupBuffer + WorkDescBuffer + R"( -layout (local_size_x = 32) in; +layout (local_size_x = CoarseTileArea) in; bool BinPolygon(Polygon polygon, ivec2 topLeft, ivec2 botRight) {