Set texture filtering to NEAREST when copying images for initial states

This commit is contained in:
baldurk
2019-05-01 21:11:49 +01:00
parent cce6800f00
commit bcd693be6f
+33 -3
View File
@@ -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,