Skip to content
4 changes: 4 additions & 0 deletions tools/clang/lib/AST/ASTContextHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,10 @@ void hlsl::AddRaytracingConstants(ASTContext &context) {
AddConstUInt(
context, StringRef("RAYTRACING_PIPELINE_FLAG_SKIP_PROCEDURAL_PRIMITIVES"),
(unsigned)DXIL::RaytracingPipelineFlags::SkipProceduralPrimitives);
AddConstUInt(context, context.getTranslationUnitDecl(),
StringRef("RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS"),
(unsigned)DXIL::RaytracingPipelineFlags::AllowOpacityMicromaps,
ConstructAvailabilityAttribute(context, VT69));
Comment thread
tex3d marked this conversation as resolved.
}

/// <summary> Adds all constants and enums for sampler feedback </summary>
Expand Down
17 changes: 16 additions & 1 deletion tools/clang/lib/Sema/SemaHLSLDiagnoseTU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
<< PatchConstantFunctionReturnIdx;
}
}

DXIL::ShaderKind EntrySK = shaderModel->GetKind();
DXIL::NodeLaunchType NodeLaunchTy = DXIL::NodeLaunchType::Invalid;
if (EntrySK == DXIL::ShaderKind::Library) {
Expand Down Expand Up @@ -733,4 +732,20 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
for (FunctionDecl *FD : callGraph.GetVisitedFunctions())
Visitor.TraverseDecl(FD);
}

if (shaderModel->GetKind() == DXIL::ShaderKind::Library) {
for (VarDecl *VD : GlobalsWithInit) {
Comment thread
tex3d marked this conversation as resolved.
Outdated
DXIL::NodeLaunchType NodeLaunchTy = DXIL::NodeLaunchType::Invalid;
HLSLReachableDiagnoseVisitor Visitor(
self, shaderModel, shaderModel->GetKind(), NodeLaunchTy, nullptr,
DiagnosedCalls, DeclAvailabilityChecked, DiagnosedTypeLocs);
QualType QT = VD->getType();
if (const RecordType *RT = QT->getAs<RecordType>()) {
RecordDecl *RD = RT->getDecl();
if (!RD->hasAttr<HLSLSubObjectAttr>())
continue;
Visitor.TraverseDecl(VD);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %dxilver 1.9 | %dxc -T lib_6_9 %s | FileCheck %s
// RUN: %dxilver 1.9 | %dxc -T lib_6_9 -ast-dump %s | FileCheck -check-prefix=AST %s
// RUN: %dxilver 1.9 | %dxc -T lib_6_9 -ast-dump-implicit %s | FileCheck -check-prefix=ASTIMPL %s


// CHECK: ; RaytracingPipelineConfig1 rpc = { MaxTraceRecursionDepth = 32, Flags = RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS };

// AST: TranslationUnitDecl 0x{{.+}} <<invalid sloc>> <invalid sloc>
// AST-NEXT: VarDecl 0x{{.+}} rpc 'RaytracingPipelineConfig1' static cinit
// AST-NEXT: InitListExpr 0x{{.+}} 'RaytracingPipelineConfig1'
// AST-NEXT: ImplicitCastExpr 0x{{.+}} 'unsigned int' <IntegralCast>
// AST-NEXT: IntegerLiteral 0x{{.+}} 'literal int' 32
// AST-NEXT: ImplicitCastExpr 0x{{.+}} 'unsigned int' <LValueToRValue>
// AST-NEXT: DeclRefExpr 0x{{.+}} 'const unsigned int' lvalue Var 0x{{.+}} 'RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS' 'const unsigned int'
// ASTIMPL: VarDecl 0x{{.+}} <<invalid sloc>> <invalid sloc> implicit referenced RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS 'const unsigned int' static cinit
// ASTIMPL-NEXT: IntegerLiteral 0x{{.+}} <<invalid sloc>> 'const unsigned int' 1024
// ASTIMPL-NEXT: AvailabilityAttr 0x{{.+}} <<invalid sloc>> Implicit 6.9 0 0 ""

RaytracingPipelineConfig1 rpc = { 32, RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS };
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %dxc -T lib_6_8 -verify %s

// expected-warning@+1{{potential misuse of built-in constant 'RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS' in shader model lib_6_8; introduced in shader model 6.9}}
RaytracingPipelineConfig1 rpc = { 32, RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS };


2 changes: 2 additions & 0 deletions tools/clang/tools/dxcompiler/dxcdisassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ static const char *FlagToString(DXIL::RaytracingPipelineFlags Flag) {
return "RAYTRACING_PIPELINE_FLAG_SKIP_TRIANGLES";
case DXIL::RaytracingPipelineFlags::SkipProceduralPrimitives:
return "RAYTRACING_PIPELINE_FLAG_SKIP_PROCEDURAL_PRIMITIVES";
case DXIL::RaytracingPipelineFlags::AllowOpacityMicromaps:
return "RAYTRACING_PIPELINE_FLAG_ALLOW_OPACITY_MICROMAPS";
}
return "<invalid RaytracingPipelineFlags>";
}
Expand Down