From bb193c6d22125f1af62e81c1251acd2a68939608 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 10 Sep 2007 16:28:10 -0600 Subject: glRasterPos function --- src/mesa/state_tracker/st_cb_rasterpos.c | 350 +++++++++++++++++++++++++++++++ 1 file changed, 350 insertions(+) create mode 100644 src/mesa/state_tracker/st_cb_rasterpos.c (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c new file mode 100644 index 0000000000..5040c21e51 --- /dev/null +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -0,0 +1,350 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + + /* + * Authors: + * Brian Paul + */ + +#include "main/imports.h" +#include "main/macros.h" + +#include "st_context.h" +#include "st_atom.h" +#include "st_draw.h" +#include "st_program.h" +#include "st_cb_rasterpos.h" +#include "st_draw.h" +#include "st_format.h" +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_winsys.h" +#include "pipe/tgsi/exec/tgsi_attribs.h" +#include "shader/prog_instruction.h" +#include "vf/vf.h" + + + +static void +setup_vertex_attribs(GLcontext *ctx) +{ + struct pipe_context *pipe = ctx->st->pipe; + const uint inputAttrs = ctx->st->state.vs.inputs_read; + uint attr; + + /* all attributes come from the default attribute buffer */ + { + struct pipe_vertex_buffer vbuffer; + vbuffer.buffer = ctx->st->default_attrib_buffer; + vbuffer.buffer_offset = 0; + vbuffer.pitch = 0; /* must be zero! */ + vbuffer.max_index = 1; + pipe->set_vertex_buffer(pipe, 0, &vbuffer); + } + + for (attr = 0; attr < 16; attr++) { + struct pipe_vertex_element velement; + + if (inputAttrs & (1 << attr)) { + velement.src_offset = attr * 4 * sizeof(GLfloat); + velement.vertex_buffer_index = 0; + velement.dst_offset = 0; + velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + pipe->set_vertex_element(pipe, attr, &velement); + } + } +} + + +static void +setup_feedback(GLcontext *ctx) +{ + struct pipe_context *pipe = ctx->st->pipe; + const uint outputAttrs = ctx->st->state.vs.outputs_written; + struct pipe_feedback_state feedback; + uint i; + + memset(&feedback, 0, sizeof(feedback)); + feedback.enabled = 1; + feedback.interleaved = 1; + feedback.discard = 1; + feedback.num_attribs = 0; + + for (i = 0; i < TGSI_ATTRIB_VAR0; i++) { + if ((1 << i) & outputAttrs) { + feedback.attrib[feedback.num_attribs] = i; + feedback.size[feedback.num_attribs] = 4; + feedback.num_attribs++; + } + } + + pipe->set_feedback_state(pipe, &feedback); +} + + + + + +/** + * Clip a point against the view volume. + * + * \param v vertex vector describing the point to clip. + * + * \return zero if outside view volume, or one if inside. + */ +static GLuint +viewclip_point( const GLfloat v[] ) +{ + if ( v[0] > v[3] || v[0] < -v[3] + || v[1] > v[3] || v[1] < -v[3] + || v[2] > v[3] || v[2] < -v[3] ) { + return 0; + } + else { + return 1; + } +} + + +/** + * Clip a point against the far/near Z clipping planes. + * + * \param v vertex vector describing the point to clip. + * + * \return zero if outside view volume, or one if inside. + */ +static GLuint +viewclip_point_z( const GLfloat v[] ) +{ + if (v[2] > v[3] || v[2] < -v[3] ) { + return 0; + } + else { + return 1; + } +} + + +/** + * Clip a point against the user clipping planes. + * + * \param ctx GL context. + * \param v vertex vector describing the point to clip. + * + * \return zero if the point was clipped, or one otherwise. + */ +static GLuint +userclip_point( GLcontext *ctx, const GLfloat v[] ) +{ + GLuint p; + + for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { + if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { + GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0] + + v[1] * ctx->Transform._ClipUserPlane[p][1] + + v[2] * ctx->Transform._ClipUserPlane[p][2] + + v[3] * ctx->Transform._ClipUserPlane[p][3]; + if (dot < 0.0F) { + return 0; + } + } + } + + return 1; +} + + +/** + * Update the current raster position. + * Do clip testing, etc. here. + */ +static void +update_rasterpos(GLcontext *ctx, + const float clipPos[4], + const float color0[4], + const float color1[4], + const float *tex) +{ + uint i; + float d, ndc[3]; + + /* clip to view volume */ + if (ctx->Transform.RasterPositionUnclipped) { + /* GL_IBM_rasterpos_clip: only clip against Z */ + if (viewclip_point_z(clipPos) == 0) { + ctx->Current.RasterPosValid = GL_FALSE; + return; + } + } + else if (viewclip_point(clipPos) == 0) { + /* Normal OpenGL behaviour */ + ctx->Current.RasterPosValid = GL_FALSE; + return; + } + + /* clip to user clipping planes */ + if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clipPos)) { + ctx->Current.RasterPosValid = GL_FALSE; + return; + } + + + /* + * update current raster position + */ + /* ndc = clip / W */ + d = (clipPos[3] == 0.0F) ? 1.0F : 1.0F / clipPos[3]; + ndc[0] = clipPos[0] * d; + ndc[1] = clipPos[1] * d; + ndc[2] = clipPos[2] * d; + /* wincoord = viewport_mapping(ndc) */ + ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] + + ctx->Viewport._WindowMap.m[MAT_TX]); + ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] + + ctx->Viewport._WindowMap.m[MAT_TY]); + ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] + + ctx->Viewport._WindowMap.m[MAT_TZ]) + / ctx->DrawBuffer->_DepthMaxF; + ctx->Current.RasterPos[3] = clipPos[3]; + + /* compute raster distance */ + if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) + ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; + else { +#if 0 + /* XXX we don't have an eye coord! */ + ctx->Current.RasterDistance = + SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] ); +#endif + } + + /* colors and texcoords */ + COPY_4FV(ctx->Current.RasterColor, color0); + COPY_4FV(ctx->Current.RasterSecondaryColor, color1); + for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { + COPY_4FV(ctx->Current.RasterTexCoords + i, tex + i *4); + } + + ctx->Current.RasterPosValid = GL_TRUE; +} + + + +static void +st_RasterPos(GLcontext *ctx, const GLfloat v[4]) +{ + struct pipe_context *pipe = ctx->st->pipe; + float *buf_map; + struct pipe_feedback_buffer fb_buf; + + st_validate_state(ctx->st); + + /* setup vertex buffers */ + setup_vertex_attribs(ctx); + + /* + * Load the default attribute buffer with current attribs. + */ + { + struct pipe_buffer_handle *buf = ctx->st->default_attrib_buffer; + const unsigned size = sizeof(ctx->Current.Attrib); + const void *data = ctx->Current.Attrib; + /* colors, texcoords, etc */ + pipe->winsys->buffer_data(pipe->winsys, buf, size, data); + /* position */ + pipe->winsys->buffer_subdata(pipe->winsys, buf, + 0, /* offset */ + 4 * sizeof(float), /* size */ + v); /* data */ + } + + + /* setup feedback state */ + setup_feedback(ctx); + + /* setup vertex feedback buffer */ + { + fb_buf.size = 8 * 4 * sizeof(float); + fb_buf.buffer = pipe->winsys->buffer_create(pipe->winsys, 0); + fb_buf.start_offset = 0; + pipe->winsys->buffer_data(pipe->winsys, fb_buf.buffer, + fb_buf.size, + NULL); /* data */ + pipe->set_feedback_buffer(pipe, 0, &fb_buf); + } + + + /* draw a point */ + pipe->draw_arrays(pipe, GL_POINTS, 0, 1); + + /* get feedback */ + buf_map = (float *) pipe->winsys->buffer_map(pipe->winsys, fb_buf.buffer, + PIPE_BUFFER_FLAG_READ); + + /* extract values and update rasterpos state */ + { + const uint outputAttrs = ctx->st->state.vs.outputs_written; + const float *pos, *color0, *color1, *tex0; + float *buf = buf_map; + + assert(outputAttrs & (1 << TGSI_ATTRIB_POS)); + pos = buf; + buf += 4; + + if (outputAttrs & (1 << TGSI_ATTRIB_COLOR0)) { + color0 = buf; + buf += 4; + } + else { + color0 = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; + } + + if (outputAttrs & (1 << TGSI_ATTRIB_COLOR1)) { + color1 = buf; + buf += 4; + } + else { + color1 = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; + } + + update_rasterpos(ctx, pos, color0, color1, tex0); + } + + + /* free vertex feedback buffer */ + pipe->winsys->buffer_unmap(pipe->winsys, fb_buf.buffer); + pipe->winsys->buffer_unreference(pipe->winsys, &fb_buf.buffer); + + /* restore pipe state */ + pipe->set_feedback_state(pipe, &ctx->st->state.feedback); +} + + +void st_init_rasterpos_functions(struct dd_function_table *functions) +{ + functions->RasterPos = st_RasterPos; +} -- cgit v1.2.3 From 6275b40063d7d06e0b05767ebca3963ce7e9c34e Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 10 Sep 2007 16:52:05 -0600 Subject: merge buffer_unreference(), buffer_reference() --- .../drivers/dri/intel_winsys/intel_winsys_pipe.c | 18 +++++----- src/mesa/drivers/x11/xm_winsys.c | 42 +++++++++++----------- src/mesa/pipe/i915simple/i915_regions.c | 4 +-- src/mesa/pipe/p_winsys.h | 9 +++-- src/mesa/pipe/softpipe/sp_region.c | 4 +-- src/mesa/pipe/softpipe/sp_state_fs.c | 5 +-- src/mesa/state_tracker/st_cb_bufferobjects.c | 2 +- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- src/mesa/state_tracker/st_draw.c | 5 +-- 9 files changed, 45 insertions(+), 46 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c index 33aacf2a43..668bedcbda 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c @@ -84,22 +84,21 @@ static void intel_buffer_unmap(struct pipe_winsys *sws, } -static struct pipe_buffer_handle * +static void intel_buffer_reference(struct pipe_winsys *sws, + struct pipe_buffer_handle **ptr, struct pipe_buffer_handle *buf) { - return pipe_bo( driBOReference( dri_bo(buf) ) ); -} - -static void intel_buffer_unreference(struct pipe_winsys *sws, - struct pipe_buffer_handle **buf) -{ - if (*buf) { - driBOUnReference( dri_bo(*buf) ); + if (*ptr) { + driBOUnReference( dri_bo(*ptr) ); *buf = NULL; } + + driBOReference( dri_bo(buf) ); + *ptr = buf; } + /* Grabs the hardware lock! */ static void intel_buffer_data(struct pipe_winsys *sws, @@ -208,7 +207,6 @@ intel_create_pipe_winsys( struct intel_context *intel ) iws->winsys.buffer_map = intel_buffer_map; iws->winsys.buffer_unmap = intel_buffer_unmap; iws->winsys.buffer_reference = intel_buffer_reference; - iws->winsys.buffer_unreference = intel_buffer_unreference; iws->winsys.buffer_data = intel_buffer_data; iws->winsys.buffer_subdata = intel_buffer_subdata; iws->winsys.buffer_get_subdata = intel_buffer_get_subdata; diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c index f1ecbf531f..b7b2941490 100644 --- a/src/mesa/drivers/x11/xm_winsys.c +++ b/src/mesa/drivers/x11/xm_winsys.c @@ -108,30 +108,31 @@ xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf) xm_buf->mapped = NULL; } - -static struct pipe_buffer_handle * -xm_buffer_reference(struct pipe_winsys *pws, struct pipe_buffer_handle *buf) -{ - struct xm_buffer *xm_buf = xm_bo(buf); - xm_buf->refcount++; - return buf; -} - static void -xm_buffer_unreference(struct pipe_winsys *pws, struct pipe_buffer_handle **buf) +xm_buffer_reference(struct pipe_winsys *pws, + struct pipe_buffer_handle **ptr, + struct pipe_buffer_handle *buf) { - if (*buf) { - struct xm_buffer *xm_buf = xm_bo(*buf); - xm_buf->refcount--; - assert(xm_buf->refcount >= 0); - if (xm_buf->refcount == 0) { - if (xm_buf->data) { - free(xm_buf->data); - xm_buf->data = NULL; + if (*ptr) { + struct xm_buffer *oldBuf = xm_bo(*ptr); + oldBuf->refcount--; + assert(oldBuf->refcount >= 0); + if (oldBuf->refcount == 0) { + if (oldBuf->data) { + free(oldBuf->data); + oldBuf->data = NULL; } - free(xm_buf); + free(oldBuf); } - *buf = NULL; + *ptr = NULL; + } + + assert(!(*ptr)); + + if (buf) { + struct xm_buffer *newBuf = xm_bo(buf); + newBuf->refcount++; + *ptr = buf; } } @@ -237,7 +238,6 @@ xmesa_create_pipe_winsys( XMesaContext xmesa ) xws->winsys.buffer_map = xm_buffer_map; xws->winsys.buffer_unmap = xm_buffer_unmap; xws->winsys.buffer_reference = xm_buffer_reference; - xws->winsys.buffer_unreference = xm_buffer_unreference; xws->winsys.buffer_data = xm_buffer_data; xws->winsys.buffer_subdata = xm_buffer_subdata; xws->winsys.buffer_get_subdata = xm_buffer_get_subdata; diff --git a/src/mesa/pipe/i915simple/i915_regions.c b/src/mesa/pipe/i915simple/i915_regions.c index aad4a6a537..bab256c763 100644 --- a/src/mesa/pipe/i915simple/i915_regions.c +++ b/src/mesa/pipe/i915simple/i915_regions.c @@ -123,8 +123,8 @@ i915_region_release(struct pipe_context *pipe, struct pipe_region **region) if ((*region)->refcount == 0) { assert((*region)->map_refcount == 0); - i915->pipe.winsys->buffer_unreference( i915->pipe.winsys, - &((*region)->buffer) ); + i915->pipe.winsys->buffer_reference( i915->pipe.winsys, + &((*region)->buffer), NULL ); free(*region); } *region = NULL; diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index 09baef020e..4d2cc2196f 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -79,11 +79,10 @@ struct pipe_winsys { void (*buffer_unmap)( struct pipe_winsys *sws, struct pipe_buffer_handle *buf ); - struct pipe_buffer_handle *(*buffer_reference)( struct pipe_winsys *sws, - struct pipe_buffer_handle *buf ); - - void (*buffer_unreference)( struct pipe_winsys *sws, - struct pipe_buffer_handle **buf ); + /** Set ptr = buf, with reference counting */ + void (*buffer_reference)( struct pipe_winsys *sws, + struct pipe_buffer_handle **ptr, + struct pipe_buffer_handle *buf ); void (*buffer_data)(struct pipe_winsys *sws, struct pipe_buffer_handle *buf, diff --git a/src/mesa/pipe/softpipe/sp_region.c b/src/mesa/pipe/softpipe/sp_region.c index 25d0a419aa..ae05b1d0de 100644 --- a/src/mesa/pipe/softpipe/sp_region.c +++ b/src/mesa/pipe/softpipe/sp_region.c @@ -121,8 +121,8 @@ sp_region_release(struct pipe_context *pipe, struct pipe_region **region) if ((*region)->refcount == 0) { assert((*region)->map_refcount == 0); - sp->pipe.winsys->buffer_unreference( sp->pipe.winsys, - &((*region)->buffer) ); + sp->pipe.winsys->buffer_reference( sp->pipe.winsys, + &((*region)->buffer), NULL ); free(*region); } *region = NULL; diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index 9e3ff6d35c..5ab246896b 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -68,8 +68,9 @@ void softpipe_set_constant_buffer(struct pipe_context *pipe, assert(index == 0); /* note: reference counting */ - ws->buffer_unreference(ws, &softpipe->constants[shader].buffer); - softpipe->constants[shader].buffer = ws->buffer_reference(ws, buf->buffer); + ws->buffer_reference(ws, + &softpipe->constants[shader].buffer, + buf->buffer); softpipe->constants[shader].size = buf->size; softpipe->dirty |= SP_NEW_CONSTANTS; diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index f1dc4fbaf4..a593bd74d1 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -81,7 +81,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj) struct st_buffer_object *st_obj = st_buffer_object(obj); if (st_obj->buffer) - pipe->winsys->buffer_unreference(pipe->winsys, &st_obj->buffer); + pipe->winsys->buffer_reference(pipe->winsys, &st_obj->buffer, NULL); free(st_obj); } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 5040c21e51..7bedf3f89f 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -337,7 +337,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) /* free vertex feedback buffer */ pipe->winsys->buffer_unmap(pipe->winsys, fb_buf.buffer); - pipe->winsys->buffer_unreference(pipe->winsys, &fb_buf.buffer); + pipe->winsys->buffer_reference(pipe->winsys, &fb_buf.buffer, NULL); /* restore pipe state */ pipe->set_feedback_state(pipe, &ctx->st->state.feedback); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index afb6f96a26..1facc14ccd 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -152,7 +152,8 @@ static void destroy_default_attribs_buffer(struct st_context *st) { struct pipe_context *pipe = st->pipe; - pipe->winsys->buffer_unreference(pipe->winsys, &st->default_attrib_buffer); + pipe->winsys->buffer_reference(pipe->winsys, + &st->default_attrib_buffer, NULL); } @@ -349,7 +350,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, pipe->draw_arrays(pipe, prim, 0, numVertex); /* XXX: do one-time */ - pipe->winsys->buffer_unreference(pipe->winsys, &vbuf); + pipe->winsys->buffer_reference(pipe->winsys, &vbuf, NULL); } -- cgit v1.2.3 From ccd63b54cfbb6bb241d55f7ac95afcd14819f469 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 18 Sep 2007 13:24:44 -0400 Subject: Convert shader to an immutable state object. --- src/mesa/pipe/cso_cache/cso_cache.c | 13 +++++++++---- src/mesa/pipe/cso_cache/cso_cache.h | 4 +++- src/mesa/pipe/failover/fo_context.h | 4 ++-- src/mesa/pipe/failover/fo_state.c | 19 +++++++++---------- src/mesa/pipe/failover/fo_state_emit.c | 4 ++-- src/mesa/pipe/i915simple/i915_context.h | 2 +- src/mesa/pipe/i915simple/i915_fpc.h | 2 +- src/mesa/pipe/i915simple/i915_fpc_translate.c | 8 ++++---- src/mesa/pipe/i915simple/i915_state.c | 27 ++++++++++++++++++++++----- src/mesa/pipe/i915simple/i915_state_derived.c | 2 +- src/mesa/pipe/p_context.h | 16 ++++++++++------ src/mesa/pipe/softpipe/sp_context.c | 14 ++++++++------ src/mesa/pipe/softpipe/sp_context.h | 4 ++-- src/mesa/pipe/softpipe/sp_quad_fs.c | 2 +- src/mesa/pipe/softpipe/sp_state.h | 14 +++++++++----- src/mesa/pipe/softpipe/sp_state_derived.c | 2 +- src/mesa/pipe/softpipe/sp_state_fs.c | 24 ++++++++++++++++++++---- src/mesa/state_tracker/st_atom_fs.c | 16 +++++++++++----- src/mesa/state_tracker/st_atom_vs.c | 16 +++++++++++----- src/mesa/state_tracker/st_cache.c | 18 ++++++++++++++++++ src/mesa/state_tracker/st_cache.h | 4 ++++ src/mesa/state_tracker/st_cb_clear.c | 12 ++++++++---- src/mesa/state_tracker/st_cb_drawpixels.c | 12 ++++++++---- src/mesa/state_tracker/st_cb_rasterpos.c | 6 +++--- src/mesa/state_tracker/st_context.h | 4 ++-- src/mesa/state_tracker/st_draw.c | 6 +++--- src/mesa/state_tracker/st_program.h | 6 +++--- 27 files changed, 176 insertions(+), 85 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/pipe/cso_cache/cso_cache.c b/src/mesa/pipe/cso_cache/cso_cache.c index 4aaadf00e6..be653d9494 100644 --- a/src/mesa/pipe/cso_cache/cso_cache.c +++ b/src/mesa/pipe/cso_cache/cso_cache.c @@ -80,6 +80,8 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_ hash = sc->depth_stencil_hash; case CSO_RASTERIZER: hash = sc->rasterizer_hash; + case CSO_SHADER: + hash = sc->shader_hash; } return hash; @@ -96,6 +98,8 @@ static int _cso_size_for_type(enum cso_cache_type type) return sizeof(struct pipe_depth_stencil_state); case CSO_RASTERIZER: return sizeof(struct pipe_rasterizer_state); + case CSO_SHADER: + return sizeof(struct pipe_shader_state); } return 0; } @@ -144,10 +148,11 @@ struct cso_cache *cso_cache_create(void) { struct cso_cache *sc = malloc(sizeof(struct cso_cache)); - sc->blend_hash = cso_hash_create(); - sc->sampler_hash = cso_hash_create(); + sc->blend_hash = cso_hash_create(); + sc->sampler_hash = cso_hash_create(); sc->depth_stencil_hash = cso_hash_create(); - sc->rasterizer_hash = cso_hash_create(); + sc->rasterizer_hash = cso_hash_create(); + sc->shader_hash = cso_hash_create(); return sc; } @@ -159,6 +164,6 @@ void cso_cache_delete(struct cso_cache *sc) cso_hash_delete(sc->sampler_hash); cso_hash_delete(sc->depth_stencil_hash); cso_hash_delete(sc->rasterizer_hash); + cso_hash_delete(sc->shader_hash); free(sc); } - diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h index 23be9cd713..d9793ca855 100644 --- a/src/mesa/pipe/cso_cache/cso_cache.h +++ b/src/mesa/pipe/cso_cache/cso_cache.h @@ -44,13 +44,15 @@ struct cso_cache { struct cso_hash *sampler_hash; struct cso_hash *depth_stencil_hash; struct cso_hash *rasterizer_hash; + struct cso_hash *shader_hash; }; enum cso_cache_type { CSO_BLEND, CSO_SAMPLER, CSO_DEPTH_STENCIL, - CSO_RASTERIZER + CSO_RASTERIZER, + CSO_SHADER }; unsigned cso_construct_key(void *item, int item_size); diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index b05ceb88ad..9556a17e4d 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -70,14 +70,14 @@ struct failover_context { const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; + const struct pipe_shader_state *fragment_shader; + const struct pipe_shader_state *vertex_shader; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_framebuffer_state framebuffer; - struct pipe_shader_state fragment_shader; - struct pipe_shader_state vertex_shader; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index 8e2b649590..04ebd33d0d 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -125,28 +125,27 @@ failover_set_framebuffer_state(struct pipe_context *pipe, } static void -failover_set_fs_state(struct pipe_context *pipe, - const struct pipe_shader_state *fs) +failover_bind_fs_state(struct pipe_context *pipe, + const struct pipe_shader_state *fs) { struct failover_context *failover = failover_context(pipe); - failover->fragment_shader = *fs; + failover->fragment_shader = fs; failover->dirty |= FO_NEW_FRAGMENT_SHADER; - failover->hw->set_fs_state( failover->hw, fs ); + failover->hw->bind_fs_state( failover->hw, fs ); } static void -failover_set_vs_state(struct pipe_context *pipe, +failover_bind_vs_state(struct pipe_context *pipe, const struct pipe_shader_state *vs) { struct failover_context *failover = failover_context(pipe); - failover->vertex_shader = *vs; + failover->vertex_shader = vs; failover->dirty |= FO_NEW_VERTEX_SHADER; - failover->hw->set_vs_state( failover->hw, vs ); + failover->hw->bind_vs_state( failover->hw, vs ); } - static void failover_set_polygon_stipple( struct pipe_context *pipe, const struct pipe_poly_stipple *stipple ) @@ -258,14 +257,14 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.bind_sampler_state = failover_bind_sampler_state; failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state; failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state; + failover->pipe.bind_fs_state = failover_bind_fs_state; + failover->pipe.bind_vs_state = failover_bind_vs_state; failover->pipe.set_alpha_test_state = failover_set_alpha_test_state; failover->pipe.set_blend_color = failover_set_blend_color; failover->pipe.set_clip_state = failover_set_clip_state; failover->pipe.set_clear_color_state = failover_set_clear_color_state; failover->pipe.set_framebuffer_state = failover_set_framebuffer_state; - failover->pipe.set_fs_state = failover_set_fs_state; - failover->pipe.set_vs_state = failover_set_vs_state; failover->pipe.set_polygon_stipple = failover_set_polygon_stipple; failover->pipe.set_scissor_state = failover_set_scissor_state; failover->pipe.set_texture_state = failover_set_texture_state; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index 1c9573a7b0..9d304074d0 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -77,10 +77,10 @@ failover_state_emit( struct failover_context *failover ) failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer ); if (failover->dirty & FO_NEW_FRAGMENT_SHADER) - failover->sw->set_fs_state( failover->sw, &failover->fragment_shader ); + failover->sw->bind_fs_state( failover->sw, failover->fragment_shader ); if (failover->dirty & FO_NEW_VERTEX_SHADER) - failover->sw->set_vs_state( failover->sw, &failover->vertex_shader ); + failover->sw->bind_vs_state( failover->sw, failover->vertex_shader ); if (failover->dirty & FO_NEW_STIPPLE) failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple ); diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index 3fab821fde..9052c92d72 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -127,6 +127,7 @@ struct i915_context const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; + const struct pipe_shader_state *fs; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -134,7 +135,6 @@ struct i915_context struct pipe_clip_state clip; struct pipe_constant_buffer constants[PIPE_SHADER_TYPES]; struct pipe_framebuffer_state framebuffer; - struct pipe_shader_state fs; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; diff --git a/src/mesa/pipe/i915simple/i915_fpc.h b/src/mesa/pipe/i915simple/i915_fpc.h index 59fcbf40d9..84e4c5a6f3 100644 --- a/src/mesa/pipe/i915simple/i915_fpc.h +++ b/src/mesa/pipe/i915simple/i915_fpc.h @@ -44,7 +44,7 @@ * Program translation state */ struct i915_fp_compile { - struct pipe_shader_state *shader; + const struct pipe_shader_state *shader; struct vertex_info *vertex_info; diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c index c2ad80c5d0..32c5600496 100644 --- a/src/mesa/pipe/i915simple/i915_fpc_translate.c +++ b/src/mesa/pipe/i915simple/i915_fpc_translate.c @@ -872,11 +872,11 @@ i915_translate_instructions(struct i915_fp_compile *p, static struct i915_fp_compile * i915_init_compile(struct i915_context *i915, - struct pipe_shader_state *fs) + const struct pipe_shader_state *fs) { struct i915_fp_compile *p = CALLOC_STRUCT(i915_fp_compile); - p->shader = &i915->fs; + p->shader = i915->fs; p->vertex_info = &i915->current.vertex_info; @@ -1032,8 +1032,8 @@ i915_fixup_depth_write(struct i915_fp_compile *p) void i915_translate_fragment_program( struct i915_context *i915 ) { - struct i915_fp_compile *p = i915_init_compile(i915, &i915->fs); - const struct tgsi_token *tokens = i915->fs.tokens; + struct i915_fp_compile *p = i915_init_compile(i915, i915->fs); + const struct tgsi_token *tokens = i915->fs->tokens; i915_find_wpos_space(p); diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 1dfa10ab28..fe835643e0 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -161,19 +161,29 @@ static void i915_set_polygon_stipple( struct pipe_context *pipe, } +static const struct pipe_shader_state * +i915_create_shader_state( struct pipe_context *pipe, + const struct pipe_shader_state *templ ) +{ + + struct pipe_shader_state *shader = malloc(sizeof(struct pipe_shader_state)); + memcpy(shader, templ, sizeof(struct pipe_shader_state)); + + return shader; +} -static void i915_set_fs_state( struct pipe_context *pipe, +static void i915_bind_fs_state( struct pipe_context *pipe, const struct pipe_shader_state *fs ) { struct i915_context *i915 = i915_context(pipe); - memcpy(&i915->fs, fs, sizeof(*fs)); + i915->fs = fs; i915->dirty |= I915_NEW_FS; } -static void i915_set_vs_state( struct pipe_context *pipe, +static void i915_bind_vs_state( struct pipe_context *pipe, const struct pipe_shader_state *vs ) { struct i915_context *i915 = i915_context(pipe); @@ -182,6 +192,11 @@ static void i915_set_vs_state( struct pipe_context *pipe, draw_set_vertex_shader(i915->draw, vs); } +static void i915_delete_shader_state( struct pipe_context *pipe, + const struct pipe_shader_state *shader ) +{ + free((struct pipe_shader_state*)shader); +} static void i915_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, @@ -358,6 +373,10 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.create_rasterizer_state = i915_create_rasterizer_state; i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state; i915->pipe.delete_rasterizer_state = i915_delete_rasterizer_state; + i915->pipe.create_shader_state = i915_create_shader_state; + i915->pipe.bind_fs_state = i915_bind_fs_state; + i915->pipe.bind_vs_state = i915_bind_vs_state; + i915->pipe.delete_shader_state = i915_delete_shader_state; i915->pipe.set_alpha_test_state = i915_set_alpha_test_state; i915->pipe.set_blend_color = i915_set_blend_color; @@ -365,8 +384,6 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.set_clear_color_state = i915_set_clear_color_state; i915->pipe.set_constant_buffer = i915_set_constant_buffer; i915->pipe.set_framebuffer_state = i915_set_framebuffer_state; - i915->pipe.set_fs_state = i915_set_fs_state; - i915->pipe.set_vs_state = i915_set_vs_state; i915->pipe.set_polygon_stipple = i915_set_polygon_stipple; i915->pipe.set_scissor_state = i915_set_scissor_state; i915->pipe.set_texture_state = i915_set_texture_state; diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 504bc10a9e..8d404c55ab 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -42,7 +42,7 @@ */ static void calculate_vertex_layout( struct i915_context *i915 ) { - const uint inputsRead = i915->fs.inputs_read; + const uint inputsRead = i915->fs->inputs_read; const interp_mode colorInterp = i915->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &i915->current.vertex_info; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index dda758fe6a..c405051bce 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -117,6 +117,16 @@ struct pipe_context { void (*delete_depth_stencil_state)(struct pipe_context *, const struct pipe_depth_stencil_state *); + const struct pipe_shader_state * (*create_shader_state)( + struct pipe_context *, + const struct pipe_shader_state *); + void (*bind_fs_state)(struct pipe_context *, + const struct pipe_shader_state *); + void (*bind_vs_state)(struct pipe_context *, + const struct pipe_shader_state *); + void (*delete_shader_state)(struct pipe_context *, + const struct pipe_shader_state *); + void (*set_alpha_test_state)( struct pipe_context *, const struct pipe_alpha_test_state * ); @@ -139,12 +149,6 @@ struct pipe_context { void (*set_framebuffer_state)( struct pipe_context *, const struct pipe_framebuffer_state * ); - void (*set_fs_state)( struct pipe_context *, - const struct pipe_shader_state * ); - - void (*set_vs_state)( struct pipe_context *, - const struct pipe_shader_state * ); - void (*set_polygon_stipple)( struct pipe_context *, const struct pipe_poly_stipple * ); diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index cf5fc2227e..25cb9d8745 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -251,17 +251,21 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, /* state setters */ softpipe->pipe.create_blend_state = softpipe_create_blend_state; - softpipe->pipe.bind_blend_state = softpipe_bind_blend_state; + softpipe->pipe.bind_blend_state = softpipe_bind_blend_state; softpipe->pipe.delete_blend_state = softpipe_delete_blend_state; softpipe->pipe.create_sampler_state = softpipe_create_sampler_state; - softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state; + softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state; softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state; softpipe->pipe.create_depth_stencil_state = softpipe_create_depth_stencil_state; - softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state; + softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state; softpipe->pipe.delete_depth_stencil_state = softpipe_delete_depth_stencil_state; softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state; - softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state; + softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state; softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state; + softpipe->pipe.create_shader_state = softpipe_create_shader_state; + softpipe->pipe.bind_fs_state = softpipe_bind_fs_state; + softpipe->pipe.bind_vs_state = softpipe_bind_vs_state; + softpipe->pipe.delete_shader_state = softpipe_delete_shader_state; softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; @@ -270,8 +274,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer; softpipe->pipe.set_feedback_state = softpipe_set_feedback_state; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; - softpipe->pipe.set_fs_state = softpipe_set_fs_state; - softpipe->pipe.set_vs_state = softpipe_set_vs_state; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; softpipe->pipe.set_scissor_state = softpipe_set_scissor_state; softpipe->pipe.set_texture_state = softpipe_set_texture_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index f1bb3d39a6..5c17c47b12 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -74,6 +74,8 @@ struct softpipe_context { const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; + const struct pipe_shader_state *fs; + const struct pipe_shader_state *vs; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -82,8 +84,6 @@ struct softpipe_context { struct pipe_constant_buffer constants[2]; struct pipe_feedback_state feedback; struct pipe_framebuffer_state framebuffer; - struct pipe_shader_state fs; - struct pipe_shader_state vs; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index 46ad08aaa1..25bc170d8c 100755 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -108,7 +108,7 @@ shade_quad( /* init machine state */ tgsi_exec_machine_init( &machine, - softpipe->fs.tokens, + softpipe->fs->tokens, PIPE_MAX_SAMPLERS, qss->samplers ); diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 62bd26c4df..04cc743bd0 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -88,11 +88,15 @@ void softpipe_set_constant_buffer(struct pipe_context *, void softpipe_set_feedback_state( struct pipe_context *, const struct pipe_feedback_state * ); -void softpipe_set_fs_state( struct pipe_context *, - const struct pipe_shader_state * ); - -void softpipe_set_vs_state( struct pipe_context *, - const struct pipe_shader_state * ); +const struct pipe_shader_state * +softpipe_create_shader_state( struct pipe_context *, + const struct pipe_shader_state * ); +void softpipe_bind_fs_state( struct pipe_context *, + const struct pipe_shader_state * ); +void softpipe_bind_vs_state( struct pipe_context *, + const struct pipe_shader_state * ); +void softpipe_delete_shader_state( struct pipe_context *, + const struct pipe_shader_state * ); void softpipe_set_polygon_stipple( struct pipe_context *, const struct pipe_poly_stipple * ); diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 8c6bacf65c..9611a2ac99 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -43,7 +43,7 @@ */ static void calculate_vertex_layout( struct softpipe_context *softpipe ) { - const uint inputsRead = softpipe->fs.inputs_read; + const uint inputsRead = softpipe->fs->inputs_read; const interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &softpipe->vertex_info; diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index 5ab246896b..fbbde2f520 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -33,23 +33,33 @@ #include "pipe/draw/draw_context.h" -void softpipe_set_fs_state( struct pipe_context *pipe, +const struct pipe_shader_state * +softpipe_create_shader_state( struct pipe_context *pipe, + const struct pipe_shader_state *templ ) +{ + struct pipe_shader_state *shader = malloc(sizeof(struct pipe_shader_state)); + memcpy(shader, templ, sizeof(struct pipe_shader_state)); + + return shader; +} + +void softpipe_bind_fs_state( struct pipe_context *pipe, const struct pipe_shader_state *fs ) { struct softpipe_context *softpipe = softpipe_context(pipe); - memcpy(&softpipe->fs, fs, sizeof(*fs)); + softpipe->fs = fs; softpipe->dirty |= SP_NEW_FS; } -void softpipe_set_vs_state( struct pipe_context *pipe, +void softpipe_bind_vs_state( struct pipe_context *pipe, const struct pipe_shader_state *vs ) { struct softpipe_context *softpipe = softpipe_context(pipe); - memcpy(&softpipe->vs, vs, sizeof(*vs)); + softpipe->vs = vs; softpipe->dirty |= SP_NEW_VS; @@ -57,6 +67,12 @@ void softpipe_set_vs_state( struct pipe_context *pipe, } +void softpipe_delete_shader_state( struct pipe_context *pipe, + const struct pipe_shader_state *shader ) +{ + free((struct pipe_shader_state*)shader); +} + void softpipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *buf) diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index d066547616..dc3e5258d8 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -38,6 +38,7 @@ #include "pipe/tgsi/exec/tgsi_dump.h" #include "st_context.h" +#include "st_cache.h" #include "st_atom.h" #include "st_program.h" @@ -46,16 +47,21 @@ static void compile_fs( struct st_context *st ) { struct st_fragment_program *fp = st->fp; + struct pipe_shader_state fs; + struct pipe_shader_state *cached; /* XXX: fix static allocation of tokens: */ tgsi_mesa_compile_fp_program( &fp->Base, fp->tokens, ST_FP_MAX_TOKENS ); - fp->fs.inputs_read + memset(&fs, 0, sizeof(fs)); + fs.inputs_read = tgsi_mesa_translate_fragment_input_mask(fp->Base.Base.InputsRead); - fp->fs.outputs_written + fs.outputs_written = tgsi_mesa_translate_fragment_output_mask(fp->Base.Base.OutputsWritten); - fp->fs.tokens = &fp->tokens[0]; + fs.tokens = &fp->tokens[0]; + cached = st_cached_shader_state(st, &fs); + fp->fsx = cached; if (TGSI_DEBUG) tgsi_dump( fp->tokens, TGSI_DUMP_VERBOSE ); @@ -92,8 +98,8 @@ static void update_fs( struct st_context *st ) if (fp->dirty) compile_fs( st ); - st->state.fs = fp->fs; - st->pipe->set_fs_state(st->pipe, &st->state.fs); + st->state.fs = fp->fsx; + st->pipe->bind_fs_state(st->pipe, st->state.fs); } } diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index 289a3e4f46..18be71367a 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -41,6 +41,7 @@ #include "pipe/tgsi/exec/tgsi_core.h" #include "st_context.h" +#include "st_cache.h" #include "st_atom.h" #include "st_program.h" @@ -55,16 +56,21 @@ static void compile_vs( struct st_context *st ) { struct st_vertex_program *vp = st->vp; - + struct pipe_shader_state vs; + struct pipe_shader_state *cached; /* XXX: fix static allocation of tokens: */ tgsi_mesa_compile_vp_program( &vp->Base, vp->tokens, ST_FP_MAX_TOKENS ); - vp->vs.inputs_read + memset(&vs, 0, sizeof(vs)); + vs.inputs_read = tgsi_mesa_translate_vertex_input_mask(vp->Base.Base.InputsRead); - vp->vs.outputs_written + vs.outputs_written = tgsi_mesa_translate_vertex_output_mask(vp->Base.Base.OutputsWritten); - vp->vs.tokens = &vp->tokens[0]; + vs.tokens = &vp->tokens[0]; + + cached = st_cached_shader_state(st, &vs); + vp->vs = cached; if (TGSI_DEBUG) tgsi_dump( vp->tokens, 0 ); @@ -110,7 +116,7 @@ static void update_vs( struct st_context *st ) #endif st->state.vs = st->vp->vs; - st->pipe->set_vs_state(st->pipe, &st->state.vs); + st->pipe->bind_vs_state(st->pipe, st->state.vs); } } diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index e9c79634bd..7b851e3901 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -111,3 +111,21 @@ struct pipe_rasterizer_state * st_cached_rasterizer_state( } return (struct pipe_rasterizer_state*)(cso_hash_iter_data(iter)); } + +struct pipe_shader_state * st_cached_shader_state( + struct st_context *st, + const struct pipe_shader_state *templ) +{ + unsigned hash_key = cso_construct_key((void*)templ, + sizeof(struct pipe_shader_state)); + struct cso_hash_iter iter = cso_find_state_template(st->cache, + hash_key, CSO_SHADER, + (void*)templ); + if (cso_hash_iter_is_null(iter)) { + const struct pipe_shader_state *created_state = + st->pipe->create_shader_state(st->pipe, templ); + iter = cso_insert_state(st->cache, hash_key, CSO_SHADER, + (void*)created_state); + } + return (struct pipe_shader_state*)(cso_hash_iter_data(iter)); +} diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index a06af31123..6a897a9993 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -53,4 +53,8 @@ struct pipe_rasterizer_state *st_cached_rasterizer_state( struct st_context *st, const struct pipe_rasterizer_state *raster); +struct pipe_shader_state *st_cached_shader_state( + struct st_context *st, + const struct pipe_shader_state *templ); + #endif diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 584bc1cc2a..2ea498663b 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -347,6 +347,7 @@ clear_with_quad(GLcontext *ctx, { static struct st_fragment_program *stfp = NULL; struct pipe_shader_state fs; + const struct pipe_shader_state *cached; if (!stfp) { stfp = make_color_shader(st); } @@ -354,13 +355,15 @@ clear_with_quad(GLcontext *ctx, fs.inputs_read = tgsi_mesa_translate_fragment_input_mask(stfp->Base.Base.InputsRead); fs.outputs_written = tgsi_mesa_translate_fragment_output_mask(stfp->Base.Base.OutputsWritten); fs.tokens = &stfp->tokens[0]; - pipe->set_fs_state(pipe, &fs); + cached = st_cached_shader_state(st, &fs); + pipe->bind_fs_state(pipe, cached); } /* vertex shader state: color/position pass-through */ { static struct st_vertex_program *stvp = NULL; struct pipe_shader_state vs; + const struct pipe_shader_state *cached; if (!stvp) { stvp = make_vertex_shader(st); } @@ -368,7 +371,8 @@ clear_with_quad(GLcontext *ctx, vs.inputs_read = stvp->Base.Base.InputsRead; vs.outputs_written = stvp->Base.Base.OutputsWritten; vs.tokens = &stvp->tokens[0]; - pipe->set_vs_state(pipe, &vs); + cached = st_cached_shader_state(st, &vs); + pipe->bind_vs_state(pipe, cached); } /* viewport state: viewport matching window dims */ @@ -394,8 +398,8 @@ clear_with_quad(GLcontext *ctx, pipe->set_alpha_test_state(pipe, &st->state.alpha_test); pipe->bind_blend_state(pipe, st->state.blend); pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil); - pipe->set_fs_state(pipe, &st->state.fs); - pipe->set_vs_state(pipe, &st->state.vs); + pipe->bind_fs_state(pipe, st->state.fs); + pipe->bind_vs_state(pipe, st->state.vs); pipe->bind_rasterizer_state(pipe, st->state.rasterizer); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); /* OR: diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 78ede8e225..37e40636f6 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -329,19 +329,22 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, { static struct st_fragment_program *stfp = NULL; struct pipe_shader_state fs; + struct pipe_shader_state *cached; if (!stfp) { stfp = make_fragment_shader(ctx->st); } memset(&fs, 0, sizeof(fs)); fs.inputs_read = stfp->Base.Base.InputsRead; fs.tokens = &stfp->tokens[0]; - pipe->set_fs_state(pipe, &fs); + cached = st_cached_shader_state(ctx->st, &fs); + pipe->bind_fs_state(pipe, cached); } /* vertex shader state: position + texcoord pass-through */ { static struct st_vertex_program *stvp = NULL; struct pipe_shader_state vs; + struct pipe_shader_state *cached; if (!stvp) { stvp = make_vertex_shader(ctx->st); } @@ -349,7 +352,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, vs.inputs_read = stvp->Base.Base.InputsRead; vs.outputs_written = stvp->Base.Base.OutputsWritten; vs.tokens = &stvp->tokens[0]; - pipe->set_vs_state(pipe, &vs); + cached = st_cached_shader_state(ctx->st, &vs); + pipe->bind_vs_state(pipe, cached); } /* texture sampling state: */ @@ -403,8 +407,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* restore GL state */ pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer); - pipe->set_fs_state(pipe, &ctx->st->state.fs); - pipe->set_vs_state(pipe, &ctx->st->state.vs); + pipe->bind_fs_state(pipe, ctx->st->state.fs); + pipe->bind_vs_state(pipe, ctx->st->state.vs); pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]); pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 7bedf3f89f..98efe1a10b 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -53,7 +53,7 @@ static void setup_vertex_attribs(GLcontext *ctx) { struct pipe_context *pipe = ctx->st->pipe; - const uint inputAttrs = ctx->st->state.vs.inputs_read; + const uint inputAttrs = ctx->st->state.vs->inputs_read; uint attr; /* all attributes come from the default attribute buffer */ @@ -84,7 +84,7 @@ static void setup_feedback(GLcontext *ctx) { struct pipe_context *pipe = ctx->st->pipe; - const uint outputAttrs = ctx->st->state.vs.outputs_written; + const uint outputAttrs = ctx->st->state.vs->outputs_written; struct pipe_feedback_state feedback; uint i; @@ -307,7 +307,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) /* extract values and update rasterpos state */ { - const uint outputAttrs = ctx->st->state.vs.outputs_written; + const uint outputAttrs = ctx->st->state.vs->outputs_written; const float *pos, *color0, *color1, *tex0; float *buf = buf_map; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 516d319a6e..a8ae5d9c56 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -78,6 +78,8 @@ struct st_context const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; + const struct pipe_shader_state *fs; + const struct pipe_shader_state *vs; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -89,8 +91,6 @@ struct st_context struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_shader_state fs; - struct pipe_shader_state vs; struct pipe_viewport_state viewport; } state; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index f68e449f07..ac63a38720 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -193,7 +193,7 @@ st_draw_vbo(GLcontext *ctx, update_default_attribs_buffer(ctx); /* this must be after state validation */ - attrsNeeded = ctx->st->state.vs.inputs_read; + attrsNeeded = ctx->st->state.vs->inputs_read; /* tell pipe about the vertex array element/attributes */ for (attr = 0; attr < 16; attr++) { @@ -395,14 +395,14 @@ st_feedback_draw_vbo(GLcontext *ctx, 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_vertex_shader(draw, &st->state.vs); + draw_set_vertex_shader(draw, st->state.vs); /* XXX need to set vertex info too */ update_default_attribs_buffer(ctx); /* this must be after state validation */ - attrsNeeded = ctx->st->state.vs.inputs_read; + attrsNeeded = ctx->st->state.vs->inputs_read; /* tell draw module about the vertex array element/attributes */ for (attr = 0; attr < 16; attr++) { diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 7a91983ce9..a2f114b1ba 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -53,8 +53,8 @@ struct st_fragment_program struct tgsi_token tokens[ST_FP_MAX_TOKENS]; GLboolean dirty; - - struct pipe_shader_state fs; + + const struct pipe_shader_state *fsx; GLuint param_state; }; @@ -75,7 +75,7 @@ struct st_vertex_program struct x86_function sse2_program; #endif - struct pipe_shader_state vs; + const struct pipe_shader_state *vs; GLuint param_state; }; -- cgit v1.2.3 From 37cf13ed9a429c755f121daa1776b1b30a985ab3 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 19 Sep 2007 18:53:36 -0600 Subject: Checkpoint: replacement of TGSI_ATTRIB_x tokens with input/output semantics. TGSI_ATTRIB_x tokens still present and used in a few places. Expanded set of TGSI_SEMANTIC_x tokens for describing the meaning of inputs/outputs. These tokens are in a crude state ATM. Lots of #if 0 / disabled code to be removed yet, etc... Softpipe and i915 drivers should be in working condition but not heavily tested. --- src/mesa/pipe/draw/draw_vertex_shader.c | 4 + src/mesa/pipe/i915simple/i915_context.c | 14 +++ src/mesa/pipe/i915simple/i915_fpc.h | 2 + src/mesa/pipe/i915simple/i915_fpc_translate.c | 81 +++++++++++++++-- src/mesa/pipe/i915simple/i915_state_derived.c | 60 ++++++++++++- src/mesa/pipe/p_context.h | 3 +- src/mesa/pipe/p_defines.h | 7 ++ src/mesa/pipe/p_state.h | 11 ++- src/mesa/pipe/softpipe/sp_context.c | 10 +++ src/mesa/pipe/softpipe/sp_state_derived.c | 90 +++++++++---------- src/mesa/pipe/tgsi/exec/tgsi_build.c | 2 +- src/mesa/pipe/tgsi/exec/tgsi_dump.c | 18 +++- src/mesa/pipe/tgsi/exec/tgsi_token.h | 31 +++++-- src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c | 118 ++++++++++++++++++++----- src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h | 2 + src/mesa/state_tracker/st_atom_fs.c | 121 ++++++++++++++++++++------ src/mesa/state_tracker/st_atom_vs.c | 114 ++++++++++++++++-------- src/mesa/state_tracker/st_cb_clear.c | 45 ++-------- src/mesa/state_tracker/st_cb_drawpixels.c | 33 +------ src/mesa/state_tracker/st_cb_rasterpos.c | 13 ++- src/mesa/state_tracker/st_draw.c | 8 +- src/mesa/state_tracker/st_program.h | 27 ++++-- 22 files changed, 580 insertions(+), 234 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index cb6c605b8d..2d424632e7 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -94,7 +94,11 @@ run_vertex_program(struct draw_context *draw, const float *trans = draw->viewport.translate; assert(count <= 4); +#if 0 assert(draw->vertex_shader.outputs_written & (1 << TGSI_ATTRIB_POS)); +#else + assert(draw->vertex_shader.output_semantics[0] == TGSI_SEMANTIC_POSITION); +#endif #ifdef DEBUG memset( &machine, 0, sizeof( machine ) ); diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index 36372898ce..715e1ef656 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -138,6 +138,18 @@ i915_max_texture_size(struct pipe_context *pipe, unsigned textureType, } +static int +i915_get_param(struct pipe_context *pipe, uint param) +{ + switch (param) { + case PIPE_PARAM_FS_NEEDS_POS: + return 0; + default: + return 0; + } +} + + static void i915_destroy( struct pipe_context *pipe ) { struct i915_context *i915 = i915_context( pipe ); @@ -272,6 +284,8 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys, i915->pipe.destroy = i915_destroy; i915->pipe.supported_formats = i915_supported_formats; i915->pipe.max_texture_size = i915_max_texture_size; + i915->pipe.get_param = i915_get_param; + i915->pipe.clear = i915_clear; i915->pipe.begin_query = i915_begin_query; diff --git a/src/mesa/pipe/i915simple/i915_fpc.h b/src/mesa/pipe/i915simple/i915_fpc.h index 84e4c5a6f3..5c4f2f90e9 100644 --- a/src/mesa/pipe/i915simple/i915_fpc.h +++ b/src/mesa/pipe/i915simple/i915_fpc.h @@ -51,6 +51,8 @@ struct i915_fp_compile { uint declarations[I915_PROGRAM_SIZE]; uint program[I915_PROGRAM_SIZE]; + uint input_semantic[PIPE_MAX_SHADER_INPUTS]; + /** points into the i915->current.constants array: */ float (*constants)[4]; uint num_constants; diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c index 32c5600496..df8859bec8 100644 --- a/src/mesa/pipe/i915simple/i915_fpc_translate.c +++ b/src/mesa/pipe/i915simple/i915_fpc_translate.c @@ -128,7 +128,7 @@ src_vector(struct i915_fp_compile *p, const struct tgsi_full_src_register *source) { uint index = source->SrcRegister.Index; - uint src; + uint src, sem; switch (source->SrcRegister.File) { case TGSI_FILE_TEMPORARY: @@ -151,6 +151,46 @@ src_vector(struct i915_fp_compile *p, /* use vertex format info to map a slot number to a VF attrib */ assert(index < p->vertex_info->num_attribs); + + sem = p->input_semantic[index]; + +#if 1 + switch (sem) { + case TGSI_SEMANTIC_POSITION: + printf("SKIP SEM POS\n"); + /* + assert(p->wpos_tex != -1); + src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL); + */ + break; + case TGSI_SEMANTIC_COLOR0: + src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL); + break; + case TGSI_SEMANTIC_COLOR1: + src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ); + src = swizzle(src, X, Y, Z, ONE); + break; + case TGSI_SEMANTIC_FOG: + src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W); + src = swizzle(src, W, W, W, W); + break; + case TGSI_SEMANTIC_TEX0: + case TGSI_SEMANTIC_TEX1: + case TGSI_SEMANTIC_TEX2: + case TGSI_SEMANTIC_TEX3: + case TGSI_SEMANTIC_TEX4: + case TGSI_SEMANTIC_TEX5: + case TGSI_SEMANTIC_TEX6: + case TGSI_SEMANTIC_TEX7: + src = i915_emit_decl(p, REG_TYPE_T, + T_TEX0 + (sem - TGSI_SEMANTIC_TEX0), + D0_CHANNEL_ALL); + break; + default: + i915_program_error(p, "Bad source->Index"); + return 0; + } +#else index = p->vertex_info->slot_to_attrib[index]; switch (index) { @@ -185,6 +225,7 @@ src_vector(struct i915_fp_compile *p, i915_program_error(p, "Bad source->Index"); return 0; } +#endif break; case TGSI_FILE_CONSTANT: @@ -220,9 +261,12 @@ src_vector(struct i915_fp_compile *p, } /* no abs() or post-abs negation */ +#if 0 + /* XXX assertions disabled to allow arbfplight.c to run */ + /* XXX enable these assertions, or fix things */ assert(!source->SrcRegisterExtMod.Absolute); assert(!source->SrcRegisterExtMod.Negate); - +#endif return src; } @@ -848,7 +892,15 @@ i915_translate_instructions(struct i915_fp_compile *p, switch( parse.FullToken.Token.Type ) { case TGSI_TOKEN_TYPE_DECLARATION: - /* XXX no-op? */ + if (parse.FullToken.FullDeclaration.Declaration.File + == TGSI_FILE_INPUT) { + /* save input register info for use in src_vector() */ + uint ind, sem; + ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First; + sem = parse.FullToken.FullDeclaration.Semantic.SemanticName; + /*printf("FS Input DECL [%u] sem %u\n", ind, sem);*/ + p->input_semantic[ind] = sem; + } break; case TGSI_TOKEN_TYPE_IMMEDIATE: @@ -989,6 +1041,7 @@ i915_fini_compile(struct i915_context *i915, struct i915_fp_compile *p) static void i915_find_wpos_space(struct i915_fp_compile *p) { +#if 0 const uint inputs = p->shader->inputs_read | (1 << TGSI_ATTRIB_POS); /*XXX hack*/ uint i; @@ -1005,6 +1058,14 @@ i915_find_wpos_space(struct i915_fp_compile *p) i915_program_error(p, "No free texcoord for wpos value"); } +#else + if (p->shader->input_semantics[0] == TGSI_SEMANTIC_POSITION) { + /* frag shader using the fragment position input */ +#if 0 + assert(0); +#endif + } +#endif } @@ -1018,13 +1079,17 @@ i915_find_wpos_space(struct i915_fp_compile *p) static void i915_fixup_depth_write(struct i915_fp_compile *p) { - if (p->shader->outputs_written & (1 << TGSI_ATTRIB_POS)) { - uint depth = UREG(REG_TYPE_OD, 0); + /* XXX assuming depth is always in output[0] */ + if (p->shader->output_semantics[0] == TGSI_SEMANTIC_DEPTH) { + const uint depth = UREG(REG_TYPE_OD, 0); i915_emit_arith(p, - A0_MOV, - depth, A0_DEST_CHANNEL_W, 0, - swizzle(depth, X, Y, Z, Z), 0, 0); + A0_MOV, /* opcode */ + depth, /* dest reg */ + A0_DEST_CHANNEL_W, /* write mask */ + 0, /* saturate? */ + swizzle(depth, X, Y, Z, Z), /* src0 */ + 0, 0 /* src1, src2 */); } } diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 8d404c55ab..dece697497 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -33,6 +33,7 @@ #include "i915_state.h" #include "i915_reg.h" #include "i915_fpc.h" +#include "pipe/tgsi/exec/tgsi_token.h" /** @@ -42,19 +43,71 @@ */ static void calculate_vertex_layout( struct i915_context *i915 ) { - const uint inputsRead = i915->fs->inputs_read; + const struct pipe_shader_state *fs = i915->fs; const interp_mode colorInterp = i915->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &i915->current.vertex_info; uint front0 = 0, back0 = 0, front1 = 0, back1 = 0; boolean needW = 0; + uint i; + boolean texCoords[8]; + memset(texCoords, 0, sizeof(texCoords)); memset(vinfo, 0, sizeof(*vinfo)); /* pos */ draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_3F, INTERP_LINEAR); /* Note: we'll set the S4_VFMT_XYZ[W] bits below */ + for (i = 0; i < fs->num_inputs; i++) { + switch (fs->input_semantics[i]) { + case TGSI_SEMANTIC_POSITION: + break; + case TGSI_SEMANTIC_COLOR0: + front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, + FORMAT_4UB, colorInterp); + vinfo->hwfmt[0] |= S4_VFMT_COLOR; + break; + case TGSI_SEMANTIC_COLOR1: + assert(0); /* untested */ + front1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1, + FORMAT_4UB, colorInterp); + vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG; + break; + case TGSI_SEMANTIC_TEX0: + case TGSI_SEMANTIC_TEX1: + case TGSI_SEMANTIC_TEX2: + case TGSI_SEMANTIC_TEX3: + case TGSI_SEMANTIC_TEX4: + case TGSI_SEMANTIC_TEX5: + case TGSI_SEMANTIC_TEX6: + case TGSI_SEMANTIC_TEX7: + { + const uint unit = fs->input_semantics[i] - TGSI_SEMANTIC_TEX0; + uint hwtc; + texCoords[unit] = TRUE; + draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_TEX0 + i, + FORMAT_4F, INTERP_PERSPECTIVE); + hwtc = TEXCOORDFMT_4D; + needW = TRUE; + vinfo->hwfmt[1] |= hwtc << (unit * 4); + } + break; + default: + assert(0); + } + + } + + /* finish up texcoord fields */ + for (i = 0; i < 8; i++) { + if (!texCoords[i]) { + const uint hwtc = TEXCOORDFMT_NOT_PRESENT; + vinfo->hwfmt[1] |= hwtc << (i* 4); + } + } + +#if 0 /* color0 */ if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, @@ -88,6 +141,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) vinfo->hwfmt[1] |= hwtc << ((i - TGSI_ATTRIB_TEX0) * 4); } } +#endif /* go back and fill in the vertex position info now that we have needW */ if (needW) { @@ -104,11 +158,11 @@ static void calculate_vertex_layout( struct i915_context *i915 ) * the vertex header. */ if (i915->rasterizer->light_twoside) { - if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { + if (front0) { back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, FORMAT_OMIT, colorInterp); } - if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) { + if (back0) { back1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC1, FORMAT_OMIT, colorInterp); } diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 1c0ab794f0..65001dfdf9 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -57,7 +57,8 @@ struct pipe_context { const char *(*get_vendor)( struct pipe_context *pipe ); - + int (*get_param)( struct pipe_context *pipe, int param ); + /* * Drawing. diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index b3ee890576..2a8109b10c 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -307,4 +307,11 @@ #define PIPE_QUERY_PRIMITIVES_EMITTED 2 #define PIPE_QUERY_TYPES 3 + +/** + * Pipe capabilities/queries + */ +#define PIPE_PARAM_FS_NEEDS_POS 1 + + #endif diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index d2cc76a59b..6396d49b84 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -50,6 +50,8 @@ #define PIPE_MAX_COLOR_BUFS 8 #define PIPE_MAX_TEXTURE_LEVELS 16 #define PIPE_MAX_FEEDBACK_ATTRIBS 16 +#define PIPE_MAX_SHADER_INPUTS 16 +#define PIPE_MAX_SHADER_OUTPUTS 16 /* fwd decl */ @@ -140,13 +142,14 @@ struct pipe_constant_buffer { struct pipe_shader_state { - unsigned inputs_read; /**< TGSI_ATTRIB_ bits */ - unsigned outputs_written; /**< TGSI_ATTRIB_ bits */ const struct tgsi_token *tokens; void *executable; - uint num_inputs; - uint num_outputs; + /** These fields somewhat constitute the shader "signature" */ + ubyte num_inputs; + ubyte num_outputs; + ubyte input_semantics[PIPE_MAX_SHADER_INPUTS]; + ubyte output_semantics[PIPE_MAX_SHADER_OUTPUTS]; }; struct pipe_depth_stencil_state diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index a56793d683..ebd5530950 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -236,6 +236,15 @@ static const char *softpipe_get_vendor( struct pipe_context *pipe ) return "Tungsten Graphics, Inc."; } +static int softpipe_get_param(struct pipe_context *pipe, uint param) +{ + switch (param) { + case PIPE_PARAM_FS_NEEDS_POS: + return 1; + default: + return 0; + } +} struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, struct softpipe_winsys *softpipe_winsys ) @@ -248,6 +257,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, /* queries */ softpipe->pipe.supported_formats = softpipe_supported_formats; softpipe->pipe.max_texture_size = softpipe_max_texture_size; + softpipe->pipe.get_param = softpipe_get_param; /* state setters */ softpipe->pipe.create_blend_state = softpipe_create_blend_state; diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 9611a2ac99..0dd0eea0b8 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -34,6 +34,7 @@ #include "sp_state.h" #include "pipe/tgsi/exec/tgsi_attribs.h" +#include "pipe/tgsi/exec/tgsi_token.h" /** @@ -43,7 +44,7 @@ */ static void calculate_vertex_layout( struct softpipe_context *softpipe ) { - const uint inputsRead = softpipe->fs->inputs_read; + const struct pipe_shader_state *fs = softpipe->fs; const interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &softpipe->vertex_info; @@ -52,57 +53,59 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) memset(vinfo, 0, sizeof(*vinfo)); - /* Need Z if depth test is enabled or the fragment program uses the - * fragment position (XYZW). - */ - if (softpipe->depth_stencil->depth.enabled || - (inputsRead & (1 << TGSI_ATTRIB_POS))) + if (softpipe->depth_stencil->depth.enabled) softpipe->need_z = TRUE; else softpipe->need_z = FALSE; + softpipe->need_w = FALSE; - /* Need W if we do any perspective-corrected interpolation or the - * fragment program uses the fragment position. - */ - if (inputsRead & (1 << TGSI_ATTRIB_POS)) - softpipe->need_w = TRUE; - else - softpipe->need_w = FALSE; - - /* position */ + /* always emit vertex pos */ /* TODO - Figure out if we need to do perspective divide, etc. */ draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_4F, INTERP_LINEAR); - - /* color0 */ - if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { - front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, - FORMAT_4F, colorInterp); - } - - /* color1 */ - if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) { - front1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1, - FORMAT_4F, colorInterp); - } - /* fog */ - if (inputsRead & (1 << TGSI_ATTRIB_FOG)) { - draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_FOG, - FORMAT_1F, INTERP_PERSPECTIVE); - } - - /* point size */ + for (i = 0; i < fs->num_inputs; i++) { + switch (fs->input_semantics[i]) { + case TGSI_SEMANTIC_POSITION: + /* Need Z if depth test is enabled or the fragment program uses the + * fragment position (XYZW). + */ + softpipe->need_z = TRUE; + softpipe->need_w = TRUE; + break; + case TGSI_SEMANTIC_COLOR0: + front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, + FORMAT_4F, colorInterp); + break; + case TGSI_SEMANTIC_COLOR1: + front1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1, + FORMAT_4F, colorInterp); + break; + case TGSI_SEMANTIC_FOG: + draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_FOG, + FORMAT_1F, INTERP_PERSPECTIVE); + break; #if 0 - /* XXX only emit if drawing points or front/back polygon mode is point mode */ - draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POINTSIZE, - FORMAT_4F, INTERP_CONSTANT); + case TGSI_SEMANTIC_PSIZE: + /* XXX only emit if drawing points or front/back polygon mode + * is point mode + */ + draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POINTSIZE, + FORMAT_4F, INTERP_CONSTANT); + break; #endif - - /* texcoords and varying vars */ - for (i = TGSI_ATTRIB_TEX0; i < TGSI_ATTRIB_VAR7; i++) { - if (inputsRead & (1 << i)) { + /*case TGSI_SEMANTIC_TEXCOORD:*/ + case TGSI_SEMANTIC_TEX0: + draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_TEX0, + FORMAT_4F, INTERP_PERSPECTIVE); + softpipe->need_w = TRUE; + break; + case TGSI_SEMANTIC_OTHER: draw_emit_vertex_attr(vinfo, i, FORMAT_4F, INTERP_PERSPECTIVE); softpipe->need_w = TRUE; + break; + + default: + assert(0); } } @@ -113,12 +116,11 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) * the vertex header. */ if (softpipe->rasterizer->light_twoside) { - if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { + if (front0) { back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, FORMAT_OMIT, colorInterp); } - - if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) { + if (back0) { back1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC1, FORMAT_OMIT, colorInterp); } diff --git a/src/mesa/pipe/tgsi/exec/tgsi_build.c b/src/mesa/pipe/tgsi/exec/tgsi_build.c index 20e4cf17f0..1320872c64 100755 --- a/src/mesa/pipe/tgsi/exec/tgsi_build.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_build.c @@ -325,7 +325,7 @@ tgsi_build_declaration_semantic( { struct tgsi_declaration_semantic ds; - assert( semantic_name <= TGSI_SEMANTIC_COLOR ); + assert( semantic_name <= TGSI_SEMANTIC_COUNT ); assert( semantic_index <= 0xFFFF ); ds = tgsi_default_declaration_semantic(); diff --git a/src/mesa/pipe/tgsi/exec/tgsi_dump.c b/src/mesa/pipe/tgsi/exec/tgsi_dump.c index e6e99d9d75..0a47ad2a8c 100755 --- a/src/mesa/pipe/tgsi/exec/tgsi_dump.c +++ b/src/mesa/pipe/tgsi/exec/tgsi_dump.c @@ -202,13 +202,27 @@ static const char *TGSI_INTERPOLATES_SHORT[] = static const char *TGSI_SEMANTICS[] = { "SEMANTIC_DEPTH", - "SEMANTIC_COLOR" + "SEMANTIC_COLOR0", + "SEMANTIC_COLOR1", + "SEMANTIC_COLOR0B", + "SEMANTIC_COLOR1B", + "SEMANTIC_POSITION", + "SEMANTIC_FOG", + "SEMANTIC_OTHER," + "SEMANTIC_TEX0", }; static const char *TGSI_SEMANTICS_SHORT[] = { "DEPTH", - "COLOR" + "COLOR0", + "COLOR1", + "COLOR0B", + "COLOR1B", + "POSITION", + "FOG", + "OTHER", + "TEX0" }; static const char *TGSI_IMMS[] = diff --git a/src/mesa/pipe/tgsi/exec/tgsi_token.h b/src/mesa/pipe/tgsi/exec/tgsi_token.h index ca53071a60..a642ba131a 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_token.h +++ b/src/mesa/pipe/tgsi/exec/tgsi_token.h @@ -73,11 +73,11 @@ struct tgsi_declaration { unsigned Type : 4; /* TGSI_TOKEN_TYPE_DECLARATION */ unsigned Size : 8; /* UINT */ - unsigned File : 4; /* TGSI_FILE_ */ - unsigned Declare : 4; /* TGSI_DECLARE_ */ - unsigned UsageMask : 4; /* TGSI_WRITEMASK_ */ - unsigned Interpolate : 1; /* BOOL */ - unsigned Semantic : 1; /* BOOL */ + unsigned File : 4; /* one of TGSI_FILE_x */ + unsigned Declare : 4; /* one of TGSI_DECLARE_x */ + unsigned UsageMask : 4; /* bitmask of TGSI_WRITEMASK_x flags */ + unsigned Interpolate : 1; /* BOOL, any interpolation info? */ + unsigned Semantic : 1; /* BOOL, any semantic info? */ unsigned Padding : 5; unsigned Extended : 1; /* BOOL */ }; @@ -103,12 +103,27 @@ struct tgsi_declaration_interpolation unsigned Padding : 28; }; -#define TGSI_SEMANTIC_DEPTH 0 -#define TGSI_SEMANTIC_COLOR 1 +#define TGSI_SEMANTIC_DEPTH 0 +#define TGSI_SEMANTIC_COLOR0 1 +#define TGSI_SEMANTIC_COLOR1 2 +#define TGSI_SEMANTIC_COLOR0B 3 /**< back-face primary color */ +#define TGSI_SEMANTIC_COLOR1B 4 /**< back-face secondary color */ +#define TGSI_SEMANTIC_POSITION 5 +#define TGSI_SEMANTIC_FOG 6 +#define TGSI_SEMANTIC_OTHER 7 /* XXX temp */ +#define TGSI_SEMANTIC_TEX0 8 +#define TGSI_SEMANTIC_TEX1 9 +#define TGSI_SEMANTIC_TEX2 10 +#define TGSI_SEMANTIC_TEX3 11 +#define TGSI_SEMANTIC_TEX4 12 +#define TGSI_SEMANTIC_TEX5 13 +#define TGSI_SEMANTIC_TEX6 14 +#define TGSI_SEMANTIC_TEX7 15 +#define TGSI_SEMANTIC_COUNT 16 /**< number of semantic values */ struct tgsi_declaration_semantic { - unsigned SemanticName : 8; /* TGSI_SEMANTIC_ */ + unsigned SemanticName : 8; /* one of TGSI_SEMANTIC_ */ unsigned SemanticIndex : 16; /* UINT */ unsigned Padding : 8; }; diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index 1f8d937bc6..fb8365aab5 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -3,9 +3,9 @@ #include "pipe/tgsi/exec/tgsi_attribs.h" #include "pipe/tgsi/mesa/mesa_to_tgsi.h" -#define TGSI_DEBUG 1 - +#define TGSI_DEBUG 0 +#if 0 /** * Convert a VERT_ATTRIB_x to a TGSI_ATTRIB_y */ @@ -209,9 +209,10 @@ tgsi_mesa_translate_fragment_output(GLuint attrib) return 0; } } +#endif -#if 01 +#if 0 uint tgsi_mesa_translate_vertex_input_mask(GLbitfield mask) { @@ -225,7 +226,6 @@ tgsi_mesa_translate_vertex_input_mask(GLbitfield mask) } return tgsiMask; } -#endif uint tgsi_mesa_translate_vertex_output_mask(GLbitfield mask) @@ -271,6 +271,7 @@ tgsi_mesa_translate_fragment_output_mask(GLbitfield mask) } +#endif @@ -319,12 +320,16 @@ map_register_file_index( GLuint processor, GLuint file, GLuint index, +#if 0 GLbitfield usage_bitmask, +#endif const GLuint inputMapping[], const GLuint outputMapping[]) { GLuint mapped_index; +#if 0 GLuint i; +#endif assert(processor == TGSI_PROCESSOR_FRAGMENT || processor == TGSI_PROCESSOR_VERTEX); @@ -345,7 +350,8 @@ map_register_file_index( inputMapping[index]); return inputMapping[index]; } - + assert(0); +#if 0 assert( usage_bitmask & (1 << index) ); mapped_index = 0; for( i = 0; i < index; i++ ) { @@ -354,6 +360,7 @@ map_register_file_index( } } printf("Map %d input %d to %d\n", processor, index, mapped_index); +#endif break; case TGSI_FILE_OUTPUT: @@ -375,14 +382,17 @@ map_register_file_index( else { /* vertex output slots are tightly packed, find mapped pos */ /* mapped_index = VERT_RESULT_x */ +#if 0 mapped_index = 0; for( i = 0; i < index; i++ ) { if( usage_bitmask & (1 << i) ) { mapped_index++; } } - printf("Map VP output from %d to %d\n", index, mapped_index); assert(outputMapping[index] == mapped_index); +#endif + mapped_index = outputMapping[index]; + printf("Map VP output from %d to %d\n", index, mapped_index); } break; @@ -452,8 +462,10 @@ static GLboolean compile_instruction( const struct prog_instruction *inst, struct tgsi_full_instruction *fullinst, +#if 0 GLuint inputs_read, GLuint outputs_written, +#endif const GLuint inputMapping[], const GLuint outputMapping[], GLuint preamble_size, @@ -475,8 +487,14 @@ compile_instruction( processor, fulldst->DstRegister.File, inst->DstReg.Index, +#if 0 outputs_written, +#endif +#if 0 NULL, +#else + inputMapping, +#endif outputMapping ); fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask ); @@ -490,7 +508,9 @@ compile_instruction( processor, fullsrc->SrcRegister.File, inst->SrcReg[i].Index, +#if 0 inputs_read, +#endif inputMapping, outputMapping ); @@ -766,10 +786,10 @@ compile_instruction( static struct tgsi_full_declaration make_frag_input_decl( - GLuint first, - GLuint last, + GLuint index, GLuint interpolate, - GLuint usage_mask ) + GLuint usage_mask, + GLuint semantic_name ) { struct tgsi_full_declaration decl; @@ -777,9 +797,11 @@ make_frag_input_decl( decl.Declaration.File = TGSI_FILE_INPUT; decl.Declaration.Declare = TGSI_DECLARE_RANGE; decl.Declaration.UsageMask = usage_mask; + decl.Declaration.Semantic = 1; decl.Declaration.Interpolate = 1; - decl.u.DeclarationRange.First = first; - decl.u.DeclarationRange.Last = last; + decl.u.DeclarationRange.First = index; + decl.u.DeclarationRange.Last = index; + decl.Semantic.SemanticName = semantic_name; decl.Interpolation.Interpolate = interpolate; return decl; @@ -809,15 +831,20 @@ make_frag_output_decl( /** * Convert Mesa fragment program to TGSI format. - * \param inputMapping array to map original Mesa fragment program inputs - * registers to TGSI generic input indexes - * \param interpMode array[FRAG_ATTRIB_x] of TGSI_INTERPOLATE_LINEAR/PERSP. + * \param inputMapping maps Mesa fragment program inputs to TGSI generic + * input indexes + * \param inputSemantic the TGSI_SEMANTIC flag for each input + * \param interpMode the TGSI_INTERPOLATE_LINEAR/PERSP mode for each input + * \param outputMapping maps Mesa fragment program outputs to TGSI + * generic outputs * */ GLboolean tgsi_mesa_compile_fp_program( const struct gl_fragment_program *program, + GLuint numInputs, const GLuint inputMapping[], + const ubyte inputSemantic[], const GLuint interpMode[], const GLuint outputMapping[], struct tgsi_token *tokens, @@ -831,9 +858,9 @@ tgsi_mesa_compile_fp_program( /* struct tgsi_full_dst_register *fulldst; struct tgsi_full_src_register *fullsrc; - */ GLuint inputs_read; GLboolean reads_wpos; + */ GLuint preamble_size = 0; *(struct tgsi_version *) &tokens[0] = tgsi_build_version(); @@ -846,6 +873,7 @@ tgsi_mesa_compile_fp_program( ti = 3; +#if 0 reads_wpos = program->Base.InputsRead & (1 << FRAG_ATTRIB_WPOS); inputs_read = program->Base.InputsRead | (1 << FRAG_ATTRIB_WPOS); @@ -856,10 +884,10 @@ tgsi_mesa_compile_fp_program( /* Fragment position. */ if( reads_wpos ) { fulldecl = make_frag_input_decl( - 0, 0, TGSI_INTERPOLATE_CONSTANT, - TGSI_WRITEMASK_XY ); + TGSI_WRITEMASK_XY, + TGSI_SEMANTIC_POSITION ); ti += tgsi_build_full_declaration( &fulldecl, &tokens[ti], @@ -869,10 +897,10 @@ tgsi_mesa_compile_fp_program( /* Fragment zw. */ fulldecl = make_frag_input_decl( - 0, 0, TGSI_INTERPOLATE_LINEAR, - reads_wpos ? TGSI_WRITEMASK_ZW : TGSI_WRITEMASK_Z ); + reads_wpos ? TGSI_WRITEMASK_ZW : TGSI_WRITEMASK_Z, + TGSI_SEMANTIC_POSITION ); ti += tgsi_build_full_declaration( &fulldecl, &tokens[ti], @@ -884,15 +912,55 @@ tgsi_mesa_compile_fp_program( if( inputs_read & (1 << i) ) { count++; fulldecl = make_frag_input_decl(count, - count, interpMode[i], - TGSI_WRITEMASK_XYZW ); + TGSI_WRITEMASK_XYZW, + inputSemantic[count] ); ti += tgsi_build_full_declaration(&fulldecl, &tokens[ti], header, maxTokens - ti ); } } +#else + + for (i = 0; i < numInputs; i++) { + switch (inputSemantic[i]) { + case TGSI_SEMANTIC_POSITION: + /* Fragment XY pos */ + fulldecl = make_frag_input_decl(i, + TGSI_INTERPOLATE_CONSTANT, + TGSI_WRITEMASK_XY, + TGSI_SEMANTIC_POSITION ); + ti += tgsi_build_full_declaration( + &fulldecl, + &tokens[ti], + header, + maxTokens - ti ); + /* Fragment ZW pos */ + fulldecl = make_frag_input_decl(i, + TGSI_INTERPOLATE_LINEAR, + TGSI_WRITEMASK_ZW, + TGSI_SEMANTIC_POSITION ); + ti += tgsi_build_full_declaration( + &fulldecl, + &tokens[ti], + header, + maxTokens - ti ); + break; + default: + fulldecl = make_frag_input_decl(i, + interpMode[i], + TGSI_WRITEMASK_XYZW, + inputSemantic[i] ); + ti += tgsi_build_full_declaration(&fulldecl, + &tokens[ti], + header, + maxTokens - ti ); + break; + } + } +#endif + /* * Declare output attributes. @@ -914,7 +982,7 @@ tgsi_mesa_compile_fp_program( if( program->Base.OutputsWritten & (1 << FRAG_RESULT_COLR) ) { fulldecl = make_frag_output_decl( 1, - TGSI_SEMANTIC_COLOR, + TGSI_SEMANTIC_COLOR0, TGSI_WRITEMASK_XYZW ); ti += tgsi_build_full_declaration( &fulldecl, @@ -956,8 +1024,10 @@ tgsi_mesa_compile_fp_program( if( compile_instruction( &program->Base.Instructions[i], &fullinst, +#if 0 inputs_read, ~0, /*outputs_written*/ +#endif inputMapping, outputMapping, preamble_size, @@ -992,10 +1062,12 @@ tgsi_mesa_compile_vp_program( struct tgsi_header *header; struct tgsi_processor *processor; struct tgsi_full_instruction fullinst; +#if 0 GLuint inputs_read = ~0; GLuint outputs_written; outputs_written = program->Base.OutputsWritten; +#endif *(struct tgsi_version *) &tokens[0] = tgsi_build_version(); @@ -1011,8 +1083,10 @@ tgsi_mesa_compile_vp_program( if( compile_instruction( &program->Base.Instructions[i], &fullinst, +#if 0 inputs_read, outputs_written, +#endif inputMapping, outputMapping, 0, diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h index 017cfce72e..8105e9e738 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h @@ -10,7 +10,9 @@ struct tgsi_token; GLboolean tgsi_mesa_compile_fp_program( const struct gl_fragment_program *program, + GLuint numInputs, const GLuint inputMapping[], + const ubyte inputSemantic[], const GLuint interpMode[], const GLuint outputMapping[], struct tgsi_token *tokens, diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index 6dd576a57c..94b69c8df7 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -27,6 +27,7 @@ /* * Authors: * Keith Whitwell + * Brian Paul */ #include "shader/prog_parameter.h" @@ -42,55 +43,121 @@ #include "st_atom.h" #include "st_program.h" + #define TGSI_DEBUG 1 -static void compile_fs( struct st_context *st ) + +/** + * Translate a Mesa fragment shader into a TGSI shader. + * \return pointer to cached pipe_shader object. + */ +struct pipe_shader_state * +st_translate_fragment_shader(struct st_context *st, + struct st_fragment_program *stfp) { - /* Map FRAG_RESULT_COLR to output 1, map FRAG_RESULT_DEPR to output 0 */ - static const GLuint outputMapping[2] = {1, 0}; - struct st_fragment_program *fp = st->fp; + GLuint outputMapping[FRAG_RESULT_MAX]; + GLuint inputMapping[PIPE_MAX_SHADER_INPUTS]; struct pipe_shader_state fs; struct pipe_shader_state *cached; GLuint interpMode[16]; /* XXX size? */ GLuint i; + GLbitfield inputsRead = stfp->Base.Base.InputsRead; + + /* Check if all fragment programs need the fragment position (in order + * to do perspective-corrected interpolation). + */ + if (st->pipe->get_param(st->pipe, PIPE_PARAM_FS_NEEDS_POS)) + inputsRead |= FRAG_BIT_WPOS; + + memset(&fs, 0, sizeof(fs)); for (i = 0; i < 16; i++) { - if (fp->Base.Base.InputsRead & (1 << i)) { - if (i == FRAG_ATTRIB_COL0 || i == FRAG_ATTRIB_COL1) { - interpMode[i] = TGSI_INTERPOLATE_LINEAR; + if (inputsRead & (1 << i)) { + inputMapping[i] = fs.num_inputs; + + switch (i) { + case FRAG_ATTRIB_WPOS: + fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_POSITION; + interpMode[fs.num_inputs] = TGSI_INTERPOLATE_CONSTANT; + break; + case FRAG_ATTRIB_COL0: + fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_COLOR0; + interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR; + break; + case FRAG_ATTRIB_COL1: + fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_COLOR1; + interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR; + break; + case FRAG_ATTRIB_TEX0: + fs.input_semantics[fs.num_inputs] = TGSI_SEMANTIC_TEX0; + interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; + break; + default: + assert(0); } - else { - interpMode[i] = TGSI_INTERPOLATE_PERSPECTIVE; + + fs.num_inputs++; + } + } + + /* + * Outputs + */ + for (i = 0; i < FRAG_RESULT_MAX; i++) { + if (stfp->Base.Base.OutputsWritten & (1 << i)) { + switch (i) { + case FRAG_RESULT_DEPR: + fs.output_semantics[fs.num_outputs] = TGSI_SEMANTIC_DEPTH; + outputMapping[i] = fs.num_outputs; + break; + case FRAG_RESULT_COLR: + fs.output_semantics[fs.num_outputs] = TGSI_SEMANTIC_COLOR0; + outputMapping[i] = fs.num_outputs; + break; + default: + assert(0); } + fs.num_outputs++; } } /* XXX: fix static allocation of tokens: */ - tgsi_mesa_compile_fp_program( &fp->Base, NULL, interpMode, + tgsi_mesa_compile_fp_program( &stfp->Base, + fs.num_inputs, + inputMapping, + fs.input_semantics, + interpMode, outputMapping, - fp->tokens, ST_FP_MAX_TOKENS ); + stfp->tokens, ST_FP_MAX_TOKENS ); - memset(&fs, 0, sizeof(fs)); +#if 0 fs.inputs_read - = tgsi_mesa_translate_fragment_input_mask(fp->Base.Base.InputsRead); + = tgsi_mesa_translate_fragment_input_mask(stfp->Base.Base.InputsRead); +#endif +#if 0 fs.outputs_written - = tgsi_mesa_translate_fragment_output_mask(fp->Base.Base.OutputsWritten); - fs.tokens = &fp->tokens[0]; + = tgsi_mesa_translate_fragment_output_mask(stfp->Base.Base.OutputsWritten); +#endif + + fs.tokens = &stfp->tokens[0]; + cached = st_cached_fs_state(st, &fs); - fp->fsx = cached; + stfp->fs = cached; if (TGSI_DEBUG) - tgsi_dump( fp->tokens, 0/*TGSI_DUMP_VERBOSE*/ ); + tgsi_dump( stfp->tokens, 0/*TGSI_DUMP_VERBOSE*/ ); + + stfp->dirty = 0; - fp->dirty = 0; + return cached; } static void update_fs( struct st_context *st ) { - struct st_fragment_program *fp = NULL; + struct st_fragment_program *stfp = NULL; /* find active shader and params. Changes to this Mesa state * should be covered by ST_NEW_FRAGMENT_PROGRAM, thanks to the @@ -101,21 +168,21 @@ static void update_fs( struct st_context *st ) st->ctx->Shader.CurrentProgram->FragmentProgram) { struct gl_fragment_program *f = st->ctx->Shader.CurrentProgram->FragmentProgram; - fp = st_fragment_program(f); + stfp = st_fragment_program(f); } else { assert(st->ctx->FragmentProgram._Current); - fp = st_fragment_program(st->ctx->FragmentProgram._Current); + stfp = st_fragment_program(st->ctx->FragmentProgram._Current); } - /* translate shader to TGSI format */ - if (st->fp != fp || fp->dirty) { - st->fp = fp; + /* if new binding, or shader has changed */ + if (st->fp != stfp || stfp->dirty) { + /* Bind the program */ + st->fp = stfp; - if (fp->dirty) - compile_fs( st ); + if (stfp->dirty) + st->state.fs = st_translate_fragment_shader( st, st->fp ); - st->state.fs = fp->fsx; st->pipe->bind_fs_state(st->pipe, st->state.fs); } } diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index 322fabc456..cf9dd810e9 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -49,14 +49,15 @@ #define TGSI_DEBUG 1 - - /** - * Translate Mesa shader to TGSI format + * Translate a Mesa vertex shader into a TGSI shader. + * \return pointer to cached pipe_shader object. */ -static void compile_vs( struct st_context *st ) +struct pipe_shader_state * +st_translate_vertex_shader(struct st_context *st, + struct st_vertex_program *stvp) { - struct st_vertex_program *vp = st->vp; + GLuint outputMapping[PIPE_MAX_SHADER_INPUTS]; struct pipe_shader_state vs; struct pipe_shader_state *cached; GLuint i; @@ -69,20 +70,56 @@ static void compile_vs( struct st_context *st ) * values and TGSI generic input indexes. */ for (i = 0; i < MAX_VERTEX_PROGRAM_ATTRIBS; i++) { - if (vp->Base.Base.InputsRead & (1 << i)) { - vp->input_to_index[i] = vs.num_inputs; - vp->index_to_input[vs.num_inputs] = i; + if (stvp->Base.Base.InputsRead & (1 << i)) { + stvp->input_to_index[i] = vs.num_inputs; + stvp->index_to_input[vs.num_inputs] = i; + switch (i) { + case VERT_ATTRIB_POS: + vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_POSITION; + break; + case VERT_ATTRIB_COLOR0: + vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR0; + break; + case VERT_ATTRIB_COLOR1: + vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1; + break; + default: + vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_OTHER; + } vs.num_inputs++; } } /* - * Determine output register mapping. + * Determine number of outputs and the register mapping. */ for (i = 0; i < VERT_RESULT_MAX; i++) { - if (vp->Base.Base.OutputsWritten & (1 << i)) { - vp->output_to_index[i] = vs.num_outputs; - vp->index_to_output[vs.num_outputs] = i; + if (stvp->Base.Base.OutputsWritten & (1 << i)) { +#if 0 + stvp->output_to_index[i] = vs.num_outputs; + stvp->index_to_output[vs.num_outputs] = i; +#endif + outputMapping[i] = vs.num_outputs; + + switch (i) { + case VERT_RESULT_HPOS: + vs.output_semantics[vs.num_outputs] = TGSI_SEMANTIC_POSITION; + break; + case VERT_RESULT_COL0: + vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR0; + break; + case VERT_RESULT_COL1: + vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1; + break; + case VERT_RESULT_BFC0: + vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR0B; + break; + case VERT_RESULT_BFC1: + vs.input_semantics[vs.num_inputs] = TGSI_SEMANTIC_COLOR1B; + break; + default: + vs.output_semantics[vs.num_outputs] = TGSI_SEMANTIC_OTHER; + } vs.num_outputs++; } } @@ -90,43 +127,50 @@ static void compile_vs( struct st_context *st ) /* XXX: fix static allocation of tokens: */ - tgsi_mesa_compile_vp_program( &vp->Base, - vp->input_to_index, - vp->output_to_index, - vp->tokens, ST_FP_MAX_TOKENS ); + tgsi_mesa_compile_vp_program( &stvp->Base, + stvp->input_to_index, +#if 0 + stvp->output_to_index, +#else + outputMapping, +#endif + stvp->tokens, ST_FP_MAX_TOKENS ); -#if 01 +#if 0 vs.inputs_read - = tgsi_mesa_translate_vertex_input_mask(vp->Base.Base.InputsRead); + = tgsi_mesa_translate_vertex_input_mask(stvp->Base.Base.InputsRead); #endif +#if 0 vs.outputs_written - = tgsi_mesa_translate_vertex_output_mask(vp->Base.Base.OutputsWritten); + = tgsi_mesa_translate_vertex_output_mask(stvp->Base.Base.OutputsWritten); +#endif - vs.tokens = &vp->tokens[0]; + vs.tokens = &stvp->tokens[0]; cached = st_cached_vs_state(st, &vs); - - vp->vs = cached; + stvp->vs = cached; if (TGSI_DEBUG) - tgsi_dump( vp->tokens, 0 ); + tgsi_dump( stvp->tokens, 0 ); #if defined(USE_X86_ASM) || defined(SLANG_X86) - if (vp->sse2_program.csr == vp->sse2_program.store) - tgsi_emit_sse2( vp->tokens, &vp->sse2_program ); + if (stvp->sse2_program.csr == stvp->sse2_program.store) + tgsi_emit_sse2( stvp->tokens, &stvp->sse2_program ); if (!cached->executable) - cached->executable = (void *) x86_get_func( &vp->sse2_program ); + cached->executable = (void *) x86_get_func( &stvp->sse2_program ); #endif - vp->dirty = 0; + stvp->dirty = 0; + + return cached; } static void update_vs( struct st_context *st ) { - struct st_vertex_program *vp; + struct st_vertex_program *stvp; /* find active shader and params -- Should be covered by * ST_NEW_VERTEX_PROGRAM @@ -136,20 +180,20 @@ static void update_vs( struct st_context *st ) st->ctx->Shader.CurrentProgram->VertexProgram) { struct gl_vertex_program *f = st->ctx->Shader.CurrentProgram->VertexProgram; - vp = st_vertex_program(f); + stvp = st_vertex_program(f); } else { assert(st->ctx->VertexProgram._Current); - vp = st_vertex_program(st->ctx->VertexProgram._Current); + stvp = st_vertex_program(st->ctx->VertexProgram._Current); } - if (st->vp != vp || vp->dirty) { - st->vp = vp; + if (st->vp != stvp || stvp->dirty) { + /* Bind the vertex program */ + st->vp = stvp; - if (vp->dirty) - compile_vs( st ); + if (stvp->dirty) + st->state.vs = st_translate_vertex_shader( st, st->vp ); - st->state.vs = st->vp->vs; st->pipe->bind_vs_state(st->pipe, st->state.vs); } } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 5d5efd9eae..ee70ce3320 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -121,11 +121,9 @@ is_depth_stencil_format(GLuint pipeFormat) static struct st_fragment_program * make_frag_shader(struct st_context *st) { - static const GLuint outputMapping[] = { 1, 0 }; GLcontext *ctx = st->ctx; struct st_fragment_program *stfp; struct gl_program *p; - GLboolean b; GLuint interpMode[16]; GLuint i; @@ -157,11 +155,7 @@ make_frag_shader(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR); stfp = (struct st_fragment_program *) p; - /* compile into tgsi format */ - b = tgsi_mesa_compile_fp_program(&stfp->Base, NULL, interpMode, - outputMapping, - stfp->tokens, ST_FP_MAX_TOKENS); - assert(b); + st_translate_fragment_shader(st, stfp); return stfp; } @@ -174,15 +168,9 @@ make_frag_shader(struct st_context *st) static struct st_vertex_program * make_vertex_shader(struct st_context *st) { - /* Map VERT_ATTRIB_POS to 0, VERT_ATTRIB_COLOR0 to 1 */ - static const GLuint inputMapping[4] = { 0, 0, 0, 1 }; - /* Map VERT_RESULT_HPOS to 0, VERT_RESULT_COL0 to 1 */ - static const GLuint outputMapping[2] = { 0, 1 }; - GLcontext *ctx = st->ctx; struct st_vertex_program *stvp; struct gl_program *p; - GLboolean b; p = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); if (!p) @@ -215,12 +203,8 @@ make_vertex_shader(struct st_context *st) (1 << VERT_RESULT_HPOS)); stvp = (struct st_vertex_program *) p; - /* compile into tgsi format */ - b = tgsi_mesa_compile_vp_program(&stvp->Base, - inputMapping, - outputMapping, - stvp->tokens, ST_FP_MAX_TOKENS); - assert(b); + st_translate_vertex_shader(st, stvp); + assert(stvp->vs); return stvp; } @@ -361,33 +345,19 @@ clear_with_quad(GLcontext *ctx, /* fragment shader state: color pass-through program */ { static struct st_fragment_program *stfp = NULL; - struct pipe_shader_state fs; - const struct pipe_shader_state *cached; if (!stfp) { stfp = make_frag_shader(st); } - memset(&fs, 0, sizeof(fs)); - fs.inputs_read = tgsi_mesa_translate_fragment_input_mask(stfp->Base.Base.InputsRead); - fs.outputs_written = tgsi_mesa_translate_fragment_output_mask(stfp->Base.Base.OutputsWritten); - fs.tokens = &stfp->tokens[0]; - cached = st_cached_fs_state(st, &fs); - pipe->bind_fs_state(pipe, cached); + pipe->bind_fs_state(pipe, stfp->fs); } /* vertex shader state: color/position pass-through */ { static struct st_vertex_program *stvp = NULL; - struct pipe_shader_state vs; - const struct pipe_shader_state *cached; 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]; - cached = st_cached_vs_state(st, &vs); - pipe->bind_vs_state(pipe, cached); + pipe->bind_vs_state(pipe, stvp->vs); } /* viewport state: viewport matching window dims */ @@ -522,12 +492,15 @@ clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) assert(strb->surface->format); +#if 01 if (ctx->Scissor.Enabled || (isDS && ctx->DrawBuffer->Visual.stencilBits > 0)) { /* scissoring or we have a combined depth/stencil buffer */ clear_with_quad(ctx, GL_FALSE, GL_TRUE, GL_FALSE); } - else { + else +#endif + { /* simple clear of whole buffer */ GLuint clearValue = depth_value(strb->surface->format, ctx->Depth.Clear); ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 0fd728c930..d4f260ee54 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -56,11 +56,9 @@ static struct st_fragment_program * make_fragment_shader(struct st_context *st) { - static const GLuint outputMapping[2] = { 1, 0 }; GLcontext *ctx = st->ctx; struct st_fragment_program *stfp; struct gl_program *p; - GLboolean b; GLuint interpMode[16]; GLuint i; @@ -94,11 +92,7 @@ make_fragment_shader(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR); stfp = (struct st_fragment_program *) p; - /* compile into tgsi format */ - b = tgsi_mesa_compile_fp_program(&stfp->Base, NULL, interpMode, - outputMapping, - stfp->tokens, ST_FP_MAX_TOKENS); - assert(b); + st_translate_fragment_shader(st, stfp); return stfp; } @@ -112,11 +106,9 @@ static struct st_vertex_program * make_vertex_shader(struct st_context *st) { /* Map VERT_RESULT_HPOS to 0, VERT_RESULT_TEX0 to 1 */ - static const GLuint outputMapping[] = { 0, 0, 0, 0, 1 }; GLcontext *ctx = st->ctx; struct st_vertex_program *stvp; struct gl_program *p; - GLboolean b; p = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); if (!p) @@ -149,11 +141,7 @@ make_vertex_shader(struct st_context *st) (1 << VERT_RESULT_HPOS)); stvp = (struct st_vertex_program *) p; - /* compile into tgsi format */ - b = tgsi_mesa_compile_vp_program(&stvp->Base, NULL, - outputMapping, - stvp->tokens, ST_FP_MAX_TOKENS); - assert(b); + st_translate_vertex_shader(st, stvp); return stvp; } @@ -339,32 +327,19 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* fragment shader state: TEX lookup program */ { static struct st_fragment_program *stfp = NULL; - struct pipe_shader_state fs; - struct pipe_shader_state *cached; if (!stfp) { stfp = make_fragment_shader(ctx->st); } - memset(&fs, 0, sizeof(fs)); - fs.inputs_read = stfp->Base.Base.InputsRead; - fs.tokens = &stfp->tokens[0]; - cached = st_cached_fs_state(ctx->st, &fs); - pipe->bind_fs_state(pipe, cached); + pipe->bind_fs_state(pipe, stfp->fs); } /* vertex shader state: position + texcoord pass-through */ { static struct st_vertex_program *stvp = NULL; - struct pipe_shader_state vs; - struct pipe_shader_state *cached; if (!stvp) { stvp = make_vertex_shader(ctx->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]; - cached = st_cached_vs_state(ctx->st, &vs); - pipe->bind_vs_state(pipe, cached); + pipe->bind_vs_state(pipe, stvp->vs); } /* texture sampling state: */ diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 98efe1a10b..5245535a65 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -53,6 +53,7 @@ static void setup_vertex_attribs(GLcontext *ctx) { struct pipe_context *pipe = ctx->st->pipe; +#if 0 const uint inputAttrs = ctx->st->state.vs->inputs_read; uint attr; @@ -77,6 +78,9 @@ setup_vertex_attribs(GLcontext *ctx) pipe->set_vertex_element(pipe, attr, &velement); } } +#else + assert(0); +#endif } @@ -84,7 +88,7 @@ static void setup_feedback(GLcontext *ctx) { struct pipe_context *pipe = ctx->st->pipe; - const uint outputAttrs = ctx->st->state.vs->outputs_written; + const struct pipe_shader_state *vs = ctx->st->state.vs; struct pipe_feedback_state feedback; uint i; @@ -94,8 +98,8 @@ setup_feedback(GLcontext *ctx) feedback.discard = 1; feedback.num_attribs = 0; - for (i = 0; i < TGSI_ATTRIB_VAR0; i++) { - if ((1 << i) & outputAttrs) { + for (i = 0; i < vs->num_outputs; i++) { + if (1/***(1 << i) & outputAttrs***/) { feedback.attrib[feedback.num_attribs] = i; feedback.size[feedback.num_attribs] = 4; feedback.num_attribs++; @@ -306,6 +310,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) PIPE_BUFFER_FLAG_READ); /* extract values and update rasterpos state */ +#if 0 /* XXX update */ { const uint outputAttrs = ctx->st->state.vs->outputs_written; const float *pos, *color0, *color1, *tex0; @@ -333,7 +338,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) update_rasterpos(ctx, pos, color0, color1, tex0); } - +#endif /* free vertex feedback buffer */ pipe->winsys->buffer_unmap(pipe->winsys, fb_buf.buffer); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 7075db82e9..238ade00ac 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -356,7 +356,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, velement.vertex_buffer_index = 0; velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; velement.dst_offset = 0; - pipe->set_vertex_element(pipe, attribs[i], &velement); + pipe->set_vertex_element(pipe, i/**attribs[i]**/, &velement); } /* draw */ @@ -411,7 +411,7 @@ st_feedback_draw_vbo(GLcontext *ctx, update_default_attribs_buffer(ctx); - +#if 0 /* this must be after state validation */ attrsNeeded = ctx->st->state.vs->inputs_read; @@ -480,7 +480,9 @@ st_feedback_draw_vbo(GLcontext *ctx, draw_set_mapped_vertex_buffer(draw, attr, map); } } - +#else + assert(0); +#endif if (ib) { unsigned indexSize; diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 68ceba4d78..4945141d15 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -45,16 +45,15 @@ struct st_fragment_program { struct gl_fragment_program Base; GLboolean error; /* If program is malformed for any reason. */ - - GLuint id; /* String id, for tracking - * ProgramStringNotify changes. - */ + GLuint id; /**< String id, for tracking ProgramStringNotify changes. */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; GLboolean dirty; - const struct pipe_shader_state *fsx; + /** Pointer to the corresponding cached shader */ + const struct pipe_shader_state *fs; + GLuint param_state; }; @@ -63,16 +62,17 @@ struct st_vertex_program { struct gl_vertex_program Base; /**< The Mesa vertex program */ GLboolean error; /**< Set if program is malformed for any reason. */ - - GLuint id; /**< String id, for tracking ProgramStringNotify changes. */ + GLuint id; /**< String id, for tracking ProgramStringNotify changes. */ /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */ GLuint input_to_index[MAX_VERTEX_PROGRAM_ATTRIBS]; /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */ GLuint index_to_input[MAX_VERTEX_PROGRAM_ATTRIBS]; +#if 0 GLuint output_to_index[MAX_VERTEX_PROGRAM_ATTRIBS]; GLuint index_to_output[MAX_VERTEX_PROGRAM_ATTRIBS]; +#endif /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; @@ -82,7 +82,9 @@ struct st_vertex_program struct x86_function sse2_program; #endif + /** Pointer to the corresponding cached shader */ const struct pipe_shader_state *vs; + GLuint param_state; }; @@ -102,4 +104,15 @@ st_vertex_program( struct gl_vertex_program *vp ) return (struct st_vertex_program *)vp; } + +extern struct pipe_shader_state * +st_translate_fragment_shader(struct st_context *st, + struct st_fragment_program *fp); + + +extern struct pipe_shader_state * +st_translate_vertex_shader(struct st_context *st, + struct st_vertex_program *vp); + + #endif -- cgit v1.2.3 From daf5b0f41baa50951e7c2f9ea5cd90b119085a7f Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 20 Sep 2007 07:50:33 -0400 Subject: Switch fragment/vertex shaders to the new caching semantics. Allow driver custom allocation within cached objects. The shaders are currently twiced (by cso layer and by the program itself). --- src/mesa/pipe/cso_cache/cso_cache.h | 10 +++++ src/mesa/pipe/failover/fo_context.h | 4 +- src/mesa/pipe/failover/fo_state.c | 75 +++++++++++++++++++++++++++---- src/mesa/pipe/failover/fo_state_emit.c | 6 ++- src/mesa/pipe/i915simple/i915_state.c | 28 +++++------- src/mesa/pipe/p_context.h | 23 ++++------ src/mesa/pipe/softpipe/sp_state.h | 11 ++--- src/mesa/pipe/softpipe/sp_state_fs.c | 27 +++++------ src/mesa/state_tracker/st_atom_fs.c | 12 ++--- src/mesa/state_tracker/st_atom_vs.c | 18 ++++---- src/mesa/state_tracker/st_cache.c | 36 ++++++++------- src/mesa/state_tracker/st_cache.h | 12 ++--- src/mesa/state_tracker/st_cb_clear.c | 8 ++-- src/mesa/state_tracker/st_cb_drawpixels.c | 8 ++-- src/mesa/state_tracker/st_cb_rasterpos.c | 3 +- src/mesa/state_tracker/st_context.h | 4 +- src/mesa/state_tracker/st_draw.c | 6 +-- src/mesa/state_tracker/st_program.h | 10 +++-- 18 files changed, 181 insertions(+), 120 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h index cd4b64eec4..57d162b2ac 100644 --- a/src/mesa/pipe/cso_cache/cso_cache.h +++ b/src/mesa/pipe/cso_cache/cso_cache.h @@ -58,6 +58,16 @@ struct cso_rasterizer { void *data; }; +struct cso_fragment_shader { + struct pipe_shader_state state; + void *data; +}; + +struct cso_vertex_shader { + struct pipe_shader_state state; + void *data; +}; + enum cso_cache_type { CSO_BLEND, CSO_SAMPLER, diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index a649899010..a81bfe82dd 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -74,8 +74,8 @@ struct failover_context { const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; const struct fo_state *rasterizer; - const struct pipe_shader_state *fragment_shader; - const struct pipe_shader_state *vertex_shader; + const struct fo_state *fragment_shader; + const struct fo_state *vertex_shader; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index 25725625e0..db3aea7756 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -150,26 +150,81 @@ failover_set_framebuffer_state(struct pipe_context *pipe, failover->hw->set_framebuffer_state( failover->hw, framebuffer ); } + +static void * +failover_create_fs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + + state->sw_state = failover->sw->create_fs_state(pipe, templ); + state->hw_state = failover->hw->create_fs_state(pipe, templ); + + return state; +} + static void failover_bind_fs_state(struct pipe_context *pipe, - const struct pipe_shader_state *fs) + void *fs) { struct failover_context *failover = failover_context(pipe); - failover->fragment_shader = fs; + failover->fragment_shader = (struct fo_state *)fs; failover->dirty |= FO_NEW_FRAGMENT_SHADER; - failover->hw->bind_fs_state( failover->hw, fs ); + failover->hw->bind_fs_state(failover->hw, (struct pipe_shader_state *)fs); +} + +static void +failover_delete_fs_state(struct pipe_context *pipe, + void *fs) +{ + struct fo_state *state = (struct fo_state*)fs; + struct failover_context *failover = failover_context(pipe); + + failover->sw->delete_fs_state(pipe, state->sw_state); + failover->hw->delete_fs_state(pipe, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); +} + +static void * +failover_create_vs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + + state->sw_state = failover->sw->create_vs_state(pipe, templ); + state->hw_state = failover->hw->create_vs_state(pipe, templ); + + return state; } static void failover_bind_vs_state(struct pipe_context *pipe, - const struct pipe_shader_state *vs) + void *vs) { struct failover_context *failover = failover_context(pipe); - failover->vertex_shader = vs; + failover->vertex_shader = (struct fo_state*)vs; failover->dirty |= FO_NEW_VERTEX_SHADER; - failover->hw->bind_vs_state( failover->hw, vs ); + failover->hw->bind_vs_state(failover->hw, vs); +} + +static void +failover_delete_vs_state(struct pipe_context *pipe, + void *vs) +{ + struct fo_state *state = (struct fo_state*)vs; + struct failover_context *failover = failover_context(pipe); + + failover->sw->delete_vs_state(pipe, state->sw_state); + failover->hw->delete_vs_state(pipe, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); } static void @@ -312,8 +367,12 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.create_rasterizer_state = failover_create_rasterizer_state; failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state; failover->pipe.delete_rasterizer_state = failover_delete_rasterizer_state; - failover->pipe.bind_fs_state = failover_bind_fs_state; - failover->pipe.bind_vs_state = failover_bind_vs_state; + failover->pipe.create_fs_state = failover_create_fs_state; + failover->pipe.bind_fs_state = failover_bind_fs_state; + failover->pipe.delete_fs_state = failover_delete_fs_state; + failover->pipe.create_vs_state = failover_create_vs_state; + failover->pipe.bind_vs_state = failover_bind_vs_state; + failover->pipe.delete_vs_state = failover_delete_vs_state; failover->pipe.set_alpha_test_state = failover_set_alpha_test_state; failover->pipe.set_blend_color = failover_set_blend_color; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index f2b0b1edc0..ec896fd020 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -78,10 +78,12 @@ failover_state_emit( struct failover_context *failover ) failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer ); if (failover->dirty & FO_NEW_FRAGMENT_SHADER) - failover->sw->bind_fs_state( failover->sw, failover->fragment_shader ); + failover->sw->bind_fs_state( failover->sw, + failover->fragment_shader->sw_state ); if (failover->dirty & FO_NEW_VERTEX_SHADER) - failover->sw->bind_vs_state( failover->sw, failover->vertex_shader ); + failover->sw->bind_vs_state( failover->sw, + failover->vertex_shader->sw_state ); if (failover->dirty & FO_NEW_STIPPLE) failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple ); diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 66aa9a0274..1104c9519d 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -228,41 +228,37 @@ static void i915_set_polygon_stipple( struct pipe_context *pipe, } -static const struct pipe_shader_state * -i915_create_shader_state( struct pipe_context *pipe, - const struct pipe_shader_state *templ ) +static void * +i915_create_shader_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { - - struct pipe_shader_state *shader = malloc(sizeof(struct pipe_shader_state)); - memcpy(shader, templ, sizeof(struct pipe_shader_state)); - - return shader; + return 0; } static void i915_bind_fs_state( struct pipe_context *pipe, - const struct pipe_shader_state *fs ) + void *fs ) { struct i915_context *i915 = i915_context(pipe); - i915->fs = fs; + i915->fs = (struct pipe_shader_state *)fs; i915->dirty |= I915_NEW_FS; } -static void i915_bind_vs_state( struct pipe_context *pipe, - const struct pipe_shader_state *vs ) +static void i915_bind_vs_state(struct pipe_context *pipe, + void *vs) { struct i915_context *i915 = i915_context(pipe); /* just pass-through to draw module */ - draw_set_vertex_shader(i915->draw, vs); + draw_set_vertex_shader(i915->draw, (const struct pipe_shader_state *)vs); } -static void i915_delete_shader_state( struct pipe_context *pipe, - const struct pipe_shader_state *shader ) +static void i915_delete_shader_state(struct pipe_context *pipe, + void *shader) { - free((struct pipe_shader_state*)shader); + /*do nothing*/ } static void i915_set_constant_buffer(struct pipe_context *pipe, diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 65001dfdf9..e17faad2c7 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -113,20 +113,15 @@ struct pipe_context { void (*delete_depth_stencil_state)(struct pipe_context *, const struct pipe_depth_stencil_state *); - const struct pipe_shader_state * (*create_fs_state)( - struct pipe_context *, - const struct pipe_shader_state *); - void (*bind_fs_state)(struct pipe_context *, - const struct pipe_shader_state *); - void (*delete_fs_state)(struct pipe_context *, - const struct pipe_shader_state *); - const struct pipe_shader_state * (*create_vs_state)( - struct pipe_context *, - const struct pipe_shader_state *); - void (*bind_vs_state)(struct pipe_context *, - const struct pipe_shader_state *); - void (*delete_vs_state)(struct pipe_context *, - const struct pipe_shader_state *); + void * (*create_fs_state)(struct pipe_context *, + const struct pipe_shader_state *); + void (*bind_fs_state)(struct pipe_context *, void *); + void (*delete_fs_state)(struct pipe_context *, void *); + + void * (*create_vs_state)(struct pipe_context *, + const struct pipe_shader_state *); + void (*bind_vs_state)(struct pipe_context *, void *); + void (*delete_vs_state)(struct pipe_context *, void *); void (*set_alpha_test_state)( struct pipe_context *, const struct pipe_alpha_test_state * ); diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index a20ae1d4a2..5ed963c21d 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -88,15 +88,12 @@ void softpipe_set_constant_buffer(struct pipe_context *, void softpipe_set_feedback_state( struct pipe_context *, const struct pipe_feedback_state * ); -const struct pipe_shader_state * +void * softpipe_create_shader_state( struct pipe_context *, const struct pipe_shader_state * ); -void softpipe_bind_fs_state( struct pipe_context *, - const struct pipe_shader_state * ); -void softpipe_bind_vs_state( struct pipe_context *, - const struct pipe_shader_state * ); -void softpipe_delete_shader_state( struct pipe_context *, - const struct pipe_shader_state * ); +void softpipe_bind_fs_state( struct pipe_context *, void * ); +void softpipe_bind_vs_state( struct pipe_context *, void * ); +void softpipe_delete_shader_state( struct pipe_context *, void * ); void softpipe_set_polygon_stipple( struct pipe_context *, const struct pipe_poly_stipple * ); diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index fbbde2f520..8306a95f44 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -33,44 +33,39 @@ #include "pipe/draw/draw_context.h" -const struct pipe_shader_state * -softpipe_create_shader_state( struct pipe_context *pipe, - const struct pipe_shader_state *templ ) +void * softpipe_create_shader_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { - struct pipe_shader_state *shader = malloc(sizeof(struct pipe_shader_state)); - memcpy(shader, templ, sizeof(struct pipe_shader_state)); - - return shader; + /* we just want the pipe_shader_state template in the bind calls */ + return 0; } -void softpipe_bind_fs_state( struct pipe_context *pipe, - const struct pipe_shader_state *fs ) +void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->fs = fs; + softpipe->fs = (struct pipe_shader_state *)fs; softpipe->dirty |= SP_NEW_FS; } -void softpipe_bind_vs_state( struct pipe_context *pipe, - const struct pipe_shader_state *vs ) +void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->vs = vs; + softpipe->vs = (struct pipe_shader_state *)vs; softpipe->dirty |= SP_NEW_VS; - draw_set_vertex_shader(softpipe->draw, vs); + draw_set_vertex_shader(softpipe->draw, (struct pipe_shader_state *)vs); } void softpipe_delete_shader_state( struct pipe_context *pipe, - const struct pipe_shader_state *shader ) + void *shader ) { - free((struct pipe_shader_state*)shader); + /* do nothing */ } void softpipe_set_constant_buffer(struct pipe_context *pipe, diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index 94b69c8df7..91e58f5831 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -51,14 +51,14 @@ * Translate a Mesa fragment shader into a TGSI shader. * \return pointer to cached pipe_shader object. */ -struct pipe_shader_state * +const struct cso_fragment_shader * st_translate_fragment_shader(struct st_context *st, struct st_fragment_program *stfp) { GLuint outputMapping[FRAG_RESULT_MAX]; GLuint inputMapping[PIPE_MAX_SHADER_INPUTS]; struct pipe_shader_state fs; - struct pipe_shader_state *cached; + const struct cso_fragment_shader *cso; GLuint interpMode[16]; /* XXX size? */ GLuint i; GLbitfield inputsRead = stfp->Base.Base.InputsRead; @@ -142,15 +142,15 @@ st_translate_fragment_shader(struct st_context *st, fs.tokens = &stfp->tokens[0]; - cached = st_cached_fs_state(st, &fs); - stfp->fs = cached; + cso = st_cached_fs_state(st, &fs); + stfp->fs = cso; if (TGSI_DEBUG) tgsi_dump( stfp->tokens, 0/*TGSI_DUMP_VERBOSE*/ ); stfp->dirty = 0; - return cached; + return cso; } @@ -183,7 +183,7 @@ static void update_fs( struct st_context *st ) if (stfp->dirty) st->state.fs = st_translate_fragment_shader( st, st->fp ); - st->pipe->bind_fs_state(st->pipe, st->state.fs); + st->pipe->bind_fs_state(st->pipe, st->state.fs->data); } } diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index cf9dd810e9..078c052ae2 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -53,13 +53,13 @@ * Translate a Mesa vertex shader into a TGSI shader. * \return pointer to cached pipe_shader object. */ -struct pipe_shader_state * +const struct cso_vertex_shader * st_translate_vertex_shader(struct st_context *st, struct st_vertex_program *stvp) { GLuint outputMapping[PIPE_MAX_SHADER_INPUTS]; struct pipe_shader_state vs; - struct pipe_shader_state *cached; + const struct cso_vertex_shader *cso; GLuint i; memset(&vs, 0, sizeof(vs)); @@ -147,8 +147,8 @@ st_translate_vertex_shader(struct st_context *st, vs.tokens = &stvp->tokens[0]; - cached = st_cached_vs_state(st, &vs); - stvp->vs = cached; + cso = st_cached_vs_state(st, &vs); + stvp->vs = cso; if (TGSI_DEBUG) tgsi_dump( stvp->tokens, 0 ); @@ -157,13 +157,13 @@ st_translate_vertex_shader(struct st_context *st, if (stvp->sse2_program.csr == stvp->sse2_program.store) tgsi_emit_sse2( stvp->tokens, &stvp->sse2_program ); - if (!cached->executable) - cached->executable = (void *) x86_get_func( &stvp->sse2_program ); + if (!cso->state.executable) + cso->state.executable = (void *) x86_get_func( &stvp->sse2_program ); #endif stvp->dirty = 0; - return cached; + return cso; } @@ -191,10 +191,10 @@ static void update_vs( struct st_context *st ) /* Bind the vertex program */ st->vp = stvp; - if (stvp->dirty) + if (stvp->dirty) st->state.vs = st_translate_vertex_shader( st, st->vp ); - st->pipe->bind_vs_state(st->pipe, st->state.vs); + st->pipe->bind_vs_state(st->pipe, st->state.vs->data); } } diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index 0f233cea58..e5ba0592cf 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -115,9 +115,9 @@ const struct cso_rasterizer* st_cached_rasterizer_state( return (struct cso_rasterizer*)(cso_hash_iter_data(iter)); } -struct pipe_shader_state * st_cached_fs_state( - struct st_context *st, - const struct pipe_shader_state *templ) +const struct cso_fragment_shader * +st_cached_fs_state(struct st_context *st, + const struct pipe_shader_state *templ) { unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_shader_state)); @@ -125,17 +125,19 @@ struct pipe_shader_state * st_cached_fs_state( hash_key, CSO_FRAGMENT_SHADER, (void*)templ); if (cso_hash_iter_is_null(iter)) { - const struct pipe_shader_state *created_state = - st->pipe->create_fs_state(st->pipe, templ); - iter = cso_insert_state(st->cache, hash_key, CSO_FRAGMENT_SHADER, - (void*)created_state); + struct cso_fragment_shader *cso = malloc(sizeof(struct cso_fragment_shader)); + memcpy(&cso->state, templ, sizeof(struct pipe_shader_state)); + cso->data = st->pipe->create_fs_state(st->pipe, templ); + if (!cso->data) + cso->data = &cso->state; + iter = cso_insert_state(st->cache, hash_key, CSO_FRAGMENT_SHADER, cso); } - return (struct pipe_shader_state*)(cso_hash_iter_data(iter)); + return (struct cso_fragment_shader*)(cso_hash_iter_data(iter)); } -struct pipe_shader_state * st_cached_vs_state( - struct st_context *st, - const struct pipe_shader_state *templ) +const struct cso_vertex_shader * +st_cached_vs_state(struct st_context *st, + const struct pipe_shader_state *templ) { unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_shader_state)); @@ -143,10 +145,12 @@ struct pipe_shader_state * st_cached_vs_state( hash_key, CSO_VERTEX_SHADER, (void*)templ); if (cso_hash_iter_is_null(iter)) { - const struct pipe_shader_state *created_state = - st->pipe->create_vs_state(st->pipe, templ); - iter = cso_insert_state(st->cache, hash_key, CSO_VERTEX_SHADER, - (void*)created_state); + struct cso_vertex_shader *cso = malloc(sizeof(struct cso_vertex_shader)); + memcpy(&cso->state, templ, sizeof(struct pipe_shader_state)); + cso->data = st->pipe->create_vs_state(st->pipe, templ); + if (!cso->data) + cso->data = &cso->state; + iter = cso_insert_state(st->cache, hash_key, CSO_VERTEX_SHADER, cso); } - return (struct pipe_shader_state*)(cso_hash_iter_data(iter)); + return (struct cso_vertex_shader*)(cso_hash_iter_data(iter)); } diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index 5b8c6168a8..356dd98183 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -55,13 +55,13 @@ const struct cso_rasterizer * st_cached_rasterizer_state(struct st_context *st, const struct pipe_rasterizer_state *raster); -struct pipe_shader_state *st_cached_fs_state( - struct st_context *st, - const struct pipe_shader_state *templ); +const struct cso_fragment_shader * +st_cached_fs_state(struct st_context *st, + const struct pipe_shader_state *templ); -struct pipe_shader_state *st_cached_vs_state( - struct st_context *st, - const struct pipe_shader_state *templ); +const struct cso_vertex_shader * +st_cached_vs_state(struct st_context *st, + const struct pipe_shader_state *templ); #endif diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index ee70ce3320..03a81652cb 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -348,7 +348,7 @@ clear_with_quad(GLcontext *ctx, if (!stfp) { stfp = make_frag_shader(st); } - pipe->bind_fs_state(pipe, stfp->fs); + pipe->bind_fs_state(pipe, stfp->fs->data); } /* vertex shader state: color/position pass-through */ @@ -357,7 +357,7 @@ clear_with_quad(GLcontext *ctx, if (!stvp) { stvp = make_vertex_shader(st); } - pipe->bind_vs_state(pipe, stvp->vs); + pipe->bind_vs_state(pipe, stvp->vs->data); } /* viewport state: viewport matching window dims */ @@ -383,8 +383,8 @@ clear_with_quad(GLcontext *ctx, pipe->set_alpha_test_state(pipe, &st->state.alpha_test); pipe->bind_blend_state(pipe, st->state.blend->data); pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil); - pipe->bind_fs_state(pipe, st->state.fs); - pipe->bind_vs_state(pipe, st->state.vs); + pipe->bind_fs_state(pipe, st->state.fs->data); + pipe->bind_vs_state(pipe, st->state.vs->data); pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); /* OR: diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index d4f260ee54..4e3c24353e 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -330,7 +330,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, if (!stfp) { stfp = make_fragment_shader(ctx->st); } - pipe->bind_fs_state(pipe, stfp->fs); + pipe->bind_fs_state(pipe, stfp->fs->data); } /* vertex shader state: position + texcoord pass-through */ @@ -339,7 +339,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, if (!stvp) { stvp = make_vertex_shader(ctx->st); } - pipe->bind_vs_state(pipe, stvp->vs); + pipe->bind_vs_state(pipe, stvp->vs->data); } /* texture sampling state: */ @@ -393,8 +393,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* restore GL state */ pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data); - pipe->bind_fs_state(pipe, ctx->st->state.fs); - pipe->bind_vs_state(pipe, ctx->st->state.vs); + pipe->bind_fs_state(pipe, ctx->st->state.fs->data); + pipe->bind_vs_state(pipe, ctx->st->state.vs->data); pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]); pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 5245535a65..04b2016ffc 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -35,6 +35,7 @@ #include "st_context.h" #include "st_atom.h" +#include "st_cache.h" #include "st_draw.h" #include "st_program.h" #include "st_cb_rasterpos.h" @@ -88,7 +89,7 @@ static void setup_feedback(GLcontext *ctx) { struct pipe_context *pipe = ctx->st->pipe; - const struct pipe_shader_state *vs = ctx->st->state.vs; + const struct pipe_shader_state *vs = &ctx->st->state.vs->state; struct pipe_feedback_state feedback; uint i; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 93b6425480..df976260f8 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -79,8 +79,8 @@ struct st_context const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; const struct cso_rasterizer *rasterizer; - const struct pipe_shader_state *fs; - const struct pipe_shader_state *vs; + const struct cso_fragment_shader *fs; + const struct cso_vertex_shader *vs; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 238ade00ac..633e4d9470 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -198,7 +198,7 @@ st_draw_vbo(GLcontext *ctx, /* must get these after state validation! */ vp = ctx->st->vp; - vs = ctx->st->state.vs; + vs = &ctx->st->state.vs->state; /* loop over TGSI shader inputs */ for (attr = 0; attr < vs->num_inputs; attr++) { @@ -405,8 +405,8 @@ 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->data); - draw_set_vertex_shader(draw, st->state.vs); + draw_set_rasterizer_state(draw, &st->state.rasterizer->state); + draw_set_vertex_shader(draw, &st->state.vs->state); /* XXX need to set vertex info too */ diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 4945141d15..4f9ace3e6a 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -40,6 +40,8 @@ #define ST_FP_MAX_TOKENS 1024 +struct cso_fragment_shader; +struct cso_vertex_shader; struct st_fragment_program { @@ -52,7 +54,7 @@ struct st_fragment_program GLboolean dirty; /** Pointer to the corresponding cached shader */ - const struct pipe_shader_state *fs; + const struct cso_fragment_shader *fs; GLuint param_state; }; @@ -83,7 +85,7 @@ struct st_vertex_program #endif /** Pointer to the corresponding cached shader */ - const struct pipe_shader_state *vs; + const struct cso_vertex_shader *vs; GLuint param_state; }; @@ -105,12 +107,12 @@ st_vertex_program( struct gl_vertex_program *vp ) } -extern struct pipe_shader_state * +extern const struct cso_fragment_shader * st_translate_fragment_shader(struct st_context *st, struct st_fragment_program *fp); -extern struct pipe_shader_state * +extern const struct cso_vertex_shader * st_translate_vertex_shader(struct st_context *st, struct st_vertex_program *vp); -- cgit v1.2.3 From c231a9d020bdec8e0749a5547971c79de64f73d8 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 20 Sep 2007 13:58:12 -0600 Subject: remove #includes of tgsi_attribs.h --- src/mesa/pipe/draw/draw_vertex.h | 4 ++-- src/mesa/pipe/softpipe/sp_quad_fs.c | 1 - src/mesa/pipe/softpipe/sp_state_derived.c | 1 - src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c | 1 - src/mesa/state_tracker/st_cb_feedback.c | 1 - src/mesa/state_tracker/st_cb_rasterpos.c | 1 - src/mesa/state_tracker/st_draw.c | 1 - 7 files changed, 2 insertions(+), 8 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 5874c554b1..5aa0df4e92 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -33,11 +33,11 @@ #ifndef DRAW_VERTEX_H #define DRAW_VERTEX_H -#include "pipe/tgsi/exec/tgsi_attribs.h" +#if 0 #define MAX_VERT_ATTRIBS 12 /* OK? */ - +#endif struct draw_context; diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index 7d2712a537..13d7eac4f2 100755 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -34,7 +34,6 @@ #include "pipe/p_util.h" #include "pipe/p_defines.h" -#include "pipe/tgsi/exec/tgsi_attribs.h" #include "sp_context.h" #include "sp_headers.h" diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 3ae207910d..b51ab66cf3 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -33,7 +33,6 @@ #include "sp_context.h" #include "sp_state.h" -#include "pipe/tgsi/exec/tgsi_attribs.h" #include "pipe/tgsi/exec/tgsi_token.h" diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index fb8365aab5..2d5114a720 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -1,6 +1,5 @@ #include "tgsi_platform.h" #include "tgsi_mesa.h" -#include "pipe/tgsi/exec/tgsi_attribs.h" #include "pipe/tgsi/mesa/mesa_to_tgsi.h" #define TGSI_DEBUG 0 diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index e846463c4c..78cf4c2b4d 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -54,7 +54,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" -#include "pipe/tgsi/exec/tgsi_attribs.h" #include "vf/vf.h" #include "pipe/draw/draw_context.h" diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 04b2016ffc..56c98916ed 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -44,7 +44,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" -#include "pipe/tgsi/exec/tgsi_attribs.h" #include "shader/prog_instruction.h" #include "vf/vf.h" diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index e6f4175bf8..0f45bf579a 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -47,7 +47,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" -#include "pipe/tgsi/exec/tgsi_attribs.h" #include "pipe/draw/draw_private.h" #include "pipe/draw/draw_context.h" -- cgit v1.2.3 From da45890818ab5ae94592208e3581b5c2febaa6b4 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 21 Sep 2007 12:06:08 -0600 Subject: Fix up some point size breakage. Start on fogcoord too. --- src/mesa/pipe/softpipe/sp_prim_setup.c | 4 +- src/mesa/pipe/softpipe/sp_state_derived.c | 62 +++++++++++++++++++++---------- src/mesa/pipe/tgsi/exec/tgsi_token.h | 5 ++- src/mesa/state_tracker/st_atom_fs.c | 4 +- src/mesa/state_tracker/st_atom_vs.c | 10 +++++ src/mesa/state_tracker/st_cb_rasterpos.c | 3 ++ 6 files changed, 63 insertions(+), 25 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index f0f9cf54bd..6d63cc9412 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -907,15 +907,13 @@ setup_point(struct draw_stage *stage, struct prim_header *prim) const struct vertex_header *v0 = prim->v[0]; const int sizeAttr = setup->softpipe->psize_slot; const float halfSize - = sizeAttr ? (0.5f * v0->data[sizeAttr][0]) + = sizeAttr > 0 ? (0.5f * v0->data[sizeAttr][0]) : (0.5f * setup->softpipe->rasterizer->point_size); const boolean round = setup->softpipe->rasterizer->point_smooth; const float x = v0->data[0][0]; /* Note: data[0] is always position */ const float y = v0->data[0][1]; unsigned slot, j; - assert(sizeAttr >= 0); - /* For points, all interpolants are constant-valued. * However, for point sprites, we'll need to setup texcoords appropriately. * XXX: which coefficients are the texcoords??? diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 0e78209e30..35ba32cd81 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -43,6 +43,7 @@ */ static void calculate_vertex_layout( struct softpipe_context *softpipe ) { + const struct pipe_shader_state *vs = softpipe->vs; const struct pipe_shader_state *fs = softpipe->fs; const interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; @@ -58,47 +59,68 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) softpipe->need_z = FALSE; softpipe->need_w = FALSE; + 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->need_z = TRUE; + softpipe->need_w = TRUE; + } + softpipe->psize_slot = -1; /* always emit vertex pos */ - /* TODO - Figure out if we need to do perspective divide, etc. */ draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR); - for (i = 0; i < fs->num_inputs; i++) { - switch (fs->input_semantic_name[i]) { + /* + * XXX I think we need to reconcile the vertex shader outputs with + * the fragment shader inputs here to make sure the slots line up. + * Might just be getting lucky so far. + * Or maybe do that in the state tracker? + */ + + for (i = 0; i < vs->num_outputs; i++) { + switch (vs->output_semantic_name[i]) { + case TGSI_SEMANTIC_POSITION: - /* Need Z if depth test is enabled or the fragment program uses the - * fragment position (XYZW). + /* vertex programs always emit position, but might not be + * needed for fragment progs. */ - softpipe->need_z = TRUE; - softpipe->need_w = TRUE; + /* no-op */ break; + case TGSI_SEMANTIC_COLOR: if (fs->input_semantic_index[i] == 0) { - front0 = draw_emit_vertex_attr(vinfo, - FORMAT_4F, colorInterp); + front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp); + } + else { + assert(fs->input_semantic_index[i] == 1); + front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp); + } + break; + + case TGSI_SEMANTIC_BCOLOR: + if (fs->input_semantic_index[i] == 0) { + back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp); } else { assert(fs->input_semantic_index[i] == 1); - front1 = draw_emit_vertex_attr(vinfo, - FORMAT_4F, colorInterp); + back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp); } break; + case TGSI_SEMANTIC_FOG: - draw_emit_vertex_attr(vinfo, - FORMAT_1F, INTERP_PERSPECTIVE); + draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE); break; -#if 0 + case TGSI_SEMANTIC_PSIZE: /* XXX only emit if drawing points or front/back polygon mode * is point mode */ - draw_emit_vertex_attr(vinfo, - FORMAT_4F, INTERP_CONSTANT); - break; -#endif + draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT); softpipe->psize_slot = i; - /*case TGSI_SEMANTIC_TEXCOORD:*/ + break; + case TGSI_SEMANTIC_GENERIC: /* this includes texcoords and varying vars */ draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE); @@ -112,6 +134,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) softpipe->nr_frag_attrs = vinfo->num_attribs; +#if 0 /* Additional attributes required for setup: Just twosided * lighting. Edgeflag is dealt with specially by setting bits in * the vertex header. @@ -124,6 +147,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) back1 = draw_emit_vertex_attr(vinfo, FORMAT_OMIT, colorInterp); } } +#endif /* If the attributes have changed, tell the draw module about * the new vertex layout. diff --git a/src/mesa/pipe/tgsi/exec/tgsi_token.h b/src/mesa/pipe/tgsi/exec/tgsi_token.h index e6f884c5cf..1d99a50dde 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_token.h +++ b/src/mesa/pipe/tgsi/exec/tgsi_token.h @@ -107,8 +107,9 @@ struct tgsi_declaration_interpolation #define TGSI_SEMANTIC_COLOR 1 #define TGSI_SEMANTIC_BCOLOR 2 /**< back-face color */ #define TGSI_SEMANTIC_FOG 3 -#define TGSI_SEMANTIC_GENERIC 4 -#define TGSI_SEMANTIC_COUNT 5 /**< number of semantic values */ +#define TGSI_SEMANTIC_PSIZE 4 +#define TGSI_SEMANTIC_GENERIC 5 +#define TGSI_SEMANTIC_COUNT 6 /**< number of semantic values */ struct tgsi_declaration_semantic { diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index 1e7886a469..f8a1dc83cf 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -95,7 +95,9 @@ st_translate_fragment_shader(struct st_context *st, interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR; break; case FRAG_ATTRIB_FOGC: - assert(0); + fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_FOG; + fs.input_semantic_index[fs.num_inputs] = 0; + interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; break; case FRAG_ATTRIB_TEX0: case FRAG_ATTRIB_TEX1: diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index e4e9902e65..ae51e9764b 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -91,6 +91,10 @@ st_translate_vertex_shader(struct st_context *st, vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR; vs.input_semantic_index[vs.num_inputs] = 1; break; + case VERT_ATTRIB_FOG: + vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_FOG; + vs.input_semantic_index[vs.num_inputs] = 0; + break; case VERT_ATTRIB_TEX0: case VERT_ATTRIB_TEX1: case VERT_ATTRIB_TEX2: @@ -152,7 +156,13 @@ st_translate_vertex_shader(struct st_context *st, vs.output_semantic_index[vs.num_outputs] = 1; break; case VERT_RESULT_FOGC: + vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_FOG; + vs.output_semantic_index[vs.num_outputs] = 0; + break; case VERT_RESULT_PSIZ: + vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_PSIZE; + vs.output_semantic_index[vs.num_outputs] = 0; + break; case VERT_RESULT_EDGE: assert(0); break; diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 56c98916ed..2311bddc65 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -265,6 +265,9 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) float *buf_map; struct pipe_feedback_buffer fb_buf; + /** XXX TEMPORARILY DISABLE */ + return; + st_validate_state(ctx->st); /* setup vertex buffers */ -- cgit v1.2.3 From 40c543eb71368c646259afb87d5c76551f6b45b7 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 25 Sep 2007 14:29:11 -0600 Subject: Translate mesa vertex/fragment programs to TGSI programs at same time to do proper linking. Previously, programs were translated independently during validation. The problem is the translation to TGSI format, which packs shader input/outputs into continuous slots, depends on which vertex program is being paired with which fragment shader. Now, we look at the outputs of the vertex program in conjunction with the inputs of the fragment shader to be sure the attributes match up correctly. The new 'linked_program_pair' class keeps track of the associations between vertex and fragment shaders. It's also the place where the TGSI tokens are kept since they're no longer per-program state but per-linkage. Still a few loose ends, like implementing some kind of hash/lookup table for linked_program_pairs. --- src/mesa/pipe/draw/draw_feedback.c | 7 +- src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c | 4 + src/mesa/sources | 4 +- src/mesa/state_tracker/st_atom.c | 3 +- src/mesa/state_tracker/st_atom.h | 3 +- src/mesa/state_tracker/st_atom_fs.c | 96 +++++++++++------- src/mesa/state_tracker/st_atom_vs.c | 156 +++++++++++++++++++----------- src/mesa/state_tracker/st_cb_clear.c | 6 +- src/mesa/state_tracker/st_cb_drawpixels.c | 6 +- src/mesa/state_tracker/st_cb_feedback.c | 4 +- src/mesa/state_tracker/st_cb_program.c | 88 ++++++++++------- src/mesa/state_tracker/st_cb_rasterpos.c | 61 ++++++------ src/mesa/state_tracker/st_context.h | 6 +- src/mesa/state_tracker/st_program.h | 27 ++++-- 14 files changed, 287 insertions(+), 184 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/pipe/draw/draw_feedback.c b/src/mesa/pipe/draw/draw_feedback.c index 3b8400233e..ee54db0ad5 100644 --- a/src/mesa/pipe/draw/draw_feedback.c +++ b/src/mesa/pipe/draw/draw_feedback.c @@ -78,11 +78,9 @@ feedback_vertex(struct draw_stage *stage, const struct vertex_header *vertex) * we can either address output buffer 0 (for interleaving) or * output buffer i (for non-interleaved). */ -#if 0 for (i = 0; i < feedback->num_attribs; i++) { - const uint attr = feedback->attrib[i]; - const uint slot = stage->draw->vertex_info.attrib_to_slot[attr]; - const float *src = attr ? vertex->data[slot] : vertex->clip; + const uint slot = feedback->attrib[i]; + const float *src = slot ? vertex->data[slot] : vertex->clip; const uint size = feedback->size[i]; float *dest = fs->dest[i * select]; @@ -104,7 +102,6 @@ feedback_vertex(struct draw_stage *stage, const struct vertex_header *vertex) } fs->dest[i * select] += size; } -#endif fs->num_vert_emitted++; } diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index d0d97ab0f8..fa27fd3cd0 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -476,6 +476,8 @@ make_input_decl( { struct tgsi_full_declaration decl; + assert(semantic_name < TGSI_SEMANTIC_COUNT); + decl = tgsi_default_full_declaration(); decl.Declaration.File = TGSI_FILE_INPUT; decl.Declaration.Declare = TGSI_DECLARE_RANGE; @@ -500,6 +502,8 @@ make_output_decl( { struct tgsi_full_declaration decl; + assert(semantic_name < TGSI_SEMANTIC_COUNT); + decl = tgsi_default_full_declaration(); decl.Declaration.File = TGSI_FILE_OUTPUT; decl.Declaration.Declare = TGSI_DECLARE_RANGE; diff --git a/src/mesa/sources b/src/mesa/sources index 0d4fdc15f4..985bd2dce6 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -200,14 +200,13 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_depth.c \ state_tracker/st_atom_fixedfunction.c \ state_tracker/st_atom_framebuffer.c \ - state_tracker/st_atom_fs.c \ state_tracker/st_atom_sampler.c \ state_tracker/st_atom_scissor.c \ + state_tracker/st_atom_shader.c \ state_tracker/st_atom_rasterizer.c \ state_tracker/st_atom_stipple.c \ state_tracker/st_atom_texture.c \ state_tracker/st_atom_viewport.c \ - state_tracker/st_atom_vs.c \ state_tracker/st_cb_bufferobjects.c \ state_tracker/st_cb_clear.c \ state_tracker/st_cb_flush.c \ @@ -224,6 +223,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_context.c \ state_tracker/st_draw.c \ state_tracker/st_format.c \ + state_tracker/st_program.c \ state_tracker/st_mipmap_tree.c SHADER_SOURCES = \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index fc339b91ed..326042cb34 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -50,8 +50,7 @@ static const struct st_tracked_state *atoms[] = &st_update_clip, &st_update_tnl, - &st_update_vs, - &st_update_fs, + &st_update_shader, &st_update_rasterizer, &st_update_polygon_stipple, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 6710c1a269..94cb7bee7a 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -49,8 +49,7 @@ const struct st_tracked_state st_update_clip; const struct st_tracked_state st_update_clear_color; const struct st_tracked_state st_update_depth_stencil; const struct st_tracked_state st_update_tnl; -const struct st_tracked_state st_update_fs; -const struct st_tracked_state st_update_vs; +const struct st_tracked_state st_update_shader; const struct st_tracked_state st_update_rasterizer; const struct st_tracked_state st_update_polygon_stipple; const struct st_tracked_state st_update_viewport; diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index dd4cdf0855..28019858f7 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -24,11 +24,12 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ - /* - * Authors: - * Keith Whitwell - * Brian Paul - */ + +/* + * Authors: + * Keith Whitwell + * Brian Paul + */ #include "shader/prog_parameter.h" @@ -50,14 +51,20 @@ /** * Translate a Mesa fragment shader into a TGSI shader. + * \param inputMapping to map fragment program input registers to TGSI + * input slots + * \param tokensOut destination for TGSI tokens * \return pointer to cached pipe_shader object. */ const struct cso_fragment_shader * -st_translate_fragment_shader(struct st_context *st, - struct st_fragment_program *stfp) +st_translate_fragment_shader(const struct st_context *st, + struct st_fragment_program *stfp, + const GLuint inputMapping[], + struct tgsi_token *tokensOut, + GLuint maxTokens) { GLuint outputMapping[FRAG_RESULT_MAX]; - GLuint inputMapping[PIPE_MAX_SHADER_INPUTS]; + GLuint defaultInputMapping[FRAG_ATTRIB_MAX]; struct pipe_shader_state fs; const struct cso_fragment_shader *cso; GLuint interpMode[16]; /* XXX size? */ @@ -67,6 +74,7 @@ st_translate_fragment_shader(struct st_context *st, /* Check if all fragment programs need the fragment position (in order * to do perspective-corrected interpolation). */ + /* XXX temporary! */ if (st->pipe->get_param(st->pipe, PIPE_PARAM_FS_NEEDS_POS)) inputsRead |= FRAG_BIT_WPOS; @@ -77,28 +85,32 @@ st_translate_fragment_shader(struct st_context *st, */ for (attr = 0; attr < FRAG_ATTRIB_MAX; attr++) { if (inputsRead & (1 << attr)) { - inputMapping[attr] = fs.num_inputs; + const GLuint slot = fs.num_inputs; + + fs.num_inputs++; + + defaultInputMapping[attr] = slot; switch (attr) { case FRAG_ATTRIB_WPOS: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_POSITION; - fs.input_semantic_index[fs.num_inputs] = 0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_CONSTANT; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + fs.input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_CONSTANT; break; case FRAG_ATTRIB_COL0: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_COLOR; - fs.input_semantic_index[fs.num_inputs] = 0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + fs.input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_LINEAR; break; case FRAG_ATTRIB_COL1: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_COLOR; - fs.input_semantic_index[fs.num_inputs] = 1; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + fs.input_semantic_index[slot] = 1; + interpMode[slot] = TGSI_INTERPOLATE_LINEAR; break; case FRAG_ATTRIB_FOGC: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_FOG; - fs.input_semantic_index[fs.num_inputs] = 0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_FOG; + fs.input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; break; case FRAG_ATTRIB_TEX0: case FRAG_ATTRIB_TEX1: @@ -108,19 +120,17 @@ st_translate_fragment_shader(struct st_context *st, case FRAG_ATTRIB_TEX5: case FRAG_ATTRIB_TEX6: case FRAG_ATTRIB_TEX7: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_GENERIC; - fs.input_semantic_index[fs.num_inputs] = attr - FRAG_ATTRIB_TEX0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + fs.input_semantic_index[slot] = attr - FRAG_ATTRIB_TEX0; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; break; case FRAG_ATTRIB_VAR0: /* fall-through */ default: - fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_GENERIC; - fs.input_semantic_index[fs.num_inputs] = attr - FRAG_ATTRIB_VAR0; - interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE; + fs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + fs.input_semantic_index[slot] = attr - FRAG_ATTRIB_VAR0; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; } - - fs.num_inputs++; } } @@ -145,35 +155,40 @@ st_translate_fragment_shader(struct st_context *st, } } + if (!inputMapping) + inputMapping = defaultInputMapping; + /* XXX: fix static allocation of tokens: */ tgsi_mesa_compile_fp_program( &stfp->Base, + /* inputs */ fs.num_inputs, inputMapping, fs.input_semantic_name, fs.input_semantic_index, interpMode, + /* outputs */ outputMapping, - stfp->tokens, ST_FP_MAX_TOKENS ); + /* tokenized result */ + tokensOut, maxTokens); + - fs.tokens = &stfp->tokens[0]; + fs.tokens = tokensOut; cso = st_cached_fs_state(st, &fs); stfp->fs = cso; if (TGSI_DEBUG) - tgsi_dump( stfp->tokens, 0/*TGSI_DUMP_VERBOSE*/ ); + tgsi_dump( tokensOut, 0/*TGSI_DUMP_VERBOSE*/ ); #if defined(USE_X86_ASM) || defined(SLANG_X86) if (stfp->sse2_program.csr == stfp->sse2_program.store) - tgsi_emit_sse2_fs( stfp->tokens, &stfp->sse2_program ); + tgsi_emit_sse2_fs( tokensOut, &stfp->sse2_program ); if (!cso->state.executable) ((struct cso_fragment_shader*)cso)->state.executable = (void *) x86_get_func( &stfp->sse2_program ); #endif - stfp->dirty = 0; - return cso; } @@ -200,8 +215,9 @@ static void update_fs( struct st_context *st ) } /* if new binding, or shader has changed */ - if (st->fp != stfp || stfp->dirty) { + if (st->fp != stfp /**|| stfp->dirty**/) { +#if 0 if (stfp->dirty) (void) st_translate_fragment_shader( st, stfp ); @@ -210,10 +226,17 @@ static void update_fs( struct st_context *st ) st->state.fs = stfp->fs; st->pipe->bind_fs_state(st->pipe, st->state.fs->data); +#else + + /* NEW */ + st->dirty.st |= ST_NEW_LINKAGE; + +#endif } } +#if 0 const struct st_tracked_state st_update_fs = { .name = "st_update_fs", .dirty = { @@ -222,3 +245,4 @@ const struct st_tracked_state st_update_fs = { }, .update = update_fs }; +#endif diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index a6c0d159d4..0f07906a96 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -51,15 +51,22 @@ /** * Translate a Mesa vertex shader into a TGSI shader. + * \param outputMapping to map vertex program output registers to TGSI + * output slots + * \param tokensOut destination for TGSI tokens * \return pointer to cached pipe_shader object. */ const struct cso_vertex_shader * -st_translate_vertex_shader(struct st_context *st, - struct st_vertex_program *stvp) +st_translate_vertex_shader(const struct st_context *st, + struct st_vertex_program *stvp, + const GLuint outputMapping[], + struct tgsi_token *tokensOut, + GLuint maxTokens) { + GLuint defaultOutputMapping[VERT_RESULT_MAX]; struct pipe_shader_state vs; const struct cso_vertex_shader *cso; - GLuint attr; + GLuint attr, i; memset(&vs, 0, sizeof(vs)); @@ -69,31 +76,36 @@ st_translate_vertex_shader(struct st_context *st, */ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { if (stvp->Base.Base.InputsRead & (1 << attr)) { - stvp->input_to_index[attr] = vs.num_inputs; - stvp->index_to_input[vs.num_inputs] = attr; + const GLuint slot = vs.num_inputs; + + vs.num_inputs++; + + stvp->input_to_index[attr] = slot; + stvp->index_to_input[slot] = attr; + switch (attr) { case VERT_ATTRIB_POS: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_POSITION; - vs.input_semantic_index[vs.num_inputs] = 0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + vs.input_semantic_index[slot] = 0; break; case VERT_ATTRIB_WEIGHT: /* fall-through */ case VERT_ATTRIB_NORMAL: /* just label as a generic */ - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC; - vs.input_semantic_index[vs.num_inputs] = 0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.input_semantic_index[slot] = 0; break; case VERT_ATTRIB_COLOR0: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR; - vs.input_semantic_index[vs.num_inputs] = 0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs.input_semantic_index[slot] = 0; break; case VERT_ATTRIB_COLOR1: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR; - vs.input_semantic_index[vs.num_inputs] = 1; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs.input_semantic_index[slot] = 1; break; case VERT_ATTRIB_FOG: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_FOG; - vs.input_semantic_index[vs.num_inputs] = 0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_FOG; + vs.input_semantic_index[slot] = 0; break; case VERT_ATTRIB_TEX0: case VERT_ATTRIB_TEX1: @@ -103,8 +115,8 @@ st_translate_vertex_shader(struct st_context *st, case VERT_ATTRIB_TEX5: case VERT_ATTRIB_TEX6: case VERT_ATTRIB_TEX7: - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC; - vs.input_semantic_index[vs.num_inputs] = attr - VERT_ATTRIB_TEX0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.input_semantic_index[slot] = attr - VERT_ATTRIB_TEX0; break; case VERT_ATTRIB_GENERIC0: case VERT_ATTRIB_GENERIC1: @@ -115,53 +127,71 @@ st_translate_vertex_shader(struct st_context *st, case VERT_ATTRIB_GENERIC6: case VERT_ATTRIB_GENERIC7: assert(attr < VERT_ATTRIB_MAX); - vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_GENERIC; - vs.input_semantic_index[vs.num_inputs] = attr - VERT_ATTRIB_GENERIC0; + vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.input_semantic_index[slot] = attr - VERT_ATTRIB_GENERIC0; break; default: assert(0); } - vs.num_inputs++; } } + /* initialize output semantics to defaults */ + for (i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) { + vs.output_semantic_name[i] = TGSI_SEMANTIC_GENERIC; + vs.output_semantic_index[i] = 0; + } + /* - * Determine number of outputs, the register mapping and - * the semantic information for each vertex output/result. + * Determine number of outputs, the (default) output register + * mapping and the semantic information for each output. */ for (attr = 0; attr < VERT_RESULT_MAX; attr++) { if (stvp->Base.Base.OutputsWritten & (1 << attr)) { - /* put this attrib in the next available slot */ - st->vertex_attrib_to_slot[attr] = vs.num_outputs; + GLuint slot; + + if (outputMapping) { + slot = outputMapping[attr]; + assert(slot != ~0); + } + else { + slot = vs.num_outputs; + vs.num_outputs++; + defaultOutputMapping[attr] = slot; + } + + /* + printf("Output %u -> slot %u\n", attr, slot); + */ switch (attr) { case VERT_RESULT_HPOS: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_POSITION; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_COL0: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_COLOR; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_COL1: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_COLOR; - vs.output_semantic_index[vs.num_outputs] = 1; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs.output_semantic_index[slot] = 1; break; case VERT_RESULT_BFC0: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_BCOLOR; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_BFC1: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_BCOLOR; - vs.output_semantic_index[vs.num_outputs] = 1; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR; + vs.output_semantic_index[slot] = 1; break; case VERT_RESULT_FOGC: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_FOG; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_FOG; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_PSIZ: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_PSIZE; - vs.output_semantic_index[vs.num_outputs] = 0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE; + vs.output_semantic_index[slot] = 0; break; case VERT_RESULT_EDGE: assert(0); @@ -174,46 +204,59 @@ st_translate_vertex_shader(struct st_context *st, case VERT_RESULT_TEX5: case VERT_RESULT_TEX6: case VERT_RESULT_TEX7: - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_GENERIC; - vs.output_semantic_index[vs.num_outputs] = attr - VERT_RESULT_TEX0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.output_semantic_index[slot] = attr - VERT_RESULT_TEX0; break; case VERT_RESULT_VAR0: /* fall-through */ default: assert(attr - VERT_RESULT_VAR0 < MAX_VARYING); - vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_GENERIC; - vs.output_semantic_index[vs.num_outputs] = attr - VERT_RESULT_VAR0; + vs.output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs.output_semantic_index[slot] = attr - VERT_RESULT_VAR0; } - - vs.num_outputs++; } } + if (outputMapping) { + /* find max output slot referenced to compute vs.num_outputs */ + GLuint maxSlot = 0; + for (attr = 0; attr < VERT_RESULT_MAX; attr++) { + if (outputMapping[attr] != ~0 && outputMapping[attr] > maxSlot) + maxSlot = outputMapping[attr]; + } + vs.num_outputs = maxSlot + 1; + } + else { + outputMapping = defaultOutputMapping; + } + /* XXX: fix static allocation of tokens: */ tgsi_mesa_compile_vp_program( &stvp->Base, + /* inputs */ vs.num_inputs, stvp->input_to_index, vs.input_semantic_name, vs.input_semantic_index, + /* outputs */ vs.num_outputs, - st->vertex_attrib_to_slot, + outputMapping, vs.output_semantic_name, vs.output_semantic_index, - stvp->tokens, ST_FP_MAX_TOKENS ); - - vs.tokens = &stvp->tokens[0]; + /* tokenized result */ + tokensOut, maxTokens); + vs.tokens = tokensOut; cso = st_cached_vs_state(st, &vs); stvp->vs = cso; if (TGSI_DEBUG) - tgsi_dump( stvp->tokens, 0 ); + tgsi_dump( tokensOut, 0 ); #if defined(USE_X86_ASM) || defined(SLANG_X86) if (stvp->sse2_program.csr == stvp->sse2_program.store) - tgsi_emit_sse2( stvp->tokens, &stvp->sse2_program ); + tgsi_emit_sse2( tokensOut, &stvp->sse2_program ); if (!cso->state.executable) ((struct cso_vertex_shader*)cso)->state.executable = (void *) x86_get_func( &stvp->sse2_program ); @@ -246,6 +289,7 @@ static void update_vs( struct st_context *st ) } if (st->vp != stvp || stvp->dirty) { +#if 0 if (stvp->dirty) (void) st_translate_vertex_shader( st, stvp ); @@ -260,10 +304,15 @@ static void update_vs( struct st_context *st ) tgsi_dump( stvp->tokens, 0 ); #endif st->pipe->bind_vs_state(st->pipe, st->state.vs->data); +#else + /* NEW */ + st->dirty.st |= ST_NEW_LINKAGE; + +#endif } } - +#if 0 const struct st_tracked_state st_update_vs = { .name = "st_update_vs", .dirty = { @@ -272,7 +321,4 @@ const struct st_tracked_state st_update_vs = { }, .update = update_vs }; - - - - +#endif diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 639e0ceb40..367ae06cf3 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -155,7 +155,8 @@ make_frag_shader(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR); stfp = (struct st_fragment_program *) p; - st_translate_fragment_shader(st, stfp); + st_translate_fragment_program(st, stfp, NULL, + stfp->tokens, ST_FP_MAX_TOKENS); return stfp; } @@ -203,7 +204,8 @@ make_vertex_shader(struct st_context *st) (1 << VERT_RESULT_HPOS)); stvp = (struct st_vertex_program *) p; - st_translate_vertex_shader(st, stvp); + st_translate_vertex_program(st, stvp, NULL, + stvp->tokens, ST_FP_MAX_TOKENS); assert(stvp->vs); return stvp; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 65c5465546..619c5d8ab7 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -92,7 +92,8 @@ make_fragment_shader(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR); stfp = (struct st_fragment_program *) p; - st_translate_fragment_shader(st, stfp); + st_translate_fragment_program(st, stfp, NULL, + stfp->tokens, ST_FP_MAX_TOKENS); return stfp; } @@ -141,7 +142,8 @@ make_vertex_shader(struct st_context *st) (1 << VERT_RESULT_HPOS)); stvp = (struct st_vertex_program *) p; - st_translate_vertex_shader(st, stvp); + st_translate_vertex_program(st, stvp, NULL, + stvp->tokens, ST_FP_MAX_TOKENS); return stvp; } diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 78cf4c2b4d..537a58f39d 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -102,13 +102,13 @@ feedback_vertex(GLcontext *ctx, const struct draw_context *draw, * color and texcoord attribs to use here. */ - slot = st->vertex_attrib_to_slot[VERT_RESULT_COL0]; + slot = st->vertex_result_to_slot[VERT_RESULT_COL0]; if (slot) color = v->data[slot]; else color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - slot = st->vertex_attrib_to_slot[VERT_RESULT_TEX0]; + slot = st->vertex_result_to_slot[VERT_RESULT_TEX0]; if (slot) texcoord = v->data[slot]; else diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 9f46f9e93f..aee316df6f 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -30,24 +30,26 @@ * Keith Whitwell */ +#include "main/glheader.h" +#include "main/macros.h" +#include "main/enums.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/program.h" +#include "shader/programopt.h" + #include "st_context.h" -#include "st_program.h" -#include "glheader.h" -#include "macros.h" -#include "enums.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "program.h" -#include "programopt.h" +#include "st_program.h" +#include "st_atom_shader.h" + #include "tnl/tnl.h" #include "pipe/tgsi/mesa/tgsi_mesa.h" -/* Counter to track program string changes: +/** + * Called via ctx->Driver.BindProgram() to bind an ARB vertex or + * fragment program. */ -static GLuint program_id = 0; - - static void st_bind_program( GLcontext *ctx, GLenum target, struct gl_program *prog ) @@ -62,8 +64,14 @@ static void st_bind_program( GLcontext *ctx, st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; break; } + st->dirty.st |= ST_NEW_LINKAGE; } + +/** + * Called via ctx->Driver.UseProgram() to bind a linked GLSL program + * (vertex shader + fragment shader). + */ static void st_use_program( GLcontext *ctx, GLuint program ) { @@ -71,6 +79,7 @@ static void st_use_program( GLcontext *ctx, st->dirty.st |= ST_NEW_VERTEX_PROGRAM; st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; + st->dirty.st |= ST_NEW_LINKAGE; } @@ -79,14 +88,13 @@ static struct gl_program *st_new_program( GLcontext *ctx, GLenum target, GLuint id ) { -// struct st_context *st = st_context(ctx); + struct st_context *st = st_context(ctx); switch (target) { case GL_VERTEX_PROGRAM_ARB: { struct st_vertex_program *prog = CALLOC_STRUCT(st_vertex_program); - prog->id = program_id++; - prog->dirty = 1; + prog->serialNo = 1; #if defined(USE_X86_ASM) || defined(SLANG_X86) x86_init_func( &prog->sse2_program ); @@ -102,8 +110,7 @@ static struct gl_program *st_new_program( GLcontext *ctx, case GL_FRAGMENT_PROGRAM_NV: { struct st_fragment_program *prog = CALLOC_STRUCT(st_fragment_program); - prog->id = program_id++; - prog->dirty = 1; + prog->serialNo = 1; #if defined(USE_X86_ASM) || defined(SLANG_X86) x86_init_func( &prog->sse2_program ); @@ -118,29 +125,40 @@ static struct gl_program *st_new_program( GLcontext *ctx, default: return _mesa_new_program(ctx, target, id); } + + st->dirty.st |= ST_NEW_LINKAGE; } + static void st_delete_program( GLcontext *ctx, struct gl_program *prog ) { + struct st_context *st = st_context(ctx); + switch( prog->Target ) { - case GL_VERTEX_PROGRAM_ARB: { + case GL_VERTEX_PROGRAM_ARB: + { + struct st_vertex_program *stvp = (struct st_vertex_program *) prog; #if defined(USE_X86_ASM) || defined(SLANG_X86) - struct st_vertex_program *p = (struct st_vertex_program *) prog; - - x86_release_func( &p->sse2_program ); + x86_release_func( &stvp->sse2_program ); #endif + st_remove_vertex_program(st, stvp); + } break; - } - case GL_FRAGMENT_PROGRAM_ARB: { + case GL_FRAGMENT_PROGRAM_ARB: + { + struct st_fragment_program *stfp + = (struct st_fragment_program *) prog; #if defined(USE_X86_ASM) || defined(SLANG_X86) - struct st_fragment_program *p = (struct st_fragment_program *) prog; - - x86_release_func( &p->sse2_program ); + x86_release_func( &stfp->sse2_program ); #endif + st_remove_fragment_program(st, stfp); + } break; + default: + assert(0); /* problem */ } - } + _mesa_delete_program( ctx, prog ); } @@ -160,27 +178,31 @@ static void st_program_string_notify( GLcontext *ctx, struct st_context *st = st_context(ctx); if (target == GL_FRAGMENT_PROGRAM_ARB) { - struct st_fragment_program *p = (struct st_fragment_program *)prog; + struct st_fragment_program *stfp = (struct st_fragment_program *) prog; if (prog == &ctx->FragmentProgram._Current->Base) st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM; - p->id = program_id++; - p->param_state = p->Base.Base.Parameters->StateFlags; + stfp->serialNo++; + + stfp->param_state = stfp->Base.Base.Parameters->StateFlags; } else if (target == GL_VERTEX_PROGRAM_ARB) { - struct st_vertex_program *p = (struct st_vertex_program *)prog; + struct st_vertex_program *stvp = (struct st_vertex_program *) prog; if (prog == &ctx->VertexProgram._Current->Base) st->dirty.st |= ST_NEW_VERTEX_PROGRAM; - p->id = program_id++; - p->param_state = p->Base.Base.Parameters->StateFlags; + stvp->serialNo++; + + stvp->param_state = stvp->Base.Base.Parameters->StateFlags; /* Also tell tnl about it: */ _tnl_program_string(ctx, target, prog); } + + st->dirty.st |= ST_NEW_LINKAGE; } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 2311bddc65..661d155e6d 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -53,9 +53,9 @@ static void setup_vertex_attribs(GLcontext *ctx) { struct pipe_context *pipe = ctx->st->pipe; -#if 0 - const uint inputAttrs = ctx->st->state.vs->inputs_read; - uint attr; + const struct cso_vertex_shader *vs = ctx->st->state.vs; + const struct st_vertex_program *stvp = ctx->st->vp; + uint slot; /* all attributes come from the default attribute buffer */ { @@ -67,20 +67,16 @@ setup_vertex_attribs(GLcontext *ctx) pipe->set_vertex_buffer(pipe, 0, &vbuffer); } - for (attr = 0; attr < 16; attr++) { + for (slot = 0; slot < vs->state.num_inputs; slot++) { struct pipe_vertex_element velement; + const GLuint attr = stvp->index_to_input[slot]; - if (inputAttrs & (1 << attr)) { - velement.src_offset = attr * 4 * sizeof(GLfloat); - velement.vertex_buffer_index = 0; - velement.dst_offset = 0; - velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - pipe->set_vertex_element(pipe, attr, &velement); - } + velement.src_offset = attr * 4 * sizeof(GLfloat); + velement.vertex_buffer_index = 0; + velement.dst_offset = 0; + velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + pipe->set_vertex_element(pipe, slot, &velement); } -#else - assert(0); -#endif } @@ -98,12 +94,11 @@ setup_feedback(GLcontext *ctx) feedback.discard = 1; feedback.num_attribs = 0; + /* feedback all results from vertex shader */ for (i = 0; i < vs->num_outputs; i++) { - if (1/***(1 << i) & outputAttrs***/) { - feedback.attrib[feedback.num_attribs] = i; - feedback.size[feedback.num_attribs] = 4; - feedback.num_attribs++; - } + feedback.attrib[feedback.num_attribs] = i; + feedback.size[feedback.num_attribs] = 4; + feedback.num_attribs++; } pipe->set_feedback_state(pipe, &feedback); @@ -261,13 +256,11 @@ update_rasterpos(GLcontext *ctx, static void st_RasterPos(GLcontext *ctx, const GLfloat v[4]) { - struct pipe_context *pipe = ctx->st->pipe; + const struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; float *buf_map; struct pipe_feedback_buffer fb_buf; - /** XXX TEMPORARILY DISABLE */ - return; - st_validate_state(ctx->st); /* setup vertex buffers */ @@ -277,7 +270,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) * Load the default attribute buffer with current attribs. */ { - struct pipe_buffer_handle *buf = ctx->st->default_attrib_buffer; + struct pipe_buffer_handle *buf = st->default_attrib_buffer; const unsigned size = sizeof(ctx->Current.Attrib); const void *data = ctx->Current.Attrib; /* colors, texcoords, etc */ @@ -313,17 +306,16 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) PIPE_BUFFER_FLAG_READ); /* extract values and update rasterpos state */ -#if 0 /* XXX update */ { - const uint outputAttrs = ctx->st->state.vs->outputs_written; + const GLuint *outputMapping = st->vertex_result_to_slot; const float *pos, *color0, *color1, *tex0; float *buf = buf_map; - assert(outputAttrs & (1 << TGSI_ATTRIB_POS)); + assert(outputMapping[VERT_RESULT_HPOS] != ~0); pos = buf; buf += 4; - if (outputAttrs & (1 << TGSI_ATTRIB_COLOR0)) { + if (outputMapping[VERT_RESULT_COL0] != ~0) { color0 = buf; buf += 4; } @@ -331,7 +323,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) color0 = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; } - if (outputAttrs & (1 << TGSI_ATTRIB_COLOR1)) { + if (outputMapping[VERT_RESULT_COL1] != ~0) { color1 = buf; buf += 4; } @@ -339,16 +331,23 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) color1 = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; } + if (outputMapping[VERT_RESULT_TEX0] != ~0) { + tex0 = buf; + buf += 4; + } + else { + tex0 = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + } + update_rasterpos(ctx, pos, color0, color1, tex0); } -#endif /* free vertex feedback buffer */ pipe->winsys->buffer_unmap(pipe->winsys, fb_buf.buffer); pipe->winsys->buffer_reference(pipe->winsys, &fb_buf.buffer, NULL); /* restore pipe state */ - pipe->set_feedback_state(pipe, &ctx->st->state.feedback); + pipe->set_feedback_state(pipe, &st->state.feedback); } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 3713328eb1..24f0ff9aaf 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -45,6 +45,8 @@ struct cso_blend; #define ST_NEW_MESA 0x1 /* Mesa state has changed */ #define ST_NEW_FRAGMENT_PROGRAM 0x2 #define ST_NEW_VERTEX_PROGRAM 0x4 +#define ST_NEW_LINKAGE 0x8 + struct st_state_flags { GLuint mesa; @@ -119,8 +121,8 @@ struct st_context GLfloat polygon_offset_scale; /* ?? */ - /** Mapping from VERT_ATTRIB_x to post-transformed vertex slot */ - GLuint vertex_attrib_to_slot[VERT_RESULT_MAX]; + /** Mapping from VERT_RESULT_x to post-transformed vertex slot */ + const GLuint *vertex_result_to_slot; struct st_vertex_program *vp; /**< Currently bound vertex program */ struct st_fragment_program *fp; /**< Currently bound fragment program */ diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 419afa4e78..355dee574b 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -47,11 +47,11 @@ struct st_fragment_program { struct gl_fragment_program Base; GLboolean error; /* If program is malformed for any reason. */ - GLuint id; /**< String id, for tracking ProgramStringNotify changes. */ + + GLuint serialNo; /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; - GLboolean dirty; #if defined(USE_X86_ASM) || defined(SLANG_X86) struct x86_function sse2_program; @@ -68,7 +68,8 @@ struct st_vertex_program { struct gl_vertex_program Base; /**< The Mesa vertex program */ GLboolean error; /**< Set if program is malformed for any reason. */ - GLuint id; /**< String id, for tracking ProgramStringNotify changes. */ + + GLuint serialNo; /** maps a Mesa VERT_ATTRIB_x to a packed TGSI input index */ GLuint input_to_index[MAX_VERTEX_PROGRAM_ATTRIBS]; @@ -77,7 +78,6 @@ struct st_vertex_program /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; - GLboolean dirty; #if defined(USE_X86_ASM) || defined(SLANG_X86) struct x86_function sse2_program; @@ -90,7 +90,8 @@ struct st_vertex_program }; -extern void st_init_program_functions(struct dd_function_table *functions); +extern void +st_init_program_functions(struct dd_function_table *functions); static inline struct st_fragment_program * @@ -99,6 +100,7 @@ st_fragment_program( struct gl_fragment_program *fp ) return (struct st_fragment_program *)fp; } + static inline struct st_vertex_program * st_vertex_program( struct gl_vertex_program *vp ) { @@ -107,13 +109,18 @@ st_vertex_program( struct gl_vertex_program *vp ) extern const struct cso_fragment_shader * -st_translate_fragment_shader(struct st_context *st, - struct st_fragment_program *fp); +st_translate_fragment_program(struct st_context *st, + struct st_fragment_program *fp, + const GLuint inputMapping[], + struct tgsi_token *tokens, + GLuint maxTokens); extern const struct cso_vertex_shader * -st_translate_vertex_shader(struct st_context *st, - struct st_vertex_program *vp); - +st_translate_vertex_program(struct st_context *st, + struct st_vertex_program *vp, + const GLuint vert_output_to_slot[], + struct tgsi_token *tokens, + GLuint maxTokens); #endif -- cgit v1.2.3 From a24031d50c6b4c584aae08316dc3c00e18e24b58 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 1 Oct 2007 13:55:16 -0600 Subject: don't crash in RasterPos if feedback not implemented yet --- src/mesa/state_tracker/st_cb_rasterpos.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 661d155e6d..13580e400b 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -101,7 +101,8 @@ setup_feedback(GLcontext *ctx) feedback.num_attribs++; } - pipe->set_feedback_state(pipe, &feedback); + if (pipe->set_feedback_state) + pipe->set_feedback_state(pipe, &feedback); } @@ -294,7 +295,8 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) pipe->winsys->buffer_data(pipe->winsys, fb_buf.buffer, fb_buf.size, NULL); /* data */ - pipe->set_feedback_buffer(pipe, 0, &fb_buf); + if (pipe->set_feedback_buffer) + pipe->set_feedback_buffer(pipe, 0, &fb_buf); } @@ -347,7 +349,8 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) pipe->winsys->buffer_reference(pipe->winsys, &fb_buf.buffer, NULL); /* restore pipe state */ - pipe->set_feedback_state(pipe, &st->state.feedback); + if (pipe->set_feedback_state) + pipe->set_feedback_state(pipe, &st->state.feedback); } -- cgit v1.2.3 From 38743e2ef1091304a7059c04c157fde80bd977ec Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 17 Oct 2007 12:32:21 -0600 Subject: generate selection hit if in selection mode and pos is not clipped --- src/mesa/state_tracker/st_cb_rasterpos.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 13580e400b..653801001a 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -31,6 +31,7 @@ */ #include "main/imports.h" +#include "main/feedback.h" #include "main/macros.h" #include "st_context.h" @@ -250,6 +251,10 @@ update_rasterpos(GLcontext *ctx, } ctx->Current.RasterPosValid = GL_TRUE; + + if (ctx->RenderMode == GL_SELECT) { + _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); + } } -- cgit v1.2.3 From f953c223df26293f955f7d0621a6f917e9cc9768 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 17 Oct 2007 16:23:25 -0600 Subject: remove #include vf.h --- src/mesa/state_tracker/st_cb_clear.c | 2 -- src/mesa/state_tracker/st_cb_drawpixels.c | 1 - src/mesa/state_tracker/st_cb_feedback.c | 1 - src/mesa/state_tracker/st_cb_rasterpos.c | 1 - 4 files changed, 5 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index c0ea1a4bf6..2e7d9f1a30 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -51,8 +51,6 @@ #include "pipe/tgsi/mesa/mesa_to_tgsi.h" -#include "vf/vf.h" - diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 9031ef46df..bb8a083883 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -47,7 +47,6 @@ #include "pipe/p_defines.h" #include "pipe/tgsi/mesa/mesa_to_tgsi.h" #include "shader/prog_instruction.h" -#include "vf/vf.h" diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 923e1cdb89..a9fd2579a2 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -55,7 +55,6 @@ #include "pipe/p_defines.h" #include "pipe/p_winsys.h" #include "pipe/cso_cache/cso_cache.h" -#include "vf/vf.h" #include "pipe/draw/draw_context.h" #include "pipe/draw/draw_private.h" diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 653801001a..eb6ee51939 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -46,7 +46,6 @@ #include "pipe/p_defines.h" #include "pipe/p_winsys.h" #include "shader/prog_instruction.h" -#include "vf/vf.h" -- cgit v1.2.3 From 5bd119f9438b680f5e42458ef0b250662af36235 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 18 Oct 2007 10:42:47 -0600 Subject: handle fogcoord/raster distance --- src/mesa/state_tracker/st_cb_rasterpos.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index eb6ee51939..40807fc05a 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -187,6 +187,7 @@ update_rasterpos(GLcontext *ctx, const float clipPos[4], const float color0[4], const float color1[4], + const float *fog, const float *tex) { uint i; @@ -232,15 +233,17 @@ update_rasterpos(GLcontext *ctx, ctx->Current.RasterPos[3] = clipPos[3]; /* compute raster distance */ +#if 0 if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; else { -#if 0 /* XXX we don't have an eye coord! */ ctx->Current.RasterDistance = SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] ); -#endif } +#else + ctx->Current.RasterDistance = fog[0]; +#endif /* colors and texcoords */ COPY_4FV(ctx->Current.RasterColor, color0); @@ -314,7 +317,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) /* extract values and update rasterpos state */ { const GLuint *outputMapping = st->vertex_result_to_slot; - const float *pos, *color0, *color1, *tex0; + const float *pos, *color0, *color1, *fog, *tex0; float *buf = buf_map; assert(outputMapping[VERT_RESULT_HPOS] != ~0); @@ -337,6 +340,14 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) color1 = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; } + if (outputMapping[VERT_RESULT_FOGC] != ~0) { + fog = buf; + buf += 4; + } + else { + fog = ctx->Current.Attrib[VERT_ATTRIB_FOG]; + } + if (outputMapping[VERT_RESULT_TEX0] != ~0) { tex0 = buf; buf += 4; @@ -345,7 +356,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) tex0 = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; } - update_rasterpos(ctx, pos, color0, color1, tex0); + update_rasterpos(ctx, pos, color0, color1, fog, tex0); } /* free vertex feedback buffer */ -- cgit v1.2.3 From fa1a66d7fc4fd7854de7958a48e4992edd154489 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 5 Nov 2007 18:04:35 +0000 Subject: Supply buffer usage hints to winsys. Winsys driver needs some hints in order to allocate the appropriate kind of memory for the buffer. --- .../drivers/dri/intel_winsys/intel_winsys_pipe.c | 6 ++++-- src/mesa/drivers/x11/xm_winsys.c | 5 +++-- src/mesa/pipe/i915simple/i915_prim_vbuf.c | 4 +++- src/mesa/pipe/p_defines.h | 14 +++++++++----- src/mesa/pipe/p_winsys.h | 11 +++++++++-- src/mesa/pipe/xlib/xm_winsys.c | 5 +++-- src/mesa/state_tracker/st_atom_constbuf.c | 3 ++- src/mesa/state_tracker/st_cb_bufferobjects.c | 20 +++++++++++++++++++- src/mesa/state_tracker/st_cb_rasterpos.c | 7 +++++-- src/mesa/state_tracker/st_draw.c | 4 +++- 10 files changed, 60 insertions(+), 19 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c index af05a3398c..cc76a40a5a 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c @@ -107,7 +107,8 @@ intel_buffer_reference(struct pipe_winsys *sws, */ static void intel_buffer_data(struct pipe_winsys *sws, struct pipe_buffer_handle *buf, - unsigned size, const void *data ) + unsigned size, const void *data, + unsigned usage ) { struct intel_context *intel = intel_pipe_winsys(sws)->intel; @@ -229,7 +230,8 @@ intel_i915_region_alloc(struct pipe_winsys *winsys, winsys->buffer_data( winsys, region->buffer, pitch * cpp * height, - NULL ); + NULL, + PIPE_BUFFER_USAGE_PIXEL ); return region; } diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c index 36805437f0..f863cdbc15 100644 --- a/src/mesa/drivers/x11/xm_winsys.c +++ b/src/mesa/drivers/x11/xm_winsys.c @@ -140,7 +140,7 @@ xm_buffer_reference(struct pipe_winsys *pws, static void xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, - unsigned size, const void *data ) + unsigned size, const void *data, unsigned usage) { struct xm_buffer *xm_buf = xm_bo(buf); assert(!xm_buf->userBuffer); @@ -265,7 +265,8 @@ xm_region_alloc(struct pipe_winsys *winsys, winsys->buffer_data( winsys, region->buffer, region->pitch * cpp * height, - NULL ); + NULL, + PIPE_BUFFER_USAGE_PIXEL ); return region; } diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c index 3632adce79..75ca6d6e5e 100644 --- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c +++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c @@ -376,7 +376,9 @@ static void vbuf_flush_elements( struct draw_stage *stage ) /* FIXME: handle failure */ if(!vbuf->buf) vbuf->buf = winsys->buffer_create(winsys, 64); - winsys->buffer_data(winsys, vbuf->buf, VBUF_SIZE, NULL); + winsys->buffer_data( winsys, vbuf->buf, + VBUF_SIZE, NULL, + PIPE_BUFFER_USAGE_VERTEX ); vbuf->vertex_map = winsys->buffer_map(winsys, vbuf->buf, PIPE_BUFFER_FLAG_WRITE ); diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index ef79716ed9..119ea1bd77 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -168,15 +168,19 @@ /** - * Buffer flags + * Buffer access flags */ #define PIPE_BUFFER_FLAG_READ 0x1 #define PIPE_BUFFER_FLAG_WRITE 0x2 -#define PIPE_BUFFER_USE_TEXTURE 0x1 -#define PIPE_BUFFER_USE_VERTEX_BUFFER 0x2 -#define PIPE_BUFFER_USE_INDEX_BUFFER 0x4 -#define PIPE_BUFFER_USE_RENDER_TARGET 0x8 + +/** + * Buffer usage flags + */ +#define PIPE_BUFFER_USAGE_PIXEL 0x1 +#define PIPE_BUFFER_USAGE_VERTEX 0x2 +#define PIPE_BUFFER_USAGE_INDEX 0x4 +#define PIPE_BUFFER_USAGE_CONSTANT 0x8 /** diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index 2d4432dbca..298b555651 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -116,10 +116,17 @@ struct pipe_winsys struct pipe_buffer_handle **ptr, struct pipe_buffer_handle *buf ); - /** Create the data store of a buffer and optionally initialize it */ + /** + * Create the data store of a buffer and optionally initialize it. + * + * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This + * usage argument is only an optimization hint, not a guarantee, therefore + * proper behavior must be observed in all circumstances. + */ void (*buffer_data)(struct pipe_winsys *sws, struct pipe_buffer_handle *buf, - unsigned size, const void *data ); + unsigned size, const void *data, + unsigned usage); /** Modify some or all of the data contained in a buffer's data store */ void (*buffer_subdata)(struct pipe_winsys *sws, diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c index 5de811a66f..45ece8ef55 100644 --- a/src/mesa/pipe/xlib/xm_winsys.c +++ b/src/mesa/pipe/xlib/xm_winsys.c @@ -120,7 +120,7 @@ xm_buffer_reference(struct pipe_winsys *pws, static void xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, - unsigned size, const void *data ) + unsigned size, const void *data, unsigned usage ) { struct xm_buffer *xm_buf = xm_bo(buf); assert(!xm_buf->userBuffer); @@ -245,7 +245,8 @@ xm_region_alloc(struct pipe_winsys *winsys, winsys->buffer_data( winsys, region->buffer, region->pitch * cpp * height, - NULL ); + NULL, + PIPE_BUFFER_USAGE_PIXEL ); return region; } diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 7da7136676..446250c226 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -80,7 +80,8 @@ void st_upload_constants( struct st_context *st, } /* load Mesa constants into the constant buffer */ - ws->buffer_data(ws, cbuf->buffer, paramBytes, params->ParameterValues); + ws->buffer_data(ws, cbuf->buffer, paramBytes, params->ParameterValues, + PIPE_BUFFER_USAGE_CONSTANT); cbuf->size = paramBytes; diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index a593bd74d1..99e1eb3c7a 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -104,11 +104,29 @@ st_bufferobj_data(GLcontext *ctx, { struct pipe_context *pipe = st_context(ctx)->pipe; struct st_buffer_object *st_obj = st_buffer_object(obj); + unsigned buffer_usage; st_obj->Base.Size = size; st_obj->Base.Usage = usage; + + switch(target) { + case GL_PIXEL_PACK_BUFFER_ARB: + case GL_PIXEL_UNPACK_BUFFER_ARB: + buffer_usage = PIPE_BUFFER_USAGE_PIXEL; + break; + case GL_ARRAY_BUFFER_ARB: + buffer_usage = PIPE_BUFFER_USAGE_VERTEX; + break; + case GL_ELEMENT_ARRAY_BUFFER_ARB: + buffer_usage = PIPE_BUFFER_USAGE_INDEX; + break; + default: + buffer_usage = 0; + } - pipe->winsys->buffer_data( pipe->winsys, st_obj->buffer, size, data ); + pipe->winsys->buffer_data( pipe->winsys, st_obj->buffer, + size, data, + buffer_usage ); } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 40807fc05a..5b97c1ee34 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -282,7 +282,9 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) const unsigned size = sizeof(ctx->Current.Attrib); const void *data = ctx->Current.Attrib; /* colors, texcoords, etc */ - pipe->winsys->buffer_data(pipe->winsys, buf, size, data); + pipe->winsys->buffer_data(pipe->winsys, buf, + size, data, + PIPE_BUFFER_USAGE_VERTEX); /* position */ pipe->winsys->buffer_subdata(pipe->winsys, buf, 0, /* offset */ @@ -301,7 +303,8 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) fb_buf.start_offset = 0; pipe->winsys->buffer_data(pipe->winsys, fb_buf.buffer, fb_buf.size, - NULL); /* data */ + NULL, /* data */ + PIPE_BUFFER_USAGE_VERTEX); if (pipe->set_feedback_buffer) pipe->set_feedback_buffer(pipe, 0, &fb_buf); } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index c3f33a447e..3e2ed6cada 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -289,7 +289,9 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, /* XXX create one-time */ vbuf = pipe->winsys->buffer_create(pipe->winsys, 32); - pipe->winsys->buffer_data(pipe->winsys, vbuf, vertex_bytes, verts); + pipe->winsys->buffer_data(pipe->winsys, vbuf, + vertex_bytes, verts, + PIPE_BUFFER_USAGE_VERTEX); /* tell pipe about the vertex buffer */ vbuffer.buffer = vbuf; -- cgit v1.2.3 From aa880bdfa05d8ff2486ef8266f93dea983b7c6fd Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 16 Nov 2007 17:13:01 -0700 Subject: Reimplement glRasterPos using the private 'draw' module. --- src/mesa/state_tracker/st_cb_rasterpos.c | 440 +++++++++++-------------------- src/mesa/state_tracker/st_context.h | 3 +- 2 files changed, 160 insertions(+), 283 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 5b97c1ee34..5279cb1cd4 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -25,353 +25,229 @@ * **************************************************************************/ - /* - * Authors: - * Brian Paul - */ +/** + * glRasterPos implementation. Basically render a GL_POINT with our + * private draw module. Plug in a special "rasterpos" stage at the end + * of the 'draw' pipeline to capture the results and update the current + * raster pos attributes. + * + * Authors: + * Brian Paul + */ + #include "main/imports.h" -#include "main/feedback.h" #include "main/macros.h" #include "st_context.h" #include "st_atom.h" -#include "st_cache.h" #include "st_draw.h" -#include "st_program.h" #include "st_cb_rasterpos.h" #include "st_draw.h" -#include "st_format.h" -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_winsys.h" +#include "pipe/draw/draw_context.h" +#include "pipe/draw/draw_private.h" #include "shader/prog_instruction.h" +#include "vbo/vbo.h" -static void -setup_vertex_attribs(GLcontext *ctx) +/** + * Our special drawing pipeline stage (replaces rasterization). + */ +struct rastpos_stage { - struct pipe_context *pipe = ctx->st->pipe; - const struct cso_vertex_shader *vs = ctx->st->state.vs; - const struct st_vertex_program *stvp = ctx->st->vp; - uint slot; - - /* all attributes come from the default attribute buffer */ - { - struct pipe_vertex_buffer vbuffer; - vbuffer.buffer = ctx->st->default_attrib_buffer; - vbuffer.buffer_offset = 0; - vbuffer.pitch = 0; /* must be zero! */ - vbuffer.max_index = 1; - pipe->set_vertex_buffer(pipe, 0, &vbuffer); - } + struct draw_stage stage; /**< Base class */ + GLcontext *ctx; /**< Rendering context */ - for (slot = 0; slot < vs->state.num_inputs; slot++) { - struct pipe_vertex_element velement; - const GLuint attr = stvp->index_to_input[slot]; + /* vertex attrib info we can setup once and re-use */ + struct gl_client_array array[VERT_ATTRIB_MAX]; + const struct gl_client_array *arrays[VERT_ATTRIB_MAX]; + struct _mesa_prim prim; +}; - velement.src_offset = attr * 4 * sizeof(GLfloat); - velement.vertex_buffer_index = 0; - velement.dst_offset = 0; - velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - pipe->set_vertex_element(pipe, slot, &velement); - } -} +static INLINE struct rastpos_stage * +rastpos_stage( struct draw_stage *stage ) +{ + return (struct rastpos_stage *) stage; +} static void -setup_feedback(GLcontext *ctx) +rastpos_begin( struct draw_stage *stage ) { - struct pipe_context *pipe = ctx->st->pipe; - const struct pipe_shader_state *vs = &ctx->st->state.vs->state; - struct pipe_feedback_state feedback; - uint i; - - memset(&feedback, 0, sizeof(feedback)); - feedback.enabled = 1; - feedback.interleaved = 1; - feedback.discard = 1; - feedback.num_attribs = 0; - - /* feedback all results from vertex shader */ - for (i = 0; i < vs->num_outputs; i++) { - feedback.attrib[feedback.num_attribs] = i; - feedback.size[feedback.num_attribs] = 4; - feedback.num_attribs++; - } - - if (pipe->set_feedback_state) - pipe->set_feedback_state(pipe, &feedback); + /* no-op */ } +static void +rastpos_end( struct draw_stage *stage ) +{ + /* no-op */ +} - - - -/** - * Clip a point against the view volume. - * - * \param v vertex vector describing the point to clip. - * - * \return zero if outside view volume, or one if inside. - */ -static GLuint -viewclip_point( const GLfloat v[] ) +static void +rastpos_reset_stipple_counter( struct draw_stage *stage ) { - if ( v[0] > v[3] || v[0] < -v[3] - || v[1] > v[3] || v[1] < -v[3] - || v[2] > v[3] || v[2] < -v[3] ) { - return 0; - } - else { - return 1; - } + /* no-op */ } +static void +rastpos_tri( struct draw_stage *stage, struct prim_header *prim ) +{ + /* should never get here */ + assert(0); +} -/** - * Clip a point against the far/near Z clipping planes. - * - * \param v vertex vector describing the point to clip. - * - * \return zero if outside view volume, or one if inside. - */ -static GLuint -viewclip_point_z( const GLfloat v[] ) +static void +rastpos_line( struct draw_stage *stage, struct prim_header *prim ) { - if (v[2] > v[3] || v[2] < -v[3] ) { - return 0; - } - else { - return 1; - } + /* should never get here */ + assert(0); } /** - * Clip a point against the user clipping planes. - * - * \param ctx GL context. - * \param v vertex vector describing the point to clip. - * - * \return zero if the point was clipped, or one otherwise. + * Update a raster pos attribute from the vertex result if it's present, + * else copy the current attrib. */ -static GLuint -userclip_point( GLcontext *ctx, const GLfloat v[] ) +static void +update_attrib(GLcontext *ctx, const GLuint *outputMapping, + const struct vertex_header *vert, + GLfloat *dest, + GLuint result, GLuint defaultAttrib) { - GLuint p; - - for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0] - + v[1] * ctx->Transform._ClipUserPlane[p][1] - + v[2] * ctx->Transform._ClipUserPlane[p][2] - + v[3] * ctx->Transform._ClipUserPlane[p][3]; - if (dot < 0.0F) { - return 0; - } - } - } - - return 1; + const GLfloat *src; + const GLuint k = outputMapping[result]; + if (k != ~0) + src = vert->data[k]; + else + src = ctx->Current.Attrib[defaultAttrib]; + COPY_4V(dest, src); } /** - * Update the current raster position. - * Do clip testing, etc. here. + * Normally, this function would render a GL_POINT. */ static void -update_rasterpos(GLcontext *ctx, - const float clipPos[4], - const float color0[4], - const float color1[4], - const float *fog, - const float *tex) +rastpos_point(struct draw_stage *stage, struct prim_header *prim) { - uint i; - float d, ndc[3]; - - /* clip to view volume */ - if (ctx->Transform.RasterPositionUnclipped) { - /* GL_IBM_rasterpos_clip: only clip against Z */ - if (viewclip_point_z(clipPos) == 0) { - ctx->Current.RasterPosValid = GL_FALSE; - return; - } - } - else if (viewclip_point(clipPos) == 0) { - /* Normal OpenGL behaviour */ - ctx->Current.RasterPosValid = GL_FALSE; - return; - } - - /* clip to user clipping planes */ - if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clipPos)) { - ctx->Current.RasterPosValid = GL_FALSE; - return; - } + struct rastpos_stage *rs = rastpos_stage(stage); + GLcontext *ctx = rs->ctx; + struct st_context *st = ctx->st; + const GLfloat height = ctx->DrawBuffer->Height; + const GLuint *outputMapping = st->vertex_result_to_slot; + const GLfloat *pos; + GLuint i; + + /* if we get here, we didn't get clipped */ + ctx->Current.RasterPosValid = GL_TRUE; + /* update raster pos */ + pos = prim->v[0]->data[0]; + ctx->Current.RasterPos[0] = pos[0]; + ctx->Current.RasterPos[1] = height - 1 - pos[1]; + ctx->Current.RasterPos[2] = pos[2]; + ctx->Current.RasterPos[3] = pos[3]; - /* - * update current raster position - */ - /* ndc = clip / W */ - d = (clipPos[3] == 0.0F) ? 1.0F : 1.0F / clipPos[3]; - ndc[0] = clipPos[0] * d; - ndc[1] = clipPos[1] * d; - ndc[2] = clipPos[2] * d; - /* wincoord = viewport_mapping(ndc) */ - ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] - + ctx->Viewport._WindowMap.m[MAT_TX]); - ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] - + ctx->Viewport._WindowMap.m[MAT_TY]); - ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] - + ctx->Viewport._WindowMap.m[MAT_TZ]) - / ctx->DrawBuffer->_DepthMaxF; - ctx->Current.RasterPos[3] = clipPos[3]; - - /* compute raster distance */ -#if 0 - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) - ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - else { - /* XXX we don't have an eye coord! */ - ctx->Current.RasterDistance = - SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] ); - } -#else - ctx->Current.RasterDistance = fog[0]; -#endif - - /* colors and texcoords */ - COPY_4FV(ctx->Current.RasterColor, color0); - COPY_4FV(ctx->Current.RasterSecondaryColor, color1); - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - COPY_4FV(ctx->Current.RasterTexCoords + i, tex + i *4); - } + /* update other raster attribs */ + update_attrib(ctx, outputMapping, prim->v[0], + ctx->Current.RasterColor, + VERT_RESULT_COL0, VERT_ATTRIB_COLOR0); - ctx->Current.RasterPosValid = GL_TRUE; + update_attrib(ctx, outputMapping, prim->v[0], + ctx->Current.RasterSecondaryColor, + VERT_RESULT_COL1, VERT_ATTRIB_COLOR1); - if (ctx->RenderMode == GL_SELECT) { - _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); + for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + update_attrib(ctx, outputMapping, prim->v[0], + ctx->Current.RasterTexCoords[i], + VERT_RESULT_TEX0 + i, VERT_ATTRIB_TEX0 + i); } } +/** + * Create rasterpos "drawing" stage. + */ +static struct rastpos_stage * +new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw) +{ + struct rastpos_stage *rs = CALLOC_STRUCT(rastpos_stage); + + rs->stage.draw = draw; + rs->stage.next = NULL; + rs->stage.begin = rastpos_begin; + rs->stage.point = rastpos_point; + rs->stage.line = rastpos_line; + rs->stage.tri = rastpos_tri; + rs->stage.end = rastpos_end; + rs->stage.reset_stipple_counter = rastpos_reset_stipple_counter; + rs->ctx = ctx; + + return rs; +} + static void st_RasterPos(GLcontext *ctx, const GLfloat v[4]) { - const struct st_context *st = ctx->st; - struct pipe_context *pipe = st->pipe; - float *buf_map; - struct pipe_feedback_buffer fb_buf; + struct st_context *st = ctx->st; + struct draw_context *draw = st->draw; + struct rastpos_stage *rs; - st_validate_state(ctx->st); - - /* setup vertex buffers */ - setup_vertex_attribs(ctx); - - /* - * Load the default attribute buffer with current attribs. - */ - { - struct pipe_buffer_handle *buf = st->default_attrib_buffer; - const unsigned size = sizeof(ctx->Current.Attrib); - const void *data = ctx->Current.Attrib; - /* colors, texcoords, etc */ - pipe->winsys->buffer_data(pipe->winsys, buf, - size, data, - PIPE_BUFFER_USAGE_VERTEX); - /* position */ - pipe->winsys->buffer_subdata(pipe->winsys, buf, - 0, /* offset */ - 4 * sizeof(float), /* size */ - v); /* data */ + if (st->rastpos_stage) { + /* get rastpos stage info */ + rs = rastpos_stage(st->rastpos_stage); } - - - /* setup feedback state */ - setup_feedback(ctx); - - /* setup vertex feedback buffer */ - { - fb_buf.size = 8 * 4 * sizeof(float); - fb_buf.buffer = pipe->winsys->buffer_create(pipe->winsys, 0); - fb_buf.start_offset = 0; - pipe->winsys->buffer_data(pipe->winsys, fb_buf.buffer, - fb_buf.size, - NULL, /* data */ - PIPE_BUFFER_USAGE_VERTEX); - if (pipe->set_feedback_buffer) - pipe->set_feedback_buffer(pipe, 0, &fb_buf); - } - - - /* draw a point */ - pipe->draw_arrays(pipe, GL_POINTS, 0, 1); - - /* get feedback */ - buf_map = (float *) pipe->winsys->buffer_map(pipe->winsys, fb_buf.buffer, - PIPE_BUFFER_FLAG_READ); - - /* extract values and update rasterpos state */ - { - const GLuint *outputMapping = st->vertex_result_to_slot; - const float *pos, *color0, *color1, *fog, *tex0; - float *buf = buf_map; - - assert(outputMapping[VERT_RESULT_HPOS] != ~0); - pos = buf; - buf += 4; - - if (outputMapping[VERT_RESULT_COL0] != ~0) { - color0 = buf; - buf += 4; - } - else { - color0 = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; + else { + /* create rastpos draw stage */ + GLuint i; + + rs = new_draw_rastpos_stage(ctx, draw); + st->rastpos_stage = &rs->stage; + + /* one-time init */ + for (i = 0; i < VERT_ATTRIB_MAX; i++) { + rs->array[i].Size = 4; + rs->array[i].Type = GL_FLOAT; + rs->array[i].Stride = 0; + rs->array[i].StrideB = 0; + rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i]; + rs->array[i].Enabled = GL_TRUE; + rs->array[i].Normalized = GL_TRUE; + rs->array[i].BufferObj = NULL; + rs->arrays[i] = &rs->array[i]; } - if (outputMapping[VERT_RESULT_COL1] != ~0) { - color1 = buf; - buf += 4; - } - else { - color1 = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; - } + rs->prim.mode = GL_POINTS; + rs->prim.indexed = 0; + rs->prim.begin = 1; + rs->prim.end = 1; + rs->prim.weak = 0; + rs->prim.start = 0; + rs->prim.count = 1; + } - if (outputMapping[VERT_RESULT_FOGC] != ~0) { - fog = buf; - buf += 4; - } - else { - fog = ctx->Current.Attrib[VERT_ATTRIB_FOG]; - } + /* plug our rastpos stage into the draw module */ + draw_set_rasterize_stage(st->draw, st->rastpos_stage); - if (outputMapping[VERT_RESULT_TEX0] != ~0) { - tex0 = buf; - buf += 4; - } - else { - tex0 = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - } + /* make sure everything's up to date */ + st_validate_state(ctx->st); - update_rasterpos(ctx, pos, color0, color1, fog, tex0); - } + /* This will get set only if rastpos_point(), above, gets called */ + ctx->Current.RasterPosValid = GL_FALSE; - /* free vertex feedback buffer */ - pipe->winsys->buffer_unmap(pipe->winsys, fb_buf.buffer); - pipe->winsys->buffer_reference(pipe->winsys, &fb_buf.buffer, NULL); + /* All vertex attribs but position were previously initialized above. + * Just plug in position pointer now. + */ + rs->array[0].Ptr = (GLubyte *) v; - /* restore pipe state */ - if (pipe->set_feedback_state) - pipe->set_feedback_state(pipe, &st->state.feedback); + /* draw the point */ + st_feedback_draw_vbo(ctx, rs->arrays, &rs->prim, 1, NULL, 0, 1); } + void st_init_rasterpos_functions(struct dd_function_table *functions) { functions->RasterPos = st_RasterPos; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 82e133911f..a6045230a0 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -68,9 +68,10 @@ struct st_context struct pipe_context *pipe; - struct draw_context *draw; /**< For selection/feedback */ + struct draw_context *draw; /**< For selection/feedback/rastpos only */ struct draw_stage *feedback_stage; /**< For GL_FEEDBACK rendermode */ struct draw_stage *selection_stage; /**< For GL_SELECT rendermode */ + struct draw_stage *rastpos_stage; /**< For glRasterPos */ /* Some state is contained in constant objects. * Other state is just parameter values. -- cgit v1.2.3 From 48731280d08bef51c406703e82986643e17b4757 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 11 Dec 2007 13:00:12 +0000 Subject: gallium: Remove feedback interfaces from pipe driver. Something similar will return when geometry shaders are added, but for now this interface is not required. --- src/mesa/pipe/draw/draw_context.c | 21 --- src/mesa/pipe/draw/draw_context.h | 6 - src/mesa/pipe/draw/draw_feedback.c | 253 ----------------------------- src/mesa/pipe/draw/draw_private.h | 9 - src/mesa/pipe/draw/draw_validate.c | 5 - src/mesa/pipe/i915simple/i915_context.c | 22 --- src/mesa/pipe/i915simple/i915_context.h | 4 - src/mesa/pipe/i915simple/i915_state.c | 30 ---- src/mesa/pipe/p_context.h | 9 - src/mesa/pipe/p_state.h | 22 --- src/mesa/pipe/softpipe/Makefile | 1 - src/mesa/pipe/softpipe/sp_context.c | 2 - src/mesa/pipe/softpipe/sp_context.h | 4 - src/mesa/pipe/softpipe/sp_draw_arrays.c | 22 --- src/mesa/pipe/softpipe/sp_state.h | 8 - src/mesa/pipe/softpipe/sp_state_feedback.c | 72 -------- src/mesa/sources | 1 - src/mesa/state_tracker/st_cb_rasterpos.c | 44 +++-- src/mesa/state_tracker/st_context.h | 1 - 19 files changed, 21 insertions(+), 515 deletions(-) delete mode 100644 src/mesa/pipe/draw/draw_feedback.c delete mode 100644 src/mesa/pipe/softpipe/sp_state_feedback.c (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index 33727e6547..179f7ed0d6 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -55,7 +55,6 @@ struct draw_context *draw_create( void ) draw->pipeline.clip = draw_clip_stage( draw ); draw->pipeline.flatshade = draw_flatshade_stage( draw ); draw->pipeline.cull = draw_cull_stage( draw ); - draw->pipeline.feedback = draw_feedback_stage( draw ); draw->pipeline.validate = draw_validate_stage( draw ); draw->pipeline.first = draw->pipeline.validate; @@ -100,7 +99,6 @@ void draw_destroy( struct draw_context *draw ) draw->pipeline.clip->destroy( draw->pipeline.clip ); draw->pipeline.flatshade->destroy( draw->pipeline.flatshade ); draw->pipeline.cull->destroy( draw->pipeline.cull ); - draw->pipeline.feedback->destroy( draw->pipeline.feedback ); draw->pipeline.validate->destroy( draw->pipeline.validate ); if (draw->pipeline.rasterize) draw->pipeline.rasterize->destroy( draw->pipeline.rasterize ); @@ -117,13 +115,6 @@ void draw_flush( struct draw_context *draw ) } -void draw_set_feedback_state( struct draw_context *draw, - const struct pipe_feedback_state *feedback ) -{ - draw_flush( draw ); - draw->feedback = *feedback; -} - /** * Register new primitive rasterization/rendering state. @@ -223,18 +214,6 @@ draw_set_mapped_constant_buffer(struct draw_context *draw, } -void -draw_set_mapped_feedback_buffer(struct draw_context *draw, uint index, - void *buffer, uint size) -{ - draw_flush( draw ); - - assert(index < PIPE_MAX_FEEDBACK_ATTRIBS); - draw->user.feedback_buffer[index] = buffer; - draw->user.feedback_buffer_size[index] = size; /* in bytes */ -} - - diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 8e2232244c..6dc6e4ce82 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -82,9 +82,6 @@ void draw_set_viewport_state( struct draw_context *draw, void draw_set_clip_state( struct draw_context *pipe, const struct pipe_clip_state *clip ); -void draw_set_feedback_state( struct draw_context *draw, - const struct pipe_feedback_state * ); - void draw_set_rasterizer_state( struct draw_context *draw, const struct pipe_rasterizer_state *raster ); @@ -120,9 +117,6 @@ void draw_set_mapped_vertex_buffer(struct draw_context *draw, void draw_set_mapped_constant_buffer(struct draw_context *draw, const void *buffer); -void -draw_set_mapped_feedback_buffer(struct draw_context *draw, uint index, - void *buffer, uint size); /*********************************************************************** diff --git a/src/mesa/pipe/draw/draw_feedback.c b/src/mesa/pipe/draw/draw_feedback.c deleted file mode 100644 index aea6a8184c..0000000000 --- a/src/mesa/pipe/draw/draw_feedback.c +++ /dev/null @@ -1,253 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ - -/** - * Primitive/vertex feedback (and/or discard) stage. - * Used to implement transformation feedback/streaming and other things - * which require a post-transformed vertex position (such as rasterpos, - * selection and feedback modes). - * - * Authors: - * Brian Paul - */ - - -#include "pipe/p_util.h" -#include "draw_private.h" - - -struct feedback_stage { - struct draw_stage stage; /**< base class */ - uint num_prim_generated; /**< number of primitives received */ - uint num_prim_emitted; /**< number of primitives fed back */ - uint num_vert_emitted; /**< number of vertices fed back */ - uint max_vert_emit; /**< max number of verts we can emit */ - float *dest[PIPE_MAX_FEEDBACK_ATTRIBS]; /**< dests for vertex attribs */ -}; - - - -/** - * Check if there's space to store 'numVerts' in the feedback buffer(s). - */ -static boolean -check_space(const struct draw_stage *stage, uint numVerts) -{ - const struct feedback_stage *fs = (struct feedback_stage *) stage; - return fs->num_vert_emitted + numVerts <= fs->max_vert_emit; -} - - -/** - * Record the given vertex's attributes into the feedback buffer(s). - */ -static void -feedback_vertex(struct draw_stage *stage, const struct vertex_header *vertex) -{ - struct feedback_stage *fs = (struct feedback_stage *) stage; - const struct pipe_feedback_state *feedback = &stage->draw->feedback; - const uint select = feedback->interleaved ? 0 : 1; - uint i; - - /* - * Note: 'select' is either 0 or 1. By multiplying 'i' by 'select' - * we can either address output buffer 0 (for interleaving) or - * output buffer i (for non-interleaved). - */ - for (i = 0; i < feedback->num_attribs; i++) { - const uint slot = feedback->attrib[i]; - const float *src = slot ? vertex->data[slot] : vertex->clip; - const uint size = feedback->size[i]; - float *dest = fs->dest[i * select]; - - switch (size) { - case 4: - dest[3] = src[3]; - /* fall-through */ - case 3: - dest[2] = src[2]; - /* fall-through */ - case 2: - dest[1] = src[1]; - /* fall-through */ - case 1: - dest[0] = src[0]; - /* fall-through */ - default: - ; - } - fs->dest[i * select] += size; - } - - fs->num_vert_emitted++; -} - - -static void feedback_begin( struct draw_stage *stage ) -{ - struct feedback_stage *fs = (struct feedback_stage *) stage; - const struct pipe_feedback_state *feedback = &stage->draw->feedback; - - fs->num_prim_generated = 0; - fs->num_prim_emitted = 0; - fs->num_vert_emitted = 0; - - assert(feedback->enabled); - - /* Compute max_vert_emit, the max number of vertices we can emit. - * And, setup dest[] pointers. - */ - if (stage->draw->feedback.interleaved) { - uint i, vertex_size = 0; - /* compute size of each interleaved vertex, in floats */ - for (i = 0; i < feedback->num_attribs; i++) { - vertex_size += feedback->size[i]; - } - /* compute max number of vertices we can feedback */ - fs->max_vert_emit = stage->draw->user.feedback_buffer_size[0] - / sizeof(float) / vertex_size; - - fs->dest[0] = (float *) stage->draw->user.feedback_buffer[0]; - } - else { - uint i; - uint max = ~0; - for (i = 0; i < feedback->num_attribs; i++) { - uint n = stage->draw->user.feedback_buffer_size[i] - / sizeof(float) / feedback->size[i]; - if (n < max) - max = n; - fs->dest[i] = (float *) stage->draw->user.feedback_buffer[i]; - } - fs->max_vert_emit = max; - } - - if (!feedback->discard) - stage->next->begin( stage->next ); -} - - -static void feedback_tri( struct draw_stage *stage, - struct prim_header *header ) -{ - struct feedback_stage *fs = (struct feedback_stage *) stage; - - fs->num_prim_generated++; - - if (stage->draw->feedback.enabled && check_space(stage, 3)) { - feedback_vertex(stage, header->v[0]); - feedback_vertex(stage, header->v[1]); - feedback_vertex(stage, header->v[2]); - fs->num_prim_emitted++; - } - - if (!stage->draw->feedback.discard) - stage->next->tri( stage->next, header ); -} - - -static void feedback_line( struct draw_stage *stage, - struct prim_header *header ) -{ - struct feedback_stage *fs = (struct feedback_stage *) stage; - - fs->num_prim_generated++; - - if (stage->draw->feedback.enabled && check_space(stage, 2)) { - feedback_vertex(stage, header->v[0]); - feedback_vertex(stage, header->v[1]); - fs->num_prim_emitted++; - } - - if (!stage->draw->feedback.discard) - stage->next->line( stage->next, header ); -} - - -static void feedback_point( struct draw_stage *stage, - struct prim_header *header ) -{ - struct feedback_stage *fs = (struct feedback_stage *) stage; - - fs->num_prim_generated++; - - if (stage->draw->feedback.enabled && check_space(stage, 1)) { - feedback_vertex(stage, header->v[0]); - fs->num_prim_emitted++; - } - - if (!stage->draw->feedback.discard) - stage->next->point( stage->next, header ); -} - - -static void feedback_end( struct draw_stage *stage ) -{ - - /* XXX Unmap the vertex feedback buffers so we can write to them */ - - - if (!stage->draw->feedback.discard) - stage->next->end( stage->next ); -} - - - -static void feedback_reset_stipple_counter( struct draw_stage *stage ) -{ - if (!stage->draw->feedback.discard) - stage->next->reset_stipple_counter( stage->next ); -} - - -static void feedback_destroy( struct draw_stage *stage ) -{ - FREE( stage ); -} - - -/** - * Create feedback drawing stage. - */ -struct draw_stage *draw_feedback_stage( struct draw_context *draw ) -{ - struct feedback_stage *feedback = CALLOC_STRUCT(feedback_stage); - - feedback->stage.draw = draw; - feedback->stage.next = NULL; - feedback->stage.begin = feedback_begin; - feedback->stage.point = feedback_point; - feedback->stage.line = feedback_line; - feedback->stage.tri = feedback_tri; - feedback->stage.end = feedback_end; - feedback->stage.reset_stipple_counter = feedback_reset_stipple_counter; - feedback->stage.destroy = feedback_destroy; - - return &feedback->stage; -} - - diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index ca5ca7b3c9..5f89ac121e 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -159,7 +159,6 @@ struct draw_context struct draw_stage *validate; /* stages (in logical order) */ - struct draw_stage *feedback; struct draw_stage *flatshade; struct draw_stage *clip; struct draw_stage *cull; @@ -172,13 +171,10 @@ struct draw_context /* pipe state that we need: */ const struct pipe_rasterizer_state *rasterizer; - struct pipe_feedback_state feedback; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; const struct draw_vertex_shader *vertex_shader; - struct pipe_vertex_buffer feedback_buffer[PIPE_ATTRIB_MAX]; - struct pipe_vertex_element feedback_element[PIPE_ATTRIB_MAX]; /* user-space vertex data, buffers */ struct { @@ -192,10 +188,6 @@ struct draw_context /** constant buffer (for vertex shader) */ const void *constants; - - /** The vertex feedback buffer */ - void *feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS]; - uint feedback_buffer_size[PIPE_MAX_FEEDBACK_ATTRIBS]; /* in bytes */ } user; /* Clip derived state: @@ -257,7 +249,6 @@ struct draw_context -extern struct draw_stage *draw_feedback_stage( struct draw_context *context ); extern struct draw_stage *draw_unfilled_stage( struct draw_context *context ); extern struct draw_stage *draw_twoside_stage( struct draw_context *context ); extern struct draw_stage *draw_offset_stage( struct draw_context *context ); diff --git a/src/mesa/pipe/draw/draw_validate.c b/src/mesa/pipe/draw/draw_validate.c index 8ce4a926e2..58cf340281 100644 --- a/src/mesa/pipe/draw/draw_validate.c +++ b/src/mesa/pipe/draw/draw_validate.c @@ -100,11 +100,6 @@ static void validate_begin( struct draw_stage *stage ) next = draw->pipeline.flatshade; } - if (draw->feedback.enabled || draw->feedback.discard) { - draw->pipeline.feedback->next = next; - next = draw->pipeline.feedback; - } - draw->pipeline.first = next; draw->pipeline.first->begin( draw->pipeline.first ); } diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index f505ff6ae6..d2bbeea16a 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -223,18 +223,6 @@ i915_draw_elements( struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } - /* Map feedback buffers if enabled */ - if (i915->feedback.enabled) { - const uint n = i915->feedback.interleaved ? 1 : i915->feedback.num_attribs; - for (i = 0; i < n; i++) { - void *ptr = pipe->winsys->buffer_map(pipe->winsys, - i915->feedback_buffer[i].buffer, - PIPE_BUFFER_FLAG_WRITE); - draw_set_mapped_feedback_buffer(draw, i, ptr, - i915->feedback_buffer[i].size); - } - } - draw_set_mapped_constant_buffer(draw, i915->current.constants[PIPE_SHADER_VERTEX]); @@ -256,16 +244,6 @@ i915_draw_elements( struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } - /* Unmap feedback buffers if enabled */ - if (i915->feedback.enabled) { - const uint n = i915->feedback.interleaved ? 1 : i915->feedback.num_attribs; - for (i = 0; i < n; i++) { - pipe->winsys->buffer_unmap(pipe->winsys, - i915->feedback_buffer[i].buffer); - draw_set_mapped_feedback_buffer(draw, i, NULL, 0); - } - } - return TRUE; } diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index dbf0c885cc..b9b67c4fcf 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -197,7 +197,6 @@ struct i915_context struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[PIPE_SHADER_TYPES]; - struct pipe_feedback_state feedback; struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; @@ -206,9 +205,6 @@ struct i915_context struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; - /** Feedback buffers */ - struct pipe_feedback_buffer feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS]; - unsigned dirty; unsigned *batch_start; diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 038fd623ea..b9f257a007 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -547,34 +547,6 @@ static void i915_set_framebuffer_state(struct pipe_context *pipe, } -static void -i915_set_feedback_state(struct pipe_context *pipe, - const struct pipe_feedback_state *feedback) -{ - struct i915_context *i915 = i915_context(pipe); - i915->feedback = *feedback; - draw_set_feedback_state(i915->draw, feedback); -} - - -static void -i915_set_feedback_buffer(struct pipe_context *pipe, - unsigned index, - const struct pipe_feedback_buffer *feedback) -{ - struct i915_context *i915 = i915_context(pipe); - - assert(index < PIPE_MAX_FEEDBACK_ATTRIBS); - - /* Need to be careful with referencing */ - pipe->winsys->buffer_reference(pipe->winsys, - &i915->feedback_buffer[index].buffer, - feedback->buffer); - i915->feedback_buffer[index].size = feedback->size; - i915->feedback_buffer[index].start_offset = feedback->start_offset; -} - - static void i915_set_clear_color_state(struct pipe_context *pipe, const struct pipe_clear_color_state *clear) @@ -751,8 +723,6 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.set_clear_color_state = i915_set_clear_color_state; i915->pipe.set_constant_buffer = i915_set_constant_buffer; i915->pipe.set_framebuffer_state = i915_set_framebuffer_state; - i915->pipe.set_feedback_state = i915_set_feedback_state; - i915->pipe.set_feedback_buffer = i915_set_feedback_buffer; i915->pipe.set_polygon_stipple = i915_set_polygon_stipple; i915->pipe.set_sampler_units = i915_set_sampler_units; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 00379fbacf..7da4992841 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -139,9 +139,6 @@ struct pipe_context { uint shader, uint index, const struct pipe_constant_buffer *buf ); - void (*set_feedback_state)( struct pipe_context *, - const struct pipe_feedback_state *); - void (*set_framebuffer_state)( struct pipe_context *, const struct pipe_framebuffer_state * ); @@ -172,12 +169,6 @@ struct pipe_context { unsigned index, const struct pipe_vertex_element * ); - /* - * Vertex feedback - */ - void (*set_feedback_buffer)(struct pipe_context *, - unsigned index, - const struct pipe_feedback_buffer *); /** Get a surface which is a "view" into a texture */ struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe, diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 6db9bbc953..50344bea78 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -103,19 +103,6 @@ struct pipe_rasterizer_state }; -/** - * Post-transform vertex feeback - */ -struct pipe_feedback_state { - uint enabled:1; /**< enable feedback? */ - uint discard:1; /**< discard primitives? */ - uint interleaved:1; /**< interleaved output? */ - uint num_attribs; - uint attrib[PIPE_MAX_FEEDBACK_ATTRIBS]; - uint size[PIPE_MAX_FEEDBACK_ATTRIBS]; -}; - - struct pipe_poly_stipple { unsigned stipple[32]; }; @@ -336,15 +323,6 @@ struct pipe_vertex_element }; -/** - * Vertex feedback buffer - */ -struct pipe_feedback_buffer { - struct pipe_buffer_handle *buffer; - unsigned size; - unsigned start_offset; -}; - /** * Hardware queries (occlusion, transform feedback, timing, etc) diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile index 647cc05373..5e6886a37e 100644 --- a/src/mesa/pipe/softpipe/Makefile +++ b/src/mesa/pipe/softpipe/Makefile @@ -27,7 +27,6 @@ DRIVER_SOURCES = \ sp_state_blend.c \ sp_state_clip.c \ sp_state_derived.c \ - sp_state_feedback.c \ sp_state_fs.c \ sp_state_sampler.c \ sp_state_rasterizer.c \ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 8b8e04c2f9..2eab3aaabb 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -306,7 +306,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.set_clip_state = softpipe_set_clip_state; softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state; softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer; - softpipe->pipe.set_feedback_state = softpipe_set_feedback_state; softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple; softpipe->pipe.set_sampler_units = softpipe_set_sampler_units; @@ -316,7 +315,6 @@ 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; - softpipe->pipe.set_feedback_buffer = softpipe_set_feedback_buffer; softpipe->pipe.draw_arrays = softpipe_draw_arrays; softpipe->pipe.draw_elements = softpipe_draw_elements; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index b97cdc52c6..1c391dcd4d 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -85,7 +85,6 @@ struct softpipe_context { struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[2]; - struct pipe_feedback_state feedback; struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; @@ -117,9 +116,6 @@ struct softpipe_context { boolean need_w; /**< produce quad/fragment W values? */ int psize_slot; - /** Feedback buffers */ - struct pipe_feedback_buffer feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS]; - #if 0 /* Stipple derived state: */ diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c index 93eb68405d..b7626f8a5f 100644 --- a/src/mesa/pipe/softpipe/sp_draw_arrays.c +++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c @@ -138,18 +138,6 @@ softpipe_draw_elements(struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } - /* Map feedback buffers if enabled */ - if (sp->feedback.enabled) { - const uint n = sp->feedback.interleaved ? 1 : sp->feedback.num_attribs; - for (i = 0; i < n; i++) { - void *ptr = pipe->winsys->buffer_map(pipe->winsys, - sp->feedback_buffer[i].buffer, - PIPE_BUFFER_FLAG_WRITE); - draw_set_mapped_feedback_buffer(draw, i, ptr, - sp->feedback_buffer[i].size); - } - } - /* draw! */ draw_arrays(draw, mode, start, count); @@ -171,16 +159,6 @@ softpipe_draw_elements(struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } - /* Unmap feedback buffers if enabled */ - if (sp->feedback.enabled) { - const uint n = sp->feedback.interleaved ? 1 : sp->feedback.num_attribs; - for (i = 0; i < n; i++) { - pipe->winsys->buffer_unmap(pipe->winsys, - sp->feedback_buffer[i].buffer); - draw_set_mapped_feedback_buffer(draw, i, NULL, 0); - } - } - /* Note: leave drawing surfaces mapped */ softpipe_unmap_constant_buffers(sp); diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index ea9d2e62be..f434567da5 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -102,9 +102,6 @@ void softpipe_set_constant_buffer(struct pipe_context *, uint shader, uint index, const struct pipe_constant_buffer *buf); -void softpipe_set_feedback_state( struct pipe_context *, - const struct pipe_feedback_state * ); - void *softpipe_create_fs_state(struct pipe_context *, const struct pipe_shader_state *); void softpipe_bind_fs_state(struct pipe_context *, void *); @@ -138,11 +135,6 @@ void softpipe_set_vertex_buffer(struct pipe_context *, unsigned index, const struct pipe_vertex_buffer *); -void softpipe_set_feedback_buffer(struct pipe_context *, - uint index, - const struct pipe_feedback_buffer *); - - void softpipe_update_derived( struct softpipe_context *softpipe ); diff --git a/src/mesa/pipe/softpipe/sp_state_feedback.c b/src/mesa/pipe/softpipe/sp_state_feedback.c deleted file mode 100644 index 02aaf34e75..0000000000 --- a/src/mesa/pipe/softpipe/sp_state_feedback.c +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************** - * - * 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. - * - **************************************************************************/ - -/** - * Authors: - * Brian Paul - */ - - -#include "sp_context.h" -#include "sp_state.h" -#include "sp_surface.h" - -#include "pipe/p_winsys.h" -#include "pipe/draw/draw_context.h" - - -void -softpipe_set_feedback_state(struct pipe_context *pipe, - const struct pipe_feedback_state *feedback) -{ - struct softpipe_context *softpipe = softpipe_context(pipe); - - softpipe->feedback = *feedback; /* struct copy */ - /* - softpipe->dirty |= SP_NEW_FEEDBACK; - */ - - draw_set_feedback_state(softpipe->draw, feedback); -} - - -void -softpipe_set_feedback_buffer(struct pipe_context *pipe, - unsigned index, - const struct pipe_feedback_buffer *feedback) -{ - struct softpipe_context *softpipe = softpipe_context(pipe); - - assert(index < PIPE_MAX_FEEDBACK_ATTRIBS); - - /* Need to be careful with referencing */ - pipe->winsys->buffer_reference(pipe->winsys, - &softpipe->feedback_buffer[index].buffer, - feedback->buffer); - softpipe->feedback_buffer[index].size = feedback->size; - softpipe->feedback_buffer[index].start_offset = feedback->start_offset; -} diff --git a/src/mesa/sources b/src/mesa/sources index c34361eaae..4a5a97b47d 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -162,7 +162,6 @@ DRAW_SOURCES = \ pipe/draw/draw_context.c\ pipe/draw/draw_cull.c \ pipe/draw/draw_debug.c \ - pipe/draw/draw_feedback.c \ pipe/draw/draw_flatshade.c \ pipe/draw/draw_offset.c \ pipe/draw/draw_prim.c \ diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 5279cb1cd4..852cff6490 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -173,6 +173,7 @@ static struct rastpos_stage * new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw) { struct rastpos_stage *rs = CALLOC_STRUCT(rastpos_stage); + GLuint i; rs->stage.draw = draw; rs->stage.next = NULL; @@ -184,6 +185,26 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw) rs->stage.reset_stipple_counter = rastpos_reset_stipple_counter; rs->ctx = ctx; + for (i = 0; i < VERT_ATTRIB_MAX; i++) { + rs->array[i].Size = 4; + rs->array[i].Type = GL_FLOAT; + rs->array[i].Stride = 0; + rs->array[i].StrideB = 0; + rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i]; + rs->array[i].Enabled = GL_TRUE; + rs->array[i].Normalized = GL_TRUE; + rs->array[i].BufferObj = NULL; + rs->arrays[i] = &rs->array[i]; + } + + rs->prim.mode = GL_POINTS; + rs->prim.indexed = 0; + rs->prim.begin = 1; + rs->prim.end = 1; + rs->prim.weak = 0; + rs->prim.start = 0; + rs->prim.count = 1; + return rs; } @@ -201,31 +222,8 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) } else { /* create rastpos draw stage */ - GLuint i; - rs = new_draw_rastpos_stage(ctx, draw); st->rastpos_stage = &rs->stage; - - /* one-time init */ - for (i = 0; i < VERT_ATTRIB_MAX; i++) { - rs->array[i].Size = 4; - rs->array[i].Type = GL_FLOAT; - rs->array[i].Stride = 0; - rs->array[i].StrideB = 0; - rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i]; - rs->array[i].Enabled = GL_TRUE; - rs->array[i].Normalized = GL_TRUE; - rs->array[i].BufferObj = NULL; - rs->arrays[i] = &rs->array[i]; - } - - rs->prim.mode = GL_POINTS; - rs->prim.indexed = 0; - rs->prim.begin = 1; - rs->prim.end = 1; - rs->prim.weak = 0; - rs->prim.start = 0; - rs->prim.count = 1; } /* plug our rastpos stage into the draw module */ diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index c31b76c63f..33aacdb6d1 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -106,7 +106,6 @@ struct st_context struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[2]; - struct pipe_feedback_state feedback; struct pipe_framebuffer_state framebuffer; struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; struct pipe_poly_stipple poly_stipple; -- cgit v1.2.3 From 7049ff53f640aeccc9523a103468183ffda996fd Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 21 Jan 2008 21:19:24 -0700 Subject: gallium: silence warnings --- src/mesa/state_tracker/st_cb_feedback.c | 4 ++-- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index ea775b9452..43543df1a8 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -103,13 +103,13 @@ feedback_vertex(GLcontext *ctx, const struct draw_context *draw, */ slot = st->vertex_result_to_slot[VERT_RESULT_COL0]; - if (slot != ~0) + if (slot != ~0U) color = v->data[slot]; else color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; slot = st->vertex_result_to_slot[VERT_RESULT_TEX0]; - if (slot != ~0) + if (slot != ~0U) texcoord = v->data[slot]; else texcoord = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 852cff6490..f1c2d2d7c3 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -117,7 +117,7 @@ update_attrib(GLcontext *ctx, const GLuint *outputMapping, { const GLfloat *src; const GLuint k = outputMapping[result]; - if (k != ~0) + if (k != ~0U) src = vert->data[k]; else src = ctx->Current.Attrib[defaultAttrib]; -- cgit v1.2.3 From c753e7adde9a7a2c8ff772fe8e2a42084c5966e0 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 24 Jan 2008 16:05:33 -0700 Subject: gallium: added rastpos_destroy() --- src/mesa/state_tracker/st_cb_rasterpos.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index f1c2d2d7c3..dc6456c775 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -104,6 +104,12 @@ rastpos_line( struct draw_stage *stage, struct prim_header *prim ) assert(0); } +static void +rastpos_destroy(struct draw_stage *stage) +{ + free(stage); +} + /** * Update a raster pos attribute from the vertex result if it's present, @@ -183,6 +189,7 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw) rs->stage.tri = rastpos_tri; rs->stage.end = rastpos_end; rs->stage.reset_stipple_counter = rastpos_reset_stipple_counter; + rs->stage.destroy = rastpos_destroy; rs->ctx = ctx; for (i = 0; i < VERT_ATTRIB_MAX; i++) { -- cgit v1.2.3 From 48355538a65fe9c0be234c61080edd70f6a86736 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 24 Jan 2008 15:23:27 -0700 Subject: gallium: added rastpos_destroy() --- src/mesa/state_tracker/st_cb_rasterpos.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index dc6456c775..9e20e94dc7 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -188,6 +188,7 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw) rs->stage.line = rastpos_line; rs->stage.tri = rastpos_tri; rs->stage.end = rastpos_end; + rs->stage.destroy = rastpos_destroy; rs->stage.reset_stipple_counter = rastpos_reset_stipple_counter; rs->stage.destroy = rastpos_destroy; rs->ctx = ctx; -- cgit v1.2.3 From 0bfd085e2866fbbd40209dcee23f0e6240583fe8 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 25 Jan 2008 15:59:27 -0700 Subject: gallium: replace prim pipeline begin/end() functions with flush() This is basically half of Keith's draw/flush patch. The stage->point/line/tri() functions are now self-validating, the validator functions are installed by the flush() function. There were excessive calls to validate_pipeline(), however. This was caused by draw_prim_queue_flush() keeping a local 'first' variable that always pointed to the validate functions. Replaced 'first' with 'draw->pipeline.first'. Performance in gears is up just slightly with this patch. --- src/mesa/pipe/cell/ppu/cell_draw_arrays.c | 9 +-- src/mesa/pipe/draw/draw_clip.c | 17 +----- src/mesa/pipe/draw/draw_cull.c | 31 +++++----- src/mesa/pipe/draw/draw_flatshade.c | 67 +++++++++++++-------- src/mesa/pipe/draw/draw_offset.c | 37 +++++++----- src/mesa/pipe/draw/draw_prim.c | 23 +++---- src/mesa/pipe/draw/draw_private.h | 5 +- src/mesa/pipe/draw/draw_stipple.c | 16 ++--- src/mesa/pipe/draw/draw_twoside.c | 99 ++++++++++++++++--------------- src/mesa/pipe/draw/draw_unfilled.c | 33 ++++++----- src/mesa/pipe/draw/draw_validate.c | 54 ++++++++++++++--- src/mesa/pipe/draw/draw_vbuf.c | 5 +- src/mesa/pipe/draw/draw_wide_prims.c | 51 ++++++++++------ src/mesa/pipe/i915simple/i915_prim_emit.c | 11 +--- src/mesa/pipe/softpipe/sp_draw_arrays.c | 9 +-- src/mesa/pipe/softpipe/sp_prim_setup.c | 43 ++++++++++++-- src/mesa/pipe/softpipe/sp_prim_vbuf.c | 4 +- src/mesa/state_tracker/st_cb_feedback.c | 24 ++------ src/mesa/state_tracker/st_cb_rasterpos.c | 11 +--- 19 files changed, 309 insertions(+), 240 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c index 8286da712c..9c41b4a523 100644 --- a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c +++ b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c @@ -143,21 +143,18 @@ cell_draw_elements(struct pipe_context *pipe, /* draw! */ draw_arrays(draw, mode, start, count); - /* always flush for now */ - draw_flush(draw); - /* - * unmap vertex/index buffers + * unmap vertex/index buffers - will cause draw module to flush */ for (i = 0; i < PIPE_ATTRIB_MAX; i++) { if (sp->vertex_buffer[i].buffer) { - pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); + pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer); } } if (indexBuffer) { - pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); draw_set_mapped_element_buffer(draw, 0, NULL); + pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); } /* Note: leave drawing surfaces mapped */ diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c index e0eb656364..2d410e3244 100644 --- a/src/mesa/pipe/draw/draw_clip.c +++ b/src/mesa/pipe/draw/draw_clip.c @@ -346,15 +346,6 @@ do_clip_line( struct draw_stage *stage, } -static void clip_begin( struct draw_stage *stage ) -{ - /* should always have position, at least */ - assert(stage->draw->num_vs_outputs > 0); - - stage->next->begin( stage->next ); -} - - static void clip_point( struct draw_stage *stage, struct prim_header *header ) @@ -402,10 +393,9 @@ clip_tri( struct draw_stage *stage, } } - -static void clip_end( struct draw_stage *stage ) +static void clip_flush( struct draw_stage *stage, unsigned flags ) { - stage->next->end( stage->next ); + stage->next->flush( stage->next, flags ); } @@ -433,11 +423,10 @@ struct draw_stage *draw_clip_stage( struct draw_context *draw ) draw_alloc_tmps( &clipper->stage, MAX_CLIPPED_VERTICES ); clipper->stage.draw = draw; - clipper->stage.begin = clip_begin; clipper->stage.point = clip_point; clipper->stage.line = clip_line; clipper->stage.tri = clip_tri; - clipper->stage.end = clip_end; + clipper->stage.flush = clip_flush; clipper->stage.reset_stipple_counter = clip_reset_stipple_counter; clipper->stage.destroy = clip_destroy; diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c index 9bd53f45f2..05c274e4dc 100644 --- a/src/mesa/pipe/draw/draw_cull.c +++ b/src/mesa/pipe/draw/draw_cull.c @@ -50,14 +50,6 @@ static INLINE struct cull_stage *cull_stage( struct draw_stage *stage ) } -static void cull_begin( struct draw_stage *stage ) -{ - struct cull_stage *cull = cull_stage(stage); - - cull->winding = stage->draw->rasterizer->cull_mode; - - stage->next->begin( stage->next ); -} static void cull_tri( struct draw_stage *stage, @@ -90,6 +82,18 @@ static void cull_tri( struct draw_stage *stage, } } +static void cull_first_tri( struct draw_stage *stage, + struct prim_header *header ) +{ + struct cull_stage *cull = cull_stage(stage); + + cull->winding = stage->draw->rasterizer->cull_mode; + + stage->tri = cull_tri; + stage->tri( stage, header ); +} + + static void cull_line( struct draw_stage *stage, struct prim_header *header ) @@ -105,12 +109,12 @@ static void cull_point( struct draw_stage *stage, } -static void cull_end( struct draw_stage *stage ) +static void cull_flush( struct draw_stage *stage, unsigned flags ) { - stage->next->end( stage->next ); + stage->tri = cull_first_tri; + stage->next->flush( stage->next, flags ); } - static void cull_reset_stipple_counter( struct draw_stage *stage ) { stage->next->reset_stipple_counter( stage->next ); @@ -135,11 +139,10 @@ struct draw_stage *draw_cull_stage( struct draw_context *draw ) cull->stage.draw = draw; cull->stage.next = NULL; - cull->stage.begin = cull_begin; cull->stage.point = cull_point; cull->stage.line = cull_line; - cull->stage.tri = cull_tri; - cull->stage.end = cull_end; + cull->stage.tri = cull_first_tri; + cull->stage.flush = cull_flush; cull->stage.reset_stipple_counter = cull_reset_stipple_counter; cull->stage.destroy = cull_destroy; diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c index 8444c53310..1419f287d2 100644 --- a/src/mesa/pipe/draw/draw_flatshade.c +++ b/src/mesa/pipe/draw/draw_flatshade.c @@ -50,25 +50,6 @@ flat_stage(struct draw_stage *stage) } -static void flatshade_begin( struct draw_stage *stage ) -{ - struct flat_stage *flat = flat_stage(stage); - const struct pipe_shader_state *vs = stage->draw->vertex_shader->state; - uint i; - - /* Find which vertex shader outputs are colors, make a list */ - flat->num_color_attribs = 0; - for (i = 0; i < vs->num_outputs; i++) { - if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR || - vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) { - flat->color_attribs[flat->num_color_attribs++] = i; - } - } - - stage->next->begin( stage->next ); -} - - /** Copy all the color attributes from 'src' vertex to 'dst' vertex */ static INLINE void copy_colors( struct draw_stage *stage, struct vertex_header *dst, @@ -144,9 +125,46 @@ static void flatshade_point( struct draw_stage *stage, } -static void flatshade_end( struct draw_stage *stage ) +static void flatshade_init_state( struct draw_stage *stage ) +{ + struct flat_stage *flat = flat_stage(stage); + const struct pipe_shader_state *vs = stage->draw->vertex_shader->state; + uint i; + + /* Find which vertex shader outputs are colors, make a list */ + flat->num_color_attribs = 0; + for (i = 0; i < vs->num_outputs; i++) { + if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR || + vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) { + flat->color_attribs[flat->num_color_attribs++] = i; + } + } + + stage->line = flatshade_line; + stage->tri = flatshade_tri; +} + +static void flatshade_first_tri( struct draw_stage *stage, + struct prim_header *header ) +{ + flatshade_init_state( stage ); + stage->tri( stage, header ); +} + +static void flatshade_first_line( struct draw_stage *stage, + struct prim_header *header ) +{ + flatshade_init_state( stage ); + stage->line( stage, header ); +} + + +static void flatshade_flush( struct draw_stage *stage, + unsigned flags ) { - stage->next->end( stage->next ); + stage->tri = flatshade_first_tri; + stage->line = flatshade_first_line; + stage->next->flush( stage->next, flags ); } @@ -174,11 +192,10 @@ struct draw_stage *draw_flatshade_stage( struct draw_context *draw ) flatshade->stage.draw = draw; flatshade->stage.next = NULL; - flatshade->stage.begin = flatshade_begin; flatshade->stage.point = flatshade_point; - flatshade->stage.line = flatshade_line; - flatshade->stage.tri = flatshade_tri; - flatshade->stage.end = flatshade_end; + flatshade->stage.line = flatshade_first_line; + flatshade->stage.tri = flatshade_first_tri; + flatshade->stage.flush = flatshade_flush; flatshade->stage.reset_stipple_counter = flatshade_reset_stipple_counter; flatshade->stage.destroy = flatshade_destroy; diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c index f8a01db3dd..a2990ee8a8 100644 --- a/src/mesa/pipe/draw/draw_offset.c +++ b/src/mesa/pipe/draw/draw_offset.c @@ -52,16 +52,7 @@ static INLINE struct offset_stage *offset_stage( struct draw_stage *stage ) } -static void offset_begin( struct draw_stage *stage ) -{ - struct offset_stage *offset = offset_stage(stage); - float mrd = 1.0f / 65535.0f; /* XXX this depends on depthbuffer bits! */ - offset->units = stage->draw->rasterizer->offset_units * mrd; - offset->scale = stage->draw->rasterizer->offset_scale; - - stage->next->begin( stage->next ); -} /** @@ -124,24 +115,39 @@ static void offset_tri( struct draw_stage *stage, } +static void offset_first_tri( struct draw_stage *stage, + struct prim_header *header ) +{ + struct offset_stage *offset = offset_stage(stage); + float mrd = 1.0f / 65535.0f; /* XXX this depends on depthbuffer bits! */ + + offset->units = stage->draw->rasterizer->offset_units * mrd; + offset->scale = stage->draw->rasterizer->offset_scale; + + stage->tri = offset_tri; + stage->tri( stage, header ); +} + static void offset_line( struct draw_stage *stage, - struct prim_header *header ) + struct prim_header *header ) { stage->next->line( stage->next, header ); } static void offset_point( struct draw_stage *stage, - struct prim_header *header ) + struct prim_header *header ) { stage->next->point( stage->next, header ); } -static void offset_end( struct draw_stage *stage ) +static void offset_flush( struct draw_stage *stage, + unsigned flags ) { - stage->next->end( stage->next ); + stage->tri = offset_first_tri; + stage->next->flush( stage->next, flags ); } @@ -169,11 +175,10 @@ struct draw_stage *draw_offset_stage( struct draw_context *draw ) offset->stage.draw = draw; offset->stage.next = NULL; - offset->stage.begin = offset_begin; offset->stage.point = offset_point; offset->stage.line = offset_line; - offset->stage.tri = offset_tri; - offset->stage.end = offset_end; + offset->stage.tri = offset_first_tri; + offset->stage.flush = offset_flush; offset->stage.reset_stipple_counter = offset_reset_stipple_counter; offset->stage.destroy = offset_destroy; diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c index f8fc23b510..5703f5f0b0 100644 --- a/src/mesa/pipe/draw/draw_prim.c +++ b/src/mesa/pipe/draw/draw_prim.c @@ -57,7 +57,7 @@ static unsigned reduced_prim[PIPE_PRIM_POLYGON + 1] = { static void draw_prim_queue_flush( struct draw_context *draw ) { - struct draw_stage *first = draw->pipeline.first; + // struct draw_stage *first = draw->pipeline.first; unsigned i; if (0) @@ -69,27 +69,31 @@ static void draw_prim_queue_flush( struct draw_context *draw ) if (draw->vs.queue_nr) draw_vertex_shader_queue_flush(draw); + /* NOTE: we cannot save draw->pipeline->first in a local var because + * draw->pipeline->first is often changed by the first call to tri(), + * line(), etc. + */ switch (draw->reduced_prim) { case RP_TRI: for (i = 0; i < draw->pq.queue_nr; i++) { if (draw->pq.queue[i].reset_line_stipple) - first->reset_stipple_counter( first ); + draw->pipeline.first->reset_stipple_counter( draw->pipeline.first ); - first->tri( first, &draw->pq.queue[i] ); + draw->pipeline.first->tri( draw->pipeline.first, &draw->pq.queue[i] ); } break; case RP_LINE: for (i = 0; i < draw->pq.queue_nr; i++) { if (draw->pq.queue[i].reset_line_stipple) - first->reset_stipple_counter( first ); + draw->pipeline.first->reset_stipple_counter( draw->pipeline.first ); - first->line( first, &draw->pq.queue[i] ); + draw->pipeline.first->line( draw->pipeline.first, &draw->pq.queue[i] ); } break; case RP_POINT: - first->reset_stipple_counter( first ); + draw->pipeline.first->reset_stipple_counter( draw->pipeline.first ); for (i = 0; i < draw->pq.queue_nr; i++) - first->point( first, &draw->pq.queue[i] ); + draw->pipeline.first->point( draw->pipeline.first, &draw->pq.queue[i] ); break; } @@ -119,7 +123,7 @@ void draw_do_flush( struct draw_context *draw, if ((flush & DRAW_FLUSH_DRAW) && draw->drawing) { - draw->pipeline.first->end( draw->pipeline.first ); + draw->pipeline.first->flush( draw->pipeline.first, ~0 ); draw->drawing = FALSE; draw->prim = ~0; draw->pipeline.first = draw->pipeline.validate; @@ -415,9 +419,6 @@ draw_arrays(struct draw_context *draw, unsigned prim, { if (!draw->drawing) { draw->drawing = TRUE; - - /* tell drawing pipeline we're beginning drawing */ - draw->pipeline.first->begin( draw->pipeline.first ); } if (draw->prim != prim) { diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index 685ec4a644..e393fa5fe2 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -101,8 +101,6 @@ struct draw_stage struct vertex_header **tmp; /**< temp vert storage, such as for clipping */ unsigned nr_tmps; - void (*begin)( struct draw_stage * ); - void (*point)( struct draw_stage *, struct prim_header * ); @@ -112,7 +110,8 @@ struct draw_stage void (*tri)( struct draw_stage *, struct prim_header * ); - void (*end)( struct draw_stage * ); + void (*flush)( struct draw_stage *, + unsigned flags ); void (*reset_stipple_counter)( struct draw_stage * ); diff --git a/src/mesa/pipe/draw/draw_stipple.c b/src/mesa/pipe/draw/draw_stipple.c index 2a47eb7be2..9029101916 100644 --- a/src/mesa/pipe/draw/draw_stipple.c +++ b/src/mesa/pipe/draw/draw_stipple.c @@ -173,7 +173,8 @@ reset_stipple_counter(struct draw_stage *stage) static void -stipple_begin(struct draw_stage *stage) +stipple_first_line(struct draw_stage *stage, + struct prim_header *header) { struct stipple_stage *stipple = stipple_stage(stage); struct draw_context *draw = stage->draw; @@ -181,14 +182,16 @@ stipple_begin(struct draw_stage *stage) stipple->pattern = draw->rasterizer->line_stipple_pattern; stipple->factor = draw->rasterizer->line_stipple_factor + 1; - stage->next->begin( stage->next ); + stage->line = stipple_line; + stage->line( stage, header ); } static void -stipple_end(struct draw_stage *stage) +stipple_flush(struct draw_stage *stage, unsigned flags) { - stage->next->end( stage->next ); + stage->line = stipple_first_line; + stage->next->flush( stage->next, flags ); } @@ -224,12 +227,11 @@ struct draw_stage *draw_stipple_stage( struct draw_context *draw ) stipple->stage.draw = draw; stipple->stage.next = NULL; - stipple->stage.begin = stipple_begin; stipple->stage.point = passthrough_point; - stipple->stage.line = stipple_line; + stipple->stage.line = stipple_first_line; stipple->stage.tri = passthrough_tri; stipple->stage.reset_stipple_counter = reset_stipple_counter; - stipple->stage.end = stipple_end; + stipple->stage.flush = stipple_flush; stipple->stage.destroy = stipple_destroy; return &stipple->stage; diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c index 75c51ec6a9..ad2aaf10bb 100644 --- a/src/mesa/pipe/draw/draw_twoside.c +++ b/src/mesa/pipe/draw/draw_twoside.c @@ -48,48 +48,6 @@ static INLINE struct twoside_stage *twoside_stage( struct draw_stage *stage ) } -static void twoside_begin( struct draw_stage *stage ) -{ - struct twoside_stage *twoside = twoside_stage(stage); - const struct pipe_shader_state *vs = stage->draw->vertex_shader->state; - uint i; - - twoside->attrib_front0 = 0; - twoside->attrib_front1 = 0; - twoside->attrib_back0 = 0; - twoside->attrib_back1 = 0; - - /* Find which vertex shader outputs are front/back colors */ - for (i = 0; i < vs->num_outputs; i++) { - if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) { - if (vs->output_semantic_index[i] == 0) - twoside->attrib_front0 = i; - else - twoside->attrib_front1 = i; - } - if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) { - if (vs->output_semantic_index[i] == 0) - twoside->attrib_back0 = i; - else - twoside->attrib_back1 = i; - } - } - - if (!twoside->attrib_back0) - twoside->attrib_front0 = 0; - - if (!twoside->attrib_back1) - twoside->attrib_front1 = 0; - - /* - * We'll multiply the primitive's determinant by this sign to determine - * if the triangle is back-facing (negative). - * sign = -1 for CCW, +1 for CW - */ - twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f; - - stage->next->begin( stage->next ); -} /** @@ -157,10 +115,56 @@ static void twoside_point( struct draw_stage *stage, } -static void twoside_end( struct draw_stage *stage ) +static void twoside_first_tri( struct draw_stage *stage, + struct prim_header *header ) { - /* pass-through */ - stage->next->end( stage->next ); + struct twoside_stage *twoside = twoside_stage(stage); + const struct pipe_shader_state *vs = stage->draw->vertex_shader->state; + uint i; + + twoside->attrib_front0 = 0; + twoside->attrib_front1 = 0; + twoside->attrib_back0 = 0; + twoside->attrib_back1 = 0; + + /* Find which vertex shader outputs are front/back colors */ + for (i = 0; i < vs->num_outputs; i++) { + if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) { + if (vs->output_semantic_index[i] == 0) + twoside->attrib_front0 = i; + else + twoside->attrib_front1 = i; + } + if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) { + if (vs->output_semantic_index[i] == 0) + twoside->attrib_back0 = i; + else + twoside->attrib_back1 = i; + } + } + + if (!twoside->attrib_back0) + twoside->attrib_front0 = 0; + + if (!twoside->attrib_back1) + twoside->attrib_front1 = 0; + + /* + * We'll multiply the primitive's determinant by this sign to determine + * if the triangle is back-facing (negative). + * sign = -1 for CCW, +1 for CW + */ + twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f; + + stage->tri = twoside_tri; + stage->tri( stage, header ); +} + + +static void twoside_flush( struct draw_stage *stage, unsigned flags ) +{ + stage->tri = twoside_first_tri; + stage->next->flush( stage->next, flags ); } @@ -188,11 +192,10 @@ struct draw_stage *draw_twoside_stage( struct draw_context *draw ) twoside->stage.draw = draw; twoside->stage.next = NULL; - twoside->stage.begin = twoside_begin; twoside->stage.point = twoside_point; twoside->stage.line = twoside_line; - twoside->stage.tri = twoside_tri; - twoside->stage.end = twoside_end; + twoside->stage.tri = twoside_first_tri; + twoside->stage.flush = twoside_flush; twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter; twoside->stage.destroy = twoside_destroy; diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c index 786826b33c..364bda8b79 100644 --- a/src/mesa/pipe/draw/draw_unfilled.c +++ b/src/mesa/pipe/draw/draw_unfilled.c @@ -55,15 +55,6 @@ static INLINE struct unfilled_stage *unfilled_stage( struct draw_stage *stage ) } -static void unfilled_begin( struct draw_stage *stage ) -{ - struct unfilled_stage *unfilled = unfilled_stage(stage); - - unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */ - unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */ - - stage->next->begin( stage->next ); -} static void point( struct draw_stage *stage, struct vertex_header *v0 ) @@ -142,6 +133,20 @@ static void unfilled_tri( struct draw_stage *stage, } } + +static void unfilled_first_tri( struct draw_stage *stage, + struct prim_header *header ) +{ + struct unfilled_stage *unfilled = unfilled_stage(stage); + + unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */ + unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */ + + stage->tri = unfilled_tri; + stage->tri( stage, header ); +} + + static void unfilled_line( struct draw_stage *stage, struct prim_header *header ) { @@ -156,9 +161,10 @@ static void unfilled_point( struct draw_stage *stage, } -static void unfilled_end( struct draw_stage *stage ) +static void unfilled_flush( struct draw_stage *stage, + unsigned flags ) { - stage->next->end( stage->next ); + stage->next->flush( stage->next, flags ); } @@ -187,11 +193,10 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw ) unfilled->stage.draw = draw; unfilled->stage.next = NULL; unfilled->stage.tmp = NULL; - unfilled->stage.begin = unfilled_begin; unfilled->stage.point = unfilled_point; unfilled->stage.line = unfilled_line; - unfilled->stage.tri = unfilled_tri; - unfilled->stage.end = unfilled_end; + unfilled->stage.tri = unfilled_first_tri; + unfilled->stage.flush = unfilled_flush; unfilled->stage.reset_stipple_counter = unfilled_reset_stipple_counter; unfilled->stage.destroy = unfilled_destroy; diff --git a/src/mesa/pipe/draw/draw_validate.c b/src/mesa/pipe/draw/draw_validate.c index 3b1f5179a9..a626fb1fba 100644 --- a/src/mesa/pipe/draw/draw_validate.c +++ b/src/mesa/pipe/draw/draw_validate.c @@ -39,7 +39,7 @@ /** * Rebuild the rendering pipeline. */ -static void validate_begin( struct draw_stage *stage ) +static struct draw_stage *validate_pipeline( struct draw_stage *stage ) { struct draw_context *draw = stage->draw; struct draw_stage *next = draw->pipeline.rasterize; @@ -106,7 +106,45 @@ static void validate_begin( struct draw_stage *stage ) } draw->pipeline.first = next; - draw->pipeline.first->begin( draw->pipeline.first ); + //BP draw->pipeline.first->begin( draw->pipeline.first ); + return next; +} + + +static void validate_tri( struct draw_stage *stage, + struct prim_header *header ) +{ + struct draw_stage *pipeline = validate_pipeline( stage ); + pipeline->tri( pipeline, header ); +} + +static void validate_line( struct draw_stage *stage, + struct prim_header *header ) +{ + struct draw_stage *pipeline = validate_pipeline( stage ); + pipeline->line( pipeline, header ); +} + +static void validate_point( struct draw_stage *stage, + struct prim_header *header ) +{ + struct draw_stage *pipeline = validate_pipeline( stage ); + pipeline->point( pipeline, header ); +} + +static void validate_reset_stipple_counter( struct draw_stage *stage ) +{ + struct draw_stage *pipeline = validate_pipeline( stage ); + pipeline->reset_stipple_counter( pipeline ); +} + +static void validate_flush( struct draw_stage *stage, + unsigned flags ) +{ + /* May need to pass a backend flush on to the rasterize stage. + */ + if (stage->next) + stage->next->flush( stage->next, flags ); } @@ -124,13 +162,13 @@ struct draw_stage *draw_validate_stage( struct draw_context *draw ) struct draw_stage *stage = CALLOC_STRUCT(draw_stage); stage->draw = draw; + stage->next = NULL; - stage->begin = validate_begin; - stage->point = NULL; - stage->line = NULL; - stage->tri = NULL; - stage->end = NULL; - stage->reset_stipple_counter = NULL; + stage->point = validate_point; + stage->line = validate_line; + stage->tri = validate_tri; + stage->flush = validate_flush; + stage->reset_stipple_counter = validate_reset_stipple_counter; stage->destroy = validate_destroy; return stage; diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index 82051d2e65..d827f51d56 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -395,7 +395,7 @@ vbuf_begin( struct draw_stage *stage ) static void -vbuf_end( struct draw_stage *stage ) +vbuf_flush( struct draw_stage *stage, unsigned flags ) { // vbuf_flush_indices( stage ); /* XXX: Overkill */ @@ -432,11 +432,10 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw, struct vbuf_stage *vbuf = CALLOC_STRUCT(vbuf_stage); vbuf->stage.draw = draw; - 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.flush = vbuf_flush; vbuf->stage.reset_stipple_counter = vbuf_reset_stipple_counter; vbuf->stage.destroy = vbuf_destroy; diff --git a/src/mesa/pipe/draw/draw_wide_prims.c b/src/mesa/pipe/draw/draw_wide_prims.c index f71a38efba..26f5d10dc0 100644 --- a/src/mesa/pipe/draw/draw_wide_prims.c +++ b/src/mesa/pipe/draw/draw_wide_prims.c @@ -262,26 +262,19 @@ static void wide_point( struct draw_stage *stage, } -static void wide_begin( struct draw_stage *stage ) +static void wide_first_point( struct draw_stage *stage, + struct prim_header *header ) { struct wide_stage *wide = wide_stage(stage); struct draw_context *draw = stage->draw; wide->half_point_size = 0.5f * draw->rasterizer->point_size; - wide->half_line_width = 0.5f * draw->rasterizer->line_width; - - if (draw->rasterizer->line_width != 1.0) { - wide->stage.line = wide_line; - } - else { - wide->stage.line = passthrough_line; - } if (draw->rasterizer->point_size != 1.0) { - wide->stage.point = wide_point; + stage->point = wide_point; } else { - wide->stage.point = passthrough_point; + stage->point = passthrough_point; } if (draw->rasterizer->point_sprite) { @@ -299,6 +292,7 @@ static void wide_begin( struct draw_stage *stage ) } wide->psize_slot = -1; + if (draw->rasterizer->point_size_per_vertex) { /* find PSIZ vertex output */ const struct draw_vertex_shader *vs = draw->vertex_shader; @@ -311,13 +305,35 @@ static void wide_begin( struct draw_stage *stage ) } } - stage->next->begin( stage->next ); + stage->point( stage, header ); +} + + + +static void wide_first_line( struct draw_stage *stage, + struct prim_header *header ) +{ + struct wide_stage *wide = wide_stage(stage); + struct draw_context *draw = stage->draw; + + wide->half_line_width = 0.5f * draw->rasterizer->line_width; + + if (draw->rasterizer->line_width != 1.0) { + wide->stage.line = wide_line; + } + else { + wide->stage.line = passthrough_line; + } + + stage->line( stage, header ); } -static void wide_end( struct draw_stage *stage ) +static void wide_flush( struct draw_stage *stage, unsigned flags ) { - stage->next->end( stage->next ); + stage->line = wide_first_line; + stage->point = wide_first_point; + stage->next->flush( stage->next, flags ); } @@ -342,11 +358,10 @@ struct draw_stage *draw_wide_stage( struct draw_context *draw ) wide->stage.draw = draw; wide->stage.next = NULL; - wide->stage.begin = wide_begin; - wide->stage.point = wide_point; - wide->stage.line = wide_line; + wide->stage.point = wide_first_point; + wide->stage.line = wide_first_line; wide->stage.tri = passthrough_tri; - wide->stage.end = wide_end; + wide->stage.flush = wide_flush; wide->stage.reset_stipple_counter = draw_reset_stipple_counter; wide->stage.destroy = wide_destroy; diff --git a/src/mesa/pipe/i915simple/i915_prim_emit.c b/src/mesa/pipe/i915simple/i915_prim_emit.c index f74671b39c..c4a706c37d 100644 --- a/src/mesa/pipe/i915simple/i915_prim_emit.c +++ b/src/mesa/pipe/i915simple/i915_prim_emit.c @@ -180,13 +180,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim) } - -static void setup_begin( struct draw_stage *stage ) -{ -} - - -static void setup_end( struct draw_stage *stage ) +static void setup_flush( struct draw_stage *stage, unsigned flags ) { } @@ -210,11 +204,10 @@ struct draw_stage *i915_draw_render_stage( struct i915_context *i915 ) setup->i915 = i915; setup->stage.draw = i915->draw; - setup->stage.begin = setup_begin; setup->stage.point = setup_point; setup->stage.line = setup_line; setup->stage.tri = setup_tri; - setup->stage.end = setup_end; + setup->stage.flush = setup_flush; setup->stage.reset_stipple_counter = reset_stipple_counter; setup->stage.destroy = render_destroy; diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c index 423c91d4b8..71a303a8b5 100644 --- a/src/mesa/pipe/softpipe/sp_draw_arrays.c +++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c @@ -142,21 +142,18 @@ softpipe_draw_elements(struct pipe_context *pipe, /* draw! */ draw_arrays(draw, mode, start, count); - /* always flush for now */ - draw_flush(draw); - /* - * unmap vertex/index buffers + * unmap vertex/index buffers - will cause draw module to flush */ for (i = 0; i < PIPE_ATTRIB_MAX; i++) { if (sp->vertex_buffer[i].buffer) { - pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); + pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer); } } if (indexBuffer) { - pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); draw_set_mapped_element_buffer(draw, 0, NULL); + pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer); } diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 478ecff2fb..088d8a4c07 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -1170,11 +1170,43 @@ static void setup_begin( struct draw_stage *stage ) setup->quad.nr_attrs = fs->num_inputs; sp->quad.first->begin(sp->quad.first); + + stage->point = setup_point; + stage->line = setup_line; + stage->tri = setup_tri; } -static void setup_end( struct draw_stage *stage ) +static void setup_first_point( struct draw_stage *stage, + struct prim_header *header ) +{ + setup_begin(stage); + stage->point( stage, header ); +} + +static void setup_first_line( struct draw_stage *stage, + struct prim_header *header ) +{ + setup_begin(stage); + stage->line( stage, header ); +} + + +static void setup_first_tri( struct draw_stage *stage, + struct prim_header *header ) +{ + setup_begin(stage); + stage->tri( stage, header ); +} + + + +static void setup_flush( struct draw_stage *stage, + unsigned flags ) { + stage->point = setup_first_point; + stage->line = setup_first_line; + stage->tri = setup_first_tri; } @@ -1198,11 +1230,10 @@ struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe ) setup->softpipe = softpipe; setup->stage.draw = softpipe->draw; - setup->stage.begin = setup_begin; - setup->stage.point = setup_point; - setup->stage.line = setup_line; - setup->stage.tri = setup_tri; - setup->stage.end = setup_end; + setup->stage.point = setup_first_point; + setup->stage.line = setup_first_line; + setup->stage.tri = setup_first_tri; + setup->stage.flush = setup_flush; setup->stage.reset_stipple_counter = reset_stipple_counter; setup->stage.destroy = render_destroy; diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.c b/src/mesa/pipe/softpipe/sp_prim_vbuf.c index dfabae8302..c9089e7eb2 100644 --- a/src/mesa/pipe/softpipe/sp_prim_vbuf.c +++ b/src/mesa/pipe/softpipe/sp_prim_vbuf.c @@ -149,8 +149,6 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr_indices) prim.edgeflags = 0; prim.pad = 0; - setup->begin( setup ); - switch (cvbr->prim) { case PIPE_PRIM_TRIANGLES: for (i = 0; i < nr_indices; i += 3) { @@ -182,7 +180,7 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr_indices) break; } - setup->end( setup ); + setup->flush( setup, 0 ); } diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 43543df1a8..31744151f1 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -159,14 +159,7 @@ feedback_point( struct draw_stage *stage, struct prim_header *prim ) static void -feedback_end( struct draw_stage *stage ) -{ - /* no-op */ -} - - -static void -feedback_begin( struct draw_stage *stage ) +feedback_flush( struct draw_stage *stage, unsigned flags ) { /* no-op */ } @@ -190,11 +183,10 @@ draw_glfeedback_stage(GLcontext *ctx, struct draw_context *draw) fs->stage.draw = draw; fs->stage.next = NULL; - fs->stage.begin = feedback_begin; fs->stage.point = feedback_point; fs->stage.line = feedback_line; fs->stage.tri = feedback_tri; - fs->stage.end = feedback_end; + fs->stage.flush = feedback_flush; fs->stage.reset_stipple_counter = feedback_reset_stipple_counter; fs->ctx = ctx; @@ -234,14 +226,7 @@ select_point( struct draw_stage *stage, struct prim_header *prim ) static void -select_begin( struct draw_stage *stage ) -{ - /* no-op */ -} - - -static void -select_end( struct draw_stage *stage ) +select_flush( struct draw_stage *stage, unsigned flags ) { /* no-op */ } @@ -264,11 +249,10 @@ draw_glselect_stage(GLcontext *ctx, struct draw_context *draw) fs->stage.draw = draw; fs->stage.next = NULL; - fs->stage.begin = select_begin; fs->stage.point = select_point; fs->stage.line = select_line; fs->stage.tri = select_tri; - fs->stage.end = select_end; + fs->stage.flush = select_flush; fs->stage.reset_stipple_counter = select_reset_stipple_counter; fs->ctx = ctx; diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 9e20e94dc7..7e347c4893 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -73,13 +73,7 @@ rastpos_stage( struct draw_stage *stage ) } static void -rastpos_begin( struct draw_stage *stage ) -{ - /* no-op */ -} - -static void -rastpos_end( struct draw_stage *stage ) +rastpos_flush( struct draw_stage *stage, unsigned flags ) { /* no-op */ } @@ -183,11 +177,10 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw) rs->stage.draw = draw; rs->stage.next = NULL; - rs->stage.begin = rastpos_begin; rs->stage.point = rastpos_point; rs->stage.line = rastpos_line; rs->stage.tri = rastpos_tri; - rs->stage.end = rastpos_end; + rs->stage.flush = rastpos_flush; rs->stage.destroy = rastpos_destroy; rs->stage.reset_stipple_counter = rastpos_reset_stipple_counter; rs->stage.destroy = rastpos_destroy; -- cgit v1.2.3 From 6acd63a4980951727939c0dd545a0324965b3834 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 15 Feb 2008 17:50:12 +0900 Subject: Code reorganization: update build. Update the Makefiles and includes for the new paths. Note that there hasn't been no separation of the Makefiles yet, and make is jumping all over the place. That will be taken care shortly. But for now, make should work. It was tested with linux and linux-dri. Linux-cell and linux-llvm might require some minor tweaks. --- configs/beos | 2 +- configs/darwin | 2 +- configs/darwin-x86ppc | 2 +- configs/default | 2 +- configs/freebsd-dri | 2 +- configs/linux-cell | 2 +- configs/linux-directfb | 2 +- configs/linux-dri | 6 +- configs/linux-dri-xcb | 4 +- configs/linux-fbdev | 2 +- configs/linux-osmesa | 2 +- configs/linux-osmesa16 | 2 +- configs/linux-osmesa16-static | 2 +- configs/linux-osmesa32 | 2 +- configs/linux-solo | 2 +- src/gallium/Makefile | 12 +-- src/gallium/Makefile.template | 7 +- src/gallium/aux/Makefile | 24 +++++ src/gallium/aux/draw/draw_private.h | 2 +- src/gallium/aux/draw/draw_vertex.c | 4 +- src/gallium/aux/draw/draw_vertex_shader.c | 4 +- src/gallium/aux/llvm/Makefile | 4 +- src/gallium/aux/llvm/gallivm.cpp | 4 +- src/gallium/aux/llvm/gallivm_cpu.cpp | 4 +- src/gallium/aux/llvm/tgsitollvm.cpp | 10 +- src/gallium/aux/pipebuffer/Makefile | 2 +- src/gallium/aux/tgsi/exec/tgsi_exec.c | 4 +- src/gallium/aux/tgsi/exec/tgsi_sse2.c | 4 +- src/gallium/aux/tgsi/util/tgsi_transform.h | 4 +- src/gallium/drivers/Makefile | 24 +++++ src/gallium/drivers/cell/ppu/Makefile | 7 +- src/gallium/drivers/cell/ppu/cell_clear.c | 2 +- src/gallium/drivers/cell/ppu/cell_context.c | 6 +- src/gallium/drivers/cell/ppu/cell_context.h | 6 +- src/gallium/drivers/cell/ppu/cell_draw_arrays.c | 2 +- src/gallium/drivers/cell/ppu/cell_flush.c | 2 +- src/gallium/drivers/cell/ppu/cell_render.c | 2 +- src/gallium/drivers/cell/ppu/cell_spu.c | 2 +- src/gallium/drivers/cell/ppu/cell_spu.h | 2 +- src/gallium/drivers/cell/ppu/cell_state_blend.c | 2 +- src/gallium/drivers/cell/ppu/cell_state_clip.c | 2 +- src/gallium/drivers/cell/ppu/cell_state_derived.c | 4 +- src/gallium/drivers/cell/ppu/cell_state_fs.c | 8 +- .../drivers/cell/ppu/cell_state_rasterizer.c | 2 +- src/gallium/drivers/cell/ppu/cell_state_sampler.c | 2 +- src/gallium/drivers/cell/ppu/cell_state_vertex.c | 2 +- src/gallium/drivers/cell/ppu/cell_surface.c | 2 +- src/gallium/drivers/cell/ppu/cell_vbuf.c | 2 +- src/gallium/drivers/cell/ppu/cell_vertex_shader.c | 6 +- src/gallium/drivers/cell/spu/Makefile | 6 +- src/gallium/drivers/cell/spu/spu_exec.c | 4 +- src/gallium/drivers/cell/spu/spu_exec.h | 2 +- src/gallium/drivers/cell/spu/spu_main.c | 2 +- src/gallium/drivers/cell/spu/spu_main.h | 4 +- src/gallium/drivers/cell/spu/spu_render.c | 2 +- src/gallium/drivers/cell/spu/spu_render.h | 2 +- src/gallium/drivers/cell/spu/spu_tile.h | 2 +- src/gallium/drivers/cell/spu/spu_util.c | 4 +- src/gallium/drivers/cell/spu/spu_vertex_shader.c | 6 +- src/gallium/drivers/failover/Makefile | 2 +- src/gallium/drivers/i915simple/Makefile | 2 +- src/gallium/drivers/i915simple/i915_context.c | 2 +- src/gallium/drivers/i915simple/i915_context.h | 2 +- .../drivers/i915simple/i915_fpc_translate.c | 4 +- src/gallium/drivers/i915simple/i915_prim_emit.c | 2 +- src/gallium/drivers/i915simple/i915_prim_vbuf.c | 2 +- src/gallium/drivers/i915simple/i915_state.c | 2 +- .../drivers/i915simple/i915_state_derived.c | 4 +- src/gallium/drivers/i915simple/i915_strings.c | 2 +- src/gallium/drivers/i915simple/i915_surface.c | 2 +- src/gallium/drivers/i965simple/Makefile | 2 +- src/gallium/drivers/i965simple/brw_shader_info.c | 2 +- src/gallium/drivers/i965simple/brw_state.c | 2 +- src/gallium/drivers/i965simple/brw_strings.c | 2 +- src/gallium/drivers/i965simple/brw_surface.c | 2 +- src/gallium/drivers/i965simple/brw_vs_emit.c | 2 +- src/gallium/drivers/i965simple/brw_wm_decl.c | 2 +- src/gallium/drivers/i965simple/brw_wm_glsl.c | 2 +- src/gallium/drivers/softpipe/Makefile | 2 +- src/gallium/drivers/softpipe/sp_context.c | 2 +- src/gallium/drivers/softpipe/sp_context.h | 2 +- src/gallium/drivers/softpipe/sp_draw_arrays.c | 2 +- src/gallium/drivers/softpipe/sp_flush.c | 2 +- src/gallium/drivers/softpipe/sp_headers.h | 2 +- src/gallium/drivers/softpipe/sp_prim_setup.c | 4 +- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 6 +- src/gallium/drivers/softpipe/sp_quad_fs.c | 2 +- src/gallium/drivers/softpipe/sp_query.c | 2 +- src/gallium/drivers/softpipe/sp_state_clip.c | 2 +- src/gallium/drivers/softpipe/sp_state_derived.c | 6 +- src/gallium/drivers/softpipe/sp_state_fs.c | 8 +- src/gallium/drivers/softpipe/sp_state_rasterizer.c | 2 +- src/gallium/drivers/softpipe/sp_state_sampler.c | 4 +- src/gallium/drivers/softpipe/sp_state_vertex.c | 2 +- src/gallium/drivers/softpipe/sp_surface.c | 2 +- src/gallium/drivers/softpipe/sp_tex_sample.c | 2 +- src/gallium/drivers/softpipe/sp_tile_cache.c | 2 +- src/gallium/winsys/dri/Makefile | 38 +++++++ src/gallium/winsys/dri/Makefile.template | 113 +++++++++++++++++++++ src/gallium/winsys/dri/intel/Makefile | 8 +- src/gallium/winsys/dri/intel/intel_winsys_i915.c | 2 +- .../winsys/dri/intel/intel_winsys_softpipe.c | 2 +- src/gallium/winsys/xlib/xm_winsys.c | 6 +- src/gallium/winsys/xlib/xm_winsys_aub.c | 2 +- src/mesa/Makefile | 16 ++- src/mesa/drivers/x11/xm_api.c | 2 +- src/mesa/drivers/x11/xm_dd.c | 2 +- src/mesa/drivers/x11/xm_surface.c | 8 +- src/mesa/drivers/x11/xm_winsys.c | 2 +- src/mesa/drivers/x11/xmesaP.h | 4 +- src/mesa/sources | 83 +++++++-------- src/mesa/state_tracker/st_atom_shader.c | 2 +- src/mesa/state_tracker/st_cache.c | 4 +- src/mesa/state_tracker/st_cache.h | 2 +- src/mesa/state_tracker/st_cb_accum.c | 2 +- src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/state_tracker/st_cb_feedback.c | 6 +- src/mesa/state_tracker/st_cb_program.c | 4 +- src/mesa/state_tracker/st_cb_rasterpos.c | 4 +- src/mesa/state_tracker/st_cb_readpixels.c | 2 +- src/mesa/state_tracker/st_cb_texture.c | 2 +- src/mesa/state_tracker/st_context.c | 4 +- src/mesa/state_tracker/st_debug.c | 4 +- src/mesa/state_tracker/st_draw.c | 4 +- src/mesa/state_tracker/st_gen_mipmap.c | 2 +- src/mesa/state_tracker/st_mesa_to_tgsi.c | 6 +- src/mesa/state_tracker/st_program.c | 4 +- 127 files changed, 445 insertions(+), 241 deletions(-) create mode 100644 src/gallium/aux/Makefile create mode 100644 src/gallium/drivers/Makefile create mode 100644 src/gallium/winsys/dri/Makefile create mode 100644 src/gallium/winsys/dri/Makefile.template (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/configs/beos b/configs/beos index f07973d0c7..2b74af739d 100644 --- a/configs/beos +++ b/configs/beos @@ -86,7 +86,7 @@ else endif # Directories -SRC_DIRS = mesa glu glut/beos +SRC_DIRS = gallium mesa glu glut/beos GLU_DIRS = sgi DRIVER_DIRS = beos PROGRAM_DIRS = beos samples redbook demos tests diff --git a/configs/darwin b/configs/darwin index 7826ecc605..bba7802696 100644 --- a/configs/darwin +++ b/configs/darwin @@ -25,5 +25,5 @@ GLW_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXt $(TOP)/lib/GL.dylib APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm # omit glw lib for now: -SRC_DIRS = mesa glu glut/glx +SRC_DIRS = gallium mesa glu glut/glx diff --git a/configs/darwin-x86ppc b/configs/darwin-x86ppc index 13172327a7..ebeb25051f 100644 --- a/configs/darwin-x86ppc +++ b/configs/darwin-x86ppc @@ -29,5 +29,5 @@ GLW_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXt $(TOP)/lib/GL.dylib APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm # omit glw lib for now: -SRC_DIRS = mesa glu glut/glx +SRC_DIRS = gallium mesa glu glut/glx diff --git a/configs/default b/configs/default index 166205a1d3..25a87e66a1 100644 --- a/configs/default +++ b/configs/default @@ -60,7 +60,7 @@ GLW_SOURCES = GLwDrawA.c # Directories to build LIB_DIR = lib -SRC_DIRS = mesa glu glut/glx glw +SRC_DIRS = gallium mesa glu glut/glx glw GLU_DIRS = sgi DRIVER_DIRS = x11 osmesa # Which subdirs under $(TOP)/progs/ to enter: diff --git a/configs/freebsd-dri b/configs/freebsd-dri index 402883d1de..67d253b869 100644 --- a/configs/freebsd-dri +++ b/configs/freebsd-dri @@ -36,7 +36,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/X11R6/lib -lGL -lXt -lX11 # Directories -SRC_DIRS = glx/x11 mesa glu glut/glx glw +SRC_DIRS = glx/x11 gallium mesa glu glut/glx glw DRIVER_DIRS = dri PROGRAM_DIRS = WINDOW_SYSTEM=dri diff --git a/configs/linux-cell b/configs/linux-cell index 3d874491e4..fdf20deeeb 100644 --- a/configs/linux-cell +++ b/configs/linux-cell @@ -21,7 +21,7 @@ CFLAGS = $(OPT_FLAGS) -Wall -Winline -fPIC -m32 -mabi=altivec -maltivec -I. -I$( CXXFLAGS = $(CFLAGS) # Omitting glw here: -SRC_DIRS = mesa glu glut/glx +SRC_DIRS = gallium mesa glu glut/glx MKDEP_OPTIONS = -fdepend -Y diff --git a/configs/linux-directfb b/configs/linux-directfb index 09332f4808..dff27f7850 100644 --- a/configs/linux-directfb +++ b/configs/linux-directfb @@ -22,7 +22,7 @@ ifeq ($(HAVE_X86), yes) endif # Directories -SRC_DIRS = mesa glu glut/directfb +SRC_DIRS = gallium mesa glu glut/directfb GLU_DIRS = sgi DRIVER_DIRS = directfb PROGRAM_DIRS = demos directfb diff --git a/configs/linux-dri b/configs/linux-dri index 936fce9982..e6135856fc 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -54,10 +54,10 @@ USING_EGL=0 # Directories ifeq ($(USING_EGL), 1) -SRC_DIRS = egl glx/x11 mesa glu glut/glx glw +SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glw PROGRAM_DIRS = egl else -SRC_DIRS = glx/x11 mesa glu glut/glx glw +SRC_DIRS = glx/x11 gallium mesa glu glut/glx glw PROGRAM_DIRS = endif @@ -66,4 +66,4 @@ WINDOW_SYSTEM=dri # gamma are missing because they have not been converted to use the new # interface. -DRI_DIRS = intel_winsys +DRI_DIRS = intel diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb index aa292a13ec..ea4bdf1864 100644 --- a/configs/linux-dri-xcb +++ b/configs/linux-dri-xcb @@ -53,10 +53,10 @@ USING_EGL=0 # Directories ifeq ($(USING_EGL), 1) -SRC_DIRS = egl glx/x11 mesa glu glut/glx glw +SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glw PROGRAM_DIRS = egl else -SRC_DIRS = glx/x11 mesa glu glut/glx glw +SRC_DIRS = glx/x11 gallium mesa glu glut/glx glw PROGRAM_DIRS = endif diff --git a/configs/linux-fbdev b/configs/linux-fbdev index e36d20a702..1ddccb3f52 100644 --- a/configs/linux-fbdev +++ b/configs/linux-fbdev @@ -6,7 +6,7 @@ CONFIG_NAME = linux-fbdev CFLAGS = -O3 -ffast-math -ansi -pedantic -fPIC -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS -DUSE_GLFBDEV_DRIVER -SRC_DIRS = mesa glu glut/fbdev +SRC_DIRS = gallium mesa glu glut/fbdev DRIVER_DIRS = fbdev osmesa PROGRAM_DIRS = fbdev demos redbook samples diff --git a/configs/linux-osmesa b/configs/linux-osmesa index cc1fbbd109..0382a19553 100644 --- a/configs/linux-osmesa +++ b/configs/linux-osmesa @@ -14,7 +14,7 @@ CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOUR # Directories -SRC_DIRS = mesa glu +SRC_DIRS = gallium mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = osdemos diff --git a/configs/linux-osmesa16 b/configs/linux-osmesa16 index 1fb0186d31..9a527592f1 100644 --- a/configs/linux-osmesa16 +++ b/configs/linux-osmesa16 @@ -17,7 +17,7 @@ OSMESA_LIB_NAME = libOSMesa16.so # Directories -SRC_DIRS = mesa glu +SRC_DIRS = gallium mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = diff --git a/configs/linux-osmesa16-static b/configs/linux-osmesa16-static index 6645504478..1e6380b02e 100644 --- a/configs/linux-osmesa16-static +++ b/configs/linux-osmesa16-static @@ -18,7 +18,7 @@ OSMESA_LIB_NAME = libOSMesa16.a # Directories -SRC_DIRS = mesa glu +SRC_DIRS = gallium mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = diff --git a/configs/linux-osmesa32 b/configs/linux-osmesa32 index a1e5a358d6..f0ef1831b0 100644 --- a/configs/linux-osmesa32 +++ b/configs/linux-osmesa32 @@ -17,7 +17,7 @@ OSMESA_LIB_NAME = libOSMesa32.so # Directories -SRC_DIRS = mesa glu +SRC_DIRS = gallium mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = diff --git a/configs/linux-solo b/configs/linux-solo index 220fe58b9a..d49b972228 100644 --- a/configs/linux-solo +++ b/configs/linux-solo @@ -43,7 +43,7 @@ GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lpthread # Directories -SRC_DIRS = glx/mini mesa glu glut/mini +SRC_DIRS = glx/mini gallium mesa glu glut/mini DRIVER_DIRS = dri PROGRAM_DIRS = miniglx diff --git a/src/gallium/Makefile b/src/gallium/Makefile index d880d090c1..a13b9a52d3 100644 --- a/src/gallium/Makefile +++ b/src/gallium/Makefile @@ -1,16 +1,8 @@ -TOP = ../../.. +TOP = ../.. include $(TOP)/configs/current -ifeq ($(CONFIG_NAME), linux-cell) -CELL_DIR = cell -endif - -ifeq ($(CONFIG_NAME), linux-llvm) -LLVM_DIR = llvm -endif - -SUBDIRS = softpipe i915simple i965simple failover pipebuffer $(CELL_DIR) $(LLVM_DIR) +SUBDIRS = aux drivers default: subdirs diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 8e84f8eb2d..0717ed8dd2 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -15,7 +15,10 @@ OBJECTS = $(C_SOURCES:.c=.o) \ ### Include directories INCLUDES = \ -I. \ - -I$(TOP)/src/mesa/pipe \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/include/pipe \ + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/drivers \ -I$(TOP)/src/mesa \ -I$(TOP)/include \ $(DRIVER_INCLUDES) @@ -38,7 +41,7 @@ INCLUDES = \ default: depend symlinks $(LIBNAME) -$(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/mesa/pipe/Makefile.template +$(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template $(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS) diff --git a/src/gallium/aux/Makefile b/src/gallium/aux/Makefile new file mode 100644 index 0000000000..da68498aa1 --- /dev/null +++ b/src/gallium/aux/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +include $(TOP)/configs/current + + +ifeq ($(CONFIG_NAME), linux-llvm) +LLVM_DIR = llvm +endif + +SUBDIRS = pipebuffer $(LLVM_DIR) + + +default: subdirs + + +subdirs: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE)) || exit 1 ; \ + fi \ + done + + +clean: + rm -f `find . -name \*.[oa]` diff --git a/src/gallium/aux/draw/draw_private.h b/src/gallium/aux/draw/draw_private.h index b17eaaed65..3d09aef87c 100644 --- a/src/gallium/aux/draw/draw_private.h +++ b/src/gallium/aux/draw/draw_private.h @@ -45,7 +45,7 @@ #include "pipe/p_defines.h" #include "x86/rtasm/x86sse.h" -#include "pipe/tgsi/exec/tgsi_exec.h" +#include "tgsi/exec/tgsi_exec.h" struct gallivm_prog; diff --git a/src/gallium/aux/draw/draw_vertex.c b/src/gallium/aux/draw/draw_vertex.c index 2d6592150f..daf1ef4b80 100644 --- a/src/gallium/aux/draw/draw_vertex.c +++ b/src/gallium/aux/draw/draw_vertex.c @@ -34,8 +34,8 @@ */ -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_private.h" +#include "draw/draw_vertex.h" /** diff --git a/src/gallium/aux/draw/draw_vertex_shader.c b/src/gallium/aux/draw/draw_vertex_shader.c index c824c1407e..377ecbb931 100644 --- a/src/gallium/aux/draw/draw_vertex_shader.c +++ b/src/gallium/aux/draw/draw_vertex_shader.c @@ -34,13 +34,13 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" #if defined(__i386__) || defined(__386__) -#include "pipe/tgsi/exec/tgsi_sse2.h" +#include "tgsi/exec/tgsi_sse2.h" #endif #include "draw_private.h" #include "draw_context.h" #include "x86/rtasm/x86sse.h" -#include "pipe/llvm/gallivm.h" +#include "llvm/gallivm.h" #define DBG_VS 0 diff --git a/src/gallium/aux/llvm/Makefile b/src/gallium/aux/llvm/Makefile index 9c6e16d86b..e6ac399d08 100644 --- a/src/gallium/aux/llvm/Makefile +++ b/src/gallium/aux/llvm/Makefile @@ -30,7 +30,9 @@ OBJECTS = $(C_SOURCES:.c=.o) \ ### Include directories INCLUDES = \ -I. \ - -I$(TOP)/src/mesa/pipe \ + -I$(TOP)/src/gallium/drivers + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/include \ -I$(TOP)/src/mesa \ -I$(TOP)/include diff --git a/src/gallium/aux/llvm/gallivm.cpp b/src/gallium/aux/llvm/gallivm.cpp index da0105c2c9..d14bb3b99a 100644 --- a/src/gallium/aux/llvm/gallivm.cpp +++ b/src/gallium/aux/llvm/gallivm.cpp @@ -42,8 +42,8 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/exec/tgsi_exec.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/exec/tgsi_exec.h" +#include "tgsi/util/tgsi_dump.h" #include #include diff --git a/src/gallium/aux/llvm/gallivm_cpu.cpp b/src/gallium/aux/llvm/gallivm_cpu.cpp index dc4d92a72a..8f9830d0b1 100644 --- a/src/gallium/aux/llvm/gallivm_cpu.cpp +++ b/src/gallium/aux/llvm/gallivm_cpu.cpp @@ -42,8 +42,8 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/exec/tgsi_exec.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/exec/tgsi_exec.h" +#include "tgsi/util/tgsi_dump.h" #include #include diff --git a/src/gallium/aux/llvm/tgsitollvm.cpp b/src/gallium/aux/llvm/tgsitollvm.cpp index 0de595e678..2cb4acce32 100644 --- a/src/gallium/aux/llvm/tgsitollvm.cpp +++ b/src/gallium/aux/llvm/tgsitollvm.cpp @@ -10,11 +10,11 @@ #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/exec/tgsi_exec.h" -#include "pipe/tgsi/util/tgsi_util.h" -#include "pipe/tgsi/util/tgsi_build.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/exec/tgsi_exec.h" +#include "tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_build.h" +#include "tgsi/util/tgsi_dump.h" #include diff --git a/src/gallium/aux/pipebuffer/Makefile b/src/gallium/aux/pipebuffer/Makefile index 75764a9a18..588629e870 100644 --- a/src/gallium/aux/pipebuffer/Makefile +++ b/src/gallium/aux/pipebuffer/Makefile @@ -17,7 +17,7 @@ C_SOURCES = \ ASM_SOURCES = -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/aux/tgsi/exec/tgsi_exec.c b/src/gallium/aux/tgsi/exec/tgsi_exec.c index 37e6007068..a8f64c2287 100644 --- a/src/gallium/aux/tgsi/exec/tgsi_exec.c +++ b/src/gallium/aux/tgsi/exec/tgsi_exec.c @@ -54,8 +54,8 @@ #include "pipe/p_state.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_util.h" #include "tgsi_exec.h" #define TILE_TOP_LEFT 0 diff --git a/src/gallium/aux/tgsi/exec/tgsi_sse2.c b/src/gallium/aux/tgsi/exec/tgsi_sse2.c index 1e56e4afb6..593464db3e 100755 --- a/src/gallium/aux/tgsi/exec/tgsi_sse2.c +++ b/src/gallium/aux/tgsi/exec/tgsi_sse2.c @@ -27,8 +27,8 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_util.h" #include "tgsi_exec.h" #include "tgsi_sse2.h" diff --git a/src/gallium/aux/tgsi/util/tgsi_transform.h b/src/gallium/aux/tgsi/util/tgsi_transform.h index 365d8c298c..fcf85d603b 100644 --- a/src/gallium/aux/tgsi/util/tgsi_transform.h +++ b/src/gallium/aux/tgsi/util/tgsi_transform.h @@ -31,8 +31,8 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_build.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_build.h" diff --git a/src/gallium/drivers/Makefile b/src/gallium/drivers/Makefile new file mode 100644 index 0000000000..c0345a9cb5 --- /dev/null +++ b/src/gallium/drivers/Makefile @@ -0,0 +1,24 @@ +TOP = ../../.. +include $(TOP)/configs/current + + +ifeq ($(CONFIG_NAME), linux-cell) +CELL_DIR = cell +endif + +SUBDIRS = softpipe i915simple i965simple failover pipebuffer $(CELL_DIR) + + +default: subdirs + + +subdirs: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE)) || exit 1 ; \ + fi \ + done + + +clean: + rm -f `find . -name \*.[oa]` diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile index 50060f5cd3..011863c11e 100644 --- a/src/gallium/drivers/cell/ppu/Makefile +++ b/src/gallium/drivers/cell/ppu/Makefile @@ -40,8 +40,11 @@ SOURCES = \ OBJECTS = $(SOURCES:.c=.o) \ -INCLUDE_DIRS = -I$(TOP)/src/mesa - +INCLUDE_DIRS = \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/drivers .c.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c index 07b908eec5..e588a30d5b 100644 --- a/src/gallium/drivers/cell/ppu/cell_clear.c +++ b/src/gallium/drivers/cell/ppu/cell_clear.c @@ -35,7 +35,7 @@ #include #include "pipe/p_inlines.h" #include "pipe/p_util.h" -#include "pipe/cell/common.h" +#include "cell/common.h" #include "cell_clear.h" #include "cell_context.h" #include "cell_batch.h" diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c index bbe1fd7a11..e1eb22f468 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.c +++ b/src/gallium/drivers/cell/ppu/cell_context.c @@ -37,9 +37,9 @@ #include "pipe/p_format.h" #include "pipe/p_util.h" #include "pipe/p_winsys.h" -#include "pipe/cell/common.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" +#include "cell/common.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" #include "cell_clear.h" #include "cell_context.h" #include "cell_draw_arrays.h" diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h index 3b63419b5e..6196c0c72f 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.h +++ b/src/gallium/drivers/cell/ppu/cell_context.h @@ -32,10 +32,10 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "pipe/draw/draw_vertex.h" -#include "pipe/draw/draw_vbuf.h" +#include "draw/draw_vertex.h" +#include "draw/draw_vbuf.h" #include "cell_winsys.h" -#include "pipe/cell/common.h" +#include "cell/common.h" struct cell_vbuf_render; diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index 717cd8370f..f12613649b 100644 --- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c +++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c @@ -39,7 +39,7 @@ #include "cell_draw_arrays.h" #include "cell_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" diff --git a/src/gallium/drivers/cell/ppu/cell_flush.c b/src/gallium/drivers/cell/ppu/cell_flush.c index f62bc4650c..20f27531fc 100644 --- a/src/gallium/drivers/cell/ppu/cell_flush.c +++ b/src/gallium/drivers/cell/ppu/cell_flush.c @@ -31,7 +31,7 @@ #include "cell_flush.h" #include "cell_spu.h" #include "cell_render.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void diff --git a/src/gallium/drivers/cell/ppu/cell_render.c b/src/gallium/drivers/cell/ppu/cell_render.c index 4ab277a4b2..b663b37622 100644 --- a/src/gallium/drivers/cell/ppu/cell_render.c +++ b/src/gallium/drivers/cell/ppu/cell_render.c @@ -34,7 +34,7 @@ #include "cell_render.h" #include "cell_spu.h" #include "pipe/p_util.h" -#include "pipe/draw/draw_private.h" +#include "draw/draw_private.h" struct render_stage { diff --git a/src/gallium/drivers/cell/ppu/cell_spu.c b/src/gallium/drivers/cell/ppu/cell_spu.c index 7c83a47e57..419e74dc40 100644 --- a/src/gallium/drivers/cell/ppu/cell_spu.c +++ b/src/gallium/drivers/cell/ppu/cell_spu.c @@ -31,7 +31,7 @@ #include "cell_spu.h" #include "pipe/p_format.h" #include "pipe/p_state.h" -#include "pipe/cell/common.h" +#include "cell/common.h" /* diff --git a/src/gallium/drivers/cell/ppu/cell_spu.h b/src/gallium/drivers/cell/ppu/cell_spu.h index 19eff94f96..137f26612e 100644 --- a/src/gallium/drivers/cell/ppu/cell_spu.h +++ b/src/gallium/drivers/cell/ppu/cell_spu.h @@ -31,7 +31,7 @@ #include #include -#include "pipe/cell/common.h" +#include "cell/common.h" #include "cell_context.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_blend.c b/src/gallium/drivers/cell/ppu/cell_state_blend.c index 4fc60548c8..b6d6d71f0c 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_blend.c +++ b/src/gallium/drivers/cell/ppu/cell_state_blend.c @@ -29,7 +29,7 @@ */ #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "cell_context.h" #include "cell_state.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_clip.c b/src/gallium/drivers/cell/ppu/cell_state_clip.c index 4f43665941..0482f87e88 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_clip.c +++ b/src/gallium/drivers/cell/ppu/cell_state_clip.c @@ -30,7 +30,7 @@ #include "cell_context.h" #include "cell_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void cell_set_clip_state( struct pipe_context *pipe, diff --git a/src/gallium/drivers/cell/ppu/cell_state_derived.c b/src/gallium/drivers/cell/ppu/cell_state_derived.c index 56daf5dfde..0c46829258 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_derived.c +++ b/src/gallium/drivers/cell/ppu/cell_state_derived.c @@ -27,8 +27,8 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_context.h" +#include "draw/draw_vertex.h" #include "cell_context.h" #include "cell_batch.h" #include "cell_state.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_fs.c b/src/gallium/drivers/cell/ppu/cell_state_fs.c index 3f46a87d18..b2ed699a5b 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_fs.c +++ b/src/gallium/drivers/cell/ppu/cell_state_fs.c @@ -29,12 +29,12 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #if 0 #include "pipe/p_shader_tokens.h" -#include "pipe/llvm/gallivm.h" -#include "pipe/tgsi/util/tgsi_dump.h" -#include "pipe/tgsi/exec/tgsi_sse2.h" +#include "llvm/gallivm.h" +#include "tgsi/util/tgsi_dump.h" +#include "tgsi/exec/tgsi_sse2.h" #endif #include "cell_context.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c b/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c index d8128ece54..7eca5b5765 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c +++ b/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c @@ -27,7 +27,7 @@ #include "pipe/p_defines.h" #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "cell_context.h" #include "cell_state.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_sampler.c b/src/gallium/drivers/cell/ppu/cell_state_sampler.c index ade6cc8338..a33421a4ad 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_sampler.c +++ b/src/gallium/drivers/cell/ppu/cell_state_sampler.c @@ -30,7 +30,7 @@ */ #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "cell_context.h" #include "cell_state.h" #include "cell_texture.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_vertex.c b/src/gallium/drivers/cell/ppu/cell_state_vertex.c index 0f01e920f9..563831b62d 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_vertex.c +++ b/src/gallium/drivers/cell/ppu/cell_state_vertex.c @@ -32,7 +32,7 @@ #include "cell_context.h" #include "cell_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void diff --git a/src/gallium/drivers/cell/ppu/cell_surface.c b/src/gallium/drivers/cell/ppu/cell_surface.c index fca93e4742..a35db0ef99 100644 --- a/src/gallium/drivers/cell/ppu/cell_surface.c +++ b/src/gallium/drivers/cell/ppu/cell_surface.c @@ -29,7 +29,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "cell_context.h" #include "cell_surface.h" diff --git a/src/gallium/drivers/cell/ppu/cell_vbuf.c b/src/gallium/drivers/cell/ppu/cell_vbuf.c index e9fafe492e..cc727ff4ed 100644 --- a/src/gallium/drivers/cell/ppu/cell_vbuf.c +++ b/src/gallium/drivers/cell/ppu/cell_vbuf.c @@ -36,7 +36,7 @@ #include "cell_flush.h" #include "cell_spu.h" #include "cell_vbuf.h" -#include "pipe/draw/draw_vbuf.h" +#include "draw/draw_vbuf.h" /** Allow vertex data to be inlined after RENDER command */ diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c index 80dd500b34..0ba4506505 100644 --- a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c +++ b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c @@ -38,9 +38,9 @@ #include "cell_spu.h" #include "cell_batch.h" -#include "pipe/cell/common.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" +#include "cell/common.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" /** * Run the vertex shader on all vertices in the vertex queue. diff --git a/src/gallium/drivers/cell/spu/Makefile b/src/gallium/drivers/cell/spu/Makefile index f202971d73..7aa947299e 100644 --- a/src/gallium/drivers/cell/spu/Makefile +++ b/src/gallium/drivers/cell/spu/Makefile @@ -31,7 +31,11 @@ SPU_OBJECTS = $(SOURCES:.c=.o) \ SPU_ASM_OUT = $(SOURCES:.c=.s) \ -INCLUDE_DIRS = -I$(TOP)/src/mesa +INCLUDE_DIRS = \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/drivers .c.o: diff --git a/src/gallium/drivers/cell/spu/spu_exec.c b/src/gallium/drivers/cell/spu/spu_exec.c index e51008b9b3..109540b1f7 100644 --- a/src/gallium/drivers/cell/spu/spu_exec.c +++ b/src/gallium/drivers/cell/spu/spu_exec.c @@ -67,8 +67,8 @@ #include "pipe/p_state.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_util.h" #include "spu_exec.h" #include "spu_main.h" #include "spu_vertex_shader.h" diff --git a/src/gallium/drivers/cell/spu/spu_exec.h b/src/gallium/drivers/cell/spu/spu_exec.h index b4c7661ef6..3e17c490d2 100644 --- a/src/gallium/drivers/cell/spu/spu_exec.h +++ b/src/gallium/drivers/cell/spu/spu_exec.h @@ -29,7 +29,7 @@ #define SPU_EXEC_H #include "pipe/p_compiler.h" -#include "pipe/tgsi/exec/tgsi_exec.h" +#include "tgsi/exec/tgsi_exec.h" #if defined __cplusplus extern "C" { diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c index e375197fe6..1e7243b863 100644 --- a/src/gallium/drivers/cell/spu/spu_main.c +++ b/src/gallium/drivers/cell/spu/spu_main.c @@ -38,7 +38,7 @@ #include "spu_tile.h" //#include "spu_test.h" #include "spu_vertex_shader.h" -#include "pipe/cell/common.h" +#include "cell/common.h" #include "pipe/p_defines.h" diff --git a/src/gallium/drivers/cell/spu/spu_main.h b/src/gallium/drivers/cell/spu/spu_main.h index 1710a17512..5c95d112ac 100644 --- a/src/gallium/drivers/cell/spu/spu_main.h +++ b/src/gallium/drivers/cell/spu/spu_main.h @@ -31,8 +31,8 @@ #include -#include "pipe/cell/common.h" -#include "pipe/draw/draw_vertex.h" +#include "cell/common.h" +#include "draw/draw_vertex.h" #include "pipe/p_state.h" diff --git a/src/gallium/drivers/cell/spu/spu_render.c b/src/gallium/drivers/cell/spu/spu_render.c index 932fb500b3..20e77aa2e6 100644 --- a/src/gallium/drivers/cell/spu/spu_render.c +++ b/src/gallium/drivers/cell/spu/spu_render.c @@ -34,7 +34,7 @@ #include "spu_render.h" #include "spu_tri.h" #include "spu_tile.h" -#include "pipe/cell/common.h" +#include "cell/common.h" diff --git a/src/gallium/drivers/cell/spu/spu_render.h b/src/gallium/drivers/cell/spu/spu_render.h index fbcdc5ec31..493434f087 100644 --- a/src/gallium/drivers/cell/spu/spu_render.h +++ b/src/gallium/drivers/cell/spu/spu_render.h @@ -29,7 +29,7 @@ #ifndef SPU_RENDER_H #define SPU_RENDER_H -#include "pipe/cell/common.h" +#include "cell/common.h" extern void cmd_render(const struct cell_command_render *render, uint *pos_incr); diff --git a/src/gallium/drivers/cell/spu/spu_tile.h b/src/gallium/drivers/cell/spu/spu_tile.h index e53340a55a..3105b848fd 100644 --- a/src/gallium/drivers/cell/spu/spu_tile.h +++ b/src/gallium/drivers/cell/spu/spu_tile.h @@ -32,7 +32,7 @@ #include #include #include "spu_main.h" -#include "pipe/cell/common.h" +#include "cell/common.h" diff --git a/src/gallium/drivers/cell/spu/spu_util.c b/src/gallium/drivers/cell/spu/spu_util.c index ac373240c1..ea4274a0a7 100644 --- a/src/gallium/drivers/cell/spu/spu_util.c +++ b/src/gallium/drivers/cell/spu/spu_util.c @@ -1,8 +1,8 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" //#include "tgsi_build.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_util.h" unsigned tgsi_util_get_src_register_swizzle( diff --git a/src/gallium/drivers/cell/spu/spu_vertex_shader.c b/src/gallium/drivers/cell/spu/spu_vertex_shader.c index c1cbbb6d1e..3f5bf41aa2 100644 --- a/src/gallium/drivers/cell/spu/spu_vertex_shader.c +++ b/src/gallium/drivers/cell/spu/spu_vertex_shader.c @@ -39,9 +39,9 @@ #include "pipe/p_shader_tokens.h" #include "spu_vertex_shader.h" #include "spu_exec.h" -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_context.h" -#include "pipe/cell/common.h" +#include "draw/draw_private.h" +#include "draw/draw_context.h" +#include "cell/common.h" #include "spu_main.h" static INLINE unsigned diff --git a/src/gallium/drivers/failover/Makefile b/src/gallium/drivers/failover/Makefile index 72d0895c74..14389bd055 100644 --- a/src/gallium/drivers/failover/Makefile +++ b/src/gallium/drivers/failover/Makefile @@ -15,7 +15,7 @@ C_SOURCES = \ ASM_SOURCES = -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/drivers/i915simple/Makefile b/src/gallium/drivers/i915simple/Makefile index 2f91de3afc..ee22ba86f9 100644 --- a/src/gallium/drivers/i915simple/Makefile +++ b/src/gallium/drivers/i915simple/Makefile @@ -32,7 +32,7 @@ C_SOURCES = \ ASM_SOURCES = -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c index 497623a700..7f71f8fd4f 100644 --- a/src/gallium/drivers/i915simple/i915_context.c +++ b/src/gallium/drivers/i915simple/i915_context.c @@ -32,7 +32,7 @@ #include "i915_texture.h" #include "i915_reg.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" #include "pipe/p_util.h" diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h index b4ea63c3e7..2d876925b2 100644 --- a/src/gallium/drivers/i915simple/i915_context.h +++ b/src/gallium/drivers/i915simple/i915_context.h @@ -33,7 +33,7 @@ #include "pipe/p_defines.h" #include "pipe/p_state.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_vertex.h" #define I915_TEX_UNITS 8 diff --git a/src/gallium/drivers/i915simple/i915_fpc_translate.c b/src/gallium/drivers/i915simple/i915_fpc_translate.c index 868f0c7e04..6c1524c768 100644 --- a/src/gallium/drivers/i915simple/i915_fpc_translate.c +++ b/src/gallium/drivers/i915simple/i915_fpc_translate.c @@ -33,9 +33,9 @@ #include "i915_fpc.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_vertex.h" /** diff --git a/src/gallium/drivers/i915simple/i915_prim_emit.c b/src/gallium/drivers/i915simple/i915_prim_emit.c index c4a706c37d..44c4325936 100644 --- a/src/gallium/drivers/i915simple/i915_prim_emit.c +++ b/src/gallium/drivers/i915simple/i915_prim_emit.c @@ -26,7 +26,7 @@ **************************************************************************/ -#include "pipe/draw/draw_private.h" +#include "draw/draw_private.h" #include "pipe/p_util.h" #include "i915_context.h" diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c index e069773fd4..c5bf6174f6 100644 --- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c +++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c @@ -38,7 +38,7 @@ */ -#include "pipe/draw/draw_vbuf.h" +#include "draw/draw_vbuf.h" #include "pipe/p_debug.h" #include "pipe/p_util.h" #include "pipe/p_inlines.h" diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c index abd5571b88..294e6fad03 100644 --- a/src/gallium/drivers/i915simple/i915_state.c +++ b/src/gallium/drivers/i915simple/i915_state.c @@ -29,7 +29,7 @@ */ -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_winsys.h" #include "pipe/p_util.h" diff --git a/src/gallium/drivers/i915simple/i915_state_derived.c b/src/gallium/drivers/i915simple/i915_state_derived.c index 653983e4a9..4767584fc6 100644 --- a/src/gallium/drivers/i915simple/i915_state_derived.c +++ b/src/gallium/drivers/i915simple/i915_state_derived.c @@ -27,8 +27,8 @@ #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_context.h" +#include "draw/draw_vertex.h" #include "i915_context.h" #include "i915_state.h" #include "i915_reg.h" diff --git a/src/gallium/drivers/i915simple/i915_strings.c b/src/gallium/drivers/i915simple/i915_strings.c index c713bf7208..301fedea19 100644 --- a/src/gallium/drivers/i915simple/i915_strings.c +++ b/src/gallium/drivers/i915simple/i915_strings.c @@ -70,7 +70,7 @@ static const char *i915_get_name( struct pipe_context *pipe ) break; } - sprintf(buffer, "pipe/i915 (chipset: %s)", chipset); + sprintf(buffer, "i915 (chipset: %s)", chipset); return buffer; } diff --git a/src/gallium/drivers/i915simple/i915_surface.c b/src/gallium/drivers/i915simple/i915_surface.c index de0cc5fe06..17fd27895a 100644 --- a/src/gallium/drivers/i915simple/i915_surface.c +++ b/src/gallium/drivers/i915simple/i915_surface.c @@ -33,7 +33,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" /* diff --git a/src/gallium/drivers/i965simple/Makefile b/src/gallium/drivers/i965simple/Makefile index 48c00ab50b..1dec1f9749 100644 --- a/src/gallium/drivers/i965simple/Makefile +++ b/src/gallium/drivers/i965simple/Makefile @@ -61,6 +61,6 @@ ASM_SOURCES = DRIVER_DEFINES = -I. -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/drivers/i965simple/brw_shader_info.c b/src/gallium/drivers/i965simple/brw_shader_info.c index 431b45466a..a762a870fe 100644 --- a/src/gallium/drivers/i965simple/brw_shader_info.c +++ b/src/gallium/drivers/i965simple/brw_shader_info.c @@ -3,7 +3,7 @@ #include "brw_state.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c index 95dfce88e4..f746d1cc57 100644 --- a/src/gallium/drivers/i965simple/brw_state.c +++ b/src/gallium/drivers/i965simple/brw_state.c @@ -33,7 +33,7 @@ #include "pipe/p_winsys.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/util/tgsi_dump.h" #include "brw_context.h" #include "brw_defines.h" diff --git a/src/gallium/drivers/i965simple/brw_strings.c b/src/gallium/drivers/i965simple/brw_strings.c index 29a41ed1e9..3d9c50961f 100644 --- a/src/gallium/drivers/i965simple/brw_strings.c +++ b/src/gallium/drivers/i965simple/brw_strings.c @@ -59,7 +59,7 @@ static const char *brw_get_name( struct pipe_context *pipe ) break; } - sprintf(buffer, "pipe/i965 (chipset: %s)", chipset); + sprintf(buffer, "i965 (chipset: %s)", chipset); return buffer; } diff --git a/src/gallium/drivers/i965simple/brw_surface.c b/src/gallium/drivers/i965simple/brw_surface.c index 518845e4b2..376a42b1a6 100644 --- a/src/gallium/drivers/i965simple/brw_surface.c +++ b/src/gallium/drivers/i965simple/brw_surface.c @@ -32,7 +32,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" /* diff --git a/src/gallium/drivers/i965simple/brw_vs_emit.c b/src/gallium/drivers/i965simple/brw_vs_emit.c index 98915ba101..05df4860ed 100644 --- a/src/gallium/drivers/i965simple/brw_vs_emit.c +++ b/src/gallium/drivers/i965simple/brw_vs_emit.c @@ -33,7 +33,7 @@ #include "brw_vs.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" struct brw_prog_info { unsigned num_temps; diff --git a/src/gallium/drivers/i965simple/brw_wm_decl.c b/src/gallium/drivers/i965simple/brw_wm_decl.c index b45a333a2e..97418a52e7 100644 --- a/src/gallium/drivers/i965simple/brw_wm_decl.c +++ b/src/gallium/drivers/i965simple/brw_wm_decl.c @@ -4,7 +4,7 @@ #include "brw_wm.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" static struct brw_reg alloc_tmp(struct brw_wm_compile *c) { diff --git a/src/gallium/drivers/i965simple/brw_wm_glsl.c b/src/gallium/drivers/i965simple/brw_wm_glsl.c index d95645d108..44f946ea74 100644 --- a/src/gallium/drivers/i965simple/brw_wm_glsl.c +++ b/src/gallium/drivers/i965simple/brw_wm_glsl.c @@ -4,7 +4,7 @@ #include "brw_wm.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_parse.h" diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile index 31438a882e..2304ea4246 100644 --- a/src/gallium/drivers/softpipe/Makefile +++ b/src/gallium/drivers/softpipe/Makefile @@ -44,7 +44,7 @@ C_SOURCES = \ ASM_SOURCES = -include ../Makefile.template +include ../../Makefile.template symlinks: diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index cea6b90104..5e98f190bb 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -29,7 +29,7 @@ * Keith Whitwell */ -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_util.h" diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index aff8c2cc5d..8c79cb3ce4 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -34,7 +34,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_vertex.h" #include "sp_quad.h" diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 71a303a8b5..2049afda34 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -38,7 +38,7 @@ #include "sp_context.h" #include "sp_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index ced0d5d098..2cbd0d7cab 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -31,7 +31,7 @@ #include "pipe/p_defines.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "sp_flush.h" #include "sp_context.h" #include "sp_surface.h" diff --git a/src/gallium/drivers/softpipe/sp_headers.h b/src/gallium/drivers/softpipe/sp_headers.h index 0ae31d8796..9cf8222133 100644 --- a/src/gallium/drivers/softpipe/sp_headers.h +++ b/src/gallium/drivers/softpipe/sp_headers.h @@ -31,7 +31,7 @@ #ifndef SP_HEADERS_H #define SP_HEADERS_H -#include "pipe/tgsi/exec/tgsi_exec.h" +#include "tgsi/exec/tgsi_exec.h" #define PRIM_POINT 1 #define PRIM_LINE 2 diff --git a/src/gallium/drivers/softpipe/sp_prim_setup.c b/src/gallium/drivers/softpipe/sp_prim_setup.c index 2772048661..d73521ccbe 100644 --- a/src/gallium/drivers/softpipe/sp_prim_setup.c +++ b/src/gallium/drivers/softpipe/sp_prim_setup.c @@ -38,8 +38,8 @@ #include "sp_quad.h" #include "sp_state.h" #include "sp_prim_setup.h" -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_vertex.h" +#include "draw/draw_private.h" +#include "draw/draw_vertex.h" #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 7f71fdb6a9..69bea8a8f5 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -39,9 +39,9 @@ #include "sp_context.h" #include "sp_state.h" #include "sp_prim_vbuf.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_vbuf.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" +#include "draw/draw_vbuf.h" #define SP_MAX_VBUF_INDEXES 1024 diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index 3316858413..b4c01a7ea8 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -42,7 +42,7 @@ #include "x86/rtasm/x86sse.h" #ifdef MESA_LLVM -#include "pipe/llvm/gallivm.h" +#include "llvm/gallivm.h" #endif #include "sp_context.h" diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c index 6a8a43aeda..adf9ccf64c 100644 --- a/src/gallium/drivers/softpipe/sp_query.c +++ b/src/gallium/drivers/softpipe/sp_query.c @@ -29,7 +29,7 @@ * Keith Whitwell */ -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_util.h" diff --git a/src/gallium/drivers/softpipe/sp_state_clip.c b/src/gallium/drivers/softpipe/sp_state_clip.c index 08c5f06d05..c797c0dd3b 100644 --- a/src/gallium/drivers/softpipe/sp_state_clip.c +++ b/src/gallium/drivers/softpipe/sp_state_clip.c @@ -29,7 +29,7 @@ */ #include "sp_context.h" #include "sp_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void softpipe_set_clip_state( struct pipe_context *pipe, diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c index 372597869f..9d8fd8b750 100644 --- a/src/gallium/drivers/softpipe/sp_state_derived.c +++ b/src/gallium/drivers/softpipe/sp_state_derived.c @@ -27,9 +27,9 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_vertex.h" -#include "pipe/draw/draw_private.h" +#include "draw/draw_context.h" +#include "draw/draw_vertex.h" +#include "draw/draw_private.h" #include "sp_context.h" #include "sp_state.h" diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index 0b814fc284..1e3cadd43d 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -32,11 +32,11 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "pipe/p_shader_tokens.h" -#include "pipe/llvm/gallivm.h" -#include "pipe/tgsi/util/tgsi_dump.h" -#include "pipe/tgsi/exec/tgsi_sse2.h" +#include "llvm/gallivm.h" +#include "tgsi/util/tgsi_dump.h" +#include "tgsi/exec/tgsi_sse2.h" void * diff --git a/src/gallium/drivers/softpipe/sp_state_rasterizer.c b/src/gallium/drivers/softpipe/sp_state_rasterizer.c index 53755099dd..98e04352db 100644 --- a/src/gallium/drivers/softpipe/sp_state_rasterizer.c +++ b/src/gallium/drivers/softpipe/sp_state_rasterizer.c @@ -29,7 +29,7 @@ #include "pipe/p_util.h" #include "sp_context.h" #include "sp_state.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index ea348c7e95..460adccec4 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -31,14 +31,14 @@ #include "pipe/p_util.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" #include "sp_context.h" #include "sp_context.h" #include "sp_state.h" #include "sp_texture.h" #include "sp_tile_cache.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" diff --git a/src/gallium/drivers/softpipe/sp_state_vertex.c b/src/gallium/drivers/softpipe/sp_state_vertex.c index 09ff540ccf..f01a10de3b 100644 --- a/src/gallium/drivers/softpipe/sp_state_vertex.c +++ b/src/gallium/drivers/softpipe/sp_state_vertex.c @@ -33,7 +33,7 @@ #include "sp_state.h" #include "sp_surface.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_context.h" void diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c index 8802ced187..653449c4f1 100644 --- a/src/gallium/drivers/softpipe/sp_surface.c +++ b/src/gallium/drivers/softpipe/sp_surface.c @@ -29,7 +29,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "sp_context.h" #include "sp_surface.h" diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 325bdb86da..2f82fd6abe 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -40,7 +40,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_util.h" -#include "pipe/tgsi/exec/tgsi_exec.h" +#include "tgsi/exec/tgsi_exec.h" /* diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 1597361b82..dde3fabc81 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -34,7 +34,7 @@ #include "pipe/p_util.h" #include "pipe/p_inlines.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "sp_context.h" #include "sp_surface.h" #include "sp_tile_cache.h" diff --git a/src/gallium/winsys/dri/Makefile b/src/gallium/winsys/dri/Makefile new file mode 100644 index 0000000000..f466ce6c3c --- /dev/null +++ b/src/gallium/winsys/dri/Makefile @@ -0,0 +1,38 @@ +# src/mesa/drivers/dri/Makefile + +TOP = ../../../.. + +include $(TOP)/configs/current + + + +default: $(TOP)/$(LIB_DIR) subdirs + + +$(TOP)/$(LIB_DIR): + -mkdir $(TOP)/$(LIB_DIR) + + +subdirs: + @for dir in $(DRI_DIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE)) || exit 1 ; \ + fi \ + done + + +install: + @for dir in $(DRI_DIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) install) || exit 1 ; \ + fi \ + done + + +clean: + @for dir in $(DRI_DIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) clean) ; \ + fi \ + done + -rm -f common/*.o diff --git a/src/gallium/winsys/dri/Makefile.template b/src/gallium/winsys/dri/Makefile.template new file mode 100644 index 0000000000..b96305c094 --- /dev/null +++ b/src/gallium/winsys/dri/Makefile.template @@ -0,0 +1,113 @@ +# -*-makefile-*- + +MESA_MODULES = $(TOP)/src/mesa/libmesa.a + +COMMON_GALLIUM_SOURCES = \ + $(TOP)/src/mesa/drivers/dri/common/utils.c \ + $(TOP)/src/mesa/drivers/dri/common/vblank.c \ + $(TOP)/src/mesa/drivers/dri/common/dri_util.c \ + $(TOP)/src/mesa/drivers/dri/common/xmlconfig.c + +COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \ + $(TOP)/src/mesa/drivers/common/driverfuncs.c \ + $(TOP)/src/mesa/drivers/dri/common/texmem.c \ + $(TOP)/src/mesa/drivers/dri/common/drirenderbuffer.c + +COMMON_BM_SOURCES = \ + $(TOP)/src/mesa/drivers/dri/common/dri_bufmgr.c \ + $(TOP)/src/mesa/drivers/dri/common/dri_drmpool.c + + +ifeq ($(WINDOW_SYSTEM),dri) +WINOBJ= +WINLIB= +INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES) + +OBJECTS = $(C_SOURCES:.c=.o) \ + $(ASM_SOURCES:.S=.o) + +else +# miniglx +WINOBJ= +WINLIB=-L$(MESA)/src/glx/mini +MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini +INCLUDES = $(MINIGLX_INCLUDES) \ + $(SHARED_INCLUDES) \ + $(PCIACCESS_CFLAGS) + +OBJECTS = $(C_SOURCES:.c=.o) \ + $(MINIGLX_SOURCES:.c=.o) \ + $(ASM_SOURCES:.S=.o) +endif + + +### Include directories +SHARED_INCLUDES = \ + -I. \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -Iserver \ + -I$(TOP)/include \ + -I$(TOP)/include/GL/internal \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/aux \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mesa/main \ + -I$(TOP)/src/mesa/glapi \ + -I$(TOP)/src/mesa/math \ + -I$(TOP)/src/mesa/transform \ + -I$(TOP)/src/mesa/shader \ + -I$(TOP)/src/mesa/swrast \ + -I$(TOP)/src/mesa/swrast_setup \ + -I$(TOP)/src/egl/main \ + -I$(TOP)/src/egl/drivers/dri \ + $(LIBDRM_CFLAGS) + + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + + +##### TARGETS ##### + +default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME) + + +$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template + $(TOP)/bin/mklib -noprefix -o $@ \ + $(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS) + + +$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) + $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) + + +depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS) + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \ + $(ASM_SOURCES) 2> /dev/null + + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` + + +# Remove .o and backup files +clean: + -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS) + -rm -f depend depend.bak + + +install: $(LIBNAME) + $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR) + $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR) + + +include depend diff --git a/src/gallium/winsys/dri/intel/Makefile b/src/gallium/winsys/dri/intel/Makefile index 9ae0f01325..40654bb2ac 100644 --- a/src/gallium/winsys/dri/intel/Makefile +++ b/src/gallium/winsys/dri/intel/Makefile @@ -7,8 +7,8 @@ LIBNAME = i915tex_dri.so MINIGLX_SOURCES = server/intel_dri.c PIPE_DRIVERS = \ - $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a \ - $(TOP)/src/mesa/pipe/i915simple/libi915simple.a + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/i915simple/libi915simple.a DRIVER_SOURCES = \ intel_winsys_pipe.c \ @@ -28,11 +28,11 @@ C_SOURCES = \ ASM_SOURCES = -DRIVER_DEFINES = -I../intel $(shell pkg-config libdrm --atleast-version=2.3.1 \ +DRIVER_DEFINES = -I$(TOP)/src/mesa/drivers/dri/intel $(shell pkg-config libdrm --atleast-version=2.3.1 \ && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP") include ../Makefile.template -intel_tex_layout.o: ../intel/intel_tex_layout.c +intel_tex_layout.o: $(TOP)/src/mesa/drivers/dri/intel/intel_tex_layout.c symlinks: diff --git a/src/gallium/winsys/dri/intel/intel_winsys_i915.c b/src/gallium/winsys/dri/intel/intel_winsys_i915.c index 1ba6a9e1b2..0ed3890e93 100644 --- a/src/gallium/winsys/dri/intel/intel_winsys_i915.c +++ b/src/gallium/winsys/dri/intel/intel_winsys_i915.c @@ -39,7 +39,7 @@ #include "intel_winsys.h" #include "pipe/p_util.h" -#include "pipe/i915simple/i915_winsys.h" +#include "i915simple/i915_winsys.h" struct intel_i915_winsys { diff --git a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c b/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c index cec3437831..9e483bdc9f 100644 --- a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c +++ b/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c @@ -34,7 +34,7 @@ #include "pipe/p_defines.h" #include "pipe/p_util.h" #include "pipe/p_format.h" -#include "pipe/softpipe/sp_winsys.h" +#include "softpipe/sp_winsys.h" struct intel_softpipe_winsys { diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xm_winsys.c index c3cd22eea3..8da596d419 100644 --- a/src/gallium/winsys/xlib/xm_winsys.c +++ b/src/gallium/winsys/xlib/xm_winsys.c @@ -41,11 +41,11 @@ #include "pipe/p_context.h" #include "pipe/p_util.h" #include "pipe/p_inlines.h" -#include "pipe/softpipe/sp_winsys.h" +#include "softpipe/sp_winsys.h" #ifdef GALLIUM_CELL -#include "pipe/cell/ppu/cell_context.h" -#include "pipe/cell/ppu/cell_winsys.h" +#include "cell/ppu/cell_context.h" +#include "cell/ppu/cell_winsys.h" #else #define TILE_SIZE 32 /* avoid compilation errors */ #endif diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.c b/src/gallium/winsys/xlib/xm_winsys_aub.c index bf41570257..dbfd37bda2 100644 --- a/src/gallium/winsys/xlib/xm_winsys_aub.c +++ b/src/gallium/winsys/xlib/xm_winsys_aub.c @@ -39,7 +39,7 @@ #include "pipe/p_winsys.h" #include "pipe/p_util.h" #include "pipe/p_inlines.h" -#include "pipe/i965simple/brw_winsys.h" +#include "i965simple/brw_winsys.h" #include "brw_aub.h" #include "xm_winsys_aub.h" diff --git a/src/mesa/Makefile b/src/mesa/Makefile index 720f1b2e02..561608fedd 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -12,16 +12,16 @@ GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY) PIPE_LIB = \ - $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a \ - $(TOP)/src/mesa/pipe/i965simple/libi965simple.a + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/i965simple/libi965simple.a ifeq ($(CONFIG_NAME), linux-cell) -CELL_LIB = $(TOP)/src/mesa/pipe/cell/ppu/libcell.a -CELL_LIB_SPU = $(TOP)/src/mesa/pipe/cell/spu/g3d_spu.a +CELL_LIB = $(TOP)/src/gallium/drivers/cell/ppu/libcell.a +CELL_LIB_SPU = $(TOP)/src/gallium/drivers/cell/spu/g3d_spu.a endif ifeq ($(CONFIG_NAME), linux-llvm) -LLVM_LIB = $(TOP)/src/mesa/pipe/llvm/libgallivm.a +LLVM_LIB = $(TOP)/src/gallium/aux/llvm/libgallivm.a endif .SUFFIXES : .cpp @@ -71,7 +71,7 @@ libmesa.a: $(SOLO_OBJECTS) fi linux-solo: depend subdirs libmesa.a - cd drivers/dri ; $(MAKE) + cd $(TOP)/src/gallium/winsys/dri ; $(MAKE) ##################################################################### @@ -165,7 +165,6 @@ depend: $(ALL_SOURCES) subdirs: @ (cd x86 ; $(MAKE)) @ (cd x86-64 ; $(MAKE)) - (cd pipe ; $(MAKE)) install: default $(INSTALL) -d $(INSTALL_DIR)/include/GL @@ -178,7 +177,7 @@ install: default $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(INSTALL_DIR)/$(LIB_DIR); \ fi @if [ "${DRIVER_DIRS}" = "dri" ] ; then \ - cd drivers/dri ; $(MAKE) install ; \ + cd $(TOP)/gallium/winsys/dri ; $(MAKE) install ; \ fi ## NOT INSTALLED YET: @@ -198,7 +197,6 @@ clean: (cd drivers/dri && $(MAKE) clean) (cd x86 && $(MAKE) clean) (cd x86-64 && $(MAKE) clean) - (cd pipe ; $(MAKE) clean ) include depend diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 08c98eab48..18b033666f 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -85,7 +85,7 @@ #include "state_tracker/st_public.h" #include "state_tracker/st_context.h" -#include "pipe/softpipe/sp_context.h" +#include "softpipe/sp_context.h" #include "pipe/p_defines.h" /** diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 8ae243ae66..34287effe1 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -53,7 +53,7 @@ #include "tnl/tnl.h" #include "tnl/t_context.h" -#include "pipe/softpipe/sp_context.h" +#include "softpipe/sp_context.h" #include "state_tracker/st_public.h" #include "state_tracker/st_context.h" #include "state_tracker/st_draw.h" diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index 5533158ece..81616b92d9 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -45,10 +45,10 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" -#include "pipe/softpipe/sp_context.h" -#include "pipe/softpipe/sp_clear.h" -#include "pipe/softpipe/sp_tile_cache.h" -#include "pipe/softpipe/sp_surface.h" +#include "softpipe/sp_context.h" +#include "softpipe/sp_clear.h" +#include "softpipe/sp_tile_cache.h" +#include "softpipe/sp_surface.h" #include "state_tracker/st_context.h" diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c index a690df2772..2edc697693 100644 --- a/src/mesa/drivers/x11/xm_winsys.c +++ b/src/mesa/drivers/x11/xm_winsys.c @@ -38,7 +38,7 @@ #include "main/macros.h" #include "pipe/p_winsys.h" -#include "pipe/softpipe/sp_winsys.h" +#include "softpipe/sp_winsys.h" /** diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 4709d63394..fd2dfcd79a 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -37,8 +37,8 @@ #include "xm_image.h" #endif #include "state_tracker/st_cb_fbo.h" -#include "pipe/softpipe/sp_context.h" -#include "pipe/softpipe/sp_surface.h" +#include "softpipe/sp_context.h" +#include "softpipe/sp_surface.h" extern _glthread_Mutex _xmesa_lock; diff --git a/src/mesa/sources b/src/mesa/sources index 1165425183..2d07738210 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -158,45 +158,45 @@ VF_SOURCES = \ DRAW_SOURCES = \ - pipe/draw/draw_clip.c \ - pipe/draw/draw_context.c\ - pipe/draw/draw_cull.c \ - pipe/draw/draw_debug.c \ - pipe/draw/draw_flatshade.c \ - pipe/draw/draw_offset.c \ - pipe/draw/draw_prim.c \ - pipe/draw/draw_stipple.c \ - pipe/draw/draw_twoside.c \ - pipe/draw/draw_unfilled.c \ - pipe/draw/draw_validate.c \ - pipe/draw/draw_vbuf.c \ - pipe/draw/draw_vertex.c \ - pipe/draw/draw_vertex_cache.c \ - pipe/draw/draw_vertex_fetch.c \ - pipe/draw/draw_vertex_shader.c \ - pipe/draw/draw_vf.c \ - pipe/draw/draw_vf_generic.c \ - pipe/draw/draw_vf_sse.c \ - pipe/draw/draw_wide_prims.c + $(TOP)/src/gallium/aux/draw/draw_clip.c \ + $(TOP)/src/gallium/aux/draw/draw_context.c\ + $(TOP)/src/gallium/aux/draw/draw_cull.c \ + $(TOP)/src/gallium/aux/draw/draw_debug.c \ + $(TOP)/src/gallium/aux/draw/draw_flatshade.c \ + $(TOP)/src/gallium/aux/draw/draw_offset.c \ + $(TOP)/src/gallium/aux/draw/draw_prim.c \ + $(TOP)/src/gallium/aux/draw/draw_stipple.c \ + $(TOP)/src/gallium/aux/draw/draw_twoside.c \ + $(TOP)/src/gallium/aux/draw/draw_unfilled.c \ + $(TOP)/src/gallium/aux/draw/draw_validate.c \ + $(TOP)/src/gallium/aux/draw/draw_vbuf.c \ + $(TOP)/src/gallium/aux/draw/draw_vertex.c \ + $(TOP)/src/gallium/aux/draw/draw_vertex_cache.c \ + $(TOP)/src/gallium/aux/draw/draw_vertex_fetch.c \ + $(TOP)/src/gallium/aux/draw/draw_vertex_shader.c \ + $(TOP)/src/gallium/aux/draw/draw_vf.c \ + $(TOP)/src/gallium/aux/draw/draw_vf_generic.c \ + $(TOP)/src/gallium/aux/draw/draw_vf_sse.c \ + $(TOP)/src/gallium/aux/draw/draw_wide_prims.c TGSIEXEC_SOURCES = \ - pipe/tgsi/exec/tgsi_exec.c \ - pipe/tgsi/exec/tgsi_sse2.c + $(TOP)/src/gallium/aux/tgsi/exec/tgsi_exec.c \ + $(TOP)/src/gallium/aux/tgsi/exec/tgsi_sse2.c TGSIUTIL_SOURCES = \ - pipe/tgsi/util/tgsi_build.c \ - pipe/tgsi/util/tgsi_dump.c \ - pipe/tgsi/util/tgsi_parse.c \ - pipe/tgsi/util/tgsi_util.c + $(TOP)/src/gallium/aux/tgsi/util/tgsi_build.c \ + $(TOP)/src/gallium/aux/tgsi/util/tgsi_dump.c \ + $(TOP)/src/gallium/aux/tgsi/util/tgsi_parse.c \ + $(TOP)/src/gallium/aux/tgsi/util/tgsi_util.c STATECACHE_SOURCES = \ - pipe/cso_cache/cso_hash.c \ - pipe/cso_cache/cso_cache.c + $(TOP)/src/gallium/aux/cso_cache/cso_hash.c \ + $(TOP)/src/gallium/aux/cso_cache/cso_cache.c PIPEUTIL_SOURCES = \ - pipe/util/p_debug.c \ - pipe/util/p_tile.c \ - pipe/util/p_util.c + $(TOP)/src/gallium/aux/util/p_debug.c \ + $(TOP)/src/gallium/aux/util/p_tile.c \ + $(TOP)/src/gallium/aux/util/p_util.c STATETRACKER_SOURCES = \ state_tracker/st_atom.c \ @@ -331,13 +331,13 @@ __COMMON_DRIVER_SOURCES = \ drivers/common/driverfuncs.c X11_DRIVER_SOURCES = \ - pipe/xlib/glxapi.c \ - pipe/xlib/fakeglx.c \ - pipe/xlib/xfonts.c \ - pipe/xlib/xm_api.c \ - pipe/xlib/xm_winsys.c \ - pipe/xlib/xm_winsys_aub.c \ - pipe/xlib/brw_aub.c + $(TOP)/src/gallium/winsys/xlib/glxapi.c \ + $(TOP)/src/gallium/winsys/xlib/fakeglx.c \ + $(TOP)/src/gallium/winsys/xlib/xfonts.c \ + $(TOP)/src/gallium/winsys/xlib/xm_api.c \ + $(TOP)/src/gallium/winsys/xlib/xm_winsys.c \ + $(TOP)/src/gallium/winsys/xlib/xm_winsys_aub.c \ + $(TOP)/src/gallium/winsys/xlib/brw_aub.c OSMESA_DRIVER_SOURCES = \ drivers/osmesa/osmesa.c @@ -425,7 +425,10 @@ FBDEV_DRIVER_OBJECTS = $(FBDEV_DRIVER_SOURCES:.c=.o) INCLUDE_DIRS = \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main + -I$(TOP)/src/mesa/main \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/aux OLD_INCLUDE_DIRS = \ -I$(TOP)/src/mesa/tnl \ @@ -435,4 +438,4 @@ OLD_INCLUDE_DIRS = \ -I$(TOP)/src/mesa/shader \ -I$(TOP)/src/mesa/shader/grammar \ -I$(TOP)/src/mesa/shader/slang \ - -I$(TOP)/src/mesa/pipe/tgsi + -I$(TOP)/s$(TOP)/src/gallium/aux/tgsi diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 2c6ec8421b..b67b620eaa 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -43,7 +43,7 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" #include "st_context.h" #include "st_cache.h" diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index e0965b217a..2979e7fae5 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -36,8 +36,8 @@ #include "pipe/p_state.h" -#include "pipe/cso_cache/cso_cache.h" -#include "pipe/cso_cache/cso_hash.h" +#include "cso_cache/cso_cache.h" +#include "cso_cache/cso_hash.h" /* Those function will either find the state of the given template diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index e0c176b0ff..b81de316ec 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -33,7 +33,7 @@ #ifndef ST_CACHE_H #define ST_CACHE_H -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" struct pipe_blend_state; struct pipe_sampler_state; diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 3a3bf9016d..663c4f205d 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -43,7 +43,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #define UNCLAMPED_FLOAT_TO_SHORT(us, f) \ diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index f13199a3c0..e2d4e06da1 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -56,7 +56,7 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "shader/prog_instruction.h" diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 31744151f1..5315294c07 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -53,10 +53,10 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" /** diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index af3ee65504..61d4f4c41c 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -39,8 +39,8 @@ #include "shader/programopt.h" #include "shader/shader_api.h" -#include "pipe/cso_cache/cso_cache.h" -#include "pipe/draw/draw_context.h" +#include "cso_cache/cso_cache.h" +#include "draw/draw_context.h" #include "st_context.h" #include "st_program.h" diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 7e347c4893..5b0eb6022b 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -44,8 +44,8 @@ #include "st_draw.h" #include "st_cb_rasterpos.h" #include "st_draw.h" -#include "pipe/draw/draw_context.h" -#include "pipe/draw/draw_private.h" +#include "draw/draw_context.h" +#include "draw/draw_private.h" #include "shader/prog_instruction.h" #include "vbo/vbo.h" diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 868c5f3c5f..c89c74229e 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -40,7 +40,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #include "st_context.h" #include "st_cb_readpixels.h" #include "st_cb_fbo.h" diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 91a40288cc..03dbb30b0f 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -47,7 +47,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/util/p_tile.h" +#include "util/p_tile.h" #define DBG if (0) printf diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index bf4618bed8..09e389f9dc 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -54,8 +54,8 @@ #include "pipe/p_context.h" #include "pipe/p_winsys.h" #include "pipe/p_inlines.h" -#include "pipe/draw/draw_context.h" -#include "pipe/cso_cache/cso_cache.h" +#include "draw/draw_context.h" +#include "cso_cache/cso_cache.h" /** diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 57450e52bf..5888bcb98a 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -31,9 +31,9 @@ #include "pipe/p_state.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "tgsi/util/tgsi_dump.h" -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" #include "st_context.h" #include "st_debug.h" diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index ae9f5c8b11..1c0fa8c6aa 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -47,8 +47,8 @@ #include "pipe/p_winsys.h" #include "pipe/p_inlines.h" -#include "pipe/draw/draw_private.h" -#include "pipe/draw/draw_context.h" +#include "draw/draw_private.h" +#include "draw/draw_context.h" static GLuint double_types[4] = { diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 459941cca8..6c09b86033 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -37,7 +37,7 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" -#include "pipe/cso_cache/cso_cache.h" +#include "cso_cache/cso_cache.h" #include "st_context.h" #include "st_draw.h" diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 325aa20173..97206752af 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -32,9 +32,9 @@ #include "pipe/p_compiler.h" #include "pipe/p_shader_tokens.h" -#include "pipe/tgsi/util/tgsi_parse.h" -#include "pipe/tgsi/util/tgsi_build.h" -#include "pipe/tgsi/util/tgsi_util.h" +#include "tgsi/util/tgsi_parse.h" +#include "tgsi/util/tgsi_build.h" +#include "tgsi/util/tgsi_util.h" #include "st_mesa_to_tgsi.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index c8297baded..dc992ee9c2 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -38,8 +38,8 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" -#include "pipe/draw/draw_context.h" -#include "pipe/tgsi/util/tgsi_dump.h" +#include "draw/draw_context.h" +#include "tgsi/util/tgsi_dump.h" #include "st_context.h" #include "st_cache.h" -- cgit v1.2.3 From 80efc5feb061a8ed9c1e91ad3711547927fa29e3 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 26 Feb 2008 14:25:36 -0700 Subject: gallium: fix off by one rasterpos bug --- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 5b0eb6022b..4d73916a35 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -145,7 +145,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) /* update raster pos */ pos = prim->v[0]->data[0]; ctx->Current.RasterPos[0] = pos[0]; - ctx->Current.RasterPos[1] = height - 1 - pos[1]; + ctx->Current.RasterPos[1] = height - pos[1]; /* invert Y */ ctx->Current.RasterPos[2] = pos[2]; ctx->Current.RasterPos[3] = pos[3]; -- cgit v1.2.3 From 9a264a056abc376a70e01f097934d590a36df887 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 28 Feb 2008 09:44:09 -0700 Subject: gallium: in GL_SELECT mode, update hitflag in rasterpos --- src/mesa/state_tracker/st_cb_rasterpos.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 4d73916a35..2ed228778e 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -38,6 +38,7 @@ #include "main/imports.h" #include "main/macros.h" +#include "main/feedback.h" #include "st_context.h" #include "st_atom.h" @@ -163,6 +164,10 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) ctx->Current.RasterTexCoords[i], VERT_RESULT_TEX0 + i, VERT_ATTRIB_TEX0 + i); } + + if (ctx->RenderMode == GL_SELECT) { + _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); + } } -- cgit v1.2.3 From 507fbe2d327efb8d608ce8e07436b97321560808 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 19 Apr 2008 15:29:27 +0100 Subject: draw: move some pipeline-specific code & state to draw_pipe.[ch] --- src/gallium/auxiliary/draw/Makefile | 1 + src/gallium/auxiliary/draw/draw_context.c | 141 +++++-------------- src/gallium/auxiliary/draw/draw_pipe.c | 161 ++++++++++++++++++++++ src/gallium/auxiliary/draw/draw_pipe.h | 110 +++++++++++++++ src/gallium/auxiliary/draw/draw_pipe_aaline.c | 1 + src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 1 + src/gallium/auxiliary/draw/draw_pipe_clip.c | 11 +- src/gallium/auxiliary/draw/draw_pipe_cull.c | 2 +- src/gallium/auxiliary/draw/draw_pipe_flatshade.c | 1 + src/gallium/auxiliary/draw/draw_pipe_offset.c | 2 +- src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 2 +- src/gallium/auxiliary/draw/draw_pipe_stipple.c | 2 +- src/gallium/auxiliary/draw/draw_pipe_twoside.c | 2 +- src/gallium/auxiliary/draw/draw_pipe_unfilled.c | 1 + src/gallium/auxiliary/draw/draw_pipe_validate.c | 17 +-- src/gallium/auxiliary/draw/draw_pipe_vbuf.c | 1 + src/gallium/auxiliary/draw/draw_pipe_wide_line.c | 1 + src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 5 +- src/gallium/auxiliary/draw/draw_private.h | 132 ++++-------------- src/gallium/auxiliary/draw/draw_pt.c | 18 --- src/gallium/auxiliary/draw/draw_pt_pipeline.c | 1 + src/gallium/auxiliary/draw/draw_pt_post_vs.c | 11 ++ src/gallium/auxiliary/draw/draw_vertex.c | 2 - src/gallium/drivers/i915simple/i915_context.c | 2 +- src/gallium/drivers/i915simple/i915_prim_emit.c | 5 +- src/gallium/drivers/softpipe/sp_prim_setup.c | 2 +- src/mesa/state_tracker/st_cb_feedback.c | 2 +- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- 28 files changed, 377 insertions(+), 262 deletions(-) create mode 100644 src/gallium/auxiliary/draw/draw_pipe.c create mode 100644 src/gallium/auxiliary/draw/draw_pipe.h (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/gallium/auxiliary/draw/Makefile b/src/gallium/auxiliary/draw/Makefile index 62f46c6db1..4fffd11b77 100644 --- a/src/gallium/auxiliary/draw/Makefile +++ b/src/gallium/auxiliary/draw/Makefile @@ -5,6 +5,7 @@ LIBNAME = draw C_SOURCES = \ draw_context.c \ + draw_pipe.c \ draw_pipe_aaline.c \ draw_pipe_aapoint.c \ draw_pipe_clip.c \ diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 6012bc155e..fa6791fa0b 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -35,6 +35,8 @@ #include "draw_context.h" #include "draw_vbuf.h" #include "draw_vs.h" +#include "draw_pt.h" +#include "draw_pipe.h" struct draw_context *draw_create( void ) @@ -49,32 +51,6 @@ struct draw_context *draw_create( void ) draw->use_sse = FALSE; #endif - /* create pipeline stages */ - draw->pipeline.wide_line = draw_wide_line_stage( draw ); - draw->pipeline.wide_point = draw_wide_point_stage( draw ); - draw->pipeline.stipple = draw_stipple_stage( draw ); - draw->pipeline.unfilled = draw_unfilled_stage( draw ); - draw->pipeline.twoside = draw_twoside_stage( draw ); - draw->pipeline.offset = draw_offset_stage( draw ); - draw->pipeline.clip = draw_clip_stage( draw ); - draw->pipeline.flatshade = draw_flatshade_stage( draw ); - draw->pipeline.cull = draw_cull_stage( draw ); - draw->pipeline.validate = draw_validate_stage( draw ); - draw->pipeline.first = draw->pipeline.validate; - - if (!draw->pipeline.wide_line || - !draw->pipeline.wide_point || - !draw->pipeline.stipple || - !draw->pipeline.unfilled || - !draw->pipeline.twoside || - !draw->pipeline.offset || - !draw->pipeline.clip || - !draw->pipeline.flatshade || - !draw->pipeline.cull || - !draw->pipeline.validate) - goto fail; - - 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 ); @@ -83,11 +59,6 @@ struct draw_context *draw_create( void ) ASSIGN_4V( draw->plane[5], 0, 0, -1, 1 ); /* mesa's a bit wonky */ draw->nr_planes = 6; - /* these defaults are oriented toward the needs of softpipe */ - draw->wide_point_threshold = 1000000.0; /* infinity */ - draw->wide_line_threshold = 1.0; - draw->line_stipple = TRUE; - draw->point_sprite = TRUE; draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */ @@ -100,6 +71,8 @@ struct draw_context *draw_create( void ) draw->machine.Inputs = align_malloc(PIPE_MAX_ATTRIBS * sizeof(struct tgsi_exec_vector), 16); draw->machine.Outputs = align_malloc(PIPE_MAX_ATTRIBS * sizeof(struct tgsi_exec_vector), 16); + if (!draw_pipeline_init( draw )) + goto fail; if (!draw_pt_init( draw )) goto fail; @@ -117,39 +90,13 @@ void draw_destroy( struct draw_context *draw ) if (!draw) return; - if (draw->pipeline.wide_line) - draw->pipeline.wide_line->destroy( draw->pipeline.wide_line ); - if (draw->pipeline.wide_point) - draw->pipeline.wide_point->destroy( draw->pipeline.wide_point ); - if (draw->pipeline.stipple) - draw->pipeline.stipple->destroy( draw->pipeline.stipple ); - if (draw->pipeline.unfilled) - draw->pipeline.unfilled->destroy( draw->pipeline.unfilled ); - if (draw->pipeline.twoside) - draw->pipeline.twoside->destroy( draw->pipeline.twoside ); - if (draw->pipeline.offset) - draw->pipeline.offset->destroy( draw->pipeline.offset ); - if (draw->pipeline.clip) - draw->pipeline.clip->destroy( draw->pipeline.clip ); - if (draw->pipeline.flatshade) - draw->pipeline.flatshade->destroy( draw->pipeline.flatshade ); - if (draw->pipeline.cull) - draw->pipeline.cull->destroy( draw->pipeline.cull ); - if (draw->pipeline.validate) - draw->pipeline.validate->destroy( draw->pipeline.validate ); - if (draw->pipeline.aaline) - draw->pipeline.aaline->destroy( draw->pipeline.aaline ); - if (draw->pipeline.aapoint) - draw->pipeline.aapoint->destroy( draw->pipeline.aapoint ); - if (draw->pipeline.pstipple) - draw->pipeline.pstipple->destroy( draw->pipeline.pstipple ); - if (draw->pipeline.rasterize) - draw->pipeline.rasterize->destroy( draw->pipeline.rasterize ); if (draw->machine.Inputs) align_free(draw->machine.Inputs); + if (draw->machine.Outputs) align_free(draw->machine.Outputs); + tgsi_exec_machine_free_data(&draw->machine); /* Not so fast -- we're just borrowing this at the moment. @@ -158,6 +105,7 @@ void draw_destroy( struct draw_context *draw ) draw->render->destroy( draw->render ); */ + draw_pipeline_destroy( draw ); draw_pt_destroy( draw ); FREE( draw ); @@ -284,7 +232,7 @@ void draw_wide_point_threshold(struct draw_context *draw, float threshold) { draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); - draw->wide_point_threshold = threshold; + draw->pipeline.wide_point_threshold = threshold; } @@ -296,7 +244,7 @@ void draw_wide_line_threshold(struct draw_context *draw, float threshold) { draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); - draw->wide_line_threshold = threshold; + draw->pipeline.wide_line_threshold = threshold; } @@ -307,7 +255,7 @@ void draw_enable_line_stipple(struct draw_context *draw, boolean enable) { draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); - draw->line_stipple = enable; + draw->pipeline.line_stipple = enable; } @@ -318,7 +266,7 @@ void draw_enable_point_sprites(struct draw_context *draw, boolean enable) { draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); - draw->point_sprite = enable; + draw->pipeline.point_sprite = enable; } @@ -373,36 +321,6 @@ draw_num_vs_outputs(struct draw_context *draw) } -/** - * Allocate space for temporary post-transform vertices, such as for clipping. - */ -void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr ) -{ - assert(!stage->tmp); - - stage->nr_tmps = nr; - - if (nr) { - ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr ); - unsigned i; - - stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr ); - - for (i = 0; i < nr; i++) - stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE); - } -} - - -void draw_free_temp_verts( struct draw_stage *stage ) -{ - if (stage->tmp) { - FREE( stage->tmp[0] ); - FREE( stage->tmp ); - stage->tmp = NULL; - } -} - boolean draw_use_sse(struct draw_context *draw) { @@ -410,23 +328,6 @@ boolean draw_use_sse(struct draw_context *draw) } -void draw_reset_vertex_ids(struct draw_context *draw) -{ - struct draw_stage *stage = draw->pipeline.first; - - while (stage) { - unsigned i; - - for (i = 0; i < stage->nr_tmps; i++) - stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID; - - stage = stage->next; - } - - draw_pt_reset_vertex_ids(draw); -} - - void draw_set_render( struct draw_context *draw, struct vbuf_render *render ) { @@ -467,3 +368,23 @@ draw_set_mapped_element_buffer( struct draw_context *draw, draw->user.elts = elements; draw->user.eltSize = eltSize; } + + + +/* Revamp me please: + */ +void draw_do_flush( struct draw_context *draw, unsigned flags ) +{ + if (!draw->flushing) + { + draw->flushing = TRUE; + + if (flags >= DRAW_FLUSH_STATE_CHANGE) { + draw->pipeline.first->flush( draw->pipeline.first, flags ); + draw->pipeline.first = draw->pipeline.validate; + draw->reduced_prim = ~0; /* is reduced_prim needed any more? */ + } + + draw->flushing = FALSE; + } +} diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c new file mode 100644 index 0000000000..9d62cb2c65 --- /dev/null +++ b/src/gallium/auxiliary/draw/draw_pipe.c @@ -0,0 +1,161 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + + /* + * Authors: + * Keith Whitwell + */ + +#include "pipe/p_util.h" +#include "draw/draw_private.h" +#include "draw/draw_pipe.h" + + +boolean draw_pipeline_init( struct draw_context *draw ) +{ + /* create pipeline stages */ + draw->pipeline.wide_line = draw_wide_line_stage( draw ); + draw->pipeline.wide_point = draw_wide_point_stage( draw ); + draw->pipeline.stipple = draw_stipple_stage( draw ); + draw->pipeline.unfilled = draw_unfilled_stage( draw ); + draw->pipeline.twoside = draw_twoside_stage( draw ); + draw->pipeline.offset = draw_offset_stage( draw ); + draw->pipeline.clip = draw_clip_stage( draw ); + draw->pipeline.flatshade = draw_flatshade_stage( draw ); + draw->pipeline.cull = draw_cull_stage( draw ); + draw->pipeline.validate = draw_validate_stage( draw ); + draw->pipeline.first = draw->pipeline.validate; + + if (!draw->pipeline.wide_line || + !draw->pipeline.wide_point || + !draw->pipeline.stipple || + !draw->pipeline.unfilled || + !draw->pipeline.twoside || + !draw->pipeline.offset || + !draw->pipeline.clip || + !draw->pipeline.flatshade || + !draw->pipeline.cull || + !draw->pipeline.validate) + return FALSE; + + /* 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.line_stipple = TRUE; + draw->pipeline.point_sprite = TRUE; + + return TRUE; +} + + +void draw_pipeline_destroy( struct draw_context *draw ) +{ + if (draw->pipeline.wide_line) + draw->pipeline.wide_line->destroy( draw->pipeline.wide_line ); + if (draw->pipeline.wide_point) + draw->pipeline.wide_point->destroy( draw->pipeline.wide_point ); + if (draw->pipeline.stipple) + draw->pipeline.stipple->destroy( draw->pipeline.stipple ); + if (draw->pipeline.unfilled) + draw->pipeline.unfilled->destroy( draw->pipeline.unfilled ); + if (draw->pipeline.twoside) + draw->pipeline.twoside->destroy( draw->pipeline.twoside ); + if (draw->pipeline.offset) + draw->pipeline.offset->destroy( draw->pipeline.offset ); + if (draw->pipeline.clip) + draw->pipeline.clip->destroy( draw->pipeline.clip ); + if (draw->pipeline.flatshade) + draw->pipeline.flatshade->destroy( draw->pipeline.flatshade ); + if (draw->pipeline.cull) + draw->pipeline.cull->destroy( draw->pipeline.cull ); + if (draw->pipeline.validate) + draw->pipeline.validate->destroy( draw->pipeline.validate ); + if (draw->pipeline.aaline) + draw->pipeline.aaline->destroy( draw->pipeline.aaline ); + if (draw->pipeline.aapoint) + draw->pipeline.aapoint->destroy( draw->pipeline.aapoint ); + if (draw->pipeline.pstipple) + draw->pipeline.pstipple->destroy( draw->pipeline.pstipple ); + if (draw->pipeline.rasterize) + draw->pipeline.rasterize->destroy( draw->pipeline.rasterize ); +} + + + + +/* This is only used for temporary verts. + */ +#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float)) + + +/** + * Allocate space for temporary post-transform vertices, such as for clipping. + */ +void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr ) +{ + assert(!stage->tmp); + + stage->nr_tmps = nr; + + if (nr) { + ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr ); + unsigned i; + + stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr ); + + for (i = 0; i < nr; i++) + stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE); + } +} + + +void draw_free_temp_verts( struct draw_stage *stage ) +{ + if (stage->tmp) { + FREE( stage->tmp[0] ); + FREE( stage->tmp ); + stage->tmp = NULL; + } +} + +void draw_reset_vertex_ids(struct draw_context *draw) +{ + struct draw_stage *stage = draw->pipeline.first; + + while (stage) { + unsigned i; + + for (i = 0; i < stage->nr_tmps; i++) + stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID; + + stage = stage->next; + } + + draw_pt_reset_vertex_ids(draw); +} + + diff --git a/src/gallium/auxiliary/draw/draw_pipe.h b/src/gallium/auxiliary/draw/draw_pipe.h new file mode 100644 index 0000000000..5b97ca5c8c --- /dev/null +++ b/src/gallium/auxiliary/draw/draw_pipe.h @@ -0,0 +1,110 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + + /* + * Authors: + * Keith Whitwell + */ + +#ifndef DRAW_PIPE_H +#define DRAW_PIPE_H + +#include "pipe/p_compiler.h" +#include "draw_private.h" /* for sizeof(vertex_header) */ + + + +/** + * Base class for all primitive drawing stages. + */ +struct draw_stage +{ + struct draw_context *draw; /**< parent context */ + + struct draw_stage *next; /**< next stage in pipeline */ + + struct vertex_header **tmp; /**< temp vert storage, such as for clipping */ + unsigned nr_tmps; + + void (*point)( struct draw_stage *, + struct prim_header * ); + + void (*line)( struct draw_stage *, + struct prim_header * ); + + void (*tri)( struct draw_stage *, + struct prim_header * ); + + void (*flush)( struct draw_stage *, + unsigned flags ); + + void (*reset_stipple_counter)( struct draw_stage * ); + + void (*destroy)( struct draw_stage * ); +}; + + +extern struct draw_stage *draw_unfilled_stage( struct draw_context *context ); +extern struct draw_stage *draw_twoside_stage( struct draw_context *context ); +extern struct draw_stage *draw_offset_stage( struct draw_context *context ); +extern struct draw_stage *draw_clip_stage( struct draw_context *context ); +extern struct draw_stage *draw_flatshade_stage( struct draw_context *context ); +extern struct draw_stage *draw_cull_stage( struct draw_context *context ); +extern struct draw_stage *draw_stipple_stage( struct draw_context *context ); +extern struct draw_stage *draw_wide_line_stage( struct draw_context *context ); +extern struct draw_stage *draw_wide_point_stage( struct draw_context *context ); +extern struct draw_stage *draw_validate_stage( struct draw_context *context ); + + +extern void draw_free_temp_verts( struct draw_stage *stage ); + +extern void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr ); + + + + +/** + * Get a writeable copy of a vertex. + * \param stage drawing stage info + * \param vert the vertex to copy (source) + * \param idx index into stage's tmp[] array to put the copy (dest) + * \return pointer to the copied vertex + */ +static INLINE struct vertex_header * +dup_vert( struct draw_stage *stage, + const struct vertex_header *vert, + unsigned idx ) +{ + struct vertex_header *tmp = stage->tmp[idx]; + const uint vsize = sizeof(struct vertex_header) + + stage->draw->num_vs_outputs * 4 * sizeof(float); + memcpy(tmp, vert, vsize); + tmp->vertex_id = UNDEFINED_VERTEX_ID; + return tmp; +} + +#endif diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index e8d2a45102..24bc87d4f8 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -43,6 +43,7 @@ #include "draw_context.h" #include "draw_private.h" +#include "draw_pipe.h" /** diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c index e84d380e50..9f878f6c02 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c @@ -49,6 +49,7 @@ #include "draw_context.h" #include "draw_vs.h" +#include "draw_pipe.h" /* diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c index 0ac3a240e5..6780f275d9 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_clip.c +++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c @@ -35,8 +35,8 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" -#include "draw_context.h" #include "draw_vs.h" +#include "draw_pipe.h" #ifndef IS_NEGATIVE @@ -204,7 +204,14 @@ static void emit_poly( struct draw_stage *stage, } } - +static INLINE float +dot4(const float *a, const float *b) +{ + return (a[0]*b[0] + + a[1]*b[1] + + a[2]*b[2] + + a[3]*b[3]); +} /* Clip a triangle against the viewport and user clip planes. diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c index 8177b0ac86..c406f89d05 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_cull.c +++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c @@ -35,7 +35,7 @@ #include "pipe/p_util.h" #include "pipe/p_defines.h" -#include "draw_private.h" +#include "draw_pipe.h" struct cull_stage { diff --git a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c index 54baa1fbc9..bdb8b49dc4 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c +++ b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c @@ -31,6 +31,7 @@ #include "pipe/p_util.h" #include "pipe/p_shader_tokens.h" #include "draw_vs.h" +#include "draw_pipe.h" /** subclass of draw_stage */ diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c index dbc676deae..dbdece45bb 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_offset.c +++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c @@ -33,7 +33,7 @@ */ #include "pipe/p_util.h" -#include "draw_private.h" +#include "draw_pipe.h" diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index 4dddb72906..4903ba2133 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -44,7 +44,7 @@ #include "tgsi/util/tgsi_dump.h" #include "draw_context.h" -#include "draw_private.h" +#include "draw_pipe.h" diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c index 506f33512c..49429ee9e1 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c @@ -39,7 +39,7 @@ #include "pipe/p_util.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" -#include "draw_private.h" +#include "draw_pipe.h" /** Subclass of draw_stage */ diff --git a/src/gallium/auxiliary/draw/draw_pipe_twoside.c b/src/gallium/auxiliary/draw/draw_pipe_twoside.c index 01d905c153..09a9d23d57 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_twoside.c +++ b/src/gallium/auxiliary/draw/draw_pipe_twoside.c @@ -32,7 +32,7 @@ #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" #include "draw_vs.h" - +#include "draw_pipe.h" struct twoside_stage { struct draw_stage stage; diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c index b07860cd9e..31e24f6a14 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c +++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c @@ -36,6 +36,7 @@ #include "pipe/p_util.h" #include "pipe/p_defines.h" #include "draw_private.h" +#include "draw_pipe.h" struct unfilled_stage { diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c index e163e078f0..ffddc2f62c 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_validate.c +++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c @@ -31,6 +31,7 @@ #include "pipe/p_util.h" #include "pipe/p_defines.h" #include "draw_private.h" +#include "draw_pipe.h" static boolean points( unsigned prim ) { @@ -66,11 +67,11 @@ draw_need_pipeline(const struct draw_context *draw, if (lines(prim)) { /* line stipple */ - if (draw->rasterizer->line_stipple_enable && draw->line_stipple) + if (draw->rasterizer->line_stipple_enable && draw->pipeline.line_stipple) return TRUE; /* wide lines */ - if (draw->rasterizer->line_width > draw->wide_line_threshold) + if (draw->rasterizer->line_width > draw->pipeline.wide_line_threshold) return TRUE; /* AA lines */ @@ -81,7 +82,7 @@ draw_need_pipeline(const struct draw_context *draw, if (points(prim)) { /* large points */ - if (draw->rasterizer->point_size > draw->wide_point_threshold) + if (draw->rasterizer->point_size > draw->pipeline.wide_point_threshold) return TRUE; /* AA points */ @@ -89,7 +90,7 @@ draw_need_pipeline(const struct draw_context *draw, return TRUE; /* point sprites */ - if (draw->rasterizer->point_sprite && draw->point_sprite) + if (draw->rasterizer->point_sprite && draw->pipeline.point_sprite) return TRUE; } @@ -145,15 +146,15 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) stage->next = next; /* drawing wide lines? */ - wide_lines = (draw->rasterizer->line_width > draw->wide_line_threshold + wide_lines = (draw->rasterizer->line_width > draw->pipeline.wide_line_threshold && !draw->rasterizer->line_smooth); /* drawing large points? */ - if (draw->rasterizer->point_sprite && draw->point_sprite) + if (draw->rasterizer->point_sprite && draw->pipeline.point_sprite) wide_points = TRUE; else if (draw->rasterizer->point_smooth && draw->pipeline.aapoint) wide_points = FALSE; - else if (draw->rasterizer->point_size > draw->wide_point_threshold) + else if (draw->rasterizer->point_size > draw->pipeline.wide_point_threshold) wide_points = TRUE; else wide_points = FALSE; @@ -186,7 +187,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) next = draw->pipeline.wide_point; } - if (draw->rasterizer->line_stipple_enable && draw->line_stipple) { + if (draw->rasterizer->line_stipple_enable && draw->pipeline.line_stipple) { draw->pipeline.stipple->next = next; next = draw->pipeline.stipple; precalc_flat = 1; /* only needed for lines really */ diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c index 30dceeb43d..c835727e32 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c +++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c @@ -40,6 +40,7 @@ #include "draw_vbuf.h" #include "draw_private.h" #include "draw_vertex.h" +#include "draw_pipe.h" #include "translate/translate.h" diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c index 9a168ce8bd..329b5d0fb0 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c @@ -32,6 +32,7 @@ #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" #include "draw_private.h" +#include "draw_pipe.h" struct wideline_stage { diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c index 3d0add0c1a..7a439178a0 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c @@ -32,6 +32,7 @@ #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" #include "draw_vs.h" +#include "draw_pipe.h" struct widepoint_stage { @@ -203,8 +204,8 @@ 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 ((draw->rasterizer->point_size > draw->wide_point_threshold) || - (draw->rasterizer->point_sprite && draw->point_sprite)) { + if ((draw->rasterizer->point_size > draw->pipeline.wide_point_threshold) || + (draw->rasterizer->point_sprite && draw->pipeline.point_sprite)) { stage->point = widepoint_point; } else { diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 37ffdbf902..b2b2f82b8f 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -51,12 +51,11 @@ struct pipe_context; struct gallivm_prog; struct gallivm_cpu_engine; - -struct draw_pt_middle_end; -struct draw_pt_front_end; struct draw_vertex_shader; +struct draw_context; +struct draw_stage; +struct vbuf_render; -#define MAX_SHADER_VERTICES 128 /** * Basic vertex info. @@ -70,17 +69,14 @@ struct vertex_header { float clip[4]; - float data[][4]; /* Note variable size */ + /* This will probably become float (*data)[4] soon: + */ + float data[][4]; }; /* NOTE: It should match vertex_id size above */ #define UNDEFINED_VERTEX_ID 0xffff -/* XXX This is too large */ -#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float)) -#define MAX_VERTEX_ALLOCATION ((MAX_VERTEX_SIZE + 0x0f) & ~0x0f) - - /** * Basic info for a point/line/triangle primitive. @@ -95,41 +91,6 @@ struct prim_header { -struct draw_context; - -/** - * Base class for all primitive drawing stages. - */ -struct draw_stage -{ - struct draw_context *draw; /**< parent context */ - - struct draw_stage *next; /**< next stage in pipeline */ - - struct vertex_header **tmp; /**< temp vert storage, such as for clipping */ - unsigned nr_tmps; - - void (*point)( struct draw_stage *, - struct prim_header * ); - - void (*line)( struct draw_stage *, - struct prim_header * ); - - void (*tri)( struct draw_stage *, - struct prim_header * ); - - void (*flush)( struct draw_stage *, - unsigned flags ); - - void (*reset_stipple_counter)( struct draw_stage * ); - - void (*destroy)( struct draw_stage * ); -}; - - - -struct vbuf_render; - #define PT_SHADE 0x1 #define PT_CLIPTEST 0x2 @@ -161,6 +122,12 @@ struct draw_context struct draw_stage *wide_line; struct draw_stage *wide_point; struct draw_stage *rasterize; + + 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 line_stipple; /**< do line stipple? */ + boolean point_sprite; /**< convert points to quads for sprites? */ + } pipeline; @@ -225,10 +192,6 @@ struct draw_context float plane[12][4]; unsigned nr_planes; - 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 line_stipple; /**< do line stipple? */ - boolean point_sprite; /**< convert points to quads for sprites? */ boolean use_sse; /* If a prim stage introduces new vertex attributes, they'll be stored here @@ -252,44 +215,29 @@ struct draw_context -extern struct draw_stage *draw_unfilled_stage( struct draw_context *context ); -extern struct draw_stage *draw_twoside_stage( struct draw_context *context ); -extern struct draw_stage *draw_offset_stage( struct draw_context *context ); -extern struct draw_stage *draw_clip_stage( struct draw_context *context ); -extern struct draw_stage *draw_flatshade_stage( struct draw_context *context ); -extern struct draw_stage *draw_cull_stage( struct draw_context *context ); -extern struct draw_stage *draw_stipple_stage( struct draw_context *context ); -extern struct draw_stage *draw_wide_line_stage( struct draw_context *context ); -extern struct draw_stage *draw_wide_point_stage( struct draw_context *context ); -extern struct draw_stage *draw_validate_stage( struct draw_context *context ); - - -extern void draw_free_temp_verts( struct draw_stage *stage ); - -extern void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr ); extern void draw_reset_vertex_ids( struct draw_context *draw ); -extern int draw_vertex_cache_check_space( struct draw_context *draw, - unsigned nr_verts ); -extern void draw_vertex_cache_invalidate( struct draw_context *draw ); -extern void draw_vertex_cache_unreference( struct draw_context *draw ); -extern void draw_vertex_cache_reset_vertex_ids( struct draw_context *draw ); +/******************************************************************************* + * Vertex processing (was passthrough) code: + */ +boolean draw_pt_init( struct draw_context *draw ); +void draw_pt_destroy( struct draw_context *draw ); +void draw_pt_reset_vertex_ids( struct draw_context *draw ); -extern void draw_update_vertex_fetch( struct draw_context *draw ); +/******************************************************************************* + * Primitive processing (pipelnie) code: + */ -extern boolean draw_need_pipeline(const struct draw_context *draw, - unsigned prim ); +boolean draw_pipeline_init( struct draw_context *draw ); +void draw_pipeline_destroy( struct draw_context *draw ); +boolean draw_need_pipeline(const struct draw_context *draw, + unsigned prim ); -/* Passthrough mode (second attempt): - */ -boolean draw_pt_init( struct draw_context *draw ); -void draw_pt_destroy( struct draw_context *draw ); -void draw_pt_reset_vertex_ids( struct draw_context *draw ); #define DRAW_FLUSH_STATE_CHANGE 0x8 #define DRAW_FLUSH_BACKEND 0x10 @@ -301,36 +249,6 @@ boolean draw_get_edgeflag( struct draw_context *draw, unsigned idx ); -/** - * Get a writeable copy of a vertex. - * \param stage drawing stage info - * \param vert the vertex to copy (source) - * \param idx index into stage's tmp[] array to put the copy (dest) - * \return pointer to the copied vertex - */ -static INLINE struct vertex_header * -dup_vert( struct draw_stage *stage, - const struct vertex_header *vert, - unsigned idx ) -{ - struct vertex_header *tmp = stage->tmp[idx]; - const uint vsize = sizeof(struct vertex_header) - + stage->draw->num_vs_outputs * 4 * sizeof(float); - memcpy(tmp, vert, vsize); - tmp->vertex_id = UNDEFINED_VERTEX_ID; - return tmp; -} - -static INLINE float -dot4(const float *a, const float *b) -{ - float result = (a[0]*b[0] + - a[1]*b[1] + - a[2]*b[2] + - a[3]*b[3]); - - return result; -} #endif /* DRAW_PRIVATE_H */ diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index f153a3ee2c..965269251f 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -165,21 +165,3 @@ draw_arrays(struct draw_context *draw, unsigned prim, draw_pt_arrays(draw, prim, start, count); } - -/* Revamp me please: - */ -void draw_do_flush( struct draw_context *draw, unsigned flags ) -{ - if (!draw->flushing) - { - draw->flushing = TRUE; - - if (flags >= DRAW_FLUSH_STATE_CHANGE) { - draw->pipeline.first->flush( draw->pipeline.first, flags ); - draw->pipeline.first = draw->pipeline.validate; - draw->reduced_prim = ~0; - } - - draw->flushing = FALSE; - } -} diff --git a/src/gallium/auxiliary/draw/draw_pt_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_pipeline.c index 1a9a3adb03..922344e448 100644 --- a/src/gallium/auxiliary/draw/draw_pt_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_pipeline.c @@ -35,6 +35,7 @@ #include "draw/draw_private.h" #include "draw/draw_vertex.h" #include "draw/draw_pt.h" +#include "draw/draw_pipe.h" static void do_point( struct draw_context *draw, const char *v0 ) diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c index b3ecec6ece..581f044dae 100644 --- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c +++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c @@ -44,6 +44,17 @@ struct pt_post_vs { +static INLINE float +dot4(const float *a, const float *b) +{ + return (a[0]*b[0] + + a[1]*b[1] + + a[2]*b[2] + + a[3]*b[3]); +} + + + static INLINE unsigned compute_clipmask_gl(const float *clip, /*const*/ float plane[][4], unsigned nr) { diff --git a/src/gallium/auxiliary/draw/draw_vertex.c b/src/gallium/auxiliary/draw/draw_vertex.c index 168036eee8..a42adaafb1 100644 --- a/src/gallium/auxiliary/draw/draw_vertex.c +++ b/src/gallium/auxiliary/draw/draw_vertex.c @@ -72,6 +72,4 @@ draw_compute_vertex_size(struct vertex_info *vinfo) assert(0); } } - - assert(vinfo->size * 4 <= MAX_VERTEX_SIZE); } diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c index 58a5854f0d..4bef21619c 100644 --- a/src/gallium/drivers/i915simple/i915_context.c +++ b/src/gallium/drivers/i915simple/i915_context.c @@ -142,7 +142,7 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen, */ i915->draw = draw_create(); assert(i915->draw); - if (GETENV("I915_VBUF")) { + if (!GETENV("I915_NO_VBUF")) { draw_set_rasterize_stage(i915->draw, i915_draw_vbuf_stage(i915)); } else { diff --git a/src/gallium/drivers/i915simple/i915_prim_emit.c b/src/gallium/drivers/i915simple/i915_prim_emit.c index b6fb0a6d88..9ffa460138 100644 --- a/src/gallium/drivers/i915simple/i915_prim_emit.c +++ b/src/gallium/drivers/i915simple/i915_prim_emit.c @@ -26,7 +26,7 @@ **************************************************************************/ -#include "draw/draw_private.h" +#include "draw/draw_pipe.h" #include "pipe/p_util.h" #include "i915_context.h" @@ -78,9 +78,6 @@ emit_hw_vertex( struct i915_context *i915, const uint j = vinfo->src_index[i]; const float *attrib = vertex->data[j]; switch (vinfo->emit[i]) { - case EMIT_OMIT: - /* no-op */ - break; case EMIT_1F: OUT_BATCH( fui(attrib[0]) ); count++; diff --git a/src/gallium/drivers/softpipe/sp_prim_setup.c b/src/gallium/drivers/softpipe/sp_prim_setup.c index 0ddb06764a..feb35d492a 100644 --- a/src/gallium/drivers/softpipe/sp_prim_setup.c +++ b/src/gallium/drivers/softpipe/sp_prim_setup.c @@ -39,7 +39,7 @@ #include "sp_setup.h" #include "sp_state.h" #include "sp_prim_setup.h" -#include "draw/draw_private.h" +#include "draw/draw_pipe.h" #include "draw/draw_vertex.h" #include "pipe/p_util.h" diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 605bfee743..1b50792bd1 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -56,7 +56,7 @@ #include "cso_cache/cso_cache.h" #include "draw/draw_context.h" -#include "draw/draw_private.h" +#include "draw/draw_pipe.h" /** diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 2ed228778e..3cb7b68bea 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -46,7 +46,7 @@ #include "st_cb_rasterpos.h" #include "st_draw.h" #include "draw/draw_context.h" -#include "draw/draw_private.h" +#include "draw/draw_pipe.h" #include "shader/prog_instruction.h" #include "vbo/vbo.h" -- cgit v1.2.3 From 6c534b830c6f5427c391c5225c34561141c201ba Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 15 Jul 2008 11:26:38 +0200 Subject: st: Silence compiler warnings on Windows. --- src/mesa/state_tracker/st_atom_framebuffer.c | 2 +- src/mesa/state_tracker/st_atom_rasterizer.c | 2 +- src/mesa/state_tracker/st_atom_viewport.c | 6 +++--- src/mesa/state_tracker/st_cb_accum.c | 2 +- src/mesa/state_tracker/st_cb_clear.c | 14 +++++++------- src/mesa/state_tracker/st_cb_drawpixels.c | 12 ++++++------ src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- src/mesa/state_tracker/st_cb_texture.c | 8 ++++---- 8 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index d46c3ee16c..80df3b0506 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -59,7 +59,7 @@ update_renderbuffer_surface(struct st_context *st, strb->surface->texture != texture || strb->surface->width != rtt_width || strb->surface->height != rtt_height) { - int level; + GLuint level; /* find matching mipmap level size */ for (level = 0; level <= texture->last_level; level++) { if (texture->width[level] == rtt_width && diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index ff40bb4312..9f4e1c1c69 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -188,7 +188,7 @@ static void update_raster_state( struct st_context *st ) { GLfloat mrd = (ctx->DrawBuffer ? ctx->DrawBuffer->_MRD : - 1.0); + 1.0f); raster->offset_units = ctx->Polygon.OffsetFactor * mrd; raster->offset_scale = (ctx->Polygon.OffsetUnits * mrd * diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c index b105909e96..8b9f1abda4 100644 --- a/src/mesa/state_tracker/st_atom_viewport.c +++ b/src/mesa/state_tracker/st_atom_viewport.c @@ -62,9 +62,9 @@ update_viewport( struct st_context *st ) GLfloat x = (GLfloat)ctx->Viewport.X; GLfloat y = (GLfloat)ctx->Viewport.Y; GLfloat z = ctx->Viewport.Near; - GLfloat half_width = (GLfloat)ctx->Viewport.Width / 2.0; - GLfloat half_height = (GLfloat)ctx->Viewport.Height / 2.0; - GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) / 2.0; + GLfloat half_width = (GLfloat)ctx->Viewport.Width / 2.0f; + GLfloat half_height = (GLfloat)ctx->Viewport.Height / 2.0f; + GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) / 2.0f; st->state.viewport.scale[0] = half_width; st->state.viewport.scale[1] = half_height * yScale; diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index c0e8c6bf33..a992e08ff6 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -290,7 +290,7 @@ accum_return(GLcontext *ctx, GLfloat value, for (ch = 0; ch < 4; ch++) { if (colormask[ch]) { GLfloat val = abuf[i * 4 + ch] * value; - abuf[i * 4 + ch] = CLAMP(val, 0.0, 1.0); + abuf[i * 4 + ch] = CLAMP(val, 0.0f, 1.0f); } else { abuf[i * 4 + ch] = cbuf[i * 4 + ch]; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index cdfcdcee72..e475f022d3 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -203,17 +203,17 @@ clear_with_quad(GLcontext *ctx, GLboolean color, GLboolean depth, GLboolean stencil) { struct st_context *st = ctx->st; - const GLfloat x0 = ctx->DrawBuffer->_Xmin; - const GLfloat x1 = ctx->DrawBuffer->_Xmax; + const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin; + const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax; GLfloat y0, y1; if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { - y0 = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax; - y1 = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin; + y0 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax); + y1 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin); } else { - y0 = ctx->DrawBuffer->_Ymin; - y1 = ctx->DrawBuffer->_Ymax; + y0 = (GLfloat) ctx->DrawBuffer->_Ymin; + y1 = (GLfloat) ctx->DrawBuffer->_Ymax; } /* @@ -286,7 +286,7 @@ clear_with_quad(GLcontext *ctx, cso_set_vertex_shader_handle(st->cso_context, st->clear.vs); /* draw quad matching scissor rect (XXX verify coord round-off) */ - draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); + draw_quad(ctx, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, ctx->Color.ClearColor); /* Restore pipe state */ cso_restore_blend(st->cso_context); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 6b0137dcf8..2ebfcaf82b 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -423,8 +423,8 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, /* setup vertex data */ { const struct gl_framebuffer *fb = st->ctx->DrawBuffer; - const GLfloat fb_width = fb->Width; - const GLfloat fb_height = fb->Height; + const GLfloat fb_width = (GLfloat) fb->Width; + const GLfloat fb_height = (GLfloat) fb->Height; const GLfloat clip_x0 = x0 / fb_width * 2.0f - 1.0f; const GLfloat clip_y0 = y0 / fb_height * 2.0f - 1.0f; const GLfloat clip_x1 = x1 / fb_width * 2.0f - 1.0f; @@ -571,8 +571,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* viewport state: viewport matching window dims */ { - const float width = ctx->DrawBuffer->Width; - const float height = ctx->DrawBuffer->Height; + const float width = (float) ctx->DrawBuffer->Width; + const float height = (float) ctx->DrawBuffer->Height; struct pipe_viewport_state vp; vp.scale[0] = 0.5f * width; vp.scale[1] = -0.5f * height; @@ -600,9 +600,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, * Recall that these coords are transformed by the current * vertex shader and viewport transformation. */ - x0 = x; + x0 = (GLfloat) x; x1 = x + width * ctx->Pixel.ZoomX; - y0 = y; + y0 = (GLfloat) y; y1 = y + height * ctx->Pixel.ZoomY; //if(!color) draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex); diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 3cb7b68bea..3b30c2a61b 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -135,7 +135,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) struct rastpos_stage *rs = rastpos_stage(stage); GLcontext *ctx = rs->ctx; struct st_context *st = ctx->st; - const GLfloat height = ctx->DrawBuffer->Height; + const GLfloat height = (GLfloat) ctx->DrawBuffer->Height; const GLuint *outputMapping = st->vertex_result_to_slot; const GLfloat *pos; GLuint i; diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 73f8b8f788..de782e8232 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -285,7 +285,7 @@ guess_and_alloc_texture(struct st_context *st, assert(!stObj->pt); if (stObj->pt && - stImage->level > stObj->base.BaseLevel && + (GLint) stImage->level > stObj->base.BaseLevel && (stImage->base.Width == 1 || (stObj->base.Target != GL_TEXTURE_1D && stImage->base.Height == 1) || @@ -296,7 +296,7 @@ guess_and_alloc_texture(struct st_context *st, /* If this image disrespects BaseLevel, allocate from level zero. * Usually BaseLevel == 0, so it's unlikely to happen. */ - if (stImage->level < stObj->base.BaseLevel) + if ((GLint) stImage->level < stObj->base.BaseLevel) firstLevel = 0; else firstLevel = stObj->base.BaseLevel; @@ -810,7 +810,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, texImage->Height, format, type); GLuint depth; - int i; + GLuint i; GLubyte *dest; /* Map */ @@ -1383,7 +1383,7 @@ calculate_first_last_level(struct st_texture_object *stObj) } else { firstLevel = 0; - lastLevel = MIN2(tObj->MaxLevel, tObj->Image[0][tObj->BaseLevel]->WidthLog2); + lastLevel = MIN2(tObj->MaxLevel, (int) tObj->Image[0][tObj->BaseLevel]->WidthLog2); } break; case GL_TEXTURE_RECTANGLE_NV: -- cgit v1.2.3 From f8870af44b32d4c69ef11013897143d46966c8e4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 24 Nov 2008 18:37:18 -0700 Subject: gallium: fix inverted raster pos when drawing into FBO --- src/mesa/state_tracker/st_cb_rasterpos.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 3b30c2a61b..3eaccb74e1 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -146,7 +146,10 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) /* update raster pos */ pos = prim->v[0]->data[0]; ctx->Current.RasterPos[0] = pos[0]; - ctx->Current.RasterPos[1] = height - pos[1]; /* invert Y */ + if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) + ctx->Current.RasterPos[1] = height - pos[1]; /* invert Y */ + else + ctx->Current.RasterPos[1] = pos[1]; ctx->Current.RasterPos[2] = pos[2]; ctx->Current.RasterPos[3] = pos[3]; -- cgit v1.2.3 From eb9bbc5265562cb6f93688fc027ea76f91601e37 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 2 Jan 2009 16:16:16 -0700 Subject: gallium: fix texcoord loop for rasterpos attributes --- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_cb_rasterpos.c') diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 3eaccb74e1..8867ca5652 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -162,7 +162,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) ctx->Current.RasterSecondaryColor, VERT_RESULT_COL1, VERT_ATTRIB_COLOR1); - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { update_attrib(ctx, outputMapping, prim->v[0], ctx->Current.RasterTexCoords[i], VERT_RESULT_TEX0 + i, VERT_ATTRIB_TEX0 + i); -- cgit v1.2.3