Skip to content

Commit b80543b

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 f401e6f commit b80543b

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
@@ -3539,11 +3539,20 @@ bool CGMSHLSLRuntime::SetUAVSRV(SourceLocation loc,
35393539
if (const BuiltinType *BTy = EltTy->getAs<BuiltinType>()) {
35403540
CompType::Kind kind = BuiltinTyToCompTy(BTy, bHasNormAttribute && bSNorm,
35413541
bHasNormAttribute && !bSNorm);
3542-
// 64bits types are implemented with u32.
3543-
if (kind == CompType::Kind::U64 || kind == CompType::Kind::I64 ||
3544-
kind == CompType::Kind::SNormF64 ||
3545-
kind == CompType::Kind::UNormF64 || kind == CompType::Kind::F64) {
3542+
// Boolean, 64-bit, and packed types are implemented with u32.
3543+
switch (kind) {
3544+
case CompType::Kind::I1:
3545+
case CompType::Kind::U64:
3546+
case CompType::Kind::I64:
3547+
case CompType::Kind::F64:
3548+
case CompType::Kind::SNormF64:
3549+
case CompType::Kind::UNormF64:
3550+
case CompType::Kind::PackedS8x32:
3551+
case CompType::Kind::PackedU8x32:
35463552
kind = CompType::Kind::U32;
3553+
break;
3554+
default:
3555+
break;
35473556
}
35483557
hlslRes->SetCompType(kind);
35493558
} else {

0 commit comments

Comments
 (0)