diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/pipe/draw/draw_arrays.c | 7 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vb.c | 66 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_context.c | 5 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.c | 6 | ||||
-rw-r--r-- | src/mesa/sources | 3 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 29 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_draw.c | 72 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_draw.h | 12 |
9 files changed, 126 insertions, 86 deletions
diff --git a/src/mesa/pipe/draw/draw_arrays.c b/src/mesa/pipe/draw/draw_arrays.c index 59098fe2421..fe9ec444252 100644 --- a/src/mesa/pipe/draw/draw_arrays.c +++ b/src/mesa/pipe/draw/draw_arrays.c @@ -170,11 +170,12 @@ run_vertex_program(struct draw_context *draw, unsigned attr; for (attr = 0; attr < 16; attr++) { if (draw->vertex_shader.inputs_read & (1 << attr)) { + unsigned buf = draw->vertex_element[attr].vertex_buffer_index; const void *src - = (const void *) ((const ubyte *) draw->mapped_vbuffer[attr] - + draw->vertex_buffer[attr].buffer_offset + = (const void *) ((const ubyte *) draw->mapped_vbuffer[buf] + + draw->vertex_buffer[buf].buffer_offset + draw->vertex_element[attr].src_offset - + elts[j] * draw->vertex_buffer[attr].pitch); + + elts[j] * draw->vertex_buffer[buf].pitch); float p[4]; fetch_attrib4(src, draw->vertex_element[attr].src_format, p); diff --git a/src/mesa/pipe/draw/draw_vb.c b/src/mesa/pipe/draw/draw_vb.c index 0eefb0b250e..f83f8b8a0ec 100644 --- a/src/mesa/pipe/draw/draw_vb.c +++ b/src/mesa/pipe/draw/draw_vb.c @@ -259,72 +259,6 @@ void draw_vb(struct draw_context *draw, #endif /*MESA*/ -/** - * XXX Temporary mechanism to draw simple vertex arrays. - * All attribs are float[4]. Arrays are interleaved, in GL-speak. - */ -void -draw_vertices(struct draw_context *draw, - unsigned mode, - unsigned numVerts, const float *vertices, - unsigned numAttrs, const unsigned attribs[]) -{ - /*unsigned first, incr;*/ - unsigned i, j; - - assert(mode <= PIPE_PRIM_POLYGON); - - draw->vs_flush = vs_flush; - - draw->vertex_size - = sizeof(struct vertex_header) + numAttrs * 4 * sizeof(float); - - - /* no element/index buffer */ - draw_set_mapped_element_buffer(draw, 0, NULL); - - /*draw_prim_info(mode, &first, &incr);*/ - draw_allocate_vertices( draw, numVerts ); - draw->pipeline.first->begin( draw->pipeline.first ); - - if (draw->prim != mode) - draw_set_prim( draw, mode ); - - /* setup attr info */ - draw->nr_attrs = numAttrs + 2; - draw->attrs[0].attrib = VF_ATTRIB_VERTEX_HEADER; - draw->attrs[0].format = EMIT_1F; - draw->attrs[1].attrib = VF_ATTRIB_CLIP_POS; - draw->attrs[1].format = EMIT_4F; - for (j = 0; j < numAttrs; j++) { - draw->vf_attr_to_slot[attribs[j]] = 2+j; - draw->attrs[2+j].attrib = attribs[j]; - draw->attrs[2+j].format = EMIT_4F; - } - - /* build vertices */ - for (i = 0; i < numVerts; i++) { - struct vertex_header *v - = (struct vertex_header *) (draw->verts + i * draw->vertex_size); - v->clipmask = 0x0; - v->edgeflag = 0; - for (j = 0; j < numAttrs; j++) { - COPY_4FV(v->data[j], vertices + (i * numAttrs + j) * 4); - } - } - - /* draw */ - draw_prim(draw, 0, numVerts); - draw_flush(draw); - draw->pipeline.first->end( draw->pipeline.first ); - - - /* clean up */ - draw_release_vertices( draw ); - draw->verts = NULL; - draw->in_vb = 0; -} - #if 000 /** diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index 8a8582e0b20..c7d469583c7 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -155,7 +155,9 @@ static void i915_draw_vb( struct pipe_context *pipe, if (i915->dirty) i915_update_derived( i915 ); +#if 0 draw_vb( i915->draw, VB ); +#endif } @@ -169,8 +171,9 @@ i915_draw_vertices(struct pipe_context *pipe, if (i915->dirty) i915_update_derived( i915 ); - +#if 0 draw_vertices(i915->draw, mode, numVertex, verts, numAttribs, attribs); +#endif } diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index e7694bbe867..91ede05c05a 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -195,6 +195,7 @@ static void softpipe_destroy( struct pipe_context *pipe ) } +#if 0 static void softpipe_draw_vb( struct pipe_context *pipe, struct vertex_buffer *VB ) { @@ -208,6 +209,7 @@ static void softpipe_draw_vb( struct pipe_context *pipe, draw_vb( softpipe->draw, VB ); softpipe_unmap_surfaces(softpipe); } +#endif static void @@ -223,7 +225,9 @@ softpipe_draw_vertices(struct pipe_context *pipe, /* XXX move mapping/unmapping to higher/coarser level? */ softpipe_map_surfaces(softpipe); +#if 0 draw_vertices(softpipe->draw, mode, numVertex, verts, numAttribs, attribs); +#endif softpipe_unmap_surfaces(softpipe); } @@ -285,8 +289,10 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.set_vertex_buffer = softpipe_set_vertex_buffer; softpipe->pipe.set_vertex_element = softpipe_set_vertex_element; +#if 0 softpipe->pipe.draw_vb = softpipe_draw_vb; softpipe->pipe.draw_vertices = softpipe_draw_vertices; +#endif softpipe->pipe.draw_arrays = softpipe_draw_arrays; softpipe->pipe.draw_elements = softpipe_draw_elements; diff --git a/src/mesa/sources b/src/mesa/sources index 0731e64d8a0..0fe97e0287d 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -164,8 +164,7 @@ DRAW_SOURCES = \ pipe/draw/draw_offset.c \ pipe/draw/draw_prim.c \ pipe/draw/draw_twoside.c \ - pipe/draw/draw_unfilled.c \ - pipe/draw/draw_vb.c + pipe/draw/draw_unfilled.c TGSICORE_SOURCES = \ pipe/tgsi/core/tgsi_build.c \ diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index f6c65ff466c..bd050ca2cdc 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -38,11 +38,17 @@ #include "st_context.h" #include "st_cb_clear.h" #include "st_cb_fbo.h" +#include "st_draw.h" #include "st_program.h" #include "st_public.h" + #include "pipe/p_context.h" +#include "pipe/p_state.h" #include "pipe/p_defines.h" +#include "pipe/p_winsys.h" + #include "pipe/tgsi/mesa/mesa_to_tgsi.h" + #include "vf/vf.h" @@ -215,8 +221,8 @@ draw_quad(GLcontext *ctx, const GLfloat color[4]) { static const GLuint attribs[2] = { - VF_ATTRIB_POS, - VF_ATTRIB_COLOR0 + 0, /* pos */ + 3 /* color */ }; GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */ GLuint i; @@ -244,8 +250,7 @@ draw_quad(GLcontext *ctx, verts[i][1][3] = color[3]; } - ctx->st->pipe->draw_vertices(ctx->st->pipe, PIPE_PRIM_QUADS, - 4, (GLfloat *) verts, 2, attribs); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, attribs); } @@ -343,6 +348,21 @@ clear_with_quad(GLcontext *ctx, st->pipe->set_fs_state(st->pipe, &fs); } + /* vertex shader state: color/position pass-through */ + { + static struct st_vertex_program *stvp = NULL; + struct pipe_shader_state vs; + if (!stvp) { + stvp = make_vertex_shader(st); + } + memset(&vs, 0, sizeof(vs)); + vs.inputs_read = stvp->Base.Base.InputsRead; + vs.outputs_written = stvp->Base.Base.OutputsWritten; + vs.tokens = &stvp->tokens[0]; + vs.constants = NULL; + st->pipe->set_vs_state(st->pipe, &vs); + } + /* draw quad matching scissor rect (XXX verify coord round-off) */ draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); @@ -351,6 +371,7 @@ clear_with_quad(GLcontext *ctx, st->pipe->set_blend_state(st->pipe, &st->state.blend); st->pipe->set_depth_state(st->pipe, &st->state.depth); st->pipe->set_fs_state(st->pipe, &st->state.fs); + st->pipe->set_vs_state(st->pipe, &st->state.vs); st->pipe->set_setup_state(st->pipe, &st->state.setup); st->pipe->set_stencil_state(st->pipe, &st->state.stencil); /* OR: diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 11261f1d99c..1aa56fcf8bc 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -38,6 +38,7 @@ #include "st_program.h" #include "st_cb_drawpixels.h" #include "st_cb_texture.h" +#include "st_draw.h" #include "st_format.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -193,12 +194,12 @@ free_mipmap_tree(struct pipe_context *pipe, struct pipe_mipmap_tree *mt) * Y=0=top */ static void -draw_quad(struct st_context *st, GLfloat x0, GLfloat y0, GLfloat z, +draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, GLfloat x1, GLfloat y1) { static const GLuint attribs[2] = { - VF_ATTRIB_POS, - VF_ATTRIB_TEX0 + 0, /* pos */ + 8 /* tex0 */ }; GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */ GLuint i; @@ -235,8 +236,7 @@ draw_quad(struct st_context *st, GLfloat x0, GLfloat y0, GLfloat z, verts[i][1][3] = 1.0; /*Q*/ } - st->pipe->draw_vertices(st->pipe, PIPE_PRIM_QUADS, - 4, (GLfloat *) verts, 2, attribs); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (GLfloat *) verts, 2, attribs); } @@ -310,7 +310,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, y1 = ctx->DrawBuffer->Height - 1 - (y + height * ctx->Pixel.ZoomY); /* draw textured quad */ - draw_quad(ctx->st, x0, y0, z, x1, y1); + draw_quad(ctx, x0, y0, z, x1, y1); /* restore GL state */ pipe->set_setup_state(pipe, &ctx->st->state.setup); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index e82f7cff2b2..a409dd97648 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -66,7 +66,9 @@ static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage ) { struct st_context *st = st_context(ctx); +#if 0 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; +#endif /* Validate driver and pipe state: */ @@ -74,7 +76,9 @@ static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage ) /* Call into the new draw code to handle the VB: */ +#if 0 st->pipe->draw_vb( st->pipe, VB ); +#endif /* Finished */ @@ -289,6 +293,72 @@ draw_vbo(GLcontext *ctx, +/** + * Utility function for drawing simple primitives (such as quads for + * glClear and glDrawPixels). Coordinates are in screen space. + * \param mode one of PIPE_PRIM_x + * \param numVertex number of vertices + * \param verts vertex data (all attributes are float[4]) + * \param numAttribs number of attributes per vertex + * \param attribs index of each attribute (0=pos, 3=color, etc) + */ +void +st_draw_vertices(GLcontext *ctx, unsigned prim, + unsigned numVertex, float *verts, + unsigned numAttribs, const unsigned attribs[]) +{ + const float width = ctx->DrawBuffer->Width; + const float height = ctx->DrawBuffer->Height; + const unsigned vertex_bytes = numVertex * numAttribs * 4 * sizeof(float); + struct pipe_context *pipe = ctx->st->pipe; + struct pipe_buffer_handle *vbuf; + struct pipe_vertex_buffer vbuffer; + struct pipe_vertex_element velement; + unsigned i; + + assert(numAttribs > 0); + assert(attribs[0] == 0); /* position */ + + /* convert to clip coords */ + for (i = 0; i < numVertex; i++) { + float x = verts[i * numAttribs * 4 + 0]; + float y = verts[i * numAttribs * 4 + 1]; + x = x / width * 2.0 - 1.0; + y = y / height * 2.0 - 1.0; + verts[i * numAttribs * 4 + 0] = x; + verts[i * numAttribs * 4 + 1] = y; + } + + /* XXX create one-time */ + vbuf = pipe->winsys->buffer_create(pipe->winsys, 32); + pipe->winsys->buffer_data(pipe->winsys, vbuf, vertex_bytes, verts); + + /* tell pipe about the vertex buffer */ + vbuffer.buffer = vbuf; + vbuffer.pitch = numAttribs * 4 * sizeof(float); /* vertex size */ + vbuffer.buffer_offset = 0; + pipe->set_vertex_buffer(pipe, 0, &vbuffer); + + /* tell pipe about the vertex attributes */ + for (i = 0; i < numAttribs; i++) { + velement.src_offset = i * 4 * sizeof(GLfloat); + velement.vertex_buffer_index = 0; + velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velement.dst_offset = 0; + pipe->set_vertex_element(pipe, attribs[i], &velement); + } + + /* draw */ + pipe->draw_arrays(pipe, prim, 0, numVertex); + + /* XXX: do one-time */ + pipe->winsys->buffer_unreference(pipe->winsys, &vbuf); +} + + + + + /* This is all a hack to keep using tnl until we have vertex programs * up and running. @@ -307,8 +377,10 @@ void st_init_draw( struct st_context *st ) vbo->draw_prims = draw_vbo; #endif +#if 0 _tnl_destroy_pipeline( ctx ); _tnl_install_pipeline( ctx, st_pipeline ); +#endif /* USE_NEW_DRAW */ _tnl_ProgramCacheInit( ctx ); diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index 0afadab5779..0005fbc51f3 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2004 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -34,11 +34,15 @@ #ifndef ST_DRAW_H #define ST_DRAW_H + void st_init_draw( struct st_context *st ); + void st_destroy_draw( struct st_context *st ); -/** XXX temporary here */ -void st_clear(struct st_context *st, GLboolean color, GLboolean depth, - GLboolean stencil); +void +st_draw_vertices(GLcontext *ctx, unsigned prim, + unsigned numVertex, float *verts, + unsigned numAttribs, const unsigned attribs[]); + #endif |