summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/draw/draw_twoside.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/draw/draw_twoside.c')
-rw-r--r--src/mesa/pipe/draw/draw_twoside.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c
index c7e268f11e..da8e7bd90d 100644
--- a/src/mesa/pipe/draw/draw_twoside.c
+++ b/src/mesa/pipe/draw/draw_twoside.c
@@ -30,12 +30,15 @@
#include "pipe/p_util.h"
#include "pipe/p_defines.h"
+#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
struct twoside_stage {
struct draw_stage stage;
float sign; /**< +1 or -1 */
+ uint attrib_front0, attrib_back0;
+ uint attrib_front1, attrib_back1;
};
@@ -48,6 +51,29 @@ static INLINE struct twoside_stage *twoside_stage( struct draw_stage *stage )
static void twoside_begin( struct draw_stage *stage )
{
struct twoside_stage *twoside = twoside_stage(stage);
+ const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+ uint i;
+
+ twoside->attrib_front0 = 0;
+ twoside->attrib_front1 = 0;
+ twoside->attrib_back0 = 0;
+ twoside->attrib_back1 = 0;
+
+ /* Find which vertex shader outputs are front/back colors */
+ for (i = 0; i < vs->num_outputs; i++) {
+ if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
+ if (vs->output_semantic_index[i] == 0)
+ twoside->attrib_front0 = i;
+ else
+ twoside->attrib_front1 = i;
+ }
+ if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+ if (vs->output_semantic_index[i] == 0)
+ twoside->attrib_back0 = i;
+ else
+ twoside->attrib_back1 = i;
+ }
+ }
/*
* We'll multiply the primitive's determinant by this sign to determine
@@ -76,13 +102,12 @@ static struct vertex_header *copy_bfc( struct twoside_stage *twoside,
unsigned idx )
{
struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx );
- const struct draw_context *draw = twoside->stage.draw;
- if (draw->attrib_front0 && draw->attrib_back0) {
- copy_attrib(draw->attrib_front0, draw->attrib_back0, tmp);
+ if (twoside->attrib_front0 && twoside->attrib_back0) {
+ copy_attrib(twoside->attrib_front0, twoside->attrib_back0, tmp);
}
- if (draw->attrib_front1 && draw->attrib_back1) {
- copy_attrib(draw->attrib_front1, draw->attrib_back1, tmp);
+ if (twoside->attrib_front1 && twoside->attrib_back1) {
+ copy_attrib(twoside->attrib_front1, twoside->attrib_back1, tmp);
}
return tmp;