summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/draw
diff options
context:
space:
mode:
authorMichal Krol <michal@tungstengraphics.com>2007-10-29 16:20:45 +0000
committerMichal Krol <michal@tungstengraphics.com>2007-10-29 17:05:38 +0000
commitee295fccdd0c94cb6b8af4dfb30283e39f548223 (patch)
treefe8f5064ad57c5dc12163efb5a91206b1e068141 /src/mesa/pipe/draw
parentd37eb130c090abc413a54e57e0d3800ac4cd59f4 (diff)
Make gallium compile in win32.
Use FREE, MALLOC, CALLOC, GETENV wrappers. Silence compiler warnings. Add proper copyrights.
Diffstat (limited to 'src/mesa/pipe/draw')
-rw-r--r--src/mesa/pipe/draw/draw_context.c16
-rw-r--r--src/mesa/pipe/draw/draw_vertex_fetch.c8
-rw-r--r--src/mesa/pipe/draw/draw_vertex_shader.c15
-rw-r--r--src/mesa/pipe/draw/draw_wide_prims.c60
4 files changed, 51 insertions, 48 deletions
diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c
index 61f9e4909b..80317dd6cf 100644
--- a/src/mesa/pipe/draw/draw_context.c
+++ b/src/mesa/pipe/draw/draw_context.c
@@ -42,7 +42,7 @@ struct draw_context *draw_create( void )
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
@@ -71,7 +71,7 @@ struct draw_context *draw_create( void )
*/
{
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);
@@ -92,8 +92,8 @@ struct draw_context *draw_create( void )
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 );
}
@@ -233,10 +233,10 @@ void draw_alloc_tmps( struct draw_stage *stage, unsigned nr )
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);
@@ -246,8 +246,8 @@ void draw_alloc_tmps( struct draw_stage *stage, unsigned nr )
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 );
}
}
diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c
index de1cd06da6..5a7e6febe9 100644
--- a/src/mesa/pipe/draw/draw_vertex_fetch.c
+++ b/src/mesa/pipe/draw/draw_vertex_fetch.c
@@ -64,16 +64,16 @@ fetch_attrib4(const void *ptr, unsigned format, float attrib[4])
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:
diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c
index 7fd17292b8..056ad007cf 100644
--- a/src/mesa/pipe/draw/draw_vertex_shader.c
+++ b/src/mesa/pipe/draw/draw_vertex_shader.c
@@ -42,7 +42,7 @@
#include "pipe/llvm/llvmtgsi.h"
-#define DBG 0
+#define DBG_VS 0
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][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],
@@ -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][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],
@@ -222,7 +222,11 @@ draw_create_vertex_shader(struct draw_context *draw,
{
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__)
@@ -269,6 +273,5 @@ void draw_delete_vertex_shader(struct draw_context *draw,
x86_release_func( (struct x86_function *) &vs->sse2_program );
#endif
- free( vs->state );
- free( vs );
+ FREE( vs );
}
diff --git a/src/mesa/pipe/draw/draw_wide_prims.c b/src/mesa/pipe/draw/draw_wide_prims.c
index 76b8a5319b..f3b4478f9a 100644
--- a/src/mesa/pipe/draw/draw_wide_prims.c
+++ b/src/mesa/pipe/draw/draw_wide_prims.c
@@ -111,44 +111,44 @@ static void wide_line( struct draw_stage *stage,
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;
}
}
@@ -179,7 +179,7 @@ static void set_texcoords(const struct wide_stage *wide,
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];
@@ -198,7 +198,7 @@ static void wide_point( struct draw_stage *stage,
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;
@@ -223,8 +223,8 @@ static void wide_point( struct draw_stage *stage,
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;
@@ -267,8 +267,8 @@ static void wide_begin( struct draw_stage *stage )
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;