Skip to content

Commit 7266a60

Browse files
OpenXRUtilities: properly set swap chain image state
1 parent 015bb82 commit 7266a60

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

Graphics/GraphicsTools/src/OpenXRUtilities.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "OpenXRUtilities.h"
2828

2929
#include "DebugUtilities.hpp"
30+
#include "GraphicsAccessories.hpp"
3031

3132
namespace Diligent
3233
{
@@ -241,6 +242,12 @@ void GetOpenXRSwapchainImage(IRenderDevice* pDevice,
241242
default:
242243
UNSUPPORTED("Unsupported device type");
243244
}
245+
246+
if (*ppImage)
247+
{
248+
const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs((*ppImage)->GetDesc().Format);
249+
(*ppImage)->SetState(FmtAttribs.IsDepthStencil() ? RESOURCE_STATE_DEPTH_WRITE : RESOURCE_STATE_RENDER_TARGET);
250+
}
244251
}
245252

246253
static XrBool32 OpenXRMessageCallbackFunction(XrDebugUtilsMessageSeverityFlagsEXT xrMessageSeverity,

Graphics/GraphicsTools/src/OpenXRUtilitiesD3D11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void GetOpenXRSwapchainImageD3D11(IRenderDevice* pDevice,
9696
RefCntAutoPtr<IRenderDeviceD3D11> pDeviceD3D11{pDevice, IID_RenderDeviceD3D11};
9797
VERIFY_EXPR(pDeviceD3D11 != nullptr);
9898

99-
pDeviceD3D11->CreateTexture2DFromD3DResource(texture, RESOURCE_STATE_RENDER_TARGET, ppImage);
99+
pDeviceD3D11->CreateTexture2DFromD3DResource(texture, RESOURCE_STATE_UNDEFINED, ppImage);
100100
}
101101

102102
} // namespace Diligent

Graphics/GraphicsTools/src/OpenXRUtilitiesD3D12.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void GetOpenXRSwapchainImageD3D12(IRenderDevice* pDevice,
115115
RefCntAutoPtr<IRenderDeviceD3D12> pDeviceD3D12{pDevice, IID_RenderDeviceD3D12};
116116
VERIFY_EXPR(pDeviceD3D12 != nullptr);
117117

118-
pDeviceD3D12->CreateTextureFromD3DResource(texture, RESOURCE_STATE_RENDER_TARGET, ppImage);
118+
pDeviceD3D12->CreateTextureFromD3DResource(texture, RESOURCE_STATE_UNDEFINED, ppImage);
119119
}
120120

121121

Graphics/GraphicsTools/src/OpenXRUtilitiesVk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void GetOpenXRSwapchainImageVk(IRenderDevice* pDevice,
114114
RefCntAutoPtr<IRenderDeviceVk> pDeviceVk{pDevice, IID_RenderDeviceVk};
115115
VERIFY_EXPR(pDeviceVk != nullptr);
116116

117-
pDeviceVk->CreateTextureFromVulkanImage(image, TexDesc, RESOURCE_STATE_RENDER_TARGET, ppImage);
117+
pDeviceVk->CreateTextureFromVulkanImage(image, TexDesc, RESOURCE_STATE_UNDEFINED, ppImage);
118118
}
119119

120120
} // namespace Diligent

0 commit comments

Comments
 (0)