From: Brian Date: Fri, 17 Aug 2007 00:11:55 +0000 (-0600) Subject: Remove many dependencies on mesa headers. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3fc926f3740da9ec27853d158243055f3cb43d43;p=mesa.git Remove many dependencies on mesa headers. To build with mesa, need -DMESA in makefile/config file. --- diff --git a/configs/linux b/configs/linux index 0d455ff46a5..ed90fe4bc2c 100644 --- a/configs/linux +++ b/configs/linux @@ -18,7 +18,8 @@ ARCH_FLAGS ?= DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \ -D_BSD_SOURCE -D_GNU_SOURCE \ - -DPTHREADS -DUSE_XSHM -DHAVE_POSIX_MEMALIGN + -DPTHREADS -DUSE_XSHM -DHAVE_POSIX_MEMALIGN \ + -DMESA X11_INCLUDES = -I/usr/X11R6/include diff --git a/configs/linux-dri-debug b/configs/linux-dri-debug index c3a458459d8..a7ce255e009 100644 --- a/configs/linux-dri-debug +++ b/configs/linux-dri-debug @@ -5,7 +5,7 @@ include $(TOP)/configs/linux-dri CONFIG_NAME = linux-dri-debug OPT_FLAGS = -O0 -g -ARCH_FLAGS = -DDEBUG +ARCH_FLAGS = -DDEBUG -DMESA # Helpful to reduce the amount of stuff that gets built sometimes: #DRI_DIRS = i915tex i915 diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c index f8bacf8a818..53a7b10f7de 100644 --- a/src/mesa/pipe/draw/draw_clip.c +++ b/src/mesa/pipe/draw/draw_clip.c @@ -32,15 +32,27 @@ */ -#include "main/macros.h" +#include "pipe/p_util.h" #include "draw_private.h" +#ifndef IS_NEGATIVE +#define IS_NEGATIVE(X) ((X) < 0.0) +#endif + +#ifndef DIFFERENT_SIGNS +#define DIFFERENT_SIGNS(x, y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F) +#endif + +#ifndef MAX_CLIPPED_VERTICES +#define MAX_CLIPPED_VERTICES ((2 * (6 + PIPE_MAX_CLIP_PLANES))+1) +#endif + struct clipper { struct draw_stage stage; /**< base class */ - GLuint active_user_planes; - GLfloat (*plane)[4]; + unsigned active_user_planes; + float (*plane)[4]; }; @@ -57,10 +69,10 @@ static INLINE struct clipper *clipper_stage( struct draw_stage *stage ) /* All attributes are float[4], so this is easy: */ -static void interp_attr( GLfloat *fdst, - GLfloat t, - const GLfloat *fin, - const GLfloat *fout ) +static void interp_attr( float *fdst, + float t, + const float *fin, + const float *fout ) { fdst[0] = LINTERP( t, fout[0], fin[0] ); fdst[1] = LINTERP( t, fout[1], fin[1] ); @@ -75,12 +87,12 @@ static void interp_attr( GLfloat *fdst, */ static void interp( const struct clipper *clip, struct vertex_header *dst, - GLfloat t, + float t, const struct vertex_header *out, const struct vertex_header *in ) { - const GLuint nr_attrs = clip->stage.draw->nr_attrs; - GLuint j; + const unsigned nr_attrs = clip->stage.draw->nr_attrs; + unsigned j; /* Vertex header. */ @@ -99,10 +111,10 @@ static void interp( const struct clipper *clip, /* Do the projective divide and insert window coordinates: */ { - const GLfloat *pos = dst->clip; - const GLfloat *scale = clip->stage.draw->viewport.scale; - const GLfloat *trans = clip->stage.draw->viewport.translate; - const GLfloat oow = 1.0 / pos[3]; + const float *pos = dst->clip; + const float *scale = clip->stage.draw->viewport.scale; + const float *trans = clip->stage.draw->viewport.translate; + const float oow = 1.0 / pos[3]; dst->data[0][0] = pos[0] * oow * scale[0] + trans[0]; dst->data[0][1] = pos[1] * oow * scale[1] + trans[1]; @@ -128,10 +140,10 @@ static void interp( const struct clipper *clip, #define CLIP_CULL_BIT 0x80 -static INLINE GLfloat dot4( const GLfloat *a, - const GLfloat *b ) +static INLINE float dot4( const float *a, + const float *b ) { - GLfloat result = (a[0]*b[0] + + float result = (a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3]); @@ -144,9 +156,9 @@ static INLINE GLfloat dot4( const GLfloat *a, static INLINE void do_tri( struct draw_stage *next, struct prim_header *header ) { - GLuint i; + unsigned i; for (i = 0; i < 3; i++) { - GLfloat *ndc = header->v[i]->data[0]; + float *ndc = header->v[i]->data[0]; _mesa_printf("ndc %f %f %f\n", ndc[0], ndc[1], ndc[2]); assert(ndc[0] >= -1 && ndc[0] <= 641); assert(ndc[1] >= 30 && ndc[1] <= 481); @@ -159,10 +171,10 @@ static INLINE void do_tri( struct draw_stage *next, static void emit_poly( struct draw_stage *stage, struct vertex_header **inlist, - GLuint n ) + unsigned n ) { struct prim_header header; - GLuint i; + unsigned i; for (i = 2; i < n; i++) { header.v[0] = inlist[0]; @@ -170,8 +182,8 @@ static void emit_poly( struct draw_stage *stage, header.v[2] = inlist[i]; { - GLuint tmp0 = header.v[0]->edgeflag; - GLuint tmp2 = header.v[2]->edgeflag; + unsigned tmp0 = header.v[0]->edgeflag; + unsigned tmp2 = header.v[2]->edgeflag; if (i != 2) header.v[0]->edgeflag = 0; if (i != n-1) header.v[2]->edgeflag = 0; @@ -188,7 +200,7 @@ static void emit_poly( struct draw_stage *stage, #if 0 static void emit_poly( struct draw_stage *stage ) { - GLuint i; + unsigned i; for (i = 2; i < n; i++) { header->v[0] = inlist[0]; @@ -206,16 +218,16 @@ static void emit_poly( struct draw_stage *stage ) static void do_clip_tri( struct draw_stage *stage, struct prim_header *header, - GLuint clipmask ) + unsigned clipmask ) { struct clipper *clipper = clipper_stage( stage ); struct vertex_header *a[MAX_CLIPPED_VERTICES]; struct vertex_header *b[MAX_CLIPPED_VERTICES]; struct vertex_header **inlist = a; struct vertex_header **outlist = b; - GLuint tmpnr = 0; - GLuint n = 3; - GLuint i; + unsigned tmpnr = 0; + unsigned n = 3; + unsigned i; inlist[0] = header->v[0]; inlist[1] = header->v[1]; @@ -231,11 +243,11 @@ do_clip_tri( struct draw_stage *stage, } while (clipmask && n >= 3) { - GLuint plane_idx = ffs(clipmask)-1; - const GLfloat *plane = clipper->plane[plane_idx]; + unsigned plane_idx = ffs(clipmask)-1; + const float *plane = clipper->plane[plane_idx]; struct vertex_header *vert_prev = inlist[0]; - GLfloat dp_prev = dot4( vert_prev->clip, plane ); - GLuint outcount = 0; + float dp_prev = dot4( vert_prev->clip, plane ); + unsigned outcount = 0; clipmask &= ~(1<clip, plane ); + float dp = dot4( vert->clip, plane ); if (!IS_NEGATIVE(dp_prev)) { outlist[outcount++] = vert_prev; @@ -258,7 +270,7 @@ do_clip_tri( struct draw_stage *stage, /* Going out of bounds. Avoid division by zero as we * know dp != dp_prev from DIFFERENT_SIGNS, above. */ - GLfloat t = dp / (dp - dp_prev); + float t = dp / (dp - dp_prev); interp( clipper, new_vert, t, vert, vert_prev ); /* Force edgeflag true in this case: @@ -267,7 +279,7 @@ do_clip_tri( struct draw_stage *stage, } else { /* Coming back in. */ - GLfloat t = dp_prev / (dp_prev - dp); + float t = dp_prev / (dp_prev - dp); interp( clipper, new_vert, t, vert_prev, vert ); /* Copy starting vert's edgeflag: @@ -300,15 +312,15 @@ do_clip_tri( struct draw_stage *stage, static void do_clip_line( struct draw_stage *stage, struct prim_header *header, - GLuint clipmask ) + unsigned clipmask ) { const struct clipper *clipper = clipper_stage( stage ); struct vertex_header *v0 = header->v[0]; struct vertex_header *v1 = header->v[1]; - const GLfloat *pos0 = v0->clip; - const GLfloat *pos1 = v1->clip; - GLfloat t0 = 0; - GLfloat t1 = 0; + const float *pos0 = v0->clip; + const float *pos1 = v1->clip; + float t0 = 0; + float t1 = 0; struct prim_header newprim; /* XXX: Note stupid hack to deal with tnl's 8-bit clipmask. Remove @@ -321,18 +333,18 @@ do_clip_line( struct draw_stage *stage, } while (clipmask) { - const GLuint plane_idx = ffs(clipmask)-1; - const GLfloat *plane = clipper->plane[plane_idx]; - const GLfloat dp0 = dot4( pos0, plane ); - const GLfloat dp1 = dot4( pos1, plane ); + const unsigned plane_idx = ffs(clipmask)-1; + const float *plane = clipper->plane[plane_idx]; + const float dp0 = dot4( pos0, plane ); + const float dp1 = dot4( pos1, plane ); if (dp1 < 0) { - GLfloat t = dp1 / (dp1 - dp0); + float t = dp1 / (dp1 - dp0); t1 = MAX2(t1, t); } if (dp0 < 0) { - GLfloat t = dp0 / (dp0 - dp1); + float t = dp0 / (dp0 - dp1); t0 = MAX2(t0, t); } @@ -365,7 +377,7 @@ do_clip_line( struct draw_stage *stage, static void clip_begin( struct draw_stage *stage ) { struct clipper *clipper = clipper_stage(stage); - GLuint nr = stage->draw->nr_planes; + unsigned nr = stage->draw->nr_planes; /* sanity checks. If these fail, review the clip/interp code! */ assert(stage->draw->nr_attrs >= 3); @@ -393,7 +405,7 @@ static void clip_line( struct draw_stage *stage, struct prim_header *header ) { - GLuint clipmask = (header->v[0]->clipmask | + unsigned clipmask = (header->v[0]->clipmask | header->v[1]->clipmask); if (clipmask == 0) { @@ -411,7 +423,7 @@ static void clip_tri( struct draw_stage *stage, struct prim_header *header ) { - GLuint clipmask = (header->v[0]->clipmask | + unsigned clipmask = (header->v[0]->clipmask | header->v[1]->clipmask | header->v[2]->clipmask); diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index f2ee6c52e07..7e6a95127af 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -30,13 +30,15 @@ * Keith Whitwell */ -#include "imports.h" -#include "macros.h" +#ifdef MESA +#include "main/macros.h" +#else +#include "pipe/p_util.h" +#endif #include "draw_context.h" #include "draw_private.h" - struct draw_context *draw_create( void ) { struct draw_context *draw = CALLOC_STRUCT( draw_context ); @@ -57,7 +59,9 @@ struct draw_context *draw_create( void ) ASSIGN_4V( draw->plane[5], 0, 0, -1, 1 ); /* mesa's a bit wonky */ draw->nr_planes = 6; +#ifdef MESA draw->vf = vf_create( GL_TRUE ); +#endif /* Statically allocate maximum sized vertices for the cache - could be cleverer... */ @@ -75,10 +79,13 @@ struct draw_context *draw_create( void ) void draw_destroy( struct draw_context *draw ) { - if (draw->header.storage) +#ifdef MESA + if (draw->header.storage) { ALIGN_FREE( draw->header.storage ); + } vf_destroy( draw->vf ); +#endif free( draw->vcache.vertex[0] ); /* Frees all the vertices. */ free( draw ); @@ -186,7 +193,9 @@ void draw_set_viewport_state( struct draw_context *draw, { draw->viewport = *viewport; /* struct copy */ +#ifdef MESA vf_set_vp_scale_translate( draw->vf, viewport->scale, viewport->translate ); +#endif /* Using tnl/ and vf/ modules is temporary while getting started. * Full pipe will have vertex shader, vertex fetch of its own. diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h index beba9429c91..ac994d64195 100644 --- a/src/mesa/pipe/draw/draw_context.h +++ b/src/mesa/pipe/draw/draw_context.h @@ -38,7 +38,6 @@ #define DRAW_CONTEXT_H -#include "main/glheader.h" #include "pipe/p_state.h" @@ -64,13 +63,13 @@ void draw_set_setup_stage( struct draw_context *draw, struct draw_stage *stage ); void draw_set_vertex_attributes( struct draw_context *draw, - const GLuint *attrs, - GLuint nr_attrs ); + const unsigned *attrs, + unsigned nr_attrs ); /* XXX temporary */ void draw_set_vertex_attributes2( struct draw_context *draw, - const GLuint *attrs, - GLuint nr_attrs ); + const unsigned *attrs, + unsigned nr_attrs ); void draw_set_vertex_array_info(struct draw_context *draw, const struct pipe_vertex_buffer *buffers, @@ -81,9 +80,9 @@ void draw_vb(struct draw_context *draw, struct vertex_buffer *VB ); void draw_vertices(struct draw_context *draw, - GLuint mode, - GLuint numVertex, const GLfloat *verts, - GLuint numAttribs, const GLuint attribs[]); + unsigned mode, + unsigned numVertex, const float *verts, + unsigned numAttribs, const unsigned attribs[]); #endif /* DRAW_CONTEXT_H */ diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c index 48a7f5dab8e..f3d56ad7197 100644 --- a/src/mesa/pipe/draw/draw_cull.c +++ b/src/mesa/pipe/draw/draw_cull.c @@ -33,14 +33,14 @@ */ -#include "main/imports.h" +#include "pipe/p_util.h" #include "pipe/p_defines.h" #include "draw_private.h" struct cull_stage { struct draw_stage stage; - GLuint winding; /**< which winding(s) to cull (one of PIPE_WINDING_x) */ + unsigned winding; /**< which winding(s) to cull (one of PIPE_WINDING_x) */ }; @@ -64,15 +64,15 @@ static void cull_tri( struct draw_stage *stage, struct prim_header *header ) { /* Window coords: */ - const GLfloat *v0 = header->v[0]->data[0]; - const GLfloat *v1 = header->v[1]->data[0]; - const GLfloat *v2 = header->v[2]->data[0]; + const float *v0 = header->v[0]->data[0]; + const float *v1 = header->v[1]->data[0]; + const float *v2 = header->v[2]->data[0]; /* edge vectors e = v0 - v2, f = v1 - v2 */ - GLfloat ex = v0[0] - v2[0]; - GLfloat ey = v0[1] - v2[1]; - GLfloat fx = v1[0] - v2[0]; - GLfloat fy = v1[1] - v2[1]; + const float ex = v0[0] - v2[0]; + const float ey = v0[1] - v2[1]; + const float fx = v1[0] - v2[0]; + const float fy = v1[1] - v2[1]; /* det = cross(e,f).z */ header->det = ex * fy - ey * fx; @@ -81,7 +81,7 @@ static void cull_tri( struct draw_stage *stage, /* if (det < 0 then Z points toward camera and triangle is * counter-clockwise winding. */ - GLuint winding = (header->det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW; + unsigned winding = (header->det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW; if ((winding & cull_stage(stage)->winding) == 0) { /* triangle is not culled, pass to next stage */ diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c index cf5e762079a..128acc5b2b1 100644 --- a/src/mesa/pipe/draw/draw_flatshade.c +++ b/src/mesa/pipe/draw/draw_flatshade.c @@ -28,14 +28,14 @@ /* Authors: Keith Whitwell */ -#include "main/imports.h" +#include "pipe/p_util.h" #include "draw_private.h" struct flatshade_stage { struct draw_stage stage; - const GLuint *lookup; + const unsigned *lookup; }; @@ -53,7 +53,7 @@ static void flatshade_begin( struct draw_stage *stage ) -static INLINE void copy_attr( GLuint attr, +static INLINE void copy_attr( unsigned attr, struct vertex_header *dst, const struct vertex_header *src ) { @@ -70,7 +70,7 @@ static INLINE void copy_colors( struct draw_stage *stage, const struct vertex_header *src ) { const struct flatshade_stage *flatshade = flatshade_stage(stage); - const GLuint *lookup = flatshade->lookup; + const unsigned *lookup = flatshade->lookup; copy_attr( lookup[VF_ATTRIB_COLOR0], dst, src ); copy_attr( lookup[VF_ATTRIB_COLOR1], dst, src ); diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c index 9f665663538..9b00b09032f 100644 --- a/src/mesa/pipe/draw/draw_offset.c +++ b/src/mesa/pipe/draw/draw_offset.c @@ -32,8 +32,7 @@ * \author Brian Paul */ -#include "main/imports.h" -#include "main/macros.h" +#include "pipe/p_util.h" #include "draw_private.h" @@ -41,8 +40,8 @@ struct offset_stage { struct draw_stage stage; - GLfloat scale; - GLfloat units; + float scale; + float units; }; @@ -56,7 +55,7 @@ static INLINE struct offset_stage *offset_stage( struct draw_stage *stage ) static void offset_begin( struct draw_stage *stage ) { struct offset_stage *offset = offset_stage(stage); - GLfloat mrd = 1.0 / 65535.0; /* XXX this depends on depthbuffer bits! */ + float mrd = 1.0 / 65535.0; /* XXX this depends on depthbuffer bits! */ offset->units = stage->draw->setup.offset_units * mrd; offset->scale = stage->draw->setup.offset_scale; @@ -73,30 +72,30 @@ static void do_offset_tri( struct draw_stage *stage, struct prim_header *header ) { struct offset_stage *offset = offset_stage(stage); - GLfloat inv_det = 1.0 / header->det; + float inv_det = 1.0 / header->det; /* Window coords: */ - GLfloat *v0 = header->v[0]->data[0]; - GLfloat *v1 = header->v[1]->data[0]; - GLfloat *v2 = header->v[2]->data[0]; + float *v0 = header->v[0]->data[0]; + float *v1 = header->v[1]->data[0]; + float *v2 = header->v[2]->data[0]; /* edge vectors e = v0 - v2, f = v1 - v2 */ - GLfloat ex = v0[0] - v2[0]; - GLfloat ey = v0[1] - v2[1]; - GLfloat ez = v0[2] - v2[2]; - GLfloat fx = v1[0] - v2[0]; - GLfloat fy = v1[1] - v2[1]; - GLfloat fz = v1[2] - v2[2]; + float ex = v0[0] - v2[0]; + float ey = v0[1] - v2[1]; + float ez = v0[2] - v2[2]; + float fx = v1[0] - v2[0]; + float fy = v1[1] - v2[1]; + float fz = v1[2] - v2[2]; /* (a,b) = cross(e,f).xy */ - GLfloat a = ey*fz - ez*fy; - GLfloat b = ez*fx - ex*fz; + float a = ey*fz - ez*fy; + float b = ez*fx - ex*fz; - GLfloat dzdx = FABSF(a * inv_det); - GLfloat dzdy = FABSF(b * inv_det); + float dzdx = FABSF(a * inv_det); + float dzdy = FABSF(b * inv_det); - GLfloat zoffset = offset->units + MAX2(dzdx, dzdy) * offset->scale; + float zoffset = offset->units + MAX2(dzdx, dzdy) * offset->scale; /* * Note: we're applying the offset and clamping per-vertex. diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c index 931404caff7..7757dacf34f 100644 --- a/src/mesa/pipe/draw/draw_prim.c +++ b/src/mesa/pipe/draw/draw_prim.c @@ -30,6 +30,7 @@ * Keith Whitwell */ +#include "pipe/p_util.h" #include "draw_private.h" #include "draw_context.h" #include "draw_prim.h" @@ -173,7 +174,7 @@ static struct vertex_header *get_uint_elt_vertex( struct draw_context *draw, static struct vertex_header *get_ushort_elt_vertex( struct draw_context *draw, unsigned i ) { - const GLushort *elts = (const GLushort *)draw->elts; + const ushort *elts = (const ushort *)draw->elts; return get_vertex( draw, elts[i] ); } @@ -181,7 +182,7 @@ static struct vertex_header *get_ushort_elt_vertex( struct draw_context *draw, static struct vertex_header *get_ubyte_elt_vertex( struct draw_context *draw, unsigned i ) { - const GLubyte *elts = (const GLubyte *)draw->elts; + const ubyte *elts = (const ubyte *)draw->elts; return get_vertex( draw, elts[i] ); } @@ -522,13 +523,13 @@ draw_trim( unsigned count, unsigned first, unsigned incr ) /** * Allocate space for temporary post-transform vertices, such as for clipping. */ -void draw_alloc_tmps( struct draw_stage *stage, GLuint nr ) +void draw_alloc_tmps( struct draw_stage *stage, unsigned nr ) { stage->nr_tmps = nr; if (nr) { - GLubyte *store = (GLubyte *) malloc(MAX_VERTEX_SIZE * nr); - GLuint i; + ubyte *store = (ubyte *) malloc(MAX_VERTEX_SIZE * nr); + unsigned i; stage->tmp = (struct vertex_header **) malloc(sizeof(struct vertex_header *) * nr); diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index b6ef32855a1..2748772fdb2 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -41,10 +41,31 @@ #define DRAW_PRIVATE_H -#include "main/glheader.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" +#ifdef MESA #include "vf/vf.h" +#else +/* XXX these are temporary */ +struct vf_attr_map { + unsigned attrib; + unsigned format; + unsigned offset; +}; +#define VF_ATTRIB_POS 0 +#define VF_ATTRIB_COLOR0 3 +#define VF_ATTRIB_COLOR1 4 +#define VF_ATTRIB_BFC0 25 +#define VF_ATTRIB_BFC1 26 + +#define VF_ATTRIB_CLIP_POS 27 +#define VF_ATTRIB_VERTEX_HEADER 28 +#define VF_ATTRIB_MAX 29 +#define EMIT_1F 0 +#define EMIT_4F 3 +#define EMIT_4F_VIEWPORT 6 +#define FRAG_ATTRIB_MAX 13 +#endif /** @@ -201,7 +222,9 @@ struct draw_context /* Misc for draw_vb.c (XXX temporary) */ +#ifdef MESA GLvector4f header; +#endif ubyte *verts; boolean in_vb; struct vertex_fetch *vf; diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c index 20b2b4a8aa4..045109dae0b 100644 --- a/src/mesa/pipe/draw/draw_twoside.c +++ b/src/mesa/pipe/draw/draw_twoside.c @@ -28,15 +28,15 @@ /* Authors: Keith Whitwell */ -#include "main/imports.h" +#include "pipe/p_util.h" #include "pipe/p_defines.h" #include "draw_private.h" struct twoside_stage { struct draw_stage stage; - GLfloat sign; /**< +1 or -1 */ - const GLuint *lookup; + float sign; /**< +1 or -1 */ + const unsigned *lookup; }; @@ -61,8 +61,8 @@ static void twoside_begin( struct draw_stage *stage ) } -static INLINE void copy_color( GLuint attr_dst, - GLuint attr_src, +static INLINE void copy_color( unsigned attr_dst, + unsigned attr_src, struct vertex_header *v ) { if (attr_dst && attr_src) { @@ -75,7 +75,7 @@ static INLINE void copy_color( GLuint attr_dst, static struct vertex_header *copy_bfc( struct twoside_stage *twoside, const struct vertex_header *v, - GLuint idx ) + unsigned idx ) { struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx ); diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c index e0e486ebe6f..4215b8b2280 100644 --- a/src/mesa/pipe/draw/draw_unfilled.c +++ b/src/mesa/pipe/draw/draw_unfilled.c @@ -33,7 +33,7 @@ /* Authors: Keith Whitwell */ -#include "main/imports.h" +#include "pipe/p_util.h" #include "pipe/p_defines.h" #include "draw_private.h" @@ -45,7 +45,7 @@ struct unfilled_stage { * legal values: PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE, * and PIPE_POLYGON_MODE_POINT, */ - GLuint mode[2]; + unsigned mode[2]; }; @@ -119,7 +119,7 @@ static void unfilled_tri( struct draw_stage *stage, struct prim_header *header ) { struct unfilled_stage *unfilled = unfilled_stage(stage); - GLuint mode = unfilled->mode[header->det < 0.0]; + unsigned mode = unfilled->mode[header->det < 0.0]; switch (mode) { case PIPE_POLYGON_MODE_FILL: diff --git a/src/mesa/pipe/draw/draw_vb.c b/src/mesa/pipe/draw/draw_vb.c index db7b217c2f5..18e48c0a687 100644 --- a/src/mesa/pipe/draw/draw_vb.c +++ b/src/mesa/pipe/draw/draw_vb.c @@ -30,11 +30,17 @@ * Keith Whitwell */ -#include "imports.h" -#include "macros.h" - +#ifdef MESA +#include "main/imports.h" +#include "main/macros.h" #include "tnl/t_context.h" #include "vf/vf.h" +#else +#define VF_ +#include "pipe/p_util.h" + +#endif /*MESA*/ + #include "draw_private.h" #include "draw_context.h" @@ -92,11 +98,11 @@ static void vs_flush( struct draw_context *draw ) * Allocate storage for post-transformation vertices. */ static void -draw_allocate_vertices( struct draw_context *draw, GLuint nr_vertices ) +draw_allocate_vertices( struct draw_context *draw, unsigned nr_vertices ) { assert(draw->vertex_size > 0); draw->nr_vertices = nr_vertices; - draw->verts = (GLubyte *) malloc( nr_vertices * draw->vertex_size ); + draw->verts = (ubyte *) malloc( nr_vertices * draw->vertex_size ); draw_invalidate_vcache( draw ); } @@ -117,20 +123,21 @@ draw_release_vertices( struct draw_context *draw ) * Note: this must match struct vertex_header's layout (I think). */ struct header_dword { - GLuint clipmask:12; - GLuint edgeflag:1; - GLuint pad:19; + unsigned clipmask:12; + unsigned edgeflag:1; + unsigned pad:19; }; +#ifdef MESA static void build_vertex_headers( struct draw_context *draw, struct vertex_buffer *VB ) { if (draw->header.storage == NULL) { - draw->header.stride = sizeof(GLfloat); + draw->header.stride = sizeof(float); draw->header.size = 1; - draw->header.storage = ALIGN_MALLOC( VB->Size * sizeof(GLfloat), 32 ); + draw->header.storage = ALIGN_MALLOC( VB->Size * sizeof(float), 32 ); draw->header.data = draw->header.storage; draw->header.count = 0; draw->header.flags = VEC_SIZE_1 | VEC_MALLOC; @@ -141,12 +148,12 @@ build_vertex_headers( struct draw_context *draw, */ { - GLuint i; + unsigned i; struct header_dword *header = (struct header_dword *)draw->header.storage; /* yes its a hack */ - assert(sizeof(*header) == sizeof(GLfloat)); + assert(sizeof(*header) == sizeof(float)); draw->header.count = VB->Count; @@ -175,16 +182,18 @@ build_vertex_headers( struct draw_context *draw, VB->AttribPtr[VF_ATTRIB_VERTEX_HEADER] = &draw->header; } +#endif /*MESA*/ +#ifdef MESA /** * This is a hack & will all go away. */ void draw_vb(struct draw_context *draw, struct vertex_buffer *VB ) { - GLuint i; + unsigned i; VB->AttribPtr[VF_ATTRIB_POS] = VB->NdcPtr; VB->AttribPtr[VF_ATTRIB_BFC0] = VB->ColorPtr[1]; @@ -212,14 +221,14 @@ void draw_vb(struct draw_context *draw, vf_emit_vertices( draw->vf, VB->Count, draw->verts ); if (VB->Elts) - draw_set_element_buffer(draw, sizeof(GLuint), VB->Elts); + draw_set_element_buffer(draw, sizeof(unsigned), VB->Elts); else draw_set_element_buffer(draw, 0, NULL); for (i = 0; i < VB->PrimitiveCount; i++) { const GLenum mode = VB->Primitive[i].mode; - const GLuint start = VB->Primitive[i].start; - GLuint length, first, incr; + const unsigned start = VB->Primitive[i].start; + unsigned length, first, incr; /* Trim the primitive down to a legal size. */ @@ -247,27 +256,28 @@ void draw_vb(struct draw_context *draw, draw->in_vb = 0; draw->elts = NULL; } +#endif /*MESA*/ /** * XXX Temporary mechanism to draw simple vertex arrays. - * All attribs are GLfloat[4]. Arrays are interleaved, in GL-speak. + * All attribs are float[4]. Arrays are interleaved, in GL-speak. */ void draw_vertices(struct draw_context *draw, - GLuint mode, - GLuint numVerts, const GLfloat *vertices, - GLuint numAttrs, const GLuint attribs[]) + unsigned mode, + unsigned numVerts, const float *vertices, + unsigned numAttrs, const unsigned attribs[]) { - /*GLuint first, incr;*/ - GLuint i, j; + /*unsigned first, incr;*/ + unsigned i, j; - assert(mode <= GL_POLYGON); + assert(mode <= PIPE_PRIM_POLYGON); draw->vs_flush = vs_flush; draw->vertex_size - = sizeof(struct vertex_header) + numAttrs * 4 * sizeof(GLfloat); + = sizeof(struct vertex_header) + numAttrs * 4 * sizeof(float); /* no element/index buffer */ @@ -344,10 +354,10 @@ do { \ * (and number of attributes) */ void draw_set_vertex_attributes( struct draw_context *draw, - const GLuint *slot_to_vf_attr, - GLuint nr_attrs ) + const unsigned *slot_to_vf_attr, + unsigned nr_attrs ) { - GLuint i; + unsigned i; memset(draw->vf_attr_to_slot, 0, sizeof(draw->vf_attr_to_slot)); draw->nr_attrs = 0; @@ -368,6 +378,8 @@ void draw_set_vertex_attributes( struct draw_context *draw, EMIT_ATTR(slot_to_vf_attr[i], EMIT_4F); /* tell the vertex format module how to construct vertices for us */ +#if MESA draw->vertex_size = vf_set_vertex_attributes( draw->vf, draw->attrs, draw->nr_attrs, 0 ); +#endif } diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h index 072dad0573a..f4af16a2dea 100755 --- a/src/mesa/pipe/p_util.h +++ b/src/mesa/pipe/p_util.h @@ -112,6 +112,18 @@ do { \ } while (0) +#define COPY_4FV( DST, SRC ) COPY_4V(DST, SRC) + + +#define ASSIGN_4V( DST, V0, V1, V2, V3 ) \ +do { \ + (DST)[0] = (V0); \ + (DST)[1] = (V1); \ + (DST)[2] = (V2); \ + (DST)[3] = (V3); \ +} while (0) + + static INLINE int ifloor(float f) { int ai, bi; diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 3f7044825a6..e63ce208d42 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -80,6 +80,11 @@ softpipe_supported_formats(struct pipe_context *pipe, unsigned *numFormats) } +/** XXX remove these? */ +#define MAX_TEXTURE_LEVELS 11 +#define MAX_TEXTURE_RECT_SIZE 2048 +#define MAX_3D_TEXTURE_LEVELS 8 + static void softpipe_max_texture_size(struct pipe_context *pipe, unsigned textureType, unsigned *maxWidth, unsigned *maxHeight, diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 9b91628aaf2..21c1032b137 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -40,6 +40,11 @@ #include "pipe/draw/draw_private.h" #include "pipe/p_util.h" +#ifndef MESA +#define FRAG_ATTRIB_WPOS 0 +#define FRAG_ATTRIB_MAX 13 +#endif + /** * Triangle edge info diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index d66a0ed851e..425076d6537 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -74,7 +74,7 @@ static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage ) /* Call into the new draw code to handle the VB: */ st->pipe->draw_vb( st->pipe, VB ); - + /* Finished */ return GL_FALSE;