summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/arbprogparse.c20
-rw-r--r--src/mesa/shader/nvvertexec.c8
-rw-r--r--src/mesa/shader/slang/slang_compile.c15
-rw-r--r--src/mesa/shader/slang/slang_execute.c14
4 files changed, 37 insertions, 20 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index e8992c6d8b1..dba8280c27e 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -3886,7 +3886,7 @@ static int extension_is_supported (const GLubyte *ext)
while (extensions < end)
{
- const GLubyte *name_end = (const GLubyte *) strchr ((const char *) extensions, ' ');
+ const GLubyte *name_end = (const GLubyte *) _mesa_strstr ((const char *) extensions, " ");
if (name_end == NULL)
name_end = end;
if (name_end - extensions == ext_len && _mesa_strncmp ((const char *) ext,
@@ -4037,7 +4037,7 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
strz[len] = '\0';
#if DEBUG_PARSING
- printf ("Checking Grammar!\n");
+ fprintf (stderr, "Checking Grammar!\n");
#endif
/* do a fast check on program string - initial production buffer is 4K */
err = grammar_fast_check (arbprogram_syn_id, strz, &parsed, &parsed_len, 0x1000);
@@ -4050,21 +4050,23 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
_mesa_error (ctx, GL_INVALID_OPERATION, "glProgramStringARB(syntax error)");
/* useful for debugging */
- if (0) {
+#if DEBUG_PARSING
+ do {
int line, col;
char *s;
- printf("Program: %s\n", (char *) strz);
- printf("Error Pos: %d\n", ctx->Program.ErrorPos);
+ fprintf(stderr, "Program: %s\n", (char *) strz);
+ fprintf(stderr, "Error Pos: %d\n", ctx->Program.ErrorPos);
s = (char *) _mesa_find_line_column(strz, strz+ctx->Program.ErrorPos, &line, &col);
- printf("line %d col %d: %s\n", line, col, s);
- }
+ fprintf(stderr, "line %d col %d: %s\n", line, col, s);
+ } while (0)
+#endif
grammar_destroy (arbprogram_syn_id);
return 1;
}
#if DEBUG_PARSING
- printf ("Destroying grammer dict [parse retval: %d]\n", err);
+ fprintf (stderr, "Destroying grammer dict [parse retval: %d]\n", err);
#endif
grammar_destroy (arbprogram_syn_id);
@@ -4120,7 +4122,7 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
_mesa_free (parsed);
#if DEBUG_PARSING
- printf ("_mesa_parse_arb_program() done\n");
+ fprintf (stderr, "_mesa_parse_arb_program() done\n");
#endif
return err;
}
diff --git a/src/mesa/shader/nvvertexec.c b/src/mesa/shader/nvvertexec.c
index 725e3ec9cd5..f99c4dfac13 100644
--- a/src/mesa/shader/nvvertexec.c
+++ b/src/mesa/shader/nvvertexec.c
@@ -452,7 +452,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{
GLfloat t[4], q[4], floor_t0;
fetch_vector1( &inst->SrcReg[0], state, t );
- floor_t0 = (float) floor(t[0]);
+ floor_t0 = FLOORF(t[0]);
if (floor_t0 > FLT_MAX_EXP) {
SET_POS_INFINITY(q[0]);
SET_POS_INFINITY(q[2]);
@@ -481,7 +481,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{
GLfloat t[4], q[4], abs_t0;
fetch_vector1( &inst->SrcReg[0], state, t );
- abs_t0 = (GLfloat) fabs(t[0]);
+ abs_t0 = FABSF(t[0]);
if (abs_t0 != 0.0F) {
/* Since we really can't handle infinite values on VMS
* like other OSes we'll use __MAXFLOAT to represent
@@ -499,7 +499,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
}
else {
int exponent;
- double mantissa = frexp(t[0], &exponent);
+ GLfloat mantissa = FREXPF(t[0], &exponent);
q[0] = (GLfloat) (exponent - 1);
q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */
q[2] = (GLfloat) (q[0] + LOG2(q[1]));
@@ -635,7 +635,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{
GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t );
- state->AddressReg[0] = (GLint) floor(t[0]);
+ state->AddressReg[0] = (GLint) FLOORF(t[0]);
}
break;
case VP_OPCODE_DPH:
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index 0ff450ca91c..688eac33c7a 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -635,7 +635,7 @@ int slang_info_log_error (slang_info_log *log, const char *msg, ...)
char buf[1024];
va_start (va, msg);
- _mesa_sprintf (buf, msg, va);
+ _mesa_vsprintf (buf, msg, va);
if (slang_info_log_message (log, "error", buf))
return 1;
slang_info_log_memory (log);
@@ -649,7 +649,7 @@ int slang_info_log_warning (slang_info_log *log, const char *msg, ...)
char buf[1024];
va_start (va, msg);
- _mesa_sprintf (buf, msg, va);
+ _mesa_vsprintf (buf, msg, va);
if (slang_info_log_message (log, "warning", buf))
return 1;
slang_info_log_memory (log);
@@ -685,7 +685,7 @@ static int parse_identifier (slang_parse_ctx *C, char **id)
slang_info_log_memory (C->L);
return 0;
}
- C->I += strlen ((const char *) C->I) + 1;
+ C->I += _mesa_strlen ((const char *) C->I) + 1;
return 1;
}
@@ -734,8 +734,9 @@ static int parse_float (slang_parse_ctx *C, float *number)
return 0;
}
- whole = (char *) (slang_alloc_malloc ((strlen (integral) + strlen (fractional) + strlen (
- exponent) + 3) * sizeof (char)));
+ whole = (char *) (slang_alloc_malloc ((_mesa_strlen (integral) +
+ _mesa_strlen (fractional) + _mesa_strlen (exponent) + 3) *
+ sizeof (char)));
if (whole == NULL)
{
slang_alloc_free (exponent);
@@ -751,7 +752,7 @@ static int parse_float (slang_parse_ctx *C, float *number)
slang_string_concat (whole, "E");
slang_string_concat (whole, exponent);
- *number = (float) (atof (whole));
+ *number = (float) (_mesa_strtod(whole, (char **)NULL));
slang_alloc_free (whole);
slang_alloc_free (exponent);
@@ -2115,7 +2116,7 @@ if (slang_string_compare ("main", (**parsed_func_ret).header.name) == 0)
xxx_prolog (&file, (**parsed_func_ret).address);
_slang_execute (&file);
slang_assembly_file_destruct (&file);
-exit (0);
+_mesa_exit (0);
}
}
return 1;
diff --git a/src/mesa/shader/slang/slang_execute.c b/src/mesa/shader/slang/slang_execute.c
index 78a638b4445..5b1d6d39409 100644
--- a/src/mesa/shader/slang/slang_execute.c
+++ b/src/mesa/shader/slang/slang_execute.c
@@ -34,6 +34,9 @@
#include "slang_storage.h"
#include "slang_execute.h"
+#define DEBUG_SLANG
+
+#ifdef DEBUG_SLANG
static void dump_instruction (FILE *f, slang_assembly *a, unsigned int i)
{
fprintf (f, "%.5u:\t", i);
@@ -179,11 +182,14 @@ static void dump (const slang_assembly_file *file)
fclose (f);
}
+#endif
int _slang_execute (const slang_assembly_file *file)
{
slang_machine mach;
+#ifdef DEBUG_SLANG
FILE *f;
+#endif
mach.ip = 0;
mach.sp = SLANG_MACHINE_STACK_SIZE;
@@ -200,13 +206,18 @@ int _slang_execute (const slang_assembly_file *file)
static_assert(sizeof (GLuint) == 4);
/*static_assert(sizeof (GLuint *) == 4);*/
+#ifdef DEBUG_SLANG
dump (file);
+#endif
+#ifdef DEBUG_SLANG
f = fopen ("~mesa-slang-assembly-execution.txt", "w");
+#endif
while (!mach.exit)
{
slang_assembly *a = file->code + mach.ip;
+#ifdef DEBUG_SLANG
if (f != NULL)
{
unsigned int i;
@@ -216,6 +227,7 @@ int _slang_execute (const slang_assembly_file *file)
fprintf (f, "\t%.5u\t%6f\t%u\n", i, mach.stack._float[i], mach.stack._addr[i]);
fflush (f);
}
+#endif
mach.ip++;
switch (a->type)
@@ -344,8 +356,10 @@ int _slang_execute (const slang_assembly_file *file)
}
}
+#ifdef DEBUG_SLANG
if (f != NULL)
fclose (f);
+#endif
return 0;
}