Skip to content

Commit 7011ea0

Browse files
author
kevyuu
committed
Fix example 28 to use select instead of ternary_op
1 parent 3042409 commit 7011ea0

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

28_FFTBloom/app_resources/fft_convolve_ifft.hlsl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ struct PreloadedSecondAxisAccessor : PreloadedAccessorMirrorTradeBase
6868
// This one shows up a lot so we give it a name
6969
const bool oddThread = glsl::gl_SubgroupInvocationID() & 1u;
7070

71-
ternary_operator<complex_t<scalar_t> > ternaryOp;
72-
7371
// Since every two consecutive columns are stored as one packed column, we divide the index by 2 to get the index of that packed column
7472
const uint32_t firstIndex = workgroup::SubgroupContiguousIndex() / 2;
7573
int32_t paddedIndex = int32_t(firstIndex) - pushConstants.halfPadding;
@@ -93,17 +91,17 @@ struct PreloadedSecondAxisAccessor : PreloadedAccessorMirrorTradeBase
9391

9492
if (glsl::gl_WorkGroupID().x)
9593
{
96-
complex_t<scalar_t> lo = ternaryOp(oddThread, otherThreadLoOrHi, loOrHi);
97-
complex_t<scalar_t> hi = ternaryOp(oddThread, loOrHi, otherThreadLoOrHi);
94+
complex_t<scalar_t> lo = select(oddThread, otherThreadLoOrHi, loOrHi);
95+
complex_t<scalar_t> hi = select(oddThread, loOrHi, otherThreadLoOrHi);
9896
fft::unpack<scalar_t>(lo, hi);
9997

10098
// --------------------------------------------------- MIRROR PADDING -------------------------------------------------------------------------------------------
10199
#ifdef MIRROR_PADDING
102-
preloaded[localElementIndex] = ternaryOp(oddThread ^ invert, hi, lo);
100+
preloaded[localElementIndex] = select(oddThread ^ invert, hi, lo);
103101
// ----------------------------------------------------- ZERO PADDING -------------------------------------------------------------------------------------------
104102
#else
105103
const complex_t<scalar_t> Zero = { scalar_t(0), scalar_t(0) };
106-
preloaded[localElementIndex] = ternaryOp(invert, Zero, ternaryOp(oddThread, hi, lo));
104+
preloaded[localElementIndex] = select(invert, Zero, select(oddThread, hi, lo));
107105
#endif
108106
// ------------------------------------------------ END PADDING DIVERGENCE ----------------------------------------------------------------------------------------
109107
}
@@ -116,7 +114,7 @@ struct PreloadedSecondAxisAccessor : PreloadedAccessorMirrorTradeBase
116114
const complex_t<scalar_t> evenThreadLo = { loOrHi.real(), otherThreadLoOrHi.real() };
117115
// Odd thread writes `hi = Z1 + iN1`
118116
const complex_t<scalar_t> oddThreadHi = { otherThreadLoOrHi.imag(), loOrHi.imag() };
119-
preloaded[localElementIndex] = ternaryOp(oddThread ^ invert, oddThreadHi, evenThreadLo);
117+
preloaded[localElementIndex] = select(oddThread ^ invert, oddThreadHi, evenThreadLo);
120118
}
121119
paddedIndex += WorkgroupSize / 2;
122120
}

28_FFTBloom/app_resources/kernel_fft_second_axis.hlsl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ struct PreloadedSecondAxisAccessor : MultiChannelPreloadedAccessorMirrorTradeBas
4646
// This one shows up a lot so we give it a name
4747
const bool oddThread = glsl::gl_SubgroupInvocationID() & 1u;
4848

49-
ternary_operator<complex_t<scalar_t> > ternaryOp;
50-
5149
if (glsl::gl_WorkGroupID().x)
5250
{
5351
// Even thread must index a y corresponding to an even element of the previous FFT pass, and the odd thread must index its DFT Mirror
@@ -72,10 +70,10 @@ struct PreloadedSecondAxisAccessor : MultiChannelPreloadedAccessorMirrorTradeBas
7270
const vector <scalar_t, 2> loOrHiVector = vector <scalar_t, 2>(loOrHi.real(), loOrHi.imag());
7371
const vector <scalar_t, 2> otherThreadloOrHiVector = glsl::subgroupShuffleXor< vector <scalar_t, 2> >(loOrHiVector, 1u);
7472
const complex_t<scalar_t> otherThreadLoOrHi = { otherThreadloOrHiVector.x, otherThreadloOrHiVector.y };
75-
complex_t<scalar_t> lo = ternaryOp(oddThread, otherThreadLoOrHi, loOrHi);
76-
complex_t<scalar_t> hi = ternaryOp(oddThread, loOrHi, otherThreadLoOrHi);
73+
complex_t<scalar_t> lo = select(oddThread, otherThreadLoOrHi, loOrHi);
74+
complex_t<scalar_t> hi = select(oddThread, loOrHi, otherThreadLoOrHi);
7775
fft::unpack<scalar_t>(lo, hi);
78-
preloaded[channel][localElementIndex] = ternaryOp(oddThread, hi, lo);
76+
preloaded[channel][localElementIndex] = select(oddThread, hi, lo);
7977

8078
packedColumnIndex += WorkgroupSize / 2;
8179
}
@@ -112,7 +110,7 @@ struct PreloadedSecondAxisAccessor : MultiChannelPreloadedAccessorMirrorTradeBas
112110
const complex_t<scalar_t> evenThreadLo = { loOrHi.real(), otherThreadLoOrHi.real() };
113111
// Odd thread writes `hi = Z1 + iN1`
114112
const complex_t<scalar_t> oddThreadHi = { otherThreadLoOrHi.imag(), loOrHi.imag() };
115-
preloaded[channel][localElementIndex] = ternaryOp(oddThread, oddThreadHi, evenThreadLo);
113+
preloaded[channel][localElementIndex] = select(oddThread, oddThreadHi, evenThreadLo);
116114

117115
packedColumnIndex += WorkgroupSize / 2;
118116
}

0 commit comments

Comments
 (0)