From 89a3da217132c68ae6c08c18f4d1e6c421ba92bf Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 6 Jul 2018 11:13:10 +0100 Subject: [PATCH] Check for ARB_texture_multisample being available * We need to hack around GLES, as it somehow added only part of the original extension - non-arrayed textures. So we conceptually split up the extension into two, and treat the real extension as a superset. --- renderdoc/driver/gl/gl_common.h | 6 ++++ renderdoc/driver/gl/gl_renderstate.cpp | 38 ++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h index 9e45dbe34..e0dca7693 100644 --- a/renderdoc/driver/gl/gl_common.h +++ b/renderdoc/driver/gl/gl_common.h @@ -584,6 +584,12 @@ extern bool IsGLES; EXT_TO_CHECK(30, 30, EXT_transform_feedback) \ EXT_TO_CHECK(30, 32, EXT_draw_buffers2) \ EXT_TO_CHECK(31, 99, ARB_texture_buffer_object) \ + /* This is a hack, the extension doesn't exist but is */ \ + /* equivalent to GLES 3.1's addition of MSAA textures but */ \ + /* NOT array MSAA textures. We'll treat the real ext as a */ \ + /* super-set. */ \ + EXT_TO_CHECK(32, 31, ARB_texture_multisample_no_array) \ + EXT_TO_CHECK(32, 32, ARB_texture_multisample) \ EXT_TO_CHECK(33, 30, ARB_explicit_attrib_location) \ EXT_TO_CHECK(33, 30, ARB_sampler_objects) \ EXT_TO_CHECK(33, 30, ARB_texture_swizzle) \ diff --git a/renderdoc/driver/gl/gl_renderstate.cpp b/renderdoc/driver/gl/gl_renderstate.cpp index 42ff838f7..f2e49d847 100644 --- a/renderdoc/driver/gl/gl_renderstate.cpp +++ b/renderdoc/driver/gl/gl_renderstate.cpp @@ -666,6 +666,9 @@ bool GLRenderState::CheckEnableDisableParam(GLenum pname) // see DoVendorChecks() return false; + case eGL_SAMPLE_MASK: + return HasExt[ARB_texture_multisample_no_array] || HasExt[ARB_texture_multisample]; + case eGL_CLIP_DISTANCE0: case eGL_CLIP_DISTANCE1: case eGL_CLIP_DISTANCE2: @@ -785,8 +788,15 @@ void GLRenderState::FetchState(WrappedOpenGL *driver) else TexBuffer[i].name = 0; - GL.glGetIntegerv(eGL_TEXTURE_BINDING_2D_MULTISAMPLE, (GLint *)&Tex2DMS[i].name); - GL.glGetIntegerv(eGL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY, (GLint *)&Tex2DMSArray[i].name); + if(HasExt[ARB_texture_multisample_no_array] || HasExt[ARB_texture_multisample]) + GL.glGetIntegerv(eGL_TEXTURE_BINDING_2D_MULTISAMPLE, (GLint *)&Tex2DMS[i].name); + else + Tex2DMS[i].name = 0; + + if(HasExt[ARB_texture_multisample]) + GL.glGetIntegerv(eGL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY, (GLint *)&Tex2DMSArray[i].name); + else + Tex2DMSArray[i].name = 0; if(HasExt[ARB_texture_cube_map_array]) GL.glGetIntegerv(eGL_TEXTURE_BINDING_CUBE_MAP_ARRAY, (GLint *)&TexCubeArray[i].name); @@ -1196,7 +1206,9 @@ void GLRenderState::FetchState(WrappedOpenGL *driver) memcpy(&ColorMasks[i], &ColorMasks[0], sizeof(ColorMask)); } - GL.glGetIntegeri_v(eGL_SAMPLE_MASK_VALUE, 0, (GLint *)&SampleMask[0]); + if(HasExt[ARB_texture_multisample_no_array] || HasExt[ARB_texture_multisample]) + GL.glGetIntegeri_v(eGL_SAMPLE_MASK_VALUE, 0, (GLint *)&SampleMask[0]); + GL.glGetIntegerv(eGL_SAMPLE_COVERAGE_VALUE, (GLint *)&SampleCoverage); { @@ -1300,20 +1312,31 @@ void GLRenderState::ApplyState(WrappedOpenGL *driver) for(GLuint i = 0; i < RDCMIN(maxTextures, (GLuint)ARRAY_COUNT(Tex2D)); i++) { GL.glActiveTexture(GLenum(eGL_TEXTURE0 + i)); + if(!IsGLES) GL.glBindTexture(eGL_TEXTURE_1D, Tex1D[i].name); + GL.glBindTexture(eGL_TEXTURE_2D, Tex2D[i].name); GL.glBindTexture(eGL_TEXTURE_3D, Tex3D[i].name); + if(!IsGLES) GL.glBindTexture(eGL_TEXTURE_1D_ARRAY, Tex1DArray[i].name); + GL.glBindTexture(eGL_TEXTURE_2D_ARRAY, Tex2DArray[i].name); + if(!IsGLES) GL.glBindTexture(eGL_TEXTURE_RECTANGLE, TexRect[i].name); + if(HasExt[ARB_texture_buffer_object]) GL.glBindTexture(eGL_TEXTURE_BUFFER, TexBuffer[i].name); + GL.glBindTexture(eGL_TEXTURE_CUBE_MAP, TexCube[i].name); - GL.glBindTexture(eGL_TEXTURE_2D_MULTISAMPLE, Tex2DMS[i].name); - GL.glBindTexture(eGL_TEXTURE_2D_MULTISAMPLE_ARRAY, Tex2DMSArray[i].name); + + if(HasExt[ARB_texture_multisample_no_array] || HasExt[ARB_texture_multisample]) + GL.glBindTexture(eGL_TEXTURE_2D_MULTISAMPLE, Tex2DMS[i].name); + + if(HasExt[ARB_texture_multisample]) + GL.glBindTexture(eGL_TEXTURE_2D_MULTISAMPLE_ARRAY, Tex2DMSArray[i].name); if(HasExt[ARB_sampler_objects]) GL.glBindSampler(i, Samplers[i].name); @@ -1641,8 +1664,11 @@ void GLRenderState::ApplyState(WrappedOpenGL *driver) GL.glColorMask(ColorMasks[0].red, ColorMasks[0].green, ColorMasks[0].blue, ColorMasks[0].alpha); } - GL.glSampleMaski(0, (GLbitfield)SampleMask[0]); + if(HasExt[ARB_texture_multisample_no_array] || HasExt[ARB_texture_multisample]) + GL.glSampleMaski(0, (GLbitfield)SampleMask[0]); + GL.glSampleCoverage(SampleCoverage, SampleCoverageInvert ? GL_TRUE : GL_FALSE); + if(HasExt[ARB_sample_shading]) GL.glMinSampleShading(MinSampleShading);