Skip to content

Commit 39d2165

Browse files
damyanpgithub-actions[bot]hekota
authored
Make ExecutionTests able to pick a specific AgilitySDK (#7963)
The original AgilitySDK API only allowed paths relative to the process's executable to be used to specificy the location of the AgilitySDK. So, previously, if we wanted to use a specific AgilitySDK with the execution tests we had to arrange for the AgilitySDK's dlls to be placed in a subdirectory underneath TAEF's te.exe. This required a convoluted dance involving finding and copying TAEF executables somewhere that could be owned by the testing process. This change makes it so we can use [ID3D12DeviceFactory](https://microsoft.github.io/DirectX-Specs/d3d/IndependentDevices.html) - which allows the AgilitySDK location to be specified using absolute paths. A new class, D3D12SDKSelector, is added to help manage this, as well as falling back to using the old-style AgilitySDK and the inbox D3D12. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Helena Kotas <[email protected]>
1 parent fe5ccb8 commit 39d2165

File tree

6 files changed

+299
-225
lines changed

6 files changed

+299
-225
lines changed

tools/clang/.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*'
1+
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-use-anonymous-namespace'

tools/clang/test/taef_exec/lit.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ if config.unsupported == False:
6969
if agility_sdk:
7070
extra_params.append('/p:')
7171
extra_params.append('D3D12SDKVersion=1')
72+
extra_params.append('/p:')
73+
extra_params.append('D3D12SDKPath=' + agility_sdk)
74+
print(f"Using Agility SDK from {agility_sdk}")
7275

7376
warp_dll = getattr(config, 'warp_dll', None)
7477
if warp_dll:

tools/clang/unittests/HLSLExec/ExecutionTest.cpp

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,8 @@ class ExecutionTest {
417417

418418
dxc::DxCompilerDllLoader m_support;
419419

420+
std::optional<D3D12SDKSelector> D3D12SDK;
420421
bool m_D3DInitCompleted = false;
421-
bool m_ExperimentalModeEnabled = false;
422-
bool m_AgilitySDKEnabled = false;
423422

424423
const float ClearColor[4] = {0.0f, 0.2f, 0.4f, 1.0f};
425424

@@ -428,46 +427,18 @@ class ExecutionTest {
428427
if (!m_D3DInitCompleted) {
429428
m_D3DInitCompleted = true;
430429

431-
HMODULE hRuntime = LoadLibraryW(L"d3d12.dll");
432-
if (hRuntime == NULL)
433-
return false;
434-
// Do not: FreeLibrary(hRuntime);
435-
// If we actually free the library, it defeats the purpose of
436-
// enableAgilitySDK and enableExperimentalMode.
437-
438-
HRESULT hr;
439-
hr = enableAgilitySDK(hRuntime);
440-
if (FAILED(hr)) {
441-
LogCommentFmt(L"Unable to enable Agility SDK - 0x%08x.", hr);
442-
} else if (hr == S_FALSE) {
443-
LogCommentFmt(L"Agility SDK not enabled.");
444-
} else {
445-
LogCommentFmt(L"Agility SDK enabled.");
446-
}
447-
448-
hr = enableExperimentalMode(hRuntime);
449-
if (FAILED(hr)) {
450-
LogCommentFmt(L"Unable to enable shader experimental mode - 0x%08x.",
451-
hr);
452-
} else if (hr == S_FALSE) {
453-
LogCommentFmt(L"Experimental mode not enabled.");
454-
} else {
455-
LogCommentFmt(L"Experimental mode enabled.");
456-
}
457-
458-
hr = enableDebugLayer();
459-
if (FAILED(hr)) {
460-
LogCommentFmt(L"Unable to enable debug layer - 0x%08x.", hr);
461-
} else if (hr == S_FALSE) {
462-
LogCommentFmt(L"Debug layer not enabled.");
463-
} else {
464-
LogCommentFmt(L"Debug layer enabled.");
465-
}
430+
D3D12SDK = D3D12SDKSelector();
466431
}
467432

468433
return true;
469434
}
470435

436+
bool createDevice(ID3D12Device **D3DDevice,
437+
D3D_SHADER_MODEL TestModel = D3D_SHADER_MODEL_6_0,
438+
bool SkipUnsupported = true) {
439+
return D3D12SDK->createDevice(D3DDevice, TestModel, SkipUnsupported);
440+
}
441+
471442
std::wstring DxcBlobToWide(IDxcBlob *pBlob) {
472443
if (!pBlob)
473444
return std::wstring();
@@ -12397,17 +12368,17 @@ static void WriteReadBackDump(st::ShaderOp *pShaderOp, st::ShaderOpTest *pTest,
1239712368
// It's exclusive with the use of the DLL as a TAEF target.
1239812369
extern "C" {
1239912370
__declspec(dllexport) HRESULT WINAPI
12400-
InitializeOpTests(void *pStrCtx, st::OutputStringFn pOutputStrFn) {
12401-
HMODULE Runtime = LoadLibraryW(L"d3d12.dll");
12402-
12403-
if (Runtime == NULL)
12404-
return E_FAIL;
12405-
12406-
HRESULT hr = enableExperimentalMode(Runtime);
12371+
InitializeOpTests([[maybe_unused]] void *pStrCtx,
12372+
[[maybe_unused]] st::OutputStringFn pOutputStrFn) {
12373+
// Note: previously, this function would call enableExperimentalMode. Since
12374+
// InitializeOpTests was only ever called from HLSLHost, as part of a now
12375+
// defunct test framework it would never be able to set a TAEF parameter to
12376+
// enable experimental mode. If/when we clean up HLSLHost we can clean this up
12377+
// as well.
12378+
#ifdef _FORCE_EXPERIMENTAL_SHADERS
12379+
#error "_FORCE_EXPERIMENTAL_SHADERS requires InitializeOpTests to be updated"
12380+
#endif
1240712381

12408-
if (FAILED(hr)) {
12409-
pOutputStrFn(pStrCtx, L"Unable to enable experimental shader models.\r\n.");
12410-
}
1241112382
return S_OK;
1241212383
}
1241312384

0 commit comments

Comments
 (0)