OpenGL Renderer: Fix a few bugs here and there.

- Fix a compiling bug for ES due to missing tokens.
- Fix Fog and Edge Mark feature availability when running legacy OpenGL. (Regressions from commit 0c7cb99 and commit 8b5ac56.)
- glDrawBuffer() now determines its own algorithm at runtime instead of at compile time. This change is being done to be consistent with all of the other Standard vs ES changes.
This commit is contained in:
rogerman 2024-08-01 00:11:05 -07:00
parent 2f177d19a2
commit 0a78fa2a2b
2 changed files with 42 additions and 40 deletions

View File

@ -2298,16 +2298,18 @@ OpenGLRenderer_1_2::OpenGLRenderer_1_2()
_geometryAttachmentPolyID = GeometryAttachmentPolyIDStandard; _geometryAttachmentPolyID = GeometryAttachmentPolyIDStandard;
_geometryAttachmentFogAttributes = GeometryAttachmentFogAttributesStandard; _geometryAttachmentFogAttributes = GeometryAttachmentFogAttributesStandard;
#if MSB_FIRST #if defined(GL_VERSION_1_2)
#if MSB_FIRST
ref->textureSrcTypeCIColor = GL_UNSIGNED_SHORT_1_5_5_5_REV; ref->textureSrcTypeCIColor = GL_UNSIGNED_SHORT_1_5_5_5_REV;
ref->textureSrcTypeCIFog = GL_UNSIGNED_INT_8_8_8_8_REV; ref->textureSrcTypeCIFog = GL_UNSIGNED_INT_8_8_8_8_REV;
ref->textureSrcTypeEdgeColor = GL_UNSIGNED_INT_8_8_8_8; ref->textureSrcTypeEdgeColor = GL_UNSIGNED_INT_8_8_8_8;
ref->textureSrcTypeToonTable = GL_UNSIGNED_SHORT_1_5_5_5_REV; ref->textureSrcTypeToonTable = GL_UNSIGNED_SHORT_1_5_5_5_REV;
#else #else
ref->textureSrcTypeCIColor = GL_UNSIGNED_SHORT_1_5_5_5_REV; ref->textureSrcTypeCIColor = GL_UNSIGNED_SHORT_1_5_5_5_REV;
ref->textureSrcTypeCIFog = GL_UNSIGNED_INT_8_8_8_8_REV; ref->textureSrcTypeCIFog = GL_UNSIGNED_INT_8_8_8_8_REV;
ref->textureSrcTypeEdgeColor = GL_UNSIGNED_INT_8_8_8_8_REV; ref->textureSrcTypeEdgeColor = GL_UNSIGNED_INT_8_8_8_8_REV;
ref->textureSrcTypeToonTable = GL_UNSIGNED_SHORT_1_5_5_5_REV; ref->textureSrcTypeToonTable = GL_UNSIGNED_SHORT_1_5_5_5_REV;
#endif
#endif #endif
} }
@ -2606,7 +2608,7 @@ Render3DError OpenGLRenderer_1_2::InitExtensions()
// Set rendering support flags based on driver features. // Set rendering support flags based on driver features.
this->willFlipAndConvertFramebufferOnGPU = this->isShaderSupported && this->isVBOSupported; this->willFlipAndConvertFramebufferOnGPU = this->isShaderSupported && this->isVBOSupported;
this->_deviceInfo.isEdgeMarkSupported = this->isShaderSupported && this->isVBOSupported && this->isFBOSupported; this->_deviceInfo.isEdgeMarkSupported = this->isShaderSupported && this->isVBOSupported && this->isFBOSupported;
this->_deviceInfo.isFogSupported = this->isShaderSupported && this->isVBOSupported; this->_deviceInfo.isFogSupported = this->isShaderSupported && this->isVBOSupported && this->isFBOSupported;
this->_deviceInfo.isTextureSmoothingSupported = this->isShaderSupported; this->_deviceInfo.isTextureSmoothingSupported = this->isShaderSupported;
this->_isDepthLEqualPolygonFacingSupported = this->isShaderSupported && this->isVBOSupported && this->isFBOSupported; this->_isDepthLEqualPolygonFacingSupported = this->isShaderSupported && this->isVBOSupported && this->isFBOSupported;
@ -3174,8 +3176,8 @@ Render3DError OpenGLRenderer_1_2::CreateGeometryPrograms()
shaderFlags << "#define ENABLE_ALPHA_TEST " << ((programFlags.EnableAlphaTest) ? "true\n" : "false\n"); shaderFlags << "#define ENABLE_ALPHA_TEST " << ((programFlags.EnableAlphaTest) ? "true\n" : "false\n");
shaderFlags << "#define ENABLE_TEXTURE_SAMPLING " << ((programFlags.EnableTextureSampling) ? "true\n" : "false\n"); shaderFlags << "#define ENABLE_TEXTURE_SAMPLING " << ((programFlags.EnableTextureSampling) ? "true\n" : "false\n");
shaderFlags << "#define TOON_SHADING_MODE " << ((programFlags.ToonShadingMode) ? 1 : 0) << "\n"; shaderFlags << "#define TOON_SHADING_MODE " << ((programFlags.ToonShadingMode) ? 1 : 0) << "\n";
shaderFlags << "#define ENABLE_FOG " << ((programFlags.EnableFog && this->_deviceInfo.isFogSupported) ? 1 : 0) << "\n"; shaderFlags << "#define ENABLE_FOG " << ((programFlags.EnableFog && this->isVBOSupported && this->isFBOSupported) ? 1 : 0) << "\n"; // Do not rely on this->_deviceInfo.isFogSupported because it hasn't been set yet.
shaderFlags << "#define ENABLE_EDGE_MARK " << ((programFlags.EnableEdgeMark && this->_deviceInfo.isEdgeMarkSupported) ? 1 : 0) << "\n"; shaderFlags << "#define ENABLE_EDGE_MARK " << ((programFlags.EnableEdgeMark && this->isVBOSupported && this->isFBOSupported) ? 1 : 0) << "\n"; // Do not rely on this->_deviceInfo.isEdgeMarkSupported because it hasn't been set yet.
shaderFlags << "#define DRAW_MODE_OPAQUE " << ((programFlags.OpaqueDrawMode && this->isVBOSupported && this->isFBOSupported) ? 1 : 0) << "\n"; shaderFlags << "#define DRAW_MODE_OPAQUE " << ((programFlags.OpaqueDrawMode && this->isVBOSupported && this->isFBOSupported) ? 1 : 0) << "\n";
shaderFlags << "\n"; shaderFlags << "\n";
shaderFlags << "#define ATTACHMENT_WORKING_BUFFER " << this->_geometryAttachmentWorkingBuffer[programFlags.DrawBuffersMode] << "\n"; shaderFlags << "#define ATTACHMENT_WORKING_BUFFER " << this->_geometryAttachmentWorkingBuffer[programFlags.DrawBuffersMode] << "\n";

View File

@ -332,42 +332,7 @@ EXTERNOGLEXT(PFNGLDELETERENDERBUFFERSEXTPROC, glDeleteRenderbuffersEXT)
// modification. In other words, these are one-to-one drop-in replacements. // modification. In other words, these are one-to-one drop-in replacements.
typedef GLclampf GLclampd; typedef GLclampf GLclampd;
#define glClearDepth(depth) glClearDepthf(depth) #define glClearDepth(depth) glClearDepthf(depth)
#ifdef OPENGL_VARIANT_ES
#define glDrawBuffer glDrawBufferES
static inline void glDrawBufferES(GLenum theAttachment)
{
GLenum bufs[4] = { GL_NONE, GL_NONE, GL_NONE, GL_NONE };
switch (theAttachment)
{
case GL_NONE:
glDrawBuffers(1, bufs);
return;
case GL_COLOR_ATTACHMENT0:
case GL_COLOR_ATTACHMENT1:
case GL_COLOR_ATTACHMENT2:
case GL_COLOR_ATTACHMENT3:
{
const GLsizei i = theAttachment - GL_COLOR_ATTACHMENT0;
bufs[i] = theAttachment;
glDrawBuffers(i+1, bufs);
return;
}
default:
return;
}
}
#else
#define glDrawBuffer glDrawBufferDESMUME
static inline void glDrawBufferDESMUME(GLenum theAttachment)
{
GLenum bufs[] = { theAttachment };
glDrawBuffers(1, bufs);
}
#endif
// 1D textures may not exist for a particular OpenGL variant, so they will be promoted to // 1D textures may not exist for a particular OpenGL variant, so they will be promoted to
// 2D textures instead. Implementations need to modify their GLSL shaders accordingly to // 2D textures instead. Implementations need to modify their GLSL shaders accordingly to
// treat any 1D textures as 2D textures instead. // treat any 1D textures as 2D textures instead.
@ -824,6 +789,41 @@ extern void (*OGLCreateRenderer_ES_3_0_Func)(OpenGLRenderer **rendererPtr);
bool IsOpenGLDriverVersionSupported(unsigned int checkVersionMajor, unsigned int checkVersionMinor, unsigned int checkVersionRevision); bool IsOpenGLDriverVersionSupported(unsigned int checkVersionMajor, unsigned int checkVersionMinor, unsigned int checkVersionRevision);
#define glDrawBuffer(theAttachment) glDrawBufferDESMUME((theAttachment), this->_variantID)
static inline void glDrawBufferDESMUME(GLenum theAttachment, const OpenGLVariantID variantID)
{
GLenum bufs[4] = { GL_NONE, GL_NONE, GL_NONE, GL_NONE };
if (variantID & OpenGLVariantFamily_ES)
{
switch (theAttachment)
{
case GL_NONE:
glDrawBuffers(1, bufs);
return;
case GL_COLOR_ATTACHMENT0:
case GL_COLOR_ATTACHMENT1:
case GL_COLOR_ATTACHMENT2:
case GL_COLOR_ATTACHMENT3:
{
const GLsizei i = theAttachment - GL_COLOR_ATTACHMENT0;
bufs[i] = theAttachment;
glDrawBuffers(i+1, bufs);
return;
}
default:
return;
}
}
else
{
bufs[0] = theAttachment;
glDrawBuffers(1, bufs);
}
}
class OpenGLTexture : public Render3DTexture class OpenGLTexture : public Render3DTexture
{ {
protected: protected: