Make gallium compile in win32.

Use FREE, MALLOC, CALLOC, GETENV wrappers.
Silence compiler warnings.
Add proper copyrights.
This commit is contained in:
Michal Krol
2007-10-29 16:20:45 +00:00
parent d37eb130c0
commit ee295fccdd
27 changed files with 366 additions and 201 deletions

View File

@@ -42,7 +42,7 @@ struct draw_context *draw_create( void )
struct draw_context *draw = CALLOC_STRUCT( draw_context ); struct draw_context *draw = CALLOC_STRUCT( draw_context );
#if defined(__i386__) || defined(__386__) #if defined(__i386__) || defined(__386__)
draw->use_sse = getenv("GALLIUM_SSE") != NULL; draw->use_sse = GETENV( "GALLIUM_SSE" ) != NULL;
#else #else
draw->use_sse = FALSE; draw->use_sse = FALSE;
#endif #endif
@@ -71,7 +71,7 @@ struct draw_context *draw_create( void )
*/ */
{ {
int i; int i;
char *tmp = malloc(Elements(draw->vcache.vertex) * MAX_VERTEX_SIZE); char *tmp = MALLOC( Elements(draw->vcache.vertex) * MAX_VERTEX_SIZE );
for (i = 0; i < Elements(draw->vcache.vertex); i++) for (i = 0; i < Elements(draw->vcache.vertex); i++)
draw->vcache.vertex[i] = (struct vertex_header *)(tmp + i * MAX_VERTEX_SIZE); draw->vcache.vertex[i] = (struct vertex_header *)(tmp + i * MAX_VERTEX_SIZE);
@@ -92,8 +92,8 @@ struct draw_context *draw_create( void )
void draw_destroy( struct draw_context *draw ) void draw_destroy( struct draw_context *draw )
{ {
free( draw->vcache.vertex[0] ); /* Frees all the vertices. */ FREE( draw->vcache.vertex[0] ); /* Frees all the vertices. */
free( draw ); FREE( draw );
} }
@@ -233,10 +233,10 @@ void draw_alloc_tmps( struct draw_stage *stage, unsigned nr )
stage->nr_tmps = nr; stage->nr_tmps = nr;
if (nr) { if (nr) {
ubyte *store = (ubyte *) malloc(MAX_VERTEX_SIZE * nr); ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
unsigned i; unsigned i;
stage->tmp = (struct vertex_header **) malloc(sizeof(struct vertex_header *) * nr); stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
for (i = 0; i < nr; i++) for (i = 0; i < nr; i++)
stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE); stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
@@ -246,8 +246,8 @@ void draw_alloc_tmps( struct draw_stage *stage, unsigned nr )
void draw_free_tmps( struct draw_stage *stage ) void draw_free_tmps( struct draw_stage *stage )
{ {
if (stage->tmp) { if (stage->tmp) {
free(stage->tmp[0]); FREE( stage->tmp[0] );
free(stage->tmp); FREE( stage->tmp );
} }
} }

View File

@@ -64,16 +64,16 @@ fetch_attrib4(const void *ptr, unsigned format, float attrib[4])
break; break;
case PIPE_FORMAT_R32G32B32A32_SSCALED: case PIPE_FORMAT_R32G32B32A32_SSCALED:
attrib[3] = ((int *) ptr)[3]; attrib[3] = (float) ((int *) ptr)[3];
/* fall-through */ /* fall-through */
case PIPE_FORMAT_R32G32B32_SSCALED: case PIPE_FORMAT_R32G32B32_SSCALED:
attrib[2] = ((int *) ptr)[2]; attrib[2] = (float) ((int *) ptr)[2];
/* fall-through */ /* fall-through */
case PIPE_FORMAT_R32G32_SSCALED: case PIPE_FORMAT_R32G32_SSCALED:
attrib[1] = ((int *) ptr)[1]; attrib[1] = (float) ((int *) ptr)[1];
/* fall-through */ /* fall-through */
case PIPE_FORMAT_R32_SSCALED: case PIPE_FORMAT_R32_SSCALED:
attrib[0] = ((int *) ptr)[0]; attrib[0] = (float) ((int *) ptr)[0];
break; break;
default: default:

View File

@@ -42,7 +42,7 @@
#include "pipe/llvm/llvmtgsi.h" #include "pipe/llvm/llvmtgsi.h"
#define DBG 0 #define DBG_VS 0
static INLINE unsigned static INLINE unsigned
@@ -149,7 +149,7 @@ run_vertex_program(struct draw_context *draw,
vOut[j]->data[0][2] = z * scale[2] + trans[2]; vOut[j]->data[0][2] = z * scale[2] + trans[2];
vOut[j]->data[0][3] = w; vOut[j]->data[0][3] = w;
#if DBG #if DBG_VS
printf("output[%d]win: %f %f %f %f\n", j, printf("output[%d]win: %f %f %f %f\n", j,
vOut[j]->data[0][0], vOut[j]->data[0][0],
vOut[j]->data[0][1], vOut[j]->data[0][1],
@@ -166,7 +166,7 @@ run_vertex_program(struct draw_context *draw,
vOut[j]->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j]; vOut[j]->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
vOut[j]->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j]; vOut[j]->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j];
vOut[j]->data[slot][3] = machine->Outputs[slot].xyzw[3].f[j]; vOut[j]->data[slot][3] = machine->Outputs[slot].xyzw[3].f[j];
#if DBG #if DBG_VS
printf("output[%d][%d]: %f %f %f %f\n", j, slot, printf("output[%d][%d]: %f %f %f %f\n", j, slot,
vOut[j]->data[slot][0], vOut[j]->data[slot][0],
vOut[j]->data[slot][1], vOut[j]->data[slot][1],
@@ -222,7 +222,11 @@ draw_create_vertex_shader(struct draw_context *draw,
{ {
struct draw_vertex_shader *vs; struct draw_vertex_shader *vs;
vs = calloc( 1, sizeof( struct draw_vertex_shader ) ); vs = CALLOC_STRUCT( draw_vertex_shader );
if (vs == NULL) {
return NULL;
}
vs->state = shader; vs->state = shader;
#if defined(__i386__) || defined(__386__) #if defined(__i386__) || defined(__386__)
@@ -269,6 +273,5 @@ void draw_delete_vertex_shader(struct draw_context *draw,
x86_release_func( (struct x86_function *) &vs->sse2_program ); x86_release_func( (struct x86_function *) &vs->sse2_program );
#endif #endif
free( vs->state ); FREE( vs );
free( vs );
} }

View File

@@ -111,44 +111,44 @@ static void wide_line( struct draw_stage *stage,
if (dx > dy) { if (dx > dy) {
/* x-major line */ /* x-major line */
pos0[1] = pos0[1] - half_width - 0.25; pos0[1] = pos0[1] - half_width - 0.25f;
pos1[1] = pos1[1] + half_width - 0.25; pos1[1] = pos1[1] + half_width - 0.25f;
pos2[1] = pos2[1] - half_width - 0.25; pos2[1] = pos2[1] - half_width - 0.25f;
pos3[1] = pos3[1] + half_width - 0.25; pos3[1] = pos3[1] + half_width - 0.25f;
if (pos0[0] < pos2[0]) { if (pos0[0] < pos2[0]) {
/* left to right line */ /* left to right line */
pos0[0] -= 0.5; pos0[0] -= 0.5f;
pos1[0] -= 0.5; pos1[0] -= 0.5f;
pos2[0] -= 0.5; pos2[0] -= 0.5f;
pos3[0] -= 0.5; pos3[0] -= 0.5f;
} }
else { else {
/* right to left line */ /* right to left line */
pos0[0] += 0.5; pos0[0] += 0.5f;
pos1[0] += 0.5; pos1[0] += 0.5f;
pos2[0] += 0.5; pos2[0] += 0.5f;
pos3[0] += 0.5; pos3[0] += 0.5f;
} }
} }
else { else {
/* y-major line */ /* y-major line */
pos0[0] = pos0[0] - half_width + 0.25; pos0[0] = pos0[0] - half_width + 0.25f;
pos1[0] = pos1[0] + half_width + 0.25; pos1[0] = pos1[0] + half_width + 0.25f;
pos2[0] = pos2[0] - half_width + 0.25; pos2[0] = pos2[0] - half_width + 0.25f;
pos3[0] = pos3[0] + half_width + 0.25; pos3[0] = pos3[0] + half_width + 0.25f;
if (pos0[1] < pos2[1]) { if (pos0[1] < pos2[1]) {
/* top to bottom line */ /* top to bottom line */
pos0[1] -= 0.5; pos0[1] -= 0.5f;
pos1[1] -= 0.5; pos1[1] -= 0.5f;
pos2[1] -= 0.5; pos2[1] -= 0.5f;
pos3[1] -= 0.5; pos3[1] -= 0.5f;
} }
else { else {
/* bottom to top line */ /* bottom to top line */
pos0[1] += 0.5; pos0[1] += 0.5f;
pos1[1] += 0.5; pos1[1] += 0.5f;
pos2[1] += 0.5; pos2[1] += 0.5f;
pos3[1] += 0.5; pos3[1] += 0.5f;
} }
} }
@@ -179,7 +179,7 @@ static void set_texcoords(const struct wide_stage *wide,
uint j = wide->texcoord_slot[i]; uint j = wide->texcoord_slot[i];
v->data[j][0] = tc[0]; v->data[j][0] = tc[0];
if (wide->texcoord_mode[i] == PIPE_SPRITE_COORD_LOWER_LEFT) if (wide->texcoord_mode[i] == PIPE_SPRITE_COORD_LOWER_LEFT)
v->data[j][1] = 1.0 - tc[1]; v->data[j][1] = 1.0f - tc[1];
else else
v->data[j][1] = tc[1]; v->data[j][1] = tc[1];
v->data[j][2] = tc[2]; v->data[j][2] = tc[2];
@@ -198,7 +198,7 @@ static void wide_point( struct draw_stage *stage,
struct prim_header *header ) struct prim_header *header )
{ {
const struct wide_stage *wide = wide_stage(stage); const struct wide_stage *wide = wide_stage(stage);
const boolean sprite = stage->draw->rasterizer->point_sprite; const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
float half_size; float half_size;
float left_adj, right_adj; float left_adj, right_adj;
@@ -223,8 +223,8 @@ static void wide_point( struct draw_stage *stage,
half_size = wide->half_point_size; half_size = wide->half_point_size;
} }
left_adj = -half_size + 0.25; left_adj = -half_size + 0.25f;
right_adj = half_size + 0.25; right_adj = half_size + 0.25f;
pos0[0] += left_adj; pos0[0] += left_adj;
pos0[1] -= half_size; pos0[1] -= half_size;
@@ -267,8 +267,8 @@ static void wide_begin( struct draw_stage *stage )
struct wide_stage *wide = wide_stage(stage); struct wide_stage *wide = wide_stage(stage);
struct draw_context *draw = stage->draw; struct draw_context *draw = stage->draw;
wide->half_point_size = 0.5 * draw->rasterizer->point_size; wide->half_point_size = 0.5f * draw->rasterizer->point_size;
wide->half_line_width = 0.5 * draw->rasterizer->line_width; wide->half_line_width = 0.5f * draw->rasterizer->line_width;
if (draw->rasterizer->line_width != 1.0) { if (draw->rasterizer->line_width != 1.0) {
wide->stage.line = wide_line; wide->stage.line = wide_line;

View File

@@ -29,7 +29,7 @@
#define PIPE_CONTEXT_H #define PIPE_CONTEXT_H
#include "p_state.h" #include "p_state.h"
#include "p_compiler.h" #include "p_util.h"
struct pipe_state_cache; struct pipe_state_cache;
/** /**
@@ -265,7 +265,7 @@ pipe_region_reference(struct pipe_region **ptr, struct pipe_region *region)
/* free the old region */ /* free the old region */
assert(oldReg->map_refcount == 0); assert(oldReg->map_refcount == 0);
/* XXX dereference the region->buffer */ /* XXX dereference the region->buffer */
free(oldReg); FREE( oldReg );
} }
*ptr = NULL; *ptr = NULL;
} }
@@ -292,7 +292,7 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
if (oldSurf->refcount == 0) { if (oldSurf->refcount == 0) {
/* free the old region */ /* free the old region */
pipe_region_reference(&oldSurf->region, NULL); pipe_region_reference(&oldSurf->region, NULL);
free(oldSurf); FREE( oldSurf );
} }
*ptr = NULL; *ptr = NULL;
} }

View File

@@ -1,28 +1,29 @@
/**************************************************************************
/*
* Mesa 3-D graphics library
* Version: 6.5.2
* *
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the
* to deal in the Software without restriction, including without limitation * "Software"), to deal in the Software without restriction, including
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * without limitation the rights to use, copy, modify, merge, publish,
* and/or sell copies of the Software, and to permit persons to whom the * distribute, sub license, and/or sell copies of the Software, and to
* Software is furnished to do so, subject to the following conditions: * 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 * The above copyright notice and this permission notice (including the
* in all copies or substantial portions of the Software. * 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 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
*/ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef P_UTIL_H #ifndef P_UTIL_H
#define P_UTIL_H #define P_UTIL_H
@@ -30,12 +31,84 @@
#include "p_compiler.h" #include "p_compiler.h"
#include <math.h> #include <math.h>
#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) #ifdef WIN32
#ifdef __cplusplus
extern "C"
{
#endif
void * __stdcall
EngAllocMem(
unsigned long Flags,
unsigned long MemSize,
unsigned long Tag );
void __stdcall
EngFreeMem(
void *Mem );
#ifdef __cplusplus
}
#endif
static INLINE void *
MALLOC( unsigned size )
{
return EngAllocMem( 0, size, 'D3AG' );
}
static INLINE void *
CALLOC( unsigned count, unsigned size )
{
void *ptr = MALLOC( count * size );
if( ptr ) {
memset( ptr, 0, count * size );
}
return ptr;
}
static INLINE void
FREE( void *ptr )
{
if( ptr ) {
EngFreeMem( ptr );
}
}
static INLINE void *
REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
{
void *new_ptr;
if( new_size <= old_size ) {
return old_ptr;
}
new_ptr = MALLOC( new_size );
if( new_ptr ) {
memcpy( new_ptr, old_ptr, old_size );
}
FREE( old_ptr );
return new_ptr;
}
#define GETENV( X ) NULL
#else // WIN32
#define MALLOC( SIZE ) malloc( SIZE ) #define MALLOC( SIZE ) malloc( SIZE )
#define CALLOC( COUNT, SIZE ) calloc( COUNT, SIZE )
#define FREE( PTR ) free( PTR ) #define FREE( PTR ) free( PTR )
#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE ) realloc( OLDPTR, NEWSIZE )
#define GETENV( X ) getenv( X )
#endif // WIN32
#define CALLOC_STRUCT(T) (struct T *) CALLOC(1, sizeof(struct T))
#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) #define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) ) #define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) ) #define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
@@ -221,5 +294,10 @@ static INLINE float LOG2(float val)
return num.f + log_2; return num.f + log_2;
} }
#if defined(__GNUC__)
#define CEILF(x) ceilf(x)
#else
#define CEILF(x) ((float) ceil(x))
#endif
#endif #endif

View File

@@ -72,10 +72,10 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
} }
else if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[0])) { else if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[0])) {
float clear[4]; float clear[4];
clear[0] = 0.2; /* XXX hack */ clear[0] = 0.2f; /* XXX hack */
clear[1] = 0.2; /* XXX hack */ clear[1] = 0.2f; /* XXX hack */
clear[2] = 0.2; /* XXX hack */ clear[2] = 0.2f; /* XXX hack */
clear[3] = 0.2; /* XXX hack */ clear[3] = 0.2f; /* XXX hack */
sp_tile_cache_clear(softpipe->cbuf_cache[0], clear); sp_tile_cache_clear(softpipe->cbuf_cache[0], clear);
} }

View File

@@ -289,12 +289,12 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
uint i; uint i;
#if defined(__i386__) || defined(__386__) #if defined(__i386__) || defined(__386__)
softpipe->use_sse = getenv("GALLIUM_SSE") != NULL; softpipe->use_sse = GETENV( "GALLIUM_SSE" ) != NULL;
#else #else
softpipe->use_sse = FALSE; softpipe->use_sse = FALSE;
#endif #endif
softpipe->dump_fs = getenv( "GALLIUM_DUMP_FS" ) != NULL; softpipe->dump_fs = GETENV( "GALLIUM_DUMP_FS" ) != NULL;
softpipe->pipe.winsys = pipe_winsys; softpipe->pipe.winsys = pipe_winsys;
softpipe->pipe.destroy = softpipe_destroy; softpipe->pipe.destroy = softpipe_destroy;
@@ -396,7 +396,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
assert(softpipe->draw); assert(softpipe->draw);
softpipe->setup = sp_draw_render_stage(softpipe); softpipe->setup = sp_draw_render_stage(softpipe);
if (getenv("SP_VBUF")) { if (GETENV( "SP_VBUF" ) != NULL) {
softpipe->vbuf = sp_draw_vbuf_stage(softpipe->draw, softpipe->vbuf = sp_draw_vbuf_stage(softpipe->draw,
&softpipe->pipe, &softpipe->pipe,
sp_vbuf_setup_draw); sp_vbuf_setup_draw);

View File

@@ -31,7 +31,6 @@
#ifndef SP_CONTEXT_H #ifndef SP_CONTEXT_H
#define SP_CONTEXT_H #define SP_CONTEXT_H
#include "pipe/p_state.h"
#include "pipe/p_context.h" #include "pipe/p_context.h"
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
@@ -63,7 +62,7 @@ struct softpipe_tile_cache;
#define SP_NEW_CONSTANTS 0x4000 #define SP_NEW_CONSTANTS 0x4000
struct sp_vertex_shader_state { struct sp_vertex_shader_state {
const struct pipe_shader_state *state; struct pipe_shader_state *state;
void *draw_data; void *draw_data;
}; };

View File

@@ -34,7 +34,6 @@
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
#include "pipe/p_context.h" #include "pipe/p_context.h"
#include "pipe/p_winsys.h" #include "pipe/p_winsys.h"
#include "pipe/p_util.h"
#include "sp_context.h" #include "sp_context.h"
#include "sp_state.h" #include "sp_state.h"

View File

@@ -516,18 +516,18 @@ static void setup_tri_edges( struct setup_stage *setup )
float vmid_y = setup->vmid->data[0][1] - 0.5f; float vmid_y = setup->vmid->data[0][1] - 0.5f;
float vmax_y = setup->vmax->data[0][1] - 0.5f; float vmax_y = setup->vmax->data[0][1] - 0.5f;
setup->emaj.sy = ceilf(vmin_y); setup->emaj.sy = CEILF(vmin_y);
setup->emaj.lines = (int) ceilf(vmax_y - setup->emaj.sy); setup->emaj.lines = (int) CEILF(vmax_y - setup->emaj.sy);
setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy; setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy;
setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy; setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy;
setup->etop.sy = ceilf(vmid_y); setup->etop.sy = CEILF(vmid_y);
setup->etop.lines = (int) ceilf(vmax_y - setup->etop.sy); setup->etop.lines = (int) CEILF(vmax_y - setup->etop.sy);
setup->etop.dxdy = setup->etop.dx / setup->etop.dy; setup->etop.dxdy = setup->etop.dx / setup->etop.dy;
setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy; setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy;
setup->ebot.sy = ceilf(vmin_y); setup->ebot.sy = CEILF(vmin_y);
setup->ebot.lines = (int) ceilf(vmid_y - setup->ebot.sy); setup->ebot.lines = (int) CEILF(vmid_y - setup->ebot.sy);
setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy; setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy;
setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy; setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy;
} }
@@ -934,7 +934,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
= sizeAttr > 0 ? v0->data[sizeAttr][0] = sizeAttr > 0 ? v0->data[sizeAttr][0]
: setup->softpipe->rasterizer->point_size; : setup->softpipe->rasterizer->point_size;
const float halfSize = 0.5F * size; const float halfSize = 0.5F * size;
const boolean round = setup->softpipe->rasterizer->point_smooth; const boolean round = (boolean) setup->softpipe->rasterizer->point_smooth;
const float x = v0->data[0][0]; /* Note: data[0] is always position */ const float x = v0->data[0][0]; /* Note: data[0] is always position */
const float y = v0->data[0][1]; const float y = v0->data[0][1];
unsigned slot, j; unsigned slot, j;

View File

@@ -295,8 +295,8 @@ struct draw_stage *sp_draw_vbuf_stage( struct draw_context *draw_context,
vbuf->draw = draw; vbuf->draw = draw;
vbuf->draw_context = draw_context; vbuf->draw_context = draw_context;
vbuf->element_map = malloc( IBUF_SIZE ); vbuf->element_map = MALLOC( IBUF_SIZE );
vbuf->vertex_map = malloc( VBUF_SIZE ); vbuf->vertex_map = MALLOC( VBUF_SIZE );
vbuf->vertex_ptr = vbuf->vertex_map; vbuf->vertex_ptr = vbuf->vertex_map;

View File

@@ -1,26 +1,29 @@
/* /**************************************************************************
* Mesa 3-D graphics library
* Version: 6.5
* *
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved. * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the
* to deal in the Software without restriction, including without limitation * "Software"), to deal in the Software without restriction, including
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * without limitation the rights to use, copy, modify, merge, publish,
* and/or sell copies of the Software, and to permit persons to whom the * distribute, sub license, and/or sell copies of the Software, and to
* Software is furnished to do so, subject to the following conditions: * 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 * The above copyright notice and this permission notice (including the
* in all copies or substantial portions of the Software. * 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 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
*/ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
/** /**
* \brief Quad depth testing * \brief Quad depth testing
@@ -188,7 +191,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
for (j = 0; j < QUAD_SIZE; j++) { for (j = 0; j < QUAD_SIZE; j++) {
int x = quad->x0 % TILE_SIZE + (j & 1); int x = quad->x0 % TILE_SIZE + (j & 1);
int y = quad->y0 % TILE_SIZE + (j >> 1); int y = quad->y0 % TILE_SIZE + (j >> 1);
tile->data.depth16[y][x] = bzzzz[j]; tile->data.depth16[y][x] = (ushort) bzzzz[j];
} }
break; break;
case PIPE_FORMAT_U_Z32: case PIPE_FORMAT_U_Z32:

View File

@@ -1,26 +1,29 @@
/* /**************************************************************************
* Mesa 3-D graphics library
* Version: 6.5
* *
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved. * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the
* to deal in the Software without restriction, including without limitation * "Software"), to deal in the Software without restriction, including
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * without limitation the rights to use, copy, modify, merge, publish,
* and/or sell copies of the Software, and to permit persons to whom the * distribute, sub license, and/or sell copies of the Software, and to
* Software is furnished to do so, subject to the following conditions: * 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 * The above copyright notice and this permission notice (including the
* in all copies or substantial portions of the Software. * 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 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 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 /* Vertices are just an array of floats, with all the attributes
* packed. We currently assume a layout like: * packed. We currently assume a layout like:
@@ -35,8 +38,6 @@
#include "pipe/p_util.h" #include "pipe/p_util.h"
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
#include "pipe/llvm/llvmtgsi.h"
#include "x86/rtasm/x86sse.h" #include "x86/rtasm/x86sse.h"
#include "sp_context.h" #include "sp_context.h"

View File

@@ -207,7 +207,7 @@ sp_region_fill(struct pipe_context *pipe,
ushort *row = (ushort *) get_pointer(dst, dstx, dsty); ushort *row = (ushort *) get_pointer(dst, dstx, dsty);
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
row[j] = value; row[j] = (ushort) value;
row += dst->pitch; row += dst->pitch;
} }
} }

View File

@@ -34,7 +34,7 @@ void *
softpipe_create_blend_state(struct pipe_context *pipe, softpipe_create_blend_state(struct pipe_context *pipe,
const struct pipe_blend_state *blend) const struct pipe_blend_state *blend)
{ {
struct pipe_blend_state *state = malloc(sizeof(struct pipe_blend_state)); struct pipe_blend_state *state = MALLOC( sizeof(struct pipe_blend_state) );
memcpy(state, blend, sizeof(struct pipe_blend_state)); memcpy(state, blend, sizeof(struct pipe_blend_state));
return state; return state;
} }
@@ -52,7 +52,7 @@ void softpipe_bind_blend_state( struct pipe_context *pipe,
void softpipe_delete_blend_state(struct pipe_context *pipe, void softpipe_delete_blend_state(struct pipe_context *pipe,
void *blend) void *blend)
{ {
free(blend); FREE( blend );
} }
@@ -75,7 +75,7 @@ void *
softpipe_create_alpha_test_state(struct pipe_context *pipe, softpipe_create_alpha_test_state(struct pipe_context *pipe,
const struct pipe_alpha_test_state *alpha) const struct pipe_alpha_test_state *alpha)
{ {
struct pipe_alpha_test_state *state = malloc(sizeof(struct pipe_alpha_test_state)); struct pipe_alpha_test_state *state = MALLOC( sizeof(struct pipe_alpha_test_state) );
memcpy(state, alpha, sizeof(struct pipe_alpha_test_state)); memcpy(state, alpha, sizeof(struct pipe_alpha_test_state));
return state; return state;
} }
@@ -95,7 +95,7 @@ void
softpipe_delete_alpha_test_state(struct pipe_context *pipe, softpipe_delete_alpha_test_state(struct pipe_context *pipe,
void *alpha) void *alpha)
{ {
free(alpha); FREE( alpha );
} }
void * void *
@@ -103,7 +103,7 @@ softpipe_create_depth_stencil_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_state *depth_stencil) const struct pipe_depth_stencil_state *depth_stencil)
{ {
struct pipe_depth_stencil_state *state = struct pipe_depth_stencil_state *state =
malloc(sizeof(struct pipe_depth_stencil_state)); MALLOC( sizeof(struct pipe_depth_stencil_state) );
memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_state)); memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_state));
return state; return state;
} }
@@ -122,5 +122,5 @@ softpipe_bind_depth_stencil_state(struct pipe_context *pipe,
void void
softpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth) softpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth)
{ {
free(depth); FREE( depth );
} }

View File

@@ -29,6 +29,7 @@
#include "sp_state.h" #include "sp_state.h"
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "pipe/p_winsys.h" #include "pipe/p_winsys.h"
#include "pipe/draw/draw_context.h" #include "pipe/draw/draw_context.h"
#include "pipe/tgsi/exec/tgsi_core.h" #include "pipe/tgsi/exec/tgsi_core.h"
@@ -43,7 +44,7 @@ void * softpipe_create_fs_state(struct pipe_context *pipe,
* that now. * that now.
*/ */
struct sp_fragment_shader_state *state = malloc(sizeof(struct sp_fragment_shader_state)); struct sp_fragment_shader_state *state = MALLOC( sizeof(struct sp_fragment_shader_state) );
state->shader = *templ; state->shader = *templ;
if( softpipe->dump_fs ) { if( softpipe->dump_fs ) {
@@ -80,7 +81,7 @@ void softpipe_delete_fs_state(struct pipe_context *pipe,
x86_release_func( &state->sse2_program ); x86_release_func( &state->sse2_program );
#endif #endif
free( state ); FREE( state );
} }
@@ -88,15 +89,27 @@ void * softpipe_create_vs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ) const struct pipe_shader_state *templ)
{ {
struct softpipe_context *softpipe = softpipe_context(pipe); struct softpipe_context *softpipe = softpipe_context(pipe);
struct sp_vertex_shader_state *state = struct sp_vertex_shader_state *state;
malloc(sizeof(struct sp_vertex_shader_state));
struct pipe_shader_state *templ_copy = state = MALLOC( sizeof(struct sp_vertex_shader_state) );
malloc(sizeof(struct pipe_shader_state)); if (state == NULL ) {
memcpy(templ_copy, templ, sizeof(struct pipe_shader_state)); return NULL;
}
state->state = MALLOC( sizeof(struct pipe_shader_state) );
if (state->state == NULL) {
FREE( state );
return NULL;
}
memcpy( state->state, templ, sizeof(struct pipe_shader_state) );
state->state = templ_copy;
state->draw_data = draw_create_vertex_shader(softpipe->draw, state->draw_data = draw_create_vertex_shader(softpipe->draw,
state->state); state->state);
if (state->draw_data == NULL) {
FREE( state->state );
FREE( state );
return NULL;
}
return state; return state;
} }
@@ -121,8 +134,8 @@ void softpipe_delete_vs_state(struct pipe_context *pipe,
(struct sp_vertex_shader_state *)vs; (struct sp_vertex_shader_state *)vs;
draw_delete_vertex_shader(softpipe->draw, state->draw_data); draw_delete_vertex_shader(softpipe->draw, state->draw_data);
free(state->state); FREE( state->state );
free(state); FREE( state );
} }

View File

@@ -1,6 +1,6 @@
/************************************************************************** /**************************************************************************
* *
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved. * All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@@ -37,7 +37,7 @@ softpipe_create_rasterizer_state(struct pipe_context *pipe,
const struct pipe_rasterizer_state *setup) const struct pipe_rasterizer_state *setup)
{ {
struct pipe_rasterizer_state *state = struct pipe_rasterizer_state *state =
malloc(sizeof(struct pipe_rasterizer_state)); MALLOC( sizeof(struct pipe_rasterizer_state) );
memcpy(state, setup, sizeof(struct pipe_rasterizer_state)); memcpy(state, setup, sizeof(struct pipe_rasterizer_state));
return state; return state;
} }
@@ -58,7 +58,7 @@ void softpipe_bind_rasterizer_state(struct pipe_context *pipe,
void softpipe_delete_rasterizer_state(struct pipe_context *pipe, void softpipe_delete_rasterizer_state(struct pipe_context *pipe,
void *rasterizer) void *rasterizer)
{ {
free(rasterizer); FREE( rasterizer );
} }

View File

@@ -38,7 +38,7 @@ void *
softpipe_create_sampler_state(struct pipe_context *pipe, softpipe_create_sampler_state(struct pipe_context *pipe,
const struct pipe_sampler_state *sampler) const struct pipe_sampler_state *sampler)
{ {
struct pipe_sampler_state *state = malloc(sizeof(struct pipe_sampler_state)); struct pipe_sampler_state *state = MALLOC( sizeof(struct pipe_sampler_state) );
memcpy(state, sampler, sizeof(struct pipe_sampler_state)); memcpy(state, sampler, sizeof(struct pipe_sampler_state));
return state; return state;
} }
@@ -60,7 +60,7 @@ void
softpipe_delete_sampler_state(struct pipe_context *pipe, softpipe_delete_sampler_state(struct pipe_context *pipe,
void *sampler) void *sampler)
{ {
free(sampler); FREE( sampler );
} }

View File

@@ -1,6 +1,6 @@
/************************************************************************** /**************************************************************************
* *
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved. * All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@@ -172,7 +172,7 @@ z16_get_tile(struct pipe_surface *ps,
const ushort *src const ushort *src
= ((const ushort *) (ps->region->map + ps->offset)) = ((const ushort *) (ps->region->map + ps->offset))
+ y * ps->region->pitch + x; + y * ps->region->pitch + x;
const float scale = 1.0 / 65535.0; const float scale = 1.0f / 65535.0f;
unsigned i, j; unsigned i, j;
unsigned w0 = w; unsigned w0 = w;
@@ -418,7 +418,7 @@ z32_get_tile(struct pipe_surface *ps,
pRow[j * 4 + 0] = pRow[j * 4 + 0] =
pRow[j * 4 + 1] = pRow[j * 4 + 1] =
pRow[j * 4 + 2] = pRow[j * 4 + 2] =
pRow[j * 4 + 3] = src[j] * scale; pRow[j * 4 + 3] = (float) (scale * src[j]);
} }
src += ps->region->pitch; src += ps->region->pitch;
p += 4 * w0; p += 4 * w0;
@@ -452,7 +452,7 @@ s8z24_get_tile(struct pipe_surface *ps,
pRow[j * 4 + 0] = pRow[j * 4 + 0] =
pRow[j * 4 + 1] = pRow[j * 4 + 1] =
pRow[j * 4 + 2] = pRow[j * 4 + 2] =
pRow[j * 4 + 3] = (src[j] & 0xffffff) * scale; pRow[j * 4 + 3] = (float) (scale * (src[j] & 0xffffff));
} }
src += ps->region->pitch; src += ps->region->pitch;
p += 4 * w0; p += 4 * w0;

View File

@@ -30,10 +30,8 @@
* Michel Dänzer <michel@tungstengraphics.com> * Michel Dänzer <michel@tungstengraphics.com>
*/ */
#include "pipe/p_state.h"
#include "pipe/p_context.h" #include "pipe/p_context.h"
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "sp_tex_layout.h" #include "sp_tex_layout.h"
@@ -76,14 +74,14 @@ sp_miptree_set_level_info(struct pipe_mipmap_tree *mt,
/* Not sure when this would happen, but anyway: /* Not sure when this would happen, but anyway:
*/ */
if (mt->level[level].image_offset) { if (mt->level[level].image_offset) {
free(mt->level[level].image_offset); FREE( mt->level[level].image_offset );
mt->level[level].image_offset = NULL; mt->level[level].image_offset = NULL;
} }
assert(nr_images); assert(nr_images);
assert(!mt->level[level].image_offset); assert(!mt->level[level].image_offset);
mt->level[level].image_offset = (unsigned *) malloc(nr_images * sizeof(unsigned)); mt->level[level].image_offset = (unsigned *) MALLOC( nr_images * sizeof(unsigned) );
mt->level[level].image_offset[0] = 0; mt->level[level].image_offset[0] = 0;
} }

View File

@@ -39,7 +39,6 @@
#include "sp_tile_cache.h" #include "sp_tile_cache.h"
#include "pipe/p_context.h" #include "pipe/p_context.h"
#include "pipe/p_defines.h" #include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "pipe/tgsi/exec/tgsi_exec.h" #include "pipe/tgsi/exec/tgsi_exec.h"
@@ -580,7 +579,7 @@ sp_get_samples_2d_common(struct tgsi_sampler *sampler,
height = sampler->texture->level[level0].height; height = sampler->texture->level[level0].height;
} }
else { else {
width = height = 1.0; width = height = 1;
} }
assert(width > 0); assert(width > 0);
@@ -697,7 +696,7 @@ sp_get_samples_3d(struct tgsi_sampler *sampler,
depth = sampler->texture->level[level0].depth; depth = sampler->texture->level[level0].depth;
} }
else { else {
width = height = depth = 1.0; width = height = depth = 1;
} }
assert(width > 0); assert(width > 0);

View File

@@ -99,7 +99,7 @@ sp_create_tile_cache(void)
struct softpipe_tile_cache *tc; struct softpipe_tile_cache *tc;
uint pos; uint pos;
tc = calloc(1, sizeof(*tc)); tc = CALLOC_STRUCT( softpipe_tile_cache );
if (tc) { if (tc) {
for (pos = 0; pos < NUM_ENTRIES; pos++) { for (pos = 0; pos < NUM_ENTRIES; pos++) {
tc->entries[pos].x = tc->entries[pos].x =
@@ -117,7 +117,7 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
for (pos = 0; pos < NUM_ENTRIES; pos++) { for (pos = 0; pos < NUM_ENTRIES; pos++) {
assert(tc->entries[pos].x < 0); assert(tc->entries[pos].x < 0);
} }
free(tc); FREE( tc );
} }

View File

@@ -1,3 +1,30 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "tgsi_platform.h" #include "tgsi_platform.h"
#include "tgsi_core.h" #include "tgsi_core.h"
@@ -7,15 +34,6 @@ struct text_dump
unsigned tabs; unsigned tabs;
}; };
static void
text_dump_write(
struct text_dump *dump,
const void *buffer,
unsigned size )
{
fwrite( buffer, size, 1, dump->file );
}
static void static void
text_dump_str( text_dump_str(
struct text_dump *dump, struct text_dump *dump,
@@ -25,13 +43,13 @@ text_dump_str(
size_t len = strlen( str ); size_t len = strlen( str );
for( i = 0; i < len; i++ ) { for( i = 0; i < len; i++ ) {
text_dump_write( dump, &str[i], 1 ); fprintf( dump->file, "%c", str[i] );
if( str[i] == '\n' ) { if( str[i] == '\n' ) {
unsigned i; unsigned i;
for( i = 0; i < dump->tabs; i++ ) { for( i = 0; i < dump->tabs; i++ ) {
text_dump_write( dump, " ", 4 ); fprintf( dump->file, " " );
} }
} }
} }
@@ -1434,9 +1452,5 @@ tgsi_dump(
TXT( "\ntgsi-dump end -------------------\n" ); TXT( "\ntgsi-dump end -------------------\n" );
tgsi_parse_free( &parse ); tgsi_parse_free( &parse );
if (dump->file != stderr &&
dump->file != stdout)
fclose( dump->file );
} }

View File

@@ -133,10 +133,10 @@ tgsi_exec_prepare( struct tgsi_exec_machine *mach )
labels->count = 0; labels->count = 0;
declarations = (struct tgsi_full_declaration *) declarations = (struct tgsi_full_declaration *)
malloc(maxDeclarations * sizeof(struct tgsi_full_declaration)); MALLOC( maxDeclarations * sizeof(struct tgsi_full_declaration) );
instructions = (struct tgsi_full_instruction *) instructions = (struct tgsi_full_instruction *)
malloc(maxInstructions * sizeof(struct tgsi_full_instruction)); MALLOC( maxInstructions * sizeof(struct tgsi_full_instruction) );
k = tgsi_parse_init( &parse, mach->Tokens ); k = tgsi_parse_init( &parse, mach->Tokens );
if (k != TGSI_PARSE_OK) { if (k != TGSI_PARSE_OK) {
@@ -153,10 +153,12 @@ tgsi_exec_prepare( struct tgsi_exec_machine *mach )
case TGSI_TOKEN_TYPE_DECLARATION: case TGSI_TOKEN_TYPE_DECLARATION:
/* save expanded declaration */ /* save expanded declaration */
if (numDeclarations == maxDeclarations) { if (numDeclarations == maxDeclarations) {
maxDeclarations += 10; declarations = REALLOC(declarations,
declarations = realloc(declarations,
maxDeclarations maxDeclarations
* sizeof(struct tgsi_full_instruction),
(maxDeclarations + 10)
* sizeof(struct tgsi_full_instruction)); * sizeof(struct tgsi_full_instruction));
maxDeclarations += 10;
} }
memcpy(declarations + numDeclarations, memcpy(declarations + numDeclarations,
&parse.FullToken.FullInstruction, &parse.FullToken.FullInstruction,
@@ -186,10 +188,12 @@ tgsi_exec_prepare( struct tgsi_exec_machine *mach )
/* save expanded instruction */ /* save expanded instruction */
if (numInstructions == maxInstructions) { if (numInstructions == maxInstructions) {
maxInstructions += 10; instructions = REALLOC(instructions,
instructions = realloc(instructions,
maxInstructions maxInstructions
* sizeof(struct tgsi_full_instruction),
(maxInstructions + 10)
* sizeof(struct tgsi_full_instruction)); * sizeof(struct tgsi_full_instruction));
maxInstructions += 10;
} }
memcpy(instructions + numInstructions, memcpy(instructions + numInstructions,
&parse.FullToken.FullInstruction, &parse.FullToken.FullInstruction,
@@ -204,13 +208,13 @@ tgsi_exec_prepare( struct tgsi_exec_machine *mach )
tgsi_parse_free (&parse); tgsi_parse_free (&parse);
if (mach->Declarations) { if (mach->Declarations) {
free(mach->Declarations); FREE( mach->Declarations );
} }
mach->Declarations = declarations; mach->Declarations = declarations;
mach->NumDeclarations = numDeclarations; mach->NumDeclarations = numDeclarations;
if (mach->Instructions) { if (mach->Instructions) {
free(mach->Instructions); FREE( mach->Instructions );
} }
mach->Instructions = instructions; mach->Instructions = instructions;
mach->NumInstructions = numInstructions; mach->NumInstructions = numInstructions;
@@ -242,7 +246,7 @@ tgsi_exec_machine_init(
k = tgsi_parse_init (&parse, mach->Tokens); k = tgsi_parse_init (&parse, mach->Tokens);
if (k != TGSI_PARSE_OK) { if (k != TGSI_PARSE_OK) {
printf("Problem parsing!\n"); fprintf( stderr, "Problem parsing!\n" );
return; return;
} }

View File

@@ -1,3 +1,30 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "tgsi_platform.h" #include "tgsi_platform.h"
#include "tgsi_core.h" #include "tgsi_core.h"
@@ -13,7 +40,7 @@ tgsi_full_token_free(
union tgsi_full_token *full_token ) union tgsi_full_token *full_token )
{ {
if( full_token->Token.Type == TGSI_TOKEN_TYPE_IMMEDIATE ) { if( full_token->Token.Type == TGSI_TOKEN_TYPE_IMMEDIATE ) {
free( full_token->FullImmediate.u.Pointer ); FREE( full_token->FullImmediate.u.Pointer );
} }
} }
@@ -123,7 +150,7 @@ tgsi_parse_token(
switch (imm->Immediate.DataType) { switch (imm->Immediate.DataType) {
case TGSI_IMM_FLOAT32: case TGSI_IMM_FLOAT32:
imm->u.Pointer = malloc( imm->u.Pointer = MALLOC(
sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.Size - 1) ); sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.Size - 1) );
for( i = 0; i < imm->Immediate.Size - 1; i++ ) { for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
next_token( ctx, &imm->u.ImmediateFloat32[i] ); next_token( ctx, &imm->u.ImmediateFloat32[i] );

View File

@@ -1,3 +1,30 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "tgsi_platform.h" #include "tgsi_platform.h"
#include "tgsi_core.h" #include "tgsi_core.h"
#include "x86/rtasm/x86sse.h" #include "x86/rtasm/x86sse.h"
@@ -465,7 +492,7 @@ emit_shufps(
struct x86_function *func, struct x86_function *func,
struct x86_reg dst, struct x86_reg dst,
struct x86_reg src, struct x86_reg src,
unsigned shuf ) unsigned char shuf )
{ {
DUMP_RRI( "SHUFPS", dst, src, shuf ); DUMP_RRI( "SHUFPS", dst, src, shuf );
sse_shufps( func, dst, src, shuf ); sse_shufps( func, dst, src, shuf );