On Tue, Jan 6, 2015 at 8:54 AM, Jose Fonseca <jfons...@vmware.com> wrote: > Do we really need a new pipe_context::set_counter_buffer method? Shouldn't > this case be covered by pipe_context::set_shader_resources ?
FWIW this is the approach I've taken in https://github.com/imirkin/mesa/commits/atomic I've mentioned this several times to Aditya, however he has been less-than-receptive in basing his work on mine. > > If we really need new method, I'd like we have better names for them, so we > can clearly distinguish them. > > IIUC GL_ARB_shader_atomic_counters correctly, this roughly matches D3D11s > "unordered access views" [1], though D3D11's UAVs can by typed [2], or raw > [3]. > > Also, are counter buffers in user memory really supported? I can't spot any > mention of that in GL_ARB_shader_atomic_counters. > > I think that rather than mimicking pipe_constant_buffer, this feature should > more closely to sampler views. > > > I confess I'm not familiar with counter buffers / UAVs, but I think this > needs a bit more thought to avoid being completely redone in the medium > term. > > > Jose > > > [1] > http://msdn.microsoft.com/en-gb/library/windows/desktop/ff476335.aspx#Unordered_Access > [2] http://msdn.microsoft.com/en-gb/library/windows/desktop/ff476258.aspx > [3] > http://msdn.microsoft.com/en-gb/library/windows/desktop/ff476900.aspx#Raw_Buffer_Views > > > On 04/01/15 21:44, adityaatluri wrote: >> >> --- >> 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 >> > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev