Skip to content

Commit e2bac39

Browse files
committed
(gpu) change code convention
1 parent eb92b2a commit e2bac39

File tree

148 files changed

+12149
-8390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+12149
-8390
lines changed

.clang-format

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,22 @@ BitFieldColonSpacing: After
2323
BreakBeforeConceptDeclarations: 'true'
2424
BreakBinaryOperations: RespectPrecedence
2525
EmptyLineBeforeAccessModifier: LogicalBlock
26+
EnumTrailingComma: Insert
27+
FixNamespaceComments: 'true'
2628
IndentExternBlock: Indent
2729
IndentGotoLabels: 'false'
2830
IndentRequiresClause: 'true'
2931
InsertBraces: 'false'
3032
InsertTrailingCommas: Wrapped
3133
LambdaBodyIndentation: Signature
3234
PPIndentWidth: 4
35+
PenaltyBreakAssignment: 1000
36+
PenaltyReturnTypeOnItsOwnLine: 1000
37+
PenaltyBreakBeforeFirstCallParameter: 1000
38+
PenaltyBreakOpenParenthesis: 1000
39+
PenaltyBreakBeforeMemberAccess: 10
40+
PenaltyIndentedWhitespace: 1
41+
ContinuationIndentWidth: 2
3342
ReferenceAlignment: Left
3443
# RemoveBracesLLVM: 'true'
3544
RequiresClausePosition: OwnLine
@@ -40,9 +49,18 @@ SpaceBeforeCaseColon: 'false'
4049
AlwaysBreakAfterDefinitionReturnType: None
4150
SpaceBeforeSquareBrackets: 'false'
4251
SpaceInEmptyBlock: 'false'
43-
AttributeMacros: [STORMKIT_FORCE_INLINE, STORMKIT_API, STORMKIT_PRIVATE, STORMKIT_PUBLIC]
52+
AttributeMacros: [STORMKIT_FORCE_INLINE, STORMKIT_API, STORMKIT_PRIVATE, STORMKIT_PUBLIC, STORMKIT_CONST, STORMKIT_PURE, STORMKIT_INTRINSIC]
4453
IfMacros: [CASE_DO, CASE_DO_RETURN, CASE, CASE_ARGS_DO]
4554
BreakAfterAttributes: Always
55+
Macros:
56+
- STORMKIT_FORCE_INLINE=[[maybe_unused]]
57+
- STORMKIT_API=[[maybe_unused]]
58+
- STORMKIT_PRIVATE=[[maybe_unused]]
59+
- STORMKIT_PUBLIC=[[maybe_unused]]
60+
- STORMKIT_CONST=[[maybe_unused]]
61+
- STORMKIT_PURE=[[maybe_unused]]
62+
- STORMKIT_INTRINSIC=[[maybe_unused]]
63+
4664
QualifierAlignment: Custom
4765
QualifierOrder: [static, inline, volatile, restrict, constexpr, const, type]
4866

@@ -64,7 +82,6 @@ ColumnLimit: '100'
6482
CompactNamespaces: 'true'
6583
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
6684
ConstructorInitializerIndentWidth: '4'
67-
ContinuationIndentWidth: '4'
6885
IncludeBlocks: Preserve
6986
IndentCaseLabels: 'true'
7087
IndentWidth: '4'
@@ -76,7 +93,6 @@ MaxEmptyLinesToKeep: '1'
7693
NamespaceIndentation: All
7794
ObjCSpaceAfterProperty: true
7895
ObjCSpaceBeforeProtocolList: false
79-
PenaltyBreakAssignment: '0'
8096
PointerAlignment: Left
8197
SortIncludes: 'true'
8298
SortUsingDeclarations: 'true'
@@ -91,7 +107,6 @@ SpacesInAngles: 'false'
91107
Standard: c++20
92108
TabWidth: '4'
93109
UseTab: Never
94-
PenaltyBreakBeforeFirstCallParameter: '120'
95110
---
96111
Language: ObjC
97112
AlignAfterOpenBracket: Align
@@ -137,8 +152,12 @@ MaxEmptyLinesToKeep: '1'
137152
NamespaceIndentation: All
138153
ObjCSpaceAfterProperty: true
139154
ObjCSpaceBeforeProtocolList: false
140-
PenaltyBreakAssignment: '0'
141155
PointerAlignment: Right
156+
PenaltyBreakAssignment: 1000
157+
PenaltyReturnTypeOnItsOwnLine: 1000
158+
PenaltyBreakBeforeFirstCallParameter: 1000
159+
PenaltyBreakOpenParenthesis: 1000
160+
PenaltyBreakBeforeMemberAccess: 10
142161
SortIncludes: 'true'
143162
SortUsingDeclarations: 'true'
144163
SpaceAfterTemplateKeyword: 'false'
@@ -152,7 +171,6 @@ SpacesInAngles: 'false'
152171
Standard: c++20
153172
TabWidth: '4'
154173
UseTab: Never
155-
PenaltyBreakBeforeFirstCallParameter: '120'
156174
PenaltyIndentedWhitespace: '1'
157175
QualifierAlignment: Custom
158176
QualifierOrder: [static, inline, volatile, restrict, constexpr, const, type]

.github/workflows/Linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
libelf-dev
8080
libdwarf-dev
8181
mold
82+
nasm
8283
llvm${{ env.LLVM_VERSION }}
8384
llvm${{ env.LLVM_VERSION }}-dev
8485
llvm${{ env.LLVM_VERSION }}-runtime
@@ -123,7 +124,7 @@ jobs:
123124
- name: Setup XMake
124125
uses: xmake-io/github-action-setup-xmake@v1
125126
with:
126-
xmake-version: Arthapz/xmake#branch@improve-jobgraph-support2
127+
xmake-version: branch@dev
127128
actions-cache-folder: .xmake-cache
128129

129130
- name: Cache XMake

.github/workflows/Windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
if: ${{ !steps.restore-xmakecache.outputs.cache-hit }}
8383
uses: xmake-io/github-action-setup-xmake@v1
8484
with:
85-
xmake-version: Arthapz/xmake#branch@fix-cmake-clang-msstl
85+
xmake-version: branch@dev
8686
actions-cache-folder: '.xmake-cache'
8787

8888
- name: Cache XMake

.github/workflows/macOS.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: Install build tools
5050
uses: tecolicom/actions-use-homebrew-tools@v1
5151
with:
52-
tools: llvm ninja meson mold
52+
tools: llvm ninja meson mold nasm pkgconf
5353
verbose: true
5454

5555
- name: Checkout
@@ -78,7 +78,7 @@ jobs:
7878
- name: Setup XMake
7979
uses: xmake-io/github-action-setup-xmake@v1
8080
with:
81-
xmake-version: Arthapz/xmake#branch@improve-jobgraph-support2
81+
xmake-version: branch@dev
8282
actions-cache-folder: .xmake-cache
8383

8484
- name: Cache XMake

src/Gpu/Execution/CommandPool.cpp renamed to backup-src/execution/command_pool.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// This file is subject to the license terms in the LICENSE file
33
// found in the top-level of this distribution
44

5-
module stormkit.Gpu;
5+
module stormkit.gpu;
66

77
import std;
88

99
import stormkit.core;
1010

11-
import stormkit.Gpu.Vulkan;
11+
import stormkit.gpu.vulkan;
1212
import :Core;
1313
import :Execution.CommandBuffer;
1414

@@ -17,7 +17,7 @@ using namespace std::literals;
1717
namespace stormkit::gpu {
1818
/////////////////////////////////////
1919
/////////////////////////////////////
20-
auto CommandPool::createVkCommandBuffers(const Device& device,
20+
auto CommandPool::create_vk_command_buffers(const Device& device,
2121
RangeExtent count,
2222
CommandBufferLevel level) const noexcept
2323
-> std::vector<vk::raii::CommandBuffer> {
@@ -44,13 +44,13 @@ namespace stormkit::gpu {
4444

4545
if (create_count > 0) {
4646
const auto allocate_info
47-
= vk::CommandBufferAllocateInfo { .commandPool = *vkHandle(),
47+
= vk::CommandBufferAllocateInfo { .commandPool = *native_handle(),
4848
.level = narrow<vk::CommandBufferLevel>(level),
4949
.commandBufferCount = as<UInt32>(count) };
5050

5151
// TODO handle error here
52-
std::ranges::move(device.vkHandle()
53-
.allocateCommandBuffers(allocate_info)
52+
std::ranges::move(device.native_handle()
53+
.allocate_command_buffers(allocate_info)
5454
.transform_error(core :.monadic::assert(
5555
std::format("Failed to allocate {} command buffers",
5656
create_count)))

src/Gpu/Execution/Pipeline.cpp renamed to backup-src/execution/pipeline.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
// This file is subject to the license terms in the LICENSE file
33
// found in the top-level of this distribution
44

5-
module stormkit.Gpu;
5+
module stormkit.gpu;
66

77
import std;
88

99
import stormkit.core;
1010

11-
import stormkit.Gpu.Vulkan;
11+
import stormkit.gpu.vulkan;
1212
import :Core;
1313
import :Execution.Pipeline;
1414
import :Execution.RenderPass;
15-
import :Execution.RasterPipelineState;
15+
import execution.raster_pipeline;
1616

1717
namespace stormkit::gpu {
1818
/////////////////////////////////////
1919
/////////////////////////////////////
20-
auto Pipeline::doInitRasterPipeline(const Device& device,
20+
auto Pipeline::do_init(const Device& device,
2121
const PipelineLayout& layout,
2222
const RenderPass& render_pass,
2323
OptionalRef<const PipelineCache> pipeline_cache) noexcept
@@ -68,14 +68,14 @@ namespace stormkit::gpu {
6868
| std::ranges::to<std::vector>();
6969

7070
const auto viewport_state =
71-
vk::PipelineViewportStateCreateInfo {}.setViewports(viewports).setScissors(scissors);
71+
vk::PipelineViewportStateCreateInfo {}.set_viewports(viewports).set_scissors(scissors);
7272

7373
const auto rasterizer =
7474
vk::PipelineRasterizationStateCreateInfo {
7575
.depthClampEnable = state.rasterization_state.depth_clamp_enable,
7676
.rasterizerDiscardEnable = state.rasterization_state.rasterizer_discard_enable,
7777
.polygonMode = narrow<vk::PolygonMode>(state.rasterization_state.polygon_mode),
78-
.cullMode = toVkFlags<vk::CullModeFlagBits>(state.rasterization_state.cull_mode),
78+
.cullMode = to_vkflags<vk::CullModeFlagBits>(state.rasterization_state.cull_mode),
7979
.frontFace = narrow<vk::FrontFace>(state.rasterization_state.front_face),
8080
.lineWidth = state.rasterization_state.line_width
8181
};
@@ -97,7 +97,7 @@ namespace stormkit::gpu {
9797
.srcAlphaBlendFactor = narrow<vk::BlendFactor>(attachment.src_alpha_blend_factor),
9898
.dstAlphaBlendFactor = narrow<vk::BlendFactor>(attachment.dst_alpha_blend_factor),
9999
.alphaBlendOp = narrow<vk::BlendOp>(attachment.alpha_blend_operation),
100-
.colorWriteMask = toVkFlags<vk::ColorComponentFlagBits>(attachment.color_write_mask)
100+
.colorWriteMask = to_vkflags<vk::ColorComponentFlagBits>(attachment.color_write_mask)
101101
};
102102
})
103103
| std::ranges::to<std::vector>();
@@ -106,7 +106,7 @@ namespace stormkit::gpu {
106106
.logicOpEnable = state.color_blend_state.logic_operation_enable,
107107
.logicOp = narrow<vk::LogicOp>(state.color_blend_state.logic_operation),
108108
}
109-
.setBlendConstants({ state.color_blend_state.blend_constants[0],
109+
.set_blend_constants({ state.color_blend_state.blend_constants[0],
110110
state.color_blend_state.blend_constants[1],
111111
state.color_blend_state.blend_constants[2],
112112
state.color_blend_state.blend_constants[3] })
@@ -124,7 +124,7 @@ namespace stormkit::gpu {
124124
static constexpr auto NAME = "main";
125125
return vk::PipelineShaderStageCreateInfo {
126126
.stage = narrow<vk::ShaderStageFlagBits>(shader->type()),
127-
.module = toVkHandle(shader),
127+
.module = to_vkhandle(shader),
128128
.pName = NAME
129129
};
130130
})
@@ -149,8 +149,8 @@ namespace stormkit::gpu {
149149
.pDepthStencilState = &depth_stencil,
150150
.pColorBlendState = &color_blending,
151151
.pDynamicState = &dynamic_state,
152-
.layout = toVkHandle(layout),
153-
.renderPass = toVkHandle(render_pass),
152+
.layout = to_vkhandle(layout),
153+
.renderPass = to_vkhandle(render_pass),
154154
.subpass = 0,
155155
.basePipelineHandle = nullptr,
156156
.basePipelineIndex = -1

src/Gpu/Execution/PipelineCache.cpp renamed to backup-src/execution/pipeline_cache.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// This file is subject to the license terms in the LICENSE file
33
// found in the top-level of this distribution
44

5-
module stormkit.Gpu;
5+
module stormkit.gpu;
66

77
import std;
88

@@ -11,17 +11,17 @@ import stormkit.log;
1111

1212
#include <stormkit/log/log_macro.hpp>
1313

14-
import stormkit.Gpu.Vulkan;
14+
import stormkit.gpu.vulkan;
1515
import :Core;
1616
import :Execution.Pipeline;
1717

1818
namespace stormkit::gpu {
19-
LOGGER("stormkit.Gpu")
19+
LOGGER("stormkit.gpu")
2020

2121
/////////////////////////////////////
2222
/////////////////////////////////////
23-
auto PipelineCache::createNewPipelineCache(const Device& device) -> VulkanExpected<void> {
24-
const auto physical_device_infos = device.physicalDevice().info();
23+
auto PipelineCache::create_new_pipeline_cache(const Device& device) -> VulkanExpected<void> {
24+
const auto physical_device_infos = device.physical_device().info();
2525

2626
m_serialized.guard.magic = MAGIC;
2727
m_serialized.guard.data_size = 0u;
@@ -34,7 +34,7 @@ namespace stormkit::gpu {
3434
std::ranges::copy(physical_device_infos.pipeline_cache_uuid,
3535
std::ranges::begin(m_serialized.uuid.value));
3636

37-
return device.vkHandle()
37+
return device.native_handle()
3838
.createPipelineCache({})
3939
.transform(core :.monadic::set(m_vk_pipeline_cache))
4040
.transform([this] noexcept -> void {
@@ -44,8 +44,8 @@ namespace stormkit::gpu {
4444

4545
/////////////////////////////////////
4646
/////////////////////////////////////
47-
auto PipelineCache::readPipelineCache(const Device& device) -> VulkanExpected<void> {
48-
const auto physical_device_infos = device.physicalDevice().info();
47+
auto PipelineCache::read_pipeline_cache(const Device& device) -> VulkanExpected<void> {
48+
const auto physical_device_infos = device.physical_device().info();
4949

5050
auto stream = std::ifstream { m_path.string(), std::ios::binary };
5151
read(stream, as_bytes(m_serialized.guard));
@@ -57,46 +57,46 @@ namespace stormkit::gpu {
5757
m_serialized.guard.magic,
5858
MAGIC);
5959

60-
return createNewPipelineCache(device);
60+
return create_new_pipeline_cache(device);
6161
}
6262

6363
if (m_serialized.infos.version != VERSION) {
6464
elog("Mismatch pipeline cache version, have {}, expected: {}",
6565
m_serialized.infos.version,
6666
VERSION);
6767

68-
return createNewPipelineCache(device);
68+
return create_new_pipeline_cache(device);
6969
}
7070

7171
if (m_serialized.infos.vendor_id != physical_device_infos.vendor_id) {
7272
elog("Mismatch pipeline cache vendor id, have {:#06x}, expected: {:#06x}",
7373
m_serialized.infos.vendor_id,
7474
physical_device_infos.vendor_id);
7575

76-
return createNewPipelineCache(device);
76+
return create_new_pipeline_cache(device);
7777
}
7878

7979
if (m_serialized.infos.device_id != physical_device_infos.device_id) {
8080
elog("Mismatch pipeline cache device id, have {:#06x}, expected: {:#06x}",
8181
m_serialized.infos.device_id,
8282
physical_device_infos.device_id);
8383

84-
return createNewPipelineCache(device);
84+
return create_new_pipeline_cache(device);
8585
}
8686

8787
if (!std::equal(std::cbegin(m_serialized.uuid.value),
8888
std::cend(m_serialized.uuid.value),
8989
std::cbegin(physical_device_infos.pipeline_cache_uuid))) {
9090
elog("Mismatch pipeline cache device UUID");
9191

92-
return createNewPipelineCache(device);
92+
return create_new_pipeline_cache(device);
9393
}
9494

9595
const auto data = read(stream, m_serialized.guard.data_size);
9696

9797
const auto create_info = vk::PipelineCacheCreateInfo {}.setInitialData<Byte>(data);
9898

99-
return device.vkHandle()
99+
return device.native_handle()
100100
.createPipelineCache(create_info)
101101
.transform(core :.monadic::set(m_vk_pipeline_cache))
102102
.transform([this]() noexcept -> void {
@@ -107,7 +107,7 @@ namespace stormkit::gpu {
107107

108108
/////////////////////////////////////
109109
/////////////////////////////////////
110-
auto PipelineCache::saveCache() -> void {
110+
auto PipelineCache::save_cache() -> void {
111111
auto data = m_vk_pipeline_cache->getData();
112112
m_serialized.guard.data_size = std::size(data);
113113
m_serialized.guard.data_hash = 0u;

0 commit comments

Comments
 (0)