Skip to contentSkip to conversation

glDispatchComputeGroupSizeARB : gl_GlobalInvocationID != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

Bug 103393 [email protected] 1 participant 10 messages Oct 21, 2017 – Oct 24, 2017

lore
Share & tools
lore
#0 lore raw

https://bugs.freedesktop.org/show_bug.cgi?id=103393

            Bug ID: 103393
           Summary: glDispatchComputeGroupSizeARB : gl_GlobalInvocationID
                    != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x +
                    gl_LocalInvocationID.x
           Product: Mesa
           Version: 17.2
          Hardware: x86-64 (AMD64)
                OS: Linux (All)
            Status: NEW
          Severity: normal
          Priority: medium
         Component: Drivers/Gallium/radeonsi
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]

Created attachment 134977
--> https://bugs.freedesktop.org/attachment.cgi?id=134977&action=edit
Difference between the result of gl_GlobalInvocationID and gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x;

The spec for ARB_compute_variable_group_size in this file
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_compute_variable_group_size.txt
state that gl_GlobalInvocationID = gl_WorkGroupID * gl_LocalGroupSizeARB + gl_LocalInvocationID; but on my computer, arch linux with Radeon RX 580 Series (AMD POLARIS10 / DRM 3.18.0 / 4.13.
7-1-ARCH, LLVM 5.0.0) : mesa version 17.2.2, gl_GlobalInvocationID = gl_LocalInvocationID ; only. If I replace uint i = gl_GlobalInvocation.x with uint i = gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x the output of the compute shader work as expected.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#1 lore raw

[Bug 103393] glDispatchComputeGroupSizeARB : gl_GlobalInvocationID.x != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

https://bugs.freedesktop.org/show_bug.cgi?id=103393

Stephane Chevigny <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

            Summary|glDispatchComputeGroupSizeA |glDispatchComputeGroupSizeA
                   |RB : gl_GlobalInvocationID  |RB :
                   |!= gl_WorkGroupID.x *       |gl_GlobalInvocationID.x !=
                   |gl_LocalGroupSizeARB.x +    |gl_WorkGroupID.x *
                   |gl_LocalInvocationID.x      |gl_LocalGroupSizeARB.x +
                   |                            |gl_LocalInvocationID.x
Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

[Bug 103393] glDispatchComputeGroupSizeARB : gl_GlobalInvocationID.x != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=103393

--- Comment #1 from Ilia Mirkin <[email protected]> ---
I wanted to test this out on nouveau -- I ran the program, and it created output. What's the expected output?

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

[Bug 103393] glDispatchComputeGroupSizeARB : gl_GlobalInvocationID.x != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=103393

--- Comment #2 from Stephane Chevigny <[email protected]> --- The expected output:
value[i].x (= gl_GlobalInvocationID.x ;) should be equal to value[i].y and value[i].w (= gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x;) for all indices i according to spec. With the parameter I gave to glDispatchComputeGroupSizeARB, the divergence of the result happen after the indice i = 63 on my computer. So value[i].x = value[i].z (=gl_LocalInvocationID.x;) instead.

So on my computer, gl_GlobalInvocationID.x appear to be only equal to gl_LocalInvocationID.x notgl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x or I misread the spec.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

[Bug 103393] glDispatchComputeGroupSizeARB : gl_GlobalInvocationID.x != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=103393

--- Comment #3 from Ilia Mirkin <[email protected]> ---
OK, I see. The relevant shader is fill_cs_450.glsl. It puts stuff into the array with values

(gl_GlobalInvocationID.x, t, gl_LocalInvocationID.x, t)

where t = gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

Ideally the values printed should be (x, x, l, x) -- i.e. t == gl_GlobalInvocationID.x.

With nouveau this outputs a bunch of BS... sometimes gl_GlobalInvocationID.x == gl_LocalInvocationID.x, other times gl_GlobalInvocationID.x == randomish value. I suspect this is a combination of a nouveau bug and a core bug [the latter of which is affecting the radeonsi output]. Going to try to take a look.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

[Bug 103393] glDispatchComputeGroupSizeARB : gl_GlobalInvocationID.x != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=103393

--- Comment #4 from Ilia Mirkin <[email protected]> ---
OK yeah, this is totally broken... for a simplified shader (which I will submit to piglit), this is generating code like

COMP
PROPERTY CS_FIXED_BLOCK_WIDTH 0
PROPERTY CS_FIXED_BLOCK_HEIGHT 0
PROPERTY CS_FIXED_BLOCK_DEPTH 0
DCL SV[0], THREAD_ID
DCL SV[1], BLOCK_ID
DCL SV[2], BLOCK_SIZE
DCL BUFFER[16]
DCL TEMP[0..3], LOCAL
IMM[0] UINT32 {8, 0, 0, 0}
0: UMAD TEMP[0].x, SV[1].xyzz, TEMP[1].xyzz, SV[0].xyzz 1: MOV TEMP[1].x, TEMP[0].xxxx
2: MOV TEMP[1].y, SV[0].xxxx
3: UMAD TEMP[2].x, SV[1].xxxx, SV[2].xxxx, SV[0].xxxx 4: UMUL TEMP[3].x, TEMP[2].xxxx, IMM[0].xxxx 5: STORE BUFFER[16].xy, TEMP[3].xxxx, TEMP[1].xyyy 6: END

Note the first op which tries to read the uninitialized TEMP[1].xyzz. Oops. Pretty sure this used to work, so probably got broken at some point with the various refactors.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

[Bug 103393] glDispatchComputeGroupSizeARB : gl_GlobalInvocationID.x != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=103393

--- Comment #5 from Stephane Chevigny <[email protected]> --- Thank you very much for checking that.

S.C.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

[Bug 103393] glDispatchComputeGroupSizeARB : gl_GlobalInvocationID.x != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=103393

--- Comment #6 from Ilia Mirkin <[email protected]> ---
https://patchwork.freedesktop.org/patch/184119/

This fixes both your application as well as a small piglit test I wrote on nouveau. The issue was in the core logic. If radeonsi still doesn't work with this, then it has additional issues.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

[Bug 103393] glDispatchComputeGroupSizeARB : gl_GlobalInvocationID.x != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=103393

--- Comment #7 from Ilia Mirkin <[email protected]> ---
An updated patch fixes the issue in a more complete way (with multiple shaders being linked together, even non-variable local sizes were broken). This is now upstream in

commit 4d24a7cb97641cacecd371d1968f6964785822e4

Author: Ilia Mirkin <[email protected]>
Date:   Sat Oct 21 15:15:41 2017 -0400

glsl: fix derived cs variables

Thanks for reporting and providing a repro! As the original issue was filed against radeonsi, I'm going to leave this open until someone can confirm that this does indeed fix the problem there.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw

[Bug 103393] glDispatchComputeGroupSizeARB : gl_GlobalInvocationID.x != gl_WorkGroupID.x * gl_LocalGroupSizeARB.x + gl_LocalInvocationID.x

In reply to [email protected]

https://bugs.freedesktop.org/show_bug.cgi?id=103393

Samuel Pitoiset <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #8 from Samuel Pitoiset <[email protected]> --- values[i].x == values[i].y == values[i].w for all indices i with radeonsi.

The issue appears to be fixed, thanks guys! Closing.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel