From a082d965de228d5035e59245df528af62761652a Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 9 Dec 2009 11:26:24 -0800 Subject: glsl: Remove unused member x from struct slang_operation. --- src/mesa/shader/slang/slang_compile_operation.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_compile_operation.h b/src/mesa/shader/slang/slang_compile_operation.h index 58f1edeed8..1f15c19896 100644 --- a/src/mesa/shader/slang/slang_compile_operation.h +++ b/src/mesa/shader/slang/slang_compile_operation.h @@ -127,7 +127,6 @@ typedef struct slang_operation_ * indicate such. num_children indicates number of elements. */ GLboolean array_constructor; - double x; } slang_operation; -- cgit v1.2.3 From 51f52edaf186a927a2c8c29ba9dba56d18928a7e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 10 Dec 2009 12:37:10 -0800 Subject: glsl: Fix array out-of-bounds access by _slang_lookup_constant. --- src/mesa/shader/slang/slang_simplify.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_simplify.c b/src/mesa/shader/slang/slang_simplify.c index b8a21f642c..539c6ff0d1 100644 --- a/src/mesa/shader/slang/slang_simplify.c +++ b/src/mesa/shader/slang/slang_simplify.c @@ -84,10 +84,11 @@ _slang_lookup_constant(const char *name) for (i = 0; info[i].Name; i++) { if (strcmp(info[i].Name, name) == 0) { /* found */ - GLint value = -1; - _mesa_GetIntegerv(info[i].Token, &value); - ASSERT(value >= 0); /* sanity check that glGetFloatv worked */ - return value; + GLint values[4]; + values[0] = -1; + _mesa_GetIntegerv(info[i].Token, values); + ASSERT(values[0] >= 0); /* sanity check that glGetFloatv worked */ + return values[0]; } } return -1; -- cgit v1.2.3 From d38ffed5236adf3ee83c0bc5bdee0233ce566e01 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 10 Dec 2009 17:50:35 -0800 Subject: glsl: Increase size of array in_slang_lookup_constant from 4 to 16. For some cases, _mesa_GetIntegerv reads up to params[15]. --- src/mesa/shader/slang/slang_simplify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_simplify.c b/src/mesa/shader/slang/slang_simplify.c index 539c6ff0d1..13b9ca3c87 100644 --- a/src/mesa/shader/slang/slang_simplify.c +++ b/src/mesa/shader/slang/slang_simplify.c @@ -84,7 +84,7 @@ _slang_lookup_constant(const char *name) for (i = 0; info[i].Name; i++) { if (strcmp(info[i].Name, name) == 0) { /* found */ - GLint values[4]; + GLint values[16]; values[0] = -1; _mesa_GetIntegerv(info[i].Token, values); ASSERT(values[0] >= 0); /* sanity check that glGetFloatv worked */ -- cgit v1.2.3 From e31df54754e2305b7cc7072053bf5a4e0b477fd6 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 10 Dec 2009 18:32:33 -0800 Subject: mesa: Assign _mesa_lookup_parameter_index return value to GLint. --- src/mesa/shader/prog_parameter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c index 2f029b02e5..f22492e029 100644 --- a/src/mesa/shader/prog_parameter.c +++ b/src/mesa/shader/prog_parameter.c @@ -500,7 +500,7 @@ GLfloat * _mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList, GLsizei nameLen, const char *name) { - GLuint i = _mesa_lookup_parameter_index(paramList, nameLen, name); + GLint i = _mesa_lookup_parameter_index(paramList, nameLen, name); if (i < 0) return NULL; else -- cgit v1.2.3 From 94fba49be97008565c0225bc46894bfd9453bb5e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 10 Dec 2009 18:51:51 -0800 Subject: mesa: Initialize variable in MatchInstruction. --- src/mesa/shader/nvfragparse.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index 0fd55524ab..b739a6aa07 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -217,6 +217,12 @@ MatchInstruction(const GLubyte *token) const struct instruction_pattern *inst; struct instruction_pattern result; + result.name = NULL; + result.opcode = MAX_OPCODE; /* i.e. invalid instruction */ + result.inputs = 0; + result.outputs = 0; + result.suffixes = 0; + for (inst = Instructions; inst->name; inst++) { if (_mesa_strncmp((const char *) token, inst->name, 3) == 0) { /* matched! */ @@ -247,7 +253,7 @@ MatchInstruction(const GLubyte *token) return result; } } - result.opcode = MAX_OPCODE; /* i.e. invalid instruction */ + return result; } -- cgit v1.2.3 From 5076a4f53a2f34cc9116b45951037f639885c7a1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 11 Dec 2009 09:16:25 -0700 Subject: mesa: check dst reg in _mesa_find_free_register() If a register was only being used as a destination (as will happen when generated condition-codes) we missed its use. So we'd errantly return a register index that was really in-use, not free. Fixes bug 25579. --- src/mesa/shader/program.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 2cd6eb8a38..18d4ef9759 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -813,9 +813,17 @@ _mesa_find_free_register(const struct gl_program *prog, GLuint regFile) const struct prog_instruction *inst = prog->Instructions + i; const GLuint n = _mesa_num_inst_src_regs(inst->Opcode); - for (k = 0; k < n; k++) { - if (inst->SrcReg[k].File == regFile) { - used[inst->SrcReg[k].Index] = GL_TRUE; + /* check dst reg first */ + if (inst->DstReg.File == regFile) { + used[inst->DstReg.Index] = GL_TRUE; + } + else { + /* check src regs otherwise */ + for (k = 0; k < n; k++) { + if (inst->SrcReg[k].File == regFile) { + used[inst->SrcReg[k].Index] = GL_TRUE; + break; + } } } } -- cgit v1.2.3