HostDisplay: Rename to GPUDevice

This commit is contained in:
Stenzek 2023-07-27 23:39:04 +10:00
parent c1fa7a5998
commit 02d379116e
150 changed files with 1023 additions and 1510 deletions

View File

@ -9,44 +9,11 @@
<ClInclude Include="build_timestamp.h" /> <ClInclude Include="build_timestamp.h" />
<ClInclude Include="byte_stream.h" /> <ClInclude Include="byte_stream.h" />
<ClInclude Include="crash_handler.h" /> <ClInclude Include="crash_handler.h" />
<ClInclude Include="d3d11\shader_cache.h" />
<ClInclude Include="d3d11\shader_compiler.h" />
<ClInclude Include="d3d11\stream_buffer.h" />
<ClInclude Include="d3d11\texture.h" />
<ClInclude Include="d3d12\context.h" />
<ClInclude Include="d3d12\descriptor_heap_manager.h" />
<ClInclude Include="d3d12\shader_cache.h" />
<ClInclude Include="d3d12\util.h" />
<ClInclude Include="d3d12\staging_texture.h" />
<ClInclude Include="d3d12\stream_buffer.h" />
<ClInclude Include="d3d12\texture.h" />
<ClInclude Include="dimensional_array.h" /> <ClInclude Include="dimensional_array.h" />
<ClInclude Include="easing.h" /> <ClInclude Include="easing.h" />
<ClInclude Include="error.h" /> <ClInclude Include="error.h" />
<ClInclude Include="fifo_queue.h" /> <ClInclude Include="fifo_queue.h" />
<ClInclude Include="file_system.h" /> <ClInclude Include="file_system.h" />
<ClInclude Include="gl\context.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\context_wgl.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\loader.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\program.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\shader_cache.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\stream_buffer.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gl\texture.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gpu_texture.h" />
<ClInclude Include="hash_combine.h" /> <ClInclude Include="hash_combine.h" />
<ClInclude Include="heap_array.h" /> <ClInclude Include="heap_array.h" />
<ClInclude Include="http_downloader.h" /> <ClInclude Include="http_downloader.h" />
@ -73,36 +40,6 @@
<ClInclude Include="timer.h" /> <ClInclude Include="timer.h" />
<ClInclude Include="types.h" /> <ClInclude Include="types.h" />
<ClInclude Include="minizip_helpers.h" /> <ClInclude Include="minizip_helpers.h" />
<ClInclude Include="vulkan\builders.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\context.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\entry_points.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\loader.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\shader_cache.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\shader_compiler.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\stream_buffer.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\swap_chain.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\texture.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="vulkan\util.h">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="win32_progress_callback.h" /> <ClInclude Include="win32_progress_callback.h" />
<ClInclude Include="windows_headers.h" /> <ClInclude Include="windows_headers.h" />
<ClInclude Include="window_info.h" /> <ClInclude Include="window_info.h" />
@ -111,38 +48,8 @@
<ClCompile Include="assert.cpp" /> <ClCompile Include="assert.cpp" />
<ClCompile Include="byte_stream.cpp" /> <ClCompile Include="byte_stream.cpp" />
<ClCompile Include="crash_handler.cpp" /> <ClCompile Include="crash_handler.cpp" />
<ClCompile Include="d3d11\shader_cache.cpp" />
<ClCompile Include="d3d11\shader_compiler.cpp" />
<ClCompile Include="d3d11\stream_buffer.cpp" />
<ClCompile Include="d3d11\texture.cpp" />
<ClCompile Include="error.cpp" /> <ClCompile Include="error.cpp" />
<ClCompile Include="d3d12\context.cpp" />
<ClCompile Include="d3d12\descriptor_heap_manager.cpp" />
<ClCompile Include="d3d12\shader_cache.cpp" />
<ClCompile Include="d3d12\staging_texture.cpp" />
<ClCompile Include="d3d12\stream_buffer.cpp" />
<ClCompile Include="d3d12\texture.cpp" />
<ClCompile Include="d3d12\util.cpp" />
<ClCompile Include="file_system.cpp" /> <ClCompile Include="file_system.cpp" />
<ClCompile Include="gl\context.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\context_wgl.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\program.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\shader_cache.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\stream_buffer.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gl\texture.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gpu_texture.cpp" />
<ClCompile Include="http_downloader.cpp" /> <ClCompile Include="http_downloader.cpp" />
<ClCompile Include="http_downloader_winhttp.cpp" /> <ClCompile Include="http_downloader_winhttp.cpp" />
<ClCompile Include="image.cpp" /> <ClCompile Include="image.cpp" />
@ -158,44 +65,12 @@
<ClCompile Include="thirdparty\StackWalker.cpp" /> <ClCompile Include="thirdparty\StackWalker.cpp" />
<ClCompile Include="threading.cpp" /> <ClCompile Include="threading.cpp" />
<ClCompile Include="timer.cpp" /> <ClCompile Include="timer.cpp" />
<ClCompile Include="vulkan\builders.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\context.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\loader.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\shader_cache.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\shader_compiler.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\stream_buffer.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\swap_chain.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\texture.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vulkan\util.cpp">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="win32_progress_callback.cpp" /> <ClCompile Include="win32_progress_callback.cpp" />
<ClCompile Include="window_info.cpp" /> <ClCompile Include="window_info.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Natvis Include="bitfield.natvis" /> <Natvis Include="bitfield.natvis" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="vulkan\entry_points.inl">
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</None>
</ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{EE054E08-3799-4A59-A422-18259C105FFD}</ProjectGuid> <ProjectGuid>{EE054E08-3799-4A59-A422-18259C105FFD}</ProjectGuid>
</PropertyGroup> </PropertyGroup>

View File

@ -5,24 +5,6 @@
<ClInclude Include="types.h" /> <ClInclude Include="types.h" />
<ClInclude Include="fifo_queue.h" /> <ClInclude Include="fifo_queue.h" />
<ClInclude Include="heap_array.h" /> <ClInclude Include="heap_array.h" />
<ClInclude Include="gl\program.h">
<Filter>gl</Filter>
</ClInclude>
<ClInclude Include="gl\stream_buffer.h">
<Filter>gl</Filter>
</ClInclude>
<ClInclude Include="gl\texture.h">
<Filter>gl</Filter>
</ClInclude>
<ClInclude Include="d3d11\stream_buffer.h">
<Filter>d3d11</Filter>
</ClInclude>
<ClInclude Include="d3d11\texture.h">
<Filter>d3d11</Filter>
</ClInclude>
<ClInclude Include="d3d11\shader_compiler.h">
<Filter>d3d11</Filter>
</ClInclude>
<ClInclude Include="rectangle.h" /> <ClInclude Include="rectangle.h" />
<ClInclude Include="log.h" /> <ClInclude Include="log.h" />
<ClInclude Include="string.h" /> <ClInclude Include="string.h" />
@ -33,47 +15,11 @@
<ClInclude Include="file_system.h" /> <ClInclude Include="file_system.h" />
<ClInclude Include="string_util.h" /> <ClInclude Include="string_util.h" />
<ClInclude Include="md5_digest.h" /> <ClInclude Include="md5_digest.h" />
<ClInclude Include="d3d11\shader_cache.h">
<Filter>d3d11</Filter>
</ClInclude>
<ClInclude Include="hash_combine.h" /> <ClInclude Include="hash_combine.h" />
<ClInclude Include="progress_callback.h" /> <ClInclude Include="progress_callback.h" />
<ClInclude Include="gl\shader_cache.h">
<Filter>gl</Filter>
</ClInclude>
<ClInclude Include="bitutils.h" /> <ClInclude Include="bitutils.h" />
<ClInclude Include="gl\context.h">
<Filter>gl</Filter>
</ClInclude>
<ClInclude Include="gl\context_wgl.h">
<Filter>gl</Filter>
</ClInclude>
<ClInclude Include="window_info.h" /> <ClInclude Include="window_info.h" />
<ClInclude Include="vulkan\texture.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="vulkan\stream_buffer.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="vulkan\shader_compiler.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="vulkan\util.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="vulkan\swap_chain.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="dimensional_array.h" /> <ClInclude Include="dimensional_array.h" />
<ClInclude Include="vulkan\context.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="vulkan\builders.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="vulkan\shader_cache.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="image.h" /> <ClInclude Include="image.h" />
<ClInclude Include="minizip_helpers.h" /> <ClInclude Include="minizip_helpers.h" />
<ClInclude Include="win32_progress_callback.h" /> <ClInclude Include="win32_progress_callback.h" />
@ -86,40 +32,10 @@
<ClInclude Include="easing.h" /> <ClInclude Include="easing.h" />
<ClInclude Include="error.h" /> <ClInclude Include="error.h" />
<ClInclude Include="platform.h" /> <ClInclude Include="platform.h" />
<ClInclude Include="d3d12\staging_texture.h">
<Filter>d3d12</Filter>
</ClInclude>
<ClInclude Include="d3d12\stream_buffer.h">
<Filter>d3d12</Filter>
</ClInclude>
<ClInclude Include="d3d12\texture.h">
<Filter>d3d12</Filter>
</ClInclude>
<ClInclude Include="d3d12\context.h">
<Filter>d3d12</Filter>
</ClInclude>
<ClInclude Include="d3d12\descriptor_heap_manager.h">
<Filter>d3d12</Filter>
</ClInclude>
<ClInclude Include="d3d12\util.h">
<Filter>d3d12</Filter>
</ClInclude>
<ClInclude Include="d3d12\shader_cache.h">
<Filter>d3d12</Filter>
</ClInclude>
<ClInclude Include="http_downloader_winhttp.h" /> <ClInclude Include="http_downloader_winhttp.h" />
<ClInclude Include="http_downloader.h" /> <ClInclude Include="http_downloader.h" />
<ClInclude Include="vulkan\entry_points.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="vulkan\loader.h">
<Filter>vulkan</Filter>
</ClInclude>
<ClInclude Include="path.h" /> <ClInclude Include="path.h" />
<ClInclude Include="windows_headers.h" /> <ClInclude Include="windows_headers.h" />
<ClInclude Include="gl\loader.h">
<Filter>gl</Filter>
</ClInclude>
<ClInclude Include="settings_interface.h" /> <ClInclude Include="settings_interface.h" />
<ClInclude Include="layered_settings_interface.h" /> <ClInclude Include="layered_settings_interface.h" />
<ClInclude Include="heterogeneous_containers.h" /> <ClInclude Include="heterogeneous_containers.h" />
@ -128,27 +44,8 @@
<ClInclude Include="scoped_guard.h" /> <ClInclude Include="scoped_guard.h" />
<ClInclude Include="build_timestamp.h" /> <ClInclude Include="build_timestamp.h" />
<ClInclude Include="sha1_digest.h" /> <ClInclude Include="sha1_digest.h" />
<ClInclude Include="gpu_texture.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="gl\program.cpp">
<Filter>gl</Filter>
</ClCompile>
<ClCompile Include="gl\stream_buffer.cpp">
<Filter>gl</Filter>
</ClCompile>
<ClCompile Include="gl\texture.cpp">
<Filter>gl</Filter>
</ClCompile>
<ClCompile Include="d3d11\texture.cpp">
<Filter>d3d11</Filter>
</ClCompile>
<ClCompile Include="d3d11\stream_buffer.cpp">
<Filter>d3d11</Filter>
</ClCompile>
<ClCompile Include="d3d11\shader_compiler.cpp">
<Filter>d3d11</Filter>
</ClCompile>
<ClCompile Include="string.cpp" /> <ClCompile Include="string.cpp" />
<ClCompile Include="byte_stream.cpp" /> <ClCompile Include="byte_stream.cpp" />
<ClCompile Include="log.cpp" /> <ClCompile Include="log.cpp" />
@ -157,43 +54,7 @@
<ClCompile Include="file_system.cpp" /> <ClCompile Include="file_system.cpp" />
<ClCompile Include="string_util.cpp" /> <ClCompile Include="string_util.cpp" />
<ClCompile Include="md5_digest.cpp" /> <ClCompile Include="md5_digest.cpp" />
<ClCompile Include="d3d11\shader_cache.cpp">
<Filter>d3d11</Filter>
</ClCompile>
<ClCompile Include="progress_callback.cpp" /> <ClCompile Include="progress_callback.cpp" />
<ClCompile Include="gl\shader_cache.cpp">
<Filter>gl</Filter>
</ClCompile>
<ClCompile Include="gl\context_wgl.cpp">
<Filter>gl</Filter>
</ClCompile>
<ClCompile Include="gl\context.cpp">
<Filter>gl</Filter>
</ClCompile>
<ClCompile Include="vulkan\texture.cpp">
<Filter>vulkan</Filter>
</ClCompile>
<ClCompile Include="vulkan\context.cpp">
<Filter>vulkan</Filter>
</ClCompile>
<ClCompile Include="vulkan\stream_buffer.cpp">
<Filter>vulkan</Filter>
</ClCompile>
<ClCompile Include="vulkan\util.cpp">
<Filter>vulkan</Filter>
</ClCompile>
<ClCompile Include="vulkan\shader_compiler.cpp">
<Filter>vulkan</Filter>
</ClCompile>
<ClCompile Include="vulkan\swap_chain.cpp">
<Filter>vulkan</Filter>
</ClCompile>
<ClCompile Include="vulkan\builders.cpp">
<Filter>vulkan</Filter>
</ClCompile>
<ClCompile Include="vulkan\shader_cache.cpp">
<Filter>vulkan</Filter>
</ClCompile>
<ClCompile Include="image.cpp" /> <ClCompile Include="image.cpp" />
<ClCompile Include="minizip_helpers.cpp" /> <ClCompile Include="minizip_helpers.cpp" />
<ClCompile Include="win32_progress_callback.cpp" /> <ClCompile Include="win32_progress_callback.cpp" />
@ -203,61 +64,19 @@
<ClCompile Include="crash_handler.cpp" /> <ClCompile Include="crash_handler.cpp" />
<ClCompile Include="error.cpp" /> <ClCompile Include="error.cpp" />
<ClCompile Include="window_info.cpp" /> <ClCompile Include="window_info.cpp" />
<ClCompile Include="d3d12\staging_texture.cpp">
<Filter>d3d12</Filter>
</ClCompile>
<ClCompile Include="d3d12\stream_buffer.cpp">
<Filter>d3d12</Filter>
</ClCompile>
<ClCompile Include="d3d12\texture.cpp">
<Filter>d3d12</Filter>
</ClCompile>
<ClCompile Include="d3d12\context.cpp">
<Filter>d3d12</Filter>
</ClCompile>
<ClCompile Include="d3d12\descriptor_heap_manager.cpp">
<Filter>d3d12</Filter>
</ClCompile>
<ClCompile Include="d3d12\util.cpp">
<Filter>d3d12</Filter>
</ClCompile>
<ClCompile Include="d3d12\shader_cache.cpp">
<Filter>d3d12</Filter>
</ClCompile>
<ClCompile Include="http_downloader_winhttp.cpp" /> <ClCompile Include="http_downloader_winhttp.cpp" />
<ClCompile Include="http_downloader.cpp" /> <ClCompile Include="http_downloader.cpp" />
<ClCompile Include="vulkan\loader.cpp">
<Filter>vulkan</Filter>
</ClCompile>
<ClCompile Include="layered_settings_interface.cpp" /> <ClCompile Include="layered_settings_interface.cpp" />
<ClCompile Include="memory_settings_interface.cpp" /> <ClCompile Include="memory_settings_interface.cpp" />
<ClCompile Include="threading.cpp" /> <ClCompile Include="threading.cpp" />
<ClCompile Include="sha1_digest.cpp" /> <ClCompile Include="sha1_digest.cpp" />
<ClCompile Include="gpu_texture.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Natvis Include="bitfield.natvis" /> <Natvis Include="bitfield.natvis" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="gl">
<UniqueIdentifier>{52487c57-753d-4888-ba26-ed63ab51a234}</UniqueIdentifier>
</Filter>
<Filter Include="d3d11">
<UniqueIdentifier>{30251086-81f3-44f5-add4-7ff9a24098ab}</UniqueIdentifier>
</Filter>
<Filter Include="vulkan">
<UniqueIdentifier>{642ff5eb-af39-4aab-a42f-6eb8188a11d7}</UniqueIdentifier>
</Filter>
<Filter Include="thirdparty"> <Filter Include="thirdparty">
<UniqueIdentifier>{fd4150b0-6f82-4251-ab23-34c25fbc5b5e}</UniqueIdentifier> <UniqueIdentifier>{fd4150b0-6f82-4251-ab23-34c25fbc5b5e}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="d3d12">
<UniqueIdentifier>{358e11c4-34af-4169-9a66-ec66342a6a2f}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="vulkan\entry_points.inl">
<Filter>vulkan</Filter>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,48 +0,0 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "context_egl_android.h"
#include "../log.h"
#include <android/native_window.h>
Log_SetChannel(GL::ContextEGLAndroid);
namespace GL {
ContextEGLAndroid::ContextEGLAndroid(const WindowInfo& wi) : ContextEGL(wi) {}
ContextEGLAndroid::~ContextEGLAndroid() = default;
std::unique_ptr<Context> ContextEGLAndroid::Create(const WindowInfo& wi, const Version* versions_to_try,
size_t num_versions_to_try)
{
std::unique_ptr<ContextEGLAndroid> context = std::make_unique<ContextEGLAndroid>(wi);
if (!context->Initialize(versions_to_try, num_versions_to_try))
return nullptr;
return context;
}
std::unique_ptr<Context> ContextEGLAndroid::CreateSharedContext(const WindowInfo& wi)
{
std::unique_ptr<ContextEGLAndroid> context = std::make_unique<ContextEGLAndroid>(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<ANativeWindow*>(m_wi.window_handle), 0, 0, static_cast<int32_t>(native_visual_id));
m_wi.surface_width = ANativeWindow_getWidth(static_cast<ANativeWindow*>(m_wi.window_handle));
m_wi.surface_height = ANativeWindow_getHeight(static_cast<ANativeWindow*>(m_wi.window_handle));
return static_cast<EGLNativeWindowType>(m_wi.window_handle);
}
} // namespace GL

View File

@ -1,24 +0,0 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// 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<Context> Create(const WindowInfo& wi, const Version* versions_to_try,
size_t num_versions_to_try);
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) override;
protected:
EGLNativeWindowType GetNativeWindow(EGLConfig config) override;
};
} // namespace GL

View File

@ -1,35 +0,0 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// 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<Context> ContextEGLFBDev::Create(const WindowInfo& wi, const Version* versions_to_try,
size_t num_versions_to_try)
{
std::unique_ptr<ContextEGLFBDev> context = std::make_unique<ContextEGLFBDev>(wi);
if (!context->Initialize(versions_to_try, num_versions_to_try))
return nullptr;
return context;
}
std::unique_ptr<Context> ContextEGLFBDev::CreateSharedContext(const WindowInfo& wi)
{
std::unique_ptr<ContextEGLFBDev> context = std::make_unique<ContextEGLFBDev>(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<EGLNativeWindowType>(0);
}
} // namespace GL

View File

@ -1,24 +0,0 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// 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<Context> Create(const WindowInfo& wi, const Version* versions_to_try,
size_t num_versions_to_try);
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) override;
protected:
EGLNativeWindowType GetNativeWindow(EGLConfig config) override;
};
} // namespace GL

View File

@ -1,289 +0,0 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// 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 <drm.h>
#include <drm_fourcc.h>
#include <gbm.h>
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<Context> ContextEGLGBM::Create(const WindowInfo& wi, const Version* versions_to_try,
size_t num_versions_to_try)
{
std::unique_ptr<ContextEGLGBM> context = std::make_unique<ContextEGLGBM>(wi);
if (!context->CreateDisplay() || !context->CreateGBMDevice() ||
!context->Initialize(versions_to_try, num_versions_to_try))
{
return nullptr;
}
return context;
}
std::unique_ptr<Context> ContextEGLGBM::CreateSharedContext(const WindowInfo& wi)
{
std::unique_ptr<ContextEGLGBM> context = std::make_unique<ContextEGLGBM>(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<u32>(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<u32> 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<Context::FullscreenModeInfo> ContextEGLGBM::EnumerateFullscreenModes()
{
std::vector<Context::FullscreenModeInfo> 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

View File

@ -1,81 +0,0 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
#include "../drm_display.h"
#include "context_egl.h"
#include <atomic>
#include <condition_variable>
#include <gbm.h>
#include <mutex>
#include <thread>
#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<Context> Create(const WindowInfo& wi, const Version* versions_to_try,
size_t num_versions_to_try);
std::unique_ptr<Context> 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<FullscreenModeInfo> 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<Buffer, MAX_BUFFERS> m_buffers{};
};
} // namespace GL

View File

@ -33,6 +33,60 @@
<ClCompile Include="cpu_types.cpp" /> <ClCompile Include="cpu_types.cpp" />
<ClCompile Include="digital_controller.cpp" /> <ClCompile Include="digital_controller.cpp" />
<ClCompile Include="game_database.cpp" /> <ClCompile Include="game_database.cpp" />
<ClCompile Include="gpu\d3d11\shader_cache.cpp" />
<ClCompile Include="gpu\d3d11\shader_compiler.cpp" />
<ClCompile Include="gpu\d3d11\stream_buffer.cpp" />
<ClCompile Include="gpu\d3d11\texture.cpp" />
<ClCompile Include="gpu\d3d11_gpu_device.cpp" />
<ClCompile Include="gpu\d3d12\context.cpp" />
<ClCompile Include="gpu\d3d12\descriptor_heap_manager.cpp" />
<ClCompile Include="gpu\d3d12\shader_cache.cpp" />
<ClCompile Include="gpu\d3d12\staging_texture.cpp" />
<ClCompile Include="gpu\d3d12\stream_buffer.cpp" />
<ClCompile Include="gpu\d3d12\texture.cpp" />
<ClCompile Include="gpu\d3d12\util.cpp" />
<ClCompile Include="gpu\d3d12_gpu_device.cpp" />
<ClCompile Include="gpu\gl\context.cpp" />
<ClCompile Include="gpu\gl\context_egl.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gpu\gl\context_egl_wayland.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gpu\gl\context_egl_x11.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gpu\gl\context_glx.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gpu\gl\context_wgl.cpp" />
<ClCompile Include="gpu\gl\program.cpp" />
<ClCompile Include="gpu\gl\shader_cache.cpp" />
<ClCompile Include="gpu\gl\stream_buffer.cpp" />
<ClCompile Include="gpu\gl\texture.cpp" />
<ClCompile Include="gpu\gl\x11_window.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="gpu\gpu_device.cpp" />
<ClCompile Include="gpu\gpu_texture.cpp" />
<ClCompile Include="gpu\imgui_impl_dx11.cpp" />
<ClCompile Include="gpu\imgui_impl_dx12.cpp" />
<ClCompile Include="gpu\imgui_impl_opengl3.cpp" />
<ClCompile Include="gpu\imgui_impl_vulkan.cpp" />
<ClCompile Include="gpu\opengl_gpu_device.cpp" />
<ClCompile Include="gpu\postprocessing_chain.cpp" />
<ClCompile Include="gpu\postprocessing_shader.cpp" />
<ClCompile Include="gpu\postprocessing_shadergen.cpp" />
<ClCompile Include="gpu\vulkan\builders.cpp" />
<ClCompile Include="gpu\vulkan\context.cpp" />
<ClCompile Include="gpu\vulkan\loader.cpp" />
<ClCompile Include="gpu\vulkan\shader_cache.cpp" />
<ClCompile Include="gpu\vulkan\shader_compiler.cpp" />
<ClCompile Include="gpu\vulkan\stream_buffer.cpp" />
<ClCompile Include="gpu\vulkan\swap_chain.cpp" />
<ClCompile Include="gpu\vulkan\texture.cpp" />
<ClCompile Include="gpu\vulkan\util.cpp" />
<ClCompile Include="gpu\vulkan_gpu_device.cpp" />
<ClCompile Include="gpu_backend.cpp" /> <ClCompile Include="gpu_backend.cpp" />
<ClCompile Include="gpu_commands.cpp" /> <ClCompile Include="gpu_commands.cpp" />
<ClCompile Include="gpu_hw_d3d11.cpp" /> <ClCompile Include="gpu_hw_d3d11.cpp" />
@ -52,7 +106,6 @@
<ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Platform)'=='ARM64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="host.cpp" /> <ClCompile Include="host.cpp" />
<ClCompile Include="host_display.cpp" />
<ClCompile Include="host_interface_progress_callback.cpp" /> <ClCompile Include="host_interface_progress_callback.cpp" />
<ClCompile Include="interrupt_controller.cpp" /> <ClCompile Include="interrupt_controller.cpp" />
<ClCompile Include="libcrypt_serials.cpp" /> <ClCompile Include="libcrypt_serials.cpp" />
@ -105,6 +158,65 @@
</ClInclude> </ClInclude>
<ClInclude Include="digital_controller.h" /> <ClInclude Include="digital_controller.h" />
<ClInclude Include="game_database.h" /> <ClInclude Include="game_database.h" />
<ClInclude Include="gpu\d3d11\shader_cache.h" />
<ClInclude Include="gpu\d3d11\shader_compiler.h" />
<ClInclude Include="gpu\d3d11\stream_buffer.h" />
<ClInclude Include="gpu\d3d11\texture.h" />
<ClInclude Include="gpu\d3d11_gpu_device.h" />
<ClInclude Include="gpu\d3d12\context.h" />
<ClInclude Include="gpu\d3d12\descriptor_heap_manager.h" />
<ClInclude Include="gpu\d3d12\shader_cache.h" />
<ClInclude Include="gpu\d3d12\staging_texture.h" />
<ClInclude Include="gpu\d3d12\stream_buffer.h" />
<ClInclude Include="gpu\d3d12\texture.h" />
<ClInclude Include="gpu\d3d12\util.h" />
<ClInclude Include="gpu\d3d12_gpu_device.h" />
<ClInclude Include="gpu\gl\context.h" />
<ClInclude Include="gpu\gl\context_agl.h">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gpu\gl\context_egl.h">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gpu\gl\context_egl_wayland.h">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gpu\gl\context_egl_x11.h">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gpu\gl\context_glx.h">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gpu\gl\context_wgl.h" />
<ClInclude Include="gpu\gl\loader.h" />
<ClInclude Include="gpu\gl\program.h" />
<ClInclude Include="gpu\gl\shader_cache.h" />
<ClInclude Include="gpu\gl\stream_buffer.h" />
<ClInclude Include="gpu\gl\texture.h" />
<ClInclude Include="gpu\gl\x11_window.h">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="gpu\gpu_device.h" />
<ClInclude Include="gpu\gpu_texture.h" />
<ClInclude Include="gpu\imgui_impl_dx11.h" />
<ClInclude Include="gpu\imgui_impl_dx12.h" />
<ClInclude Include="gpu\imgui_impl_opengl3.h" />
<ClInclude Include="gpu\imgui_impl_vulkan.h" />
<ClInclude Include="gpu\opengl_gpu_device.h" />
<ClInclude Include="gpu\postprocessing_chain.h" />
<ClInclude Include="gpu\postprocessing_shader.h" />
<ClInclude Include="gpu\postprocessing_shadergen.h" />
<ClInclude Include="gpu\vulkan\builders.h" />
<ClInclude Include="gpu\vulkan\context.h" />
<ClInclude Include="gpu\vulkan\entry_points.h" />
<ClInclude Include="gpu\vulkan\loader.h" />
<ClInclude Include="gpu\vulkan\shader_cache.h" />
<ClInclude Include="gpu\vulkan\shader_compiler.h" />
<ClInclude Include="gpu\vulkan\stream_buffer.h" />
<ClInclude Include="gpu\vulkan\swap_chain.h" />
<ClInclude Include="gpu\vulkan\texture.h" />
<ClInclude Include="gpu\vulkan\util.h" />
<ClInclude Include="gpu\vulkan_gpu_device.h" />
<ClInclude Include="gpu_backend.h" /> <ClInclude Include="gpu_backend.h" />
<ClInclude Include="gpu_hw_d3d11.h" /> <ClInclude Include="gpu_hw_d3d11.h" />
<ClInclude Include="gpu_hw_d3d12.h" /> <ClInclude Include="gpu_hw_d3d12.h" />
@ -126,7 +238,6 @@
</ClInclude> </ClInclude>
<ClInclude Include="gte_types.h" /> <ClInclude Include="gte_types.h" />
<ClInclude Include="host.h" /> <ClInclude Include="host.h" />
<ClInclude Include="host_display.h" />
<ClInclude Include="host_interface_progress_callback.h" /> <ClInclude Include="host_interface_progress_callback.h" />
<ClInclude Include="host_settings.h" /> <ClInclude Include="host_settings.h" />
<ClInclude Include="input_types.h" /> <ClInclude Include="input_types.h" />
@ -157,6 +268,12 @@
<ClInclude Include="timing_event.h" /> <ClInclude Include="timing_event.h" />
<ClInclude Include="types.h" /> <ClInclude Include="types.h" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="gpu\gl\context_agl.mm">
<ExcludedFromBuild>true</ExcludedFromBuild>
</None>
<None Include="gpu\vulkan\entry_points.inl" />
</ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{868B98C8-65A1-494B-8346-250A73A48C0A}</ProjectGuid> <ProjectGuid>{868B98C8-65A1-494B-8346-250A73A48C0A}</ProjectGuid>
</PropertyGroup> </PropertyGroup>

View File

@ -35,7 +35,6 @@
<ClCompile Include="sio.cpp" /> <ClCompile Include="sio.cpp" />
<ClCompile Include="controller.cpp" /> <ClCompile Include="controller.cpp" />
<ClCompile Include="analog_controller.cpp" /> <ClCompile Include="analog_controller.cpp" />
<ClCompile Include="host_display.cpp" />
<ClCompile Include="timing_event.cpp" /> <ClCompile Include="timing_event.cpp" />
<ClCompile Include="cdrom_async_reader.cpp" /> <ClCompile Include="cdrom_async_reader.cpp" />
<ClCompile Include="psf_loader.cpp" /> <ClCompile Include="psf_loader.cpp" />
@ -60,6 +59,138 @@
<ClCompile Include="host.cpp" /> <ClCompile Include="host.cpp" />
<ClCompile Include="game_database.cpp" /> <ClCompile Include="game_database.cpp" />
<ClCompile Include="pcdrv.cpp" /> <ClCompile Include="pcdrv.cpp" />
<ClCompile Include="gpu\d3d11_gpu_device.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d12_gpu_device.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\gpu_device.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\opengl_gpu_device.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan_gpu_device.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d11\stream_buffer.cpp">
<Filter>gpu\d3d11</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d11\texture.cpp">
<Filter>gpu\d3d11</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d11\shader_cache.cpp">
<Filter>gpu\d3d11</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d11\shader_compiler.cpp">
<Filter>gpu\d3d11</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d12\shader_cache.cpp">
<Filter>gpu\d3d12</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d12\staging_texture.cpp">
<Filter>gpu\d3d12</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d12\stream_buffer.cpp">
<Filter>gpu\d3d12</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d12\texture.cpp">
<Filter>gpu\d3d12</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d12\util.cpp">
<Filter>gpu\d3d12</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d12\context.cpp">
<Filter>gpu\d3d12</Filter>
</ClCompile>
<ClCompile Include="gpu\d3d12\descriptor_heap_manager.cpp">
<Filter>gpu\d3d12</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\context_egl_wayland.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\context_egl_x11.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\context_glx.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\context_wgl.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\program.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\shader_cache.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\stream_buffer.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\texture.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\x11_window.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\context.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\gl\context_egl.cpp">
<Filter>gpu\gl</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan\stream_buffer.cpp">
<Filter>gpu\vulkan</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan\swap_chain.cpp">
<Filter>gpu\vulkan</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan\texture.cpp">
<Filter>gpu\vulkan</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan\util.cpp">
<Filter>gpu\vulkan</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan\builders.cpp">
<Filter>gpu\vulkan</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan\context.cpp">
<Filter>gpu\vulkan</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan\loader.cpp">
<Filter>gpu\vulkan</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan\shader_cache.cpp">
<Filter>gpu\vulkan</Filter>
</ClCompile>
<ClCompile Include="gpu\vulkan\shader_compiler.cpp">
<Filter>gpu\vulkan</Filter>
</ClCompile>
<ClCompile Include="gpu\postprocessing_chain.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\postprocessing_shader.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\postprocessing_shadergen.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\imgui_impl_dx12.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\imgui_impl_opengl3.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\imgui_impl_vulkan.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\imgui_impl_dx11.cpp">
<Filter>gpu</Filter>
</ClCompile>
<ClCompile Include="gpu\gpu_texture.cpp">
<Filter>gpu</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="types.h" /> <ClInclude Include="types.h" />
@ -86,7 +217,6 @@
<ClInclude Include="gpu_sw.h" /> <ClInclude Include="gpu_sw.h" />
<ClInclude Include="gpu_hw_shadergen.h" /> <ClInclude Include="gpu_hw_shadergen.h" />
<ClInclude Include="gpu_hw_d3d11.h" /> <ClInclude Include="gpu_hw_d3d11.h" />
<ClInclude Include="host_display.h" />
<ClInclude Include="bios.h" /> <ClInclude Include="bios.h" />
<ClInclude Include="cpu_recompiler_types.h" /> <ClInclude Include="cpu_recompiler_types.h" />
<ClInclude Include="cpu_code_cache.h" /> <ClInclude Include="cpu_code_cache.h" />
@ -127,5 +257,171 @@
<ClInclude Include="game_database.h" /> <ClInclude Include="game_database.h" />
<ClInclude Include="input_types.h" /> <ClInclude Include="input_types.h" />
<ClInclude Include="pcdrv.h" /> <ClInclude Include="pcdrv.h" />
<ClInclude Include="gpu\d3d11_gpu_device.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d12_gpu_device.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\gpu_device.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\opengl_gpu_device.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan_gpu_device.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d11\shader_compiler.h">
<Filter>gpu\d3d11</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d11\stream_buffer.h">
<Filter>gpu\d3d11</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d11\texture.h">
<Filter>gpu\d3d11</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d11\shader_cache.h">
<Filter>gpu\d3d11</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d12\shader_cache.h">
<Filter>gpu\d3d12</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d12\staging_texture.h">
<Filter>gpu\d3d12</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d12\stream_buffer.h">
<Filter>gpu\d3d12</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d12\texture.h">
<Filter>gpu\d3d12</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d12\util.h">
<Filter>gpu\d3d12</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d12\context.h">
<Filter>gpu\d3d12</Filter>
</ClInclude>
<ClInclude Include="gpu\d3d12\descriptor_heap_manager.h">
<Filter>gpu\d3d12</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\context_egl_wayland.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\context_egl_x11.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\context_glx.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\context_wgl.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\loader.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\program.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\shader_cache.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\stream_buffer.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\texture.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\x11_window.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\context.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\context_agl.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\gl\context_egl.h">
<Filter>gpu\gl</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\stream_buffer.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\swap_chain.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\texture.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\util.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\builders.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\context.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\entry_points.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\loader.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\shader_cache.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\vulkan\shader_compiler.h">
<Filter>gpu\vulkan</Filter>
</ClInclude>
<ClInclude Include="gpu\postprocessing_chain.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\postprocessing_shader.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\postprocessing_shadergen.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\imgui_impl_dx12.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\imgui_impl_opengl3.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\imgui_impl_vulkan.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\imgui_impl_dx11.h">
<Filter>gpu</Filter>
</ClInclude>
<ClInclude Include="gpu\gpu_texture.h">
<Filter>gpu</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="gpu">
<UniqueIdentifier>{7b18fac1-ee2b-4816-8537-eb8f32d40ada}</UniqueIdentifier>
</Filter>
<Filter Include="gpu\d3d11">
<UniqueIdentifier>{f5b7a4af-72c7-406f-b787-9036115c3580}</UniqueIdentifier>
</Filter>
<Filter Include="gpu\d3d12">
<UniqueIdentifier>{17c2f89b-5cf4-4d3a-9343-a03c1c668b85}</UniqueIdentifier>
</Filter>
<Filter Include="gpu\gl">
<UniqueIdentifier>{e2aeacc6-65aa-4110-bef9-5f3e1fc0470e}</UniqueIdentifier>
</Filter>
<Filter Include="gpu\vulkan">
<UniqueIdentifier>{e4809e3b-2adc-440a-82df-044a408409b3}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="gpu\gl\context_agl.mm">
<Filter>gpu\gl</Filter>
</None>
<None Include="gpu\vulkan\entry_points.inl">
<Filter>gpu\vulkan</Filter>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -7,8 +7,8 @@
#include "common/log.h" #include "common/log.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "dma.h" #include "dma.h"
#include "gpu/gpu_device.h"
#include "host.h" #include "host.h"
#include "host_display.h"
#include "imgui.h" #include "imgui.h"
#include "interrupt_controller.h" #include "interrupt_controller.h"
#include "settings.h" #include "settings.h"

View File

@ -17,7 +17,7 @@
class StateWrapper; class StateWrapper;
class HostDisplay; class GPUDevice;
class GPUTexture; class GPUTexture;
class TimingEvent; class TimingEvent;

View File

@ -2,9 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "shader_cache.h" #include "shader_cache.h"
#include "../file_system.h" #include "common/file_system.h"
#include "../log.h" #include "common/log.h"
#include "../md5_digest.h" #include "common/md5_digest.h"
#include "shader_compiler.h" #include "shader_compiler.h"
#include <d3dcompiler.h> #include <d3dcompiler.h>
Log_SetChannel(D3D11::ShaderCache); Log_SetChannel(D3D11::ShaderCache);

View File

@ -2,9 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../hash_combine.h" #include "common/hash_combine.h"
#include "../types.h" #include "common/types.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include "shader_compiler.h" #include "shader_compiler.h"
#include <cstdio> #include <cstdio>
#include <d3d11.h> #include <d3d11.h>

View File

@ -1,9 +1,9 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "shader_compiler.h" #include "shader_compiler.h"
#include "../log.h" #include "common/log.h"
#include "../string_util.h" #include "common/string_util.h"
#include <array> #include <array>
#include <d3dcompiler.h> #include <d3dcompiler.h>
#include <fstream> #include <fstream>

View File

@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../windows_headers.h" #include "common/windows_headers.h"
#include <d3d11.h> #include <d3d11.h>
#include <string_view> #include <string_view>
#include <type_traits> #include <type_traits>

View File

@ -2,9 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "stream_buffer.h" #include "stream_buffer.h"
#include "../align.h" #include "common/align.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
Log_SetChannel(D3D11); Log_SetChannel(D3D11);
namespace D3D11 { namespace D3D11 {

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include <d3d11.h> #include <d3d11.h>
#include <wrl/client.h> #include <wrl/client.h>
@ -26,7 +26,7 @@ public:
bool Create(ID3D11Device* device, D3D11_BIND_FLAG bind_flags, u32 size); bool Create(ID3D11Device* device, D3D11_BIND_FLAG bind_flags, u32 size);
void Adopt(ComPtr<ID3D11Buffer> buffer); void Adopt(ComPtr<ID3D11Buffer> buffer);
void Release(); void Release();
struct MappingResult struct MappingResult
{ {
void* pointer; void* pointer;
@ -44,4 +44,4 @@ private:
u32 m_position; u32 m_position;
bool m_use_map_no_overwrite = false; bool m_use_map_no_overwrite = false;
}; };
} // namespace GL } // namespace D3D11

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "texture.h" #include "texture.h"
#include "../log.h" #include "common/log.h"
#include <array> #include <array>
Log_SetChannel(D3D11); Log_SetChannel(D3D11);

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include "../gpu_texture.h" #include "../gpu_texture.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include <d3d11.h> #include <d3d11.h>
#include <wrl/client.h> #include <wrl/client.h>

View File

@ -1,16 +1,15 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // 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/assert.h"
#include "common/d3d11/shader_cache.h"
#include "common/d3d11/shader_compiler.h"
#include "common/log.h" #include "common/log.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "common_host.h" #include "d3d11/shader_cache.h"
#include "core/host_settings.h" #include "d3d11/shader_compiler.h"
#include "core/settings.h"
#include "core/shader_cache_version.h"
#include "display_ps.hlsl.h" #include "display_ps.hlsl.h"
#include "display_ps_alpha.hlsl.h" #include "display_ps_alpha.hlsl.h"
#include "display_vs.hlsl.h" #include "display_vs.hlsl.h"
@ -19,16 +18,16 @@
#include "postprocessing_shadergen.h" #include "postprocessing_shadergen.h"
#include <array> #include <array>
#include <dxgi1_5.h> #include <dxgi1_5.h>
Log_SetChannel(D3D11HostDisplay); Log_SetChannel(D3D11GPUDevice);
#pragma comment(lib, "d3d11.lib") #pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib") #pragma comment(lib, "dxgi.lib")
static constexpr std::array<float, 4> s_clear_color = {}; static constexpr std::array<float, 4> s_clear_color = {};
D3D11HostDisplay::D3D11HostDisplay() = default; D3D11GPUDevice::D3D11GPUDevice() = default;
D3D11HostDisplay::~D3D11HostDisplay() D3D11GPUDevice::~D3D11GPUDevice()
{ {
DestroyStagingBuffer(); DestroyStagingBuffer();
DestroyResources(); DestroyResources();
@ -37,34 +36,34 @@ D3D11HostDisplay::~D3D11HostDisplay()
m_device.Reset(); m_device.Reset();
} }
RenderAPI D3D11HostDisplay::GetRenderAPI() const RenderAPI D3D11GPUDevice::GetRenderAPI() const
{ {
return RenderAPI::D3D11; return RenderAPI::D3D11;
} }
void* D3D11HostDisplay::GetDevice() const void* D3D11GPUDevice::GetDevice() const
{ {
return m_device.Get(); return m_device.Get();
} }
void* D3D11HostDisplay::GetContext() const void* D3D11GPUDevice::GetContext() const
{ {
return m_context.Get(); return m_context.Get();
} }
bool D3D11HostDisplay::HasDevice() const bool D3D11GPUDevice::HasDevice() const
{ {
return static_cast<bool>(m_device); return static_cast<bool>(m_device);
} }
bool D3D11HostDisplay::HasSurface() const bool D3D11GPUDevice::HasSurface() const
{ {
return static_cast<bool>(m_swap_chain); return static_cast<bool>(m_swap_chain);
} }
std::unique_ptr<GPUTexture> D3D11HostDisplay::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, std::unique_ptr<GPUTexture> D3D11GPUDevice::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Format format, const void* data, GPUTexture::Format format, const void* data, u32 data_stride,
u32 data_stride, bool dynamic /* = false */) bool dynamic /* = false */)
{ {
std::unique_ptr<D3D11::Texture> tex(std::make_unique<D3D11::Texture>()); std::unique_ptr<D3D11::Texture> tex(std::make_unique<D3D11::Texture>());
if (!tex->Create(m_device.Get(), width, height, layers, levels, samples, format, D3D11_BIND_SHADER_RESOURCE, data, if (!tex->Create(m_device.Get(), width, height, layers, levels, samples, format, D3D11_BIND_SHADER_RESOURCE, data,
@ -76,7 +75,7 @@ std::unique_ptr<GPUTexture> D3D11HostDisplay::CreateTexture(u32 width, u32 heigh
return tex; 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<D3D11::Texture*>(texture); D3D11::Texture* tex = static_cast<D3D11::Texture*>(texture);
if (!tex->IsDynamic() || tex->GetWidth() != width || tex->GetHeight() != height) if (!tex->IsDynamic() || tex->GetWidth() != width || tex->GetHeight() != height)
@ -95,26 +94,26 @@ bool D3D11HostDisplay::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 he
return true; 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<D3D11::Texture*>(texture); D3D11::Texture* tex = static_cast<D3D11::Texture*>(texture);
m_context->Unmap(tex->GetD3DTexture(), 0); m_context->Unmap(tex->GetD3DTexture(), 0);
} }
bool D3D11HostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, bool D3D11GPUDevice::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data,
u32 pitch) u32 pitch)
{ {
D3D11::Texture* tex = static_cast<D3D11::Texture*>(texture); D3D11::Texture* tex = static_cast<D3D11::Texture*>(texture);
if (tex->IsDynamic()) 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); 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); m_context->UpdateSubresource(tex->GetD3DTexture(), 0, &dst_box, data, pitch, pitch * height);
return true; return true;
} }
bool D3D11HostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, bool D3D11GPUDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data,
u32 out_data_stride) u32 out_data_stride)
{ {
const D3D11::Texture* tex = static_cast<const D3D11::Texture*>(texture); const D3D11::Texture* tex = static_cast<const D3D11::Texture*>(texture);
if (!CheckStagingBufferSize(width, height, tex->GetDXGIFormat())) if (!CheckStagingBufferSize(width, height, tex->GetDXGIFormat()))
@ -138,7 +137,7 @@ bool D3D11HostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 wi
return true; 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 && if (m_readback_staging_texture_width >= width && m_readback_staging_texture_width >= height &&
m_readback_staging_texture_format == format) m_readback_staging_texture_format == format)
@ -157,7 +156,7 @@ bool D3D11HostDisplay::CheckStagingBufferSize(u32 width, u32 height, DXGI_FORMAT
return true; return true;
} }
void D3D11HostDisplay::DestroyStagingBuffer() void D3D11GPUDevice::DestroyStagingBuffer()
{ {
m_readback_staging_texture.Reset(); m_readback_staging_texture.Reset();
m_readback_staging_texture_width = 0; m_readback_staging_texture_width = 0;
@ -165,7 +164,7 @@ void D3D11HostDisplay::DestroyStagingBuffer()
m_readback_staging_texture_format = DXGI_FORMAT_UNKNOWN; 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); const DXGI_FORMAT dfmt = D3D11::Texture::GetDXGIFormat(format);
if (dfmt == DXGI_FORMAT_UNKNOWN) 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)); 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()) 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; m_vsync_enabled = enabled;
} }
bool D3D11HostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) bool D3D11GPUDevice::CreateDevice(const WindowInfo& wi, bool vsync)
{ {
UINT create_flags = 0; UINT create_flags = 0;
if (g_settings.gpu_use_debug_device) if (g_settings.gpu_use_debug_device)
@ -320,7 +319,7 @@ bool D3D11HostDisplay::CreateDevice(const WindowInfo& wi, bool vsync)
return true; return true;
} }
bool D3D11HostDisplay::SetupDevice() bool D3D11GPUDevice::SetupDevice()
{ {
if (!CreateResources()) if (!CreateResources())
return false; return false;
@ -328,17 +327,17 @@ bool D3D11HostDisplay::SetupDevice()
return true; return true;
} }
bool D3D11HostDisplay::MakeCurrent() bool D3D11GPUDevice::MakeCurrent()
{ {
return true; return true;
} }
bool D3D11HostDisplay::DoneCurrent() bool D3D11GPUDevice::DoneCurrent()
{ {
return true; return true;
} }
bool D3D11HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) bool D3D11GPUDevice::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode)
{ {
HRESULT hr; HRESULT hr;
@ -408,7 +407,7 @@ bool D3D11HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode)
return CreateSwapChainRTV(); return CreateSwapChainRTV();
} }
bool D3D11HostDisplay::CreateSwapChainRTV() bool D3D11GPUDevice::CreateSwapChainRTV()
{ {
ComPtr<ID3D11Texture2D> backbuffer; ComPtr<ID3D11Texture2D> backbuffer;
HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(backbuffer.GetAddressOf())); HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(backbuffer.GetAddressOf()));
@ -453,7 +452,7 @@ bool D3D11HostDisplay::CreateSwapChainRTV()
return true; return true;
} }
bool D3D11HostDisplay::ChangeWindow(const WindowInfo& new_wi) bool D3D11GPUDevice::ChangeWindow(const WindowInfo& new_wi)
{ {
DestroySurface(); DestroySurface();
@ -461,7 +460,7 @@ bool D3D11HostDisplay::ChangeWindow(const WindowInfo& new_wi)
return CreateSwapChain(nullptr); return CreateSwapChain(nullptr);
} }
void D3D11HostDisplay::DestroySurface() void D3D11GPUDevice::DestroySurface()
{ {
m_window_info.SetSurfaceless(); m_window_info.SetSurfaceless();
if (IsFullscreen()) if (IsFullscreen())
@ -471,7 +470,7 @@ void D3D11HostDisplay::DestroySurface()
m_swap_chain.Reset(); 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) if (!m_swap_chain)
return; 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"); Panic("Failed to recreate swap chain RTV after resize");
} }
bool D3D11HostDisplay::SupportsFullscreen() const bool D3D11GPUDevice::SupportsFullscreen() const
{ {
return true; return true;
} }
bool D3D11HostDisplay::IsFullscreen() bool D3D11GPUDevice::IsFullscreen()
{ {
BOOL is_fullscreen = FALSE; BOOL is_fullscreen = FALSE;
return (m_swap_chain && SUCCEEDED(m_swap_chain->GetFullscreenState(&is_fullscreen, nullptr)) && is_fullscreen); 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) if (!m_swap_chain)
return false; return false;
@ -560,7 +559,7 @@ bool D3D11HostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, flo
return true; return true;
} }
bool D3D11HostDisplay::CreateResources() bool D3D11GPUDevice::CreateResources()
{ {
HRESULT hr; HRESULT hr;
@ -631,9 +630,9 @@ bool D3D11HostDisplay::CreateResources()
return true; return true;
} }
void D3D11HostDisplay::DestroyResources() void D3D11GPUDevice::DestroyResources()
{ {
HostDisplay::DestroyResources(); GPUDevice::DestroyResources();
m_post_processing_chain.ClearStages(); m_post_processing_chain.ClearStages();
m_post_processing_input_texture.Destroy(); m_post_processing_input_texture.Destroy();
@ -651,23 +650,23 @@ void D3D11HostDisplay::DestroyResources()
m_display_rasterizer_state.Reset(); m_display_rasterizer_state.Reset();
} }
bool D3D11HostDisplay::CreateImGuiContext() bool D3D11GPUDevice::CreateImGuiContext()
{ {
return ImGui_ImplDX11_Init(m_device.Get(), m_context.Get()); return ImGui_ImplDX11_Init(m_device.Get(), m_context.Get());
} }
void D3D11HostDisplay::DestroyImGuiContext() void D3D11GPUDevice::DestroyImGuiContext()
{ {
ImGui_ImplDX11_Shutdown(); ImGui_ImplDX11_Shutdown();
} }
bool D3D11HostDisplay::UpdateImGuiFontTexture() bool D3D11GPUDevice::UpdateImGuiFontTexture()
{ {
ImGui_ImplDX11_CreateFontsTexture(); ImGui_ImplDX11_CreateFontsTexture();
return true; return true;
} }
bool D3D11HostDisplay::Render(bool skip_present) bool D3D11GPUDevice::Render(bool skip_present)
{ {
if (skip_present || !m_swap_chain) if (skip_present || !m_swap_chain)
{ {
@ -705,8 +704,8 @@ bool D3D11HostDisplay::Render(bool skip_present)
return true; return true;
} }
bool D3D11HostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rectangle<s32>& draw_rect, bool D3D11GPUDevice::RenderScreenshot(u32 width, u32 height, const Common::Rectangle<s32>& draw_rect,
std::vector<u32>* out_pixels, u32* out_stride, GPUTexture::Format* out_format) std::vector<u32>* out_pixels, u32* out_stride, GPUTexture::Format* out_format)
{ {
static constexpr GPUTexture::Format hdformat = GPUTexture::Format::RGBA8; static constexpr GPUTexture::Format hdformat = GPUTexture::Format::RGBA8;
@ -747,13 +746,13 @@ bool D3D11HostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rec
return true; return true;
} }
void D3D11HostDisplay::RenderImGui() void D3D11GPUDevice::RenderImGui()
{ {
ImGui::Render(); ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
} }
void D3D11HostDisplay::RenderDisplay() void D3D11GPUDevice::RenderDisplay()
{ {
const auto [left, top, width, height] = CalculateDrawRect(GetWindowWidth(), GetWindowHeight()); const auto [left, top, width, height] = CalculateDrawRect(GetWindowWidth(), GetWindowHeight());
@ -777,9 +776,9 @@ void D3D11HostDisplay::RenderDisplay()
IsUsingLinearFiltering()); IsUsingLinearFiltering());
} }
void D3D11HostDisplay::RenderDisplay(s32 left, s32 top, s32 width, s32 height, D3D11::Texture* texture, 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_x, s32 texture_view_y, s32 texture_view_width,
s32 texture_view_height, bool linear_filter) s32 texture_view_height, bool linear_filter)
{ {
m_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); m_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
m_context->VSSetShader(m_display_vertex_shader.Get(), nullptr, 0); 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); m_context->Draw(3, 0);
} }
void D3D11HostDisplay::RenderSoftwareCursor() void D3D11GPUDevice::RenderSoftwareCursor()
{ {
if (!HasSoftwareCursor()) if (!HasSoftwareCursor())
return; return;
@ -819,7 +818,7 @@ void D3D11HostDisplay::RenderSoftwareCursor()
RenderSoftwareCursor(left, top, width, height, m_cursor_texture.get()); 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->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
m_context->VSSetShader(m_display_vertex_shader.Get(), nullptr, 0); 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); m_context->Draw(3, 0);
} }
HostDisplay::AdapterAndModeList D3D11HostDisplay::StaticGetAdapterAndModeList() GPUDevice::AdapterAndModeList D3D11GPUDevice::StaticGetAdapterAndModeList()
{ {
ComPtr<IDXGIFactory> dxgi_factory; ComPtr<IDXGIFactory> dxgi_factory;
HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf())); HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf()));
@ -853,7 +852,7 @@ HostDisplay::AdapterAndModeList D3D11HostDisplay::StaticGetAdapterAndModeList()
return GetAdapterAndModeList(dxgi_factory.Get()); return GetAdapterAndModeList(dxgi_factory.Get());
} }
HostDisplay::AdapterAndModeList D3D11HostDisplay::GetAdapterAndModeList(IDXGIFactory* dxgi_factory) GPUDevice::AdapterAndModeList D3D11GPUDevice::GetAdapterAndModeList(IDXGIFactory* dxgi_factory)
{ {
AdapterAndModeList adapter_info; AdapterAndModeList adapter_info;
ComPtr<IDXGIAdapter> current_adapter; ComPtr<IDXGIAdapter> current_adapter;
@ -921,12 +920,12 @@ HostDisplay::AdapterAndModeList D3D11HostDisplay::GetAdapterAndModeList(IDXGIFac
return adapter_info; return adapter_info;
} }
HostDisplay::AdapterAndModeList D3D11HostDisplay::GetAdapterAndModeList() GPUDevice::AdapterAndModeList D3D11GPUDevice::GetAdapterAndModeList()
{ {
return GetAdapterAndModeList(m_dxgi_factory.Get()); 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()) if (config.empty())
{ {
@ -983,7 +982,7 @@ bool D3D11HostDisplay::SetPostProcessingChain(const std::string_view& config)
return true; 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()); DebugAssert(!m_post_processing_stages.empty());
@ -1014,10 +1013,10 @@ bool D3D11HostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 ta
return true; return true;
} }
void D3D11HostDisplay::ApplyPostProcessingChain(ID3D11RenderTargetView* final_target, s32 final_left, s32 final_top, void D3D11GPUDevice::ApplyPostProcessingChain(ID3D11RenderTargetView* final_target, s32 final_left, s32 final_top,
s32 final_width, s32 final_height, D3D11::Texture* texture, s32 final_width, s32 final_height, D3D11::Texture* texture,
s32 texture_view_x, s32 texture_view_y, s32 texture_view_width, s32 texture_view_x, s32 texture_view_y, s32 texture_view_width,
s32 texture_view_height, u32 target_width, u32 target_height) s32 texture_view_height, u32 target_width, u32 target_height)
{ {
if (!CheckPostProcessingRenderTargets(target_width, 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); m_context->PSSetShaderResources(0, 1, &null_srv);
} }
bool D3D11HostDisplay::CreateTimestampQueries() bool D3D11GPUDevice::CreateTimestampQueries()
{ {
for (u32 i = 0; i < NUM_TIMESTAMP_QUERIES; i++) for (u32 i = 0; i < NUM_TIMESTAMP_QUERIES; i++)
{ {
@ -1094,7 +1093,7 @@ bool D3D11HostDisplay::CreateTimestampQueries()
return true; return true;
} }
void D3D11HostDisplay::DestroyTimestampQueries() void D3D11GPUDevice::DestroyTimestampQueries()
{ {
if (!m_timestamp_queries[0][0]) if (!m_timestamp_queries[0][0])
return; return;
@ -1109,7 +1108,7 @@ void D3D11HostDisplay::DestroyTimestampQueries()
m_timestamp_query_started = 0; m_timestamp_query_started = 0;
} }
void D3D11HostDisplay::PopTimestampQuery() void D3D11GPUDevice::PopTimestampQuery()
{ {
while (m_waiting_timestamp_queries > 0) 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) if (m_timestamp_query_started || !m_timestamp_queries[0][0] || m_waiting_timestamp_queries == NUM_TIMESTAMP_QUERIES)
return; return;
@ -1165,7 +1164,7 @@ void D3D11HostDisplay::KickTimestampQuery()
m_timestamp_query_started = true; m_timestamp_query_started = true;
} }
bool D3D11HostDisplay::SetGPUTimingEnabled(bool enabled) bool D3D11GPUDevice::SetGPUTimingEnabled(bool enabled)
{ {
if (m_gpu_timing_enabled == enabled) if (m_gpu_timing_enabled == enabled)
return true; return true;
@ -1186,7 +1185,7 @@ bool D3D11HostDisplay::SetGPUTimingEnabled(bool enabled)
} }
} }
float D3D11HostDisplay::GetAndResetAccumulatedGPUTime() float D3D11GPUDevice::GetAndResetAccumulatedGPUTime()
{ {
const float value = m_accumulated_gpu_time; const float value = m_accumulated_gpu_time;
m_accumulated_gpu_time = 0.0f; m_accumulated_gpu_time = 0.0f;

View File

@ -2,13 +2,13 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "common/d3d11/stream_buffer.h"
#include "common/d3d11/texture.h"
#include "common/timer.h" #include "common/timer.h"
#include "common/window_info.h" #include "common/window_info.h"
#include "common/windows_headers.h" #include "common/windows_headers.h"
#include "core/host_display.h" #include "d3d11/stream_buffer.h"
#include "frontend-common/postprocessing_chain.h" #include "d3d11/texture.h"
#include "gpu_device.h"
#include "postprocessing_chain.h"
#include <d3d11.h> #include <d3d11.h>
#include <dxgi.h> #include <dxgi.h>
#include <memory> #include <memory>
@ -17,14 +17,14 @@
#include <vector> #include <vector>
#include <wrl/client.h> #include <wrl/client.h>
class D3D11HostDisplay final : public HostDisplay class D3D11GPUDevice final : public GPUDevice
{ {
public: public:
template<typename T> template<typename T>
using ComPtr = Microsoft::WRL::ComPtr<T>; using ComPtr = Microsoft::WRL::ComPtr<T>;
D3D11HostDisplay(); D3D11GPUDevice();
~D3D11HostDisplay(); ~D3D11GPUDevice();
RenderAPI GetRenderAPI() const override; RenderAPI GetRenderAPI() const override;
void* GetDevice() const override; void* GetDevice() const override;

View File

@ -1,11 +1,11 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
// Parts originally from Dolphin Emulator, also written by myself. // Parts originally from Dolphin Emulator, also written by myself.
#include "context.h" #include "context.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "../scoped_guard.h" #include "common/scoped_guard.h"
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <dxgi1_2.h> #include <dxgi1_2.h>

View File

@ -1,11 +1,11 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
// Parts originally from Dolphin Emulator, also written by myself. // Parts originally from Dolphin Emulator, also written by myself.
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include "descriptor_heap_manager.h" #include "descriptor_heap_manager.h"
#include "stream_buffer.h" #include "stream_buffer.h"
#include <array> #include <array>

View File

@ -3,8 +3,8 @@
// Parts originally from Dolphin Emulator, also written by myself. // Parts originally from Dolphin Emulator, also written by myself.
#include "descriptor_heap_manager.h" #include "descriptor_heap_manager.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "context.h" #include "context.h"
Log_SetChannel(DescriptorHeapManager); Log_SetChannel(DescriptorHeapManager);

View File

@ -4,8 +4,8 @@
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include <bitset> #include <bitset>
#include <d3d12.h> #include <d3d12.h>
#include <map> #include <map>

View File

@ -3,9 +3,9 @@
#include "shader_cache.h" #include "shader_cache.h"
#include "../d3d11/shader_compiler.h" #include "../d3d11/shader_compiler.h"
#include "../file_system.h" #include "common/file_system.h"
#include "../log.h" #include "common/log.h"
#include "../md5_digest.h" #include "common/md5_digest.h"
#include <d3dcompiler.h> #include <d3dcompiler.h>
Log_SetChannel(D3D12::ShaderCache); Log_SetChannel(D3D12::ShaderCache);

View File

@ -2,9 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../hash_combine.h" #include "common/hash_combine.h"
#include "../types.h" #include "common/types.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include <cstdio> #include <cstdio>
#include <d3d12.h> #include <d3d12.h>
#include <string_view> #include <string_view>

View File

@ -2,9 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "staging_texture.h" #include "staging_texture.h"
#include "../align.h" #include "common/align.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "context.h" #include "context.h"
#include "util.h" #include "util.h"
Log_SetChannel(D3D12); Log_SetChannel(D3D12);

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include <cstring> #include <cstring>
#include <d3d12.h> #include <d3d12.h>
#include <wrl/client.h> #include <wrl/client.h>
@ -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, void CopyFromTexture(ID3D12Resource* src_texture, u32 src_subresource, u32 src_x, u32 src_y, u32 dst_x, u32 dst_y,
u32 width, u32 height); u32 width, u32 height);
bool ReadPixels(u32 x, u32 y, u32 width, u32 height, void* data, u32 row_pitch); 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); bool WritePixels(u32 x, u32 y, u32 width, u32 height, const void* data, u32 row_pitch);

View File

@ -1,11 +1,11 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
// Parts originally from Dolphin Emulator, also written by myself. // Parts originally from Dolphin Emulator, also written by myself.
#include "stream_buffer.h" #include "stream_buffer.h"
#include "../align.h" #include "common/align.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "context.h" #include "context.h"
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>

View File

@ -1,11 +1,11 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
// Parts originally from Dolphin Emulator, also written by myself. // Parts originally from Dolphin Emulator, also written by myself.
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include <d3d12.h> #include <d3d12.h>
#include <deque> #include <deque>
#include <utility> #include <utility>

View File

@ -2,9 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "texture.h" #include "texture.h"
#include "../align.h" #include "common/align.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "context.h" #include "context.h"
#include "staging_texture.h" #include "staging_texture.h"
#include "stream_buffer.h" #include "stream_buffer.h"

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include "../gpu_texture.h" #include "../gpu_texture.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include "descriptor_heap_manager.h" #include "descriptor_heap_manager.h"
#include <d3d12.h> #include <d3d12.h>
#include <wrl/client.h> #include <wrl/client.h>

View File

@ -2,10 +2,10 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "util.h" #include "util.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "../string.h" #include "common/string.h"
#include "../string_util.h" #include "common/string_util.h"
#include "context.h" #include "context.h"
#include "shader_cache.h" #include "shader_cache.h"
#include <cstdarg> #include <cstdarg>

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "../windows_headers.h" #include "common/windows_headers.h"
#include <array> #include <array>
#include <d3d12.h> #include <d3d12.h>
#include <wrl/client.h> #include <wrl/client.h>

View File

@ -1,30 +1,30 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // 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/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/log.h"
#include "common/string_util.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.hlsl.h"
#include "display_ps_alpha.hlsl.h" #include "display_ps_alpha.hlsl.h"
#include "display_vs.hlsl.h" #include "display_vs.hlsl.h"
#include "frontend-common/postprocessing_shadergen.h"
#include "imgui.h" #include "imgui.h"
#include "imgui_impl_dx12.h" #include "imgui_impl_dx12.h"
#include "postprocessing_shadergen.h"
#include <array> #include <array>
#include <dxgi1_5.h> #include <dxgi1_5.h>
Log_SetChannel(D3D12HostDisplay); Log_SetChannel(D3D12GPUDevice);
static constexpr const std::array<float, 4> s_clear_color = {0.0f, 0.0f, 0.0f, 1.0f}; static constexpr const std::array<float, 4> 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) if (!g_d3d12_context)
return; return;
@ -35,34 +35,34 @@ D3D12HostDisplay::~D3D12HostDisplay()
g_d3d12_context->Destroy(); g_d3d12_context->Destroy();
} }
RenderAPI D3D12HostDisplay::GetRenderAPI() const RenderAPI D3D12GPUDevice::GetRenderAPI() const
{ {
return RenderAPI::D3D12; return RenderAPI::D3D12;
} }
void* D3D12HostDisplay::GetDevice() const void* D3D12GPUDevice::GetDevice() const
{ {
return g_d3d12_context->GetDevice(); return g_d3d12_context->GetDevice();
} }
void* D3D12HostDisplay::GetContext() const void* D3D12GPUDevice::GetContext() const
{ {
return g_d3d12_context.get(); return g_d3d12_context.get();
} }
bool D3D12HostDisplay::HasDevice() const bool D3D12GPUDevice::HasDevice() const
{ {
return static_cast<bool>(g_d3d12_context); return static_cast<bool>(g_d3d12_context);
} }
bool D3D12HostDisplay::HasSurface() const bool D3D12GPUDevice::HasSurface() const
{ {
return static_cast<bool>(m_swap_chain); return static_cast<bool>(m_swap_chain);
} }
std::unique_ptr<GPUTexture> D3D12HostDisplay::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, std::unique_ptr<GPUTexture> D3D12GPUDevice::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Format format, const void* data, GPUTexture::Format format, const void* data, u32 data_stride,
u32 data_stride, bool dynamic /* = false */) bool dynamic /* = false */)
{ {
const DXGI_FORMAT dformat = D3D12::Texture::GetDXGIFormat(format); const DXGI_FORMAT dformat = D3D12::Texture::GetDXGIFormat(format);
if (dformat == DXGI_FORMAT_UNKNOWN) if (dformat == DXGI_FORMAT_UNKNOWN)
@ -81,24 +81,24 @@ std::unique_ptr<GPUTexture> D3D12HostDisplay::CreateTexture(u32 width, u32 heigh
return tex; 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<D3D12::Texture*>(texture)->BeginStreamUpdate(0, 0, width, height, out_buffer, out_pitch); return static_cast<D3D12::Texture*>(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<D3D12::Texture*>(texture)->EndStreamUpdate(x, y, width, height); static_cast<D3D12::Texture*>(texture)->EndStreamUpdate(x, y, width, height);
} }
bool D3D12HostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, bool D3D12GPUDevice::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data,
u32 pitch) 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, bool D3D12GPUDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data,
u32 out_data_stride) u32 out_data_stride)
{ {
const D3D12::Texture* tex = static_cast<const D3D12::Texture*>(texture); const D3D12::Texture* tex = static_cast<const D3D12::Texture*>(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); 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); const DXGI_FORMAT dfmt = D3D12::Texture::GetDXGIFormat(format);
if (dfmt == DXGI_FORMAT_UNKNOWN) if (dfmt == DXGI_FORMAT_UNKNOWN)
@ -122,7 +122,7 @@ bool D3D12HostDisplay::SupportsTextureFormat(GPUTexture::Format format) const
return g_d3d12_context->SupportsTextureFormat(dfmt); return g_d3d12_context->SupportsTextureFormat(dfmt);
} }
bool D3D12HostDisplay::GetHostRefreshRate(float* refresh_rate) bool D3D12GPUDevice::GetHostRefreshRate(float* refresh_rate)
{ {
if (m_swap_chain && IsFullscreen()) 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; m_vsync_enabled = enabled;
} }
bool D3D12HostDisplay::CreateDevice(const WindowInfo& wi, bool vsync) bool D3D12GPUDevice::CreateDevice(const WindowInfo& wi, bool vsync)
{ {
ComPtr<IDXGIFactory> temp_dxgi_factory; ComPtr<IDXGIFactory> temp_dxgi_factory;
HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(temp_dxgi_factory.GetAddressOf())); HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(temp_dxgi_factory.GetAddressOf()));
@ -213,7 +213,7 @@ bool D3D12HostDisplay::CreateDevice(const WindowInfo& wi, bool vsync)
return true; return true;
} }
bool D3D12HostDisplay::SetupDevice() bool D3D12GPUDevice::SetupDevice()
{ {
if (!CreateResources()) if (!CreateResources())
return false; return false;
@ -221,17 +221,17 @@ bool D3D12HostDisplay::SetupDevice()
return true; return true;
} }
bool D3D12HostDisplay::MakeCurrent() bool D3D12GPUDevice::MakeCurrent()
{ {
return true; return true;
} }
bool D3D12HostDisplay::DoneCurrent() bool D3D12GPUDevice::DoneCurrent()
{ {
return true; return true;
} }
bool D3D12HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) bool D3D12GPUDevice::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode)
{ {
HRESULT hr; HRESULT hr;
@ -284,7 +284,7 @@ bool D3D12HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode)
return CreateSwapChainRTV(); return CreateSwapChainRTV();
} }
bool D3D12HostDisplay::CreateSwapChainRTV() bool D3D12GPUDevice::CreateSwapChainRTV()
{ {
DXGI_SWAP_CHAIN_DESC swap_chain_desc; DXGI_SWAP_CHAIN_DESC swap_chain_desc;
HRESULT hr = m_swap_chain->GetDesc(&swap_chain_desc); HRESULT hr = m_swap_chain->GetDesc(&swap_chain_desc);
@ -335,7 +335,7 @@ bool D3D12HostDisplay::CreateSwapChainRTV()
return true; return true;
} }
void D3D12HostDisplay::DestroySwapChainRTVs() void D3D12GPUDevice::DestroySwapChainRTVs()
{ {
for (D3D12::Texture& buffer : m_swap_chain_buffers) for (D3D12::Texture& buffer : m_swap_chain_buffers)
buffer.Destroy(false); buffer.Destroy(false);
@ -343,7 +343,7 @@ void D3D12HostDisplay::DestroySwapChainRTVs()
m_current_swap_chain_buffer = 0; m_current_swap_chain_buffer = 0;
} }
bool D3D12HostDisplay::ChangeWindow(const WindowInfo& new_wi) bool D3D12GPUDevice::ChangeWindow(const WindowInfo& new_wi)
{ {
DestroySurface(); DestroySurface();
@ -351,7 +351,7 @@ bool D3D12HostDisplay::ChangeWindow(const WindowInfo& new_wi)
return CreateSwapChain(nullptr); return CreateSwapChain(nullptr);
} }
void D3D12HostDisplay::DestroySurface() void D3D12GPUDevice::DestroySurface()
{ {
m_window_info.SetSurfaceless(); m_window_info.SetSurfaceless();
@ -365,7 +365,7 @@ void D3D12HostDisplay::DestroySurface()
m_swap_chain.Reset(); 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) if (!m_swap_chain)
return; 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"); Panic("Failed to recreate swap chain RTV after resize");
} }
bool D3D12HostDisplay::SupportsFullscreen() const bool D3D12GPUDevice::SupportsFullscreen() const
{ {
return true; return true;
} }
bool D3D12HostDisplay::IsFullscreen() bool D3D12GPUDevice::IsFullscreen()
{ {
BOOL is_fullscreen = FALSE; BOOL is_fullscreen = FALSE;
return (m_swap_chain && SUCCEEDED(m_swap_chain->GetFullscreenState(&is_fullscreen, nullptr)) && is_fullscreen); 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) if (!m_swap_chain)
return false; return false;
@ -458,12 +458,12 @@ bool D3D12HostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, flo
return true; return true;
} }
HostDisplay::AdapterAndModeList D3D12HostDisplay::GetAdapterAndModeList() GPUDevice::AdapterAndModeList D3D12GPUDevice::GetAdapterAndModeList()
{ {
return GetAdapterAndModeList(m_dxgi_factory.Get()); return GetAdapterAndModeList(m_dxgi_factory.Get());
} }
bool D3D12HostDisplay::CreateResources() bool D3D12GPUDevice::CreateResources()
{ {
D3D12::RootSignatureBuilder rsbuilder; D3D12::RootSignatureBuilder rsbuilder;
rsbuilder.Add32BitConstants(0, 4, D3D12_SHADER_VISIBILITY_VERTEX); rsbuilder.Add32BitConstants(0, 4, D3D12_SHADER_VISIBILITY_VERTEX);
@ -543,9 +543,9 @@ bool D3D12HostDisplay::CreateResources()
return true; return true;
} }
void D3D12HostDisplay::DestroyResources() void D3D12GPUDevice::DestroyResources()
{ {
HostDisplay::DestroyResources(); GPUDevice::DestroyResources();
m_post_processing_cbuffer.Destroy(false); m_post_processing_cbuffer.Destroy(false);
m_post_processing_chain.ClearStages(); m_post_processing_chain.ClearStages();
@ -563,7 +563,7 @@ void D3D12HostDisplay::DestroyResources()
m_display_root_signature.Reset(); m_display_root_signature.Reset();
} }
bool D3D12HostDisplay::CreateImGuiContext() bool D3D12GPUDevice::CreateImGuiContext()
{ {
ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width); ImGui::GetIO().DisplaySize.x = static_cast<float>(m_window_info.surface_width);
ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height); ImGui::GetIO().DisplaySize.y = static_cast<float>(m_window_info.surface_height);
@ -571,19 +571,19 @@ bool D3D12HostDisplay::CreateImGuiContext()
return ImGui_ImplDX12_Init(DXGI_FORMAT_R8G8B8A8_UNORM); return ImGui_ImplDX12_Init(DXGI_FORMAT_R8G8B8A8_UNORM);
} }
void D3D12HostDisplay::DestroyImGuiContext() void D3D12GPUDevice::DestroyImGuiContext()
{ {
g_d3d12_context->WaitForGPUIdle(); g_d3d12_context->WaitForGPUIdle();
ImGui_ImplDX12_Shutdown(); ImGui_ImplDX12_Shutdown();
} }
bool D3D12HostDisplay::UpdateImGuiFontTexture() bool D3D12GPUDevice::UpdateImGuiFontTexture()
{ {
return ImGui_ImplDX12_CreateFontsTexture(); return ImGui_ImplDX12_CreateFontsTexture();
} }
bool D3D12HostDisplay::Render(bool skip_present) bool D3D12GPUDevice::Render(bool skip_present)
{ {
if (skip_present || !m_swap_chain) if (skip_present || !m_swap_chain)
{ {
@ -615,8 +615,8 @@ bool D3D12HostDisplay::Render(bool skip_present)
return true; return true;
} }
bool D3D12HostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rectangle<s32>& draw_rect, bool D3D12GPUDevice::RenderScreenshot(u32 width, u32 height, const Common::Rectangle<s32>& draw_rect,
std::vector<u32>* out_pixels, u32* out_stride, GPUTexture::Format* out_format) std::vector<u32>* out_pixels, u32* out_stride, GPUTexture::Format* out_format)
{ {
static constexpr DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; static constexpr DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM;
static constexpr GPUTexture::Format hdformat = GPUTexture::Format::RGBA8; 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); 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); g_d3d12_context->SetEnableGPUTiming(enabled);
m_gpu_timing_enabled = enabled; m_gpu_timing_enabled = enabled;
return true; return true;
} }
float D3D12HostDisplay::GetAndResetAccumulatedGPUTime() float D3D12GPUDevice::GetAndResetAccumulatedGPUTime()
{ {
return g_d3d12_context->GetAndResetAccumulatedGPUTime(); return g_d3d12_context->GetAndResetAccumulatedGPUTime();
} }
void D3D12HostDisplay::RenderImGui(ID3D12GraphicsCommandList* cmdlist) void D3D12GPUDevice::RenderImGui(ID3D12GraphicsCommandList* cmdlist)
{ {
ImGui::Render(); ImGui::Render();
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData()); 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()); 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()); m_display_texture_view_height, IsUsingLinearFiltering());
} }
void D3D12HostDisplay::RenderDisplay(ID3D12GraphicsCommandList* cmdlist, s32 left, s32 top, s32 width, s32 height, void D3D12GPUDevice::RenderDisplay(ID3D12GraphicsCommandList* cmdlist, s32 left, s32 top, s32 width, s32 height,
D3D12::Texture* texture, s32 texture_view_x, s32 texture_view_y, D3D12::Texture* texture, s32 texture_view_x, s32 texture_view_y,
s32 texture_view_width, s32 texture_view_height, bool linear_filter) s32 texture_view_width, s32 texture_view_height, bool linear_filter)
{ {
const float position_adjust = linear_filter ? 0.5f : 0.0f; const float position_adjust = linear_filter ? 0.5f : 0.0f;
const float size_adjust = linear_filter ? 1.0f : 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); cmdlist->DrawInstanced(3, 1, 0, 0);
} }
void D3D12HostDisplay::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist) void D3D12GPUDevice::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist)
{ {
if (!HasSoftwareCursor()) if (!HasSoftwareCursor())
return; return;
@ -741,8 +741,8 @@ void D3D12HostDisplay::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist)
RenderSoftwareCursor(cmdlist, left, top, width, height, m_cursor_texture.get()); RenderSoftwareCursor(cmdlist, left, top, width, height, m_cursor_texture.get());
} }
void D3D12HostDisplay::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist, s32 left, s32 top, s32 width, void D3D12GPUDevice::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist, s32 left, s32 top, s32 width, s32 height,
s32 height, GPUTexture* texture_handle) GPUTexture* texture_handle)
{ {
const float uniforms[4] = {0.0f, 0.0f, 1.0f, 1.0f}; 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); cmdlist->DrawInstanced(3, 1, 0, 0);
} }
HostDisplay::AdapterAndModeList D3D12HostDisplay::StaticGetAdapterAndModeList() GPUDevice::AdapterAndModeList D3D12GPUDevice::StaticGetAdapterAndModeList()
{ {
ComPtr<IDXGIFactory> dxgi_factory; ComPtr<IDXGIFactory> dxgi_factory;
HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf())); HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf()));
@ -768,7 +768,7 @@ HostDisplay::AdapterAndModeList D3D12HostDisplay::StaticGetAdapterAndModeList()
return GetAdapterAndModeList(dxgi_factory.Get()); return GetAdapterAndModeList(dxgi_factory.Get());
} }
HostDisplay::AdapterAndModeList D3D12HostDisplay::GetAdapterAndModeList(IDXGIFactory* dxgi_factory) GPUDevice::AdapterAndModeList D3D12GPUDevice::GetAdapterAndModeList(IDXGIFactory* dxgi_factory)
{ {
AdapterAndModeList adapter_info; AdapterAndModeList adapter_info;
ComPtr<IDXGIAdapter> current_adapter; ComPtr<IDXGIAdapter> current_adapter;
@ -836,19 +836,19 @@ HostDisplay::AdapterAndModeList D3D12HostDisplay::GetAdapterAndModeList(IDXGIFac
return adapter_info; 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)), : pipeline(std::move(move.pipeline)), output_texture(std::move(move.output_texture)),
uniforms_size(move.uniforms_size) uniforms_size(move.uniforms_size)
{ {
move.uniforms_size = 0; move.uniforms_size = 0;
} }
D3D12HostDisplay::PostProcessingStage::~PostProcessingStage() D3D12GPUDevice::PostProcessingStage::~PostProcessingStage()
{ {
output_texture.Destroy(true); 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); g_d3d12_context->ExecuteCommandList(true);
@ -933,7 +933,7 @@ bool D3D12HostDisplay::SetPostProcessingChain(const std::string_view& config)
return true; 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()); DebugAssert(!m_post_processing_stages.empty());
@ -971,11 +971,11 @@ bool D3D12HostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 ta
return true; return true;
} }
void D3D12HostDisplay::ApplyPostProcessingChain(ID3D12GraphicsCommandList* cmdlist, D3D12::Texture* final_target, void D3D12GPUDevice::ApplyPostProcessingChain(ID3D12GraphicsCommandList* cmdlist, D3D12::Texture* final_target,
s32 final_left, s32 final_top, s32 final_width, s32 final_height, s32 final_left, s32 final_top, s32 final_width, s32 final_height,
D3D12::Texture* texture, s32 texture_view_x, s32 texture_view_y, D3D12::Texture* texture, s32 texture_view_x, s32 texture_view_y,
s32 texture_view_width, s32 texture_view_height, u32 target_width, s32 texture_view_width, s32 texture_view_height, u32 target_width,
u32 target_height) u32 target_height)
{ {
if (!CheckPostProcessingRenderTargets(target_width, target_height)) if (!CheckPostProcessingRenderTargets(target_width, target_height))
{ {

View File

@ -2,14 +2,14 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #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/timer.h"
#include "common/window_info.h" #include "common/window_info.h"
#include "common/windows_headers.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 "postprocessing_chain.h"
#include <d3d12.h> #include <d3d12.h>
#include <dxgi.h> #include <dxgi.h>
@ -19,14 +19,14 @@
#include <vector> #include <vector>
#include <wrl/client.h> #include <wrl/client.h>
class D3D12HostDisplay final : public HostDisplay class D3D12GPUDevice final : public GPUDevice
{ {
public: public:
template<typename T> template<typename T>
using ComPtr = Microsoft::WRL::ComPtr<T>; using ComPtr = Microsoft::WRL::ComPtr<T>;
D3D12HostDisplay(); D3D12GPUDevice();
~D3D12HostDisplay(); ~D3D12GPUDevice();
RenderAPI GetRenderAPI() const override; RenderAPI GetRenderAPI() const override;
void* GetDevice() const override; void* GetDevice() const override;

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "context.h" #include "context.h"
#include "../log.h" #include "common/log.h"
#include "loader.h" #include "loader.h"
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
@ -17,32 +17,20 @@ Log_SetChannel(GL::Context);
#include "context_wgl.h" #include "context_wgl.h"
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include "context_agl.h" #include "context_agl.h"
#endif #else
#ifdef USE_EGL #ifdef USE_EGL
#if defined(USE_WAYLAND) || defined(USE_GBM) || defined(USE_FBDEV) || defined(USE_X11) #ifdef USE_WAYLAND
#if defined(USE_WAYLAND)
#include "context_egl_wayland.h" #include "context_egl_wayland.h"
#endif #endif
#if defined(USE_GBM) #ifdef USE_X11
#include "context_egl_gbm.h"
#endif
#if defined(USE_FBDEV)
#include "context_egl_fbdev.h"
#endif
#if defined(USE_X11)
#include "context_egl_x11.h" #include "context_egl_x11.h"
#endif #endif
#elif defined(ANDROID)
#include "context_egl_android.h"
#else
#error Unknown EGL platform
#endif
#endif #endif
#ifdef USE_GLX #ifdef USE_GLX
#include "context_glx.h" #include "context_glx.h"
#endif #endif
#endif
namespace GL { namespace GL {
@ -131,12 +119,7 @@ std::unique_ptr<GL::Context> Context::Create(const WindowInfo& wi, const Version
context = ContextWGL::Create(wi, versions_to_try, num_versions_to_try); context = ContextWGL::Create(wi, versions_to_try, num_versions_to_try);
#elif defined(__APPLE__) #elif defined(__APPLE__)
context = ContextAGL::Create(wi, versions_to_try, num_versions_to_try); context = ContextAGL::Create(wi, versions_to_try, num_versions_to_try);
#elif defined(ANDROID) #else
#ifdef USE_EGL
context = ContextEGLAndroid::Create(wi, versions_to_try, num_versions_to_try);
#endif
#endif
#if defined(USE_X11) #if defined(USE_X11)
if (wi.type == WindowInfo::Type::X11) if (wi.type == WindowInfo::Type::X11)
{ {
@ -156,15 +139,6 @@ std::unique_ptr<GL::Context> Context::Create(const WindowInfo& wi, const Version
if (wi.type == WindowInfo::Type::Wayland) if (wi.type == WindowInfo::Type::Wayland)
context = ContextEGLWayland::Create(wi, versions_to_try, num_versions_to_try); context = ContextEGLWayland::Create(wi, versions_to_try, num_versions_to_try);
#endif #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 #endif
if (!context) if (!context)

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "../window_info.h" #include "common/window_info.h"
#include <array> #include <array>
#include <memory> #include <memory>
#include <vector> #include <vector>

View File

@ -1,10 +1,10 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "context_wgl.h" #include "context_wgl.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "../scoped_guard.h" #include "common/scoped_guard.h"
#include "loader.h" #include "loader.h"
Log_SetChannel(GL::ContextWGL); Log_SetChannel(GL::ContextWGL);

View File

@ -1,9 +1,8 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../windows_headers.h" #include "common/windows_headers.h"
#include "context.h" #include "context.h"
#include "glad_wgl.h" #include "glad_wgl.h"
#include "loader.h" #include "loader.h"

View File

@ -5,7 +5,7 @@
// Fix glad.h including windows.h // Fix glad.h including windows.h
#ifdef _WIN32 #ifdef _WIN32
#include "../windows_headers.h" #include "common/windows_headers.h"
#endif #endif
#include "glad.h" #include "glad.h"

View File

@ -2,9 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "program.h" #include "program.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "../string_util.h" #include "common/string_util.h"
#include <array> #include <array>
#include <fstream> #include <fstream>
Log_SetChannel(GL); Log_SetChannel(GL);

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "loader.h" #include "loader.h"
#include <string_view> #include <string_view>
#include <vector> #include <vector>

View File

@ -2,11 +2,11 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "shader_cache.h" #include "shader_cache.h"
#include "../file_system.h" #include "common/file_system.h"
#include "../log.h" #include "common/log.h"
#include "../md5_digest.h" #include "common/md5_digest.h"
#include "../path.h" #include "common/path.h"
#include "../string_util.h" #include "common/string_util.h"
Log_SetChannel(GL::ShaderCache); Log_SetChannel(GL::ShaderCache);
#pragma pack(push, 1) #pragma pack(push, 1)

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../hash_combine.h" #include "common/hash_combine.h"
#include "../types.h" #include "common/types.h"
#include "program.h" #include "program.h"
#include <cstdio> #include <cstdio>
#include <functional> #include <functional>

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "stream_buffer.h" #include "stream_buffer.h"
#include "../align.h" #include "common/align.h"
#include "../assert.h" #include "common/assert.h"
#include <array> #include <array>
#include <cstdio> #include <cstdio>

View File

@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "loader.h" #include "loader.h"
#include <memory> #include <memory>
#include <tuple> #include <tuple>

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "texture.h" #include "texture.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include <array> #include <array>
#include <limits> #include <limits>
#include <tuple> #include <tuple>

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>

View File

@ -1,14 +1,14 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // 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/align.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/file_system.h" #include "common/file_system.h"
#include "common/log.h" #include "common/log.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "common/timer.h" #include "common/timer.h"
#include "settings.h"
#include "stb_image.h" #include "stb_image.h"
#include "stb_image_resize.h" #include "stb_image_resize.h"
#include "stb_image_write.h" #include "stb_image_write.h"
@ -17,13 +17,13 @@
#include <cstring> #include <cstring>
#include <thread> #include <thread>
#include <vector> #include <vector>
Log_SetChannel(HostDisplay); Log_SetChannel(GPUDevice);
std::unique_ptr<HostDisplay> g_host_display; std::unique_ptr<GPUDevice> g_host_display;
HostDisplay::~HostDisplay() = default; GPUDevice::~GPUDevice() = default;
RenderAPI HostDisplay::GetPreferredAPI() RenderAPI GPUDevice::GetPreferredAPI()
{ {
#ifdef _WIN32 #ifdef _WIN32
return RenderAPI::D3D11; return RenderAPI::D3D11;
@ -32,12 +32,12 @@ RenderAPI HostDisplay::GetPreferredAPI()
#endif #endif
} }
void HostDisplay::DestroyResources() void GPUDevice::DestroyResources()
{ {
m_cursor_texture.reset(); 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; void* map_ptr;
u32 map_pitch; u32 map_pitch;
@ -49,7 +49,7 @@ bool HostDisplay::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u3
return true; 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()) if (!mode.empty())
{ {
@ -95,23 +95,23 @@ bool HostDisplay::ParseFullscreenMode(const std::string_view& mode, u32* width,
return false; 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); return StringUtil::StdStringFromFormat("%u x %u @ %f hz", width, height, refresh_rate);
} }
bool HostDisplay::UsesLowerLeftOrigin() const bool GPUDevice::UsesLowerLeftOrigin() const
{ {
const RenderAPI api = GetRenderAPI(); const RenderAPI api = GetRenderAPI();
return (api == RenderAPI::OpenGL || api == RenderAPI::OpenGLES); 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; 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) if (m_display_frame_interval == 0.0f)
return false; return false;
@ -125,7 +125,7 @@ bool HostDisplay::ShouldSkipDisplayingFrame()
return false; 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; 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); 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) 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); return WindowInfo::QueryRefreshRateForWindow(m_window_info, refresh_rate);
} }
bool HostDisplay::SetGPUTimingEnabled(bool enabled) bool GPUDevice::SetGPUTimingEnabled(bool enabled)
{ {
return false; return false;
} }
float HostDisplay::GetAndResetAccumulatedGPUTime() float GPUDevice::GetAndResetAccumulatedGPUTime()
{ {
return 0.0f; return 0.0f;
} }
void HostDisplay::SetSoftwareCursor(std::unique_ptr<GPUTexture> texture, float scale /*= 1.0f*/) void GPUDevice::SetSoftwareCursor(std::unique_ptr<GPUTexture> texture, float scale /*= 1.0f*/)
{ {
m_cursor_texture = std::move(texture); m_cursor_texture = std::move(texture);
m_cursor_texture_scale = scale; 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<GPUTexture> tex = std::unique_ptr<GPUTexture> tex =
CreateTexture(width, height, 1, 1, 1, GPUTexture::Format::RGBA8, pixels, stride, false); 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; 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"); auto fp = FileSystem::OpenManagedCFile(path, "rb");
if (!fp) if (!fp)
@ -210,21 +210,20 @@ bool HostDisplay::SetSoftwareCursor(const char* path, float scale /*= 1.0f*/)
return true; return true;
} }
void HostDisplay::ClearSoftwareCursor() void GPUDevice::ClearSoftwareCursor()
{ {
m_cursor_texture.reset(); m_cursor_texture.reset();
m_cursor_texture_scale = 1.0f; m_cursor_texture_scale = 1.0f;
} }
bool HostDisplay::IsUsingLinearFiltering() const bool GPUDevice::IsUsingLinearFiltering() const
{ {
return g_settings.display_linear_filtering; return g_settings.display_linear_filtering;
} }
void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, float* out_left, float* out_top, 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_width, float* out_height, float* out_left_padding, float* out_top_padding,
float* out_top_padding, float* out_scale, float* out_x_scale, float* out_scale, float* out_x_scale, bool apply_aspect_ratio /* = true */) const
bool apply_aspect_ratio /* = true */) const
{ {
const float window_ratio = static_cast<float>(window_width) / static_cast<float>(window_height); const float window_ratio = static_cast<float>(window_width) / static_cast<float>(window_height);
const float display_aspect_ratio = g_settings.display_stretch ? window_ratio : m_display_aspect_ratio; 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; *out_scale = scale;
} }
std::tuple<s32, s32, s32, s32> HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, std::tuple<s32, s32, s32, s32> GPUDevice::CalculateDrawRect(s32 window_width, s32 window_height,
bool apply_aspect_ratio /* = true */) const bool apply_aspect_ratio /* = true */) const
{ {
float left, top, width, height, left_padding, top_padding; float left, top, width, height, left_padding, top_padding;
CalculateDrawRect(window_width, window_height, &left, &top, &width, &height, &left_padding, &top_padding, nullptr, CalculateDrawRect(window_width, window_height, &left, &top, &width, &height, &left_padding, &top_padding, nullptr,
@ -340,12 +339,12 @@ std::tuple<s32, s32, s32, s32> HostDisplay::CalculateDrawRect(s32 window_width,
static_cast<s32>(width), static_cast<s32>(height)); static_cast<s32>(width), static_cast<s32>(height));
} }
std::tuple<s32, s32, s32, s32> HostDisplay::CalculateSoftwareCursorDrawRect() const std::tuple<s32, s32, s32, s32> GPUDevice::CalculateSoftwareCursorDrawRect() const
{ {
return CalculateSoftwareCursorDrawRect(m_mouse_position_x, m_mouse_position_y); return CalculateSoftwareCursorDrawRect(m_mouse_position_x, m_mouse_position_y);
} }
std::tuple<s32, s32, s32, s32> HostDisplay::CalculateSoftwareCursorDrawRect(s32 cursor_x, s32 cursor_y) const std::tuple<s32, s32, s32, s32> GPUDevice::CalculateSoftwareCursorDrawRect(s32 cursor_x, s32 cursor_y) const
{ {
const float scale = m_window_info.surface_scale * m_cursor_texture_scale; const float scale = m_window_info.surface_scale * m_cursor_texture_scale;
const u32 cursor_extents_x = static_cast<u32>(static_cast<float>(m_cursor_texture->GetWidth()) * scale * 0.5f); const u32 cursor_extents_x = static_cast<u32>(static_cast<float>(m_cursor_texture->GetWidth()) * scale * 0.5f);
@ -359,9 +358,9 @@ std::tuple<s32, s32, s32, s32> HostDisplay::CalculateSoftwareCursorDrawRect(s32
return std::tie(out_left, out_top, out_width, out_height); return std::tie(out_left, out_top, out_width, out_height);
} }
std::tuple<float, float> HostDisplay::ConvertWindowCoordinatesToDisplayCoordinates(s32 window_x, s32 window_y, std::tuple<float, float> GPUDevice::ConvertWindowCoordinatesToDisplayCoordinates(s32 window_x, s32 window_y,
s32 window_width, s32 window_width,
s32 window_height) const s32 window_height) const
{ {
float left, top, width, height, left_padding, top_padding; float left, top, width, height, left_padding, top_padding;
float scale, x_scale; float scale, x_scale;
@ -454,10 +453,9 @@ static bool CompressAndWriteTextureToFile(u32 width, u32 height, std::string fil
return true; return true;
} }
bool HostDisplay::WriteTextureToFile(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, std::string filename, bool GPUDevice::WriteTextureToFile(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, std::string filename,
bool clear_alpha /* = true */, bool flip_y /* = false */, bool clear_alpha /* = true */, bool flip_y /* = false */, u32 resize_width /* = 0 */,
u32 resize_width /* = 0 */, u32 resize_height /* = 0 */, u32 resize_height /* = 0 */, bool compress_on_thread /* = false */)
bool compress_on_thread /* = false */)
{ {
std::vector<u32> texture_data(width * height); std::vector<u32> texture_data(width * height);
u32 texture_data_stride = Common::AlignUpPow2(GPUTexture::GetPixelSize(texture->GetFormat()) * width, 4); 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; return true;
} }
bool HostDisplay::WriteDisplayTextureToFile(std::string filename, bool full_resolution /* = true */, bool GPUDevice::WriteDisplayTextureToFile(std::string filename, bool full_resolution /* = true */,
bool apply_aspect_ratio /* = true */, bool compress_on_thread /* = false */) bool apply_aspect_ratio /* = true */, bool compress_on_thread /* = false */)
{ {
if (!m_display_texture) if (!m_display_texture)
return false; return false;
@ -540,8 +538,8 @@ bool HostDisplay::WriteDisplayTextureToFile(std::string filename, bool full_reso
static_cast<u32>(resize_height), compress_on_thread); static_cast<u32>(resize_height), compress_on_thread);
} }
bool HostDisplay::WriteDisplayTextureToBuffer(std::vector<u32>* buffer, u32 resize_width /* = 0 */, bool GPUDevice::WriteDisplayTextureToBuffer(std::vector<u32>* buffer, u32 resize_width /* = 0 */,
u32 resize_height /* = 0 */, bool clear_alpha /* = true */) u32 resize_height /* = 0 */, bool clear_alpha /* = true */)
{ {
if (!m_display_texture) if (!m_display_texture)
return false; return false;
@ -618,8 +616,8 @@ bool HostDisplay::WriteDisplayTextureToBuffer(std::vector<u32>* buffer, u32 resi
return true; return true;
} }
bool HostDisplay::WriteScreenshotToFile(std::string filename, bool internal_resolution /* = false */, bool GPUDevice::WriteScreenshotToFile(std::string filename, bool internal_resolution /* = false */,
bool compress_on_thread /* = false */) bool compress_on_thread /* = false */)
{ {
u32 width = m_window_info.surface_width; u32 width = m_window_info.surface_width;
u32 height = m_window_info.surface_height; u32 height = m_window_info.surface_height;

View File

@ -2,10 +2,10 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "common/gpu_texture.h"
#include "common/rectangle.h" #include "common/rectangle.h"
#include "common/types.h"
#include "common/window_info.h" #include "common/window_info.h"
#include "types.h" #include "gpu_texture.h"
#include <memory> #include <memory>
#include <string> #include <string>
#include <string_view> #include <string_view>
@ -23,7 +23,7 @@ enum class RenderAPI : u32
}; };
// Interface to the frontend's renderer. // Interface to the frontend's renderer.
class HostDisplay class GPUDevice
{ {
public: public:
struct AdapterAndModeList struct AdapterAndModeList
@ -32,7 +32,7 @@ public:
std::vector<std::string> fullscreen_modes; std::vector<std::string> fullscreen_modes;
}; };
virtual ~HostDisplay(); virtual ~GPUDevice();
/// Returns the default/preferred API for the system. /// Returns the default/preferred API for the system.
static RenderAPI GetPreferredAPI(); static RenderAPI GetPreferredAPI();
@ -252,10 +252,10 @@ protected:
}; };
/// Returns a pointer to the current host display abstraction. Assumes AcquireHostDisplay() has been called. /// Returns a pointer to the current host display abstraction. Assumes AcquireHostDisplay() has been called.
extern std::unique_ptr<HostDisplay> g_host_display; extern std::unique_ptr<GPUDevice> g_host_display;
namespace Host { namespace Host {
std::unique_ptr<HostDisplay> CreateDisplayForAPI(RenderAPI api); std::unique_ptr<GPUDevice> CreateDisplayForAPI(RenderAPI api);
/// Creates the host display. This may create a new window. The API used depends on the current configuration. /// Creates the host display. This may create a new window. The API used depends on the current configuration.
bool AcquireHostDisplay(RenderAPI api); bool AcquireHostDisplay(RenderAPI api);

View File

@ -1,9 +1,9 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "gpu_texture.h" #include "gpu_texture.h"
#include "log.h" #include "common/log.h"
#include "string_util.h" #include "common/string_util.h"
Log_SetChannel(GPUTexture); Log_SetChannel(GPUTexture);
GPUTexture::GPUTexture() = default; GPUTexture::GPUTexture() = default;

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "types.h" #include "common/types.h"
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>

View File

@ -31,7 +31,7 @@
#include "imgui.h" #include "imgui.h"
#include "imgui_impl_dx11.h" #include "imgui_impl_dx11.h"
#include "common/d3d11/texture.h" #include "d3d11/texture.h"
// DirectX // DirectX
#include <stdio.h> #include <stdio.h>

View File

@ -40,9 +40,9 @@
#include "common/windows_headers.h" #include "common/windows_headers.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/d3d12/context.h" #include "d3d12/context.h"
#include "common/d3d12/texture.h" #include "d3d12/texture.h"
#include "common/d3d12/stream_buffer.h" #include "d3d12/stream_buffer.h"
#include "imgui.h" #include "imgui.h"
#include "imgui_impl_dx12.h" #include "imgui_impl_dx12.h"

View File

@ -104,8 +104,8 @@
#endif #endif
// GL includes // GL includes
#include "common/gl/loader.h" #include "gl/loader.h"
#include "common/gl/texture.h" #include "gl/texture.h"
#include "common/log.h" #include "common/log.h"
Log_SetChannel(ImGui_ImplOpenGL3); Log_SetChannel(ImGui_ImplOpenGL3);

View File

@ -63,11 +63,11 @@
#include "imgui_impl_vulkan.h" #include "imgui_impl_vulkan.h"
#include "common/vulkan/builders.h" #include "vulkan/builders.h"
#include "common/vulkan/context.h" #include "vulkan/context.h"
#include "common/vulkan/texture.h" #include "vulkan/texture.h"
#include "common/vulkan/stream_buffer.h" #include "vulkan/stream_buffer.h"
#include "common/vulkan/util.h" #include "vulkan/util.h"
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include "imgui.h" // IMGUI_IMPL_API #include "imgui.h" // IMGUI_IMPL_API
#include "common/vulkan/loader.h" #include "vulkan/loader.h"
// Called by user code // Called by user code
bool ImGui_ImplVulkan_Init(VkRenderPass render_pass); bool ImGui_ImplVulkan_Init(VkRenderPass render_pass);

View File

@ -1,27 +1,27 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // 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/align.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/log.h" #include "common/log.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "common_host.h"
#include "imgui.h" #include "imgui.h"
#include "imgui_impl_opengl3.h" #include "imgui_impl_opengl3.h"
#include "postprocessing_shadergen.h" #include "postprocessing_shadergen.h"
#include <array> #include <array>
#include <tuple> #include <tuple>
Log_SetChannel(OpenGLHostDisplay); Log_SetChannel(OpenGLGPUDevice);
enum : u32 enum : u32
{ {
TEXTURE_STREAM_BUFFER_SIZE = 16 * 1024 * 1024, TEXTURE_STREAM_BUFFER_SIZE = 16 * 1024 * 1024,
}; };
OpenGLHostDisplay::OpenGLHostDisplay() = default; OpenGLGPUDevice::OpenGLGPUDevice() = default;
OpenGLHostDisplay::~OpenGLHostDisplay() OpenGLGPUDevice::~OpenGLGPUDevice()
{ {
if (!m_gl_context) if (!m_gl_context)
return; return;
@ -32,24 +32,24 @@ OpenGLHostDisplay::~OpenGLHostDisplay()
m_gl_context.reset(); m_gl_context.reset();
} }
RenderAPI OpenGLHostDisplay::GetRenderAPI() const RenderAPI OpenGLGPUDevice::GetRenderAPI() const
{ {
return m_gl_context->IsGLES() ? RenderAPI::OpenGLES : RenderAPI::OpenGL; return m_gl_context->IsGLES() ? RenderAPI::OpenGLES : RenderAPI::OpenGL;
} }
void* OpenGLHostDisplay::GetDevice() const void* OpenGLGPUDevice::GetDevice() const
{ {
return nullptr; return nullptr;
} }
void* OpenGLHostDisplay::GetContext() const void* OpenGLGPUDevice::GetContext() const
{ {
return m_gl_context.get(); return m_gl_context.get();
} }
std::unique_ptr<GPUTexture> OpenGLHostDisplay::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, std::unique_ptr<GPUTexture> OpenGLGPUDevice::CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Format format, const void* data, GPUTexture::Format format, const void* data, u32 data_stride,
u32 data_stride, bool dynamic /* = false */) bool dynamic /* = false */)
{ {
std::unique_ptr<GL::Texture> tex(std::make_unique<GL::Texture>()); std::unique_ptr<GL::Texture> tex(std::make_unique<GL::Texture>());
if (!tex->Create(width, height, layers, levels, samples, format, data, data_stride)) if (!tex->Create(width, height, layers, levels, samples, format, data, data_stride))
@ -58,8 +58,7 @@ std::unique_ptr<GPUTexture> OpenGLHostDisplay::CreateTexture(u32 width, u32 heig
return tex; return tex;
} }
bool OpenGLHostDisplay::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, bool OpenGLGPUDevice::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, u32* out_pitch)
u32* out_pitch)
{ {
const u32 pixel_size = texture->GetPixelSize(); const u32 pixel_size = texture->GetPixelSize();
const u32 stride = Common::AlignUpPow2(width * pixel_size, 4); const u32 stride = Common::AlignUpPow2(width * pixel_size, 4);
@ -86,7 +85,7 @@ bool OpenGLHostDisplay::BeginTextureUpdate(GPUTexture* texture, u32 width, u32 h
return true; 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 pixel_size = texture->GetPixelSize();
const u32 stride = Common::AlignUpPow2(width * pixel_size, 4); 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, bool OpenGLGPUDevice::UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data,
u32 pitch) u32 pitch)
{ {
GL::Texture* gl_texture = static_cast<GL::Texture*>(texture); GL::Texture* gl_texture = static_cast<GL::Texture*>(texture);
const auto [gl_internal_format, gl_format, gl_type] = GL::Texture::GetPixelFormatMapping(gl_texture->GetFormat()); 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; return true;
} }
bool OpenGLHostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data, bool OpenGLGPUDevice::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data,
u32 out_data_stride) u32 out_data_stride)
{ {
GLint alignment; GLint alignment;
if (out_data_stride & 1) if (out_data_stride & 1)
@ -204,13 +203,13 @@ bool OpenGLHostDisplay::DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 w
return true; 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); const auto [gl_internal_format, gl_format, gl_type] = GL::Texture::GetPixelFormatMapping(format);
return (gl_internal_format != static_cast<GLenum>(0)); return (gl_internal_format != static_cast<GLenum>(0));
} }
void OpenGLHostDisplay::SetVSync(bool enabled) void OpenGLGPUDevice::SetVSync(bool enabled)
{ {
if (m_vsync_enabled == enabled) if (m_vsync_enabled == enabled)
return; return;
@ -219,7 +218,7 @@ void OpenGLHostDisplay::SetVSync(bool enabled)
SetSwapInterval(); SetSwapInterval();
} }
const char* OpenGLHostDisplay::GetGLSLVersionString() const const char* OpenGLGPUDevice::GetGLSLVersionString() const
{ {
if (GetRenderAPI() == RenderAPI::OpenGLES) 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(); std::string header = GetGLSLVersionString();
header += "\n\n"; 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<bool>(m_gl_context); return static_cast<bool>(m_gl_context);
} }
bool OpenGLHostDisplay::HasSurface() const bool OpenGLGPUDevice::HasSurface() const
{ {
return m_window_info.type != WindowInfo::Type::Surfaceless; 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); m_gl_context = GL::Context::Create(wi);
if (!m_gl_context) if (!m_gl_context)
@ -295,7 +294,7 @@ bool OpenGLHostDisplay::CreateDevice(const WindowInfo& wi, bool vsync)
return true; 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. // 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); m_use_gles2_draw_path = (GetRenderAPI() == RenderAPI::OpenGLES && !GLAD_GL_ES_VERSION_3_1);
@ -332,7 +331,7 @@ bool OpenGLHostDisplay::SetupDevice()
return true; return true;
} }
bool OpenGLHostDisplay::MakeCurrent() bool OpenGLGPUDevice::MakeCurrent()
{ {
if (!m_gl_context->MakeCurrent()) if (!m_gl_context->MakeCurrent())
{ {
@ -344,12 +343,12 @@ bool OpenGLHostDisplay::MakeCurrent()
return true; return true;
} }
bool OpenGLHostDisplay::DoneCurrent() bool OpenGLGPUDevice::DoneCurrent()
{ {
return m_gl_context->DoneCurrent(); return m_gl_context->DoneCurrent();
} }
bool OpenGLHostDisplay::ChangeWindow(const WindowInfo& new_wi) bool OpenGLGPUDevice::ChangeWindow(const WindowInfo& new_wi)
{ {
Assert(m_gl_context); Assert(m_gl_context);
@ -368,7 +367,7 @@ bool OpenGLHostDisplay::ChangeWindow(const WindowInfo& new_wi)
return true; 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) if (!m_gl_context)
return; return;
@ -377,7 +376,7 @@ void OpenGLHostDisplay::ResizeWindow(s32 new_window_width, s32 new_window_height
m_window_info = m_gl_context->GetWindowInfo(); m_window_info = m_gl_context->GetWindowInfo();
} }
void OpenGLHostDisplay::SetSwapInterval() void OpenGLGPUDevice::SetSwapInterval()
{ {
if (m_window_info.type == WindowInfo::Type::Surfaceless) if (m_window_info.type == WindowInfo::Type::Surfaceless)
return; return;
@ -394,22 +393,22 @@ void OpenGLHostDisplay::SetSwapInterval()
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current_fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current_fbo);
} }
bool OpenGLHostDisplay::SupportsFullscreen() const bool OpenGLGPUDevice::SupportsFullscreen() const
{ {
return false; return false;
} }
bool OpenGLHostDisplay::IsFullscreen() bool OpenGLGPUDevice::IsFullscreen()
{ {
return false; 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; return false;
} }
HostDisplay::AdapterAndModeList OpenGLHostDisplay::GetAdapterAndModeList() GPUDevice::AdapterAndModeList OpenGLGPUDevice::GetAdapterAndModeList()
{ {
AdapterAndModeList aml; AdapterAndModeList aml;
@ -424,7 +423,7 @@ HostDisplay::AdapterAndModeList OpenGLHostDisplay::GetAdapterAndModeList()
return aml; return aml;
} }
void OpenGLHostDisplay::DestroySurface() void OpenGLGPUDevice::DestroySurface()
{ {
if (!m_gl_context) if (!m_gl_context)
return; return;
@ -434,23 +433,23 @@ void OpenGLHostDisplay::DestroySurface()
Log_ErrorPrintf("Failed to switch to surfaceless"); Log_ErrorPrintf("Failed to switch to surfaceless");
} }
bool OpenGLHostDisplay::CreateImGuiContext() bool OpenGLGPUDevice::CreateImGuiContext()
{ {
return ImGui_ImplOpenGL3_Init(GetGLSLVersionString()); return ImGui_ImplOpenGL3_Init(GetGLSLVersionString());
} }
void OpenGLHostDisplay::DestroyImGuiContext() void OpenGLGPUDevice::DestroyImGuiContext()
{ {
ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplOpenGL3_Shutdown();
} }
bool OpenGLHostDisplay::UpdateImGuiFontTexture() bool OpenGLGPUDevice::UpdateImGuiFontTexture()
{ {
ImGui_ImplOpenGL3_DestroyFontsTexture(); ImGui_ImplOpenGL3_DestroyFontsTexture();
return ImGui_ImplOpenGL3_CreateFontsTexture(); return ImGui_ImplOpenGL3_CreateFontsTexture();
} }
bool OpenGLHostDisplay::CreateResources() bool OpenGLGPUDevice::CreateResources()
{ {
if (!m_use_gles2_draw_path) if (!m_use_gles2_draw_path)
{ {
@ -615,9 +614,9 @@ void main()
return true; return true;
} }
void OpenGLHostDisplay::DestroyResources() void OpenGLGPUDevice::DestroyResources()
{ {
HostDisplay::DestroyResources(); GPUDevice::DestroyResources();
m_post_processing_chain.ClearStages(); m_post_processing_chain.ClearStages();
m_post_processing_input_texture.Destroy(); m_post_processing_input_texture.Destroy();
@ -649,7 +648,7 @@ void OpenGLHostDisplay::DestroyResources()
m_display_program.Destroy(); 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) if (skip_present || m_window_info.type == WindowInfo::Type::Surfaceless)
{ {
@ -680,8 +679,8 @@ bool OpenGLHostDisplay::Render(bool skip_present)
return true; return true;
} }
bool OpenGLHostDisplay::RenderScreenshot(u32 width, u32 height, const Common::Rectangle<s32>& draw_rect, bool OpenGLGPUDevice::RenderScreenshot(u32 width, u32 height, const Common::Rectangle<s32>& draw_rect,
std::vector<u32>* out_pixels, u32* out_stride, GPUTexture::Format* out_format) std::vector<u32>* out_pixels, u32* out_stride, GPUTexture::Format* out_format)
{ {
GL::Texture texture; GL::Texture texture;
if (!texture.Create(width, height, 1, 1, 1, GPUTexture::Format::RGBA8, nullptr, 0) || !texture.CreateFramebuffer()) 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; return true;
} }
void OpenGLHostDisplay::RenderImGui() void OpenGLGPUDevice::RenderImGui()
{ {
ImGui::Render(); ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
GL::Program::ResetLastProgram(); GL::Program::ResetLastProgram();
} }
void OpenGLHostDisplay::RenderDisplay() void OpenGLGPUDevice::RenderDisplay()
{ {
const auto [left, top, width, height] = CalculateDrawRect(GetWindowWidth(), GetWindowHeight()); 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); glDisableVertexAttribArray(0);
} }
void OpenGLHostDisplay::RenderDisplay(s32 left, s32 bottom, s32 width, s32 height, GL::Texture* texture, 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_x, s32 texture_view_y, s32 texture_view_width,
s32 texture_view_height, bool linear_filter) s32 texture_view_height, bool linear_filter)
{ {
glViewport(left, bottom, width, height); glViewport(left, bottom, width, height);
glDisable(GL_BLEND); 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()) if (!HasSoftwareCursor())
return; return;
@ -826,7 +825,7 @@ void OpenGLHostDisplay::RenderSoftwareCursor()
RenderSoftwareCursor(left, GetWindowHeight() - top - height, width, height, m_cursor_texture.get()); 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); glViewport(left, bottom, width, height);
glEnable(GL_BLEND); 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()) if (config.empty())
{ {
@ -923,7 +922,7 @@ bool OpenGLHostDisplay::SetPostProcessingChain(const std::string_view& config)
return true; 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()); DebugAssert(!m_post_processing_stages.empty());
@ -954,10 +953,10 @@ bool OpenGLHostDisplay::CheckPostProcessingRenderTargets(u32 target_width, u32 t
return true; return true;
} }
void OpenGLHostDisplay::ApplyPostProcessingChain(GLuint final_target, s32 final_left, s32 final_top, s32 final_width, 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 final_height, GL::Texture* texture, s32 texture_view_x,
s32 texture_view_y, s32 texture_view_width, s32 texture_view_height, s32 texture_view_y, s32 texture_view_width, s32 texture_view_height,
u32 target_width, u32 target_height) u32 target_width, u32 target_height)
{ {
if (!CheckPostProcessingRenderTargets(target_width, 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(); m_post_processing_ubo->Unbind();
} }
void OpenGLHostDisplay::CreateTimestampQueries() void OpenGLGPUDevice::CreateTimestampQueries()
{ {
const bool gles = m_gl_context->IsGLES(); const bool gles = m_gl_context->IsGLES();
const auto GenQueries = gles ? glGenQueriesEXT : glGenQueries; const auto GenQueries = gles ? glGenQueriesEXT : glGenQueries;
@ -1022,7 +1021,7 @@ void OpenGLHostDisplay::CreateTimestampQueries()
KickTimestampQuery(); KickTimestampQuery();
} }
void OpenGLHostDisplay::DestroyTimestampQueries() void OpenGLGPUDevice::DestroyTimestampQueries()
{ {
if (m_timestamp_queries[0] == 0) if (m_timestamp_queries[0] == 0)
return; return;
@ -1044,7 +1043,7 @@ void OpenGLHostDisplay::DestroyTimestampQueries()
m_timestamp_query_started = false; m_timestamp_query_started = false;
} }
void OpenGLHostDisplay::PopTimestampQuery() void OpenGLGPUDevice::PopTimestampQuery()
{ {
const bool gles = m_gl_context->IsGLES(); 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) if (m_timestamp_query_started || m_waiting_timestamp_queries == NUM_TIMESTAMP_QUERIES)
return; return;
@ -1105,7 +1104,7 @@ void OpenGLHostDisplay::KickTimestampQuery()
m_timestamp_query_started = true; m_timestamp_query_started = true;
} }
bool OpenGLHostDisplay::SetGPUTimingEnabled(bool enabled) bool OpenGLGPUDevice::SetGPUTimingEnabled(bool enabled)
{ {
if (m_gpu_timing_enabled == enabled) if (m_gpu_timing_enabled == enabled)
return true; return true;
@ -1125,14 +1124,14 @@ bool OpenGLHostDisplay::SetGPUTimingEnabled(bool enabled)
return true; return true;
} }
float OpenGLHostDisplay::GetAndResetAccumulatedGPUTime() float OpenGLGPUDevice::GetAndResetAccumulatedGPUTime()
{ {
const float value = m_accumulated_gpu_time; const float value = m_accumulated_gpu_time;
m_accumulated_gpu_time = 0.0f; m_accumulated_gpu_time = 0.0f;
return value; return value;
} }
GL::StreamBuffer* OpenGLHostDisplay::GetTextureStreamBuffer() GL::StreamBuffer* OpenGLGPUDevice::GetTextureStreamBuffer()
{ {
if (m_use_gles2_draw_path || m_texture_stream_buffer) if (m_use_gles2_draw_path || m_texture_stream_buffer)
return m_texture_stream_buffer.get(); return m_texture_stream_buffer.get();

View File

@ -2,22 +2,22 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #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/timer.h"
#include "common/window_info.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 "postprocessing_chain.h"
#include <memory> #include <memory>
class OpenGLHostDisplay final : public HostDisplay class OpenGLGPUDevice final : public GPUDevice
{ {
public: public:
OpenGLHostDisplay(); OpenGLGPUDevice();
~OpenGLHostDisplay(); ~OpenGLGPUDevice();
RenderAPI GetRenderAPI() const override; RenderAPI GetRenderAPI() const override;
void* GetDevice() const override; void* GetDevice() const override;

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "builders.h" #include "builders.h"
#include "../assert.h" #include "common/assert.h"
#include "util.h" #include "util.h"
namespace Vulkan { namespace Vulkan {

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "loader.h" #include "loader.h"
#include <array> #include <array>

View File

@ -2,10 +2,10 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "context.h" #include "context.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "../string_util.h" #include "common/string_util.h"
#include "../window_info.h" #include "common/window_info.h"
#include "swap_chain.h" #include "swap_chain.h"
#include "util.h" #include "util.h"
#include <algorithm> #include <algorithm>

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include "loader.h" #include "loader.h"
#include "stream_buffer.h" #include "stream_buffer.h"
#include <array> #include <array>

View File

@ -10,7 +10,7 @@
#define VK_USE_PLATFORM_WIN32_KHR #define VK_USE_PLATFORM_WIN32_KHR
// vulkan.h pulls in windows.h on Windows, so we need to include our replacement header first // 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 #endif

View File

@ -2,10 +2,10 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "shader_cache.h" #include "shader_cache.h"
#include "../assert.h" #include "common/assert.h"
#include "../file_system.h" #include "common/file_system.h"
#include "../log.h" #include "common/log.h"
#include "../md5_digest.h" #include "common/md5_digest.h"
#include "context.h" #include "context.h"
#include "shader_compiler.h" #include "shader_compiler.h"
#include "util.h" #include "util.h"

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
#include "../hash_combine.h" #include "common/hash_combine.h"
#include "../types.h" #include "common/types.h"
#include "loader.h" #include "loader.h"
#include "shader_compiler.h" #include "shader_compiler.h"
#include <cstdio> #include <cstdio>

View File

@ -2,9 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "shader_compiler.h" #include "shader_compiler.h"
#include "../assert.h" #include "common/assert.h"
#include "../log.h" #include "common/log.h"
#include "../string_util.h" #include "common/string_util.h"
#include "util.h" #include "util.h"
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
@ -122,7 +122,7 @@ bool InitializeGlslang()
return false; return false;
} }
std::atexit([]() { glslang::FinalizeProcess(); }); std::atexit(DeinitializeGlslang);
glslang_initialized = true; glslang_initialized = true;
return true; return true;

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include "../types.h" #include "common/types.h"
#include <optional> #include <optional>
#include <string_view> #include <string_view>
#include <vector> #include <vector>

Some files were not shown because too many files have changed in this diff Show More