gallium: add texture barrier support to the interface and st/mesa (v2)
authorMarek Olšák <maraeo@gmail.com>
Tue, 8 Mar 2011 10:32:35 +0000 (11:32 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 15 Mar 2011 14:58:12 +0000 (15:58 +0100)
v2: change the gallium entry point to texture_barrier.

src/gallium/docs/source/context.rst
src/gallium/include/pipe/p_context.h
src/mesa/SConscript
src/mesa/sources.mak
src/mesa/state_tracker/st_cb_texturebarrier.c [new file with mode: 0644]
src/mesa/state_tracker/st_cb_texturebarrier.h [new file with mode: 0644]
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_extensions.c

index c6812cd309e31be4857307808d77d007093ba452..b0229c70f20ce24ebbd367523c7a94407c0b6a2d 100644 (file)
@@ -408,6 +408,16 @@ The width0 is redefined to ``MAX2(width0, offset+size)``.
 
 
 
+.. _texture_barrier
+
+texture_barrier
+%%%%%%%%%%%%%%%
+
+This function flushes all pending writes to the currently-set surfaces and
+invalidates all read caches of the currently-set samplers.
+
+
+
 .. _pipe_transfer:
 
 PIPE_TRANSFER
index 211f99f7cef66410cf8726c6c7063c8e871f7e61..d8de3bac0ecd85772b2f80186ad4c88a7abaf491 100644 (file)
@@ -390,6 +390,11 @@ struct pipe_context {
                                 struct pipe_resource *,
                                 unsigned offset,
                                 unsigned size);
+
+   /**
+    * Flush any pending framebuffer writes and invalidate texture caches.
+    */
+   void (*texture_barrier)(struct pipe_context *);
 };
 
 
index dc9090fb735f92fbabb76e1bc6586a431100ee31..63954da9e2097d3d77b98dc967971ff5d4a0b205 100644 (file)
@@ -201,6 +201,7 @@ statetracker_sources = [
     'state_tracker/st_cb_syncobj.c',
     'state_tracker/st_cb_strings.c',
     'state_tracker/st_cb_texture.c',
+    'state_tracker/st_cb_texturebarrier.c',
     'state_tracker/st_cb_viewport.c',
     'state_tracker/st_cb_xformfb.c',
     'state_tracker/st_context.c',
index 59782cbd05d2cd7191e821a8d7043f6ca686ee10..fcf8ab2e7945462ceeb5c0c2d34a94f7c4fdc31b 100644 (file)
@@ -221,6 +221,7 @@ STATETRACKER_SOURCES = \
        state_tracker/st_cb_syncobj.c \
        state_tracker/st_cb_strings.c \
        state_tracker/st_cb_texture.c \
+       state_tracker/st_cb_texturebarrier.c \
        state_tracker/st_cb_viewport.c \
        state_tracker/st_cb_xformfb.c \
        state_tracker/st_context.c \
diff --git a/src/mesa/state_tracker/st_cb_texturebarrier.c b/src/mesa/state_tracker/st_cb_texturebarrier.c
new file mode 100644 (file)
index 0000000..2f1a22b
--- /dev/null
@@ -0,0 +1,60 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Marek Olšák <maraeo@gmail.com>
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/**
+ * glTextureBarrierNV function
+ *
+ * \author Marek Olšák
+ */
+
+
+#include "main/imports.h"
+#include "main/context.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "st_context.h"
+#include "st_cb_texturebarrier.h"
+
+
+/**
+ * Called via ctx->Driver.TextureBarrier()
+ */
+static void
+st_TextureBarrier(struct gl_context *ctx)
+{
+   struct pipe_context *pipe = st_context(ctx)->pipe;
+
+   pipe->texture_barrier(pipe);
+}
+
+
+void st_init_texture_barrier_functions(struct dd_function_table *functions)
+{
+   functions->TextureBarrier = st_TextureBarrier;
+}
diff --git a/src/mesa/state_tracker/st_cb_texturebarrier.h b/src/mesa/state_tracker/st_cb_texturebarrier.h
new file mode 100644 (file)
index 0000000..3b7d377
--- /dev/null
@@ -0,0 +1,37 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Marek Olšák <maraeo@gmail.com>
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef ST_CB_TEXTUREBARRIER_H
+#define ST_CB_TEXTUREBARRIER_H
+
+
+struct dd_function_table;
+
+extern void st_init_texture_barrier_functions(struct dd_function_table *functions);
+
+
+#endif
index 60972e07de87a35d8cdcb03bb454c8a87b75044f..5a39ab0a110e678db37cf98d4f47737e845303e7 100644 (file)
@@ -53,6 +53,7 @@
 #include "st_cb_flush.h"
 #include "st_cb_syncobj.h"
 #include "st_cb_strings.h"
+#include "st_cb_texturebarrier.h"
 #include "st_cb_viewport.h"
 #include "st_atom.h"
 #include "st_draw.h"
@@ -288,6 +289,7 @@ void st_init_driver_functions(struct dd_function_table *functions)
    st_init_cond_render_functions(functions);
    st_init_readpixels_functions(functions);
    st_init_texture_functions(functions);
+   st_init_texture_barrier_functions(functions);
    st_init_flush_functions(functions);
    st_init_string_functions(functions);
    st_init_viewport_functions(functions);
index e34f90f41e16ba1a67309e983c08e42fe80b4897..bbcae3b02e9fc560675a22ea8275fa3675bdd645 100644 (file)
@@ -522,4 +522,8 @@ void st_init_extensions(struct st_context *st)
    if (screen->fence_finish) {
       ctx->Extensions.ARB_sync = GL_TRUE;
    }
+
+   if (st->pipe->texture_barrier) {
+      ctx->Extensions.NV_texture_barrier = GL_TRUE;
+   }
 }