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
This commit is contained in:
@@ -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
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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 <stdint.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
|
@@ -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_ */
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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 )
|
||||
{
|
||||
|
@@ -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,
|
||||
|
@@ -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 {
|
||||
|
@@ -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__)
|
||||
|
@@ -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),
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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 */
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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"
|
||||
|
||||
|
Reference in New Issue
Block a user