From: Olivier Galibert <galibert@pobox.com>
To: intel-gfx@lists.freedesktop.org, mesa-dev@lists.freedesktop.org
Cc: Olivier Galibert <galibert@pobox.com>
Subject: [PATCH 2/9] intel gen4-5: simplify the bfc copy in the sf.
Date: Thu, 19 Jul 2012 22:00:17 +0200 [thread overview]
Message-ID: <1342728024-15055-3-git-send-email-galibert@pobox.com> (raw)
In-Reply-To: <1342728024-15055-1-git-send-email-galibert@pobox.com>
This patch is mostly designed to make followup patches simpler, but
it's a simplification by itself.
Signed-off-by: Olivier Galibert <galibert@pobox.com>
---
src/mesa/drivers/dri/i965/brw_sf_emit.c | 93 +++++++++++++++++--------------
1 file changed, 52 insertions(+), 41 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c
index ff6383b..9d8aa38 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c
@@ -79,24 +79,9 @@ have_attr(struct brw_sf_compile *c, GLuint attr)
/***********************************************************************
* Twoside lighting
*/
-static void copy_bfc( struct brw_sf_compile *c,
- struct brw_reg vert )
-{
- struct brw_compile *p = &c->func;
- GLuint i;
-
- for (i = 0; i < 2; i++) {
- if (have_attr(c, VERT_RESULT_COL0+i) &&
- have_attr(c, VERT_RESULT_BFC0+i))
- brw_MOV(p,
- get_vert_result(c, vert, VERT_RESULT_COL0+i),
- get_vert_result(c, vert, VERT_RESULT_BFC0+i));
- }
-}
-
-
static void do_twoside_color( struct brw_sf_compile *c )
{
+ GLuint i, need_0, need_1;
struct brw_compile *p = &c->func;
GLuint backface_conditional = c->key.frontface_ccw ? BRW_CONDITIONAL_G : BRW_CONDITIONAL_L;
@@ -105,12 +90,14 @@ static void do_twoside_color( struct brw_sf_compile *c )
if (c->key.primitive == SF_UNFILLED_TRIS)
return;
- /* XXX: What happens if BFC isn't present? This could only happen
- * for user-supplied vertex programs, as t_vp_build.c always does
- * the right thing.
+ /* If the vertex shader provides both front and backface color, do
+ * the selection. Otherwise the generated code will pick up
+ * whichever there is.
*/
- if (!(have_attr(c, VERT_RESULT_COL0) && have_attr(c, VERT_RESULT_BFC0)) &&
- !(have_attr(c, VERT_RESULT_COL1) && have_attr(c, VERT_RESULT_BFC1)))
+ need_0 = have_attr(c, VERT_RESULT_COL0) && have_attr(c, VERT_RESULT_BFC0);
+ need_1 = have_attr(c, VERT_RESULT_COL1) && have_attr(c, VERT_RESULT_BFC1);
+
+ if (!need_0 && !need_1)
return;
/* Need to use BRW_EXECUTE_4 and also do an 4-wide compare in order
@@ -121,12 +108,15 @@ static void do_twoside_color( struct brw_sf_compile *c )
brw_push_insn_state(p);
brw_CMP(p, vec4(brw_null_reg()), backface_conditional, c->det, brw_imm_f(0));
brw_IF(p, BRW_EXECUTE_4);
- {
- switch (c->nr_verts) {
- case 3: copy_bfc(c, c->vert[2]);
- case 2: copy_bfc(c, c->vert[1]);
- case 1: copy_bfc(c, c->vert[0]);
- }
+ for (i=0; i<c->nr_verts; i++) {
+ if (need_0)
+ brw_MOV(p,
+ get_vert_result(c, c->vert[i], VERT_RESULT_COL0),
+ get_vert_result(c, c->vert[i], VERT_RESULT_BFC0));
+ if (need_1)
+ brw_MOV(p,
+ get_vert_result(c, c->vert[i], VERT_RESULT_COL1),
+ get_vert_result(c, c->vert[i], VERT_RESULT_BFC1));
}
brw_ENDIF(p);
brw_pop_insn_state(p);
@@ -139,20 +129,27 @@ static void do_twoside_color( struct brw_sf_compile *c )
*/
#define VERT_RESULT_COLOR_BITS (BITFIELD64_BIT(VERT_RESULT_COL0) | \
- BITFIELD64_BIT(VERT_RESULT_COL1))
+ BITFIELD64_BIT(VERT_RESULT_COL1))
static void copy_colors( struct brw_sf_compile *c,
struct brw_reg dst,
- struct brw_reg src)
+ struct brw_reg src,
+ int allow_twoside)
{
struct brw_compile *p = &c->func;
GLuint i;
for (i = VERT_RESULT_COL0; i <= VERT_RESULT_COL1; i++) {
- if (have_attr(c,i))
+ if (have_attr(c,i)) {
brw_MOV(p,
get_vert_result(c, dst, i),
get_vert_result(c, src, i));
+
+ } else if(allow_twoside && have_attr(c, i - VERT_RESULT_COL0 + VERT_RESULT_BFC0)) {
+ brw_MOV(p,
+ get_vert_result(c, dst, i - VERT_RESULT_COL0 + VERT_RESULT_BFC0),
+ get_vert_result(c, src, i - VERT_RESULT_COL0 + VERT_RESULT_BFC0));
+ }
}
}
@@ -167,9 +164,19 @@ static void do_flatshade_triangle( struct brw_sf_compile *c )
struct brw_compile *p = &c->func;
struct intel_context *intel = &p->brw->intel;
struct brw_reg ip = brw_ip_reg();
- GLuint nr = _mesa_bitcount_64(c->key.attrs & VERT_RESULT_COLOR_BITS);
GLuint jmpi = 1;
+ GLuint nr;
+
+ if (c->key.do_twoside_color) {
+ nr = ((c->key.attrs & (BITFIELD64_BIT(VERT_RESULT_COL0) | BITFIELD64_BIT(VERT_RESULT_BFC0))) != 0) +
+ ((c->key.attrs & (BITFIELD64_BIT(VERT_RESULT_COL1) | BITFIELD64_BIT(VERT_RESULT_BFC1))) != 0);
+
+ } else {
+ nr = ((c->key.attrs & BITFIELD64_BIT(VERT_RESULT_COL0)) != 0) +
+ ((c->key.attrs & BITFIELD64_BIT(VERT_RESULT_COL1)) != 0);
+ }
+
if (!nr)
return;
@@ -186,16 +193,16 @@ static void do_flatshade_triangle( struct brw_sf_compile *c )
brw_MUL(p, c->pv, c->pv, brw_imm_d(jmpi*(nr*2+1)));
brw_JMPI(p, ip, ip, c->pv);
- copy_colors(c, c->vert[1], c->vert[0]);
- copy_colors(c, c->vert[2], c->vert[0]);
+ copy_colors(c, c->vert[1], c->vert[0], c->key.do_twoside_color);
+ copy_colors(c, c->vert[2], c->vert[0], c->key.do_twoside_color);
brw_JMPI(p, ip, ip, brw_imm_d(jmpi*(nr*4+1)));
- copy_colors(c, c->vert[0], c->vert[1]);
- copy_colors(c, c->vert[2], c->vert[1]);
+ copy_colors(c, c->vert[0], c->vert[1], c->key.do_twoside_color);
+ copy_colors(c, c->vert[2], c->vert[1], c->key.do_twoside_color);
brw_JMPI(p, ip, ip, brw_imm_d(jmpi*nr*2));
- copy_colors(c, c->vert[0], c->vert[2]);
- copy_colors(c, c->vert[1], c->vert[2]);
+ copy_colors(c, c->vert[0], c->vert[2], c->key.do_twoside_color);
+ copy_colors(c, c->vert[1], c->vert[2], c->key.do_twoside_color);
brw_pop_insn_state(p);
}
@@ -224,10 +231,10 @@ static void do_flatshade_line( struct brw_sf_compile *c )
brw_MUL(p, c->pv, c->pv, brw_imm_d(jmpi*(nr+1)));
brw_JMPI(p, ip, ip, c->pv);
- copy_colors(c, c->vert[1], c->vert[0]);
+ copy_colors(c, c->vert[1], c->vert[0], 0);
brw_JMPI(p, ip, ip, brw_imm_ud(jmpi*nr));
- copy_colors(c, c->vert[0], c->vert[1]);
+ copy_colors(c, c->vert[0], c->vert[1], 0);
brw_pop_insn_state(p);
}
@@ -337,13 +344,17 @@ calculate_masks(struct brw_sf_compile *c,
if (c->key.do_flat_shading)
persp_mask = c->key.attrs & ~(BITFIELD64_BIT(VERT_RESULT_HPOS) |
BITFIELD64_BIT(VERT_RESULT_COL0) |
- BITFIELD64_BIT(VERT_RESULT_COL1));
+ BITFIELD64_BIT(VERT_RESULT_COL1) |
+ BITFIELD64_BIT(VERT_RESULT_BFC0) |
+ BITFIELD64_BIT(VERT_RESULT_BFC1));
else
persp_mask = c->key.attrs & ~(BITFIELD64_BIT(VERT_RESULT_HPOS));
if (c->key.do_flat_shading)
linear_mask = c->key.attrs & ~(BITFIELD64_BIT(VERT_RESULT_COL0) |
- BITFIELD64_BIT(VERT_RESULT_COL1));
+ BITFIELD64_BIT(VERT_RESULT_COL1) |
+ BITFIELD64_BIT(VERT_RESULT_BFC0) |
+ BITFIELD64_BIT(VERT_RESULT_BFC1));
else
linear_mask = c->key.attrs;
--
1.7.10.280.gaa39
next prev parent reply other threads:[~2012-07-19 20:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-19 20:00 (no subject) Olivier Galibert
2012-07-19 20:00 ` [PATCH 1/9] intel gen4-5: fix the vue view in the fs Olivier Galibert
2012-07-26 17:18 ` [Mesa-dev] " Eric Anholt
2012-07-27 9:21 ` Olivier Galibert
2012-07-19 20:00 ` Olivier Galibert [this message]
2012-07-26 17:20 ` [PATCH 2/9] intel gen4-5: simplify the bfc copy in the sf Eric Anholt
2012-07-19 20:00 ` [PATCH 3/9] intel gen4-5: fix GL_VERTEX_PROGRAM_TWO_SIDE selection Olivier Galibert
2012-07-26 17:19 ` Eric Anholt
2012-07-19 20:00 ` [PATCH 4/9] intel gen4-5: Fix backface/frontface selection when one one color is written to Olivier Galibert
2012-07-20 17:01 ` Eric Anholt
2012-07-20 18:03 ` Olivier Galibert
2012-07-19 20:00 ` [PATCH 5/9] intel gen4-5: Compute the interpolation status for every variable in one place Olivier Galibert
2012-07-26 17:22 ` [Mesa-dev] " Eric Anholt
2012-07-27 9:12 ` Olivier Galibert
2012-07-19 20:00 ` [PATCH 6/9] intel gen4-5: Correctly setup the parameters in the sf Olivier Galibert
2012-07-19 20:00 ` [PATCH 7/9] intel gen4-5: Correctly handle flat vs. non-flat in the clipper Olivier Galibert
2012-07-19 20:00 ` [PATCH 8/9] intel gen4-5: Make noperspective clipping work Olivier Galibert
2012-07-19 20:00 ` [PATCH 9/9] intel gen4-5: Don't touch flatshaded values when clipping, only copy them Olivier Galibert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342728024-15055-3-git-send-email-galibert@pobox.com \
--to=galibert@pobox.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mesa-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).