Skip to content

Commit

Permalink
Fix rest of issues with merge
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Sep 5, 2023
1 parent 79354ef commit 055707f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 20 deletions.
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions src/mods/TemporalUpscaler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <utility/FunctionHook.hpp>
#include <sdk/intrusive_ptr.hpp>

#include "vr/d3d12/CommandContext.hpp"
#include "vr/d3d12/TextureContext.hpp"
#include "Mod.hpp"

Expand Down Expand Up @@ -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<ID3D12Resource> m_old_backbuffer{};

std::array<std::array<Matrix4x4f, 6>, 2> m_old_projection_matrix{};
Expand Down
22 changes: 11 additions & 11 deletions src/mods/vr/D3D12Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -673,7 +673,7 @@ std::optional<std::string> D3D12Component::OpenXR::create_swapchains() {

ctx.textures[j] = {XR_TYPE_SWAPCHAIN_IMAGE_D3D12_KHR};
ctx.texture_contexts[j] = std::make_unique<d3d12::TextureContext>();
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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions src/mods/vr/D3D12Component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<d3d12::TextureContext, 3> left_eye_tex{};
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit 055707f

Please sign in to comment.