emscripten-core / emscripten-core/emscripten

glGetActiveUniformBlockiv returns invalid value if GL_UNIFORM_BLOCK_BINDING is 0

Open
#13,701 1 comment 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

glGetActiveUniformBlockiv, in https://github.com/emscripten-core/emscripten/blob/main/src/library_webgl2.js, is defined as:

```
var result = GLctx['getActiveUniformBlockParameter'](program, uniformBlockIndex, pname);
if (!result) return; // If an error occurs, nothing will be written to params.
if (typeof result == 'number') {
{{{ makeSetValue('params', '0', 'result', 'i32') }}};
} else {
for (var i = 0; i < result.length; i++) {
{{{ makeSetValue('params', 'i*4', 'result[i]', 'i32') }}};
}
}
```
When querying GL_UNIFORM_BLOCK_BINDING, if it returns 0, the `if (!result)` check returns without setting the return value.

The "error" check should only be done for the array condition. The `typeof result == 'number' check will already validate that it's a number.

```
var result = GLctx['getActiveUniformBlockParameter'](program, uniformBlockIndex, pname);
if (typeof result == 'number') {
{{{ makeSetValue('params', '0', 'result', 'i32') }}};
} else {
if (!result) return; // If an error occurs, nothing will be written to params.
for (var i = 0; i < result.length; i++) {
{{{ makeSetValue('params', 'i*4', 'result[i]', 'i32') }}};
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.