OpenGL Renderer: Fix issues that would throw a GL error.

- glTexParameteri() with GL_TEXTURE_2D_MULTISAMPLE throws INVALID_ENUM when trying to assign a sampler-related state, so these calls have been removed.
- glMapBufferRange() throws GL_INVALID_OPERATION if the buffer size is 0, so check for this condition first.
This commit is contained in:
rogerman 2024-07-13 10:43:04 -07:00
parent aaf88d9f14
commit 241ca96cf1
2 changed files with 358 additions and 351 deletions

View File

@ -4354,6 +4354,8 @@ Render3DError OpenGLRenderer_1_2::BeginRender(const GFX3D_State &renderState, co
this->_enableAlphaBlending = (renderState.DISP3DCNT.EnableAlphaBlending) ? true : false; this->_enableAlphaBlending = (renderState.DISP3DCNT.EnableAlphaBlending) ? true : false;
if (this->_clippedPolyCount > 0)
{
if (this->isVBOSupported) if (this->isVBOSupported)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OGLRef.iboGeometryIndexID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OGLRef.iboGeometryIndexID);
@ -4550,9 +4552,9 @@ Render3DError OpenGLRenderer_1_2::BeginRender(const GFX3D_State &renderState, co
} }
} }
#endif #endif
}
glReadBuffer(OGL_COLOROUT_ATTACHMENT_ID); glReadBuffer(OGL_COLOROUT_ATTACHMENT_ID);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
@ -4654,6 +4656,11 @@ Render3DError OpenGLRenderer_1_2::RenderGeometry()
Render3DError OpenGLRenderer_1_2::PostprocessFramebuffer() Render3DError OpenGLRenderer_1_2::PostprocessFramebuffer()
{ {
if (this->_clippedPolyCount < 1)
{
return OGLERROR_NOERR;
}
OGLRenderRef &OGLRef = *this->ref; OGLRenderRef &OGLRef = *this->ref;
if ( (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported) || if ( (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported) ||

View File

@ -1038,18 +1038,10 @@ Render3DError OpenGLRenderer_3_2::CreateMultisampledFBO(GLsizei numSamples)
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GColor); glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GColor);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGColorID); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGColorID);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, GL_RGBA8, (GLsizei)this->_framebufferWidth, (GLsizei)this->_framebufferHeight, GL_TRUE); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, GL_RGBA8, (GLsizei)this->_framebufferWidth, (GLsizei)this->_framebufferHeight, GL_TRUE);
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FinalColor); glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FinalColor);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGWorkingID); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGWorkingID);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, GL_RGBA8, (GLsizei)this->_framebufferWidth, (GLsizei)this->_framebufferHeight, GL_TRUE); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, GL_RGBA8, (GLsizei)this->_framebufferWidth, (GLsizei)this->_framebufferHeight, GL_TRUE);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
@ -2289,6 +2281,8 @@ Render3DError OpenGLRenderer_3_2::BeginRender(const GFX3D_State &renderState, co
this->_enableAlphaBlending = (renderState.DISP3DCNT.EnableAlphaBlending) ? true : false; this->_enableAlphaBlending = (renderState.DISP3DCNT.EnableAlphaBlending) ? true : false;
if (this->_clippedPolyCount > 0)
{
glBindBuffer(GL_ARRAY_BUFFER, OGLRef.vboGeometryVtxID); glBindBuffer(GL_ARRAY_BUFFER, OGLRef.vboGeometryVtxID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OGLRef.iboGeometryIndexID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OGLRef.iboGeometryIndexID);
@ -2481,8 +2475,9 @@ Render3DError OpenGLRenderer_3_2::BeginRender(const GFX3D_State &renderState, co
this->_geometryProgramFlags.OpaqueDrawMode = 1; this->_geometryProgramFlags.OpaqueDrawMode = 1;
this->_SetupGeometryShaders(this->_geometryProgramFlags); this->_SetupGeometryShaders(this->_geometryProgramFlags);
glReadBuffer(OGL_COLOROUT_ATTACHMENT_ID); }
glReadBuffer(OGL_COLOROUT_ATTACHMENT_ID);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
@ -2493,6 +2488,11 @@ Render3DError OpenGLRenderer_3_2::BeginRender(const GFX3D_State &renderState, co
Render3DError OpenGLRenderer_3_2::PostprocessFramebuffer() Render3DError OpenGLRenderer_3_2::PostprocessFramebuffer()
{ {
if (this->_clippedPolyCount < 1)
{
return OGLERROR_NOERR;
}
OGLRenderRef &OGLRef = *this->ref; OGLRenderRef &OGLRef = *this->ref;
if (this->_enableEdgeMark || this->_enableFog) if (this->_enableEdgeMark || this->_enableFog)