summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2013-07-31 07:34:49 -0400
committerZack Rusin <[email protected]>2013-08-02 20:11:18 -0400
commitd6b3a193d4d525c5048ebf793e6a63fd98f92d64 (patch)
tree03fa602befb47cfa29efad7bc1c85e1ec645e92a /src/gallium/drivers/llvmpipe
parent05487ef88ded5fea0b1de7bc08d44846648d1ce2 (diff)
draw: inject frontface info into wireframe outputs
Draw module can decompose primitives into wireframe models, which is a fancy word for 'lines', unfortunately that decomposition means that we weren't able to preserve the original front-face info which could be derived from the original primitives (lines don't have a 'face'). To fix it allow draw module to inject a fake face semantic into outputs from which the backends can figure out the original frontfacing info of the primitives. Signed-off-by: Zack Rusin <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.h3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_context.h1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_line.c14
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_point.c15
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_derived.c9
6 files changed, 39 insertions, 4 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h
index 9495e42feee..fc948a727fe 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -122,6 +122,9 @@ struct llvmpipe_context {
/** Which geometry shader output slot contains layer */
int layer_slot;
+ /** A fake frontface output for unfilled primitives */
+ int face_slot;
+
/**< minimum resolvable depth value, for polygon offset */
double mrd;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 65f61edc360..5fde01fa13b 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -1053,6 +1053,7 @@ lp_setup_update_state( struct lp_setup_context *setup,
setup->psize = lp->psize_slot;
setup->viewport_index_slot = lp->viewport_index_slot;
setup->layer_slot = lp->layer_slot;
+ setup->face_slot = lp->face_slot;
assert(lp->dirty == 0);
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h
index 89c23bbb3ac..ea1d0d688d8 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h
@@ -106,6 +106,7 @@ struct lp_setup_context
float psize;
unsigned viewport_index_slot;
unsigned layer_slot;
+ unsigned face_slot;
struct pipe_framebuffer_state fb;
struct u_rect framebuffer;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c b/src/gallium/drivers/llvmpipe/lp_setup_line.c
index bfed59cba0a..3b16163ba59 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
@@ -37,6 +37,7 @@
#include "lp_state_fs.h"
#include "lp_state_setup.h"
#include "lp_context.h"
+#include "draw/draw_context.h"
#define NUM_CHANNELS 4
@@ -45,6 +46,7 @@ struct lp_line_info {
float dx;
float dy;
float oneoverarea;
+ boolean frontfacing;
const float (*v1)[4];
const float (*v2)[4];
@@ -214,7 +216,8 @@ static void setup_line_coefficients( struct lp_setup_context *setup,
case LP_INTERP_FACING:
for (i = 0; i < NUM_CHANNELS; i++)
if (usage_mask & (1 << i))
- constant_coef(setup, info, slot+1, 1.0, i);
+ constant_coef(setup, info, slot+1,
+ info->frontfacing ? 1.0f : -1.0f, i);
break;
default:
@@ -613,15 +616,22 @@ try_setup_line( struct lp_setup_context *setup,
plane[2].dcdx = y[2] - y[3];
plane[3].dcdx = y[3] - y[0];
+ if (draw_will_inject_frontface(lp_context->draw) &&
+ setup->face_slot > 0) {
+ line->inputs.frontfacing = v1[setup->face_slot][0];
+ } else {
+ line->inputs.frontfacing = TRUE;
+ }
+
/* Setup parameter interpolants:
*/
info.a0 = GET_A0(&line->inputs);
info.dadx = GET_DADX(&line->inputs);
info.dady = GET_DADY(&line->inputs);
+ info.frontfacing = line->inputs.frontfacing;
setup_line_coefficients(setup, &info);
- line->inputs.frontfacing = TRUE;
line->inputs.disable = FALSE;
line->inputs.opaque = FALSE;
line->inputs.layer = layer;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c b/src/gallium/drivers/llvmpipe/lp_setup_point.c
index 868a9a904b7..cbcc8d4f2f3 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_point.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c
@@ -38,6 +38,7 @@
#include "lp_state_setup.h"
#include "lp_context.h"
#include "tgsi/tgsi_scan.h"
+#include "draw/draw_context.h"
#define NUM_CHANNELS 4
@@ -51,6 +52,8 @@ struct point_info {
float (*a0)[4];
float (*dadx)[4];
float (*dady)[4];
+
+ boolean frontfacing;
};
@@ -276,7 +279,8 @@ setup_point_coefficients( struct lp_setup_context *setup,
case LP_INTERP_FACING:
for (i = 0; i < NUM_CHANNELS; i++)
if (usage_mask & (1 << i))
- constant_coef(setup, info, slot+1, 1.0, i);
+ constant_coef(setup, info, slot+1,
+ info->frontfacing ? 1.0f : -1.0f, i);
break;
default:
@@ -384,6 +388,13 @@ try_setup_point( struct lp_setup_context *setup,
lp_context->pipeline_statistics.c_primitives++;
}
+ if (draw_will_inject_frontface(lp_context->draw) &&
+ setup->face_slot > 0) {
+ point->inputs.frontfacing = v0[setup->face_slot][0];
+ } else {
+ point->inputs.frontfacing = TRUE;
+ }
+
info.v0 = v0;
info.dx01 = 0;
info.dx12 = fixed_width;
@@ -392,12 +403,12 @@ try_setup_point( struct lp_setup_context *setup,
info.a0 = GET_A0(&point->inputs);
info.dadx = GET_DADX(&point->inputs);
info.dady = GET_DADY(&point->inputs);
+ info.frontfacing = point->inputs.frontfacing;
/* Setup parameter interpolants:
*/
setup_point_coefficients(setup, &info);
- point->inputs.frontfacing = TRUE;
point->inputs.disable = FALSE;
point->inputs.opaque = FALSE;
point->inputs.layer = layer;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c
index dc80358c7be..5a51b50821e 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_derived.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c
@@ -53,6 +53,8 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
int vs_index;
uint i;
+ draw_prepare_shader_outputs(llvmpipe->draw);
+
llvmpipe->color_slot[0] = -1;
llvmpipe->color_slot[1] = -1;
llvmpipe->bcolor_slot[0] = -1;
@@ -138,6 +140,13 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
llvmpipe->layer_slot = 0;
}
+ /* Check for a fake front face for unfilled primitives*/
+ vs_index = draw_find_shader_output(llvmpipe->draw,
+ TGSI_SEMANTIC_FACE, 0);
+ if (vs_index >= 0) {
+ llvmpipe->face_slot = vinfo->num_attribs;
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
+ }
draw_compute_vertex_size(vinfo);
lp_setup_set_vertex_info(llvmpipe->setup, vinfo);