Skip to content

Implement the DeviceMemoryBarrier HLSL Function #99105

Open
@farzonl

Description

@farzonl
  • Implement DeviceMemoryBarrier clang builtin,
  • Link DeviceMemoryBarrier clang builtin with hlsl_intrinsics.h
  • Add sema checks for DeviceMemoryBarrier to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for DeviceMemoryBarrier to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/DeviceMemoryBarrier.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/DeviceMemoryBarrier-errors.hlsl
  • Create the int_dx_DeviceMemoryBarrier intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_DeviceMemoryBarrier to 80 in DXIL.td
  • Create the DeviceMemoryBarrier.ll and DeviceMemoryBarrier_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_DeviceMemoryBarrier intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the DeviceMemoryBarrier lowering and map it to int_spv_DeviceMemoryBarrier in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/DeviceMemoryBarrier.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 DeviceMemoryBarrier_test.hlsl -T lib_6_8 -enable-16bit-types -O0

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

HLSL:

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

Syntax

void DeviceMemoryBarrier(void);

Parameters

This function has no parameters.

Return value

This function does not return a value.

Remarks

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 x

 

See also

Intrinsic Functions

Shader Model 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions