forked from KhronosGroup/OpenXR-SDK-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd3d_common.h
53 lines (43 loc) · 1.42 KB
/
d3d_common.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
53
// Copyright (c) 2017-2023, The Khronos Group Inc.
//
// SPDX-License-Identifier: Apache-2.0
#pragma once
#if defined(XR_USE_GRAPHICS_API_D3D11) || defined(XR_USE_GRAPHICS_API_D3D12)
#include <DirectXMath.h>
struct ModelConstantBuffer {
DirectX::XMFLOAT4X4 Model;
};
struct ViewProjectionConstantBuffer {
DirectX::XMFLOAT4X4 ViewProjection;
};
// Separate entrypoints for the vertex and pixel shader functions.
constexpr char ShaderHlsl[] = R"_(
struct PSVertex {
float4 Pos : SV_POSITION;
float3 Color : COLOR0;
};
struct Vertex {
float3 Pos : POSITION;
float3 Color : COLOR0;
};
cbuffer ModelConstantBuffer : register(b0) {
float4x4 Model;
};
cbuffer ViewProjectionConstantBuffer : register(b1) {
float4x4 ViewProjection;
};
PSVertex MainVS(Vertex input) {
PSVertex output;
output.Pos = mul(mul(float4(input.Pos, 1), Model), ViewProjection);
output.Color = input.Color;
return output;
}
float4 MainPS(PSVertex input) : SV_TARGET {
return float4(input.Color, 1);
}
)_";
DirectX::XMMATRIX XM_CALLCONV LoadXrPose(const XrPosef& pose);
DirectX::XMMATRIX XM_CALLCONV LoadXrMatrix(const XrMatrix4x4f& matrix);
Microsoft::WRL::ComPtr<ID3DBlob> CompileShader(const char* hlsl, const char* entrypoint, const char* shaderTarget);
Microsoft::WRL::ComPtr<IDXGIAdapter1> GetAdapter(LUID adapterId);
#endif