[Mesa-dev] [PATCH 2/3] nir: Add new barrier functions for compute shaders

Francisco Jerez currojerez at riseup.net
Wed Nov 4 08:06:06 PST 2015


Jordan Justen <jordan.l.justen at intel.com> writes:

> When these functions are called in glsl-ir, we create a corresponding
> nir intrinsic function call.
>
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

> ---
>  src/glsl/nir/glsl_to_nir.cpp  | 15 +++++++++++++++
>  src/glsl/nir/nir_intrinsics.h | 11 +++++++++++
>  2 files changed, 26 insertions(+)
>
> diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
> index 57aba5b..facb9fa 100644
> --- a/src/glsl/nir/glsl_to_nir.cpp
> +++ b/src/glsl/nir/glsl_to_nir.cpp
> @@ -719,6 +719,16 @@ nir_visitor::visit(ir_call *ir)
>           op = nir_intrinsic_ssbo_atomic_comp_swap;
>        } else if (strcmp(ir->callee_name(), "__intrinsic_shader_clock") == 0) {
>           op = nir_intrinsic_shader_clock;
> +      } else if (strcmp(ir->callee_name(), "__intrinsic_group_memory_barrier") == 0) {
> +         op = nir_intrinsic_group_memory_barrier;
> +      } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_atomic_counter") == 0) {
> +         op = nir_intrinsic_memory_barrier_atomic_counter;
> +      } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_buffer") == 0) {
> +         op = nir_intrinsic_memory_barrier_buffer;
> +      } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_image") == 0) {
> +         op = nir_intrinsic_memory_barrier_image;
> +      } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_shared") == 0) {
> +         op = nir_intrinsic_memory_barrier_shared;
>        } else {
>           unreachable("not reached");
>        }
> @@ -821,6 +831,11 @@ nir_visitor::visit(ir_call *ir)
>           break;
>        }
>        case nir_intrinsic_memory_barrier:
> +      case nir_intrinsic_group_memory_barrier:
> +      case nir_intrinsic_memory_barrier_atomic_counter:
> +      case nir_intrinsic_memory_barrier_buffer:
> +      case nir_intrinsic_memory_barrier_image:
> +      case nir_intrinsic_memory_barrier_shared:
>           nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr);
>           break;
>        case nir_intrinsic_shader_clock:
> diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h
> index c2b6fe7..36fb286 100644
> --- a/src/glsl/nir/nir_intrinsics.h
> +++ b/src/glsl/nir/nir_intrinsics.h
> @@ -91,6 +91,17 @@ BARRIER(memory_barrier)
>   */
>  INTRINSIC(shader_clock, 0, ARR(), true, 1, 0, 0, NIR_INTRINSIC_CAN_ELIMINATE)
>  
> +/*
> + * Memory barrier with semantics analogous to the compute shader
> + * groupMemoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(),
> + * memoryBarrierImage() and memoryBarrierShared() GLSL intrinsics.
> + */
> +BARRIER(group_memory_barrier)
> +BARRIER(memory_barrier_atomic_counter)
> +BARRIER(memory_barrier_buffer)
> +BARRIER(memory_barrier_image)
> +BARRIER(memory_barrier_shared)
> +
>  /** A conditional discard, with a single boolean source. */
>  INTRINSIC(discard_if, 1, ARR(1), false, 0, 0, 0, 0)
>  
> -- 
> 2.6.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20151104/ebeb4e2f/attachment-0001.sig>


More information about the mesa-dev mailing list