[Mesa-dev] [PATCH 4/4] gallium: add interface for writable shader buffers

Marek Olšák maraeo at gmail.com
Fri Jul 10 07:51:17 PDT 2015


For Evergreen (the first DX11 radeon), which only supports 12 writable
resources, we'll only expose 8 images, 8 shader storage buffers and 8
atomic counter buffers. There will be a CAP saying that only a total
of 12 is allowed to be used by a shader and all bindings slots will
thus be considered virtual. The real binding will take place at draw
time when the shader and other states are known, and the shader will
determine the real slot locations.

I suppose there will be some difficulties while implementing DX11 on
top of gallium, but let's face it, DX11 is an old and limiting API, it
was released in 2009 and the first Vulkan(DX12)-capable radeon was
released in 2011 while OpenGL was picking up new features from both.

Marek


On Fri, Jul 10, 2015 at 3:04 PM, Roland Scheidegger <sroland at vmware.com> wrote:
> This looks all pretty reasonable, though I can't really figure out if we
> could translate from d3d11 to that. In particular, it's UAVs for all of
> buffers and images, and I'm not entirely sure if it's actually possible
> to figure out which UAV entries are a shader buffer and which ones are a
> shader image.
> But I don't really understand the documentation in that area, I
> certainly don't want to hold things up as I'm aware noone else is really
> interested in d3d compatibility, at the worst we can still fix that up
> somehow later.
>
> Roland
>
>
> Am 09.07.2015 um 23:46 schrieb Marek Olšák:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> ---
>>  src/gallium/include/pipe/p_context.h | 18 ++++++++++++++++++
>>  src/gallium/include/pipe/p_state.h   | 10 ++++++++++
>>  2 files changed, 28 insertions(+)
>>
>> diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
>> index 022ace5..b4512e7 100644
>> --- a/src/gallium/include/pipe/p_context.h
>> +++ b/src/gallium/include/pipe/p_context.h
>> @@ -58,6 +58,7 @@ struct pipe_resource;
>>  struct pipe_sampler_state;
>>  struct pipe_sampler_view;
>>  struct pipe_scissor_state;
>> +struct pipe_shader_buffer;
>>  struct pipe_shader_state;
>>  struct pipe_stencil_ref;
>>  struct pipe_stream_output_target;
>> @@ -237,6 +238,23 @@ struct pipe_context {
>>                            const float default_inner_level[2]);
>>
>>     /**
>> +    * Bind an array of shader buffers that will be used by a shader.
>> +    * Any buffers that were previously bound to the specified range
>> +    * will be unbound.
>> +    *
>> +    * \param shader     selects shader stage
>> +    * \param start_slot first buffer slot to bind.
>> +    * \param count      number of consecutive buffers to bind.
>> +    * \param buffers    array of pointers to the buffers to bind, it
>> +    *                   should contain at least \a count elements
>> +    *                   unless it's NULL, in which case no buffers will
>> +    *                   be bound.
>> +    */
>> +   void (*set_shader_buffers)(struct pipe_context *, unsigned shader,
>> +                              unsigned start_slot, unsigned count,
>> +                              struct pipe_shader_buffer *buffers);
>> +
>> +   /**
>>      * Bind an array of images that will be used by a shader.
>>      * Any images that were previously bound to the specified range
>>      * will be unbound.
>> diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
>> index f655dda..b269a23 100644
>> --- a/src/gallium/include/pipe/p_state.h
>> +++ b/src/gallium/include/pipe/p_state.h
>> @@ -490,6 +490,16 @@ struct pipe_constant_buffer {
>>
>>
>>  /**
>> + * An untyped shader buffer supporting loads, stores, and atomics.
>> + */
>> +struct pipe_shader_buffer {
>> +   struct pipe_resource *buffer; /**< the actual buffer */
>> +   unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */
>> +   unsigned buffer_size;   /**< how much data can be read in shader */
>> +};
>> +
>> +
>> +/**
>>   * A stream output target. The structure specifies the range vertices can
>>   * be written to.
>>   *
>>
>


More information about the mesa-dev mailing list