Merge remote-tracking branch 'public/master' into vulkan
[mesa.git] / src / mesa / drivers / dri / i965 / brw_fs_nir.cpp
index aa4c745db69ff2533cc8437d7ad204a732c98dd9..ab564bbcb9eee596f31da32dbacc5ed44da10e99 100644 (file)
@@ -765,29 +765,15 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)
       inst->saturate = instr->dest.saturate;
       break;
 
-   case nir_op_fsin: {
-      fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_F);
-      inst = bld.emit(SHADER_OPCODE_SIN, tmp, op[0]);
-      if (instr->dest.saturate) {
-         inst->dst = result;
-         inst->saturate = true;
-      } else {
-         bld.MUL(result, tmp, brw_imm_f(0.99997));
-      }
+   case nir_op_fsin:
+      inst = bld.emit(SHADER_OPCODE_SIN, result, op[0]);
+      inst->saturate = instr->dest.saturate;
       break;
-   }
 
-   case nir_op_fcos: {
-      fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_F);
-      inst = bld.emit(SHADER_OPCODE_COS, tmp, op[0]);
-      if (instr->dest.saturate) {
-         inst->dst = result;
-         inst->saturate = true;
-      } else {
-         bld.MUL(result, tmp, brw_imm_f(0.99997));
-      }
+   case nir_op_fcos:
+      inst = bld.emit(SHADER_OPCODE_COS, result, op[0]);
+      inst->saturate = instr->dest.saturate;
       break;
-   }
 
    case nir_op_fddx:
       if (fs_key->high_quality_derivatives) {
@@ -878,6 +864,10 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)
        * When we XOR the sources, the top bit is 0 if they are the same and 1
        * if they are different.  We can then use a conditional modifier to
        * turn that into a predicate.  This leads us to an XOR.l instruction.
+       *
+       * Technically, according to the PRM, you're not allowed to use .l on a
+       * XOR instruction.  However, emperical experiments and Curro's reading
+       * of the simulator source both indicate that it's safe.
        */
       fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_D);
       inst = bld.XOR(tmp, op[0], op[1]);
@@ -3081,7 +3071,7 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
 
    fs_reg coordinate, shadow_comparitor, lod, lod2, sample_index, mcs, tex_offset;
 
-   /* Our hardware requires a LOD for buffer textures */
+   /* The hardware requires a LOD for buffer textures */
    if (instr->sampler_dim == GLSL_SAMPLER_DIM_BUF)
       lod = brw_imm_d(0);