From ea98e9820d7117f7a187f355445796b1ef5d9e0c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 20 Nov 2009 16:03:48 -0800 Subject: draw: Initialize variable in draw_pt.c. --- src/gallium/auxiliary/draw/draw_pt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium/auxiliary/draw/draw_pt.c') diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index dbb5ac7182..4865a2d854 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -192,7 +192,8 @@ draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count) prim, start, count); for (i = 0; i < count; i++) { - uint ii, j; + uint ii = 0; + uint j; if (draw->pt.user.elts) { /* indexed arrays */ -- cgit v1.2.3 From a08e348a84f57ed5e8bf5888f1ce13934d2ce8fa Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 9 Dec 2009 19:03:10 +0100 Subject: gallium: first steps to treat edgeflags as regular vertex element The idea here is to eliminate the set_edgeflags() call in pipe_context by treating edgeflags as a regular vertex element. Edgeflags provoke special treatment in hardware, which means we need to label them in some way, in this case we'll be passing them through the vertex shader and labelling the vertex shader output with a new TGSI semantic (TGSI_SEMANTIC_EDGEFLAG). --- src/gallium/auxiliary/draw/draw_context.c | 7 --- src/gallium/auxiliary/draw/draw_context.h | 3 - src/gallium/auxiliary/draw/draw_private.h | 2 - src/gallium/auxiliary/draw/draw_pt.c | 4 +- src/gallium/auxiliary/draw/draw_pt.h | 5 -- src/gallium/auxiliary/draw/draw_pt_fetch.c | 32 ++++------- .../auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 3 +- src/gallium/auxiliary/draw/draw_pt_post_vs.c | 53 +++++++++++++++--- src/gallium/include/pipe/p_context.h | 8 --- src/gallium/include/pipe/p_shader_tokens.h | 3 +- src/mesa/state_tracker/st_atom_shader.c | 11 +++- src/mesa/state_tracker/st_draw.c | 64 ---------------------- src/mesa/state_tracker/st_mesa_to_tgsi.c | 13 ++--- src/mesa/state_tracker/st_program.c | 32 ++++++++++- src/mesa/state_tracker/st_program.h | 2 +- 15 files changed, 111 insertions(+), 131 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_pt.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index a4f1fcddc1..cc5f7f0105 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -366,13 +366,6 @@ void draw_set_render( struct draw_context *draw, draw->render = render; } -void draw_set_edgeflags( struct draw_context *draw, - const unsigned *edgeflag ) -{ - draw->pt.user.edgeflag = edgeflag; -} - - /** diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index d529e4e9a2..465b8f10c6 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -143,9 +143,6 @@ void draw_set_mapped_constant_buffer(struct draw_context *draw, const void *buffer, unsigned size ); -void draw_set_edgeflags( struct draw_context *draw, - const unsigned *edgeflag ); - /*********************************************************************** * draw_prim.c diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 41fcb16a0a..0750e6e379 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -142,8 +142,6 @@ struct draw_context /* user-space vertex data, buffers */ struct { - const unsigned *edgeflag; - /** vertex element/index buffer (ex: glDrawElements) */ const void *elts; /** bytes per index (0, 1, 2 or 4) */ diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 4865a2d854..139ae1fe55 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -318,8 +318,10 @@ draw_arrays(struct draw_context *draw, unsigned prim, boolean draw_pt_get_edgeflag( struct draw_context *draw, unsigned idx ) { - if (draw->pt.user.edgeflag) + if (draw->pt.user.edgeflag) { + float *ef = draw->pt.verted_buffer[idx] return (draw->pt.user.edgeflag[idx/32] & (1 << (idx%32))) != 0; + } else return 1; } diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h index 7a17a9fb6b..b5c8c82f4a 100644 --- a/src/gallium/auxiliary/draw/draw_pt.h +++ b/src/gallium/auxiliary/draw/draw_pt.h @@ -149,11 +149,6 @@ struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw ); struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *draw); -/* More helpers: - */ -boolean draw_pt_get_edgeflag( struct draw_context *draw, - unsigned idx ); - /******************************************************************************* * HW vertex emit: diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 65c3a34c34..cb609f8c41 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -120,7 +120,12 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, fetch->translate = translate_cache_find(fetch->cache, &key); { - static struct vertex_header vh = { 0, 1, 0, UNDEFINED_VERTEX_ID, { .0f, .0f, .0f, .0f } }; + static struct vertex_header vh = { 0, + 1, + 0, + UNDEFINED_VERTEX_ID, + { .0f, .0f, .0f, .0f } }; + fetch->translate->set_buffer(fetch->translate, draw->pt.nr_vertex_buffers, &vh, @@ -128,9 +133,6 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, } } - fetch->need_edgeflags = ((draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL || - draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) && - draw->pt.user.edgeflag); } @@ -158,16 +160,10 @@ void draw_pt_fetch_run( struct pt_fetch *fetch, count, verts ); - /* Edgeflags are hard to fit into a translate program, populate - * them separately if required. In the setup above they are - * defaulted to one, so only need this if there is reason to change - * that default: + /* Extract edgeflag values from vertex data into the header. */ if (fetch->need_edgeflags) { - for (i = 0; i < count; i++) { - struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size); - vh->edgeflag = draw_pt_get_edgeflag( draw, elts[i] ); - } + extract_edge_flags( fetch, count ); } } @@ -194,16 +190,12 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch, count, verts ); - /* Edgeflags are hard to fit into a translate program, populate - * them separately if required. In the setup above they are - * defaulted to one, so only need this if there is reason to change - * that default: + /* Extract edgeflag values from vertex data into the header. XXX: + * this should be done after the vertex shader is run. + * Bypass-vs-and-clip interaction with pipeline??? */ if (fetch->need_edgeflags) { - for (i = 0; i < count; i++) { - struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size); - vh->edgeflag = draw_pt_get_edgeflag( draw, start + i ); - } + extract_edge_flags( fetch, count ); } } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index df6c265b7e..d41436858a 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -86,7 +86,8 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle, (boolean)draw->bypass_clipping, (boolean)(draw->identity_viewport || draw->rasterizer->bypass_vs_clip_and_viewport), - (boolean)draw->rasterizer->gl_rasterization_rules ); + (boolean)draw->rasterizer->gl_rasterization_rules, + need_edgeflags ); if (!(opt & PT_PIPELINE)) { diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c index 6c1cb48e8b..0745b168de 100644 --- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c +++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c @@ -147,6 +147,34 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs, +/* As above plus edgeflags + */ +static boolean +post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs, + struct vertex_header *vertices, + unsigned count, + unsigned stride ) +{ + if (!post_vs_cliptest_viewport_gl( pvs, vertices, count, stride)) + return FALSE; + + /* If present, copy edgeflag VS output into vertex header. + * Otherwise, leave header as is. + */ + if (pvs->draw->vs.edgeflag_output) { + struct vertex_header *out = vertices; + int ef = pvs->draw->vs.edgeflag_output; + + for (j = 0; j < count; j++) { + const float *edgeflag = out->data[ef]; + out->edgeflag = (edgeflag[0] != 1.0f); + } + } +} + + + + /* If bypass_clipping is set, skip cliptest and rhw divide. */ static boolean post_vs_viewport( struct pt_post_vs *pvs, @@ -203,15 +231,26 @@ void draw_pt_post_vs_prepare( struct pt_post_vs *pvs, boolean bypass_viewport, boolean opengl ) { - if (bypass_clipping) { - if (bypass_viewport) - pvs->run = post_vs_none; - else - pvs->run = post_vs_viewport; + if (!need_edgeflags) { + if (bypass_clipping) { + if (bypass_viewport) + pvs->run = post_vs_none; + else + pvs->run = post_vs_viewport; + } + else { + /* if (opengl) */ + pvs->run = post_vs_cliptest_viewport_gl; + } } else { - /* if (opengl) */ - pvs->run = post_vs_cliptest_viewport_gl; + /* If we need to copy edgeflags to the vertex header, it should + * mean we're running the primitive pipeline. Hence the bypass + * flags should be false. + */ + assert(!bypass_clipping); + assert(!bypass_viewport); + pvs->run = post_vs_cliptest_viewport_gl_edgeflag; } } diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index f896001eb1..11bcdc0a24 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -57,14 +57,6 @@ struct pipe_context { void (*destroy)( struct pipe_context * ); - - /* Possible interface for setting edgeflags. These aren't really - * vertex elements, so don't fit there. - */ - void (*set_edgeflags)( struct pipe_context *, - const unsigned *bitfield ); - - /** * VBO drawing (return false on fallbacks (temporary??)) */ diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index 588ca5e026..c051d4dae8 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -127,7 +127,8 @@ struct tgsi_declaration_range #define TGSI_SEMANTIC_GENERIC 5 #define TGSI_SEMANTIC_NORMAL 6 #define TGSI_SEMANTIC_FACE 7 -#define TGSI_SEMANTIC_COUNT 8 /**< number of semantic values */ +#define TGSI_SEMANTIC_EDGEFLAG 8 +#define TGSI_SEMANTIC_COUNT 9 /**< number of semantic values */ struct tgsi_declaration_semantic { diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 09baff875b..e209634c90 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -106,7 +106,16 @@ find_translated_vp(struct st_context *st, /* Nothing in our key yet. This will change: */ memset(&key, 0, sizeof key); - key.dummy = 0; + + /* When this is true, we will add an extra input to the vertex + * shader translation (for edgeflags), an extra output with + * edgeflag semantics, and extend the vertex shader to pass through + * the input to the output. We'll need to use similar logic to set + * up the extra vertex_element input for edgeflags. + */ + key.passthrough_edgeflags = (ctx->Polygon.FrontMode != GL_FILL || + ctx->Polygon.BackMode != GL_FILL); + /* Do we need to throw away old translations after a change in the * GL program string? diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index e13ae57a0e..773a3f17cd 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -217,59 +217,7 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, } -/* - * If edge flags are needed, setup an bitvector of flags and call - * pipe->set_edgeflags(). - * XXX memleak: need to free the returned pointer at some point - */ -static void * -setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, - const struct gl_client_array *array) -{ - struct pipe_context *pipe = ctx->st->pipe; - - if ((primMode == GL_TRIANGLES || - primMode == GL_QUADS || - primMode == GL_POLYGON) && - (ctx->Polygon.FrontMode != GL_FILL || - ctx->Polygon.BackMode != GL_FILL)) { - /* need edge flags */ - GLint i; - unsigned *vec; - struct st_buffer_object *stobj = st_buffer_object(array->BufferObj); - ubyte *map; - - if (!stobj || stobj->Base.Name == 0) { - /* edge flags are not in a VBO */ - return NULL; - } - - vec = (unsigned *) _mesa_calloc(sizeof(unsigned) * ((count + 31) / 32)); - if (!vec) - return NULL; - - map = pipe_buffer_map(pipe->screen, stobj->buffer, PIPE_BUFFER_USAGE_CPU_READ); - map = ADD_POINTERS(map, array->Ptr); - for (i = 0; i < count; i++) { - if (*((float *) map)) - vec[i/32] |= 1 << (i % 32); - - map += array->StrideB; - } - - pipe_buffer_unmap(pipe->screen, stobj->buffer); - - pipe->set_edgeflags(pipe, vec); - - return vec; - } - else { - /* edge flags not needed */ - pipe->set_edgeflags(pipe, NULL); - return NULL; - } -} /** @@ -671,10 +619,6 @@ st_draw_vbo(GLcontext *ctx, * through to driver & draw module. These interfaces still * need a bit of work... */ - setup_edgeflags(ctx, prims[i].mode, - prims[i].start + indexOffset, prims[i].count, - arrays[VERT_ATTRIB_EDGEFLAG]); - pipe->draw_range_elements(pipe, indexBuf, indexSize, min_index, max_index, @@ -683,10 +627,6 @@ st_draw_vbo(GLcontext *ctx, } else { for (i = 0; i < nr_prims; i++) { - setup_edgeflags(ctx, prims[i].mode, - prims[i].start + indexOffset, prims[i].count, - arrays[VERT_ATTRIB_EDGEFLAG]); - pipe->draw_elements(pipe, indexBuf, indexSize, prims[i].mode, prims[i].start + indexOffset, prims[i].count); @@ -699,10 +639,6 @@ st_draw_vbo(GLcontext *ctx, /* non-indexed */ GLuint i; for (i = 0; i < nr_prims; i++) { - setup_edgeflags(ctx, prims[i].mode, - prims[i].start, prims[i].count, - arrays[VERT_ATTRIB_EDGEFLAG]); - pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count); } } diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 1611d53e2f..9fd670cac2 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -741,6 +741,7 @@ emit_face_var( struct st_translate *t, const struct tgsi_token * st_translate_mesa_program( GLcontext *ctx, + struct ureg_program *ureg; uint procType, const struct gl_program *program, GLuint numInputs, @@ -754,7 +755,6 @@ st_translate_mesa_program( const ubyte outputSemanticIndex[] ) { struct st_translate translate, *t; - struct ureg_program *ureg; const struct tgsi_token *tokens = NULL; unsigned i; @@ -764,11 +764,7 @@ st_translate_mesa_program( t->procType = procType; t->inputMapping = inputMapping; t->outputMapping = outputMapping; - t->ureg = ureg_create( procType ); - if (t->ureg == NULL) - return NULL; - - ureg = t->ureg; + t->ureg = ureg; /*_mesa_print_program(program);*/ @@ -899,8 +895,7 @@ st_translate_mesa_program( t->insn[t->labels[i].branch_target] ); } - tokens = ureg_get_tokens( ureg, NULL ); - ureg_destroy( ureg ); + return PIPE_OK; out: FREE(t->insn); @@ -919,7 +914,7 @@ out: debug_assert(0); } - return tokens; + return PIPE_ERROR_OUT_OF_MEMORY; } diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 5c81a033f9..876d92539e 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -192,10 +192,16 @@ st_translate_vertex_program(struct st_context *st, { struct st_vp_varient *vpv = CALLOC_STRUCT(st_vp_varient); struct pipe_context *pipe = st->pipe; + struct ureg_program *ureg; - vpv->state.tokens = + ureg = ureg_create( TGSI_PROCESSOR_VERTEX ); + if (ureg == NULL) + return NULL; + + error = st_translate_mesa_program(st->ctx, TGSI_PROCESSOR_VERTEX, + ureg, &stvp->Base.Base, /* inputs */ stvp->num_inputs, @@ -209,6 +215,20 @@ st_translate_vertex_program(struct st_context *st, stvp->output_semantic_name, stvp->output_semantic_index ); + if (ret) + goto fail; + + /* Edgeflags will be the last input: + */ + if (key.passthrough_edgeflags) { + ureg_MOV( ureg, + ureg_DECL_output( ureg, TGSI_SEMANTIC_EDGEFLAG, 0 ), + ureg_DECL_next_vs_input(ureg)); + } + + tokens = ureg_get_tokens( ureg, NULL ); + ureg_destroy( ureg ); + vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->state); if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) { @@ -222,6 +242,10 @@ st_translate_vertex_program(struct st_context *st, } return vpv; + +fail: + ureg_destroy( ureg ); + return NULL; } @@ -243,6 +267,7 @@ st_translate_fragment_program(struct st_context *st, GLuint interpMode[16]; /* XXX size? */ GLuint attr; const GLbitfield inputsRead = stfp->Base.Base.InputsRead; + struct ureg_program *ureg; GLuint vslot = 0; uint fs_num_inputs = 0; @@ -377,6 +402,11 @@ st_translate_fragment_program(struct st_context *st, if (!inputMapping) inputMapping = defaultInputMapping; + ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); + if (ureg == NULL) + return NULL; + + stfp->state.tokens = st_translate_mesa_program(st->ctx, TGSI_PROCESSOR_FRAGMENT, diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 88aadbd751..91392785e5 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -73,7 +73,7 @@ struct st_fragment_program struct st_vp_varient_key { - char dummy; /* currently unused */ + boolean passthrough_edgeflags; }; -- cgit v1.2.3 From a0127b6ced257919180ba3a1bf534b68d9c750be Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 14 Dec 2009 18:36:33 +0100 Subject: gallium: more work for edgeflags changes fixes, cleanups, etc. not working yet --- src/gallium/auxiliary/draw/draw_private.h | 1 + src/gallium/auxiliary/draw/draw_pt.c | 11 ----------- src/gallium/auxiliary/draw/draw_pt.h | 3 ++- src/gallium/auxiliary/draw/draw_pt_fetch.c | 15 +-------------- src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 5 ++--- src/gallium/auxiliary/draw/draw_pt_post_vs.c | 5 ++++- src/gallium/auxiliary/draw/draw_vs.c | 4 ++++ src/gallium/auxiliary/draw/draw_vs.h | 1 + src/gallium/drivers/softpipe/sp_context.c | 2 -- src/gallium/drivers/softpipe/sp_draw_arrays.c | 8 -------- src/gallium/drivers/softpipe/sp_state.h | 4 ---- src/mesa/state_tracker/st_atom_shader.c | 4 ++-- src/mesa/state_tracker/st_mesa_to_tgsi.c | 10 ++++------ src/mesa/state_tracker/st_mesa_to_tgsi.h | 4 +++- src/mesa/state_tracker/st_program.c | 15 ++++++++++----- 15 files changed, 34 insertions(+), 58 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_pt.c') diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 0750e6e379..3850cede1e 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -182,6 +182,7 @@ struct draw_context struct draw_vertex_shader *vertex_shader; uint num_vs_outputs; /**< convenience, from vertex_shader */ uint position_output; + uint edgeflag_output; /** TGSI program interpreter runtime state */ struct tgsi_exec_machine *machine; diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 139ae1fe55..2801dbafe4 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -314,14 +314,3 @@ draw_arrays(struct draw_context *draw, unsigned prim, /* drawing done here: */ draw_pt_arrays(draw, prim, start, count); } - -boolean draw_pt_get_edgeflag( struct draw_context *draw, - unsigned idx ) -{ - if (draw->pt.user.edgeflag) { - float *ef = draw->pt.verted_buffer[idx] - return (draw->pt.user.edgeflag[idx/32] & (1 << (idx%32))) != 0; - } - else - return 1; -} diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h index b5c8c82f4a..20edf7a227 100644 --- a/src/gallium/auxiliary/draw/draw_pt.h +++ b/src/gallium/auxiliary/draw/draw_pt.h @@ -212,7 +212,8 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs, void draw_pt_post_vs_prepare( struct pt_post_vs *pvs, boolean bypass_clipping, boolean bypass_viewport, - boolean opengl ); + boolean opengl, + boolean need_edgeflags ); struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw ); diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index cb609f8c41..305bfef435 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -42,11 +42,11 @@ struct pt_fetch { struct translate *translate; unsigned vertex_size; - boolean need_edgeflags; struct translate_cache *cache; }; + /* Perform the fetch from API vertex elements & vertex buffers, to a * contiguous set of float[4] attributes as required for the * vertex_shader->run_linear() method. @@ -160,11 +160,6 @@ void draw_pt_fetch_run( struct pt_fetch *fetch, count, verts ); - /* Extract edgeflag values from vertex data into the header. - */ - if (fetch->need_edgeflags) { - extract_edge_flags( fetch, count ); - } } @@ -189,14 +184,6 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch, start, count, verts ); - - /* Extract edgeflag values from vertex data into the header. XXX: - * this should be done after the vertex shader is run. - * Bypass-vs-and-clip interaction with pipeline??? - */ - if (fetch->need_edgeflags) { - extract_edge_flags( fetch, count ); - } } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index d41436858a..932113783d 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -85,10 +85,9 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle, draw_pt_post_vs_prepare( fpme->post_vs, (boolean)draw->bypass_clipping, (boolean)(draw->identity_viewport || - draw->rasterizer->bypass_vs_clip_and_viewport), + draw->rasterizer->bypass_vs_clip_and_viewport), (boolean)draw->rasterizer->gl_rasterization_rules, - need_edgeflags ); - + (draw->vs.edgeflag_output ? true : false) ); if (!(opt & PT_PIPELINE)) { draw_pt_emit_prepare( fpme->emit, diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c index 0745b168de..08d77649a3 100644 --- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c +++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c @@ -155,6 +155,7 @@ post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs, unsigned count, unsigned stride ) { + unsigned j; if (!post_vs_cliptest_viewport_gl( pvs, vertices, count, stride)) return FALSE; @@ -170,6 +171,7 @@ post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs, out->edgeflag = (edgeflag[0] != 1.0f); } } + return TRUE; } @@ -229,7 +231,8 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs, void draw_pt_post_vs_prepare( struct pt_post_vs *pvs, boolean bypass_clipping, boolean bypass_viewport, - boolean opengl ) + boolean opengl, + boolean need_edgeflags ) { if (!need_edgeflags) { if (bypass_clipping) { diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index 790e89ed82..3553689532 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -101,6 +101,9 @@ draw_create_vertex_shader(struct draw_context *draw, if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION && vs->info.output_semantic_index[i] == 0) vs->position_output = i; + else if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_EDGEFLAG && + vs->info.output_semantic_index[i] == 0) + vs->edgeflag_output = i; } } @@ -120,6 +123,7 @@ draw_bind_vertex_shader(struct draw_context *draw, draw->vs.vertex_shader = dvs; draw->vs.num_vs_outputs = dvs->info.num_outputs; draw->vs.position_output = dvs->position_output; + draw->vs.edgeflag_output = dvs->edgeflag_output; dvs->prepare( dvs, draw ); } else { diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h index 89ae158751..e3b807ebd0 100644 --- a/src/gallium/auxiliary/draw/draw_vs.h +++ b/src/gallium/auxiliary/draw/draw_vs.h @@ -107,6 +107,7 @@ struct draw_vertex_shader { struct tgsi_shader_info info; unsigned position_output; + unsigned edgeflag_output; /* Extracted from shader: */ diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index f8bf3e9974..2a33587b5a 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -238,8 +238,6 @@ softpipe_create( struct pipe_screen *screen ) softpipe->pipe.draw_arrays = softpipe_draw_arrays; softpipe->pipe.draw_elements = softpipe_draw_elements; softpipe->pipe.draw_range_elements = softpipe_draw_range_elements; - softpipe->pipe.set_edgeflags = softpipe_set_edgeflags; - softpipe->pipe.clear = softpipe_clear; softpipe->pipe.flush = softpipe_flush; diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index d4045816d0..518ef8806e 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -184,11 +184,3 @@ softpipe_draw_elements(struct pipe_context *pipe, 0, 0xffffffff, mode, start, count ); } - - -void -softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags) -{ - struct softpipe_context *sp = softpipe_context(pipe); - draw_set_edgeflags(sp->draw, edgeflags); -} diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index d488fb8710..26d5c3fbb2 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -189,10 +189,6 @@ softpipe_draw_range_elements(struct pipe_context *pipe, unsigned max_index, unsigned mode, unsigned start, unsigned count); -void -softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags); - - void softpipe_map_transfers(struct softpipe_context *sp); diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index e209634c90..629bf8953e 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -113,8 +113,8 @@ find_translated_vp(struct st_context *st, * the input to the output. We'll need to use similar logic to set * up the extra vertex_element input for edgeflags. */ - key.passthrough_edgeflags = (ctx->Polygon.FrontMode != GL_FILL || - ctx->Polygon.BackMode != GL_FILL); + key.passthrough_edgeflags = (st->ctx->Polygon.FrontMode != GL_FILL || + st->ctx->Polygon.BackMode != GL_FILL); /* Do we need to throw away old translations after a change in the diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 9fd670cac2..72bd17bf41 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -738,11 +738,11 @@ emit_face_var( struct st_translate *t, * * \return array of translated tokens, caller's responsibility to free */ -const struct tgsi_token * +enum pipe_error st_translate_mesa_program( GLcontext *ctx, - struct ureg_program *ureg; uint procType, + struct ureg_program *ureg, const struct gl_program *program, GLuint numInputs, const GLuint inputMapping[], @@ -755,7 +755,6 @@ st_translate_mesa_program( const ubyte outputSemanticIndex[] ) { struct st_translate translate, *t; - const struct tgsi_token *tokens = NULL; unsigned i; t = &translate; @@ -904,16 +903,15 @@ out: if (t->error) { debug_printf("%s: translate error flag set\n", __FUNCTION__); - FREE((void *)tokens); - tokens = NULL; } +/* ??? if (!tokens) { debug_printf("%s: failed to translate Mesa program:\n", __FUNCTION__); _mesa_print_program(program); debug_assert(0); } - +*/ return PIPE_ERROR_OUT_OF_MEMORY; } diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h index dc0362fe79..9dae373ede 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -30,6 +30,7 @@ #define ST_MESA_TO_TGSI_H #include "main/mtypes.h" +#include "tgsi/tgsi_ureg.h" #if defined __cplusplus @@ -39,10 +40,11 @@ extern "C" { struct tgsi_token; struct gl_program; -const struct tgsi_token * +enum pipe_error st_translate_mesa_program( GLcontext *ctx, uint procType, + struct ureg_program *ureg, const struct gl_program *program, GLuint numInputs, const GLuint inputMapping[], diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 876d92539e..24f2387429 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -193,6 +193,7 @@ st_translate_vertex_program(struct st_context *st, struct st_vp_varient *vpv = CALLOC_STRUCT(st_vp_varient); struct pipe_context *pipe = st->pipe; struct ureg_program *ureg; + enum pipe_error error; ureg = ureg_create( TGSI_PROCESSOR_VERTEX ); if (ureg == NULL) @@ -215,18 +216,18 @@ st_translate_vertex_program(struct st_context *st, stvp->output_semantic_name, stvp->output_semantic_index ); - if (ret) + if (error) goto fail; /* Edgeflags will be the last input: */ - if (key.passthrough_edgeflags) { + if (key->passthrough_edgeflags) { ureg_MOV( ureg, ureg_DECL_output( ureg, TGSI_SEMANTIC_EDGEFLAG, 0 ), ureg_DECL_next_vs_input(ureg)); } - tokens = ureg_get_tokens( ureg, NULL ); + vpv->state.tokens = ureg_get_tokens( ureg, NULL ); ureg_destroy( ureg ); vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->state); @@ -266,6 +267,7 @@ st_translate_fragment_program(struct st_context *st, GLuint defaultInputMapping[FRAG_ATTRIB_MAX]; GLuint interpMode[16]; /* XXX size? */ GLuint attr; + enum pipe_error error; const GLbitfield inputsRead = stfp->Base.Base.InputsRead; struct ureg_program *ureg; GLuint vslot = 0; @@ -404,12 +406,13 @@ st_translate_fragment_program(struct st_context *st, ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); if (ureg == NULL) - return NULL; + return; - stfp->state.tokens = + error = st_translate_mesa_program(st->ctx, TGSI_PROCESSOR_FRAGMENT, + ureg, &stfp->Base.Base, /* inputs */ fs_num_inputs, @@ -423,6 +426,8 @@ st_translate_fragment_program(struct st_context *st, fs_output_semantic_name, fs_output_semantic_index ); + stfp->state.tokens = ureg_get_tokens( ureg, NULL ); + ureg_destroy( ureg ); stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->state); if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) { -- cgit v1.2.3