Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Several WebGL2 getParameter() calls return undefined instead of the required Boolean or Number types, breaking conformance tests and type-dependent application logic.

Changes

Added missing parameter enums:

  • WebGLBooleanParameterName: kSampleAlphaToCoverage, kSampleCoverage
  • WebGL2BooleanParameterName: kRasterizerDiscard (new enum)
  • WebGL2IntegerParameterName: kUniformBufferOffsetAlignment

Backend implementation:

  • Added WebGL2Context::getParameterV2(WebGL2BooleanParameterName) method
  • Added uniformBufferOffsetAlignment property with lazy GL query and caching
  • Updated GetParameter switch statements to route new parameters correctly

Fixed parameters:

// Now return correct types instead of undefined
gl.getParameter(gl.RASTERIZER_DISCARD)              // boolean (was undefined)
gl.getParameter(gl.SAMPLE_ALPHA_TO_COVERAGE)        // boolean (was undefined)
gl.getParameter(gl.SAMPLE_COVERAGE)                 // boolean (was undefined)
gl.getParameter(gl.MAX_3D_TEXTURE_SIZE)             // number >= 256 (was undefined)
gl.getParameter(gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT) // number >= 1 (was undefined)

All changes align with WebGL2 spec §6.3.

Original prompt

This section details on the original issue you should resolve

<issue_title>WebGL2 context.getParameter returns "undefined" instead of expected types/values for boolean and type checks</issue_title>
<issue_description>### Problem
Some calls to context.getParameter() in the WebGL2 context in JSAR are returning the wrong JS type or an invalid value in critical conformance cases. For example:

  • getParameter(context.RASTERIZER_DISCARD) should return a boolean (false by default), but is undefined
  • getParameter(context.SAMPLE_ALPHA_TO_COVERAGE) and getParameter(context.SAMPLE_COVERAGE) should return booleans
  • getParameter(context.MAX_3D_TEXTURE_SIZE), getParameter(context.UNIFORM_BUFFER_OFFSET_ALIGNMENT), and similar should be non-undefined numbers (integer >= minimum)
  • Certain parameters are NOT being returned as instances of Number or Boolean as required, but are undefined or wrong type

Notable FAIL cases

  • context.getParameter(context.MAX_3D_TEXTURE_SIZE) should be >= 256. Was undefined
  • context.getParameter(context.MAX_3D_TEXTURE_SIZE) is not an instance of Number
  • context.getParameter(context.UNIFORM_BUFFER_OFFSET_ALIGNMENT) should be >= 1. Was undefined
  • context.getParameter(context.UNIFORM_BUFFER_OFFSET_ALIGNMENT) is not an instance of Number
  • context.getParameter(context.RASTERIZER_DISCARD) should be false (boolean) Was undefined
  • Similar errors on other boolean/numeric parameters

Expected Behavior

All type checks per WebGL2 and WebGL1 spec should pass: the returned value should always be of the correct type (Boolean, Number) and value as defined. Never undefined.

Impact

  • Fails conformance and type safety tests
  • Might break application logic depending on typeof/value checks

References

Suggested Actions

  • Audit getParameter implementation for value and type safety
  • Match Chromium mapping for Number and Boolean return values
  • Expand regression tests for typeof/instance conformance

Category: WebGL2 API type & value conformance</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…eters

Co-authored-by: EndlessJour9527 <155411404+EndlessJour9527@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix WebGL2 context.getParameter returning undefined values Fix WebGL2 getParameter returning undefined for boolean and integer conformance parameters Nov 18, 2025
Copilot finished work on behalf of EndlessJour9527 November 18, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebGL2 context.getParameter returns "undefined" instead of expected types/values for boolean and type checks

2 participants