Skip to content

Commit 90d94ca

Browse files
committed
style: Reformat with clang-format 17 (modified PR 1761)
Signed-off-by: Larry Gritz <[email protected]>
1 parent 5da8e8c commit 90d94ca

23 files changed

+182
-547
lines changed

src/include/OSL/device_ptr.h

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,21 @@ template<class T> class device_ptr {
3232
#ifdef __CUDA_ARCH__
3333
/// On device, act as a pointer. None of these things are allowed on the
3434
/// host.
35-
T* operator->() const
36-
{
37-
return m_ptr;
38-
}
39-
T& operator*() const
40-
{
41-
return *m_ptr;
42-
}
35+
T* operator->() const { return m_ptr; }
36+
T& operator*() const { return *m_ptr; }
4337
#endif
4438

4539
/// Extract the raw device-side pointer. Use with caution! On the host,
4640
/// this will not point to valid memory.
47-
T* d_get() const
48-
{
49-
return m_ptr;
50-
}
41+
T* d_get() const { return m_ptr; }
5142

5243
/// Evaluate as bool is a null pointer check.
53-
operator bool() const noexcept
54-
{
55-
return m_ptr != nullptr;
56-
}
44+
operator bool() const noexcept { return m_ptr != nullptr; }
5745

5846
/// Reset the pointer to `dptr`, which must be a device-side raw pointer,
5947
/// or null. Since this device_ptr is non-owning, any previous value is
6048
/// simply overwritten.
61-
void reset(T* dptr = nullptr)
62-
{
63-
m_ptr = dptr;
64-
}
49+
void reset(T* dptr = nullptr) { m_ptr = dptr; }
6550

6651
private:
6752
T* m_ptr = nullptr; // underlying pointer, initializes to null

src/include/OSL/device_string.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ struct DeviceString {
5353
// In OptiX 7 we can't return the string's contents. Make this a compile
5454
// time error.
5555
#ifndef __CUDA_ARCH__
56-
OSL_HOSTDEVICE const char* c_str() const
57-
{
58-
return m_chars;
59-
}
56+
OSL_HOSTDEVICE const char* c_str() const { return m_chars; }
6057
#endif
6158

6259
OSL_HOSTDEVICE bool operator==(const DeviceString& other) const
@@ -81,10 +78,7 @@ struct DeviceString {
8178
return hash() != other;
8279
}
8380

84-
OSL_HOSTDEVICE operator size_t() const
85-
{
86-
return hash();
87-
}
81+
OSL_HOSTDEVICE operator size_t() const { return hash(); }
8882

8983
#endif
9084
};

src/include/OSL/mask.h

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,13 @@ template<int WidthT> class Mask {
171171
}
172172

173173

174-
OSL_FORCEINLINE ValueType value() const
175-
{
176-
return m_value;
177-
}
174+
OSL_FORCEINLINE ValueType value() const { return m_value; }
178175

179176
// count number of active bits
180-
OSL_FORCEINLINE int count() const
181-
{
182-
return OSL::popcount(m_value);
183-
}
177+
OSL_FORCEINLINE int count() const { return OSL::popcount(m_value); }
184178

185179
// NOTE: undefined result if no bits are on
186-
OSL_FORCEINLINE int first_on() const
187-
{
188-
return OSL::countr_zero(m_value);
189-
}
180+
OSL_FORCEINLINE int first_on() const { return OSL::countr_zero(m_value); }
190181

191182
OSL_FORCEINLINE Mask invert() const
192183
{
@@ -239,10 +230,7 @@ template<int WidthT> class Mask {
239230
return (m_value != static_cast<ValueType>(0));
240231
}
241232

242-
OSL_FORCEINLINE bool any_off() const
243-
{
244-
return (m_value < valid_bits);
245-
}
233+
OSL_FORCEINLINE bool any_off() const { return (m_value < valid_bits); }
246234

247235
OSL_FORCEINLINE bool any_off(const Mask& mask) const
248236
{
@@ -257,39 +245,27 @@ template<int WidthT> class Mask {
257245
// So really only set_on or set_off is required
258246
// Choose to not provide a generic set(int lane, bool flag)
259247

260-
OSL_FORCEINLINE void set_on(int lane)
261-
{
262-
m_value |= (1 << lane);
263-
}
248+
OSL_FORCEINLINE void set_on(int lane) { m_value |= (1 << lane); }
264249

265250
OSL_FORCEINLINE void set_on_if(int lane, bool cond)
266251
{
267252
m_value |= (cond << lane);
268253
}
269254

270-
OSL_FORCEINLINE void set_all_on()
271-
{
272-
m_value = valid_bits;
273-
}
255+
OSL_FORCEINLINE void set_all_on() { m_value = valid_bits; }
274256
OSL_FORCEINLINE void set_count_on(int count)
275257
{
276258
m_value = valid_bits >> (width - count);
277259
}
278260

279-
OSL_FORCEINLINE void set_off(int lane)
280-
{
281-
m_value &= (~(1 << lane));
282-
}
261+
OSL_FORCEINLINE void set_off(int lane) { m_value &= (~(1 << lane)); }
283262

284263
OSL_FORCEINLINE void set_off_if(int lane, bool cond)
285264
{
286265
m_value &= (~(cond << lane));
287266
}
288267

289-
OSL_FORCEINLINE void set_all_off()
290-
{
291-
m_value = static_cast<ValueType>(0);
292-
}
268+
OSL_FORCEINLINE void set_all_off() { m_value = static_cast<ValueType>(0); }
293269

294270
OSL_FORCEINLINE bool operator==(const Mask& other) const
295271
{
@@ -323,10 +299,7 @@ template<int WidthT> class Mask {
323299
return Mask(m_value | other.m_value);
324300
}
325301

326-
OSL_FORCEINLINE Mask operator~() const
327-
{
328-
return invert();
329-
}
302+
OSL_FORCEINLINE Mask operator~() const { return invert(); }
330303

331304

332305
template<int MinOccupancyT, int MaxOccupancyT = width, typename FunctorT>

src/include/OSL/oslclosure.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,8 @@ OSL_ALIGNAS(16) ClosureComponent : public ClosureColor
109109
Vec3 w; ///< Weight of this component
110110

111111
/// Handy method for getting the parameter memory as a void*.
112-
OSL_HOSTDEVICE void* data()
113-
{
114-
return (char*)(this + 1);
115-
}
116-
OSL_HOSTDEVICE const void* data() const
117-
{
118-
return (const char*)(this + 1);
119-
}
112+
OSL_HOSTDEVICE void* data() { return (char*)(this + 1); }
113+
OSL_HOSTDEVICE const void* data() const { return (const char*)(this + 1); }
120114

121115
/// Handy methods for extracting the underlying parameters as a struct
122116
template<typename T> OSL_HOSTDEVICE const T* as() const

src/include/OSL/rendererservices.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ struct ShaderGlobals;
1919
class ShaderGroup;
2020

2121
// Tags for polymorphic dispatch
22-
template<int SimdWidthT> class WidthOf {
23-
};
22+
template<int SimdWidthT> class WidthOf {};
2423

2524

2625
/// Opaque pointer to whatever the renderer uses to represent a

src/include/OSL/wide.h

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -299,16 +299,13 @@ struct alignas(VecReg<WidthT>) BlockOfBuiltin {
299299

300300
// Specializations
301301
template<int WidthT>
302-
struct Block<float, WidthT> : public BlockOfBuiltin<float, WidthT> {
303-
};
302+
struct Block<float, WidthT> : public BlockOfBuiltin<float, WidthT> {};
304303

305304
template<int WidthT>
306-
struct Block<int, WidthT> : public BlockOfBuiltin<int, WidthT> {
307-
};
305+
struct Block<int, WidthT> : public BlockOfBuiltin<int, WidthT> {};
308306

309307
template<typename DataT, int WidthT>
310-
struct Block<DataT*, WidthT> : public BlockOfBuiltin<DataT*, WidthT> {
311-
};
308+
struct Block<DataT*, WidthT> : public BlockOfBuiltin<DataT*, WidthT> {};
312309

313310

314311
// Vec4 isn't used by external interfaces, but some internal
@@ -2283,15 +2280,9 @@ template<typename DataT, int WidthT> struct MaskedLaneProxy {
22832280
// visibility to end user whose IDE
22842281
// might display these methods vs. free
22852282
// functions
2286-
OSL_FORCEINLINE bool is_on() const
2287-
{
2288-
return m_mask.is_on(m_lane);
2289-
}
2283+
OSL_FORCEINLINE bool is_on() const { return m_mask.is_on(m_lane); }
22902284

2291-
OSL_FORCEINLINE bool is_off() const
2292-
{
2293-
return m_mask.is_off(m_lane);
2294-
}
2285+
OSL_FORCEINLINE bool is_off() const { return m_mask.is_off(m_lane); }
22952286

22962287
private:
22972288
Block<DataT, WidthT>& m_ref_wide_data;
@@ -2353,15 +2344,9 @@ struct MaskedArrayLaneProxy {
23532344
// visibility to end user whose IDE
23542345
// might display these methods vs. free
23552346
// functions
2356-
OSL_FORCEINLINE bool is_on() const
2357-
{
2358-
return m_mask.is_on(m_lane);
2359-
}
2347+
OSL_FORCEINLINE bool is_on() const { return m_mask.is_on(m_lane); }
23602348

2361-
OSL_FORCEINLINE bool is_off() const
2362-
{
2363-
return m_mask.is_off(m_lane);
2364-
}
2349+
OSL_FORCEINLINE bool is_off() const { return m_mask.is_off(m_lane); }
23652350

23662351
OSL_FORCEINLINE MaskedLaneProxy<DataT, WidthT>
23672352
operator[](int array_index) const
@@ -2726,7 +2711,8 @@ struct MaskedDeriv : public Masked<DataT, WidthT> {
27262711
template<typename FirstT, typename... ListT,
27272712
std::enable_if_t<std::is_same<typename std::decay<FirstT>::type,
27282713
MaskedDeriv>::value,
2729-
bool> = true>
2714+
bool>
2715+
= true>
27302716
OSL_FORCEINLINE MaskedDeriv(FirstT&& first, ListT&&... argList)
27312717
: Masked<DataT, WidthT>(std::forward<FirstT>(first),
27322718
std::forward<ListT>(argList)...)
@@ -2737,7 +2723,8 @@ struct MaskedDeriv : public Masked<DataT, WidthT> {
27372723
template<typename FirstT, typename... ListT,
27382724
std::enable_if_t<!std::is_same<typename std::decay<FirstT>::type,
27392725
MaskedDeriv>::value,
2740-
bool> = true>
2726+
bool>
2727+
= true>
27412728
OSL_FORCEINLINE MaskedDeriv(FirstT&& first, ListT&&... argList)
27422729
: Masked<DataT, WidthT>(std::forward<FirstT>(first),
27432730
std::forward<ListT>(argList)...,
@@ -3188,7 +3175,8 @@ template<typename DataT, int DerivIndexT> struct RefDeriv : public Ref<DataT> {
31883175
template<typename FirstT, typename... ListT,
31893176
std::enable_if_t<!std::is_same<typename std::decay<FirstT>::type,
31903177
RefDeriv>::value,
3191-
bool> = true>
3178+
bool>
3179+
= true>
31923180
explicit OSL_FORCEINLINE RefDeriv(FirstT&& first, ListT&&... argList)
31933181
: Ref<DataT>(std::forward<FirstT>(first),
31943182
std::forward<ListT>(argList)...,

0 commit comments

Comments
 (0)