Skip to content

Commit

Permalink
Rename anonymous-namespace functions
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Apr 19, 2023
1 parent 10dda5a commit 8827952
Show file tree
Hide file tree
Showing 22 changed files with 205 additions and 204 deletions.
12 changes: 6 additions & 6 deletions src/core/engine/backends/vulkan_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace glow {
namespace {

[[nodiscard]] auto select_gpu() -> VkPhysicalDevice
[[nodiscard]] auto _select_gpu() -> VkPhysicalDevice
{
GLOW_ASSERT(vk::get_instance() != VK_NULL_HANDLE);
GLOW_ASSERT(vk::get_surface() != VK_NULL_HANDLE);
Expand All @@ -42,7 +42,7 @@ namespace {
return gpu;
}

[[nodiscard]] auto create_render_pass(const VkFormat swapchain_image_format)
[[nodiscard]] auto _create_render_pass(const VkFormat swapchain_image_format)
-> vk::RenderPassInfo
{
vk::RenderPassBuilder builder;
Expand Down Expand Up @@ -76,7 +76,7 @@ namespace {
return builder.build();
}

[[nodiscard]] auto create_graphics_command_pool() -> vk::CommandPoolPtr
[[nodiscard]] auto _create_graphics_command_pool() -> vk::CommandPoolPtr
{
const auto queue_family_indices =
vk::get_queue_family_indices(vk::get_gpu(), vk::get_surface());
Expand All @@ -96,15 +96,15 @@ VulkanBackend::VulkanBackend()
: mInstance {vk::create_instance()},
mDebugMessenger {kDebugBuild ? vk::create_debug_messenger() : nullptr},
mSurface {vk::create_surface()},
mGPU {select_gpu()},
mGPU {_select_gpu()},
mDevice {vk::create_device()},
mAllocator {vk::create_allocator()},
mSwapchain {},
mRenderPassInfo {create_render_pass(mSwapchain.get_image_format())},
mRenderPassInfo {_create_render_pass(mSwapchain.get_image_format())},
mSampler {vk::create_sampler(VK_SAMPLER_ADDRESS_MODE_REPEAT)},
mPipelineCache {vk::create_pipeline_cache()},
mImGuiData {},
mGraphicsCommandPool {create_graphics_command_pool()}
mGraphicsCommandPool {_create_graphics_command_pool()}
{
create_shading_pipeline();
create_frame_data();
Expand Down
4 changes: 2 additions & 2 deletions src/core/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace glow {
namespace {

[[nodiscard]] auto determine_refresh_rate() -> float64
[[nodiscard]] auto _determine_refresh_rate() -> float64
{
SDL_DisplayMode mode {};
if (SDL_GetDesktopDisplayMode(0, &mode) == 0) {
Expand All @@ -42,7 +42,7 @@ Engine::Engine(const GraphicsAPI api)
: mInitializer {api},
mWindow {mInitializer.get_window().get_handle()},
mCounterFreq(static_cast<float64>(SDL_GetPerformanceFrequency())),
mFixedDelta {1.0 / determine_refresh_rate()}
mFixedDelta {1.0 / _determine_refresh_rate()}
{
spdlog::debug("[Engine] Counter frequency: {:L}", mCounterFreq);
spdlog::debug("[Engine] Fixed delta: {:.4f}", mFixedDelta);
Expand Down
19 changes: 10 additions & 9 deletions src/core/graphics/opengl/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace glow::gl {
namespace {

[[nodiscard]] auto create_texture(TextureCache& cache, Path path) -> Maybe<uint>
[[nodiscard]] auto _create_texture(TextureCache& cache, Path path) -> Maybe<uint>
{
if (const auto iter = cache.textures.find(path); iter != cache.textures.end()) {
return iter->second.get_id();
Expand All @@ -35,9 +35,9 @@ namespace {
return kNothing;
}

[[nodiscard]] auto create_material(Scene& scene,
const MaterialData& material_data,
const Path& model_dir) -> Entity
[[nodiscard]] auto _create_material(Scene& scene,
const MaterialData& material_data,
const Path& model_dir) -> Entity
{
auto& texture_cache = scene.get<TextureCache>();

Expand All @@ -46,12 +46,12 @@ namespace {

if (material_data.diffuse_tex.has_value()) {
material.diffuse_tex =
create_texture(texture_cache, model_dir / *material_data.diffuse_tex);
_create_texture(texture_cache, model_dir / *material_data.diffuse_tex);
}

if (material_data.specular_tex.has_value()) {
material.specular_tex =
create_texture(texture_cache, model_dir / *material_data.specular_tex);
_create_texture(texture_cache, model_dir / *material_data.specular_tex);
}

material.ambient = material_data.ambient;
Expand All @@ -62,7 +62,7 @@ namespace {
return material_entity;
}

[[nodiscard]] auto create_mesh(const MeshData& mesh_data, const Entity material_entity)
[[nodiscard]] auto _create_mesh(const MeshData& mesh_data, const Entity material_entity)
-> Mesh
{
Mesh mesh;
Expand Down Expand Up @@ -104,13 +104,14 @@ void assign_model(Scene& scene, const Entity entity, const Path& path)
material_entities.reserve(model_data->materials.size());

for (const auto& [material_id, material_data] : model_data->materials) {
const auto material_entity = create_material(scene, material_data, model_data->dir);
const auto material_entity =
_create_material(scene, material_data, model_data->dir);
material_entities[material_id] = material_entity;
}

for (const auto& mesh_data : model_data->meshes) {
const auto material_entity = material_entities.at(mesh_data.material_id);
model.meshes.push_back(create_mesh(mesh_data, material_entity));
model.meshes.push_back(_create_mesh(mesh_data, material_entity));
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/core/graphics/opengl/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
namespace glow::gl {
namespace {

void compile_and_link_program(Program& program,
const char* vert_path,
const char* frag_path)
void _compile_and_link_program(Program& program,
const char* vert_path,
const char* frag_path)
{
program.load_shader_files(vert_path, frag_path).check("Compilation error");
program.link().check("Link error");
Expand Down Expand Up @@ -57,19 +57,19 @@ void Renderer::init_uniform_buffers()

void Renderer::load_environment_program()
{
compile_and_link_program(mEnvProgram,
"assets/shaders/gl/environment.vert",
"assets/shaders/gl/environment.frag");
_compile_and_link_program(mEnvProgram,
"assets/shaders/gl/environment.vert",
"assets/shaders/gl/environment.frag");

mEnvProgram.set_uniform("uEnvTexture", 0).check("uEnvTexture");
mEnvProgram.set_uniform_block_binding("EnvironmentBuffer", 0).check("EnvBuffer UBO");
}

void Renderer::load_shading_program()
{
compile_and_link_program(mShadingProgram,
"assets/shaders/gl/shading.vert",
"assets/shaders/gl/shading.frag");
_compile_and_link_program(mShadingProgram,
"assets/shaders/gl/shading.vert",
"assets/shaders/gl/shading.frag");

mShadingProgram.set_uniform("uMaterialDiffuseTex", 5).check("uMaterialDiffuseTex");
mShadingProgram.set_uniform_block_binding("MatrixBuffer", 0).check("Matrix UBO");
Expand All @@ -78,9 +78,9 @@ void Renderer::load_shading_program()

void Renderer::load_framebuffer_program()
{
compile_and_link_program(mFramebufferProgram,
"assets/shaders/gl/framebuffer.vert",
"assets/shaders/gl/framebuffer.frag");
_compile_and_link_program(mFramebufferProgram,
"assets/shaders/gl/framebuffer.vert",
"assets/shaders/gl/framebuffer.frag");

mFramebufferProgram.set_uniform("uFramebuffer", 0).check("uFramebuffer");
mFramebufferProgram.set_uniform_block_binding("Options", 0)
Expand Down
30 changes: 15 additions & 15 deletions src/core/graphics/opengl/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ inline const HashMap<uint, const char*> kErrorMessages = {
{GL_STACK_OVERFLOW, "GL_STACK_OVERFLOW"},
};

[[nodiscard]] auto get_integer(const uint name) -> uint
[[nodiscard]] auto _get_integer(const uint name) -> uint
{
int id {};
glGetIntegerv(name, &id);
return static_cast<uint>(id);
}

[[nodiscard]] auto get_string_length(const GLubyte* str) -> usize
[[nodiscard]] auto _get_string_length(const GLubyte* str) -> usize
{
const GLubyte* ptr = str;

Expand All @@ -42,13 +42,13 @@ inline const HashMap<uint, const char*> kErrorMessages = {
return static_cast<usize>(ptr - str);
}

[[nodiscard]] auto to_string(const GLubyte* raw_str) -> String
[[nodiscard]] auto _to_string(const GLubyte* raw_str) -> String
{
if (!raw_str) {
return String {};
}

const auto length = get_string_length(raw_str);
const auto length = _get_string_length(raw_str);

String result;
result.resize(length);
Expand Down Expand Up @@ -129,57 +129,57 @@ auto convert_buffer_usage(const BufferUsage usage) -> uint

auto get_bound_vertex_array() -> uint
{
return get_integer(GL_VERTEX_ARRAY_BINDING);
return _get_integer(GL_VERTEX_ARRAY_BINDING);
}

auto get_bound_vertex_buffer() -> uint
{
return get_integer(GL_ARRAY_BUFFER_BINDING);
return _get_integer(GL_ARRAY_BUFFER_BINDING);
}

auto get_bound_index_buffer() -> uint
{
return get_integer(GL_ELEMENT_ARRAY_BUFFER_BINDING);
return _get_integer(GL_ELEMENT_ARRAY_BUFFER_BINDING);
}

auto get_bound_uniform_buffer() -> uint
{
return get_integer(GL_UNIFORM_BUFFER_BINDING);
return _get_integer(GL_UNIFORM_BUFFER_BINDING);
}

auto get_bound_framebuffer() -> uint
{
return get_integer(GL_FRAMEBUFFER_BINDING);
return _get_integer(GL_FRAMEBUFFER_BINDING);
}

auto get_bound_texture() -> uint
{
return get_integer(GL_TEXTURE_BINDING_2D);
return _get_integer(GL_TEXTURE_BINDING_2D);
}

auto get_bound_program() -> uint
{
return get_integer(GL_CURRENT_PROGRAM);
return _get_integer(GL_CURRENT_PROGRAM);
}

auto get_renderer_name() -> String
{
return to_string(glGetString(GL_RENDERER));
return _to_string(glGetString(GL_RENDERER));
}

auto get_vendor_name() -> String
{
return to_string(glGetString(GL_VENDOR));
return _to_string(glGetString(GL_VENDOR));
}

auto get_version() -> String
{
return to_string(glGetString(GL_VERSION));
return _to_string(glGetString(GL_VERSION));
}

auto get_glsl_version() -> String
{
return to_string(glGetString(GL_SHADING_LANGUAGE_VERSION));
return _to_string(glGetString(GL_SHADING_LANGUAGE_VERSION));
}

} // namespace glow::gl
10 changes: 5 additions & 5 deletions src/core/graphics/vulkan/command_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace glow::vk {
namespace {

void allocate_command_buffers_helper(VkCommandPool cmd_pool,
const uint32 count,
VkCommandBuffer* out_buffers)
void _allocate_command_buffers_helper(VkCommandPool cmd_pool,
const uint32 count,
VkCommandBuffer* out_buffers)
{
GLOW_ASSERT(out_buffers != nullptr);

Expand Down Expand Up @@ -57,15 +57,15 @@ auto allocate_command_buffers(VkCommandPool cmd_pool, const uint32 count)
Vector<VkCommandBuffer> cmd_buffers;
cmd_buffers.resize(count);

allocate_command_buffers_helper(cmd_pool, count, cmd_buffers.data());
_allocate_command_buffers_helper(cmd_pool, count, cmd_buffers.data());

return cmd_buffers;
}

auto allocate_command_buffer(VkCommandPool cmd_pool) -> VkCommandBuffer
{
VkCommandBuffer cmd_buffer = VK_NULL_HANDLE;
allocate_command_buffers_helper(cmd_pool, 1, &cmd_buffer);
_allocate_command_buffers_helper(cmd_pool, 1, &cmd_buffer);

return cmd_buffer;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/graphics/vulkan/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace glow::vk {
namespace {

void print_relevant_device_properties(VkPhysicalDevice gpu)
void _print_relevant_device_properties(VkPhysicalDevice gpu)
{
VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor_properties {};
push_descriptor_properties.sType =
Expand Down Expand Up @@ -123,7 +123,7 @@ auto create_device() -> DevicePtr
set_graphics_queue(graphics_queue);
set_presentation_queue(presentation_queue);

print_relevant_device_properties(get_gpu());
_print_relevant_device_properties(get_gpu());

return DevicePtr {device};
}
Expand Down
Loading

0 comments on commit 8827952

Please sign in to comment.