Some git wierdness going on.
#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
st_create_context( mesaCtx,
- generic_create() );
+ softpipe_create() );
return c;
}
#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"
/*
*
**************************************************************************/
-#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.
*/
* 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 * );
};
*
**************************************************************************/
-#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
*
**************************************************************************/
-#ifndef SP_STATE_H
-#define SP_STATE_H
+#ifndef PIPE_STATE_H
+#define PIPE_STATE_H
#include "mtypes.h"
#include "vf/vf.h"
#define FILL_LINE 2
#define FILL_TRI 3
-struct softpipe_setup_state {
+struct pipe_setup_state {
GLuint flatshade:1;
GLuint light_twoside:1;
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;
};
-#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? */
};
-struct softpipe_blend_state {
+struct pipe_blend_state {
GLuint blend_enable:1;
GLuint rgb_func:3;
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;
};
-/* This will change for hardware softpipes...
+/* This will change for hardware pipes...
*/
-struct softpipe_surface {
+struct pipe_surface {
GLubyte *ptr;
GLint stride;
GLuint cpp;
/**
* 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;
#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 */
};
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-#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);
- }
-}
-
-
-
-
-
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-#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
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-#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 );
-}
-
-
+++ /dev/null
-
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-#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
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-#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
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-#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
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-#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<<plane_idx);
-
- inlist[n] = inlist[0]; /* prevent rotation of vertices */
-
- for (i = 1; i <= n; i++) {
- struct vertex_header *vert = inlist[i];
-
- GLfloat dp = dot4( vert->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<<plane_idx);
-
- const GLfloat dp0 = dot4( pos0, plane );
- const GLfloat dp1 = dot4( pos1, plane );
-
- if (dp1 < 0) {
- GLfloat t = dp1 / (dp1 - dp0);
- if (t > 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<<nr)-1) & ~((1<<6)-1);
-
- stage->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;
-}
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-#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;
-}
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-#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;
-}
-
-
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-#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;
-}
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-#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;
-}
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-#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;
-}
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-#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;
-}
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-#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
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-#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;
-}
-
-
-
+++ /dev/null
-/**************************************************************************
- *
- * 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<<ATTR); \
-} while (0)
-
-
-static GLuint frag_to_vf[FRAG_ATTRIB_MAX] =
-{
- VF_ATTRIB_POS,
- VF_ATTRIB_COLOR0,
- VF_ATTRIB_COLOR1,
- VF_ATTRIB_FOG,
- VF_ATTRIB_TEX0,
- VF_ATTRIB_TEX1,
- VF_ATTRIB_TEX2,
- VF_ATTRIB_TEX3,
- VF_ATTRIB_TEX4,
- VF_ATTRIB_TEX5,
- VF_ATTRIB_TEX6,
- VF_ATTRIB_TEX7,
-};
-
-
-/* Derived from: fs, setup states.
- */
-static void calculate_vertex_layout( struct generic_context *generic )
-{
- struct gl_fragment_program *fp = generic->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;
-}
+++ /dev/null
-/**************************************************************************
- *
- * 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;
-}
-
-
-
-
-
-
-
-
-
+++ /dev/null
-/**************************************************************************
- *
- * 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;
-}
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-#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;
-}
-
-
+++ /dev/null
-/**************************************************************************
- *
- * 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,
-};
-
-
-
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-#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
+++ /dev/null
-/**************************************************************************
- *
- * 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 <keith@tungstengraphics.com>
- */
-#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
+++ /dev/null
-/*
- * 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 );
-}
-
-
-
-
-
-
-
+++ /dev/null
-/*
- * 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<<i)) {
- for (j = 0; j < 4; j++) {
- dest[j][i] = src[j][i];
- }
- }
- }
-}
-
-
-/* Write to the output, taking mask into account.
- *
- * Note that surfaces support only full quad reads and writes.
- */
-void quad_output( struct generic_context *generic,
- struct quad_header *quad )
-{
-
- if (quad->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 );
- }
-}
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
$(VBO_SOURCES) \
$(VF_SOURCES) \
$(SOFTPIPE_SOURCES) \
+ $(STATETRACKER_SOURCES) \
$(TNL_SOURCES) \
$(SHADER_SOURCES) \
$(SWRAST_SOURCES) \
#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
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);
/**
- * 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;
static void
update_blend( struct st_context *st )
{
- struct softpipe_blend_state blend;
+ struct pipe_blend_state blend;
memset(&blend, 0, sizeof(blend));
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 */
}
}
*/
#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,
*/
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,
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 );
}
}
#include "st_context.h"
-#include "softpipe/sp_context.h"
+#include "pipe/p_context.h"
#include "st_atom.h"
*/
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],
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);
}
}
#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;
static void
update_depth( struct st_context *st )
{
- struct softpipe_depth_state depth;
+ struct pipe_depth_state depth;
memset(&depth, 0, sizeof(depth));
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 */
}
}
*/
#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);
}
}
#include "st_context.h"
-#include "softpipe/sp_context.h"
+#include "pipe/p_context.h"
#include "st_atom.h"
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;
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 */
}
}
#include "st_context.h"
-#include "softpipe/sp_context.h"
+#include "pipe/p_context.h"
#include "st_atom.h"
static GLuint translate_fill( GLenum 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));
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 );
}
}
#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;
/**
- * 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;
static void
update_stencil( struct st_context *st )
{
- struct softpipe_stencil_state stencil;
+ struct pipe_stencil_state stencil;
memset(&stencil, 0, sizeof(stencil));
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 */
}
}
#include "context.h"
#include "colormac.h"
#include "st_context.h"
-#include "softpipe/sp_context.h"
+#include "pipe/p_context.h"
#include "st_atom.h"
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;
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);
}
}
}
#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)
{
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;
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 );
}
#define ST_CONTEXT_H
#include "mtypes.h"
-#include "softpipe/sp_state.h"
+#include "pipe/p_state.h"
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 {
#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.
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
*/
&_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,
};
#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 );