mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 01:04:06 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user