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 pack_clamp_s8 HLSL Function #99229

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

Implement the pack_clamp_s8 HLSL Function #99229

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

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
220 Pack4x8 6.6 ()

SPIR-V

SClamp:

Description:

SClamp

Result is min(max(x, minVal), maxVal), where x, minVal and
maxVal are interpreted as signed integers. Result is undefined if
minVal > maxVal.

Result Type and the type of the operands must both be integer scalar
or integer vector types. Result Type and operand types must have the
same number of components with the same component width. Results are
computed per component.

Number Operand 1 Operand 2 Operand 3 Operand 4

45

<id>
x

<id>
minVal

<id>
maxVal

Test Case(s)

Example 1

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

export int8_t4_packed fn(int4 p1) {
    return pack_clamp_s8(p1);
}

HLSL:

Syntax

p32i8 pack_clamp_s8(sint16or32_only<4> v);

Type Description

Name Template Type Component Type Size
ret scalar int8_t4_packed 1
v vector int or int16_t 4

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 6.6 and higher shader models yes

Shader Stages

See also

@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 Jan 21, 2025
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