Skip to content

Commit 6e848f6

Browse files
hekotatex3d
authored andcommitted
Enable experimental shaders option in HLK tests (#3601)
(cherry picked from commit d878c0a)
1 parent 1071f1f commit 6e848f6

1 file changed

Lines changed: 33 additions & 31 deletions

File tree

tools/clang/unittests/HLSL/ExecutionTest.cpp

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,6 @@ static bool contains(InputIterator b, InputIterator e, const T &val) {
8686
return e != std::find(b, e, val);
8787
}
8888

89-
static HRESULT EnableExperimentalShaderModels() {
90-
HMODULE hRuntime = LoadLibraryW(L"d3d12.dll");
91-
if (hRuntime == NULL) {
92-
return HRESULT_FROM_WIN32(GetLastError());
93-
}
94-
95-
D3D12EnableExperimentalFeaturesFn pD3D12EnableExperimentalFeatures =
96-
(D3D12EnableExperimentalFeaturesFn)GetProcAddress(hRuntime, "D3D12EnableExperimentalFeatures");
97-
if (pD3D12EnableExperimentalFeatures == nullptr) {
98-
FreeLibrary(hRuntime);
99-
return HRESULT_FROM_WIN32(GetLastError());
100-
}
101-
102-
HRESULT hr = pD3D12EnableExperimentalFeatures(1, &D3D12ExperimentalShaderModelsID, nullptr, nullptr);
103-
FreeLibrary(hRuntime);
104-
return hr;
105-
}
106-
10789
static HRESULT ReportLiveObjects() {
10890
CComPtr<IDXGIDebug1> pDebug;
10991
IFR(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&pDebug)));
@@ -1280,7 +1262,26 @@ class ExecutionTest {
12801262
return hr;
12811263
}
12821264

1283-
#ifndef _HLK_CONF
1265+
static HRESULT EnableExperimentalShaderModels() {
1266+
HMODULE hRuntime = LoadLibraryW(L"d3d12.dll");
1267+
if (hRuntime == NULL) {
1268+
return HRESULT_FROM_WIN32(GetLastError());
1269+
}
1270+
1271+
D3D12EnableExperimentalFeaturesFn pD3D12EnableExperimentalFeatures =
1272+
(D3D12EnableExperimentalFeaturesFn)GetProcAddress(
1273+
hRuntime, "D3D12EnableExperimentalFeatures");
1274+
if (pD3D12EnableExperimentalFeatures == nullptr) {
1275+
FreeLibrary(hRuntime);
1276+
return HRESULT_FROM_WIN32(GetLastError());
1277+
}
1278+
1279+
HRESULT hr = pD3D12EnableExperimentalFeatures(
1280+
1, &D3D12ExperimentalShaderModelsID, nullptr, nullptr);
1281+
FreeLibrary(hRuntime);
1282+
return hr;
1283+
}
1284+
12841285
HRESULT EnableExperimentalMode() {
12851286
if (m_ExperimentalModeEnabled) {
12861287
return S_OK;
@@ -1294,7 +1295,6 @@ class ExecutionTest {
12941295
}
12951296
return hr;
12961297
}
1297-
#endif
12981298

12991299
struct FenceObj {
13001300
HANDLE m_fenceEvent = NULL;
@@ -1432,6 +1432,18 @@ static void SetupComputeValuePattern(std::vector<uint32_t> &values,
14321432
}
14331433

14341434
bool ExecutionTest::ExecutionTestClassSetup() {
1435+
HRESULT hr;
1436+
#if !defined(_HLK_CONF) || defined(_HLK_CONF_TEST_EXPERIMENTAL)
1437+
hr = EnableExperimentalMode();
1438+
if (FAILED(hr)) {
1439+
LogCommentFmt(L"Unable to enable shader experimental mode - 0x%08x.", hr);
1440+
} else if (hr == S_FALSE) {
1441+
LogCommentFmt(L"Experimental mode not enabled.");
1442+
} else {
1443+
LogCommentFmt(L"Experimental mode enabled.");
1444+
}
1445+
#endif // !defined(_HLK_CONF) || defined(_HLK_CONF_TEST_EXPERIMENTAL)
1446+
14351447
#ifdef _HLK_CONF
14361448
// TODO: Enabling the D3D driver verifier. Check out the logic in the D3DConf_12_Core test.
14371449
VERIFY_SUCCEEDED(m_support.Initialize());
@@ -1442,16 +1454,6 @@ bool ExecutionTest::ExecutionTestClassSetup() {
14421454
}
14431455
return true;
14441456
#else
1445-
HRESULT hr = EnableExperimentalMode();
1446-
if (FAILED(hr)) {
1447-
LogCommentFmt(L"Unable to enable shader experimental mode - 0x%08x.", hr);
1448-
}
1449-
else if (hr == S_FALSE) {
1450-
LogCommentFmt(L"Experimental mode not enabled.");
1451-
}
1452-
else {
1453-
LogCommentFmt(L"Experimental mode enabled.");
1454-
}
14551457
hr = EnableDebugLayer();
14561458
if (FAILED(hr)) {
14571459
LogCommentFmt(L"Unable to enable debug layer - 0x%08x.", hr);
@@ -9570,7 +9572,7 @@ static void WriteReadBackDump(st::ShaderOp *pShaderOp, st::ShaderOpTest *pTest,
95709572
// It's exclusive with the use of the DLL as a TAEF target.
95719573
extern "C" {
95729574
__declspec(dllexport) HRESULT WINAPI InitializeOpTests(void *pStrCtx, st::OutputStringFn pOutputStrFn) {
9573-
HRESULT hr = EnableExperimentalShaderModels();
9575+
HRESULT hr = ExecutionTest::EnableExperimentalShaderModels();
95749576
if (FAILED(hr)) {
95759577
pOutputStrFn(pStrCtx, L"Unable to enable experimental shader models.\r\n.");
95769578
}

0 commit comments

Comments
 (0)