LibWeb/WebGL: Implement texImage3D()

This commit is contained in:
Aliaksandr Kalenik 2024-12-10 05:30:03 +01:00 committed by Alexander Kalenik
parent ba19328b98
commit af4f0c5a81
Notes: github-actions[bot] 2024-12-13 08:20:47 +00:00
2 changed files with 20 additions and 1 deletions

View file

@ -314,7 +314,7 @@ interface mixin WebGL2RenderingContextBase {
// May throw DOMException
[FIXME] undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, TexImageSource source);
[FIXME] undefined texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView? srcData);
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);
[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

@ -540,6 +540,25 @@ public:
continue;
}
if (function.name == "texImage3D"sv) {
// 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();
}
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.