Skip to content

Commit

Permalink
Fix new clang-tidy nags
Browse files Browse the repository at this point in the history
  • Loading branch information
sndels committed Nov 23, 2024
1 parent 06969d2 commit 313fafa
Show file tree
Hide file tree
Showing 31 changed files with 64 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void deallocatefun(void *block, void *user)
{
WHEELS_ASSERT(user != nullptr);
TlsfAllocator *alloc = static_cast<TlsfAllocator *>(user);
return alloc->deallocate(block);
alloc->deallocate(block);
}

} // namespace
Expand Down
3 changes: 1 addition & 2 deletions src/gfx/DescriptorAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ void DescriptorAllocator::allocate(
Span<const char *const> debugNames, Span<vk::DescriptorSet> output)
{
WHEELS_ASSERT(m_initialized);

return allocate(layouts, debugNames, output, nullptr);
allocate(layouts, debugNames, output, nullptr);
}

void DescriptorAllocator::nextPool()
Expand Down
5 changes: 4 additions & 1 deletion src/gfx/Resources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// TODO:
// Tighter transfer, shader access flags
enum class BufferState : uint32_t
enum class BufferState : uint16_t
{
Unknown = 0,

Expand Down Expand Up @@ -133,6 +133,9 @@ template <typename T>
requires(wheels::SameAs<T, BufferState> || wheels::SameAs<T, ImageState>)
constexpr T operator|(T lhs, T rhs)
{
// TODO:
// Could the valid combinations be easily enumerated?
// NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
return static_cast<T>(
static_cast<uint64_t>(lhs) | static_cast<uint64_t>(rhs));
}
Expand Down
2 changes: 1 addition & 1 deletion src/render/DebugRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using namespace wheels;
namespace
{

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
CameraBindingSet,
GeometryBuffersBindingSet,
Expand Down
8 changes: 3 additions & 5 deletions src/render/DeferredShading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using namespace wheels;
namespace
{

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
LightsBindingSet,
LightClustersBindingSet,
Expand Down Expand Up @@ -85,8 +85,7 @@ void DeferredShading::init(
WHEELS_ASSERT(!m_initialized);

m_computePass.init(
WHEELS_MOV(scopeAlloc),
[&dsLayouts](Allocator &alloc)
WHEELS_MOV(scopeAlloc), [&dsLayouts](Allocator &alloc)
{ return shaderDefinitionCallback(alloc, dsLayouts.world); },
ComputePassOptions{
.storageSetIndex = StorageBindingSet,
Expand All @@ -104,8 +103,7 @@ void DeferredShading::recompileShaders(
WHEELS_ASSERT(m_initialized);

m_computePass.recompileShader(
WHEELS_MOV(scopeAlloc), changedFiles,
[&dsLayouts](Allocator &alloc)
WHEELS_MOV(scopeAlloc), changedFiles, [&dsLayouts](Allocator &alloc)
{ return shaderDefinitionCallback(alloc, dsLayouts.world); },
externalDsLayouts(dsLayouts));
}
Expand Down
2 changes: 1 addition & 1 deletion src/render/ForwardRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace wheels;
namespace
{

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
LightsBindingSet,
LightClustersBindingSet,
Expand Down
2 changes: 1 addition & 1 deletion src/render/GBufferRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace
const vk::Format sAlbedoRoughnessFormat = vk::Format::eR8G8B8A8Unorm;
const vk::Format sNormalMetalnessFormat = vk::Format::eA2B10G10R10UnormPack32;

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
CameraBindingSet,
MaterialDatasBindingSet,
Expand Down
2 changes: 1 addition & 1 deletion src/render/LightClustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ constexpr uint32_t sGroupDim = 16;
constexpr uint32_t maxPointIndicesPerTile = 128;
constexpr uint32_t maxSpotIndicesPerTile = 128;

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
LightsBindingSet,
CameraBindingSet,
Expand Down
7 changes: 3 additions & 4 deletions src/render/MeshletCuller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const uint32_t sMaxRecordsPerFrame = 2;

const uint32_t sMaxHierarchicalDepthMips = 12;

enum GeneratorBindingSet : uint32_t
enum GeneratorBindingSet : uint8_t
{
GeneratorGeometryBindingSet,
GeneratorSceneInstancesBindingSet,
Expand All @@ -42,7 +42,7 @@ enum GeneratorBindingSet : uint32_t
GeneratorBindingSetCount,
};

enum CullerBindingSet : uint32_t
enum CullerBindingSet : uint8_t
{
CullerCameraBindingSet,
CullerGeometryBindingSet,
Expand Down Expand Up @@ -146,8 +146,7 @@ void MeshletCuller::init(
WHEELS_ASSERT(!m_initialized);

m_drawListGenerator.init(
scopeAlloc.child_scope(),
[&worldDsLayouts](Allocator &alloc)
scopeAlloc.child_scope(), [&worldDsLayouts](Allocator &alloc)
{ return generatorDefinitionCallback(alloc, worldDsLayouts); },
ComputePassOptions{
.storageSetIndex = GeneratorStorageBindingSet,
Expand Down
2 changes: 1 addition & 1 deletion src/render/MeshletCuller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MeshletCuller

void startFrame();

enum class Mode
enum class Mode : uint8_t
{
Opaque,
Transparent,
Expand Down
6 changes: 3 additions & 3 deletions src/render/RtReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace

constexpr uint32_t sFramePeriod = 4096;

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
CameraBindingSet,
RTBindingSet,
Expand All @@ -47,15 +47,15 @@ constexpr vk::ShaderStageFlags sVkShaderStageFlagsAllRt =
vk::ShaderStageFlagBits::eMissKHR |
vk::ShaderStageFlagBits::eIntersectionKHR;

enum class StageIndex : uint32_t
enum class StageIndex : uint8_t
{
RayGen,
ClosestHit,
AnyHit,
Miss,
};

enum class GroupIndex : uint32_t
enum class GroupIndex : uint8_t
{
RayGen,
Hit,
Expand Down
2 changes: 1 addition & 1 deletion src/render/SkyboxRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace wheels;
namespace
{

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
SkyboxBindingSet,
CameraBindingSet,
Expand Down
2 changes: 1 addition & 1 deletion src/render/TemporalAntiAliasing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ constexpr StaticArray<
static_cast<size_t>(TemporalAntiAliasing::VelocitySamplingType::Count)>
sVelocitySamplingTypeNames{{VELOCITY_SAMPLING_TYPE_STRS}};

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
CameraBindingSet,
StorageBindingSet,
Expand Down
4 changes: 2 additions & 2 deletions src/render/TemporalAntiAliasing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
class TemporalAntiAliasing
{
public:
enum class ColorClippingType : uint32_t
enum class ColorClippingType : uint8_t
{
COLOR_CLIPPING_TYPES_AND_COUNT
};

enum class VelocitySamplingType : uint32_t
enum class VelocitySamplingType : uint8_t
{
VELOCITY_SAMPLING_TYPES_AND_COUNT
};
Expand Down
2 changes: 1 addition & 1 deletion src/render/TextureDebug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class TextureDebug
{
public:
enum class ChannelType : uint32_t
enum class ChannelType : uint8_t
{
TEXTURE_DEBUG_CHANNEL_TYPES_AND_COUNT
};
Expand Down
2 changes: 1 addition & 1 deletion src/render/dof/DepthOfFieldGather.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class DepthOfFieldGather
{
public:
enum GatherType : uint32_t
enum GatherType : uint8_t
{
GatherType_Foreground,
GatherType_Background,
Expand Down
2 changes: 1 addition & 1 deletion src/render/dof/DepthOfFieldSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace wheels;
namespace
{

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
CameraBindingSet,
StorageBindingSet,
Expand Down
8 changes: 3 additions & 5 deletions src/render/rtdi/RtDiInitialReservoirs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace

constexpr uint32_t sFramePeriod = 4096;

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
LightsBindingSet,
CameraBindingSet,
Expand Down Expand Up @@ -67,8 +67,7 @@ void RtDiInitialReservoirs::init(
WHEELS_ASSERT(!m_initialized);

m_computePass.init(
WHEELS_MOV(scopeAlloc),
[&dsLayouts](Allocator &alloc)
WHEELS_MOV(scopeAlloc), [&dsLayouts](Allocator &alloc)
{ return shaderDefinitionCallback(alloc, dsLayouts.world); },
ComputePassOptions{
.storageSetIndex = StorageBindingSet,
Expand All @@ -86,8 +85,7 @@ bool RtDiInitialReservoirs::recompileShaders(
WHEELS_ASSERT(m_initialized);

return m_computePass.recompileShader(
WHEELS_MOV(scopeAlloc), changedFiles,
[&dsLayouts](Allocator &alloc)
WHEELS_MOV(scopeAlloc), changedFiles, [&dsLayouts](Allocator &alloc)
{ return shaderDefinitionCallback(alloc, dsLayouts.world); },
externalDsLayouts(dsLayouts));
}
Expand Down
8 changes: 3 additions & 5 deletions src/render/rtdi/RtDiSpatialReuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace

constexpr uint32_t sFramePeriod = 4096;

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
LightsBindingSet,
CameraBindingSet,
Expand Down Expand Up @@ -67,8 +67,7 @@ void RtDiSpatialReuse::init(
WHEELS_ASSERT(!m_initialized);

m_computePass.init(
WHEELS_MOV(scopeAlloc),
[&dsLayouts](Allocator &alloc)
WHEELS_MOV(scopeAlloc), [&dsLayouts](Allocator &alloc)
{ return shaderDefinitionCallback(alloc, dsLayouts.world); },
ComputePassOptions{
.storageSetIndex = StorageBindingSet,
Expand All @@ -86,8 +85,7 @@ bool RtDiSpatialReuse::recompileShaders(
WHEELS_ASSERT(m_initialized);

return m_computePass.recompileShader(
WHEELS_MOV(scopeAlloc), changedFiles,
[&dsLayouts](Allocator &alloc)
WHEELS_MOV(scopeAlloc), changedFiles, [&dsLayouts](Allocator &alloc)
{ return shaderDefinitionCallback(alloc, dsLayouts.world); },
externalDsLayouts(dsLayouts));
}
Expand Down
6 changes: 3 additions & 3 deletions src/render/rtdi/RtDiTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace

constexpr uint32_t sFramePeriod = 4096;

enum BindingSet : uint32_t
enum BindingSet : uint8_t
{
CameraBindingSet,
RTBindingSet,
Expand All @@ -47,15 +47,15 @@ constexpr vk::ShaderStageFlags sVkShaderStageFlagsAllRt =
vk::ShaderStageFlagBits::eMissKHR |
vk::ShaderStageFlagBits::eIntersectionKHR;

enum class StageIndex : uint32_t
enum class StageIndex : uint8_t
{
RayGen,
ClosestHit,
AnyHit,
Miss,
};

enum class GroupIndex : uint32_t
enum class GroupIndex : uint8_t
{
RayGen,
Hit,
Expand Down
2 changes: 1 addition & 1 deletion src/scene/Animations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <glm/gtc/quaternion.hpp>
#include <wheels/containers/array.hpp>

enum class InterpolationType
enum class InterpolationType : uint8_t
{
Step,
Linear,
Expand Down
2 changes: 1 addition & 1 deletion src/scene/DeferredLoadingContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <wheels/containers/static_array.hpp>
#include <wheels/containers/string.hpp>

enum class IndicesType
enum class IndicesType : uint8_t
{
Uint8,
Uint16,
Expand Down
2 changes: 1 addition & 1 deletion src/scene/DrawType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define DRAW_TYPES_STRS FOR_EACH(DRAW_TYPES_STRINGIFY, DRAW_TYPES)

enum class DrawType : uint32_t
enum class DrawType : uint8_t
{
DRAW_TYPES_AND_COUNT
};
Expand Down
2 changes: 1 addition & 1 deletion src/scene/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ bool World::unbuiltBlases() const
void World::drawDeferredLoadingUi() const
{
WHEELS_ASSERT(m_initialized);
return m_impl->m_data.drawDeferredLoadingUi();
m_impl->m_data.drawDeferredLoadingUi();
}

bool World::drawSceneUi()
Expand Down
11 changes: 4 additions & 7 deletions src/scene/WorldData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void *cgltf_alloc_func(void *user, cgltf_size size)
void cgltf_free_func(void *user, void *ptr)
{
Allocator *alloc = static_cast<Allocator *>(user);
return alloc->deallocate(ptr);
alloc->deallocate(ptr);
}

const StaticArray sCgltfResultStr{{
Expand Down Expand Up @@ -1488,13 +1488,10 @@ void WorldData::gatherScene(

// Angular attenuation rom gltf spec
const auto angleScale =
1.f /
max(0.001f, static_cast<float>(
cos(light.spot_inner_cone_angle) -
cos(light.spot_outer_cone_angle)));
1.f / max(0.001f, cos(light.spot_inner_cone_angle) -
cos(light.spot_outer_cone_angle));
const auto angleOffset =
static_cast<float>(-cos(light.spot_outer_cone_angle)) *
angleScale;
-cos(light.spot_outer_cone_angle) * angleScale;

sceneLight.radianceAndAngleScale =
vec4{
Expand Down
Loading

0 comments on commit 313fafa

Please sign in to comment.