LibWeb: Ensure WebGL buffers don't mix between index and other data

The spec mandates that a buffer during its lifetime can only get bound
to either an index buffer or any other type.
This commit is contained in:
Undefine 2025-11-06 22:39:51 +01:00 committed by Jelle Raaijmakers
parent 85478c9215
commit 7d6212ae71
Notes: github-actions[bot] 2025-11-27 18:21:19 +00:00
4 changed files with 38 additions and 0 deletions

View file

@ -2,6 +2,7 @@
* Copyright (c) 2024-2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
* Copyright (c) 2024-2025, Luke Wilde <luke@ladybird.org>
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
* Copyright (c) 2025, Undefine <undefine@undefine.pl>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -964,6 +965,11 @@ void WebGL2RenderingContextImpl::bind_buffer_base(WebIDL::UnsignedLong target, W
return;
}
buffer_handle = handle_or_error.release_value();
if (!buffer->is_compatible_with(target)) {
set_error(GL_INVALID_OPERATION);
return;
}
}
glBindBufferBase(target, index, buffer_handle);
}
@ -980,6 +986,11 @@ void WebGL2RenderingContextImpl::bind_buffer_range(WebIDL::UnsignedLong target,
return;
}
buffer_handle = handle_or_error.release_value();
if (!buffer->is_compatible_with(target)) {
set_error(GL_INVALID_OPERATION);
return;
}
}
glBindBufferRange(target, index, buffer_handle, offset, size);
}