mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibWeb/WebGL2: Implement getActiveUniformBlockParameter
This commit is contained in:
parent
191ceb0f61
commit
c067271897
Notes:
github-actions[bot]
2025-01-08 14:59:54 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/c0672718976 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2943 Reviewed-by: https://github.com/kalenikaliaksandr
2 changed files with 40 additions and 1 deletions
|
@ -422,7 +422,7 @@ interface mixin WebGL2RenderingContextBase {
|
|||
[FIXME] sequence<GLuint>? getUniformIndices(WebGLProgram program, sequence<DOMString> uniformNames);
|
||||
[FIXME] any getActiveUniforms(WebGLProgram program, sequence<GLuint> uniformIndices, GLenum pname);
|
||||
[FIXME] GLuint getUniformBlockIndex(WebGLProgram program, DOMString uniformBlockName);
|
||||
[FIXME] any getActiveUniformBlockParameter(WebGLProgram program, GLuint uniformBlockIndex, GLenum pname);
|
||||
any getActiveUniformBlockParameter(WebGLProgram program, GLuint uniformBlockIndex, GLenum pname);
|
||||
DOMString? getActiveUniformBlockName(WebGLProgram program, GLuint uniformBlockIndex);
|
||||
undefined uniformBlockBinding(WebGLProgram program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
|
||||
|
||||
|
|
|
@ -341,6 +341,40 @@ static void generate_webgl_object_handle_unwrap(SourceGenerator& generator, Stri
|
|||
generator.append(unwrap_generator.as_string_view());
|
||||
}
|
||||
|
||||
static void generate_get_active_uniform_block_parameter(SourceGenerator& generator)
|
||||
{
|
||||
generate_webgl_object_handle_unwrap(generator, "program"sv, "JS::js_null()"sv);
|
||||
generator.append(R"~~~(
|
||||
switch (pname) {
|
||||
case GL_UNIFORM_BLOCK_BINDING:
|
||||
case GL_UNIFORM_BLOCK_DATA_SIZE:
|
||||
case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: {
|
||||
GLint result = 0;
|
||||
glGetActiveUniformBlockiv(program_handle, uniform_block_index, pname, &result);
|
||||
return JS::Value(result);
|
||||
}
|
||||
case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: {
|
||||
GLint num_active_uniforms = 0;
|
||||
glGetActiveUniformBlockiv(program_handle, uniform_block_index, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &num_active_uniforms);
|
||||
auto active_uniform_indices_buffer = MUST(ByteBuffer::create_zeroed(num_active_uniforms * sizeof(GLint)));
|
||||
glGetActiveUniformBlockiv(program_handle, uniform_block_index, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, reinterpret_cast<GLint*>(active_uniform_indices_buffer.data()));
|
||||
auto array_buffer = JS::ArrayBuffer::create(m_realm, move(active_uniform_indices_buffer));
|
||||
return JS::Uint32Array::create(m_realm, num_active_uniforms, array_buffer);
|
||||
}
|
||||
case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
|
||||
case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: {
|
||||
GLint result = 0;
|
||||
glGetActiveUniformBlockiv(program_handle, uniform_block_index, pname, &result);
|
||||
return JS::Value(result == GL_TRUE);
|
||||
}
|
||||
default:
|
||||
dbgln("Unknown WebGL active uniform block parameter name: {:x}", pname);
|
||||
set_error(GL_INVALID_ENUM);
|
||||
return JS::js_null();
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
StringView generated_header_path;
|
||||
|
@ -807,6 +841,11 @@ public:
|
|||
continue;
|
||||
}
|
||||
|
||||
if (function.name == "getActiveUniformBlockParameter"sv) {
|
||||
generate_get_active_uniform_block_parameter(function_impl_generator);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (function.name == "bufferData"sv && function.overload_index == 0) {
|
||||
function_impl_generator.append(R"~~~(
|
||||
glBufferData(target, size, 0, usage);
|
||||
|
|
Loading…
Add table
Reference in a new issue