remove usage of vertex_header

This commit is contained in:
Keith Whitwell 2008-04-08 17:59:28 +01:00 committed by Zack Rusin
parent 7a8ad75c89
commit c95dcc4962
13 changed files with 1485 additions and 1349 deletions

View File

@ -212,12 +212,6 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
case EMIT_1F:
feme->fetch[i].emit = emit_R32_FLOAT;
break;
case EMIT_HEADER:
feme->fetch[i].ptr = (const ubyte *)&zero;
feme->fetch[i].pitch = 0;
feme->fetch[i].fetch = fetch_R32_FLOAT;
feme->fetch[i].emit = emit_R32_FLOAT;
break;
case EMIT_1F_PSIZE:
feme->fetch[i].ptr = (const ubyte *)&feme->draw->rasterizer->point_size;
feme->fetch[i].pitch = 0;

View File

@ -126,13 +126,6 @@ dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data)
case EMIT_OMIT:
debug_printf("EMIT_OMIT:");
break;
case EMIT_ALL:
assert(i == 0);
assert(j == 0);
debug_printf("EMIT_ALL:\t");
for(k = 0; k < vinfo->size*4; ++k)
debug_printf("%02x ", *data++);
break;
case EMIT_1F:
debug_printf("EMIT_1F:\t");
debug_printf("%f ", *(float *)data); data += sizeof(float);
@ -217,19 +210,6 @@ emit_vertex( struct vbuf_stage *vbuf,
case EMIT_OMIT:
/* no-op */
break;
case EMIT_ALL:
/* just copy the whole vertex as-is to the vbuf */
assert(i == 0);
assert(j == 0);
memcpy(vbuf->vertex_ptr, vertex, vinfo->size * 4);
vbuf->vertex_ptr += vinfo->size;
count += vinfo->size;
break;
case EMIT_HEADER:
memcpy(vbuf->vertex_ptr, vertex, sizeof(*vertex));
*vbuf->vertex_ptr += sizeof(*vertex) / 4;
count += sizeof(*vertex) / 4;
break;
case EMIT_1F:
*vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
count++;

View File

@ -52,9 +52,6 @@ draw_compute_vertex_size(struct vertex_info *vinfo)
switch (vinfo->emit[i]) {
case EMIT_OMIT:
break;
case EMIT_HEADER:
vinfo->size += sizeof(struct vertex_header) / 4;
break;
case EMIT_4UB:
/* fall-through */
case EMIT_1F_PSIZE:
@ -71,8 +68,6 @@ draw_compute_vertex_size(struct vertex_info *vinfo)
case EMIT_4F:
vinfo->size += 4;
break;
case EMIT_ALL:
/* fall-through */
default:
assert(0);
}

View File

@ -47,8 +47,6 @@
*/
enum attrib_emit {
EMIT_OMIT, /**< don't emit the attribute */
EMIT_ALL, /**< emit whole post-xform vertex, w/ header */
EMIT_HEADER, /**< emit vertex_header struct (XXX temp?) */
EMIT_1F,
EMIT_1F_PSIZE, /**< insert constant point size */
EMIT_2F,

View File

@ -205,7 +205,7 @@ void draw_vf_set_vertex_info( struct draw_vertex_fetch *vf,
const struct vertex_info *vinfo,
float point_size )
{
unsigned i, j, k;
unsigned i, j;
struct draw_vf_attr *a = vf->attr;
struct draw_vf_attr_map attrs[PIPE_MAX_SHADER_INPUTS];
unsigned count = 0; /* for debug/sanity */
@ -217,60 +217,6 @@ void draw_vf_set_vertex_info( struct draw_vertex_fetch *vf,
case EMIT_OMIT:
/* no-op */
break;
case EMIT_ALL: {
/* just copy the whole vertex as-is to the vbuf */
unsigned s = vinfo->size;
assert(i == 0);
assert(j == 0);
/* copy the vertex header */
/* XXX: we actually don't copy the header, just pad it */
attrs[nr_attrs].attrib = 0;
attrs[nr_attrs].format = DRAW_EMIT_PAD;
attrs[nr_attrs].offset = offsetof(struct vertex_header, data);
s -= offsetof(struct vertex_header, data)/4;
count += offsetof(struct vertex_header, data)/4;
nr_attrs++;
/* copy the vertex data */
for(k = 0; k < (s & ~0x3); k += 4) {
attrs[nr_attrs].attrib = k/4;
attrs[nr_attrs].format = DRAW_EMIT_4F;
attrs[nr_attrs].offset = 0;
nr_attrs++;
count += 4;
}
/* tail */
/* XXX: actually, this shouldn't be needed */
attrs[nr_attrs].attrib = k/4;
attrs[nr_attrs].offset = 0;
switch(s & 0x3) {
case 0:
break;
case 1:
attrs[nr_attrs].format = DRAW_EMIT_1F;
nr_attrs++;
count += 1;
break;
case 2:
attrs[nr_attrs].format = DRAW_EMIT_2F;
nr_attrs++;
count += 2;
break;
case 3:
attrs[nr_attrs].format = DRAW_EMIT_3F;
nr_attrs++;
count += 3;
break;
}
break;
}
case EMIT_HEADER:
/* XXX emit new DRAW_EMIT_HEADER attribute??? */
attrs[nr_attrs].attrib = 0;
attrs[nr_attrs].format = DRAW_EMIT_PAD;
attrs[nr_attrs].offset = offsetof(struct vertex_header, data);
count += offsetof(struct vertex_header, data)/4;
nr_attrs++;
break;
case EMIT_1F:
attrs[nr_attrs].attrib = j;
attrs[nr_attrs].format = DRAW_EMIT_1F;

View File

@ -27,6 +27,7 @@ C_SOURCES = \
sp_quad_stencil.c \
sp_quad_stipple.c \
sp_screen.c \
sp_setup.c \
sp_state_blend.c \
sp_state_clip.c \
sp_state_derived.c \

View File

@ -14,6 +14,7 @@ softpipe = env.ConvenienceLibrary(
'sp_flush.c',
'sp_prim_setup.c',
'sp_prim_vbuf.c',
'sp_setup.c',
'sp_quad_alpha_test.c',
'sp_quad_blend.c',
'sp_quad.c',

File diff suppressed because it is too large Load Diff

View File

@ -69,6 +69,12 @@ typedef void (*vbuf_draw_func)( struct pipe_context *pipe,
extern struct draw_stage *
sp_draw_render_stage( struct softpipe_context *softpipe );
extern struct setup_context *
sp_draw_setup_context( struct draw_stage * );
extern void
sp_draw_flush( struct draw_stage * );
extern struct draw_stage *
sp_draw_vbuf_stage( struct draw_context *draw_context,

View File

@ -1,8 +1,8 @@
/**************************************************************************
*
*
* 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
@ -10,11 +10,11 @@
* 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.
@ -22,7 +22,7 @@
* 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.
*
*
**************************************************************************/
/**
@ -30,7 +30,7 @@
* softpipe rendering pipeline.
* Probably not desired in general, but useful for testing/debuggin.
* Enabled/Disabled with SP_VBUF env var.
*
*
* Authors
* Brian Paul
*/
@ -39,14 +39,16 @@
#include "sp_context.h"
#include "sp_state.h"
#include "sp_prim_vbuf.h"
#include "sp_prim_setup.h"
#include "sp_setup.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"
#define SP_MAX_VBUF_INDEXES 1024
#define SP_MAX_VBUF_SIZE 4096
typedef const float (*cptrf4)[4];
/**
* Subclass of vbuf_render.
@ -69,7 +71,6 @@ softpipe_vbuf_render(struct vbuf_render *vbr)
}
static const struct vertex_info *
sp_vbuf_get_vertex_info(struct vbuf_render *vbr)
{
@ -91,7 +92,7 @@ sp_vbuf_allocate_vertices(struct vbuf_render *vbr,
static void
sp_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
sp_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
unsigned vertex_size, unsigned vertices_used)
{
struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
@ -114,7 +115,7 @@ sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
else {
return FALSE;
}
}
@ -122,22 +123,19 @@ sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
* Recalculate prim's determinant.
* XXX is this needed?
*/
static void
calc_det(struct prim_header *header)
static float
calc_det( const float (*v0)[4],
const float (*v1)[4],
const float (*v2)[4] )
{
/* 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];
const float ex = v0[0][0] - v2[0][0];
const float ey = v0[0][1] - v2[0][1];
const float fx = v1[0][0] - v2[0][0];
const float fy = v1[0][1] - v2[0][1];
/* det = cross(e,f).z */
header->det = ex * fy - ey * fx;
return ex * fy - ey * fx;
}
@ -147,48 +145,51 @@ 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_vbuf.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;
cptrf4 v[3];
struct setup_context *setup_ctx = sp_draw_setup_context(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 );
for (j = 0; j < 3; j++)
v[j] = (cptrf4)((char *)vertex_buffer +
indices[i+j] * vertex_size);
setup_tri( setup_ctx,
calc_det(v[0], v[1], v[2]),
v[0],
v[1],
v[2]);
}
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 );
for (j = 0; j < 2; j++)
v[j] = (cptrf4)((char *)vertex_buffer +
indices[i+j] * vertex_size);
setup_line( setup_ctx,
v[0],
v[1] );
}
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 );
v[0] = (cptrf4)((char *)vertex_buffer +
indices[i] * vertex_size);
setup_point( setup_ctx,
v[0] );
}
break;
}
setup->flush( setup, 0 );
sp_draw_flush( setup );
}
@ -202,111 +203,131 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
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;
const void *vertex_buffer = cvbr->vertex_buffer;
const unsigned vertex_size = softpipe->vertex_info_vbuf.size * sizeof(float);
unsigned i;
prim.det = 0;
prim.reset_line_stipple = 0;
prim.edgeflags = 0;
prim.pad = 0;
struct setup_context *setup_ctx = sp_draw_setup_context(setup);
cptrf4 v[3];
#define VERTEX(I) \
(struct vertex_header *) ((char *) vertex_buffer + (I) * vertex_size)
(cptrf4) ((char *) vertex_buffer + (I) * vertex_size)
switch (cvbr->prim) {
case PIPE_PRIM_POINTS:
for (i = 0; i < nr; i++) {
prim.v[0] = VERTEX(i);
setup->point( setup, &prim );
v[0] = VERTEX(i);
setup_point( setup_ctx, v[0] );
}
break;
case PIPE_PRIM_LINES:
assert(nr % 2 == 0);
for (i = 0; i < nr; i += 2) {
prim.v[0] = VERTEX(i);
prim.v[1] = VERTEX(i + 1);
setup->line( setup, &prim );
v[0] = VERTEX(i);
v[1] = VERTEX(i + 1);
setup_line( setup_ctx, v[0], v[1] );
}
break;
case PIPE_PRIM_LINE_STRIP:
for (i = 1; i < nr; i++) {
prim.v[0] = VERTEX(i - 1);
prim.v[1] = VERTEX(i);
setup->line( setup, &prim );
v[0] = VERTEX(i - 1);
v[1] = VERTEX(i);
setup_line( setup_ctx, v[0], v[1] );
}
break;
case PIPE_PRIM_TRIANGLES:
assert(nr % 3 == 0);
for (i = 0; i < nr; i += 3) {
prim.v[0] = VERTEX(i + 0);
prim.v[1] = VERTEX(i + 1);
prim.v[2] = VERTEX(i + 2);
calc_det(&prim);
setup->tri( setup, &prim );
v[0] = VERTEX(i + 0);
v[1] = VERTEX(i + 1);
v[2] = VERTEX(i + 2);
setup_tri( setup_ctx,
calc_det(v[0], v[1], v[2]),
v[0],
v[1],
v[2] );
}
break;
case PIPE_PRIM_TRIANGLE_STRIP:
assert(nr >= 3);
for (i = 2; i < nr; i++) {
prim.v[0] = VERTEX(i - 2);
prim.v[1] = VERTEX(i - 1);
prim.v[2] = VERTEX(i);
calc_det(&prim);
setup->tri( setup, &prim );
v[0] = VERTEX(i - 2);
v[1] = VERTEX(i - 1);
v[2] = VERTEX(i);
setup_tri( setup_ctx,
calc_det(v[0], v[1], v[2]),
v[0],
v[1],
v[2] );
}
break;
case PIPE_PRIM_TRIANGLE_FAN:
assert(nr >= 3);
for (i = 2; i < nr; i++) {
prim.v[0] = VERTEX(0);
prim.v[1] = VERTEX(i - 1);
prim.v[2] = VERTEX(i);
calc_det(&prim);
setup->tri( setup, &prim );
v[0] = VERTEX(0);
v[1] = VERTEX(i - 1);
v[2] = VERTEX(i);
setup_tri( setup_ctx,
calc_det(v[0], v[1], v[2]),
v[0],
v[1],
v[2] );
}
break;
case PIPE_PRIM_QUADS:
assert(nr % 4 == 0);
for (i = 0; i < nr; i += 4) {
prim.v[0] = VERTEX(i + 0);
prim.v[1] = VERTEX(i + 1);
prim.v[2] = VERTEX(i + 2);
calc_det(&prim);
setup->tri( setup, &prim );
v[0] = VERTEX(i + 0);
v[1] = VERTEX(i + 1);
v[2] = VERTEX(i + 2);
setup_tri( setup_ctx,
calc_det(v[0], v[1], v[2]),
v[0],
v[1],
v[2] );
prim.v[0] = VERTEX(i + 0);
prim.v[1] = VERTEX(i + 2);
prim.v[2] = VERTEX(i + 3);
calc_det(&prim);
setup->tri( setup, &prim );
v[0] = VERTEX(i + 0);
v[1] = VERTEX(i + 2);
v[2] = VERTEX(i + 3);
setup_tri( setup_ctx,
calc_det(v[0], v[1], v[2]),
v[0],
v[1],
v[2] );
}
break;
case PIPE_PRIM_QUAD_STRIP:
assert(nr >= 4);
for (i = 2; i < nr; i += 2) {
prim.v[0] = VERTEX(i - 2);
prim.v[1] = VERTEX(i);
prim.v[2] = VERTEX(i + 1);
calc_det(&prim);
setup->tri( setup, &prim );
v[0] = VERTEX(i - 2);
v[1] = VERTEX(i);
v[2] = VERTEX(i + 1);
setup_tri( setup_ctx,
calc_det(v[0], v[1], v[2]),
v[0],
v[1],
v[2] );
prim.v[0] = VERTEX(i - 2);
prim.v[1] = VERTEX(i + 1);
prim.v[2] = VERTEX(i - 1);
calc_det(&prim);
setup->tri( setup, &prim );
v[0] = VERTEX(i - 2);
v[1] = VERTEX(i + 1);
v[2] = VERTEX(i - 1);
setup_tri( setup_ctx,
calc_det(v[0], v[1], v[2]),
v[0],
v[1],
v[2] );
}
break;
case PIPE_PRIM_POLYGON:
/* draw as tri fan */
for (i = 2; i < nr; i++) {
prim.v[0] = VERTEX(0);
prim.v[1] = VERTEX(i - 1);
prim.v[2] = VERTEX(i);
calc_det(&prim);
setup->tri( setup, &prim );
v[0] = VERTEX(0);
v[1] = VERTEX(i - 1);
v[2] = VERTEX(i);
setup_tri( setup_ctx,
calc_det(v[0], v[1], v[2]),
v[0],
v[1],
v[2] );
}
break;
default:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
/**************************************************************************
*
* 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_SETUP_H
#define SP_SETUP_H
struct setup_context;
struct softpipe_context;
void setup_tri( struct setup_context *setup,
float det,
const float (*v0)[4],
const float (*v1)[4],
const float (*v2)[4] );
void
setup_line(struct setup_context *setup,
const float (*v0)[4],
const float (*v1)[4]);
void
setup_point( struct setup_context *setup,
const float (*v0)[4] );
struct setup_context *setup_create_context( struct softpipe_context *softpipe );
void setup_prepare( struct setup_context *setup );
void setup_destroy_context( struct setup_context *setup );
#endif

View File

@ -71,25 +71,16 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
* simply emit the whole post-xform vertex as-is:
*/
struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf;
#if 0
vinfo_vbuf->num_attribs = 0;
/* special-case to allow memcpy of whole vertex */
draw_emit_vertex_attr(vinfo_vbuf, EMIT_ALL, INTERP_NONE, 0);
/* size in dwords or floats */
vinfo_vbuf->size = 4 * draw_num_vs_outputs(softpipe->draw)
+ sizeof(struct vertex_header) / 4;
#else
/* for pass-through mode, we need a more explicit list of attribs */
const uint num = draw_num_vs_outputs(softpipe->draw);
uint i;
/* No longer any need to try and emit draw vertex_header info.
*/
vinfo_vbuf->num_attribs = 0;
draw_emit_vertex_attr(vinfo_vbuf, EMIT_HEADER, INTERP_NONE, 0);
for (i = 0; i < num; i++) {
draw_emit_vertex_attr(vinfo_vbuf, EMIT_4F, INTERP_PERSPECTIVE, i);
}
draw_compute_vertex_size(vinfo_vbuf);
#endif
}
/*