diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index b9ae0ca63..9fd188207 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -255,9 +255,6 @@ ALWAYS_INLINE void CopyOutRow16(const u16* src_p template void GPU_SW::CopyOut15Bit(u32 src_x, u32 src_y, u32 width, u32 height, u32 field, bool interlaced, bool interleaved) { - u8* dst_ptr; - u32 dst_stride; - using OutputPixelType = std::conditional_t; @@ -266,16 +263,11 @@ void GPU_SW::CopyOut15Bit(u32 src_x, u32 src_y, u32 width, u32 height, u32 field if (!texture) return; - if (!interlaced) - { - if (!texture->Map(reinterpret_cast(&dst_ptr), &dst_stride, 0, 0, width, height)) - return; - } - else - { - dst_stride = GPU_MAX_DISPLAY_WIDTH * sizeof(OutputPixelType); - dst_ptr = m_display_texture_buffer.data() + (field != 0 ? dst_stride : 0); - } + u32 dst_stride = GPU_MAX_DISPLAY_WIDTH * sizeof(OutputPixelType); + u8* dst_ptr = m_display_texture_buffer.data() + (interlaced ? (field != 0 ? dst_stride : 0) : 0); + + const bool mapped = + (!interlaced && texture->Map(reinterpret_cast(&dst_ptr), &dst_stride, 0, 0, width, height)); const u32 output_stride = dst_stride; const u8 interlaced_shift = BoolToUInt8(interlaced); @@ -315,7 +307,7 @@ void GPU_SW::CopyOut15Bit(u32 src_x, u32 src_y, u32 width, u32 height, u32 field } } - if (!interlaced) + if (mapped) texture->Unmap(); else texture->Update(0, 0, width, height, m_display_texture_buffer.data(), output_stride); @@ -349,9 +341,6 @@ template void GPU_SW::CopyOut24Bit(u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 height, u32 field, bool interlaced, bool interleaved) { - u8* dst_ptr; - u32 dst_stride; - using OutputPixelType = std::conditional_t; @@ -360,16 +349,10 @@ void GPU_SW::CopyOut24Bit(u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 heigh if (!texture) return; - if (!interlaced) - { - if (!texture->Map(reinterpret_cast(&dst_ptr), &dst_stride, 0, 0, width, height)) - return; - } - else - { - dst_stride = Common::AlignUpPow2(width * sizeof(OutputPixelType), 4); - dst_ptr = m_display_texture_buffer.data() + (field != 0 ? dst_stride : 0); - } + u32 dst_stride = Common::AlignUpPow2(width * sizeof(OutputPixelType), 4); + u8* dst_ptr = m_display_texture_buffer.data() + (interlaced ? (field != 0 ? dst_stride : 0) : 0); + const bool mapped = + (!interlaced && texture->Map(reinterpret_cast(&dst_ptr), &dst_stride, 0, 0, width, height)); const u32 output_stride = dst_stride; const u8 interlaced_shift = BoolToUInt8(interlaced); @@ -473,7 +456,7 @@ void GPU_SW::CopyOut24Bit(u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 heigh } } - if (!interlaced) + if (mapped) texture->Unmap(); else texture->Update(0, 0, width, height, m_display_texture_buffer.data(), output_stride); diff --git a/src/util/opengl_device.cpp b/src/util/opengl_device.cpp index 7b4a4441f..dce4366e8 100644 --- a/src/util/opengl_device.cpp +++ b/src/util/opengl_device.cpp @@ -395,7 +395,7 @@ bool OpenGLDevice::CheckFeatures(bool* buggy_pbo) const bool is_shitty_mobile_driver = (vendor_id_powervr || vendor_id_qualcomm || vendor_id_arm); const bool is_buggy_pbo = (!GLAD_GL_VERSION_4_4 && !GLAD_GL_ARB_buffer_storage && !GLAD_GL_EXT_buffer_storage) || is_shitty_mobile_driver; - *buggy_pbo = true;// is_buggy_pbo; + *buggy_pbo = is_buggy_pbo; if (is_buggy_pbo && !is_shitty_mobile_driver) Log_WarningPrint("Not using PBOs for texture uploads because buffer_storage is unavailable."); diff --git a/src/util/opengl_texture.cpp b/src/util/opengl_texture.cpp index 352d7863f..e71d68cbd 100644 --- a/src/util/opengl_texture.cpp +++ b/src/util/opengl_texture.cpp @@ -205,7 +205,7 @@ bool OpenGLTexture::Update(u32 x, u32 y, u32 width, u32 height, const void* data { GL_INS("Not using PBO for map size %u", map_size); glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize()); - glTextureSubImage2D(target, layer, x, y, width, height, gl_format, gl_type, data); + glTexSubImage2D(target, layer, x, y, width, height, gl_format, gl_type, data); } else { @@ -215,8 +215,8 @@ bool OpenGLTexture::Update(u32 x, u32 y, u32 width, u32 height, const void* data sb->Bind(); glPixelStorei(GL_UNPACK_ROW_LENGTH, preferred_pitch / GetPixelSize()); - glTextureSubImage2D(GL_TEXTURE_2D, layer, x, y, width, height, gl_format, gl_type, - reinterpret_cast(static_cast(map.buffer_offset))); + glTexSubImage2D(GL_TEXTURE_2D, layer, x, y, width, height, gl_format, gl_type, + reinterpret_cast(static_cast(map.buffer_offset))); sb->Unbind(); } @@ -261,7 +261,7 @@ void OpenGLTexture::Unmap() sb->Unmap(upload_size); sb->Bind(); - glPixelStorei(GL_UNPACK_ROW_LENGTH, m_map_width); + glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize()); OpenGLDevice::BindUpdateTextureUnit();