Tie BinCombined's local_size_x to the coarse tiles' area

This commit is contained in:
FireNX70 2024-06-13 00:30:33 +02:00
parent 57b5e16e6d
commit f097cc3b4e
3 changed files with 6 additions and 2 deletions

View File

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

View File

@ -166,6 +166,7 @@ private:
int TileSize;
static constexpr int CoarseTileCountX = 8;
int CoarseTileCountY;
int CoarseTileArea;
int CoarseTileW;
int CoarseTileH;

View File

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