Skip to content

Commit f133aec

Browse files
committed
rename variables
1 parent 719bb94 commit f133aec

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,13 @@ constexpr vector<T, N> smoothstep_vec_impl(vector<T, N> Min, vector<T, N> Max,
101101
#endif
102102
}
103103

104-
template <typename T>
105-
constexpr vector<T, 4> lit_impl(T N_dot_l, T N_dot_h, T M) {
106-
bool Cond1 = N_dot_l < 0;
107-
T ClampedP1 = select<T>(Cond1, 0, N_dot_l);
108-
vector<T, 4> Result = {1, ClampedP1, 0, 1};
109-
bool CombinedCond = or (Cond1, (N_dot_h < 0));
110-
T LogP2 = log(N_dot_h);
111-
T Exp = exp(LogP2 * M);
112-
Result[2] = select<T>(CombinedCond, 0, Exp);
104+
template <typename T> constexpr vector<T, 4> lit_impl(T NDotL, T NDotH, T M) {
105+
bool DiffuseCond = NDotL < 0;
106+
T Diffuse = select<T>(DiffuseCond, 0, NDotL);
107+
vector<T, 4> Result = {1, Diffuse, 0, 1};
108+
bool SpecularCond = or (DiffuseCond, (NDotH < 0));
109+
T SpecularExp = exp(log(NDotH) * M);
110+
Result[2] = select<T>(SpecularCond, 0, SpecularExp);
113111
return Result;
114112
}
115113

clang/lib/Headers/hlsl/hlsl_intrinsics.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ const inline float length(__detail::HLSL_FIXED_VECTOR<float, N> X) {
257257
// lit builtins
258258
//===----------------------------------------------------------------------===//
259259

260-
/// \fn vector<T, 4> lit(T x, T y)
260+
/// \fn vector<T, 4> lit(T NDotL, T NDotH, T M)
261261
/// \brief Returns a lighting coefficient vector.
262-
/// \param N_dot_l The dot product of the normalized surface normal and the
262+
/// \param NDotL The dot product of the normalized surface normal and the
263263
/// light vector.
264-
/// \param N_dot_h The dot product of the half-angle vector and the surface
264+
/// \param NDotH The dot product of the half-angle vector and the surface
265265
/// normal.
266266
/// \param M A specular exponent.
267267
///
@@ -271,17 +271,17 @@ const inline float length(__detail::HLSL_FIXED_VECTOR<float, N> X) {
271271
template <typename T>
272272
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
273273
const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
274-
__detail::is_same<half, T>::value,
275-
vector<T, 4>> lit(T N_dot_l, T N_dot_h, T M) {
276-
return __detail::lit_impl(N_dot_l, N_dot_h, M);
274+
__detail::is_same<half, T>::value,
275+
vector<T, 4>> lit(T NDotL, T NDotH, T M) {
276+
return __detail::lit_impl(NDotL, NDotH, M);
277277
}
278278

279279
template <typename T>
280280
const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
281281
__detail::is_same<float, T>::value,
282282
vector<T, 4>>
283-
lit(T N_dot_l, T N_dot_h, T M) {
284-
return __detail::lit_impl(N_dot_l, N_dot_h, M);
283+
lit(T NDotL, T NDotH, T M) {
284+
return __detail::lit_impl(NDotL, NDotH, M);
285285
}
286286

287287
//===----------------------------------------------------------------------===//

clang/test/CodeGenHLSL/builtins/lit.hlsl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -O1 -o - | FileCheck %s
33

44
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x half> @_Z13test_lit_halfDhDhDh(
5-
// CHECK-SAME: half noundef nofpclass(nan inf) [[N_DOT_L:%.*]], half noundef nofpclass(nan inf) [[N_DOT_H:%.*]], half noundef nofpclass(nan inf) [[M:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
5+
// CHECK-SAME: half noundef nofpclass(nan inf) [[NDOTL:%.*]], half noundef nofpclass(nan inf) [[NDOTH:%.*]], half noundef nofpclass(nan inf) [[M:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
66
// CHECK-NEXT: [[ENTRY:.*:]]
7-
// CHECK-NEXT: [[CMP_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half [[N_DOT_L]], 0xH0000
8-
// CHECK-NEXT: [[HLSL_SELECT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.maxnum.f16(half [[N_DOT_L]], half 0xH0000)
7+
// CHECK-NEXT: [[CMP_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half [[NDOTL]], 0xH0000
8+
// CHECK-NEXT: [[HLSL_SELECT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.maxnum.f16(half [[NDOTL]], half 0xH0000)
99
// CHECK-NEXT: [[VECINIT2_I:%.*]] = insertelement <4 x half> <half 0xH3C00, half poison, half poison, half 0xH3C00>, half [[HLSL_SELECT_I]], i64 1
10-
// CHECK-NEXT: [[CMP4_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half [[N_DOT_H]], 0xH0000
10+
// CHECK-NEXT: [[CMP4_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt half [[NDOTH]], 0xH0000
1111
// CHECK-NEXT: [[HLSL_OR_I:%.*]] = or i1 [[CMP_I]], [[CMP4_I]]
12-
// CHECK-NEXT: [[ELT_LOG_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.log.f16(half [[N_DOT_H]])
12+
// CHECK-NEXT: [[ELT_LOG_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.log.f16(half [[NDOTH]])
1313
// CHECK-NEXT: [[MUL_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn half [[ELT_LOG_I]], [[M]]
1414
// CHECK-NEXT: [[ELT_EXP_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn half @llvm.exp.f16(half [[MUL_I]])
1515
// CHECK-NEXT: [[HLSL_SELECT7_I:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[HLSL_OR_I]], half 0xH0000, half [[ELT_EXP_I]]
1616
// CHECK-NEXT: [[VECINS_I:%.*]] = insertelement <4 x half> [[VECINIT2_I]], half [[HLSL_SELECT7_I]], i64 2
1717
// CHECK-NEXT: ret <4 x half> [[VECINS_I]]
1818
//
19-
half4 test_lit_half(half N_dot_l, half N_dot_h, half M) { return lit(N_dot_l, N_dot_h, M); }
19+
half4 test_lit_half(half NDotL, half NDotH, half M) { return lit(NDotL, NDotH, M); }
2020

2121
// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> @_Z14test_lit_floatfff(
22-
// CHECK-SAME: float noundef nofpclass(nan inf) [[N_DOT_L:%.*]], float noundef nofpclass(nan inf) [[N_DOT_H:%.*]], float noundef nofpclass(nan inf) [[M:%.*]]) local_unnamed_addr #[[ATTR0]] {
22+
// CHECK-SAME: float noundef nofpclass(nan inf) [[NDOTL:%.*]], float noundef nofpclass(nan inf) [[NDOTH:%.*]], float noundef nofpclass(nan inf) [[M:%.*]]) local_unnamed_addr #[[ATTR0]] {
2323
// CHECK-NEXT: [[ENTRY:.*:]]
24-
// CHECK-NEXT: [[CMP_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt float [[N_DOT_L]], 0.000000e+00
25-
// CHECK-NEXT: [[HLSL_SELECT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.maxnum.f32(float [[N_DOT_L]], float 0.000000e+00)
24+
// CHECK-NEXT: [[CMP_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt float [[NDOTL]], 0.000000e+00
25+
// CHECK-NEXT: [[HLSL_SELECT_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.maxnum.f32(float [[NDOTL]], float 0.000000e+00)
2626
// CHECK-NEXT: [[VECINIT2_I:%.*]] = insertelement <4 x float> <float 1.000000e+00, float poison, float poison, float 1.000000e+00>, float [[HLSL_SELECT_I]], i64 1
27-
// CHECK-NEXT: [[CMP4_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt float [[N_DOT_H]], 0.000000e+00
27+
// CHECK-NEXT: [[CMP4_I:%.*]] = fcmp reassoc nnan ninf nsz arcp afn olt float [[NDOTH]], 0.000000e+00
2828
// CHECK-NEXT: [[HLSL_OR_I:%.*]] = or i1 [[CMP_I]], [[CMP4_I]]
29-
// CHECK-NEXT: [[ELT_LOG_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.log.f32(float [[N_DOT_H]])
29+
// CHECK-NEXT: [[ELT_LOG_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.log.f32(float [[NDOTH]])
3030
// CHECK-NEXT: [[MUL_I:%.*]] = fmul reassoc nnan ninf nsz arcp afn float [[ELT_LOG_I]], [[M]]
3131
// CHECK-NEXT: [[ELT_EXP_I:%.*]] = tail call reassoc nnan ninf nsz arcp afn float @llvm.exp.f32(float [[MUL_I]])
3232
// CHECK-NEXT: [[HLSL_SELECT7_I:%.*]] = select reassoc nnan ninf nsz arcp afn i1 [[HLSL_OR_I]], float 0.000000e+00, float [[ELT_EXP_I]]
3333
// CHECK-NEXT: [[VECINS_I:%.*]] = insertelement <4 x float> [[VECINIT2_I]], float [[HLSL_SELECT7_I]], i64 2
3434
// CHECK-NEXT: ret <4 x float> [[VECINS_I]]
3535
//
36-
float4 test_lit_float(float N_dot_l, float N_dot_h, float M) { return lit(N_dot_l, N_dot_h, M); }
36+
float4 test_lit_float(float NDotL, float NDotH, float M) { return lit(NDotL, NDotH, M); }

0 commit comments

Comments
 (0)