glsl: fix crash in loop analysis when some controls can't be determined
[mesa.git] / src / gallium / drivers / softpipe / sp_fs_exec.c
index a8999ed34794db88cf8eef71a9f70d930066a9ff..346e1b402baba023916102fdc59789429216e3ab 100644 (file)
@@ -127,11 +127,8 @@ exec_run( const struct sp_fragment_shader *base,
                     (float)quad->input.x0, (float)quad->input.y0, 
                     &machine->QuadPos);
 
-   if (quad->input.facing) {
-      machine->Face = -1.0f;
-   } else {
-      machine->Face = 1.0f;
-   }
+   /* convert 0 to 1.0 and 1 to -1.0 */
+   machine->Face = (float) (quad->input.facing * -2 + 1);
 
    quad->inout.mask &= tgsi_exec_machine_run( machine );
    if (quad->inout.mask == 0)
@@ -148,17 +145,30 @@ exec_run( const struct sp_fragment_shader *base,
          case TGSI_SEMANTIC_COLOR:
             {
                uint cbuf = sem_index[i];
+
+               assert(sizeof(quad->output.color[cbuf]) ==
+                      sizeof(machine->Outputs[i]));
+
+               /* copy float[4][4] result */
                memcpy(quad->output.color[cbuf],
-                      &machine->Outputs[i].xyzw[0].f[0],
+                      &machine->Outputs[i],
                       sizeof(quad->output.color[0]) );
             }
             break;
          case TGSI_SEMANTIC_POSITION:
             {
                uint j;
-               for (j = 0; j < 4; j++) {
+
+               for (j = 0; j < 4; j++)
                   quad->output.depth[j] = machine->Outputs[i].xyzw[2].f[j];
-               }
+            }
+            break;
+         case TGSI_SEMANTIC_STENCIL:
+            {
+               uint j;
+
+               for (j = 0; j < 4; j++)
+                  quad->output.stencil[j] = (unsigned)machine->Outputs[i].xyzw[1].f[j];
             }
             break;
          }