summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2023-09-28 15:25:13 -0300
committerFrederico Linhares <fred@linhares.blue>2023-09-28 15:54:55 -0300
commit6899fac50a2992053e6eea627cb83da1d40e3d79 (patch)
tree0dfe0cb3df481582c5c7ad58de77fda080d0d8cf
parent607255a8fd901da7a3d6dcdafe9c0585f8c81521 (diff)
styl Rename ODO structures to UDO
* src/vk/uniform_data_object.hpp: I do not remember why I named these structs ODO. UDO makes more sense as they represents "uniform data objects."
-rw-r--r--src/vk/graphics_pipeline_2d_solid.cpp4
-rw-r--r--src/vk/graphics_pipeline_2d_solid_layout.cpp4
-rw-r--r--src/vk/graphics_pipeline_2d_wired.cpp10
-rw-r--r--src/vk/graphics_pipeline_2d_wired_layout.cpp8
-rw-r--r--src/vk/graphics_pipeline_3d.cpp16
-rw-r--r--src/vk/graphics_pipeline_3d_skeletal.cpp22
-rw-r--r--src/vk/renderer.cpp4
-rw-r--r--src/vk/skeletal_model.cpp4
-rw-r--r--src/vk/static_model.cpp4
-rw-r--r--src/vk/uniform_data_object.hpp18
-rw-r--r--src/vk/view_2d.cpp8
-rw-r--r--src/vk/view_3d.cpp8
12 files changed, 56 insertions, 54 deletions
diff --git a/src/vk/graphics_pipeline_2d_solid.cpp b/src/vk/graphics_pipeline_2d_solid.cpp
index 13800dc..d7f2b17 100644
--- a/src/vk/graphics_pipeline_2d_solid.cpp
+++ b/src/vk/graphics_pipeline_2d_solid.cpp
@@ -324,11 +324,11 @@ GraphicsPipeline2DSolid::draw(
draw_command_buffer, 0, 1, &sprite_to_draw.sprite->vertex_buffer->buffer,
offsets);
- ODOVector4D position{sprite_to_draw.position};
+ UDOVector4D position{sprite_to_draw.position};
vkCmdPushConstants(
draw_command_buffer,
cg_core.vk_graphics_pipeline_2d_solid_layout->pipeline,
- VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(ODOVector4D), &position);
+ VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(UDOVector4D), &position);
vkCmdDraw(draw_command_buffer, Sprite::vertex_count, 1, 0, 0);
}
diff --git a/src/vk/graphics_pipeline_2d_solid_layout.cpp b/src/vk/graphics_pipeline_2d_solid_layout.cpp
index 0ed41d0..e6c871f 100644
--- a/src/vk/graphics_pipeline_2d_solid_layout.cpp
+++ b/src/vk/graphics_pipeline_2d_solid_layout.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 Frederico de Oliveira Linhares
+ * Copyright 2022-2023 Frederico de Oliveira Linhares
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -111,7 +111,7 @@ load_pipeline(void *obj)
std::array<VkPushConstantRange, 1> push_constants;
push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
push_constants[0].offset = 0;
- push_constants[0].size = sizeof(VK::ODOVector4D);
+ push_constants[0].size = sizeof(VK::UDOVector4D);
VkPipelineLayoutCreateInfo pipeline_layout_info{};
pipeline_layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
diff --git a/src/vk/graphics_pipeline_2d_wired.cpp b/src/vk/graphics_pipeline_2d_wired.cpp
index 3247b78..51431b4 100644
--- a/src/vk/graphics_pipeline_2d_wired.cpp
+++ b/src/vk/graphics_pipeline_2d_wired.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 Frederico de Oliveira Linhares
+ * Copyright 2022-2023 Frederico de Oliveira Linhares
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -332,16 +332,16 @@ GraphicsPipeline2DWired::draw(
{
auto &rect{view->rectangles_to_draw[current_frame][i]};
- ODOVector4D position{rect.position};
- ODOVector3D color{rect.color};
+ UDOVector4D position{rect.position};
+ UDOVector3D color{rect.color};
vkCmdPushConstants(
draw_command_buffer,
cg_core.vk_graphics_pipeline_2d_wired_layout->pipeline,
- VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(ODOVector4D), &position);
+ VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(UDOVector4D), &position);
vkCmdPushConstants(
draw_command_buffer,
cg_core.vk_graphics_pipeline_2d_wired_layout->pipeline,
- VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(ODOVector4D), sizeof(ODOVector3D),
+ VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(UDOVector4D), sizeof(UDOVector3D),
&color);
vkCmdDrawIndexed(
draw_command_buffer, Rectangle::VertexCount, 1, 0, 0, 0);
diff --git a/src/vk/graphics_pipeline_2d_wired_layout.cpp b/src/vk/graphics_pipeline_2d_wired_layout.cpp
index 8e06641..3f259e3 100644
--- a/src/vk/graphics_pipeline_2d_wired_layout.cpp
+++ b/src/vk/graphics_pipeline_2d_wired_layout.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 Frederico de Oliveira Linhares
+ * Copyright 2022-2023 Frederico de Oliveira Linhares
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,11 +74,11 @@ load_pipeline(void *obj)
std::array<VkPushConstantRange, 2> push_constants;
push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
push_constants[0].offset = 0;
- push_constants[0].size = sizeof(VK::ODOVector4D);
+ push_constants[0].size = sizeof(VK::UDOVector4D);
push_constants[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
- push_constants[1].offset = sizeof(VK::ODOVector4D);
- push_constants[1].size = sizeof(VK::ODOVector3D);
+ push_constants[1].offset = sizeof(VK::UDOVector4D);
+ push_constants[1].size = sizeof(VK::UDOVector3D);
VkPipelineLayoutCreateInfo pipeline_layout_info{};
pipeline_layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
diff --git a/src/vk/graphics_pipeline_3d.cpp b/src/vk/graphics_pipeline_3d.cpp
index 355509e..f96b082 100644
--- a/src/vk/graphics_pipeline_3d.cpp
+++ b/src/vk/graphics_pipeline_3d.cpp
@@ -38,7 +38,7 @@ load_world_vert_uniform_buffer(void *obj)
self->ub_world_vert.reserve(cg_core.vk_swapchain->images_count);
for(auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
self->ub_world_vert.emplace_back(
- cg_core.vk_device_with_swapchain, sizeof(VK::ODOWorld3D_Vert));
+ cg_core.vk_device_with_swapchain, sizeof(VK::UDOWorld3D_Vert));
}
catch(const std::exception& e)
{
@@ -64,7 +64,7 @@ load_world_frag_uniform_buffer(void *obj)
self->ub_world_frag.reserve(cg_core.vk_swapchain->images_count);
for(auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
self->ub_world_frag.emplace_back(
- cg_core.vk_device_with_swapchain, sizeof(VK::ODOWorld3D_Frag));
+ cg_core.vk_device_with_swapchain, sizeof(VK::UDOWorld3D_Frag));
}
catch(const std::exception& e)
{
@@ -148,12 +148,12 @@ load_resources_to_descriptor_sets(void *obj)
VkDescriptorBufferInfo world_vert_info{};
world_vert_info.buffer = self->ub_world_vert[i].buffer;
world_vert_info.offset = 0;
- world_vert_info.range = sizeof(VK::ODOWorld3D_Vert);
+ world_vert_info.range = sizeof(VK::UDOWorld3D_Vert);
VkDescriptorBufferInfo world_frag_info{};
world_frag_info.buffer = self->ub_world_frag[i].buffer;
world_frag_info.offset = 0;
- world_frag_info.range = sizeof(VK::ODOWorld3D_Frag);
+ world_frag_info.range = sizeof(VK::UDOWorld3D_Frag);
std::array<VkWriteDescriptorSet, 2> write_descriptors{};
write_descriptors[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@@ -596,14 +596,14 @@ GraphicsPipeline3D::draw(
vkCmdDrawIndexed(
draw_command_buffer, static_mesh->index_count, 1, 0, 0, 0);
- VK::ODOStaticModel odo_static_model{};
- odo_static_model.base_matrix = base_matrix;
- instance->uniform_buffers[image_index].copy_data(&odo_static_model);
+ VK::UDOStaticModel udo_static_model{};
+ udo_static_model.base_matrix = base_matrix;
+ instance->uniform_buffers[image_index].copy_data(&udo_static_model);
}
}
{ // Update view uniform buffers
- VK::ODOView3D ubo_view_3d{};
+ VK::UDOView3D ubo_view_3d{};
// View matrix.
ubo_view_3d.view = glm::mat4{1.0f};
diff --git a/src/vk/graphics_pipeline_3d_skeletal.cpp b/src/vk/graphics_pipeline_3d_skeletal.cpp
index 3e1db66..43f21d6 100644
--- a/src/vk/graphics_pipeline_3d_skeletal.cpp
+++ b/src/vk/graphics_pipeline_3d_skeletal.cpp
@@ -38,7 +38,7 @@ load_world_vert_uniform_buffer(void *obj)
self->ub_world_vert.reserve(cg_core.vk_swapchain->images_count);
for(auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
self->ub_world_vert.emplace_back(
- cg_core.vk_device_with_swapchain, sizeof(VK::ODOWorld3D_Vert));
+ cg_core.vk_device_with_swapchain, sizeof(VK::UDOWorld3D_Vert));
}
catch(const std::exception& e)
{
@@ -64,7 +64,7 @@ load_world_frag_uniform_buffer(void *obj)
self->ub_world_frag.reserve(cg_core.vk_swapchain->images_count);
for(auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
self->ub_world_frag.emplace_back(
- cg_core.vk_device_with_swapchain, sizeof(VK::ODOWorld3D_Frag));
+ cg_core.vk_device_with_swapchain, sizeof(VK::UDOWorld3D_Frag));
}
catch(const std::exception& e)
{
@@ -148,12 +148,12 @@ load_resources_to_descriptor_sets(void *obj)
VkDescriptorBufferInfo world_vert_info{};
world_vert_info.buffer = self->ub_world_vert[i].buffer;
world_vert_info.offset = 0;
- world_vert_info.range = sizeof(VK::ODOWorld3D_Vert);
+ world_vert_info.range = sizeof(VK::UDOWorld3D_Vert);
VkDescriptorBufferInfo world_frag_info{};
world_frag_info.buffer = self->ub_world_frag[i].buffer;
world_frag_info.offset = 0;
- world_frag_info.range = sizeof(VK::ODOWorld3D_Frag);
+ world_frag_info.range = sizeof(VK::UDOWorld3D_Frag);
std::array<VkWriteDescriptorSet, 2> write_descriptors{};
write_descriptors[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@@ -606,18 +606,18 @@ GraphicsPipeline3DSkeletal::draw(
vkCmdDrawIndexed(
draw_command_buffer, skeletal_mesh->index_count, 1, 0, 0, 0);
- VK::ODOSkeletalModel odo_skeletal_model{};
+ VK::UDOSkeletalModel udo_skeletal_model{};
instance->tick(cg_core.delta_time);
- odo_skeletal_model.base_matrix = base_matrix;
+ udo_skeletal_model.base_matrix = base_matrix;
std::copy(instance->bone_transforms.begin(),
instance->bone_transforms.end(),
- odo_skeletal_model.bone_matrices);
- instance->uniform_buffers[image_index].copy_data(&odo_skeletal_model);
+ udo_skeletal_model.bone_matrices);
+ instance->uniform_buffers[image_index].copy_data(&udo_skeletal_model);
}
}
{ // Update view uniform buffers
- VK::ODOView3D ubo_view_3d{};
+ VK::UDOView3D ubo_view_3d{};
// View matrix.
ubo_view_3d.view = glm::mat4{1.0f};
@@ -642,11 +642,11 @@ GraphicsPipeline3DSkeletal::draw(
// TODO: Do not update this for each view. All views use the same data.
{ // Update world uniform buffer
- ODOWorld3D_Vert ubo_world_3d_vert{};
+ UDOWorld3D_Vert ubo_world_3d_vert{};
ubo_world_3d_vert.ambient_light_color = glm::vec4{0.25, 0.25, 0.25, 1.0};
this->ub_world_vert[image_index].copy_data(&ubo_world_3d_vert);
- ODOWorld3D_Frag ubo_world_3d_frag{};
+ UDOWorld3D_Frag ubo_world_3d_frag{};
ubo_world_3d_frag.directional_light_direction =
glm::vec3{-0.57735, 0.57735, -0.57735};
ubo_world_3d_frag.directional_light_color = glm::vec4{0.8, 0.8, 0.8, 1.0};
diff --git a/src/vk/renderer.cpp b/src/vk/renderer.cpp
index b886175..c7eda2e 100644
--- a/src/vk/renderer.cpp
+++ b/src/vk/renderer.cpp
@@ -209,13 +209,13 @@ Renderer::draw()
clear_values[1].depthStencil = {1.0f, 0};
{ // Update world uniform buffer
- ODOWorld3D_Vert ubo_world_3d_vert{};
+ UDOWorld3D_Vert ubo_world_3d_vert{};
ubo_world_3d_vert.ambient_light_color =
glm::vec4{0.25, 0.25, 0.25, 1.0};
cg_core.vk_graphics_pipeline_3d->ub_world_vert[image_index].copy_data(
&ubo_world_3d_vert);
- ODOWorld3D_Frag ubo_world_3d_frag{};
+ UDOWorld3D_Frag ubo_world_3d_frag{};
ubo_world_3d_frag.directional_light_direction =
glm::vec3{-0.57735, 0.57735, -0.57735};
ubo_world_3d_frag.directional_light_color =
diff --git a/src/vk/skeletal_model.cpp b/src/vk/skeletal_model.cpp
index 8528535..e7ede6d 100644
--- a/src/vk/skeletal_model.cpp
+++ b/src/vk/skeletal_model.cpp
@@ -32,7 +32,7 @@ load_uniform_buffers(void *obj)
self->uniform_buffers.reserve(cg_core.vk_swapchain->images_count);
for(auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
self->uniform_buffers.emplace_back(
- cg_core.vk_device_with_swapchain, sizeof(VK::ODOSkeletalModel));
+ cg_core.vk_device_with_swapchain, sizeof(VK::UDOSkeletalModel));
}
catch(const std::exception& e)
{
@@ -117,7 +117,7 @@ load_buffers_to_descriptor_sets(void *obj)
VkDescriptorBufferInfo buffer_info{};
buffer_info.buffer = self->uniform_buffers[i].buffer;
buffer_info.offset = 0;
- buffer_info.range = sizeof(VK::ODOSkeletalModel);
+ buffer_info.range = sizeof(VK::UDOSkeletalModel);
VkDescriptorImageInfo image_info{};
image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
diff --git a/src/vk/static_model.cpp b/src/vk/static_model.cpp
index bf1f0d3..b1c44fc 100644
--- a/src/vk/static_model.cpp
+++ b/src/vk/static_model.cpp
@@ -32,7 +32,7 @@ load_uniform_buffers(void *obj)
self->uniform_buffers.reserve(cg_core.vk_swapchain->images_count);
for(auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
self->uniform_buffers.emplace_back(
- cg_core.vk_device_with_swapchain, sizeof(VK::ODOStaticModel));
+ cg_core.vk_device_with_swapchain, sizeof(VK::UDOStaticModel));
}
catch(const std::exception& e)
{
@@ -117,7 +117,7 @@ load_buffers_to_descriptor_sets(void *obj)
VkDescriptorBufferInfo buffer_info{};
buffer_info.buffer = self->uniform_buffers[i].buffer;
buffer_info.offset = 0;
- buffer_info.range = sizeof(VK::ODOStaticModel);
+ buffer_info.range = sizeof(VK::UDOStaticModel);
VkDescriptorImageInfo image_info{};
image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
diff --git a/src/vk/uniform_data_object.hpp b/src/vk/uniform_data_object.hpp
index 4ee4e73..de69655 100644
--- a/src/vk/uniform_data_object.hpp
+++ b/src/vk/uniform_data_object.hpp
@@ -23,45 +23,47 @@
namespace VK
{
-struct ODOView2D
+// UDO = "uniform data object"
+
+struct UDOView2D
{
glm::mat4 proj;
};
-struct ODOView3D
+struct UDOView3D
{
glm::mat4 view;
glm::mat4 proj;
};
-struct ODOWorld3D_Vert
+struct UDOWorld3D_Vert
{
glm::vec4 ambient_light_color;
};
-struct ODOWorld3D_Frag
+struct UDOWorld3D_Frag
{
glm::vec3 directional_light_direction;
glm::vec4 directional_light_color;
};
-struct ODOStaticModel
+struct UDOStaticModel
{
glm::mat4 base_matrix;
};
-struct ODOSkeletalModel
+struct UDOSkeletalModel
{
glm::mat4 base_matrix;
glm::mat4 bone_matrices[SKELETAL_MESH_MAX_NUM_OF_BONES];
};
-struct ODOVector4D
+struct UDOVector4D
{
glm::vec4 vector;
};
-struct ODOVector3D
+struct UDOVector3D
{
glm::vec3 vectors;
};
diff --git a/src/vk/view_2d.cpp b/src/vk/view_2d.cpp
index eb19d9c..799327f 100644
--- a/src/vk/view_2d.cpp
+++ b/src/vk/view_2d.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 Frederico de Oliveira Linhares
+ * Copyright 2022-2023 Frederico de Oliveira Linhares
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ load_2d_uniform_buffer(void *obj)
self->ub_2d.reserve(cg_core.vk_swapchain->images_count);
for(auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
self->ub_2d.emplace_back(
- cg_core.vk_device_with_swapchain, sizeof(VK::ODOView2D));
+ cg_core.vk_device_with_swapchain, sizeof(VK::UDOView2D));
}
catch(const std::exception& e)
{
@@ -82,7 +82,7 @@ load_resources_to_descriptor_sets_2d(void *obj)
VkDescriptorBufferInfo view_2d_info{};
view_2d_info.buffer = self->ub_2d[i].buffer;
view_2d_info.offset = 0;
- view_2d_info.range = sizeof(VK::ODOView2D);
+ view_2d_info.range = sizeof(VK::UDOView2D);
std::array<VkWriteDescriptorSet, 1> write_descriptors{};
write_descriptors[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@@ -99,7 +99,7 @@ load_resources_to_descriptor_sets_2d(void *obj)
cg_core.vk_device_with_swapchain->device, write_descriptors.size(),
write_descriptors.data(), 0, nullptr);
- VK::ODOView2D ubo_view_2d;
+ VK::UDOView2D ubo_view_2d;
ubo_view_2d.proj = glm::ortho(
0.0f, self->projection_width,
0.0f, self->projection_height,
diff --git a/src/vk/view_3d.cpp b/src/vk/view_3d.cpp
index 66e1d34..eb2421e 100644
--- a/src/vk/view_3d.cpp
+++ b/src/vk/view_3d.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 Frederico de Oliveira Linhares
+ * Copyright 2022-2023 Frederico de Oliveira Linhares
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ load_3d_uniform_buffer(void *obj)
self->ub_3d.reserve(cg_core.vk_swapchain->images_count);
for(auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
self->ub_3d.emplace_back(
- cg_core.vk_device_with_swapchain, sizeof(VK::ODOView3D));
+ cg_core.vk_device_with_swapchain, sizeof(VK::UDOView3D));
}
catch(const std::exception& e)
{
@@ -82,7 +82,7 @@ load_resources_to_descriptor_sets_3d(void *obj)
VkDescriptorBufferInfo view_3d_info{};
view_3d_info.buffer = self->ub_3d[i].buffer;
view_3d_info.offset = 0;
- view_3d_info.range = sizeof(VK::ODOView3D);
+ view_3d_info.range = sizeof(VK::UDOView3D);
std::array<VkWriteDescriptorSet, 1> write_descriptors{};
write_descriptors[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@@ -99,7 +99,7 @@ load_resources_to_descriptor_sets_3d(void *obj)
cg_core.vk_device_with_swapchain->device, write_descriptors.size(),
write_descriptors.data(), 0, nullptr);
- VK::ODOView3D ubo_view_3d;
+ VK::UDOView3D ubo_view_3d;
ubo_view_3d.proj = glm::ortho(
0.0f, self->region.z,
0.0f, self->region.w,