GX2: Fix command buffer padding writing out of bounds

This commit is contained in:
Exzap 2025-06-22 22:17:29 +02:00
parent 5a4731f919
commit 4f4c9594ac

View file

@ -144,6 +144,11 @@ namespace GX2
void GX2Command_StartNewCommandBuffer(uint32 numU32s) void GX2Command_StartNewCommandBuffer(uint32 numU32s)
{ {
// On submission command buffers are padded to 32 byte alignment
// but nowhere is it guaranteed that internal command buffers have their size aligned to 32 byte (even on console, but testing is required)
// Thus the padding can write out of bounds but this seems to trigger only very rarely in partice. As a workaround we always pad the command buffer size to 32 bytes here
numU32s = (numU32s + 7) & ~0x7;
uint32 coreIndex = coreinit::OSGetCoreId(); uint32 coreIndex = coreinit::OSGetCoreId();
auto& coreCBState = s_perCoreCBState[coreIndex]; auto& coreCBState = s_perCoreCBState[coreIndex];
numU32s = std::max<uint32>(numU32s, 0x100); numU32s = std::max<uint32>(numU32s, 0x100);