diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index cf07f60cf87..98f27d2e5a8 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -845,6 +845,7 @@ class WebGLRenderingContext; class WebGLSampler; class WebGLShader; class WebGLShaderPrecisionFormat; +class WebGLSync; class WebGLTexture; class WebGLUniformLocation; class WebGLVertexArrayObject; diff --git a/Libraries/LibWeb/WebGL/Types.h b/Libraries/LibWeb/WebGL/Types.h index bf8d35a25df..9d5c6d7a2a5 100644 --- a/Libraries/LibWeb/WebGL/Types.h +++ b/Libraries/LibWeb/WebGL/Types.h @@ -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*; + } diff --git a/Libraries/LibWeb/WebGL/WebGL2RenderingContextBase.idl b/Libraries/LibWeb/WebGL/WebGL2RenderingContextBase.idl index a9d58c5eb3e..037f5d92fce 100644 --- a/Libraries/LibWeb/WebGL/WebGL2RenderingContextBase.idl +++ b/Libraries/LibWeb/WebGL/WebGL2RenderingContextBase.idl @@ -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); diff --git a/Libraries/LibWeb/WebGL/WebGLSync.cpp b/Libraries/LibWeb/WebGL/WebGLSync.cpp index cc89e5cdff6..46a6f71512b 100644 --- a/Libraries/LibWeb/WebGL/WebGLSync.cpp +++ b/Libraries/LibWeb/WebGL/WebGLSync.cpp @@ -13,13 +13,14 @@ namespace Web::WebGL { GC_DEFINE_ALLOCATOR(WebGLSync); -GC::Ref WebGLSync::create(JS::Realm& realm, GLuint handle) +GC::Ref WebGLSync::create(JS::Realm& realm, GLsyncInternal handle) { return realm.create(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) { } diff --git a/Libraries/LibWeb/WebGL/WebGLSync.h b/Libraries/LibWeb/WebGL/WebGLSync.h index f64195c7125..c9616a665bf 100644 --- a/Libraries/LibWeb/WebGL/WebGLSync.h +++ b/Libraries/LibWeb/WebGL/WebGLSync.h @@ -16,14 +16,18 @@ class WebGLSync : public WebGLObject { GC_DECLARE_ALLOCATOR(WebGLSync); public: - static GC::Ref create(JS::Realm& realm, GLuint handle); + static GC::Ref 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 }; }; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index c2296ce36c2..a017ed109e7 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -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, diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp index c3e7d66a16f..c60babea153 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp @@ -357,6 +357,7 @@ ErrorOr serenity_main(Main::Arguments arguments) #include #include #include +#include #include #include #include @@ -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 strings;