diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c2123e15..867e0bb5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2086,6 +2086,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -2137,6 +2138,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -2287,6 +2289,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -2338,6 +2341,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -3971,6 +3975,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -4022,6 +4027,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -4172,6 +4178,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -4223,6 +4230,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -4373,6 +4381,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -4424,6 +4433,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -6800,6 +6810,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -6851,6 +6862,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -7001,6 +7013,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -7052,6 +7065,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -7945,6 +7959,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -7996,6 +8011,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -8887,6 +8903,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -8938,6 +8955,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -9831,6 +9849,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -9882,6 +9901,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" @@ -10775,6 +10795,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D11Component.cpp" "src/mods/vr/D3D12Component.cpp" "src/mods/vr/OverlayComponent.cpp" + "src/mods/vr/d3d12/CommandContext.cpp" "src/mods/vr/d3d12/DirectXTK.cpp" "src/mods/vr/d3d12/ResourceCopier.cpp" "src/mods/vr/d3d12/TextureContext.cpp" @@ -10826,6 +10847,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework "src/mods/vr/D3D12Component.hpp" "src/mods/vr/OverlayComponent.hpp" "src/mods/vr/d3d12/ComPtr.hpp" + "src/mods/vr/d3d12/CommandContext.hpp" "src/mods/vr/d3d12/DirectXTK.hpp" "src/mods/vr/d3d12/ResourceCopier.hpp" "src/mods/vr/d3d12/TextureContext.hpp" diff --git a/src/mods/TemporalUpscaler.hpp b/src/mods/TemporalUpscaler.hpp index 61a292b4c..0b20ebe7c 100644 --- a/src/mods/TemporalUpscaler.hpp +++ b/src/mods/TemporalUpscaler.hpp @@ -4,6 +4,7 @@ #include #include +#include "vr/d3d12/CommandContext.hpp" #include "vr/d3d12/TextureContext.hpp" #include "Mod.hpp" @@ -184,8 +185,8 @@ class TemporalUpscaler : public Mod { float m_motion_scale[2]{-1.0f, 1.0f}; float m_jitter_evaluate_scale{1.0f}; - d3d12::ResourceCopier m_copier{}; - d3d12::ResourceCopier m_big_copier{}; + d3d12::CommandContext m_copier{}; + d3d12::CommandContext m_big_copier{}; ComPtr m_old_backbuffer{}; std::array, 2> m_old_projection_matrix{}; diff --git a/src/mods/vr/D3D12Component.cpp b/src/mods/vr/D3D12Component.cpp index 349d909c3..6254201a9 100644 --- a/src/mods/vr/D3D12Component.cpp +++ b/src/mods/vr/D3D12Component.cpp @@ -48,16 +48,16 @@ vr::EVRCompositorError D3D12Component::on_frame(VR* vr) { // TODO: Correct this for the upscaler...? if (!m_backbuffer_is_8bit) { - auto command_list = m_backbuffer_copy.copier.cmd_list.Get(); - m_backbuffer_copy.copier.wait(INFINITE); + auto command_list = m_backbuffer_copy.commands.cmd_list.Get(); + m_backbuffer_copy.commands.wait(INFINITE); // Copy current backbuffer into our copy so we can use it as an SRV. - m_backbuffer_copy.copier.copy(backbuffer.Get(), m_backbuffer_copy.texture.Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_PRESENT); + m_backbuffer_copy.commands.copy(backbuffer.Get(), m_backbuffer_copy.texture.Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_PRESENT); // Convert the backbuffer to 8-bit. render_srv_to_rtv(command_list, m_backbuffer_copy, m_converted_eye_tex, D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - m_backbuffer_copy.copier.execute(); + m_backbuffer_copy.commands.execute(); } auto eye_texture = m_backbuffer_is_8bit ? backbuffer : m_converted_eye_tex.texture; @@ -673,7 +673,7 @@ std::optional D3D12Component::OpenXR::create_swapchains() { ctx.textures[j] = {XR_TYPE_SWAPCHAIN_IMAGE_D3D12_KHR}; ctx.texture_contexts[j] = std::make_unique(); - ctx.texture_contexts[j]->copier.setup((std::wstring{L"OpenXR Swapchain "} + std::to_wstring(i) + L" " + std::to_wstring(j)).c_str()); + ctx.texture_contexts[j]->commands.setup((std::wstring{L"OpenXR Swapchain "} + std::to_wstring(i) + L" " + std::to_wstring(j)).c_str()); backbuffer_desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; @@ -767,7 +767,7 @@ void D3D12Component::OpenXR::copy(uint32_t swapchain_idx, ID3D12Resource* resour spdlog::info("[VR] Attempting to correct..."); for (auto& texture_ctx : ctx.texture_contexts) { - texture_ctx->copier.reset(); + texture_ctx->commands.reset(); } texture_index = 0; @@ -789,21 +789,21 @@ void D3D12Component::OpenXR::copy(uint32_t swapchain_idx, ID3D12Resource* resour spdlog::error("[VR] xrWaitSwapchainImage failed: {}", vr->m_openxr->get_result_string(result)); } else { auto& texture_ctx = ctx.texture_contexts[texture_index]; - texture_ctx->copier.wait(INFINITE); + texture_ctx->commands.wait(INFINITE); if (src_box != nullptr) { - texture_ctx->copier.copy_region( + texture_ctx->commands.copy_region( resource, ctx.textures[texture_index].texture, src_box, src_state, D3D12_RESOURCE_STATE_RENDER_TARGET); } else { - texture_ctx->copier.copy( + texture_ctx->commands.copy( resource, ctx.textures[texture_index].texture, src_state, D3D12_RESOURCE_STATE_RENDER_TARGET); } - texture_ctx->copier.execute(); + texture_ctx->commands.execute(); XrSwapchainImageReleaseInfo release_info{XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO}; auto result = xrReleaseSwapchainImage(swapchain.handle, &release_info); @@ -820,7 +820,7 @@ void D3D12Component::OpenXR::copy(uint32_t swapchain_idx, ID3D12Resource* resour } for (auto& texture_ctx : ctx.texture_contexts) { - texture_ctx->copier.wait(INFINITE); + texture_ctx->commands.wait(INFINITE); } result = xrReleaseSwapchainImage(swapchain.handle, &release_info); diff --git a/src/mods/vr/D3D12Component.hpp b/src/mods/vr/D3D12Component.hpp index b2a1c6f04..18051d132 100644 --- a/src/mods/vr/D3D12Component.hpp +++ b/src/mods/vr/D3D12Component.hpp @@ -75,28 +75,28 @@ class D3D12Component { d3d12::TextureContext& acquire_left() { auto& ctx = get_left(); - ctx.copier.wait(INFINITE); + ctx.commands.wait(INFINITE); return ctx; } d3d12::TextureContext& acquire_right() { auto& ctx = get_right(); - ctx.copier.wait(INFINITE); + ctx.commands.wait(INFINITE); return ctx; } void copy_left(ID3D12Resource* src, D3D12_RESOURCE_STATES src_state = D3D12_RESOURCE_STATE_PRESENT) { auto& ctx = this->acquire_left(); - ctx.copier.copy(src, ctx.texture.Get(), src_state, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - ctx.copier.execute(); + ctx.commands.copy(src, ctx.texture.Get(), src_state, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + ctx.commands.execute(); } void copy_right(ID3D12Resource* src, D3D12_RESOURCE_STATES src_state = D3D12_RESOURCE_STATE_PRESENT) { auto& ctx = this->acquire_right(); - ctx.copier.copy(src, ctx.texture.Get(), src_state, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - ctx.copier.execute(); + ctx.commands.copy(src, ctx.texture.Get(), src_state, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + ctx.commands.execute(); } std::array left_eye_tex{}; @@ -115,7 +115,7 @@ class D3D12Component { for (auto& ctx : this->contexts) { for (auto& texture_ctx : ctx.texture_contexts) { - texture_ctx->copier.wait(INFINITE); + texture_ctx->commands.wait(INFINITE); } } }