From 6393cda6766b707ef01e925d378239a66d143ae0 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 14 Jun 2007 18:11:48 +0100 Subject: Renamed softpipe directories and files to something less confusing. softpipe/state_tracker --> state_tracker/ softpipe/ --> pipe/ softpipe/generic --> pipe/softpipe/ I don't think pipe is a great name, but I disliked all the others too. Luckily it's fairly easy to rename with git, so this can be revisited later. --- src/mesa/state_tracker/st_draw.c | 107 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 src/mesa/state_tracker/st_draw.c (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c new file mode 100644 index 0000000000..12646402ee --- /dev/null +++ b/src/mesa/state_tracker/st_draw.c @@ -0,0 +1,107 @@ +/************************************************************************** + * + * 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 "imports.h" + +#include "tnl/t_context.h" +#include "tnl/t_pipeline.h" + +#include "st_context.h" +#include "st_atom.h" +#include "st_draw.h" +#include "softpipe/sp_context.h" + +/* + * TNL stage which feedsinto the above. + * + * XXX: this needs to go into each driver using this code, because we + * cannot make the leap from ctx->draw_context in this file. The + * driver needs to customize tnl anyway, so this isn't a big deal. + */ +static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage ) +{ + struct st_context *st = st_context(ctx); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + + /* Validate driver and softpipe state: + */ + st_validate_state( st ); + + /* Call into the new draw code to handle the VB: + */ + st->softpipe->draw_vb( st->softpipe, VB ); + + /* Finished + */ + return GL_FALSE; +} + +const struct tnl_pipeline_stage st_draw = { + "check state and draw", + NULL, + NULL, + NULL, + NULL, + draw +}; + +static const struct tnl_pipeline_stage *intel_pipeline[] = { + &_tnl_vertex_transform_stage, + &_tnl_vertex_cull_stage, + &_tnl_normal_transform_stage, + &_tnl_lighting_stage, + &_tnl_fog_coordinate_stage, + &_tnl_texgen_stage, + &_tnl_texture_transform_stage, + &_tnl_point_attenuation_stage, + &_tnl_vertex_program_stage, + &st_draw, /* ADD: escape to softpipe */ + 0, +}; + +/* This is all a hack to keep using tnl until we have vertex programs + * up and running. + */ +void st_init_draw( struct st_context *st ) +{ + GLcontext *ctx = st->ctx; + + _tnl_destroy_pipeline( ctx ); + _tnl_install_pipeline( ctx, intel_pipeline ); +} + + +void st_destroy_draw( struct st_context *st ) +{ + /* Nothing to do. + */ +} -- cgit v1.2.3 From 943964a1e5bad86bdceb0a06d60fb3b302ebce6a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 14 Jun 2007 18:23:43 +0100 Subject: Rename directories again?! Some git wierdness going on. --- src/mesa/drivers/x11/xm_api.c | 6 +- src/mesa/drivers/x11/xm_dd.c | 4 +- src/mesa/pipe/p_context.h | 54 +- src/mesa/pipe/p_defines.h | 164 +++--- src/mesa/pipe/p_state.h | 62 +-- src/mesa/pipe/softpipe/g_context.c | 135 ----- src/mesa/pipe/softpipe/g_context.h | 149 ----- src/mesa/pipe/softpipe/g_draw.c | 696 ----------------------- src/mesa/pipe/softpipe/g_draw.h | 56 -- src/mesa/pipe/softpipe/g_headers.h | 116 ---- src/mesa/pipe/softpipe/g_prim.h | 90 --- src/mesa/pipe/softpipe/g_prim_clip.c | 429 --------------- src/mesa/pipe/softpipe/g_prim_cull.c | 119 ---- src/mesa/pipe/softpipe/g_prim_flatshade.c | 149 ----- src/mesa/pipe/softpipe/g_prim_offset.c | 157 ------ src/mesa/pipe/softpipe/g_prim_setup.c | 888 ------------------------------ src/mesa/pipe/softpipe/g_prim_setup.h | 121 ---- src/mesa/pipe/softpipe/g_prim_twoside.c | 149 ----- src/mesa/pipe/softpipe/g_prim_unfilled.c | 165 ------ src/mesa/pipe/softpipe/g_state.h | 61 -- src/mesa/pipe/softpipe/g_state_clip.c | 69 --- src/mesa/pipe/softpipe/g_state_derived.c | 136 ----- src/mesa/pipe/softpipe/g_state_fs.c | 50 -- src/mesa/pipe/softpipe/g_state_setup.c | 122 ---- src/mesa/pipe/softpipe/g_state_surface.c | 53 -- src/mesa/pipe/softpipe/g_surface.c | 153 ----- src/mesa/pipe/softpipe/g_surface.h | 115 ---- src/mesa/pipe/softpipe/g_tile.h | 42 -- src/mesa/pipe/softpipe/g_tile_fs.c | 203 ------- src/mesa/pipe/softpipe/g_tile_output.c | 92 ---- src/mesa/sources | 63 ++- src/mesa/state_tracker/st_atom_blend.c | 92 ++-- src/mesa/state_tracker/st_atom_cbuf.c | 6 +- src/mesa/state_tracker/st_atom_clip.c | 8 +- src/mesa/state_tracker/st_atom_depth.c | 26 +- src/mesa/state_tracker/st_atom_fs.c | 6 +- src/mesa/state_tracker/st_atom_scissor.c | 6 +- src/mesa/state_tracker/st_atom_setup.c | 6 +- src/mesa/state_tracker/st_atom_stencil.c | 44 +- src/mesa/state_tracker/st_atom_viewport.c | 6 +- src/mesa/state_tracker/st_context.c | 8 +- src/mesa/state_tracker/st_context.h | 26 +- src/mesa/state_tracker/st_draw.c | 8 +- src/mesa/state_tracker/st_public.h | 4 +- 44 files changed, 302 insertions(+), 4812 deletions(-) delete mode 100644 src/mesa/pipe/softpipe/g_context.c delete mode 100644 src/mesa/pipe/softpipe/g_context.h delete mode 100644 src/mesa/pipe/softpipe/g_draw.c delete mode 100644 src/mesa/pipe/softpipe/g_draw.h delete mode 100644 src/mesa/pipe/softpipe/g_headers.h delete mode 100644 src/mesa/pipe/softpipe/g_prim.h delete mode 100644 src/mesa/pipe/softpipe/g_prim_clip.c delete mode 100644 src/mesa/pipe/softpipe/g_prim_cull.c delete mode 100644 src/mesa/pipe/softpipe/g_prim_flatshade.c delete mode 100644 src/mesa/pipe/softpipe/g_prim_offset.c delete mode 100644 src/mesa/pipe/softpipe/g_prim_setup.c delete mode 100644 src/mesa/pipe/softpipe/g_prim_setup.h delete mode 100644 src/mesa/pipe/softpipe/g_prim_twoside.c delete mode 100644 src/mesa/pipe/softpipe/g_prim_unfilled.c delete mode 100644 src/mesa/pipe/softpipe/g_state.h delete mode 100644 src/mesa/pipe/softpipe/g_state_clip.c delete mode 100644 src/mesa/pipe/softpipe/g_state_derived.c delete mode 100644 src/mesa/pipe/softpipe/g_state_fs.c delete mode 100644 src/mesa/pipe/softpipe/g_state_setup.c delete mode 100644 src/mesa/pipe/softpipe/g_state_surface.c delete mode 100644 src/mesa/pipe/softpipe/g_surface.c delete mode 100644 src/mesa/pipe/softpipe/g_surface.h delete mode 100644 src/mesa/pipe/softpipe/g_tile.h delete mode 100644 src/mesa/pipe/softpipe/g_tile_fs.c delete mode 100644 src/mesa/pipe/softpipe/g_tile_output.c (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index af1a169a76..396a0923e9 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -80,8 +80,8 @@ #include "tnl/t_pipeline.h" #include "drivers/common/driverfuncs.h" -#include "softpipe/state_tracker/st_public.h" -#include "softpipe/generic/g_context.h" +#include "state_tracker/st_public.h" +#include "pipe/softpipe/sp_context.h" /** * Global X driver lock @@ -1561,7 +1561,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) st_create_context( mesaCtx, - generic_create() ); + softpipe_create() ); return c; } diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 63e7115e80..eb59d1d05e 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -53,8 +53,8 @@ #include "tnl/tnl.h" #include "tnl/t_context.h" -#include "softpipe/generic/g_context.h" -#include "softpipe/state_tracker/st_public.h" +#include "pipe/softpipe/sp_context.h" +#include "state_tracker/st_public.h" /* diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 716ddd27a9..dc7a80744a 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -25,12 +25,14 @@ * **************************************************************************/ -#ifndef SP_CONTEXT_H -#define SP_CONTEXT_H +#ifndef PIPE_CONTEXT_H +#define PIPE_CONTEXT_H #include "mtypes.h" -extern struct softpipe_context *generic_create( void ); +/* Kludge: + */ +extern struct pipe_context *softpipe_create( void ); /* Drawing currently kludged up via the existing tnl/ module. */ @@ -41,48 +43,48 @@ struct vertex_buffer; * Software pipeline rendering context. Basically a collection of * state setting functions, plus VBO drawing entrypoint. */ -struct softpipe_context { +struct pipe_context { - void (*destroy)( struct softpipe_context * ); + void (*destroy)( struct pipe_context * ); /* * Drawing */ - void (*draw_vb)( struct softpipe_context *softpipe, + void (*draw_vb)( struct pipe_context *pipe, struct vertex_buffer *VB ); /* * State functions */ - void (*set_blend_state)( struct softpipe_context *, - const struct softpipe_blend_state * ); + void (*set_blend_state)( struct pipe_context *, + const struct pipe_blend_state * ); - void (*set_cbuf_state)( struct softpipe_context *, - const struct softpipe_surface * ); + void (*set_cbuf_state)( struct pipe_context *, + const struct pipe_surface * ); - void (*set_clip_state)( struct softpipe_context *, - const struct softpipe_clip_state * ); + void (*set_clip_state)( struct pipe_context *, + const struct pipe_clip_state * ); - void (*set_depth_state)( struct softpipe_context *, - const struct softpipe_depth_state * ); + void (*set_depth_state)( struct pipe_context *, + const struct pipe_depth_state * ); - void (*set_fs_state)( struct softpipe_context *, - const struct softpipe_fs_state * ); + void (*set_fs_state)( struct pipe_context *, + const struct pipe_fs_state * ); - void (*set_polygon_stipple)( struct softpipe_context *, - const struct softpipe_poly_stipple * ); + void (*set_polygon_stipple)( struct pipe_context *, + const struct pipe_poly_stipple * ); - void (*set_setup_state)( struct softpipe_context *, - const struct softpipe_setup_state * ); + void (*set_setup_state)( struct pipe_context *, + const struct pipe_setup_state * ); - void (*set_scissor_rect)( struct softpipe_context *, - const struct softpipe_scissor_rect * ); + void (*set_scissor_rect)( struct pipe_context *, + const struct pipe_scissor_rect * ); - void (*set_stencil_state)( struct softpipe_context *, - const struct softpipe_stencil_state * ); + void (*set_stencil_state)( struct pipe_context *, + const struct pipe_stencil_state * ); - void (*set_viewport)( struct softpipe_context *, - const struct softpipe_viewport * ); + void (*set_viewport)( struct pipe_context *, + const struct pipe_viewport * ); }; diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index c381865dab..1ca717e7ec 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -25,97 +25,97 @@ * **************************************************************************/ -#ifndef SP_DEFINES_H -#define SP_DEFINES_H +#ifndef PIPE_DEFINES_H +#define PIPE_DEFINES_H -#define SP_BLENDFACTOR_ONE 0x1 -#define SP_BLENDFACTOR_SRC_COLOR 0x2 -#define SP_BLENDFACTOR_SRC_ALPHA 0x3 -#define SP_BLENDFACTOR_DST_ALPHA 0x4 -#define SP_BLENDFACTOR_DST_COLOR 0x5 -#define SP_BLENDFACTOR_SRC_ALPHA_SATURATE 0x6 -#define SP_BLENDFACTOR_CONST_COLOR 0x7 -#define SP_BLENDFACTOR_CONST_ALPHA 0x8 -#define SP_BLENDFACTOR_SRC1_COLOR 0x9 -#define SP_BLENDFACTOR_SRC1_ALPHA 0x0A -#define SP_BLENDFACTOR_ZERO 0x11 -#define SP_BLENDFACTOR_INV_SRC_COLOR 0x12 -#define SP_BLENDFACTOR_INV_SRC_ALPHA 0x13 -#define SP_BLENDFACTOR_INV_DST_ALPHA 0x14 -#define SP_BLENDFACTOR_INV_DST_COLOR 0x15 -#define SP_BLENDFACTOR_INV_CONST_COLOR 0x17 -#define SP_BLENDFACTOR_INV_CONST_ALPHA 0x18 -#define SP_BLENDFACTOR_INV_SRC1_COLOR 0x19 -#define SP_BLENDFACTOR_INV_SRC1_ALPHA 0x1A +#define PIPE_BLENDFACTOR_ONE 0x1 +#define PIPE_BLENDFACTOR_SRC_COLOR 0x2 +#define PIPE_BLENDFACTOR_SRC_ALPHA 0x3 +#define PIPE_BLENDFACTOR_DST_ALPHA 0x4 +#define PIPE_BLENDFACTOR_DST_COLOR 0x5 +#define PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE 0x6 +#define PIPE_BLENDFACTOR_CONST_COLOR 0x7 +#define PIPE_BLENDFACTOR_CONST_ALPHA 0x8 +#define PIPE_BLENDFACTOR_SRC1_COLOR 0x9 +#define PIPE_BLENDFACTOR_SRC1_ALPHA 0x0A +#define PIPE_BLENDFACTOR_ZERO 0x11 +#define PIPE_BLENDFACTOR_INV_SRC_COLOR 0x12 +#define PIPE_BLENDFACTOR_INV_SRC_ALPHA 0x13 +#define PIPE_BLENDFACTOR_INV_DST_ALPHA 0x14 +#define PIPE_BLENDFACTOR_INV_DST_COLOR 0x15 +#define PIPE_BLENDFACTOR_INV_CONST_COLOR 0x17 +#define PIPE_BLENDFACTOR_INV_CONST_ALPHA 0x18 +#define PIPE_BLENDFACTOR_INV_SRC1_COLOR 0x19 +#define PIPE_BLENDFACTOR_INV_SRC1_ALPHA 0x1A -#define SP_BLEND_ADD 0 -#define SP_BLEND_SUBTRACT 1 -#define SP_BLEND_REVERSE_SUBTRACT 2 -#define SP_BLEND_MIN 3 -#define SP_BLEND_MAX 4 +#define PIPE_BLEND_ADD 0 +#define PIPE_BLEND_SUBTRACT 1 +#define PIPE_BLEND_REVERSE_SUBTRACT 2 +#define PIPE_BLEND_MIN 3 +#define PIPE_BLEND_MAX 4 -#define SP_LOGICOP_CLEAR 0 -#define SP_LOGICOP_NOR 1 -#define SP_LOGICOP_AND_INVERTED 2 -#define SP_LOGICOP_COPY_INVERTED 3 -#define SP_LOGICOP_AND_REVERSE 4 -#define SP_LOGICOP_INVERT 5 -#define SP_LOGICOP_XOR 6 -#define SP_LOGICOP_NAND 7 -#define SP_LOGICOP_AND 8 -#define SP_LOGICOP_EQUIV 9 -#define SP_LOGICOP_NOOP 10 -#define SP_LOGICOP_OR_INVERTED 11 -#define SP_LOGICOP_COPY 12 -#define SP_LOGICOP_OR_REVERSE 13 -#define SP_LOGICOP_OR 14 -#define SP_LOGICOP_SET 15 +#define PIPE_LOGICOP_CLEAR 0 +#define PIPE_LOGICOP_NOR 1 +#define PIPE_LOGICOP_AND_INVERTED 2 +#define PIPE_LOGICOP_COPY_INVERTED 3 +#define PIPE_LOGICOP_AND_REVERSE 4 +#define PIPE_LOGICOP_INVERT 5 +#define PIPE_LOGICOP_XOR 6 +#define PIPE_LOGICOP_NAND 7 +#define PIPE_LOGICOP_AND 8 +#define PIPE_LOGICOP_EQUIV 9 +#define PIPE_LOGICOP_NOOP 10 +#define PIPE_LOGICOP_OR_INVERTED 11 +#define PIPE_LOGICOP_COPY 12 +#define PIPE_LOGICOP_OR_REVERSE 13 +#define PIPE_LOGICOP_OR 14 +#define PIPE_LOGICOP_SET 15 -#define SP_STENCIL_FUNC_NEVER 0 -#define SP_STENCIL_FUNC_LESS 1 -#define SP_STENCIL_FUNC_EQUAL 2 -#define SP_STENCIL_FUNC_LEQUAL 3 -#define SP_STENCIL_FUNC_GREATER 4 -#define SP_STENCIL_FUNC_NOTEQUAL 5 -#define SP_STENCIL_FUNC_GEQUAL 6 -#define SP_STENCIL_FUNC_ALWAYS 7 +#define PIPE_STENCIL_FUNC_NEVER 0 +#define PIPE_STENCIL_FUNC_LESS 1 +#define PIPE_STENCIL_FUNC_EQUAL 2 +#define PIPE_STENCIL_FUNC_LEQUAL 3 +#define PIPE_STENCIL_FUNC_GREATER 4 +#define PIPE_STENCIL_FUNC_NOTEQUAL 5 +#define PIPE_STENCIL_FUNC_GEQUAL 6 +#define PIPE_STENCIL_FUNC_ALWAYS 7 -#define SP_STENCIL_OP_KEEP 0 -#define SP_STENCIL_OP_ZERO 1 -#define SP_STENCIL_OP_REPLACE 2 -#define SP_STENCIL_OP_INCR 3 -#define SP_STENCIL_OP_DECR 4 -#define SP_STENCIL_OP_INCR_WRAP 5 -#define SP_STENCIL_OP_DECR_WRAP 6 -#define SP_STENCIL_OP_INVERT 7 +#define PIPE_STENCIL_OP_KEEP 0 +#define PIPE_STENCIL_OP_ZERO 1 +#define PIPE_STENCIL_OP_REPLACE 2 +#define PIPE_STENCIL_OP_INCR 3 +#define PIPE_STENCIL_OP_DECR 4 +#define PIPE_STENCIL_OP_INCR_WRAP 5 +#define PIPE_STENCIL_OP_DECR_WRAP 6 +#define PIPE_STENCIL_OP_INVERT 7 /* Note: same as stencil funcs. Also used for shadow/depth compare */ -#define SP_DEPTH_FUNC_NEVER 0 -#define SP_DEPTH_FUNC_LESS 1 -#define SP_DEPTH_FUNC_EQUAL 2 -#define SP_DEPTH_FUNC_LEQUAL 3 -#define SP_DEPTH_FUNC_GREATER 4 -#define SP_DEPTH_FUNC_NOTEQUAL 5 -#define SP_DEPTH_FUNC_GEQUAL 6 -#define SP_DEPTH_FUNC_ALWAYS 7 +#define PIPE_DEPTH_FUNC_NEVER 0 +#define PIPE_DEPTH_FUNC_LESS 1 +#define PIPE_DEPTH_FUNC_EQUAL 2 +#define PIPE_DEPTH_FUNC_LEQUAL 3 +#define PIPE_DEPTH_FUNC_GREATER 4 +#define PIPE_DEPTH_FUNC_NOTEQUAL 5 +#define PIPE_DEPTH_FUNC_GEQUAL 6 +#define PIPE_DEPTH_FUNC_ALWAYS 7 -#define SP_TEX_WRAP_REPEAT 0 -#define SP_TEX_WRAP_CLAMP 1 -#define SP_TEX_WRAP_CLAMP_TO_EDGE 2 -#define SP_TEX_WRAP_CLAMP_TO_BORDER 3 -#define SP_TEX_WRAP_MIRROR_REPEAT 4 -#define SP_TEX_WRAP_MIRROR_CLAMP 5 -#define SP_TEX_WRAP_MIRROR_CLAMP_TO_EDGE 6 -#define SP_TEX_WRAP_MIRROR_CLAMP_TO_BORDER 7 +#define PIPE_TEX_WRAP_REPEAT 0 +#define PIPE_TEX_WRAP_CLAMP 1 +#define PIPE_TEX_WRAP_CLAMP_TO_EDGE 2 +#define PIPE_TEX_WRAP_CLAMP_TO_BORDER 3 +#define PIPE_TEX_WRAP_MIRROR_REPEAT 4 +#define PIPE_TEX_WRAP_MIRROR_CLAMP 5 +#define PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE 6 +#define PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER 7 -#define SP_TEX_FILTER_NEAREST 0 -#define SP_TEX_FILTER_LINEAR 1 -#define SP_TEX_FILTER_NEAREST_MIPMAP_NEAREST 2 -#define SP_TEX_FILTER_NEAREST_MIPMAP_LINEAR 3 -#define SP_TEX_FILTER_LINEAR_MIPMAP_NEAREST 4 -#define SP_TEX_FILTER_LINEAR_MIPMAP_LINEAR 5 +#define PIPE_TEX_FILTER_NEAREST 0 +#define PIPE_TEX_FILTER_LINEAR 1 +#define PIPE_TEX_FILTER_NEAREST_MIPMAP_NEAREST 2 +#define PIPE_TEX_FILTER_NEAREST_MIPMAP_LINEAR 3 +#define PIPE_TEX_FILTER_LINEAR_MIPMAP_NEAREST 4 +#define PIPE_TEX_FILTER_LINEAR_MIPMAP_LINEAR 5 -#define SP_TEX_COMPARE_NONE 0 -#define SP_TEX_COMPARE_R_TO_TEXTURE 1 +#define PIPE_TEX_COMPARE_NONE 0 +#define PIPE_TEX_COMPARE_R_TO_TEXTURE 1 #endif diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 150fa9fcad..7264f253d9 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -25,8 +25,8 @@ * **************************************************************************/ -#ifndef SP_STATE_H -#define SP_STATE_H +#ifndef PIPE_STATE_H +#define PIPE_STATE_H #include "mtypes.h" #include "vf/vf.h" @@ -40,7 +40,7 @@ #define FILL_LINE 2 #define FILL_TRI 3 -struct softpipe_setup_state { +struct pipe_setup_state { GLuint flatshade:1; GLuint light_twoside:1; @@ -63,17 +63,17 @@ struct softpipe_setup_state { GLfloat offset_scale; }; -struct softpipe_poly_stipple { +struct pipe_poly_stipple { GLuint stipple[32]; }; -struct softpipe_viewport { +struct pipe_viewport { GLfloat scale[4]; GLfloat translate[4]; }; -struct softpipe_scissor_rect { +struct pipe_scissor_rect { GLshort minx; GLshort miny; GLshort maxx; @@ -81,26 +81,26 @@ struct softpipe_scissor_rect { }; -#define SP_MAX_CLIP_PLANES 6 +#define PIPE_MAX_CLIP_PLANES 6 -struct softpipe_clip_state { - GLfloat ucp[SP_MAX_CLIP_PLANES][4]; +struct pipe_clip_state { + GLfloat ucp[PIPE_MAX_CLIP_PLANES][4]; GLuint nr; }; -struct softpipe_fs_state { +struct pipe_fs_state { struct gl_fragment_program *fp; }; -#define SP_MAX_CONSTANT 32 +#define PIPE_MAX_CONSTANT 32 -struct softpipe_constant_buffer { - GLfloat constant[SP_MAX_CONSTANT][4]; +struct pipe_constant_buffer { + GLfloat constant[PIPE_MAX_CONSTANT][4]; GLuint nr_constants; }; -struct softpipe_depth_state +struct pipe_depth_state { GLuint enabled:1; /**< depth test enabled? */ GLuint writemask:1; /**< allow depth buffer writes? */ @@ -109,7 +109,7 @@ struct softpipe_depth_state }; -struct softpipe_blend_state { +struct pipe_blend_state { GLuint blend_enable:1; GLuint rgb_func:3; @@ -124,17 +124,17 @@ struct softpipe_blend_state { GLuint logicop_func:4; }; -struct softpipe_blend_color { +struct pipe_blend_color { GLfloat color[4]; }; -struct softpipe_stencil_state { +struct pipe_stencil_state { GLuint front_enabled:1; - GLuint front_func:3; /**< SP_STENCIL_FUNC_x */ - GLuint front_fail_op:3; /**< SP_STENCIL_OP_x */ - GLuint front_zpass_op:3; /**< SP_STENCIL_OP_x */ - GLuint front_zfail_op:3; /**< SP_STENCIL_OP_x */ + GLuint front_func:3; /**< PIPE_STENCIL_FUNC_x */ + GLuint front_fail_op:3; /**< PIPE_STENCIL_OP_x */ + GLuint front_zpass_op:3; /**< PIPE_STENCIL_OP_x */ + GLuint front_zfail_op:3; /**< PIPE_STENCIL_OP_x */ GLuint back_enabled:1; GLuint back_func:3; GLuint back_fail_op:3; @@ -147,9 +147,9 @@ struct softpipe_stencil_state { }; -/* This will change for hardware softpipes... +/* This will change for hardware pipes... */ -struct softpipe_surface { +struct pipe_surface { GLubyte *ptr; GLint stride; GLuint cpp; @@ -160,13 +160,13 @@ struct softpipe_surface { /** * Texture sampler state. */ -struct softpipe_sampler_state +struct pipe_sampler_state { - GLuint wrap_s:3; /**< SP_TEX_WRAP_x */ - GLuint wrap_t:3; /**< SP_TEX_WRAP_x */ - GLuint wrap_r:3; /**< SP_TEX_WRAP_x */ - GLuint min_filter:3; /**< SP_TEX_FILTER_x */ - GLuint mag_filter:1; /**< SP_TEX_FILTER_LINEAR or _NEAREST */ + GLuint wrap_s:3; /**< PIPE_TEX_WRAP_x */ + GLuint wrap_t:3; /**< PIPE_TEX_WRAP_x */ + GLuint wrap_r:3; /**< PIPE_TEX_WRAP_x */ + GLuint min_filter:3; /**< PIPE_TEX_FILTER_x */ + GLuint mag_filter:1; /**< PIPE_TEX_FILTER_LINEAR or _NEAREST */ GLfloat min_lod; GLfloat max_lod; GLfloat lod_bias; @@ -176,8 +176,8 @@ struct softpipe_sampler_state #endif GLfloat max_anisotropy; GLuint compare:1; /**< shadow/depth compare enabled? */ - GLenum compare_mode:1; /**< SP_TEX_COMPARE_x */ - GLenum compare_func:3; /**< SP_DEPTH_FUNC_x */ + GLenum compare_mode:1; /**< PIPE_TEX_COMPARE_x */ + GLenum compare_func:3; /**< PIPE_DEPTH_FUNC_x */ GLfloat shadow_ambient; /**< shadow test fail color/intensity */ }; diff --git a/src/mesa/pipe/softpipe/g_context.c b/src/mesa/pipe/softpipe/g_context.c deleted file mode 100644 index c3329b5c7d..0000000000 --- a/src/mesa/pipe/softpipe/g_context.c +++ /dev/null @@ -1,135 +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. - * - **************************************************************************/ - -/* Author: - * Keith Whitwell - */ - -#include "imports.h" -#include "macros.h" - -#include "tnl/t_context.h" -#include "vf/vf.h" - -#include "g_context.h" -#include "g_prim.h" -#include "g_state.h" -#include "g_draw.h" - -static void generic_destroy( struct softpipe_context *softpipe ) -{ - struct generic_context *generic = generic_context( softpipe ); - - draw_destroy( generic->draw ); - - FREE( generic ); -} - - -static void generic_draw_vb( struct softpipe_context *softpipe, - struct vertex_buffer *VB ) -{ - struct generic_context *generic = generic_context( softpipe ); - - if (generic->dirty) - generic_update_derived( generic ); - - draw_vb( generic->draw, VB ); -} - -struct softpipe_context *generic_create( void ) -{ - struct generic_context *generic = CALLOC_STRUCT(generic_context); - - generic->softpipe.destroy = generic_destroy; - generic->softpipe.set_clip_state = generic_set_clip_state; - generic->softpipe.set_viewport = generic_set_viewport; - generic->softpipe.set_setup_state = generic_set_setup_state; - generic->softpipe.set_scissor_rect = generic_set_scissor_rect; - generic->softpipe.set_fs_state = generic_set_fs_state; - generic->softpipe.set_polygon_stipple = generic_set_polygon_stipple; - generic->softpipe.set_cbuf_state = generic_set_cbuf_state; - generic->softpipe.draw_vb = generic_draw_vb; - - - - generic->prim.setup = prim_setup( generic ); - generic->prim.unfilled = prim_unfilled( generic ); - generic->prim.twoside = prim_twoside( generic ); - generic->prim.offset = prim_offset( generic ); - generic->prim.clip = prim_clip( generic ); - generic->prim.flatshade = prim_flatshade( generic ); - generic->prim.cull = prim_cull( generic ); - - - generic->draw = draw_create( generic ); - - ASSIGN_4V( generic->plane[0], -1, 0, 0, 1 ); - ASSIGN_4V( generic->plane[1], 1, 0, 0, 1 ); - ASSIGN_4V( generic->plane[2], 0, -1, 0, 1 ); - ASSIGN_4V( generic->plane[3], 0, 1, 0, 1 ); - ASSIGN_4V( generic->plane[4], 0, 0, 1, 1 ); /* yes these are correct */ - ASSIGN_4V( generic->plane[5], 0, 0, -1, 1 ); /* mesa's a bit wonky */ - generic->nr_planes = 6; - - return &generic->softpipe; -} - - - - - - -#define MAX_VERTEX_SIZE ((2 + FRAG_ATTRIB_MAX) * 4 * sizeof(GLfloat)) - -void prim_alloc_tmps( struct prim_stage *stage, GLuint nr ) -{ - stage->nr_tmps = nr; - - if (nr) { - GLubyte *store = MALLOC(MAX_VERTEX_SIZE * nr); - GLuint i; - - stage->tmp = MALLOC(sizeof(struct vertex_header *) * nr); - - for (i = 0; i < nr; i++) - stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE); - } -} - -void prim_free_tmps( struct prim_stage *stage ) -{ - if (stage->tmp) { - FREE(stage->tmp[0]); - FREE(stage->tmp); - } -} - - - - - diff --git a/src/mesa/pipe/softpipe/g_context.h b/src/mesa/pipe/softpipe/g_context.h deleted file mode 100644 index 24d467f2c3..0000000000 --- a/src/mesa/pipe/softpipe/g_context.h +++ /dev/null @@ -1,149 +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: Keith Whitwell - */ - -#ifndef G_CONTEXT_H -#define G_CONTEXT_H - -#include "glheader.h" - -#include "softpipe/sp_state.h" -#include "softpipe/sp_context.h" - - - -struct generic_surface; -struct draw_context; -struct prim_stage; - - -enum interp_mode { - INTERP_CONSTANT, - INTERP_LINEAR, - INTERP_PERSPECTIVE -}; - - -#define G_NEW_VIEWPORT 0x1 -#define G_NEW_SETUP 0x2 -#define G_NEW_FS 0x4 -#define G_NEW_BLEND 0x8 -#define G_NEW_CBUF 0x10 -#define G_NEW_CLIP 0x20 -#define G_NEW_SCISSOR 0x40 -#define G_NEW_STIPPLE 0x80 - - - -struct generic_context { - struct softpipe_context softpipe; - - - /* The most recent drawing state as set by the driver: - */ - struct softpipe_viewport viewport; - struct softpipe_setup_state setup; - struct softpipe_fs_state fs; - struct softpipe_blend_state blend; - struct softpipe_surface cbuf; - struct softpipe_clip_state clip; - struct softpipe_scissor_rect scissor; - struct softpipe_poly_stipple poly_stipple; - GLuint dirty; - - - /* Cbuf derived state??? - */ - struct generic_surface *cbuf_surface; - - /* Clip derived state: - */ - GLfloat plane[12][4]; - GLuint nr_planes; - - /* Setup derived state. TODO: this should be passed in the program - * tokens as parameters to DECL instructions. - * - * For now we just set colors to CONST on flatshade, textures to - * perspective always and everything else to linear. - */ - enum interp_mode interp[VF_ATTRIB_MAX]; - - - /* FS + setup derived state: - */ - GLuint fp_attr_to_slot[VF_ATTRIB_MAX]; - GLuint vf_attr_to_slot[VF_ATTRIB_MAX]; - GLuint nr_attrs; - GLuint nr_frag_attrs; - GLuint attr_mask; - - GLboolean need_z; - GLboolean need_w; - - /* Stipple derived state: - */ - GLubyte stipple_masks[16][16]; - - - /* The software clipper/setup engine. - */ - struct { - struct prim_stage *setup; - struct prim_stage *unfilled; - struct prim_stage *twoside; - struct prim_stage *clip; - struct prim_stage *flatshade; - struct prim_stage *offset; - struct prim_stage *cull; - - struct prim_stage *first; - - GLenum prim; - GLuint vertex_size; - } prim; - - /* Temp kludge: - */ - struct draw_context *draw; -}; - - - - -static INLINE struct generic_context * -generic_context( struct softpipe_context *softpipe ) -{ - return (struct generic_context *)softpipe; -} - - - - -#endif diff --git a/src/mesa/pipe/softpipe/g_draw.c b/src/mesa/pipe/softpipe/g_draw.c deleted file mode 100644 index 4e094c21a0..0000000000 --- a/src/mesa/pipe/softpipe/g_draw.c +++ /dev/null @@ -1,696 +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: - * Keith Whitwell - */ - -#include "imports.h" - -#include "tnl/t_context.h" - -#include "g_context.h" -#include "g_prim.h" -#include "g_headers.h" -#include "g_draw.h" - -/* This file is a temporary set of hooks to allow us to use the tnl/ - * and vf/ modules until we have replacements in softpipe. - */ - - -struct draw_context -{ - struct generic_context *generic; - - struct vf_attr_map attrs[VF_ATTRIB_MAX]; - GLuint nr_attrs; - GLuint vertex_size; - struct vertex_fetch *vf; - - GLubyte *verts; - GLuint nr_vertices; - GLboolean in_vb; - - GLenum prim; - - /* Helper for tnl: - */ - GLvector4f header; -}; - - -static struct vertex_header *get_vertex( struct draw_context *pipe, - GLuint i ) -{ - return (struct vertex_header *)(pipe->verts + i * pipe->vertex_size); -} - - - -static void draw_allocate_vertices( struct draw_context *draw, - GLuint nr_vertices ) -{ - draw->nr_vertices = nr_vertices; - draw->verts = MALLOC( nr_vertices * draw->vertex_size ); - - draw->generic->prim.first->begin( draw->generic->prim.first ); -} - -static void draw_set_prim( struct draw_context *draw, - GLenum prim ) -{ - draw->prim = prim; - - /* Not done yet - need to force edgeflags to 1 in strip/fan - * primitives. - */ -#if 0 - switch (prim) { - case GL_TRIANGLES: - case GL_POLYGON: - case GL_QUADS: - case GL_QUAD_STRIP: /* yes, we need this */ - respect_edgeflags( pipe, GL_TRUE ); - break; - - default: - respect_edgeflags( pipe, GL_FALSE ); - break; - } -#endif -} - - - -static void do_quad( struct prim_stage *first, - struct vertex_header *v0, - struct vertex_header *v1, - struct vertex_header *v2, - struct vertex_header *v3 ) -{ - struct prim_header prim; - - { - GLuint tmp = v1->edgeflag; - v1->edgeflag = 0; - - prim.v[0] = v0; - prim.v[1] = v1; - prim.v[2] = v3; - first->tri( first, &prim ); - - v1->edgeflag = tmp; - } - - { - GLuint tmp = v3->edgeflag; - v3->edgeflag = 0; - - prim.v[0] = v1; - prim.v[1] = v2; - prim.v[2] = v3; - first->tri( first, &prim ); - - v3->edgeflag = tmp; - } -} - - - - -static void draw_indexed_prim( struct draw_context *draw, - const GLuint *elts, - GLuint count ) -{ - struct prim_stage * const first = draw->generic->prim.first; - struct prim_header prim; - GLuint i; - - prim.det = 0; /* valid from cull stage onwards */ - prim.v[0] = 0; - prim.v[1] = 0; - prim.v[2] = 0; - - switch (draw->prim) { - case GL_POINTS: - for (i = 0; i < count; i ++) { - prim.v[0] = get_vertex( draw, elts[i] ); - - first->point( first, &prim ); - } - break; - - case GL_LINES: - for (i = 0; i+1 < count; i += 2) { - prim.v[0] = get_vertex( draw, elts[i + 0] ); - prim.v[1] = get_vertex( draw, elts[i + 1] ); - - first->line( first, &prim ); - } - break; - - case GL_LINE_LOOP: - if (count >= 2) { - for (i = 1; i < count; i++) { - prim.v[0] = get_vertex( draw, elts[i-1] ); - prim.v[1] = get_vertex( draw, elts[i] ); - first->line( first, &prim ); - } - - prim.v[0] = get_vertex( draw, elts[count-1] ); - prim.v[1] = get_vertex( draw, elts[0] ); - first->line( first, &prim ); - } - break; - - case GL_LINE_STRIP: - /* I'm guessing it will be necessary to have something like a - * render->reset_line_stipple() method to properly support - * splitting strips into primitives like this. Alternately we - * could just scan ahead to find individual clipped lines and - * otherwise leave the strip intact - that might be better, but - * require more complex code here. - */ - if (count >= 2) { - prim.v[0] = 0; - prim.v[1] = get_vertex( draw, elts[0] ); - - for (i = 1; i < count; i++) { - prim.v[0] = prim.v[1]; - prim.v[1] = get_vertex( draw, elts[i] ); - - first->line( first, &prim ); - } - } - break; - - case GL_TRIANGLES: - for (i = 0; i+2 < count; i += 3) { - prim.v[0] = get_vertex( draw, elts[i + 0] ); - prim.v[1] = get_vertex( draw, elts[i + 1] ); - prim.v[2] = get_vertex( draw, elts[i + 2] ); - - first->tri( first, &prim ); - } - break; - - case GL_TRIANGLE_STRIP: - for (i = 0; i+2 < count; i++) { - if (i & 1) { - prim.v[0] = get_vertex( draw, elts[i + 1] ); - prim.v[1] = get_vertex( draw, elts[i + 0] ); - prim.v[2] = get_vertex( draw, elts[i + 2] ); - } - else { - prim.v[0] = get_vertex( draw, elts[i + 0] ); - prim.v[1] = get_vertex( draw, elts[i + 1] ); - prim.v[2] = get_vertex( draw, elts[i + 2] ); - } - - first->tri( first, &prim ); - } - break; - - case GL_TRIANGLE_FAN: - if (count >= 3) { - prim.v[0] = get_vertex( draw, elts[0] ); - prim.v[1] = 0; - prim.v[2] = get_vertex( draw, elts[1] ); - - for (i = 0; i+2 < count; i++) { - prim.v[1] = prim.v[2]; - prim.v[2] = get_vertex( draw, elts[i+2] ); - - first->tri( first, &prim ); - } - } - break; - - case GL_QUADS: - for (i = 0; i+3 < count; i += 4) { - do_quad( first, - get_vertex( draw, elts[i + 0] ), - get_vertex( draw, elts[i + 1] ), - get_vertex( draw, elts[i + 2] ), - get_vertex( draw, elts[i + 3] )); - } - break; - - case GL_QUAD_STRIP: - for (i = 0; i+3 < count; i += 2) { - do_quad( first, - get_vertex( draw, elts[i + 2] ), - get_vertex( draw, elts[i + 0] ), - get_vertex( draw, elts[i + 1] ), - get_vertex( draw, elts[i + 3] )); - } - break; - - - case GL_POLYGON: - if (count >= 3) { - prim.v[0] = 0; - prim.v[1] = get_vertex( draw, elts[1] ); - prim.v[2] = get_vertex( draw, elts[0] ); - - for (i = 0; i+2 < count; i++) { - prim.v[0] = prim.v[1]; - prim.v[1] = get_vertex( draw, elts[i+2] ); - - first->tri( first, &prim ); - } - } - break; - - default: - assert(0); - break; - } -} - -static void draw_prim( struct draw_context *draw, - GLuint start, - GLuint count ) -{ - struct prim_stage * const first = draw->generic->prim.first; - struct prim_header prim; - GLuint i; - -// _mesa_printf("%s (%d) %d/%d\n", __FUNCTION__, draw->prim, start, count ); - - prim.det = 0; /* valid from cull stage onwards */ - prim.v[0] = 0; - prim.v[1] = 0; - prim.v[2] = 0; - - switch (draw->prim) { - case GL_POINTS: - for (i = 0; i < count; i ++) { - prim.v[0] = get_vertex( draw, start + i ); - first->point( first, &prim ); - } - break; - - case GL_LINES: - for (i = 0; i+1 < count; i += 2) { - prim.v[0] = get_vertex( draw, start + i + 0 ); - prim.v[1] = get_vertex( draw, start + i + 1 ); - - first->line( first, &prim ); - } - break; - - case GL_LINE_LOOP: - if (count >= 2) { - for (i = 1; i < count; i++) { - prim.v[0] = get_vertex( draw, start + i - 1 ); - prim.v[1] = get_vertex( draw, start + i ); - first->line( first, &prim ); - } - - prim.v[0] = get_vertex( draw, start + count - 1 ); - prim.v[1] = get_vertex( draw, start + 0 ); - first->line( first, &prim ); - } - break; - - case GL_LINE_STRIP: - if (count >= 2) { - prim.v[0] = 0; - prim.v[1] = get_vertex( draw, start + 0 ); - - for (i = 1; i < count; i++) { - prim.v[0] = prim.v[1]; - prim.v[1] = get_vertex( draw, start + i ); - - first->line( first, &prim ); - } - } - break; - - case GL_TRIANGLES: - for (i = 0; i+2 < count; i += 3) { - prim.v[0] = get_vertex( draw, start + i + 0 ); - prim.v[1] = get_vertex( draw, start + i + 1 ); - prim.v[2] = get_vertex( draw, start + i + 2 ); - - first->tri( first, &prim ); - } - break; - - case GL_TRIANGLE_STRIP: - for (i = 0; i+2 < count; i++) { - if (i & 1) { - prim.v[0] = get_vertex( draw, start + i + 1 ); - prim.v[1] = get_vertex( draw, start + i + 0 ); - prim.v[2] = get_vertex( draw, start + i + 2 ); - } - else { - prim.v[0] = get_vertex( draw, start + i + 0 ); - prim.v[1] = get_vertex( draw, start + i + 1 ); - prim.v[2] = get_vertex( draw, start + i + 2 ); - } - - first->tri( first, &prim ); - } - break; - - case GL_TRIANGLE_FAN: - if (count >= 3) { - prim.v[0] = get_vertex( draw, start + 0 ); - prim.v[1] = 0; - prim.v[2] = get_vertex( draw, start + 1 ); - - for (i = 0; i+2 < count; i++) { - prim.v[1] = prim.v[2]; - prim.v[2] = get_vertex( draw, start + i + 2 ); - - first->tri( first, &prim ); - } - } - break; - - - case GL_QUADS: - for (i = 0; i+3 < count; i += 4) { - do_quad( first, - get_vertex( draw, start + i + 0 ), - get_vertex( draw, start + i + 1 ), - get_vertex( draw, start + i + 2 ), - get_vertex( draw, start + i + 3 )); - } - break; - - case GL_QUAD_STRIP: - for (i = 0; i+3 < count; i += 2) { - do_quad( first, - get_vertex( draw, start + i + 2 ), - get_vertex( draw, start + i + 0 ), - get_vertex( draw, start + i + 1 ), - get_vertex( draw, start + i + 3 )); - } - break; - - case GL_POLYGON: - if (count >= 3) { - prim.v[0] = 0; - prim.v[1] = get_vertex( draw, start + 1 ); - prim.v[2] = get_vertex( draw, start + 0 ); - - for (i = 0; i+2 < count; i++) { - prim.v[0] = prim.v[1]; - prim.v[1] = get_vertex( draw, start + i + 2 ); - - first->tri( first, &prim ); - } - } - break; - - default: - assert(0); - break; - } -} - - -static void draw_release_vertices( struct draw_context *draw ) -{ - draw->generic->prim.first->end( draw->generic->prim.first ); - - FREE(draw->verts); - draw->verts = NULL; -} - - -struct header_dword { - GLuint clipmask:12; - GLuint edgeflag:1; - GLuint pad:19; -}; - - -static void -build_vertex_headers( struct draw_context *draw, - struct vertex_buffer *VB ) -{ - if (draw->header.storage == NULL) { - draw->header.stride = sizeof(GLfloat); - draw->header.size = 1; - draw->header.storage = ALIGN_MALLOC( VB->Size * sizeof(GLfloat), 32 ); - draw->header.data = draw->header.storage; - draw->header.count = 0; - draw->header.flags = VEC_SIZE_1 | VEC_MALLOC; - } - - /* Build vertex header attribute. - * - */ - - { - GLuint i; - struct header_dword *header = (struct header_dword *)draw->header.storage; - - /* yes its a hack - */ - assert(sizeof(*header) == sizeof(GLfloat)); - - draw->header.count = VB->Count; - - if (VB->EdgeFlag) { - for (i = 0; i < VB->Count; i++) { - header[i].clipmask = VB->ClipMask[i]; - header[i].edgeflag = VB->EdgeFlag[i]; - header[i].pad = 0; - } - } - else if (VB->ClipOrMask) { - for (i = 0; i < VB->Count; i++) { - header[i].clipmask = VB->ClipMask[i]; - header[i].edgeflag = 0; - header[i].pad = 0; - } - } - else { - for (i = 0; i < VB->Count; i++) { - header[i].clipmask = 0; - header[i].edgeflag = 0; - header[i].pad = 0; - } - } - } - - VB->AttribPtr[VF_ATTRIB_VERTEX_HEADER] = &draw->header; -} - - - - - -static GLuint draw_prim_info(GLenum mode, GLuint *first, GLuint *incr) -{ - switch (mode) { - case GL_POINTS: - *first = 1; - *incr = 1; - return 0; - case GL_LINES: - *first = 2; - *incr = 2; - return 0; - case GL_LINE_STRIP: - *first = 2; - *incr = 1; - return 0; - case GL_LINE_LOOP: - *first = 2; - *incr = 1; - return 1; - case GL_TRIANGLES: - *first = 3; - *incr = 3; - return 0; - case GL_TRIANGLE_STRIP: - *first = 3; - *incr = 1; - return 0; - case GL_TRIANGLE_FAN: - case GL_POLYGON: - *first = 3; - *incr = 1; - return 1; - case GL_QUADS: - *first = 4; - *incr = 4; - return 0; - case GL_QUAD_STRIP: - *first = 4; - *incr = 2; - return 0; - default: - assert(0); - *first = 1; - *incr = 1; - return 0; - } -} - - -static GLuint trim( GLuint count, GLuint first, GLuint incr ) -{ - if (count < first) - return 0; - else - return count - (count - first) % incr; -} - - -/* This is a hack & will all go away. - */ -void draw_vb(struct draw_context *draw, - struct vertex_buffer *VB ) -{ - GLuint i; - - VB->AttribPtr[VF_ATTRIB_POS] = VB->NdcPtr; - VB->AttribPtr[VF_ATTRIB_BFC0] = VB->ColorPtr[1]; - VB->AttribPtr[VF_ATTRIB_BFC1] = VB->SecondaryColorPtr[1]; - VB->AttribPtr[VF_ATTRIB_CLIP_POS] = VB->ClipPtr; - - /* Build vertex headers: - */ - build_vertex_headers( draw, VB ); - - draw->in_vb = 1; - - /* Allocate the vertices: - */ - draw_allocate_vertices( draw, VB->Count ); - - /* Bind the vb outputs: - */ - vf_set_sources( draw->vf, VB->AttribPtr, 0 ); - - /* Build the hardware or prim-pipe vertices: - */ - vf_emit_vertices( draw->vf, VB->Count, draw->verts ); - - - for (i = 0; i < VB->PrimitiveCount; i++) { - - GLenum mode = VB->Primitive[i].mode; - GLuint start = VB->Primitive[i].start; - GLuint length, first, incr; - - /* Trim the primitive down to a legal size. - */ - draw_prim_info( mode, &first, &incr ); - length = trim( VB->Primitive[i].count, first, incr ); - - if (!length) - continue; - - if (draw->prim != mode) - draw_set_prim( draw, mode ); - - if (VB->Elts) { - draw_indexed_prim( draw, - VB->Elts + start, - length ); - } - else { - draw_prim( draw, - start, - length ); - } - } - - draw_release_vertices( draw ); - draw->verts = NULL; - draw->in_vb = 0; -} - -void draw_set_viewport( struct draw_context *draw, - const GLfloat *scale, - const GLfloat *translate ) -{ - assert(!draw->in_vb); - vf_set_vp_scale_translate( draw->vf, scale, translate ); -} - - - -struct draw_context *draw_create( struct generic_context *generic ) -{ - struct draw_context *draw = CALLOC_STRUCT( draw_context ); - draw->generic = generic; - draw->vf = vf_create( GL_TRUE ); - - return draw; -} - - -void draw_destroy( struct draw_context *draw ) -{ - if (draw->header.storage) - ALIGN_FREE( draw->header.storage ); - - vf_destroy( draw->vf ); - - FREE( draw ); -} - -#define EMIT_ATTR( ATTR, STYLE ) \ -do { \ - draw->attrs[draw->nr_attrs].attrib = ATTR; \ - draw->attrs[draw->nr_attrs].format = STYLE; \ - draw->nr_attrs++; \ -} while (0) - - -void draw_set_vertex_attributes( struct draw_context *draw, - const GLuint *attrs, - GLuint nr_attrs ) -{ - GLuint i; - - draw->nr_attrs = 0; - - EMIT_ATTR(VF_ATTRIB_VERTEX_HEADER, EMIT_1F); - EMIT_ATTR(VF_ATTRIB_CLIP_POS, EMIT_4F); - - assert(attrs[0] == VF_ATTRIB_POS); - EMIT_ATTR(attrs[0], EMIT_4F_VIEWPORT); - - for (i = 1; i < nr_attrs; i++) - EMIT_ATTR(attrs[i], EMIT_4F); - - draw->vertex_size = vf_set_vertex_attributes( draw->vf, draw->attrs, draw->nr_attrs, 0 ); -} - - diff --git a/src/mesa/pipe/softpipe/g_draw.h b/src/mesa/pipe/softpipe/g_draw.h deleted file mode 100644 index 78c93b4df7..0000000000 --- a/src/mesa/pipe/softpipe/g_draw.h +++ /dev/null @@ -1,56 +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: Keith Whitwell - */ - -#ifndef G_DRAW_H -#define G_DRAW_H - -#include "glheader.h" -#include "softpipe/sp_state.h" - - -struct draw_context; - -struct draw_context *draw_create( struct generic_context *generic ); - -void draw_destroy( struct draw_context *draw ); - -void draw_set_viewport( struct draw_context *draw, - const GLfloat *scale, - const GLfloat *translate ); - -void draw_set_vertex_attributes( struct draw_context *draw, - const GLuint *attrs, - GLuint nr_attrs ); - -void draw_vb(struct draw_context *draw, - struct vertex_buffer *VB ); - -#endif diff --git a/src/mesa/pipe/softpipe/g_headers.h b/src/mesa/pipe/softpipe/g_headers.h deleted file mode 100644 index 96ff52a453..0000000000 --- a/src/mesa/pipe/softpipe/g_headers.h +++ /dev/null @@ -1,116 +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: Keith Whitwell - */ -#ifndef G_HEADERS_H -#define G_HEADERS_H - -#define PRIM_POINT 1 -#define PRIM_LINE 2 -#define PRIM_TRI 3 - -struct prim_header { - GLfloat det; - struct vertex_header *v[3]; -}; - -/* Carry some useful information around with the vertices in the prim - * pipe. - */ -struct vertex_header { - GLuint clipmask:12; - GLuint edgeflag:1; - GLuint pad:19; - - GLfloat clip[4]; - - GLfloat data[][4]; /* Note variable size */ -}; - - - - - -/* The rasterizer generates 2x2 quads of fragment and feeds them to - * the current fp_machine (see below). - */ -#define QUAD_BOTTOM_LEFT 0 -#define QUAD_BOTTOM_RIGHT 1 -#define QUAD_TOP_LEFT 2 -#define QUAD_TOP_RIGHT 3 -#define QUAD_SIZE (2*2) - -#define MASK_BOTTOM_LEFT 0x1 -#define MASK_BOTTOM_RIGHT 0x2 -#define MASK_TOP_LEFT 0x4 -#define MASK_TOP_RIGHT 0x8 -#define MASK_ALL 0xf - - -#define NUM_CHANNELS 4 /* avoid confusion between 4 pixels and 4 channels */ - - -struct setup_coefficient { - GLfloat a0[NUM_CHANNELS]; /* in an xyzw layout */ - GLfloat dadx[NUM_CHANNELS]; - GLfloat dady[NUM_CHANNELS]; -}; - - - -/* Encodes everything we need to know about a 2x2 pixel block. Uses - * "Channel-Serial" or "SoA" layout. - * - * Will expand to include non-attribute things like AA coverage and - * maybe prefetched depth from the depth buffer. - */ -struct quad_header { - GLint x0; - GLint y0; - GLuint mask; - GLuint facing; /**< Front or back facing? */ - - struct { - GLfloat color[4][QUAD_SIZE]; /* rrrr, gggg, bbbb, aaaa */ - GLfloat depth[QUAD_SIZE]; - } outputs; - - const struct setup_coefficient *coef; - - const enum interp_mode *interp; /* XXX: this information should be - * encoded in fragment program DECL - * statements. */ - - GLuint nr_attrs; -}; - - - - - -#endif diff --git a/src/mesa/pipe/softpipe/g_prim.h b/src/mesa/pipe/softpipe/g_prim.h deleted file mode 100644 index e3b2c5ea2f..0000000000 --- a/src/mesa/pipe/softpipe/g_prim.h +++ /dev/null @@ -1,90 +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: Keith Whitwell - */ - -#ifndef G_PRIM_H -#define G_PRIM_H - -#include "glheader.h" -#include "g_headers.h" - -struct generic_context; - -struct prim_stage *prim_setup( struct generic_context *context ); -struct prim_stage *prim_unfilled( struct generic_context *context ); -struct prim_stage *prim_twoside( struct generic_context *context ); -struct prim_stage *prim_offset( struct generic_context *context ); -struct prim_stage *prim_clip( struct generic_context *context ); -struct prim_stage *prim_flatshade( struct generic_context *context ); -struct prim_stage *prim_cull( struct generic_context *context ); - - -/* Internal structs and helpers for the primitive clip/setup pipeline: - */ -struct prim_stage { - struct generic_context *generic; - - struct prim_stage *next; - - struct vertex_header **tmp; - GLuint nr_tmps; - - void (*begin)( struct prim_stage * ); - - void (*point)( struct prim_stage *, - struct prim_header * ); - - void (*line)( struct prim_stage *, - struct prim_header * ); - - void (*tri)( struct prim_stage *, - struct prim_header * ); - - void (*end)( struct prim_stage * ); -}; - - - -/* Get a writeable copy of a vertex: - */ -static INLINE struct vertex_header * -dup_vert( struct prim_stage *stage, - const struct vertex_header *vert, - GLuint idx ) -{ - struct vertex_header *tmp = stage->tmp[idx]; - memcpy(tmp, vert, stage->generic->prim.vertex_size ); - return tmp; -} - -void prim_free_tmps( struct prim_stage *stage ); -void prim_alloc_tmps( struct prim_stage *stage, GLuint nr ); - - -#endif diff --git a/src/mesa/pipe/softpipe/g_prim_clip.c b/src/mesa/pipe/softpipe/g_prim_clip.c deleted file mode 100644 index 742def9c7d..0000000000 --- a/src/mesa/pipe/softpipe/g_prim_clip.c +++ /dev/null @@ -1,429 +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: Keith Whitwell - */ - -#include "imports.h" -#include "macros.h" - -#include "g_context.h" -#include "g_prim.h" - -struct clipper { - struct prim_stage stage; - - GLuint active_user_planes; -}; - -/* This is a bit confusing: - */ -static INLINE struct clipper *clipper_stage( struct prim_stage *stage ) -{ - return (struct clipper *)stage; -} - - -#define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT))) - - -/* All attributes are float[4], so this is easy: - */ -static void interp_attr( GLfloat *fdst, - GLfloat t, - const GLfloat *fin, - const GLfloat *fout ) -{ - fdst[0] = LINTERP( t, fout[0], fin[0] ); - fdst[1] = LINTERP( t, fout[1], fin[1] ); - fdst[2] = LINTERP( t, fout[2], fin[2] ); - fdst[3] = LINTERP( t, fout[3], fin[3] ); -} - - - - -/* Interpolate between two vertices to produce a third. - */ -static void interp( struct clipper *clip, - struct vertex_header *dst, - GLfloat t, - const struct vertex_header *out, - const struct vertex_header *in ) -{ - const GLuint nr_attrs = clip->stage.generic->nr_attrs; - GLuint j; - - /* Vertex header. - */ - { - dst->clipmask = 0; - dst->edgeflag = 0; - dst->pad = 0; - } - - /* Clip coordinates: interpolate normally - */ - { - interp_attr(dst->clip, t, in->clip, out->clip); - } - - /* Do the projective divide and insert window coordinates: - */ - { - const GLfloat *pos = dst->clip; - const GLfloat *scale = clip->stage.generic->viewport.scale; - const GLfloat *trans = clip->stage.generic->viewport.translate; - GLfloat oow; - - oow = 1.0 / pos[3]; - - dst->data[0][0] = pos[0] * oow * scale[0] + trans[0]; - dst->data[0][1] = pos[1] * oow * scale[1] + trans[1]; - dst->data[0][2] = pos[2] * oow * scale[2] + trans[2]; - dst->data[0][3] = oow; - } - - - /* Other attributes - */ - for (j = 1; j < nr_attrs-1; j++) { - interp_attr(dst->data[j], t, in->data[j], out->data[j]); - } -} - - -#define CLIP_USER_BIT 0x40 -#define CLIP_CULL_BIT 0x80 - - -static INLINE GLfloat dot4( const GLfloat *a, - const GLfloat *b ) -{ - GLfloat result = (a[0]*b[0] + - a[1]*b[1] + - a[2]*b[2] + - a[3]*b[3]); - - return result; -} - - -#if 0 -static INLINE void do_tri( struct prim_stage *next, - struct prim_header *header ) -{ - GLuint i; - for (i = 0; i < 3; i++) { - GLfloat *ndc = header->v[i]->data[0]; - _mesa_printf("ndc %f %f %f\n", ndc[0], ndc[1], ndc[2]); - assert(ndc[0] >= -1 && ndc[0] <= 641); - assert(ndc[1] >= 30 && ndc[1] <= 481); - } - _mesa_printf("\n"); - next->tri(next, header); -} -#endif - - -static void emit_poly( struct prim_stage *stage, - struct vertex_header **inlist, - GLuint n ) -{ - struct prim_header header; - GLuint i; - - for (i = 2; i < n; i++) { - header.v[0] = inlist[0]; - header.v[1] = inlist[i-1]; - header.v[2] = inlist[i]; - - { - GLuint tmp0 = header.v[0]->edgeflag; - GLuint tmp2 = header.v[2]->edgeflag; - - if (i != 2) header.v[0]->edgeflag = 0; - if (i != n-1) header.v[2]->edgeflag = 0; - - stage->next->tri( stage->next, &header ); - - header.v[0]->edgeflag = tmp0; - header.v[2]->edgeflag = tmp2; - } - } -} - - -#if 0 -static void emit_poly( struct prim_stage *stage ) -{ - GLuint i; - - for (i = 2; i < n; i++) { - header->v[0] = inlist[0]; - header->v[1] = inlist[i-1]; - header->v[2] = inlist[i]; - - stage->next->tri( stage->next, header ); - } -} -#endif - - -/* Clip a triangle against the viewport and user clip planes. - */ -static void -do_clip_tri( struct prim_stage *stage, - struct prim_header *header, - GLuint clipmask ) -{ - struct clipper *clipper = clipper_stage( stage ); - struct vertex_header *a[MAX_CLIPPED_VERTICES]; - struct vertex_header *b[MAX_CLIPPED_VERTICES]; - struct vertex_header **inlist = a; - struct vertex_header **outlist = b; - GLuint tmpnr = 0; - GLuint n = 3; - GLuint i; - - inlist[0] = header->v[0]; - inlist[1] = header->v[1]; - inlist[2] = header->v[2]; - - /* XXX: Note stupid hack to deal with tnl's 8-bit clipmask. Remove - * this once we correctly use 16bit masks for userclip planes. - */ - clipmask &= ~CLIP_CULL_BIT; - if (clipmask & CLIP_USER_BIT) { - clipmask &= ~CLIP_USER_BIT; - clipmask |= clipper->active_user_planes; - } - - while (clipmask && n >= 3) { - GLuint plane_idx = ffs(clipmask)-1; - const GLfloat *plane = clipper->stage.generic->plane[plane_idx]; - struct vertex_header *vert_prev = inlist[0]; - GLfloat dp_prev = dot4( vert_prev->clip, plane ); - GLuint outcount = 0; - - clipmask &= ~(1<clip, plane ); - - if (!IS_NEGATIVE(dp_prev)) { - outlist[outcount++] = vert_prev; - } - - if (DIFFERENT_SIGNS(dp, dp_prev)) { - struct vertex_header *new_vert = clipper->stage.tmp[tmpnr++]; - outlist[outcount++] = new_vert; - - if (IS_NEGATIVE(dp)) { - /* Going out of bounds. Avoid division by zero as we - * know dp != dp_prev from DIFFERENT_SIGNS, above. - */ - GLfloat t = dp / (dp - dp_prev); - interp( clipper, new_vert, t, vert, vert_prev ); - - /* Force edgeflag true in this case: - */ - new_vert->edgeflag = 1; - } else { - /* Coming back in. - */ - GLfloat t = dp_prev / (dp_prev - dp); - interp( clipper, new_vert, t, vert_prev, vert ); - - /* Copy starting vert's edgeflag: - */ - new_vert->edgeflag = vert_prev->edgeflag; - } - } - - vert_prev = vert; - dp_prev = dp; - } - - { - struct vertex_header **tmp = inlist; - inlist = outlist; - outlist = tmp; - n = outcount; - } - } - - /* Emit the polygon as triangles to the setup stage: - */ - if (n >= 3) - emit_poly( stage, inlist, n ); -} - - -/* Clip a line against the viewport and user clip planes. - */ -static void -do_clip_line( struct prim_stage *stage, - struct prim_header *header, - GLuint clipmask ) -{ - struct clipper *clipper = clipper_stage( stage ); - struct vertex_header *v0 = header->v[0]; - struct vertex_header *v1 = header->v[1]; - const GLfloat *pos0 = v0->clip; - const GLfloat *pos1 = v1->clip; - GLfloat t0 = 0; - GLfloat t1 = 0; - - /* XXX: Note stupid hack to deal with tnl's 8-bit clipmask. Remove - * this once we correctly use 16bit masks for userclip planes. - */ - clipmask &= ~CLIP_CULL_BIT; - if (clipmask & CLIP_USER_BIT) { - clipmask &= ~CLIP_USER_BIT; - clipmask |= clipper->active_user_planes; - } - - while (clipmask) { - GLuint plane_idx = ffs(clipmask)-1; - const GLfloat *plane = clipper->stage.generic->plane[plane_idx]; - - clipmask &= ~(1< t1) t1 = t; - } - - if (dp0 < 0) { - GLfloat t = dp0 / (dp0 - dp1); - if (t > t0) t0 = t; - } - - if (t0 + t1 >= 1.0) - return; /* discard */ - } - - if (v0->clipmask) { - interp( clipper, stage->tmp[0], t0, v0, v1 ); - header->v[0] = stage->tmp[0]; - } - - if (v1->clipmask) { - interp( clipper, stage->tmp[1], t1, v1, v0 ); - header->v[1] = stage->tmp[1]; - } - - stage->next->line( stage->next, header ); -} - - - -static void clip_begin( struct prim_stage *stage ) -{ - struct clipper *clipper = clipper_stage(stage); - GLuint nr = stage->generic->nr_planes; - - /* Hacky bitmask to use when we hit CLIP_USER_BIT: - */ - clipper->active_user_planes = ((1<next->begin( stage->next ); -} - -static void -clip_point( struct prim_stage *stage, - struct prim_header *header ) -{ - if (header->v[0]->clipmask == 0) - stage->next->point( stage->next, header ); -} - - -static void -clip_line( struct prim_stage *stage, - struct prim_header *header ) -{ - GLuint clipmask = (header->v[0]->clipmask | - header->v[1]->clipmask); - - if (clipmask == 0) { - stage->next->line( stage->next, header ); - } - else if ((header->v[0]->clipmask & - header->v[1]->clipmask) == 0) { - do_clip_line(stage, header, clipmask); - } -} - - -static void -clip_tri( struct prim_stage *stage, - struct prim_header *header ) -{ - GLuint clipmask = (header->v[0]->clipmask | - header->v[1]->clipmask | - header->v[2]->clipmask); - - if (clipmask == 0) { - stage->next->tri( stage->next, header ); - } - else if ((header->v[0]->clipmask & - header->v[1]->clipmask & - header->v[2]->clipmask) == 0) { - do_clip_tri(stage, header, clipmask); - } -} - -static void clip_end( struct prim_stage *stage ) -{ - stage->next->end( stage->next ); -} - - -struct prim_stage *prim_clip( struct generic_context *generic ) -{ - struct clipper *clipper = CALLOC_STRUCT(clipper); - - prim_alloc_tmps( &clipper->stage, MAX_CLIPPED_VERTICES ); - - clipper->stage.generic = generic; - 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; - - return &clipper->stage; -} diff --git a/src/mesa/pipe/softpipe/g_prim_cull.c b/src/mesa/pipe/softpipe/g_prim_cull.c deleted file mode 100644 index 633fbcc492..0000000000 --- a/src/mesa/pipe/softpipe/g_prim_cull.c +++ /dev/null @@ -1,119 +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: Keith Whitwell - */ -#include "imports.h" - -#include "g_context.h" -#include "g_prim.h" - - - -struct cull_stage { - struct prim_stage stage; - GLuint mode; -}; - - - -static INLINE struct cull_stage *cull_stage( struct prim_stage *stage ) -{ - return (struct cull_stage *)stage; -} - - -static void cull_begin( struct prim_stage *stage ) -{ - struct cull_stage *cull = cull_stage(stage); - - cull->mode = stage->generic->setup.cull_mode; - - stage->next->begin( stage->next ); -} - - -static void cull_tri( struct prim_stage *stage, - struct prim_header *header ) -{ - /* Window coords: */ - GLfloat *v0 = (GLfloat *)&(header->v[0]->data[0]); - GLfloat *v1 = (GLfloat *)&(header->v[1]->data[0]); - GLfloat *v2 = (GLfloat *)&(header->v[2]->data[0]); - - GLfloat ex = v0[0] - v2[0]; - GLfloat ey = v0[1] - v2[1]; - GLfloat fx = v1[0] - v2[0]; - GLfloat fy = v1[1] - v2[1]; - - header->det = ex * fy - ey * fx; - - _mesa_printf("%s %f\n", __FUNCTION__, header->det ); - - if (header->det != 0) { - GLuint mode = (header->det < 0) ? WINDING_CW : WINDING_CCW; - - if ((mode & cull_stage(stage)->mode) == 0) - stage->next->tri( stage->next, header ); - } -} - - -static void cull_line( struct prim_stage *stage, - struct prim_header *header ) -{ - stage->next->line( stage->next, header ); -} - - -static void cull_point( struct prim_stage *stage, - struct prim_header *header ) -{ - stage->next->point( stage->next, header ); -} - -static void cull_end( struct prim_stage *stage ) -{ - stage->next->end( stage->next ); -} - -struct prim_stage *prim_cull( struct generic_context *generic ) -{ - struct cull_stage *cull = CALLOC_STRUCT(cull_stage); - - prim_alloc_tmps( &cull->stage, 0 ); - - cull->stage.generic = generic; - 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; - - return &cull->stage; -} diff --git a/src/mesa/pipe/softpipe/g_prim_flatshade.c b/src/mesa/pipe/softpipe/g_prim_flatshade.c deleted file mode 100644 index 1974a64fa8..0000000000 --- a/src/mesa/pipe/softpipe/g_prim_flatshade.c +++ /dev/null @@ -1,149 +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: Keith Whitwell - */ -#include "imports.h" - -#include "g_context.h" -#include "g_prim.h" - - -struct flatshade_stage { - struct prim_stage stage; - - const GLuint *lookup; -}; - - - -static INLINE struct flatshade_stage *flatshade_stage( struct prim_stage *stage ) -{ - return (struct flatshade_stage *)stage; -} - - -static void flatshade_begin( struct prim_stage *stage ) -{ - stage->next->begin( stage->next ); -} - - - -static INLINE void copy_attr( GLuint attr, - struct vertex_header *dst, - const struct vertex_header *src ) -{ - if (attr) { - memcpy( dst->data[attr], - src->data[attr], - sizeof(src->data[0]) ); - } -} - -static void copy_colors( struct prim_stage *stage, - struct vertex_header *dst, - const struct vertex_header *src ) -{ - struct flatshade_stage *flatshade = flatshade_stage(stage); - const GLuint *lookup = flatshade->lookup; - - copy_attr( lookup[VF_ATTRIB_COLOR0], dst, src ); - copy_attr( lookup[VF_ATTRIB_COLOR1], dst, src ); - copy_attr( lookup[VF_ATTRIB_BFC0], dst, src ); - copy_attr( lookup[VF_ATTRIB_BFC1], dst, src ); -} - - - -/* Flatshade tri. Required for clipping and when unfilled tris are - * active, otherwise handled by hardware. - */ -static void flatshade_tri( struct prim_stage *stage, - struct prim_header *header ) -{ - struct prim_header tmp; - - tmp.det = header->det; - tmp.v[0] = dup_vert(stage, header->v[0], 0); - tmp.v[1] = dup_vert(stage, header->v[1], 1); - tmp.v[2] = header->v[2]; - - copy_colors(stage, tmp.v[0], tmp.v[2]); - copy_colors(stage, tmp.v[1], tmp.v[2]); - - stage->next->tri( stage->next, &tmp ); -} - - -/* Flatshade line. Required for clipping. - */ -static void flatshade_line( struct prim_stage *stage, - struct prim_header *header ) -{ - struct prim_header tmp; - - tmp.v[0] = dup_vert(stage, header->v[0], 0); - tmp.v[1] = header->v[1]; - - copy_colors(stage, tmp.v[0], tmp.v[1]); - - stage->next->line( stage->next, &tmp ); -} - - -static void flatshade_point( struct prim_stage *stage, - struct prim_header *header ) -{ - stage->next->point( stage->next, header ); -} - -static void flatshade_end( struct prim_stage *stage ) -{ - stage->next->end( stage->next ); -} - -struct prim_stage *prim_flatshade( struct generic_context *generic ) -{ - struct flatshade_stage *flatshade = CALLOC_STRUCT(flatshade_stage); - - prim_alloc_tmps( &flatshade->stage, 2 ); - - flatshade->stage.generic = generic; - 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->lookup = generic->vf_attr_to_slot; - - return &flatshade->stage; -} - - diff --git a/src/mesa/pipe/softpipe/g_prim_offset.c b/src/mesa/pipe/softpipe/g_prim_offset.c deleted file mode 100644 index 801ce9a441..0000000000 --- a/src/mesa/pipe/softpipe/g_prim_offset.c +++ /dev/null @@ -1,157 +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: Keith Whitwell - */ -#include "imports.h" -#include "macros.h" - -#include "g_context.h" -#include "g_prim.h" - - - -struct offset_stage { - struct prim_stage stage; - - GLuint hw_data_offset; - - GLfloat scale; - GLfloat units; -}; - - - -static INLINE struct offset_stage *offset_stage( struct prim_stage *stage ) -{ - return (struct offset_stage *)stage; -} - - -static void offset_begin( struct prim_stage *stage ) -{ - struct offset_stage *offset = offset_stage(stage); - - offset->units = stage->generic->setup.offset_units; - offset->scale = stage->generic->setup.offset_scale; - - stage->next->begin( stage->next ); -} - - -/* Offset tri. Some hardware can handle this, but not usually when - * doing unfilled rendering. - */ -static void do_offset_tri( struct prim_stage *stage, - struct prim_header *header ) -{ - struct offset_stage *offset = offset_stage(stage); - GLfloat inv_det = 1.0 / header->det; - - /* Window coords: - */ - GLfloat *v0 = (GLfloat *)&(header->v[0]->data[0]); - GLfloat *v1 = (GLfloat *)&(header->v[1]->data[0]); - GLfloat *v2 = (GLfloat *)&(header->v[2]->data[0]); - - GLfloat ex = v0[0] - v2[2]; - GLfloat fx = v1[0] - v2[2]; - GLfloat ey = v0[1] - v2[2]; - GLfloat fy = v1[1] - v2[2]; - GLfloat ez = v0[2] - v2[2]; - GLfloat fz = v1[2] - v2[2]; - - GLfloat a = ey*fz - ez*fy; - GLfloat b = ez*fx - ex*fz; - - GLfloat ac = a * inv_det; - GLfloat bc = b * inv_det; - GLfloat zoffset; - - if ( ac < 0.0f ) ac = -ac; - if ( bc < 0.0f ) bc = -bc; - - zoffset = offset->units + MAX2( ac, bc ) * offset->scale; - - v0[2] += zoffset; - v1[2] += zoffset; - v2[2] += zoffset; - - stage->next->tri( stage->next, header ); -} - - -static void offset_tri( struct prim_stage *stage, - struct prim_header *header ) -{ - struct prim_header tmp; - - tmp.det = header->det; - tmp.v[0] = dup_vert(stage, header->v[0], 0); - tmp.v[1] = dup_vert(stage, header->v[1], 1); - tmp.v[2] = dup_vert(stage, header->v[2], 2); - - do_offset_tri( stage->next, &tmp ); -} - - - -static void offset_line( struct prim_stage *stage, - struct prim_header *header ) -{ - stage->next->line( stage->next, header ); -} - - -static void offset_point( struct prim_stage *stage, - struct prim_header *header ) -{ - stage->next->point( stage->next, header ); -} - - -static void offset_end( struct prim_stage *stage ) -{ - stage->next->end( stage->next ); -} - -struct prim_stage *prim_offset( struct generic_context *generic ) -{ - struct offset_stage *offset = CALLOC_STRUCT(offset_stage); - - prim_alloc_tmps( &offset->stage, 3 ); - - offset->stage.generic = generic; - 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; - - return &offset->stage; -} diff --git a/src/mesa/pipe/softpipe/g_prim_setup.c b/src/mesa/pipe/softpipe/g_prim_setup.c deleted file mode 100644 index 41e1381a60..0000000000 --- a/src/mesa/pipe/softpipe/g_prim_setup.c +++ /dev/null @@ -1,888 +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: Keith Whitwell - */ - -#include "imports.h" -#include "macros.h" - -#include "g_context.h" -#include "g_prim.h" -#include "g_tile.h" - - -/** - * Triangle edge info - */ -struct edge { - GLfloat dx; /* X(v1) - X(v0), used only during setup */ - GLfloat dy; /* Y(v1) - Y(v0), used only during setup */ - GLfloat dxdy; /* dx/dy */ - GLfloat sx; /* first sample point x coord */ - GLfloat sy; - GLint lines; /* number of lines on this edge */ -}; - - -/** - * Triangle setup info (derived from prim_stage). - * Also used for line drawing (taking some liberties). - */ -struct setup_stage { - struct prim_stage stage; /**< This must be first */ - - /* Vertices are just an array of floats making up each attribute in - * turn. Currently fixed at 4 floats, but should change in time. - * Codegen will help cope with this. - */ - const struct vertex_header *vmax; - const struct vertex_header *vmid; - const struct vertex_header *vmin; - const struct vertex_header *vprovoke; - - struct edge ebot; - struct edge etop; - struct edge emaj; - - GLfloat oneoverarea; - - struct setup_coefficient coef[FRAG_ATTRIB_MAX]; - struct quad_header quad; - - struct { - GLint left[2]; /**< [0] = row0, [1] = row1 */ - GLint right[2]; - GLint y; - GLuint y_flags; - GLuint mask; /**< mask of MASK_BOTTOM/TOP_LEFT/RIGHT bits */ - } span; -}; - - - -/** - * Basically a cast wrapper. - */ -static inline struct setup_stage *setup_stage( struct prim_stage *stage ) -{ - return (struct setup_stage *)stage; -} - - -/** - * Given an X or Y coordinate, return the block/quad coordinate that it - * belongs to. - */ -static inline GLint block( GLint x ) -{ - return x & ~1; -} - - - -static void setup_begin( struct prim_stage *stage ) -{ - setup_stage(stage)->quad.nr_attrs = stage->generic->nr_frag_attrs; -} - - -/** - * Run shader on a quad/block. - */ -static void run_shader_block( struct setup_stage *setup, - GLint x, GLint y, GLuint mask ) -{ - setup->quad.x0 = x; - setup->quad.y0 = y; - setup->quad.mask = mask; - - quad_shade( setup->stage.generic, &setup->quad ); -} - - -/** - * Compute mask which indicates which pixels in the 2x2 quad are actually inside - * the triangle's bounds. - * - * this is pretty nasty... may need to rework flush_spans again to - * fix it, if possible. - */ -static GLuint calculate_mask( struct setup_stage *setup, - GLint x ) -{ - GLuint mask = 0; - - if (x >= setup->span.left[0] && x < setup->span.right[0]) - mask |= MASK_BOTTOM_LEFT; - - if (x >= setup->span.left[1] && x < setup->span.right[1]) - mask |= MASK_TOP_LEFT; - - if (x+1 >= setup->span.left[0] && x+1 < setup->span.right[0]) - mask |= MASK_BOTTOM_RIGHT; - - if (x+1 >= setup->span.left[1] && x+1 < setup->span.right[1]) - mask |= MASK_TOP_RIGHT; - - return mask; -} - - -/** - * Render a horizontal span of quads - */ -static void flush_spans( struct setup_stage *setup ) -{ - GLint minleft, maxright; - GLint x; - - switch (setup->span.y_flags) { - case 3: - minleft = MIN2(setup->span.left[0], setup->span.left[1]); - maxright = MAX2(setup->span.right[0], setup->span.right[1]); - break; - - case 1: - minleft = setup->span.left[0]; - maxright = setup->span.right[0]; - break; - - case 2: - minleft = setup->span.left[1]; - maxright = setup->span.right[1]; - break; - - default: - return; - } - - - for (x = block(minleft); x <= block(maxright); ) - { - run_shader_block( setup, x, - setup->span.y, - calculate_mask( setup, x ) ); - x += 2; - } - - setup->span.y = 0; - setup->span.y_flags = 0; - setup->span.right[0] = 0; - setup->span.right[1] = 0; -} - - -static GLboolean setup_sort_vertices( struct setup_stage *setup, - const struct prim_header *prim ) -{ - const struct vertex_header *v0 = prim->v[0]; - const struct vertex_header *v1 = prim->v[1]; - const struct vertex_header *v2 = prim->v[2]; - - setup->vprovoke = v2; - - /* determine bottom to top order of vertices */ - { - GLfloat y0 = v0->data[0][1]; - GLfloat y1 = v1->data[0][1]; - GLfloat y2 = v2->data[0][1]; - if (y0 <= y1) { - if (y1 <= y2) { - /* y0<=y1<=y2 */ - setup->vmin = v0; - setup->vmid = v1; - setup->vmax = v2; - } - else if (y2 <= y0) { - /* y2<=y0<=y1 */ - setup->vmin = v2; - setup->vmid = v0; - setup->vmax = v1; - } - else { - /* y0<=y2<=y1 */ - setup->vmin = v0; - setup->vmid = v2; - setup->vmax = v1; - } - } - else { - if (y0 <= y2) { - /* y1<=y0<=y2 */ - setup->vmin = v1; - setup->vmid = v0; - setup->vmax = v2; - } - else if (y2 <= y1) { - /* y2<=y1<=y0 */ - setup->vmin = v2; - setup->vmid = v1; - setup->vmax = v0; - } - else { - /* y1<=y2<=y0 */ - setup->vmin = v1; - setup->vmid = v2; - setup->vmax = v0; - } - } - } - - setup->ebot.dx = setup->vmid->data[0][0] - setup->vmin->data[0][0]; - setup->ebot.dy = setup->vmid->data[0][1] - setup->vmin->data[0][1]; - setup->emaj.dx = setup->vmax->data[0][0] - setup->vmin->data[0][0]; - setup->emaj.dy = setup->vmax->data[0][1] - setup->vmin->data[0][1]; - setup->etop.dx = setup->vmax->data[0][0] - setup->vmid->data[0][0]; - setup->etop.dy = setup->vmax->data[0][1] - setup->vmid->data[0][1]; - - /* xxx: may need to adjust this sign according to the if-tree - * above: - * - * XXX: this is like 'det', but calculated from screen coords?? - */ - { - const GLfloat area = (setup->emaj.dx * setup->ebot.dy - - setup->ebot.dx * setup->emaj.dy); - - setup->oneoverarea = 1.0 / area; - } - - /* XXX need to know if this is a front or back-facing triangle: - * - the GLSL gl_FrontFacing fragment attribute (bool) - * - two-sided stencil test - */ - setup->quad.facing = 0; - - _mesa_printf("%s one-over-area %f\n", __FUNCTION__, setup->oneoverarea ); - - - return GL_TRUE; -} - - -/** - * Compute a0 for a constant-valued coefficient (GL_FLAT shading). - */ -static void const_coeff( struct setup_stage *setup, - GLuint slot, - GLuint i ) -{ - setup->coef[slot].dadx[i] = 0; - setup->coef[slot].dady[i] = 0; - - /* need provoking vertex info! - */ - setup->coef[slot].a0[i] = setup->vprovoke->data[slot][i]; -} - - -/** - * Compute a0, dadx and dady for a linearly interpolated coefficient, - * for a triangle. - */ -static void tri_linear_coeff( struct setup_stage *setup, - GLuint slot, - GLuint i) -{ - GLfloat botda = setup->vmid->data[slot][i] - setup->vmin->data[slot][i]; - GLfloat majda = setup->vmax->data[slot][i] - setup->vmin->data[slot][i]; - GLfloat a = setup->ebot.dy * majda - botda * setup->emaj.dy; - GLfloat b = setup->emaj.dx * botda - majda * setup->ebot.dx; - - setup->coef[slot].dadx[i] = a * setup->oneoverarea; - setup->coef[slot].dady[i] = b * setup->oneoverarea; - - /* calculate a0 as the value which would be sampled for the - * fragment at (0,0), taking into account that we want to sample at - * pixel centers, in other words (0.5, 0.5). - * - * this is neat but unfortunately not a good way to do things for - * triangles with very large values of dadx or dady as it will - * result in the subtraction and re-addition from a0 of a very - * large number, which means we'll end up loosing a lot of the - * fractional bits and precision from a0. the way to fix this is - * to define a0 as the sample at a pixel center somewhere near vmin - * instead - i'll switch to this later. - */ - setup->coef[slot].a0[i] = (setup->vmin->data[slot][i] - - (setup->coef[slot].dadx[i] * (setup->vmin->data[0][0] - 0.5) + - setup->coef[slot].dady[i] * (setup->vmin->data[0][1] - 0.5))); - - _mesa_printf("attr[%d].%c: %f dx:%f dy:%f\n", - slot, "xyzw"[i], - setup->coef[slot].a0[i], - setup->coef[slot].dadx[i], - setup->coef[slot].dady[i]); -} - - -/** - * Compute a0, dadx and dady for a perspective-corrected interpolant, - * for a triangle. - */ -static void tri_persp_coeff( struct setup_stage *setup, - GLuint slot, - GLuint i ) -{ - /* premultiply by 1/w: - */ - GLfloat mina = setup->vmin->data[slot][i] * setup->vmin->data[0][3]; - GLfloat mida = setup->vmid->data[slot][i] * setup->vmid->data[0][3]; - GLfloat maxa = setup->vmax->data[slot][i] * setup->vmax->data[0][3]; - - GLfloat botda = mida - mina; - GLfloat majda = maxa - mina; - GLfloat a = setup->ebot.dy * majda - botda * setup->emaj.dy; - GLfloat b = setup->emaj.dx * botda - majda * setup->ebot.dx; - - setup->coef[slot].dadx[i] = a * setup->oneoverarea; - setup->coef[slot].dady[i] = b * setup->oneoverarea; - setup->coef[slot].a0[i] = (mina - - (setup->coef[slot].dadx[i] * (setup->vmin->data[0][0] - 0.5) + - setup->coef[slot].dady[i] * (setup->vmin->data[0][1] - 0.5))); -} - - - -/** - * Compute the setup->coef[] array dadx, dady, a0 values. - * Must be called after setup->vmin,vmid,vmax,vprovoke are initialized. - */ -static void setup_tri_coefficients( struct setup_stage *setup ) -{ - const enum interp_mode *interp = setup->stage.generic->interp; - GLuint slot, j; - - /* z and w are done by linear interpolation: - */ - tri_linear_coeff(setup, 0, 2); - tri_linear_coeff(setup, 0, 3); - - /* setup interpolation for all the remaining attributes: - */ - for (slot = 1; slot < setup->quad.nr_attrs; slot++) { - switch (interp[slot]) { - case INTERP_CONSTANT: - for (j = 0; j < NUM_CHANNELS; j++) - const_coeff(setup, slot, j); - break; - - case INTERP_LINEAR: - for (j = 0; j < NUM_CHANNELS; j++) - tri_linear_coeff(setup, slot, j); - break; - - case INTERP_PERSPECTIVE: - for (j = 0; j < NUM_CHANNELS; j++) - tri_persp_coeff(setup, slot, j); - break; - } - } -} - - - -static void setup_tri_edges( struct setup_stage *setup ) -{ - GLfloat vmin_x = setup->vmin->data[0][0] + 0.5; - GLfloat vmid_x = setup->vmid->data[0][0] + 0.5; - - GLfloat vmin_y = setup->vmin->data[0][1] - 0.5; - GLfloat vmid_y = setup->vmid->data[0][1] - 0.5; - GLfloat vmax_y = setup->vmax->data[0][1] - 0.5; - - setup->emaj.sy = ceilf(vmin_y); - setup->emaj.lines = (GLint) ceilf(vmax_y - setup->emaj.sy); - setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy; - setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy; - - setup->etop.sy = ceilf(vmid_y); - setup->etop.lines = (GLint) ceilf(vmax_y - setup->etop.sy); - setup->etop.dxdy = setup->etop.dx / setup->etop.dy; - setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy; - - setup->ebot.sy = ceilf(vmin_y); - setup->ebot.lines = (GLint) ceilf(vmid_y - setup->ebot.sy); - setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy; - setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy; -} - - -/** - * Render the upper or lower half of a triangle. - * Scissoring is applied here too. - */ -static void subtriangle( struct setup_stage *setup, - struct edge *eleft, - struct edge *eright, - GLuint lines ) -{ - GLint y, start_y, finish_y; - GLint sy = (GLint)eleft->sy; - - assert((GLint)eleft->sy == (GLint) eright->sy); - assert((GLint)eleft->sy >= 0); /* catch bug in x64? */ - - /* scissor y: - */ - if (setup->stage.generic->setup.scissor) { - start_y = sy; - finish_y = start_y + lines; - - if (start_y < setup->stage.generic->scissor.miny) - start_y = setup->stage.generic->scissor.miny; - - if (finish_y > setup->stage.generic->scissor.maxy) - finish_y = setup->stage.generic->scissor.maxy; - - start_y -= sy; - finish_y -= sy; - } - else { - start_y = 0; - finish_y = lines; - } - - _mesa_printf("%s %d %d\n", __FUNCTION__, start_y, finish_y); - - for (y = start_y; y < finish_y; y++) { - - /* avoid accumulating adds as floats don't have the precision to - * accurately iterate large triangle edges that way. luckily we - * can just multiply these days. - * - * this is all drowned out by the attribute interpolation anyway. - */ - GLint left = (GLint)(eleft->sx + y * eleft->dxdy); - GLint right = (GLint)(eright->sx + y * eright->dxdy); - - /* scissor x: - */ - if (setup->stage.generic->setup.scissor) { - if (left < setup->stage.generic->scissor.minx) - left = setup->stage.generic->scissor.minx; - - if (right > setup->stage.generic->scissor.maxx) - right = setup->stage.generic->scissor.maxx; - } - - if (left < right) { - GLint _y = sy+y; - if (block(_y) != setup->span.y) { - flush_spans(setup); - setup->span.y = block(_y); - } - - setup->span.left[_y&1] = left; - setup->span.right[_y&1] = right; - setup->span.y_flags |= 1<<(_y&1); - } - } - - - /* save the values so that emaj can be restarted: - */ - eleft->sx += lines * eleft->dxdy; - eright->sx += lines * eright->dxdy; - eleft->sy += lines; - eright->sy += lines; -} - - -/** - * Do setup for triangle rasterization, then render the triangle. - */ -static void setup_tri( struct prim_stage *stage, - struct prim_header *prim ) -{ - struct setup_stage *setup = setup_stage( stage ); - - _mesa_printf("%s\n", __FUNCTION__ ); - - setup_sort_vertices( setup, prim ); - setup_tri_coefficients( setup ); - setup_tri_edges( setup ); - - setup->span.y = 0; - setup->span.y_flags = 0; - setup->span.right[0] = 0; - setup->span.right[1] = 0; -// setup->span.z_mode = tri_z_mode( setup->ctx ); - -// init_constant_attribs( setup ); - - if (setup->oneoverarea < 0.0) { - /* emaj on left: - */ - subtriangle( setup, &setup->emaj, &setup->ebot, setup->ebot.lines ); - subtriangle( setup, &setup->emaj, &setup->etop, setup->etop.lines ); - } - else { - /* emaj on right: - */ - subtriangle( setup, &setup->ebot, &setup->emaj, setup->ebot.lines ); - subtriangle( setup, &setup->etop, &setup->emaj, setup->etop.lines ); - } - - flush_spans( setup ); -} - - - -/** - * Compute a0, dadx and dady for a linearly interpolated coefficient, - * for a line. - */ -static void -line_linear_coeff(struct setup_stage *setup, GLuint slot, GLuint i) -{ - const GLfloat dz = setup->vmax->data[slot][i] - setup->vmin->data[slot][i]; - const GLfloat dadx = dz * setup->emaj.dx * setup->oneoverarea; - const GLfloat dady = dz * setup->emaj.dy * setup->oneoverarea; - setup->coef[slot].dadx[i] = dadx; - setup->coef[slot].dady[i] = dady; - setup->coef[slot].a0[i] - = (setup->vmin->data[slot][i] - - (dadx * (setup->vmin->data[0][0] - 0.5) + - dady * (setup->vmin->data[0][1] - 0.5))); -} - - -/** - * Compute a0, dadx and dady for a perspective-corrected interpolant, - * for a line. - */ -static void -line_persp_coeff(struct setup_stage *setup, GLuint slot, GLuint i) -{ - /* XXX to do */ - line_linear_coeff(setup, slot, i); /* XXX temporary */ -} - - -/** - * Compute the setup->coef[] array dadx, dady, a0 values. - * Must be called after setup->vmin,vmax are initialized. - */ -static INLINE void -setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim) -{ - const enum interp_mode *interp = setup->stage.generic->interp; - GLuint slot, j; - - /* use setup->vmin, vmax to point to vertices */ - setup->vprovoke = prim->v[1]; - setup->vmin = prim->v[0]; - setup->vmax = prim->v[1]; - - setup->emaj.dx = setup->vmax->data[0][0] - setup->vmin->data[0][0]; - setup->emaj.dy = setup->vmax->data[0][1] - setup->vmin->data[0][1]; - /* NOTE: this is not really 1/area */ - setup->oneoverarea = 1.0 / (setup->emaj.dx * setup->emaj.dx + - setup->emaj.dy * setup->emaj.dy); - - /* z and w are done by linear interpolation: - */ - line_linear_coeff(setup, 0, 2); - line_linear_coeff(setup, 0, 3); - - /* setup interpolation for all the remaining attributes: - */ - for (slot = 1; slot < setup->quad.nr_attrs; slot++) { - switch (interp[slot]) { - case INTERP_CONSTANT: - for (j = 0; j < NUM_CHANNELS; j++) - const_coeff(setup, slot, j); - break; - - case INTERP_LINEAR: - for (j = 0; j < NUM_CHANNELS; j++) - line_linear_coeff(setup, slot, j); - break; - - case INTERP_PERSPECTIVE: - for (j = 0; j < NUM_CHANNELS; j++) - line_persp_coeff(setup, slot, j); - break; - } - } -} - - -/** - * Plot a pixel in a line segment. - */ -static INLINE void -plot(struct setup_stage *setup, GLint x, GLint y) -{ - const GLint iy = y & 1; - const GLint ix = x & 1; - const GLint quadX = x - ix; - const GLint quadY = y - iy; - const GLint mask = (1 << ix) << (2 * iy); - - if (quadX != setup->quad.x0 || - quadY != setup->quad.y0) - { - /* flush prev quad, start new quad */ - - if (setup->quad.x0 != -1) - quad_shade(setup->stage.generic, &setup->quad); - - setup->quad.x0 = quadX; - setup->quad.y0 = quadY; - setup->quad.mask = 0x0; - } - - setup->quad.mask |= mask; -} - - - -/** - * Do setup for line rasterization, then render the line. - * XXX single-pixel width, no stipple, etc - * XXX no scissoring yet. - */ -static void -setup_line(struct prim_stage *stage, struct prim_header *prim) -{ - const struct vertex_header *v0 = prim->v[0]; - const struct vertex_header *v1 = prim->v[1]; - struct setup_stage *setup = setup_stage( stage ); - - GLint x0 = (GLint) v0->data[0][0]; - GLint x1 = (GLint) v1->data[0][0]; - GLint y0 = (GLint) v0->data[0][1]; - GLint y1 = (GLint) v1->data[0][1]; - GLint dx = x1 - x0; - GLint dy = y1 - y0; - GLint xstep, ystep; - - if (dx == 0 && dy == 0) - return; - - setup_line_coefficients(setup, prim); - - if (dx < 0) { - dx = -dx; /* make positive */ - xstep = -1; - } - else { - xstep = 1; - } - - if (dy < 0) { - dy = -dy; /* make positive */ - ystep = -1; - } - else { - ystep = 1; - } - - assert(dx >= 0); - assert(dy >= 0); - - setup->quad.x0 = setup->quad.y0 = -1; - setup->quad.mask = 0x0; - - if (dx > dy) { - /*** X-major line ***/ - GLint i; - const GLint errorInc = dy + dy; - GLint error = errorInc - dx; - const GLint errorDec = error - dx; - - for (i = 0; i < dx; i++) { - plot(setup, x0, y0); - - x0 += xstep; - if (error < 0) { - error += errorInc; - } - else { - error += errorDec; - y0 += ystep; - } - } - } - else { - /*** Y-major line ***/ - GLint i; - const GLint errorInc = dx + dx; - GLint error = errorInc - dy; - const GLint errorDec = error - dy; - - for (i = 0; i < dy; i++) { - plot(setup, x0, y0); - - y0 += ystep; - - if (error < 0) { - error += errorInc; - } - else { - error += errorDec; - x0 += xstep; - } - } - } - - /* draw final quad */ - if (setup->quad.mask) { - quad_shade(setup->stage.generic, &setup->quad); - } -} - - -/** - * Do setup for point rasterization, then render the point. - * Round or square points... - * XXX could optimize a lot for 1-pixel points. - */ -static void -setup_point(struct prim_stage *stage, struct prim_header *prim) -{ - struct setup_stage *setup = setup_stage( stage ); - GLfloat halfSize = 7.3; /*XXX this is a vertex attrib */ - GLfloat halfSizeSquared = halfSize * halfSize; - const struct vertex_header *v0 = prim->v[0]; - const GLfloat x = v0->data[FRAG_ATTRIB_WPOS][0]; - const GLfloat y = v0->data[FRAG_ATTRIB_WPOS][1]; - const GLint ixmin = block((GLint) (x - halfSize)); - const GLint ixmax = block((GLint) (x + halfSize)); - const GLint iymin = block((GLint) (y - halfSize)); - const GLint iymax = block((GLint) (y + halfSize)); - GLboolean round = GL_TRUE; - GLint ix, iy; - GLuint slot, j; - - /* For points, all interpolants are constant-valued. - * However, for point sprites, we'll need to setup texcoords appropriately. - * XXX: which coefficients are the texcoords??? - * We may do point sprites as textured quads... - * - * KW: We don't know which coefficients are texcoords - ultimately - * the choice of what interpolation mode to use for each attribute - * should be determined by the fragment program, using - * per-attribute declaration statements that include interpolation - * mode as a parameter. So either the fragment program will have - * to be adjusted for pointsprite vs normal point behaviour, or - * otherwise a special interpolation mode will have to be defined - * which matches the required behaviour for point sprites. But - - * the latter is not a feature of normal hardware, and as such - * probably should be ruled out on that basis. - */ - setup->vprovoke = prim->v[0]; - const_coeff(setup, 0, 2); - const_coeff(setup, 0, 3); - for (slot = 1; slot < setup->quad.nr_attrs; slot++) { - for (j = 0; j < NUM_CHANNELS; j++) - const_coeff(setup, slot, j); - } - - /* XXX need to clip against scissor bounds too */ - - for (iy = iymin; iy <= iymax; iy += 2) { - for (ix = ixmin; ix <= ixmax; ix += 2) { - - if (round) { - /* rounded points */ - /* XXX for GL_SMOOTH, need to compute per-fragment coverage too */ - GLfloat dx, dy; - - setup->quad.mask = 0x0; - - dx = (ix + 0.5) - x; - dy = (iy + 0.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) - setup->quad.mask |= MASK_BOTTOM_LEFT; - - dx = (ix + 1.5) - x; - dy = (iy + 0.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) - setup->quad.mask |= MASK_BOTTOM_RIGHT; - - dx = (ix + 0.5) - x; - dy = (iy + 1.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) - setup->quad.mask |= MASK_TOP_LEFT; - - dx = (ix + 1.5) - x; - dy = (iy + 1.5) - y; - if (dx * dx + dy * dy <= halfSizeSquared) - setup->quad.mask |= MASK_TOP_RIGHT; - } - else { - /* square points */ - setup->quad.mask = 0xf; - - if (ix + 0.5 < x - halfSize) - setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT); - - if (ix + 1.5 > x + halfSize) - setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT); - - if (iy + 0.5 < y - halfSize) - setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT); - - if (iy + 1.5 > y + halfSize) - setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT); - } - - if (setup->quad.mask) { - setup->quad.x0 = ix; - setup->quad.y0 = iy; - quad_shade( setup->stage.generic, &setup->quad ); - } - } - } -} - - - -static void setup_end( struct prim_stage *stage ) -{ -} - - -struct prim_stage *prim_setup( struct generic_context *generic ) -{ - struct setup_stage *setup = CALLOC_STRUCT(setup_stage); - - setup->stage.generic = generic; - 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->quad.coef = setup->coef; - - return &setup->stage; -} diff --git a/src/mesa/pipe/softpipe/g_prim_setup.h b/src/mesa/pipe/softpipe/g_prim_setup.h deleted file mode 100644 index 40a70c543e..0000000000 --- a/src/mesa/pipe/softpipe/g_prim_setup.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef S_TRI_H -#define S_TRI_H - -/* Vertices are just an array of floats, with all the attributes - * packed. We currently assume a layout like: - * - * attr[0][0..3] - window position - * attr[1..n][0..3] - remaining attributes. - * - * Attributes are assumed to be 4 floats wide but are packed so that - * all the enabled attributes run contiguously. - */ - -#include "glheader.h" -#include "imports.h" -#include "s_tri_public.h" -#include "s_context.h" - - - -struct tri_context; -struct fp_context; -struct be_context; - -/* Note the rasterizer does not take a GLcontext argument. This is - * deliberate. - */ -struct tri_context *tri_create_context( GLcontext *ctx ); - -void tri_destroy_context( struct tri_context *tri ); - -void tri_set_fp_context( struct tri_context *tri, - struct fp_context *fp, - void (*fp_run)( struct fp_context *fp, - const struct fp_inputs *, - struct fp_outputs * )); - - -void tri_set_be_context( struct tri_context *tri, - struct be_context *be, - void (*be_run)( struct be_context *be, - const struct fp_outputs * )); - -void tri_set_attribs( struct tri_context *tri, - const struct attr_info *info, - GLuint nr_attrib ); - -void tri_set_backface( struct tri_context *tri, - GLfloat backface ); - -void tri_set_scissor( struct tri_context *tri, - GLint x, - GLint y, - GLuint width, - GLuint height, - GLboolean enabled ); - -void tri_set_stipple( struct tri_context *tri, - const GLuint *pattern, - GLboolean enabled ); - -/* Unfilled triangles will be handled elsewhere (higher in the - * pipeline), as will things like stipple (lower in the pipeline). - */ - -void tri_triangle( struct tri_context *tri, - const struct vertex *v0, - const struct vertex *v1, - const struct vertex *v2 ); - -/* TODO: rasterize_line, rasterize_point?? - * How will linestipple work? - */ - - -#ifdef SETUP_PRIVATE - - - - - - -GLboolean tri_setup( struct tri_context *tri, - const struct vertex *v0, - const struct vertex *v1, - const struct vertex *v2 ); - -void tri_rasterize( struct tri_context *tri ); -void tri_rasterize_spans( struct tri_context *tri ); - - - - - - -#endif -#endif diff --git a/src/mesa/pipe/softpipe/g_prim_twoside.c b/src/mesa/pipe/softpipe/g_prim_twoside.c deleted file mode 100644 index 334ae2f537..0000000000 --- a/src/mesa/pipe/softpipe/g_prim_twoside.c +++ /dev/null @@ -1,149 +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: Keith Whitwell - */ -#include "imports.h" -#include "g_context.h" -#include "g_prim.h" - - -struct twoside_stage { - struct prim_stage stage; - - GLfloat facing; - const GLuint *lookup; -}; - - -static INLINE struct twoside_stage *twoside_stage( struct prim_stage *stage ) -{ - return (struct twoside_stage *)stage; -} - - -static void twoside_begin( struct prim_stage *stage ) -{ - struct twoside_stage *twoside = twoside_stage(stage); - - twoside->facing = (stage->generic->setup.front_winding == WINDING_CW) ? -1 : 1; - - stage->next->begin( stage->next ); -} - - -static INLINE void copy_color( GLuint attr_dst, - GLuint attr_src, - struct vertex_header *v ) -{ - if (attr_dst && attr_src) { - memcpy( v->data[attr_dst], - v->data[attr_src], - sizeof(v->data[0]) ); - } -} - - -static struct vertex_header *copy_bfc( struct twoside_stage *twoside, - const struct vertex_header *v, - GLuint idx ) -{ - struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx ); - - copy_color( twoside->lookup[VF_ATTRIB_COLOR0], - twoside->lookup[VF_ATTRIB_BFC0], - tmp ); - - copy_color( twoside->lookup[VF_ATTRIB_COLOR1], - twoside->lookup[VF_ATTRIB_BFC1], - tmp ); - - return tmp; -} - - -/* Twoside tri: - */ -static void twoside_tri( struct prim_stage *stage, - struct prim_header *header ) -{ - struct twoside_stage *twoside = twoside_stage(stage); - - if (header->det * twoside->facing < 0) { - struct prim_header tmp; - - tmp.det = header->det; - tmp.v[0] = copy_bfc(twoside, header->v[0], 0); - tmp.v[1] = copy_bfc(twoside, header->v[1], 1); - tmp.v[2] = copy_bfc(twoside, header->v[2], 2); - - stage->next->tri( stage->next, &tmp ); - } - else { - stage->next->tri( stage->next, header ); - } -} - - -static void twoside_line( struct prim_stage *stage, - struct prim_header *header ) -{ - stage->next->line( stage->next, header ); -} - - -static void twoside_point( struct prim_stage *stage, - struct prim_header *header ) -{ - stage->next->point( stage->next, header ); -} - -static void twoside_end( struct prim_stage *stage ) -{ - stage->next->end( stage->next ); -} - - - -struct prim_stage *prim_twoside( struct generic_context *generic ) -{ - struct twoside_stage *twoside = CALLOC_STRUCT(twoside_stage); - - prim_alloc_tmps( &twoside->stage, 3 ); - - twoside->stage.generic = generic; - 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->lookup = generic->vf_attr_to_slot; - - return &twoside->stage; -} diff --git a/src/mesa/pipe/softpipe/g_prim_unfilled.c b/src/mesa/pipe/softpipe/g_prim_unfilled.c deleted file mode 100644 index 7c6ee79f92..0000000000 --- a/src/mesa/pipe/softpipe/g_prim_unfilled.c +++ /dev/null @@ -1,165 +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: Keith Whitwell - */ -#include "imports.h" - -#include "g_context.h" -#include "g_prim.h" - - - -struct unfilled_stage { - struct prim_stage stage; - - GLuint mode[2]; -}; - - -static INLINE struct unfilled_stage *unfilled_stage( struct prim_stage *stage ) -{ - return (struct unfilled_stage *)stage; -} - - -static void unfilled_begin( struct prim_stage *stage ) -{ - struct unfilled_stage *unfilled = unfilled_stage(stage); - - unfilled->mode[0] = stage->generic->setup.fill_ccw; - unfilled->mode[1] = stage->generic->setup.fill_cw; - - stage->next->begin( stage->next ); -} - -static void point( struct prim_stage *stage, - struct vertex_header *v0 ) -{ - struct prim_header tmp; - tmp.v[0] = v0; - stage->next->point( stage->next, &tmp ); -} - -static void line( struct prim_stage *stage, - struct vertex_header *v0, - struct vertex_header *v1 ) -{ - struct prim_header tmp; - tmp.v[0] = v0; - tmp.v[1] = v1; - stage->next->line( stage->next, &tmp ); -} - - -static void points( struct prim_stage *stage, - struct prim_header *header ) -{ - struct vertex_header *v0 = header->v[0]; - struct vertex_header *v1 = header->v[1]; - struct vertex_header *v2 = header->v[2]; - - if (v0->edgeflag) point( stage, v0 ); - if (v1->edgeflag) point( stage, v1 ); - if (v2->edgeflag) point( stage, v2 ); -} - -static void lines( struct prim_stage *stage, - struct prim_header *header ) -{ - struct vertex_header *v0 = header->v[0]; - struct vertex_header *v1 = header->v[1]; - struct vertex_header *v2 = header->v[2]; - - if (v0->edgeflag) line( stage, v0, v1 ); - if (v1->edgeflag) line( stage, v1, v2 ); - if (v2->edgeflag) line( stage, v2, v0 ); -} - - -/* Unfilled tri: - * - * Note edgeflags in the vertex struct is not sufficient as we will - * need to manipulate them when decomposing primitives??? - */ -static void unfilled_tri( struct prim_stage *stage, - struct prim_header *header ) -{ - struct unfilled_stage *unfilled = unfilled_stage(stage); - GLuint mode = unfilled->mode[header->det < 0]; - - switch (mode) { - case FILL_TRI: - stage->next->tri( stage->next, header ); - break; - - case FILL_LINE: - lines( stage, header ); - break; - - case GL_POINT: - points( stage, header ); - break; - } -} - -static void unfilled_line( struct prim_stage *stage, - struct prim_header *header ) -{ - stage->next->line( stage->next, header ); -} - - -static void unfilled_point( struct prim_stage *stage, - struct prim_header *header ) -{ - stage->next->point( stage->next, header ); -} - - -static void unfilled_end( struct prim_stage *stage ) -{ - stage->next->end( stage->next ); -} - -struct prim_stage *prim_unfilled( struct generic_context *generic ) -{ - struct unfilled_stage *unfilled = CALLOC_STRUCT(unfilled_stage); - - prim_alloc_tmps( &unfilled->stage, 0 ); - - unfilled->stage.generic = generic; - 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; - - return &unfilled->stage; -} diff --git a/src/mesa/pipe/softpipe/g_state.h b/src/mesa/pipe/softpipe/g_state.h deleted file mode 100644 index 5077d37ab7..0000000000 --- a/src/mesa/pipe/softpipe/g_state.h +++ /dev/null @@ -1,61 +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: Keith Whitwell - */ - -#ifndef PRIM_H -#define PRIM_H - -#include "glheader.h" -#include "softpipe/sp_state.h" - - -void generic_set_clip_state( struct softpipe_context *, - const struct softpipe_clip_state * ); - -void generic_set_viewport( struct softpipe_context *, - const struct softpipe_viewport * ); - -void generic_set_setup_state( struct softpipe_context *, - const struct softpipe_setup_state * ); - -void generic_set_scissor_rect( struct softpipe_context *, - const struct softpipe_scissor_rect * ); - -void generic_set_fs_state( struct softpipe_context *, - const struct softpipe_fs_state * ); - -void generic_set_polygon_stipple( struct softpipe_context *, - const struct softpipe_poly_stipple * ); - -void generic_set_cbuf_state( struct softpipe_context *, - const struct softpipe_surface * ); - -void generic_update_derived( struct generic_context *generic ); - -#endif diff --git a/src/mesa/pipe/softpipe/g_state_clip.c b/src/mesa/pipe/softpipe/g_state_clip.c deleted file mode 100644 index b90034e11e..0000000000 --- a/src/mesa/pipe/softpipe/g_state_clip.c +++ /dev/null @@ -1,69 +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: Keith Whitwell - */ -#include "imports.h" - -#include "g_context.h" -#include "g_state.h" -#include "g_draw.h" - - - -void generic_set_clip_state( struct softpipe_context *softpipe, - const struct softpipe_clip_state *clip ) -{ - struct generic_context *generic = generic_context(softpipe); - - memcpy(&generic->plane[6], clip->ucp, clip->nr * sizeof(clip->ucp[0])); - - generic->nr_planes = 6 + clip->nr; - generic->dirty |= G_NEW_CLIP; -} - - - -/* Called when driver state tracker notices changes to the viewport - * matrix: - */ -void generic_set_viewport( struct softpipe_context *softpipe, - const struct softpipe_viewport *viewport ) -{ - struct generic_context *generic = generic_context(softpipe); - - memcpy(&generic->viewport, viewport, sizeof(viewport)); - - /* Using tnl/ and vf/ modules is temporary while getting started. - * Full softpipe will have vertex shader, vertex fetch of its own. - */ - draw_set_viewport( generic->draw, viewport->scale, viewport->translate ); - generic->dirty |= G_NEW_VIEWPORT; -} - - - diff --git a/src/mesa/pipe/softpipe/g_state_derived.c b/src/mesa/pipe/softpipe/g_state_derived.c deleted file mode 100644 index 678825afe1..0000000000 --- a/src/mesa/pipe/softpipe/g_state_derived.c +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 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. - * - **************************************************************************/ - -#include "glheader.h" -#include "macros.h" -#include "enums.h" -#include "program.h" - -#include "g_context.h" -#include "g_draw.h" -#include "g_state.h" - -#define EMIT_ATTR( ATTR, FRAG_ATTR, INTERP ) \ -do { \ - slot_to_vf_attr[generic->nr_attrs] = ATTR; \ - generic->vf_attr_to_slot[ATTR] = generic->nr_attrs; \ - generic->fp_attr_to_slot[FRAG_ATTR] = generic->nr_attrs; \ - generic->interp[generic->nr_attrs] = INTERP; \ - generic->nr_attrs++; \ - attr_mask |= (1<fs.fp; - const GLuint inputsRead = fp->Base.InputsRead; - GLuint slot_to_vf_attr[VF_ATTRIB_MAX]; - GLuint attr_mask = 0; - GLuint i; - - generic->nr_attrs = 0; - memset(slot_to_vf_attr, 0, sizeof(slot_to_vf_attr)); - - memset(generic->fp_attr_to_slot, 0, sizeof(generic->vf_attr_to_slot)); - memset(generic->vf_attr_to_slot, 0, sizeof(generic->fp_attr_to_slot)); - - /* TODO - Figure out if we need to do perspective divide, etc. - */ - EMIT_ATTR(VF_ATTRIB_POS, FRAG_ATTRIB_WPOS, INTERP_LINEAR); - - /* Pull in the rest of the attributes. They are all in float4 - * format. Future optimizations could be to keep some attributes - * as fixed point or ubyte format. - */ - for (i = 1; i < FRAG_ATTRIB_TEX0; i++) { - if (inputsRead & (i << i)) { - EMIT_ATTR(frag_to_vf[i], i, INTERP_LINEAR); - } - } - - for (i = FRAG_ATTRIB_TEX0; i < FRAG_ATTRIB_MAX; i++) { - if (inputsRead & (i << i)) { - EMIT_ATTR(frag_to_vf[i], i, INTERP_PERSPECTIVE); - } - } - - generic->nr_frag_attrs = generic->nr_attrs; - - /* Additional attributes required for setup: Just twosided - * lighting. Edgeflag is dealt with specially by setting bits in - * the vertex header. - */ - if (generic->setup.light_twoside) { - if (inputsRead & FRAG_BIT_COL0) { - EMIT_ATTR(VF_ATTRIB_BFC0, FRAG_ATTRIB_MAX, 0); /* XXX: mark as discarded after setup */ - } - - if (inputsRead & FRAG_BIT_COL1) { - EMIT_ATTR(VF_ATTRIB_BFC1, FRAG_ATTRIB_MAX, 0); /* XXX: discard after setup */ - } - } - - if (attr_mask != generic->attr_mask) { - generic->attr_mask = attr_mask; - - draw_set_vertex_attributes( generic->draw, - slot_to_vf_attr, - generic->nr_attrs ); - } -} - - -/* Hopefully this will remain quite simple, otherwise need to pull in - * something like the state tracker mechanism. - */ -void generic_update_derived( struct generic_context *generic ) -{ - if (generic->dirty & (G_NEW_SETUP | G_NEW_FS)) - calculate_vertex_layout( generic ); - - generic->dirty = 0; -} diff --git a/src/mesa/pipe/softpipe/g_state_fs.c b/src/mesa/pipe/softpipe/g_state_fs.c deleted file mode 100644 index 8a430c0c65..0000000000 --- a/src/mesa/pipe/softpipe/g_state_fs.c +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 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. - * - **************************************************************************/ - -#include "g_context.h" -#include "g_state.h" - - - -void generic_set_fs_state( struct softpipe_context *softpipe, - const struct softpipe_fs_state *fs ) -{ - struct generic_context *generic = generic_context(softpipe); - - memcpy(&generic->fs, fs, sizeof(*fs)); - - generic->dirty |= G_NEW_FS; -} - - - - - - - - - diff --git a/src/mesa/pipe/softpipe/g_state_setup.c b/src/mesa/pipe/softpipe/g_state_setup.c deleted file mode 100644 index 2a5176c5a1..0000000000 --- a/src/mesa/pipe/softpipe/g_state_setup.c +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 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. - * - **************************************************************************/ - -#include "g_context.h" -#include "g_state.h" -#include "g_prim.h" - - - - -static void validate_prim_pipe( struct generic_context *generic ) -{ - struct prim_stage *next = generic->prim.setup; - - /* TODO: make the current primitive part of the state and build - * shorter pipelines for lines & points. - */ - if (generic->setup.fill_cw != FILL_TRI || - generic->setup.fill_ccw != FILL_TRI) { - - generic->prim.unfilled->next = next; - next = generic->prim.unfilled; - } - - if (generic->setup.offset_cw || - generic->setup.offset_ccw) { - generic->prim.offset->next = next; - next = generic->prim.offset; - } - - if (generic->setup.light_twoside) { - generic->prim.twoside->next = next; - next = generic->prim.twoside; - } - - /* Always run the cull stage as we calculate determinant there - * also. Fix this.. - */ - { - generic->prim.cull->next = next; - next = generic->prim.cull; - } - - - /* Clip stage - */ - { - generic->prim.clip->next = next; - next = generic->prim.clip; - } - - /* Do software flatshading prior to clipping. XXX: should only do - * this for clipped primitives, ie it is a part of the clip - * routine. - */ - if (generic->setup.flatshade) { - generic->prim.flatshade->next = next; - next = generic->prim.flatshade; - } - - - generic->prim.first = next; -} - - - - -void generic_set_setup_state( struct softpipe_context *softpipe, - const struct softpipe_setup_state *setup ) -{ - struct generic_context *generic = generic_context(softpipe); - - memcpy( &generic->setup, setup, sizeof(*setup) ); - - validate_prim_pipe( generic ); - generic->dirty |= G_NEW_SETUP; -} - - - -void generic_set_scissor_rect( struct softpipe_context *softpipe, - const struct softpipe_scissor_rect *scissor ) -{ - struct generic_context *generic = generic_context(softpipe); - - memcpy( &generic->scissor, scissor, sizeof(*scissor) ); - generic->dirty |= G_NEW_SCISSOR; -} - - -void generic_set_polygon_stipple( struct softpipe_context *softpipe, - const struct softpipe_poly_stipple *stipple ) -{ - struct generic_context *generic = generic_context(softpipe); - - memcpy( &generic->poly_stipple, stipple, sizeof(*stipple) ); - generic->dirty |= G_NEW_STIPPLE; -} diff --git a/src/mesa/pipe/softpipe/g_state_surface.c b/src/mesa/pipe/softpipe/g_state_surface.c deleted file mode 100644 index c791ce4640..0000000000 --- a/src/mesa/pipe/softpipe/g_state_surface.c +++ /dev/null @@ -1,53 +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: Keith Whitwell - */ -#include "imports.h" - -#include "g_context.h" -#include "g_state.h" -#include "g_surface.h" - - -/* This is all a total hack. - */ -void generic_set_cbuf_state( struct softpipe_context *softpipe, - const struct softpipe_surface *surface ) -{ - struct generic_context *generic = generic_context(softpipe); - - if (generic->cbuf_surface == NULL) { - generic->cbuf_surface = CALLOC_STRUCT(generic_surface); - generic->cbuf_surface->type = &gs_rgba8; - } - - generic->cbuf_surface->surface = *surface; - generic->dirty |= G_NEW_CBUF; -} - - diff --git a/src/mesa/pipe/softpipe/g_surface.c b/src/mesa/pipe/softpipe/g_surface.c deleted file mode 100644 index 2df30cde70..0000000000 --- a/src/mesa/pipe/softpipe/g_surface.c +++ /dev/null @@ -1,153 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 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. - * - **************************************************************************/ - -#include "g_context.h" -#include "g_state.h" -#include "g_surface.h" -#include "g_headers.h" - -static void rgba8_read_quad_f( struct generic_surface *gs, - GLint x, GLint y, - GLfloat (*rgba)[NUM_CHANNELS] ) -{ - GLuint i, j, k = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++, k++) { - GLubyte *ptr = gs->surface.ptr + (y+i) * gs->surface.stride + (x+j) * 4; - rgba[k][0] = ptr[0] * (1.0 / 255.0); - rgba[k][1] = ptr[1] * (1.0 / 255.0); - rgba[k][2] = ptr[2] * (1.0 / 255.0); - rgba[k][3] = ptr[3] * (1.0 / 255.0); - } - } -} - -static void rgba8_read_quad_f_swz( struct generic_surface *gs, - GLint x, GLint y, - GLfloat (*rrrr)[QUAD_SIZE] ) -{ - GLuint i, j, k = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++, k++) { - GLubyte *ptr = gs->surface.ptr + (y+i) * gs->surface.stride + (x+j) * 4; - rrrr[0][k] = ptr[0] * (1.0 / 255.0); - rrrr[1][k] = ptr[1] * (1.0 / 255.0); - rrrr[2][k] = ptr[2] * (1.0 / 255.0); - rrrr[3][k] = ptr[3] * (1.0 / 255.0); - } - } -} - -static void rgba8_write_quad_f( struct generic_surface *gs, - GLint x, GLint y, - GLfloat (*rgba)[NUM_CHANNELS] ) -{ - GLuint i, j, k = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++, k++) { - GLubyte *ptr = gs->surface.ptr + (y+i) * gs->surface.stride + (x+j) * 4; - ptr[0] = rgba[k][0] * 255.0; - ptr[1] = rgba[k][1] * 255.0; - ptr[2] = rgba[k][2] * 255.0; - ptr[3] = rgba[k][3] * 255.0; - } - } -} - -static void rgba8_write_quad_f_swz( struct generic_surface *gs, - GLint x, GLint y, - GLfloat (*rrrr)[QUAD_SIZE] ) -{ - GLuint i, j, k = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++, k++) { - GLubyte *ptr = gs->surface.ptr + (y+i) * gs->surface.stride + (x+j) * 4; - ptr[0] = rrrr[0][k] * 255.0; - ptr[1] = rrrr[1][k] * 255.0; - ptr[2] = rrrr[2][k] * 255.0; - ptr[3] = rrrr[3][k] * 255.0; - } - } -} - - - - -static void rgba8_read_quad_ub( struct generic_surface *gs, - GLint x, GLint y, - GLubyte (*rgba)[NUM_CHANNELS] ) -{ - GLuint i, j, k = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++, k++) { - GLubyte *ptr = gs->surface.ptr + (y+i) * gs->surface.stride + (x+j) * 4; - rgba[k][0] = ptr[0]; - rgba[k][1] = ptr[1]; - rgba[k][2] = ptr[2]; - rgba[k][3] = ptr[3]; - } - } -} - - -static void rgba8_write_quad_ub( struct generic_surface *gs, - GLint x, GLint y, - GLubyte (*rgba)[NUM_CHANNELS] ) -{ - GLuint i, j, k = 0; - - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++, k++) { - GLubyte *ptr = gs->surface.ptr + (y+i) * gs->surface.stride + (x+j) * 4; - ptr[0] = rgba[k][0]; - ptr[1] = rgba[k][1]; - ptr[2] = rgba[k][2]; - ptr[3] = rgba[k][3]; - } - } -} - - - - -struct generic_surface_type gs_rgba8 = { - G_SURFACE_RGBA_8888, - rgba8_read_quad_f, - rgba8_read_quad_f_swz, - rgba8_read_quad_ub, - rgba8_write_quad_f, - rgba8_write_quad_f_swz, - rgba8_write_quad_ub, -}; - - - diff --git a/src/mesa/pipe/softpipe/g_surface.h b/src/mesa/pipe/softpipe/g_surface.h deleted file mode 100644 index 23c28f0bb4..0000000000 --- a/src/mesa/pipe/softpipe/g_surface.h +++ /dev/null @@ -1,115 +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: Keith Whitwell - */ - -#ifndef G_SURFACE_H -#define G_SURFACE_H - -#include "glheader.h" -#include "g_headers.h" - -struct generic_surface; - -#define G_SURFACE_RGBA_8888 0x1 - -/* Internal structs and helpers for the primitive clip/setup pipeline: - */ -struct generic_surface_type { - - GLuint format; - - void (*read_quad_f)( struct generic_surface *, - GLint x, GLint y, - GLfloat (*rgba)[NUM_CHANNELS] ); - - void (*read_quad_f_swz)( struct generic_surface *, - GLint x, GLint y, - GLfloat (*rrrr)[QUAD_SIZE] ); - - void (*read_quad_ub)( struct generic_surface *, - GLint x, GLint y, - GLubyte (*rgba)[NUM_CHANNELS] ); - - - void (*write_quad_f)( struct generic_surface *, - GLint x, GLint y, - GLfloat (*rgba)[NUM_CHANNELS] ); - - void (*write_quad_f_swz)( struct generic_surface *, - GLint x, GLint y, - GLfloat (*rrrr)[QUAD_SIZE] ); - - - void (*write_quad_ub)( struct generic_surface *, - GLint x, GLint y, - GLubyte (*rgba)[NUM_CHANNELS] ); - - -}; - - -struct generic_surface { - struct generic_surface_type *type; - struct softpipe_surface surface; -}; - - -static INLINE void gs_read_quad_f( struct generic_surface *gs, - GLint x, GLint y, - GLfloat (*rgba)[NUM_CHANNELS] ) -{ - gs->type->read_quad_f(gs, x, y, rgba); -} - -static INLINE void gs_read_quad_f_swz( struct generic_surface *gs, - GLint x, GLint y, - GLfloat (*rrrr)[QUAD_SIZE] ) -{ - gs->type->read_quad_f_swz(gs, x, y, rrrr); -} - -static INLINE void gs_write_quad_f( struct generic_surface *gs, - GLint x, GLint y, - GLfloat (*rgba)[NUM_CHANNELS] ) -{ - gs->type->write_quad_f(gs, x, y, rgba); -} - -static INLINE void gs_write_quad_f_swz( struct generic_surface *gs, - GLint x, GLint y, - GLfloat (*rrrr)[QUAD_SIZE] ) -{ - gs->type->write_quad_f_swz(gs, x, y, rrrr); -} - -/* Like this, or hidden? - */ -struct generic_surface_type gs_rgba8; - -#endif diff --git a/src/mesa/pipe/softpipe/g_tile.h b/src/mesa/pipe/softpipe/g_tile.h deleted file mode 100644 index 6ae5212356..0000000000 --- a/src/mesa/pipe/softpipe/g_tile.h +++ /dev/null @@ -1,42 +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: Keith Whitwell - */ -#ifndef G_TILE_H -#define G_TILE_H - -struct generic_context; -struct quad_header; - -void quad_shade( struct generic_context *generic, - struct quad_header *quad ); - -void quad_output( struct generic_context *generic, - struct quad_header *quad ); - -#endif diff --git a/src/mesa/pipe/softpipe/g_tile_fs.c b/src/mesa/pipe/softpipe/g_tile_fs.c deleted file mode 100644 index 4c5e6efaed..0000000000 --- a/src/mesa/pipe/softpipe/g_tile_fs.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -/* Vertices are just an array of floats, with all the attributes - * packed. We currently assume a layout like: - * - * attr[0][0..3] - window position - * attr[1..n][0..3] - remaining attributes. - * - * Attributes are assumed to be 4 floats wide but are packed so that - * all the enabled attributes run contiguously. - */ - -#include "glheader.h" -#include "g_context.h" -#include "g_headers.h" -#include "g_tile.h" - -struct exec_machine { - const struct setup_coefficient *coef; - - GLfloat attr[FRAG_ATTRIB_MAX][4][QUAD_SIZE]; -}; - - -/** - * Compute quad's attributes values, as constants (GL_FLAT shading). - */ -static INLINE void cinterp( struct exec_machine *exec, - GLuint attrib, - GLuint i ) -{ - GLuint j; - - for (j = 0; j < QUAD_SIZE; j++) { - exec->attr[attrib][i][j] = exec->coef[attrib].a0[i]; - } -} - - -/** - * Compute quad's attribute values by linear interpolation. - * - * Push into the fp: - * - * INPUT[attr] = MAD COEF_A0[attr], COEF_DADX[attr], INPUT_WPOS.xxxx - * INPUT[attr] = MAD INPUT[attr], COEF_DADY[attr], INPUT_WPOS.yyyy - */ -static INLINE void linterp( struct exec_machine *exec, - GLuint attrib, - GLuint i ) -{ - GLuint j; - - for (j = 0; j < QUAD_SIZE; j++) { - const GLfloat x = exec->attr[FRAG_ATTRIB_WPOS][0][j]; - const GLfloat y = exec->attr[FRAG_ATTRIB_WPOS][1][j]; - exec->attr[attrib][i][j] = (exec->coef[attrib].a0[i] + - exec->coef[attrib].dadx[i] * x + - exec->coef[attrib].dady[i] * y); - } -} - - -/** - * Compute quad's attribute values by linear interpolation with - * perspective correction. - * - * Push into the fp: - * - * INPUT[attr] = MAD COEF_A0[attr], COEF_DADX[attr], INPUT_WPOS.xxxx - * INPUT[attr] = MAD INPUT[attr], COEF_DADY[attr], INPUT_WPOS.yyyy - * INPUT[attr] = MUL INPUT[attr], INPUT_WPOS.wwww - * - * (Or should that be 1/w ???) - */ -static INLINE void pinterp( struct exec_machine *exec, - GLuint attrib, - GLuint i ) -{ - GLuint j; - - for (j = 0; j < QUAD_SIZE; j++) { - const GLfloat x = exec->attr[FRAG_ATTRIB_WPOS][0][j]; - const GLfloat y = exec->attr[FRAG_ATTRIB_WPOS][1][j]; - const GLfloat invW = exec->attr[FRAG_ATTRIB_WPOS][3][j]; - exec->attr[attrib][i][j] = ((exec->coef[attrib].a0[i] + - exec->coef[attrib].dadx[i] * x + - exec->coef[attrib].dady[i] * y) * invW); - } -} - - - -/* This should be done by the fragment shader execution unit (code - * generated from the decl instructions). Do it here for now. - */ -void quad_shade( struct generic_context *generic, - struct quad_header *quad ) -{ - struct exec_machine exec; - GLfloat fx = quad->x0; - GLfloat fy = quad->y0; - GLuint i, j; - - exec.coef = quad->coef; - - /* Position: - */ - exec.attr[FRAG_ATTRIB_WPOS][0][0] = fx; - exec.attr[FRAG_ATTRIB_WPOS][0][1] = fx + 1.0; - exec.attr[FRAG_ATTRIB_WPOS][0][2] = fx; - exec.attr[FRAG_ATTRIB_WPOS][0][3] = fx + 1.0; - - exec.attr[FRAG_ATTRIB_WPOS][1][0] = fy; - exec.attr[FRAG_ATTRIB_WPOS][1][1] = fy; - exec.attr[FRAG_ATTRIB_WPOS][1][2] = fy + 1.0; - exec.attr[FRAG_ATTRIB_WPOS][1][3] = fy + 1.0; - - /* Z and W are done by linear interpolation: - * XXX we'll probably have to use integers for Z - */ - if (generic->need_z) { - linterp(&exec, 0, 2); - } - - if (generic->need_w) { - linterp(&exec, 0, 3); -// invert(&exec, 0, 3); - } - - /* Interpolate all the remaining attributes. This will get pushed - * into the fragment program's responsibilities at some point. - */ - for (i = 1; i < quad->nr_attrs; i++) { -#if 1 - for (j = 0; j < NUM_CHANNELS; j++) - linterp(&exec, i, j); -#else - switch (quad->interp[i]) { - case INTERP_CONSTANT: - for (j = 0; j < NUM_CHANNELS; j++) - cinterp(&exec, i, j); - break; - - case INTERP_LINEAR: - for (j = 0; j < NUM_CHANNELS; j++) - linterp(&exec, i, j); - break; - - case INTERP_PERSPECTIVE: - for (j = 0; j < NUM_CHANNELS; j++) - pinterp(&exec, i, j); - break; - } -#endif - } - -#if 0 - generic->run_fs( tri->fp, quad, &tri->outputs ); -#else - { - GLuint attr = generic->fp_attr_to_slot[FRAG_ATTRIB_COL0]; - assert(attr); - - memcpy(quad->outputs.color, - exec.attr[attr], - sizeof(quad->outputs.color)); - } -#endif - - - if (quad->mask) - quad_output( generic, quad ); -} - - - - - - - diff --git a/src/mesa/pipe/softpipe/g_tile_output.c b/src/mesa/pipe/softpipe/g_tile_output.c deleted file mode 100644 index 058ca30193..0000000000 --- a/src/mesa/pipe/softpipe/g_tile_output.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -/* Vertices are just an array of floats, with all the attributes - * packed. We currently assume a layout like: - * - * attr[0][0..3] - window position - * attr[1..n][0..3] - remaining attributes. - * - * Attributes are assumed to be 4 floats wide but are packed so that - * all the enabled attributes run contiguously. - */ - -#include "glheader.h" -#include "g_context.h" -#include "g_headers.h" -#include "g_surface.h" -#include "g_tile.h" - - -static void mask_copy( GLfloat (*dest)[4], - GLfloat (*src)[4], - GLuint mask ) -{ - GLuint i, j; - - for (i = 0; i < 4; i++) { - if (mask & (1<mask != MASK_ALL) - { - GLfloat tmp[4][QUAD_SIZE]; - - /* Yes, we'll probably have a masked write as well, but this is - * how blend will be done at least. - */ - gs_read_quad_f_swz( generic->cbuf_surface, - quad->x0, - quad->y0, - tmp ); - - mask_copy( tmp, quad->outputs.color, quad->mask ); - - gs_write_quad_f_swz( generic->cbuf_surface, - quad->x0, - quad->y0, - tmp ); - } - else - { - gs_write_quad_f_swz( generic->cbuf_surface, - quad->x0, - quad->y0, - quad->outputs.color ); - } -} diff --git a/src/mesa/sources b/src/mesa/sources index eda3ef7beb..af8d678878 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -155,36 +155,38 @@ VF_SOURCES = \ vf/vf_sse.c SOFTPIPE_SOURCES = \ - softpipe/generic/g_context.c \ - softpipe/generic/g_draw.c \ - softpipe/generic/g_prim_clip.c \ - softpipe/generic/g_prim_cull.c \ - softpipe/generic/g_prim_flatshade.c \ - softpipe/generic/g_prim_offset.c \ - softpipe/generic/g_prim_setup.c \ - softpipe/generic/g_prim_twoside.c \ - softpipe/generic/g_prim_unfilled.c \ - softpipe/generic/g_state_clip.c \ - softpipe/generic/g_state_derived.c \ - softpipe/generic/g_state_fs.c \ - softpipe/generic/g_state_setup.c \ - softpipe/generic/g_state_surface.c \ - softpipe/generic/g_surface.c \ - softpipe/generic/g_tile_fs.c \ - softpipe/generic/g_tile_output.c \ - softpipe/state_tracker/st_atom.c \ - softpipe/state_tracker/st_atom_blend.c \ - softpipe/state_tracker/st_atom_cbuf.c \ - softpipe/state_tracker/st_atom_clip.c \ - softpipe/state_tracker/st_atom_depth.c \ - softpipe/state_tracker/st_atom_fs.c \ - softpipe/state_tracker/st_atom_scissor.c \ - softpipe/state_tracker/st_atom_stencil.c \ - softpipe/state_tracker/st_atom_setup.c \ - softpipe/state_tracker/st_atom_viewport.c \ - softpipe/state_tracker/st_cb_program.c \ - softpipe/state_tracker/st_draw.c \ - softpipe/state_tracker/st_context.c + pipe/softpipe/sp_context.c \ + pipe/softpipe/sp_draw.c \ + pipe/softpipe/sp_prim_clip.c \ + pipe/softpipe/sp_prim_cull.c \ + pipe/softpipe/sp_prim_flatshade.c \ + pipe/softpipe/sp_prim_offset.c \ + pipe/softpipe/sp_prim_setup.c \ + pipe/softpipe/sp_prim_twoside.c \ + pipe/softpipe/sp_prim_unfilled.c \ + pipe/softpipe/sp_state_clip.c \ + pipe/softpipe/sp_state_derived.c \ + pipe/softpipe/sp_state_fs.c \ + pipe/softpipe/sp_state_setup.c \ + pipe/softpipe/sp_state_surface.c \ + pipe/softpipe/sp_surface.c \ + pipe/softpipe/sp_tile_fs.c \ + pipe/softpipe/sp_tile_output.c + +STATETRACKER_SOURCES = \ + state_tracker/st_atom.c \ + state_tracker/st_atom_blend.c \ + state_tracker/st_atom_cbuf.c \ + state_tracker/st_atom_clip.c \ + state_tracker/st_atom_depth.c \ + state_tracker/st_atom_fs.c \ + state_tracker/st_atom_scissor.c \ + state_tracker/st_atom_stencil.c \ + state_tracker/st_atom_setup.c \ + state_tracker/st_atom_viewport.c \ + state_tracker/st_cb_program.c \ + state_tracker/st_draw.c \ + state_tracker/st_context.c @@ -334,6 +336,7 @@ SOLO_SOURCES = \ $(VBO_SOURCES) \ $(VF_SOURCES) \ $(SOFTPIPE_SOURCES) \ + $(STATETRACKER_SOURCES) \ $(TNL_SOURCES) \ $(SHADER_SOURCES) \ $(SWRAST_SOURCES) \ diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index eabb9172ba..03fbd290e0 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -34,12 +34,12 @@ #include "st_context.h" #include "st_atom.h" -#include "softpipe/sp_context.h" -#include "softpipe/sp_defines.h" +#include "pipe/p_context.h" +#include "pipe/p_defines.h" /** - * Convert GLenum blend tokens to softpipe tokens. + * Convert GLenum blend tokens to pipe tokens. * Both blend factors and blend funcs are accepted. */ static GLuint @@ -48,54 +48,54 @@ gl_blend_to_sp(GLenum blend) switch (blend) { /* blend functions */ case GL_FUNC_ADD: - return SP_BLEND_ADD; + return PIPE_BLEND_ADD; case GL_FUNC_SUBTRACT: - return SP_BLEND_SUBTRACT; + return PIPE_BLEND_SUBTRACT; case GL_FUNC_REVERSE_SUBTRACT: - return SP_BLEND_REVERSE_SUBTRACT; + return PIPE_BLEND_REVERSE_SUBTRACT; case GL_MIN: - return SP_BLEND_MIN; + return PIPE_BLEND_MIN; case GL_MAX: - return SP_BLEND_MAX; + return PIPE_BLEND_MAX; /* blend factors */ case GL_ONE: - return SP_BLENDFACTOR_ONE; + return PIPE_BLENDFACTOR_ONE; case GL_SRC_COLOR: - return SP_BLENDFACTOR_SRC_COLOR; + return PIPE_BLENDFACTOR_SRC_COLOR; case GL_SRC_ALPHA: - return SP_BLENDFACTOR_SRC_ALPHA; + return PIPE_BLENDFACTOR_SRC_ALPHA; case GL_DST_ALPHA: - return SP_BLENDFACTOR_DST_ALPHA; + return PIPE_BLENDFACTOR_DST_ALPHA; case GL_DST_COLOR: - return SP_BLENDFACTOR_DST_COLOR; + return PIPE_BLENDFACTOR_DST_COLOR; case GL_SRC_ALPHA_SATURATE: - return SP_BLENDFACTOR_SRC_ALPHA_SATURATE; + return PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE; case GL_CONSTANT_COLOR: - return SP_BLENDFACTOR_CONST_COLOR; + return PIPE_BLENDFACTOR_CONST_COLOR; case GL_CONSTANT_ALPHA: - return SP_BLENDFACTOR_CONST_ALPHA; + return PIPE_BLENDFACTOR_CONST_ALPHA; /* - return SP_BLENDFACTOR_SRC1_COLOR; - return SP_BLENDFACTOR_SRC1_ALPHA; + return PIPE_BLENDFACTOR_SRC1_COLOR; + return PIPE_BLENDFACTOR_SRC1_ALPHA; */ case GL_ZERO: - return SP_BLENDFACTOR_ZERO; + return PIPE_BLENDFACTOR_ZERO; case GL_ONE_MINUS_SRC_COLOR: - return SP_BLENDFACTOR_INV_SRC_COLOR; + return PIPE_BLENDFACTOR_INV_SRC_COLOR; case GL_ONE_MINUS_SRC_ALPHA: - return SP_BLENDFACTOR_INV_SRC_ALPHA; + return PIPE_BLENDFACTOR_INV_SRC_ALPHA; case GL_ONE_MINUS_DST_COLOR: - return SP_BLENDFACTOR_INV_DST_ALPHA; + return PIPE_BLENDFACTOR_INV_DST_ALPHA; case GL_ONE_MINUS_DST_ALPHA: - return SP_BLENDFACTOR_INV_DST_COLOR; + return PIPE_BLENDFACTOR_INV_DST_COLOR; case GL_ONE_MINUS_CONSTANT_COLOR: - return SP_BLENDFACTOR_INV_CONST_COLOR; + return PIPE_BLENDFACTOR_INV_CONST_COLOR; case GL_ONE_MINUS_CONSTANT_ALPHA: - return SP_BLENDFACTOR_INV_CONST_ALPHA; + return PIPE_BLENDFACTOR_INV_CONST_ALPHA; /* - return SP_BLENDFACTOR_INV_SRC1_COLOR; - return SP_BLENDFACTOR_INV_SRC1_ALPHA; + return PIPE_BLENDFACTOR_INV_SRC1_COLOR; + return PIPE_BLENDFACTOR_INV_SRC1_ALPHA; */ default: assert("invalid GL token in gl_blend_to_sp()" == NULL); @@ -105,44 +105,44 @@ gl_blend_to_sp(GLenum blend) /** - * Convert GLenum logicop tokens to softpipe tokens. + * Convert GLenum logicop tokens to pipe tokens. */ static GLuint gl_logicop_to_sp(GLenum logicop) { switch (logicop) { case GL_CLEAR: - return SP_LOGICOP_CLEAR; + return PIPE_LOGICOP_CLEAR; case GL_NOR: - return SP_LOGICOP_NOR; + return PIPE_LOGICOP_NOR; case GL_AND_INVERTED: - return SP_LOGICOP_AND_INVERTED; + return PIPE_LOGICOP_AND_INVERTED; case GL_COPY_INVERTED: - return SP_LOGICOP_COPY_INVERTED; + return PIPE_LOGICOP_COPY_INVERTED; case GL_AND_REVERSE: - return SP_LOGICOP_AND_REVERSE; + return PIPE_LOGICOP_AND_REVERSE; case GL_INVERT: - return SP_LOGICOP_INVERT; + return PIPE_LOGICOP_INVERT; case GL_XOR: - return SP_LOGICOP_XOR; + return PIPE_LOGICOP_XOR; case GL_NAND: - return SP_LOGICOP_NAND; + return PIPE_LOGICOP_NAND; case GL_AND: - return SP_LOGICOP_AND; + return PIPE_LOGICOP_AND; case GL_EQUIV: - return SP_LOGICOP_EQUIV; + return PIPE_LOGICOP_EQUIV; case GL_NOOP: - return SP_LOGICOP_NOOP; + return PIPE_LOGICOP_NOOP; case GL_OR_INVERTED: - return SP_LOGICOP_OR_INVERTED; + return PIPE_LOGICOP_OR_INVERTED; case GL_COPY: - return SP_LOGICOP_COPY; + return PIPE_LOGICOP_COPY; case GL_OR_REVERSE: - return SP_LOGICOP_OR_REVERSE; + return PIPE_LOGICOP_OR_REVERSE; case GL_OR: - return SP_LOGICOP_OR; + return PIPE_LOGICOP_OR; case GL_SET: - return SP_LOGICOP_SET; + return PIPE_LOGICOP_SET; default: assert("invalid GL token in gl_logicop_to_sp()" == NULL); return 0; @@ -153,7 +153,7 @@ gl_logicop_to_sp(GLenum logicop) static void update_blend( struct st_context *st ) { - struct softpipe_blend_state blend; + struct pipe_blend_state blend; memset(&blend, 0, sizeof(blend)); @@ -183,7 +183,7 @@ update_blend( struct st_context *st ) if (memcmp(&blend, &st->state.blend, sizeof(blend)) != 0) { /* state has changed */ st->state.blend = blend; /* struct copy */ - st->softpipe->set_blend_state(st->softpipe, &blend); /* set new state */ + st->pipe->set_blend_state(st->pipe, &blend); /* set new state */ } } diff --git a/src/mesa/state_tracker/st_atom_cbuf.c b/src/mesa/state_tracker/st_atom_cbuf.c index cd707ec5ef..0f90aa7646 100644 --- a/src/mesa/state_tracker/st_atom_cbuf.c +++ b/src/mesa/state_tracker/st_atom_cbuf.c @@ -31,7 +31,7 @@ */ #include "st_context.h" -#include "softpipe/sp_context.h" +#include "pipe/p_context.h" #include "st_atom.h" extern GLboolean xmesa_get_cbuf_details( GLcontext *ctx, @@ -45,7 +45,7 @@ extern GLboolean xmesa_get_cbuf_details( GLcontext *ctx, */ static void update_cbuf_state( struct st_context *st ) { - struct softpipe_surface cbuf; + struct pipe_surface cbuf; GLboolean ok; ok = xmesa_get_cbuf_details( st->ctx, @@ -58,7 +58,7 @@ static void update_cbuf_state( struct st_context *st ) if (memcmp(&cbuf, &st->state.cbuf, sizeof(cbuf)) != 0) { st->state.cbuf = cbuf; - st->softpipe->set_cbuf_state( st->softpipe, &cbuf ); + st->pipe->set_cbuf_state( st->pipe, &cbuf ); } } diff --git a/src/mesa/state_tracker/st_atom_clip.c b/src/mesa/state_tracker/st_atom_clip.c index 710d6ffc84..8ccad637d5 100644 --- a/src/mesa/state_tracker/st_atom_clip.c +++ b/src/mesa/state_tracker/st_atom_clip.c @@ -32,7 +32,7 @@ #include "st_context.h" -#include "softpipe/sp_context.h" +#include "pipe/p_context.h" #include "st_atom.h" @@ -40,12 +40,12 @@ */ static void update_clip( struct st_context *st ) { - struct softpipe_clip_state clip; + struct pipe_clip_state clip; GLuint i; memset(&clip, 0, sizeof(clip)); - for (i = 0; i < SP_MAX_CLIP_PLANES; i++) { + for (i = 0; i < PIPE_MAX_CLIP_PLANES; i++) { if (st->ctx->Transform.ClipPlanesEnabled & (1 << i)) { memcpy(clip.ucp[clip.nr], st->ctx->Transform._ClipUserPlane[i], @@ -56,7 +56,7 @@ static void update_clip( struct st_context *st ) if (memcmp(&clip, &st->state.clip, sizeof(clip)) != 0) { st->state.clip = clip; - st->softpipe->set_clip_state(st->softpipe, &clip); + st->pipe->set_clip_state(st->pipe, &clip); } } diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index 5532abc8fd..4c891e6e54 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -34,25 +34,25 @@ #include "st_context.h" #include "st_atom.h" -#include "softpipe/sp_context.h" -#include "softpipe/sp_defines.h" +#include "pipe/p_context.h" +#include "pipe/p_defines.h" /** - * Convert GLenum depth func tokens to softpipe tokens. + * Convert GLenum depth func tokens to pipe tokens. */ static GLuint gl_depth_func_to_sp(GLenum func) { /* Same values, just biased */ - assert(SP_DEPTH_FUNC_NEVER == GL_NEVER - GL_NEVER); - assert(SP_DEPTH_FUNC_LESS == GL_LESS - GL_NEVER); - assert(SP_DEPTH_FUNC_EQUAL == GL_EQUAL - GL_NEVER); - assert(SP_DEPTH_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER); - assert(SP_DEPTH_FUNC_GREATER == GL_GREATER - GL_NEVER); - assert(SP_DEPTH_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER); - assert(SP_DEPTH_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER); - assert(SP_DEPTH_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER); + assert(PIPE_DEPTH_FUNC_NEVER == GL_NEVER - GL_NEVER); + assert(PIPE_DEPTH_FUNC_LESS == GL_LESS - GL_NEVER); + assert(PIPE_DEPTH_FUNC_EQUAL == GL_EQUAL - GL_NEVER); + assert(PIPE_DEPTH_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER); + assert(PIPE_DEPTH_FUNC_GREATER == GL_GREATER - GL_NEVER); + assert(PIPE_DEPTH_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER); + assert(PIPE_DEPTH_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER); + assert(PIPE_DEPTH_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER); assert(func >= GL_NEVER); assert(func <= GL_ALWAYS); return func - GL_NEVER; @@ -62,7 +62,7 @@ gl_depth_func_to_sp(GLenum func) static void update_depth( struct st_context *st ) { - struct softpipe_depth_state depth; + struct pipe_depth_state depth; memset(&depth, 0, sizeof(depth)); @@ -74,7 +74,7 @@ update_depth( struct st_context *st ) if (memcmp(&depth, &st->state.depth, sizeof(depth)) != 0) { /* state has changed */ st->state.depth = depth; /* struct copy */ - st->softpipe->set_depth_state(st->softpipe, &depth); /* set new state */ + st->pipe->set_depth_state(st->pipe, &depth); /* set new state */ } } diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index ca109d2d34..9c6bc1ce2a 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -30,19 +30,19 @@ */ #include "st_context.h" -#include "softpipe/sp_context.h" +#include "pipe/p_context.h" #include "st_atom.h" static void update_fs( struct st_context *st ) { - struct softpipe_fs_state fs; + struct pipe_fs_state fs; fs.fp = st->ctx->FragmentProgram._Current; if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0) { st->state.fs = fs; - st->softpipe->set_fs_state(st->softpipe, &fs); + st->pipe->set_fs_state(st->pipe, &fs); } } diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c index 105c2a6dd9..75bead388f 100644 --- a/src/mesa/state_tracker/st_atom_scissor.c +++ b/src/mesa/state_tracker/st_atom_scissor.c @@ -32,7 +32,7 @@ #include "st_context.h" -#include "softpipe/sp_context.h" +#include "pipe/p_context.h" #include "st_atom.h" @@ -42,7 +42,7 @@ static void update_scissor( struct st_context *st ) { - struct softpipe_scissor_rect scissor; + struct pipe_scissor_rect scissor; const struct gl_framebuffer *fb = st->ctx->DrawBuffer; scissor.minx = 0; @@ -69,7 +69,7 @@ update_scissor( struct st_context *st ) if (memcmp(&scissor, &st->state.scissor, sizeof(scissor)) != 0) { /* state has changed */ st->state.scissor = scissor; /* struct copy */ - st->softpipe->set_scissor_rect(st->softpipe, &scissor); /* activate */ + st->pipe->set_scissor_rect(st->pipe, &scissor); /* activate */ } } diff --git a/src/mesa/state_tracker/st_atom_setup.c b/src/mesa/state_tracker/st_atom_setup.c index 2a582ea36c..d88d403c1d 100644 --- a/src/mesa/state_tracker/st_atom_setup.c +++ b/src/mesa/state_tracker/st_atom_setup.c @@ -32,7 +32,7 @@ #include "st_context.h" -#include "softpipe/sp_context.h" +#include "pipe/p_context.h" #include "st_atom.h" static GLuint translate_fill( GLenum mode ) @@ -60,7 +60,7 @@ static GLboolean get_offset_flag( GLuint fill_mode, static void update_setup_state( struct st_context *st ) { GLcontext *ctx = st->ctx; - struct softpipe_setup_state setup; + struct pipe_setup_state setup; memset(&setup, 0, sizeof(setup)); @@ -162,7 +162,7 @@ static void update_setup_state( struct st_context *st ) if (memcmp(&setup, &st->state.setup, sizeof(setup)) != 0) { st->state.setup = setup; - st->softpipe->set_setup_state( st->softpipe, &setup ); + st->pipe->set_setup_state( st->pipe, &setup ); } } diff --git a/src/mesa/state_tracker/st_atom_stencil.c b/src/mesa/state_tracker/st_atom_stencil.c index 32610c3d24..b9f24f49e6 100644 --- a/src/mesa/state_tracker/st_atom_stencil.c +++ b/src/mesa/state_tracker/st_atom_stencil.c @@ -34,25 +34,25 @@ #include "st_context.h" #include "st_atom.h" -#include "softpipe/sp_context.h" -#include "softpipe/sp_defines.h" +#include "pipe/p_context.h" +#include "pipe/p_defines.h" /** - * Convert GLenum stencil func tokens to softpipe tokens. + * Convert GLenum stencil func tokens to pipe tokens. */ static GLuint gl_stencil_func_to_sp(GLenum func) { /* Same values, just biased */ - assert(SP_STENCIL_FUNC_NEVER == GL_NEVER - GL_NEVER); - assert(SP_STENCIL_FUNC_LESS == GL_LESS - GL_NEVER); - assert(SP_STENCIL_FUNC_EQUAL == GL_EQUAL - GL_NEVER); - assert(SP_STENCIL_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER); - assert(SP_STENCIL_FUNC_GREATER == GL_GREATER - GL_NEVER); - assert(SP_STENCIL_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER); - assert(SP_STENCIL_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER); - assert(SP_STENCIL_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER); + assert(PIPE_STENCIL_FUNC_NEVER == GL_NEVER - GL_NEVER); + assert(PIPE_STENCIL_FUNC_LESS == GL_LESS - GL_NEVER); + assert(PIPE_STENCIL_FUNC_EQUAL == GL_EQUAL - GL_NEVER); + assert(PIPE_STENCIL_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER); + assert(PIPE_STENCIL_FUNC_GREATER == GL_GREATER - GL_NEVER); + assert(PIPE_STENCIL_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER); + assert(PIPE_STENCIL_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER); + assert(PIPE_STENCIL_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER); assert(func >= GL_NEVER); assert(func <= GL_ALWAYS); return func - GL_NEVER; @@ -60,28 +60,28 @@ gl_stencil_func_to_sp(GLenum func) /** - * Convert GLenum stencil op tokens to softpipe tokens. + * Convert GLenum stencil op tokens to pipe tokens. */ static GLuint gl_stencil_op_to_sp(GLenum func) { switch (func) { case GL_KEEP: - return SP_STENCIL_OP_KEEP; + return PIPE_STENCIL_OP_KEEP; case GL_ZERO: - return SP_STENCIL_OP_ZERO; + return PIPE_STENCIL_OP_ZERO; case GL_REPLACE: - return SP_STENCIL_OP_REPLACE; + return PIPE_STENCIL_OP_REPLACE; case GL_INCR: - return SP_STENCIL_OP_INCR; + return PIPE_STENCIL_OP_INCR; case GL_DECR: - return SP_STENCIL_OP_DECR; + return PIPE_STENCIL_OP_DECR; case GL_INCR_WRAP: - return SP_STENCIL_OP_INCR_WRAP; + return PIPE_STENCIL_OP_INCR_WRAP; case GL_DECR_WRAP: - return SP_STENCIL_OP_DECR_WRAP; + return PIPE_STENCIL_OP_DECR_WRAP; case GL_INVERT: - return SP_STENCIL_OP_INVERT; + return PIPE_STENCIL_OP_INVERT; default: assert("invalid GL token in gl_stencil_op_to_sp()" == NULL); return 0; @@ -92,7 +92,7 @@ gl_stencil_op_to_sp(GLenum func) static void update_stencil( struct st_context *st ) { - struct softpipe_stencil_state stencil; + struct pipe_stencil_state stencil; memset(&stencil, 0, sizeof(stencil)); @@ -121,7 +121,7 @@ update_stencil( struct st_context *st ) if (memcmp(&stencil, &st->state.stencil, sizeof(stencil)) != 0) { /* state has changed */ st->state.stencil = stencil; /* struct copy */ - st->softpipe->set_stencil_state(st->softpipe, &stencil); /* set new state */ + st->pipe->set_stencil_state(st->pipe, &stencil); /* set new state */ } } diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c index af896e2e31..765bcf3647 100644 --- a/src/mesa/state_tracker/st_atom_viewport.c +++ b/src/mesa/state_tracker/st_atom_viewport.c @@ -29,7 +29,7 @@ #include "context.h" #include "colormac.h" #include "st_context.h" -#include "softpipe/sp_context.h" +#include "pipe/p_context.h" #include "st_atom.h" @@ -88,7 +88,7 @@ static void update_viewport( struct st_context *st ) GLfloat half_height = ctx->Viewport.Height / 2.0; GLfloat half_depth = (ctx->Viewport.Far - ctx->Viewport.Near) / 2.0; - struct softpipe_viewport vp; + struct pipe_viewport vp; vp.scale[0] = half_width; vp.scale[1] = half_height * yScale; @@ -102,7 +102,7 @@ static void update_viewport( struct st_context *st ) if (memcmp(&vp, &st->state.viewport, sizeof(vp)) != 0) { st->state.viewport = vp; - st->softpipe->set_viewport(st->softpipe, &vp); + st->pipe->set_viewport(st->pipe, &vp); } } } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 8a06dd88df..6308e81a61 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -31,7 +31,7 @@ #include "st_atom.h" #include "st_draw.h" #include "st_program.h" -#include "softpipe/sp_context.h" +#include "pipe/p_context.h" void st_invalidate_state(GLcontext * ctx, GLuint new_state) { @@ -43,14 +43,14 @@ void st_invalidate_state(GLcontext * ctx, GLuint new_state) struct st_context *st_create_context( GLcontext *ctx, - struct softpipe_context *softpipe ) + struct pipe_context *pipe ) { struct st_context *st = CALLOC_STRUCT( st_context ); ctx->st = st; st->ctx = ctx; - st->softpipe = softpipe; + st->pipe = pipe; st->dirty.mesa = ~0; st->dirty.st = ~0; @@ -68,7 +68,7 @@ void st_destroy_context( struct st_context *st ) st_destroy_atoms( st ); st_destroy_draw( st ); st_destroy_cb_program( st ); - st->softpipe->destroy( st->softpipe ); + st->pipe->destroy( st->pipe ); FREE( st ); } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 317d377371..6d9460e2f0 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -29,7 +29,7 @@ #define ST_CONTEXT_H #include "mtypes.h" -#include "softpipe/sp_state.h" +#include "pipe/p_state.h" struct st_context; @@ -58,23 +58,23 @@ struct st_context { GLcontext *ctx; - struct softpipe_context *softpipe; + struct pipe_context *pipe; - /* Eventually will use a cache to feed the softpipe with + /* Eventually will use a cache to feed the pipe with * create/bind/delete calls to constant state objects. Not yet * though, we just shove random objects across the interface. */ struct { - struct softpipe_viewport viewport; - struct softpipe_setup_state setup; - struct softpipe_fs_state fs; - struct softpipe_blend_state blend; - struct softpipe_surface cbuf; - struct softpipe_clip_state clip; - struct softpipe_depth_state depth; - struct softpipe_scissor_rect scissor; - struct softpipe_poly_stipple poly_stipple; - struct softpipe_stencil_state stencil; + struct pipe_viewport viewport; + struct pipe_setup_state setup; + struct pipe_fs_state fs; + struct pipe_blend_state blend; + struct pipe_surface cbuf; + struct pipe_clip_state clip; + struct pipe_depth_state depth; + struct pipe_scissor_rect scissor; + struct pipe_poly_stipple poly_stipple; + struct pipe_stencil_state stencil; } state; struct { diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 12646402ee..4db8189988 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -38,7 +38,7 @@ #include "st_context.h" #include "st_atom.h" #include "st_draw.h" -#include "softpipe/sp_context.h" +#include "pipe/p_context.h" /* * TNL stage which feedsinto the above. @@ -52,13 +52,13 @@ static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage ) struct st_context *st = st_context(ctx); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - /* Validate driver and softpipe state: + /* Validate driver and pipe state: */ st_validate_state( st ); /* Call into the new draw code to handle the VB: */ - st->softpipe->draw_vb( st->softpipe, VB ); + st->pipe->draw_vb( st->pipe, VB ); /* Finished */ @@ -84,7 +84,7 @@ static const struct tnl_pipeline_stage *intel_pipeline[] = { &_tnl_texture_transform_stage, &_tnl_point_attenuation_stage, &_tnl_vertex_program_stage, - &st_draw, /* ADD: escape to softpipe */ + &st_draw, /* ADD: escape to pipe */ 0, }; diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index 8241dbd52d..3191549a2f 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -31,10 +31,10 @@ #include "mtypes.h" struct st_context; -struct softpipe_context; +struct pipe_context; struct st_context *st_create_context( GLcontext *ctx, - struct softpipe_context *softpipe); + struct pipe_context *pipe); void st_destroy_context( struct st_context *st ); -- cgit v1.2.3 From abf45c2a3db39fc1690e282e7f7603bc1d81f647 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Jun 2007 12:50:16 -0600 Subject: fix comment --- src/mesa/state_tracker/st_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 4db8189988..1f6c261bc2 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -41,7 +41,7 @@ #include "pipe/p_context.h" /* - * TNL stage which feedsinto the above. + * TNL stage which feeds into the above. * * XXX: this needs to go into each driver using this code, because we * cannot make the leap from ctx->draw_context in this file. The -- cgit v1.2.3 From b7c646d1bcf4b6fa285996d1b9b660ce478190f6 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Jun 2007 13:10:48 -0600 Subject: actually use new glClear code --- src/mesa/drivers/x11/xm_dd.c | 12 ++++++++++++ src/mesa/pipe/softpipe/sp_clear.c | 10 +++++----- src/mesa/state_tracker/st_draw.c | 14 ++++++++++++++ src/mesa/state_tracker/st_draw.h | 4 ++++ 4 files changed, 35 insertions(+), 5 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index eb59d1d05e..5725414856 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -55,6 +55,8 @@ #include "pipe/softpipe/sp_context.h" #include "state_tracker/st_public.h" +#include "state_tracker/st_context.h" +#include "state_tracker/st_draw.h" /* @@ -393,6 +395,7 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers) /* we can't handle color or index masking */ if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) { +#if 0 if (buffers & BUFFER_BIT_FRONT_LEFT) { /* clear front color buffer */ struct gl_renderbuffer *frontRb @@ -416,6 +419,15 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers) buffers &= ~BUFFER_BIT_BACK_LEFT; } } +#else + /* Clear with state-tracker/pipe interface */ + struct st_context *st = st_context(ctx); + GLboolean color = (buffers & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) ? 1: 0; + GLboolean depth = (buffers & BUFFER_BIT_DEPTH) ? 1 : 0; + GLboolean stencil = (buffers & BUFFER_BIT_STENCIL) ? 1 : 0; + GLboolean accum = (buffers & BUFFER_BIT_ACCUM) ? 1 : 0; + st_clear(st, color, depth, stencil, accum); +#endif } } if (buffers) diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c index 536f0d3924..e83bc053ef 100644 --- a/src/mesa/pipe/softpipe/sp_clear.c +++ b/src/mesa/pipe/softpipe/sp_clear.c @@ -40,14 +40,14 @@ void softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, GLboolean stencil, GLboolean accum) { - struct softpipe_context *softpipe = softpipe_context(pipe); + const struct softpipe_context *softpipe = softpipe_context(pipe); + const GLint x = softpipe->scissor.minx; + const GLint y = softpipe->scissor.miny; + const GLint w = softpipe->scissor.maxx - x; + const GLint h = softpipe->scissor.maxy - y; if (color) { GLuint i; - const GLint x = softpipe->scissor.minx; - const GLint y = softpipe->scissor.miny; - const GLint w = softpipe->scissor.maxx - x; - const GLint h = softpipe->scissor.maxy - y; GLubyte clr[4]; UNCLAMPED_FLOAT_TO_UBYTE(clr[0], softpipe->clear_color.color[0]); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 1f6c261bc2..55b98629db 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -105,3 +105,17 @@ void st_destroy_draw( struct st_context *st ) /* Nothing to do. */ } + + +/** XXX temporary here */ +void +st_clear(struct st_context *st, GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum) +{ + /* Validate driver and pipe state: + */ + st_validate_state( st ); + + st->pipe->clear(st->pipe, color, depth, stencil, accum); +} + diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index f51059706a..7a3ba52130 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -37,4 +37,8 @@ void st_init_draw( struct st_context *st ); void st_destroy_draw( struct st_context *st ); +/** XXX temporary here */ +void st_clear(struct st_context *st, GLboolean color, GLboolean depth, + GLboolean stencil, GLboolean accum); + #endif -- cgit v1.2.3 From 1edb5aafadc16ac0d7c604a3cd4a9c2e91d9b705 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Jun 2007 14:27:42 -0600 Subject: better comment --- src/mesa/state_tracker/st_draw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 55b98629db..24abee132f 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -112,8 +112,7 @@ void st_clear(struct st_context *st, GLboolean color, GLboolean depth, GLboolean stencil, GLboolean accum) { - /* Validate driver and pipe state: - */ + /* This makes sure the softpipe has the latest scissor, etc values */ st_validate_state( st ); st->pipe->clear(st->pipe, color, depth, stencil, accum); -- cgit v1.2.3 From 78cc48f70afee7edc5291e195af8e6b6ebbf2de9 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 20 Jun 2007 23:04:00 +0100 Subject: Rename static variable in temporary tnl code --- src/mesa/state_tracker/st_draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 24abee132f..a424d1dd05 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -74,7 +74,7 @@ const struct tnl_pipeline_stage st_draw = { draw }; -static const struct tnl_pipeline_stage *intel_pipeline[] = { +static const struct tnl_pipeline_stage *st_pipeline[] = { &_tnl_vertex_transform_stage, &_tnl_vertex_cull_stage, &_tnl_normal_transform_stage, @@ -96,7 +96,7 @@ void st_init_draw( struct st_context *st ) GLcontext *ctx = st->ctx; _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, intel_pipeline ); + _tnl_install_pipeline( ctx, st_pipeline ); } -- cgit v1.2.3 From 4f442d9ef5db42867c99a7288b4114a0340f73e6 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 2 Aug 2007 13:59:31 +0100 Subject: Reroute some clear functionality. Still require the intelClear() call to flush batchbuffers. That will be removed later... --- src/mesa/drivers/dri/i915pipe/intel_buffers.c | 120 ++------------------------ src/mesa/drivers/dri/i915pipe/intel_context.c | 7 +- src/mesa/main/buffers.c | 8 -- src/mesa/pipe/softpipe/sp_clear.c | 70 +++++---------- src/mesa/sources | 1 + src/mesa/state_tracker/st_cb_clear.c | 89 +++++++++++++++++++ src/mesa/state_tracker/st_context.c | 1 + src/mesa/state_tracker/st_draw.c | 11 --- 8 files changed, 125 insertions(+), 182 deletions(-) create mode 100644 src/mesa/state_tracker/st_cb_clear.c (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/drivers/dri/i915pipe/intel_buffers.c b/src/mesa/drivers/dri/i915pipe/intel_buffers.c index e39220fe47..5e68a869bf 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_buffers.c +++ b/src/mesa/drivers/dri/i915pipe/intel_buffers.c @@ -295,110 +295,14 @@ intelWindowMoved(struct intel_context *intel) -/** - * Called by ctx->Driver.Clear. - * XXX NO LONGER USED - REMOVE IN NEAR FUTURE - */ -#if 0 -static void -intelClear(GLcontext *ctx, GLbitfield mask) -#else -static void -OLD_intelClear(struct pipe_context *pipe, - GLboolean color, GLboolean depth, - GLboolean stencil, GLboolean accum) -#endif -{ - GLcontext *ctx = (GLcontext *) pipe->glctx; - const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask); - GLbitfield tri_mask = 0; - GLbitfield blit_mask = 0; - GLbitfield swrast_mask = 0; - struct gl_framebuffer *fb = ctx->DrawBuffer; - GLuint i; - - GLbitfield mask; - - if (color) - mask = ctx->DrawBuffer->_ColorDrawBufferMask[0]; /*XXX temporary*/ - else - mask = 0x0; - - if (0) - fprintf(stderr, "%s\n", __FUNCTION__); - - /* HW color buffers (front, back, aux, generic FBO, etc) */ - if (colorMask == ~0) { - /* clear all R,G,B,A */ - /* XXX FBO: need to check if colorbuffers are software RBOs! */ - blit_mask |= (mask & BUFFER_BITS_COLOR); - } - else { - /* glColorMask in effect */ - tri_mask |= (mask & BUFFER_BITS_COLOR); - } - - /* HW stencil */ - if (stencil) { - const struct pipe_region *stencilRegion - = intel_get_rb_region(fb, BUFFER_STENCIL); - if (stencilRegion) { - /* have hw stencil */ - if ((ctx->Stencil.WriteMask[0] & 0xff) != 0xff) { - /* not clearing all stencil bits, so use triangle clearing */ - tri_mask |= BUFFER_BIT_STENCIL; - } - else { - /* clearing all stencil bits, use blitting */ - blit_mask |= BUFFER_BIT_STENCIL; - } - } - } - - /* HW depth */ - if (depth) { - /* clear depth with whatever method is used for stencil (see above) */ - if (tri_mask & BUFFER_BIT_STENCIL) - tri_mask |= BUFFER_BIT_DEPTH; - else - blit_mask |= BUFFER_BIT_DEPTH; - } - - /* SW fallback clearing */ - swrast_mask = mask & ~tri_mask & ~blit_mask; - - for (i = 0; i < BUFFER_COUNT; i++) { - GLuint bufBit = 1 << i; - if ((blit_mask | tri_mask) & bufBit) { - if (!fb->Attachment[i].Renderbuffer->ClassID) { - blit_mask &= ~bufBit; - tri_mask &= ~bufBit; - swrast_mask |= bufBit; - } - } - } - - - intelFlush(ctx); /* XXX intelClearWithBlit also does this */ - - if (blit_mask) - intelClearWithBlit(ctx, blit_mask); - -#if 0 - if (swrast_mask | tri_mask) - _swrast_Clear(ctx, swrast_mask | tri_mask); -#else - softpipe_clear(pipe, GL_FALSE, - (swrast_mask | tri_mask) & BUFFER_BIT_DEPTH, - (swrast_mask | tri_mask) & BUFFER_BIT_STENCIL, - (swrast_mask | tri_mask) & BUFFER_BIT_ACCUM); -#endif -} - -/** - * Clear buffers. Called via pipe->clear(). - */ +/* XXX - kludge required because softpipe_clear uses + * region->fill(), which still calls intelBlit(!), but doesn't + * flush the batchbuffer. + * + * One way or another, that behaviour should stop, and then this + * function can go aawy. + */ void intelClear(struct pipe_context *pipe, GLboolean color, GLboolean depth, @@ -407,19 +311,9 @@ intelClear(struct pipe_context *pipe, GLcontext *ctx = (GLcontext *) pipe->glctx; struct intel_context *intel = intel_context(ctx); - /* XXX - * Examine stencil and color writemasks to determine if we can clear - * with blits. - */ - - intelFlush(&intel->ctx); - LOCK_HARDWARE(intel); - softpipe_clear(pipe, color, depth, stencil, accum); intel_batchbuffer_flush(intel->batch); - - UNLOCK_HARDWARE(intel); } diff --git a/src/mesa/drivers/dri/i915pipe/intel_context.c b/src/mesa/drivers/dri/i915pipe/intel_context.c index be8235d7d1..0fc24c3b5a 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_context.c +++ b/src/mesa/drivers/dri/i915pipe/intel_context.c @@ -417,7 +417,12 @@ intelCreateContext(const __GLcontextModes * mesaVis, */ st_create_context( &intel->ctx, softpipe_create() ); - + + /* KW: Not sure I like this - we should only be talking to the + * state_tracker. The pipe code will need some way of talking to + * us, eg for batchbuffer ioctls, and there will need to be a + * buffer manager interface. So, this is a temporary hack, right? + */ intel->pipe = intel->ctx.st->pipe; intel->pipe->screen = intelScreen; intel->pipe->glctx = ctx; diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index bb019b5998..eea443c03c 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -178,15 +178,7 @@ _mesa_Clear( GLbitfield mask ) } ASSERT(ctx->Driver.Clear); -#if 0 ctx->Driver.Clear(ctx, bufferMask); -#else - st_clear(ctx->st, - (mask & GL_COLOR_BUFFER_BIT) ? GL_TRUE : GL_FALSE, - (bufferMask & BUFFER_BIT_DEPTH) ? GL_TRUE : GL_FALSE, - (bufferMask & BUFFER_BIT_STENCIL) ? GL_TRUE : GL_FALSE, - (bufferMask & BUFFER_BIT_ACCUM) ? GL_TRUE : GL_FALSE); -#endif } } diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c index a133b48891..09cc643003 100644 --- a/src/mesa/pipe/softpipe/sp_clear.c +++ b/src/mesa/pipe/softpipe/sp_clear.c @@ -60,53 +60,20 @@ color_value(GLuint format, const GLfloat color[4]) } } -static GLuint -color_mask(GLuint format, GLuint pipeMask) -{ - GLuint mask = 0x0; - switch (format) { - case PIPE_FORMAT_U_R8_G8_B8_A8: - if (pipeMask & PIPE_MASK_R) mask |= 0xff000000; - if (pipeMask & PIPE_MASK_G) mask |= 0x00ff0000; - if (pipeMask & PIPE_MASK_B) mask |= 0x0000ff00; - if (pipeMask & PIPE_MASK_A) mask |= 0x000000ff; - break; - case PIPE_FORMAT_U_A8_R8_G8_B8: - if (pipeMask & PIPE_MASK_R) mask |= 0x00ff0000; - if (pipeMask & PIPE_MASK_G) mask |= 0x0000ff00; - if (pipeMask & PIPE_MASK_B) mask |= 0x000000ff; - if (pipeMask & PIPE_MASK_A) mask |= 0xff000000; - break; - case PIPE_FORMAT_U_R5_G6_B5: - if (pipeMask & PIPE_MASK_R) mask |= 0xf800; - if (pipeMask & PIPE_MASK_G) mask |= 0x07e0; - if (pipeMask & PIPE_MASK_B) mask |= 0x001f; - if (pipeMask & PIPE_MASK_A) mask |= 0; - break; - default: - return 0; - } - return mask; -} - -/** - * XXX This should probaby be renamed to something like pipe_clear_with_blits() - * and moved into a device-independent pipe file. - */ void softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, GLboolean stencil, GLboolean accum) { - const struct softpipe_context *softpipe = softpipe_context(pipe); + struct softpipe_context *softpipe = softpipe_context(pipe); GLint x, y, w, h; - softpipe_update_derived(softpipe); + softpipe_update_derived(softpipe); /* not needed?? */ - x = softpipe->cliprect.minx; - y = softpipe->cliprect.miny; - w = softpipe->cliprect.maxx - x; - h = softpipe->cliprect.maxy - y; + x = 0; + y = 0; + w = softpipe->framebuffer.cbufs[0]->width; + h = softpipe->framebuffer.cbufs[0]->height; if (color) { GLuint i; @@ -114,8 +81,7 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, struct pipe_surface *ps = softpipe->framebuffer.cbufs[i]; GLuint clearVal = color_value(ps->format, softpipe->clear_color.color); - GLuint mask = color_mask(ps->format, softpipe->blend.colormask); - pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, mask); + pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, ~0); } } @@ -124,10 +90,13 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, /* clear Z and stencil together */ struct pipe_surface *ps = softpipe->framebuffer.zbuf; if (ps->format == PIPE_FORMAT_S8_Z24) { - GLuint mask = (softpipe->stencil.write_mask[0] << 8) | 0xffffff; + GLuint mask = (softpipe->stencil.write_mask[0] << 8) | 0xffffff; GLuint clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff); + + assert (mask == ~0); + clearVal |= (softpipe->stencil.clear_value << 24); - pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, mask); + pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, ~0); } else { /* XXX Z24_S8 format? */ @@ -138,33 +107,36 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, /* separate Z and stencil */ if (depth) { struct pipe_surface *ps = softpipe->framebuffer.zbuf; - GLuint mask, clearVal; + GLuint clearVal; switch (ps->format) { case PIPE_FORMAT_U_Z16: clearVal = (GLuint) (softpipe->depth_test.clear * 65535.0); - mask = 0xffff; break; case PIPE_FORMAT_U_Z32: clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffffff); - mask = 0xffffffff; break; case PIPE_FORMAT_S8_Z24: clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff); - mask = 0xffffff; break; default: assert(0); } - pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, mask); + pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, ~0); } if (stencil) { struct pipe_surface *ps = softpipe->framebuffer.sbuf; GLuint clearVal = softpipe->stencil.clear_value; + + /* If this is not ~0, we shouldn't get here - clear should be + * done with geometry instead. + */ GLuint mask = softpipe->stencil.write_mask[0]; + assert((mask & 0xff) == 0xff); + switch (ps->format) { case PIPE_FORMAT_S8_Z24: clearVal = clearVal << 24; @@ -187,7 +159,7 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, */ struct pipe_surface *ps = softpipe->framebuffer.abuf; GLuint clearVal = 0x0; /* XXX FIX */ - GLuint mask = !0; + GLuint mask = ~0; assert(ps); pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, mask); } diff --git a/src/mesa/sources b/src/mesa/sources index d9ee7266e5..d0fe3a979f 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -191,6 +191,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_stencil.c \ state_tracker/st_atom_stipple.c \ state_tracker/st_atom_viewport.c \ + state_tracker/st_cb_clear.c \ state_tracker/st_cb_program.c \ state_tracker/st_draw.c \ state_tracker/st_context.c \ diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c new file mode 100644 index 0000000000..d9cb83b8ad --- /dev/null +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -0,0 +1,89 @@ +/************************************************************************** + * + * Copyright 2003 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 + * Brian Paul + */ + +#include "st_context.h" +#include "glheader.h" +#include "macros.h" +#include "enums.h" +#include "st_context.h" +#include "st_atom.h" +#include "pipe/p_context.h" + + + +/* XXX: doesn't pick up the differences between front/back/left/right + * clears. Need to sort that out... + */ +static void st_clear(GLcontext *ctx, GLbitfield mask) +{ + struct st_context *st = ctx->st; + GLboolean color = (mask & BUFFER_BITS_COLOR) ? GL_TRUE : GL_FALSE; + GLboolean depth = (mask & BUFFER_BIT_DEPTH) ? GL_TRUE : GL_FALSE; + GLboolean stencil = (mask & BUFFER_BIT_STENCIL) ? GL_TRUE : GL_FALSE; + GLboolean accum = (mask & BUFFER_BIT_ACCUM) ? GL_TRUE : GL_FALSE; + GLboolean fullscreen = 1; /* :-) */ + + /* This makes sure the softpipe has the latest scissor, etc values */ + st_validate_state( st ); + + if (fullscreen) { + /* pipe->clear() should clear a particular surface, so that we + * can iterate over render buffers at this level and clear the + * ones GL is asking for. + * + * Will probably need something like pipe->clear_z_stencil() to + * cope with the special case of paired and unpaired z/stencil + * buffers, though could perhaps deal with them explicitly at + * this level. + */ + st->pipe->clear(st->pipe, color, depth, stencil, accum); + } + else { + /* Convert to geometry, etc: + */ + } +} + + +void st_init_cb_clear( struct st_context *st ) +{ + struct dd_function_table *functions = &st->ctx->Driver; + + functions->Clear = st_clear; +} + + +void st_destroy_cb_clear( struct st_context *st ) +{ +} + diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 6308e81a61..4d3f0ec4d3 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -58,6 +58,7 @@ struct st_context *st_create_context( GLcontext *ctx, st_init_atoms( st ); st_init_draw( st ); st_init_cb_program( st ); + st_init_cb_clear( st ); return st; } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index a424d1dd05..95fa43df4d 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -107,14 +107,3 @@ void st_destroy_draw( struct st_context *st ) } -/** XXX temporary here */ -void -st_clear(struct st_context *st, GLboolean color, GLboolean depth, - GLboolean stencil, GLboolean accum) -{ - /* This makes sure the softpipe has the latest scissor, etc values */ - st_validate_state( st ); - - st->pipe->clear(st->pipe, color, depth, stencil, accum); -} - -- cgit v1.2.3 From bff0411c5a1a9fdfff7f8a5128af4d496b89fa0d Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 15 Aug 2007 11:45:54 -0600 Subject: sketch out vbo drawing function --- src/mesa/state_tracker/st_draw.c | 58 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 95fa43df4d..002565a658 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -30,7 +30,9 @@ * Keith Whitwell */ -#include "imports.h" +#include "main/imports.h" + +#include "vbo/vbo.h" #include "tnl/t_context.h" #include "tnl/t_pipeline.h" @@ -38,7 +40,10 @@ #include "st_context.h" #include "st_atom.h" #include "st_draw.h" +#include "st_cb_bufferobjects.h" #include "pipe/p_context.h" +#include "pipe/p_defines.h" + /* * TNL stage which feeds into the above. @@ -88,6 +93,57 @@ static const struct tnl_pipeline_stage *st_pipeline[] = { 0, }; + + +/** + * This function gets plugged into the VBO module and is called when + * we have something to render. + * Basically, translate the information into the format expected by pipe. + */ +static void +draw_vbo(GLcontext *ctx, + const struct gl_client_array **arrays, + const struct _mesa_prim *prims, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLuint min_index, + GLuint max_index) +{ + struct pipe_context *pipe = ctx->st->pipe; + GLuint attr; + + /* tell pipe about the vertex array element/attributes */ + for (attr = 0; attr < 16; attr++) { + struct gl_buffer_object *bufobj = arrays[attr]->BufferObj; + if (bufobj && bufobj->Name) { + struct st_buffer_object *stobj = st_buffer_object(bufobj); + struct pipe_buffer_handle *buffer = stobj->buffer; + GLenum type = arrays[attr]->Type; + GLint size = arrays[attr]->Size; + struct pipe_vertex_buffer vbuffer; + struct pipe_vertex_element velement; + + vbuffer.pitch = 0; + vbuffer.max_index = 0; + vbuffer.buffer = NULL; + vbuffer.buffer_offset = 0; + + velement.src_offset = 0; + velement.vertex_buffer_index = attr; + velement.dst_offset = 0; + velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + + pipe->set_vertex_buffer(pipe, attr, &vbuffer); + pipe->set_vertex_element(pipe, attr, &velement); + } + } + + /* do actual drawing */ +} + + + + /* This is all a hack to keep using tnl until we have vertex programs * up and running. */ -- cgit v1.2.3 From 181cf1d52a9fe0ad8be9d48aa69775f575336d3d Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 15 Aug 2007 19:00:06 -0600 Subject: convert vbo->draw_prims() to pipe->draw_arrays(): works in very limited cases, disabled for now --- src/mesa/state_tracker/st_draw.c | 81 ++++++++++++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 12 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 002565a658..0b13432256 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -44,6 +44,15 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "vbo/vbo_context.h" + +/* + * Enabling this causes the VBO module to call draw_vbo() below, + * bypassing the T&L module. This only works with VBO-based demos, + * such as progs/test/bufferobj.c + */ +#define USE_NEW_DRAW 0 + /* * TNL stage which feeds into the above. @@ -95,6 +104,31 @@ static const struct tnl_pipeline_stage *st_pipeline[] = { +static GLuint +pipe_vertex_format(GLenum format, GLuint size) +{ + static const GLuint float_fmts[4] = { + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32G32_FLOAT, + PIPE_FORMAT_R32G32B32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT, + }; + + assert(format >= GL_BYTE); + assert(format <= GL_DOUBLE); + assert(size >= 1); + assert(size <= 4); + + switch (format) { + case GL_FLOAT: + return float_fmts[size - 1]; + default: + assert(0); + } +} + + + /** * This function gets plugged into the VBO module and is called when * we have something to render. @@ -110,35 +144,48 @@ draw_vbo(GLcontext *ctx, GLuint max_index) { struct pipe_context *pipe = ctx->st->pipe; - GLuint attr; + GLuint attr, i; /* tell pipe about the vertex array element/attributes */ for (attr = 0; attr < 16; attr++) { struct gl_buffer_object *bufobj = arrays[attr]->BufferObj; + struct pipe_vertex_buffer vbuffer; + struct pipe_vertex_element velement; + if (bufobj && bufobj->Name) { struct st_buffer_object *stobj = st_buffer_object(bufobj); - struct pipe_buffer_handle *buffer = stobj->buffer; - GLenum type = arrays[attr]->Type; - GLint size = arrays[attr]->Size; - struct pipe_vertex_buffer vbuffer; - struct pipe_vertex_element velement; - vbuffer.pitch = 0; + assert(stobj->buffer); + + vbuffer.pitch = arrays[attr]->StrideB; /* in bytes */ vbuffer.max_index = 0; - vbuffer.buffer = NULL; + vbuffer.buffer = stobj->buffer; vbuffer.buffer_offset = 0; - velement.src_offset = 0; + /* Recall that for VBOs, the gl_client_array->Ptr field is + * really an offset from the start of the VBO, not a pointer. + */ + velement.src_offset = (unsigned) arrays[attr]->Ptr; velement.vertex_buffer_index = attr; velement.dst_offset = 0; - velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velement.src_format = pipe_vertex_format(arrays[attr]->Type, + arrays[attr]->Size); + } + else { + /* vertex attribute data is not an a real buffer! */ + /* XXX we'll want to handle that someday... */ - pipe->set_vertex_buffer(pipe, attr, &vbuffer); - pipe->set_vertex_element(pipe, attr, &velement); + vbuffer.buffer = NULL; } + + pipe->set_vertex_buffer(pipe, attr, &vbuffer); + pipe->set_vertex_element(pipe, attr, &velement); } /* do actual drawing */ + for (i = 0; i < nr_prims; i++) { + pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count); + } } @@ -151,8 +198,18 @@ void st_init_draw( struct st_context *st ) { GLcontext *ctx = st->ctx; +#if USE_NEW_DRAW + struct vbo_context *vbo = (struct vbo_context *) ctx->swtnl_im; + + assert(vbo); + assert(vbo->draw_prims); + vbo->draw_prims = draw_vbo; + +#else _tnl_destroy_pipeline( ctx ); _tnl_install_pipeline( ctx, st_pipeline ); +#endif + } -- cgit v1.2.3 From e3bdd66bf69fb12fa02d161989755944077b280d Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 17:33:49 -0600 Subject: misc changes to support vertex shaders (disabled by default) --- src/mesa/pipe/softpipe/sp_context.c | 1 + src/mesa/state_tracker/st_atom_fs.c | 11 +++++++++-- src/mesa/state_tracker/st_context.c | 3 +++ src/mesa/state_tracker/st_draw.c | 13 +++++++++++-- 4 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 4c0dacd458..3f7044825a 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -269,6 +269,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.set_depth_state = softpipe_set_depth_test_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_sampler_state = softpipe_set_sampler_state; softpipe->pipe.set_scissor_state = softpipe_set_scissor_state; diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index 9731ab6cee..9dddb18498 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -134,6 +134,9 @@ static void update_vs( struct st_context *st ) struct st_vertex_program *vp = NULL; struct gl_program_parameter_list *params = NULL; + if (st->ctx->VertexProgram._MaintainTnlProgram) + _tnl_UpdateFixedFunctionProgram( st->ctx ); + if (st->ctx->Shader.CurrentProgram && st->ctx->Shader.CurrentProgram->LinkStatus && st->ctx->Shader.CurrentProgram->VertexProgram) { @@ -148,11 +151,15 @@ static void update_vs( struct st_context *st ) } /* XXXX temp */ +#if 1 if (!vp) return; - +#endif if (vp && params) { /* load program's constants array */ + + _mesa_load_state_parameters(st->ctx, params); + vp->constants.nr_constants = params->NumParameters; memcpy(vp->constants.constant, params->ParameterValues, @@ -179,7 +186,7 @@ static void update_vs( struct st_context *st ) const struct st_tracked_state st_update_vs = { .dirty = { - .mesa = _NEW_PROGRAM, + .mesa = _NEW_PROGRAM | _NEW_MODELVIEW, .st = ST_NEW_VERTEX_PROGRAM, }, .update = update_vs diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 2a85ce6baa..35a262ab5b 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -73,6 +73,9 @@ struct st_context *st_create_context( GLcontext *ctx, st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE; + st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; + + #if 0 st_init_cb_clear( st ); st_init_cb_program( st ); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 0b13432256..d66a0ed851 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -36,6 +36,7 @@ #include "tnl/t_context.h" #include "tnl/t_pipeline.h" +#include "tnl/t_vp_build.h" /* USE_NEW_DRAW */ #include "st_context.h" #include "st_atom.h" @@ -89,6 +90,9 @@ const struct tnl_pipeline_stage st_draw = { }; static const struct tnl_pipeline_stage *st_pipeline[] = { +#if USE_NEW_DRAW + &_tnl_vertex_program_stage, +#else &_tnl_vertex_transform_stage, &_tnl_vertex_cull_stage, &_tnl_normal_transform_stage, @@ -98,6 +102,7 @@ static const struct tnl_pipeline_stage *st_pipeline[] = { &_tnl_texture_transform_stage, &_tnl_point_attenuation_stage, &_tnl_vertex_program_stage, +#endif &st_draw, /* ADD: escape to pipe */ 0, }; @@ -146,6 +151,9 @@ draw_vbo(GLcontext *ctx, struct pipe_context *pipe = ctx->st->pipe; GLuint attr, i; + st_validate_state(ctx->st); + + /* tell pipe about the vertex array element/attributes */ for (attr = 0; attr < 16; attr++) { struct gl_buffer_object *bufobj = arrays[attr]->BufferObj; @@ -205,11 +213,12 @@ void st_init_draw( struct st_context *st ) assert(vbo->draw_prims); vbo->draw_prims = draw_vbo; -#else +#endif _tnl_destroy_pipeline( ctx ); _tnl_install_pipeline( ctx, st_pipeline ); -#endif + /* USE_NEW_DRAW */ + _tnl_ProgramCacheInit( ctx ); } -- cgit v1.2.3 From 3fc926f3740da9ec27853d158243055f3cb43d43 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 18:11:55 -0600 Subject: Remove many dependencies on mesa headers. To build with mesa, need -DMESA in makefile/config file. --- configs/linux | 3 +- configs/linux-dri-debug | 2 +- src/mesa/pipe/draw/draw_clip.c | 110 ++++++++++++++++++--------------- src/mesa/pipe/draw/draw_context.c | 17 +++-- src/mesa/pipe/draw/draw_context.h | 15 +++-- src/mesa/pipe/draw/draw_cull.c | 20 +++--- src/mesa/pipe/draw/draw_flatshade.c | 8 +-- src/mesa/pipe/draw/draw_offset.c | 39 ++++++------ src/mesa/pipe/draw/draw_prim.c | 11 ++-- src/mesa/pipe/draw/draw_private.h | 25 +++++++- src/mesa/pipe/draw/draw_twoside.c | 12 ++-- src/mesa/pipe/draw/draw_unfilled.c | 6 +- src/mesa/pipe/draw/draw_vb.c | 66 ++++++++++++-------- src/mesa/pipe/p_util.h | 12 ++++ src/mesa/pipe/softpipe/sp_context.c | 5 ++ src/mesa/pipe/softpipe/sp_prim_setup.c | 5 ++ src/mesa/state_tracker/st_draw.c | 2 +- 17 files changed, 218 insertions(+), 140 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/configs/linux b/configs/linux index 0d455ff46a..ed90fe4bc2 100644 --- a/configs/linux +++ b/configs/linux @@ -18,7 +18,8 @@ ARCH_FLAGS ?= DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \ -D_BSD_SOURCE -D_GNU_SOURCE \ - -DPTHREADS -DUSE_XSHM -DHAVE_POSIX_MEMALIGN + -DPTHREADS -DUSE_XSHM -DHAVE_POSIX_MEMALIGN \ + -DMESA X11_INCLUDES = -I/usr/X11R6/include diff --git a/configs/linux-dri-debug b/configs/linux-dri-debug index c3a458459d..a7ce255e00 100644 --- a/configs/linux-dri-debug +++ b/configs/linux-dri-debug @@ -5,7 +5,7 @@ include $(TOP)/configs/linux-dri CONFIG_NAME = linux-dri-debug OPT_FLAGS = -O0 -g -ARCH_FLAGS = -DDEBUG +ARCH_FLAGS = -DDEBUG -DMESA # Helpful to reduce the amount of stuff that gets built sometimes: #DRI_DIRS = i915tex i915 diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c index f8bacf8a81..53a7b10f7d 100644 --- a/src/mesa/pipe/draw/draw_clip.c +++ b/src/mesa/pipe/draw/draw_clip.c @@ -32,15 +32,27 @@ */ -#include "main/macros.h" +#include "pipe/p_util.h" #include "draw_private.h" +#ifndef IS_NEGATIVE +#define IS_NEGATIVE(X) ((X) < 0.0) +#endif + +#ifndef DIFFERENT_SIGNS +#define DIFFERENT_SIGNS(x, y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F) +#endif + +#ifndef MAX_CLIPPED_VERTICES +#define MAX_CLIPPED_VERTICES ((2 * (6 + PIPE_MAX_CLIP_PLANES))+1) +#endif + struct clipper { struct draw_stage stage; /**< base class */ - GLuint active_user_planes; - GLfloat (*plane)[4]; + unsigned active_user_planes; + float (*plane)[4]; }; @@ -57,10 +69,10 @@ static INLINE struct clipper *clipper_stage( struct draw_stage *stage ) /* All attributes are float[4], so this is easy: */ -static void interp_attr( GLfloat *fdst, - GLfloat t, - const GLfloat *fin, - const GLfloat *fout ) +static void interp_attr( float *fdst, + float t, + const float *fin, + const float *fout ) { fdst[0] = LINTERP( t, fout[0], fin[0] ); fdst[1] = LINTERP( t, fout[1], fin[1] ); @@ -75,12 +87,12 @@ static void interp_attr( GLfloat *fdst, */ static void interp( const struct clipper *clip, struct vertex_header *dst, - GLfloat t, + float t, const struct vertex_header *out, const struct vertex_header *in ) { - const GLuint nr_attrs = clip->stage.draw->nr_attrs; - GLuint j; + const unsigned nr_attrs = clip->stage.draw->nr_attrs; + unsigned j; /* Vertex header. */ @@ -99,10 +111,10 @@ static void interp( const struct clipper *clip, /* Do the projective divide and insert window coordinates: */ { - const GLfloat *pos = dst->clip; - const GLfloat *scale = clip->stage.draw->viewport.scale; - const GLfloat *trans = clip->stage.draw->viewport.translate; - const GLfloat oow = 1.0 / pos[3]; + const float *pos = dst->clip; + const float *scale = clip->stage.draw->viewport.scale; + const float *trans = clip->stage.draw->viewport.translate; + const float oow = 1.0 / pos[3]; dst->data[0][0] = pos[0] * oow * scale[0] + trans[0]; dst->data[0][1] = pos[1] * oow * scale[1] + trans[1]; @@ -128,10 +140,10 @@ static void interp( const struct clipper *clip, #define CLIP_CULL_BIT 0x80 -static INLINE GLfloat dot4( const GLfloat *a, - const GLfloat *b ) +static INLINE float dot4( const float *a, + const float *b ) { - GLfloat result = (a[0]*b[0] + + float result = (a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]); @@ -144,9 +156,9 @@ static INLINE GLfloat dot4( const GLfloat *a, static INLINE void do_tri( struct draw_stage *next, struct prim_header *header ) { - GLuint i; + unsigned i; for (i = 0; i < 3; i++) { - GLfloat *ndc = header->v[i]->data[0]; + float *ndc = header->v[i]->data[0]; _mesa_printf("ndc %f %f %f\n", ndc[0], ndc[1], ndc[2]); assert(ndc[0] >= -1 && ndc[0] <= 641); assert(ndc[1] >= 30 && ndc[1] <= 481); @@ -159,10 +171,10 @@ static INLINE void do_tri( struct draw_stage *next, static void emit_poly( struct draw_stage *stage, struct vertex_header **inlist, - GLuint n ) + unsigned n ) { struct prim_header header; - GLuint i; + unsigned i; for (i = 2; i < n; i++) { header.v[0] = inlist[0]; @@ -170,8 +182,8 @@ static void emit_poly( struct draw_stage *stage, header.v[2] = inlist[i]; { - GLuint tmp0 = header.v[0]->edgeflag; - GLuint tmp2 = header.v[2]->edgeflag; + unsigned tmp0 = header.v[0]->edgeflag; + unsigned tmp2 = header.v[2]->edgeflag; if (i != 2) header.v[0]->edgeflag = 0; if (i != n-1) header.v[2]->edgeflag = 0; @@ -188,7 +200,7 @@ static void emit_poly( struct draw_stage *stage, #if 0 static void emit_poly( struct draw_stage *stage ) { - GLuint i; + unsigned i; for (i = 2; i < n; i++) { header->v[0] = inlist[0]; @@ -206,16 +218,16 @@ static void emit_poly( struct draw_stage *stage ) static void do_clip_tri( struct draw_stage *stage, struct prim_header *header, - GLuint clipmask ) + unsigned clipmask ) { struct clipper *clipper = clipper_stage( stage ); struct vertex_header *a[MAX_CLIPPED_VERTICES]; struct vertex_header *b[MAX_CLIPPED_VERTICES]; struct vertex_header **inlist = a; struct vertex_header **outlist = b; - GLuint tmpnr = 0; - GLuint n = 3; - GLuint i; + unsigned tmpnr = 0; + unsigned n = 3; + unsigned i; inlist[0] = header->v[0]; inlist[1] = header->v[1]; @@ -231,11 +243,11 @@ do_clip_tri( struct draw_stage *stage, } while (clipmask && n >= 3) { - GLuint plane_idx = ffs(clipmask)-1; - const GLfloat *plane = clipper->plane[plane_idx]; + unsigned plane_idx = ffs(clipmask)-1; + const float *plane = clipper->plane[plane_idx]; struct vertex_header *vert_prev = inlist[0]; - GLfloat dp_prev = dot4( vert_prev->clip, plane ); - GLuint outcount = 0; + float dp_prev = dot4( vert_prev->clip, plane ); + unsigned outcount = 0; clipmask &= ~(1<clip, plane ); + float dp = dot4( vert->clip, plane ); if (!IS_NEGATIVE(dp_prev)) { outlist[outcount++] = vert_prev; @@ -258,7 +270,7 @@ do_clip_tri( struct draw_stage *stage, /* Going out of bounds. Avoid division by zero as we * know dp != dp_prev from DIFFERENT_SIGNS, above. */ - GLfloat t = dp / (dp - dp_prev); + float t = dp / (dp - dp_prev); interp( clipper, new_vert, t, vert, vert_prev ); /* Force edgeflag true in this case: @@ -267,7 +279,7 @@ do_clip_tri( struct draw_stage *stage, } else { /* Coming back in. */ - GLfloat t = dp_prev / (dp_prev - dp); + float t = dp_prev / (dp_prev - dp); interp( clipper, new_vert, t, vert_prev, vert ); /* Copy starting vert's edgeflag: @@ -300,15 +312,15 @@ do_clip_tri( struct draw_stage *stage, static void do_clip_line( struct draw_stage *stage, struct prim_header *header, - GLuint clipmask ) + unsigned clipmask ) { const struct clipper *clipper = clipper_stage( stage ); struct vertex_header *v0 = header->v[0]; struct vertex_header *v1 = header->v[1]; - const GLfloat *pos0 = v0->clip; - const GLfloat *pos1 = v1->clip; - GLfloat t0 = 0; - GLfloat t1 = 0; + const float *pos0 = v0->clip; + const float *pos1 = v1->clip; + float t0 = 0; + float t1 = 0; struct prim_header newprim; /* XXX: Note stupid hack to deal with tnl's 8-bit clipmask. Remove @@ -321,18 +333,18 @@ do_clip_line( struct draw_stage *stage, } while (clipmask) { - const GLuint plane_idx = ffs(clipmask)-1; - const GLfloat *plane = clipper->plane[plane_idx]; - const GLfloat dp0 = dot4( pos0, plane ); - const GLfloat dp1 = dot4( pos1, plane ); + const unsigned plane_idx = ffs(clipmask)-1; + const float *plane = clipper->plane[plane_idx]; + const float dp0 = dot4( pos0, plane ); + const float dp1 = dot4( pos1, plane ); if (dp1 < 0) { - GLfloat t = dp1 / (dp1 - dp0); + float t = dp1 / (dp1 - dp0); t1 = MAX2(t1, t); } if (dp0 < 0) { - GLfloat t = dp0 / (dp0 - dp1); + float t = dp0 / (dp0 - dp1); t0 = MAX2(t0, t); } @@ -365,7 +377,7 @@ do_clip_line( struct draw_stage *stage, static void clip_begin( struct draw_stage *stage ) { struct clipper *clipper = clipper_stage(stage); - GLuint nr = stage->draw->nr_planes; + unsigned nr = stage->draw->nr_planes; /* sanity checks. If these fail, review the clip/interp code! */ assert(stage->draw->nr_attrs >= 3); @@ -393,7 +405,7 @@ static void clip_line( struct draw_stage *stage, struct prim_header *header ) { - GLuint clipmask = (header->v[0]->clipmask | + unsigned clipmask = (header->v[0]->clipmask | header->v[1]->clipmask); if (clipmask == 0) { @@ -411,7 +423,7 @@ static void clip_tri( struct draw_stage *stage, struct prim_header *header ) { - GLuint clipmask = (header->v[0]->clipmask | + unsigned clipmask = (header->v[0]->clipmask | header->v[1]->clipmask | header->v[2]->clipmask); diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index f2ee6c52e0..7e6a95127a 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -30,13 +30,15 @@ * Keith Whitwell */ -#include "imports.h" -#include "macros.h" +#ifdef MESA +#include "main/macros.h" +#else +#include "pipe/p_util.h" +#endif #include "draw_context.h" #include "draw_private.h" - struct draw_context *draw_create( void ) { struct draw_context *draw = CALLOC_STRUCT( draw_context ); @@ -57,7 +59,9 @@ struct draw_context *draw_create( void ) ASSIGN_4V( draw->plane[5], 0, 0, -1, 1 ); /* mesa's a bit wonky */ draw->nr_planes = 6; +#ifdef MESA draw->vf = vf_create( GL_TRUE ); +#endif /* Statically allocate maximum sized vertices for the cache - could be cleverer... */ @@ -75,10 +79,13 @@ struct draw_context *draw_create( void ) void draw_destroy( struct draw_context *draw ) { - if (draw->header.storage) +#ifdef MESA + if (draw->header.storage) { ALIGN_FREE( draw->header.storage ); + } vf_destroy( draw->vf ); +#endif free( draw->vcache.vertex[0] ); /* Frees all the vertices. */ free( draw ); @@ -186,7 +193,9 @@ void draw_set_viewport_state( struct draw_context *draw, { draw->viewport = *viewport; /* struct copy */ +#ifdef MESA vf_set_vp_scale_translate( draw->vf, viewport->scale, viewport->translate ); +#endif /* Using tnl/ and vf/ modules is temporary while getting started. * Full pipe will have vertex shader, vertex fetch of its own. diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index beba9429c9..ac994d6419 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -38,7 +38,6 @@ #define DRAW_CONTEXT_H -#include "main/glheader.h" #include "pipe/p_state.h" @@ -64,13 +63,13 @@ void draw_set_setup_stage( struct draw_context *draw, struct draw_stage *stage ); void draw_set_vertex_attributes( struct draw_context *draw, - const GLuint *attrs, - GLuint nr_attrs ); + const unsigned *attrs, + unsigned nr_attrs ); /* XXX temporary */ void draw_set_vertex_attributes2( struct draw_context *draw, - const GLuint *attrs, - GLuint nr_attrs ); + const unsigned *attrs, + unsigned nr_attrs ); void draw_set_vertex_array_info(struct draw_context *draw, const struct pipe_vertex_buffer *buffers, @@ -81,9 +80,9 @@ void draw_vb(struct draw_context *draw, struct vertex_buffer *VB ); void draw_vertices(struct draw_context *draw, - GLuint mode, - GLuint numVertex, const GLfloat *verts, - GLuint numAttribs, const GLuint attribs[]); + unsigned mode, + unsigned numVertex, const float *verts, + unsigned numAttribs, const unsigned attribs[]); #endif /* DRAW_CONTEXT_H */ diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c index 48a7f5dab8..f3d56ad719 100644 --- a/src/mesa/pipe/draw/draw_cull.c +++ b/src/mesa/pipe/draw/draw_cull.c @@ -33,14 +33,14 @@ */ -#include "main/imports.h" +#include "pipe/p_util.h" #include "pipe/p_defines.h" #include "draw_private.h" struct cull_stage { struct draw_stage stage; - GLuint winding; /**< which winding(s) to cull (one of PIPE_WINDING_x) */ + unsigned winding; /**< which winding(s) to cull (one of PIPE_WINDING_x) */ }; @@ -64,15 +64,15 @@ static void cull_tri( struct draw_stage *stage, struct prim_header *header ) { /* Window coords: */ - const GLfloat *v0 = header->v[0]->data[0]; - const GLfloat *v1 = header->v[1]->data[0]; - const GLfloat *v2 = header->v[2]->data[0]; + const float *v0 = header->v[0]->data[0]; + const float *v1 = header->v[1]->data[0]; + const float *v2 = header->v[2]->data[0]; /* edge vectors e = v0 - v2, f = v1 - v2 */ - GLfloat ex = v0[0] - v2[0]; - GLfloat ey = v0[1] - v2[1]; - GLfloat fx = v1[0] - v2[0]; - GLfloat fy = v1[1] - v2[1]; + const float ex = v0[0] - v2[0]; + const float ey = v0[1] - v2[1]; + const float fx = v1[0] - v2[0]; + const float fy = v1[1] - v2[1]; /* det = cross(e,f).z */ header->det = ex * fy - ey * fx; @@ -81,7 +81,7 @@ static void cull_tri( struct draw_stage *stage, /* if (det < 0 then Z points toward camera and triangle is * counter-clockwise winding. */ - GLuint winding = (header->det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW; + unsigned winding = (header->det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW; if ((winding & cull_stage(stage)->winding) == 0) { /* triangle is not culled, pass to next stage */ diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c index cf5e762079..128acc5b2b 100644 --- a/src/mesa/pipe/draw/draw_flatshade.c +++ b/src/mesa/pipe/draw/draw_flatshade.c @@ -28,14 +28,14 @@ /* Authors: Keith Whitwell */ -#include "main/imports.h" +#include "pipe/p_util.h" #include "draw_private.h" struct flatshade_stage { struct draw_stage stage; - const GLuint *lookup; + const unsigned *lookup; }; @@ -53,7 +53,7 @@ static void flatshade_begin( struct draw_stage *stage ) -static INLINE void copy_attr( GLuint attr, +static INLINE void copy_attr( unsigned attr, struct vertex_header *dst, const struct vertex_header *src ) { @@ -70,7 +70,7 @@ static INLINE void copy_colors( struct draw_stage *stage, const struct vertex_header *src ) { const struct flatshade_stage *flatshade = flatshade_stage(stage); - const GLuint *lookup = flatshade->lookup; + const unsigned *lookup = flatshade->lookup; copy_attr( lookup[VF_ATTRIB_COLOR0], dst, src ); copy_attr( lookup[VF_ATTRIB_COLOR1], dst, src ); diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c index 9f66566353..9b00b09032 100644 --- a/src/mesa/pipe/draw/draw_offset.c +++ b/src/mesa/pipe/draw/draw_offset.c @@ -32,8 +32,7 @@ * \author Brian Paul */ -#include "main/imports.h" -#include "main/macros.h" +#include "pipe/p_util.h" #include "draw_private.h" @@ -41,8 +40,8 @@ struct offset_stage { struct draw_stage stage; - GLfloat scale; - GLfloat units; + float scale; + float units; }; @@ -56,7 +55,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); - GLfloat mrd = 1.0 / 65535.0; /* XXX this depends on depthbuffer bits! */ + float mrd = 1.0 / 65535.0; /* XXX this depends on depthbuffer bits! */ offset->units = stage->draw->setup.offset_units * mrd; offset->scale = stage->draw->setup.offset_scale; @@ -73,30 +72,30 @@ static void do_offset_tri( struct draw_stage *stage, struct prim_header *header ) { struct offset_stage *offset = offset_stage(stage); - GLfloat inv_det = 1.0 / header->det; + float inv_det = 1.0 / header->det; /* Window coords: */ - GLfloat *v0 = header->v[0]->data[0]; - GLfloat *v1 = header->v[1]->data[0]; - GLfloat *v2 = header->v[2]->data[0]; + float *v0 = header->v[0]->data[0]; + float *v1 = header->v[1]->data[0]; + float *v2 = header->v[2]->data[0]; /* edge vectors e = v0 - v2, f = v1 - v2 */ - GLfloat ex = v0[0] - v2[0]; - GLfloat ey = v0[1] - v2[1]; - GLfloat ez = v0[2] - v2[2]; - GLfloat fx = v1[0] - v2[0]; - GLfloat fy = v1[1] - v2[1]; - GLfloat fz = v1[2] - v2[2]; + float ex = v0[0] - v2[0]; + float ey = v0[1] - v2[1]; + float ez = v0[2] - v2[2]; + float fx = v1[0] - v2[0]; + float fy = v1[1] - v2[1]; + float fz = v1[2] - v2[2]; /* (a,b) = cross(e,f).xy */ - GLfloat a = ey*fz - ez*fy; - GLfloat b = ez*fx - ex*fz; + float a = ey*fz - ez*fy; + float b = ez*fx - ex*fz; - GLfloat dzdx = FABSF(a * inv_det); - GLfloat dzdy = FABSF(b * inv_det); + float dzdx = FABSF(a * inv_det); + float dzdy = FABSF(b * inv_det); - GLfloat zoffset = offset->units + MAX2(dzdx, dzdy) * offset->scale; + float zoffset = offset->units + MAX2(dzdx, dzdy) * offset->scale; /* * Note: we're applying the offset and clamping per-vertex. diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c index 931404caff..7757dacf34 100644 --- a/src/mesa/pipe/draw/draw_prim.c +++ b/src/mesa/pipe/draw/draw_prim.c @@ -30,6 +30,7 @@ * Keith Whitwell */ +#include "pipe/p_util.h" #include "draw_private.h" #include "draw_context.h" #include "draw_prim.h" @@ -173,7 +174,7 @@ static struct vertex_header *get_uint_elt_vertex( struct draw_context *draw, static struct vertex_header *get_ushort_elt_vertex( struct draw_context *draw, unsigned i ) { - const GLushort *elts = (const GLushort *)draw->elts; + const ushort *elts = (const ushort *)draw->elts; return get_vertex( draw, elts[i] ); } @@ -181,7 +182,7 @@ static struct vertex_header *get_ushort_elt_vertex( struct draw_context *draw, static struct vertex_header *get_ubyte_elt_vertex( struct draw_context *draw, unsigned i ) { - const GLubyte *elts = (const GLubyte *)draw->elts; + const ubyte *elts = (const ubyte *)draw->elts; return get_vertex( draw, elts[i] ); } @@ -522,13 +523,13 @@ draw_trim( unsigned count, unsigned first, unsigned incr ) /** * Allocate space for temporary post-transform vertices, such as for clipping. */ -void draw_alloc_tmps( struct draw_stage *stage, GLuint nr ) +void draw_alloc_tmps( struct draw_stage *stage, unsigned nr ) { stage->nr_tmps = nr; if (nr) { - GLubyte *store = (GLubyte *) malloc(MAX_VERTEX_SIZE * nr); - GLuint i; + ubyte *store = (ubyte *) malloc(MAX_VERTEX_SIZE * nr); + unsigned i; stage->tmp = (struct vertex_header **) malloc(sizeof(struct vertex_header *) * nr); diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index b6ef32855a..2748772fdb 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -41,10 +41,31 @@ #define DRAW_PRIVATE_H -#include "main/glheader.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" +#ifdef MESA #include "vf/vf.h" +#else +/* XXX these are temporary */ +struct vf_attr_map { + unsigned attrib; + unsigned format; + unsigned offset; +}; +#define VF_ATTRIB_POS 0 +#define VF_ATTRIB_COLOR0 3 +#define VF_ATTRIB_COLOR1 4 +#define VF_ATTRIB_BFC0 25 +#define VF_ATTRIB_BFC1 26 + +#define VF_ATTRIB_CLIP_POS 27 +#define VF_ATTRIB_VERTEX_HEADER 28 +#define VF_ATTRIB_MAX 29 +#define EMIT_1F 0 +#define EMIT_4F 3 +#define EMIT_4F_VIEWPORT 6 +#define FRAG_ATTRIB_MAX 13 +#endif /** @@ -201,7 +222,9 @@ struct draw_context /* Misc for draw_vb.c (XXX temporary) */ +#ifdef MESA GLvector4f header; +#endif ubyte *verts; boolean in_vb; struct vertex_fetch *vf; diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c index 20b2b4a8aa..045109dae0 100644 --- a/src/mesa/pipe/draw/draw_twoside.c +++ b/src/mesa/pipe/draw/draw_twoside.c @@ -28,15 +28,15 @@ /* Authors: Keith Whitwell */ -#include "main/imports.h" +#include "pipe/p_util.h" #include "pipe/p_defines.h" #include "draw_private.h" struct twoside_stage { struct draw_stage stage; - GLfloat sign; /**< +1 or -1 */ - const GLuint *lookup; + float sign; /**< +1 or -1 */ + const unsigned *lookup; }; @@ -61,8 +61,8 @@ static void twoside_begin( struct draw_stage *stage ) } -static INLINE void copy_color( GLuint attr_dst, - GLuint attr_src, +static INLINE void copy_color( unsigned attr_dst, + unsigned attr_src, struct vertex_header *v ) { if (attr_dst && attr_src) { @@ -75,7 +75,7 @@ static INLINE void copy_color( GLuint attr_dst, static struct vertex_header *copy_bfc( struct twoside_stage *twoside, const struct vertex_header *v, - GLuint idx ) + unsigned idx ) { struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx ); diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c index e0e486ebe6..4215b8b228 100644 --- a/src/mesa/pipe/draw/draw_unfilled.c +++ b/src/mesa/pipe/draw/draw_unfilled.c @@ -33,7 +33,7 @@ /* Authors: Keith Whitwell */ -#include "main/imports.h" +#include "pipe/p_util.h" #include "pipe/p_defines.h" #include "draw_private.h" @@ -45,7 +45,7 @@ struct unfilled_stage { * legal values: PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE, * and PIPE_POLYGON_MODE_POINT, */ - GLuint mode[2]; + unsigned mode[2]; }; @@ -119,7 +119,7 @@ static void unfilled_tri( struct draw_stage *stage, struct prim_header *header ) { struct unfilled_stage *unfilled = unfilled_stage(stage); - GLuint mode = unfilled->mode[header->det < 0.0]; + unsigned mode = unfilled->mode[header->det < 0.0]; switch (mode) { case PIPE_POLYGON_MODE_FILL: diff --git a/src/mesa/pipe/draw/draw_vb.c b/src/mesa/pipe/draw/draw_vb.c index db7b217c2f..18e48c0a68 100644 --- a/src/mesa/pipe/draw/draw_vb.c +++ b/src/mesa/pipe/draw/draw_vb.c @@ -30,11 +30,17 @@ * Keith Whitwell */ -#include "imports.h" -#include "macros.h" - +#ifdef MESA +#include "main/imports.h" +#include "main/macros.h" #include "tnl/t_context.h" #include "vf/vf.h" +#else +#define VF_ +#include "pipe/p_util.h" + +#endif /*MESA*/ + #include "draw_private.h" #include "draw_context.h" @@ -92,11 +98,11 @@ static void vs_flush( struct draw_context *draw ) * Allocate storage for post-transformation vertices. */ static void -draw_allocate_vertices( struct draw_context *draw, GLuint nr_vertices ) +draw_allocate_vertices( struct draw_context *draw, unsigned nr_vertices ) { assert(draw->vertex_size > 0); draw->nr_vertices = nr_vertices; - draw->verts = (GLubyte *) malloc( nr_vertices * draw->vertex_size ); + draw->verts = (ubyte *) malloc( nr_vertices * draw->vertex_size ); draw_invalidate_vcache( draw ); } @@ -117,20 +123,21 @@ draw_release_vertices( struct draw_context *draw ) * Note: this must match struct vertex_header's layout (I think). */ struct header_dword { - GLuint clipmask:12; - GLuint edgeflag:1; - GLuint pad:19; + unsigned clipmask:12; + unsigned edgeflag:1; + unsigned pad:19; }; +#ifdef MESA static void build_vertex_headers( struct draw_context *draw, struct vertex_buffer *VB ) { if (draw->header.storage == NULL) { - draw->header.stride = sizeof(GLfloat); + draw->header.stride = sizeof(float); draw->header.size = 1; - draw->header.storage = ALIGN_MALLOC( VB->Size * sizeof(GLfloat), 32 ); + draw->header.storage = ALIGN_MALLOC( VB->Size * sizeof(float), 32 ); draw->header.data = draw->header.storage; draw->header.count = 0; draw->header.flags = VEC_SIZE_1 | VEC_MALLOC; @@ -141,12 +148,12 @@ build_vertex_headers( struct draw_context *draw, */ { - GLuint i; + unsigned i; struct header_dword *header = (struct header_dword *)draw->header.storage; /* yes its a hack */ - assert(sizeof(*header) == sizeof(GLfloat)); + assert(sizeof(*header) == sizeof(float)); draw->header.count = VB->Count; @@ -175,16 +182,18 @@ build_vertex_headers( struct draw_context *draw, VB->AttribPtr[VF_ATTRIB_VERTEX_HEADER] = &draw->header; } +#endif /*MESA*/ +#ifdef MESA /** * This is a hack & will all go away. */ void draw_vb(struct draw_context *draw, struct vertex_buffer *VB ) { - GLuint i; + unsigned i; VB->AttribPtr[VF_ATTRIB_POS] = VB->NdcPtr; VB->AttribPtr[VF_ATTRIB_BFC0] = VB->ColorPtr[1]; @@ -212,14 +221,14 @@ void draw_vb(struct draw_context *draw, vf_emit_vertices( draw->vf, VB->Count, draw->verts ); if (VB->Elts) - draw_set_element_buffer(draw, sizeof(GLuint), VB->Elts); + draw_set_element_buffer(draw, sizeof(unsigned), VB->Elts); else draw_set_element_buffer(draw, 0, NULL); for (i = 0; i < VB->PrimitiveCount; i++) { const GLenum mode = VB->Primitive[i].mode; - const GLuint start = VB->Primitive[i].start; - GLuint length, first, incr; + const unsigned start = VB->Primitive[i].start; + unsigned length, first, incr; /* Trim the primitive down to a legal size. */ @@ -247,27 +256,28 @@ void draw_vb(struct draw_context *draw, draw->in_vb = 0; draw->elts = NULL; } +#endif /*MESA*/ /** * XXX Temporary mechanism to draw simple vertex arrays. - * All attribs are GLfloat[4]. Arrays are interleaved, in GL-speak. + * All attribs are float[4]. Arrays are interleaved, in GL-speak. */ void draw_vertices(struct draw_context *draw, - GLuint mode, - GLuint numVerts, const GLfloat *vertices, - GLuint numAttrs, const GLuint attribs[]) + unsigned mode, + unsigned numVerts, const float *vertices, + unsigned numAttrs, const unsigned attribs[]) { - /*GLuint first, incr;*/ - GLuint i, j; + /*unsigned first, incr;*/ + unsigned i, j; - assert(mode <= GL_POLYGON); + assert(mode <= PIPE_PRIM_POLYGON); draw->vs_flush = vs_flush; draw->vertex_size - = sizeof(struct vertex_header) + numAttrs * 4 * sizeof(GLfloat); + = sizeof(struct vertex_header) + numAttrs * 4 * sizeof(float); /* no element/index buffer */ @@ -344,10 +354,10 @@ do { \ * (and number of attributes) */ void draw_set_vertex_attributes( struct draw_context *draw, - const GLuint *slot_to_vf_attr, - GLuint nr_attrs ) + const unsigned *slot_to_vf_attr, + unsigned nr_attrs ) { - GLuint i; + unsigned i; memset(draw->vf_attr_to_slot, 0, sizeof(draw->vf_attr_to_slot)); draw->nr_attrs = 0; @@ -368,6 +378,8 @@ void draw_set_vertex_attributes( struct draw_context *draw, EMIT_ATTR(slot_to_vf_attr[i], EMIT_4F); /* tell the vertex format module how to construct vertices for us */ +#if MESA draw->vertex_size = vf_set_vertex_attributes( draw->vf, draw->attrs, draw->nr_attrs, 0 ); +#endif } diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h index 072dad0573..f4af16a2de 100755 --- a/src/mesa/pipe/p_util.h +++ b/src/mesa/pipe/p_util.h @@ -112,6 +112,18 @@ do { \ } while (0) +#define COPY_4FV( DST, SRC ) COPY_4V(DST, SRC) + + +#define ASSIGN_4V( DST, V0, V1, V2, V3 ) \ +do { \ + (DST)[0] = (V0); \ + (DST)[1] = (V1); \ + (DST)[2] = (V2); \ + (DST)[3] = (V3); \ +} while (0) + + static INLINE int ifloor(float f) { int ai, bi; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 3f7044825a..e63ce208d4 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -80,6 +80,11 @@ softpipe_supported_formats(struct pipe_context *pipe, unsigned *numFormats) } +/** XXX remove these? */ +#define MAX_TEXTURE_LEVELS 11 +#define MAX_TEXTURE_RECT_SIZE 2048 +#define MAX_3D_TEXTURE_LEVELS 8 + static void softpipe_max_texture_size(struct pipe_context *pipe, unsigned textureType, unsigned *maxWidth, unsigned *maxHeight, diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 9b91628aaf..21c1032b13 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -40,6 +40,11 @@ #include "pipe/draw/draw_private.h" #include "pipe/p_util.h" +#ifndef MESA +#define FRAG_ATTRIB_WPOS 0 +#define FRAG_ATTRIB_MAX 13 +#endif + /** * Triangle edge info diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index d66a0ed851..425076d653 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -74,7 +74,7 @@ static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage ) /* Call into the new draw code to handle the VB: */ st->pipe->draw_vb( st->pipe, VB ); - + /* Finished */ return GL_FALSE; -- cgit v1.2.3 From 1f026d98dd77b6d26cc76946d92f69a9e6091b8e Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 18 Aug 2007 16:05:49 +0100 Subject: Create a default vertex attribute buffer which mirrors ctx->Current.Attrrib[] Used when the vertex shader references attributes which aren't present in VBOs. --- src/mesa/state_tracker/st_context.h | 2 + src/mesa/state_tracker/st_draw.c | 113 +++++++++++++++++++++++++++--------- 2 files changed, 88 insertions(+), 27 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 25ed20a5f8..35774a790e 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -104,6 +104,8 @@ struct st_context struct st_state_flags dirty; GLfloat polygon_offset_scale; /* ?? */ + + struct pipe_buffer_handle *default_attrib_buffer; }; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 425076d653..db24b24fa7 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -44,6 +44,7 @@ #include "st_cb_bufferobjects.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "pipe/p_winsys.h" #include "vbo/vbo_context.h" @@ -52,7 +53,7 @@ * bypassing the T&L module. This only works with VBO-based demos, * such as progs/test/bufferobj.c */ -#define USE_NEW_DRAW 0 +#define USE_NEW_DRAW 01 /* @@ -134,6 +135,38 @@ pipe_vertex_format(GLenum format, GLuint size) +/** + * The default attribute buffer is basically a copy of the + * ctx->Current.Attrib[] array. It's used when the vertex program + * references an attribute for which we don't have a VBO/array. + */ +static void +create_default_attribs_buffer(struct st_context *st) +{ + struct pipe_context *pipe = st->pipe; + st->default_attrib_buffer = pipe->winsys->buffer_create( pipe->winsys, 32 ); +} + + +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); +} + + +static void +update_default_attribs_buffer(GLcontext *ctx) +{ + struct pipe_context *pipe = ctx->st->pipe; + struct pipe_buffer_handle *buf = ctx->st->default_attrib_buffer; + const unsigned size = sizeof(ctx->Current.Attrib); + const void *data = ctx->Current.Attrib; + pipe->winsys->buffer_data(pipe->winsys, buf, size, data); +} + + /** * This function gets plugged into the VBO module and is called when * we have something to render. @@ -150,41 +183,66 @@ draw_vbo(GLcontext *ctx, { struct pipe_context *pipe = ctx->st->pipe; GLuint attr, i; + GLbitfield attrsNeeded; + const unsigned attr0_offset = (unsigned) arrays[0]->Ptr; st_validate_state(ctx->st); + update_default_attribs_buffer(ctx); + /* this must be after state validation */ + attrsNeeded = ctx->st->state.vs.inputs_read; /* tell pipe about the vertex array element/attributes */ for (attr = 0; attr < 16; attr++) { - struct gl_buffer_object *bufobj = arrays[attr]->BufferObj; struct pipe_vertex_buffer vbuffer; struct pipe_vertex_element velement; - if (bufobj && bufobj->Name) { - struct st_buffer_object *stobj = st_buffer_object(bufobj); - - assert(stobj->buffer); - - vbuffer.pitch = arrays[attr]->StrideB; /* in bytes */ - vbuffer.max_index = 0; - vbuffer.buffer = stobj->buffer; - vbuffer.buffer_offset = 0; - - /* Recall that for VBOs, the gl_client_array->Ptr field is - * really an offset from the start of the VBO, not a pointer. - */ - velement.src_offset = (unsigned) arrays[attr]->Ptr; - velement.vertex_buffer_index = attr; - velement.dst_offset = 0; - velement.src_format = pipe_vertex_format(arrays[attr]->Type, - arrays[attr]->Size); + vbuffer.buffer = NULL; + vbuffer.pitch = 0; + velement.src_offset = 0; + velement.vertex_buffer_index = 0; + velement.src_format = 0; + + if (attrsNeeded & (1 << attr)) { + struct gl_buffer_object *bufobj = arrays[attr]->BufferObj; + + if (bufobj && bufobj->Name) { + struct st_buffer_object *stobj = st_buffer_object(bufobj); + /* Recall that for VBOs, the gl_client_array->Ptr field is + * really an offset from the start of the VBO, not a pointer. + */ + unsigned offset = (unsigned) arrays[attr]->Ptr; + + assert(stobj->buffer); + + vbuffer.buffer = stobj->buffer; + vbuffer.buffer_offset = attr0_offset; /* in bytes */ + vbuffer.pitch = arrays[attr]->StrideB; /* in bytes */ + vbuffer.max_index = 0; /* need this? */ + + velement.src_offset = offset - attr0_offset; /* bytes */ + velement.vertex_buffer_index = attr; + velement.dst_offset = 0; /* need this? */ + velement.src_format = pipe_vertex_format(arrays[attr]->Type, + arrays[attr]->Size); + assert(velement.src_format); + } + else { + /* use the default attribute buffer */ + vbuffer.buffer = ctx->st->default_attrib_buffer; + vbuffer.buffer_offset = 0; + vbuffer.pitch = 0; /* must be zero! */ + vbuffer.max_index = 1; + + velement.src_offset = attr * 4 * sizeof(GLfloat); + velement.vertex_buffer_index = attr; + velement.dst_offset = 0; + velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + } } - else { - /* vertex attribute data is not an a real buffer! */ - /* XXX we'll want to handle that someday... */ - vbuffer.buffer = NULL; - } + if (attr == 0) + assert(vbuffer.buffer); pipe->set_vertex_buffer(pipe, attr, &vbuffer); pipe->set_vertex_element(pipe, attr, &velement); @@ -209,6 +267,8 @@ void st_init_draw( struct st_context *st ) #if USE_NEW_DRAW struct vbo_context *vbo = (struct vbo_context *) ctx->swtnl_im; + create_default_attribs_buffer(st); + assert(vbo); assert(vbo->draw_prims); vbo->draw_prims = draw_vbo; @@ -224,8 +284,7 @@ void st_init_draw( struct st_context *st ) void st_destroy_draw( struct st_context *st ) { - /* Nothing to do. - */ + destroy_default_attribs_buffer(st); } -- cgit v1.2.3 From a83b72a67263faf21bf16ff879c9718660684aed Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 20 Aug 2007 12:52:33 -0600 Subject: implement DrawElements, still some rough spots --- src/mesa/state_tracker/st_draw.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index db24b24fa7..e82f7cff2b 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -249,8 +249,41 @@ draw_vbo(GLcontext *ctx, } /* do actual drawing */ - for (i = 0; i < nr_prims; i++) { - pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count); + if (ib) { + /* indexed primitive */ + struct gl_buffer_object *bufobj = ib->obj; + struct pipe_buffer_handle *bh = NULL; + unsigned indexSize; + + if (bufobj && bufobj->Name) { + /* elements/indexes are in a real VBO */ + struct st_buffer_object *stobj = st_buffer_object(bufobj); + bh = stobj->buffer; + switch (ib->type) { + case GL_UNSIGNED_INT: + indexSize = 4; + break; + case GL_UNSIGNED_SHORT: + indexSize = 2; + break; + default: + assert(0); + } + } + else { + assert(0); + } + + for (i = 0; i < nr_prims; i++) { + pipe->draw_elements(pipe, bh, indexSize, + prims[i].mode, prims[i].start, prims[i].count); + } + } + else { + /* non-indexed */ + for (i = 0; i < nr_prims; i++) { + pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count); + } } } -- cgit v1.2.3 From 51da8ee85eccf0df3721cbd863cd174382d1ddfd Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 20 Aug 2007 16:21:08 -0600 Subject: Start to remove the temporary draw_vb() and draw_vertices() code. new st_draw_vertices() utility used by glClear and glDrawPixels --- src/mesa/pipe/draw/draw_arrays.c | 7 +-- src/mesa/pipe/draw/draw_vb.c | 66 ---------------------------- src/mesa/pipe/i915simple/i915_context.c | 5 ++- src/mesa/pipe/softpipe/sp_context.c | 6 +++ src/mesa/sources | 3 +- src/mesa/state_tracker/st_cb_clear.c | 29 +++++++++++-- src/mesa/state_tracker/st_cb_drawpixels.c | 12 +++--- src/mesa/state_tracker/st_draw.c | 72 +++++++++++++++++++++++++++++++ src/mesa/state_tracker/st_draw.h | 12 ++++-- 9 files changed, 126 insertions(+), 86 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_arrays.c b/src/mesa/pipe/draw/draw_arrays.c index 59098fe242..fe9ec44425 100644 --- a/src/mesa/pipe/draw/draw_arrays.c +++ b/src/mesa/pipe/draw/draw_arrays.c @@ -170,11 +170,12 @@ run_vertex_program(struct draw_context *draw, unsigned attr; for (attr = 0; attr < 16; attr++) { if (draw->vertex_shader.inputs_read & (1 << attr)) { + unsigned buf = draw->vertex_element[attr].vertex_buffer_index; const void *src - = (const void *) ((const ubyte *) draw->mapped_vbuffer[attr] - + draw->vertex_buffer[attr].buffer_offset + = (const void *) ((const ubyte *) draw->mapped_vbuffer[buf] + + draw->vertex_buffer[buf].buffer_offset + draw->vertex_element[attr].src_offset - + elts[j] * draw->vertex_buffer[attr].pitch); + + elts[j] * draw->vertex_buffer[buf].pitch); float p[4]; fetch_attrib4(src, draw->vertex_element[attr].src_format, p); diff --git a/src/mesa/pipe/draw/draw_vb.c b/src/mesa/pipe/draw/draw_vb.c index 0eefb0b250..f83f8b8a0e 100644 --- a/src/mesa/pipe/draw/draw_vb.c +++ b/src/mesa/pipe/draw/draw_vb.c @@ -259,72 +259,6 @@ void draw_vb(struct draw_context *draw, #endif /*MESA*/ -/** - * XXX Temporary mechanism to draw simple vertex arrays. - * All attribs are float[4]. Arrays are interleaved, in GL-speak. - */ -void -draw_vertices(struct draw_context *draw, - unsigned mode, - unsigned numVerts, const float *vertices, - unsigned numAttrs, const unsigned attribs[]) -{ - /*unsigned first, incr;*/ - unsigned i, j; - - assert(mode <= PIPE_PRIM_POLYGON); - - draw->vs_flush = vs_flush; - - draw->vertex_size - = sizeof(struct vertex_header) + numAttrs * 4 * sizeof(float); - - - /* no element/index buffer */ - draw_set_mapped_element_buffer(draw, 0, NULL); - - /*draw_prim_info(mode, &first, &incr);*/ - draw_allocate_vertices( draw, numVerts ); - draw->pipeline.first->begin( draw->pipeline.first ); - - if (draw->prim != mode) - draw_set_prim( draw, mode ); - - /* setup attr info */ - draw->nr_attrs = numAttrs + 2; - draw->attrs[0].attrib = VF_ATTRIB_VERTEX_HEADER; - draw->attrs[0].format = EMIT_1F; - draw->attrs[1].attrib = VF_ATTRIB_CLIP_POS; - draw->attrs[1].format = EMIT_4F; - for (j = 0; j < numAttrs; j++) { - draw->vf_attr_to_slot[attribs[j]] = 2+j; - draw->attrs[2+j].attrib = attribs[j]; - draw->attrs[2+j].format = EMIT_4F; - } - - /* build vertices */ - for (i = 0; i < numVerts; i++) { - struct vertex_header *v - = (struct vertex_header *) (draw->verts + i * draw->vertex_size); - v->clipmask = 0x0; - v->edgeflag = 0; - for (j = 0; j < numAttrs; j++) { - COPY_4FV(v->data[j], vertices + (i * numAttrs + j) * 4); - } - } - - /* draw */ - draw_prim(draw, 0, numVerts); - draw_flush(draw); - draw->pipeline.first->end( draw->pipeline.first ); - - - /* clean up */ - draw_release_vertices( draw ); - draw->verts = NULL; - draw->in_vb = 0; -} - #if 000 /** diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index 8a8582e0b2..c7d469583c 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -155,7 +155,9 @@ static void i915_draw_vb( struct pipe_context *pipe, if (i915->dirty) i915_update_derived( i915 ); +#if 0 draw_vb( i915->draw, VB ); +#endif } @@ -169,8 +171,9 @@ i915_draw_vertices(struct pipe_context *pipe, if (i915->dirty) i915_update_derived( i915 ); - +#if 0 draw_vertices(i915->draw, mode, numVertex, verts, numAttribs, attribs); +#endif } diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index e7694bbe86..91ede05c05 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -195,6 +195,7 @@ static void softpipe_destroy( struct pipe_context *pipe ) } +#if 0 static void softpipe_draw_vb( struct pipe_context *pipe, struct vertex_buffer *VB ) { @@ -208,6 +209,7 @@ static void softpipe_draw_vb( struct pipe_context *pipe, draw_vb( softpipe->draw, VB ); softpipe_unmap_surfaces(softpipe); } +#endif static void @@ -223,7 +225,9 @@ softpipe_draw_vertices(struct pipe_context *pipe, /* XXX move mapping/unmapping to higher/coarser level? */ softpipe_map_surfaces(softpipe); +#if 0 draw_vertices(softpipe->draw, mode, numVertex, verts, numAttribs, attribs); +#endif softpipe_unmap_surfaces(softpipe); } @@ -285,8 +289,10 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.set_vertex_buffer = softpipe_set_vertex_buffer; softpipe->pipe.set_vertex_element = softpipe_set_vertex_element; +#if 0 softpipe->pipe.draw_vb = softpipe_draw_vb; softpipe->pipe.draw_vertices = softpipe_draw_vertices; +#endif softpipe->pipe.draw_arrays = softpipe_draw_arrays; softpipe->pipe.draw_elements = softpipe_draw_elements; diff --git a/src/mesa/sources b/src/mesa/sources index 0731e64d8a..0fe97e0287 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -164,8 +164,7 @@ DRAW_SOURCES = \ pipe/draw/draw_offset.c \ pipe/draw/draw_prim.c \ pipe/draw/draw_twoside.c \ - pipe/draw/draw_unfilled.c \ - pipe/draw/draw_vb.c + pipe/draw/draw_unfilled.c TGSICORE_SOURCES = \ pipe/tgsi/core/tgsi_build.c \ diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index f6c65ff466..bd050ca2cd 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -38,11 +38,17 @@ #include "st_context.h" #include "st_cb_clear.h" #include "st_cb_fbo.h" +#include "st_draw.h" #include "st_program.h" #include "st_public.h" + #include "pipe/p_context.h" +#include "pipe/p_state.h" #include "pipe/p_defines.h" +#include "pipe/p_winsys.h" + #include "pipe/tgsi/mesa/mesa_to_tgsi.h" + #include "vf/vf.h" @@ -215,8 +221,8 @@ draw_quad(GLcontext *ctx, const GLfloat color[4]) { static const GLuint attribs[2] = { - VF_ATTRIB_POS, - VF_ATTRIB_COLOR0 + 0, /* pos */ + 3 /* color */ }; GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */ GLuint i; @@ -244,8 +250,7 @@ draw_quad(GLcontext *ctx, verts[i][1][3] = color[3]; } - ctx->st->pipe->draw_vertices(ctx->st->pipe, PIPE_PRIM_QUADS, - 4, (GLfloat *) verts, 2, attribs); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, attribs); } @@ -343,6 +348,21 @@ clear_with_quad(GLcontext *ctx, st->pipe->set_fs_state(st->pipe, &fs); } + /* vertex shader state: color/position pass-through */ + { + static struct st_vertex_program *stvp = NULL; + struct pipe_shader_state vs; + if (!stvp) { + stvp = make_vertex_shader(st); + } + memset(&vs, 0, sizeof(vs)); + vs.inputs_read = stvp->Base.Base.InputsRead; + vs.outputs_written = stvp->Base.Base.OutputsWritten; + vs.tokens = &stvp->tokens[0]; + vs.constants = NULL; + st->pipe->set_vs_state(st->pipe, &vs); + } + /* draw quad matching scissor rect (XXX verify coord round-off) */ draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); @@ -351,6 +371,7 @@ clear_with_quad(GLcontext *ctx, st->pipe->set_blend_state(st->pipe, &st->state.blend); st->pipe->set_depth_state(st->pipe, &st->state.depth); st->pipe->set_fs_state(st->pipe, &st->state.fs); + st->pipe->set_vs_state(st->pipe, &st->state.vs); st->pipe->set_setup_state(st->pipe, &st->state.setup); st->pipe->set_stencil_state(st->pipe, &st->state.stencil); /* OR: diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 11261f1d99..1aa56fcf8b 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -38,6 +38,7 @@ #include "st_program.h" #include "st_cb_drawpixels.h" #include "st_cb_texture.h" +#include "st_draw.h" #include "st_format.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -193,12 +194,12 @@ free_mipmap_tree(struct pipe_context *pipe, struct pipe_mipmap_tree *mt) * Y=0=top */ static void -draw_quad(struct st_context *st, GLfloat x0, GLfloat y0, GLfloat z, +draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, GLfloat x1, GLfloat y1) { static const GLuint attribs[2] = { - VF_ATTRIB_POS, - VF_ATTRIB_TEX0 + 0, /* pos */ + 8 /* tex0 */ }; GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */ GLuint i; @@ -235,8 +236,7 @@ draw_quad(struct st_context *st, GLfloat x0, GLfloat y0, GLfloat z, verts[i][1][3] = 1.0; /*Q*/ } - st->pipe->draw_vertices(st->pipe, PIPE_PRIM_QUADS, - 4, (GLfloat *) verts, 2, attribs); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (GLfloat *) verts, 2, attribs); } @@ -310,7 +310,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, y1 = ctx->DrawBuffer->Height - 1 - (y + height * ctx->Pixel.ZoomY); /* draw textured quad */ - draw_quad(ctx->st, x0, y0, z, x1, y1); + draw_quad(ctx, x0, y0, z, x1, y1); /* restore GL state */ pipe->set_setup_state(pipe, &ctx->st->state.setup); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index e82f7cff2b..a409dd9764 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -66,7 +66,9 @@ static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage ) { struct st_context *st = st_context(ctx); +#if 0 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; +#endif /* Validate driver and pipe state: */ @@ -74,7 +76,9 @@ static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage ) /* Call into the new draw code to handle the VB: */ +#if 0 st->pipe->draw_vb( st->pipe, VB ); +#endif /* Finished */ @@ -289,6 +293,72 @@ draw_vbo(GLcontext *ctx, +/** + * Utility function for drawing simple primitives (such as quads for + * glClear and glDrawPixels). Coordinates are in screen space. + * \param mode one of PIPE_PRIM_x + * \param numVertex number of vertices + * \param verts vertex data (all attributes are float[4]) + * \param numAttribs number of attributes per vertex + * \param attribs index of each attribute (0=pos, 3=color, etc) + */ +void +st_draw_vertices(GLcontext *ctx, unsigned prim, + unsigned numVertex, float *verts, + unsigned numAttribs, const unsigned attribs[]) +{ + const float width = ctx->DrawBuffer->Width; + const float height = ctx->DrawBuffer->Height; + const unsigned vertex_bytes = numVertex * numAttribs * 4 * sizeof(float); + struct pipe_context *pipe = ctx->st->pipe; + struct pipe_buffer_handle *vbuf; + struct pipe_vertex_buffer vbuffer; + struct pipe_vertex_element velement; + unsigned i; + + assert(numAttribs > 0); + assert(attribs[0] == 0); /* position */ + + /* convert to clip coords */ + for (i = 0; i < numVertex; i++) { + float x = verts[i * numAttribs * 4 + 0]; + float y = verts[i * numAttribs * 4 + 1]; + x = x / width * 2.0 - 1.0; + y = y / height * 2.0 - 1.0; + verts[i * numAttribs * 4 + 0] = x; + verts[i * numAttribs * 4 + 1] = y; + } + + /* XXX create one-time */ + vbuf = pipe->winsys->buffer_create(pipe->winsys, 32); + pipe->winsys->buffer_data(pipe->winsys, vbuf, vertex_bytes, verts); + + /* tell pipe about the vertex buffer */ + vbuffer.buffer = vbuf; + vbuffer.pitch = numAttribs * 4 * sizeof(float); /* vertex size */ + vbuffer.buffer_offset = 0; + pipe->set_vertex_buffer(pipe, 0, &vbuffer); + + /* tell pipe about the vertex attributes */ + for (i = 0; i < numAttribs; i++) { + velement.src_offset = i * 4 * sizeof(GLfloat); + velement.vertex_buffer_index = 0; + velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velement.dst_offset = 0; + pipe->set_vertex_element(pipe, attribs[i], &velement); + } + + /* draw */ + pipe->draw_arrays(pipe, prim, 0, numVertex); + + /* XXX: do one-time */ + pipe->winsys->buffer_unreference(pipe->winsys, &vbuf); +} + + + + + /* This is all a hack to keep using tnl until we have vertex programs * up and running. @@ -307,8 +377,10 @@ void st_init_draw( struct st_context *st ) vbo->draw_prims = draw_vbo; #endif +#if 0 _tnl_destroy_pipeline( ctx ); _tnl_install_pipeline( ctx, st_pipeline ); +#endif /* USE_NEW_DRAW */ _tnl_ProgramCacheInit( ctx ); diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index 0afadab577..0005fbc51f 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2004 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -34,11 +34,15 @@ #ifndef ST_DRAW_H #define ST_DRAW_H + void st_init_draw( struct st_context *st ); + void st_destroy_draw( struct st_context *st ); -/** XXX temporary here */ -void st_clear(struct st_context *st, GLboolean color, GLboolean depth, - GLboolean stencil); +void +st_draw_vertices(GLcontext *ctx, unsigned prim, + unsigned numVertex, float *verts, + unsigned numAttribs, const unsigned attribs[]); + #endif -- cgit v1.2.3 From 8175eaa3b49f3b62f7ab251c4e0fbd14dd9f7e2b Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 20 Aug 2007 16:31:12 -0600 Subject: Checkpoint: remove more of the old draw_vb() code. --- src/mesa/pipe/draw/draw_arrays.c | 3 -- src/mesa/pipe/draw/draw_context.c | 6 ++- src/mesa/pipe/draw/draw_private.h | 7 +-- src/mesa/pipe/i915simple/i915_context.c | 28 ++--------- src/mesa/pipe/p_context.h | 17 ------- src/mesa/pipe/softpipe/sp_context.c | 42 ----------------- src/mesa/pipe/softpipe/sp_state_vertex.c | 4 ++ src/mesa/state_tracker/st_draw.c | 80 +------------------------------- 8 files changed, 18 insertions(+), 169 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_arrays.c b/src/mesa/pipe/draw/draw_arrays.c index fe9ec44425..8cb34e8f8e 100644 --- a/src/mesa/pipe/draw/draw_arrays.c +++ b/src/mesa/pipe/draw/draw_arrays.c @@ -354,9 +354,6 @@ do { \ } while (0) -/** - * XXX very similar to same func in draw_vb.c (which will go away) - */ void draw_set_vertex_attributes( struct draw_context *draw, const unsigned *slot_to_vf_attr, diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index cc00576c53..0a3df37b7f 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -60,7 +60,9 @@ struct draw_context *draw_create( void ) draw->nr_planes = 6; #ifdef MESA +#if 0 draw->vf = vf_create( GL_TRUE ); +#endif #endif /* Statically allocate maximum sized vertices for the cache - could be cleverer... @@ -79,7 +81,7 @@ struct draw_context *draw_create( void ) void draw_destroy( struct draw_context *draw ) { -#ifdef MESA +#if 0/*def MESA*/ if (draw->header.storage) { ALIGN_FREE( draw->header.storage ); } @@ -194,7 +196,9 @@ void draw_set_viewport_state( struct draw_context *draw, draw->viewport = *viewport; /* struct copy */ #ifdef MESA +#if 0 vf_set_vp_scale_translate( draw->vf, viewport->scale, viewport->translate ); +#endif #endif /* Using tnl/ and vf/ modules is temporary while getting started. diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index 5c3efb80e9..a9825e646b 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -222,14 +222,11 @@ struct draw_context } pq; - /* Misc for draw_vb.c (XXX temporary) - */ -#ifdef MESA - GLvector4f header; -#endif +#if 0 ubyte *verts; boolean in_vb; struct vertex_fetch *vf; +#endif }; diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index c7d469583c..b34899a867 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -147,33 +147,16 @@ static void i915_destroy( struct pipe_context *pipe ) free( i915 ); } -static void i915_draw_vb( struct pipe_context *pipe, - struct vertex_buffer *VB ) -{ - struct i915_context *i915 = i915_context( pipe ); - - if (i915->dirty) - i915_update_derived( i915 ); - -#if 0 - draw_vb( i915->draw, VB ); -#endif -} - -static void -i915_draw_vertices(struct pipe_context *pipe, - unsigned mode, - unsigned numVertex, const float *verts, - unsigned numAttribs, const unsigned attribs[]) +static void i915_draw_arrays( struct pipe_context *pipe, + unsigned mode, unsigned start, unsigned count) { struct i915_context *i915 = i915_context( pipe ); if (i915->dirty) i915_update_derived( i915 ); -#if 0 - draw_vertices(i915->draw, mode, numVertex, verts, numAttribs, attribs); -#endif + + draw_arrays(i915->draw, mode, start, count); } @@ -217,12 +200,11 @@ 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.draw_vb = i915_draw_vb; - i915->pipe.draw_vertices = i915_draw_vertices; i915->pipe.clear = i915_clear; i915->pipe.reset_occlusion_counter = NULL; /* no support */ i915->pipe.get_occlusion_counter = NULL; + i915->pipe.draw_arrays = i915_draw_arrays; /* * Create drawing context and plug our rendering stage into it. diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index a3664a3b80..c4496cda50 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -28,16 +28,10 @@ #ifndef PIPE_CONTEXT_H #define PIPE_CONTEXT_H -//#include "main/mtypes.h" #include "p_state.h" #include "p_compiler.h" -/* Drawing currently kludged up via the existing tnl/ module. - */ -struct vertex_buffer; - - /** * Software pipeline rendering context. Basically a collection of * state setting functions, plus VBO drawing entrypoint. @@ -68,17 +62,6 @@ struct pipe_context { /* * Drawing */ - /* XXX this is temporary */ - void (*draw_vb)( struct pipe_context *pipe, - struct vertex_buffer *VB ); - - /* XXX this is temporary */ - void (*draw_vertices)( struct pipe_context *pipe, - unsigned mode, - unsigned numVertex, const float *verts, - unsigned numAttribs, const unsigned attribs[]); - - /** this is basically what we want */ void (*draw_arrays)( struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count); diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 91ede05c05..ab9becc99e 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -195,44 +195,6 @@ static void softpipe_destroy( struct pipe_context *pipe ) } -#if 0 -static void softpipe_draw_vb( struct pipe_context *pipe, - struct vertex_buffer *VB ) -{ - struct softpipe_context *softpipe = softpipe_context( pipe ); - - if (softpipe->dirty) - softpipe_update_derived( softpipe ); - - /* XXX move mapping/unmapping to higher/coarser level? */ - softpipe_map_surfaces(softpipe); - draw_vb( softpipe->draw, VB ); - softpipe_unmap_surfaces(softpipe); -} -#endif - - -static void -softpipe_draw_vertices(struct pipe_context *pipe, - unsigned mode, - unsigned numVertex, const float *verts, - unsigned numAttribs, const unsigned attribs[]) -{ - struct softpipe_context *softpipe = softpipe_context( pipe ); - - if (softpipe->dirty) - softpipe_update_derived( softpipe ); - - /* XXX move mapping/unmapping to higher/coarser level? */ - softpipe_map_surfaces(softpipe); -#if 0 - draw_vertices(softpipe->draw, mode, numVertex, verts, numAttribs, attribs); -#endif - softpipe_unmap_surfaces(softpipe); -} - - - static void softpipe_reset_occlusion_counter(struct pipe_context *pipe) { struct softpipe_context *softpipe = softpipe_context( pipe ); @@ -289,10 +251,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; -#if 0 - softpipe->pipe.draw_vb = softpipe_draw_vb; - softpipe->pipe.draw_vertices = softpipe_draw_vertices; -#endif softpipe->pipe.draw_arrays = softpipe_draw_arrays; softpipe->pipe.draw_elements = softpipe_draw_elements; diff --git a/src/mesa/pipe/softpipe/sp_state_vertex.c b/src/mesa/pipe/softpipe/sp_state_vertex.c index 18852552eb..09ff540ccf 100644 --- a/src/mesa/pipe/softpipe/sp_state_vertex.c +++ b/src/mesa/pipe/softpipe/sp_state_vertex.c @@ -27,10 +27,14 @@ /* Authors: Keith Whitwell */ + + #include "sp_context.h" #include "sp_state.h" #include "sp_surface.h" +#include "pipe/draw/draw_context.h" + void softpipe_set_vertex_element(struct pipe_context *pipe, diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index a409dd9764..5a13fdd2bf 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -33,10 +33,9 @@ #include "main/imports.h" #include "vbo/vbo.h" +#include "vbo/vbo_context.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "tnl/t_vp_build.h" /* USE_NEW_DRAW */ +#include "tnl/t_vp_build.h" #include "st_context.h" #include "st_atom.h" @@ -46,72 +45,6 @@ #include "pipe/p_defines.h" #include "pipe/p_winsys.h" -#include "vbo/vbo_context.h" - -/* - * Enabling this causes the VBO module to call draw_vbo() below, - * bypassing the T&L module. This only works with VBO-based demos, - * such as progs/test/bufferobj.c - */ -#define USE_NEW_DRAW 01 - - -/* - * TNL stage which feeds into the above. - * - * XXX: this needs to go into each driver using this code, because we - * cannot make the leap from ctx->draw_context in this file. The - * driver needs to customize tnl anyway, so this isn't a big deal. - */ -static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage ) -{ - struct st_context *st = st_context(ctx); -#if 0 - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; -#endif - - /* Validate driver and pipe state: - */ - st_validate_state( st ); - - /* Call into the new draw code to handle the VB: - */ -#if 0 - st->pipe->draw_vb( st->pipe, VB ); -#endif - - /* Finished - */ - return GL_FALSE; -} - -const struct tnl_pipeline_stage st_draw = { - "check state and draw", - NULL, - NULL, - NULL, - NULL, - draw -}; - -static const struct tnl_pipeline_stage *st_pipeline[] = { -#if USE_NEW_DRAW - &_tnl_vertex_program_stage, -#else - &_tnl_vertex_transform_stage, - &_tnl_vertex_cull_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_fog_coordinate_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - &_tnl_point_attenuation_stage, - &_tnl_vertex_program_stage, -#endif - &st_draw, /* ADD: escape to pipe */ - 0, -}; - static GLuint @@ -366,8 +299,6 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, void st_init_draw( struct st_context *st ) { GLcontext *ctx = st->ctx; - -#if USE_NEW_DRAW struct vbo_context *vbo = (struct vbo_context *) ctx->swtnl_im; create_default_attribs_buffer(st); @@ -376,13 +307,6 @@ void st_init_draw( struct st_context *st ) assert(vbo->draw_prims); vbo->draw_prims = draw_vbo; -#endif -#if 0 - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, st_pipeline ); -#endif - - /* USE_NEW_DRAW */ _tnl_ProgramCacheInit( ctx ); } -- cgit v1.2.3 From 7d5e7f03191673a02f8d3b9d5e4b95c074c5acdd Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 23 Aug 2007 17:39:52 -0600 Subject: map Mesa vertex attribs/arrays to TGSI attribs --- src/mesa/state_tracker/st_draw.c | 74 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 5 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 5a13fdd2bf..a88e2106d7 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -44,6 +44,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" +#include "pipe/tgsi/core/tgsi_attribs.h" @@ -71,6 +72,68 @@ pipe_vertex_format(GLenum format, GLuint size) } +/** + * Convert a mesa vertex attribute to a TGSI attribute + */ +static GLuint +tgsi_attrib_to_mesa_attrib(GLuint attr) +{ + switch (attr) { + case TGSI_ATTRIB_POS: + return VERT_ATTRIB_POS; + case TGSI_ATTRIB_WEIGHT: + return VERT_ATTRIB_WEIGHT; + case TGSI_ATTRIB_NORMAL: + return VERT_ATTRIB_NORMAL; + case TGSI_ATTRIB_COLOR0: + return VERT_ATTRIB_COLOR0; + case TGSI_ATTRIB_COLOR1: + return VERT_ATTRIB_COLOR1; + case TGSI_ATTRIB_FOG: + return VERT_ATTRIB_FOG; + case TGSI_ATTRIB_COLOR_INDEX: + return VERT_ATTRIB_COLOR_INDEX; + case TGSI_ATTRIB_EDGEFLAG: + return VERT_ATTRIB_EDGEFLAG; + case TGSI_ATTRIB_TEX0: + return VERT_ATTRIB_TEX0; + case TGSI_ATTRIB_TEX1: + return VERT_ATTRIB_TEX1; + case TGSI_ATTRIB_TEX2: + return VERT_ATTRIB_TEX2; + case TGSI_ATTRIB_TEX3: + return VERT_ATTRIB_TEX3; + case TGSI_ATTRIB_TEX4: + return VERT_ATTRIB_TEX4; + case TGSI_ATTRIB_TEX5: + return VERT_ATTRIB_TEX5; + case TGSI_ATTRIB_TEX6: + return VERT_ATTRIB_TEX6; + case TGSI_ATTRIB_TEX7: + return VERT_ATTRIB_TEX7; + case TGSI_ATTRIB_VAR0: + return VERT_ATTRIB_GENERIC0; + case TGSI_ATTRIB_VAR1: + return VERT_ATTRIB_GENERIC1; + case TGSI_ATTRIB_VAR2: + return VERT_ATTRIB_GENERIC2; + case TGSI_ATTRIB_VAR3: + return VERT_ATTRIB_GENERIC3; + case TGSI_ATTRIB_VAR4: + return VERT_ATTRIB_GENERIC4; + case TGSI_ATTRIB_VAR5: + return VERT_ATTRIB_GENERIC5; + case TGSI_ATTRIB_VAR6: + return VERT_ATTRIB_GENERIC6; + case TGSI_ATTRIB_VAR7: + return VERT_ATTRIB_GENERIC7; + default: + assert(0); + return 0; + } +} + + /** * The default attribute buffer is basically a copy of the @@ -141,27 +204,28 @@ draw_vbo(GLcontext *ctx, velement.src_format = 0; if (attrsNeeded & (1 << attr)) { - struct gl_buffer_object *bufobj = arrays[attr]->BufferObj; + const GLuint mesaAttr = tgsi_attrib_to_mesa_attrib(attr); + struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; if (bufobj && bufobj->Name) { struct st_buffer_object *stobj = st_buffer_object(bufobj); /* Recall that for VBOs, the gl_client_array->Ptr field is * really an offset from the start of the VBO, not a pointer. */ - unsigned offset = (unsigned) arrays[attr]->Ptr; + unsigned offset = (unsigned) arrays[mesaAttr]->Ptr; assert(stobj->buffer); vbuffer.buffer = stobj->buffer; vbuffer.buffer_offset = attr0_offset; /* in bytes */ - vbuffer.pitch = arrays[attr]->StrideB; /* in bytes */ + vbuffer.pitch = arrays[mesaAttr]->StrideB; /* in bytes */ vbuffer.max_index = 0; /* need this? */ velement.src_offset = offset - attr0_offset; /* bytes */ velement.vertex_buffer_index = attr; velement.dst_offset = 0; /* need this? */ - velement.src_format = pipe_vertex_format(arrays[attr]->Type, - arrays[attr]->Size); + velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size); assert(velement.src_format); } else { -- cgit v1.2.3 From c89502bb4e6d80182e4977ab084639850e1eba68 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 24 Aug 2007 10:01:20 +0100 Subject: Fixup include paths after rename --- src/mesa/pipe/draw/draw_prim.c | 2 +- src/mesa/pipe/draw/draw_vertex.h | 2 +- src/mesa/pipe/i915simple/i915_fpc_translate.c | 4 ++-- src/mesa/pipe/softpipe/sp_headers.h | 2 +- src/mesa/pipe/softpipe/sp_quad_fs.c | 2 +- src/mesa/pipe/softpipe/sp_state_derived.c | 2 +- src/mesa/pipe/softpipe/sp_tex_sample.c | 2 +- src/mesa/pipe/tgsi/deco/tgsi_deco.h | 2 +- src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c | 2 +- src/mesa/pipe/tgsi/mesa/tgsi_mesa.h | 2 +- src/mesa/sources | 10 +++++----- src/mesa/state_tracker/st_atom_fs.c | 2 +- src/mesa/state_tracker/st_atom_vs.c | 2 +- src/mesa/state_tracker/st_draw.c | 2 +- src/mesa/state_tracker/st_program.h | 2 +- 15 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c index 18a5d39077..c98d6ff298 100644 --- a/src/mesa/pipe/draw/draw_prim.c +++ b/src/mesa/pipe/draw/draw_prim.c @@ -35,7 +35,7 @@ #include "draw_context.h" #include "draw_prim.h" -#include "pipe/tgsi/core/tgsi_core.h" +#include "pipe/tgsi/exec/tgsi_core.h" #define RP_NONE 0 diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 0e15ea89a2..c104aa1143 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -33,7 +33,7 @@ #ifndef DRAW_VERTEX_H #define DRAW_VERTEX_H -#include "pipe/tgsi/core/tgsi_attribs.h" +#include "pipe/tgsi/exec/tgsi_attribs.h" #define MAX_VERT_ATTRIBS 12 /* OK? */ diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c index e7315d2263..6fcba719ae 100644 --- a/src/mesa/pipe/i915simple/i915_fpc_translate.c +++ b/src/mesa/pipe/i915simple/i915_fpc_translate.c @@ -29,8 +29,8 @@ #include "i915_context.h" #include "i915_fpc.h" -#include "pipe/tgsi/core/tgsi_token.h" -#include "pipe/tgsi/core/tgsi_parse.h" +#include "pipe/tgsi/exec/tgsi_token.h" +#include "pipe/tgsi/exec/tgsi_parse.h" #include "pipe/draw/draw_vertex.h" diff --git a/src/mesa/pipe/softpipe/sp_headers.h b/src/mesa/pipe/softpipe/sp_headers.h index cc8294b18e..b377c34712 100644 --- a/src/mesa/pipe/softpipe/sp_headers.h +++ b/src/mesa/pipe/softpipe/sp_headers.h @@ -31,7 +31,7 @@ #ifndef SP_HEADERS_H #define SP_HEADERS_H -#include "../tgsi/core/tgsi_core.h" +#include "../tgsi/exec/tgsi_core.h" #define PRIM_POINT 1 #define PRIM_LINE 2 diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index 8d41e09465..bfc31f94a6 100755 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -34,7 +34,7 @@ #include "pipe/p_util.h" #include "pipe/p_defines.h" -#include "pipe/tgsi/core/tgsi_attribs.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 76200857f0..b0d79eedda 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -33,7 +33,7 @@ #include "sp_context.h" #include "sp_state.h" -#include "pipe/tgsi/core/tgsi_attribs.h" +#include "pipe/tgsi/exec/tgsi_attribs.h" diff --git a/src/mesa/pipe/softpipe/sp_tex_sample.c b/src/mesa/pipe/softpipe/sp_tex_sample.c index 23a0306bba..40d0cf40ae 100644 --- a/src/mesa/pipe/softpipe/sp_tex_sample.c +++ b/src/mesa/pipe/softpipe/sp_tex_sample.c @@ -39,7 +39,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_util.h" -#include "pipe/tgsi/core/tgsi_exec.h" +#include "pipe/tgsi/exec/tgsi_exec.h" /* diff --git a/src/mesa/pipe/tgsi/deco/tgsi_deco.h b/src/mesa/pipe/tgsi/deco/tgsi_deco.h index 06a2654fb6..3560e455f3 100644 --- a/src/mesa/pipe/tgsi/deco/tgsi_deco.h +++ b/src/mesa/pipe/tgsi/deco/tgsi_deco.h @@ -1,7 +1,7 @@ #if !defined TGSI_DECO_H #define TGSI_DECO_H -#include "../core/tgsi_core.h" +#include "../exec/tgsi_core.h" #include "deco_caps.h" #endif // !defined TGSI_DECO_H diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index f33a702958..78390767df 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -1,6 +1,6 @@ #include "tgsi_platform.h" #include "tgsi_mesa.h" -#include "pipe/tgsi/core/tgsi_attribs.h" +#include "pipe/tgsi/exec/tgsi_attribs.h" #include "pipe/tgsi/mesa/mesa_to_tgsi.h" #define TGSI_DEBUG 1 diff --git a/src/mesa/pipe/tgsi/mesa/tgsi_mesa.h b/src/mesa/pipe/tgsi/mesa/tgsi_mesa.h index 0053748fde..a4e16e708e 100644 --- a/src/mesa/pipe/tgsi/mesa/tgsi_mesa.h +++ b/src/mesa/pipe/tgsi/mesa/tgsi_mesa.h @@ -1,7 +1,7 @@ #if !defined TGSI_MESA_H #define TGSI_MESA_H -#include "../core/tgsi_core.h" +#include "../exec/tgsi_core.h" #include "mesa_to_tgsi.h" #endif // !defined TGSI_MESA_H diff --git a/src/mesa/sources b/src/mesa/sources index e78db591ab..ec30a889f6 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -167,11 +167,11 @@ DRAW_SOURCES = \ pipe/draw/draw_unfilled.c TGSICORE_SOURCES = \ - pipe/tgsi/core/tgsi_build.c \ - pipe/tgsi/core/tgsi_dump.c \ - pipe/tgsi/core/tgsi_exec.c \ - pipe/tgsi/core/tgsi_parse.c \ - pipe/tgsi/core/tgsi_util.c + pipe/tgsi/exec/tgsi_build.c \ + pipe/tgsi/exec/tgsi_dump.c \ + pipe/tgsi/exec/tgsi_exec.c \ + pipe/tgsi/exec/tgsi_parse.c \ + pipe/tgsi/exec/tgsi_util.c TGSIDECO_SOURCES = \ pipe/tgsi/deco/deco_caps.c diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index a34a227ac0..a164ded184 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -35,7 +35,7 @@ #include "pipe/p_defines.h" #include "pipe/p_winsys.h" #include "pipe/tgsi/mesa/mesa_to_tgsi.h" -#include "pipe/tgsi/core/tgsi_dump.h" +#include "pipe/tgsi/exec/tgsi_dump.h" #include "st_context.h" #include "st_atom.h" diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index 8c9365d9d8..4c83a8c5c1 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -37,7 +37,7 @@ #include "pipe/p_defines.h" #include "pipe/p_winsys.h" #include "pipe/tgsi/mesa/mesa_to_tgsi.h" -#include "pipe/tgsi/core/tgsi_dump.h" +#include "pipe/tgsi/exec/tgsi_dump.h" #include "st_context.h" #include "st_atom.h" diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index a88e2106d7..afb6f96a26 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -44,7 +44,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" -#include "pipe/tgsi/core/tgsi_attribs.h" +#include "pipe/tgsi/exec/tgsi_attribs.h" diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 3ff4f4e9c7..e7eb7a8e3f 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -35,7 +35,7 @@ #define ST_PROGRAM_H #include "mtypes.h" -#include "pipe/tgsi/core/tgsi_token.h" +#include "pipe/tgsi/exec/tgsi_token.h" #define ST_FP_MAX_TOKENS 1024 -- 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_draw.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 b4bacd1fca336f043d1ee3c3a346fbd42a3b02eb Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 17 Sep 2007 14:24:11 -0600 Subject: Plug in selection/feedback code. Not quite finished yet. Selection/feedback are done with a private instance of the 'draw' module in the state tracker. Not quite all the draw context's state is set yet, namely vertex format info. Hold off on that for a bit... --- src/mesa/sources | 1 + src/mesa/state_tracker/st_context.c | 6 ++ src/mesa/state_tracker/st_context.h | 7 ++ src/mesa/state_tracker/st_draw.c | 180 ++++++++++++++++++++++++++++++++++-- src/mesa/state_tracker/st_draw.h | 20 ++++ 5 files changed, 205 insertions(+), 9 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/sources b/src/mesa/sources index a672ad2fcf..ec561294c5 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -210,6 +210,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_cb_flush.c \ state_tracker/st_cb_drawpixels.c \ state_tracker/st_cb_fbo.c \ + state_tracker/st_cb_feedback.c \ state_tracker/st_cb_program.c \ state_tracker/st_cb_queryobj.c \ state_tracker/st_cb_rasterpos.c \ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index e66e65e2dd..6ab643f1fe 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -33,6 +33,7 @@ #include "st_cb_clear.h" #include "st_cb_drawpixels.h" #include "st_cb_fbo.h" +#include "st_cb_feedback.h" #include "st_cb_queryobj.h" #include "st_cb_rasterpos.h" #include "st_cb_readpixels.h" @@ -43,6 +44,7 @@ #include "st_draw.h" #include "st_program.h" #include "pipe/p_context.h" +#include "pipe/draw/draw_context.h" void st_invalidate_state(GLcontext * ctx, GLuint new_state) @@ -64,6 +66,8 @@ struct st_context *st_create_context( GLcontext *ctx, st->ctx = ctx; st->pipe = pipe; + st->draw = draw_create(); /* for selection/feedback */ + st->dirty.mesa = ~0; st->dirty.st = ~0; @@ -97,6 +101,7 @@ struct st_context *st_create_context( GLcontext *ctx, void st_destroy_context( struct st_context *st ) { + draw_destroy(st->draw); st_destroy_atoms( st ); st_destroy_draw( st ); @@ -120,6 +125,7 @@ void st_init_driver_functions(struct dd_function_table *functions) st_init_clear_functions(functions); st_init_drawpixels_functions(functions); st_init_fbo_functions(functions); + st_init_feedback_functions(functions); st_init_program_functions(functions); st_init_query_functions(functions); st_init_rasterpos_functions(functions); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 98b78af7c5..56cae7d973 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -37,6 +37,9 @@ struct st_region; struct st_texture_object; struct st_texture_image; struct st_fragment_program; +struct draw_context; +struct draw_stage; + #define ST_NEW_MESA 0x1 /* Mesa state has changed */ #define ST_NEW_FRAGMENT_PROGRAM 0x2 @@ -62,6 +65,10 @@ struct st_context struct pipe_context *pipe; + struct draw_context *draw; /**< For selection/feedback */ + struct draw_stage *feedback_stage; /**< For FL_FEEDBACK rendermode */ + struct draw_stage *selection_stage; /**< For GL_SELECT rendermode */ + /* Eventually will use a cache to feed the pipe with * create/bind/delete calls to constant state objects. Not yet * though, we just shove random objects across the interface. diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 1facc14ccd..69f4b7fa5b 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -46,6 +46,8 @@ #include "pipe/p_winsys.h" #include "pipe/tgsi/exec/tgsi_attribs.h" +#include "pipe/draw/draw_private.h" +#include "pipe/draw/draw_context.h" static GLuint @@ -173,14 +175,14 @@ update_default_attribs_buffer(GLcontext *ctx) * we have something to render. * Basically, translate the information into the format expected by pipe. */ -static void -draw_vbo(GLcontext *ctx, - const struct gl_client_array **arrays, - const struct _mesa_prim *prims, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index) +void +st_draw_vbo(GLcontext *ctx, + const struct gl_client_array **arrays, + const struct _mesa_prim *prims, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLuint min_index, + GLuint max_index) { struct pipe_context *pipe = ctx->st->pipe; GLuint attr, i; @@ -356,6 +358,166 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, +/** + * Called by VBO to draw arrays when in selection or feedback mode. + * This is very much like the normal draw_vbo() function above. + * Look at code refactoring some day. + * Might move this into the failover module some day. + */ +void +st_feedback_draw_vbo(GLcontext *ctx, + const struct gl_client_array **arrays, + const struct _mesa_prim *prims, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLuint min_index, + GLuint max_index) +{ + struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; + struct draw_context *draw = st->draw; + GLuint attr, i; + GLbitfield attrsNeeded; + const unsigned attr0_offset = (unsigned) arrays[0]->Ptr; + struct pipe_buffer_handle *index_buffer_handle = 0; + + assert(ctx->RenderMode == GL_SELECT || + ctx->RenderMode == GL_FEEDBACK); + assert(draw); + + /* + * Set up the draw module's state. + * + * We'd like to do this less frequently, but the normal state-update + * code sends state updates to the pipe, not to our private draw module. + */ + assert(draw); + draw_set_viewport_state(draw, &st->state.viewport); + draw_set_clip_state(draw, &st->state.clip); + draw_set_setup_state(draw, &st->state.setup); + 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; + + /* tell draw module about the vertex array element/attributes */ + for (attr = 0; attr < 16; attr++) { + struct pipe_vertex_buffer vbuffer; + struct pipe_vertex_element velement; + void *map; + + vbuffer.buffer = NULL; + vbuffer.pitch = 0; + velement.src_offset = 0; + velement.vertex_buffer_index = 0; + velement.src_format = 0; + + if (attrsNeeded & (1 << attr)) { + const GLuint mesaAttr = tgsi_attrib_to_mesa_attrib(attr); + struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; + + if (bufobj && bufobj->Name) { + struct st_buffer_object *stobj = st_buffer_object(bufobj); + /* Recall that for VBOs, the gl_client_array->Ptr field is + * really an offset from the start of the VBO, not a pointer. + */ + unsigned offset = (unsigned) arrays[mesaAttr]->Ptr; + + assert(stobj->buffer); + + vbuffer.buffer = stobj->buffer; + vbuffer.buffer_offset = attr0_offset; /* in bytes */ + vbuffer.pitch = arrays[mesaAttr]->StrideB; /* in bytes */ + vbuffer.max_index = 0; /* need this? */ + + velement.src_offset = offset - attr0_offset; /* bytes */ + velement.vertex_buffer_index = attr; + velement.dst_offset = 0; /* need this? */ + velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size); + assert(velement.src_format); + } + else { + /* use the default attribute buffer */ + vbuffer.buffer = ctx->st->default_attrib_buffer; + vbuffer.buffer_offset = 0; + vbuffer.pitch = 0; /* must be zero! */ + vbuffer.max_index = 1; + + velement.src_offset = attr * 4 * sizeof(GLfloat); + velement.vertex_buffer_index = attr; + velement.dst_offset = 0; + velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + } + } + + if (attr == 0) + assert(vbuffer.buffer); + + draw_set_vertex_buffer(draw, attr, &vbuffer); + draw_set_vertex_element(draw, attr, &velement); + + /* map the attrib buffer */ + if (vbuffer.buffer) { + map = pipe->winsys->buffer_map(pipe->winsys, + vbuffer.buffer, + PIPE_BUFFER_FLAG_READ); + draw_set_mapped_vertex_buffer(draw, attr, map); + } + } + + + if (ib) { + unsigned indexSize; + struct gl_buffer_object *bufobj = ib->obj; + struct st_buffer_object *stobj = st_buffer_object(bufobj); + index_buffer_handle = stobj->buffer; + void *map; + + switch (ib->type) { + case GL_UNSIGNED_INT: + indexSize = 4; + break; + case GL_UNSIGNED_SHORT: + indexSize = 2; + break; + default: + assert(0); + } + + map = pipe->winsys->buffer_map(pipe->winsys, + index_buffer_handle, + PIPE_BUFFER_FLAG_READ); + draw_set_mapped_element_buffer(draw, indexSize, map); + } + + + /* draw here */ + for (i = 0; i < nr_prims; i++) { + draw_arrays(draw, prims[i].mode, prims[i].start, prims[i].count); + } + + + /* + * unmap vertex/index buffers + */ + for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + if (draw->vertex_buffer[i].buffer) { + pipe->winsys->buffer_unmap(pipe->winsys, + draw->vertex_buffer[i].buffer); + draw_set_mapped_vertex_buffer(draw, i, NULL); + } + } + if (ib) { + pipe->winsys->buffer_unmap(pipe->winsys, index_buffer_handle); + draw_set_mapped_element_buffer(draw, 0, NULL); + } +} + /* This is all a hack to keep using tnl until we have vertex programs @@ -370,7 +532,7 @@ void st_init_draw( struct st_context *st ) assert(vbo); assert(vbo->draw_prims); - vbo->draw_prims = draw_vbo; + vbo->draw_prims = st_draw_vbo; _tnl_ProgramCacheInit( ctx ); } diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index 0005fbc51f..1fcd1b7e6b 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -34,11 +34,31 @@ #ifndef ST_DRAW_H #define ST_DRAW_H +struct _mesa_prim; +struct _mesa_index_buffer; void st_init_draw( struct st_context *st ); void st_destroy_draw( struct st_context *st ); +extern void +st_draw_vbo(GLcontext *ctx, + const struct gl_client_array **arrays, + const struct _mesa_prim *prims, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLuint min_index, + GLuint max_index); + +extern void +st_feedback_draw_vbo(GLcontext *ctx, + const struct gl_client_array **arrays, + const struct _mesa_prim *prims, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLuint min_index, + GLuint max_index); + void st_draw_vertices(GLcontext *ctx, unsigned prim, unsigned numVertex, float *verts, -- cgit v1.2.3 From 294401814d1d89cc731de1c22c25333aa5d59374 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 17 Sep 2007 12:59:50 -0400 Subject: converting the setup state to immutable object and renaming it to rasterizer state --- src/mesa/cso_cache/cso_cache.c | 6 ++ src/mesa/cso_cache/cso_cache.h | 4 +- src/mesa/pipe/draw/draw_context.c | 16 ++--- src/mesa/pipe/draw/draw_context.h | 2 +- src/mesa/pipe/draw/draw_cull.c | 2 +- src/mesa/pipe/draw/draw_offset.c | 4 +- src/mesa/pipe/draw/draw_private.h | 2 +- src/mesa/pipe/draw/draw_twoside.c | 2 +- src/mesa/pipe/draw/draw_unfilled.c | 4 +- src/mesa/pipe/failover/fo_context.h | 8 +-- src/mesa/pipe/failover/fo_state.c | 14 ++-- src/mesa/pipe/failover/fo_state_emit.c | 4 +- src/mesa/pipe/i915simple/i915_context.h | 4 +- src/mesa/pipe/i915simple/i915_state.c | 30 ++++++-- src/mesa/pipe/i915simple/i915_state_derived.c | 6 +- src/mesa/pipe/i915simple/i915_state_dynamic.c | 16 ++--- src/mesa/pipe/i915simple/i915_state_immediate.c | 30 ++++---- src/mesa/pipe/p_context.h | 11 ++- src/mesa/pipe/p_state.h | 4 +- src/mesa/pipe/softpipe/sp_context.c | 4 +- src/mesa/pipe/softpipe/sp_context.h | 4 +- src/mesa/pipe/softpipe/sp_prim_setup.c | 18 ++--- src/mesa/pipe/softpipe/sp_quad.c | 8 +-- src/mesa/pipe/softpipe/sp_quad_coverage.c | 6 +- src/mesa/pipe/softpipe/sp_state.h | 12 ++-- src/mesa/pipe/softpipe/sp_state_derived.c | 10 +-- src/mesa/pipe/softpipe/sp_state_setup.c | 26 +++++-- src/mesa/state_tracker/st_atom.c | 2 +- src/mesa/state_tracker/st_atom.h | 2 +- src/mesa/state_tracker/st_atom_setup.c | 95 +++++++++++++------------ src/mesa/state_tracker/st_cache.c | 18 +++++ src/mesa/state_tracker/st_cache.h | 6 +- src/mesa/state_tracker/st_cb_clear.c | 12 ++-- src/mesa/state_tracker/st_cb_drawpixels.c | 8 ++- src/mesa/state_tracker/st_context.h | 2 +- src/mesa/state_tracker/st_draw.c | 2 +- 36 files changed, 245 insertions(+), 159 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/cso_cache/cso_cache.c b/src/mesa/cso_cache/cso_cache.c index a4730394f8..4aaadf00e6 100644 --- a/src/mesa/cso_cache/cso_cache.c +++ b/src/mesa/cso_cache/cso_cache.c @@ -78,6 +78,8 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_ hash = sc->sampler_hash; case CSO_DEPTH_STENCIL: hash = sc->depth_stencil_hash; + case CSO_RASTERIZER: + hash = sc->rasterizer_hash; } return hash; @@ -92,6 +94,8 @@ static int _cso_size_for_type(enum cso_cache_type type) return sizeof(struct pipe_sampler_state); case CSO_DEPTH_STENCIL: return sizeof(struct pipe_depth_stencil_state); + case CSO_RASTERIZER: + return sizeof(struct pipe_rasterizer_state); } return 0; } @@ -143,6 +147,7 @@ struct cso_cache *cso_cache_create(void) 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(); return sc; } @@ -153,6 +158,7 @@ void cso_cache_delete(struct cso_cache *sc) cso_hash_delete(sc->blend_hash); cso_hash_delete(sc->sampler_hash); cso_hash_delete(sc->depth_stencil_hash); + cso_hash_delete(sc->rasterizer_hash); free(sc); } diff --git a/src/mesa/cso_cache/cso_cache.h b/src/mesa/cso_cache/cso_cache.h index c340cf7f67..23be9cd713 100644 --- a/src/mesa/cso_cache/cso_cache.h +++ b/src/mesa/cso_cache/cso_cache.h @@ -43,12 +43,14 @@ struct cso_cache { struct cso_hash *blend_hash; struct cso_hash *sampler_hash; struct cso_hash *depth_stencil_hash; + struct cso_hash *rasterizer_hash; }; enum cso_cache_type { CSO_BLEND, CSO_SAMPLER, - CSO_DEPTH_STENCIL + CSO_DEPTH_STENCIL, + CSO_RASTERIZER }; unsigned cso_construct_key(void *item, int item_size); diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index 4498293e92..f3236ad59e 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -98,19 +98,19 @@ static void validate_pipeline( struct draw_context *draw ) * shorter pipelines for lines & points. */ - if (draw->setup.fill_cw != PIPE_POLYGON_MODE_FILL || - draw->setup.fill_ccw != PIPE_POLYGON_MODE_FILL) { + if (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL || + draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) { draw->pipeline.unfilled->next = next; next = draw->pipeline.unfilled; } - if (draw->setup.offset_cw || - draw->setup.offset_ccw) { + if (draw->rasterizer->offset_cw || + draw->rasterizer->offset_ccw) { draw->pipeline.offset->next = next; next = draw->pipeline.offset; } - if (draw->setup.light_twoside) { + if (draw->rasterizer->light_twoside) { draw->pipeline.twoside->next = next; next = draw->pipeline.twoside; } @@ -134,7 +134,7 @@ static void validate_pipeline( struct draw_context *draw ) * this for clipped primitives, ie it is a part of the clip * routine. */ - if (draw->setup.flatshade) { + if (draw->rasterizer->flatshade) { draw->pipeline.flatshade->next = next; next = draw->pipeline.flatshade; } @@ -161,9 +161,9 @@ void draw_set_feedback_state( struct draw_context *draw, * This causes the drawing pipeline to be rebuilt. */ void draw_set_setup_state( struct draw_context *draw, - const struct pipe_setup_state *setup ) + const struct pipe_rasterizer_state *raster ) { - draw->setup = *setup; /* struct copy */ + draw->rasterizer = raster; validate_pipeline( draw ); } diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 2babc02f45..2714252fc5 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -87,7 +87,7 @@ void draw_set_feedback_state( struct draw_context *draw, const struct pipe_feedback_state * ); void draw_set_setup_state( struct draw_context *draw, - const struct pipe_setup_state *setup ); + const struct pipe_rasterizer_state *raster ); void draw_set_setup_stage( struct draw_context *draw, struct draw_stage *stage ); diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c index f3d56ad719..f898834ba5 100644 --- a/src/mesa/pipe/draw/draw_cull.c +++ b/src/mesa/pipe/draw/draw_cull.c @@ -54,7 +54,7 @@ static void cull_begin( struct draw_stage *stage ) { struct cull_stage *cull = cull_stage(stage); - cull->winding = stage->draw->setup.cull_mode; + cull->winding = stage->draw->rasterizer->cull_mode; stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c index 4f653e8c54..6acc7cbcd2 100644 --- a/src/mesa/pipe/draw/draw_offset.c +++ b/src/mesa/pipe/draw/draw_offset.c @@ -57,8 +57,8 @@ 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->setup.offset_units * mrd; - offset->scale = stage->draw->setup.offset_scale; + offset->units = stage->draw->rasterizer->offset_units * mrd; + offset->scale = stage->draw->rasterizer->offset_scale; stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index 8bcc3717c4..fb0aaff40d 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -137,7 +137,7 @@ struct draw_context } pipeline; /* pipe state that we need: */ - struct pipe_setup_state setup; + 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]; diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c index 98eb088035..3eb8cce637 100644 --- a/src/mesa/pipe/draw/draw_twoside.c +++ b/src/mesa/pipe/draw/draw_twoside.c @@ -55,7 +55,7 @@ static void twoside_begin( struct draw_stage *stage ) * if the triangle is back-facing (negative). * sign = -1 for CCW, +1 for CW */ - twoside->sign = (stage->draw->setup.front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f; + twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f; stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c index b0d6f3d065..2d374329d8 100644 --- a/src/mesa/pipe/draw/draw_unfilled.c +++ b/src/mesa/pipe/draw/draw_unfilled.c @@ -59,8 +59,8 @@ static void unfilled_begin( struct draw_stage *stage ) { struct unfilled_stage *unfilled = unfilled_stage(stage); - unfilled->mode[0] = stage->draw->setup.fill_ccw; /* front */ - unfilled->mode[1] = stage->draw->setup.fill_cw; /* back */ + unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */ + unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */ stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h index 63ec7239ab..b05ceb88ad 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -37,7 +37,7 @@ #define FO_NEW_VIEWPORT 0x1 -#define FO_NEW_SETUP 0x2 +#define FO_NEW_RASTERIZER 0x2 #define FO_NEW_FRAGMENT_SHADER 0x4 #define FO_NEW_BLEND 0x8 #define FO_NEW_CLIP 0x10 @@ -66,9 +66,10 @@ struct failover_context { /* The most recent drawing state as set by the driver: */ - const struct pipe_blend_state *blend; - const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; + const struct pipe_blend_state *blend; + const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_rasterizer_state *rasterizer; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -79,7 +80,6 @@ struct failover_context { struct pipe_shader_state vertex_shader; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_setup_state setup; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index 43b9757b31..8e2b649590 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -160,15 +160,15 @@ failover_set_polygon_stipple( struct pipe_context *pipe, -static void -failover_set_setup_state( struct pipe_context *pipe, - const struct pipe_setup_state *setup ) +static void +failover_bind_rasterizer_state( struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup ) { struct failover_context *failover = failover_context(pipe); - failover->setup = *setup; - failover->dirty |= FO_NEW_SETUP; - failover->hw->set_setup_state( failover->hw, setup ); + failover->rasterizer = setup; + failover->dirty |= FO_NEW_RASTERIZER; + failover->hw->bind_rasterizer_state( failover->hw, setup ); } @@ -257,6 +257,7 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.bind_blend_state = failover_bind_blend_state; 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.set_alpha_test_state = failover_set_alpha_test_state; failover->pipe.set_blend_color = failover_set_blend_color; @@ -267,7 +268,6 @@ failover_init_state_functions( struct failover_context *failover ) 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_setup_state = failover_set_setup_state; failover->pipe.set_texture_state = failover_set_texture_state; failover->pipe.set_viewport_state = failover_set_viewport_state; failover->pipe.set_vertex_buffer = failover_set_vertex_buffer; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index 3a1865d766..1c9573a7b0 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -85,8 +85,8 @@ failover_state_emit( struct failover_context *failover ) if (failover->dirty & FO_NEW_STIPPLE) failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple ); - if (failover->dirty & FO_NEW_SETUP) - failover->sw->set_setup_state( failover->sw, &failover->setup ); + if (failover->dirty & FO_NEW_RASTERIZER) + failover->sw->bind_rasterizer_state( failover->sw, failover->rasterizer ); if (failover->dirty & FO_NEW_SCISSOR) failover->sw->set_scissor_state( failover->sw, &failover->scissor ); diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index 518f780449..3fab821fde 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -126,6 +126,7 @@ struct i915_context const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_rasterizer_state *rasterizer; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -136,7 +137,6 @@ struct i915_context struct pipe_shader_state fs; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_setup_state setup; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; @@ -159,7 +159,7 @@ struct i915_context /* A flag for each state_tracker state object: */ #define I915_NEW_VIEWPORT 0x1 -#define I915_NEW_SETUP 0x2 +#define I915_NEW_RASTERIZER 0x2 #define I915_NEW_FS 0x4 #define I915_NEW_BLEND 0x8 #define I915_NEW_CLIP 0x10 diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 5ac2e27d1a..00764902bc 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -288,19 +288,36 @@ static void i915_set_viewport_state( struct pipe_context *pipe, } -static void i915_set_setup_state( struct pipe_context *pipe, - const struct pipe_setup_state *setup ) + +static const struct pipe_rasterizer_state * +i915_create_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup) +{ + struct pipe_rasterizer_state *raster = + malloc(sizeof(struct pipe_rasterizer_state)); + memcpy(raster, setup, sizeof(struct pipe_rasterizer_state)); + + return raster; +} + +static void i915_bind_rasterizer_state( struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup ) { struct i915_context *i915 = i915_context(pipe); - i915->setup = *setup; + i915->rasterizer = setup; /* pass-through to draw module */ draw_set_setup_state(i915->draw, setup); - i915->dirty |= I915_NEW_SETUP; + i915->dirty |= I915_NEW_RASTERIZER; } +static void i915_delete_rasterizer_state( struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup ) +{ + free((struct pipe_rasterizer_state*)setup); +} static void i915_set_vertex_buffer( struct pipe_context *pipe, unsigned index, @@ -338,6 +355,10 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.bind_depth_stencil_state = i915_bind_depth_stencil_state; i915->pipe.delete_depth_stencil_state = i915_delete_depth_stencil_state; + 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.set_alpha_test_state = i915_set_alpha_test_state; i915->pipe.set_blend_color = i915_set_blend_color; i915->pipe.set_clip_state = i915_set_clip_state; @@ -348,7 +369,6 @@ i915_init_state_functions( struct i915_context *i915 ) 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_setup_state = i915_set_setup_state; i915->pipe.set_texture_state = i915_set_texture_state; i915->pipe.set_viewport_state = i915_set_viewport_state; i915->pipe.set_vertex_buffer = i915_set_vertex_buffer; diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 792bb93b17..504bc10a9e 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -44,7 +44,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) { const uint inputsRead = i915->fs.inputs_read; const interp_mode colorInterp - = i915->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR; + = 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; @@ -103,7 +103,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) * lighting. Edgeflag is dealt with specially by setting bits in * the vertex header. */ - if (i915->setup.light_twoside) { + if (i915->rasterizer->light_twoside) { if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, FORMAT_OMIT, colorInterp); @@ -142,7 +142,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) */ void i915_update_derived( struct i915_context *i915 ) { - if (i915->dirty & (I915_NEW_SETUP | I915_NEW_FS)) + if (i915->dirty & (I915_NEW_RASTERIZER | I915_NEW_FS)) calculate_vertex_layout( i915 ); if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_TEXTURE)) diff --git a/src/mesa/pipe/i915simple/i915_state_dynamic.c b/src/mesa/pipe/i915simple/i915_state_dynamic.c index 9140eee7c2..a9791962e2 100644 --- a/src/mesa/pipe/i915simple/i915_state_dynamic.c +++ b/src/mesa/pipe/i915simple/i915_state_dynamic.c @@ -261,10 +261,10 @@ static void upload_DEPTHSCALE( struct i915_context *i915 ) memset( ds, 0, sizeof(ds) ); - /* I915_NEW_SETUP + /* I915_NEW_RASTERIZER */ ds[0].u = _3DSTATE_DEPTH_OFFSET_SCALE; - ds[1].f = i915->setup.offset_scale; + ds[1].f = i915->rasterizer->offset_scale; set_dynamic_indirect( i915, I915_DYNAMIC_DEPTHSCALE_0, @@ -273,7 +273,7 @@ static void upload_DEPTHSCALE( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_DEPTHSCALE = { - .dirty = I915_NEW_SETUP, + .dirty = I915_NEW_RASTERIZER, .update = upload_DEPTHSCALE }; @@ -298,9 +298,9 @@ static void upload_STIPPLE( struct i915_context *i915 ) st[0] = _3DSTATE_STIPPLE; st[1] = 0; - /* I915_NEW_SETUP + /* I915_NEW_RASTERIZER */ - if (i915->setup.poly_stipple_enable) { + if (i915->rasterizer->poly_stipple_enable) { st[1] |= ST1_ENABLE; } @@ -333,7 +333,7 @@ static void upload_STIPPLE( struct i915_context *i915 ) const struct i915_tracked_state i915_upload_STIPPLE = { - .dirty = I915_NEW_SETUP | I915_NEW_STIPPLE, + .dirty = I915_NEW_RASTERIZER | I915_NEW_STIPPLE, .update = upload_STIPPLE }; @@ -346,7 +346,7 @@ static void upload_SCISSOR_ENABLE( struct i915_context *i915 ) { unsigned sc[1]; - if (i915->setup.scissor) + if (i915->rasterizer->scissor) sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT; else sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT; @@ -358,7 +358,7 @@ static void upload_SCISSOR_ENABLE( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_SCISSOR_ENABLE = { - .dirty = I915_NEW_SETUP, + .dirty = I915_NEW_RASTERIZER, .update = upload_SCISSOR_ENABLE }; diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c index 484913d308..73508f557f 100644 --- a/src/mesa/pipe/i915simple/i915_state_immediate.c +++ b/src/mesa/pipe/i915simple/i915_state_immediate.c @@ -62,8 +62,8 @@ static void upload_S2S4(struct i915_context *i915) assert(LIS4); /* should never be zero? */ } - /* I915_NEW_SETUP */ - switch (i915->setup.cull_mode) { + /* I915_NEW_RASTERIZER */ + switch (i915->rasterizer->cull_mode) { case PIPE_WINDING_NONE: LIS4 |= S4_CULLMODE_NONE; break; @@ -78,25 +78,25 @@ static void upload_S2S4(struct i915_context *i915) break; } - /* I915_NEW_SETUP */ + /* I915_NEW_RASTERIZER */ { - int line_width = CLAMP((int)(i915->setup.line_width * 2), 1, 0xf); + int line_width = CLAMP((int)(i915->rasterizer->line_width * 2), 1, 0xf); LIS4 |= line_width << S4_LINE_WIDTH_SHIFT; - if (i915->setup.line_smooth) + if (i915->rasterizer->line_smooth) LIS4 |= S4_LINE_ANTIALIAS_ENABLE; } - /* I915_NEW_SETUP */ + /* I915_NEW_RASTERIZER */ { - int point_size = CLAMP((int) i915->setup.point_size, 1, 0xff); + int point_size = CLAMP((int) i915->rasterizer->point_size, 1, 0xff); LIS4 |= point_size << S4_POINT_WIDTH_SHIFT; } - /* I915_NEW_SETUP */ - if (i915->setup.flatshade) { + /* I915_NEW_RASTERIZER */ + if (i915->rasterizer->flatshade) { LIS4 |= (S4_FLATSHADE_ALPHA | S4_FLATSHADE_COLOR | S4_FLATSHADE_SPECULAR); @@ -114,7 +114,7 @@ static void upload_S2S4(struct i915_context *i915) const struct i915_tracked_state i915_upload_S2S4 = { - .dirty = I915_NEW_SETUP | I915_NEW_VERTEX_FORMAT, + .dirty = I915_NEW_RASTERIZER | I915_NEW_VERTEX_FORMAT, .update = upload_S2S4 }; @@ -165,7 +165,7 @@ static void upload_S5( struct i915_context *i915 ) #if 0 - /* I915_NEW_SETUP */ + /* I915_NEW_RASTERIZER */ if (i915->state.Polygon->OffsetFill) { LIS5 |= S5_GLOBAL_DEPTH_OFFSET_ENABLE; } @@ -179,7 +179,7 @@ static void upload_S5( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_S5 = { - .dirty = (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_SETUP), + .dirty = (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_RASTERIZER), .update = upload_S5 }; @@ -247,9 +247,9 @@ static void upload_S7( struct i915_context *i915 ) { float LIS7; - /* I915_NEW_SETUP + /* I915_NEW_RASTERIZER */ - LIS7 = i915->setup.offset_units; /* probably incorrect */ + LIS7 = i915->rasterizer->offset_units; /* probably incorrect */ if (LIS7 != i915->current.immediate[I915_IMMEDIATE_S7]) { i915->current.immediate[I915_IMMEDIATE_S7] = LIS7; @@ -258,7 +258,7 @@ static void upload_S7( struct i915_context *i915 ) } const struct i915_tracked_state i915_upload_S7 = { - .dirty = I915_NEW_SETUP, + .dirty = I915_NEW_RASTERIZER, .update = upload_S7 }; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 488f002531..dda758fe6a 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -101,6 +101,14 @@ struct pipe_context { void (*delete_sampler_state)(struct pipe_context *, const struct pipe_sampler_state *); + const struct pipe_rasterizer_state *(*create_rasterizer_state)( + struct pipe_context *, + const struct pipe_rasterizer_state *); + void (*bind_rasterizer_state)(struct pipe_context *, + const struct pipe_rasterizer_state *); + void (*delete_rasterizer_state)(struct pipe_context *, + const struct pipe_rasterizer_state *); + const struct pipe_depth_stencil_state * (*create_depth_stencil_state)( struct pipe_context *, const struct pipe_depth_stencil_state *); @@ -140,9 +148,6 @@ struct pipe_context { void (*set_polygon_stipple)( struct pipe_context *, const struct pipe_poly_stipple * ); - void (*set_setup_state)( struct pipe_context *, - const struct pipe_setup_state * ); - void (*set_scissor_state)( struct pipe_context *, const struct pipe_scissor_state * ); diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 30e559b594..048feede3b 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -65,9 +65,9 @@ struct pipe_buffer_handle; /** - * Primitive (point/line/tri) setup info + * Primitive (point/line/tri) rasterization info */ -struct pipe_setup_state +struct pipe_rasterizer_state { unsigned flatshade:1; unsigned light_twoside:1; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 9a8b55bb0e..7753ce40d7 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -259,6 +259,9 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.create_depth_stencil_state = softpipe_create_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.delete_rasterizer_state = softpipe_delete_rasterizer_state; softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; @@ -271,7 +274,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, 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_setup_state = softpipe_set_setup_state; softpipe->pipe.set_texture_state = softpipe_set_texture_state; softpipe->pipe.set_viewport_state = softpipe_set_viewport_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 4cbb0f891e..f1bb3d39a6 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -47,7 +47,7 @@ struct draw_stage; #define SP_NEW_VIEWPORT 0x1 -#define SP_NEW_SETUP 0x2 +#define SP_NEW_RASTERIZER 0x2 #define SP_NEW_FS 0x4 #define SP_NEW_BLEND 0x8 #define SP_NEW_CLIP 0x10 @@ -73,6 +73,7 @@ struct softpipe_context { const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_rasterizer_state *rasterizer; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -85,7 +86,6 @@ struct softpipe_context { struct pipe_shader_state vs; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_setup_state setup; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 83d317c36f..c64a4e9708 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -351,7 +351,7 @@ static boolean setup_sort_vertices( struct setup_stage *setup, * - the GLSL gl_FrontFacing fragment attribute (bool) * - two-sided stencil test */ - setup->quad.facing = (prim->det > 0.0) ^ (setup->softpipe->setup.front_winding == PIPE_WINDING_CW); + setup->quad.facing = (prim->det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW); return TRUE; } @@ -830,10 +830,10 @@ setup_line(struct draw_stage *stage, struct prim_header *prim) const int errorDec = error - dx; for (i = 0; i < dx; i++) { - if (!sp->setup.line_stipple_enable || + if (!sp->rasterizer->line_stipple_enable || stipple_test(sp->line_stipple_counter, - sp->setup.line_stipple_pattern, - sp->setup.line_stipple_factor + 1)) { + sp->rasterizer->line_stipple_pattern, + sp->rasterizer->line_stipple_factor + 1)) { plot(setup, x0, y0); } @@ -857,10 +857,10 @@ setup_line(struct draw_stage *stage, struct prim_header *prim) const int errorDec = error - dy; for (i = 0; i < dy; i++) { - if (!sp->setup.line_stipple_enable || + if (!sp->rasterizer->line_stipple_enable || stipple_test(sp->line_stipple_counter, - sp->setup.line_stipple_pattern, - sp->setup.line_stipple_factor + 1)) { + sp->rasterizer->line_stipple_pattern, + sp->rasterizer->line_stipple_factor + 1)) { plot(setup, x0, y0); } @@ -899,8 +899,8 @@ setup_point(struct draw_stage *stage, struct prim_header *prim) const int sizeAttr = setup->lookup[TGSI_ATTRIB_POINTSIZE]; const float halfSize = sizeAttr ? (0.5f * v0->data[sizeAttr][0]) - : (0.5f * setup->softpipe->setup.point_size); - const boolean round = setup->softpipe->setup.point_smooth; + : (0.5f * setup->softpipe->rasterizer->point_size); + const boolean round = setup->softpipe->rasterizer->point_smooth; const float x = v0->data[TGSI_ATTRIB_POS][0]; const float y = v0->data[TGSI_ATTRIB_POS][1]; unsigned slot, j; diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c index 1f45776d47..fc4f8328cf 100644 --- a/src/mesa/pipe/softpipe/sp_quad.c +++ b/src/mesa/pipe/softpipe/sp_quad.c @@ -36,9 +36,9 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp->quad.first = sp->quad.occlusion; } - if (sp->setup.poly_smooth || - sp->setup.line_smooth || - sp->setup.point_smooth) { + if (sp->rasterizer->poly_smooth || + sp->rasterizer->line_smooth || + sp->rasterizer->point_smooth) { sp->quad.coverage->next = sp->quad.first; sp->quad.first = sp->quad.coverage; } @@ -65,7 +65,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp) sp->quad.first = sp->quad.shade; } - if (sp->setup.poly_stipple_enable) { + if (sp->rasterizer->poly_stipple_enable) { sp->quad.polygon_stipple->next = sp->quad.first; sp->quad.first = sp->quad.polygon_stipple; } diff --git a/src/mesa/pipe/softpipe/sp_quad_coverage.c b/src/mesa/pipe/softpipe/sp_quad_coverage.c index 8dfec59350..89f50bcca2 100644 --- a/src/mesa/pipe/softpipe/sp_quad_coverage.c +++ b/src/mesa/pipe/softpipe/sp_quad_coverage.c @@ -47,9 +47,9 @@ coverage_quad(struct quad_stage *qs, struct quad_header *quad) { struct softpipe_context *softpipe = qs->softpipe; - if ((softpipe->setup.poly_smooth && quad->prim == PRIM_TRI) || - (softpipe->setup.line_smooth && quad->prim == PRIM_LINE) || - (softpipe->setup.point_smooth && quad->prim == PRIM_POINT)) { + if ((softpipe->rasterizer->poly_smooth && quad->prim == PRIM_TRI) || + (softpipe->rasterizer->line_smooth && quad->prim == PRIM_LINE) || + (softpipe->rasterizer->point_smooth && quad->prim == PRIM_POINT)) { unsigned j; for (j = 0; j < QUAD_SIZE; j++) { assert(quad->coverage[j] >= 0.0); diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index caec3b4519..62bd26c4df 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -50,7 +50,6 @@ void softpipe_bind_sampler_state(struct pipe_context *, void softpipe_delete_sampler_state(struct pipe_context *, const struct pipe_sampler_state *); - const struct pipe_depth_stencil_state * softpipe_create_depth_stencil_state(struct pipe_context *, const struct pipe_depth_stencil_state *); @@ -59,6 +58,14 @@ void softpipe_bind_depth_stencil_state(struct pipe_context *, void softpipe_delete_depth_stencil_state(struct pipe_context *, const struct pipe_depth_stencil_state *); +const struct pipe_rasterizer_state * +softpipe_create_rasterizer_state(struct pipe_context *, + const struct pipe_rasterizer_state *); +void softpipe_bind_rasterizer_state(struct pipe_context *, + const struct pipe_rasterizer_state *); +void softpipe_delete_rasterizer_state(struct pipe_context *, + const struct pipe_rasterizer_state *); + void softpipe_set_framebuffer_state( struct pipe_context *, const struct pipe_framebuffer_state * ); @@ -93,9 +100,6 @@ void softpipe_set_polygon_stipple( struct pipe_context *, void softpipe_set_scissor_state( struct pipe_context *, const struct pipe_scissor_state * ); -void softpipe_set_setup_state( struct pipe_context *, - const struct pipe_setup_state * ); - void softpipe_set_texture_state( struct pipe_context *, unsigned unit, struct pipe_mipmap_tree * ); diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 47743e185c..8c6bacf65c 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -45,7 +45,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) { const uint inputsRead = softpipe->fs.inputs_read; const interp_mode colorInterp - = softpipe->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR; + = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &softpipe->vertex_info; uint front0 = 0, back0 = 0, front1 = 0, back1 = 0; uint i; @@ -112,7 +112,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) * lighting. Edgeflag is dealt with specially by setting bits in * the vertex header. */ - if (softpipe->setup.light_twoside) { + if (softpipe->rasterizer->light_twoside) { if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, FORMAT_OMIT, colorInterp); @@ -160,7 +160,7 @@ compute_cliprect(struct softpipe_context *sp) surfHeight = sp->scissor.maxy; } - if (sp->setup.scissor) { + if (sp->rasterizer->scissor) { /* clip to scissor rect */ sp->cliprect.minx = MAX2(sp->scissor.minx, 0); sp->cliprect.miny = MAX2(sp->scissor.miny, 0); @@ -182,7 +182,7 @@ compute_cliprect(struct softpipe_context *sp) */ void softpipe_update_derived( struct softpipe_context *softpipe ) { - if (softpipe->dirty & (SP_NEW_SETUP | SP_NEW_FS)) + if (softpipe->dirty & (SP_NEW_RASTERIZER | SP_NEW_FS)) calculate_vertex_layout( softpipe ); if (softpipe->dirty & (SP_NEW_SCISSOR | @@ -194,7 +194,7 @@ void softpipe_update_derived( struct softpipe_context *softpipe ) SP_NEW_DEPTH_STENCIL | SP_NEW_ALPHA_TEST | SP_NEW_FRAMEBUFFER | - SP_NEW_SETUP | + SP_NEW_RASTERIZER | SP_NEW_FS)) sp_build_quad_pipeline(softpipe); diff --git a/src/mesa/pipe/softpipe/sp_state_setup.c b/src/mesa/pipe/softpipe/sp_state_setup.c index 4715a26f55..6788396355 100644 --- a/src/mesa/pipe/softpipe/sp_state_setup.c +++ b/src/mesa/pipe/softpipe/sp_state_setup.c @@ -31,17 +31,35 @@ #include "pipe/draw/draw_context.h" -void softpipe_set_setup_state( struct pipe_context *pipe, - const struct pipe_setup_state *setup ) + +const struct pipe_rasterizer_state * +softpipe_create_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup) +{ + struct pipe_rasterizer_state *raster = + malloc(sizeof(struct pipe_rasterizer_state)); + memcpy(raster, setup, sizeof(struct pipe_rasterizer_state)); + + return raster; +} + +void softpipe_bind_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup) { struct softpipe_context *softpipe = softpipe_context(pipe); /* pass-through to draw module */ draw_set_setup_state(softpipe->draw, setup); - memcpy( &softpipe->setup, setup, sizeof(*setup) ); + softpipe->rasterizer = setup; + + softpipe->dirty |= SP_NEW_RASTERIZER; +} - softpipe->dirty |= SP_NEW_SETUP; +void softpipe_delete_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *rasterizer) +{ + free((struct pipe_rasterizer_state*)rasterizer); } diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 99d0bcb90b..a4af3aeb20 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -53,7 +53,7 @@ static const struct st_tracked_state *atoms[] = &st_update_vs, &st_update_fs, - &st_update_setup, + &st_update_rasterizer, &st_update_polygon_stipple, &st_update_viewport, &st_update_scissor, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 0e362b1fbf..26f6514698 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -51,7 +51,7 @@ 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_setup; +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; const struct st_tracked_state st_update_scissor; diff --git a/src/mesa/state_tracker/st_atom_setup.c b/src/mesa/state_tracker/st_atom_setup.c index 09d921560d..cab8ad5cd6 100644 --- a/src/mesa/state_tracker/st_atom_setup.c +++ b/src/mesa/state_tracker/st_atom_setup.c @@ -32,6 +32,7 @@ #include "st_context.h" +#include "st_cache.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "st_atom.h" @@ -68,20 +69,21 @@ static GLboolean get_offset_flag( GLuint fill_mode, } -static void update_setup_state( struct st_context *st ) +static void update_raster_state( struct st_context *st ) { GLcontext *ctx = st->ctx; - struct pipe_setup_state setup; + struct pipe_rasterizer_state raster; + const struct pipe_rasterizer_state *cached; - memset(&setup, 0, sizeof(setup)); + memset(&raster, 0, sizeof(raster)); /* _NEW_POLYGON, _NEW_BUFFERS */ { if (ctx->Polygon.FrontFace == GL_CCW) - setup.front_winding = PIPE_WINDING_CCW; + raster.front_winding = PIPE_WINDING_CCW; else - setup.front_winding = PIPE_WINDING_CW; + raster.front_winding = PIPE_WINDING_CW; /* XXX * I think the intention here is that user-created framebuffer objects @@ -90,13 +92,13 @@ static void update_setup_state( struct st_context *st ) * But this is an implementation/driver-specific artifact - remove... */ if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) - setup.front_winding ^= PIPE_WINDING_BOTH; + raster.front_winding ^= PIPE_WINDING_BOTH; } /* _NEW_LIGHT */ if (ctx->Light.ShadeModel == GL_FLAT) - setup.flatshade = 1; + raster.flatshade = 1; /* _NEW_LIGHT | _NEW_PROGRAM * @@ -105,23 +107,23 @@ static void update_setup_state( struct st_context *st ) * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. */ if (ctx->VertexProgram._Enabled) { - setup.light_twoside = ctx->VertexProgram.TwoSideEnabled; + raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; } else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { - setup.light_twoside = 1; + raster.light_twoside = 1; } /* _NEW_POLYGON */ if (ctx->Polygon.CullFlag) { if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - setup.cull_mode = PIPE_WINDING_BOTH; + raster.cull_mode = PIPE_WINDING_BOTH; } else if (ctx->Polygon.CullFaceMode == GL_FRONT) { - setup.cull_mode = setup.front_winding; + raster.cull_mode = raster.front_winding; } else { - setup.cull_mode = setup.front_winding ^ PIPE_WINDING_BOTH; + raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; } } @@ -131,23 +133,23 @@ static void update_setup_state( struct st_context *st ) GLuint fill_front = translate_fill( ctx->Polygon.FrontMode ); GLuint fill_back = translate_fill( ctx->Polygon.BackMode ); - if (setup.front_winding == PIPE_WINDING_CW) { - setup.fill_cw = fill_front; - setup.fill_ccw = fill_back; + if (raster.front_winding == PIPE_WINDING_CW) { + raster.fill_cw = fill_front; + raster.fill_ccw = fill_back; } else { - setup.fill_cw = fill_back; - setup.fill_ccw = fill_front; + raster.fill_cw = fill_back; + raster.fill_ccw = fill_front; } /* Simplify when culling is active: */ - if (setup.cull_mode & PIPE_WINDING_CW) { - setup.fill_cw = setup.fill_ccw; + if (raster.cull_mode & PIPE_WINDING_CW) { + raster.fill_cw = raster.fill_ccw; } - if (setup.cull_mode & PIPE_WINDING_CCW) { - setup.fill_ccw = setup.fill_cw; + if (raster.cull_mode & PIPE_WINDING_CCW) { + raster.fill_ccw = raster.fill_cw; } } @@ -155,67 +157,68 @@ static void update_setup_state( struct st_context *st ) */ if (ctx->Polygon.OffsetUnits != 0.0 || ctx->Polygon.OffsetFactor != 0.0) { - setup.offset_cw = get_offset_flag( setup.fill_cw, &ctx->Polygon ); - setup.offset_ccw = get_offset_flag( setup.fill_ccw, &ctx->Polygon ); - setup.offset_units = ctx->Polygon.OffsetUnits; - setup.offset_scale = ctx->Polygon.OffsetFactor; + raster.offset_cw = get_offset_flag( raster.fill_cw, &ctx->Polygon ); + raster.offset_ccw = get_offset_flag( raster.fill_ccw, &ctx->Polygon ); + raster.offset_units = ctx->Polygon.OffsetUnits; + raster.offset_scale = ctx->Polygon.OffsetFactor; } if (ctx->Polygon.SmoothFlag) - setup.poly_smooth = 1; + raster.poly_smooth = 1; if (ctx->Polygon.StippleFlag) - setup.poly_stipple_enable = 1; + raster.poly_stipple_enable = 1; /* _NEW_BUFFERS, _NEW_POLYGON */ - if (setup.fill_cw != PIPE_POLYGON_MODE_FILL || - setup.fill_ccw != PIPE_POLYGON_MODE_FILL) + if (raster.fill_cw != PIPE_POLYGON_MODE_FILL || + raster.fill_ccw != PIPE_POLYGON_MODE_FILL) { GLfloat mrd = (ctx->DrawBuffer ? ctx->DrawBuffer->_MRD : 1.0); - setup.offset_units = ctx->Polygon.OffsetFactor * mrd; - setup.offset_scale = (ctx->Polygon.OffsetUnits * mrd * + raster.offset_units = ctx->Polygon.OffsetFactor * mrd; + raster.offset_scale = (ctx->Polygon.OffsetUnits * mrd * st->polygon_offset_scale); } /* _NEW_POINT */ - setup.point_size = ctx->Point.Size; - setup.point_smooth = ctx->Point.SmoothFlag; + raster.point_size = ctx->Point.Size; + raster.point_smooth = ctx->Point.SmoothFlag; /* _NEW_LINE */ - setup.line_width = ctx->Line.Width; - setup.line_smooth = ctx->Line.SmoothFlag; - setup.line_stipple_enable = ctx->Line.StippleFlag; - setup.line_stipple_pattern = ctx->Line.StipplePattern; + raster.line_width = ctx->Line.Width; + raster.line_smooth = ctx->Line.SmoothFlag; + raster.line_stipple_enable = ctx->Line.StippleFlag; + raster.line_stipple_pattern = ctx->Line.StipplePattern; /* GL stipple factor is in [1,256], remap to [0, 255] here */ - setup.line_stipple_factor = ctx->Line.StippleFactor - 1; + raster.line_stipple_factor = ctx->Line.StippleFactor - 1; /* _NEW_MULTISAMPLE */ if (ctx->Multisample.Enabled) - setup.multisample = 1; + raster.multisample = 1; /* _NEW_SCISSOR */ if (ctx->Scissor.Enabled) - setup.scissor = 1; + raster.scissor = 1; - if (memcmp(&setup, &st->state.setup, sizeof(setup)) != 0) { - st->state.setup = setup; - st->pipe->set_setup_state( st->pipe, &setup ); + cached = st_cached_rasterizer_state(st, &raster); + if (st->state.rasterizer != cached) { + st->state.rasterizer = cached; + st->pipe->bind_rasterizer_state( st->pipe, cached ); } } -const struct st_tracked_state st_update_setup = { - .name = "st_update_setup", +const struct st_tracked_state st_update_rasterizer = { + .name = "st_update_rasterizer", .dirty = { .mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR | _NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE), .st = 0, }, - .update = update_setup_state + .update = update_raster_state }; diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index 64c03be99d..a687c15587 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -93,3 +93,21 @@ struct pipe_depth_stencil_state * st_cached_depth_stencil_state( } return (struct pipe_depth_stencil_state*)(cso_hash_iter_data(iter)); } + +struct pipe_rasterizer_state * st_cached_rasterizer_state( + struct st_context *st, + const struct pipe_rasterizer_state *raster) +{ + unsigned hash_key = cso_construct_key((void*)raster, + sizeof(struct pipe_rasterizer_state)); + struct cso_hash_iter iter = cso_find_state_template(st->cache, + hash_key, CSO_RASTERIZER, + (void*)raster); + if (cso_hash_iter_is_null(iter)) { + const struct pipe_rasterizer_state *created_state = + st->pipe->create_rasterizer_state(st->pipe, raster); + iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER, + (void*)created_state); + } + return (struct pipe_rasterizer_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 78cb2e774e..a06af31123 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -47,6 +47,10 @@ struct pipe_sampler_state * st_cached_sampler_state( struct pipe_depth_stencil_state *st_cached_depth_stencil_state( struct st_context *st, - const struct pipe_depth_stencil_state *sampler); + const struct pipe_depth_stencil_state *depth_stencil); + +struct pipe_rasterizer_state *st_cached_rasterizer_state( + struct st_context *st, + const struct pipe_rasterizer_state *raster); #endif diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index e9aabd15b5..584bc1cc2a 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -329,16 +329,18 @@ clear_with_quad(GLcontext *ctx, /* setup state: nothing */ { - struct pipe_setup_state setup; - memset(&setup, 0, sizeof(setup)); + struct pipe_rasterizer_state raster; + const struct pipe_rasterizer_state *cached; + memset(&raster, 0, sizeof(raster)); #if 0 /* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD * that matches the scissor bounds. */ if (ctx->Scissor.Enabled) - setup.scissor = 1; + raster.scissor = 1; #endif - pipe->set_setup_state(pipe, &setup); + cached = st_cached_rasterizer_state(ctx->st, &raster); + pipe->bind_rasterizer_state(pipe, cached); } /* fragment shader state: color pass-through program */ @@ -394,7 +396,7 @@ clear_with_quad(GLcontext *ctx, 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->set_setup_state(pipe, &st->state.setup); + pipe->bind_rasterizer_state(pipe, st->state.rasterizer); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); /* OR: st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index a0012e3a8c..78ede8e225 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -316,11 +316,13 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* setup state: just scissor */ { - struct pipe_setup_state setup; + struct pipe_rasterizer_state setup; + struct pipe_rasterizer_state *cached; memset(&setup, 0, sizeof(setup)); if (ctx->Scissor.Enabled) setup.scissor = 1; - pipe->set_setup_state(pipe, &setup); + cached = st_cached_rasterizer_state(ctx->st, &setup); + pipe->bind_rasterizer_state(pipe, cached); } /* fragment shader state: TEX lookup program */ @@ -400,7 +402,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, draw_quad(ctx, x0, y0, z, x1, y1); /* restore GL state */ - pipe->set_setup_state(pipe, &ctx->st->state.setup); + 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->set_texture_state(pipe, unit, ctx->st->state.texture[unit]); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 7c887d0b55..516d319a6e 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -77,6 +77,7 @@ struct st_context const struct pipe_blend_state *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_rasterizer_state *rasterizer; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -88,7 +89,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_setup_state setup; struct pipe_shader_state fs; struct pipe_shader_state vs; struct pipe_viewport_state viewport; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 69f4b7fa5b..1ea7799021 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -394,7 +394,7 @@ 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_setup_state(draw, &st->state.setup); + draw_set_setup_state(draw, st->state.rasterizer); draw_set_vertex_shader(draw, &st->state.vs); /* XXX need to set vertex info too */ -- cgit v1.2.3 From de69fc1703f79e5c97e66b654de7a93b7abce8f0 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 18 Sep 2007 10:02:16 -0400 Subject: Finishing up rename of the setup state to the rasterizer state. --- src/mesa/pipe/draw/draw_context.c | 14 +- src/mesa/pipe/draw/draw_context.h | 8 +- src/mesa/pipe/draw/draw_private.h | 2 +- src/mesa/pipe/i915simple/i915_context.c | 2 +- src/mesa/pipe/i915simple/i915_state.c | 2 +- src/mesa/pipe/softpipe/Makefile | 2 +- src/mesa/pipe/softpipe/sp_context.c | 2 +- src/mesa/pipe/softpipe/sp_state_rasterizer.c | 65 ++++++++ src/mesa/pipe/softpipe/sp_state_setup.c | 65 -------- src/mesa/sources | 2 +- src/mesa/state_tracker/st_atom_rasterizer.c | 224 +++++++++++++++++++++++++++ src/mesa/state_tracker/st_atom_setup.c | 224 --------------------------- src/mesa/state_tracker/st_cb_feedback.c | 4 +- src/mesa/state_tracker/st_draw.c | 2 +- 14 files changed, 309 insertions(+), 309 deletions(-) create mode 100644 src/mesa/pipe/softpipe/sp_state_rasterizer.c delete mode 100644 src/mesa/pipe/softpipe/sp_state_setup.c create mode 100644 src/mesa/state_tracker/st_atom_rasterizer.c delete mode 100644 src/mesa/state_tracker/st_atom_setup.c (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index f3236ad59e..9acbc53742 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -89,7 +89,7 @@ void draw_destroy( struct draw_context *draw ) */ static void validate_pipeline( struct draw_context *draw ) { - struct draw_stage *next = draw->pipeline.setup; + struct draw_stage *next = draw->pipeline.rasterize; /* * NOTE: we build up the pipeline in end-to-start order. @@ -157,11 +157,11 @@ void draw_set_feedback_state( struct draw_context *draw, /** - * Register new primitive setup/rendering state. + * Register new primitive rasterization/rendering state. * This causes the drawing pipeline to be rebuilt. */ -void draw_set_setup_state( struct draw_context *draw, - const struct pipe_rasterizer_state *raster ) +void draw_set_rasterizer_state( struct draw_context *draw, + const struct pipe_rasterizer_state *raster ) { draw->rasterizer = raster; validate_pipeline( draw ); @@ -172,10 +172,10 @@ void draw_set_setup_state( struct draw_context *draw, * Plug in the primitive rendering/rasterization stage. * This is provided by the device driver. */ -void draw_set_setup_stage( struct draw_context *draw, - struct draw_stage *stage ) +void draw_set_rasterize_stage( struct draw_context *draw, + struct draw_stage *stage ) { - draw->pipeline.setup = stage; + draw->pipeline.rasterize = stage; } diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 2714252fc5..4eb59aab01 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -86,11 +86,11 @@ void draw_set_clip_state( struct draw_context *pipe, void draw_set_feedback_state( struct draw_context *draw, const struct pipe_feedback_state * ); -void draw_set_setup_state( struct draw_context *draw, - const struct pipe_rasterizer_state *raster ); +void draw_set_rasterizer_state( struct draw_context *draw, + const struct pipe_rasterizer_state *raster ); -void draw_set_setup_stage( struct draw_context *draw, - struct draw_stage *stage ); +void draw_set_rasterize_stage( struct draw_context *draw, + struct draw_stage *stage ); unsigned draw_prim_info( unsigned prim, unsigned *first, unsigned *incr ); diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index fb0aaff40d..bd8c11eb94 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -133,7 +133,7 @@ struct draw_context struct draw_stage *twoside; struct draw_stage *offset; struct draw_stage *unfilled; - struct draw_stage *setup; /* aka render/rasterize */ + struct draw_stage *rasterize; } pipeline; /* pipe state that we need: */ diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index 6e48b3bd03..36372898ce 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -285,7 +285,7 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys, */ i915->draw = draw_create(); assert(i915->draw); - draw_set_setup_stage(i915->draw, i915_draw_render_stage(i915)); + draw_set_rasterize_stage(i915->draw, i915_draw_render_stage(i915)); i915_init_region_functions(i915); i915_init_surface_functions(i915); diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 00764902bc..1dfa10ab28 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -308,7 +308,7 @@ static void i915_bind_rasterizer_state( struct pipe_context *pipe, i915->rasterizer = setup; /* pass-through to draw module */ - draw_set_setup_state(i915->draw, setup); + draw_set_rasterizer_state(i915->draw, setup); i915->dirty |= I915_NEW_RASTERIZER; } diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile index 401df1cfb7..0335f56b99 100644 --- a/src/mesa/pipe/softpipe/Makefile +++ b/src/mesa/pipe/softpipe/Makefile @@ -29,7 +29,7 @@ DRIVER_SOURCES = \ sp_state_feedback.c \ sp_state_fs.c \ sp_state_sampler.c \ - sp_state_setup.c \ + sp_state_rasterizer.c \ sp_state_surface.c \ sp_state_vertex.c \ sp_tex_layout.c \ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 7753ce40d7..cf5fc2227e 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -318,7 +318,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, */ softpipe->draw = draw_create(); assert(softpipe->draw); - draw_set_setup_stage(softpipe->draw, sp_draw_render_stage(softpipe)); + draw_set_rasterize_stage(softpipe->draw, sp_draw_render_stage(softpipe)); sp_init_region_functions(softpipe); sp_init_surface_functions(softpipe); diff --git a/src/mesa/pipe/softpipe/sp_state_rasterizer.c b/src/mesa/pipe/softpipe/sp_state_rasterizer.c new file mode 100644 index 0000000000..d832adb91b --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_state_rasterizer.c @@ -0,0 +1,65 @@ +/************************************************************************** + * + * Copyright 2003 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. + * + **************************************************************************/ + +#include "pipe/p_defines.h" +#include "sp_context.h" +#include "sp_state.h" +#include "pipe/draw/draw_context.h" + + + +const struct pipe_rasterizer_state * +softpipe_create_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup) +{ + struct pipe_rasterizer_state *raster = + malloc(sizeof(struct pipe_rasterizer_state)); + memcpy(raster, setup, sizeof(struct pipe_rasterizer_state)); + + return raster; +} + +void softpipe_bind_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + + /* pass-through to draw module */ + draw_set_rasterizer_state(softpipe->draw, setup); + + softpipe->rasterizer = setup; + + softpipe->dirty |= SP_NEW_RASTERIZER; +} + +void softpipe_delete_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *rasterizer) +{ + free((struct pipe_rasterizer_state*)rasterizer); +} + + diff --git a/src/mesa/pipe/softpipe/sp_state_setup.c b/src/mesa/pipe/softpipe/sp_state_setup.c deleted file mode 100644 index 6788396355..0000000000 --- a/src/mesa/pipe/softpipe/sp_state_setup.c +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 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. - * - **************************************************************************/ - -#include "pipe/p_defines.h" -#include "sp_context.h" -#include "sp_state.h" -#include "pipe/draw/draw_context.h" - - - -const struct pipe_rasterizer_state * -softpipe_create_rasterizer_state(struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup) -{ - struct pipe_rasterizer_state *raster = - malloc(sizeof(struct pipe_rasterizer_state)); - memcpy(raster, setup, sizeof(struct pipe_rasterizer_state)); - - return raster; -} - -void softpipe_bind_rasterizer_state(struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup) -{ - struct softpipe_context *softpipe = softpipe_context(pipe); - - /* pass-through to draw module */ - draw_set_setup_state(softpipe->draw, setup); - - softpipe->rasterizer = setup; - - softpipe->dirty |= SP_NEW_RASTERIZER; -} - -void softpipe_delete_rasterizer_state(struct pipe_context *pipe, - const struct pipe_rasterizer_state *rasterizer) -{ - free((struct pipe_rasterizer_state*)rasterizer); -} - - diff --git a/src/mesa/sources b/src/mesa/sources index 017a0167bd..0d4fdc15f4 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -203,7 +203,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_atom_fs.c \ state_tracker/st_atom_sampler.c \ state_tracker/st_atom_scissor.c \ - state_tracker/st_atom_setup.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 \ diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c new file mode 100644 index 0000000000..cab8ad5cd6 --- /dev/null +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -0,0 +1,224 @@ +/************************************************************************** + * + * 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 "st_context.h" +#include "st_cache.h" +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "st_atom.h" + +static GLuint translate_fill( GLenum mode ) +{ + switch (mode) { + case GL_POINT: + return PIPE_POLYGON_MODE_POINT; + case GL_LINE: + return PIPE_POLYGON_MODE_LINE; + case GL_FILL: + return PIPE_POLYGON_MODE_FILL; + default: + assert(0); + return 0; + } +} + +static GLboolean get_offset_flag( GLuint fill_mode, + const struct gl_polygon_attrib *p ) +{ + switch (fill_mode) { + case PIPE_POLYGON_MODE_POINT: + return p->OffsetPoint; + case PIPE_POLYGON_MODE_LINE: + return p->OffsetLine; + case PIPE_POLYGON_MODE_FILL: + return p->OffsetFill; + default: + assert(0); + return 0; + } +} + + +static void update_raster_state( struct st_context *st ) +{ + GLcontext *ctx = st->ctx; + struct pipe_rasterizer_state raster; + const struct pipe_rasterizer_state *cached; + + memset(&raster, 0, sizeof(raster)); + + /* _NEW_POLYGON, _NEW_BUFFERS + */ + { + if (ctx->Polygon.FrontFace == GL_CCW) + raster.front_winding = PIPE_WINDING_CCW; + else + raster.front_winding = PIPE_WINDING_CW; + + /* XXX + * I think the intention here is that user-created framebuffer objects + * use Y=0=TOP layout instead of OpenGL's normal Y=0=bottom layout. + * Flipping Y changes CW to CCW and vice-versa. + * But this is an implementation/driver-specific artifact - remove... + */ + if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) + raster.front_winding ^= PIPE_WINDING_BOTH; + } + + /* _NEW_LIGHT + */ + if (ctx->Light.ShadeModel == GL_FLAT) + raster.flatshade = 1; + + /* _NEW_LIGHT | _NEW_PROGRAM + * + * Back-face colors can come from traditional lighting (when + * GL_LIGHT_MODEL_TWO_SIDE is set) or from vertex programs (when + * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. + */ + if (ctx->VertexProgram._Enabled) { + raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; + } + else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { + raster.light_twoside = 1; + } + + /* _NEW_POLYGON + */ + if (ctx->Polygon.CullFlag) { + if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { + raster.cull_mode = PIPE_WINDING_BOTH; + } + else if (ctx->Polygon.CullFaceMode == GL_FRONT) { + raster.cull_mode = raster.front_winding; + } + else { + raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; + } + } + + /* _NEW_POLYGON + */ + { + GLuint fill_front = translate_fill( ctx->Polygon.FrontMode ); + GLuint fill_back = translate_fill( ctx->Polygon.BackMode ); + + if (raster.front_winding == PIPE_WINDING_CW) { + raster.fill_cw = fill_front; + raster.fill_ccw = fill_back; + } + else { + raster.fill_cw = fill_back; + raster.fill_ccw = fill_front; + } + + /* Simplify when culling is active: + */ + if (raster.cull_mode & PIPE_WINDING_CW) { + raster.fill_cw = raster.fill_ccw; + } + + if (raster.cull_mode & PIPE_WINDING_CCW) { + raster.fill_ccw = raster.fill_cw; + } + } + + /* _NEW_POLYGON + */ + if (ctx->Polygon.OffsetUnits != 0.0 || + ctx->Polygon.OffsetFactor != 0.0) { + raster.offset_cw = get_offset_flag( raster.fill_cw, &ctx->Polygon ); + raster.offset_ccw = get_offset_flag( raster.fill_ccw, &ctx->Polygon ); + raster.offset_units = ctx->Polygon.OffsetUnits; + raster.offset_scale = ctx->Polygon.OffsetFactor; + } + + if (ctx->Polygon.SmoothFlag) + raster.poly_smooth = 1; + + if (ctx->Polygon.StippleFlag) + raster.poly_stipple_enable = 1; + + + /* _NEW_BUFFERS, _NEW_POLYGON + */ + if (raster.fill_cw != PIPE_POLYGON_MODE_FILL || + raster.fill_ccw != PIPE_POLYGON_MODE_FILL) + { + GLfloat mrd = (ctx->DrawBuffer ? + ctx->DrawBuffer->_MRD : + 1.0); + + raster.offset_units = ctx->Polygon.OffsetFactor * mrd; + raster.offset_scale = (ctx->Polygon.OffsetUnits * mrd * + st->polygon_offset_scale); + } + + /* _NEW_POINT + */ + raster.point_size = ctx->Point.Size; + raster.point_smooth = ctx->Point.SmoothFlag; + + /* _NEW_LINE + */ + raster.line_width = ctx->Line.Width; + raster.line_smooth = ctx->Line.SmoothFlag; + raster.line_stipple_enable = ctx->Line.StippleFlag; + raster.line_stipple_pattern = ctx->Line.StipplePattern; + /* GL stipple factor is in [1,256], remap to [0, 255] here */ + raster.line_stipple_factor = ctx->Line.StippleFactor - 1; + + /* _NEW_MULTISAMPLE */ + if (ctx->Multisample.Enabled) + raster.multisample = 1; + + /* _NEW_SCISSOR */ + if (ctx->Scissor.Enabled) + raster.scissor = 1; + + cached = st_cached_rasterizer_state(st, &raster); + if (st->state.rasterizer != cached) { + st->state.rasterizer = cached; + st->pipe->bind_rasterizer_state( st->pipe, cached ); + } +} + +const struct st_tracked_state st_update_rasterizer = { + .name = "st_update_rasterizer", + .dirty = { + .mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR | + _NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE), + .st = 0, + }, + .update = update_raster_state +}; diff --git a/src/mesa/state_tracker/st_atom_setup.c b/src/mesa/state_tracker/st_atom_setup.c deleted file mode 100644 index cab8ad5cd6..0000000000 --- a/src/mesa/state_tracker/st_atom_setup.c +++ /dev/null @@ -1,224 +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: - * Keith Whitwell - */ - - -#include "st_context.h" -#include "st_cache.h" -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "st_atom.h" - -static GLuint translate_fill( GLenum mode ) -{ - switch (mode) { - case GL_POINT: - return PIPE_POLYGON_MODE_POINT; - case GL_LINE: - return PIPE_POLYGON_MODE_LINE; - case GL_FILL: - return PIPE_POLYGON_MODE_FILL; - default: - assert(0); - return 0; - } -} - -static GLboolean get_offset_flag( GLuint fill_mode, - const struct gl_polygon_attrib *p ) -{ - switch (fill_mode) { - case PIPE_POLYGON_MODE_POINT: - return p->OffsetPoint; - case PIPE_POLYGON_MODE_LINE: - return p->OffsetLine; - case PIPE_POLYGON_MODE_FILL: - return p->OffsetFill; - default: - assert(0); - return 0; - } -} - - -static void update_raster_state( struct st_context *st ) -{ - GLcontext *ctx = st->ctx; - struct pipe_rasterizer_state raster; - const struct pipe_rasterizer_state *cached; - - memset(&raster, 0, sizeof(raster)); - - /* _NEW_POLYGON, _NEW_BUFFERS - */ - { - if (ctx->Polygon.FrontFace == GL_CCW) - raster.front_winding = PIPE_WINDING_CCW; - else - raster.front_winding = PIPE_WINDING_CW; - - /* XXX - * I think the intention here is that user-created framebuffer objects - * use Y=0=TOP layout instead of OpenGL's normal Y=0=bottom layout. - * Flipping Y changes CW to CCW and vice-versa. - * But this is an implementation/driver-specific artifact - remove... - */ - if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) - raster.front_winding ^= PIPE_WINDING_BOTH; - } - - /* _NEW_LIGHT - */ - if (ctx->Light.ShadeModel == GL_FLAT) - raster.flatshade = 1; - - /* _NEW_LIGHT | _NEW_PROGRAM - * - * Back-face colors can come from traditional lighting (when - * GL_LIGHT_MODEL_TWO_SIDE is set) or from vertex programs (when - * GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here. - */ - if (ctx->VertexProgram._Enabled) { - raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; - } - else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { - raster.light_twoside = 1; - } - - /* _NEW_POLYGON - */ - if (ctx->Polygon.CullFlag) { - if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - raster.cull_mode = PIPE_WINDING_BOTH; - } - else if (ctx->Polygon.CullFaceMode == GL_FRONT) { - raster.cull_mode = raster.front_winding; - } - else { - raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; - } - } - - /* _NEW_POLYGON - */ - { - GLuint fill_front = translate_fill( ctx->Polygon.FrontMode ); - GLuint fill_back = translate_fill( ctx->Polygon.BackMode ); - - if (raster.front_winding == PIPE_WINDING_CW) { - raster.fill_cw = fill_front; - raster.fill_ccw = fill_back; - } - else { - raster.fill_cw = fill_back; - raster.fill_ccw = fill_front; - } - - /* Simplify when culling is active: - */ - if (raster.cull_mode & PIPE_WINDING_CW) { - raster.fill_cw = raster.fill_ccw; - } - - if (raster.cull_mode & PIPE_WINDING_CCW) { - raster.fill_ccw = raster.fill_cw; - } - } - - /* _NEW_POLYGON - */ - if (ctx->Polygon.OffsetUnits != 0.0 || - ctx->Polygon.OffsetFactor != 0.0) { - raster.offset_cw = get_offset_flag( raster.fill_cw, &ctx->Polygon ); - raster.offset_ccw = get_offset_flag( raster.fill_ccw, &ctx->Polygon ); - raster.offset_units = ctx->Polygon.OffsetUnits; - raster.offset_scale = ctx->Polygon.OffsetFactor; - } - - if (ctx->Polygon.SmoothFlag) - raster.poly_smooth = 1; - - if (ctx->Polygon.StippleFlag) - raster.poly_stipple_enable = 1; - - - /* _NEW_BUFFERS, _NEW_POLYGON - */ - if (raster.fill_cw != PIPE_POLYGON_MODE_FILL || - raster.fill_ccw != PIPE_POLYGON_MODE_FILL) - { - GLfloat mrd = (ctx->DrawBuffer ? - ctx->DrawBuffer->_MRD : - 1.0); - - raster.offset_units = ctx->Polygon.OffsetFactor * mrd; - raster.offset_scale = (ctx->Polygon.OffsetUnits * mrd * - st->polygon_offset_scale); - } - - /* _NEW_POINT - */ - raster.point_size = ctx->Point.Size; - raster.point_smooth = ctx->Point.SmoothFlag; - - /* _NEW_LINE - */ - raster.line_width = ctx->Line.Width; - raster.line_smooth = ctx->Line.SmoothFlag; - raster.line_stipple_enable = ctx->Line.StippleFlag; - raster.line_stipple_pattern = ctx->Line.StipplePattern; - /* GL stipple factor is in [1,256], remap to [0, 255] here */ - raster.line_stipple_factor = ctx->Line.StippleFactor - 1; - - /* _NEW_MULTISAMPLE */ - if (ctx->Multisample.Enabled) - raster.multisample = 1; - - /* _NEW_SCISSOR */ - if (ctx->Scissor.Enabled) - raster.scissor = 1; - - cached = st_cached_rasterizer_state(st, &raster); - if (st->state.rasterizer != cached) { - st->state.rasterizer = cached; - st->pipe->bind_rasterizer_state( st->pipe, cached ); - } -} - -const struct st_tracked_state st_update_rasterizer = { - .name = "st_update_rasterizer", - .dirty = { - .mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR | - _NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE), - .st = 0, - }, - .update = update_raster_state -}; diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index b97b2bb027..8e8084fe59 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -285,14 +285,14 @@ st_RenderMode(GLcontext *ctx, GLenum newMode ) else if (newMode == GL_SELECT) { if (!st->selection_stage) st->selection_stage = draw_glselect_stage(ctx, draw); - draw_set_setup_stage(draw, st->selection_stage); + draw_set_rasterize_stage(draw, st->selection_stage); /* Plug in new vbo draw function */ vbo->draw_prims = st_feedback_draw_vbo; } else { if (!st->feedback_stage) st->feedback_stage = draw_glfeedback_stage(ctx, draw); - draw_set_setup_stage(draw, st->feedback_stage); + draw_set_rasterize_stage(draw, st->feedback_stage); /* Plug in new vbo draw function */ vbo->draw_prims = st_feedback_draw_vbo; } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 1ea7799021..f68e449f07 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -394,7 +394,7 @@ 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_setup_state(draw, st->state.rasterizer); + draw_set_rasterizer_state(draw, st->state.rasterizer); draw_set_vertex_shader(draw, &st->state.vs); /* XXX need to set vertex info too */ -- 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_draw.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 bb611c5f1f6aec7ac51d4fa3301422b47f6de795 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 18 Sep 2007 19:37:36 -0600 Subject: Checkpoint: rework shader input/output register mapping. This is a step toward removing TGSI_ATTRIB_ tokens. Basically, when translating Mesa programs to TGSI programs, pass in input and output register re-maps, plus interpolation info. There's some known breakage (cubemap.c) so more to be done... --- src/mesa/pipe/draw/draw_vertex_fetch.c | 39 +++++------ src/mesa/pipe/draw/draw_vertex_shader.c | 14 +++- src/mesa/pipe/p_state.h | 3 + src/mesa/pipe/softpipe/sp_prim_setup.c | 8 +++ src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c | 72 +++++++++++++++------ src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h | 5 ++ src/mesa/state_tracker/st_atom_fs.c | 23 ++++++- src/mesa/state_tracker/st_atom_vs.c | 46 +++++++++++-- src/mesa/state_tracker/st_cb_clear.c | 21 +++++- src/mesa/state_tracker/st_cb_drawpixels.c | 15 ++++- src/mesa/state_tracker/st_draw.c | 103 ++++++++++++++++-------------- src/mesa/state_tracker/st_program.h | 17 +++-- 12 files changed, 260 insertions(+), 106 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index 0dbbdf17f2..ce402d681f 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -67,6 +67,10 @@ fetch_attrib4(const void *ptr, unsigned format, float attrib[4]) } } + +/** + * Fetch vertex attributes for 'count' vertices. + */ void draw_vertex_fetch( struct draw_context *draw, struct tgsi_exec_machine *machine, const unsigned *elts, @@ -74,27 +78,26 @@ void draw_vertex_fetch( struct draw_context *draw, { unsigned j; - - /* load machine inputs */ + /* loop over vertices */ for (j = 0; j < count; j++) { - unsigned attr; - for (attr = 0; attr < 16; attr++) { - if (draw->vertex_shader.inputs_read & (1 << attr)) { - unsigned buf = draw->vertex_element[attr].vertex_buffer_index; - const void *src - = (const void *) ((const ubyte *) draw->mapped_vbuffer[buf] - + draw->vertex_buffer[buf].buffer_offset - + draw->vertex_element[attr].src_offset - + elts[j] * draw->vertex_buffer[buf].pitch); - float p[4]; + uint attr; + /* loop over vertex attributes (vertex shader inputs) */ + for (attr = 0; attr < draw->vertex_shader.num_inputs; attr++) { + + unsigned buf = draw->vertex_element[attr].vertex_buffer_index; + const void *src + = (const void *) ((const ubyte *) draw->mapped_vbuffer[buf] + + draw->vertex_buffer[buf].buffer_offset + + draw->vertex_element[attr].src_offset + + elts[j] * draw->vertex_buffer[buf].pitch); + float p[4]; - fetch_attrib4(src, draw->vertex_element[attr].src_format, p); + fetch_attrib4(src, draw->vertex_element[attr].src_format, p); - machine->Inputs[attr].xyzw[0].f[j] = p[0]; /*X*/ - machine->Inputs[attr].xyzw[1].f[j] = p[1]; /*Y*/ - machine->Inputs[attr].xyzw[2].f[j] = p[2]; /*Z*/ - machine->Inputs[attr].xyzw[3].f[j] = p[3]; /*W*/ - } + machine->Inputs[attr].xyzw[0].f[j] = p[0]; /*X*/ + machine->Inputs[attr].xyzw[1].f[j] = p[1]; /*Y*/ + machine->Inputs[attr].xyzw[2].f[j] = p[2]; /*Z*/ + machine->Inputs[attr].xyzw[3].f[j] = p[3]; /*W*/ } } } diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index 8effc74cbe..cb6c605b8d 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -114,7 +114,6 @@ run_vertex_program(struct draw_context *draw, draw_vertex_fetch( draw, &machine, elts, count ); - /* run shader */ if( draw->vertex_shader.executable != NULL ) { #if defined(USE_X86_ASM) || defined(SLANG_X86) @@ -159,14 +158,23 @@ run_vertex_program(struct draw_context *draw, vOut[j]->data[0][2] = z * scale[2] + trans[2]; vOut[j]->data[0][3] = w; - /* remaining attributes are packed into sequential post-transform + /* Remaining attributes are packed into sequential post-transform * vertex attrib slots. + * Skip 0 since we just did it above. + * Subtract two because of the VERTEX_HEADER, CLIP_POS attribs. */ - for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) { + for (slot = 1; slot < draw->vertex_info.num_attribs - 2; slot++) { vOut[j]->data[slot][0] = machine.Outputs[slot].xyzw[0].f[j]; vOut[j]->data[slot][1] = machine.Outputs[slot].xyzw[1].f[j]; vOut[j]->data[slot][2] = machine.Outputs[slot].xyzw[2].f[j]; vOut[j]->data[slot][3] = machine.Outputs[slot].xyzw[3].f[j]; + /* + printf("output %d: %f %f %f %f\n", slot, + vOut[j]->data[slot][0], + vOut[j]->data[slot][1], + vOut[j]->data[slot][2], + vOut[j]->data[slot][3]); + */ } } /* loop over vertices */ } diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 048feede3b..d2cc76a59b 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -144,6 +144,9 @@ struct pipe_shader_state { unsigned outputs_written; /**< TGSI_ATTRIB_ bits */ const struct tgsi_token *tokens; void *executable; + + uint num_inputs; + uint num_outputs; }; struct pipe_depth_stencil_state diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index d0baf0734b..8a4be79d11 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -448,6 +448,14 @@ static void tri_persp_coeff( struct setup_stage *setup, float a = setup->ebot.dy * majda - botda * setup->emaj.dy; float b = setup->emaj.dx * botda - majda * setup->ebot.dx; + /* + printf("tri persp %d,%d: %f %f %f\n", slot, i, + setup->vmin->data[slot][i], + setup->vmid->data[slot][i], + setup->vmax->data[slot][i] + ); + */ + assert(slot < TGSI_ATTRIB_MAX); assert(i <= 3); diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c index 2820706537..1f8d937bc6 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c @@ -211,6 +211,7 @@ tgsi_mesa_translate_fragment_output(GLuint attrib) } +#if 01 uint tgsi_mesa_translate_vertex_input_mask(GLbitfield mask) { @@ -224,7 +225,7 @@ tgsi_mesa_translate_vertex_input_mask(GLbitfield mask) } return tgsiMask; } - +#endif uint tgsi_mesa_translate_vertex_output_mask(GLbitfield mask) @@ -318,7 +319,9 @@ map_register_file_index( GLuint processor, GLuint file, GLuint index, - GLbitfield usage_bitmask ) + GLbitfield usage_bitmask, + const GLuint inputMapping[], + const GLuint outputMapping[]) { GLuint mapped_index; GLuint i; @@ -337,6 +340,12 @@ map_register_file_index( * etc. */ assert( index < 32 ); + if (inputMapping) { + printf("New map %d input %d to %d\n", processor, index, + inputMapping[index]); + return inputMapping[index]; + } + assert( usage_bitmask & (1 << index) ); mapped_index = 0; for( i = 0; i < index; i++ ) { @@ -344,7 +353,7 @@ map_register_file_index( mapped_index++; } } - printf("Map input %d to %d\n", index, mapped_index); + printf("Map %d input %d to %d\n", processor, index, mapped_index); break; case TGSI_FILE_OUTPUT: @@ -372,6 +381,8 @@ map_register_file_index( mapped_index++; } } + printf("Map VP output from %d to %d\n", index, mapped_index); + assert(outputMapping[index] == mapped_index); } break; @@ -443,6 +454,8 @@ compile_instruction( struct tgsi_full_instruction *fullinst, GLuint inputs_read, GLuint outputs_written, + const GLuint inputMapping[], + const GLuint outputMapping[], GLuint preamble_size, GLuint processor ) { @@ -462,7 +475,9 @@ compile_instruction( processor, fulldst->DstRegister.File, inst->DstReg.Index, - outputs_written + outputs_written, + NULL, + outputMapping ); fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask ); @@ -475,7 +490,9 @@ compile_instruction( processor, fullsrc->SrcRegister.File, inst->SrcReg[i].Index, - inputs_read ); + inputs_read, + inputMapping, + outputMapping ); for( j = 0; j < 4; j++ ) { GLuint swz; @@ -789,9 +806,20 @@ make_frag_output_decl( return 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. + * + */ GLboolean tgsi_mesa_compile_fp_program( const struct gl_fragment_program *program, + const GLuint inputMapping[], + const GLuint interpMode[], + const GLuint outputMapping[], struct tgsi_token *tokens, GLuint maxTokens ) { @@ -800,8 +828,10 @@ tgsi_mesa_compile_fp_program( struct tgsi_processor *processor; struct tgsi_full_declaration fulldecl; struct tgsi_full_instruction fullinst; + /* struct tgsi_full_dst_register *fulldst; struct tgsi_full_src_register *fullsrc; + */ GLuint inputs_read; GLboolean reads_wpos; GLuint preamble_size = 0; @@ -822,7 +852,7 @@ tgsi_mesa_compile_fp_program( /* * Declare input attributes. Note that we do not interpolate fragment position. */ - + reads_wpos = 1; /* Fragment position. */ if( reads_wpos ) { fulldecl = make_frag_input_decl( @@ -853,20 +883,16 @@ tgsi_mesa_compile_fp_program( for( i = 1; i < 32; i++ ) { if( inputs_read & (1 << i) ) { count++; + fulldecl = make_frag_input_decl(count, + count, + interpMode[i], + TGSI_WRITEMASK_XYZW ); + ti += tgsi_build_full_declaration(&fulldecl, + &tokens[ti], + header, + maxTokens - ti ); } - } - if( count > 0 ) { - fulldecl = make_frag_input_decl( - 1, - 1 + count - 1, - TGSI_INTERPOLATE_PERSPECTIVE, - TGSI_WRITEMASK_XYZW ); - ti += tgsi_build_full_declaration( - &fulldecl, - &tokens[ti], - header, - maxTokens - ti ); - } + } /* * Declare output attributes. @@ -932,6 +958,8 @@ tgsi_mesa_compile_fp_program( &fullinst, inputs_read, ~0, /*outputs_written*/ + inputMapping, + outputMapping, preamble_size, TGSI_PROCESSOR_FRAGMENT ) ) { assert( i == program->Base.NumInstructions - 1 ); @@ -955,8 +983,10 @@ tgsi_mesa_compile_fp_program( GLboolean tgsi_mesa_compile_vp_program( const struct gl_vertex_program *program, + const GLuint inputMapping[], + const GLuint outputMapping[], struct tgsi_token *tokens, - GLuint maxTokens ) + GLuint maxTokens) { GLuint i, ti; struct tgsi_header *header; @@ -983,6 +1013,8 @@ tgsi_mesa_compile_vp_program( &fullinst, inputs_read, outputs_written, + inputMapping, + outputMapping, 0, TGSI_PROCESSOR_VERTEX ) ) { assert( i == program->Base.NumInstructions - 1 ); diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h index fda3fa397f..017cfce72e 100644 --- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h +++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.h @@ -10,12 +10,17 @@ struct tgsi_token; GLboolean tgsi_mesa_compile_fp_program( const struct gl_fragment_program *program, + const GLuint inputMapping[], + const GLuint interpMode[], + const GLuint outputMapping[], struct tgsi_token *tokens, GLuint maxTokens ); GLboolean tgsi_mesa_compile_vp_program( const struct gl_vertex_program *program, + const GLuint inputMapping[], + const GLuint outputMapping[], struct tgsi_token *tokens, GLuint maxTokens ); diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index dc3e5258d8..3df2c6750a 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -42,17 +42,34 @@ #include "st_atom.h" #include "st_program.h" -#define TGSI_DEBUG 0 +#define TGSI_DEBUG 1 static void compile_fs( struct st_context *st ) { + /* 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; struct pipe_shader_state fs; struct pipe_shader_state *cached; + GLuint interpMode[16]; /* XXX size? */ + GLuint i; + + 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; + } + else { + interpMode[i] = TGSI_INTERPOLATE_PERSPECTIVE; + } + } + } /* XXX: fix static allocation of tokens: */ - tgsi_mesa_compile_fp_program( &fp->Base, fp->tokens, ST_FP_MAX_TOKENS ); + tgsi_mesa_compile_fp_program( &fp->Base, NULL, interpMode, + outputMapping, + fp->tokens, ST_FP_MAX_TOKENS ); memset(&fs, 0, sizeof(fs)); fs.inputs_read @@ -64,7 +81,7 @@ static void compile_fs( struct st_context *st ) fp->fsx = cached; if (TGSI_DEBUG) - tgsi_dump( fp->tokens, TGSI_DUMP_VERBOSE ); + tgsi_dump( fp->tokens, 0/*TGSI_DUMP_VERBOSE*/ ); fp->dirty = 0; } diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c index 8f1df80a7f..8de19e41ee 100644 --- a/src/mesa/state_tracker/st_atom_vs.c +++ b/src/mesa/state_tracker/st_atom_vs.c @@ -51,25 +51,61 @@ -/* translate shader to TGSI format -*/ +/** + * Translate Mesa shader to TGSI format + */ 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; + GLuint i; + + memset(&vs, 0, sizeof(vs)); + + /* + * Determine how many inputs there are. + * Also, compute two look-up tables that map between Mesa VERT_ATTRIB_x + * 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; + vs.num_inputs++; + } + } + + /* + * Determine output 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; + vs.num_outputs++; + } + } + + /* XXX: fix static allocation of tokens: */ - tgsi_mesa_compile_vp_program( &vp->Base, vp->tokens, ST_FP_MAX_TOKENS ); + tgsi_mesa_compile_vp_program( &vp->Base, + vp->input_to_index, + vp->output_to_index, + vp->tokens, ST_FP_MAX_TOKENS ); - memset(&vs, 0, sizeof(vs)); +#if 01 vs.inputs_read = tgsi_mesa_translate_vertex_input_mask(vp->Base.Base.InputsRead); +#endif vs.outputs_written = tgsi_mesa_translate_vertex_output_mask(vp->Base.Base.OutputsWritten); + vs.tokens = &vp->tokens[0]; cached = st_cached_shader_state(st, &vs); + vp->vs = cached; if (TGSI_DEBUG) @@ -121,7 +157,7 @@ static void update_vs( struct st_context *st ) const struct st_tracked_state st_update_vs = { .name = "st_update_vs", .dirty = { - .mesa = 0, + .mesa = _NEW_PROGRAM, .st = ST_NEW_VERTEX_PROGRAM, }, .update = update_vs diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 2ea498663b..65cac9dbde 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -119,12 +119,19 @@ is_depth_stencil_format(GLuint pipeFormat) * Create a simple fragment shader that just passes through the fragment color. */ static struct st_fragment_program * -make_color_shader(struct st_context *st) +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; + + /* XXX temporary */ + for (i = 0; i < 16; i++) + interpMode[i] = TGSI_INTERPOLATE_LINEAR; p = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); if (!p) @@ -151,7 +158,8 @@ make_color_shader(struct st_context *st) stfp = (struct st_fragment_program *) p; /* compile into tgsi format */ - b = tgsi_mesa_compile_fp_program(&stfp->Base, + b = tgsi_mesa_compile_fp_program(&stfp->Base, NULL, interpMode, + outputMapping, stfp->tokens, ST_FP_MAX_TOKENS); assert(b); @@ -166,6 +174,11 @@ make_color_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; @@ -204,6 +217,8 @@ make_vertex_shader(struct st_context *st) 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); @@ -349,7 +364,7 @@ clear_with_quad(GLcontext *ctx, struct pipe_shader_state fs; const struct pipe_shader_state *cached; if (!stfp) { - stfp = make_color_shader(st); + stfp = make_frag_shader(st); } memset(&fs, 0, sizeof(fs)); fs.inputs_read = tgsi_mesa_translate_fragment_input_mask(stfp->Base.Base.InputsRead); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 37e40636f6..731c060c11 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -56,10 +56,17 @@ 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; + + /* XXX temporary */ + for (i = 0; i < 16; i++) + interpMode[i] = TGSI_INTERPOLATE_LINEAR; p = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); if (!p) @@ -88,7 +95,8 @@ make_fragment_shader(struct st_context *st) stfp = (struct st_fragment_program *) p; /* compile into tgsi format */ - b = tgsi_mesa_compile_fp_program(&stfp->Base, + b = tgsi_mesa_compile_fp_program(&stfp->Base, NULL, interpMode, + outputMapping, stfp->tokens, ST_FP_MAX_TOKENS); assert(b); @@ -103,6 +111,8 @@ make_fragment_shader(struct st_context *st) 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; @@ -140,7 +150,8 @@ make_vertex_shader(struct st_context *st) stvp = (struct st_vertex_program *) p; /* compile into tgsi format */ - b = tgsi_mesa_compile_vp_program(&stvp->Base, + b = tgsi_mesa_compile_vp_program(&stvp->Base, NULL, + outputMapping, stvp->tokens, ST_FP_MAX_TOKENS); assert(b); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index ac63a38720..bff0ad7ef7 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -37,10 +37,12 @@ #include "tnl/t_vp_build.h" -#include "st_context.h" #include "st_atom.h" -#include "st_draw.h" +#include "st_context.h" #include "st_cb_bufferobjects.h" +#include "st_draw.h" +#include "st_program.h" + #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" @@ -185,18 +187,22 @@ st_draw_vbo(GLcontext *ctx, GLuint max_index) { struct pipe_context *pipe = ctx->st->pipe; - GLuint attr, i; - GLbitfield attrsNeeded; + const struct st_vertex_program *vp = ctx->st->vp; + const struct pipe_shader_state *vs; const unsigned attr0_offset = (unsigned) arrays[0]->Ptr; + GLboolean needDefaultAttribs = GL_FALSE; + GLuint attr; st_validate_state(ctx->st); - update_default_attribs_buffer(ctx); - /* this must be after state validation */ - attrsNeeded = ctx->st->state.vs->inputs_read; + /* must do this after state validation! */ + vs = ctx->st->state.vs; + + /* loop over TGSI shader inputs */ + for (attr = 0; attr < vs->num_inputs; attr++) { + const GLuint mesaAttr = vp->index_to_input[attr]; + struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; - /* tell pipe about the vertex array element/attributes */ - for (attr = 0; attr < 16; attr++) { struct pipe_vertex_buffer vbuffer; struct pipe_vertex_element velement; @@ -206,43 +212,40 @@ st_draw_vbo(GLcontext *ctx, velement.vertex_buffer_index = 0; velement.src_format = 0; - if (attrsNeeded & (1 << attr)) { - const GLuint mesaAttr = tgsi_attrib_to_mesa_attrib(attr); - struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; - - if (bufobj && bufobj->Name) { - struct st_buffer_object *stobj = st_buffer_object(bufobj); - /* Recall that for VBOs, the gl_client_array->Ptr field is - * really an offset from the start of the VBO, not a pointer. - */ - unsigned offset = (unsigned) arrays[mesaAttr]->Ptr; - - assert(stobj->buffer); - - vbuffer.buffer = stobj->buffer; - vbuffer.buffer_offset = attr0_offset; /* in bytes */ - vbuffer.pitch = arrays[mesaAttr]->StrideB; /* in bytes */ - vbuffer.max_index = 0; /* need this? */ - - velement.src_offset = offset - attr0_offset; /* bytes */ - velement.vertex_buffer_index = attr; - velement.dst_offset = 0; /* need this? */ - velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size); - assert(velement.src_format); - } - else { - /* use the default attribute buffer */ - vbuffer.buffer = ctx->st->default_attrib_buffer; - vbuffer.buffer_offset = 0; - vbuffer.pitch = 0; /* must be zero! */ - vbuffer.max_index = 1; - - velement.src_offset = attr * 4 * sizeof(GLfloat); - velement.vertex_buffer_index = attr; - velement.dst_offset = 0; - velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - } + if (bufobj && bufobj->Name) { + struct st_buffer_object *stobj = st_buffer_object(bufobj); + /* Recall that for VBOs, the gl_client_array->Ptr field is + * really an offset from the start of the VBO, not a pointer. + */ + unsigned offset = (unsigned) arrays[mesaAttr]->Ptr; + + assert(stobj->buffer); + + vbuffer.buffer = stobj->buffer; + vbuffer.buffer_offset = attr0_offset; /* in bytes */ + vbuffer.pitch = arrays[mesaAttr]->StrideB; /* in bytes */ + vbuffer.max_index = 0; /* need this? */ + + velement.src_offset = offset - attr0_offset; /* bytes */ + velement.vertex_buffer_index = attr; + velement.dst_offset = 0; /* need this? */ + velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size); + assert(velement.src_format); + } + else { + /* use the default attribute buffer */ + needDefaultAttribs = GL_TRUE; + + vbuffer.buffer = ctx->st->default_attrib_buffer; + vbuffer.buffer_offset = 0; + vbuffer.pitch = 0; /* must be zero! */ + vbuffer.max_index = 1; + + velement.src_offset = mesaAttr * 4 * sizeof(GLfloat); + velement.vertex_buffer_index = attr; + velement.dst_offset = 0; + velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; } if (attr == 0) @@ -252,12 +255,17 @@ st_draw_vbo(GLcontext *ctx, pipe->set_vertex_element(pipe, attr, &velement); } + if (needDefaultAttribs) { + update_default_attribs_buffer(ctx); + } + + /* do actual drawing */ if (ib) { /* indexed primitive */ struct gl_buffer_object *bufobj = ib->obj; struct pipe_buffer_handle *bh = NULL; - unsigned indexSize; + unsigned indexSize, i; if (bufobj && bufobj->Name) { /* elements/indexes are in a real VBO */ @@ -285,6 +293,7 @@ st_draw_vbo(GLcontext *ctx, } else { /* non-indexed */ + GLuint i; for (i = 0; i < nr_prims; i++) { pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count); } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index a2f114b1ba..68ceba4d78 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -61,13 +61,20 @@ struct st_fragment_program struct st_vertex_program { - struct gl_vertex_program Base; - GLboolean error; /* If program is malformed for any reason. */ + 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]; + + GLuint output_to_index[MAX_VERTEX_PROGRAM_ATTRIBS]; + GLuint index_to_output[MAX_VERTEX_PROGRAM_ATTRIBS]; + /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; GLboolean dirty; -- cgit v1.2.3 From b3cc74aa448f42340cbd01578a51f94eb2949618 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 19 Sep 2007 10:16:46 -0600 Subject: grab vertex program pointer after state validation --- src/mesa/state_tracker/st_draw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index bff0ad7ef7..6efe3ce8b8 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -187,7 +187,7 @@ st_draw_vbo(GLcontext *ctx, GLuint max_index) { struct pipe_context *pipe = ctx->st->pipe; - const struct st_vertex_program *vp = ctx->st->vp; + const struct st_vertex_program *vp; const struct pipe_shader_state *vs; const unsigned attr0_offset = (unsigned) arrays[0]->Ptr; GLboolean needDefaultAttribs = GL_FALSE; @@ -195,7 +195,8 @@ st_draw_vbo(GLcontext *ctx, st_validate_state(ctx->st); - /* must do this after state validation! */ + /* must get these after state validation! */ + vp = ctx->st->vp; vs = ctx->st->state.vs; /* loop over TGSI shader inputs */ -- cgit v1.2.3 From fe555c39bb7fd530298b5be4a8f06bff41726c86 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 19 Sep 2007 14:01:18 -0400 Subject: Convert the rasterizer cso to the new semantics. Basically make cso hold the driver specific struct, while managing the template. --- src/mesa/pipe/cso_cache/cso_cache.h | 5 ++++ src/mesa/pipe/failover/fo_context.h | 2 +- src/mesa/pipe/failover/fo_state.c | 35 ++++++++++++++++++++++++---- src/mesa/pipe/failover/fo_state_emit.c | 3 ++- src/mesa/pipe/i915simple/i915_state.c | 18 ++++++-------- src/mesa/pipe/p_context.h | 11 ++++----- src/mesa/pipe/softpipe/sp_state.h | 8 +++---- src/mesa/pipe/softpipe/sp_state_rasterizer.c | 18 ++++++-------- src/mesa/state_tracker/st_atom_rasterizer.c | 10 ++++---- src/mesa/state_tracker/st_cache.c | 20 +++++++++------- src/mesa/state_tracker/st_cache.h | 6 ++--- src/mesa/state_tracker/st_cb_clear.c | 8 +++---- src/mesa/state_tracker/st_cb_drawpixels.c | 8 +++---- src/mesa/state_tracker/st_context.h | 2 +- src/mesa/state_tracker/st_draw.c | 2 +- 15 files changed, 90 insertions(+), 66 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h index 7ac5908922..cd4b64eec4 100644 --- a/src/mesa/pipe/cso_cache/cso_cache.h +++ b/src/mesa/pipe/cso_cache/cso_cache.h @@ -53,6 +53,11 @@ struct cso_blend { void *data; }; +struct cso_rasterizer { + struct pipe_rasterizer_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 ea7fb109b3..a649899010 100644 --- a/src/mesa/pipe/failover/fo_context.h +++ b/src/mesa/pipe/failover/fo_context.h @@ -73,7 +73,7 @@ struct failover_context { const struct fo_state *blend; 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 fo_state *rasterizer; const struct pipe_shader_state *fragment_shader; const struct pipe_shader_state *vertex_shader; diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c index ba110a6e4f..25725625e0 100644 --- a/src/mesa/pipe/failover/fo_state.c +++ b/src/mesa/pipe/failover/fo_state.c @@ -183,17 +183,42 @@ failover_set_polygon_stipple( struct pipe_context *pipe, failover->hw->set_polygon_stipple( failover->hw, stipple ); } +static void * +failover_create_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *templ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + state->sw_state = failover->sw->create_rasterizer_state(pipe, templ); + state->hw_state = failover->hw->create_rasterizer_state(pipe, templ); + + return state; +} static void -failover_bind_rasterizer_state( struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup ) +failover_bind_rasterizer_state(struct pipe_context *pipe, + void *raster) { struct failover_context *failover = failover_context(pipe); - failover->rasterizer = setup; + failover->rasterizer = (struct fo_state *)raster; failover->dirty |= FO_NEW_RASTERIZER; - failover->hw->bind_rasterizer_state( failover->hw, setup ); + failover->hw->bind_rasterizer_state( failover->hw, raster ); +} + +static void +failover_delete_rasterizer_state(struct pipe_context *pipe, + void *raster) +{ + struct fo_state *state = (struct fo_state*)raster; + struct failover_context *failover = failover_context(pipe); + + failover->sw->delete_rasterizer_state(pipe, state->sw_state); + failover->hw->delete_rasterizer_state(pipe, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); } @@ -284,7 +309,9 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.delete_blend_state = failover_delete_blend_state; failover->pipe.bind_sampler_state = failover_bind_sampler_state; failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state; + 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; diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c index 72697c01a9..f2b0b1edc0 100644 --- a/src/mesa/pipe/failover/fo_state_emit.c +++ b/src/mesa/pipe/failover/fo_state_emit.c @@ -87,7 +87,8 @@ failover_state_emit( struct failover_context *failover ) failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple ); if (failover->dirty & FO_NEW_RASTERIZER) - failover->sw->bind_rasterizer_state( failover->sw, failover->rasterizer ); + failover->sw->bind_rasterizer_state( failover->sw, + failover->rasterizer->sw_state ); if (failover->dirty & FO_NEW_SCISSOR) failover->sw->set_scissor_state( failover->sw, &failover->scissor ); diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 4a4d26be65..66aa9a0274 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -371,23 +371,19 @@ static void i915_set_viewport_state( struct pipe_context *pipe, } -static const struct pipe_rasterizer_state * +static void * i915_create_rasterizer_state(struct pipe_context *pipe, const struct pipe_rasterizer_state *setup) { - struct pipe_rasterizer_state *raster = - malloc(sizeof(struct pipe_rasterizer_state)); - memcpy(raster, setup, sizeof(struct pipe_rasterizer_state)); - - return raster; + return 0; } static void i915_bind_rasterizer_state( struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup ) + void *setup ) { struct i915_context *i915 = i915_context(pipe); - i915->rasterizer = setup; + i915->rasterizer = (struct pipe_rasterizer_state *)setup; /* pass-through to draw module */ draw_set_rasterizer_state(i915->draw, setup); @@ -395,10 +391,10 @@ static void i915_bind_rasterizer_state( struct pipe_context *pipe, i915->dirty |= I915_NEW_RASTERIZER; } -static void i915_delete_rasterizer_state( struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup ) +static void i915_delete_rasterizer_state(struct pipe_context *pipe, + void *setup) { - free((struct pipe_rasterizer_state*)setup); + /* do nothing */ } static void i915_set_vertex_buffer( struct pipe_context *pipe, diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index adca6612d5..1c0ab794f0 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -99,13 +99,10 @@ struct pipe_context { void (*delete_sampler_state)(struct pipe_context *, const struct pipe_sampler_state *); - const struct pipe_rasterizer_state *(*create_rasterizer_state)( - struct pipe_context *, - const struct pipe_rasterizer_state *); - void (*bind_rasterizer_state)(struct pipe_context *, - const struct pipe_rasterizer_state *); - void (*delete_rasterizer_state)(struct pipe_context *, - const struct pipe_rasterizer_state *); + void *(*create_rasterizer_state)(struct pipe_context *, + const struct pipe_rasterizer_state *); + void (*bind_rasterizer_state)(struct pipe_context *, void *); + void (*delete_rasterizer_state)(struct pipe_context *, void *); const struct pipe_depth_stencil_state * (*create_depth_stencil_state)( struct pipe_context *, diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 8e7776a6c7..a20ae1d4a2 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -58,13 +58,13 @@ void softpipe_bind_depth_stencil_state(struct pipe_context *, void softpipe_delete_depth_stencil_state(struct pipe_context *, const struct pipe_depth_stencil_state *); -const struct pipe_rasterizer_state * +void * softpipe_create_rasterizer_state(struct pipe_context *, - const struct pipe_rasterizer_state *); -void softpipe_bind_rasterizer_state(struct pipe_context *, const struct pipe_rasterizer_state *); +void softpipe_bind_rasterizer_state(struct pipe_context *, + void *); void softpipe_delete_rasterizer_state(struct pipe_context *, - const struct pipe_rasterizer_state *); + void *); void softpipe_set_framebuffer_state( struct pipe_context *, const struct pipe_framebuffer_state * ); diff --git a/src/mesa/pipe/softpipe/sp_state_rasterizer.c b/src/mesa/pipe/softpipe/sp_state_rasterizer.c index d832adb91b..d7845cef82 100644 --- a/src/mesa/pipe/softpipe/sp_state_rasterizer.c +++ b/src/mesa/pipe/softpipe/sp_state_rasterizer.c @@ -32,34 +32,30 @@ -const struct pipe_rasterizer_state * +void * softpipe_create_rasterizer_state(struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup) + const struct pipe_rasterizer_state *setup) { - struct pipe_rasterizer_state *raster = - malloc(sizeof(struct pipe_rasterizer_state)); - memcpy(raster, setup, sizeof(struct pipe_rasterizer_state)); - - return raster; + return 0; } void softpipe_bind_rasterizer_state(struct pipe_context *pipe, - const struct pipe_rasterizer_state *setup) + void *setup) { struct softpipe_context *softpipe = softpipe_context(pipe); /* pass-through to draw module */ draw_set_rasterizer_state(softpipe->draw, setup); - softpipe->rasterizer = setup; + softpipe->rasterizer = (struct pipe_rasterizer_state *)setup; softpipe->dirty |= SP_NEW_RASTERIZER; } void softpipe_delete_rasterizer_state(struct pipe_context *pipe, - const struct pipe_rasterizer_state *rasterizer) + void *rasterizer) { - free((struct pipe_rasterizer_state*)rasterizer); + /* do nothing */ } diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index cab8ad5cd6..e0d83ddaea 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -73,7 +73,7 @@ static void update_raster_state( struct st_context *st ) { GLcontext *ctx = st->ctx; struct pipe_rasterizer_state raster; - const struct pipe_rasterizer_state *cached; + const struct cso_rasterizer *cso; memset(&raster, 0, sizeof(raster)); @@ -206,10 +206,10 @@ static void update_raster_state( struct st_context *st ) if (ctx->Scissor.Enabled) raster.scissor = 1; - cached = st_cached_rasterizer_state(st, &raster); - if (st->state.rasterizer != cached) { - st->state.rasterizer = cached; - st->pipe->bind_rasterizer_state( st->pipe, cached ); + cso = st_cached_rasterizer_state(st, &raster); + if (st->state.rasterizer != cso) { + st->state.rasterizer = cso; + st->pipe->bind_rasterizer_state(st->pipe, cso->data); } } diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index bd6c63b7a1..0f233cea58 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -95,22 +95,24 @@ struct pipe_depth_stencil_state * st_cached_depth_stencil_state( return (struct pipe_depth_stencil_state*)(cso_hash_iter_data(iter)); } -struct pipe_rasterizer_state * st_cached_rasterizer_state( +const struct cso_rasterizer* st_cached_rasterizer_state( struct st_context *st, - const struct pipe_rasterizer_state *raster) + const struct pipe_rasterizer_state *templ) { - unsigned hash_key = cso_construct_key((void*)raster, + unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_rasterizer_state)); struct cso_hash_iter iter = cso_find_state_template(st->cache, hash_key, CSO_RASTERIZER, - (void*)raster); + (void*)templ); if (cso_hash_iter_is_null(iter)) { - const struct pipe_rasterizer_state *created_state = - st->pipe->create_rasterizer_state(st->pipe, raster); - iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER, - (void*)created_state); + struct cso_rasterizer *cso = malloc(sizeof(struct cso_rasterizer)); + memcpy(&cso->state, templ, sizeof(struct pipe_rasterizer_state)); + cso->data = st->pipe->create_rasterizer_state(st->pipe, templ); + if (!cso->data) + cso->data = &cso->state; + iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER, cso); } - return (struct pipe_rasterizer_state*)(cso_hash_iter_data(iter)); + return (struct cso_rasterizer*)(cso_hash_iter_data(iter)); } struct pipe_shader_state * st_cached_fs_state( diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index fb0ff0d4db..5b8c6168a8 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -51,9 +51,9 @@ struct pipe_depth_stencil_state *st_cached_depth_stencil_state( struct st_context *st, const struct pipe_depth_stencil_state *depth_stencil); -struct pipe_rasterizer_state *st_cached_rasterizer_state( - struct st_context *st, - const struct pipe_rasterizer_state *raster); +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, diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 3a6991754a..5d5efd9eae 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -345,7 +345,7 @@ clear_with_quad(GLcontext *ctx, /* setup state: nothing */ { struct pipe_rasterizer_state raster; - const struct pipe_rasterizer_state *cached; + const struct cso_rasterizer *cso; memset(&raster, 0, sizeof(raster)); #if 0 /* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD @@ -354,8 +354,8 @@ clear_with_quad(GLcontext *ctx, if (ctx->Scissor.Enabled) raster.scissor = 1; #endif - cached = st_cached_rasterizer_state(ctx->st, &raster); - pipe->bind_rasterizer_state(pipe, cached); + cso = st_cached_rasterizer_state(ctx->st, &raster); + pipe->bind_rasterizer_state(pipe, cso->data); } /* fragment shader state: color pass-through program */ @@ -415,7 +415,7 @@ clear_with_quad(GLcontext *ctx, 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_rasterizer_state(pipe, st->state.rasterizer); + pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); /* OR: st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 4a554cd5a4..0fd728c930 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -328,12 +328,12 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* setup state: just scissor */ { struct pipe_rasterizer_state setup; - struct pipe_rasterizer_state *cached; + const struct cso_rasterizer *cso; memset(&setup, 0, sizeof(setup)); if (ctx->Scissor.Enabled) setup.scissor = 1; - cached = st_cached_rasterizer_state(ctx->st, &setup); - pipe->bind_rasterizer_state(pipe, cached); + cso = st_cached_rasterizer_state(ctx->st, &setup); + pipe->bind_rasterizer_state(pipe, cso->data); } /* fragment shader state: TEX lookup program */ @@ -417,7 +417,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, draw_quad(ctx, x0, y0, z, x1, y1); /* restore GL state */ - pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer); + 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->set_texture_state(pipe, unit, ctx->st->state.texture[unit]); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 966574b67c..93b6425480 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -78,7 +78,7 @@ struct st_context const struct cso_blend *blend; 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 cso_rasterizer *rasterizer; const struct pipe_shader_state *fs; const struct pipe_shader_state *vs; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 6efe3ce8b8..e36c10d595 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -404,7 +404,7 @@ 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); + draw_set_rasterizer_state(draw, st->state.rasterizer->data); draw_set_vertex_shader(draw, st->state.vs); /* XXX need to set vertex info too */ -- cgit v1.2.3 From b8ecec7abefcd1f0720e448c05e901af0224806a Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 19 Sep 2007 14:14:03 -0400 Subject: Adding proper includes often helps with the warnings, or so i hear.. --- src/mesa/state_tracker/st_draw.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index e36c10d595..7075db82e9 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -38,6 +38,7 @@ #include "tnl/t_vp_build.h" #include "st_atom.h" +#include "st_cache.h" #include "st_context.h" #include "st_cb_bufferobjects.h" #include "st_draw.h" -- 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_draw.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_draw.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 674d0130693f827ae9ea8e902a38c46d64444384 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 20 Sep 2007 13:50:53 -0600 Subject: checkpoint: TGSI_ATTRIB_x tokens no longer used --- src/mesa/pipe/draw/draw_vertex.h | 2 +- src/mesa/pipe/i915simple/i915_state_derived.c | 25 +++++++++---------------- src/mesa/pipe/softpipe/sp_prim_setup.c | 12 ++++++------ src/mesa/pipe/softpipe/sp_state_derived.c | 20 +++++++++----------- src/mesa/pipe/tgsi/exec/tgsi_attribs.h | 2 ++ src/mesa/state_tracker/st_draw.c | 3 ++- 6 files changed, 29 insertions(+), 35 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 1d900b3a4e..5874c554b1 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -87,7 +87,7 @@ struct vertex_info * \return slot in which the attribute was added */ static INLINE uint -draw_emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, +draw_emit_vertex_attr(struct vertex_info *vinfo, attrib_format format, interp_mode interp) { const uint n = vinfo->num_attribs; diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 91d00fb1c2..1485d37a62 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -55,7 +55,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) memset(vinfo, 0, sizeof(*vinfo)); /* pos */ - draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POS, FORMAT_3F, INTERP_LINEAR); + draw_emit_vertex_attr(vinfo, FORMAT_3F, INTERP_LINEAR); /* Note: we'll set the S4_VFMT_XYZ[W] bits below */ for (i = 0; i < fs->num_inputs; i++) { @@ -63,14 +63,12 @@ static void calculate_vertex_layout( struct i915_context *i915 ) case TGSI_SEMANTIC_POSITION: break; case TGSI_SEMANTIC_COLOR0: - front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, - FORMAT_4UB, colorInterp); + front0 = draw_emit_vertex_attr(vinfo, 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); + front1 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp); vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG; break; case TGSI_SEMANTIC_TEX0: @@ -85,8 +83,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) 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); + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE); hwtc = TEXCOORDFMT_4D; needW = TRUE; vinfo->hwfmt[1] |= hwtc << (unit * 4); @@ -109,16 +106,14 @@ static void calculate_vertex_layout( struct i915_context *i915 ) #if 0 /* color0 */ if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) { - front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, - FORMAT_4UB, colorInterp); + front0 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp); vinfo->hwfmt[0] |= S4_VFMT_COLOR; } /* color 1 */ if (inputsRead & (1 << TGSI_ATTRIB_COLOR1)) { assert(0); /* untested */ - front1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1, - FORMAT_4UB, colorInterp); + front1 = draw_emit_vertex_attr(vinfo, FORMAT_4UB, colorInterp); vinfo->hwfmt[0] |= S4_VFMT_SPEC_FOG; } @@ -130,7 +125,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) for (i = TGSI_ATTRIB_TEX0; i <= TGSI_ATTRIB_TEX7; i++) { uint hwtc; if (inputsRead & (1 << i)) { - draw_emit_vertex_attr(vinfo, i, FORMAT_4F, INTERP_PERSPECTIVE); + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE); hwtc = TEXCOORDFMT_4D; needW = TRUE; } @@ -158,12 +153,10 @@ static void calculate_vertex_layout( struct i915_context *i915 ) */ if (i915->rasterizer->light_twoside) { if (front0) { - back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, - FORMAT_OMIT, colorInterp); + back0 = draw_emit_vertex_attr(vinfo, FORMAT_OMIT, colorInterp); } if (back0) { - back1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC1, - FORMAT_OMIT, colorInterp); + back1 = draw_emit_vertex_attr(vinfo, FORMAT_OMIT, colorInterp); } } diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 913ae44601..f0f9cf54bd 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -79,7 +79,7 @@ struct setup_stage { float oneoverarea; - struct tgsi_interp_coef coef[TGSI_ATTRIB_MAX]; + struct tgsi_interp_coef coef[PIPE_MAX_SHADER_INPUTS]; struct quad_header quad; struct { @@ -366,7 +366,7 @@ static void const_coeff( struct setup_stage *setup, unsigned slot, unsigned i ) { - assert(slot < TGSI_ATTRIB_MAX); + assert(slot < PIPE_MAX_SHADER_INPUTS); assert(i <= 3); setup->coef[slot].dadx[i] = 0; @@ -391,7 +391,7 @@ static void tri_linear_coeff( struct setup_stage *setup, float a = setup->ebot.dy * majda - botda * setup->emaj.dy; float b = setup->emaj.dx * botda - majda * setup->ebot.dx; - assert(slot < TGSI_ATTRIB_MAX); + assert(slot < PIPE_MAX_SHADER_INPUTS); assert(i <= 3); setup->coef[slot].dadx[i] = a * setup->oneoverarea; @@ -454,7 +454,7 @@ static void tri_persp_coeff( struct setup_stage *setup, ); */ - assert(slot < TGSI_ATTRIB_MAX); + assert(slot < PIPE_MAX_SHADER_INPUTS); assert(i <= 3); setup->coef[slot].dadx[i] = a * setup->oneoverarea; @@ -910,8 +910,8 @@ setup_point(struct draw_stage *stage, struct prim_header *prim) = sizeAttr ? (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[TGSI_ATTRIB_POS][0]; - const float y = v0->data[TGSI_ATTRIB_POS][1]; + 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); diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 03b5d7ea3f..3ae207910d 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -63,7 +63,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) /* 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); + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR); for (i = 0; i < fs->num_inputs; i++) { switch (fs->input_semantics[i]) { @@ -75,15 +75,15 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) softpipe->need_w = TRUE; break; case TGSI_SEMANTIC_COLOR0: - front0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR0, + front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp); break; case TGSI_SEMANTIC_COLOR1: - front1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_COLOR1, + front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp); break; case TGSI_SEMANTIC_FOG: - draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_FOG, + draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE); break; #if 0 @@ -91,19 +91,19 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) /* XXX only emit if drawing points or front/back polygon mode * is point mode */ - draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_POINTSIZE, + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_CONSTANT); break; #endif softpipe->psize_slot = i; /*case TGSI_SEMANTIC_TEXCOORD:*/ case TGSI_SEMANTIC_TEX0: - draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_TEX0, + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE); softpipe->need_w = TRUE; break; case TGSI_SEMANTIC_OTHER: - draw_emit_vertex_attr(vinfo, i, FORMAT_4F, INTERP_PERSPECTIVE); + draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE); softpipe->need_w = TRUE; break; @@ -120,12 +120,10 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) */ if (softpipe->rasterizer->light_twoside) { if (front0) { - back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0, - FORMAT_OMIT, colorInterp); + back0 = draw_emit_vertex_attr(vinfo, FORMAT_OMIT, colorInterp); } if (back0) { - back1 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC1, - FORMAT_OMIT, colorInterp); + back1 = draw_emit_vertex_attr(vinfo, FORMAT_OMIT, colorInterp); } } diff --git a/src/mesa/pipe/tgsi/exec/tgsi_attribs.h b/src/mesa/pipe/tgsi/exec/tgsi_attribs.h index b8f6ba7da8..fa13da12be 100644 --- a/src/mesa/pipe/tgsi/exec/tgsi_attribs.h +++ b/src/mesa/pipe/tgsi/exec/tgsi_attribs.h @@ -5,6 +5,7 @@ /** * The specific values here are not important (could remove them). */ +#if 0 enum { TGSI_ATTRIB_POS = 0, TGSI_ATTRIB_WEIGHT = 1, @@ -41,6 +42,7 @@ enum { #define TGSI_MAX_TEXTURE 8 #define TGSI_MAX_VARYING 8 +#endif diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 633e4d9470..e6f4175bf8 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -77,6 +77,7 @@ pipe_vertex_format(GLenum format, GLuint size) } +#if 0 /** * Convert a mesa vertex attribute to a TGSI attribute */ @@ -137,7 +138,7 @@ tgsi_attrib_to_mesa_attrib(GLuint attr) return 0; } } - +#endif /** -- 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_draw.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 0dfa5506a318b202ac955a59cc7c9b22b5ff3867 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 25 Sep 2007 16:56:35 -0600 Subject: st_draw_vertices() no longer needs attribs[] array parameter --- src/mesa/state_tracker/st_cb_clear.c | 6 +----- src/mesa/state_tracker/st_cb_drawpixels.c | 13 ++----------- src/mesa/state_tracker/st_draw.c | 5 ++--- src/mesa/state_tracker/st_draw.h | 2 +- 4 files changed, 6 insertions(+), 20 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 367ae06cf3..3a70d2f121 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -223,10 +223,6 @@ draw_quad(GLcontext *ctx, float x0, float y0, float x1, float y1, GLfloat z, const GLfloat color[4]) { - static const GLuint attribs[2] = { - 0, /* pos */ - 3 /* color */ - }; GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */ GLuint i; @@ -253,7 +249,7 @@ draw_quad(GLcontext *ctx, verts[i][1][3] = color[3]; } - st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, attribs); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 49120a4dea..9efd718834 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -312,10 +312,6 @@ static void draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, GLfloat x1, GLfloat y1) { - static const GLuint attribs[2] = { - 0, /* pos */ - 8 /* tex0 */ - }; GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */ GLuint i; @@ -351,7 +347,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, verts[i][1][3] = 1.0; /*Q*/ } - st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, attribs); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2); } @@ -359,11 +355,6 @@ static void draw_quad_colored(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, GLfloat x1, GLfloat y1, const GLfloat *color) { - static const GLuint attribs[3] = { - 0, /* pos */ - 1, /* color */ - 8 /* tex0 */ - }; GLfloat verts[4][3][4]; /* four verts, three attribs, XYZW */ GLuint i; @@ -403,7 +394,7 @@ draw_quad_colored(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, verts[i][2][3] = 1.0; /*Q*/ } - st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 3, attribs); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 3); } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 0f45bf579a..ce5bf0c8a9 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -316,7 +316,7 @@ st_draw_vbo(GLcontext *ctx, void st_draw_vertices(GLcontext *ctx, unsigned prim, unsigned numVertex, float *verts, - unsigned numAttribs, const unsigned attribs[]) + unsigned numAttribs) { const float width = ctx->DrawBuffer->Width; const float height = ctx->DrawBuffer->Height; @@ -328,7 +328,6 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, unsigned i; assert(numAttribs > 0); - assert(attribs[0] == 0); /* position */ /* convert to clip coords */ for (i = 0; i < numVertex; i++) { @@ -356,7 +355,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, i/**attribs[i]**/, &velement); + pipe->set_vertex_element(pipe, i, &velement); } /* draw */ diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index 1fcd1b7e6b..89ee790c57 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -62,7 +62,7 @@ st_feedback_draw_vbo(GLcontext *ctx, void st_draw_vertices(GLcontext *ctx, unsigned prim, unsigned numVertex, float *verts, - unsigned numAttribs, const unsigned attribs[]); + unsigned numAttribs); #endif -- cgit v1.2.3 From 6dcfddb8e2ec2bfb6187b912807fa65f28da2c5e Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Fri, 28 Sep 2007 04:33:55 -0400 Subject: Redoing the way we handle vertex shaders for the draw module. --- src/mesa/pipe/draw/draw_context.c | 8 ---- src/mesa/pipe/draw/draw_context.h | 9 ++-- src/mesa/pipe/draw/draw_private.h | 14 ++++++- src/mesa/pipe/draw/draw_vertex_fetch.c | 2 +- src/mesa/pipe/draw/draw_vertex_shader.c | 50 +++++++++++++++++++++-- src/mesa/pipe/i915simple/i915_state.c | 44 ++++++++++++-------- src/mesa/pipe/softpipe/sp_context.c | 8 ++-- src/mesa/pipe/softpipe/sp_context.h | 8 +++- 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 | 49 +++++++++++++++++----- src/mesa/state_tracker/st_cb_program.c | 7 ---- src/mesa/state_tracker/st_draw.c | 2 +- src/mesa/state_tracker/st_program.c | 8 ---- src/mesa/state_tracker/st_program.h | 4 -- src/mesa/x86/rtasm/x86sse.c | 68 +++++++++++++++---------------- src/mesa/x86/rtasm/x86sse.h | 49 +++++++++++----------- 17 files changed, 211 insertions(+), 135 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index 66c66ff698..5efb173228 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -155,14 +155,6 @@ void draw_set_viewport_state( struct draw_context *draw, } -void -draw_set_vertex_shader(struct draw_context *draw, - const struct pipe_shader_state *shader) -{ - draw_flush( draw ); - draw->vertex_shader = *shader; -} - void draw_set_vertex_buffer(struct draw_context *draw, diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 0ccf5f6046..398e96d94d 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -92,9 +92,12 @@ void draw_set_rasterize_stage( struct draw_context *draw, struct draw_stage *stage ); -void -draw_set_vertex_shader(struct draw_context *draw, - const struct pipe_shader_state *shader); +void * draw_create_vertex_shader(struct draw_context *draw, + const struct pipe_shader_state *shader); +void draw_bind_vertex_shader(struct draw_context *draw, + void *vcso); +void draw_delete_vertex_shader(struct draw_context *draw, + void *vcso); void diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index ebef5347ab..2f52299f74 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -46,6 +46,7 @@ #include "draw_vertex.h" +#include "x86/rtasm/x86sse.h" /** * Basic vertex info. @@ -104,7 +105,7 @@ struct draw_stage void (*tri)( struct draw_stage *, struct prim_header * ); - + void (*end)( struct draw_stage * ); void (*reset_stipple_counter)( struct draw_stage * ); @@ -116,6 +117,15 @@ struct draw_stage #define VCACHE_OVERFLOW 4 #define VS_QUEUE_LENGTH (VCACHE_SIZE + VCACHE_OVERFLOW + 1) /* can never fill up */ +/** + * Private version of the compiled vertex_shader + */ +struct draw_vertex_shader { + const struct pipe_shader_state *state; +#if defined(__i386__) || defined(__386__) + struct x86_function sse2_program; +#endif +}; /** * Private context for the drawing module. @@ -145,7 +155,7 @@ struct draw_context struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; - struct pipe_shader_state vertex_shader; + 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]; diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index 2b839d641e..bc37e18c34 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -85,7 +85,7 @@ void draw_vertex_fetch( struct draw_context *draw, /*printf("fetch vertex %u: \n", j);*/ /* loop over vertex attributes (vertex shader inputs) */ - for (attr = 0; attr < draw->vertex_shader.num_inputs; attr++) { + for (attr = 0; attr < draw->vertex_shader->state->num_inputs; attr++) { unsigned buf = draw->vertex_element[attr].vertex_buffer_index; const void *src diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index a2e1cdc472..f7ddbd1909 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -36,6 +36,8 @@ #include "draw_context.h" #include "draw_vertex.h" +#include "x86/rtasm/x86sse.h" + #include "pipe/tgsi/exec/tgsi_core.h" static INLINE unsigned @@ -70,6 +72,7 @@ typedef void (XSTDCALL *codegen_function) ( float (*constant)[4], struct tgsi_exec_vector *temporary ); + /** * Transform vertices with the current vertex program/shader * Up to four vertices can be shaded at a time. @@ -92,7 +95,7 @@ run_vertex_program(struct draw_context *draw, const float *trans = draw->viewport.translate; assert(count <= 4); - assert(draw->vertex_shader.output_semantic_name[0] + assert(draw->vertex_shader->state->output_semantic_name[0] == TGSI_SEMANTIC_POSITION); #ifdef DEBUG @@ -101,7 +104,7 @@ run_vertex_program(struct draw_context *draw, /* init machine state */ tgsi_exec_machine_init(&machine, - draw->vertex_shader.tokens, + draw->vertex_shader->state->tokens, PIPE_MAX_SAMPLERS, NULL /*samplers*/ ); @@ -114,8 +117,8 @@ run_vertex_program(struct draw_context *draw, draw_vertex_fetch( draw, &machine, elts, count ); /* run shader */ - if( draw->vertex_shader.executable != NULL ) { - codegen_function func = (codegen_function) draw->vertex_shader.executable; + if( draw->vertex_shader->state->executable != NULL ) { + codegen_function func = (codegen_function) draw->vertex_shader->state->executable; func( machine.Inputs, machine.Outputs, @@ -206,3 +209,42 @@ void draw_vertex_shader_queue_flush( struct draw_context *draw ) draw->vs.queue_nr = 0; } + +void * +draw_create_vertex_shader(struct draw_context *draw, + const struct pipe_shader_state *shader) +{ + struct draw_vertex_shader *vs = calloc(1, sizeof(struct draw_vertex_shader)); + + vs->state = shader; +#if defined(__i386__) || defined(__386__) + x86_init_func(&vs->sse2_program); + + tgsi_emit_sse2(shader->tokens, &vs->sse2_program); + + ((struct pipe_shader_state*)(vs->state))->executable = + x86_get_func(&vs->sse2_program); +#endif + + return vs; +} + +void draw_bind_vertex_shader(struct draw_context *draw, + void *vcso) +{ + draw_flush(draw); + draw->vertex_shader = (struct draw_vertex_shader*)(vcso); +} + +void draw_delete_vertex_shader(struct draw_context *draw, + void *vcso) +{ + struct draw_vertex_shader *vs = (struct draw_vertex_shader*)(vcso); +#if defined(__i386__) || defined(__386__) + x86_release_func(&vs->sse2_program); +#endif + free(vcso); +} + + + diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 5c6d37a466..19ca5e575f 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -443,16 +443,13 @@ static void i915_set_polygon_stipple( struct pipe_context *pipe, { } - -static void * -i915_create_shader_state(struct pipe_context *pipe, - const struct pipe_shader_state *templ) +static void * i915_create_fs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { return 0; } -static void i915_bind_fs_state( struct pipe_context *pipe, - void *fs ) +static void i915_bind_fs_state(struct pipe_context *pipe, void *fs) { struct i915_context *i915 = i915_context(pipe); @@ -461,20 +458,35 @@ static void i915_bind_fs_state( struct pipe_context *pipe, i915->dirty |= I915_NEW_FS; } +static void i915_delete_fs_state(struct pipe_context *pipe, void *shader) +{ + /*do nothing*/ +} -static void i915_bind_vs_state(struct pipe_context *pipe, - void *vs) +static void * +i915_create_vs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { struct i915_context *i915 = i915_context(pipe); /* just pass-through to draw module */ - draw_set_vertex_shader(i915->draw, (const struct pipe_shader_state *)vs); + return draw_create_vertex_shader(i915->draw, templ); } -static void i915_delete_shader_state(struct pipe_context *pipe, - void *shader) +static void i915_bind_vs_state(struct pipe_context *pipe, void *vs) { - /*do nothing*/ + struct i915_context *i915 = i915_context(pipe); + + /* just pass-through to draw module */ + draw_bind_vertex_shader(i915->draw, vs); +} + +static void i915_delete_vs_state(struct pipe_context *pipe, void *shader) +{ + struct i915_context *i915 = i915_context(pipe); + + /* just pass-through to draw module */ + draw_delete_vertex_shader(i915->draw, shader); } static void i915_set_constant_buffer(struct pipe_context *pipe, @@ -707,12 +719,12 @@ 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_fs_state = i915_create_shader_state; + i915->pipe.create_fs_state = i915_create_fs_state; i915->pipe.bind_fs_state = i915_bind_fs_state; - i915->pipe.delete_fs_state = i915_delete_shader_state; - i915->pipe.create_vs_state = i915_create_shader_state; + i915->pipe.delete_fs_state = i915_delete_fs_state; + i915->pipe.create_vs_state = i915_create_vs_state; i915->pipe.bind_vs_state = i915_bind_vs_state; - i915->pipe.delete_vs_state = i915_delete_shader_state; + i915->pipe.delete_vs_state = i915_delete_vs_state; i915->pipe.set_blend_color = i915_set_blend_color; i915->pipe.set_clip_state = i915_set_clip_state; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index e415966dae..695bf1a9e0 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -275,12 +275,12 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state; softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state; softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state; - softpipe->pipe.create_fs_state = softpipe_create_shader_state; + softpipe->pipe.create_fs_state = softpipe_create_fs_state; softpipe->pipe.bind_fs_state = softpipe_bind_fs_state; - softpipe->pipe.delete_fs_state = softpipe_delete_shader_state; - softpipe->pipe.create_vs_state = softpipe_create_shader_state; + softpipe->pipe.delete_fs_state = softpipe_delete_fs_state; + softpipe->pipe.create_vs_state = softpipe_create_vs_state; softpipe->pipe.bind_vs_state = softpipe_bind_vs_state; - softpipe->pipe.delete_vs_state = softpipe_delete_shader_state; + softpipe->pipe.delete_vs_state = softpipe_delete_vs_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_clip_state = softpipe_set_clip_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index c0a681f3d6..ccf29b5683 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -62,8 +62,12 @@ struct draw_stage; #define SP_NEW_VS 0x2000 #define SP_NEW_CONSTANTS 0x4000 +struct sp_vertex_shader_state { + const struct pipe_shader_state *state; + void *draw_data; +}; -struct softpipe_context { +struct softpipe_context { struct pipe_context pipe; /**< base class */ struct softpipe_winsys *winsys; /**< window system interface */ @@ -76,7 +80,7 @@ struct softpipe_context { 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; + const struct sp_vertex_shader_state *vs; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index f0e1461d25..f9061e86e5 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -87,12 +87,14 @@ void softpipe_set_constant_buffer(struct pipe_context *, void softpipe_set_feedback_state( struct pipe_context *, const struct pipe_feedback_state * ); -void * -softpipe_create_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_create_fs_state(struct pipe_context *, + const struct pipe_shader_state *); +void softpipe_bind_fs_state(struct pipe_context *, void *); +void softpipe_delete_fs_state(struct pipe_context *, void *); +void *softpipe_create_vs_state(struct pipe_context *, + const struct pipe_shader_state *); +void softpipe_bind_vs_state(struct pipe_context *, void *); +void softpipe_delete_vs_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_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 6c6e798069..b6145df8e2 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 struct pipe_shader_state *vs = softpipe->vs; + const struct pipe_shader_state *vs = softpipe->vs->state; const struct pipe_shader_state *fs = softpipe->fs; const interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index 8306a95f44..f1bec2c73a 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -33,10 +33,13 @@ #include "pipe/draw/draw_context.h" -void * softpipe_create_shader_state(struct pipe_context *pipe, - const struct pipe_shader_state *templ) +void * softpipe_create_fs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { - /* we just want the pipe_shader_state template in the bind calls */ + /* Decide whether we'll be codegenerating this shader and if so do + * that now. + */ + return 0; } @@ -49,25 +52,51 @@ void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) softpipe->dirty |= SP_NEW_FS; } +void softpipe_delete_fs_state(struct pipe_context *pipe, + void *shader) +{ +} + + +void * softpipe_create_vs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + struct sp_vertex_shader_state *state = + malloc(sizeof(struct sp_vertex_shader_state)); + + state->state = templ; + state->draw_data = draw_create_vertex_shader(softpipe->draw, + state->state); + + return state; +} void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->vs = (struct pipe_shader_state *)vs; + softpipe->vs = (const struct sp_vertex_shader_state *)vs; - softpipe->dirty |= SP_NEW_VS; + draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data); - draw_set_vertex_shader(softpipe->draw, (struct pipe_shader_state *)vs); + softpipe->dirty |= SP_NEW_VS; } - -void softpipe_delete_shader_state( struct pipe_context *pipe, - void *shader ) +void softpipe_delete_vs_state(struct pipe_context *pipe, + void *vs) { - /* do nothing */ + struct softpipe_context *softpipe = softpipe_context(pipe); + + struct sp_vertex_shader_state *state = + (struct sp_vertex_shader_state *)vs; + + draw_delete_vertex_shader(softpipe->draw, state->draw_data); + free(state); } + + 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_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 25dbc2c244..3a7ce9405e 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -86,10 +86,6 @@ static struct gl_program *st_new_program( GLcontext *ctx, prog->serialNo = 1; -#if defined(__i386__) || defined(__386__) - x86_init_func( &prog->sse2_program ); -#endif - return _mesa_init_vertex_program( ctx, &prog->Base, target, @@ -129,9 +125,6 @@ static void st_delete_program( GLcontext *ctx, case GL_VERTEX_PROGRAM_ARB: { struct st_vertex_program *stvp = (struct st_vertex_program *) prog; -#if defined(__i386__) || defined(__386__) - x86_release_func( &stvp->sse2_program ); -#endif st_remove_vertex_program(st, stvp); } break; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index ce5bf0c8a9..7c836ba2c1 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -405,7 +405,7 @@ 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->state); - draw_set_vertex_shader(draw, &st->state.vs->state); + draw_bind_vertex_shader(draw, st->state.vs->data); /* XXX need to set vertex info too */ diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 44cc33b09f..116b59a067 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -253,14 +253,6 @@ st_translate_vertex_program(struct st_context *st, if (TGSI_DEBUG) tgsi_dump( tokensOut, 0 ); -#if defined(__i386__) || defined(__386__) - if (stvp->sse2_program.csr == stvp->sse2_program.store) - 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 ); -#endif - return cso; } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 6e106c16b0..2b79201313 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -79,10 +79,6 @@ struct st_vertex_program /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; -#if defined(__i386__) || defined(__386__) - struct x86_function sse2_program; -#endif - /** Pointer to the corresponding cached shader */ const struct cso_vertex_shader *vs; diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c index a6cfa40f91..f9a9352e46 100644 --- a/src/mesa/x86/rtasm/x86sse.c +++ b/src/mesa/x86/rtasm/x86sse.c @@ -6,22 +6,22 @@ #define DISASSEM 0 #define X86_TWOB 0x0f -static GLubyte *cptr( void (*label)() ) +static unsigned char *cptr( void (*label)() ) { - return (char *)(unsigned long)label; + return (unsigned char *)(unsigned long)label; } /* Emit bytes to the instruction stream: */ -static void emit_1b( struct x86_function *p, GLbyte b0 ) +static void emit_1b( struct x86_function *p, char b0 ) { - *(GLbyte *)(p->csr++) = b0; + *(char *)(p->csr++) = b0; } -static void emit_1i( struct x86_function *p, GLint i0 ) +static void emit_1i( struct x86_function *p, int i0 ) { - *(GLint *)(p->csr) = i0; + *(int *)(p->csr) = i0; p->csr += 4; } @@ -35,20 +35,20 @@ static void disassem( struct x86_function *p, const char *fn ) #endif } -static void emit_1ub_fn( struct x86_function *p, GLubyte b0, const char *fn ) +static void emit_1ub_fn( struct x86_function *p, unsigned char b0, const char *fn ) { disassem(p, fn); *(p->csr++) = b0; } -static void emit_2ub_fn( struct x86_function *p, GLubyte b0, GLubyte b1, const char *fn ) +static void emit_2ub_fn( struct x86_function *p, unsigned char b0, unsigned char b1, const char *fn ) { disassem(p, fn); *(p->csr++) = b0; *(p->csr++) = b1; } -static void emit_3ub_fn( struct x86_function *p, GLubyte b0, GLubyte b1, GLubyte b2, const char *fn ) +static void emit_3ub_fn( struct x86_function *p, unsigned char b0, unsigned char b1, unsigned char b2, const char *fn ) { disassem(p, fn); *(p->csr++) = b0; @@ -69,7 +69,7 @@ static void emit_modrm( struct x86_function *p, struct x86_reg reg, struct x86_reg regmem ) { - GLubyte val = 0; + unsigned char val = 0; assert(reg.mod == mod_REG); @@ -104,7 +104,7 @@ static void emit_modrm( struct x86_function *p, static void emit_modrm_noreg( struct x86_function *p, - GLuint op, + unsigned op, struct x86_reg regmem ) { struct x86_reg dummy = x86_make_reg(file_REG32, op); @@ -117,8 +117,8 @@ static void emit_modrm_noreg( struct x86_function *p, * the arguments presented. */ static void emit_op_modrm( struct x86_function *p, - GLubyte op_dst_is_reg, - GLubyte op_dst_is_mem, + unsigned char op_dst_is_reg, + unsigned char op_dst_is_mem, struct x86_reg dst, struct x86_reg src ) { @@ -162,7 +162,7 @@ struct x86_reg x86_make_reg( enum x86_reg_file file, } struct x86_reg x86_make_disp( struct x86_reg reg, - GLint disp ) + int disp ) { assert(reg.file == file_REG32); @@ -191,7 +191,7 @@ struct x86_reg x86_get_base_reg( struct x86_reg reg ) return x86_make_reg( reg.file, reg.idx ); } -GLubyte *x86_get_label( struct x86_function *p ) +unsigned char *x86_get_label( struct x86_function *p ) { return p->csr; } @@ -205,13 +205,13 @@ GLubyte *x86_get_label( struct x86_function *p ) void x86_jcc( struct x86_function *p, enum x86_cc cc, - GLubyte *label ) + unsigned char *label ) { - GLint offset = label - (x86_get_label(p) + 2); + int offset = label - (x86_get_label(p) + 2); if (offset <= 127 && offset >= -128) { emit_1ub(p, 0x70 + cc); - emit_1b(p, (GLbyte) offset); + emit_1b(p, (char) offset); } else { offset = label - (x86_get_label(p) + 6); @@ -222,7 +222,7 @@ void x86_jcc( struct x86_function *p, /* Always use a 32bit offset for forward jumps: */ -GLubyte *x86_jcc_forward( struct x86_function *p, +unsigned char *x86_jcc_forward( struct x86_function *p, enum x86_cc cc ) { emit_2ub(p, 0x0f, 0x80 + cc); @@ -230,14 +230,14 @@ GLubyte *x86_jcc_forward( struct x86_function *p, return x86_get_label(p); } -GLubyte *x86_jmp_forward( struct x86_function *p) +unsigned char *x86_jmp_forward( struct x86_function *p) { emit_1ub(p, 0xe9); emit_1i(p, 0); return x86_get_label(p); } -GLubyte *x86_call_forward( struct x86_function *p) +unsigned char *x86_call_forward( struct x86_function *p) { emit_1ub(p, 0xe8); emit_1i(p, 0); @@ -247,12 +247,12 @@ GLubyte *x86_call_forward( struct x86_function *p) /* Fixup offset from forward jump: */ void x86_fixup_fwd_jump( struct x86_function *p, - GLubyte *fixup ) + unsigned char *fixup ) { *(int *)(fixup - 4) = x86_get_label(p) - fixup; } -void x86_jmp( struct x86_function *p, GLubyte *label) +void x86_jmp( struct x86_function *p, unsigned char *label) { emit_1ub(p, 0xe9); emit_1i(p, label - x86_get_label(p) - 4); @@ -268,7 +268,7 @@ void x86_call( struct x86_function *p, void (*label)()) * Temporary. As I need immediate operands, and dont want to mess with the codegen, * I load the immediate into general purpose register and use it. */ -void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm ) +void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, int imm ) { assert(dst.mod == mod_REG); emit_1ub(p, 0xb8 + dst.idx); @@ -595,7 +595,7 @@ void sse_cvtps2pi( struct x86_function *p, void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - GLubyte shuf) + unsigned char shuf) { emit_2ub(p, X86_TWOB, 0xC6); emit_modrm(p, dest, arg0); @@ -605,7 +605,7 @@ void sse_shufps( struct x86_function *p, void sse_cmpps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - GLubyte cc) + unsigned char cc) { emit_2ub(p, X86_TWOB, 0xC2); emit_modrm(p, dest, arg0); @@ -630,7 +630,7 @@ void sse_pmovmskb( struct x86_function *p, void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - GLubyte shuf) + unsigned char shuf) { emit_3ub(p, 0x66, X86_TWOB, 0x70); emit_modrm(p, dest, arg0); @@ -772,11 +772,11 @@ void x87_fclex( struct x86_function *p ) static void x87_arith_op( struct x86_function *p, struct x86_reg dst, struct x86_reg arg, - GLubyte dst0ub0, - GLubyte dst0ub1, - GLubyte arg0ub0, - GLubyte arg0ub1, - GLubyte argmem_noreg) + unsigned char dst0ub0, + unsigned char dst0ub1, + unsigned char arg0ub0, + unsigned char arg0ub1, + unsigned char argmem_noreg) { assert(dst.file == file_x87); @@ -1116,7 +1116,7 @@ void mmx_movq( struct x86_function *p, * account any push/pop activity: */ struct x86_reg x86_fn_arg( struct x86_function *p, - GLuint arg ) + unsigned arg ) { return x86_make_disp(x86_make_reg(file_REG32, reg_SP), p->stack_offset + arg * 4); /* ??? */ @@ -1128,7 +1128,7 @@ void x86_init_func( struct x86_function *p ) x86_init_func_size(p, 1024); } -void x86_init_func_size( struct x86_function *p, GLuint code_size ) +void x86_init_func_size( struct x86_function *p, unsigned code_size ) { p->store = _mesa_exec_malloc(code_size); p->csr = p->store; diff --git a/src/mesa/x86/rtasm/x86sse.h b/src/mesa/x86/rtasm/x86sse.h index c1ca06088b..63b9a36392 100644 --- a/src/mesa/x86/rtasm/x86sse.h +++ b/src/mesa/x86/rtasm/x86sse.h @@ -4,24 +4,22 @@ #if defined(__i386__) || defined(__386__) -#include "glheader.h" - /* It is up to the caller to ensure that instructions issued are * suitable for the host cpu. There are no checks made in this module * for mmx/sse/sse2 support on the cpu. */ struct x86_reg { - GLuint file:3; - GLuint idx:3; - GLuint mod:2; /* mod_REG if this is just a register */ - GLint disp:24; /* only +/- 23bits of offset - should be enough... */ + unsigned file:3; + unsigned idx:3; + unsigned mod:2; /* mod_REG if this is just a register */ + int disp:24; /* only +/- 23bits of offset - should be enough... */ }; struct x86_function { - GLubyte *store; - GLubyte *csr; - GLuint stack_offset; - GLint need_emms; + unsigned char *store; + unsigned char *csr; + unsigned stack_offset; + int need_emms; const char *fn; }; @@ -81,7 +79,7 @@ enum sse_cc { void x86_init_func( struct x86_function *p ); -void x86_init_func_size( struct x86_function *p, GLuint code_size ); +void x86_init_func_size( struct x86_function *p, unsigned code_size ); void x86_release_func( struct x86_function *p ); void (*x86_get_func( struct x86_function *p ))( void ); @@ -93,7 +91,7 @@ struct x86_reg x86_make_reg( enum x86_reg_file file, enum x86_reg_name idx ); struct x86_reg x86_make_disp( struct x86_reg reg, - GLint disp ); + int disp ); struct x86_reg x86_deref( struct x86_reg reg ); @@ -102,23 +100,23 @@ struct x86_reg x86_get_base_reg( struct x86_reg reg ); /* Labels, jumps and fixup: */ -GLubyte *x86_get_label( struct x86_function *p ); +unsigned char *x86_get_label( struct x86_function *p ); void x86_jcc( struct x86_function *p, enum x86_cc cc, - GLubyte *label ); + unsigned char *label ); -GLubyte *x86_jcc_forward( struct x86_function *p, +unsigned char *x86_jcc_forward( struct x86_function *p, enum x86_cc cc ); -GLubyte *x86_jmp_forward( struct x86_function *p); +unsigned char *x86_jmp_forward( struct x86_function *p); -GLubyte *x86_call_forward( struct x86_function *p); +unsigned char *x86_call_forward( struct x86_function *p); void x86_fixup_fwd_jump( struct x86_function *p, - GLubyte *fixup ); + unsigned char *fixup ); -void x86_jmp( struct x86_function *p, GLubyte *label ); +void x86_jmp( struct x86_function *p, unsigned char *label ); void x86_call( struct x86_function *p, void (*label)() ); @@ -126,7 +124,7 @@ void x86_call( struct x86_function *p, void (*label)() ); * Temporary. As I need immediate operands, and dont want to mess with the codegen, * I load the immediate into general purpose register and use it. */ -void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm ); +void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, int imm ); /* Macro for sse_shufps() and sse2_pshufd(): @@ -147,7 +145,8 @@ void sse2_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src ) void sse2_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse2_packsswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse2_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf ); +void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, + unsigned char shuf ); void sse2_rcpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse2_rcpss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); @@ -157,7 +156,8 @@ void sse_cvtps2pi( struct x86_function *p, struct x86_reg dst, struct x86_reg sr void sse_divss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_andnps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_andps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_cmpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src, GLubyte cc ); +void sse_cmpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src, + unsigned char cc ); void sse_maxps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_maxss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_minps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); @@ -175,7 +175,8 @@ void sse_xorps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ) void sse_subps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_rsqrtps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_rsqrtss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf ); +void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, + unsigned char shuf ); void sse_pmovmskb( struct x86_function *p, struct x86_reg dest, struct x86_reg src ); void x86_add( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); @@ -247,7 +248,7 @@ void x87_fucom( struct x86_function *p, struct x86_reg arg ); * account any push/pop activity. Note - doesn't track explict * manipulation of ESP by other instructions. */ -struct x86_reg x86_fn_arg( struct x86_function *p, GLuint arg ); +struct x86_reg x86_fn_arg( struct x86_function *p, unsigned arg ); #endif #endif -- cgit v1.2.3 From 901577e07fcab0cf90a272fee900cb0831ae84c3 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Fri, 28 Sep 2007 12:28:16 -0400 Subject: Revert "Redoing the way we handle vertex shaders for the draw module." This reverts commit 6dcfddb8e2ec2bfb6187b912807fa65f28da2c5e. --- src/mesa/pipe/draw/draw_context.c | 8 ++++ src/mesa/pipe/draw/draw_context.h | 9 ++-- src/mesa/pipe/draw/draw_private.h | 14 +------ src/mesa/pipe/draw/draw_vertex_fetch.c | 2 +- src/mesa/pipe/draw/draw_vertex_shader.c | 50 ++--------------------- src/mesa/pipe/i915simple/i915_state.c | 44 ++++++++------------ src/mesa/pipe/softpipe/sp_context.c | 8 ++-- src/mesa/pipe/softpipe/sp_context.h | 8 +--- 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 | 49 +++++----------------- src/mesa/state_tracker/st_cb_program.c | 7 ++++ src/mesa/state_tracker/st_draw.c | 2 +- src/mesa/state_tracker/st_program.c | 8 ++++ src/mesa/state_tracker/st_program.h | 4 ++ src/mesa/x86/rtasm/x86sse.c | 68 +++++++++++++++---------------- src/mesa/x86/rtasm/x86sse.h | 49 +++++++++++----------- 17 files changed, 135 insertions(+), 211 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index 5efb173228..66c66ff698 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -155,6 +155,14 @@ void draw_set_viewport_state( struct draw_context *draw, } +void +draw_set_vertex_shader(struct draw_context *draw, + const struct pipe_shader_state *shader) +{ + draw_flush( draw ); + draw->vertex_shader = *shader; +} + void draw_set_vertex_buffer(struct draw_context *draw, diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 398e96d94d..0ccf5f6046 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -92,12 +92,9 @@ void draw_set_rasterize_stage( struct draw_context *draw, struct draw_stage *stage ); -void * draw_create_vertex_shader(struct draw_context *draw, - const struct pipe_shader_state *shader); -void draw_bind_vertex_shader(struct draw_context *draw, - void *vcso); -void draw_delete_vertex_shader(struct draw_context *draw, - void *vcso); +void +draw_set_vertex_shader(struct draw_context *draw, + const struct pipe_shader_state *shader); void diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index 2f52299f74..ebef5347ab 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -46,7 +46,6 @@ #include "draw_vertex.h" -#include "x86/rtasm/x86sse.h" /** * Basic vertex info. @@ -105,7 +104,7 @@ struct draw_stage void (*tri)( struct draw_stage *, struct prim_header * ); - + void (*end)( struct draw_stage * ); void (*reset_stipple_counter)( struct draw_stage * ); @@ -117,15 +116,6 @@ struct draw_stage #define VCACHE_OVERFLOW 4 #define VS_QUEUE_LENGTH (VCACHE_SIZE + VCACHE_OVERFLOW + 1) /* can never fill up */ -/** - * Private version of the compiled vertex_shader - */ -struct draw_vertex_shader { - const struct pipe_shader_state *state; -#if defined(__i386__) || defined(__386__) - struct x86_function sse2_program; -#endif -}; /** * Private context for the drawing module. @@ -155,7 +145,7 @@ struct draw_context 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_shader_state vertex_shader; struct pipe_vertex_buffer feedback_buffer[PIPE_ATTRIB_MAX]; struct pipe_vertex_element feedback_element[PIPE_ATTRIB_MAX]; diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index bc37e18c34..2b839d641e 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -85,7 +85,7 @@ void draw_vertex_fetch( struct draw_context *draw, /*printf("fetch vertex %u: \n", j);*/ /* loop over vertex attributes (vertex shader inputs) */ - for (attr = 0; attr < draw->vertex_shader->state->num_inputs; attr++) { + for (attr = 0; attr < draw->vertex_shader.num_inputs; attr++) { unsigned buf = draw->vertex_element[attr].vertex_buffer_index; const void *src diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index f7ddbd1909..a2e1cdc472 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -36,8 +36,6 @@ #include "draw_context.h" #include "draw_vertex.h" -#include "x86/rtasm/x86sse.h" - #include "pipe/tgsi/exec/tgsi_core.h" static INLINE unsigned @@ -72,7 +70,6 @@ typedef void (XSTDCALL *codegen_function) ( float (*constant)[4], struct tgsi_exec_vector *temporary ); - /** * Transform vertices with the current vertex program/shader * Up to four vertices can be shaded at a time. @@ -95,7 +92,7 @@ run_vertex_program(struct draw_context *draw, const float *trans = draw->viewport.translate; assert(count <= 4); - assert(draw->vertex_shader->state->output_semantic_name[0] + assert(draw->vertex_shader.output_semantic_name[0] == TGSI_SEMANTIC_POSITION); #ifdef DEBUG @@ -104,7 +101,7 @@ run_vertex_program(struct draw_context *draw, /* init machine state */ tgsi_exec_machine_init(&machine, - draw->vertex_shader->state->tokens, + draw->vertex_shader.tokens, PIPE_MAX_SAMPLERS, NULL /*samplers*/ ); @@ -117,8 +114,8 @@ run_vertex_program(struct draw_context *draw, draw_vertex_fetch( draw, &machine, elts, count ); /* run shader */ - if( draw->vertex_shader->state->executable != NULL ) { - codegen_function func = (codegen_function) draw->vertex_shader->state->executable; + if( draw->vertex_shader.executable != NULL ) { + codegen_function func = (codegen_function) draw->vertex_shader.executable; func( machine.Inputs, machine.Outputs, @@ -209,42 +206,3 @@ void draw_vertex_shader_queue_flush( struct draw_context *draw ) draw->vs.queue_nr = 0; } - -void * -draw_create_vertex_shader(struct draw_context *draw, - const struct pipe_shader_state *shader) -{ - struct draw_vertex_shader *vs = calloc(1, sizeof(struct draw_vertex_shader)); - - vs->state = shader; -#if defined(__i386__) || defined(__386__) - x86_init_func(&vs->sse2_program); - - tgsi_emit_sse2(shader->tokens, &vs->sse2_program); - - ((struct pipe_shader_state*)(vs->state))->executable = - x86_get_func(&vs->sse2_program); -#endif - - return vs; -} - -void draw_bind_vertex_shader(struct draw_context *draw, - void *vcso) -{ - draw_flush(draw); - draw->vertex_shader = (struct draw_vertex_shader*)(vcso); -} - -void draw_delete_vertex_shader(struct draw_context *draw, - void *vcso) -{ - struct draw_vertex_shader *vs = (struct draw_vertex_shader*)(vcso); -#if defined(__i386__) || defined(__386__) - x86_release_func(&vs->sse2_program); -#endif - free(vcso); -} - - - diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 19ca5e575f..5c6d37a466 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -443,13 +443,16 @@ static void i915_set_polygon_stipple( struct pipe_context *pipe, { } -static void * i915_create_fs_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) { return 0; } -static void i915_bind_fs_state(struct pipe_context *pipe, void *fs) +static void i915_bind_fs_state( struct pipe_context *pipe, + void *fs ) { struct i915_context *i915 = i915_context(pipe); @@ -458,35 +461,20 @@ static void i915_bind_fs_state(struct pipe_context *pipe, void *fs) i915->dirty |= I915_NEW_FS; } -static void i915_delete_fs_state(struct pipe_context *pipe, void *shader) -{ - /*do nothing*/ -} - -static void * -i915_create_vs_state(struct pipe_context *pipe, - const struct pipe_shader_state *templ) -{ - struct i915_context *i915 = i915_context(pipe); - - /* just pass-through to draw module */ - return draw_create_vertex_shader(i915->draw, templ); -} -static void i915_bind_vs_state(struct pipe_context *pipe, void *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_bind_vertex_shader(i915->draw, vs); + draw_set_vertex_shader(i915->draw, (const struct pipe_shader_state *)vs); } -static void i915_delete_vs_state(struct pipe_context *pipe, void *shader) +static void i915_delete_shader_state(struct pipe_context *pipe, + void *shader) { - struct i915_context *i915 = i915_context(pipe); - - /* just pass-through to draw module */ - draw_delete_vertex_shader(i915->draw, shader); + /*do nothing*/ } static void i915_set_constant_buffer(struct pipe_context *pipe, @@ -719,12 +707,12 @@ 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_fs_state = i915_create_fs_state; + i915->pipe.create_fs_state = i915_create_shader_state; i915->pipe.bind_fs_state = i915_bind_fs_state; - i915->pipe.delete_fs_state = i915_delete_fs_state; - i915->pipe.create_vs_state = i915_create_vs_state; + i915->pipe.delete_fs_state = i915_delete_shader_state; + i915->pipe.create_vs_state = i915_create_shader_state; i915->pipe.bind_vs_state = i915_bind_vs_state; - i915->pipe.delete_vs_state = i915_delete_vs_state; + i915->pipe.delete_vs_state = i915_delete_shader_state; i915->pipe.set_blend_color = i915_set_blend_color; i915->pipe.set_clip_state = i915_set_clip_state; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 695bf1a9e0..e415966dae 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -275,12 +275,12 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state; softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state; softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state; - softpipe->pipe.create_fs_state = softpipe_create_fs_state; + softpipe->pipe.create_fs_state = softpipe_create_shader_state; softpipe->pipe.bind_fs_state = softpipe_bind_fs_state; - softpipe->pipe.delete_fs_state = softpipe_delete_fs_state; - softpipe->pipe.create_vs_state = softpipe_create_vs_state; + softpipe->pipe.delete_fs_state = softpipe_delete_shader_state; + softpipe->pipe.create_vs_state = softpipe_create_shader_state; softpipe->pipe.bind_vs_state = softpipe_bind_vs_state; - softpipe->pipe.delete_vs_state = softpipe_delete_vs_state; + softpipe->pipe.delete_vs_state = softpipe_delete_shader_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_clip_state = softpipe_set_clip_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index ccf29b5683..c0a681f3d6 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -62,12 +62,8 @@ struct draw_stage; #define SP_NEW_VS 0x2000 #define SP_NEW_CONSTANTS 0x4000 -struct sp_vertex_shader_state { - const struct pipe_shader_state *state; - void *draw_data; -}; -struct softpipe_context { +struct softpipe_context { struct pipe_context pipe; /**< base class */ struct softpipe_winsys *winsys; /**< window system interface */ @@ -80,7 +76,7 @@ struct softpipe_context { const struct pipe_depth_stencil_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; const struct pipe_shader_state *fs; - const struct sp_vertex_shader_state *vs; + const struct pipe_shader_state *vs; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index f9061e86e5..f0e1461d25 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -87,14 +87,12 @@ void softpipe_set_constant_buffer(struct pipe_context *, 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 *); -void softpipe_delete_fs_state(struct pipe_context *, void *); -void *softpipe_create_vs_state(struct pipe_context *, - const struct pipe_shader_state *); -void softpipe_bind_vs_state(struct pipe_context *, void *); -void softpipe_delete_vs_state(struct pipe_context *, void *); +void * +softpipe_create_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_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index b6145df8e2..6c6e798069 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 struct pipe_shader_state *vs = softpipe->vs->state; + 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; diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index f1bec2c73a..8306a95f44 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -33,13 +33,10 @@ #include "pipe/draw/draw_context.h" -void * softpipe_create_fs_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) { - /* Decide whether we'll be codegenerating this shader and if so do - * that now. - */ - + /* we just want the pipe_shader_state template in the bind calls */ return 0; } @@ -52,50 +49,24 @@ void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) softpipe->dirty |= SP_NEW_FS; } -void softpipe_delete_fs_state(struct pipe_context *pipe, - void *shader) -{ -} - - -void * softpipe_create_vs_state(struct pipe_context *pipe, - const struct pipe_shader_state *templ) -{ - struct softpipe_context *softpipe = softpipe_context(pipe); - struct sp_vertex_shader_state *state = - malloc(sizeof(struct sp_vertex_shader_state)); - - state->state = templ; - state->draw_data = draw_create_vertex_shader(softpipe->draw, - state->state); - - return state; -} void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->vs = (const struct sp_vertex_shader_state *)vs; - - draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data); + softpipe->vs = (struct pipe_shader_state *)vs; softpipe->dirty |= SP_NEW_VS; -} -void softpipe_delete_vs_state(struct pipe_context *pipe, - void *vs) -{ - struct softpipe_context *softpipe = softpipe_context(pipe); - - struct sp_vertex_shader_state *state = - (struct sp_vertex_shader_state *)vs; - - draw_delete_vertex_shader(softpipe->draw, state->draw_data); - free(state); + draw_set_vertex_shader(softpipe->draw, (struct pipe_shader_state *)vs); } +void softpipe_delete_shader_state( struct pipe_context *pipe, + void *shader ) +{ + /* do nothing */ +} void softpipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 3a7ce9405e..25dbc2c244 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -86,6 +86,10 @@ static struct gl_program *st_new_program( GLcontext *ctx, prog->serialNo = 1; +#if defined(__i386__) || defined(__386__) + x86_init_func( &prog->sse2_program ); +#endif + return _mesa_init_vertex_program( ctx, &prog->Base, target, @@ -125,6 +129,9 @@ static void st_delete_program( GLcontext *ctx, case GL_VERTEX_PROGRAM_ARB: { struct st_vertex_program *stvp = (struct st_vertex_program *) prog; +#if defined(__i386__) || defined(__386__) + x86_release_func( &stvp->sse2_program ); +#endif st_remove_vertex_program(st, stvp); } break; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 7c836ba2c1..ce5bf0c8a9 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -405,7 +405,7 @@ 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->state); - draw_bind_vertex_shader(draw, st->state.vs->data); + 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.c b/src/mesa/state_tracker/st_program.c index 116b59a067..44cc33b09f 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -253,6 +253,14 @@ st_translate_vertex_program(struct st_context *st, if (TGSI_DEBUG) tgsi_dump( tokensOut, 0 ); +#if defined(__i386__) || defined(__386__) + if (stvp->sse2_program.csr == stvp->sse2_program.store) + 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 ); +#endif + return cso; } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 2b79201313..6e106c16b0 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -79,6 +79,10 @@ struct st_vertex_program /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; +#if defined(__i386__) || defined(__386__) + struct x86_function sse2_program; +#endif + /** Pointer to the corresponding cached shader */ const struct cso_vertex_shader *vs; diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c index f9a9352e46..a6cfa40f91 100644 --- a/src/mesa/x86/rtasm/x86sse.c +++ b/src/mesa/x86/rtasm/x86sse.c @@ -6,22 +6,22 @@ #define DISASSEM 0 #define X86_TWOB 0x0f -static unsigned char *cptr( void (*label)() ) +static GLubyte *cptr( void (*label)() ) { - return (unsigned char *)(unsigned long)label; + return (char *)(unsigned long)label; } /* Emit bytes to the instruction stream: */ -static void emit_1b( struct x86_function *p, char b0 ) +static void emit_1b( struct x86_function *p, GLbyte b0 ) { - *(char *)(p->csr++) = b0; + *(GLbyte *)(p->csr++) = b0; } -static void emit_1i( struct x86_function *p, int i0 ) +static void emit_1i( struct x86_function *p, GLint i0 ) { - *(int *)(p->csr) = i0; + *(GLint *)(p->csr) = i0; p->csr += 4; } @@ -35,20 +35,20 @@ static void disassem( struct x86_function *p, const char *fn ) #endif } -static void emit_1ub_fn( struct x86_function *p, unsigned char b0, const char *fn ) +static void emit_1ub_fn( struct x86_function *p, GLubyte b0, const char *fn ) { disassem(p, fn); *(p->csr++) = b0; } -static void emit_2ub_fn( struct x86_function *p, unsigned char b0, unsigned char b1, const char *fn ) +static void emit_2ub_fn( struct x86_function *p, GLubyte b0, GLubyte b1, const char *fn ) { disassem(p, fn); *(p->csr++) = b0; *(p->csr++) = b1; } -static void emit_3ub_fn( struct x86_function *p, unsigned char b0, unsigned char b1, unsigned char b2, const char *fn ) +static void emit_3ub_fn( struct x86_function *p, GLubyte b0, GLubyte b1, GLubyte b2, const char *fn ) { disassem(p, fn); *(p->csr++) = b0; @@ -69,7 +69,7 @@ static void emit_modrm( struct x86_function *p, struct x86_reg reg, struct x86_reg regmem ) { - unsigned char val = 0; + GLubyte val = 0; assert(reg.mod == mod_REG); @@ -104,7 +104,7 @@ static void emit_modrm( struct x86_function *p, static void emit_modrm_noreg( struct x86_function *p, - unsigned op, + GLuint op, struct x86_reg regmem ) { struct x86_reg dummy = x86_make_reg(file_REG32, op); @@ -117,8 +117,8 @@ static void emit_modrm_noreg( struct x86_function *p, * the arguments presented. */ static void emit_op_modrm( struct x86_function *p, - unsigned char op_dst_is_reg, - unsigned char op_dst_is_mem, + GLubyte op_dst_is_reg, + GLubyte op_dst_is_mem, struct x86_reg dst, struct x86_reg src ) { @@ -162,7 +162,7 @@ struct x86_reg x86_make_reg( enum x86_reg_file file, } struct x86_reg x86_make_disp( struct x86_reg reg, - int disp ) + GLint disp ) { assert(reg.file == file_REG32); @@ -191,7 +191,7 @@ struct x86_reg x86_get_base_reg( struct x86_reg reg ) return x86_make_reg( reg.file, reg.idx ); } -unsigned char *x86_get_label( struct x86_function *p ) +GLubyte *x86_get_label( struct x86_function *p ) { return p->csr; } @@ -205,13 +205,13 @@ unsigned char *x86_get_label( struct x86_function *p ) void x86_jcc( struct x86_function *p, enum x86_cc cc, - unsigned char *label ) + GLubyte *label ) { - int offset = label - (x86_get_label(p) + 2); + GLint offset = label - (x86_get_label(p) + 2); if (offset <= 127 && offset >= -128) { emit_1ub(p, 0x70 + cc); - emit_1b(p, (char) offset); + emit_1b(p, (GLbyte) offset); } else { offset = label - (x86_get_label(p) + 6); @@ -222,7 +222,7 @@ void x86_jcc( struct x86_function *p, /* Always use a 32bit offset for forward jumps: */ -unsigned char *x86_jcc_forward( struct x86_function *p, +GLubyte *x86_jcc_forward( struct x86_function *p, enum x86_cc cc ) { emit_2ub(p, 0x0f, 0x80 + cc); @@ -230,14 +230,14 @@ unsigned char *x86_jcc_forward( struct x86_function *p, return x86_get_label(p); } -unsigned char *x86_jmp_forward( struct x86_function *p) +GLubyte *x86_jmp_forward( struct x86_function *p) { emit_1ub(p, 0xe9); emit_1i(p, 0); return x86_get_label(p); } -unsigned char *x86_call_forward( struct x86_function *p) +GLubyte *x86_call_forward( struct x86_function *p) { emit_1ub(p, 0xe8); emit_1i(p, 0); @@ -247,12 +247,12 @@ unsigned char *x86_call_forward( struct x86_function *p) /* Fixup offset from forward jump: */ void x86_fixup_fwd_jump( struct x86_function *p, - unsigned char *fixup ) + GLubyte *fixup ) { *(int *)(fixup - 4) = x86_get_label(p) - fixup; } -void x86_jmp( struct x86_function *p, unsigned char *label) +void x86_jmp( struct x86_function *p, GLubyte *label) { emit_1ub(p, 0xe9); emit_1i(p, label - x86_get_label(p) - 4); @@ -268,7 +268,7 @@ void x86_call( struct x86_function *p, void (*label)()) * Temporary. As I need immediate operands, and dont want to mess with the codegen, * I load the immediate into general purpose register and use it. */ -void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, int imm ) +void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm ) { assert(dst.mod == mod_REG); emit_1ub(p, 0xb8 + dst.idx); @@ -595,7 +595,7 @@ void sse_cvtps2pi( struct x86_function *p, void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char shuf) + GLubyte shuf) { emit_2ub(p, X86_TWOB, 0xC6); emit_modrm(p, dest, arg0); @@ -605,7 +605,7 @@ void sse_shufps( struct x86_function *p, void sse_cmpps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char cc) + GLubyte cc) { emit_2ub(p, X86_TWOB, 0xC2); emit_modrm(p, dest, arg0); @@ -630,7 +630,7 @@ void sse_pmovmskb( struct x86_function *p, void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char shuf) + GLubyte shuf) { emit_3ub(p, 0x66, X86_TWOB, 0x70); emit_modrm(p, dest, arg0); @@ -772,11 +772,11 @@ void x87_fclex( struct x86_function *p ) static void x87_arith_op( struct x86_function *p, struct x86_reg dst, struct x86_reg arg, - unsigned char dst0ub0, - unsigned char dst0ub1, - unsigned char arg0ub0, - unsigned char arg0ub1, - unsigned char argmem_noreg) + GLubyte dst0ub0, + GLubyte dst0ub1, + GLubyte arg0ub0, + GLubyte arg0ub1, + GLubyte argmem_noreg) { assert(dst.file == file_x87); @@ -1116,7 +1116,7 @@ void mmx_movq( struct x86_function *p, * account any push/pop activity: */ struct x86_reg x86_fn_arg( struct x86_function *p, - unsigned arg ) + GLuint arg ) { return x86_make_disp(x86_make_reg(file_REG32, reg_SP), p->stack_offset + arg * 4); /* ??? */ @@ -1128,7 +1128,7 @@ void x86_init_func( struct x86_function *p ) x86_init_func_size(p, 1024); } -void x86_init_func_size( struct x86_function *p, unsigned code_size ) +void x86_init_func_size( struct x86_function *p, GLuint code_size ) { p->store = _mesa_exec_malloc(code_size); p->csr = p->store; diff --git a/src/mesa/x86/rtasm/x86sse.h b/src/mesa/x86/rtasm/x86sse.h index 63b9a36392..c1ca06088b 100644 --- a/src/mesa/x86/rtasm/x86sse.h +++ b/src/mesa/x86/rtasm/x86sse.h @@ -4,22 +4,24 @@ #if defined(__i386__) || defined(__386__) +#include "glheader.h" + /* It is up to the caller to ensure that instructions issued are * suitable for the host cpu. There are no checks made in this module * for mmx/sse/sse2 support on the cpu. */ struct x86_reg { - unsigned file:3; - unsigned idx:3; - unsigned mod:2; /* mod_REG if this is just a register */ - int disp:24; /* only +/- 23bits of offset - should be enough... */ + GLuint file:3; + GLuint idx:3; + GLuint mod:2; /* mod_REG if this is just a register */ + GLint disp:24; /* only +/- 23bits of offset - should be enough... */ }; struct x86_function { - unsigned char *store; - unsigned char *csr; - unsigned stack_offset; - int need_emms; + GLubyte *store; + GLubyte *csr; + GLuint stack_offset; + GLint need_emms; const char *fn; }; @@ -79,7 +81,7 @@ enum sse_cc { void x86_init_func( struct x86_function *p ); -void x86_init_func_size( struct x86_function *p, unsigned code_size ); +void x86_init_func_size( struct x86_function *p, GLuint code_size ); void x86_release_func( struct x86_function *p ); void (*x86_get_func( struct x86_function *p ))( void ); @@ -91,7 +93,7 @@ struct x86_reg x86_make_reg( enum x86_reg_file file, enum x86_reg_name idx ); struct x86_reg x86_make_disp( struct x86_reg reg, - int disp ); + GLint disp ); struct x86_reg x86_deref( struct x86_reg reg ); @@ -100,23 +102,23 @@ struct x86_reg x86_get_base_reg( struct x86_reg reg ); /* Labels, jumps and fixup: */ -unsigned char *x86_get_label( struct x86_function *p ); +GLubyte *x86_get_label( struct x86_function *p ); void x86_jcc( struct x86_function *p, enum x86_cc cc, - unsigned char *label ); + GLubyte *label ); -unsigned char *x86_jcc_forward( struct x86_function *p, +GLubyte *x86_jcc_forward( struct x86_function *p, enum x86_cc cc ); -unsigned char *x86_jmp_forward( struct x86_function *p); +GLubyte *x86_jmp_forward( struct x86_function *p); -unsigned char *x86_call_forward( struct x86_function *p); +GLubyte *x86_call_forward( struct x86_function *p); void x86_fixup_fwd_jump( struct x86_function *p, - unsigned char *fixup ); + GLubyte *fixup ); -void x86_jmp( struct x86_function *p, unsigned char *label ); +void x86_jmp( struct x86_function *p, GLubyte *label ); void x86_call( struct x86_function *p, void (*label)() ); @@ -124,7 +126,7 @@ void x86_call( struct x86_function *p, void (*label)() ); * Temporary. As I need immediate operands, and dont want to mess with the codegen, * I load the immediate into general purpose register and use it. */ -void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, int imm ); +void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm ); /* Macro for sse_shufps() and sse2_pshufd(): @@ -145,8 +147,7 @@ void sse2_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src ) void sse2_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse2_packsswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse2_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char shuf ); +void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf ); void sse2_rcpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse2_rcpss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); @@ -156,8 +157,7 @@ void sse_cvtps2pi( struct x86_function *p, struct x86_reg dst, struct x86_reg sr void sse_divss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_andnps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_andps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_cmpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src, - unsigned char cc ); +void sse_cmpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src, GLubyte cc ); void sse_maxps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_maxss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_minps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); @@ -175,8 +175,7 @@ void sse_xorps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ) void sse_subps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_rsqrtps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); void sse_rsqrtss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); -void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char shuf ); +void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf ); void sse_pmovmskb( struct x86_function *p, struct x86_reg dest, struct x86_reg src ); void x86_add( struct x86_function *p, struct x86_reg dst, struct x86_reg src ); @@ -248,7 +247,7 @@ void x87_fucom( struct x86_function *p, struct x86_reg arg ); * account any push/pop activity. Note - doesn't track explict * manipulation of ESP by other instructions. */ -struct x86_reg x86_fn_arg( struct x86_function *p, unsigned arg ); +struct x86_reg x86_fn_arg( struct x86_function *p, GLuint arg ); #endif #endif -- cgit v1.2.3 From a1a989f0be8dc34082b52bb3b3a6eacb36d9e75e Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Fri, 28 Sep 2007 04:33:55 -0400 Subject: Redoing the way we handle vertex shaders for the draw module. --- src/mesa/pipe/draw/draw_context.c | 8 ----- src/mesa/pipe/draw/draw_context.h | 9 ++++-- src/mesa/pipe/draw/draw_private.h | 14 +++++++-- src/mesa/pipe/draw/draw_vertex_fetch.c | 2 +- src/mesa/pipe/draw/draw_vertex_shader.c | 50 ++++++++++++++++++++++++++++--- src/mesa/pipe/i915simple/i915_state.c | 44 +++++++++++++++++---------- src/mesa/pipe/softpipe/sp_context.c | 8 ++--- src/mesa/pipe/softpipe/sp_context.h | 8 +++-- 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 | 49 +++++++++++++++++++++++------- src/mesa/state_tracker/st_cb_program.c | 7 ----- src/mesa/state_tracker/st_draw.c | 2 +- src/mesa/state_tracker/st_program.c | 8 ----- src/mesa/state_tracker/st_program.h | 4 --- 15 files changed, 152 insertions(+), 77 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index 66c66ff698..5efb173228 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -155,14 +155,6 @@ void draw_set_viewport_state( struct draw_context *draw, } -void -draw_set_vertex_shader(struct draw_context *draw, - const struct pipe_shader_state *shader) -{ - draw_flush( draw ); - draw->vertex_shader = *shader; -} - void draw_set_vertex_buffer(struct draw_context *draw, diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index 0ccf5f6046..398e96d94d 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -92,9 +92,12 @@ void draw_set_rasterize_stage( struct draw_context *draw, struct draw_stage *stage ); -void -draw_set_vertex_shader(struct draw_context *draw, - const struct pipe_shader_state *shader); +void * draw_create_vertex_shader(struct draw_context *draw, + const struct pipe_shader_state *shader); +void draw_bind_vertex_shader(struct draw_context *draw, + void *vcso); +void draw_delete_vertex_shader(struct draw_context *draw, + void *vcso); void diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index ebef5347ab..2f52299f74 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -46,6 +46,7 @@ #include "draw_vertex.h" +#include "x86/rtasm/x86sse.h" /** * Basic vertex info. @@ -104,7 +105,7 @@ struct draw_stage void (*tri)( struct draw_stage *, struct prim_header * ); - + void (*end)( struct draw_stage * ); void (*reset_stipple_counter)( struct draw_stage * ); @@ -116,6 +117,15 @@ struct draw_stage #define VCACHE_OVERFLOW 4 #define VS_QUEUE_LENGTH (VCACHE_SIZE + VCACHE_OVERFLOW + 1) /* can never fill up */ +/** + * Private version of the compiled vertex_shader + */ +struct draw_vertex_shader { + const struct pipe_shader_state *state; +#if defined(__i386__) || defined(__386__) + struct x86_function sse2_program; +#endif +}; /** * Private context for the drawing module. @@ -145,7 +155,7 @@ struct draw_context struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; - struct pipe_shader_state vertex_shader; + 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]; diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index 2b839d641e..bc37e18c34 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -85,7 +85,7 @@ void draw_vertex_fetch( struct draw_context *draw, /*printf("fetch vertex %u: \n", j);*/ /* loop over vertex attributes (vertex shader inputs) */ - for (attr = 0; attr < draw->vertex_shader.num_inputs; attr++) { + for (attr = 0; attr < draw->vertex_shader->state->num_inputs; attr++) { unsigned buf = draw->vertex_element[attr].vertex_buffer_index; const void *src diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index a2e1cdc472..f7ddbd1909 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -36,6 +36,8 @@ #include "draw_context.h" #include "draw_vertex.h" +#include "x86/rtasm/x86sse.h" + #include "pipe/tgsi/exec/tgsi_core.h" static INLINE unsigned @@ -70,6 +72,7 @@ typedef void (XSTDCALL *codegen_function) ( float (*constant)[4], struct tgsi_exec_vector *temporary ); + /** * Transform vertices with the current vertex program/shader * Up to four vertices can be shaded at a time. @@ -92,7 +95,7 @@ run_vertex_program(struct draw_context *draw, const float *trans = draw->viewport.translate; assert(count <= 4); - assert(draw->vertex_shader.output_semantic_name[0] + assert(draw->vertex_shader->state->output_semantic_name[0] == TGSI_SEMANTIC_POSITION); #ifdef DEBUG @@ -101,7 +104,7 @@ run_vertex_program(struct draw_context *draw, /* init machine state */ tgsi_exec_machine_init(&machine, - draw->vertex_shader.tokens, + draw->vertex_shader->state->tokens, PIPE_MAX_SAMPLERS, NULL /*samplers*/ ); @@ -114,8 +117,8 @@ run_vertex_program(struct draw_context *draw, draw_vertex_fetch( draw, &machine, elts, count ); /* run shader */ - if( draw->vertex_shader.executable != NULL ) { - codegen_function func = (codegen_function) draw->vertex_shader.executable; + if( draw->vertex_shader->state->executable != NULL ) { + codegen_function func = (codegen_function) draw->vertex_shader->state->executable; func( machine.Inputs, machine.Outputs, @@ -206,3 +209,42 @@ void draw_vertex_shader_queue_flush( struct draw_context *draw ) draw->vs.queue_nr = 0; } + +void * +draw_create_vertex_shader(struct draw_context *draw, + const struct pipe_shader_state *shader) +{ + struct draw_vertex_shader *vs = calloc(1, sizeof(struct draw_vertex_shader)); + + vs->state = shader; +#if defined(__i386__) || defined(__386__) + x86_init_func(&vs->sse2_program); + + tgsi_emit_sse2(shader->tokens, &vs->sse2_program); + + ((struct pipe_shader_state*)(vs->state))->executable = + x86_get_func(&vs->sse2_program); +#endif + + return vs; +} + +void draw_bind_vertex_shader(struct draw_context *draw, + void *vcso) +{ + draw_flush(draw); + draw->vertex_shader = (struct draw_vertex_shader*)(vcso); +} + +void draw_delete_vertex_shader(struct draw_context *draw, + void *vcso) +{ + struct draw_vertex_shader *vs = (struct draw_vertex_shader*)(vcso); +#if defined(__i386__) || defined(__386__) + x86_release_func(&vs->sse2_program); +#endif + free(vcso); +} + + + diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 5c6d37a466..19ca5e575f 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -443,16 +443,13 @@ static void i915_set_polygon_stipple( struct pipe_context *pipe, { } - -static void * -i915_create_shader_state(struct pipe_context *pipe, - const struct pipe_shader_state *templ) +static void * i915_create_fs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { return 0; } -static void i915_bind_fs_state( struct pipe_context *pipe, - void *fs ) +static void i915_bind_fs_state(struct pipe_context *pipe, void *fs) { struct i915_context *i915 = i915_context(pipe); @@ -461,20 +458,35 @@ static void i915_bind_fs_state( struct pipe_context *pipe, i915->dirty |= I915_NEW_FS; } +static void i915_delete_fs_state(struct pipe_context *pipe, void *shader) +{ + /*do nothing*/ +} -static void i915_bind_vs_state(struct pipe_context *pipe, - void *vs) +static void * +i915_create_vs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { struct i915_context *i915 = i915_context(pipe); /* just pass-through to draw module */ - draw_set_vertex_shader(i915->draw, (const struct pipe_shader_state *)vs); + return draw_create_vertex_shader(i915->draw, templ); } -static void i915_delete_shader_state(struct pipe_context *pipe, - void *shader) +static void i915_bind_vs_state(struct pipe_context *pipe, void *vs) { - /*do nothing*/ + struct i915_context *i915 = i915_context(pipe); + + /* just pass-through to draw module */ + draw_bind_vertex_shader(i915->draw, vs); +} + +static void i915_delete_vs_state(struct pipe_context *pipe, void *shader) +{ + struct i915_context *i915 = i915_context(pipe); + + /* just pass-through to draw module */ + draw_delete_vertex_shader(i915->draw, shader); } static void i915_set_constant_buffer(struct pipe_context *pipe, @@ -707,12 +719,12 @@ 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_fs_state = i915_create_shader_state; + i915->pipe.create_fs_state = i915_create_fs_state; i915->pipe.bind_fs_state = i915_bind_fs_state; - i915->pipe.delete_fs_state = i915_delete_shader_state; - i915->pipe.create_vs_state = i915_create_shader_state; + i915->pipe.delete_fs_state = i915_delete_fs_state; + i915->pipe.create_vs_state = i915_create_vs_state; i915->pipe.bind_vs_state = i915_bind_vs_state; - i915->pipe.delete_vs_state = i915_delete_shader_state; + i915->pipe.delete_vs_state = i915_delete_vs_state; i915->pipe.set_blend_color = i915_set_blend_color; i915->pipe.set_clip_state = i915_set_clip_state; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index e415966dae..695bf1a9e0 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -275,12 +275,12 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state; softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state; softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state; - softpipe->pipe.create_fs_state = softpipe_create_shader_state; + softpipe->pipe.create_fs_state = softpipe_create_fs_state; softpipe->pipe.bind_fs_state = softpipe_bind_fs_state; - softpipe->pipe.delete_fs_state = softpipe_delete_shader_state; - softpipe->pipe.create_vs_state = softpipe_create_shader_state; + softpipe->pipe.delete_fs_state = softpipe_delete_fs_state; + softpipe->pipe.create_vs_state = softpipe_create_vs_state; softpipe->pipe.bind_vs_state = softpipe_bind_vs_state; - softpipe->pipe.delete_vs_state = softpipe_delete_shader_state; + softpipe->pipe.delete_vs_state = softpipe_delete_vs_state; softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_clip_state = softpipe_set_clip_state; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index c0a681f3d6..ccf29b5683 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -62,8 +62,12 @@ struct draw_stage; #define SP_NEW_VS 0x2000 #define SP_NEW_CONSTANTS 0x4000 +struct sp_vertex_shader_state { + const struct pipe_shader_state *state; + void *draw_data; +}; -struct softpipe_context { +struct softpipe_context { struct pipe_context pipe; /**< base class */ struct softpipe_winsys *winsys; /**< window system interface */ @@ -76,7 +80,7 @@ struct softpipe_context { 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; + const struct sp_vertex_shader_state *vs; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index f0e1461d25..f9061e86e5 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -87,12 +87,14 @@ void softpipe_set_constant_buffer(struct pipe_context *, void softpipe_set_feedback_state( struct pipe_context *, const struct pipe_feedback_state * ); -void * -softpipe_create_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_create_fs_state(struct pipe_context *, + const struct pipe_shader_state *); +void softpipe_bind_fs_state(struct pipe_context *, void *); +void softpipe_delete_fs_state(struct pipe_context *, void *); +void *softpipe_create_vs_state(struct pipe_context *, + const struct pipe_shader_state *); +void softpipe_bind_vs_state(struct pipe_context *, void *); +void softpipe_delete_vs_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_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 6c6e798069..b6145df8e2 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 struct pipe_shader_state *vs = softpipe->vs; + const struct pipe_shader_state *vs = softpipe->vs->state; const struct pipe_shader_state *fs = softpipe->fs; const interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index 8306a95f44..f1bec2c73a 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -33,10 +33,13 @@ #include "pipe/draw/draw_context.h" -void * softpipe_create_shader_state(struct pipe_context *pipe, - const struct pipe_shader_state *templ) +void * softpipe_create_fs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) { - /* we just want the pipe_shader_state template in the bind calls */ + /* Decide whether we'll be codegenerating this shader and if so do + * that now. + */ + return 0; } @@ -49,25 +52,51 @@ void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) softpipe->dirty |= SP_NEW_FS; } +void softpipe_delete_fs_state(struct pipe_context *pipe, + void *shader) +{ +} + + +void * softpipe_create_vs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + struct sp_vertex_shader_state *state = + malloc(sizeof(struct sp_vertex_shader_state)); + + state->state = templ; + state->draw_data = draw_create_vertex_shader(softpipe->draw, + state->state); + + return state; +} void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->vs = (struct pipe_shader_state *)vs; + softpipe->vs = (const struct sp_vertex_shader_state *)vs; - softpipe->dirty |= SP_NEW_VS; + draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data); - draw_set_vertex_shader(softpipe->draw, (struct pipe_shader_state *)vs); + softpipe->dirty |= SP_NEW_VS; } - -void softpipe_delete_shader_state( struct pipe_context *pipe, - void *shader ) +void softpipe_delete_vs_state(struct pipe_context *pipe, + void *vs) { - /* do nothing */ + struct softpipe_context *softpipe = softpipe_context(pipe); + + struct sp_vertex_shader_state *state = + (struct sp_vertex_shader_state *)vs; + + draw_delete_vertex_shader(softpipe->draw, state->draw_data); + free(state); } + + 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_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 25dbc2c244..3a7ce9405e 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -86,10 +86,6 @@ static struct gl_program *st_new_program( GLcontext *ctx, prog->serialNo = 1; -#if defined(__i386__) || defined(__386__) - x86_init_func( &prog->sse2_program ); -#endif - return _mesa_init_vertex_program( ctx, &prog->Base, target, @@ -129,9 +125,6 @@ static void st_delete_program( GLcontext *ctx, case GL_VERTEX_PROGRAM_ARB: { struct st_vertex_program *stvp = (struct st_vertex_program *) prog; -#if defined(__i386__) || defined(__386__) - x86_release_func( &stvp->sse2_program ); -#endif st_remove_vertex_program(st, stvp); } break; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index ce5bf0c8a9..7c836ba2c1 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -405,7 +405,7 @@ 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->state); - draw_set_vertex_shader(draw, &st->state.vs->state); + draw_bind_vertex_shader(draw, st->state.vs->data); /* XXX need to set vertex info too */ diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 44cc33b09f..116b59a067 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -253,14 +253,6 @@ st_translate_vertex_program(struct st_context *st, if (TGSI_DEBUG) tgsi_dump( tokensOut, 0 ); -#if defined(__i386__) || defined(__386__) - if (stvp->sse2_program.csr == stvp->sse2_program.store) - 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 ); -#endif - return cso; } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 6e106c16b0..2b79201313 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -79,10 +79,6 @@ struct st_vertex_program /** The program in TGSI format */ struct tgsi_token tokens[ST_FP_MAX_TOKENS]; -#if defined(__i386__) || defined(__386__) - struct x86_function sse2_program; -#endif - /** Pointer to the corresponding cached shader */ const struct cso_vertex_shader *vs; -- cgit v1.2.3 From 453ac4b1ebc70aeabb182f2b336c6abb3324323e Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 10 Oct 2007 18:00:12 -0600 Subject: Use winsys->user_buffer_create() to wrap user-space vertex arrays and element buffers. Now client-side vertex arrays and glDrawElements work. More testing/debug/clean-up to come... --- src/mesa/state_tracker/st_draw.c | 72 ++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 22 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 7c836ba2c1..22f09c7a98 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -31,6 +31,7 @@ */ #include "main/imports.h" +#include "main/image.h" #include "vbo/vbo.h" #include "vbo/vbo_context.h" @@ -61,6 +62,12 @@ pipe_vertex_format(GLenum format, GLuint size) PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT, }; + static const GLuint int_fmts[4] = { + PIPE_FORMAT_R32_SSCALED, + PIPE_FORMAT_R32G32_SSCALED, + PIPE_FORMAT_R32G32B32_SSCALED, + PIPE_FORMAT_R32G32B32A32_SSCALED, + }; assert(format >= GL_BYTE); assert(format <= GL_DOUBLE); @@ -70,6 +77,8 @@ pipe_vertex_format(GLenum format, GLuint size) switch (format) { case GL_FLOAT: return float_fmts[size - 1]; + case GL_INT: + return int_fmts[size - 1]; default: assert(0); } @@ -215,6 +224,7 @@ st_draw_vbo(GLcontext *ctx, velement.src_format = 0; if (bufobj && bufobj->Name) { + /* attribute data is in a VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); /* Recall that for VBOs, the gl_client_array->Ptr field is * really an offset from the start of the VBO, not a pointer. @@ -236,23 +246,30 @@ st_draw_vbo(GLcontext *ctx, assert(velement.src_format); } else { - /* use the default attribute buffer */ - needDefaultAttribs = GL_TRUE; + /* attribute data is in user-space memory, not a VBO */ + uint bytes = (arrays[mesaAttr]->Size + * _mesa_sizeof_type(arrays[mesaAttr]->Type) + * (max_index + 1)); + + /* wrap user data */ + vbuffer.buffer + = pipe->winsys->user_buffer_create(pipe->winsys, + (void *) arrays[mesaAttr]->Ptr, + bytes); + + /* XXX need to deref/free this buffer.vbuffer after drawing! */ - vbuffer.buffer = ctx->st->default_attrib_buffer; vbuffer.buffer_offset = 0; - vbuffer.pitch = 0; /* must be zero! */ - vbuffer.max_index = 1; + vbuffer.pitch = arrays[mesaAttr]->StrideB; /* in bytes */ + vbuffer.max_index = 0; /* need this? */ - velement.src_offset = mesaAttr * 4 * sizeof(GLfloat); + velement.src_offset = 0; velement.vertex_buffer_index = attr; - velement.dst_offset = 0; - velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velement.dst_offset = 0; /* need this? */ + velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size); } - if (attr == 0) - assert(vbuffer.buffer); - pipe->set_vertex_buffer(pipe, attr, &vbuffer); pipe->set_vertex_element(pipe, attr, &velement); } @@ -268,30 +285,41 @@ st_draw_vbo(GLcontext *ctx, struct gl_buffer_object *bufobj = ib->obj; struct pipe_buffer_handle *bh = NULL; unsigned indexSize, i; + GLboolean userBuffer = GL_FALSE; + + switch (ib->type) { + case GL_UNSIGNED_INT: + indexSize = 4; + break; + case GL_UNSIGNED_SHORT: + indexSize = 2; + break; + default: + assert(0); + } if (bufobj && bufobj->Name) { /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); bh = stobj->buffer; - switch (ib->type) { - case GL_UNSIGNED_INT: - indexSize = 4; - break; - case GL_UNSIGNED_SHORT: - indexSize = 2; - break; - default: - assert(0); - } + /* XXX reference buffer here, don't special case userBuffer below */ } else { - assert(0); + /* element/indicies are in user space memory */ + bh = pipe->winsys->user_buffer_create(pipe->winsys, + (void *) ib->ptr, + ib->count * indexSize); + userBuffer = GL_TRUE; } for (i = 0; i < nr_prims; i++) { pipe->draw_elements(pipe, bh, indexSize, prims[i].mode, prims[i].start, prims[i].count); } + + if (userBuffer) { + pipe->winsys->buffer_reference(pipe->winsys, &bh, NULL); + } } else { /* non-indexed */ -- cgit v1.2.3 From 71efb6cf69724da2f1e783a13c3074d4e8645c64 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 11 Oct 2007 09:11:13 -0600 Subject: clean-up, streamline st_draw_vbo() --- src/mesa/state_tracker/st_draw.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 22f09c7a98..bfaa352fdc 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -197,6 +197,7 @@ st_draw_vbo(GLcontext *ctx, GLuint max_index) { struct pipe_context *pipe = ctx->st->pipe; + struct pipe_winsys *winsys = pipe->winsys; const struct st_vertex_program *vp; const struct pipe_shader_state *vs; const unsigned attr0_offset = (unsigned) arrays[0]->Ptr; @@ -253,9 +254,9 @@ st_draw_vbo(GLcontext *ctx, /* wrap user data */ vbuffer.buffer - = pipe->winsys->user_buffer_create(pipe->winsys, - (void *) arrays[mesaAttr]->Ptr, - bytes); + = winsys->user_buffer_create(winsys, + (void *) arrays[mesaAttr]->Ptr, + bytes); /* XXX need to deref/free this buffer.vbuffer after drawing! */ @@ -283,9 +284,8 @@ st_draw_vbo(GLcontext *ctx, if (ib) { /* indexed primitive */ struct gl_buffer_object *bufobj = ib->obj; - struct pipe_buffer_handle *bh = NULL; + struct pipe_buffer_handle *indexBuf = NULL; unsigned indexSize, i; - GLboolean userBuffer = GL_FALSE; switch (ib->type) { case GL_UNSIGNED_INT: @@ -298,28 +298,26 @@ st_draw_vbo(GLcontext *ctx, assert(0); } + /* get/create the index buffer object */ if (bufobj && bufobj->Name) { /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); - bh = stobj->buffer; - /* XXX reference buffer here, don't special case userBuffer below */ + winsys->buffer_reference(winsys, &indexBuf, stobj->buffer); } else { /* element/indicies are in user space memory */ - bh = pipe->winsys->user_buffer_create(pipe->winsys, + indexBuf = winsys->user_buffer_create(winsys, (void *) ib->ptr, ib->count * indexSize); - userBuffer = GL_TRUE; } + /* draw */ for (i = 0; i < nr_prims; i++) { - pipe->draw_elements(pipe, bh, indexSize, - prims[i].mode, prims[i].start, prims[i].count); + pipe->draw_elements(pipe, indexBuf, indexSize, + prims[i].mode, prims[i].start, prims[i].count); } - if (userBuffer) { - pipe->winsys->buffer_reference(pipe->winsys, &bh, NULL); - } + winsys->buffer_reference(winsys, &indexBuf, NULL); } else { /* non-indexed */ -- cgit v1.2.3 From 4d79f2c4a2ef87595558051b3bdaeb54b4bd0339 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 11 Oct 2007 09:48:06 -0600 Subject: streamline st_draw_vbo() a bit more, free user-space buffers at end --- src/mesa/state_tracker/st_draw.c | 76 +++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 44 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index bfaa352fdc..f8a3440bc9 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -200,9 +200,11 @@ st_draw_vbo(GLcontext *ctx, struct pipe_winsys *winsys = pipe->winsys; const struct st_vertex_program *vp; const struct pipe_shader_state *vs; - const unsigned attr0_offset = (unsigned) arrays[0]->Ptr; - GLboolean needDefaultAttribs = GL_FALSE; GLuint attr; + struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; + + /* sanity check for pointer arithmetic below */ + assert(sizeof(arrays[0]->Ptr[0]) == 1); st_validate_state(ctx->st); @@ -210,41 +212,26 @@ st_draw_vbo(GLcontext *ctx, vp = ctx->st->vp; vs = &ctx->st->state.vs->state; - /* loop over TGSI shader inputs */ + /* loop over TGSI shader inputs to determine vertex buffer + * and attribute info + */ for (attr = 0; attr < vs->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; - - struct pipe_vertex_buffer vbuffer; struct pipe_vertex_element velement; - vbuffer.buffer = NULL; - vbuffer.pitch = 0; - velement.src_offset = 0; - velement.vertex_buffer_index = 0; - velement.src_format = 0; - if (bufobj && bufobj->Name) { - /* attribute data is in a VBO */ - struct st_buffer_object *stobj = st_buffer_object(bufobj); - /* Recall that for VBOs, the gl_client_array->Ptr field is + /* Attribute data is in a VBO. + * Recall that for VBOs, the gl_client_array->Ptr field is * really an offset from the start of the VBO, not a pointer. */ - unsigned offset = (unsigned) arrays[mesaAttr]->Ptr; - + struct st_buffer_object *stobj = st_buffer_object(bufobj); assert(stobj->buffer); - vbuffer.buffer = stobj->buffer; - vbuffer.buffer_offset = attr0_offset; /* in bytes */ - vbuffer.pitch = arrays[mesaAttr]->StrideB; /* in bytes */ - vbuffer.max_index = 0; /* need this? */ - - velement.src_offset = offset - attr0_offset; /* bytes */ - velement.vertex_buffer_index = attr; - velement.dst_offset = 0; /* need this? */ - velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size); - assert(velement.src_format); + vbuffer[attr].buffer = NULL; + winsys->buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); + vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ + velement.src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; } else { /* attribute data is in user-space memory, not a VBO */ @@ -253,32 +240,28 @@ st_draw_vbo(GLcontext *ctx, * (max_index + 1)); /* wrap user data */ - vbuffer.buffer + vbuffer[attr].buffer = winsys->user_buffer_create(winsys, (void *) arrays[mesaAttr]->Ptr, bytes); - - /* XXX need to deref/free this buffer.vbuffer after drawing! */ - - vbuffer.buffer_offset = 0; - vbuffer.pitch = arrays[mesaAttr]->StrideB; /* in bytes */ - vbuffer.max_index = 0; /* need this? */ - + vbuffer[attr].buffer_offset = 0; velement.src_offset = 0; - velement.vertex_buffer_index = attr; - velement.dst_offset = 0; /* need this? */ - velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size); } - pipe->set_vertex_buffer(pipe, attr, &vbuffer); + /* common-case setup */ + vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ + vbuffer[attr].max_index = 0; /* need this? */ + velement.vertex_buffer_index = attr; + velement.dst_offset = 0; /* need this? */ + velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size); + assert(velement.src_format); + + /* tell pipe about this attribute */ + pipe->set_vertex_buffer(pipe, attr, &vbuffer[attr]); pipe->set_vertex_element(pipe, attr, &velement); } - if (needDefaultAttribs) { - update_default_attribs_buffer(ctx); - } - /* do actual drawing */ if (ib) { @@ -326,6 +309,11 @@ st_draw_vbo(GLcontext *ctx, pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count); } } + + /* unreference buffers (frees wrapped user-space buffer objects) */ + for (attr = 0; attr < vs->num_inputs; attr++) { + winsys->buffer_reference(winsys, &vbuffer[attr].buffer, NULL); + } } -- cgit v1.2.3 From 55dd7d794719ebdbf62b58cc15e022ce1e430873 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 11 Oct 2007 10:00:54 -0600 Subject: update st_feedback_draw_vbo() --- src/mesa/state_tracker/st_draw.c | 138 ++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 80 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index f8a3440bc9..aa7fedf9b8 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -171,17 +171,6 @@ destroy_default_attribs_buffer(struct st_context *st) } -static void -update_default_attribs_buffer(GLcontext *ctx) -{ - struct pipe_context *pipe = ctx->st->pipe; - struct pipe_buffer_handle *buf = ctx->st->default_attrib_buffer; - const unsigned size = sizeof(ctx->Current.Attrib); - const void *data = ctx->Current.Attrib; - pipe->winsys->buffer_data(pipe->winsys, buf, size, data); -} - - /** * This function gets plugged into the VBO module and is called when * we have something to render. @@ -200,8 +189,8 @@ st_draw_vbo(GLcontext *ctx, struct pipe_winsys *winsys = pipe->winsys; const struct st_vertex_program *vp; const struct pipe_shader_state *vs; - GLuint attr; struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; + GLuint attr; /* sanity check for pointer arithmetic below */ assert(sizeof(arrays[0]->Ptr[0]) == 1); @@ -400,15 +389,23 @@ st_feedback_draw_vbo(GLcontext *ctx, struct st_context *st = ctx->st; struct pipe_context *pipe = st->pipe; struct draw_context *draw = st->draw; - GLuint attr, i; - GLbitfield attrsNeeded; - const unsigned attr0_offset = (unsigned) arrays[0]->Ptr; + struct pipe_winsys *winsys = pipe->winsys; + const struct st_vertex_program *vp; + const struct pipe_shader_state *vs; struct pipe_buffer_handle *index_buffer_handle = 0; + struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; + GLuint attr, i; assert(ctx->RenderMode == GL_SELECT || ctx->RenderMode == GL_FEEDBACK); assert(draw); + st_validate_state(ctx->st); + + /* must get these after state validation! */ + vp = ctx->st->vp; + vs = &ctx->st->state.vs->state; + /* * Set up the draw module's state. * @@ -420,82 +417,63 @@ st_feedback_draw_vbo(GLcontext *ctx, draw_set_clip_state(draw, &st->state.clip); draw_set_rasterizer_state(draw, &st->state.rasterizer->state); draw_bind_vertex_shader(draw, st->state.vs->data); - /* XXX need to set vertex info too */ - - update_default_attribs_buffer(ctx); -#if 0 - /* this must be after state validation */ - attrsNeeded = ctx->st->state.vs->inputs_read; - - /* tell draw module about the vertex array element/attributes */ - for (attr = 0; attr < 16; attr++) { - struct pipe_vertex_buffer vbuffer; + /* loop over TGSI shader inputs to determine vertex buffer + * and attribute info + */ + for (attr = 0; attr < vs->num_inputs; attr++) { + const GLuint mesaAttr = vp->index_to_input[attr]; + struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; struct pipe_vertex_element velement; void *map; - vbuffer.buffer = NULL; - vbuffer.pitch = 0; - velement.src_offset = 0; - velement.vertex_buffer_index = 0; - velement.src_format = 0; - - if (attrsNeeded & (1 << attr)) { - const GLuint mesaAttr = tgsi_attrib_to_mesa_attrib(attr); - struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; - - if (bufobj && bufobj->Name) { - struct st_buffer_object *stobj = st_buffer_object(bufobj); - /* Recall that for VBOs, the gl_client_array->Ptr field is - * really an offset from the start of the VBO, not a pointer. - */ - unsigned offset = (unsigned) arrays[mesaAttr]->Ptr; - - assert(stobj->buffer); - - vbuffer.buffer = stobj->buffer; - vbuffer.buffer_offset = attr0_offset; /* in bytes */ - vbuffer.pitch = arrays[mesaAttr]->StrideB; /* in bytes */ - vbuffer.max_index = 0; /* need this? */ - - velement.src_offset = offset - attr0_offset; /* bytes */ - velement.vertex_buffer_index = attr; - velement.dst_offset = 0; /* need this? */ - velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size); - assert(velement.src_format); - } - else { - /* use the default attribute buffer */ - vbuffer.buffer = ctx->st->default_attrib_buffer; - vbuffer.buffer_offset = 0; - vbuffer.pitch = 0; /* must be zero! */ - vbuffer.max_index = 1; - - velement.src_offset = attr * 4 * sizeof(GLfloat); - velement.vertex_buffer_index = attr; - velement.dst_offset = 0; - velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - } + if (bufobj && bufobj->Name) { + /* Attribute data is in a VBO. + * Recall that for VBOs, the gl_client_array->Ptr field is + * really an offset from the start of the VBO, not a pointer. + */ + struct st_buffer_object *stobj = st_buffer_object(bufobj); + assert(stobj->buffer); + + vbuffer[attr].buffer = NULL; + winsys->buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); + vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ + velement.src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; + } + else { + /* attribute data is in user-space memory, not a VBO */ + uint bytes = (arrays[mesaAttr]->Size + * _mesa_sizeof_type(arrays[mesaAttr]->Type) + * (max_index + 1)); + + /* wrap user data */ + vbuffer[attr].buffer + = winsys->user_buffer_create(winsys, + (void *) arrays[mesaAttr]->Ptr, + bytes); + vbuffer[attr].buffer_offset = 0; + velement.src_offset = 0; } - if (attr == 0) - assert(vbuffer.buffer); + /* common-case setup */ + vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ + vbuffer[attr].max_index = 0; /* need this? */ + velement.vertex_buffer_index = attr; + velement.dst_offset = 0; /* need this? */ + velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size); + assert(velement.src_format); - draw_set_vertex_buffer(draw, attr, &vbuffer); + /* tell draw about this attribute */ + draw_set_vertex_buffer(draw, attr, &vbuffer[attr]); draw_set_vertex_element(draw, attr, &velement); /* map the attrib buffer */ - if (vbuffer.buffer) { - map = pipe->winsys->buffer_map(pipe->winsys, - vbuffer.buffer, - PIPE_BUFFER_FLAG_READ); - draw_set_mapped_vertex_buffer(draw, attr, map); - } + map = pipe->winsys->buffer_map(pipe->winsys, + vbuffer[attr].buffer, + PIPE_BUFFER_FLAG_READ); + draw_set_mapped_vertex_buffer(draw, attr, map); } -#else - assert(0); -#endif if (ib) { unsigned indexSize; -- cgit v1.2.3 From 3ab326e1d7ef0ae9bd03dbce33e791449b865ba1 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 11 Oct 2007 10:01:17 -0600 Subject: remove unused tgsi_attrib_to_mesa_attrib() --- src/mesa/state_tracker/st_draw.c | 64 ---------------------------------------- 1 file changed, 64 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index aa7fedf9b8..26cd76f939 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -85,70 +85,6 @@ pipe_vertex_format(GLenum format, GLuint size) } -#if 0 -/** - * Convert a mesa vertex attribute to a TGSI attribute - */ -static GLuint -tgsi_attrib_to_mesa_attrib(GLuint attr) -{ - switch (attr) { - case TGSI_ATTRIB_POS: - return VERT_ATTRIB_POS; - case TGSI_ATTRIB_WEIGHT: - return VERT_ATTRIB_WEIGHT; - case TGSI_ATTRIB_NORMAL: - return VERT_ATTRIB_NORMAL; - case TGSI_ATTRIB_COLOR0: - return VERT_ATTRIB_COLOR0; - case TGSI_ATTRIB_COLOR1: - return VERT_ATTRIB_COLOR1; - case TGSI_ATTRIB_FOG: - return VERT_ATTRIB_FOG; - case TGSI_ATTRIB_COLOR_INDEX: - return VERT_ATTRIB_COLOR_INDEX; - case TGSI_ATTRIB_EDGEFLAG: - return VERT_ATTRIB_EDGEFLAG; - case TGSI_ATTRIB_TEX0: - return VERT_ATTRIB_TEX0; - case TGSI_ATTRIB_TEX1: - return VERT_ATTRIB_TEX1; - case TGSI_ATTRIB_TEX2: - return VERT_ATTRIB_TEX2; - case TGSI_ATTRIB_TEX3: - return VERT_ATTRIB_TEX3; - case TGSI_ATTRIB_TEX4: - return VERT_ATTRIB_TEX4; - case TGSI_ATTRIB_TEX5: - return VERT_ATTRIB_TEX5; - case TGSI_ATTRIB_TEX6: - return VERT_ATTRIB_TEX6; - case TGSI_ATTRIB_TEX7: - return VERT_ATTRIB_TEX7; - case TGSI_ATTRIB_VAR0: - return VERT_ATTRIB_GENERIC0; - case TGSI_ATTRIB_VAR1: - return VERT_ATTRIB_GENERIC1; - case TGSI_ATTRIB_VAR2: - return VERT_ATTRIB_GENERIC2; - case TGSI_ATTRIB_VAR3: - return VERT_ATTRIB_GENERIC3; - case TGSI_ATTRIB_VAR4: - return VERT_ATTRIB_GENERIC4; - case TGSI_ATTRIB_VAR5: - return VERT_ATTRIB_GENERIC5; - case TGSI_ATTRIB_VAR6: - return VERT_ATTRIB_GENERIC6; - case TGSI_ATTRIB_VAR7: - return VERT_ATTRIB_GENERIC7; - default: - assert(0); - return 0; - } -} -#endif - - /** * The default attribute buffer is basically a copy of the * ctx->Current.Attrib[] array. It's used when the vertex program -- cgit v1.2.3 From afd6bd3cb0036089f7fe01eb140b5d9ee2654ce9 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 11 Oct 2007 10:03:59 -0600 Subject: rename some vars, updated comments --- src/mesa/state_tracker/st_draw.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 26cd76f939..f62f2b3a3a 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -53,8 +53,11 @@ #include "pipe/draw/draw_context.h" +/** + * Return a PIPE_FORMAT_x for the given GL datatype and size. + */ static GLuint -pipe_vertex_format(GLenum format, GLuint size) +pipe_vertex_format(GLenum type, GLuint size) { static const GLuint float_fmts[4] = { PIPE_FORMAT_R32_FLOAT, @@ -69,12 +72,12 @@ pipe_vertex_format(GLenum format, GLuint size) PIPE_FORMAT_R32G32B32A32_SSCALED, }; - assert(format >= GL_BYTE); - assert(format <= GL_DOUBLE); + assert(type >= GL_BYTE); + assert(type <= GL_DOUBLE); assert(size >= 1); assert(size <= 4); - switch (format) { + switch (type) { case GL_FLOAT: return float_fmts[size - 1]; case GL_INT: @@ -250,7 +253,6 @@ st_draw_vbo(GLcontext *ctx, * \param numVertex number of vertices * \param verts vertex data (all attributes are float[4]) * \param numAttribs number of attributes per vertex - * \param attribs index of each attribute (0=pos, 3=color, etc) */ void st_draw_vertices(GLcontext *ctx, unsigned prim, @@ -460,14 +462,12 @@ st_feedback_draw_vbo(GLcontext *ctx, -/* This is all a hack to keep using tnl until we have vertex programs - * up and running. - */ void st_init_draw( struct st_context *st ) { GLcontext *ctx = st->ctx; struct vbo_context *vbo = (struct vbo_context *) ctx->swtnl_im; + /* actually, not used here, but elsewhere */ create_default_attribs_buffer(st); assert(vbo); -- cgit v1.2.3 From 47fc06753ec4319a3ac6470060a4582975daceda Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 12 Oct 2007 16:13:15 -0600 Subject: added assertion to be sure we don't exceed bitfield size --- src/mesa/state_tracker/st_draw.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index f62f2b3a3a..cc204640eb 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -160,6 +160,7 @@ st_draw_vbo(GLcontext *ctx, winsys->buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ velement.src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; + assert(velement.src_offset <= 2048); /* 11-bit field */ } else { /* attribute data is in user-space memory, not a VBO */ -- cgit v1.2.3 From 8630e5edb36f00de30117d56c1691363d471c0cc Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 15 Oct 2007 13:05:15 -0600 Subject: call pipe->set_vertex_buffer() after drawing/unreferencing. This fixes potential a stale reference to vertex buffers. Fixes cubemap demo on i915. --- src/mesa/state_tracker/st_draw.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index cc204640eb..640fa8263e 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -242,6 +242,8 @@ st_draw_vbo(GLcontext *ctx, /* unreference buffers (frees wrapped user-space buffer objects) */ for (attr = 0; attr < vs->num_inputs; attr++) { winsys->buffer_reference(winsys, &vbuffer[attr].buffer, NULL); + assert(!vbuffer[attr].buffer); + pipe->set_vertex_buffer(pipe, attr, &vbuffer[attr]); } } -- cgit v1.2.3 From 520ad5f854723955c89584e4fa0bd172d0969e09 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 15 Oct 2007 13:25:13 -0600 Subject: GL_SELECT mode works now --- src/mesa/state_tracker/st_cb_feedback.c | 7 +++++++ src/mesa/state_tracker/st_draw.c | 15 +++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 537a58f39d..f0c6bf6185 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -293,6 +293,13 @@ st_RenderMode(GLcontext *ctx, GLenum newMode ) draw_set_rasterize_stage(draw, st->selection_stage); /* Plug in new vbo draw function */ vbo->draw_prims = st_feedback_draw_vbo; + /* setup post-transform vertex attribs */ + { + /* just emit pos as GLfloat[4] */ + static const uint attrs[1] = { FORMAT_4F }; + const interp_mode *interp = NULL; + draw_set_vertex_attributes(draw, attrs, interp, 1); + } } else { if (!st->feedback_stage) diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 640fa8263e..7fcc4d8e65 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -336,6 +336,7 @@ st_feedback_draw_vbo(GLcontext *ctx, struct pipe_buffer_handle *index_buffer_handle = 0; struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; GLuint attr, i; + ubyte *mapped_constants; assert(ctx->RenderMode == GL_SELECT || ctx->RenderMode == GL_FEEDBACK); @@ -439,6 +440,17 @@ st_feedback_draw_vbo(GLcontext *ctx, PIPE_BUFFER_FLAG_READ); draw_set_mapped_element_buffer(draw, indexSize, map); } + else { + /* no index/element buffer */ + draw_set_mapped_element_buffer(draw, 0, NULL); + } + + + /* map constant buffers */ + mapped_constants = winsys->buffer_map(winsys, + st->state.constants[PIPE_SHADER_VERTEX].buffer, + PIPE_BUFFER_FLAG_READ); + draw_set_mapped_constant_buffer(st->draw, mapped_constants); /* draw here */ @@ -447,6 +459,9 @@ st_feedback_draw_vbo(GLcontext *ctx, } + /* unmap constant buffers */ + winsys->buffer_unmap(winsys, st->state.constants[PIPE_SHADER_VERTEX].buffer); + /* * unmap vertex/index buffers */ -- cgit v1.2.3 From 0585b4e746f35efbc8577311eab6679951217ac3 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 15 Oct 2007 15:05:08 -0600 Subject: Undo prev changes. --- src/mesa/state_tracker/st_cb_feedback.c | 29 ++++++----------------------- src/mesa/state_tracker/st_draw.c | 30 ++++++++++++++++++++++++++++++ src/mesa/tnl/t_vp_build.c | 7 +++++++ 3 files changed, 43 insertions(+), 23 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 5e334e3c85..923e1cdb89 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -93,8 +93,9 @@ feedback_vertex(GLcontext *ctx, const struct draw_context *draw, const GLfloat ci = 0; GLuint slot; + /* Recall that Y=0=Top of window for Gallium wincoords */ win[0] = v->data[0][0]; - win[1] = v->data[0][1]; + win[1] = ctx->DrawBuffer->Height - v->data[0][1]; win[2] = v->data[0][2]; win[3] = 1.0F / v->data[0][3]; @@ -104,13 +105,13 @@ feedback_vertex(GLcontext *ctx, const struct draw_context *draw, */ slot = st->vertex_result_to_slot[VERT_RESULT_COL0]; - if (slot) + if (slot != ~0) color = v->data[slot]; else color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; slot = st->vertex_result_to_slot[VERT_RESULT_TEX0]; - if (slot) + if (slot != ~0) texcoord = v->data[slot]; else texcoord = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; @@ -294,13 +295,6 @@ st_RenderMode(GLcontext *ctx, GLenum newMode ) draw_set_rasterize_stage(draw, st->selection_stage); /* Plug in new vbo draw function */ vbo->draw_prims = st_feedback_draw_vbo; - /* setup post-transform vertex attribs */ - { - /* just emit pos as GLfloat[4] */ - static const uint attrs[1] = { FORMAT_4F }; - const interp_mode *interp = NULL; - draw_set_vertex_attributes(draw, attrs, interp, 1); - } } else { if (!st->feedback_stage) @@ -308,19 +302,8 @@ st_RenderMode(GLcontext *ctx, GLenum newMode ) draw_set_rasterize_stage(draw, st->feedback_stage); /* Plug in new vbo draw function */ vbo->draw_prims = st_feedback_draw_vbo; - /* setup post-transform vertex attribs */ - { - /* emit all attribs as GLfloat[4] */ - uint attrs[PIPE_MAX_SHADER_OUTPUTS]; - interp_mode interp[PIPE_MAX_SHADER_OUTPUTS]; - GLuint n = st->state.vs->state.num_outputs; - GLuint i; - for (i = 0; i < n; i++) { - attrs[i] = FORMAT_4F; - interp[i] = INTERP_NONE; - } - draw_set_vertex_attributes(draw, attrs, interp, n); - } + /* need to generate/use a vertex program that emits pos/color/tex */ + st->dirty.st |= ST_NEW_VERTEX_PROGRAM; } } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 7fcc4d8e65..1806a1888b 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -310,6 +310,35 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, } +/** + * Set the (private) draw module's post-transformed vertex format when in + * GL_SELECT or GL_FEEDBACK mode. + */ +static void +set_feedback_vertex_format(GLcontext *ctx) +{ + struct st_context *st = ctx->st; + uint attrs[PIPE_MAX_SHADER_OUTPUTS]; + interp_mode interp[PIPE_MAX_SHADER_OUTPUTS]; + GLuint n, i; + + if (ctx->RenderMode == GL_FEEDBACK) { + /* emit all attribs (pos, color, texcoord) as GLfloat[4] */ + n = st->state.vs->state.num_outputs; + for (i = 0; i < n; i++) { + attrs[i] = FORMAT_4F; + interp[i] = INTERP_NONE; + } + } + else { + assert(ctx->RenderMode == GL_SELECT); + n = 1; + attrs[0] = FORMAT_4F; + interp[0] = INTERP_NONE; + } + + draw_set_vertex_attributes(st->draw, attrs, interp, n); +} /** @@ -359,6 +388,7 @@ st_feedback_draw_vbo(GLcontext *ctx, draw_set_clip_state(draw, &st->state.clip); draw_set_rasterizer_state(draw, &st->state.rasterizer->state); draw_bind_vertex_shader(draw, st->state.vs->data); + set_feedback_vertex_format(ctx); /* loop over TGSI shader inputs to determine vertex buffer * and attribute info diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index b28102b1b9..a588b0d16b 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -134,6 +134,13 @@ static struct state_key *make_state_key( GLcontext *ctx ) assert(fp); key->fragprog_inputs_read = fp->Base.InputsRead; + if (ctx->RenderMode == GL_FEEDBACK) { + /* This is a bit of a hack, but you can imagine feedback mode as using + * a special no-op fragment shader that just requires particular + * inputs (inputs which satisfy feedback mode). + */ + key->fragprog_inputs_read |= FRAG_BIT_COL0 | FRAG_BIT_TEX0; + } key->separate_specular = (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR); -- cgit v1.2.3 From b2605d5f803f51f216fd815374b59dfc616f7e13 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 15 Oct 2007 17:27:54 -0600 Subject: GL_UNSIGNED_BYTE indexes --- src/mesa/state_tracker/st_draw.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 1806a1888b..fbf7713f58 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -206,6 +206,9 @@ st_draw_vbo(GLcontext *ctx, case GL_UNSIGNED_SHORT: indexSize = 2; break; + case GL_UNSIGNED_BYTE: + indexSize = 1; + break; default: assert(0); } -- cgit v1.2.3 From 11ce6244a79106c592364b30434b6ddade3fd6bb Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Oct 2007 14:34:40 -0600 Subject: Undo indexOffset change (I think, git???) --- src/mesa/pipe/failover/fo_context.c | 6 ++++-- src/mesa/pipe/i915simple/i915_context.c | 7 ++++--- src/mesa/pipe/p_context.h | 2 +- src/mesa/pipe/softpipe/sp_draw_arrays.c | 7 ++++--- src/mesa/pipe/softpipe/sp_state.h | 2 +- src/mesa/state_tracker/st_draw.c | 6 ++++-- 6 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c index 076d516583..b836ef29f3 100644 --- a/src/mesa/pipe/failover/fo_context.c +++ b/src/mesa/pipe/failover/fo_context.c @@ -47,7 +47,7 @@ static void failover_destroy( struct pipe_context *pipe ) static boolean failover_draw_elements( struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, + unsigned indexSize, unsigned indexOffset, unsigned prim, unsigned start, unsigned count) { struct failover_context *failover = failover_context( pipe ); @@ -65,6 +65,7 @@ static boolean failover_draw_elements( struct pipe_context *pipe, if (!failover->hw->draw_elements( failover->hw, indexBuffer, indexSize, + indexOffset, prim, start, count )) { @@ -84,6 +85,7 @@ static boolean failover_draw_elements( struct pipe_context *pipe, failover->sw->draw_elements( failover->sw, indexBuffer, indexSize, + indexOffset, prim, start, count ); @@ -102,7 +104,7 @@ static boolean failover_draw_elements( struct pipe_context *pipe, static boolean failover_draw_arrays( struct pipe_context *pipe, unsigned prim, unsigned start, unsigned count) { - return failover_draw_elements(pipe, NULL, 0, prim, start, count); + return failover_draw_elements(pipe, NULL, 0, 0, prim, start, count); } diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index 161f8ce697..adc91fb473 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -178,7 +178,7 @@ i915_end_query(struct pipe_context *pipe, struct pipe_query_object *q) static boolean i915_draw_elements( struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, + unsigned indexSize, unsigned indexOffset, unsigned prim, unsigned start, unsigned count) { struct i915_context *i915 = i915_context( pipe ); @@ -202,9 +202,10 @@ i915_draw_elements( struct pipe_context *pipe, } /* Map index buffer, if present */ if (indexBuffer) { - void *mapped_indexes + ubyte *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, PIPE_BUFFER_FLAG_READ); + mapped_indexes += indexOffset; draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -262,7 +263,7 @@ i915_draw_elements( struct pipe_context *pipe, static boolean i915_draw_arrays( struct pipe_context *pipe, unsigned prim, unsigned start, unsigned count) { - return i915_draw_elements(pipe, NULL, 0, prim, start, count); + return i915_draw_elements(pipe, NULL, 0, 0, prim, start, count); } diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 2558a6341c..08082f9367 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -71,7 +71,7 @@ struct pipe_context { boolean (*draw_elements)( struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, + unsigned indexSize, unsigned indexOffset, unsigned mode, unsigned start, unsigned count); /** Clear a surface to given value (no scissor; clear whole surface) */ diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c index 64a4fbe333..d5cd6beae8 100644 --- a/src/mesa/pipe/softpipe/sp_draw_arrays.c +++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c @@ -75,7 +75,7 @@ boolean softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { - return softpipe_draw_elements(pipe, NULL, 0, mode, start, count); + return softpipe_draw_elements(pipe, NULL, 0, 0, mode, start, count); } @@ -90,7 +90,7 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, boolean softpipe_draw_elements(struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, + unsigned indexSize, unsigned indexOffset, unsigned mode, unsigned start, unsigned count) { struct softpipe_context *sp = softpipe_context(pipe); @@ -130,9 +130,10 @@ softpipe_draw_elements(struct pipe_context *pipe, } /* Map index buffer, if present */ if (indexBuffer) { - void *mapped_indexes + ubyte *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, PIPE_BUFFER_FLAG_READ); + mapped_indexes += indexOffset; draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index c194f0ea0d..8747f34cdd 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -131,7 +131,7 @@ boolean softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, boolean softpipe_draw_elements(struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, + unsigned indexSize, unsigned indexOffset, unsigned mode, unsigned start, unsigned count); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index fbf7713f58..50251a816b 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -197,7 +197,7 @@ st_draw_vbo(GLcontext *ctx, /* indexed primitive */ struct gl_buffer_object *bufobj = ib->obj; struct pipe_buffer_handle *indexBuf = NULL; - unsigned indexSize, i; + unsigned indexSize, indexOffset, i; switch (ib->type) { case GL_UNSIGNED_INT: @@ -218,17 +218,19 @@ st_draw_vbo(GLcontext *ctx, /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); winsys->buffer_reference(winsys, &indexBuf, stobj->buffer); + indexOffset = (unsigned) ib->ptr; } else { /* element/indicies are in user space memory */ indexBuf = winsys->user_buffer_create(winsys, (void *) ib->ptr, ib->count * indexSize); + indexOffset = 0; } /* draw */ for (i = 0; i < nr_prims; i++) { - pipe->draw_elements(pipe, indexBuf, indexSize, + pipe->draw_elements(pipe, indexBuf, indexSize, indexOffset, prims[i].mode, prims[i].start, prims[i].count); } -- cgit v1.2.3 From 40a0b053f78acd0a08f6876518b8e9301480431f Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Oct 2007 14:35:40 -0600 Subject: Revert "Undo indexOffset change (I think, git???)" This reverts commit 11ce6244a79106c592364b30434b6ddade3fd6bb. --- src/mesa/pipe/failover/fo_context.c | 6 ++---- src/mesa/pipe/i915simple/i915_context.c | 7 +++---- src/mesa/pipe/p_context.h | 2 +- src/mesa/pipe/softpipe/sp_draw_arrays.c | 7 +++---- src/mesa/pipe/softpipe/sp_state.h | 2 +- src/mesa/state_tracker/st_draw.c | 6 ++---- 6 files changed, 12 insertions(+), 18 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c index b836ef29f3..076d516583 100644 --- a/src/mesa/pipe/failover/fo_context.c +++ b/src/mesa/pipe/failover/fo_context.c @@ -47,7 +47,7 @@ static void failover_destroy( struct pipe_context *pipe ) static boolean failover_draw_elements( struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, unsigned indexOffset, + unsigned indexSize, unsigned prim, unsigned start, unsigned count) { struct failover_context *failover = failover_context( pipe ); @@ -65,7 +65,6 @@ static boolean failover_draw_elements( struct pipe_context *pipe, if (!failover->hw->draw_elements( failover->hw, indexBuffer, indexSize, - indexOffset, prim, start, count )) { @@ -85,7 +84,6 @@ static boolean failover_draw_elements( struct pipe_context *pipe, failover->sw->draw_elements( failover->sw, indexBuffer, indexSize, - indexOffset, prim, start, count ); @@ -104,7 +102,7 @@ static boolean failover_draw_elements( struct pipe_context *pipe, static boolean failover_draw_arrays( struct pipe_context *pipe, unsigned prim, unsigned start, unsigned count) { - return failover_draw_elements(pipe, NULL, 0, 0, prim, start, count); + return failover_draw_elements(pipe, NULL, 0, prim, start, count); } diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index adc91fb473..161f8ce697 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -178,7 +178,7 @@ i915_end_query(struct pipe_context *pipe, struct pipe_query_object *q) static boolean i915_draw_elements( struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, unsigned indexOffset, + unsigned indexSize, unsigned prim, unsigned start, unsigned count) { struct i915_context *i915 = i915_context( pipe ); @@ -202,10 +202,9 @@ i915_draw_elements( struct pipe_context *pipe, } /* Map index buffer, if present */ if (indexBuffer) { - ubyte *mapped_indexes + void *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, PIPE_BUFFER_FLAG_READ); - mapped_indexes += indexOffset; draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -263,7 +262,7 @@ i915_draw_elements( struct pipe_context *pipe, static boolean i915_draw_arrays( struct pipe_context *pipe, unsigned prim, unsigned start, unsigned count) { - return i915_draw_elements(pipe, NULL, 0, 0, prim, start, count); + return i915_draw_elements(pipe, NULL, 0, prim, start, count); } diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 08082f9367..2558a6341c 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -71,7 +71,7 @@ struct pipe_context { boolean (*draw_elements)( struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, unsigned indexOffset, + unsigned indexSize, unsigned mode, unsigned start, unsigned count); /** Clear a surface to given value (no scissor; clear whole surface) */ diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c index d5cd6beae8..64a4fbe333 100644 --- a/src/mesa/pipe/softpipe/sp_draw_arrays.c +++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c @@ -75,7 +75,7 @@ boolean softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { - return softpipe_draw_elements(pipe, NULL, 0, 0, mode, start, count); + return softpipe_draw_elements(pipe, NULL, 0, mode, start, count); } @@ -90,7 +90,7 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, boolean softpipe_draw_elements(struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, unsigned indexOffset, + unsigned indexSize, unsigned mode, unsigned start, unsigned count) { struct softpipe_context *sp = softpipe_context(pipe); @@ -130,10 +130,9 @@ softpipe_draw_elements(struct pipe_context *pipe, } /* Map index buffer, if present */ if (indexBuffer) { - ubyte *mapped_indexes + void *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, PIPE_BUFFER_FLAG_READ); - mapped_indexes += indexOffset; draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 8747f34cdd..c194f0ea0d 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -131,7 +131,7 @@ boolean softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, boolean softpipe_draw_elements(struct pipe_context *pipe, struct pipe_buffer_handle *indexBuffer, - unsigned indexSize, unsigned indexOffset, + unsigned indexSize, unsigned mode, unsigned start, unsigned count); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 50251a816b..fbf7713f58 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -197,7 +197,7 @@ st_draw_vbo(GLcontext *ctx, /* indexed primitive */ struct gl_buffer_object *bufobj = ib->obj; struct pipe_buffer_handle *indexBuf = NULL; - unsigned indexSize, indexOffset, i; + unsigned indexSize, i; switch (ib->type) { case GL_UNSIGNED_INT: @@ -218,19 +218,17 @@ st_draw_vbo(GLcontext *ctx, /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); winsys->buffer_reference(winsys, &indexBuf, stobj->buffer); - indexOffset = (unsigned) ib->ptr; } else { /* element/indicies are in user space memory */ indexBuf = winsys->user_buffer_create(winsys, (void *) ib->ptr, ib->count * indexSize); - indexOffset = 0; } /* draw */ for (i = 0; i < nr_prims; i++) { - pipe->draw_elements(pipe, indexBuf, indexSize, indexOffset, + pipe->draw_elements(pipe, indexBuf, indexSize, prims[i].mode, prims[i].start, prims[i].count); } -- cgit v1.2.3 From 7636aac54bb357ce907ae6cc2c41f32957faecf3 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Oct 2007 14:40:09 -0600 Subject: Fix glDrawElements + VBO rendering when ptr/offset is not zero. When an index VBO is bound, glDrawElement's indices pointer is really an offset into the element buffer. Add that offset to the prims[i].start value before calling pipe->draw_elements(). Fixes vbo.c conform test. --- src/mesa/state_tracker/st_draw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index fbf7713f58..d7d9a1d203 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -197,7 +197,7 @@ st_draw_vbo(GLcontext *ctx, /* indexed primitive */ struct gl_buffer_object *bufobj = ib->obj; struct pipe_buffer_handle *indexBuf = NULL; - unsigned indexSize, i; + unsigned indexSize, indexOffset, i; switch (ib->type) { case GL_UNSIGNED_INT: @@ -218,18 +218,21 @@ st_draw_vbo(GLcontext *ctx, /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); winsys->buffer_reference(winsys, &indexBuf, stobj->buffer); + indexOffset = (unsigned) ib->ptr / indexSize; } else { /* element/indicies are in user space memory */ indexBuf = winsys->user_buffer_create(winsys, (void *) ib->ptr, ib->count * indexSize); + indexOffset = 0; } /* draw */ for (i = 0; i < nr_prims; i++) { pipe->draw_elements(pipe, indexBuf, indexSize, - prims[i].mode, prims[i].start, prims[i].count); + prims[i].mode, + prims[i].start + indexOffset, prims[i].count); } winsys->buffer_reference(winsys, &indexBuf, NULL); -- cgit v1.2.3 From a70c5e37f1c2e43738469e4799ad2b9e7c604782 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 29 Oct 2007 08:35:08 -0400 Subject: Remove typedefs from enums. typedefs are rather evil, remove them and use the enum keyword explicitely. --- src/mesa/pipe/draw/draw_flatshade.c | 2 +- src/mesa/pipe/draw/draw_vertex.c | 4 ++-- src/mesa/pipe/draw/draw_vertex.h | 16 ++++++++-------- src/mesa/pipe/i915simple/i915_context.h | 2 +- src/mesa/pipe/i915simple/i915_state_derived.c | 2 +- src/mesa/pipe/softpipe/sp_prim_setup.c | 6 +++--- src/mesa/pipe/softpipe/sp_state_derived.c | 2 +- src/mesa/state_tracker/st_draw.c | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c index 2ba0d5820e..3b22c01b34 100644 --- a/src/mesa/pipe/draw/draw_flatshade.c +++ b/src/mesa/pipe/draw/draw_flatshade.c @@ -56,7 +56,7 @@ static INLINE void copy_colors( struct draw_stage *stage, const struct vertex_header *src ) { const uint num_attribs = stage->draw->vertex_info.num_attribs; - const interp_mode *interp = stage->draw->vertex_info.interp_mode; + const enum interp_mode *interp = stage->draw->vertex_info.interp_mode; uint i; /* Look for constant/flat attribs and duplicate from src to dst vertex */ diff --git a/src/mesa/pipe/draw/draw_vertex.c b/src/mesa/pipe/draw/draw_vertex.c index 1204a944de..ce76cb043c 100644 --- a/src/mesa/pipe/draw/draw_vertex.c +++ b/src/mesa/pipe/draw/draw_vertex.c @@ -44,7 +44,7 @@ static INLINE void emit_vertex_attr(struct vertex_info *vinfo, - attrib_format format, interp_mode interp) + enum attrib_format format, enum interp_mode interp) { const uint n = vinfo->num_attribs; vinfo->interp_mode[n] = interp; @@ -95,7 +95,7 @@ draw_compute_vertex_size(struct vertex_info *vinfo) void draw_set_vertex_attributes( struct draw_context *draw, const uint *slot_to_vf_attr, - const interp_mode *interps, + const enum interp_mode *interps, unsigned nr_attrs ) { struct vertex_info *vinfo = &draw->vertex_info; diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 2968981708..a1fa7aae5a 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -40,7 +40,7 @@ struct draw_context; /** * Vertex attribute format */ -typedef enum { +enum attrib_format { FORMAT_OMIT, FORMAT_1F, FORMAT_2F, @@ -48,18 +48,18 @@ typedef enum { FORMAT_4F, FORMAT_4F_VIEWPORT, FORMAT_4UB -} attrib_format; +}; /** * Attribute interpolation mode */ -typedef enum { +enum interp_mode { INTERP_NONE, /**< never interpolate vertex header info */ INTERP_CONSTANT, INTERP_LINEAR, INTERP_PERSPECTIVE -} interp_mode; +}; /** @@ -69,8 +69,8 @@ struct vertex_info { uint num_attribs; uint hwfmt[4]; /**< hardware format info for this format */ - interp_mode interp_mode[PIPE_MAX_SHADER_OUTPUTS]; - attrib_format format[PIPE_MAX_SHADER_OUTPUTS]; /**< FORMAT_x */ + enum interp_mode interp_mode[PIPE_MAX_SHADER_OUTPUTS]; + enum attrib_format format[PIPE_MAX_SHADER_OUTPUTS]; /**< FORMAT_x */ uint size; /**< total vertex size in dwords */ }; @@ -82,7 +82,7 @@ struct vertex_info */ static INLINE uint draw_emit_vertex_attr(struct vertex_info *vinfo, - attrib_format format, interp_mode interp) + enum attrib_format format, enum interp_mode interp) { const uint n = vinfo->num_attribs; assert(n < PIPE_MAX_SHADER_OUTPUTS); @@ -95,7 +95,7 @@ draw_emit_vertex_attr(struct vertex_info *vinfo, extern void draw_set_vertex_attributes( struct draw_context *draw, const uint *attrs, - const interp_mode *interps, + const enum interp_mode *interps, unsigned nr_attrs ); extern void draw_set_twoside_attributes(struct draw_context *draw, diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index 5d312286f6..5c748ea896 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -130,7 +130,7 @@ struct i915_depth_stencil_state { struct i915_rasterizer_state { int light_twoside : 1; unsigned st; - interp_mode color_interp; + enum interp_mode color_interp; unsigned LIS4; unsigned LIS7; diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 95f705929e..ed1521fcce 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -44,7 +44,7 @@ static void calculate_vertex_layout( struct i915_context *i915 ) { const struct pipe_shader_state *fs = i915->fs; - const interp_mode colorInterp = i915->rasterizer->color_interp; + const enum interp_mode colorInterp = i915->rasterizer->color_interp; struct vertex_info vinfo; uint front0 = 0, back0 = 0, front1 = 0, back1 = 0; boolean needW = 0; diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 0b1b592bbe..21d643bfe0 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -471,7 +471,7 @@ static void tri_persp_coeff( struct setup_stage *setup, */ static void setup_tri_coefficients( struct setup_stage *setup ) { - const interp_mode *interp = setup->softpipe->vertex_info.interp_mode; + const enum interp_mode *interp = setup->softpipe->vertex_info.interp_mode; unsigned slot, j; /* z and w are done by linear interpolation: @@ -701,7 +701,7 @@ line_persp_coeff(struct setup_stage *setup, unsigned slot, unsigned i) static INLINE void setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim) { - const interp_mode *interp = setup->softpipe->vertex_info.interp_mode; + const enum interp_mode *interp = setup->softpipe->vertex_info.interp_mode; unsigned slot, j; /* use setup->vmin, vmax to point to vertices */ @@ -927,7 +927,7 @@ static void setup_point(struct draw_stage *stage, struct prim_header *prim) { struct setup_stage *setup = setup_stage( stage ); - const interp_mode *interp = setup->softpipe->vertex_info.interp_mode; + const enum interp_mode *interp = setup->softpipe->vertex_info.interp_mode; const struct vertex_header *v0 = prim->v[0]; const int sizeAttr = setup->softpipe->psize_slot; const float size diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index b6145df8e2..e5ca953e60 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -45,7 +45,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) { const struct pipe_shader_state *vs = softpipe->vs->state; const struct pipe_shader_state *fs = softpipe->fs; - const interp_mode colorInterp + const enum interp_mode colorInterp = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR; struct vertex_info *vinfo = &softpipe->vertex_info; boolean emitBack0 = FALSE, emitBack1 = FALSE, emitPsize = FALSE; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index d7d9a1d203..065e157bc6 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -325,7 +325,7 @@ set_feedback_vertex_format(GLcontext *ctx) { struct st_context *st = ctx->st; uint attrs[PIPE_MAX_SHADER_OUTPUTS]; - interp_mode interp[PIPE_MAX_SHADER_OUTPUTS]; + enum interp_mode interp[PIPE_MAX_SHADER_OUTPUTS]; GLuint n, i; if (ctx->RenderMode == GL_FEEDBACK) { -- cgit v1.2.3 From 8d9afa76eb090ff58ca9a8a7a86a0b23ffc56857 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 31 Oct 2007 12:17:32 -0600 Subject: Use ffvertex_prog.c code instead of t_vp_build.c code. --- src/mesa/main/ffvertex_prog.h | 2 ++ src/mesa/sources | 1 + src/mesa/state_tracker/st_draw.c | 4 ---- src/mesa/tnl/t_context.c | 4 ++++ src/mesa/tnl/t_vp_build.c | 6 +++++- src/mesa/tnl/t_vp_build.h | 4 ++++ 6 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/main/ffvertex_prog.h b/src/mesa/main/ffvertex_prog.h index 74cafc65c1..38dc5fbb8d 100644 --- a/src/mesa/main/ffvertex_prog.h +++ b/src/mesa/main/ffvertex_prog.h @@ -30,6 +30,8 @@ #define FFVERTEX_PROG_H +#include "main/mtypes.h" + struct gl_vertex_program * _mesa_get_fixed_func_vertex_program(GLcontext *ctx); diff --git a/src/mesa/sources b/src/mesa/sources index 727872378e..845a5ff556 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -27,6 +27,7 @@ MAIN_SOURCES = \ main/extensions.c \ main/fbobject.c \ main/feedback.c \ + main/ffvertex_prog.c \ main/fog.c \ main/framebuffer.c \ main/get.c \ diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 065e157bc6..c3f33a447e 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -36,8 +36,6 @@ #include "vbo/vbo.h" #include "vbo/vbo_context.h" -#include "tnl/t_vp_build.h" - #include "st_atom.h" #include "st_cache.h" #include "st_context.h" @@ -527,8 +525,6 @@ void st_init_draw( struct st_context *st ) assert(vbo); assert(vbo->draw_prims); vbo->draw_prims = st_draw_vbo; - - _tnl_ProgramCacheInit( ctx ); } diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 3b8dd18bbb..60770a91c2 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -61,7 +61,9 @@ _tnl_CreateContext( GLcontext *ctx ) /* Initialize tnl state. */ if (ctx->VertexProgram._MaintainTnlProgram) { +#if 0 _tnl_ProgramCacheInit( ctx ); +#endif _tnl_install_pipeline( ctx, _tnl_vp_pipeline ); } else { _tnl_install_pipeline( ctx, _tnl_default_pipeline ); @@ -90,8 +92,10 @@ _tnl_DestroyContext( GLcontext *ctx ) _tnl_destroy_pipeline( ctx ); +#if 0 if (ctx->VertexProgram._MaintainTnlProgram) _tnl_ProgramCacheDestroy( ctx ); +#endif FREE(tnl); ctx->swtnl_context = NULL; diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 2b7d8eebe0..215d6653a3 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -33,6 +33,7 @@ #include "glheader.h" #include "macros.h" #include "enums.h" +#include "main/ffvertex_prog.h" #include "shader/program.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" @@ -41,7 +42,7 @@ #include "t_context.h" /* NOTE: very light dependency on this */ #include "t_vp_build.h" - +#if 0 struct state_key { unsigned light_global_enabled:1; unsigned light_local_viewer:1; @@ -1605,6 +1606,7 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx) return prog; } +#endif void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx ) @@ -1627,6 +1629,7 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx ) } } +#if 0 void _tnl_ProgramCacheInit( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -1655,3 +1658,4 @@ void _tnl_ProgramCacheDestroy( GLcontext *ctx ) FREE(tnl->vp_cache->items); FREE(tnl->vp_cache); } +#endif diff --git a/src/mesa/tnl/t_vp_build.h b/src/mesa/tnl/t_vp_build.h index 034701d8c4..adcd8f1662 100644 --- a/src/mesa/tnl/t_vp_build.h +++ b/src/mesa/tnl/t_vp_build.h @@ -37,12 +37,16 @@ _NEW_FOG | \ _NEW_POINT) +#if 0 extern struct gl_vertex_program * _mesa_get_fixed_func_vertex_program(GLcontext *ctx); +#endif extern void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx ); +#if 0 extern void _tnl_ProgramCacheInit( GLcontext *ctx ); extern void _tnl_ProgramCacheDestroy( GLcontext *ctx ); +#endif #endif -- 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_draw.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 6a1154bab0d296b60f889bdc13254568f4051104 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 16 Nov 2007 17:12:22 -0700 Subject: adjustments so st_feedback_draw_vbo() can be used for glRasterPos --- src/mesa/state_tracker/st_draw.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 3e2ed6cada..3b6d829145 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -318,7 +318,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, /** * Set the (private) draw module's post-transformed vertex format when in - * GL_SELECT or GL_FEEDBACK mode. + * GL_SELECT or GL_FEEDBACK mode or for glRasterPos. */ static void set_feedback_vertex_format(GLcontext *ctx) @@ -328,7 +328,14 @@ set_feedback_vertex_format(GLcontext *ctx) enum interp_mode interp[PIPE_MAX_SHADER_OUTPUTS]; GLuint n, i; - if (ctx->RenderMode == GL_FEEDBACK) { + if (ctx->RenderMode == GL_SELECT) { + assert(ctx->RenderMode == GL_SELECT); + n = 1; + attrs[0] = FORMAT_4F; + interp[0] = INTERP_NONE; + } + else { + /* GL_FEEDBACK, or glRasterPos */ /* emit all attribs (pos, color, texcoord) as GLfloat[4] */ n = st->state.vs->state.num_outputs; for (i = 0; i < n; i++) { @@ -336,19 +343,14 @@ set_feedback_vertex_format(GLcontext *ctx) interp[i] = INTERP_NONE; } } - else { - assert(ctx->RenderMode == GL_SELECT); - n = 1; - attrs[0] = FORMAT_4F; - interp[0] = INTERP_NONE; - } draw_set_vertex_attributes(st->draw, attrs, interp, n); } /** - * Called by VBO to draw arrays when in selection or feedback mode. + * Called by VBO to draw arrays when in selection or feedback mode and + * to implement glRasterPos. * This is very much like the normal draw_vbo() function above. * Look at code refactoring some day. * Might move this into the failover module some day. @@ -373,8 +375,6 @@ st_feedback_draw_vbo(GLcontext *ctx, GLuint attr, i; ubyte *mapped_constants; - assert(ctx->RenderMode == GL_SELECT || - ctx->RenderMode == GL_FEEDBACK); assert(draw); st_validate_state(ctx->st); -- cgit v1.2.3 From 9f0b5bba707d6c36896b4b8afad4e6b459da5e99 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 21 Nov 2007 16:00:57 -0700 Subject: Replace draw_set_vertex_attributes() with simpler draw_set_vertex_info(). Just pass in the vertex_info object and make a copy of it. --- src/mesa/pipe/draw/draw_vertex.c | 35 ++++++++++++--------------- src/mesa/pipe/draw/draw_vertex.h | 6 ++--- src/mesa/pipe/i915simple/i915_state_derived.c | 7 ++---- src/mesa/pipe/softpipe/sp_state_derived.c | 5 +--- src/mesa/state_tracker/st_draw.c | 21 ++++++++-------- 5 files changed, 31 insertions(+), 43 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_vertex.c b/src/mesa/pipe/draw/draw_vertex.c index 983ed71ec0..89f54ff186 100644 --- a/src/mesa/pipe/draw/draw_vertex.c +++ b/src/mesa/pipe/draw/draw_vertex.c @@ -87,37 +87,34 @@ draw_compute_vertex_size(struct vertex_info *vinfo) /** - * Tell the drawing module about the layout of post-transformation vertices + * Tell the drawing module about the contents of post-transformation vertices. + * Note that the vertex attribute format info isn't used by 'draw'; all + * attributes are handled as float[4]. But when the driver emits vertices + * it'll use that info. + * We _do_ care about the number of attributes and their interpolation modes. */ void -draw_set_vertex_attributes( struct draw_context *draw, - const uint *slot_to_vf_attr, - const enum interp_mode *interps, - unsigned nr_attrs ) +draw_set_vertex_info( struct draw_context *draw, + const struct vertex_info *info) { - struct vertex_info *vinfo = &draw->vertex_info; - unsigned i; + assert(info->interp_mode[0] == INTERP_LINEAR); /* should be vert pos */ - assert(interps[0] == INTERP_LINEAR); /* should be vert pos */ - - assert(nr_attrs <= PIPE_MAX_SHADER_OUTPUTS); + assert(info->num_attribs <= PIPE_MAX_SHADER_OUTPUTS); /* Note that draw-module vertices will consist of the attributes passed * to this function, plus a header/prefix containing the vertex header * flags and GLfloat[4] clip pos. */ - memset(vinfo, 0, sizeof(*vinfo)); - - /* copy attrib info */ - for (i = 0; i < nr_attrs; i++) { - emit_vertex_attr(vinfo, FORMAT_4F, interps[i]); - } + memcpy(&draw->vertex_info, info, sizeof(*info)); - draw_compute_vertex_size(vinfo); + draw_compute_vertex_size(&draw->vertex_info); - /* add extra words for vertex header (uint), clip pos (float[4]) */ - vinfo->size += 5; + /* Need to know vertex size (in words) for vertex copying elsewhere. + * Four words per attribute, plus vertex header (uint) and clip + * position (float[4]). + */ + draw->vertex_info.size = draw->vertex_info.num_attribs * 4 + 5; } diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index d9b5e7c8c0..8bb328affa 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -92,10 +92,8 @@ draw_emit_vertex_attr(struct vertex_info *vinfo, } -extern void draw_set_vertex_attributes( struct draw_context *draw, - const uint *attrs, - const enum interp_mode *interps, - unsigned nr_attrs ); +extern void draw_set_vertex_info( struct draw_context *draw, + const struct vertex_info *info); extern void draw_set_twoside_attributes(struct draw_context *draw, uint front0, uint back0, diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index ed1521fcce..688c0c5798 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -132,11 +132,8 @@ static void calculate_vertex_layout( struct i915_context *i915 ) /* If the attributes have changed, tell the draw module about the new * vertex layout. We'll also update the hardware vertex format info. */ - draw_set_vertex_attributes( i915->draw, - NULL,/*vinfo.slot_to_attrib,*/ - vinfo.interp_mode, - vinfo.num_attribs); - + draw_set_vertex_info( i915->draw, &vinfo); + draw_set_twoside_attributes(i915->draw, front0, back0, front1, back1); diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 81f70f0f24..7e5efbfde3 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -156,10 +156,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) if (1/*vinfo->attr_mask != softpipe->attr_mask*/) { /*softpipe->attr_mask = vinfo->attr_mask;*/ - draw_set_vertex_attributes( softpipe->draw, - NULL,/*vinfo->slot_to_attrib,*/ - vinfo->interp_mode, - vinfo->num_attribs); + draw_set_vertex_info( softpipe->draw, vinfo); draw_set_twoside_attributes(softpipe->draw, front0, back0, front1, back1); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 3b6d829145..61ff034550 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -324,27 +324,26 @@ static void set_feedback_vertex_format(GLcontext *ctx) { struct st_context *st = ctx->st; - uint attrs[PIPE_MAX_SHADER_OUTPUTS]; - enum interp_mode interp[PIPE_MAX_SHADER_OUTPUTS]; - GLuint n, i; + struct vertex_info vinfo; + GLuint i; if (ctx->RenderMode == GL_SELECT) { assert(ctx->RenderMode == GL_SELECT); - n = 1; - attrs[0] = FORMAT_4F; - interp[0] = INTERP_NONE; + vinfo.num_attribs = 1; + vinfo.format[0] = FORMAT_4F; + vinfo.interp_mode[0] = INTERP_NONE; } else { /* GL_FEEDBACK, or glRasterPos */ /* emit all attribs (pos, color, texcoord) as GLfloat[4] */ - n = st->state.vs->state.num_outputs; - for (i = 0; i < n; i++) { - attrs[i] = FORMAT_4F; - interp[i] = INTERP_NONE; + vinfo.num_attribs = st->state.vs->state.num_outputs; + for (i = 0; i < vinfo.num_attribs; i++) { + vinfo.format[i] = FORMAT_4F; + vinfo.interp_mode[i] = INTERP_LINEAR; } } - draw_set_vertex_attributes(st->draw, attrs, interp, n); + draw_set_vertex_info(st->draw, &vinfo); } -- cgit v1.2.3 From ce30f0550f02b28219c84851d71e0713aa315ee3 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 5 Dec 2007 14:54:29 -0700 Subject: silence warning --- src/mesa/state_tracker/st_draw.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 61ff034550..b4c0d0cdd6 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -83,6 +83,7 @@ pipe_vertex_format(GLenum type, GLuint size) default: assert(0); } + return 0; /* silence compiler warning */ } -- cgit v1.2.3 From c885775cae8feabe5431ba7867fac99332f5ee8e Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 7 Dec 2007 17:24:42 -0700 Subject: New vbo_set_draw_func() to keep vbo context opaque to state tracker and tnl module. --- src/mesa/state_tracker/st_cb_feedback.c | 8 +++----- src/mesa/state_tracker/st_draw.c | 6 +----- src/mesa/tnl/t_context.c | 3 +++ src/mesa/vbo/vbo.h | 3 +++ src/mesa/vbo/vbo_context.c | 12 ++++++++++++ 5 files changed, 22 insertions(+), 10 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index a9fd2579a2..ea775b9452 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -43,7 +43,6 @@ #include "main/macros.h" #include "vbo/vbo.h" -#include "vbo/vbo_context.h" #include "st_context.h" #include "st_atom.h" @@ -281,26 +280,25 @@ static void st_RenderMode(GLcontext *ctx, GLenum newMode ) { struct st_context *st = ctx->st; - struct vbo_context *vbo = (struct vbo_context *) ctx->swtnl_im; struct draw_context *draw = st->draw; if (newMode == GL_RENDER) { /* restore normal VBO draw function */ - vbo->draw_prims = st_draw_vbo; + vbo_set_draw_func(ctx, st_draw_vbo); } else if (newMode == GL_SELECT) { if (!st->selection_stage) st->selection_stage = draw_glselect_stage(ctx, draw); draw_set_rasterize_stage(draw, st->selection_stage); /* Plug in new vbo draw function */ - vbo->draw_prims = st_feedback_draw_vbo; + vbo_set_draw_func(ctx, st_feedback_draw_vbo); } else { if (!st->feedback_stage) st->feedback_stage = draw_glfeedback_stage(ctx, draw); draw_set_rasterize_stage(draw, st->feedback_stage); /* Plug in new vbo draw function */ - vbo->draw_prims = st_feedback_draw_vbo; + vbo_set_draw_func(ctx, st_feedback_draw_vbo); /* need to generate/use a vertex program that emits pos/color/tex */ st->dirty.st |= ST_NEW_VERTEX_PROGRAM; } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index b4c0d0cdd6..32dcd73c46 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -34,7 +34,6 @@ #include "main/image.h" #include "vbo/vbo.h" -#include "vbo/vbo_context.h" #include "st_atom.h" #include "st_cache.h" @@ -519,14 +518,11 @@ st_feedback_draw_vbo(GLcontext *ctx, void st_init_draw( struct st_context *st ) { GLcontext *ctx = st->ctx; - struct vbo_context *vbo = (struct vbo_context *) ctx->swtnl_im; /* actually, not used here, but elsewhere */ create_default_attribs_buffer(st); - assert(vbo); - assert(vbo->draw_prims); - vbo->draw_prims = st_draw_vbo; + vbo_set_draw_func(ctx, st_draw_vbo); } diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index b87452d2eb..0ace5c2d6f 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -78,6 +78,9 @@ _tnl_CreateContext( GLcontext *ctx ) tnl->nr_blocks = 0; + /* plug in the VBO drawing function */ + vbo_set_draw_func(ctx, _tnl_draw_prims); + return GL_TRUE; } diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 4c51b44cda..79d33d09c1 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -117,4 +117,7 @@ void vbo_rebase_prims( GLcontext *ctx, void vbo_use_buffer_objects(GLcontext *ctx); +void vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func); + + #endif diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index ad4556c500..60d0b76ab6 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -31,6 +31,7 @@ #include "vbo.h" #include "vbo_context.h" +#if 0 /* Reach out and grab this to use as the default: */ extern void _tnl_draw_prims( GLcontext *ctx, @@ -40,6 +41,7 @@ extern void _tnl_draw_prims( GLcontext *ctx, const struct _mesa_index_buffer *ib, GLuint min_index, GLuint max_index ); +#endif @@ -214,7 +216,9 @@ GLboolean _vbo_CreateContext( GLcontext *ctx ) /* By default: */ +#if 0 /* dead - see vbo_set_draw_func() */ vbo->draw_prims = _tnl_draw_prims; +#endif /* Hook our functions into exec and compile dispatch tables. These * will pretty much be permanently installed, which means that the @@ -245,3 +249,11 @@ void _vbo_DestroyContext( GLcontext *ctx ) FREE(vbo_context(ctx)); ctx->swtnl_im = NULL; } + + +void vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func) +{ + struct vbo_context *vbo = vbo_context(ctx); + vbo->draw_prims = func; +} + -- cgit v1.2.3 From cd1eefee8404ae69ea5b604971b8be78abf588e6 Mon Sep 17 00:00:00 2001 From: keithw Date: Mon, 19 Nov 2007 20:05:38 +0000 Subject: add fence interfaces and buffer create flags to pipe_winsys --- src/mesa/pipe/i915simple/i915_prim_vbuf.c | 2 +- src/mesa/pipe/p_defines.h | 8 +++-- src/mesa/pipe/p_winsys.h | 44 ++++++++++++++++++++-------- src/mesa/state_tracker/st_atom_constbuf.c | 2 +- src/mesa/state_tracker/st_cb_bufferobjects.c | 2 +- src/mesa/state_tracker/st_draw.c | 4 +-- 6 files changed, 42 insertions(+), 20 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c index 08ac5b672c..571ad40595 100644 --- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c +++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c @@ -99,7 +99,7 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render, /* FIXME: handle failure */ assert(!i915->vbo); - i915->vbo = winsys->buffer_create(winsys, 64); + i915->vbo = winsys->buffer_create(winsys, 64, 0, 0); winsys->buffer_data( winsys, i915->vbo, size, NULL, I915_BUFFER_USAGE_LIT_VERTEX ); diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index a853605486..8dce3aba90 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -170,8 +170,12 @@ /** * Buffer access flags */ -#define PIPE_BUFFER_FLAG_READ 0x1 -#define PIPE_BUFFER_FLAG_WRITE 0x2 +#define PIPE_BUFFER_FLAG_READ 0x1 +#define PIPE_BUFFER_FLAG_WRITE 0x2 +#define PIPE_BUFFER_FLAG_MEM_LOCAL 0x4 +#define PIPE_BUFFER_FLAG_CACHED 0x8 +#define PIPE_BUFFER_FLAG_CUSTOM (1<<16) + /** diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index 438e8bdb63..f46807995d 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -59,6 +59,7 @@ struct pipe_surface; /** Opaque type */ struct pipe_buffer_handle; +struct pipe_fence_handle; struct pipe_winsys { @@ -104,8 +105,10 @@ struct pipe_winsys * systems must then implement that interface (rather than the * other way around...). */ - struct pipe_buffer_handle *(*buffer_create)(struct pipe_winsys *sws, - unsigned alignment ); + struct pipe_buffer_handle *(*buffer_create)( struct pipe_winsys *sws, + unsigned alignment, + unsigned flags, + unsigned hint ); /** Create a buffer that wraps user-space data */ struct pipe_buffer_handle *(*user_buffer_create)(struct pipe_winsys *sws, @@ -136,24 +139,39 @@ struct pipe_winsys * 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, + int (*buffer_data)(struct pipe_winsys *sws, struct pipe_buffer_handle *buf, 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, - struct pipe_buffer_handle *buf, - unsigned long offset, - unsigned long size, - const void *data); + int (*buffer_subdata)(struct pipe_winsys *sws, + struct pipe_buffer_handle *buf, + unsigned long offset, + unsigned long size, + const void *data); /** Query some or all of the data contained in a buffer's data store */ - void (*buffer_get_subdata)(struct pipe_winsys *sws, - struct pipe_buffer_handle *buf, - unsigned long offset, - unsigned long size, - void *data); + int (*buffer_get_subdata)(struct pipe_winsys *sws, + struct pipe_buffer_handle *buf, + unsigned long offset, + unsigned long size, + void *data); + + + void (*fence_reference)( struct pipe_winsys *sws, + struct pipe_fence_handle **ptr, + struct pipe_fence_handle *fence ); + + int (*fence_signalled)( struct pipe_winsys *sws, + struct pipe_fence_handle *fence, + unsigned flag ); + + + int (*fence_finish)( struct pipe_winsys *sws, + struct pipe_fence_handle *fence, + unsigned flag ); + }; diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 446250c226..57f5ec68d2 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -70,7 +70,7 @@ void st_upload_constants( struct st_context *st, _mesa_load_state_parameters(st->ctx, params); if (!cbuf->buffer) - cbuf->buffer = ws->buffer_create(ws, 1); + cbuf->buffer = ws->buffer_create(ws, 1, 0, 0); if (0) { diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 99e1eb3c7a..872248cdb5 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -63,7 +63,7 @@ st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target) _mesa_initialize_buffer_object(&st_obj->Base, name, target); - st_obj->buffer = st->pipe->winsys->buffer_create( st->pipe->winsys, 32 ); + st_obj->buffer = st->pipe->winsys->buffer_create( st->pipe->winsys, 32, 0, 0 ); return &st_obj->Base; } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 32dcd73c46..0a5725ae6a 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -95,7 +95,7 @@ static void create_default_attribs_buffer(struct st_context *st) { struct pipe_context *pipe = st->pipe; - st->default_attrib_buffer = pipe->winsys->buffer_create( pipe->winsys, 32 ); + st->default_attrib_buffer = pipe->winsys->buffer_create( pipe->winsys, 32, 0, 0 ); } @@ -288,7 +288,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, } /* XXX create one-time */ - vbuf = pipe->winsys->buffer_create(pipe->winsys, 32); + vbuf = pipe->winsys->buffer_create(pipe->winsys, 32, 0, 0); pipe->winsys->buffer_data(pipe->winsys, vbuf, vertex_bytes, verts, PIPE_BUFFER_USAGE_VERTEX); -- cgit v1.2.3 From 73a05942766cee4e3cc200725e9760c5a9b67bb4 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 23 Nov 2007 12:02:50 +0000 Subject: gallium: support the full range of possible vertex types --- src/mesa/state_tracker/st_draw.c | 152 +++++++++++++++++++++++++++++++++------ 1 file changed, 129 insertions(+), 23 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 0a5725ae6a..c6fea1f7bc 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -50,37 +50,141 @@ #include "pipe/draw/draw_context.h" +static GLuint double_types[4] = { + PIPE_FORMAT_R64_FLOAT, + PIPE_FORMAT_R64G64_FLOAT, + PIPE_FORMAT_R64G64B64_FLOAT, + PIPE_FORMAT_R64G64B64A64_FLOAT +}; + +static GLuint float_types[4] = { + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32G32_FLOAT, + PIPE_FORMAT_R32G32B32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT +}; + +static GLuint uint_types_norm[4] = { + PIPE_FORMAT_R32_UNORM, + PIPE_FORMAT_R32G32_UNORM, + PIPE_FORMAT_R32G32B32_UNORM, + PIPE_FORMAT_R32G32B32A32_UNORM +}; + +static GLuint uint_types_scale[4] = { + PIPE_FORMAT_R32_USCALED, + PIPE_FORMAT_R32G32_USCALED, + PIPE_FORMAT_R32G32B32_USCALED, + PIPE_FORMAT_R32G32B32A32_USCALED +}; + +static GLuint int_types_norm[4] = { + PIPE_FORMAT_R32_SNORM, + PIPE_FORMAT_R32G32_SNORM, + PIPE_FORMAT_R32G32B32_SNORM, + PIPE_FORMAT_R32G32B32A32_SNORM +}; + +static GLuint int_types_scale[4] = { + PIPE_FORMAT_R32_SSCALED, + PIPE_FORMAT_R32G32_SSCALED, + PIPE_FORMAT_R32G32B32_SSCALED, + PIPE_FORMAT_R32G32B32A32_SSCALED +}; + +static GLuint ushort_types_norm[4] = { + PIPE_FORMAT_R16_UNORM, + PIPE_FORMAT_R16G16_UNORM, + PIPE_FORMAT_R16G16B16_UNORM, + PIPE_FORMAT_R16G16B16A16_UNORM +}; + +static GLuint ushort_types_scale[4] = { + PIPE_FORMAT_R16_USCALED, + PIPE_FORMAT_R16G16_USCALED, + PIPE_FORMAT_R16G16B16_USCALED, + PIPE_FORMAT_R16G16B16A16_USCALED +}; + +static GLuint short_types_norm[4] = { + PIPE_FORMAT_R16_SNORM, + PIPE_FORMAT_R16G16_SNORM, + PIPE_FORMAT_R16G16B16_SNORM, + PIPE_FORMAT_R16G16B16A16_SNORM +}; + +static GLuint short_types_scale[4] = { + PIPE_FORMAT_R16_SSCALED, + PIPE_FORMAT_R16G16_SSCALED, + PIPE_FORMAT_R16G16B16_SSCALED, + PIPE_FORMAT_R16G16B16A16_SSCALED +}; + +static GLuint ubyte_types_norm[4] = { + PIPE_FORMAT_R8_UNORM, + PIPE_FORMAT_R8G8_UNORM, + PIPE_FORMAT_R8G8B8_UNORM, + PIPE_FORMAT_R8G8B8A8_UNORM +}; + +static GLuint ubyte_types_scale[4] = { + PIPE_FORMAT_R8_USCALED, + PIPE_FORMAT_R8G8_USCALED, + PIPE_FORMAT_R8G8B8_USCALED, + PIPE_FORMAT_R8G8B8A8_USCALED +}; + +static GLuint byte_types_norm[4] = { + PIPE_FORMAT_R8_SNORM, + PIPE_FORMAT_R8G8_SNORM, + PIPE_FORMAT_R8G8B8_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM +}; + +static GLuint byte_types_scale[4] = { + PIPE_FORMAT_R8_SSCALED, + PIPE_FORMAT_R8G8_SSCALED, + PIPE_FORMAT_R8G8B8_SSCALED, + PIPE_FORMAT_R8G8B8A8_SSCALED +}; + + /** * Return a PIPE_FORMAT_x for the given GL datatype and size. */ static GLuint -pipe_vertex_format(GLenum type, GLuint size) +pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized) { - static const GLuint float_fmts[4] = { - PIPE_FORMAT_R32_FLOAT, - PIPE_FORMAT_R32G32_FLOAT, - PIPE_FORMAT_R32G32B32_FLOAT, - PIPE_FORMAT_R32G32B32A32_FLOAT, - }; - static const GLuint int_fmts[4] = { - PIPE_FORMAT_R32_SSCALED, - PIPE_FORMAT_R32G32_SSCALED, - PIPE_FORMAT_R32G32B32_SSCALED, - PIPE_FORMAT_R32G32B32A32_SSCALED, - }; - assert(type >= GL_BYTE); assert(type <= GL_DOUBLE); assert(size >= 1); assert(size <= 4); - switch (type) { - case GL_FLOAT: - return float_fmts[size - 1]; - case GL_INT: - return int_fmts[size - 1]; - default: - assert(0); + if (normalized) { + switch (type) { + case GL_DOUBLE: return double_types[size-1]; + case GL_FLOAT: return float_types[size-1]; + case GL_INT: return int_types_norm[size-1]; + case GL_SHORT: return short_types_norm[size-1]; + case GL_BYTE: return byte_types_norm[size-1]; + case GL_UNSIGNED_INT: return uint_types_norm[size-1]; + case GL_UNSIGNED_SHORT: return ushort_types_norm[size-1]; + case GL_UNSIGNED_BYTE: return ubyte_types_norm[size-1]; + default: assert(0); return 0; + } + } + else { + switch (type) { + case GL_DOUBLE: return double_types[size-1]; + case GL_FLOAT: return float_types[size-1]; + case GL_INT: return int_types_scale[size-1]; + case GL_SHORT: return short_types_scale[size-1]; + case GL_BYTE: return byte_types_scale[size-1]; + case GL_UNSIGNED_INT: return uint_types_scale[size-1]; + case GL_UNSIGNED_SHORT: return ushort_types_scale[size-1]; + case GL_UNSIGNED_BYTE: return ubyte_types_scale[size-1]; + default: assert(0); return 0; + } } return 0; /* silence compiler warning */ } @@ -181,7 +285,8 @@ st_draw_vbo(GLcontext *ctx, velement.vertex_buffer_index = attr; velement.dst_offset = 0; /* need this? */ velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size); + arrays[mesaAttr]->Size, + arrays[mesaAttr]->Normalized); assert(velement.src_format); /* tell pipe about this attribute */ @@ -438,7 +543,8 @@ st_feedback_draw_vbo(GLcontext *ctx, velement.vertex_buffer_index = attr; velement.dst_offset = 0; /* need this? */ velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size); + arrays[mesaAttr]->Size, + arrays[mesaAttr]->Normalized); assert(velement.src_format); /* tell draw about this attribute */ -- cgit v1.2.3 From f7195b32323d50e9541a5c5cb3143e83d05bd8d8 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 10 Dec 2007 21:07:53 +1100 Subject: Correct user VBO size. --- src/mesa/state_tracker/st_draw.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index c6fea1f7bc..24bb4823bc 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -266,9 +266,14 @@ st_draw_vbo(GLcontext *ctx, } else { /* attribute data is in user-space memory, not a VBO */ - uint bytes = (arrays[mesaAttr]->Size - * _mesa_sizeof_type(arrays[mesaAttr]->Type) - * (max_index + 1)); + uint bytes; + + if (!arrays[mesaAttr]->StrideB) { + bytes = arrays[mesaAttr]->Size + * _mesa_sizeof_type(arrays[mesaAttr]->Type); + } else { + bytes = arrays[mesaAttr]->StrideB * (max_index + 1); + } /* wrap user data */ vbuffer[attr].buffer -- cgit v1.2.3 From c9f9c5098042e4f200efc3d25447a5a8b7e69b36 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 10 Dec 2007 17:25:54 -0700 Subject: XXX comments about some hard-coded values that need to be fixed --- src/mesa/state_tracker/st_cb_fbo.c | 1 + src/mesa/state_tracker/st_draw.c | 1 + 2 files changed, 2 insertions(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 6e9e7e3a24..ef6aec6e88 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -120,6 +120,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer, NULL); + /* XXX don't hard-code magic 32 here */ strb->surface->buffer = pipe->winsys->buffer_create(pipe->winsys, 32, 0, 0); if (!strb->surface->buffer) return GL_FALSE; /* out of memory, try s/w buffer? */ diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 24bb4823bc..274ae86a3e 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -199,6 +199,7 @@ static void create_default_attribs_buffer(struct st_context *st) { struct pipe_context *pipe = st->pipe; + /* XXX don't hardcode magic 32 here */ st->default_attrib_buffer = pipe->winsys->buffer_create( pipe->winsys, 32, 0, 0 ); } -- cgit v1.2.3 From c31416971e4eac148f8e82d6c4392bd6f9cbc05d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 18 Dec 2007 17:25:33 +0000 Subject: gallium: rationalize vertex_element state packet Remove dst_offset (not used) Add nr_components, which could be calculated from format, but would be too much effort. Update i965 driver to cope. --- src/mesa/pipe/i965simple/brw_context.h | 10 +------ src/mesa/pipe/i965simple/brw_draw_upload.c | 14 ++------- src/mesa/pipe/i965simple/brw_state.c | 46 ++++++++++++++---------------- src/mesa/pipe/p_state.h | 4 +-- src/mesa/state_tracker/st_draw.c | 6 ++-- 5 files changed, 29 insertions(+), 51 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/i965simple/brw_context.h b/src/mesa/pipe/i965simple/brw_context.h index 11146570be..fc2cb055e9 100644 --- a/src/mesa/pipe/i965simple/brw_context.h +++ b/src/mesa/pipe/i965simple/brw_context.h @@ -443,14 +443,6 @@ struct brw_cached_batch_item { */ #define ATTRIB_BIT_DWORDS ((PIPE_ATTRIB_MAX+31)/32) -struct brw_vertex_element { - struct brw_vertex_element_state vep; - - unsigned index; - unsigned element_size; - unsigned count; - unsigned vbo_rebase_offset; -}; @@ -508,7 +500,7 @@ struct brw_context */ struct pipe_vertex_buffer *vbo_array[PIPE_ATTRIB_MAX]; - struct brw_vertex_element inputs[PIPE_ATTRIB_MAX]; + struct brw_vertex_element_state inputs[PIPE_ATTRIB_MAX]; #define BRW_NR_UPLOAD_BUFS 17 #define BRW_UPLOAD_INIT_SIZE (128*1024) diff --git a/src/mesa/pipe/i965simple/brw_draw_upload.c b/src/mesa/pipe/i965simple/brw_draw_upload.c index 19626ca633..88d6c9d111 100644 --- a/src/mesa/pipe/i965simple/brw_draw_upload.c +++ b/src/mesa/pipe/i965simple/brw_draw_upload.c @@ -260,18 +260,8 @@ boolean brw_upload_vertex_elements( struct brw_context *brw ) memset(&vep, 0, sizeof(vep)); - for (i = 0; i < nr_enabled; i++) { - struct brw_vertex_element *input = &brw->vb.inputs[i]; - - switch (brw->vb.vbo_array[input->vep.ve0.vertex_buffer_index]->pitch) { - case 0: input->vep.ve1.vfcomponent0 = BRW_VFCOMPONENT_STORE_0; - case 1: input->vep.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_0; - case 2: input->vep.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_0; - case 3: input->vep.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_1_FLT; - break; - } - vep.ve[i] = input->vep; - } + for (i = 0; i < nr_enabled; i++) + vep.ve[i] = brw->vb.inputs[i]; vep.header.length = (1 + nr_enabled * sizeof(vep.ve[0])/4) - 2; diff --git a/src/mesa/pipe/i965simple/brw_state.c b/src/mesa/pipe/i965simple/brw_state.c index 2008853654..daf14ff4ff 100644 --- a/src/mesa/pipe/i965simple/brw_state.c +++ b/src/mesa/pipe/i965simple/brw_state.c @@ -272,31 +272,27 @@ static void brw_set_vertex_element(struct pipe_context *pipe, struct brw_context *brw = brw_context(pipe); assert(index < PIPE_ATTRIB_MAX); - struct brw_vertex_element el; - memset(&el, 0, sizeof(struct brw_vertex_element)); - - /* do we need those anymore?*/ - el.index = index; -#if 0 - /*FIXME*/ - el.element_size = 0; - el.count = 0; - el.vbo_rebase_offset = 0; -#endif - - el.vep.ve0.src_offset = element->src_offset; - el.vep.ve0.src_format = brw_translate_surface_format(element->src_format); - el.vep.ve0.valid = 1; - el.vep.ve0.vertex_buffer_index = element->vertex_buffer_index; - - el.vep.ve1.dst_offset = index * 4; - el.vep.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_SRC; - el.vep.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_SRC; - el.vep.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_SRC; - el.vep.ve1.vfcomponent0 = BRW_VFCOMPONENT_STORE_SRC; - /*can we count of brw->vb.vbo_array[element->vertex_buffer_index] - * being initialized ok to actually compute vbcomponent's - * correctly? */ + struct brw_vertex_element_state el; + memset(&el, 0, sizeof(el)); + + el.ve0.src_offset = element->src_offset; + el.ve0.src_format = brw_translate_surface_format(element->src_format); + el.ve0.valid = 1; + el.ve0.vertex_buffer_index = element->vertex_buffer_index; + + el.ve1.dst_offset = index * 4; + + el.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_SRC; + el.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_SRC; + el.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_SRC; + el.ve1.vfcomponent0 = BRW_VFCOMPONENT_STORE_SRC; + + switch (element->nr_components) { + case 1: el.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_0; + case 2: el.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_0; + case 3: el.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_1_FLT; + break; + } brw->vb.inputs[index] = el; } diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index b7793c6d31..16d50fdb82 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -307,8 +307,8 @@ struct pipe_vertex_element * this attribute live in? */ unsigned vertex_buffer_index:5; - - unsigned dst_offset:8; + unsigned nr_components:3; + enum pipe_format src_format; /**< PIPE_FORMAT_* */ }; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 274ae86a3e..a3e061d604 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -289,7 +289,7 @@ st_draw_vbo(GLcontext *ctx, vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ vbuffer[attr].max_index = 0; /* need this? */ velement.vertex_buffer_index = attr; - velement.dst_offset = 0; /* need this? */ + velement.nr_components = arrays[mesaAttr]->Size; velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, arrays[mesaAttr]->Normalized); @@ -415,7 +415,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, velement.src_offset = i * 4 * sizeof(GLfloat); velement.vertex_buffer_index = 0; velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - velement.dst_offset = 0; + velement.nr_components = 4; pipe->set_vertex_element(pipe, i, &velement); } @@ -547,7 +547,7 @@ st_feedback_draw_vbo(GLcontext *ctx, vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ vbuffer[attr].max_index = 0; /* need this? */ velement.vertex_buffer_index = attr; - velement.dst_offset = 0; /* need this? */ + velement.nr_components = arrays[mesaAttr]->Size; velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, arrays[mesaAttr]->Normalized); -- cgit v1.2.3 From f13a200c8367c58fc962bdad9bcb22263d385886 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 19 Dec 2007 07:49:42 -0500 Subject: actually set the max_index. useful in the driver --- src/mesa/state_tracker/st_draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index a3e061d604..b3d463043d 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -287,7 +287,7 @@ st_draw_vbo(GLcontext *ctx, /* common-case setup */ vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ - vbuffer[attr].max_index = 0; /* need this? */ + vbuffer[attr].max_index = max_index; velement.vertex_buffer_index = attr; velement.nr_components = arrays[mesaAttr]->Size; velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, @@ -545,7 +545,7 @@ st_feedback_draw_vbo(GLcontext *ctx, /* common-case setup */ vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ - vbuffer[attr].max_index = 0; /* need this? */ + vbuffer[attr].max_index = max_index; velement.vertex_buffer_index = attr; velement.nr_components = arrays[mesaAttr]->Size; velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, -- cgit v1.2.3 From 678db26b9d2db0c76e7676b5499d8d55a5619a94 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 28 Dec 2007 14:25:09 -0700 Subject: unref buffer after drawing, fixes rastpos mem leak --- src/mesa/state_tracker/st_draw.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index b3d463043d..96db9e3c03 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -616,6 +616,7 @@ st_feedback_draw_vbo(GLcontext *ctx, if (draw->vertex_buffer[i].buffer) { pipe->winsys->buffer_unmap(pipe->winsys, draw->vertex_buffer[i].buffer); + winsys->buffer_reference(winsys, &draw->vertex_buffer[i].buffer, NULL); draw_set_mapped_vertex_buffer(draw, i, NULL); } } -- cgit v1.2.3 From ac95fee4fffee77bb7bd798d094ed2e3a7c4019b Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Jan 2008 19:12:46 -0700 Subject: Fix problems with vertex shaders and the private draw module. The CSO returned by pipe->create_vs_state() can't be passed to the private draw module. That was causing glRasterPos to blow up. Add a 'draw_shader' field to st_vertex_program for use with the private draw module. Change st_context->state.vs type from cso_vertex_shader to st_vertex_program. --- src/mesa/state_tracker/st_atom_shader.c | 23 +++++++++++++---------- src/mesa/state_tracker/st_cb_clear.c | 6 +++--- src/mesa/state_tracker/st_cb_drawpixels.c | 4 ++-- src/mesa/state_tracker/st_cb_program.c | 11 +++++++---- src/mesa/state_tracker/st_context.h | 2 +- src/mesa/state_tracker/st_debug.c | 4 ++-- src/mesa/state_tracker/st_draw.c | 12 ++++++++---- src/mesa/state_tracker/st_program.c | 6 ++---- src/mesa/state_tracker/st_program.h | 7 +++++-- 9 files changed, 43 insertions(+), 32 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 2a182c7d9c..1ed9333556 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -43,6 +43,8 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" +#include "pipe/cso_cache/cso_cache.h" + #include "st_context.h" #include "st_cache.h" #include "st_atom.h" @@ -71,8 +73,8 @@ struct translated_vertex_program /** The program in TGSI format */ struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; - /** Pointer to the translated, cached vertex shader */ - const struct cso_vertex_shader *vs; + /** Pointer to the translated vertex program */ + struct st_vertex_program *vp; struct translated_vertex_program *next; /**< next in linked list */ }; @@ -257,12 +259,13 @@ find_translated_vp(struct st_context *st, assert(stvp->Base.Base.NumInstructions > 1); - xvp->vs = st_translate_vertex_program(st, stvp, - xvp->output_to_slot, - xvp->tokens, - ST_MAX_SHADER_TOKENS); - assert(xvp->vs); - stvp->vs = NULL; /* don't want to use this */ + st_translate_vertex_program(st, stvp, + xvp->output_to_slot, + xvp->tokens, + ST_MAX_SHADER_TOKENS); + + assert(stvp->cso); + xvp->vp = stvp; /* translated VP is up to date now */ xvp->serialNo = stvp->serialNo; @@ -291,8 +294,8 @@ update_linkage( struct st_context *st ) xvp = find_translated_vp(st, stvp, stfp); st->vp = stvp; - st->state.vs = xvp->vs; - st->pipe->bind_vs_state(st->pipe, st->state.vs->data); + st->state.vs = xvp->vp; + st->pipe->bind_vs_state(st->pipe, st->state.vs->cso->data); st->fp = stfp; st->state.fs = stfp->fs; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 40319f4b4b..758d4a4086 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -208,7 +208,7 @@ make_vertex_shader(struct st_context *st) stvp = (struct st_vertex_program *) p; st_translate_vertex_program(st, stvp, NULL, stvp->tokens, ST_MAX_SHADER_TOKENS); - assert(stvp->vs); + assert(stvp->cso); return stvp; } @@ -350,7 +350,7 @@ clear_with_quad(GLcontext *ctx, if (!stvp) { stvp = make_vertex_shader(st); } - pipe->bind_vs_state(pipe, stvp->vs->data); + pipe->bind_vs_state(pipe, stvp->cso->data); } /* viewport state: viewport matching window dims */ @@ -376,7 +376,7 @@ clear_with_quad(GLcontext *ctx, pipe->bind_blend_state(pipe, st->state.blend->data); pipe->bind_depth_stencil_alpha_state(pipe, st->state.depth_stencil->data); pipe->bind_fs_state(pipe, st->state.fs->data); - pipe->bind_vs_state(pipe, st->state.vs->data); + pipe->bind_vs_state(pipe, st->state.vs->cso->data); pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); pipe->set_viewport_state(pipe, &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 be5434f91b..f4d6b9362c 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -662,7 +662,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, pipe->bind_fs_state(pipe, stfp->fs->data); /* vertex shader state: position + texcoord pass-through */ - pipe->bind_vs_state(pipe, stvp->vs->data); + pipe->bind_vs_state(pipe, stvp->cso->data); /* texture sampling state: */ { @@ -719,7 +719,7 @@ 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->data); - pipe->bind_vs_state(pipe, ctx->st->state.vs->data); + pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data); pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]); pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index aed6b1ee97..63a954264e 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -39,6 +39,8 @@ #include "shader/programopt.h" #include "shader/shader_api.h" +#include "pipe/cso_cache/cso_cache.h" + #include "st_context.h" #include "st_program.h" #include "st_atom_shader.h" @@ -181,10 +183,11 @@ static void st_program_string_notify( GLcontext *ctx, stvp->serialNo++; - if (stvp->vs) { - /* free the TGSI code */ - // cso_delete(stfp->vs); - stvp->vs = NULL; + if (stvp->cso) { + /* free the CSO data */ + st->pipe->delete_vs_state(st->pipe, stvp->cso->data); + FREE((void *) stvp->cso); + stvp->cso = NULL; } stvp->param_state = stvp->Base.Base.Parameters->StateFlags; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 0f40f3ceee..5ae21c93f9 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -100,7 +100,7 @@ struct st_context const struct cso_depth_stencil_alpha *depth_stencil; const struct cso_rasterizer *rasterizer; const struct cso_fragment_shader *fs; - const struct cso_vertex_shader *vs; + struct st_vertex_program *vs; struct pipe_blend_color blend_color; struct pipe_clip_state clip; diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index cffd66751d..57450e52bf 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -53,11 +53,11 @@ st_print_current(void) int i; printf("Vertex Transform Inputs:\n"); - for (i = 0; i < st->state.vs->state.num_inputs; i++) { + for (i = 0; i < st->state.vs->cso->state.num_inputs; i++) { printf(" Slot %d: VERT_ATTRIB_%d\n", i, st->vp->index_to_input[i]); } - tgsi_dump( st->state.vs->state.tokens, 0 ); + tgsi_dump( st->state.vs->cso->state.tokens, 0 ); if (st->vp->Base.Base.Parameters) _mesa_print_parameter_list(st->vp->Base.Base.Parameters); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 96db9e3c03..94b3a9531a 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -241,7 +241,7 @@ st_draw_vbo(GLcontext *ctx, /* must get these after state validation! */ vp = ctx->st->vp; - vs = &ctx->st->state.vs->state; + vs = &ctx->st->state.vs->cso->state; /* loop over TGSI shader inputs to determine vertex buffer * and attribute info @@ -447,7 +447,7 @@ set_feedback_vertex_format(GLcontext *ctx) else { /* GL_FEEDBACK, or glRasterPos */ /* emit all attribs (pos, color, texcoord) as GLfloat[4] */ - vinfo.num_attribs = st->state.vs->state.num_outputs; + vinfo.num_attribs = st->state.vs->cso->state.num_outputs; for (i = 0; i < vinfo.num_attribs; i++) { vinfo.format[i] = FORMAT_4F; vinfo.interp_mode[i] = INTERP_LINEAR; @@ -491,7 +491,11 @@ st_feedback_draw_vbo(GLcontext *ctx, /* must get these after state validation! */ vp = ctx->st->vp; - vs = &ctx->st->state.vs->state; + vs = &ctx->st->state.vs->cso->state; + + if (!st->state.vs->draw_shader) { + st->state.vs->draw_shader = draw_create_vertex_shader(draw, vs); + } /* * Set up the draw module's state. @@ -503,7 +507,7 @@ 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->state); - draw_bind_vertex_shader(draw, st->state.vs->data); + draw_bind_vertex_shader(draw, st->state.vs->draw_shader); set_feedback_vertex_format(ctx); /* loop over TGSI shader inputs to determine vertex buffer diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 1852228b29..1f1e6500e0 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -57,7 +57,7 @@ * \param tokensOut destination for TGSI tokens * \return pointer to cached pipe_shader object. */ -const struct cso_vertex_shader * +void st_translate_vertex_program(struct st_context *st, struct st_vertex_program *stvp, const GLuint outputMapping[], @@ -256,12 +256,10 @@ st_translate_vertex_program(struct st_context *st, vs.tokens = tokensOut; cso = st_cached_vs_state(st, &vs); - stvp->vs = cso; + stvp->cso = cso; if (TGSI_DEBUG) tgsi_dump( tokensOut, 0 ); - - return cso; } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 049f9f659f..de02c3185f 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -90,7 +90,10 @@ struct st_vertex_program struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; /** Pointer to the corresponding cached shader */ - const struct cso_vertex_shader *vs; + const struct cso_vertex_shader *cso; + + /** For using our private draw module (glRasterPos) */ + struct draw_vertex_shader *draw_shader; GLuint param_state; }; @@ -122,7 +125,7 @@ st_translate_fragment_program(struct st_context *st, GLuint maxTokens); -extern const struct cso_vertex_shader * +extern void st_translate_vertex_program(struct st_context *st, struct st_vertex_program *vp, const GLuint vert_output_to_slot[], -- cgit v1.2.3 From b3f081999f8eb904370df7492e39184268c77c13 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 23 Jan 2008 09:27:39 -0700 Subject: gallium: s/INTERP_NONE/INTERP_LINEAR/ to fix assertion with progs/samples/select.c --- src/mesa/state_tracker/st_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 94b3a9531a..8674b3edd1 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -442,7 +442,7 @@ set_feedback_vertex_format(GLcontext *ctx) assert(ctx->RenderMode == GL_SELECT); vinfo.num_attribs = 1; vinfo.format[0] = FORMAT_4F; - vinfo.interp_mode[0] = INTERP_NONE; + vinfo.interp_mode[0] = INTERP_LINEAR; } else { /* GL_FEEDBACK, or glRasterPos */ -- cgit v1.2.3 From cd3643698eafa0869a8317b002e5b066de0172e7 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 23 Jan 2008 12:48:41 -0700 Subject: gallium: overhaul usage of vertex_info in draw module. Remove all dependencies on vertex_info, except for draw_vbuf. Drawing stages now strictly operate on post-transformed vertices and don't know anything about hw vertices. Use vertex program output info for two-side/flat/etc stages. Temporarily disable vbuf module in softpipe driver. --- src/mesa/pipe/draw/draw_clip.c | 4 +- src/mesa/pipe/draw/draw_context.c | 6 --- src/mesa/pipe/draw/draw_context.h | 1 - src/mesa/pipe/draw/draw_flatshade.c | 73 +++++++++++++++++---------- src/mesa/pipe/draw/draw_private.h | 14 ++--- src/mesa/pipe/draw/draw_stipple.c | 30 +++-------- src/mesa/pipe/draw/draw_twoside.c | 35 +++++++++++-- src/mesa/pipe/draw/draw_vertex.c | 70 ------------------------- src/mesa/pipe/draw/draw_vertex.h | 14 +---- src/mesa/pipe/draw/draw_vertex_cache.c | 1 - src/mesa/pipe/draw/draw_vertex_fetch.c | 1 - src/mesa/pipe/draw/draw_vertex_shader.c | 5 +- src/mesa/pipe/draw/draw_vertex_shader_llvm.c | 5 +- src/mesa/pipe/i915simple/i915_state_derived.c | 6 +-- src/mesa/pipe/softpipe/sp_context.c | 2 +- src/mesa/pipe/softpipe/sp_context.h | 2 + src/mesa/pipe/softpipe/sp_prim_setup.c | 2 +- src/mesa/pipe/softpipe/sp_prim_vbuf.c | 5 +- src/mesa/pipe/softpipe/sp_state_derived.c | 7 ++- src/mesa/state_tracker/st_draw.c | 4 ++ 20 files changed, 117 insertions(+), 170 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c index c50376f11f..e0eb656364 100644 --- a/src/mesa/pipe/draw/draw_clip.c +++ b/src/mesa/pipe/draw/draw_clip.c @@ -93,7 +93,7 @@ static void interp( const struct clipper *clip, const struct vertex_header *out, const struct vertex_header *in ) { - const unsigned nr_attrs = clip->stage.draw->vertex_info.num_attribs; + const unsigned nr_attrs = clip->stage.draw->num_vs_outputs; unsigned j; /* Vertex header. @@ -349,7 +349,7 @@ do_clip_line( struct draw_stage *stage, static void clip_begin( struct draw_stage *stage ) { /* should always have position, at least */ - assert(stage->draw->vertex_info.num_attribs >= 1); + assert(stage->draw->num_vs_outputs > 0); stage->next->begin( stage->next ); } diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index 5b9ea55630..ff23288fa8 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -77,11 +77,6 @@ struct draw_context *draw_create( void ) draw->vcache.vertex[i] = (struct vertex_header *)(tmp + i * MAX_VERTEX_SIZE); } - draw->attrib_front0 = 0; - draw->attrib_back0 = 0; - draw->attrib_front1 = 0; - draw->attrib_back1 = 0; - draw->convert_wide_points = TRUE; draw->convert_wide_lines = TRUE; @@ -242,7 +237,6 @@ draw_convert_wide_lines(struct draw_context *draw, boolean enable) } - /** * Allocate space for temporary post-transform vertices, such as for clipping. */ diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index cfde26ceb7..ddeb184497 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -122,7 +122,6 @@ void draw_set_mapped_constant_buffer(struct draw_context *draw, const void *buffer); - /*********************************************************************** * draw_prim.c */ diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c index d7551e7948..46b0f7970f 100644 --- a/src/mesa/pipe/draw/draw_flatshade.c +++ b/src/mesa/pipe/draw/draw_flatshade.c @@ -29,42 +29,59 @@ */ #include "pipe/p_util.h" +#include "pipe/p_shader_tokens.h" #include "draw_private.h" -static void flatshade_begin( struct draw_stage *stage ) +/** subclass of draw_stage */ +struct flat_stage { - stage->next->begin( stage->next ); -} + struct draw_stage stage; + + uint num_color_attribs; + uint color_attribs[4]; /* front/back primary/secondary colors */ +}; +static INLINE struct flat_stage * +flat_stage(struct draw_stage *stage) +{ + return (struct flat_stage *) stage; +} + -static INLINE void copy_attr( unsigned attr, - struct vertex_header *dst, - const struct vertex_header *src ) +static void flatshade_begin( struct draw_stage *stage ) { - if (attr) { - memcpy( dst->data[attr], - src->data[attr], - sizeof(src->data[0]) ); + 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, const struct vertex_header *src ) { - const uint num_attribs = stage->draw->vertex_info.num_attribs; - const enum interp_mode *interp = stage->draw->vertex_info.interp_mode; + const struct flat_stage *flat = flat_stage(stage); uint i; /* Look for constant/flat attribs and duplicate from src to dst vertex */ /* skip attrib[0] which is vert pos */ - for (i = 1; i < num_attribs; i++) { - if (interp[i] == INTERP_CONSTANT) { - copy_attr( i, dst, src ); - } + for (i = 0; i < flat->num_color_attribs; i++) { + const uint attr = flat->color_attribs[i]; + memcpy(dst->data[attr], src->data[attr], sizeof(src->data[0])); } } @@ -139,21 +156,21 @@ static void flatshade_destroy( struct draw_stage *stage ) */ struct draw_stage *draw_flatshade_stage( struct draw_context *draw ) { - struct draw_stage *flatshade = CALLOC_STRUCT(draw_stage); + struct flat_stage *flatshade = CALLOC_STRUCT(flat_stage); - draw_alloc_tmps( flatshade, 2 ); + draw_alloc_tmps( &flatshade->stage, 2 ); - flatshade->draw = draw; - flatshade->next = NULL; - flatshade->begin = flatshade_begin; - flatshade->point = flatshade_point; - flatshade->line = flatshade_line; - flatshade->tri = flatshade_tri; - flatshade->end = flatshade_end; - flatshade->reset_stipple_counter = flatshade_reset_stipple_counter; - flatshade->destroy = flatshade_destroy; + 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.reset_stipple_counter = flatshade_reset_stipple_counter; + flatshade->stage.destroy = flatshade_destroy; - return flatshade; + return &flatshade->stage; } diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index a264fabfb4..685ec4a644 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -44,8 +44,6 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" -#include "draw_vertex.h" - #include "x86/rtasm/x86sse.h" #include "pipe/tgsi/exec/tgsi_exec.h" @@ -170,6 +168,8 @@ struct draw_context struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; const struct draw_vertex_shader *vertex_shader; + uint num_vs_outputs; /**< convenience, from vertex_shader */ + /* user-space vertex data, buffers */ struct { /** vertex element/index buffer (ex: glDrawElements) */ @@ -189,12 +189,6 @@ struct draw_context float plane[12][4]; unsigned nr_planes; - /** Describes the layout of post-transformation vertices */ - struct vertex_info vertex_info; - /** Two-sided attributes: */ - uint attrib_front0, attrib_back0; - uint attrib_front1, attrib_back1; - boolean convert_wide_points; /**< convert wide points to tris? */ boolean convert_wide_lines; /**< convert side lines to tris? */ @@ -309,7 +303,9 @@ dup_vert( struct draw_stage *stage, unsigned idx ) { struct vertex_header *tmp = stage->tmp[idx]; - memcpy(tmp, vert, stage->draw->vertex_info.size * sizeof(float) ); + 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; } diff --git a/src/mesa/pipe/draw/draw_stipple.c b/src/mesa/pipe/draw/draw_stipple.c index 3e0d5689e1..2a47eb7be2 100644 --- a/src/mesa/pipe/draw/draw_stipple.c +++ b/src/mesa/pipe/draw/draw_stipple.c @@ -61,6 +61,7 @@ stipple_stage(struct draw_stage *stage) /** * Compute interpolated vertex attributes for 'dst' at position 't' * between 'v0' and 'v1'. + * XXX using linear interpolation for all attribs at this time. */ static void screen_interp( struct draw_context *draw, @@ -70,28 +71,13 @@ screen_interp( struct draw_context *draw, const struct vertex_header *v1 ) { uint attr; - for (attr = 0; attr < draw->vertex_info.num_attribs; attr++) { - switch (draw->vertex_info.interp_mode[attr]) { - case INTERP_NONE: - case INTERP_CONSTANT: - COPY_4FV(dst->data[attr], v0->data[attr]); - break; - case INTERP_PERSPECTIVE: - /* Fall-through */ - /* XXX special-case perspective? */ - case INTERP_LINEAR: - { - const float *val0 = v0->data[attr]; - const float *val1 = v1->data[attr]; - float *newv = dst->data[attr]; - uint i; - for (i = 0; i < 4; i++) { - newv[i] = val0[i] + t * (val1[i] - val0[i]); - } - } - break; - default: - abort(); + for (attr = 0; attr < draw->num_vs_outputs; attr++) { + const float *val0 = v0->data[attr]; + const float *val1 = v1->data[attr]; + float *newv = dst->data[attr]; + uint i; + for (i = 0; i < 4; i++) { + newv[i] = val0[i] + t * (val1[i] - val0[i]); } } } diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c index c7e268f11e..da8e7bd90d 100644 --- a/src/mesa/pipe/draw/draw_twoside.c +++ b/src/mesa/pipe/draw/draw_twoside.c @@ -30,12 +30,15 @@ #include "pipe/p_util.h" #include "pipe/p_defines.h" +#include "pipe/p_shader_tokens.h" #include "draw_private.h" struct twoside_stage { struct draw_stage stage; float sign; /**< +1 or -1 */ + uint attrib_front0, attrib_back0; + uint attrib_front1, attrib_back1; }; @@ -48,6 +51,29 @@ 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; + } + } /* * We'll multiply the primitive's determinant by this sign to determine @@ -76,13 +102,12 @@ static struct vertex_header *copy_bfc( struct twoside_stage *twoside, unsigned idx ) { struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx ); - const struct draw_context *draw = twoside->stage.draw; - if (draw->attrib_front0 && draw->attrib_back0) { - copy_attrib(draw->attrib_front0, draw->attrib_back0, tmp); + if (twoside->attrib_front0 && twoside->attrib_back0) { + copy_attrib(twoside->attrib_front0, twoside->attrib_back0, tmp); } - if (draw->attrib_front1 && draw->attrib_back1) { - copy_attrib(draw->attrib_front1, draw->attrib_back1, tmp); + if (twoside->attrib_front1 && twoside->attrib_back1) { + copy_attrib(twoside->attrib_front1, twoside->attrib_back1, tmp); } return tmp; diff --git a/src/mesa/pipe/draw/draw_vertex.c b/src/mesa/pipe/draw/draw_vertex.c index 6191fcedbf..1ab004be10 100644 --- a/src/mesa/pipe/draw/draw_vertex.c +++ b/src/mesa/pipe/draw/draw_vertex.c @@ -38,17 +38,6 @@ #include "pipe/draw/draw_vertex.h" -static INLINE void -emit_vertex_attr(struct vertex_info *vinfo, - enum attrib_format format, enum interp_mode interp) -{ - const uint n = vinfo->num_attribs; - vinfo->interp_mode[n] = interp; - vinfo->format[n] = format; - vinfo->num_attribs++; -} - - /** * Compute the size of a vertex, in dwords/floats, to update the * vinfo->size field. @@ -86,62 +75,3 @@ draw_compute_vertex_size(struct vertex_info *vinfo) assert(vinfo->size * 4 <= MAX_VERTEX_SIZE); } - - -/** - * Tell the drawing module about the contents of post-transformation vertices. - * Note that the vertex attribute format info isn't used by 'draw'; all - * attributes are handled as float[4]. But when the driver emits vertices - * it'll use that info. - * We _do_ care about the number of attributes and their interpolation modes. - */ -void -draw_set_vertex_info( struct draw_context *draw, - const struct vertex_info *info) -{ - assert(info->interp_mode[0] == INTERP_LINEAR); /* should be vert pos */ - assert(info->num_attribs <= PIPE_MAX_SHADER_OUTPUTS); - - memcpy(&draw->vertex_info, info, sizeof(*info)); - - /* Need to know vertex size (in words) for vertex copying elsewhere. - * Four words per attribute, plus vertex header (uint) and clip - * position (float[4]). - */ - draw->vertex_info.size = draw->vertex_info.num_attribs * 4 + 5; -} - - -/** - * This function is used to tell the draw module about attributes - * (like colors) that need to be selected based on front/back face - * orientation. - * - * The logic is: - * if (polygon is back-facing) { - * vertex->attrib[front0] = vertex->attrib[back0]; - * vertex->attrib[front1] = vertex->attrib[back1]; - * } - * - * \param front0 first attrib to replace if the polygon is back-facing - * \param back0 first attrib to copy if the polygon is back-facing - * \param front1 second attrib to replace if the polygon is back-facing - * \param back1 second attrib to copy if the polygon is back-facing - * - * Pass -1 to disable two-sided attributes. - */ -void -draw_set_twoside_attributes(struct draw_context *draw, - uint front0, uint back0, - uint front1, uint back1) -{ - /* XXX we could alternately pass an array of front/back attribs if there's - * ever need for more than two. One could imagine a shader extension - * that allows arbitrary attributes to be selected based on polygon - * orientation... - */ - draw->attrib_front0 = front0; - draw->attrib_back0 = back0; - draw->attrib_front1 = front1; - draw->attrib_back1 = back1; -} diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index e4f85bc49f..28abd8ab91 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -34,9 +34,6 @@ #define DRAW_VERTEX_H -struct draw_context; - - /** * Vertex attribute format */ @@ -63,7 +60,7 @@ enum interp_mode { /** - * Information about post-transformed vertex layout. + * Information about hardware/rasterization vertex layout. */ struct vertex_info { @@ -71,7 +68,7 @@ struct vertex_info uint hwfmt[4]; /**< hardware format info for this format */ enum interp_mode interp_mode[PIPE_MAX_SHADER_OUTPUTS]; enum attrib_format format[PIPE_MAX_SHADER_OUTPUTS]; /**< FORMAT_x */ - uint src_index[PIPE_MAX_SHADER_OUTPUTS]; + uint src_index[PIPE_MAX_SHADER_OUTPUTS]; /**< map to post-xform attribs */ uint size; /**< total vertex size in dwords */ }; @@ -98,13 +95,6 @@ draw_emit_vertex_attr(struct vertex_info *vinfo, } -extern void draw_set_vertex_info( struct draw_context *draw, - const struct vertex_info *info); - -extern void draw_set_twoside_attributes(struct draw_context *draw, - uint front0, uint back0, - uint front1, uint back1); - extern void draw_compute_vertex_size(struct vertex_info *vinfo); diff --git a/src/mesa/pipe/draw/draw_vertex_cache.c b/src/mesa/pipe/draw/draw_vertex_cache.c index 29993f14d2..97a40b876e 100644 --- a/src/mesa/pipe/draw/draw_vertex_cache.c +++ b/src/mesa/pipe/draw/draw_vertex_cache.c @@ -33,7 +33,6 @@ #include "pipe/p_util.h" #include "draw_private.h" #include "draw_context.h" -#include "draw_vertex.h" void draw_vertex_cache_invalidate( struct draw_context *draw ) diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index 3ca17f8829..4d64d3d4f2 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -34,7 +34,6 @@ #include "pipe/p_shader_tokens.h" #include "draw_private.h" #include "draw_context.h" -#include "draw_vertex.h" #define DRAW_DBG 0 diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index c2e038453e..5ca659dbf5 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -38,7 +38,6 @@ #endif #include "draw_private.h" #include "draw_context.h" -#include "draw_vertex.h" #include "x86/rtasm/x86sse.h" #include "pipe/llvm/gallivm.h" @@ -176,7 +175,7 @@ run_vertex_program(struct draw_context *draw, /* Remaining attributes are packed into sequential post-transform * vertex attrib slots. */ - for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) { + for (slot = 1; slot < draw->num_vs_outputs; slot++) { vOut[j]->data[slot][0] = machine->Outputs[slot].xyzw[0].f[j]; vOut[j]->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j]; vOut[j]->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j]; @@ -275,6 +274,8 @@ draw_bind_vertex_shader(struct draw_context *draw, draw_flush(draw); draw->vertex_shader = dvs; + draw->num_vs_outputs = dvs->state->num_outputs; + /* specify the fragment program to interpret/execute */ tgsi_exec_machine_init(&draw->machine, draw->vertex_shader->state->tokens, diff --git a/src/mesa/pipe/draw/draw_vertex_shader_llvm.c b/src/mesa/pipe/draw/draw_vertex_shader_llvm.c index acd61163fa..08be1b83f8 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader_llvm.c +++ b/src/mesa/pipe/draw/draw_vertex_shader_llvm.c @@ -33,7 +33,6 @@ #include "pipe/p_util.h" #include "draw_private.h" #include "draw_context.h" -#include "draw_vertex.h" #ifdef MESA_LLVM @@ -132,7 +131,7 @@ void draw_vertex_shader_queue_flush_llvm(struct draw_context *draw) gallivm_prog_exec(prog, inputs, outputs, consts, draw->vs.queue_nr, draw->vertex_shader->state->num_inputs, - draw->vertex_info.num_attribs - 2); + draw->vertex_shader->state->num_outputs); /* store machine results */ @@ -173,7 +172,7 @@ void draw_vertex_shader_queue_flush_llvm(struct draw_context *draw) /* Remaining attributes are packed into sequential post-transform * vertex attrib slots. */ - for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) { + for (slot = 1; slot < draw->vs_num_outputs; slot++) { vOut->data[slot][0] = dests[slot][0]; vOut->data[slot][1] = dests[slot][1]; vOut->data[slot][2] = dests[slot][2]; diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c index 466c704d87..1f17de9cef 100644 --- a/src/mesa/pipe/i915simple/i915_state_derived.c +++ b/src/mesa/pipe/i915simple/i915_state_derived.c @@ -133,10 +133,10 @@ static void calculate_vertex_layout( struct i915_context *i915 ) /* If the attributes have changed, tell the draw module about the new * vertex layout. We'll also update the hardware vertex format info. */ - draw_set_vertex_info( i915->draw, &vinfo); + /*draw_set_vertex_info( i915->draw, &vinfo);*/ - draw_set_twoside_attributes(i915->draw, - front0, back0, front1, back1); + /*draw_set_twoside_attributes(i915->draw, + front0, back0, front1, back1);*/ /* Need to set this flag so that the LIS2/4 registers get set. * It also means the i915_update_immediate() function must be called diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 68c18e2d05..6dccedbdcb 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -328,7 +328,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, assert(softpipe->draw); softpipe->setup = sp_draw_render_stage(softpipe); - if (GETENV( "SP_VBUF" ) != NULL) { + if (0 && GETENV( "SP_VBUF" ) != NULL) { softpipe->vbuf = sp_draw_vbuf_stage(softpipe->draw, &softpipe->pipe, sp_vbuf_render); diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 3537f86a61..4ce0410075 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -40,6 +40,7 @@ struct softpipe_winsys; +struct softpipe_vbuf_render; struct draw_context; struct draw_stage; struct softpipe_tile_cache; @@ -125,6 +126,7 @@ struct softpipe_context { struct draw_context *draw; struct draw_stage *setup; struct draw_stage *vbuf; + struct softpipe_vbuf_render *vbuf_render; uint current_cbuf; /**< current color buffer being written to */ diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index cdc385e4db..533a2fbd4d 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -1278,7 +1278,7 @@ void sp_vbuf_render( struct pipe_context *pipe, struct softpipe_context *softpipe = softpipe_context( pipe ); struct setup_stage *setup = setup_stage( softpipe->setup ); struct prim_header prim; - unsigned vertex_size = setup->stage.draw->vertex_info.size * sizeof(float); + unsigned vertex_size = softpipe->vertex_info.size * sizeof(float); unsigned i, j; prim.det = 0; diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.c b/src/mesa/pipe/softpipe/sp_prim_vbuf.c index 055cb19f9a..1d58e375a9 100644 --- a/src/mesa/pipe/softpipe/sp_prim_vbuf.c +++ b/src/mesa/pipe/softpipe/sp_prim_vbuf.c @@ -263,8 +263,11 @@ static void vbuf_flush_elements( struct draw_stage *stage ) static void vbuf_begin( struct draw_stage *stage ) { struct vbuf_stage *vbuf = vbuf_stage(stage); + struct softpipe_context *softpipe = softpipe_context(vbuf->pipe); - vbuf->vertex_size = vbuf->draw_context->vertex_info.size * sizeof(float); + //vbuf->vertex_size = vbuf->draw_context->vertex_info.size * sizeof(float); + + vbuf->vertex_size = softpipe->vertex_info.size * sizeof(float); } diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 0f1410e5de..64e86a0d86 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -122,6 +122,8 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) } } + draw_compute_vertex_size(vinfo); + softpipe->nr_frag_attrs = fs->num_inputs; /* We want these after all other attribs since they won't get passed @@ -146,10 +148,11 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) if (1/*vinfo->attr_mask != softpipe->attr_mask*/) { /*softpipe->attr_mask = vinfo->attr_mask;*/ - draw_set_vertex_info( softpipe->draw, vinfo); + /*draw_set_vertex_info( softpipe->draw, vinfo);*/ - draw_set_twoside_attributes(softpipe->draw, + /*draw_set_twoside_attributes(softpipe->draw, front0, back0, front1, back1); + */ } } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 8674b3edd1..71acf6e862 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -434,10 +434,13 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, static void set_feedback_vertex_format(GLcontext *ctx) { +#if 0 struct st_context *st = ctx->st; struct vertex_info vinfo; GLuint i; + memset(&vinfo, 0, sizeof(vinfo)); + if (ctx->RenderMode == GL_SELECT) { assert(ctx->RenderMode == GL_SELECT); vinfo.num_attribs = 1; @@ -455,6 +458,7 @@ set_feedback_vertex_format(GLcontext *ctx) } draw_set_vertex_info(st->draw, &vinfo); +#endif } -- cgit v1.2.3 From 756d52ec12c41ee90ee9598dc9028cc134806bd2 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 25 Jan 2008 17:01:01 +0100 Subject: gallium: Simplify winsys buffer interface. The properties of a buffer represented by struct pipe_buffer_handle are now basically constant over its lifetime. The state tracker gets to deal with any more complex buffer semantics it may need to provide. --- .../drivers/dri/intel_winsys/intel_winsys_pipe.c | 82 +++++++------- src/mesa/pipe/i915simple/i915_context.c | 4 +- src/mesa/pipe/i915simple/i915_prim_vbuf.c | 8 +- src/mesa/pipe/i915simple/i915_state.c | 3 +- src/mesa/pipe/i915simple/i915_texture.c | 14 +-- src/mesa/pipe/i965simple/brw_curbe.c | 7 +- src/mesa/pipe/i965simple/brw_draw_upload.c | 6 +- src/mesa/pipe/i965simple/brw_misc_state.c | 6 +- src/mesa/pipe/i965simple/brw_state_pool.c | 10 +- src/mesa/pipe/i965simple/brw_tex_layout.c | 14 +-- src/mesa/pipe/p_defines.h | 26 ++--- src/mesa/pipe/p_inlines.h | 4 +- src/mesa/pipe/p_winsys.h | 59 +++------- src/mesa/pipe/pipebuffer/pb_buffer_handle.c | 52 +-------- src/mesa/pipe/pipebuffer/pb_buffer_handle.h | 4 +- src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c | 3 +- src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c | 4 +- src/mesa/pipe/softpipe/sp_draw_arrays.c | 6 +- src/mesa/pipe/softpipe/sp_texture.c | 9 +- src/mesa/pipe/xlib/xm_winsys.c | 69 ++---------- src/mesa/pipe/xlib/xm_winsys_aub.c | 119 +++++---------------- src/mesa/state_tracker/st_atom_constbuf.c | 16 ++- src/mesa/state_tracker/st_cb_bufferobjects.c | 106 ++++++++++-------- src/mesa/state_tracker/st_cb_bufferobjects.h | 1 + src/mesa/state_tracker/st_context.h | 7 -- src/mesa/state_tracker/st_draw.c | 45 ++------ 26 files changed, 228 insertions(+), 456 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.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 340fa2fb85..43ed0602a4 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c @@ -70,10 +70,10 @@ static void *intel_buffer_map(struct pipe_winsys *winsys, { unsigned drm_flags = 0; - if (flags & PIPE_BUFFER_FLAG_WRITE) + if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) drm_flags |= DRM_BO_FLAG_WRITE; - if (flags & PIPE_BUFFER_FLAG_READ) + if (flags & PIPE_BUFFER_USAGE_CPU_READ) drm_flags |= DRM_BO_FLAG_READ; return driBOMap( dri_bo(buf), drm_flags, 0 ); @@ -103,50 +103,48 @@ intel_buffer_reference(struct pipe_winsys *winsys, } -/* Grabs the hardware lock! - */ -static int intel_buffer_data(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, - unsigned size, const void *data, - unsigned usage ) -{ - driBOData( dri_bo(buf), size, data, 0 ); - return 0; -} - -static int intel_buffer_subdata(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, - unsigned long offset, - unsigned long size, - const void *data) -{ - driBOSubData( dri_bo(buf), offset, size, data ); - return 0; -} - -static int intel_buffer_get_subdata(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, - unsigned long offset, - unsigned long size, - void *data) -{ - driBOGetSubData( dri_bo(buf), offset, size, data ); - return 0; -} - /* Pipe has no concept of pools. We choose the tex/region pool * for all buffers. + * Grabs the hardware lock! */ static struct pipe_buffer_handle * intel_buffer_create(struct pipe_winsys *winsys, unsigned alignment, - unsigned flags, - unsigned hint ) + unsigned usage, + unsigned size ) { struct _DriBufferObject *buffer; struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys); + unsigned flags = 0; + + if (usage & (PIPE_BUFFER_USAGE_VERTEX /*| IWS_BUFFER_USAGE_LOCAL*/)) { + flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED; + } else { + flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT; + } + + if (usage & PIPE_BUFFER_USAGE_GPU_READ) + flags |= DRM_BO_FLAG_READ; + + if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) + flags |= DRM_BO_FLAG_WRITE; + + /* drm complains if we don't set any read/write flags. + */ + if ((flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) == 0) + flags |= DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE; + +#if 0 + if (flags & IWS_BUFFER_USAGE_EXE) + flags |= DRM_BO_FLAG_EXE; + + if (usage & IWS_BUFFER_USAGE_CACHED) + flags |= DRM_BO_FLAG_CACHED; +#endif + driGenBuffers( iws->regionPool, - "pipe buffer", 1, &buffer, alignment, flags, hint ); + "pipe buffer", 1, &buffer, alignment, flags, 0 ); + driBOData( buffer, size, NULL, 0 ); return pipe_bo(buffer); } @@ -219,15 +217,12 @@ intel_i915_surface_alloc_storage(struct pipe_winsys *winsys, surf->pitch = round_up(width, alignment / surf->cpp); assert(!surf->buffer); - surf->buffer = winsys->buffer_create(winsys, alignment, 0, 0); + surf->buffer = winsys->buffer_create(winsys, alignment, + PIPE_BUFFER_USAGE_PIXEL, + surf->pitch * surf->cpp * height); if(!surf->buffer) return -1; - ret = winsys->buffer_data(winsys, - surf->buffer, - surf->pitch * surf->cpp * height, - NULL, - PIPE_BUFFER_USAGE_PIXEL); if(ret) { winsys->buffer_reference(winsys, &surf->buffer, NULL); return ret; @@ -285,9 +280,6 @@ intel_create_pipe_winsys( int fd ) iws->winsys.buffer_map = intel_buffer_map; iws->winsys.buffer_unmap = intel_buffer_unmap; iws->winsys.buffer_reference = intel_buffer_reference; - iws->winsys.buffer_data = intel_buffer_data; - iws->winsys.buffer_subdata = intel_buffer_subdata; - iws->winsys.buffer_get_subdata = intel_buffer_get_subdata; iws->winsys.flush_frontbuffer = intel_flush_frontbuffer; iws->winsys.printf = intel_printf; iws->winsys.get_name = intel_get_name; diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index 1c6b8cbb05..c2b96d2554 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -185,7 +185,7 @@ i915_draw_elements( struct pipe_context *pipe, void *buf = pipe->winsys->buffer_map(pipe->winsys, i915->vertex_buffer[i].buffer, - PIPE_BUFFER_FLAG_READ); + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } } @@ -193,7 +193,7 @@ i915_draw_elements( struct pipe_context *pipe, if (indexBuffer) { void *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, - PIPE_BUFFER_FLAG_READ); + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c index edc62e25e5..0887f9a1c6 100644 --- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c +++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c @@ -99,16 +99,14 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render, /* FIXME: handle failure */ assert(!i915->vbo); - i915->vbo = winsys->buffer_create(winsys, 64, 0, 0); - winsys->buffer_data( winsys, i915->vbo, - size, NULL, - I915_BUFFER_USAGE_LIT_VERTEX ); + i915->vbo = winsys->buffer_create(winsys, 64, I915_BUFFER_USAGE_LIT_VERTEX, + size); i915->dirty |= I915_NEW_VBO; return winsys->buffer_map(winsys, i915->vbo, - PIPE_BUFFER_FLAG_WRITE ); + PIPE_BUFFER_USAGE_CPU_WRITE); } diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 1190e05699..950ea52d60 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -476,7 +476,8 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, { void *mapped; if (buf->size && - (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_FLAG_READ))) { + (mapped = ws->buffer_map(ws, buf->buffer, + PIPE_BUFFER_USAGE_CPU_READ))) { memcpy(i915->current.constants[shader], mapped, buf->size); ws->buffer_unmap(ws, buf->buffer); i915->current.num_user_constants[shader] diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c index 6b0a4a96f3..bf80e18233 100644 --- a/src/mesa/pipe/i915simple/i915_texture.c +++ b/src/mesa/pipe/i915simple/i915_texture.c @@ -490,15 +490,11 @@ i915_texture_create(struct pipe_context *pipe, struct pipe_texture **pt) sizeof(struct i915_texture) - sizeof(struct pipe_texture)); if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) : - i915_miptree_layout(pipe, tex)) { - tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64, 0, 0); - - if (tex->buffer) - pipe->winsys->buffer_data(pipe->winsys, tex->buffer, - tex->pitch * tex->base.cpp * - tex->total_height, NULL, - PIPE_BUFFER_USAGE_PIXEL); - } + i915_miptree_layout(pipe, tex)) + tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64, + PIPE_BUFFER_USAGE_PIXEL, + tex->pitch * tex->base.cpp * + tex->total_height); if (!tex->buffer) { FREE(tex); diff --git a/src/mesa/pipe/i965simple/brw_curbe.c b/src/mesa/pipe/i965simple/brw_curbe.c index 4d79a7abe2..2733eb4e75 100644 --- a/src/mesa/pipe/i965simple/brw_curbe.c +++ b/src/mesa/pipe/i965simple/brw_curbe.c @@ -255,15 +255,12 @@ static void upload_constant_buffer(struct brw_context *brw) /* FIXME: buffer size is num_consts + num_immediates */ if (brw->vs.prog_data->num_consts) { /* map the vertex constant buffer and copy to curbe: */ - ws->buffer_map(ws, cbuffer->buffer, 0); + void *data = ws->buffer_map(ws, cbuffer->buffer, 0); /* FIXME: this is wrong. the cbuffer->size currently * represents size of consts + immediates. so if we'll * have both we'll copy over the end of the buffer * with the subsequent memcpy */ - ws->buffer_get_subdata(ws, cbuffer->buffer, - 0, - cbuffer->size, - &buf[offset]); + memcpy(&buf[offset], data, cbuffer->size); ws->buffer_unmap(ws, cbuffer->buffer); offset += cbuffer->size; } diff --git a/src/mesa/pipe/i965simple/brw_draw_upload.c b/src/mesa/pipe/i965simple/brw_draw_upload.c index 88d6c9d111..43e53914e9 100644 --- a/src/mesa/pipe/i965simple/brw_draw_upload.c +++ b/src/mesa/pipe/i965simple/brw_draw_upload.c @@ -240,7 +240,7 @@ boolean brw_upload_vertex_buffers( struct brw_context *brw ) for (i = 0; i < nr_enabled; i++) { OUT_BATCH( vbp.vb[i].vb0.dword ); - OUT_RELOC( vbp.vb[i].buffer, PIPE_BUFFER_FLAG_READ, + OUT_RELOC( vbp.vb[i].buffer, PIPE_BUFFER_USAGE_GPU_READ, vbp.vb[i].offset); OUT_BATCH( vbp.vb[i].max_index ); OUT_BATCH( vbp.vb[i].instance_data_step_rate ); @@ -290,8 +290,8 @@ boolean brw_upload_indices( struct brw_context *brw, BEGIN_BATCH(4, 0); OUT_BATCH( ib.header.dword ); - OUT_RELOC( index_buffer, PIPE_BUFFER_FLAG_READ, start); - OUT_RELOC( index_buffer, PIPE_BUFFER_FLAG_READ, start + count); + OUT_RELOC( index_buffer, PIPE_BUFFER_USAGE_GPU_READ, start); + OUT_RELOC( index_buffer, PIPE_BUFFER_USAGE_GPU_READ, start + count); OUT_BATCH( 0 ); ADVANCE_BATCH(); } diff --git a/src/mesa/pipe/i965simple/brw_misc_state.c b/src/mesa/pipe/i965simple/brw_misc_state.c index 3b7f36dd1d..925049ecc1 100644 --- a/src/mesa/pipe/i965simple/brw_misc_state.c +++ b/src/mesa/pipe/i965simple/brw_misc_state.c @@ -245,7 +245,7 @@ static void upload_depthbuffer(struct brw_context *brw) // (depth_surface->region->tiled << 27) | (BRW_SURFACE_2D << 29)); OUT_RELOC(depth_surface->buffer, - PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE, 0); + PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE, 0); OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW << 1) | ((depth_surface->pitch - 1) << 6) | ((depth_surface->height - 1) << 19)); @@ -465,10 +465,10 @@ static void upload_state_base_address( struct brw_context *brw ) BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS); OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (6 - 2)); OUT_RELOC(brw->pool[BRW_GS_POOL].buffer, - PIPE_BUFFER_FLAG_READ, + PIPE_BUFFER_USAGE_GPU_READ, 1); /* General state base address */ OUT_RELOC(brw->pool[BRW_SS_POOL].buffer, - PIPE_BUFFER_FLAG_READ, + PIPE_BUFFER_USAGE_GPU_READ, 1); /* Surface state base address */ OUT_BATCH(1); /* Indirect object base address */ OUT_BATCH(1); /* General state upper bound */ diff --git a/src/mesa/pipe/i965simple/brw_state_pool.c b/src/mesa/pipe/i965simple/brw_state_pool.c index 78268ed8f2..2f930be837 100644 --- a/src/mesa/pipe/i965simple/brw_state_pool.c +++ b/src/mesa/pipe/i965simple/brw_state_pool.c @@ -91,13 +91,9 @@ static void brw_init_pool( struct brw_context *brw, pool->brw = brw; pool->buffer = brw->pipe.winsys->buffer_create(brw->pipe.winsys, - 4096, 0, 0); - - brw->pipe.winsys->buffer_data(brw->pipe.winsys, - pool->buffer, - size, - NULL, - 0 /* DRM_BO_FLAG_MEM_TT */); + 4096, + 0 /* DRM_BO_FLAG_MEM_TT */, + size); } static void brw_destroy_pool( struct brw_context *brw, diff --git a/src/mesa/pipe/i965simple/brw_tex_layout.c b/src/mesa/pipe/i965simple/brw_tex_layout.c index 2b2bf16f1b..eadacbf09e 100644 --- a/src/mesa/pipe/i965simple/brw_tex_layout.c +++ b/src/mesa/pipe/i965simple/brw_tex_layout.c @@ -308,15 +308,11 @@ brw_texture_create(struct pipe_context *pipe, struct pipe_texture **pt) memset(&tex->base + 1, 0, sizeof(struct brw_texture) - sizeof(struct pipe_texture)); - if (brw_miptree_layout(pipe, tex)) { - tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64, 0, 0); - - if (tex->buffer) - pipe->winsys->buffer_data(pipe->winsys, tex->buffer, - tex->pitch * tex->base.cpp * - tex->total_height, NULL, - PIPE_BUFFER_USAGE_PIXEL); - } + if (brw_miptree_layout(pipe, tex)) + tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64, + PIPE_BUFFER_USAGE_PIXEL, + tex->pitch * tex->base.cpp * + tex->total_height); if (!tex->buffer) { FREE(tex); diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index 50bea691e7..90eebd5e6c 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -177,26 +177,20 @@ enum pipe_texture_target { #define PIPE_SURFACE_STATUS_CLEAR 2 -/** - * Buffer access flags - */ -#define PIPE_BUFFER_FLAG_READ 0x1 -#define PIPE_BUFFER_FLAG_WRITE 0x2 -#define PIPE_BUFFER_FLAG_MEM_LOCAL 0x4 -#define PIPE_BUFFER_FLAG_CACHED 0x8 -#define PIPE_BUFFER_FLAG_CUSTOM (1<<16) - - - /** * Buffer usage flags */ -#define PIPE_BUFFER_USAGE_PIXEL (1 << 0) -#define PIPE_BUFFER_USAGE_VERTEX (1 << 1) -#define PIPE_BUFFER_USAGE_INDEX (1 << 2) -#define PIPE_BUFFER_USAGE_CONSTANT (1 << 3) +#define PIPE_BUFFER_USAGE_CPU_READ (1 << 0) +#define PIPE_BUFFER_USAGE_CPU_WRITE (1 << 1) +#define PIPE_BUFFER_USAGE_GPU_READ (1 << 2) +#define PIPE_BUFFER_USAGE_GPU_WRITE (1 << 3) +#define PIPE_BUFFER_USAGE_PIXEL (1 << 4) +#define PIPE_BUFFER_USAGE_VERTEX (1 << 5) +#define PIPE_BUFFER_USAGE_INDEX (1 << 6) +#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7) /** Pipe driver custam usage flags should be greater or equal to this value */ -#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16) +#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16) + /** * Flush types: diff --git a/src/mesa/pipe/p_inlines.h b/src/mesa/pipe/p_inlines.h index 6976d087f9..8ee0820f92 100644 --- a/src/mesa/pipe/p_inlines.h +++ b/src/mesa/pipe/p_inlines.h @@ -37,8 +37,8 @@ static INLINE void * pipe_surface_map(struct pipe_surface *surface) { return (char *)surface->winsys->buffer_map( surface->winsys, surface->buffer, - PIPE_BUFFER_FLAG_WRITE | - PIPE_BUFFER_FLAG_READ ) + PIPE_BUFFER_USAGE_CPU_WRITE | + PIPE_BUFFER_USAGE_CPU_READ ) + surface->offset; } diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index 75c6dc7e85..9742f59a4d 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -1,4 +1,4 @@ -/************************************************************************** + /************************************************************************** * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. @@ -93,17 +93,20 @@ struct pipe_winsys /** - * The buffer manager is modeled after the dri_bufmgr interface, which - * in turn is modeled after the ARB_vertex_buffer_object extension, - * but this is the subset that gallium cares about. Remember that - * gallium gets to choose the interface it needs, and the window - * systems must then implement that interface (rather than the + * Buffer management. Buffer attributes are mostly fixed over its lifetime. + * + * Remember that gallium gets to choose the interface it needs, and the + * window systems must then implement that interface (rather than the * other way around...). + * + * 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. */ struct pipe_buffer_handle *(*buffer_create)( struct pipe_winsys *sws, unsigned alignment, - unsigned flags, - unsigned hint ); + unsigned usage, + unsigned size ); /** Create a buffer that wraps user-space data */ struct pipe_buffer_handle *(*user_buffer_create)(struct pipe_winsys *sws, @@ -116,7 +119,7 @@ struct pipe_winsys */ void *(*buffer_map)( struct pipe_winsys *sws, struct pipe_buffer_handle *buf, - unsigned flags ); + unsigned usage ); void (*buffer_unmap)( struct pipe_winsys *sws, struct pipe_buffer_handle *buf ); @@ -126,44 +129,8 @@ struct pipe_winsys struct pipe_buffer_handle **ptr, struct pipe_buffer_handle *buf ); - /** - * 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. - * - * Returns zero on success. - */ - int (*buffer_data)(struct pipe_winsys *sws, - struct pipe_buffer_handle *buf, - unsigned size, const void *data, - unsigned usage); - /** - * Modify some or all of the data contained in a buffer's data store. - * - * Returns zero on success. - */ - int (*buffer_subdata)(struct pipe_winsys *sws, - struct pipe_buffer_handle *buf, - unsigned long offset, - unsigned long size, - const void *data); - - /** - * Query some or all of the data contained in a buffer's data store. - * - * Returns zero on success. - */ - int (*buffer_get_subdata)(struct pipe_winsys *sws, - struct pipe_buffer_handle *buf, - unsigned long offset, - unsigned long size, - void *data); - - - /** Set ptr = buf, with reference counting */ + /** Set ptr = fence, with reference counting */ void (*fence_reference)( struct pipe_winsys *sws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence ); diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c b/src/mesa/pipe/pipebuffer/pb_buffer_handle.c index 5a5eaee7ac..9aeff976f3 100644 --- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c +++ b/src/mesa/pipe/pipebuffer/pb_buffer_handle.c @@ -46,8 +46,8 @@ static struct pipe_buffer_handle * buffer_handle_create(struct pipe_winsys *winsys, unsigned alignment, - unsigned flags, - unsigned hint) + unsigned usage, + unsigned size) { struct pipe_buffer_handle *handle; @@ -57,8 +57,8 @@ buffer_handle_create(struct pipe_winsys *winsys, handle->refcount = 1; handle->alignment = alignment; - handle->flags = flags; - handle->hint = hint; + handle->usage = usage; + handle->size = size; handle->buf = &null_buffer; @@ -73,7 +73,7 @@ buffer_handle_create_user(struct pipe_winsys *winsys, struct pipe_buffer_handle *handle; struct pipe_buffer *buf; - handle = buffer_handle_create(winsys, 1, 0, 0); + handle = buffer_handle_create(winsys, 1, 0, size); if(!handle) return NULL; @@ -129,46 +129,6 @@ buffer_handle_reference(struct pipe_winsys *winsys, } -static int -buffer_handle_subdata(struct pipe_winsys *winsys, - struct pipe_buffer_handle *handle, - unsigned long offset, - unsigned long size, - const void *data) -{ - void *map; - assert(handle); - assert(data); - map = buffer_handle_map(winsys, handle, PIPE_BUFFER_FLAG_WRITE); - if(map) { - memcpy((char *)map + offset, data, size); - buffer_handle_unmap(winsys, handle); - return 0; - } - return -1; -} - - -static int -buffer_handle_get_subdata(struct pipe_winsys *winsys, - struct pipe_buffer_handle *handle, - unsigned long offset, - unsigned long size, - void *data) -{ - void *map; - assert(handle); - assert(data); - map = buffer_handle_map(winsys, handle, PIPE_BUFFER_FLAG_READ); - if(map) { - memcpy(data, (char *)map + offset, size); - buffer_handle_unmap(winsys, handle); - return 0; - } - return -1; -} - - void buffer_handle_init_winsys(struct pipe_winsys *winsys) { @@ -177,6 +137,4 @@ buffer_handle_init_winsys(struct pipe_winsys *winsys) winsys->buffer_map = buffer_handle_map; winsys->buffer_unmap = buffer_handle_unmap; winsys->buffer_reference = buffer_handle_reference; - winsys->buffer_subdata = buffer_handle_subdata; - winsys->buffer_get_subdata = buffer_handle_get_subdata; } diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h b/src/mesa/pipe/pipebuffer/pb_buffer_handle.h index 076eec2fdc..34133c9fba 100644 --- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h +++ b/src/mesa/pipe/pipebuffer/pb_buffer_handle.h @@ -55,8 +55,8 @@ struct pipe_buffer_handle /** Allocation characteristics */ unsigned alignment; - unsigned flags; - unsigned hint; + unsigned usage; + unsigned size; /** * The actual buffer. diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c index e9bc34b4a4..d174f24e32 100644 --- a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c +++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c @@ -241,7 +241,8 @@ mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer, mm->buffer = buffer; mm->map = buffer_map(mm->buffer, - PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE ); + PIPE_BUFFER_USAGE_CPU_READ | + PIPE_BUFFER_USAGE_CPU_WRITE); if(!mm->map) goto failure; diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c index ee6fa62500..e6a8c78668 100644 --- a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c +++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c @@ -246,8 +246,8 @@ pool_bufmgr_create(struct buffer_manager *provider, goto failure; pool->map = buffer_map(pool->buffer, - PIPE_BUFFER_FLAG_READ | - PIPE_BUFFER_FLAG_WRITE ); + PIPE_BUFFER_USAGE_CPU_READ | + PIPE_BUFFER_USAGE_CPU_WRITE); if(!pool->map) goto failure; diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c index b7626f8a5f..8ee9177e5b 100644 --- a/src/mesa/pipe/softpipe/sp_draw_arrays.c +++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c @@ -50,7 +50,7 @@ softpipe_map_constant_buffers(struct softpipe_context *sp) for (i = 0; i < 2; i++) { if (sp->constants[i].size) sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer, - PIPE_BUFFER_FLAG_READ); + PIPE_BUFFER_USAGE_CPU_READ); } draw_set_mapped_constant_buffer(sp->draw, @@ -122,7 +122,7 @@ softpipe_draw_elements(struct pipe_context *pipe, void *buf = pipe->winsys->buffer_map(pipe->winsys, sp->vertex_buffer[i].buffer, - PIPE_BUFFER_FLAG_READ); + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } } @@ -130,7 +130,7 @@ softpipe_draw_elements(struct pipe_context *pipe, if (indexBuffer) { void *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, - PIPE_BUFFER_FLAG_READ); + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c index d43a6996e9..23e9c1b376 100644 --- a/src/mesa/pipe/softpipe/sp_texture.c +++ b/src/mesa/pipe/softpipe/sp_texture.c @@ -91,12 +91,9 @@ softpipe_texture_create(struct pipe_context *pipe, struct pipe_texture **pt) softpipe_texture_layout(spt); - spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32, 0, 0); - - if (spt->buffer) { - pipe->winsys->buffer_data(pipe->winsys, spt->buffer, spt->buffer_size, - NULL, PIPE_BUFFER_USAGE_PIXEL); - } + spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32, + PIPE_BUFFER_USAGE_PIXEL, + spt->buffer_size); if (!spt->buffer) { FREE(spt); diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c index 432431aca1..cb043ef394 100644 --- a/src/mesa/pipe/xlib/xm_winsys.c +++ b/src/mesa/pipe/xlib/xm_winsys.c @@ -165,48 +165,6 @@ xm_buffer_reference(struct pipe_winsys *pws, } } -static int -xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, - unsigned size, const void *data, unsigned usage ) -{ - struct xm_buffer *xm_buf = xm_bo(buf); - assert(!xm_buf->userBuffer); - if (xm_buf->size != size) { - if (xm_buf->data) - align_free(xm_buf->data); - /* align to 16-byte multiple for Cell */ - xm_buf->data = align_malloc(size, 16); - xm_buf->size = size; - } - if (data) - memcpy(xm_buf->data, data, size); - return 0; -} - -static int -xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, - unsigned long offset, unsigned long size, const void *data) -{ - struct xm_buffer *xm_buf = xm_bo(buf); - GLubyte *b = (GLubyte *) xm_buf->data; - assert(!xm_buf->userBuffer); - assert(b); - memcpy(b + offset, data, size); - return 0; -} - -static int -xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, - unsigned long offset, unsigned long size, void *data) -{ - const struct xm_buffer *xm_buf = xm_bo(buf); - const GLubyte *b = (GLubyte *) xm_buf->data; - assert(!xm_buf->userBuffer); - assert(b); - memcpy(data, b + offset, size); - return 0; -} - /** * Display a surface that's in a tiled configuration. That is, all the @@ -317,11 +275,16 @@ xm_get_name(struct pipe_winsys *pws) static struct pipe_buffer_handle * xm_buffer_create(struct pipe_winsys *pws, unsigned alignment, - unsigned flags, - unsigned hints) + unsigned usage, + unsigned size) { struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); buffer->refcount = 1; + + /* align to 16-byte multiple for Cell */ + buffer->data = align_malloc(size, max(alignment, 16)); + buffer->size = size; + return pipe_bo(buffer); } @@ -359,7 +322,6 @@ xm_surface_alloc_storage(struct pipe_winsys *winsys, unsigned flags) { const unsigned alignment = 64; - int ret; surf->width = width; surf->height = height; @@ -372,19 +334,11 @@ xm_surface_alloc_storage(struct pipe_winsys *winsys, #endif assert(!surf->buffer); - surf->buffer = winsys->buffer_create(winsys, alignment, 0, 0); + surf->buffer = winsys->buffer_create(winsys, alignment, + PIPE_BUFFER_USAGE_PIXEL, + surf->pitch * surf->cpp * height); if(!surf->buffer) return -1; - - ret = winsys->buffer_data(winsys, - surf->buffer, - surf->pitch * surf->cpp * height, - NULL, - 0); - if(ret) { - winsys->buffer_reference(winsys, &surf->buffer, NULL); - return ret; - } return 0; } @@ -454,9 +408,6 @@ xmesa_get_pipe_winsys_aub(void) ws->buffer_map = xm_buffer_map; ws->buffer_unmap = xm_buffer_unmap; ws->buffer_reference = xm_buffer_reference; - ws->buffer_data = xm_buffer_data; - ws->buffer_subdata = xm_buffer_subdata; - ws->buffer_get_subdata = xm_buffer_get_subdata; ws->surface_alloc = xm_surface_alloc; ws->surface_alloc_storage = xm_surface_alloc_storage; diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.c b/src/mesa/pipe/xlib/xm_winsys_aub.c index 980c0be540..28dd07bc6e 100644 --- a/src/mesa/pipe/xlib/xm_winsys_aub.c +++ b/src/mesa/pipe/xlib/xm_winsys_aub.c @@ -101,7 +101,7 @@ static void *aub_buffer_map(struct pipe_winsys *winsys, assert(sbo->data); - if (flags & PIPE_BUFFER_FLAG_WRITE) + if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) sbo->dump_on_unmap = 1; sbo->map_count++; @@ -150,61 +150,6 @@ aub_buffer_reference(struct pipe_winsys *winsys, } -static int aub_buffer_data(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, - unsigned size, const void *data, - unsigned usage ) -{ - struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys); - struct aub_buffer *sbo = aub_bo(buf); - - /* Could reuse buffers that are not referenced in current - * batchbuffer. Can't do that atm, so always reallocate: - */ - if (1 || sbo->size < size) { - assert(iws->used + size < iws->size); - sbo->data = iws->pool + iws->used; - sbo->offset = AUB_BUF_START + iws->used; - iws->used += align(size, 4096); - } - - sbo->size = size; - - if (data != NULL) { - memcpy(sbo->data, data, size); - - brw_aub_gtt_data( iws->aubfile, - sbo->offset, - sbo->data, - sbo->size, - 0, - 0 ); - } - return 0; -} - -static int aub_buffer_subdata(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, - unsigned long offset, - unsigned long size, - const void *data) -{ - struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys); - struct aub_buffer *sbo = aub_bo(buf); - - assert(sbo->size > offset + size); - memcpy(sbo->data + offset, data, size); - - brw_aub_gtt_data( iws->aubfile, - sbo->offset + offset, - sbo->data + offset, - size, - 0, - 0 ); - return 0; -} - - void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys, struct pipe_buffer_handle *buf, unsigned long offset, @@ -258,29 +203,30 @@ void xmesa_display_aub( /* struct pipe_winsys *winsys, */ -static int aub_buffer_get_subdata(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, - unsigned long offset, - unsigned long size, - void *data) -{ - struct aub_buffer *sbo = aub_bo(buf); - assert(sbo->size >= offset + size); - memcpy(data, sbo->data + offset, size); - return 0; -} - /* Pipe has no concept of pools. We choose the tex/region pool * for all buffers. */ static struct pipe_buffer_handle * aub_buffer_create(struct pipe_winsys *winsys, - unsigned alignment, - unsigned flags, - unsigned hint) + unsigned alignment, + unsigned usage, + unsigned size) { + struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys); struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer); + sbo->refcount = 1; + + /* Could reuse buffers that are not referenced in current + * batchbuffer. Can't do that atm, so always reallocate: + */ + assert(iws->used + size < iws->size); + sbo->data = iws->pool + iws->used; + sbo->offset = AUB_BUF_START + iws->used; + iws->used += align(size, 4096); + + sbo->size = size; + return pipe_bo(sbo); } @@ -288,17 +234,14 @@ aub_buffer_create(struct pipe_winsys *winsys, static struct pipe_buffer_handle * aub_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes) { - struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer); - - sbo->refcount = 1; + struct aub_buffer *sbo; /* Lets hope this is meant for upload, not as a result! */ - aub_buffer_data( winsys, - pipe_bo(sbo), - bytes, - ptr, - 0 ); + sbo = aub_bo(aub_buffer_create( winsys, 0, 0, 0 )); + + sbo->data = ptr; + sbo->size = bytes; return pipe_bo(sbo); } @@ -345,7 +288,6 @@ aub_i915_surface_alloc_storage(struct pipe_winsys *winsys, unsigned flags) { const unsigned alignment = 64; - int ret; surf->width = width; surf->height = height; @@ -354,20 +296,12 @@ aub_i915_surface_alloc_storage(struct pipe_winsys *winsys, surf->pitch = round_up(width, alignment / surf->cpp); assert(!surf->buffer); - surf->buffer = winsys->buffer_create(winsys, alignment, 0, 0); + surf->buffer = winsys->buffer_create(winsys, alignment, + PIPE_BUFFER_USAGE_PIXEL, + surf->pitch * surf->cpp * height); if(!surf->buffer) return -1; - ret = winsys->buffer_data(winsys, - surf->buffer, - surf->pitch * surf->cpp * height, - NULL, - 0); - if(ret) { - winsys->buffer_reference(winsys, &surf->buffer, NULL); - return ret; - } - return 0; } @@ -418,9 +352,6 @@ xmesa_create_pipe_winsys_aub( void ) iws->winsys.buffer_map = aub_buffer_map; iws->winsys.buffer_unmap = aub_buffer_unmap; iws->winsys.buffer_reference = aub_buffer_reference; - iws->winsys.buffer_data = aub_buffer_data; - iws->winsys.buffer_subdata = aub_buffer_subdata; - iws->winsys.buffer_get_subdata = aub_buffer_get_subdata; iws->winsys.flush_frontbuffer = aub_flush_frontbuffer; iws->winsys.printf = aub_printf; iws->winsys.get_name = aub_get_name; diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 57f5ec68d2..c9d63136b5 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -69,8 +69,13 @@ void st_upload_constants( struct st_context *st, _mesa_load_state_parameters(st->ctx, params); - if (!cbuf->buffer) - cbuf->buffer = ws->buffer_create(ws, 1, 0, 0); + if (cbuf->buffer && cbuf->size != paramBytes) + ws->buffer_reference( ws, &cbuf->buffer, NULL ); + + if (!cbuf->buffer) { + cbuf->buffer = ws->buffer_create(ws, 1, PIPE_BUFFER_USAGE_CONSTANT, + paramBytes); + } if (0) { @@ -80,8 +85,11 @@ void st_upload_constants( struct st_context *st, } /* load Mesa constants into the constant buffer */ - ws->buffer_data(ws, cbuf->buffer, paramBytes, params->ParameterValues, - PIPE_BUFFER_USAGE_CONSTANT); + if (cbuf->buffer) { + memcpy(ws->buffer_map(ws, cbuf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE), + params->ParameterValues, paramBytes); + ws->buffer_unmap(ws, cbuf->buffer); + } cbuf->size = paramBytes; diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 872248cdb5..60bd1d5f0d 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -55,7 +55,6 @@ static struct gl_buffer_object * st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target) { - struct st_context *st = st_context(ctx); struct st_buffer_object *st_obj = CALLOC_STRUCT(st_buffer_object); if (!st_obj) @@ -63,8 +62,6 @@ st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target) _mesa_initialize_buffer_object(&st_obj->Base, name, target); - st_obj->buffer = st->pipe->winsys->buffer_create( st->pipe->winsys, 32, 0, 0 ); - return &st_obj->Base; } @@ -88,6 +85,57 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj) +/** + * Replace data in a subrange of buffer object. If the data range + * specified by size + offset extends beyond the end of the buffer or + * if data is NULL, no copy is performed. + * Called via glBufferSubDataARB(). + */ +static void +st_bufferobj_subdata(GLcontext *ctx, + GLenum target, + GLintptrARB offset, + GLsizeiptrARB size, + const GLvoid * data, struct gl_buffer_object *obj) +{ + struct pipe_context *pipe = st_context(ctx)->pipe; + struct st_buffer_object *st_obj = st_buffer_object(obj); + char *map; + + if (offset >= st_obj->size || size > (st_obj->size - offset)) + return; + + map = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer, + PIPE_BUFFER_USAGE_CPU_WRITE); + memcpy(map + offset, data, size); + pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer); +} + + +/** + * Called via glGetBufferSubDataARB(). + */ +static void +st_bufferobj_get_subdata(GLcontext *ctx, + GLenum target, + GLintptrARB offset, + GLsizeiptrARB size, + GLvoid * data, struct gl_buffer_object *obj) +{ + struct pipe_context *pipe = st_context(ctx)->pipe; + struct st_buffer_object *st_obj = st_buffer_object(obj); + char *map; + + if (offset >= st_obj->size || size > (st_obj->size - offset)) + return; + + map = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer, + PIPE_BUFFER_USAGE_CPU_READ); + memcpy(data, map + offset, size); + pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer); +} + + /** * Allocate space for and store data in a buffer object. Any data that was * previously stored in the buffer object is lost. If data is NULL, @@ -102,7 +150,8 @@ st_bufferobj_data(GLcontext *ctx, GLenum usage, struct gl_buffer_object *obj) { - struct pipe_context *pipe = st_context(ctx)->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct st_buffer_object *st_obj = st_buffer_object(obj); unsigned buffer_usage; @@ -124,46 +173,15 @@ st_bufferobj_data(GLcontext *ctx, buffer_usage = 0; } - pipe->winsys->buffer_data( pipe->winsys, st_obj->buffer, - size, data, - buffer_usage ); -} + pipe->winsys->buffer_reference( pipe->winsys, &st_obj->buffer, NULL ); + st_obj->buffer = pipe->winsys->buffer_create( pipe->winsys, 32, buffer_usage, + size ); -/** - * Replace data in a subrange of buffer object. If the data range - * specified by size + offset extends beyond the end of the buffer or - * if data is NULL, no copy is performed. - * Called via glBufferSubDataARB(). - */ -static void -st_bufferobj_subdata(GLcontext *ctx, - GLenum target, - GLintptrARB offset, - GLsizeiptrARB size, - const GLvoid * data, struct gl_buffer_object *obj) -{ - struct pipe_context *pipe = st_context(ctx)->pipe; - struct st_buffer_object *st_obj = st_buffer_object(obj); - - pipe->winsys->buffer_subdata(pipe->winsys, st_obj->buffer, offset, size, data); -} - - -/** - * Called via glGetBufferSubDataARB(). - */ -static void -st_bufferobj_get_subdata(GLcontext *ctx, - GLenum target, - GLintptrARB offset, - GLsizeiptrARB size, - GLvoid * data, struct gl_buffer_object *obj) -{ - struct pipe_context *pipe = st_context(ctx)->pipe; - struct st_buffer_object *st_obj = st_buffer_object(obj); + st_obj->size = size; - pipe->winsys->buffer_get_subdata(pipe->winsys, st_obj->buffer, offset, size, data); + if (data) + st_bufferobj_subdata(ctx, target, 0, size, data, obj); } @@ -180,15 +198,15 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access, switch (access) { case GL_WRITE_ONLY: - flags = PIPE_BUFFER_FLAG_WRITE; + flags = PIPE_BUFFER_USAGE_CPU_WRITE; break; case GL_READ_ONLY: - flags = PIPE_BUFFER_FLAG_READ; + flags = PIPE_BUFFER_USAGE_CPU_READ; break; case GL_READ_WRITE: /* fall-through */ default: - flags = PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE; + flags = PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE; break; } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h b/src/mesa/state_tracker/st_cb_bufferobjects.h index 2090a743e0..15003ae15d 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.h +++ b/src/mesa/state_tracker/st_cb_bufferobjects.h @@ -40,6 +40,7 @@ struct st_buffer_object { struct gl_buffer_object Base; struct pipe_buffer_handle *buffer; + GLsizeiptrARB size; }; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 5ae21c93f9..2b6f8743f3 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -164,13 +164,6 @@ struct st_context struct st_fragment_program *combined_prog; } bitmap; - /** - * Buffer object which stores the ctx->Current.Attrib[] values. - * Used for vertex array drawing when we we need an attribute for - * which there's no enabled array. - */ - struct pipe_buffer_handle *default_attrib_buffer; - struct cso_cache *cache; }; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 71acf6e862..371d4e7966 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -190,29 +190,6 @@ pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized) } -/** - * The default attribute buffer is basically a copy of the - * ctx->Current.Attrib[] array. It's used when the vertex program - * references an attribute for which we don't have a VBO/array. - */ -static void -create_default_attribs_buffer(struct st_context *st) -{ - struct pipe_context *pipe = st->pipe; - /* XXX don't hardcode magic 32 here */ - st->default_attrib_buffer = pipe->winsys->buffer_create( pipe->winsys, 32, 0, 0 ); -} - - -static void -destroy_default_attribs_buffer(struct st_context *st) -{ - struct pipe_context *pipe = st->pipe; - pipe->winsys->buffer_reference(pipe->winsys, - &st->default_attrib_buffer, NULL); -} - - /** * This function gets plugged into the VBO module and is called when * we have something to render. @@ -399,10 +376,14 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, } /* XXX create one-time */ - vbuf = pipe->winsys->buffer_create(pipe->winsys, 32, 0, 0); - pipe->winsys->buffer_data(pipe->winsys, vbuf, - vertex_bytes, verts, - PIPE_BUFFER_USAGE_VERTEX); + vbuf = pipe->winsys->buffer_create(pipe->winsys, 32, + PIPE_BUFFER_USAGE_VERTEX, vertex_bytes); + assert(vbuf); + + memcpy(pipe->winsys->buffer_map(pipe->winsys, vbuf, + PIPE_BUFFER_USAGE_CPU_WRITE), + verts, vertex_bytes); + pipe->winsys->buffer_unmap(pipe->winsys, vbuf); /* tell pipe about the vertex buffer */ vbuffer.buffer = vbuf; @@ -568,7 +549,7 @@ st_feedback_draw_vbo(GLcontext *ctx, /* map the attrib buffer */ map = pipe->winsys->buffer_map(pipe->winsys, vbuffer[attr].buffer, - PIPE_BUFFER_FLAG_READ); + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, attr, map); } @@ -592,7 +573,7 @@ st_feedback_draw_vbo(GLcontext *ctx, map = pipe->winsys->buffer_map(pipe->winsys, index_buffer_handle, - PIPE_BUFFER_FLAG_READ); + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, map); } else { @@ -604,7 +585,7 @@ st_feedback_draw_vbo(GLcontext *ctx, /* map constant buffers */ mapped_constants = winsys->buffer_map(winsys, st->state.constants[PIPE_SHADER_VERTEX].buffer, - PIPE_BUFFER_FLAG_READ); + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_constant_buffer(st->draw, mapped_constants); @@ -640,16 +621,12 @@ void st_init_draw( struct st_context *st ) { GLcontext *ctx = st->ctx; - /* actually, not used here, but elsewhere */ - create_default_attribs_buffer(st); - vbo_set_draw_func(ctx, st_draw_vbo); } void st_destroy_draw( struct st_context *st ) { - destroy_default_attribs_buffer(st); } -- cgit v1.2.3 From 1e0d30a515e4cac891b6c590f12a33e0e8a8e295 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 25 Jan 2008 20:53:31 +0000 Subject: gallium: rename pipe_buffer_handle to pipe_buffer, rework pipebuffer/ code Provide an actual definition of the pipe_buffer struct, containing the parameters used to create the buffer, and its refcount. Shift refcounting buffers out of the winsys interface, similar to surfaces & textures. Rework pipebuffer/ to reflect the fact these changes, and also Michel's reworking of the buffer interface. --- src/mesa/drivers/dri/intel_winsys/intel_winsys.h | 23 ++-- .../drivers/dri/intel_winsys/intel_winsys_i915.c | 2 +- .../drivers/dri/intel_winsys/intel_winsys_pipe.c | 53 ++++---- src/mesa/drivers/x11/xm_winsys.c | 24 ++-- src/mesa/pipe/cell/ppu/cell_draw_arrays.c | 2 +- src/mesa/pipe/cell/ppu/cell_draw_arrays.h | 2 +- src/mesa/pipe/cell/ppu/cell_texture.h | 2 +- src/mesa/pipe/failover/fo_context.c | 2 +- src/mesa/pipe/i915simple/i915_blit.c | 6 +- src/mesa/pipe/i915simple/i915_blit.h | 6 +- src/mesa/pipe/i915simple/i915_context.c | 2 +- src/mesa/pipe/i915simple/i915_context.h | 4 +- src/mesa/pipe/i915simple/i915_prim_vbuf.c | 3 +- src/mesa/pipe/i915simple/i915_state_emit.c | 2 +- src/mesa/pipe/i915simple/i915_surface.c | 2 +- src/mesa/pipe/i915simple/i915_texture.c | 2 +- src/mesa/pipe/i915simple/i915_winsys.h | 4 +- src/mesa/pipe/i965simple/brw_blit.c | 6 +- src/mesa/pipe/i965simple/brw_blit.h | 8 +- src/mesa/pipe/i965simple/brw_context.h | 6 +- src/mesa/pipe/i965simple/brw_draw.c | 4 +- src/mesa/pipe/i965simple/brw_draw.h | 2 +- src/mesa/pipe/i965simple/brw_draw_upload.c | 4 +- src/mesa/pipe/i965simple/brw_state.h | 2 +- src/mesa/pipe/i965simple/brw_state_pool.c | 7 +- src/mesa/pipe/i965simple/brw_surface.c | 2 +- src/mesa/pipe/i965simple/brw_tex_layout.c | 3 +- src/mesa/pipe/i965simple/brw_winsys.h | 8 +- src/mesa/pipe/i965simple/brw_wm_surface_state.c | 2 +- src/mesa/pipe/p_context.h | 2 +- src/mesa/pipe/p_inlines.h | 43 +++++-- src/mesa/pipe/p_state.h | 23 +++- src/mesa/pipe/p_winsys.h | 17 +-- src/mesa/pipe/pipebuffer/Makefile | 2 - src/mesa/pipe/pipebuffer/pb_buffer.c | 49 ++++++-- src/mesa/pipe/pipebuffer/pb_buffer.h | 111 ++++++++-------- src/mesa/pipe/pipebuffer/pb_buffer_client.c | 60 ++++----- src/mesa/pipe/pipebuffer/pb_buffer_fenced.c | 102 ++++++--------- src/mesa/pipe/pipebuffer/pb_buffer_fenced.h | 10 +- src/mesa/pipe/pipebuffer/pb_buffer_handle.c | 140 --------------------- src/mesa/pipe/pipebuffer/pb_buffer_handle.h | 120 ------------------ src/mesa/pipe/pipebuffer/pb_buffer_malloc.c | 41 +++--- src/mesa/pipe/pipebuffer/pb_buffer_null.c | 98 --------------- src/mesa/pipe/pipebuffer/pb_bufmgr.h | 24 ++-- src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c | 36 +++--- src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c | 88 ++++++------- src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c | 75 +++++------ src/mesa/pipe/softpipe/sp_context.c | 2 +- src/mesa/pipe/softpipe/sp_draw_arrays.c | 2 +- src/mesa/pipe/softpipe/sp_state.h | 2 +- src/mesa/pipe/softpipe/sp_state_fs.c | 7 +- src/mesa/pipe/softpipe/sp_texture.c | 4 +- src/mesa/pipe/softpipe/sp_texture.h | 2 +- src/mesa/pipe/xlib/xm_winsys.c | 80 +++++------- src/mesa/pipe/xlib/xm_winsys_aub.c | 44 +++---- src/mesa/pipe/xlib/xm_winsys_aub.h | 4 +- src/mesa/state_tracker/st_atom_constbuf.c | 3 +- src/mesa/state_tracker/st_cb_bufferobjects.c | 5 +- src/mesa/state_tracker/st_cb_bufferobjects.h | 4 +- src/mesa/state_tracker/st_cb_fbo.c | 4 +- src/mesa/state_tracker/st_context.c | 3 +- src/mesa/state_tracker/st_draw.c | 21 ++-- 62 files changed, 529 insertions(+), 894 deletions(-) delete mode 100644 src/mesa/pipe/pipebuffer/pb_buffer_handle.c delete mode 100644 src/mesa/pipe/pipebuffer/pb_buffer_handle.h delete mode 100644 src/mesa/pipe/pipebuffer/pb_buffer_null.c (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h index 89e63e0a79..ffc40782be 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h @@ -28,10 +28,12 @@ #ifndef INTEL_WINSYS_H #define INTEL_WINSYS_H +#include "pipe/p_state.h" + struct intel_context; struct pipe_context; struct pipe_winsys; -struct pipe_buffer_handle; +struct pipe_buffer; struct _DriBufferObject; struct pipe_winsys * @@ -49,20 +51,21 @@ intel_create_i915simple( struct intel_context *intel, struct pipe_winsys *winsys ); +struct intel_buffer { + struct pipe_buffer base; + struct _DriBufferObject *driBO; +}; -/* Turn the pipe opaque buffer pointer into a dri_bufmgr opaque - * buffer pointer... - */ -static INLINE struct _DriBufferObject * -dri_bo( struct pipe_buffer_handle *bo ) +static INLINE struct intel_buffer * +intel_buffer( struct pipe_buffer *buf ) { - return (struct _DriBufferObject *)bo; + return (struct intel_buffer *)buf; } -static INLINE struct pipe_buffer_handle * -pipe_bo( struct _DriBufferObject *bo ) +static INLINE struct _DriBufferObject * +dri_bo( struct pipe_buffer *buf ) { - return (struct pipe_buffer_handle *)bo; + return intel_buffer(buf)->driBO; } diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c index 8e0eea4392..1ba6a9e1b2 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c @@ -85,7 +85,7 @@ static void intel_i915_batch_dword( struct i915_winsys *sws, } static void intel_i915_batch_reloc( struct i915_winsys *sws, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned access_flags, unsigned delta ) { 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 43ed0602a4..910c0d2cc5 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c @@ -43,6 +43,7 @@ #include "pipe/p_defines.h" #include "pipe/p_state.h" #include "pipe/p_util.h" +#include "pipe/p_inlines.h" @@ -65,7 +66,7 @@ intel_pipe_winsys( struct pipe_winsys *winsys ) /* Most callbacks map direcly onto dri_bufmgr operations: */ static void *intel_buffer_map(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned flags ) { unsigned drm_flags = 0; @@ -80,26 +81,17 @@ static void *intel_buffer_map(struct pipe_winsys *winsys, } static void intel_buffer_unmap(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf) + struct pipe_buffer *buf) { driBOUnmap( dri_bo(buf) ); } static void -intel_buffer_reference(struct pipe_winsys *winsys, - struct pipe_buffer_handle **ptr, - struct pipe_buffer_handle *buf) +intel_buffer_destroy(struct pipe_winsys *winsys, + struct pipe_buffer *buf) { - if (*ptr) { - driBOUnReference( dri_bo(*ptr) ); - *ptr = NULL; - } - - if (buf) { - driBOReference( dri_bo(buf) ); - *ptr = buf; - } + driBOUnReference( dri_bo(buf) ); } @@ -107,16 +99,21 @@ intel_buffer_reference(struct pipe_winsys *winsys, * for all buffers. * Grabs the hardware lock! */ -static struct pipe_buffer_handle * +static struct pipe_buffer * intel_buffer_create(struct pipe_winsys *winsys, unsigned alignment, unsigned usage, unsigned size ) { - struct _DriBufferObject *buffer; + struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer ); struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys); unsigned flags = 0; + buffer->base.refcount = 1; + buffer->base.alignment = alignment; + buffer->base.usage = usage; + buffer->base.size = size; + if (usage & (PIPE_BUFFER_USAGE_VERTEX /*| IWS_BUFFER_USAGE_LOCAL*/)) { flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED; } else { @@ -143,20 +140,24 @@ intel_buffer_create(struct pipe_winsys *winsys, #endif driGenBuffers( iws->regionPool, - "pipe buffer", 1, &buffer, alignment, flags, 0 ); - driBOData( buffer, size, NULL, 0 ); - return pipe_bo(buffer); + "pipe buffer", 1, &buffer->driBO, alignment, flags, 0 ); + + driBOData( buffer->driBO, size, NULL, 0 ); + + return &buffer->base; } -static struct pipe_buffer_handle * +static struct pipe_buffer * intel_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes) { - struct _DriBufferObject *buffer; + struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer ); struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys); + driGenUserBuffer( iws->regionPool, - "pipe user buffer", &buffer, ptr, bytes); - return pipe_bo(buffer); + "pipe user buffer", &buffer->driBO, ptr, bytes); + + return &buffer->base; } @@ -224,7 +225,7 @@ intel_i915_surface_alloc_storage(struct pipe_winsys *winsys, return -1; if(ret) { - winsys->buffer_reference(winsys, &surf->buffer, NULL); + pipe_buffer_reference(winsys, &surf->buffer, NULL); return ret; } @@ -239,7 +240,7 @@ intel_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s) surf->refcount--; if (surf->refcount == 0) { if (surf->buffer) - winsys->buffer_reference(winsys, &surf->buffer, NULL); + pipe_buffer_reference(winsys, &surf->buffer, NULL); free(surf); } *s = NULL; @@ -279,7 +280,7 @@ intel_create_pipe_winsys( int fd ) iws->winsys.user_buffer_create = intel_user_buffer_create; iws->winsys.buffer_map = intel_buffer_map; iws->winsys.buffer_unmap = intel_buffer_unmap; - iws->winsys.buffer_reference = intel_buffer_reference; + iws->winsys.buffer_destroy = intel_buffer_destroy; iws->winsys.flush_frontbuffer = intel_flush_frontbuffer; iws->winsys.printf = intel_printf; iws->winsys.get_name = intel_get_name; diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c index dafbe96a1e..a690df2772 100644 --- a/src/mesa/drivers/x11/xm_winsys.c +++ b/src/mesa/drivers/x11/xm_winsys.c @@ -71,15 +71,15 @@ struct xm_buffer * buffer pointer... */ static inline struct xm_buffer * -xm_bo( struct pipe_buffer_handle *bo ) +xm_bo( struct pipe_buffer *bo ) { return (struct xm_buffer *) bo; } -static inline struct pipe_buffer_handle * +static inline struct pipe_buffer * pipe_bo( struct xm_buffer *bo ) { - return (struct pipe_buffer_handle *) bo; + return (struct pipe_buffer *) bo; } /* Turn a softpipe winsys into an xm/softpipe winsys: @@ -94,7 +94,7 @@ xm_winsys(struct softpipe_winsys *sws) /* Most callbacks map direcly onto dri_bufmgr operations: */ static void * -xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, +xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) { struct xm_buffer *xm_buf = xm_bo(buf); @@ -103,7 +103,7 @@ xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, } static void -xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf) +xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) { struct xm_buffer *xm_buf = xm_bo(buf); xm_buf->mapped = NULL; @@ -111,8 +111,8 @@ xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf) static void xm_buffer_reference(struct pipe_winsys *pws, - struct pipe_buffer_handle **ptr, - struct pipe_buffer_handle *buf) + struct pipe_buffer **ptr, + struct pipe_buffer *buf) { if (*ptr) { struct xm_buffer *oldBuf = xm_bo(*ptr); @@ -139,7 +139,7 @@ xm_buffer_reference(struct pipe_winsys *pws, } static void -xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, +xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned size, const void *data, unsigned usage) { struct xm_buffer *xm_buf = xm_bo(buf); @@ -155,7 +155,7 @@ xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, } static void -xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, +xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned long offset, unsigned long size, const void *data) { struct xm_buffer *xm_buf = xm_bo(buf); @@ -166,7 +166,7 @@ xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, } static void -xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, +xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned long offset, unsigned long size, void *data) { const struct xm_buffer *xm_buf = xm_bo(buf); @@ -209,7 +209,7 @@ xm_get_name(struct pipe_winsys *pws) } -static struct pipe_buffer_handle * +static struct pipe_buffer * xm_buffer_create(struct pipe_winsys *pws, unsigned alignment, unsigned flags, @@ -224,7 +224,7 @@ xm_buffer_create(struct pipe_winsys *pws, /** * Create buffer which wraps user-space data. */ -static struct pipe_buffer_handle * +static struct pipe_buffer * xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) { struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); diff --git a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c index 537cec8785..8286da712c 100644 --- a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c +++ b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c @@ -89,7 +89,7 @@ cell_draw_arrays(struct pipe_context *pipe, unsigned mode, */ boolean cell_draw_elements(struct pipe_context *pipe, - struct pipe_buffer_handle *indexBuffer, + struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count) { diff --git a/src/mesa/pipe/cell/ppu/cell_draw_arrays.h b/src/mesa/pipe/cell/ppu/cell_draw_arrays.h index bd5b703f3b..d5df4aa05f 100644 --- a/src/mesa/pipe/cell/ppu/cell_draw_arrays.h +++ b/src/mesa/pipe/cell/ppu/cell_draw_arrays.h @@ -33,7 +33,7 @@ boolean cell_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count); boolean cell_draw_elements(struct pipe_context *pipe, - struct pipe_buffer_handle *indexBuffer, + struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count); diff --git a/src/mesa/pipe/cell/ppu/cell_texture.h b/src/mesa/pipe/cell/ppu/cell_texture.h index 97d8bd1230..ef5808c086 100644 --- a/src/mesa/pipe/cell/ppu/cell_texture.h +++ b/src/mesa/pipe/cell/ppu/cell_texture.h @@ -44,7 +44,7 @@ struct cell_texture /* The data is held here: */ - struct pipe_buffer_handle *buffer; + struct pipe_buffer *buffer; unsigned long buffer_size; }; diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c index a1291f583b..3799c4dfb0 100644 --- a/src/mesa/pipe/failover/fo_context.c +++ b/src/mesa/pipe/failover/fo_context.c @@ -46,7 +46,7 @@ static void failover_destroy( struct pipe_context *pipe ) static boolean failover_draw_elements( struct pipe_context *pipe, - struct pipe_buffer_handle *indexBuffer, + struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned prim, unsigned start, unsigned count) { diff --git a/src/mesa/pipe/i915simple/i915_blit.c b/src/mesa/pipe/i915simple/i915_blit.c index 6e95313a0d..d49876f970 100644 --- a/src/mesa/pipe/i915simple/i915_blit.c +++ b/src/mesa/pipe/i915simple/i915_blit.c @@ -38,7 +38,7 @@ void i915_fill_blit(struct i915_context *i915, unsigned cpp, short dst_pitch, - struct pipe_buffer_handle *dst_buffer, + struct pipe_buffer *dst_buffer, unsigned dst_offset, short x, short y, short w, short h, @@ -87,10 +87,10 @@ void i915_copy_blit( struct i915_context *i915, unsigned cpp, short src_pitch, - struct pipe_buffer_handle *src_buffer, + struct pipe_buffer *src_buffer, unsigned src_offset, short dst_pitch, - struct pipe_buffer_handle *dst_buffer, + struct pipe_buffer *dst_buffer, unsigned dst_offset, short src_x, short src_y, short dst_x, short dst_y, diff --git a/src/mesa/pipe/i915simple/i915_blit.h b/src/mesa/pipe/i915simple/i915_blit.h index 7ea4e979ec..d7a66be10a 100644 --- a/src/mesa/pipe/i915simple/i915_blit.h +++ b/src/mesa/pipe/i915simple/i915_blit.h @@ -33,10 +33,10 @@ extern void i915_copy_blit(struct i915_context *i915, unsigned cpp, short src_pitch, - struct pipe_buffer_handle *src_buffer, + struct pipe_buffer *src_buffer, unsigned src_offset, short dst_pitch, - struct pipe_buffer_handle *dst_buffer, + struct pipe_buffer *dst_buffer, unsigned dst_offset, short srcx, short srcy, short dstx, short dsty, @@ -45,7 +45,7 @@ extern void i915_copy_blit(struct i915_context *i915, extern void i915_fill_blit(struct i915_context *i915, unsigned cpp, short dst_pitch, - struct pipe_buffer_handle *dst_buffer, + struct pipe_buffer *dst_buffer, unsigned dst_offset, short x, short y, short w, short h, unsigned color); diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index c2b96d2554..497623a700 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -166,7 +166,7 @@ static void i915_destroy( struct pipe_context *pipe ) static boolean i915_draw_elements( struct pipe_context *pipe, - struct pipe_buffer_handle *indexBuffer, + struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned prim, unsigned start, unsigned count) { diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index 2f1f036993..b4ea63c3e7 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -172,7 +172,7 @@ struct i915_texture { /* The data is held here: */ - struct pipe_buffer_handle *buffer; + struct pipe_buffer *buffer; }; struct i915_context @@ -204,7 +204,7 @@ struct i915_context unsigned *batch_start; /** Vertex buffer */ - struct pipe_buffer_handle *vbo; + struct pipe_buffer *vbo; struct i915_state current; unsigned hardware_dirty; diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c index 0887f9a1c6..39154b2488 100644 --- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c +++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c @@ -42,6 +42,7 @@ #include "pipe/draw/draw_vbuf.h" #include "pipe/p_util.h" +#include "pipe/p_inlines.h" #include "pipe/p_winsys.h" #include "i915_context.h" @@ -192,7 +193,7 @@ i915_vbuf_render_release_vertices( struct vbuf_render *render, assert(i915->vbo); winsys->buffer_unmap(winsys, i915->vbo); - winsys->buffer_reference(winsys, &i915->vbo, NULL); + pipe_buffer_reference(winsys, &i915->vbo, NULL); } diff --git a/src/mesa/pipe/i915simple/i915_state_emit.c b/src/mesa/pipe/i915simple/i915_state_emit.c index 8598eacc9c..657f523893 100644 --- a/src/mesa/pipe/i915simple/i915_state_emit.c +++ b/src/mesa/pipe/i915simple/i915_state_emit.c @@ -278,7 +278,7 @@ i915_emit_hardware_state(struct i915_context *i915 ) OUT_BATCH(enabled); for (unit = 0; unit < I915_TEX_UNITS; unit++) { if (enabled & (1 << unit)) { - struct pipe_buffer_handle *buf = + struct pipe_buffer *buf = i915->texture[unit]->buffer; uint offset = 0; assert(buf); diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c index e625f5a68c..8ef02b99cd 100644 --- a/src/mesa/pipe/i915simple/i915_surface.c +++ b/src/mesa/pipe/i915simple/i915_surface.c @@ -65,7 +65,7 @@ i915_get_tex_surface(struct pipe_context *pipe, if (ps) { assert(ps->refcount); assert(ps->winsys); - pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, tex->buffer); + pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer); ps->format = pt->format; ps->cpp = pt->cpp; ps->width = pt->width[level]; diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c index bf80e18233..61944fe7d9 100644 --- a/src/mesa/pipe/i915simple/i915_texture.c +++ b/src/mesa/pipe/i915simple/i915_texture.c @@ -523,7 +523,7 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt) DBG("%s deleting %p\n", __FUNCTION__, (void *) tex); */ - pipe->winsys->buffer_reference(pipe->winsys, &tex->buffer, NULL); + pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL); for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) if (tex->image_offset[i]) diff --git a/src/mesa/pipe/i915simple/i915_winsys.h b/src/mesa/pipe/i915simple/i915_winsys.h index 2c0f335d34..fe49710852 100644 --- a/src/mesa/pipe/i915simple/i915_winsys.h +++ b/src/mesa/pipe/i915simple/i915_winsys.h @@ -50,7 +50,7 @@ * etc. */ -struct pipe_buffer_handle; +struct pipe_buffer; struct pipe_winsys; @@ -93,7 +93,7 @@ struct i915_winsys { * I915_BUFFER_ACCESS_READ macros. */ void (*batch_reloc)( struct i915_winsys *sws, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned access_flags, unsigned delta ); diff --git a/src/mesa/pipe/i965simple/brw_blit.c b/src/mesa/pipe/i965simple/brw_blit.c index 4692129e40..bbd366294f 100644 --- a/src/mesa/pipe/i965simple/brw_blit.c +++ b/src/mesa/pipe/i965simple/brw_blit.c @@ -42,7 +42,7 @@ void brw_fill_blit(struct brw_context *brw, unsigned cpp, short dst_pitch, - struct pipe_buffer_handle *dst_buffer, + struct pipe_buffer *dst_buffer, unsigned dst_offset, boolean dst_tiled, short x, short y, @@ -113,11 +113,11 @@ static unsigned translate_raster_op(unsigned logicop) void brw_copy_blit(struct brw_context *brw, unsigned cpp, short src_pitch, - struct pipe_buffer_handle *src_buffer, + struct pipe_buffer *src_buffer, unsigned src_offset, boolean src_tiled, short dst_pitch, - struct pipe_buffer_handle *dst_buffer, + struct pipe_buffer *dst_buffer, unsigned dst_offset, boolean dst_tiled, short src_x, short src_y, diff --git a/src/mesa/pipe/i965simple/brw_blit.h b/src/mesa/pipe/i965simple/brw_blit.h index 371a135375..7f17a70173 100644 --- a/src/mesa/pipe/i965simple/brw_blit.h +++ b/src/mesa/pipe/i965simple/brw_blit.h @@ -3,13 +3,13 @@ #include "pipe/p_compiler.h" -struct pipe_buffer_handle; +struct pipe_buffer; struct brw_context; void brw_fill_blit(struct brw_context *intel, unsigned cpp, short dst_pitch, - struct pipe_buffer_handle *dst_buffer, + struct pipe_buffer *dst_buffer, unsigned dst_offset, boolean dst_tiled, short x, short y, @@ -18,11 +18,11 @@ void brw_fill_blit(struct brw_context *intel, void brw_copy_blit(struct brw_context *intel, unsigned cpp, short src_pitch, - struct pipe_buffer_handle *src_buffer, + struct pipe_buffer *src_buffer, unsigned src_offset, boolean src_tiled, short dst_pitch, - struct pipe_buffer_handle *dst_buffer, + struct pipe_buffer *dst_buffer, unsigned dst_offset, boolean dst_tiled, short src_x, short src_y, diff --git a/src/mesa/pipe/i965simple/brw_context.h b/src/mesa/pipe/i965simple/brw_context.h index c610a435e0..65664d853d 100644 --- a/src/mesa/pipe/i965simple/brw_context.h +++ b/src/mesa/pipe/i965simple/brw_context.h @@ -260,7 +260,7 @@ struct brw_texture { /* The data is held here: */ - struct pipe_buffer_handle *buffer; + struct pipe_buffer *buffer; }; /* Data about a particular attempt to compile a program. Note that @@ -350,7 +350,7 @@ struct brw_surface_binding_table { struct brw_cache; struct brw_mem_pool { - struct pipe_buffer_handle *buffer; + struct pipe_buffer *buffer; unsigned size; unsigned offset; /* offset of first free byte */ @@ -615,7 +615,7 @@ struct brw_context unsigned nr_surfaces; unsigned max_threads; - struct pipe_buffer_handle *scratch_buffer; + struct pipe_buffer *scratch_buffer; unsigned scratch_buffer_size; unsigned sampler_count; diff --git a/src/mesa/pipe/i965simple/brw_draw.c b/src/mesa/pipe/i965simple/brw_draw.c index acfb524a30..7598e3dc8a 100644 --- a/src/mesa/pipe/i965simple/brw_draw.c +++ b/src/mesa/pipe/i965simple/brw_draw.c @@ -144,7 +144,7 @@ static boolean brw_emit_prim( struct brw_context *brw, * fallback conditions. */ static boolean brw_try_draw_elements( struct pipe_context *pipe, - struct pipe_buffer_handle *index_buffer, + struct pipe_buffer *index_buffer, unsigned index_size, unsigned mode, unsigned start, @@ -183,7 +183,7 @@ static boolean brw_try_draw_elements( struct pipe_context *pipe, static boolean brw_draw_elements( struct pipe_context *pipe, - struct pipe_buffer_handle *indexBuffer, + struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, diff --git a/src/mesa/pipe/i965simple/brw_draw.h b/src/mesa/pipe/i965simple/brw_draw.h index 053f2efb9d..62fe0d5d0e 100644 --- a/src/mesa/pipe/i965simple/brw_draw.h +++ b/src/mesa/pipe/i965simple/brw_draw.h @@ -42,7 +42,7 @@ boolean brw_upload_vertices( struct brw_context *brw, unsigned max_index ); boolean brw_upload_indices(struct brw_context *brw, - const struct pipe_buffer_handle *index_buffer, + const struct pipe_buffer *index_buffer, int ib_size, int start, int count); boolean brw_upload_vertex_buffers( struct brw_context *brw ); diff --git a/src/mesa/pipe/i965simple/brw_draw_upload.c b/src/mesa/pipe/i965simple/brw_draw_upload.c index 43e53914e9..aa85d93866 100644 --- a/src/mesa/pipe/i965simple/brw_draw_upload.c +++ b/src/mesa/pipe/i965simple/brw_draw_upload.c @@ -47,7 +47,7 @@ struct brw_array_state { unsigned dword; } vb0; - struct pipe_buffer_handle *buffer; + struct pipe_buffer *buffer; unsigned offset; unsigned max_index; @@ -272,7 +272,7 @@ boolean brw_upload_vertex_elements( struct brw_context *brw ) } boolean brw_upload_indices( struct brw_context *brw, - const struct pipe_buffer_handle *index_buffer, + const struct pipe_buffer *index_buffer, int ib_size, int start, int count) { /* Emit the indexbuffer packet: diff --git a/src/mesa/pipe/i965simple/brw_state.h b/src/mesa/pipe/i965simple/brw_state.h index 8b4d7aabf0..258e9a556e 100644 --- a/src/mesa/pipe/i965simple/brw_state.h +++ b/src/mesa/pipe/i965simple/brw_state.h @@ -106,7 +106,7 @@ boolean brw_search_cache( struct brw_cache *cache, void brw_init_caches( struct brw_context *brw ); void brw_destroy_caches( struct brw_context *brw ); -static inline struct pipe_buffer_handle *brw_cache_buffer(struct brw_context *brw, +static inline struct pipe_buffer *brw_cache_buffer(struct brw_context *brw, enum brw_cache_id id) { return brw->cache[id].pool->buffer; diff --git a/src/mesa/pipe/i965simple/brw_state_pool.c b/src/mesa/pipe/i965simple/brw_state_pool.c index 2f930be837..7c67f0ee25 100644 --- a/src/mesa/pipe/i965simple/brw_state_pool.c +++ b/src/mesa/pipe/i965simple/brw_state_pool.c @@ -44,6 +44,7 @@ #include "pipe/p_winsys.h" #include "pipe/p_util.h" +#include "pipe/p_inlines.h" #include "brw_context.h" #include "brw_state.h" @@ -101,9 +102,9 @@ static void brw_destroy_pool( struct brw_context *brw, { struct brw_mem_pool *pool = &brw->pool[pool_id]; - pool->brw->pipe.winsys->buffer_reference( pool->brw->pipe.winsys, - &pool->buffer, - NULL ); + pipe_buffer_reference( pool->brw->pipe.winsys, + &pool->buffer, + NULL ); } diff --git a/src/mesa/pipe/i965simple/brw_surface.c b/src/mesa/pipe/i965simple/brw_surface.c index 76b8c73d5c..252aec7d29 100644 --- a/src/mesa/pipe/i965simple/brw_surface.c +++ b/src/mesa/pipe/i965simple/brw_surface.c @@ -64,7 +64,7 @@ brw_get_tex_surface(struct pipe_context *pipe, if (ps) { assert(ps->format); assert(ps->refcount); - pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, tex->buffer); + pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer); ps->format = pt->format; ps->cpp = pt->cpp; ps->width = pt->width[level]; diff --git a/src/mesa/pipe/i965simple/brw_tex_layout.c b/src/mesa/pipe/i965simple/brw_tex_layout.c index eadacbf09e..b8b6b579e2 100644 --- a/src/mesa/pipe/i965simple/brw_tex_layout.c +++ b/src/mesa/pipe/i965simple/brw_tex_layout.c @@ -39,6 +39,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_util.h" +#include "pipe/p_inlines.h" #include "pipe/p_winsys.h" #include "brw_context.h" @@ -341,7 +342,7 @@ brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt) DBG("%s deleting %p\n", __FUNCTION__, (void *) tex); */ - pipe->winsys->buffer_reference(pipe->winsys, &tex->buffer, NULL); + pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL); for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) if (tex->image_offset[i]) diff --git a/src/mesa/pipe/i965simple/brw_winsys.h b/src/mesa/pipe/i965simple/brw_winsys.h index b60f63aa5b..3523a58614 100644 --- a/src/mesa/pipe/i965simple/brw_winsys.h +++ b/src/mesa/pipe/i965simple/brw_winsys.h @@ -50,7 +50,7 @@ * etc. */ -struct pipe_buffer_handle; +struct pipe_buffer; struct pipe_fence_handle; struct pipe_winsys; @@ -136,7 +136,7 @@ struct brw_winsys { * I915_BUFFER_ACCESS_READ macros. */ void (*batch_reloc)(struct brw_winsys *sws, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned access_flags, unsigned delta); @@ -159,7 +159,7 @@ struct brw_winsys { * simulator: */ void (*buffer_subdata_typed)(struct brw_winsys *sws, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned long offset, unsigned long size, const void *data, @@ -170,7 +170,7 @@ struct brw_winsys { * of places yet: */ unsigned (*get_buffer_offset)( struct brw_winsys *sws, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned flags ); }; diff --git a/src/mesa/pipe/i965simple/brw_wm_surface_state.c b/src/mesa/pipe/i965simple/brw_wm_surface_state.c index fc40e0438c..cbb4f2efd3 100644 --- a/src/mesa/pipe/i965simple/brw_wm_surface_state.c +++ b/src/mesa/pipe/i965simple/brw_wm_surface_state.c @@ -127,7 +127,7 @@ static unsigned translate_tex_format( enum pipe_format pipe_format ) } static unsigned brw_buffer_offset(struct brw_context *brw, - struct pipe_buffer_handle *buffer) + struct pipe_buffer *buffer) { return brw->winsys->get_buffer_offset(brw->winsys, buffer, diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 7a18d48865..37464c88a1 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -74,7 +74,7 @@ struct pipe_context { unsigned mode, unsigned start, unsigned count); boolean (*draw_elements)( struct pipe_context *pipe, - struct pipe_buffer_handle *indexBuffer, + struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count); diff --git a/src/mesa/pipe/p_inlines.h b/src/mesa/pipe/p_inlines.h index 8ee0820f92..ebf6ed86bc 100644 --- a/src/mesa/pipe/p_inlines.h +++ b/src/mesa/pipe/p_inlines.h @@ -56,20 +56,38 @@ pipe_surface_unmap(struct pipe_surface *surface) static INLINE void pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf) { - assert(ptr); - if (*ptr) { + /* bump the refcount first */ + if (surf) + surf->refcount++; + + if (*ptr /* && --(*ptr)->refcount == 0 */) { struct pipe_winsys *winsys = (*ptr)->winsys; winsys->surface_release(winsys, ptr); assert(!*ptr); } - if (surf) { - /* reference the new thing */ - surf->refcount++; - *ptr = surf; - } + + *ptr = surf; +} + + +/* XXX: thread safety issues! + */ +static INLINE void +pipe_buffer_reference(struct pipe_winsys *winsys, + struct pipe_buffer **ptr, + struct pipe_buffer *buf) +{ + if (buf) + buf->refcount++; + + if (*ptr && --(*ptr)->refcount == 0) + winsys->buffer_destroy( winsys, *ptr ); + + *ptr = buf; } + /** * \sa pipe_surface_reference */ @@ -78,15 +96,16 @@ pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr, struct pipe_texture *pt) { assert(ptr); + + if (pt) + pt->refcount++; + if (*ptr) { pipe->texture_release(pipe, ptr); assert(!*ptr); } - if (pt) { - /* reference the new thing */ - pt->refcount++; - *ptr = pt; - } + + *ptr = pt; } diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index 146a479cf3..83ca43f678 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -60,8 +60,21 @@ struct pipe_surface; struct pipe_winsys; -/* opaque type */ -struct pipe_buffer_handle; + + +/** + * The driver will certainly subclass this to include actual memory + * management information. + */ +struct pipe_buffer { + unsigned alignment; + unsigned usage; + unsigned size; + + /** Reference count */ + unsigned refcount; +}; + @@ -129,7 +142,7 @@ struct pipe_clip_state { * Constants for vertex/fragment shaders */ struct pipe_constant_buffer { - struct pipe_buffer_handle *buffer; + struct pipe_buffer *buffer; unsigned size; /** in bytes */ }; @@ -240,7 +253,7 @@ struct pipe_sampler_state */ struct pipe_surface { - struct pipe_buffer_handle *buffer; /**< driver private buffer handle */ + struct pipe_buffer *buffer; /**< driver private buffer handle */ enum pipe_format format; /**< PIPE_FORMAT_x */ unsigned status; /**< PIPE_SURFACE_STATUS_x */ unsigned clear_value; /**< may be temporary */ @@ -290,7 +303,7 @@ struct pipe_vertex_buffer unsigned pitch:11; /**< stride to same attrib in next vertex, in bytes */ unsigned max_index; /**< number of vertices in this buffer */ unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ - struct pipe_buffer_handle *buffer; /**< the actual buffer */ + struct pipe_buffer *buffer; /**< the actual buffer */ }; diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index 9742f59a4d..95e3684008 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -39,9 +39,6 @@ */ -/** Opaque type for a buffer */ -struct pipe_buffer_handle; - /** Opaque type */ struct pipe_fence_handle; @@ -103,13 +100,13 @@ struct pipe_winsys * usage argument is only an optimization hint, not a guarantee, therefore * proper behavior must be observed in all circumstances. */ - struct pipe_buffer_handle *(*buffer_create)( struct pipe_winsys *sws, + struct pipe_buffer *(*buffer_create)( struct pipe_winsys *sws, unsigned alignment, unsigned usage, unsigned size ); /** Create a buffer that wraps user-space data */ - struct pipe_buffer_handle *(*user_buffer_create)(struct pipe_winsys *sws, + struct pipe_buffer *(*user_buffer_create)(struct pipe_winsys *sws, void *ptr, unsigned bytes); @@ -118,16 +115,14 @@ struct pipe_winsys * flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE. */ void *(*buffer_map)( struct pipe_winsys *sws, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned usage ); void (*buffer_unmap)( struct pipe_winsys *sws, - struct pipe_buffer_handle *buf ); + struct pipe_buffer *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_destroy)( struct pipe_winsys *sws, + struct pipe_buffer *buf ); /** Set ptr = fence, with reference counting */ diff --git a/src/mesa/pipe/pipebuffer/Makefile b/src/mesa/pipe/pipebuffer/Makefile index 061d8a060f..0d23e8b8f1 100644 --- a/src/mesa/pipe/pipebuffer/Makefile +++ b/src/mesa/pipe/pipebuffer/Makefile @@ -8,10 +8,8 @@ LIBNAME = pipebuffer DRIVER_SOURCES = \ pb_buffer.c \ pb_buffer_client.c \ - pb_buffer_handle.c \ pb_buffer_fenced.c \ pb_buffer_malloc.c \ - pb_buffer_null.c \ pb_bufmgr_fenced.c \ pb_bufmgr_mm.c \ pb_bufmgr_pool.c diff --git a/src/mesa/pipe/pipebuffer/pb_buffer.c b/src/mesa/pipe/pipebuffer/pb_buffer.c index 99c960b697..90ab9044ff 100644 --- a/src/mesa/pipe/pipebuffer/pb_buffer.c +++ b/src/mesa/pipe/pipebuffer/pb_buffer.c @@ -34,19 +34,44 @@ #include "pb_buffer.h" +#include "pipe/p_winsys.h" -void -buffer_reference(struct pipe_buffer **dst, - struct pipe_buffer *src) + +static void * +pb_winsys_map(struct pipe_winsys *winsys, + struct pipe_buffer *ws_buf, + unsigned flags) +{ + struct pb_buffer *buf = pb_buffer(ws_buf); + + return buf->vtbl->map(buf, flags); +} + +static void +pb_winsys_unmap(struct pipe_winsys *winsys, + struct pipe_buffer *ws_buf) +{ + struct pb_buffer *buf = pb_buffer(ws_buf); + + buf->vtbl->unmap(buf); +} + +static void +pb_winsys_destroy(struct pipe_winsys *winsys, + struct pipe_buffer *ws_buf) +{ + struct pb_buffer *buf = pb_buffer(ws_buf); + + buf->vtbl->destroy(buf); +} + + + +void +pb_init_winsys(struct pipe_winsys *winsys) { - if(*dst != src) { - if (src) - src->vtbl->reference(src); - - if (*dst) - (*dst)->vtbl->release(*dst); - - *dst = src; - } + winsys->buffer_map = pb_winsys_map; + winsys->buffer_unmap = pb_winsys_unmap; + winsys->buffer_destroy = pb_winsys_destroy; } diff --git a/src/mesa/pipe/pipebuffer/pb_buffer.h b/src/mesa/pipe/pipebuffer/pb_buffer.h index 0523531395..f909bded0d 100644 --- a/src/mesa/pipe/pipebuffer/pb_buffer.h +++ b/src/mesa/pipe/pipebuffer/pb_buffer.h @@ -47,53 +47,43 @@ #include #include +#include "pipe/p_state.h" -struct pipe_buffer_vtbl; - +struct pb_vtbl; /** - * Base class for all pipe buffers. + * Base class for all pb_* buffers. */ -struct pipe_buffer +struct pb_buffer { + struct pipe_buffer base; + /** * Pointer to the virtual function table. * * Avoid accessing this table directly. Use the inline functions below * instead to avoid mistakes. */ - const struct pipe_buffer_vtbl *vtbl; + const struct pb_vtbl *vtbl; }; - /** * Virtual function table for the buffer storage operations. * * Note that creation is not done through this table. */ -struct pipe_buffer_vtbl +struct pb_vtbl { - /** - * Add a reference to the buffer. - * - * This method can be a no-op for buffers that don't need reference - * counting. - */ - void (*reference)( struct pipe_buffer *buf ); - - /** - * Release a reference to this buffer and destroy it. - */ - void (*release)( struct pipe_buffer *buf ); + void (*destroy)( struct pb_buffer *buf ); /** * Map the entire data store of a buffer object into the client's address. * flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE. */ - void *(*map)( struct pipe_buffer *buf, + void *(*map)( struct pb_buffer *buf, unsigned flags ); - void (*unmap)( struct pipe_buffer *buf ); + void (*unmap)( struct pb_buffer *buf ); /** * Get the base buffer and the offset. @@ -106,29 +96,17 @@ struct pipe_buffer_vtbl * * Note that this will increase the reference count of the base buffer. */ - void (*get_base_buffer)( struct pipe_buffer *buf, - struct pipe_buffer **base_buf, + void (*get_base_buffer)( struct pb_buffer *buf, + struct pb_buffer **base_buf, unsigned *offset ); }; -/** *dst = src with reference counting */ -void -buffer_reference(struct pipe_buffer **dst, - struct pipe_buffer *src); - - -static inline void -buffer_release(struct pipe_buffer *buf) -{ - assert(buf); - buf->vtbl->release(buf); -} - - +/* Accessor functions for pb->vtbl: + */ static inline void * -buffer_map(struct pipe_buffer *buf, - unsigned flags) +pb_map(struct pb_buffer *buf, + unsigned flags) { assert(buf); return buf->vtbl->map(buf, flags); @@ -136,7 +114,7 @@ buffer_map(struct pipe_buffer *buf, static inline void -buffer_unmap(struct pipe_buffer *buf) +pb_unmap(struct pb_buffer *buf) { assert(buf); buf->vtbl->unmap(buf); @@ -144,32 +122,63 @@ buffer_unmap(struct pipe_buffer *buf) static inline void -buffer_get_base_buffer( struct pipe_buffer *buf, - struct pipe_buffer **base_buf, - unsigned *offset ) +pb_get_base_buffer( struct pb_buffer *buf, + struct pb_buffer **base_buf, + unsigned *offset ) { buf->vtbl->get_base_buffer(buf, base_buf, offset); } +static inline void +pb_destroy(struct pb_buffer *buf) +{ + assert(buf); + buf->vtbl->destroy(buf); +} + -/** Placeholder for empty buffers. */ -extern struct pipe_buffer null_buffer; /** - * Client buffers (also designated as user buffers) are just for convenience - * of the state tracker, so that it can masquerade its own data as a buffer. + * User buffers are special buffers that initially reference memory + * held by the user but which may if necessary copy that memory into + * device memory behind the scenes, for submission to hardware. + * + * These are particularly useful when the referenced data is never + * submitted to hardware at all, in the particular case of software + * vertex processing. */ -struct pipe_buffer * -client_buffer_create(void *data); +struct pb_buffer * +pb_user_buffer_create(void *data, unsigned bytes); /** * Malloc-based buffer to store data that can't be used by the graphics * hardware. */ -struct pipe_buffer * -malloc_buffer_create(unsigned size); +struct pb_buffer * +pb_malloc_buffer_create( unsigned alignment, + unsigned usage, + unsigned size ); + + + +static inline struct pipe_buffer * +pb_pipe_buffer( struct pb_buffer *pbuf ) +{ + return &pbuf->base; +} + +static inline struct pb_buffer * +pb_buffer( struct pipe_buffer *buf ) +{ + /* Could add a magic cookie check on debug builds. + */ + return (struct pb_buffer *)buf; +} + +void +pb_init_winsys(struct pipe_winsys *winsys); #endif /*PB_BUFFER_H_*/ diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_client.c b/src/mesa/pipe/pipebuffer/pb_buffer_client.c index bb7f5a9a94..6bf4745301 100644 --- a/src/mesa/pipe/pipebuffer/pb_buffer_client.c +++ b/src/mesa/pipe/pipebuffer/pb_buffer_client.c @@ -35,36 +35,30 @@ #include "pb_buffer.h" +#include "pipe/p_util.h" -struct client_buffer +struct pb_user_buffer { - struct pipe_buffer base; + struct pb_buffer base; void *data; }; -extern const struct pipe_buffer_vtbl client_buffer_vtbl; +extern const struct pb_vtbl pb_user_buffer_vtbl; -static inline struct client_buffer * -client_buffer(struct pipe_buffer *buf) +static INLINE struct pb_user_buffer * +pb_user_buffer(struct pb_buffer *buf) { assert(buf); - assert(buf->vtbl == &client_buffer_vtbl); - return (struct client_buffer *)buf; + assert(buf->vtbl == &pb_user_buffer_vtbl); + return (struct pb_user_buffer *)buf; } static void -client_buffer_reference(struct pipe_buffer *buf) -{ - /* No-op */ -} - - -static void -client_buffer_release(struct pipe_buffer *buf) +pb_user_buffer_destroy(struct pb_buffer *buf) { assert(buf); free(buf); @@ -72,23 +66,23 @@ client_buffer_release(struct pipe_buffer *buf) static void * -client_buffer_map(struct pipe_buffer *buf, +pb_user_buffer_map(struct pb_buffer *buf, unsigned flags) { - return client_buffer(buf)->data; + return pb_user_buffer(buf)->data; } static void -client_buffer_unmap(struct pipe_buffer *buf) +pb_user_buffer_unmap(struct pb_buffer *buf) { /* No-op */ } static void -client_buffer_get_base_buffer(struct pipe_buffer *buf, - struct pipe_buffer **base_buf, +pb_user_buffer_get_base_buffer(struct pb_buffer *buf, + struct pb_buffer **base_buf, unsigned *offset) { *base_buf = buf; @@ -96,27 +90,25 @@ client_buffer_get_base_buffer(struct pipe_buffer *buf, } -const struct pipe_buffer_vtbl -client_buffer_vtbl = { - client_buffer_reference, - client_buffer_release, - client_buffer_map, - client_buffer_unmap, - client_buffer_get_base_buffer +const struct pb_vtbl +pb_user_buffer_vtbl = { + pb_user_buffer_destroy, + pb_user_buffer_map, + pb_user_buffer_unmap, + pb_user_buffer_get_base_buffer }; -struct pipe_buffer * -client_buffer_create(void *data) +struct pb_buffer * +pb_user_buffer_create(void *data, unsigned bytes) { - struct client_buffer *buf; - - buf = (struct client_buffer *)malloc(sizeof(struct client_buffer)); + struct pb_user_buffer *buf = CALLOC_STRUCT(pb_user_buffer); + if(!buf) return NULL; - buf->base.vtbl = &client_buffer_vtbl; - + buf->base.vtbl = &pb_user_buffer_vtbl; + buf->base.base.size = bytes; buf->data = data; return &buf->base; diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c index dfb80b1dcf..625120d714 100644 --- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c +++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c @@ -72,9 +72,9 @@ struct fenced_buffer_list */ struct fenced_buffer { - struct pipe_buffer base; + struct pb_buffer base; - struct pipe_buffer *buffer; + struct pb_buffer *buffer; unsigned refcount; struct pipe_fence_handle *fence; @@ -84,8 +84,8 @@ struct fenced_buffer }; -static inline struct fenced_buffer * -fenced_buffer(struct pipe_buffer *buf) +static INLINE struct fenced_buffer * +fenced_buffer(struct pb_buffer *buf) { assert(buf); assert(buf->vtbl == &fenced_buffer_vtbl); @@ -93,12 +93,6 @@ fenced_buffer(struct pipe_buffer *buf) } -static void -_fenced_buffer_destroy(struct fenced_buffer *fenced_buf) -{ - buffer_release(fenced_buf->buffer); - free(fenced_buf); -} static void @@ -143,97 +137,81 @@ _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, LIST_DEL(list); fenced_list->numDelayed--; - - _fenced_buffer_destroy(fenced_buf); - } -} - -static void -fenced_buffer_reference(struct pipe_buffer *buf) -{ - struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_buffer_list *fenced_list = fenced_buf->list; - - _glthread_LOCK_MUTEX(fenced_list->mutex); - fenced_buf->refcount++; - _glthread_UNLOCK_MUTEX(fenced_list->mutex); + /* Do the delayed destroy: + */ + pb_destroy(fenced_buf->buffer); + free(fenced_buf); + } } static void -fenced_buffer_release(struct pipe_buffer *buf) +fenced_buffer_destroy(struct pb_buffer *buf) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); struct fenced_buffer_list *fenced_list = fenced_buf->list; - _glthread_LOCK_MUTEX(fenced_list->mutex); - - fenced_buf->refcount--; - if(!fenced_buf->refcount) { - if (fenced_buf->fence) { - LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed); - fenced_list->numDelayed++; - } - else { - _fenced_buffer_destroy(fenced_buf); - } - - if ((fenced_list->numDelayed % fenced_list->checkDelayed) == 0) - _fenced_buffer_list_check_free(fenced_list, 0); + if (fenced_buf->fence) { + LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed); + fenced_list->numDelayed++; + } + else { + pb_destroy(fenced_buf->buffer); + free(fenced_buf); } - _glthread_UNLOCK_MUTEX(fenced_list->mutex); + if ((fenced_list->numDelayed % fenced_list->checkDelayed) == 0) + _fenced_buffer_list_check_free(fenced_list, 0); } static void * -fenced_buffer_map(struct pipe_buffer *buf, +fenced_buffer_map(struct pb_buffer *buf, unsigned flags) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - return buffer_map(fenced_buf->buffer, flags); + return pb_map(fenced_buf->buffer, flags); } static void -fenced_buffer_unmap(struct pipe_buffer *buf) +fenced_buffer_unmap(struct pb_buffer *buf) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - buffer_unmap(fenced_buf->buffer); + pb_unmap(fenced_buf->buffer); } static void -fenced_buffer_get_base_buffer(struct pipe_buffer *buf, - struct pipe_buffer **base_buf, +fenced_buffer_get_base_buffer(struct pb_buffer *buf, + struct pb_buffer **base_buf, unsigned *offset) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - buffer_get_base_buffer(fenced_buf->buffer, base_buf, offset); + pb_get_base_buffer(fenced_buf->buffer, base_buf, offset); } -const struct pipe_buffer_vtbl +const struct pb_vtbl fenced_buffer_vtbl = { - fenced_buffer_reference, - fenced_buffer_release, + fenced_buffer_destroy, fenced_buffer_map, fenced_buffer_unmap, fenced_buffer_get_base_buffer }; -struct pipe_buffer * +struct pb_buffer * fenced_buffer_create(struct fenced_buffer_list *fenced_list, - struct pipe_buffer *buffer) + struct pb_buffer *buffer) { struct fenced_buffer *buf; if(!buffer) return NULL; - buf = (struct fenced_buffer *)calloc(1, sizeof(struct fenced_buffer)); + buf = CALLOC_STRUCT(fenced_buffer); if(!buf) return NULL; @@ -247,20 +225,16 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list, void -buffer_fence(struct pipe_buffer *buf, +buffer_fence(struct pb_buffer *buf, struct pipe_fence_handle *fence) { - if(buf->vtbl == &fenced_buffer_vtbl) { - struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_buffer_list *fenced_list = fenced_buf->list; - struct pipe_winsys *winsys = fenced_list->winsys; + struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_buffer_list *fenced_list = fenced_buf->list; + struct pipe_winsys *winsys = fenced_list->winsys; - _glthread_LOCK_MUTEX(fenced_list->mutex); - winsys->fence_reference(winsys, &fenced_buf->fence, fence); - _glthread_UNLOCK_MUTEX(fenced_list->mutex); - } - else - assert(0); + _glthread_LOCK_MUTEX(fenced_list->mutex); + winsys->fence_reference(winsys, &fenced_buf->fence, fence); + _glthread_UNLOCK_MUTEX(fenced_list->mutex); } diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h index 07e42a67f8..09082a5390 100644 --- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h +++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h @@ -70,7 +70,7 @@ struct fenced_buffer_list; * * NOTE: Made public for debugging purposes. */ -extern const struct pipe_buffer_vtbl fenced_buffer_vtbl; +extern const struct pb_vtbl fenced_buffer_vtbl; /** @@ -98,19 +98,19 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list); * * NOTE: this will not increase the buffer reference count. */ -struct pipe_buffer * +struct pb_buffer * fenced_buffer_create(struct fenced_buffer_list *fenced, - struct pipe_buffer *buffer); + struct pb_buffer *buffer); /** * Set a buffer's fence. * - * NOTE: Although it takes a generic pipe buffer argument, it will fail + * NOTE: Although it takes a generic pb_buffer argument, it will fail * on everything but buffers returned by fenced_buffer_create. */ void -buffer_fence(struct pipe_buffer *buf, +buffer_fence(struct pb_buffer *buf, struct pipe_fence_handle *fence); diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c b/src/mesa/pipe/pipebuffer/pb_buffer_handle.c deleted file mode 100644 index 9aeff976f3..0000000000 --- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c +++ /dev/null @@ -1,140 +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. - * - **************************************************************************/ - -/** - * \file - * Drop-in implementation of the winsys driver functions for buffer handles. - * - * \author José Fonseca - */ - - -#include -#include - -#include "pipe/p_winsys.h" -#include "pipe/p_defines.h" - -#include "pb_buffer.h" -#include "pb_buffer_handle.h" - - -static struct pipe_buffer_handle * -buffer_handle_create(struct pipe_winsys *winsys, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct pipe_buffer_handle *handle; - - handle = (struct pipe_buffer_handle *)malloc(sizeof(struct pipe_buffer_handle)); - if(!handle) - return NULL; - - handle->refcount = 1; - handle->alignment = alignment; - handle->usage = usage; - handle->size = size; - - handle->buf = &null_buffer; - - return handle; -} - - -static struct pipe_buffer_handle * -buffer_handle_create_user(struct pipe_winsys *winsys, - void *data, unsigned size) -{ - struct pipe_buffer_handle *handle; - struct pipe_buffer *buf; - - handle = buffer_handle_create(winsys, 1, 0, size); - if(!handle) - return NULL; - - buf = client_buffer_create(data); - if(!buf) { - free(handle); - return NULL; - } - - buffer_handle_data(handle, buf); - - return handle; -} - - -static void * -buffer_handle_map(struct pipe_winsys *winsys, - struct pipe_buffer_handle *handle, - unsigned flags) -{ - return buffer_map(handle->buf, flags); -} - - -static void -buffer_handle_unmap(struct pipe_winsys *winsys, - struct pipe_buffer_handle *handle) -{ - buffer_unmap(handle->buf); -} - - -static void -buffer_handle_reference(struct pipe_winsys *winsys, - struct pipe_buffer_handle **dst, - struct pipe_buffer_handle *src) -{ - /* XXX: should this be thread safe? */ - - if (src) { - src->refcount++; - } - - if (*dst) { - (*dst)->refcount--; - if ((*dst)->refcount == 0) { - buffer_release((*dst)->buf); - free(*dst); - } - } - - *dst = src; -} - - -void -buffer_handle_init_winsys(struct pipe_winsys *winsys) -{ - winsys->buffer_create = buffer_handle_create; - winsys->user_buffer_create = buffer_handle_create_user; - winsys->buffer_map = buffer_handle_map; - winsys->buffer_unmap = buffer_handle_unmap; - winsys->buffer_reference = buffer_handle_reference; -} diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h b/src/mesa/pipe/pipebuffer/pb_buffer_handle.h deleted file mode 100644 index 34133c9fba..0000000000 --- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h +++ /dev/null @@ -1,120 +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. - * - **************************************************************************/ - -/** - * \file - * Buffer handle interface. - * - * \author José Fonseca - */ - -#ifndef PB_BUFFER_HANDLE_H_ -#define PB_BUFFER_HANDLE_H_ - - -#include - -#include "pb_buffer.h" - - -/** - * Buffer handle. - * - * The buffer handle and the buffer data storage are separate entities. This - * is modelled after ARB_vertex_buffer_object, which is the interface that - * Gallium requires. See p_winsys.h for more information. - */ -struct pipe_buffer_handle -{ - /** Reference count */ - unsigned refcount; - - /** Allocation characteristics */ - unsigned alignment; - unsigned usage; - unsigned size; - - /** - * The actual buffer. - * - * It should never be NULL. Use null_buffer instead. - */ - struct pipe_buffer *buf; -}; - - -/** - * Set buffer storage. - * - * NOTE: this will not increase the buffer reference count. - */ -static inline void -buffer_handle_data(struct pipe_buffer_handle *handle, - struct pipe_buffer *buf) -{ - assert(handle); - assert(handle->buf); - buffer_release(handle->buf); - assert(buf); - handle->buf = buf; -} - - -static inline void -buffer_handle_clear(struct pipe_buffer_handle *handle) -{ - buffer_handle_data(handle, &null_buffer); -} - - -static inline int -buffer_handle_has_data(struct pipe_buffer_handle *handle) { - assert(handle); - assert(handle->buf); - return handle->buf != &null_buffer; -} - - -/** - * Fill in the pipe_winsys' buffer-related callbacks. - * - * Specifically, the fullfilled functions are: - * - buffer_create - * - user_buffer_create - * - buffer_map - * - buffer_unmap - * - buffer_reference - * - buffer_subdata - * - buffer_get_subdata - * - * NOTE: buffer_data is left untouched. - */ -void -buffer_handle_init_winsys(struct pipe_winsys *winsys); - - -#endif /*PB_BUFFER_HANDLE_H_*/ diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c index 65ad51e1e7..e02eb1eebd 100644 --- a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c +++ b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c @@ -42,15 +42,15 @@ struct malloc_buffer { - struct pipe_buffer base; + struct pb_buffer base; void *data; }; -extern const struct pipe_buffer_vtbl malloc_buffer_vtbl; +extern const struct pb_vtbl malloc_buffer_vtbl; -static inline struct malloc_buffer * -malloc_buffer(struct pipe_buffer *buf) +static INLINE struct malloc_buffer * +malloc_buffer(struct pb_buffer *buf) { assert(buf); assert(buf->vtbl == &malloc_buffer_vtbl); @@ -59,14 +59,7 @@ malloc_buffer(struct pipe_buffer *buf) static void -malloc_buffer_reference(struct pipe_buffer *buf) -{ - /* no-op */ -} - - -static void -malloc_buffer_release(struct pipe_buffer *buf) +malloc_buffer_destroy(struct pb_buffer *buf) { free(malloc_buffer(buf)->data); free(buf); @@ -74,7 +67,7 @@ malloc_buffer_release(struct pipe_buffer *buf) static void * -malloc_buffer_map(struct pipe_buffer *buf, +malloc_buffer_map(struct pb_buffer *buf, unsigned flags) { return malloc_buffer(buf)->data; @@ -82,15 +75,15 @@ malloc_buffer_map(struct pipe_buffer *buf, static void -malloc_buffer_unmap(struct pipe_buffer *buf) +malloc_buffer_unmap(struct pb_buffer *buf) { /* No-op */ } static void -malloc_buffer_get_base_buffer(struct pipe_buffer *buf, - struct pipe_buffer **base_buf, +malloc_buffer_get_base_buffer(struct pb_buffer *buf, + struct pb_buffer **base_buf, unsigned *offset) { *base_buf = buf; @@ -98,18 +91,19 @@ malloc_buffer_get_base_buffer(struct pipe_buffer *buf, } -const struct pipe_buffer_vtbl +const struct pb_vtbl malloc_buffer_vtbl = { - malloc_buffer_reference, - malloc_buffer_release, + malloc_buffer_destroy, malloc_buffer_map, malloc_buffer_unmap, malloc_buffer_get_base_buffer }; -struct pipe_buffer * -malloc_buffer_create(unsigned size) +struct pb_buffer * +pb_malloc_buffer_create( unsigned alignment, + unsigned usage, + unsigned size ) { struct malloc_buffer *buf; @@ -121,7 +115,10 @@ malloc_buffer_create(unsigned size) return NULL; buf->base.vtbl = &malloc_buffer_vtbl; - + buf->base.base.alignment = alignment; + buf->base.base.usage = usage; + buf->base.base.size = size; + buf->data = malloc(size); if(!buf->data) { free(buf); diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_null.c b/src/mesa/pipe/pipebuffer/pb_buffer_null.c deleted file mode 100644 index a356c6b2d5..0000000000 --- a/src/mesa/pipe/pipebuffer/pb_buffer_null.c +++ /dev/null @@ -1,98 +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. - * - **************************************************************************/ - -/** - * \file - * Null buffer implementation. - * - * We have a special null buffer object so that we can safely call buffer - * operations without having to check whether the buffer pointer is null or not. - * - * \author José Fonseca - */ - - -#include "pipe/p_winsys.h" -#include "pipe/p_defines.h" - -#include "pb_buffer.h" - - -static void -null_buffer_reference(struct pipe_buffer *buf) -{ - /* No-op */ -} - - -static void -null_buffer_release(struct pipe_buffer *buf) -{ - /* No-op */ -} - - -static void * -null_buffer_map(struct pipe_buffer *buf, - unsigned flags) -{ - assert(0); - return NULL; -} - - -static void -null_buffer_unmap(struct pipe_buffer *buf) -{ - assert(0); -} - - -static void -null_buffer_get_base_buffer(struct pipe_buffer *buf, - struct pipe_buffer **base_buf, - unsigned *offset) -{ - *base_buf = buf; - *offset = 0; -} - - -const struct pipe_buffer_vtbl -pipe_buffer_vtbl = { - null_buffer_reference, - null_buffer_release, - null_buffer_map, - null_buffer_unmap, - null_buffer_get_base_buffer -}; - - -struct pipe_buffer -null_buffer = { - &pipe_buffer_vtbl -}; diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr.h b/src/mesa/pipe/pipebuffer/pb_bufmgr.h index 12e36323a8..13d4ea7545 100644 --- a/src/mesa/pipe/pipebuffer/pb_bufmgr.h +++ b/src/mesa/pipe/pipebuffer/pb_bufmgr.h @@ -60,15 +60,15 @@ struct pipe_winsys; /** * Abstract base class for all buffer managers. */ -struct buffer_manager +struct pb_manager { /* XXX: we will likely need more allocation flags */ - struct pipe_buffer * - (*create_buffer)( struct buffer_manager *mgr, + struct pb_buffer * + (*create_buffer)( struct pb_manager *mgr, size_t size ); void - (*destroy)( struct buffer_manager *mgr ); + (*destroy)( struct pb_manager *mgr ); }; @@ -80,8 +80,8 @@ struct buffer_manager * * It is meant to manage the allocation of batch buffer pools. */ -struct buffer_manager * -pool_bufmgr_create(struct buffer_manager *provider, +struct pb_manager * +pool_bufmgr_create(struct pb_manager *provider, size_t n, size_t size); @@ -92,8 +92,8 @@ pool_bufmgr_create(struct buffer_manager *provider, * with the size of the heap, and then using the old mm memory manager to manage * that heap. */ -struct buffer_manager * -mm_bufmgr_create(struct buffer_manager *provider, +struct pb_manager * +mm_bufmgr_create(struct pb_manager *provider, size_t size, size_t align2); /** @@ -101,8 +101,8 @@ mm_bufmgr_create(struct buffer_manager *provider, * * Buffer will be release when the manager is destroyed. */ -struct buffer_manager * -mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer, +struct pb_manager * +mm_bufmgr_create_from_buffer(struct pb_buffer *buffer, size_t size, size_t align2); @@ -115,8 +115,8 @@ mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer, * NOTE: the buffer manager that provides the buffers will be destroyed * at the same time. */ -struct buffer_manager * -fenced_bufmgr_create(struct buffer_manager *provider, +struct pb_manager * +fenced_bufmgr_create(struct pb_manager *provider, struct pipe_winsys *winsys); diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c index defd8e4df7..8cdbbed272 100644 --- a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c +++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c @@ -42,30 +42,30 @@ #include "pb_bufmgr.h" -struct fenced_buffer_manager +struct fenced_pb_manager { - struct buffer_manager base; + struct pb_manager base; - struct buffer_manager *provider; + struct pb_manager *provider; struct fenced_buffer_list *fenced_list; }; -static inline struct fenced_buffer_manager * -fenced_buffer_manager(struct buffer_manager *mgr) +static inline struct fenced_pb_manager * +fenced_pb_manager(struct pb_manager *mgr) { assert(mgr); - return (struct fenced_buffer_manager *)mgr; + return (struct fenced_pb_manager *)mgr; } -static struct pipe_buffer * -fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size) +static struct pb_buffer * +fenced_bufmgr_create_buffer(struct pb_manager *mgr, size_t size) { - struct fenced_buffer_manager *fenced_mgr = fenced_buffer_manager(mgr); - struct pipe_buffer *buf; - struct pipe_buffer *fenced_buf; + struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr); + struct pb_buffer *buf; + struct pb_buffer *fenced_buf; /* check for free buffers before allocating new ones */ fenced_buffer_list_check_free(fenced_mgr->fenced_list, 0); @@ -84,7 +84,7 @@ fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size) fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf); if(!fenced_buf) { - buffer_release(buf); + pb_destroy(buf); } return fenced_buf; @@ -92,9 +92,9 @@ fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size) static void -fenced_bufmgr_destroy(struct buffer_manager *mgr) +fenced_bufmgr_destroy(struct pb_manager *mgr) { - struct fenced_buffer_manager *fenced_mgr = fenced_buffer_manager(mgr); + struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr); fenced_buffer_list_destroy(fenced_mgr->fenced_list); @@ -104,13 +104,13 @@ fenced_bufmgr_destroy(struct buffer_manager *mgr) } -struct buffer_manager * -fenced_bufmgr_create(struct buffer_manager *provider, +struct pb_manager * +fenced_bufmgr_create(struct pb_manager *provider, struct pipe_winsys *winsys) { - struct fenced_buffer_manager *fenced_mgr; + struct fenced_pb_manager *fenced_mgr; - fenced_mgr = (struct fenced_buffer_manager *)calloc(1, sizeof(*fenced_mgr)); + fenced_mgr = (struct fenced_pb_manager *)calloc(1, sizeof(*fenced_mgr)); if (!fenced_mgr) return NULL; diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c index d174f24e32..f456b571d9 100644 --- a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c +++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c @@ -53,9 +53,9 @@ #define SUPER(__derived) (&(__derived)->base) -struct mm_buffer_manager +struct mm_pb_manager { - struct buffer_manager base; + struct pb_manager base; _glthread_Mutex mutex; @@ -64,31 +64,31 @@ struct mm_buffer_manager size_t align2; - struct pipe_buffer *buffer; + struct pb_buffer *buffer; void *map; }; -static inline struct mm_buffer_manager * -mm_buffer_manager(struct buffer_manager *mgr) +static inline struct mm_pb_manager * +mm_pb_manager(struct pb_manager *mgr) { assert(mgr); - return (struct mm_buffer_manager *)mgr; + return (struct mm_pb_manager *)mgr; } struct mm_buffer { - struct pipe_buffer base; + struct pb_buffer base; - struct mm_buffer_manager *mgr; + struct mm_pb_manager *mgr; struct mem_block *block; }; static inline struct mm_buffer * -mm_buffer(struct pipe_buffer *buf) +mm_buffer(struct pb_buffer *buf) { assert(buf); return (struct mm_buffer *)buf; @@ -96,17 +96,10 @@ mm_buffer(struct pipe_buffer *buf) static void -mm_buffer_reference(struct pipe_buffer *buf) -{ - /* No-op */ -} - - -static void -mm_buffer_release(struct pipe_buffer *buf) +mm_buffer_destroy(struct pb_buffer *buf) { struct mm_buffer *mm_buf = mm_buffer(buf); - struct mm_buffer_manager *mm = mm_buf->mgr; + struct mm_pb_manager *mm = mm_buf->mgr; _glthread_LOCK_MUTEX(mm->mutex); mmFreeMem(mm_buf->block); @@ -116,50 +109,49 @@ mm_buffer_release(struct pipe_buffer *buf) static void * -mm_buffer_map(struct pipe_buffer *buf, +mm_buffer_map(struct pb_buffer *buf, unsigned flags) { struct mm_buffer *mm_buf = mm_buffer(buf); - struct mm_buffer_manager *mm = mm_buf->mgr; + struct mm_pb_manager *mm = mm_buf->mgr; return (unsigned char *) mm->map + mm_buf->block->ofs; } static void -mm_buffer_unmap(struct pipe_buffer *buf) +mm_buffer_unmap(struct pb_buffer *buf) { /* No-op */ } static void -mm_buffer_get_base_buffer(struct pipe_buffer *buf, - struct pipe_buffer **base_buf, +mm_buffer_get_base_buffer(struct pb_buffer *buf, + struct pb_buffer **base_buf, unsigned *offset) { struct mm_buffer *mm_buf = mm_buffer(buf); - struct mm_buffer_manager *mm = mm_buf->mgr; - buffer_get_base_buffer(mm->buffer, base_buf, offset); + struct mm_pb_manager *mm = mm_buf->mgr; + pb_get_base_buffer(mm->buffer, base_buf, offset); *offset += mm_buf->block->ofs; } -static const struct pipe_buffer_vtbl +static const struct pb_vtbl mm_buffer_vtbl = { - mm_buffer_reference, - mm_buffer_release, + mm_buffer_destroy, mm_buffer_map, mm_buffer_unmap, mm_buffer_get_base_buffer }; -static struct pipe_buffer * -mm_bufmgr_create_buffer(struct buffer_manager *mgr, +static struct pb_buffer * +mm_bufmgr_create_buffer(struct pb_manager *mgr, size_t size) { - struct mm_buffer_manager *mm = mm_buffer_manager(mgr); + struct mm_pb_manager *mm = mm_pb_manager(mgr); struct mm_buffer *mm_buf; _glthread_LOCK_MUTEX(mm->mutex); @@ -200,16 +192,16 @@ mm_bufmgr_create_buffer(struct buffer_manager *mgr, static void -mm_bufmgr_destroy(struct buffer_manager *mgr) +mm_bufmgr_destroy(struct pb_manager *mgr) { - struct mm_buffer_manager *mm = mm_buffer_manager(mgr); + struct mm_pb_manager *mm = mm_pb_manager(mgr); _glthread_LOCK_MUTEX(mm->mutex); mmDestroy(mm->heap); - buffer_unmap(mm->buffer); - buffer_release(mm->buffer); + pb_unmap(mm->buffer); + pb_destroy(mm->buffer); _glthread_UNLOCK_MUTEX(mm->mutex); @@ -217,16 +209,16 @@ mm_bufmgr_destroy(struct buffer_manager *mgr) } -struct buffer_manager * -mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer, +struct pb_manager * +mm_bufmgr_create_from_buffer(struct pb_buffer *buffer, size_t size, size_t align2) { - struct mm_buffer_manager *mm; + struct mm_pb_manager *mm; if(!buffer) return NULL; - mm = (struct mm_buffer_manager *)calloc(1, sizeof(*mm)); + mm = (struct mm_pb_manager *)calloc(1, sizeof(*mm)); if (!mm) return NULL; @@ -240,9 +232,9 @@ mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer, mm->buffer = buffer; - mm->map = buffer_map(mm->buffer, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); + mm->map = pb_map(mm->buffer, + PIPE_BUFFER_USAGE_CPU_READ | + PIPE_BUFFER_USAGE_CPU_WRITE); if(!mm->map) goto failure; @@ -256,19 +248,19 @@ failure: if(mm->heap) mmDestroy(mm->heap); if(mm->map) - buffer_unmap(mm->buffer); + pb_unmap(mm->buffer); if(mm) free(mm); return NULL; } -struct buffer_manager * -mm_bufmgr_create(struct buffer_manager *provider, +struct pb_manager * +mm_bufmgr_create(struct pb_manager *provider, size_t size, size_t align2) { - struct pipe_buffer *buffer; - struct buffer_manager *mgr; + struct pb_buffer *buffer; + struct pb_manager *mgr; assert(provider); assert(provider->create_buffer); @@ -278,7 +270,7 @@ mm_bufmgr_create(struct buffer_manager *provider, mgr = mm_bufmgr_create_from_buffer(buffer, size, align2); if (!mgr) { - buffer_release(buffer); + pb_destroy(buffer); return NULL; } diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c index e6a8c78668..7e8494f615 100644 --- a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c +++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c @@ -55,9 +55,9 @@ #define SUPER(__derived) (&(__derived)->base) -struct pool_buffer_manager +struct pool_pb_manager { - struct buffer_manager base; + struct pb_manager base; _glthread_Mutex mutex; @@ -68,26 +68,26 @@ struct pool_buffer_manager struct list_head free; - struct pipe_buffer *buffer; + struct pb_buffer *buffer; void *map; struct pool_buffer *bufs; }; -static inline struct pool_buffer_manager * -pool_buffer_manager(struct buffer_manager *mgr) +static inline struct pool_pb_manager * +pool_pb_manager(struct pb_manager *mgr) { assert(mgr); - return (struct pool_buffer_manager *)mgr; + return (struct pool_pb_manager *)mgr; } struct pool_buffer { - struct pipe_buffer base; + struct pb_buffer base; - struct pool_buffer_manager *mgr; + struct pool_pb_manager *mgr; struct list_head head; @@ -96,25 +96,19 @@ struct pool_buffer static inline struct pool_buffer * -pool_buffer(struct pipe_buffer *buf) +pool_buffer(struct pb_buffer *buf) { assert(buf); return (struct pool_buffer *)buf; } -static void -pool_buffer_reference(struct pipe_buffer *buf) -{ - /* No-op */ -} - static void -pool_buffer_release(struct pipe_buffer *buf) +pool_buffer_destroy(struct pb_buffer *buf) { struct pool_buffer *pool_buf = pool_buffer(buf); - struct pool_buffer_manager *pool = pool_buf->mgr; + struct pool_pb_manager *pool = pool_buf->mgr; _glthread_LOCK_MUTEX(pool->mutex); LIST_ADD(&pool_buf->head, &pool->free); @@ -124,10 +118,10 @@ pool_buffer_release(struct pipe_buffer *buf) static void * -pool_buffer_map(struct pipe_buffer *buf, unsigned flags) +pool_buffer_map(struct pb_buffer *buf, unsigned flags) { struct pool_buffer *pool_buf = pool_buffer(buf); - struct pool_buffer_manager *pool = pool_buf->mgr; + struct pool_pb_manager *pool = pool_buf->mgr; void *map; _glthread_LOCK_MUTEX(pool->mutex); @@ -138,38 +132,37 @@ pool_buffer_map(struct pipe_buffer *buf, unsigned flags) static void -pool_buffer_unmap(struct pipe_buffer *buf) +pool_buffer_unmap(struct pb_buffer *buf) { /* No-op */ } static void -pool_buffer_get_base_buffer(struct pipe_buffer *buf, - struct pipe_buffer **base_buf, +pool_buffer_get_base_buffer(struct pb_buffer *buf, + struct pb_buffer **base_buf, unsigned *offset) { struct pool_buffer *pool_buf = pool_buffer(buf); - struct pool_buffer_manager *pool = pool_buf->mgr; - buffer_get_base_buffer(pool->buffer, base_buf, offset); + struct pool_pb_manager *pool = pool_buf->mgr; + pb_get_base_buffer(pool->buffer, base_buf, offset); *offset += pool_buf->start; } -static const struct pipe_buffer_vtbl +static const struct pb_vtbl pool_buffer_vtbl = { - pool_buffer_reference, - pool_buffer_release, + pool_buffer_destroy, pool_buffer_map, pool_buffer_unmap, pool_buffer_get_base_buffer }; -static struct pipe_buffer * -pool_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size) +static struct pb_buffer * +pool_bufmgr_create_buffer(struct pb_manager *mgr, size_t size) { - struct pool_buffer_manager *pool = pool_buffer_manager(mgr); + struct pool_pb_manager *pool = pool_pb_manager(mgr); struct pool_buffer *pool_buf; struct list_head *item; @@ -201,15 +194,15 @@ pool_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size) static void -pool_bufmgr_destroy(struct buffer_manager *mgr) +pool_bufmgr_destroy(struct pb_manager *mgr) { - struct pool_buffer_manager *pool = pool_buffer_manager(mgr); + struct pool_pb_manager *pool = pool_pb_manager(mgr); _glthread_LOCK_MUTEX(pool->mutex); free(pool->bufs); - buffer_unmap(pool->buffer); - buffer_release(pool->buffer); + pb_unmap(pool->buffer); + pb_destroy(pool->buffer); _glthread_UNLOCK_MUTEX(pool->mutex); @@ -217,16 +210,16 @@ pool_bufmgr_destroy(struct buffer_manager *mgr) } -struct buffer_manager * -pool_bufmgr_create(struct buffer_manager *provider, +struct pb_manager * +pool_bufmgr_create(struct pb_manager *provider, size_t numBufs, size_t bufSize) { - struct pool_buffer_manager *pool; + struct pool_pb_manager *pool; struct pool_buffer *pool_buf; int i; - pool = (struct pool_buffer_manager *)calloc(1, sizeof(*pool)); + pool = (struct pool_pb_manager *)calloc(1, sizeof(*pool)); if (!pool) return NULL; @@ -245,7 +238,7 @@ pool_bufmgr_create(struct buffer_manager *provider, if (!pool->buffer) goto failure; - pool->map = buffer_map(pool->buffer, + pool->map = pb_map(pool->buffer, PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE); if(!pool->map) @@ -270,9 +263,9 @@ failure: if(pool->bufs) free(pool->bufs); if(pool->map) - buffer_unmap(pool->buffer); + pb_unmap(pool->buffer); if(pool->buffer) - buffer_release(pool->buffer); + pb_destroy(pool->buffer); if(pool) free(pool); return NULL; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 8dadd9aa74..cea6b90104 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -135,7 +135,7 @@ static void softpipe_destroy( struct pipe_context *pipe ) for (i = 0; i < Elements(softpipe->constants); i++) { if (softpipe->constants[i].buffer) { - ws->buffer_reference(ws, &softpipe->constants[i].buffer, NULL); + pipe_buffer_reference(ws, &softpipe->constants[i].buffer, NULL); } } diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c index 8ee9177e5b..423c91d4b8 100644 --- a/src/mesa/pipe/softpipe/sp_draw_arrays.c +++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c @@ -88,7 +88,7 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, */ boolean softpipe_draw_elements(struct pipe_context *pipe, - struct pipe_buffer_handle *indexBuffer, + struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count) { diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index bac7b0876f..af955c1e17 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -157,7 +157,7 @@ boolean softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count); boolean softpipe_draw_elements(struct pipe_context *pipe, - struct pipe_buffer_handle *indexBuffer, + struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count); diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index 945c93411f..1430be7869 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -30,6 +30,7 @@ #include "pipe/p_defines.h" #include "pipe/p_util.h" +#include "pipe/p_inlines.h" #include "pipe/p_winsys.h" #include "pipe/draw/draw_context.h" #include "pipe/p_shader_tokens.h" @@ -165,9 +166,9 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, assert(index == 0); /* note: reference counting */ - ws->buffer_reference(ws, - &softpipe->constants[shader].buffer, - buf->buffer); + pipe_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/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c index 23e9c1b376..172234843d 100644 --- a/src/mesa/pipe/softpipe/sp_texture.c +++ b/src/mesa/pipe/softpipe/sp_texture.c @@ -121,7 +121,7 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt) DBG("%s deleting %p\n", __FUNCTION__, (void *) spt); */ - pipe->winsys->buffer_reference(pipe->winsys, &spt->buffer, NULL); + pipe_buffer_reference(pipe->winsys, &spt->buffer, NULL); FREE(spt); } @@ -144,7 +144,7 @@ softpipe_get_tex_surface(struct pipe_context *pipe, if (ps) { assert(ps->refcount); assert(ps->winsys); - pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, spt->buffer); + pipe_buffer_reference(pipe->winsys, &ps->buffer, spt->buffer); ps->format = pt->format; ps->cpp = pt->cpp; ps->width = pt->width[level]; diff --git a/src/mesa/pipe/softpipe/sp_texture.h b/src/mesa/pipe/softpipe/sp_texture.h index 0494bf365b..c6cf370351 100644 --- a/src/mesa/pipe/softpipe/sp_texture.h +++ b/src/mesa/pipe/softpipe/sp_texture.h @@ -41,7 +41,7 @@ struct softpipe_texture /* The data is held here: */ - struct pipe_buffer_handle *buffer; + struct pipe_buffer *buffer; unsigned long buffer_size; }; diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c index cb043ef394..c3cd22eea3 100644 --- a/src/mesa/pipe/xlib/xm_winsys.c +++ b/src/mesa/pipe/xlib/xm_winsys.c @@ -40,6 +40,7 @@ #include "pipe/p_format.h" #include "pipe/p_context.h" #include "pipe/p_util.h" +#include "pipe/p_inlines.h" #include "pipe/softpipe/sp_winsys.h" #ifdef GALLIUM_CELL @@ -57,9 +58,8 @@ */ struct xm_buffer { + struct pipe_buffer base; boolean userBuffer; /** Is this a user-space buffer? */ - int refcount; - unsigned size; void *data; void *mapped; }; @@ -106,63 +106,44 @@ xmesa_softpipe_winsys(struct softpipe_winsys *spws) * buffer pointer... */ static INLINE struct xm_buffer * -xm_bo( struct pipe_buffer_handle *bo ) +xm_buffer( struct pipe_buffer *buf ) { - return (struct xm_buffer *) bo; + return (struct xm_buffer *)buf; } -static INLINE struct pipe_buffer_handle * -pipe_bo( struct xm_buffer *bo ) -{ - return (struct pipe_buffer_handle *) bo; -} /* Most callbacks map direcly onto dri_bufmgr operations: */ static void * -xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf, +xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) { - struct xm_buffer *xm_buf = xm_bo(buf); + struct xm_buffer *xm_buf = xm_buffer(buf); xm_buf->mapped = xm_buf->data; return xm_buf->mapped; } static void -xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf) +xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) { - struct xm_buffer *xm_buf = xm_bo(buf); + struct xm_buffer *xm_buf = xm_buffer(buf); xm_buf->mapped = NULL; } static void -xm_buffer_reference(struct pipe_winsys *pws, - struct pipe_buffer_handle **ptr, - struct pipe_buffer_handle *buf) +xm_buffer_destroy(struct pipe_winsys *pws, + struct pipe_buffer *buf) { - if (*ptr) { - struct xm_buffer *oldBuf = xm_bo(*ptr); - oldBuf->refcount--; - assert(oldBuf->refcount >= 0); - if (oldBuf->refcount == 0) { - if (oldBuf->data) { - if (!oldBuf->userBuffer) - align_free(oldBuf->data); - oldBuf->data = NULL; - } - free(oldBuf); - } - *ptr = NULL; - } + struct xm_buffer *oldBuf = xm_buffer(buf); - assert(!(*ptr)); - - if (buf) { - struct xm_buffer *newBuf = xm_bo(buf); - newBuf->refcount++; - *ptr = buf; + if (oldBuf->data) { + if (!oldBuf->userBuffer) + align_free(oldBuf->data); + oldBuf->data = NULL; } + + free(oldBuf); } @@ -174,7 +155,7 @@ static void xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf) { XImage *ximage = b->tempImage; - struct xm_buffer *xm_buf = xm_bo(surf->buffer); + struct xm_buffer *xm_buf = xm_buffer(surf->buffer); const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE; uint x, y; @@ -214,7 +195,7 @@ void xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf) { XImage *ximage = b->tempImage; - struct xm_buffer *xm_buf = xm_bo(surf->buffer); + struct xm_buffer *xm_buf = xm_buffer(surf->buffer); const struct xmesa_surface *xm_surf = xmesa_surface((struct pipe_surface *) surf); @@ -272,35 +253,38 @@ xm_get_name(struct pipe_winsys *pws) } -static struct pipe_buffer_handle * +static struct pipe_buffer * xm_buffer_create(struct pipe_winsys *pws, unsigned alignment, unsigned usage, unsigned size) { struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - buffer->refcount = 1; + buffer->base.refcount = 1; + buffer->base.alignment = alignment; + buffer->base.usage = usage; + buffer->base.size = size; /* align to 16-byte multiple for Cell */ buffer->data = align_malloc(size, max(alignment, 16)); - buffer->size = size; - return pipe_bo(buffer); + return &buffer->base; } /** * Create buffer which wraps user-space data. */ -static struct pipe_buffer_handle * +static struct pipe_buffer * xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) { struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); + buffer->base.refcount = 1; + buffer->base.size = bytes; buffer->userBuffer = TRUE; - buffer->refcount = 1; buffer->data = ptr; - buffer->size = bytes; - return pipe_bo(buffer); + + return &buffer->base; } @@ -376,7 +360,7 @@ xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s) surf->refcount--; if (surf->refcount == 0) { if (surf->buffer) - winsys->buffer_reference(winsys, &surf->buffer, NULL); + pipe_buffer_reference(winsys, &surf->buffer, NULL); free(surf); } *s = NULL; @@ -407,7 +391,7 @@ xmesa_get_pipe_winsys_aub(void) ws->user_buffer_create = xm_user_buffer_create; ws->buffer_map = xm_buffer_map; ws->buffer_unmap = xm_buffer_unmap; - ws->buffer_reference = xm_buffer_reference; + ws->buffer_destroy = xm_buffer_destroy; ws->surface_alloc = xm_surface_alloc; ws->surface_alloc_storage = xm_surface_alloc_storage; diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.c b/src/mesa/pipe/xlib/xm_winsys_aub.c index 28dd07bc6e..bf41570257 100644 --- a/src/mesa/pipe/xlib/xm_winsys_aub.c +++ b/src/mesa/pipe/xlib/xm_winsys_aub.c @@ -38,6 +38,7 @@ #include "pipe/p_winsys.h" #include "pipe/p_util.h" +#include "pipe/p_inlines.h" #include "pipe/i965simple/brw_winsys.h" #include "brw_aub.h" #include "xm_winsys_aub.h" @@ -79,22 +80,22 @@ aub_pipe_winsys( struct pipe_winsys *winsys ) static INLINE struct aub_buffer * -aub_bo( struct pipe_buffer_handle *bo ) +aub_bo( struct pipe_buffer *bo ) { return (struct aub_buffer *)bo; } -static INLINE struct pipe_buffer_handle * +static INLINE struct pipe_buffer * pipe_bo( struct aub_buffer *bo ) { - return (struct pipe_buffer_handle *)bo; + return (struct pipe_buffer *)bo; } static void *aub_buffer_map(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned flags ) { struct aub_buffer *sbo = aub_bo(buf); @@ -109,7 +110,7 @@ static void *aub_buffer_map(struct pipe_winsys *winsys, } static void aub_buffer_unmap(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf) + struct pipe_buffer *buf) { struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys); struct aub_buffer *sbo = aub_bo(buf); @@ -132,26 +133,15 @@ static void aub_buffer_unmap(struct pipe_winsys *winsys, static void -aub_buffer_reference(struct pipe_winsys *winsys, - struct pipe_buffer_handle **ptr, - struct pipe_buffer_handle *buf) +aub_buffer_destroy(struct pipe_winsys *winsys, + struct pipe_buffer *buf) { - if (*ptr) { - assert(aub_bo(*ptr)->refcount != 0); - if (--(aub_bo(*ptr)->refcount) == 0) - free(*ptr); - *ptr = NULL; - } - - if (buf) { - aub_bo(buf)->refcount++; - *ptr = buf; - } + free(buf); } void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned long offset, unsigned long size, const void *data, @@ -206,7 +196,7 @@ void xmesa_display_aub( /* struct pipe_winsys *winsys, */ /* Pipe has no concept of pools. We choose the tex/region pool * for all buffers. */ -static struct pipe_buffer_handle * +static struct pipe_buffer * aub_buffer_create(struct pipe_winsys *winsys, unsigned alignment, unsigned usage, @@ -231,7 +221,7 @@ aub_buffer_create(struct pipe_winsys *winsys, } -static struct pipe_buffer_handle * +static struct pipe_buffer * aub_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes) { struct aub_buffer *sbo; @@ -312,7 +302,7 @@ aub_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s) surf->refcount--; if (surf->refcount == 0) { if (surf->buffer) - winsys->buffer_reference(winsys, &surf->buffer, NULL); + pipe_buffer_reference(winsys, &surf->buffer, NULL); free(surf); } *s = NULL; @@ -351,7 +341,7 @@ xmesa_create_pipe_winsys_aub( void ) iws->winsys.user_buffer_create = aub_user_buffer_create; iws->winsys.buffer_map = aub_buffer_map; iws->winsys.buffer_unmap = aub_buffer_unmap; - iws->winsys.buffer_reference = aub_buffer_reference; + iws->winsys.buffer_destroy = aub_buffer_destroy; iws->winsys.flush_frontbuffer = aub_flush_frontbuffer; iws->winsys.printf = aub_printf; iws->winsys.get_name = aub_get_name; @@ -439,7 +429,7 @@ static void aub_i965_batch_dword( struct brw_winsys *sws, } static void aub_i965_batch_reloc( struct brw_winsys *sws, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned access_flags, unsigned delta ) { @@ -450,7 +440,7 @@ static void aub_i965_batch_reloc( struct brw_winsys *sws, } static unsigned aub_i965_get_buffer_offset( struct brw_winsys *sws, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned access_flags ) { return aub_bo(buf)->offset; @@ -482,7 +472,7 @@ static void aub_i965_batch_flush( struct brw_winsys *sws, static void aub_i965_buffer_subdata_typed(struct brw_winsys *winsys, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned long offset, unsigned long size, const void *data, diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.h b/src/mesa/pipe/xlib/xm_winsys_aub.h index c0fe449107..7bee199116 100644 --- a/src/mesa/pipe/xlib/xm_winsys_aub.h +++ b/src/mesa/pipe/xlib/xm_winsys_aub.h @@ -30,7 +30,7 @@ struct pipe_context; struct pipe_winsys; -struct pipe_buffer_handle; +struct pipe_buffer; struct pipe_surface; struct pipe_winsys * @@ -47,7 +47,7 @@ xmesa_create_i965simple( struct pipe_winsys *winsys ); void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys, - struct pipe_buffer_handle *buf, + struct pipe_buffer *buf, unsigned long offset, unsigned long size, const void *data, diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index c9d63136b5..21416da2e0 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -37,6 +37,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" +#include "pipe/p_inlines.h" #include "st_context.h" #include "st_atom.h" @@ -70,7 +71,7 @@ void st_upload_constants( struct st_context *st, _mesa_load_state_parameters(st->ctx, params); if (cbuf->buffer && cbuf->size != paramBytes) - ws->buffer_reference( ws, &cbuf->buffer, NULL ); + pipe_buffer_reference( ws, &cbuf->buffer, NULL ); if (!cbuf->buffer) { cbuf->buffer = ws->buffer_create(ws, 1, PIPE_BUFFER_USAGE_CONSTANT, diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 60bd1d5f0d..fa1254ff7c 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -36,6 +36,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" +#include "pipe/p_inlines.h" @@ -78,7 +79,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_reference(pipe->winsys, &st_obj->buffer, NULL); + pipe_buffer_reference(pipe->winsys, &st_obj->buffer, NULL); free(st_obj); } @@ -173,7 +174,7 @@ st_bufferobj_data(GLcontext *ctx, buffer_usage = 0; } - pipe->winsys->buffer_reference( pipe->winsys, &st_obj->buffer, NULL ); + pipe_buffer_reference( pipe->winsys, &st_obj->buffer, NULL ); st_obj->buffer = pipe->winsys->buffer_create( pipe->winsys, 32, buffer_usage, size ); diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h b/src/mesa/state_tracker/st_cb_bufferobjects.h index 15003ae15d..dcbb5a5233 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.h +++ b/src/mesa/state_tracker/st_cb_bufferobjects.h @@ -30,7 +30,7 @@ struct st_context; struct gl_buffer_object; -struct pipe_buffer_handle; +struct pipe_buffer; /** * State_tracker vertex/pixel buffer object, derived from Mesa's @@ -39,7 +39,7 @@ struct pipe_buffer_handle; struct st_buffer_object { struct gl_buffer_object Base; - struct pipe_buffer_handle *buffer; + struct pipe_buffer *buffer; GLsizeiptrARB size; }; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index f02cb3d133..4341623267 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -100,8 +100,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, } if (strb->surface->buffer) - pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer, - NULL); + pipe_buffer_reference(pipe->winsys, &strb->surface->buffer, + NULL); /* Determine surface format here */ if (strb->format != PIPE_FORMAT_NONE) { diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 668ac139f7..9c206c057a 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -52,6 +52,7 @@ #include "st_program.h" #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" @@ -152,7 +153,7 @@ static void st_destroy_context_priv( struct st_context *st ) for (i = 0; i < Elements(st->state.constants); i++) { if (st->state.constants[i].buffer) { - ws->buffer_reference(ws, &st->state.constants[i].buffer, NULL); + pipe_buffer_reference(ws, &st->state.constants[i].buffer, NULL); } } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 371d4e7966..8ef50ee768 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -45,6 +45,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" +#include "pipe/p_inlines.h" #include "pipe/draw/draw_private.h" #include "pipe/draw/draw_context.h" @@ -237,7 +238,7 @@ st_draw_vbo(GLcontext *ctx, assert(stobj->buffer); vbuffer[attr].buffer = NULL; - winsys->buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); + pipe_buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ velement.src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; assert(velement.src_offset <= 2048); /* 11-bit field */ @@ -282,7 +283,7 @@ st_draw_vbo(GLcontext *ctx, if (ib) { /* indexed primitive */ struct gl_buffer_object *bufobj = ib->obj; - struct pipe_buffer_handle *indexBuf = NULL; + struct pipe_buffer *indexBuf = NULL; unsigned indexSize, indexOffset, i; switch (ib->type) { @@ -303,7 +304,7 @@ st_draw_vbo(GLcontext *ctx, if (bufobj && bufobj->Name) { /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); - winsys->buffer_reference(winsys, &indexBuf, stobj->buffer); + pipe_buffer_reference(winsys, &indexBuf, stobj->buffer); indexOffset = (unsigned) ib->ptr / indexSize; } else { @@ -321,7 +322,7 @@ st_draw_vbo(GLcontext *ctx, prims[i].start + indexOffset, prims[i].count); } - winsys->buffer_reference(winsys, &indexBuf, NULL); + pipe_buffer_reference(winsys, &indexBuf, NULL); } else { /* non-indexed */ @@ -333,7 +334,7 @@ st_draw_vbo(GLcontext *ctx, /* unreference buffers (frees wrapped user-space buffer objects) */ for (attr = 0; attr < vs->num_inputs; attr++) { - winsys->buffer_reference(winsys, &vbuffer[attr].buffer, NULL); + pipe_buffer_reference(winsys, &vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); pipe->set_vertex_buffer(pipe, attr, &vbuffer[attr]); } @@ -358,7 +359,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, const float height = ctx->DrawBuffer->Height; const unsigned vertex_bytes = numVertex * numAttribs * 4 * sizeof(float); struct pipe_context *pipe = ctx->st->pipe; - struct pipe_buffer_handle *vbuf; + struct pipe_buffer *vbuf; struct pipe_vertex_buffer vbuffer; struct pipe_vertex_element velement; unsigned i; @@ -404,7 +405,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, pipe->draw_arrays(pipe, prim, 0, numVertex); /* XXX: do one-time */ - pipe->winsys->buffer_reference(pipe->winsys, &vbuf, NULL); + pipe_buffer_reference(pipe->winsys, &vbuf, NULL); } @@ -465,7 +466,7 @@ st_feedback_draw_vbo(GLcontext *ctx, struct pipe_winsys *winsys = pipe->winsys; const struct st_vertex_program *vp; const struct pipe_shader_state *vs; - struct pipe_buffer_handle *index_buffer_handle = 0; + struct pipe_buffer *index_buffer_handle = 0; struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; GLuint attr, i; ubyte *mapped_constants; @@ -513,7 +514,7 @@ st_feedback_draw_vbo(GLcontext *ctx, assert(stobj->buffer); vbuffer[attr].buffer = NULL; - winsys->buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); + pipe_buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ velement.src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; } @@ -605,7 +606,7 @@ st_feedback_draw_vbo(GLcontext *ctx, if (draw->vertex_buffer[i].buffer) { pipe->winsys->buffer_unmap(pipe->winsys, draw->vertex_buffer[i].buffer); - winsys->buffer_reference(winsys, &draw->vertex_buffer[i].buffer, NULL); + pipe_buffer_reference(winsys, &draw->vertex_buffer[i].buffer, NULL); draw_set_mapped_vertex_buffer(draw, i, NULL); } } -- cgit v1.2.3 From c185c55aec8c6d0e47a2d7b84acf7d063acfce61 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 29 Jan 2008 12:37:07 +0000 Subject: gallium: don't rely on assert(0) for error handling - may be disabled --- src/mesa/state_tracker/st_draw.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 8ef50ee768..c9b8e78485 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -298,6 +298,7 @@ st_draw_vbo(GLcontext *ctx, break; default: assert(0); + return; } /* get/create the index buffer object */ @@ -570,6 +571,7 @@ st_feedback_draw_vbo(GLcontext *ctx, break; default: assert(0); + return; } map = pipe->winsys->buffer_map(pipe->winsys, -- cgit v1.2.3 From 0b64ee6960f9e099bc1a6ca6fa10720fee875b3a Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 8 Feb 2008 14:51:32 -0700 Subject: gallium: added inClipCoords param to st_draw_vertices() to indicate coord system of vertices Also, export st_make_passthrough_vertex_shader() from st_cb_drawpixels.c --- src/mesa/state_tracker/st_cb_clear.c | 2 +- src/mesa/state_tracker/st_cb_drawpixels.c | 18 +++++++++--------- src/mesa/state_tracker/st_cb_drawpixels.h | 4 ++++ src/mesa/state_tracker/st_draw.c | 21 ++++++++++++--------- src/mesa/state_tracker/st_draw.h | 3 ++- 5 files changed, 28 insertions(+), 20 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 0cd469c156..ab98b54bab 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -251,7 +251,7 @@ draw_quad(GLcontext *ctx, verts[i][1][3] = color[3]; } - st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, GL_FALSE); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 34d420fcff..07886e7982 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -355,8 +355,8 @@ make_fragment_shader_z(struct st_context *st) * Create a simple vertex shader that just passes through the * vertex position and texcoord (and optionally, color). */ -static struct st_vertex_program * -make_vertex_shader(struct st_context *st, GLboolean passColor) +struct st_vertex_program * +st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor) { /* only make programs once and re-use */ static struct st_vertex_program *progs[2] = { NULL, NULL }; @@ -572,7 +572,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, verts[i][1][3] = 1.0; /*Q*/ } - st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, GL_FALSE); } @@ -625,7 +625,7 @@ draw_quad_colored(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, verts[i][2][3] = 1.0; /*Q*/ } - st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 3); + st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 3, GL_FALSE); } @@ -945,7 +945,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, if (format == GL_DEPTH_COMPONENT) { ps = st->state.framebuffer.zsbuf; stfp = make_fragment_shader_z(ctx->st); - stvp = make_vertex_shader(ctx->st, GL_TRUE); + stvp = st_make_passthrough_vertex_shader(ctx->st, GL_TRUE); color = ctx->Current.RasterColor; } else if (format == GL_STENCIL_INDEX) { @@ -956,7 +956,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, else { ps = st->state.framebuffer.cbufs[0]; stfp = combined_drawpix_fragment_program(ctx); - stvp = make_vertex_shader(ctx->st, GL_FALSE); + stvp = st_make_passthrough_vertex_shader(ctx->st, GL_FALSE); color = NULL; } @@ -1111,7 +1111,7 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, struct st_context *st = ctx->st; struct pipe_texture *pt; - stvp = make_vertex_shader(ctx->st, GL_TRUE); + stvp = st_make_passthrough_vertex_shader(ctx->st, GL_TRUE); stfp = combined_bitmap_fragment_program(ctx); st_validate_state(st); @@ -1229,13 +1229,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, rbRead = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); color = NULL; stfp = combined_drawpix_fragment_program(ctx); - stvp = make_vertex_shader(ctx->st, GL_FALSE); + stvp = st_make_passthrough_vertex_shader(ctx->st, GL_FALSE); } else { rbRead = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer); color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; stfp = make_fragment_shader_z(ctx->st); - stvp = make_vertex_shader(ctx->st, GL_TRUE); + stvp = st_make_passthrough_vertex_shader(ctx->st, GL_TRUE); } psRead = rbRead->surface; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.h b/src/mesa/state_tracker/st_cb_drawpixels.h index 71ba487020..b8b906f06b 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.h +++ b/src/mesa/state_tracker/st_cb_drawpixels.h @@ -30,6 +30,10 @@ #define ST_CB_DRAWPIXELS_H +extern struct st_vertex_program * +st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor); + + extern void st_init_drawpixels_functions(struct dd_function_table *functions); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index c9b8e78485..ae9f5c8b11 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -354,7 +354,8 @@ st_draw_vbo(GLcontext *ctx, void st_draw_vertices(GLcontext *ctx, unsigned prim, unsigned numVertex, float *verts, - unsigned numAttribs) + unsigned numAttribs, + GLboolean inClipCoords) { const float width = ctx->DrawBuffer->Width; const float height = ctx->DrawBuffer->Height; @@ -367,14 +368,16 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, assert(numAttribs > 0); - /* convert to clip coords */ - for (i = 0; i < numVertex; i++) { - float x = verts[i * numAttribs * 4 + 0]; - float y = verts[i * numAttribs * 4 + 1]; - x = x / width * 2.0 - 1.0; - y = y / height * 2.0 - 1.0; - verts[i * numAttribs * 4 + 0] = x; - verts[i * numAttribs * 4 + 1] = y; + if (!inClipCoords) { + /* convert to clip coords */ + for (i = 0; i < numVertex; i++) { + float x = verts[i * numAttribs * 4 + 0]; + float y = verts[i * numAttribs * 4 + 1]; + x = x / width * 2.0 - 1.0; + y = y / height * 2.0 - 1.0; + verts[i * numAttribs * 4 + 0] = x; + verts[i * numAttribs * 4 + 1] = y; + } } /* XXX create one-time */ diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index 89ee790c57..171bde57e5 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -62,7 +62,8 @@ st_feedback_draw_vbo(GLcontext *ctx, void st_draw_vertices(GLcontext *ctx, unsigned prim, unsigned numVertex, float *verts, - unsigned numAttribs); + unsigned numAttribs, + GLboolean inClipCoords); #endif -- 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_draw.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 339e7ec6805e6de8794514c0a935081b5d36d38f Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 11 Mar 2008 18:54:31 -0600 Subject: gallium: rework CSO-related code in state tracker Use the code in cso_context.c rather than st_cache.c. Basically, binding of state objects now goes through the CSO module. But Vertex/fragment shaders go through pipe->bind_fs/vs_state() since they're not cached by the CSO module at this time. Also, update softpipe driver to handle NULL state objects in various places. This happens during context destruction. May need to update other drivers... --- src/gallium/auxiliary/draw/draw_aaline.c | 3 +- src/gallium/auxiliary/draw/draw_aapoint.c | 3 +- src/gallium/auxiliary/draw/draw_pstipple.c | 3 +- src/gallium/drivers/softpipe/sp_state_fs.c | 3 +- src/mesa/sources | 1 - src/mesa/state_tracker/st_atom_blend.c | 52 ++++++-------- src/mesa/state_tracker/st_atom_depth.c | 60 +++++++--------- src/mesa/state_tracker/st_atom_rasterizer.c | 108 ++++++++++++++-------------- src/mesa/state_tracker/st_atom_sampler.c | 43 ++++++----- src/mesa/state_tracker/st_atom_shader.c | 28 ++------ src/mesa/state_tracker/st_cb_accum.c | 1 - src/mesa/state_tracker/st_cb_clear.c | 47 ++++++------ src/mesa/state_tracker/st_cb_drawpixels.c | 64 +++++++++-------- src/mesa/state_tracker/st_cb_program.c | 5 +- src/mesa/state_tracker/st_context.c | 9 ++- src/mesa/state_tracker/st_context.h | 19 ++--- src/mesa/state_tracker/st_debug.c | 6 +- src/mesa/state_tracker/st_draw.c | 13 ++-- src/mesa/state_tracker/st_gen_mipmap.c | 34 ++++----- src/mesa/state_tracker/st_mesa_to_tgsi.c | 5 +- src/mesa/state_tracker/st_mesa_to_tgsi.h | 2 +- src/mesa/state_tracker/st_program.c | 59 +++++++++------ src/mesa/state_tracker/st_program.h | 22 ++---- 23 files changed, 292 insertions(+), 298 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/draw/draw_aaline.c b/src/gallium/auxiliary/draw/draw_aaline.c index 3ec73b0800..6b1e640ae9 100644 --- a/src/gallium/auxiliary/draw/draw_aaline.c +++ b/src/gallium/auxiliary/draw/draw_aaline.c @@ -733,7 +733,8 @@ aaline_bind_fs_state(struct pipe_context *pipe, void *fs) /* save current */ aaline->fs = aafs; /* pass-through */ - aaline->driver_bind_fs_state(aaline->pipe, aafs->driver_fs); + aaline->driver_bind_fs_state(aaline->pipe, + (aafs ? aafs->driver_fs : NULL)); } diff --git a/src/gallium/auxiliary/draw/draw_aapoint.c b/src/gallium/auxiliary/draw/draw_aapoint.c index 70f696475f..99e9e9fe34 100644 --- a/src/gallium/auxiliary/draw/draw_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_aapoint.c @@ -800,7 +800,8 @@ aapoint_bind_fs_state(struct pipe_context *pipe, void *fs) /* save current */ aapoint->fs = aafs; /* pass-through */ - aapoint->driver_bind_fs_state(aapoint->pipe, aafs->driver_fs); + aapoint->driver_bind_fs_state(aapoint->pipe, + (aafs ? aafs->driver_fs : NULL)); } diff --git a/src/gallium/auxiliary/draw/draw_pstipple.c b/src/gallium/auxiliary/draw/draw_pstipple.c index b3e52dc1c7..ed50d0805a 100644 --- a/src/gallium/auxiliary/draw/draw_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pstipple.c @@ -595,7 +595,8 @@ pstip_bind_fs_state(struct pipe_context *pipe, void *fs) /* save current */ pstip->fs = aafs; /* pass-through */ - pstip->driver_bind_fs_state(pstip->pipe, aafs->driver_fs); + pstip->driver_bind_fs_state(pstip->pipe, + (aafs ? aafs->driver_fs : NULL)); } diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index eb641ed321..4eefd1d61f 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -120,7 +120,8 @@ softpipe_bind_vs_state(struct pipe_context *pipe, void *vs) softpipe->vs = (const struct sp_vertex_shader *)vs; - draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data); + draw_bind_vertex_shader(softpipe->draw, + (softpipe->vs ? softpipe->vs->draw_data : NULL)); softpipe->dirty |= SP_NEW_VS; } diff --git a/src/mesa/sources b/src/mesa/sources index f0bf7b31fb..e3d5f22849 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -184,7 +184,6 @@ STATETRACKER_SOURCES = \ state_tracker/st_cb_readpixels.c \ state_tracker/st_cb_strings.c \ state_tracker/st_cb_texture.c \ - state_tracker/st_cache.c \ state_tracker/st_context.c \ state_tracker/st_debug.c \ state_tracker/st_draw.c \ diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 2a9d209153..6c13fc8141 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -33,11 +33,11 @@ #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "cso_cache/cso_context.h" /** @@ -155,44 +155,43 @@ translate_logicop(GLenum logicop) static void update_blend( struct st_context *st ) { - struct pipe_blend_state blend; - const struct cso_blend *cso; + struct pipe_blend_state *blend = &st->state.blend; - memset(&blend, 0, sizeof(blend)); + memset(blend, 0, sizeof(*blend)); if (st->ctx->Color.ColorLogicOpEnabled || (st->ctx->Color.BlendEnabled && st->ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) { /* logicop enabled */ - blend.logicop_enable = 1; - blend.logicop_func = translate_logicop(st->ctx->Color.LogicOp); + blend->logicop_enable = 1; + blend->logicop_func = translate_logicop(st->ctx->Color.LogicOp); } else if (st->ctx->Color.BlendEnabled) { /* blending enabled */ - blend.blend_enable = 1; + blend->blend_enable = 1; - blend.rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB); + blend->rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB); if (st->ctx->Color.BlendEquationRGB == GL_MIN || st->ctx->Color.BlendEquationRGB == GL_MAX) { /* Min/max are special */ - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ONE; + blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rgb_dst_factor = PIPE_BLENDFACTOR_ONE; } else { - blend.rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB); - blend.rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB); + blend->rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB); + blend->rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB); } - blend.alpha_func = translate_blend(st->ctx->Color.BlendEquationA); + blend->alpha_func = translate_blend(st->ctx->Color.BlendEquationA); if (st->ctx->Color.BlendEquationA == GL_MIN || st->ctx->Color.BlendEquationA == GL_MAX) { /* Min/max are special */ - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ONE; + blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend->alpha_dst_factor = PIPE_BLENDFACTOR_ONE; } else { - blend.alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA); - blend.alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA); + blend->alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA); + blend->alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA); } } else { @@ -201,25 +200,18 @@ update_blend( struct st_context *st ) /* Colormask - maybe reverse these bits? */ if (st->ctx->Color.ColorMask[0]) - blend.colormask |= PIPE_MASK_R; + blend->colormask |= PIPE_MASK_R; if (st->ctx->Color.ColorMask[1]) - blend.colormask |= PIPE_MASK_G; + blend->colormask |= PIPE_MASK_G; if (st->ctx->Color.ColorMask[2]) - blend.colormask |= PIPE_MASK_B; + blend->colormask |= PIPE_MASK_B; if (st->ctx->Color.ColorMask[3]) - blend.colormask |= PIPE_MASK_A; + blend->colormask |= PIPE_MASK_A; if (st->ctx->Color.DitherFlag) - blend.dither = 1; + blend->dither = 1; - cso = st_cached_blend_state(st, &blend); - - if (st->state.blend != cso) { - /* state has changed */ - st->state.blend = cso; - /* bind new state */ - st->pipe->bind_blend_state(st->pipe, cso->data); - } + cso_set_blend(st->cso_context, blend); if (memcmp(st->ctx->Color.BlendColor, &st->state.blend_color, 4 * sizeof(GLfloat)) != 0) { /* state has changed */ diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index 7aecdbfbcc..827ad3b548 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -34,10 +34,10 @@ #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "cso_cache/cso_context.h" /** @@ -93,53 +93,47 @@ gl_stencil_op_to_pipe(GLenum func) static void update_depth_stencil_alpha(struct st_context *st) { - struct pipe_depth_stencil_alpha_state depth_stencil; - const struct cso_depth_stencil_alpha *cso; + struct pipe_depth_stencil_alpha_state *dsa = &st->state.depth_stencil; - memset(&depth_stencil, 0, sizeof(depth_stencil)); + memset(dsa, 0, sizeof(*dsa)); - depth_stencil.depth.enabled = st->ctx->Depth.Test; - depth_stencil.depth.writemask = st->ctx->Depth.Mask; - depth_stencil.depth.func = st_compare_func_to_pipe(st->ctx->Depth.Func); + dsa->depth.enabled = st->ctx->Depth.Test; + dsa->depth.writemask = st->ctx->Depth.Mask; + dsa->depth.func = st_compare_func_to_pipe(st->ctx->Depth.Func); if (st->ctx->Query.CurrentOcclusionObject && st->ctx->Query.CurrentOcclusionObject->Active) - depth_stencil.depth.occlusion_count = 1; + dsa->depth.occlusion_count = 1; if (st->ctx->Stencil.Enabled) { - depth_stencil.stencil[0].enabled = 1; - depth_stencil.stencil[0].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]); - depth_stencil.stencil[0].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]); - depth_stencil.stencil[0].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]); - depth_stencil.stencil[0].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]); - depth_stencil.stencil[0].ref_value = st->ctx->Stencil.Ref[0] & 0xff; - depth_stencil.stencil[0].value_mask = st->ctx->Stencil.ValueMask[0] & 0xff; - depth_stencil.stencil[0].write_mask = st->ctx->Stencil.WriteMask[0] & 0xff; + dsa->stencil[0].enabled = 1; + dsa->stencil[0].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]); + dsa->stencil[0].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]); + dsa->stencil[0].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]); + dsa->stencil[0].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]); + dsa->stencil[0].ref_value = st->ctx->Stencil.Ref[0] & 0xff; + dsa->stencil[0].value_mask = st->ctx->Stencil.ValueMask[0] & 0xff; + dsa->stencil[0].write_mask = st->ctx->Stencil.WriteMask[0] & 0xff; if (st->ctx->Stencil.TestTwoSide) { - depth_stencil.stencil[1].enabled = 1; - depth_stencil.stencil[1].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]); - depth_stencil.stencil[1].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]); - depth_stencil.stencil[1].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]); - depth_stencil.stencil[1].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]); - depth_stencil.stencil[1].ref_value = st->ctx->Stencil.Ref[1] & 0xff; - depth_stencil.stencil[1].value_mask = st->ctx->Stencil.ValueMask[1] & 0xff; - depth_stencil.stencil[1].write_mask = st->ctx->Stencil.WriteMask[1] & 0xff; + dsa->stencil[1].enabled = 1; + dsa->stencil[1].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]); + dsa->stencil[1].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]); + dsa->stencil[1].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]); + dsa->stencil[1].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]); + dsa->stencil[1].ref_value = st->ctx->Stencil.Ref[1] & 0xff; + dsa->stencil[1].value_mask = st->ctx->Stencil.ValueMask[1] & 0xff; + dsa->stencil[1].write_mask = st->ctx->Stencil.WriteMask[1] & 0xff; } } if (st->ctx->Color.AlphaEnabled) { - depth_stencil.alpha.enabled = 1; - depth_stencil.alpha.func = st_compare_func_to_pipe(st->ctx->Color.AlphaFunc); - depth_stencil.alpha.ref = st->ctx->Color.AlphaRef; + dsa->alpha.enabled = 1; + dsa->alpha.func = st_compare_func_to_pipe(st->ctx->Color.AlphaFunc); + dsa->alpha.ref = st->ctx->Color.AlphaRef; } - cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil); - if (st->state.depth_stencil != cso) { - /* state has changed */ - st->state.depth_stencil = cso; - st->pipe->bind_depth_stencil_alpha_state(st->pipe, cso->data); /* bind new state */ - } + cso_set_depth_stencil_alpha(st->cso_context, dsa); } diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 229839d8b2..77cef9236b 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -32,10 +32,11 @@ #include "main/macros.h" #include "st_context.h" -#include "st_cache.h" +#include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "st_atom.h" +#include "cso_cache/cso_context.h" + static GLuint translate_fill( GLenum mode ) { @@ -72,22 +73,21 @@ static GLboolean get_offset_flag( GLuint fill_mode, static void update_raster_state( struct st_context *st ) { GLcontext *ctx = st->ctx; - struct pipe_rasterizer_state raster; - const struct cso_rasterizer *cso; + struct pipe_rasterizer_state *raster = &st->state.rasterizer; const struct gl_vertex_program *vertProg = ctx->VertexProgram._Current; uint i; - memset(&raster, 0, sizeof(raster)); + memset(raster, 0, sizeof(*raster)); - raster.origin_lower_left = 1; /* Always true for OpenGL */ + raster->origin_lower_left = 1; /* Always true for OpenGL */ /* _NEW_POLYGON, _NEW_BUFFERS */ { if (ctx->Polygon.FrontFace == GL_CCW) - raster.front_winding = PIPE_WINDING_CCW; + raster->front_winding = PIPE_WINDING_CCW; else - raster.front_winding = PIPE_WINDING_CW; + raster->front_winding = PIPE_WINDING_CW; /* XXX * I think the intention here is that user-created framebuffer objects @@ -96,13 +96,13 @@ static void update_raster_state( struct st_context *st ) * But this is an implementation/driver-specific artifact - remove... */ if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) - raster.front_winding ^= PIPE_WINDING_BOTH; + raster->front_winding ^= PIPE_WINDING_BOTH; } /* _NEW_LIGHT */ if (ctx->Light.ShadeModel == GL_FLAT) - raster.flatshade = 1; + raster->flatshade = 1; /* _NEW_LIGHT | _NEW_PROGRAM * @@ -113,28 +113,28 @@ static void update_raster_state( struct st_context *st ) if (ctx->VertexProgram._Current) { if (ctx->VertexProgram._Enabled) { /* user-defined program */ - raster.light_twoside = ctx->VertexProgram.TwoSideEnabled; + raster->light_twoside = ctx->VertexProgram.TwoSideEnabled; } else { /* TNL-generated program */ - raster.light_twoside = ctx->Light.Enabled && ctx->Light.Model.TwoSide; + raster->light_twoside = ctx->Light.Enabled && ctx->Light.Model.TwoSide; } } else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { - raster.light_twoside = 1; + raster->light_twoside = 1; } /* _NEW_POLYGON */ if (ctx->Polygon.CullFlag) { if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - raster.cull_mode = PIPE_WINDING_BOTH; + raster->cull_mode = PIPE_WINDING_BOTH; } else if (ctx->Polygon.CullFaceMode == GL_FRONT) { - raster.cull_mode = raster.front_winding; + raster->cull_mode = raster->front_winding; } else { - raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; + raster->cull_mode = raster->front_winding ^ PIPE_WINDING_BOTH; } } @@ -144,23 +144,23 @@ static void update_raster_state( struct st_context *st ) GLuint fill_front = translate_fill( ctx->Polygon.FrontMode ); GLuint fill_back = translate_fill( ctx->Polygon.BackMode ); - if (raster.front_winding == PIPE_WINDING_CW) { - raster.fill_cw = fill_front; - raster.fill_ccw = fill_back; + if (raster->front_winding == PIPE_WINDING_CW) { + raster->fill_cw = fill_front; + raster->fill_ccw = fill_back; } else { - raster.fill_cw = fill_back; - raster.fill_ccw = fill_front; + raster->fill_cw = fill_back; + raster->fill_ccw = fill_front; } /* Simplify when culling is active: */ - if (raster.cull_mode & PIPE_WINDING_CW) { - raster.fill_cw = raster.fill_ccw; + if (raster->cull_mode & PIPE_WINDING_CW) { + raster->fill_cw = raster->fill_ccw; } - if (raster.cull_mode & PIPE_WINDING_CCW) { - raster.fill_ccw = raster.fill_cw; + if (raster->cull_mode & PIPE_WINDING_CCW) { + raster->fill_ccw = raster->fill_cw; } } @@ -168,95 +168,91 @@ static void update_raster_state( struct st_context *st ) */ if (ctx->Polygon.OffsetUnits != 0.0 || ctx->Polygon.OffsetFactor != 0.0) { - raster.offset_cw = get_offset_flag( raster.fill_cw, &ctx->Polygon ); - raster.offset_ccw = get_offset_flag( raster.fill_ccw, &ctx->Polygon ); - raster.offset_units = ctx->Polygon.OffsetUnits; - raster.offset_scale = ctx->Polygon.OffsetFactor; + raster->offset_cw = get_offset_flag( raster->fill_cw, &ctx->Polygon ); + raster->offset_ccw = get_offset_flag( raster->fill_ccw, &ctx->Polygon ); + raster->offset_units = ctx->Polygon.OffsetUnits; + raster->offset_scale = ctx->Polygon.OffsetFactor; } if (ctx->Polygon.SmoothFlag) - raster.poly_smooth = 1; + raster->poly_smooth = 1; if (ctx->Polygon.StippleFlag) - raster.poly_stipple_enable = 1; + raster->poly_stipple_enable = 1; /* _NEW_BUFFERS, _NEW_POLYGON */ - if (raster.fill_cw != PIPE_POLYGON_MODE_FILL || - raster.fill_ccw != PIPE_POLYGON_MODE_FILL) + if (raster->fill_cw != PIPE_POLYGON_MODE_FILL || + raster->fill_ccw != PIPE_POLYGON_MODE_FILL) { GLfloat mrd = (ctx->DrawBuffer ? ctx->DrawBuffer->_MRD : 1.0); - raster.offset_units = ctx->Polygon.OffsetFactor * mrd; - raster.offset_scale = (ctx->Polygon.OffsetUnits * mrd * + raster->offset_units = ctx->Polygon.OffsetFactor * mrd; + raster->offset_scale = (ctx->Polygon.OffsetUnits * mrd * st->polygon_offset_scale); } /* _NEW_POINT */ - raster.point_size = ctx->Point.Size; - raster.point_smooth = ctx->Point.SmoothFlag; - raster.point_sprite = ctx->Point.PointSprite; + raster->point_size = ctx->Point.Size; + raster->point_smooth = ctx->Point.SmoothFlag; + raster->point_sprite = ctx->Point.PointSprite; for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { if (ctx->Point.CoordReplace[i]) { if (ctx->Point.SpriteOrigin == GL_UPPER_LEFT) - raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_UPPER_LEFT; + raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_UPPER_LEFT; else - raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_LOWER_LEFT; + raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_LOWER_LEFT; } else { - raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE; + raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE; } } if (vertProg) { if (vertProg->Base.Id == 0) { if (vertProg->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { /* generated program which emits point size */ - raster.point_size_per_vertex = TRUE; + raster->point_size_per_vertex = TRUE; } } else if (ctx->VertexProgram.PointSizeEnabled) { /* user-defined program and GL_VERTEX_PROGRAM_POINT_SIZE set */ - raster.point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled; + raster->point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled; } } /* _NEW_LINE */ - raster.line_smooth = ctx->Line.SmoothFlag; + raster->line_smooth = ctx->Line.SmoothFlag; if (ctx->Line.SmoothFlag) { - raster.line_width = CLAMP(ctx->Line.Width, + raster->line_width = CLAMP(ctx->Line.Width, ctx->Const.MinLineWidthAA, ctx->Const.MaxLineWidthAA); } else { - raster.line_width = CLAMP(ctx->Line.Width, + raster->line_width = CLAMP(ctx->Line.Width, ctx->Const.MinLineWidth, ctx->Const.MaxLineWidth); } - raster.line_stipple_enable = ctx->Line.StippleFlag; - raster.line_stipple_pattern = ctx->Line.StipplePattern; + raster->line_stipple_enable = ctx->Line.StippleFlag; + raster->line_stipple_pattern = ctx->Line.StipplePattern; /* GL stipple factor is in [1,256], remap to [0, 255] here */ - raster.line_stipple_factor = ctx->Line.StippleFactor - 1; + raster->line_stipple_factor = ctx->Line.StippleFactor - 1; /* _NEW_MULTISAMPLE */ if (ctx->Multisample.Enabled) - raster.multisample = 1; + raster->multisample = 1; /* _NEW_SCISSOR */ if (ctx->Scissor.Enabled) - raster.scissor = 1; + raster->scissor = 1; - cso = st_cached_rasterizer_state(st, &raster); - if (st->state.rasterizer != cso) { - st->state.rasterizer = cso; - st->pipe->bind_rasterizer_state(st->pipe, cso->data); - } + cso_set_rasterizer(st->cso_context, raster); } const struct st_tracked_state st_update_rasterizer = { diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 1000f98ffc..1babba9b4f 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -33,11 +33,11 @@ #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "st_program.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "cso_cache/cso_context.h" /** @@ -124,9 +124,9 @@ update_samplers(struct st_context *st) /* loop over sampler units (aka tex image units) */ for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) { - struct pipe_sampler_state sampler; + struct pipe_sampler_state *sampler = st->state.samplers + su; - memset(&sampler, 0, sizeof(sampler)); + memset(sampler, 0, sizeof(*sampler)); if (fs->Base.Base.SamplersUsed & (1 << su)) { GLuint texUnit = fs->Base.Base.SamplerUnits[su]; @@ -135,37 +135,37 @@ update_samplers(struct st_context *st) assert(texobj); - sampler.wrap_s = gl_wrap_to_sp(texobj->WrapS); - sampler.wrap_t = gl_wrap_to_sp(texobj->WrapT); - sampler.wrap_r = gl_wrap_to_sp(texobj->WrapR); + sampler->wrap_s = gl_wrap_to_sp(texobj->WrapS); + sampler->wrap_t = gl_wrap_to_sp(texobj->WrapT); + sampler->wrap_r = gl_wrap_to_sp(texobj->WrapR); - sampler.min_img_filter = gl_filter_to_img_filter(texobj->MinFilter); - sampler.min_mip_filter = gl_filter_to_mip_filter(texobj->MinFilter); - sampler.mag_img_filter = gl_filter_to_img_filter(texobj->MagFilter); + sampler->min_img_filter = gl_filter_to_img_filter(texobj->MinFilter); + sampler->min_mip_filter = gl_filter_to_mip_filter(texobj->MinFilter); + sampler->mag_img_filter = gl_filter_to_img_filter(texobj->MagFilter); if (texobj->Target != GL_TEXTURE_RECTANGLE_ARB) - sampler.normalized_coords = 1; + sampler->normalized_coords = 1; - sampler.lod_bias = st->ctx->Texture.Unit[su].LodBias; + sampler->lod_bias = st->ctx->Texture.Unit[su].LodBias; #if 1 - sampler.min_lod = (texobj->MinLod) < 0.0 ? 0.0 : texobj->MinLod; - sampler.max_lod = texobj->MaxLod; + sampler->min_lod = (texobj->MinLod) < 0.0 ? 0.0 : texobj->MinLod; + sampler->max_lod = texobj->MaxLod; #else /* min/max lod should really be as follows (untested). * Also, calculate_first_last_level() needs to be overhauled * since today's hardware had real support for LOD clamping. */ - sampler.min_lod = MAX2(texobj->BaseLevel, texobj->MinLod); - sampler.max_lod = MIN2(texobj->MaxLevel, texobj->MaxLod); + sampler->min_lod = MAX2(texobj->BaseLevel, texobj->MinLod); + sampler->max_lod = MIN2(texobj->MaxLevel, texobj->MaxLod); #endif - sampler.max_anisotropy = texobj->MaxAnisotropy; + sampler->max_anisotropy = texobj->MaxAnisotropy; /* only care about ARB_shadow, not SGI shadow */ if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) { - sampler.compare = 1; - sampler.compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE; - sampler.compare_func + sampler->compare = 1; + sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE; + sampler->compare_func = st_compare_func_to_pipe(texobj->CompareFunc); } @@ -174,11 +174,10 @@ update_samplers(struct st_context *st) /* XXX more sampler state here */ } - st->state.sampler[su] = st_cached_sampler_state(st, &sampler)->data; + cso_single_sampler(st->cso_context, su, sampler); } - st->pipe->bind_sampler_states(st->pipe, st->state.num_samplers, - st->state.sampler); + cso_single_sampler_done(st->cso_context); } diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 10c131d554..0726688493 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -43,10 +43,9 @@ #include "pipe/p_context.h" #include "pipe/p_shader_tokens.h" -#include "cso_cache/cso_cache.h" +#include "cso_cache/cso_context.h" #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "st_program.h" #include "st_atom_shader.h" @@ -70,9 +69,6 @@ struct translated_vertex_program /** Maps VERT_RESULT_x to slot */ GLuint output_to_slot[VERT_RESULT_MAX]; - /** The program in TGSI format */ - struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; - /** Pointer to the translated vertex program */ struct st_vertex_program *vp; @@ -158,7 +154,7 @@ find_translated_vp(struct st_context *st, /* * Translate fragment program if needed. */ - if (!stfp->cso) { + if (!stfp->state.tokens) { GLuint inAttr, numIn = 0; for (inAttr = 0; inAttr < FRAG_ATTRIB_MAX; inAttr++) { @@ -175,11 +171,7 @@ find_translated_vp(struct st_context *st, assert(stfp->Base.Base.NumInstructions > 1); - (void) st_translate_fragment_program(st, stfp, - stfp->input_to_slot, - stfp->tokens, - ST_MAX_SHADER_TOKENS); - assert(stfp->cso); + st_translate_fragment_program(st, stfp, stfp->input_to_slot); } @@ -261,12 +253,8 @@ find_translated_vp(struct st_context *st, assert(stvp->Base.Base.NumInstructions > 1); - st_translate_vertex_program(st, stvp, - xvp->output_to_slot, - xvp->tokens, - ST_MAX_SHADER_TOKENS); + st_translate_vertex_program(st, stvp, xvp->output_to_slot); - assert(stvp->cso); xvp->vp = stvp; /* translated VP is up to date now */ @@ -296,12 +284,10 @@ update_linkage( struct st_context *st ) xvp = find_translated_vp(st, stvp, stfp); st->vp = stvp; - st->state.vs = xvp->vp; - st->pipe->bind_vs_state(st->pipe, st->state.vs->cso->data); - st->fp = stfp; - st->state.fs = stfp->cso; - st->pipe->bind_fs_state(st->pipe, st->state.fs->data); + + st->pipe->bind_vs_state(st->pipe, stvp->driver_shader); + st->pipe->bind_fs_state(st->pipe, stfp->driver_shader); st->vertex_result_to_slot = xvp->output_to_slot; } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 663c4f205d..f1fddc4e02 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -35,7 +35,6 @@ #include "main/macros.h" #include "st_context.h" -#include "st_cache.h" #include "st_cb_accum.h" #include "st_cb_fbo.h" #include "st_draw.h" diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index e712fd84cd..eae40f2a4f 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -35,7 +35,6 @@ #include "main/macros.h" #include "shader/prog_instruction.h" #include "st_atom.h" -#include "st_cache.h" #include "st_context.h" #include "st_cb_accum.h" #include "st_cb_clear.h" @@ -50,6 +49,8 @@ #include "pipe/p_defines.h" #include "pipe/p_winsys.h" +#include "cso_cache/cso_context.h" + @@ -157,8 +158,7 @@ make_frag_shader(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR); stfp = (struct st_fragment_program *) p; - st_translate_fragment_program(st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(st, stfp, NULL); return stfp; } @@ -206,9 +206,10 @@ make_vertex_shader(struct st_context *st) (1 << VERT_RESULT_HPOS)); stvp = (struct st_vertex_program *) p; - st_translate_vertex_program(st, stvp, NULL, - stvp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_vertex_program(st, stvp, NULL); +#if 0 assert(stvp->cso); +#endif return stvp; } @@ -284,7 +285,6 @@ clear_with_quad(GLcontext *ctx, /* blend state: RGBA masking */ { struct pipe_blend_state blend; - const struct cso_blend *cso; memset(&blend, 0, sizeof(blend)); if (color) { if (ctx->Color.ColorMask[0]) @@ -298,14 +298,12 @@ clear_with_quad(GLcontext *ctx, if (st->ctx->Color.DitherFlag) blend.dither = 1; } - cso = st_cached_blend_state(st, &blend); - pipe->bind_blend_state(pipe, cso->data); + cso_set_blend(st->cso_context, &blend); } /* depth_stencil state: always pass/set to ref value */ { struct pipe_depth_stencil_alpha_state depth_stencil; - const struct cso_depth_stencil_alpha *cso; memset(&depth_stencil, 0, sizeof(depth_stencil)); if (depth) { depth_stencil.depth.enabled = 1; @@ -323,14 +321,13 @@ clear_with_quad(GLcontext *ctx, depth_stencil.stencil[0].value_mask = 0xff; depth_stencil.stencil[0].write_mask = ctx->Stencil.WriteMask[0] & 0xff; } - cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil); - pipe->bind_depth_stencil_alpha_state(pipe, cso->data); + + cso_set_depth_stencil_alpha(st->cso_context, &depth_stencil); } /* rasterizer state: nothing */ { struct pipe_rasterizer_state raster; - const struct cso_rasterizer *cso; memset(&raster, 0, sizeof(raster)); #if 0 /* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD @@ -339,8 +336,7 @@ clear_with_quad(GLcontext *ctx, if (ctx->Scissor.Enabled) raster.scissor = 1; #endif - cso = st_cached_rasterizer_state(st, &raster); - pipe->bind_rasterizer_state(pipe, cso->data); + cso_set_rasterizer(st->cso_context, &raster); } /* fragment shader state: color pass-through program */ @@ -349,7 +345,7 @@ clear_with_quad(GLcontext *ctx, if (!stfp) { stfp = make_frag_shader(st); } - pipe->bind_fs_state(pipe, stfp->cso->data); + pipe->bind_fs_state(pipe, stfp->driver_shader); } /* vertex shader state: color/position pass-through */ @@ -358,7 +354,7 @@ clear_with_quad(GLcontext *ctx, if (!stvp) { stvp = make_vertex_shader(st); } - pipe->bind_vs_state(pipe, stvp->cso->data); + pipe->bind_vs_state(pipe, stvp->driver_shader); } /* viewport state: viewport matching window dims */ @@ -380,16 +376,19 @@ clear_with_quad(GLcontext *ctx, /* draw quad matching scissor rect (XXX verify coord round-off) */ draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); +#if 0 + /* Can't depend on old state objects still existing -- may have + * been deleted to make room in the hash, etc. (Should get + * fixed...) + */ + st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL); +#else /* Restore pipe state */ - pipe->bind_blend_state(pipe, st->state.blend->data); - pipe->bind_depth_stencil_alpha_state(pipe, st->state.depth_stencil->data); - pipe->bind_fs_state(pipe, st->state.fs->data); - pipe->bind_vs_state(pipe, st->state.vs->cso->data); - pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); + cso_set_rasterizer(st->cso_context, &st->state.rasterizer); + pipe->bind_fs_state(pipe, st->fp->driver_shader); + pipe->bind_vs_state(pipe, st->vp->driver_shader); +#endif pipe->set_viewport_state(pipe, &st->state.viewport); - /* OR: - st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL); - */ } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index dee4c4132a..18ec9645c4 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -41,7 +41,6 @@ #include "st_context.h" #include "st_atom.h" #include "st_atom_constbuf.h" -#include "st_cache.h" #include "st_draw.h" #include "st_program.h" #include "st_cb_drawpixels.h" @@ -58,6 +57,7 @@ #include "pipe/p_winsys.h" #include "util/p_tile.h" #include "shader/prog_instruction.h" +#include "cso_cache/cso_context.h" /** @@ -159,8 +159,7 @@ make_bitmap_fragment_program(GLcontext *ctx) stfp = (struct st_fragment_program *) p; stfp->Base.UsesKill = GL_TRUE; - st_translate_fragment_program(ctx->st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(ctx->st, stfp, NULL); return stfp; } @@ -204,8 +203,7 @@ combined_bitmap_fragment_program(GLcontext *ctx) #endif /* translate to TGSI tokens */ - st_translate_fragment_program(st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(st, stfp, NULL); /* save new program, update serial numbers */ st->bitmap.user_prog_sn = st->fp->serialNo; @@ -266,8 +264,7 @@ combined_drawpix_fragment_program(GLcontext *ctx) #endif /* translate to TGSI tokens */ - st_translate_fragment_program(st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(st, stfp, NULL); /* save new program, update serial numbers */ st->pixel_xfer.xfer_prog_sn = st->pixel_xfer.program->serialNo; @@ -343,8 +340,7 @@ make_fragment_shader_z(struct st_context *st) p->OutputsWritten = (1 << FRAG_RESULT_COLR) | (1 << FRAG_RESULT_DEPR); stfp = (struct st_fragment_program *) p; - st_translate_fragment_program(st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(st, stfp, NULL); return stfp; } @@ -421,8 +417,7 @@ st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor) } stvp = (struct st_vertex_program *) p; - st_translate_vertex_program(st, stvp, NULL, - stvp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_vertex_program(st, stvp, NULL); progs[passColor] = stvp; @@ -641,7 +636,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, const GLfloat *color, GLboolean invertTex) { + struct st_context *st = ctx->st; struct pipe_context *pipe = ctx->st->pipe; + struct cso_context *cso = ctx->st->cso_context; GLfloat x0, y0, x1, y1; GLuint maxSize; @@ -656,24 +653,23 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, /* setup state: just scissor */ { struct pipe_rasterizer_state setup; - const struct cso_rasterizer *cso; memset(&setup, 0, sizeof(setup)); if (ctx->Scissor.Enabled) setup.scissor = 1; - cso = st_cached_rasterizer_state(ctx->st, &setup); - pipe->bind_rasterizer_state(pipe, cso->data); + + cso_set_rasterizer(cso, &setup); } /* fragment shader state: TEX lookup program */ - pipe->bind_fs_state(pipe, stfp->cso->data); + pipe->bind_fs_state(pipe, stfp->driver_shader); /* vertex shader state: position + texcoord pass-through */ - pipe->bind_vs_state(pipe, stvp->cso->data); + pipe->bind_vs_state(pipe, stvp->driver_shader); + /* texture sampling state: */ { struct pipe_sampler_state sampler; - const struct cso_sampler *cso; memset(&sampler, 0, sizeof(sampler)); sampler.wrap_s = PIPE_TEX_WRAP_CLAMP; sampler.wrap_t = PIPE_TEX_WRAP_CLAMP; @@ -682,8 +678,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; sampler.normalized_coords = 1; - cso = st_cached_sampler_state(ctx->st, &sampler); - pipe->bind_sampler_states(pipe, 1, (void**)&cso->data); + + cso_single_sampler(cso, 0, &sampler); + cso_single_sampler_done(cso); } /* viewport state: viewport matching window dims */ @@ -723,14 +720,25 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, draw_quad(ctx, x0, y0, z, x1, y1, invertTex); /* restore GL state */ - pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data); - pipe->bind_fs_state(pipe, ctx->st->state.fs->data); - pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data); pipe->set_sampler_textures(pipe, ctx->st->state.num_textures, ctx->st->state.sampler_texture); - pipe->bind_sampler_states(pipe, ctx->st->state.num_samplers, - ctx->st->state.sampler); + pipe->set_viewport_state(pipe, &ctx->st->state.viewport); + +#if 0 + /* Can't depend on old state objects still existing -- may have + * been deleted to make room in the hash, etc. (Should get + * fixed...) + */ + st_invalidate_state(ctx, _NEW_COLOR | _NEW_TEXTURE); +#else + /* restore state */ + pipe->bind_fs_state(pipe, st->fp->driver_shader); + pipe->bind_vs_state(pipe, st->vp->driver_shader); + cso_set_rasterizer(cso, &st->state.rasterizer); + cso_set_samplers(cso, PIPE_MAX_SAMPLERS, + (const struct pipe_sampler_state **) st->state.sampler_list); +#endif } @@ -798,10 +806,10 @@ compatible_formats(GLenum format, GLenum type, enum pipe_format pipeFormat) static GLboolean any_fragment_ops(const struct st_context *st) { - if (st->state.depth_stencil->state.alpha.enabled || - st->state.blend->state.blend_enable || - st->state.blend->state.logicop_enable || - st->state.depth_stencil->state.depth.enabled) + if (st->state.depth_stencil.alpha.enabled || + st->state.depth_stencil.depth.enabled || + st->state.blend.blend_enable || + st->state.blend.logicop_enable) /* XXX more checks */ return GL_TRUE; else diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 61d4f4c41c..4dc76f19b1 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -168,11 +168,13 @@ static void st_program_string_notify( GLcontext *ctx, stfp->serialNo++; +#if 0 if (stfp->cso) { /* free the TGSI code */ // cso_delete(stfp->vs); stfp->cso = NULL; } +#endif stfp->param_state = stfp->Base.Base.Parameters->StateFlags; @@ -184,13 +186,14 @@ static void st_program_string_notify( GLcontext *ctx, stvp->serialNo++; +#if 0 if (stvp->cso) { /* free the CSO data */ st->pipe->delete_vs_state(st->pipe, stvp->cso->data); FREE((void *) stvp->cso); stvp->cso = NULL; } - +#endif if (stvp->draw_shader) { draw_delete_vertex_shader(st->draw, stvp->draw_shader); stvp->draw_shader = NULL; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 09e389f9dc..5458ab420e 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -56,6 +56,7 @@ #include "pipe/p_inlines.h" #include "draw/draw_context.h" #include "cso_cache/cso_cache.h" +#include "cso_cache/cso_context.h" /** @@ -78,6 +79,7 @@ void st_invalidate_state(GLcontext * ctx, GLuint new_state) static struct st_context * st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) { + uint i; struct st_context *st = CALLOC_STRUCT( st_context ); ctx->st = st; @@ -93,12 +95,15 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st->dirty.mesa = ~0; st->dirty.st = ~0; - st->cache = cso_cache_create(); + st->cso_context = cso_create_context(pipe); st_init_atoms( st ); st_init_draw( st ); st_init_generate_mipmap(st); + for (i = 0; i < PIPE_MAX_SAMPLERS; i++) + st->state.sampler_list[i] = &st->state.samplers[i]; + /* we want all vertex data to be placed in buffer objects */ vbo_use_buffer_objects(ctx); @@ -149,7 +154,7 @@ static void st_destroy_context_priv( struct st_context *st ) _vbo_DestroyContext(st->ctx); - cso_cache_delete( st->cache ); + cso_destroy_context(st->cso_context); _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 897a5109b7..e81aebba3d 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -74,14 +74,11 @@ struct st_context * Other state is just parameter values. */ struct { - const struct cso_alpha_test *alpha_test; - const struct cso_blend *blend; - void *sampler[PIPE_MAX_SAMPLERS]; - const struct cso_depth_stencil_alpha *depth_stencil; - const struct cso_rasterizer *rasterizer; - const struct cso_fragment_shader *fs; - struct st_vertex_program *vs; - + struct pipe_blend_state blend; + struct pipe_depth_stencil_alpha_state depth_stencil; + struct pipe_rasterizer_state rasterizer; + struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_state *sampler_list[PIPE_MAX_SAMPLERS]; struct pipe_blend_color blend_color; struct pipe_clip_state clip; struct pipe_constant_buffer constants[2]; @@ -151,6 +148,10 @@ struct st_context /** For gen/render mipmap feature */ struct { + struct pipe_blend_state blend; + struct pipe_depth_stencil_alpha_state depthstencil; + struct pipe_rasterizer_state rasterizer; + void *blend_cso; void *depthstencil_cso; void *rasterizer_cso; @@ -158,7 +159,7 @@ struct st_context struct st_vertex_program *stvp; } gen_mipmap; - struct cso_cache *cache; + struct cso_context *cso_context; }; diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 5888bcb98a..9c13010da8 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -53,15 +53,15 @@ st_print_current(void) int i; printf("Vertex Transform Inputs:\n"); - for (i = 0; i < st->state.vs->cso->state.num_inputs; i++) { + for (i = 0; i < st->vp->state.num_inputs; i++) { printf(" Slot %d: VERT_ATTRIB_%d\n", i, st->vp->index_to_input[i]); } - tgsi_dump( st->state.vs->cso->state.tokens, 0 ); + tgsi_dump( st->vp->state.tokens, 0 ); if (st->vp->Base.Base.Parameters) _mesa_print_parameter_list(st->vp->Base.Base.Parameters); - tgsi_dump( st->state.fs->state.tokens, 0 ); + tgsi_dump( st->fp->state.tokens, 0 ); if (st->fp->Base.Base.Parameters) _mesa_print_parameter_list(st->fp->Base.Base.Parameters); } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 1c0fa8c6aa..98504e46c1 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -36,7 +36,6 @@ #include "vbo/vbo.h" #include "st_atom.h" -#include "st_cache.h" #include "st_context.h" #include "st_cb_bufferobjects.h" #include "st_draw.h" @@ -219,7 +218,7 @@ st_draw_vbo(GLcontext *ctx, /* must get these after state validation! */ vp = ctx->st->vp; - vs = &ctx->st->state.vs->cso->state; + vs = &ctx->st->vp->state; /* loop over TGSI shader inputs to determine vertex buffer * and attribute info @@ -481,10 +480,10 @@ st_feedback_draw_vbo(GLcontext *ctx, /* must get these after state validation! */ vp = ctx->st->vp; - vs = &ctx->st->state.vs->cso->state; + vs = &st->vp->state; - if (!st->state.vs->draw_shader) { - st->state.vs->draw_shader = draw_create_vertex_shader(draw, vs); + if (!st->vp->draw_shader) { + st->vp->draw_shader = draw_create_vertex_shader(draw, vs); } /* @@ -496,8 +495,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->state); - draw_bind_vertex_shader(draw, st->state.vs->draw_shader); + draw_set_rasterizer_state(draw, &st->state.rasterizer); + draw_bind_vertex_shader(draw, st->vp->draw_shader); set_feedback_vertex_format(ctx); /* loop over TGSI shader inputs to determine vertex buffer diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 3723e26d45..9c4e1032ef 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -38,6 +38,7 @@ #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" #include "cso_cache/cso_cache.h" +#include "cso_cache/cso_context.h" #include "st_context.h" #include "st_draw.h" @@ -89,8 +90,7 @@ make_tex_fragment_program(GLcontext *ctx) stfp = (struct st_fragment_program *) p; - st_translate_fragment_program(ctx->st, stfp, NULL, - stfp->tokens, ST_MAX_SHADER_TOKENS); + st_translate_fragment_program(ctx->st, stfp, NULL); return stfp; } @@ -118,6 +118,7 @@ st_init_generate_mipmap(struct st_context *st) blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; blend.colormask = PIPE_MASK_RGBA; + st->gen_mipmap.blend = blend; st->gen_mipmap.blend_cso = pipe->create_blend_state(pipe, &blend); memset(&depthstencil, 0, sizeof(depthstencil)); @@ -257,14 +258,14 @@ st_render_mipmap(struct st_context *st, sampler.normalized_coords = 1; - /* bind CSOs */ - pipe->bind_blend_state(pipe, st->gen_mipmap.blend_cso); - pipe->bind_depth_stencil_alpha_state(pipe, st->gen_mipmap.depthstencil_cso); - pipe->bind_rasterizer_state(pipe, st->gen_mipmap.rasterizer_cso); + /* bind state */ + cso_set_blend(st->cso_context, &st->gen_mipmap.blend); + cso_set_depth_stencil_alpha(st->cso_context, &st->gen_mipmap.depthstencil); + cso_set_rasterizer(st->cso_context, &st->gen_mipmap.rasterizer); /* bind shaders */ - pipe->bind_fs_state(pipe, st->gen_mipmap.stfp->cso->data); - pipe->bind_vs_state(pipe, st->gen_mipmap.stvp->cso->data); + pipe->bind_fs_state(pipe, st->gen_mipmap.stfp->driver_shader); + pipe->bind_vs_state(pipe, st->gen_mipmap.stvp->driver_shader); /* * XXX for small mipmap levels, it may be faster to use the software @@ -304,17 +305,18 @@ st_render_mipmap(struct st_context *st, /*pt->first_level = first_level_save;*/ /* restore pipe state */ - if (st->state.rasterizer) - pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); - if (st->state.fs) - pipe->bind_fs_state(pipe, st->state.fs->data); - if (st->state.vs) - pipe->bind_vs_state(pipe, st->state.vs->cso->data); - pipe->bind_sampler_states(pipe, st->state.num_samplers, - st->state.sampler); +#if 0 + cso_set_rasterizer(st->cso_context, &st->state.rasterizer); + cso_set_samplers(st->cso_context, st->state.samplers_list); + pipe->bind_fs_state(pipe, st->fp->shader_program); + pipe->bind_vs_state(pipe, st->vp->shader_program); pipe->set_sampler_textures(pipe, st->state.num_textures, st->state.sampler_texture); pipe->set_viewport_state(pipe, &st->state.viewport); +#else + /* XXX is this sufficient? */ + st_invalidate_state(st->ctx, _NEW_COLOR | _NEW_TEXTURE); +#endif return TRUE; } diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 97206752af..9446b012ad 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -683,8 +683,9 @@ find_temporaries(const struct gl_program *program, * \param tokens array to store translated tokens in * \param maxTokens size of the tokens array * + * \return number of tokens placed in 'tokens' buffer, or zero if error */ -GLboolean +GLuint tgsi_translate_mesa_program( uint procType, const struct gl_program *program, @@ -918,6 +919,6 @@ tgsi_translate_mesa_program( maxTokens - ti ); } - return GL_TRUE; + return ti; } diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h index 3ababf1339..63fc855b53 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -39,7 +39,7 @@ extern "C" { struct tgsi_token; struct gl_program; -GLboolean +GLuint tgsi_translate_mesa_program( uint procType, const struct gl_program *program, diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index aa252c845a..0f8784e132 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -42,15 +42,29 @@ #include "tgsi/util/tgsi_dump.h" #include "st_context.h" -#include "st_cache.h" #include "st_atom.h" #include "st_program.h" #include "st_mesa_to_tgsi.h" +#include "cso_cache/cso_context.h" #define TGSI_DEBUG 0 +/** XXX we should use the version of this from p_util.h but including + * that header causes symbol collisions. + */ +static INLINE void * +mem_dup(const void *src, uint size) +{ + void *dup = MALLOC(size); + if (dup) + memcpy(dup, src, size); + return dup; +} + + + /** * Translate a Mesa vertex shader into a TGSI shader. * \param outputMapping to map vertex program output registers to TGSI @@ -61,15 +75,15 @@ void st_translate_vertex_program(struct st_context *st, struct st_vertex_program *stvp, - const GLuint outputMapping[], - struct tgsi_token *tokensOut, - GLuint maxTokens) + const GLuint outputMapping[]) { + struct pipe_context *pipe = st->pipe; + struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; GLuint defaultOutputMapping[VERT_RESULT_MAX]; struct pipe_shader_state vs; - const struct cso_vertex_shader *cso; GLuint attr, i; GLuint num_generic = 0; + GLuint num_tokens; memset(&vs, 0, sizeof(vs)); @@ -240,7 +254,7 @@ st_translate_vertex_program(struct st_context *st, /* XXX: fix static allocation of tokens: */ - tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX, + num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX, &stvp->Base.Base, /* inputs */ vs.num_inputs, @@ -252,20 +266,21 @@ st_translate_vertex_program(struct st_context *st, vs.num_outputs, outputMapping, vs.output_semantic_name, - vs.output_semantic_index, + vs.output_semantic_index, /* tokenized result */ - tokensOut, maxTokens); + tokens, ST_MAX_SHADER_TOKENS); - vs.tokens = tokensOut; + vs.tokens = (struct tgsi_token *) + mem_dup(tokens, num_tokens * sizeof(tokens[0])); - cso = st_cached_vs_state(st, &vs); - stvp->cso = cso; + stvp->state = vs; /* struct copy */ + stvp->driver_shader = pipe->create_vs_state(pipe, &vs); if (0) _mesa_print_program(&stvp->Base.Base); if (TGSI_DEBUG) - tgsi_dump( tokensOut, 0 ); + tgsi_dump( vs.tokens, 0 ); } @@ -280,10 +295,10 @@ st_translate_vertex_program(struct st_context *st, const struct cso_fragment_shader * st_translate_fragment_program(struct st_context *st, struct st_fragment_program *stfp, - const GLuint inputMapping[], - struct tgsi_token *tokensOut, - GLuint maxTokens) + const GLuint inputMapping[]) { + struct pipe_context *pipe = st->pipe; + struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; GLuint outputMapping[FRAG_RESULT_MAX]; GLuint defaultInputMapping[FRAG_ATTRIB_MAX]; struct pipe_shader_state fs; @@ -293,6 +308,7 @@ st_translate_fragment_program(struct st_context *st, const GLbitfield inputsRead = stfp->Base.Base.InputsRead; GLuint vslot = 0; GLuint num_generic = 0; + GLuint num_tokens; memset(&fs, 0, sizeof(fs)); @@ -401,7 +417,7 @@ st_translate_fragment_program(struct st_context *st, /* XXX: fix static allocation of tokens: */ - tgsi_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT, + num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT, &stfp->Base.Base, /* inputs */ fs.num_inputs, @@ -415,18 +431,19 @@ st_translate_fragment_program(struct st_context *st, fs.output_semantic_name, fs.output_semantic_index, /* tokenized result */ - tokensOut, maxTokens); + tokens, ST_MAX_SHADER_TOKENS); - fs.tokens = tokensOut; + fs.tokens = (struct tgsi_token *) + mem_dup(tokens, num_tokens * sizeof(tokens[0])); - cso = st_cached_fs_state(st, &fs); - stfp->cso = cso; + stfp->state = fs; /* struct copy */ + stfp->driver_shader = pipe->create_fs_state(pipe, &fs); if (0) _mesa_print_program(&stfp->Base.Base); if (TGSI_DEBUG) - tgsi_dump( tokensOut, 0/*TGSI_DUMP_VERBOSE*/ ); + tgsi_dump( fs.tokens, 0/*TGSI_DUMP_VERBOSE*/ ); return cso; } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 31558af6ce..78786dcbb6 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -60,11 +60,8 @@ struct st_fragment_program /** map FP input back to VP output */ GLuint input_map[PIPE_MAX_SHADER_INPUTS]; - /** The program in TGSI format */ - struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; - - /** Pointer to the corresponding cached shader */ - const struct cso_fragment_shader *cso; + struct pipe_shader_state state; + struct pipe_shader_state *driver_shader; GLuint param_state; @@ -88,11 +85,8 @@ struct st_vertex_program /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */ GLuint index_to_input[PIPE_MAX_SHADER_INPUTS]; - /** The program in TGSI format */ - struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; - - /** Pointer to the corresponding cached shader */ - const struct cso_vertex_shader *cso; + struct pipe_shader_state state; + struct pipe_shader_state *driver_shader; /** For using our private draw module (glRasterPos) */ struct draw_vertex_shader *draw_shader; @@ -122,16 +116,12 @@ st_vertex_program( struct gl_vertex_program *vp ) extern const struct cso_fragment_shader * st_translate_fragment_program(struct st_context *st, struct st_fragment_program *fp, - const GLuint inputMapping[], - struct tgsi_token *tokens, - GLuint maxTokens); + const GLuint inputMapping[]); extern void 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); + const GLuint vert_output_to_slot[]); #endif -- cgit v1.2.3 From fa9e7e9a8debb68611909ac2ffab527c6c39a3e5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 13 Mar 2008 18:08:18 +0000 Subject: gallium: remove semantic info from pipe_shader_state Brian's patch to clean up the shader interfaces. --- src/gallium/auxiliary/draw/draw_aaline.c | 2 +- src/gallium/auxiliary/draw/draw_aapoint.c | 2 +- src/gallium/auxiliary/draw/draw_pstipple.c | 2 +- src/gallium/include/pipe/p_state.h | 2 + src/mesa/state_tracker/st_debug.c | 2 + src/mesa/state_tracker/st_draw.c | 6 +- src/mesa/state_tracker/st_program.c | 167 ++++++++++++++++------------- src/mesa/state_tracker/st_program.h | 2 + 8 files changed, 104 insertions(+), 81 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/draw/draw_aaline.c b/src/gallium/auxiliary/draw/draw_aaline.c index 6b1e640ae9..bed709bad0 100644 --- a/src/gallium/auxiliary/draw/draw_aaline.c +++ b/src/gallium/auxiliary/draw/draw_aaline.c @@ -340,7 +340,7 @@ generate_aaline_fs(struct aaline_stage *aaline) tgsi_dump(aaline_fs.tokens, 0); #endif -#if 1 /* XXX remove */ +#if 0 /* XXX remove */ aaline_fs.input_semantic_name[aaline_fs.num_inputs] = TGSI_SEMANTIC_GENERIC; aaline_fs.input_semantic_index[aaline_fs.num_inputs] = transform.maxGeneric + 1; aaline_fs.num_inputs++; diff --git a/src/gallium/auxiliary/draw/draw_aapoint.c b/src/gallium/auxiliary/draw/draw_aapoint.c index 99e9e9fe34..4bc2b5f3e2 100644 --- a/src/gallium/auxiliary/draw/draw_aapoint.c +++ b/src/gallium/auxiliary/draw/draw_aapoint.c @@ -514,7 +514,7 @@ generate_aapoint_fs(struct aapoint_stage *aapoint) tgsi_dump(aapoint_fs.tokens, 0); #endif -#if 1 /* XXX remove */ +#if 0 /* XXX remove */ aapoint_fs.input_semantic_name[aapoint_fs.num_inputs] = TGSI_SEMANTIC_GENERIC; aapoint_fs.input_semantic_index[aapoint_fs.num_inputs] = transform.maxGeneric + 1; aapoint_fs.num_inputs++; diff --git a/src/gallium/auxiliary/draw/draw_pstipple.c b/src/gallium/auxiliary/draw/draw_pstipple.c index 8b3e84a9a0..d7475b457c 100644 --- a/src/gallium/auxiliary/draw/draw_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pstipple.c @@ -331,7 +331,7 @@ generate_pstip_fs(struct pstip_stage *pstip) pstip->sampler_unit = transform.maxSampler + 1; -#if 1 /* XXX remove */ +#if 0 /* XXX remove */ if (transform.wincoordInput < 0) { pstip_fs.input_semantic_name[pstip_fs.num_inputs] = TGSI_SEMANTIC_POSITION; pstip_fs.input_semantic_index[pstip_fs.num_inputs] = (ubyte)transform.maxInput; diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index e338a27383..bb5fab5d5f 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -162,6 +162,7 @@ struct pipe_constant_buffer struct pipe_shader_state { const struct tgsi_token *tokens; +#if 0 /* XXX these are going away */ ubyte num_inputs; ubyte num_outputs; @@ -169,6 +170,7 @@ struct pipe_shader_state ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS]; ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */ ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; +#endif }; diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 9c13010da8..8b9b91aa34 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -52,10 +52,12 @@ st_print_current(void) struct st_context *st = ctx->st; int i; +#if 0 printf("Vertex Transform Inputs:\n"); for (i = 0; i < st->vp->state.num_inputs; i++) { printf(" Slot %d: VERT_ATTRIB_%d\n", i, st->vp->index_to_input[i]); } +#endif tgsi_dump( st->vp->state.tokens, 0 ); if (st->vp->Base.Base.Parameters) diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 98504e46c1..5ebd0bbcce 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -223,7 +223,7 @@ st_draw_vbo(GLcontext *ctx, /* loop over TGSI shader inputs to determine vertex buffer * and attribute info */ - for (attr = 0; attr < vs->num_inputs; attr++) { + for (attr = 0; attr < /*vs*/vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; struct pipe_vertex_element velement; @@ -333,7 +333,7 @@ st_draw_vbo(GLcontext *ctx, } /* unreference buffers (frees wrapped user-space buffer objects) */ - for (attr = 0; attr < vs->num_inputs; attr++) { + for (attr = 0; attr < /*vs*/vp->num_inputs; attr++) { pipe_buffer_reference(winsys, &vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); pipe->set_vertex_buffer(pipe, attr, &vbuffer[attr]); @@ -502,7 +502,7 @@ st_feedback_draw_vbo(GLcontext *ctx, /* loop over TGSI shader inputs to determine vertex buffer * and attribute info */ - for (attr = 0; attr < vs->num_inputs; attr++) { + for (attr = 0; attr < /*vs*/vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; struct pipe_vertex_element velement; diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 0f8784e132..d9d11ee0e8 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -85,6 +85,14 @@ st_translate_vertex_program(struct st_context *st, GLuint num_generic = 0; GLuint num_tokens; + ubyte vs_input_semantic_name[PIPE_MAX_SHADER_INPUTS]; + ubyte vs_input_semantic_index[PIPE_MAX_SHADER_INPUTS]; + uint vs_num_inputs = 0; + + ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; + ubyte vs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; + uint vs_num_outputs = 0; + memset(&vs, 0, sizeof(vs)); /* @@ -93,36 +101,36 @@ st_translate_vertex_program(struct st_context *st, */ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { if (stvp->Base.Base.InputsRead & (1 << attr)) { - const GLuint slot = vs.num_inputs; + const GLuint slot = vs_num_inputs; - 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[slot] = TGSI_SEMANTIC_POSITION; - vs.input_semantic_index[slot] = 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[slot] = TGSI_SEMANTIC_GENERIC; - vs.input_semantic_index[slot] = 0; + vs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs_input_semantic_index[slot] = 0; break; case VERT_ATTRIB_COLOR0: - vs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; - vs.input_semantic_index[slot] = 0; + vs_input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs_input_semantic_index[slot] = 0; break; case VERT_ATTRIB_COLOR1: - vs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; - vs.input_semantic_index[slot] = 1; + vs_input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs_input_semantic_index[slot] = 1; break; case VERT_ATTRIB_FOG: - vs.input_semantic_name[slot] = TGSI_SEMANTIC_FOG; - vs.input_semantic_index[slot] = 0; + vs_input_semantic_name[slot] = TGSI_SEMANTIC_FOG; + vs_input_semantic_index[slot] = 0; break; case VERT_ATTRIB_TEX0: case VERT_ATTRIB_TEX1: @@ -132,8 +140,8 @@ st_translate_vertex_program(struct st_context *st, case VERT_ATTRIB_TEX5: case VERT_ATTRIB_TEX6: case VERT_ATTRIB_TEX7: - vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - vs.input_semantic_index[slot] = num_generic++; + vs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs_input_semantic_index[slot] = num_generic++; break; case VERT_ATTRIB_GENERIC0: case VERT_ATTRIB_GENERIC1: @@ -144,8 +152,8 @@ st_translate_vertex_program(struct st_context *st, case VERT_ATTRIB_GENERIC6: case VERT_ATTRIB_GENERIC7: assert(attr < VERT_ATTRIB_MAX); - vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - vs.input_semantic_index[slot] = num_generic++; + vs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs_input_semantic_index[slot] = num_generic++; break; default: assert(0); @@ -155,8 +163,8 @@ st_translate_vertex_program(struct st_context *st, /* 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; + vs_output_semantic_name[i] = TGSI_SEMANTIC_GENERIC; + vs_output_semantic_index[i] = 0; } num_generic = 0; @@ -173,8 +181,8 @@ st_translate_vertex_program(struct st_context *st, assert(slot != ~0); } else { - slot = vs.num_outputs; - vs.num_outputs++; + slot = vs_num_outputs; + vs_num_outputs++; defaultOutputMapping[attr] = slot; } @@ -185,32 +193,32 @@ st_translate_vertex_program(struct st_context *st, switch (attr) { case VERT_RESULT_HPOS: assert(slot == 0); - vs.output_semantic_name[slot] = TGSI_SEMANTIC_POSITION; - vs.output_semantic_index[slot] = 0; + vs_output_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + vs_output_semantic_index[slot] = 0; break; case VERT_RESULT_COL0: - vs.output_semantic_name[slot] = TGSI_SEMANTIC_COLOR; - vs.output_semantic_index[slot] = 0; + vs_output_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs_output_semantic_index[slot] = 0; break; case VERT_RESULT_COL1: - vs.output_semantic_name[slot] = TGSI_SEMANTIC_COLOR; - vs.output_semantic_index[slot] = 1; + vs_output_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + vs_output_semantic_index[slot] = 1; break; case VERT_RESULT_BFC0: - vs.output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR; - vs.output_semantic_index[slot] = 0; + vs_output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR; + vs_output_semantic_index[slot] = 0; break; case VERT_RESULT_BFC1: - vs.output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR; - vs.output_semantic_index[slot] = 1; + vs_output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR; + vs_output_semantic_index[slot] = 1; break; case VERT_RESULT_FOGC: - vs.output_semantic_name[slot] = TGSI_SEMANTIC_FOG; - vs.output_semantic_index[slot] = 0; + vs_output_semantic_name[slot] = TGSI_SEMANTIC_FOG; + vs_output_semantic_index[slot] = 0; break; case VERT_RESULT_PSIZ: - vs.output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE; - vs.output_semantic_index[slot] = 0; + vs_output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE; + vs_output_semantic_index[slot] = 0; break; case VERT_RESULT_EDGE: assert(0); @@ -223,30 +231,30 @@ st_translate_vertex_program(struct st_context *st, case VERT_RESULT_TEX5: case VERT_RESULT_TEX6: case VERT_RESULT_TEX7: - vs.output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - vs.output_semantic_index[slot] = num_generic++; + vs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs_output_semantic_index[slot] = num_generic++; break; case VERT_RESULT_VAR0: /* fall-through */ default: assert(attr - VERT_RESULT_VAR0 < MAX_VARYING); - vs.output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - vs.output_semantic_index[slot] = num_generic++; + vs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + vs_output_semantic_index[slot] = num_generic++; } } } - assert(vs.output_semantic_name[0] == TGSI_SEMANTIC_POSITION); + assert(vs_output_semantic_name[0] == TGSI_SEMANTIC_POSITION); if (outputMapping) { - /* find max output slot referenced to compute vs.num_outputs */ + /* 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; + vs_num_outputs = maxSlot + 1; } else { outputMapping = defaultOutputMapping; @@ -257,22 +265,23 @@ st_translate_vertex_program(struct st_context *st, num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX, &stvp->Base.Base, /* inputs */ - vs.num_inputs, + vs_num_inputs, stvp->input_to_index, - vs.input_semantic_name, - vs.input_semantic_index, + vs_input_semantic_name, + vs_input_semantic_index, NULL, /* outputs */ - vs.num_outputs, + vs_num_outputs, outputMapping, - vs.output_semantic_name, - vs.output_semantic_index, + vs_output_semantic_name, + vs_output_semantic_index, /* tokenized result */ tokens, ST_MAX_SHADER_TOKENS); vs.tokens = (struct tgsi_token *) mem_dup(tokens, num_tokens * sizeof(tokens[0])); + stvp->num_inputs = vs_num_inputs; stvp->state = vs; /* struct copy */ stvp->driver_shader = pipe->create_vs_state(pipe, &vs); @@ -310,6 +319,14 @@ st_translate_fragment_program(struct st_context *st, GLuint num_generic = 0; GLuint num_tokens; + ubyte fs_input_semantic_name[PIPE_MAX_SHADER_INPUTS]; + ubyte fs_input_semantic_index[PIPE_MAX_SHADER_INPUTS]; + uint fs_num_inputs = 0; + + ubyte fs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; + ubyte fs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; + uint fs_num_outputs = 0; + memset(&fs, 0, sizeof(fs)); /* which vertex output goes to the first fragment input: */ @@ -323,33 +340,33 @@ st_translate_fragment_program(struct st_context *st, */ for (attr = 0; attr < FRAG_ATTRIB_MAX; attr++) { if (inputsRead & (1 << attr)) { - const GLuint slot = fs.num_inputs; + const GLuint slot = fs_num_inputs; defaultInputMapping[attr] = slot; stfp->input_map[slot] = vslot++; - fs.num_inputs++; + fs_num_inputs++; switch (attr) { case FRAG_ATTRIB_WPOS: - fs.input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; - fs.input_semantic_index[slot] = 0; + fs_input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + fs_input_semantic_index[slot] = 0; interpMode[slot] = TGSI_INTERPOLATE_LINEAR; break; case FRAG_ATTRIB_COL0: - fs.input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; - fs.input_semantic_index[slot] = 0; + 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[slot] = TGSI_SEMANTIC_COLOR; - fs.input_semantic_index[slot] = 1; + 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[slot] = TGSI_SEMANTIC_FOG; - fs.input_semantic_index[slot] = 0; + fs_input_semantic_name[slot] = TGSI_SEMANTIC_FOG; + fs_input_semantic_index[slot] = 0; interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; break; case FRAG_ATTRIB_TEX0: @@ -360,15 +377,15 @@ st_translate_fragment_program(struct st_context *st, case FRAG_ATTRIB_TEX5: case FRAG_ATTRIB_TEX6: case FRAG_ATTRIB_TEX7: - fs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - fs.input_semantic_index[slot] = num_generic++; + fs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + fs_input_semantic_index[slot] = num_generic++; interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; break; case FRAG_ATTRIB_VAR0: /* fall-through */ default: - fs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - fs.input_semantic_index[slot] = num_generic++; + fs_input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + fs_input_semantic_index[slot] = num_generic++; interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; } } @@ -383,10 +400,10 @@ st_translate_fragment_program(struct st_context *st, /* if z is written, emit that first */ if (outputsWritten & (1 << FRAG_RESULT_DEPR)) { - fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_POSITION; - fs.output_semantic_index[fs.num_outputs] = 0; - outputMapping[FRAG_RESULT_DEPR] = fs.num_outputs; - fs.num_outputs++; + fs_output_semantic_name[fs_num_outputs] = TGSI_SEMANTIC_POSITION; + fs_output_semantic_index[fs_num_outputs] = 0; + outputMapping[FRAG_RESULT_DEPR] = fs_num_outputs; + fs_num_outputs++; outputsWritten &= ~(1 << FRAG_RESULT_DEPR); } @@ -399,15 +416,15 @@ st_translate_fragment_program(struct st_context *st, assert(0); break; case FRAG_RESULT_COLR: - fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_COLOR; - fs.output_semantic_index[fs.num_outputs] = numColors; - outputMapping[attr] = fs.num_outputs; + fs_output_semantic_name[fs_num_outputs] = TGSI_SEMANTIC_COLOR; + fs_output_semantic_index[fs_num_outputs] = numColors; + outputMapping[attr] = fs_num_outputs; numColors++; break; default: assert(0); } - fs.num_outputs++; + fs_num_outputs++; } } } @@ -420,16 +437,16 @@ st_translate_fragment_program(struct st_context *st, num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT, &stfp->Base.Base, /* inputs */ - fs.num_inputs, + fs_num_inputs, inputMapping, - fs.input_semantic_name, - fs.input_semantic_index, + fs_input_semantic_name, + fs_input_semantic_index, interpMode, /* outputs */ - fs.num_outputs, + fs_num_outputs, outputMapping, - fs.output_semantic_name, - fs.output_semantic_index, + fs_output_semantic_name, + fs_output_semantic_index, /* tokenized result */ tokens, ST_MAX_SHADER_TOKENS); diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 78786dcbb6..9ef2a07eaa 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -85,6 +85,8 @@ struct st_vertex_program /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */ GLuint index_to_input[PIPE_MAX_SHADER_INPUTS]; + GLuint num_inputs; + struct pipe_shader_state state; struct pipe_shader_state *driver_shader; -- cgit v1.2.3 From 1213c7257335d577cf0217e34edafddf0451ba1b Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 19 Mar 2008 10:43:35 -0600 Subject: gallium: remove old commented-out code --- src/mesa/state_tracker/st_draw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 5ebd0bbcce..20af90df7d 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -223,7 +223,7 @@ st_draw_vbo(GLcontext *ctx, /* loop over TGSI shader inputs to determine vertex buffer * and attribute info */ - for (attr = 0; attr < /*vs*/vp->num_inputs; attr++) { + for (attr = 0; attr < vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; struct pipe_vertex_element velement; @@ -333,7 +333,7 @@ st_draw_vbo(GLcontext *ctx, } /* unreference buffers (frees wrapped user-space buffer objects) */ - for (attr = 0; attr < /*vs*/vp->num_inputs; attr++) { + for (attr = 0; attr < vp->num_inputs; attr++) { pipe_buffer_reference(winsys, &vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); pipe->set_vertex_buffer(pipe, attr, &vbuffer[attr]); @@ -502,7 +502,7 @@ st_feedback_draw_vbo(GLcontext *ctx, /* loop over TGSI shader inputs to determine vertex buffer * and attribute info */ - for (attr = 0; attr < /*vs*/vp->num_inputs; attr++) { + for (attr = 0; attr < vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; struct pipe_vertex_element velement; -- cgit v1.2.3 From 39038c11699bbc9baab744542e96d54e91cb452a Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 27 Mar 2008 17:41:55 -0600 Subject: gallium: replace PIPE_ATTRIB_MAX with PIPE_MAX_ATTRIBS The later follows the naming scheme of other limits. Keep the old definition until all possible usage is updated. --- src/gallium/auxiliary/draw/draw_context.c | 4 ++-- src/gallium/auxiliary/draw/draw_private.h | 12 ++++++------ src/gallium/auxiliary/draw/draw_pt_fetch_emit.c | 2 +- src/gallium/auxiliary/draw/draw_vf.c | 4 ++-- src/gallium/auxiliary/draw/draw_vf.h | 2 +- src/gallium/auxiliary/draw/draw_vs_exec.c | 4 ++-- src/gallium/auxiliary/draw/draw_vs_llvm.c | 4 ++-- src/gallium/auxiliary/draw/draw_vs_sse.c | 4 ++-- src/gallium/drivers/cell/ppu/cell_context.h | 6 +++--- src/gallium/drivers/cell/ppu/cell_draw_arrays.c | 4 ++-- src/gallium/drivers/cell/ppu/cell_state_vertex.c | 4 ++-- src/gallium/drivers/cell/ppu/cell_vertex_fetch.c | 2 +- src/gallium/drivers/cell/spu/spu_main.c | 4 ++-- src/gallium/drivers/cell/spu/spu_vertex_shader.c | 4 ++-- src/gallium/drivers/cell/spu/spu_vertex_shader.h | 8 ++++---- src/gallium/drivers/failover/fo_context.h | 4 ++-- src/gallium/drivers/failover/fo_state_emit.c | 4 ++-- src/gallium/drivers/i915simple/i915_context.c | 4 ++-- src/gallium/drivers/i915simple/i915_context.h | 2 +- src/gallium/drivers/i965simple/brw_clip.h | 2 +- src/gallium/drivers/i965simple/brw_context.h | 12 ++++++------ src/gallium/drivers/i965simple/brw_state.c | 2 +- src/gallium/drivers/i965simple/brw_wm.h | 4 ++-- src/gallium/drivers/softpipe/sp_context.h | 6 +++--- src/gallium/drivers/softpipe/sp_draw_arrays.c | 4 ++-- src/gallium/drivers/softpipe/sp_quad_fs.c | 4 ++-- src/gallium/drivers/softpipe/sp_state_vertex.c | 4 ++-- src/gallium/include/pipe/p_state.h | 3 ++- src/mesa/state_tracker/st_draw.c | 2 +- 29 files changed, 63 insertions(+), 62 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 903cc26766..81858e01ca 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -238,7 +238,7 @@ draw_set_vertex_buffer(struct draw_context *draw, const struct pipe_vertex_buffer *buffer) { draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE/*STATE_CHANGE*/ ); - assert(attr < PIPE_ATTRIB_MAX); + assert(attr < PIPE_MAX_ATTRIBS); draw->vertex_buffer[attr] = *buffer; } @@ -249,7 +249,7 @@ draw_set_vertex_element(struct draw_context *draw, const struct pipe_vertex_element *element) { draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE/*STATE_CHANGE*/ ); - assert(attr < PIPE_ATTRIB_MAX); + assert(attr < PIPE_MAX_ATTRIBS); draw->vertex_element[attr] = *element; } diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 7007ee22c4..8eb2f515cb 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -228,8 +228,8 @@ struct draw_context /* pipe state that we need: */ const struct pipe_rasterizer_state *rasterizer; struct pipe_viewport_state viewport; - struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; - struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; + struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; + struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; struct draw_vertex_shader *vertex_shader; uint num_vs_outputs; /**< convenience, from vertex_shader */ @@ -242,7 +242,7 @@ struct draw_context unsigned eltSize; /** vertex arrays */ - const void *vbuffer[PIPE_ATTRIB_MAX]; + const void *vbuffer[PIPE_MAX_ATTRIBS]; /** constant buffer (for vertex shader) */ const void *constants; @@ -275,9 +275,9 @@ struct draw_context /* Vertex fetch internal state */ struct { - const ubyte *src_ptr[PIPE_ATTRIB_MAX]; - unsigned pitch[PIPE_ATTRIB_MAX]; - fetch_func fetch[PIPE_ATTRIB_MAX]; + const ubyte *src_ptr[PIPE_MAX_ATTRIBS]; + unsigned pitch[PIPE_MAX_ATTRIBS]; + fetch_func fetch[PIPE_MAX_ATTRIBS]; unsigned nr_attrs; full_fetch_func fetch_func; pt_fetch_func pt_fetch; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index 64ef83d800..9b098bc173 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -78,7 +78,7 @@ struct fetch_emit_middle_end { unsigned pitch; void (*fetch)( const void *from, float *attrib); void (*emit)( const float *attrib, float **out ); - } fetch[PIPE_ATTRIB_MAX]; + } fetch[PIPE_MAX_ATTRIBS]; unsigned nr_fetch; unsigned hw_vertex_size; diff --git a/src/gallium/auxiliary/draw/draw_vf.c b/src/gallium/auxiliary/draw/draw_vf.c index f4e29a6293..7bb34ace7a 100644 --- a/src/gallium/auxiliary/draw/draw_vf.c +++ b/src/gallium/auxiliary/draw/draw_vf.c @@ -158,7 +158,7 @@ draw_vf_set_vertex_attributes( struct draw_vertex_fetch *vf, unsigned offset = 0; unsigned i, j; - assert(nr < PIPE_ATTRIB_MAX); + assert(nr < PIPE_MAX_ATTRIBS); for (j = 0, i = 0; i < nr; i++) { const unsigned format = map[i].format; @@ -390,7 +390,7 @@ struct draw_vertex_fetch *draw_vf_create( void ) struct draw_vertex_fetch *vf = CALLOC_STRUCT(draw_vertex_fetch); unsigned i; - for (i = 0; i < PIPE_ATTRIB_MAX; i++) + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) vf->attr[i].vf = vf; vf->identity[0] = 0.0; diff --git a/src/gallium/auxiliary/draw/draw_vf.h b/src/gallium/auxiliary/draw/draw_vf.h index 011c8f0ff1..7555d1bd58 100644 --- a/src/gallium/auxiliary/draw/draw_vf.h +++ b/src/gallium/auxiliary/draw/draw_vf.h @@ -169,7 +169,7 @@ struct draw_vf_attr struct draw_vertex_fetch { - struct draw_vf_attr attr[PIPE_ATTRIB_MAX]; + struct draw_vf_attr attr[PIPE_MAX_ATTRIBS]; unsigned attr_count; unsigned vertex_stride; diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c index 4e2fa72707..487d0ea7f4 100644 --- a/src/gallium/auxiliary/draw/draw_vs_exec.c +++ b/src/gallium/auxiliary/draw/draw_vs_exec.c @@ -99,8 +99,8 @@ vs_exec_run( struct draw_vertex_shader *shader, struct tgsi_exec_machine *machine = &draw->machine; unsigned int j; - ALIGN16_DECL(struct tgsi_exec_vector, inputs, PIPE_ATTRIB_MAX); - ALIGN16_DECL(struct tgsi_exec_vector, outputs, PIPE_ATTRIB_MAX); + ALIGN16_DECL(struct tgsi_exec_vector, inputs, PIPE_MAX_ATTRIBS); + ALIGN16_DECL(struct tgsi_exec_vector, outputs, PIPE_MAX_ATTRIBS); const float *scale = draw->viewport.scale; const float *trans = draw->viewport.translate; diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c index bd983f2ddf..d29cb18efe 100644 --- a/src/gallium/auxiliary/draw/draw_vs_llvm.c +++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c @@ -107,8 +107,8 @@ vs_llvm_run( struct draw_vertex_shader *base, struct tgsi_exec_machine *machine = &draw->machine; unsigned int j; - ALIGN16_DECL(struct tgsi_exec_vector, inputs, PIPE_ATTRIB_MAX); - ALIGN16_DECL(struct tgsi_exec_vector, outputs, PIPE_ATTRIB_MAX); + ALIGN16_DECL(struct tgsi_exec_vector, inputs, PIPE_MAX_ATTRIBS); + ALIGN16_DECL(struct tgsi_exec_vector, outputs, PIPE_MAX_ATTRIBS); const float *scale = draw->viewport.scale; const float *trans = draw->viewport.translate; diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c index a4503c143e..bc910dc2d0 100644 --- a/src/gallium/auxiliary/draw/draw_vs_sse.c +++ b/src/gallium/auxiliary/draw/draw_vs_sse.c @@ -114,8 +114,8 @@ vs_sse_run( struct draw_vertex_shader *base, struct tgsi_exec_machine *machine = &draw->machine; unsigned int j; - ALIGN16_DECL(struct tgsi_exec_vector, inputs, PIPE_ATTRIB_MAX); - ALIGN16_DECL(struct tgsi_exec_vector, outputs, PIPE_ATTRIB_MAX); + ALIGN16_DECL(struct tgsi_exec_vector, inputs, PIPE_MAX_ATTRIBS); + ALIGN16_DECL(struct tgsi_exec_vector, outputs, PIPE_MAX_ATTRIBS); const float *scale = draw->viewport.scale; const float *trans = draw->viewport.translate; diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h index 0442abddc1..7f656a9744 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.h +++ b/src/gallium/drivers/cell/ppu/cell_context.h @@ -103,8 +103,8 @@ struct cell_context struct cell_texture *texture[PIPE_MAX_SAMPLERS]; uint num_textures; struct pipe_viewport_state viewport; - struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; - struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; + struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; + struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; ubyte *cbuf_map[PIPE_MAX_COLOR_BUFS]; ubyte *zsbuf_map; @@ -141,7 +141,7 @@ struct cell_context struct spe_function attrib_fetch; - unsigned attrib_fetch_offsets[PIPE_ATTRIB_MAX]; + unsigned attrib_fetch_offsets[PIPE_MAX_ATTRIBS]; }; diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index c839fb4d12..b896252f81 100644 --- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c +++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c @@ -123,7 +123,7 @@ cell_draw_elements(struct pipe_context *pipe, /* * Map vertex buffers */ - for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (sp->vertex_buffer[i].buffer) { void *buf = pipe->winsys->buffer_map(pipe->winsys, sp->vertex_buffer[i].buffer, @@ -151,7 +151,7 @@ cell_draw_elements(struct pipe_context *pipe, /* * unmap vertex/index buffers - will cause draw module to flush */ - for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (sp->vertex_buffer[i].buffer) { draw_set_mapped_vertex_buffer(draw, i, NULL); pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer); diff --git a/src/gallium/drivers/cell/ppu/cell_state_vertex.c b/src/gallium/drivers/cell/ppu/cell_state_vertex.c index 563831b62d..37d25fb357 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_vertex.c +++ b/src/gallium/drivers/cell/ppu/cell_state_vertex.c @@ -41,7 +41,7 @@ cell_set_vertex_element(struct pipe_context *pipe, const struct pipe_vertex_element *attrib) { struct cell_context *cell = cell_context(pipe); - assert(index < PIPE_ATTRIB_MAX); + assert(index < PIPE_MAX_ATTRIBS); cell->vertex_element[index] = *attrib; /* struct copy */ cell->dirty |= CELL_NEW_VERTEX; @@ -55,7 +55,7 @@ cell_set_vertex_buffer(struct pipe_context *pipe, const struct pipe_vertex_buffer *buffer) { struct cell_context *cell = cell_context(pipe); - assert(index < PIPE_ATTRIB_MAX); + assert(index < PIPE_MAX_ATTRIBS); cell->vertex_buffer[index] = *buffer; /* struct copy */ cell->dirty |= CELL_NEW_VERTEX; diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c b/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c index 4828a8023b..49d5443cde 100644 --- a/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c +++ b/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c @@ -263,7 +263,7 @@ void cell_update_vertex_fetch(struct draw_context *draw) struct cell_context *const cell = (struct cell_context *) draw->driver_private; struct spe_function *p = &cell->attrib_fetch; - unsigned function_index[PIPE_ATTRIB_MAX]; + unsigned function_index[PIPE_MAX_ATTRIBS]; unsigned unique_attr_formats; int out_ptr; int in_ptr; diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c index fccff01e10..d7f46f8024 100644 --- a/src/gallium/drivers/cell/spu/spu_main.c +++ b/src/gallium/drivers/cell/spu/spu_main.c @@ -55,7 +55,7 @@ struct spu_global spu; struct spu_vs_context draw; -static unsigned char attribute_fetch_code_buffer[136 * PIPE_ATTRIB_MAX] +static unsigned char attribute_fetch_code_buffer[136 * PIPE_MAX_ATTRIBS] ALIGN16_ATTRIB; static unsigned char depth_stencil_code_buffer[4 * 64] @@ -361,7 +361,7 @@ cmd_state_vs_array_info(const struct cell_array_info *vs_info) { const unsigned attr = vs_info->attr; - ASSERT(attr < PIPE_ATTRIB_MAX); + ASSERT(attr < PIPE_MAX_ATTRIBS); draw.vertex_fetch.src_ptr[attr] = vs_info->base; draw.vertex_fetch.pitch[attr] = vs_info->pitch; draw.vertex_fetch.size[attr] = vs_info->size; diff --git a/src/gallium/drivers/cell/spu/spu_vertex_shader.c b/src/gallium/drivers/cell/spu/spu_vertex_shader.c index 8363efeeb6..3119a78c06 100644 --- a/src/gallium/drivers/cell/spu/spu_vertex_shader.c +++ b/src/gallium/drivers/cell/spu/spu_vertex_shader.c @@ -86,8 +86,8 @@ run_vertex_program(struct spu_vs_context *draw, struct spu_exec_machine *machine = &draw->machine; unsigned int j; - ALIGN16_DECL(struct spu_exec_vector, inputs, PIPE_ATTRIB_MAX); - ALIGN16_DECL(struct spu_exec_vector, outputs, PIPE_ATTRIB_MAX); + ALIGN16_DECL(struct spu_exec_vector, inputs, PIPE_MAX_ATTRIBS); + ALIGN16_DECL(struct spu_exec_vector, outputs, PIPE_MAX_ATTRIBS); const float *scale = draw->viewport.scale; const float *trans = draw->viewport.translate; diff --git a/src/gallium/drivers/cell/spu/spu_vertex_shader.h b/src/gallium/drivers/cell/spu/spu_vertex_shader.h index 54a4b8d9b9..4c74f5e74d 100644 --- a/src/gallium/drivers/cell/spu/spu_vertex_shader.h +++ b/src/gallium/drivers/cell/spu/spu_vertex_shader.h @@ -16,10 +16,10 @@ struct spu_vs_context { struct pipe_viewport_state viewport; struct { - uint64_t src_ptr[PIPE_ATTRIB_MAX]; - unsigned pitch[PIPE_ATTRIB_MAX]; - unsigned size[PIPE_ATTRIB_MAX]; - unsigned code_offset[PIPE_ATTRIB_MAX]; + uint64_t src_ptr[PIPE_MAX_ATTRIBS]; + unsigned pitch[PIPE_MAX_ATTRIBS]; + unsigned size[PIPE_MAX_ATTRIBS]; + unsigned code_offset[PIPE_MAX_ATTRIBS]; unsigned nr_attrs; boolean dirty; diff --git a/src/gallium/drivers/failover/fo_context.h b/src/gallium/drivers/failover/fo_context.h index 8f3ad3ee79..4afe10c4b8 100644 --- a/src/gallium/drivers/failover/fo_context.h +++ b/src/gallium/drivers/failover/fo_context.h @@ -84,8 +84,8 @@ struct failover_context { struct pipe_scissor_state scissor; struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; - struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; - struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; + struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; + struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; void *sw_sampler_state[PIPE_MAX_SAMPLERS]; void *hw_sampler_state[PIPE_MAX_SAMPLERS]; diff --git a/src/gallium/drivers/failover/fo_state_emit.c b/src/gallium/drivers/failover/fo_state_emit.c index 3de931e04e..bb89f925e9 100644 --- a/src/gallium/drivers/failover/fo_state_emit.c +++ b/src/gallium/drivers/failover/fo_state_emit.c @@ -104,7 +104,7 @@ failover_state_emit( struct failover_context *failover ) } if (failover->dirty & FO_NEW_VERTEX_BUFFER) { - for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (failover->dirty_vertex_buffer & (1<sw->set_vertex_buffer( failover->sw, i, &failover->vertex_buffer[i] ); @@ -113,7 +113,7 @@ failover_state_emit( struct failover_context *failover ) } if (failover->dirty & FO_NEW_VERTEX_ELEMENT) { - for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (failover->dirty_vertex_element & (1<sw->set_vertex_element( failover->sw, i, &failover->vertex_element[i] ); diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c index 15ff2360b7..fee33d82de 100644 --- a/src/gallium/drivers/i915simple/i915_context.c +++ b/src/gallium/drivers/i915simple/i915_context.c @@ -65,7 +65,7 @@ i915_draw_elements( struct pipe_context *pipe, /* * Map vertex buffers */ - for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (i915->vertex_buffer[i].buffer) { void *buf = pipe->winsys->buffer_map(pipe->winsys, @@ -96,7 +96,7 @@ i915_draw_elements( struct pipe_context *pipe, /* * unmap vertex/index buffers */ - for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (i915->vertex_buffer[i].buffer) { pipe->winsys->buffer_unmap(pipe->winsys, i915->vertex_buffer[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h index 746f18ba38..8e707ea574 100644 --- a/src/gallium/drivers/i915simple/i915_context.h +++ b/src/gallium/drivers/i915simple/i915_context.h @@ -232,7 +232,7 @@ struct i915_context struct pipe_scissor_state scissor; struct i915_texture *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; - struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; + struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; unsigned dirty; diff --git a/src/gallium/drivers/i965simple/brw_clip.h b/src/gallium/drivers/i965simple/brw_clip.h index a89d08b791..d70fc094ff 100644 --- a/src/gallium/drivers/i965simple/brw_clip.h +++ b/src/gallium/drivers/i965simple/brw_clip.h @@ -116,7 +116,7 @@ struct brw_clip_compile { unsigned last_mrf; unsigned header_position_offset; - unsigned offset[PIPE_ATTRIB_MAX]; + unsigned offset[PIPE_MAX_ATTRIBS]; }; #define ATTR_SIZE (4*4) diff --git a/src/gallium/drivers/i965simple/brw_context.h b/src/gallium/drivers/i965simple/brw_context.h index b83a13c3b6..0c96ba1732 100644 --- a/src/gallium/drivers/i965simple/brw_context.h +++ b/src/gallium/drivers/i965simple/brw_context.h @@ -433,17 +433,17 @@ struct brw_cached_batch_item { -/* Protect against a future where PIPE_ATTRIB_MAX > 32. Wouldn't life +/* Protect against a future where PIPE_MAX_ATTRIBS > 32. Wouldn't life * be easier if C allowed arrays of packed elements? */ -#define ATTRIB_BIT_DWORDS ((PIPE_ATTRIB_MAX+31)/32) +#define ATTRIB_BIT_DWORDS ((PIPE_MAX_ATTRIBS+31)/32) struct brw_vertex_info { - unsigned varying; /* varying:1[PIPE_ATTRIB_MAX] */ - unsigned sizes[ATTRIB_BIT_DWORDS * 2]; /* sizes:2[PIPE_ATTRIB_MAX] */ + unsigned varying; /* varying:1[PIPE_MAX_ATTRIBS] */ + unsigned sizes[ATTRIB_BIT_DWORDS * 2]; /* sizes:2[PIPE_MAX_ATTRIBS] */ }; @@ -496,9 +496,9 @@ struct brw_context /* Arrays with buffer objects to copy non-bufferobj arrays into * for upload: */ - const struct pipe_vertex_buffer *vbo_array[PIPE_ATTRIB_MAX]; + const struct pipe_vertex_buffer *vbo_array[PIPE_MAX_ATTRIBS]; - struct brw_vertex_element_state inputs[PIPE_ATTRIB_MAX]; + struct brw_vertex_element_state inputs[PIPE_MAX_ATTRIBS]; #define BRW_NR_UPLOAD_BUFS 17 #define BRW_UPLOAD_INIT_SIZE (128*1024) diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c index f5efe9fc06..0d04a8a594 100644 --- a/src/gallium/drivers/i965simple/brw_state.c +++ b/src/gallium/drivers/i965simple/brw_state.c @@ -292,7 +292,7 @@ static void brw_set_vertex_element(struct pipe_context *pipe, /* flush ? */ struct brw_context *brw = brw_context(pipe); - assert(index < PIPE_ATTRIB_MAX); + assert(index < PIPE_MAX_ATTRIBS); struct brw_vertex_element_state el; memset(&el, 0, sizeof(el)); diff --git a/src/gallium/drivers/i965simple/brw_wm.h b/src/gallium/drivers/i965simple/brw_wm.h index a1ac0f504a..b29c4393f0 100644 --- a/src/gallium/drivers/i965simple/brw_wm.h +++ b/src/gallium/drivers/i965simple/brw_wm.h @@ -76,7 +76,7 @@ struct brw_wm_prog_key { #define PROGRAM_INTERNAL_PARAM #define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */ -#define BRW_WM_MAX_INSN (MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS*3 + PIPE_ATTRIB_MAX + 3) +#define BRW_WM_MAX_INSN (MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS*3 + PIPE_MAX_ATTRIBS + 3) #define BRW_WM_MAX_GRF 128 /* hardware limit */ #define BRW_WM_MAX_VREG (BRW_WM_MAX_INSN * 4) #define BRW_WM_MAX_REF (BRW_WM_MAX_INSN * 12) @@ -84,7 +84,7 @@ struct brw_wm_prog_key { #define BRW_WM_MAX_CONST 256 #define BRW_WM_MAX_KILLS MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS -#define PAYLOAD_DEPTH (PIPE_ATTRIB_MAX) +#define PAYLOAD_DEPTH (PIPE_MAX_ATTRIBS) #define MAX_IFSN 32 #define MAX_LOOP_DEPTH 32 diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 19e6cfaf02..dc9d0e6d5d 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -77,8 +77,8 @@ struct softpipe_context { struct pipe_scissor_state scissor; struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; - struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; - struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; + struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; + struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; unsigned dirty; unsigned num_samplers; @@ -92,7 +92,7 @@ struct softpipe_context { /* * Mapped vertex buffers */ - ubyte *mapped_vbuffer[PIPE_ATTRIB_MAX]; + ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS]; /** Mapped constant buffers */ void *mapped_constants[PIPE_SHADER_TYPES]; diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 5b5a0fe573..ab54050d3f 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -125,7 +125,7 @@ softpipe_draw_elements(struct pipe_context *pipe, /* * Map vertex buffers */ - for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (sp->vertex_buffer[i].buffer) { void *buf = pipe->winsys->buffer_map(pipe->winsys, @@ -153,7 +153,7 @@ softpipe_draw_elements(struct pipe_context *pipe, /* * unmap vertex/index buffers - will cause draw module to flush */ - for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (sp->vertex_buffer[i].buffer) { draw_set_mapped_vertex_buffer(draw, i, NULL); pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer); diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index 861285101f..c10ad80e01 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -185,8 +185,8 @@ struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe ) uint i; /* allocate storage for program inputs/outputs, aligned to 16 bytes */ - qss->inputs = MALLOC(PIPE_ATTRIB_MAX * sizeof(*qss->inputs) + 16); - qss->outputs = MALLOC(PIPE_ATTRIB_MAX * sizeof(*qss->outputs) + 16); + qss->inputs = MALLOC(PIPE_MAX_ATTRIBS * sizeof(*qss->inputs) + 16); + qss->outputs = MALLOC(PIPE_MAX_ATTRIBS * sizeof(*qss->outputs) + 16); qss->machine.Inputs = align16(qss->inputs); qss->machine.Outputs = align16(qss->outputs); diff --git a/src/gallium/drivers/softpipe/sp_state_vertex.c b/src/gallium/drivers/softpipe/sp_state_vertex.c index f01a10de3b..c054e76d9b 100644 --- a/src/gallium/drivers/softpipe/sp_state_vertex.c +++ b/src/gallium/drivers/softpipe/sp_state_vertex.c @@ -42,7 +42,7 @@ softpipe_set_vertex_element(struct pipe_context *pipe, const struct pipe_vertex_element *attrib) { struct softpipe_context *softpipe = softpipe_context(pipe); - assert(index < PIPE_ATTRIB_MAX); + assert(index < PIPE_MAX_ATTRIBS); softpipe->vertex_element[index] = *attrib; /* struct copy */ softpipe->dirty |= SP_NEW_VERTEX; @@ -56,7 +56,7 @@ softpipe_set_vertex_buffer(struct pipe_context *pipe, const struct pipe_vertex_buffer *buffer) { struct softpipe_context *softpipe = softpipe_context(pipe); - assert(index < PIPE_ATTRIB_MAX); + assert(index < PIPE_MAX_ATTRIBS); softpipe->vertex_buffer[index] = *buffer; /* struct copy */ softpipe->dirty |= SP_NEW_VERTEX; diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index a2bd8c6aaa..2490412126 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -54,7 +54,8 @@ extern "C" { #define PIPE_MAX_SAMPLERS 8 #define PIPE_MAX_CLIP_PLANES 6 #define PIPE_MAX_CONSTANT 32 -#define PIPE_ATTRIB_MAX 32 +#define PIPE_MAX_ATTRIBS 32 +#define PIPE_ATTRIB_MAX 32 /* XXX obsolete - remove */ #define PIPE_MAX_COLOR_BUFS 8 #define PIPE_MAX_TEXTURE_LEVELS 16 #define PIPE_MAX_FEEDBACK_ATTRIBS 16 diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 20af90df7d..4aca3311b7 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -606,7 +606,7 @@ st_feedback_draw_vbo(GLcontext *ctx, /* * unmap vertex/index buffers */ - for (i = 0; i < PIPE_ATTRIB_MAX; i++) { + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (draw->vertex_buffer[i].buffer) { pipe->winsys->buffer_unmap(pipe->winsys, draw->vertex_buffer[i].buffer); -- cgit v1.2.3 From a52c0416d1f2105960b4646e2e268aed26814689 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 29 Mar 2008 14:41:03 +0100 Subject: gallium: Set vertex state/buffers en-mass. --- src/gallium/auxiliary/draw/draw_context.c | 24 ++++--- src/gallium/auxiliary/draw/draw_context.h | 12 ++-- src/gallium/auxiliary/util/u_draw_quad.c | 16 +++-- src/gallium/drivers/cell/ppu/cell_context.c | 4 +- src/gallium/drivers/cell/ppu/cell_state.h | 12 ++-- src/gallium/drivers/cell/ppu/cell_state_vertex.c | 30 +++++---- src/gallium/drivers/failover/fo_context.h | 9 +-- src/gallium/drivers/failover/fo_state.c | 35 +++++----- src/gallium/drivers/failover/fo_state_emit.c | 22 ++----- src/gallium/drivers/i915simple/i915_state.c | 23 +++---- src/gallium/drivers/i965simple/brw_state.c | 60 +++++++++-------- src/gallium/drivers/softpipe/sp_context.c | 4 +- src/gallium/drivers/softpipe/sp_state.h | 12 ++-- src/gallium/drivers/softpipe/sp_state_vertex.c | 31 +++++---- src/gallium/include/pipe/p_context.h | 12 ++-- src/mesa/state_tracker/st_draw.c | 82 +++++++++++++----------- 16 files changed, 205 insertions(+), 183 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 81858e01ca..10bf9f54c1 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -233,24 +233,28 @@ void draw_set_viewport_state( struct draw_context *draw, void -draw_set_vertex_buffer(struct draw_context *draw, - unsigned attr, - const struct pipe_vertex_buffer *buffer) +draw_set_vertex_buffers(struct draw_context *draw, + unsigned count, + const struct pipe_vertex_buffer *buffers) { + assert(count <= PIPE_MAX_ATTRIBS); + draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE/*STATE_CHANGE*/ ); - assert(attr < PIPE_MAX_ATTRIBS); - draw->vertex_buffer[attr] = *buffer; + + memcpy(draw->vertex_buffer, buffers, count * sizeof(buffers[0])); } void -draw_set_vertex_element(struct draw_context *draw, - unsigned attr, - const struct pipe_vertex_element *element) +draw_set_vertex_elements(struct draw_context *draw, + unsigned count, + const struct pipe_vertex_element *elements) { + assert(count <= PIPE_MAX_ATTRIBS); + draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE/*STATE_CHANGE*/ ); - assert(attr < PIPE_MAX_ATTRIBS); - draw->vertex_element[attr] = *element; + + memcpy(draw->vertex_element, elements, count * sizeof(elements[0])); } diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index dae687e590..84bae3bd78 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -138,13 +138,13 @@ void draw_delete_vertex_shader(struct draw_context *draw, * Vertex data functions */ -void draw_set_vertex_buffer(struct draw_context *draw, - unsigned attr, - const struct pipe_vertex_buffer *buffer); +void draw_set_vertex_buffers(struct draw_context *draw, + unsigned count, + const struct pipe_vertex_buffer *buffers); -void draw_set_vertex_element(struct draw_context *draw, - unsigned attr, - const struct pipe_vertex_element *element); +void draw_set_vertex_elements(struct draw_context *draw, + unsigned count, + const struct pipe_vertex_element *elements); void draw_set_mapped_element_buffer( struct draw_context *draw, unsigned eltSize, void *elements ); diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c index 37e8533609..e659edb088 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.c +++ b/src/gallium/auxiliary/util/u_draw_quad.c @@ -45,23 +45,25 @@ util_draw_vertex_buffer(struct pipe_context *pipe, uint num_attribs) { struct pipe_vertex_buffer vbuffer; - struct pipe_vertex_element velement; + struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; uint i; + assert(num_attribs <= PIPE_MAX_ATTRIBS); + /* tell pipe about the vertex buffer */ vbuffer.buffer = vbuf; vbuffer.pitch = num_attribs * 4 * sizeof(float); /* vertex size */ vbuffer.buffer_offset = 0; - pipe->set_vertex_buffer(pipe, 0, &vbuffer); + pipe->set_vertex_buffers(pipe, 1, &vbuffer); /* tell pipe about the vertex attributes */ for (i = 0; i < num_attribs; i++) { - velement.src_offset = i * 4 * sizeof(float); - velement.vertex_buffer_index = 0; - velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - velement.nr_components = 4; - pipe->set_vertex_element(pipe, i, &velement); + velements[i].src_offset = i * 4 * sizeof(float); + velements[i].vertex_buffer_index = 0; + velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velements[i].nr_components = 4; } + pipe->set_vertex_elements(pipe, num_attribs, velements); /* draw */ pipe->draw_arrays(pipe, prim_type, 0, num_verts); diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c index ccbbd1d331..12eb5aa254 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.c +++ b/src/gallium/drivers/cell/ppu/cell_context.c @@ -103,8 +103,8 @@ cell_create_context(struct pipe_screen *screen, cell->pipe.destroy = cell_destroy_context; /* state setters */ - cell->pipe.set_vertex_buffer = cell_set_vertex_buffer; - cell->pipe.set_vertex_element = cell_set_vertex_element; + cell->pipe.set_vertex_buffers = cell_set_vertex_buffers; + cell->pipe.set_vertex_elements = cell_set_vertex_elements; cell->pipe.draw_arrays = cell_draw_arrays; cell->pipe.draw_elements = cell_draw_elements; diff --git a/src/gallium/drivers/cell/ppu/cell_state.h b/src/gallium/drivers/cell/ppu/cell_state.h index 31ce505e21..82580ea35a 100644 --- a/src/gallium/drivers/cell/ppu/cell_state.h +++ b/src/gallium/drivers/cell/ppu/cell_state.h @@ -48,13 +48,13 @@ #define CELL_NEW_VERTEX_INFO 0x8000 -void cell_set_vertex_element(struct pipe_context *, - unsigned index, - const struct pipe_vertex_element *); +void cell_set_vertex_elements(struct pipe_context *, + unsigned count, + const struct pipe_vertex_element *); -void cell_set_vertex_buffer(struct pipe_context *, - unsigned index, - const struct pipe_vertex_buffer *); +void cell_set_vertex_buffers(struct pipe_context *, + unsigned count, + const struct pipe_vertex_buffer *); void cell_update_derived( struct cell_context *softpipe ); diff --git a/src/gallium/drivers/cell/ppu/cell_state_vertex.c b/src/gallium/drivers/cell/ppu/cell_state_vertex.c index 37d25fb357..6c83b8dc72 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_vertex.c +++ b/src/gallium/drivers/cell/ppu/cell_state_vertex.c @@ -36,28 +36,34 @@ void -cell_set_vertex_element(struct pipe_context *pipe, - unsigned index, - const struct pipe_vertex_element *attrib) +cell_set_vertex_elements(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *elements) { struct cell_context *cell = cell_context(pipe); - assert(index < PIPE_MAX_ATTRIBS); - cell->vertex_element[index] = *attrib; /* struct copy */ + + assert(count <= PIPE_MAX_ATTRIBS); + + memcpy(cell->vertex_element, elements, count * sizeof(elements[0])); + cell->dirty |= CELL_NEW_VERTEX; - draw_set_vertex_element(cell->draw, index, attrib); + draw_set_vertex_elements(cell->draw, count, elements); } void -cell_set_vertex_buffer(struct pipe_context *pipe, - unsigned index, - const struct pipe_vertex_buffer *buffer) +cell_set_vertex_buffers(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_buffer *buffers) { struct cell_context *cell = cell_context(pipe); - assert(index < PIPE_MAX_ATTRIBS); - cell->vertex_buffer[index] = *buffer; /* struct copy */ + + assert(count <= PIPE_MAX_ATTRIBS); + + memcpy(cell->vertex_buffer, buffers, count * sizeof(buffers[0])); + cell->dirty |= CELL_NEW_VERTEX; - draw_set_vertex_buffer(cell->draw, index, buffer); + draw_set_vertex_buffers(cell->draw, count, buffers); } diff --git a/src/gallium/drivers/failover/fo_context.h b/src/gallium/drivers/failover/fo_context.h index 4afe10c4b8..c6409fe1e1 100644 --- a/src/gallium/drivers/failover/fo_context.h +++ b/src/gallium/drivers/failover/fo_context.h @@ -84,15 +84,16 @@ struct failover_context { struct pipe_scissor_state scissor; struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; struct pipe_viewport_state viewport; - struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; - struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; + struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; + struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS]; + + uint num_vertex_buffers; + uint num_vertex_elements; void *sw_sampler_state[PIPE_MAX_SAMPLERS]; void *hw_sampler_state[PIPE_MAX_SAMPLERS]; unsigned dirty; - unsigned dirty_vertex_buffer; - unsigned dirty_vertex_element; unsigned num_samplers; unsigned num_textures; diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c index 11eec2714e..6a79706632 100644 --- a/src/gallium/drivers/failover/fo_state.c +++ b/src/gallium/drivers/failover/fo_state.c @@ -402,32 +402,35 @@ failover_set_viewport_state( struct pipe_context *pipe, static void -failover_set_vertex_buffer(struct pipe_context *pipe, - unsigned unit, - const struct pipe_vertex_buffer *vertex_buffer) +failover_set_vertex_buffers(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_buffer *vertex_buffers) { struct failover_context *failover = failover_context(pipe); - failover->vertex_buffer[unit] = *vertex_buffer; + memcpy(failover->vertex_buffers, vertex_buffers, + count * sizeof(vertex_buffers[0])); failover->dirty |= FO_NEW_VERTEX_BUFFER; - failover->dirty_vertex_buffer |= (1<sw->set_vertex_buffer( failover->sw, unit, vertex_buffer ); - failover->hw->set_vertex_buffer( failover->hw, unit, vertex_buffer ); + failover->num_vertex_buffers = count; + failover->sw->set_vertex_buffers( failover->sw, count, vertex_buffers ); + failover->hw->set_vertex_buffers( failover->hw, count, vertex_buffers ); } static void -failover_set_vertex_element(struct pipe_context *pipe, - unsigned unit, - const struct pipe_vertex_element *vertex_element) +failover_set_vertex_elements(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *vertex_elements) { struct failover_context *failover = failover_context(pipe); - failover->vertex_element[unit] = *vertex_element; + memcpy(failover->vertex_elements, vertex_elements, + count * sizeof(vertex_elements[0])); + failover->dirty |= FO_NEW_VERTEX_ELEMENT; - failover->dirty_vertex_element |= (1<sw->set_vertex_element( failover->sw, unit, vertex_element ); - failover->hw->set_vertex_element( failover->hw, unit, vertex_element ); + failover->num_vertex_elements = count; + failover->sw->set_vertex_elements( failover->sw, count, vertex_elements ); + failover->hw->set_vertex_elements( failover->hw, count, vertex_elements ); } void @@ -474,7 +477,7 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.set_scissor_state = failover_set_scissor_state; failover->pipe.set_sampler_textures = failover_set_sampler_textures; failover->pipe.set_viewport_state = failover_set_viewport_state; - failover->pipe.set_vertex_buffer = failover_set_vertex_buffer; - failover->pipe.set_vertex_element = failover_set_vertex_element; + failover->pipe.set_vertex_buffers = failover_set_vertex_buffers; + failover->pipe.set_vertex_elements = failover_set_vertex_elements; failover->pipe.set_constant_buffer = failover_set_constant_buffer; } diff --git a/src/gallium/drivers/failover/fo_state_emit.c b/src/gallium/drivers/failover/fo_state_emit.c index bb89f925e9..bd4fce9d20 100644 --- a/src/gallium/drivers/failover/fo_state_emit.c +++ b/src/gallium/drivers/failover/fo_state_emit.c @@ -53,8 +53,6 @@ void failover_state_emit( struct failover_context *failover ) { - unsigned i; - if (failover->dirty & FO_NEW_BLEND) failover->sw->bind_blend_state( failover->sw, failover->blend->sw_state ); @@ -104,24 +102,16 @@ failover_state_emit( struct failover_context *failover ) } if (failover->dirty & FO_NEW_VERTEX_BUFFER) { - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (failover->dirty_vertex_buffer & (1<sw->set_vertex_buffer( failover->sw, i, - &failover->vertex_buffer[i] ); - } - } + failover->sw->set_vertex_buffers( failover->sw, + failover->num_vertex_buffers, + failover->vertex_buffers ); } if (failover->dirty & FO_NEW_VERTEX_ELEMENT) { - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (failover->dirty_vertex_element & (1<sw->set_vertex_element( failover->sw, i, - &failover->vertex_element[i] ); - } - } + failover->sw->set_vertex_elements( failover->sw, + failover->num_vertex_elements, + failover->vertex_elements ); } failover->dirty = 0; - failover->dirty_vertex_element = 0; - failover->dirty_vertex_buffer = 0; } diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c index 1cec36e206..4404bc4590 100644 --- a/src/gallium/drivers/i915simple/i915_state.c +++ b/src/gallium/drivers/i915simple/i915_state.c @@ -687,23 +687,24 @@ static void i915_delete_rasterizer_state(struct pipe_context *pipe, FREE(raster); } -static void i915_set_vertex_buffer( struct pipe_context *pipe, - unsigned index, - const struct pipe_vertex_buffer *buffer ) +static void i915_set_vertex_buffers(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_buffer *buffers) { struct i915_context *i915 = i915_context(pipe); - i915->vertex_buffer[index] = *buffer; + + memcpy(i915->vertex_buffer, buffers, count * sizeof(buffers[0])); /* pass-through to draw module */ - draw_set_vertex_buffer(i915->draw, index, buffer); + draw_set_vertex_buffers(i915->draw, count, buffers); } -static void i915_set_vertex_element( struct pipe_context *pipe, - unsigned index, - const struct pipe_vertex_element *element) +static void i915_set_vertex_elements(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *elements) { struct i915_context *i915 = i915_context(pipe); /* pass-through to draw module */ - draw_set_vertex_element(i915->draw, index, element); + draw_set_vertex_elements(i915->draw, count, elements); } @@ -742,6 +743,6 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.set_scissor_state = i915_set_scissor_state; i915->pipe.set_sampler_textures = i915_set_sampler_textures; i915->pipe.set_viewport_state = i915_set_viewport_state; - i915->pipe.set_vertex_buffer = i915_set_vertex_buffer; - i915->pipe.set_vertex_element = i915_set_vertex_element; + i915->pipe.set_vertex_buffers = i915_set_vertex_buffers; + i915->pipe.set_vertex_elements = i915_set_vertex_elements; } diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c index 0d04a8a594..376f1487b2 100644 --- a/src/gallium/drivers/i965simple/brw_state.c +++ b/src/gallium/drivers/i965simple/brw_state.c @@ -277,45 +277,49 @@ static void brw_set_viewport_state( struct pipe_context *pipe, } -static void brw_set_vertex_buffer( struct pipe_context *pipe, - unsigned index, - const struct pipe_vertex_buffer *buffer ) +static void brw_set_vertex_buffers(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_buffer *buffers) { struct brw_context *brw = brw_context(pipe); - brw->vb.vbo_array[index] = buffer; + memcpy(brw->vb.vbo_array, buffers, count * sizeof(buffers[0])); } -static void brw_set_vertex_element(struct pipe_context *pipe, - unsigned index, - const struct pipe_vertex_element *element) +static void brw_set_vertex_elements(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *elements) { /* flush ? */ struct brw_context *brw = brw_context(pipe); + uint i; - assert(index < PIPE_MAX_ATTRIBS); - struct brw_vertex_element_state el; - memset(&el, 0, sizeof(el)); + assert(count <= PIPE_MAX_ATTRIBS); - el.ve0.src_offset = element->src_offset; - el.ve0.src_format = brw_translate_surface_format(element->src_format); - el.ve0.valid = 1; - el.ve0.vertex_buffer_index = element->vertex_buffer_index; + for (i = 0; i < count; i++) { + struct brw_vertex_element_state el; + memset(&el, 0, sizeof(el)); - el.ve1.dst_offset = index * 4; + el.ve0.src_offset = elements[i].src_offset; + el.ve0.src_format = brw_translate_surface_format(elements[i].src_format); + el.ve0.valid = 1; + el.ve0.vertex_buffer_index = elements[i].vertex_buffer_index; - el.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_SRC; - el.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_SRC; - el.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_SRC; - el.ve1.vfcomponent0 = BRW_VFCOMPONENT_STORE_SRC; + el.ve1.dst_offset = i * 4; - switch (element->nr_components) { - case 1: el.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_0; - case 2: el.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_0; - case 3: el.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_1_FLT; - break; - } + el.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_SRC; + el.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_SRC; + el.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_SRC; + el.ve1.vfcomponent0 = BRW_VFCOMPONENT_STORE_SRC; - brw->vb.inputs[index] = el; + switch (elements[i].nr_components) { + case 1: el.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_0; + case 2: el.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_0; + case 3: el.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_1_FLT; + break; + } + + brw->vb.inputs[i] = el; + } } @@ -457,6 +461,6 @@ brw_init_state_functions( struct brw_context *brw ) brw->pipe.set_scissor_state = brw_set_scissor_state; brw->pipe.set_sampler_textures = brw_set_sampler_textures; brw->pipe.set_viewport_state = brw_set_viewport_state; - brw->pipe.set_vertex_buffer = brw_set_vertex_buffer; - brw->pipe.set_vertex_element = brw_set_vertex_element; + brw->pipe.set_vertex_buffers = brw_set_vertex_buffers; + brw->pipe.set_vertex_elements = brw_set_vertex_elements; } diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 16fb06f176..e298ed37c3 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -174,8 +174,8 @@ softpipe_create( struct pipe_screen *screen, softpipe->pipe.set_sampler_textures = softpipe_set_sampler_textures; softpipe->pipe.set_viewport_state = softpipe_set_viewport_state; - softpipe->pipe.set_vertex_buffer = softpipe_set_vertex_buffer; - softpipe->pipe.set_vertex_element = softpipe_set_vertex_element; + softpipe->pipe.set_vertex_buffers = softpipe_set_vertex_buffers; + softpipe->pipe.set_vertex_elements = softpipe_set_vertex_elements; softpipe->pipe.draw_arrays = softpipe_draw_arrays; softpipe->pipe.draw_elements = softpipe_draw_elements; diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index 0bb1095aec..6e6501f5bc 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -151,13 +151,13 @@ void softpipe_set_sampler_textures( struct pipe_context *, void softpipe_set_viewport_state( struct pipe_context *, const struct pipe_viewport_state * ); -void softpipe_set_vertex_element(struct pipe_context *, - unsigned index, - const struct pipe_vertex_element *); +void softpipe_set_vertex_elements(struct pipe_context *, + unsigned count, + const struct pipe_vertex_element *); -void softpipe_set_vertex_buffer(struct pipe_context *, - unsigned index, - const struct pipe_vertex_buffer *); +void softpipe_set_vertex_buffers(struct pipe_context *, + unsigned count, + const struct pipe_vertex_buffer *); void softpipe_update_derived( struct softpipe_context *softpipe ); diff --git a/src/gallium/drivers/softpipe/sp_state_vertex.c b/src/gallium/drivers/softpipe/sp_state_vertex.c index c054e76d9b..e0230e16a4 100644 --- a/src/gallium/drivers/softpipe/sp_state_vertex.c +++ b/src/gallium/drivers/softpipe/sp_state_vertex.c @@ -37,28 +37,35 @@ void -softpipe_set_vertex_element(struct pipe_context *pipe, - unsigned index, - const struct pipe_vertex_element *attrib) +softpipe_set_vertex_elements(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *attribs) { struct softpipe_context *softpipe = softpipe_context(pipe); - assert(index < PIPE_MAX_ATTRIBS); - softpipe->vertex_element[index] = *attrib; /* struct copy */ + + assert(count <= PIPE_MAX_ATTRIBS); + + memcpy(softpipe->vertex_element, attribs, + count * sizeof(struct pipe_vertex_element)); + softpipe->dirty |= SP_NEW_VERTEX; - draw_set_vertex_element(softpipe->draw, index, attrib); + draw_set_vertex_elements(softpipe->draw, count, attribs); } void -softpipe_set_vertex_buffer(struct pipe_context *pipe, - unsigned index, - const struct pipe_vertex_buffer *buffer) +softpipe_set_vertex_buffers(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_buffer *buffers) { struct softpipe_context *softpipe = softpipe_context(pipe); - assert(index < PIPE_MAX_ATTRIBS); - softpipe->vertex_buffer[index] = *buffer; /* struct copy */ + + assert(count <= PIPE_MAX_ATTRIBS); + + memcpy(softpipe->vertex_buffer, buffers, count * sizeof(buffers[0])); + softpipe->dirty |= SP_NEW_VERTEX; - draw_set_vertex_buffer(softpipe->draw, index, buffer); + draw_set_vertex_buffers(softpipe->draw, count, buffers); } diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 2d063e3f9e..324f70185a 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -155,13 +155,13 @@ struct pipe_context { unsigned num_textures, struct pipe_texture ** ); - void (*set_vertex_buffer)( struct pipe_context *, - unsigned index, - const struct pipe_vertex_buffer * ); + void (*set_vertex_buffers)( struct pipe_context *, + unsigned num_buffers, + const struct pipe_vertex_buffer * ); - void (*set_vertex_element)( struct pipe_context *, - unsigned index, - const struct pipe_vertex_element * ); + void (*set_vertex_elements)( struct pipe_context *, + unsigned num_elements, + const struct pipe_vertex_element * ); /*@}*/ diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 4aca3311b7..f0f62246dd 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -210,6 +210,7 @@ st_draw_vbo(GLcontext *ctx, const struct pipe_shader_state *vs; struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; GLuint attr; + struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; /* sanity check for pointer arithmetic below */ assert(sizeof(arrays[0]->Ptr[0]) == 1); @@ -226,7 +227,6 @@ st_draw_vbo(GLcontext *ctx, for (attr = 0; attr < vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; - struct pipe_vertex_element velement; if (bufobj && bufobj->Name) { /* Attribute data is in a VBO. @@ -239,8 +239,8 @@ st_draw_vbo(GLcontext *ctx, vbuffer[attr].buffer = NULL; pipe_buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ - velement.src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; - assert(velement.src_offset <= 2048); /* 11-bit field */ + velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; + assert(velements[attr].src_offset <= 2048); /* 11-bit field */ } else { /* attribute data is in user-space memory, not a VBO */ @@ -259,24 +259,24 @@ st_draw_vbo(GLcontext *ctx, (void *) arrays[mesaAttr]->Ptr, bytes); vbuffer[attr].buffer_offset = 0; - velement.src_offset = 0; + velements[attr].src_offset = 0; } /* common-case setup */ vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ vbuffer[attr].max_index = max_index; - velement.vertex_buffer_index = attr; - velement.nr_components = arrays[mesaAttr]->Size; - velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size, - arrays[mesaAttr]->Normalized); - assert(velement.src_format); - - /* tell pipe about this attribute */ - pipe->set_vertex_buffer(pipe, attr, &vbuffer[attr]); - pipe->set_vertex_element(pipe, attr, &velement); + velements[attr].vertex_buffer_index = attr; + velements[attr].nr_components = arrays[mesaAttr]->Size; + velements[attr].src_format + = pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size, + arrays[mesaAttr]->Normalized); + assert(velements[attr].src_format); } + pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer); + pipe->set_vertex_elements(pipe, vp->num_inputs, velements); + /* do actual drawing */ if (ib) { @@ -336,8 +336,8 @@ st_draw_vbo(GLcontext *ctx, for (attr = 0; attr < vp->num_inputs; attr++) { pipe_buffer_reference(winsys, &vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); - pipe->set_vertex_buffer(pipe, attr, &vbuffer[attr]); } + pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer); } @@ -362,7 +362,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, struct pipe_context *pipe = ctx->st->pipe; struct pipe_buffer *vbuf; struct pipe_vertex_buffer vbuffer; - struct pipe_vertex_element velement; + struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; unsigned i; assert(numAttribs > 0); @@ -393,16 +393,16 @@ st_draw_vertices(GLcontext *ctx, unsigned prim, vbuffer.buffer = vbuf; vbuffer.pitch = numAttribs * 4 * sizeof(float); /* vertex size */ vbuffer.buffer_offset = 0; - pipe->set_vertex_buffer(pipe, 0, &vbuffer); + pipe->set_vertex_buffers(pipe, 1, &vbuffer); /* tell pipe about the vertex attributes */ for (i = 0; i < numAttribs; i++) { - velement.src_offset = i * 4 * sizeof(GLfloat); - velement.vertex_buffer_index = 0; - velement.src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - velement.nr_components = 4; - pipe->set_vertex_element(pipe, i, &velement); + velements[i].src_offset = i * 4 * sizeof(GLfloat); + velements[i].vertex_buffer_index = 0; + velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velements[i].nr_components = 4; } + pipe->set_vertex_elements(pipe, numAttribs, velements); /* draw */ pipe->draw_arrays(pipe, prim, 0, numVertex); @@ -470,7 +470,8 @@ st_feedback_draw_vbo(GLcontext *ctx, const struct st_vertex_program *vp; const struct pipe_shader_state *vs; struct pipe_buffer *index_buffer_handle = 0; - struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; + struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS]; + struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; GLuint attr, i; ubyte *mapped_constants; @@ -505,7 +506,6 @@ st_feedback_draw_vbo(GLcontext *ctx, for (attr = 0; attr < vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; - struct pipe_vertex_element velement; void *map; if (bufobj && bufobj->Name) { @@ -516,10 +516,10 @@ st_feedback_draw_vbo(GLcontext *ctx, struct st_buffer_object *stobj = st_buffer_object(bufobj); assert(stobj->buffer); - vbuffer[attr].buffer = NULL; - pipe_buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); - vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ - velement.src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; + vbuffers[attr].buffer = NULL; + pipe_buffer_reference(winsys, &vbuffers[attr].buffer, stobj->buffer); + vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ + velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; } else { /* attribute data is in user-space memory, not a VBO */ @@ -528,35 +528,39 @@ st_feedback_draw_vbo(GLcontext *ctx, * (max_index + 1)); /* wrap user data */ - vbuffer[attr].buffer + vbuffers[attr].buffer = winsys->user_buffer_create(winsys, (void *) arrays[mesaAttr]->Ptr, bytes); - vbuffer[attr].buffer_offset = 0; - velement.src_offset = 0; + vbuffers[attr].buffer_offset = 0; + velements[attr].src_offset = 0; } /* common-case setup */ - vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ - vbuffer[attr].max_index = max_index; - velement.vertex_buffer_index = attr; - velement.nr_components = arrays[mesaAttr]->Size; - velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type, + vbuffers[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ + vbuffers[attr].max_index = max_index; + velements[attr].vertex_buffer_index = attr; + velements[attr].nr_components = arrays[mesaAttr]->Size; + velements[attr].src_format = pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, arrays[mesaAttr]->Normalized); - assert(velement.src_format); + assert(velements[attr].src_format); /* tell draw about this attribute */ +#if 0 draw_set_vertex_buffer(draw, attr, &vbuffer[attr]); - draw_set_vertex_element(draw, attr, &velement); +#endif /* map the attrib buffer */ map = pipe->winsys->buffer_map(pipe->winsys, - vbuffer[attr].buffer, + vbuffers[attr].buffer, PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, attr, map); } + draw_set_vertex_buffers(draw, vp->num_inputs, vbuffers); + draw_set_vertex_elements(draw, vp->num_inputs, velements); + if (ib) { unsigned indexSize; struct gl_buffer_object *bufobj = ib->obj; -- cgit v1.2.3 From 7d72607e142c0412b88183b849fd701e698b8f79 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 19 Apr 2008 17:27:52 +0100 Subject: draw: move incoming vertex state into draw->pt This state is effectively private to the vertex processing part of the draw module. --- src/gallium/auxiliary/draw/draw_context.c | 28 +++++-------- src/gallium/auxiliary/draw/draw_private.h | 47 +++++++++++----------- src/gallium/auxiliary/draw/draw_pt.c | 8 ++++ src/gallium/auxiliary/draw/draw_pt.h | 9 +---- src/gallium/auxiliary/draw/draw_pt_elts.c | 6 +-- src/gallium/auxiliary/draw/draw_pt_fetch.c | 20 ++++----- src/gallium/auxiliary/draw/draw_pt_fetch_emit.c | 6 +-- .../auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 2 +- src/gallium/auxiliary/draw/draw_pt_vcache.c | 2 +- src/mesa/state_tracker/st_draw.c | 6 +-- 10 files changed, 63 insertions(+), 71 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 3e69867d11..4988d67faa 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -62,8 +62,6 @@ struct draw_context *draw_create( void ) draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */ - draw_set_mapped_element_buffer( draw, 0, NULL ); - tgsi_exec_machine_init(&draw->machine); /* FIXME: give this machine thing a proper constructor: @@ -188,8 +186,8 @@ draw_set_vertex_buffers(struct draw_context *draw, { assert(count <= PIPE_MAX_ATTRIBS); - memcpy(draw->vertex_buffer, buffers, count * sizeof(buffers[0])); - draw->nr_vertex_buffers = count; + memcpy(draw->pt.vertex_buffer, buffers, count * sizeof(buffers[0])); + draw->pt.nr_vertex_buffers = count; } @@ -200,8 +198,8 @@ draw_set_vertex_elements(struct draw_context *draw, { assert(count <= PIPE_MAX_ATTRIBS); - memcpy(draw->vertex_element, elements, count * sizeof(elements[0])); - draw->nr_vertex_elements = count; + memcpy(draw->pt.vertex_element, elements, count * sizeof(elements[0])); + draw->pt.nr_vertex_elements = count; } @@ -212,7 +210,7 @@ void draw_set_mapped_vertex_buffer(struct draw_context *draw, unsigned attr, const void *buffer) { - draw->user.vbuffer[attr] = buffer; + draw->pt.user.vbuffer[attr] = buffer; } @@ -220,7 +218,7 @@ void draw_set_mapped_constant_buffer(struct draw_context *draw, const void *buffer) { - draw->user.constants = buffer; + draw->pt.user.constants = buffer; } @@ -337,18 +335,10 @@ void draw_set_render( struct draw_context *draw, void draw_set_edgeflags( struct draw_context *draw, const unsigned *edgeflag ) { - draw->user.edgeflag = edgeflag; + draw->pt.user.edgeflag = edgeflag; } -boolean draw_get_edgeflag( struct draw_context *draw, - unsigned idx ) -{ - if (draw->user.edgeflag) - return (draw->user.edgeflag[idx/32] & (1 << (idx%32))) != 0; - else - return 1; -} /** @@ -365,8 +355,8 @@ void draw_set_mapped_element_buffer( struct draw_context *draw, unsigned eltSize, void *elements ) { - draw->user.elts = elements; - draw->user.eltSize = eltSize; + draw->pt.user.elts = elements; + draw->pt.user.eltSize = eltSize; } diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 6cf3e54e28..27f61c2f40 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -149,6 +149,29 @@ struct draw_context struct { struct draw_pt_front_end *vcache; } front; + + struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; + unsigned nr_vertex_buffers; + + struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; + unsigned nr_vertex_elements; + + /* user-space vertex data, buffers */ + struct { + const unsigned *edgeflag; + + /** vertex element/index buffer (ex: glDrawElements) */ + const void *elts; + /** bytes per index (0, 1, 2 or 4) */ + unsigned eltSize; + + /** vertex arrays */ + const void *vbuffer[PIPE_MAX_ATTRIBS]; + + /** constant buffer (for vertex shader) */ + const void *constants; + } user; + } pt; boolean flushing; @@ -157,33 +180,12 @@ struct draw_context const struct pipe_rasterizer_state *rasterizer; struct pipe_viewport_state viewport; - struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; - unsigned nr_vertex_buffers; - - struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; - unsigned nr_vertex_elements; - struct draw_vertex_shader *vertex_shader; boolean identity_viewport; uint num_vs_outputs; /**< convenience, from vertex_shader */ - /* user-space vertex data, buffers */ - struct { - const unsigned *edgeflag; - - /** vertex element/index buffer (ex: glDrawElements) */ - const void *elts; - /** bytes per index (0, 1, 2 or 4) */ - unsigned eltSize; - - /** vertex arrays */ - const void *vbuffer[PIPE_MAX_ATTRIBS]; - - /** constant buffer (for vertex shader) */ - const void *constants; - } user; /* Clip derived state: */ @@ -257,9 +259,6 @@ boolean draw_need_pipeline(const struct draw_context *draw, void draw_do_flush( struct draw_context *draw, unsigned flags ); -boolean draw_get_edgeflag( struct draw_context *draw, - unsigned idx ); - diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 965269251f..9f8e8d3d62 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -165,3 +165,11 @@ draw_arrays(struct draw_context *draw, unsigned prim, draw_pt_arrays(draw, prim, start, count); } +boolean draw_pt_get_edgeflag( struct draw_context *draw, + unsigned idx ) +{ + if (draw->pt.user.edgeflag) + return (draw->pt.user.edgeflag[idx/32] & (1 << (idx%32))) != 0; + else + return 1; +} diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h index eaf8e0374a..fd0d158fcf 100644 --- a/src/gallium/auxiliary/draw/draw_pt.h +++ b/src/gallium/auxiliary/draw/draw_pt.h @@ -141,13 +141,8 @@ struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *d /* More helpers: */ -void draw_pt_run_pipeline( struct draw_context *draw, - unsigned prim, - struct vertex_header *verts, - unsigned vertex_count, - unsigned vertex_stride, - const ushort *elts, - unsigned count ); +boolean draw_pt_get_edgeflag( struct draw_context *draw, + unsigned idx ); /******************************************************************************* diff --git a/src/gallium/auxiliary/draw/draw_pt_elts.c b/src/gallium/auxiliary/draw/draw_pt_elts.c index d49770e7b2..2094c081ed 100644 --- a/src/gallium/auxiliary/draw/draw_pt_elts.c +++ b/src/gallium/auxiliary/draw/draw_pt_elts.c @@ -59,7 +59,7 @@ static unsigned elt_vert( const void *elts, unsigned idx ) pt_elt_func draw_pt_elt_func( struct draw_context *draw ) { - switch (draw->user.eltSize) { + switch (draw->pt.user.eltSize) { case 0: return elt_vert; case 1: return elt_ubyte; case 2: return elt_ushort; @@ -71,9 +71,9 @@ pt_elt_func draw_pt_elt_func( struct draw_context *draw ) const void *draw_pt_elt_ptr( struct draw_context *draw, unsigned start ) { - const char *elts = draw->user.elts; + const char *elts = draw->pt.user.elts; - switch (draw->user.eltSize) { + switch (draw->pt.user.eltSize) { case 0: return (const void *)(((const ubyte *)NULL) + start); case 1: diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 037e3765da..c588710b75 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -76,7 +76,7 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, /* Need to set header->vertex_id = 0xffff somehow. */ key.element[nr].input_format = PIPE_FORMAT_R32_FLOAT; - key.element[nr].input_buffer = draw->nr_vertex_buffers; + key.element[nr].input_buffer = draw->pt.nr_vertex_buffers; key.element[nr].input_offset = 0; key.element[nr].output_format = PIPE_FORMAT_R32_FLOAT; key.element[nr].output_offset = dst_offset; @@ -90,10 +90,10 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, } - for (i = 0; i < draw->nr_vertex_elements; i++) { - key.element[nr].input_format = draw->vertex_element[i].src_format; - key.element[nr].input_buffer = draw->vertex_element[i].vertex_buffer_index; - key.element[nr].input_offset = draw->vertex_element[i].src_offset; + for (i = 0; i < draw->pt.nr_vertex_elements; i++) { + key.element[nr].input_format = draw->pt.vertex_element[i].src_format; + key.element[nr].input_buffer = draw->pt.vertex_element[i].vertex_buffer_index; + key.element[nr].input_offset = draw->pt.vertex_element[i].src_offset; key.element[nr].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT; key.element[nr].output_offset = dst_offset; @@ -120,7 +120,7 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, { static struct vertex_header vh = { 0, 0, 0, 0xffff }; fetch->translate->set_buffer(fetch->translate, - draw->nr_vertex_buffers, + draw->pt.nr_vertex_buffers, &vh, 0); } @@ -139,12 +139,12 @@ void draw_pt_fetch_run( struct pt_fetch *fetch, struct translate *translate = fetch->translate; unsigned i; - for (i = 0; i < draw->nr_vertex_buffers; i++) { + for (i = 0; i < draw->pt.nr_vertex_buffers; i++) { translate->set_buffer(translate, i, - ((char *)draw->user.vbuffer[i] + - draw->vertex_buffer[i].buffer_offset), - draw->vertex_buffer[i].pitch ); + ((char *)draw->pt.user.vbuffer[i] + + draw->pt.vertex_buffer[i].buffer_offset), + draw->pt.vertex_buffer[i].pitch ); } translate->run_elts( translate, diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index 6e4fea460b..1b9b3bfaa6 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -117,7 +117,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, memset(&key, 0, sizeof(key)); for (i = 0; i < vinfo->num_attribs; i++) { - const struct pipe_vertex_element *src = &draw->vertex_element[vinfo->src_index[i]]; + const struct pipe_vertex_element *src = &draw->pt.vertex_element[vinfo->src_index[i]]; unsigned emit_sz = 0; unsigned input_format = src->src_format; @@ -144,7 +144,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, break; case EMIT_1F_PSIZE: input_format = PIPE_FORMAT_R32_FLOAT; - input_buffer = draw->nr_vertex_buffers; + input_buffer = draw->pt.nr_vertex_buffers; input_offset = 0; output_format = PIPE_FORMAT_R32_FLOAT; emit_sz = 1 * sizeof(float); @@ -179,7 +179,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, feme->translate = translate_create( &key ); feme->translate->set_buffer(feme->translate, - draw->nr_vertex_buffers, + draw->pt.nr_vertex_buffers, &feme->point_size, 0); } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index e1df594035..881e47d59d 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -135,7 +135,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle, shader->run_linear(shader, (const float (*)[4])pipeline_verts->data, ( float (*)[4])pipeline_verts->data, - (const float (*)[4])draw->user.constants, + (const float (*)[4])draw->pt.user.constants, fetch_count, fpme->vertex_size, fpme->vertex_size); diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 5561f2b6fb..b61bb50664 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -106,7 +106,7 @@ static unsigned add_edgeflag( struct vcache_frontend *vcache, unsigned idx, unsigned mask ) { - if (mask && draw_get_edgeflag(vcache->draw, idx)) + if (mask && draw_pt_get_edgeflag(vcache->draw, idx)) return idx | DRAW_PT_EDGEFLAG; else return idx; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index f0f62246dd..befcb96bd8 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -611,10 +611,10 @@ st_feedback_draw_vbo(GLcontext *ctx, * unmap vertex/index buffers */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (draw->vertex_buffer[i].buffer) { + if (draw->pt.vertex_buffer[i].buffer) { pipe->winsys->buffer_unmap(pipe->winsys, - draw->vertex_buffer[i].buffer); - pipe_buffer_reference(winsys, &draw->vertex_buffer[i].buffer, NULL); + draw->pt.vertex_buffer[i].buffer); + pipe_buffer_reference(winsys, &draw->pt.vertex_buffer[i].buffer, NULL); draw_set_mapped_vertex_buffer(draw, i, NULL); } } -- cgit v1.2.3 From ef683014dd72612e6eb245e89e754b033acb3a49 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 24 Apr 2008 16:01:18 -0600 Subject: gallium: initial edgeflags code --- src/mesa/state_tracker/st_draw.c | 60 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index befcb96bd8..097166f444 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -190,6 +190,57 @@ pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized) } +/* + * If edge flags are needed, setup an bitvector of flags and call + * pipe->set_edgeflags(). + * XXX memleak: need to free the returned pointer at some point + */ +static void * +setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, + const struct gl_client_array *array) +{ + struct pipe_context *pipe = ctx->st->pipe; + + if ((primMode == GL_TRIANGLES || + primMode == GL_QUADS || + primMode == GL_POLYGON) && + (ctx->Polygon.FrontMode != GL_FILL || + ctx->Polygon.BackMode != GL_FILL)) { + /* need edge flags */ + GLuint i; + unsigned *vec = (unsigned *) calloc(sizeof(unsigned), (count + 31) / 32); + struct st_buffer_object *stobj = st_buffer_object(array->BufferObj); + ubyte *map; + + if (!vec) + return NULL; + + map = pipe->winsys->buffer_map(pipe->winsys, stobj->buffer, + PIPE_BUFFER_USAGE_CPU_READ); + map = ADD_POINTERS(map, array->Ptr); + + for (i = 0; i < count; i++) { + if (*((float *) map)) + vec[i/32] |= 1 << (i % 32); + + map += array->StrideB; + } + + pipe->winsys->buffer_unmap(pipe->winsys, stobj->buffer); + + pipe->set_edgeflags(pipe, vec); + + return vec; + } + else { + /* edge flags not needed */ + pipe->set_edgeflags(pipe, NULL); + return NULL; + } +} + + + /** * This function gets plugged into the VBO module and is called when * we have something to render. @@ -277,7 +328,6 @@ st_draw_vbo(GLcontext *ctx, pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer); pipe->set_vertex_elements(pipe, vp->num_inputs, velements); - /* do actual drawing */ if (ib) { /* indexed primitive */ @@ -317,6 +367,10 @@ st_draw_vbo(GLcontext *ctx, /* draw */ for (i = 0; i < nr_prims; i++) { + setup_edgeflags(ctx, prims[i].mode, + prims[i].start + indexOffset, prims[i].count, + arrays[VERT_ATTRIB_EDGEFLAG]); + pipe->draw_elements(pipe, indexBuf, indexSize, prims[i].mode, prims[i].start + indexOffset, prims[i].count); @@ -328,6 +382,10 @@ st_draw_vbo(GLcontext *ctx, /* non-indexed */ GLuint i; for (i = 0; i < nr_prims; i++) { + setup_edgeflags(ctx, prims[i].mode, + prims[i].start, prims[i].count, + arrays[VERT_ATTRIB_EDGEFLAG]); + pipe->draw_arrays(pipe, prims[i].mode, prims[i].start, prims[i].count); } } -- cgit v1.2.3 From b4c7a48d5c9ed2f9535a17d6c05cd55178c7880a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 24 Apr 2008 16:40:08 -0600 Subject: gallium: fix an edgeflags crash --- src/mesa/state_tracker/st_draw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 097166f444..e40eeddff5 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -208,10 +208,14 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, ctx->Polygon.BackMode != GL_FILL)) { /* need edge flags */ GLuint i; - unsigned *vec = (unsigned *) calloc(sizeof(unsigned), (count + 31) / 32); + unsigned *vec; struct st_buffer_object *stobj = st_buffer_object(array->BufferObj); ubyte *map; + if (!stobj) + return NULL; + + vec = (unsigned *) calloc(sizeof(unsigned), (count + 31) / 32); if (!vec) return NULL; -- cgit v1.2.3 From b6d8b21cc8e36eb4f6fa72a067561f3fa8bd6ebf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 25 Apr 2008 14:00:40 -0600 Subject: gallium: remove unused st_draw_vertices() --- src/mesa/state_tracker/st_draw.c | 70 ---------------------------------------- src/mesa/state_tracker/st_draw.h | 7 ---- 2 files changed, 77 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index e40eeddff5..6c20120ac7 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -404,76 +404,6 @@ st_draw_vbo(GLcontext *ctx, -/** - * Utility function for drawing simple primitives (such as quads for - * glClear and glDrawPixels). Coordinates are in screen space. - * \param mode one of PIPE_PRIM_x - * \param numVertex number of vertices - * \param verts vertex data (all attributes are float[4]) - * \param numAttribs number of attributes per vertex - */ -void -st_draw_vertices(GLcontext *ctx, unsigned prim, - unsigned numVertex, float *verts, - unsigned numAttribs, - GLboolean inClipCoords) -{ - const float width = ctx->DrawBuffer->Width; - const float height = ctx->DrawBuffer->Height; - const unsigned vertex_bytes = numVertex * numAttribs * 4 * sizeof(float); - struct pipe_context *pipe = ctx->st->pipe; - struct pipe_buffer *vbuf; - struct pipe_vertex_buffer vbuffer; - struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; - unsigned i; - - assert(numAttribs > 0); - - if (!inClipCoords) { - /* convert to clip coords */ - for (i = 0; i < numVertex; i++) { - float x = verts[i * numAttribs * 4 + 0]; - float y = verts[i * numAttribs * 4 + 1]; - x = x / width * 2.0 - 1.0; - y = y / height * 2.0 - 1.0; - verts[i * numAttribs * 4 + 0] = x; - verts[i * numAttribs * 4 + 1] = y; - } - } - - /* XXX create one-time */ - vbuf = pipe->winsys->buffer_create(pipe->winsys, 32, - PIPE_BUFFER_USAGE_VERTEX, vertex_bytes); - assert(vbuf); - - memcpy(pipe->winsys->buffer_map(pipe->winsys, vbuf, - PIPE_BUFFER_USAGE_CPU_WRITE), - verts, vertex_bytes); - pipe->winsys->buffer_unmap(pipe->winsys, vbuf); - - /* tell pipe about the vertex buffer */ - vbuffer.buffer = vbuf; - vbuffer.pitch = numAttribs * 4 * sizeof(float); /* vertex size */ - vbuffer.buffer_offset = 0; - pipe->set_vertex_buffers(pipe, 1, &vbuffer); - - /* tell pipe about the vertex attributes */ - for (i = 0; i < numAttribs; i++) { - velements[i].src_offset = i * 4 * sizeof(GLfloat); - velements[i].vertex_buffer_index = 0; - velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - velements[i].nr_components = 4; - } - pipe->set_vertex_elements(pipe, numAttribs, velements); - - /* draw */ - pipe->draw_arrays(pipe, prim, 0, numVertex); - - /* XXX: do one-time */ - pipe_buffer_reference(pipe->winsys, &vbuf, NULL); -} - - /** * Set the (private) draw module's post-transformed vertex format when in * GL_SELECT or GL_FEEDBACK mode or for glRasterPos. diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index 171bde57e5..c81f2b25da 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -59,11 +59,4 @@ st_feedback_draw_vbo(GLcontext *ctx, GLuint min_index, GLuint max_index); -void -st_draw_vertices(GLcontext *ctx, unsigned prim, - unsigned numVertex, float *verts, - unsigned numAttribs, - GLboolean inClipCoords); - - #endif -- cgit v1.2.3 From 99fba5466bfd14c4e052041c0571821be529e762 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 30 Apr 2008 10:43:59 -0600 Subject: gallium: use new buffer wrapper functions in p_inlines.h This allows us to remove most of the direct references to winsys in the state tracker. --- src/mesa/state_tracker/st_atom_constbuf.c | 14 ++++---- src/mesa/state_tracker/st_cb_bitmap.c | 13 +++---- src/mesa/state_tracker/st_cb_bufferobjects.c | 22 +++++------- src/mesa/state_tracker/st_cb_clear.c | 14 ++++---- src/mesa/state_tracker/st_cb_drawpixels.c | 13 +++---- src/mesa/state_tracker/st_cb_fbo.c | 2 +- src/mesa/state_tracker/st_context.c | 4 +-- src/mesa/state_tracker/st_draw.c | 54 ++++++++++++---------------- src/mesa/state_tracker/st_gen_mipmap.c | 14 ++++---- src/mesa/state_tracker/st_texture.c | 1 - 10 files changed, 62 insertions(+), 89 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 03093579e1..2b659aebbc 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -36,7 +36,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "pipe/p_winsys.h" #include "pipe/p_inlines.h" #include "st_context.h" @@ -54,7 +53,7 @@ void st_upload_constants( struct st_context *st, struct gl_program_parameter_list *params, unsigned id) { - struct pipe_winsys *ws = st->pipe->winsys; + struct pipe_context *pipe = st->pipe; struct pipe_constant_buffer *cbuf = &st->state.constants[id]; assert(id == PIPE_SHADER_VERTEX || id == PIPE_SHADER_FRAGMENT); @@ -74,8 +73,8 @@ void st_upload_constants( struct st_context *st, /* We always need to get a new buffer, to keep the drivers simple and * avoid gratuitous rendering synchronization. */ - pipe_buffer_reference( ws, &cbuf->buffer, NULL ); - cbuf->buffer = ws->buffer_create( ws, 1, PIPE_BUFFER_USAGE_CONSTANT, + pipe_reference_buffer(pipe, &cbuf->buffer, NULL ); + cbuf->buffer = pipe_buffer_create(pipe, 1, PIPE_BUFFER_USAGE_CONSTANT, paramBytes ); if (0) @@ -87,9 +86,10 @@ void st_upload_constants( struct st_context *st, /* load Mesa constants into the constant buffer */ if (cbuf->buffer) { - memcpy(ws->buffer_map(ws, cbuf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE), - params->ParameterValues, paramBytes); - ws->buffer_unmap(ws, cbuf->buffer); + void *map = pipe_buffer_map(pipe, cbuf->buffer, + PIPE_BUFFER_USAGE_CPU_WRITE); + memcpy(map, params->ParameterValues, paramBytes); + pipe_buffer_unmap(pipe, cbuf->buffer); } cbuf->size = paramBytes; diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index d73cd4abfa..f0a3b75357 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -50,7 +50,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/p_winsys.h" #include "util/p_tile.h" #include "util/u_draw_quad.h" #include "util/u_simple_shaders.h" @@ -372,9 +371,8 @@ setup_bitmap_vertex_data(struct st_context *st, void *buf; if (!st->bitmap.vbuf) { - st->bitmap.vbuf = pipe->winsys->buffer_create(pipe->winsys, 32, - PIPE_BUFFER_USAGE_VERTEX, - sizeof(st->bitmap.vertices)); + st->bitmap.vbuf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX, + sizeof(st->bitmap.vertices)); } /* Positions are in clip coords since we need to do clipping in case @@ -413,10 +411,9 @@ setup_bitmap_vertex_data(struct st_context *st, } /* put vertex data into vbuf */ - buf = pipe->winsys->buffer_map(pipe->winsys, st->bitmap.vbuf, - PIPE_BUFFER_USAGE_CPU_WRITE); + buf = pipe_buffer_map(pipe, st->bitmap.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(buf, st->bitmap.vertices, sizeof(st->bitmap.vertices)); - pipe->winsys->buffer_unmap(pipe->winsys, st->bitmap.vbuf); + pipe_buffer_unmap(pipe, st->bitmap.vbuf); } @@ -761,7 +758,7 @@ st_destroy_bitmap(struct st_context *st) } if (st->bitmap.vbuf) { - pipe->winsys->buffer_destroy(pipe->winsys, st->bitmap.vbuf); + pipe_buffer_destroy(pipe, st->bitmap.vbuf); st->bitmap.vbuf = NULL; } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index fa1254ff7c..af79aefa96 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -35,7 +35,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "pipe/p_winsys.h" #include "pipe/p_inlines.h" @@ -79,7 +78,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_buffer_reference(pipe->winsys, &st_obj->buffer, NULL); + pipe_reference_buffer(pipe, &st_obj->buffer, NULL); free(st_obj); } @@ -106,10 +105,9 @@ st_bufferobj_subdata(GLcontext *ctx, if (offset >= st_obj->size || size > (st_obj->size - offset)) return; - map = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer, - PIPE_BUFFER_USAGE_CPU_WRITE); + map = pipe_buffer_map(pipe, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(map + offset, data, size); - pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer); + pipe_buffer_unmap(pipe, st_obj->buffer); } @@ -130,10 +128,9 @@ st_bufferobj_get_subdata(GLcontext *ctx, if (offset >= st_obj->size || size > (st_obj->size - offset)) return; - map = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pipe, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_READ); memcpy(data, map + offset, size); - pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer); + pipe_buffer_unmap(pipe, st_obj->buffer); } @@ -174,10 +171,9 @@ st_bufferobj_data(GLcontext *ctx, buffer_usage = 0; } - pipe_buffer_reference( pipe->winsys, &st_obj->buffer, NULL ); + pipe_reference_buffer( pipe, &st_obj->buffer, NULL ); - st_obj->buffer = pipe->winsys->buffer_create( pipe->winsys, 32, buffer_usage, - size ); + st_obj->buffer = pipe_buffer_create( pipe, 32, buffer_usage, size ); st_obj->size = size; @@ -211,7 +207,7 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access, break; } - obj->Pointer = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer, flags); + obj->Pointer = pipe_buffer_map(pipe, st_obj->buffer, flags); return obj->Pointer; } @@ -225,7 +221,7 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj) struct pipe_context *pipe = st_context(ctx)->pipe; struct st_buffer_object *st_obj = st_buffer_object(obj); - pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer); + pipe_buffer_unmap(pipe, st_obj->buffer); obj->Pointer = NULL; return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 95a5fb8db4..fe979f10bd 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -45,9 +45,9 @@ #include "st_mesa_to_tgsi.h" #include "pipe/p_context.h" +#include "pipe/p_inlines.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" -#include "pipe/p_winsys.h" #include "util/u_pack_color.h" #include "util/u_simple_shaders.h" #include "util/u_draw_quad.h" @@ -106,7 +106,7 @@ st_destroy_clear(struct st_context *st) st->clear.vs = NULL; } if (st->clear.vbuf) { - pipe->winsys->buffer_destroy(pipe->winsys, st->clear.vbuf); + pipe_buffer_destroy(pipe, st->clear.vbuf); st->clear.vbuf = NULL; } } @@ -142,9 +142,8 @@ draw_quad(GLcontext *ctx, void *buf; if (!st->clear.vbuf) { - st->clear.vbuf = pipe->winsys->buffer_create(pipe->winsys, 32, - PIPE_BUFFER_USAGE_VERTEX, - sizeof(st->clear.vertices)); + st->clear.vbuf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX, + sizeof(st->clear.vertices)); } /* positions */ @@ -171,10 +170,9 @@ draw_quad(GLcontext *ctx, } /* put vertex data into vbuf */ - buf = pipe->winsys->buffer_map(pipe->winsys, st->clear.vbuf, - PIPE_BUFFER_USAGE_CPU_WRITE); + buf = pipe_buffer_map(pipe, st->clear.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(buf, st->clear.vertices, sizeof(st->clear.vertices)); - pipe->winsys->buffer_unmap(pipe->winsys, st->clear.vbuf); + pipe_buffer_unmap(pipe, st->clear.vbuf); /* draw */ util_draw_vertex_buffer(pipe, st->clear.vbuf, diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 7597ea323c..65bfd6cfcc 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -55,7 +55,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/p_winsys.h" #include "util/p_tile.h" #include "util/u_draw_quad.h" #include "shader/prog_instruction.h" @@ -483,20 +482,18 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, ubyte *map; /* allocate/load buffer object with vertex data */ - buf = pipe->winsys->buffer_create(pipe->winsys, 32, - PIPE_BUFFER_USAGE_VERTEX, - sizeof(verts)); - map = pipe->winsys->buffer_map(pipe->winsys, buf, - PIPE_BUFFER_USAGE_CPU_WRITE); + buf = pipe_buffer_create(pipe,32, PIPE_BUFFER_USAGE_VERTEX, + sizeof(verts)); + map = pipe_buffer_map(pipe, buf, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(map, verts, sizeof(verts)); - pipe->winsys->buffer_unmap(pipe->winsys, buf); + pipe_buffer_unmap(pipe, buf); util_draw_vertex_buffer(pipe, buf, PIPE_PRIM_QUADS, 4, /* verts */ 3); /* attribs/vert */ - pipe->winsys->buffer_destroy(pipe->winsys, buf); + pipe_buffer_destroy(pipe, buf); } } diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 2d741d9390..fc8a5ea7f6 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -105,7 +105,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, } else if (strb->surface->buffer) { /* release/discard the old surface buffer */ - pipe_buffer_reference(pipe->winsys, &strb->surface->buffer, NULL); + pipe_reference_buffer(pipe, &strb->surface->buffer, NULL); } /* Determine surface format here */ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 8a30871fa0..c900064f2b 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -55,7 +55,6 @@ #include "st_gen_mipmap.h" #include "st_program.h" #include "pipe/p_context.h" -#include "pipe/p_winsys.h" #include "pipe/p_inlines.h" #include "draw/draw_context.h" #include "cso_cache/cso_cache.h" @@ -157,7 +156,6 @@ struct st_context *st_create_context(struct pipe_context *pipe, static void st_destroy_context_priv( struct st_context *st ) { - struct pipe_winsys *ws = st->pipe->winsys; uint i; draw_destroy(st->draw); @@ -172,7 +170,7 @@ static void st_destroy_context_priv( struct st_context *st ) for (i = 0; i < Elements(st->state.constants); i++) { if (st->state.constants[i].buffer) { - pipe_buffer_reference(ws, &st->state.constants[i].buffer, NULL); + pipe_reference_buffer(st->pipe, &st->state.constants[i].buffer, NULL); } } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 6c20120ac7..0fe4d198bd 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -43,7 +43,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "pipe/p_winsys.h" #include "pipe/p_inlines.h" #include "draw/draw_private.h" @@ -219,8 +218,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, if (!vec) return NULL; - map = pipe->winsys->buffer_map(pipe->winsys, stobj->buffer, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pipe, stobj->buffer, PIPE_BUFFER_USAGE_CPU_READ); map = ADD_POINTERS(map, array->Ptr); for (i = 0; i < count; i++) { @@ -230,7 +228,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, map += array->StrideB; } - pipe->winsys->buffer_unmap(pipe->winsys, stobj->buffer); + pipe_buffer_unmap(pipe, stobj->buffer); pipe->set_edgeflags(pipe, vec); @@ -260,7 +258,6 @@ st_draw_vbo(GLcontext *ctx, GLuint max_index) { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_winsys *winsys = pipe->winsys; const struct st_vertex_program *vp; const struct pipe_shader_state *vs; struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; @@ -292,7 +289,7 @@ st_draw_vbo(GLcontext *ctx, assert(stobj->buffer); vbuffer[attr].buffer = NULL; - pipe_buffer_reference(winsys, &vbuffer[attr].buffer, stobj->buffer); + pipe_reference_buffer(pipe, &vbuffer[attr].buffer, stobj->buffer); vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; assert(velements[attr].src_offset <= 2048); /* 11-bit field */ @@ -310,9 +307,8 @@ st_draw_vbo(GLcontext *ctx, /* wrap user data */ vbuffer[attr].buffer - = winsys->user_buffer_create(winsys, - (void *) arrays[mesaAttr]->Ptr, - bytes); + = pipe_user_buffer_create(pipe, (void *) arrays[mesaAttr]->Ptr, + bytes); vbuffer[attr].buffer_offset = 0; velements[attr].src_offset = 0; } @@ -358,14 +354,13 @@ st_draw_vbo(GLcontext *ctx, if (bufobj && bufobj->Name) { /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); - pipe_buffer_reference(winsys, &indexBuf, stobj->buffer); + pipe_reference_buffer(pipe, &indexBuf, stobj->buffer); indexOffset = (unsigned) ib->ptr / indexSize; } else { /* element/indicies are in user space memory */ - indexBuf = winsys->user_buffer_create(winsys, - (void *) ib->ptr, - ib->count * indexSize); + indexBuf = pipe_user_buffer_create(pipe, (void *) ib->ptr, + ib->count * indexSize); indexOffset = 0; } @@ -380,7 +375,7 @@ st_draw_vbo(GLcontext *ctx, prims[i].start + indexOffset, prims[i].count); } - pipe_buffer_reference(winsys, &indexBuf, NULL); + pipe_reference_buffer(pipe, &indexBuf, NULL); } else { /* non-indexed */ @@ -396,7 +391,7 @@ st_draw_vbo(GLcontext *ctx, /* unreference buffers (frees wrapped user-space buffer objects) */ for (attr = 0; attr < vp->num_inputs; attr++) { - pipe_buffer_reference(winsys, &vbuffer[attr].buffer, NULL); + pipe_reference_buffer(pipe, &vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); } pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer); @@ -458,7 +453,6 @@ st_feedback_draw_vbo(GLcontext *ctx, struct st_context *st = ctx->st; struct pipe_context *pipe = st->pipe; struct draw_context *draw = st->draw; - struct pipe_winsys *winsys = pipe->winsys; const struct st_vertex_program *vp; const struct pipe_shader_state *vs; struct pipe_buffer *index_buffer_handle = 0; @@ -509,7 +503,7 @@ st_feedback_draw_vbo(GLcontext *ctx, assert(stobj->buffer); vbuffers[attr].buffer = NULL; - pipe_buffer_reference(winsys, &vbuffers[attr].buffer, stobj->buffer); + pipe_reference_buffer(pipe, &vbuffers[attr].buffer, stobj->buffer); vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; } @@ -521,9 +515,8 @@ st_feedback_draw_vbo(GLcontext *ctx, /* wrap user data */ vbuffers[attr].buffer - = winsys->user_buffer_create(winsys, - (void *) arrays[mesaAttr]->Ptr, - bytes); + = pipe_user_buffer_create(pipe, (void *) arrays[mesaAttr]->Ptr, + bytes); vbuffers[attr].buffer_offset = 0; velements[attr].src_offset = 0; } @@ -544,9 +537,8 @@ st_feedback_draw_vbo(GLcontext *ctx, #endif /* map the attrib buffer */ - map = pipe->winsys->buffer_map(pipe->winsys, - vbuffers[attr].buffer, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pipe, vbuffers[attr].buffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, attr, map); } @@ -572,9 +564,8 @@ st_feedback_draw_vbo(GLcontext *ctx, return; } - map = pipe->winsys->buffer_map(pipe->winsys, - index_buffer_handle, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pipe, index_buffer_handle, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, map); } else { @@ -584,7 +575,7 @@ st_feedback_draw_vbo(GLcontext *ctx, /* map constant buffers */ - mapped_constants = winsys->buffer_map(winsys, + mapped_constants = pipe_buffer_map(pipe, st->state.constants[PIPE_SHADER_VERTEX].buffer, PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_constant_buffer(st->draw, mapped_constants); @@ -597,21 +588,20 @@ st_feedback_draw_vbo(GLcontext *ctx, /* unmap constant buffers */ - winsys->buffer_unmap(winsys, st->state.constants[PIPE_SHADER_VERTEX].buffer); + pipe_buffer_unmap(pipe, st->state.constants[PIPE_SHADER_VERTEX].buffer); /* * unmap vertex/index buffers */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (draw->pt.vertex_buffer[i].buffer) { - pipe->winsys->buffer_unmap(pipe->winsys, - draw->pt.vertex_buffer[i].buffer); - pipe_buffer_reference(winsys, &draw->pt.vertex_buffer[i].buffer, NULL); + pipe_buffer_unmap(pipe, draw->pt.vertex_buffer[i].buffer); + pipe_reference_buffer(pipe, &draw->pt.vertex_buffer[i].buffer, NULL); draw_set_mapped_vertex_buffer(draw, i, NULL); } } if (ib) { - pipe->winsys->buffer_unmap(pipe->winsys, index_buffer_handle); + pipe_buffer_unmap(pipe, index_buffer_handle); draw_set_mapped_element_buffer(draw, 0, NULL); } } diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index da9ec12a4d..1a0e19c2f9 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -36,7 +36,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/p_winsys.h" #include "util/u_gen_mipmap.h" #include "cso_cache/cso_cache.h" @@ -105,7 +104,6 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, { struct pipe_context *pipe = ctx->st->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_winsys *ws = pipe->winsys; struct pipe_texture *pt = st_get_texobj_texture(texObj); const uint baseLevel = texObj->BaseLevel; const uint lastLevel = pt->last_level; @@ -128,11 +126,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice); dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice); - srcData = (ubyte *) ws->buffer_map(ws, srcSurf->buffer, - PIPE_BUFFER_USAGE_CPU_READ) + srcData = (ubyte *) pipe_buffer_map(pipe, srcSurf->buffer, + PIPE_BUFFER_USAGE_CPU_READ) + srcSurf->offset; - dstData = (ubyte *) ws->buffer_map(ws, dstSurf->buffer, - PIPE_BUFFER_USAGE_CPU_WRITE) + dstData = (ubyte *) pipe_buffer_map(pipe, dstSurf->buffer, + PIPE_BUFFER_USAGE_CPU_WRITE) + dstSurf->offset; _mesa_generate_mipmap_level(target, datatype, comps, @@ -144,8 +142,8 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, dstSurf->pitch * dstSurf->cpp, /* stride in bytes */ dstData); - ws->buffer_unmap(ws, srcSurf->buffer); - ws->buffer_unmap(ws, dstSurf->buffer); + pipe_buffer_unmap(pipe, srcSurf->buffer); + pipe_buffer_unmap(pipe, dstSurf->buffer); pipe_surface_reference(&srcSurf, NULL); pipe_surface_reference(&dstSurf, NULL); diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 66d81e2b95..f68bef1207 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -38,7 +38,6 @@ #include "pipe/p_inlines.h" #include "pipe/p_util.h" #include "pipe/p_inlines.h" -#include "pipe/p_winsys.h" #define DBG if(0) printf -- cgit v1.2.3 From 54507125e735ffa595e252282eaabf38095c21e1 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 2 May 2008 10:08:03 +0000 Subject: Some changed for non-C99 compilers --- src/mesa/state_tracker/st_atom_blend.c | 15 +++++--------- src/mesa/state_tracker/st_atom_clip.c | 15 +++++--------- src/mesa/state_tracker/st_atom_constbuf.c | 20 +++++++++--------- src/mesa/state_tracker/st_atom_depth.c | 10 ++++----- src/mesa/state_tracker/st_atom_fixedfunction.c | 10 ++++----- src/mesa/state_tracker/st_atom_framebuffer.c | 10 ++++----- src/mesa/state_tracker/st_atom_pixeltransfer.c | 10 ++++----- src/mesa/state_tracker/st_atom_rasterizer.c | 12 +++++------ src/mesa/state_tracker/st_atom_sampler.c | 15 +++++--------- src/mesa/state_tracker/st_atom_scissor.c | 15 +++++--------- src/mesa/state_tracker/st_atom_shader.c | 10 ++++----- src/mesa/state_tracker/st_atom_stipple.c | 10 ++++----- src/mesa/state_tracker/st_atom_texture.c | 15 +++++--------- src/mesa/state_tracker/st_atom_viewport.c | 10 ++++----- src/mesa/state_tracker/st_cb_clear.c | 2 +- src/mesa/state_tracker/st_draw.c | 5 +++-- src/mesa/state_tracker/st_extensions.c | 28 +++++++++++++------------- 17 files changed, 94 insertions(+), 118 deletions(-) mode change 100644 => 100755 src/mesa/state_tracker/st_atom_blend.c mode change 100644 => 100755 src/mesa/state_tracker/st_atom_clip.c mode change 100644 => 100755 src/mesa/state_tracker/st_atom_constbuf.c (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c old mode 100644 new mode 100755 index 2a0e92245c..35c09c3e08 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -223,15 +223,10 @@ update_blend( struct st_context *st ) const struct st_tracked_state st_update_blend = { - .name = "st_update_blend", - .dirty = { - .mesa = (_NEW_COLOR), /* XXX _NEW_BLEND someday? */ - .st = 0, + "st_update_blend", /* name */ + { /* dirty */ + (_NEW_COLOR), /* XXX _NEW_BLEND someday? */ /* mesa */ + 0, /* st */ }, - .update = update_blend + update_blend, /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_clip.c b/src/mesa/state_tracker/st_atom_clip.c old mode 100644 new mode 100755 index a6f0568660..23d709b814 --- a/src/mesa/state_tracker/st_atom_clip.c +++ b/src/mesa/state_tracker/st_atom_clip.c @@ -62,15 +62,10 @@ static void update_clip( struct st_context *st ) const struct st_tracked_state st_update_clip = { - .name = "st_update_clip", - .dirty = { - .mesa = (_NEW_TRANSFORM), - .st = 0, + "st_update_clip", /* name */ + { /* dirty */ + (_NEW_TRANSFORM), /* mesa */ + 0, /* st */ }, - .update = update_clip + update_clip /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c old mode 100644 new mode 100755 index 2b659aebbc..2856e0f0e0 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -113,12 +113,12 @@ static void update_vs_constants(struct st_context *st ) } const struct st_tracked_state st_update_vs_constants = { - .name = "st_update_vs_constants", - .dirty = { - .mesa = 0, /* set dynamically above */ - .st = ST_NEW_VERTEX_PROGRAM, + "st_update_vs_constants", /* name */ + { /* dirty */ + 0, /* set dynamically above */ /* mesa */ + ST_NEW_VERTEX_PROGRAM, /* st */ }, - .update = update_vs_constants + update_vs_constants /* update */ }; /* Fragment shader: @@ -132,11 +132,11 @@ static void update_fs_constants(struct st_context *st ) } const struct st_tracked_state st_update_fs_constants = { - .name = "st_update_fs_constants", - .dirty = { - .mesa = 0, /* set dynamically above */ - .st = ST_NEW_FRAGMENT_PROGRAM, + "st_update_fs_constants", /* name */ + { /* dirty */ + 0, /* set dynamically above */ /* mesa */ + ST_NEW_FRAGMENT_PROGRAM, /* st */ }, - .update = update_fs_constants + update_fs_constants /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index ef467582c0..0e791ceb20 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -142,10 +142,10 @@ update_depth_stencil_alpha(struct st_context *st) const struct st_tracked_state st_update_depth_stencil_alpha = { - .name = "st_update_depth_stencil", - .dirty = { - .mesa = (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR), - .st = 0, + "st_update_depth_stencil", /* name */ + { /* dirty */ + (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR), /* mesa */ + 0, /* st */ }, - .update = update_depth_stencil_alpha + update_depth_stencil_alpha /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_fixedfunction.c b/src/mesa/state_tracker/st_atom_fixedfunction.c index 3f137e1633..165567af70 100644 --- a/src/mesa/state_tracker/st_atom_fixedfunction.c +++ b/src/mesa/state_tracker/st_atom_fixedfunction.c @@ -55,12 +55,12 @@ static void update_tnl( struct st_context *st ) const struct st_tracked_state st_update_tnl = { - .name = "st_update_tnl", - .dirty = { - .mesa = TNL_FIXED_FUNCTION_STATE_FLAGS, - .st = 0 + "st_update_tnl", /* name */ + { /* dirty */ + TNL_FIXED_FUNCTION_STATE_FLAGS, /* mesa */ + 0 /* st */ }, - .update = update_tnl + update_tnl /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 14eeb58cc1..0a6974d8a7 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -96,11 +96,11 @@ update_framebuffer_state( struct st_context *st ) const struct st_tracked_state st_update_framebuffer = { - .name = "st_update_framebuffer", - .dirty = { - .mesa = _NEW_BUFFERS, - .st = 0, + "st_update_framebuffer", /* name */ + { /* dirty */ + _NEW_BUFFERS, /* mesa */ + 0, /* st */ }, - .update = update_framebuffer_state + update_framebuffer_state /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 76356bbad7..999c148449 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -463,10 +463,10 @@ update_pixel_transfer(struct st_context *st) const struct st_tracked_state st_update_pixel_transfer = { - .name = "st_update_pixel_transfer", - .dirty = { - .mesa = _NEW_PIXEL | _NEW_COLOR_MATRIX, - .st = 0, + "st_update_pixel_transfer", /* name */ + { /* dirty */ + _NEW_PIXEL | _NEW_COLOR_MATRIX, /* mesa */ + 0, /* st */ }, - .update = update_pixel_transfer + update_pixel_transfer /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index bb14cf9045..87a91d56d0 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -267,11 +267,11 @@ static void update_raster_state( struct st_context *st ) } const struct st_tracked_state st_update_rasterizer = { - .name = "st_update_rasterizer", - .dirty = { - .mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR | - _NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE), - .st = 0, + "st_update_rasterizer", /* name */ + { /* dirty */ + (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR | /* mesa */ + _NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE), + 0, /* st */ }, - .update = update_raster_state + update_raster_state /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 0237da3693..7515bb30cc 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -185,15 +185,10 @@ update_samplers(struct st_context *st) const struct st_tracked_state st_update_sampler = { - .name = "st_update_sampler", - .dirty = { - .mesa = _NEW_TEXTURE, - .st = 0, + "st_update_sampler", /* name */ + { /* dirty */ + _NEW_TEXTURE, /* mesa */ + 0, /* st */ }, - .update = update_samplers + update_samplers /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c index 59601e91a1..f5db492403 100644 --- a/src/mesa/state_tracker/st_atom_scissor.c +++ b/src/mesa/state_tracker/st_atom_scissor.c @@ -83,15 +83,10 @@ update_scissor( struct st_context *st ) const struct st_tracked_state st_update_scissor = { - .name = "st_update_scissor", - .dirty = { - .mesa = (_NEW_SCISSOR | _NEW_BUFFERS), - .st = 0, + "st_update_scissor", /* name */ + { /* dirty */ + (_NEW_SCISSOR | _NEW_BUFFERS), /* mesa */ + 0, /* st */ }, - .update = update_scissor + update_scissor /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 3f5ec71112..652500f52a 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -281,10 +281,10 @@ update_linkage( struct st_context *st ) const struct st_tracked_state st_update_shader = { - .name = "st_update_shader", - .dirty = { - .mesa = 0, - .st = ST_NEW_VERTEX_PROGRAM | ST_NEW_FRAGMENT_PROGRAM + "st_update_shader", /* name */ + { /* dirty */ + 0, /* mesa */ + ST_NEW_VERTEX_PROGRAM | ST_NEW_FRAGMENT_PROGRAM /* st */ }, - .update = update_linkage + update_linkage /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_stipple.c b/src/mesa/state_tracker/st_atom_stipple.c index c91214059a..f395930ab4 100644 --- a/src/mesa/state_tracker/st_atom_stipple.c +++ b/src/mesa/state_tracker/st_atom_stipple.c @@ -54,10 +54,10 @@ update_stipple( struct st_context *st ) const struct st_tracked_state st_update_polygon_stipple = { - .name = "st_update_polygon_stipple", - .dirty = { - .mesa = (_NEW_POLYGONSTIPPLE), - .st = 0, + "st_update_polygon_stipple", /* name */ + { /* dirty */ + (_NEW_POLYGONSTIPPLE), /* mesa */ + 0, /* st */ }, - .update = update_stipple + update_stipple /* update */ }; diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index d15da5895a..f42b2f8d66 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -111,15 +111,10 @@ update_textures(struct st_context *st) const struct st_tracked_state st_update_texture = { - .name = "st_update_texture", - .dirty = { - .mesa = _NEW_TEXTURE, - .st = ST_NEW_FRAGMENT_PROGRAM, + "st_update_texture", /* name */ + { /* dirty */ + _NEW_TEXTURE, /* mesa */ + ST_NEW_FRAGMENT_PROGRAM, /* st */ }, - .update = update_textures + update_textures /* update */ }; - - - - - diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c index eb3f62cfbe..4b51521470 100644 --- a/src/mesa/state_tracker/st_atom_viewport.c +++ b/src/mesa/state_tracker/st_atom_viewport.c @@ -82,10 +82,10 @@ update_viewport( struct st_context *st ) const struct st_tracked_state st_update_viewport = { - .name = "st_update_viewport", - .dirty = { - .mesa = _NEW_BUFFERS | _NEW_VIEWPORT, - .st = 0, + "st_update_viewport", /* name */ + { /* dirty */ + _NEW_BUFFERS | _NEW_VIEWPORT, /* mesa */ + 0, /* st */ }, - .update = update_viewport + update_viewport /* update */ }; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index fe979f10bd..b7d7204633 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -34,8 +34,8 @@ #include "main/glheader.h" #include "main/macros.h" #include "shader/prog_instruction.h" -#include "st_atom.h" #include "st_context.h" +#include "st_atom.h" #include "st_cb_accum.h" #include "st_cb_clear.h" #include "st_cb_fbo.h" diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 0fe4d198bd..a3bffbfc95 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -35,8 +35,8 @@ #include "vbo/vbo.h" -#include "st_atom.h" #include "st_context.h" +#include "st_atom.h" #include "st_cb_bufferobjects.h" #include "st_draw.h" #include "st_program.h" @@ -549,9 +549,10 @@ st_feedback_draw_vbo(GLcontext *ctx, unsigned indexSize; struct gl_buffer_object *bufobj = ib->obj; struct st_buffer_object *stobj = st_buffer_object(bufobj); - index_buffer_handle = stobj->buffer; void *map; + index_buffer_handle = stobj->buffer; + switch (ib->type) { case GL_UNSIGNED_INT: indexSize = 4; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 260a2efe88..6f94ba39ae 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -38,17 +38,17 @@ #include "st_extensions.h" -static int min(int a, int b) +static int _min(int a, int b) { return (a < b) ? a : b; } -static int max(int a, int b) +static int _max(int a, int b) { return (a > b) ? a : b; } -static int clamp(int a, int min, int max) +static int _clamp(int a, int min, int max) { if (a < min) return min; @@ -69,42 +69,42 @@ void st_init_limits(struct st_context *st) struct gl_constants *c = &st->ctx->Const; c->MaxTextureLevels - = min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), MAX_TEXTURE_LEVELS); c->Max3DTextureLevels - = min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), MAX_3D_TEXTURE_LEVELS); c->MaxCubeTextureLevels - = min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), MAX_CUBE_TEXTURE_LEVELS); c->MaxTextureRectSize - = min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); + = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); c->MaxTextureUnits = c->MaxTextureImageUnits = c->MaxTextureCoordUnits - = min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS), + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS), MAX_TEXTURE_IMAGE_UNITS); c->MaxDrawBuffers - = clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), + = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), 1, MAX_DRAW_BUFFERS); c->MaxLineWidth - = max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH)); + = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH)); c->MaxLineWidthAA - = max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA)); + = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA)); c->MaxPointSize - = max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH)); + = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH)); c->MaxPointSizeAA - = max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA)); + = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA)); c->MaxTextureMaxAnisotropy - = max(2.0, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY)); + = _max(2.0, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY)); c->MaxTextureLodBias = screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS); -- cgit v1.2.3 From 82605d7bcd533d7c96cc619c45970efd7229dc3b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 29 May 2008 11:46:43 +0100 Subject: draw: draw_range_elements trial --- src/gallium/auxiliary/draw/draw_context.c | 20 +++- src/gallium/auxiliary/draw/draw_context.h | 10 +- src/gallium/auxiliary/draw/draw_private.h | 2 + src/gallium/auxiliary/draw/draw_pt.h | 9 ++ src/gallium/auxiliary/draw/draw_pt_fetch_emit.c | 48 ++++++++ .../auxiliary/draw/draw_pt_fetch_shade_emit.c | 49 ++++++++ .../auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 80 +++++++++++++- src/gallium/auxiliary/draw/draw_pt_vcache.c | 123 ++++++++++++++++++++- src/gallium/drivers/softpipe/sp_context.c | 1 + src/gallium/drivers/softpipe/sp_draw_arrays.c | 31 +++++- src/gallium/drivers/softpipe/sp_state.h | 7 ++ src/gallium/include/pipe/p_context.h | 14 +++ src/mesa/state_tracker/st_draw.c | 27 ++++- 13 files changed, 404 insertions(+), 17 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 8509baf865..bcec85c2ef 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -348,14 +348,30 @@ void draw_set_edgeflags( struct draw_context *draw, * \param elements the element buffer ptr */ void -draw_set_mapped_element_buffer( struct draw_context *draw, - unsigned eltSize, void *elements ) +draw_set_mapped_element_buffer_range( struct draw_context *draw, + unsigned eltSize, + unsigned min_index, + unsigned max_index, + void *elements ) { draw->pt.user.elts = elements; draw->pt.user.eltSize = eltSize; + draw->pt.user.min_index = min_index; + draw->pt.user.max_index = max_index; } +void +draw_set_mapped_element_buffer( struct draw_context *draw, + unsigned eltSize, + void *elements ) +{ + draw->pt.user.elts = elements; + draw->pt.user.eltSize = eltSize; + draw->pt.user.min_index = 0; + draw->pt.user.max_index = 0xffffffff; +} + /* Revamp me please: */ diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index c5c3d3b09e..8dd03cb79e 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -118,8 +118,16 @@ void draw_set_vertex_elements(struct draw_context *draw, unsigned count, const struct pipe_vertex_element *elements); +void +draw_set_mapped_element_buffer_range( struct draw_context *draw, + unsigned eltSize, + unsigned min_index, + unsigned max_index, + void *elements ); + void draw_set_mapped_element_buffer( struct draw_context *draw, - unsigned eltSize, void *elements ); + unsigned eltSize, + void *elements ); void draw_set_mapped_vertex_buffer(struct draw_context *draw, unsigned attr, const void *buffer); diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 4cbccc8b5b..40f1d978f2 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -147,6 +147,8 @@ struct draw_context const void *elts; /** bytes per index (0, 1, 2 or 4) */ unsigned eltSize; + unsigned min_index; + unsigned max_index; /** vertex arrays */ const void *vbuffer[PIPE_MAX_ATTRIBS]; diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h index e03816ebbc..6b8ba1d171 100644 --- a/src/gallium/auxiliary/draw/draw_pt.h +++ b/src/gallium/auxiliary/draw/draw_pt.h @@ -96,6 +96,15 @@ struct draw_pt_middle_end { unsigned start, unsigned count); + /* Transform all vertices in a linear range and then draw them with + * the supplied element list. + */ + void (*run_linear_elts)( struct draw_pt_middle_end *, + unsigned fetch_start, + unsigned fetch_count, + const ushort *draw_elts, + unsigned draw_count ); + void (*finish)( struct draw_pt_middle_end * ); void (*destroy)( struct draw_pt_middle_end * ); }; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index a1d041a74f..09bdc5fb5e 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -311,6 +311,53 @@ static void fetch_emit_run_linear( struct draw_pt_middle_end *middle, } +static void fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle, + unsigned start, + unsigned count, + const ushort *draw_elts, + unsigned draw_count ) +{ + struct fetch_emit_middle_end *feme = (struct fetch_emit_middle_end *)middle; + struct draw_context *draw = feme->draw; + void *hw_verts; + + /* XXX: need to flush to get prim_vbuf.c to release its allocation?? + */ + draw_do_flush( draw, DRAW_FLUSH_BACKEND ); + + hw_verts = draw->render->allocate_vertices( draw->render, + (ushort)feme->translate->key.output_stride, + (ushort)count ); + if (!hw_verts) { + assert(0); + return; + } + + /* Single routine to fetch vertices and emit HW verts. + */ + feme->translate->run( feme->translate, + start, + count, + hw_verts ); + + /* XXX: Draw arrays path to avoid re-emitting index list again and + * again. + */ + draw->render->draw( draw->render, + draw_elts, + draw_count ); + + /* Done -- that was easy, wasn't it: + */ + draw->render->release_vertices( draw->render, + hw_verts, + feme->translate->key.output_stride, + count ); + +} + + + static void fetch_emit_finish( struct draw_pt_middle_end *middle ) { @@ -343,6 +390,7 @@ struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw ) fetch_emit->base.prepare = fetch_emit_prepare; fetch_emit->base.run = fetch_emit_run; fetch_emit->base.run_linear = fetch_emit_run_linear; + fetch_emit->base.run_linear_elts = fetch_emit_run_linear_elts; fetch_emit->base.finish = fetch_emit_finish; fetch_emit->base.destroy = fetch_emit_destroy; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c index 5265a13160..efa6dddbda 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c @@ -310,6 +310,54 @@ fse_run(struct draw_pt_middle_end *middle, } + +static void fse_run_linear_elts( struct draw_pt_middle_end *middle, + unsigned start, + unsigned count, + const ushort *draw_elts, + unsigned draw_count ) +{ + struct fetch_shade_emit *fse = (struct fetch_shade_emit *)middle; + struct draw_context *draw = fse->draw; + unsigned alloc_count = align(count, 4); + char *hw_verts; + + /* XXX: need to flush to get prim_vbuf.c to release its allocation?? + */ + draw_do_flush( draw, DRAW_FLUSH_BACKEND ); + + hw_verts = draw->render->allocate_vertices( draw->render, + (ushort)fse->key.output_stride, + (ushort)alloc_count ); + + if (!hw_verts) { + assert(0); + return; + } + + /* Single routine to fetch vertices, run shader and emit HW verts. + * Clipping is done elsewhere -- either by the API or on hardware, + * or for some other reason not required... + */ + fse->active->run_linear( fse->active, + start, count, + hw_verts ); + + + draw->render->draw( draw->render, + draw_elts, + draw_count ); + + + + draw->render->release_vertices( draw->render, + hw_verts, + fse->key.output_stride, + count ); +} + + + static void fse_finish( struct draw_pt_middle_end *middle ) { } @@ -330,6 +378,7 @@ struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw ) fse->base.prepare = fse_prepare; fse->base.run = fse_run; fse->base.run_linear = fse_run_linear; + fse->base.run_linear_elts = fse_run_linear_elts; fse->base.finish = fse_finish; fse->base.destroy = fse_destroy; fse->draw = draw; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index 06718779a5..c58a900867 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -98,7 +98,6 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle, - static void fetch_pipeline_run( struct draw_pt_middle_end *middle, const unsigned *fetch_elts, unsigned fetch_count, @@ -251,6 +250,84 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle, +static void fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle, + unsigned start, + unsigned count, + const ushort *draw_elts, + unsigned draw_count ) +{ + struct fetch_pipeline_middle_end *fpme = (struct fetch_pipeline_middle_end *)middle; + struct draw_context *draw = fpme->draw; + struct draw_vertex_shader *shader = draw->vs.vertex_shader; + unsigned opt = fpme->opt; + unsigned alloc_count = align_int( count, 4 ); + + struct vertex_header *pipeline_verts = + (struct vertex_header *)MALLOC(fpme->vertex_size * alloc_count); + + if (!pipeline_verts) { + /* Not much we can do here - just skip the rendering. + */ + assert(0); + return; + } + + /* Fetch into our vertex buffer + */ + draw_pt_fetch_run_linear( fpme->fetch, + start, + count, + (char *)pipeline_verts ); + + /* Run the shader, note that this overwrites the data[] parts of + * the pipeline verts. If there is no shader, ie a bypass shader, + * then the inputs == outputs, and are already in the correct + * place. + */ + if (opt & PT_SHADE) + { + shader->run_linear(shader, + (const float (*)[4])pipeline_verts->data, + ( float (*)[4])pipeline_verts->data, + (const float (*)[4])draw->pt.user.constants, + count, + fpme->vertex_size, + fpme->vertex_size); + } + + if (draw_pt_post_vs_run( fpme->post_vs, + pipeline_verts, + count, + fpme->vertex_size )) + { + opt |= PT_PIPELINE; + } + + /* Do we need to run the pipeline? + */ + if (opt & PT_PIPELINE) { + draw_pipeline_run( fpme->draw, + fpme->prim, + pipeline_verts, + count, + fpme->vertex_size, + draw_elts, + draw_count ); + } + else { + draw_pt_emit( fpme->emit, + (const float (*)[4])pipeline_verts->data, + count, + fpme->vertex_size, + draw_elts, + draw_count ); + } + + FREE(pipeline_verts); +} + + + static void fetch_pipeline_finish( struct draw_pt_middle_end *middle ) { /* nothing to do */ @@ -282,6 +359,7 @@ struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit( struct draw_context * fpme->base.prepare = fetch_pipeline_prepare; fpme->base.run = fetch_pipeline_run; fpme->base.run_linear = fetch_pipeline_linear_run; + fpme->base.run_linear_elts = fetch_pipeline_linear_run_elts; fpme->base.finish = fetch_pipeline_finish; fpme->base.destroy = fetch_pipeline_destroy; diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 96e02fbf3a..720b91b8e6 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -36,8 +36,8 @@ #include "draw/draw_pt.h" -#define CACHE_MAX 32 -#define FETCH_MAX 128 +#define CACHE_MAX 1024 +#define FETCH_MAX 4096 #define DRAW_MAX (16*1024) struct vcache_frontend { @@ -201,7 +201,124 @@ static void vcache_ef_quad( struct vcache_frontend *vcache, #define FUNC vcache_run #include "draw_pt_vcache_tmp.h" +static void translate_uint_elts( const unsigned *src, + unsigned count, + int delta, + ushort *dest ) +{ + unsigned i; + + for (i = 0; i < count; i++) + dest[i] = (ushort)(src[i] + delta); +} + +static void translate_ushort_elts( const ushort *src, + unsigned count, + int delta, + ushort *dest ) +{ + unsigned i; + + for (i = 0; i < count; i++) + dest[i] = (ushort)(src[i] + delta); +} +static void translate_ubyte_elts( const ubyte *src, + unsigned count, + int delta, + ushort *dest ) +{ + unsigned i; + + for (i = 0; i < count; i++) + dest[i] = (ushort)(src[i] + delta); +} + +#if 0 +static enum pipe_format format_from_get_elt( pt_elt_func get_elt ) +{ + switch (draw->pt.user.eltSize) { + case 1: return PIPE_FORMAT_R8_UNORM; + case 2: return PIPE_FORMAT_R16_UNORM; + case 4: return PIPE_FORMAT_R32_UNORM; + default: return PIPE_FORMAT_NONE; + } +} +#endif + +static void vcache_check_run( struct draw_pt_front_end *frontend, + pt_elt_func get_elt, + const void *elts, + unsigned draw_count ) +{ + struct vcache_frontend *vcache = (struct vcache_frontend *)frontend; + struct draw_context *draw = vcache->draw; + unsigned min_index = draw->pt.user.min_index; + unsigned max_index = draw->pt.user.max_index; + unsigned index_size = draw->pt.user.eltSize; + unsigned fetch_count = MAX2(max_index, max_index + 1 - min_index); + const ushort *transformed_elts; + ushort *storage = NULL; + + printf("fetch_count %x\n", fetch_count); + + if (fetch_count >= FETCH_MAX || + fetch_count > draw_count) + goto fail; + + + if (min_index == 0 && + index_size == 2) + { + transformed_elts = (const ushort *)elts; + } + else + { + storage = MALLOC( draw_count * sizeof(ushort) ); + if (!storage) + goto fail; + + switch(index_size) { + case 1: + translate_ubyte_elts( (const ubyte *)elts, + draw_count, + 0 - (int)min_index, + storage ); + break; + + case 2: + translate_ushort_elts( (const ushort *)elts, + draw_count, + 0 - (int)min_index, + storage ); + break; + + case 4: + translate_uint_elts( (const uint *)elts, + draw_count, + 0 - (int)min_index, + storage ); + break; + + default: + assert(0); + return; + } + transformed_elts = storage; + } + + vcache->middle->run_linear_elts( vcache->middle, + min_index, /* start */ + fetch_count, + transformed_elts, + draw_count ); + + FREE(storage); + return; + + fail: + vcache_run( frontend, get_elt, elts, draw_count ); +} @@ -219,7 +336,7 @@ static void vcache_prepare( struct draw_pt_front_end *frontend, } else { - vcache->base.run = vcache_run; + vcache->base.run = vcache_check_run; } vcache->input_prim = prim; diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 045a1f74a9..1e0106b86c 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -179,6 +179,7 @@ softpipe_create( struct pipe_screen *screen, softpipe->pipe.draw_arrays = softpipe_draw_arrays; softpipe->pipe.draw_elements = softpipe_draw_elements; + softpipe->pipe.draw_range_elements = softpipe_draw_range_elements; softpipe->pipe.set_edgeflags = softpipe_set_edgeflags; diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 6c58f9909d..dbecf6865f 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -108,11 +108,14 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, * * XXX should the element buffer be specified/bound with a separate function? */ + boolean -softpipe_draw_elements(struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned mode, unsigned start, unsigned count) +softpipe_draw_range_elements(struct pipe_context *pipe, + struct pipe_buffer *indexBuffer, + unsigned indexSize, + unsigned min_index, + unsigned max_index, + unsigned mode, unsigned start, unsigned count) { struct softpipe_context *sp = softpipe_context(pipe); struct draw_context *draw = sp->draw; @@ -141,11 +144,14 @@ softpipe_draw_elements(struct pipe_context *pipe, void *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); + draw_set_mapped_element_buffer_range(draw, indexSize, + min_index, + max_index, + mapped_indexes); } else { /* no index/element buffer */ - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL); } @@ -171,6 +177,19 @@ softpipe_draw_elements(struct pipe_context *pipe, return TRUE; } +boolean +softpipe_draw_elements(struct pipe_context *pipe, + struct pipe_buffer *indexBuffer, + unsigned indexSize, + unsigned mode, unsigned start, unsigned count) +{ + return softpipe_draw_range_elements( pipe, indexBuffer, + indexSize, + 0, 0xffffffff, + mode, start, count ); +} + + void softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags) diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index 452e51fa79..701e02b295 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -171,6 +171,13 @@ boolean softpipe_draw_elements(struct pipe_context *pipe, struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count); +boolean +softpipe_draw_range_elements(struct pipe_context *pipe, + struct pipe_buffer *indexBuffer, + unsigned indexSize, + unsigned min_index, + unsigned max_index, + unsigned mode, unsigned start, unsigned count); void softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags); diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 0f68f592f7..faf112c6d6 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -76,6 +76,20 @@ struct pipe_context { struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count); + + /* XXX: this is (probably) a temporary entrypoint, as the range + * information should be available from the vertex_buffer state. + * Using this to quickly evaluate a specialized path in the draw + * module. + */ + boolean (*draw_range_elements)( struct pipe_context *pipe, + struct pipe_buffer *indexBuffer, + unsigned indexSize, + unsigned minIndex, + unsigned maxIndex, + unsigned mode, + unsigned start, + unsigned count); /*@}*/ diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index a3bffbfc95..551860452a 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -365,14 +365,33 @@ st_draw_vbo(GLcontext *ctx, } /* draw */ - for (i = 0; i < nr_prims; i++) { + if (nr_prims == 1 && pipe->draw_range_elements != NULL) { + i = 0; + + /* XXX: exercise temporary path to pass min/max directly + * through to driver & draw module. These interfaces still + * need a bit of work... + */ setup_edgeflags(ctx, prims[i].mode, prims[i].start + indexOffset, prims[i].count, arrays[VERT_ATTRIB_EDGEFLAG]); - pipe->draw_elements(pipe, indexBuf, indexSize, - prims[i].mode, - prims[i].start + indexOffset, prims[i].count); + pipe->draw_range_elements(pipe, indexBuf, indexSize, + min_index, + max_index, + prims[i].mode, + prims[i].start + indexOffset, prims[i].count); + } + else { + for (i = 0; i < nr_prims; i++) { + setup_edgeflags(ctx, prims[i].mode, + prims[i].start + indexOffset, prims[i].count, + arrays[VERT_ATTRIB_EDGEFLAG]); + + pipe->draw_elements(pipe, indexBuf, indexSize, + prims[i].mode, + prims[i].start + indexOffset, prims[i].count); + } } pipe_reference_buffer(pipe, &indexBuf, NULL); -- cgit v1.2.3 From bb2e13b9e82b68ec3b9fc56a4c35e7ead8fd138f Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 29 May 2008 12:38:49 +0100 Subject: draw: make sure constant buffer data is aligned before passing to aos.c --- src/gallium/auxiliary/draw/draw_context.c | 5 +++-- src/gallium/auxiliary/draw/draw_context.h | 3 ++- src/gallium/auxiliary/draw/draw_private.h | 9 ++++++++- src/gallium/auxiliary/draw/draw_vs.c | 19 ++++++++++++++++++- src/gallium/auxiliary/draw/draw_vs_aos.c | 4 ++-- src/gallium/drivers/i915simple/i915_context.c | 4 +++- src/gallium/drivers/softpipe/sp_draw_arrays.c | 5 +++-- src/mesa/state_tracker/st_draw.c | 7 ++++--- 8 files changed, 43 insertions(+), 13 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index bcec85c2ef..2f263cf06a 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -217,10 +217,11 @@ draw_set_mapped_vertex_buffer(struct draw_context *draw, void draw_set_mapped_constant_buffer(struct draw_context *draw, - const void *buffer) + const void *buffer, + unsigned size ) { draw->pt.user.constants = buffer; - draw_vs_set_constants( draw, (const float (*)[4])buffer ); + draw_vs_set_constants( draw, (const float (*)[4])buffer, size ); } diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index 8dd03cb79e..b8f2bfa332 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -133,7 +133,8 @@ void draw_set_mapped_vertex_buffer(struct draw_context *draw, unsigned attr, const void *buffer); void draw_set_mapped_constant_buffer(struct draw_context *draw, - const void *buffer); + const void *buffer, + unsigned size ); void draw_set_edgeflags( struct draw_context *draw, const unsigned *edgeflag ); diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 40f1d978f2..88a7224b62 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -190,6 +190,12 @@ struct draw_context struct aos_machine *aos_machine; + const float (*aligned_constants)[4]; + + const float (*aligned_constant_storage)[4]; + unsigned const_storage_size; + + struct translate *fetch; struct translate_cache *fetch_cache; struct translate *emit; @@ -225,7 +231,8 @@ void draw_vs_set_viewport( struct draw_context *, const struct pipe_viewport_state * ); void draw_vs_set_constants( struct draw_context *, - const float (*constants)[4] ); + const float (*constants)[4], + unsigned size ); diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index a8b6d0c90d..ce35112fc1 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -43,8 +43,22 @@ void draw_vs_set_constants( struct draw_context *draw, - const float (*constants)[4] ) + const float (*constants)[4], + unsigned size ) { + if (((unsigned)constants) & 0xf) { + if (size > draw->vs.const_storage_size) { + if (draw->vs.aligned_constant_storage) + align_free(draw->vs.aligned_constant_storage); + draw->vs.aligned_constant_storage = align_malloc( size, 16 ); + } + memcpy( draw->vs.aligned_constant_storage, + constants, + size ); + constants = draw->vs.aligned_constant_storage; + } + + draw->vs.aligned_constants = constants; draw_vs_aos_machine_constants( draw->vs.aos_machine, constants ); } @@ -159,6 +173,9 @@ draw_vs_destroy( struct draw_context *draw ) if (draw->vs.aos_machine) draw_vs_aos_machine_destroy(draw->vs.aos_machine); + if (draw->vs.aligned_constant_storage) + align_free(draw->vs.aligned_constant_storage); + tgsi_exec_machine_free_data(&draw->vs.machine); } diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c index b5e4e1e7b1..55cabb6df9 100644 --- a/src/gallium/auxiliary/draw/draw_vs_aos.c +++ b/src/gallium/auxiliary/draw/draw_vs_aos.c @@ -1957,7 +1957,7 @@ static void PIPE_CDECL vaos_run_elts( struct draw_vs_varient *varient, struct aos_machine *machine = vaos->draw->vs.aos_machine; machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size; - machine->constants = (const float (*)[4])vaos->draw->pt.user.constants; + machine->constants = vaos->draw->vs.aligned_constants; machine->immediates = vaos->base.vs->immediates; machine->attrib = vaos->attrib; @@ -1976,7 +1976,7 @@ static void PIPE_CDECL vaos_run_linear( struct draw_vs_varient *varient, struct aos_machine *machine = vaos->draw->vs.aos_machine; machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size; - machine->constants = (const float (*)[4])vaos->draw->pt.user.constants; + machine->constants = vaos->draw->vs.aligned_constants; machine->immediates = vaos->base.vs->immediates; machine->attrib = vaos->attrib; diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c index 4bef21619c..c609d16a5a 100644 --- a/src/gallium/drivers/i915simple/i915_context.c +++ b/src/gallium/drivers/i915simple/i915_context.c @@ -86,7 +86,9 @@ i915_draw_elements( struct pipe_context *pipe, draw_set_mapped_constant_buffer(draw, - i915->current.constants[PIPE_SHADER_VERTEX]); + i915->current.constants[PIPE_SHADER_VERTEX], + ( i915->current.num_user_constants[PIPE_SHADER_VERTEX] * + 4 * sizeof(float) )); /* draw! */ draw_arrays(i915->draw, prim, start, count); diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index dbecf6865f..d4d5fa744f 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -54,7 +54,8 @@ softpipe_map_constant_buffers(struct softpipe_context *sp) } draw_set_mapped_constant_buffer(sp->draw, - sp->mapped_constants[PIPE_SHADER_VERTEX]); + sp->mapped_constants[PIPE_SHADER_VERTEX], + sp->constants[i].size); } static void @@ -68,7 +69,7 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp) */ draw_flush(sp->draw); - draw_set_mapped_constant_buffer(sp->draw, NULL); + draw_set_mapped_constant_buffer(sp->draw, NULL, 0); for (i = 0; i < 2; i++) { if (sp->constants[i].size) diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 551860452a..5300848ef6 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -596,9 +596,10 @@ st_feedback_draw_vbo(GLcontext *ctx, /* map constant buffers */ mapped_constants = pipe_buffer_map(pipe, - st->state.constants[PIPE_SHADER_VERTEX].buffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_constant_buffer(st->draw, mapped_constants); + st->state.constants[PIPE_SHADER_VERTEX].buffer, + PIPE_BUFFER_USAGE_CPU_READ); + draw_set_mapped_constant_buffer(st->draw, mapped_constants, + st->state.constants[PIPE_SHADER_VERTEX].buffer->size); /* draw here */ -- cgit v1.2.3 From 89e9d6b6db933c870443714c3d7c9539d117cddf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 23 Jun 2008 17:13:14 -0600 Subject: gallium: added support for fixed-point formats, drawing --- src/gallium/auxiliary/translate/translate_generic.c | 18 ++++++++++++++++++ src/gallium/include/pipe/p_format.h | 5 +++++ src/mesa/state_tracker/st_cb_texture.c | 3 ++- src/mesa/state_tracker/st_draw.c | 14 ++++++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c index 3fec89b36e..17e37d1745 100644 --- a/src/gallium/auxiliary/translate/translate_generic.c +++ b/src/gallium/auxiliary/translate/translate_generic.c @@ -121,6 +121,8 @@ emit_##NAME(const float *attrib, void *ptr) \ #define FROM_16_SNORM(i) ((float) ((short *) ptr)[i] / 32767.0f) #define FROM_32_SNORM(i) ((float) ((int *) ptr)[i] / 2147483647.0f) +#define FROM_32_FIXED(i) (((int *) ptr)[i] / 65536.0) + #define TO_64_FLOAT(x) ((double) x) #define TO_32_FLOAT(x) (x) @@ -140,6 +142,8 @@ emit_##NAME(const float *attrib, void *ptr) \ #define TO_16_SNORM(x) ((short) (x * 32767.0f)) #define TO_32_SNORM(x) ((int) (x * 2147483647.0f)) +#define TO_32_FIXED(x) ((int) (x * 65536.0f)) + ATTRIB( R64G64B64A64_FLOAT, 4, double, FROM_64_FLOAT, TO_64_FLOAT ) @@ -215,6 +219,11 @@ ATTRIB( R8_SNORM, 1, char, FROM_8_SNORM, TO_8_SNORM ) ATTRIB( A8R8G8B8_UNORM, 4, ubyte, FROM_8_UNORM, TO_8_UNORM ) //ATTRIB( R8G8B8A8_UNORM, 4, ubyte, FROM_8_UNORM, TO_8_UNORM ) +ATTRIB( R32G32B32A32_FIXED, 4, int, FROM_32_FIXED, TO_32_FIXED ) +ATTRIB( R32G32B32_FIXED, 3, int, FROM_32_FIXED, TO_32_FIXED ) +ATTRIB( R32G32_FIXED, 2, int, FROM_32_FIXED, TO_32_FIXED ) +ATTRIB( R32_FIXED, 1, int, FROM_32_FIXED, TO_32_FIXED ) + static void @@ -386,6 +395,15 @@ static fetch_func get_fetch_func( enum pipe_format format ) case PIPE_FORMAT_B8G8R8A8_UNORM: return &fetch_B8G8R8A8_UNORM; + case PIPE_FORMAT_R32_FIXED: + return &fetch_R32_FIXED; + case PIPE_FORMAT_R32G32_FIXED: + return &fetch_R32G32_FIXED; + case PIPE_FORMAT_R32G32B32_FIXED: + return &fetch_R32G32B32_FIXED; + case PIPE_FORMAT_R32G32B32A32_FIXED: + return &fetch_R32G32B32A32_FIXED; + default: assert(0); return &fetch_NULL; diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 579fdb2957..00aa02311c 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -83,6 +83,7 @@ static INLINE uint pf_layout(uint f) /**< PIPE_FORMAT_LAYOUT_ */ #define PIPE_FORMAT_TYPE_USCALED 4 /**< uints, not normalized */ #define PIPE_FORMAT_TYPE_SSCALED 5 /**< ints, not normalized */ #define PIPE_FORMAT_TYPE_SRGB 6 /**< sRGB colorspace */ +#define PIPE_FORMAT_TYPE_FIXED 7 /**< 16.16 fixed point */ /** @@ -353,6 +354,10 @@ enum pipe_format { PIPE_FORMAT_R8G8B8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SSCALED ), PIPE_FORMAT_R8G8B8A8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SSCALED ), PIPE_FORMAT_R8G8B8X8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SSCALED ), + PIPE_FORMAT_R32_FIXED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R001, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FIXED ), + PIPE_FORMAT_R32G32_FIXED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG01, 4, 4, 0, 0, PIPE_FORMAT_TYPE_FIXED ), + PIPE_FORMAT_R32G32B32_FIXED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB1, 4, 4, 4, 0, PIPE_FORMAT_TYPE_FIXED ), + PIPE_FORMAT_R32G32B32A32_FIXED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_FIXED ), /* sRGB formats */ PIPE_FORMAT_L8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SRGB ), PIPE_FORMAT_A8_L8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRG, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ), diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index da45a5e321..7d52d1da1b 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1161,7 +1161,8 @@ do_copy_texsubimage(GLcontext *ctx, (void) texImage; - /* XX need this? st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);*/ + /* XX need this?*/ + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); /* determine if copying depth or color data */ if (baseFormat == GL_DEPTH_COMPONENT) { diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 5300848ef6..6867d50c87 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -147,6 +147,14 @@ static GLuint byte_types_scale[4] = { PIPE_FORMAT_R8G8B8A8_SSCALED }; +static GLuint fixed_types[4] = { + PIPE_FORMAT_R32_FIXED, + PIPE_FORMAT_R32G32_FIXED, + PIPE_FORMAT_R32G32B32_FIXED, + PIPE_FORMAT_R32G32B32A32_FIXED +}; + + /** * Return a PIPE_FORMAT_x for the given GL datatype and size. @@ -154,8 +162,8 @@ static GLuint byte_types_scale[4] = { static GLuint pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized) { - assert(type >= GL_BYTE); - assert(type <= GL_DOUBLE); + assert((type >= GL_BYTE && type <= GL_DOUBLE) || + type == GL_FIXED); assert(size >= 1); assert(size <= 4); @@ -169,6 +177,7 @@ pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized) case GL_UNSIGNED_INT: return uint_types_norm[size-1]; case GL_UNSIGNED_SHORT: return ushort_types_norm[size-1]; case GL_UNSIGNED_BYTE: return ubyte_types_norm[size-1]; + case GL_FIXED: return fixed_types[size-1]; default: assert(0); return 0; } } @@ -182,6 +191,7 @@ pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized) case GL_UNSIGNED_INT: return uint_types_scale[size-1]; case GL_UNSIGNED_SHORT: return ushort_types_scale[size-1]; case GL_UNSIGNED_BYTE: return ubyte_types_scale[size-1]; + case GL_FIXED: return fixed_types[size-1]; default: assert(0); return 0; } } -- cgit v1.2.3 From 18ec140ef27b6488bea9d54e21b08b0a3afbcafe Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 24 Jun 2008 11:34:46 +0900 Subject: mesa: Use appropriate unsigned/signed, float/integer types. --- src/mesa/main/mm.c | 4 ++-- src/mesa/shader/program.c | 2 +- src/mesa/shader/shader_api.c | 4 ++-- src/mesa/shader/slang/slang_compile.c | 2 +- src/mesa/shader/slang/slang_print.c | 6 +++--- src/mesa/state_tracker/st_cb_drawpixels.c | 18 +++++++++--------- src/mesa/state_tracker/st_cb_readpixels.c | 9 +++++---- src/mesa/state_tracker/st_draw.c | 2 +- src/mesa/state_tracker/st_extensions.c | 12 ++++++------ 9 files changed, 30 insertions(+), 29 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/main/mm.c b/src/mesa/main/mm.c index fb7809ed22..9f3aa00aff 100644 --- a/src/mesa/main/mm.c +++ b/src/mesa/main/mm.c @@ -164,8 +164,8 @@ mmAllocMem(struct mem_block *heap, int size, int align2, int startSearch) { struct mem_block *p; const int mask = (1 << align2)-1; - unsigned int startofs = 0; - unsigned int endofs; + int startofs = 0; + int endofs; if (!heap || align2 < 0 || size <= 0) return NULL; diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index a0817a91ec..b27ed6b7d3 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -467,7 +467,7 @@ _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count) for (i = 0; i < prog->NumInstructions; i++) { struct prog_instruction *inst = prog->Instructions + i; if (inst->BranchTarget > 0) { - if (inst->BranchTarget >= start) { + if ((GLuint)inst->BranchTarget >= start) { inst->BranchTarget += count; } } diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 856179e1d5..97edb25400 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1079,7 +1079,7 @@ update_textures_used(struct gl_program *prog) */ static void set_program_uniform(GLcontext *ctx, struct gl_program *program, GLint location, - GLenum type, GLint count, GLint elems, const void *values) + GLenum type, GLsizei count, GLint elems, const void *values) { if (program->Parameters->Parameters[location].Type == PROGRAM_SAMPLER) { /* This controls which texture unit which is used by a sampler */ @@ -1111,7 +1111,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, GLint location, } else { /* ordinary uniform variable */ - GLuint k, i; + GLsizei k, i; if (count * elems > program->Parameters->Parameters[location].Size) { _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(count too large)"); diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index cdea1c5128..8485103129 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -1934,7 +1934,7 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, byte *prod; GLuint size, start, version; slang_string preprocessed; - int maxVersion; + GLuint maxVersion; #if FEATURE_ARB_shading_language_120 maxVersion = 120; diff --git a/src/mesa/shader/slang/slang_print.c b/src/mesa/shader/slang/slang_print.c index f3e127cb13..4a7d4bbbc7 100644 --- a/src/mesa/shader/slang/slang_print.c +++ b/src/mesa/shader/slang/slang_print.c @@ -182,14 +182,14 @@ static void print_generic2(const slang_operation *op, const char *oper, const char *s, int indent) { - int i; + GLuint i; if (oper) { spaces(indent); printf("[%p locals %p] %s %s\n", (void*) op, (void*) op->locals, oper, s); } for (i = 0; i < op->num_children; i++) { spaces(indent); - printf("//child %d:\n", i); + printf("//child %u:\n", i); slang_print_tree(&op->children[i], indent); } } @@ -804,7 +804,7 @@ int slang_checksum_tree(const slang_operation *op) { int s = op->num_children; - int i; + GLuint i; for (i = 0; i < op->num_children; i++) { s += slang_checksum_tree(&op->children[i]); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index a486581989..8fdeb5c380 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -517,7 +517,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, struct pipe_context *pipe = ctx->st->pipe; struct cso_context *cso = ctx->st->cso_context; GLfloat x0, y0, x1, y1; - GLuint maxSize; + GLsizei maxSize; /* limit checks */ /* XXX if DrawPixels image is larger than max texture size, break @@ -574,14 +574,14 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, const float width = ctx->DrawBuffer->Width; const float height = ctx->DrawBuffer->Height; struct pipe_viewport_state vp; - vp.scale[0] = 0.5 * width; - vp.scale[1] = -0.5 * height; - vp.scale[2] = 1.0; - vp.scale[3] = 1.0; - vp.translate[0] = 0.5 * width; - vp.translate[1] = 0.5 * height; - vp.translate[2] = 0.0; - vp.translate[3] = 0.0; + vp.scale[0] = 0.5f * width; + vp.scale[1] = -0.5f * height; + vp.scale[2] = 1.0f; + vp.scale[3] = 1.0f; + vp.translate[0] = 0.5f * width; + vp.translate[1] = 0.5f * height; + vp.translate[2] = 0.0f; + vp.translate[3] = 0.0f; cso_set_viewport(cso, &vp); } diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 08934af319..c5193631a7 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -177,7 +177,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, struct pipe_screen *screen = pipe->screen; GLfloat temp[MAX_WIDTH][4]; const GLbitfield transferOps = ctx->_ImageTransferState; - GLint i, yStep, dfStride; + GLsizei i, j; + GLint yStep, dfStride; GLfloat *df; struct st_renderbuffer *strb; struct gl_pixelstore_attrib clippedPacking = *pack; @@ -258,7 +259,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, surf->format == PIPE_FORMAT_X8Z24_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { - GLuint ztemp[MAX_WIDTH], j; + GLuint ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / ((1 << 24) - 1); pipe_get_tile_raw(pipe, surf, x, y, width, 1, ztemp, 0); @@ -283,7 +284,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } else if (surf->format == PIPE_FORMAT_Z16_UNORM) { for (i = 0; i < height; i++) { - GLushort ztemp[MAX_WIDTH], j; + GLushort ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / 0xffff; pipe_get_tile_raw(pipe, surf, x, y, width, 1, ztemp, 0); @@ -298,7 +299,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } else if (surf->format == PIPE_FORMAT_Z32_UNORM) { for (i = 0; i < height; i++) { - GLuint ztemp[MAX_WIDTH], j; + GLuint ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / 0xffffffff; pipe_get_tile_raw(pipe, surf, x, y, width, 1, ztemp, 0); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 6867d50c87..21911774d7 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -216,7 +216,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)) { /* need edge flags */ - GLuint i; + GLint i; unsigned *vec; struct st_buffer_object *stobj = st_buffer_object(array->BufferObj); ubyte *map; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 6f94ba39ae..d804d2b453 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -43,7 +43,7 @@ static int _min(int a, int b) return (a < b) ? a : b; } -static int _max(int a, int b) +static float _maxf(float a, float b) { return (a > b) ? a : b; } @@ -94,17 +94,17 @@ void st_init_limits(struct st_context *st) 1, MAX_DRAW_BUFFERS); c->MaxLineWidth - = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH)); + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH)); c->MaxLineWidthAA - = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA)); + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA)); c->MaxPointSize - = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH)); + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH)); c->MaxPointSizeAA - = _max(1.0, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA)); + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA)); c->MaxTextureMaxAnisotropy - = _max(2.0, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY)); + = _maxf(2.0f, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY)); c->MaxTextureLodBias = screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS); -- cgit v1.2.3 From b7dfabcaab020e89644f47ec243b231c21fece63 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 7 Jul 2008 10:08:43 -0600 Subject: gallium: simplify/fix buffer_offset, src_offset computation for VBO arrays Things broke when vertex position wasn't the first attribute. --- src/mesa/state_tracker/st_draw.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 21911774d7..3291387929 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -300,8 +300,8 @@ st_draw_vbo(GLcontext *ctx, vbuffer[attr].buffer = NULL; pipe_reference_buffer(pipe, &vbuffer[attr].buffer, stobj->buffer); - vbuffer[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ - velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; + vbuffer[attr].buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; + velements[attr].src_offset = 0; assert(velements[attr].src_offset <= 2048); /* 11-bit field */ } else { @@ -335,6 +335,25 @@ st_draw_vbo(GLcontext *ctx, assert(velements[attr].src_format); } +#if 0 + { + GLuint i; + char buf[100]; + for (i = 0; i < vp->num_inputs; i++) { + printf("buffers[%d].pitch = %u\n", i, vbuffer[i].pitch); + printf("buffers[%d].max_index = %u\n", i, vbuffer[i].max_index); + printf("buffers[%d].buffer_offset = %u\n", i, vbuffer[i].buffer_offset); + printf("buffers[%d].buffer = %p\n", i, (void*) vbuffer[i].buffer); + } + for (i = 0; i < vp->num_inputs; i++) { + printf("vlements[%d].src_offset = %u\n", i, velements[i].src_offset); + printf("vlements[%d].vbuffer_index = %u\n", i, velements[i].vertex_buffer_index); + printf("vlements[%d].nr_comps = %u\n", i, velements[i].nr_components); + printf("vlements[%d].format = %s\n", i, pf_sprint_name(buf, velements[i].src_format)); + } + } +#endif + pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer); pipe->set_vertex_elements(pipe, vp->num_inputs, velements); -- cgit v1.2.3 From 1828b6d0315be805ec1eea1594fae5b28cfb4ca8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 7 Jul 2008 10:12:55 -0600 Subject: gallium: move assertion (though not really significant) --- src/mesa/state_tracker/st_draw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 3291387929..a57d7b6a7a 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -302,7 +302,6 @@ st_draw_vbo(GLcontext *ctx, pipe_reference_buffer(pipe, &vbuffer[attr].buffer, stobj->buffer); vbuffer[attr].buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; velements[attr].src_offset = 0; - assert(velements[attr].src_offset <= 2048); /* 11-bit field */ } else { /* attribute data is in user-space memory, not a VBO */ @@ -323,6 +322,8 @@ st_draw_vbo(GLcontext *ctx, velements[attr].src_offset = 0; } + assert(velements[attr].src_offset <= 2048); /* 11-bit field */ + /* common-case setup */ vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ vbuffer[attr].max_index = max_index; -- cgit v1.2.3 From bae90edfdae0eac6c844ede21285453ef96a4f6e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 10 Jul 2008 14:23:27 -0600 Subject: gallium: check for FEATURE_feedback and FEATURE_drawpix when creating/using the aux draw module --- src/mesa/state_tracker/st_cb_program.c | 4 ++++ src/mesa/state_tracker/st_context.c | 4 ++++ src/mesa/state_tracker/st_draw.c | 2 ++ 3 files changed, 10 insertions(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 11ba5d56f3..ea0fa20012 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -144,9 +144,11 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog) } if (stvp->draw_shader) { +#if FEATURE_feedback || FEATURE_drawpix /* this would only have been allocated for the RasterPos path */ draw_delete_vertex_shader(st->draw, stvp->draw_shader); stvp->draw_shader = NULL; +#endif } if (stvp->state.tokens) { @@ -232,9 +234,11 @@ static void st_program_string_notify( GLcontext *ctx, } if (stvp->draw_shader) { +#if FEATURE_feedback || FEATURE_drawpix /* this would only have been allocated for the RasterPos path */ draw_delete_vertex_shader(st->draw, stvp->draw_shader); stvp->draw_shader = NULL; +#endif } if (stvp->state.tokens) { diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index bf78cacb8e..8b30e35684 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -98,6 +98,7 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) /* state tracker needs the VBO module */ _vbo_CreateContext(ctx); +#if FEATURE_feedback || FEATURE_drawpix st->draw = draw_create(); /* for selection/feedback */ /* Disable draw options that might convert points/lines to tris, etc. @@ -107,6 +108,7 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) draw_wide_point_threshold(st->draw, 1000.0f); draw_enable_line_stipple(st->draw, FALSE); draw_enable_point_sprites(st->draw, FALSE); +#endif st->dirty.mesa = ~0; st->dirty.st = ~0; @@ -164,7 +166,9 @@ static void st_destroy_context_priv( struct st_context *st ) { uint i; +#if FEATURE_feedback || FEATURE_drawpix draw_destroy(st->draw); +#endif st_destroy_atoms( st ); st_destroy_draw( st ); st_destroy_generate_mipmap(st); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index a57d7b6a7a..30c2bdb723 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -447,6 +447,7 @@ st_draw_vbo(GLcontext *ctx, } +#if FEATURE_feedback || FEATURE_drawpix /** * Set the (private) draw module's post-transformed vertex format when in @@ -657,6 +658,7 @@ st_feedback_draw_vbo(GLcontext *ctx, } } +#endif /* FEATURE_feedback || FEATURE_drawpix */ void st_init_draw( struct st_context *st ) -- cgit v1.2.3 From 1ffd6908d4153d647f8a3bf1ba9fe9d33c206185 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 7 Aug 2008 19:25:54 +0100 Subject: mesa: pf_sprint_name->pf_name. --- src/mesa/state_tracker/st_draw.c | 3 +-- src/mesa/state_tracker/st_format.c | 9 +-------- 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 30c2bdb723..cc3d7450a9 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -339,7 +339,6 @@ st_draw_vbo(GLcontext *ctx, #if 0 { GLuint i; - char buf[100]; for (i = 0; i < vp->num_inputs; i++) { printf("buffers[%d].pitch = %u\n", i, vbuffer[i].pitch); printf("buffers[%d].max_index = %u\n", i, vbuffer[i].max_index); @@ -350,7 +349,7 @@ st_draw_vbo(GLcontext *ctx, printf("vlements[%d].src_offset = %u\n", i, velements[i].src_offset); printf("vlements[%d].vbuffer_index = %u\n", i, velements[i].vertex_buffer_index); printf("vlements[%d].nr_comps = %u\n", i, velements[i].nr_components); - printf("vlements[%d].format = %s\n", i, pf_sprint_name(buf, velements[i].src_format)); + printf("vlements[%d].format = %s\n", i, pf_name(velements[i].src_format)); } } #endif diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index b6d97ef659..2461f39622 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -91,14 +91,7 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo) info = format; #if 0 - { - char fmtname[256]; - - pf_sprint_name( fmtname, format ); - printf( - "%s\n", - fmtname ); - } + printf("%s\n", pf_name( format ) ); #endif /* Data type */ -- cgit v1.2.3 From 52a6b7e6da8cabf7104c17becb81dea26c44db18 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 15 Aug 2008 11:50:29 -0600 Subject: gallium: in st_draw_vbo() use ctx->Current.Attrib[] values when arrays are missing/null fixes potential segfaults when vertex arrays are missing --- src/mesa/state_tracker/st_draw.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index cc3d7450a9..e1bc108eae 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -289,6 +289,7 @@ st_draw_vbo(GLcontext *ctx, for (attr = 0; attr < vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; + GLsizei stride = arrays[mesaAttr]->StrideB; if (bufobj && bufobj->Name) { /* Attribute data is in a VBO. @@ -307,17 +308,27 @@ st_draw_vbo(GLcontext *ctx, /* attribute data is in user-space memory, not a VBO */ uint bytes; - if (!arrays[mesaAttr]->StrideB) { - bytes = arrays[mesaAttr]->Size - * _mesa_sizeof_type(arrays[mesaAttr]->Type); - } else { - bytes = arrays[mesaAttr]->StrideB * (max_index + 1); + /* wrap user data */ + if (arrays[mesaAttr]->Ptr) { + /* user's vertex array */ + if (arrays[mesaAttr]->StrideB) { + bytes = arrays[mesaAttr]->StrideB * (max_index + 1); + } + else { + bytes = arrays[mesaAttr]->Size + * _mesa_sizeof_type(arrays[mesaAttr]->Type); + } + vbuffer[attr].buffer = pipe_user_buffer_create(pipe, + (void *) arrays[mesaAttr]->Ptr, bytes); + } + else { + /* no array, use ctx->Current.Attrib[] value */ + bytes = sizeof(ctx->Current.Attrib[0]); + vbuffer[attr].buffer = pipe_user_buffer_create(pipe, + (void *) ctx->Current.Attrib[mesaAttr], bytes); + stride = 0; } - /* wrap user data */ - vbuffer[attr].buffer - = pipe_user_buffer_create(pipe, (void *) arrays[mesaAttr]->Ptr, - bytes); vbuffer[attr].buffer_offset = 0; velements[attr].src_offset = 0; } @@ -325,7 +336,7 @@ st_draw_vbo(GLcontext *ctx, assert(velements[attr].src_offset <= 2048); /* 11-bit field */ /* common-case setup */ - vbuffer[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ + vbuffer[attr].pitch = stride; /* in bytes */ vbuffer[attr].max_index = max_index; velements[attr].vertex_buffer_index = attr; velements[attr].nr_components = arrays[mesaAttr]->Size; -- cgit v1.2.3 From ce40bc2ae088ce6defac6b2bf424dcfd0e141a75 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Aug 2008 13:20:10 -0600 Subject: gallium: in st_draw_vbo() try to detect interleaved arrays in a single VBO. --- src/mesa/state_tracker/st_draw.c | 176 +++++++++++++++++++++++++++++++++------ 1 file changed, 149 insertions(+), 27 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index e1bc108eae..9db14171a0 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -252,36 +252,103 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, } +/** + * Examine the active arrays to determine if we have interleaved + * vertex arrays living in one VBO. + */ +static GLboolean +is_interleaved_arrays(const struct st_vertex_program *vp, + const struct gl_client_array **arrays) +{ + GLuint attr; + struct gl_buffer_object *firstBufObj = NULL; + GLint firstStride = -1; + + for (attr = 0; attr < vp->num_inputs; attr++) { + const GLuint mesaAttr = vp->index_to_input[attr]; + struct gl_buffer_object *bufObj = arrays[mesaAttr]->BufferObj; + GLsizei stride = arrays[mesaAttr]->StrideB; + + if (!bufObj || !bufObj->Name) + return GL_FALSE; + + if (!firstBufObj) { + firstBufObj = bufObj; + firstStride = stride; + } + else if (bufObj != firstBufObj || + stride != firstStride) { + return GL_FALSE; + } + } + return GL_TRUE; +} + /** - * This function gets plugged into the VBO module and is called when - * we have something to render. - * Basically, translate the information into the format expected by pipe. + * Set up for drawing interleaved arrays that all live in one VBO. */ -void -st_draw_vbo(GLcontext *ctx, - const struct gl_client_array **arrays, - const struct _mesa_prim *prims, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index) +static void +setup_interleaved_attribs(GLcontext *ctx, + const struct st_vertex_program *vp, + const struct gl_client_array **arrays, + GLuint max_index, + struct pipe_vertex_buffer *vbuffer, + struct pipe_vertex_element velements[]) { struct pipe_context *pipe = ctx->st->pipe; - const struct st_vertex_program *vp; - const struct pipe_shader_state *vs; - struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; + GLboolean buffer_init = GL_FALSE; GLuint attr; - struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; - /* sanity check for pointer arithmetic below */ - assert(sizeof(arrays[0]->Ptr[0]) == 1); + /* loop over TGSI shader inputs to determine vertex buffer + * and attribute info + */ + for (attr = 0; attr < vp->num_inputs; attr++) { + const GLuint mesaAttr = vp->index_to_input[attr]; + struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; + struct st_buffer_object *stobj = st_buffer_object(bufobj); + GLsizei stride = arrays[mesaAttr]->StrideB; - st_validate_state(ctx->st); + assert(stobj->buffer); - /* must get these after state validation! */ - vp = ctx->st->vp; - vs = &ctx->st->vp->state; + /*printf("stobj %u = %p\n", attr, (void*)stobj);*/ + + if (!buffer_init) { + vbuffer->buffer = NULL; + pipe_reference_buffer(pipe, &vbuffer->buffer, stobj->buffer); + vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; + vbuffer->pitch = stride; /* in bytes */ + vbuffer->max_index = max_index; + buffer_init = GL_TRUE; + } + + velements[attr].src_offset = + (unsigned) arrays[mesaAttr]->Ptr - vbuffer->buffer_offset; + velements[attr].vertex_buffer_index = 0; + velements[attr].nr_components = arrays[mesaAttr]->Size; + velements[attr].src_format + = pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size, + arrays[mesaAttr]->Normalized); + assert(velements[attr].src_format); + } +} + + +/** + * Set up a separate pipe_vertex_buffer and pipe_vertex_element for each + * vertex attribute. + */ +static void +setup_non_interleaved_attribs(GLcontext *ctx, + const struct st_vertex_program *vp, + const struct gl_client_array **arrays, + GLuint max_index, + struct pipe_vertex_buffer vbuffer[], + struct pipe_vertex_element velements[]) +{ + struct pipe_context *pipe = ctx->st->pipe; + GLuint attr; /* loop over TGSI shader inputs to determine vertex buffer * and attribute info @@ -298,6 +365,7 @@ st_draw_vbo(GLcontext *ctx, */ struct st_buffer_object *stobj = st_buffer_object(bufobj); assert(stobj->buffer); + /*printf("stobj %u = %p\n", attr, (void*) stobj);*/ vbuffer[attr].buffer = NULL; pipe_reference_buffer(pipe, &vbuffer[attr].buffer, stobj->buffer); @@ -307,6 +375,7 @@ st_draw_vbo(GLcontext *ctx, else { /* attribute data is in user-space memory, not a VBO */ uint bytes; + /*printf("user-space array %d\n", attr);*/ /* wrap user data */ if (arrays[mesaAttr]->Ptr) { @@ -346,27 +415,80 @@ st_draw_vbo(GLcontext *ctx, arrays[mesaAttr]->Normalized); assert(velements[attr].src_format); } +} + + + + +/** + * This function gets plugged into the VBO module and is called when + * we have something to render. + * Basically, translate the information into the format expected by pipe. + */ +void +st_draw_vbo(GLcontext *ctx, + const struct gl_client_array **arrays, + const struct _mesa_prim *prims, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLuint min_index, + GLuint max_index) +{ + struct pipe_context *pipe = ctx->st->pipe; + const struct st_vertex_program *vp; + const struct pipe_shader_state *vs; + struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; + GLuint attr; + struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; + unsigned num_vbuffers, num_velements; + + /* sanity check for pointer arithmetic below */ + assert(sizeof(arrays[0]->Ptr[0]) == 1); + + st_validate_state(ctx->st); + + /* must get these after state validation! */ + vp = ctx->st->vp; + vs = &ctx->st->vp->state; + + /* + * Setup the vbuffer[] and velements[] arrays. + */ + if (is_interleaved_arrays(vp, arrays)) { + /*printf("Draw interleaved\n");*/ + setup_interleaved_attribs(ctx, vp, arrays, max_index, + vbuffer, velements); + num_vbuffers = 1; + num_velements = vp->num_inputs; + } + else { + /*printf("Draw non-interleaved\n");*/ + setup_non_interleaved_attribs(ctx, vp, arrays, max_index, + vbuffer, velements); + num_vbuffers = vp->num_inputs; + num_velements = vp->num_inputs; + } #if 0 { GLuint i; - for (i = 0; i < vp->num_inputs; i++) { + for (i = 0; i < num_vbuffers; i++) { printf("buffers[%d].pitch = %u\n", i, vbuffer[i].pitch); printf("buffers[%d].max_index = %u\n", i, vbuffer[i].max_index); printf("buffers[%d].buffer_offset = %u\n", i, vbuffer[i].buffer_offset); printf("buffers[%d].buffer = %p\n", i, (void*) vbuffer[i].buffer); } - for (i = 0; i < vp->num_inputs; i++) { - printf("vlements[%d].src_offset = %u\n", i, velements[i].src_offset); + for (i = 0; i < num_velements; i++) { printf("vlements[%d].vbuffer_index = %u\n", i, velements[i].vertex_buffer_index); + printf("vlements[%d].src_offset = %u\n", i, velements[i].src_offset); printf("vlements[%d].nr_comps = %u\n", i, velements[i].nr_components); printf("vlements[%d].format = %s\n", i, pf_name(velements[i].src_format)); } } #endif - pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer); - pipe->set_vertex_elements(pipe, vp->num_inputs, velements); + pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer); + pipe->set_vertex_elements(pipe, num_velements, velements); /* do actual drawing */ if (ib) { @@ -449,7 +571,7 @@ st_draw_vbo(GLcontext *ctx, } /* unreference buffers (frees wrapped user-space buffer objects) */ - for (attr = 0; attr < vp->num_inputs; attr++) { + for (attr = 0; attr < num_vbuffers; attr++) { pipe_reference_buffer(pipe, &vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); } -- cgit v1.2.3 From ee402e5ce2d9203558bf066642becb952399c3e9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Aug 2008 14:42:50 -0600 Subject: gallium: better support for user-space interleaved arrays Basically, set up one user-space wrapper for all arrays instead of the individual arrays. --- src/mesa/state_tracker/st_draw.c | 135 +++++++++++++++++++++++++++++---------- 1 file changed, 100 insertions(+), 35 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 9db14171a0..2c80701186 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -32,6 +32,7 @@ #include "main/imports.h" #include "main/image.h" +#include "main/macros.h" #include "vbo/vbo.h" @@ -254,82 +255,146 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, /** * Examine the active arrays to determine if we have interleaved - * vertex arrays living in one VBO. + * vertex arrays all living in one VBO, or all living in user space. + * \param userSpace returns whether the arrays are in user space. */ static GLboolean is_interleaved_arrays(const struct st_vertex_program *vp, - const struct gl_client_array **arrays) + const struct gl_client_array **arrays, + GLboolean *userSpace) { GLuint attr; - struct gl_buffer_object *firstBufObj = NULL; + const struct gl_buffer_object *firstBufObj = NULL; GLint firstStride = -1; + GLuint num_client_arrays = 0; + const GLubyte *client_addr = NULL; for (attr = 0; attr < vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; - struct gl_buffer_object *bufObj = arrays[mesaAttr]->BufferObj; - GLsizei stride = arrays[mesaAttr]->StrideB; + const struct gl_buffer_object *bufObj = arrays[mesaAttr]->BufferObj; + const GLsizei stride = arrays[mesaAttr]->StrideB; /* in bytes */ - if (!bufObj || !bufObj->Name) + if (firstStride < 0) { + firstStride = stride; + } + else if (firstStride != stride) { return GL_FALSE; - - if (!firstBufObj) { + } + + if (!bufObj || !bufObj->Name) { + num_client_arrays++; + /* Try to detect if the client-space arrays are + * "close" to each other. + */ + if (!client_addr) { + client_addr = arrays[mesaAttr]->Ptr; + } + else if (abs(arrays[mesaAttr]->Ptr - client_addr) > firstStride) { + /* arrays start too far apart */ + return GL_FALSE; + } + } + else if (!firstBufObj) { firstBufObj = bufObj; - firstStride = stride; } - else if (bufObj != firstBufObj || - stride != firstStride) { + else if (bufObj != firstBufObj) { return GL_FALSE; } } + + *userSpace = (num_client_arrays == vp->num_inputs); + /*printf("user space: %d\n", (int) *userSpace);*/ + return GL_TRUE; } /** - * Set up for drawing interleaved arrays that all live in one VBO. + * Once we know all the arrays are in user space, this function + * computes the memory range occupied by the arrays. + */ +static void +get_user_arrays_bounds(const struct st_vertex_program *vp, + const struct gl_client_array **arrays, + GLuint max_index, + const GLubyte **low, const GLubyte **high) +{ + const GLubyte *low_addr = NULL; + GLuint attr; + GLint stride; + + for (attr = 0; attr < vp->num_inputs; attr++) { + const GLuint mesaAttr = vp->index_to_input[attr]; + const GLubyte *start = arrays[mesaAttr]->Ptr; + stride = arrays[mesaAttr]->StrideB; + if (attr == 0) { + low_addr = start; + } + else { + low_addr = MIN2(low_addr, start); + } + } + + *low = low_addr; + *high = low_addr + (max_index + 1) * stride; +} + + +/** + * Set up for drawing interleaved arrays that all live in one VBO + * or all live in user space. + * \param vbuffer returns vertex buffer info + * \param velements returns vertex element info */ static void setup_interleaved_attribs(GLcontext *ctx, const struct st_vertex_program *vp, const struct gl_client_array **arrays, GLuint max_index, + GLboolean userSpace, struct pipe_vertex_buffer *vbuffer, struct pipe_vertex_element velements[]) { struct pipe_context *pipe = ctx->st->pipe; - GLboolean buffer_init = GL_FALSE; GLuint attr; + const GLubyte *offset0; - /* loop over TGSI shader inputs to determine vertex buffer - * and attribute info - */ for (attr = 0; attr < vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; struct st_buffer_object *stobj = st_buffer_object(bufobj); GLsizei stride = arrays[mesaAttr]->StrideB; - assert(stobj->buffer); - /*printf("stobj %u = %p\n", attr, (void*)stobj);*/ - if (!buffer_init) { - vbuffer->buffer = NULL; - pipe_reference_buffer(pipe, &vbuffer->buffer, stobj->buffer); - vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; + if (attr == 0) { + if (userSpace) { + const GLubyte *low, *high; + get_user_arrays_bounds(vp, arrays, max_index, &low, &high); + /*printf("user buffer range: %p %p %d\n", low, high, high-low);*/ + vbuffer->buffer = + pipe_user_buffer_create(pipe, (void *) low, high - low); + vbuffer->buffer_offset = 0; + offset0 = low; + } + else { + vbuffer->buffer = NULL; + pipe_reference_buffer(pipe, &vbuffer->buffer, stobj->buffer); + vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; + offset0 = arrays[mesaAttr]->Ptr; + } vbuffer->pitch = stride; /* in bytes */ vbuffer->max_index = max_index; - buffer_init = GL_TRUE; } velements[attr].src_offset = - (unsigned) arrays[mesaAttr]->Ptr - vbuffer->buffer_offset; + (unsigned) (arrays[mesaAttr]->Ptr - offset0); velements[attr].vertex_buffer_index = 0; velements[attr].nr_components = arrays[mesaAttr]->Size; - velements[attr].src_format - = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size, - arrays[mesaAttr]->Normalized); + velements[attr].src_format = + pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size, + arrays[mesaAttr]->Normalized); assert(velements[attr].src_format); } } @@ -338,6 +403,8 @@ setup_interleaved_attribs(GLcontext *ctx, /** * Set up a separate pipe_vertex_buffer and pipe_vertex_element for each * vertex attribute. + * \param vbuffer returns vertex buffer info + * \param velements returns vertex element info */ static void setup_non_interleaved_attribs(GLcontext *ctx, @@ -350,9 +417,6 @@ setup_non_interleaved_attribs(GLcontext *ctx, struct pipe_context *pipe = ctx->st->pipe; GLuint attr; - /* loop over TGSI shader inputs to determine vertex buffer - * and attribute info - */ for (attr = 0; attr < vp->num_inputs; attr++) { const GLuint mesaAttr = vp->index_to_input[attr]; struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; @@ -375,7 +439,7 @@ setup_non_interleaved_attribs(GLcontext *ctx, else { /* attribute data is in user-space memory, not a VBO */ uint bytes; - /*printf("user-space array %d\n", attr);*/ + /*printf("user-space array %d stride %d\n", attr, stride);*/ /* wrap user data */ if (arrays[mesaAttr]->Ptr) { @@ -423,7 +487,7 @@ setup_non_interleaved_attribs(GLcontext *ctx, /** * This function gets plugged into the VBO module and is called when * we have something to render. - * Basically, translate the information into the format expected by pipe. + * Basically, translate the information into the format expected by gallium. */ void st_draw_vbo(GLcontext *ctx, @@ -441,6 +505,7 @@ st_draw_vbo(GLcontext *ctx, GLuint attr; struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; unsigned num_vbuffers, num_velements; + GLboolean userSpace; /* sanity check for pointer arithmetic below */ assert(sizeof(arrays[0]->Ptr[0]) == 1); @@ -454,9 +519,9 @@ st_draw_vbo(GLcontext *ctx, /* * Setup the vbuffer[] and velements[] arrays. */ - if (is_interleaved_arrays(vp, arrays)) { + if (is_interleaved_arrays(vp, arrays, &userSpace)) { /*printf("Draw interleaved\n");*/ - setup_interleaved_attribs(ctx, vp, arrays, max_index, + setup_interleaved_attribs(ctx, vp, arrays, max_index, userSpace, vbuffer, velements); num_vbuffers = 1; num_velements = vp->num_inputs; -- cgit v1.2.3 From f637a96e85a51a66f2c53b91118a6815bb61d6e6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Sep 2008 11:48:05 +0900 Subject: gallium: Have pipe_buffer_* receive a pipe_screen instead of a pipe_context. We want to use the pipe_buffer_* inlines everywhere, but a pipe context is not always available nor is it needed. --- src/gallium/auxiliary/util/u_draw_quad.c | 2 +- src/gallium/drivers/cell/ppu/cell_state_shader.c | 2 +- src/gallium/drivers/cell/ppu/cell_texture.c | 4 +-- src/gallium/drivers/i915simple/i915_prim_vbuf.c | 2 +- src/gallium/drivers/i915simple/i915_texture.c | 8 ++--- src/gallium/drivers/i965simple/brw_state_pool.c | 2 +- src/gallium/drivers/i965simple/brw_tex_layout.c | 4 +-- src/gallium/drivers/softpipe/sp_context.c | 2 +- src/gallium/drivers/softpipe/sp_state_fs.c | 2 +- src/gallium/drivers/softpipe/sp_texture.c | 6 ++-- src/gallium/include/pipe/p_inlines.h | 28 +++++++-------- src/gallium/state_trackers/python/p_context.i | 2 +- src/gallium/state_trackers/python/st_device.c | 2 +- .../state_trackers/python/st_softpipe_winsys.c | 2 +- src/gallium/winsys/drm/intel/dri/intel_screen.c | 2 +- src/gallium/winsys/egl_xlib/sw_winsys.c | 2 +- src/gallium/winsys/gdi/wmesa.c | 2 +- src/gallium/winsys/xlib/xm_winsys.c | 2 +- src/gallium/winsys/xlib/xm_winsys_aub.c | 2 +- src/mesa/state_tracker/st_atom_constbuf.c | 8 ++--- src/mesa/state_tracker/st_cb_bitmap.c | 8 ++--- src/mesa/state_tracker/st_cb_bufferobjects.c | 18 +++++----- src/mesa/state_tracker/st_cb_clear.c | 8 ++--- src/mesa/state_tracker/st_cb_drawpixels.c | 8 ++--- src/mesa/state_tracker/st_context.c | 2 +- src/mesa/state_tracker/st_draw.c | 40 +++++++++++----------- src/mesa/state_tracker/st_gen_mipmap.c | 8 ++--- 27 files changed, 89 insertions(+), 89 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c index bf143815d8..d643ee9ab7 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.c +++ b/src/gallium/auxiliary/util/u_draw_quad.c @@ -127,6 +127,6 @@ util_draw_texquad(struct pipe_context *pipe, util_draw_vertex_buffer(pipe, vbuf, PIPE_PRIM_TRIANGLE_FAN, 4, 2); } - pipe_buffer_reference(pipe->winsys, &vbuf, NULL); + pipe_buffer_reference(pipe->screen, &vbuf, NULL); } } diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c index 86bcad05e9..3d1b887da9 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_shader.c +++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c @@ -166,7 +166,7 @@ cell_set_constant_buffer(struct pipe_context *pipe, assert(index == 0); /* note: reference counting */ - pipe_buffer_reference(ws, + winsys_buffer_reference(ws, &cell->constants[shader].buffer, buf->buffer); cell->constants[shader].size = buf->size; diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c index 5a0942bbd6..5c01aa21b8 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.c +++ b/src/gallium/drivers/cell/ppu/cell_texture.c @@ -130,7 +130,7 @@ cell_texture_release_screen(struct pipe_screen *screen, DBG("%s deleting %p\n", __FUNCTION__, (void *) spt); */ - pipe_buffer_reference(screen->winsys, &spt->buffer, NULL); + pipe_buffer_reference(screen, &spt->buffer, NULL); FREE(spt); } @@ -161,7 +161,7 @@ cell_get_tex_surface_screen(struct pipe_screen *screen, if (ps) { assert(ps->refcount); assert(ps->winsys); - pipe_buffer_reference(ws, &ps->buffer, spt->buffer); + winsys_buffer_reference(ws, &ps->buffer, spt->buffer); ps->format = pt->format; ps->block = pt->block; ps->width = pt->width[level]; diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c index e4ece55098..9397a2ca1a 100644 --- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c +++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c @@ -124,7 +124,7 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render, if (i915_render->vbo_size > size + i915_render->vbo_offset && !i915->vbo_flushed) { } else { i915->vbo_flushed = 0; - pipe_buffer_reference(winsys, &i915_render->vbo, NULL); + winsys_buffer_reference(winsys, &i915_render->vbo, NULL); } if (!i915_render->vbo) { diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c index a853a5a3f6..bd87217063 100644 --- a/src/gallium/drivers/i915simple/i915_texture.c +++ b/src/gallium/drivers/i915simple/i915_texture.c @@ -645,7 +645,7 @@ i915_texture_release(struct pipe_screen *screen, DBG("%s deleting %p\n", __FUNCTION__, (void *) tex); */ - pipe_buffer_reference(screen->winsys, &tex->buffer, NULL); + pipe_buffer_reference(screen, &tex->buffer, NULL); for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) if (tex->image_offset[i]) @@ -684,7 +684,7 @@ i915_get_tex_surface(struct pipe_screen *screen, ps->refcount = 1; ps->winsys = ws; pipe_texture_reference(&ps->texture, pt); - pipe_buffer_reference(ws, &ps->buffer, tex->buffer); + pipe_buffer_reference(screen, &ps->buffer, tex->buffer); ps->format = pt->format; ps->width = pt->width[level]; ps->height = pt->height[level]; @@ -728,7 +728,7 @@ i915_texture_blanket(struct pipe_screen * screen, i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1); i915_miptree_set_image_offset(tex, 0, 0, 0, 0); - pipe_buffer_reference(screen->winsys, &tex->buffer, buffer); + pipe_buffer_reference(screen, &tex->buffer, buffer); return &tex->base; } @@ -756,7 +756,7 @@ i915_tex_surface_release(struct pipe_screen *screen, } pipe_texture_reference(&surf->texture, NULL); - pipe_buffer_reference(screen->winsys, &surf->buffer, NULL); + pipe_buffer_reference(screen, &surf->buffer, NULL); FREE(surf); } diff --git a/src/gallium/drivers/i965simple/brw_state_pool.c b/src/gallium/drivers/i965simple/brw_state_pool.c index 78d4c0e411..d0dc1ef74d 100644 --- a/src/gallium/drivers/i965simple/brw_state_pool.c +++ b/src/gallium/drivers/i965simple/brw_state_pool.c @@ -103,7 +103,7 @@ static void brw_destroy_pool( struct brw_context *brw, { struct brw_mem_pool *pool = &brw->pool[pool_id]; - pipe_buffer_reference( pool->brw->pipe.winsys, + winsys_buffer_reference( pool->brw->pipe.winsys, &pool->buffer, NULL ); } diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.c b/src/gallium/drivers/i965simple/brw_tex_layout.c index 05eda9d1f2..cc0c665e02 100644 --- a/src/gallium/drivers/i965simple/brw_tex_layout.c +++ b/src/gallium/drivers/i965simple/brw_tex_layout.c @@ -330,7 +330,7 @@ brw_texture_release_screen(struct pipe_screen *screen, DBG("%s deleting %p\n", __FUNCTION__, (void *) tex); */ - pipe_buffer_reference(ws, &tex->buffer, NULL); + winsys_buffer_reference(ws, &tex->buffer, NULL); for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) if (tex->image_offset[i]) @@ -369,7 +369,7 @@ brw_get_tex_surface_screen(struct pipe_screen *screen, if (ps) { assert(ps->format); assert(ps->refcount); - pipe_buffer_reference(ws, &ps->buffer, tex->buffer); + winsys_buffer_reference(ws, &ps->buffer, tex->buffer); ps->format = pt->format; ps->width = pt->width[level]; ps->height = pt->height[level]; diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index dda90f760a..6f12390cf7 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -113,7 +113,7 @@ static void softpipe_destroy( struct pipe_context *pipe ) for (i = 0; i < Elements(softpipe->constants); i++) { if (softpipe->constants[i].buffer) { - pipe_buffer_reference(ws, &softpipe->constants[i].buffer, NULL); + winsys_buffer_reference(ws, &softpipe->constants[i].buffer, NULL); } } diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index 1be461b3a4..e5b609cf6c 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -152,7 +152,7 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, assert(index == 0); /* note: reference counting */ - pipe_buffer_reference(ws, + winsys_buffer_reference(ws, &softpipe->constants[shader].buffer, buf ? buf->buffer : NULL); softpipe->constants[shader].size = buf ? buf->size : 0; diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 3a737d6f72..c283e3e410 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -192,7 +192,7 @@ softpipe_texture_blanket(struct pipe_screen * screen, spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]); spt->stride[0] = stride[0]; - pipe_buffer_reference(screen->winsys, &spt->buffer, buffer); + pipe_buffer_reference(screen, &spt->buffer, buffer); return &spt->base; } @@ -208,7 +208,7 @@ softpipe_texture_release(struct pipe_screen *screen, if (--(*pt)->refcount <= 0) { struct softpipe_texture *spt = softpipe_texture(*pt); - pipe_buffer_reference(screen->winsys, &spt->buffer, NULL); + pipe_buffer_reference(screen, &spt->buffer, NULL); FREE(spt); } *pt = NULL; @@ -231,7 +231,7 @@ softpipe_get_tex_surface(struct pipe_screen *screen, if (ps) { assert(ps->refcount); assert(ps->winsys); - pipe_buffer_reference(ws, &ps->buffer, spt->buffer); + pipe_buffer_reference(screen, &ps->buffer, spt->buffer); ps->format = pt->format; ps->block = pt->block; ps->width = pt->width[level]; diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h index 1e4b98edb4..d70de8e301 100644 --- a/src/gallium/include/pipe/p_inlines.h +++ b/src/gallium/include/pipe/p_inlines.h @@ -109,7 +109,7 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf) /* XXX: thread safety issues! */ static INLINE void -pipe_buffer_reference(struct pipe_winsys *winsys, +winsys_buffer_reference(struct pipe_winsys *winsys, struct pipe_buffer **ptr, struct pipe_buffer *buf) { @@ -164,48 +164,48 @@ pipe_texture_release(struct pipe_texture **ptr) */ static INLINE struct pipe_buffer * -pipe_buffer_create( struct pipe_context *pipe, +pipe_buffer_create( struct pipe_screen *screen, unsigned alignment, unsigned usage, unsigned size ) { - return pipe->winsys->buffer_create(pipe->winsys, alignment, usage, size); + return screen->winsys->buffer_create(screen->winsys, alignment, usage, size); } static INLINE struct pipe_buffer * -pipe_user_buffer_create( struct pipe_context *pipe, void *ptr, unsigned size ) +pipe_user_buffer_create( struct pipe_screen *screen, void *ptr, unsigned size ) { - return pipe->winsys->user_buffer_create(pipe->winsys, ptr, size); + return screen->winsys->user_buffer_create(screen->winsys, ptr, size); } static INLINE void -pipe_buffer_destroy( struct pipe_context *pipe, struct pipe_buffer *buf ) +pipe_buffer_destroy( struct pipe_screen *screen, struct pipe_buffer *buf ) { - pipe->winsys->buffer_destroy(pipe->winsys, buf); + screen->winsys->buffer_destroy(screen->winsys, buf); } static INLINE void * -pipe_buffer_map(struct pipe_context *pipe, +pipe_buffer_map(struct pipe_screen *screen, struct pipe_buffer *buf, unsigned usage) { - return pipe->winsys->buffer_map(pipe->winsys, buf, usage); + return screen->winsys->buffer_map(screen->winsys, buf, usage); } static INLINE void -pipe_buffer_unmap(struct pipe_context *pipe, +pipe_buffer_unmap(struct pipe_screen *screen, struct pipe_buffer *buf) { - pipe->winsys->buffer_unmap(pipe->winsys, buf); + screen->winsys->buffer_unmap(screen->winsys, buf); } /* XXX when we're using this everywhere, get rid of - * pipe_buffer_reference() above. + * winsys_buffer_reference() above. */ static INLINE void -pipe_reference_buffer(struct pipe_context *pipe, +pipe_buffer_reference(struct pipe_screen *screen, struct pipe_buffer **ptr, struct pipe_buffer *buf) { - pipe_buffer_reference(pipe->winsys, ptr, buf); + winsys_buffer_reference(screen->winsys, ptr, buf); } diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 0b2621f7c3..231e07cd63 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -248,7 +248,7 @@ struct st_context { util_draw_vertex_buffer(pipe, vbuf, prim, num_verts, num_attribs); error2: - pipe_buffer_reference(pipe->winsys, &vbuf, NULL); + pipe_buffer_reference(pipe->screen, &vbuf, NULL); error1: ; } diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index f71d85dd9b..bd71755f0b 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -293,7 +293,7 @@ st_buffer_destroy(struct st_buffer *st_buf) { if(st_buf) { struct pipe_winsys *winsys = st_buf->st_dev->screen->winsys; - pipe_buffer_reference(winsys, &st_buf->buffer, NULL); + pipe_buffer_reference(pipe->screen, &st_buf->buffer, NULL); FREE(st_buf); } } diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c index 2d4f5434b3..f62113a469 100644 --- a/src/gallium/state_trackers/python/st_softpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c @@ -221,7 +221,7 @@ st_softpipe_surface_release(struct pipe_winsys *winsys, surf->refcount--; if (surf->refcount == 0) { if (surf->buffer) - pipe_buffer_reference(winsys, &surf->buffer, NULL); + winsys_buffer_reference(winsys, &surf->buffer, NULL); free(surf); } *s = NULL; diff --git a/src/gallium/winsys/drm/intel/dri/intel_screen.c b/src/gallium/winsys/drm/intel/dri/intel_screen.c index 46d4861e77..3a486481f5 100644 --- a/src/gallium/winsys/drm/intel/dri/intel_screen.c +++ b/src/gallium/winsys/drm/intel/dri/intel_screen.c @@ -83,7 +83,7 @@ intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys, buffer); /* Unref the buffer we don't need it anyways */ - pipe_buffer_reference(screen->winsys, &buffer, NULL); + pipe_buffer_reference(screen, &buffer, NULL); surface = screen->get_tex_surface(screen, texture, diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.c b/src/gallium/winsys/egl_xlib/sw_winsys.c index ae81d7f801..2fd190da52 100644 --- a/src/gallium/winsys/egl_xlib/sw_winsys.c +++ b/src/gallium/winsys/egl_xlib/sw_winsys.c @@ -216,7 +216,7 @@ surface_release(struct pipe_winsys *winsys, struct pipe_surface **s) surf->refcount--; if (surf->refcount == 0) { if (surf->buffer) - pipe_buffer_reference(winsys, &surf->buffer, NULL); + winsys_buffer_reference(winsys, &surf->buffer, NULL); free(surf); } *s = NULL; diff --git a/src/gallium/winsys/gdi/wmesa.c b/src/gallium/winsys/gdi/wmesa.c index 730fb1b541..ed3dd2b927 100644 --- a/src/gallium/winsys/gdi/wmesa.c +++ b/src/gallium/winsys/gdi/wmesa.c @@ -463,7 +463,7 @@ wm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s) surf->refcount--; if (surf->refcount == 0) { if (surf->buffer) - pipe_buffer_reference(winsys, &surf->buffer, NULL); + winsys_buffer_reference(winsys, &surf->buffer, NULL); free(surf); } *s = NULL; diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xm_winsys.c index 68ead7f528..70f01e0ef8 100644 --- a/src/gallium/winsys/xlib/xm_winsys.c +++ b/src/gallium/winsys/xlib/xm_winsys.c @@ -543,7 +543,7 @@ xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s) surf->refcount--; if (surf->refcount == 0) { if (surf->buffer) - pipe_buffer_reference(winsys, &surf->buffer, NULL); + winsys_buffer_reference(winsys, &surf->buffer, NULL); free(surf); } *s = NULL; diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.c b/src/gallium/winsys/xlib/xm_winsys_aub.c index 35c4ebc4ba..b7c10b6bca 100644 --- a/src/gallium/winsys/xlib/xm_winsys_aub.c +++ b/src/gallium/winsys/xlib/xm_winsys_aub.c @@ -308,7 +308,7 @@ aub_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s) surf->refcount--; if (surf->refcount == 0) { if (surf->buffer) - pipe_buffer_reference(winsys, &surf->buffer, NULL); + winsys_buffer_reference(winsys, &surf->buffer, NULL); free(surf); } *s = NULL; diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index d3aadf5074..d02e51cb9a 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -73,8 +73,8 @@ void st_upload_constants( struct st_context *st, /* We always need to get a new buffer, to keep the drivers simple and * avoid gratuitous rendering synchronization. */ - pipe_reference_buffer(pipe, &cbuf->buffer, NULL ); - cbuf->buffer = pipe_buffer_create(pipe, 16, PIPE_BUFFER_USAGE_CONSTANT, + pipe_buffer_reference(pipe->screen, &cbuf->buffer, NULL ); + cbuf->buffer = pipe_buffer_create(pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT, paramBytes ); if (0) @@ -86,10 +86,10 @@ void st_upload_constants( struct st_context *st, /* load Mesa constants into the constant buffer */ if (cbuf->buffer) { - void *map = pipe_buffer_map(pipe, cbuf->buffer, + void *map = pipe_buffer_map(pipe->screen, cbuf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(map, params->ParameterValues, paramBytes); - pipe_buffer_unmap(pipe, cbuf->buffer); + pipe_buffer_unmap(pipe->screen, cbuf->buffer); } cbuf->size = paramBytes; diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index a0c305d66f..694104f9cf 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -378,7 +378,7 @@ setup_bitmap_vertex_data(struct st_context *st, void *buf; if (!st->bitmap.vbuf) { - st->bitmap.vbuf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX, + st->bitmap.vbuf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX, sizeof(st->bitmap.vertices)); } @@ -418,9 +418,9 @@ setup_bitmap_vertex_data(struct st_context *st, } /* put vertex data into vbuf */ - buf = pipe_buffer_map(pipe, st->bitmap.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE); + buf = pipe_buffer_map(pipe->screen, st->bitmap.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(buf, st->bitmap.vertices, sizeof(st->bitmap.vertices)); - pipe_buffer_unmap(pipe, st->bitmap.vbuf); + pipe_buffer_unmap(pipe->screen, st->bitmap.vbuf); } @@ -779,7 +779,7 @@ st_destroy_bitmap(struct st_context *st) } if (st->bitmap.vbuf) { - pipe_buffer_destroy(pipe, st->bitmap.vbuf); + pipe_buffer_destroy(pipe->screen, st->bitmap.vbuf); st->bitmap.vbuf = NULL; } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index af79aefa96..07fa2afce0 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -78,7 +78,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_reference_buffer(pipe, &st_obj->buffer, NULL); + pipe_buffer_reference(pipe->screen, &st_obj->buffer, NULL); free(st_obj); } @@ -105,9 +105,9 @@ st_bufferobj_subdata(GLcontext *ctx, if (offset >= st_obj->size || size > (st_obj->size - offset)) return; - map = pipe_buffer_map(pipe, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); + map = pipe_buffer_map(pipe->screen, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(map + offset, data, size); - pipe_buffer_unmap(pipe, st_obj->buffer); + pipe_buffer_unmap(pipe->screen, st_obj->buffer); } @@ -128,9 +128,9 @@ st_bufferobj_get_subdata(GLcontext *ctx, if (offset >= st_obj->size || size > (st_obj->size - offset)) return; - map = pipe_buffer_map(pipe, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pipe->screen, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_READ); memcpy(data, map + offset, size); - pipe_buffer_unmap(pipe, st_obj->buffer); + pipe_buffer_unmap(pipe->screen, st_obj->buffer); } @@ -171,9 +171,9 @@ st_bufferobj_data(GLcontext *ctx, buffer_usage = 0; } - pipe_reference_buffer( pipe, &st_obj->buffer, NULL ); + pipe_buffer_reference( pipe->screen, &st_obj->buffer, NULL ); - st_obj->buffer = pipe_buffer_create( pipe, 32, buffer_usage, size ); + st_obj->buffer = pipe_buffer_create( pipe->screen, 32, buffer_usage, size ); st_obj->size = size; @@ -207,7 +207,7 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access, break; } - obj->Pointer = pipe_buffer_map(pipe, st_obj->buffer, flags); + obj->Pointer = pipe_buffer_map(pipe->screen, st_obj->buffer, flags); return obj->Pointer; } @@ -221,7 +221,7 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj) struct pipe_context *pipe = st_context(ctx)->pipe; struct st_buffer_object *st_obj = st_buffer_object(obj); - pipe_buffer_unmap(pipe, st_obj->buffer); + pipe_buffer_unmap(pipe->screen, st_obj->buffer); obj->Pointer = NULL; return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index e475f022d3..013b9a9c9c 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -116,7 +116,7 @@ st_destroy_clear(struct st_context *st) st->clear.vs = NULL; } if (st->clear.vbuf) { - pipe_buffer_destroy(pipe, st->clear.vbuf); + pipe_buffer_destroy(pipe->screen, st->clear.vbuf); st->clear.vbuf = NULL; } } @@ -152,7 +152,7 @@ draw_quad(GLcontext *ctx, void *buf; if (!st->clear.vbuf) { - st->clear.vbuf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX, + st->clear.vbuf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX, sizeof(st->clear.vertices)); } @@ -180,9 +180,9 @@ draw_quad(GLcontext *ctx, } /* put vertex data into vbuf */ - buf = pipe_buffer_map(pipe, st->clear.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE); + buf = pipe_buffer_map(pipe->screen, st->clear.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(buf, st->clear.vertices, sizeof(st->clear.vertices)); - pipe_buffer_unmap(pipe, st->clear.vbuf); + pipe_buffer_unmap(pipe->screen, st->clear.vbuf); /* draw */ util_draw_vertex_buffer(pipe, st->clear.vbuf, diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 4ec7c752df..00bbcae32a 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -487,17 +487,17 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, ubyte *map; /* allocate/load buffer object with vertex data */ - buf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX, + buf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX, sizeof(verts)); - map = pipe_buffer_map(pipe, buf, PIPE_BUFFER_USAGE_CPU_WRITE); + map = pipe_buffer_map(pipe->screen, buf, PIPE_BUFFER_USAGE_CPU_WRITE); memcpy(map, verts, sizeof(verts)); - pipe_buffer_unmap(pipe, buf); + pipe_buffer_unmap(pipe->screen, buf); util_draw_vertex_buffer(pipe, buf, PIPE_PRIM_QUADS, 4, /* verts */ 3); /* attribs/vert */ - pipe_buffer_reference(pipe->winsys, &buf, NULL); + pipe_buffer_reference(pipe->screen, &buf, NULL); } } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 83b0be06da..08d4db7f7f 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -196,7 +196,7 @@ static void st_destroy_context_priv( struct st_context *st ) for (i = 0; i < Elements(st->state.constants); i++) { if (st->state.constants[i].buffer) { - pipe_reference_buffer(st->pipe, &st->state.constants[i].buffer, NULL); + pipe_buffer_reference(st->pipe->screen, &st->state.constants[i].buffer, NULL); } } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 2c80701186..bdf8648ef7 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -229,7 +229,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, if (!vec) return NULL; - map = pipe_buffer_map(pipe, stobj->buffer, PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pipe->screen, stobj->buffer, PIPE_BUFFER_USAGE_CPU_READ); map = ADD_POINTERS(map, array->Ptr); for (i = 0; i < count; i++) { @@ -239,7 +239,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, map += array->StrideB; } - pipe_buffer_unmap(pipe, stobj->buffer); + pipe_buffer_unmap(pipe->screen, stobj->buffer); pipe->set_edgeflags(pipe, vec); @@ -373,13 +373,13 @@ setup_interleaved_attribs(GLcontext *ctx, get_user_arrays_bounds(vp, arrays, max_index, &low, &high); /*printf("user buffer range: %p %p %d\n", low, high, high-low);*/ vbuffer->buffer = - pipe_user_buffer_create(pipe, (void *) low, high - low); + pipe_user_buffer_create(pipe->screen, (void *) low, high - low); vbuffer->buffer_offset = 0; offset0 = low; } else { vbuffer->buffer = NULL; - pipe_reference_buffer(pipe, &vbuffer->buffer, stobj->buffer); + pipe_buffer_reference(pipe->screen, &vbuffer->buffer, stobj->buffer); vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; offset0 = arrays[mesaAttr]->Ptr; } @@ -432,7 +432,7 @@ setup_non_interleaved_attribs(GLcontext *ctx, /*printf("stobj %u = %p\n", attr, (void*) stobj);*/ vbuffer[attr].buffer = NULL; - pipe_reference_buffer(pipe, &vbuffer[attr].buffer, stobj->buffer); + pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, stobj->buffer); vbuffer[attr].buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; velements[attr].src_offset = 0; } @@ -451,13 +451,13 @@ setup_non_interleaved_attribs(GLcontext *ctx, bytes = arrays[mesaAttr]->Size * _mesa_sizeof_type(arrays[mesaAttr]->Type); } - vbuffer[attr].buffer = pipe_user_buffer_create(pipe, + vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr, bytes); } else { /* no array, use ctx->Current.Attrib[] value */ bytes = sizeof(ctx->Current.Attrib[0]); - vbuffer[attr].buffer = pipe_user_buffer_create(pipe, + vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen, (void *) ctx->Current.Attrib[mesaAttr], bytes); stride = 0; } @@ -581,12 +581,12 @@ st_draw_vbo(GLcontext *ctx, if (bufobj && bufobj->Name) { /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); - pipe_reference_buffer(pipe, &indexBuf, stobj->buffer); + pipe_buffer_reference(pipe->screen, &indexBuf, stobj->buffer); indexOffset = (unsigned) ib->ptr / indexSize; } else { /* element/indicies are in user space memory */ - indexBuf = pipe_user_buffer_create(pipe, (void *) ib->ptr, + indexBuf = pipe_user_buffer_create(pipe->screen, (void *) ib->ptr, ib->count * indexSize); indexOffset = 0; } @@ -621,7 +621,7 @@ st_draw_vbo(GLcontext *ctx, } } - pipe_reference_buffer(pipe, &indexBuf, NULL); + pipe_buffer_reference(pipe->screen, &indexBuf, NULL); } else { /* non-indexed */ @@ -637,7 +637,7 @@ st_draw_vbo(GLcontext *ctx, /* unreference buffers (frees wrapped user-space buffer objects) */ for (attr = 0; attr < num_vbuffers; attr++) { - pipe_reference_buffer(pipe, &vbuffer[attr].buffer, NULL); + pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); } pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer); @@ -750,7 +750,7 @@ st_feedback_draw_vbo(GLcontext *ctx, assert(stobj->buffer); vbuffers[attr].buffer = NULL; - pipe_reference_buffer(pipe, &vbuffers[attr].buffer, stobj->buffer); + pipe_buffer_reference(pipe->screen, &vbuffers[attr].buffer, stobj->buffer); vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; } @@ -762,7 +762,7 @@ st_feedback_draw_vbo(GLcontext *ctx, /* wrap user data */ vbuffers[attr].buffer - = pipe_user_buffer_create(pipe, (void *) arrays[mesaAttr]->Ptr, + = pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr, bytes); vbuffers[attr].buffer_offset = 0; velements[attr].src_offset = 0; @@ -784,7 +784,7 @@ st_feedback_draw_vbo(GLcontext *ctx, #endif /* map the attrib buffer */ - map = pipe_buffer_map(pipe, vbuffers[attr].buffer, + map = pipe_buffer_map(pipe->screen, vbuffers[attr].buffer, PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, attr, map); } @@ -812,7 +812,7 @@ st_feedback_draw_vbo(GLcontext *ctx, return; } - map = pipe_buffer_map(pipe, index_buffer_handle, + map = pipe_buffer_map(pipe->screen, index_buffer_handle, PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer(draw, indexSize, map); } @@ -823,7 +823,7 @@ st_feedback_draw_vbo(GLcontext *ctx, /* map constant buffers */ - mapped_constants = pipe_buffer_map(pipe, + mapped_constants = pipe_buffer_map(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX].buffer, PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_constant_buffer(st->draw, mapped_constants, @@ -837,20 +837,20 @@ st_feedback_draw_vbo(GLcontext *ctx, /* unmap constant buffers */ - pipe_buffer_unmap(pipe, st->state.constants[PIPE_SHADER_VERTEX].buffer); + pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX].buffer); /* * unmap vertex/index buffers */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (draw->pt.vertex_buffer[i].buffer) { - pipe_buffer_unmap(pipe, draw->pt.vertex_buffer[i].buffer); - pipe_reference_buffer(pipe, &draw->pt.vertex_buffer[i].buffer, NULL); + pipe_buffer_unmap(pipe->screen, draw->pt.vertex_buffer[i].buffer); + pipe_buffer_reference(pipe->screen, &draw->pt.vertex_buffer[i].buffer, NULL); draw_set_mapped_vertex_buffer(draw, i, NULL); } } if (ib) { - pipe_buffer_unmap(pipe, index_buffer_handle); + pipe_buffer_unmap(pipe->screen, index_buffer_handle); draw_set_mapped_element_buffer(draw, 0, NULL); } } diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 6db9bc0dd5..b9d114b1c9 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -128,10 +128,10 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice, PIPE_BUFFER_USAGE_CPU_WRITE); - srcData = (ubyte *) pipe_buffer_map(pipe, srcSurf->buffer, + srcData = (ubyte *) pipe_buffer_map(pipe->screen, srcSurf->buffer, PIPE_BUFFER_USAGE_CPU_READ) + srcSurf->offset; - dstData = (ubyte *) pipe_buffer_map(pipe, dstSurf->buffer, + dstData = (ubyte *) pipe_buffer_map(pipe->screen, dstSurf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE) + dstSurf->offset; @@ -144,8 +144,8 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, dstSurf->stride, /* stride in bytes */ dstData); - pipe_buffer_unmap(pipe, srcSurf->buffer); - pipe_buffer_unmap(pipe, dstSurf->buffer); + pipe_buffer_unmap(pipe->screen, srcSurf->buffer); + pipe_buffer_unmap(pipe->screen, dstSurf->buffer); pipe_surface_reference(&srcSurf, NULL); pipe_surface_reference(&dstSurf, NULL); -- cgit v1.2.3 From 4f1dafaa82985bf0f04a16ba2ba2d1e8ccf83724 Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Tue, 7 Oct 2008 21:28:38 +0200 Subject: Mesa: fix the case where there are no vertex attributes. This is a backport of 8e8208d6db8b764568539784a6473d545dec2265 to gallium-0.1 --- src/mesa/state_tracker/st_draw.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index bdf8648ef7..61949a9388 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -525,6 +525,8 @@ st_draw_vbo(GLcontext *ctx, vbuffer, velements); num_vbuffers = 1; num_velements = vp->num_inputs; + if (num_velements == 0) + num_vbuffers = 0; } else { /*printf("Draw non-interleaved\n");*/ -- cgit v1.2.3 From 6282c38283ea81af1d950dbc1f82a6950e8350ae Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 5 Nov 2008 14:05:04 -0700 Subject: gallium: if VERBOSE_GLSL flag is set, check for non-initialized uniforms at draw time This will warn the user that the shader being run may be using uninitialized uniform variables. --- src/mesa/state_tracker/st_draw.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 61949a9388..ed3ae3e91a 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -33,6 +33,7 @@ #include "main/imports.h" #include "main/image.h" #include "main/macros.h" +#include "shader/prog_uniform.h" #include "vbo/vbo.h" @@ -483,6 +484,28 @@ setup_non_interleaved_attribs(GLcontext *ctx, +/** + * Prior to drawing, check that any uniforms referenced by the + * current shader have been set. If a uniform has not been set, + * issue a warning. + */ +static void +check_uniforms(GLcontext *ctx) +{ + const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram; + if (shProg && shProg->LinkStatus) { + GLuint i; + for (i = 0; i < shProg->Uniforms->NumUniforms; i++) { + const struct gl_uniform *u = &shProg->Uniforms->Uniforms[i]; + if (!u->Initialized) { + _mesa_warning(ctx, + "Using shader with uninitialized uniform: %s", + u->Name); + } + } + } +} + /** * This function gets plugged into the VBO module and is called when @@ -516,6 +539,10 @@ st_draw_vbo(GLcontext *ctx, vp = ctx->st->vp; vs = &ctx->st->vp->state; + if (MESA_VERBOSE & VERBOSE_GLSL) { + check_uniforms(ctx); + } + /* * Setup the vbuffer[] and velements[] arrays. */ -- cgit v1.2.3 From de14fdd63f26a2e6fc55fad92c08966f269601a6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 5 Nov 2008 14:05:42 -0700 Subject: gallium: added check for degenerate drawing calls --- src/mesa/state_tracker/st_draw.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index ed3ae3e91a..7cf06da43c 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -584,6 +584,9 @@ st_draw_vbo(GLcontext *ctx, pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer); pipe->set_vertex_elements(pipe, num_velements, velements); + if (num_vbuffers == 0 || num_velements == 0) + return; + /* do actual drawing */ if (ib) { /* indexed primitive */ -- cgit v1.2.3 From eb4dded5be60af4c7d45394aaa0aca24549ec3d8 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Sun, 9 Nov 2008 01:02:10 +0200 Subject: Mesa: fix number of buffers in st_draw_vbo(). The clean-up call to pipe->set_vertex_buffers() should use the same number of buffers as the first call. Signed-off-by: Pekka Paalanen --- src/mesa/state_tracker/st_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 7cf06da43c..4bc734bad3 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -672,7 +672,7 @@ st_draw_vbo(GLcontext *ctx, pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); } - pipe->set_vertex_buffers(pipe, vp->num_inputs, vbuffer); + pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer); } -- cgit v1.2.3 From 8627a14ec872c532ac7660abfaf1a2db9b8608bb Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Dec 2008 15:42:28 +0000 Subject: st: move feedback draw function to new file --- src/mesa/sources.mak | 1 + src/mesa/state_tracker/st_draw.c | 234 +------------------------- src/mesa/state_tracker/st_draw.h | 5 + src/mesa/state_tracker/st_draw_feedback.c | 262 ++++++++++++++++++++++++++++++ 4 files changed, 276 insertions(+), 226 deletions(-) create mode 100644 src/mesa/state_tracker/st_draw_feedback.c (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index 14fd8597a8..9ebac8e1cd 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -201,6 +201,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_context.c \ state_tracker/st_debug.c \ state_tracker/st_draw.c \ + state_tracker/st_draw_feedback.c \ state_tracker/st_extensions.c \ state_tracker/st_format.c \ state_tracker/st_framebuffer.c \ diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 4bc734bad3..8f27076848 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -47,9 +47,6 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "draw/draw_private.h" -#include "draw/draw_context.h" - static GLuint double_types[4] = { PIPE_FORMAT_R64_FLOAT, @@ -161,8 +158,8 @@ static GLuint fixed_types[4] = { /** * Return a PIPE_FORMAT_x for the given GL datatype and size. */ -static GLuint -pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized) +GLuint +st_pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized) { assert((type >= GL_BYTE && type <= GL_DOUBLE) || type == GL_FIXED); @@ -393,9 +390,9 @@ setup_interleaved_attribs(GLcontext *ctx, velements[attr].vertex_buffer_index = 0; velements[attr].nr_components = arrays[mesaAttr]->Size; velements[attr].src_format = - pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size, - arrays[mesaAttr]->Normalized); + st_pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size, + arrays[mesaAttr]->Normalized); assert(velements[attr].src_format); } } @@ -475,9 +472,9 @@ setup_non_interleaved_attribs(GLcontext *ctx, velements[attr].vertex_buffer_index = attr; velements[attr].nr_components = arrays[mesaAttr]->Size; velements[attr].src_format - = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size, - arrays[mesaAttr]->Normalized); + = st_pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size, + arrays[mesaAttr]->Normalized); assert(velements[attr].src_format); } } @@ -675,221 +672,6 @@ st_draw_vbo(GLcontext *ctx, pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer); } - -#if FEATURE_feedback || FEATURE_drawpix - -/** - * Set the (private) draw module's post-transformed vertex format when in - * GL_SELECT or GL_FEEDBACK mode or for glRasterPos. - */ -static void -set_feedback_vertex_format(GLcontext *ctx) -{ -#if 0 - struct st_context *st = ctx->st; - struct vertex_info vinfo; - GLuint i; - - memset(&vinfo, 0, sizeof(vinfo)); - - if (ctx->RenderMode == GL_SELECT) { - assert(ctx->RenderMode == GL_SELECT); - vinfo.num_attribs = 1; - vinfo.format[0] = FORMAT_4F; - vinfo.interp_mode[0] = INTERP_LINEAR; - } - else { - /* GL_FEEDBACK, or glRasterPos */ - /* emit all attribs (pos, color, texcoord) as GLfloat[4] */ - vinfo.num_attribs = st->state.vs->cso->state.num_outputs; - for (i = 0; i < vinfo.num_attribs; i++) { - vinfo.format[i] = FORMAT_4F; - vinfo.interp_mode[i] = INTERP_LINEAR; - } - } - - draw_set_vertex_info(st->draw, &vinfo); -#endif -} - - -/** - * Called by VBO to draw arrays when in selection or feedback mode and - * to implement glRasterPos. - * This is very much like the normal draw_vbo() function above. - * Look at code refactoring some day. - * Might move this into the failover module some day. - */ -void -st_feedback_draw_vbo(GLcontext *ctx, - const struct gl_client_array **arrays, - const struct _mesa_prim *prims, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index) -{ - struct st_context *st = ctx->st; - struct pipe_context *pipe = st->pipe; - struct draw_context *draw = st->draw; - const struct st_vertex_program *vp; - const struct pipe_shader_state *vs; - struct pipe_buffer *index_buffer_handle = 0; - struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS]; - struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; - GLuint attr, i; - ubyte *mapped_constants; - - assert(draw); - - st_validate_state(ctx->st); - - /* must get these after state validation! */ - vp = ctx->st->vp; - vs = &st->vp->state; - - if (!st->vp->draw_shader) { - st->vp->draw_shader = draw_create_vertex_shader(draw, vs); - } - - /* - * Set up the draw module's state. - * - * We'd like to do this less frequently, but the normal state-update - * code sends state updates to the pipe, not to our private draw module. - */ - 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); - draw_bind_vertex_shader(draw, st->vp->draw_shader); - set_feedback_vertex_format(ctx); - - /* loop over TGSI shader inputs to determine vertex buffer - * and attribute info - */ - for (attr = 0; attr < vp->num_inputs; attr++) { - const GLuint mesaAttr = vp->index_to_input[attr]; - struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; - void *map; - - if (bufobj && bufobj->Name) { - /* Attribute data is in a VBO. - * Recall that for VBOs, the gl_client_array->Ptr field is - * really an offset from the start of the VBO, not a pointer. - */ - struct st_buffer_object *stobj = st_buffer_object(bufobj); - assert(stobj->buffer); - - vbuffers[attr].buffer = NULL; - pipe_buffer_reference(pipe->screen, &vbuffers[attr].buffer, stobj->buffer); - vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ - velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; - } - else { - /* attribute data is in user-space memory, not a VBO */ - uint bytes = (arrays[mesaAttr]->Size - * _mesa_sizeof_type(arrays[mesaAttr]->Type) - * (max_index + 1)); - - /* wrap user data */ - vbuffers[attr].buffer - = pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr, - bytes); - vbuffers[attr].buffer_offset = 0; - velements[attr].src_offset = 0; - } - - /* common-case setup */ - vbuffers[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ - vbuffers[attr].max_index = max_index; - velements[attr].vertex_buffer_index = attr; - velements[attr].nr_components = arrays[mesaAttr]->Size; - velements[attr].src_format = pipe_vertex_format(arrays[mesaAttr]->Type, - arrays[mesaAttr]->Size, - arrays[mesaAttr]->Normalized); - assert(velements[attr].src_format); - - /* tell draw about this attribute */ -#if 0 - draw_set_vertex_buffer(draw, attr, &vbuffer[attr]); -#endif - - /* map the attrib buffer */ - map = pipe_buffer_map(pipe->screen, vbuffers[attr].buffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_vertex_buffer(draw, attr, map); - } - - draw_set_vertex_buffers(draw, vp->num_inputs, vbuffers); - draw_set_vertex_elements(draw, vp->num_inputs, velements); - - if (ib) { - unsigned indexSize; - struct gl_buffer_object *bufobj = ib->obj; - struct st_buffer_object *stobj = st_buffer_object(bufobj); - void *map; - - index_buffer_handle = stobj->buffer; - - switch (ib->type) { - case GL_UNSIGNED_INT: - indexSize = 4; - break; - case GL_UNSIGNED_SHORT: - indexSize = 2; - break; - default: - assert(0); - return; - } - - map = pipe_buffer_map(pipe->screen, index_buffer_handle, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_element_buffer(draw, indexSize, map); - } - else { - /* no index/element buffer */ - draw_set_mapped_element_buffer(draw, 0, NULL); - } - - - /* map constant buffers */ - mapped_constants = pipe_buffer_map(pipe->screen, - st->state.constants[PIPE_SHADER_VERTEX].buffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_constant_buffer(st->draw, mapped_constants, - st->state.constants[PIPE_SHADER_VERTEX].buffer->size); - - - /* draw here */ - for (i = 0; i < nr_prims; i++) { - draw_arrays(draw, prims[i].mode, prims[i].start, prims[i].count); - } - - - /* unmap constant buffers */ - pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX].buffer); - - /* - * unmap vertex/index buffers - */ - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - if (draw->pt.vertex_buffer[i].buffer) { - pipe_buffer_unmap(pipe->screen, draw->pt.vertex_buffer[i].buffer); - pipe_buffer_reference(pipe->screen, &draw->pt.vertex_buffer[i].buffer, NULL); - draw_set_mapped_vertex_buffer(draw, i, NULL); - } - } - if (ib) { - pipe_buffer_unmap(pipe->screen, index_buffer_handle); - draw_set_mapped_element_buffer(draw, 0, NULL); - } -} - -#endif /* FEATURE_feedback || FEATURE_drawpix */ - - void st_init_draw( struct st_context *st ) { GLcontext *ctx = st->ctx; diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index c81f2b25da..659c3ac834 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -59,4 +59,9 @@ st_feedback_draw_vbo(GLcontext *ctx, GLuint min_index, GLuint max_index); +/* Internal function: + */ +extern GLuint +st_pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized); + #endif diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c new file mode 100644 index 0000000000..834c3844c4 --- /dev/null +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -0,0 +1,262 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +#include "main/imports.h" +#include "main/image.h" +#include "main/macros.h" +#include "shader/prog_uniform.h" + +#include "vbo/vbo.h" + +#include "st_context.h" +#include "st_atom.h" +#include "st_cb_bufferobjects.h" +#include "st_draw.h" +#include "st_program.h" + +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_inlines.h" + +#include "draw/draw_private.h" +#include "draw/draw_context.h" + + +#if FEATURE_feedback || FEATURE_drawpix + +/** + * Set the (private) draw module's post-transformed vertex format when in + * GL_SELECT or GL_FEEDBACK mode or for glRasterPos. + */ +static void +set_feedback_vertex_format(GLcontext *ctx) +{ +#if 0 + struct st_context *st = ctx->st; + struct vertex_info vinfo; + GLuint i; + + memset(&vinfo, 0, sizeof(vinfo)); + + if (ctx->RenderMode == GL_SELECT) { + assert(ctx->RenderMode == GL_SELECT); + vinfo.num_attribs = 1; + vinfo.format[0] = FORMAT_4F; + vinfo.interp_mode[0] = INTERP_LINEAR; + } + else { + /* GL_FEEDBACK, or glRasterPos */ + /* emit all attribs (pos, color, texcoord) as GLfloat[4] */ + vinfo.num_attribs = st->state.vs->cso->state.num_outputs; + for (i = 0; i < vinfo.num_attribs; i++) { + vinfo.format[i] = FORMAT_4F; + vinfo.interp_mode[i] = INTERP_LINEAR; + } + } + + draw_set_vertex_info(st->draw, &vinfo); +#endif +} + + +/** + * Called by VBO to draw arrays when in selection or feedback mode and + * to implement glRasterPos. + * This is very much like the normal draw_vbo() function above. + * Look at code refactoring some day. + * Might move this into the failover module some day. + */ +void +st_feedback_draw_vbo(GLcontext *ctx, + const struct gl_client_array **arrays, + const struct _mesa_prim *prims, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLuint min_index, + GLuint max_index) +{ + struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; + struct draw_context *draw = st->draw; + const struct st_vertex_program *vp; + const struct pipe_shader_state *vs; + struct pipe_buffer *index_buffer_handle = 0; + struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS]; + struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; + GLuint attr, i; + ubyte *mapped_constants; + + assert(draw); + + st_validate_state(ctx->st); + + /* must get these after state validation! */ + vp = ctx->st->vp; + vs = &st->vp->state; + + if (!st->vp->draw_shader) { + st->vp->draw_shader = draw_create_vertex_shader(draw, vs); + } + + /* + * Set up the draw module's state. + * + * We'd like to do this less frequently, but the normal state-update + * code sends state updates to the pipe, not to our private draw module. + */ + 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); + draw_bind_vertex_shader(draw, st->vp->draw_shader); + set_feedback_vertex_format(ctx); + + /* loop over TGSI shader inputs to determine vertex buffer + * and attribute info + */ + for (attr = 0; attr < vp->num_inputs; attr++) { + const GLuint mesaAttr = vp->index_to_input[attr]; + struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; + void *map; + + if (bufobj && bufobj->Name) { + /* Attribute data is in a VBO. + * Recall that for VBOs, the gl_client_array->Ptr field is + * really an offset from the start of the VBO, not a pointer. + */ + struct st_buffer_object *stobj = st_buffer_object(bufobj); + assert(stobj->buffer); + + vbuffers[attr].buffer = NULL; + pipe_buffer_reference(pipe->screen, &vbuffers[attr].buffer, stobj->buffer); + vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */ + velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; + } + else { + /* attribute data is in user-space memory, not a VBO */ + uint bytes = (arrays[mesaAttr]->Size + * _mesa_sizeof_type(arrays[mesaAttr]->Type) + * (max_index + 1)); + + /* wrap user data */ + vbuffers[attr].buffer + = pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr, + bytes); + vbuffers[attr].buffer_offset = 0; + velements[attr].src_offset = 0; + } + + /* common-case setup */ + vbuffers[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ + vbuffers[attr].max_index = max_index; + velements[attr].vertex_buffer_index = attr; + velements[attr].nr_components = arrays[mesaAttr]->Size; + velements[attr].src_format = + st_pipe_vertex_format(arrays[mesaAttr]->Type, + arrays[mesaAttr]->Size, + arrays[mesaAttr]->Normalized); + assert(velements[attr].src_format); + + /* tell draw about this attribute */ +#if 0 + draw_set_vertex_buffer(draw, attr, &vbuffer[attr]); +#endif + + /* map the attrib buffer */ + map = pipe_buffer_map(pipe->screen, vbuffers[attr].buffer, + PIPE_BUFFER_USAGE_CPU_READ); + draw_set_mapped_vertex_buffer(draw, attr, map); + } + + draw_set_vertex_buffers(draw, vp->num_inputs, vbuffers); + draw_set_vertex_elements(draw, vp->num_inputs, velements); + + if (ib) { + unsigned indexSize; + struct gl_buffer_object *bufobj = ib->obj; + struct st_buffer_object *stobj = st_buffer_object(bufobj); + void *map; + + index_buffer_handle = stobj->buffer; + + switch (ib->type) { + case GL_UNSIGNED_INT: + indexSize = 4; + break; + case GL_UNSIGNED_SHORT: + indexSize = 2; + break; + default: + assert(0); + return; + } + + map = pipe_buffer_map(pipe->screen, index_buffer_handle, + PIPE_BUFFER_USAGE_CPU_READ); + draw_set_mapped_element_buffer(draw, indexSize, map); + } + else { + /* no index/element buffer */ + draw_set_mapped_element_buffer(draw, 0, NULL); + } + + + /* map constant buffers */ + mapped_constants = pipe_buffer_map(pipe->screen, + st->state.constants[PIPE_SHADER_VERTEX].buffer, + PIPE_BUFFER_USAGE_CPU_READ); + draw_set_mapped_constant_buffer(st->draw, mapped_constants, + st->state.constants[PIPE_SHADER_VERTEX].buffer->size); + + + /* draw here */ + for (i = 0; i < nr_prims; i++) { + draw_arrays(draw, prims[i].mode, prims[i].start, prims[i].count); + } + + + /* unmap constant buffers */ + pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX].buffer); + + /* + * unmap vertex/index buffers + */ + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { + if (draw->pt.vertex_buffer[i].buffer) { + pipe_buffer_unmap(pipe->screen, draw->pt.vertex_buffer[i].buffer); + pipe_buffer_reference(pipe->screen, &draw->pt.vertex_buffer[i].buffer, NULL); + draw_set_mapped_vertex_buffer(draw, i, NULL); + } + } + if (ib) { + pipe_buffer_unmap(pipe->screen, index_buffer_handle); + draw_set_mapped_element_buffer(draw, 0, NULL); + } +} + +#endif /* FEATURE_feedback || FEATURE_drawpix */ + -- cgit v1.2.3 From eb20e2984e51e632ef1a51620db7aca3eb89dafa Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Dec 2008 15:43:21 +0000 Subject: st: reduce unnecessary calls to pipe->set_vertex_buffers() --- src/mesa/state_tracker/st_draw.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 8f27076848..3229e93248 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -409,6 +409,7 @@ setup_non_interleaved_attribs(GLcontext *ctx, const struct st_vertex_program *vp, const struct gl_client_array **arrays, GLuint max_index, + GLboolean *userSpace, struct pipe_vertex_buffer vbuffer[], struct pipe_vertex_element velements[]) { @@ -420,6 +421,8 @@ setup_non_interleaved_attribs(GLcontext *ctx, struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; GLsizei stride = arrays[mesaAttr]->StrideB; + *userSpace = GL_FALSE; + if (bufobj && bufobj->Name) { /* Attribute data is in a VBO. * Recall that for VBOs, the gl_client_array->Ptr field is @@ -439,6 +442,8 @@ setup_non_interleaved_attribs(GLcontext *ctx, uint bytes; /*printf("user-space array %d stride %d\n", attr, stride);*/ + *userSpace = GL_TRUE; + /* wrap user data */ if (arrays[mesaAttr]->Ptr) { /* user's vertex array */ @@ -555,7 +560,7 @@ st_draw_vbo(GLcontext *ctx, else { /*printf("Draw non-interleaved\n");*/ setup_non_interleaved_attribs(ctx, vp, arrays, max_index, - vbuffer, velements); + &userSpace, vbuffer, velements); num_vbuffers = vp->num_inputs; num_velements = vp->num_inputs; } @@ -665,13 +670,17 @@ st_draw_vbo(GLcontext *ctx, } /* unreference buffers (frees wrapped user-space buffer objects) */ - for (attr = 0; attr < num_vbuffers; attr++) { - pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, NULL); - assert(!vbuffer[attr].buffer); + if (userSpace) + { + for (attr = 0; attr < num_vbuffers; attr++) { + pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, NULL); + assert(!vbuffer[attr].buffer); + } + pipe->set_vertex_buffers(pipe, 0, NULL); } - pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer); } + void st_init_draw( struct st_context *st ) { GLcontext *ctx = st->ctx; -- cgit v1.2.3 From 3a5d260cb1d2602b9fc32392f18538d0a6ff41c2 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 12 Dec 2008 18:34:49 +0000 Subject: gallium: fix refcount bug introduced in eb20e2984 --- src/mesa/state_tracker/st_draw.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 3229e93248..e78d98f1e9 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -670,12 +670,13 @@ st_draw_vbo(GLcontext *ctx, } /* unreference buffers (frees wrapped user-space buffer objects) */ + for (attr = 0; attr < num_vbuffers; attr++) { + pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, NULL); + assert(!vbuffer[attr].buffer); + } + if (userSpace) { - for (attr = 0; attr < num_vbuffers; attr++) { - pipe_buffer_reference(pipe->screen, &vbuffer[attr].buffer, NULL); - assert(!vbuffer[attr].buffer); - } pipe->set_vertex_buffers(pipe, 0, NULL); } } -- cgit v1.2.3 From c828adc3f614f518ba2ce328cad477d31e292290 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 12 Dec 2008 20:31:39 +0000 Subject: mesa: when we have interleaved arrays, check bounds for both VBO's and user space objects --- src/mesa/state_tracker/st_draw.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 4bc734bad3..887358be62 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -304,18 +304,17 @@ is_interleaved_arrays(const struct st_vertex_program *vp, } *userSpace = (num_client_arrays == vp->num_inputs); - /*printf("user space: %d\n", (int) *userSpace);*/ + /* printf("user space: %d (%d %d)\n", (int) *userSpace,num_client_arrays,vp->num_inputs); */ return GL_TRUE; } /** - * Once we know all the arrays are in user space, this function - * computes the memory range occupied by the arrays. + * Compute the memory range occupied by the arrays. */ static void -get_user_arrays_bounds(const struct st_vertex_program *vp, +get_arrays_bounds(const struct st_vertex_program *vp, const struct gl_client_array **arrays, GLuint max_index, const GLubyte **low, const GLubyte **high) @@ -365,24 +364,24 @@ setup_interleaved_attribs(GLcontext *ctx, struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; struct st_buffer_object *stobj = st_buffer_object(bufobj); GLsizei stride = arrays[mesaAttr]->StrideB; + const GLubyte *low, *high; /*printf("stobj %u = %p\n", attr, (void*)stobj);*/ if (attr == 0) { + get_arrays_bounds(vp, arrays, max_index, &low, &high); + /*printf("buffer range: %p %p %d\n", low, high, high-low);*/ + + offset0 = low; if (userSpace) { - const GLubyte *low, *high; - get_user_arrays_bounds(vp, arrays, max_index, &low, &high); - /*printf("user buffer range: %p %p %d\n", low, high, high-low);*/ vbuffer->buffer = pipe_user_buffer_create(pipe->screen, (void *) low, high - low); vbuffer->buffer_offset = 0; - offset0 = low; } else { vbuffer->buffer = NULL; pipe_buffer_reference(pipe->screen, &vbuffer->buffer, stobj->buffer); vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; - offset0 = arrays[mesaAttr]->Ptr; } vbuffer->pitch = stride; /* in bytes */ vbuffer->max_index = max_index; -- cgit v1.2.3 From a725a8e27a16fc2b38741ad28e43982a55431e0e Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 12 Dec 2008 20:37:21 +0000 Subject: mesa: move declaration --- src/mesa/state_tracker/st_draw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 887358be62..bac84a4dba 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -364,11 +364,12 @@ setup_interleaved_attribs(GLcontext *ctx, struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj; struct st_buffer_object *stobj = st_buffer_object(bufobj); GLsizei stride = arrays[mesaAttr]->StrideB; - const GLubyte *low, *high; /*printf("stobj %u = %p\n", attr, (void*)stobj);*/ if (attr == 0) { + const GLubyte *low, *high; + get_arrays_bounds(vp, arrays, max_index, &low, &high); /*printf("buffer range: %p %p %d\n", low, high, high-low);*/ -- cgit v1.2.3 From 872b515e8f0bb1be5bad85fd9d01529c71f07ba2 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 26 Jan 2009 13:45:45 -0500 Subject: gallium: standardize on stride instead of pitch in the interface --- src/gallium/auxiliary/draw/draw_pt.c | 6 +++--- src/gallium/auxiliary/draw/draw_pt_fetch.c | 4 ++-- src/gallium/auxiliary/draw/draw_pt_fetch_emit.c | 2 +- src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c | 4 ++-- src/gallium/auxiliary/util/u_draw_quad.c | 2 +- src/gallium/drivers/i965simple/brw_draw_upload.c | 2 +- src/gallium/drivers/nv30/nv30_vbo.c | 4 ++-- src/gallium/drivers/nv40/nv40_vbo.c | 4 ++-- src/gallium/drivers/nv50/nv50_vbo.c | 2 +- src/gallium/drivers/trace/tr_state.c | 4 ++-- src/gallium/include/pipe/p_screen.h | 2 +- src/gallium/include/pipe/p_state.h | 2 +- src/mesa/state_tracker/st_draw.c | 6 +++--- src/mesa/state_tracker/st_draw_feedback.c | 2 +- 14 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 18f24e5980..4e5ffa0930 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -228,7 +228,7 @@ draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count) for (j = 0; j < draw->pt.nr_vertex_elements; j++) { uint buf = draw->pt.vertex_element[j].vertex_buffer_index; ubyte *ptr = (ubyte *) draw->pt.user.vbuffer[buf]; - ptr += draw->pt.vertex_buffer[buf].pitch * ii; + ptr += draw->pt.vertex_buffer[buf].stride * ii; ptr += draw->pt.vertex_element[j].src_offset; debug_printf(" Attr %u: ", j); @@ -301,8 +301,8 @@ draw_arrays(struct draw_context *draw, unsigned prim, } debug_printf("Buffers:\n"); for (i = 0; i < draw->pt.nr_vertex_buffers; i++) { - debug_printf(" pitch=%u offset=%u ptr=%p\n", - draw->pt.vertex_buffer[i].pitch, + debug_printf(" stride=%u offset=%u ptr=%p\n", + draw->pt.vertex_buffer[i].stride, draw->pt.vertex_buffer[i].buffer_offset, draw->pt.user.vbuffer[i]); } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 6377f896fb..058caf7dcc 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -144,7 +144,7 @@ void draw_pt_fetch_run( struct pt_fetch *fetch, i, ((char *)draw->pt.user.vbuffer[i] + draw->pt.vertex_buffer[i].buffer_offset), - draw->pt.vertex_buffer[i].pitch ); + draw->pt.vertex_buffer[i].stride ); } translate->run_elts( translate, @@ -180,7 +180,7 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch, i, ((char *)draw->pt.user.vbuffer[i] + draw->pt.vertex_buffer[i].buffer_offset), - draw->pt.vertex_buffer[i].pitch ); + draw->pt.vertex_buffer[i].stride ); } translate->run( translate, diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index 0227652632..dcb7744b17 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -195,7 +195,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, i, ((char *)draw->pt.user.vbuffer[i] + draw->pt.vertex_buffer[i].buffer_offset), - draw->pt.vertex_buffer[i].pitch ); + draw->pt.vertex_buffer[i].stride ); } *max_vertices = (draw->render->max_vertex_buffer_bytes / diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c index 1649cdc6cd..84ffe3296a 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c @@ -121,7 +121,7 @@ static void fse_prepare( struct draw_pt_middle_end *middle, } for (i = 0; i < 5 && i < nr_vbs; i++) { - if (draw->pt.vertex_buffer[i].pitch == 0) + if (draw->pt.vertex_buffer[i].stride == 0) fse->key.const_vbuffers |= (1<pt.user.vbuffer[i] + draw->pt.vertex_buffer[i].buffer_offset), - draw->pt.vertex_buffer[i].pitch ); + draw->pt.vertex_buffer[i].stride ); } *max_vertices = (draw->render->max_vertex_buffer_bytes / diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c index d7bb74b87b..1af575530f 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.c +++ b/src/gallium/auxiliary/util/u_draw_quad.c @@ -53,7 +53,7 @@ util_draw_vertex_buffer(struct pipe_context *pipe, /* tell pipe about the vertex buffer */ vbuffer.buffer = vbuf; - vbuffer.pitch = num_attribs * 4 * sizeof(float); /* vertex size */ + vbuffer.stride = num_attribs * 4 * sizeof(float); /* vertex size */ vbuffer.buffer_offset = offset; pipe->set_vertex_buffers(pipe, 1, &vbuffer); diff --git a/src/gallium/drivers/i965simple/brw_draw_upload.c b/src/gallium/drivers/i965simple/brw_draw_upload.c index 7c20ea52af..2d9ca3f2ea 100644 --- a/src/gallium/drivers/i965simple/brw_draw_upload.c +++ b/src/gallium/drivers/i965simple/brw_draw_upload.c @@ -223,7 +223,7 @@ boolean brw_upload_vertex_buffers( struct brw_context *brw ) break; } - vbp.vb[i].vb0.bits.pitch = brw->vb.vbo_array[i]->pitch; + vbp.vb[i].vb0.bits.pitch = brw->vb.vbo_array[i]->stride; vbp.vb[i].vb0.bits.pad = 0; vbp.vb[i].vb0.bits.access_type = BRW_VERTEXBUFFER_ACCESS_VERTEXDATA; vbp.vb[i].vb0.bits.vb_index = i; diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c index 556f981d4a..2d6d48ac16 100644 --- a/src/gallium/drivers/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nv30/nv30_vbo.c @@ -503,7 +503,7 @@ nv30_vbo_validate(struct nv30_context *nv30) ve = &nv30->vtxelt[hw]; vb = &nv30->vtxbuf[ve->vertex_buffer_index]; - if (!vb->pitch) { + if (!vb->stride) { if (!sattr) sattr = so_new(16 * 5, 0); @@ -524,7 +524,7 @@ nv30_vbo_validate(struct nv30_context *nv30) so_reloc(vtxbuf, vb->buffer, vb->buffer_offset + ve->src_offset, vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR, 0, NV34TCL_VTXBUF_ADDRESS_DMA1); - so_data (vtxfmt, ((vb->pitch << NV34TCL_VTXFMT_STRIDE_SHIFT) | + so_data (vtxfmt, ((vb->stride << NV34TCL_VTXFMT_STRIDE_SHIFT) | (ncomp << NV34TCL_VTXFMT_SIZE_SHIFT) | type)); } diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c index 09f6e79d32..8f1834628f 100644 --- a/src/gallium/drivers/nv40/nv40_vbo.c +++ b/src/gallium/drivers/nv40/nv40_vbo.c @@ -501,7 +501,7 @@ nv40_vbo_validate(struct nv40_context *nv40) ve = &nv40->vtxelt[hw]; vb = &nv40->vtxbuf[ve->vertex_buffer_index]; - if (!vb->pitch) { + if (!vb->stride) { if (!sattr) sattr = so_new(16 * 5, 0); @@ -522,7 +522,7 @@ nv40_vbo_validate(struct nv40_context *nv40) so_reloc(vtxbuf, vb->buffer, vb->buffer_offset + ve->src_offset, vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR, 0, NV40TCL_VTXBUF_ADDRESS_DMA1); - so_data (vtxfmt, ((vb->pitch << NV40TCL_VTXFMT_STRIDE_SHIFT) | + so_data (vtxfmt, ((vb->stride << NV40TCL_VTXFMT_STRIDE_SHIFT) | (ncomp << NV40TCL_VTXFMT_SIZE_SHIFT) | type)); } diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 435dc9777d..c482a4c241 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -226,7 +226,7 @@ nv50_vbo_validate(struct nv50_context *nv50) } so_method(vtxbuf, tesla, 0x900 + (i * 16), 3); - so_data (vtxbuf, 0x20000000 | vb->pitch); + so_data (vtxbuf, 0x20000000 | vb->stride); so_reloc (vtxbuf, vb->buffer, vb->buffer_offset + ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c index 986d939e0c..546231612f 100644 --- a/src/gallium/drivers/trace/tr_state.c +++ b/src/gallium/drivers/trace/tr_state.c @@ -280,7 +280,7 @@ void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_ trace_dump_member(uint, &state->stencil[i], fail_op); trace_dump_member(uint, &state->stencil[i], zpass_op); trace_dump_member(uint, &state->stencil[i], zfail_op); - trace_dump_member(uint, &state->stencil[i], ref_value); + trace_dump_member(uint, &state->stencil[i], ref_value); trace_dump_member(uint, &state->stencil[i], value_mask); trace_dump_member(uint, &state->stencil[i], write_mask); trace_dump_struct_end(); @@ -435,7 +435,7 @@ void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state) trace_dump_struct_begin("pipe_vertex_buffer"); - trace_dump_member(uint, state, pitch); + trace_dump_member(uint, state, stride); trace_dump_member(uint, state, max_index); trace_dump_member(uint, state, buffer_offset); trace_dump_member(ptr, state, buffer); diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 3bedc75294..492667c93a 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -103,7 +103,7 @@ struct pipe_screen { */ struct pipe_texture * (*texture_blanket)(struct pipe_screen *, const struct pipe_texture *templat, - const unsigned *pitch, + const unsigned *stride, struct pipe_buffer *buffer); void (*texture_release)(struct pipe_screen *, diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index abe7cbe9e7..46f62abf3f 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -337,7 +337,7 @@ struct pipe_texture */ struct pipe_vertex_buffer { - unsigned pitch; /**< stride to same attrib in next vertex, in bytes */ + unsigned stride; /**< stride to same attrib in next vertex, in bytes */ unsigned max_index; /**< number of vertices in this buffer */ unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ struct pipe_buffer *buffer; /**< the actual buffer */ diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 31383b4887..630ad2bcdf 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -381,7 +381,7 @@ setup_interleaved_attribs(GLcontext *ctx, pipe_buffer_reference(pipe->screen, &vbuffer->buffer, stobj->buffer); vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; } - vbuffer->pitch = stride; /* in bytes */ + vbuffer->stride = stride; /* in bytes */ vbuffer->max_index = max_index; } @@ -472,7 +472,7 @@ setup_non_interleaved_attribs(GLcontext *ctx, assert(velements[attr].src_offset <= 2048); /* 11-bit field */ /* common-case setup */ - vbuffer[attr].pitch = stride; /* in bytes */ + vbuffer[attr].stride = stride; /* in bytes */ vbuffer[attr].max_index = max_index; velements[attr].vertex_buffer_index = attr; velements[attr].nr_components = arrays[mesaAttr]->Size; @@ -569,7 +569,7 @@ st_draw_vbo(GLcontext *ctx, { GLuint i; for (i = 0; i < num_vbuffers; i++) { - printf("buffers[%d].pitch = %u\n", i, vbuffer[i].pitch); + printf("buffers[%d].stride = %u\n", i, vbuffer[i].stride); printf("buffers[%d].max_index = %u\n", i, vbuffer[i].max_index); printf("buffers[%d].buffer_offset = %u\n", i, vbuffer[i].buffer_offset); printf("buffers[%d].buffer = %p\n", i, (void*) vbuffer[i].buffer); diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 834c3844c4..5c9c4506c2 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -171,7 +171,7 @@ st_feedback_draw_vbo(GLcontext *ctx, } /* common-case setup */ - vbuffers[attr].pitch = arrays[mesaAttr]->StrideB; /* in bytes */ + vbuffers[attr].stride = arrays[mesaAttr]->StrideB; /* in bytes */ vbuffers[attr].max_index = max_index; velements[attr].vertex_buffer_index = attr; velements[attr].nr_components = arrays[mesaAttr]->Size; -- cgit v1.2.3 From a47965588fdaa75166c48d50974b38fcbfd2a749 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 3 Feb 2009 20:07:42 +0000 Subject: mesa: fix offset problem with interleaved arrays --- src/mesa/state_tracker/st_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_draw.c') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 630ad2bcdf..942f913ea2 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -379,7 +379,7 @@ setup_interleaved_attribs(GLcontext *ctx, else { vbuffer->buffer = NULL; pipe_buffer_reference(pipe->screen, &vbuffer->buffer, stobj->buffer); - vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; + vbuffer->buffer_offset = (unsigned) low; } vbuffer->stride = stride; /* in bytes */ vbuffer->max_index = max_index; -- cgit v1.2.3