@@ -1483,177 +1483,6 @@ class ExecutionTest {
14831483 }
14841484#endif
14851485
1486- HRESULT EnableDebugLayer() {
1487- // The debug layer does net yet validate DXIL programs that require
1488- // rewriting, but basic logging should work properly.
1489- HRESULT hr = S_FALSE;
1490- if (useDebugIfaces()) {
1491- CComPtr<ID3D12Debug> debugController;
1492- hr = D3D12GetDebugInterface(IID_PPV_ARGS(&debugController));
1493- if (SUCCEEDED(hr)) {
1494- debugController->EnableDebugLayer();
1495- hr = S_OK;
1496- }
1497- }
1498- return hr;
1499- }
1500-
1501- static std::wstring GetModuleName() {
1502- wchar_t moduleName[MAX_PATH + 1] = {0};
1503- DWORD length = GetModuleFileNameW(NULL, moduleName, MAX_PATH);
1504- if (length == 0 || length == MAX_PATH) {
1505- return std::wstring(); // Error condition
1506- }
1507- return std::wstring(moduleName, length);
1508- }
1509-
1510- static std::wstring ComputeSDKFullPath(std::wstring SDKPath) {
1511- std::wstring modulePath = GetModuleName();
1512- size_t pos = modulePath.rfind('\\');
1513- if (pos == std::wstring::npos)
1514- return SDKPath;
1515- if (SDKPath.substr(0, 2) != L".\\")
1516- return SDKPath;
1517- return modulePath.substr(0, pos) + SDKPath.substr(1);
1518- }
1519-
1520- static UINT GetD3D12SDKVersion(std::wstring SDKPath) {
1521- // Try to automatically get the D3D12SDKVersion from the DLL
1522- UINT SDKVersion = 0;
1523- std::wstring D3DCorePath = ComputeSDKFullPath(SDKPath);
1524- D3DCorePath.append(L"D3D12Core.dll");
1525- HMODULE hCore = LoadLibraryW(D3DCorePath.c_str());
1526- if (hCore) {
1527- if (UINT *pSDKVersion = (UINT *)GetProcAddress(hCore, "D3D12SDKVersion"))
1528- SDKVersion = *pSDKVersion;
1529- FreeModule(hCore);
1530- }
1531- return SDKVersion;
1532- }
1533-
1534- static HRESULT EnableAgilitySDK(HMODULE hRuntime, UINT SDKVersion,
1535- LPCWSTR SDKPath) {
1536- D3D12GetInterfaceFn pD3D12GetInterface =
1537- (D3D12GetInterfaceFn)GetProcAddress(hRuntime, "D3D12GetInterface");
1538- CComPtr<ID3D12SDKConfiguration> pD3D12SDKConfiguration;
1539- IFR(pD3D12GetInterface(CLSID_D3D12SDKConfiguration,
1540- IID_PPV_ARGS(&pD3D12SDKConfiguration)));
1541- IFR(pD3D12SDKConfiguration->SetSDKVersion(SDKVersion, CW2A(SDKPath)));
1542-
1543- // Currently, it appears that the SetSDKVersion will succeed even when
1544- // D3D12Core is not found, or its version doesn't match. When that's the
1545- // case, will cause a failure in the very next thing that actually requires
1546- // D3D12Core.dll to be loaded instead. So, we attempt to clear experimental
1547- // features next, which is a valid use case and a no-op at this point. This
1548- // requires D3D12Core to be loaded. If this fails, we know the AgilitySDK
1549- // setting actually failed.
1550- D3D12EnableExperimentalFeaturesFn pD3D12EnableExperimentalFeatures =
1551- (D3D12EnableExperimentalFeaturesFn)GetProcAddress(
1552- hRuntime, "D3D12EnableExperimentalFeatures");
1553- if (pD3D12EnableExperimentalFeatures == nullptr) {
1554- // If this failed, D3D12 must be too old for AgilitySDK. But if that's
1555- // the case, creating D3D12SDKConfiguration should have failed. So while
1556- // this case shouldn't be hit, fail if it is.
1557- return HRESULT_FROM_WIN32(GetLastError());
1558- }
1559- return pD3D12EnableExperimentalFeatures(0, nullptr, nullptr, nullptr);
1560- }
1561-
1562- static HRESULT EnableExperimentalShaderModels(HMODULE hRuntime) {
1563- D3D12EnableExperimentalFeaturesFn pD3D12EnableExperimentalFeatures =
1564- (D3D12EnableExperimentalFeaturesFn)GetProcAddress(
1565- hRuntime, "D3D12EnableExperimentalFeatures");
1566- if (pD3D12EnableExperimentalFeatures == nullptr) {
1567- return HRESULT_FROM_WIN32(GetLastError());
1568- }
1569- return pD3D12EnableExperimentalFeatures(1, &D3D12ExperimentalShaderModelsID,
1570- nullptr, nullptr);
1571- }
1572-
1573- static HRESULT EnableExperimentalShaderModels() {
1574- HMODULE hRuntime = LoadLibraryW(L"d3d12.dll");
1575- if (hRuntime == NULL)
1576- return E_FAIL;
1577- return EnableExperimentalShaderModels(hRuntime);
1578- }
1579-
1580- HRESULT EnableAgilitySDK(HMODULE hRuntime) {
1581- // D3D12SDKVersion > 1 will use provided version, otherwise, auto-detect.
1582- // D3D12SDKVersion == 1 means fail if we can't auto-detect.
1583- UINT SDKVersion = 0;
1584- WEX::TestExecution::RuntimeParameters::TryGetValue(L"D3D12SDKVersion",
1585- SDKVersion);
1586-
1587- // SDKPath must be relative path from .exe, which means relative to
1588- // TE.exe location, and must start with ".\\", such as with the
1589- // default: ".\\D3D12\\"
1590- WEX::Common::String SDKPath;
1591- if (SUCCEEDED(WEX::TestExecution::RuntimeParameters::TryGetValue(
1592- L"D3D12SDKPath", SDKPath))) {
1593- // Make sure path ends in backslash
1594- if (!SDKPath.IsEmpty() && SDKPath.Right(1) != "\\") {
1595- SDKPath.Append("\\");
1596- }
1597- }
1598- if (SDKPath.IsEmpty()) {
1599- SDKPath = L".\\D3D12\\";
1600- }
1601-
1602- bool mustFind = SDKVersion > 0;
1603- if (SDKVersion <= 1) {
1604- // lookup version from D3D12Core.dll
1605- SDKVersion = GetD3D12SDKVersion((LPCWSTR)SDKPath);
1606- if (mustFind && SDKVersion == 0) {
1607- LogErrorFmt(L"Agility SDK not found in relative path: %s",
1608- (LPCWSTR)SDKPath);
1609- return E_FAIL;
1610- }
1611- }
1612-
1613- // Not found, not asked for.
1614- if (SDKVersion == 0)
1615- return S_FALSE;
1616-
1617- HRESULT hr = EnableAgilitySDK(hRuntime, SDKVersion, (LPCWSTR)SDKPath);
1618- if (FAILED(hr)) {
1619- // If SDKVersion provided, fail if not successful.
1620- // 1 means we should find it, and fill in the version automatically.
1621- if (mustFind) {
1622- LogErrorFmt(L"Failed to set Agility SDK version %d at path: %s",
1623- SDKVersion, (LPCWSTR)SDKPath);
1624- return hr;
1625- }
1626- return S_FALSE;
1627- }
1628- if (hr == S_OK) {
1629- LogCommentFmt(L"Agility SDK version set to: %d", SDKVersion);
1630- m_AgilitySDKEnabled = true;
1631- }
1632- return hr;
1633- }
1634-
1635- HRESULT EnableExperimentalMode(HMODULE hRuntime) {
1636- if (m_ExperimentalModeEnabled) {
1637- return S_OK;
1638- }
1639-
1640- #ifdef _FORCE_EXPERIMENTAL_SHADERS
1641- bool bExperimentalShaderModels = true;
1642- #else
1643- bool bExperimentalShaderModels = GetTestParamBool(L"ExperimentalShaders");
1644- #endif // _FORCE_EXPERIMENTAL_SHADERS
1645-
1646- HRESULT hr = S_FALSE;
1647- if (bExperimentalShaderModels) {
1648- hr = EnableExperimentalShaderModels(hRuntime);
1649- if (SUCCEEDED(hr)) {
1650- m_ExperimentalModeEnabled = true;
1651- }
1652- }
1653-
1654- return hr;
1655- }
1656-
16571486 struct FenceObj {
16581487 HANDLE m_fenceEvent = NULL ;
16591488 CComPtr<ID3D12Fence> m_fence;
@@ -12699,7 +12528,13 @@ static void WriteReadBackDump(st::ShaderOp *pShaderOp, st::ShaderOpTest *pTest,
1269912528extern " C" {
1270012529__declspec (dllexport) HRESULT WINAPI
1270112530 InitializeOpTests(void *pStrCtx, st::OutputStringFn pOutputStrFn) {
12702- HRESULT hr = ExecutionTest::EnableExperimentalShaderModels();
12531+ HMODULE Runtime = LoadLibraryW (L" d3d12.dll" );
12532+
12533+ if (Runtime == NULL )
12534+ return E_FAIL;
12535+
12536+ HRESULT hr = enableExperimentalMode (Runtime);
12537+
1270312538 if (FAILED (hr)) {
1270412539 pOutputStrFn (pStrCtx, L" Unable to enable experimental shader models.\r\n ." );
1270512540 }
0 commit comments