diff options
author | Marek Olšák <[email protected]> | 2016-01-02 23:08:27 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-01-08 20:06:23 +0100 |
commit | 24737f2298619844685e7deceaeb8dbfc2165ee3 (patch) | |
tree | f2998914715aca7474127cef7c21cc8b24fdd41d /src/mesa/program/programopt.c | |
parent | 4191c1a57c1e806a078bfc5b074b557ff2b54c35 (diff) |
program: add a helper for rewriting FP position input to sysval
Reviewed-by: Edward O'Callaghan <[email protected]
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/program/programopt.c')
-rw-r--r-- | src/mesa/program/programopt.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c index af78150d594..24dde57725e 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; + + 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; + } + } + } +} |