[Mesa-dev] [PATCH 2/8] program: add a helper for rewriting FP position input to sysval
Ian Romanick
idr at freedesktop.org
Fri Jan 8 14:25:54 PST 2016
On 01/07/2016 05:29 PM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/mesa/program/programopt.c | 27 +++++++++++++++++++++++++++
> src/mesa/program/programopt.h | 2 ++
> 2 files changed, 29 insertions(+)
>
> diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c
> index af78150..24dde57 100644
> --- a/src/mesa/program/programopt.c
> +++ b/src/mesa/program/programopt.c
> @@ -589,3 +589,30 @@ _mesa_remove_output_reads(struct gl_program *prog, gl_register_file type)
> }
> }
> }
> +
> +void
> +_mesa_program_fragment_position_to_sysval(struct gl_program *prog)
> +{
> + GLuint i;
> +
> + if (prog->Target != GL_FRAGMENT_PROGRAM_ARB ||
> + !(prog->InputsRead & BITFIELD64_BIT(VARYING_SLOT_POS)))
> + return;
> +
> + prog->InputsRead &= ~BITFIELD64_BIT(VARYING_SLOT_POS);
> + prog->SystemValuesRead |= 1 << SYSTEM_VALUE_FRAG_COORD;
> +
> + for (i = 0; i < prog->NumInstructions; i++) {
> + struct prog_instruction *inst = prog->Instructions + i;
> + const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
> + GLuint j;
I'd make numSrc and j just be unsigned. With that, this patch is
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> +
> + for (j = 0; j < numSrc; j++) {
> + if (inst->SrcReg[j].File == PROGRAM_INPUT &&
> + inst->SrcReg[j].Index == VARYING_SLOT_POS) {
> + inst->SrcReg[j].File = PROGRAM_SYSTEM_VALUE;
> + inst->SrcReg[j].Index = SYSTEM_VALUE_FRAG_COORD;
> + }
> + }
> + }
> +}
> diff --git a/src/mesa/program/programopt.h b/src/mesa/program/programopt.h
> index 757421e..1520d16 100644
> --- a/src/mesa/program/programopt.h
> +++ b/src/mesa/program/programopt.h
> @@ -51,6 +51,8 @@ _mesa_count_texture_instructions(struct gl_program *prog);
> extern void
> _mesa_remove_output_reads(struct gl_program *prog, gl_register_file type);
>
> +extern void
> +_mesa_program_fragment_position_to_sysval(struct gl_program *prog);
>
> #ifdef __cplusplus
> }
>
More information about the mesa-dev
mailing list