diff --git a/Graphics/GraphicsTools/src/OpenXRUtilities.cpp b/Graphics/GraphicsTools/src/OpenXRUtilities.cpp index 477d42661..9b9b19c12 100644 --- a/Graphics/GraphicsTools/src/OpenXRUtilities.cpp +++ b/Graphics/GraphicsTools/src/OpenXRUtilities.cpp @@ -27,6 +27,7 @@ #include "OpenXRUtilities.h" #include "DebugUtilities.hpp" +#include "GraphicsAccessories.hpp" namespace Diligent { @@ -241,6 +242,12 @@ void GetOpenXRSwapchainImage(IRenderDevice* pDevice, default: UNSUPPORTED("Unsupported device type"); } + + if (*ppImage) + { + const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs((*ppImage)->GetDesc().Format); + (*ppImage)->SetState(FmtAttribs.IsDepthStencil() ? RESOURCE_STATE_DEPTH_WRITE : RESOURCE_STATE_RENDER_TARGET); + } } static XrBool32 OpenXRMessageCallbackFunction(XrDebugUtilsMessageSeverityFlagsEXT xrMessageSeverity, diff --git a/Graphics/GraphicsTools/src/OpenXRUtilitiesD3D11.cpp b/Graphics/GraphicsTools/src/OpenXRUtilitiesD3D11.cpp index a0b758b3f..1d492371a 100644 --- a/Graphics/GraphicsTools/src/OpenXRUtilitiesD3D11.cpp +++ b/Graphics/GraphicsTools/src/OpenXRUtilitiesD3D11.cpp @@ -96,7 +96,7 @@ void GetOpenXRSwapchainImageD3D11(IRenderDevice* pDevice, RefCntAutoPtr<IRenderDeviceD3D11> pDeviceD3D11{pDevice, IID_RenderDeviceD3D11}; VERIFY_EXPR(pDeviceD3D11 != nullptr); - pDeviceD3D11->CreateTexture2DFromD3DResource(texture, RESOURCE_STATE_RENDER_TARGET, ppImage); + pDeviceD3D11->CreateTexture2DFromD3DResource(texture, RESOURCE_STATE_UNDEFINED, ppImage); } } // namespace Diligent diff --git a/Graphics/GraphicsTools/src/OpenXRUtilitiesD3D12.cpp b/Graphics/GraphicsTools/src/OpenXRUtilitiesD3D12.cpp index a15132e96..9058f7438 100644 --- a/Graphics/GraphicsTools/src/OpenXRUtilitiesD3D12.cpp +++ b/Graphics/GraphicsTools/src/OpenXRUtilitiesD3D12.cpp @@ -115,7 +115,7 @@ void GetOpenXRSwapchainImageD3D12(IRenderDevice* pDevice, RefCntAutoPtr<IRenderDeviceD3D12> pDeviceD3D12{pDevice, IID_RenderDeviceD3D12}; VERIFY_EXPR(pDeviceD3D12 != nullptr); - pDeviceD3D12->CreateTextureFromD3DResource(texture, RESOURCE_STATE_RENDER_TARGET, ppImage); + pDeviceD3D12->CreateTextureFromD3DResource(texture, RESOURCE_STATE_UNDEFINED, ppImage); } diff --git a/Graphics/GraphicsTools/src/OpenXRUtilitiesVk.cpp b/Graphics/GraphicsTools/src/OpenXRUtilitiesVk.cpp index 6498cd829..119260e9c 100644 --- a/Graphics/GraphicsTools/src/OpenXRUtilitiesVk.cpp +++ b/Graphics/GraphicsTools/src/OpenXRUtilitiesVk.cpp @@ -114,7 +114,7 @@ void GetOpenXRSwapchainImageVk(IRenderDevice* pDevice, RefCntAutoPtr<IRenderDeviceVk> pDeviceVk{pDevice, IID_RenderDeviceVk}; VERIFY_EXPR(pDeviceVk != nullptr); - pDeviceVk->CreateTextureFromVulkanImage(image, TexDesc, RESOURCE_STATE_RENDER_TARGET, ppImage); + pDeviceVk->CreateTextureFromVulkanImage(image, TexDesc, RESOURCE_STATE_UNDEFINED, ppImage); } } // namespace Diligent