diff options
author | Paul Berry <[email protected]> | 2011-08-23 10:41:31 -0700 |
---|---|---|
committer | Paul Berry <[email protected]> | 2011-09-06 11:04:15 -0700 |
commit | d1435a49e9765ab4e988dd8b65a5599da34f3512 (patch) | |
tree | 307d598ac52d4cc4381aa7aaf28b2e74e7d791d2 /src | |
parent | d9eca0b27903acef97f7b69a70dc791b433f1c98 (diff) |
i965: new VS: move clip distance computation (GEN5+) to a separate function.
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 35 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 8c613bd9572..01313ec192d 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -465,6 +465,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); int emit_vue_header_gen6(int header_mrf); int emit_vue_header_gen4(int header_mrf); 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 bd8878a1ebe..8cc52c1d181 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1789,6 +1789,24 @@ vec4_visitor::emit_psiz_and_flags(struct brw_reg reg) } } +void +vec4_visitor::emit_clip_distances(struct brw_reg reg, int offset) +{ + if (intel->gen < 6) { + /* Clip distance slots are set aside in gen5, but they are not used. It + * is not clear whether we actually need to set aside space for them, + * but the performance cost is negligible. + */ + return; + } + + for (int i = 0; i + offset < c->key.nr_userclip && i < 4; ++i) { + emit(DP4(dst_reg(brw_writemask(reg, 1 << i)), + src_reg(output_reg[VERT_RESULT_HPOS]), + src_reg(c->userplane[i + offset]))); + } +} + int vec4_visitor::emit_vue_header_gen4(int header_mrf) { @@ -1814,7 +1832,8 @@ vec4_visitor::emit_vue_header_gen4(int header_mrf) src_reg(output_reg[VERT_RESULT_HPOS]))); /* user clip distance. */ - header_mrf += 2; + emit_clip_distances(brw_message_reg(header_mrf++), 0); + emit_clip_distances(brw_message_reg(header_mrf++), 4); /* Pad so that vertex element data is aligned. */ header_mrf++; @@ -1858,18 +1877,8 @@ vec4_visitor::emit_vue_header_gen6(int header_mrf) current_annotation = "user clip distances"; if (c->key.nr_userclip) { - for (int i = 0; i < c->key.nr_userclip; i++) { - struct brw_reg m; - if (i < 4) - m = brw_message_reg(header_mrf); - else - m = brw_message_reg(header_mrf + 1); - - emit(DP4(dst_reg(brw_writemask(m, 1 << (i & 3))), - src_reg(output_reg[VERT_RESULT_HPOS]), - src_reg(c->userplane[i]))); - } - header_mrf += 2; + emit_clip_distances(brw_message_reg(header_mrf++), 0); + emit_clip_distances(brw_message_reg(header_mrf++), 4); } current_annotation = NULL; |