Bug 94116 - program interface queries not returning right data for UBO / GL_BLOCK_INDEX
Summary: program interface queries not returning right data for UBO / GL_BLOCK_INDEX
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Kenneth Graunke
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: i965-deqp
  Show dependency treegraph
 
Reported: 2016-02-12 15:59 UTC by Ilia Mirkin
Modified: 2019-03-14 08:40 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Test results for dEQP-GLES31.functional.program_interface_query.uniform.block_index.* (7.93 KB, text/plain)
2016-02-12 15:59 UTC, Ilia Mirkin
Details
Partial fix (793 bytes, patch)
2016-02-13 06:41 UTC, Timothy Arceri
Details | Splinter Review

Description Ilia Mirkin 2016-02-12 15:59:37 UTC
Created attachment 121715 [details]
Test results for dEQP-GLES31.functional.program_interface_query.uniform.block_index.*

Not 100% sure that my diagnosis is correct, but it seems that there's some disagreement between the GL_BLOCK_INDEX being returned by glGetProgramResourceiv and the resource index accepted by glGetProgramResourceName.

Note the output of these dEQP tests:

MESA_GLES_VERSION_OVERRIDE=3.1 ./deqp-gles31 --deqp-visibility=hidden --deqp-case='dEQP-GLES31.functional.program_interface_query.uniform.block_index.*'
dEQP Core git-0c2b7cdc3a0455e0486f88574021d3ccd22f28a8 (0x0c2b7cdc) starting..
  target implementation = 'X11 EGL/GLX'

Test case 'dEQP-GLES31.functional.program_interface_query.uniform.block_index.default_block'..
Compute shader compile time = 2.354000 ms
Link time = 0.581000 ms
Test case duration in microseconds = 6153 us
  Pass (Pass)

Test case 'dEQP-GLES31.functional.program_interface_query.uniform.block_index.named_block'..
Compute shader compile time = 0.319000 ms
Link time = 0.522000 ms
Mesa: User error: GL_INVALID_VALUE in glGetProgramResourceName(index 1)
Test case duration in microseconds = 2495 us
  Fail (query block name: glGetError() returned GL_INVALID_VALUE at es31fProgramInterfaceQueryTestCase.cpp:609)

Test case 'dEQP-GLES31.functional.program_interface_query.uniform.block_index.unnamed_block'..
Compute shader compile time = 0.291000 ms
Link time = 0.526000 ms
Mesa: User error: GL_INVALID_VALUE in glGetProgramResourceName(index 1)
Test case duration in microseconds = 2408 us
  Fail (query block name: glGetError() returned GL_INVALID_VALUE at es31fProgramInterfaceQueryTestCase.cpp:609)

Test case 'dEQP-GLES31.functional.program_interface_query.uniform.block_index.block_array'..
Compute shader compile time = 0.398000 ms
Link time = 1.887000 ms
Test case duration in microseconds = 3985 us
  Fail (resource block index invalid)

DONE!

Now the difference between the default_block one and the others is that the others have a layout(binding=0). For default block, it returns GL_BLOCK_INDEX: -1, and it's all happy about that. I would sort of have assumed that for the others, the block index should be 0, but I'm not 100% sure. When it goes to use this block index as an argument to glGetProgramResouceName it errors out for the first 2, and for the last one it gets:

  <Text>Block name with index 1 is &quot;TargetInterface[1]&quot;</Text>
  <Text>        Error, expected TargetInterface[0]</Text>

So I suspect there's an off-by-one somewhere. Attaching the test result output from dEQP which includes the shaders.
Comment 1 Timothy Arceri 2016-02-13 06:41:35 UTC
Created attachment 121732 [details] [review]
Partial fix

This is a partial fix although I wonder if it needs to apply to SSBO too.

The problem is we are trying to match the program resource index not the block index.
Comment 2 Kenneth Graunke 2016-03-30 07:34:56 UTC
I'm working on a fix for this.
Comment 3 Timothy Arceri 2016-04-03 00:02:44 UTC
Fixed by:

commit	0fbd073dc284f952ea7df691941a65ddc89b7554

glsl: store ubo or ssbo index in block index

Previously we store the buffer block index i.e the index of a combined
ubo/ssbo list.

Fixes several dEQP-GLES31.functional tests:
- program_interface_query.uniform.block_index.block_array
- program_interface_query.uniform.block_index.named_block
- program_interface_query.uniform.block_index.unnamed_block
- program_interface_query.uniform.random.10
- program_interface_query.uniform.random.15
- program_interface_query.uniform.random.22
- program_interface_query.uniform.random.24
- program_interface_query.uniform.random.26
- program_interface_query.uniform.random.28
- program_interface_query.uniform.random.3
- program_interface_query.uniform.random.31
- program_interface_query.uniform.random.38
- program_interface_query.uniform.random.5

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94116
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.