From 9a5fda5af58314575d87709ed39d53b3e55e1740 Mon Sep 17 00:00:00 2001 From: "Jarosz, Piotr" Date: Mon, 27 Jan 2025 10:13:12 +0000 Subject: [PATCH] Fix HW GlobalData alignment Alignmet of HW GlobalData data should be 64 bytes. Add 8 bytes to the padding. --- IGC/AdaptorCommon/RayTracing/API/RayDispatchGlobalData.h | 9 ++++++--- .../RayTracing/AutoGenRTStackAccessPrivateOS.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/IGC/AdaptorCommon/RayTracing/API/RayDispatchGlobalData.h b/IGC/AdaptorCommon/RayTracing/API/RayDispatchGlobalData.h index 83f67fa2065c..54fb78752c8e 100644 --- a/IGC/AdaptorCommon/RayTracing/API/RayDispatchGlobalData.h +++ b/IGC/AdaptorCommon/RayTracing/API/RayDispatchGlobalData.h @@ -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; @@ -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; @@ -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?"); diff --git a/IGC/AdaptorCommon/RayTracing/AutoGenRTStackAccessPrivateOS.h b/IGC/AdaptorCommon/RayTracing/AutoGenRTStackAccessPrivateOS.h index b687d7338752..328e88143ab8 100644 --- a/IGC/AdaptorCommon/RayTracing/AutoGenRTStackAccessPrivateOS.h +++ b/IGC/AdaptorCommon/RayTracing/AutoGenRTStackAccessPrivateOS.h @@ -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), };