@@ -99,6 +99,7 @@ struct consts
9999struct v2f
100100{
101101 float4 pos : SV_POSITION;
102+ float4 s : S;
102103 float2 zeroVal : ZERO;
103104 float tinyVal : TINY;
104105 float oneVal : ONE;
@@ -116,6 +117,18 @@ v2f main(consts IN, uint tri : SV_InstanceID)
116117 v2f OUT = (v2f)0;
117118
118119 OUT.pos = float4(IN.pos.x + IN.pos.z * float(tri), IN.pos.y, 0.0f, 1);
120+ // OUT.s.xy : 0 -> 2 : across the triangle x & y, changes per pixel
121+ OUT.s.x = IN.pos.x + 1.0;
122+ OUT.s.x *= 512.0;
123+ OUT.s.x -= 1.0;
124+ OUT.s.x /= 2.0;
125+
126+ OUT.s.y = IN.pos.y;
127+ OUT.s.y *= 2.0;
128+ OUT.s.y += 0.5;
129+ OUT.s.y = 2.0 - OUT.s.y;
130+ // OUT.s.zw : large variation in x & y
131+ OUT.s.zw = (IN.pos.xy + float2(543.0, 213.0)) * (IN.pos.yx + float2(100.0, -113.0));
119132
120133 OUT.zeroVal = IN.zeroVal.xx;
121134 OUT.oneVal = IN.oneVal;
@@ -1000,6 +1013,49 @@ float4 main(v2f IN) : SV_Target0
10001013 return float4(0.4f, 0.4f, 0.4f, 0.4f);
10011014}
10021015
1016+ )EOSHADER" ;
1017+
1018+ std::string noResourcesPixel = R"EOSHADER(
1019+
1020+ float4 main(v2f IN) : SV_Target0
1021+ {
1022+ float posinf = IN.oneVal/IN.zeroVal.x;
1023+ float neginf = IN.negoneVal/IN.zeroVal.x;
1024+ float nan = IN.zeroVal.x/IN.zeroVal.y;
1025+
1026+ float negone = IN.negoneVal;
1027+ float posone = IN.oneVal;
1028+ float zero = IN.zeroVal.x;
1029+ float tiny = IN.tinyVal;
1030+
1031+ int intval = IN.intval;
1032+
1033+ if(IN.tri == 0)
1034+ {
1035+ // IN.s.xy : 0/1/2 : across the triangle in x & y
1036+ float2 s = IN.s.xy;
1037+ return float4(ddx(s.x), ddy(s.y), s.x, s.y);
1038+ }
1039+ if(IN.tri == 1)
1040+ {
1041+ // IN.s.wz : large variation across the triangle in x & y
1042+ float2 s = IN.s.zw;
1043+ return float4(ddx(s.x), ddy(s.y), s.x, s.y);
1044+ }
1045+ if(IN.tri == 2)
1046+ {
1047+ // IN.s : 0/1/2 : across the triangle in x & y
1048+ float2 s = IN.s.xy;
1049+ if (s.x > 0.5)
1050+ discard;
1051+ if (s.y > 0.5)
1052+ discard;
1053+ s *= posone * float2(0.55f, 0.48f);
1054+ return float4(ddx(s.x), ddy(s.y), s.x, s.y);
1055+ }
1056+
1057+ return float4(0.4f, 0.4f, 0.4f, 0.4f);
1058+ };
10031059)EOSHADER" ;
10041060
10051061 std::string msaaPixel = R"EOSHADER(
@@ -1093,7 +1149,7 @@ void main(int3 inTestIndex : SV_GroupID)
10931149 size_t lastTest = pixel.rfind (" IN.tri == " );
10941150 lastTest += sizeof (" IN.tri == " ) - 1 ;
10951151
1096- const uint32_t numTests = atoi (pixel.c_str () + lastTest) + 1 ;
1152+ const uint32_t numResTests = atoi (pixel.c_str () + lastTest) + 1 ;
10971153
10981154 std::string undefined_tests = " Undefined tests:" ;
10991155
@@ -1110,6 +1166,10 @@ void main(int3 inTestIndex : SV_GroupID)
11101166 undef = pixel.find (" undefined-test" , undef + 1 );
11111167 }
11121168
1169+ lastTest = noResourcesPixel.rfind (" IN.tri == " );
1170+ lastTest += sizeof (" IN.tri == " ) - 1 ;
1171+ const uint32_t numNoResTests = atoi (noResourcesPixel.c_str () + lastTest) + 1 ;
1172+
11131173 std::vector<D3D12_INPUT_ELEMENT_DESC> inputLayout;
11141174 inputLayout.reserve (4 );
11151175 inputLayout.push_back ({
@@ -1250,9 +1310,9 @@ void main(int3 inTestIndex : SV_GroupID)
12501310 psos[3 ]->SetName (L" ps_5_1_opt" );
12511311
12521312 // Recompile with SM 6.0, SM 6.2 and SM 6.6
1253- uint32_t compileOptions = CompileOptionFlags::None;
1254- if (opts4. Native16BitShaderOpsSupported )
1255- compileOptions |= CompileOptionFlags::Enable16BitTypes ;
1313+ const uint32_t compileOptions = (opts4. Native16BitShaderOpsSupported )
1314+ ? CompileOptionFlags::Enable16BitTypes
1315+ : CompileOptionFlags::None ;
12561316 if (supportSM60)
12571317 {
12581318 ID3DBlobPtr vsblob = Compile (common + vertex, " main" , " vs_6_0" );
@@ -1314,7 +1374,113 @@ void main(int3 inTestIndex : SV_GroupID)
13141374 psos[9 ]->SetName (L" ps_6_6_opt" );
13151375 }
13161376
1317- static const uint32_t texDim = AlignUp (numTests, 64U ) * 4 ;
1377+ ID3D12PipelineStatePtr noResPSOs[numShaderModels * 2 ] = {};
1378+ noResPSOs[0 ] = MakePSO ()
1379+ .RootSig (sig)
1380+ .InputLayout (inputLayout)
1381+ .VS (vs5blob)
1382+ .PS (Compile (common + noResourcesPixel, " main" , " ps_5_0" ,
1383+ CompileOptionFlags::SkipOptimise))
1384+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1385+ noResPSOs[0 ]->SetName (L" ps_5_0" );
1386+ noResPSOs[1 ] =
1387+ MakePSO ()
1388+ .RootSig (sig)
1389+ .InputLayout (inputLayout)
1390+ .VS (vs5blob)
1391+ .PS (Compile (common + noResourcesPixel, " main" , " ps_5_0" , CompileOptionFlags::None))
1392+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1393+ noResPSOs[1 ]->SetName (L" ps_5_0_opt" );
1394+
1395+ // Recompile the same PS with SM 5.1 to test shader debugging with the different bytecode
1396+ noResPSOs[2 ] = MakePSO ()
1397+ .RootSig (sig)
1398+ .InputLayout (inputLayout)
1399+ .VS (vs5blob)
1400+ .PS (Compile (common + " \n #define SM_5_1 1\n " + noResourcesPixel, " main" ,
1401+ " ps_5_1" , CompileOptionFlags::SkipOptimise))
1402+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1403+ noResPSOs[2 ]->SetName (L" ps_5_1" );
1404+ noResPSOs[3 ] = MakePSO ()
1405+ .RootSig (sig)
1406+ .InputLayout (inputLayout)
1407+ .VS (vs5blob)
1408+ .PS (Compile (common + " \n #define SM_5_1 1\n " + noResourcesPixel, " main" ,
1409+ " ps_5_1" , CompileOptionFlags::None))
1410+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1411+ noResPSOs[3 ]->SetName (L" ps_5_1_opt" );
1412+
1413+ // Recompile with SM 6.0, SM 6.2 and SM 6.6
1414+ if (supportSM60)
1415+ {
1416+ ID3DBlobPtr vsblob = Compile (common + vertex, " main" , " vs_6_0" );
1417+ noResPSOs[4 ] =
1418+ MakePSO ()
1419+ .RootSig (sig)
1420+ .InputLayout (inputLayout)
1421+ .VS (vsblob)
1422+ .PS (Compile (common + " \n #define SM_6_0 1\n " + shaderDefines + noResourcesPixel,
1423+ " main" , " ps_6_0" , CompileOptionFlags::SkipOptimise))
1424+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1425+ noResPSOs[4 ]->SetName (L" ps_6_0" );
1426+ noResPSOs[5 ] =
1427+ MakePSO ()
1428+ .RootSig (sig)
1429+ .InputLayout (inputLayout)
1430+ .VS (vsblob)
1431+ .PS (Compile (common + " \n #define SM_6_0 1\n " + shaderDefines + noResourcesPixel,
1432+ " main" , " ps_6_0" , CompileOptionFlags::None))
1433+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1434+ noResPSOs[5 ]->SetName (L" ps_6_0_opt" );
1435+ }
1436+ if (supportSM62)
1437+ {
1438+ ID3DBlobPtr vsblob = Compile (common + vertex, " main" , " vs_6_2" );
1439+ noResPSOs[6 ] =
1440+ MakePSO ()
1441+ .RootSig (sig)
1442+ .InputLayout (inputLayout)
1443+ .VS (vsblob)
1444+ .PS (Compile (common + " \n #define SM_6_2 1\n " + shaderDefines + noResourcesPixel,
1445+ " main" , " ps_6_2" , compileOptions | CompileOptionFlags::SkipOptimise))
1446+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1447+ noResPSOs[6 ]->SetName (L" ps_6_2" );
1448+ noResPSOs[7 ] =
1449+ MakePSO ()
1450+ .RootSig (sig)
1451+ .InputLayout (inputLayout)
1452+ .VS (vsblob)
1453+ .PS (Compile (common + " \n #define SM_6_2 1\n " + shaderDefines + noResourcesPixel,
1454+ " main" , " ps_6_2" , compileOptions))
1455+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1456+ noResPSOs[7 ]->SetName (L" ps_6_2_opt" );
1457+ }
1458+ if (supportSM66)
1459+ {
1460+ ID3DBlobPtr vsblob = Compile (common + vertex, " main" , " vs_6_6" );
1461+ noResPSOs[8 ] =
1462+ MakePSO ()
1463+ .RootSig (sig)
1464+ .InputLayout (inputLayout)
1465+ .VS (vsblob)
1466+ .PS (Compile (common + " \n #define SM_6_6 1\n " + shaderDefines + noResourcesPixel,
1467+ " main" , " ps_6_6" , compileOptions | CompileOptionFlags::SkipOptimise))
1468+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1469+ noResPSOs[8 ]->SetName (L" ps_6_6" );
1470+ noResPSOs[9 ] =
1471+ MakePSO ()
1472+ .RootSig (sig)
1473+ .InputLayout (inputLayout)
1474+ .VS (vsblob)
1475+ .PS (Compile (common + " \n #define SM_6_6 1\n " + shaderDefines + noResourcesPixel,
1476+ " main" , " ps_6_6" , compileOptions))
1477+ .RTVs ({DXGI_FORMAT_R32G32B32A32_FLOAT});
1478+ noResPSOs[9 ]->SetName (L" ps_6_6_opt" );
1479+ }
1480+
1481+ static_assert (ARRAY_COUNT (psos) == ARRAY_COUNT (noResPSOs), " Mismatched PSO counts" );
1482+
1483+ static const uint32_t texDim = AlignUp (std::max (numResTests, numNoResTests), 64U ) * 4 ;
13181484
13191485 ID3D12ResourcePtr fltTex = MakeTexture (DXGI_FORMAT_R32G32B32A32_FLOAT, texDim, 4 )
13201486 .RTV ()
@@ -1748,19 +1914,10 @@ void main(int3 inTestIndex : SV_GroupID)
17481914
17491915 setMarker (cmd, undefined_tests);
17501916
1751- float blitOffsets[] = {0 .0f , 4 .0f , 8 .0f , 12 .0f , 16 .0f , 20 .0f , 24 .0f , 28 .0f , 32 .0f , 36 .0f };
1752- D3D12_RECT scissors[] = {
1753- {0 , 0 , (int )texDim, 4 }, {0 , 4 , (int )texDim, 8 }, {0 , 8 , (int )texDim, 12 },
1754- {0 , 12 , (int )texDim, 16 }, {0 , 16 , (int )texDim, 20 }, {0 , 20 , (int )texDim, 24 },
1755- {0 , 24 , (int )texDim, 28 }, {0 , 28 , (int )texDim, 32 }, {0 , 32 , (int )texDim, 36 },
1756- {0 , 36 , (int )texDim, 40 },
1757- };
17581917 const char *markers[] = {
17591918 " sm_5_0" , " sm_5_0_opt" , " sm_5_1" , " sm_5_1_opt" , " sm_6_0" ,
17601919 " sm_6_0_opt" , " sm_6_2" , " sm_6_2_opt" , " sm_6_6" , " sm_6_6_opt" ,
17611920 };
1762- static_assert (ARRAY_COUNT (blitOffsets) == ARRAY_COUNT (psos), " mismatched array dimension" );
1763- static_assert (ARRAY_COUNT (scissors) == ARRAY_COUNT (psos), " mismatched array dimension" );
17641921 static_assert (ARRAY_COUNT (markers) == ARRAY_COUNT (psos), " mismatched array dimension" );
17651922
17661923 // Clear, draw, and blit to backbuffer - once for each SM 5.0, 5.1, 6.0, 6.2, 6.6
@@ -1774,54 +1931,81 @@ void main(int3 inTestIndex : SV_GroupID)
17741931 TEST_ASSERT (countGraphicsPasses <= ARRAY_COUNT (psos), " More graphic passes than psos" );
17751932 for (size_t i = 0 ; i < countGraphicsPasses; ++i)
17761933 {
1777- OMSetRenderTargets (cmd, {fltRTV}, {});
1778- ClearRenderTargetView (cmd, fltRTV, {0 .2f , 0 .2f , 0 .2f , 1 .0f });
1934+ float blitOffset = 8 .0f * i;
1935+ D3D12_RECT scissor = {};
1936+ scissor.left = 0 ;
1937+ scissor.top = (int )(8 * i);
1938+ scissor.right = (int )texDim;
17791939
1780- IASetVertexBuffer (cmd, vb, sizeof (ConstsA2V), 0 );
1781- cmd->IASetPrimitiveTopology (D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
1782-
1783- cmd->SetGraphicsRootSignature (sig);
1784- cmd->SetDescriptorHeaps (1 , &m_CBVUAVSRV.GetInterfacePtr ());
1785- cmd->SetGraphicsRootDescriptorTable (0 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1786- cmd->SetGraphicsRootDescriptorTable (1 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1787- cmd->SetGraphicsRootDescriptorTable (2 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1788- cmd->SetGraphicsRootDescriptorTable (3 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1789- cmd->SetGraphicsRootDescriptorTable (4 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1790- cmd->SetGraphicsRootUnorderedAccessView (5 , rootDummy->GetGPUVirtualAddress ());
1791- cmd->SetGraphicsRootShaderResourceView (6 ,
1792- rootStruct->GetGPUVirtualAddress () + renderDataSize);
1793- cmd->SetGraphicsRootDescriptorTable (7 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1794-
1795- cmd->SetPipelineState (psos[i]);
1796-
1797- RSSetViewport (cmd, {0 .0f , 0 .0f , (float )texDim, 4 .0f , 0 .0f , 1 .0f });
1798- RSSetScissorRect (cmd, {0 , 0 , (int )texDim, 4 });
1799-
1800- UINT zero[4 ] = {};
1801- cmd->ClearUnorderedAccessViewUint (uav1gpu, uav1cpu, rawBuf2, zero, 0 , NULL );
1802- cmd->ClearUnorderedAccessViewUint (uav2gpu, uav2cpu, structBuf2, zero, 0 , NULL );
1803- cmd->ClearUnorderedAccessViewUint (uav3gpu, uav3cpu, rawBuf2, zero, 0 , NULL );
1804-
1805- // Add a marker so we can easily locate this draw
1806- setMarker (cmd, markers[i]);
1807- cmd->DrawInstanced (3 , numTests, 0 , 0 );
1808-
1809- ResourceBarrier (cmd, fltTex, D3D12_RESOURCE_STATE_RENDER_TARGET,
1810- D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
1811-
1812- OMSetRenderTargets (cmd, {rtv}, {});
1813- RSSetViewport (cmd, {0 .0f , 0 .0f , (float )screenWidth, (float )screenHeight, 0 .0f , 1 .0f });
1814- RSSetScissorRect (cmd, scissors[i]);
1815-
1816- cmd->IASetPrimitiveTopology (D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
1817- cmd->SetGraphicsRootSignature (blitSig);
1818- cmd->SetPipelineState (blitpso);
1819- cmd->SetGraphicsRoot32BitConstant (0 , *(UINT *)&blitOffsets[i], 0 );
1820- cmd->SetGraphicsRootDescriptorTable (1 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1821- cmd->DrawInstanced (4 , 1 , 0 , 0 );
1822-
1823- ResourceBarrier (cmd, fltTex, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
1824- D3D12_RESOURCE_STATE_RENDER_TARGET);
1940+ for (size_t j = 0 ; j < 2 ; ++j)
1941+ {
1942+ OMSetRenderTargets (cmd, {fltRTV}, {});
1943+ ClearRenderTargetView (cmd, fltRTV, {0 .2f , 0 .2f , 0 .2f , 1 .0f });
1944+
1945+ IASetVertexBuffer (cmd, vb, sizeof (ConstsA2V), 0 );
1946+ cmd->IASetPrimitiveTopology (D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
1947+
1948+ cmd->SetGraphicsRootSignature (sig);
1949+ cmd->SetDescriptorHeaps (1 , &m_CBVUAVSRV.GetInterfacePtr ());
1950+ cmd->SetGraphicsRootDescriptorTable (0 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1951+ cmd->SetGraphicsRootDescriptorTable (1 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1952+ cmd->SetGraphicsRootDescriptorTable (2 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1953+ cmd->SetGraphicsRootDescriptorTable (3 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1954+ cmd->SetGraphicsRootDescriptorTable (4 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1955+ cmd->SetGraphicsRootUnorderedAccessView (5 , rootDummy->GetGPUVirtualAddress ());
1956+ cmd->SetGraphicsRootShaderResourceView (
1957+ 6 , rootStruct->GetGPUVirtualAddress () + renderDataSize);
1958+ cmd->SetGraphicsRootDescriptorTable (7 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
1959+
1960+ // Add a marker so we can easily locate this draw
1961+ std::string markerName = markers[i];
1962+ uint32_t numTests = 0 ;
1963+ ID3D12PipelineStatePtr pso = NULL ;
1964+ if (j == 0 )
1965+ {
1966+ pso = psos[i];
1967+ numTests = numResTests;
1968+ }
1969+ else
1970+ {
1971+ markerName = " NoResources " + markerName;
1972+ pso = noResPSOs[i];
1973+ numTests = numNoResTests;
1974+ }
1975+ cmd->SetPipelineState (pso);
1976+
1977+ RSSetViewport (cmd, {0 .0f , 0 .0f , (float )texDim, 4 .0f , 0 .0f , 1 .0f });
1978+ RSSetScissorRect (cmd, {0 , 0 , (int )texDim, 4 });
1979+
1980+ UINT zero[4 ] = {};
1981+ cmd->ClearUnorderedAccessViewUint (uav1gpu, uav1cpu, rawBuf2, zero, 0 , NULL );
1982+ cmd->ClearUnorderedAccessViewUint (uav2gpu, uav2cpu, structBuf2, zero, 0 , NULL );
1983+ cmd->ClearUnorderedAccessViewUint (uav3gpu, uav3cpu, rawBuf2, zero, 0 , NULL );
1984+
1985+ setMarker (cmd, markerName.c_str ());
1986+ cmd->DrawInstanced (3 , numTests, 0 , 0 );
1987+
1988+ ResourceBarrier (cmd, fltTex, D3D12_RESOURCE_STATE_RENDER_TARGET,
1989+ D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
1990+
1991+ scissor.bottom = scissor.top + 4 ;
1992+ OMSetRenderTargets (cmd, {rtv}, {});
1993+ RSSetViewport (cmd, {0 .0f , 0 .0f , (float )screenWidth, (float )screenHeight, 0 .0f , 1 .0f });
1994+ RSSetScissorRect (cmd, scissor);
1995+
1996+ cmd->IASetPrimitiveTopology (D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
1997+ cmd->SetGraphicsRootSignature (blitSig);
1998+ cmd->SetPipelineState (blitpso);
1999+ cmd->SetGraphicsRoot32BitConstant (0 , *(UINT *)&blitOffset, 0 );
2000+ cmd->SetGraphicsRootDescriptorTable (1 , m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart ());
2001+ cmd->DrawInstanced (4 , 1 , 0 , 0 );
2002+
2003+ ResourceBarrier (cmd, fltTex, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
2004+ D3D12_RESOURCE_STATE_RENDER_TARGET);
2005+
2006+ scissor.top += 4 ;
2007+ blitOffset += 4 .0f ;
2008+ }
18252009 }
18262010
18272011 // Render MSAA test
0 commit comments