nir: Add new texop nir_texop_tex_prefetch
authorEduardo Lima Mitev <elima@igalia.com>
Wed, 10 Jul 2019 07:48:21 +0000 (09:48 +0200)
committerRob Clark <robdclark@gmail.com>
Fri, 18 Oct 2019 21:11:54 +0000 (21:11 +0000)
This is like nir_texop_tex, but signals that the sampling coordinates
are immutable during the shader stage, in a way that allows the HW
that supports pre-dispatching sampling operations to pre-fetch
the result prior to scheduling the shader stage.

This is introduced to support the feature in Freedreno. Adreno HW
from a4xx supports it.

A NIR pass introduced later in this series will detect sampling
operations that are eligible for pre-dispatch, and replace
nir_texop_tex by this new op, to tell the backend to enable
pre-fetch.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
src/compiler/nir/nir.h
src/compiler/nir/nir_print.c
src/compiler/spirv/spirv_to_nir.c

index 5c98aeefc66aec4fa7955cb14e16ed5855ecb290..43c904913d62ee052ac39396ed64ccf10b74995b 100644 (file)
@@ -1736,6 +1736,7 @@ typedef enum {
    nir_texop_samples_identical,  /**< Query whether all samples are definitely
                                   * identical.
                                   */
+   nir_texop_tex_prefetch,       /**< Regular texture look-up, eligible for pre-dispatch */
 } nir_texop;
 
 typedef struct {
index 496f92796761147092a7ef83389302a3607d165e..8408fa2ba741013f29f03d9f2f5336c60bad0e46 100644 (file)
@@ -985,6 +985,9 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
    case nir_texop_samples_identical:
       fprintf(fp, "samples_identical ");
       break;
+   case nir_texop_tex_prefetch:
+      fprintf(fp, "tex (pre-dispatchable) ");
+      break;
    default:
       unreachable("Invalid texture operation");
       break;
index 4fb2edae88d458269c0bb52d108783095b4a19bb..14b76785561acd392ab20aba08eea3b1c761b7e7 100644 (file)
@@ -2110,6 +2110,8 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
       break;
    case nir_texop_txf_ms_mcs:
       vtn_fail("unexpected nir_texop_txf_ms_mcs");
+   case nir_texop_tex_prefetch:
+      vtn_fail("unexpected nir_texop_tex_prefetch");
    }
 
    unsigned idx = 4;