nir: replace nir_load_system_value calls with appropiate builder functions
authorKarol Herbst <kherbst@redhat.com>
Thu, 19 Jul 2018 09:44:31 +0000 (11:44 +0200)
committerKarol Herbst <kherbst@redhat.com>
Wed, 14 Nov 2018 01:09:11 +0000 (02:09 +0100)
this helps reduce the overall code changes when a bit_size parameter is
added to nir_load_system_value

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Karol Herbst <kherbst@redhat.com>
src/amd/vulkan/radv_meta_buffer.c
src/amd/vulkan/radv_meta_bufimage.c
src/amd/vulkan/radv_meta_clear.c
src/amd/vulkan/radv_meta_fast_clear.c
src/amd/vulkan/radv_meta_resolve_cs.c
src/amd/vulkan/radv_query.c
src/compiler/nir/nir_lower_clip.c
src/compiler/nir/nir_lower_wpos_center.c
src/intel/vulkan/anv_nir_lower_input_attachments.c

index 8726d36f5fa09ca123ad88e367693b2b715c27af..76854d7bbad1617113f4164b0d8d01305a7f8a1c 100644 (file)
@@ -15,8 +15,8 @@ build_buffer_fill_shader(struct radv_device *dev)
        b.shader->info.cs.local_size[1] = 1;
        b.shader->info.cs.local_size[2] = 1;
 
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
@@ -67,8 +67,8 @@ build_buffer_copy_shader(struct radv_device *dev)
        b.shader->info.cs.local_size[1] = 1;
        b.shader->info.cs.local_size[2] = 1;
 
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
index 6f074a70b4c43e8780f0d3c8594f35eea4acd13c..f5b68f6c9a6a907fe55db138669ddce83a3898b9 100644 (file)
@@ -60,8 +60,8 @@ build_nir_itob_compute_shader(struct radv_device *dev, bool is_3d)
        output_img->data.descriptor_set = 0;
        output_img->data.binding = 1;
 
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
@@ -289,8 +289,8 @@ build_nir_btoi_compute_shader(struct radv_device *dev, bool is_3d)
        output_img->data.descriptor_set = 0;
        output_img->data.binding = 1;
 
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
@@ -719,8 +719,8 @@ build_nir_itoi_compute_shader(struct radv_device *dev, bool is_3d)
        output_img->data.descriptor_set = 0;
        output_img->data.binding = 1;
 
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
@@ -1139,8 +1139,8 @@ build_nir_cleari_compute_shader(struct radv_device *dev, bool is_3d)
        output_img->data.descriptor_set = 0;
        output_img->data.binding = 0;
 
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
index c8a7f80d55d2513e65e5b1ed9ea45c4d2116272b..35da8797f5d9955ef4010fde3871b1f5d83b8fae 100644 (file)
@@ -81,8 +81,8 @@ build_color_shaders(struct nir_shader **out_vs,
                                    "v_layer");
        vs_out_layer->data.location = VARYING_SLOT_LAYER;
        vs_out_layer->data.interpolation = INTERP_MODE_FLAT;
-       nir_ssa_def *inst_id = nir_load_system_value(&vs_b, nir_intrinsic_load_instance_id, 0);
-       nir_ssa_def *base_instance = nir_load_system_value(&vs_b, nir_intrinsic_load_base_instance, 0);
+       nir_ssa_def *inst_id = nir_load_instance_id(&vs_b);
+       nir_ssa_def *base_instance = nir_load_base_instance(&vs_b);
 
        nir_ssa_def *layer_id = nir_iadd(&vs_b, inst_id, base_instance);
        nir_store_var(&vs_b, vs_out_layer, layer_id, 0x1);
@@ -470,8 +470,8 @@ build_depthstencil_shader(struct nir_shader **out_vs, struct nir_shader **out_fs
                                    "v_layer");
        vs_out_layer->data.location = VARYING_SLOT_LAYER;
        vs_out_layer->data.interpolation = INTERP_MODE_FLAT;
-       nir_ssa_def *inst_id = nir_load_system_value(&vs_b, nir_intrinsic_load_instance_id, 0);
-       nir_ssa_def *base_instance = nir_load_system_value(&vs_b, nir_intrinsic_load_base_instance, 0);
+       nir_ssa_def *inst_id = nir_load_instance_id(&vs_b);
+       nir_ssa_def *base_instance = nir_load_base_instance(&vs_b);
 
        nir_ssa_def *layer_id = nir_iadd(&vs_b, inst_id, base_instance);
        nir_store_var(&vs_b, vs_out_layer, layer_id, 0x1);
index 9544ee94f5ca65c6a76796221c9d188100532a26..53f1b31a9908b34f3f48bfe53c853688f7203f15 100644 (file)
@@ -58,8 +58,8 @@ build_dcc_decompress_compute_shader(struct radv_device *dev)
        output_img->data.descriptor_set = 0;
        output_img->data.binding = 1;
 
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
index 2fcfb0aaefff3003fff6fddbf2f1984713711477..e56df7f8a59e248501d272520bd63732ecb315df 100644 (file)
@@ -99,8 +99,8 @@ build_resolve_compute_shader(struct radv_device *dev, bool is_integer, bool is_s
                                                       img_type, "out_img");
        output_img->data.descriptor_set = 0;
        output_img->data.binding = 1;
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
index 9993b9acd6d2e9bfdeafde725ac5b59d5dc0daa2..550abe307a1ecffb8ea4f02099c9ac21cdece20a 100644 (file)
@@ -153,8 +153,8 @@ build_occlusion_query_shader(struct radv_device *device) {
        nir_ssa_dest_init(&src_buf->instr, &src_buf->dest, 1, 32, NULL);
        nir_builder_instr_insert(&b, &src_buf->instr);
 
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
@@ -343,8 +343,8 @@ build_pipeline_statistics_query_shader(struct radv_device *device) {
        nir_ssa_dest_init(&src_buf->instr, &src_buf->dest, 1, 32, NULL);
        nir_builder_instr_insert(&b, &src_buf->instr);
 
-       nir_ssa_def *invoc_id = nir_load_system_value(&b, nir_intrinsic_load_local_invocation_id, 0);
-       nir_ssa_def *wg_id = nir_load_system_value(&b, nir_intrinsic_load_work_group_id, 0);
+       nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
index 7081295a5000062b9f5d1f0c94221d5a9ccbe4a9..9e2d9a5cf5050a526527cb4f72b312030ab4805b 100644 (file)
@@ -173,8 +173,7 @@ lower_clip_vs(nir_function_impl *impl, unsigned ucp_enables,
 
    for (int plane = 0; plane < MAX_CLIP_PLANES; plane++) {
       if (ucp_enables & (1 << plane)) {
-         nir_ssa_def *ucp =
-            nir_load_system_value(&b, nir_intrinsic_load_user_clip_plane, plane);
+         nir_ssa_def *ucp = nir_load_user_clip_plane(&b, plane);
 
          /* calculate clipdist[plane] - dot(ucp, cv): */
          clipdist[plane] = nir_fdot4(&b, ucp, cv);
index b6f3529c766f49fa11ce1141180be6eb2c1ec7b7..74f4d2a970153848be8d55051eed06ce015660a3 100644 (file)
@@ -57,8 +57,7 @@ update_fragcoord(nir_builder *b, nir_intrinsic_instr *intr,
    if (!for_sample_shading) {
       wpos = nir_fadd(b, wpos, nir_imm_vec4(b, 0.5f, 0.5f, 0.0f, 0.0f));
    } else {
-      nir_ssa_def *spos =
-         nir_load_system_value(b, nir_intrinsic_load_sample_pos, 0);
+      nir_ssa_def *spos = nir_load_sample_pos(b);
 
       wpos = nir_fadd(b, wpos,
                       nir_vec4(b,
index 97e1f48936a354ad9baaedbce4edcb57e2ad3262..655e58449553136d9bd93e9f2b3182059e450b45 100644 (file)
@@ -61,8 +61,7 @@ try_lower_input_load(nir_function_impl *impl, nir_intrinsic_instr *load)
    nir_ssa_def *offset = nir_ssa_for_src(&b, load->src[1], 2);
    nir_ssa_def *pos = nir_iadd(&b, frag_coord, offset);
 
-   nir_ssa_def *layer =
-      nir_load_system_value(&b, nir_intrinsic_load_layer_id, 0);
+   nir_ssa_def *layer = nir_load_layer_id(&b);
    nir_ssa_def *coord =
       nir_vec3(&b, nir_channel(&b, pos, 0), nir_channel(&b, pos, 1), layer);