i965: Fix Crystal Well PCI IDs.
[mesa.git] / src / mesa / program / ir_to_mesa.cpp
index baa317204c4c881432643eb3a5da50655afa5a5c..486cf4639cef4fa901dfe7ca9a0b492ce696a199 100644 (file)
@@ -325,16 +325,16 @@ public:
    void *mem_ctx;
 };
 
-src_reg undef_src = src_reg(PROGRAM_UNDEFINED, 0, NULL);
+static src_reg undef_src = src_reg(PROGRAM_UNDEFINED, 0, NULL);
 
-dst_reg undef_dst = dst_reg(PROGRAM_UNDEFINED, SWIZZLE_NOOP);
+static dst_reg undef_dst = dst_reg(PROGRAM_UNDEFINED, SWIZZLE_NOOP);
 
-dst_reg address_reg = dst_reg(PROGRAM_ADDRESS, WRITEMASK_X);
+static dst_reg address_reg = dst_reg(PROGRAM_ADDRESS, WRITEMASK_X);
 
 static int
 swizzle_for_size(int size)
 {
-   int size_swizzles[4] = {
+   static const int size_swizzles[4] = {
       MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
       MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y),
       MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z),
@@ -623,10 +623,14 @@ type_size(const struct glsl_type *type)
        * at link time.
        */
       return 1;
-   default:
-      assert(0);
-      return 0;
+   case GLSL_TYPE_VOID:
+   case GLSL_TYPE_ERROR:
+   case GLSL_TYPE_INTERFACE:
+      assert(!"Invalid type in type_size");
+      break;
    }
+
+   return 0;
 }
 
 /**
@@ -1427,7 +1431,21 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
    case ir_unop_fract:
       emit(ir, OPCODE_FRC, result_dst, op[0]);
       break;
-
+   case ir_unop_pack_snorm_2x16:
+   case ir_unop_pack_snorm_4x8:
+   case ir_unop_pack_unorm_2x16:
+   case ir_unop_pack_unorm_4x8:
+   case ir_unop_pack_half_2x16:
+   case ir_unop_unpack_snorm_2x16:
+   case ir_unop_unpack_snorm_4x8:
+   case ir_unop_unpack_unorm_2x16:
+   case ir_unop_unpack_unorm_4x8:
+   case ir_unop_unpack_half_2x16:
+   case ir_unop_unpack_half_2x16_split_x:
+   case ir_unop_unpack_half_2x16_split_y:
+   case ir_binop_pack_half_2x16_split:
+      assert(!"not supported");
+      break;
    case ir_binop_min:
       emit(ir, OPCODE_MIN, result_dst, op[0], op[1]);
       break;
@@ -1456,6 +1474,17 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
       emit(ir, OPCODE_MOV, result_dst, op[0]);
       break;
 
+   case ir_binop_ubo_load:
+      assert(!"not supported");
+      break;
+
+   case ir_triop_lrp:
+      /* ir_triop_lrp operands are (x, y, a) while
+       * OPCODE_LRP operands are (a, y, x) to match ARB_fragment_program.
+       */
+      emit(ir, OPCODE_LRP, result_dst, op[2], op[1], op[0]);
+      break;
+
    case ir_quadop_vector:
       /* This operation should have already been handled.
        */
@@ -1525,21 +1554,18 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
                                               var->location);
         this->variables.push_tail(entry);
         break;
-      case ir_var_in:
-      case ir_var_inout:
+      case ir_var_shader_in:
         /* The linker assigns locations for varyings and attributes,
          * including deprecated builtins (like gl_Color),
          * user-assigned generic attributes (glBindVertexLocation),
          * and user-defined varyings.
-         *
-         * FINISHME: We would hit this path for function arguments.  Fix!
          */
         assert(var->location != -1);
          entry = new(mem_ctx) variable_storage(var,
                                                PROGRAM_INPUT,
                                                var->location);
          break;
-      case ir_var_out:
+      case ir_var_shader_out:
         assert(var->location != -1);
          entry = new(mem_ctx) variable_storage(var,
                                                PROGRAM_OUTPUT,
@@ -2019,6 +2045,9 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
       ir->lod_info.grad.dPdy->accept(this);
       dy = this->result;
       break;
+   case ir_txf_ms:
+      assert(!"Unexpected ir_txf_ms opcode");
+      break;
    }
 
    const glsl_type *sampler_type = ir->sampler->type;
@@ -2356,7 +2385,7 @@ print_program(struct prog_instruction *mesa_instructions,
    }
 }
 
-class add_uniform_to_shader : public uniform_field_visitor {
+class add_uniform_to_shader : public program_resource_visitor {
 public:
    add_uniform_to_shader(struct gl_shader_program *shader_program,
                         struct gl_program_parameter_list *params)
@@ -2368,13 +2397,14 @@ public:
    void process(ir_variable *var)
    {
       this->idx = -1;
-      this->uniform_field_visitor::process(var);
+      this->program_resource_visitor::process(var);
 
       var->location = this->idx;
    }
 
 private:
-   virtual void visit_field(const glsl_type *type, const char *name);
+   virtual void visit_field(const glsl_type *type, const char *name,
+                            bool row_major);
 
    struct gl_shader_program *shader_program;
    struct gl_program_parameter_list *params;
@@ -2382,10 +2412,13 @@ private:
 };
 
 void
-add_uniform_to_shader::visit_field(const glsl_type *type, const char *name)
+add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
+                                   bool row_major)
 {
    unsigned int size;
 
+   (void) row_major;
+
    if (type->is_vector() || type->is_scalar()) {
       size = type->vector_elements;
    } else {
@@ -2403,7 +2436,7 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name)
    int index = _mesa_lookup_parameter_index(params, -1, name);
    if (index < 0) {
       index = _mesa_add_parameter(params, file, name, size, type->gl_type,
-                                 NULL, NULL, 0x0);
+                                 NULL, NULL);
 
       /* Sampler uniform values are stored in prog->SamplerUnits,
        * and the entry in that array is selected by this index we
@@ -2455,7 +2488,7 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
       ir_variable *var = ((ir_instruction *) node)->as_variable();
 
       if ((var == NULL) || (var->mode != ir_var_uniform)
-         || (strncmp(var->name, "gl_", 3) == 0))
+         || var->is_in_uniform_block() || (strncmp(var->name, "gl_", 3) == 0))
         continue;
 
       add.process(var);
@@ -2518,7 +2551,11 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
            format = uniform_native;
            columns = 1;
            break;
-        default:
+         case GLSL_TYPE_ARRAY:
+         case GLSL_TYPE_VOID:
+         case GLSL_TYPE_STRUCT:
+         case GLSL_TYPE_ERROR:
+         case GLSL_TYPE_INTERFACE:
            assert(!"Should not get here.");
            break;
         }
@@ -3056,8 +3093,8 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader)
       return;
    }
 
-   state->error = preprocess(state, &source, &state->info_log,
-                            &ctx->Extensions, ctx->API);
+   state->error = glcpp_preprocess(state, &source, &state->info_log,
+                            &ctx->Extensions, ctx);
 
    if (ctx->Shader.Flags & GLSL_DUMP) {
       printf("GLSL source for %s shader %d:\n",