From 765eb85eb39fa9561a0ca305d107cf27b001724a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Sat, 21 Nov 2026 19:29:08 +0200 Subject: [PATCH 1/2] Add support for the WebGL 2 extension OVR_multiview2 Fixes: #20173 Co-Authored-By: Claude Fable 5.2 --- ChangeLog.md | 1 + src/lib/libhtml5_webgl.js | 4 +- src/lib/libsigs.js | 2 + src/lib/libwebgl.js | 2 + src/lib/libwebgl2.js | 15 ++ system/include/emscripten/html5_webgl.h | 2 + system/include/webgl/webgl2_ext.h | 20 ++ system/lib/gl/webgl2.c | 6 +- test/browser/webgl2_ovr_multiview2.c | 209 ++++++++++++++++++ .../browser/webgl2_simple_enable_extensions.c | 4 + .../test_codesize_hello_dylink_all.json | 10 +- test/test_browser.py | 13 ++ 12 files changed, 283 insertions(+), 5 deletions(-) create mode 100644 test/browser/webgl2_ovr_multiview2.c diff --git a/ChangeLog.md b/ChangeLog.md index c9ec38b00e617..32a51985e93c8 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -43,6 +43,7 @@ See docs/process.md for more on how version tagging works. - Building with `-sJSPI` now bumps the default minimum supported browser versions to the first ones that support JSPI: Chrome 137, Firefox 153, Safari 27 and Node.js 24. (#28334) +- Added support for the WebGL 2 extension `OVR_multiview2`. (#20173) 7.0.0 - 11/06/26 ---------------- diff --git a/src/lib/libhtml5_webgl.js b/src/lib/libhtml5_webgl.js index f950fc7742d78..7b846bebc0357 100644 --- a/src/lib/libhtml5_webgl.js +++ b/src/lib/libhtml5_webgl.js @@ -344,6 +344,7 @@ var LibraryHtml5WebGL = { #if MAX_WEBGL_VERSION >= 2 if (extString == 'WEBGL_draw_instanced_base_vertex_base_instance') webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance(GLctx); if (extString == 'WEBGL_multi_draw_instanced_base_vertex_base_instance') webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance(GLctx); + if (extString == 'OVR_multiview2') webgl_enable_OVR_multiview2(GLctx); #endif if (extString == 'WEBGL_multi_draw') webgl_enable_WEBGL_multi_draw(GLctx); @@ -360,7 +361,8 @@ var LibraryHtml5WebGL = { 'EXT_clip_control', 'WEBGL_polygon_mode', 'WEBGL_draw_instanced_base_vertex_base_instance', - 'WEBGL_multi_draw_instanced_base_vertex_base_instance'].includes(extString)) { + 'WEBGL_multi_draw_instanced_base_vertex_base_instance', + 'OVR_multiview2'].includes(extString)) { err('When building with -sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=0, function emscripten_webgl_enable_extension() cannot be used to enable extension ' + extString + '! Use one of the functions emscripten_webgl_enable_*() to enable it!'); } diff --git a/src/lib/libsigs.js b/src/lib/libsigs.js index cb70908f30512..2d9457108fa0b 100644 --- a/src/lib/libsigs.js +++ b/src/lib/libsigs.js @@ -883,6 +883,7 @@ sigs = { emscripten_webgl_enable_EXT_clip_control__sig: 'ip', emscripten_webgl_enable_EXT_polygon_offset_clamp__sig: 'ip', emscripten_webgl_enable_OES_vertex_array_object__sig: 'ip', + emscripten_webgl_enable_OVR_multiview2__sig: 'ip', emscripten_webgl_enable_WEBGL_draw_buffers__sig: 'ip', emscripten_webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance__sig: 'ip', emscripten_webgl_enable_WEBGL_multi_draw__sig: 'ip', @@ -1075,6 +1076,7 @@ sigs = { glFramebufferTexture2D__sig: 'viiiii', glFramebufferTexture2DOES__sig: 'viiiii', glFramebufferTextureLayer__sig: 'viiiii', + glFramebufferTextureMultiviewOVR__sig: 'viiiiii', glFrontFace__sig: 'vi', glFrustum__sig: 'vdddddd', glFrustumf__sig: 'vffffff', diff --git a/src/lib/libwebgl.js b/src/lib/libwebgl.js index 8a09b5fda4580..d82175e32b81c 100644 --- a/src/lib/libwebgl.js +++ b/src/lib/libwebgl.js @@ -193,6 +193,7 @@ for (let i = 0; i <= GL_POOL_TEMP_BUFFERS_SIZE; ++i) { 'EXT_disjoint_timer_query_webgl2', 'EXT_texture_norm16', 'NV_shader_noperspective_interpolation', + 'OVR_multiview2', 'WEBGL_clip_cull_distance', 'WEBGL_draw_instanced_base_vertex_base_instance', 'WEBGL_multi_draw_instanced_base_vertex_base_instance', @@ -1207,6 +1208,7 @@ for (let i = 0; i <= GL_POOL_TEMP_BUFFERS_SIZE; ++i) { // Extensions that are available from WebGL >= 2 (no-op if called on a WebGL 1 context active) webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance(gl); webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance(gl); + webgl_enable_OVR_multiview2(gl); // On WebGL 2, EXT_disjoint_timer_query is replaced with an alternative // that's based on core APIs, and exposes only the queryCounterEXT() diff --git a/src/lib/libwebgl2.js b/src/lib/libwebgl2.js index 8bfe09c19da3b..6a4e7355c438b 100644 --- a/src/lib/libwebgl2.js +++ b/src/lib/libwebgl2.js @@ -991,6 +991,21 @@ var LibraryWebGL2 = { emscripten_webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance: (ctx) => webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance(GL.contexts[ctx].GLctx), + + $webgl_enable_OVR_multiview2: (ctx) => + // Closure is expected to be allowed to minify the '.ovrMultiview2' property, so not accessing it quoted. + !!(ctx.ovrMultiview2 = ctx.getExtension('OVR_multiview2')), + + emscripten_webgl_enable_OVR_multiview2: (ctx) => + webgl_enable_OVR_multiview2(GL.contexts[ctx].GLctx), + + glFramebufferTextureMultiviewOVR: (target, attachment, texture, level, baseViewIndex, numViews) => { +#if GL_ASSERTIONS + assert(GLctx.ovrMultiview2, 'OVR_multiview2 not supported, or not enabled. Before calling glFramebufferTextureMultiviewOVR(), call emscripten_webgl_enable_OVR_multiview2() to enable this extension, and verify that it returns true to indicate support. (alternatively, build with -sGL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS=1 to enable all GL extensions by default)'); + GL.validateGLObjectID(GL.textures, texture, 'glFramebufferTextureMultiviewOVR', 'texture'); +#endif + GLctx.ovrMultiview2['framebufferTextureMultiviewOVR'](target, attachment, GL.textures[texture], level, baseViewIndex, numViews); + }, }; #if MAX_WEBGL_VERSION >= 2 diff --git a/system/include/emscripten/html5_webgl.h b/system/include/emscripten/html5_webgl.h index bfad39731f1ea..9f164ee2ed9db 100644 --- a/system/include/emscripten/html5_webgl.h +++ b/system/include/emscripten/html5_webgl.h @@ -82,6 +82,8 @@ bool emscripten_webgl_enable_EXT_clip_control(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE co bool emscripten_webgl_enable_WEBGL_polygon_mode(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_OVR_multiview2(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); + typedef bool (*em_webgl_context_callback)(int eventType, const void *reserved, void *userData); EMSCRIPTEN_RESULT emscripten_set_webglcontextlost_callback_on_thread(const char * _Nonnull target, void *userData, bool useCapture, em_webgl_context_callback callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_set_webglcontextrestored_callback_on_thread(const char * _Nonnull target, void *userData, bool useCapture, em_webgl_context_callback callback, pthread_t targetThread); diff --git a/system/include/webgl/webgl2_ext.h b/system/include/webgl/webgl2_ext.h index 76908cec3e9f6..03ac66af185ff 100644 --- a/system/include/webgl/webgl2_ext.h +++ b/system/include/webgl/webgl2_ext.h @@ -1,6 +1,7 @@ #pragma once #include "webgl2.h" +#include // 33. https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query_webgl2/ #ifndef EMSCRIPTEN_GL_EXT_disjoint_timer_query_webgl2 @@ -12,6 +13,25 @@ WEBGL_APICALL void GL_APIENTRY glQueryCounterEXT(GLuint query, GLenum target); #endif /* EMSCRIPTEN_GL_EXT_disjoint_timer_query_webgl2 */ +// 36. https://www.khronos.org/registry/webgl/extensions/OVR_multiview2/ +#ifndef EMSCRIPTEN_GL_OVR_multiview2 +#define EMSCRIPTEN_GL_OVR_multiview2 1 +// To enable: call +bool emscripten_webgl_enable_OVR_multiview2(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +// or link with -sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=1 and +// call emscripten_webgl_enable_extension(ctx, "OVR_multiview2"); +// +// Shaders must enable the extension with "#extension GL_OVR_multiview2 : require". +// WebGL does not support the older "GL_OVR_multiview" shader extension name, and +// only 2D array textures can be attached with glFramebufferTextureMultiviewOVR(). +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +WEBGL_APICALL void GL_APIENTRY emscripten_glFramebufferTextureMultiviewOVR(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +WEBGL_APICALL void GL_APIENTRY glFramebufferTextureMultiviewOVR(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif /* EMSCRIPTEN_GL_OVR_multiview2 */ + // 46. https://www.khronos.org/registry/webgl/extensions/WEBGL_draw_instanced_base_vertex_base_instance/ #ifndef EMSCRIPTEN_GL_WEBGL_draw_instanced_base_vertex_base_instance #define EMSCRIPTEN_GL_WEBGL_draw_instanced_base_vertex_base_instance 1 diff --git a/system/lib/gl/webgl2.c b/system/lib/gl/webgl2.c index 2d9e2d29511ee..44ecea7c78de4 100644 --- a/system/lib/gl/webgl2.c +++ b/system/lib/gl/webgl2.c @@ -13,6 +13,7 @@ #include #include +#include #include "webgl_internal.h" @@ -150,6 +151,9 @@ GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES(GLuint array) { return glIsV GL_APICALL void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs) { glDrawBuffers(n, bufs); } GL_APICALL void GL_APIENTRY glDrawBuffersWEBGL(GLsizei n, const GLenum *bufs) { glDrawBuffers(n, bufs); } +// WebGL 2 extensions: +ASYNC_GL_FUNCTION_6(EM_FUNC_SIG_VIIIIII, void, glFramebufferTextureMultiviewOVR, GLenum, GLenum, GLuint, GLint, GLint, GLsizei); + #endif // ~__EMSCRIPTEN_PTHREADS__) && __EMSCRIPTEN_OFFSCREEN_FRAMEBUFFER__ #if GL_ENABLE_GET_PROC_ADDRESS @@ -307,7 +311,7 @@ void *emscripten_webgl2_get_proc_address(const char *name) { RETURN_FN(glDrawBuffersWEBGL); // WebGL 2 extensions: - // (currently none) + RETURN_FN(glFramebufferTextureMultiviewOVR); return 0; } diff --git a/test/browser/webgl2_ovr_multiview2.c b/test/browser/webgl2_ovr_multiview2.c new file mode 100644 index 0000000000000..2f3278f2f472a --- /dev/null +++ b/test/browser/webgl2_ovr_multiview2.c @@ -0,0 +1,209 @@ +// Copyright 2026 The Emscripten Authors. All rights reserved. +// Emscripten is available under two separate licenses, the MIT license and the +// University of Illinois/NCSA Open Source License. Both these licenses can be +// found in the LICENSE file. + +// Tests the WebGL 2 extension OVR_multiview2, which allows rendering to +// several layers ("views") of a 2D array texture with a single draw call. +// See https://github.com/emscripten-core/emscripten/issues/20173 +// +// The extension is not available in all browsers and platforms. If it is not +// supported, the test only verifies that it cannot be enabled. + +#include +#include +#include +#include +#include + +// The function glFramebufferTextureMultiviewOVR() is declared both by the +// Khronos GLES extension header, and by the Emscripten WebGL 2 extension +// header. Include both to verify that the two can be used together. +#define GL_GLEXT_PROTOTYPES +#include +#include +#include + +#define WIDTH 4 +#define HEIGHT 4 +#define NUM_VIEWS 2 + +static bool has_extension(const char *name) { + GLint num_extensions = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions); + for (GLint i = 0; i < num_extensions; ++i) { + if (!strcmp((const char *)glGetStringi(GL_EXTENSIONS, i), name)) return true; + } + return false; +} + +static GLuint compile_shader(GLenum type, const char *src) { + GLuint shader = glCreateShader(type); + glShaderSource(shader, 1, &src, NULL); + glCompileShader(shader); + GLint compiled = 0; + glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); + if (!compiled) { + char log[1024]; + glGetShaderInfoLog(shader, sizeof(log), NULL, log); + printf("Shader compile failed: %s\n", log); + } + assert(compiled); + return shader; +} + +static GLuint create_array_texture(GLenum internal_format) { + GLuint texture; + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D_ARRAY, texture); + glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, internal_format, WIDTH, HEIGHT, NUM_VIEWS); + return texture; +} + +static void assert_attachment(GLenum attachment, GLint type, GLint num_views, GLint base_view_index) { + GLint value = -1; + glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value); + assert(value == type); + if (type != GL_NONE) { + glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR, &value); + assert(value == num_views); + glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR, &value); + assert(value == base_view_index); + } + assert(glGetError() == GL_NO_ERROR); +} + +// Reads back a pixel from the given layer of the texture. Reading from a +// multiview framebuffer is not allowed, so do this via a regular framebuffer +// that has the layer as its attachment. +static void assert_layer_color(GLuint texture, int layer, int r, int g, int b) { + GLuint fbo; + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); + glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0, layer); + assert(glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + unsigned char pixel[4] = { 0x12, 0x34, 0x56, 0x78 }; + glReadPixels(WIDTH / 2, HEIGHT / 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); + printf("Layer %d: %d,%d,%d,%d\n", layer, pixel[0], pixel[1], pixel[2], pixel[3]); + assert(pixel[0] == r && pixel[1] == g && pixel[2] == b && pixel[3] == 255); + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &fbo); + assert(glGetError() == GL_NO_ERROR); +} + +int main() { + EmscriptenWebGLContextAttributes attr; + emscripten_webgl_init_context_attributes(&attr); + attr.majorVersion = 2; + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr); + assert(ctx > 0); + emscripten_webgl_make_context_current(ctx); + + bool supported = has_extension("GL_OVR_multiview2"); + printf("OVR_multiview2 supported: %d\n", supported); + +#if defined(TEST_EXPLICIT_ENABLE) + // Enable the extension with its dedicated function. + assert(emscripten_webgl_enable_OVR_multiview2(ctx) == supported); +#elif defined(TEST_SIMPLE_ENABLE) + // Enable the extension with the generic extension enable function. + assert(emscripten_webgl_enable_extension(ctx, "OVR_multiview2") == supported); +#else + // By default the extension is enabled automatically at context creation + // time, if the browser supports it (-sGL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS). +#endif + + if (!supported) { + printf("OVR_multiview2 is not supported, skipping test.\n"); + return 0; + } + + GLint max_views = 0; + glGetIntegerv(GL_MAX_VIEWS_OVR, &max_views); + printf("GL_MAX_VIEWS_OVR: %d\n", max_views); + assert(max_views >= NUM_VIEWS); + assert(glGetError() == GL_NO_ERROR); + + GLuint color = create_array_texture(GL_RGBA8); + GLuint depth = create_array_texture(GL_DEPTH_COMPONENT24); + + GLuint fbo; + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); + glFramebufferTextureMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, color, 0, 0, NUM_VIEWS); + assert(glGetError() == GL_NO_ERROR); + + // Attach the depth buffer via a function pointer to also test + // that the function can be looked up dynamically. + void (*framebufferTextureMultiview)(GLenum, GLenum, GLuint, GLint, GLint, GLsizei) = + (void (*)(GLenum, GLenum, GLuint, GLint, GLint, GLsizei))emscripten_webgl_get_proc_address("glFramebufferTextureMultiviewOVR"); + assert(framebufferTextureMultiview); + framebufferTextureMultiview(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depth, 0, 0, NUM_VIEWS); + assert(glGetError() == GL_NO_ERROR); + + assert(glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + assert_attachment(GL_COLOR_ATTACHMENT0, GL_TEXTURE, NUM_VIEWS, 0); + assert_attachment(GL_DEPTH_ATTACHMENT, GL_TEXTURE, NUM_VIEWS, 0); + + // Attaching the null texture detaches the attachment. + glFramebufferTextureMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 0, 0, 0, NUM_VIEWS); + assert_attachment(GL_DEPTH_ATTACHMENT, GL_NONE, 0, 0); + glFramebufferTextureMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depth, 0, 0, NUM_VIEWS); + assert_attachment(GL_DEPTH_ATTACHMENT, GL_TEXTURE, NUM_VIEWS, 0); + + // Invalid parameters are reported as GL errors. + glFramebufferTextureMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, color, 0, 0, max_views + 1); + assert(glGetError() == GL_INVALID_VALUE); + assert_attachment(GL_COLOR_ATTACHMENT0, GL_TEXTURE, NUM_VIEWS, 0); + assert(glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + + // Render a fullscreen triangle to both views with a single draw call. The + // output color depends on the view that is being rendered to. + GLuint vs = compile_shader(GL_VERTEX_SHADER, + "#version 300 es\n" + "#extension GL_OVR_multiview2 : require\n" + "layout(num_views = 2) in;\n" + "flat out vec4 color;\n" + "void main() {\n" + " color = (gl_ViewID_OVR == 0u) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0);\n" + " gl_Position = vec4(float((gl_VertexID << 1) & 2) * 2.0 - 1.0, float(gl_VertexID & 2) * 2.0 - 1.0, 0.0, 1.0);\n" + "}\n"); + + GLuint fs = compile_shader(GL_FRAGMENT_SHADER, + "#version 300 es\n" + "precision mediump float;\n" + "flat in vec4 color;\n" + "out vec4 outColor;\n" + "void main() { outColor = color; }\n"); + + GLuint program = glCreateProgram(); + glAttachShader(program, vs); + glAttachShader(program, fs); + glLinkProgram(program); + GLint linked = 0; + glGetProgramiv(program, GL_LINK_STATUS, &linked); + assert(linked); + glUseProgram(program); + + GLuint vao; + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + glViewport(0, 0, WIDTH, HEIGHT); + glClearColor(0.f, 0.f, 1.f, 1.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + assert(glGetError() == GL_NO_ERROR); + + // Clearing a multiview framebuffer clears all of the views. + assert_layer_color(color, 0, 0, 0, 255); + assert_layer_color(color, 1, 0, 0, 255); + + glDrawArrays(GL_TRIANGLES, 0, 3); + assert(glGetError() == GL_NO_ERROR); + + assert_layer_color(color, 0, 255, 0, 0); + assert_layer_color(color, 1, 0, 255, 0); + + printf("Test passed!\n"); + return 0; +} diff --git a/test/browser/webgl2_simple_enable_extensions.c b/test/browser/webgl2_simple_enable_extensions.c index 03fa26b9b9031..2dd44919919d4 100644 --- a/test/browser/webgl2_simple_enable_extensions.c +++ b/test/browser/webgl2_simple_enable_extensions.c @@ -70,6 +70,9 @@ int main() if (hasext(exts, "WEBGL_polygon_mode")) assert(emscripten_webgl_enable_WEBGL_polygon_mode(context)); + if (hasext(exts, "OVR_multiview2")) + assert(emscripten_webgl_enable_OVR_multiview2(context)); + #if WEBGL_SIMPLE_ENABLE_EXTENSION assert(hasext(exts, "ANGLE_instanced_arrays") == emscripten_webgl_enable_extension(context, "ANGLE_instanced_arrays")); assert(hasext(exts, "OES_vertex_array_object") == emscripten_webgl_enable_extension(context, "OES_vertex_array_object")); @@ -77,6 +80,7 @@ int main() assert(hasext(exts, "WEBGL_draw_instanced_base_vertex_base_instance") == emscripten_webgl_enable_extension(context, "WEBGL_draw_instanced_base_vertex_base_instance")); assert(hasext(exts, "WEBGL_multi_draw") == emscripten_webgl_enable_extension(context, "WEBGL_multi_draw")); assert(hasext(exts, "WEBGL_multi_draw_instanced_base_vertex_base_instance") == emscripten_webgl_enable_extension(context, "WEBGL_multi_draw_instanced_base_vertex_base_instance")); + assert(hasext(exts, "OVR_multiview2") == emscripten_webgl_enable_extension(context, "OVR_multiview2")); #endif return 0; diff --git a/test/codesize/test_codesize_hello_dylink_all.json b/test/codesize/test_codesize_hello_dylink_all.json index f545d480e709e..e78f958c57935 100644 --- a/test/codesize/test_codesize_hello_dylink_all.json +++ b/test/codesize/test_codesize_hello_dylink_all.json @@ -1,7 +1,7 @@ { - "a.out.js": 268338, - "a.out.nodebug.wasm": 535698, - "total": 804036, + "a.out.js": 268699, + "a.out.nodebug.wasm": 535807, + "total": 804506, "sent": [ "IMG_Init", "IMG_Load", @@ -607,6 +607,7 @@ "emscripten_glFramebufferRenderbuffer", "emscripten_glFramebufferTexture2D", "emscripten_glFramebufferTextureLayer", + "emscripten_glFramebufferTextureMultiviewOVR", "emscripten_glFrontFace", "emscripten_glGenBuffers", "emscripten_glGenFramebuffers", @@ -965,6 +966,7 @@ "emscripten_webgl_enable_EXT_clip_control", "emscripten_webgl_enable_EXT_polygon_offset_clamp", "emscripten_webgl_enable_OES_vertex_array_object", + "emscripten_webgl_enable_OVR_multiview2", "emscripten_webgl_enable_WEBGL_draw_buffers", "emscripten_webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance", "emscripten_webgl_enable_WEBGL_multi_draw", @@ -1114,6 +1116,7 @@ "glFramebufferRenderbuffer", "glFramebufferTexture2D", "glFramebufferTextureLayer", + "glFramebufferTextureMultiviewOVR", "glFrontFace", "glGenBuffers", "glGenFramebuffers", @@ -1570,6 +1573,7 @@ "GOT.func.emscripten_glFramebufferRenderbuffer", "GOT.func.emscripten_glFramebufferTexture2D", "GOT.func.emscripten_glFramebufferTextureLayer", + "GOT.func.emscripten_glFramebufferTextureMultiviewOVR", "GOT.func.emscripten_glFrontFace", "GOT.func.emscripten_glGenBuffers", "GOT.func.emscripten_glGenFramebuffers", diff --git a/test/test_browser.py b/test/test_browser.py index 67a220b16b202..4ff6ba735c6d6 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -2667,6 +2667,19 @@ def test_webgl2_pthreads(self): # (the testcase doesn't even use threads, but is compiled with thread support). self.btest_exit('webgl2.c', cflags=['-sMAX_WEBGL_VERSION=2', '-lGL', '-pthread']) + # Tests the WebGL 2 extension OVR_multiview2 (#20173) + @requires_webgl2 + @parameterized({ + '': ([],), + 'explicit_enable': (['-DTEST_EXPLICIT_ENABLE', '-sGL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS=0', '-sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=0'],), + 'simple_enable': (['-DTEST_SIMPLE_ENABLE', '-sGL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS=0'],), + 'assertions': (['-sGL_ASSERTIONS'],), + 'closure': (['-O2', '-g1', '--closure=1'],), + 'offscreenframebuffer_pthread': (['-sOFFSCREEN_FRAMEBUFFER', '-pthread', '-sPROXY_TO_PTHREAD'],), + }) + def test_webgl2_ovr_multiview2(self, args): + self.btest_exit('webgl2_ovr_multiview2.c', cflags=['-sMAX_WEBGL_VERSION=2', '-lGL'] + args) + @requires_graphics_hardware def test_webgl2_objects(self): self.btest_exit('webgl2_objects.c', cflags=['-sMAX_WEBGL_VERSION=2', '-lGL']) From 04282aa764499c65a6cc7c1fb4dfc77eb8ed70c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Sat, 21 Nov 2026 21:17:08 +0200 Subject: [PATCH 2/2] Remove extra comment --- test/test_browser.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_browser.py b/test/test_browser.py index 4ff6ba735c6d6..8c5441cea9fc6 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -2667,7 +2667,6 @@ def test_webgl2_pthreads(self): # (the testcase doesn't even use threads, but is compiled with thread support). self.btest_exit('webgl2.c', cflags=['-sMAX_WEBGL_VERSION=2', '-lGL', '-pthread']) - # Tests the WebGL 2 extension OVR_multiview2 (#20173) @requires_webgl2 @parameterized({ '': ([],),