Commit graph

213 commits

Author SHA1 Message Date
Undefine
c01f0e537e LibWeb: Clear m_current_program when the program gets deleted 2025-11-27 19:19:54 +01:00
Undefine
b0fcb35134 LibWeb: Implement WebGL getParameter(GL_VERTEX_ARRAY_BINDING) 2025-11-27 19:19:54 +01:00
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
Jelle Raaijmakers
82dfa69e4e LibWeb/WebGL: Implement getRenderbufferParameter() 2025-11-27 15:51:59 +01:00
Undefine
2a73f779c3 LibWeb: Small WebGL spec fix for vertexAttribPointer 2025-11-06 19:02:36 +01:00
Undefine
5caead88fc LibWeb: Allow WebGL getParameter when WEBGL_draw_buffers is enabled
When that extensions is enabled we should allow getting the parameter
value of MAX_COLOR_ATTACHMENTS_WEBGL.
2025-11-06 19:02:36 +01:00
Undefine
d4ac9fc5c6 LibWeb: Implement WebGL extension OES_standard_derivatives 2025-11-06 19:02:36 +01:00
Undefine
2bf35881f9 LibWeb: Ensure compressed* WebGL functions don't allow disabled formats 2025-11-06 19:02:36 +01:00
Undefine
044ac2dd28 LibWeb: Fix WebGL getError
getError was just calling out to glGetError and never checking our
error value that we were maintaining ourselves.
2025-11-06 19:02:36 +01:00
Undefine
e7aeb71d29 LibWeb: Move WebGL error variable to WebGLRenderingContextBase
Implementations in both WebGL1 and WebGL2 were the same and most
probably will stay the same.
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
7a1668fe22 LibWeb: Switch include in WebGLRenderingContextImpl to OpenGL ES 3
The reasoning behind this is that in the next commit some of the WebGL2
specific parameters will be moved here. This header is needed to give
us access to those defines. Note that when in WebGL1 nothing from ES3
will be used as it's locked behind WebGL2 checks (it wouldn't work
anyways as we request ES2 from ANGLE).
2025-11-05 02:19:32 +01:00
Undefine
395bc3ee27 LibWeb: Add a webgl_version getter to OpenGLContext 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
Undefine
c70886ab1f LibWeb: Split off WebGLRenderingContextImpl to Impl and Overloads
This is more like what the IDL files specify with two different mixins,
but the inheritance structure here is slightly different for easier
maintenance. This will also allow the WebGL2 Impl to inherit from the
WebGL1 Impl as WebGL versions don't share the functions defined in the
Overloads interfaces.
2025-11-05 02:19:32 +01:00
Undefine
7f0f1c3266 LibWeb: Add missing WebGL includes 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
Undefine
78aa3467e9 LibWeb: Define GLintptr as 64-bit
In the IDL file GLintptr is defined as long long which is 64-bit, which
made that definition incorrect.
2025-11-01 16:53:39 -07:00
Undefine
8867f1ae62 LibWeb: Correctly report available WebGL extensions
The correct behaviour is to get values of both GL_EXTENSIONS and
GL_REQUESTABLE_EXTENSIONS_ANGLE.
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
Zaggy1024
7e20b21879 LibWeb: Bind the default frame/render buffers when resetting context
This fixes the masking and warping effects on pixijs.com.

Co-authored-by: Luke Wilde <luke@ladybird.org>
2025-10-29 22:06:31 -07:00
Luke Wilde
3ca4ff6037 LibWeb/WebGL: Don't attempt to do texture transforms on an empty texture
Skia will not give us a surface if the width or height is zero.
2025-10-28 10:05:56 -07:00
Luke Wilde
d733bf54cc LibWeb/WebGL: Avoid copying canvas surface when uploading it 2025-10-25 12:56:17 +02:00
Luke Wilde
d65f0e4490 LibWeb/WebGL: Calculate the correct pitch for compacted types
It's not correct to multiply the number of components by the number of
bytes, since compact formats such as 4_4_4_4 have 4 components but
_always_ stored in 2 bytes, not 8 if you were to do such a
multiplication.

Fixes textures on Google Maps having large blank stripes.
2025-10-25 12:56:17 +02: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
b8bbebd3ff LibWeb/WebGL: Upload blank image in texImage2D if pixels is null 2025-10-21 23:29:50 +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
66a36050bd LibWeb/WebGL: Use surfaceless contexts when making a context current
After we bind the surface to the context for the first time when
allocating the backing image, it internally has a permanent reference
count above 0.

If we switch to a different context and back, the switch back will fail
because the surface has a reference count, which makes ANGLE think
we're trying to use it on a different thread.

However, we can avoid this by using surfaceless contexts, since we
don't use the default framebuffer.

Fixes multiple WebGL contexts on the page freezing.
2025-10-21 09:59:59 +02:00