aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/program
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-11-04 08:57:20 +0100
committermarha <marha@users.sourceforge.net>2011-11-04 08:57:20 +0100
commit02f377d5e2dd18537d0807ad63675a0970b5a37d (patch)
tree1814c826db4d95a30ad71431d9c84b8d2611ec18 /mesalib/src/mesa/program
parent6f4feafd4d22beaabfb0202e66b0dea9047ee084 (diff)
downloadvcxsrv-02f377d5e2dd18537d0807ad63675a0970b5a37d.tar.gz
vcxsrv-02f377d5e2dd18537d0807ad63675a0970b5a37d.tar.bz2
vcxsrv-02f377d5e2dd18537d0807ad63675a0970b5a37d.zip
xserver pixman mesa git update 4 nov 2011
Diffstat (limited to 'mesalib/src/mesa/program')
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp26
-rw-r--r--mesalib/src/mesa/program/nvfragparse.c14
-rw-r--r--mesalib/src/mesa/program/prog_instruction.h2
-rw-r--r--mesalib/src/mesa/program/program.c2
4 files changed, 29 insertions, 15 deletions
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 93563bdaa..3c2eb5707 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -2273,6 +2273,9 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
case GLSL_SAMPLER_DIM_BUF:
assert(!"FINISHME: Implement ARB_texture_buffer_object");
break;
+ case GLSL_SAMPLER_DIM_EXTERNAL:
+ inst->tex_target = TEXTURE_EXTERNAL_INDEX;
+ break;
default:
assert(!"Should not get here.");
}
@@ -2546,7 +2549,7 @@ count_resources(struct gl_program *prog)
*
* XXX more checks are needed...
*/
-static void
+static bool
check_resources(const struct gl_context *ctx,
struct gl_shader_program *shader_program,
struct gl_program *prog)
@@ -2586,6 +2589,8 @@ check_resources(const struct gl_context *ctx,
default:
_mesa_problem(ctx, "unexpected program type in check_resources()");
}
+
+ return shader_program->LinkStatus;
}
class add_uniform_to_shader : public uniform_field_visitor {
@@ -3168,9 +3173,7 @@ get_mesa_program(struct gl_context *ctx,
}
if (!shader_program->LinkStatus) {
- free(mesa_instructions);
- _mesa_reference_program(ctx, &shader->Program, NULL);
- return NULL;
+ goto fail_exit;
}
set_branchtargets(&v, mesa_instructions, num_instructions);
@@ -3191,10 +3194,16 @@ get_mesa_program(struct gl_context *ctx,
prog->Instructions = mesa_instructions;
prog->NumInstructions = num_instructions;
+ /* Setting this to NULL prevents a possible double free in the fail_exit
+ * path (far below).
+ */
+ mesa_instructions = NULL;
+
do_set_program_inouts(shader->ir, prog, shader->Type == GL_FRAGMENT_SHADER);
count_resources(prog);
- check_resources(ctx, shader_program, prog);
+ if (!check_resources(ctx, shader_program, prog))
+ goto fail_exit;
_mesa_reference_program(ctx, &shader->Program, prog);
@@ -3203,6 +3212,11 @@ get_mesa_program(struct gl_context *ctx,
}
return prog;
+
+fail_exit:
+ free(mesa_instructions);
+ _mesa_reference_program(ctx, &shader->Program, NULL);
+ return NULL;
}
extern "C" {
@@ -3301,7 +3315,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
_mesa_reference_program(ctx, &linked_prog, NULL);
}
- return GL_TRUE;
+ return prog->LinkStatus;
}
diff --git a/mesalib/src/mesa/program/nvfragparse.c b/mesalib/src/mesa/program/nvfragparse.c
index ce72c610d..bcc553a9b 100644
--- a/mesalib/src/mesa/program/nvfragparse.c
+++ b/mesalib/src/mesa/program/nvfragparse.c
@@ -568,7 +568,7 @@ Parse_VectorOrScalarConstant(struct parse_state *parseState, GLfloat *vec)
*/
static GLboolean
Parse_TextureImageId(struct parse_state *parseState,
- GLubyte *texUnit, GLubyte *texTargetBit)
+ GLubyte *texUnit, GLubyte *texTarget)
{
GLubyte imageSrc[100];
GLint unit;
@@ -592,26 +592,26 @@ Parse_TextureImageId(struct parse_state *parseState,
RETURN_ERROR1("Expected ,");
if (Parse_String(parseState, "1D")) {
- *texTargetBit = TEXTURE_1D_BIT;
+ *texTarget = TEXTURE_1D_INDEX;
}
else if (Parse_String(parseState, "2D")) {
- *texTargetBit = TEXTURE_2D_BIT;
+ *texTarget = TEXTURE_2D_INDEX;
}
else if (Parse_String(parseState, "3D")) {
- *texTargetBit = TEXTURE_3D_BIT;
+ *texTarget = TEXTURE_3D_INDEX;
}
else if (Parse_String(parseState, "CUBE")) {
- *texTargetBit = TEXTURE_CUBE_BIT;
+ *texTarget = TEXTURE_CUBE_INDEX;
}
else if (Parse_String(parseState, "RECT")) {
- *texTargetBit = TEXTURE_RECT_BIT;
+ *texTarget = TEXTURE_RECT_INDEX;
}
else {
RETURN_ERROR1("Invalid texture target token");
}
/* update record of referenced texture units */
- parseState->texturesUsed[*texUnit] |= *texTargetBit;
+ parseState->texturesUsed[*texUnit] |= (1 << *texTarget);
if (_mesa_bitcount(parseState->texturesUsed[*texUnit]) > 1) {
RETURN_ERROR1("Only one texture target can be used per texture unit.");
}
diff --git a/mesalib/src/mesa/program/prog_instruction.h b/mesalib/src/mesa/program/prog_instruction.h
index db2b594e7..09659ce9c 100644
--- a/mesalib/src/mesa/program/prog_instruction.h
+++ b/mesalib/src/mesa/program/prog_instruction.h
@@ -392,7 +392,7 @@ struct prog_instruction
GLuint TexSrcUnit:5;
/** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */
- GLuint TexSrcTarget:3;
+ GLuint TexSrcTarget:4;
/** True if tex instruction should do shadow comparison */
GLuint TexShadow:1;
diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c
index 736652529..582cbccf8 100644
--- a/mesalib/src/mesa/program/program.c
+++ b/mesalib/src/mesa/program/program.c
@@ -78,7 +78,7 @@ _mesa_init_program(struct gl_context *ctx)
ASSERT(MAX_TEXTURE_UNITS <= (1 << 5));
/* If this fails, increase prog_instruction::TexSrcTarget size */
- ASSERT(NUM_TEXTURE_TARGETS <= (1 << 3));
+ ASSERT(NUM_TEXTURE_TARGETS <= (1 << 4));
ctx->Program.ErrorPos = -1;
ctx->Program.ErrorString = _mesa_strdup("");