[Mesa-dev] [PATCH] r600g: fix range handling for tgsi input/output declarations

Christian König deathsimple at vodafone.de
Thu Mar 28 02:01:50 PDT 2013


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?

> +			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