Skip to content

Commit a75ab9e

Browse files
committed
Fix LifetimeIntrinsicTest issues (#3609)
* Fix LifetimeIntrinsicTest issues - was only run on SM 6.6 supporting devices - would only run SM 6.6 tests in experimental mode, compiling with -Vd - wasn't specifying options required to test lifetime fallback paths * Disable LifetimeIntrinsicTest and HelperLaneTestWave on warp (cherry picked from commit 22fa209)
1 parent 695cc75 commit a75ab9e

1 file changed

Lines changed: 85 additions & 40 deletions

File tree

tools/clang/unittests/HLSL/ExecutionTest.cpp

Lines changed: 85 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,7 @@ class ExecutionTest {
308308
TEST_METHOD(AtomicsShared64Test);
309309
TEST_METHOD(AtomicsFloatTest);
310310
TEST_METHOD(HelperLaneTest);
311-
BEGIN_TEST_METHOD(HelperLaneTestWave)
312-
TEST_METHOD_PROPERTY(L"Priority", L"2") // Remove this line once warp handles this
313-
END_TEST_METHOD()
311+
TEST_METHOD(HelperLaneTestWave);
314312
TEST_METHOD(SignatureResourcesTest)
315313
TEST_METHOD(DynamicResourcesTest)
316314
TEST_METHOD(QuadReadTest)
@@ -1384,10 +1382,10 @@ class ExecutionTest {
13841382
}
13851383

13861384
void RunRWByteBufferComputeTest(ID3D12Device *pDevice, LPCSTR shader, std::vector<uint32_t> &values);
1387-
void RunLifetimeIntrinsicTest(ID3D12Device *pDevice, LPCSTR shader, D3D_SHADER_MODEL shaderModel, bool useLibTarget, LPCWSTR *pOptions, int numOptions, std::vector<uint32_t> &values);
1385+
void RunLifetimeIntrinsicTest(ID3D12Device *pDevice, LPCSTR shader, D3D_SHADER_MODEL shaderModel, bool useLibTarget, llvm::ArrayRef<LPCWSTR> options, std::vector<uint32_t> &values);
13881386
void RunLifetimeIntrinsicComputeTest(ID3D12Device *pDevice, LPCSTR pShader, CComPtr<ID3D12DescriptorHeap>& pUavHeap, CComPtr<ID3D12RootSignature>& pRootSignature,
13891387
LPCWSTR pTargetProfile, LPCWSTR *pOptions, int numOptions, std::vector<uint32_t> &values);
1390-
void RunLifetimeIntrinsicLibTest(ID3D12Device5 *pDevice, LPCSTR pShader, CComPtr<ID3D12RootSignature>& pRootSignature,
1388+
void RunLifetimeIntrinsicLibTest(ID3D12Device *pDevice0, LPCSTR pShader, CComPtr<ID3D12RootSignature>& pRootSignature,
13911389
LPCWSTR pTargetProfile, LPCWSTR *pOptions, int numOptions);
13921390

13931391
void SetDescriptorHeap(ID3D12GraphicsCommandList *pCommandList, ID3D12DescriptorHeap *pHeap) {
@@ -1634,8 +1632,11 @@ void ExecutionTest::RunLifetimeIntrinsicComputeTest(ID3D12Device *pDevice, LPCST
16341632
WaitForSignal(pCommandQueue, FO);
16351633
}
16361634

1637-
void ExecutionTest::RunLifetimeIntrinsicLibTest(ID3D12Device5 *pDevice, LPCSTR pShader, CComPtr<ID3D12RootSignature>& pRootSignature,
1635+
void ExecutionTest::RunLifetimeIntrinsicLibTest(ID3D12Device *pDevice0, LPCSTR pShader, CComPtr<ID3D12RootSignature>& pRootSignature,
16381636
LPCWSTR pTargetProfile, LPCWSTR *pOptions, int numOptions) {
1637+
CComPtr<ID3D12Device5> pDevice;
1638+
VERIFY_SUCCEEDED(pDevice0->QueryInterface(IID_PPV_ARGS(&pDevice)));
1639+
16391640
// Create command queue.
16401641
CComPtr<ID3D12CommandQueue> pCommandQueue;
16411642
CreateCommandQueue(pDevice, L"RunLifetimeIntrinsicTest Command Queue", &pCommandQueue, D3D12_COMMAND_LIST_TYPE_DIRECT);
@@ -1686,7 +1687,7 @@ void ExecutionTest::RunLifetimeIntrinsicLibTest(ID3D12Device5 *pDevice, LPCSTR p
16861687
}
16871688

16881689
void ExecutionTest::RunLifetimeIntrinsicTest(ID3D12Device *pDevice, LPCSTR pShader, D3D_SHADER_MODEL shaderModel, bool useLibTarget,
1689-
LPCWSTR *pOptions, int numOptions, std::vector<uint32_t> &values) {
1690+
llvm::ArrayRef<LPCWSTR> options, std::vector<uint32_t> &values) {
16901691
LPCWSTR pTargetProfile;
16911692
switch (shaderModel) {
16921693
default: pTargetProfile = useLibTarget ? L"lib_6_3" : L"cs_6_0"; break; // Default to 6.3 for lib, 6.0 otherwise.
@@ -1722,10 +1723,13 @@ void ExecutionTest::RunLifetimeIntrinsicTest(ID3D12Device *pDevice, LPCSTR pShad
17221723
CreateRootSignatureFromDesc(pDevice, &rootSignatureDesc, &pRootSignature);
17231724
}
17241725

1725-
if (useLibTarget)
1726-
RunLifetimeIntrinsicLibTest(reinterpret_cast<ID3D12Device5*>(pDevice), pShader, pRootSignature, pTargetProfile, pOptions, numOptions);
1727-
else
1728-
RunLifetimeIntrinsicComputeTest(pDevice, pShader, pUavHeap, pRootSignature, pTargetProfile, pOptions, numOptions, values);
1726+
if (useLibTarget) {
1727+
RunLifetimeIntrinsicLibTest(pDevice, pShader, pRootSignature, pTargetProfile,
1728+
const_cast<LPCWSTR*>(options.data()), static_cast<int>(options.size()));
1729+
} else {
1730+
RunLifetimeIntrinsicComputeTest(pDevice, pShader, pUavHeap, pRootSignature, pTargetProfile,
1731+
const_cast<LPCWSTR*>(options.data()), static_cast<int>(options.size()), values);
1732+
}
17291733
}
17301734

17311735
TEST_F(ExecutionTest, LifetimeIntrinsicTest) {
@@ -1772,59 +1776,94 @@ TEST_F(ExecutionTest, LifetimeIntrinsicTest) {
17721776
static const int ThreadsPerGroup = NumThreadsX * NumThreadsY * NumThreadsZ;
17731777
static const int DispatchGroupCount = 1;
17741778

1775-
// TODO: There's probably a lot of things in the rest of this test that could be stripped away.
1779+
CComPtr<ID3D12Device> pDevice;
1780+
bool bSM_6_6_Supported = CreateDevice(&pDevice, D3D_SHADER_MODEL_6_6, false, true);
1781+
bool bSM_6_3_Supported = bSM_6_6_Supported;
1782+
if (!bSM_6_6_Supported) {
1783+
// Try 6.3 for downlevel DXR case
1784+
bSM_6_3_Supported = CreateDevice(&pDevice, D3D_SHADER_MODEL_6_3, false, true);
1785+
}
1786+
if (!bSM_6_3_Supported) {
1787+
// Otherwise, 6.0 better be supported for compute case
1788+
VERIFY_IS_TRUE(CreateDevice(&pDevice, D3D_SHADER_MODEL_6_0, false, false));
1789+
}
1790+
bool bDXRSupported = bSM_6_3_Supported && DoesDeviceSupportRayTracing(pDevice);
17761791

1777-
CComPtr<ID3D12Device5> pDevice;
1778-
if (!CreateDevice(reinterpret_cast<ID3D12Device**>(&pDevice), D3D_SHADER_MODEL_6_6, true, true)) {
1779-
WEX::Logging::Log::Comment(L"Lifetime test not run pre 6.6");
1792+
if (GetTestParamUseWARP(UseWarpByDefault()) || IsDeviceBasicAdapter(pDevice)) {
1793+
WEX::Logging::Log::Comment(L"WARP has a known issue with LifetimeIntrinsicTest.");
17801794
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped);
17811795
return;
17821796
}
17831797

1798+
if (!bSM_6_6_Supported) {
1799+
WEX::Logging::Log::Comment(L"Native lifetime markers skipped, device does not support SM 6.6");
1800+
}
1801+
if (!bDXRSupported) {
1802+
WEX::Logging::Log::Comment(L"DXR lifetime tests skipped, device does not support DXR");
1803+
}
1804+
17841805
std::vector<uint32_t> values;
17851806
SetupComputeValuePattern(values, ThreadsPerGroup * DispatchGroupCount);
17861807

17871808
// Run a number of tests for different configurations that will cause
1788-
// lifetime intrinsics to be placed directly, be replaced by a zeroinitializer
1789-
// store, or be replaced by an undef store.
1790-
LPCWSTR pOptions15[] = {L"/validator-version 1.5"};
1791-
LPCWSTR pOptions16[] = {L"/validator-version 1.6", L"/Vd"};
1809+
// lifetime intrinsics to be:
1810+
// - placed directly
1811+
// - translated to an undef store
1812+
// - translated to a zeroinitializer store
1813+
// against compute and DXR targets, downlevel and SM 6.6:
1814+
// - downlevel: cs_6_0, lib_6_3 (DXR)
1815+
// - cs_6_6, lib_6_6 (DXR)
17921816

17931817
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
17941818

1795-
// Test regular shader with zeroinitializer store.
1796-
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_0, false, pOptions15, _countof(pOptions15), values);
1819+
WEX::Logging::Log::Comment(L"==== cs_6_0 with default translation");
1820+
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_0, false,
1821+
{L"-enable-lifetime-markers"}, values);
17971822
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
17981823

1799-
if (DoesDeviceSupportRayTracing(pDevice)) {
1800-
// Test library with zeroinitializer store.
1801-
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_3, true, pOptions15, _countof(pOptions15), values);
1824+
if (bDXRSupported) {
1825+
WEX::Logging::Log::Comment(L"==== DXR lib_6_3 with default translation");
1826+
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_3, true,
1827+
{L"-enable-lifetime-markers"}, values);
18021828
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
18031829
}
18041830

1805-
// Testing SM 6.6 and validator version 1.6 requires experimental shaders
1806-
// being turned on.
1807-
if (!m_ExperimentalModeEnabled)
1808-
return;
1809-
1810-
// Test regular shader with undef store.
1811-
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_0, false, pOptions16, _countof(pOptions16), values);
1831+
WEX::Logging::Log::Comment(L"==== cs_6_0 with zeroinitializer translation");
1832+
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_0, false,
1833+
{L"-enable-lifetime-markers", L"-force-zero-store-lifetimes"}, values);
18121834
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
18131835

1814-
if (DoesDeviceSupportRayTracing(pDevice)) {
1815-
// Test library with undef store.
1816-
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_3, true, pOptions16, _countof(pOptions16), values);
1836+
if (bDXRSupported) {
1837+
WEX::Logging::Log::Comment(L"==== DXR lib_6_3 with zeroinitializer translation");
1838+
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_3, true,
1839+
{L"-enable-lifetime-markers", L"-force-zero-store-lifetimes"}, values);
18171840
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
18181841
}
18191842

1820-
// Test regular shader with lifetime intrinsics.
1821-
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_5, false, pOptions16, _countof(pOptions16), values); // TODO: Test 6.6 here!
1822-
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
1843+
if (bSM_6_6_Supported) {
1844+
WEX::Logging::Log::Comment(L"==== cs_6_6 with zeroinitializer translation");
1845+
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_6, false,
1846+
{L"-enable-lifetime-markers", L"-force-zero-store-lifetimes"}, values);
1847+
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
1848+
1849+
if (bDXRSupported) {
1850+
WEX::Logging::Log::Comment(L"==== DXR lib_6_6 with zeroinitializer translation");
1851+
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_6, true,
1852+
{L"-enable-lifetime-markers", L"-force-zero-store-lifetimes"}, values);
1853+
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
1854+
}
18231855

1824-
if (DoesDeviceSupportRayTracing(pDevice)) {
1825-
// Test library with lifetime intrinsics.
1826-
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_5, true, pOptions16, _countof(pOptions16), values); // TODO: Test 6.6 here!
1856+
WEX::Logging::Log::Comment(L"==== cs_6_6 with native lifetime markers");
1857+
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_6, false,
1858+
{L"-enable-lifetime-markers"}, values);
18271859
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
1860+
1861+
if (bDXRSupported) {
1862+
WEX::Logging::Log::Comment(L"==== DXR lib_6_6 with native lifetime markers");
1863+
RunLifetimeIntrinsicTest(pDevice, pShader, D3D_SHADER_MODEL_6_6, true,
1864+
{L"-enable-lifetime-markers"}, values);
1865+
VERIFY_ARE_EQUAL(values[1], (uint32_t)1);
1866+
}
18281867
}
18291868
}
18301869

@@ -9392,6 +9431,12 @@ TEST_F(ExecutionTest, HelperLaneTestWave) {
93929431
continue;
93939432
}
93949433

9434+
if (GetTestParamUseWARP(UseWarpByDefault()) || IsDeviceBasicAdapter(pDevice)) {
9435+
WEX::Logging::Log::Comment(L"WARP has a known issue with HelperLaneTestWave.");
9436+
WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped);
9437+
return;
9438+
}
9439+
93959440
if (!DoesDeviceSupportWaveOps(pDevice)) {
93969441
LogCommentFmt(L"Device does not support wave operations in shader model 6.%1u", ((UINT)sm & 0x0f));
93979442
continue;

0 commit comments

Comments
 (0)