[Piglit] [PATCH 0/1] Test for updating shared buffer

Fabian Bieler fabianbieler at fastmail.fm
Sun Jan 7 22:56:38 UTC 2018

On 2018-01-07 03:37, David McFarland wrote:
> This test is based on the glx shader sharing test. It currently fails for me on
> radeonsi.  The idea is:
> - create context A+B
> - make A current
>   - create buffer
>   - set buffer content to red
>   - bind buffer as uniform
>   - draw quad with uniform colour
> - make B current
>   - bind buffer as uniform
>   - draw quad with uniform colour
>   - set buffer content to green
>   - draw quad with uniform colour
> - make A current
>   - draw quad with uniform colour
>   ** this one ends up red
>   - set buffer content to blue
>   ** this results in the assert
>   - draw quad with uniform colour
> My mesa-dev post on the issue:
> https://lists.freedesktop.org/archives/mesa-dev/2017-December/180779.html
> This is what I'm using to work around it:
> https://github.com/corngood/mesa/commit/54174bbe6c58a28b1a64105944649bed78d65f17
> If you take that commit and run this test on radeonsi, the test should fail, but
> if you enable R600_DEBUG=disable_buffer_realloc, it should pass.
> Does anyone see a problem with how I'm expecting this to work?
I think you'll have to call glFinish (or some fence functions) after
altering a buffer and before switching the context to ensure the changes
are visible in the new context.

>From section D.3.1 of the GL 3.2 core spec:
"The object T is considered to have been changed once a command such as
described in section D.3 has completed. Completion of a command may be
determined either by calling Finish, or by calling FenceSync and
executing a WaitSync command on the associated sync object. The second
method does not require a round trip to the GL server and may be more
efficient, particularly when changes to T in one context must be known
to have completed before executing commands dependent on those changes
in another context."

Of course, even without the additional synchronization the test
shouldn't abort.
> If not, is this a suitable test for piglit?
I'd appreciate a comment at the top of the file describing the test.
E.g.: what you wrote above.

I also have some bike-shedding comments if you're into that sort of
thing 😉:

The "program" variable could be made local.
check_error could be replaced by piglit_check_gl_error(GL_NO_ERROR).
All functions except main could me made static.
Shader creation could be simplified with piglit_build_simple_program.
> David McFarland (1):
>   Add glx buffer sharing test.
>  tests/all.py                   |   1 +
>  tests/glx/CMakeLists.gl.txt    |   1 +
>  tests/glx/glx-buffer-sharing.c | 277 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 279 insertions(+)
>  create mode 100644 tests/glx/glx-buffer-sharing.c

More information about the Piglit mailing list