GPU/HW: Elide buffer copy in scanout and fix flipped display

This commit is contained in:
Connor McLaughlin
2019-11-04 01:45:03 +10:00
parent ac45f3892c
commit a397979d72
8 changed files with 55 additions and 61 deletions

View File

@ -567,15 +567,9 @@ void GPU_HW_D3D11::UpdateDisplay()
}
else if (!m_GPUSTAT.display_area_color_depth_24 && !m_GPUSTAT.vertical_interlace)
{
const CD3D11_BOX src_box(scaled_vram_offset_x, scaled_vram_offset_y, 0,
scaled_vram_offset_x + scaled_display_width,
scaled_vram_offset_y + scaled_display_height, 1);
m_context->CopySubresourceRegion(m_display_texture.GetD3DTexture(), 0, 0, 0, 0, m_vram_texture.GetD3DTexture(), 0,
&src_box);
m_host_display->SetDisplayTexture(m_display_texture.GetD3DSRV(), 0, 0, scaled_display_width,
scaled_display_height, m_display_texture.GetWidth(),
m_display_texture.GetHeight(), m_crtc_state.display_aspect_ratio);
m_host_display->SetDisplayTexture(m_vram_texture.GetD3DSRV(), scaled_vram_offset_x, scaled_vram_offset_y,
scaled_display_width, scaled_display_height, m_vram_texture.GetWidth(),
m_vram_texture.GetHeight(), m_crtc_state.display_aspect_ratio);
}
else
{

View File

@ -439,9 +439,10 @@ 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())), 0, 0,
m_vram_texture->GetWidth(), m_vram_texture->GetHeight(),
m_vram_texture->GetWidth(), m_vram_texture->GetHeight(), 1.0f);
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture->GetGLId())), 0,
m_vram_texture->GetHeight(), m_vram_texture->GetWidth(),
-static_cast<s32>(m_vram_texture->GetHeight()), m_vram_texture->GetWidth(),
m_vram_texture->GetHeight(), 1.0f);
}
else
{
@ -454,8 +455,6 @@ void GPU_HW_OpenGL::UpdateDisplay()
VRAM_HEIGHT - vram_offset_y);
const u32 scaled_display_width = display_width * m_resolution_scale;
const u32 scaled_display_height = display_height * m_resolution_scale;
const u32 flipped_vram_offset_y = VRAM_HEIGHT - vram_offset_y - display_height;
const u32 scaled_flipped_vram_offset_y = m_vram_texture->GetHeight() - scaled_vram_offset_y - scaled_display_height;
if (m_GPUSTAT.display_disable)
{
@ -463,17 +462,17 @@ void GPU_HW_OpenGL::UpdateDisplay()
}
else if (!m_GPUSTAT.display_area_color_depth_24 && !m_GPUSTAT.vertical_interlace)
{
// fast path when both interlacing and 24-bit depth is off
glCopyImageSubData(m_vram_texture->GetGLId(), GL_TEXTURE_2D, 0, scaled_vram_offset_x,
scaled_flipped_vram_offset_y, 0, m_display_texture->GetGLId(), GL_TEXTURE_2D, 0, 0, 0, 0,
scaled_display_width, scaled_display_height, 1);
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture->GetGLId())), 0,
0, scaled_display_width, scaled_display_height, m_display_texture->GetWidth(),
m_display_texture->GetHeight(), m_crtc_state.display_aspect_ratio);
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture->GetGLId())),
scaled_vram_offset_x, m_vram_texture->GetHeight() - scaled_vram_offset_y,
scaled_display_width, -static_cast<s32>(scaled_display_height),
m_vram_texture->GetWidth(), m_vram_texture->GetHeight(),
m_crtc_state.display_aspect_ratio);
}
else
{
const u32 flipped_vram_offset_y = VRAM_HEIGHT - vram_offset_y - display_height;
const u32 scaled_flipped_vram_offset_y =
m_vram_texture->GetHeight() - scaled_vram_offset_y - scaled_display_height;
const u32 field_offset = BoolToUInt8(m_GPUSTAT.vertical_interlace && !m_GPUSTAT.drawing_even_line);
const u32 scaled_field_offset = field_offset * m_resolution_scale;
@ -507,9 +506,10 @@ void GPU_HW_OpenGL::UpdateDisplay()
glDrawArrays(GL_TRIANGLES, 0, 3);
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture->GetGLId())), 0,
0, display_width, display_height, m_display_texture->GetWidth(),
m_display_texture->GetHeight(), m_crtc_state.display_aspect_ratio);
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_texture->GetGLId())),
0, display_height, display_width, -static_cast<s32>(display_height),
m_display_texture->GetWidth(), m_display_texture->GetHeight(),
m_crtc_state.display_aspect_ratio);
}
else
{
@ -524,8 +524,9 @@ void GPU_HW_OpenGL::UpdateDisplay()
glDrawArrays(GL_TRIANGLES, 0, 3);
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_vram_texture->GetGLId())), 0,
0, scaled_display_width, scaled_display_height, m_display_texture->GetWidth(),
m_host_display->SetDisplayTexture(reinterpret_cast<void*>(static_cast<uintptr_t>(m_display_texture->GetGLId())),
0, scaled_display_height, scaled_display_width,
-static_cast<s32>(scaled_display_height), m_display_texture->GetWidth(),
m_display_texture->GetHeight(), m_crtc_state.display_aspect_ratio);
}

View File

@ -35,7 +35,7 @@ public:
virtual void UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data,
u32 data_stride) = 0;
virtual void SetDisplayTexture(void* texture_handle, u32 offset_x, u32 offset_y, u32 width, u32 height,
virtual void SetDisplayTexture(void* texture_handle, s32 offset_x, s32 offset_y, s32 width, s32 height,
u32 texture_width, u32 texture_height, float aspect_ratio) = 0;
virtual void SetDisplayLinearFiltering(bool enabled) = 0;

View File

@ -14,7 +14,7 @@ struct Settings
bool start_paused = false;
GPURenderer gpu_renderer = GPURenderer::HardwareOpenGL;
GPURenderer gpu_renderer = GPURenderer::Software;
u32 gpu_resolution_scale = 1;
u32 max_gpu_resolution_scale = 1;
bool gpu_vsync = true;