Skip to content

Commit 906b8b7

Browse files
Only support CoopVec tests if using d3d12.h with at least ID3D12GraphicsCommandList10
1 parent f64db41 commit 906b8b7

2 files changed

Lines changed: 42 additions & 4 deletions

File tree

tools/clang/unittests/HLSLExec/CoopVecAPI.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#pragma once
22
// clang-format off
33

4-
#if D3D12_PREVIEW_SDK_VERSION < 717
4+
#if !defined(D3D12_PREVIEW_SDK_VERSION) || D3D12_PREVIEW_SDK_VERSION < 717
5+
6+
#ifdef __ID3D12GraphicsCommandList10_INTERFACE_DEFINED__
7+
#define HAVE_COOPVEC_API 1
58

69
// This file contains the definitions of the D3D12 cooperative vector API.
710
// It is used to test the cooperative vector API on older SDKs.
@@ -160,7 +163,16 @@ ID3D12GraphicsCommandList11 : public ID3D12GraphicsCommandList10
160163
_In_ UINT DescCount) = 0;
161164

162165
};
163-
166+
164167
#endif /* __ID3D12GraphicsCommandList11_INTERFACE_DEFINED__ */
165168

169+
#else // __ID3D12GraphicsCommandList10_INTERFACE_DEFINED__
170+
// The used d3d12.h header does not support ID3D12GraphicsCommandList10,
171+
// so we cannot define ID3D12GraphicsCommandList11.
172+
#define HAVE_COOPVEC_API 0
173+
#endif // __ID3D12GraphicsCommandList10_INTERFACE_DEFINED__
174+
175+
#else // D3D12_PREVIEW_SDK_VERSION < 717
176+
// Preview header has CoopVec support
177+
#define HAVE_COOPVEC_API 1
166178
#endif // D3D12_PREVIEW_SDK_VERSION < 717

tools/clang/unittests/HLSLExec/ExecutionTest.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,10 @@ class ExecutionTest {
781781
void RunResourceTest(ID3D12Device *pDevice, const char *pShader,
782782
const wchar_t *sm, bool isDynamic);
783783

784+
void runCoopVecMulTest();
785+
void runCoopVecOuterProductTest();
786+
787+
#if HAVE_COOPVEC_API
784788
struct CoopVecMulSubtestConfig {
785789
int InputPerThread;
786790
int OutputPerThread;
@@ -790,7 +794,6 @@ class ExecutionTest {
790794
bool Bias;
791795
};
792796

793-
void runCoopVecMulTest();
794797
void
795798
runCoopVecMulTestConfig(ID3D12Device *D3DDevice,
796799
D3D12_COOPERATIVE_VECTOR_PROPERTIES_MUL &MulProps);
@@ -805,14 +808,14 @@ class ExecutionTest {
805808
D3D12_LINEAR_ALGEBRA_MATRIX_LAYOUT MatrixLayout;
806809
};
807810

808-
void runCoopVecOuterProductTest();
809811
void runCoopVecOuterProductTestConfig(
810812
ID3D12Device *D3DDevice,
811813
D3D12_COOPERATIVE_VECTOR_PROPERTIES_ACCUMULATE &AccumulateProps);
812814
void runCoopVecOuterProductSubtest(
813815
ID3D12Device *D3DDevice,
814816
D3D12_COOPERATIVE_VECTOR_PROPERTIES_ACCUMULATE &AccumulateProps,
815817
CoopVecOuterProductSubtestConfig &Config);
818+
#endif // HAVE_COOPVEC_API
816819

817820
template <class T1, class T2>
818821
void WaveIntrinsicsActivePrefixTest(TableParameter *pParameterList,
@@ -1771,13 +1774,18 @@ class ExecutionTest {
17711774
}
17721775

17731776
bool DoesDeviceSupportCooperativeVector(ID3D12Device *Device) {
1777+
#if HAVE_COOPVEC_API
17741778
D3D12_FEATURE_DATA_D3D12_OPTIONS_EXPERIMENTAL O;
17751779
if (FAILED(Device->CheckFeatureSupport(
17761780
(D3D12_FEATURE)D3D12_FEATURE_D3D12_OPTIONS_EXPERIMENTAL, &O,
17771781
sizeof(O))))
17781782
return false;
17791783
return O.CooperativeVectorTier !=
17801784
D3D12_COOPERATIVE_VECTOR_TIER_NOT_SUPPORTED;
1785+
#else
1786+
UNREFERENCED_PARAMETER(Device);
1787+
return false;
1788+
#endif
17811789
}
17821790

17831791
bool IsFallbackPathEnabled() {
@@ -11994,6 +12002,12 @@ VERIFY_SUCCEEDED(DoArraysMatch<T>(OutputVector, ExpectedVector,
1199412002
//
1199512003
// The current implementation will always write the final output data as float.
1199612004
void ExecutionTest::runCoopVecMulTest() {
12005+
#if !HAVE_COOPVEC_API
12006+
WEX::Logging::Log::Comment(
12007+
"Cooperative vector API not supported in build configuration. Skipping.");
12008+
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped);
12009+
return;
12010+
#else
1199712011
// Create device and verify coopvec support
1199812012
CComPtr<ID3D12Device> D3DDevice;
1199912013
if (!CreateDevice(&D3DDevice, D3D_SHADER_MODEL_6_9)) {
@@ -12104,8 +12118,10 @@ void ExecutionTest::runCoopVecMulTest() {
1210412118
// Run the test
1210512119
runCoopVecMulTestConfig(D3DDevice, MulAddConfig);
1210612120
}
12121+
#endif // HAVE_COOPVEC_API
1210712122
}
1210812123

12124+
#if HAVE_COOPVEC_API
1210912125
void ExecutionTest::runCoopVecMulTestConfig(
1211012126
ID3D12Device *D3DDevice,
1211112127
D3D12_COOPERATIVE_VECTOR_PROPERTIES_MUL &MulProps) {
@@ -12730,6 +12746,7 @@ void main(uint threadIdx : SV_GroupThreadID)
1273012746
VERIFY_IS_TRUE(Equal);
1273112747
}
1273212748
}
12749+
#endif // HAVE_COOPVEC_API
1273312750

1273412751
TEST_F(ExecutionTest, CoopVec_Mul) {
1273512752
WEX::TestExecution::SetVerifyOutput verifySettings(
@@ -12738,6 +12755,12 @@ TEST_F(ExecutionTest, CoopVec_Mul) {
1273812755
}
1273912756

1274012757
void ExecutionTest::runCoopVecOuterProductTest() {
12758+
#if !HAVE_COOPVEC_API
12759+
WEX::Logging::Log::Comment(
12760+
"Cooperative vector API not supported in build configuration. Skipping.");
12761+
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped);
12762+
return;
12763+
#else
1274112764
// Create device and verify coopvec support
1274212765
CComPtr<ID3D12Device> D3DDevice;
1274312766
if (!CreateDevice(&D3DDevice, D3D_SHADER_MODEL_6_9)) {
@@ -12771,8 +12794,10 @@ void ExecutionTest::runCoopVecOuterProductTest() {
1277112794
// Run the test
1277212795
runCoopVecOuterProductTestConfig(D3DDevice, AccumulateConfig);
1277312796
}
12797+
#endif // HAVE_COOPVEC_API
1277412798
}
1277512799

12800+
#if HAVE_COOPVEC_API
1277612801
void ExecutionTest::runCoopVecOuterProductTestConfig(
1277712802
ID3D12Device *D3DDevice,
1277812803
D3D12_COOPERATIVE_VECTOR_PROPERTIES_ACCUMULATE &AccumulateProps) {
@@ -13314,6 +13339,7 @@ void main(uint threadIdx : SV_GroupThreadID)
1331413339
VERIFY_IS_TRUE(Equal);
1331513340
}
1331613341
}
13342+
#endif // HAVE_COOPVEC_API
1331713343

1331813344
TEST_F(ExecutionTest, CoopVec_OuterProduct) {
1331913345
WEX::TestExecution::SetVerifyOutput verifySettings(

0 commit comments

Comments
 (0)