GPU: Fix display in OpenGL renderer
This commit is contained in:
parent
63064f80c2
commit
e8e44991db
|
@ -521,11 +521,10 @@ void GPU_HW_D3D11::UpdateDisplay()
|
|||
|
||||
if (m_system->GetSettings().debugging.show_vram)
|
||||
{
|
||||
m_host_display->SetDisplayTexture(
|
||||
m_vram_texture.GetD3DSRV(), m_vram_texture.GetWidth(), m_vram_texture.GetHeight(),
|
||||
Common::Rectangle<s32>(0, 0, m_vram_texture.GetWidth(), m_vram_texture.GetHeight()));
|
||||
m_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT,
|
||||
Common::Rectangle<s32>(0, 0, VRAM_WIDTH, VRAM_HEIGHT), 1.0f);
|
||||
m_host_display->SetDisplayTexture(m_vram_texture.GetD3DSRV(), m_vram_texture.GetWidth(), m_vram_texture.GetHeight(),
|
||||
0, 0, m_vram_texture.GetWidth(), m_vram_texture.GetHeight());
|
||||
m_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, Common::Rectangle<s32>(0, 0, VRAM_WIDTH, VRAM_HEIGHT),
|
||||
1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -546,10 +545,9 @@ void GPU_HW_D3D11::UpdateDisplay()
|
|||
}
|
||||
else if (!m_GPUSTAT.display_area_color_depth_24 && !interlaced)
|
||||
{
|
||||
m_host_display->SetDisplayTexture(
|
||||
m_vram_texture.GetD3DSRV(), m_vram_texture.GetWidth(), m_vram_texture.GetHeight(),
|
||||
Common::Rectangle<s32>::FromExtents(scaled_vram_offset_x, scaled_vram_offset_y, scaled_display_width,
|
||||
scaled_display_height));
|
||||
m_host_display->SetDisplayTexture(m_vram_texture.GetD3DSRV(), m_vram_texture.GetWidth(),
|
||||
m_vram_texture.GetHeight(), scaled_vram_offset_x, scaled_vram_offset_y,
|
||||
scaled_display_width, scaled_display_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -575,8 +573,7 @@ void GPU_HW_D3D11::UpdateDisplay()
|
|||
DrawUtilityShader(display_pixel_shader, uniforms, sizeof(uniforms));
|
||||
|
||||
m_host_display->SetDisplayTexture(m_display_texture.GetD3DSRV(), m_display_texture.GetWidth(),
|
||||
m_display_texture.GetHeight(),
|
||||
Common::Rectangle<s32>(0, 0, display_width, display_height));
|
||||
m_display_texture.GetHeight(), 0, 0, display_width, display_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -588,8 +585,8 @@ void GPU_HW_D3D11::UpdateDisplay()
|
|||
DrawUtilityShader(display_pixel_shader, uniforms, sizeof(uniforms));
|
||||
|
||||
m_host_display->SetDisplayTexture(m_display_texture.GetD3DSRV(), m_display_texture.GetWidth(),
|
||||
m_display_texture.GetHeight(),
|
||||
Common::Rectangle<s32>(0, 0, scaled_display_width, scaled_display_height));
|
||||
m_display_texture.GetHeight(), 0, 0, scaled_display_width,
|
||||
scaled_display_height);
|
||||
}
|
||||
|
||||
RestoreGraphicsAPIState();
|
||||
|
|
|
@ -476,12 +476,12 @@ void GPU_HW_OpenGL::UpdateDisplay()
|
|||
|
||||
if (m_system->GetSettings().debugging.show_vram)
|
||||
{
|
||||
m_host_display->SetDisplayTexture(
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture.GetGLId())), m_vram_texture.GetWidth(),
|
||||
-static_cast<s32>(m_vram_texture.GetHeight()),
|
||||
Common::Rectangle<s32>(0, m_vram_texture.GetHeight(), m_vram_texture.GetWidth(), 0));
|
||||
m_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT,
|
||||
Common::Rectangle<s32>(0, 0, VRAM_WIDTH, VRAM_HEIGHT), 1.0f);
|
||||
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture.GetGLId())),
|
||||
m_vram_texture.GetWidth(), static_cast<s32>(m_vram_texture.GetHeight()), 0,
|
||||
m_vram_texture.GetHeight(), m_vram_texture.GetWidth(),
|
||||
-static_cast<s32>(m_vram_texture.GetHeight()));
|
||||
m_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, Common::Rectangle<s32>(0, 0, VRAM_WIDTH, VRAM_HEIGHT),
|
||||
1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -501,11 +501,10 @@ void GPU_HW_OpenGL::UpdateDisplay()
|
|||
}
|
||||
else if (!m_GPUSTAT.display_area_color_depth_24 && !interlaced)
|
||||
{
|
||||
m_host_display->SetDisplayTexture(
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture.GetGLId())), m_vram_texture.GetWidth(),
|
||||
m_vram_texture.GetHeight(),
|
||||
Common::Rectangle<s32>(scaled_vram_offset_x, m_vram_texture.GetHeight() - scaled_vram_offset_y,
|
||||
scaled_display_width, -static_cast<s32>(scaled_display_height)));
|
||||
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture.GetGLId())),
|
||||
m_vram_texture.GetWidth(), m_vram_texture.GetHeight(), scaled_vram_offset_x,
|
||||
m_vram_texture.GetHeight() - scaled_vram_offset_y, scaled_display_width,
|
||||
-static_cast<s32>(scaled_display_height));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -544,10 +543,9 @@ void GPU_HW_OpenGL::UpdateDisplay()
|
|||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
m_host_display->SetDisplayTexture(
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_texture.GetGLId())), m_display_texture.GetWidth(),
|
||||
m_display_texture.GetHeight(),
|
||||
Common::Rectangle<s32>(0, display_height, display_width, -static_cast<s32>(display_height)));
|
||||
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_texture.GetGLId())),
|
||||
m_display_texture.GetWidth(), m_display_texture.GetHeight(), 0,
|
||||
display_height, display_width, -static_cast<s32>(display_height));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -563,9 +561,9 @@ void GPU_HW_OpenGL::UpdateDisplay()
|
|||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_texture.GetGLId())),
|
||||
m_display_texture.GetWidth(), m_display_texture.GetHeight(),
|
||||
Common::Rectangle<s32>(0, scaled_display_height, scaled_display_width,
|
||||
-static_cast<s32>(scaled_display_height)));
|
||||
m_display_texture.GetWidth(), m_display_texture.GetHeight(), 0,
|
||||
scaled_display_height, scaled_display_width,
|
||||
-static_cast<s32>(scaled_display_height));
|
||||
}
|
||||
|
||||
// restore state
|
||||
|
|
|
@ -343,10 +343,10 @@ void GPU_HW_OpenGL_ES::UpdateDisplay()
|
|||
|
||||
if (m_system->GetSettings().debugging.show_vram)
|
||||
{
|
||||
m_host_display->SetDisplayTexture(
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture.GetGLId())), m_vram_texture.GetWidth(),
|
||||
-static_cast<s32>(m_vram_texture.GetHeight()),
|
||||
Common::Rectangle<s32>(0, m_vram_texture.GetHeight(), m_vram_texture.GetWidth(), 0));
|
||||
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture.GetGLId())),
|
||||
m_vram_texture.GetWidth(), static_cast<s32>(m_vram_texture.GetHeight()), 0,
|
||||
m_vram_texture.GetHeight(), m_vram_texture.GetWidth(),
|
||||
-static_cast<s32>(m_vram_texture.GetHeight()));
|
||||
m_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, Common::Rectangle<s32>(0, 0, VRAM_WIDTH, VRAM_HEIGHT),
|
||||
1.0f);
|
||||
}
|
||||
|
@ -368,11 +368,10 @@ void GPU_HW_OpenGL_ES::UpdateDisplay()
|
|||
}
|
||||
else if (!m_GPUSTAT.display_area_color_depth_24 && !interlaced)
|
||||
{
|
||||
m_host_display->SetDisplayTexture(
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture.GetGLId())), m_vram_texture.GetWidth(),
|
||||
m_vram_texture.GetHeight(),
|
||||
Common::Rectangle<s32>(scaled_vram_offset_x, m_vram_texture.GetHeight() - scaled_vram_offset_y,
|
||||
scaled_display_width, -static_cast<s32>(scaled_display_height)));
|
||||
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture.GetGLId())),
|
||||
m_vram_texture.GetWidth(), m_vram_texture.GetHeight(), scaled_vram_offset_x,
|
||||
m_vram_texture.GetHeight() - scaled_vram_offset_y, scaled_display_width,
|
||||
-static_cast<s32>(scaled_display_height));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -411,10 +410,9 @@ void GPU_HW_OpenGL_ES::UpdateDisplay()
|
|||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
m_host_display->SetDisplayTexture(
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_texture.GetGLId())), m_display_texture.GetWidth(),
|
||||
m_display_texture.GetHeight(),
|
||||
Common::Rectangle<s32>(0, display_height, display_width, -static_cast<s32>(display_height)));
|
||||
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_texture.GetGLId())),
|
||||
m_display_texture.GetWidth(), m_display_texture.GetHeight(), 0,
|
||||
display_height, display_width, -static_cast<s32>(display_height));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -430,9 +428,9 @@ void GPU_HW_OpenGL_ES::UpdateDisplay()
|
|||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_texture.GetGLId())),
|
||||
m_display_texture.GetWidth(), m_display_texture.GetHeight(),
|
||||
Common::Rectangle<s32>(0, scaled_display_height, scaled_display_width,
|
||||
-static_cast<s32>(scaled_display_height)));
|
||||
m_display_texture.GetWidth(), m_display_texture.GetHeight(), 0,
|
||||
scaled_display_height, scaled_display_width,
|
||||
-static_cast<s32>(scaled_display_height));
|
||||
}
|
||||
|
||||
// restore state
|
||||
|
|
|
@ -140,8 +140,8 @@ void GPU_SW::UpdateDisplay()
|
|||
|
||||
m_host_display->UpdateTexture(m_display_texture.get(), 0, 0, display_width, display_height,
|
||||
m_display_texture_buffer.data(), display_width * sizeof(u32));
|
||||
m_host_display->SetDisplayTexture(m_display_texture->GetHandle(), VRAM_WIDTH, VRAM_HEIGHT,
|
||||
Common::Rectangle<s32>(0, 0, display_width, display_height));
|
||||
m_host_display->SetDisplayTexture(m_display_texture->GetHandle(), VRAM_WIDTH, VRAM_HEIGHT, 0, 0, display_width,
|
||||
display_height);
|
||||
m_host_display->SetDisplayParameters(m_crtc_state.visible_display_width, m_crtc_state.visible_display_height,
|
||||
m_crtc_state.GetActiveDisplayRectangle(), m_crtc_state.display_aspect_ratio);
|
||||
}
|
||||
|
@ -150,10 +150,10 @@ void GPU_SW::UpdateDisplay()
|
|||
CopyOut15Bit(m_vram.data(), VRAM_WIDTH, m_display_texture_buffer.data(), VRAM_WIDTH, VRAM_HEIGHT, VRAM_HEIGHT);
|
||||
m_host_display->UpdateTexture(m_display_texture.get(), 0, 0, VRAM_WIDTH, VRAM_HEIGHT,
|
||||
m_display_texture_buffer.data(), VRAM_WIDTH * sizeof(u32));
|
||||
m_host_display->SetDisplayTexture(m_display_texture->GetHandle(), VRAM_WIDTH, VRAM_HEIGHT,
|
||||
Common::Rectangle<s32>(0, 0, VRAM_WIDTH, VRAM_HEIGHT));
|
||||
m_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT,
|
||||
Common::Rectangle<s32>(0, 0, VRAM_WIDTH, VRAM_HEIGHT), 1.0f);
|
||||
m_host_display->SetDisplayTexture(m_display_texture->GetHandle(), VRAM_WIDTH, VRAM_HEIGHT, 0, 0, VRAM_WIDTH,
|
||||
VRAM_HEIGHT);
|
||||
m_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, Common::Rectangle<s32>(0, 0, VRAM_WIDTH, VRAM_HEIGHT),
|
||||
1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,17 +57,23 @@ public:
|
|||
m_display_texture_handle = nullptr;
|
||||
m_display_texture_width = 0;
|
||||
m_display_texture_height = 0;
|
||||
m_display_texture_rect = {};
|
||||
m_display_texture_view_x = 0;
|
||||
m_display_texture_view_y = 0;
|
||||
m_display_texture_view_width = 0;
|
||||
m_display_texture_view_height = 0;
|
||||
m_display_changed = true;
|
||||
}
|
||||
|
||||
void SetDisplayTexture(void* texture_handle, s32 texture_width, s32 texture_height,
|
||||
const Common::Rectangle<s32>& texture_rect)
|
||||
void SetDisplayTexture(void* texture_handle, s32 texture_width, s32 texture_height, s32 view_x, s32 view_y,
|
||||
s32 view_width, s32 view_height)
|
||||
{
|
||||
m_display_texture_handle = texture_handle;
|
||||
m_display_texture_width = texture_width;
|
||||
m_display_texture_height = texture_height;
|
||||
m_display_texture_rect = texture_rect;
|
||||
m_display_texture_view_x = view_x;
|
||||
m_display_texture_view_y = view_y;
|
||||
m_display_texture_view_width = view_width;
|
||||
m_display_texture_view_height = view_height;
|
||||
m_display_changed = true;
|
||||
}
|
||||
|
||||
|
@ -99,7 +105,10 @@ protected:
|
|||
void* m_display_texture_handle = nullptr;
|
||||
s32 m_display_texture_width = 0;
|
||||
s32 m_display_texture_height = 0;
|
||||
Common::Rectangle<s32> m_display_texture_rect{};
|
||||
s32 m_display_texture_view_x = 0;
|
||||
s32 m_display_texture_view_y = 0;
|
||||
s32 m_display_texture_view_width = 0;
|
||||
s32 m_display_texture_view_height = 0;
|
||||
|
||||
s32 m_display_top_margin = 0;
|
||||
|
||||
|
|
|
@ -418,10 +418,10 @@ void D3D11DisplayWindow::renderDisplay()
|
|||
0, 1, m_display_linear_filtering ? m_linear_sampler.GetAddressOf() : m_point_sampler.GetAddressOf());
|
||||
|
||||
const float uniforms[4] = {
|
||||
static_cast<float>(m_display_texture_rect.left) / static_cast<float>(m_display_texture_width),
|
||||
static_cast<float>(m_display_texture_rect.top) / static_cast<float>(m_display_texture_height),
|
||||
(static_cast<float>(m_display_texture_rect.GetWidth()) - 0.5f) / static_cast<float>(m_display_texture_width),
|
||||
(static_cast<float>(m_display_texture_rect.GetHeight()) - 0.5f) / static_cast<float>(m_display_texture_height)};
|
||||
static_cast<float>(m_display_texture_view_x) / static_cast<float>(m_display_texture_width),
|
||||
static_cast<float>(m_display_texture_view_y) / static_cast<float>(m_display_texture_height),
|
||||
(static_cast<float>(m_display_texture_view_width) - 0.5f) / static_cast<float>(m_display_texture_width),
|
||||
(static_cast<float>(m_display_texture_view_height) - 0.5f) / static_cast<float>(m_display_texture_height)};
|
||||
const auto map = m_display_uniform_buffer.Map(m_context.Get(), sizeof(uniforms), sizeof(uniforms));
|
||||
std::memcpy(map.pointer, uniforms, sizeof(uniforms));
|
||||
m_display_uniform_buffer.Unmap(m_context.Get(), sizeof(uniforms));
|
||||
|
|
|
@ -475,10 +475,10 @@ void OpenGLDisplayWindow::renderDisplay()
|
|||
glDepthMask(GL_FALSE);
|
||||
m_display_program.Bind();
|
||||
m_display_program.Uniform4f(
|
||||
0, static_cast<float>(m_display_texture_rect.left) / static_cast<float>(m_display_texture_width),
|
||||
static_cast<float>(m_display_texture_rect.top) / static_cast<float>(m_display_texture_height),
|
||||
(static_cast<float>(m_display_texture_rect.GetWidth()) - 0.5f) / static_cast<float>(m_display_texture_width),
|
||||
(static_cast<float>(m_display_texture_rect.GetHeight()) - 0.5f) / static_cast<float>(m_display_texture_height));
|
||||
0, static_cast<float>(m_display_texture_view_x) / static_cast<float>(m_display_texture_width),
|
||||
static_cast<float>(m_display_texture_view_y) / static_cast<float>(m_display_texture_height),
|
||||
(static_cast<float>(m_display_texture_view_width) - 0.5f) / static_cast<float>(m_display_texture_width),
|
||||
(static_cast<float>(m_display_texture_view_height) - 0.5f) / static_cast<float>(m_display_texture_height));
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(reinterpret_cast<uintptr_t>(m_display_texture_handle)));
|
||||
glBindSampler(0, m_display_linear_filtering ? m_display_linear_sampler : m_display_nearest_sampler);
|
||||
glBindVertexArray(m_display_vao);
|
||||
|
|
|
@ -395,10 +395,10 @@ void D3D11HostDisplay::RenderDisplay()
|
|||
0, 1, m_display_linear_filtering ? m_linear_sampler.GetAddressOf() : m_point_sampler.GetAddressOf());
|
||||
|
||||
const float uniforms[4] = {
|
||||
static_cast<float>(m_display_texture_rect.left) / static_cast<float>(m_display_texture_width),
|
||||
static_cast<float>(m_display_texture_rect.top) / static_cast<float>(m_display_texture_height),
|
||||
(static_cast<float>(m_display_texture_rect.GetWidth()) - 0.5f) / static_cast<float>(m_display_texture_width),
|
||||
(static_cast<float>(m_display_texture_rect.GetHeight()) - 0.5f) / static_cast<float>(m_display_texture_height)};
|
||||
static_cast<float>(m_display_texture_view_x) / static_cast<float>(m_display_texture_width),
|
||||
static_cast<float>(m_display_texture_view_y) / static_cast<float>(m_display_texture_height),
|
||||
(static_cast<float>(m_display_texture_view_width) - 0.5f) / static_cast<float>(m_display_texture_width),
|
||||
(static_cast<float>(m_display_texture_view_height) - 0.5f) / static_cast<float>(m_display_texture_height)};
|
||||
const auto map = m_display_uniform_buffer.Map(m_context.Get(), sizeof(uniforms), sizeof(uniforms));
|
||||
std::memcpy(map.pointer, uniforms, sizeof(uniforms));
|
||||
m_display_uniform_buffer.Unmap(m_context.Get(), sizeof(uniforms));
|
||||
|
|
|
@ -386,10 +386,10 @@ void OpenGLHostDisplay::RenderDisplay()
|
|||
glDepthMask(GL_FALSE);
|
||||
m_display_program.Bind();
|
||||
m_display_program.Uniform4f(
|
||||
0, static_cast<float>(m_display_texture_rect.left) / static_cast<float>(m_display_texture_width),
|
||||
static_cast<float>(m_display_texture_rect.top) / static_cast<float>(m_display_texture_height),
|
||||
(static_cast<float>(m_display_texture_rect.GetWidth()) - 0.5f) / static_cast<float>(m_display_texture_width),
|
||||
(static_cast<float>(m_display_texture_rect.GetHeight()) - 0.5f) / static_cast<float>(m_display_texture_height));
|
||||
0, static_cast<float>(m_display_texture_view_x) / static_cast<float>(m_display_texture_width),
|
||||
static_cast<float>(m_display_texture_view_y) / static_cast<float>(m_display_texture_height),
|
||||
(static_cast<float>(m_display_texture_view_width) - 0.5f) / static_cast<float>(m_display_texture_width),
|
||||
(static_cast<float>(m_display_texture_view_height) - 0.5f) / static_cast<float>(m_display_texture_height));
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(reinterpret_cast<uintptr_t>(m_display_texture_handle)));
|
||||
glBindSampler(0, m_display_linear_filtering ? m_display_linear_sampler : m_display_nearest_sampler);
|
||||
glBindVertexArray(m_display_vao);
|
||||
|
|
Loading…
Reference in New Issue