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 QuadReadLaneAt HLSL Function #99174

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

Implement the QuadReadLaneAt HLSL Function #99174

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 QuadReadLaneAt clang builtin,
  • Link QuadReadLaneAt clang builtin with hlsl_intrinsics.h
  • Add sema checks for QuadReadLaneAt to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for QuadReadLaneAt to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/QuadReadLaneAt.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/QuadReadLaneAt-errors.hlsl
  • Create the int_dx_QuadReadLaneAt intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_QuadReadLaneAt to 122 in DXIL.td
  • Create the QuadReadLaneAt.ll and QuadReadLaneAt_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_QuadReadLaneAt intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the QuadReadLaneAt lowering and map it to int_spv_QuadReadLaneAt in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/QuadReadLaneAt.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
122 QuadReadLaneAt 6.0 ('library', 'compute', 'amplification', 'mesh', 'pixel', 'node')

SPIR-V

OpGroupNonUniformQuadBroadcast:

Description:

Result is the Value of the invocation within the
quad with a quad index equal to Index.

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

Execution is a Scope, but has no effect on the
behavior of this instruction. It must be Subgroup.

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

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

Before version 1.5, Index must come from a constant
instruction
. Starting with version 1.5,
Index must be dynamically uniform.

If the value of Index is greater than or equal to 4, or refers to an
inactive invocation, the resulting value is undefined.

Capability:
GroupNonUniformQuad

Missing before version 1.3.

Word Count Opcode Results Operands

6

365

<id>
Result Type

Result <id>

Scope <id>
Execution

<id>
Value

<id>
Index

Test Case(s)

Example 1

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

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

Example 2

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

export uint4 fn(uint4 p1, uint p2) {
    return QuadReadLaneAt(p1, p2);
}

Example 3

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

export int4 fn(int4 p1, uint p2) {
    return QuadReadLaneAt(p1, p2);
}

HLSL:

Returns the specified source value from the lane identified by the lane ID within the current quad.

Syntax

<type> QuadReadLaneAt(
   <type> sourceValue,
   uint   quadLaneID  
);

Parameters

sourceValue

The requested type.

quadLaneID

The lane ID; this will be a value from 0 to 3.

Return value

The specified source value. The result of this function is uniform across the quad. If the source lane is inactive, the results are undefined.

Remarks

For more information on quads, refer to Overview of Shader Model 6.

This function is supported from shader model 6.0 only in pixel and compute shaders.

 

See also

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
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: No status
Development

No branches or pull requests

1 participant