Skip to content

Commit

Permalink
Set the resource kind as u32 for boolean resources
Browse files Browse the repository at this point in the history
It was producing a validation error previously because they are represented as u32 and i1 is not valid for output resources. This preserves the cmp conversions for values read from the resource, but satisfies the validation requirement. Performs some incidental consolidation of types that are represented as u32.

Related to microsoft#7079
  • Loading branch information
pow2clk committed Feb 3, 2025
1 parent 5dd0c17 commit dff706c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
11 changes: 1 addition & 10 deletions lib/DXIL/DxilResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,7 @@ DxilResource::DxilResource()
CompType DxilResource::GetCompType() const { return m_CompType; }

void DxilResource::SetCompType(const CompType CT) {
// Translate packed types to u32
switch (CT.GetKind()) {
case CompType::Kind::PackedS8x32:
case CompType::Kind::PackedU8x32:
m_CompType = CompType::getU32();
break;
default:
m_CompType = CT;
break;
}
m_CompType = CT;
}

Type *DxilResource::GetRetType() const {
Expand Down
17 changes: 13 additions & 4 deletions tools/clang/lib/CodeGen/CGHLSLMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3510,11 +3510,20 @@ bool CGMSHLSLRuntime::SetUAVSRV(SourceLocation loc,
if (const BuiltinType *BTy = EltTy->getAs<BuiltinType>()) {
CompType::Kind kind = BuiltinTyToCompTy(BTy, bHasNormAttribute && bSNorm,
bHasNormAttribute && !bSNorm);
// 64bits types are implemented with u32.
if (kind == CompType::Kind::U64 || kind == CompType::Kind::I64 ||
kind == CompType::Kind::SNormF64 ||
kind == CompType::Kind::UNormF64 || kind == CompType::Kind::F64) {
// Boolean, 64-bit, and packed types are implemented with u32.
switch(kind) {
case CompType::Kind::I1:
case CompType::Kind::U64:
case CompType::Kind::I64:
case CompType::Kind::F64:
case CompType::Kind::SNormF64:
case CompType::Kind::UNormF64:
case CompType::Kind::PackedS8x32:
case CompType::Kind::PackedU8x32:
kind = CompType::Kind::U32;
break;
default:
break;
}
hlslRes->SetCompType(kind);
} else {
Expand Down

0 comments on commit dff706c

Please sign in to comment.