@@ -112,6 +112,11 @@ class PixTest : public ::testing::Test {
112
112
TEST_METHOD (SignatureModification_VertexIdAlready)
113
113
TEST_METHOD (SignatureModification_SomethingElseFirst)
114
114
115
+ TEST_METHOD (AccessTracking_ModificationReport_Nothing)
116
+ TEST_METHOD (AccessTracking_ModificationReport_Read)
117
+ TEST_METHOD (AccessTracking_ModificationReport_Write)
118
+ TEST_METHOD (AccessTracking_ModificationReport_SM66)
119
+
115
120
TEST_METHOD (PixStructAnnotation_Lib_DualRaygen)
116
121
TEST_METHOD (PixStructAnnotation_Lib_RaygenAllocaStructAlignment)
117
122
@@ -348,6 +353,8 @@ class PixTest : public ::testing::Test {
348
353
*ppNewShaderOut = pNewContainer.Detach ();
349
354
}
350
355
356
+ void ValidateAccessTrackingMods (const char *hlsl, bool modsExpected);
357
+
351
358
class ModuleAndHangersOn {
352
359
std::unique_ptr<llvm::LLVMContext> llvmContext;
353
360
std::unique_ptr<llvm::Module> llvmModule;
@@ -429,7 +436,7 @@ class PixTest : public ::testing::Test {
429
436
const wchar_t *profile = L" as_6_5" );
430
437
void ValidateAllocaWrite (std::vector<AllocaWrite> const &allocaWrites,
431
438
size_t index, const char *name);
432
- CComPtr<IDxcBlob> RunShaderAccessTrackingPass (IDxcBlob *blob);
439
+ PassOutput RunShaderAccessTrackingPass (IDxcBlob *blob);
433
440
std::string RunDxilPIXAddTidToAmplificationShaderPayloadPass (IDxcBlob *blob);
434
441
CComPtr<IDxcBlob> RunDxilPIXMeshShaderOutputPass (IDxcBlob *blob);
435
442
CComPtr<IDxcBlob> RunDxilPIXDXRInvocationsLog (IDxcBlob *blob);
@@ -576,13 +583,14 @@ TEST_F(PixTest, CompileDebugDisasmPDB) {
576
583
VERIFY_SUCCEEDED (pCompiler->Disassemble (pPdbBlob, &pDisasm));
577
584
}
578
585
579
- CComPtr<IDxcBlob> PixTest::RunShaderAccessTrackingPass (IDxcBlob *blob) {
586
+ PassOutput PixTest::RunShaderAccessTrackingPass (IDxcBlob *blob) {
580
587
CComPtr<IDxcOptimizer> pOptimizer;
581
588
VERIFY_SUCCEEDED (
582
589
m_dllSupport.CreateInstance (CLSID_DxcOptimizer, &pOptimizer));
583
590
std::vector<LPCWSTR> Options;
584
591
Options.push_back (L" -opt-mod-passes" );
585
- Options.push_back (L" -hlsl-dxil-pix-shader-access-instrumentation,config=" );
592
+ Options.push_back (L" -hlsl-dxil-pix-shader-access-instrumentation,config=U0:0:"
593
+ L" 10i0;U0:1:2i0;.0;0;0." );
586
594
587
595
CComPtr<IDxcBlob> pOptimizedModule;
588
596
CComPtr<IDxcBlobEncoding> pText;
@@ -604,7 +612,12 @@ CComPtr<IDxcBlob> PixTest::RunShaderAccessTrackingPass(IDxcBlob *blob) {
604
612
CComPtr<IDxcBlob> pNewContainer;
605
613
VERIFY_SUCCEEDED (pAssembleResult->GetResult (&pNewContainer));
606
614
607
- return pNewContainer;
615
+ PassOutput ret;
616
+ ret.blob = pNewContainer;
617
+ std::string outputText = BlobToUtf8 (pText);
618
+ ret.lines = Tokenize (outputText.c_str (), " \n " );
619
+
620
+ return ret;
608
621
}
609
622
610
623
CComPtr<IDxcBlob> PixTest::RunDxilPIXMeshShaderOutputPass (IDxcBlob *blob) {
@@ -816,6 +829,61 @@ TEST_F(PixTest, SignatureModification_SomethingElseFirst) {
816
829
VERIFY_ARE_EQUAL (sig.GetElement (2 ).GetStartRow (), 2 );
817
830
}
818
831
832
+ void PixTest::ValidateAccessTrackingMods (const char *hlsl, bool modsExpected) {
833
+ auto code = Compile (m_dllSupport, hlsl, L" ps_6_6" , {L" -Od" }, L" main" );
834
+ auto result = RunShaderAccessTrackingPass (code).lines ;
835
+ bool hasMods = true ;
836
+ for (auto const &line : result)
837
+ if (line.find (" NotModified" ) != std::string::npos)
838
+ hasMods = false ;
839
+ VERIFY_ARE_EQUAL (modsExpected, hasMods);
840
+ }
841
+
842
+ TEST_F (PixTest, AccessTracking_ModificationReport_Nothing) {
843
+ const char *hlsl = R"(
844
+ float main() : SV_Target
845
+ {
846
+ return 0;
847
+ }
848
+ )" ;
849
+ ValidateAccessTrackingMods (hlsl, false );
850
+ }
851
+
852
+ TEST_F (PixTest, AccessTracking_ModificationReport_Read) {
853
+ const char *hlsl = R"(
854
+ RWByteAddressBuffer g_texture;
855
+ float main() : SV_Target
856
+ {
857
+ return g_texture.Load(0);
858
+ }
859
+ )" ;
860
+ ValidateAccessTrackingMods (hlsl, true );
861
+ }
862
+
863
+ TEST_F (PixTest, AccessTracking_ModificationReport_Write) {
864
+ const char *hlsl = R"(
865
+ RWByteAddressBuffer g_texture;
866
+ float main() : SV_Target
867
+ {
868
+ g_texture.Store(0, 0);
869
+ return 0;
870
+ }
871
+ )" ;
872
+ ValidateAccessTrackingMods (hlsl, true );
873
+ }
874
+
875
+ TEST_F (PixTest, AccessTracking_ModificationReport_SM66) {
876
+ const char *hlsl = R"(
877
+ float main() : SV_Target
878
+ {
879
+ RWByteAddressBuffer g_texture = ResourceDescriptorHeap[0];
880
+ g_texture.Store(0, 0);
881
+ return 0;
882
+ }
883
+ )" ;
884
+ ValidateAccessTrackingMods (hlsl, true );
885
+ }
886
+
819
887
TEST_F (PixTest, AddToASGroupSharedPayload) {
820
888
821
889
const char *hlsl = R"(
@@ -2720,7 +2788,7 @@ void MyMiss(inout MyPayload payload)
2720
2788
CComPtr<IDxcBlob> compiled;
2721
2789
VERIFY_SUCCEEDED (pResult->GetResult (&compiled));
2722
2790
2723
- auto optimizedContainer = RunShaderAccessTrackingPass (compiled);
2791
+ auto optimizedContainer = RunShaderAccessTrackingPass (compiled). blob ;
2724
2792
2725
2793
const char *pBlobContent =
2726
2794
reinterpret_cast <const char *>(optimizedContainer->GetBufferPointer ());
@@ -2790,7 +2858,7 @@ float4 main(int i : A, float j : B) : SV_TARGET
2790
2858
)x" ;
2791
2859
2792
2860
auto compiled = Compile (m_dllSupport, dynamicTextureAccess, L" ps_6_6" );
2793
- auto pOptimizedContainer = RunShaderAccessTrackingPass (compiled);
2861
+ auto pOptimizedContainer = RunShaderAccessTrackingPass (compiled). blob ;
2794
2862
2795
2863
const char *pBlobContent =
2796
2864
reinterpret_cast <const char *>(pOptimizedContainer->GetBufferPointer ());
0 commit comments