From bcd693be6f6c94d318147d003653cdc1e0db2e89 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 1 May 2019 17:29:11 +0100 Subject: [PATCH] Set texture filtering to NEAREST when copying images for initial states --- renderdoc/driver/gl/gl_initstate.cpp | 36 +++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/gl/gl_initstate.cpp b/renderdoc/driver/gl/gl_initstate.cpp index 6369f3741..d056a319c 100644 --- a/renderdoc/driver/gl/gl_initstate.cpp +++ b/renderdoc/driver/gl/gl_initstate.cpp @@ -829,6 +829,17 @@ void GLResourceManager::PrepareTextureInitialContents(ResourceId liveid, Resourc GL.glTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_MAX_LEVEL, (GLint *)&maxlevel); + // set min/mag filters to NEAREST since we are doing an identity copy. Avoids issues where the + // spec says that e.g. integer or stencil textures cannot have a LINEAR filter + if(!ms) + { + GLenum nearest = eGL_NEAREST; + GL.glTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_MIN_FILTER, + (GLint *)&nearest); + GL.glTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_MAG_FILTER, + (GLint *)&nearest); + } + bool iscomp = IsCompressedFormat(details.internalFormat); bool avoidCopySubImage = false; @@ -958,6 +969,14 @@ void GLResourceManager::PrepareTextureInitialContents(ResourceId liveid, Resourc GL.glTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_MAX_LEVEL, (GLint *)&state.maxLevel); + + if(!ms) + { + GL.glTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_MIN_FILTER, + (GLint *)&state.minFilter); + GL.glTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_MAG_FILTER, + (GLint *)&state.magFilter); + } } initContents.resource = GLResource(res.ContextShareGroup, eResTexture, tex); @@ -1821,6 +1840,9 @@ void GLResourceManager::Apply_InitialState(GLResource live, GLInitialContents in { GLuint tex = initial.resource.name; + bool ms = (details.curType == eGL_TEXTURE_2D_MULTISAMPLE || + details.curType == eGL_TEXTURE_2D_MULTISAMPLE_ARRAY); + if(initial.resource != GLResource(MakeNullResource) && tex != 0) { int mips = GetNumMips(details.curType, tex, details.width, details.height, details.depth); @@ -1837,6 +1859,17 @@ void GLResourceManager::Apply_InitialState(GLResource live, GLInitialContents in GL.glTextureParameterivEXT(live.name, details.curType, eGL_TEXTURE_MAX_LEVEL, (GLint *)&maxlevel); + // set min/mag filters to NEAREST since we are doing an identity copy. Avoids issues where + // the spec says that e.g. integer or stencil textures cannot have a LINEAR filter + if(!ms) + { + GLenum nearest = eGL_NEAREST; + GL.glTextureParameterivEXT(live.name, details.curType, eGL_TEXTURE_MIN_FILTER, + (GLint *)&nearest); + GL.glTextureParameterivEXT(live.name, details.curType, eGL_TEXTURE_MAG_FILTER, + (GLint *)&nearest); + } + bool iscomp = IsCompressedFormat(details.internalFormat); bool avoidCopySubImage = false; @@ -1953,9 +1986,6 @@ void GLResourceManager::Apply_InitialState(GLResource live, GLInitialContents in } } - bool ms = (details.curType == eGL_TEXTURE_2D_MULTISAMPLE || - details.curType == eGL_TEXTURE_2D_MULTISAMPLE_ARRAY); - if((state.depthMode == eGL_DEPTH_COMPONENT || state.depthMode == eGL_STENCIL_INDEX) && HasExt[ARB_stencil_texturing]) GL.glTextureParameterivEXT(live.name, details.curType, eGL_DEPTH_STENCIL_TEXTURE_MODE,