Monado OpenXR Runtime
comp_d3d11_client.cpp File Reference

D3D11 client side glue to compositor implementation. More...

#include "comp_d3d11_client.h"
#include "comp_d3d_common.hpp"
#include "xrt/xrt_compositor.h"
#include "xrt/xrt_config_os.h"
#include "xrt/xrt_handles.h"
#include "xrt/xrt_deleters.hpp"
#include "xrt/xrt_results.h"
#include "xrt/xrt_vulkan_includes.h"
#include "d3d/d3d_dxgi_formats.h"
#include "d3d/d3d_d3d11_helpers.hpp"
#include "d3d/d3d_d3d11_allocator.hpp"
#include "d3d/d3d_d3d11_fence.hpp"
#include "util/u_misc.h"
#include "util/u_pretty_print.h"
#include "util/u_time.h"
#include "util/u_logging.h"
#include "util/u_debug.h"
#include "util/u_handles.h"
#include "util/u_win32_com_guard.hpp"
#include <d3d11_1.h>
#include <d3d11_3.h>
#include <wil/resource.h>
#include <wil/com.h>
#include <wil/result_macros.h>
#include <assert.h>
#include <memory>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <chrono>
Include dependency graph for comp_d3d11_client.cpp:

Data Structures

class  client_d3d11_compositor
 Wraps the real compositor providing a D3D11 based interface. More...
 
struct  client_d3d11_swapchain_data
 Split out from client_d3d11_swapchain to ensure that it is standard layout, std::vector for instance is not standard layout. More...
 
struct  client_d3d11_swapchain
 Wraps the real compositor swapchain providing a D3D11 based interface. More...
 

Typedefs

using unique_compositor_semaphore_ref = std::unique_ptr< struct xrt_compositor_semaphore, xrt::deleters::reference_deleter< struct xrt_compositor_semaphore, xrt_compositor_semaphore_reference > >
 

Functions

static DWORD convertTimeoutToWindowsMilliseconds (int64_t timeout_ns)
 
template<size_t N>
static bool formatMessage (DWORD err, char(&buf)[N])
 
static xrt_result_t client_d3d11_swapchain_acquire_image (struct xrt_swapchain *xsc, uint32_t *out_index)
 
static xrt_result_t client_d3d11_swapchain_wait_image (struct xrt_swapchain *xsc, int64_t timeout_ns, uint32_t index)
 
static xrt_result_t client_d3d11_swapchain_barrier_image (struct xrt_swapchain *xsc, enum xrt_barrier_direction direction, uint32_t index)
 
static xrt_result_t client_d3d11_swapchain_release_image (struct xrt_swapchain *xsc, uint32_t index)
 
static void client_d3d11_swapchain_destroy (struct xrt_swapchain *xsc)
 
static wil::com_ptr< ID3D11Texture2D1 > import_image (ID3D11Device1 &device, HANDLE h)
 
static wil::com_ptr< ID3D11Texture2D1 > import_image_dxgi (ID3D11Device1 &device, HANDLE h)
 
static wil::com_ptr< ID3D11Fence > import_fence (ID3D11Device5 &device, HANDLE h)
 
xrt_result_t client_d3d11_create_swapchain (struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain **out_xsc)
 
static xrt_result_t client_d3d11_compositor_passthrough_create (struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
 
static xrt_result_t client_d3d11_compositor_passthrough_layer_create (struct xrt_compositor *xc, const struct xrt_passthrough_layer_create_info *info)
 
static xrt_result_t client_d3d11_compositor_passthrough_destroy (struct xrt_compositor *xc)
 
static xrt_result_t client_d3d11_compositor_begin_session (struct xrt_compositor *xc, const struct xrt_begin_session_info *info)
 
static xrt_result_t client_d3d11_compositor_end_session (struct xrt_compositor *xc)
 
static xrt_result_t client_d3d11_compositor_wait_frame (struct xrt_compositor *xc, int64_t *out_frame_id, int64_t *predicted_display_time, int64_t *predicted_display_period)
 
static xrt_result_t client_d3d11_compositor_begin_frame (struct xrt_compositor *xc, int64_t frame_id)
 
static xrt_result_t client_d3d11_compositor_discard_frame (struct xrt_compositor *xc, int64_t frame_id)
 
static xrt_result_t client_d3d11_compositor_layer_begin (struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
 
static xrt_result_t client_d3d11_compositor_layer_projection (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
 
static xrt_result_t client_d3d11_compositor_layer_projection_depth (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], struct xrt_swapchain *d_xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
 
static xrt_result_t client_d3d11_compositor_layer_quad (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 
static xrt_result_t client_d3d11_compositor_layer_cube (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 
static xrt_result_t client_d3d11_compositor_layer_cylinder (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 
static xrt_result_t client_d3d11_compositor_layer_equirect1 (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 
static xrt_result_t client_d3d11_compositor_layer_equirect2 (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 
static xrt_result_t client_d3d11_compositor_layer_passthrough (struct xrt_compositor *xc, struct xrt_device *xdev, const struct xrt_layer_data *data)
 
static xrt_result_t client_d3d11_compositor_layer_commit (struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
 
static xrt_result_t client_d3d11_compositor_get_swapchain_create_properties (struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain_create_properties *xsccp)
 
static void client_d3d11_compositor_destroy (struct xrt_compositor *xc)
 
static void client_d3d11_compositor_init_try_timeline_semaphores (struct client_d3d11_compositor *c)
 
static void client_d3d11_compositor_init_try_internal_blocking (struct client_d3d11_compositor *c)
 
struct xrt_compositor_d3d11client_d3d11_compositor_create (struct xrt_compositor_native *xcn, ID3D11Device *device)
 

Variables

static constexpr uint64_t kKeyedMutexKey = 0
 
static constexpr auto kFenceTimeout = 500ms
 
static constexpr size_t kErrorBufSize = 256
 

Detailed Description

D3D11 client side glue to compositor implementation.

Author
Rylie Pavlik rylie.nosp@m..pav.nosp@m.lik@c.nosp@m.olla.nosp@m.bora..nosp@m.com
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m
Fernando Velazquez Innella finne.nosp@m.lla@.nosp@m.magic.nosp@m.leap.nosp@m..com

Function Documentation

◆ client_d3d11_create_swapchain()

◆ client_d3d11_swapchain_wait_image()

static xrt_result_t client_d3d11_swapchain_wait_image ( struct xrt_swapchain xsc,
int64_t  timeout_ns,
uint32_t  index 
)
static