[Mesa-dev] [PATCH 03/10] radeonsi: generalize si_set_constant_buffer
Marek Olšák
maraeo at gmail.com
Thu Apr 21 23:09:29 UTC 2016
On Thu, Apr 21, 2016 at 8:11 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> On 20.04.2016 10:47, Marek Olšák wrote:
>>
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> this will be used in the next commit
>> ---
>> src/gallium/drivers/radeonsi/si_descriptors.c | 27
>> +++++++++++++++++----------
>> 1 file changed, 17 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c
>> b/src/gallium/drivers/radeonsi/si_descriptors.c
>> index c802b1e..b8f74f4 100644
>> --- a/src/gallium/drivers/radeonsi/si_descriptors.c
>> +++ b/src/gallium/drivers/radeonsi/si_descriptors.c
>> @@ -775,15 +775,10 @@ void si_upload_const_buffer(struct si_context *sctx,
>> struct r600_resource **rbuf
>> util_memcpy_cpu_to_le32(tmp, ptr, size);
>> }
>>
>> -static void si_set_constant_buffer(struct pipe_context *ctx, uint shader,
>> uint slot,
>> - struct pipe_constant_buffer *input)
>> +static void si_set_constant_buffer(struct si_context *sctx,
>> + struct si_buffer_resources *buffers,
>> + uint slot, struct pipe_constant_buffer
>> *input)
>> {
>> - struct si_context *sctx = (struct si_context *)ctx;
>> - struct si_buffer_resources *buffers =
>> &sctx->const_buffers[shader];
>> -
>> - if (shader >= SI_NUM_SHADERS)
>> - return;
>> -
>> assert(slot < buffers->desc.num_elements);
>> pipe_resource_reference(&buffers->buffers[slot], NULL);
>>
>> @@ -806,7 +801,7 @@ static void si_set_constant_buffer(struct pipe_context
>> *ctx, uint shader, uint s
>> input->buffer_size,
>> &buffer_offset);
>> if (!buffer) {
>> /* Just unbind on failure. */
>> - si_set_constant_buffer(ctx, shader, slot,
>> NULL);
>> + si_set_constant_buffer(sctx, buffers,
>> slot, NULL);
>> return;
>> }
>> va = r600_resource(buffer)->gpu_address +
>> buffer_offset;
>> @@ -842,6 +837,18 @@ static void si_set_constant_buffer(struct
>> pipe_context *ctx, uint shader, uint s
>> buffers->desc.dirty_mask |= 1llu << slot;
>> }
>>
>> +static void si_pipe_set_constant_buffer(struct pipe_context *ctx,
>> + uint shader, uint slot,
>> + struct pipe_constant_buffer
>> *input)
>> +{
>> + struct si_context *sctx = (struct si_context *)ctx;
>> +
>> + if (shader >= SI_NUM_SHADERS)
>> + return;
>
>
> I know you just moved the check, but couldn't/shouldn't that be an
> assert(shader < SI_NUM_SHADERS) instead?
I don't think it matters much. An assertion helps discover bugs during
development. An IF statement is a strong guarantee that it can't
happen to users.
Marek
More information about the mesa-dev
mailing list