From e5536aa584e91d2a859c2f905d9ce40fc410470b Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Mon, 27 May 2019 17:48:42 +0200 Subject: [PATCH] compiler: Add color system value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is nice to have with radeonsi, where color varyings are handled specially to avoid recompiles. Reviewed-by: Bas Nieuwenhuizen Reviewed-by: Marek Olšák --- src/compiler/nir/nir.c | 8 ++++++++ src/compiler/nir/nir_intrinsics.py | 6 ++++++ src/compiler/shader_enums.c | 2 ++ src/compiler/shader_enums.h | 2 ++ 4 files changed, 18 insertions(+) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 81f569b4c2b..4f2da2d431f 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -1848,6 +1848,10 @@ 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_COLOR0: + return nir_intrinsic_load_color0; + case SYSTEM_VALUE_COLOR1: + return nir_intrinsic_load_color1; case SYSTEM_VALUE_VIEW_INDEX: return nir_intrinsic_load_view_index; case SYSTEM_VALUE_SUBGROUP_SIZE: @@ -1933,6 +1937,10 @@ 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_color0: + return SYSTEM_VALUE_COLOR0; + case nir_intrinsic_load_color1: + return SYSTEM_VALUE_COLOR1; case nir_intrinsic_load_view_index: return SYSTEM_VALUE_VIEW_INDEX; case nir_intrinsic_load_subgroup_size: diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py index 24bb0990805..70ff1b99de0 100644 --- a/src/compiler/nir/nir_intrinsics.py +++ b/src/compiler/nir/nir_intrinsics.py @@ -594,6 +594,12 @@ system_value("blend_const_color_rgba", 4) system_value("blend_const_color_rgba8888_unorm", 1) system_value("blend_const_color_aaaa8888_unorm", 1) +# System values for gl_Color, for radeonsi which interpolates these in the +# shader prolog to handle two-sided color without recompiles and therefore +# doesn't handle these in the main shader part like normal varyings. +system_value("color0", 4) +system_value("color1", 4) + # Barycentric coordinate intrinsics. # # These set up the barycentric coordinates for a particular interpolation. diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c index 451f1b758de..f7613cf01a2 100644 --- a/src/compiler/shader_enums.c +++ b/src/compiler/shader_enums.c @@ -231,6 +231,8 @@ gl_system_value_name(gl_system_value sysval) ENUM(SYSTEM_VALUE_SAMPLE_POS), ENUM(SYSTEM_VALUE_SAMPLE_MASK_IN), ENUM(SYSTEM_VALUE_HELPER_INVOCATION), + ENUM(SYSTEM_VALUE_COLOR0), + ENUM(SYSTEM_VALUE_COLOR1), ENUM(SYSTEM_VALUE_TESS_COORD), ENUM(SYSTEM_VALUE_VERTICES_IN), ENUM(SYSTEM_VALUE_PRIMITIVE_ID), diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h index cf753df3791..4d5af8a815b 100644 --- a/src/compiler/shader_enums.h +++ b/src/compiler/shader_enums.h @@ -580,6 +580,8 @@ typedef enum SYSTEM_VALUE_SAMPLE_POS, SYSTEM_VALUE_SAMPLE_MASK_IN, SYSTEM_VALUE_HELPER_INVOCATION, + SYSTEM_VALUE_COLOR0, + SYSTEM_VALUE_COLOR1, /*@}*/ /** -- 2.30.2