Get rid of _mesa_vert_result_to_frag_attrib().
Now that there is no difference between the enums that represent vertex outputs and fragment inputs, there's no need for a conversion function. But we still need to be able to detect when a given vertex output has no corresponding fragment input. So it is replaced by a new function, _mesa_varying_slot_in_fs(), which tells whether the given varying slot exists as an FS input or not. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net> Tested-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
@@ -1265,16 +1265,14 @@ fs_visitor::calculate_urb_setup()
|
||||
continue;
|
||||
|
||||
if (c->key.vp_outputs_written & BITFIELD64_BIT(i)) {
|
||||
int fp_index = _mesa_vert_result_to_frag_attrib((gl_varying_slot) i);
|
||||
|
||||
/* The back color slot is skipped when the front color is
|
||||
* also written to. In addition, some slots can be
|
||||
* written in the vertex shader and not read in the
|
||||
* fragment shader. So the register number must always be
|
||||
* incremented, mapped or not.
|
||||
*/
|
||||
if (fp_index >= 0)
|
||||
urb_setup[fp_index] = urb_next;
|
||||
if (_mesa_varying_slot_in_fs((gl_varying_slot) i))
|
||||
urb_setup[i] = urb_next;
|
||||
urb_next++;
|
||||
}
|
||||
}
|
||||
@@ -3001,10 +2999,8 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||
key.proj_attrib_mask |= BITFIELD64_BIT(i);
|
||||
|
||||
if (intel->gen < 6) {
|
||||
int vp_index = _mesa_vert_result_to_frag_attrib((gl_varying_slot) i);
|
||||
|
||||
if (vp_index >= 0)
|
||||
key.vp_outputs_written |= BITFIELD64_BIT(vp_index);
|
||||
if (_mesa_varying_slot_in_fs((gl_varying_slot) i))
|
||||
key.vp_outputs_written |= BITFIELD64_BIT(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,17 +144,14 @@ static void calc_sizes( struct tracker *t )
|
||||
* which describes the fragment program input sizes.
|
||||
*/
|
||||
for (vertRes = 0; vertRes < VARYING_SLOT_MAX; vertRes++) {
|
||||
|
||||
/* map vertex program output index to fragment program input index */
|
||||
GLint fragAttrib = _mesa_vert_result_to_frag_attrib(vertRes);
|
||||
if (fragAttrib < 0)
|
||||
if (!_mesa_varying_slot_in_fs(vertRes))
|
||||
continue;
|
||||
|
||||
switch (get_output_size(t, vertRes)) {
|
||||
case 4: t->size_masks[4-1] |= BITFIELD64_BIT(fragAttrib);
|
||||
case 3: t->size_masks[3-1] |= BITFIELD64_BIT(fragAttrib);
|
||||
case 2: t->size_masks[2-1] |= BITFIELD64_BIT(fragAttrib);
|
||||
case 1: t->size_masks[1-1] |= BITFIELD64_BIT(fragAttrib);
|
||||
case 4: t->size_masks[4-1] |= BITFIELD64_BIT(vertRes);
|
||||
case 3: t->size_masks[3-1] |= BITFIELD64_BIT(vertRes);
|
||||
case 2: t->size_masks[2-1] |= BITFIELD64_BIT(vertRes);
|
||||
case 1: t->size_masks[1-1] |= BITFIELD64_BIT(vertRes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-21
@@ -217,7 +217,7 @@ typedef enum
|
||||
* When this enum is updated, the following code must be updated too:
|
||||
* - vertResults (in prog_print.c's arb_output_attrib_string())
|
||||
* - fragAttribs (in prog_print.c's arb_input_attrib_string())
|
||||
* - _mesa_vert_result_to_frag_attrib()
|
||||
* - _mesa_varying_slot_in_fs()
|
||||
* - _mesa_frag_attrib_to_vert_result()
|
||||
*/
|
||||
typedef enum
|
||||
@@ -288,8 +288,8 @@ typedef enum
|
||||
|
||||
/**
|
||||
* Indexes for fragment program input attributes. Note that
|
||||
* _mesa_vert_result_to_frag_attrib() and frag_attrib_to_vert_result() make
|
||||
* assumptions about the layout of this enum.
|
||||
* _mesa_frag_attrib_to_vert_result() makes assumptions about the layout of
|
||||
* this enum.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -315,26 +315,22 @@ typedef enum
|
||||
|
||||
|
||||
/**
|
||||
* Convert from a gl_varying_slot value for a vertex output to the
|
||||
* corresponding gl_frag_attrib.
|
||||
*
|
||||
* Varying output values which have no corresponding gl_frag_attrib
|
||||
* (VARYING_SLOT_PSIZ, VARYING_SLOT_BFC0, VARYING_SLOT_BFC1, and
|
||||
* VARYING_SLOT_EDGE) are converted to a value of -1.
|
||||
* Determine if the given gl_varying_slot appears in the fragment shader.
|
||||
*/
|
||||
static inline int
|
||||
_mesa_vert_result_to_frag_attrib(gl_varying_slot vert_result)
|
||||
static inline GLboolean
|
||||
_mesa_varying_slot_in_fs(gl_varying_slot slot)
|
||||
{
|
||||
if (vert_result <= VARYING_SLOT_TEX7)
|
||||
return vert_result;
|
||||
else if (vert_result < VARYING_SLOT_CLIP_DIST0)
|
||||
return -1;
|
||||
else if (vert_result <= VARYING_SLOT_CLIP_DIST1)
|
||||
return vert_result;
|
||||
else if (vert_result < VARYING_SLOT_VAR0)
|
||||
return -1;
|
||||
else
|
||||
return vert_result;
|
||||
switch (slot) {
|
||||
case VARYING_SLOT_PSIZ:
|
||||
case VARYING_SLOT_BFC0:
|
||||
case VARYING_SLOT_BFC1:
|
||||
case VARYING_SLOT_EDGE:
|
||||
case VARYING_SLOT_CLIP_VERTEX:
|
||||
case VARYING_SLOT_LAYER:
|
||||
return GL_FALSE;
|
||||
default:
|
||||
return GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user