summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2004-03-30 22:19:50 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2004-03-30 22:19:50 +0000
commit2c0d84ac4495c39503a45d48b6a36a813f07122c (patch)
tree0e3003fac697b13d544488ceb1ce596e4a927951
parent1af8ae0e846676c36f20fdaf83df17da97e67eb2 (diff)
Bring across X2D/XPD fixes from trunk.
-rw-r--r--src/mesa/main/arbfragparse.c2
-rw-r--r--src/mesa/main/arbparse.c60
-rw-r--r--src/mesa/main/nvfragparse.c4
-rw-r--r--src/mesa/main/nvfragprog.h3
-rw-r--r--src/mesa/shader/arbfragparse.c2
-rw-r--r--src/mesa/shader/arbprogparse.c40
-rw-r--r--src/mesa/swrast/s_nvfragprog.c12
7 files changed, 55 insertions, 68 deletions
diff --git a/src/mesa/main/arbfragparse.c b/src/mesa/main/arbfragparse.c
index bce8732f25..4d09dbc6e3 100644
--- a/src/mesa/main/arbfragparse.c
+++ b/src/mesa/main/arbfragparse.c
@@ -145,7 +145,7 @@ _mesa_debug_fp_inst(GLint num, struct fp_instruction *fp)
case FP_OPCODE_TXP:
fprintf(stderr, "FP_OPCODE_TXP"); break;
- case FP_OPCODE_X2D:
+ case FP_OPCODE_XPD:
fprintf(stderr, "FP_OPCODE_XPD"); break;
default:
diff --git a/src/mesa/main/arbparse.c b/src/mesa/main/arbparse.c
index 01771597e9..6ef1350400 100644
--- a/src/mesa/main/arbparse.c
+++ b/src/mesa/main/arbparse.c
@@ -2652,24 +2652,17 @@ grammar_get_last_error (GLubyte * text, GLint size, GLint *pos)
const GLubyte *p = error_message;
*text = '\0';
-#define APPEND_CHARACTER(x) \
- do { \
- if (dots_made == 0) { \
- if (len < size - 1) { \
- text[len++] = (x); \
- text[len] = '\0'; \
- } \
- else { \
- GLint i; \
- for (i = 0; i < 3; i++) { \
- if (--len >= 0) { \
- text[len] = '.'; \
- } \
- } \
- dots_made = 1; \
- } \
- } \
- } while (0)
+#define APPEND_CHARACTER(x) if (dots_made == 0) {\
+ if (len < size - 1) {\
+ text[len++] = (x); text[len] = '\0';\
+ } else {\
+ GLint i;\
+ for (i = 0; i < 3; i++)\
+ if (--len >= 0)\
+ text[len] = '.';\
+ dots_made = 1;\
+ }\
+}
if (p) {
while (*p) {
@@ -2677,15 +2670,15 @@ grammar_get_last_error (GLubyte * text, GLint size, GLint *pos)
const GLubyte *r = error_param;
while (*r) {
- APPEND_CHARACTER (*r);
- r++;
+ APPEND_CHARACTER (*r)
+ r++;
}
p++;
}
else {
- APPEND_CHARACTER (*p);
- p++;
+ APPEND_CHARACTER (*p)
+ p++;
}
}
}
@@ -5141,7 +5134,7 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_XPD_SAT:
fp->Saturate = 1;
case OP_XPD:
- fp->Opcode = FP_OPCODE_X2D;
+ fp->Opcode = FP_OPCODE_XPD;
break;
}
@@ -5932,7 +5925,7 @@ parse_arb_program (GLcontext * ctx, GLubyte * inst, struct var_cache **vc_head,
* \param str - The program string
* \param len - The program string length
* \param Program - The arb_program struct to return all the parsed info in
- * \return 0 on success, 1 on error
+ * \return 0 on sucess, 1 on error
*/
GLuint
_mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
@@ -5944,21 +5937,6 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
struct var_cache *vc_head;
dict *dt;
GLubyte *parsed, *inst;
- GLubyte *strCopy;
-
- /* init to zero in case of parse error */
- _mesa_bzero(program, sizeof(*program));
-
- /* Need a null-terminated string for parsing */
- strCopy = (GLubyte *) _mesa_malloc(len + 1);
- if (!strCopy) {
- _mesa_error (ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
- return 1;
- }
- _mesa_memcpy(strCopy, str, len);
- strCopy[len] = 0;
- str = strCopy;
-
#if DEBUG_PARSING
fprintf (stderr, "Loading grammar text!\n");
@@ -5969,7 +5947,6 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
_mesa_set_program_error (ctx, error_pos, error_msg);
_mesa_error (ctx, GL_INVALID_OPERATION,
"Error loading grammer rule set");
- _mesa_free(strCopy);
return 1;
}
@@ -5986,7 +5963,6 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
_mesa_error (ctx, GL_INVALID_OPERATION, "Parse Error");
dict_destroy (&dt);
- _mesa_free(strCopy);
return 1;
}
@@ -6052,10 +6028,8 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
var_cache_destroy (&vc_head);
_mesa_free (parsed);
- _mesa_free(strCopy);
#if DEBUG_PARSING
printf ("_mesa_parse_arb_program() done\n");
#endif
-
return err;
}
diff --git a/src/mesa/main/nvfragparse.c b/src/mesa/main/nvfragparse.c
index b742ff0a32..c95bb53d5b 100644
--- a/src/mesa/main/nvfragparse.c
+++ b/src/mesa/main/nvfragparse.c
@@ -91,8 +91,8 @@ static const struct instruction_pattern Instructions[] = {
{ "DDY", FP_OPCODE_DDY, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
{ "DP3", FP_OPCODE_DP3, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S },
{ "DP4", FP_OPCODE_DP4, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S },
- { "DST", FP_OPCODE_DP4, INPUT_2V, OUTPUT_V, _R | _H | _C | _S },
- { "EX2", FP_OPCODE_DP4, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "DST", FP_OPCODE_DST, INPUT_2V, OUTPUT_V, _R | _H | _C | _S },
+ { "EX2", FP_OPCODE_EX2, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
{ "FLR", FP_OPCODE_FLR, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
{ "FRC", FP_OPCODE_FRC, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
{ "KIL", FP_OPCODE_KIL, INPUT_CC, OUTPUT_NONE, 0 },
diff --git a/src/mesa/main/nvfragprog.h b/src/mesa/main/nvfragprog.h
index fa817d4b9c..187e7072d2 100644
--- a/src/mesa/main/nvfragprog.h
+++ b/src/mesa/main/nvfragprog.h
@@ -112,7 +112,8 @@ enum fp_opcode {
FP_OPCODE_UP2US, /* NV_f_p only */
FP_OPCODE_UP4B, /* NV_f_p only */
FP_OPCODE_UP4UB, /* NV_f_p only */
- FP_OPCODE_X2D, /* XPD in ARB_f_p */
+ FP_OPCODE_XPD, /* ARB_f_p only - cross product */
+ FP_OPCODE_X2D, /* NV_f_p only - 2d mat mul */
FP_OPCODE_END /* private opcode */
};
diff --git a/src/mesa/shader/arbfragparse.c b/src/mesa/shader/arbfragparse.c
index 46d80dd2e2..d876946a25 100644
--- a/src/mesa/shader/arbfragparse.c
+++ b/src/mesa/shader/arbfragparse.c
@@ -145,7 +145,7 @@ _mesa_debug_fp_inst(GLint num, struct fp_instruction *fp)
case FP_OPCODE_TXP:
fprintf(stderr, "FP_OPCODE_TXP"); break;
- case FP_OPCODE_X2D:
+ case FP_OPCODE_XPD:
fprintf(stderr, "FP_OPCODE_XPD"); break;
default:
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 7fa2569c64..7584df2bf5 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -384,8 +384,8 @@ static char arb_grammar_text[] =
#define PARAM_CONSTANT 0x05
/* param state property */
-#define STATE_MATERIAL_PARSER 0x01
-#define STATE_LIGHT_PARSER 0x02
+#define STATE_MATERIAL 0x01
+#define STATE_LIGHT 0x02
#define STATE_LIGHT_MODEL 0x03
#define STATE_LIGHT_PROD 0x04
#define STATE_FOG 0x05
@@ -2903,7 +2903,7 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
case OP_XPD_SAT:
fp->Saturate = 1;
case OP_XPD:
- fp->Opcode = FP_OPCODE_X2D;
+ fp->Opcode = FP_OPCODE_XPD;
break;
}
@@ -3704,7 +3704,7 @@ static char core_grammar_text[] =
static int set_reg8 (GLcontext *ctx, grammar id, const byte *name, byte value)
{
- char error_msg[300];
+ char error_msg;
GLint error_pos;
if (grammar_set_reg8 (id, name, value))
@@ -3716,29 +3716,29 @@ static int set_reg8 (GLcontext *ctx, grammar id, const byte *name, byte value)
return 1;
}
-static int extension_is_supported (const GLubyte *ext)
+/*
+ Taken from SGI sample code
+*/
+static int extension_is_supported (const byte *ext)
{
- const GLubyte *extensions = glGetString (GL_EXTENSIONS);
- const GLubyte *end = extensions + _mesa_strlen ((const char *) extensions);
- const GLint ext_len = _mesa_strlen ((const char *) ext);
-
- while (extensions < end)
- {
- const GLubyte *name_end = (const GLubyte *) strchr ((const char *) extensions, ' ');
- if (name_end == NULL)
- name_end = end;
- if (name_end - extensions == ext_len && _mesa_strncmp ((const char *) ext,
- (const char *) extensions, ext_len) == 0)
- return 1;
- extensions = name_end + 1;
- }
+ const byte *extensions = glGetString (GL_EXTENSIONS);
+ const byte *end = extensions + _mesa_strlen ((const char *) extensions);
+ const int ext_len = _mesa_strlen ((const char *) ext);
+
+ while (extensions < end) {
+ const int n = _mesa_strcspn ((const char *) extensions, " ");
+ if ((ext_len == n) && (_mesa_strncmp ((const char *) ext,
+ (const char *) extensions, n) == 0))
+ return 1;
+ extensions += (n + 1);
+ }
return 0;
}
static int enable_ext (GLcontext *ctx, grammar id, const byte *name, const byte *extname)
{
- if (extension_is_supported (extname))
+ if (extension_is_supported (extname)) {
if (set_reg8 (ctx, id, name, 0x01))
return 1;
return 0;
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index 4083581ab0..127cc4f0b4 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -1233,6 +1233,18 @@ execute_program( GLcontext *ctx,
store_vector4( inst, machine, result );
}
break;
+ case FP_OPCODE_XPD: /* cross product */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = a[1] * b[2] - a[2] * b[1];
+ result[1] = a[2] * b[0] - a[0] * b[2];
+ result[2] = a[0] * b[1] - a[1] * b[0];
+ result[3] = 1.0;
+ store_vector4( inst, machine, result );
+ }
+ break;
case FP_OPCODE_X2D: /* 2-D matrix transform */
{
GLfloat a[4], b[4], c[4], result[4];