mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibWeb/WebGL: Implement uniform{1,2,3,4}{i,f}v calls for WebGL2
This commit is contained in:
parent
194edbfd89
commit
cfff38a176
Notes:
github-actions[bot]
2024-12-13 08:20:14 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: cfff38a176
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2878
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/gmta
2 changed files with 38 additions and 17 deletions
|
@ -43,15 +43,15 @@ interface mixin WebGL2RenderingContextOverloads {
|
||||||
[FIXME] undefined compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLintptr offset);
|
[FIXME] undefined compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLintptr offset);
|
||||||
[FIXME] undefined compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,GLsizei width, GLsizei height, GLenum format, [AllowShared] ArrayBufferView srcData, optional unsigned long long srcOffset = 0, optional GLuint srcLengthOverride = 0);
|
[FIXME] undefined compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,GLsizei width, GLsizei height, GLenum format, [AllowShared] ArrayBufferView srcData, optional unsigned long long srcOffset = 0, optional GLuint srcLengthOverride = 0);
|
||||||
|
|
||||||
[FIXME] undefined uniform1fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
undefined uniform1fv(WebGLUniformLocation? location, Float32List v, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
[FIXME] undefined uniform2fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
undefined uniform2fv(WebGLUniformLocation? location, Float32List v, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
[FIXME] undefined uniform3fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
undefined uniform3fv(WebGLUniformLocation? location, Float32List v, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
[FIXME] undefined uniform4fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
undefined uniform4fv(WebGLUniformLocation? location, Float32List v, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
|
|
||||||
[FIXME] undefined uniform1iv(WebGLUniformLocation? location, Int32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
undefined uniform1iv(WebGLUniformLocation? location, Int32List v, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
[FIXME] undefined uniform2iv(WebGLUniformLocation? location, Int32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
undefined uniform2iv(WebGLUniformLocation? location, Int32List v, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
[FIXME] undefined uniform3iv(WebGLUniformLocation? location, Int32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
undefined uniform3iv(WebGLUniformLocation? location, Int32List v, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
[FIXME] undefined uniform4iv(WebGLUniformLocation? location, Int32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
undefined uniform4iv(WebGLUniformLocation? location, Int32List v, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
|
|
||||||
[FIXME] undefined uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
[FIXME] undefined uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
[FIXME] undefined uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
[FIXME] undefined uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
|
||||||
|
|
|
@ -326,7 +326,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
SourceGenerator implementation_file_generator { implementation_file_string_builder };
|
SourceGenerator implementation_file_generator { implementation_file_string_builder };
|
||||||
implementation_file_generator.set("class_name", class_name);
|
implementation_file_generator.set("class_name", class_name);
|
||||||
|
|
||||||
auto webgl_version = class_name == "WebGLRenderingContext" ? 1 : 2;
|
auto webgl_version = class_name == "WebGLRenderingContextImpl" ? 1 : 2;
|
||||||
if (webgl_version == 1) {
|
if (webgl_version == 1) {
|
||||||
implementation_file_generator.append(R"~~~(
|
implementation_file_generator.append(R"~~~(
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
|
@ -713,17 +713,38 @@ public:
|
||||||
}
|
}
|
||||||
function_impl_generator.set("number_of_vector_elements", number_of_vector_elements);
|
function_impl_generator.set("number_of_vector_elements", number_of_vector_elements);
|
||||||
function_impl_generator.append(R"~~~(
|
function_impl_generator.append(R"~~~(
|
||||||
|
@cpp_element_type@ const* data = nullptr;
|
||||||
|
size_t count = 0;
|
||||||
if (v.has<Vector<@cpp_element_type@>>()) {
|
if (v.has<Vector<@cpp_element_type@>>()) {
|
||||||
auto& data = v.get<Vector<@cpp_element_type@>>();
|
auto& vector = v.get<Vector<@cpp_element_type@>>();
|
||||||
glUniform@number_of_vector_elements@@gl_postfix@v(location->handle(), data.size() / @number_of_vector_elements@, data.data());
|
data = vector.data();
|
||||||
return;
|
count = vector.size();
|
||||||
|
} else if (v.has<GC::Root<WebIDL::BufferSource>>()) {
|
||||||
|
auto& typed_array_base = static_cast<JS::TypedArrayBase&>(*v.get<GC::Root<WebIDL::BufferSource>>()->raw_object());
|
||||||
|
auto& typed_array = verify_cast<JS::@typed_array_type@>(typed_array_base);
|
||||||
|
data = typed_array.data().data();
|
||||||
|
count = typed_array.array_length().length();
|
||||||
|
} else {
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
)~~~");
|
||||||
|
|
||||||
|
if (webgl_version == 2) {
|
||||||
|
function_impl_generator.append(R"~~~(
|
||||||
|
data += src_offset;
|
||||||
|
if (src_length == 0) {
|
||||||
|
count -= src_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& typed_array_base = static_cast<JS::TypedArrayBase&>(*v.get<GC::Root<WebIDL::BufferSource>>()->raw_object());
|
if (src_offset + src_length <= count) {
|
||||||
auto& typed_array = verify_cast<JS::@typed_array_type@>(typed_array_base);
|
set_error(GL_INVALID_VALUE);
|
||||||
@cpp_element_type@ const* data = typed_array.data().data();
|
return;
|
||||||
auto count = typed_array.array_length().length() / @number_of_vector_elements@;
|
}
|
||||||
glUniform@number_of_vector_elements@@gl_postfix@v(location->handle(), count, data);
|
)~~~");
|
||||||
|
}
|
||||||
|
|
||||||
|
function_impl_generator.append(R"~~~(
|
||||||
|
glUniform@number_of_vector_elements@@gl_postfix@v(location->handle(), count / @number_of_vector_elements@, data);
|
||||||
)~~~");
|
)~~~");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue