From bce6e2c238dedbb78ba7425099447006f2650f3c Mon Sep 17 00:00:00 2001 From: Vladislav Belov Date: Sat, 12 Apr 2025 16:27:52 +0200 Subject: [PATCH] Fixes out of bounds during GL buffer binding. There was an out of bounds access during binding a uniform buffer on GL. Fixes #7567, #7598. --- source/renderer/backend/gl/DeviceCommandContext.cpp | 4 ++++ source/renderer/backend/gl/DeviceCommandContext.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/renderer/backend/gl/DeviceCommandContext.cpp b/source/renderer/backend/gl/DeviceCommandContext.cpp index dacdd4377b..87bc323305 100644 --- a/source/renderer/backend/gl/DeviceCommandContext.cpp +++ b/source/renderer/backend/gl/DeviceCommandContext.cpp @@ -246,6 +246,9 @@ CDeviceCommandContext::CDeviceCommandContext(CDevice* device) for (size_t index = 0; index < m_BoundBuffers.size(); ++index) { const CBuffer::Type type = static_cast(index); + // Currently we don't support upload buffers for GL. + if (type == CBuffer::Type::UPLOAD) + continue; const GLenum target = BufferTypeToGLTarget(type); const GLuint handle = 0; m_BoundBuffers[index].first = target; @@ -1456,6 +1459,7 @@ CDeviceCommandContext::ScopedBufferBind::ScopedBufferBind( { ENSURE(buffer); m_CacheIndex = static_cast(buffer->GetType()); + ENSURE(m_CacheIndex < m_DeviceCommandContext->m_BoundBuffers.size()); const GLenum target = BufferTypeToGLTarget(buffer->GetType()); const GLuint handle = buffer->GetHandle(); if (m_DeviceCommandContext->m_BoundBuffers[m_CacheIndex].first == target && diff --git a/source/renderer/backend/gl/DeviceCommandContext.h b/source/renderer/backend/gl/DeviceCommandContext.h index 5f1a251007..3d23d89c06 100644 --- a/source/renderer/backend/gl/DeviceCommandContext.h +++ b/source/renderer/backend/gl/DeviceCommandContext.h @@ -221,7 +221,7 @@ private: }; using BoundBuffer = std::pair; - std::array m_BoundBuffers; + std::array m_BoundBuffers; class ScopedBufferBind { public: