[Mesa-dev] [PATCH] r600g: fix range handling for tgsi input/output declarations
Vadim Girlin
vadimgirlin at gmail.com
Thu Mar 28 12:34:43 PDT 2013
On 03/28/2013 01:01 PM, � wrote:
> Am 27.03.2013 20:37, schrieb Vadim Girlin:
>> Signed-off-by: Vadim Girlin <vadimgirlin at gmail.com>
>> ---
>> src/gallium/drivers/r600/r600_shader.c | 19 +++++++++++++++----
>> 1 file changed, 15 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/gallium/drivers/r600/r600_shader.c
>> b/src/gallium/drivers/r600/r600_shader.c
>> index 29facf7..d4c9c03 100644
>> --- a/src/gallium/drivers/r600/r600_shader.c
>> +++ b/src/gallium/drivers/r600/r600_shader.c
>> @@ -874,12 +874,12 @@ static int select_twoside_color(struct
>> r600_shader_ctx *ctx, int front, int back
>> static int tgsi_declaration(struct r600_shader_ctx *ctx)
>> {
>> struct tgsi_full_declaration *d =
>> &ctx->parse.FullToken.FullDeclaration;
>> - unsigned i;
>> - int r;
>> + int r, i, j, count = d->Range.Last - d->Range.First + 1;
>> switch (d->Declaration.File) {
>> case TGSI_FILE_INPUT:
>> - i = ctx->shader->ninput++;
>> + i = ctx->shader->ninput;
>> + ctx->shader->ninput += count;
>> ctx->shader->input[i].name = d->Semantic.Name;
>> ctx->shader->input[i].sid = d->Semantic.Index;
>> ctx->shader->input[i].interpolate = d->Interp.Interpolate;
>> @@ -903,9 +903,15 @@ static int tgsi_declaration(struct
>> r600_shader_ctx *ctx)
>> return r;
>> }
>> }
>> + for (j = 1; j < count; ++j) {
>> + memcpy(&ctx->shader->input[i + j], &ctx->shader->input[i],
>> + sizeof(struct r600_shader_io));
>
> Instead of memcpy, shouldn't an assignment do the trick here as well?
Yes, assignment should work fine, I just used to use memcpy in such
cases for some reason. I'll replace memcpy with assignment.
Also I think second part (outputs handling) can be dropped for now -
currently we only need to handle the inputs (for HUD shaders), and later
when array declarations for inputs/outputs will be implemented in TGSI
probably we'll need to update the parser in r600g anyway - I'm just not
sure yet how the semantic indices should be handled for input/output arrays.
Vadim
>
>> + ctx->shader->input[i + j].gpr += j;
>> + }
>> break;
>> case TGSI_FILE_OUTPUT:
>> - i = ctx->shader->noutput++;
>> + i = ctx->shader->noutput;
>> + ctx->shader->noutput += count;
>> ctx->shader->output[i].name = d->Semantic.Name;
>> ctx->shader->output[i].sid = d->Semantic.Index;
>> ctx->shader->output[i].gpr =
>> ctx->file_offset[TGSI_FILE_OUTPUT] + d->Range.First;
>> @@ -933,6 +939,11 @@ static int tgsi_declaration(struct
>> r600_shader_ctx *ctx)
>> break;
>> }
>> }
>> + for (j = 1; j < count; ++j) {
>> + memcpy(&ctx->shader->output[i + j], &ctx->shader->output[i],
>> + sizeof(struct r600_shader_io));
>
> Same here.
>
>> + ctx->shader->output[i + j].gpr += j;
>> + }
>> break;
>> case TGSI_FILE_CONSTANT:
>> case TGSI_FILE_TEMPORARY:
>
> Christian.
More information about the mesa-dev
mailing list