aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/barrier.c
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2016-07-05 23:18:18 -0700
committerFrancisco Jerez <[email protected]>2016-08-24 13:28:30 -0700
commit6a976bbf84c9c8790fa61bbeb5eb24a2e646c76c (patch)
tree5694814433c143737310b7c54f00b046b8580ab0 /src/mesa/main/barrier.c
parent83d2f9db2929781d7d4b182355c872a7cbbcaeec (diff)
mesa: Move shader memory barrier functions into barrier.c.
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main/barrier.c')
-rw-r--r--src/mesa/main/barrier.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/mesa/main/barrier.c b/src/mesa/main/barrier.c
index beb48fb77b5..7ae8fc6b0aa 100644
--- a/src/mesa/main/barrier.c
+++ b/src/mesa/main/barrier.c
@@ -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);
+ }
+}