mesa: fix num_draw_buffers==0 in fixed-function fragment program generation
authorBrian Paul <brianp@vmware.com>
Thu, 13 Jan 2011 00:32:00 +0000 (17:32 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 13 Jan 2011 00:55:45 +0000 (17:55 -0700)
This fixes a problem when glDrawBuffers(GL_NONE).  The fragment program
was writing to color output[0] but OutputsWritten was 0.  That led to a
failed assertion in the Mesa->TGSI translation code.

NOTE: This is a candidate for the 7.9 and 7.10 branches.

src/mesa/main/texenvprogram.c

index a3fa3fe826cebcb790fd449d4bad5383dda6348b..c1380f2a645547dfc19a403e31fe455004c3b2aa 100644 (file)
@@ -1467,7 +1467,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key,
    p.last_tex_stage = 0;
    release_temps(ctx, &p);
 
    p.last_tex_stage = 0;
    release_temps(ctx, &p);
 
-   if (key->enabled_units) {
+   if (key->enabled_units && key->num_draw_buffers) {
       GLboolean needbumpstage = GL_FALSE;
 
       /* Zeroth pass - bump map textures first */
       GLboolean needbumpstage = GL_FALSE;
 
       /* Zeroth pass - bump map textures first */
@@ -1560,7 +1560,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key,
    _mesa_copy_instructions(p.program->Base.Instructions, instBuffer,
                            p.program->Base.NumInstructions);
 
    _mesa_copy_instructions(p.program->Base.Instructions, instBuffer,
                            p.program->Base.NumInstructions);
 
-   if (p.program->FogOption) {
+   if (key->num_draw_buffers && p.program->FogOption) {
       _mesa_append_fog_code(ctx, p.program);
       p.program->FogOption = GL_NONE;
    }
       _mesa_append_fog_code(ctx, p.program);
       p.program->FogOption = GL_NONE;
    }