Skip to content

Commit

Permalink
Merge branch 'master' into pd-upscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Sep 27, 2023
2 parents f9d2a54 + ed20c5b commit 71bd4b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
18 changes: 2 additions & 16 deletions src/mods/vr/D3D11Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,25 +660,15 @@ std::optional<std::string> D3D11Component::OpenXR::create_swapchains() {
return "Failed to enumerate swapchain images.";
}

spdlog::info("[VR] Runtime wants {} images for swapchain {}", image_count, i);

auto& ctx = this->contexts[i];

ctx.textures.clear();
ctx.textures.resize(image_count);

for (uint32_t j = 0; j < image_count; ++j) {
spdlog::info("[VR] Creating swapchain image {} for swapchain {}", j, i);

ctx.textures[j] = {XR_TYPE_SWAPCHAIN_IMAGE_D3D11_KHR};

if (FAILED(device->CreateTexture2D(&backbuffer_desc, nullptr, &ctx.textures[j].texture))) {
spdlog::error("[VR] Failed to create swapchain texture {} {}", i, j);
return "Failed to create swapchain texture.";
}

// get immediate context
//ComPtr<ID3D11DeviceContext> context{};
//device->GetImmediateContext(&context);
//context->CopyResource(ctx.textures[j].texture, backbuffer.Get());
}

result = xrEnumerateSwapchainImages(swapchain.handle, image_count, &image_count, (XrSwapchainImageBaseHeader*)&ctx.textures[0]);
Expand Down Expand Up @@ -715,10 +705,6 @@ void D3D11Component::OpenXR::destroy_swapchains() {
} else {
spdlog::info("[VR] Destroyed swapchain {}.", i);
}

for (auto& tex : ctx.textures) {
tex.texture->Release();
}

ctx.textures.clear();
}
Expand Down
17 changes: 2 additions & 15 deletions src/mods/vr/D3D12Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ std::optional<std::string> D3D12Component::OpenXR::create_swapchains() {
return "Failed to enumerate swapchain images.";
}

spdlog::info("[VR] Runtime wants {} images for swapchain {}", image_count, i);

auto& ctx = this->contexts[i];

ctx.textures.clear();
Expand All @@ -678,20 +680,9 @@ std::optional<std::string> D3D12Component::OpenXR::create_swapchains() {
ctx.texture_contexts.resize(image_count);

for (uint32_t j = 0; j < image_count; ++j) {
spdlog::info("[VR] Creating swapchain image {} for swapchain {}", j, i);

ctx.textures[j] = {XR_TYPE_SWAPCHAIN_IMAGE_D3D12_KHR};
ctx.texture_contexts[j] = std::make_unique<d3d12::TextureContext>();
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;
backbuffer_desc.Flags &= ~D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE;

if (FAILED(device->CreateCommittedResource(&heap_props, D3D12_HEAP_FLAG_NONE, &backbuffer_desc, D3D12_RESOURCE_STATE_RENDER_TARGET, nullptr, IID_PPV_ARGS(&ctx.textures[j].texture)))) {
spdlog::error("[VR] Failed to create swapchain texture {} {}", i, j);
return "Failed to create swapchain texture.";
}
}

result = xrEnumerateSwapchainImages(swapchain.handle, image_count, &image_count, (XrSwapchainImageBaseHeader*)&ctx.textures[0]);
Expand Down Expand Up @@ -730,10 +721,6 @@ void D3D12Component::OpenXR::destroy_swapchains() {
spdlog::info("[VR] Destroyed swapchain {}.", i);
}

for (auto& tex : ctx.textures) {
tex.texture->Release();
}

ctx.textures.clear();
}

Expand Down

0 comments on commit 71bd4b5

Please sign in to comment.