nir: Add nir_texop_samples_identical opcode
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 18 Nov 2015 01:09:09 +0000 (17:09 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 20 Nov 2015 04:17:16 +0000 (20:17 -0800)
This is the NIR analog to GLSL IR ir_samples_identical.

v2: Don't add the second nir_tex_src_ms_index parameter.  Suggested by
Ken and Jason.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
src/glsl/nir/glsl_to_nir.cpp
src/glsl/nir/nir.h
src/glsl/nir/nir_print.c
src/mesa/drivers/dri/i965/brw_fs_nir.cpp
src/mesa/drivers/dri/i965/brw_vec4_nir.cpp

index 157dc73a3c68c4961f0416624a2fd488faadce28..0f5c7e901bafc6e4270c1ff3b09a9b5567e7ebaf 100644 (file)
@@ -1624,6 +1624,7 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex)
        case nir_texop_tg4:
        case nir_texop_query_levels:
        case nir_texop_texture_samples:
+       case nir_texop_samples_identical:
                compile_error(ctx, "Unhandled NIR tex type: %d\n", tex->op);
                return;
        }
@@ -1889,6 +1890,8 @@ emit_instr(struct ir3_compile *ctx, nir_instr *instr)
                case nir_texop_query_levels:
                        emit_tex_query_levels(ctx, tex);
                        break;
+               case nir_texop_samples_identical:
+                       unreachable("nir_texop_samples_identical");
                default:
                        emit_tex(ctx, tex);
                        break;
index e149d73e051f0ce0a85e9ecd8d0f2e1ef078ee8d..18ef4909049950dd97bd859332c67ae16e1af2b9 100644 (file)
@@ -1798,6 +1798,11 @@ nir_visitor::visit(ir_texture *ir)
       num_srcs = 0;
       break;
 
+   case ir_samples_identical:
+      op = nir_texop_samples_identical;
+      num_srcs = 1; /* coordinate */
+      break;
+
    default:
       unreachable("not reached");
    }
@@ -1825,6 +1830,7 @@ nir_visitor::visit(ir_texture *ir)
    case GLSL_TYPE_INT:
       instr->dest_type = nir_type_int;
       break;
+   case GLSL_TYPE_BOOL:
    case GLSL_TYPE_UINT:
       instr->dest_type = nir_type_unsigned;
       break;
index 09eb712c06a40008370f7bf7f580889ef30b611e..087b4537c09d82b1d09441a732a7853ae7783fa9 100644 (file)
@@ -956,6 +956,9 @@ typedef enum {
    nir_texop_tg4,                /**< Texture gather */
    nir_texop_query_levels,       /**< Texture levels query */
    nir_texop_texture_samples,    /**< Texture samples query */
+   nir_texop_samples_identical,  /**< Query whether all samples are definitely
+                                  * identical.
+                                  */
 } nir_texop;
 
 typedef struct {
@@ -1029,6 +1032,7 @@ nir_tex_instr_dest_size(nir_tex_instr *instr)
 
    case nir_texop_texture_samples:
    case nir_texop_query_levels:
+   case nir_texop_samples_identical:
       return 1;
 
    default:
index 54b8cc64a9b4a9baa01c2b7006844ea25be80d70..c98a0476ef9170139c08e0feb48a57048ea59f42 100644 (file)
@@ -512,7 +512,9 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
    case nir_texop_texture_samples:
       fprintf(fp, "texture_samples ");
       break;
-
+   case nir_texop_samples_identical:
+      fprintf(fp, "samples_identical ");
+      break;
    default:
       unreachable("Invalid texture operation");
       break;
index 3394e4a75674096b0d8e594dc5a73d83716c8e8d..8fc7ee42d6b5b20ab2264fe95ef6d86b4dbe4780 100644 (file)
@@ -2733,6 +2733,7 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
       inst->base_mrf = -1;
       return;
    }
+   case nir_texop_samples_identical: op = ir_samples_identical; break;
    default:
       unreachable("unknown texture opcode");
    }
index 3d186b49d4e9b0d7c59fa8dd6844c393b0b48850..8088767bce6c16db1125c153da1ae04bbfe49b48 100644 (file)
@@ -1545,6 +1545,7 @@ ir_texture_opcode_for_nir_texop(nir_texop texop)
    case nir_texop_txf_ms: op = ir_txf_ms; break;
    case nir_texop_txl: op = ir_txl; break;
    case nir_texop_txs: op = ir_txs; break;
+   case nir_texop_samples_identical: op = ir_samples_identical; break;
    default:
       unreachable("unknown texture opcode");
    }