mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-31 03:45:38 +00:00
OpenGLHostDisplay: Allow filtering to be toggled for GLES2 path
This commit is contained in:
parent
d455b61d5e
commit
43d1495a63
|
@ -156,6 +156,35 @@ bool OpenGLHostDisplay::DownloadTexture(const void* texture_handle, HostDisplayP
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLHostDisplay::BindDisplayPixelsTexture()
|
||||||
|
{
|
||||||
|
if (m_display_pixels_texture_id == 0)
|
||||||
|
{
|
||||||
|
glGenTextures(1, &m_display_pixels_texture_id);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_display_pixels_texture_id);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_display_linear_filtering ? GL_LINEAR : GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_display_linear_filtering ? GL_LINEAR : GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||||
|
m_display_texture_is_linear_filtered = m_display_linear_filtering;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_display_pixels_texture_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLHostDisplay::UpdateDisplayPixelsTextureFilter()
|
||||||
|
{
|
||||||
|
if (m_display_linear_filtering == m_display_texture_is_linear_filtered)
|
||||||
|
return;
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_display_linear_filtering ? GL_LINEAR : GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_display_linear_filtering ? GL_LINEAR : GL_NEAREST);
|
||||||
|
m_display_texture_is_linear_filtered = m_display_linear_filtering;
|
||||||
|
}
|
||||||
|
|
||||||
bool OpenGLHostDisplay::SupportsDisplayPixelFormat(HostDisplayPixelFormat format) const
|
bool OpenGLHostDisplay::SupportsDisplayPixelFormat(HostDisplayPixelFormat format) const
|
||||||
{
|
{
|
||||||
return (std::get<0>(s_display_pixel_format_mapping[static_cast<u32>(format)]) != static_cast<GLenum>(0));
|
return (std::get<0>(s_display_pixel_format_mapping[static_cast<u32>(format)]) != static_cast<GLenum>(0));
|
||||||
|
@ -183,17 +212,7 @@ bool OpenGLHostDisplay::BeginSetDisplayPixels(HostDisplayPixelFormat format, u32
|
||||||
*out_buffer = map.pointer;
|
*out_buffer = map.pointer;
|
||||||
*out_pitch = stride;
|
*out_pitch = stride;
|
||||||
|
|
||||||
if (m_display_pixels_texture_id == 0)
|
BindDisplayPixelsTexture();
|
||||||
{
|
|
||||||
glGenTextures(1, &m_display_pixels_texture_id);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_display_pixels_texture_id);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_pixels_texture_id)), format, width, height,
|
SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_pixels_texture_id)), format, width, height,
|
||||||
0, 0, width, height);
|
0, 0, width, height);
|
||||||
return true;
|
return true;
|
||||||
|
@ -223,20 +242,7 @@ void OpenGLHostDisplay::EndSetDisplayPixels()
|
||||||
bool OpenGLHostDisplay::SetDisplayPixels(HostDisplayPixelFormat format, u32 width, u32 height, const void* buffer,
|
bool OpenGLHostDisplay::SetDisplayPixels(HostDisplayPixelFormat format, u32 width, u32 height, const void* buffer,
|
||||||
u32 pitch)
|
u32 pitch)
|
||||||
{
|
{
|
||||||
if (m_display_pixels_texture_id == 0)
|
BindDisplayPixelsTexture();
|
||||||
{
|
|
||||||
glGenTextures(1, &m_display_pixels_texture_id);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_display_pixels_texture_id);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_display_pixels_texture_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto [gl_internal_format, gl_format, gl_type] = s_display_pixel_format_mapping[static_cast<u32>(format)];
|
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 u32 pixel_size = GetDisplayPixelFormatSize(format);
|
||||||
|
@ -789,6 +795,9 @@ void OpenGLHostDisplay::RenderDisplay(s32 left, s32 bottom, s32 width, s32 heigh
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (static_cast<GLuint>(reinterpret_cast<uintptr_t>(texture_handle)) == m_display_pixels_texture_id)
|
||||||
|
UpdateDisplayPixelsTextureFilter();
|
||||||
|
|
||||||
DrawFullscreenQuadES2(m_display_texture_view_x, m_display_texture_view_y, m_display_texture_view_width,
|
DrawFullscreenQuadES2(m_display_texture_view_x, m_display_texture_view_y, m_display_texture_view_width,
|
||||||
m_display_texture_view_height, m_display_texture_width, m_display_texture_height);
|
m_display_texture_view_height, m_display_texture_width, m_display_texture_height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,9 @@ protected:
|
||||||
virtual void DestroyImGuiContext() override;
|
virtual void DestroyImGuiContext() override;
|
||||||
virtual bool UpdateImGuiFontTexture() override;
|
virtual bool UpdateImGuiFontTexture() override;
|
||||||
|
|
||||||
|
void BindDisplayPixelsTexture();
|
||||||
|
void UpdateDisplayPixelsTextureFilter();
|
||||||
|
|
||||||
void RenderDisplay();
|
void RenderDisplay();
|
||||||
void RenderImGui();
|
void RenderImGui();
|
||||||
void RenderSoftwareCursor();
|
void RenderSoftwareCursor();
|
||||||
|
@ -116,6 +119,7 @@ protected:
|
||||||
std::unique_ptr<GL::StreamBuffer> m_post_processing_ubo;
|
std::unique_ptr<GL::StreamBuffer> m_post_processing_ubo;
|
||||||
std::vector<PostProcessingStage> m_post_processing_stages;
|
std::vector<PostProcessingStage> m_post_processing_stages;
|
||||||
|
|
||||||
|
bool m_display_texture_is_linear_filtered = false;
|
||||||
bool m_use_gles2_draw_path = false;
|
bool m_use_gles2_draw_path = false;
|
||||||
std::vector<u8> m_gles2_pixels_repack_buffer;
|
std::vector<u8> m_gles2_pixels_repack_buffer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue