mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-07 01:53:24 +09:00
[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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user