gallium/tgsi_exec: Fix up NumOutputs counting
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_exec.c
index 972b0a9ded2189aa19d785bd4f3abaf31d29f90d..ab17c1f9bc293cb971d9a4943cc45f2eddc79133 100644 (file)
@@ -378,6 +378,16 @@ micro_dfrac(union tgsi_double_channel *dst,
    dst->d[3] = src->d[3] - floor(src->d[3]);
 }
 
+static void
+micro_dflr(union tgsi_double_channel *dst,
+           const union tgsi_double_channel *src)
+{
+   dst->d[0] = floor(src->d[0]);
+   dst->d[1] = floor(src->d[1]);
+   dst->d[2] = floor(src->d[2]);
+   dst->d[3] = floor(src->d[3]);
+}
+
 static void
 micro_dldexp(union tgsi_double_channel *dst,
              const union tgsi_double_channel *src0,
@@ -1181,14 +1191,8 @@ tgsi_exec_machine_bind_shader(
                                    * sizeof(struct tgsi_full_declaration));
             maxDeclarations += 10;
          }
-         if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_OUTPUT) {
-            unsigned reg;
-            for (reg = parse.FullToken.FullDeclaration.Range.First;
-                 reg <= parse.FullToken.FullDeclaration.Range.Last;
-                 ++reg) {
-               ++mach->NumOutputs;
-            }
-         }
+         if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_OUTPUT)
+            mach->NumOutputs = MAX2(mach->NumOutputs, parse.FullToken.FullDeclaration.Range.Last + 1);
          else if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_SYSTEM_VALUE) {
             const struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration;
             mach->SysSemanticToIndex[decl->Semantic.Name] = decl->Range.First;
@@ -1271,7 +1275,6 @@ struct tgsi_exec_machine *
 tgsi_exec_machine_create(enum pipe_shader_type shader_type)
 {
    struct tgsi_exec_machine *mach;
-   uint i;
 
    mach = align_malloc( sizeof *mach, 16 );
    if (!mach)
@@ -6111,6 +6114,10 @@ exec_instruction(
       exec_double_unary(mach, inst, micro_dfrac);
       break;
 
+   case TGSI_OPCODE_DFLR:
+      exec_double_unary(mach, inst, micro_dflr);
+      break;
+
    case TGSI_OPCODE_DLDEXP:
       exec_dldexp(mach, inst);
       break;