i965/fs: make emit_fragcoord_interpolation() not take an ir_variable
authorConnor Abbott <connor.abbott@intel.com>
Tue, 5 Aug 2014 18:02:02 +0000 (11:02 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Jan 2015 15:18:58 +0000 (07:18 -0800)
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_fp.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp

index cbe4fda63dd9f0aa17cc62ebea6b7b5fc0afa6c6..642b9dc34058aec42a3a9e4a510693a5994dfd89 100644 (file)
@@ -1203,16 +1203,17 @@ fs_visitor::setup_builtin_uniform_values(ir_variable *ir)
 }
 
 fs_reg *
-fs_visitor::emit_fragcoord_interpolation(ir_variable *ir)
+fs_visitor::emit_fragcoord_interpolation(bool pixel_center_integer,
+                                         bool origin_upper_left)
 {
    assert(stage == MESA_SHADER_FRAGMENT);
    brw_wm_prog_key *key = (brw_wm_prog_key*) this->key;
-   fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type);
+   fs_reg *reg = new(this->mem_ctx) fs_reg(this, glsl_type::vec4_type);
    fs_reg wpos = *reg;
-   bool flip = !ir->data.origin_upper_left ^ key->render_to_fbo;
+   bool flip = !origin_upper_left ^ key->render_to_fbo;
 
    /* gl_FragCoord.x */
-   if (ir->data.pixel_center_integer) {
+   if (pixel_center_integer) {
       emit(MOV(wpos, this->pixel_x));
    } else {
       emit(ADD(wpos, this->pixel_x, fs_reg(0.5f)));
@@ -1220,11 +1221,11 @@ fs_visitor::emit_fragcoord_interpolation(ir_variable *ir)
    wpos = offset(wpos, 1);
 
    /* gl_FragCoord.y */
-   if (!flip && ir->data.pixel_center_integer) {
+   if (!flip && pixel_center_integer) {
       emit(MOV(wpos, this->pixel_y));
    } else {
       fs_reg pixel_y = this->pixel_y;
-      float offset = (ir->data.pixel_center_integer ? 0.0 : 0.5);
+      float offset = (pixel_center_integer ? 0.0 : 0.5);
 
       if (flip) {
         pixel_y.negate = true;
index c9f235cd09e9b5b5486d90ed320a837fdb9ed45e..d488c621566c8030d7eb1b990494d42d25d52f3d 100644 (file)
@@ -471,7 +471,8 @@ public:
 
    void emit_dummy_fs();
    void emit_repclear_shader();
-   fs_reg *emit_fragcoord_interpolation(ir_variable *ir);
+   fs_reg *emit_fragcoord_interpolation(bool pixel_center_integer,
+                                        bool origin_upper_left);
    fs_inst *emit_linterp(const fs_reg &attr, const fs_reg &interp,
                          glsl_interp_qualifier interpolation_mode,
                          bool is_centroid, bool is_sample);
index bead05a21a82fa9ee1ffb8bea2f1a7baca5e12df..8041740784e732090bb7fd8df96b315665ea9d74 100644 (file)
@@ -584,8 +584,10 @@ fs_visitor::setup_fp_regs()
                gl_fragment_program *fp = (gl_fragment_program*) prog;
                ir->data.pixel_center_integer = fp->PixelCenterInteger;
                ir->data.origin_upper_left = fp->OriginUpperLeft;
+               fp_input_regs[i] =
+                  *emit_fragcoord_interpolation(fp->PixelCenterInteger,
+                                                fp->OriginUpperLeft);
             }
-            fp_input_regs[i] = *emit_fragcoord_interpolation(ir);
             break;
          case VARYING_SLOT_FACE:
             fp_input_regs[i] = *emit_frontfacing_interpolation();
index 1e7fdf5b4f20014286de7f27e77f03da1e524ed4..9c6b197a923641492769d29551ec6e52f8df011c 100644 (file)
@@ -93,7 +93,8 @@ fs_visitor::visit(ir_variable *ir)
             fs_reg(ATTR, ir->data.location,
                    brw_type_for_base_type(ir->type->get_scalar_type()));
       } else if (!strcmp(ir->name, "gl_FragCoord")) {
-        reg = emit_fragcoord_interpolation(ir);
+         reg = emit_fragcoord_interpolation(ir->data.pixel_center_integer,
+                                            ir->data.origin_upper_left);
       } else if (!strcmp(ir->name, "gl_FrontFacing")) {
         reg = emit_frontfacing_interpolation();
       } else {