summaryrefslogtreecommitdiff
path: root/src/vk
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2023-09-27 15:19:02 -0300
committerFrederico Linhares <fred@linhares.blue>2023-09-27 15:19:02 -0300
commit607255a8fd901da7a3d6dcdafe9c0585f8c81521 (patch)
tree2cc8b89cbe71ef13a447d9cec5647701e979753b /src/vk
parent25bf78bfb4785e2cbed683cc56d3cec4271d8b5a (diff)
refa Remove redundant uniform buffer updates
* src/vk/graphics_pipeline_3d.cpp: Remove redundant uniform buffer updates * src/vk/renderer.cpp: Update world colors just once for each frame.
Diffstat (limited to 'src/vk')
-rw-r--r--src/vk/graphics_pipeline_3d.cpp13
-rw-r--r--src/vk/renderer.cpp17
2 files changed, 17 insertions, 13 deletions
diff --git a/src/vk/graphics_pipeline_3d.cpp b/src/vk/graphics_pipeline_3d.cpp
index 6639d99..355509e 100644
--- a/src/vk/graphics_pipeline_3d.cpp
+++ b/src/vk/graphics_pipeline_3d.cpp
@@ -625,19 +625,6 @@ GraphicsPipeline3D::draw(
view->ub_3d[image_index].copy_data(&ubo_view_3d);
}
-
- // TODO: Do not update this for each view. All views use the same data.
- { // Update world uniform buffer
- ODOWorld3D_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{};
- 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};
- this->ub_world_frag[image_index].copy_data(&ubo_world_3d_frag);
- }
}
}
diff --git a/src/vk/renderer.cpp b/src/vk/renderer.cpp
index b240cb9..b886175 100644
--- a/src/vk/renderer.cpp
+++ b/src/vk/renderer.cpp
@@ -19,6 +19,7 @@
#include <array>
#include "../core.hpp"
+#include "uniform_data_object.hpp"
namespace
{
@@ -207,6 +208,22 @@ Renderer::draw()
clear_values[0].color = {0.12f, 0.12f, 0.18f, 1.0f};
clear_values[1].depthStencil = {1.0f, 0};
+ { // Update world uniform buffer
+ ODOWorld3D_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{};
+ 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};
+ cg_core.vk_graphics_pipeline_3d->ub_world_frag[image_index].copy_data(
+ &ubo_world_3d_frag);
+ }
+
VkRenderPassBeginInfo render_pass_begin{};
render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
render_pass_begin.pNext = nullptr;