diff options
Diffstat (limited to 'src/gallium/drivers/softpipe')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_context.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_context.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_quad_depth_test.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_quad_pipe.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_setup.c | 120 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_state_rasterizer.c | 2 |
6 files changed, 92 insertions, 49 deletions
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index d0c2978c24..9dcb5586c6 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -93,6 +93,7 @@ softpipe_destroy( struct pipe_context *pipe ) softpipe->quad.shade->destroy( softpipe->quad.shade ); softpipe->quad.depth_test->destroy( softpipe->quad.depth_test ); softpipe->quad.blend->destroy( softpipe->quad.blend ); + softpipe->quad.pstipple->destroy( softpipe->quad.pstipple ); for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { sp_destroy_tile_cache(softpipe->cbuf_cache[i]); @@ -296,12 +297,13 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->quad.shade = sp_quad_shade_stage(softpipe); softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe); softpipe->quad.blend = sp_quad_blend_stage(softpipe); + softpipe->quad.pstipple = sp_quad_polygon_stipple_stage(softpipe); /* * Create drawing context and plug our rendering stage into it. */ - softpipe->draw = draw_create(); + softpipe->draw = draw_create(&softpipe->pipe); if (!softpipe->draw) goto fail; @@ -330,7 +332,9 @@ softpipe_create_context( struct pipe_screen *screen, draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe); /* Do polygon stipple w/ texture map + frag prog? */ +#if DO_PSTIPPLE_IN_DRAW_MODULE draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe); +#endif sp_init_surface_functions(softpipe); diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index be8f2cb3e0..92607874b6 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -38,6 +38,10 @@ #include "sp_quad_pipe.h" +/** Do polygon stipple in the driver here, or in the draw module? */ +#define DO_PSTIPPLE_IN_DRAW_MODULE 1 + + struct softpipe_vbuf_render; struct draw_context; struct draw_stage; @@ -126,6 +130,7 @@ struct softpipe_context { struct quad_stage *shade; struct quad_stage *depth_test; struct quad_stage *blend; + struct quad_stage *pstipple; struct quad_stage *first; /**< points to one of the above stages */ } quad; diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 4ee31969e6..72117c233e 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -520,6 +520,9 @@ depth_stencil_test_quad(struct quad_stage *qs, face = 0; } + /* 0 = front-face, 1 = back-face */ + assert(face == 0 || face == 1); + /* choose front or back face function, operator, etc */ /* XXX we could do these initializations once per primitive */ func = softpipe->depth_stencil->stencil[face].func; diff --git a/src/gallium/drivers/softpipe/sp_quad_pipe.c b/src/gallium/drivers/softpipe/sp_quad_pipe.c index 1b5bab4eca..43b8e88e33 100644 --- a/src/gallium/drivers/softpipe/sp_quad_pipe.c +++ b/src/gallium/drivers/softpipe/sp_quad_pipe.c @@ -59,5 +59,10 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp_push_quad_first( sp, sp->quad.depth_test ); sp_push_quad_first( sp, sp->quad.shade ); } + +#if !DO_PSTIPPLE_IN_DRAW_MODULE + if (sp->rasterizer->poly_stipple_enable) + sp_push_quad_first( sp, sp->quad.pstipple ); +#endif } diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index e136cb7cf7..86354664e4 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -47,6 +47,7 @@ #define DEBUG_VERTS 0 #define DEBUG_FRAGS 0 + /** * Triangle edge info */ @@ -59,11 +60,16 @@ struct edge { }; +/** + * Max number of quads (2x2 pixel blocks) to process per batch. + * This can't be arbitrarily increased since we depend on some 32-bit + * bitmasks (two bits per quad). + */ #define MAX_QUADS 16 /** - * Triangle setup info (derived from draw_stage). + * Triangle setup info. * Also used for line drawing (taking some liberties). */ struct setup_context { @@ -140,7 +146,7 @@ cull_tri(const struct setup_context *setup, float det) * Clip setup->quad against the scissor/surface bounds. */ static INLINE void -quad_clip( struct setup_context *setup, struct quad_header *quad ) +quad_clip(struct setup_context *setup, struct quad_header *quad) { const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect; const int minx = (int) cliprect->minx; @@ -171,7 +177,7 @@ quad_clip( struct setup_context *setup, struct quad_header *quad ) * Emit a quad (pass to next stage) with clipping. */ static INLINE void -clip_emit_quad( struct setup_context *setup, struct quad_header *quad ) +clip_emit_quad(struct setup_context *setup, struct quad_header *quad) { quad_clip( setup, quad ); @@ -188,12 +194,15 @@ clip_emit_quad( struct setup_context *setup, struct quad_header *quad ) * Given an X or Y coordinate, return the block/quad coordinate that it * belongs to. */ -static INLINE int block( int x ) +static INLINE int +block(int x) { return x & ~(2-1); } -static INLINE int block_x( int x ) + +static INLINE int +block_x(int x) { return x & ~(16-1); } @@ -202,9 +211,10 @@ static INLINE int block_x( int x ) /** * Render a horizontal span of quads */ -static void flush_spans( struct setup_context *setup ) +static void +flush_spans(struct setup_context *setup) { - const int step = 16; + const int step = MAX_QUADS; const int xleft0 = setup->span.left[0]; const int xleft1 = setup->span.left[1]; const int xright0 = setup->span.right[0]; @@ -265,8 +275,9 @@ static void flush_spans( struct setup_context *setup ) #if DEBUG_VERTS -static void print_vertex(const struct setup_context *setup, - const float (*v)[4]) +static void +print_vertex(const struct setup_context *setup, + const float (*v)[4]) { int i; debug_printf(" Vertex: (%p)\n", (void *) v); @@ -280,16 +291,18 @@ static void print_vertex(const struct setup_context *setup, } #endif + /** * Sort the vertices from top to bottom order, setting up the triangle * edge fields (ebot, emaj, etop). * \return FALSE if coords are inf/nan (cull the tri), TRUE otherwise */ -static boolean setup_sort_vertices( struct setup_context *setup, - float det, - const float (*v0)[4], - const float (*v1)[4], - const float (*v2)[4] ) +static boolean +setup_sort_vertices(struct setup_context *setup, + float det, + const float (*v0)[4], + const float (*v1)[4], + const float (*v2)[4]) { setup->vprovoke = v2; @@ -374,6 +387,7 @@ static boolean setup_sort_vertices( struct setup_context *setup, /* We need to know if this is a front or back-facing triangle for: * - the GLSL gl_FrontFacing fragment attribute (bool) * - two-sided stencil test + * 0 = front-facing, 1 = back-facing */ setup->facing = ((det > 0.0) ^ @@ -446,9 +460,10 @@ tri_apply_cylindrical_wrap(float v0, * \param slot which attribute slot * \param i which component of the slot (0..3) */ -static void const_coeff( struct setup_context *setup, - struct tgsi_interp_coef *coef, - uint vertSlot, uint i) +static void +const_coeff(struct setup_context *setup, + struct tgsi_interp_coef *coef, + uint vertSlot, uint i) { assert(i <= 3); @@ -590,7 +605,8 @@ setup_fragcoord_coeff(struct setup_context *setup, uint slot) * Compute the setup->coef[] array dadx, dady, a0 values. * Must be called after setup->vmin,vmid,vmax,vprovoke are initialized. */ -static void setup_tri_coefficients( struct setup_context *setup ) +static void +setup_tri_coefficients(struct setup_context *setup) { struct softpipe_context *softpipe = setup->softpipe; const struct sp_fragment_shader *spfs = softpipe->fs; @@ -649,7 +665,8 @@ static void setup_tri_coefficients( struct setup_context *setup ) } if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) { - setup->coef[fragSlot].a0[0] = 1.0f - setup->facing; + /* convert 0 to 1.0 and 1 to -1.0 */ + setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f; setup->coef[fragSlot].dadx[0] = 0.0; setup->coef[fragSlot].dady[0] = 0.0; } @@ -657,8 +674,8 @@ static void setup_tri_coefficients( struct setup_context *setup ) } - -static void setup_tri_edges( struct setup_context *setup ) +static void +setup_tri_edges(struct setup_context *setup) { float vmin_x = setup->vmin[0][0] + setup->pixel_offset; float vmid_x = setup->vmid[0][0] + setup->pixel_offset; @@ -669,17 +686,17 @@ static void setup_tri_edges( struct setup_context *setup ) setup->emaj.sy = ceilf(vmin_y); setup->emaj.lines = (int) ceilf(vmax_y - setup->emaj.sy); - setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy; + setup->emaj.dxdy = setup->emaj.dy ? setup->emaj.dx / setup->emaj.dy : .0f; setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy; setup->etop.sy = ceilf(vmid_y); setup->etop.lines = (int) ceilf(vmax_y - setup->etop.sy); - setup->etop.dxdy = setup->etop.dx / setup->etop.dy; + setup->etop.dxdy = setup->etop.dy ? setup->etop.dx / setup->etop.dy : .0f; setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy; setup->ebot.sy = ceilf(vmin_y); setup->ebot.lines = (int) ceilf(vmid_y - setup->ebot.sy); - setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy; + setup->ebot.dxdy = setup->ebot.dy ? setup->ebot.dx / setup->ebot.dy : .0f; setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy; } @@ -688,10 +705,11 @@ static void setup_tri_edges( struct setup_context *setup ) * Render the upper or lower half of a triangle. * Scissoring/cliprect is applied here too. */ -static void subtriangle( struct setup_context *setup, - struct edge *eleft, - struct edge *eright, - int lines ) +static void +subtriangle(struct setup_context *setup, + struct edge *eleft, + struct edge *eright, + int lines) { const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect; const int minx = (int) cliprect->minx; @@ -765,9 +783,9 @@ static void subtriangle( struct setup_context *setup, * calculate it here. */ static float -calc_det( const float (*v0)[4], - const float (*v1)[4], - const float (*v2)[4] ) +calc_det(const float (*v0)[4], + const float (*v1)[4], + const float (*v2)[4]) { /* edge vectors e = v0 - v2, f = v1 - v2 */ const float ex = v0[0][0] - v2[0][0]; @@ -783,10 +801,11 @@ calc_det( const float (*v0)[4], /** * Do setup for triangle rasterization, then render the triangle. */ -void sp_setup_tri( struct setup_context *setup, - const float (*v0)[4], - const float (*v1)[4], - const float (*v2)[4] ) +void +sp_setup_tri(struct setup_context *setup, + const float (*v0)[4], + const float (*v1)[4], + const float (*v2)[4]) { float det; @@ -926,7 +945,7 @@ line_persp_coeff(const struct setup_context *setup, * Compute the setup->coef[] array dadx, dady, a0 values. * Must be called after setup->vmin,vmax are initialized. */ -static INLINE boolean +static boolean setup_line_coefficients(struct setup_context *setup, const float (*v0)[4], const float (*v1)[4]) @@ -1002,7 +1021,8 @@ setup_line_coefficients(struct setup_context *setup, } if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) { - setup->coef[fragSlot].a0[0] = 1.0f - setup->facing; + /* convert 0 to 1.0 and 1 to -1.0 */ + setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f; setup->coef[fragSlot].dadx[0] = 0.0; setup->coef[fragSlot].dady[0] = 0.0; } @@ -1047,8 +1067,8 @@ plot(struct setup_context *setup, int x, int y) */ void sp_setup_line(struct setup_context *setup, - const float (*v0)[4], - const float (*v1)[4]) + const float (*v0)[4], + const float (*v1)[4]) { int x0 = (int) v0[0][0]; int x1 = (int) v1[0][0]; @@ -1176,8 +1196,8 @@ point_persp_coeff(const struct setup_context *setup, * XXX could optimize a lot for 1-pixel points. */ void -sp_setup_point( struct setup_context *setup, - const float (*v0)[4] ) +sp_setup_point(struct setup_context *setup, + const float (*v0)[4]) { struct softpipe_context *softpipe = setup->softpipe; const struct sp_fragment_shader *spfs = softpipe->fs; @@ -1248,7 +1268,8 @@ sp_setup_point( struct setup_context *setup, } if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) { - setup->coef[fragSlot].a0[0] = 1.0f - setup->facing; + /* convert 0 to 1.0 and 1 to -1.0 */ + setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f; setup->coef[fragSlot].dadx[0] = 0.0; setup->coef[fragSlot].dady[0] = 0.0; } @@ -1377,7 +1398,12 @@ sp_setup_point( struct setup_context *setup, } } -void sp_setup_prepare( struct setup_context *setup ) + +/** + * Called by vbuf code just before we start buffering primitives. + */ +void +sp_setup_prepare(struct setup_context *setup) { struct softpipe_context *sp = setup->softpipe; @@ -1403,8 +1429,8 @@ void sp_setup_prepare( struct setup_context *setup ) } - -void sp_setup_destroy_context( struct setup_context *setup ) +void +sp_setup_destroy_context(struct setup_context *setup) { FREE( setup ); } @@ -1413,7 +1439,8 @@ void sp_setup_destroy_context( struct setup_context *setup ) /** * Create a new primitive setup/render stage. */ -struct setup_context *sp_setup_create_context( struct softpipe_context *softpipe ) +struct setup_context * +sp_setup_create_context(struct softpipe_context *softpipe) { struct setup_context *setup = CALLOC_STRUCT(setup_context); unsigned i; @@ -1430,4 +1457,3 @@ struct setup_context *sp_setup_create_context( struct softpipe_context *softpipe return setup; } - diff --git a/src/gallium/drivers/softpipe/sp_state_rasterizer.c b/src/gallium/drivers/softpipe/sp_state_rasterizer.c index a5b00336d4..c9ede09f26 100644 --- a/src/gallium/drivers/softpipe/sp_state_rasterizer.c +++ b/src/gallium/drivers/softpipe/sp_state_rasterizer.c @@ -49,7 +49,7 @@ void softpipe_bind_rasterizer_state(struct pipe_context *pipe, return; /* pass-through to draw module */ - draw_set_rasterizer_state(softpipe->draw, rasterizer); + draw_set_rasterizer_state(softpipe->draw, rasterizer, rasterizer); softpipe->rasterizer = rasterizer; |