Skip to content

Commit fafbc42

Browse files
authored
Don't set RaytracingTier1_1 based on subobjects; enable flag validation (microsoft#6320)
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 microsoft#6321
1 parent 4c4a588 commit fafbc42

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

lib/DXIL/DxilModule.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -288,27 +288,6 @@ unsigned DxilModule::GetGlobalFlags() const {
288288
return Flags;
289289
}
290290

291-
static bool RequiresRaytracingTier1_1(const DxilSubobjects *pSubobjects) {
292-
if (!pSubobjects)
293-
return false;
294-
for (const auto &it : pSubobjects->GetSubobjects()) {
295-
switch (it.second->GetKind()) {
296-
case DXIL::SubobjectKind::RaytracingPipelineConfig1:
297-
return true;
298-
case DXIL::SubobjectKind::StateObjectConfig: {
299-
uint32_t configFlags;
300-
if (it.second->GetStateObjectConfig(configFlags) &&
301-
((configFlags &
302-
(unsigned)DXIL::StateObjectFlags::AllowStateObjectAdditions) != 0))
303-
return true;
304-
} break;
305-
default:
306-
break;
307-
}
308-
}
309-
return false;
310-
}
311-
312291
void DxilModule::CollectShaderFlagsForModule(ShaderFlags &Flags) {
313292
ComputeShaderCompatInfo();
314293
for (auto &itInfo : m_FuncToShaderCompat)
@@ -380,10 +359,6 @@ void DxilModule::CollectShaderFlagsForModule(ShaderFlags &Flags) {
380359
bool hasCSRawAndStructuredViaShader4X =
381360
hasRawAndStructuredBuffer && m_pSM->GetMajor() == 4 && m_pSM->IsCS();
382361
Flags.SetCSRawAndStructuredViaShader4X(hasCSRawAndStructuredViaShader4X);
383-
384-
if (!Flags.GetRaytracingTier1_1()) {
385-
Flags.SetRaytracingTier1_1(RequiresRaytracingTier1_1(GetSubobjects()));
386-
}
387362
}
388363

389364
void DxilModule::CollectShaderFlagsForModule() {

lib/HLSL/DxilValidation.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4448,10 +4448,6 @@ static void ValidateResources(ValidationContext &ValCtx) {
44484448
}
44494449

44504450
static void ValidateShaderFlags(ValidationContext &ValCtx) {
4451-
// TODO: validate flags foreach entry.
4452-
if (ValCtx.isLibProfile)
4453-
return;
4454-
44554451
ShaderFlags calcFlags;
44564452
ValCtx.DxilMod.CollectShaderFlagsForModule(calcFlags);
44574453
const uint64_t mask = ShaderFlags::GetShaderFlagsRawForCollection();

tools/clang/test/HLSLFileCheck/shader_targets/raytracing/subobjects_raytracingPipelineConfig1.hlsl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// RUN: %dxilver 1.5 | %dxc -T lib_6_3 %s | FileCheck %s
22

3+
// RaytracingTier1_1 flag should not be set on the module based on subobjects.
4+
// This is not even set for compatibility with validator 1.7 because that
5+
// validator did not validate the flags.
6+
// CHECK-NOT: Raytracing tier 1.1 features
7+
38
// CHECK: ; GlobalRootSignature grs = { <48 bytes> };
49
// CHECK: ; StateObjectConfig soc = { STATE_OBJECT_FLAG_ALLOW_LOCAL_DEPENDENCIES_ON_EXTERNAL_DEFINITIONS | STATE_OBJECT_FLAG_ALLOW_STATE_OBJECT_ADDITIONS };
510
// CHECK: ; LocalRootSignature lrs = { <48 bytes> };
@@ -27,6 +32,7 @@ RaytracingPipelineConfig1 rpc2 = {32, RAYTRACING_PIPELINE_FLAG_NONE };
2732
TriangleHitGroup trHitGt = {"a", "b"};
2833
ProceduralPrimitiveHitGroup ppHitGt = { "a", "b", "c"};
2934

30-
int main(int i : INDEX) : SV_Target {
31-
return 1;
32-
}
35+
// DXR entry point to ensure RDAT flags match during validation.
36+
[shader("raygeneration")]
37+
void main(void) {
38+
}

0 commit comments

Comments
 (0)