diff options
| author | Zack Rusin <zackr@vmware.com> | 2013-07-31 07:34:49 -0400 |
|---|---|---|
| committer | Zack Rusin <zackr@vmware.com> | 2013-08-02 20:11:18 -0400 |
| commit | d6b3a193d4d525c5048ebf793e6a63fd98f92d64 (patch) | |
| tree | 03fa602befb47cfa29efad7bc1c85e1ec645e92a /src/gallium/auxiliary/draw/draw_context.c | |
| parent | 05487ef88ded5fea0b1de7bc08d44846648d1ce2 (diff) | |
| download | external_mesa3d-d6b3a193d4d525c5048ebf793e6a63fd98f92d64.tar.gz external_mesa3d-d6b3a193d4d525c5048ebf793e6a63fd98f92d64.tar.bz2 external_mesa3d-d6b3a193d4d525c5048ebf793e6a63fd98f92d64.zip | |
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 <zackr@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_context.c')
| -rw-r--r-- | src/gallium/auxiliary/draw/draw_context.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 29bbc94d0a..377b852f05 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -39,6 +39,7 @@ #include "util/u_helpers.h" #include "util/u_prim.h" #include "draw_context.h" +#include "draw_pipe.h" #include "draw_vs.h" #include "draw_gs.h" @@ -540,6 +541,22 @@ draw_get_shader_info(const struct draw_context *draw) } } +/** + * Prepare outputs slots from the draw module + * + * Certain parts of the draw module can emit additional + * outputs that can be quite useful to the backends, a good + * example of it is the process of decomposing primitives + * into wireframes (aka. lines) which normally would lose + * the face-side information, but using this method we can + * inject another shader output which passes the original + * face side information to the backend. + */ +void +draw_prepare_shader_outputs(struct draw_context *draw) +{ + draw_unfilled_prepare_outputs(draw, draw->pipeline.unfilled); +} /** * Ask the draw module for the location/slot of the given vertex attribute in @@ -1007,3 +1024,29 @@ draw_stats_clipper_primitives(struct draw_context *draw, } } } + + +/** + * Returns true if the draw module will inject the frontface + * info into the outputs. + * + * Given the specified primitive and rasterizer state + * the function will figure out if the draw module + * will inject the front-face information into shader + * outputs. This is done to preserve the front-facing + * info when decomposing primitives into wireframes. + */ +boolean +draw_will_inject_frontface(const struct draw_context *draw) +{ + unsigned reduced_prim = u_reduced_prim(draw->pt.prim); + const struct pipe_rasterizer_state *rast = draw->rasterizer; + + if (reduced_prim != PIPE_PRIM_TRIANGLES) { + return FALSE; + } + + return (rast && + (rast->fill_front != PIPE_POLYGON_MODE_FILL || + rast->fill_back != PIPE_POLYGON_MODE_FILL)); +} |
