Something I'm stumbling quite often is with workaround code that today is probably useless.
For example:
Code: Select all
mStateCacheManager->setDisabled(GL_SCISSOR_TEST);
// GL requires you to reset the scissor when disabling
w = mActiveViewport->getActualWidth();
h = mActiveViewport->getActualHeight();
x = mActiveViewport->getActualLeft();
if (flipping)
y = mActiveViewport->getActualTop();
else
y = targetHeight - mActiveViewport->getActualTop() - h;
OGRE_CHECK_GL_ERROR(glScissor(static_cast<GLsizei>(x),
static_cast<GLsizei>(y),
static_cast<GLsizei>(w),
static_cast<GLsizei>(h)));
So, clearly, calling glScissor after glDisable(GL_SCISSOR_TEST) is unnecessary.When the scissor test is disabled, it is as though the scissor box includes the entire window.
Either the guy who wrote this didn't knew the spec well, or he was workarounding a non-compliant buggy driver.
Who knows how long this bug was there? If by 2014 this bug has been erradicated from all OpenGL drivers, we're just left with an inefficient code adding API overhead.
So... I SAY NO TO WORKAROUNDS! We can't let drivers dictate the terms and then make us look bad when they're done fixing it.
From now on, we should follow a couple rules:
1. (Dekstop) Avoid workarounds. If the driver is buggy, it's their job to correct it. Bug the vendor's driver team to fix it. They usually do it. Let's keep a list of hall of shame until they fix it; blaming them instead of us. Desktop users are used to installing latest drivers, so this is not a long term problem, rather very short term.
If the bug is critical (i.e. affects many systems or many vendors, breaks too much compatibility, it is very noticeable, could put a lot of blame on us), go to rule 2.
1. (Mobile) Prefer avoiding workarounds if possible. But Android ES drivers are a minefield, and they can take ages to be updated with the proper fix (if the bug is ever fixed). So this rule is much more lax. Go to rule 2.
2. Enclose the workaround in a macro and define the macro in OgreGL3PlusPrerequisites.h/OgreGLES2Prerequisites.h
Then document the workaround:
Code: Select all
//glScissor rectangle needs to be reset even after glDisable(GL_SCISSOR_TEST); otherwise it still gets scissored
//First seen: YYYY/MM/DD
//Last seen: YYYY/MM/DD
//Driver: nv_gl.dll 1.2.3456
//GPU: GeForce NNN
#define OGRE_GL3_WORKAROUND_1
Code: Select all
#ifdef OGRE_GL3_WORKAROUND_1
/* .. workaround code here .. */
#endif
And more importantly, we can track each bit of workaround code and enable/disable on demand (and if too old, get removed)
Any feedback?