Skip to content
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

Implement the WaveActiveAllEqual HLSL Function #99162

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

Implement the WaveActiveAllEqual HLSL Function #99162

farzonl opened this issue Jul 16, 2024 · 0 comments
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 WaveActiveAllEqual clang builtin,
  • Link WaveActiveAllEqual clang builtin with hlsl_intrinsics.h
  • Add sema checks for WaveActiveAllEqual to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for WaveActiveAllEqual to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/WaveActiveAllEqual.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/WaveActiveAllEqual-errors.hlsl
  • Create the int_dx_WaveActiveAllEqual intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_WaveActiveAllEqual to 115 in DXIL.td
  • Create the WaveActiveAllEqual.ll and WaveActiveAllEqual_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_WaveActiveAllEqual intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the WaveActiveAllEqual lowering and map it to int_spv_WaveActiveAllEqual in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveActiveAllEqual.ll

DirectX

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

SPIR-V

OpGroupNonUniformAllEqual:

Description:

Evaluates a value for all active invocations in the group. The
result is true if Value is equal 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.

Value must be a scalar or vector of floating-point
type
, integer type, or Boolean
type
. The compare operation is based on this type, and if it
is a floating-point type, an ordered-and-equal compare is used.

Capability:
GroupNonUniformVote

Missing before version 1.3.

Word Count Opcode Results Operands

5

336

<id>
Result Type

Result <id>

Scope <id>
Execution

<id>
Value

Test Case(s)

Example 1

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

export bool4 fn(float4 p1) {
    return WaveActiveAllEqual(p1);
}

HLSL:

Returns true if the expression is the same for every active lane in the current wave (and thus uniform across it).

Syntax

<bool-type> WaveActiveAllEqual(
   <type> expr
);

Parameters

expr

The expression to evaluate.
<type> can be a basic scalar, vector, or matrix type.

Return value

Returns true for each component of expr that is the same for every active lane in the current wave.

<bool-type> will be a scalar, vector, or matrix of bool, matching the dimensionality of the input <type>.
For instance, an input <type> of matrix<float, 4, 3> will result in a return <bool-type> of matrix<bool, 4, 3>.

Remarks

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

 

See also

Overview of Shader Model 6

Shader Model 6

@farzonl farzonl added backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. labels Jul 16, 2024
@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
@damyanp damyanp moved this from Planning to Active in HLSL Support Nov 26, 2024
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: Active
Development

No branches or pull requests

1 participant