-
Notifications
You must be signed in to change notification settings - Fork 13k
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 clip
HLSL Function
#99093
Comments
Edit: Updated link with Vulkan 1.1 and 1.3 output. |
I can work on this |
@llvm/issue-subscribers-clang-codegen Author: Farzon Lotfi (farzonl)
- [ ] Implement `clip` clang builtin,
- [ ] Link `clip` clang builtin with `hlsl_intrinsics.h`
- [ ] Add sema checks for `clip` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp`
- [ ] Add codegen for `clip` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/clip.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/clip-errors.hlsl`
- [ ] Create the `int_dx_clip` intrinsic in `IntrinsicsDirectX.td`
- [ ] Create the `DXILOpMapping` of `int_dx_clip` to `82` in `DXIL.td`
- [ ] Create the `clip.ll` and `clip_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
- [ ] Create the `int_spv_clip` intrinsic in `IntrinsicsSPIRV.td`
- [ ] In SPIRVInstructionSelector.cpp create the `clip` lowering and map it to `int_spv_clip` in `SPIRVInstructionSelector::selectIntrinsic`.
- [ ] Create SPIR-V backend test case in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/clip.ll`
DirectX
SPIR-VOpDemoteToHelperInvocation:Description:(OpDemoteToHelperInvocationEXT)** Demote this fragment shader invocation to a helper Unlike the OpTerminateInvocation After an invocation executes this instruction, any subsequent load of This instruction is only valid in the Fragment Execution Capability: Missing before version 1.6.
Test Case(s)Example 1//dxc clip_test.hlsl -T ps_6_8
RWBuffer<float4> Buf;
float4 main( ) : SV_Target {
float4 p1 = Buf[0];
clip(p1.a);
return p1;
} HLSL:Discards the current pixel if the specified value is less than zero.
Parameters
Return ValueNone. RemarksUse the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane. Also, use the clip function to test for alpha behavior, as shown in the following example:
Type Description
Minimum Shader ModelThis function is supported in the following shader models.
See also<dl> <dt> Intrinsic Functions (DirectX HLSL) |
@llvm/issue-subscribers-clang-frontend Author: Farzon Lotfi (farzonl)
- [ ] Implement `clip` clang builtin,
- [ ] Link `clip` clang builtin with `hlsl_intrinsics.h`
- [ ] Add sema checks for `clip` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp`
- [ ] Add codegen for `clip` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/clip.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/clip-errors.hlsl`
- [ ] Create the `int_dx_clip` intrinsic in `IntrinsicsDirectX.td`
- [ ] Create the `DXILOpMapping` of `int_dx_clip` to `82` in `DXIL.td`
- [ ] Create the `clip.ll` and `clip_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
- [ ] Create the `int_spv_clip` intrinsic in `IntrinsicsSPIRV.td`
- [ ] In SPIRVInstructionSelector.cpp create the `clip` lowering and map it to `int_spv_clip` in `SPIRVInstructionSelector::selectIntrinsic`.
- [ ] Create SPIR-V backend test case in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/clip.ll`
DirectX
SPIR-VOpDemoteToHelperInvocation:Description:(OpDemoteToHelperInvocationEXT)** Demote this fragment shader invocation to a helper Unlike the OpTerminateInvocation After an invocation executes this instruction, any subsequent load of This instruction is only valid in the Fragment Execution Capability: Missing before version 1.6.
Test Case(s)Example 1//dxc clip_test.hlsl -T ps_6_8
RWBuffer<float4> Buf;
float4 main( ) : SV_Target {
float4 p1 = Buf[0];
clip(p1.a);
return p1;
} HLSL:Discards the current pixel if the specified value is less than zero.
Parameters
Return ValueNone. RemarksUse the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane. Also, use the clip function to test for alpha behavior, as shown in the following example:
Type Description
Minimum Shader ModelThis function is supported in the following shader models.
See also<dl> <dt> Intrinsic Functions (DirectX HLSL) |
clip
clang builtin,clip
clang builtin withhlsl_intrinsics.h
clip
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
clip
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
clang/test/CodeGenHLSL/builtins/clip.hlsl
clang/test/SemaHLSL/BuiltIns/clip-errors.hlsl
int_dx_clip
intrinsic inIntrinsicsDirectX.td
DXILOpMapping
ofint_dx_clip
to82
inDXIL.td
clip.ll
andclip_errors.ll
tests inllvm/test/CodeGen/DirectX/
int_spv_clip
intrinsic inIntrinsicsSPIRV.td
clip
lowering and map it toint_spv_clip
inSPIRVInstructionSelector::selectIntrinsic
.llvm/test/CodeGen/SPIRV/hlsl-intrinsics/clip.ll
DirectX
SPIR-V
OpDemoteToHelperInvocation:
Description:
(OpDemoteToHelperInvocationEXT)**
Demote this fragment shader invocation to a helper
invocation. Any stores to memory after this instruction are suppressed
and the fragment does not write outputs to the framebuffer.
Unlike the OpTerminateInvocation
instruction, this does not necessarily terminate the invocation which
might be needed for derivative calculations. It is not considered a flow
control instruction (flow control does not become non-uniform) and does
not terminate the block. The implementation may terminate helper
invocations before the end of the shader as an optimization, but doing
so must not affect derivative calculations and does not make control
flow non-uniform.
After an invocation executes this instruction, any subsequent load of
HelperInvocation within that invocation will load an undefined value
unless the HelperInvocation built-in variable is
decorated with Volatile or the load included
Volatile in its Memory Operands
This instruction is only valid in the Fragment Execution
Model.
Capability:
DemoteToHelperInvocation
Missing before version 1.6.
Test Case(s)
Example 1
HLSL:
Discards the current pixel if the specified value is less than zero.
Parameters
Return Value
None.
Remarks
Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.
Also, use the clip function to test for alpha behavior, as shown in the following example:
Type Description
Minimum Shader Model
This function is supported in the following shader models.
See also
Intrinsic Functions (DirectX HLSL)
The text was updated successfully, but these errors were encountered: