diff options
author | Brian <[email protected]> | 2008-01-23 13:17:50 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2008-01-23 13:17:50 -0700 |
commit | 2d37e78e636e5e1e7d5d00230e50a00f7a71e868 (patch) | |
tree | 8fae0ed858c04330908996bc2289e50b8467718f /src/mesa/pipe | |
parent | cd3643698eafa0869a8317b002e5b066de0172e7 (diff) |
gallium: restore/rewrite vbuf code for softpipe
Now based on the draw_vbuf code, instead being a custom one-off.
Disabled by default, enable with SP_VBUF env var.
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r-- | src/mesa/pipe/draw/draw_vbuf.c | 5 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex.c | 3 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex.h | 1 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state_derived.c | 8 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.c | 9 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_prim_setup.c | 84 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_prim_setup.h | 10 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_prim_vbuf.c | 392 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_prim_vbuf.h | 38 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_derived.c | 69 |
10 files changed, 206 insertions, 413 deletions
diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index a4b6247e18d..c179b5e9dd1 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -145,6 +145,11 @@ emit_vertex( struct vbuf_stage *vbuf, case FORMAT_OMIT: /* no-op */ break; + case FORMAT_HEADER: + memcpy(vbuf->vertex_ptr, vertex, sizeof(*vertex)); + vbuf->vertex_ptr += sizeof(*vertex) / 4; + count += sizeof(*vertex) / 4; + break; case FORMAT_1F: *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); count++; diff --git a/src/mesa/pipe/draw/draw_vertex.c b/src/mesa/pipe/draw/draw_vertex.c index 1ab004be101..37d8b04ef9c 100644 --- a/src/mesa/pipe/draw/draw_vertex.c +++ b/src/mesa/pipe/draw/draw_vertex.c @@ -52,6 +52,9 @@ draw_compute_vertex_size(struct vertex_info *vinfo) switch (vinfo->format[i]) { case FORMAT_OMIT: break; + case FORMAT_HEADER: + vinfo->size += sizeof(struct vertex_header) / 4; + break; case FORMAT_4UB: /* fall-through */ case FORMAT_1F_PSIZE: diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 28abd8ab910..e76a17c198b 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -39,6 +39,7 @@ */ enum attrib_format { FORMAT_OMIT, /**< don't emit the attribute */ + FORMAT_HEADER, /**< The 5-byte vertex header */ FORMAT_1F, FORMAT_1F_PSIZE, /**< insert constant point size */ FORMAT_2F, diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 1f17de9cef0..03a46edc55f 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -130,14 +130,6 @@ static void calculate_vertex_layout( struct i915_context *i915 ) draw_compute_vertex_size(&vinfo); if (memcmp(&i915->current.vertex_info, &vinfo, sizeof(vinfo))) { - /* If the attributes have changed, tell the draw module about the new - * vertex layout. We'll also update the hardware vertex format info. - */ - /*draw_set_vertex_info( i915->draw, &vinfo);*/ - - /*draw_set_twoside_attributes(i915->draw, - front0, back0, front1, back1);*/ - /* Need to set this flag so that the LIS2/4 registers get set. * It also means the i915_update_immediate() function must be called * after this one, in i915_update_derived(). diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 6dccedbdcb4..81436c6d790 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -37,6 +37,7 @@ #include "sp_context.h" #include "sp_flush.h" #include "sp_prim_setup.h" +#include "sp_prim_vbuf.h" #include "sp_state.h" #include "sp_surface.h" #include "sp_tile_cache.h" @@ -328,12 +329,8 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, assert(softpipe->draw); softpipe->setup = sp_draw_render_stage(softpipe); - if (0 && GETENV( "SP_VBUF" ) != NULL) { - softpipe->vbuf = sp_draw_vbuf_stage(softpipe->draw, - &softpipe->pipe, - sp_vbuf_render); - - draw_set_rasterize_stage(softpipe->draw, softpipe->vbuf); + if (GETENV( "SP_VBUF" ) != NULL) { + sp_init_vbuf(softpipe); } else { draw_set_rasterize_stage(softpipe->draw, softpipe->setup); diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 533a2fbd4d1..9b2f10bbbb1 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -1237,87 +1237,3 @@ struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe ) return &setup->stage; } - - -/* Recalculate det. This is only used in the test harness below: - */ -static void calc_det( struct prim_header *header ) -{ - /* Window coords: */ - const float *v0 = header->v[0]->data[0]; - const float *v1 = header->v[1]->data[0]; - const float *v2 = header->v[2]->data[0]; - - /* edge vectors e = v0 - v2, f = v1 - v2 */ - const float ex = v0[0] - v2[0]; - const float ey = v0[1] - v2[1]; - const float fx = v1[0] - v2[0]; - const float fy = v1[1] - v2[1]; - - /* det = cross(e,f).z */ - header->det = ex * fy - ey * fx; -} - - - -/** - * Render buffer of points/lines/triangles. - * Called by vbuf code when the vertex or index buffer is filled. - * - * The big issue at this point is that reset_stipple doesn't make it - * through the interface. Probably need to split primitives at reset - * stipple, perhaps using the ~0 index marker. - */ -void sp_vbuf_render( struct pipe_context *pipe, - unsigned primitive, - const ushort *elements, - unsigned nr_elements, - const void *vertex_buffer, - unsigned nr_vertices ) -{ - struct softpipe_context *softpipe = softpipe_context( pipe ); - struct setup_stage *setup = setup_stage( softpipe->setup ); - struct prim_header prim; - unsigned vertex_size = softpipe->vertex_info.size * sizeof(float); - unsigned i, j; - - prim.det = 0; - prim.reset_line_stipple = 0; - prim.edgeflags = 0; - prim.pad = 0; - - setup->stage.begin( &setup->stage ); - - switch (primitive) { - case PIPE_PRIM_TRIANGLES: - for (i = 0; i < nr_elements; i += 3) { - for (j = 0; j < 3; j++) - prim.v[j] = (struct vertex_header *)((char *)vertex_buffer + - elements[i+j] * vertex_size); - - calc_det(&prim); - setup->stage.tri( &setup->stage, &prim ); - } - break; - - case PIPE_PRIM_LINES: - for (i = 0; i < nr_elements; i += 2) { - for (j = 0; j < 2; j++) - prim.v[j] = (struct vertex_header *)((char *)vertex_buffer + - elements[i+j] * vertex_size); - - setup->stage.line( &setup->stage, &prim ); - } - break; - - case PIPE_PRIM_POINTS: - for (i = 0; i < nr_elements; i++) { - prim.v[0] = (struct vertex_header *)((char *)vertex_buffer + - elements[i] * vertex_size); - setup->stage.point( &setup->stage, &prim ); - } - break; - } - - setup->stage.end( &setup->stage ); -} diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.h b/src/mesa/pipe/softpipe/sp_prim_setup.h index c16dc634b00..f3e8a79dd9e 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.h +++ b/src/mesa/pipe/softpipe/sp_prim_setup.h @@ -76,14 +76,4 @@ sp_draw_vbuf_stage( struct draw_context *draw_context, vbuf_draw_func draw ); -extern void -sp_vbuf_render( struct pipe_context *pipe, - unsigned prim, - const ushort *elements, - unsigned nr_elements, - const void *vertex_buffer, - unsigned nr_vertices ); - - - #endif /* SP_PRIM_SETUP_H */ diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.c b/src/mesa/pipe/softpipe/sp_prim_vbuf.c index 1d58e375a99..b76405f1792 100644 --- a/src/mesa/pipe/softpipe/sp_prim_vbuf.c +++ b/src/mesa/pipe/softpipe/sp_prim_vbuf.c @@ -2,7 +2,7 @@ * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -26,302 +26,198 @@ **************************************************************************/ /** - * Build post-transformation, post-clipping vertex buffers and element - * lists by hooking into the end of the primitive pipeline and - * manipulating the vertex_id field in the vertex headers. - * - * Keith Whitwell <[email protected]> + * Post-transform vertex buffering. This is an optional part of the + * softpipe rendering pipeline. + * Probably not desired in general, but useful for testing/debuggin. + * Enabled/Disabled with SP_VBUF env var. + * + * Authors + * Brian Paul */ #include "sp_context.h" -#include "sp_headers.h" -#include "sp_quad.h" -#include "sp_prim_setup.h" +#include "sp_prim_vbuf.h" +#include "pipe/draw/draw_context.h" #include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_vertex.h" -#include "pipe/p_util.h" - -static void vbuf_flush_elements( struct draw_stage *stage ); +#include "pipe/draw/draw_vbuf.h" -#define VBUF_SIZE (64*1024) -#define IBUF_SIZE (16*1024) +#define SP_MAX_VBUF_INDEXES 1024 +#define SP_MAX_VBUF_SIZE 4096 /** - * Vertex buffer emit stage. + * Subclass of vbuf_render. */ -struct vbuf_stage { - struct draw_stage stage; /**< This must be first (base class) */ - - struct draw_context *draw_context; - struct pipe_context *pipe; - vbuf_draw_func draw; - - /* Vertices are passed in as an array of floats making up each - * attribute in turn. Will eventually convert to hardware format - * in this stage. - */ - char *vertex_map; - char *vertex_ptr; - unsigned vertex_size; - unsigned nr_vertices; - - unsigned max_vertices; - - ushort *element_map; - unsigned nr_elements; - - unsigned prim; - -}; - -/** - * Basically a cast wrapper. - */ -static INLINE struct vbuf_stage *vbuf_stage( struct draw_stage *stage ) -{ - return (struct vbuf_stage *)stage; -} - - - - -static boolean overflow( void *map, void *ptr, unsigned bytes, unsigned bufsz ) +struct softpipe_vbuf_render { - unsigned long used = (unsigned long) ((char *) ptr - (char *) map); - return (used + bytes) > bufsz; -} - - -static boolean check_space( struct vbuf_stage *vbuf ) -{ - if (overflow( vbuf->vertex_map, - vbuf->vertex_ptr, - 4 * vbuf->vertex_size, - VBUF_SIZE )) - return FALSE; - - - if (vbuf->nr_elements + 4 > IBUF_SIZE / sizeof(ushort) ) - return FALSE; - - return TRUE; -} + struct vbuf_render base; + struct softpipe_context *softpipe; + uint prim; + uint vertex_size; + void *vertex_buffer; +}; -static void emit_vertex( struct vbuf_stage *vbuf, - struct vertex_header *vertex ) +/** cast wrapper */ +static struct softpipe_vbuf_render * +softpipe_vbuf_render(struct vbuf_render *vbr) { -// fprintf(stderr, "emit vertex %d to %p\n", -// vbuf->nr_vertices, vbuf->vertex_ptr); - - vertex->vertex_id = vbuf->nr_vertices++; - - //vbuf->emit_vertex( vbuf->vertex_ptr, vertex ); - - /* Note: for softpipe, the vertex includes the vertex header info - * such as clip flags and clip coords. In the future when vbuf is - * always used, we could just copy the vertex attributes/data here. - * The sp_prim_setup.c code doesn't use any of the vertex header info. - */ - memcpy(vbuf->vertex_ptr, vertex, vbuf->vertex_size); - - vbuf->vertex_ptr += vbuf->vertex_size; + return (struct softpipe_vbuf_render *) vbr; } -/** - * - */ -static void vbuf_tri( struct draw_stage *stage, - struct prim_header *prim ) -{ - struct vbuf_stage *vbuf = vbuf_stage( stage ); - unsigned i; - - if (!check_space( vbuf )) - vbuf_flush_elements( stage ); - - for (i = 0; i < 3; i++) { - if (prim->v[i]->vertex_id == UNDEFINED_VERTEX_ID) - emit_vertex( vbuf, prim->v[i] ); - - vbuf->element_map[vbuf->nr_elements++] = (ushort) prim->v[i]->vertex_id; - } -} - - -static void vbuf_line(struct draw_stage *stage, - struct prim_header *prim) +static const struct vertex_info * +sp_vbuf_get_vertex_info(struct vbuf_render *vbr) { - struct vbuf_stage *vbuf = vbuf_stage( stage ); - unsigned i; - - if (!check_space( vbuf )) - vbuf_flush_elements( stage ); - - for (i = 0; i < 2; i++) { - if (prim->v[i]->vertex_id == UNDEFINED_VERTEX_ID) - emit_vertex( vbuf, prim->v[i] ); - - vbuf->element_map[vbuf->nr_elements++] = (ushort) prim->v[i]->vertex_id; - } + struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); + /* XXX check for state changes? */ + return &cvbr->softpipe->vertex_info; } -static void vbuf_point(struct draw_stage *stage, - struct prim_header *prim) +static void * +sp_vbuf_allocate_vertices(struct vbuf_render *vbr, + ushort vertex_size, ushort nr_vertices) { - struct vbuf_stage *vbuf = vbuf_stage( stage ); - - if (!check_space( vbuf )) - vbuf_flush_elements( stage ); - - if (prim->v[0]->vertex_id == UNDEFINED_VERTEX_ID) - emit_vertex( vbuf, prim->v[0] ); - - vbuf->element_map[vbuf->nr_elements++] = (ushort) prim->v[0]->vertex_id; + struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); + assert(!cvbr->vertex_buffer); + cvbr->vertex_buffer = align_malloc(vertex_size * nr_vertices, 16); + cvbr->vertex_size = vertex_size; + return cvbr->vertex_buffer; } -static void vbuf_first_tri( struct draw_stage *stage, - struct prim_header *prim ) +static void +sp_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices, + unsigned vertex_size, unsigned vertices_used) { - struct vbuf_stage *vbuf = vbuf_stage( stage ); - - vbuf_flush_elements( stage ); - stage->tri = vbuf_tri; - stage->tri( stage, prim ); - vbuf->prim = PIPE_PRIM_TRIANGLES; + struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); + align_free(vertices); + assert(vertices == cvbr->vertex_buffer); + cvbr->vertex_buffer = NULL; } -static void vbuf_first_line( struct draw_stage *stage, - struct prim_header *prim ) -{ - struct vbuf_stage *vbuf = vbuf_stage( stage ); - - vbuf_flush_elements( stage ); - stage->line = vbuf_line; - stage->line( stage, prim ); - vbuf->prim = PIPE_PRIM_LINES; -} -static void vbuf_first_point( struct draw_stage *stage, - struct prim_header *prim ) +static void +sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim) { - struct vbuf_stage *vbuf = vbuf_stage( stage ); - - vbuf_flush_elements( stage ); - stage->point = vbuf_point; - stage->point( stage, prim ); - vbuf->prim = PIPE_PRIM_POINTS; + struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); + cvbr->prim = prim; } - -static void vbuf_flush_elements( struct draw_stage *stage ) -{ - struct vbuf_stage *vbuf = vbuf_stage( stage ); - - if (vbuf->nr_elements) { - /* - fprintf(stderr, "%s (%d elts)\n", __FUNCTION__, vbuf->nr_elements); - */ - - /* Draw now or add to list of primitives??? - */ - vbuf->draw( vbuf->pipe, - vbuf->prim, - vbuf->element_map, - vbuf->nr_elements, - vbuf->vertex_map, - (unsigned) (vbuf->vertex_ptr - vbuf->vertex_map) / vbuf->vertex_size ); - - vbuf->nr_elements = 0; - - vbuf->vertex_ptr = vbuf->vertex_map; - vbuf->nr_vertices = 0; - - /* Reset vertex ids? Actually, want to not do that unless our - * vertex buffer is full. Would like separate - * flush-on-index-full and flush-on-vb-full, but may raise - * issues uploading vertices if the hardware wants to flush when - * we flush. - */ - draw_reset_vertex_ids( vbuf->draw_context ); +/** + * Recalculate prim's determinant. + * XXX is this needed? + */ +static void +calc_det(struct prim_header *header) +{ + /* Window coords: */ + const float *v0 = header->v[0]->data[0]; + const float *v1 = header->v[1]->data[0]; + const float *v2 = header->v[2]->data[0]; + + /* edge vectors e = v0 - v2, f = v1 - v2 */ + const float ex = v0[0] - v2[0]; + const float ey = v0[1] - v2[1]; + const float fx = v1[0] - v2[0]; + const float fy = v1[1] - v2[1]; + + /* det = cross(e,f).z */ + header->det = ex * fy - ey * fx; +} + + +static void +sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr_indices) +{ + struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); + struct softpipe_context *softpipe = cvbr->softpipe; + struct draw_stage *setup = softpipe->setup; + struct prim_header prim; + unsigned vertex_size = softpipe->vertex_info.size * sizeof(float); + unsigned i, j; + void *vertex_buffer = cvbr->vertex_buffer; + + prim.det = 0; + prim.reset_line_stipple = 0; + prim.edgeflags = 0; + prim.pad = 0; + + setup->begin( setup ); + + switch (cvbr->prim) { + case PIPE_PRIM_TRIANGLES: + for (i = 0; i < nr_indices; i += 3) { + for (j = 0; j < 3; j++) + prim.v[j] = (struct vertex_header *)((char *)vertex_buffer + + indices[i+j] * vertex_size); + + calc_det(&prim); + setup->tri( setup, &prim ); + } + break; + + case PIPE_PRIM_LINES: + for (i = 0; i < nr_indices; i += 2) { + for (j = 0; j < 2; j++) + prim.v[j] = (struct vertex_header *)((char *)vertex_buffer + + indices[i+j] * vertex_size); + + setup->line( setup, &prim ); + } + break; + + case PIPE_PRIM_POINTS: + for (i = 0; i < nr_indices; i++) { + prim.v[0] = (struct vertex_header *)((char *)vertex_buffer + + indices[i] * vertex_size); + setup->point( setup, &prim ); + } + break; } - stage->tri = vbuf_first_tri; - stage->line = vbuf_first_line; - stage->point = vbuf_first_point; + setup->end( setup ); } -static void vbuf_begin( struct draw_stage *stage ) +static void +sp_vbuf_destroy(struct vbuf_render *vbr) { - struct vbuf_stage *vbuf = vbuf_stage(stage); - struct softpipe_context *softpipe = softpipe_context(vbuf->pipe); - - //vbuf->vertex_size = vbuf->draw_context->vertex_info.size * sizeof(float); - - vbuf->vertex_size = softpipe->vertex_info.size * sizeof(float); + struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); + cvbr->softpipe->vbuf_render = NULL; + FREE(cvbr); } -static void vbuf_end( struct draw_stage *stage ) -{ - /* Overkill. - */ - vbuf_flush_elements( stage ); -} - - -static void reset_stipple_counter( struct draw_stage *stage ) +/** + * Initialize the post-transform vertex buffer information for the given + * context. + */ +void +sp_init_vbuf(struct softpipe_context *sp) { - /* XXX: This doesn't work. - */ -} + assert(sp->draw); + sp->vbuf_render = CALLOC_STRUCT(softpipe_vbuf_render); -static void vbuf_destroy( struct draw_stage *stage ) -{ - struct vbuf_stage *vbuf = vbuf_stage( stage ); + sp->vbuf_render->base.max_indices = SP_MAX_VBUF_INDEXES; + sp->vbuf_render->base.max_vertex_buffer_bytes = SP_MAX_VBUF_SIZE; - FREE( vbuf->element_map ); - FREE( vbuf->vertex_map ); - FREE( stage ); -} + sp->vbuf_render->base.get_vertex_info = sp_vbuf_get_vertex_info; + sp->vbuf_render->base.allocate_vertices = sp_vbuf_allocate_vertices; + sp->vbuf_render->base.set_primitive = sp_vbuf_set_primitive; + sp->vbuf_render->base.draw = sp_vbuf_draw; + sp->vbuf_render->base.release_vertices = sp_vbuf_release_vertices; + sp->vbuf_render->base.destroy = sp_vbuf_destroy; + sp->vbuf_render->softpipe = sp; -/** - * Create a new primitive vbuf/render stage. - */ -struct draw_stage *sp_draw_vbuf_stage( struct draw_context *draw_context, - struct pipe_context *pipe, - vbuf_draw_func draw ) -{ - struct vbuf_stage *vbuf = CALLOC_STRUCT(vbuf_stage); - - vbuf->stage.begin = vbuf_begin; - vbuf->stage.point = vbuf_first_point; - vbuf->stage.line = vbuf_first_line; - vbuf->stage.tri = vbuf_first_tri; - vbuf->stage.end = vbuf_end; - vbuf->stage.reset_stipple_counter = reset_stipple_counter; - vbuf->stage.destroy = vbuf_destroy; - - vbuf->pipe = pipe; - vbuf->draw = draw; - vbuf->draw_context = draw_context; - - vbuf->element_map = MALLOC( IBUF_SIZE ); - vbuf->vertex_map = MALLOC( VBUF_SIZE ); - - vbuf->vertex_ptr = vbuf->vertex_map; - + sp->vbuf = draw_vbuf_stage(sp->draw, &sp->vbuf_render->base); - return &vbuf->stage; + draw_set_rasterize_stage(sp->draw, sp->vbuf); } diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.h b/src/mesa/pipe/softpipe/sp_prim_vbuf.h new file mode 100644 index 00000000000..1de9cc2a894 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_prim_vbuf.h @@ -0,0 +1,38 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef SP_VBUF_H +#define SP_VBUF_H + + +struct softpipe_context; + +extern void +sp_init_vbuf(struct softpipe_context *softpipe); + + +#endif /* SP_VBUF_H */ diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 64e86a0d86d..74d34c50a85 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -45,24 +45,16 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) const enum interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &softpipe->vertex_info; - boolean emitBack0 = FALSE, emitBack1 = FALSE, emitPsize = FALSE; - uint front0 = 0, back0 = 0, front1 = 0, back1 = 0; uint i; - int src = 0; memset(vinfo, 0, sizeof(*vinfo)); - - if (fs->input_semantic_name[0] == TGSI_SEMANTIC_POSITION) { - /* Need Z if depth test is enabled or the fragment program uses the - * fragment position (XYZW). - */ - } - softpipe->psize_slot = -1; - /* always emit vertex pos */ - draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR, src++); + if (softpipe->vbuf) { + /* softpipe's setup/rasterizer stage expects vertex to have a header */ + draw_emit_vertex_attr(vinfo, FORMAT_HEADER, INTERP_LINEAR, 0); + } /* * XXX I think we need to reconcile the vertex shader outputs with @@ -75,46 +67,38 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) switch (vs->output_semantic_name[i]) { case TGSI_SEMANTIC_POSITION: - /* vertex programs always emit position, but might not be - * needed for fragment progs. - */ - /* no-op */ + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR, i); break; case TGSI_SEMANTIC_COLOR: if (vs->output_semantic_index[i] == 0) { - front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++); + draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, i); } else { assert(vs->output_semantic_index[i] == 1); - front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++); + draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, i); } break; case TGSI_SEMANTIC_BCOLOR: - if (vs->output_semantic_index[i] == 0) { - emitBack0 = TRUE; - } - else { - assert(vs->output_semantic_index[i] == 1); - emitBack1 = TRUE; - } + /* no-op */ break; case TGSI_SEMANTIC_FOG: - draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE, src++); + draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE, i); break; case TGSI_SEMANTIC_PSIZE: /* XXX only emit if drawing points or front/back polygon mode * is point mode */ - emitPsize = TRUE; + softpipe->psize_slot + = draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT, i); break; case TGSI_SEMANTIC_GENERIC: /* this includes texcoords and varying vars */ - draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, src++); + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE, i); break; default: @@ -125,35 +109,6 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) draw_compute_vertex_size(vinfo); softpipe->nr_frag_attrs = fs->num_inputs; - - /* We want these after all other attribs since they won't get passed - * to the fragment shader. All prior vertex output attribs should match - * up 1:1 with the fragment shader inputs. - */ - if (emitBack0) { - back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++); - } - if (emitBack1) { - back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp, src++); - } - if (emitPsize) { - softpipe->psize_slot - = draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT, src++); - } - - /* If the attributes have changed, tell the draw module about - * the new vertex layout. - */ - /* XXX we also need to do this when the shading mode (interp modes) change: */ - if (1/*vinfo->attr_mask != softpipe->attr_mask*/) { - /*softpipe->attr_mask = vinfo->attr_mask;*/ - - /*draw_set_vertex_info( softpipe->draw, vinfo);*/ - - /*draw_set_twoside_attributes(softpipe->draw, - front0, back0, front1, back1); - */ - } } |