Skip to content

Commit 7b5940d

Browse files
committed
LibWeb: Store and return pixel (un)pack buffer bindings in WebGL2
1 parent 30729fe commit 7b5940d

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

Libraries/LibWeb/WebGL/WebGL2RenderingContextImpl.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright (c) 2024-2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
33
* Copyright (c) 2024-2025, Luke Wilde <luke@ladybird.org>
4+
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
45
*
56
* SPDX-License-Identifier: BSD-2-Clause
67
*/
@@ -15,7 +16,6 @@ extern "C" {
1516

1617
#include <LibJS/Runtime/Array.h>
1718
#include <LibJS/Runtime/ArrayBuffer.h>
18-
#include <LibJS/Runtime/DataView.h>
1919
#include <LibJS/Runtime/TypedArray.h>
2020
#include <LibWeb/WebGL/OpenGLContext.h>
2121
#include <LibWeb/WebGL/WebGL2RenderingContextImpl.h>
@@ -1591,25 +1591,30 @@ void WebGL2RenderingContextImpl::bind_buffer(WebIDL::UnsignedLong target, GC::Ro
15911591
}
15921592

15931593
switch (target) {
1594-
case GL_ELEMENT_ARRAY_BUFFER:
1595-
m_element_array_buffer_binding = buffer;
1596-
break;
15971594
case GL_ARRAY_BUFFER:
15981595
m_array_buffer_binding = buffer;
15991596
break;
1600-
1601-
case GL_UNIFORM_BUFFER:
1602-
m_uniform_buffer_binding = buffer;
1603-
break;
16041597
case GL_COPY_READ_BUFFER:
16051598
m_copy_read_buffer_binding = buffer;
16061599
break;
16071600
case GL_COPY_WRITE_BUFFER:
16081601
m_copy_write_buffer_binding = buffer;
16091602
break;
1603+
case GL_ELEMENT_ARRAY_BUFFER:
1604+
m_element_array_buffer_binding = buffer;
1605+
break;
1606+
case GL_PIXEL_PACK_BUFFER:
1607+
m_pixel_pack_buffer_binding = buffer;
1608+
break;
1609+
case GL_PIXEL_UNPACK_BUFFER:
1610+
m_pixel_unpack_buffer_binding = buffer;
1611+
break;
16101612
case GL_TRANSFORM_FEEDBACK_BUFFER:
16111613
m_transform_feedback_buffer_binding = buffer;
16121614
break;
1615+
case GL_UNIFORM_BUFFER:
1616+
m_uniform_buffer_binding = buffer;
1617+
break;
16131618
default:
16141619
dbgln("Unknown WebGL buffer object binding target for storing current binding: 0x{:04x}", target);
16151620
set_error(GL_INVALID_ENUM);
@@ -2844,6 +2849,16 @@ JS::Value WebGL2RenderingContextImpl::get_parameter(WebIDL::UnsignedLong pname)
28442849
return JS::js_null();
28452850
return JS::Value(m_transform_feedback_buffer_binding);
28462851
}
2852+
case GL_PIXEL_PACK_BUFFER_BINDING: {
2853+
if (!m_pixel_pack_buffer_binding)
2854+
return JS::js_null();
2855+
return JS::Value(m_pixel_pack_buffer_binding);
2856+
}
2857+
case GL_PIXEL_UNPACK_BUFFER_BINDING: {
2858+
if (!m_pixel_unpack_buffer_binding)
2859+
return JS::js_null();
2860+
return JS::Value(m_pixel_unpack_buffer_binding);
2861+
}
28472862
case GL_TRANSFORM_FEEDBACK_PAUSED: {
28482863
GLboolean result { GL_FALSE };
28492864
glGetBooleanvRobustANGLE(GL_TRANSFORM_FEEDBACK_PAUSED, 1, nullptr, &result);
@@ -3440,6 +3455,8 @@ void WebGL2RenderingContextImpl::visit_edges(JS::Cell::Visitor& visitor)
34403455
visitor.visit(m_texture_binding_2d_array);
34413456
visitor.visit(m_texture_binding_3d);
34423457
visitor.visit(m_transform_feedback_binding);
3458+
visitor.visit(m_pixel_pack_buffer_binding);
3459+
visitor.visit(m_pixel_unpack_buffer_binding);
34433460
}
34443461

34453462
}

Libraries/LibWeb/WebGL/WebGL2RenderingContextImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ class WebGL2RenderingContextImpl : public WebGLRenderingContextBase {
257257
GC::Ptr<WebGLBuffer> m_copy_read_buffer_binding;
258258
GC::Ptr<WebGLBuffer> m_copy_write_buffer_binding;
259259
GC::Ptr<WebGLBuffer> m_transform_feedback_buffer_binding;
260+
GC::Ptr<WebGLBuffer> m_pixel_pack_buffer_binding;
261+
GC::Ptr<WebGLBuffer> m_pixel_unpack_buffer_binding;
260262
GC::Ptr<WebGLTexture> m_texture_binding_2d_array;
261263
GC::Ptr<WebGLTexture> m_texture_binding_3d;
262264
GC::Ptr<WebGLTransformFeedback> m_transform_feedback_binding;

0 commit comments

Comments
 (0)