<div dir="ltr"><div dir="ltr"><div>There's a MR out to fix this:</div><div><br></div><div><a href="https://gitlab.freedesktop.org/mesa/mesa/merge_requests/478/diffs">https://gitlab.freedesktop.org/mesa/mesa/merge_requests/478/diffs</a><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 19, 2019 at 5:32 AM Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This commit breaks some CTS with RADV (eg. <br>
dEQP-VK.ssbo.phys.layout.single_basic_type.std430.bvec2) and it <br>
introduces one compiler warning (minor stuff).<br>
<br>
Is the Rb tag missing too?<br>
<br>
Thanks!<br>
<br>
On 3/19/19 5:57 AM, GitLab Mirror wrote:<br>
> Module: Mesa<br>
> Branch: master<br>
> Commit: c95afe56a8033a87dca71cc93191d448c2981cf7<br>
> URL: <a href="http://cgit.freedesktop.org/mesa/mesa/commit/?id=c95afe56a8033a87dca71cc93191d448c2981cf7" rel="noreferrer" target="_blank">http://cgit.freedesktop.org/mesa/mesa/commit/?id=c95afe56a8033a87dca71cc93191d448c2981cf7</a><br>
><br>
> Author: Karol Herbst <<a href="mailto:kherbst@redhat.com" target="_blank">kherbst@redhat.com</a>><br>
> Date: Tue Nov 6 12:06:08 2018 +0100<br>
><br>
> nir/spirv: handle kernel function parameters<br>
><br>
> the idea here is to generate an entry point stub function wrapping around the<br>
> actual kernel function and turn all parameters into shader inputs with byte<br>
> addressing instead of vec4.<br>
><br>
> This gives us several advantages:<br>
> 1. calling kernel functions doesn't differ from calling any other function<br>
> 2. CL inputs match uniforms in most ways and we can just take advantage of most<br>
> of nir_lower_io<br>
><br>
> v2: move code into a seperate function<br>
> v3: verify the entry point got a name<br>
> fix minor typo<br>
> v4: make vtn_emit_kernel_entry_point_wrapper take the old entry point as an arg<br>
><br>
> Signed-off-by: Karol Herbst <<a href="mailto:kherbst@redhat.com" target="_blank">kherbst@redhat.com</a>><br>
><br>
> ---<br>
><br>
> src/compiler/spirv/spirv_to_nir.c | 66 +++++++++++++++++++++++++++++++++++++++<br>
> 1 file changed, 66 insertions(+)<br>
><br>
> diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c<br>
> index 5becd3418da..df5bba2c2a0 100644<br>
> --- a/src/compiler/spirv/spirv_to_nir.c<br>
> +++ b/src/compiler/spirv/spirv_to_nir.c<br>
> @@ -4453,6 +4453,68 @@ vtn_create_builder(const uint32_t *words, size_t word_count,<br>
> return NULL;<br>
> }<br>
> <br>
> +static nir_function *<br>
> +vtn_emit_kernel_entry_point_wrapper(struct vtn_builder *b,<br>
> + const nir_function *entry_point)<br>
> +{<br>
> + vtn_assert(entry_point == b->entry_point->func->impl->function);<br>
> + vtn_fail_if(!entry_point->name, "entry points are required to have a name");<br>
> + const char *func_name =<br>
> + ralloc_asprintf(b->shader, "__wrapped_%s", entry_point->name);<br>
> +<br>
> + /* we shouldn't have any inputs yet */<br>
> + vtn_assert(!entry_point->shader->num_inputs);<br>
> + vtn_assert(b->shader->info.stage == MESA_SHADER_KERNEL);<br>
> +<br>
> + nir_function *main_entry_point = nir_function_create(b->shader, func_name);<br>
> + main_entry_point->impl = nir_function_impl_create(main_entry_point);<br>
> + nir_builder_init(&b->nb, main_entry_point->impl);<br>
> + b->nb.cursor = nir_after_cf_list(&main_entry_point->impl->body);<br>
> + b->func_param_idx = 0;<br>
> +<br>
> + nir_call_instr *call = nir_call_instr_create(b->nb.shader, entry_point);<br>
> +<br>
> + for (unsigned i = 0; i < entry_point->num_params; ++i) {<br>
> + struct vtn_type *param_type = b->entry_point->func->type->params[i];<br>
> +<br>
> + /* consider all pointers to function memory to be parameters passed<br>
> + * by value<br>
> + */<br>
> + bool is_by_val = param_type->base_type == vtn_base_type_pointer &&<br>
> + param_type->storage_class == SpvStorageClassFunction;<br>
> +<br>
> + /* input variable */<br>
> + nir_variable *in_var = rzalloc(b->nb.shader, nir_variable);<br>
> + in_var->data.mode = nir_var_shader_in;<br>
> + in_var->data.read_only = true;<br>
> + in_var->data.location = i;<br>
> +<br>
> + if (is_by_val)<br>
> + in_var->type = param_type->deref->type;<br>
> + else<br>
> + in_var->type = param_type->type;<br>
> +<br>
> + nir_shader_add_variable(b->nb.shader, in_var);<br>
> + b->nb.shader->num_inputs++;<br>
> +<br>
> + /* we have to copy the entire variable into function memory */<br>
> + if (is_by_val) {<br>
> + nir_variable *copy_var =<br>
> + nir_local_variable_create(main_entry_point->impl, in_var->type,<br>
> + "copy_in");<br>
> + nir_copy_var(&b->nb, copy_var, in_var);<br>
> + call->params[i] =<br>
> + nir_src_for_ssa(&nir_build_deref_var(&b->nb, copy_var)->dest.ssa);<br>
> + } else {<br>
> + call->params[i] = nir_src_for_ssa(nir_load_var(&b->nb, in_var));<br>
> + }<br>
> + }<br>
> +<br>
> + nir_builder_instr_insert(&b->nb, &call->instr);<br>
> +<br>
> + return main_entry_point;<br>
> +}<br>
> +<br>
> nir_function *<br>
> spirv_to_nir(const uint32_t *words, size_t word_count,<br>
> struct nir_spirv_specialization *spec, unsigned num_spec,<br>
> @@ -4542,6 +4604,10 @@ spirv_to_nir(const uint32_t *words, size_t word_count,<br>
> nir_function *entry_point = b->entry_point->func->impl->function;<br>
> vtn_assert(entry_point);<br>
> <br>
> + /* post process entry_points with input params */<br>
> + if (entry_point->num_params && b->shader->info.stage == MESA_SHADER_KERNEL)<br>
> + entry_point = vtn_emit_kernel_entry_point_wrapper(b, entry_point);<br>
> +<br>
> entry_point->is_entrypoint = true;<br>
> <br>
> /* When multiple shader stages exist in the same SPIR-V module, we<br>
><br>
> _______________________________________________<br>
> mesa-commit mailing list<br>
> <a href="mailto:mesa-commit@lists.freedesktop.org" target="_blank">mesa-commit@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-commit" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-commit</a><br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote></div>