also misc changes to use more unsigned multiplication
also fix framebuffer resize
This commit is contained in:
RSDuck 2023-04-17 20:53:41 +02:00
parent 60a3fe24ed
commit 07bd9c06aa
3 changed files with 13 additions and 11 deletions

View File

@ -89,7 +89,6 @@ bool ComputeRenderer::Init()
glGenBuffers(1, &TileMemory);
glGenTextures(1, &YSpanIndicesTexture);
glGenTextures(1, &Framebuffer);
glGenTextures(1, &LowResFramebuffer);
glBindTexture(GL_TEXTURE_2D, LowResFramebuffer);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8UI, 256, 192);
@ -230,6 +229,9 @@ void ComputeRenderer::SetRenderSettings(GPU::RenderSettings& settings)
glBindBuffer(GL_SHADER_STORAGE_BUFFER, BinResultMemory);
glBufferData(GL_SHADER_STORAGE_BUFFER, binResultSize, nullptr, GL_DYNAMIC_DRAW);
if (Framebuffer != 0)
glDeleteTextures(1, &Framebuffer);
glGenTextures(1, &Framebuffer);
glBindTexture(GL_TEXTURE_2D, Framebuffer);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, ScreenWidth, ScreenHeight);
@ -1391,7 +1393,7 @@ void ComputeRenderer::RenderFrame()
for (int i = 0; i < numVariants; i++)
{
GLuint shader = 0;
if (variants[i].Texture == -1)
if (variants[i].Texture == 0)
{
shader = shadersNoTexture[variants[i].BlendMode];
}

View File

@ -213,7 +213,7 @@ private:
u32 TextureDecodingBuffer[1024*1024];
GLuint Framebuffer;
GLuint Framebuffer = 0;
GLuint LowResFramebuffer;
GLuint PixelBuffer;

View File

@ -299,11 +299,11 @@ uint Div64_32_32(uint numHi, uint numLo, uint den)
// there's a 1 in the MSB.
// We also shift numer by the same amount. This cannot overflow because numHi < den.
// The expression (-shift & 63) is the same as (64 - shift), except it avoids the UB of shifting
// by 64. <---- in C. I'm pretty sure shifts are masked in GLSL, but whatever.
// by 64. (it's also UB in GLSL!!!!)
uint shift = 31 - findMSB(den);
den <<= shift;
numHi <<= shift;
numHi |= (numLo >> (-shift & 63U)) & uint(-int(shift) >> 63);
numHi |= (numLo >> (-shift & 31U)) & uint(-int(shift) >> 31);
numLo <<= shift;
// Extract the low digits of the numerator and both digits of the denominator.
@ -347,12 +347,12 @@ int CalcYFactorY(YSpanSetup span, int i)
/*
maybe it would be better to do use a 32x32=64 multiplication?
*/
uint numLo = abs(i * span.W0n);
uint numLo = uint(abs(i)) * uint(span.W0n);
uint numHi = 0U;
numHi |= numLo >> (32-YFactorShift);
numHi |= numLo >> (32U-YFactorShift);
numLo <<= YFactorShift;
uint den = abs(i * span.W0d + (span.I1 - span.I0 - i) * span.W1d);
uint den = uint(abs(i)) * uint(span.W0d) + uint(abs(span.I1 - span.I0 - i)) * span.W1d;
if (den == 0)
{
@ -370,12 +370,12 @@ int CalcYFactorX(XSpanSetup span, int x)
if (span.X0 != span.X1)
{
uint numLo = uint(x) * span.W0;
uint numLo = uint(x) * uint(span.W0);
uint numHi = 0U;
numHi |= numLo >> (32-YFactorShift);
numHi |= numLo >> (32U-YFactorShift);
numLo <<= YFactorShift;
uint den = (uint(x) * span.W0) + (uint(span.X1 - span.X0 - x) * span.W1);
uint den = uint(x) * uint(span.W0) + uint(span.X1 - span.X0 - x) * uint(span.W1);
if (den == 0)
return 0;