Skip to content

Implement the WaveReadLaneAt HLSL Function #70104

Closed
@llvm-beanz

Description

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

DirectX

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

SPIR-V

OpGroupNonUniformShuffle:

Description:

Result is the Value of the invocation identified by the
id Id.

Result Type must be a scalar or vector of floating-point
type
, integer type, or Boolean
type
.

Execution is a Scope that identifies the group of
invocations affected by this command.

The type of Value must be the same as Result Type.

Id must be a scalar of integer type, whose Signedness
operand is 0.

The resulting value is undefined if Id is an inactive invocation, or
is greater than or equal to the size of the group.

Capability:
GroupNonUniformShuffle

Missing before version 1.3.

Word Count Opcode Results Operands

6

345

<id>
Result Type

Result <id>

Scope <id>
Execution

<id>
Value

<id>
Id

Test Case(s)

Example 1

//dxc WaveReadLaneAt_test.hlsl -T lib_6_8 -E fn -enable-16bit-types -spirv -fspv-target-env=universal1.5 -fcgl -O0

export float4 fn(float4 p1, uint p2) {
    return WaveReadLaneAt(p1, p2);
}

HLSL:

Returns the value of the expression for the given lane index within the specified wave.

Syntax

<type> WaveReadLaneAt(
   <type> expr,
   uint laneIndex
);

Parameters

expr

The expression to evaluate.

laneIndex

The index of the lane for which the expr result will be returned.

Return value

The resulting value is the result of expr. It will be uniform if laneIndex is uniform.

Remarks

If laneIndex is uniform, then this is effectively a broadcast operation; otherwise, it's a shuffle operation.

The result is undefined on a helper lane, or if the lane referred to by laneIndex is inactive or a helper lane.

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

See also

Activity

converted this from a draft issue on Oct 24, 2023
changed the title [-][HLSL] Implement `WaveReadLaneAt` intrinsic[/-] [+]Implement the `WaveReadLaneAt` HLSL Function[/+] on Jul 16, 2024
inbelic

inbelic commented on Sep 25, 2024

@inbelic
Contributor

Taking a look into this.

self-assigned this
on Sep 25, 2024
damyanp

damyanp commented on Oct 4, 2024

@damyanp
Contributor

Marking re-estimate this. Since this was originally refined, we have a different approach to implementing intrinsics and the way we've been estimating intrinsics has changed quite a bit.

moved this to Active in HLSL Supporton Oct 9, 2024
moved this from Active to Reviewing in HLSL Supporton Oct 10, 2024

14 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Closed

Milestone

No milestone

Development

Participants

@farzonl@damyanp@EugeneZelenko@llvm-beanz@inbelic

Issue actions

    Implement the `WaveReadLaneAt` HLSL Function · Issue #70104 · llvm/llvm-project