diff options
author | marha <marha@users.sourceforge.net> | 2011-04-27 15:56:59 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-04-27 15:56:59 +0000 |
commit | 100633b3e7619842f345cb7603b0db6b5761dd11 (patch) | |
tree | 3c3af754c7e801c07263269837d6a05072ff834c /mesalib/src/mesa/main/ff_fragment_shader.cpp | |
parent | 205a4bdae76f287126db9f45a4f0ba631e3efca1 (diff) | |
parent | 96d6df5da9cddedf4931bf8e17f96e242467c661 (diff) | |
download | vcxsrv-100633b3e7619842f345cb7603b0db6b5761dd11.tar.gz vcxsrv-100633b3e7619842f345cb7603b0db6b5761dd11.tar.bz2 vcxsrv-100633b3e7619842f345cb7603b0db6b5761dd11.zip |
svn merge ^/branches/released .
Diffstat (limited to 'mesalib/src/mesa/main/ff_fragment_shader.cpp')
-rw-r--r-- | mesalib/src/mesa/main/ff_fragment_shader.cpp | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp index d4f7f2970..562a37b81 100644 --- a/mesalib/src/mesa/main/ff_fragment_shader.cpp +++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp @@ -1530,15 +1530,26 @@ create_new_program(struct gl_context *ctx, struct state_key *key, */
emit_arith( &p, OPCODE_END, undef, WRITEMASK_XYZW, 0, undef, undef, undef);
- if (key->fog_enabled) {
- /* Pull fog mode from struct gl_context, the value in the state key is
- * a reduced value and not what is expected in FogOption
- */
- p.program->FogOption = ctx->Fog.Mode;
- p.program->Base.InputsRead |= FRAG_BIT_FOGC;
+ /* Allocate final instruction array. This has to be done before calling
+ * _mesa_append_fog_code because that function frees the Base.Instructions.
+ * At this point, Base.Instructions points to stack data, so it's a really
+ * bad idea to free it.
+ */
+ p.program->Base.Instructions
+ = _mesa_alloc_instructions(p.program->Base.NumInstructions);
+ if (!p.program->Base.Instructions) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY,
+ "generating tex env program");
+ return;
}
- else {
- p.program->FogOption = GL_NONE;
+ _mesa_copy_instructions(p.program->Base.Instructions, instBuffer,
+ p.program->Base.NumInstructions);
+
+ /* Append fog code. This must be done before checking the program against
+ * the limits becuase it will potentially add some instructions.
+ */
+ if (key->fog_enabled) {
+ _mesa_append_fog_code(ctx, p.program, ctx->Fog.Mode, GL_FALSE);
}
if (p.program->Base.NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections)
@@ -1552,23 +1563,6 @@ create_new_program(struct gl_context *ctx, struct state_key *key, ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS);
- /* Allocate final instruction array */
- p.program->Base.Instructions
- = _mesa_alloc_instructions(p.program->Base.NumInstructions);
- if (!p.program->Base.Instructions) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY,
- "generating tex env program");
- return;
- }
- _mesa_copy_instructions(p.program->Base.Instructions, instBuffer,
- p.program->Base.NumInstructions);
-
- if (key->num_draw_buffers && p.program->FogOption) {
- _mesa_append_fog_code(ctx, p.program, GL_FALSE);
- p.program->FogOption = GL_NONE;
- }
-
-
/* Notify driver the fragment program has (actually) changed.
*/
if (ctx->Driver.ProgramStringNotify) {
|