LibWeb/WebGL2: Implement texSubImage2D with ArrayBufferView and offset

This commit is contained in:
Luke Wilde 2024-12-13 18:57:00 +00:00 committed by Alexander Kalenik
parent e6ebec853b
commit 766f4d2ec4
Notes: github-actions[bot] 2024-12-14 08:09:26 +00:00
2 changed files with 14 additions and 1 deletions

View file

@ -36,7 +36,7 @@ interface mixin WebGL2RenderingContextOverloads {
// May throw DOMException
[FIXME] undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, TexImageSource source);
[FIXME] undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView srcData, unsigned long long srcOffset);
undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView srcData, unsigned long long srcOffset);
[FIXME] undefined compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLintptr offset);
[FIXME] undefined compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, [AllowShared] ArrayBufferView srcData, optional unsigned long long srcOffset = 0, optional GLuint srcLengthOverride = 0);

View file

@ -670,6 +670,19 @@ public:
continue;
}
if (webgl_version == 2 && function.name == "texSubImage2D"sv && function.overload_index == 1) {
function_impl_generator.append(R"~~~(
void const* pixels_ptr = nullptr;
if (src_data) {
auto const& viewed_array_buffer = src_data->viewed_array_buffer();
auto const& byte_buffer = viewed_array_buffer->buffer();
pixels_ptr = byte_buffer.data() + src_offset;
}
glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels_ptr);
)~~~");
continue;
}
if (function.name == "texSubImage3D"sv && function.overload_index == 0) {
function_impl_generator.append(R"~~~(
void const* pixels_ptr = nullptr;