forked from microsoft/DirectXShaderCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHlslExecTestUtils.h
More file actions
106 lines (89 loc) · 4.02 KB
/
HlslExecTestUtils.h
File metadata and controls
106 lines (89 loc) · 4.02 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef HLSLEXECTESTUTILS_H
#define HLSLEXECTESTUTILS_H
#include <atlcomcli.h>
#include <d3d12.h>
#include <memory>
#include <optional>
#include <string>
#include <windows.h>
#include "ShaderOpTest.h"
#include "dxc/Support/dxcapi.use.h"
// D3D_SHADER_MODEL_6_10 is not yet in the released Windows SDK. Define locally
// so the test can query 6.10 driver support. This should be removed once
// widely supported.
#if defined(D3D12_PREVIEW_SDK_VERSION) && D3D12_PREVIEW_SDK_VERSION < 720
static const D3D_SHADER_MODEL D3D_SHADER_MODEL_6_10 = (D3D_SHADER_MODEL)0x6a;
#endif
// Local highest shader model known to DXC. Update this when adding support
// for new shader models. Unlike D3D_HIGHEST_SHADER_MODEL from the SDK,
// this stays in sync with DXC's own capabilities.
#define DXC_HIGHEST_SHADER_MODEL D3D_SHADER_MODEL_6_10
bool useDxbc();
/// Manages D3D12 (Agility) SDK selection
///
/// Based on TAEF runtime parameters, this picks an appropriate D3D12 SDK.
///
/// TAEF parameters:
///
/// D3D12SDKPath: relative or absolute path to the D3D12 Agility SDK bin
/// directory. Absolute path is only supported on OS's that support
/// ID3D12DeviceFactory.
///
/// D3D12SDKVersion: requested SDK version
///
/// 0: auto-detect (quietly fallback to inbox version)
///
/// 1: auto-detect (fail if unable to use the auto-detected version)
///
/// >1: use specified version
class D3D12SDKSelector {
CComPtr<ID3D12DeviceFactory> DeviceFactory;
public:
D3D12SDKSelector();
~D3D12SDKSelector();
bool createDevice(ID3D12Device **D3DDevice,
D3D_SHADER_MODEL TestModel = D3D_SHADER_MODEL_6_0,
bool SkipUnsupported = true);
};
void readHlslDataIntoNewStream(LPCWSTR RelativePath, IStream **Stream,
dxc::SpecificDllLoader &Support);
bool doesDeviceSupportInt64(ID3D12Device *pDevice);
bool doesDeviceSupportDouble(ID3D12Device *pDevice);
bool doesDeviceSupportWaveOps(ID3D12Device *pDevice);
bool doesDeviceSupportBarycentrics(ID3D12Device *pDevice);
bool doesDeviceSupportNative16bitOps(ID3D12Device *pDevice);
bool doesDeviceSupportMeshShaders(ID3D12Device *pDevice);
bool doesDeviceSupportRayTracing(ID3D12Device *pDevice);
bool doesDeviceSupportMeshAmpDerivatives(ID3D12Device *pDevice);
bool doesDeviceSupportTyped64Atomics(ID3D12Device *pDevice);
bool doesDeviceSupportHeap64Atomics(ID3D12Device *pDevice);
bool doesDeviceSupportShared64Atomics(ID3D12Device *pDevice);
bool doesDeviceSupportAdvancedTexOps(ID3D12Device *pDevice);
bool doesDeviceSupportWritableMSAA(ID3D12Device *pDevice);
bool doesDeviceSupportEnhancedBarriers(ID3D12Device *pDevice);
bool doesDeviceSupportRelaxedFormatCasting(ID3D12Device *pDevice);
bool isFallbackPathEnabled();
UINT getMaxGroupSharedMemoryCS(ID3D12Device *Device);
UINT getMaxGroupSharedMemoryAS(ID3D12Device *Device);
UINT getMaxGroupSharedMemoryMS(ID3D12Device *Device);
/// Create a ShaderOp for a compute shader dispatch.
std::unique_ptr<st::ShaderOp>
createComputeOp(const char *Source, const char *Target, const char *RootSig,
const char *Args = nullptr, UINT DispatchX = 1,
UINT DispatchY = 1, UINT DispatchZ = 1);
/// Add a UAV buffer resource to a ShaderOp.
void addUAVBuffer(st::ShaderOp *Op, const char *Name, UINT64 Width,
bool ReadBack, const char *Init = "zero");
/// Bind a resource to a root UAV parameter by index.
void addRootUAV(st::ShaderOp *Op, UINT Index, const char *ResName);
/// Run a programmatically-built ShaderOp and return the result.
std::shared_ptr<st::ShaderOpTestResult>
runShaderOp(ID3D12Device *Device, dxc::SpecificDllLoader &DxcSupport,
std::unique_ptr<st::ShaderOp> Op,
st::ShaderOpTest::TInitCallbackFn InitCallback = nullptr);
/// Compiles an HLSL shader using the DXC API to verify it is well-formed.
/// Fails the test on compile error.
void compileShader(dxc::SpecificDllLoader &DxcSupport, const char *Source,
const char *Target, const std::string &Args,
bool VerboseLogging = false);
#endif // HLSLEXECTESTUTILS_H