On 30 June 2012 11:50, Olivier Galibert <span dir="ltr"><<a href="mailto:galibert@pobox.com" target="_blank">galibert@pobox.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
At that point, all interpolation piglit tests involving fixed clipping<br>
work as long as there's no noperspective.<br>
<br>
Signed-off-by: Olivier Galibert <<a href="mailto:galibert@pobox.com">galibert@pobox.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_clip.c | 10 ++++-<br>
src/mesa/drivers/dri/i965/brw_clip.h | 6 +--<br>
src/mesa/drivers/dri/i965/brw_clip_line.c | 6 +--<br>
src/mesa/drivers/dri/i965/brw_clip_tri.c | 20 ++++-----<br>
src/mesa/drivers/dri/i965/brw_clip_unfilled.c | 2 +-<br>
src/mesa/drivers/dri/i965/brw_clip_util.c | 56 +++++++------------------<br>
6 files changed, 41 insertions(+), 59 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c<br>
index 52e8c47..952eb4a 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip.c<br>
@@ -215,7 +215,7 @@ brw_upload_clip_prog(struct brw_context *brw)<br>
struct intel_context *intel = &brw->intel;<br>
struct gl_context *ctx = &intel->ctx;<br>
struct brw_clip_prog_key key;<br>
-<br>
+ int i;<br>
memset(&key, 0, sizeof(key));<br>
<br>
brw_lookup_interpolation(brw);<br>
@@ -227,7 +227,13 @@ brw_upload_clip_prog(struct brw_context *brw)<br>
/* CACHE_NEW_VS_PROG (also part of VUE map) */<br>
key.attrs = brw->vs.prog_data->outputs_written;<br>
/* _NEW_LIGHT */<br>
- key.do_flat_shading = (ctx->Light.ShadeModel == GL_FLAT);<br>
+ key.has_flat_shading = 0;<br>
+ for (i = 0; i < BRW_VERT_RESULT_MAX; i++) {<br>
+ if (brw_get_interpolation_mode(brw, i) == INTERP_QUALIFIER_FLAT) {<br>
+ key.has_flat_shading = 1;<br>
+ break;<br>
+ }<br>
+ }<br>
key.pv_first = (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION);<br>
brw_copy_interpolation_modes(brw, key.interpolation_mode);<br>
/* _NEW_TRANSFORM (also part of VUE map)*/<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip.h b/src/mesa/drivers/dri/i965/brw_clip.h<br>
index 6f811ae..0ea0394 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip.h<br>
@@ -46,7 +46,7 @@ struct brw_clip_prog_key {<br>
GLbitfield64 interpolation_mode[2]; /* copy of the main context */<br>
GLuint primitive:4;<br>
GLuint nr_userclip:4;<br>
- GLuint do_flat_shading:1;<br>
+ GLuint has_flat_shading:1;<br>
GLuint pv_first:1;<br>
GLuint do_unfilled:1;<br>
GLuint fill_cw:2; /* includes cull information */<br>
@@ -166,8 +166,8 @@ void brw_clip_kill_thread(struct brw_clip_compile *c);<br>
struct brw_reg brw_clip_plane_stride( struct brw_clip_compile *c );<br>
struct brw_reg brw_clip_plane0_address( struct brw_clip_compile *c );<br>
<br>
-void brw_clip_copy_colors( struct brw_clip_compile *c,<br>
- GLuint to, GLuint from );<br>
+void brw_clip_copy_flatshaded_attributes( struct brw_clip_compile *c,<br>
+ GLuint to, GLuint from );<br>
<br>
void brw_clip_init_clipmask( struct brw_clip_compile *c );<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip_line.c b/src/mesa/drivers/dri/i965/brw_clip_line.c<br>
index 6cf2bd2..729d8c0 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip_line.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip_line.c<br>
@@ -271,11 +271,11 @@ void brw_emit_line_clip( struct brw_clip_compile *c )<br>
brw_clip_line_alloc_regs(c);<br>
brw_clip_init_ff_sync(c);<br>
<br>
- if (c->key.do_flat_shading) {<br>
+ if (c->key.has_flat_shading) {<br>
if (c->key.pv_first)<br>
- brw_clip_copy_colors(c, 1, 0);<br>
+ brw_clip_copy_flatshaded_attributes(c, 1, 0);<br>
else<br>
- brw_clip_copy_colors(c, 0, 1);<br>
+ brw_clip_copy_flatshaded_attributes(c, 0, 1);<br>
}<br>
<br>
clip_and_emit_line(c);<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c b/src/mesa/drivers/dri/i965/brw_clip_tri.c<br>
index a29f8e0..71225f5 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip_tri.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c<br>
@@ -187,8 +187,8 @@ void brw_clip_tri_flat_shade( struct brw_clip_compile *c )<br>
<br>
brw_IF(p, BRW_EXECUTE_1);<br>
{<br>
- brw_clip_copy_colors(c, 1, 0);<br>
- brw_clip_copy_colors(c, 2, 0);<br>
+ brw_clip_copy_flatshaded_attributes(c, 1, 0);<br>
+ brw_clip_copy_flatshaded_attributes(c, 2, 0);<br>
}<br>
brw_ELSE(p);<br>
{<br>
@@ -200,19 +200,19 @@ void brw_clip_tri_flat_shade( struct brw_clip_compile *c )<br>
brw_imm_ud(_3DPRIM_TRIFAN));<br>
brw_IF(p, BRW_EXECUTE_1);<br>
{<br>
- brw_clip_copy_colors(c, 0, 1);<br>
- brw_clip_copy_colors(c, 2, 1);<br>
+ brw_clip_copy_flatshaded_attributes(c, 0, 1);<br>
+ brw_clip_copy_flatshaded_attributes(c, 2, 1);<br>
}<br>
brw_ELSE(p);<br>
{<br>
- brw_clip_copy_colors(c, 1, 0);<br>
- brw_clip_copy_colors(c, 2, 0);<br>
+ brw_clip_copy_flatshaded_attributes(c, 1, 0);<br>
+ brw_clip_copy_flatshaded_attributes(c, 2, 0);<br>
}<br>
brw_ENDIF(p);<br>
}<br>
else {<br>
- brw_clip_copy_colors(c, 0, 2);<br>
- brw_clip_copy_colors(c, 1, 2);<br>
+ brw_clip_copy_flatshaded_attributes(c, 0, 2);<br>
+ brw_clip_copy_flatshaded_attributes(c, 1, 2);<br>
}<br>
}<br>
brw_ENDIF(p);<br>
@@ -606,8 +606,8 @@ void brw_emit_tri_clip( struct brw_clip_compile *c )<br>
* flatshading, need to apply the flatshade here because we don't<br>
* respect the PV when converting to trifan for emit:<br>
*/<br>
- if (c->key.do_flat_shading)<br>
- brw_clip_tri_flat_shade(c);<br>
+ if (c->key.has_flat_shading)<br>
+ brw_clip_tri_flat_shade(c);<br>
<br>
if ((c->key.clip_mode == BRW_CLIPMODE_NORMAL) ||<br>
(c->key.clip_mode == BRW_CLIPMODE_KERNEL_CLIP))<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c<br>
index 03c7d42..96f9a84 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c<br>
@@ -502,7 +502,7 @@ void brw_emit_unfilled_clip( struct brw_clip_compile *c )<br>
<br>
/* Need to do this whether we clip or not:<br>
*/<br>
- if (c->key.do_flat_shading)<br>
+ if (c->key.has_flat_shading)<br>
brw_clip_tri_flat_shade(c);<br>
<br>
brw_clip_init_clipmask(c);<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip_util.c b/src/mesa/drivers/dri/i965/brw_clip_util.c<br>
index bf8cc3a..7b0205a 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip_util.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip_util.c<br>
@@ -165,7 +165,7 @@ void brw_clip_interp_vertex( struct brw_clip_compile *c,<br>
vert_result == VERT_RESULT_CLIP_DIST1) {<br>
/* PSIZ doesn't need interpolation because it isn't used by the<br>
* fragment shader. CLIP_DIST0 and CLIP_DIST1 don't need<br>
- * intepolation because on pre-GEN6, these are just placeholder VUE<br>
+ * interpolation because on pre-GEN6, these are just placeholder VUE<br></blockquote><div><br>Heh. Thanks for fixing my typo :)<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
* slots that don't perform any action.<br>
*/<br>
} else if (vert_result < VERT_RESULT_MAX) {<br>
@@ -291,49 +291,25 @@ struct brw_reg brw_clip_plane_stride( struct brw_clip_compile *c )<br>
}<br>
<br>
<br>
-/* If flatshading, distribute color from provoking vertex prior to<br>
+/* Distribute flatshaded attributes from provoking vertex prior to<br>
* clipping.<br>
*/<br>
-void brw_clip_copy_colors( struct brw_clip_compile *c,<br>
- GLuint to, GLuint from )<br>
+void brw_clip_copy_flatshaded_attributes( struct brw_clip_compile *c,<br>
+ GLuint to, GLuint from )<br>
{<br>
struct brw_compile *p = &c->func;<br>
-<br>
- if (brw_clip_have_vert_result(c, VERT_RESULT_COL0))<br>
- brw_MOV(p,<br>
- byte_offset(c->reg.vertex[to],<br>
- brw_vert_result_to_offset(&c->vue_map,<br>
- VERT_RESULT_COL0)),<br>
- byte_offset(c->reg.vertex[from],<br>
- brw_vert_result_to_offset(&c->vue_map,<br>
- VERT_RESULT_COL0)));<br>
-<br>
- if (brw_clip_have_vert_result(c, VERT_RESULT_COL1))<br>
- brw_MOV(p,<br>
- byte_offset(c->reg.vertex[to],<br>
- brw_vert_result_to_offset(&c->vue_map,<br>
- VERT_RESULT_COL1)),<br>
- byte_offset(c->reg.vertex[from],<br>
- brw_vert_result_to_offset(&c->vue_map,<br>
- VERT_RESULT_COL1)));<br>
-<br>
- if (brw_clip_have_vert_result(c, VERT_RESULT_BFC0))<br>
- brw_MOV(p,<br>
- byte_offset(c->reg.vertex[to],<br>
- brw_vert_result_to_offset(&c->vue_map,<br>
- VERT_RESULT_BFC0)),<br>
- byte_offset(c->reg.vertex[from],<br>
- brw_vert_result_to_offset(&c->vue_map,<br>
- VERT_RESULT_BFC0)));<br>
-<br>
- if (brw_clip_have_vert_result(c, VERT_RESULT_BFC1))<br>
- brw_MOV(p,<br>
- byte_offset(c->reg.vertex[to],<br>
- brw_vert_result_to_offset(&c->vue_map,<br>
- VERT_RESULT_BFC1)),<br>
- byte_offset(c->reg.vertex[from],<br>
- brw_vert_result_to_offset(&c->vue_map,<br>
- VERT_RESULT_BFC1)));<br>
+ struct brw_context *brw = p->brw;<br>
+ GLuint i;<br>
+<br>
+ for (i = 0; i < BRW_VERT_RESULT_MAX; i++) {<br>
+ if (brw_get_interpolation_mode(brw, i) == INTERP_QUALIFIER_FLAT) {<br>
+ brw_MOV(p,<br>
+ byte_offset(c->reg.vertex[to],<br>
+ brw_vue_slot_to_offset(i)),<br>
+ byte_offset(c->reg.vertex[from],<br>
+ brw_vue_slot_to_offset(i)));<br>
+ }<br>
+ }<br>
}<br></blockquote><div><br>Ah, a loop! This is so much better. Thanks.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
1.7.10.rc3.1.gb306<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br>This patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>