Use FREE, MALLOC, CALLOC, GETENV wrappers.
Silence compiler warnings.
Add proper copyrights.
struct draw_context *draw = CALLOC_STRUCT( draw_context );
#if defined(__i386__) || defined(__386__)
- draw->use_sse = getenv("GALLIUM_SSE") != NULL;
+ draw->use_sse = GETENV( "GALLIUM_SSE" ) != NULL;
#else
draw->use_sse = FALSE;
#endif
*/
{
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++)
draw->vcache.vertex[i] = (struct vertex_header *)(tmp + i * MAX_VERTEX_SIZE);
void draw_destroy( struct draw_context *draw )
{
- free( draw->vcache.vertex[0] ); /* Frees all the vertices. */
- free( draw );
+ FREE( draw->vcache.vertex[0] ); /* Frees all the vertices. */
+ FREE( draw );
}
stage->nr_tmps = nr;
if (nr) {
- ubyte *store = (ubyte *) malloc(MAX_VERTEX_SIZE * nr);
+ ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
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++)
stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
void draw_free_tmps( struct draw_stage *stage )
{
if (stage->tmp) {
- free(stage->tmp[0]);
- free(stage->tmp);
+ FREE( stage->tmp[0] );
+ FREE( stage->tmp );
}
}
break;
case PIPE_FORMAT_R32G32B32A32_SSCALED:
- attrib[3] = ((int *) ptr)[3];
+ attrib[3] = (float) ((int *) ptr)[3];
/* fall-through */
case PIPE_FORMAT_R32G32B32_SSCALED:
- attrib[2] = ((int *) ptr)[2];
+ attrib[2] = (float) ((int *) ptr)[2];
/* fall-through */
case PIPE_FORMAT_R32G32_SSCALED:
- attrib[1] = ((int *) ptr)[1];
+ attrib[1] = (float) ((int *) ptr)[1];
/* fall-through */
case PIPE_FORMAT_R32_SSCALED:
- attrib[0] = ((int *) ptr)[0];
+ attrib[0] = (float) ((int *) ptr)[0];
break;
default:
#include "pipe/llvm/llvmtgsi.h"
-#define DBG 0
+#define DBG_VS 0
static INLINE unsigned
vOut[j]->data[0][2] = z * scale[2] + trans[2];
vOut[j]->data[0][3] = w;
-#if DBG
+#if DBG_VS
printf("output[%d]win: %f %f %f %f\n", j,
vOut[j]->data[0][0],
vOut[j]->data[0][1],
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][3] = machine->Outputs[slot].xyzw[3].f[j];
-#if DBG
+#if DBG_VS
printf("output[%d][%d]: %f %f %f %f\n", j, slot,
vOut[j]->data[slot][0],
vOut[j]->data[slot][1],
{
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;
#if defined(__i386__) || defined(__386__)
x86_release_func( (struct x86_function *) &vs->sse2_program );
#endif
- free( vs->state );
- free( vs );
+ FREE( vs );
}
if (dx > dy) {
/* x-major line */
- pos0[1] = pos0[1] - half_width - 0.25;
- pos1[1] = pos1[1] + half_width - 0.25;
- pos2[1] = pos2[1] - half_width - 0.25;
- pos3[1] = pos3[1] + half_width - 0.25;
+ pos0[1] = pos0[1] - half_width - 0.25f;
+ pos1[1] = pos1[1] + half_width - 0.25f;
+ pos2[1] = pos2[1] - half_width - 0.25f;
+ pos3[1] = pos3[1] + half_width - 0.25f;
if (pos0[0] < pos2[0]) {
/* left to right line */
- pos0[0] -= 0.5;
- pos1[0] -= 0.5;
- pos2[0] -= 0.5;
- pos3[0] -= 0.5;
+ pos0[0] -= 0.5f;
+ pos1[0] -= 0.5f;
+ pos2[0] -= 0.5f;
+ pos3[0] -= 0.5f;
}
else {
/* right to left line */
- pos0[0] += 0.5;
- pos1[0] += 0.5;
- pos2[0] += 0.5;
- pos3[0] += 0.5;
+ pos0[0] += 0.5f;
+ pos1[0] += 0.5f;
+ pos2[0] += 0.5f;
+ pos3[0] += 0.5f;
}
}
else {
/* y-major line */
- pos0[0] = pos0[0] - half_width + 0.25;
- pos1[0] = pos1[0] + half_width + 0.25;
- pos2[0] = pos2[0] - half_width + 0.25;
- pos3[0] = pos3[0] + half_width + 0.25;
+ pos0[0] = pos0[0] - half_width + 0.25f;
+ pos1[0] = pos1[0] + half_width + 0.25f;
+ pos2[0] = pos2[0] - half_width + 0.25f;
+ pos3[0] = pos3[0] + half_width + 0.25f;
if (pos0[1] < pos2[1]) {
/* top to bottom line */
- pos0[1] -= 0.5;
- pos1[1] -= 0.5;
- pos2[1] -= 0.5;
- pos3[1] -= 0.5;
+ pos0[1] -= 0.5f;
+ pos1[1] -= 0.5f;
+ pos2[1] -= 0.5f;
+ pos3[1] -= 0.5f;
}
else {
/* bottom to top line */
- pos0[1] += 0.5;
- pos1[1] += 0.5;
- pos2[1] += 0.5;
- pos3[1] += 0.5;
+ pos0[1] += 0.5f;
+ pos1[1] += 0.5f;
+ pos2[1] += 0.5f;
+ pos3[1] += 0.5f;
}
}
uint j = wide->texcoord_slot[i];
v->data[j][0] = tc[0];
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
v->data[j][1] = tc[1];
v->data[j][2] = tc[2];
struct prim_header *header )
{
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 left_adj, right_adj;
half_size = wide->half_point_size;
}
- left_adj = -half_size + 0.25;
- right_adj = half_size + 0.25;
+ left_adj = -half_size + 0.25f;
+ right_adj = half_size + 0.25f;
pos0[0] += left_adj;
pos0[1] -= half_size;
struct wide_stage *wide = wide_stage(stage);
struct draw_context *draw = stage->draw;
- wide->half_point_size = 0.5 * draw->rasterizer->point_size;
- wide->half_line_width = 0.5 * draw->rasterizer->line_width;
+ wide->half_point_size = 0.5f * draw->rasterizer->point_size;
+ wide->half_line_width = 0.5f * draw->rasterizer->line_width;
if (draw->rasterizer->line_width != 1.0) {
wide->stage.line = wide_line;
#define PIPE_CONTEXT_H
#include "p_state.h"
-#include "p_compiler.h"
+#include "p_util.h"
struct pipe_state_cache;
/**
/* free the old region */
assert(oldReg->map_refcount == 0);
/* XXX dereference the region->buffer */
- free(oldReg);
+ FREE( oldReg );
}
*ptr = NULL;
}
if (oldSurf->refcount == 0) {
/* free the old region */
pipe_region_reference(&oldSurf->region, NULL);
- free(oldSurf);
+ FREE( oldSurf );
}
*ptr = NULL;
}
-
-/*
- * 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
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
+ * 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
+ * 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.
+ *
+ **************************************************************************/
#ifndef P_UTIL_H
#define P_UTIL_H
#include "p_compiler.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 CALLOC( COUNT, SIZE ) calloc( COUNT, SIZE )
+
#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 MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
return num.f + log_2;
}
+#if defined(__GNUC__)
+#define CEILF(x) ceilf(x)
+#else
+#define CEILF(x) ((float) ceil(x))
+#endif
#endif
}
else if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[0])) {
float clear[4];
- clear[0] = 0.2; /* XXX hack */
- clear[1] = 0.2; /* XXX hack */
- clear[2] = 0.2; /* XXX hack */
- clear[3] = 0.2; /* XXX hack */
+ clear[0] = 0.2f; /* XXX hack */
+ clear[1] = 0.2f; /* XXX hack */
+ clear[2] = 0.2f; /* XXX hack */
+ clear[3] = 0.2f; /* XXX hack */
sp_tile_cache_clear(softpipe->cbuf_cache[0], clear);
}
uint i;
#if defined(__i386__) || defined(__386__)
- softpipe->use_sse = getenv("GALLIUM_SSE") != NULL;
+ softpipe->use_sse = GETENV( "GALLIUM_SSE" ) != NULL;
#else
softpipe->use_sse = FALSE;
#endif
- softpipe->dump_fs = getenv( "GALLIUM_DUMP_FS" ) != NULL;
+ softpipe->dump_fs = GETENV( "GALLIUM_DUMP_FS" ) != NULL;
softpipe->pipe.winsys = pipe_winsys;
softpipe->pipe.destroy = softpipe_destroy;
assert(softpipe->draw);
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->pipe,
sp_vbuf_setup_draw);
#ifndef SP_CONTEXT_H
#define SP_CONTEXT_H
-#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#define SP_NEW_CONSTANTS 0x4000
struct sp_vertex_shader_state {
- const struct pipe_shader_state *state;
+ struct pipe_shader_state *state;
void *draw_data;
};
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
#include "sp_context.h"
#include "sp_state.h"
float vmid_y = setup->vmid->data[0][1] - 0.5f;
float vmax_y = setup->vmax->data[0][1] - 0.5f;
- setup->emaj.sy = ceilf(vmin_y);
- setup->emaj.lines = (int) ceilf(vmax_y - setup->emaj.sy);
+ setup->emaj.sy = CEILF(vmin_y);
+ setup->emaj.lines = (int) CEILF(vmax_y - setup->emaj.sy);
setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy;
setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy;
- setup->etop.sy = ceilf(vmid_y);
- setup->etop.lines = (int) ceilf(vmax_y - setup->etop.sy);
+ setup->etop.sy = CEILF(vmid_y);
+ setup->etop.lines = (int) CEILF(vmax_y - setup->etop.sy);
setup->etop.dxdy = setup->etop.dx / setup->etop.dy;
setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy;
- setup->ebot.sy = ceilf(vmin_y);
- setup->ebot.lines = (int) ceilf(vmid_y - setup->ebot.sy);
+ setup->ebot.sy = CEILF(vmin_y);
+ setup->ebot.lines = (int) CEILF(vmid_y - setup->ebot.sy);
setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy;
setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy;
}
= sizeAttr > 0 ? v0->data[sizeAttr][0]
: setup->softpipe->rasterizer->point_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 y = v0->data[0][1];
unsigned slot, j;
vbuf->draw = draw;
vbuf->draw_context = draw_context;
- vbuf->element_map = malloc( IBUF_SIZE );
- vbuf->vertex_map = malloc( VBUF_SIZE );
+ vbuf->element_map = MALLOC( IBUF_SIZE );
+ vbuf->vertex_map = MALLOC( VBUF_SIZE );
vbuf->vertex_ptr = vbuf->vertex_map;
-/*
- * 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
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
+ * 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
+ * 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.
+ *
+ **************************************************************************/
/**
* \brief Quad depth testing
for (j = 0; j < QUAD_SIZE; j++) {
int x = quad->x0 % 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;
case PIPE_FORMAT_U_Z32:
-/*
- * 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
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
+ * 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
+ * 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.
+ *
+ **************************************************************************/
/* Vertices are just an array of floats, with all the attributes
* packed. We currently assume a layout like:
#include "pipe/p_util.h"
#include "pipe/p_defines.h"
-#include "pipe/llvm/llvmtgsi.h"
-
#include "x86/rtasm/x86sse.h"
#include "sp_context.h"
ushort *row = (ushort *) get_pointer(dst, dstx, dsty);
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++)
- row[j] = value;
+ row[j] = (ushort) value;
row += dst->pitch;
}
}
softpipe_create_blend_state(struct pipe_context *pipe,
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));
return state;
}
void softpipe_delete_blend_state(struct pipe_context *pipe,
void *blend)
{
- free(blend);
+ FREE( blend );
}
softpipe_create_alpha_test_state(struct pipe_context *pipe,
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));
return state;
}
softpipe_delete_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
- free(alpha);
+ FREE( alpha );
}
void *
const struct pipe_depth_stencil_state *depth_stencil)
{
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));
return state;
}
void
softpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth)
{
- free(depth);
+ FREE( depth );
}
#include "sp_state.h"
#include "pipe/p_defines.h"
+#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/draw/draw_context.h"
#include "pipe/tgsi/exec/tgsi_core.h"
* 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;
if( softpipe->dump_fs ) {
x86_release_func( &state->sse2_program );
#endif
- free( state );
+ FREE( state );
}
const struct pipe_shader_state *templ)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- struct sp_vertex_shader_state *state =
- malloc(sizeof(struct sp_vertex_shader_state));
- struct pipe_shader_state *templ_copy =
- malloc(sizeof(struct pipe_shader_state));
- memcpy(templ_copy, templ, sizeof(struct pipe_shader_state));
+ struct sp_vertex_shader_state *state;
+
+ state = MALLOC( sizeof(struct sp_vertex_shader_state) );
+ if (state == NULL ) {
+ 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->state);
+ if (state->draw_data == NULL) {
+ FREE( state->state );
+ FREE( state );
+ return NULL;
+ }
return state;
}
(struct sp_vertex_shader_state *)vs;
draw_delete_vertex_shader(softpipe->draw, state->draw_data);
- free(state->state);
- free(state);
+ FREE( state->state );
+ FREE( state );
}
/**************************************************************************
*
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
const struct pipe_rasterizer_state *setup)
{
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));
return state;
}
void softpipe_delete_rasterizer_state(struct pipe_context *pipe,
void *rasterizer)
{
- free(rasterizer);
+ FREE( rasterizer );
}
softpipe_create_sampler_state(struct pipe_context *pipe,
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));
return state;
}
softpipe_delete_sampler_state(struct pipe_context *pipe,
void *sampler)
{
- free(sampler);
+ FREE( sampler );
}
/**************************************************************************
*
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
const ushort *src
= ((const ushort *) (ps->region->map + ps->offset))
+ y * ps->region->pitch + x;
- const float scale = 1.0 / 65535.0;
+ const float scale = 1.0f / 65535.0f;
unsigned i, j;
unsigned w0 = w;
pRow[j * 4 + 0] =
pRow[j * 4 + 1] =
pRow[j * 4 + 2] =
- pRow[j * 4 + 3] = src[j] * scale;
+ pRow[j * 4 + 3] = (float) (scale * src[j]);
}
src += ps->region->pitch;
p += 4 * w0;
pRow[j * 4 + 0] =
pRow[j * 4 + 1] =
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;
p += 4 * w0;
* Michel Dänzer <michel@tungstengraphics.com>
*/
-#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "sp_tex_layout.h"
/* Not sure when this would happen, but anyway:
*/
if (mt->level[level].image_offset) {
- free(mt->level[level].image_offset);
+ FREE( mt->level[level].image_offset );
mt->level[level].image_offset = NULL;
}
assert(nr_images);
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;
}
#include "sp_tile_cache.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "pipe/tgsi/exec/tgsi_exec.h"
height = sampler->texture->level[level0].height;
}
else {
- width = height = 1.0;
+ width = height = 1;
}
assert(width > 0);
depth = sampler->texture->level[level0].depth;
}
else {
- width = height = depth = 1.0;
+ width = height = depth = 1;
}
assert(width > 0);
struct softpipe_tile_cache *tc;
uint pos;
- tc = calloc(1, sizeof(*tc));
+ tc = CALLOC_STRUCT( softpipe_tile_cache );
if (tc) {
for (pos = 0; pos < NUM_ENTRIES; pos++) {
tc->entries[pos].x =
for (pos = 0; pos < NUM_ENTRIES; pos++) {
assert(tc->entries[pos].x < 0);
}
- free(tc);
+ FREE( tc );
}
+/**************************************************************************
+ *
+ * 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_core.h"
unsigned tabs;
};
-static void
-text_dump_write(
- struct text_dump *dump,
- const void *buffer,
- unsigned size )
-{
- fwrite( buffer, size, 1, dump->file );
-}
-
static void
text_dump_str(
struct text_dump *dump,
size_t len = strlen( str );
for( i = 0; i < len; i++ ) {
- text_dump_write( dump, &str[i], 1 );
+ fprintf( dump->file, "%c", str[i] );
if( str[i] == '\n' ) {
unsigned i;
for( i = 0; i < dump->tabs; i++ ) {
- text_dump_write( dump, " ", 4 );
+ fprintf( dump->file, " " );
}
}
}
TXT( "\ntgsi-dump end -------------------\n" );
tgsi_parse_free( &parse );
-
- if (dump->file != stderr &&
- dump->file != stdout)
- fclose( dump->file );
}
labels->count = 0;
declarations = (struct tgsi_full_declaration *)
- malloc(maxDeclarations * sizeof(struct tgsi_full_declaration));
+ MALLOC( maxDeclarations * sizeof(struct tgsi_full_declaration) );
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 );
if (k != TGSI_PARSE_OK) {
case TGSI_TOKEN_TYPE_DECLARATION:
/* save expanded declaration */
if (numDeclarations == maxDeclarations) {
- maxDeclarations += 10;
- declarations = realloc(declarations,
+ declarations = REALLOC(declarations,
maxDeclarations
+ * sizeof(struct tgsi_full_instruction),
+ (maxDeclarations + 10)
* sizeof(struct tgsi_full_instruction));
+ maxDeclarations += 10;
}
memcpy(declarations + numDeclarations,
&parse.FullToken.FullInstruction,
/* save expanded instruction */
if (numInstructions == maxInstructions) {
- maxInstructions += 10;
- instructions = realloc(instructions,
+ instructions = REALLOC(instructions,
maxInstructions
+ * sizeof(struct tgsi_full_instruction),
+ (maxInstructions + 10)
* sizeof(struct tgsi_full_instruction));
+ maxInstructions += 10;
}
memcpy(instructions + numInstructions,
&parse.FullToken.FullInstruction,
tgsi_parse_free (&parse);
if (mach->Declarations) {
- free(mach->Declarations);
+ FREE( mach->Declarations );
}
mach->Declarations = declarations;
mach->NumDeclarations = numDeclarations;
if (mach->Instructions) {
- free(mach->Instructions);
+ FREE( mach->Instructions );
}
mach->Instructions = instructions;
mach->NumInstructions = numInstructions;
k = tgsi_parse_init (&parse, mach->Tokens);
if (k != TGSI_PARSE_OK) {
- printf("Problem parsing!\n");
+ fprintf( stderr, "Problem parsing!\n" );
return;
}
+/**************************************************************************
+ *
+ * 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_core.h"
union tgsi_full_token *full_token )
{
if( full_token->Token.Type == TGSI_TOKEN_TYPE_IMMEDIATE ) {
- free( full_token->FullImmediate.u.Pointer );
+ FREE( full_token->FullImmediate.u.Pointer );
}
}
switch (imm->Immediate.DataType) {
case TGSI_IMM_FLOAT32:
- imm->u.Pointer = malloc(
+ imm->u.Pointer = MALLOC(
sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.Size - 1) );
for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
next_token( ctx, &imm->u.ImmediateFloat32[i] );
+/**************************************************************************
+ *
+ * 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_core.h"
#include "x86/rtasm/x86sse.h"
struct x86_function *func,
struct x86_reg dst,
struct x86_reg src,
- unsigned shuf )
+ unsigned char shuf )
{
DUMP_RRI( "SHUFPS", dst, src, shuf );
sse_shufps( func, dst, src, shuf );