Prechádzať zdrojové kódy

LibWeb/WebGL2: Implement texImage3D with ArrayBufferView and offset

Luke Wilde 7 mesiacov pred
rodič
commit
6e42f401f9

+ 1 - 1
Libraries/LibWeb/WebGL/WebGL2RenderingContextBase.idl

@@ -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);
     [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);
     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);
     [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);
 
 

+ 20 - 1
Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp

@@ -595,7 +595,7 @@ public:
             continue;
             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 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 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 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;
             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) {
         if (function.name == "texImage2D"sv && function.overload_index == 1) {
             // FIXME: If this function is called with an ImageData whose data attribute has been neutered,
             // FIXME: If this function is called with an ImageData whose data attribute has been neutered,
             //        an INVALID_VALUE error is generated.
             //        an INVALID_VALUE error is generated.