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.
This commit is contained in:
Vladislav Belov
2025-04-12 16:27:52 +02:00
parent 1b797ce0a0
commit bce6e2c238
2 changed files with 5 additions and 1 deletions
@@ -246,6 +246,9 @@ CDeviceCommandContext::CDeviceCommandContext(CDevice* device)
for (size_t index = 0; index < m_BoundBuffers.size(); ++index)
{
const CBuffer::Type type = static_cast<CBuffer::Type>(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<size_t>(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 &&
@@ -221,7 +221,7 @@ private:
};
using BoundBuffer = std::pair<GLenum, GLuint>;
std::array<BoundBuffer, 2> m_BoundBuffers;
std::array<BoundBuffer, 4> m_BoundBuffers;
class ScopedBufferBind
{
public: