Skip to content

Commit

Permalink
OpenXRUtilities: properly set swap chain image state
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Dec 8, 2024
1 parent 015bb82 commit 7266a60
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Graphics/GraphicsTools/src/OpenXRUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "OpenXRUtilities.h"

#include "DebugUtilities.hpp"
#include "GraphicsAccessories.hpp"

namespace Diligent
{
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Graphics/GraphicsTools/src/OpenXRUtilitiesD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Graphics/GraphicsTools/src/OpenXRUtilitiesD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion Graphics/GraphicsTools/src/OpenXRUtilitiesVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7266a60

Please sign in to comment.