mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 08:08:06 +02:00
r300/fragprog: Remove hardcoded FRAG_ATTRIB_xxx constants
Signed-off-by: Nicolai Hähnle <nhaehnle@gmail.com>
This commit is contained in:
parent
e034683eda
commit
790334883a
3 changed files with 61 additions and 46 deletions
|
|
@ -78,6 +78,12 @@ struct r300_fragment_program_compiler {
|
|||
GLboolean is_r500;
|
||||
unsigned OutputDepth;
|
||||
unsigned OutputColor;
|
||||
|
||||
void * UserData;
|
||||
void (*AllocateHwInputs)(
|
||||
void * yourdata,
|
||||
void (*allocate)(void * data, unsigned input, unsigned hwreg),
|
||||
void * mydata);
|
||||
};
|
||||
|
||||
void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c);
|
||||
|
|
|
|||
|
|
@ -427,51 +427,6 @@ static void scan_instructions(struct pair_state *s)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reserve hardware temporary registers for the program inputs.
|
||||
*
|
||||
* @note This allocation is performed explicitly, because the order of inputs
|
||||
* is determined by the RS hardware.
|
||||
*/
|
||||
static void allocate_input_registers(struct pair_state *s)
|
||||
{
|
||||
GLuint InputsRead = s->Compiler->Base.Program.InputsRead;
|
||||
int i;
|
||||
GLuint hwindex = 0;
|
||||
|
||||
/* Primary colour */
|
||||
if (InputsRead & FRAG_BIT_COL0)
|
||||
alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_COL0, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_COL0;
|
||||
|
||||
/* Secondary color */
|
||||
if (InputsRead & FRAG_BIT_COL1)
|
||||
alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_COL1, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_COL1;
|
||||
|
||||
/* Texcoords */
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (InputsRead & (FRAG_BIT_TEX0 << i))
|
||||
alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_TEX0+i, hwindex++);
|
||||
}
|
||||
InputsRead &= ~FRAG_BITS_TEX_ANY;
|
||||
|
||||
/* Fogcoords treated as a texcoord */
|
||||
if (InputsRead & FRAG_BIT_FOGC)
|
||||
alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_FOGC, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_FOGC;
|
||||
|
||||
/* fragment position treated as a texcoord */
|
||||
if (InputsRead & FRAG_BIT_WPOS)
|
||||
alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_WPOS, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_WPOS;
|
||||
|
||||
/* Anything else */
|
||||
if (InputsRead)
|
||||
error("Don't know how to handle inputs 0x%x\n", InputsRead);
|
||||
}
|
||||
|
||||
|
||||
static void decrement_dependencies(struct pair_state *s, struct pair_state_instruction *pairinst)
|
||||
{
|
||||
ASSERT(pairinst->NumDependencies > 0);
|
||||
|
|
@ -870,6 +825,12 @@ static void emit_alu(struct pair_state *s)
|
|||
s->Compiler->Base.Error = s->Compiler->Base.Error || !s->Handler->EmitPaired(s->UserData, &pair);
|
||||
}
|
||||
|
||||
/* Callback function for assigning input registers to hardware registers */
|
||||
static void alloc_helper(void * data, unsigned input, unsigned hwreg)
|
||||
{
|
||||
struct pair_state * s = data;
|
||||
alloc_hw_reg(s, PROGRAM_INPUT, input, hwreg);
|
||||
}
|
||||
|
||||
void radeonPairProgram(
|
||||
struct r300_fragment_program_compiler * compiler,
|
||||
|
|
@ -887,7 +848,7 @@ void radeonPairProgram(
|
|||
_mesa_printf("Emit paired program\n");
|
||||
|
||||
scan_instructions(&s);
|
||||
allocate_input_registers(&s);
|
||||
s.Compiler->AllocateHwInputs(s.Compiler->UserData, &alloc_helper, &s);
|
||||
|
||||
while(!s.Compiler->Base.Error &&
|
||||
(s.ReadyTEX || s.ReadyRGB || s.ReadyAlpha || s.ReadyFullALU)) {
|
||||
|
|
|
|||
|
|
@ -149,6 +149,52 @@ static void rewriteFog(struct r300_fragment_program_compiler *compiler)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reserve hardware temporary registers for the program inputs.
|
||||
*
|
||||
* @note This allocation is performed explicitly, because the order of inputs
|
||||
* is determined by the RS hardware.
|
||||
*/
|
||||
static void allocate_hw_inputs(void * yourdata, void (*allocate)(void * data, unsigned input, unsigned hwreg), void * mydata)
|
||||
{
|
||||
struct r300_fragment_program_compiler * c = yourdata;
|
||||
GLuint InputsRead = c->Base.Program.InputsRead;
|
||||
int i;
|
||||
GLuint hwindex = 0;
|
||||
|
||||
/* Primary colour */
|
||||
if (InputsRead & FRAG_BIT_COL0)
|
||||
allocate(mydata, FRAG_ATTRIB_COL0, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_COL0;
|
||||
|
||||
/* Secondary color */
|
||||
if (InputsRead & FRAG_BIT_COL1)
|
||||
allocate(mydata, FRAG_ATTRIB_COL1, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_COL1;
|
||||
|
||||
/* Texcoords */
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (InputsRead & (FRAG_BIT_TEX0 << i))
|
||||
allocate(mydata, FRAG_ATTRIB_TEX0+i, hwindex++);
|
||||
}
|
||||
InputsRead &= ~FRAG_BITS_TEX_ANY;
|
||||
|
||||
/* Fogcoords treated as a texcoord */
|
||||
if (InputsRead & FRAG_BIT_FOGC)
|
||||
allocate(mydata, FRAG_ATTRIB_FOGC, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_FOGC;
|
||||
|
||||
/* fragment position treated as a texcoord */
|
||||
if (InputsRead & FRAG_BIT_WPOS)
|
||||
allocate(mydata, FRAG_ATTRIB_WPOS, hwindex++);
|
||||
InputsRead &= ~FRAG_BIT_WPOS;
|
||||
|
||||
/* Anything else */
|
||||
if (InputsRead)
|
||||
rc_error(&c->Base, "Don't know how to handle inputs 0x%x\n", InputsRead);
|
||||
}
|
||||
|
||||
|
||||
static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_program_cont *cont, struct r300_fragment_program *fp)
|
||||
{
|
||||
r300ContextPtr r300 = R300_CONTEXT(ctx);
|
||||
|
|
@ -162,6 +208,8 @@ static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_prog
|
|||
compiler.is_r500 = (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) ? GL_TRUE : GL_FALSE;
|
||||
compiler.OutputDepth = FRAG_RESULT_DEPTH;
|
||||
compiler.OutputColor = FRAG_RESULT_COLOR;
|
||||
compiler.AllocateHwInputs = &allocate_hw_inputs;
|
||||
compiler.UserData = &compiler;
|
||||
|
||||
if (compiler.Base.Debug) {
|
||||
fflush(stdout);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue