<div dir="ltr">On 23 July 2013 01:16, 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The program keys are updated accordingly, but the values are not used<br>
yet.<br>
<br>
[V1-2]: Signed-off-by: Olivier Galibert <galibert at <a href="http://pobox.com" target="_blank">pobox.com</a>><br>
<br>
V3: Updated for vue_map changes, intel -> brw merge, etc. (Chris Forbes)<br>
V4: Compute interpolation map as a new state atom rather than tacking it<br>
on the front of the clip setup<br>
<br>
Signed-off-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz" target="_blank">chrisf@ijw.co.nz</a>><br>
---<br>
src/mesa/drivers/dri/i965/Makefile.sources | 1 +<br>
src/mesa/drivers/dri/i965/brw_clip.c | 8 ++-<br>
src/mesa/drivers/dri/i965/brw_clip.h | 1 +<br>
src/mesa/drivers/dri/i965/brw_context.h | 7 ++<br>
src/mesa/drivers/dri/i965/brw_interpolation_map.c | 85 +++++++++++++++++++++++<br>
src/mesa/drivers/dri/i965/brw_sf.c | 7 +-<br>
src/mesa/drivers/dri/i965/brw_sf.h | 1 +<br>
src/mesa/drivers/dri/i965/brw_state.h | 1 +<br>
src/mesa/drivers/dri/i965/brw_state_upload.c | 3 +<br>
9 files changed, 112 insertions(+), 2 deletions(-)<br>
create mode 100644 src/mesa/drivers/dri/i965/brw_interpolation_map.c<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources<br>
index 1f401fe..ac8487b 100644<br>
--- a/src/mesa/drivers/dri/i965/Makefile.sources<br>
+++ b/src/mesa/drivers/dri/i965/Makefile.sources<br>
@@ -62,6 +62,7 @@ i965_FILES = \<br>
brw_gs.c \<br>
brw_gs_emit.c \<br>
brw_gs_state.c \<br>
+ brw_interpolation_map.c \<br>
brw_lower_texture_gradients.cpp \<br>
brw_misc_state.c \<br>
brw_program.c \<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c<br>
index 2ebf3f6..60d85e8 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip.c<br>
@@ -141,6 +141,10 @@ brw_upload_clip_prog(struct brw_context *brw)<br>
<br>
/* Populate the key:<br>
*/<br>
+<br>
+ /* BRW_NEW_INTERPOLATION_MAP */<br>
+ memcpy(key.interpolation_mode, brw->interpolation_mode, BRW_VARYING_SLOT_COUNT);<br></blockquote><div><br></div><div>Random idea, which you may feel free to disregard: What if we make interpolation_mode a struct, e.g.:<br>
<br>struct interpolation_mode_map<br>{<br> unsigned char mode[BRW_VARYING_SLOT_COUNT];<br>}<br><br></div><div>That way, this memcpy can just change to:<br><br></div><div>key.interpolation_mode = brw->interpolation_mode;<br>
<br></div><div>And the compiler takes care of making sure the types match and figuring out the right number of bytes to copy.<br></div><br></div><div class="gmail_quote">The disadvantage, of course, is that everywhere you use key.interpolation_mode[...] in the rest of the series you'll have to replace that with key.interpolation_mode.mode[...], which looks pretty silly :)<br>
<br></div><div class="gmail_quote">Either way, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
/* BRW_NEW_REDUCED_PRIMITIVE */<br>
key.primitive = brw->reduced_primitive;<br>
/* BRW_NEW_VUE_MAP_GEOM_OUT */<br>
@@ -256,7 +260,9 @@ const struct brw_tracked_state brw_clip_prog = {<br>
_NEW_TRANSFORM |<br>
_NEW_POLYGON |<br>
_NEW_BUFFERS),<br>
- .brw = (BRW_NEW_REDUCED_PRIMITIVE | BRW_NEW_VUE_MAP_GEOM_OUT)<br>
+ .brw = (BRW_NEW_REDUCED_PRIMITIVE |<br>
+ BRW_NEW_VUE_MAP_GEOM_OUT |<br>
+ BRW_NEW_INTERPOLATION_MAP)<br>
},<br>
.emit = brw_upload_clip_prog<br>
};<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip.h b/src/mesa/drivers/dri/i965/brw_clip.h<br>
index 02259d4..fcbe2a0 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip.h<br>
@@ -43,6 +43,7 @@<br>
*/<br>
struct brw_clip_prog_key {<br>
GLbitfield64 attrs;<br>
+ unsigned char interpolation_mode[BRW_VARYING_SLOT_COUNT];<br>
GLuint primitive:4;<br>
GLuint nr_userclip:4;<br>
GLuint do_flat_shading:1;<br>
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h<br>
index 86f9f71..29e522c 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
@@ -154,6 +154,7 @@ enum brw_state_id {<br>
BRW_STATE_STATS_WM,<br>
BRW_STATE_UNIFORM_BUFFER,<br>
BRW_STATE_META_IN_PROGRESS,<br>
+ BRW_STATE_INTERPOLATION_MAP,<br>
};<br>
<br>
#define BRW_NEW_URB_FENCE (1 << BRW_STATE_URB_FENCE)<br>
@@ -186,6 +187,7 @@ enum brw_state_id {<br>
#define BRW_NEW_STATS_WM (1 << BRW_STATE_STATS_WM)<br>
#define BRW_NEW_UNIFORM_BUFFER (1 << BRW_STATE_UNIFORM_BUFFER)<br>
#define BRW_NEW_META_IN_PROGRESS (1 << BRW_STATE_META_IN_PROGRESS)<br>
+#define BRW_NEW_INTERPOLATION_MAP (1 << BRW_STATE_INTERPOLATION_MAP)<br>
<br>
struct brw_state_flags {<br>
/** State update flags signalled by mesa internals */<br>
@@ -1203,6 +1205,11 @@ struct brw_context<br>
uint32_t render_target_format[MESA_FORMAT_COUNT];<br>
bool format_supported_as_render_target[MESA_FORMAT_COUNT];<br>
<br>
+ /* Interpolation modes, one byte per vue slot.<br>
+ * Used Gen4/5 by the clip|sf|wm stages. Ignored on Gen6+.<br>
+ */<br>
+ unsigned char interpolation_mode[BRW_VARYING_SLOT_COUNT];<br>
+<br>
/* PrimitiveRestart */<br>
struct {<br>
bool in_progress;<br>
diff --git a/src/mesa/drivers/dri/i965/brw_interpolation_map.c b/src/mesa/drivers/dri/i965/brw_interpolation_map.c<br>
new file mode 100644<br>
index 0000000..a007078<br>
--- /dev/null<br>
+++ b/src/mesa/drivers/dri/i965/brw_interpolation_map.c<br>
@@ -0,0 +1,85 @@<br>
+/*<br>
+ * Copyright © 2013 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+#include "brw_state.h"<br>
+<br>
+<br>
+/* Set up interpolation modes for every element in the VUE */<br>
+static void<br>
+brw_setup_vue_interpolation(struct brw_context *brw)<br>
+{<br>
+ const struct gl_fragment_program *fprog = brw->fragment_program;<br>
+ struct brw_vue_map *vue_map = &brw->vue_map_geom_out;<br>
+<br>
+ memset(brw->interpolation_mode, INTERP_QUALIFIER_NONE, BRW_VARYING_SLOT_COUNT);<br>
+<br>
+ brw->state.dirty.brw |= BRW_NEW_INTERPOLATION_MAP;<br>
+<br>
+ if (!fprog)<br>
+ return;<br>
+<br>
+ for (int i=0; i < vue_map->num_slots; i++) {<br>
+ int varying = vue_map->slot_to_varying[i];<br>
+ if (varying == -1)<br>
+ continue;<br>
+<br>
+ /* HPOS always wants noperspective. setting it up here allows<br>
+ * us to not need special handling in the SF program. */<br>
+ if (varying == VARYING_SLOT_POS) {<br>
+ brw->interpolation_mode[i] = INTERP_QUALIFIER_NOPERSPECTIVE;<br>
+ continue;<br>
+ }<br>
+<br>
+ int frag_attrib = varying;<br>
+ if (varying == VARYING_SLOT_BFC0 || varying == VARYING_SLOT_BFC1)<br>
+ frag_attrib = varying - VARYING_SLOT_BFC0 + VARYING_SLOT_COL0;<br>
+<br>
+ if (!(fprog->Base.InputsRead & BITFIELD64_BIT(frag_attrib)))<br>
+ continue;<br>
+<br>
+ enum glsl_interp_qualifier mode = fprog->InterpQualifier[frag_attrib];<br>
+<br>
+ /* If the mode is not specified, the default varies: Color values<br>
+ * follow GL_SHADE_MODEL; everything else is smooth.<br>
+ */<br>
+ if (mode == INTERP_QUALIFIER_NONE) {<br>
+ if (frag_attrib == VARYING_SLOT_COL0 || frag_attrib == VARYING_SLOT_COL1)<br>
+ mode = brw->ctx.Light.ShadeModel == GL_FLAT<br>
+ ? INTERP_QUALIFIER_FLAT : INTERP_QUALIFIER_SMOOTH;<br>
+ else<br>
+ mode = INTERP_QUALIFIER_SMOOTH;<br>
+ }<br>
+<br>
+ brw->interpolation_mode[i] = mode;<br>
+ }<br>
+}<br>
+<br>
+<br>
+const struct brw_tracked_state brw_interpolation_map = {<br>
+ .dirty = {<br>
+ .mesa = _NEW_LIGHT,<br>
+ .brw = (BRW_NEW_FRAGMENT_PROGRAM |<br>
+ BRW_NEW_VUE_MAP_GEOM_OUT)<br>
+ },<br>
+ .emit = brw_setup_vue_interpolation<br>
+};<br>
diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c<br>
index d73973c..933cff2 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_sf.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_sf.c<br>
@@ -189,6 +189,9 @@ brw_upload_sf_prog(struct brw_context *brw)<br>
if ((ctx->Point.SpriteOrigin == GL_LOWER_LEFT) != render_to_fbo)<br>
key.sprite_origin_lower_left = true;<br>
<br>
+ /* BRW_NEW_INTERPOLATION_MAP */<br>
+ memcpy(key.interpolation_mode, brw->interpolation_mode, BRW_VARYING_SLOT_COUNT);<br>
+<br>
/* _NEW_LIGHT | _NEW_PROGRAM */<br>
key.do_flat_shading = (ctx->Light.ShadeModel == GL_FLAT);<br>
key.do_twoside_color = ((ctx->Light.Enabled && ctx->Light.Model.TwoSide) ||<br>
@@ -215,7 +218,9 @@ const struct brw_tracked_state brw_sf_prog = {<br>
.dirty = {<br>
.mesa = (_NEW_HINT | _NEW_LIGHT | _NEW_POLYGON | _NEW_POINT |<br>
_NEW_TRANSFORM | _NEW_BUFFERS | _NEW_PROGRAM),<br>
- .brw = (BRW_NEW_REDUCED_PRIMITIVE | BRW_NEW_VUE_MAP_GEOM_OUT)<br>
+ .brw = (BRW_NEW_REDUCED_PRIMITIVE |<br>
+ BRW_NEW_VUE_MAP_GEOM_OUT |<br>
+ BRW_NEW_INTERPOLATION_MAP)<br>
},<br>
.emit = brw_upload_sf_prog<br>
};<br>
diff --git a/src/mesa/drivers/dri/i965/brw_sf.h b/src/mesa/drivers/dri/i965/brw_sf.h<br>
index caeb0d0..55a860d 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_sf.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_sf.h<br>
@@ -46,6 +46,7 @@<br>
<br>
struct brw_sf_prog_key {<br>
GLbitfield64 attrs;<br>
+ unsigned char interpolation_mode[BRW_VARYING_SLOT_COUNT];<br>
uint8_t point_sprite_coord_replace;<br>
GLuint primitive:2;<br>
GLuint do_twoside_color:1;<br>
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h<br>
index ed1df87..321bffe 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_state.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_state.h<br>
@@ -76,6 +76,7 @@ extern const struct brw_tracked_state brw_wm_binding_table;<br>
extern const struct brw_tracked_state brw_vs_binding_table;<br>
extern const struct brw_tracked_state brw_wm_ubo_surfaces;<br>
extern const struct brw_tracked_state brw_wm_unit;<br>
+extern const struct brw_tracked_state brw_interpolation_map;<br>
<br>
extern const struct brw_tracked_state brw_psp_urb_cbs;<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
index c9ba781..e3ef245 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
@@ -41,6 +41,9 @@ static const struct brw_tracked_state *gen4_atoms[] =<br>
{<br>
&brw_vs_prog, /* must do before GS prog, state base address. */<br>
&brw_gs_prog, /* must do before state base address */<br>
+<br>
+ &brw_interpolation_map,<br>
+<br>
&brw_clip_prog, /* must do before state base address */<br>
&brw_sf_prog, /* must do before state base address */<br>
&brw_wm_prog, /* must do before state base address */<br>
<span><font color="#888888">--<br>
1.8.3.3<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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>