i965: Set up clip distance VUE slots appropriately for gl_ClipDistance.

When gl_ClipDistance is in use, the contents of the gl_ClipDistance
array just need to be copied directly into the clip distance VUE
slots, so we re-use the code that copies all other generic VUE slots
(this has been extracted to its own method).  When gl_ClipDistance is
not in use, the vertex shader needs to calculate the clip distances
based on user-specified clipping planes.

This patch also removes the i965-specific enum values
BRW_VERT_RESULT_CLIP[01], since we now have generic Mesa enums that
serve the same purpose (VERT_RESULT_CLIP_DIST[01]).

Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Paul Berry 2011-09-02 12:36:09 -07:00
parent d9cb683f81
commit 62bad54727
4 changed files with 32 additions and 27 deletions

View file

@ -290,8 +290,6 @@ typedef enum
{
BRW_VERT_RESULT_NDC = VERT_RESULT_MAX,
BRW_VERT_RESULT_HPOS_DUPLICATE,
BRW_VERT_RESULT_CLIP0,
BRW_VERT_RESULT_CLIP1,
BRW_VERT_RESULT_PAD,
BRW_VERT_RESULT_MAX
} brw_vert_result;

View file

@ -486,6 +486,7 @@ public:
void emit_ndc_computation();
void emit_psiz_and_flags(struct brw_reg reg);
void emit_clip_distances(struct brw_reg reg, int offset);
void emit_generic_urb_slot(dst_reg reg, int vert_result);
void emit_urb_slot(int mrf, int vert_result);
void emit_urb_writes(void);

View file

@ -1829,6 +1829,23 @@ vec4_visitor::emit_clip_distances(struct brw_reg reg, int offset)
}
}
void
vec4_visitor::emit_generic_urb_slot(dst_reg reg, int vert_result)
{
assert (vert_result < VERT_RESULT_MAX);
current_annotation = output_reg_annotation[vert_result];
/* Copy the register, saturating if necessary */
vec4_instruction *inst = emit(MOV(reg,
src_reg(output_reg[vert_result])));
if ((vert_result == VERT_RESULT_COL0 ||
vert_result == VERT_RESULT_COL1 ||
vert_result == VERT_RESULT_BFC0 ||
vert_result == VERT_RESULT_BFC1) &&
c->key.clamp_vertex_color) {
inst->saturate = true;
}
}
void
vec4_visitor::emit_urb_slot(int mrf, int vert_result)
{
@ -1851,31 +1868,20 @@ vec4_visitor::emit_urb_slot(int mrf, int vert_result)
current_annotation = "gl_Position";
emit(MOV(reg, src_reg(output_reg[VERT_RESULT_HPOS])));
break;
case BRW_VERT_RESULT_CLIP0:
current_annotation = "user clip distances";
emit_clip_distances(hw_reg, 0);
break;
case BRW_VERT_RESULT_CLIP1:
current_annotation = "user clip distances";
emit_clip_distances(hw_reg, 4);
case VERT_RESULT_CLIP_DIST0:
case VERT_RESULT_CLIP_DIST1:
if (this->c->key.uses_clip_distance) {
emit_generic_urb_slot(reg, vert_result);
} else {
current_annotation = "user clip distances";
emit_clip_distances(hw_reg, (vert_result - VERT_RESULT_CLIP_DIST0) * 4);
}
break;
case BRW_VERT_RESULT_PAD:
/* No need to write to this slot */
break;
default: {
assert (vert_result < VERT_RESULT_MAX);
current_annotation = output_reg_annotation[vert_result];
/* Copy the register, saturating if necessary */
vec4_instruction *inst = emit(MOV(reg,
src_reg(output_reg[vert_result])));
if ((vert_result == VERT_RESULT_COL0 ||
vert_result == VERT_RESULT_COL1 ||
vert_result == VERT_RESULT_BFC0 ||
vert_result == VERT_RESULT_BFC1) &&
c->key.clamp_vertex_color) {
inst->saturate = true;
}
}
default:
emit_generic_urb_slot(reg, vert_result);
break;
}
}

View file

@ -96,8 +96,8 @@ brw_compute_vue_map(struct brw_vue_map *vue_map,
assign_vue_slot(vue_map, VERT_RESULT_PSIZ);
assign_vue_slot(vue_map, BRW_VERT_RESULT_NDC);
assign_vue_slot(vue_map, BRW_VERT_RESULT_HPOS_DUPLICATE);
assign_vue_slot(vue_map, BRW_VERT_RESULT_CLIP0);
assign_vue_slot(vue_map, BRW_VERT_RESULT_CLIP1);
assign_vue_slot(vue_map, VERT_RESULT_CLIP_DIST0);
assign_vue_slot(vue_map, VERT_RESULT_CLIP_DIST1);
assign_vue_slot(vue_map, BRW_VERT_RESULT_PAD);
assign_vue_slot(vue_map, VERT_RESULT_HPOS);
break;
@ -113,8 +113,8 @@ brw_compute_vue_map(struct brw_vue_map *vue_map,
assign_vue_slot(vue_map, VERT_RESULT_PSIZ);
assign_vue_slot(vue_map, VERT_RESULT_HPOS);
if (nr_userclip) {
assign_vue_slot(vue_map, BRW_VERT_RESULT_CLIP0);
assign_vue_slot(vue_map, BRW_VERT_RESULT_CLIP1);
assign_vue_slot(vue_map, VERT_RESULT_CLIP_DIST0);
assign_vue_slot(vue_map, VERT_RESULT_CLIP_DIST1);
}
/* front and back colors need to be consecutive so that we can use
* ATTRIBUTE_SWIZZLE_INPUTATTR_FACING to swizzle them when doing