Description
- implement
reflect
in thehlsl_intrinsics.h
Implement reflect spirv target builtin inclang/include/clang/Basic/BuiltinsSPIRV.td
Add a spirv fast path inhlsl_detail.h
in the form
#if (__has_builtin(__builtin_spirv_reflect))
return __builtin_spirv_reflect(...);
#else
return ...; // regular behavior
#endif
- Add codegen for spirv
reflect
builtin toEmitSPIRVBuiltinExpr
inCGBuiltin.cpp
Add HLSL codegen tests toclang/test/CodeGenHLSL/builtins/reflect.hlsl
Add SPIRV builtin codegen tests toclang/test/CodeGenSPIRV/Builtins/reflect.c
Add sema tests toclang/test/SemaHLSL/BuiltIns/reflect-errors.hlsl
Add spirv sema tests toclang/test/CodeGenSPIRV/Builtins/reflect-errors.c
Create theint_spv_reflect
intrinsic inIntrinsicsSPIRV.td
In SPIRVInstructionSelector.cpp create thereflect
lowering and map it toint_spv_reflect
inSPIRVInstructionSelector::selectIntrinsic
.Create SPIR-V backend test case inllvm/test/CodeGen/SPIRV/hlsl-intrinsics/reflect.ll
Create SPIR-V backend test case inllvm/test/CodeGen/SPIRV/opencl/reflect.ll
DirectX
There were no DXIL opcodes found for reflect
. That should make it easy to do entirely in the frontend.
In DXC it was done via emitting llvmir. We do not want to do that in upstream.
SPIR-V
Reflect:
Description:
Reflect
For the incident vector I and surface orientation N, the result is
the reflection direction:
I - 2 * dot(N, I) * N
N must already be normalized in order to achieve the desired result.
The operands must all be a scalar or vector whose component type is
floating-point.
Result Type and the type of all operands must be the same type.
Number | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
---|---|---|---|---|
71 |
<id> |
<id> |
Test Case(s)
Example 1
//dxc reflect_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float4 p1, float4 p2) {
return reflect(p1, p2);
}
HLSL:
Returns a reflection vector using an incident ray and a surface normal.
ret reflect(i, n) |
---|
Parameters
Item | Description |
---|---|
i |
[in] A floating-point, incident vector. |
n |
[in] A floating-point, normal vector. |
Return Value
A floating-point, reflection vector.
Remarks
This function calculates the reflection vector using the following formula: v = i - 2 * n * dot(i n) .
Type Description
Name | Template Type | Component Type | Size |
---|---|---|---|
i | vector | float | any |
n | vector | float | same dimension(s) as input i |
ret | vector | float | same dimension(s) as input i |
Minimum Shader Model
This function is supported in the following shader models.
Shader Model | Supported |
---|---|
Shader Model 1 (DirectX HLSL) and higher shader models | yes |
See also
Metadata
Metadata
Assignees
Type
Projects
Status
Activity
jerryyiransun commentedon Dec 6, 2024
Hello, is anyone currently working on this issue? If not, I’d like to take it on.
farzonl commentedon Dec 6, 2024
@jerryyiransun we are redesigning how we are going to do some of these intrinsics to be header only implementations. I’m on vacation right now. Give me two weeks and i’ll rewrite this ticket to match our expectations.
jerryyiransun commentedon Dec 6, 2024
@farzonl Thank you for the update, I'll wait for the updated ticket and proceed based on the revised expectations. Enjoy your vacation!
19 remaining items