Skip to content

Commit

Permalink
Don't set RaytracingTier1_1 based on subobjects; enable flag validati…
Browse files Browse the repository at this point in the history
…on (#6320) (#6322)

In validator version 1.7 and below, the RaytracingTier1_1 module flag
was set on every function if any StateObjectConfig subobject had the
AllowStateObjectAdditions flag set. This was incorrect, as the
requirement is validated in the runtime based on the use of the
subobject instead. Subobjects are removed from the module and placed in
RDAT during container serialization, so the requirement would be lost
when recomputing the flags in validation. This didn't break validation
because flag validation was completely disabled for libraries!

This change fixes this problem, and allows DxilValidation to validate
ShaderFlags because they will no longer mismatch due to this issue.
Running CollectShaderFlagsForModule is also necessary for collecting
per-function shader flags which will be used by call graph validation in
a subsequent change, so enabling flag validation unblocks that as well.

Fixes #6321

(cherry picked from commit fafbc42)
  • Loading branch information
tex3d authored Feb 20, 2024
1 parent c80232c commit 8bb9f28
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
25 changes: 0 additions & 25 deletions lib/DXIL/DxilModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,27 +288,6 @@ unsigned DxilModule::GetGlobalFlags() const {
return Flags;
}

static bool RequiresRaytracingTier1_1(const DxilSubobjects *pSubobjects) {
if (!pSubobjects)
return false;
for (const auto &it : pSubobjects->GetSubobjects()) {
switch (it.second->GetKind()) {
case DXIL::SubobjectKind::RaytracingPipelineConfig1:
return true;
case DXIL::SubobjectKind::StateObjectConfig: {
uint32_t configFlags;
if (it.second->GetStateObjectConfig(configFlags) &&
((configFlags &
(unsigned)DXIL::StateObjectFlags::AllowStateObjectAdditions) != 0))
return true;
} break;
default:
break;
}
}
return false;
}

void DxilModule::CollectShaderFlagsForModule(ShaderFlags &Flags) {
ComputeShaderCompatInfo();
for (auto &itInfo : m_FuncToShaderCompat)
Expand Down Expand Up @@ -380,10 +359,6 @@ void DxilModule::CollectShaderFlagsForModule(ShaderFlags &Flags) {
bool hasCSRawAndStructuredViaShader4X =
hasRawAndStructuredBuffer && m_pSM->GetMajor() == 4 && m_pSM->IsCS();
Flags.SetCSRawAndStructuredViaShader4X(hasCSRawAndStructuredViaShader4X);

if (!Flags.GetRaytracingTier1_1()) {
Flags.SetRaytracingTier1_1(RequiresRaytracingTier1_1(GetSubobjects()));
}
}

void DxilModule::CollectShaderFlagsForModule() {
Expand Down
4 changes: 0 additions & 4 deletions lib/HLSL/DxilValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4448,10 +4448,6 @@ static void ValidateResources(ValidationContext &ValCtx) {
}

static void ValidateShaderFlags(ValidationContext &ValCtx) {
// TODO: validate flags foreach entry.
if (ValCtx.isLibProfile)
return;

ShaderFlags calcFlags;
ValCtx.DxilMod.CollectShaderFlagsForModule(calcFlags);
const uint64_t mask = ShaderFlags::GetShaderFlagsRawForCollection();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// RUN: %dxilver 1.5 | %dxc -T lib_6_3 %s | FileCheck %s

// RaytracingTier1_1 flag should not be set on the module based on subobjects.
// This is not even set for compatibility with validator 1.7 because that
// validator did not validate the flags.
// CHECK-NOT: Raytracing tier 1.1 features

// CHECK: ; GlobalRootSignature grs = { <48 bytes> };
// CHECK: ; StateObjectConfig soc = { STATE_OBJECT_FLAG_ALLOW_LOCAL_DEPENDENCIES_ON_EXTERNAL_DEFINITIONS | STATE_OBJECT_FLAG_ALLOW_STATE_OBJECT_ADDITIONS };
// CHECK: ; LocalRootSignature lrs = { <48 bytes> };
Expand Down Expand Up @@ -27,6 +32,7 @@ RaytracingPipelineConfig1 rpc2 = {32, RAYTRACING_PIPELINE_FLAG_NONE };
TriangleHitGroup trHitGt = {"a", "b"};
ProceduralPrimitiveHitGroup ppHitGt = { "a", "b", "c"};

int main(int i : INDEX) : SV_Target {
return 1;
}
// DXR entry point to ensure RDAT flags match during validation.
[shader("raygeneration")]
void main(void) {
}

0 comments on commit 8bb9f28

Please sign in to comment.