From bdc38254618d5f984e206b5ddb484c3cbc55c3bb Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 16 Jan 2008 16:31:37 -0700 Subject: Fix broken fog. Note that fogcoord and front-facing attribs are in the same register, in the X and Y channels, respectively. --- src/mesa/pipe/softpipe/sp_prim_setup.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/mesa/pipe/softpipe') diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 722cadc5c0..7847027cae 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -554,12 +554,6 @@ static void setup_tri_coefficients( struct setup_stage *setup ) */ setup_fragcoord_coeff(setup); } - else if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) { - /* FOG.y = front/back facing XXX fix this */ - setup->coef[fragSlot].a0[1] = 1 - setup->quad.facing; - setup->coef[fragSlot].dadx[1] = 0.0; - setup->coef[fragSlot].dady[1] = 0.0; - } else { #endif uint j; @@ -578,8 +572,18 @@ static void setup_tri_coefficients( struct setup_stage *setup ) break; default: /* invalid interp mode */ - assert(0); + /* assert(0); re-enable this and run demos/fogcoord.c ... */ + ; + } + + if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) { + /* FOG.y = front/back facing XXX fix this */ + setup->coef[fragSlot].a0[1] = 1 - setup->quad.facing; + setup->coef[fragSlot].dadx[1] = 0.0; + setup->coef[fragSlot].dady[1] = 0.0; } + + #if USE_INPUT_MAP } #endif -- cgit v1.2.3 From af51d188c3e894c2ac3d261831320f178d1bd6fe Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 17 Dec 2007 12:03:51 +0000 Subject: gallium: fix warning --- src/mesa/pipe/softpipe/sp_winsys.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/pipe/softpipe') diff --git a/src/mesa/pipe/softpipe/sp_winsys.h b/src/mesa/pipe/softpipe/sp_winsys.h index cbf64ebb85..d6b379f58c 100644 --- a/src/mesa/pipe/softpipe/sp_winsys.h +++ b/src/mesa/pipe/softpipe/sp_winsys.h @@ -37,6 +37,7 @@ #include "pipe/p_compiler.h" /* for boolean */ +enum pipe_format; struct softpipe_winsys { /** test if the given format is supported for front/back color bufs */ -- cgit v1.2.3 From 271f9dac79a9247de9a57f4d248e404bf1652a13 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 17 Jan 2008 13:39:14 +0900 Subject: Back-port miscellaneous fixes from internal branch (mostly portability fixes). These are changes that are in our internal branch, but somehow were skipped so far. It was done using visual comparison of the branches -- it is likely that changes are being carried on the wrong way --- src/mesa/pipe/Makefile.template | 9 +++-- src/mesa/pipe/i915simple/i915_prim_vbuf.c | 2 +- src/mesa/pipe/i915simple/i915_surface.c | 1 + src/mesa/pipe/i915simple/i915_texture.c | 12 +++--- src/mesa/pipe/p_compiler.h | 19 +++++++++ src/mesa/pipe/p_format.h | 2 + src/mesa/pipe/p_shader_tokens.h | 3 +- src/mesa/pipe/p_util.h | 64 +++++++++++++++++++------------ src/mesa/pipe/p_winsys.h | 5 ++- src/mesa/pipe/softpipe/sp_prim_setup.c | 2 +- src/mesa/pipe/softpipe/sp_quad_fs.c | 2 +- src/mesa/pipe/softpipe/sp_quad_stipple.c | 2 + src/mesa/pipe/softpipe/sp_surface.c | 1 + src/mesa/pipe/softpipe/sp_texture.c | 2 +- src/mesa/pipe/softpipe/sp_tile_cache.c | 10 ++--- src/mesa/pipe/tgsi/util/tgsi_build.c | 6 +-- src/mesa/state_tracker/st_cb_fbo.c | 2 + src/mesa/state_tracker/st_public.h | 3 ++ 18 files changed, 98 insertions(+), 49 deletions(-) (limited to 'src/mesa/pipe/softpipe') diff --git a/src/mesa/pipe/Makefile.template b/src/mesa/pipe/Makefile.template index 3cd07660b6..8e84f8eb2d 100644 --- a/src/mesa/pipe/Makefile.template +++ b/src/mesa/pipe/Makefile.template @@ -17,7 +17,8 @@ INCLUDES = \ -I. \ -I$(TOP)/src/mesa/pipe \ -I$(TOP)/src/mesa \ - -I$(TOP)/include + -I$(TOP)/include \ + $(DRIVER_INCLUDES) ##### RULES ##### @@ -34,11 +35,11 @@ INCLUDES = \ ##### TARGETS ##### -default:: depend symlinks $(LIBNAME) +default: depend symlinks $(LIBNAME) $(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/mesa/pipe/Makefile.template - $(TOP)/bin/mklib -o $@ -static $(OBJECTS) + $(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS) depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) @@ -54,7 +55,7 @@ tags: # Remove .o and backup files -clean: +clean:: -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS) -rm -f depend depend.bak diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c index d85a6d3c0f..edc62e25e5 100644 --- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c +++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c @@ -202,7 +202,7 @@ static void i915_vbuf_render_destroy( struct vbuf_render *render ) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); - free(i915_render); + FREE(i915_render); } diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c index e3c3cdd2e4..72a65e0fb4 100644 --- a/src/mesa/pipe/i915simple/i915_surface.c +++ b/src/mesa/pipe/i915simple/i915_surface.c @@ -64,6 +64,7 @@ i915_get_tex_surface(struct pipe_context *pipe, ps = pipe->winsys->surface_alloc(pipe->winsys); if (ps) { assert(ps->refcount); + assert(ps->winsys); pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, tex->buffer); ps->format = pt->format; ps->cpp = pt->cpp; diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c index 44f72e63cc..6b0a4a96f3 100644 --- a/src/mesa/pipe/i915simple/i915_texture.c +++ b/src/mesa/pipe/i915simple/i915_texture.c @@ -123,7 +123,7 @@ i945_miptree_layout_2d( struct i915_texture *tex ) * 2nd mipmap out past the width of its parent. */ if (pt->first_level != pt->last_level) { - unsigned mip1_width = align(minify(pt->width[0]), align_w) + unsigned mip1_width = align_int(minify(pt->width[0]), align_w) + minify(minify(pt->width[0])); if (mip1_width > pt->width[0]) @@ -133,7 +133,7 @@ i945_miptree_layout_2d( struct i915_texture *tex ) /* Pitch must be a whole number of dwords, even though we * express it in texels. */ - tex->pitch = align(tex->pitch * pt->cpp, 4) / pt->cpp; + tex->pitch = align_int(tex->pitch * pt->cpp, 4) / pt->cpp; tex->total_height = 0; for ( level = pt->first_level ; level <= pt->last_level ; level++ ) { @@ -144,7 +144,7 @@ i945_miptree_layout_2d( struct i915_texture *tex ) if (pt->compressed) img_height = MAX2(1, height/4); else - img_height = align(height, align_h); + img_height = align_int(height, align_h); /* Because the images are packed better, the final offset @@ -155,7 +155,7 @@ i945_miptree_layout_2d( struct i915_texture *tex ) /* Layout_below: step right after second mipmap. */ if (level == pt->first_level + 1) { - x += align(width, align_w); + x += align_int(width, align_w); } else { y += img_height; @@ -531,9 +531,9 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt) for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) if (tex->image_offset[i]) - free(tex->image_offset[i]); + FREE(tex->image_offset[i]); - free(tex); + FREE(tex); } *pt = NULL; } diff --git a/src/mesa/pipe/p_compiler.h b/src/mesa/pipe/p_compiler.h index 4f2c9ef88a..ab9609deab 100644 --- a/src/mesa/pipe/p_compiler.h +++ b/src/mesa/pipe/p_compiler.h @@ -50,6 +50,25 @@ typedef unsigned short ushort; typedef unsigned long long uint64; +#if defined(__MSC__) + +typedef unsigned short uint16_t; +typedef long int32_t; +typedef unsigned long uint32_t; +typedef long long int64_t; +typedef unsigned long long uint64_t; + +#if defined(_WIN64) +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif + +#else +#include +#endif + + #define TRUE 1 #define FALSE 0 diff --git a/src/mesa/pipe/p_format.h b/src/mesa/pipe/p_format.h index b1772b352f..9f60cdbb04 100644 --- a/src/mesa/pipe/p_format.h +++ b/src/mesa/pipe/p_format.h @@ -97,6 +97,8 @@ static INLINE uint pf_get(pipe_format_rgbazs_t f, uint shift, uint mask) return (f >> shift) & mask; } +/* XXX: The bit layout needs to be revised, can't currently encode 10-bit components. */ + #define pf_swizzle_x(f) pf_get(f, 2, 0x7) /**< PIPE_FORMAT_COMP_ */ #define pf_swizzle_y(f) pf_get(f, 5, 0x7) /**< PIPE_FORMAT_COMP_ */ #define pf_swizzle_z(f) pf_get(f, 8, 0x7) /**< PIPE_FORMAT_COMP_ */ diff --git a/src/mesa/pipe/p_shader_tokens.h b/src/mesa/pipe/p_shader_tokens.h index e5922b439f..e9d1d66bda 100644 --- a/src/mesa/pipe/p_shader_tokens.h +++ b/src/mesa/pipe/p_shader_tokens.h @@ -109,7 +109,8 @@ struct tgsi_declaration_interpolation #define TGSI_SEMANTIC_FOG 3 #define TGSI_SEMANTIC_PSIZE 4 #define TGSI_SEMANTIC_GENERIC 5 -#define TGSI_SEMANTIC_COUNT 6 /**< number of semantic values */ +#define TGSI_SEMANTIC_NORMAL 6 +#define TGSI_SEMANTIC_COUNT 7 /**< number of semantic values */ struct tgsi_declaration_semantic { diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h index 69ec62e307..573fef9b83 100644 --- a/src/mesa/pipe/p_util.h +++ b/src/mesa/pipe/p_util.h @@ -111,6 +111,32 @@ REALLOC( void *old_ptr, unsigned old_size, unsigned new_size ) #define CALLOC_STRUCT(T) (struct T *) CALLOC(1, sizeof(struct T)) +/** + * Return a pointer aligned to next multiple of N bytes. + */ +static INLINE void * +align_pointer( void *unaligned, uint alignment ) +{ + if (sizeof(void *) == 64) { + union { + void *p; + uint64 u; + } pu; + pu.p = unaligned; + pu.u = (pu.u + alignment - 1) & ~(uint64) (alignment - 1); + return pu.p; + } + else { + /* 32-bit pointers */ + union { + void *p; + uint u; + } pu; + pu.p = unaligned; + pu.u = (pu.u + alignment - 1) & ~(alignment - 1); + return pu.p; + } +} /** * Return memory on given byte alignment @@ -123,19 +149,18 @@ align_malloc(size_t bytes, uint alignment) (void) posix_memalign(& mem, alignment, bytes); return mem; #else - typedef unsigned long int uintptr_t; - uintptr_t ptr, buf; + char *ptr, *buf; assert( alignment > 0 ); - ptr = (uintptr_t) MALLOC(bytes + alignment + sizeof(void *)); + ptr = (char *) MALLOC(bytes + alignment + sizeof(void *)); if (!ptr) return NULL; - buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); - *(uintptr_t *)(buf - sizeof(void *)) = ptr; + buf = (char *) align_pointer( ptr + sizeof(void *), alignment ); + *(char **)(buf - sizeof(void *)) = ptr; - return (void *) buf; + return buf; #endif /* defined(HAVE_POSIX_MEMALIGN) */ } @@ -169,28 +194,17 @@ align_free(void *ptr) static INLINE void * align16( void *unaligned ) { - if (sizeof(void *) == 64) { - union { - void *p; - uint64 u; - } pu; - pu.p = unaligned; - pu.u = (pu.u + 15) & ~15; - return pu.p; - } - else { - /* 32-bit pointers */ - union { - void *p; - uint u; - } pu; - pu.p = unaligned; - pu.u = (pu.u + 15) & ~15; - return pu.p; - } + return align_pointer( unaligned, 16 ); } +static INLINE int align_int(int x, int align) +{ + return (x + align - 1) & ~(align - 1); +} + + + #if defined(__MSC__) && defined(__WIN32__) static INLINE unsigned ffs( unsigned u ) { diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index aa9362ec0b..75c6dc7e85 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -79,7 +79,10 @@ struct pipe_winsys /** allocate a new surface (no context dependency) */ struct pipe_surface *(*surface_alloc)(struct pipe_winsys *ws); - /** allocate storage for a pipe_surface */ + /** + * Allocate storage for a pipe_surface. + * Returns 0 if succeeds. + */ int (*surface_alloc_storage)(struct pipe_winsys *ws, struct pipe_surface *surf, unsigned width, unsigned height, diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index 7847027cae..89f8df945c 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -488,7 +488,7 @@ setup_fragcoord_coeff(struct setup_stage *setup) if (setup->softpipe->rasterizer->origin_lower_left) { /* y=0=bottom */ const int winHeight = setup->softpipe->framebuffer.cbufs[0]->height; - setup->coef[0].a0[1] = winHeight - 1; + setup->coef[0].a0[1] = (float) (winHeight - 1); setup->coef[0].dady[1] = -1.0; } else { diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index 921dfbaccb..0001c76a80 100644 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -133,7 +133,7 @@ shade_quad( machine->InterpCoefs = quad->coef; /* Compute X, Y, Z, W vals for this quad */ - setup_pos_vector(quad->posCoef, quad->x0, quad->y0, &machine->QuadPos); + setup_pos_vector(quad->posCoef, (float) quad->x0, (float) quad->y0, &machine->QuadPos); /* run shader */ #if defined(__i386__) || defined(__386__) diff --git a/src/mesa/pipe/softpipe/sp_quad_stipple.c b/src/mesa/pipe/softpipe/sp_quad_stipple.c index 0c42963dfe..8660432259 100644 --- a/src/mesa/pipe/softpipe/sp_quad_stipple.c +++ b/src/mesa/pipe/softpipe/sp_quad_stipple.c @@ -36,6 +36,7 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad) stipple1 = softpipe->poly_stipple.stipple[y1 % 32]; #if 1 + { const int col0 = quad->x0 % 32; if ((stipple0 & (bit31 >> col0)) == 0) quad->mask &= ~MASK_TOP_LEFT; @@ -48,6 +49,7 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad) if ((stipple1 & (bit30 >> col0)) == 0) quad->mask &= ~MASK_BOTTOM_RIGHT; + } #else /* We'd like to use this code, but we'd need to redefine * MASK_TOP_LEFT to be (1 << 1) and MASK_TOP_RIGHT to be (1 << 0), diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index 6c080d5b5c..a580fb3e82 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -50,6 +50,7 @@ softpipe_get_tex_surface(struct pipe_context *pipe, ps = pipe->winsys->surface_alloc(pipe->winsys); if (ps) { assert(ps->refcount); + assert(ps->winsys); pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, spt->buffer); ps->format = pt->format; ps->cpp = pt->cpp; diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c index e5e6bfe01b..532bcfcc51 100644 --- a/src/mesa/pipe/softpipe/sp_texture.c +++ b/src/mesa/pipe/softpipe/sp_texture.c @@ -126,7 +126,7 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt) pipe->winsys->buffer_reference(pipe->winsys, &spt->buffer, NULL); - free(spt); + FREE(spt); } *pt = NULL; } diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c index 6515ce668c..1974f77459 100644 --- a/src/mesa/pipe/softpipe/sp_tile_cache.c +++ b/src/mesa/pipe/softpipe/sp_tile_cache.c @@ -286,7 +286,7 @@ clear_tile(struct softpipe_cached_tile *tile, else { for (i = 0; i < TILE_SIZE; i++) { for (j = 0; j < TILE_SIZE; j++) { - tile->data.depth16[i][j] = clear_value; + tile->data.depth16[i][j] = (ushort) clear_value; } } } @@ -564,10 +564,10 @@ sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue) r = g = b = a = 0; } - tc->clear_color[0] = r / 255.0; - tc->clear_color[1] = g / 255.0; - tc->clear_color[2] = b / 255.0; - tc->clear_color[3] = a / 255.0; + tc->clear_color[0] = r / 255.0f; + tc->clear_color[1] = g / 255.0f; + tc->clear_color[2] = b / 255.0f; + tc->clear_color[3] = a / 255.0f; #if TILE_CLEAR_OPTIMIZATION /* set flags to indicate all the tiles are cleared */ diff --git a/src/mesa/pipe/tgsi/util/tgsi_build.c b/src/mesa/pipe/tgsi/util/tgsi_build.c index 19b2aad921..67f7d2c2c2 100644 --- a/src/mesa/pipe/tgsi/util/tgsi_build.c +++ b/src/mesa/pipe/tgsi/util/tgsi_build.c @@ -365,7 +365,7 @@ tgsi_build_immediate( immediate = tgsi_default_immediate(); - header_bodysize_grow( header ); + header_bodysize_grow( header ); return immediate; } @@ -415,7 +415,7 @@ tgsi_build_full_immediate( struct tgsi_header *header, unsigned maxsize ) { - unsigned size = 0, i; + unsigned size = 0, i; struct tgsi_immediate *immediate; if( maxsize <= size ) @@ -433,7 +433,7 @@ tgsi_build_full_immediate( if32 = (struct tgsi_immediate_float32 *) &tokens[size]; size++; - *if32 = tgsi_build_immediate_float32( + *if32 = tgsi_build_immediate_float32( full_imm->u.ImmediateFloat32[i].Float, immediate, header ); diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 2d6b3fc749..f02cb3d133 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -93,6 +93,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, if (!strb->surface) { strb->surface = pipe->winsys->surface_alloc(pipe->winsys); assert(strb->surface); + assert(strb->surface->refcount); + assert(strb->surface->winsys); if (!strb->surface) return GL_FALSE; } diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index ed5ef1f159..78a8fde82b 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -28,6 +28,9 @@ #ifndef ST_PUBLIC_H #define ST_PUBLIC_H +#include "GL/gl.h" +#include "GL/internal/glcore.h" /* for __GLcontextModes */ + #include "pipe/p_compiler.h" #include "pipe/p_format.h" -- cgit v1.2.3 From e44bdcf9789caf9971c3c94605fbff7ce66af7ba Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 18 Jan 2008 19:08:30 +0100 Subject: Unify copy_rect helpers. Some of the copies were buggy. --- src/mesa/pipe/i915simple/i915_surface.c | 57 +++++-------------------- src/mesa/pipe/i965simple/brw_surface.c | 56 +++++-------------------- src/mesa/pipe/p_util.h | 9 ++++ src/mesa/pipe/softpipe/sp_surface.c | 63 ++++++---------------------- src/mesa/pipe/util/p_util.c | 73 +++++++++++++++++++++++++++++++++ src/mesa/sources | 3 +- 6 files changed, 118 insertions(+), 143 deletions(-) create mode 100644 src/mesa/pipe/util/p_util.c (limited to 'src/mesa/pipe/softpipe') diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c index 72a65e0fb4..e625f5a68c 100644 --- a/src/mesa/pipe/i915simple/i915_surface.c +++ b/src/mesa/pipe/i915simple/i915_surface.c @@ -77,41 +77,6 @@ i915_get_tex_surface(struct pipe_context *pipe, } -static void -copy_rect(ubyte * dst, - unsigned cpp, - unsigned dst_pitch, - unsigned dst_x, - unsigned dst_y, - unsigned width, - unsigned height, - const ubyte *src, - unsigned src_pitch, - unsigned src_x, - unsigned src_y) -{ - unsigned i; - - dst_pitch *= cpp; - src_pitch *= cpp; - dst += dst_x * cpp; - src += src_x * cpp; - dst += dst_y * dst_pitch; - src += src_y * dst_pitch; - width *= cpp; - - if (width == dst_pitch && width == src_pitch) - memcpy(dst, src, height * width); - else { - for (i = 0; i < height; i++) { - memcpy(dst, src, width); - dst += dst_pitch; - src += src_pitch; - } - } -} - - /* Upload data to a rectangular sub-region. Lots of choices how to do this: * * - memcpy by span to current destination @@ -126,9 +91,9 @@ i915_surface_data(struct pipe_context *pipe, const void *src, unsigned src_pitch, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { - copy_rect(pipe_surface_map(dst), - dst->cpp, dst->pitch, - dstx, dsty, width, height, src, src_pitch, srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst), + dst->cpp, dst->pitch, + dstx, dsty, width, height, src, src_pitch, srcx, srcy); pipe_surface_unmap(dst); } @@ -148,14 +113,14 @@ i915_surface_copy(struct pipe_context *pipe, assert( dst->cpp == src->cpp ); if (0) { - copy_rect(pipe_surface_map(dst), - dst->cpp, - dst->pitch, - dstx, dsty, - width, height, - pipe_surface_map(src), - src->pitch, - srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst), + dst->cpp, + dst->pitch, + dstx, dsty, + width, height, + pipe_surface_map(src), + src->pitch, + srcx, srcy); pipe_surface_unmap(src); pipe_surface_unmap(dst); diff --git a/src/mesa/pipe/i965simple/brw_surface.c b/src/mesa/pipe/i965simple/brw_surface.c index 4eacbdf82b..76b8c73d5c 100644 --- a/src/mesa/pipe/i965simple/brw_surface.c +++ b/src/mesa/pipe/i965simple/brw_surface.c @@ -76,40 +76,6 @@ brw_get_tex_surface(struct pipe_context *pipe, } -static void -copy_rect(ubyte * dst, - unsigned cpp, - unsigned dst_pitch, - unsigned dst_x, - unsigned dst_y, - unsigned width, - unsigned height, - const ubyte *src, - unsigned src_pitch, - unsigned src_x, - unsigned src_y) -{ - unsigned i; - - dst_pitch *= cpp; - src_pitch *= cpp; - dst += dst_x * cpp; - src += src_x * cpp; - dst += dst_y * dst_pitch; - src += src_y * dst_pitch; - width *= cpp; - - if (width == dst_pitch && width == src_pitch) - memcpy(dst, src, height * width); - else { - for (i = 0; i < height; i++) { - memcpy(dst, src, width); - dst += dst_pitch; - src += src_pitch; - } - } -} - /* Upload data to a rectangular sub-region. Lots of choices how to do this: * * - memcpy by span to current destination @@ -124,9 +90,9 @@ brw_surface_data(struct pipe_context *pipe, const void *src, unsigned src_pitch, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { - copy_rect(pipe_surface_map(dst) + dst->offset, - dst->cpp, dst->pitch, - dstx, dsty, width, height, src, src_pitch, srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst) + dst->offset, + dst->cpp, dst->pitch, + dstx, dsty, width, height, src, src_pitch, srcx, srcy); pipe_surface_unmap(dst); } @@ -146,14 +112,14 @@ brw_surface_copy(struct pipe_context *pipe, assert(dst->cpp == src->cpp); if (0) { - copy_rect(pipe_surface_map(dst) + dst->offset, - dst->cpp, - dst->pitch, - dstx, dsty, - width, height, - pipe_surface_map(src) + src->offset, - src->pitch, - srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst) + dst->offset, + dst->cpp, + dst->pitch, + dstx, dsty, + width, height, + pipe_surface_map(src) + src->offset, + src->pitch, + srcx, srcy); pipe_surface_unmap(src); pipe_surface_unmap(dst); diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h index 573fef9b83..a2bc330424 100644 --- a/src/mesa/pipe/p_util.h +++ b/src/mesa/pipe/p_util.h @@ -383,4 +383,13 @@ static INLINE int align(int value, int alignment) */ extern void _mesa_printf(const char *str, ...); + +/* util/p_util.c + */ +extern void pipe_copy_rect(ubyte * dst, unsigned cpp, unsigned dst_pitch, + unsigned dst_x, unsigned dst_y, unsigned width, + unsigned height, const ubyte * src, + unsigned src_pitch, unsigned src_x, unsigned src_y); + + #endif diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index a580fb3e82..d5119654ed 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -72,45 +72,6 @@ softpipe_get_tex_surface(struct pipe_context *pipe, } -/** - * Copy 2D rect from one place to another. - * Position and sizes are in pixels. - */ -static void -copy_rect(ubyte * dst, - unsigned cpp, - unsigned dst_pitch, - unsigned dst_x, - unsigned dst_y, - unsigned width, - unsigned height, - const ubyte * src, - unsigned src_pitch, - unsigned src_x, - unsigned src_y) -{ - unsigned i; - - dst_pitch *= cpp; - src_pitch *= cpp; - dst += dst_x * cpp; - src += src_x * cpp; - dst += dst_y * dst_pitch; - src += src_y * src_pitch; - width *= cpp; - - if (width == dst_pitch && width == src_pitch) - memcpy(dst, src, height * width); - else { - for (i = 0; i < height; i++) { - memcpy(dst, src, width); - dst += dst_pitch; - src += src_pitch; - } - } -} - - /* Upload data to a rectangular sub-region. Lots of choices how to do this: * * - memcpy by span to current destination @@ -125,10 +86,10 @@ sp_surface_data(struct pipe_context *pipe, const void *src, unsigned src_pitch, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { - copy_rect(pipe_surface_map(dst), - dst->cpp, - dst->pitch, - dstx, dsty, width, height, src, src_pitch, srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst), + dst->cpp, + dst->pitch, + dstx, dsty, width, height, src, src_pitch, srcx, srcy); pipe_surface_unmap(dst); } @@ -145,14 +106,14 @@ sp_surface_copy(struct pipe_context *pipe, { assert( dst->cpp == src->cpp ); - copy_rect(pipe_surface_map(dst), - dst->cpp, - dst->pitch, - dstx, dsty, - width, height, - pipe_surface_map(src), - src->pitch, - srcx, srcy); + pipe_copy_rect(pipe_surface_map(dst), + dst->cpp, + dst->pitch, + dstx, dsty, + width, height, + pipe_surface_map(src), + src->pitch, + srcx, srcy); pipe_surface_unmap(src); pipe_surface_unmap(dst); diff --git a/src/mesa/pipe/util/p_util.c b/src/mesa/pipe/util/p_util.c new file mode 100644 index 0000000000..c4882b77d2 --- /dev/null +++ b/src/mesa/pipe/util/p_util.c @@ -0,0 +1,73 @@ +/************************************************************************** + * + * Copyright 2008 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. + * + **************************************************************************/ + +/** + * Miscellaneous utility functions. + */ + + +#include "pipe/p_defines.h" +#include "pipe/p_util.h" + + +/** + * Copy 2D rect from one place to another. + * Position and sizes are in pixels. + */ +void +pipe_copy_rect(ubyte * dst, + unsigned cpp, + unsigned dst_pitch, + unsigned dst_x, + unsigned dst_y, + unsigned width, + unsigned height, + const ubyte * src, + unsigned src_pitch, + unsigned src_x, + unsigned src_y) +{ + unsigned i; + + dst_pitch *= cpp; + src_pitch *= cpp; + dst += dst_x * cpp; + src += src_x * cpp; + dst += dst_y * dst_pitch; + src += src_y * src_pitch; + width *= cpp; + + if (width == dst_pitch && width == src_pitch) + memcpy(dst, src, height * width); + else { + for (i = 0; i < height; i++) { + memcpy(dst, src, width); + dst += dst_pitch; + src += src_pitch; + } + } +} diff --git a/src/mesa/sources b/src/mesa/sources index 90ce9ce370..d8760ba134 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -191,7 +191,8 @@ STATECACHE_SOURCES = \ pipe/cso_cache/cso_cache.c PIPEUTIL_SOURCES = \ - pipe/util/p_tile.c + pipe/util/p_tile.c \ + pipe/util/p_util.c STATETRACKER_SOURCES = \ state_tracker/st_atom.c \ -- cgit v1.2.3