Make sure texture swizzles match before performing a copy

This commit is contained in:
Dr. Chat 2015-11-14 22:34:34 -06:00
parent e471767f4c
commit 3efc7f339a
1 changed files with 11 additions and 0 deletions

View File

@ -268,6 +268,15 @@ void Blitter::CopyColorTexture2D(GLuint src_texture, Rect2D src_rect,
glDepthMask(GL_FALSE);
glBindProgramPipeline(color_pipeline_);
// Make sure the texture swizzles match before performing a copy
// TODO: Is this a good place for this?
GLint swizzle_map[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}};
glGetTextureParameteriv(src_texture, GL_TEXTURE_SWIZZLE_RGBA, swizzle_map[0]);
glGetTextureParameteriv(dest_texture, GL_TEXTURE_SWIZZLE_RGBA,
swizzle_map[1]);
glTextureParameteriv(src_texture, GL_TEXTURE_SWIZZLE_RGBA, swizzle_map[1]);
glNamedFramebufferTexture(scratch_framebuffer_, GL_COLOR_ATTACHMENT0,
dest_texture, 0);
glNamedFramebufferDrawBuffer(scratch_framebuffer_, GL_COLOR_ATTACHMENT0);
@ -277,6 +286,8 @@ void Blitter::CopyColorTexture2D(GLuint src_texture, Rect2D src_rect,
glNamedFramebufferTexture(scratch_framebuffer_, GL_COLOR_ATTACHMENT0, GL_NONE,
0);
glTextureParameteriv(src_texture, GL_TEXTURE_SWIZZLE_RGBA, swizzle_map[0]);
state.Restore();
}