st/mesa: remove duplicate calculation of fp input mapping
This was being calculated the same way in two different places. Now just do it in st_translate_fragment_program().
This commit is contained in:
@@ -60,26 +60,10 @@ static void
|
|||||||
translate_fp(struct st_context *st,
|
translate_fp(struct st_context *st,
|
||||||
struct st_fragment_program *stfp)
|
struct st_fragment_program *stfp)
|
||||||
{
|
{
|
||||||
const GLbitfield fragInputsRead = stfp->Base.Base.InputsRead;
|
|
||||||
|
|
||||||
if (!stfp->state.tokens) {
|
if (!stfp->state.tokens) {
|
||||||
GLuint inAttr, numIn = 0;
|
|
||||||
|
|
||||||
for (inAttr = 0; inAttr < FRAG_ATTRIB_MAX; inAttr++) {
|
|
||||||
if (fragInputsRead & (1 << inAttr)) {
|
|
||||||
stfp->input_to_slot[inAttr] = numIn;
|
|
||||||
numIn++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stfp->input_to_slot[inAttr] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stfp->num_input_slots = numIn;
|
|
||||||
|
|
||||||
assert(stfp->Base.Base.NumInstructions > 0);
|
assert(stfp->Base.Base.NumInstructions > 0);
|
||||||
|
|
||||||
st_translate_fragment_program(st, stfp, stfp->input_to_slot);
|
st_translate_fragment_program(st, stfp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -221,7 +221,7 @@ combined_bitmap_fragment_program(GLcontext *ctx)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* translate to TGSI tokens */
|
/* translate to TGSI tokens */
|
||||||
st_translate_fragment_program(st, stfp->bitmap_program, NULL);
|
st_translate_fragment_program(st, stfp->bitmap_program);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stfp->bitmap_program;
|
return stfp->bitmap_program;
|
||||||
|
@@ -140,7 +140,7 @@ combined_drawpix_fragment_program(GLcontext *ctx)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* translate to TGSI tokens */
|
/* translate to TGSI tokens */
|
||||||
st_translate_fragment_program(st, stfp, NULL);
|
st_translate_fragment_program(st, stfp);
|
||||||
|
|
||||||
/* save new program, update serial numbers */
|
/* save new program, update serial numbers */
|
||||||
st->pixel_xfer.xfer_prog_sn = st->pixel_xfer.program->serialNo;
|
st->pixel_xfer.xfer_prog_sn = st->pixel_xfer.program->serialNo;
|
||||||
@@ -221,7 +221,7 @@ make_fragment_shader_z(struct st_context *st)
|
|||||||
p->SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
|
p->SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
|
||||||
|
|
||||||
st->drawpix.z_shader = (struct st_fragment_program *) p;
|
st->drawpix.z_shader = (struct st_fragment_program *) p;
|
||||||
st_translate_fragment_program(st, st->drawpix.z_shader, NULL);
|
st_translate_fragment_program(st, st->drawpix.z_shader);
|
||||||
|
|
||||||
return st->drawpix.z_shader;
|
return st->drawpix.z_shader;
|
||||||
}
|
}
|
||||||
|
@@ -269,18 +269,15 @@ fail:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a Mesa fragment shader into a TGSI shader.
|
* Translate a Mesa fragment shader into a TGSI shader.
|
||||||
* \param inputMapping to map fragment program input registers to TGSI
|
|
||||||
* input slots
|
|
||||||
* \return pointer to cached pipe_shader object.
|
* \return pointer to cached pipe_shader object.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
st_translate_fragment_program(struct st_context *st,
|
st_translate_fragment_program(struct st_context *st,
|
||||||
struct st_fragment_program *stfp,
|
struct st_fragment_program *stfp )
|
||||||
const GLuint inputMapping[])
|
|
||||||
{
|
{
|
||||||
struct pipe_context *pipe = st->pipe;
|
struct pipe_context *pipe = st->pipe;
|
||||||
GLuint outputMapping[FRAG_RESULT_MAX];
|
GLuint outputMapping[FRAG_RESULT_MAX];
|
||||||
GLuint defaultInputMapping[FRAG_ATTRIB_MAX];
|
GLuint inputMapping[FRAG_ATTRIB_MAX];
|
||||||
GLuint interpMode[16]; /* XXX size? */
|
GLuint interpMode[16]; /* XXX size? */
|
||||||
GLuint attr;
|
GLuint attr;
|
||||||
enum pipe_error error;
|
enum pipe_error error;
|
||||||
@@ -298,11 +295,9 @@ st_translate_fragment_program(struct st_context *st,
|
|||||||
*/
|
*/
|
||||||
for (attr = 0; attr < FRAG_ATTRIB_MAX; attr++) {
|
for (attr = 0; attr < FRAG_ATTRIB_MAX; attr++) {
|
||||||
if (inputsRead & (1 << attr)) {
|
if (inputsRead & (1 << attr)) {
|
||||||
const GLuint slot = fs_num_inputs;
|
const GLuint slot = fs_num_inputs++;
|
||||||
|
|
||||||
defaultInputMapping[attr] = slot;
|
inputMapping[attr] = slot;
|
||||||
|
|
||||||
fs_num_inputs++;
|
|
||||||
|
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case FRAG_ATTRIB_WPOS:
|
case FRAG_ATTRIB_WPOS:
|
||||||
@@ -367,6 +362,9 @@ st_translate_fragment_program(struct st_context *st,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
inputMapping[attr] = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -408,9 +406,6 @@ st_translate_fragment_program(struct st_context *st,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inputMapping)
|
|
||||||
inputMapping = defaultInputMapping;
|
|
||||||
|
|
||||||
ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
|
ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
|
||||||
if (ureg == NULL)
|
if (ureg == NULL)
|
||||||
return;
|
return;
|
||||||
|
@@ -52,9 +52,6 @@ struct st_fragment_program
|
|||||||
struct gl_fragment_program Base;
|
struct gl_fragment_program Base;
|
||||||
GLuint serialNo;
|
GLuint serialNo;
|
||||||
|
|
||||||
GLuint input_to_slot[FRAG_ATTRIB_MAX]; /**< Maps FRAG_ATTRIB_x to slot */
|
|
||||||
GLuint num_input_slots;
|
|
||||||
|
|
||||||
ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
|
ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
|
||||||
ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
|
ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
|
||||||
|
|
||||||
@@ -168,8 +165,7 @@ st_reference_fragprog(struct st_context *st,
|
|||||||
|
|
||||||
extern void
|
extern void
|
||||||
st_translate_fragment_program(struct st_context *st,
|
st_translate_fragment_program(struct st_context *st,
|
||||||
struct st_fragment_program *fp,
|
struct st_fragment_program *fp);
|
||||||
const GLuint inputMapping[]);
|
|
||||||
|
|
||||||
|
|
||||||
/* Called after program string change, discard all previous
|
/* Called after program string change, discard all previous
|
||||||
|
Reference in New Issue
Block a user