<div dir="ltr">On 31 July 2013 04:07, Chris Forbes <span dir="ltr"><<a href="mailto:chrisf@ijw.co.nz" target="_blank">chrisf@ijw.co.nz</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Previously we only gave special treatment to the builtin color varyings.<br>
This patch adds support for arbitrary flat-shaded varyings, which is<br>
required for GLSL 1.30.<br>
<br>
Based on Olivier Galibert's patch from last year:<br>
<a href="http://lists.freedesktop.org/archives/mesa-dev/2012-July/024340.html" target="_blank">http://lists.freedesktop.org/archives/mesa-dev/2012-July/024340.html</a><br>
<br>
V5: Move key.do_flat_shading to brw_clip_compile.has_flat_shading<br>
<br>
[V1-2]: Signed-off-by: Olivier Galibert <galibert at <a href="http://pobox.com" target="_blank">pobox.com</a>><br>
Signed-off-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz">chrisf@ijw.co.nz</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_clip.c | 5 ++-<br>
src/mesa/drivers/dri/i965/brw_clip.h | 7 ++--<br>
src/mesa/drivers/dri/i965/brw_clip_line.c | 6 ++--<br>
src/mesa/drivers/dri/i965/brw_clip_tri.c | 18 +++++------<br>
src/mesa/drivers/dri/i965/brw_clip_unfilled.c | 2 +-<br>
src/mesa/drivers/dri/i965/brw_clip_util.c | 46 ++++++---------------------<br>
6 files changed, 30 insertions(+), 54 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 7621675..1c2a4bc 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip.c<br>
@@ -70,6 +70,9 @@ static void compile_clip_prog( struct brw_context *brw,<br>
c.key = *key;<br>
c.vue_map = brw->vue_map_geom_out;<br>
<br>
+ c.has_flat_shading =<br>
+ brw_any_flat_varyings(&key->interpolation_mode);<br>
+<br>
/* nr_regs is the number of registers filled by reading data from the VUE.<br>
* This program accesses the entire VUE, so nr_regs needs to be the size of<br>
* the VUE (measured in pairs, since two slots are stored in each<br>
@@ -149,8 +152,8 @@ brw_upload_clip_prog(struct brw_context *brw)<br>
key.primitive = brw->reduced_primitive;<br>
/* BRW_NEW_VUE_MAP_GEOM_OUT */<br>
key.attrs = brw->vue_map_geom_out.slots_valid;<br>
+<br>
/* _NEW_LIGHT */<br>
- key.do_flat_shading = (ctx->Light.ShadeModel == GL_FLAT);<br>
key.pv_first = (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION);<br>
/* _NEW_TRANSFORM (also part of VUE map)*/<br>
key.nr_userclip = _mesa_bitcount_64(ctx->Transform.ClipPlanesEnabled);<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip.h b/src/mesa/drivers/dri/i965/brw_clip.h<br>
index e0d75b0..c408fac 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,6 @@ struct brw_clip_prog_key {<br>
struct interpolation_mode_map interpolation_mode;<br>
GLuint primitive:4;<br>
GLuint nr_userclip:4;<br>
- GLuint do_flat_shading:1;<br>
GLuint pv_first:1;<br>
GLuint do_unfilled:1;<br>
GLuint fill_cw:2; /* includes cull information */<br>
@@ -121,6 +120,8 @@ struct brw_clip_compile {<br>
bool need_direction;<br>
<br>
struct brw_vue_map vue_map;<br>
+<br>
+ GLuint has_flat_shading:1;<br></blockquote><div><br></div><div>As with the last patch, I'd recommend making this a bool. With that fixed, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
};<br>
<br>
/**<br>
@@ -173,8 +174,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 9ce80b8..9001d36 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip_line.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip_line.c<br>
@@ -272,11 +272,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->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 bea0853..19179c1 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip_tri.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c<br>
@@ -190,8 +190,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>
@@ -203,19 +203,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>
@@ -645,7 +645,7 @@ 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>
+ if (c->has_flat_shading)<br>
brw_clip_tri_flat_shade(c);<br>
<br>
if ((c->key.clip_mode == BRW_CLIPMODE_NORMAL) ||<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 e211b95..af327d6 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c<br>
@@ -501,7 +501,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->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 37b7734..9d77d1e 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip_util.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip_util.c<br>
@@ -290,49 +290,21 @@ 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>
+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_varying(c, VARYING_SLOT_COL0))<br>
- brw_MOV(p,<br>
- byte_offset(c->reg.vertex[to],<br>
- brw_varying_to_offset(&c->vue_map,<br>
- VARYING_SLOT_COL0)),<br>
- byte_offset(c->reg.vertex[from],<br>
- brw_varying_to_offset(&c->vue_map,<br>
- VARYING_SLOT_COL0)));<br>
-<br>
- if (brw_clip_have_varying(c, VARYING_SLOT_COL1))<br>
- brw_MOV(p,<br>
- byte_offset(c->reg.vertex[to],<br>
- brw_varying_to_offset(&c->vue_map,<br>
- VARYING_SLOT_COL1)),<br>
- byte_offset(c->reg.vertex[from],<br>
- brw_varying_to_offset(&c->vue_map,<br>
- VARYING_SLOT_COL1)));<br>
-<br>
- if (brw_clip_have_varying(c, VARYING_SLOT_BFC0))<br>
- brw_MOV(p,<br>
- byte_offset(c->reg.vertex[to],<br>
- brw_varying_to_offset(&c->vue_map,<br>
- VARYING_SLOT_BFC0)),<br>
- byte_offset(c->reg.vertex[from],<br>
- brw_varying_to_offset(&c->vue_map,<br>
- VARYING_SLOT_BFC0)));<br>
-<br>
- if (brw_clip_have_varying(c, VARYING_SLOT_BFC1))<br>
- brw_MOV(p,<br>
- byte_offset(c->reg.vertex[to],<br>
- brw_varying_to_offset(&c->vue_map,<br>
- VARYING_SLOT_BFC1)),<br>
- byte_offset(c->reg.vertex[from],<br>
- brw_varying_to_offset(&c->vue_map,<br>
- VARYING_SLOT_BFC1)));<br>
+ for (int i = 0; i < c->vue_map.num_slots; i++) {<br>
+ if (c->key.interpolation_mode.mode[i] == INTERP_QUALIFIER_FLAT) {<br>
+ brw_MOV(p,<br>
+ byte_offset(c->reg.vertex[to], brw_vue_slot_to_offset(i)),<br>
+ byte_offset(c->reg.vertex[from], brw_vue_slot_to_offset(i)));<br>
+ }<br>
+ }<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
1.8.3.4<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></div></div>