From c5c5cd7132e18f4aad8e73d8ee879f8823c4c1e7 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 22 Feb 2010 22:02:58 -0500 Subject: gallium/draw: initial code to properly support llvm in the draw module code generate big chunks of the vertex pipeline in order to speed up software vertex processing. --- src/gallium/auxiliary/draw/draw_context.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_context.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index d5ddc4a6a92..6fa73ad56ba 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -44,6 +44,18 @@ struct draw_context *draw_create( void ) if (draw == NULL) goto fail; + if (!draw_init(draw)) + goto fail; + + return draw; + +fail: + draw_destroy( draw ); + return NULL; +} + +boolean draw_init(struct draw_context *draw) +{ ASSIGN_4V( draw->plane[0], -1, 0, 0, 1 ); ASSIGN_4V( draw->plane[1], 1, 0, 0, 1 ); ASSIGN_4V( draw->plane[2], 0, -1, 0, 1 ); @@ -57,22 +69,18 @@ struct draw_context *draw_create( void ) if (!draw_pipeline_init( draw )) - goto fail; + return FALSE; if (!draw_pt_init( draw )) - goto fail; + return FALSE; if (!draw_vs_init( draw )) - goto fail; + return FALSE; if (!draw_gs_init( draw )) - goto fail; + return FALSE; - return draw; - -fail: - draw_destroy( draw ); - return NULL; + return TRUE; } -- cgit v1.2.3 From b609cfc7c9c38f26e7e6d6f7dd5dd6d38f4ed209 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 18 Apr 2010 09:45:54 +0200 Subject: draw: Cosmetic cleanups and comments. --- src/gallium/auxiliary/draw/draw_context.c | 6 ++++++ src/gallium/auxiliary/draw/draw_pipe.c | 2 +- src/gallium/auxiliary/draw/draw_pipe_vbuf.c | 2 +- src/gallium/auxiliary/draw/draw_vertex.h | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_context.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index b6574a9fea1..99f4e6dd2a8 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -56,6 +56,12 @@ fail: boolean draw_init(struct draw_context *draw) { + /* + * Note that several functions compute the clipmask of the predefined + * formats with hardcoded formulas instead of using these. So modifications + * here must be reflected there too. + */ + ASSIGN_4V( draw->plane[0], -1, 0, 0, 1 ); ASSIGN_4V( draw->plane[1], 1, 0, 0, 1 ); ASSIGN_4V( draw->plane[2], 0, -1, 0, 1 ); diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c index 83dc1a35f4c..b8f57dde6d8 100644 --- a/src/gallium/auxiliary/draw/draw_pipe.c +++ b/src/gallium/auxiliary/draw/draw_pipe.c @@ -225,7 +225,7 @@ static void do_triangle( struct draw_context *draw, /** - * Code to run the pipeline on a fairly arbitary collection of vertices. + * Code to run the pipeline on a fairly arbitrary collection of vertices. * For drawing indexed primitives. * * Vertex headers must be pre-initialized with the diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c index 1c7db0005a9..ee2b8116032 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c +++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c @@ -235,7 +235,7 @@ vbuf_start_prim( struct vbuf_stage *vbuf, uint prim ) for (i = 0; i < vbuf->vinfo->num_attribs; i++) { unsigned emit_sz = 0; unsigned src_buffer = 0; - unsigned output_format; + enum pipe_format output_format; unsigned src_offset = (vbuf->vinfo->attrib[i].src_index * 4 * sizeof(float) ); output_format = draw_translate_vinfo_format(vbuf->vinfo->attrib[i].emit); diff --git a/src/gallium/auxiliary/draw/draw_vertex.h b/src/gallium/auxiliary/draw/draw_vertex.h index ca272371267..3af31ffe126 100644 --- a/src/gallium/auxiliary/draw/draw_vertex.h +++ b/src/gallium/auxiliary/draw/draw_vertex.h @@ -142,7 +142,7 @@ void draw_dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data); -static INLINE unsigned draw_translate_vinfo_format(enum attrib_emit emit) +static INLINE enum pipe_format draw_translate_vinfo_format(enum attrib_emit emit) { switch (emit) { case EMIT_OMIT: @@ -166,7 +166,7 @@ static INLINE unsigned draw_translate_vinfo_format(enum attrib_emit emit) } } -static INLINE unsigned draw_translate_vinfo_size(enum attrib_emit emit) +static INLINE enum attrib_emit draw_translate_vinfo_size(enum attrib_emit emit) { switch (emit) { case EMIT_OMIT: -- cgit v1.2.3 From e3a34cc7f6c9f959cdc2af4486e84587fab4d0d7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 19 Apr 2010 08:35:53 -0600 Subject: gallium/draw: use correct rasterization state for wide/AA points/lines When points or lines are decomposed into triangles, we need to be sure to disable polygon culling, stippling, "un-filled" modes, etc. This patch sets the rasterization state to disable those things prior to drawing points/lines with triangles, then restores the previous state afterward. The new piglit point-no-line-cull test checks this problem & solution. --- src/gallium/auxiliary/draw/draw_context.c | 65 ++++++++++++++++++++-- src/gallium/auxiliary/draw/draw_context.h | 5 +- src/gallium/auxiliary/draw/draw_pipe_aaline.c | 49 ++++++++++------ src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 39 ++++++++----- src/gallium/auxiliary/draw/draw_pipe_wide_line.c | 34 ++++++++++- src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 20 +++++++ src/gallium/auxiliary/draw/draw_private.h | 15 ++++- src/gallium/drivers/i915/i915_context.c | 2 +- src/gallium/drivers/i915/i915_state.c | 3 +- src/gallium/drivers/llvmpipe/lp_context.c | 2 +- src/gallium/drivers/llvmpipe/lp_state_rasterizer.c | 14 ++++- src/gallium/drivers/nv50/nv50_context.c | 2 +- src/gallium/drivers/r300/r300_context.c | 2 +- src/gallium/drivers/r300/r300_state.c | 2 +- src/gallium/drivers/softpipe/sp_context.c | 2 +- src/gallium/drivers/softpipe/sp_state_rasterizer.c | 2 +- src/gallium/drivers/svga/svga_pipe_rasterizer.c | 3 +- src/gallium/drivers/svga/svga_swtnl_draw.c | 2 +- src/gallium/drivers/svga/svga_swtnl_state.c | 3 +- src/mesa/state_tracker/st_context.c | 2 +- src/mesa/state_tracker/st_draw_feedback.c | 2 +- 21 files changed, 213 insertions(+), 57 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_context.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index bb0988543f5..18435af8482 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -31,6 +31,7 @@ */ +#include "pipe/p_context.h" #include "util/u_memory.h" #include "util/u_math.h" #include "draw_context.h" @@ -38,7 +39,7 @@ #include "draw_gs.h" -struct draw_context *draw_create( void ) +struct draw_context *draw_create( struct pipe_context *pipe ) { struct draw_context *draw = CALLOC_STRUCT( draw_context ); if (draw == NULL) @@ -68,6 +69,8 @@ struct draw_context *draw_create( void ) if (!draw_gs_init( draw )) goto fail; + draw->pipe = pipe; + return draw; fail: @@ -78,10 +81,21 @@ fail: void draw_destroy( struct draw_context *draw ) { + struct pipe_context *pipe = draw->pipe; + int i, j; + if (!draw) return; - + /* free any rasterizer CSOs that we may have created. + */ + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + if (draw->rasterizer_no_cull[i][j]) { + pipe->delete_rasterizer_state(pipe, draw->rasterizer_no_cull[i][j]); + } + } + } /* Not so fast -- we're just borrowing this at the moment. * @@ -123,12 +137,17 @@ void draw_set_mrd(struct draw_context *draw, double mrd) * This causes the drawing pipeline to be rebuilt. */ void draw_set_rasterizer_state( struct draw_context *draw, - const struct pipe_rasterizer_state *raster ) + const struct pipe_rasterizer_state *raster, + void *rast_handle ) { - draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); + if (!draw->suspend_flushing) { + draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); - draw->rasterizer = raster; - draw->bypass_clipping = draw->driver.bypass_clipping; + draw->rasterizer = raster; + draw->rast_handle = rast_handle; + + draw->bypass_clipping = draw->driver.bypass_clipping; + } } @@ -481,3 +500,37 @@ draw_current_shader_position_output(const struct draw_context *draw) return draw->gs.position_output; return draw->vs.position_output; } + + +/** + * Return a pointer/handle for a driver/CSO rasterizer object which + * disabled culling, stippling, unfilled tris, etc. + * This is used by some pipeline stages (such as wide_point, aa_line + * and aa_point) which convert points/lines into triangles. In those + * cases we don't want to accidentally cull the triangles. + * + * \param scissor should the rasterizer state enable scissoring? + * \param flatshade should the rasterizer state use flat shading? + * \return rasterizer CSO handle + */ +void * +draw_get_rasterizer_no_cull( struct draw_context *draw, + boolean scissor, + boolean flatshade ) +{ + if (!draw->rasterizer_no_cull[scissor][flatshade]) { + /* create now */ + struct pipe_context *pipe = draw->pipe; + struct pipe_rasterizer_state rast; + + memset(&rast, 0, sizeof(rast)); + rast.scissor = scissor; + rast.flatshade = flatshade; + rast.front_winding = PIPE_WINDING_CCW; + rast.gl_rasterization_rules = draw->rasterizer->gl_rasterization_rules; + + draw->rasterizer_no_cull[scissor][flatshade] = + pipe->create_rasterizer_state(pipe, &rast); + } + return draw->rasterizer_no_cull[scissor][flatshade]; +} diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index acd81b9712d..3b21a881703 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -49,7 +49,7 @@ struct draw_geometry_shader; struct tgsi_sampler; -struct draw_context *draw_create( void ); +struct draw_context *draw_create( struct pipe_context *pipe ); void draw_destroy( struct draw_context *draw ); @@ -60,7 +60,8 @@ void draw_set_clip_state( struct draw_context *pipe, const struct pipe_clip_state *clip ); void draw_set_rasterizer_state( struct draw_context *draw, - const struct pipe_rasterizer_state *raster ); + const struct pipe_rasterizer_state *raster, + void *rast_handle ); void draw_set_rasterize_stage( struct draw_context *draw, struct draw_stage *stage ); diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 8f6ca15dfa2..72d7480efba 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -113,8 +113,6 @@ struct aaline_stage void **); void (*driver_set_sampler_textures)(struct pipe_context *, unsigned, struct pipe_texture **); - - struct pipe_context *pipe; }; @@ -339,6 +337,7 @@ aa_transform_inst(struct tgsi_transform_context *ctx, static boolean generate_aaline_fs(struct aaline_stage *aaline) { + struct pipe_context *pipe = aaline->stage.draw->pipe; const struct pipe_shader_state *orig_fs = &aaline->fs->state; struct pipe_shader_state aaline_fs; struct aa_transform_context transform; @@ -371,7 +370,7 @@ generate_aaline_fs(struct aaline_stage *aaline) aaline->fs->sampler_unit = transform.freeSampler; aaline->fs->aaline_fs - = aaline->driver_create_fs_state(aaline->pipe, &aaline_fs); + = aaline->driver_create_fs_state(pipe, &aaline_fs); if (aaline->fs->aaline_fs == NULL) goto fail; @@ -391,7 +390,7 @@ fail: static boolean aaline_create_texture(struct aaline_stage *aaline) { - struct pipe_context *pipe = aaline->pipe; + struct pipe_context *pipe = aaline->stage.draw->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_texture texTemp; uint level; @@ -464,7 +463,7 @@ static boolean aaline_create_sampler(struct aaline_stage *aaline) { struct pipe_sampler_state sampler; - struct pipe_context *pipe = aaline->pipe; + struct pipe_context *pipe = aaline->stage.draw->pipe; memset(&sampler, 0, sizeof(sampler)); sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; @@ -493,13 +492,14 @@ static boolean bind_aaline_fragment_shader(struct aaline_stage *aaline) { struct draw_context *draw = aaline->stage.draw; + struct pipe_context *pipe = draw->pipe; if (!aaline->fs->aaline_fs && !generate_aaline_fs(aaline)) return FALSE; draw->suspend_flushing = TRUE; - aaline->driver_bind_fs_state(aaline->pipe, aaline->fs->aaline_fs); + aaline->driver_bind_fs_state(pipe, aaline->fs->aaline_fs); draw->suspend_flushing = FALSE; return TRUE; @@ -639,8 +639,10 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header) { auto struct aaline_stage *aaline = aaline_stage(stage); struct draw_context *draw = stage->draw; - struct pipe_context *pipe = aaline->pipe; + struct pipe_context *pipe = draw->pipe; + const struct pipe_rasterizer_state *rast = draw->rasterizer; uint num_samplers; + void *r; assert(draw->rasterizer->line_smooth); @@ -679,6 +681,11 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header) draw->suspend_flushing = TRUE; aaline->driver_bind_sampler_states(pipe, num_samplers, aaline->state.sampler); aaline->driver_set_sampler_textures(pipe, num_samplers, aaline->state.texture); + + /* Disable triangle culling, stippling, unfilled mode etc. */ + r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade); + pipe->bind_rasterizer_state(pipe, r); + draw->suspend_flushing = FALSE; /* now really draw first line */ @@ -692,7 +699,7 @@ aaline_flush(struct draw_stage *stage, unsigned flags) { struct draw_context *draw = stage->draw; struct aaline_stage *aaline = aaline_stage(stage); - struct pipe_context *pipe = aaline->pipe; + struct pipe_context *pipe = draw->pipe; stage->line = aaline_first_line; stage->next->flush( stage->next, flags ); @@ -704,6 +711,12 @@ aaline_flush(struct draw_stage *stage, unsigned flags) aaline->state.sampler); aaline->driver_set_sampler_textures(pipe, aaline->num_textures, aaline->state.texture); + + /* restore original rasterizer state */ + if (draw->rast_handle) { + pipe->bind_rasterizer_state(pipe, draw->rast_handle); + } + draw->suspend_flushing = FALSE; draw->extra_shader_outputs.slot = 0; @@ -721,6 +734,7 @@ static void aaline_destroy(struct draw_stage *stage) { struct aaline_stage *aaline = aaline_stage(stage); + struct pipe_context *pipe = stage->draw->pipe; uint i; for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { @@ -728,7 +742,7 @@ aaline_destroy(struct draw_stage *stage) } if (aaline->sampler_cso) - aaline->pipe->delete_sampler_state(aaline->pipe, aaline->sampler_cso); + pipe->delete_sampler_state(pipe, aaline->sampler_cso); if (aaline->texture) pipe_texture_reference(&aaline->texture, NULL); @@ -787,13 +801,14 @@ aaline_create_fs_state(struct pipe_context *pipe, { struct aaline_stage *aaline = aaline_stage_from_pipe(pipe); struct aaline_fragment_shader *aafs = CALLOC_STRUCT(aaline_fragment_shader); + if (aafs == NULL) return NULL; aafs->state = *fs; /* pass-through */ - aafs->driver_fs = aaline->driver_create_fs_state(aaline->pipe, fs); + aafs->driver_fs = aaline->driver_create_fs_state(pipe, fs); return aafs; } @@ -808,8 +823,7 @@ aaline_bind_fs_state(struct pipe_context *pipe, void *fs) /* save current */ aaline->fs = aafs; /* pass-through */ - aaline->driver_bind_fs_state(aaline->pipe, - (aafs ? aafs->driver_fs : NULL)); + aaline->driver_bind_fs_state(pipe, (aafs ? aafs->driver_fs : NULL)); } @@ -818,11 +832,12 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs) { struct aaline_stage *aaline = aaline_stage_from_pipe(pipe); struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs; + /* pass-through */ - aaline->driver_delete_fs_state(aaline->pipe, aafs->driver_fs); + aaline->driver_delete_fs_state(pipe, aafs->driver_fs); if (aafs->aaline_fs) - aaline->driver_delete_fs_state(aaline->pipe, aafs->aaline_fs); + aaline->driver_delete_fs_state(pipe, aafs->aaline_fs); FREE(aafs); } @@ -839,7 +854,7 @@ aaline_bind_sampler_states(struct pipe_context *pipe, aaline->num_samplers = num; /* pass-through */ - aaline->driver_bind_sampler_states(aaline->pipe, num, sampler); + aaline->driver_bind_sampler_states(pipe, num, sampler); } @@ -860,7 +875,7 @@ aaline_set_sampler_textures(struct pipe_context *pipe, aaline->num_textures = num; /* pass-through */ - aaline->driver_set_sampler_textures(aaline->pipe, num, texture); + aaline->driver_set_sampler_textures(pipe, num, texture); } @@ -883,8 +898,6 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe) if (!aaline) goto fail; - aaline->pipe = pipe; - /* create special texture, sampler state */ if (!aaline_create_texture(aaline)) goto fail; diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c index 9f9fb4312c1..bba6f50c020 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c @@ -107,8 +107,6 @@ struct aapoint_stage const struct pipe_shader_state *); void (*driver_bind_fs_state)(struct pipe_context *, void *); void (*driver_delete_fs_state)(struct pipe_context *, void *); - - struct pipe_context *pipe; }; @@ -499,6 +497,7 @@ generate_aapoint_fs(struct aapoint_stage *aapoint) struct pipe_shader_state aapoint_fs; struct aa_transform_context transform; const uint newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS; + struct pipe_context *pipe = aapoint->stage.draw->pipe; aapoint_fs = *orig_fs; /* copy to init */ aapoint_fs.tokens = tgsi_alloc_tokens(newLen); @@ -527,7 +526,7 @@ generate_aapoint_fs(struct aapoint_stage *aapoint) #endif aapoint->fs->aapoint_fs - = aapoint->driver_create_fs_state(aapoint->pipe, &aapoint_fs); + = aapoint->driver_create_fs_state(pipe, &aapoint_fs); if (aapoint->fs->aapoint_fs == NULL) goto fail; @@ -549,13 +548,14 @@ static boolean bind_aapoint_fragment_shader(struct aapoint_stage *aapoint) { struct draw_context *draw = aapoint->stage.draw; + struct pipe_context *pipe = draw->pipe; if (!aapoint->fs->aapoint_fs && !generate_aapoint_fs(aapoint)) return FALSE; draw->suspend_flushing = TRUE; - aapoint->driver_bind_fs_state(aapoint->pipe, aapoint->fs->aapoint_fs); + aapoint->driver_bind_fs_state(pipe, aapoint->fs->aapoint_fs); draw->suspend_flushing = FALSE; return TRUE; @@ -679,6 +679,9 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header) { auto struct aapoint_stage *aapoint = aapoint_stage(stage); struct draw_context *draw = stage->draw; + struct pipe_context *pipe = draw->pipe; + const struct pipe_rasterizer_state *rast = draw->rasterizer; + void *r; assert(draw->rasterizer->point_smooth); @@ -716,6 +719,14 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header) } } + draw->suspend_flushing = TRUE; + + /* Disable triangle culling, stippling, unfilled mode etc. */ + r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade); + pipe->bind_rasterizer_state(pipe, r); + + draw->suspend_flushing = FALSE; + /* now really draw first point */ stage->point = aapoint_point; stage->point(stage, header); @@ -727,7 +738,7 @@ aapoint_flush(struct draw_stage *stage, unsigned flags) { struct draw_context *draw = stage->draw; struct aapoint_stage *aapoint = aapoint_stage(stage); - struct pipe_context *pipe = aapoint->pipe; + struct pipe_context *pipe = draw->pipe; stage->point = aapoint_first_point; stage->next->flush( stage->next, flags ); @@ -735,6 +746,12 @@ aapoint_flush(struct draw_stage *stage, unsigned flags) /* restore original frag shader */ draw->suspend_flushing = TRUE; aapoint->driver_bind_fs_state(pipe, aapoint->fs->driver_fs); + + /* restore original rasterizer state */ + if (draw->rast_handle) { + pipe->bind_rasterizer_state(pipe, draw->rast_handle); + } + draw->suspend_flushing = FALSE; draw->extra_shader_outputs.slot = 0; @@ -811,7 +828,7 @@ aapoint_create_fs_state(struct pipe_context *pipe, aafs->state = *fs; /* pass-through */ - aafs->driver_fs = aapoint->driver_create_fs_state(aapoint->pipe, fs); + aafs->driver_fs = aapoint->driver_create_fs_state(pipe, fs); return aafs; } @@ -825,7 +842,7 @@ aapoint_bind_fs_state(struct pipe_context *pipe, void *fs) /* save current */ aapoint->fs = aafs; /* pass-through */ - aapoint->driver_bind_fs_state(aapoint->pipe, + aapoint->driver_bind_fs_state(pipe, (aafs ? aafs->driver_fs : NULL)); } @@ -837,10 +854,10 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs) struct aapoint_fragment_shader *aafs = (struct aapoint_fragment_shader *) fs; /* pass-through */ - aapoint->driver_delete_fs_state(aapoint->pipe, aafs->driver_fs); + aapoint->driver_delete_fs_state(pipe, aafs->driver_fs); if (aafs->aapoint_fs) - aapoint->driver_delete_fs_state(aapoint->pipe, aafs->aapoint_fs); + aapoint->driver_delete_fs_state(pipe, aafs->aapoint_fs); FREE(aafs); } @@ -857,8 +874,6 @@ draw_install_aapoint_stage(struct draw_context *draw, { struct aapoint_stage *aapoint; - pipe->draw = (void *) draw; - /* * Create / install AA point drawing / prim stage */ @@ -866,8 +881,6 @@ draw_install_aapoint_stage(struct draw_context *draw, if (aapoint == NULL) return FALSE; - aapoint->pipe = pipe; - /* save original driver functions */ aapoint->driver_create_fs_state = pipe->create_fs_state; aapoint->driver_bind_fs_state = pipe->bind_fs_state; diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c index 3073c870825..265a420d01e 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c @@ -28,6 +28,7 @@ /* Authors: Keith Whitwell */ +#include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" #include "util/u_math.h" @@ -142,9 +143,40 @@ static void wideline_line( struct draw_stage *stage, } +static void wideline_first_line( struct draw_stage *stage, + struct prim_header *header ) +{ + struct draw_context *draw = stage->draw; + struct pipe_context *pipe = draw->pipe; + const struct pipe_rasterizer_state *rast = draw->rasterizer; + void *r; + + /* Disable triangle culling, stippling, unfilled mode etc. */ + r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade); + draw->suspend_flushing = TRUE; + pipe->bind_rasterizer_state(pipe, r); + draw->suspend_flushing = FALSE; + + stage->line = wideline_line; + + wideline_line(stage, header); +} + + static void wideline_flush( struct draw_stage *stage, unsigned flags ) { + struct draw_context *draw = stage->draw; + struct pipe_context *pipe = draw->pipe; + + stage->line = wideline_first_line; stage->next->flush( stage->next, flags ); + + /* restore original rasterizer state */ + if (draw->rast_handle) { + draw->suspend_flushing = TRUE; + pipe->bind_rasterizer_state(pipe, draw->rast_handle); + draw->suspend_flushing = FALSE; + } } @@ -171,7 +203,7 @@ struct draw_stage *draw_wide_line_stage( struct draw_context *draw ) wide->stage.name = "wide-line"; wide->stage.next = NULL; wide->stage.point = draw_pipe_passthrough_point; - wide->stage.line = wideline_line; + wide->stage.line = wideline_first_line; wide->stage.tri = draw_pipe_passthrough_tri; wide->stage.flush = wideline_flush; wide->stage.reset_stipple_counter = wideline_reset_stipple_counter; diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c index fdabce7d443..d6d7513e2af 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c @@ -52,6 +52,7 @@ */ +#include "pipe/p_context.h" #include "util/u_math.h" #include "util/u_memory.h" #include "pipe/p_defines.h" @@ -213,6 +214,9 @@ static void widepoint_first_point( struct draw_stage *stage, { struct widepoint_stage *wide = widepoint_stage(stage); struct draw_context *draw = stage->draw; + struct pipe_context *pipe = draw->pipe; + const struct pipe_rasterizer_state *rast = draw->rasterizer; + void *r; wide->half_point_size = 0.5f * draw->rasterizer->point_size; wide->xbias = 0.0; @@ -222,6 +226,12 @@ static void widepoint_first_point( struct draw_stage *stage, wide->xbias = 0.125; } + /* Disable triangle culling, stippling, unfilled mode etc. */ + r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade); + draw->suspend_flushing = TRUE; + pipe->bind_rasterizer_state(pipe, r); + draw->suspend_flushing = FALSE; + /* XXX we won't know the real size if it's computed by the vertex shader! */ if ((draw->rasterizer->point_size > draw->pipeline.wide_point_threshold) || (draw->rasterizer->sprite_coord_enable && draw->pipeline.point_sprite)) { @@ -277,9 +287,19 @@ static void widepoint_first_point( struct draw_stage *stage, static void widepoint_flush( struct draw_stage *stage, unsigned flags ) { + struct draw_context *draw = stage->draw; + struct pipe_context *pipe = draw->pipe; + stage->point = widepoint_first_point; stage->next->flush( stage->next, flags ); stage->draw->extra_shader_outputs.slot = 0; + + /* restore original rasterizer state */ + if (draw->rast_handle) { + draw->suspend_flushing = TRUE; + pipe->bind_rasterizer_state(pipe, draw->rast_handle); + draw->suspend_flushing = FALSE; + } } diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 1e6e01af9e2..3fe3dc519d4 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -82,6 +82,8 @@ struct vertex_header { */ struct draw_context { + struct pipe_context *pipe; + /** Drawing/primitive pipeline stages */ struct { struct draw_stage *first; /**< one of the following */ @@ -174,8 +176,14 @@ struct draw_context double mrd; /**< minimum resolvable depth value, for polygon offset */ - /* pipe state that we need: */ + /** Current rasterizer state given to us by the driver */ const struct pipe_rasterizer_state *rasterizer; + /** Driver CSO handle for the current rasterizer state */ + void *rast_handle; + + /** Rasterizer CSOs without culling/stipple/etc */ + void *rasterizer_no_cull[2][2]; + struct pipe_viewport_state viewport; boolean identity_viewport; @@ -345,5 +353,10 @@ void draw_do_flush( struct draw_context *draw, unsigned flags ); +void * +draw_get_rasterizer_no_cull( struct draw_context *draw, + boolean scissor, + boolean flatshade ); + #endif /* DRAW_PRIVATE_H */ diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 3d45a22b7e7..2f1ab7592db 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -210,7 +210,7 @@ i915_create_context(struct pipe_screen *screen, void *priv) /* * Create drawing context and plug our rendering stage into it. */ - i915->draw = draw_create(); + i915->draw = draw_create(&i915->base); assert(i915->draw); if (!debug_get_bool_option("I915_NO_VBUF", FALSE)) { draw_set_rasterize_stage(i915->draw, i915_draw_vbuf_stage(i915)); diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 62169918e2b..7a19cec39dc 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -714,7 +714,8 @@ static void i915_bind_rasterizer_state( struct pipe_context *pipe, /* pass-through to draw module */ draw_set_rasterizer_state(i915->draw, - (i915->rasterizer ? i915->rasterizer->templ : NULL)); + (i915->rasterizer ? i915->rasterizer->templ : NULL), + raster); i915->dirty |= I915_NEW_RASTERIZER; } diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index e31ae6a3fc1..6962a7921bf 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -174,7 +174,7 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv ) /* * Create drawing context and plug our rendering stage into it. */ - llvmpipe->draw = draw_create(); + llvmpipe->draw = draw_create(&llvmpipe->pipe); if (!llvmpipe->draw) goto fail; diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c index feb012816c9..8592da0d9d9 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c +++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c @@ -38,19 +38,26 @@ void * llvmpipe_create_rasterizer_state(struct pipe_context *pipe, const struct pipe_rasterizer_state *rast) { + /* We do nothing special with rasterizer state. + * The CSO handle is just a pointer to a pipe_rasterizer_state object. + */ return mem_dup(rast, sizeof(*rast)); } -void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, - void *rasterizer) + + +void +llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); + const struct pipe_rasterizer_state *rasterizer = + (const struct pipe_rasterizer_state *) handle; if (llvmpipe->rasterizer == rasterizer) return; /* pass-through to draw module */ - draw_set_rasterizer_state(llvmpipe->draw, rasterizer); + draw_set_rasterizer_state(llvmpipe->draw, rasterizer, handle); llvmpipe->rasterizer = rasterizer; @@ -68,6 +75,7 @@ void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, llvmpipe->dirty |= LP_NEW_RASTERIZER; } + void llvmpipe_delete_rasterizer_state(struct pipe_context *pipe, void *rasterizer) { diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index 7be12fcdef4..031cc128142 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -129,7 +129,7 @@ nv50_create(struct pipe_screen *pscreen, void *priv) nv50_init_state_functions(nv50); nv50_init_query_functions(nv50); - nv50->draw = draw_create(); + nv50->draw = draw_create(&nv50->pipe); assert(nv50->draw); draw_set_rasterize_stage(nv50->draw, nv50_draw_render_stage(nv50)); diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 86b98a4ba52..0d5ebdf5897 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -181,7 +181,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->context.draw_range_elements = r300_swtcl_draw_range_elements; /* Create a Draw. This is used for SW TCL. */ - r300->draw = draw_create(); + r300->draw = draw_create(&r300->context); /* Enable our renderer. */ draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300)); /* Enable Draw's clipping. */ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 1f6f99d3e52..9c5eba4206f 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -810,7 +810,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) if (r300->draw) { draw_flush(r300->draw); - draw_set_rasterizer_state(r300->draw, &rs->rs); + draw_set_rasterizer_state(r300->draw, &rs->rs, state); } if (rs) { diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index ddc35bcd629..7c7abc9eb26 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -298,7 +298,7 @@ softpipe_create_context( struct pipe_screen *screen, /* * 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; diff --git a/src/gallium/drivers/softpipe/sp_state_rasterizer.c b/src/gallium/drivers/softpipe/sp_state_rasterizer.c index a5b00336d44..c9ede09f268 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; diff --git a/src/gallium/drivers/svga/svga_pipe_rasterizer.c b/src/gallium/drivers/svga/svga_pipe_rasterizer.c index 35717788677..5253c45cb20 100644 --- a/src/gallium/drivers/svga/svga_pipe_rasterizer.c +++ b/src/gallium/drivers/svga/svga_pipe_rasterizer.c @@ -222,7 +222,8 @@ static void svga_bind_rasterizer_state( struct pipe_context *pipe, svga->curr.rast = raster; - draw_set_rasterizer_state(svga->swtnl.draw, raster ? &raster->templ : NULL); + draw_set_rasterizer_state(svga->swtnl.draw, raster ? &raster->templ : NULL, + state); svga->dirty |= SVGA_NEW_RAST; } diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c index da15be155c8..0758f3ff72b 100644 --- a/src/gallium/drivers/svga/svga_swtnl_draw.c +++ b/src/gallium/drivers/svga/svga_swtnl_draw.c @@ -134,7 +134,7 @@ boolean svga_init_swtnl( struct svga_context *svga ) /* * Create drawing context and plug our rendering stage into it. */ - svga->swtnl.draw = draw_create(); + svga->swtnl.draw = draw_create(&svga->pipe); if (svga->swtnl.draw == NULL) goto fail; diff --git a/src/gallium/drivers/svga/svga_swtnl_state.c b/src/gallium/drivers/svga/svga_swtnl_state.c index 35f36a828fd..6dfdb5e89be 100644 --- a/src/gallium/drivers/svga/svga_swtnl_state.c +++ b/src/gallium/drivers/svga/svga_swtnl_state.c @@ -113,7 +113,8 @@ static int update_swtnl_draw( struct svga_context *svga, if (dirty & SVGA_NEW_RAST) draw_set_rasterizer_state(svga->swtnl.draw, - &svga->curr.rast->templ); + &svga->curr.rast->templ, + (void *) svga->curr.rast); if (dirty & SVGA_NEW_FRAME_BUFFER) draw_set_mrd(svga->swtnl.draw, diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index de8beaf5e25..684a60b5508 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -115,7 +115,7 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) _vbo_CreateContext(ctx); #if FEATURE_feedback || FEATURE_drawpix - st->draw = draw_create(); /* for selection/feedback */ + st->draw = draw_create(pipe); /* for selection/feedback */ /* Disable draw options that might convert points/lines to tris, etc. * as that would foul-up feedback/selection mode. diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 087f2f22bbf..6bffdd8daa8 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -134,7 +134,7 @@ st_feedback_draw_vbo(GLcontext *ctx, assert(draw); draw_set_viewport_state(draw, &st->state.viewport); draw_set_clip_state(draw, &st->state.clip); - draw_set_rasterizer_state(draw, &st->state.rasterizer); + draw_set_rasterizer_state(draw, &st->state.rasterizer, NULL); draw_bind_vertex_shader(draw, st->vp_varient->draw_shader); set_feedback_vertex_format(ctx); -- cgit v1.2.3 From 2197fac47cb1f87387820678357cc67c9a2536b9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 19 Apr 2010 18:14:04 +0200 Subject: draw: Implement index bias. --- src/gallium/auxiliary/draw/draw_context.c | 4 ++ src/gallium/auxiliary/draw/draw_context.h | 2 + src/gallium/auxiliary/draw/draw_private.h | 1 + src/gallium/auxiliary/draw/draw_pt.c | 6 +- src/gallium/auxiliary/draw/draw_pt.h | 1 + .../auxiliary/draw/draw_pt_varray_tmp_linear.h | 3 + src/gallium/auxiliary/draw/draw_pt_vcache.c | 17 +++-- src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h | 77 +++++++++++----------- 8 files changed, 65 insertions(+), 46 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_context.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 99f4e6dd2a8..b6c558ba9b1 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -427,12 +427,14 @@ void draw_set_render( struct draw_context *draw, void draw_set_mapped_element_buffer_range( struct draw_context *draw, unsigned eltSize, + int eltBias, unsigned min_index, unsigned max_index, const void *elements ) { draw->pt.user.elts = elements; draw->pt.user.eltSize = eltSize; + draw->pt.user.eltBias = eltBias; draw->pt.user.min_index = min_index; draw->pt.user.max_index = max_index; } @@ -441,10 +443,12 @@ draw_set_mapped_element_buffer_range( struct draw_context *draw, void draw_set_mapped_element_buffer( struct draw_context *draw, unsigned eltSize, + int eltBias, const void *elements ) { draw->pt.user.elts = elements; draw->pt.user.eltSize = eltSize; + draw->pt.user.eltBias = eltBias; draw->pt.user.min_index = 0; draw->pt.user.max_index = 0xffffffff; } diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index 1af4961716c..cfa0ad88d0a 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -139,12 +139,14 @@ void draw_set_vertex_elements(struct draw_context *draw, void draw_set_mapped_element_buffer_range( struct draw_context *draw, unsigned eltSize, + int eltBias, unsigned min_index, unsigned max_index, const void *elements ); void draw_set_mapped_element_buffer( struct draw_context *draw, unsigned eltSize, + int eltBias, const void *elements ); void draw_set_mapped_vertex_buffer(struct draw_context *draw, diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index da64102d9d1..33b0c196d4e 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -148,6 +148,7 @@ struct draw_context const void *elts; /** bytes per index (0, 1, 2 or 4) */ unsigned eltSize; + int eltBias; unsigned min_index; unsigned max_index; diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 43f6c5650a0..aa1f7064a3a 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -111,6 +111,7 @@ draw_pt_arrays(struct draw_context *draw, frontend->run(frontend, draw_pt_elt_func(draw), draw_pt_elt_ptr(draw, start), + draw->pt.user.eltBias, count); frontend->finish( frontend ); @@ -222,8 +223,11 @@ draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count) break; default: assert(0); + return; } - debug_printf("Element[%u + %u] -> Vertex %u:\n", start, i, ii); + ii += draw->pt.user.eltBias; + debug_printf("Element[%u + %u] + %i -> Vertex %u:\n", start, i, + draw->pt.user.eltBias, ii); } else { /* non-indexed arrays */ diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h index c2797a759ee..3e3ea320cc0 100644 --- a/src/gallium/auxiliary/draw/draw_pt.h +++ b/src/gallium/auxiliary/draw/draw_pt.h @@ -67,6 +67,7 @@ struct draw_pt_front_end { void (*run)( struct draw_pt_front_end *, pt_elt_func elt_func, const void *elt_ptr, + int elt_bias, unsigned count ); void (*finish)( struct draw_pt_front_end * ); diff --git a/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h b/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h index f0aec5febab..a292346be95 100644 --- a/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h +++ b/src/gallium/auxiliary/draw/draw_pt_varray_tmp_linear.h @@ -6,6 +6,7 @@ static unsigned trim( unsigned count, unsigned first, unsigned incr ) static void FUNC(struct draw_pt_front_end *frontend, pt_elt_func get_elt, const void *elts, + int elt_bias, unsigned count) { struct varray_frontend *varray = (struct varray_frontend *)frontend; @@ -14,6 +15,8 @@ static void FUNC(struct draw_pt_front_end *frontend, unsigned j; unsigned first, incr; + assert(elt_bias == 0); + draw_pt_split_prim(varray->input_prim, &first, &incr); /* Sanitize primitive length: diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 757c4874545..a513188b918 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -329,6 +329,7 @@ static INLINE void vcache_check_run( struct draw_pt_front_end *frontend, pt_elt_func get_elt, const void *elts, + int elt_bias, unsigned draw_count ) { struct vcache_frontend *vcache = (struct vcache_frontend *)frontend; @@ -362,8 +363,9 @@ vcache_check_run( struct draw_pt_front_end *frontend, } - if (min_index == 0 && - index_size == 2) + if (elt_bias <= 0 && + min_index == (unsigned)-elt_bias && + index_size == 2) { transformed_elts = (const ushort *)elts; } @@ -373,7 +375,8 @@ vcache_check_run( struct draw_pt_front_end *frontend, if (!storage) goto fail; - if (min_index == 0) { + if (elt_bias <= 0 && + min_index == (unsigned)-elt_bias) { switch(index_size) { case 1: translate_ubyte_elts( (const ubyte *)elts, @@ -404,21 +407,21 @@ vcache_check_run( struct draw_pt_front_end *frontend, case 1: rebase_ubyte_elts( (const ubyte *)elts, draw_count, - 0 - (int)min_index, + elt_bias - (int)min_index, storage ); break; case 2: rebase_ushort_elts( (const ushort *)elts, draw_count, - 0 - (int)min_index, + elt_bias - (int)min_index, storage ); break; case 4: rebase_uint_elts( (const uint *)elts, draw_count, - 0 - (int)min_index, + elt_bias - (int)min_index, storage ); break; @@ -447,7 +450,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, fetch_count, draw_count); fail: - vcache_run( frontend, get_elt, elts, draw_count ); + vcache_run( frontend, get_elt, elts, elt_bias, draw_count ); } diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h index 7cba8547f15..eedd31b7f85 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h +++ b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h @@ -3,6 +3,7 @@ static void FUNC( struct draw_pt_front_end *frontend, pt_elt_func get_elt, const void *elts, + int elt_bias, unsigned count ) { struct vcache_frontend *vcache = (struct vcache_frontend *)frontend; @@ -20,7 +21,7 @@ static void FUNC( struct draw_pt_front_end *frontend, case PIPE_PRIM_POINTS: for (i = 0; i < count; i ++) { POINT( vcache, - get_elt(elts, i + 0) ); + get_elt(elts, i + 0) + elt_bias ); } break; @@ -28,8 +29,8 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 0; i+1 < count; i += 2) { LINE( vcache, DRAW_PIPE_RESET_STIPPLE, - get_elt(elts, i + 0), - get_elt(elts, i + 1)); + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias); } break; @@ -40,14 +41,14 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 1; i < count; i++, flags = 0) { LINE( vcache, flags, - get_elt(elts, i - 1), - get_elt(elts, i )); + get_elt(elts, i - 1) + elt_bias, + get_elt(elts, i ) + elt_bias); } LINE( vcache, flags, - get_elt(elts, i - 1), - get_elt(elts, 0 )); + get_elt(elts, i - 1) + elt_bias, + get_elt(elts, 0 ) + elt_bias); } break; @@ -56,8 +57,8 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 1; i < count; i++, flags = 0) { LINE( vcache, flags, - get_elt(elts, i - 1), - get_elt(elts, i )); + get_elt(elts, i - 1) + elt_bias, + get_elt(elts, i ) + elt_bias); } break; @@ -65,9 +66,9 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 0; i+2 < count; i += 3) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2 )); + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2 ) + elt_bias); } break; @@ -76,18 +77,18 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 0; i+2 < count; i++) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, i + 0), - get_elt(elts, i + 1 + (i&1)), - get_elt(elts, i + 2 - (i&1))); + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1 + (i&1) + elt_bias), + get_elt(elts, i + 2 - (i&1) + elt_bias)); } } else { for (i = 0; i+2 < count; i++) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, i + 0 + (i&1)), - get_elt(elts, i + 1 - (i&1)), - get_elt(elts, i + 2 )); + get_elt(elts, i + 0 + (i&1) + elt_bias), + get_elt(elts, i + 1 - (i&1) + elt_bias), + get_elt(elts, i + 2 ) + elt_bias); } } break; @@ -98,18 +99,18 @@ static void FUNC( struct draw_pt_front_end *frontend, for (i = 0; i+2 < count; i++) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, i + 1), - get_elt(elts, i + 2), - get_elt(elts, 0 )); + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2) + elt_bias, + get_elt(elts, 0 ) + elt_bias); } } else { for (i = 0; i+2 < count; i++) { TRIANGLE( vcache, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - get_elt(elts, 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2 )); + get_elt(elts, 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2 ) + elt_bias); } } } @@ -119,20 +120,20 @@ static void FUNC( struct draw_pt_front_end *frontend, case PIPE_PRIM_QUADS: for (i = 0; i+3 < count; i += 4) { QUAD( vcache, - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2), - get_elt(elts, i + 3) ); + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2) + elt_bias, + get_elt(elts, i + 3) + elt_bias ); } break; case PIPE_PRIM_QUAD_STRIP: for (i = 0; i+3 < count; i += 2) { QUAD( vcache, - get_elt(elts, i + 2), - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 3) ); + get_elt(elts, i + 2) + elt_bias, + get_elt(elts, i + 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 3) + elt_bias ); } break; @@ -165,16 +166,16 @@ static void FUNC( struct draw_pt_front_end *frontend, if (flatfirst) { TRIANGLE( vcache, flags, - get_elt(elts, 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2) ); + get_elt(elts, 0) + elt_bias, + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2) + elt_bias ); } else { TRIANGLE( vcache, flags, - get_elt(elts, i + 1), - get_elt(elts, i + 2), - get_elt(elts, 0)); + get_elt(elts, i + 1) + elt_bias, + get_elt(elts, i + 2) + elt_bias, + get_elt(elts, 0) + elt_bias); } } } -- cgit v1.2.3 From 7c4208c3a0f48955720f41b3cb320a120c505ba6 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 19 Apr 2010 12:46:08 -0400 Subject: draw llvm: fix constructor mess use just one constructor to figure out whether to use llvm. --- src/gallium/auxiliary/draw/draw_context.c | 8 ++++++++ src/gallium/auxiliary/draw/draw_context.h | 7 ------- src/gallium/auxiliary/draw/draw_llvm.c | 22 +--------------------- src/gallium/drivers/llvmpipe/lp_context.c | 8 -------- 4 files changed, 9 insertions(+), 36 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_context.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 5726444c9b7..0d8f8807b24 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -38,6 +38,9 @@ #include "draw_vs.h" #include "draw_gs.h" +#if HAVE_LLVM +#include "gallivm/lp_bld_init.h" +#endif struct draw_context *draw_create( struct pipe_context *pipe ) { @@ -45,6 +48,11 @@ struct draw_context *draw_create( struct pipe_context *pipe ) if (draw == NULL) goto fail; +#if HAVE_LLVM + assert(lp_build_engine); + draw->engine = lp_build_engine; +#endif + if (!draw_init(draw)) goto fail; diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index 0d328304eb0..51767bb214d 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -197,11 +197,4 @@ boolean draw_need_pipeline(const struct draw_context *draw, const struct pipe_rasterizer_state *rasterizer, unsigned prim ); -#ifdef HAVE_LLVM -/******************************************************************************* - * LLVM integration - */ -struct draw_context *draw_create_with_llvm(void); -#endif - #endif /* DRAW_CONTEXT_H */ diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index a5403a49c35..e3ef9e425fa 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -196,7 +196,7 @@ draw_llvm_create(struct draw_context *draw) init_globals(llvm); -#if 1 +#if 0 LLVMDumpModule(llvm->module); #endif @@ -223,26 +223,6 @@ draw_llvm_prepare(struct draw_llvm *llvm, int num_inputs) return variant; } - -struct draw_context *draw_create_with_llvm(void) -{ - struct draw_context *draw = CALLOC_STRUCT( draw_context ); - if (draw == NULL) - goto fail; - - assert(lp_build_engine); - draw->engine = lp_build_engine; - - if (!draw_init(draw)) - goto fail; - - return draw; - -fail: - draw_destroy( draw ); - return NULL; -} - static void generate_vs(struct draw_llvm *llvm, LLVMBuilderRef builder, diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index efdc2450f79..f7cf06d8d46 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -45,10 +45,6 @@ #include "lp_query.h" #include "lp_setup.h" - -#define USE_DRAW_LLVM 1 - - static void llvmpipe_destroy( struct pipe_context *pipe ) { struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe ); @@ -162,11 +158,7 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv ) /* * Create drawing context and plug our rendering stage into it. */ -#if USE_DRAW_LLVM - llvmpipe->draw = draw_create_with_llvm(&llvmpipe->pipe); -#else llvmpipe->draw = draw_create(&llvmpipe->pipe); -#endif if (!llvmpipe->draw) goto fail; -- cgit v1.2.3 From 49ba607abab17cc07e9f163f5415636474fd7940 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 20 Apr 2010 00:00:52 -0700 Subject: draw llvm: Move dereference of pointer after NULL check. --- src/gallium/auxiliary/draw/draw_context.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium/auxiliary/draw/draw_context.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 0d8f8807b24..d490d3325c2 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -103,12 +103,14 @@ boolean draw_init(struct draw_context *draw) void draw_destroy( struct draw_context *draw ) { - struct pipe_context *pipe = draw->pipe; + struct pipe_context *pipe; int i, j; if (!draw) return; + pipe = draw->pipe; + /* free any rasterizer CSOs that we may have created. */ for (i = 0; i < 2; i++) { -- cgit v1.2.3 From 8cb223eb020560d59c8f73e09b832cef477933b7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 21 Apr 2010 14:24:26 -0600 Subject: gallium/draw: fix point sprite handling New draw API function to indicate whether or not to convert points to quads for sprite rasterization. Fix point-to-quad conversion regression in the wide-point stage. We need to check the pipe_rasterizer_state::point_quad_rasterization flag. --- src/gallium/auxiliary/draw/draw_context.c | 11 +++++++++++ src/gallium/auxiliary/draw/draw_context.h | 2 ++ src/gallium/auxiliary/draw/draw_pipe.c | 1 + src/gallium/auxiliary/draw/draw_pipe_validate.c | 7 +++++++ src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 7 +++---- src/gallium/auxiliary/draw/draw_private.h | 1 + 6 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_context.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 4196f01e0b2..710bf792fc3 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -303,6 +303,17 @@ draw_wide_point_threshold(struct draw_context *draw, float threshold) } +/** + * Should the draw module handle point->quad conversion for drawing sprites? + */ +void +draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite) +{ + draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); + draw->pipeline.wide_point_sprites = draw_sprite; +} + + /** * Tells the draw module to draw lines with triangles if their width * is greater than this threshold. diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index 7b41bb48dd3..b905c2f2da6 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -67,6 +67,8 @@ void draw_set_rasterize_stage( struct draw_context *draw, void draw_wide_point_threshold(struct draw_context *draw, float threshold); +void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite); + void draw_wide_line_threshold(struct draw_context *draw, float threshold); void draw_enable_line_stipple(struct draw_context *draw, boolean enable); diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c index b8f57dde6d8..64c35025081 100644 --- a/src/gallium/auxiliary/draw/draw_pipe.c +++ b/src/gallium/auxiliary/draw/draw_pipe.c @@ -66,6 +66,7 @@ boolean draw_pipeline_init( struct draw_context *draw ) /* these defaults are oriented toward the needs of softpipe */ draw->pipeline.wide_point_threshold = 1000000.0; /* infinity */ draw->pipeline.wide_line_threshold = 1.0; + draw->pipeline.wide_point_sprites = FALSE; draw->pipeline.line_stipple = TRUE; draw->pipeline.point_sprite = TRUE; diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c index 23fa4cf6060..2a50af7a414 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_validate.c +++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c @@ -100,6 +100,11 @@ draw_need_pipeline(const struct draw_context *draw, if (rasterizer->point_size > draw->pipeline.wide_point_threshold) return TRUE; + /* sprite points */ + if (rasterizer->point_quad_rasterization + && draw->pipeline.wide_point_sprites) + return TRUE; + /* AA points */ if (rasterizer->point_smooth && draw->pipeline.aapoint) return TRUE; @@ -172,6 +177,8 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) wide_points = FALSE; else if (rast->point_size > draw->pipeline.wide_point_threshold) wide_points = TRUE; + else if (rast->point_quad_rasterization && draw->pipeline.wide_point_sprites) + wide_points = TRUE; else wide_points = FALSE; diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c index 30116f4925f..a86fe19586c 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c @@ -132,10 +132,9 @@ static void set_texcoords(const struct widepoint_stage *wide, static void widepoint_point( struct draw_stage *stage, struct prim_header *header ) { - /* XXX should take point_quad_rasterization into account? */ const struct widepoint_stage *wide = widepoint_stage(stage); const unsigned pos = draw_current_shader_position_output(stage->draw); - const boolean sprite = (boolean) stage->draw->rasterizer->sprite_coord_enable; + const boolean sprite = (boolean) stage->draw->rasterizer->point_quad_rasterization; float half_size; float left_adj, right_adj, bot_adj, top_adj; @@ -237,14 +236,14 @@ static void widepoint_first_point( struct draw_stage *stage, /* XXX we won't know the real size if it's computed by the vertex shader! */ if ((rast->point_size > draw->pipeline.wide_point_threshold) || - (rast->sprite_coord_enable && draw->pipeline.point_sprite)) { + (rast->point_quad_rasterization && draw->pipeline.point_sprite)) { stage->point = widepoint_point; } else { stage->point = draw_pipe_passthrough_point; } - if (rast->sprite_coord_enable) { + if (rast->point_quad_rasterization) { /* find vertex shader texcoord outputs */ const struct draw_vertex_shader *vs = draw->vs.vertex_shader; uint i, j = 0; diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 0b3c9e69bd5..4bb3282f62c 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -111,6 +111,7 @@ struct draw_context float wide_point_threshold; /**< convert pnts to tris if larger than this */ float wide_line_threshold; /**< convert lines to tris if wider than this */ + boolean wide_point_sprites; /**< convert points to tris for sprite mode */ boolean line_stipple; /**< do line stipple? */ boolean point_sprite; /**< convert points to quads for sprites? */ -- cgit v1.2.3 From 5c364b3ef78cd36a41c43a771efe5b631ea9559b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 21 Apr 2010 17:30:39 +0100 Subject: draw: Make LLVM integration work without llvmpipe too (e.g. sofptipe). Prevents the assertion failure. --- src/gallium/auxiliary/draw/draw_context.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium/auxiliary/draw/draw_context.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 710bf792fc3..02abddf1491 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -49,6 +49,7 @@ struct draw_context *draw_create( struct pipe_context *pipe ) goto fail; #if HAVE_LLVM + lp_build_init(); assert(lp_build_engine); draw->engine = lp_build_engine; #endif -- cgit v1.2.3