mesa: Move shader memory barrier functions into barrier.c.
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 6 Jul 2016 06:18:18 +0000 (23:18 -0700)
committerFrancisco Jerez <currojerez@riseup.net>
Wed, 24 Aug 2016 20:28:30 +0000 (13:28 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/barrier.c
src/mesa/main/barrier.h
src/mesa/main/shaderimage.c
src/mesa/main/shaderimage.h

index beb48fb77b5e47c5d043e11b1bd8aa1c4ba32dd2..7ae8fc6b0aac41162fe47d5b49cc8261103ffaf3 100644 (file)
@@ -57,3 +57,54 @@ _mesa_TextureBarrierNV(void)
 
    ctx->Driver.TextureBarrier(ctx);
 }
+
+void GLAPIENTRY
+_mesa_MemoryBarrier(GLbitfield barriers)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   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) {
+         ctx->Driver.MemoryBarrier(ctx, all_allowed_bits);
+         return;
+      }
+
+      /* 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);
+   }
+}
index 0652d14f3f005039b3af644ef13b309c83f7564e..8eee583c7ff5fe41b971ea3a519145e5f44e631d 100644 (file)
@@ -41,4 +41,10 @@ _mesa_init_barrier_functions(struct dd_function_table *driver);
 extern void GLAPIENTRY
 _mesa_TextureBarrierNV(void);
 
+void GLAPIENTRY
+_mesa_MemoryBarrier(GLbitfield barriers);
+
+void GLAPIENTRY
+_mesa_MemoryBarrierByRegion(GLbitfield barriers);
+
 #endif /* BARRIER_H */
index 90643c4ed6d8a6d96dd585d57a7174508e8ad7c8..db36e3bb1010da66d2c5348fb374b99d99243e35 100644 (file)
@@ -753,54 +753,3 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures)
 
    _mesa_end_texture_lookups(ctx);
 }
-
-void GLAPIENTRY
-_mesa_MemoryBarrier(GLbitfield barriers)
-{
-   GET_CURRENT_CONTEXT(ctx);
-
-   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) {
-         ctx->Driver.MemoryBarrier(ctx, all_allowed_bits);
-         return;
-      }
-
-      /* 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);
-   }
-}
index 85193e104f65166d24a19d5e35bc8d519e69f845..2cf0b0abc72750f4664317f3a8f66a5f85ac9140 100644 (file)
@@ -87,12 +87,6 @@ _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
 void GLAPIENTRY
 _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures);
 
-void GLAPIENTRY
-_mesa_MemoryBarrier(GLbitfield barriers);
-
-void GLAPIENTRY
-_mesa_MemoryBarrierByRegion(GLbitfield barriers);
-
 #ifdef __cplusplus
 }
 #endif