Skip to content

Implement the WaveActiveAllTrue HLSL Function #99161

@farzonl

Description

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

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
114 WaveAllTrue 6.0 ('library', 'compute', 'amplification', 'mesh', 'pixel', 'vertex', 'hull', 'domain', 'geometry', 'raygeneration', 'intersection', 'anyhit', 'closesthit', 'miss', 'callable', 'node')

SPIR-V

OpGroupNonUniformAll:

Description:

Evaluates a predicate for all active invocations in the group,
resulting in true if predicate evaluates to true for all active
invocations in the group, otherwise the result is
false.

Result Type must be a Boolean type.

Execution is a Scope that identifies the group of
invocations affected by this command. It must be Subgroup.

Predicate must be a Boolean type.

Capability:
GroupNonUniformVote

Missing before version 1.3.

Word Count Opcode Results Operands

5

334

<id>
Result Type

Result <id>

Scope <id>
Execution

<id>
Predicate

Test Case(s)

Example 1

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

export bool fn(bool p1) {
    return WaveActiveAllTrue(p1);
}

HLSL:

Returns true if the expression is true in all active lanes in the current wave.

Syntax

bool WaveActiveAllTrue(
   bool expr
);

Parameters

expr

The boolean expression to evaluate.

Return value

True if the expression is true in all lanes.

Remarks

This function is supported from shader model 6.0 in all shader stages.

 

See also

Overview of Shader Model 6

Shader Model 6

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportbackend:DirectXbackend:SPIR-Vbot:HLSLclang:codegenIR generation bugs: mangling, exceptions, etc.metaissueIssue to collect references to a group of similar or related issues.

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions