diff options
author | Frederico Linhares <fred@linhares.blue> | 2025-07-14 15:00:52 -0300 |
---|---|---|
committer | Frederico Linhares <fred@linhares.blue> | 2025-07-14 15:00:52 -0300 |
commit | 0efc2fc6e7aeba281b2718157439f3e43c23d61a (patch) | |
tree | 80060f7ea35d80ce2e71240e029ee50e2f94c2bc /src | |
parent | 8bedf8a366cb6c1179bc89678c863517b9356d48 (diff) |
fixt Improve graphics
* src/blu_cat/gra/graphics_pipeline_2d_solid.cpp,
src/blu_cat/gra/graphics_pipeline_2d_wired.cpp: remove redundant
view port.
* src/blu_cat/gra/renderer.cpp: Add view port to a more efficient place.
Cleanup 2D images.
Diffstat (limited to 'src')
-rw-r--r-- | src/blu_cat/com/binary_writer.cpp | 4 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_solid.cpp | 19 | ||||
-rw-r--r-- | src/blu_cat/gra/graphics_pipeline_2d_wired.cpp | 18 | ||||
-rw-r--r-- | src/blu_cat/gra/renderer.cpp | 35 |
4 files changed, 31 insertions, 45 deletions
diff --git a/src/blu_cat/com/binary_writer.cpp b/src/blu_cat/com/binary_writer.cpp index 7af3b6d..fe06195 100644 --- a/src/blu_cat/com/binary_writer.cpp +++ b/src/blu_cat/com/binary_writer.cpp @@ -32,12 +32,12 @@ union IntAndFloat64bit{ } BinaryWriter::BinaryWriter(const char *file_path): - output{file_path, std::ios::binary} + output{file_path, std::ios::binary} { } BinaryWriter::BinaryWriter(const std::string &file_path): - BinaryWriter{file_path.c_str()} + BinaryWriter{file_path.c_str()} { } diff --git a/src/blu_cat/gra/graphics_pipeline_2d_solid.cpp b/src/blu_cat/gra/graphics_pipeline_2d_solid.cpp index 05dcbe1..0d72fc9 100644 --- a/src/blu_cat/gra/graphics_pipeline_2d_solid.cpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_solid.cpp @@ -238,25 +238,6 @@ GraphicsPipeline2DSolid::draw( const VkCommandBuffer draw_command_buffer, const size_t current_frame, const size_t next_frame, const uint32_t image_index) { - // TODO set viewport just once per view, not once per pipeline. - { // Set viewport - VkViewport vk_viewport{}; - vk_viewport.x = 0; - vk_viewport.y = 0; - vk_viewport.width = static_cast<float>(BluCat::INT::core.display_width); - vk_viewport.height = static_cast<float>(BluCat::INT::core.display_height); - vk_viewport.minDepth = 0.0f; - vk_viewport.maxDepth = 1.0f; - vkCmdSetViewport(draw_command_buffer, 0, 1, &vk_viewport); - - VkRect2D vk_scissor{}; - vk_scissor.offset.x = 0; - vk_scissor.offset.y = 0; - vk_scissor.extent.width = BluCat::INT::core.display_width; - vk_scissor.extent.height = BluCat::INT::core.display_height; - vkCmdSetScissor(draw_command_buffer, 0, 1, &vk_scissor); - } - vkCmdBindPipeline( draw_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, this->graphic_pipeline); diff --git a/src/blu_cat/gra/graphics_pipeline_2d_wired.cpp b/src/blu_cat/gra/graphics_pipeline_2d_wired.cpp index 1273c67..209dafd 100644 --- a/src/blu_cat/gra/graphics_pipeline_2d_wired.cpp +++ b/src/blu_cat/gra/graphics_pipeline_2d_wired.cpp @@ -250,24 +250,6 @@ GraphicsPipeline2DWired::draw( const VkCommandBuffer draw_command_buffer, const size_t current_frame, const size_t next_frame, const uint32_t image_index) { - // TODO set viewport just once per view, not once per pipeline. - { // Set viewport - VkViewport vk_viewport{}; - vk_viewport.x = 0; - vk_viewport.y = 0; - vk_viewport.width = static_cast<float>(BluCat::INT::core.display_width); - vk_viewport.height = static_cast<float>(BluCat::INT::core.display_height); - vk_viewport.minDepth = 0.0f; - vk_viewport.maxDepth = 1.0f; - vkCmdSetViewport(draw_command_buffer, 0, 1, &vk_viewport); - - VkRect2D vk_scissor{}; - vk_scissor.offset.x = 0; - vk_scissor.offset.y = 0; - vk_scissor.extent.width = BluCat::INT::core.display_width; - vk_scissor.extent.height = BluCat::INT::core.display_height; - vkCmdSetScissor(draw_command_buffer, 0, 1, &vk_scissor); - } // Draw rectangles { diff --git a/src/blu_cat/gra/renderer.cpp b/src/blu_cat/gra/renderer.cpp index 36b9925..eb11899 100644 --- a/src/blu_cat/gra/renderer.cpp +++ b/src/blu_cat/gra/renderer.cpp @@ -390,7 +390,7 @@ Renderer::draw() } } - vkCmdEndRenderPass(draw_command_buffer); + vkCmdEndRenderPass(draw_command_buffer); { // 2D render pass VkRenderPassBeginInfo render_pass_begin{}; @@ -406,12 +406,29 @@ Renderer::draw() render_pass_begin.clearValueCount = 0; render_pass_begin.pClearValues = nullptr; - vkCmdBeginRenderPass( - draw_command_buffer, &render_pass_begin, VK_SUBPASS_CONTENTS_INLINE); - + vkCmdBeginRenderPass( + draw_command_buffer, &render_pass_begin, VK_SUBPASS_CONTENTS_INLINE); } - { // 2D solid drawing + { // Set viewport + VkViewport vk_viewport{}; + vk_viewport.x = 0; + vk_viewport.y = 0; + vk_viewport.width = static_cast<float>(BluCat::INT::core.display_width); + vk_viewport.height = static_cast<float>(BluCat::INT::core.display_height); + vk_viewport.minDepth = 0.0f; + vk_viewport.maxDepth = 1.0f; + vkCmdSetViewport(draw_command_buffer, 0, 1, &vk_viewport); + + VkRect2D vk_scissor{}; + vk_scissor.offset.x = 0; + vk_scissor.offset.y = 0; + vk_scissor.extent.width = BluCat::INT::core.display_width; + vk_scissor.extent.height = BluCat::INT::core.display_height; + vkCmdSetScissor(draw_command_buffer, 0, 1, &vk_scissor); + } + + { // 2D solid drawing BluCat::INT::core.vk_graphics_pipeline_2d_solid->draw( draw_command_buffer, BluCat::INT::core.vk_swapchain->current_frame, next_frame, image_index); @@ -478,7 +495,9 @@ Renderer::draw() this->skeletal_models_to_draw[next_frame].clear(); this->static_models_to_draw[next_frame].clear(); this->sprites_3d_to_draw[next_frame].clear(); - BluCat::INT::core.vk_swapchain->current_frame = next_frame; + this->rectangles_to_draw[next_frame].clear(); + this->sprites_to_draw[next_frame].clear(); + BluCat::INT::core.vk_swapchain->current_frame = next_frame; } } else @@ -492,6 +511,10 @@ Renderer::draw() BluCat::INT::core.vk_swapchain->current_frame].clear(); this->sprites_to_draw[ BluCat::INT::core.vk_swapchain->current_frame].clear(); + this->rectangles_to_draw[ + BluCat::INT::core.vk_swapchain->current_frame].clear(); + this->sprites_to_draw[ + BluCat::INT::core.vk_swapchain->current_frame].clear(); } } |