llvm-project
llvm-project copied to clipboard
Implement the `pack_clamp_s8` HLSL Function
- [ ] Implement
pack_clamp_s8clang builtin, - [ ] Link
pack_clamp_s8clang builtin withhlsl_intrinsics.h - [ ] Add sema checks for
pack_clamp_s8toCheckHLSLBuiltinFunctionCallinSemaChecking.cpp - [ ] Add codegen for
pack_clamp_s8toEmitHLSLBuiltinExprinCGBuiltin.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_s8intrinsic inIntrinsicsDirectX.td - [ ] Create the
DXILOpMappingofint_dx_pack_clamp_s8to220inDXIL.td - [ ] Create the
pack_clamp_s8.llandpack_clamp_s8_errors.lltests inllvm/test/CodeGen/DirectX/ - [ ] Create the
int_spv_pack_clamp_s8intrinsic inIntrinsicsSPIRV.td - [ ] In SPIRVInstructionSelector.cpp create the
pack_clamp_s8lowering and map it toint_spv_pack_clamp_s8inSPIRVInstructionSelector::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> |
<id> |
<id> |
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
I don't have the permissions to self assign this, but I can pick it up along with the other pack and unpack tasks.