forked from blitz-research/dawnxr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dawnxr_internal.h
52 lines (37 loc) · 2.53 KB
/
dawnxr_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
#include "dawnxr.h"
#include <vector>
#define XR_TRY(X) \
{ \
auto r = (X); \
if (XR_FAILED(r)) { \
std::cout << "### XR_TRY failed: " << #X << std::endl; \
return r; \
} \
}
#define XR_PROC(XRINST, FUNCID) \
PFN_##FUNCID FUNCID{}; \
xrGetInstanceProcAddr((XRINST), #FUNCID, (PFN_xrVoidFunction*)(&FUNCID));
namespace dawnxr::internal {
struct Session {
XrSession const backendSession;
WGPUDevice const device;
virtual XrResult enumerateSwapchainFormats(std::vector<WGPUTextureFormat>& formats) = 0;
virtual XrResult createSwapchain(const XrSwapchainCreateInfo* createInfo, std::vector<WGPUTextureView>& images,
XrSwapchain* swapchain) = 0;
// TODO: destroySwapchainImages
virtual ~Session() = default;
protected:
Session(XrSession session, const WGPUDevice& device) : backendSession(session), device(device) {}
};
#ifdef XR_USE_GRAPHICS_API_D3D12
XrResult getD3D12GraphicsRequirements(XrInstance instance, XrSystemId systemId, GraphicsRequirementsDawn* requirements);
XrResult createD3D12OpenXRConfig(XrInstance instance, XrSystemId systemId, void** config);
XrResult createD3D12Session(XrInstance instance, const XrSessionCreateInfo* createInfo, Session** session);
#endif
#ifdef XR_USE_GRAPHICS_API_VULKAN
XrResult getVulkanGraphicsRequirements(XrInstance instance, XrSystemId systemId, GraphicsRequirementsDawn* requirements);
XrResult createVulkanOpenXRConfig(XrInstance instance, XrSystemId systemId, void** config);
XrResult createVulkanSession(XrInstance instance, const XrSessionCreateInfo* createInfo, Session** session);
#endif
} // namespace dawnxr::internal