LibWeb/WebGL2: Implement texImage3D with ArrayBufferView and offset

This commit is contained in:
Luke Wilde 2024-12-13 19:00:43 +00:00 committed by Alexander Kalenik
parent 50b4d65540
commit 6e42f401f9
Notes: github-actions[bot] 2024-12-14 08:09:15 +00:00
2 changed files with 21 additions and 2 deletions

View file

@ -316,7 +316,7 @@ interface mixin WebGL2RenderingContextBase {
[FIXME] undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, TexImageSource source);
undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView? srcData);
[FIXME] undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView srcData, unsigned long long srcOffset);
undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView srcData, unsigned long long srcOffset);
[FIXME] undefined texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLintptr pboOffset);

View file

@ -595,7 +595,7 @@ public:
continue;
}
if (function.name == "texImage3D"sv) {
if (function.name == "texImage3D"sv && function.overload_index == 0) {
// FIXME: If a WebGLBuffer is bound to the PIXEL_UNPACK_BUFFER target, generates an INVALID_OPERATION error.
// FIXME: If srcData is null, a buffer of sufficient size initialized to 0 is passed.
// FIXME: If type is specified as FLOAT_32_UNSIGNED_INT_24_8_REV, srcData must be null; otherwise, generates an INVALID_OPERATION error.
@ -614,6 +614,25 @@ public:
continue;
}
if (function.name == "texImage3D"sv && function.overload_index == 1) {
// FIXME: If a WebGLBuffer is bound to the PIXEL_UNPACK_BUFFER target, generates an INVALID_OPERATION error.
// FIXME: If srcData is null, a buffer of sufficient size initialized to 0 is passed.
// FIXME: If type is specified as FLOAT_32_UNSIGNED_INT_24_8_REV, srcData must be null; otherwise, generates an INVALID_OPERATION error.
// FIXME: If srcData is non-null, the type of srcData must match the type according to the above table; otherwise, generate an INVALID_OPERATION error.
// FIXME: If an attempt is made to call this function with no WebGLTexture bound (see above), generates an INVALID_OPERATION error.
// FIXME: If there's not enough data in srcData starting at srcOffset, generate INVALID_OPERATION.
function_impl_generator.append(R"~~~(
void const* src_data_ptr = nullptr;
if (src_data) {
auto const& viewed_array_buffer = src_data->viewed_array_buffer();
auto const& byte_buffer = viewed_array_buffer->buffer();
src_data_ptr = byte_buffer.data() + src_offset;
}
glTexImage3D(target, level, internalformat, width, height, depth, border, format, type, src_data_ptr);
)~~~");
continue;
}
if (function.name == "texImage2D"sv && function.overload_index == 1) {
// FIXME: If this function is called with an ImageData whose data attribute has been neutered,
// an INVALID_VALUE error is generated.