gl_rasterizer/cache: only reallocate cubemap when size/format mismatch

This commit is contained in:
wwylele 2018-03-11 13:31:29 +02:00
parent 15e8664ef7
commit 889d8aaab3

View File

@ -1264,10 +1264,18 @@ void RasterizerCacheOpenGL::FillTextureCube(GLuint dest_handle,
state.Apply(); state.Apply();
glActiveTexture(TextureUnits::TextureCube.Enum()); glActiveTexture(TextureUnits::TextureCube.Enum());
FormatTuple format_tuple = GetFormatTuple(faces[0].surface->pixel_format); FormatTuple format_tuple = GetFormatTuple(faces[0].surface->pixel_format);
GLint cur_size, cur_format;
glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_TEXTURE_WIDTH, &cur_size);
glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_TEXTURE_INTERNAL_FORMAT,
&cur_format);
if (cur_size != scaled_size || cur_format != format_tuple.internal_format) {
for (auto& face : faces) { for (auto& face : faces) {
glTexImage2D(face.gl_face, 0, format_tuple.internal_format, scaled_size, scaled_size, 0, glTexImage2D(face.gl_face, 0, format_tuple.internal_format, scaled_size, scaled_size, 0,
format_tuple.format, format_tuple.type, nullptr); format_tuple.format, format_tuple.type, nullptr);
} }
}
state.draw.read_framebuffer = read_framebuffer.handle; state.draw.read_framebuffer = read_framebuffer.handle;
state.draw.draw_framebuffer = draw_framebuffer.handle; state.draw.draw_framebuffer = draw_framebuffer.handle;