[Mesa-dev] [RFC 01/12] compiler: Add a system value and varying for ViewIndex

Jason Ekstrand jason at jlekstrand.net
Thu Mar 23 04:01:00 UTC 2017


---
 src/compiler/nir/nir.c            | 4 ++++
 src/compiler/nir/nir_intrinsics.h | 1 +
 src/compiler/shader_enums.c       | 2 ++
 src/compiler/shader_enums.h       | 4 ++++
 4 files changed, 11 insertions(+)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 937b630..39a74a2 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1903,6 +1903,8 @@ nir_intrinsic_from_system_value(gl_system_value val)
       return nir_intrinsic_load_patch_vertices_in;
    case SYSTEM_VALUE_HELPER_INVOCATION:
       return nir_intrinsic_load_helper_invocation;
+   case SYSTEM_VALUE_VIEW_INDEX:
+      return nir_intrinsic_load_view_index;
    default:
       unreachable("system value does not directly correspond to intrinsic");
    }
@@ -1954,6 +1956,8 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
       return SYSTEM_VALUE_VERTICES_IN;
    case nir_intrinsic_load_helper_invocation:
       return SYSTEM_VALUE_HELPER_INVOCATION;
+   case nir_intrinsic_load_view_index:
+      return SYSTEM_VALUE_VIEW_INDEX;
    default:
       unreachable("intrinsic doesn't produce a system value");
    }
diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
index 105c56f..6a38865 100644
--- a/src/compiler/nir/nir_intrinsics.h
+++ b/src/compiler/nir/nir_intrinsics.h
@@ -329,6 +329,7 @@ SYSTEM_VALUE(helper_invocation, 1, 0, xx, xx, xx)
 SYSTEM_VALUE(channel_num, 1, 0, xx, xx, xx)
 SYSTEM_VALUE(alpha_ref_float, 1, 0, xx, xx, xx)
 SYSTEM_VALUE(layer_id, 1, 0, xx, xx, xx)
+SYSTEM_VALUE(view_index, 1, 0, xx, xx, xx)
 
 /* Blend constant color values.  Float values are clamped. */
 SYSTEM_VALUE(blend_const_color_r_float, 1, 0, xx, xx, xx)
diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c
index e704c95..1539dbf 100644
--- a/src/compiler/shader_enums.c
+++ b/src/compiler/shader_enums.c
@@ -162,6 +162,7 @@ gl_varying_slot_name(gl_varying_slot slot)
       ENUM(VARYING_SLOT_TESS_LEVEL_INNER),
       ENUM(VARYING_SLOT_BOUNDING_BOX0),
       ENUM(VARYING_SLOT_BOUNDING_BOX1),
+      ENUM(VARYING_SLOT_VIEW_INDEX),
       ENUM(VARYING_SLOT_VAR0),
       ENUM(VARYING_SLOT_VAR1),
       ENUM(VARYING_SLOT_VAR2),
@@ -225,6 +226,7 @@ gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_GLOBAL_INVOCATION_ID),
      ENUM(SYSTEM_VALUE_WORK_GROUP_ID),
      ENUM(SYSTEM_VALUE_NUM_WORK_GROUPS),
+     ENUM(SYSTEM_VALUE_VIEW_INDEX),
      ENUM(SYSTEM_VALUE_VERTEX_CNT),
    };
    STATIC_ASSERT(ARRAY_SIZE(names) == SYSTEM_VALUE_MAX);
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index 98565c8..a4668a7 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -217,6 +217,7 @@ typedef enum
    VARYING_SLOT_TESS_LEVEL_INNER, /* Only appears as TCS output. */
    VARYING_SLOT_BOUNDING_BOX0, /* Only appears as TCS output. */
    VARYING_SLOT_BOUNDING_BOX1, /* Only appears as TCS output. */
+   VARYING_SLOT_VIEW_INDEX,
    VARYING_SLOT_VAR0, /* First generic varying slot */
    /* the remaining are simply for the benefit of gl_varying_slot_name()
     * and not to be construed as an upper bound:
@@ -476,6 +477,9 @@ typedef enum
    SYSTEM_VALUE_LOCAL_GROUP_SIZE,
    /*@}*/
 
+   /** Required for VK_KHX_multiview */
+   SYSTEM_VALUE_VIEW_INDEX,
+
    /**
     * Driver internal vertex-count, used (for example) for drivers to
     * calculate stride for stream-out outputs.  Not externally visible.
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list