Skip to content

Implement the QuadReadAcrossY HLSL Function #99176

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

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

Implement the QuadReadAcrossY HLSL Function #99176

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

DirectX

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

SPIR-V

OpGroupNonUniformQuadSwap:

Description:

Swap the Value of the invocation within the
quad with another invocation in the quad using Direction.

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.

Direction is the kind of swap to perform.

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

Direction must come from a constant
instruction
.

The value returned in Result is the value provided to Value by
another invocation in the same quad scope instance. The invocation
providing this value is determined according to Direction.

A Direction of 0 indicates a horizontal swap;

  • Invocations with quad indices of 0 and 1 swap values
  • Invocations with quad indices of 2 and 3 swap values
    A Direction of 1 indicates a vertical swap;
  • Invocations with quad indices of 0 and 2 swap values
  • Invocations with quad indices of 1 and 3 swap values
    A Direction of 2 indicates a diagonal swap;
  • Invocations with quad indices of 0 and 3 swap values
  • Invocations with quad indices of 1 and 2 swap values

Direction must be one of the above values.

If an active invocation reads Value from an inactive invocation, the
resulting value is undefined.

Capability:
GroupNonUniformQuad

Missing before version 1.3.

Word Count Opcode Results Operands

6

366

<id>
Result Type

Result <id>

Scope <id>
Execution

<id>
Value

<id>
Direction

Test Case(s)

Example 1

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

export float4 fn(float4 p1) {
    return QuadReadAcrossY(p1);
}

Example 2

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

export uint4 fn(uint4 p1) {
    return QuadReadAcrossY(p1);
}

Example 3

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

export int4 fn(int4 p1) {
    return QuadReadAcrossY(p1);
}

HLSL:

Returns the specified source value read from the other lane in this quad in the Y direction.

Syntax

<type> QuadReadAcrossY(
   <type> localValue
);

Parameters

localValue

The requested type.

Return value

The specified source value. 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
@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 Ready 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: Ready
Development

No branches or pull requests

1 participant