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 QuadReadAcrossDiagonal HLSL Function #99177

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

Implement the QuadReadAcrossDiagonal HLSL Function #99177

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

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

Example 2

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

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

Example 3

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

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

HLSL:

Returns the specified local value which is read from the diagonally opposite lane in this quad.

Syntax

<type> QuadReadAcrossDiagonal(
   <type> localValue
);

Parameters

localValue

The requested type.

Return value

The specified local value which is read from the diagonally opposite lane in this quad.

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