From bc2db26e070c2d942db92b47e226659fd8cd7651 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 2 Jul 2026 14:25:40 +0800 Subject: [PATCH] [Fix] (MG_Backend/DirectVulkan): validate shader storage block bindings [skip ci] --- MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp b/MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp index 1099f71a..7814a35b 100644 --- a/MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp @@ -8,7 +8,9 @@ #include "DirectVulkan.h" #include "DirectVulkanResourceState.h" +#include "MG_Backend/BackendObjects.h" #include "MG_State/GLState/Core.h" +#include "MG_State/GLState/ErrorState/ErrorInfo.h" #include "MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h" #include "MG_Util/Miscellany/IndexGenerator.h" #include @@ -1115,7 +1117,19 @@ namespace MobileGL::MG_Backend::DirectVulkan { auto* programObject = TryGetDirectVulkanProgram(program); if (!programObject) return; auto& cache = GetProgramResourceCache(*programObject); + const Int maxBindings = pActiveBackendObject + ? pActiveBackendObject->GetDynamicParameters().MaxShaderStorageBufferBindings + : 0; + if (storageBlockBinding >= static_cast(maxBindings)) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeUnique("DirectVulkan", __func__, "Shader storage binding is out of range.")); + return; + } if (storageBlockIndex >= cache.storageBlocks.size()) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeUnique("DirectVulkan", __func__, "Shader storage block index is not active.")); return; } cache.storageBlocks[storageBlockIndex].binding = storageBlockBinding;