[Mesa-dev] [PATCH v3] mesa: Implement glMemoryBarrierByRegion

Rob Clark robdclark at gmail.com
Mon Aug 24 11:35:50 PDT 2015


fwiw, issue seems to be due to picking up installed libglapi.so vs.
one in $MESA/lib (where I was pointing $LD_LIBRARY_PATH)..

So this shouldn't be an issue running installed mesa.  (Although I'm a
bit curious how it ended up using installed libglapi.so vs the one in
$LD_LIBRARY_PATH)

BR,
-R

On Mon, Aug 24, 2015 at 11:08 AM, Rob Clark <robdclark at gmail.com> wrote:
> ping?  It would be kinda nice to have gles working again.
>
> Fwiw, issue seems to be an off-by-one in the dispatch table, resulting
> in (for example) glCheckFramebufferStatus() ending up in
> _mesa_DeleteFramebuffers(), which ends badly..
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff6ec77e3 in _mesa_DeleteFramebuffers (n=36160,
> framebuffers=0x0) at main/fbobject.c:2581
> 2581          if (framebuffers[i] > 0) {
> (gdb) bt
> #0  0x00007ffff6ec77e3 in _mesa_DeleteFramebuffers (n=36160,
> framebuffers=0x0) at main/fbobject.c:2581
> #1  0x00007ffff659ec80 in glCheckFramebufferStatus (target=36160) at
> es2api/glapi_mapi_tmp.h:2629
> #2  0x000000000049f04d in retrace_glCheckFramebufferStatus (call=...)
> at /home/robclark/src/apitrace/build/retrace/glretrace_gl.cpp:26685
> #3  0x000000000040b854 in retrace::retraceCall
> (call=call at entry=0xacf900) at
> /home/robclark/src/apitrace/retrace/retrace_main.cpp:239
> #4  0x000000000040beca in runLeg (call=0xacf900, this=0xa68660) at
> /home/robclark/src/apitrace/retrace/retrace_main.cpp:399
> #5  runRace (this=0xa68660) at
> /home/robclark/src/apitrace/retrace/retrace_main.cpp:370
> #6  retrace::RelayRace::run (this=<optimized out>) at
> /home/robclark/src/apitrace/retrace/retrace_main.cpp:539
> #7  0x00000000004078cb in mainLoop () at
> /home/robclark/src/apitrace/retrace/retrace_main.cpp:599
> #8  main (argc=4, argv=0x7fffffffdfb8) at
> /home/robclark/src/apitrace/retrace/retrace_main.cpp:908
>
>
>
> BR,
> -R
>
>
> On Fri, Aug 21, 2015 at 5:41 PM, Rob Clark <robdclark at gmail.com> wrote:
>> so this one appears to break gles dispatch (on i965, but probably others)..
>>
>> Somehow glCheckFramebufferStatus() ends up in
>> _mesa_DeleteFramebuffers(), which doesn't go so well..  not sure I
>> understand the dispatch code to understand what the issue is.  But
>> could someone either fix it or revert this patch?
>>
>> BR,
>> -R
>>
>> On Fri, Aug 14, 2015 at 7:30 AM, Marta Lofstedt
>> <marta.lofstedt at linux.intel.com> wrote:
>>> From: Marta Lofstedt <marta.lofstedt at intel.com>
>>>
>>> The function glMemoryBarrierByRegion is part of
>>> OpenGL ES 3.1 and OpenGL 4.5 core and compatibility
>>> profiles.
>>>
>>> Signed-off-by: Marta Lofstedt <marta.lofstedt at intel.com>
>>> ---
>>>  src/mapi/glapi/gen/GL4x.xml             |  6 +++++
>>>  src/mesa/main/shaderimage.c             | 40 +++++++++++++++++++++++++++++++++
>>>  src/mesa/main/shaderimage.h             |  3 +++
>>>  src/mesa/main/tests/dispatch_sanity.cpp |  9 ++++++--
>>>  4 files changed, 56 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/mapi/glapi/gen/GL4x.xml b/src/mapi/glapi/gen/GL4x.xml
>>> index 94ddfb7..dee5027 100644
>>> --- a/src/mapi/glapi/gen/GL4x.xml
>>> +++ b/src/mapi/glapi/gen/GL4x.xml
>>> @@ -44,4 +44,10 @@
>>>    <enum name="DEPTH_STENCIL_TEXTURE_MODE"              value="0x90EA"/>
>>>  </category>
>>>
>>> +<category name="4.5">
>>> +  <function name="MemoryBarrierByRegion" es2="3.1">
>>> +    <param name="barriers" type="GLbitfield"/>
>>> +  </function>
>>> +</category>
>>> +
>>>  </OpenGLAPI>
>>> diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
>>> index a348cdb..7337f22 100644
>>> --- a/src/mesa/main/shaderimage.c
>>> +++ b/src/mesa/main/shaderimage.c
>>> @@ -653,3 +653,43 @@ _mesa_MemoryBarrier(GLbitfield barriers)
>>>     if (ctx->Driver.MemoryBarrier)
>>>        ctx->Driver.MemoryBarrier(ctx, barriers);
>>>  }
>>> +
>>> +void GLAPIENTRY
>>> +_mesa_MemoryBarrierByRegion(GLbitfield barriers)
>>> +{
>>> +   GET_CURRENT_CONTEXT(ctx);
>>> +
>>> +   GLbitfield all_allowed_bits = GL_ATOMIC_COUNTER_BARRIER_BIT |
>>> +                                 GL_FRAMEBUFFER_BARRIER_BIT |
>>> +                                 GL_SHADER_IMAGE_ACCESS_BARRIER_BIT |
>>> +                                 GL_SHADER_STORAGE_BARRIER_BIT |
>>> +                                 GL_TEXTURE_FETCH_BARRIER_BIT |
>>> +                                 GL_UNIFORM_BARRIER_BIT;
>>> +
>>> +   if (ctx->Driver.MemoryBarrier) {
>>> +      /* From section 7.11.2 of the OpenGL ES 3.1 specification:
>>> +       *
>>> +       *    "When barriers is ALL_BARRIER_BITS, shader memory accesses will be
>>> +       *     synchronized relative to all these barrier bits, but not to other
>>> +       *     barrier bits specific to MemoryBarrier."
>>> +       *
>>> +       * That is, if barriers is the special value GL_ALL_BARRIER_BITS, then all
>>> +       * barriers allowed by glMemoryBarrierByRegion should be activated."
>>> +       */
>>> +      if (barriers == GL_ALL_BARRIER_BITS)
>>> +         return ctx->Driver.MemoryBarrier(ctx, all_allowed_bits);
>>> +
>>> +      /* From section 7.11.2 of the OpenGL ES 3.1 specification:
>>> +       *
>>> +       *    "An INVALID_VALUE error is generated if barriers is not the special
>>> +       *     value ALL_BARRIER_BITS, and has any bits set other than those
>>> +       *     described above."
>>> +       */
>>> +      if ((barriers & ~all_allowed_bits) != 0) {
>>> +         _mesa_error(ctx, GL_INVALID_VALUE,
>>> +                     "glMemoryBarrierByRegion(unsupported barrier bit");
>>> +      }
>>> +
>>> +      ctx->Driver.MemoryBarrier(ctx, barriers);
>>> +   }
>>> +}
>>> diff --git a/src/mesa/main/shaderimage.h b/src/mesa/main/shaderimage.h
>>> index 33d8a1e..d08ece8 100644
>>> --- a/src/mesa/main/shaderimage.h
>>> +++ b/src/mesa/main/shaderimage.h
>>> @@ -68,6 +68,9 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures);
>>>  void GLAPIENTRY
>>>  _mesa_MemoryBarrier(GLbitfield barriers);
>>>
>>> +void GLAPIENTRY
>>> +_mesa_MemoryBarrierByRegion(GLbitfield barriers);
>>> +
>>>  #ifdef __cplusplus
>>>  }
>>>  #endif
>>> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
>>> index af89d2c..59107eb 100644
>>> --- a/src/mesa/main/tests/dispatch_sanity.cpp
>>> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
>>> @@ -851,6 +851,9 @@ const struct function common_desktop_functions_possible[] = {
>>>  // { "glTextureStorage2DMultisampleEXT", 43, -1 },      // XXX: Add to xml
>>>  // { "glTextureStorage3DMultisampleEXT", 43, -1 },      // XXX: Add to xml
>>>
>>> +/* GL 4.5 */
>>> +   { "glMemoryBarrierByRegion", 45, -1 },
>>> +
>>>     /* GL_ARB_internalformat_query */
>>>     { "glGetInternalformativ", 30, -1 },
>>>
>>> @@ -1739,6 +1742,9 @@ const struct function gl_core_functions_possible[] = {
>>>  // { "glTextureStorage2DMultisampleEXT", 43, -1 },      // XXX: Add to xml
>>>  // { "glTextureStorage3DMultisampleEXT", 43, -1 },      // XXX: Add to xml
>>>
>>> +/* GL 4.5 */
>>> +   { "glMemoryBarrierByRegion", 45, -1 },
>>> +
>>>     /* GL_ARB_direct_state_access */
>>>     { "glCreateTransformFeedbacks", 45, -1 },
>>>     { "glTransformFeedbackBufferBase", 45, -1 },
>>> @@ -2461,8 +2467,7 @@ const struct function gles31_functions_possible[] = {
>>>     { "glGetBooleani_v", 31, -1 },
>>>     { "glMemoryBarrier", 31, -1 },
>>>
>>> -   // FINISHME: This function has not been implemented yet.
>>> -   // { "glMemoryBarrierByRegion", 31, -1 },
>>> +   { "glMemoryBarrierByRegion", 31, -1 },
>>>
>>>     { "glTexStorage2DMultisample", 31, -1 },
>>>     { "glGetMultisamplefv", 31, -1 },
>>> --
>>> 1.9.1
>>>
>>> _______________________________________________
>>> mesa-dev mailing list
>>> mesa-dev at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list