[Mesa-dev,06/17] mesa: Add blend barrier entry point and driver hook.

Submitted by Francisco Jerez on Aug. 13, 2016, 1:08 a.m.

Details

Message ID 871t1t5vc5.fsf@riseup.net
State New
Headers show
Series "Framebuffer fetch." ( rev: 11 ) in Mesa

Not browsing as part of any series.

Commit Message

Francisco Jerez Aug. 13, 2016, 1:08 a.m.
Kenneth Graunke <kenneth@whitecape.org> writes:

> On Wednesday, July 20, 2016 9:49:36 PM PDT Francisco Jerez wrote:
>> Both MESA_shader_framebuffer_fetch_non_coherent and the non-coherent
>> variant of KHR_blend_equation_advanced will use this driver hook to
>> request coherency between framebuffer reads and writes.  This
>> intentionally doesn't hook up glBlendBarrierMESA to the dispatch layer
>> since the extension isn't exposed to applications yet, see [1]
>> for more details.
>> 
>> [1] https://lists.freedesktop.org/archives/mesa-dev/2016-July/124028.html
>> ---
>>  src/mesa/main/barrier.c | 14 ++++++++++++++
>>  src/mesa/main/barrier.h |  3 +++
>>  src/mesa/main/dd.h      | 12 ++++++++++++
>>  3 files changed, 29 insertions(+)
>> 
>> diff --git a/src/mesa/main/barrier.c b/src/mesa/main/barrier.c
>> index 7ae8fc6..42a5e0f 100644
>> --- a/src/mesa/main/barrier.c
>> +++ b/src/mesa/main/barrier.c
>> @@ -108,3 +108,17 @@ _mesa_MemoryBarrierByRegion(GLbitfield barriers)
>>        ctx->Driver.MemoryBarrier(ctx, barriers);
>>     }
>>  }
>> +
>> +void GLAPIENTRY
>> +_mesa_BlendBarrierMESA(void)
>> +{
>> +   GET_CURRENT_CONTEXT(ctx);
>> +
>> +   if (!ctx->Extensions.MESA_shader_framebuffer_fetch_non_coherent) {
>> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>> +                  "glBlendBarrier(not supported)");
>> +      return;
>> +   }
>> +
>> +   ctx->Driver.BlendBarrier(ctx);
>> +}
>> diff --git a/src/mesa/main/barrier.h b/src/mesa/main/barrier.h
>> index 8eee583..21dce90 100644
>> --- a/src/mesa/main/barrier.h
>> +++ b/src/mesa/main/barrier.h
>> @@ -47,4 +47,7 @@ _mesa_MemoryBarrier(GLbitfield barriers);
>>  void GLAPIENTRY
>>  _mesa_MemoryBarrierByRegion(GLbitfield barriers);
>>  
>> +void GLAPIENTRY
>> +_mesa_BlendBarrierMESA(void);
>> +
>>  #endif /* BARRIER_H */
>> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
>> index 114cbd2..807cb2a 100644
>> --- a/src/mesa/main/dd.h
>> +++ b/src/mesa/main/dd.h
>> @@ -959,6 +959,18 @@ struct dd_function_table {
>>     /** @} */
>>  
>>     /**
>> +    * GL_MESA_shader_framebuffer_fetch_non_coherent rendering barrier.
>> +    *
>> +    * On return from this function any framebuffer contents written by
>> +    * previous draw commands are guaranteed to be visible from subsequent
>> +    * fragment shader invocations using the
>> +    * MESA_shader_framebuffer_fetch_non_coherent interface.
>> +    */
>> +   /** @{ */
>> +   void (*BlendBarrier)(struct gl_context *ctx);
>> +   /** @} */
>> +
>> +   /**
>>      * \name GL_ARB_compute_shader interface
>>      */
>>     /*@{*/
>> 
>
> Don't you need to add this to the glapi XML?  Otherwise, it probably
> won't actually be exposed.

Yeah, that was intentional, see the commit message ;).  I split the
glapi changes into a separate commit because glBlendBarrier is still not
exposed through any externally visible extension.  We can probably hook
it up as soon as either KHR_blend_equation_advanced or
MESA_shader_framebuffer_fetch_non_coherent lands, whichever comes first.

Here's the other half of this commit I was intending to send together
with the remaining core changes to expose the MESA FB fetch extensions,
for the case it's useful to you.

Patch hide | download patch | download mbox

From 2a61df15e1ed4410ea60903ffc05104046111e70 Mon Sep 17 00:00:00 2001
From: Francisco Jerez <currojerez@riseup.net>
Date: Tue, 5 Jul 2016 21:26:37 -0700
Subject: [PATCH] glapi: Hook up glBlendBarrierMESA to the dispatch generation
 logic.

---
 src/mapi/glapi/gen/apiexec.py           | 3 +++
 src/mapi/glapi/gen/gl_API.xml           | 4 ++++
 src/mesa/main/tests/dispatch_sanity.cpp | 6 ++++++
 3 files changed, 13 insertions(+)

diff --git a/src/mapi/glapi/gen/apiexec.py b/src/mapi/glapi/gen/apiexec.py
index b4f4cf6..e028613 100644
--- a/src/mapi/glapi/gen/apiexec.py
+++ b/src/mapi/glapi/gen/apiexec.py
@@ -252,4 +252,7 @@  functions = {
     "GetQueryBufferObjectuiv": exec_info(core=31),
     "GetQueryBufferObjecti64v": exec_info(core=31),
     "GetQueryBufferObjectui64v": exec_info(core=31),
+
+    # GL_MESA_shader_framebuffer_fetch_non_coherent
+    "BlendBarrierMESA": exec_info(compatibility=20, core=31, es2=20),
 }
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 79e1ba1..e41f399 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -12921,6 +12921,10 @@ 
     </function>
 </category>
 
+<category name="GL_MESA_shader_framebuffer_fetch_non_coherent" number="999">  <!-- XXX - Get real extension number -->
+    <function name="BlendBarrierMESA"/>  <!-- XXX - alias="BlendBarrier" -->
+</category>
+
 <xi:include href="OES_EGL_image.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
 <xi:include href="EXT_texture_integer.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index ee3c3d4a..64026b0 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -955,6 +955,9 @@  const struct function common_desktop_functions_possible[] = {
    /* GL_EXT_window_rectangles */
    { "glWindowRectanglesEXT", 30, -1 },
 
+   /* GL_MESA_shader_framebuffer_blend_non_coherent */
+   { "glBlendBarrierMESA", 20, -1 },
+
    { NULL, 0, -1 }
 };
 
@@ -2322,6 +2325,9 @@  const struct function gles2_functions_possible[] = {
    { "glGetnUniformivKHR", 20, -1 },
    { "glGetnUniformuivKHR", 20, -1 },
 
+   /* GL_MESA_shader_framebuffer_blend_non_coherent */
+   { "glBlendBarrierMESA", 20, -1 },
+
    { NULL, 0, -1 }
 };
 
-- 
2.9.0