Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-04-02 14:49:08 +0300
committerJulian Eisel <julian@blender.org>2020-04-02 14:50:27 +0300
commit53d029d6daaa79ed2eb3e647a7c1313e47953fda (patch)
tree58ca4394ad97ccfa5543275d75715e2952f31174 /intern/ghost
parent782e6ea4edd9cb09f2583c8f28a24d6330dc6ce8 (diff)
Cleanup: Avoid complex template type for XR-Swapchain
I rather avoid types like `std::vector<std::unique_ptr<GHOST_XrSwapchain>>`, which is easy to do in this case.
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_XrSession.cpp7
-rw-r--r--intern/ghost/intern/GHOST_XrSwapchain.cpp12
-rw-r--r--intern/ghost/intern/GHOST_XrSwapchain.h1
3 files changed, 15 insertions, 5 deletions
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index dbe0846a2ca..7be0f300210 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -45,7 +45,7 @@ struct OpenXRSessionData {
XrSpace reference_space;
XrSpace view_space;
std::vector<XrView> views;
- std::vector<std::unique_ptr<GHOST_XrSwapchain>> swapchains;
+ std::vector<GHOST_XrSwapchain> swapchains;
};
struct GHOST_XrDrawInfo {
@@ -267,8 +267,7 @@ void GHOST_XrSession::prepareDrawing()
"Failed to get count of view configurations.");
for (const XrViewConfigurationView &view_config : view_configs) {
- m_oxr->swapchains.push_back(std::unique_ptr<GHOST_XrSwapchain>(
- new GHOST_XrSwapchain(*m_gpu_binding, m_oxr->session, view_config)));
+ m_oxr->swapchains.emplace_back(*m_gpu_binding, m_oxr->session, view_config);
}
m_oxr->views.resize(view_count, {XR_TYPE_VIEW});
@@ -443,7 +442,7 @@ XrCompositionLayerProjection GHOST_XrSession::drawLayer(
r_proj_layer_views.resize(view_count);
for (uint32_t view_idx = 0; view_idx < view_count; view_idx++) {
- drawView(*m_oxr->swapchains[view_idx],
+ drawView(m_oxr->swapchains[view_idx],
r_proj_layer_views[view_idx],
view_location,
m_oxr->views[view_idx],
diff --git a/intern/ghost/intern/GHOST_XrSwapchain.cpp b/intern/ghost/intern/GHOST_XrSwapchain.cpp
index 4c91bcc2dc3..f50cfde0687 100644
--- a/intern/ghost/intern/GHOST_XrSwapchain.cpp
+++ b/intern/ghost/intern/GHOST_XrSwapchain.cpp
@@ -92,9 +92,19 @@ GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_IXrGraphicsBinding &gpu_binding,
m_oxr->swapchain_images = swapchain_images_create(m_oxr->swapchain, gpu_binding);
}
+GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_XrSwapchain &&other)
+ : m_oxr(std::move(other.m_oxr)),
+ m_image_width(other.m_image_width),
+ m_image_height(other.m_image_height)
+{
+ /* Prevent xrDestroySwapchain call for the moved out item. */
+ other.m_oxr = nullptr;
+}
+
GHOST_XrSwapchain::~GHOST_XrSwapchain()
{
- if (m_oxr->swapchain != XR_NULL_HANDLE) {
+ /* m_oxr may be NULL after move. */
+ if (m_oxr && m_oxr->swapchain != XR_NULL_HANDLE) {
CHECK_XR_ASSERT(xrDestroySwapchain(m_oxr->swapchain));
}
}
diff --git a/intern/ghost/intern/GHOST_XrSwapchain.h b/intern/ghost/intern/GHOST_XrSwapchain.h
index df9cd924dd0..ab0a6736c9c 100644
--- a/intern/ghost/intern/GHOST_XrSwapchain.h
+++ b/intern/ghost/intern/GHOST_XrSwapchain.h
@@ -30,6 +30,7 @@ class GHOST_XrSwapchain {
GHOST_XrSwapchain(GHOST_IXrGraphicsBinding &gpu_binding,
const XrSession &session,
const XrViewConfigurationView &view_config);
+ GHOST_XrSwapchain(GHOST_XrSwapchain &&other);
~GHOST_XrSwapchain();
XrSwapchainImageBaseHeader *acquireDrawableSwapchainImage();