Skip to content

Implement the AllMemoryBarrier HLSL Function #99076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
12 tasks
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 0 comments
Open
12 tasks
Tracked by #99235

Implement the AllMemoryBarrier HLSL Function #99076

farzonl opened this issue Jul 16, 2024 · 0 comments
Assignees
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.

Comments

@farzonl
Copy link
Member

farzonl commented Jul 16, 2024

  • Implement AllMemoryBarrier clang builtin,
  • Link AllMemoryBarrier clang builtin with hlsl_intrinsics.h
  • Add sema checks for AllMemoryBarrier to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for AllMemoryBarrier to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/AllMemoryBarrier.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/AllMemoryBarrier-errors.hlsl
  • Create the int_dx_AllMemoryBarrier intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_AllMemoryBarrier to 80 in DXIL.td
  • Create the AllMemoryBarrier.ll and AllMemoryBarrier_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_AllMemoryBarrier intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the AllMemoryBarrier lowering and map it to int_spv_AllMemoryBarrier in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/AllMemoryBarrier.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
80 Barrier 6.0 ()

SPIR-V

OpMemoryBarrier:

Description:

Control the order that memory accesses are observed.

Ensures that memory accesses issued before this instruction are observed
before memory accesses issued after this instruction. This control is
ensured only for memory accesses issued by this
invocation and observed by another invocation executing
within Memory scope. If the Vulkan memory model
is declared, this ordering only applies to memory accesses that use the
NonPrivatePointer memory operand or
NonPrivateTexel image operand.

Semantics declares what kind of memory is being controlled and what
kind of control to apply.

To execute both a memory barrier and a control barrier, see
OpControlBarrier.

Word Count Opcode Results Operands

3

225

Scope <id>
Memory

Memory Semantics <id>
Semantics

Test Case(s)

Example 1

//dxc AllMemoryBarrier_test.hlsl -T lib_6_8 -enable-16bit-types -O0

export void fn() {
    return AllMemoryBarrier();
}

HLSL:

Blocks execution of all threads in a group until all memory accesses have been completed.

Syntax

void AllMemoryBarrier(void);

Parameters

This function has no parameters.

Return value

This function does not return a value.

Remarks

A memory barrier guarantees that outstanding memory operations have completed. Threads are synchronized at GroupSync barriers. This may stall a thread or threads if memory operations are in progress.

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 5 and higher shader models yes

 

This function is supported in the following types of shaders:

Vertex Hull Domain Geometry Pixel Compute
x

 

See also

Intrinsic Functions

Shader Model 5

@farzonl farzonl added backend:DirectX backend:SPIR-V HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. bot:HLSL labels Jul 16, 2024
This was referenced Jul 16, 2024
Closed
Closed
@damyanp damyanp moved this to Ready in HLSL Support Oct 30, 2024
@damyanp damyanp moved this from Ready to Planning in HLSL Support Oct 30, 2024
@farzonl farzonl moved this from Designing to Planning in HLSL Support Nov 19, 2024
@farzonl farzonl moved this from Planning to Designing in HLSL Support Nov 19, 2024
@damyanp damyanp removed the status in HLSL Support Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Status: No status
Development

No branches or pull requests

1 participant