From 02d379116ec0d93c1495d025506c661b85211b9f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 27 Jul 2023 23:39:04 +1000 Subject: [PATCH] HostDisplay: Rename to GPUDevice --- src/common/common.vcxproj | 125 -------- src/common/common.vcxproj.filters | 181 ----------- src/common/gl/context_egl_android.cpp | 48 --- src/common/gl/context_egl_android.h | 24 -- src/common/gl/context_egl_fbdev.cpp | 35 -- src/common/gl/context_egl_fbdev.h | 24 -- src/common/gl/context_egl_gbm.cpp | 289 ----------------- src/common/gl/context_egl_gbm.h | 81 ----- src/core/core.vcxproj | 121 ++++++- src/core/core.vcxproj.filters | 300 +++++++++++++++++- src/core/gpu.cpp | 2 +- src/core/gpu.h | 2 +- .../gpu}/d3d11/shader_cache.cpp | 6 +- src/{common => core/gpu}/d3d11/shader_cache.h | 6 +- .../gpu}/d3d11/shader_compiler.cpp | 6 +- .../gpu}/d3d11/shader_compiler.h | 4 +- .../gpu}/d3d11/stream_buffer.cpp | 6 +- .../gpu}/d3d11/stream_buffer.h | 8 +- src/{common => core/gpu}/d3d11/texture.cpp | 2 +- src/{common => core/gpu}/d3d11/texture.h | 2 +- .../gpu/d3d11_gpu_device.cpp} | 147 +++++---- .../gpu/d3d11_gpu_device.h} | 14 +- src/{common => core/gpu}/d3d12/context.cpp | 8 +- src/{common => core/gpu}/d3d12/context.h | 6 +- .../gpu}/d3d12/descriptor_heap_manager.cpp | 4 +- .../gpu}/d3d12/descriptor_heap_manager.h | 4 +- .../gpu}/d3d12/shader_cache.cpp | 6 +- src/{common => core/gpu}/d3d12/shader_cache.h | 6 +- .../gpu}/d3d12/staging_texture.cpp | 6 +- .../gpu}/d3d12/staging_texture.h | 5 +- .../gpu}/d3d12/stream_buffer.cpp | 8 +- .../gpu}/d3d12/stream_buffer.h | 6 +- src/{common => core/gpu}/d3d12/texture.cpp | 6 +- src/{common => core/gpu}/d3d12/texture.h | 2 +- src/{common => core/gpu}/d3d12/util.cpp | 8 +- src/{common => core/gpu}/d3d12/util.h | 4 +- .../gpu/d3d12_gpu_device.cpp} | 146 ++++----- .../gpu/d3d12_gpu_device.h} | 16 +- .../gpu}/display_ps.hlsl | 0 .../gpu}/display_ps.hlsl.h | 0 .../gpu}/display_ps_alpha.hlsl.h | 0 .../gpu}/display_vs.hlsl | 0 .../gpu}/display_vs.hlsl.h | 0 src/{common => core/gpu}/gl/context.cpp | 38 +-- src/{common => core/gpu}/gl/context.h | 4 +- src/{common => core/gpu}/gl/context_agl.h | 0 src/{common => core/gpu}/gl/context_agl.mm | 0 src/{common => core/gpu}/gl/context_egl.cpp | 0 src/{common => core/gpu}/gl/context_egl.h | 0 .../gpu}/gl/context_egl_wayland.cpp | 0 .../gpu}/gl/context_egl_wayland.h | 0 .../gpu}/gl/context_egl_x11.cpp | 0 src/{common => core/gpu}/gl/context_egl_x11.h | 0 src/{common => core/gpu}/gl/context_glx.cpp | 0 src/{common => core/gpu}/gl/context_glx.h | 0 src/{common => core/gpu}/gl/context_wgl.cpp | 8 +- src/{common => core/gpu}/gl/context_wgl.h | 5 +- src/{common => core/gpu}/gl/loader.h | 2 +- src/{common => core/gpu}/gl/program.cpp | 6 +- src/{common => core/gpu}/gl/program.h | 2 +- src/{common => core/gpu}/gl/shader_cache.cpp | 10 +- src/{common => core/gpu}/gl/shader_cache.h | 4 +- src/{common => core/gpu}/gl/stream_buffer.cpp | 4 +- src/{common => core/gpu}/gl/stream_buffer.h | 4 +- src/{common => core/gpu}/gl/texture.cpp | 4 +- src/{common => core/gpu}/gl/texture.h | 0 src/{common => core/gpu}/gl/x11_window.cpp | 0 src/{common => core/gpu}/gl/x11_window.h | 2 +- .../{host_display.cpp => gpu/gpu_device.cpp} | 84 +++-- src/core/{host_display.h => gpu/gpu_device.h} | 12 +- src/{common => core/gpu}/gpu_texture.cpp | 6 +- src/{common => core/gpu}/gpu_texture.h | 2 +- .../gpu}/imgui_impl_dx11.cpp | 2 +- .../gpu}/imgui_impl_dx11.h | 0 .../gpu}/imgui_impl_dx12.cpp | 6 +- .../gpu}/imgui_impl_dx12.h | 0 .../gpu}/imgui_impl_opengl3.cpp | 4 +- .../gpu}/imgui_impl_opengl3.h | 0 .../gpu}/imgui_impl_vulkan.cpp | 10 +- .../gpu}/imgui_impl_vulkan.h | 2 +- .../gpu/opengl_gpu_device.cpp} | 129 ++++---- .../gpu/opengl_gpu_device.h} | 18 +- .../gpu}/postprocessing_chain.cpp | 0 .../gpu}/postprocessing_chain.h | 0 .../gpu}/postprocessing_shader.cpp | 0 .../gpu}/postprocessing_shader.h | 0 .../gpu}/postprocessing_shadergen.cpp | 0 .../gpu}/postprocessing_shadergen.h | 0 src/{common => core/gpu}/vulkan/builders.cpp | 2 +- src/{common => core/gpu}/vulkan/builders.h | 2 +- src/{common => core/gpu}/vulkan/context.cpp | 8 +- src/{common => core/gpu}/vulkan/context.h | 2 +- .../gpu}/vulkan/entry_points.h | 0 .../gpu}/vulkan/entry_points.inl | 0 src/{common => core/gpu}/vulkan/loader.cpp | 0 src/{common => core/gpu}/vulkan/loader.h | 2 +- .../gpu}/vulkan/shader_cache.cpp | 8 +- .../gpu}/vulkan/shader_cache.h | 4 +- .../gpu}/vulkan/shader_compiler.cpp | 8 +- .../gpu}/vulkan/shader_compiler.h | 2 +- .../gpu}/vulkan/stream_buffer.cpp | 6 +- .../gpu}/vulkan/stream_buffer.h | 2 +- .../gpu}/vulkan/swap_chain.cpp | 4 +- src/{common => core/gpu}/vulkan/swap_chain.h | 4 +- src/{common => core/gpu}/vulkan/texture.cpp | 8 +- src/{common => core/gpu}/vulkan/texture.h | 0 src/{common => core/gpu}/vulkan/util.cpp | 6 +- src/{common => core/gpu}/vulkan/util.h | 4 +- .../gpu/vulkan_gpu_device.cpp} | 141 ++++---- .../gpu/vulkan_gpu_device.h} | 14 +- src/core/gpu_hw.h | 2 +- src/core/gpu_hw_d3d11.cpp | 4 +- src/core/gpu_hw_d3d11.h | 8 +- src/core/gpu_hw_d3d12.cpp | 12 +- src/core/gpu_hw_d3d12.h | 6 +- src/core/gpu_hw_opengl.cpp | 2 +- src/core/gpu_hw_opengl.h | 10 +- src/core/gpu_hw_vulkan.cpp | 10 +- src/core/gpu_hw_vulkan.h | 4 +- src/core/gpu_sw.cpp | 4 +- src/core/gpu_sw.h | 5 +- src/core/gpu_sw_backend.cpp | 2 +- src/core/gte.cpp | 4 +- src/core/guncon.cpp | 2 +- src/core/playstation_mouse.cpp | 2 +- src/core/settings.cpp | 4 +- src/core/shadergen.cpp | 2 +- src/core/shadergen.h | 2 +- src/core/system.cpp | 9 +- src/duckstation-nogui/nogui_host.cpp | 2 +- src/duckstation-nogui/nogui_platform.h | 2 +- src/duckstation-nogui/vty_nogui_platform.cpp | 2 +- src/duckstation-qt/displaysettingswidget.cpp | 14 +- src/duckstation-qt/mainwindow.cpp | 4 +- src/duckstation-qt/mainwindow.h | 2 +- .../postprocessingchainconfigwidget.cpp | 2 +- .../postprocessingchainconfigwidget.h | 4 +- .../postprocessingshaderconfigwidget.h | 2 +- src/duckstation-qt/qthost.h | 4 +- src/duckstation-regtest/regtest_host.cpp | 2 +- .../regtest_host_display.cpp | 2 +- .../regtest_host_display.h | 4 +- src/frontend-common/achievements.cpp | 2 +- src/frontend-common/common_host.cpp | 31 +- src/frontend-common/frontend-common.vcxproj | 38 --- .../frontend-common.vcxproj.filters | 22 -- src/frontend-common/fullscreen_ui.cpp | 17 +- src/frontend-common/imgui_fullscreen.cpp | 2 +- src/frontend-common/imgui_manager.cpp | 10 +- src/frontend-common/imgui_overlays.cpp | 2 +- 150 files changed, 1023 insertions(+), 1510 deletions(-) delete mode 100644 src/common/gl/context_egl_android.cpp delete mode 100644 src/common/gl/context_egl_android.h delete mode 100644 src/common/gl/context_egl_fbdev.cpp delete mode 100644 src/common/gl/context_egl_fbdev.h delete mode 100644 src/common/gl/context_egl_gbm.cpp delete mode 100644 src/common/gl/context_egl_gbm.h rename src/{common => core/gpu}/d3d11/shader_cache.cpp (99%) rename src/{common => core/gpu}/d3d11/shader_cache.h (96%) rename src/{common => core/gpu}/d3d11/shader_compiler.cpp (97%) rename src/{common => core/gpu}/d3d11/shader_compiler.h (94%) rename src/{common => core/gpu}/d3d11/stream_buffer.cpp (97%) rename src/{common => core/gpu}/d3d11/stream_buffer.h (93%) rename src/{common => core/gpu}/d3d11/texture.cpp (99%) rename src/{common => core/gpu}/d3d11/texture.h (97%) rename src/{frontend-common/d3d11_host_display.cpp => core/gpu/d3d11_gpu_device.cpp} (88%) rename src/{frontend-common/d3d11_host_display.h => core/gpu/d3d11_gpu_device.h} (95%) rename src/{common => core/gpu}/d3d12/context.cpp (99%) rename src/{common => core/gpu}/d3d12/context.h (97%) rename src/{common => core/gpu}/d3d12/descriptor_heap_manager.cpp (98%) rename src/{common => core/gpu}/d3d12/descriptor_heap_manager.h (97%) rename src/{common => core/gpu}/d3d12/shader_cache.cpp (99%) rename src/{common => core/gpu}/d3d12/shader_cache.h (97%) rename src/{common => core/gpu}/d3d12/staging_texture.cpp (98%) rename src/{common => core/gpu}/d3d12/staging_texture.h (95%) rename src/{common => core/gpu}/d3d12/stream_buffer.cpp (98%) rename src/{common => core/gpu}/d3d12/stream_buffer.h (93%) rename src/{common => core/gpu}/d3d12/texture.cpp (99%) rename src/{common => core/gpu}/d3d12/texture.h (98%) rename src/{common => core/gpu}/d3d12/util.cpp (98%) rename src/{common => core/gpu}/d3d12/util.h (98%) rename src/{frontend-common/d3d12_host_display.cpp => core/gpu/d3d12_gpu_device.cpp} (87%) rename src/{frontend-common/d3d12_host_display.h => core/gpu/d3d12_gpu_device.h} (94%) rename src/{frontend-common => core/gpu}/display_ps.hlsl (100%) rename src/{frontend-common => core/gpu}/display_ps.hlsl.h (100%) rename src/{frontend-common => core/gpu}/display_ps_alpha.hlsl.h (100%) rename src/{frontend-common => core/gpu}/display_vs.hlsl (100%) rename src/{frontend-common => core/gpu}/display_vs.hlsl.h (100%) rename src/{common => core/gpu}/gl/context.cpp (92%) rename src/{common => core/gpu}/gl/context.h (97%) rename src/{common => core/gpu}/gl/context_agl.h (100%) rename src/{common => core/gpu}/gl/context_agl.mm (100%) rename src/{common => core/gpu}/gl/context_egl.cpp (100%) rename src/{common => core/gpu}/gl/context_egl.h (100%) rename src/{common => core/gpu}/gl/context_egl_wayland.cpp (100%) rename src/{common => core/gpu}/gl/context_egl_wayland.h (100%) rename src/{common => core/gpu}/gl/context_egl_x11.cpp (100%) rename src/{common => core/gpu}/gl/context_egl_x11.h (100%) rename src/{common => core/gpu}/gl/context_glx.cpp (100%) rename src/{common => core/gpu}/gl/context_glx.h (100%) rename src/{common => core/gpu}/gl/context_wgl.cpp (98%) rename src/{common => core/gpu}/gl/context_wgl.h (93%) rename src/{common => core/gpu}/gl/loader.h (79%) rename src/{common => core/gpu}/gl/program.cpp (99%) rename src/{common => core/gpu}/gl/program.h (98%) rename src/{common => core/gpu}/gl/shader_cache.cpp (98%) rename src/{common => core/gpu}/gl/shader_cache.h (97%) rename src/{common => core/gpu}/gl/stream_buffer.cpp (99%) rename src/{common => core/gpu}/gl/stream_buffer.h (89%) rename src/{common => core/gpu}/gl/texture.cpp (99%) rename src/{common => core/gpu}/gl/texture.h (100%) rename src/{common => core/gpu}/gl/x11_window.cpp (100%) rename src/{common => core/gpu}/gl/x11_window.h (97%) rename src/core/{host_display.cpp => gpu/gpu_device.cpp} (87%) rename src/core/{host_display.h => gpu/gpu_device.h} (98%) rename src/{common => core/gpu}/gpu_texture.cpp (97%) rename src/{common => core/gpu}/gpu_texture.h (98%) rename src/{frontend-common => core/gpu}/imgui_impl_dx11.cpp (99%) rename src/{frontend-common => core/gpu}/imgui_impl_dx11.h (100%) rename src/{frontend-common => core/gpu}/imgui_impl_dx12.cpp (99%) rename src/{frontend-common => core/gpu}/imgui_impl_dx12.h (100%) rename src/{frontend-common => core/gpu}/imgui_impl_opengl3.cpp (99%) rename src/{frontend-common => core/gpu}/imgui_impl_opengl3.h (100%) rename src/{frontend-common => core/gpu}/imgui_impl_vulkan.cpp (99%) rename src/{frontend-common => core/gpu}/imgui_impl_vulkan.h (92%) rename src/{frontend-common/opengl_host_display.cpp => core/gpu/opengl_gpu_device.cpp} (88%) rename src/{frontend-common/opengl_host_display.h => core/gpu/opengl_gpu_device.h} (94%) rename src/{frontend-common => core/gpu}/postprocessing_chain.cpp (100%) rename src/{frontend-common => core/gpu}/postprocessing_chain.h (100%) rename src/{frontend-common => core/gpu}/postprocessing_shader.cpp (100%) rename src/{frontend-common => core/gpu}/postprocessing_shader.h (100%) rename src/{frontend-common => core/gpu}/postprocessing_shadergen.cpp (100%) rename src/{frontend-common => core/gpu}/postprocessing_shadergen.h (100%) rename src/{common => core/gpu}/vulkan/builders.cpp (99%) rename src/{common => core/gpu}/vulkan/builders.h (99%) rename src/{common => core/gpu}/vulkan/context.cpp (99%) rename src/{common => core/gpu}/vulkan/context.h (99%) rename src/{common => core/gpu}/vulkan/entry_points.h (100%) rename src/{common => core/gpu}/vulkan/entry_points.inl (100%) rename src/{common => core/gpu}/vulkan/loader.cpp (100%) rename src/{common => core/gpu}/vulkan/loader.h (98%) rename src/{common => core/gpu}/vulkan/shader_cache.cpp (99%) rename src/{common => core/gpu}/vulkan/shader_cache.h (98%) rename src/{common => core/gpu}/vulkan/shader_compiler.cpp (97%) rename src/{common => core/gpu}/vulkan/shader_compiler.h (97%) rename src/{common => core/gpu}/vulkan/stream_buffer.cpp (99%) rename src/{common => core/gpu}/vulkan/stream_buffer.h (98%) rename src/{common => core/gpu}/vulkan/swap_chain.cpp (99%) rename src/{common => core/gpu}/vulkan/swap_chain.h (98%) rename src/{common => core/gpu}/vulkan/texture.cpp (99%) rename src/{common => core/gpu}/vulkan/texture.h (100%) rename src/{common => core/gpu}/vulkan/util.cpp (99%) rename src/{common => core/gpu}/vulkan/util.h (99%) rename src/{frontend-common/vulkan_host_display.cpp => core/gpu/vulkan_gpu_device.cpp} (90%) rename src/{frontend-common/vulkan_host_display.h => core/gpu/vulkan_gpu_device.h} (95%) diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 5f7250afa..7b11526f2 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -9,44 +9,11 @@ - - - - - - - - - - - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - @@ -73,36 +40,6 @@ - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - @@ -111,38 +48,8 @@ - - - - - - - - - - - - - true - - - true - - - true - - - true - - - true - - - true - - @@ -158,44 +65,12 @@ - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - - true - - {EE054E08-3799-4A59-A422-18259C105FFD} diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters index a89b94d0a..68d64d9be 100644 --- a/src/common/common.vcxproj.filters +++ b/src/common/common.vcxproj.filters @@ -5,24 +5,6 @@ - - gl - - - gl - - - gl - - - d3d11 - - - d3d11 - - - d3d11 - @@ -33,47 +15,11 @@ - - d3d11 - - - gl - - - gl - - - gl - - - vulkan - - - vulkan - - - vulkan - - - vulkan - - - vulkan - - - vulkan - - - vulkan - - - vulkan - @@ -86,40 +32,10 @@ - - d3d12 - - - d3d12 - - - d3d12 - - - d3d12 - - - d3d12 - - - d3d12 - - - d3d12 - - - vulkan - - - vulkan - - - gl - @@ -128,27 +44,8 @@ - - - gl - - - gl - - - gl - - - d3d11 - - - d3d11 - - - d3d11 - @@ -157,43 +54,7 @@ - - d3d11 - - - gl - - - gl - - - gl - - - vulkan - - - vulkan - - - vulkan - - - vulkan - - - vulkan - - - vulkan - - - vulkan - - - vulkan - @@ -203,61 +64,19 @@ - - d3d12 - - - d3d12 - - - d3d12 - - - d3d12 - - - d3d12 - - - d3d12 - - - d3d12 - - - vulkan - - - - {52487c57-753d-4888-ba26-ed63ab51a234} - - - {30251086-81f3-44f5-add4-7ff9a24098ab} - - - {642ff5eb-af39-4aab-a42f-6eb8188a11d7} - {fd4150b0-6f82-4251-ab23-34c25fbc5b5e} - - {358e11c4-34af-4169-9a66-ec66342a6a2f} - - - - - vulkan - \ No newline at end of file diff --git a/src/common/gl/context_egl_android.cpp b/src/common/gl/context_egl_android.cpp deleted file mode 100644 index 6ca861f52..000000000 --- a/src/common/gl/context_egl_android.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin -// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) - -#include "context_egl_android.h" -#include "../log.h" -#include -Log_SetChannel(GL::ContextEGLAndroid); - -namespace GL { -ContextEGLAndroid::ContextEGLAndroid(const WindowInfo& wi) : ContextEGL(wi) {} -ContextEGLAndroid::~ContextEGLAndroid() = default; - -std::unique_ptr ContextEGLAndroid::Create(const WindowInfo& wi, const Version* versions_to_try, - size_t num_versions_to_try) -{ - std::unique_ptr context = std::make_unique(wi); - if (!context->Initialize(versions_to_try, num_versions_to_try)) - return nullptr; - - return context; -} - -std::unique_ptr ContextEGLAndroid::CreateSharedContext(const WindowInfo& wi) -{ - std::unique_ptr context = std::make_unique(wi); - context->m_display = m_display; - - if (!context->CreateContextAndSurface(m_version, m_context, false)) - return nullptr; - - return context; -} - -EGLNativeWindowType ContextEGLAndroid::GetNativeWindow(EGLConfig config) -{ - EGLint native_visual_id = 0; - if (!eglGetConfigAttrib(m_display, m_config, EGL_NATIVE_VISUAL_ID, &native_visual_id)) - { - Log_ErrorPrintf("Failed to get native visual ID"); - return 0; - } - - ANativeWindow_setBuffersGeometry(static_cast(m_wi.window_handle), 0, 0, static_cast(native_visual_id)); - m_wi.surface_width = ANativeWindow_getWidth(static_cast(m_wi.window_handle)); - m_wi.surface_height = ANativeWindow_getHeight(static_cast(m_wi.window_handle)); - return static_cast(m_wi.window_handle); -} -} // namespace GL diff --git a/src/common/gl/context_egl_android.h b/src/common/gl/context_egl_android.h deleted file mode 100644 index c8241e8ea..000000000 --- a/src/common/gl/context_egl_android.h +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin -// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) - -#pragma once -#include "context_egl.h" - -namespace GL { - -class ContextEGLAndroid final : public ContextEGL -{ -public: - ContextEGLAndroid(const WindowInfo& wi); - ~ContextEGLAndroid() override; - - static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try, - size_t num_versions_to_try); - - std::unique_ptr CreateSharedContext(const WindowInfo& wi) override; - -protected: - EGLNativeWindowType GetNativeWindow(EGLConfig config) override; -}; - -} // namespace GL diff --git a/src/common/gl/context_egl_fbdev.cpp b/src/common/gl/context_egl_fbdev.cpp deleted file mode 100644 index b69fc58bc..000000000 --- a/src/common/gl/context_egl_fbdev.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin -// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) - -#include "context_egl_fbdev.h" - -namespace GL { -ContextEGLFBDev::ContextEGLFBDev(const WindowInfo& wi) : ContextEGL(wi) {} -ContextEGLFBDev::~ContextEGLFBDev() = default; - -std::unique_ptr ContextEGLFBDev::Create(const WindowInfo& wi, const Version* versions_to_try, - size_t num_versions_to_try) -{ - std::unique_ptr context = std::make_unique(wi); - if (!context->Initialize(versions_to_try, num_versions_to_try)) - return nullptr; - - return context; -} - -std::unique_ptr ContextEGLFBDev::CreateSharedContext(const WindowInfo& wi) -{ - std::unique_ptr context = std::make_unique(wi); - context->m_display = m_display; - - if (!context->CreateContextAndSurface(m_version, m_context, false)) - return nullptr; - - return context; -} - -EGLNativeWindowType ContextEGLFBDev::GetNativeWindow(EGLConfig config) -{ - return static_cast(0); -} -} // namespace GL diff --git a/src/common/gl/context_egl_fbdev.h b/src/common/gl/context_egl_fbdev.h deleted file mode 100644 index 35f5b8cf4..000000000 --- a/src/common/gl/context_egl_fbdev.h +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin -// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) - -#pragma once -#include "context_egl.h" - -namespace GL { - -class ContextEGLFBDev final : public ContextEGL -{ -public: - ContextEGLFBDev(const WindowInfo& wi); - ~ContextEGLFBDev() override; - - static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try, - size_t num_versions_to_try); - - std::unique_ptr CreateSharedContext(const WindowInfo& wi) override; - -protected: - EGLNativeWindowType GetNativeWindow(EGLConfig config) override; -}; - -} // namespace GL diff --git a/src/common/gl/context_egl_gbm.cpp b/src/common/gl/context_egl_gbm.cpp deleted file mode 100644 index 2f8c7de70..000000000 --- a/src/common/gl/context_egl_gbm.cpp +++ /dev/null @@ -1,289 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin -// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) - -#include "context_egl_gbm.h" -#include "../assert.h" -#include "../log.h" -#include -#include -#include -Log_SetChannel(GL::ContextEGLGBM); - -namespace GL { -ContextEGLGBM::ContextEGLGBM(const WindowInfo& wi) : ContextEGL(wi) -{ -#ifdef CONTEXT_EGL_GBM_USE_PRESENT_THREAD - StartPresentThread(); -#endif -} - -ContextEGLGBM::~ContextEGLGBM() -{ -#ifdef CONTEXT_EGL_GBM_USE_PRESENT_THREAD - StopPresentThread(); - Assert(!m_current_present_buffer); -#endif - - m_drm_display.RestoreBuffer(); - - // We have to destroy the context before the surface/device. - // Leaving it to the base class would be too late. - DestroySurface(); - DestroyContext(); - - while (m_num_buffers > 0) - { - Buffer& buffer = m_buffers[--m_num_buffers]; - m_drm_display.RemoveBuffer(buffer.fb_id); - } - - if (m_fb_surface) - gbm_surface_destroy(m_fb_surface); - - if (m_gbm_device) - gbm_device_destroy(m_gbm_device); -} - -std::unique_ptr ContextEGLGBM::Create(const WindowInfo& wi, const Version* versions_to_try, - size_t num_versions_to_try) -{ - std::unique_ptr context = std::make_unique(wi); - if (!context->CreateDisplay() || !context->CreateGBMDevice() || - !context->Initialize(versions_to_try, num_versions_to_try)) - { - return nullptr; - } - - return context; -} - -std::unique_ptr ContextEGLGBM::CreateSharedContext(const WindowInfo& wi) -{ - std::unique_ptr context = std::make_unique(wi); - context->m_display = m_display; - - if (!context->CreateContextAndSurface(m_version, m_context, false)) - return nullptr; - - return context; -} - -void ContextEGLGBM::ResizeSurface(u32 new_surface_width, u32 new_surface_height) -{ - ContextEGL::ResizeSurface(new_surface_width, new_surface_height); -} - -bool ContextEGLGBM::CreateGBMDevice() -{ - Assert(!m_gbm_device); - m_gbm_device = gbm_create_device(m_drm_display.GetCardFD()); - if (!m_gbm_device) - { - Log_ErrorPrintf("gbm_create_device() failed: %d", errno); - return false; - } - - return true; -} - -bool ContextEGLGBM::CreateDisplay() -{ - if (!m_drm_display.Initialize(m_wi.surface_width, m_wi.surface_height, m_wi.surface_refresh_rate)) - return false; - - m_wi.surface_width = m_drm_display.GetWidth(); - m_wi.surface_height = m_drm_display.GetHeight(); - m_wi.surface_refresh_rate = m_drm_display.GetRefreshRate(); - return true; -} - -bool ContextEGLGBM::SetDisplay() -{ - if (!eglGetPlatformDisplayEXT) - { - Log_ErrorPrintf("eglGetPlatformDisplayEXT() not loaded"); - return false; - } - - m_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, m_gbm_device, nullptr); - if (!m_display) - { - Log_ErrorPrintf("eglGetPlatformDisplayEXT() failed"); - return false; - } - - return true; -} - -EGLNativeWindowType ContextEGLGBM::GetNativeWindow(EGLConfig config) -{ - EGLint visual_id; - eglGetConfigAttrib(m_display, config, EGL_NATIVE_VISUAL_ID, &visual_id); - - Assert(!m_fb_surface); - m_fb_surface = gbm_surface_create(m_gbm_device, m_drm_display.GetWidth(), m_drm_display.GetHeight(), - static_cast(visual_id), GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT); - if (!m_fb_surface) - { - Log_ErrorPrintf("gbm_surface_create() failed: %d", errno); - return {}; - } - - return (EGLNativeWindowType)((void*)m_fb_surface); -} - -ContextEGLGBM::Buffer* ContextEGLGBM::LockFrontBuffer() -{ - struct gbm_bo* bo = gbm_surface_lock_front_buffer(m_fb_surface); - - Buffer* buffer = nullptr; - for (u32 i = 0; i < m_num_buffers; i++) - { - if (m_buffers[i].bo == bo) - { - buffer = &m_buffers[i]; - break; - } - } - - if (!buffer) - { - // haven't tracked this buffer yet - Assert(m_num_buffers < MAX_BUFFERS); - - const u32 width = gbm_bo_get_width(bo); - const u32 height = gbm_bo_get_height(bo); - const u32 stride = gbm_bo_get_stride(bo); - const u32 format = gbm_bo_get_format(bo); - const u32 handle = gbm_bo_get_handle(bo).u32; - - std::optional fb_id = m_drm_display.AddBuffer(width, height, format, handle, stride, 0); - if (!fb_id.has_value()) - return nullptr; - - buffer = &m_buffers[m_num_buffers]; - buffer->bo = bo; - buffer->fb_id = fb_id.value(); - m_num_buffers++; - } - - return buffer; -} - -void ContextEGLGBM::ReleaseBuffer(Buffer* buffer) -{ - gbm_surface_release_buffer(m_fb_surface, buffer->bo); -} - -void ContextEGLGBM::PresentBuffer(Buffer* buffer, bool wait_for_vsync) -{ - m_drm_display.PresentBuffer(buffer->fb_id, wait_for_vsync); -} - -bool ContextEGLGBM::SwapBuffers() -{ - if (!ContextEGL::SwapBuffers()) - return false; - -#ifdef CONTEXT_EGL_GBM_USE_PRESENT_THREAD - std::unique_lock lock(m_present_mutex); - m_present_pending.store(true); - m_present_cv.notify_one(); - if (m_vsync) - m_present_done_cv.wait(lock, [this]() { return !m_present_pending.load(); }); -#else - Buffer* front_buffer = LockFrontBuffer(); - if (!front_buffer) - return false; - - PresentSurface(front_buffer, m_vsync && m_last_front_buffer); - - if (m_last_front_buffer) - ReleaseBuffer(m_last_front_buffer); - - m_last_front_buffer = front_buffer; -#endif - - return true; -} - -bool ContextEGLGBM::SetSwapInterval(s32 interval) -{ - if (interval < 0 || interval > 1) - return false; - - std::unique_lock lock(m_present_mutex); - m_vsync = (interval > 0); - return true; -} - -std::vector ContextEGLGBM::EnumerateFullscreenModes() -{ - std::vector modes; - modes.reserve(m_drm_display.GetModeCount()); - for (u32 i = 0; i < m_drm_display.GetModeCount(); i++) - { - modes.push_back(FullscreenModeInfo{m_drm_display.GetModeWidth(i), m_drm_display.GetModeHeight(i), - m_drm_display.GetModeRefreshRate(i)}); - } - return modes; -} - -#ifdef CONTEXT_EGL_GBM_USE_PRESENT_THREAD - -void ContextEGLGBM::StartPresentThread() -{ - m_present_thread_shutdown.store(false); - m_present_thread = std::thread(&ContextEGLGBM::PresentThread, this); -} - -void ContextEGLGBM::StopPresentThread() -{ - if (!m_present_thread.joinable()) - return; - - { - std::unique_lock lock(m_present_mutex); - m_present_thread_shutdown.store(true); - m_present_cv.notify_one(); - } - - m_present_thread.join(); -} - -void ContextEGLGBM::PresentThread() -{ - std::unique_lock lock(m_present_mutex); - - while (!m_present_thread_shutdown.load()) - { - m_present_cv.wait(lock); - - if (!m_present_pending.load()) - continue; - - Buffer* next_buffer = LockFrontBuffer(); - const bool wait_for_vsync = m_vsync && m_current_present_buffer; - - lock.unlock(); - PresentBuffer(next_buffer, wait_for_vsync); - lock.lock(); - - if (m_current_present_buffer) - ReleaseBuffer(m_current_present_buffer); - - m_current_present_buffer = next_buffer; - m_present_pending.store(false); - m_present_done_cv.notify_one(); - } - - if (m_current_present_buffer) - { - ReleaseBuffer(m_current_present_buffer); - m_current_present_buffer = nullptr; - } -} - -#endif - -} // namespace GL diff --git a/src/common/gl/context_egl_gbm.h b/src/common/gl/context_egl_gbm.h deleted file mode 100644 index 0bc0d8aef..000000000 --- a/src/common/gl/context_egl_gbm.h +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin -// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) - -#pragma once -#include "../drm_display.h" -#include "context_egl.h" -#include -#include -#include -#include -#include - -#define CONTEXT_EGL_GBM_USE_PRESENT_THREAD 1 - -namespace GL { - -class ContextEGLGBM final : public ContextEGL -{ -public: - ContextEGLGBM(const WindowInfo& wi); - ~ContextEGLGBM() override; - - static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try, - size_t num_versions_to_try); - - std::unique_ptr CreateSharedContext(const WindowInfo& wi) override; - void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override; - - bool SwapBuffers() override; - bool SetSwapInterval(s32 interval) override; - - std::vector EnumerateFullscreenModes() override; - -protected: - bool SetDisplay() override; - EGLNativeWindowType GetNativeWindow(EGLConfig config) override; - -private: - enum : u32 - { - MAX_BUFFERS = 5 - }; - - struct Buffer - { - struct gbm_bo* bo; - u32 fb_id; - }; - - bool CreateDisplay(); - - bool CreateGBMDevice(); - Buffer* LockFrontBuffer(); - void ReleaseBuffer(Buffer* buffer); - void PresentBuffer(Buffer* buffer, bool wait_for_vsync); - - void StartPresentThread(); - void StopPresentThread(); - void PresentThread(); - - DRMDisplay m_drm_display; - struct gbm_device* m_gbm_device = nullptr; - struct gbm_surface* m_fb_surface = nullptr; - bool m_vsync = true; - -#ifdef CONTEXT_EGL_GBM_USE_PRESENT_THREAD - std::thread m_present_thread; - std::mutex m_present_mutex; - std::condition_variable m_present_cv; - std::atomic_bool m_present_pending{false}; - std::atomic_bool m_present_thread_shutdown{false}; - std::condition_variable m_present_done_cv; - - Buffer* m_current_present_buffer = nullptr; -#endif - - u32 m_num_buffers = 0; - std::array m_buffers{}; -}; - -} // namespace GL diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index a07ce3903..f5fdc3e4f 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj @@ -33,6 +33,60 @@ + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + @@ -52,7 +106,6 @@ true - @@ -105,6 +158,65 @@ + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + true + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + @@ -126,7 +238,6 @@ - @@ -157,6 +268,12 @@ + + + true + + + {868B98C8-65A1-494B-8346-250A73A48C0A} diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index 871da6173..d4666b47e 100644 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters @@ -35,7 +35,6 @@ - @@ -60,6 +59,138 @@ + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu\d3d11 + + + gpu\d3d11 + + + gpu\d3d11 + + + gpu\d3d11 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + @@ -86,7 +217,6 @@ - @@ -127,5 +257,171 @@ + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu\d3d11 + + + gpu\d3d11 + + + gpu\d3d11 + + + gpu\d3d11 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\d3d12 + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\gl + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu\vulkan + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + + + gpu + + + + + {7b18fac1-ee2b-4816-8537-eb8f32d40ada} + + + {f5b7a4af-72c7-406f-b787-9036115c3580} + + + {17c2f89b-5cf4-4d3a-9343-a03c1c668b85} + + + {e2aeacc6-65aa-4110-bef9-5f3e1fc0470e} + + + {e4809e3b-2adc-440a-82df-044a408409b3} + + + + + gpu\gl + + + gpu\vulkan + \ No newline at end of file diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index d099a2be4..2e4ef286b 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -7,8 +7,8 @@ #include "common/log.h" #include "common/string_util.h" #include "dma.h" +#include "gpu/gpu_device.h" #include "host.h" -#include "host_display.h" #include "imgui.h" #include "interrupt_controller.h" #include "settings.h" diff --git a/src/core/gpu.h b/src/core/gpu.h index 75ac564ec..89d4a9bdb 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -17,7 +17,7 @@ class StateWrapper; -class HostDisplay; +class GPUDevice; class GPUTexture; class TimingEvent; diff --git a/src/common/d3d11/shader_cache.cpp b/src/core/gpu/d3d11/shader_cache.cpp similarity index 99% rename from src/common/d3d11/shader_cache.cpp rename to src/core/gpu/d3d11/shader_cache.cpp index b1c9b5c0e..6bd1112fd 100644 --- a/src/common/d3d11/shader_cache.cpp +++ b/src/core/gpu/d3d11/shader_cache.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "shader_cache.h" -#include "../file_system.h" -#include "../log.h" -#include "../md5_digest.h" +#include "common/file_system.h" +#include "common/log.h" +#include "common/md5_digest.h" #include "shader_compiler.h" #include Log_SetChannel(D3D11::ShaderCache); diff --git a/src/common/d3d11/shader_cache.h b/src/core/gpu/d3d11/shader_cache.h similarity index 96% rename from src/common/d3d11/shader_cache.h rename to src/core/gpu/d3d11/shader_cache.h index a608cda7a..325211b1f 100644 --- a/src/common/d3d11/shader_cache.h +++ b/src/core/gpu/d3d11/shader_cache.h @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../hash_combine.h" -#include "../types.h" -#include "../windows_headers.h" +#include "common/hash_combine.h" +#include "common/types.h" +#include "common/windows_headers.h" #include "shader_compiler.h" #include #include diff --git a/src/common/d3d11/shader_compiler.cpp b/src/core/gpu/d3d11/shader_compiler.cpp similarity index 97% rename from src/common/d3d11/shader_compiler.cpp rename to src/core/gpu/d3d11/shader_compiler.cpp index 197361064..fd9f3e4f3 100644 --- a/src/common/d3d11/shader_compiler.cpp +++ b/src/core/gpu/d3d11/shader_compiler.cpp @@ -1,9 +1,9 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "shader_compiler.h" -#include "../log.h" -#include "../string_util.h" +#include "common/log.h" +#include "common/string_util.h" #include #include #include diff --git a/src/common/d3d11/shader_compiler.h b/src/core/gpu/d3d11/shader_compiler.h similarity index 94% rename from src/common/d3d11/shader_compiler.h rename to src/core/gpu/d3d11/shader_compiler.h index 176c45158..98935b810 100644 --- a/src/common/d3d11/shader_compiler.h +++ b/src/core/gpu/d3d11/shader_compiler.h @@ -1,8 +1,8 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../windows_headers.h" +#include "common/windows_headers.h" #include #include #include diff --git a/src/common/d3d11/stream_buffer.cpp b/src/core/gpu/d3d11/stream_buffer.cpp similarity index 97% rename from src/common/d3d11/stream_buffer.cpp rename to src/core/gpu/d3d11/stream_buffer.cpp index ad39eb95f..762cde57b 100644 --- a/src/common/d3d11/stream_buffer.cpp +++ b/src/core/gpu/d3d11/stream_buffer.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "stream_buffer.h" -#include "../align.h" -#include "../assert.h" -#include "../log.h" +#include "common/align.h" +#include "common/assert.h" +#include "common/log.h" Log_SetChannel(D3D11); namespace D3D11 { diff --git a/src/common/d3d11/stream_buffer.h b/src/core/gpu/d3d11/stream_buffer.h similarity index 93% rename from src/common/d3d11/stream_buffer.h rename to src/core/gpu/d3d11/stream_buffer.h index aac81b93b..b13862d49 100644 --- a/src/common/d3d11/stream_buffer.h +++ b/src/core/gpu/d3d11/stream_buffer.h @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../types.h" -#include "../windows_headers.h" +#include "common/types.h" +#include "common/windows_headers.h" #include #include @@ -26,7 +26,7 @@ public: bool Create(ID3D11Device* device, D3D11_BIND_FLAG bind_flags, u32 size); void Adopt(ComPtr buffer); void Release(); - + struct MappingResult { void* pointer; @@ -44,4 +44,4 @@ private: u32 m_position; bool m_use_map_no_overwrite = false; }; -} // namespace GL \ No newline at end of file +} // namespace D3D11 \ No newline at end of file diff --git a/src/common/d3d11/texture.cpp b/src/core/gpu/d3d11/texture.cpp similarity index 99% rename from src/common/d3d11/texture.cpp rename to src/core/gpu/d3d11/texture.cpp index df2d3f599..39213adb1 100644 --- a/src/common/d3d11/texture.cpp +++ b/src/core/gpu/d3d11/texture.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "texture.h" -#include "../log.h" +#include "common/log.h" #include Log_SetChannel(D3D11); diff --git a/src/common/d3d11/texture.h b/src/core/gpu/d3d11/texture.h similarity index 97% rename from src/common/d3d11/texture.h rename to src/core/gpu/d3d11/texture.h index 6060387af..21741b08a 100644 --- a/src/common/d3d11/texture.h +++ b/src/core/gpu/d3d11/texture.h @@ -3,7 +3,7 @@ #pragma once #include "../gpu_texture.h" -#include "../windows_headers.h" +#include "common/windows_headers.h" #include #include diff --git a/src/frontend-common/d3d11_host_display.cpp b/src/core/gpu/d3d11_gpu_device.cpp similarity index 88% rename from src/frontend-common/d3d11_host_display.cpp rename to src/core/gpu/d3d11_gpu_device.cpp index e28e17212..201f5796e 100644 --- a/src/frontend-common/d3d11_host_display.cpp +++ b/src/core/gpu/d3d11_gpu_device.cpp @@ -1,16 +1,15 @@ // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) -#include "d3d11_host_display.h" +#include "d3d11_gpu_device.h" +#include "../host_settings.h" +#include "../settings.h" +#include "../shader_cache_version.h" #include "common/assert.h" -#include "common/d3d11/shader_cache.h" -#include "common/d3d11/shader_compiler.h" #include "common/log.h" #include "common/string_util.h" -#include "common_host.h" -#include "core/host_settings.h" -#include "core/settings.h" -#include "core/shader_cache_version.h" +#include "d3d11/shader_cache.h" +#include "d3d11/shader_compiler.h" #include "display_ps.hlsl.h" #include "display_ps_alpha.hlsl.h" #include "display_vs.hlsl.h" @@ -19,16 +18,16 @@ #include "postprocessing_shadergen.h" #include #include -Log_SetChannel(D3D11HostDisplay); +Log_SetChannel(D3D11GPUDevice); #pragma comment(lib, "d3d11.lib") #pragma comment(lib, "dxgi.lib") static constexpr std::array s_clear_color = {}; -D3D11HostDisplay::D3D11HostDisplay() = default; +D3D11GPUDevice::D3D11GPUDevice() = default; -D3D11HostDisplay::~D3D11HostDisplay() +D3D11GPUDevice::~D3D11GPUDevice() { DestroyStagingBuffer(); DestroyResources(); @@ -37,34 +36,34 @@ D3D11HostDisplay::~D3D11HostDisplay() m_device.Reset(); } -RenderAPI D3D11HostDisplay::GetRenderAPI() const +RenderAPI D3D11GPUDevice::GetRenderAPI() const { return RenderAPI::D3D11; } -void* D3D11HostDisplay::GetDevice() const +void* D3D11GPUDevice::GetDevice() const { return m_device.Get(); } -void* D3D11HostDisplay::GetContext() const +void* D3D11GPUDevice::GetContext() const { return m_context.Get(); } -bool D3D11HostDisplay::HasDevice() const +bool D3D11GPUDevice::HasDevice() const { return static_cast(m_device); } -bool D3D11HostDisplay::HasSurface() const +bool D3D11GPUDevice::HasSurface() const { return static_cast(m_swap_chain); } -std::unique_ptr D3D11HostDisplay::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, - GPUTexture::Format format, const void* data, - u32 data_stride, bool dynamic /* = false */) +std::unique_ptr D3D11GPUDevice::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, + GPUTexture::Format format, const void* data, u32 data_stride, + bool dynamic /* = false */) { std::unique_ptr tex(std::make_unique()); if (!tex->Create(m_device.Get(), width, height, layers, levels, samples, format, D3D11_BIND_SHADER_RESOURCE, data, @@ -76,7 +75,7 @@ std::unique_ptr D3D11HostDisplay::CreateTexture(u32 width, u32 heigh return tex; } -bool D3D11HostDisplay::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, u32* out_pitch) +bool D3D11GPUDevice::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, u32* out_pitch) { D3D11::Texture* tex = static_cast(texture); if (!tex->IsDynamic() || tex->GetWidth() != width || tex->GetHeight() != height) @@ -95,26 +94,26 @@ bool D3D11HostDisplay::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 he return true; } -void D3D11HostDisplay::EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height) +void D3D11GPUDevice::EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height) { D3D11::Texture* tex = static_cast(texture); m_context->Unmap(tex->GetD3DTexture(), 0); } -bool D3D11HostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, - u32 pitch) +bool D3D11GPUDevice::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, + u32 pitch) { D3D11::Texture* tex = static_cast(texture); if (tex->IsDynamic()) - return HostDisplay::UpdateTexture(texture, x, y, width, height, data, pitch); + return GPUDevice::UpdateTexture(texture, x, y, width, height, data, pitch); const CD3D11_BOX dst_box(x, y, 0, x + width, y + height, 1); m_context->UpdateSubresource(tex->GetD3DTexture(), 0, &dst_box, data, pitch, pitch * height); return true; } -bool D3D11HostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, - u32 out_data_stride) +bool D3D11GPUDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, + u32 out_data_stride) { const D3D11::Texture* tex = static_cast(texture); if (!CheckStagingBufferSize(width, height, tex->GetDXGIFormat())) @@ -138,7 +137,7 @@ bool D3D11HostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 wi return true; } -bool D3D11HostDisplay::CheckStagingBufferSize(u32 width, u32 height, DXGI_FORMAT format) +bool D3D11GPUDevice::CheckStagingBufferSize(u32 width, u32 height, DXGI_FORMAT format) { if (m_readback_staging_texture_width >= width && m_readback_staging_texture_width >= height && m_readback_staging_texture_format == format) @@ -157,7 +156,7 @@ bool D3D11HostDisplay::CheckStagingBufferSize(u32 width, u32 height, DXGI_FORMAT return true; } -void D3D11HostDisplay::DestroyStagingBuffer() +void D3D11GPUDevice::DestroyStagingBuffer() { m_readback_staging_texture.Reset(); m_readback_staging_texture_width = 0; @@ -165,7 +164,7 @@ void D3D11HostDisplay::DestroyStagingBuffer() m_readback_staging_texture_format = DXGI_FORMAT_UNKNOWN; } -bool D3D11HostDisplay::SupportsTextureFormat(GPUTexture::Format format) const +bool D3D11GPUDevice::SupportsTextureFormat(GPUTexture::Format format) const { const DXGI_FORMAT dfmt = D3D11::Texture::GetDXGIFormat(format); if (dfmt == DXGI_FORMAT_UNKNOWN) @@ -176,7 +175,7 @@ bool D3D11HostDisplay::SupportsTextureFormat(GPUTexture::Format format) const return (SUCCEEDED(m_device->CheckFormatSupport(dfmt, &support)) && ((support & required) == required)); } -bool D3D11HostDisplay::GetHostRefreshRate(float* refresh_rate) +bool D3D11GPUDevice::GetHostRefreshRate(float* refresh_rate) { if (m_swap_chain && IsFullscreen()) { @@ -192,15 +191,15 @@ bool D3D11HostDisplay::GetHostRefreshRate(float* refresh_rate) } } - return HostDisplay::GetHostRefreshRate(refresh_rate); + return GPUDevice::GetHostRefreshRate(refresh_rate); } -void D3D11HostDisplay::SetVSync(bool enabled) +void D3D11GPUDevice::SetVSync(bool enabled) { m_vsync_enabled = enabled; } -bool D3D11HostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) +bool D3D11GPUDevice::CreateDevice(const WindowInfo& wi, bool vsync) { UINT create_flags = 0; if (g_settings.gpu_use_debug_device) @@ -320,7 +319,7 @@ bool D3D11HostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) return true; } -bool D3D11HostDisplay::SetupDevice() +bool D3D11GPUDevice::SetupDevice() { if (!CreateResources()) return false; @@ -328,17 +327,17 @@ bool D3D11HostDisplay::SetupDevice() return true; } -bool D3D11HostDisplay::MakeCurrent() +bool D3D11GPUDevice::MakeCurrent() { return true; } -bool D3D11HostDisplay::DoneCurrent() +bool D3D11GPUDevice::DoneCurrent() { return true; } -bool D3D11HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) +bool D3D11GPUDevice::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) { HRESULT hr; @@ -408,7 +407,7 @@ bool D3D11HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) return CreateSwapChainRTV(); } -bool D3D11HostDisplay::CreateSwapChainRTV() +bool D3D11GPUDevice::CreateSwapChainRTV() { ComPtr backbuffer; HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(backbuffer.GetAddressOf())); @@ -453,7 +452,7 @@ bool D3D11HostDisplay::CreateSwapChainRTV() return true; } -bool D3D11HostDisplay::ChangeWindow(const WindowInfo& new_wi) +bool D3D11GPUDevice::ChangeWindow(const WindowInfo& new_wi) { DestroySurface(); @@ -461,7 +460,7 @@ bool D3D11HostDisplay::ChangeWindow(const WindowInfo& new_wi) return CreateSwapChain(nullptr); } -void D3D11HostDisplay::DestroySurface() +void D3D11GPUDevice::DestroySurface() { m_window_info.SetSurfaceless(); if (IsFullscreen()) @@ -471,7 +470,7 @@ void D3D11HostDisplay::DestroySurface() m_swap_chain.Reset(); } -void D3D11HostDisplay::ResizeWindow(s32 new_window_width, s32 new_window_height) +void D3D11GPUDevice::ResizeWindow(s32 new_window_width, s32 new_window_height) { if (!m_swap_chain) return; @@ -487,18 +486,18 @@ void D3D11HostDisplay::ResizeWindow(s32 new_window_width, s32 new_window_height) Panic("Failed to recreate swap chain RTV after resize"); } -bool D3D11HostDisplay::SupportsFullscreen() const +bool D3D11GPUDevice::SupportsFullscreen() const { return true; } -bool D3D11HostDisplay::IsFullscreen() +bool D3D11GPUDevice::IsFullscreen() { BOOL is_fullscreen = FALSE; return (m_swap_chain && SUCCEEDED(m_swap_chain->GetFullscreenState(&is_fullscreen, nullptr)) && is_fullscreen); } -bool D3D11HostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) +bool D3D11GPUDevice::SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) { if (!m_swap_chain) return false; @@ -560,7 +559,7 @@ bool D3D11HostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, flo return true; } -bool D3D11HostDisplay::CreateResources() +bool D3D11GPUDevice::CreateResources() { HRESULT hr; @@ -631,9 +630,9 @@ bool D3D11HostDisplay::CreateResources() return true; } -void D3D11HostDisplay::DestroyResources() +void D3D11GPUDevice::DestroyResources() { - HostDisplay::DestroyResources(); + GPUDevice::DestroyResources(); m_post_processing_chain.ClearStages(); m_post_processing_input_texture.Destroy(); @@ -651,23 +650,23 @@ void D3D11HostDisplay::DestroyResources() m_display_rasterizer_state.Reset(); } -bool D3D11HostDisplay::CreateImGuiContext() +bool D3D11GPUDevice::CreateImGuiContext() { return ImGui_ImplDX11_Init(m_device.Get(), m_context.Get()); } -void D3D11HostDisplay::DestroyImGuiContext() +void D3D11GPUDevice::DestroyImGuiContext() { ImGui_ImplDX11_Shutdown(); } -bool D3D11HostDisplay::UpdateImGuiFontTexture() +bool D3D11GPUDevice::UpdateImGuiFontTexture() { ImGui_ImplDX11_CreateFontsTexture(); return true; } -bool D3D11HostDisplay::Render(bool skip_present) +bool D3D11GPUDevice::Render(bool skip_present) { if (skip_present || !m_swap_chain) { @@ -705,8 +704,8 @@ bool D3D11HostDisplay::Render(bool skip_present) return true; } -bool D3D11HostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rectangle& draw_rect, - std::vector* out_pixels, u32* out_stride, GPUTexture::Format* out_format) +bool D3D11GPUDevice::RenderScreenshot(u32 width, u32 height, const Common::Rectangle& draw_rect, + std::vector* out_pixels, u32* out_stride, GPUTexture::Format* out_format) { static constexpr GPUTexture::Format hdformat = GPUTexture::Format::RGBA8; @@ -747,13 +746,13 @@ bool D3D11HostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rec return true; } -void D3D11HostDisplay::RenderImGui() +void D3D11GPUDevice::RenderImGui() { ImGui::Render(); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); } -void D3D11HostDisplay::RenderDisplay() +void D3D11GPUDevice::RenderDisplay() { const auto [left, top, width, height] = CalculateDrawRect(GetWindowWidth(), GetWindowHeight()); @@ -777,9 +776,9 @@ void D3D11HostDisplay::RenderDisplay() IsUsingLinearFiltering()); } -void D3D11HostDisplay::RenderDisplay(s32 left, s32 top, s32 width, s32 height, D3D11::Texture* texture, - s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, - s32 texture_view_height, bool linear_filter) +void D3D11GPUDevice::RenderDisplay(s32 left, s32 top, s32 width, s32 height, D3D11::Texture* texture, + s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, + s32 texture_view_height, bool linear_filter) { m_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); m_context->VSSetShader(m_display_vertex_shader.Get(), nullptr, 0); @@ -810,7 +809,7 @@ void D3D11HostDisplay::RenderDisplay(s32 left, s32 top, s32 width, s32 height, D m_context->Draw(3, 0); } -void D3D11HostDisplay::RenderSoftwareCursor() +void D3D11GPUDevice::RenderSoftwareCursor() { if (!HasSoftwareCursor()) return; @@ -819,7 +818,7 @@ void D3D11HostDisplay::RenderSoftwareCursor() RenderSoftwareCursor(left, top, width, height, m_cursor_texture.get()); } -void D3D11HostDisplay::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 height, GPUTexture* texture_handle) +void D3D11GPUDevice::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 height, GPUTexture* texture_handle) { m_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); m_context->VSSetShader(m_display_vertex_shader.Get(), nullptr, 0); @@ -843,7 +842,7 @@ void D3D11HostDisplay::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 he m_context->Draw(3, 0); } -HostDisplay::AdapterAndModeList D3D11HostDisplay::StaticGetAdapterAndModeList() +GPUDevice::AdapterAndModeList D3D11GPUDevice::StaticGetAdapterAndModeList() { ComPtr dxgi_factory; HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf())); @@ -853,7 +852,7 @@ HostDisplay::AdapterAndModeList D3D11HostDisplay::StaticGetAdapterAndModeList() return GetAdapterAndModeList(dxgi_factory.Get()); } -HostDisplay::AdapterAndModeList D3D11HostDisplay::GetAdapterAndModeList(IDXGIFactory* dxgi_factory) +GPUDevice::AdapterAndModeList D3D11GPUDevice::GetAdapterAndModeList(IDXGIFactory* dxgi_factory) { AdapterAndModeList adapter_info; ComPtr current_adapter; @@ -921,12 +920,12 @@ HostDisplay::AdapterAndModeList D3D11HostDisplay::GetAdapterAndModeList(IDXGIFac return adapter_info; } -HostDisplay::AdapterAndModeList D3D11HostDisplay::GetAdapterAndModeList() +GPUDevice::AdapterAndModeList D3D11GPUDevice::GetAdapterAndModeList() { return GetAdapterAndModeList(m_dxgi_factory.Get()); } -bool D3D11HostDisplay::SetPostProcessingChain(const std::string_view& config) +bool D3D11GPUDevice::SetPostProcessingChain(const std::string_view& config) { if (config.empty()) { @@ -983,7 +982,7 @@ bool D3D11HostDisplay::SetPostProcessingChain(const std::string_view& config) return true; } -bool D3D11HostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 target_height) +bool D3D11GPUDevice::CheckPostProcessingRenderTargets(u32 target_width, u32 target_height) { DebugAssert(!m_post_processing_stages.empty()); @@ -1014,10 +1013,10 @@ bool D3D11HostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 ta return true; } -void D3D11HostDisplay::ApplyPostProcessingChain(ID3D11RenderTargetView* final_target, s32 final_left, s32 final_top, - s32 final_width, s32 final_height, D3D11::Texture* texture, - s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, - s32 texture_view_height, u32 target_width, u32 target_height) +void D3D11GPUDevice::ApplyPostProcessingChain(ID3D11RenderTargetView* final_target, s32 final_left, s32 final_top, + s32 final_width, s32 final_height, D3D11::Texture* texture, + s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, + s32 texture_view_height, u32 target_width, u32 target_height) { if (!CheckPostProcessingRenderTargets(target_width, target_height)) { @@ -1074,7 +1073,7 @@ void D3D11HostDisplay::ApplyPostProcessingChain(ID3D11RenderTargetView* final_ta m_context->PSSetShaderResources(0, 1, &null_srv); } -bool D3D11HostDisplay::CreateTimestampQueries() +bool D3D11GPUDevice::CreateTimestampQueries() { for (u32 i = 0; i < NUM_TIMESTAMP_QUERIES; i++) { @@ -1094,7 +1093,7 @@ bool D3D11HostDisplay::CreateTimestampQueries() return true; } -void D3D11HostDisplay::DestroyTimestampQueries() +void D3D11GPUDevice::DestroyTimestampQueries() { if (!m_timestamp_queries[0][0]) return; @@ -1109,7 +1108,7 @@ void D3D11HostDisplay::DestroyTimestampQueries() m_timestamp_query_started = 0; } -void D3D11HostDisplay::PopTimestampQuery() +void D3D11GPUDevice::PopTimestampQuery() { while (m_waiting_timestamp_queries > 0) { @@ -1155,7 +1154,7 @@ void D3D11HostDisplay::PopTimestampQuery() } } -void D3D11HostDisplay::KickTimestampQuery() +void D3D11GPUDevice::KickTimestampQuery() { if (m_timestamp_query_started || !m_timestamp_queries[0][0] || m_waiting_timestamp_queries == NUM_TIMESTAMP_QUERIES) return; @@ -1165,7 +1164,7 @@ void D3D11HostDisplay::KickTimestampQuery() m_timestamp_query_started = true; } -bool D3D11HostDisplay::SetGPUTimingEnabled(bool enabled) +bool D3D11GPUDevice::SetGPUTimingEnabled(bool enabled) { if (m_gpu_timing_enabled == enabled) return true; @@ -1186,7 +1185,7 @@ bool D3D11HostDisplay::SetGPUTimingEnabled(bool enabled) } } -float D3D11HostDisplay::GetAndResetAccumulatedGPUTime() +float D3D11GPUDevice::GetAndResetAccumulatedGPUTime() { const float value = m_accumulated_gpu_time; m_accumulated_gpu_time = 0.0f; diff --git a/src/frontend-common/d3d11_host_display.h b/src/core/gpu/d3d11_gpu_device.h similarity index 95% rename from src/frontend-common/d3d11_host_display.h rename to src/core/gpu/d3d11_gpu_device.h index f6c4f725c..27d788ff9 100644 --- a/src/frontend-common/d3d11_host_display.h +++ b/src/core/gpu/d3d11_gpu_device.h @@ -2,13 +2,13 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "common/d3d11/stream_buffer.h" -#include "common/d3d11/texture.h" #include "common/timer.h" #include "common/window_info.h" #include "common/windows_headers.h" -#include "core/host_display.h" -#include "frontend-common/postprocessing_chain.h" +#include "d3d11/stream_buffer.h" +#include "d3d11/texture.h" +#include "gpu_device.h" +#include "postprocessing_chain.h" #include #include #include @@ -17,14 +17,14 @@ #include #include -class D3D11HostDisplay final : public HostDisplay +class D3D11GPUDevice final : public GPUDevice { public: template using ComPtr = Microsoft::WRL::ComPtr; - D3D11HostDisplay(); - ~D3D11HostDisplay(); + D3D11GPUDevice(); + ~D3D11GPUDevice(); RenderAPI GetRenderAPI() const override; void* GetDevice() const override; diff --git a/src/common/d3d12/context.cpp b/src/core/gpu/d3d12/context.cpp similarity index 99% rename from src/common/d3d12/context.cpp rename to src/core/gpu/d3d12/context.cpp index 186b1b30b..1d4514ba7 100644 --- a/src/common/d3d12/context.cpp +++ b/src/core/gpu/d3d12/context.cpp @@ -1,11 +1,11 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // Parts originally from Dolphin Emulator, also written by myself. #include "context.h" -#include "../assert.h" -#include "../log.h" -#include "../scoped_guard.h" +#include "common/assert.h" +#include "common/log.h" +#include "common/scoped_guard.h" #include #include #include diff --git a/src/common/d3d12/context.h b/src/core/gpu/d3d12/context.h similarity index 97% rename from src/common/d3d12/context.h rename to src/core/gpu/d3d12/context.h index 8bdc8e99b..dcad6d1c3 100644 --- a/src/common/d3d12/context.h +++ b/src/core/gpu/d3d12/context.h @@ -1,11 +1,11 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // Parts originally from Dolphin Emulator, also written by myself. #pragma once -#include "../types.h" -#include "../windows_headers.h" +#include "common/types.h" +#include "common/windows_headers.h" #include "descriptor_heap_manager.h" #include "stream_buffer.h" #include diff --git a/src/common/d3d12/descriptor_heap_manager.cpp b/src/core/gpu/d3d12/descriptor_heap_manager.cpp similarity index 98% rename from src/common/d3d12/descriptor_heap_manager.cpp rename to src/core/gpu/d3d12/descriptor_heap_manager.cpp index ca215fc62..20956a9f4 100644 --- a/src/common/d3d12/descriptor_heap_manager.cpp +++ b/src/core/gpu/d3d12/descriptor_heap_manager.cpp @@ -3,8 +3,8 @@ // Parts originally from Dolphin Emulator, also written by myself. #include "descriptor_heap_manager.h" -#include "../assert.h" -#include "../log.h" +#include "common/assert.h" +#include "common/log.h" #include "context.h" Log_SetChannel(DescriptorHeapManager); diff --git a/src/common/d3d12/descriptor_heap_manager.h b/src/core/gpu/d3d12/descriptor_heap_manager.h similarity index 97% rename from src/common/d3d12/descriptor_heap_manager.h rename to src/core/gpu/d3d12/descriptor_heap_manager.h index c5ad8267b..b05034ae4 100644 --- a/src/common/d3d12/descriptor_heap_manager.h +++ b/src/core/gpu/d3d12/descriptor_heap_manager.h @@ -4,8 +4,8 @@ #pragma once -#include "../types.h" -#include "../windows_headers.h" +#include "common/types.h" +#include "common/windows_headers.h" #include #include #include diff --git a/src/common/d3d12/shader_cache.cpp b/src/core/gpu/d3d12/shader_cache.cpp similarity index 99% rename from src/common/d3d12/shader_cache.cpp rename to src/core/gpu/d3d12/shader_cache.cpp index ce3f878e7..e8498ca13 100644 --- a/src/common/d3d12/shader_cache.cpp +++ b/src/core/gpu/d3d12/shader_cache.cpp @@ -3,9 +3,9 @@ #include "shader_cache.h" #include "../d3d11/shader_compiler.h" -#include "../file_system.h" -#include "../log.h" -#include "../md5_digest.h" +#include "common/file_system.h" +#include "common/log.h" +#include "common/md5_digest.h" #include Log_SetChannel(D3D12::ShaderCache); diff --git a/src/common/d3d12/shader_cache.h b/src/core/gpu/d3d12/shader_cache.h similarity index 97% rename from src/common/d3d12/shader_cache.h rename to src/core/gpu/d3d12/shader_cache.h index b5c2e6b1d..83ffff2d4 100644 --- a/src/common/d3d12/shader_cache.h +++ b/src/core/gpu/d3d12/shader_cache.h @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../hash_combine.h" -#include "../types.h" -#include "../windows_headers.h" +#include "common/hash_combine.h" +#include "common/types.h" +#include "common/windows_headers.h" #include #include #include diff --git a/src/common/d3d12/staging_texture.cpp b/src/core/gpu/d3d12/staging_texture.cpp similarity index 98% rename from src/common/d3d12/staging_texture.cpp rename to src/core/gpu/d3d12/staging_texture.cpp index 76e6ffeb3..14744a4f2 100644 --- a/src/common/d3d12/staging_texture.cpp +++ b/src/core/gpu/d3d12/staging_texture.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "staging_texture.h" -#include "../align.h" -#include "../assert.h" -#include "../log.h" +#include "common/align.h" +#include "common/assert.h" +#include "common/log.h" #include "context.h" #include "util.h" Log_SetChannel(D3D12); diff --git a/src/common/d3d12/staging_texture.h b/src/core/gpu/d3d12/staging_texture.h similarity index 95% rename from src/common/d3d12/staging_texture.h rename to src/core/gpu/d3d12/staging_texture.h index 2d97954b4..11e95e335 100644 --- a/src/common/d3d12/staging_texture.h +++ b/src/core/gpu/d3d12/staging_texture.h @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../types.h" -#include "../windows_headers.h" +#include "common/types.h" +#include "common/windows_headers.h" #include #include #include @@ -40,7 +40,6 @@ public: void CopyFromTexture(ID3D12Resource* src_texture, u32 src_subresource, u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height); - bool ReadPixels(u32 x, u32 y, u32 width, u32 height, void* data, u32 row_pitch); bool WritePixels(u32 x, u32 y, u32 width, u32 height, const void* data, u32 row_pitch); diff --git a/src/common/d3d12/stream_buffer.cpp b/src/core/gpu/d3d12/stream_buffer.cpp similarity index 98% rename from src/common/d3d12/stream_buffer.cpp rename to src/core/gpu/d3d12/stream_buffer.cpp index 18b82f013..8baa765c3 100644 --- a/src/common/d3d12/stream_buffer.cpp +++ b/src/core/gpu/d3d12/stream_buffer.cpp @@ -1,11 +1,11 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // Parts originally from Dolphin Emulator, also written by myself. #include "stream_buffer.h" -#include "../align.h" -#include "../assert.h" -#include "../log.h" +#include "common/align.h" +#include "common/assert.h" +#include "common/log.h" #include "context.h" #include #include diff --git a/src/common/d3d12/stream_buffer.h b/src/core/gpu/d3d12/stream_buffer.h similarity index 93% rename from src/common/d3d12/stream_buffer.h rename to src/core/gpu/d3d12/stream_buffer.h index 1655f6a30..ca2972791 100644 --- a/src/common/d3d12/stream_buffer.h +++ b/src/core/gpu/d3d12/stream_buffer.h @@ -1,11 +1,11 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // Parts originally from Dolphin Emulator, also written by myself. #pragma once -#include "../types.h" -#include "../windows_headers.h" +#include "common/types.h" +#include "common/windows_headers.h" #include #include #include diff --git a/src/common/d3d12/texture.cpp b/src/core/gpu/d3d12/texture.cpp similarity index 99% rename from src/common/d3d12/texture.cpp rename to src/core/gpu/d3d12/texture.cpp index cfa19cdd2..16d6af35b 100644 --- a/src/common/d3d12/texture.cpp +++ b/src/core/gpu/d3d12/texture.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "texture.h" -#include "../align.h" -#include "../assert.h" -#include "../log.h" +#include "common/align.h" +#include "common/assert.h" +#include "common/log.h" #include "context.h" #include "staging_texture.h" #include "stream_buffer.h" diff --git a/src/common/d3d12/texture.h b/src/core/gpu/d3d12/texture.h similarity index 98% rename from src/common/d3d12/texture.h rename to src/core/gpu/d3d12/texture.h index d43078469..50b2e777b 100644 --- a/src/common/d3d12/texture.h +++ b/src/core/gpu/d3d12/texture.h @@ -3,7 +3,7 @@ #pragma once #include "../gpu_texture.h" -#include "../windows_headers.h" +#include "common/windows_headers.h" #include "descriptor_heap_manager.h" #include #include diff --git a/src/common/d3d12/util.cpp b/src/core/gpu/d3d12/util.cpp similarity index 98% rename from src/common/d3d12/util.cpp rename to src/core/gpu/d3d12/util.cpp index 607a980b1..726430025 100644 --- a/src/common/d3d12/util.cpp +++ b/src/core/gpu/d3d12/util.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "util.h" -#include "../assert.h" -#include "../log.h" -#include "../string.h" -#include "../string_util.h" +#include "common/assert.h" +#include "common/log.h" +#include "common/string.h" +#include "common/string_util.h" #include "context.h" #include "shader_cache.h" #include diff --git a/src/common/d3d12/util.h b/src/core/gpu/d3d12/util.h similarity index 98% rename from src/common/d3d12/util.h rename to src/core/gpu/d3d12/util.h index 11f2c1986..cafbe8341 100644 --- a/src/common/d3d12/util.h +++ b/src/core/gpu/d3d12/util.h @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../types.h" -#include "../windows_headers.h" +#include "common/types.h" +#include "common/windows_headers.h" #include #include #include diff --git a/src/frontend-common/d3d12_host_display.cpp b/src/core/gpu/d3d12_gpu_device.cpp similarity index 87% rename from src/frontend-common/d3d12_host_display.cpp rename to src/core/gpu/d3d12_gpu_device.cpp index 1e3df79ea..3447caeeb 100644 --- a/src/frontend-common/d3d12_host_display.cpp +++ b/src/core/gpu/d3d12_gpu_device.cpp @@ -1,30 +1,30 @@ // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) -#include "d3d12_host_display.h" +#include "d3d12_gpu_device.h" +#include "../settings.h" #include "common/assert.h" -#include "common/d3d11/shader_compiler.h" -#include "common/d3d12/context.h" -#include "common/d3d12/shader_cache.h" -#include "common/d3d12/util.h" #include "common/log.h" #include "common/string_util.h" -#include "core/settings.h" +#include "d3d11/shader_compiler.h" +#include "d3d12/context.h" +#include "d3d12/shader_cache.h" +#include "d3d12/util.h" #include "display_ps.hlsl.h" #include "display_ps_alpha.hlsl.h" #include "display_vs.hlsl.h" -#include "frontend-common/postprocessing_shadergen.h" #include "imgui.h" #include "imgui_impl_dx12.h" +#include "postprocessing_shadergen.h" #include #include -Log_SetChannel(D3D12HostDisplay); +Log_SetChannel(D3D12GPUDevice); static constexpr const std::array s_clear_color = {0.0f, 0.0f, 0.0f, 1.0f}; -D3D12HostDisplay::D3D12HostDisplay() = default; +D3D12GPUDevice::D3D12GPUDevice() = default; -D3D12HostDisplay::~D3D12HostDisplay() +D3D12GPUDevice::~D3D12GPUDevice() { if (!g_d3d12_context) return; @@ -35,34 +35,34 @@ D3D12HostDisplay::~D3D12HostDisplay() g_d3d12_context->Destroy(); } -RenderAPI D3D12HostDisplay::GetRenderAPI() const +RenderAPI D3D12GPUDevice::GetRenderAPI() const { return RenderAPI::D3D12; } -void* D3D12HostDisplay::GetDevice() const +void* D3D12GPUDevice::GetDevice() const { return g_d3d12_context->GetDevice(); } -void* D3D12HostDisplay::GetContext() const +void* D3D12GPUDevice::GetContext() const { return g_d3d12_context.get(); } -bool D3D12HostDisplay::HasDevice() const +bool D3D12GPUDevice::HasDevice() const { return static_cast(g_d3d12_context); } -bool D3D12HostDisplay::HasSurface() const +bool D3D12GPUDevice::HasSurface() const { return static_cast(m_swap_chain); } -std::unique_ptr D3D12HostDisplay::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, - GPUTexture::Format format, const void* data, - u32 data_stride, bool dynamic /* = false */) +std::unique_ptr D3D12GPUDevice::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, + GPUTexture::Format format, const void* data, u32 data_stride, + bool dynamic /* = false */) { const DXGI_FORMAT dformat = D3D12::Texture::GetDXGIFormat(format); if (dformat == DXGI_FORMAT_UNKNOWN) @@ -81,24 +81,24 @@ std::unique_ptr D3D12HostDisplay::CreateTexture(u32 width, u32 heigh return tex; } -bool D3D12HostDisplay::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, u32* out_pitch) +bool D3D12GPUDevice::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, u32* out_pitch) { return static_cast(texture)->BeginStreamUpdate(0, 0, width, height, out_buffer, out_pitch); } -void D3D12HostDisplay::EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height) +void D3D12GPUDevice::EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height) { static_cast(texture)->EndStreamUpdate(x, y, width, height); } -bool D3D12HostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, - u32 pitch) +bool D3D12GPUDevice::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, + u32 pitch) { - return HostDisplay::UpdateTexture(texture, x, y, width, height, data, pitch); + return GPUDevice::UpdateTexture(texture, x, y, width, height, data, pitch); } -bool D3D12HostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, - u32 out_data_stride) +bool D3D12GPUDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, + u32 out_data_stride) { const D3D12::Texture* tex = static_cast(texture); @@ -113,7 +113,7 @@ bool D3D12HostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 wi return m_readback_staging_texture.ReadPixels(0, 0, width, height, out_data, out_data_stride); } -bool D3D12HostDisplay::SupportsTextureFormat(GPUTexture::Format format) const +bool D3D12GPUDevice::SupportsTextureFormat(GPUTexture::Format format) const { const DXGI_FORMAT dfmt = D3D12::Texture::GetDXGIFormat(format); if (dfmt == DXGI_FORMAT_UNKNOWN) @@ -122,7 +122,7 @@ bool D3D12HostDisplay::SupportsTextureFormat(GPUTexture::Format format) const return g_d3d12_context->SupportsTextureFormat(dfmt); } -bool D3D12HostDisplay::GetHostRefreshRate(float* refresh_rate) +bool D3D12GPUDevice::GetHostRefreshRate(float* refresh_rate) { if (m_swap_chain && IsFullscreen()) { @@ -138,15 +138,15 @@ bool D3D12HostDisplay::GetHostRefreshRate(float* refresh_rate) } } - return HostDisplay::GetHostRefreshRate(refresh_rate); + return GPUDevice::GetHostRefreshRate(refresh_rate); } -void D3D12HostDisplay::SetVSync(bool enabled) +void D3D12GPUDevice::SetVSync(bool enabled) { m_vsync_enabled = enabled; } -bool D3D12HostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) +bool D3D12GPUDevice::CreateDevice(const WindowInfo& wi, bool vsync) { ComPtr temp_dxgi_factory; HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(temp_dxgi_factory.GetAddressOf())); @@ -213,7 +213,7 @@ bool D3D12HostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) return true; } -bool D3D12HostDisplay::SetupDevice() +bool D3D12GPUDevice::SetupDevice() { if (!CreateResources()) return false; @@ -221,17 +221,17 @@ bool D3D12HostDisplay::SetupDevice() return true; } -bool D3D12HostDisplay::MakeCurrent() +bool D3D12GPUDevice::MakeCurrent() { return true; } -bool D3D12HostDisplay::DoneCurrent() +bool D3D12GPUDevice::DoneCurrent() { return true; } -bool D3D12HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) +bool D3D12GPUDevice::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) { HRESULT hr; @@ -284,7 +284,7 @@ bool D3D12HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) return CreateSwapChainRTV(); } -bool D3D12HostDisplay::CreateSwapChainRTV() +bool D3D12GPUDevice::CreateSwapChainRTV() { DXGI_SWAP_CHAIN_DESC swap_chain_desc; HRESULT hr = m_swap_chain->GetDesc(&swap_chain_desc); @@ -335,7 +335,7 @@ bool D3D12HostDisplay::CreateSwapChainRTV() return true; } -void D3D12HostDisplay::DestroySwapChainRTVs() +void D3D12GPUDevice::DestroySwapChainRTVs() { for (D3D12::Texture& buffer : m_swap_chain_buffers) buffer.Destroy(false); @@ -343,7 +343,7 @@ void D3D12HostDisplay::DestroySwapChainRTVs() m_current_swap_chain_buffer = 0; } -bool D3D12HostDisplay::ChangeWindow(const WindowInfo& new_wi) +bool D3D12GPUDevice::ChangeWindow(const WindowInfo& new_wi) { DestroySurface(); @@ -351,7 +351,7 @@ bool D3D12HostDisplay::ChangeWindow(const WindowInfo& new_wi) return CreateSwapChain(nullptr); } -void D3D12HostDisplay::DestroySurface() +void D3D12GPUDevice::DestroySurface() { m_window_info.SetSurfaceless(); @@ -365,7 +365,7 @@ void D3D12HostDisplay::DestroySurface() m_swap_chain.Reset(); } -void D3D12HostDisplay::ResizeWindow(s32 new_window_width, s32 new_window_height) +void D3D12GPUDevice::ResizeWindow(s32 new_window_width, s32 new_window_height) { if (!m_swap_chain) return; @@ -384,18 +384,18 @@ void D3D12HostDisplay::ResizeWindow(s32 new_window_width, s32 new_window_height) Panic("Failed to recreate swap chain RTV after resize"); } -bool D3D12HostDisplay::SupportsFullscreen() const +bool D3D12GPUDevice::SupportsFullscreen() const { return true; } -bool D3D12HostDisplay::IsFullscreen() +bool D3D12GPUDevice::IsFullscreen() { BOOL is_fullscreen = FALSE; return (m_swap_chain && SUCCEEDED(m_swap_chain->GetFullscreenState(&is_fullscreen, nullptr)) && is_fullscreen); } -bool D3D12HostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) +bool D3D12GPUDevice::SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) { if (!m_swap_chain) return false; @@ -458,12 +458,12 @@ bool D3D12HostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, flo return true; } -HostDisplay::AdapterAndModeList D3D12HostDisplay::GetAdapterAndModeList() +GPUDevice::AdapterAndModeList D3D12GPUDevice::GetAdapterAndModeList() { return GetAdapterAndModeList(m_dxgi_factory.Get()); } -bool D3D12HostDisplay::CreateResources() +bool D3D12GPUDevice::CreateResources() { D3D12::RootSignatureBuilder rsbuilder; rsbuilder.Add32BitConstants(0, 4, D3D12_SHADER_VISIBILITY_VERTEX); @@ -543,9 +543,9 @@ bool D3D12HostDisplay::CreateResources() return true; } -void D3D12HostDisplay::DestroyResources() +void D3D12GPUDevice::DestroyResources() { - HostDisplay::DestroyResources(); + GPUDevice::DestroyResources(); m_post_processing_cbuffer.Destroy(false); m_post_processing_chain.ClearStages(); @@ -563,7 +563,7 @@ void D3D12HostDisplay::DestroyResources() m_display_root_signature.Reset(); } -bool D3D12HostDisplay::CreateImGuiContext() +bool D3D12GPUDevice::CreateImGuiContext() { ImGui::GetIO().DisplaySize.x = static_cast(m_window_info.surface_width); ImGui::GetIO().DisplaySize.y = static_cast(m_window_info.surface_height); @@ -571,19 +571,19 @@ bool D3D12HostDisplay::CreateImGuiContext() return ImGui_ImplDX12_Init(DXGI_FORMAT_R8G8B8A8_UNORM); } -void D3D12HostDisplay::DestroyImGuiContext() +void D3D12GPUDevice::DestroyImGuiContext() { g_d3d12_context->WaitForGPUIdle(); ImGui_ImplDX12_Shutdown(); } -bool D3D12HostDisplay::UpdateImGuiFontTexture() +bool D3D12GPUDevice::UpdateImGuiFontTexture() { return ImGui_ImplDX12_CreateFontsTexture(); } -bool D3D12HostDisplay::Render(bool skip_present) +bool D3D12GPUDevice::Render(bool skip_present) { if (skip_present || !m_swap_chain) { @@ -615,8 +615,8 @@ bool D3D12HostDisplay::Render(bool skip_present) return true; } -bool D3D12HostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rectangle& draw_rect, - std::vector* out_pixels, u32* out_stride, GPUTexture::Format* out_format) +bool D3D12GPUDevice::RenderScreenshot(u32 width, u32 height, const Common::Rectangle& draw_rect, + std::vector* out_pixels, u32* out_stride, GPUTexture::Format* out_format) { static constexpr DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; static constexpr GPUTexture::Format hdformat = GPUTexture::Format::RGBA8; @@ -665,25 +665,25 @@ bool D3D12HostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rec return m_readback_staging_texture.ReadPixels(0, 0, width, height, out_pixels->data(), stride); } -bool D3D12HostDisplay::SetGPUTimingEnabled(bool enabled) +bool D3D12GPUDevice::SetGPUTimingEnabled(bool enabled) { g_d3d12_context->SetEnableGPUTiming(enabled); m_gpu_timing_enabled = enabled; return true; } -float D3D12HostDisplay::GetAndResetAccumulatedGPUTime() +float D3D12GPUDevice::GetAndResetAccumulatedGPUTime() { return g_d3d12_context->GetAndResetAccumulatedGPUTime(); } -void D3D12HostDisplay::RenderImGui(ID3D12GraphicsCommandList* cmdlist) +void D3D12GPUDevice::RenderImGui(ID3D12GraphicsCommandList* cmdlist) { ImGui::Render(); ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData()); } -void D3D12HostDisplay::RenderDisplay(ID3D12GraphicsCommandList* cmdlist, D3D12::Texture* swap_chain_buf) +void D3D12GPUDevice::RenderDisplay(ID3D12GraphicsCommandList* cmdlist, D3D12::Texture* swap_chain_buf) { const auto [left, top, width, height] = CalculateDrawRect(GetWindowWidth(), GetWindowHeight()); @@ -708,9 +708,9 @@ void D3D12HostDisplay::RenderDisplay(ID3D12GraphicsCommandList* cmdlist, D3D12:: m_display_texture_view_height, IsUsingLinearFiltering()); } -void D3D12HostDisplay::RenderDisplay(ID3D12GraphicsCommandList* cmdlist, s32 left, s32 top, s32 width, s32 height, - D3D12::Texture* texture, s32 texture_view_x, s32 texture_view_y, - s32 texture_view_width, s32 texture_view_height, bool linear_filter) +void D3D12GPUDevice::RenderDisplay(ID3D12GraphicsCommandList* cmdlist, s32 left, s32 top, s32 width, s32 height, + D3D12::Texture* texture, s32 texture_view_x, s32 texture_view_y, + s32 texture_view_width, s32 texture_view_height, bool linear_filter) { const float position_adjust = linear_filter ? 0.5f : 0.0f; const float size_adjust = linear_filter ? 1.0f : 0.0f; @@ -732,7 +732,7 @@ void D3D12HostDisplay::RenderDisplay(ID3D12GraphicsCommandList* cmdlist, s32 lef cmdlist->DrawInstanced(3, 1, 0, 0); } -void D3D12HostDisplay::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist) +void D3D12GPUDevice::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist) { if (!HasSoftwareCursor()) return; @@ -741,8 +741,8 @@ void D3D12HostDisplay::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist) RenderSoftwareCursor(cmdlist, left, top, width, height, m_cursor_texture.get()); } -void D3D12HostDisplay::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist, s32 left, s32 top, s32 width, - s32 height, GPUTexture* texture_handle) +void D3D12GPUDevice::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist, s32 left, s32 top, s32 width, s32 height, + GPUTexture* texture_handle) { const float uniforms[4] = {0.0f, 0.0f, 1.0f, 1.0f}; @@ -758,7 +758,7 @@ void D3D12HostDisplay::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist, cmdlist->DrawInstanced(3, 1, 0, 0); } -HostDisplay::AdapterAndModeList D3D12HostDisplay::StaticGetAdapterAndModeList() +GPUDevice::AdapterAndModeList D3D12GPUDevice::StaticGetAdapterAndModeList() { ComPtr dxgi_factory; HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf())); @@ -768,7 +768,7 @@ HostDisplay::AdapterAndModeList D3D12HostDisplay::StaticGetAdapterAndModeList() return GetAdapterAndModeList(dxgi_factory.Get()); } -HostDisplay::AdapterAndModeList D3D12HostDisplay::GetAdapterAndModeList(IDXGIFactory* dxgi_factory) +GPUDevice::AdapterAndModeList D3D12GPUDevice::GetAdapterAndModeList(IDXGIFactory* dxgi_factory) { AdapterAndModeList adapter_info; ComPtr current_adapter; @@ -836,19 +836,19 @@ HostDisplay::AdapterAndModeList D3D12HostDisplay::GetAdapterAndModeList(IDXGIFac return adapter_info; } -D3D12HostDisplay::PostProcessingStage::PostProcessingStage(PostProcessingStage&& move) +D3D12GPUDevice::PostProcessingStage::PostProcessingStage(PostProcessingStage&& move) : pipeline(std::move(move.pipeline)), output_texture(std::move(move.output_texture)), uniforms_size(move.uniforms_size) { move.uniforms_size = 0; } -D3D12HostDisplay::PostProcessingStage::~PostProcessingStage() +D3D12GPUDevice::PostProcessingStage::~PostProcessingStage() { output_texture.Destroy(true); } -bool D3D12HostDisplay::SetPostProcessingChain(const std::string_view& config) +bool D3D12GPUDevice::SetPostProcessingChain(const std::string_view& config) { g_d3d12_context->ExecuteCommandList(true); @@ -933,7 +933,7 @@ bool D3D12HostDisplay::SetPostProcessingChain(const std::string_view& config) return true; } -bool D3D12HostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 target_height) +bool D3D12GPUDevice::CheckPostProcessingRenderTargets(u32 target_width, u32 target_height) { DebugAssert(!m_post_processing_stages.empty()); @@ -971,11 +971,11 @@ bool D3D12HostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 ta return true; } -void D3D12HostDisplay::ApplyPostProcessingChain(ID3D12GraphicsCommandList* cmdlist, D3D12::Texture* final_target, - s32 final_left, s32 final_top, s32 final_width, s32 final_height, - D3D12::Texture* texture, s32 texture_view_x, s32 texture_view_y, - s32 texture_view_width, s32 texture_view_height, u32 target_width, - u32 target_height) +void D3D12GPUDevice::ApplyPostProcessingChain(ID3D12GraphicsCommandList* cmdlist, D3D12::Texture* final_target, + s32 final_left, s32 final_top, s32 final_width, s32 final_height, + D3D12::Texture* texture, s32 texture_view_x, s32 texture_view_y, + s32 texture_view_width, s32 texture_view_height, u32 target_width, + u32 target_height) { if (!CheckPostProcessingRenderTargets(target_width, target_height)) { diff --git a/src/frontend-common/d3d12_host_display.h b/src/core/gpu/d3d12_gpu_device.h similarity index 94% rename from src/frontend-common/d3d12_host_display.h rename to src/core/gpu/d3d12_gpu_device.h index dfd49848d..3f076eb93 100644 --- a/src/frontend-common/d3d12_host_display.h +++ b/src/core/gpu/d3d12_gpu_device.h @@ -2,14 +2,14 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "common/d3d12/descriptor_heap_manager.h" -#include "common/d3d12/staging_texture.h" -#include "common/d3d12/stream_buffer.h" -#include "common/d3d12/texture.h" #include "common/timer.h" #include "common/window_info.h" #include "common/windows_headers.h" -#include "core/host_display.h" +#include "d3d12/descriptor_heap_manager.h" +#include "d3d12/staging_texture.h" +#include "d3d12/stream_buffer.h" +#include "d3d12/texture.h" +#include "gpu_device.h" #include "postprocessing_chain.h" #include #include @@ -19,14 +19,14 @@ #include #include -class D3D12HostDisplay final : public HostDisplay +class D3D12GPUDevice final : public GPUDevice { public: template using ComPtr = Microsoft::WRL::ComPtr; - D3D12HostDisplay(); - ~D3D12HostDisplay(); + D3D12GPUDevice(); + ~D3D12GPUDevice(); RenderAPI GetRenderAPI() const override; void* GetDevice() const override; diff --git a/src/frontend-common/display_ps.hlsl b/src/core/gpu/display_ps.hlsl similarity index 100% rename from src/frontend-common/display_ps.hlsl rename to src/core/gpu/display_ps.hlsl diff --git a/src/frontend-common/display_ps.hlsl.h b/src/core/gpu/display_ps.hlsl.h similarity index 100% rename from src/frontend-common/display_ps.hlsl.h rename to src/core/gpu/display_ps.hlsl.h diff --git a/src/frontend-common/display_ps_alpha.hlsl.h b/src/core/gpu/display_ps_alpha.hlsl.h similarity index 100% rename from src/frontend-common/display_ps_alpha.hlsl.h rename to src/core/gpu/display_ps_alpha.hlsl.h diff --git a/src/frontend-common/display_vs.hlsl b/src/core/gpu/display_vs.hlsl similarity index 100% rename from src/frontend-common/display_vs.hlsl rename to src/core/gpu/display_vs.hlsl diff --git a/src/frontend-common/display_vs.hlsl.h b/src/core/gpu/display_vs.hlsl.h similarity index 100% rename from src/frontend-common/display_vs.hlsl.h rename to src/core/gpu/display_vs.hlsl.h diff --git a/src/common/gl/context.cpp b/src/core/gpu/gl/context.cpp similarity index 92% rename from src/common/gl/context.cpp rename to src/core/gpu/gl/context.cpp index 266a2b976..a5692306b 100644 --- a/src/common/gl/context.cpp +++ b/src/core/gpu/gl/context.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "context.h" -#include "../log.h" +#include "common/log.h" #include "loader.h" #include #include @@ -17,32 +17,20 @@ Log_SetChannel(GL::Context); #include "context_wgl.h" #elif defined(__APPLE__) #include "context_agl.h" -#endif - +#else #ifdef USE_EGL -#if defined(USE_WAYLAND) || defined(USE_GBM) || defined(USE_FBDEV) || defined(USE_X11) -#if defined(USE_WAYLAND) +#ifdef USE_WAYLAND #include "context_egl_wayland.h" #endif -#if defined(USE_GBM) -#include "context_egl_gbm.h" -#endif -#if defined(USE_FBDEV) -#include "context_egl_fbdev.h" -#endif -#if defined(USE_X11) +#ifdef USE_X11 #include "context_egl_x11.h" #endif -#elif defined(ANDROID) -#include "context_egl_android.h" -#else -#error Unknown EGL platform -#endif #endif #ifdef USE_GLX #include "context_glx.h" #endif +#endif namespace GL { @@ -131,12 +119,7 @@ std::unique_ptr Context::Create(const WindowInfo& wi, const Version context = ContextWGL::Create(wi, versions_to_try, num_versions_to_try); #elif defined(__APPLE__) context = ContextAGL::Create(wi, versions_to_try, num_versions_to_try); -#elif defined(ANDROID) -#ifdef USE_EGL - context = ContextEGLAndroid::Create(wi, versions_to_try, num_versions_to_try); -#endif -#endif - +#else #if defined(USE_X11) if (wi.type == WindowInfo::Type::X11) { @@ -156,15 +139,6 @@ std::unique_ptr Context::Create(const WindowInfo& wi, const Version if (wi.type == WindowInfo::Type::Wayland) context = ContextEGLWayland::Create(wi, versions_to_try, num_versions_to_try); #endif - -#if defined(USE_GBM) - if (wi.type == WindowInfo::Type::Display) - context = ContextEGLGBM::Create(wi, versions_to_try, num_versions_to_try); -#endif - -#if defined(USE_FBDEV) - if (wi.type == WindowInfo::Type::Display) - context = ContextEGLFBDev::Create(wi, versions_to_try, num_versions_to_try); #endif if (!context) diff --git a/src/common/gl/context.h b/src/core/gpu/gl/context.h similarity index 97% rename from src/common/gl/context.h rename to src/core/gpu/gl/context.h index f4c90311c..2bef9ee2f 100644 --- a/src/common/gl/context.h +++ b/src/core/gpu/gl/context.h @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../types.h" -#include "../window_info.h" +#include "common/types.h" +#include "common/window_info.h" #include #include #include diff --git a/src/common/gl/context_agl.h b/src/core/gpu/gl/context_agl.h similarity index 100% rename from src/common/gl/context_agl.h rename to src/core/gpu/gl/context_agl.h diff --git a/src/common/gl/context_agl.mm b/src/core/gpu/gl/context_agl.mm similarity index 100% rename from src/common/gl/context_agl.mm rename to src/core/gpu/gl/context_agl.mm diff --git a/src/common/gl/context_egl.cpp b/src/core/gpu/gl/context_egl.cpp similarity index 100% rename from src/common/gl/context_egl.cpp rename to src/core/gpu/gl/context_egl.cpp diff --git a/src/common/gl/context_egl.h b/src/core/gpu/gl/context_egl.h similarity index 100% rename from src/common/gl/context_egl.h rename to src/core/gpu/gl/context_egl.h diff --git a/src/common/gl/context_egl_wayland.cpp b/src/core/gpu/gl/context_egl_wayland.cpp similarity index 100% rename from src/common/gl/context_egl_wayland.cpp rename to src/core/gpu/gl/context_egl_wayland.cpp diff --git a/src/common/gl/context_egl_wayland.h b/src/core/gpu/gl/context_egl_wayland.h similarity index 100% rename from src/common/gl/context_egl_wayland.h rename to src/core/gpu/gl/context_egl_wayland.h diff --git a/src/common/gl/context_egl_x11.cpp b/src/core/gpu/gl/context_egl_x11.cpp similarity index 100% rename from src/common/gl/context_egl_x11.cpp rename to src/core/gpu/gl/context_egl_x11.cpp diff --git a/src/common/gl/context_egl_x11.h b/src/core/gpu/gl/context_egl_x11.h similarity index 100% rename from src/common/gl/context_egl_x11.h rename to src/core/gpu/gl/context_egl_x11.h diff --git a/src/common/gl/context_glx.cpp b/src/core/gpu/gl/context_glx.cpp similarity index 100% rename from src/common/gl/context_glx.cpp rename to src/core/gpu/gl/context_glx.cpp diff --git a/src/common/gl/context_glx.h b/src/core/gpu/gl/context_glx.h similarity index 100% rename from src/common/gl/context_glx.h rename to src/core/gpu/gl/context_glx.h diff --git a/src/common/gl/context_wgl.cpp b/src/core/gpu/gl/context_wgl.cpp similarity index 98% rename from src/common/gl/context_wgl.cpp rename to src/core/gpu/gl/context_wgl.cpp index 2b5d22b74..11827fbdc 100644 --- a/src/common/gl/context_wgl.cpp +++ b/src/core/gpu/gl/context_wgl.cpp @@ -1,10 +1,10 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "context_wgl.h" -#include "../assert.h" -#include "../log.h" -#include "../scoped_guard.h" +#include "common/assert.h" +#include "common/log.h" +#include "common/scoped_guard.h" #include "loader.h" Log_SetChannel(GL::ContextWGL); diff --git a/src/common/gl/context_wgl.h b/src/core/gpu/gl/context_wgl.h similarity index 93% rename from src/common/gl/context_wgl.h rename to src/core/gpu/gl/context_wgl.h index 6a032b5a1..abaa542eb 100644 --- a/src/common/gl/context_wgl.h +++ b/src/core/gpu/gl/context_wgl.h @@ -1,9 +1,8 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../windows_headers.h" - +#include "common/windows_headers.h" #include "context.h" #include "glad_wgl.h" #include "loader.h" diff --git a/src/common/gl/loader.h b/src/core/gpu/gl/loader.h similarity index 79% rename from src/common/gl/loader.h rename to src/core/gpu/gl/loader.h index c7f1479ea..5cdaf1a25 100644 --- a/src/common/gl/loader.h +++ b/src/core/gpu/gl/loader.h @@ -5,7 +5,7 @@ // Fix glad.h including windows.h #ifdef _WIN32 -#include "../windows_headers.h" +#include "common/windows_headers.h" #endif #include "glad.h" \ No newline at end of file diff --git a/src/common/gl/program.cpp b/src/core/gpu/gl/program.cpp similarity index 99% rename from src/common/gl/program.cpp rename to src/core/gpu/gl/program.cpp index 204260eee..27ad014de 100644 --- a/src/common/gl/program.cpp +++ b/src/core/gpu/gl/program.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "program.h" -#include "../assert.h" -#include "../log.h" -#include "../string_util.h" +#include "common/assert.h" +#include "common/log.h" +#include "common/string_util.h" #include #include Log_SetChannel(GL); diff --git a/src/common/gl/program.h b/src/core/gpu/gl/program.h similarity index 98% rename from src/common/gl/program.h rename to src/core/gpu/gl/program.h index 8fe43b507..e8c3e1141 100644 --- a/src/common/gl/program.h +++ b/src/core/gpu/gl/program.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../types.h" +#include "common/types.h" #include "loader.h" #include #include diff --git a/src/common/gl/shader_cache.cpp b/src/core/gpu/gl/shader_cache.cpp similarity index 98% rename from src/common/gl/shader_cache.cpp rename to src/core/gpu/gl/shader_cache.cpp index 286a73cab..1e9fec263 100644 --- a/src/common/gl/shader_cache.cpp +++ b/src/core/gpu/gl/shader_cache.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "shader_cache.h" -#include "../file_system.h" -#include "../log.h" -#include "../md5_digest.h" -#include "../path.h" -#include "../string_util.h" +#include "common/file_system.h" +#include "common/log.h" +#include "common/md5_digest.h" +#include "common/path.h" +#include "common/string_util.h" Log_SetChannel(GL::ShaderCache); #pragma pack(push, 1) diff --git a/src/common/gl/shader_cache.h b/src/core/gpu/gl/shader_cache.h similarity index 97% rename from src/common/gl/shader_cache.h rename to src/core/gpu/gl/shader_cache.h index a65278831..145aa1d45 100644 --- a/src/common/gl/shader_cache.h +++ b/src/core/gpu/gl/shader_cache.h @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../hash_combine.h" -#include "../types.h" +#include "common/hash_combine.h" +#include "common/types.h" #include "program.h" #include #include diff --git a/src/common/gl/stream_buffer.cpp b/src/core/gpu/gl/stream_buffer.cpp similarity index 99% rename from src/common/gl/stream_buffer.cpp rename to src/core/gpu/gl/stream_buffer.cpp index a50930cb3..4cf7173de 100644 --- a/src/common/gl/stream_buffer.cpp +++ b/src/core/gpu/gl/stream_buffer.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "stream_buffer.h" -#include "../align.h" -#include "../assert.h" +#include "common/align.h" +#include "common/assert.h" #include #include diff --git a/src/common/gl/stream_buffer.h b/src/core/gpu/gl/stream_buffer.h similarity index 89% rename from src/common/gl/stream_buffer.h rename to src/core/gpu/gl/stream_buffer.h index c7a35e0d6..5f386575e 100644 --- a/src/common/gl/stream_buffer.h +++ b/src/core/gpu/gl/stream_buffer.h @@ -1,8 +1,8 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../types.h" +#include "common/types.h" #include "loader.h" #include #include diff --git a/src/common/gl/texture.cpp b/src/core/gpu/gl/texture.cpp similarity index 99% rename from src/common/gl/texture.cpp rename to src/core/gpu/gl/texture.cpp index 08bcce89a..7e75978de 100644 --- a/src/common/gl/texture.cpp +++ b/src/core/gpu/gl/texture.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "texture.h" -#include "../assert.h" -#include "../log.h" +#include "common/assert.h" +#include "common/log.h" #include #include #include diff --git a/src/common/gl/texture.h b/src/core/gpu/gl/texture.h similarity index 100% rename from src/common/gl/texture.h rename to src/core/gpu/gl/texture.h diff --git a/src/common/gl/x11_window.cpp b/src/core/gpu/gl/x11_window.cpp similarity index 100% rename from src/common/gl/x11_window.cpp rename to src/core/gpu/gl/x11_window.cpp diff --git a/src/common/gl/x11_window.h b/src/core/gpu/gl/x11_window.h similarity index 97% rename from src/common/gl/x11_window.h rename to src/core/gpu/gl/x11_window.h index 0aa9e9d6d..d19ae7ff1 100644 --- a/src/common/gl/x11_window.h +++ b/src/core/gpu/gl/x11_window.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../types.h" +#include "common/types.h" #include #include diff --git a/src/core/host_display.cpp b/src/core/gpu/gpu_device.cpp similarity index 87% rename from src/core/host_display.cpp rename to src/core/gpu/gpu_device.cpp index 18cd5785d..e39572de2 100644 --- a/src/core/host_display.cpp +++ b/src/core/gpu/gpu_device.cpp @@ -1,14 +1,14 @@ // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) -#include "host_display.h" +#include "gpu_device.h" +#include "../settings.h" #include "common/align.h" #include "common/assert.h" #include "common/file_system.h" #include "common/log.h" #include "common/string_util.h" #include "common/timer.h" -#include "settings.h" #include "stb_image.h" #include "stb_image_resize.h" #include "stb_image_write.h" @@ -17,13 +17,13 @@ #include #include #include -Log_SetChannel(HostDisplay); +Log_SetChannel(GPUDevice); -std::unique_ptr g_host_display; +std::unique_ptr g_host_display; -HostDisplay::~HostDisplay() = default; +GPUDevice::~GPUDevice() = default; -RenderAPI HostDisplay::GetPreferredAPI() +RenderAPI GPUDevice::GetPreferredAPI() { #ifdef _WIN32 return RenderAPI::D3D11; @@ -32,12 +32,12 @@ RenderAPI HostDisplay::GetPreferredAPI() #endif } -void HostDisplay::DestroyResources() +void GPUDevice::DestroyResources() { m_cursor_texture.reset(); } -bool HostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, u32 pitch) +bool GPUDevice::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, u32 pitch) { void* map_ptr; u32 map_pitch; @@ -49,7 +49,7 @@ bool HostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u3 return true; } -bool HostDisplay::ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height, float* refresh_rate) +bool GPUDevice::ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height, float* refresh_rate) { if (!mode.empty()) { @@ -95,23 +95,23 @@ bool HostDisplay::ParseFullscreenMode(const std::string_view& mode, u32* width, return false; } -std::string HostDisplay::GetFullscreenModeString(u32 width, u32 height, float refresh_rate) +std::string GPUDevice::GetFullscreenModeString(u32 width, u32 height, float refresh_rate) { return StringUtil::StdStringFromFormat("%u x %u @ %f hz", width, height, refresh_rate); } -bool HostDisplay::UsesLowerLeftOrigin() const +bool GPUDevice::UsesLowerLeftOrigin() const { const RenderAPI api = GetRenderAPI(); return (api == RenderAPI::OpenGL || api == RenderAPI::OpenGLES); } -void HostDisplay::SetDisplayMaxFPS(float max_fps) +void GPUDevice::SetDisplayMaxFPS(float max_fps) { m_display_frame_interval = (max_fps > 0.0f) ? (1.0f / max_fps) : 0.0f; } -bool HostDisplay::ShouldSkipDisplayingFrame() +bool GPUDevice::ShouldSkipDisplayingFrame() { if (m_display_frame_interval == 0.0f) return false; @@ -125,7 +125,7 @@ bool HostDisplay::ShouldSkipDisplayingFrame() return false; } -void HostDisplay::ThrottlePresentation() +void GPUDevice::ThrottlePresentation() { const float throttle_rate = (m_window_info.surface_refresh_rate > 0.0f) ? m_window_info.surface_refresh_rate : 60.0f; @@ -143,7 +143,7 @@ void HostDisplay::ThrottlePresentation() Common::Timer::SleepUntil(m_last_frame_displayed_time, false); } -bool HostDisplay::GetHostRefreshRate(float* refresh_rate) +bool GPUDevice::GetHostRefreshRate(float* refresh_rate) { if (m_window_info.surface_refresh_rate > 0.0f) { @@ -154,23 +154,23 @@ bool HostDisplay::GetHostRefreshRate(float* refresh_rate) return WindowInfo::QueryRefreshRateForWindow(m_window_info, refresh_rate); } -bool HostDisplay::SetGPUTimingEnabled(bool enabled) +bool GPUDevice::SetGPUTimingEnabled(bool enabled) { return false; } -float HostDisplay::GetAndResetAccumulatedGPUTime() +float GPUDevice::GetAndResetAccumulatedGPUTime() { return 0.0f; } -void HostDisplay::SetSoftwareCursor(std::unique_ptr texture, float scale /*= 1.0f*/) +void GPUDevice::SetSoftwareCursor(std::unique_ptr texture, float scale /*= 1.0f*/) { m_cursor_texture = std::move(texture); m_cursor_texture_scale = scale; } -bool HostDisplay::SetSoftwareCursor(const void* pixels, u32 width, u32 height, u32 stride, float scale /*= 1.0f*/) +bool GPUDevice::SetSoftwareCursor(const void* pixels, u32 width, u32 height, u32 stride, float scale /*= 1.0f*/) { std::unique_ptr tex = CreateTexture(width, height, 1, 1, 1, GPUTexture::Format::RGBA8, pixels, stride, false); @@ -181,7 +181,7 @@ bool HostDisplay::SetSoftwareCursor(const void* pixels, u32 width, u32 height, u return true; } -bool HostDisplay::SetSoftwareCursor(const char* path, float scale /*= 1.0f*/) +bool GPUDevice::SetSoftwareCursor(const char* path, float scale /*= 1.0f*/) { auto fp = FileSystem::OpenManagedCFile(path, "rb"); if (!fp) @@ -210,21 +210,20 @@ bool HostDisplay::SetSoftwareCursor(const char* path, float scale /*= 1.0f*/) return true; } -void HostDisplay::ClearSoftwareCursor() +void GPUDevice::ClearSoftwareCursor() { m_cursor_texture.reset(); m_cursor_texture_scale = 1.0f; } -bool HostDisplay::IsUsingLinearFiltering() const +bool GPUDevice::IsUsingLinearFiltering() const { return g_settings.display_linear_filtering; } -void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, float* out_left, float* out_top, - float* out_width, float* out_height, float* out_left_padding, - float* out_top_padding, float* out_scale, float* out_x_scale, - bool apply_aspect_ratio /* = true */) const +void GPUDevice::CalculateDrawRect(s32 window_width, s32 window_height, float* out_left, float* out_top, + float* out_width, float* out_height, float* out_left_padding, float* out_top_padding, + float* out_scale, float* out_x_scale, bool apply_aspect_ratio /* = true */) const { const float window_ratio = static_cast(window_width) / static_cast(window_height); const float display_aspect_ratio = g_settings.display_stretch ? window_ratio : m_display_aspect_ratio; @@ -329,8 +328,8 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, float* *out_scale = scale; } -std::tuple HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, - bool apply_aspect_ratio /* = true */) const +std::tuple GPUDevice::CalculateDrawRect(s32 window_width, s32 window_height, + bool apply_aspect_ratio /* = true */) const { float left, top, width, height, left_padding, top_padding; CalculateDrawRect(window_width, window_height, &left, &top, &width, &height, &left_padding, &top_padding, nullptr, @@ -340,12 +339,12 @@ std::tuple HostDisplay::CalculateDrawRect(s32 window_width, static_cast(width), static_cast(height)); } -std::tuple HostDisplay::CalculateSoftwareCursorDrawRect() const +std::tuple GPUDevice::CalculateSoftwareCursorDrawRect() const { return CalculateSoftwareCursorDrawRect(m_mouse_position_x, m_mouse_position_y); } -std::tuple HostDisplay::CalculateSoftwareCursorDrawRect(s32 cursor_x, s32 cursor_y) const +std::tuple GPUDevice::CalculateSoftwareCursorDrawRect(s32 cursor_x, s32 cursor_y) const { const float scale = m_window_info.surface_scale * m_cursor_texture_scale; const u32 cursor_extents_x = static_cast(static_cast(m_cursor_texture->GetWidth()) * scale * 0.5f); @@ -359,9 +358,9 @@ std::tuple HostDisplay::CalculateSoftwareCursorDrawRect(s32 return std::tie(out_left, out_top, out_width, out_height); } -std::tuple HostDisplay::ConvertWindowCoordinatesToDisplayCoordinates(s32 window_x, s32 window_y, - s32 window_width, - s32 window_height) const +std::tuple GPUDevice::ConvertWindowCoordinatesToDisplayCoordinates(s32 window_x, s32 window_y, + s32 window_width, + s32 window_height) const { float left, top, width, height, left_padding, top_padding; float scale, x_scale; @@ -454,10 +453,9 @@ static bool CompressAndWriteTextureToFile(u32 width, u32 height, std::string fil return true; } -bool HostDisplay::WriteTextureToFile(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, std::string filename, - bool clear_alpha /* = true */, bool flip_y /* = false */, - u32 resize_width /* = 0 */, u32 resize_height /* = 0 */, - bool compress_on_thread /* = false */) +bool GPUDevice::WriteTextureToFile(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, std::string filename, + bool clear_alpha /* = true */, bool flip_y /* = false */, u32 resize_width /* = 0 */, + u32 resize_height /* = 0 */, bool compress_on_thread /* = false */) { std::vector texture_data(width * height); u32 texture_data_stride = Common::AlignUpPow2(GPUTexture::GetPixelSize(texture->GetFormat()) * width, 4); @@ -488,8 +486,8 @@ bool HostDisplay::WriteTextureToFile(GPUTexture* texture, u32 x, u32 y, u32 widt return true; } -bool HostDisplay::WriteDisplayTextureToFile(std::string filename, bool full_resolution /* = true */, - bool apply_aspect_ratio /* = true */, bool compress_on_thread /* = false */) +bool GPUDevice::WriteDisplayTextureToFile(std::string filename, bool full_resolution /* = true */, + bool apply_aspect_ratio /* = true */, bool compress_on_thread /* = false */) { if (!m_display_texture) return false; @@ -540,8 +538,8 @@ bool HostDisplay::WriteDisplayTextureToFile(std::string filename, bool full_reso static_cast(resize_height), compress_on_thread); } -bool HostDisplay::WriteDisplayTextureToBuffer(std::vector* buffer, u32 resize_width /* = 0 */, - u32 resize_height /* = 0 */, bool clear_alpha /* = true */) +bool GPUDevice::WriteDisplayTextureToBuffer(std::vector* buffer, u32 resize_width /* = 0 */, + u32 resize_height /* = 0 */, bool clear_alpha /* = true */) { if (!m_display_texture) return false; @@ -618,8 +616,8 @@ bool HostDisplay::WriteDisplayTextureToBuffer(std::vector* buffer, u32 resi return true; } -bool HostDisplay::WriteScreenshotToFile(std::string filename, bool internal_resolution /* = false */, - bool compress_on_thread /* = false */) +bool GPUDevice::WriteScreenshotToFile(std::string filename, bool internal_resolution /* = false */, + bool compress_on_thread /* = false */) { u32 width = m_window_info.surface_width; u32 height = m_window_info.surface_height; diff --git a/src/core/host_display.h b/src/core/gpu/gpu_device.h similarity index 98% rename from src/core/host_display.h rename to src/core/gpu/gpu_device.h index cd23b93af..5ee6e23c2 100644 --- a/src/core/host_display.h +++ b/src/core/gpu/gpu_device.h @@ -2,10 +2,10 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "common/gpu_texture.h" #include "common/rectangle.h" +#include "common/types.h" #include "common/window_info.h" -#include "types.h" +#include "gpu_texture.h" #include #include #include @@ -23,7 +23,7 @@ enum class RenderAPI : u32 }; // Interface to the frontend's renderer. -class HostDisplay +class GPUDevice { public: struct AdapterAndModeList @@ -32,7 +32,7 @@ public: std::vector fullscreen_modes; }; - virtual ~HostDisplay(); + virtual ~GPUDevice(); /// Returns the default/preferred API for the system. static RenderAPI GetPreferredAPI(); @@ -252,10 +252,10 @@ protected: }; /// Returns a pointer to the current host display abstraction. Assumes AcquireHostDisplay() has been called. -extern std::unique_ptr g_host_display; +extern std::unique_ptr g_host_display; namespace Host { -std::unique_ptr CreateDisplayForAPI(RenderAPI api); +std::unique_ptr CreateDisplayForAPI(RenderAPI api); /// Creates the host display. This may create a new window. The API used depends on the current configuration. bool AcquireHostDisplay(RenderAPI api); diff --git a/src/common/gpu_texture.cpp b/src/core/gpu/gpu_texture.cpp similarity index 97% rename from src/common/gpu_texture.cpp rename to src/core/gpu/gpu_texture.cpp index 7744ff8b9..a8f6a96a2 100644 --- a/src/common/gpu_texture.cpp +++ b/src/core/gpu/gpu_texture.cpp @@ -1,9 +1,9 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "gpu_texture.h" -#include "log.h" -#include "string_util.h" +#include "common/log.h" +#include "common/string_util.h" Log_SetChannel(GPUTexture); GPUTexture::GPUTexture() = default; diff --git a/src/common/gpu_texture.h b/src/core/gpu/gpu_texture.h similarity index 98% rename from src/common/gpu_texture.h rename to src/core/gpu/gpu_texture.h index c63ab3301..528e127f8 100644 --- a/src/common/gpu_texture.h +++ b/src/core/gpu/gpu_texture.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "types.h" +#include "common/types.h" #include #include diff --git a/src/frontend-common/imgui_impl_dx11.cpp b/src/core/gpu/imgui_impl_dx11.cpp similarity index 99% rename from src/frontend-common/imgui_impl_dx11.cpp rename to src/core/gpu/imgui_impl_dx11.cpp index 3d8b0f7a6..244814c62 100644 --- a/src/frontend-common/imgui_impl_dx11.cpp +++ b/src/core/gpu/imgui_impl_dx11.cpp @@ -31,7 +31,7 @@ #include "imgui.h" #include "imgui_impl_dx11.h" -#include "common/d3d11/texture.h" +#include "d3d11/texture.h" // DirectX #include diff --git a/src/frontend-common/imgui_impl_dx11.h b/src/core/gpu/imgui_impl_dx11.h similarity index 100% rename from src/frontend-common/imgui_impl_dx11.h rename to src/core/gpu/imgui_impl_dx11.h diff --git a/src/frontend-common/imgui_impl_dx12.cpp b/src/core/gpu/imgui_impl_dx12.cpp similarity index 99% rename from src/frontend-common/imgui_impl_dx12.cpp rename to src/core/gpu/imgui_impl_dx12.cpp index f1e286eec..b6e69b9c2 100644 --- a/src/frontend-common/imgui_impl_dx12.cpp +++ b/src/core/gpu/imgui_impl_dx12.cpp @@ -40,9 +40,9 @@ #include "common/windows_headers.h" #include "common/assert.h" -#include "common/d3d12/context.h" -#include "common/d3d12/texture.h" -#include "common/d3d12/stream_buffer.h" +#include "d3d12/context.h" +#include "d3d12/texture.h" +#include "d3d12/stream_buffer.h" #include "imgui.h" #include "imgui_impl_dx12.h" diff --git a/src/frontend-common/imgui_impl_dx12.h b/src/core/gpu/imgui_impl_dx12.h similarity index 100% rename from src/frontend-common/imgui_impl_dx12.h rename to src/core/gpu/imgui_impl_dx12.h diff --git a/src/frontend-common/imgui_impl_opengl3.cpp b/src/core/gpu/imgui_impl_opengl3.cpp similarity index 99% rename from src/frontend-common/imgui_impl_opengl3.cpp rename to src/core/gpu/imgui_impl_opengl3.cpp index ab606b90f..eded12d93 100644 --- a/src/frontend-common/imgui_impl_opengl3.cpp +++ b/src/core/gpu/imgui_impl_opengl3.cpp @@ -104,8 +104,8 @@ #endif // GL includes -#include "common/gl/loader.h" -#include "common/gl/texture.h" +#include "gl/loader.h" +#include "gl/texture.h" #include "common/log.h" Log_SetChannel(ImGui_ImplOpenGL3); diff --git a/src/frontend-common/imgui_impl_opengl3.h b/src/core/gpu/imgui_impl_opengl3.h similarity index 100% rename from src/frontend-common/imgui_impl_opengl3.h rename to src/core/gpu/imgui_impl_opengl3.h diff --git a/src/frontend-common/imgui_impl_vulkan.cpp b/src/core/gpu/imgui_impl_vulkan.cpp similarity index 99% rename from src/frontend-common/imgui_impl_vulkan.cpp rename to src/core/gpu/imgui_impl_vulkan.cpp index 381e4a96c..a850a4a6b 100644 --- a/src/frontend-common/imgui_impl_vulkan.cpp +++ b/src/core/gpu/imgui_impl_vulkan.cpp @@ -63,11 +63,11 @@ #include "imgui_impl_vulkan.h" -#include "common/vulkan/builders.h" -#include "common/vulkan/context.h" -#include "common/vulkan/texture.h" -#include "common/vulkan/stream_buffer.h" -#include "common/vulkan/util.h" +#include "vulkan/builders.h" +#include "vulkan/context.h" +#include "vulkan/texture.h" +#include "vulkan/stream_buffer.h" +#include "vulkan/util.h" #include #include diff --git a/src/frontend-common/imgui_impl_vulkan.h b/src/core/gpu/imgui_impl_vulkan.h similarity index 92% rename from src/frontend-common/imgui_impl_vulkan.h rename to src/core/gpu/imgui_impl_vulkan.h index 5b4ecdb67..fe8efc6c8 100644 --- a/src/frontend-common/imgui_impl_vulkan.h +++ b/src/core/gpu/imgui_impl_vulkan.h @@ -3,7 +3,7 @@ #pragma once #include "imgui.h" // IMGUI_IMPL_API -#include "common/vulkan/loader.h" +#include "vulkan/loader.h" // Called by user code bool ImGui_ImplVulkan_Init(VkRenderPass render_pass); diff --git a/src/frontend-common/opengl_host_display.cpp b/src/core/gpu/opengl_gpu_device.cpp similarity index 88% rename from src/frontend-common/opengl_host_display.cpp rename to src/core/gpu/opengl_gpu_device.cpp index c058b56de..441ca6e6f 100644 --- a/src/frontend-common/opengl_host_display.cpp +++ b/src/core/gpu/opengl_gpu_device.cpp @@ -1,27 +1,27 @@ // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) -#include "opengl_host_display.h" +#include "opengl_gpu_device.h" +#include "../settings.h" #include "common/align.h" #include "common/assert.h" #include "common/log.h" #include "common/string_util.h" -#include "common_host.h" #include "imgui.h" #include "imgui_impl_opengl3.h" #include "postprocessing_shadergen.h" #include #include -Log_SetChannel(OpenGLHostDisplay); +Log_SetChannel(OpenGLGPUDevice); enum : u32 { TEXTURE_STREAM_BUFFER_SIZE = 16 * 1024 * 1024, }; -OpenGLHostDisplay::OpenGLHostDisplay() = default; +OpenGLGPUDevice::OpenGLGPUDevice() = default; -OpenGLHostDisplay::~OpenGLHostDisplay() +OpenGLGPUDevice::~OpenGLGPUDevice() { if (!m_gl_context) return; @@ -32,24 +32,24 @@ OpenGLHostDisplay::~OpenGLHostDisplay() m_gl_context.reset(); } -RenderAPI OpenGLHostDisplay::GetRenderAPI() const +RenderAPI OpenGLGPUDevice::GetRenderAPI() const { return m_gl_context->IsGLES() ? RenderAPI::OpenGLES : RenderAPI::OpenGL; } -void* OpenGLHostDisplay::GetDevice() const +void* OpenGLGPUDevice::GetDevice() const { return nullptr; } -void* OpenGLHostDisplay::GetContext() const +void* OpenGLGPUDevice::GetContext() const { return m_gl_context.get(); } -std::unique_ptr OpenGLHostDisplay::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, - GPUTexture::Format format, const void* data, - u32 data_stride, bool dynamic /* = false */) +std::unique_ptr OpenGLGPUDevice::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, + GPUTexture::Format format, const void* data, u32 data_stride, + bool dynamic /* = false */) { std::unique_ptr tex(std::make_unique()); if (!tex->Create(width, height, layers, levels, samples, format, data, data_stride)) @@ -58,8 +58,7 @@ std::unique_ptr OpenGLHostDisplay::CreateTexture(u32 width, u32 heig return tex; } -bool OpenGLHostDisplay::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, - u32* out_pitch) +bool OpenGLGPUDevice::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, u32* out_pitch) { const u32 pixel_size = texture->GetPixelSize(); const u32 stride = Common::AlignUpPow2(width * pixel_size, 4); @@ -86,7 +85,7 @@ bool OpenGLHostDisplay::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 h return true; } -void OpenGLHostDisplay::EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height) +void OpenGLGPUDevice::EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height) { const u32 pixel_size = texture->GetPixelSize(); const u32 stride = Common::AlignUpPow2(width * pixel_size, 4); @@ -127,8 +126,8 @@ void OpenGLHostDisplay::EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 } } -bool OpenGLHostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, - u32 pitch) +bool OpenGLGPUDevice::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, + u32 pitch) { GL::Texture* gl_texture = static_cast(texture); const auto [gl_internal_format, gl_format, gl_type] = GL::Texture::GetPixelFormatMapping(gl_texture->GetFormat()); @@ -173,8 +172,8 @@ bool OpenGLHostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 wid return true; } -bool OpenGLHostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, - u32 out_data_stride) +bool OpenGLGPUDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, + u32 out_data_stride) { GLint alignment; if (out_data_stride & 1) @@ -204,13 +203,13 @@ bool OpenGLHostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 w return true; } -bool OpenGLHostDisplay::SupportsTextureFormat(GPUTexture::Format format) const +bool OpenGLGPUDevice::SupportsTextureFormat(GPUTexture::Format format) const { const auto [gl_internal_format, gl_format, gl_type] = GL::Texture::GetPixelFormatMapping(format); return (gl_internal_format != static_cast(0)); } -void OpenGLHostDisplay::SetVSync(bool enabled) +void OpenGLGPUDevice::SetVSync(bool enabled) { if (m_vsync_enabled == enabled) return; @@ -219,7 +218,7 @@ void OpenGLHostDisplay::SetVSync(bool enabled) SetSwapInterval(); } -const char* OpenGLHostDisplay::GetGLSLVersionString() const +const char* OpenGLGPUDevice::GetGLSLVersionString() const { if (GetRenderAPI() == RenderAPI::OpenGLES) { @@ -237,7 +236,7 @@ const char* OpenGLHostDisplay::GetGLSLVersionString() const } } -std::string OpenGLHostDisplay::GetGLSLVersionHeader() const +std::string OpenGLGPUDevice::GetGLSLVersionHeader() const { std::string header = GetGLSLVersionString(); header += "\n\n"; @@ -270,17 +269,17 @@ static void APIENTRY GLDebugCallback(GLenum source, GLenum type, GLuint id, GLen } } -bool OpenGLHostDisplay::HasDevice() const +bool OpenGLGPUDevice::HasDevice() const { return static_cast(m_gl_context); } -bool OpenGLHostDisplay::HasSurface() const +bool OpenGLGPUDevice::HasSurface() const { return m_window_info.type != WindowInfo::Type::Surfaceless; } -bool OpenGLHostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) +bool OpenGLGPUDevice::CreateDevice(const WindowInfo& wi, bool vsync) { m_gl_context = GL::Context::Create(wi); if (!m_gl_context) @@ -295,7 +294,7 @@ bool OpenGLHostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) return true; } -bool OpenGLHostDisplay::SetupDevice() +bool OpenGLGPUDevice::SetupDevice() { // If we don't have GLES3.1, then SV_VertexID isn't defined when no VBOs are active. m_use_gles2_draw_path = (GetRenderAPI() == RenderAPI::OpenGLES && !GLAD_GL_ES_VERSION_3_1); @@ -332,7 +331,7 @@ bool OpenGLHostDisplay::SetupDevice() return true; } -bool OpenGLHostDisplay::MakeCurrent() +bool OpenGLGPUDevice::MakeCurrent() { if (!m_gl_context->MakeCurrent()) { @@ -344,12 +343,12 @@ bool OpenGLHostDisplay::MakeCurrent() return true; } -bool OpenGLHostDisplay::DoneCurrent() +bool OpenGLGPUDevice::DoneCurrent() { return m_gl_context->DoneCurrent(); } -bool OpenGLHostDisplay::ChangeWindow(const WindowInfo& new_wi) +bool OpenGLGPUDevice::ChangeWindow(const WindowInfo& new_wi) { Assert(m_gl_context); @@ -368,7 +367,7 @@ bool OpenGLHostDisplay::ChangeWindow(const WindowInfo& new_wi) return true; } -void OpenGLHostDisplay::ResizeWindow(s32 new_window_width, s32 new_window_height) +void OpenGLGPUDevice::ResizeWindow(s32 new_window_width, s32 new_window_height) { if (!m_gl_context) return; @@ -377,7 +376,7 @@ void OpenGLHostDisplay::ResizeWindow(s32 new_window_width, s32 new_window_height m_window_info = m_gl_context->GetWindowInfo(); } -void OpenGLHostDisplay::SetSwapInterval() +void OpenGLGPUDevice::SetSwapInterval() { if (m_window_info.type == WindowInfo::Type::Surfaceless) return; @@ -394,22 +393,22 @@ void OpenGLHostDisplay::SetSwapInterval() glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current_fbo); } -bool OpenGLHostDisplay::SupportsFullscreen() const +bool OpenGLGPUDevice::SupportsFullscreen() const { return false; } -bool OpenGLHostDisplay::IsFullscreen() +bool OpenGLGPUDevice::IsFullscreen() { return false; } -bool OpenGLHostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) +bool OpenGLGPUDevice::SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) { return false; } -HostDisplay::AdapterAndModeList OpenGLHostDisplay::GetAdapterAndModeList() +GPUDevice::AdapterAndModeList OpenGLGPUDevice::GetAdapterAndModeList() { AdapterAndModeList aml; @@ -424,7 +423,7 @@ HostDisplay::AdapterAndModeList OpenGLHostDisplay::GetAdapterAndModeList() return aml; } -void OpenGLHostDisplay::DestroySurface() +void OpenGLGPUDevice::DestroySurface() { if (!m_gl_context) return; @@ -434,23 +433,23 @@ void OpenGLHostDisplay::DestroySurface() Log_ErrorPrintf("Failed to switch to surfaceless"); } -bool OpenGLHostDisplay::CreateImGuiContext() +bool OpenGLGPUDevice::CreateImGuiContext() { return ImGui_ImplOpenGL3_Init(GetGLSLVersionString()); } -void OpenGLHostDisplay::DestroyImGuiContext() +void OpenGLGPUDevice::DestroyImGuiContext() { ImGui_ImplOpenGL3_Shutdown(); } -bool OpenGLHostDisplay::UpdateImGuiFontTexture() +bool OpenGLGPUDevice::UpdateImGuiFontTexture() { ImGui_ImplOpenGL3_DestroyFontsTexture(); return ImGui_ImplOpenGL3_CreateFontsTexture(); } -bool OpenGLHostDisplay::CreateResources() +bool OpenGLGPUDevice::CreateResources() { if (!m_use_gles2_draw_path) { @@ -615,9 +614,9 @@ void main() return true; } -void OpenGLHostDisplay::DestroyResources() +void OpenGLGPUDevice::DestroyResources() { - HostDisplay::DestroyResources(); + GPUDevice::DestroyResources(); m_post_processing_chain.ClearStages(); m_post_processing_input_texture.Destroy(); @@ -649,7 +648,7 @@ void OpenGLHostDisplay::DestroyResources() m_display_program.Destroy(); } -bool OpenGLHostDisplay::Render(bool skip_present) +bool OpenGLGPUDevice::Render(bool skip_present) { if (skip_present || m_window_info.type == WindowInfo::Type::Surfaceless) { @@ -680,8 +679,8 @@ bool OpenGLHostDisplay::Render(bool skip_present) return true; } -bool OpenGLHostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rectangle& draw_rect, - std::vector* out_pixels, u32* out_stride, GPUTexture::Format* out_format) +bool OpenGLGPUDevice::RenderScreenshot(u32 width, u32 height, const Common::Rectangle& draw_rect, + std::vector* out_pixels, u32* out_stride, GPUTexture::Format* out_format) { GL::Texture texture; if (!texture.Create(width, height, 1, 1, 1, GPUTexture::Format::RGBA8, nullptr, 0) || !texture.CreateFramebuffer()) @@ -723,14 +722,14 @@ bool OpenGLHostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Re return true; } -void OpenGLHostDisplay::RenderImGui() +void OpenGLGPUDevice::RenderImGui() { ImGui::Render(); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); GL::Program::ResetLastProgram(); } -void OpenGLHostDisplay::RenderDisplay() +void OpenGLGPUDevice::RenderDisplay() { const auto [left, top, width, height] = CalculateDrawRect(GetWindowWidth(), GetWindowHeight()); @@ -778,9 +777,9 @@ static void DrawFullscreenQuadES2(s32 tex_view_x, s32 tex_view_y, s32 tex_view_w glDisableVertexAttribArray(0); } -void OpenGLHostDisplay::RenderDisplay(s32 left, s32 bottom, s32 width, s32 height, GL::Texture* texture, - s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, - s32 texture_view_height, bool linear_filter) +void OpenGLGPUDevice::RenderDisplay(s32 left, s32 bottom, s32 width, s32 height, GL::Texture* texture, + s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, + s32 texture_view_height, bool linear_filter) { glViewport(left, bottom, width, height); glDisable(GL_BLEND); @@ -817,7 +816,7 @@ void OpenGLHostDisplay::RenderDisplay(s32 left, s32 bottom, s32 width, s32 heigh } } -void OpenGLHostDisplay::RenderSoftwareCursor() +void OpenGLGPUDevice::RenderSoftwareCursor() { if (!HasSoftwareCursor()) return; @@ -826,7 +825,7 @@ void OpenGLHostDisplay::RenderSoftwareCursor() RenderSoftwareCursor(left, GetWindowHeight() - top - height, width, height, m_cursor_texture.get()); } -void OpenGLHostDisplay::RenderSoftwareCursor(s32 left, s32 bottom, s32 width, s32 height, GPUTexture* texture_handle) +void OpenGLGPUDevice::RenderSoftwareCursor(s32 left, s32 bottom, s32 width, s32 height, GPUTexture* texture_handle) { glViewport(left, bottom, width, height); glEnable(GL_BLEND); @@ -854,7 +853,7 @@ void OpenGLHostDisplay::RenderSoftwareCursor(s32 left, s32 bottom, s32 width, s3 } } -bool OpenGLHostDisplay::SetPostProcessingChain(const std::string_view& config) +bool OpenGLGPUDevice::SetPostProcessingChain(const std::string_view& config) { if (config.empty()) { @@ -923,7 +922,7 @@ bool OpenGLHostDisplay::SetPostProcessingChain(const std::string_view& config) return true; } -bool OpenGLHostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 target_height) +bool OpenGLGPUDevice::CheckPostProcessingRenderTargets(u32 target_width, u32 target_height) { DebugAssert(!m_post_processing_stages.empty()); @@ -954,10 +953,10 @@ bool OpenGLHostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 t return true; } -void OpenGLHostDisplay::ApplyPostProcessingChain(GLuint final_target, s32 final_left, s32 final_top, s32 final_width, - s32 final_height, GL::Texture* texture, s32 texture_view_x, - s32 texture_view_y, s32 texture_view_width, s32 texture_view_height, - u32 target_width, u32 target_height) +void OpenGLGPUDevice::ApplyPostProcessingChain(GLuint final_target, s32 final_left, s32 final_top, s32 final_width, + s32 final_height, GL::Texture* texture, s32 texture_view_x, + s32 texture_view_y, s32 texture_view_width, s32 texture_view_height, + u32 target_width, u32 target_height) { if (!CheckPostProcessingRenderTargets(target_width, target_height)) { @@ -1013,7 +1012,7 @@ void OpenGLHostDisplay::ApplyPostProcessingChain(GLuint final_target, s32 final_ m_post_processing_ubo->Unbind(); } -void OpenGLHostDisplay::CreateTimestampQueries() +void OpenGLGPUDevice::CreateTimestampQueries() { const bool gles = m_gl_context->IsGLES(); const auto GenQueries = gles ? glGenQueriesEXT : glGenQueries; @@ -1022,7 +1021,7 @@ void OpenGLHostDisplay::CreateTimestampQueries() KickTimestampQuery(); } -void OpenGLHostDisplay::DestroyTimestampQueries() +void OpenGLGPUDevice::DestroyTimestampQueries() { if (m_timestamp_queries[0] == 0) return; @@ -1044,7 +1043,7 @@ void OpenGLHostDisplay::DestroyTimestampQueries() m_timestamp_query_started = false; } -void OpenGLHostDisplay::PopTimestampQuery() +void OpenGLGPUDevice::PopTimestampQuery() { const bool gles = m_gl_context->IsGLES(); @@ -1093,7 +1092,7 @@ void OpenGLHostDisplay::PopTimestampQuery() } } -void OpenGLHostDisplay::KickTimestampQuery() +void OpenGLGPUDevice::KickTimestampQuery() { if (m_timestamp_query_started || m_waiting_timestamp_queries == NUM_TIMESTAMP_QUERIES) return; @@ -1105,7 +1104,7 @@ void OpenGLHostDisplay::KickTimestampQuery() m_timestamp_query_started = true; } -bool OpenGLHostDisplay::SetGPUTimingEnabled(bool enabled) +bool OpenGLGPUDevice::SetGPUTimingEnabled(bool enabled) { if (m_gpu_timing_enabled == enabled) return true; @@ -1125,14 +1124,14 @@ bool OpenGLHostDisplay::SetGPUTimingEnabled(bool enabled) return true; } -float OpenGLHostDisplay::GetAndResetAccumulatedGPUTime() +float OpenGLGPUDevice::GetAndResetAccumulatedGPUTime() { const float value = m_accumulated_gpu_time; m_accumulated_gpu_time = 0.0f; return value; } -GL::StreamBuffer* OpenGLHostDisplay::GetTextureStreamBuffer() +GL::StreamBuffer* OpenGLGPUDevice::GetTextureStreamBuffer() { if (m_use_gles2_draw_path || m_texture_stream_buffer) return m_texture_stream_buffer.get(); diff --git a/src/frontend-common/opengl_host_display.h b/src/core/gpu/opengl_gpu_device.h similarity index 94% rename from src/frontend-common/opengl_host_display.h rename to src/core/gpu/opengl_gpu_device.h index 2cc21c120..e8d0a393e 100644 --- a/src/frontend-common/opengl_host_display.h +++ b/src/core/gpu/opengl_gpu_device.h @@ -2,22 +2,22 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "common/gl/context.h" -#include "common/gl/loader.h" -#include "common/gl/program.h" -#include "common/gl/stream_buffer.h" -#include "common/gl/texture.h" #include "common/timer.h" #include "common/window_info.h" -#include "core/host_display.h" +#include "gl/context.h" +#include "gl/loader.h" +#include "gl/program.h" +#include "gl/stream_buffer.h" +#include "gl/texture.h" +#include "gpu_device.h" #include "postprocessing_chain.h" #include -class OpenGLHostDisplay final : public HostDisplay +class OpenGLGPUDevice final : public GPUDevice { public: - OpenGLHostDisplay(); - ~OpenGLHostDisplay(); + OpenGLGPUDevice(); + ~OpenGLGPUDevice(); RenderAPI GetRenderAPI() const override; void* GetDevice() const override; diff --git a/src/frontend-common/postprocessing_chain.cpp b/src/core/gpu/postprocessing_chain.cpp similarity index 100% rename from src/frontend-common/postprocessing_chain.cpp rename to src/core/gpu/postprocessing_chain.cpp diff --git a/src/frontend-common/postprocessing_chain.h b/src/core/gpu/postprocessing_chain.h similarity index 100% rename from src/frontend-common/postprocessing_chain.h rename to src/core/gpu/postprocessing_chain.h diff --git a/src/frontend-common/postprocessing_shader.cpp b/src/core/gpu/postprocessing_shader.cpp similarity index 100% rename from src/frontend-common/postprocessing_shader.cpp rename to src/core/gpu/postprocessing_shader.cpp diff --git a/src/frontend-common/postprocessing_shader.h b/src/core/gpu/postprocessing_shader.h similarity index 100% rename from src/frontend-common/postprocessing_shader.h rename to src/core/gpu/postprocessing_shader.h diff --git a/src/frontend-common/postprocessing_shadergen.cpp b/src/core/gpu/postprocessing_shadergen.cpp similarity index 100% rename from src/frontend-common/postprocessing_shadergen.cpp rename to src/core/gpu/postprocessing_shadergen.cpp diff --git a/src/frontend-common/postprocessing_shadergen.h b/src/core/gpu/postprocessing_shadergen.h similarity index 100% rename from src/frontend-common/postprocessing_shadergen.h rename to src/core/gpu/postprocessing_shadergen.h diff --git a/src/common/vulkan/builders.cpp b/src/core/gpu/vulkan/builders.cpp similarity index 99% rename from src/common/vulkan/builders.cpp rename to src/core/gpu/vulkan/builders.cpp index 4efc5d001..5711e614e 100644 --- a/src/common/vulkan/builders.cpp +++ b/src/core/gpu/vulkan/builders.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "builders.h" -#include "../assert.h" +#include "common/assert.h" #include "util.h" namespace Vulkan { diff --git a/src/common/vulkan/builders.h b/src/core/gpu/vulkan/builders.h similarity index 99% rename from src/common/vulkan/builders.h rename to src/core/gpu/vulkan/builders.h index b2f6642d6..39f85abbb 100644 --- a/src/common/vulkan/builders.h +++ b/src/core/gpu/vulkan/builders.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../types.h" +#include "common/types.h" #include "loader.h" #include diff --git a/src/common/vulkan/context.cpp b/src/core/gpu/vulkan/context.cpp similarity index 99% rename from src/common/vulkan/context.cpp rename to src/core/gpu/vulkan/context.cpp index bcdb6669a..ab085612a 100644 --- a/src/common/vulkan/context.cpp +++ b/src/core/gpu/vulkan/context.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "context.h" -#include "../assert.h" -#include "../log.h" -#include "../string_util.h" -#include "../window_info.h" +#include "common/assert.h" +#include "common/log.h" +#include "common/string_util.h" +#include "common/window_info.h" #include "swap_chain.h" #include "util.h" #include diff --git a/src/common/vulkan/context.h b/src/core/gpu/vulkan/context.h similarity index 99% rename from src/common/vulkan/context.h rename to src/core/gpu/vulkan/context.h index bc9ebb872..1ae53e27f 100644 --- a/src/common/vulkan/context.h +++ b/src/core/gpu/vulkan/context.h @@ -3,7 +3,7 @@ #pragma once -#include "../types.h" +#include "common/types.h" #include "loader.h" #include "stream_buffer.h" #include diff --git a/src/common/vulkan/entry_points.h b/src/core/gpu/vulkan/entry_points.h similarity index 100% rename from src/common/vulkan/entry_points.h rename to src/core/gpu/vulkan/entry_points.h diff --git a/src/common/vulkan/entry_points.inl b/src/core/gpu/vulkan/entry_points.inl similarity index 100% rename from src/common/vulkan/entry_points.inl rename to src/core/gpu/vulkan/entry_points.inl diff --git a/src/common/vulkan/loader.cpp b/src/core/gpu/vulkan/loader.cpp similarity index 100% rename from src/common/vulkan/loader.cpp rename to src/core/gpu/vulkan/loader.cpp diff --git a/src/common/vulkan/loader.h b/src/core/gpu/vulkan/loader.h similarity index 98% rename from src/common/vulkan/loader.h rename to src/core/gpu/vulkan/loader.h index c6a6b4acd..3871f4860 100644 --- a/src/common/vulkan/loader.h +++ b/src/core/gpu/vulkan/loader.h @@ -10,7 +10,7 @@ #define VK_USE_PLATFORM_WIN32_KHR // vulkan.h pulls in windows.h on Windows, so we need to include our replacement header first -#include "../windows_headers.h" +#include "common/windows_headers.h" #endif diff --git a/src/common/vulkan/shader_cache.cpp b/src/core/gpu/vulkan/shader_cache.cpp similarity index 99% rename from src/common/vulkan/shader_cache.cpp rename to src/core/gpu/vulkan/shader_cache.cpp index 2ba6d8030..4ccfff866 100644 --- a/src/common/vulkan/shader_cache.cpp +++ b/src/core/gpu/vulkan/shader_cache.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "shader_cache.h" -#include "../assert.h" -#include "../file_system.h" -#include "../log.h" -#include "../md5_digest.h" +#include "common/assert.h" +#include "common/file_system.h" +#include "common/log.h" +#include "common/md5_digest.h" #include "context.h" #include "shader_compiler.h" #include "util.h" diff --git a/src/common/vulkan/shader_cache.h b/src/core/gpu/vulkan/shader_cache.h similarity index 98% rename from src/common/vulkan/shader_cache.h rename to src/core/gpu/vulkan/shader_cache.h index 8504b781e..7f645d6ac 100644 --- a/src/common/vulkan/shader_cache.h +++ b/src/core/gpu/vulkan/shader_cache.h @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "../hash_combine.h" -#include "../types.h" +#include "common/hash_combine.h" +#include "common/types.h" #include "loader.h" #include "shader_compiler.h" #include diff --git a/src/common/vulkan/shader_compiler.cpp b/src/core/gpu/vulkan/shader_compiler.cpp similarity index 97% rename from src/common/vulkan/shader_compiler.cpp rename to src/core/gpu/vulkan/shader_compiler.cpp index 664cb96b7..afdb4102b 100644 --- a/src/common/vulkan/shader_compiler.cpp +++ b/src/core/gpu/vulkan/shader_compiler.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "shader_compiler.h" -#include "../assert.h" -#include "../log.h" -#include "../string_util.h" +#include "common/assert.h" +#include "common/log.h" +#include "common/string_util.h" #include "util.h" #include #include @@ -122,7 +122,7 @@ bool InitializeGlslang() return false; } - std::atexit([]() { glslang::FinalizeProcess(); }); + std::atexit(DeinitializeGlslang); glslang_initialized = true; return true; diff --git a/src/common/vulkan/shader_compiler.h b/src/core/gpu/vulkan/shader_compiler.h similarity index 97% rename from src/common/vulkan/shader_compiler.h rename to src/core/gpu/vulkan/shader_compiler.h index 8537a63ea..57b91cc6d 100644 --- a/src/common/vulkan/shader_compiler.h +++ b/src/core/gpu/vulkan/shader_compiler.h @@ -3,7 +3,7 @@ #pragma once -#include "../types.h" +#include "common/types.h" #include #include #include diff --git a/src/common/vulkan/stream_buffer.cpp b/src/core/gpu/vulkan/stream_buffer.cpp similarity index 99% rename from src/common/vulkan/stream_buffer.cpp rename to src/core/gpu/vulkan/stream_buffer.cpp index 387ab1f44..5b505aa32 100644 --- a/src/common/vulkan/stream_buffer.cpp +++ b/src/core/gpu/vulkan/stream_buffer.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "stream_buffer.h" -#include "../align.h" -#include "../assert.h" -#include "../log.h" +#include "common/align.h" +#include "common/assert.h" +#include "common/log.h" #include "context.h" #include "util.h" Log_SetChannel(Vulkan::StreamBuffer); diff --git a/src/common/vulkan/stream_buffer.h b/src/core/gpu/vulkan/stream_buffer.h similarity index 98% rename from src/common/vulkan/stream_buffer.h rename to src/core/gpu/vulkan/stream_buffer.h index cdff9a7b4..6714b2491 100644 --- a/src/common/vulkan/stream_buffer.h +++ b/src/core/gpu/vulkan/stream_buffer.h @@ -3,7 +3,7 @@ #pragma once -#include "../types.h" +#include "common/types.h" #include "loader.h" #include #include diff --git a/src/common/vulkan/swap_chain.cpp b/src/core/gpu/vulkan/swap_chain.cpp similarity index 99% rename from src/common/vulkan/swap_chain.cpp rename to src/core/gpu/vulkan/swap_chain.cpp index d9a54e0dd..98d48eadf 100644 --- a/src/common/vulkan/swap_chain.cpp +++ b/src/core/gpu/vulkan/swap_chain.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "swap_chain.h" -#include "../assert.h" -#include "../log.h" +#include "common/assert.h" +#include "common/log.h" #include "context.h" #include "util.h" #include diff --git a/src/common/vulkan/swap_chain.h b/src/core/gpu/vulkan/swap_chain.h similarity index 98% rename from src/common/vulkan/swap_chain.h rename to src/core/gpu/vulkan/swap_chain.h index c7ef1c99e..46fd3f82b 100644 --- a/src/common/vulkan/swap_chain.h +++ b/src/core/gpu/vulkan/swap_chain.h @@ -3,8 +3,8 @@ #pragma once -#include "../types.h" -#include "../window_info.h" +#include "common/types.h" +#include "common/window_info.h" #include "texture.h" #include "loader.h" #include diff --git a/src/common/vulkan/texture.cpp b/src/core/gpu/vulkan/texture.cpp similarity index 99% rename from src/common/vulkan/texture.cpp rename to src/core/gpu/vulkan/texture.cpp index 82f57fb32..6db622453 100644 --- a/src/common/vulkan/texture.cpp +++ b/src/core/gpu/vulkan/texture.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "texture.h" -#include "../align.h" -#include "../assert.h" -#include "../log.h" -#include "../string_util.h" +#include "common/align.h" +#include "common/assert.h" +#include "common/log.h" +#include "common/string_util.h" #include "context.h" #include "util.h" #include diff --git a/src/common/vulkan/texture.h b/src/core/gpu/vulkan/texture.h similarity index 100% rename from src/common/vulkan/texture.h rename to src/core/gpu/vulkan/texture.h diff --git a/src/common/vulkan/util.cpp b/src/core/gpu/vulkan/util.cpp similarity index 99% rename from src/common/vulkan/util.cpp rename to src/core/gpu/vulkan/util.cpp index 75690fb50..2102cfde2 100644 --- a/src/common/vulkan/util.cpp +++ b/src/core/gpu/vulkan/util.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "util.h" -#include "../assert.h" -#include "../log.h" -#include "../string_util.h" +#include "common/assert.h" +#include "common/log.h" +#include "common/string_util.h" #include "context.h" #include "shader_compiler.h" diff --git a/src/common/vulkan/util.h b/src/core/gpu/vulkan/util.h similarity index 99% rename from src/common/vulkan/util.h rename to src/core/gpu/vulkan/util.h index 8e06be421..63f8c7f2b 100644 --- a/src/common/vulkan/util.h +++ b/src/core/gpu/vulkan/util.h @@ -3,8 +3,8 @@ #pragma once -#include "../string.h" -#include "../types.h" +#include "common/string.h" +#include "common/types.h" #include "context.h" #include "loader.h" #include diff --git a/src/frontend-common/vulkan_host_display.cpp b/src/core/gpu/vulkan_gpu_device.cpp similarity index 90% rename from src/frontend-common/vulkan_host_display.cpp rename to src/core/gpu/vulkan_gpu_device.cpp index aa0eade9f..fca577b43 100644 --- a/src/frontend-common/vulkan_host_display.cpp +++ b/src/core/gpu/vulkan_gpu_device.cpp @@ -1,29 +1,29 @@ // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) -#include "vulkan_host_display.h" +#include "vulkan_gpu_device.h" +#include "../settings.h" +#include "../shader_cache_version.h" #include "common/align.h" #include "common/assert.h" #include "common/log.h" #include "common/scoped_guard.h" #include "common/string_util.h" -#include "common/vulkan/builders.h" -#include "common/vulkan/context.h" -#include "common/vulkan/shader_cache.h" -#include "common/vulkan/stream_buffer.h" -#include "common/vulkan/swap_chain.h" -#include "common/vulkan/util.h" -#include "common_host.h" -#include "core/shader_cache_version.h" #include "imgui.h" #include "imgui_impl_vulkan.h" #include "postprocessing_shadergen.h" +#include "vulkan/builders.h" +#include "vulkan/context.h" +#include "vulkan/shader_cache.h" +#include "vulkan/stream_buffer.h" +#include "vulkan/swap_chain.h" +#include "vulkan/util.h" #include -Log_SetChannel(VulkanHostDisplay); +Log_SetChannel(VulkanGPUDevice); -VulkanHostDisplay::VulkanHostDisplay() = default; +VulkanGPUDevice::VulkanGPUDevice() = default; -VulkanHostDisplay::~VulkanHostDisplay() +VulkanGPUDevice::~VulkanGPUDevice() { if (!g_vulkan_context) return; @@ -41,22 +41,22 @@ VulkanHostDisplay::~VulkanHostDisplay() AssertMsg(!m_swap_chain, "Swap chain should have been destroyed by now"); } -RenderAPI VulkanHostDisplay::GetRenderAPI() const +RenderAPI VulkanGPUDevice::GetRenderAPI() const { return RenderAPI::Vulkan; } -void* VulkanHostDisplay::GetDevice() const +void* VulkanGPUDevice::GetDevice() const { return nullptr; } -void* VulkanHostDisplay::GetContext() const +void* VulkanGPUDevice::GetContext() const { return nullptr; } -bool VulkanHostDisplay::ChangeWindow(const WindowInfo& new_wi) +bool VulkanGPUDevice::ChangeWindow(const WindowInfo& new_wi) { g_vulkan_context->WaitForGPUIdle(); @@ -102,7 +102,7 @@ bool VulkanHostDisplay::ChangeWindow(const WindowInfo& new_wi) return true; } -void VulkanHostDisplay::ResizeWindow(s32 new_window_width, s32 new_window_height) +void VulkanGPUDevice::ResizeWindow(s32 new_window_width, s32 new_window_height) { g_vulkan_context->WaitForGPUIdle(); @@ -113,36 +113,36 @@ void VulkanHostDisplay::ResizeWindow(s32 new_window_width, s32 new_window_height m_vsync_enabled = m_swap_chain->IsVSyncEnabled(); } -bool VulkanHostDisplay::SupportsFullscreen() const +bool VulkanGPUDevice::SupportsFullscreen() const { return false; } -bool VulkanHostDisplay::IsFullscreen() +bool VulkanGPUDevice::IsFullscreen() { return false; } -bool VulkanHostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) +bool VulkanGPUDevice::SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) { return false; } -HostDisplay::AdapterAndModeList VulkanHostDisplay::GetAdapterAndModeList() +GPUDevice::AdapterAndModeList VulkanGPUDevice::GetAdapterAndModeList() { return StaticGetAdapterAndModeList(m_window_info.type != WindowInfo::Type::Surfaceless ? &m_window_info : nullptr); } -void VulkanHostDisplay::DestroySurface() +void VulkanGPUDevice::DestroySurface() { m_window_info.SetSurfaceless(); g_vulkan_context->WaitForGPUIdle(); m_swap_chain.reset(); } -std::unique_ptr VulkanHostDisplay::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, - GPUTexture::Format format, const void* data, - u32 data_stride, bool dynamic /* = false */) +std::unique_ptr VulkanGPUDevice::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, + GPUTexture::Format format, const void* data, u32 data_stride, + bool dynamic /* = false */) { const VkFormat vk_format = Vulkan::Texture::GetVkFormat(format); if (vk_format == VK_FORMAT_UNDEFINED) @@ -179,24 +179,23 @@ std::unique_ptr VulkanHostDisplay::CreateTexture(u32 width, u32 heig return texture; } -bool VulkanHostDisplay::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, - u32* out_pitch) +bool VulkanGPUDevice::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, u32* out_pitch) { return static_cast(texture)->BeginUpdate(width, height, out_buffer, out_pitch); } -void VulkanHostDisplay::EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height) +void VulkanGPUDevice::EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height) { static_cast(texture)->EndUpdate(x, y, width, height, 0, 0); } -bool VulkanHostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, - u32 pitch) +bool VulkanGPUDevice::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, + u32 pitch) { return static_cast(texture)->Update(x, y, width, height, 0, 0, data, pitch); } -bool VulkanHostDisplay::SupportsTextureFormat(GPUTexture::Format format) const +bool VulkanGPUDevice::SupportsTextureFormat(GPUTexture::Format format) const { const VkFormat vk_format = Vulkan::Texture::GetVkFormat(format); if (vk_format == VK_FORMAT_UNDEFINED) @@ -209,7 +208,7 @@ bool VulkanHostDisplay::SupportsTextureFormat(GPUTexture::Format format) const return ((fp.optimalTilingFeatures & required) == required); } -void VulkanHostDisplay::SetVSync(bool enabled) +void VulkanGPUDevice::SetVSync(bool enabled) { if (!m_swap_chain || m_swap_chain->IsVSyncEnabled() == enabled) return; @@ -220,7 +219,7 @@ void VulkanHostDisplay::SetVSync(bool enabled) m_vsync_enabled = m_swap_chain->IsVSyncEnabled(); } -bool VulkanHostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) +bool VulkanGPUDevice::CreateDevice(const WindowInfo& wi, bool vsync) { WindowInfo local_wi(wi); bool result = @@ -252,7 +251,7 @@ bool VulkanHostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) return true; } -bool VulkanHostDisplay::SetupDevice() +bool VulkanGPUDevice::SetupDevice() { if (!CreateResources()) return false; @@ -260,17 +259,17 @@ bool VulkanHostDisplay::SetupDevice() return true; } -bool VulkanHostDisplay::HasDevice() const +bool VulkanGPUDevice::HasDevice() const { return static_cast(g_vulkan_context); } -bool VulkanHostDisplay::HasSurface() const +bool VulkanGPUDevice::HasSurface() const { return static_cast(m_swap_chain); } -VkRenderPass VulkanHostDisplay::GetRenderPassForDisplay() const +VkRenderPass VulkanGPUDevice::GetRenderPassForDisplay() const { if (m_swap_chain) { @@ -284,7 +283,7 @@ VkRenderPass VulkanHostDisplay::GetRenderPassForDisplay() const } } -void VulkanHostDisplay::DestroyStagingBuffer() +void VulkanGPUDevice::DestroyStagingBuffer() { if (m_readback_staging_buffer == VK_NULL_HANDLE) return; @@ -298,8 +297,8 @@ void VulkanHostDisplay::DestroyStagingBuffer() m_readback_staging_buffer_size = 0; } -bool VulkanHostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, - u32 out_data_stride) +bool VulkanGPUDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, + u32 out_data_stride) { Vulkan::Texture* tex = static_cast(texture); @@ -364,7 +363,7 @@ bool VulkanHostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 w return true; } -bool VulkanHostDisplay::CheckStagingBufferSize(u32 required_size) +bool VulkanGPUDevice::CheckStagingBufferSize(u32 required_size) { if (m_readback_staging_buffer_size >= required_size) return true; @@ -399,7 +398,7 @@ bool VulkanHostDisplay::CheckStagingBufferSize(u32 required_size) return true; } -bool VulkanHostDisplay::CreateResources() +bool VulkanGPUDevice::CreateResources() { static constexpr char fullscreen_quad_vertex_shader[] = R"( #version 450 core @@ -543,9 +542,9 @@ void main() return true; } -void VulkanHostDisplay::DestroyResources() +void VulkanGPUDevice::DestroyResources() { - HostDisplay::DestroyResources(); + GPUDevice::DestroyResources(); Vulkan::Util::SafeDestroyPipelineLayout(m_post_process_pipeline_layout); Vulkan::Util::SafeDestroyPipelineLayout(m_post_process_ubo_pipeline_layout); @@ -566,7 +565,7 @@ void VulkanHostDisplay::DestroyResources() Vulkan::Util::SafeDestroySampler(m_linear_sampler); } -bool VulkanHostDisplay::CreateImGuiContext() +bool VulkanGPUDevice::CreateImGuiContext() { const VkRenderPass render_pass = m_swap_chain ? m_swap_chain->GetClearRenderPass() : @@ -578,30 +577,30 @@ bool VulkanHostDisplay::CreateImGuiContext() return ImGui_ImplVulkan_Init(render_pass); } -void VulkanHostDisplay::DestroyImGuiContext() +void VulkanGPUDevice::DestroyImGuiContext() { g_vulkan_context->WaitForGPUIdle(); ImGui_ImplVulkan_Shutdown(); } -bool VulkanHostDisplay::UpdateImGuiFontTexture() +bool VulkanGPUDevice::UpdateImGuiFontTexture() { // Just in case we were drawing something. g_vulkan_context->ExecuteCommandBuffer(true); return ImGui_ImplVulkan_CreateFontsTexture(); } -bool VulkanHostDisplay::MakeCurrent() +bool VulkanGPUDevice::MakeCurrent() { return true; } -bool VulkanHostDisplay::DoneCurrent() +bool VulkanGPUDevice::DoneCurrent() { return true; } -bool VulkanHostDisplay::Render(bool skip_present) +bool VulkanGPUDevice::Render(bool skip_present) { if (skip_present || !m_swap_chain) { @@ -677,8 +676,8 @@ bool VulkanHostDisplay::Render(bool skip_present) return true; } -bool VulkanHostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rectangle& draw_rect, - std::vector* out_pixels, u32* out_stride, GPUTexture::Format* out_format) +bool VulkanGPUDevice::RenderScreenshot(u32 width, u32 height, const Common::Rectangle& draw_rect, + std::vector* out_pixels, u32* out_stride, GPUTexture::Format* out_format) { // in theory we could do this without a swap chain, but postprocessing assumes it for now... if (!m_swap_chain) @@ -773,7 +772,7 @@ bool VulkanHostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Re return true; } -void VulkanHostDisplay::BeginSwapChainRenderPass(VkFramebuffer framebuffer, u32 width, u32 height) +void VulkanGPUDevice::BeginSwapChainRenderPass(VkFramebuffer framebuffer, u32 width, u32 height) { const VkClearValue clear_value = {{{0.0f, 0.0f, 0.0f, 1.0f}}}; const VkRenderPassBeginInfo rp = {VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, @@ -788,7 +787,7 @@ void VulkanHostDisplay::BeginSwapChainRenderPass(VkFramebuffer framebuffer, u32 vkCmdBeginRenderPass(g_vulkan_context->GetCurrentCommandBuffer(), &rp, VK_SUBPASS_CONTENTS_INLINE); } -void VulkanHostDisplay::RenderDisplay() +void VulkanGPUDevice::RenderDisplay() { const Vulkan::Util::DebugScope debugScope(g_vulkan_context->GetCurrentCommandBuffer(), "VulkanHostDisplay::RenderDisplay"); @@ -816,9 +815,9 @@ void VulkanHostDisplay::RenderDisplay() IsUsingLinearFiltering()); } -void VulkanHostDisplay::RenderDisplay(s32 left, s32 top, s32 width, s32 height, Vulkan::Texture* texture, - s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, - s32 texture_view_height, bool linear_filter) +void VulkanGPUDevice::RenderDisplay(s32 left, s32 top, s32 width, s32 height, Vulkan::Texture* texture, + s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, + s32 texture_view_height, bool linear_filter) { VkCommandBuffer cmdbuffer = g_vulkan_context->GetCurrentCommandBuffer(); const Vulkan::Util::DebugScope debugScope( @@ -854,14 +853,14 @@ void VulkanHostDisplay::RenderDisplay(s32 left, s32 top, s32 width, s32 height, vkCmdDraw(cmdbuffer, 3, 1, 0, 0); } -void VulkanHostDisplay::RenderImGui() +void VulkanGPUDevice::RenderImGui() { const Vulkan::Util::DebugScope debugScope(g_vulkan_context->GetCurrentCommandBuffer(), "Imgui"); ImGui::Render(); ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData()); } -void VulkanHostDisplay::RenderSoftwareCursor() +void VulkanGPUDevice::RenderSoftwareCursor() { if (!HasSoftwareCursor()) return; @@ -870,7 +869,7 @@ void VulkanHostDisplay::RenderSoftwareCursor() RenderSoftwareCursor(left, top, width, height, m_cursor_texture.get()); } -void VulkanHostDisplay::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 height, GPUTexture* texture) +void VulkanGPUDevice::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 height, GPUTexture* texture) { VkCommandBuffer cmdbuffer = g_vulkan_context->GetCurrentCommandBuffer(); const Vulkan::Util::DebugScope debugScope(cmdbuffer, "VulkanHostDisplay::RenderSoftwareCursor: {%u,%u} %ux%u", left, @@ -898,7 +897,7 @@ void VulkanHostDisplay::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 h vkCmdDraw(cmdbuffer, 3, 1, 0, 0); } -bool VulkanHostDisplay::SetGPUTimingEnabled(bool enabled) +bool VulkanGPUDevice::SetGPUTimingEnabled(bool enabled) { if (g_vulkan_context->SetEnableGPUTiming(enabled)) { @@ -909,12 +908,12 @@ bool VulkanHostDisplay::SetGPUTimingEnabled(bool enabled) return false; } -float VulkanHostDisplay::GetAndResetAccumulatedGPUTime() +float VulkanGPUDevice::GetAndResetAccumulatedGPUTime() { return g_vulkan_context->GetAndResetAccumulatedGPUTime(); } -HostDisplay::AdapterAndModeList VulkanHostDisplay::StaticGetAdapterAndModeList(const WindowInfo* wi) +GPUDevice::AdapterAndModeList VulkanGPUDevice::StaticGetAdapterAndModeList(const WindowInfo* wi) { AdapterAndModeList ret; std::vector fsmodes; @@ -954,7 +953,7 @@ HostDisplay::AdapterAndModeList VulkanHostDisplay::StaticGetAdapterAndModeList(c return ret; } -VulkanHostDisplay::PostProcessingStage::PostProcessingStage(PostProcessingStage&& move) +VulkanGPUDevice::PostProcessingStage::PostProcessingStage(PostProcessingStage&& move) : pipeline(move.pipeline), output_framebuffer(move.output_framebuffer), output_texture(std::move(move.output_texture)), uniforms_size(move.uniforms_size) { @@ -963,7 +962,7 @@ VulkanHostDisplay::PostProcessingStage::PostProcessingStage(PostProcessingStage& move.uniforms_size = 0; } -VulkanHostDisplay::PostProcessingStage::~PostProcessingStage() +VulkanGPUDevice::PostProcessingStage::~PostProcessingStage() { if (output_framebuffer != VK_NULL_HANDLE) g_vulkan_context->DeferFramebufferDestruction(output_framebuffer); @@ -973,7 +972,7 @@ VulkanHostDisplay::PostProcessingStage::~PostProcessingStage() g_vulkan_context->DeferPipelineDestruction(pipeline); } -bool VulkanHostDisplay::SetPostProcessingChain(const std::string_view& config) +bool VulkanGPUDevice::SetPostProcessingChain(const std::string_view& config) { g_vulkan_context->ExecuteCommandBuffer(true); @@ -1061,7 +1060,7 @@ bool VulkanHostDisplay::SetPostProcessingChain(const std::string_view& config) return true; } -bool VulkanHostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 target_height) +bool VulkanGPUDevice::CheckPostProcessingRenderTargets(u32 target_width, u32 target_height) { DebugAssert(!m_post_processing_stages.empty()); @@ -1121,10 +1120,10 @@ bool VulkanHostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 t return true; } -void VulkanHostDisplay::ApplyPostProcessingChain(VkFramebuffer target_fb, s32 final_left, s32 final_top, - s32 final_width, s32 final_height, Vulkan::Texture* texture, - s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, - s32 texture_view_height, u32 target_width, u32 target_height) +void VulkanGPUDevice::ApplyPostProcessingChain(VkFramebuffer target_fb, s32 final_left, s32 final_top, s32 final_width, + s32 final_height, Vulkan::Texture* texture, s32 texture_view_x, + s32 texture_view_y, s32 texture_view_width, s32 texture_view_height, + u32 target_width, u32 target_height) { VkCommandBuffer cmdbuffer = g_vulkan_context->GetCurrentCommandBuffer(); const Vulkan::Util::DebugScope post_scope(cmdbuffer, "VulkanHostDisplay::ApplyPostProcessingChain"); diff --git a/src/frontend-common/vulkan_host_display.h b/src/core/gpu/vulkan_gpu_device.h similarity index 95% rename from src/frontend-common/vulkan_host_display.h rename to src/core/gpu/vulkan_gpu_device.h index 1da6c500a..4bf761360 100644 --- a/src/frontend-common/vulkan_host_display.h +++ b/src/core/gpu/vulkan_gpu_device.h @@ -3,12 +3,12 @@ #pragma once #include "common/timer.h" -#include "common/vulkan/loader.h" -#include "common/vulkan/stream_buffer.h" -#include "common/vulkan/swap_chain.h" #include "common/window_info.h" -#include "core/host_display.h" +#include "gpu_device.h" #include "postprocessing_chain.h" +#include "vulkan/loader.h" +#include "vulkan/stream_buffer.h" +#include "vulkan/swap_chain.h" #include #include @@ -17,11 +17,11 @@ class StreamBuffer; class SwapChain; } // namespace Vulkan -class VulkanHostDisplay final : public HostDisplay +class VulkanGPUDevice final : public GPUDevice { public: - VulkanHostDisplay(); - ~VulkanHostDisplay(); + VulkanGPUDevice(); + ~VulkanGPUDevice(); RenderAPI GetRenderAPI() const override; void* GetDevice() const override; diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index c4f399dff..56eae26db 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -4,7 +4,7 @@ #pragma once #include "common/heap_array.h" #include "gpu.h" -#include "host_display.h" +#include "gpu/gpu_device.h" #include #include #include diff --git a/src/core/gpu_hw_d3d11.cpp b/src/core/gpu_hw_d3d11.cpp index fa7a17ccc..5ee00f38c 100644 --- a/src/core/gpu_hw_d3d11.cpp +++ b/src/core/gpu_hw_d3d11.cpp @@ -3,12 +3,12 @@ #include "gpu_hw_d3d11.h" #include "common/assert.h" -#include "common/d3d11/shader_compiler.h" #include "common/log.h" #include "common/timer.h" +#include "gpu/d3d11/shader_compiler.h" +#include "gpu/gpu_device.h" #include "gpu_hw_shadergen.h" #include "gpu_sw_backend.h" -#include "host_display.h" #include "shader_cache_version.h" #include "system.h" #include "util/state_wrapper.h" diff --git a/src/core/gpu_hw_d3d11.h b/src/core/gpu_hw_d3d11.h index 0a6f7533d..d1f35aa2a 100644 --- a/src/core/gpu_hw_d3d11.h +++ b/src/core/gpu_hw_d3d11.h @@ -2,9 +2,9 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "common/d3d11/shader_cache.h" -#include "common/d3d11/stream_buffer.h" -#include "common/d3d11/texture.h" +#include "gpu/d3d11/shader_cache.h" +#include "gpu/d3d11/stream_buffer.h" +#include "gpu/d3d11/texture.h" #include "gpu_hw.h" #include "texture_replacements.h" #include @@ -123,7 +123,7 @@ private: ComPtr m_screen_quad_vertex_shader; ComPtr m_uv_quad_vertex_shader; ComPtr m_copy_pixel_shader; - std::array, 2>, 2> m_vram_fill_pixel_shaders; // [wrapped][interlaced] + std::array, 2>, 2> m_vram_fill_pixel_shaders; // [wrapped][interlaced] ComPtr m_vram_read_pixel_shader; ComPtr m_vram_write_pixel_shader; ComPtr m_vram_copy_pixel_shader; diff --git a/src/core/gpu_hw_d3d12.cpp b/src/core/gpu_hw_d3d12.cpp index 533d674e9..987712443 100644 --- a/src/core/gpu_hw_d3d12.cpp +++ b/src/core/gpu_hw_d3d12.cpp @@ -4,16 +4,16 @@ #include "gpu_hw_d3d12.h" #include "common/align.h" #include "common/assert.h" -#include "common/d3d11/shader_compiler.h" -#include "common/d3d12/context.h" -#include "common/d3d12/descriptor_heap_manager.h" -#include "common/d3d12/shader_cache.h" -#include "common/d3d12/util.h" #include "common/log.h" #include "common/scoped_guard.h" #include "common/timer.h" +#include "gpu/d3d11/shader_compiler.h" +#include "gpu/d3d12/context.h" +#include "gpu/d3d12/descriptor_heap_manager.h" +#include "gpu/d3d12/shader_cache.h" +#include "gpu/d3d12/util.h" +#include "gpu/gpu_device.h" #include "gpu_hw_shadergen.h" -#include "host_display.h" #include "system.h" Log_SetChannel(GPU_HW_D3D12); diff --git a/src/core/gpu_hw_d3d12.h b/src/core/gpu_hw_d3d12.h index 88cf60e8e..292dfc608 100644 --- a/src/core/gpu_hw_d3d12.h +++ b/src/core/gpu_hw_d3d12.h @@ -2,10 +2,10 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "common/d3d12/staging_texture.h" -#include "common/d3d12/stream_buffer.h" -#include "common/d3d12/texture.h" #include "common/dimensional_array.h" +#include "gpu/d3d12/staging_texture.h" +#include "gpu/d3d12/stream_buffer.h" +#include "gpu/d3d12/texture.h" #include "gpu_hw.h" #include "texture_replacements.h" #include diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 214307a25..d2d8fffdf 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -5,9 +5,9 @@ #include "common/assert.h" #include "common/log.h" #include "common/timer.h" +#include "gpu/gpu_device.h" #include "gpu_hw_shadergen.h" #include "host.h" -#include "host_display.h" #include "shader_cache_version.h" #include "system.h" #include "texture_replacements.h" diff --git a/src/core/gpu_hw_opengl.h b/src/core/gpu_hw_opengl.h index b7a091bfc..31031db24 100644 --- a/src/core/gpu_hw_opengl.h +++ b/src/core/gpu_hw_opengl.h @@ -2,11 +2,11 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "common/gl/loader.h" -#include "common/gl/program.h" -#include "common/gl/shader_cache.h" -#include "common/gl/stream_buffer.h" -#include "common/gl/texture.h" +#include "gpu/gl/loader.h" +#include "gpu/gl/program.h" +#include "gpu/gl/shader_cache.h" +#include "gpu/gl/stream_buffer.h" +#include "gpu/gl/texture.h" #include "gpu_hw.h" #include "texture_replacements.h" #include diff --git a/src/core/gpu_hw_vulkan.cpp b/src/core/gpu_hw_vulkan.cpp index 8a2137f01..68168e4f1 100644 --- a/src/core/gpu_hw_vulkan.cpp +++ b/src/core/gpu_hw_vulkan.cpp @@ -6,12 +6,12 @@ #include "common/log.h" #include "common/scoped_guard.h" #include "common/timer.h" -#include "common/vulkan/builders.h" -#include "common/vulkan/context.h" -#include "common/vulkan/shader_cache.h" -#include "common/vulkan/util.h" +#include "gpu/gpu_device.h" +#include "gpu/vulkan/builders.h" +#include "gpu/vulkan/context.h" +#include "gpu/vulkan/shader_cache.h" +#include "gpu/vulkan/util.h" #include "gpu_hw_shadergen.h" -#include "host_display.h" #include "system.h" #include "util/state_wrapper.h" Log_SetChannel(GPU_HW_Vulkan); diff --git a/src/core/gpu_hw_vulkan.h b/src/core/gpu_hw_vulkan.h index fbb8200c4..c90c610c0 100644 --- a/src/core/gpu_hw_vulkan.h +++ b/src/core/gpu_hw_vulkan.h @@ -3,8 +3,8 @@ #pragma once #include "common/dimensional_array.h" -#include "common/vulkan/stream_buffer.h" -#include "common/vulkan/texture.h" +#include "gpu/vulkan/stream_buffer.h" +#include "gpu/vulkan/texture.h" #include "gpu_hw.h" #include "texture_replacements.h" #include diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index 188e1b9fb..fa21dfdc9 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -7,7 +7,7 @@ #include "common/log.h" #include "common/make_array.h" #include "common/platform.h" -#include "host_display.h" +#include "gpu/gpu_device.h" #include "system.h" #include Log_SetChannel(GPU_SW); @@ -895,7 +895,7 @@ void GPU_SW::CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 std::unique_ptr GPU::CreateSoftwareRenderer() { // we need something to draw in.. but keep the current api if we have one - if (!g_host_display && !Host::AcquireHostDisplay(HostDisplay::GetPreferredAPI())) + if (!g_host_display && !Host::AcquireHostDisplay(GPUDevice::GetPreferredAPI())) return nullptr; std::unique_ptr gpu(std::make_unique()); diff --git a/src/core/gpu_sw.h b/src/core/gpu_sw.h index 57bb1d778..b85462f58 100644 --- a/src/core/gpu_sw.h +++ b/src/core/gpu_sw.h @@ -4,14 +4,13 @@ #pragma once #include "common/heap_array.h" #include "gpu.h" +#include "gpu/gpu_device.h" #include "gpu_sw_backend.h" -#include "host_display.h" #include #include #include -namespace Threading -{ +namespace Threading { class Thread; } diff --git a/src/core/gpu_sw_backend.cpp b/src/core/gpu_sw_backend.cpp index 017418658..ceac8d51b 100644 --- a/src/core/gpu_sw_backend.cpp +++ b/src/core/gpu_sw_backend.cpp @@ -4,8 +4,8 @@ #include "gpu_sw_backend.h" #include "common/assert.h" #include "common/log.h" +#include "gpu/gpu_device.h" #include "gpu_sw_backend.h" -#include "host_display.h" #include "system.h" #include Log_SetChannel(GPU_SW_Backend); diff --git a/src/core/gte.cpp b/src/core/gte.cpp index 25feb02eb..9377a6b26 100644 --- a/src/core/gte.cpp +++ b/src/core/gte.cpp @@ -4,13 +4,13 @@ #include "gte.h" #include "common/assert.h" #include "common/bitutils.h" -#include "util/state_wrapper.h" #include "cpu_core.h" #include "cpu_core_private.h" -#include "host_display.h" +#include "gpu/gpu_device.h" #include "pgxp.h" #include "settings.h" #include "timing_event.h" +#include "util/state_wrapper.h" #include #include #include diff --git a/src/core/guncon.cpp b/src/core/guncon.cpp index d80efd24a..fbd513561 100644 --- a/src/core/guncon.cpp +++ b/src/core/guncon.cpp @@ -5,8 +5,8 @@ #include "common/assert.h" #include "common/log.h" #include "gpu.h" +#include "gpu/gpu_device.h" #include "host.h" -#include "host_display.h" #include "resources.h" #include "system.h" #include "util/state_wrapper.h" diff --git a/src/core/playstation_mouse.cpp b/src/core/playstation_mouse.cpp index ae01ef32e..a3a8b89ed 100644 --- a/src/core/playstation_mouse.cpp +++ b/src/core/playstation_mouse.cpp @@ -5,8 +5,8 @@ #include "common/assert.h" #include "common/log.h" #include "gpu.h" +#include "gpu/gpu_device.h" #include "host.h" -#include "host_display.h" #include "system.h" #include "util/state_wrapper.h" #include diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 68fb136b2..cae6d18dc 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -10,8 +10,8 @@ #include "common/path.h" #include "common/string_util.h" #include "controller.h" +#include "gpu/gpu_device.h" #include "host.h" -#include "host_display.h" #include "host_settings.h" #include "system.h" #include @@ -946,7 +946,7 @@ RenderAPI Settings::GetRenderAPIForRenderer(GPURenderer renderer) #endif case GPURenderer::Software: default: - return HostDisplay::GetPreferredAPI(); + return GPUDevice::GetPreferredAPI(); } } diff --git a/src/core/shadergen.cpp b/src/core/shadergen.cpp index f0b8b0b33..7b5a0505b 100644 --- a/src/core/shadergen.cpp +++ b/src/core/shadergen.cpp @@ -8,7 +8,7 @@ #include #ifdef WITH_OPENGL -#include "common/gl/loader.h" +#include "gpu/gl/loader.h" #endif Log_SetChannel(ShaderGen); diff --git a/src/core/shadergen.h b/src/core/shadergen.h index ed353ac03..83fac9a94 100644 --- a/src/core/shadergen.h +++ b/src/core/shadergen.h @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once +#include "gpu/gpu_device.h" #include "gpu_hw.h" -#include "host_display.h" #include #include diff --git a/src/core/system.cpp b/src/core/system.cpp index 167683514..1e50a4f9f 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -23,9 +23,9 @@ #include "fmt/format.h" #include "game_database.h" #include "gpu.h" +#include "gpu/gpu_device.h" #include "gte.h" #include "host.h" -#include "host_display.h" #include "host_interface_progress_callback.h" #include "host_settings.h" #include "interrupt_controller.h" @@ -529,7 +529,7 @@ bool System::GetGameDetailsFromImage(CDImage* cdi, std::string* out_id, GameHash pos++; } } - + if (out_id) { if (id.empty()) @@ -644,7 +644,7 @@ std::string System::GetExecutableNameForImage(CDImage* cdi, bool strip_subdirect } bool System::ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_name, - std::vector* out_executable_data) + std::vector* out_executable_data) { ISOReader iso; if (!iso.Open(cdi, 1)) @@ -653,7 +653,8 @@ bool System::ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_n return ReadExecutableFromImage(iso, out_executable_name, out_executable_data); } -bool System::ReadExecutableFromImage(ISOReader& iso, std::string* out_executable_name, std::vector* out_executable_data) +bool System::ReadExecutableFromImage(ISOReader& iso, std::string* out_executable_name, + std::vector* out_executable_data) { const std::string executable_path = GetExecutableNameForImage(iso, false); Log_DevPrintf("Executable path: '%s'", executable_path.c_str()); diff --git a/src/duckstation-nogui/nogui_host.cpp b/src/duckstation-nogui/nogui_host.cpp index 2d1799ae7..d1db023fa 100644 --- a/src/duckstation-nogui/nogui_host.cpp +++ b/src/duckstation-nogui/nogui_host.cpp @@ -12,8 +12,8 @@ #include "common/threading.h" #include "core/controller.h" #include "core/gpu.h" +#include "core/gpu/gpu_device.h" #include "core/host.h" -#include "core/host_display.h" #include "core/host_settings.h" #include "core/settings.h" #include "core/system.h" diff --git a/src/duckstation-nogui/nogui_platform.h b/src/duckstation-nogui/nogui_platform.h index 17a21b355..984f1b9c6 100644 --- a/src/duckstation-nogui/nogui_platform.h +++ b/src/duckstation-nogui/nogui_platform.h @@ -4,7 +4,7 @@ #pragma once #include "common/types.h" -#include "core/host_display.h" +#include "core/gpu/gpu_device.h" #include #include #include diff --git a/src/duckstation-nogui/vty_nogui_platform.cpp b/src/duckstation-nogui/vty_nogui_platform.cpp index 3c394dab6..6dea8ce1c 100644 --- a/src/duckstation-nogui/vty_nogui_platform.cpp +++ b/src/duckstation-nogui/vty_nogui_platform.cpp @@ -82,7 +82,7 @@ std::optional VTYNoGUIPlatform::GetPlatformWindowInfo() const std::string fullscreen_mode = Host::GetStringSettingValue("GPU", "FullscreenMode", ""); if (!fullscreen_mode.empty()) { - if (!HostDisplay::ParseFullscreenMode(fullscreen_mode, &wi.surface_width, &wi.surface_height, + if (!GPUDevice::ParseFullscreenMode(fullscreen_mode, &wi.surface_width, &wi.surface_height, &wi.surface_refresh_rate)) { Log_ErrorPrintf("Failed to parse fullscreen mode '%s'", fullscreen_mode.c_str()); diff --git a/src/duckstation-qt/displaysettingswidget.cpp b/src/duckstation-qt/displaysettingswidget.cpp index d9f168510..79df988dc 100644 --- a/src/duckstation-qt/displaysettingswidget.cpp +++ b/src/duckstation-qt/displaysettingswidget.cpp @@ -12,11 +12,11 @@ // For enumerating adapters. #ifdef _WIN32 -#include "frontend-common/d3d11_host_display.h" -#include "frontend-common/d3d12_host_display.h" +#include "core/gpu/d3d11_gpu_device.h" +#include "core/gpu/d3d12_gpu_device.h" #endif #ifdef WITH_VULKAN -#include "frontend-common/vulkan_host_display.h" +#include "core/gpu/vulkan_gpu_device.h" #endif DisplaySettingsWidget::DisplaySettingsWidget(SettingsDialog* dialog, QWidget* parent) @@ -189,23 +189,23 @@ void DisplaySettingsWidget::setupAdditionalUi() void DisplaySettingsWidget::populateGPUAdaptersAndResolutions() { - HostDisplay::AdapterAndModeList aml; + GPUDevice::AdapterAndModeList aml; bool thread_supported = false; bool threaded_presentation_supported = false; switch (static_cast(m_ui.renderer->currentIndex())) { #ifdef _WIN32 case GPURenderer::HardwareD3D11: - aml = D3D11HostDisplay::StaticGetAdapterAndModeList(); + aml = D3D11GPUDevice::StaticGetAdapterAndModeList(); break; case GPURenderer::HardwareD3D12: - aml = D3D12HostDisplay::StaticGetAdapterAndModeList(); + aml = D3D12GPUDevice::StaticGetAdapterAndModeList(); break; #endif #ifdef WITH_VULKAN case GPURenderer::HardwareVulkan: - aml = VulkanHostDisplay::StaticGetAdapterAndModeList(nullptr); + aml = VulkanGPUDevice::StaticGetAdapterAndModeList(nullptr); threaded_presentation_supported = true; break; #endif diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index c37379b82..9c89a6356 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -10,7 +10,7 @@ #include "common/log.h" #include "core/achievements.h" #include "core/host.h" -#include "core/host_display.h" +#include "core/gpu/gpu_device.h" #include "core/memory_card.h" #include "core/settings.h" #include "core/system.h" @@ -429,7 +429,7 @@ void MainWindow::setDisplayFullscreen(const std::string& fullscreen_mode) float refresh_rate; bool result = false; - if (HostDisplay::ParseFullscreenMode(fullscreen_mode, &width, &height, &refresh_rate)) + if (GPUDevice::ParseFullscreenMode(fullscreen_mode, &width, &height, &refresh_rate)) { result = g_host_display->SetFullscreen(true, width, height, refresh_rate); if (result) diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 363adf490..b38d518d2 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -29,7 +29,7 @@ class CheatManagerDialog; class DebuggerWindow; class MainWindow; -class HostDisplay; +class GPUDevice; namespace GameList { struct Entry; } diff --git a/src/duckstation-qt/postprocessingchainconfigwidget.cpp b/src/duckstation-qt/postprocessingchainconfigwidget.cpp index 7a9d34330..a28354ce2 100644 --- a/src/duckstation-qt/postprocessingchainconfigwidget.cpp +++ b/src/duckstation-qt/postprocessingchainconfigwidget.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "postprocessingchainconfigwidget.h" -#include "frontend-common/postprocessing_chain.h" +#include "core/gpu/postprocessing_chain.h" #include "postprocessingshaderconfigwidget.h" #include "qthost.h" #include diff --git a/src/duckstation-qt/postprocessingchainconfigwidget.h b/src/duckstation-qt/postprocessingchainconfigwidget.h index 2e3b0bcde..cf02328fd 100644 --- a/src/duckstation-qt/postprocessingchainconfigwidget.h +++ b/src/duckstation-qt/postprocessingchainconfigwidget.h @@ -3,11 +3,11 @@ #pragma once #include "common/types.h" +#include "core/gpu/postprocessing_chain.h" #include "ui_postprocessingchainconfigwidget.h" -#include "frontend-common/postprocessing_chain.h" #include -#include #include +#include #include namespace FrontendCommon { diff --git a/src/duckstation-qt/postprocessingshaderconfigwidget.h b/src/duckstation-qt/postprocessingshaderconfigwidget.h index 82730ef70..e1cd10684 100644 --- a/src/duckstation-qt/postprocessingshaderconfigwidget.h +++ b/src/duckstation-qt/postprocessingshaderconfigwidget.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "frontend-common/postprocessing_shader.h" +#include "core/gpu/postprocessing_shader.h" #include #include diff --git a/src/duckstation-qt/qthost.h b/src/duckstation-qt/qthost.h index c57f89be6..161cf23be 100644 --- a/src/duckstation-qt/qthost.h +++ b/src/duckstation-qt/qthost.h @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once +#include "core/gpu/gpu_device.h" #include "core/host.h" -#include "core/host_display.h" #include "core/host_settings.h" #include "core/system.h" #include "core/types.h" @@ -39,7 +39,7 @@ class QTranslator; class INISettingsInterface; -class HostDisplay; +class GPUDevice; class MainWindow; class DisplayWidget; diff --git a/src/duckstation-regtest/regtest_host.cpp b/src/duckstation-regtest/regtest_host.cpp index ae2727faa..01a712b2e 100644 --- a/src/duckstation-regtest/regtest_host.cpp +++ b/src/duckstation-regtest/regtest_host.cpp @@ -9,7 +9,7 @@ #include "common/path.h" #include "common/string_util.h" #include "core/host.h" -#include "core/host_display.h" +#include "core/gpu_device.h" #include "core/host_settings.h" #include "core/system.h" #include "frontend-common/common_host.h" diff --git a/src/duckstation-regtest/regtest_host_display.cpp b/src/duckstation-regtest/regtest_host_display.cpp index 6383c22f2..f1f165635 100644 --- a/src/duckstation-regtest/regtest_host_display.cpp +++ b/src/duckstation-regtest/regtest_host_display.cpp @@ -71,7 +71,7 @@ bool RegTestHostDisplay::CreateResources() void RegTestHostDisplay::DestroyResources() {} -HostDisplay::AdapterAndModeList RegTestHostDisplay::GetAdapterAndModeList() +GPUDevice::AdapterAndModeList RegTestHostDisplay::GetAdapterAndModeList() { return {}; } diff --git a/src/duckstation-regtest/regtest_host_display.h b/src/duckstation-regtest/regtest_host_display.h index 505fcc05e..dbcb1e0ee 100644 --- a/src/duckstation-regtest/regtest_host_display.h +++ b/src/duckstation-regtest/regtest_host_display.h @@ -2,10 +2,10 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "core/host_display.h" +#include "core/gpu_device.h" #include -class RegTestHostDisplay final : public HostDisplay +class RegTestHostDisplay final : public GPUDevice { public: RegTestHostDisplay(); diff --git a/src/frontend-common/achievements.cpp b/src/frontend-common/achievements.cpp index 5797e2366..94d46bf15 100644 --- a/src/frontend-common/achievements.cpp +++ b/src/frontend-common/achievements.cpp @@ -13,8 +13,8 @@ #include "core/bios.h" #include "core/bus.h" #include "core/cpu_core.h" +#include "core/gpu/gpu_device.h" #include "core/host.h" -#include "core/host_display.h" #include "core/host_settings.h" #include "core/system.h" #include "fullscreen_ui.h" diff --git a/src/frontend-common/common_host.cpp b/src/frontend-common/common_host.cpp index 6ceb7d9a0..9e143f2f4 100644 --- a/src/frontend-common/common_host.cpp +++ b/src/frontend-common/common_host.cpp @@ -16,9 +16,9 @@ #include "core/cpu_code_cache.h" #include "core/dma.h" #include "core/gpu.h" +#include "core/gpu/gpu_device.h" #include "core/gte.h" #include "core/host.h" -#include "core/host_display.h" #include "core/host_settings.h" #include "core/mdec.h" #include "core/pgxp.h" @@ -55,19 +55,19 @@ #ifdef _WIN32 #include "common/windows_headers.h" -#include "frontend-common/d3d11_host_display.h" -#include "frontend-common/d3d12_host_display.h" +#include "core/gpu/d3d11_gpu_device.h" +#include "core/gpu/d3d12_gpu_device.h" #include #include #include #endif #ifdef WITH_OPENGL -#include "frontend-common/opengl_host_display.h" +#include "core/gpu/opengl_gpu_device.h" #endif #ifdef WITH_VULKAN -#include "frontend-common/vulkan_host_display.h" +#include "core/gpu/vulkan_gpu_device.h" #endif Log_SetChannel(CommonHostInterface); @@ -139,38 +139,38 @@ void CommonHost::PumpMessagesOnCPUThread() #endif } -std::unique_ptr Host::CreateDisplayForAPI(RenderAPI api) +std::unique_ptr Host::CreateDisplayForAPI(RenderAPI api) { switch (api) { #ifdef WITH_VULKAN case RenderAPI::Vulkan: - return std::make_unique(); + return std::make_unique(); #endif #ifdef WITH_OPENGL case RenderAPI::OpenGL: case RenderAPI::OpenGLES: - return std::make_unique(); + return std::make_unique(); #endif #ifdef _WIN32 case RenderAPI::D3D12: - return std::make_unique(); + return std::make_unique(); case RenderAPI::D3D11: - return std::make_unique(); + return std::make_unique(); #endif default: #if defined(_WIN32) && defined(_M_ARM64) - return std::make_unique(); + return std::make_unique(); #elif defined(_WIN32) - return std::make_unique(); + return std::make_unique(); #elif defined(WITH_OPENGL) - return std::make_unique(); + return std::make_unique(); #elif defined(WITH_VULKAN) - return std::make_unique(); + return std::make_unique(); #else return {}; #endif @@ -570,8 +570,7 @@ void CommonHost::UpdateDiscordPresence(bool rich_presence_only) SmallString details_string; if (!System::IsShutdown()) { - details_string.AppendFormattedString("%s (%s)", System::GetGameTitle().c_str(), - System::GetGameSerial().c_str()); + details_string.AppendFormattedString("%s (%s)", System::GetGameTitle().c_str(), System::GetGameSerial().c_str()); } else { diff --git a/src/frontend-common/frontend-common.vcxproj b/src/frontend-common/frontend-common.vcxproj index ea07d2c33..49e67729c 100644 --- a/src/frontend-common/frontend-common.vcxproj +++ b/src/frontend-common/frontend-common.vcxproj @@ -5,37 +5,18 @@ - - - - - - true - - - true - - - true - - - - - - true - @@ -44,36 +25,17 @@ - - - - - - true - - - true - - - true - - - - - - true - diff --git a/src/frontend-common/frontend-common.vcxproj.filters b/src/frontend-common/frontend-common.vcxproj.filters index a1d19f7ab..b58137f52 100644 --- a/src/frontend-common/frontend-common.vcxproj.filters +++ b/src/frontend-common/frontend-common.vcxproj.filters @@ -3,21 +3,10 @@ - - - - - - - - - - - @@ -34,22 +23,11 @@ - - - - - - - - - - - diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp index c90e5c54e..ec7d25cae 100644 --- a/src/frontend-common/fullscreen_ui.cpp +++ b/src/frontend-common/fullscreen_ui.cpp @@ -20,8 +20,9 @@ #include "core/controller.h" #include "core/cpu_core.h" #include "core/gpu.h" +#include "core/gpu/gpu_device.h" +#include "core/gpu/postprocessing_chain.h" #include "core/host.h" -#include "core/host_display.h" #include "core/host_settings.h" #include "core/memory_card_image.h" #include "core/resources.h" @@ -37,7 +38,6 @@ #include "imgui_manager.h" #include "imgui_stdlib.h" #include "input_manager.h" -#include "postprocessing_chain.h" #include "scmversion/scmversion.h" #include "util/ini_settings_interface.h" #include @@ -2355,7 +2355,7 @@ void FullscreenUI::SwitchToGameSettings(const GameList::Entry* entry) void FullscreenUI::PopulateGraphicsAdapterList() { - HostDisplay::AdapterAndModeList ml(g_host_display->GetAdapterAndModeList()); + GPUDevice::AdapterAndModeList ml(g_host_display->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")) { - HostDisplay::AdapterAndModeList aml(g_host_display->GetAdapterAndModeList()); + GPUDevice::AdapterAndModeList aml(g_host_display->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")) { - HostDisplay::AdapterAndModeList aml(g_host_display->GetAdapterAndModeList()); + GPUDevice::AdapterAndModeList aml(g_host_display->GetAdapterAndModeList()); ImGuiFullscreen::ChoiceDialogOptions options; options.reserve(aml.fullscreen_modes.size() + 2); @@ -4505,9 +4505,10 @@ void FullscreenUI::DrawAdvancedSettingsPage() DrawFloatRangeSetting(bsi, "Display FPS Limit", "Limits how many frames are displayed to the screen. These frames are still rendered.", "Display", "MaxFPS", Settings::DEFAULT_DISPLAY_MAX_FPS, 0.0f, 500.0f, "%.2f FPS"); - DrawToggleSetting(bsi, "Stretch Display Vertically", - "Stretches the display to match the aspect ratio by multiplying vertically instead of horizontally.", - "Display", "StretchVertically", false); + DrawToggleSetting( + bsi, "Stretch Display Vertically", + "Stretches the display to match the aspect ratio by multiplying vertically instead of horizontally.", "Display", + "StretchVertically", false); MenuHeading("PGXP Settings"); diff --git a/src/frontend-common/imgui_fullscreen.cpp b/src/frontend-common/imgui_fullscreen.cpp index 3bab3d4e5..05cea3ca6 100644 --- a/src/frontend-common/imgui_fullscreen.cpp +++ b/src/frontend-common/imgui_fullscreen.cpp @@ -15,8 +15,8 @@ #include "common/string_util.h" #include "common/threading.h" #include "common/timer.h" +#include "core/gpu/gpu_device.h" #include "core/host.h" -#include "core/host_display.h" #include "fmt/core.h" #include "imgui_internal.h" #include "imgui_stdlib.h" diff --git a/src/frontend-common/imgui_manager.cpp b/src/frontend-common/imgui_manager.cpp index d2f570548..5143c4761 100644 --- a/src/frontend-common/imgui_manager.cpp +++ b/src/frontend-common/imgui_manager.cpp @@ -10,8 +10,8 @@ #include "common/timer.h" #include "common_host.h" #include "core/gpu.h" +#include "core/gpu/gpu_device.h" #include "core/host.h" -#include "core/host_display.h" #include "core/system.h" #include "fmt/format.h" #include "fullscreen_ui.h" @@ -569,10 +569,10 @@ void Host::AddOSDMessage(std::string message, float duration /*= 2.0f*/) void Host::AddKeyedOSDMessage(std::string key, std::string message, float duration /* = 2.0f */) { - if (!key.empty()) - Log_InfoPrintf("OSD [%s]: %s", key.c_str(), message.c_str()); - else - Log_InfoPrintf("OSD: %s", message.c_str()); + if (!key.empty()) + Log_InfoPrintf("OSD [%s]: %s", key.c_str(), message.c_str()); + else + Log_InfoPrintf("OSD: %s", message.c_str()); OSDMessage msg; msg.key = std::move(key); diff --git a/src/frontend-common/imgui_overlays.cpp b/src/frontend-common/imgui_overlays.cpp index 1cf32a698..0fe18d4da 100644 --- a/src/frontend-common/imgui_overlays.cpp +++ b/src/frontend-common/imgui_overlays.cpp @@ -12,8 +12,8 @@ #include "common_host.h" #include "core/controller.h" #include "core/gpu.h" +#include "core/gpu/gpu_device.h" #include "core/host.h" -#include "core/host_display.h" #include "core/host_settings.h" #include "core/settings.h" #include "core/spu.h"