[clang] [HLSL] Codegen for `cbuffer` declarations without embedded arrays or structs (PR #119755)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 13 13:49:09 PST 2024
================
@@ -164,18 +164,18 @@ Decl *SemaHLSL::ActOnStartBuffer(Scope *BufferScope, bool CBuffer,
return Result;
}
-// Calculate the size of a legacy cbuffer type based on
+// Calculate the size of a legacy cbuffer type in bytes based on
// https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-packing-rules
static unsigned calculateLegacyCbufferSize(const ASTContext &Context,
QualType T) {
unsigned Size = 0;
- constexpr unsigned CBufferAlign = 128;
+ constexpr unsigned CBufferAlign = 16;
if (const RecordType *RT = T->getAs<RecordType>()) {
const RecordDecl *RD = RT->getDecl();
for (const FieldDecl *Field : RD->fields()) {
QualType Ty = Field->getType();
unsigned FieldSize = calculateLegacyCbufferSize(Context, Ty);
- unsigned FieldAlign = 32;
+ unsigned FieldAlign = 4;
if (Ty->isAggregateType())
----------------
hekota wrote:
This is not the correct alignment, it does not work for 16-bit types and probably not for 64-bit types either.
I have filed a bug here: llvm/llvm-project#119641
https://github.com/llvm/llvm-project/pull/119755
More information about the cfe-commits
mailing list