Skip to content

WebGL2: transformFeedbackVaryings API not implemented, breaks conformance and library support #410

@EndlessJour9527

Description

@EndlessJour9527

Background

When running WebGL2 code or Khronos conformance tests in JSAR Runtime, the following error is encountered:

Uncaught Error: Failed to execute 'transformFeedbackVaryings' on 'WebGL2RenderingContext': Not implemented

This occurs when JS/WebGL2 code calls the API:

gl.transformFeedbackVaryings(program, ['gl_Position'], gl.INTERLEAVED_ATTRIBS);

Impact

  • Standard conformance tests requiring transform feedback fail to run in JSAR
  • Popular libraries that use transform feedback (e.g., Three.js advanced rendering patterns, Babylon.js particle systems, GPU-based computation, etc.) fail or degrade
  • Both classic and XR spatial apps depending on this API are blocked

Web Standard Reference

Root Cause

  • The native C++ binding for WebGL2RenderingContext.transformFeedbackVaryings is missing or stubbed as "not implemented" in JSAR
  • No logic dispatching from JS layer to the actual OpenGL call (glTransformFeedbackVaryings)

Acceptance Criteria

  • Calling gl.transformFeedbackVaryings in JSAR WebGL2 context correctly dispatches to native and configures transform feedback as per spec
  • Conformance tests referencing this API pass
  • Popular libraries relying on transform feedback work (Three.js, Babylon.js examples)

Implementation Guidance (C++)

  • Add JS binding for transformFeedbackVaryings in WebGL2RenderingContext
  • Dispatch to corresponding OpenGL API:
void WebGL2RenderingContext::transformFeedbackVaryings(WebGLProgram* program, const std::vector<std::string>& varyings, GLenum bufferMode) {
    // Convert string array to C array
    std::vector<const char*> c_varyings;
    for (const auto& v : varyings) {
        c_varyings.push_back(v.c_str());
    }
    glTransformFeedbackVaryings(program->glObject(), c_varyings.size(), c_varyings.data(), bufferMode);
}
  • Update JS-to-native binding so the method is available on WebGL2RenderingContext
  • Fails gracefully (throws per spec) if invoked on invalid program object

Relevant code location to update:

  • src/client/builtin_scene/webgl_rendering_context.cpp

Supporting this API is required for WebGL2 spec conformance and ecosystem compatibility.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions