[Mesa-dev] [PATCH] gallium/include/pipe: Added interface for atomic counter buffers in pipe

adityaatluri adityaavinash1 at gmail.com
Wed Nov 12 21:18:49 PST 2014


---
 src/gallium/include/pipe/p_context.h |  5 +++++
 src/gallium/include/pipe/p_defines.h |  7 ++++++-
 src/gallium/include/pipe/p_state.h   | 10 ++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index af5674f..bf3be31 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -44,6 +44,7 @@ struct pipe_blit_info;
 struct pipe_box;
 struct pipe_clip_state;
 struct pipe_constant_buffer;
+struct pipe_counter_buffer;
 struct pipe_depth_stencil_alpha_state;
 struct pipe_draw_info;
 struct pipe_fence_handle;
@@ -201,6 +202,10 @@ struct pipe_context {
                                 uint shader, uint index,
                                 struct pipe_constant_buffer *buf );
 
+   void (*set_counter_buffer)( struct pipe_context *,
+                               uint shader, uint index,
+                               struct pipe_counter_buffer *buf );
+
    void (*set_framebuffer_state)( struct pipe_context *,
                                   const struct pipe_framebuffer_state * );
 
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 8c4e415..717ab6a 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -341,6 +341,7 @@ enum pipe_flush_flags {
 #define PIPE_BIND_VERTEX_BUFFER        (1 << 4) /* set_vertex_buffers */
 #define PIPE_BIND_INDEX_BUFFER         (1 << 5) /* draw_elements */
 #define PIPE_BIND_CONSTANT_BUFFER      (1 << 6) /* set_constant_buffer */
+#define PIPE_BIND_COUNTER_BUFFER       (1 << 7) /* set_counter_buffer */
 #define PIPE_BIND_DISPLAY_TARGET       (1 << 8) /* flush_front_buffer */
 #define PIPE_BIND_TRANSFER_WRITE       (1 << 9) /* transfer_map */
 #define PIPE_BIND_TRANSFER_READ        (1 << 10) /* transfer_map */
@@ -572,6 +573,8 @@ enum pipe_cap {
    PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE = 109,
    PIPE_CAP_SAMPLER_VIEW_TARGET = 110,
    PIPE_CAP_CLIP_HALFZ = 111,
+   PIPE_CAP_USER_COUNTER_BUFFERS = 112,
+   PIPE_CAP_COUNTER_BUFFER_OFFSET_ALIGNMENT = 113,
 };
 
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
@@ -631,7 +634,9 @@ enum pipe_shader_cap
    PIPE_SHADER_CAP_PREFERRED_IR,
    PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED,
    PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS,
-   PIPE_SHADER_CAP_DOUBLES
+   PIPE_SHADER_CAP_DOUBLES,
+   PIPE_SHADER_CAP_MAX_COUNTER_BUFFER_SIZE,
+   PIPE_SHADER_CAP_MAX_COUNTER_BUFFERS
 };
 
 /**
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 43bc48b..49fae5d 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -57,6 +57,7 @@ extern "C" {
 #define PIPE_MAX_CLIP_PLANES       8
 #define PIPE_MAX_COLOR_BUFS        8
 #define PIPE_MAX_CONSTANT_BUFFERS 32
+#define PIPE_MAX_COUNTER_BUFFERS  32
 #define PIPE_MAX_SAMPLERS         16
 #define PIPE_MAX_SHADER_INPUTS    32
 #define PIPE_MAX_SHADER_OUTPUTS   48 /* 32 GENERICs + POS, PSIZE, FOG, etc. */
@@ -462,6 +463,15 @@ struct pipe_constant_buffer {
    const void *user_buffer;  /**< pointer to a user buffer if buffer == NULL */
 };
 
+/**
+ * A Counter buffer. A new buffer is set everytime a variable with
+ * atomic_uint is defined.
+ */
+struct pipe_counter_buffer{
+   struct pipe_resource *buffer; /**< The actual buffer */
+   unsigned buffer_offset; /**< The offset to start of data in buffer in bytes */
+   const void *user_buffer; /**< The buffer which is created by the compiler */
+};
 
 /**
  * A stream output target. The structure specifies the range vertices can
-- 
1.9.1



More information about the mesa-dev mailing list