handle all cases more robustly

This commit is contained in:
BreadFish64 2020-06-20 12:52:58 -05:00
parent d04071d6b3
commit b80c6f7534
1 changed files with 16 additions and 9 deletions

View File

@ -777,16 +777,27 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) {
}
OGLTexture temp_tex;
if (need_texture_barrier && GLES) {
if (need_texture_barrier) {
temp_tex.Create();
AllocateSurfaceTexture(temp_tex.handle, GetFormatTuple(color_surface->pixel_format),
color_surface->GetScaledWidth(), color_surface->GetScaledHeight());
glCopyImageSubData(color_surface->texture.handle, GL_TEXTURE_2D, 0, 0, 0, 0,
temp_tex.handle, GL_TEXTURE_2D, 0, 0, 0, 0, color_surface->GetScaledWidth(),
color_surface->GetScaledHeight(), 1);
for (std::size_t mip{0}; mip <= color_surface->max_level; ++mip) {
glCopyImageSubData(color_surface->texture.handle, GL_TEXTURE_2D, mip, 0, 0, 0,
temp_tex.handle, GL_TEXTURE_2D, mip, 0, 0, 0,
color_surface->GetScaledWidth() >> mip,
color_surface->GetScaledHeight() >> mip, 1);
}
for (auto& unit : state.texture_units) {
if (unit.texture_2d == color_surface->texture.handle)
if (unit.texture_2d == color_surface->texture.handle) {
unit.texture_2d = temp_tex.handle;
}
}
for (auto shadow_unit : {&state.image_shadow_texture_nx, &state.image_shadow_texture_ny,
&state.image_shadow_texture_nz, &state.image_shadow_texture_px,
&state.image_shadow_texture_py, &state.image_shadow_texture_pz}) {
if (*shadow_unit == color_surface->texture.handle) {
*shadow_unit = temp_tex.handle;
}
}
}
@ -864,10 +875,6 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) {
GL_TEXTURE_UPDATE_BARRIER_BIT | GL_FRAMEBUFFER_BARRIER_BIT);
}
if (need_texture_barrier && GLAD_GL_ARB_texture_barrier) {
glTextureBarrier();
}
// Mark framebuffer surfaces as dirty
Common::Rectangle<u32> draw_rect_unscaled{draw_rect.left / res_scale, draw_rect.top / res_scale,
draw_rect.right / res_scale,