g_host_display -> g_gpu_device

This commit is contained in:
Stenzek 2023-08-06 15:31:54 +10:00
parent 7625385f27
commit 716cd50a22
25 changed files with 300 additions and 301 deletions

View File

@ -27,8 +27,8 @@ GPU::GPU() = default;
GPU::~GPU()
{
if (g_host_display)
g_host_display->SetGPUTimingEnabled(false);
if (g_gpu_device)
g_gpu_device->SetGPUTimingEnabled(false);
}
bool GPU::Initialize()
@ -49,12 +49,12 @@ bool GPU::Initialize()
UpdateCRTCConfig();
if (g_settings.display_post_processing && !g_settings.display_post_process_chain.empty() &&
!g_host_display->SetPostProcessingChain(g_settings.display_post_process_chain))
!g_gpu_device->SetPostProcessingChain(g_settings.display_post_process_chain))
{
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
}
g_host_display->SetGPUTimingEnabled(g_settings.display_show_gpu);
g_gpu_device->SetGPUTimingEnabled(g_settings.display_show_gpu);
return true;
}
@ -75,7 +75,7 @@ void GPU::UpdateSettings()
// Crop mode calls this, so recalculate the display area
UpdateCRTCDisplayParameters();
g_host_display->SetGPUTimingEnabled(g_settings.display_show_gpu);
g_gpu_device->SetGPUTimingEnabled(g_settings.display_show_gpu);
}
void GPU::CPUClockChanged()
@ -971,8 +971,8 @@ void GPU::UpdateCommandTickEvent()
bool GPU::ConvertScreenCoordinatesToBeamTicksAndLines(s32 window_x, s32 window_y, float x_scale, u32* out_tick,
u32* out_line) const
{
auto [display_x, display_y] = g_host_display->ConvertWindowCoordinatesToDisplayCoordinates(
window_x, window_y, g_host_display->GetWindowWidth(), g_host_display->GetWindowHeight());
auto [display_x, display_y] = g_gpu_device->ConvertWindowCoordinatesToDisplayCoordinates(
window_x, window_y, g_gpu_device->GetWindowWidth(), g_gpu_device->GetWindowHeight());
if (x_scale != 1.0f)
{

View File

@ -263,7 +263,7 @@ public:
D3D11Device();
~D3D11Device();
ALWAYS_INLINE static D3D11Device& GetInstance() { return *static_cast<D3D11Device*>(g_host_display.get()); }
ALWAYS_INLINE static D3D11Device& GetInstance() { return *static_cast<D3D11Device*>(g_gpu_device.get()); }
ALWAYS_INLINE static ID3D11Device* GetD3DDevice() { return GetInstance().m_device.Get(); }
ALWAYS_INLINE static ID3D11DeviceContext* GetD3DContext() { return GetInstance().m_context.Get(); }

View File

@ -52,7 +52,7 @@ extern std::unique_ptr<GPUDevice> WrapNewMetalDevice();
// TODO: input layout => VAO in GL, buffer might change
// TODO: one big lookup table for render passes, or dynamic rendering
std::unique_ptr<GPUDevice> g_host_display;
std::unique_ptr<GPUDevice> g_gpu_device;
GPUFramebuffer::GPUFramebuffer(GPUTexture* rt, GPUTexture* ds, u32 width, u32 height)
: m_rt(rt), m_ds(ds), m_width(width), m_height(height)

View File

@ -709,8 +709,7 @@ private:
std::unique_ptr<PostProcessingChain> m_post_processing_chain;
};
/// Returns a pointer to the current host display abstraction. Assumes AcquireHostDisplay() has been called.
extern std::unique_ptr<GPUDevice> g_host_display;
extern std::unique_ptr<GPUDevice> g_gpu_device;
namespace Host {
/// Called when the core is creating a render device.
@ -733,13 +732,13 @@ void InvalidateDisplay();
struct GLAutoPop
{
GLAutoPop(int dummy) {}
~GLAutoPop() { g_host_display->PopDebugGroup(); }
~GLAutoPop() { g_gpu_device->PopDebugGroup(); }
};
#define GL_SCOPE(...) GLAutoPop gl_auto_pop((g_host_display->PushDebugGroup(__VA_ARGS__), 0))
#define GL_PUSH(...) g_host_display->PushDebugGroup(__VA_ARGS__)
#define GL_POP() g_host_display->PopDebugGroup()
#define GL_INS(...) g_host_display->InsertDebugMessage(__VA_ARGS__)
#define GL_SCOPE(...) GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(__VA_ARGS__), 0))
#define GL_PUSH(...) g_gpu_device->PushDebugGroup(__VA_ARGS__)
#define GL_POP() g_gpu_device->PopDebugGroup()
#define GL_INS(...) g_gpu_device->InsertDebugMessage(__VA_ARGS__)
#define GL_OBJECT_NAME(obj, ...) (obj)->SetDebugName(StringUtil::StdStringFromFormat(__VA_ARGS__))
#else
#define GL_SCOPE(...) (void)0

View File

@ -29,7 +29,7 @@ public:
OpenGLDevice();
~OpenGLDevice();
ALWAYS_INLINE static OpenGLDevice& GetInstance() { return *static_cast<OpenGLDevice*>(g_host_display.get()); }
ALWAYS_INLINE static OpenGLDevice& GetInstance() { return *static_cast<OpenGLDevice*>(g_gpu_device.get()); }
ALWAYS_INLINE static OpenGLStreamBuffer* GetTextureStreamBuffer()
{
return GetInstance().m_texture_stream_buffer.get();

View File

@ -207,13 +207,13 @@ bool PostProcessingChain::CheckTargets(GPUTexture::Format format, u32 target_wid
m_input_framebuffer.reset();
m_input_texture.reset();
if (!(m_input_texture = g_host_display->CreateTexture(target_width, target_height, 1, 1, 1,
if (!(m_input_texture = g_gpu_device->CreateTexture(target_width, target_height, 1, 1, 1,
GPUTexture::Type::RenderTarget, format)))
{
return false;
}
if (!(m_input_framebuffer = g_host_display->CreateFramebuffer(m_input_texture.get())))
if (!(m_input_framebuffer = g_gpu_device->CreateFramebuffer(m_input_texture.get())))
{
m_input_texture.reset();
return false;
@ -236,7 +236,7 @@ bool PostProcessingChain::CheckTargets(GPUTexture::Format format, u32 target_wid
config.address_u = GPUSampler::AddressMode::ClampToBorder;
config.address_v = GPUSampler::AddressMode::ClampToBorder;
config.border_color = 0xFF000000u;
if (!(m_border_sampler = g_host_display->CreateSampler(config)))
if (!(m_border_sampler = g_gpu_device->CreateSampler(config)))
return false;
}
@ -246,12 +246,12 @@ bool PostProcessingChain::CheckTargets(GPUTexture::Format format, u32 target_wid
bool PostProcessingChain::Apply(GPUFramebuffer* final_target, s32 final_left, s32 final_top, s32 final_width,
s32 final_height, s32 orig_width, s32 orig_height, u32 target_width, u32 target_height)
{
const u32 window_width = final_target ? final_target->GetWidth() : g_host_display->GetWindowWidth();
const u32 window_height = final_target ? final_target->GetHeight() : g_host_display->GetWindowHeight();
const u32 window_width = final_target ? final_target->GetWidth() : g_gpu_device->GetWindowWidth();
const u32 window_height = final_target ? final_target->GetHeight() : g_gpu_device->GetWindowHeight();
GL_PUSH("PostProcessingChain Apply");
g_host_display->SetViewportAndScissor(final_left, final_top, final_width, final_height);
g_gpu_device->SetViewportAndScissor(final_left, final_top, final_width, final_height);
GPUTexture* input = m_input_texture.get();
input->MakeReadyForSampling();
@ -266,11 +266,11 @@ bool PostProcessingChain::Apply(GPUFramebuffer* final_target, s32 final_left, s3
// Assumes final stage has been cleared already.
if (!is_final)
g_host_display->ClearRenderTarget(stage.GetOutputTexture(), 0);
g_gpu_device->ClearRenderTarget(stage.GetOutputTexture(), 0);
if (is_final && !final_target)
{
if (!g_host_display->BeginPresent(false))
if (!g_gpu_device->BeginPresent(false))
{
result = false;
break;
@ -278,19 +278,19 @@ bool PostProcessingChain::Apply(GPUFramebuffer* final_target, s32 final_left, s3
}
else
{
g_host_display->SetFramebuffer(is_final ? final_target : stage.GetOutputFramebuffer());
g_gpu_device->SetFramebuffer(is_final ? final_target : stage.GetOutputFramebuffer());
}
g_host_display->SetPipeline(stage.GetPipeline());
g_host_display->SetTextureSampler(0, input, m_border_sampler.get());
g_gpu_device->SetPipeline(stage.GetPipeline());
g_gpu_device->SetTextureSampler(0, input, m_border_sampler.get());
const u32 uniforms_size = stage.GetUniformsSize();
void* uniforms = g_host_display->MapUniformBuffer(uniforms_size);
void* uniforms = g_gpu_device->MapUniformBuffer(uniforms_size);
stage.FillUniformBuffer(uniforms, input->GetWidth(), input->GetHeight(), final_left, final_top, final_width,
final_height, window_width, window_height, orig_width, orig_height,
static_cast<float>(m_timer.GetTimeSeconds()));
g_host_display->UnmapUniformBuffer(uniforms_size);
g_host_display->Draw(3, 0);
g_gpu_device->UnmapUniformBuffer(uniforms_size);
g_gpu_device->Draw(3, 0);
if (!is_final)
{

View File

@ -294,12 +294,12 @@ bool PostProcessingShader::CompilePipeline(GPUTexture::Format target_format)
if (m_pipeline)
m_pipeline.reset();
PostProcessingShaderGen shadergen(g_host_display->GetRenderAPI(), g_host_display->GetFeatures().dual_source_blend);
PostProcessingShaderGen shadergen(g_gpu_device->GetRenderAPI(), g_gpu_device->GetFeatures().dual_source_blend);
std::unique_ptr<GPUShader> vs =
g_host_display->CreateShader(GPUShaderStage::Vertex, shadergen.GeneratePostProcessingVertexShader(*this));
g_gpu_device->CreateShader(GPUShaderStage::Vertex, shadergen.GeneratePostProcessingVertexShader(*this));
std::unique_ptr<GPUShader> fs =
g_host_display->CreateShader(GPUShaderStage::Fragment, shadergen.GeneratePostProcessingFragmentShader(*this));
g_gpu_device->CreateShader(GPUShaderStage::Fragment, shadergen.GeneratePostProcessingFragmentShader(*this));
if (!vs || !fs)
return false;
@ -316,7 +316,7 @@ bool PostProcessingShader::CompilePipeline(GPUTexture::Format target_format)
plconfig.vertex_shader = vs.get();
plconfig.fragment_shader = fs.get();
if (!(m_pipeline = g_host_display->CreatePipeline(plconfig)))
if (!(m_pipeline = g_gpu_device->CreatePipeline(plconfig)))
return false;
return true;
@ -334,12 +334,12 @@ bool PostProcessingShader::ResizeOutput(GPUTexture::Format format, u32 width, u3
m_output_texture.reset();
if (!(m_output_texture =
g_host_display->CreateTexture(width, height, 1, 1, 1, GPUTexture::Type::RenderTarget, format)))
g_gpu_device->CreateTexture(width, height, 1, 1, 1, GPUTexture::Type::RenderTarget, format)))
{
return false;
}
if (!(m_output_framebuffer = g_host_display->CreateFramebuffer(m_output_texture.get())))
if (!(m_output_framebuffer = g_gpu_device->CreateFramebuffer(m_output_texture.get())))
{
m_output_texture.reset();
return false;

View File

@ -53,7 +53,7 @@ GPU_HW::GPU_HW() : GPU()
GPU_HW::~GPU_HW()
{
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
if (m_sw_renderer)
{
@ -77,8 +77,8 @@ bool GPU_HW::Initialize()
if (!GPU::Initialize())
return false;
const GPUDevice::Features features = g_host_display->GetFeatures();
m_max_resolution_scale = g_host_display->GetMaxTextureSize() / VRAM_WIDTH;
const GPUDevice::Features features = g_gpu_device->GetFeatures();
m_max_resolution_scale = g_gpu_device->GetMaxTextureSize() / VRAM_WIDTH;
m_supports_dual_source_blend = features.dual_source_blend;
m_supports_per_sample_shading = features.per_sample_shading;
m_supports_adaptive_downsampling = features.mipmapped_render_targets;
@ -86,7 +86,7 @@ bool GPU_HW::Initialize()
m_resolution_scale = CalculateResolutionScale();
m_multisamples = std::min(g_settings.gpu_multisamples, m_max_multisamples);
m_render_api = g_host_display->GetRenderAPI();
m_render_api = g_gpu_device->GetRenderAPI();
m_per_sample_shading = g_settings.gpu_per_sample_shading && m_supports_per_sample_shading;
m_true_color = g_settings.gpu_true_color;
m_scaled_dithering = g_settings.gpu_scaled_dithering;
@ -181,7 +181,7 @@ bool GPU_HW::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
return false;
}
g_host_display->CopyTextureRegion(m_vram_texture.get(), 0, 0, 0, 0, tex, 0, 0, 0, 0, tex->GetWidth(),
g_gpu_device->CopyTextureRegion(m_vram_texture.get(), 0, 0, 0, 0, tex, 0, 0, 0, 0, tex->GetWidth(),
tex->GetHeight());
}
else
@ -192,7 +192,7 @@ bool GPU_HW::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
delete tex;
tex =
g_host_display
g_gpu_device
->CreateTexture(m_vram_texture->GetWidth(), m_vram_texture->GetHeight(), 1, 1, m_vram_texture->GetSamples(),
GPUTexture::Type::RenderTarget, GPUTexture::Format::RGBA8, nullptr, 0, false)
.release();
@ -201,7 +201,7 @@ bool GPU_HW::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
return false;
}
g_host_display->CopyTextureRegion(tex, 0, 0, 0, 0, m_vram_texture.get(), 0, 0, 0, 0, tex->GetWidth(),
g_gpu_device->CopyTextureRegion(tex, 0, 0, 0, 0, m_vram_texture.get(), 0, 0, 0, 0, tex->GetWidth(),
tex->GetHeight());
}
}
@ -219,9 +219,9 @@ bool GPU_HW::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
void GPU_HW::RestoreGraphicsAPIState()
{
g_host_display->SetTextureSampler(0, m_vram_read_texture.get(), g_host_display->GetNearestSampler());
g_host_display->SetFramebuffer(m_vram_framebuffer.get());
g_host_display->SetViewport(0, 0, m_vram_texture->GetWidth(), m_vram_texture->GetHeight());
g_gpu_device->SetTextureSampler(0, m_vram_read_texture.get(), g_gpu_device->GetNearestSampler());
g_gpu_device->SetFramebuffer(m_vram_framebuffer.get());
g_gpu_device->SetViewport(0, 0, m_vram_texture->GetWidth(), m_vram_texture->GetHeight());
SetScissor();
m_batch_ubo_dirty = true;
}
@ -236,7 +236,7 @@ void GPU_HW::UpdateSettings()
{
RestoreGraphicsAPIState();
ReadVRAM(0, 0, VRAM_WIDTH, VRAM_HEIGHT);
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
CreateBuffers();
}
@ -344,7 +344,7 @@ u32 GPU_HW::CalculateResolutionScale() const
(m_console_is_pal ? (PAL_VERTICAL_ACTIVE_END - PAL_VERTICAL_ACTIVE_START) :
(NTSC_VERTICAL_ACTIVE_END - NTSC_VERTICAL_ACTIVE_START));
const s32 preferred_scale =
static_cast<s32>(std::ceil(static_cast<float>(g_host_display->GetWindowHeight()) / height));
static_cast<s32>(std::ceil(static_cast<float>(g_gpu_device->GetWindowHeight()) / height));
Log_InfoPrintf("Height = %d, preferred scale = %d", height, preferred_scale);
scale = static_cast<u32>(std::clamp<s32>(preferred_scale, 1, m_max_resolution_scale));
@ -425,17 +425,17 @@ bool GPU_HW::CreateBuffers()
const u32 texture_height = VRAM_HEIGHT * m_resolution_scale;
const u8 samples = static_cast<u8>(m_multisamples);
if (!(m_vram_texture = g_host_display->CreateTexture(texture_width, texture_height, 1, 1, samples,
if (!(m_vram_texture = g_gpu_device->CreateTexture(texture_width, texture_height, 1, 1, samples,
GPUTexture::Type::RenderTarget, VRAM_RT_FORMAT)) ||
!(m_vram_depth_texture = g_host_display->CreateTexture(texture_width, texture_height, 1, 1, samples,
!(m_vram_depth_texture = g_gpu_device->CreateTexture(texture_width, texture_height, 1, 1, samples,
GPUTexture::Type::DepthStencil, VRAM_DS_FORMAT)) ||
!(m_vram_read_texture = g_host_display->CreateTexture(texture_width, texture_height, 1, 1, 1,
!(m_vram_read_texture = g_gpu_device->CreateTexture(texture_width, texture_height, 1, 1, 1,
GPUTexture::Type::Texture, VRAM_RT_FORMAT)) ||
!(m_display_texture = g_host_display->CreateTexture(
!(m_display_texture = g_gpu_device->CreateTexture(
((m_downsample_mode == GPUDownsampleMode::Adaptive) ? VRAM_WIDTH : GPU_MAX_DISPLAY_WIDTH) *
m_resolution_scale,
GPU_MAX_DISPLAY_HEIGHT * m_resolution_scale, 1, 1, 1, GPUTexture::Type::RenderTarget, VRAM_RT_FORMAT)) ||
!(m_vram_readback_texture = g_host_display->CreateTexture(VRAM_WIDTH / 2, VRAM_HEIGHT, 1, 1, 1,
!(m_vram_readback_texture = g_gpu_device->CreateTexture(VRAM_WIDTH / 2, VRAM_HEIGHT, 1, 1, 1,
GPUTexture::Type::RenderTarget, VRAM_RT_FORMAT)))
{
return false;
@ -443,12 +443,12 @@ bool GPU_HW::CreateBuffers()
// vram framebuffer has both colour and depth
if (!(m_vram_framebuffer =
g_host_display->CreateFramebuffer(m_vram_texture.get(), 0, 0, m_vram_depth_texture.get(), 0, 0)) ||
g_gpu_device->CreateFramebuffer(m_vram_texture.get(), 0, 0, m_vram_depth_texture.get(), 0, 0)) ||
!(m_vram_update_depth_framebuffer =
g_host_display->CreateFramebuffer(nullptr, 0, 0, m_vram_depth_texture.get(), 0, 0)) ||
g_gpu_device->CreateFramebuffer(nullptr, 0, 0, m_vram_depth_texture.get(), 0, 0)) ||
!(m_vram_readback_framebuffer =
g_host_display->CreateFramebuffer(m_vram_readback_texture.get(), 0, 0, nullptr, 0, 0)) ||
!(m_display_framebuffer = g_host_display->CreateFramebuffer(m_display_texture.get(), 0, 0, nullptr, 0, 0)))
g_gpu_device->CreateFramebuffer(m_vram_readback_texture.get(), 0, 0, nullptr, 0, 0)) ||
!(m_display_framebuffer = g_gpu_device->CreateFramebuffer(m_display_texture.get(), 0, 0, nullptr, 0, 0)))
{
return false;
}
@ -459,7 +459,7 @@ bool GPU_HW::CreateBuffers()
GL_OBJECT_NAME(m_display_framebuffer, "Display Framebuffer");
// TODO: check caps
if (!(m_vram_upload_buffer = g_host_display->CreateTextureBuffer(GPUTextureBuffer::Format::R16UI,
if (!(m_vram_upload_buffer = g_gpu_device->CreateTextureBuffer(GPUTextureBuffer::Format::R16UI,
VRAM_UPDATE_TEXTURE_BUFFER_SIZE / sizeof(u16))))
{
return false;
@ -504,24 +504,24 @@ bool GPU_HW::CreateBuffers()
#endif
if (m_downsample_mode == GPUDownsampleMode::Box)
{
if (!(m_downsample_texture = g_host_display->CreateTexture(VRAM_WIDTH, VRAM_HEIGHT, 1, 1, 1,
if (!(m_downsample_texture = g_gpu_device->CreateTexture(VRAM_WIDTH, VRAM_HEIGHT, 1, 1, 1,
GPUTexture::Type::RenderTarget, VRAM_RT_FORMAT)) ||
!(m_downsample_framebuffer = g_host_display->CreateFramebuffer(m_downsample_texture.get())))
!(m_downsample_framebuffer = g_gpu_device->CreateFramebuffer(m_downsample_texture.get())))
{
return false;
}
}
g_host_display->SetFramebuffer(m_vram_framebuffer.get());
g_gpu_device->SetFramebuffer(m_vram_framebuffer.get());
SetFullVRAMDirtyRectangle();
return true;
}
void GPU_HW::ClearFramebuffer()
{
g_host_display->ClearRenderTarget(m_vram_texture.get(), 0);
g_host_display->ClearDepth(m_vram_depth_texture.get(), m_pgxp_depth_buffer ? 1.0f : 0.0f);
g_host_display->ClearRenderTarget(m_display_texture.get(), 0);
g_gpu_device->ClearRenderTarget(m_vram_texture.get(), 0);
g_gpu_device->ClearDepth(m_vram_depth_texture.get(), m_pgxp_depth_buffer ? 1.0f : 0.0f);
g_gpu_device->ClearRenderTarget(m_display_texture.get(), 0);
ClearVRAMDirtyRectangle();
m_last_depth_z = 1.0f;
}
@ -545,8 +545,8 @@ void GPU_HW::DestroyBuffers()
bool GPU_HW::CompilePipelines()
{
const GPUDevice::Features features = g_host_display->GetFeatures();
GPU_HW_ShaderGen shadergen(g_host_display->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading,
const GPUDevice::Features features = g_gpu_device->GetFeatures();
GPU_HW_ShaderGen shadergen(g_gpu_device->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading,
m_true_color, m_scaled_dithering, m_texture_filtering, m_using_uv_limits,
m_pgxp_depth_buffer, m_disable_color_perspective, m_supports_dual_source_blend);
@ -566,7 +566,7 @@ bool GPU_HW::CompilePipelines()
for (u8 textured = 0; textured < 2; textured++)
{
const std::string vs = shadergen.GenerateBatchVertexShader(ConvertToBoolUnchecked(textured));
if (!(batch_vertex_shaders[textured] = g_host_display->CreateShader(GPUShaderStage::Vertex, vs)))
if (!(batch_vertex_shaders[textured] = g_gpu_device->CreateShader(GPUShaderStage::Vertex, vs)))
return false;
progress.Increment();
@ -585,7 +585,7 @@ bool GPU_HW::CompilePipelines()
ConvertToBoolUnchecked(dithering), ConvertToBoolUnchecked(interlacing));
if (!(batch_fragment_shaders[render_mode][texture_mode][dithering][interlacing] =
g_host_display->CreateShader(GPUShaderStage::Fragment, fs)))
g_gpu_device->CreateShader(GPUShaderStage::Fragment, fs)))
{
return false;
}
@ -702,7 +702,7 @@ bool GPU_HW::CompilePipelines()
}
if (!(m_batch_pipelines[depth_test][render_mode][texture_mode][transparency_mode][dithering]
[interlacing] = g_host_display->CreatePipeline(plconfig)))
[interlacing] = g_gpu_device->CreatePipeline(plconfig)))
{
return false;
}
@ -718,9 +718,9 @@ bool GPU_HW::CompilePipelines()
batch_shader_guard.Run();
std::unique_ptr<GPUShader> fullscreen_quad_vertex_shader =
g_host_display->CreateShader(GPUShaderStage::Vertex, shadergen.GenerateScreenQuadVertexShader());
g_gpu_device->CreateShader(GPUShaderStage::Vertex, shadergen.GenerateScreenQuadVertexShader());
std::unique_ptr<GPUShader> uv_quad_vertex_shader =
g_host_display->CreateShader(GPUShaderStage::Vertex, shadergen.GenerateUVQuadVertexShader());
g_gpu_device->CreateShader(GPUShaderStage::Vertex, shadergen.GenerateUVQuadVertexShader());
if (!fullscreen_quad_vertex_shader || !uv_quad_vertex_shader)
return false;
@ -737,7 +737,7 @@ bool GPU_HW::CompilePipelines()
{
for (u8 interlaced = 0; interlaced < 2; interlaced++)
{
std::unique_ptr<GPUShader> fs = g_host_display->CreateShader(
std::unique_ptr<GPUShader> fs = g_gpu_device->CreateShader(
GPUShaderStage::Fragment,
shadergen.GenerateVRAMFillFragmentShader(ConvertToBoolUnchecked(wrapped), ConvertToBoolUnchecked(interlaced)));
if (!fs)
@ -746,7 +746,7 @@ bool GPU_HW::CompilePipelines()
plconfig.fragment_shader = fs.get();
plconfig.depth = GPUPipeline::DepthState::GetAlwaysWriteState();
if (!(m_vram_fill_pipelines[wrapped][interlaced] = g_host_display->CreatePipeline(plconfig)))
if (!(m_vram_fill_pipelines[wrapped][interlaced] = g_gpu_device->CreatePipeline(plconfig)))
return false;
progress.Increment();
@ -756,7 +756,7 @@ bool GPU_HW::CompilePipelines()
// VRAM copy
{
std::unique_ptr<GPUShader> fs =
g_host_display->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateVRAMCopyFragmentShader());
g_gpu_device->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateVRAMCopyFragmentShader());
if (!fs)
return false;
@ -767,7 +767,7 @@ bool GPU_HW::CompilePipelines()
plconfig.depth.depth_test =
(depth_test != 0) ? GPUPipeline::DepthFunc::GreaterEqual : GPUPipeline::DepthFunc::Always;
if (!(m_vram_copy_pipelines[depth_test] = g_host_display->CreatePipeline(plconfig)))
if (!(m_vram_copy_pipelines[depth_test] = g_gpu_device->CreatePipeline(plconfig)))
return false;
GL_OBJECT_NAME(m_vram_copy_pipelines[depth_test], "VRAM Write Pipeline, depth=%u", depth_test);
@ -780,7 +780,7 @@ bool GPU_HW::CompilePipelines()
// TODO: SSBO path here...
{
const bool use_ssbo = features.texture_buffers_emulated_with_ssbo;
std::unique_ptr<GPUShader> fs = g_host_display->CreateShader(
std::unique_ptr<GPUShader> fs = g_gpu_device->CreateShader(
GPUShaderStage::Fragment, shadergen.GenerateVRAMWriteFragmentShader(use_ssbo));
if (!fs)
return false;
@ -792,7 +792,7 @@ bool GPU_HW::CompilePipelines()
plconfig.depth.depth_test =
(depth_test != 0) ? GPUPipeline::DepthFunc::GreaterEqual : GPUPipeline::DepthFunc::Always;
if (!(m_vram_write_pipelines[depth_test] = g_host_display->CreatePipeline(plconfig)))
if (!(m_vram_write_pipelines[depth_test] = g_gpu_device->CreatePipeline(plconfig)))
return false;
GL_OBJECT_NAME(m_vram_write_pipelines[depth_test], "VRAM Write Pipeline, depth=%u", depth_test);
@ -804,7 +804,7 @@ bool GPU_HW::CompilePipelines()
// VRAM update depth
{
std::unique_ptr<GPUShader> fs =
g_host_display->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateVRAMUpdateDepthFragmentShader());
g_gpu_device->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateVRAMUpdateDepthFragmentShader());
if (!fs)
return false;
@ -814,7 +814,7 @@ bool GPU_HW::CompilePipelines()
plconfig.depth = GPUPipeline::DepthState::GetAlwaysWriteState();
plconfig.blend.write_mask = 0;
if (!(m_vram_update_depth_pipeline = g_host_display->CreatePipeline(plconfig)))
if (!(m_vram_update_depth_pipeline = g_gpu_device->CreatePipeline(plconfig)))
return false;
GL_OBJECT_NAME(m_vram_update_depth_pipeline, "VRAM Update Depth Pipeline");
@ -830,13 +830,13 @@ bool GPU_HW::CompilePipelines()
// VRAM read
{
std::unique_ptr<GPUShader> fs =
g_host_display->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateVRAMReadFragmentShader());
g_gpu_device->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateVRAMReadFragmentShader());
if (!fs)
return false;
plconfig.fragment_shader = fs.get();
if (!(m_vram_readback_pipeline = g_host_display->CreatePipeline(plconfig)))
if (!(m_vram_readback_pipeline = g_gpu_device->CreatePipeline(plconfig)))
return false;
GL_OBJECT_NAME(m_vram_readback_pipeline, "VRAM Read Pipeline");
@ -849,7 +849,7 @@ bool GPU_HW::CompilePipelines()
{
for (u8 interlace_mode = 0; interlace_mode < 3; interlace_mode++)
{
std::unique_ptr<GPUShader> fs = g_host_display->CreateShader(
std::unique_ptr<GPUShader> fs = g_gpu_device->CreateShader(
GPUShaderStage::Fragment,
shadergen.GenerateDisplayFragmentShader(
ConvertToBoolUnchecked(depth_24), static_cast<InterlacedRenderMode>(interlace_mode), m_chroma_smoothing));
@ -858,7 +858,7 @@ bool GPU_HW::CompilePipelines()
plconfig.fragment_shader = fs.get();
if (!(m_display_pipelines[depth_24][interlace_mode] = g_host_display->CreatePipeline(plconfig)))
if (!(m_display_pipelines[depth_24][interlace_mode] = g_gpu_device->CreatePipeline(plconfig)))
return false;
progress.Increment();
@ -868,12 +868,12 @@ bool GPU_HW::CompilePipelines()
{
std::unique_ptr<GPUShader> fs =
g_host_display->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateCopyFragmentShader());
g_gpu_device->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateCopyFragmentShader());
if (!fs)
return false;
plconfig.fragment_shader = fs.get();
if (!(m_copy_pipeline = g_host_display->CreatePipeline(plconfig)))
if (!(m_copy_pipeline = g_gpu_device->CreatePipeline(plconfig)))
return false;
}
@ -950,14 +950,14 @@ bool GPU_HW::CompilePipelines()
if (m_downsample_mode == GPUDownsampleMode::Box)
{
std::unique_ptr<GPUShader> fs =
g_host_display->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateBoxSampleDownsampleFragmentShader());
g_gpu_device->CreateShader(GPUShaderStage::Fragment, shadergen.GenerateBoxSampleDownsampleFragmentShader());
if (!fs)
return false;
GL_OBJECT_NAME(fs, "Downsample First Pass Fragment Shader");
plconfig.fragment_shader = fs.get();
if (!(m_downsample_first_pass_pipeline = g_host_display->CreatePipeline(plconfig)))
if (!(m_downsample_first_pass_pipeline = g_gpu_device->CreatePipeline(plconfig)))
return false;
GL_OBJECT_NAME(m_downsample_first_pass_pipeline, "Downsample First Pass Pipeline");
@ -1001,13 +1001,13 @@ void GPU_HW::UpdateVRAMReadTexture()
if (m_vram_texture->IsMultisampled())
{
g_host_display->ResolveTextureRegion(m_vram_read_texture.get(), scaled_rect.left, scaled_rect.top, 0, 0,
g_gpu_device->ResolveTextureRegion(m_vram_read_texture.get(), scaled_rect.left, scaled_rect.top, 0, 0,
m_vram_texture.get(), scaled_rect.left, scaled_rect.top, 0, 0,
scaled_rect.GetWidth(), scaled_rect.GetHeight());
}
else
{
g_host_display->CopyTextureRegion(m_vram_read_texture.get(), scaled_rect.left, scaled_rect.top, 0, 0,
g_gpu_device->CopyTextureRegion(m_vram_read_texture.get(), scaled_rect.left, scaled_rect.top, 0, 0,
m_vram_texture.get(), scaled_rect.left, scaled_rect.top, 0, 0,
scaled_rect.GetWidth(), scaled_rect.GetHeight());
}
@ -1022,15 +1022,15 @@ void GPU_HW::UpdateDepthBufferFromMaskBit()
return;
// Viewport should already be set full, only need to fudge the scissor.
g_host_display->SetScissor(0, 0, m_vram_texture->GetWidth(), m_vram_texture->GetHeight());
g_host_display->SetFramebuffer(m_vram_update_depth_framebuffer.get());
g_host_display->SetPipeline(m_vram_update_depth_pipeline.get());
g_host_display->SetTextureSampler(0, m_vram_texture.get(), g_host_display->GetNearestSampler());
g_host_display->Draw(3, 0);
g_gpu_device->SetScissor(0, 0, m_vram_texture->GetWidth(), m_vram_texture->GetHeight());
g_gpu_device->SetFramebuffer(m_vram_update_depth_framebuffer.get());
g_gpu_device->SetPipeline(m_vram_update_depth_pipeline.get());
g_gpu_device->SetTextureSampler(0, m_vram_texture.get(), g_gpu_device->GetNearestSampler());
g_gpu_device->Draw(3, 0);
// Restore.
g_host_display->SetTextureSampler(0, m_vram_read_texture.get(), g_host_display->GetNearestSampler());
g_host_display->SetFramebuffer(m_vram_framebuffer.get());
g_gpu_device->SetTextureSampler(0, m_vram_read_texture.get(), g_gpu_device->GetNearestSampler());
g_gpu_device->SetFramebuffer(m_vram_framebuffer.get());
SetScissor();
}
@ -1038,7 +1038,7 @@ void GPU_HW::ClearDepthBuffer()
{
DebugAssert(m_pgxp_depth_buffer);
g_host_display->ClearDepth(m_vram_depth_texture.get(), 1.0f);
g_gpu_device->ClearDepth(m_vram_depth_texture.get(), 1.0f);
m_last_depth_z = 1.0f;
}
@ -1049,7 +1049,7 @@ void GPU_HW::SetScissor()
const s32 top = m_drawing_area.top * m_resolution_scale;
const s32 bottom = std::max<u32>((m_drawing_area.bottom + 1) * m_resolution_scale, top + 1);
g_host_display->SetScissor(left, top, right - left, bottom - top);
g_gpu_device->SetScissor(left, top, right - left, bottom - top);
}
void GPU_HW::MapBatchVertexPointer(u32 required_vertices)
@ -1058,7 +1058,7 @@ void GPU_HW::MapBatchVertexPointer(u32 required_vertices)
void* map;
u32 space;
g_host_display->MapVertexBuffer(sizeof(BatchVertex), required_vertices, &map, &space, &m_batch_base_vertex);
g_gpu_device->MapVertexBuffer(sizeof(BatchVertex), required_vertices, &map, &space, &m_batch_base_vertex);
m_batch_start_vertex_ptr = static_cast<BatchVertex*>(map);
m_batch_current_vertex_ptr = m_batch_start_vertex_ptr;
@ -1068,7 +1068,7 @@ void GPU_HW::MapBatchVertexPointer(u32 required_vertices)
void GPU_HW::UnmapBatchVertexPointer(u32 used_vertices)
{
DebugAssert(m_batch_start_vertex_ptr);
g_host_display->UnmapVertexBuffer(sizeof(BatchVertex), used_vertices);
g_gpu_device->UnmapVertexBuffer(sizeof(BatchVertex), used_vertices);
m_batch_start_vertex_ptr = nullptr;
m_batch_end_vertex_ptr = nullptr;
m_batch_current_vertex_ptr = nullptr;
@ -1078,17 +1078,17 @@ void GPU_HW::DrawBatchVertices(BatchRenderMode render_mode, u32 base_vertex, u32
{
// [depth_test][render_mode][texture_mode][transparency_mode][dithering][interlacing]
const u8 depth_test = m_batch.use_depth_buffer ? static_cast<u8>(2) : BoolToUInt8(m_batch.check_mask_before_draw);
g_host_display->SetPipeline(
g_gpu_device->SetPipeline(
m_batch_pipelines[depth_test][static_cast<u8>(render_mode)][static_cast<u8>(m_batch.texture_mode)][static_cast<u8>(
m_batch.transparency_mode)][BoolToUInt8(m_batch.dithering)][BoolToUInt8(m_batch.interlacing)]
.get());
g_host_display->Draw(num_vertices, base_vertex);
g_gpu_device->Draw(num_vertices, base_vertex);
}
void GPU_HW::ClearDisplay()
{
g_host_display->ClearDisplayTexture();
g_host_display->ClearRenderTarget(m_display_texture.get(), 0xFF000000u);
g_gpu_device->ClearDisplayTexture();
g_gpu_device->ClearRenderTarget(m_display_texture.get(), 0xFF000000u);
}
void GPU_HW::HandleFlippedQuadTextureCoordinates(BatchVertex* vertices)
@ -1843,7 +1843,7 @@ bool GPU_HW::BlitVRAMReplacementTexture(const TextureReplacementTexture* tex, u3
m_vram_replacement_texture.reset();
if (!(m_vram_replacement_texture =
g_host_display->CreateTexture(tex->GetWidth(), tex->GetHeight(), 1, 1, 1, GPUTexture::Type::Texture,
g_gpu_device->CreateTexture(tex->GetWidth(), tex->GetHeight(), 1, 1, 1, GPUTexture::Type::Texture,
GPUTexture::Format::RGBA8, tex->GetPixels(), tex->GetPitch(), true)))
{
return false;
@ -1858,11 +1858,11 @@ bool GPU_HW::BlitVRAMReplacementTexture(const TextureReplacementTexture* tex, u3
}
}
g_host_display->SetFramebuffer(m_vram_framebuffer.get()); // TODO: needed?
g_host_display->SetTextureSampler(0, m_vram_replacement_texture.get(), g_host_display->GetLinearSampler());
g_host_display->SetPipeline(m_copy_pipeline.get());
g_host_display->SetViewportAndScissor(dst_x, dst_y, width, height);
g_host_display->Draw(3, 0);
g_gpu_device->SetFramebuffer(m_vram_framebuffer.get()); // TODO: needed?
g_gpu_device->SetTextureSampler(0, m_vram_replacement_texture.get(), g_gpu_device->GetLinearSampler());
g_gpu_device->SetPipeline(m_copy_pipeline.get());
g_gpu_device->SetViewportAndScissor(dst_x, dst_y, width, height);
g_gpu_device->Draw(3, 0);
RestoreGraphicsAPIState();
return true;
@ -2052,18 +2052,18 @@ void GPU_HW::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color)
IncludeVRAMDirtyRectangle(
Common::Rectangle<u32>::FromExtents(x, y, width, height).Clamped(0, 0, VRAM_WIDTH, VRAM_HEIGHT));
g_host_display->SetPipeline(m_vram_fill_pipelines[BoolToUInt8(IsVRAMFillOversized(x, y, width, height))]
g_gpu_device->SetPipeline(m_vram_fill_pipelines[BoolToUInt8(IsVRAMFillOversized(x, y, width, height))]
[BoolToUInt8(IsInterlacedRenderingEnabled())]
.get());
const Common::Rectangle<u32> bounds(GetVRAMTransferBounds(x, y, width, height));
g_host_display->SetViewportAndScissor(bounds.left * m_resolution_scale, bounds.top * m_resolution_scale,
g_gpu_device->SetViewportAndScissor(bounds.left * m_resolution_scale, bounds.top * m_resolution_scale,
bounds.GetWidth() * m_resolution_scale,
bounds.GetHeight() * m_resolution_scale);
const VRAMFillUBOData uniforms = GetVRAMFillUBOData(x, y, width, height, color);
g_host_display->PushUniformBuffer(&uniforms, sizeof(uniforms));
g_host_display->Draw(3, 0);
g_gpu_device->PushUniformBuffer(&uniforms, sizeof(uniforms));
g_gpu_device->Draw(3, 0);
RestoreGraphicsAPIState();
}
@ -2083,15 +2083,15 @@ void GPU_HW::ReadVRAM(u32 x, u32 y, u32 width, u32 height)
// Encode the 24-bit texture as 16-bit.
const u32 uniforms[4] = {copy_rect.left, copy_rect.top, copy_rect.GetWidth(), copy_rect.GetHeight()};
g_host_display->SetPipeline(m_vram_readback_pipeline.get());
g_host_display->SetFramebuffer(m_vram_readback_framebuffer.get());
g_host_display->SetTextureSampler(0, m_vram_texture.get(), g_host_display->GetNearestSampler());
g_host_display->SetViewportAndScissor(0, 0, encoded_width, encoded_height);
g_host_display->PushUniformBuffer(uniforms, sizeof(uniforms));
g_host_display->Draw(3, 0);
g_gpu_device->SetPipeline(m_vram_readback_pipeline.get());
g_gpu_device->SetFramebuffer(m_vram_readback_framebuffer.get());
g_gpu_device->SetTextureSampler(0, m_vram_texture.get(), g_gpu_device->GetNearestSampler());
g_gpu_device->SetViewportAndScissor(0, 0, encoded_width, encoded_height);
g_gpu_device->PushUniformBuffer(uniforms, sizeof(uniforms));
g_gpu_device->Draw(3, 0);
// Stage the readback and copy it into our shadow buffer.
g_host_display->DownloadTexture(m_vram_readback_texture.get(), 0, 0, encoded_width, encoded_height,
g_gpu_device->DownloadTexture(m_vram_readback_texture.get(), 0, 0, encoded_width, encoded_height,
reinterpret_cast<u32*>(&m_vram_shadow[copy_rect.top * VRAM_WIDTH + copy_rect.left]),
VRAM_WIDTH * sizeof(u16));
@ -2133,12 +2133,12 @@ void GPU_HW::UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data, b
// the viewport should already be set to the full vram, so just adjust the scissor
const Common::Rectangle<u32> scaled_bounds = bounds * m_resolution_scale;
g_host_display->SetScissor(scaled_bounds.left, scaled_bounds.top, scaled_bounds.GetWidth(),
g_gpu_device->SetScissor(scaled_bounds.left, scaled_bounds.top, scaled_bounds.GetWidth(),
scaled_bounds.GetHeight());
g_host_display->SetPipeline(m_vram_write_pipelines[BoolToUInt8(check_mask && !m_pgxp_depth_buffer)].get());
g_host_display->PushUniformBuffer(&uniforms, sizeof(uniforms));
g_host_display->SetTextureBuffer(0, m_vram_upload_buffer.get());
g_host_display->Draw(3, 0);
g_gpu_device->SetPipeline(m_vram_write_pipelines[BoolToUInt8(check_mask && !m_pgxp_depth_buffer)].get());
g_gpu_device->PushUniformBuffer(&uniforms, sizeof(uniforms));
g_gpu_device->SetTextureBuffer(0, m_vram_upload_buffer.get());
g_gpu_device->Draw(3, 0);
RestoreGraphicsAPIState();
}
@ -2160,12 +2160,12 @@ void GPU_HW::CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32
// VRAM read texture should already be bound.
const Common::Rectangle<u32> dst_bounds_scaled(dst_bounds * m_resolution_scale);
g_host_display->SetViewportAndScissor(dst_bounds_scaled.left, dst_bounds_scaled.top, dst_bounds_scaled.GetWidth(),
g_gpu_device->SetViewportAndScissor(dst_bounds_scaled.left, dst_bounds_scaled.top, dst_bounds_scaled.GetWidth(),
dst_bounds_scaled.GetHeight());
g_host_display->SetPipeline(
g_gpu_device->SetPipeline(
m_vram_copy_pipelines[BoolToUInt8(m_GPUSTAT.check_mask_before_draw && !m_pgxp_depth_buffer)].get());
g_host_display->PushUniformBuffer(&uniforms, sizeof(uniforms));
g_host_display->Draw(3, 0);
g_gpu_device->PushUniformBuffer(&uniforms, sizeof(uniforms));
g_gpu_device->Draw(3, 0);
RestoreGraphicsAPIState();
if (m_GPUSTAT.check_mask_before_draw && !m_pgxp_depth_buffer)
@ -2192,7 +2192,7 @@ void GPU_HW::CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32
m_current_depth++;
}
g_host_display->CopyTextureRegion(m_vram_texture.get(), dst_x * m_resolution_scale, dst_y * m_resolution_scale, 0, 0,
g_gpu_device->CopyTextureRegion(m_vram_texture.get(), dst_x * m_resolution_scale, dst_y * m_resolution_scale, 0, 0,
m_vram_read_texture.get(), src_x * m_resolution_scale, src_y * m_resolution_scale,
0, 0, width * m_resolution_scale, height * m_resolution_scale);
}
@ -2324,7 +2324,7 @@ void GPU_HW::FlushRender()
if (m_batch_ubo_dirty)
{
g_host_display->UploadUniformBuffer(&m_batch_ubo_data, sizeof(m_batch_ubo_data));
g_gpu_device->UploadUniformBuffer(&m_batch_ubo_data, sizeof(m_batch_ubo_data));
m_renderer_stats.num_uniform_buffer_updates++;
m_batch_ubo_dirty = false;
}
@ -2351,21 +2351,21 @@ void GPU_HW::UpdateDisplay()
if (IsUsingMultisampling())
{
UpdateVRAMReadTexture();
g_host_display->SetDisplayTexture(m_vram_read_texture.get(), 0, 0, m_vram_read_texture->GetWidth(),
g_gpu_device->SetDisplayTexture(m_vram_read_texture.get(), 0, 0, m_vram_read_texture->GetWidth(),
m_vram_read_texture->GetHeight());
}
else
{
g_host_display->SetDisplayTexture(m_vram_texture.get(), 0, 0, m_vram_texture->GetWidth(),
g_gpu_device->SetDisplayTexture(m_vram_texture.get(), 0, 0, m_vram_texture->GetWidth(),
m_vram_texture->GetHeight());
}
g_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, 0, 0, VRAM_WIDTH, VRAM_HEIGHT,
g_gpu_device->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, 0, 0, VRAM_WIDTH, VRAM_HEIGHT,
static_cast<float>(VRAM_WIDTH) / static_cast<float>(VRAM_HEIGHT));
}
else
{
g_host_display->SetDisplayParameters(m_crtc_state.display_width, m_crtc_state.display_height,
g_gpu_device->SetDisplayParameters(m_crtc_state.display_width, m_crtc_state.display_height,
m_crtc_state.display_origin_left, m_crtc_state.display_origin_top,
m_crtc_state.display_vram_width, m_crtc_state.display_vram_height,
GetDisplayAspectRatio());
@ -2383,7 +2383,7 @@ void GPU_HW::UpdateDisplay()
if (IsDisplayDisabled())
{
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
}
else if (!m_GPUSTAT.display_area_color_depth_24 && interlaced == InterlacedRenderMode::None &&
!IsUsingMultisampling() && (scaled_vram_offset_x + scaled_display_width) <= m_vram_texture->GetWidth() &&
@ -2397,7 +2397,7 @@ void GPU_HW::UpdateDisplay()
}
else
{
g_host_display->SetDisplayTexture(m_vram_texture.get(), scaled_vram_offset_x, scaled_vram_offset_y,
g_gpu_device->SetDisplayTexture(m_vram_texture.get(), scaled_vram_offset_x, scaled_vram_offset_y,
scaled_display_width, scaled_display_height);
}
}
@ -2405,29 +2405,29 @@ void GPU_HW::UpdateDisplay()
{
// TODO: discard vs load for interlaced
if (interlaced == InterlacedRenderMode::None)
g_host_display->InvalidateRenderTarget(m_display_texture.get());
g_gpu_device->InvalidateRenderTarget(m_display_texture.get());
g_host_display->SetPipeline(
g_gpu_device->SetPipeline(
m_display_pipelines[BoolToUInt8(m_GPUSTAT.display_area_color_depth_24)][static_cast<u8>(interlaced)].get());
g_host_display->SetFramebuffer(m_display_framebuffer.get());
g_gpu_device->SetFramebuffer(m_display_framebuffer.get());
const u32 reinterpret_field_offset = (interlaced != InterlacedRenderMode::None) ? GetInterlacedDisplayField() : 0;
const u32 reinterpret_start_x = m_crtc_state.regs.X * resolution_scale;
const u32 reinterpret_crop_left = (m_crtc_state.display_vram_left - m_crtc_state.regs.X) * resolution_scale;
const u32 uniforms[4] = {reinterpret_start_x, scaled_vram_offset_y + reinterpret_field_offset,
reinterpret_crop_left, reinterpret_field_offset};
g_host_display->PushUniformBuffer(uniforms, sizeof(uniforms));
g_gpu_device->PushUniformBuffer(uniforms, sizeof(uniforms));
Assert(scaled_display_width <= m_display_texture->GetWidth() &&
scaled_display_height <= m_display_texture->GetHeight());
g_host_display->SetViewportAndScissor(0, 0, scaled_display_width, scaled_display_height);
g_host_display->Draw(3, 0);
g_gpu_device->SetViewportAndScissor(0, 0, scaled_display_width, scaled_display_height);
g_gpu_device->Draw(3, 0);
if (IsUsingDownsampling())
DownsampleFramebuffer(m_display_texture.get(), 0, 0, scaled_display_width, scaled_display_height);
else
g_host_display->SetDisplayTexture(m_display_texture.get(), 0, 0, scaled_display_width, scaled_display_height);
g_gpu_device->SetDisplayTexture(m_display_texture.get(), 0, 0, scaled_display_width, scaled_display_height);
RestoreGraphicsAPIState();
}
@ -2524,16 +2524,16 @@ void GPU_HW::DownsampleFramebufferBoxFilter(GPUTexture* source, u32 left, u32 to
source->MakeReadyForSampling();
g_host_display->ClearRenderTarget(m_downsample_texture.get(), 0);
g_host_display->SetFramebuffer(m_downsample_framebuffer.get());
g_host_display->SetPipeline(m_downsample_first_pass_pipeline.get());
g_host_display->SetTextureSampler(0, source, g_host_display->GetNearestSampler());
g_host_display->SetViewportAndScissor(ds_left, ds_top, ds_width, ds_height);
g_host_display->Draw(3, 0);
g_gpu_device->ClearRenderTarget(m_downsample_texture.get(), 0);
g_gpu_device->SetFramebuffer(m_downsample_framebuffer.get());
g_gpu_device->SetPipeline(m_downsample_first_pass_pipeline.get());
g_gpu_device->SetTextureSampler(0, source, g_gpu_device->GetNearestSampler());
g_gpu_device->SetViewportAndScissor(ds_left, ds_top, ds_width, ds_height);
g_gpu_device->Draw(3, 0);
RestoreGraphicsAPIState();
g_host_display->SetDisplayTexture(m_downsample_texture.get(), ds_left, ds_top, ds_width, ds_height);
g_gpu_device->SetDisplayTexture(m_downsample_texture.get(), ds_left, ds_top, ds_width, ds_height);
}
void GPU_HW::DrawRendererStats(bool is_idle_frame)

View File

@ -20,7 +20,7 @@ GPU_HW_D3D12::GPU_HW_D3D12() = default;
GPU_HW_D3D12::~GPU_HW_D3D12()
{
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
DestroyResources();
}
@ -124,7 +124,7 @@ void GPU_HW_D3D12::UpdateSettings()
}
// Everything should be finished executing before recreating resources.
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
g_d3d12_context->ExecuteCommandList(true);
if (framebuffer_changed)
@ -397,7 +397,7 @@ bool GPU_HW_D3D12::CompilePipelines()
D3D12::ShaderCache shader_cache;
shader_cache.Open(EmuFolders::Cache, g_d3d12_context->GetFeatureLevel(), g_settings.gpu_use_debug_device);
GPU_HW_ShaderGen shadergen(g_host_display->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading,
GPU_HW_ShaderGen shadergen(g_gpu_device->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading,
m_true_color, m_scaled_dithering, m_texture_filtering, m_using_uv_limits,
m_pgxp_depth_buffer, m_disable_color_perspective, m_supports_dual_source_blend);
@ -827,7 +827,7 @@ void GPU_HW_D3D12::ClearDisplay()
{
GPU_HW::ClearDisplay();
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
static constexpr float clear_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
m_display_texture.TransitionToState(D3D12_RESOURCE_STATE_RENDER_TARGET);
@ -844,20 +844,20 @@ void GPU_HW_D3D12::UpdateDisplay()
if (IsUsingMultisampling())
{
UpdateVRAMReadTexture();
g_host_display->SetDisplayTexture(&m_vram_read_texture, 0, 0, m_vram_read_texture.GetWidth(),
g_gpu_device->SetDisplayTexture(&m_vram_read_texture, 0, 0, m_vram_read_texture.GetWidth(),
m_vram_read_texture.GetHeight());
}
else
{
m_vram_texture.TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
g_host_display->SetDisplayTexture(&m_vram_texture, 0, 0, m_vram_texture.GetWidth(), m_vram_texture.GetHeight());
g_gpu_device->SetDisplayTexture(&m_vram_texture, 0, 0, m_vram_texture.GetWidth(), m_vram_texture.GetHeight());
}
g_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, 0, 0, VRAM_WIDTH, VRAM_HEIGHT,
g_gpu_device->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, 0, 0, VRAM_WIDTH, VRAM_HEIGHT,
static_cast<float>(VRAM_WIDTH) / static_cast<float>(VRAM_HEIGHT));
}
else
{
g_host_display->SetDisplayParameters(m_crtc_state.display_width, m_crtc_state.display_height,
g_gpu_device->SetDisplayParameters(m_crtc_state.display_width, m_crtc_state.display_height,
m_crtc_state.display_origin_left, m_crtc_state.display_origin_top,
m_crtc_state.display_vram_width, m_crtc_state.display_vram_height,
GetDisplayAspectRatio());
@ -875,14 +875,14 @@ void GPU_HW_D3D12::UpdateDisplay()
if (IsDisplayDisabled())
{
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
}
else if (!m_GPUSTAT.display_area_color_depth_24 && interlaced == InterlacedRenderMode::None &&
!IsUsingMultisampling() && (scaled_vram_offset_x + scaled_display_width) <= m_vram_texture.GetWidth() &&
(scaled_vram_offset_y + scaled_display_height) <= m_vram_texture.GetHeight())
{
m_vram_texture.TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
g_host_display->SetDisplayTexture(&m_vram_texture, scaled_vram_offset_x, scaled_vram_offset_y,
g_gpu_device->SetDisplayTexture(&m_vram_texture, scaled_vram_offset_x, scaled_vram_offset_y,
scaled_display_width, scaled_display_height);
}
else
@ -909,7 +909,7 @@ void GPU_HW_D3D12::UpdateDisplay()
m_display_texture.TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
m_vram_texture.TransitionToState(D3D12_RESOURCE_STATE_RENDER_TARGET);
g_host_display->SetDisplayTexture(&m_display_texture, 0, 0, scaled_display_width, scaled_display_height);
g_gpu_device->SetDisplayTexture(&m_display_texture, 0, 0, scaled_display_width, scaled_display_height);
RestoreGraphicsAPIState();
}

View File

@ -20,7 +20,7 @@ GPU_HW_Vulkan::GPU_HW_Vulkan() = default;
GPU_HW_Vulkan::~GPU_HW_Vulkan()
{
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
DestroyResources();
}
@ -119,7 +119,7 @@ void GPU_HW_Vulkan::UpdateSettings()
}
// Everything should be finished executing before recreating resources.
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
g_vulkan_context->ExecuteCommandBuffer(true);
if (framebuffer_changed)
@ -826,7 +826,7 @@ bool GPU_HW_Vulkan::CompilePipelines()
VkDevice device = g_vulkan_context->GetDevice();
VkPipelineCache pipeline_cache = g_vulkan_shader_cache->GetPipelineCache();
GPU_HW_ShaderGen shadergen(g_host_display->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading,
GPU_HW_ShaderGen shadergen(g_gpu_device->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading,
m_true_color, m_scaled_dithering, m_texture_filtering, m_using_uv_limits,
m_pgxp_depth_buffer, m_disable_color_perspective, m_supports_dual_source_blend);
@ -1300,7 +1300,7 @@ void GPU_HW_Vulkan::ClearDisplay()
GPU_HW::ClearDisplay();
EndRenderPass();
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
VkCommandBuffer cmdbuf = g_vulkan_context->GetCurrentCommandBuffer();
const Vulkan::Util::DebugScope debugScope(cmdbuf, "GPU_HW_Vulkan::ClearDisplay");
@ -1330,19 +1330,19 @@ void GPU_HW_Vulkan::UpdateDisplay()
UpdateVRAMReadTexture();
}
g_host_display->SetDisplayTexture(&m_vram_read_texture, 0, 0, m_vram_read_texture.GetWidth(),
g_gpu_device->SetDisplayTexture(&m_vram_read_texture, 0, 0, m_vram_read_texture.GetWidth(),
m_vram_read_texture.GetHeight());
}
else
{
g_host_display->SetDisplayTexture(&m_vram_texture, 0, 0, m_vram_texture.GetWidth(), m_vram_texture.GetHeight());
g_gpu_device->SetDisplayTexture(&m_vram_texture, 0, 0, m_vram_texture.GetWidth(), m_vram_texture.GetHeight());
}
g_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, 0, 0, VRAM_WIDTH, VRAM_HEIGHT,
g_gpu_device->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, 0, 0, VRAM_WIDTH, VRAM_HEIGHT,
static_cast<float>(VRAM_WIDTH) / static_cast<float>(VRAM_HEIGHT));
}
else
{
g_host_display->SetDisplayParameters(m_crtc_state.display_width, m_crtc_state.display_height,
g_gpu_device->SetDisplayParameters(m_crtc_state.display_width, m_crtc_state.display_height,
m_crtc_state.display_origin_left, m_crtc_state.display_origin_top,
m_crtc_state.display_vram_width, m_crtc_state.display_vram_height,
GetDisplayAspectRatio());
@ -1360,7 +1360,7 @@ void GPU_HW_Vulkan::UpdateDisplay()
if (IsDisplayDisabled())
{
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
}
else if (!m_GPUSTAT.display_area_color_depth_24 && interlaced == InterlacedRenderMode::None &&
!IsUsingMultisampling() && (scaled_vram_offset_x + scaled_display_width) <= m_vram_texture.GetWidth() &&
@ -1373,7 +1373,7 @@ void GPU_HW_Vulkan::UpdateDisplay()
}
else
{
g_host_display->SetDisplayTexture(&m_vram_texture, scaled_vram_offset_x, scaled_vram_offset_y,
g_gpu_device->SetDisplayTexture(&m_vram_texture, scaled_vram_offset_x, scaled_vram_offset_y,
scaled_display_width, scaled_display_height);
}
}
@ -1419,7 +1419,7 @@ void GPU_HW_Vulkan::UpdateDisplay()
}
else
{
g_host_display->SetDisplayTexture(&m_display_texture, 0, 0, scaled_display_width, scaled_display_height);
g_gpu_device->SetDisplayTexture(&m_display_texture, 0, 0, scaled_display_width, scaled_display_height);
RestoreGraphicsAPIState();
}
}
@ -1468,7 +1468,7 @@ void GPU_HW_Vulkan::ReadVRAM(u32 x, u32 y, u32 width, u32 height)
m_vram_texture.TransitionToLayout(cmdbuf, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
// Stage the readback and copy it into our shadow buffer (will execute command buffer and stall).
g_host_display->DownloadTexture(&m_vram_readback_texture, 0, 0, encoded_width, encoded_height,
g_gpu_device->DownloadTexture(&m_vram_readback_texture, 0, 0, encoded_width, encoded_height,
&m_vram_shadow[copy_rect.top * VRAM_WIDTH + copy_rect.left],
VRAM_WIDTH * sizeof(u16));
@ -1759,7 +1759,7 @@ void GPU_HW_Vulkan::DownsampleFramebufferBoxFilter(Vulkan::Texture& source, u32
RestoreGraphicsAPIState();
g_host_display->SetDisplayTexture(&m_downsample_texture, ds_left, ds_top, ds_width, ds_height);
g_gpu_device->SetDisplayTexture(&m_downsample_texture, ds_left, ds_top, ds_width, ds_height);
}
void GPU_HW_Vulkan::DownsampleFramebufferAdaptive(Vulkan::Texture& source, u32 left, u32 top, u32 width, u32 height)
@ -1856,5 +1856,5 @@ void GPU_HW_Vulkan::DownsampleFramebufferAdaptive(Vulkan::Texture& source, u32 l
}
RestoreGraphicsAPIState();
g_host_display->SetDisplayTexture(&m_display_texture, left, top, width, height);
g_gpu_device->SetDisplayTexture(&m_display_texture, left, top, width, height);
}

View File

@ -39,7 +39,7 @@ GPU_SW::GPU_SW()
GPU_SW::~GPU_SW()
{
m_backend.Shutdown();
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
}
const Threading::Thread* GPU_SW::GetSWThread() const
@ -63,7 +63,7 @@ bool GPU_SW::Initialize()
GPUTexture::Format::RGB565, GPUTexture::Format::RGBA5551);
for (const GPUTexture::Format format : formats_for_16bit)
{
if (g_host_display->SupportsTextureFormat(format))
if (g_gpu_device->SupportsTextureFormat(format))
{
m_16bit_display_format = format;
break;
@ -71,7 +71,7 @@ bool GPU_SW::Initialize()
}
for (const GPUTexture::Format format : formats_for_24bit)
{
if (g_host_display->SupportsTextureFormat(format))
if (g_gpu_device->SupportsTextureFormat(format))
{
m_24bit_display_format = format;
break;
@ -105,10 +105,10 @@ GPUTexture* GPU_SW::GetDisplayTexture(u32 width, u32 height, GPUTexture::Format
if (!m_display_texture || m_display_texture->GetWidth() != width || m_display_texture->GetHeight() != height ||
m_display_texture->GetFormat() != format)
{
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
m_display_texture.reset();
m_display_texture =
g_host_display->CreateTexture(width, height, 1, 1, 1, GPUTexture::Type::Texture, format, nullptr, 0, true);
g_gpu_device->CreateTexture(width, height, 1, 1, 1, GPUTexture::Type::Texture, format, nullptr, 0, true);
if (!m_display_texture)
Log_ErrorPrintf("Failed to create %ux%u %u texture", width, height, static_cast<u32>(format));
}
@ -317,7 +317,7 @@ void GPU_SW::CopyOut15Bit(u32 src_x, u32 src_y, u32 width, u32 height, u32 field
else
texture->Update(0, 0, width, height, m_display_texture_buffer.data(), output_stride);
g_host_display->SetDisplayTexture(texture, 0, 0, width, height);
g_gpu_device->SetDisplayTexture(texture, 0, 0, width, height);
}
void GPU_SW::CopyOut15Bit(GPUTexture::Format display_format, u32 src_x, u32 src_y, u32 width, u32 height, u32 field,
@ -475,7 +475,7 @@ void GPU_SW::CopyOut24Bit(u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 heigh
else
texture->Update(0, 0, width, height, m_display_texture_buffer.data(), output_stride);
g_host_display->SetDisplayTexture(texture, 0, 0, width, height);
g_gpu_device->SetDisplayTexture(texture, 0, 0, width, height);
}
void GPU_SW::CopyOut24Bit(GPUTexture::Format display_format, u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 height,
@ -512,14 +512,14 @@ void GPU_SW::UpdateDisplay()
if (!g_settings.debugging.show_vram)
{
g_host_display->SetDisplayParameters(m_crtc_state.display_width, m_crtc_state.display_height,
g_gpu_device->SetDisplayParameters(m_crtc_state.display_width, m_crtc_state.display_height,
m_crtc_state.display_origin_left, m_crtc_state.display_origin_top,
m_crtc_state.display_vram_width, m_crtc_state.display_vram_height,
GetDisplayAspectRatio());
if (IsDisplayDisabled())
{
g_host_display->ClearDisplayTexture();
g_gpu_device->ClearDisplayTexture();
return;
}
@ -560,7 +560,7 @@ void GPU_SW::UpdateDisplay()
else
{
CopyOut15Bit(m_16bit_display_format, 0, 0, VRAM_WIDTH, VRAM_HEIGHT, 0, false, false);
g_host_display->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, 0, 0, VRAM_WIDTH, VRAM_HEIGHT,
g_gpu_device->SetDisplayParameters(VRAM_WIDTH, VRAM_HEIGHT, 0, 0, VRAM_WIDTH, VRAM_HEIGHT,
static_cast<float>(VRAM_WIDTH) / static_cast<float>(VRAM_HEIGHT));
}
}

View File

@ -190,14 +190,14 @@ void UpdateAspectRatio()
{
case DisplayAspectRatio::MatchWindow:
{
if (!g_host_display)
if (!g_gpu_device)
{
s_aspect_ratio = DisplayAspectRatio::R4_3;
return;
}
num = g_host_display->GetWindowWidth();
denom = g_host_display->GetWindowHeight();
num = g_gpu_device->GetWindowWidth();
denom = g_gpu_device->GetWindowHeight();
}
break;

View File

@ -177,8 +177,8 @@ bool GunCon::Transfer(const u8 data_in, u8* data_out)
void GunCon::UpdatePosition()
{
// get screen coordinates
const s32 mouse_x = g_host_display->GetMousePositionX();
const s32 mouse_y = g_host_display->GetMousePositionY();
const s32 mouse_x = g_gpu_device->GetMousePositionX();
const s32 mouse_y = g_gpu_device->GetMousePositionY();
// are we within the active display area?
u32 tick, line;

View File

@ -16,8 +16,8 @@ static constexpr std::array<u8, static_cast<size_t>(PlayStationMouse::Button::Co
PlayStationMouse::PlayStationMouse(u32 index) : Controller(index)
{
m_last_host_position_x = g_host_display->GetMousePositionX();
m_last_host_position_y = g_host_display->GetMousePositionY();
m_last_host_position_x = g_gpu_device->GetMousePositionX();
m_last_host_position_y = g_gpu_device->GetMousePositionY();
}
PlayStationMouse::~PlayStationMouse() = default;
@ -157,8 +157,8 @@ bool PlayStationMouse::Transfer(const u8 data_in, u8* data_out)
void PlayStationMouse::UpdatePosition()
{
// get screen coordinates
const s32 mouse_x = g_host_display->GetMousePositionX();
const s32 mouse_y = g_host_display->GetMousePositionY();
const s32 mouse_x = g_gpu_device->GetMousePositionX();
const s32 mouse_y = g_gpu_device->GetMousePositionY();
const s32 delta_x = mouse_x - m_last_host_position_x;
const s32 delta_y = mouse_y - m_last_host_position_y;
m_last_host_position_x = mouse_x;

View File

@ -1081,11 +1081,11 @@ float Settings::GetDisplayAspectRatioValue() const
{
case DisplayAspectRatio::MatchWindow:
{
if (!g_host_display)
if (!g_gpu_device)
return s_display_aspect_ratio_values[static_cast<int>(DEFAULT_DISPLAY_ASPECT_RATIO)];
return static_cast<float>(g_host_display->GetWindowWidth()) /
static_cast<float>(g_host_display->GetWindowHeight());
return static_cast<float>(g_gpu_device->GetWindowWidth()) /
static_cast<float>(g_gpu_device->GetWindowHeight());
}
case DisplayAspectRatio::Custom:

View File

@ -1134,7 +1134,7 @@ bool System::BootSystem(SystemBootParameters parameters)
Assert(s_state == State::Shutdown);
s_state = State::Starting;
s_startup_cancelled.store(false);
s_keep_gpu_device_on_shutdown = static_cast<bool>(g_host_display);
s_keep_gpu_device_on_shutdown = static_cast<bool>(g_gpu_device);
s_region = g_settings.region;
Host::OnSystemStarting();
@ -1523,9 +1523,9 @@ void System::DestroySystem()
ClearRunningGame();
// Restore present-all-frames behavior.
if (s_keep_gpu_device_on_shutdown && g_host_display)
if (s_keep_gpu_device_on_shutdown && g_gpu_device)
{
g_host_display->SetDisplayMaxFPS(0.0f);
g_gpu_device->SetDisplayMaxFPS(0.0f);
UpdateSoftwareCursor();
}
else
@ -1577,11 +1577,11 @@ void System::Execute()
PauseSystem(true);
}
const bool skip_present = g_host_display->ShouldSkipDisplayingFrame();
const bool skip_present = g_gpu_device->ShouldSkipDisplayingFrame();
Host::RenderDisplay(skip_present);
if (!skip_present && g_host_display->IsGPUTimingEnabled())
if (!skip_present && g_gpu_device->IsGPUTimingEnabled())
{
s_accumulated_gpu_time += g_host_display->GetAndResetAccumulatedGPUTime();
s_accumulated_gpu_time += g_gpu_device->GetAndResetAccumulatedGPUTime();
s_presents_since_last_update++;
}
@ -1635,12 +1635,12 @@ bool System::CreateGPU(GPURenderer renderer)
{
const RenderAPI api = Settings::GetRenderAPIForRenderer(renderer);
if (!g_host_display || g_host_display->GetRenderAPI() != api)
if (!g_gpu_device || g_gpu_device->GetRenderAPI() != api)
{
if (g_host_display)
if (g_gpu_device)
{
Log_WarningPrintf("Recreating GPU device, expecting %s got %s", GPUDevice::RenderAPIToString(api),
GPUDevice::RenderAPIToString(g_host_display->GetRenderAPI()));
GPUDevice::RenderAPIToString(g_gpu_device->GetRenderAPI()));
}
Host::ReleaseGPUDevice();
@ -2079,7 +2079,7 @@ bool System::InternalSaveState(ByteStream* state, u32 screenshot_size /* = 256 *
if (screenshot_size > 0)
{
// assume this size is the width
const float display_aspect_ratio = g_host_display->GetDisplayAspectRatio();
const float display_aspect_ratio = g_gpu_device->GetDisplayAspectRatio();
const u32 screenshot_width = screenshot_size;
const u32 screenshot_height =
std::max(1u, static_cast<u32>(static_cast<float>(screenshot_width) /
@ -2089,7 +2089,7 @@ bool System::InternalSaveState(ByteStream* state, u32 screenshot_size /* = 256 *
std::vector<u32> screenshot_buffer;
u32 screenshot_stride;
GPUTexture::Format screenshot_format;
if (g_host_display->RenderScreenshot(screenshot_width, screenshot_height,
if (g_gpu_device->RenderScreenshot(screenshot_width, screenshot_height,
Common::Rectangle<s32>::FromExtents(0, 0, screenshot_width, screenshot_height),
&screenshot_buffer, &screenshot_stride, &screenshot_format) &&
GPUTexture::ConvertTextureDataToRGBA8(screenshot_width, screenshot_height, screenshot_buffer, screenshot_stride,
@ -2102,7 +2102,7 @@ bool System::InternalSaveState(ByteStream* state, u32 screenshot_size /* = 256 *
}
else
{
if (g_host_display->UsesLowerLeftOrigin())
if (g_gpu_device->UsesLowerLeftOrigin())
{
GPUTexture::FlipTextureDataRGBA8(screenshot_width, screenshot_height, screenshot_buffer, screenshot_stride);
}
@ -2367,7 +2367,7 @@ void System::UpdatePerformanceCounters()
s_fps_timer.ResetTo(now_ticks);
if (g_host_display->IsGPUTimingEnabled())
if (g_gpu_device->IsGPUTimingEnabled())
{
s_average_gpu_time = s_accumulated_gpu_time / static_cast<float>(std::max(s_presents_since_last_update, 1u));
s_gpu_usage = s_accumulated_gpu_time / (time * 10.0f);
@ -2414,7 +2414,7 @@ void System::UpdateSpeedLimiterState()
s_target_speed == 1.0f && IsValid())
{
float host_refresh_rate;
if (g_host_display->GetHostRefreshRate(&host_refresh_rate))
if (g_gpu_device->GetHostRefreshRate(&host_refresh_rate))
{
const float ratio = host_refresh_rate / System::GetThrottleFrequency();
s_syncing_to_host = (ratio >= 0.95f && ratio <= 1.05f);
@ -2470,8 +2470,8 @@ void System::UpdateDisplaySync()
Log_VerbosePrintf("Max display fps: %f (%s)", max_display_fps,
s_display_all_frames ? "displaying all frames" : "skipping displaying frames when needed");
g_host_display->SetDisplayMaxFPS(max_display_fps);
g_host_display->SetVSync(video_sync_enabled);
g_gpu_device->SetDisplayMaxFPS(max_display_fps);
g_gpu_device->SetVSync(video_sync_enabled);
}
bool System::ShouldUseVSync()
@ -3436,13 +3436,13 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
{
if (g_settings.display_post_processing && !g_settings.display_post_process_chain.empty())
{
if (!g_host_display->SetPostProcessingChain(g_settings.display_post_process_chain))
if (!g_gpu_device->SetPostProcessingChain(g_settings.display_post_process_chain))
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to load post processing shader chain."),
20.0f);
}
else
{
g_host_display->SetPostProcessingChain({});
g_gpu_device->SetPostProcessingChain({});
}
}
}
@ -3934,7 +3934,7 @@ bool System::SaveScreenshot(const char* filename /* = nullptr */, bool full_reso
return false;
}
const bool screenshot_saved = g_host_display->WriteScreenshotToFile(
const bool screenshot_saved = g_gpu_device->WriteScreenshotToFile(
filename, g_settings.display_internal_resolution_screenshots, compress_on_thread);
if (!screenshot_saved)
@ -4293,7 +4293,7 @@ void System::TogglePostProcessing()
Host::AddKeyedOSDMessage("PostProcessing",
Host::TranslateStdString("OSDMessage", "Post-processing is now enabled."), 10.0f);
if (!g_host_display->SetPostProcessingChain(g_settings.display_post_process_chain))
if (!g_gpu_device->SetPostProcessingChain(g_settings.display_post_process_chain))
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to load post processing shader chain."),
20.0f);
}
@ -4301,7 +4301,7 @@ void System::TogglePostProcessing()
{
Host::AddKeyedOSDMessage("PostProcessing",
Host::TranslateStdString("OSDMessage", "Post-processing is now disabled."), 10.0f);
g_host_display->SetPostProcessingChain({});
g_gpu_device->SetPostProcessingChain({});
}
}
@ -4310,7 +4310,7 @@ void System::ReloadPostProcessingShaders()
if (!IsValid() || !g_settings.display_post_processing)
return;
if (!g_host_display->SetPostProcessingChain(g_settings.display_post_process_chain))
if (!g_gpu_device->SetPostProcessingChain(g_settings.display_post_process_chain))
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to load post-processing shader chain."), 20.0f);
else
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Post-processing shaders reloaded."), 10.0f);
@ -4378,7 +4378,7 @@ void System::UpdateSoftwareCursor()
if (!IsValid())
{
Host::SetMouseMode(false, false);
g_host_display->ClearSoftwareCursor();
g_gpu_device->ClearSoftwareCursor();
return;
}
@ -4401,12 +4401,12 @@ void System::UpdateSoftwareCursor()
if (image && image->IsValid())
{
g_host_display->SetSoftwareCursor(image->GetPixels(), image->GetWidth(), image->GetHeight(), image->GetPitch(),
g_gpu_device->SetSoftwareCursor(image->GetPixels(), image->GetWidth(), image->GetHeight(), image->GetPitch(),
image_scale);
}
else
{
g_host_display->ClearSoftwareCursor();
g_gpu_device->ClearSoftwareCursor();
}
}
@ -4419,13 +4419,13 @@ void System::RequestDisplaySize(float scale /*= 0.0f*/)
scale = g_gpu->IsHardwareRenderer() ? static_cast<float>(g_settings.gpu_resolution_scale) : 1.0f;
const float y_scale =
(static_cast<float>(g_host_display->GetDisplayWidth()) / static_cast<float>(g_host_display->GetDisplayHeight())) /
g_host_display->GetDisplayAspectRatio();
(static_cast<float>(g_gpu_device->GetDisplayWidth()) / static_cast<float>(g_gpu_device->GetDisplayHeight())) /
g_gpu_device->GetDisplayAspectRatio();
const u32 requested_width =
std::max<u32>(static_cast<u32>(std::ceil(static_cast<float>(g_host_display->GetDisplayWidth()) * scale)), 1);
std::max<u32>(static_cast<u32>(std::ceil(static_cast<float>(g_gpu_device->GetDisplayWidth()) * scale)), 1);
const u32 requested_height = std::max<u32>(
static_cast<u32>(std::ceil(static_cast<float>(g_host_display->GetDisplayHeight()) * y_scale * scale)), 1);
static_cast<u32>(std::ceil(static_cast<float>(g_gpu_device->GetDisplayHeight()) * y_scale * scale)), 1);
Host::RequestResizeHostDisplay(static_cast<s32>(requested_width), static_cast<s32>(requested_height));
}

View File

@ -413,7 +413,7 @@ void NoGUIHost::StartSystem(SystemBootParameters params)
void NoGUIHost::ProcessPlatformWindowResize(s32 width, s32 height, float scale)
{
Host::RunOnCPUThread([width, height, scale]() {
g_host_display->ResizeWindow(width, height, scale);
g_gpu_device->ResizeWindow(width, height, scale);
ImGuiManager::WindowResized();
System::HostDisplayResized();
});
@ -421,8 +421,8 @@ void NoGUIHost::ProcessPlatformWindowResize(s32 width, s32 height, float scale)
void NoGUIHost::ProcessPlatformMouseMoveEvent(float x, float y)
{
if (g_host_display)
g_host_display->SetMousePosition(static_cast<s32>(x), static_cast<s32>(y));
if (g_gpu_device)
g_gpu_device->SetMousePosition(static_cast<s32>(x), static_cast<s32>(y));
InputManager::UpdatePointerAbsolutePosition(0, x, y);
ImGuiManager::UpdateMousePosition(x, y);
@ -645,8 +645,8 @@ void NoGUIHost::CPUThreadMainLoop()
Host::PumpMessagesOnCPUThread();
Host::RenderDisplay(false);
if (!g_host_display->IsVsyncEnabled())
g_host_display->ThrottlePresentation();
if (!g_gpu_device->IsVsyncEnabled())
g_gpu_device->ThrottlePresentation();
}
}
@ -748,7 +748,7 @@ void Host::RenderDisplay(bool skip_present)
ImGuiManager::RenderOverlayWindows();
ImGuiManager::RenderDebugWindows();
g_host_display->Render(skip_present);
g_gpu_device->Render(skip_present);
ImGuiManager::NewFrame();
}

View File

@ -471,7 +471,7 @@ void MainWindow::updateDisplayWidgetCursor()
void MainWindow::updateDisplayRelatedActions(bool has_surface, bool render_to_main, bool fullscreen)
{
// rendering to main, or switched to gamelist/grid
m_ui.actionViewSystemDisplay->setEnabled((has_surface && render_to_main) || (!has_surface && g_host_display));
m_ui.actionViewSystemDisplay->setEnabled((has_surface && render_to_main) || (!has_surface && g_gpu_device));
m_ui.menuWindowSize->setEnabled(has_surface && !fullscreen);
m_ui.actionFullscreen->setEnabled(has_surface);
@ -1782,7 +1782,7 @@ bool MainWindow::isShowingGameList() const
bool MainWindow::isRenderingFullscreen() const
{
if (!g_host_display || !m_display_widget)
if (!g_gpu_device || !m_display_widget)
return false;
return getDisplayContainer()->isFullScreen();

View File

@ -339,13 +339,13 @@ void EmuThread::checkForSettingsChanges(const Settings& old_settings)
updatePerformanceCounters();
}
if (g_host_display)
if (g_gpu_device)
{
const bool render_to_main = shouldRenderToMain();
if (m_is_rendering_to_main != render_to_main)
{
m_is_rendering_to_main = render_to_main;
g_host_display->UpdateWindow();
g_gpu_device->UpdateWindow();
}
}
}
@ -477,7 +477,7 @@ void EmuThread::stopFullscreenUI()
QMetaObject::invokeMethod(this, &EmuThread::stopFullscreenUI, Qt::QueuedConnection);
// wait until the host display is gone
while (g_host_display)
while (g_gpu_device)
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1);
return;
@ -486,7 +486,7 @@ void EmuThread::stopFullscreenUI()
if (System::IsValid())
shutdownSystem();
if (!g_host_display)
if (!g_gpu_device)
return;
m_run_fullscreen_ui = false;
@ -571,8 +571,8 @@ void EmuThread::onDisplayWindowMouseMoveEvent(bool relative, float x, float y)
DebugAssert(isOnThread());
if (!relative)
{
if (g_host_display)
g_host_display->SetMousePosition(static_cast<s32>(x), static_cast<s32>(y));
if (g_gpu_device)
g_gpu_device->SetMousePosition(static_cast<s32>(x), static_cast<s32>(y));
InputManager::UpdatePointerAbsolutePosition(0, x, y);
ImGuiManager::UpdateMousePosition(x, y);
@ -584,11 +584,11 @@ void EmuThread::onDisplayWindowMouseMoveEvent(bool relative, float x, float y)
if (y != 0.0f)
InputManager::UpdatePointerRelativeDelta(0, InputPointerAxis::Y, y);
if (g_host_display)
if (g_gpu_device)
{
const float abs_x = static_cast<float>(g_host_display->GetMousePositionX()) + x;
const float abs_y = static_cast<float>(g_host_display->GetMousePositionY()) + y;
g_host_display->SetMousePosition(static_cast<s32>(abs_x), static_cast<s32>(abs_y));
const float abs_x = static_cast<float>(g_gpu_device->GetMousePositionX()) + x;
const float abs_y = static_cast<float>(g_gpu_device->GetMousePositionY()) + y;
g_gpu_device->SetMousePosition(static_cast<s32>(abs_x), static_cast<s32>(abs_y));
ImGuiManager::UpdateMousePosition(abs_x, abs_y);
}
}
@ -628,7 +628,7 @@ void EmuThread::redrawDisplayWindow()
return;
}
if (!g_host_display || System::IsShutdown())
if (!g_gpu_device || System::IsShutdown())
return;
renderDisplay(false);
@ -654,7 +654,7 @@ void EmuThread::setFullscreen(bool fullscreen, bool allow_render_to_main)
return;
}
if (!g_host_display || m_is_fullscreen == fullscreen)
if (!g_gpu_device || m_is_fullscreen == fullscreen)
return;
m_is_fullscreen = fullscreen;
@ -680,7 +680,7 @@ void EmuThread::setSurfaceless(bool surfaceless)
return;
}
if (!g_host_display || m_is_surfaceless == surfaceless)
if (!g_gpu_device || m_is_surfaceless == surfaceless)
return;
m_is_surfaceless = surfaceless;
@ -703,10 +703,10 @@ void EmuThread::requestDisplaySize(float scale)
std::optional<WindowInfo> EmuThread::acquireRenderWindow(bool recreate_window)
{
DebugAssert(g_host_display);
DebugAssert(g_gpu_device);
u32 fs_width, fs_height;
float fs_refresh_rate;
m_is_exclusive_fullscreen = (m_is_fullscreen && g_host_display->SupportsExclusiveFullscreen() &&
m_is_exclusive_fullscreen = (m_is_fullscreen && g_gpu_device->SupportsExclusiveFullscreen() &&
GPUDevice::GetRequestedExclusiveFullscreenMode(&fs_width, &fs_height, &fs_refresh_rate));
const bool window_fullscreen = m_is_fullscreen && !m_is_exclusive_fullscreen;
@ -1363,11 +1363,11 @@ void EmuThread::run()
m_event_loop->processEvents(QEventLoop::AllEvents);
CommonHost::PumpMessagesOnCPUThread();
if (g_host_display)
if (g_gpu_device)
{
renderDisplay(false);
if (!g_host_display->IsVsyncEnabled())
g_host_display->ThrottlePresentation();
if (!g_gpu_device->IsVsyncEnabled())
g_gpu_device->ThrottlePresentation();
}
}
}
@ -1398,7 +1398,7 @@ void EmuThread::renderDisplay(bool skip_present)
ImGuiManager::RenderOverlayWindows();
ImGuiManager::RenderDebugWindows();
g_host_display->Render(skip_present);
g_gpu_device->Render(skip_present);
ImGuiManager::NewFrame();
}
@ -1544,7 +1544,7 @@ void Host::ReleaseRenderWindow()
void EmuThread::updatePerformanceCounters()
{
const RenderAPI render_api = g_host_display ? g_host_display->GetRenderAPI() : RenderAPI::None;
const RenderAPI render_api = g_gpu_device ? g_gpu_device->GetRenderAPI() : RenderAPI::None;
const bool hardware_renderer = g_gpu && g_gpu->IsHardwareRenderer();
u32 render_width = 0;
u32 render_height = 0;

View File

@ -287,13 +287,13 @@ void Host::SetFullscreen(bool enabled)
bool Host::AcquireHostDisplay(RenderAPI api)
{
g_host_display = std::make_unique<RegTestHostDisplay>();
g_gpu_device = std::make_unique<RegTestHostDisplay>();
return true;
}
void Host::ReleaseHostDisplay()
{
g_host_display.reset();
g_gpu_device.reset();
}
void Host::RenderDisplay(bool skip_present)
@ -302,7 +302,7 @@ void Host::RenderDisplay(bool skip_present)
if (s_frame_dump_interval > 0 && (s_frame_dump_interval == 1 || (frame % s_frame_dump_interval) == 0))
{
std::string dump_filename(RegTestHost::GetFrameDumpFilename(frame));
g_host_display->WriteDisplayTextureToFile(std::move(dump_filename));
g_gpu_device->WriteDisplayTextureToFile(std::move(dump_filename));
}
}

View File

@ -131,29 +131,29 @@ void CommonHost::PumpMessagesOnCPUThread()
bool Host::CreateGPUDevice(RenderAPI api)
{
DebugAssert(!g_host_display);
DebugAssert(!g_gpu_device);
Log_InfoPrintf("Trying to create a %s GPU device...", GPUDevice::RenderAPIToString(api));
g_host_display = GPUDevice::CreateDeviceForAPI(api);
g_gpu_device = GPUDevice::CreateDeviceForAPI(api);
// TODO: option to disable shader cache
// TODO: FSUI should always use vsync..
const bool vsync = System::IsValid() ? System::ShouldUseVSync() : g_settings.video_sync_enabled;
if (!g_host_display ||
!g_host_display->Create(g_settings.gpu_adapter, EmuFolders::Cache, g_settings.gpu_use_debug_device, vsync))
if (!g_gpu_device ||
!g_gpu_device->Create(g_settings.gpu_adapter, EmuFolders::Cache, g_settings.gpu_use_debug_device, vsync))
{
Log_ErrorPrintf("Failed to initialize GPU device.");
if (g_host_display)
g_host_display->Destroy();
g_host_display.reset();
if (g_gpu_device)
g_gpu_device->Destroy();
g_gpu_device.reset();
return false;
}
if (!ImGuiManager::Initialize())
{
Log_ErrorPrintf("Failed to initialize ImGuiManager.");
g_host_display->Destroy();
g_host_display.reset();
g_gpu_device->Destroy();
g_gpu_device.reset();
return false;
}
@ -162,10 +162,10 @@ bool Host::CreateGPUDevice(RenderAPI api)
void Host::UpdateDisplayWindow()
{
if (!g_host_display)
if (!g_gpu_device)
return;
if (!g_host_display->UpdateWindow())
if (!g_gpu_device->UpdateWindow())
{
Host::ReportErrorAsync("Error", "Failed to change window after update. The log may contain more information.");
return;
@ -180,12 +180,12 @@ void Host::UpdateDisplayWindow()
void Host::ResizeDisplayWindow(s32 width, s32 height, float scale)
{
if (!g_host_display)
if (!g_gpu_device)
return;
Log_DevPrintf("Display window resized to %dx%d", width, height);
g_host_display->ResizeWindow(width, height, scale);
g_gpu_device->ResizeWindow(width, height, scale);
ImGuiManager::WindowResized();
// If we're paused, re-present the current frame at the new window size.
@ -200,15 +200,15 @@ void Host::ResizeDisplayWindow(s32 width, s32 height, float scale)
void Host::ReleaseGPUDevice()
{
if (!g_host_display)
if (!g_gpu_device)
return;
SaveStateSelectorUI::DestroyTextures();
ImGuiManager::Shutdown();
Log_InfoPrintf("Destroying %s GPU device...", GPUDevice::RenderAPIToString(g_host_display->GetRenderAPI()));
g_host_display->Destroy();
g_host_display.reset();
Log_InfoPrintf("Destroying %s GPU device...", GPUDevice::RenderAPIToString(g_gpu_device->GetRenderAPI()));
g_gpu_device->Destroy();
g_gpu_device.reset();
}
#ifndef __ANDROID__
@ -503,7 +503,7 @@ void Host::DisplayLoadingScreen(const char* message, int progress_min /*= -1*/,
ImGui::End();
ImGui::EndFrame();
g_host_display->Render(false);
g_gpu_device->Render(false);
ImGui::NewFrame();
}

View File

@ -2355,7 +2355,7 @@ void FullscreenUI::SwitchToGameSettings(const GameList::Entry* entry)
void FullscreenUI::PopulateGraphicsAdapterList()
{
GPUDevice::AdapterAndModeList ml(g_host_display->GetAdapterAndModeList());
GPUDevice::AdapterAndModeList ml(g_gpu_device->GetAdapterAndModeList());
s_graphics_adapter_list_cache = std::move(ml.adapter_names);
s_fullscreen_mode_list_cache = std::move(ml.fullscreen_modes);
s_fullscreen_mode_list_cache.insert(s_fullscreen_mode_list_cache.begin(), "Borderless Fullscreen");
@ -3544,7 +3544,7 @@ void FullscreenUI::DrawDisplaySettingsPage()
adapter.has_value() ? (adapter->empty() ? "Default" : adapter->c_str()) :
"Use Global Setting"))
{
GPUDevice::AdapterAndModeList aml(g_host_display->GetAdapterAndModeList());
GPUDevice::AdapterAndModeList aml(g_gpu_device->GetAdapterAndModeList());
ImGuiFullscreen::ChoiceDialogOptions options;
options.reserve(aml.adapter_names.size() + 2);
@ -3588,7 +3588,7 @@ void FullscreenUI::DrawDisplaySettingsPage()
fsmode.has_value() ? (fsmode->empty() ? "Borderless Fullscreen" : fsmode->c_str()) :
"Use Global Setting"))
{
GPUDevice::AdapterAndModeList aml(g_host_display->GetAdapterAndModeList());
GPUDevice::AdapterAndModeList aml(g_gpu_device->GetAdapterAndModeList());
ImGuiFullscreen::ChoiceDialogOptions options;
options.reserve(aml.fullscreen_modes.size() + 2);
@ -3819,7 +3819,7 @@ void FullscreenUI::SavePostProcessingChain()
const std::string config(s_postprocessing_chain.GetConfigString());
bsi->SetStringValue("Display", "PostProcessChain", config.c_str());
if (bsi->GetBoolValue("Display", "PostProcessing", false))
g_host_display->SetPostProcessingChain(config);
g_gpu_device->SetPostProcessingChain(config);
if (IsEditingGameSettings(bsi))
{
s_game_settings_interface->Save();
@ -3854,7 +3854,7 @@ void FullscreenUI::DrawPostProcessingSettingsPage()
bsi->GetBoolValue("Display", "PostProcessing", false)))
{
const std::string chain(bsi->GetStringValue("Display", "PostProcessChain", ""));
g_host_display->SetPostProcessingChain(chain);
g_gpu_device->SetPostProcessingChain(chain);
if (chain.empty())
ShowToast(std::string(), "Post-processing chain is empty.");
else
@ -4860,13 +4860,13 @@ void FullscreenUI::PopulateSaveStateScreenshot(SaveStateListEntry* li, const Ext
li->preview_texture.reset();
if (ssi && !ssi->screenshot_data.empty())
{
li->preview_texture = g_host_display->CreateTexture(
li->preview_texture = g_gpu_device->CreateTexture(
ssi->screenshot_width, ssi->screenshot_height, 1, 1, 1, GPUTexture::Type::Texture, GPUTexture::Format::RGBA8,
ssi->screenshot_data.data(), sizeof(u32) * ssi->screenshot_width, false);
}
else
{
li->preview_texture = g_host_display->CreateTexture(
li->preview_texture = g_gpu_device->CreateTexture(
PLACEHOLDER_ICON_WIDTH, PLACEHOLDER_ICON_HEIGHT, 1, 1, 1, GPUTexture::Type::Texture, GPUTexture::Format::RGBA8,
PLACEHOLDER_ICON_DATA, sizeof(u32) * PLACEHOLDER_ICON_WIDTH, false);
}

View File

@ -268,7 +268,7 @@ std::optional<Common::RGBA8Image> ImGuiFullscreen::LoadTextureImage(const char*
std::shared_ptr<GPUTexture> ImGuiFullscreen::UploadTexture(const char* path, const Common::RGBA8Image& image)
{
std::unique_ptr<GPUTexture> texture =
g_host_display->CreateTexture(image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Type::Texture,
g_gpu_device->CreateTexture(image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Type::Texture,
GPUTexture::Format::RGBA8, image.GetPixels(), image.GetPitch());
if (!texture)
{

View File

@ -84,7 +84,7 @@ bool ImGuiManager::Initialize()
}
s_global_scale =
std::max(g_host_display->GetWindowScale() * static_cast<float>(g_settings.display_osd_scale / 100.0f), 1.0f);
std::max(g_gpu_device->GetWindowScale() * static_cast<float>(g_settings.display_osd_scale / 100.0f), 1.0f);
ImGui::CreateContext();
@ -102,15 +102,15 @@ bool ImGuiManager::Initialize()
#endif
io.DisplayFramebufferScale = ImVec2(1, 1); // We already scale things ourselves, this would double-apply scaling
io.DisplaySize.x = static_cast<float>(g_host_display->GetWindowWidth());
io.DisplaySize.y = static_cast<float>(g_host_display->GetWindowHeight());
io.DisplaySize.x = static_cast<float>(g_gpu_device->GetWindowWidth());
io.DisplaySize.y = static_cast<float>(g_gpu_device->GetWindowHeight());
SetKeyMap();
SetStyle();
AssertMsg(!FullscreenUI::IsInitialized(), "Fullscreen UI is not initialized on ImGui init");
if (!AddImGuiFonts(false) || !g_host_display->UpdateImGuiFontTexture())
if (!AddImGuiFonts(false) || !g_gpu_device->UpdateImGuiFontTexture())
{
Panic("Failed to create ImGui font text");
ImGui::DestroyContext();
@ -140,8 +140,8 @@ void ImGuiManager::Shutdown()
void ImGuiManager::WindowResized()
{
const u32 new_width = g_host_display ? g_host_display->GetWindowWidth() : 0;
const u32 new_height = g_host_display ? g_host_display->GetWindowHeight() : 0;
const u32 new_width = g_gpu_device ? g_gpu_device->GetWindowWidth() : 0;
const u32 new_height = g_gpu_device ? g_gpu_device->GetWindowHeight() : 0;
ImGui::GetIO().DisplaySize = ImVec2(static_cast<float>(new_width), static_cast<float>(new_height));
@ -154,7 +154,7 @@ void ImGuiManager::WindowResized()
void ImGuiManager::UpdateScale()
{
const float window_scale = g_host_display ? g_host_display->GetWindowScale() : 1.0f;
const float window_scale = g_gpu_device ? g_gpu_device->GetWindowScale() : 1.0f;
const float scale = std::max(window_scale * static_cast<float>(g_settings.display_osd_scale / 100.0f), 1.0f);
if (scale == s_global_scale && (!HasFullscreenFonts() || !ImGuiFullscreen::UpdateLayoutScale()))
@ -173,7 +173,7 @@ void ImGuiManager::UpdateScale()
if (!AddImGuiFonts(HasFullscreenFonts()))
Panic("Failed to create ImGui font text");
if (!g_host_display->UpdateImGuiFontTexture())
if (!g_gpu_device->UpdateImGuiFontTexture())
Panic("Failed to recreate font texture after scale+resize");
NewFrame();
@ -528,7 +528,7 @@ bool ImGuiManager::AddFullscreenFontsIfMissing()
AddImGuiFonts(false);
}
g_host_display->UpdateImGuiFontTexture();
g_gpu_device->UpdateImGuiFontTexture();
NewFrame();
return HasFullscreenFonts();

View File

@ -314,7 +314,7 @@ void ImGuiManager::DrawPerformanceOverlay()
#endif
}
if (g_settings.display_show_gpu && g_host_display->IsGPUTimingEnabled())
if (g_settings.display_show_gpu && g_gpu_device->IsGPUTimingEnabled())
{
text.Assign("GPU: ");
FormatProcessorStat(text, System::GetGPUUsage(), System::GetGPUAverageTime());
@ -720,17 +720,17 @@ void SaveStateSelectorUI::InitializeListEntry(ListEntry* li, ExtendedSaveStateIn
li->preview_texture.reset();
// Might not have a display yet, we're called at startup..
if (g_host_display)
if (g_gpu_device)
{
if (ssi && !ssi->screenshot_data.empty())
{
li->preview_texture = g_host_display->CreateTexture(
li->preview_texture = g_gpu_device->CreateTexture(
ssi->screenshot_width, ssi->screenshot_height, 1, 1, 1, GPUTexture::Type::Texture, GPUTexture::Format::RGBA8,
ssi->screenshot_data.data(), sizeof(u32) * ssi->screenshot_width, false);
}
else
{
li->preview_texture = g_host_display->CreateTexture(
li->preview_texture = g_gpu_device->CreateTexture(
PLACEHOLDER_ICON_WIDTH, PLACEHOLDER_ICON_HEIGHT, 1, 1, 1, GPUTexture::Type::Texture, GPUTexture::Format::RGBA8,
PLACEHOLDER_ICON_DATA, sizeof(u32) * PLACEHOLDER_ICON_WIDTH, false);
}
@ -749,9 +749,9 @@ void SaveStateSelectorUI::InitializePlaceholderListEntry(ListEntry* li, std::str
li->slot = slot;
li->global = global;
if (g_host_display)
if (g_gpu_device)
{
li->preview_texture = g_host_display->CreateTexture(
li->preview_texture = g_gpu_device->CreateTexture(
PLACEHOLDER_ICON_WIDTH, PLACEHOLDER_ICON_HEIGHT, 1, 1, 1, GPUTexture::Type::Texture, GPUTexture::Format::RGBA8,
PLACEHOLDER_ICON_DATA, sizeof(u32) * PLACEHOLDER_ICON_WIDTH, false);
if (!li->preview_texture)