Skip to content

Commit 6917a0f

Browse files
committed
· Changes to issues raised by clang tidy
· Image allocation changes (WIP)
1 parent dfc9eae commit 6917a0f

Some content is hidden

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

61 files changed

+623
-213
lines changed

CMakeLists.txt

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.2.2)
2-
project (scener::root)
2+
project (scener)
33
enable_language (CXX)
44

55
# set (CMAKE_VERBOSE_MAKEFILE on)
@@ -37,7 +37,7 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -std=c++1z")
3737

3838
if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
3939
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-terminate")
40-
# "-Weverything -Wno-undef -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-nested-anon-types -Wno-gnu-anonymous-struct"
40+
# "-Weverything -Wno-undef -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-nested-anon-types -Wno-gnu-anonymous-struct"
4141
endif ()
4242

4343
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
@@ -50,11 +50,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
5050
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lc++ -lc++abi")
5151
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -lc++ -lc++abi")
5252

53-
# elseif ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" )
54-
# message ("-> GCC")
55-
# else ()
56-
# message ("-> unknown compiler ...")
57-
53+
elseif ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" )
54+
else ()
55+
message ("-> unknown compiler ...")
5856
endif ()
5957

6058
# SceneR
@@ -63,8 +61,8 @@ set (SCENER_LIB_DIRS ${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
6361
set (SCENER_LIBRARIES scener)
6462

6563
# global definitions
66-
set (VK_USE_PLATFORM_WAYLAND_KHR "1")
67-
# set (VK_USE_PLATFORM_XCB_KHR "1")
64+
# set (VK_USE_PLATFORM_WAYLAND_KHR "1")
65+
set (VK_USE_PLATFORM_XCB_KHR "1")
6866

6967
# project subdirectories
7068
add_subdirectory (source)

README.markdown

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ These instructions will get you a copy of the project up and running on your loc
88

99
### Prerequisites
1010

11-
| Name | Version |
12-
|--------------------------------------------|---------------|
13-
| C++ compiler | Clang 4.0 |
14-
| C compiler | Clang 4.0 |
15-
| [**libC++**](http://libcxx.llvm.org/) | 4.0 (Linux) |
11+
| Name | Version |
12+
|---------------|---------------|
13+
| C++ compiler | Clang / GCC |
14+
| C compiler | Clang / GCC |
1615

1716
```
1817
sudo apt-get install clang libc++ lldb git

externals/scener-math

Submodule scener-math updated from 8e9d60c to 098fded

externals/vulkan-memory-allocator

source-tidy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
#
55
# clang-format accepts multiple files during one run, but let's limit it to 12
66
# here so we (hopefully) avoid excessive memory usage.
7-
find ./source \( -name \*.c -or -name \*.cpp -or -name \*.cc \)|xargs -n1 -P4 clang-tidy-3.9 -header-filter=source/.* -checks=cppcoreguidelines-*,readability-*
7+
find ./source \( -name \*.c -or -name \*.cpp -or -name \*.cc \)|xargs -n1 -P4 clang-tidy-5.0 -p=./build -header-filter=source/.* -checks=cppcoreguidelines-*,readability-*

source/samples/vulkan-sample/main.cpp

+23-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
#include "scener/graphics/vulkan/adapter.hpp"
5+
#include "scener/graphics/vulkan/image_options.hpp"
6+
#include "scener/graphics/vulkan/image.hpp"
7+
#include "scener/graphics/vulkan/memory_allocator.hpp"
8+
#include "scener/graphics/vulkan/physical_device.hpp"
59
#include "scener/graphics/vulkan/logical_device.hpp"
6-
#include "scener/graphics/vulkan/platform.hpp"
10+
#include "scener/graphics/vulkan/surface.hpp"
11+
#include "scener/graphics/texture_target.hpp"
712

813
using scener::graphics::vulkan::adapter;
914
using scener::graphics::vulkan::display_surface;
15+
using scener::graphics::vulkan::image_options;
16+
using scener::graphics::vulkan::image;
1017
using scener::graphics::vulkan::render_surface;
18+
using scener::graphics::texture_target;
1119

1220
int main()
1321
{
@@ -29,10 +37,21 @@ int main()
2937
// Create the Swap Chain
3038
ldevice.create_swap_chain(rsurface);
3139

32-
// Create the render targets
33-
ldevice.create_render_targets(dsurface.rect().size());
40+
// Try to allocate an image
41+
image_options options = {
42+
vk::ImageUsageFlagBits::eColorAttachment
43+
, texture_target::texture_2d
44+
, { 1600, 900, 1 }
45+
, 1
46+
};
47+
48+
auto image = ldevice.create_image(options);
3449

35-
dsurface.show();
50+
// Record present command buffers
51+
//ldevice.record_command_buffers();
52+
53+
// Create the render targets
54+
// ldevice.create_render_targets(dsurface.rect().size());
3655

3756
return 0;
3857
}

source/scener/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required (VERSION 3.2.2)
2-
project (scener)
2+
project (scener::framework)
33
enable_language (CXX)
44

55
# Vulkan

source/scener/content/content_manager.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace scener::content
4646

4747
auto stream = open_stream(assetname);
4848

49-
content_reader reader(assetname, this, *stream);
49+
content_reader reader(assetname, this, stream);
5050

5151
auto asset = reader.read_asset();
5252

@@ -60,13 +60,13 @@ namespace scener::content
6060
_resource_manager.clear();
6161
}
6262

63-
std::shared_ptr<file_stream> content_manager::open_stream(const std::string& assetname) noexcept
63+
file_stream content_manager::open_stream(const std::string& assetname) const noexcept
6464
{
6565
const auto filename = assetname + ".gltf";
6666
const auto path = scener::io::path::combine(_root_directory, filename);
6767

6868
Ensures(scener::io::file::exists(path));
6969

70-
return std::make_shared<file_stream>(path);
70+
return file_stream { path };
7171
}
7272
}

source/scener/content/content_manager.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace scener::content
4747
void unload() noexcept;
4848

4949
private:
50-
std::shared_ptr<io::file_stream> open_stream(const std::string& assetname) noexcept;
50+
io::file_stream open_stream(const std::string& assetname) const noexcept;
5151

5252
private:
5353
graphics::service_container* _service_provider;

source/scener/content/content_resource_manager.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace scener::content
6464
/// Clears the resource manager instance.
6565
void clear()
6666
{
67-
if (_resources.size() > 0)
67+
if (!_resources.empty())
6868
{
6969
_resources.clear();
7070
}

source/scener/content/dds/surface.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace scener::content::dds
1515
{
1616
Expects(scener::io::file::exists(filename));
1717

18-
file_stream stream(filename);
19-
header dds_header;
18+
auto stream = file_stream(filename);
19+
header dds_header = { };
2020
std::size_t block_size = 16;
2121

2222
Ensures(stream.length() >= sizeof dds_header);

source/scener/content/readers/technique_reader.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ namespace scener::content::readers
9090
}
9191

9292
const auto& parameter = effect->_parameters[it.key()];
93-
93+
9494
if (parameter == nullptr)
9595
{
9696
continue;
@@ -101,7 +101,7 @@ namespace scener::content::readers
101101
if (current.count(k_node) != 0)
102102
{
103103
// const auto nodeId = it.value()["node"].get<std::string>();
104-
104+
105105
// TODO: Read node reference
106106
// auto node = context.find_object<Node>(nodeId);
107107
// parameter->set_value<matrix4>(node->matrix);
@@ -167,7 +167,7 @@ namespace scener::content::readers
167167
}
168168

169169
void content_type_reader<effect_technique>::add_default_pass(content_reader* input
170-
, const nlohmann::json& node
170+
, const nlohmann::json& value
171171
, effect_technique* effect) const noexcept
172172
{
173173
auto gdservice = input->content_manager()->service_provider()->get_service<igraphics_device_service>();
@@ -181,27 +181,27 @@ namespace scener::content::readers
181181
pass->_parameters.push_back(param.second);
182182
}
183183

184-
read_pass_program(input, node[k_program].get<std::string>(), pass.get());
184+
read_pass_program(input, value[k_program].get<std::string>(), pass.get());
185185

186186
effect->_passes.push_back(pass);
187187
}
188188

189189
void content_type_reader<effect_technique>::read_pass_program(content_reader* input
190-
, const std::string& programName
191-
, effect_pass* effectPass) const noexcept
190+
, const std::string& name
191+
, effect_pass* pass) const noexcept
192192
{
193193
// Pass program
194-
effectPass->_program = input->read_object_instance<program>(programName);
194+
pass->_program = input->read_object_instance<program>(name);
195195

196196
// Uniforms
197-
auto offsets = effectPass->_program->get_uniform_offsets();
197+
auto offsets = pass->_program->get_uniform_offsets();
198198

199-
for (const auto& parameter : effectPass->_parameters)
199+
for (const auto& parameter : pass->_parameters)
200200
{
201201
if (offsets.find(parameter->_uniform_name) != offsets.end())
202202
{
203203
parameter->_offset = offsets[parameter->_uniform_name];
204-
parameter->_constant_buffer = effectPass->_program->constant_buffer();
204+
parameter->_constant_buffer = pass->_program->constant_buffer();
205205
}
206206
}
207207
}

source/scener/content/readers/technique_reader.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace scener::content::readers
3333

3434
void read_pass_program(content_reader* input, const std::string& name, graphics::effect_pass* pass) const noexcept;
3535

36-
void cache_parameters(graphics::effect_technique* effect) const noexcept;
36+
void cache_parameters(graphics::effect_technique* technique) const noexcept;
3737

3838
void describe_parameter(graphics::effect_parameter* parameter, std::int32_t type) const noexcept;
3939
};

source/scener/graphics/animation.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ namespace scener::graphics
1717
/// Stores keyframe based animations.
1818
class animation final
1919
{
20-
public:
21-
/// Initializes a new instance of the Animatin class.
22-
animation() = default;
23-
2420
public:
2521
/// Gets the current time of the animation.
2622
/// \returns the current time of the animation.

source/scener/graphics/blend_state.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ namespace scener::graphics
2727
/// \param device the graphics device associated with this blend state.
2828
blend_state(gsl::not_null<graphics_device*> device) noexcept;
2929

30-
/// Releases all resources being used by this BlendState.
31-
~blend_state() override = default;
32-
3330
public:
3431
/// Gets or sets the arithmetic operation when blending alpha values.
3532
blend_function alpha_blend_function { blend_function::add };

source/scener/graphics/bone.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ namespace scener::graphics
2323
public:
2424
typedef std::size_t index_type;
2525

26-
public:
27-
/// Initializes a new instance of the ModelBone class.
28-
bone() = default;
29-
3026
public:
3127
/// Gets the index of this bone in the Bones collection.
3228
/// \returns the index of this bone in the Bones collection.

source/scener/graphics/component.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ namespace scener::graphics
2424
/// \param renderer the renderer that owns the component.
2525
component(gsl::not_null<renderer*> renderer) noexcept;
2626

27-
/// Releases all resources being used by this component instance.
28-
~component() override = default;
29-
3027
public:
3128
/// Gets the Renderer associated with this Component.
3229
/// \returns a pointer to the Renderer instance associated with this Component.

source/scener/graphics/depth_stencil_state.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ namespace scener::graphics
2323
/// \param device the graphics device associated with this depth stencil state.
2424
depth_stencil_state(gsl::not_null<graphics_device*> device) noexcept;
2525

26-
/// Releases all resources being used by this DepthStencilState.
27-
~depth_stencil_state() override = default;
28-
2926
public:
3027
/// Gets or sets the stencil operation to perform if the stencil test passes and the depth-buffer
3128
/// test fails for a counterclockwise triangle.

source/scener/graphics/directional_light.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ namespace scener::graphics
1212
class directional_light final
1313
{
1414
public:
15-
/// Creates an instance of a light that projects its effect in a specified direction.
16-
/// This contructor creates an instance of a white light projected along a vector3 of value (0, 0, -1).
15+
/// Creates an instance of a light that projects its effect along a specified vector3 with a specified color.
1716
directional_light() noexcept;
1817

1918
/// Creates an instance of a light that projects its effect along a specified vector3 with a specified color.

source/scener/graphics/drawable_component.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ namespace scener::graphics
2323
/// \param renderer the renderer that owns the component.
2424
drawable_component(gsl::not_null<graphics::renderer*> renderer) noexcept;
2525

26-
/// Releases all resources being used by this DrawableComponent.
27-
~drawable_component() override = default;
28-
2926
public:
3027
/// The graphics device the drawable component is associated with.
3128
graphics_device* device() noexcept;

source/scener/graphics/effect_parameter.hpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@
1212
#include "scener/graphics/effect_parameter_type.hpp"
1313
#include "scener/math/matrix.hpp"
1414

15-
namespace scener::content::readers { template <typename T> class content_type_reader; }
15+
namespace scener::content::readers { template <typename T> class content_type_reader; }
1616
namespace scener::graphics::opengl { class constant_buffer; }
1717

1818
namespace scener::graphics
1919
{
2020
/// Represents an EffectTechnique parameter.
2121
class effect_parameter final
2222
{
23-
public:
24-
/// Initializes a new instance of the EffectParameter class.
25-
effect_parameter() = default;
26-
2723
public:
2824
/// Gets the number of columns in the parameter description.
2925
std::size_t column_count() const noexcept;

source/scener/graphics/effect_technique.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ namespace scener::graphics
3535
/// \param device the graphics device associated with this EffectTechnique.
3636
effect_technique(gsl::not_null<graphics_device*> device) noexcept;
3737

38-
/// Releases all resources being used by this EffectTechnique.
39-
~effect_technique() override = default;
40-
4138
public:
4239
/// Gets the material alpha which determines its transparency.
4340
/// Range is between 1 (fully opaque) and 0 (fully transparent).

source/scener/graphics/graphics_device_manager.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ namespace scener::graphics
2626
/// \param renderer the Renderer associated with this GraphicsDeviceManager.
2727
graphics_device_manager(gsl::not_null<renderer*> renderer) noexcept;
2828

29-
/// Releases all resources being used by this GraphicsDeviceManager.
30-
~graphics_device_manager() override = default;
31-
3229
public:
3330
/// Applies any changes to device-related propertie.
3431
void apply_changes() noexcept;

source/scener/graphics/index_buffer.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ namespace scener::graphics
3030
, component_type index_element_type
3131
, std::size_t index_count) noexcept;
3232

33-
/// Releases all resources being used by this IndexBuffer.
34-
~index_buffer() override = default;
35-
3633
public:
3734
/// Gets the number of indices in the buffer.
3835
/// \returns the number of indices.

source/scener/graphics/model_mesh.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ namespace scener::graphics
2121
/// Represents a mesh that is part of a Model.
2222
class model_mesh final
2323
{
24-
public:
25-
/// Initializes a new instance of the ModelMesh class.
26-
model_mesh() = default;
27-
2824
public:
2925
/// Gets the BoundingSphere that contains this mesh.
3026
/// \returns The BoundingSphere that contains this mesh.

0 commit comments

Comments
 (0)