Skip to content

Commit 9379446

Browse files
committed
Format with clang-format
1 parent c1d30c7 commit 9379446

28 files changed

+239
-236
lines changed

.clang-format

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://zed0.co.uk/clang-format-configurator/
2-
# 5.0.0 (VS 2017)
2+
# 7.0.0 (VS 2019)
33
BasedOnStyle: WebKit
44
AccessModifierOffset: '-4'
55
AlignAfterOpenBracket: Align
@@ -11,19 +11,19 @@ AlignTrailingComments: 'true'
1111
AllowAllParametersOfDeclarationOnNextLine: 'false'
1212
AllowShortBlocksOnASingleLine: 'false'
1313
AllowShortCaseLabelsOnASingleLine: 'false'
14-
AllowShortFunctionsOnASingleLine: InlineOnly
14+
AllowShortFunctionsOnASingleLine: Empty
1515
AllowShortIfStatementsOnASingleLine: 'false'
1616
AllowShortLoopsOnASingleLine: 'false'
1717
AlwaysBreakAfterReturnType: None
1818
AlwaysBreakBeforeMultilineStrings: 'false'
19-
AlwaysBreakTemplateDeclarations: 'true'
19+
AlwaysBreakTemplateDeclarations: 'Yes'
2020
BinPackArguments: 'false'
2121
BinPackParameters: 'false'
2222
BreakBeforeBinaryOperators: None
2323
BreakBeforeBraces: Allman
24-
BreakBeforeInheritanceComma: 'false'
2524
BreakBeforeTernaryOperators: 'true'
2625
BreakConstructorInitializers: AfterColon
26+
BreakInheritanceList: AfterColon
2727
BreakStringLiterals: 'false'
2828
ColumnLimit: '120'
2929
CompactNamespaces: 'false'
@@ -32,9 +32,12 @@ ConstructorInitializerIndentWidth: '4'
3232
ContinuationIndentWidth: '4'
3333
Cpp11BracedListStyle: 'false'
3434
DerivePointerAlignment: 'false'
35+
DisableFormat: 'false'
3536
ExperimentalAutoDetectBinPacking: 'false'
3637
FixNamespaceComments: 'true'
38+
IncludeBlocks: Merge
3739
IndentCaseLabels: 'true'
40+
IndentPPDirectives: None
3841
IndentWidth: '4'
3942
IndentWrappedFunctionNames: 'true'
4043
KeepEmptyLinesAtTheStartOfBlocks: 'false'
@@ -48,7 +51,11 @@ SortUsingDeclarations: 'false'
4851
SpaceAfterCStyleCast: 'false'
4952
SpaceAfterTemplateKeyword: 'false'
5053
SpaceBeforeAssignmentOperators: 'true'
54+
SpaceBeforeCpp11BracedList: 'true'
55+
SpaceBeforeCtorInitializerColon: 'true'
56+
SpaceBeforeInheritanceColon: 'true'
5157
SpaceBeforeParens: Never
58+
SpaceBeforeRangeBasedForLoopColon: 'true'
5259
SpaceInEmptyParentheses: 'false'
5360
SpacesBeforeTrailingComments: '1'
5461
SpacesInAngles: 'false'
@@ -58,4 +65,4 @@ SpacesInParentheses: 'false'
5865
SpacesInSquareBrackets: 'false'
5966
Standard: Cpp11
6067
TabWidth: '4'
61-
UseTab: Never
68+
UseTab: Never

src/Cluster.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,10 @@ void Cluster::initialize(int _argc, char* _argv[])
115115
// Sponza
116116
// debug camera + lights
117117
scene->camera.lookAt({ -7.0f, 2.0f, 0.0f }, scene->center, glm::vec3(0.0f, 1.0f, 0.0f));
118-
scene->pointLights.lights = {
119-
// pos, power
120-
{ { -5.0f, 0.3f, 0.0f }, { 100.0f, 100.0f, 100.0f } },
121-
{ { 0.0f, 0.3f, 0.0f }, { 100.0f, 100.0f, 100.0f } },
122-
{ { 5.0f, 0.3f, 0.0f }, { 100.0f, 100.0f, 100.0f } }
118+
scene->pointLights.lights = { // pos, power
119+
{ { -5.0f, 0.3f, 0.0f }, { 100.0f, 100.0f, 100.0f } },
120+
{ { 0.0f, 0.3f, 0.0f }, { 100.0f, 100.0f, 100.0f } },
121+
{ { 5.0f, 0.3f, 0.0f }, { 100.0f, 100.0f, 100.0f } }
123122
};
124123
scene->pointLights.update();
125124
config->lights = scene->pointLights.lights.size();
@@ -259,19 +258,19 @@ void Cluster::BgfxCallbacks::traceVargs(const char* filePath, uint16_t line, con
259258
if(written > 0 && written < BX_COUNTOF(buffer))
260259
{
261260
// bgfx sends lines with newlines, spdlog adds another
262-
if(buffer[written-1] == '\n')
261+
if(buffer[written - 1] == '\n')
263262
buffer[written - 1] = '\0';
264263
Log->trace(buffer);
265264
}
266265
}
267266

268267
void Cluster::BgfxCallbacks::screenShot(const char* name,
269-
uint32_t width,
270-
uint32_t height,
271-
uint32_t pitch,
272-
const void* data,
273-
uint32_t /*size*/,
274-
bool yflip)
268+
uint32_t width,
269+
uint32_t height,
270+
uint32_t pitch,
271+
const void* data,
272+
uint32_t /*size*/,
273+
bool yflip)
275274
{
276275
// save screen shot as PNG
277276
char filePath[1024];
@@ -410,10 +409,7 @@ void Cluster::generateLights(unsigned int count)
410409
position.y = glm::abs(position.y); // Sponza
411410
glm::vec3 color = glm::vec3(dist(mt), dist(mt), dist(mt));
412411
glm::vec3 power = color * (dist(mt) * (POWER_MAX - POWER_MIN) + POWER_MIN);
413-
lights[i] = {
414-
position,
415-
power
416-
};
412+
lights[i] = { position, power };
417413
}
418414

419415
scene->pointLights.update();

src/Cluster.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,14 @@ class Cluster : public bigg::Application
6060
virtual void profilerBegin(const char*, uint32_t, const char*, uint16_t) override {}
6161
virtual void profilerBeginLiteral(const char*, uint32_t, const char*, uint16_t) override {}
6262
virtual void profilerEnd() override {}
63-
virtual uint32_t cacheReadSize(uint64_t) override { return 0; }
64-
virtual bool cacheRead(uint64_t, void*, uint32_t) override { return false; }
63+
virtual uint32_t cacheReadSize(uint64_t) override
64+
{
65+
return 0;
66+
}
67+
virtual bool cacheRead(uint64_t, void*, uint32_t) override
68+
{
69+
return false;
70+
}
6571
virtual void cacheWrite(uint64_t, const void*, uint32_t) override {}
6672
virtual void captureBegin(uint32_t, uint32_t, uint32_t, bgfx::TextureFormat::Enum, bool) override {}
6773
virtual void captureEnd() override {}

src/Config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Config::Config() :
2424
showConfigWindow(true),
2525
showLog(true),
2626
showStatsOverlay(true),
27-
overlays({true, true, true, true}),
27+
overlays({ true, true, true, true }),
2828
showBuffers(true),
2929
debugVisualization(false)
3030
{

src/Config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Config
1313

1414
// Log
1515

16-
bool writeLog; // not exposed to UI
16+
bool writeLog; // not exposed to UI
1717
const char* logFile; // not exposed to UI
1818

1919
// Renderer
@@ -23,8 +23,8 @@ class Config
2323
Renderer::TonemappingMode tonemappingMode;
2424

2525
bool profile; // not exposed to UI
26-
bool vsync; // not exposed to UI
27-
bool msaa; // not exposed to UI
26+
bool vsync; // not exposed to UI
27+
bool msaa; // not exposed to UI
2828

2929
// Scene
3030

src/Log/AssimpSource.h

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,30 @@
66

77
class AssimpLogSource : public Assimp::Logger
88
{
9-
virtual void OnDebug(const char* message) override { Log->debug(message); }
10-
virtual void OnInfo (const char* message) override { Log->info (message); }
11-
virtual void OnWarn (const char* message) override { Log->warn (message); }
12-
virtual void OnError(const char* message) override { Log->error(message); }
9+
virtual void OnDebug(const char* message) override
10+
{
11+
Log->debug(message);
12+
}
13+
virtual void OnInfo(const char* message) override
14+
{
15+
Log->info(message);
16+
}
17+
virtual void OnWarn(const char* message) override
18+
{
19+
Log->warn(message);
20+
}
21+
virtual void OnError(const char* message) override
22+
{
23+
Log->error(message);
24+
}
1325

14-
virtual bool attachStream(Assimp::LogStream* pStream, unsigned int severity) override { delete pStream; return true; }
15-
virtual bool detatchStream(Assimp::LogStream* pStream, unsigned int severity) override { return true; }
26+
virtual bool attachStream(Assimp::LogStream* pStream, unsigned int severity) override
27+
{
28+
delete pStream;
29+
return true;
30+
}
31+
virtual bool detatchStream(Assimp::LogStream* pStream, unsigned int severity) override
32+
{
33+
return true;
34+
}
1635
};

src/Log/UISink.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace spdlog
88
{
99
namespace ext
1010
{
11-
1211
template<typename Mutex, typename Func>
1312
class clusterui_sink : public sinks::base_sink<Mutex>
1413
{
@@ -29,8 +28,10 @@ class clusterui_sink : public sinks::base_sink<Mutex>
2928
virtual void flush_() override {}
3029
};
3130

32-
template<typename Func> using clusterui_sink_mt = clusterui_sink<std::mutex, Func>;
33-
template<typename Func> using clusterui_sink_st = clusterui_sink<details::null_mutex, Func>;
31+
template<typename Func>
32+
using clusterui_sink_mt = clusterui_sink<std::mutex, Func>;
33+
template<typename Func>
34+
using clusterui_sink_st = clusterui_sink<details::null_mutex, Func>;
3435

3536
} // namespace ext
3637
} // namespace spdlog

src/Renderer/ClusterShader.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ ClusterShader::ClusterShader() :
1717
atomicIndexBuffer(BGFX_INVALID_HANDLE),
1818
lightCount(0)
1919
{
20-
static_assert(CLUSTERS_Z % CLUSTERS_Z_THREADS == 0, "number of cluster depth slices must be divisible by thread count z-dimension");
20+
static_assert(CLUSTERS_Z % CLUSTERS_Z_THREADS == 0,
21+
"number of cluster depth slices must be divisible by thread count z-dimension");
2122
}
2223

2324
void ClusterShader::initialize()
@@ -27,10 +28,13 @@ void ClusterShader::initialize()
2728
clusterSizesVecUniform = bgfx::createUniform("u_clusterSizesVec", bgfx::UniformType::Vec4);
2829
zNearFarVecUniform = bgfx::createUniform("u_zNearFarVec", bgfx::UniformType::Vec4);
2930

30-
clustersBuffer = bgfx::createDynamicVertexBuffer(CLUSTER_COUNT, ClusterVertex::decl, BGFX_BUFFER_COMPUTE_READ_WRITE);
31-
lightIndicesBuffer = bgfx::createDynamicIndexBuffer (CLUSTER_COUNT * MAX_LIGHTS_PER_CLUSTER, BGFX_BUFFER_COMPUTE_READ_WRITE | BGFX_BUFFER_INDEX32);
32-
lightGridBuffer = bgfx::createDynamicIndexBuffer (CLUSTER_COUNT * 4, BGFX_BUFFER_COMPUTE_READ_WRITE | BGFX_BUFFER_INDEX32);
33-
atomicIndexBuffer = bgfx::createDynamicIndexBuffer (1, BGFX_BUFFER_COMPUTE_READ_WRITE | BGFX_BUFFER_INDEX32);
31+
clustersBuffer =
32+
bgfx::createDynamicVertexBuffer(CLUSTER_COUNT, ClusterVertex::decl, BGFX_BUFFER_COMPUTE_READ_WRITE);
33+
lightIndicesBuffer = bgfx::createDynamicIndexBuffer(CLUSTER_COUNT * MAX_LIGHTS_PER_CLUSTER,
34+
BGFX_BUFFER_COMPUTE_READ_WRITE | BGFX_BUFFER_INDEX32);
35+
lightGridBuffer =
36+
bgfx::createDynamicIndexBuffer(CLUSTER_COUNT * 4, BGFX_BUFFER_COMPUTE_READ_WRITE | BGFX_BUFFER_INDEX32);
37+
atomicIndexBuffer = bgfx::createDynamicIndexBuffer(1, BGFX_BUFFER_COMPUTE_READ_WRITE | BGFX_BUFFER_INDEX32);
3438
}
3539

3640
void ClusterShader::shutdown()
@@ -52,11 +56,8 @@ void ClusterShader::setUniforms(const Scene* scene, uint16_t screenWidth, uint16
5256
{
5357
assert(scene != nullptr);
5458

55-
float clusterSizesVec[4] =
56-
{
57-
std::ceil((float)screenWidth / CLUSTERS_X),
58-
std::ceil((float)screenHeight / CLUSTERS_Y)
59-
};
59+
float clusterSizesVec[4] = { std::ceil((float)screenWidth / CLUSTERS_X),
60+
std::ceil((float)screenHeight / CLUSTERS_Y) };
6061

6162
bgfx::setUniform(clusterSizesVecUniform, clusterSizesVec);
6263
float zNearFarVec[4] = { scene->camera.zNear, scene->camera.zFar };

src/Renderer/ClusterShader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class ClusterShader
2828
static constexpr uint32_t MAX_LIGHTS_PER_CLUSTER = 100;
2929

3030
private:
31-
3231
struct ClusterVertex
3332
{
3433
// w is padding

src/Renderer/ClusteredRenderer.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ ClusteredRenderer::ClusteredRenderer(const Scene* scene) :
1515
{
1616
}
1717

18-
ClusteredRenderer::~ClusteredRenderer()
19-
{
20-
}
21-
2218
bool ClusteredRenderer::supported()
2319
{
2420
const bgfx::Caps* caps = bgfx::getCaps();
@@ -146,5 +142,6 @@ void ClusteredRenderer::onShutdown()
146142
bgfx::destroy(lightingProgram);
147143
bgfx::destroy(debugVisProgram);
148144

149-
clusterBuildingComputeProgram = lightCullingComputeProgram = lightingProgram = debugVisProgram = BGFX_INVALID_HANDLE;
145+
clusterBuildingComputeProgram = lightCullingComputeProgram = lightingProgram = debugVisProgram =
146+
BGFX_INVALID_HANDLE;
150147
}

0 commit comments

Comments
 (0)