summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_interpolation_map.c
diff options
context:
space:
mode:
authorChris Forbes <chrisf@ijw.co.nz>2013-07-07 02:56:14 +1200
committerChris Forbes <chrisf@ijw.co.nz>2013-08-01 20:58:19 +1200
commit9f51499d28f80cbbafa4c1489637e1a6a68d9345 (patch)
tree61a8cef92720590201eac9f214767f8263674238 /src/mesa/drivers/dri/i965/brw_interpolation_map.c
parentc6f3036179dc187770caa741da0aa073b807b1cf (diff)
downloadexternal_mesa3d-9f51499d28f80cbbafa4c1489637e1a6a68d9345.zip
external_mesa3d-9f51499d28f80cbbafa4c1489637e1a6a68d9345.tar.gz
external_mesa3d-9f51499d28f80cbbafa4c1489637e1a6a68d9345.tar.bz2
i965 Gen4/5: Introduce 'interpolation map' alongside the VUE map
The interpolation map (in brw->interpolation_mode) is a new auxiliary structure alongside the post-GS VUE map, which describes the interpolation modes for each VUE slot, for use by the clip and SF stages. This patch introduces a new state atom to compute the interpolation map, and adjusts the program keys for the clip and SF stages, but it is not actually used yet. [V1-2]: Signed-off-by: Olivier Galibert <galibert at pobox.com> V3: Updated for vue_map changes, intel -> brw merge, etc. (Chris Forbes) V4: Compute interpolation map as a new state atom rather than tacking it on the front of the clip setup V5: Rework commit message, make interpolation_mode_map a struct. Signed-off-by: Chris Forbes <chrisf@ijw.co.nz> Reviewed-by: Paul Berry <stereotype441@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_interpolation_map.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_interpolation_map.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_interpolation_map.c b/src/mesa/drivers/dri/i965/brw_interpolation_map.c
new file mode 100644
index 0000000..7b7dbef
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_interpolation_map.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "brw_state.h"
+
+
+/* Set up interpolation modes for every element in the VUE */
+static void
+brw_setup_vue_interpolation(struct brw_context *brw)
+{
+ const struct gl_fragment_program *fprog = brw->fragment_program;
+ struct brw_vue_map *vue_map = &brw->vue_map_geom_out;
+
+ memset(&brw->interpolation_mode, INTERP_QUALIFIER_NONE, sizeof(brw->interpolation_mode));
+
+ brw->state.dirty.brw |= BRW_NEW_INTERPOLATION_MAP;
+
+ if (!fprog)
+ return;
+
+ for (int i = 0; i < vue_map->num_slots; i++) {
+ int varying = vue_map->slot_to_varying[i];
+ if (varying == -1)
+ continue;
+
+ /* HPOS always wants noperspective. setting it up here allows
+ * us to not need special handling in the SF program. */
+ if (varying == VARYING_SLOT_POS) {
+ brw->interpolation_mode.mode[i] = INTERP_QUALIFIER_NOPERSPECTIVE;
+ continue;
+ }
+
+ int frag_attrib = varying;
+ if (varying == VARYING_SLOT_BFC0 || varying == VARYING_SLOT_BFC1)
+ frag_attrib = varying - VARYING_SLOT_BFC0 + VARYING_SLOT_COL0;
+
+ if (!(fprog->Base.InputsRead & BITFIELD64_BIT(frag_attrib)))
+ continue;
+
+ enum glsl_interp_qualifier mode = fprog->InterpQualifier[frag_attrib];
+
+ /* If the mode is not specified, the default varies: Color values
+ * follow GL_SHADE_MODEL; everything else is smooth.
+ */
+ if (mode == INTERP_QUALIFIER_NONE) {
+ if (frag_attrib == VARYING_SLOT_COL0 || frag_attrib == VARYING_SLOT_COL1)
+ mode = brw->ctx.Light.ShadeModel == GL_FLAT
+ ? INTERP_QUALIFIER_FLAT : INTERP_QUALIFIER_SMOOTH;
+ else
+ mode = INTERP_QUALIFIER_SMOOTH;
+ }
+
+ brw->interpolation_mode.mode[i] = mode;
+ }
+}
+
+
+const struct brw_tracked_state brw_interpolation_map = {
+ .dirty = {
+ .mesa = _NEW_LIGHT,
+ .brw = (BRW_NEW_FRAGMENT_PROGRAM |
+ BRW_NEW_VUE_MAP_GEOM_OUT)
+ },
+ .emit = brw_setup_vue_interpolation
+};