Bug Description
Running Khronos/WebGL2 conformance test (active-built-in-attribs.html) in JSAR Runtime:
shouldBe('activeInfo.name', '"gl_VertexID"');
attribLoc = gl.getAttribLocation(prog, 'gl_VertexID');
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be able to request the location of a built-in.");
shouldBe('attribLoc', '-1');
Test fails: attribLoc should be -1. Was 0.
Spec Reference
Root Cause
- JSAR currently returns 0 for built-in attribute names instead of -1, violating spec compliance.
- Correct behavior: gl.getAttribLocation(program, 'gl_VertexID') MUST return -1, never a valid location.
Acceptance Criteria
- getAttribLocation on any built-in attribute ('gl_VertexID', 'gl_InstanceID', 'gl_Position', 'gl_PointSize') MUST always return -1
- The referenced conformance test passes
Implementation Guidance (C++)
- Fix the attribute location query in WebGLRenderingContext/WebGL2RenderingContext
- Check if the attribute name matches any of the built-in names, and always return -1
int WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const std::string& name) {
static const std::set<std::string> kBuiltInAttribs = {
"gl_VertexID", "gl_InstanceID", "gl_Position", "gl_PointSize"
};
if (kBuiltInAttribs.count(name)) {
return -1;
}
// ... normal lookup logic
}
- Update error handling and unit tests for built-in attribute query
Impact
- Strict compliance with WebGL2 specification
- Enables all Khronos/WebGL2 tests for built-in attrib queries to pass
Relevant test HTML:
Bug Description
Running Khronos/WebGL2 conformance test (active-built-in-attribs.html) in JSAR Runtime:
Test fails: attribLoc should be -1. Was 0.
Spec Reference
Root Cause
Acceptance Criteria
Implementation Guidance (C++)
Impact
Relevant test HTML:
Spec:
Chromium ref: