LibWeb/WebGL: Return correct types from get{Shader,Program}Parameter

Returning numbers instead of booleans for the statuses made Ruffle
(through the wgpu crate) think a shader/program failed to compile/link,
as it does a strict type comparison.
This commit is contained in:
Luke Wilde 2024-12-30 12:20:52 +00:00 committed by Alexander Kalenik
parent db2d8f8f17
commit 2b20b8aaff
Notes: github-actions[bot] 2025-01-08 14:57:22 +00:00

View file

@ -897,7 +897,17 @@ public:
function_impl_generator.append(R"~~~(
GLint result = 0;
glGetShaderiv(shader_handle, pname, &result);
switch (pname) {
case GL_SHADER_TYPE:
return JS::Value(result);
case GL_DELETE_STATUS:
case GL_COMPILE_STATUS:
return JS::Value(result == GL_TRUE);
default:
dbgln("Unknown WebGL shader parameter name: 0x{:04x}", pname);
set_error(GL_INVALID_ENUM);
return JS::js_null();
}
)~~~");
continue;
}
@ -907,7 +917,31 @@ public:
function_impl_generator.append(R"~~~(
GLint result = 0;
glGetProgramiv(program_handle, pname, &result);
switch (pname) {
case GL_ATTACHED_SHADERS:
case GL_ACTIVE_ATTRIBUTES:
case GL_ACTIVE_UNIFORMS:
)~~~");
if (webgl_version == 2) {
function_impl_generator.append(R"~~~(
case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
case GL_TRANSFORM_FEEDBACK_VARYINGS:
case GL_ACTIVE_UNIFORM_BLOCKS:
)~~~");
}
function_impl_generator.append(R"~~~(
return JS::Value(result);
case GL_DELETE_STATUS:
case GL_LINK_STATUS:
case GL_VALIDATE_STATUS:
return JS::Value(result == GL_TRUE);
default:
dbgln("Unknown WebGL program parameter name: 0x{:04x}", pname);
set_error(GL_INVALID_ENUM);
return JS::js_null();
}
)~~~");
continue;
}