diff options
author | Paul Berry <[email protected]> | 2011-09-02 12:36:09 -0700 |
---|---|---|
committer | Paul Berry <[email protected]> | 2011-09-23 15:32:39 -0700 |
commit | 62bad54727690bff5ed42a74272e7822fd36cdb6 (patch) | |
tree | bac40490f6fcfdc128d67572a81eda17a0afd485 /src/mesa/drivers/dri | |
parent | d9cb683f81b5daefda2f8599b4ba0365cc6f009a (diff) |
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 <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 48 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs.c | 8 |
4 files changed, 32 insertions, 27 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 6772029e33c..d32eded90d1 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -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; diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 19190a71e90..876a6917201 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -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); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 61c226a8395..a32451fa2fe 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1830,6 +1830,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) { struct brw_reg hw_reg = brw_message_reg(mrf); @@ -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; } } diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index fdccd9410b4..93c68381380 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -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 |