[Fix] (Magma): a uniform block declared at an empty binding point reads a zeroed block on the monolith arm instead of dereferencing a null buffer, as the wire arm already does

This commit is contained in:
2026-09-29 19:32:19 -04:00
parent 4aec5621a8
commit 7784d6bbf7
@@ -2784,9 +2784,20 @@ namespace MobileGL::MG_Backend::DirectVulkan {
auto& bindingPoint = MGB_CTX->GetBufferBindingPoint(BufferTarget::Uniform, frontendBinding);
const auto& bufferObject = bindingPoint.GetBoundObject();
MOBILEGL_ASSERT(bufferObject != nullptr,
"ResolveUniformBufferPayload: no UBO bound at frontend binding %u for block '%s'",
frontendBinding, program.GetUniformBlockName(static_cast<Uint32>(blockIndex)).c_str());
static thread_local Vector<Uint8> paddedUbo;
if (bufferObject == nullptr) {
// A block the program declares at a point with nothing bound - e.g. its buffer was
// deleted while bound, which unbinds it (DeletedBoundBufferScenario). GL leaves what
// the shader READS undefined and raises no error; this used to dereference the null
// object. The wire arm already answers it with a zeroed block
// (ResolveWireUniformBufferPayload), so this one does too.
const VkDeviceSize blockSize =
static_cast<VkDeviceSize>(program.GetUBOSizeAt(static_cast<Uint32>(blockIndex)));
paddedUbo.assign(static_cast<SizeT>(blockSize > 0 ? blockSize : 16), 0);
out.payload = paddedUbo.data();
out.payloadSize = static_cast<VkDeviceSize>(paddedUbo.size());
return true;
}
bufferObject->SyncPersistentMappedRange();
MOBILEGL_ASSERT(bufferObject->MappedData() != nullptr && bufferObject->GetSize() != 0,
@@ -2819,7 +2830,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
outSize = blockSize;
outData = bufferObject->MappedData() + static_cast<SizeT>(rangeStart);
if (available < blockSize) {
static thread_local Vector<Uint8> paddedUbo;
paddedUbo.assign(static_cast<SizeT>(blockSize), 0);
Memcpy(paddedUbo.data(), outData, static_cast<SizeT>(available));
outData = paddedUbo.data();