Skip to content

Commit 26fa31b

Browse files
committed
Set the resource kind as u32 for boolean resources
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
1 parent 5dd0c17 commit 26fa31b

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

lib/DXIL/DxilResource.cpp

+1-12
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,7 @@ DxilResource::DxilResource()
3030

3131
CompType DxilResource::GetCompType() const { return m_CompType; }
3232

33-
void DxilResource::SetCompType(const CompType CT) {
34-
// Translate packed types to u32
35-
switch (CT.GetKind()) {
36-
case CompType::Kind::PackedS8x32:
37-
case CompType::Kind::PackedU8x32:
38-
m_CompType = CompType::getU32();
39-
break;
40-
default:
41-
m_CompType = CT;
42-
break;
43-
}
44-
}
33+
void DxilResource::SetCompType(const CompType CT) { m_CompType = CT; }
4534

4635
Type *DxilResource::GetRetType() const {
4736
Type *Ty = GetHLSLType()->getPointerElementType();

tools/clang/lib/CodeGen/CGHLSLMS.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -3510,11 +3510,20 @@ bool CGMSHLSLRuntime::SetUAVSRV(SourceLocation loc,
35103510
if (const BuiltinType *BTy = EltTy->getAs<BuiltinType>()) {
35113511
CompType::Kind kind = BuiltinTyToCompTy(BTy, bHasNormAttribute && bSNorm,
35123512
bHasNormAttribute && !bSNorm);
3513-
// 64bits types are implemented with u32.
3514-
if (kind == CompType::Kind::U64 || kind == CompType::Kind::I64 ||
3515-
kind == CompType::Kind::SNormF64 ||
3516-
kind == CompType::Kind::UNormF64 || kind == CompType::Kind::F64) {
3513+
// Boolean, 64-bit, and packed types are implemented with u32.
3514+
switch (kind) {
3515+
case CompType::Kind::I1:
3516+
case CompType::Kind::U64:
3517+
case CompType::Kind::I64:
3518+
case CompType::Kind::F64:
3519+
case CompType::Kind::SNormF64:
3520+
case CompType::Kind::UNormF64:
3521+
case CompType::Kind::PackedS8x32:
3522+
case CompType::Kind::PackedU8x32:
35173523
kind = CompType::Kind::U32;
3524+
break;
3525+
default:
3526+
break;
35183527
}
35193528
hlslRes->SetCompType(kind);
35203529
} else {

0 commit comments

Comments
 (0)