summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/arbprogparse.c6
-rw-r--r--src/mesa/shader/arbprogram.c44
-rw-r--r--src/mesa/shader/hash_table.c4
-rw-r--r--src/mesa/shader/lex.yy.c23
-rw-r--r--src/mesa/shader/nvprogram.c29
-rw-r--r--src/mesa/shader/prog_instruction.h1
-rw-r--r--src/mesa/shader/prog_optimize.c256
-rw-r--r--src/mesa/shader/prog_print.c6
-rw-r--r--src/mesa/shader/program_parse.tab.c650
-rw-r--r--src/mesa/shader/program_parse.tab.h2
-rw-r--r--src/mesa/shader/program_parse.y118
-rw-r--r--src/mesa/shader/program_parser.h2
-rw-r--r--src/mesa/shader/programopt.c8
-rw-r--r--src/mesa/shader/shader_api.c68
-rw-r--r--src/mesa/shader/slang/slang_codegen.c2
-rw-r--r--src/mesa/shader/slang/slang_emit.c201
-rw-r--r--src/mesa/shader/slang/slang_link.c55
-rw-r--r--src/mesa/shader/slang/slang_vartable.c4
-rw-r--r--src/mesa/shader/symbol_table.c22
19 files changed, 1033 insertions, 468 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 05ee4f563eb..dd732b6666b 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -87,6 +87,9 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target,
return;
}
+ if (program->Base.String != NULL)
+ _mesa_free(program->Base.String);
+
/* Copy the relevant contents of the arb_program struct into the
* fragment_program struct.
*/
@@ -178,6 +181,9 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target,
return;
}
+ if (program->Base.String != NULL)
+ _mesa_free(program->Base.String);
+
/* Copy the relevant contents of the arb_program struct into the
* vertex_program struct.
*/
diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c
index 4d8cff07001..eb537cd1b99 100644
--- a/src/mesa/shader/arbprogram.c
+++ b/src/mesa/shader/arbprogram.c
@@ -37,6 +37,8 @@
#include "main/mtypes.h"
#include "arbprogram.h"
#include "arbprogparse.h"
+#include "nvfragparse.h"
+#include "nvvertparse.h"
#include "program.h"
@@ -428,36 +430,66 @@ void GLAPIENTRY
_mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
const GLvoid *string)
{
+ struct gl_program *base;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ if (!ctx->Extensions.ARB_vertex_program
+ && !ctx->Extensions.ARB_fragment_program) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramStringARB()");
+ return;
+ }
+
if (format != GL_PROGRAM_FORMAT_ASCII_ARB) {
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(format)");
return;
}
+ /* The first couple cases are complicated. The same enum value is used for
+ * ARB and NV vertex programs. If the target is a vertex program, parse it
+ * using the ARB grammar if the string starts with "!!ARB" or if
+ * NV_vertex_program is not supported.
+ */
if (target == GL_VERTEX_PROGRAM_ARB
- && ctx->Extensions.ARB_vertex_program) {
+ && ctx->Extensions.ARB_vertex_program
+ && ((strncmp(string, "!!ARB", 5) == 0)
+ || !ctx->Extensions.NV_vertex_program)) {
struct gl_vertex_program *prog = ctx->VertexProgram.Current;
_mesa_parse_arb_vertex_program(ctx, target, string, len, prog);
-
- if (ctx->Program.ErrorPos == -1 && ctx->Driver.ProgramStringNotify)
- ctx->Driver.ProgramStringNotify( ctx, target, &prog->Base );
+
+ base = & prog->Base;
+ }
+ else if ((target == GL_VERTEX_PROGRAM_ARB
+ || target == GL_VERTEX_STATE_PROGRAM_NV)
+ && ctx->Extensions.NV_vertex_program) {
+ struct gl_vertex_program *prog = ctx->VertexProgram.Current;
+ _mesa_parse_nv_vertex_program(ctx, target, string, len, prog);
+
+ base = & prog->Base;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
struct gl_fragment_program *prog = ctx->FragmentProgram.Current;
_mesa_parse_arb_fragment_program(ctx, target, string, len, prog);
- if (ctx->Program.ErrorPos == -1 && ctx->Driver.ProgramStringNotify)
- ctx->Driver.ProgramStringNotify( ctx, target, &prog->Base );
+ base = & prog->Base;
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_NV
+ && ctx->Extensions.NV_fragment_program) {
+ struct gl_fragment_program *prog = ctx->FragmentProgram.Current;
+ _mesa_parse_nv_fragment_program(ctx, target, string, len, prog);
+
+ base = & prog->Base;
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(target)");
return;
}
+
+ if (ctx->Program.ErrorPos == -1 && ctx->Driver.ProgramStringNotify)
+ ctx->Driver.ProgramStringNotify( ctx, target, base );
}
diff --git a/src/mesa/shader/hash_table.c b/src/mesa/shader/hash_table.c
index 881179f9d85..e89a2564d76 100644
--- a/src/mesa/shader/hash_table.c
+++ b/src/mesa/shader/hash_table.c
@@ -27,10 +27,6 @@
*
* \author Ian Romanick <[email protected]>
*/
-#include <stdlib.h>
-#include <string.h>
-
-#include <assert.h>
#include "main/imports.h"
#include "main/simple_list.h"
diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c
index 17843c2121b..68543ae2e12 100644
--- a/src/mesa/shader/lex.yy.c
+++ b/src/mesa/shader/lex.yy.c
@@ -158,7 +158,15 @@ typedef void* yyscan_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -1153,7 +1161,7 @@ handle_ident(struct asm_parser_state *state, const char *text, YYSTYPE *lval)
} while(0);
#define YY_EXTRA_TYPE struct asm_parser_state *
-#line 1157 "lex.yy.c"
+#line 1165 "lex.yy.c"
#define INITIAL 0
@@ -1290,7 +1298,12 @@ static int input (yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@@ -1397,7 +1410,7 @@ YY_DECL
#line 157 "program_lexer.l"
-#line 1401 "lex.yy.c"
+#line 1414 "lex.yy.c"
yylval = yylval_param;
@@ -2461,7 +2474,7 @@ YY_RULE_SETUP
#line 481 "program_lexer.l"
ECHO;
YY_BREAK
-#line 2465 "lex.yy.c"
+#line 2478 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -3229,8 +3242,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c
index 471a7358a2f..fd6cbb0f409 100644
--- a/src/mesa/shader/nvprogram.c
+++ b/src/mesa/shader/nvprogram.c
@@ -47,6 +47,7 @@
#include "prog_instruction.h"
#include "nvfragparse.h"
#include "nvvertparse.h"
+#include "arbprogparse.h"
#include "nvprogram.h"
@@ -595,6 +596,12 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ if (!ctx->Extensions.NV_vertex_program
+ && !ctx->Extensions.NV_fragment_program) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV()");
+ return;
+ }
+
if (id == 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(id)");
return;
@@ -627,7 +634,13 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
}
_mesa_HashInsert(ctx->Shared->Programs, id, vprog);
}
- _mesa_parse_nv_vertex_program(ctx, target, program, len, vprog);
+
+ if (ctx->Extensions.ARB_vertex_program
+ && (strncmp((char *) program, "!!ARB", 5) == 0)) {
+ _mesa_parse_arb_vertex_program(ctx, target, program, len, vprog);
+ } else {
+ _mesa_parse_nv_vertex_program(ctx, target, program, len, vprog);
+ }
}
else if (target == GL_FRAGMENT_PROGRAM_NV
&& ctx->Extensions.NV_fragment_program) {
@@ -643,6 +656,20 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
}
_mesa_parse_nv_fragment_program(ctx, target, program, len, fprog);
}
+ else if (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program) {
+ struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog;
+ if (!fprog || prog == &_mesa_DummyProgram) {
+ fprog = (struct gl_fragment_program *)
+ ctx->Driver.NewProgram(ctx, target, id);
+ if (!fprog) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
+ return;
+ }
+ _mesa_HashInsert(ctx->Shared->Programs, id, fprog);
+ }
+ _mesa_parse_arb_fragment_program(ctx, target, program, len, fprog);
+ }
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glLoadProgramNV(target)");
}
diff --git a/src/mesa/shader/prog_instruction.h b/src/mesa/shader/prog_instruction.h
index 1c687bc16cf..224350caac6 100644
--- a/src/mesa/shader/prog_instruction.h
+++ b/src/mesa/shader/prog_instruction.h
@@ -312,7 +312,6 @@ struct prog_dst_register
*/
GLuint CondSrc:1;
/*@}*/
- GLuint pad:28;
};
diff --git a/src/mesa/shader/prog_optimize.c b/src/mesa/shader/prog_optimize.c
index 9d937488e37..4fe351251e8 100644
--- a/src/mesa/shader/prog_optimize.c
+++ b/src/mesa/shader/prog_optimize.c
@@ -38,6 +38,39 @@
static GLboolean dbg = GL_FALSE;
+/* Returns the mask of channels read from the given srcreg in this instruction.
+ */
+static GLuint
+get_src_arg_mask(const struct prog_instruction *inst, int arg)
+{
+ int writemask = inst->DstReg.WriteMask;
+
+ if (inst->CondUpdate)
+ writemask = WRITEMASK_XYZW;
+
+ switch (inst->Opcode) {
+ case OPCODE_MOV:
+ case OPCODE_ABS:
+ case OPCODE_ADD:
+ case OPCODE_MUL:
+ case OPCODE_SUB:
+ return writemask;
+ case OPCODE_RCP:
+ case OPCODE_SIN:
+ case OPCODE_COS:
+ case OPCODE_RSQ:
+ case OPCODE_POW:
+ case OPCODE_EX2:
+ return WRITEMASK_X;
+ case OPCODE_DP2:
+ return WRITEMASK_XY;
+ case OPCODE_DP3:
+ case OPCODE_XPD:
+ return WRITEMASK_XYZ;
+ default:
+ return WRITEMASK_XYZW;
+ }
+}
/**
* In 'prog' remove instruction[i] if removeFlags[i] == TRUE.
@@ -74,6 +107,12 @@ remove_instructions(struct gl_program *prog, const GLboolean *removeFlags)
}
}
}
+ /* Finish removing if the first instruction was to be removed. */
+ if (removeCount > 0) {
+ GLint removeStart = removeEnd - removeCount + 1;
+ _mesa_delete_instructions(prog, removeStart, removeCount);
+ removeStart = removeCount = 0; /* reset removal info */
+ }
return totalRemoved;
}
@@ -187,11 +226,10 @@ _mesa_consolidate_registers(struct gl_program *prog)
static void
_mesa_remove_dead_code(struct gl_program *prog)
{
- GLboolean tempWritten[MAX_PROGRAM_TEMPS], tempRead[MAX_PROGRAM_TEMPS];
+ GLboolean tempRead[MAX_PROGRAM_TEMPS][4];
GLboolean *removeInst; /* per-instruction removal flag */
- GLuint i, rem;
+ GLuint i, rem = 0, comp;
- memset(tempWritten, 0, sizeof(tempWritten));
memset(tempRead, 0, sizeof(tempRead));
if (dbg) {
@@ -212,16 +250,37 @@ _mesa_remove_dead_code(struct gl_program *prog)
for (j = 0; j < numSrc; j++) {
if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
const GLuint index = inst->SrcReg[j].Index;
+ GLuint read_mask;
ASSERT(index < MAX_PROGRAM_TEMPS);
+ read_mask = get_src_arg_mask(inst, j);
if (inst->SrcReg[j].RelAddr) {
if (dbg)
_mesa_printf("abort remove dead code (indirect temp)\n");
- _mesa_free(removeInst);
- return;
+ goto done;
}
- tempRead[index] = GL_TRUE;
+ for (comp = 0; comp < 4; comp++) {
+ GLuint swz = (inst->SrcReg[j].Swizzle >> (3 * comp)) & 0x7;
+
+ if ((read_mask & (1 << comp)) == 0)
+ continue;
+
+ switch (swz) {
+ case SWIZZLE_X:
+ tempRead[index][0] = GL_TRUE;
+ break;
+ case SWIZZLE_Y:
+ tempRead[index][1] = GL_TRUE;
+ break;
+ case SWIZZLE_Z:
+ tempRead[index][2] = GL_TRUE;
+ break;
+ case SWIZZLE_W:
+ tempRead[index][3] = GL_TRUE;
+ break;
+ }
+ }
}
}
@@ -233,50 +292,63 @@ _mesa_remove_dead_code(struct gl_program *prog)
if (inst->DstReg.RelAddr) {
if (dbg)
_mesa_printf("abort remove dead code (indirect temp)\n");
- _mesa_free(removeInst);
- return;
+ goto done;
}
- tempWritten[index] = GL_TRUE;
if (inst->CondUpdate) {
/* If we're writing to this register and setting condition
* codes we cannot remove the instruction. Prevent removal
* by setting the 'read' flag.
*/
- tempRead[index] = GL_TRUE;
+ tempRead[index][0] = GL_TRUE;
+ tempRead[index][1] = GL_TRUE;
+ tempRead[index][2] = GL_TRUE;
+ tempRead[index][3] = GL_TRUE;
}
}
}
- if (dbg) {
- for (i = 0; i < MAX_PROGRAM_TEMPS; i++) {
- if (tempWritten[i] && !tempRead[i])
- _mesa_printf("Remove writes to tmp %u\n", i);
- }
- }
-
/* find instructions that write to dead registers, flag for removal */
for (i = 0; i < prog->NumInstructions; i++) {
- const struct prog_instruction *inst = prog->Instructions + i;
- if (inst->DstReg.File == PROGRAM_TEMPORARY) {
- GLint index = inst->DstReg.Index;
- removeInst[i] = (tempWritten[index] && !tempRead[index]);
- if (dbg && removeInst[i]) {
- _mesa_printf("Remove inst %u: ", i);
- _mesa_print_instruction(inst);
- }
+ struct prog_instruction *inst = prog->Instructions + i;
+ const GLuint numDst = _mesa_num_inst_dst_regs(inst->Opcode);
+
+ if (numDst != 0 && inst->DstReg.File == PROGRAM_TEMPORARY) {
+ GLint chan, index = inst->DstReg.Index;
+
+ for (chan = 0; chan < 4; chan++) {
+ if (!tempRead[index][chan] &&
+ inst->DstReg.WriteMask & (1 << chan)) {
+ if (dbg) {
+ _mesa_printf("Remove writemask on %u.%c\n", i,
+ chan == 3 ? 'w' : 'x' + chan);
+ }
+ inst->DstReg.WriteMask &= ~(1 << chan);
+ rem++;
+ }
+ }
+
+ if (inst->DstReg.WriteMask == 0) {
+ /* If we cleared all writes, the instruction can be removed. */
+ if (dbg)
+ _mesa_printf("Remove instruction %u: \n", i);
+ removeInst[i] = GL_TRUE;
+ }
}
}
/* now remove the instructions which aren't needed */
rem = remove_instructions(prog, removeInst);
- _mesa_free(removeInst);
-
if (dbg) {
- _mesa_printf("Optimize: End dead code removal. %u instructions removed\n", rem);
+ _mesa_printf("Optimize: End dead code removal.\n");
+ _mesa_printf(" %u channel writes removed\n", rem);
+ _mesa_printf(" %u instructions removed\n", rem);
/*_mesa_print_program(prog);*/
}
+
+done:
+ _mesa_free(removeInst);
}
@@ -325,6 +397,132 @@ find_next_temp_use(const struct gl_program *prog, GLuint start, GLuint index)
return END;
}
+static GLboolean _mesa_is_flow_control_opcode(enum prog_opcode opcode)
+{
+ switch (opcode) {
+ case OPCODE_BGNLOOP:
+ case OPCODE_BGNSUB:
+ case OPCODE_BRA:
+ case OPCODE_CAL:
+ case OPCODE_CONT:
+ case OPCODE_IF:
+ case OPCODE_ELSE:
+ case OPCODE_END:
+ case OPCODE_ENDIF:
+ case OPCODE_ENDLOOP:
+ case OPCODE_ENDSUB:
+ case OPCODE_RET:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+/**
+ * Try to remove use of extraneous MOV instructions, to free them up for dead
+ * code removal.
+ */
+static void
+_mesa_remove_extra_move_use(struct gl_program *prog)
+{
+ GLuint i, j;
+
+ if (dbg) {
+ _mesa_printf("Optimize: Begin remove extra move use\n");
+ _mesa_print_program(prog);
+ }
+
+ /*
+ * Look for sequences such as this:
+ * MOV tmpX, arg0;
+ * ...
+ * FOO tmpY, tmpX, arg1;
+ * and convert into:
+ * MOV tmpX, arg0;
+ * ...
+ * FOO tmpY, arg0, arg1;
+ */
+
+ for (i = 0; i + 1 < prog->NumInstructions; i++) {
+ const struct prog_instruction *mov = prog->Instructions + i;
+
+ if (mov->Opcode != OPCODE_MOV ||
+ mov->DstReg.File != PROGRAM_TEMPORARY ||
+ mov->DstReg.RelAddr ||
+ mov->DstReg.CondMask != COND_TR ||
+ mov->SaturateMode != SATURATE_OFF ||
+ mov->SrcReg[0].RelAddr)
+ continue;
+
+ /* Walk through remaining instructions until the or src reg gets
+ * rewritten or we get into some flow-control, eliminating the use of
+ * this MOV.
+ */
+ for (j = i + 1; j < prog->NumInstructions; j++) {
+ struct prog_instruction *inst2 = prog->Instructions + j;
+ int arg;
+
+ if (_mesa_is_flow_control_opcode(inst2->Opcode))
+ break;
+
+ /* First rewrite this instruction's args if appropriate. */
+ for (arg = 0; arg < _mesa_num_inst_src_regs(inst2->Opcode); arg++) {
+ int comp;
+ int read_mask = get_src_arg_mask(inst2, arg);
+
+ if (inst2->SrcReg[arg].File != mov->DstReg.File ||
+ inst2->SrcReg[arg].Index != mov->DstReg.Index ||
+ inst2->SrcReg[arg].RelAddr ||
+ inst2->SrcReg[arg].Abs)
+ continue;
+
+ /* Check that all the sources for this arg of inst2 come from inst1
+ * or constants.
+ */
+ for (comp = 0; comp < 4; comp++) {
+ int src_swz = GET_SWZ(inst2->SrcReg[arg].Swizzle, comp);
+
+ /* If the MOV didn't write that channel, can't use it. */
+ if ((read_mask & (1 << comp)) &&
+ src_swz <= SWIZZLE_W &&
+ (mov->DstReg.WriteMask & (1 << src_swz)) == 0)
+ break;
+ }
+ if (comp != 4)
+ continue;
+
+ /* Adjust the swizzles of inst2 to point at MOV's source */
+ for (comp = 0; comp < 4; comp++) {
+ int inst2_swz = GET_SWZ(inst2->SrcReg[arg].Swizzle, comp);
+
+ if (inst2_swz <= SWIZZLE_W) {
+ GLuint s = GET_SWZ(mov->SrcReg[0].Swizzle, inst2_swz);
+ inst2->SrcReg[arg].Swizzle &= ~(7 << (3 * comp));
+ inst2->SrcReg[arg].Swizzle |= s << (3 * comp);
+ inst2->SrcReg[arg].Negate ^= (((mov->SrcReg[0].Negate >>
+ inst2_swz) & 0x1) << comp);
+ }
+ }
+ inst2->SrcReg[arg].File = mov->SrcReg[0].File;
+ inst2->SrcReg[arg].Index = mov->SrcReg[0].Index;
+ }
+
+ /* If this instruction overwrote part of the move, our time is up. */
+ if ((inst2->DstReg.File == mov->DstReg.File &&
+ (inst2->DstReg.RelAddr ||
+ inst2->DstReg.Index == mov->DstReg.Index)) ||
+ (inst2->DstReg.File == mov->SrcReg[0].File &&
+ (inst2->DstReg.RelAddr ||
+ inst2->DstReg.Index == mov->SrcReg[0].Index)))
+ break;
+ }
+ }
+
+ if (dbg) {
+ _mesa_printf("Optimize: End remove extra move use.\n");
+ /*_mesa_print_program(prog);*/
+ }
+}
/**
* Try to remove extraneous MOV instructions from the given program.
@@ -823,6 +1021,8 @@ _mesa_reallocate_registers(struct gl_program *prog)
void
_mesa_optimize_program(GLcontext *ctx, struct gl_program *program)
{
+ _mesa_remove_extra_move_use(program);
+
if (1)
_mesa_remove_dead_code(program);
diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c
index ba4d39452f4..52c102cbaa3 100644
--- a/src/mesa/shader/prog_print.c
+++ b/src/mesa/shader/prog_print.c
@@ -826,11 +826,11 @@ _mesa_print_program(const struct gl_program *prog)
* XXX move to imports.[ch] if useful elsewhere.
*/
static const char *
-binary(GLbitfield val)
+binary(GLbitfield64 val)
{
- static char buf[50];
+ static char buf[80];
GLint i, len = 0;
- for (i = 31; i >= 0; --i) {
+ for (i = 63; i >= 0; --i) {
if (val & (1 << i))
buf[len++] = '1';
else if (len > 0 || i == 0)
diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c
index c0f50147bd9..d4f84294884 100644
--- a/src/mesa/shader/program_parse.tab.c
+++ b/src/mesa/shader/program_parse.tab.c
@@ -137,8 +137,14 @@ static int validate_inputs(struct YYLTYPE *locp,
static void init_dst_reg(struct prog_dst_register *r);
+static void set_dst_reg(struct prog_dst_register *r,
+ gl_register_file file, GLint index);
+
static void init_src_reg(struct asm_src_register *r);
+static void set_src_reg(struct asm_src_register *r,
+ gl_register_file file, GLint index);
+
static void asm_instruction_set_operands(struct asm_instruction *inst,
const struct prog_dst_register *dst, const struct asm_src_register *src0,
const struct asm_src_register *src1, const struct asm_src_register *src2);
@@ -179,7 +185,7 @@ static struct asm_instruction *asm_instruction_copy_ctor(
/* Line 189 of yacc.c */
-#line 183 "program_parse.tab.c"
+#line 189 "program_parse.tab.c"
/* Enabling traces. */
#ifndef YYDEBUG
@@ -321,7 +327,7 @@ typedef union YYSTYPE
{
/* Line 214 of yacc.c */
-#line 116 "program_parse.y"
+#line 122 "program_parse.y"
struct asm_instruction *inst;
struct asm_symbol *sym;
@@ -350,7 +356,7 @@ typedef union YYSTYPE
/* Line 214 of yacc.c */
-#line 354 "program_parse.tab.c"
+#line 360 "program_parse.tab.c"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -374,14 +380,14 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */
/* Line 264 of yacc.c */
-#line 261 "program_parse.y"
+#line 267 "program_parse.y"
extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param,
void *yyscanner);
/* Line 264 of yacc.c */
-#line 385 "program_parse.tab.c"
+#line 391 "program_parse.tab.c"
#ifdef short
# undef short
@@ -782,35 +788,35 @@ static const yytype_int16 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 268, 268, 271, 279, 291, 292, 295, 317, 318,
- 321, 336, 339, 344, 351, 352, 353, 354, 355, 356,
- 357, 360, 361, 362, 365, 371, 377, 383, 390, 396,
- 403, 447, 452, 462, 506, 512, 513, 514, 515, 516,
- 517, 518, 519, 520, 521, 522, 523, 526, 538, 546,
- 563, 570, 589, 600, 620, 645, 654, 687, 694, 709,
- 759, 801, 812, 833, 843, 849, 880, 897, 897, 899,
- 906, 918, 919, 920, 923, 937, 951, 969, 980, 992,
- 994, 995, 996, 997, 1000, 1000, 1000, 1000, 1001, 1004,
- 1008, 1013, 1020, 1027, 1034, 1057, 1080, 1081, 1082, 1083,
- 1084, 1085, 1088, 1106, 1110, 1116, 1120, 1124, 1128, 1137,
- 1146, 1150, 1155, 1161, 1172, 1172, 1173, 1175, 1179, 1183,
- 1187, 1193, 1193, 1195, 1211, 1234, 1237, 1248, 1254, 1260,
- 1261, 1268, 1274, 1280, 1288, 1294, 1300, 1308, 1314, 1320,
- 1328, 1329, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339,
- 1340, 1341, 1342, 1345, 1354, 1358, 1362, 1368, 1377, 1381,
- 1385, 1394, 1398, 1404, 1410, 1417, 1422, 1430, 1440, 1442,
- 1450, 1456, 1460, 1464, 1470, 1481, 1490, 1494, 1499, 1503,
- 1507, 1511, 1517, 1524, 1528, 1534, 1542, 1553, 1560, 1564,
- 1570, 1580, 1591, 1595, 1613, 1622, 1625, 1631, 1635, 1639,
- 1645, 1656, 1661, 1666, 1671, 1676, 1681, 1689, 1692, 1697,
- 1710, 1718, 1729, 1737, 1737, 1739, 1739, 1741, 1751, 1756,
- 1763, 1773, 1782, 1787, 1794, 1804, 1814, 1826, 1826, 1827,
- 1827, 1829, 1839, 1847, 1857, 1865, 1873, 1882, 1893, 1897,
- 1903, 1904, 1905, 1908, 1908, 1911, 1946, 1950, 1950, 1953,
- 1959, 1967, 1980, 1989, 1998, 2002, 2011, 2020, 2031, 2038,
- 2043, 2052, 2064, 2067, 2076, 2087, 2088, 2089, 2092, 2093,
- 2094, 2097, 2098, 2101, 2102, 2105, 2106, 2109, 2120, 2131,
- 2142, 2163, 2164
+ 0, 274, 274, 277, 285, 297, 298, 301, 325, 326,
+ 329, 344, 347, 352, 359, 360, 361, 362, 363, 364,
+ 365, 368, 369, 370, 373, 379, 385, 391, 398, 404,
+ 411, 455, 460, 470, 514, 520, 521, 522, 523, 524,
+ 525, 526, 527, 528, 529, 530, 531, 534, 546, 554,
+ 571, 578, 595, 606, 626, 651, 658, 691, 698, 713,
+ 768, 809, 818, 839, 848, 852, 881, 900, 900, 902,
+ 909, 921, 922, 923, 926, 940, 954, 974, 985, 997,
+ 999, 1000, 1001, 1002, 1005, 1005, 1005, 1005, 1006, 1009,
+ 1013, 1018, 1025, 1032, 1039, 1062, 1085, 1086, 1087, 1088,
+ 1089, 1090, 1093, 1112, 1116, 1122, 1126, 1130, 1134, 1143,
+ 1152, 1156, 1161, 1167, 1178, 1178, 1179, 1181, 1185, 1189,
+ 1193, 1199, 1199, 1201, 1218, 1243, 1246, 1257, 1263, 1269,
+ 1270, 1277, 1283, 1289, 1297, 1303, 1309, 1317, 1323, 1329,
+ 1337, 1338, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348,
+ 1349, 1350, 1351, 1354, 1363, 1367, 1371, 1377, 1386, 1390,
+ 1394, 1403, 1407, 1413, 1419, 1426, 1431, 1439, 1449, 1451,
+ 1459, 1465, 1469, 1473, 1479, 1490, 1499, 1503, 1508, 1512,
+ 1516, 1520, 1526, 1533, 1537, 1543, 1551, 1562, 1569, 1573,
+ 1579, 1589, 1600, 1604, 1622, 1631, 1634, 1640, 1644, 1648,
+ 1654, 1665, 1670, 1675, 1680, 1685, 1690, 1698, 1701, 1706,
+ 1719, 1727, 1738, 1746, 1746, 1748, 1748, 1750, 1760, 1765,
+ 1772, 1782, 1791, 1796, 1803, 1813, 1823, 1835, 1835, 1836,
+ 1836, 1838, 1848, 1856, 1866, 1874, 1882, 1891, 1902, 1906,
+ 1912, 1913, 1914, 1917, 1917, 1920, 1955, 1959, 1959, 1962,
+ 1969, 1978, 1992, 2001, 2010, 2014, 2023, 2032, 2043, 2050,
+ 2055, 2064, 2076, 2079, 2088, 2099, 2100, 2101, 2104, 2105,
+ 2106, 2109, 2110, 2113, 2114, 2117, 2118, 2121, 2132, 2143,
+ 2154, 2180, 2181
};
#endif
@@ -2119,7 +2125,7 @@ yyreduce:
case 3:
/* Line 1455 of yacc.c */
-#line 272 "program_parse.y"
+#line 278 "program_parse.y"
{
if (state->prog->Target != GL_VERTEX_PROGRAM_ARB) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid fragment program header");
@@ -2132,7 +2138,7 @@ yyreduce:
case 4:
/* Line 1455 of yacc.c */
-#line 280 "program_parse.y"
+#line 286 "program_parse.y"
{
if (state->prog->Target != GL_FRAGMENT_PROGRAM_ARB) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid vertex program header");
@@ -2147,7 +2153,7 @@ yyreduce:
case 7:
/* Line 1455 of yacc.c */
-#line 296 "program_parse.y"
+#line 302 "program_parse.y"
{
int valid = 0;
@@ -2158,6 +2164,8 @@ yyreduce:
}
+ free((yyvsp[(2) - (3)].string));
+
if (!valid) {
const char *const err_str = (state->mode == ARB_vertex)
? "invalid ARB vertex program option"
@@ -2172,7 +2180,7 @@ yyreduce:
case 10:
/* Line 1455 of yacc.c */
-#line 322 "program_parse.y"
+#line 330 "program_parse.y"
{
if ((yyvsp[(1) - (2)].inst) != NULL) {
if (state->inst_tail == NULL) {
@@ -2192,7 +2200,7 @@ yyreduce:
case 12:
/* Line 1455 of yacc.c */
-#line 340 "program_parse.y"
+#line 348 "program_parse.y"
{
(yyval.inst) = (yyvsp[(1) - (1)].inst);
state->prog->NumAluInstructions++;
@@ -2202,7 +2210,7 @@ yyreduce:
case 13:
/* Line 1455 of yacc.c */
-#line 345 "program_parse.y"
+#line 353 "program_parse.y"
{
(yyval.inst) = (yyvsp[(1) - (1)].inst);
state->prog->NumTexInstructions++;
@@ -2212,7 +2220,7 @@ yyreduce:
case 24:
/* Line 1455 of yacc.c */
-#line 366 "program_parse.y"
+#line 374 "program_parse.y"
{
(yyval.inst) = asm_instruction_ctor(OPCODE_ARL, & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL);
;}
@@ -2221,7 +2229,7 @@ yyreduce:
case 25:
/* Line 1455 of yacc.c */
-#line 372 "program_parse.y"
+#line 380 "program_parse.y"
{
(yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL);
;}
@@ -2230,7 +2238,7 @@ yyreduce:
case 26:
/* Line 1455 of yacc.c */
-#line 378 "program_parse.y"
+#line 386 "program_parse.y"
{
(yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL);
;}
@@ -2239,7 +2247,7 @@ yyreduce:
case 27:
/* Line 1455 of yacc.c */
-#line 384 "program_parse.y"
+#line 392 "program_parse.y"
{
(yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL);
;}
@@ -2248,7 +2256,7 @@ yyreduce:
case 28:
/* Line 1455 of yacc.c */
-#line 391 "program_parse.y"
+#line 399 "program_parse.y"
{
(yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL);
;}
@@ -2257,7 +2265,7 @@ yyreduce:
case 29:
/* Line 1455 of yacc.c */
-#line 398 "program_parse.y"
+#line 406 "program_parse.y"
{
(yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), & (yyvsp[(6) - (8)].src_reg), & (yyvsp[(8) - (8)].src_reg));
;}
@@ -2266,7 +2274,7 @@ yyreduce:
case 30:
/* Line 1455 of yacc.c */
-#line 404 "program_parse.y"
+#line 412 "program_parse.y"
{
(yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), NULL, NULL);
if ((yyval.inst) != NULL) {
@@ -2313,7 +2321,7 @@ yyreduce:
case 31:
/* Line 1455 of yacc.c */
-#line 448 "program_parse.y"
+#line 456 "program_parse.y"
{
(yyval.inst) = asm_instruction_ctor(OPCODE_KIL, NULL, & (yyvsp[(2) - (2)].src_reg), NULL, NULL);
state->fragment.UsesKill = 1;
@@ -2323,7 +2331,7 @@ yyreduce:
case 32:
/* Line 1455 of yacc.c */
-#line 453 "program_parse.y"
+#line 461 "program_parse.y"
{
(yyval.inst) = asm_instruction_ctor(OPCODE_KIL_NV, NULL, NULL, NULL, NULL);
(yyval.inst)->Base.DstReg.CondMask = (yyvsp[(2) - (2)].dst_reg).CondMask;
@@ -2336,7 +2344,7 @@ yyreduce:
case 33:
/* Line 1455 of yacc.c */
-#line 463 "program_parse.y"
+#line 471 "program_parse.y"
{
(yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (12)].temp_inst), & (yyvsp[(2) - (12)].dst_reg), & (yyvsp[(4) - (12)].src_reg), & (yyvsp[(6) - (12)].src_reg), & (yyvsp[(8) - (12)].src_reg));
if ((yyval.inst) != NULL) {
@@ -2383,7 +2391,7 @@ yyreduce:
case 34:
/* Line 1455 of yacc.c */
-#line 507 "program_parse.y"
+#line 515 "program_parse.y"
{
(yyval.integer) = (yyvsp[(2) - (2)].integer);
;}
@@ -2392,91 +2400,91 @@ yyreduce:
case 35:
/* Line 1455 of yacc.c */
-#line 512 "program_parse.y"
+#line 520 "program_parse.y"
{ (yyval.integer) = TEXTURE_1D_INDEX; ;}
break;
case 36:
/* Line 1455 of yacc.c */
-#line 513 "program_parse.y"
+#line 521 "program_parse.y"
{ (yyval.integer) = TEXTURE_2D_INDEX; ;}
break;
case 37:
/* Line 1455 of yacc.c */
-#line 514 "program_parse.y"
+#line 522 "program_parse.y"
{ (yyval.integer) = TEXTURE_3D_INDEX; ;}
break;
case 38:
/* Line 1455 of yacc.c */
-#line 515 "program_parse.y"
+#line 523 "program_parse.y"
{ (yyval.integer) = TEXTURE_CUBE_INDEX; ;}
break;
case 39:
/* Line 1455 of yacc.c */
-#line 516 "program_parse.y"
+#line 524 "program_parse.y"
{ (yyval.integer) = TEXTURE_RECT_INDEX; ;}
break;
case 40:
/* Line 1455 of yacc.c */
-#line 517 "program_parse.y"
+#line 525 "program_parse.y"
{ (yyval.integer) = -TEXTURE_1D_INDEX; ;}
break;
case 41:
/* Line 1455 of yacc.c */
-#line 518 "program_parse.y"
+#line 526 "program_parse.y"
{ (yyval.integer) = -TEXTURE_2D_INDEX; ;}
break;
case 42:
/* Line 1455 of yacc.c */
-#line 519 "program_parse.y"
+#line 527 "program_parse.y"
{ (yyval.integer) = -TEXTURE_RECT_INDEX; ;}
break;
case 43:
/* Line 1455 of yacc.c */
-#line 520 "program_parse.y"
+#line 528 "program_parse.y"
{ (yyval.integer) = TEXTURE_1D_ARRAY_INDEX; ;}
break;
case 44:
/* Line 1455 of yacc.c */
-#line 521 "program_parse.y"
+#line 529 "program_parse.y"
{ (yyval.integer) = TEXTURE_2D_ARRAY_INDEX; ;}
break;
case 45:
/* Line 1455 of yacc.c */
-#line 522 "program_parse.y"
+#line 530 "program_parse.y"
{ (yyval.integer) = -TEXTURE_1D_ARRAY_INDEX; ;}
break;
case 46:
/* Line 1455 of yacc.c */
-#line 523 "program_parse.y"
+#line 531 "program_parse.y"
{ (yyval.integer) = -TEXTURE_2D_ARRAY_INDEX; ;}
break;
case 47:
/* Line 1455 of yacc.c */
-#line 527 "program_parse.y"
+#line 535 "program_parse.y"
{
/* FIXME: Is this correct? Should the extenedSwizzle be applied
* FIXME: to the existing swizzle?
@@ -2491,7 +2499,7 @@ yyreduce:
case 48:
/* Line 1455 of yacc.c */
-#line 539 "program_parse.y"
+#line 547 "program_parse.y"
{
(yyval.src_reg) = (yyvsp[(2) - (2)].src_reg);
@@ -2504,7 +2512,7 @@ yyreduce:
case 49:
/* Line 1455 of yacc.c */
-#line 547 "program_parse.y"
+#line 555 "program_parse.y"
{
(yyval.src_reg) = (yyvsp[(3) - (4)].src_reg);
@@ -2524,7 +2532,7 @@ yyreduce:
case 50:
/* Line 1455 of yacc.c */
-#line 564 "program_parse.y"
+#line 572 "program_parse.y"
{
(yyval.src_reg) = (yyvsp[(1) - (2)].src_reg);
@@ -2536,7 +2544,7 @@ yyreduce:
case 51:
/* Line 1455 of yacc.c */
-#line 571 "program_parse.y"
+#line 579 "program_parse.y"
{
struct asm_symbol temp_sym;
@@ -2549,16 +2557,14 @@ yyreduce:
temp_sym.param_binding_begin = ~0;
initialize_symbol_from_const(state->prog, & temp_sym, & (yyvsp[(1) - (1)].vector));
- init_src_reg(& (yyval.src_reg));
- (yyval.src_reg).Base.File = PROGRAM_CONSTANT;
- (yyval.src_reg).Base.Index = temp_sym.param_binding_begin;
+ set_src_reg(& (yyval.src_reg), PROGRAM_CONSTANT, temp_sym.param_binding_begin);
;}
break;
case 52:
/* Line 1455 of yacc.c */
-#line 590 "program_parse.y"
+#line 596 "program_parse.y"
{
(yyval.src_reg) = (yyvsp[(2) - (3)].src_reg);
@@ -2574,7 +2580,7 @@ yyreduce:
case 53:
/* Line 1455 of yacc.c */
-#line 601 "program_parse.y"
+#line 607 "program_parse.y"
{
(yyval.src_reg) = (yyvsp[(3) - (5)].src_reg);
@@ -2596,7 +2602,7 @@ yyreduce:
case 54:
/* Line 1455 of yacc.c */
-#line 621 "program_parse.y"
+#line 627 "program_parse.y"
{
(yyval.dst_reg) = (yyvsp[(1) - (3)].dst_reg);
(yyval.dst_reg).WriteMask = (yyvsp[(2) - (3)].swiz_mask).mask;
@@ -2616,7 +2622,7 @@ yyreduce:
YYERROR;
}
- state->prog->OutputsWritten |= (1U << (yyval.dst_reg).Index);
+ state->prog->OutputsWritten |= BITFIELD64_BIT((yyval.dst_reg).Index);
}
;}
break;
@@ -2624,11 +2630,9 @@ yyreduce:
case 55:
/* Line 1455 of yacc.c */
-#line 646 "program_parse.y"
+#line 652 "program_parse.y"
{
- init_dst_reg(& (yyval.dst_reg));
- (yyval.dst_reg).File = PROGRAM_ADDRESS;
- (yyval.dst_reg).Index = 0;
+ set_dst_reg(& (yyval.dst_reg), PROGRAM_ADDRESS, 0);
(yyval.dst_reg).WriteMask = (yyvsp[(2) - (2)].swiz_mask).mask;
;}
break;
@@ -2636,7 +2640,7 @@ yyreduce:
case 56:
/* Line 1455 of yacc.c */
-#line 655 "program_parse.y"
+#line 659 "program_parse.y"
{
const unsigned xyzw_valid =
((yyvsp[(1) - (7)].ext_swizzle).xyzw_valid << 0)
@@ -2672,7 +2676,7 @@ yyreduce:
case 57:
/* Line 1455 of yacc.c */
-#line 688 "program_parse.y"
+#line 692 "program_parse.y"
{
(yyval.ext_swizzle) = (yyvsp[(2) - (2)].ext_swizzle);
(yyval.ext_swizzle).negate = ((yyvsp[(1) - (2)].negate)) ? 1 : 0;
@@ -2682,7 +2686,7 @@ yyreduce:
case 58:
/* Line 1455 of yacc.c */
-#line 695 "program_parse.y"
+#line 699 "program_parse.y"
{
if (((yyvsp[(1) - (1)].integer) != 0) && ((yyvsp[(1) - (1)].integer) != 1)) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid extended swizzle selector");
@@ -2702,14 +2706,19 @@ yyreduce:
case 59:
/* Line 1455 of yacc.c */
-#line 710 "program_parse.y"
+#line 714 "program_parse.y"
{
+ char s;
+
if (strlen((yyvsp[(1) - (1)].string)) > 1) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid extended swizzle selector");
YYERROR;
}
- switch ((yyvsp[(1) - (1)].string)[0]) {
+ s = (yyvsp[(1) - (1)].string)[0];
+ free((yyvsp[(1) - (1)].string));
+
+ switch (s) {
case 'x':
(yyval.ext_swizzle).swz = SWIZZLE_X;
(yyval.ext_swizzle).xyzw_valid = 1;
@@ -2755,11 +2764,13 @@ yyreduce:
case 60:
/* Line 1455 of yacc.c */
-#line 760 "program_parse.y"
+#line 769 "program_parse.y"
{
struct asm_symbol *const s = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string));
+ free((yyvsp[(1) - (1)].string));
+
if (s == NULL) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable");
YYERROR;
@@ -2775,16 +2786,13 @@ yyreduce:
init_src_reg(& (yyval.src_reg));
switch (s->type) {
case at_temp:
- (yyval.src_reg).Base.File = PROGRAM_TEMPORARY;
- (yyval.src_reg).Base.Index = s->temp_binding;
+ set_src_reg(& (yyval.src_reg), PROGRAM_TEMPORARY, s->temp_binding);
break;
case at_param:
- (yyval.src_reg).Base.File = s->param_binding_type;
- (yyval.src_reg).Base.Index = s->param_binding_begin;
+ set_src_reg(& (yyval.src_reg), s->param_binding_type, s->param_binding_begin);
break;
case at_attrib:
- (yyval.src_reg).Base.File = PROGRAM_INPUT;
- (yyval.src_reg).Base.Index = s->attrib_binding;
+ set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, s->attrib_binding);
state->prog->InputsRead |= (1U << (yyval.src_reg).Base.Index);
if (!validate_inputs(& (yylsp[(1) - (1)]), state)) {
@@ -2802,11 +2810,9 @@ yyreduce:
case 61:
/* Line 1455 of yacc.c */
-#line 802 "program_parse.y"
+#line 810 "program_parse.y"
{
- init_src_reg(& (yyval.src_reg));
- (yyval.src_reg).Base.File = PROGRAM_INPUT;
- (yyval.src_reg).Base.Index = (yyvsp[(1) - (1)].attrib);
+ set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, (yyvsp[(1) - (1)].attrib));
state->prog->InputsRead |= (1U << (yyval.src_reg).Base.Index);
if (!validate_inputs(& (yylsp[(1) - (1)]), state)) {
@@ -2818,7 +2824,7 @@ yyreduce:
case 62:
/* Line 1455 of yacc.c */
-#line 813 "program_parse.y"
+#line 819 "program_parse.y"
{
if (! (yyvsp[(3) - (4)].src_reg).Base.RelAddr
&& ((unsigned) (yyvsp[(3) - (4)].src_reg).Base.Index >= (yyvsp[(1) - (4)].sym)->param_binding_length)) {
@@ -2844,35 +2850,34 @@ yyreduce:
case 63:
/* Line 1455 of yacc.c */
-#line 834 "program_parse.y"
+#line 840 "program_parse.y"
{
- init_src_reg(& (yyval.src_reg));
- (yyval.src_reg).Base.File = ((yyvsp[(1) - (1)].temp_sym).name != NULL)
+ gl_register_file file = ((yyvsp[(1) - (1)].temp_sym).name != NULL)
? (yyvsp[(1) - (1)].temp_sym).param_binding_type
: PROGRAM_CONSTANT;
- (yyval.src_reg).Base.Index = (yyvsp[(1) - (1)].temp_sym).param_binding_begin;
+ set_src_reg(& (yyval.src_reg), file, (yyvsp[(1) - (1)].temp_sym).param_binding_begin);
;}
break;
case 64:
/* Line 1455 of yacc.c */
-#line 844 "program_parse.y"
+#line 849 "program_parse.y"
{
- init_dst_reg(& (yyval.dst_reg));
- (yyval.dst_reg).File = PROGRAM_OUTPUT;
- (yyval.dst_reg).Index = (yyvsp[(1) - (1)].result);
+ set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, (yyvsp[(1) - (1)].result));
;}
break;
case 65:
/* Line 1455 of yacc.c */
-#line 850 "program_parse.y"
+#line 853 "program_parse.y"
{
struct asm_symbol *const s = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string));
+ free((yyvsp[(1) - (1)].string));
+
if (s == NULL) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable");
YYERROR;
@@ -2881,19 +2886,15 @@ yyreduce:
YYERROR;
}
- init_dst_reg(& (yyval.dst_reg));
switch (s->type) {
case at_temp:
- (yyval.dst_reg).File = PROGRAM_TEMPORARY;
- (yyval.dst_reg).Index = s->temp_binding;
+ set_dst_reg(& (yyval.dst_reg), PROGRAM_TEMPORARY, s->temp_binding);
break;
case at_output:
- (yyval.dst_reg).File = PROGRAM_OUTPUT;
- (yyval.dst_reg).Index = s->output_binding;
+ set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, s->output_binding);
break;
default:
- (yyval.dst_reg).File = s->param_binding_type;
- (yyval.dst_reg).Index = s->param_binding_begin;
+ set_dst_reg(& (yyval.dst_reg), s->param_binding_type, s->param_binding_begin);
break;
}
;}
@@ -2902,11 +2903,13 @@ yyreduce:
case 66:
/* Line 1455 of yacc.c */
-#line 881 "program_parse.y"
+#line 882 "program_parse.y"
{
struct asm_symbol *const s = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string));
+ free((yyvsp[(1) - (1)].string));
+
if (s == NULL) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable");
YYERROR;
@@ -2922,7 +2925,7 @@ yyreduce:
case 69:
/* Line 1455 of yacc.c */
-#line 900 "program_parse.y"
+#line 903 "program_parse.y"
{
init_src_reg(& (yyval.src_reg));
(yyval.src_reg).Base.Index = (yyvsp[(1) - (1)].integer);
@@ -2932,7 +2935,7 @@ yyreduce:
case 70:
/* Line 1455 of yacc.c */
-#line 907 "program_parse.y"
+#line 910 "program_parse.y"
{
/* FINISHME: Add support for multiple address registers.
*/
@@ -2947,28 +2950,28 @@ yyreduce:
case 71:
/* Line 1455 of yacc.c */
-#line 918 "program_parse.y"
+#line 921 "program_parse.y"
{ (yyval.integer) = 0; ;}
break;
case 72:
/* Line 1455 of yacc.c */
-#line 919 "program_parse.y"
+#line 922 "program_parse.y"
{ (yyval.integer) = (yyvsp[(2) - (2)].integer); ;}
break;
case 73:
/* Line 1455 of yacc.c */
-#line 920 "program_parse.y"
+#line 923 "program_parse.y"
{ (yyval.integer) = -(yyvsp[(2) - (2)].integer); ;}
break;
case 74:
/* Line 1455 of yacc.c */
-#line 924 "program_parse.y"
+#line 927 "program_parse.y"
{
if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 63)) {
char s[100];
@@ -2985,7 +2988,7 @@ yyreduce:
case 75:
/* Line 1455 of yacc.c */
-#line 938 "program_parse.y"
+#line 941 "program_parse.y"
{
if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 64)) {
char s[100];
@@ -3002,11 +3005,13 @@ yyreduce:
case 76:
/* Line 1455 of yacc.c */
-#line 952 "program_parse.y"
+#line 955 "program_parse.y"
{
struct asm_symbol *const s = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string));
+ free((yyvsp[(1) - (1)].string));
+
if (s == NULL) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid array member");
YYERROR;
@@ -3023,7 +3028,7 @@ yyreduce:
case 77:
/* Line 1455 of yacc.c */
-#line 970 "program_parse.y"
+#line 975 "program_parse.y"
{
if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid address component selector");
@@ -3037,7 +3042,7 @@ yyreduce:
case 78:
/* Line 1455 of yacc.c */
-#line 981 "program_parse.y"
+#line 986 "program_parse.y"
{
if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) {
yyerror(& (yylsp[(1) - (1)]), state,
@@ -3052,21 +3057,21 @@ yyreduce:
case 83:
/* Line 1455 of yacc.c */
-#line 997 "program_parse.y"
+#line 1002 "program_parse.y"
{ (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;}
break;
case 88:
/* Line 1455 of yacc.c */
-#line 1001 "program_parse.y"
+#line 1006 "program_parse.y"
{ (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;}
break;
case 89:
/* Line 1455 of yacc.c */
-#line 1005 "program_parse.y"
+#line 1010 "program_parse.y"
{
(yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg);
;}
@@ -3075,7 +3080,7 @@ yyreduce:
case 90:
/* Line 1455 of yacc.c */
-#line 1009 "program_parse.y"
+#line 1014 "program_parse.y"
{
(yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg);
;}
@@ -3084,7 +3089,7 @@ yyreduce:
case 91:
/* Line 1455 of yacc.c */
-#line 1013 "program_parse.y"
+#line 1018 "program_parse.y"
{
(yyval.dst_reg).CondMask = COND_TR;
(yyval.dst_reg).CondSwizzle = SWIZZLE_NOOP;
@@ -3095,7 +3100,7 @@ yyreduce:
case 92:
/* Line 1455 of yacc.c */
-#line 1021 "program_parse.y"
+#line 1026 "program_parse.y"
{
(yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg);
(yyval.dst_reg).CondSwizzle = (yyvsp[(2) - (2)].swiz_mask).swizzle;
@@ -3105,7 +3110,7 @@ yyreduce:
case 93:
/* Line 1455 of yacc.c */
-#line 1028 "program_parse.y"
+#line 1033 "program_parse.y"
{
(yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg);
(yyval.dst_reg).CondSwizzle = (yyvsp[(2) - (2)].swiz_mask).swizzle;
@@ -3115,7 +3120,7 @@ yyreduce:
case 94:
/* Line 1455 of yacc.c */
-#line 1035 "program_parse.y"
+#line 1040 "program_parse.y"
{
const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string));
if ((cond == 0) || ((yyvsp[(1) - (1)].string)[2] != '\0')) {
@@ -3141,7 +3146,7 @@ yyreduce:
case 95:
/* Line 1455 of yacc.c */
-#line 1058 "program_parse.y"
+#line 1063 "program_parse.y"
{
const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string));
if ((cond == 0) || ((yyvsp[(1) - (1)].string)[2] != '\0')) {
@@ -3167,12 +3172,13 @@ yyreduce:
case 102:
/* Line 1455 of yacc.c */
-#line 1089 "program_parse.y"
+#line 1094 "program_parse.y"
{
struct asm_symbol *const s =
declare_variable(state, (yyvsp[(2) - (4)].string), at_attrib, & (yylsp[(2) - (4)]));
if (s == NULL) {
+ free((yyvsp[(2) - (4)].string));
YYERROR;
} else {
s->attrib_binding = (yyvsp[(4) - (4)].attrib);
@@ -3188,7 +3194,7 @@ yyreduce:
case 103:
/* Line 1455 of yacc.c */
-#line 1107 "program_parse.y"
+#line 1113 "program_parse.y"
{
(yyval.attrib) = (yyvsp[(2) - (2)].attrib);
;}
@@ -3197,7 +3203,7 @@ yyreduce:
case 104:
/* Line 1455 of yacc.c */
-#line 1111 "program_parse.y"
+#line 1117 "program_parse.y"
{
(yyval.attrib) = (yyvsp[(2) - (2)].attrib);
;}
@@ -3206,7 +3212,7 @@ yyreduce:
case 105:
/* Line 1455 of yacc.c */
-#line 1117 "program_parse.y"
+#line 1123 "program_parse.y"
{
(yyval.attrib) = VERT_ATTRIB_POS;
;}
@@ -3215,7 +3221,7 @@ yyreduce:
case 106:
/* Line 1455 of yacc.c */
-#line 1121 "program_parse.y"
+#line 1127 "program_parse.y"
{
(yyval.attrib) = VERT_ATTRIB_WEIGHT;
;}
@@ -3224,7 +3230,7 @@ yyreduce:
case 107:
/* Line 1455 of yacc.c */
-#line 1125 "program_parse.y"
+#line 1131 "program_parse.y"
{
(yyval.attrib) = VERT_ATTRIB_NORMAL;
;}
@@ -3233,7 +3239,7 @@ yyreduce:
case 108:
/* Line 1455 of yacc.c */
-#line 1129 "program_parse.y"
+#line 1135 "program_parse.y"
{
if (!state->ctx->Extensions.EXT_secondary_color) {
yyerror(& (yylsp[(2) - (2)]), state, "GL_EXT_secondary_color not supported");
@@ -3247,7 +3253,7 @@ yyreduce:
case 109:
/* Line 1455 of yacc.c */
-#line 1138 "program_parse.y"
+#line 1144 "program_parse.y"
{
if (!state->ctx->Extensions.EXT_fog_coord) {
yyerror(& (yylsp[(1) - (1)]), state, "GL_EXT_fog_coord not supported");
@@ -3261,7 +3267,7 @@ yyreduce:
case 110:
/* Line 1455 of yacc.c */
-#line 1147 "program_parse.y"
+#line 1153 "program_parse.y"
{
(yyval.attrib) = VERT_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer);
;}
@@ -3270,7 +3276,7 @@ yyreduce:
case 111:
/* Line 1455 of yacc.c */
-#line 1151 "program_parse.y"
+#line 1157 "program_parse.y"
{
yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported");
YYERROR;
@@ -3280,7 +3286,7 @@ yyreduce:
case 112:
/* Line 1455 of yacc.c */
-#line 1156 "program_parse.y"
+#line 1162 "program_parse.y"
{
(yyval.attrib) = VERT_ATTRIB_GENERIC0 + (yyvsp[(3) - (4)].integer);
;}
@@ -3289,7 +3295,7 @@ yyreduce:
case 113:
/* Line 1455 of yacc.c */
-#line 1162 "program_parse.y"
+#line 1168 "program_parse.y"
{
if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxAttribs) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid vertex attribute reference");
@@ -3303,7 +3309,7 @@ yyreduce:
case 117:
/* Line 1455 of yacc.c */
-#line 1176 "program_parse.y"
+#line 1182 "program_parse.y"
{
(yyval.attrib) = FRAG_ATTRIB_WPOS;
;}
@@ -3312,7 +3318,7 @@ yyreduce:
case 118:
/* Line 1455 of yacc.c */
-#line 1180 "program_parse.y"
+#line 1186 "program_parse.y"
{
(yyval.attrib) = FRAG_ATTRIB_COL0 + (yyvsp[(2) - (2)].integer);
;}
@@ -3321,7 +3327,7 @@ yyreduce:
case 119:
/* Line 1455 of yacc.c */
-#line 1184 "program_parse.y"
+#line 1190 "program_parse.y"
{
(yyval.attrib) = FRAG_ATTRIB_FOGC;
;}
@@ -3330,7 +3336,7 @@ yyreduce:
case 120:
/* Line 1455 of yacc.c */
-#line 1188 "program_parse.y"
+#line 1194 "program_parse.y"
{
(yyval.attrib) = FRAG_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer);
;}
@@ -3339,12 +3345,13 @@ yyreduce:
case 123:
/* Line 1455 of yacc.c */
-#line 1196 "program_parse.y"
+#line 1202 "program_parse.y"
{
struct asm_symbol *const s =
declare_variable(state, (yyvsp[(2) - (3)].string), at_param, & (yylsp[(2) - (3)]));
if (s == NULL) {
+ free((yyvsp[(2) - (3)].string));
YYERROR;
} else {
s->param_binding_type = (yyvsp[(3) - (3)].temp_sym).param_binding_type;
@@ -3358,9 +3365,10 @@ yyreduce:
case 124:
/* Line 1455 of yacc.c */
-#line 1212 "program_parse.y"
+#line 1219 "program_parse.y"
{
if (((yyvsp[(4) - (6)].integer) != 0) && ((unsigned) (yyvsp[(4) - (6)].integer) != (yyvsp[(6) - (6)].temp_sym).param_binding_length)) {
+ free((yyvsp[(2) - (6)].string));
yyerror(& (yylsp[(4) - (6)]), state,
"parameter array size and number of bindings must match");
YYERROR;
@@ -3369,6 +3377,7 @@ yyreduce:
declare_variable(state, (yyvsp[(2) - (6)].string), (yyvsp[(6) - (6)].temp_sym).type, & (yylsp[(2) - (6)]));
if (s == NULL) {
+ free((yyvsp[(2) - (6)].string));
YYERROR;
} else {
s->param_binding_type = (yyvsp[(6) - (6)].temp_sym).param_binding_type;
@@ -3383,7 +3392,7 @@ yyreduce:
case 125:
/* Line 1455 of yacc.c */
-#line 1234 "program_parse.y"
+#line 1243 "program_parse.y"
{
(yyval.integer) = 0;
;}
@@ -3392,9 +3401,9 @@ yyreduce:
case 126:
/* Line 1455 of yacc.c */
-#line 1238 "program_parse.y"
+#line 1247 "program_parse.y"
{
- if (((yyvsp[(1) - (1)].integer) < 1) || ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxParameters)) {
+ if (((yyvsp[(1) - (1)].integer) < 1) || ((unsigned) (yyvsp[(1) - (1)].integer) > state->limits->MaxParameters)) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid parameter array size");
YYERROR;
} else {
@@ -3406,7 +3415,7 @@ yyreduce:
case 127:
/* Line 1455 of yacc.c */
-#line 1249 "program_parse.y"
+#line 1258 "program_parse.y"
{
(yyval.temp_sym) = (yyvsp[(2) - (2)].temp_sym);
;}
@@ -3415,7 +3424,7 @@ yyreduce:
case 128:
/* Line 1455 of yacc.c */
-#line 1255 "program_parse.y"
+#line 1264 "program_parse.y"
{
(yyval.temp_sym) = (yyvsp[(3) - (4)].temp_sym);
;}
@@ -3424,7 +3433,7 @@ yyreduce:
case 130:
/* Line 1455 of yacc.c */
-#line 1262 "program_parse.y"
+#line 1271 "program_parse.y"
{
(yyvsp[(1) - (3)].temp_sym).param_binding_length += (yyvsp[(3) - (3)].temp_sym).param_binding_length;
(yyval.temp_sym) = (yyvsp[(1) - (3)].temp_sym);
@@ -3434,7 +3443,7 @@ yyreduce:
case 131:
/* Line 1455 of yacc.c */
-#line 1269 "program_parse.y"
+#line 1278 "program_parse.y"
{
memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
(yyval.temp_sym).param_binding_begin = ~0;
@@ -3445,7 +3454,7 @@ yyreduce:
case 132:
/* Line 1455 of yacc.c */
-#line 1275 "program_parse.y"
+#line 1284 "program_parse.y"
{
memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
(yyval.temp_sym).param_binding_begin = ~0;
@@ -3456,7 +3465,7 @@ yyreduce:
case 133:
/* Line 1455 of yacc.c */
-#line 1281 "program_parse.y"
+#line 1290 "program_parse.y"
{
memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
(yyval.temp_sym).param_binding_begin = ~0;
@@ -3467,7 +3476,7 @@ yyreduce:
case 134:
/* Line 1455 of yacc.c */
-#line 1289 "program_parse.y"
+#line 1298 "program_parse.y"
{
memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
(yyval.temp_sym).param_binding_begin = ~0;
@@ -3478,7 +3487,7 @@ yyreduce:
case 135:
/* Line 1455 of yacc.c */
-#line 1295 "program_parse.y"
+#line 1304 "program_parse.y"
{
memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
(yyval.temp_sym).param_binding_begin = ~0;
@@ -3489,7 +3498,7 @@ yyreduce:
case 136:
/* Line 1455 of yacc.c */
-#line 1301 "program_parse.y"
+#line 1310 "program_parse.y"
{
memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
(yyval.temp_sym).param_binding_begin = ~0;
@@ -3500,7 +3509,7 @@ yyreduce:
case 137:
/* Line 1455 of yacc.c */
-#line 1309 "program_parse.y"
+#line 1318 "program_parse.y"
{
memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
(yyval.temp_sym).param_binding_begin = ~0;
@@ -3511,7 +3520,7 @@ yyreduce:
case 138:
/* Line 1455 of yacc.c */
-#line 1315 "program_parse.y"
+#line 1324 "program_parse.y"
{
memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
(yyval.temp_sym).param_binding_begin = ~0;
@@ -3522,7 +3531,7 @@ yyreduce:
case 139:
/* Line 1455 of yacc.c */
-#line 1321 "program_parse.y"
+#line 1330 "program_parse.y"
{
memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym)));
(yyval.temp_sym).param_binding_begin = ~0;
@@ -3533,98 +3542,98 @@ yyreduce:
case 140:
/* Line 1455 of yacc.c */
-#line 1328 "program_parse.y"
+#line 1337 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(1) - (1)].state), sizeof((yyval.state))); ;}
break;
case 141:
/* Line 1455 of yacc.c */
-#line 1329 "program_parse.y"
+#line 1338 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 142:
/* Line 1455 of yacc.c */
-#line 1332 "program_parse.y"
+#line 1341 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 143:
/* Line 1455 of yacc.c */
-#line 1333 "program_parse.y"
+#line 1342 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 144:
/* Line 1455 of yacc.c */
-#line 1334 "program_parse.y"
+#line 1343 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 145:
/* Line 1455 of yacc.c */
-#line 1335 "program_parse.y"
+#line 1344 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 146:
/* Line 1455 of yacc.c */
-#line 1336 "program_parse.y"
+#line 1345 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 147:
/* Line 1455 of yacc.c */
-#line 1337 "program_parse.y"
+#line 1346 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 148:
/* Line 1455 of yacc.c */
-#line 1338 "program_parse.y"
+#line 1347 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 149:
/* Line 1455 of yacc.c */
-#line 1339 "program_parse.y"
+#line 1348 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 150:
/* Line 1455 of yacc.c */
-#line 1340 "program_parse.y"
+#line 1349 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 151:
/* Line 1455 of yacc.c */
-#line 1341 "program_parse.y"
+#line 1350 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 152:
/* Line 1455 of yacc.c */
-#line 1342 "program_parse.y"
+#line 1351 "program_parse.y"
{ memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;}
break;
case 153:
/* Line 1455 of yacc.c */
-#line 1346 "program_parse.y"
+#line 1355 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = STATE_MATERIAL;
@@ -3636,7 +3645,7 @@ yyreduce:
case 154:
/* Line 1455 of yacc.c */
-#line 1355 "program_parse.y"
+#line 1364 "program_parse.y"
{
(yyval.integer) = (yyvsp[(1) - (1)].integer);
;}
@@ -3645,7 +3654,7 @@ yyreduce:
case 155:
/* Line 1455 of yacc.c */
-#line 1359 "program_parse.y"
+#line 1368 "program_parse.y"
{
(yyval.integer) = STATE_EMISSION;
;}
@@ -3654,7 +3663,7 @@ yyreduce:
case 156:
/* Line 1455 of yacc.c */
-#line 1363 "program_parse.y"
+#line 1372 "program_parse.y"
{
(yyval.integer) = STATE_SHININESS;
;}
@@ -3663,7 +3672,7 @@ yyreduce:
case 157:
/* Line 1455 of yacc.c */
-#line 1369 "program_parse.y"
+#line 1378 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = STATE_LIGHT;
@@ -3675,7 +3684,7 @@ yyreduce:
case 158:
/* Line 1455 of yacc.c */
-#line 1378 "program_parse.y"
+#line 1387 "program_parse.y"
{
(yyval.integer) = (yyvsp[(1) - (1)].integer);
;}
@@ -3684,7 +3693,7 @@ yyreduce:
case 159:
/* Line 1455 of yacc.c */
-#line 1382 "program_parse.y"
+#line 1391 "program_parse.y"
{
(yyval.integer) = STATE_POSITION;
;}
@@ -3693,7 +3702,7 @@ yyreduce:
case 160:
/* Line 1455 of yacc.c */
-#line 1386 "program_parse.y"
+#line 1395 "program_parse.y"
{
if (!state->ctx->Extensions.EXT_point_parameters) {
yyerror(& (yylsp[(1) - (1)]), state, "GL_ARB_point_parameters not supported");
@@ -3707,7 +3716,7 @@ yyreduce:
case 161:
/* Line 1455 of yacc.c */
-#line 1395 "program_parse.y"
+#line 1404 "program_parse.y"
{
(yyval.integer) = (yyvsp[(2) - (2)].integer);
;}
@@ -3716,7 +3725,7 @@ yyreduce:
case 162:
/* Line 1455 of yacc.c */
-#line 1399 "program_parse.y"
+#line 1408 "program_parse.y"
{
(yyval.integer) = STATE_HALF_VECTOR;
;}
@@ -3725,7 +3734,7 @@ yyreduce:
case 163:
/* Line 1455 of yacc.c */
-#line 1405 "program_parse.y"
+#line 1414 "program_parse.y"
{
(yyval.integer) = STATE_SPOT_DIRECTION;
;}
@@ -3734,7 +3743,7 @@ yyreduce:
case 164:
/* Line 1455 of yacc.c */
-#line 1411 "program_parse.y"
+#line 1420 "program_parse.y"
{
(yyval.state)[0] = (yyvsp[(2) - (2)].state)[0];
(yyval.state)[1] = (yyvsp[(2) - (2)].state)[1];
@@ -3744,7 +3753,7 @@ yyreduce:
case 165:
/* Line 1455 of yacc.c */
-#line 1418 "program_parse.y"
+#line 1427 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = STATE_LIGHTMODEL_AMBIENT;
@@ -3754,7 +3763,7 @@ yyreduce:
case 166:
/* Line 1455 of yacc.c */
-#line 1423 "program_parse.y"
+#line 1432 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = STATE_LIGHTMODEL_SCENECOLOR;
@@ -3765,7 +3774,7 @@ yyreduce:
case 167:
/* Line 1455 of yacc.c */
-#line 1431 "program_parse.y"
+#line 1440 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = STATE_LIGHTPROD;
@@ -3778,7 +3787,7 @@ yyreduce:
case 169:
/* Line 1455 of yacc.c */
-#line 1443 "program_parse.y"
+#line 1452 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = (yyvsp[(3) - (3)].integer);
@@ -3789,7 +3798,7 @@ yyreduce:
case 170:
/* Line 1455 of yacc.c */
-#line 1451 "program_parse.y"
+#line 1460 "program_parse.y"
{
(yyval.integer) = STATE_TEXENV_COLOR;
;}
@@ -3798,7 +3807,7 @@ yyreduce:
case 171:
/* Line 1455 of yacc.c */
-#line 1457 "program_parse.y"
+#line 1466 "program_parse.y"
{
(yyval.integer) = STATE_AMBIENT;
;}
@@ -3807,7 +3816,7 @@ yyreduce:
case 172:
/* Line 1455 of yacc.c */
-#line 1461 "program_parse.y"
+#line 1470 "program_parse.y"
{
(yyval.integer) = STATE_DIFFUSE;
;}
@@ -3816,7 +3825,7 @@ yyreduce:
case 173:
/* Line 1455 of yacc.c */
-#line 1465 "program_parse.y"
+#line 1474 "program_parse.y"
{
(yyval.integer) = STATE_SPECULAR;
;}
@@ -3825,7 +3834,7 @@ yyreduce:
case 174:
/* Line 1455 of yacc.c */
-#line 1471 "program_parse.y"
+#line 1480 "program_parse.y"
{
if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxLights) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid light selector");
@@ -3839,7 +3848,7 @@ yyreduce:
case 175:
/* Line 1455 of yacc.c */
-#line 1482 "program_parse.y"
+#line 1491 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = STATE_TEXGEN;
@@ -3851,7 +3860,7 @@ yyreduce:
case 176:
/* Line 1455 of yacc.c */
-#line 1491 "program_parse.y"
+#line 1500 "program_parse.y"
{
(yyval.integer) = STATE_TEXGEN_EYE_S;
;}
@@ -3860,7 +3869,7 @@ yyreduce:
case 177:
/* Line 1455 of yacc.c */
-#line 1495 "program_parse.y"
+#line 1504 "program_parse.y"
{
(yyval.integer) = STATE_TEXGEN_OBJECT_S;
;}
@@ -3869,7 +3878,7 @@ yyreduce:
case 178:
/* Line 1455 of yacc.c */
-#line 1500 "program_parse.y"
+#line 1509 "program_parse.y"
{
(yyval.integer) = STATE_TEXGEN_EYE_S - STATE_TEXGEN_EYE_S;
;}
@@ -3878,7 +3887,7 @@ yyreduce:
case 179:
/* Line 1455 of yacc.c */
-#line 1504 "program_parse.y"
+#line 1513 "program_parse.y"
{
(yyval.integer) = STATE_TEXGEN_EYE_T - STATE_TEXGEN_EYE_S;
;}
@@ -3887,7 +3896,7 @@ yyreduce:
case 180:
/* Line 1455 of yacc.c */
-#line 1508 "program_parse.y"
+#line 1517 "program_parse.y"
{
(yyval.integer) = STATE_TEXGEN_EYE_R - STATE_TEXGEN_EYE_S;
;}
@@ -3896,7 +3905,7 @@ yyreduce:
case 181:
/* Line 1455 of yacc.c */
-#line 1512 "program_parse.y"
+#line 1521 "program_parse.y"
{
(yyval.integer) = STATE_TEXGEN_EYE_Q - STATE_TEXGEN_EYE_S;
;}
@@ -3905,7 +3914,7 @@ yyreduce:
case 182:
/* Line 1455 of yacc.c */
-#line 1518 "program_parse.y"
+#line 1527 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = (yyvsp[(2) - (2)].integer);
@@ -3915,7 +3924,7 @@ yyreduce:
case 183:
/* Line 1455 of yacc.c */
-#line 1525 "program_parse.y"
+#line 1534 "program_parse.y"
{
(yyval.integer) = STATE_FOG_COLOR;
;}
@@ -3924,7 +3933,7 @@ yyreduce:
case 184:
/* Line 1455 of yacc.c */
-#line 1529 "program_parse.y"
+#line 1538 "program_parse.y"
{
(yyval.integer) = STATE_FOG_PARAMS;
;}
@@ -3933,7 +3942,7 @@ yyreduce:
case 185:
/* Line 1455 of yacc.c */
-#line 1535 "program_parse.y"
+#line 1544 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = STATE_CLIPPLANE;
@@ -3944,7 +3953,7 @@ yyreduce:
case 186:
/* Line 1455 of yacc.c */
-#line 1543 "program_parse.y"
+#line 1552 "program_parse.y"
{
if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxClipPlanes) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid clip plane selector");
@@ -3958,7 +3967,7 @@ yyreduce:
case 187:
/* Line 1455 of yacc.c */
-#line 1554 "program_parse.y"
+#line 1563 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = (yyvsp[(2) - (2)].integer);
@@ -3968,7 +3977,7 @@ yyreduce:
case 188:
/* Line 1455 of yacc.c */
-#line 1561 "program_parse.y"
+#line 1570 "program_parse.y"
{
(yyval.integer) = STATE_POINT_SIZE;
;}
@@ -3977,7 +3986,7 @@ yyreduce:
case 189:
/* Line 1455 of yacc.c */
-#line 1565 "program_parse.y"
+#line 1574 "program_parse.y"
{
(yyval.integer) = STATE_POINT_ATTENUATION;
;}
@@ -3986,7 +3995,7 @@ yyreduce:
case 190:
/* Line 1455 of yacc.c */
-#line 1571 "program_parse.y"
+#line 1580 "program_parse.y"
{
(yyval.state)[0] = (yyvsp[(1) - (5)].state)[0];
(yyval.state)[1] = (yyvsp[(1) - (5)].state)[1];
@@ -3999,7 +4008,7 @@ yyreduce:
case 191:
/* Line 1455 of yacc.c */
-#line 1581 "program_parse.y"
+#line 1590 "program_parse.y"
{
(yyval.state)[0] = (yyvsp[(1) - (2)].state)[0];
(yyval.state)[1] = (yyvsp[(1) - (2)].state)[1];
@@ -4012,7 +4021,7 @@ yyreduce:
case 192:
/* Line 1455 of yacc.c */
-#line 1591 "program_parse.y"
+#line 1600 "program_parse.y"
{
(yyval.state)[2] = 0;
(yyval.state)[3] = 3;
@@ -4022,7 +4031,7 @@ yyreduce:
case 193:
/* Line 1455 of yacc.c */
-#line 1596 "program_parse.y"
+#line 1605 "program_parse.y"
{
/* It seems logical that the matrix row range specifier would have
* to specify a range or more than one row (i.e., $5 > $3).
@@ -4043,7 +4052,7 @@ yyreduce:
case 194:
/* Line 1455 of yacc.c */
-#line 1614 "program_parse.y"
+#line 1623 "program_parse.y"
{
(yyval.state)[0] = (yyvsp[(2) - (3)].state)[0];
(yyval.state)[1] = (yyvsp[(2) - (3)].state)[1];
@@ -4054,7 +4063,7 @@ yyreduce:
case 195:
/* Line 1455 of yacc.c */
-#line 1622 "program_parse.y"
+#line 1631 "program_parse.y"
{
(yyval.integer) = 0;
;}
@@ -4063,7 +4072,7 @@ yyreduce:
case 196:
/* Line 1455 of yacc.c */
-#line 1626 "program_parse.y"
+#line 1635 "program_parse.y"
{
(yyval.integer) = (yyvsp[(1) - (1)].integer);
;}
@@ -4072,7 +4081,7 @@ yyreduce:
case 197:
/* Line 1455 of yacc.c */
-#line 1632 "program_parse.y"
+#line 1641 "program_parse.y"
{
(yyval.integer) = STATE_MATRIX_INVERSE;
;}
@@ -4081,7 +4090,7 @@ yyreduce:
case 198:
/* Line 1455 of yacc.c */
-#line 1636 "program_parse.y"
+#line 1645 "program_parse.y"
{
(yyval.integer) = STATE_MATRIX_TRANSPOSE;
;}
@@ -4090,7 +4099,7 @@ yyreduce:
case 199:
/* Line 1455 of yacc.c */
-#line 1640 "program_parse.y"
+#line 1649 "program_parse.y"
{
(yyval.integer) = STATE_MATRIX_INVTRANS;
;}
@@ -4099,7 +4108,7 @@ yyreduce:
case 200:
/* Line 1455 of yacc.c */
-#line 1646 "program_parse.y"
+#line 1655 "program_parse.y"
{
if ((yyvsp[(1) - (1)].integer) > 3) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid matrix row reference");
@@ -4113,7 +4122,7 @@ yyreduce:
case 201:
/* Line 1455 of yacc.c */
-#line 1657 "program_parse.y"
+#line 1666 "program_parse.y"
{
(yyval.state)[0] = STATE_MODELVIEW_MATRIX;
(yyval.state)[1] = (yyvsp[(2) - (2)].integer);
@@ -4123,7 +4132,7 @@ yyreduce:
case 202:
/* Line 1455 of yacc.c */
-#line 1662 "program_parse.y"
+#line 1671 "program_parse.y"
{
(yyval.state)[0] = STATE_PROJECTION_MATRIX;
(yyval.state)[1] = 0;
@@ -4133,7 +4142,7 @@ yyreduce:
case 203:
/* Line 1455 of yacc.c */
-#line 1667 "program_parse.y"
+#line 1676 "program_parse.y"
{
(yyval.state)[0] = STATE_MVP_MATRIX;
(yyval.state)[1] = 0;
@@ -4143,7 +4152,7 @@ yyreduce:
case 204:
/* Line 1455 of yacc.c */
-#line 1672 "program_parse.y"
+#line 1681 "program_parse.y"
{
(yyval.state)[0] = STATE_TEXTURE_MATRIX;
(yyval.state)[1] = (yyvsp[(2) - (2)].integer);
@@ -4153,7 +4162,7 @@ yyreduce:
case 205:
/* Line 1455 of yacc.c */
-#line 1677 "program_parse.y"
+#line 1686 "program_parse.y"
{
yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported");
YYERROR;
@@ -4163,7 +4172,7 @@ yyreduce:
case 206:
/* Line 1455 of yacc.c */
-#line 1682 "program_parse.y"
+#line 1691 "program_parse.y"
{
(yyval.state)[0] = STATE_PROGRAM_MATRIX;
(yyval.state)[1] = (yyvsp[(3) - (4)].integer);
@@ -4173,7 +4182,7 @@ yyreduce:
case 207:
/* Line 1455 of yacc.c */
-#line 1689 "program_parse.y"
+#line 1698 "program_parse.y"
{
(yyval.integer) = 0;
;}
@@ -4182,7 +4191,7 @@ yyreduce:
case 208:
/* Line 1455 of yacc.c */
-#line 1693 "program_parse.y"
+#line 1702 "program_parse.y"
{
(yyval.integer) = (yyvsp[(2) - (3)].integer);
;}
@@ -4191,7 +4200,7 @@ yyreduce:
case 209:
/* Line 1455 of yacc.c */
-#line 1698 "program_parse.y"
+#line 1707 "program_parse.y"
{
/* Since GL_ARB_vertex_blend isn't supported, only modelview matrix
* zero is valid.
@@ -4208,7 +4217,7 @@ yyreduce:
case 210:
/* Line 1455 of yacc.c */
-#line 1711 "program_parse.y"
+#line 1720 "program_parse.y"
{
/* Since GL_ARB_matrix_palette isn't supported, just let any value
* through here. The error will be generated later.
@@ -4220,7 +4229,7 @@ yyreduce:
case 211:
/* Line 1455 of yacc.c */
-#line 1719 "program_parse.y"
+#line 1728 "program_parse.y"
{
if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxProgramMatrices) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid program matrix selector");
@@ -4234,7 +4243,7 @@ yyreduce:
case 212:
/* Line 1455 of yacc.c */
-#line 1730 "program_parse.y"
+#line 1739 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = STATE_DEPTH_RANGE;
@@ -4244,7 +4253,7 @@ yyreduce:
case 217:
/* Line 1455 of yacc.c */
-#line 1742 "program_parse.y"
+#line 1751 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = state->state_param_enum;
@@ -4257,7 +4266,7 @@ yyreduce:
case 218:
/* Line 1455 of yacc.c */
-#line 1752 "program_parse.y"
+#line 1761 "program_parse.y"
{
(yyval.state)[0] = (yyvsp[(1) - (1)].integer);
(yyval.state)[1] = (yyvsp[(1) - (1)].integer);
@@ -4267,7 +4276,7 @@ yyreduce:
case 219:
/* Line 1455 of yacc.c */
-#line 1757 "program_parse.y"
+#line 1766 "program_parse.y"
{
(yyval.state)[0] = (yyvsp[(1) - (3)].integer);
(yyval.state)[1] = (yyvsp[(3) - (3)].integer);
@@ -4277,7 +4286,7 @@ yyreduce:
case 220:
/* Line 1455 of yacc.c */
-#line 1764 "program_parse.y"
+#line 1773 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = state->state_param_enum;
@@ -4290,7 +4299,7 @@ yyreduce:
case 221:
/* Line 1455 of yacc.c */
-#line 1774 "program_parse.y"
+#line 1783 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = state->state_param_enum;
@@ -4303,7 +4312,7 @@ yyreduce:
case 222:
/* Line 1455 of yacc.c */
-#line 1783 "program_parse.y"
+#line 1792 "program_parse.y"
{
(yyval.state)[0] = (yyvsp[(1) - (1)].integer);
(yyval.state)[1] = (yyvsp[(1) - (1)].integer);
@@ -4313,7 +4322,7 @@ yyreduce:
case 223:
/* Line 1455 of yacc.c */
-#line 1788 "program_parse.y"
+#line 1797 "program_parse.y"
{
(yyval.state)[0] = (yyvsp[(1) - (3)].integer);
(yyval.state)[1] = (yyvsp[(3) - (3)].integer);
@@ -4323,7 +4332,7 @@ yyreduce:
case 224:
/* Line 1455 of yacc.c */
-#line 1795 "program_parse.y"
+#line 1804 "program_parse.y"
{
memset((yyval.state), 0, sizeof((yyval.state)));
(yyval.state)[0] = state->state_param_enum;
@@ -4336,7 +4345,7 @@ yyreduce:
case 225:
/* Line 1455 of yacc.c */
-#line 1805 "program_parse.y"
+#line 1814 "program_parse.y"
{
if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxEnvParams) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid environment parameter reference");
@@ -4349,7 +4358,7 @@ yyreduce:
case 226:
/* Line 1455 of yacc.c */
-#line 1815 "program_parse.y"
+#line 1824 "program_parse.y"
{
if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxLocalParams) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid local parameter reference");
@@ -4362,7 +4371,7 @@ yyreduce:
case 231:
/* Line 1455 of yacc.c */
-#line 1830 "program_parse.y"
+#line 1839 "program_parse.y"
{
(yyval.vector).count = 4;
(yyval.vector).data[0] = (yyvsp[(1) - (1)].real);
@@ -4375,7 +4384,7 @@ yyreduce:
case 232:
/* Line 1455 of yacc.c */
-#line 1840 "program_parse.y"
+#line 1849 "program_parse.y"
{
(yyval.vector).count = 1;
(yyval.vector).data[0] = (yyvsp[(1) - (1)].real);
@@ -4388,7 +4397,7 @@ yyreduce:
case 233:
/* Line 1455 of yacc.c */
-#line 1848 "program_parse.y"
+#line 1857 "program_parse.y"
{
(yyval.vector).count = 1;
(yyval.vector).data[0] = (float) (yyvsp[(1) - (1)].integer);
@@ -4401,7 +4410,7 @@ yyreduce:
case 234:
/* Line 1455 of yacc.c */
-#line 1858 "program_parse.y"
+#line 1867 "program_parse.y"
{
(yyval.vector).count = 4;
(yyval.vector).data[0] = (yyvsp[(2) - (3)].real);
@@ -4414,7 +4423,7 @@ yyreduce:
case 235:
/* Line 1455 of yacc.c */
-#line 1866 "program_parse.y"
+#line 1875 "program_parse.y"
{
(yyval.vector).count = 4;
(yyval.vector).data[0] = (yyvsp[(2) - (5)].real);
@@ -4427,7 +4436,7 @@ yyreduce:
case 236:
/* Line 1455 of yacc.c */
-#line 1875 "program_parse.y"
+#line 1884 "program_parse.y"
{
(yyval.vector).count = 4;
(yyval.vector).data[0] = (yyvsp[(2) - (7)].real);
@@ -4440,7 +4449,7 @@ yyreduce:
case 237:
/* Line 1455 of yacc.c */
-#line 1884 "program_parse.y"
+#line 1893 "program_parse.y"
{
(yyval.vector).count = 4;
(yyval.vector).data[0] = (yyvsp[(2) - (9)].real);
@@ -4453,7 +4462,7 @@ yyreduce:
case 238:
/* Line 1455 of yacc.c */
-#line 1894 "program_parse.y"
+#line 1903 "program_parse.y"
{
(yyval.real) = ((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].real) : (yyvsp[(2) - (2)].real);
;}
@@ -4462,7 +4471,7 @@ yyreduce:
case 239:
/* Line 1455 of yacc.c */
-#line 1898 "program_parse.y"
+#line 1907 "program_parse.y"
{
(yyval.real) = (float)(((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].integer) : (yyvsp[(2) - (2)].integer));
;}
@@ -4471,35 +4480,35 @@ yyreduce:
case 240:
/* Line 1455 of yacc.c */
-#line 1903 "program_parse.y"
+#line 1912 "program_parse.y"
{ (yyval.negate) = FALSE; ;}
break;
case 241:
/* Line 1455 of yacc.c */
-#line 1904 "program_parse.y"
+#line 1913 "program_parse.y"
{ (yyval.negate) = TRUE; ;}
break;
case 242:
/* Line 1455 of yacc.c */
-#line 1905 "program_parse.y"
+#line 1914 "program_parse.y"
{ (yyval.negate) = FALSE; ;}
break;
case 243:
/* Line 1455 of yacc.c */
-#line 1908 "program_parse.y"
+#line 1917 "program_parse.y"
{ (yyval.integer) = (yyvsp[(2) - (2)].integer); ;}
break;
case 245:
/* Line 1455 of yacc.c */
-#line 1912 "program_parse.y"
+#line 1921 "program_parse.y"
{
/* NV_fragment_program_option defines the size qualifiers in a
* fairly broken way. "SHORT" or "LONG" can optionally be used
@@ -4538,7 +4547,7 @@ yyreduce:
case 246:
/* Line 1455 of yacc.c */
-#line 1946 "program_parse.y"
+#line 1955 "program_parse.y"
{
;}
break;
@@ -4546,16 +4555,17 @@ yyreduce:
case 247:
/* Line 1455 of yacc.c */
-#line 1950 "program_parse.y"
+#line 1959 "program_parse.y"
{ (yyval.integer) = (yyvsp[(1) - (1)].integer); ;}
break;
case 249:
/* Line 1455 of yacc.c */
-#line 1954 "program_parse.y"
+#line 1963 "program_parse.y"
{
if (!declare_variable(state, (yyvsp[(3) - (3)].string), (yyvsp[(0) - (3)].integer), & (yylsp[(3) - (3)]))) {
+ free((yyvsp[(3) - (3)].string));
YYERROR;
}
;}
@@ -4564,9 +4574,10 @@ yyreduce:
case 250:
/* Line 1455 of yacc.c */
-#line 1960 "program_parse.y"
+#line 1970 "program_parse.y"
{
if (!declare_variable(state, (yyvsp[(1) - (1)].string), (yyvsp[(0) - (1)].integer), & (yylsp[(1) - (1)]))) {
+ free((yyvsp[(1) - (1)].string));
YYERROR;
}
;}
@@ -4575,12 +4586,13 @@ yyreduce:
case 251:
/* Line 1455 of yacc.c */
-#line 1968 "program_parse.y"
+#line 1979 "program_parse.y"
{
struct asm_symbol *const s =
declare_variable(state, (yyvsp[(3) - (5)].string), at_output, & (yylsp[(3) - (5)]));
if (s == NULL) {
+ free((yyvsp[(3) - (5)].string));
YYERROR;
} else {
s->output_binding = (yyvsp[(5) - (5)].result);
@@ -4591,7 +4603,7 @@ yyreduce:
case 252:
/* Line 1455 of yacc.c */
-#line 1981 "program_parse.y"
+#line 1993 "program_parse.y"
{
if (state->mode == ARB_vertex) {
(yyval.result) = VERT_RESULT_HPOS;
@@ -4605,7 +4617,7 @@ yyreduce:
case 253:
/* Line 1455 of yacc.c */
-#line 1990 "program_parse.y"
+#line 2002 "program_parse.y"
{
if (state->mode == ARB_vertex) {
(yyval.result) = VERT_RESULT_FOGC;
@@ -4619,7 +4631,7 @@ yyreduce:
case 254:
/* Line 1455 of yacc.c */
-#line 1999 "program_parse.y"
+#line 2011 "program_parse.y"
{
(yyval.result) = (yyvsp[(2) - (2)].result);
;}
@@ -4628,7 +4640,7 @@ yyreduce:
case 255:
/* Line 1455 of yacc.c */
-#line 2003 "program_parse.y"
+#line 2015 "program_parse.y"
{
if (state->mode == ARB_vertex) {
(yyval.result) = VERT_RESULT_PSIZ;
@@ -4642,7 +4654,7 @@ yyreduce:
case 256:
/* Line 1455 of yacc.c */
-#line 2012 "program_parse.y"
+#line 2024 "program_parse.y"
{
if (state->mode == ARB_vertex) {
(yyval.result) = VERT_RESULT_TEX0 + (yyvsp[(3) - (3)].integer);
@@ -4656,7 +4668,7 @@ yyreduce:
case 257:
/* Line 1455 of yacc.c */
-#line 2021 "program_parse.y"
+#line 2033 "program_parse.y"
{
if (state->mode == ARB_fragment) {
(yyval.result) = FRAG_RESULT_DEPTH;
@@ -4670,7 +4682,7 @@ yyreduce:
case 258:
/* Line 1455 of yacc.c */
-#line 2032 "program_parse.y"
+#line 2044 "program_parse.y"
{
(yyval.result) = (yyvsp[(2) - (3)].integer) + (yyvsp[(3) - (3)].integer);
;}
@@ -4679,7 +4691,7 @@ yyreduce:
case 259:
/* Line 1455 of yacc.c */
-#line 2038 "program_parse.y"
+#line 2050 "program_parse.y"
{
(yyval.integer) = (state->mode == ARB_vertex)
? VERT_RESULT_COL0
@@ -4690,7 +4702,7 @@ yyreduce:
case 260:
/* Line 1455 of yacc.c */
-#line 2044 "program_parse.y"
+#line 2056 "program_parse.y"
{
if (state->mode == ARB_vertex) {
(yyval.integer) = VERT_RESULT_COL0;
@@ -4704,7 +4716,7 @@ yyreduce:
case 261:
/* Line 1455 of yacc.c */
-#line 2053 "program_parse.y"
+#line 2065 "program_parse.y"
{
if (state->mode == ARB_vertex) {
(yyval.integer) = VERT_RESULT_BFC0;
@@ -4718,7 +4730,7 @@ yyreduce:
case 262:
/* Line 1455 of yacc.c */
-#line 2064 "program_parse.y"
+#line 2076 "program_parse.y"
{
(yyval.integer) = 0;
;}
@@ -4727,7 +4739,7 @@ yyreduce:
case 263:
/* Line 1455 of yacc.c */
-#line 2068 "program_parse.y"
+#line 2080 "program_parse.y"
{
if (state->mode == ARB_vertex) {
(yyval.integer) = 0;
@@ -4741,7 +4753,7 @@ yyreduce:
case 264:
/* Line 1455 of yacc.c */
-#line 2077 "program_parse.y"
+#line 2089 "program_parse.y"
{
if (state->mode == ARB_vertex) {
(yyval.integer) = 1;
@@ -4755,91 +4767,91 @@ yyreduce:
case 265:
/* Line 1455 of yacc.c */
-#line 2087 "program_parse.y"
+#line 2099 "program_parse.y"
{ (yyval.integer) = 0; ;}
break;
case 266:
/* Line 1455 of yacc.c */
-#line 2088 "program_parse.y"
+#line 2100 "program_parse.y"
{ (yyval.integer) = 0; ;}
break;
case 267:
/* Line 1455 of yacc.c */
-#line 2089 "program_parse.y"
+#line 2101 "program_parse.y"
{ (yyval.integer) = 1; ;}
break;
case 268:
/* Line 1455 of yacc.c */
-#line 2092 "program_parse.y"
+#line 2104 "program_parse.y"
{ (yyval.integer) = 0; ;}
break;
case 269:
/* Line 1455 of yacc.c */
-#line 2093 "program_parse.y"
+#line 2105 "program_parse.y"
{ (yyval.integer) = 0; ;}
break;
case 270:
/* Line 1455 of yacc.c */
-#line 2094 "program_parse.y"
+#line 2106 "program_parse.y"
{ (yyval.integer) = 1; ;}
break;
case 271:
/* Line 1455 of yacc.c */
-#line 2097 "program_parse.y"
+#line 2109 "program_parse.y"
{ (yyval.integer) = 0; ;}
break;
case 272:
/* Line 1455 of yacc.c */
-#line 2098 "program_parse.y"
+#line 2110 "program_parse.y"
{ (yyval.integer) = (yyvsp[(2) - (3)].integer); ;}
break;
case 273:
/* Line 1455 of yacc.c */
-#line 2101 "program_parse.y"
+#line 2113 "program_parse.y"
{ (yyval.integer) = 0; ;}
break;
case 274:
/* Line 1455 of yacc.c */
-#line 2102 "program_parse.y"
+#line 2114 "program_parse.y"
{ (yyval.integer) = (yyvsp[(2) - (3)].integer); ;}
break;
case 275:
/* Line 1455 of yacc.c */
-#line 2105 "program_parse.y"
+#line 2117 "program_parse.y"
{ (yyval.integer) = 0; ;}
break;
case 276:
/* Line 1455 of yacc.c */
-#line 2106 "program_parse.y"
+#line 2118 "program_parse.y"
{ (yyval.integer) = (yyvsp[(2) - (3)].integer); ;}
break;
case 277:
/* Line 1455 of yacc.c */
-#line 2110 "program_parse.y"
+#line 2122 "program_parse.y"
{
if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureCoordUnits) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid texture coordinate unit selector");
@@ -4853,7 +4865,7 @@ yyreduce:
case 278:
/* Line 1455 of yacc.c */
-#line 2121 "program_parse.y"
+#line 2133 "program_parse.y"
{
if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureImageUnits) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid texture image unit selector");
@@ -4867,7 +4879,7 @@ yyreduce:
case 279:
/* Line 1455 of yacc.c */
-#line 2132 "program_parse.y"
+#line 2144 "program_parse.y"
{
if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureUnits) {
yyerror(& (yylsp[(1) - (1)]), state, "invalid texture unit selector");
@@ -4881,18 +4893,23 @@ yyreduce:
case 280:
/* Line 1455 of yacc.c */
-#line 2143 "program_parse.y"
+#line 2155 "program_parse.y"
{
struct asm_symbol *exist = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(2) - (4)].string));
struct asm_symbol *target = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(4) - (4)].string));
+ free((yyvsp[(4) - (4)].string));
if (exist != NULL) {
- yyerror(& (yylsp[(2) - (4)]), state, "redeclared identifier");
+ char m[1000];
+ _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", (yyvsp[(2) - (4)].string));
+ free((yyvsp[(2) - (4)].string));
+ yyerror(& (yylsp[(2) - (4)]), state, m);
YYERROR;
} else if (target == NULL) {
+ free((yyvsp[(2) - (4)].string));
yyerror(& (yylsp[(4) - (4)]), state,
"undefined variable binding in ALIAS statement");
YYERROR;
@@ -4905,7 +4922,7 @@ yyreduce:
/* Line 1455 of yacc.c */
-#line 4909 "program_parse.tab.c"
+#line 4926 "program_parse.tab.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -5124,7 +5141,7 @@ yyreturn:
/* Line 1675 of yacc.c */
-#line 2167 "program_parse.y"
+#line 2184 "program_parse.y"
void
@@ -5224,6 +5241,26 @@ init_dst_reg(struct prog_dst_register *r)
}
+/** Like init_dst_reg() but set the File and Index fields. */
+void
+set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index)
+{
+ const GLint maxIndex = 1 << INST_INDEX_BITS;
+ const GLint minIndex = 0;
+ ASSERT(index >= minIndex);
+ ASSERT(index <= maxIndex);
+ ASSERT(file == PROGRAM_TEMPORARY ||
+ file == PROGRAM_ADDRESS ||
+ file == PROGRAM_OUTPUT);
+ memset(r, 0, sizeof(*r));
+ r->File = file;
+ r->Index = index;
+ r->WriteMask = WRITEMASK_XYZW;
+ r->CondMask = COND_TR;
+ r->CondSwizzle = SWIZZLE_NOOP;
+}
+
+
void
init_src_reg(struct asm_src_register *r)
{
@@ -5234,6 +5271,23 @@ init_src_reg(struct asm_src_register *r)
}
+/** Like init_src_reg() but set the File and Index fields. */
+void
+set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index)
+{
+ const GLint maxIndex = (1 << INST_INDEX_BITS) - 1;
+ const GLint minIndex = -(1 << INST_INDEX_BITS);
+ ASSERT(index >= minIndex);
+ ASSERT(index <= maxIndex);
+ ASSERT(file < PROGRAM_FILE_MAX);
+ memset(r, 0, sizeof(*r));
+ r->Base.File = file;
+ r->Base.Index = index;
+ r->Base.Swizzle = SWIZZLE_NOOP;
+ r->Symbol = NULL;
+}
+
+
/**
* Validate the set of inputs used by a program
*
diff --git a/src/mesa/shader/program_parse.tab.h b/src/mesa/shader/program_parse.tab.h
index 860b6f886e9..406100c859c 100644
--- a/src/mesa/shader/program_parse.tab.h
+++ b/src/mesa/shader/program_parse.tab.h
@@ -154,7 +154,7 @@ typedef union YYSTYPE
{
/* Line 1676 of yacc.c */
-#line 116 "program_parse.y"
+#line 122 "program_parse.y"
struct asm_instruction *inst;
struct asm_symbol *sym;
diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y
index 9703e8e670f..8ca6f9805b8 100644
--- a/src/mesa/shader/program_parse.y
+++ b/src/mesa/shader/program_parse.y
@@ -66,8 +66,14 @@ static int validate_inputs(struct YYLTYPE *locp,
static void init_dst_reg(struct prog_dst_register *r);
+static void set_dst_reg(struct prog_dst_register *r,
+ gl_register_file file, GLint index);
+
static void init_src_reg(struct asm_src_register *r);
+static void set_src_reg(struct asm_src_register *r,
+ gl_register_file file, GLint index);
+
static void asm_instruction_set_operands(struct asm_instruction *inst,
const struct prog_dst_register *dst, const struct asm_src_register *src0,
const struct asm_src_register *src1, const struct asm_src_register *src2);
@@ -303,6 +309,8 @@ option: OPTION string ';'
}
+ free($2);
+
if (!valid) {
const char *const err_str = (state->mode == ARB_vertex)
? "invalid ARB vertex program option"
@@ -580,9 +588,7 @@ scalarUse: srcReg scalarSuffix
temp_sym.param_binding_begin = ~0;
initialize_symbol_from_const(state->prog, & temp_sym, & $1);
- init_src_reg(& $$);
- $$.Base.File = PROGRAM_CONSTANT;
- $$.Base.Index = temp_sym.param_binding_begin;
+ set_src_reg(& $$, PROGRAM_CONSTANT, temp_sym.param_binding_begin);
}
;
@@ -637,16 +643,14 @@ maskedDstReg: dstReg optionalMask optionalCcMask
YYERROR;
}
- state->prog->OutputsWritten |= (1U << $$.Index);
+ state->prog->OutputsWritten |= BITFIELD64_BIT($$.Index);
}
}
;
maskedAddrReg: addrReg addrWriteMask
{
- init_dst_reg(& $$);
- $$.File = PROGRAM_ADDRESS;
- $$.Index = 0;
+ set_dst_reg(& $$, PROGRAM_ADDRESS, 0);
$$.WriteMask = $2.mask;
}
;
@@ -708,12 +712,17 @@ extSwizSel: INTEGER
}
| string
{
+ char s;
+
if (strlen($1) > 1) {
yyerror(& @1, state, "invalid extended swizzle selector");
YYERROR;
}
- switch ($1[0]) {
+ s = $1[0];
+ free($1);
+
+ switch (s) {
case 'x':
$$.swz = SWIZZLE_X;
$$.xyzw_valid = 1;
@@ -761,6 +770,8 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
struct asm_symbol *const s = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, $1);
+ free($1);
+
if (s == NULL) {
yyerror(& @1, state, "invalid operand variable");
YYERROR;
@@ -776,16 +787,13 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
init_src_reg(& $$);
switch (s->type) {
case at_temp:
- $$.Base.File = PROGRAM_TEMPORARY;
- $$.Base.Index = s->temp_binding;
+ set_src_reg(& $$, PROGRAM_TEMPORARY, s->temp_binding);
break;
case at_param:
- $$.Base.File = s->param_binding_type;
- $$.Base.Index = s->param_binding_begin;
+ set_src_reg(& $$, s->param_binding_type, s->param_binding_begin);
break;
case at_attrib:
- $$.Base.File = PROGRAM_INPUT;
- $$.Base.Index = s->attrib_binding;
+ set_src_reg(& $$, PROGRAM_INPUT, s->attrib_binding);
state->prog->InputsRead |= (1U << $$.Base.Index);
if (!validate_inputs(& @1, state)) {
@@ -800,9 +808,7 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
}
| attribBinding
{
- init_src_reg(& $$);
- $$.Base.File = PROGRAM_INPUT;
- $$.Base.Index = $1;
+ set_src_reg(& $$, PROGRAM_INPUT, $1);
state->prog->InputsRead |= (1U << $$.Base.Index);
if (!validate_inputs(& @1, state)) {
@@ -832,25 +838,24 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
}
| paramSingleItemUse
{
- init_src_reg(& $$);
- $$.Base.File = ($1.name != NULL)
+ gl_register_file file = ($1.name != NULL)
? $1.param_binding_type
: PROGRAM_CONSTANT;
- $$.Base.Index = $1.param_binding_begin;
+ set_src_reg(& $$, file, $1.param_binding_begin);
}
;
dstReg: resultBinding
{
- init_dst_reg(& $$);
- $$.File = PROGRAM_OUTPUT;
- $$.Index = $1;
+ set_dst_reg(& $$, PROGRAM_OUTPUT, $1);
}
| USED_IDENTIFIER /* temporaryReg | vertexResultReg */
{
struct asm_symbol *const s = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, $1);
+ free($1);
+
if (s == NULL) {
yyerror(& @1, state, "invalid operand variable");
YYERROR;
@@ -859,19 +864,15 @@ dstReg: resultBinding
YYERROR;
}
- init_dst_reg(& $$);
switch (s->type) {
case at_temp:
- $$.File = PROGRAM_TEMPORARY;
- $$.Index = s->temp_binding;
+ set_dst_reg(& $$, PROGRAM_TEMPORARY, s->temp_binding);
break;
case at_output:
- $$.File = PROGRAM_OUTPUT;
- $$.Index = s->output_binding;
+ set_dst_reg(& $$, PROGRAM_OUTPUT, s->output_binding);
break;
default:
- $$.File = s->param_binding_type;
- $$.Index = s->param_binding_begin;
+ set_dst_reg(& $$, s->param_binding_type, s->param_binding_begin);
break;
}
}
@@ -882,6 +883,8 @@ progParamArray: USED_IDENTIFIER
struct asm_symbol *const s = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, $1);
+ free($1);
+
if (s == NULL) {
yyerror(& @1, state, "invalid operand variable");
YYERROR;
@@ -953,6 +956,8 @@ addrReg: USED_IDENTIFIER
struct asm_symbol *const s = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, $1);
+ free($1);
+
if (s == NULL) {
yyerror(& @1, state, "invalid array member");
YYERROR;
@@ -1091,6 +1096,7 @@ ATTRIB_statement: ATTRIB IDENTIFIER '=' attribBinding
declare_variable(state, $2, at_attrib, & @2);
if (s == NULL) {
+ free($2);
YYERROR;
} else {
s->attrib_binding = $4;
@@ -1198,6 +1204,7 @@ PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit
declare_variable(state, $2, at_param, & @2);
if (s == NULL) {
+ free($2);
YYERROR;
} else {
s->param_binding_type = $3.param_binding_type;
@@ -1211,6 +1218,7 @@ PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit
PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit
{
if (($4 != 0) && ((unsigned) $4 != $6.param_binding_length)) {
+ free($2);
yyerror(& @4, state,
"parameter array size and number of bindings must match");
YYERROR;
@@ -1219,6 +1227,7 @@ PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit
declare_variable(state, $2, $6.type, & @2);
if (s == NULL) {
+ free($2);
YYERROR;
} else {
s->param_binding_type = $6.param_binding_type;
@@ -1236,7 +1245,7 @@ optArraySize:
}
| INTEGER
{
- if (($1 < 1) || ((unsigned) $1 >= state->limits->MaxParameters)) {
+ if (($1 < 1) || ((unsigned) $1 > state->limits->MaxParameters)) {
yyerror(& @1, state, "invalid parameter array size");
YYERROR;
} else {
@@ -1953,12 +1962,14 @@ ADDRESS_statement: ADDRESS { $<integer>$ = $1; } varNameList
varNameList: varNameList ',' IDENTIFIER
{
if (!declare_variable(state, $3, $<integer>0, & @3)) {
+ free($3);
YYERROR;
}
}
| IDENTIFIER
{
if (!declare_variable(state, $1, $<integer>0, & @1)) {
+ free($1);
YYERROR;
}
}
@@ -1970,6 +1981,7 @@ OUTPUT_statement: optVarSize OUTPUT IDENTIFIER '=' resultBinding
declare_variable(state, $3, at_output, & @3);
if (s == NULL) {
+ free($3);
YYERROR;
} else {
s->output_binding = $5;
@@ -2146,11 +2158,16 @@ ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER
struct asm_symbol *target = (struct asm_symbol *)
_mesa_symbol_table_find_symbol(state->st, 0, $4);
+ free($4);
if (exist != NULL) {
- yyerror(& @2, state, "redeclared identifier");
+ char m[1000];
+ _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", $2);
+ free($2);
+ yyerror(& @2, state, m);
YYERROR;
} else if (target == NULL) {
+ free($2);
yyerror(& @4, state,
"undefined variable binding in ALIAS statement");
YYERROR;
@@ -2263,6 +2280,26 @@ init_dst_reg(struct prog_dst_register *r)
}
+/** Like init_dst_reg() but set the File and Index fields. */
+void
+set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index)
+{
+ const GLint maxIndex = 1 << INST_INDEX_BITS;
+ const GLint minIndex = 0;
+ ASSERT(index >= minIndex);
+ ASSERT(index <= maxIndex);
+ ASSERT(file == PROGRAM_TEMPORARY ||
+ file == PROGRAM_ADDRESS ||
+ file == PROGRAM_OUTPUT);
+ memset(r, 0, sizeof(*r));
+ r->File = file;
+ r->Index = index;
+ r->WriteMask = WRITEMASK_XYZW;
+ r->CondMask = COND_TR;
+ r->CondSwizzle = SWIZZLE_NOOP;
+}
+
+
void
init_src_reg(struct asm_src_register *r)
{
@@ -2273,6 +2310,23 @@ init_src_reg(struct asm_src_register *r)
}
+/** Like init_src_reg() but set the File and Index fields. */
+void
+set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index)
+{
+ const GLint maxIndex = (1 << INST_INDEX_BITS) - 1;
+ const GLint minIndex = -(1 << INST_INDEX_BITS);
+ ASSERT(index >= minIndex);
+ ASSERT(index <= maxIndex);
+ ASSERT(file < PROGRAM_FILE_MAX);
+ memset(r, 0, sizeof(*r));
+ r->Base.File = file;
+ r->Base.Index = index;
+ r->Base.Swizzle = SWIZZLE_NOOP;
+ r->Symbol = NULL;
+}
+
+
/**
* Validate the set of inputs used by a program
*
diff --git a/src/mesa/shader/program_parser.h b/src/mesa/shader/program_parser.h
index bce6041381f..c170948f73a 100644
--- a/src/mesa/shader/program_parser.h
+++ b/src/mesa/shader/program_parser.h
@@ -35,7 +35,7 @@ enum asm_type {
at_attrib,
at_param,
at_temp,
- at_output,
+ at_output
};
struct asm_symbol {
diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c
index 3b8529592dd..a0daac1b806 100644
--- a/src/mesa/shader/programopt.c
+++ b/src/mesa/shader/programopt.c
@@ -109,7 +109,7 @@ _mesa_insert_mvp_dp4_code(GLcontext *ctx, struct gl_vertex_program *vprog)
vprog->Base.Instructions = newInst;
vprog->Base.NumInstructions = newLen;
vprog->Base.InputsRead |= VERT_BIT_POS;
- vprog->Base.OutputsWritten |= (1 << VERT_RESULT_HPOS);
+ vprog->Base.OutputsWritten |= BITFIELD64_BIT(VERT_RESULT_HPOS);
}
@@ -211,7 +211,7 @@ _mesa_insert_mvp_mad_code(GLcontext *ctx, struct gl_vertex_program *vprog)
vprog->Base.Instructions = newInst;
vprog->Base.NumInstructions = newLen;
vprog->Base.InputsRead |= VERT_BIT_POS;
- vprog->Base.OutputsWritten |= (1 << VERT_RESULT_HPOS);
+ vprog->Base.OutputsWritten |= BITFIELD64_BIT(VERT_RESULT_HPOS);
}
@@ -613,7 +613,7 @@ _mesa_nop_fragment_program(GLcontext *ctx, struct gl_fragment_program *prog)
prog->Base.Instructions = inst;
prog->Base.NumInstructions = 2;
prog->Base.InputsRead = 1 << inputAttr;
- prog->Base.OutputsWritten = 1 << FRAG_RESULT_COLOR;
+ prog->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR);
}
@@ -657,7 +657,7 @@ _mesa_nop_vertex_program(GLcontext *ctx, struct gl_vertex_program *prog)
prog->Base.Instructions = inst;
prog->Base.NumInstructions = 2;
prog->Base.InputsRead = 1 << inputAttr;
- prog->Base.OutputsWritten = 1 << VERT_RESULT_COL0;
+ prog->Base.OutputsWritten = BITFIELD64_BIT(VERT_RESULT_COL0);
/*
* Now insert code to do standard modelview/projection transformation.
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index f473bd1173b..453cd3964af 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1499,6 +1499,41 @@ _mesa_link_program(GLcontext *ctx, GLuint program)
/**
+ * Print basic shader info (for debug).
+ */
+static void
+print_shader_info(const struct gl_shader_program *shProg)
+{
+ GLuint i;
+
+ _mesa_printf("Mesa: glUseProgram(%u)\n", shProg->Name);
+ for (i = 0; i < shProg->NumShaders; i++) {
+ const char *s;
+ switch (shProg->Shaders[i]->Type) {
+ case GL_VERTEX_SHADER:
+ s = "vertex";
+ break;
+ case GL_FRAGMENT_SHADER:
+ s = "fragment";
+ break;
+ case GL_GEOMETRY_SHADER:
+ s = "geometry";
+ break;
+ default:
+ s = "";
+ }
+ _mesa_printf(" %s shader %u, checksum %u\n", s,
+ shProg->Shaders[i]->Name,
+ shProg->Shaders[i]->SourceChecksum);
+ }
+ if (shProg->VertexProgram)
+ _mesa_printf(" vert prog %u\n", shProg->VertexProgram->Base.Id);
+ if (shProg->FragmentProgram)
+ _mesa_printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id);
+}
+
+
+/**
* Called via ctx->Driver.UseProgram()
*/
void
@@ -1512,8 +1547,6 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
return;
}
- FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
-
if (program) {
shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram");
if (!shProg) {
@@ -1527,38 +1560,17 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
/* debug code */
if (ctx->Shader.Flags & GLSL_USE_PROG) {
- GLuint i;
- _mesa_printf("Mesa: glUseProgram(%u)\n", shProg->Name);
- for (i = 0; i < shProg->NumShaders; i++) {
- const char *s;
- switch (shProg->Shaders[i]->Type) {
- case GL_VERTEX_SHADER:
- s = "vertex";
- break;
- case GL_FRAGMENT_SHADER:
- s = "fragment";
- break;
- case GL_GEOMETRY_SHADER:
- s = "geometry";
- break;
- default:
- s = "";
- }
- _mesa_printf(" %s shader %u, checksum %u\n", s,
- shProg->Shaders[i]->Name,
- shProg->Shaders[i]->SourceChecksum);
- }
- if (shProg->VertexProgram)
- _mesa_printf(" vert prog %u\n", shProg->VertexProgram->Base.Id);
- if (shProg->FragmentProgram)
- _mesa_printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id);
+ print_shader_info(shProg);
}
}
else {
shProg = NULL;
}
- _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram, shProg);
+ if (ctx->Shader.CurrentProgram != shProg) {
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+ _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram, shProg);
+ }
}
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 344dfdc6804..ee5a50ca82e 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -925,7 +925,7 @@ gen_return_with_expression(slang_assemble_ctx *A, slang_operation *oper)
slang_operation_copy(rhs, &oper->children[0]);
}
- ///blockOper->locals->outer_scope = oper->locals->outer_scope;
+ /*blockOper->locals->outer_scope = oper->locals->outer_scope;*/
/*slang_print_tree(blockOper, 0);*/
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 3af301eacdf..99eb254cee0 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -81,8 +81,8 @@ new_subroutine(slang_emit_info *emitInfo, GLuint *id)
emitInfo->Subroutines = (struct gl_program **)
_mesa_realloc(emitInfo->Subroutines,
- n * sizeof(struct gl_program),
- (n + 1) * sizeof(struct gl_program));
+ n * sizeof(struct gl_program *),
+ (n + 1) * sizeof(struct gl_program *));
emitInfo->Subroutines[n] = ctx->Driver.NewProgram(ctx, emitInfo->prog->Target, 0);
emitInfo->Subroutines[n]->Parameters = emitInfo->prog->Parameters;
emitInfo->NumSubroutines++;
@@ -195,6 +195,9 @@ alloc_node_storage(slang_emit_info *emitInfo, slang_ir_node *n,
if (!n->Store) {
assert(defaultSize > 0);
n->Store = _slang_new_ir_storage(PROGRAM_TEMPORARY, -1, defaultSize);
+ if (!n->Store) {
+ return GL_FALSE;
+ }
}
/* now allocate actual register(s). I.e. set n->Store->Index >= 0 */
@@ -431,6 +434,9 @@ new_instruction(slang_emit_info *emitInfo, gl_inst_opcode opcode)
_mesa_realloc_instructions(prog->Instructions,
prog->NumInstructions,
emitInfo->MaxInstructions);
+ if (!prog->Instructions) {
+ return NULL;
+ }
}
inst = prog->Instructions + prog->NumInstructions;
@@ -451,12 +457,14 @@ emit_arl_load(slang_emit_info *emitInfo,
gl_register_file file, GLint index, GLuint swizzle)
{
struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_ARL);
- inst->SrcReg[0].File = file;
- inst->SrcReg[0].Index = index;
- inst->SrcReg[0].Swizzle = fix_swizzle(swizzle);
- inst->DstReg.File = PROGRAM_ADDRESS;
- inst->DstReg.Index = 0;
- inst->DstReg.WriteMask = WRITEMASK_X;
+ if (inst) {
+ inst->SrcReg[0].File = file;
+ inst->SrcReg[0].Index = index;
+ inst->SrcReg[0].Swizzle = fix_swizzle(swizzle);
+ inst->DstReg.File = PROGRAM_ADDRESS;
+ inst->DstReg.Index = 0;
+ inst->DstReg.WriteMask = WRITEMASK_X;
+ }
return inst;
}
@@ -543,6 +551,9 @@ emit_instruction(slang_emit_info *emitInfo,
&srcRelAddr,
NULL,
NULL);
+ if (!inst) {
+ return NULL;
+ }
src[i] = &newSrc[i];
}
@@ -765,7 +776,9 @@ static struct prog_instruction *
emit_comment(slang_emit_info *emitInfo, const char *comment)
{
struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_NOP);
- inst_comment(inst, comment);
+ if (inst) {
+ inst_comment(inst, comment);
+ }
return inst;
}
@@ -792,7 +805,9 @@ emit_arith(slang_emit_info *emitInfo, slang_ir_node *n)
emit(emitInfo, n->Children[0]->Children[0]); /* A */
emit(emitInfo, n->Children[0]->Children[1]); /* B */
emit(emitInfo, n->Children[1]); /* C */
- alloc_node_storage(emitInfo, n, -1); /* dest */
+ if (!alloc_node_storage(emitInfo, n, -1)) { /* dest */
+ return NULL;
+ }
inst = emit_instruction(emitInfo,
OPCODE_MAD,
@@ -813,7 +828,9 @@ emit_arith(slang_emit_info *emitInfo, slang_ir_node *n)
emit(emitInfo, n->Children[0]); /* A */
emit(emitInfo, n->Children[1]->Children[0]); /* B */
emit(emitInfo, n->Children[1]->Children[1]); /* C */
- alloc_node_storage(emitInfo, n, -1); /* dest */
+ if (!alloc_node_storage(emitInfo, n, -1)) { /* dest */
+ return NULL;
+ }
inst = emit_instruction(emitInfo,
OPCODE_MAD,
@@ -839,7 +856,9 @@ emit_arith(slang_emit_info *emitInfo, slang_ir_node *n)
}
/* result storage */
- alloc_node_storage(emitInfo, n, -1);
+ if (!alloc_node_storage(emitInfo, n, -1)) {
+ return NULL;
+ }
inst = emit_instruction(emitInfo,
info->InstOpcode,
@@ -932,6 +951,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
n->Children[0]->Store,
n->Children[1]->Store,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, "Compare values");
/* Compute val = DOT(temp, temp) (reduction) */
@@ -941,6 +963,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
&tempStore,
&tempStore,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst->SrcReg[0].Swizzle = inst->SrcReg[1].Swizzle = swizzle; /*override*/
inst_comment(inst, "Reduce vec to bool");
@@ -956,6 +981,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
n->Store,
&zero,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, "Invert true/false");
}
}
@@ -985,6 +1013,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
&srcStore0,
&srcStore1,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, "Begin struct/array comparison");
}
else {
@@ -994,12 +1025,18 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
&srcStore0,
&srcStore1,
NULL);
+ if (!inst) {
+ return NULL;
+ }
/* ADD accTemp, accTemp, sneTemp; # like logical-OR */
inst = emit_instruction(emitInfo, OPCODE_ADD,
&accTemp, /* dest */
&accTemp,
&sneTemp,
NULL);
+ if (!inst) {
+ return NULL;
+ }
}
}
@@ -1009,6 +1046,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
&accTemp,
&accTemp,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, "End struct/array comparison");
if (n->Opcode == IR_EQUAL) {
@@ -1020,6 +1060,9 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
n->Store,
&zero,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, "Invert true/false");
}
@@ -1093,7 +1136,9 @@ emit_clamp(slang_emit_info *emitInfo, slang_ir_node *n)
* the intermediate result. Use a temp register instead.
*/
_mesa_bzero(&tmpNode, sizeof(tmpNode));
- alloc_node_storage(emitInfo, &tmpNode, n->Store->Size);
+ if (!alloc_node_storage(emitInfo, &tmpNode, n->Store->Size)) {
+ return NULL;
+ }
/* tmp = max(ch[0], ch[1]) */
inst = emit_instruction(emitInfo, OPCODE_MAX,
@@ -1101,6 +1146,9 @@ emit_clamp(slang_emit_info *emitInfo, slang_ir_node *n)
n->Children[0]->Store,
n->Children[1]->Store,
NULL);
+ if (!inst) {
+ return NULL;
+ }
/* n->dest = min(tmp, ch[2]) */
inst = emit_instruction(emitInfo, OPCODE_MIN,
@@ -1135,7 +1183,9 @@ emit_negation(slang_emit_info *emitInfo, slang_ir_node *n)
n->Children[0]->Store,
NULL,
NULL);
- inst->SrcReg[0].Negate = NEGATE_XYZW;
+ if (inst) {
+ inst->SrcReg[0].Negate = NEGATE_XYZW;
+ }
return inst;
}
@@ -1191,6 +1241,9 @@ emit_fcall(slang_emit_info *emitInfo, slang_ir_node *n)
* really just a NOP to attach the label to.
*/
inst = new_instruction(emitInfo, OPCODE_BGNSUB);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, n->Label->Name);
}
@@ -1202,10 +1255,16 @@ emit_fcall(slang_emit_info *emitInfo, slang_ir_node *n)
inst = prev_instruction(emitInfo);
if (inst && inst->Opcode != OPCODE_RET) {
inst = new_instruction(emitInfo, OPCODE_RET);
+ if (!inst) {
+ return NULL;
+ }
}
if (emitInfo->EmitBeginEndSub) {
inst = new_instruction(emitInfo, OPCODE_ENDSUB);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, n->Label->Name);
}
@@ -1215,6 +1274,9 @@ emit_fcall(slang_emit_info *emitInfo, slang_ir_node *n)
/* emit the function call */
inst = new_instruction(emitInfo, OPCODE_CAL);
+ if (!inst) {
+ return NULL;
+ }
/* The branch target is just the subroutine number (changed later) */
inst->BranchTarget = subroutineId;
inst_comment(inst, n->Label->Name);
@@ -1235,7 +1297,9 @@ emit_return(slang_emit_info *emitInfo, slang_ir_node *n)
assert(n->Opcode == IR_RETURN);
assert(n->Label);
inst = new_instruction(emitInfo, OPCODE_RET);
- inst->DstReg.CondMask = COND_TR; /* always return */
+ if (inst) {
+ inst->DstReg.CondMask = COND_TR; /* always return */
+ }
return inst;
}
@@ -1249,6 +1313,9 @@ emit_kill(slang_emit_info *emitInfo)
* Note that ARB-KILL depends on sign of vector operand.
*/
inst = new_instruction(emitInfo, OPCODE_KIL_NV);
+ if (!inst) {
+ return NULL;
+ }
inst->DstReg.CondMask = COND_TR; /* always kill */
assert(emitInfo->prog->Target == GL_FRAGMENT_PROGRAM_ARB);
@@ -1321,6 +1388,9 @@ emit_tex(slang_emit_info *emitInfo, slang_ir_node *n)
n->Children[1]->Store,
NULL,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst->TexShadow = shadow;
@@ -1423,6 +1493,9 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
&srcStore,
NULL,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, "IR_COPY block");
srcStore.Index++;
dstStore.Index++;
@@ -1438,6 +1511,9 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
n->Children[1]->Store,
NULL,
NULL);
+ if (!inst) {
+ return NULL;
+ }
dstAnnot = storage_annotation(n->Children[0], emitInfo->prog);
srcAnnot = storage_annotation(n->Children[1], emitInfo->prog);
inst->Comment = instruction_annotation(inst->Opcode, dstAnnot,
@@ -1499,6 +1575,9 @@ emit_cond(slang_emit_info *emitInfo, slang_ir_node *n)
n->Children[0]->Store,
NULL,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst->CondUpdate = GL_TRUE;
inst_comment(inst, "COND expr");
_slang_free_temp(emitInfo->vt, n->Store);
@@ -1561,6 +1640,9 @@ emit_not(slang_emit_info *emitInfo, slang_ir_node *n)
n->Children[0]->Store,
&zero,
NULL);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, "NOT");
free_node_storage(emitInfo->vt, n->Children[0]);
@@ -1600,8 +1682,10 @@ emit_if(slang_emit_info *emitInfo, slang_ir_node *n)
if (emitInfo->EmitHighLevelInstructions) {
if (emitInfo->EmitCondCodes) {
/* IF condcode THEN ... */
- struct prog_instruction *ifInst;
- ifInst = new_instruction(emitInfo, OPCODE_IF);
+ struct prog_instruction *ifInst = new_instruction(emitInfo, OPCODE_IF);
+ if (!ifInst) {
+ return NULL;
+ }
ifInst->DstReg.CondMask = COND_NE; /* if cond is non-zero */
/* only test the cond code (1 of 4) that was updated by the
* previous instruction.
@@ -1609,17 +1693,25 @@ emit_if(slang_emit_info *emitInfo, slang_ir_node *n)
ifInst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
}
else {
+ struct prog_instruction *inst;
+
/* IF src[0] THEN ... */
- emit_instruction(emitInfo, OPCODE_IF,
- NULL, /* dst */
- n->Children[0]->Store, /* op0 */
- NULL,
- NULL);
+ inst = emit_instruction(emitInfo, OPCODE_IF,
+ NULL, /* dst */
+ n->Children[0]->Store, /* op0 */
+ NULL,
+ NULL);
+ if (!inst) {
+ return NULL;
+ }
}
}
else {
/* conditional jump to else, or endif */
struct prog_instruction *ifInst = new_instruction(emitInfo, OPCODE_BRA);
+ if (!ifInst) {
+ return NULL;
+ }
ifInst->DstReg.CondMask = COND_EQ; /* BRA if cond is zero */
inst_comment(ifInst, "if zero");
ifInst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
@@ -1632,12 +1724,17 @@ emit_if(slang_emit_info *emitInfo, slang_ir_node *n)
/* have else body */
elseInstLoc = prog->NumInstructions;
if (emitInfo->EmitHighLevelInstructions) {
- (void) new_instruction(emitInfo, OPCODE_ELSE);
+ struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_ELSE);
+ if (!inst) {
+ return NULL;
+ }
}
else {
/* jump to endif instruction */
- struct prog_instruction *inst;
- inst = new_instruction(emitInfo, OPCODE_BRA);
+ struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_BRA);
+ if (!inst) {
+ return NULL;
+ }
inst_comment(inst, "else");
inst->DstReg.CondMask = COND_TR; /* always branch */
}
@@ -1650,7 +1747,10 @@ emit_if(slang_emit_info *emitInfo, slang_ir_node *n)
}
if (emitInfo->EmitHighLevelInstructions) {
- (void) new_instruction(emitInfo, OPCODE_ENDIF);
+ struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_ENDIF);
+ if (!inst) {
+ return NULL;
+ }
}
if (n->Children[2]) {
@@ -1671,7 +1771,10 @@ emit_loop(slang_emit_info *emitInfo, slang_ir_node *n)
/* emit OPCODE_BGNLOOP */
beginInstLoc = prog->NumInstructions;
if (emitInfo->EmitHighLevelInstructions) {
- (void) new_instruction(emitInfo, OPCODE_BGNLOOP);
+ struct prog_instruction *inst = new_instruction(emitInfo, OPCODE_BGNLOOP);
+ if (!inst) {
+ return NULL;
+ }
}
/* body */
@@ -1689,10 +1792,16 @@ emit_loop(slang_emit_info *emitInfo, slang_ir_node *n)
if (emitInfo->EmitHighLevelInstructions) {
/* emit OPCODE_ENDLOOP */
endInst = new_instruction(emitInfo, OPCODE_ENDLOOP);
+ if (!endInst) {
+ return NULL;
+ }
}
else {
/* emit unconditional BRA-nch */
endInst = new_instruction(emitInfo, OPCODE_BRA);
+ if (!endInst) {
+ return NULL;
+ }
endInst->DstReg.CondMask = COND_TR; /* always true */
}
/* ENDLOOP's BranchTarget points to the BGNLOOP inst */
@@ -1762,7 +1871,9 @@ emit_cont_break(slang_emit_info *emitInfo, slang_ir_node *n)
}
n->InstLocation = emitInfo->prog->NumInstructions;
inst = new_instruction(emitInfo, opcode);
- inst->DstReg.CondMask = COND_TR; /* always true */
+ if (inst) {
+ inst->DstReg.CondMask = COND_TR; /* always true */
+ }
return inst;
}
@@ -1798,8 +1909,10 @@ emit_cont_break_if_true(slang_emit_info *emitInfo, slang_ir_node *n)
*/
const GLuint condWritemask = inst->DstReg.WriteMask;
inst = new_instruction(emitInfo, opcode);
- inst->DstReg.CondMask = COND_NE;
- inst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
+ if (inst) {
+ inst->DstReg.CondMask = COND_NE;
+ inst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
+ }
return inst;
}
else {
@@ -1814,10 +1927,19 @@ emit_cont_break_if_true(slang_emit_info *emitInfo, slang_ir_node *n)
n->Children[0]->Store,
NULL,
NULL);
+ if (!inst) {
+ return NULL;
+ }
n->InstLocation = emitInfo->prog->NumInstructions;
inst = new_instruction(emitInfo, opcode);
+ if (!inst) {
+ return NULL;
+ }
inst = new_instruction(emitInfo, OPCODE_ENDIF);
+ if (!inst) {
+ return NULL;
+ }
emitInfo->prog->Instructions[ifInstLoc].BranchTarget
= emitInfo->prog->NumInstructions;
@@ -1828,8 +1950,10 @@ emit_cont_break_if_true(slang_emit_info *emitInfo, slang_ir_node *n)
const GLuint condWritemask = inst->DstReg.WriteMask;
assert(emitInfo->EmitCondCodes);
inst = new_instruction(emitInfo, OPCODE_BRA);
- inst->DstReg.CondMask = COND_NE;
- inst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
+ if (inst) {
+ inst->DstReg.CondMask = COND_NE;
+ inst->DstReg.CondSwizzle = writemask_to_swizzle(condWritemask);
+ }
return inst;
}
}
@@ -1976,6 +2100,9 @@ emit_array_element(slang_emit_info *emitInfo, slang_ir_node *n)
indexStore, /* the index */
&elemSizeStore,
NULL);
+ if (!inst) {
+ return NULL;
+ }
indexStore = indexTemp;
}
@@ -2002,6 +2129,9 @@ emit_array_element(slang_emit_info *emitInfo, slang_ir_node *n)
indexStore, /* the index */
&indirectArray, /* indirect array base */
NULL);
+ if (!inst) {
+ return NULL;
+ }
indexStore = indexTemp;
}
@@ -2201,7 +2331,9 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
if (n->Comment) {
inst = new_instruction(emitInfo, OPCODE_NOP);
- inst->Comment = _mesa_strdup(n->Comment);
+ if (inst) {
+ inst->Comment = _mesa_strdup(n->Comment);
+ }
inst = NULL;
}
@@ -2503,6 +2635,9 @@ _slang_emit_code(slang_ir_node *n, slang_var_table *vt,
if (withEnd) {
struct prog_instruction *inst;
inst = new_instruction(&emitInfo, OPCODE_END);
+ if (!inst) {
+ return GL_FALSE;
+ }
}
_slang_resolve_subroutines(&emitInfo);
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 71038d2d94e..ed27821a951 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -104,7 +104,7 @@ link_varying_vars(GLcontext *ctx,
GLuint *map, i, firstVarying, newFile;
GLbitfield *inOutFlags;
- map = (GLuint *) malloc(prog->Varying->NumParameters * sizeof(GLuint));
+ map = (GLuint *) _mesa_malloc(prog->Varying->NumParameters * sizeof(GLuint));
if (!map)
return GL_FALSE;
@@ -135,6 +135,7 @@ link_varying_vars(GLcontext *ctx,
&shProg->Varying->Parameters[j];
if (var->Size != v->Size) {
link_error(shProg, "mismatched varying variable types");
+ _mesa_free(map);
return GL_FALSE;
}
if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_CENTROID)) {
@@ -142,6 +143,7 @@ link_varying_vars(GLcontext *ctx,
_mesa_snprintf(msg, sizeof(msg),
"centroid modifier mismatch for '%s'", var->Name);
link_error(shProg, msg);
+ _mesa_free(map);
return GL_FALSE;
}
if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_INVARIANT)) {
@@ -149,6 +151,7 @@ link_varying_vars(GLcontext *ctx,
_mesa_snprintf(msg, sizeof(msg),
"invariant modifier mismatch for '%s'", var->Name);
link_error(shProg, msg);
+ _mesa_free(map);
return GL_FALSE;
}
}
@@ -160,6 +163,7 @@ link_varying_vars(GLcontext *ctx,
if (shProg->Varying->NumParameters > ctx->Const.MaxVarying) {
link_error(shProg, "Too many varying variables");
+ _mesa_free(map);
return GL_FALSE;
}
@@ -199,7 +203,7 @@ link_varying_vars(GLcontext *ctx,
}
}
- free(map);
+ _mesa_free(map);
/* these will get recomputed before linking is completed */
prog->InputsRead = 0x0;
@@ -511,7 +515,7 @@ _slang_update_inputs_outputs(struct gl_program *prog)
}
if (inst->DstReg.File == PROGRAM_OUTPUT) {
- prog->OutputsWritten |= 1 << inst->DstReg.Index;
+ prog->OutputsWritten |= BITFIELD64_BIT(inst->DstReg.Index);
if (inst->DstReg.RelAddr) {
/* If the output attribute is indexed with relative addressing
* we know that it must be a varying or texcoord such as
@@ -524,14 +528,17 @@ _slang_update_inputs_outputs(struct gl_program *prog)
if (prog->Target == GL_VERTEX_PROGRAM_ARB) {
if (inst->DstReg.Index == VERT_RESULT_TEX0) {
/* mark all texcoord outputs as written */
- const GLbitfield mask =
- ((1 << MAX_TEXTURE_COORD_UNITS) - 1) << VERT_RESULT_TEX0;
+ const GLbitfield64 mask =
+ BITFIELD64_RANGE(VERT_RESULT_TEX0,
+ (VERT_RESULT_TEX0
+ + MAX_TEXTURE_COORD_UNITS - 1));
prog->OutputsWritten |= mask;
}
else if (inst->DstReg.Index == VERT_RESULT_VAR0) {
/* mark all generic varying outputs as written */
- const GLbitfield mask =
- ((1 << MAX_VARYING) - 1) << VERT_RESULT_VAR0;
+ const GLbitfield64 mask =
+ BITFIELD64_RANGE(VERT_RESULT_VAR0,
+ (VERT_RESULT_VAR0 + MAX_VARYING - 1));
prog->OutputsWritten |= mask;
}
}
@@ -583,11 +590,16 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
{
struct gl_shader *newShader;
const struct gl_shader *firstShader = NULL;
- GLuint shaderLengths[100];
+ GLuint *shaderLengths;
GLchar *source;
GLuint totalLen = 0, len = 0;
GLuint i;
+ shaderLengths = (GLuint *)_mesa_malloc(shProg->NumShaders * sizeof(GLuint));
+ if (!shaderLengths) {
+ return NULL;
+ }
+
/* compute total size of new shader source code */
for (i = 0; i < shProg->NumShaders; i++) {
const struct gl_shader *shader = shProg->Shaders[i];
@@ -599,12 +611,16 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
}
}
- if (totalLen == 0)
+ if (totalLen == 0) {
+ _mesa_free(shaderLengths);
return NULL;
+ }
source = (GLchar *) _mesa_malloc(totalLen + 1);
- if (!source)
+ if (!source) {
+ _mesa_free(shaderLengths);
return NULL;
+ }
/* concatenate shaders */
for (i = 0; i < shProg->NumShaders; i++) {
@@ -619,9 +635,16 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
_mesa_printf("---NEW CONCATENATED SHADER---:\n%s\n------------\n", source);
*/
+ _mesa_free(shaderLengths);
+
remove_extra_version_directives(source);
newShader = CALLOC_STRUCT(gl_shader);
+ if (!newShader) {
+ _mesa_free(source);
+ return NULL;
+ }
+
newShader->Type = shaderType;
newShader->Source = source;
newShader->Pragmas = firstShader->Pragmas;
@@ -803,7 +826,8 @@ _slang_link(GLcontext *ctx,
if (shProg->VertexProgram) {
_slang_update_inputs_outputs(&shProg->VertexProgram->Base);
_slang_count_temporaries(&shProg->VertexProgram->Base);
- if (!(shProg->VertexProgram->Base.OutputsWritten & (1 << VERT_RESULT_HPOS))) {
+ if (!(shProg->VertexProgram->Base.OutputsWritten
+ & BITFIELD64_BIT(VERT_RESULT_HPOS))) {
/* the vertex program did not compute a vertex position */
link_error(shProg,
"gl_Position was not written by vertex shader\n");
@@ -821,7 +845,7 @@ _slang_link(GLcontext *ctx,
if (shProg->FragmentProgram) {
const GLbitfield varyingRead
= shProg->FragmentProgram->Base.InputsRead >> FRAG_ATTRIB_VAR0;
- const GLbitfield varyingWritten = shProg->VertexProgram ?
+ const GLbitfield64 varyingWritten = shProg->VertexProgram ?
shProg->VertexProgram->Base.OutputsWritten >> VERT_RESULT_VAR0 : 0x0;
if ((varyingRead & varyingWritten) != varyingRead) {
link_error(shProg,
@@ -832,9 +856,10 @@ _slang_link(GLcontext *ctx,
/* check that gl_FragColor and gl_FragData are not both written to */
if (shProg->FragmentProgram) {
- GLbitfield outputsWritten = shProg->FragmentProgram->Base.OutputsWritten;
- if ((outputsWritten & ((1 << FRAG_RESULT_COLOR))) &&
- (outputsWritten >= (1 << FRAG_RESULT_DATA0))) {
+ const GLbitfield64 outputsWritten =
+ shProg->FragmentProgram->Base.OutputsWritten;
+ if ((outputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) &&
+ (outputsWritten >= BITFIELD64_BIT(FRAG_RESULT_DATA0))) {
link_error(shProg, "Fragment program cannot write both gl_FragColor"
" and gl_FragData[].\n");
return;
diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c
index a4ebacc0936..e07e3a226a5 100644
--- a/src/mesa/shader/slang/slang_vartable.c
+++ b/src/mesa/shader/slang/slang_vartable.c
@@ -311,10 +311,10 @@ _slang_free_temp(slang_var_table *vt, slang_ir_storage *store)
{
struct table *t = vt->Top;
GLuint i;
- GLuint r = store->Index;
+ GLint r = store->Index;
assert(store->Size > 0);
assert(r >= 0);
- assert(r + store->Size <= vt->MaxRegisters * 4);
+ assert((GLuint)r + store->Size <= vt->MaxRegisters * 4);
if (dbg) printf("Free temp sz %d at %d.%s (level %d) store %p\n",
store->Size, r,
_mesa_swizzle_string(store->Swizzle, 0, 0),
diff --git a/src/mesa/shader/symbol_table.c b/src/mesa/shader/symbol_table.c
index 7a9aa7b8f65..1f6d9b844d6 100644
--- a/src/mesa/shader/symbol_table.c
+++ b/src/mesa/shader/symbol_table.c
@@ -20,12 +20,8 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
+#include "main/imports.h"
#include "symbol_table.h"
#include "hash_table.h"
@@ -73,6 +69,9 @@ struct symbol {
/**
*/
struct symbol_header {
+ /** Linkage in list of all headers in a given symbol table. */
+ struct symbol_header *next;
+
/** Symbol name. */
const char *name;
@@ -102,6 +101,9 @@ struct _mesa_symbol_table {
/** Top of scope stack. */
struct scope_level *current_scope;
+
+ /** List of all symbol headers in the table. */
+ struct symbol_header *hdr;
};
@@ -301,6 +303,8 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table,
hdr->name = name;
hash_table_insert(table->ht, hdr, name);
+ hdr->next = table->hdr;
+ table->hdr = hdr;
}
check_symbol_table(table);
@@ -341,10 +345,18 @@ _mesa_symbol_table_ctor(void)
void
_mesa_symbol_table_dtor(struct _mesa_symbol_table *table)
{
+ struct symbol_header *hdr;
+ struct symbol_header *next;
+
while (table->current_scope != NULL) {
_mesa_symbol_table_pop_scope(table);
}
+ for (hdr = table->hdr; hdr != NULL; hdr = next) {
+ next = hdr->next;
+ _mesa_free(hdr);
+ }
+
hash_table_dtor(table->ht);
free(table);
}