Commit graph

39 commits

Author SHA1 Message Date
Undefine
f373ab7011 LibWeb: Bind WebGL uniform locations to their respective program
The spec mandates that each uniform location object only gets used with
the program it was created with.
2025-11-27 19:19:54 +01:00
Undefine
7d6212ae71 LibWeb: Ensure WebGL buffers don't mix between index and other data
The spec mandates that a buffer during its lifetime can only get bound
to either an index buffer or any other type.
2025-11-27 19:19:54 +01:00
Undefine
2bf35881f9 LibWeb: Ensure compressed* WebGL functions don't allow disabled formats 2025-11-06 19:02:36 +01:00
Undefine
5b88b76b84 LibWeb: Deduplicate WebGL1 implementations from WebGL2
This makes the WebGL2 implementation file inherit from the WebGL1
implementation file. This is actually closer to what the IDL files
describe and allows us to not have to maintain two copies of the same
functions.
2025-11-05 02:19:32 +01:00
Undefine
df1aeda955 LibWeb: Deduplicate the WebGL null_terminated_string helper 2025-11-05 02:19:32 +01:00
Undefine
6c115171da LibWeb: Split off WebGL2RenderingContextImpl to Impl and Overloads
This mostly analogous to the previous commit that does the same with
the WebGL1 Impl file.
2025-11-05 02:19:32 +01:00
Luke Wilde
8adde0980a LibWeb/WebGL: Respect UNPACK_PREMULTIPLY_ALPHA
Fixes splats on https://superspl.at having dark splotches, as they
expect textures with unpremultiplied alpha.
2025-11-04 17:06:24 +01:00
Undefine
f4eef9d174 LibWeb: Implement a bunch of values for WebGL2 getParameter 2025-11-01 16:53:39 -07:00
Undefine
50d66ba74c LibWeb: Implement WebGL getVertexAttribOffset 2025-11-01 16:53:39 -07:00
Undefine
1bc7e9d3f8 LibWeb: Stub out WebGL getUniform
This makes the function return a dummy value instead of undefined
as that fixes a crash while capturing on SpectorJS.
2025-11-01 16:53:39 -07:00
Undefine
a2c659ee6b LibWeb: Implement WebGL getVertexAttrib
This also implements all allowed parameter name values for this
function.
2025-11-01 16:53:39 -07:00
Undefine
2d8b393c76 LibWeb: Implement WebGL getShaderSource 2025-11-01 16:53:39 -07:00
Undefine
932a3328a3 LibWeb: Implement WebGL getParameter(COMPRESSED_TEXTURE_FORMATS) 2025-11-01 16:53:39 -07:00
Undefine
bc3761b40d LibWeb: Stubout WebGL2 getParameter(MAX_CLIENT_WAIT_TIMEOUT_WEBGL)
The spec actually mandates that clientWaitSync actually has a time
limit and this is a way to get it. For now just return infinity as this
is required of SpectorJS to work.
2025-11-01 16:53:39 -07:00
Jelle Raaijmakers
2f7797f854 LibWeb: Implement WebGL2's getBufferSubData()
This allows copying data from a buffer to an ArrayBufferView's storage.
2025-10-30 16:20:33 -07:00
Jelle Raaijmakers
25d78f7c8e LibWeb: Implement WebGL2's readPixels with a byte offset argument
We pass it in as a `void*` since that's what this API expects when you
have bound the GL_PIXEL_PACK_BUFFER buffer.
2025-10-30 16:20:33 -07:00
Jelle Raaijmakers
7b5940d27d LibWeb: Store and return pixel (un)pack buffer bindings in WebGL2 2025-10-30 16:20:33 -07:00
Luke Wilde
3e7061da40 LibWeb/WebGL: Respect UNPACK_FLIP_Y_WEBGL pixel storage parameter
When this is true, we have to vertically flip TexImageSource provided
images before uploading them.

Fixes several graphical glitches on Google Maps.
Fixes globe being upside down on Shopify's homepage.
Likely fixes more websites.
2025-10-25 12:56:17 +02:00
Luke Wilde
008699c129 LibWeb/WebGL: Return null from getUniformLocation if uniform isn't found 2025-10-25 12:56:17 +02:00
Luke Wilde
4ebe43af58 LibWeb/WebGL2: Implement most of the transform feedback APIs 2025-10-21 23:29:50 +02:00
Luke Wilde
39d42b7b73 LibWeb/WebGL2: Implement waitSync 2025-10-21 23:29:50 +02:00
Luke Wilde
3005cc30b4 LibWeb/WebGL2: Check if WebGLSync object belongs to the current context 2025-10-21 23:29:50 +02:00
Luke Wilde
3d2874bc4e LibWeb/WebGL2: Implement invalidateSubFramebuffer 2025-10-21 23:29:50 +02:00
Luke Wilde
b949c8ea47 LibWeb/WebGL2: Implement framebufferTextureLayer 2025-10-21 23:29:50 +02:00
Luke Wilde
5c1bf5c3f6 LibWeb/WebGL2: Implement most of the query APIs 2025-10-21 23:29:50 +02:00
Luke Wilde
2b941731a7 LibWeb/WebGL2: Implement compressedTex(Sub)Image3D 2025-10-21 23:29:50 +02:00
Luke Wilde
8dcbe69eb6 LibWeb/WebGL2: Implement drawRangeElements 2025-10-21 23:29:50 +02:00
Luke Wilde
2c13a2a68c LibWeb/WebGL2: Implement vertexAttribI4(u)i(v) 2025-10-21 23:29:50 +02:00
Luke Wilde
35763ffe53 LibWeb/WebGL2: Implement uniform{1,2,3,4}uiv 2025-10-21 23:29:50 +02:00
Luke Wilde
59bea36a59 LibWeb/WebGL2: Implement remaining uniformMatrix methods 2025-10-21 23:29:50 +02:00
Luke Wilde
ab3eb9adab LibWeb/WebGL: Replace manual pointer math with Span
This deduplicates a lot of sensitive pointer math by using Span, which
performs this math for us with more safety checks and with type
information.

This also allows us to use the correctly typed Span for typed arrays,
which automatically fixes srcOffset to now offset by the number of
elements instead of bytes. This goes for srcLengthOverride too.

Fixes the Rive animations on Shopify's homepage not appearing.
Fixes some Unity applications such as ArcViewer having missing
graphics.
2025-10-20 16:26:12 +02:00
Luke Wilde
b15f4424f9 LibWeb/WebGL: Implement the EXT_texture_filter_anisotropic extension 2025-10-20 15:33:33 +02:00
Aliaksandr Kalenik
20490d146c LibWeb/WebGL: Deduplicate read_and_pixel_convert_texture_image_source()
After we commited code produced by WebGL generator this function ended
up duplicated between WebGL 1 and 2 contexts.
2025-10-02 18:41:02 +02:00
Aliaksandr Kalenik
a6288e12e9 LibWeb/WebGL: Use TexImageSource alias in method signatures 2025-10-02 18:41:02 +02:00
Aliaksandr Kalenik
ffc05a9ca9 LibWeb/WebGL: Define Uint32List exactly like in the spec
Same fix as d54cab60 but applied for Uint32List.
2025-09-30 18:35:32 +02:00
Aliaksandr Kalenik
c75a8fab3b LibWeb/WebGL: Define Int32List exactly like in the spec
Same fix as d54cab60 but applied for Int32List.
2025-09-30 17:57:46 +02:00
Aliaksandr Kalenik
655cd339a7 LibWeb/WebGL: Move Float32List -> Span<float> conversion into helper
This allows to remove lots of duplicated code.
2025-09-30 16:47:16 +02:00
Aliaksandr Kalenik
d54cab60a8 LibWeb/WebGL: Define Float32List exactly like in the spec
Use `Float32Array or sequence<GLfloat>` instead of
`BufferSource or sequence<GLfloat>`. This meaningfully changes behavior
for `Float16Array` and `Float64Array`: they are now converted to
`sequence<GLfloat>` by iterating the typed array, rather than being
treated as a `BufferSource`. As a result, many WebGL calls now work
correctly where we previously crashed in `VERIFY_NOT_REACHED()` due to
the assumption that a `BufferSource` was always a `Float32Array`.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/5962
2025-09-30 16:47:16 +02:00
Luke Wilde
e85b809f8d LibWeb+Meta: Move WebGL rendering context implementations in tree
This copies the latest generated code in tree and then removes code
generation for the WebGL rendering contexts. This is because it didn't
add much value, and we can maintain the generated output instead of
both that and the generator itself.
2025-07-02 19:00:49 +02:00