LibWeb/WebGL2: Implement fenceSync

This commit is contained in:
Luke Wilde 2024-12-13 14:42:03 +00:00 committed by Alexander Kalenik
commit 135ceb387e
Notes: github-actions[bot] 2024-12-14 08:10:14 +00:00
7 changed files with 26 additions and 6 deletions

View file

@ -845,6 +845,7 @@ class WebGLRenderingContext;
class WebGLSampler;
class WebGLShader;
class WebGLShaderPrecisionFormat;
class WebGLSync;
class WebGLTexture;
class WebGLUniformLocation;
class WebGLVertexArrayObject;

View file

@ -15,4 +15,8 @@ using GLenum = unsigned int;
using GLuint = unsigned int;
using GLint = int;
// FIXME: This should really be "struct __GLsync*", but the linker doesn't recognise it.
// Since this conflicts with the original definition of GLsync, the suffix "Internal" has been added.
using GLsyncInternal = void*;
}

View file

@ -396,7 +396,7 @@ interface mixin WebGL2RenderingContextBase {
[FIXME] any getSamplerParameter(WebGLSampler sampler, GLenum pname);
// Sync objects
[FIXME] WebGLSync? fenceSync(GLenum condition, GLbitfield flags);
WebGLSync? fenceSync(GLenum condition, GLbitfield flags);
[FIXME] GLboolean isSync(WebGLSync? sync); // [WebGLHandlesContextLoss]
[FIXME] undefined deleteSync(WebGLSync? sync);
[FIXME] GLenum clientWaitSync(WebGLSync sync, GLbitfield flags, GLuint64 timeout);

View file

@ -13,13 +13,14 @@ namespace Web::WebGL {
GC_DEFINE_ALLOCATOR(WebGLSync);
GC::Ref<WebGLSync> WebGLSync::create(JS::Realm& realm, GLuint handle)
GC::Ref<WebGLSync> WebGLSync::create(JS::Realm& realm, GLsyncInternal handle)
{
return realm.create<WebGLSync>(realm, handle);
}
WebGLSync::WebGLSync(JS::Realm& realm, GLuint handle)
: WebGLObject(realm, handle)
WebGLSync::WebGLSync(JS::Realm& realm, GLsyncInternal handle)
: WebGLObject(realm, 0)
, m_sync_handle(handle)
{
}

View file

@ -16,14 +16,18 @@ class WebGLSync : public WebGLObject {
GC_DECLARE_ALLOCATOR(WebGLSync);
public:
static GC::Ref<WebGLSync> create(JS::Realm& realm, GLuint handle);
static GC::Ref<WebGLSync> create(JS::Realm& realm, GLsyncInternal handle);
virtual ~WebGLSync() override;
GLsyncInternal sync_handle() const { return m_sync_handle; }
protected:
explicit WebGLSync(JS::Realm&, GLuint handle);
explicit WebGLSync(JS::Realm&, GLsyncInternal handle);
virtual void initialize(JS::Realm&) override;
GLsyncInternal m_sync_handle { nullptr };
};
}

View file

@ -116,6 +116,7 @@ static bool is_platform_object(Type const& type)
"WebGLSampler"sv,
"WebGLShader"sv,
"WebGLShaderPrecisionFormat"sv,
"WebGLSync"sv,
"WebGLTexture"sv,
"WebGLUniformLocation"sv,
"WebGLVertexArrayObject"sv,

View file

@ -357,6 +357,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
#include <LibWeb/WebGL/@class_name@.h>
#include <LibWeb/WebGL/WebGLSampler.h>
#include <LibWeb/WebGL/WebGLShader.h>
#include <LibWeb/WebGL/WebGLSync.h>
#include <LibWeb/WebGL/WebGLShaderPrecisionFormat.h>
#include <LibWeb/WebGL/WebGLTexture.h>
#include <LibWeb/WebGL/WebGLUniformLocation.h>
@ -519,6 +520,14 @@ public:
continue;
}
if (function.name == "fenceSync"sv) {
function_impl_generator.append(R"~~~(
GLsync handle = glFenceSync(condition, flags);
return WebGLSync::create(m_realm, handle);
)~~~");
continue;
}
if (function.name == "shaderSource"sv) {
function_impl_generator.append(R"~~~(
Vector<GLchar*> strings;