Esempio n. 1
0
    nir_foreach_instr_safe(instr, block) {
        if (instr->type == nir_instr_type_intrinsic) {
            nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
            if (intr->intrinsic == nir_intrinsic_load_var) {
                nir_deref_var *dvar = intr->variables[0];
                nir_variable *var = dvar->var;

                if (var->data.mode == nir_var_shader_in &&
                        var->data.location == VARYING_SLOT_POS) {
                    /* gl_FragCoord should not have array/struct deref's: */
                    assert(dvar->deref.child == NULL);
                    lower_fragcoord(state, intr);
                } else if (var->data.mode == nir_var_system_value &&
                           var->data.location == SYSTEM_VALUE_SAMPLE_POS) {
                    assert(dvar->deref.child == NULL);
                    lower_load_sample_pos(state, intr);
                }
            } else if (intr->intrinsic == nir_intrinsic_interp_var_at_offset) {
                lower_interp_var_at_offset(state, intr);
            }
        } else if (instr->type == nir_instr_type_alu) {
            nir_alu_instr *alu = nir_instr_as_alu(instr);
            if (alu->op == nir_op_fddy ||
                    alu->op == nir_op_fddy_fine ||
                    alu->op == nir_op_fddy_coarse)
                lower_fddy(state, alu);
        }
    }
Esempio n. 2
0
   nir_foreach_instr_safe(instr, block) {
      if (instr->type == nir_instr_type_intrinsic) {
         nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
         if (intr->intrinsic == nir_intrinsic_load_deref) {
            nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
            nir_variable *var = nir_deref_instr_get_variable(deref);

            if ((var->data.mode == nir_var_shader_in &&
                 var->data.location == VARYING_SLOT_POS) ||
                (var->data.mode == nir_var_system_value &&
                 var->data.location == SYSTEM_VALUE_FRAG_COORD)) {
               /* gl_FragCoord should not have array/struct derefs: */
               lower_fragcoord(state, intr, var);
            } else if (var->data.mode == nir_var_system_value &&
                       var->data.location == SYSTEM_VALUE_SAMPLE_POS) {
               lower_load_sample_pos(state, intr);
            } else if (var->data.mode == nir_var_shader_in &&
                       var->data.location == VARYING_SLOT_PNTC &&
                       state->shader->options->lower_wpos_pntc) {
               lower_load_pointcoord(state, intr);
            }
         } else if (intr->intrinsic == nir_intrinsic_load_frag_coord) {
            lower_fragcoord(state, intr, NULL);
         } else if (intr->intrinsic == nir_intrinsic_load_sample_pos) {
            lower_load_sample_pos(state, intr);
         } else if (intr->intrinsic == nir_intrinsic_interp_deref_at_offset) {
            lower_interp_deref_at_offset(state, intr);
         }
      } else if (instr->type == nir_instr_type_alu) {
         nir_alu_instr *alu = nir_instr_as_alu(instr);
         if (alu->op == nir_op_fddy ||
             alu->op == nir_op_fddy_fine ||
             alu->op == nir_op_fddy_coarse)
            lower_fddy(state, alu);
      }
   }