Skip to content

Commit

Permalink
Fix HW GlobalData alignment
Browse files Browse the repository at this point in the history
Alignmet of HW GlobalData data should be 64 bytes.
Add 8 bytes to the padding.
  • Loading branch information
JaroszPiotr authored and igcbot committed Jan 31, 2025
1 parent b859709 commit 9a5fda5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions IGC/AdaptorCommon/RayTracing/API/RayDispatchGlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ struct RayDispatchGlobalData
} rt_data_info;
// In addition to the dword of padding to align `common`, we also
// add 8 dwords so Xe and Xe3 both have the same RTGlobals size.
uint32_t paddingBits[1+6]; // padding
uint32_t paddingBits[1+8]; // padding

// HW doesn't read anything below this point.
RayDispatchGlobalDataCommon common;
Expand Down Expand Up @@ -286,7 +286,7 @@ struct RayDispatchGlobalData
uint32_t pad_mbz : 31;
uint64_t hitGroupBasePtr; // base pointer of hit group shader record array (16-bytes alignment)
uint64_t missShaderBasePtr; // base pointer of miss shader record array (8-bytes alignment)
uint32_t _align_mbz[2]; // pad hardware section to 64 bytes
uint32_t _align_mbz[4]; // pad hardware section to 64 bytes

// HW doesn't read anything below this point.
RayDispatchGlobalDataCommon common;
Expand All @@ -303,7 +303,10 @@ constexpr uint32_t RTGlobalsAlign = 256;
constexpr uint32_t RTStackAlign = 128;
static_assert(RTStackAlign % RayDispatchGlobalData::StackChunkSize == 0, "no?");

static_assert(sizeof(RayDispatchGlobalData) == 184, "unexpected size?");
static_assert((sizeof(RayDispatchGlobalData::RT::Xe) - sizeof(RayDispatchGlobalData::RayDispatchGlobalDataCommon)) % 64 == 0, "Unexpected GlobalData alignment");
static_assert((sizeof(RayDispatchGlobalData::RT::Xe3) - sizeof(RayDispatchGlobalData::RayDispatchGlobalDataCommon)) % 64 == 0, "Unexpected GlobalData alignment");

static_assert(sizeof(RayDispatchGlobalData) == 192, "unexpected size?");
static_assert(sizeof(RayDispatchGlobalData::RT::Xe) == sizeof(RayDispatchGlobalData), "unexpected size?");
static_assert(sizeof(RayDispatchGlobalData::RT::Xe3) == sizeof(RayDispatchGlobalData), "unexpected size?");
static_assert(offsetof(RayDispatchGlobalData::RT::Xe, common) == offsetof(RayDispatchGlobalData::RT::Xe3, common), "unexpected size?");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ static Type* _struct_IGC__RayDispatchGlobalData__RT__Xe(Module &M)
[&] {
auto *EltTy =
IntegerType::get(M.getContext(), 32);
return ArrayType::get(EltTy, 7);
return ArrayType::get(EltTy, 9);
}(),
_struct_IGC__RayDispatchGlobalData__RayDispatchGlobalDataCommon(M),
};
Expand Down

0 comments on commit 9a5fda5

Please sign in to comment.