-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[HLSL] Implement the dst HLSL Function #133828
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
Changes from 17 commits
3a45246
4cde5a5
0b82759
464aee1
cd53a27
bd44eaa
b31595b
5b4157a
93f8f19
6073386
312817d
1e3a68c
b164fc1
6ca58ec
57517c3
60eddc7
30ab473
7f0a5c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,6 +190,32 @@ const inline float dot2add(half2 A, half2 B, float C) { | |
| return __detail::dot2add_impl(A, B, C); | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
metkarpoonam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // dst builtins | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| /// \fn fvector dst(fvector, fvector) | ||
farzonl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// \brief Calculates a distance vector. | ||
| /// \param Src0 [in] The first vector contains the squared distance represented | ||
| /// as {_, d*d, d*d, _} | ||
farzonl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// \param Src1 [in] The second vector contains the reciprocal distance | ||
| /// represented as {_, 1/d, _, 1/d} | ||
farzonl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// | ||
| /// Return the computed distance vector contain {1, d, d*d, 1/d} | ||
|
||
|
|
||
| _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2) | ||
| const inline half4 dst(half4 Src0, half4 Src1) { | ||
| return __detail::dst_impl(Src0, Src1); | ||
| } | ||
|
|
||
| const inline float4 dst(float4 Src0, float4 Src1) { | ||
| return __detail::dst_impl(Src0, Src1); | ||
| } | ||
|
|
||
| const inline double4 dst(double4 Src0, double4 Src1) { | ||
| return __detail::dst_impl(Src0, Src1); | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // fmod builtins | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.2-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s | ||
|
|
||
|
|
||
| // CHECK-LABEL: define {{.*}} <4 x float> @{{[A-Za-z1-9_]+}}dst_impl{{[A-Za-z1-9_]*}}( | ||
| // CHECK-SAME: <4 x float> {{[A-Za-z )(]*}} [[P:%.*]], <4 x float> {{[A-Za-z )(]*}} [[Q:%.*]]) #[[ATTR0:[0-9]+]] { | ||
| // CHECK: [[VECEXT:%.*]] = extractelement <4 x float> [[PADDR:%.*]], i32 1 | ||
| // CHECK: [[VECEXT1:%.*]] = extractelement <4 x float> [[QADDR:%.*]], i32 1 | ||
| // CHECK: [[MULRES:%.*]] = fmul {{[A-Za-z ]*}} float [[VECEXT]], [[VECEXT1]] | ||
| // CHECK: [[VECINIT:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float poison>, float [[MULRES]], i32 1 | ||
| // CHECK: [[VECINIT2:%.*]] = extractelement <4 x float> [[PADDR2:%.*]], i32 2 | ||
| // CHECK: [[VECINIT3:%.*]] = insertelement <4 x float> [[VECINIT]], float [[VECINIT2]], i32 2 | ||
| // CHECK: [[VECINIT4:%.*]] = extractelement <4 x float> [[QADDR3:%.*]], i32 3 | ||
farzonl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // CHECK: [[VECINIT5:%.*]] = insertelement <4 x float> [[VECINIT3]], float [[VECINIT4]], i32 3 | ||
| // CHECK-NEXT: store <4 x float> [[VECINIT5]], ptr [[DEST:%.*]], align 16 | ||
| // CHECK-NEXT: [[RES:%.*]] = load <4 x float>, ptr [[DEST]], align 16 | ||
| // CHECK-NEXT: ret <4 x float> [[RES]] | ||
| float4 dstWithFloat(float4 p1, float4 p2) | ||
| { | ||
| return dst(p1, p2); | ||
| } | ||
|
|
||
| // CHECK-LABEL: define {{.*}} <4 x half> @{{[A-Za-z1-9_]+}}dst_impl{{[A-Za-z1-9_]*}}( | ||
| // CHECK-SAME: <4 x half> {{[A-Za-z )(]*}} [[P:%.*]], <4 x half> {{[A-Za-z )(]*}} [[Q:%.*]]) #[[ATTR0]] { | ||
| // CHECK: [[VECEXT:%.*]] = extractelement <4 x half> [[PADDR:%.*]], i32 1 | ||
| // CHECK: [[VECEXT1:%.*]] = extractelement <4 x half> [[QADDR:%.*]], i32 1 | ||
| // CHECK: [[MULRES:%.*]] = fmul {{[A-Za-z ]*}} half [[VECEXT]], [[VECEXT1]] | ||
| // CHECK: [[VECINIT:%.*]] = insertelement <4 x half> <half 0xH3C00, half poison, half poison, half poison>, half [[MULRES]], i32 1 | ||
| // CHECK: [[VECINIT2:%.*]] = extractelement <4 x half> [[PADDR2:%.*]], i32 2 | ||
| // CHECK: [[VECINIT3:%.*]] = insertelement <4 x half> [[VECINIT]], half [[VECINIT2]], i32 2 | ||
| // CHECK: [[VECINIT4:%.*]] = extractelement <4 x half> [[QADDR3:%.*]], i32 3 | ||
| // CHECK: [[VECINIT5:%.*]] = insertelement <4 x half> [[VECINIT3]], half [[VECINIT4]], i32 3 | ||
| // CHECK-NEXT: store <4 x half> [[VECINIT5]], ptr [[DEST:%.*]], align 8 | ||
| // CHECK-NEXT: [[RES:%.*]] = load <4 x half>, ptr [[DEST]], align 8 | ||
| // CHECK-NEXT: ret <4 x half> [[RES]] | ||
| half4 dstwithHalf(half4 p1, half4 p2) | ||
| { | ||
| return dst(p1, p2); | ||
| } | ||
|
|
||
| // CHECK-LABEL: define {{.*}} <4 x double> @{{[A-Za-z1-9_]+}}dst_impl{{[A-Za-z1-9_]*}}( | ||
| // CHECK-SAME: <4 x double> {{[A-Za-z )(]*}} [[P:%.*]], <4 x double> {{[A-Za-z )(]*}} [[Q:%.*]]) #[[ATTR0:[0-9]+]] { | ||
| // CHECK: [[VECEXT:%.*]] = extractelement <4 x double> [[PADDR:%.*]], i32 1 | ||
| // CHECK: [[VECEXT1:%.*]] = extractelement <4 x double> [[QADDR:%.*]], i32 1 | ||
| // CHECK: [[MULRES:%.*]] = fmul {{[A-Za-z ]*}} double [[VECEXT]], [[VECEXT1]] | ||
| // CHECK: [[VECINIT:%.*]] = insertelement <4 x double> <double 1.000000e+00, double poison, double poison, double poison>, double [[MULRES]], i32 1 | ||
| // CHECK: [[VECINIT2:%.*]] = extractelement <4 x double> [[PADDR2:%.*]], i32 2 | ||
| // CHECK: [[VECINIT3:%.*]] = insertelement <4 x double> [[VECINIT]], double [[VECINIT2]], i32 2 | ||
| // CHECK: [[VECINIT4:%.*]] = extractelement <4 x double> [[QADDR3:%.*]], i32 3 | ||
| // CHECK: [[VECINIT5:%.*]] = insertelement <4 x double> [[VECINIT3]], double [[VECINIT4]], i32 3 | ||
| // CHECK-NEXT: store <4 x double> [[VECINIT5]], ptr [[DEST:%.*]], align 32 | ||
| // CHECK-NEXT: [[RES:%.*]] = load <4 x double>, ptr [[DEST]], align 32 | ||
| // CHECK-NEXT: ret <4 x double> [[RES]] | ||
| double4 dstWithDouble(double4 p1, double4 p2) | ||
| { | ||
| return dst(p1, p2); | ||
| } | ||
farzonl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.