llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.24k stars 12.07k forks source link

Implement the `Barrier` HLSL Function #99234

Open farzonl opened 4 months ago

farzonl commented 4 months ago

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
244 BarrierByMemoryType 6.8 ()

SPIR-V

There is no support for Barrier when targeting SPIR-V.

Test Case(s)

Example 1

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

export void fn() {
    uint p1 = 1;
    uint p2 = 1;

    return Barrier(p1, p2);
}

Example 2

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

export void fn() {
    uint p1 = 1;
    uint p2 = 1;

    return Barrier(p1, p2);
}

HLSL:

Syntax

void Barrier(uint MemoryTypeFlags, uint SemanticFlags);
void Barrier(NodeRecordOrUAV o, uint SemanticFlags);

Type Description

Name Template Type Component Type Size
ret void void 0
MemoryTypeFlags scalar uint 1
SemanticFlags scalar uint 1

Type Description

Name Template Type Component Type Size
ret void void 0
o scalar 1
SemanticFlags scalar uint 1

Minimum Shader Model

This function is supported in the following shader models. Shader Model Supported
Shader Model 6.8 and higher shader models yes

Shader Stages

See also

farzonl commented 3 days ago

@adam-yang After last week's refinement we have considered that your Barrier ticket should cover all the cases: