From 9da8179a1e8c835749c6c97f4adc31d0428cae8e Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Thu, 18 Feb 2021 10:28:20 -0800 Subject: [PATCH] microsoft/clc: Let lower_vars_to_explicit_types fill kernel input driver_location Importantly, also run that before mucking with the variable list via image lowering, which removes and inserts variables, making the driver_location no longer line up with metadata. Fixes: ff05da7f ("microsoft: Add CLC frontend and kernel/compute support to DXIL converter") Reviewed-By: Bill Kristiansen Part-of: --- src/microsoft/clc/clc_compiler.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/microsoft/clc/clc_compiler.c b/src/microsoft/clc/clc_compiler.c index cae4b1d7fef..5042fc05d6b 100644 --- a/src/microsoft/clc/clc_compiler.c +++ b/src/microsoft/clc/clc_compiler.c @@ -1102,7 +1102,6 @@ clc_to_dxil(struct clc_context *ctx, unsigned size = glsl_get_cl_size(var->type); offset = align(offset, glsl_get_cl_alignment(var->type)); - var->data.driver_location = offset; metadata->args[i].offset = offset; metadata->args[i].size = size; @@ -1267,6 +1266,9 @@ clc_to_dxil(struct clc_context *ctx, NIR_PASS_V(nir, nir_opt_dce); NIR_PASS_V(nir, nir_opt_deref); + // For uniforms (kernel inputs), run this before adjusting variable list via image/sampler lowering + NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, nir_var_uniform, glsl_get_cl_type_size_align); + // Needs to come before lower_explicit_io NIR_PASS_V(nir, nir_lower_cl_images_to_tex); struct clc_image_lower_context image_lower_context = { metadata, &srv_id, &uav_id }; @@ -1280,7 +1282,7 @@ clc_to_dxil(struct clc_context *ctx, nir->scratch_size = 0; NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, - nir_var_mem_shared | nir_var_function_temp | nir_var_uniform | nir_var_mem_global | nir_var_mem_constant, + nir_var_mem_shared | nir_var_function_temp | nir_var_mem_global | nir_var_mem_constant, glsl_get_cl_type_size_align); NIR_PASS_V(nir, dxil_nir_lower_ubo_to_temp);