Add a vendor check to avoid querying GL_POLYGON_MODE on AMD

This commit is contained in:
baldurk
2014-12-14 12:17:38 +00:00
parent e1d01970c6
commit a984352b74
5 changed files with 47 additions and 7 deletions
+25
View File
@@ -150,6 +150,7 @@ void DoVendorChecks(const GLHookSet &gl, GLWindowingData context)
else if(compSize == 48)
{
VendorCheck[VendorCheck_EXT_compressed_cube_size] = true;
RDCWARN("Compressed cubemap size returns whole cubemap");
}
else
{
@@ -159,6 +160,25 @@ void DoVendorChecks(const GLHookSet &gl, GLWindowingData context)
gl.glDeleteTextures(1, &dummy);
}
if(gl.glGetIntegerv && gl.glGetError)
{
// clear all error flags.
GLenum err = gl.glGetError();
while(err != eGL_NONE) err = gl.glGetError();
GLint dummy[2] = {0};
gl.glGetIntegerv(eGL_POLYGON_MODE, dummy);
err = gl.glGetError();
if(err != eGL_NONE)
{
// if we got an error trying to query that, we should enable this hack
VendorCheck[VendorCheck_AMD_polygon_mode_query] = true;
RDCWARN("Using AMD hack to avoid GL_POLYGON_MODE");
}
}
// only do this when we have a proper context e.g. on windows where an old
// context is first created. Check to see if FBOs or VAOs are shared between
// contexts.
@@ -186,6 +206,11 @@ void DoVendorChecks(const GLHookSet &gl, GLWindowingData context)
VendorCheck[VendorCheck_EXT_fbo_shared] = (gl.glIsFramebuffer(fbo) != GL_FALSE);
VendorCheck[VendorCheck_EXT_vao_shared] = (gl.glIsVertexArray(vao) != GL_FALSE);
if(VendorCheck[VendorCheck_EXT_fbo_shared])
RDCWARN("FBOs are shared on this implementation");
if(VendorCheck[VendorCheck_EXT_vao_shared])
RDCWARN("VAOs are shared on this implementation");
// switch back to context
MakeContextCurrent(context);
+1
View File
@@ -109,6 +109,7 @@ enum VendorCheckEnum
VendorCheck_NV_avoid_D32S8_copy,
VendorCheck_EXT_fbo_shared,
VendorCheck_EXT_vao_shared,
VendorCheck_AMD_polygon_mode_query,
VendorCheck_Count,
};
extern bool VendorCheck[VendorCheck_Count];
+4 -2
View File
@@ -1273,7 +1273,8 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, TextureDisplayOverlay overl
GLint depthTest = GL_FALSE;
gl.glGetIntegerv(eGL_DEPTH_TEST, (GLint*)&depthTest);
GLenum polyMode = eGL_FILL;
gl.glGetIntegerv(eGL_POLYGON_MODE, (GLint*)&polyMode);
if(!VendorCheck[VendorCheck_AMD_polygon_mode_query])
gl.glGetIntegerv(eGL_POLYGON_MODE, (GLint*)&polyMode);
gl.glDisable(eGL_DEPTH_TEST);
gl.glPolygonMode(eGL_FRONT_AND_BACK, eGL_LINE);
@@ -1468,7 +1469,8 @@ void GLReplay::RenderMesh(uint32_t frameID, const vector<uint32_t> &events, Mesh
GLint depthTest = GL_FALSE;
gl.glGetIntegerv(eGL_DEPTH_TEST, (GLint*)&depthTest);
GLenum polyMode = eGL_FILL;
gl.glGetIntegerv(eGL_POLYGON_MODE, (GLint*)&polyMode);
if(!VendorCheck[VendorCheck_AMD_polygon_mode_query])
gl.glGetIntegerv(eGL_POLYGON_MODE, (GLint*)&polyMode);
gl.glDisable(eGL_DEPTH_TEST);
gl.glPolygonMode(eGL_FRONT_AND_BACK, eGL_LINE);
+12 -5
View File
@@ -907,11 +907,18 @@ struct RenderTextState
gl.glGetIntegeri_v(eGL_BLEND_DST_RGB, 0, (GLint*)&DestinationRGB);
gl.glGetIntegeri_v(eGL_BLEND_DST_ALPHA, 0, (GLint*)&DestinationAlpha);
GLenum dummy[2] = { eGL_FILL, eGL_FILL };
// docs suggest this is enumeration[2] even though polygon mode can't be set independently for front
// and back faces.
gl.glGetIntegerv(eGL_POLYGON_MODE, (GLint *)&dummy);
PolygonMode = dummy[0];
if(!VendorCheck[VendorCheck_AMD_polygon_mode_query])
{
GLenum dummy[2] = { eGL_FILL, eGL_FILL };
// docs suggest this is enumeration[2] even though polygon mode can't be set independently for front
// and back faces.
gl.glGetIntegerv(eGL_POLYGON_MODE, (GLint *)&dummy);
PolygonMode = dummy[0];
}
else
{
PolygonMode = eGL_FILL;
}
gl.glGetFloati_v(eGL_VIEWPORT, 0, &Viewport[0]);
+5
View File
@@ -278,6 +278,7 @@ void GLRenderState::FetchState(void *ctx, WrappedOpenGL *gl)
m_Real->glGetFloatv(eGL_PATCH_DEFAULT_INNER_LEVEL, &PatchParams.defaultInnerLevel[0]);
m_Real->glGetFloatv(eGL_PATCH_DEFAULT_OUTER_LEVEL, &PatchParams.defaultOuterLevel[0]);
if(!VendorCheck[VendorCheck_AMD_polygon_mode_query])
{
// This was listed in docs as enumeration[2] even though polygon mode can't be set independently for front
// and back faces for a while, so pass large enough array to be sure.
@@ -287,6 +288,10 @@ void GLRenderState::FetchState(void *ctx, WrappedOpenGL *gl)
m_Real->glGetIntegerv(eGL_POLYGON_MODE, (GLint *)&dummy);
PolygonMode = dummy[0];
}
else
{
PolygonMode = eGL_FILL;
}
m_Real->glGetFloatv(eGL_POLYGON_OFFSET_FACTOR, &PolygonOffset[0]);
m_Real->glGetFloatv(eGL_POLYGON_OFFSET_UNITS, &PolygonOffset[1]);