i965: Add HiZ operation state to brw_context
[mesa.git] / src / mesa / drivers / dri / i965 / brw_shader.cpp
index 3ff6bbaed47eb555989bc4fb72c0327283f384b8..f25fab30a03017e9c4ffdd89e97e6204a5d91600 100644 (file)
@@ -27,8 +27,8 @@ extern "C" {
 #include "brw_vs.h"
 }
 #include "brw_fs.h"
-#include "../glsl/ir_optimization.h"
-#include "../glsl/ir_print_visitor.h"
+#include "glsl/ir_optimization.h"
+#include "glsl/ir_print_visitor.h"
 
 struct gl_shader *
 brw_new_shader(struct gl_context *ctx, GLuint name, GLuint type)
@@ -81,6 +81,9 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
    struct intel_context *intel = &brw->intel;
    unsigned int stage;
 
+   if (!_mesa_ir_link_shader(ctx, prog))
+      return false;
+
    for (stage = 0; stage < ARRAY_SIZE(prog->_LinkedShaders); stage++) {
       struct brw_shader *shader =
         (struct brw_shader *)prog->_LinkedShaders[stage];
@@ -119,7 +122,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
       bool input = true;
       bool output = stage == MESA_SHADER_FRAGMENT;
       bool temp = stage == MESA_SHADER_FRAGMENT;
-      bool uniform = true;
+      bool uniform = stage == MESA_SHADER_FRAGMENT;
 
       lower_variable_index_to_cond_assign(shader->ir,
                                          input, output, temp, uniform);
@@ -138,7 +141,8 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                                   false /* loops */
                                   ) || progress;
 
-        progress = do_common_optimization(shader->ir, true, 32) || progress;
+        progress = do_common_optimization(shader->ir, true, true, 32)
+          || progress;
       } while (progress);
 
       validate_ir_tree(shader->ir);
@@ -147,13 +151,10 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
       ralloc_free(mem_ctx);
    }
 
-   if (!_mesa_ir_link_shader(ctx, prog))
-      return GL_FALSE;
-
    if (!brw_shader_precompile(ctx, prog))
-      return GL_FALSE;
+      return false;
 
-   return GL_TRUE;
+   return true;
 }
 
 
@@ -169,6 +170,7 @@ brw_type_for_base_type(const struct glsl_type *type)
    case GLSL_TYPE_UINT:
       return BRW_REGISTER_TYPE_UD;
    case GLSL_TYPE_ARRAY:
+      return brw_type_for_base_type(type->fields.array);
    case GLSL_TYPE_STRUCT:
    case GLSL_TYPE_SAMPLER:
       /* These should be overridden with the type of the member when
@@ -226,6 +228,10 @@ brw_math_function(enum opcode op)
       return BRW_MATH_FUNCTION_SIN;
    case SHADER_OPCODE_COS:
       return BRW_MATH_FUNCTION_COS;
+   case SHADER_OPCODE_INT_QUOTIENT:
+      return BRW_MATH_FUNCTION_INT_DIV_QUOTIENT;
+   case SHADER_OPCODE_INT_REMAINDER:
+      return BRW_MATH_FUNCTION_INT_DIV_REMAINDER;
    default:
       assert(!"not reached: unknown math function");
       return 0;