Closed Bug 1755973 Opened 4 years ago Closed 3 years ago

Using WebGL2 returns wrong Uniform Buffer Object indices for uniform arrays

Categories

(Core :: Graphics: CanvasWebGL, defect, P1)

Firefox 97
defect

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: nikoloffgeorgi, Assigned: jgilbert)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36

Steps to reproduce:

I am writing a WebGL app which uses Uniform Buffer Objects. I declare my UBO in my shader like so:

uniform Lighting {
vec3 pointLightPositions[4];
vec3 pointLightColors[4];
float pointLightIntensity;
float diffuseLightMixFactor;
};

My shaders compile and link in a program successfully. However, once I try to obtain the individual UBO member indices by calling:

const uniformIndices = gl.getUniformIndices(program, [
'pointLightPositions,
'pointLightColors,
'pointLightIntensity',
'diffuseLightMixFactor'
])

I get back the following indices:

0: 4294967295
1: 4294967295
2: 7
3: 8

Clearly the first two are wrong, while the third and last ones are ok. I suspect it has to do with the fact that the first two members are using uniform arrays. Please also notice how the third and fourth members, which are simple floats, have correct indices + correct offsets. So the offsets are being calculated correctly, but the indices are totally wrong.

The Bugbug bot thinks this bug should belong to the 'Core::Canvas: WebGL' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Canvas: WebGL
Product: Firefox → Core

The severity field is not set for this bug.
:jgilbert, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jgilbert)
  1. Does getUniformIndices(program, ['pointLightPositions[0]']) work?

  2. Are pointLightPositions and pointLightColors both used by the shader? (They can return -1 if the compiler thinks they are unused)

Flags: needinfo?(jgilbert) → needinfo?(nikoloffgeorgi)
Severity: -- → S3
Priority: -- → P2

Hell yes, someone else is having the same issue. I can confirm this is happening to me.

my shader contains this:
uniform Group {
vec3 groupPosition[10];
vec3 rotor[10];
};

my js code calls this:
const uboVariableIndices = gl.getUniformIndices(
shaderPrograms,
["groupPosition", "rotor"]
);

and getUniformIndices returns:

uboVariableIndices
0: 4294967295
1: 4294967295

The same code works in chrome and safari. Check meatdumpling.com to see this in action.

Just wondering, do you need more proof than a completely unrelated party chiming in and saying that this is happening and providing a working demonstration? Right now I'm creating a suboptimal workaround for this because I believe in you guys and the fucking awesome piece of tech that is The Fox but I'm really hoping that this gets fixed.

Just in case anyone happens upon this issue, in order to get around the getUniformIndices issue what you can do is check another browser's indices and copy them over. The subsequent call to getActiveUniforms that you may do with the provided indices is equivalent from what I can tell. Time may change things.

I tried to delve into the code to figure out where this function was being called but after a few hours I still have no idea. So, workaround time. On the bright side, my code is fast again. ¯_(ツ)_/¯

Redirect a needinfo that is pending on an inactive user to the triage owner.
:jgilbert, since the bug has high priority and recent activity, could you please find another way to get the information or close the bug as INCOMPLETE if it is not actionable?

For more information, please visit auto_nag documentation.

Flags: needinfo?(nikoloffgeorgi) → needinfo?(jgilbert)

The preferred workaround is to query arrays via e.g. ["groupPosition[0]", "rotor[0]"].
Firefox's bug is that we're supposed to treat e.g. "groupPosition" the same as "groupPosition[0]" if groupPosition is an array.

Flags: needinfo?(jgilbert)
Assignee: nobody → jgilbert
Severity: S3 → S4
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: P2 → P1
Pushed by jgilbert@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cbe4507efd74 Try implied arr+[0] in GetUniformIndices. r=gfx-reviewers,bradwerth
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: