nir: Drop "SSA" from NIR language

Everything is SSA now.

   sed -e 's/nir_ssa_def/nir_def/g' \
       -e 's/nir_ssa_undef/nir_undef/g' \
       -e 's/nir_ssa_scalar/nir_scalar/g' \
       -e 's/nir_src_rewrite_ssa/nir_src_rewrite/g' \
       -e 's/nir_gather_ssa_types/nir_gather_types/g' \
       -i $(git grep -l nir | grep -v relnotes)

   git mv src/compiler/nir/nir_gather_ssa_types.c \
          src/compiler/nir/nir_gather_types.c

   ninja -C build/ clang-format
   cd src/compiler/nir && find *.c *.h -type f -exec clang-format -i \{} \;

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Acked-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24585>
This commit is contained in:
Alyssa Rosenzweig
2023-08-12 16:17:15 -04:00
parent 777d336b1f
commit 09d31922de
492 changed files with 10408 additions and 10455 deletions
+21 -21
View File
@@ -117,7 +117,7 @@ compute_off_scale(uint32_t src_level_size,
*scale_out = dst_scale;
}
static inline nir_ssa_def *
static inline nir_def *
load_struct_var(nir_builder *b, nir_variable *var, uint32_t field)
{
nir_deref_instr *deref =
@@ -125,13 +125,13 @@ load_struct_var(nir_builder *b, nir_variable *var, uint32_t field)
return nir_load_deref(b, deref);
}
static nir_ssa_def *
static nir_def *
build_tex_resolve(nir_builder *b, nir_deref_instr *t,
nir_ssa_def *coord,
nir_def *coord,
VkSampleCountFlagBits samples,
VkResolveModeFlagBits resolve_mode)
{
nir_ssa_def *accum = nir_txf_ms_deref(b, t, coord, nir_imm_int(b, 0));
nir_def *accum = nir_txf_ms_deref(b, t, coord, nir_imm_int(b, 0));
if (resolve_mode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT)
return accum;
@@ -139,7 +139,7 @@ build_tex_resolve(nir_builder *b, nir_deref_instr *t,
glsl_get_sampler_result_type(t->type);
for (unsigned i = 1; i < samples; i++) {
nir_ssa_def *val = nir_txf_ms_deref(b, t, coord, nir_imm_int(b, i));
nir_def *val = nir_txf_ms_deref(b, t, coord, nir_imm_int(b, i));
switch (resolve_mode) {
case VK_RESOLVE_MODE_AVERAGE_BIT:
assert(base_type == GLSL_TYPE_FLOAT);
@@ -213,28 +213,28 @@ build_blit_shader(const struct vk_meta_blit_key *key)
nir_variable *push = nir_variable_create(b->shader, nir_var_mem_push_const,
push_iface_type, "push");
nir_ssa_def *xy_xform = load_struct_var(b, push, 0);
nir_ssa_def *xy_off = nir_channels(b, xy_xform, 3 << 0);
nir_ssa_def *xy_scale = nir_channels(b, xy_xform, 3 << 2);
nir_def *xy_xform = load_struct_var(b, push, 0);
nir_def *xy_off = nir_channels(b, xy_xform, 3 << 0);
nir_def *xy_scale = nir_channels(b, xy_xform, 3 << 2);
nir_ssa_def *out_coord_xy = nir_load_frag_coord(b);
nir_def *out_coord_xy = nir_load_frag_coord(b);
out_coord_xy = nir_trim_vector(b, out_coord_xy, 2);
nir_ssa_def *src_coord_xy = nir_ffma(b, out_coord_xy, xy_scale, xy_off);
nir_def *src_coord_xy = nir_ffma(b, out_coord_xy, xy_scale, xy_off);
nir_ssa_def *z_xform = load_struct_var(b, push, 1);
nir_ssa_def *out_layer = nir_load_layer_id(b);
nir_ssa_def *src_coord;
nir_def *z_xform = load_struct_var(b, push, 1);
nir_def *out_layer = nir_load_layer_id(b);
nir_def *src_coord;
if (key->dim == GLSL_SAMPLER_DIM_3D) {
nir_ssa_def *z_off = nir_channel(b, z_xform, 0);
nir_ssa_def *z_scale = nir_channel(b, z_xform, 1);
nir_ssa_def *out_coord_z = nir_fadd_imm(b, nir_u2f32(b, out_layer), 0.5);
nir_ssa_def *src_coord_z = nir_ffma(b, out_coord_z, z_scale, z_off);
nir_def *z_off = nir_channel(b, z_xform, 0);
nir_def *z_scale = nir_channel(b, z_xform, 1);
nir_def *out_coord_z = nir_fadd_imm(b, nir_u2f32(b, out_layer), 0.5);
nir_def *src_coord_z = nir_ffma(b, out_coord_z, z_scale, z_off);
src_coord = nir_vec3(b, nir_channel(b, src_coord_xy, 0),
nir_channel(b, src_coord_xy, 1),
src_coord_z);
} else {
nir_ssa_def *arr_delta = nir_channel(b, z_xform, 2);
nir_ssa_def *in_layer = nir_iadd(b, out_layer, arr_delta);
nir_def *arr_delta = nir_channel(b, z_xform, 2);
nir_def *in_layer = nir_iadd(b, out_layer, arr_delta);
if (key->dim == GLSL_SAMPLER_DIM_1D) {
src_coord = nir_vec2(b, nir_channel(b, src_coord_xy, 0),
nir_u2f32(b, in_layer));
@@ -303,7 +303,7 @@ build_blit_shader(const struct vk_meta_blit_key *key)
texture->data.binding = aspect_to_tex_binding(aspect);
nir_deref_instr *t = nir_build_deref_var(b, texture);
nir_ssa_def *val;
nir_def *val;
if (resolve_mode == VK_RESOLVE_MODE_NONE) {
val = nir_txl_deref(b, t, s, src_coord, nir_imm_float(b, 0));
} else {
@@ -314,7 +314,7 @@ build_blit_shader(const struct vk_meta_blit_key *key)
if (key->stencil_as_discard) {
assert(key->aspects == VK_IMAGE_ASPECT_STENCIL_BIT);
nir_ssa_def *stencil_bit = nir_channel(b, z_xform, 3);
nir_def *stencil_bit = nir_channel(b, z_xform, 3);
nir_discard_if(b, nir_ieq(b, nir_iand(b, val, stencil_bit),
nir_imm_int(b, 0)));
} else {
+1 -1
View File
@@ -67,7 +67,7 @@ build_clear_shader(const struct vk_meta_clear_key *key)
nir_build_deref_struct(b, nir_build_deref_var(b, push), 0);
u_foreach_bit(a, key->color_attachments_cleared) {
nir_ssa_def *color_value =
nir_def *color_value =
nir_load_deref(b, nir_build_deref_array_imm(b, push_arr, a));
const struct glsl_type *out_type;
+1 -1
View File
@@ -79,7 +79,7 @@ vk_meta_draw_rects_vs_nir(struct vk_meta_device *device, bool use_gs)
use_gs ? "layer_out" : "gl_Layer");
layer->data.location = use_gs ? VARYING_SLOT_VAR1 : VARYING_SLOT_LAYER;
nir_ssa_def *vtx = nir_load_var(b, in);
nir_def *vtx = nir_load_var(b, in);
nir_store_var(b, pos, nir_vec4(b, nir_channel(b, vtx, 0),
nir_channel(b, vtx, 1),
nir_channel(b, vtx, 2),
+25 -25
View File
@@ -28,9 +28,9 @@
#include <math.h>
static nir_ssa_def *
static nir_def *
y_range(nir_builder *b,
nir_ssa_def *y_channel,
nir_def *y_channel,
int bpc,
VkSamplerYcbcrRange range)
{
@@ -51,9 +51,9 @@ y_range(nir_builder *b,
}
}
static nir_ssa_def *
static nir_def *
chroma_range(nir_builder *b,
nir_ssa_def *chroma_channel,
nir_def *chroma_channel,
int bpc,
VkSamplerYcbcrRange range)
{
@@ -115,14 +115,14 @@ ycbcr_model_to_rgb_matrix(VkSamplerYcbcrModelConversion model)
}
}
nir_ssa_def *
nir_def *
nir_convert_ycbcr_to_rgb(nir_builder *b,
VkSamplerYcbcrModelConversion model,
VkSamplerYcbcrRange range,
nir_ssa_def *raw_channels,
nir_def *raw_channels,
uint32_t *bpcs)
{
nir_ssa_def *expanded_channels =
nir_def *expanded_channels =
nir_vec4(b,
chroma_range(b, nir_channel(b, raw_channels, 0), bpcs[0], range),
y_range(b, nir_channel(b, raw_channels, 1), bpcs[1], range),
@@ -135,7 +135,7 @@ nir_convert_ycbcr_to_rgb(nir_builder *b,
const nir_const_value_3_4 *conversion_matrix =
ycbcr_model_to_rgb_matrix(model);
nir_ssa_def *converted_channels[] = {
nir_def *converted_channels[] = {
nir_fdot(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[0])),
nir_fdot(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[1])),
nir_fdot(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[2]))
@@ -148,7 +148,7 @@ nir_convert_ycbcr_to_rgb(nir_builder *b,
struct ycbcr_state {
nir_builder *builder;
nir_ssa_def *image_size;
nir_def *image_size;
nir_tex_instr *origin_tex;
nir_deref_instr *tex_deref;
const struct vk_ycbcr_conversion_state *conversion;
@@ -156,7 +156,7 @@ struct ycbcr_state {
};
/* TODO: we should probably replace this with a push constant/uniform. */
static nir_ssa_def *
static nir_def *
get_texture_size(struct ycbcr_state *state, nir_deref_instr *texture)
{
if (state->image_size)
@@ -184,10 +184,10 @@ get_texture_size(struct ycbcr_state *state, nir_deref_instr *texture)
return state->image_size;
}
static nir_ssa_def *
static nir_def *
implicit_downsampled_coord(nir_builder *b,
nir_ssa_def *value,
nir_ssa_def *max_value,
nir_def *value,
nir_def *max_value,
int div_scale)
{
return nir_fadd(b,
@@ -198,15 +198,15 @@ implicit_downsampled_coord(nir_builder *b,
max_value)));
}
static nir_ssa_def *
static nir_def *
implicit_downsampled_coords(struct ycbcr_state *state,
nir_ssa_def *old_coords,
nir_def *old_coords,
const struct vk_format_ycbcr_plane *format_plane)
{
nir_builder *b = state->builder;
const struct vk_ycbcr_conversion_state *conversion = state->conversion;
nir_ssa_def *image_size = get_texture_size(state, state->tex_deref);
nir_ssa_def *comp[4] = { NULL, };
nir_def *image_size = get_texture_size(state, state->tex_deref);
nir_def *comp[4] = { NULL, };
int c;
for (c = 0; c < ARRAY_SIZE(conversion->chroma_offsets); c++) {
@@ -228,7 +228,7 @@ implicit_downsampled_coords(struct ycbcr_state *state,
return nir_vec(b, comp, old_coords->num_components);
}
static nir_ssa_def *
static nir_def *
create_plane_tex_instr_implicit(struct ycbcr_state *state,
uint32_t plane)
{
@@ -365,10 +365,10 @@ lower_ycbcr_tex_instr(nir_builder *b, nir_instr *instr, void *_state)
uint8_t y_bpc = y_format_desc->channel[0].size;
/* |ycbcr_comp| holds components in the order : Cr-Y-Cb */
nir_ssa_def *zero = nir_imm_float(b, 0.0f);
nir_ssa_def *one = nir_imm_float(b, 1.0f);
nir_def *zero = nir_imm_float(b, 0.0f);
nir_def *one = nir_imm_float(b, 1.0f);
/* Use extra 2 channels for following swizzle */
nir_ssa_def *ycbcr_comp[5] = { zero, zero, zero, one, zero };
nir_def *ycbcr_comp[5] = { zero, zero, zero, one, zero };
uint8_t ycbcr_bpcs[5];
memset(ycbcr_bpcs, y_bpc, sizeof(ycbcr_bpcs));
@@ -389,7 +389,7 @@ lower_ycbcr_tex_instr(nir_builder *b, nir_instr *instr, void *_state)
.conversion = conversion,
.format_ycbcr_info = format_ycbcr_info,
};
nir_ssa_def *plane_sample = create_plane_tex_instr_implicit(&tex_state, p);
nir_def *plane_sample = create_plane_tex_instr_implicit(&tex_state, p);
for (uint32_t pc = 0; pc < 4; pc++) {
VkComponentSwizzle ycbcr_swizzle = format_plane->ycbcr_swizzle[pc];
@@ -407,7 +407,7 @@ lower_ycbcr_tex_instr(nir_builder *b, nir_instr *instr, void *_state)
}
/* Now remaps components to the order specified by the conversion. */
nir_ssa_def *swizzled_comp[4] = { NULL, };
nir_def *swizzled_comp[4] = { NULL, };
uint32_t swizzled_bpcs[4] = { 0, };
for (uint32_t i = 0; i < ARRAY_SIZE(conversion->mapping); i++) {
@@ -431,7 +431,7 @@ lower_ycbcr_tex_instr(nir_builder *b, nir_instr *instr, void *_state)
}
}
nir_ssa_def *result = nir_vec(b, swizzled_comp, 4);
nir_def *result = nir_vec(b, swizzled_comp, 4);
if (conversion->ycbcr_model != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
result = nir_convert_ycbcr_to_rgb(b, conversion->ycbcr_model,
conversion->ycbcr_range,
@@ -439,7 +439,7 @@ lower_ycbcr_tex_instr(nir_builder *b, nir_instr *instr, void *_state)
swizzled_bpcs);
}
nir_ssa_def_rewrite_uses(&tex->dest.ssa, result);
nir_def_rewrite_uses(&tex->dest.ssa, result);
nir_instr_remove(&tex->instr);
return true;
+2 -2
View File
@@ -32,11 +32,11 @@
extern "C" {
#endif
nir_ssa_def *
nir_def *
nir_convert_ycbcr_to_rgb(nir_builder *b,
VkSamplerYcbcrModelConversion model,
VkSamplerYcbcrRange range,
nir_ssa_def *raw_channels,
nir_def *raw_channels,
uint32_t *bpcs);
struct vk_ycbcr_conversion;