From e83c387ebe3d22333ceef766b882651c18a252ee Mon Sep 17 00:00:00 2001 From: DHrpcs3 Date: Tue, 21 Jun 2016 00:39:44 +0300 Subject: [PATCH] OpenGL renderer: Fixed texture bias setup. --- rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp | 54 +++++++++++++++-------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp b/rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp index 8c811ea9f1..3c5928df48 100644 --- a/rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp +++ b/rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp @@ -409,10 +409,13 @@ namespace rsx const u32 texaddr = rsx::get_address(tex.offset(), tex.location()); //We can't re-use texture handles if using immutable storage - if (m_id) remove(); - create(); + if (m_id) + { + __glcheck remove(); + } + __glcheck create(); - glActiveTexture(GL_TEXTURE0 + index); + __glcheck glActiveTexture(GL_TEXTURE0 + index); bind(); u32 full_format = tex.format(); @@ -420,8 +423,8 @@ namespace rsx u32 format = full_format & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); bool is_swizzled = !!(~full_format & CELL_GCM_TEXTURE_LN); - ::gl::pixel_pack_settings().apply(); - ::gl::pixel_unpack_settings().apply(); + __glcheck ::gl::pixel_pack_settings().apply(); + __glcheck ::gl::pixel_unpack_settings().apply(); u32 aligned_pitch = tex.pitch(); @@ -429,8 +432,8 @@ namespace rsx std::vector data_upload_buf(texture_data_sz); u32 block_sz = get_pitch_modifier(format); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - create_and_fill_texture(tex.get_extended_texture_dimension(), tex.get_exact_mipmap_count(), format, tex.width(), tex.height(), tex.depth(), get_subresources_layout(tex), is_swizzled, data_upload_buf); + __glcheck glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + __glcheck create_and_fill_texture(tex.get_extended_texture_dimension(), tex.get_exact_mipmap_count(), format, tex.width(), tex.height(), tex.depth(), get_subresources_layout(tex), is_swizzled, data_upload_buf); const std::array& glRemap = get_swizzle_remap(format); @@ -443,29 +446,28 @@ namespace rsx u8 remap_g = (tex.remap() >> 4) & 0x3; u8 remap_b = (tex.remap() >> 6) & 0x3; - glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_A, glRemap[remap_a]); - glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_R, glRemap[remap_r]); - glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_G, glRemap[remap_g]); - glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_B, glRemap[remap_b]); + __glcheck glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_A, glRemap[remap_a]); + __glcheck glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_R, glRemap[remap_r]); + __glcheck glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_G, glRemap[remap_g]); + __glcheck glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_B, glRemap[remap_b]); } else { - - glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_A, glRemap[0]); - glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_R, glRemap[1]); - glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_G, glRemap[2]); - glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_B, glRemap[3]); + __glcheck glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_A, glRemap[0]); + __glcheck glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_R, glRemap[1]); + __glcheck glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_G, glRemap[2]); + __glcheck glTexParameteri(m_target, GL_TEXTURE_SWIZZLE_B, glRemap[3]); } - glTexParameteri(m_target, GL_TEXTURE_WRAP_S, gl_wrap(tex.wrap_s())); - glTexParameteri(m_target, GL_TEXTURE_WRAP_T, gl_wrap(tex.wrap_t())); - glTexParameteri(m_target, GL_TEXTURE_WRAP_R, gl_wrap(tex.wrap_r())); + __glcheck glTexParameteri(m_target, GL_TEXTURE_WRAP_S, gl_wrap(tex.wrap_s())); + __glcheck glTexParameteri(m_target, GL_TEXTURE_WRAP_T, gl_wrap(tex.wrap_t())); + __glcheck glTexParameteri(m_target, GL_TEXTURE_WRAP_R, gl_wrap(tex.wrap_r())); - glTexParameteri(m_target, GL_TEXTURE_COMPARE_FUNC, gl_tex_zfunc[tex.zfunc()]); + __glcheck glTexParameteri(m_target, GL_TEXTURE_COMPARE_FUNC, gl_tex_zfunc[tex.zfunc()]); - glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, tex.bias()); - glTexParameteri(m_target, GL_TEXTURE_MIN_LOD, (tex.min_lod() >> 8)); - glTexParameteri(m_target, GL_TEXTURE_MAX_LOD, (tex.max_lod() >> 8)); + __glcheck glTexParameterf(m_target, GL_TEXTURE_LOD_BIAS, tex.bias()); + __glcheck glTexParameteri(m_target, GL_TEXTURE_MIN_LOD, (tex.min_lod() >> 8)); + __glcheck glTexParameteri(m_target, GL_TEXTURE_MAX_LOD, (tex.max_lod() >> 8)); int min_filter = gl_tex_min_filter(tex.min_filter()); @@ -478,9 +480,9 @@ namespace rsx } } - glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, min_filter); - glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, gl_tex_mag_filter(tex.mag_filter())); - glTexParameterf(m_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_aniso(tex.max_aniso())); + __glcheck glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, min_filter); + __glcheck glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, gl_tex_mag_filter(tex.mag_filter())); + __glcheck glTexParameterf(m_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_aniso(tex.max_aniso())); } void texture::bind()