OpenGLHostDisplay: Fix interlaced software renderer output

This commit is contained in:
Connor McLaughlin 2021-02-05 02:16:45 +10:00
parent 7b4650700f
commit d455b61d5e
2 changed files with 26 additions and 1 deletions

View file

@ -2,6 +2,7 @@
#include "common/align.h"
#include "common/assert.h"
#include "common/log.h"
#include "common/string_util.h"
#include "imgui.h"
#include "imgui_impl_opengl3.h"
#include "postprocessing_shadergen.h"
@ -238,9 +239,32 @@ bool OpenGLHostDisplay::SetDisplayPixels(HostDisplayPixelFormat format, u32 widt
}
const auto [gl_internal_format, gl_format, gl_type] = s_display_pixel_format_mapping[static_cast<u32>(format)];
const u32 pixel_size = GetDisplayPixelFormatSize(format);
const bool is_packed_tightly = (pitch == (pixel_size * width));
// If we have GLES3, we can set row_length.
if (!m_use_gles2_draw_path || is_packed_tightly)
{
if (!is_packed_tightly)
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / pixel_size);
glTexImage2D(GL_TEXTURE_2D, 0, gl_internal_format, width, height, 0, gl_format, gl_type, buffer);
if (!is_packed_tightly)
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
else
{
// Otherwise, we need to repack the image.
const u32 packed_pitch = width * pixel_size;
const u32 repack_size = packed_pitch * height;
if (m_gles2_pixels_repack_buffer.size() < repack_size)
m_gles2_pixels_repack_buffer.resize(repack_size);
StringUtil::StrideMemCpy(m_gles2_pixels_repack_buffer.data(), packed_pitch, buffer, pitch, packed_pitch, height);
glTexImage2D(GL_TEXTURE_2D, 0, gl_internal_format, width, height, 0, gl_format, gl_type,
m_gles2_pixels_repack_buffer.data());
}
glBindTexture(GL_TEXTURE_2D, 0);
SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_pixels_texture_id)), format, width, height,

View file

@ -117,6 +117,7 @@ protected:
std::vector<PostProcessingStage> m_post_processing_stages;
bool m_use_gles2_draw_path = false;
std::vector<u8> m_gles2_pixels_repack_buffer;
};
} // namespace FrontendCommon