[Mesa-dev] [PATCH] spirv/nir: Add support for OpAtomicLoad/Store
Jason Ekstrand
jason at jlekstrand.net
Tue Sep 6 16:50:46 UTC 2016
On Tue, Sep 6, 2016 at 9:16 AM, Lionel Landwerlin <llandwerlin at gmail.com>
wrote:
> Fixes new CTS tests :
>
> dEQP-VK.spirv_assembly.instruction.compute.opatomic.load
> dEQP-VK.spirv_assembly.instruction.compute.opatomic.store
>
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> Cc: Jason Ekstrand <jason.ekstrand at intel.com>
> ---
> src/compiler/spirv/spirv_to_nir.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/src/compiler/spirv/spirv_to_nir.c
> b/src/compiler/spirv/spirv_to_nir.c
> index fda38f9..104b74f 100644
> --- a/src/compiler/spirv/spirv_to_nir.c
> +++ b/src/compiler/spirv/spirv_to_nir.c
> @@ -1913,6 +1913,32 @@ vtn_handle_ssbo_or_shared_atomic(struct
> vtn_builder *b, SpvOp opcode,
> nir_builder_instr_insert(&b->nb, &atomic->instr);
> }
>
> +static void
> +vtn_handle_atomic_load_store(struct vtn_builder *b, bool load,
> + const uint32_t *w, unsigned count)
> +{
> + struct vtn_access_chain *chain =
> + load ?
> + vtn_value(b, w[3], vtn_value_type_access_chain)->access_chain :
> + vtn_value(b, w[1], vtn_value_type_access_chain)->access_chain;
> +
> + switch (chain->var->mode) {
> + case vtn_variable_mode_image:
> + case vtn_variable_mode_ssbo:
> + case vtn_variable_mode_ubo:
> + if (load) {
> + struct vtn_value *val = vtn_push_value(b, w[2],
> vtn_value_type_ssa);
> + val->ssa = vtn_variable_load(b, chain);
> + } else {
> + struct vtn_ssa_value *src = vtn_ssa_value(b, w[4]);
> + vtn_variable_store(b, src, chain);
>
This may work for UBOs and SSBOs but it will not work for images. They
need to go through the image load store paths.
> + }
> + break;
> + default:
> + unreachable("invalid block variable");
> + }
> +}
> +
> static nir_alu_instr *
> create_vec(nir_shader *shader, unsigned num_components, unsigned bit_size)
> {
> @@ -2649,6 +2675,13 @@ vtn_handle_body_instruction(struct vtn_builder *b,
> SpvOp opcode,
> vtn_handle_variables(b, opcode, w, count);
> break;
>
> + case SpvOpAtomicLoad:
> + vtn_handle_atomic_load_store(b, true, w, count);
> + break;
> + case SpvOpAtomicStore:
> + vtn_handle_atomic_load_store(b, false, w, count);
> + break;
> +
> case SpvOpFunctionCall:
> vtn_handle_function_call(b, opcode, w, count);
> break;
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160906/e885df61/attachment.html>
More information about the mesa-dev
mailing list