diff --git a/fixtures/html/webgl-conformance/webgl2-getattriblocation-builtin-attribs.html b/fixtures/html/webgl-conformance/webgl2-getattriblocation-builtin-attribs.html new file mode 100644 index 000000000..eab859c68 --- /dev/null +++ b/fixtures/html/webgl-conformance/webgl2-getattriblocation-builtin-attribs.html @@ -0,0 +1,150 @@ + + + + + WebGL2 getAttribLocation Built-in Attributes Test + + + + +

WebGL2 getAttribLocation Built-in Attributes Test

+

Testing that getAttribLocation returns -1 for built-in attributes per WebGL 2.0 spec §5.18

+
+ + + + + diff --git a/src/client/graphics/webgl_context.cpp b/src/client/graphics/webgl_context.cpp index 9e60d485b..6177d2f70 100644 --- a/src/client/graphics/webgl_context.cpp +++ b/src/client/graphics/webgl_context.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -831,6 +832,15 @@ namespace endor optional WebGLContext::getAttribLocation(shared_ptr program, const string &name) { assert(program != nullptr && "Program is not null"); + + // WebGL 2.0 spec §5.18: Built-in attributes always return -1 + static const std::set kBuiltInAttribs = { + "gl_VertexID", "gl_InstanceID", "gl_Position", "gl_PointSize"}; + if (kBuiltInAttribs.count(name)) + { + return nullopt; // Returns nullopt which script bindings converts to -1 + } + return program->hasAttribLocation(name) ? optional(program->getAttribLocation(name)) : nullopt; }