mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb/WebGL: Implement getShaderPrecisionFormat
This commit is contained in:
parent
a14cd5dab8
commit
bf2b8c5f2b
Notes:
github-actions[bot]
2024-12-05 20:42:25 +00:00
Author: https://github.com/Lubrsi
Commit: bf2b8c5f2b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2791
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/shannonbooth
8 changed files with 59 additions and 11 deletions
|
@ -841,6 +841,7 @@ class WebGLProgram;
|
||||||
class WebGLRenderbuffer;
|
class WebGLRenderbuffer;
|
||||||
class WebGLRenderingContext;
|
class WebGLRenderingContext;
|
||||||
class WebGLShader;
|
class WebGLShader;
|
||||||
|
class WebGLShaderPrecisionFormat;
|
||||||
class WebGLTexture;
|
class WebGLTexture;
|
||||||
class WebGLUniformLocation;
|
class WebGLUniformLocation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,6 @@ namespace Web::WebGL {
|
||||||
|
|
||||||
using GLenum = unsigned int;
|
using GLenum = unsigned int;
|
||||||
using GLuint = unsigned int;
|
using GLuint = unsigned int;
|
||||||
|
using GLint = int;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#import <WebGL/WebGLObject.idl>
|
#import <WebGL/WebGLObject.idl>
|
||||||
#import <WebGL/WebGLProgram.idl>
|
#import <WebGL/WebGLProgram.idl>
|
||||||
#import <WebGL/WebGLShader.idl>
|
#import <WebGL/WebGLShader.idl>
|
||||||
|
#import <WebGL/WebGLShaderPrecisionFormat.idl>
|
||||||
#import <WebGL/WebGLTexture.idl>
|
#import <WebGL/WebGLTexture.idl>
|
||||||
#import <WebGL/WebGLUniformLocation.idl>
|
#import <WebGL/WebGLUniformLocation.idl>
|
||||||
#import <WebGL/WebGLRenderbuffer.idl>
|
#import <WebGL/WebGLRenderbuffer.idl>
|
||||||
|
@ -119,7 +120,7 @@ interface mixin WebGLRenderingContextBase {
|
||||||
DOMString? getProgramInfoLog(WebGLProgram program);
|
DOMString? getProgramInfoLog(WebGLProgram program);
|
||||||
[FIXME] any getRenderbufferParameter(GLenum target, GLenum pname);
|
[FIXME] any getRenderbufferParameter(GLenum target, GLenum pname);
|
||||||
any getShaderParameter(WebGLShader shader, GLenum pname);
|
any getShaderParameter(WebGLShader shader, GLenum pname);
|
||||||
[FIXME] WebGLShaderPrecisionFormat? getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
|
WebGLShaderPrecisionFormat? getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
|
||||||
DOMString? getShaderInfoLog(WebGLShader shader);
|
DOMString? getShaderInfoLog(WebGLShader shader);
|
||||||
|
|
||||||
[FIXME] DOMString? getShaderSource(WebGLShader shader);
|
[FIXME] DOMString? getShaderSource(WebGLShader shader);
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Luke Wilde <luke@ladybird.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/Realm.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/Bindings/WebGLShaderPrecisionFormatPrototype.h>
|
#include <LibWeb/Bindings/WebGLShaderPrecisionFormatPrototype.h>
|
||||||
#include <LibWeb/WebGL/WebGLShaderPrecisionFormat.h>
|
#include <LibWeb/WebGL/WebGLShaderPrecisionFormat.h>
|
||||||
|
|
||||||
|
@ -11,11 +14,25 @@ namespace Web::WebGL {
|
||||||
|
|
||||||
GC_DEFINE_ALLOCATOR(WebGLShaderPrecisionFormat);
|
GC_DEFINE_ALLOCATOR(WebGLShaderPrecisionFormat);
|
||||||
|
|
||||||
WebGLShaderPrecisionFormat::WebGLShaderPrecisionFormat(JS::Realm& realm)
|
GC::Ref<WebGLShaderPrecisionFormat> WebGLShaderPrecisionFormat::create(JS::Realm& realm, GLint range_min, GLint range_max, GLint precision)
|
||||||
: WebGLObject(realm, 0)
|
{
|
||||||
|
return realm.create<WebGLShaderPrecisionFormat>(realm, range_min, range_max, precision);
|
||||||
|
}
|
||||||
|
|
||||||
|
WebGLShaderPrecisionFormat::WebGLShaderPrecisionFormat(JS::Realm& realm, GLint range_min, GLint range_max, GLint precision)
|
||||||
|
: Bindings::PlatformObject(realm)
|
||||||
|
, m_range_min(range_min)
|
||||||
|
, m_range_max(range_max)
|
||||||
|
, m_precision(precision)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
WebGLShaderPrecisionFormat::~WebGLShaderPrecisionFormat() = default;
|
WebGLShaderPrecisionFormat::~WebGLShaderPrecisionFormat() = default;
|
||||||
|
|
||||||
|
void WebGLShaderPrecisionFormat::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
Base::initialize(realm);
|
||||||
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(WebGLShaderPrecisionFormat);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,39 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Luke Wilde <luke@ladybird.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/WebGL/WebGLObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/WebGL/Types.h>
|
||||||
|
|
||||||
namespace Web::WebGL {
|
namespace Web::WebGL {
|
||||||
|
|
||||||
class WebGLShaderPrecisionFormat final : public WebGLObject {
|
class WebGLShaderPrecisionFormat final : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(WebGLShaderPrecisionFormat, WebGLObject);
|
WEB_PLATFORM_OBJECT(WebGLShaderPrecisionFormat, Bindings::PlatformObject);
|
||||||
GC_DECLARE_ALLOCATOR(WebGLShaderPrecisionFormat);
|
GC_DECLARE_ALLOCATOR(WebGLShaderPrecisionFormat);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~WebGLShaderPrecisionFormat();
|
static GC::Ref<WebGLShaderPrecisionFormat> create(JS::Realm& realm, GLint range_min, GLint range_max, GLint precision);
|
||||||
|
|
||||||
|
virtual ~WebGLShaderPrecisionFormat() override;
|
||||||
|
|
||||||
|
GLint range_min() const { return m_range_min; }
|
||||||
|
GLint range_max() const { return m_range_max; }
|
||||||
|
GLint precision() const { return m_precision; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit WebGLShaderPrecisionFormat(JS::Realm&);
|
explicit WebGLShaderPrecisionFormat(JS::Realm&, GLint range_min, GLint range_max, GLint precision);
|
||||||
|
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GLint m_range_min { 0 };
|
||||||
|
GLint m_range_max { 0 };
|
||||||
|
GLint m_precision { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// https://registry.khronos.org/webgl/specs/latest/1.0/#5.12
|
// https://registry.khronos.org/webgl/specs/latest/1.0/#5.12
|
||||||
[Exposed=(Window,Worker)]
|
[Exposed=(Window,Worker)]
|
||||||
interface WebGLShaderPrecisionFormat {
|
interface WebGLShaderPrecisionFormat {
|
||||||
[FIXME] readonly attribute GLint rangeMin;
|
readonly attribute GLint rangeMin;
|
||||||
[FIXME] readonly attribute GLint rangeMax;
|
readonly attribute GLint rangeMax;
|
||||||
[FIXME] readonly attribute GLint precision;
|
readonly attribute GLint precision;
|
||||||
};
|
};
|
||||||
|
|
|
@ -113,6 +113,7 @@ static bool is_platform_object(Type const& type)
|
||||||
"WebGLRenderbuffer"sv,
|
"WebGLRenderbuffer"sv,
|
||||||
"WebGLRenderingContext"sv,
|
"WebGLRenderingContext"sv,
|
||||||
"WebGLShader"sv,
|
"WebGLShader"sv,
|
||||||
|
"WebGLShaderPrecisionFormat"sv,
|
||||||
"WebGLTexture"sv,
|
"WebGLTexture"sv,
|
||||||
"WebGLUniformLocation"sv,
|
"WebGLUniformLocation"sv,
|
||||||
"Window"sv,
|
"Window"sv,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
|
* Copyright (c) 2024, Luke Wilde <luke@ladybird.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -327,6 +328,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
#include <LibWeb/WebGL/WebGLRenderbuffer.h>
|
#include <LibWeb/WebGL/WebGLRenderbuffer.h>
|
||||||
#include <LibWeb/WebGL/WebGLRenderingContextImpl.h>
|
#include <LibWeb/WebGL/WebGLRenderingContextImpl.h>
|
||||||
#include <LibWeb/WebGL/WebGLShader.h>
|
#include <LibWeb/WebGL/WebGLShader.h>
|
||||||
|
#include <LibWeb/WebGL/WebGLShaderPrecisionFormat.h>
|
||||||
#include <LibWeb/WebGL/WebGLTexture.h>
|
#include <LibWeb/WebGL/WebGLTexture.h>
|
||||||
#include <LibWeb/WebGL/WebGLUniformLocation.h>
|
#include <LibWeb/WebGL/WebGLUniformLocation.h>
|
||||||
#include <LibWeb/WebIDL/Buffers.h>
|
#include <LibWeb/WebIDL/Buffers.h>
|
||||||
|
@ -718,6 +720,16 @@ public:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (function.name == "getShaderPrecisionFormat"sv) {
|
||||||
|
function_impl_generator.append(R"~~~(
|
||||||
|
GLint range[2];
|
||||||
|
GLint precision;
|
||||||
|
glGetShaderPrecisionFormat(shadertype, precisiontype, range, &precision);
|
||||||
|
return WebGLShaderPrecisionFormat::create(m_realm, range[0], range[1], precision);
|
||||||
|
)~~~");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (function.name == "deleteBuffer"sv) {
|
if (function.name == "deleteBuffer"sv) {
|
||||||
function_impl_generator.append(R"~~~(
|
function_impl_generator.append(R"~~~(
|
||||||
auto handle = buffer ? buffer->handle() : 0;
|
auto handle = buffer ? buffer->handle() : 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue