-
Notifications
You must be signed in to change notification settings - Fork 6
Command buffers #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Command buffers #78
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b16a129
Rewritten vk_command_buffers from scratch
Fra1sse 77965d4
Linked CommandBuffers with VulkanEngine
Fra1sse 670bb55
Finalized CommandBuffers class
Fra1sse 7d591ad
Added private variables to the class
Fra1sse 379d381
Refactored VulkanEngine parameter to use references instead of pointers
Fra1sse 084a537
Merge branch 'main' into command_buffers
Fra1sse 5da77ad
Modified init_commands()
Fra1sse 923a402
abandoned
Fra1sse 4d74bbe
Merge branch 'main' into command_buffers
Fra1sse 6e0a5cc
merge main
Fra1sse ef85e1a
Refactor CommandBuffers class
Fra1sse cda46c8
small changes
Fra1sse 612af11
fix: fixed cycle var, deleted comment
Fra1sse a57145e
add explanatory comments to CommandBuffers class
Fra1sse e88469d
Clean up unnecessary braces and fix 'for' in vk_command_buffers.cpp
Fra1sse 14219ed
Fix merge conflicts from main
Fra1sse 60b6005
some changes
Fra1sse f7e0c9e
refactor: adjust Xenia's pr
Gr-i-niy 2464aef
Merge branch 'main' into command_buffers
Gr-i-niy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #include "graphics/vulkan/vk_command_buffers_container.h" | ||
| #include "graphics/vulkan/vk_engine.h" | ||
| #include "graphics/vulkan/vk_initializers.h" | ||
|
|
||
| CommandBuffersContainer::CommandBuffersContainer() { | ||
| // Initialize members - actual initialization happens in init_sync_structures | ||
| _immCommandBuffer = VK_NULL_HANDLE; | ||
| } | ||
|
|
||
| void CommandBuffersContainer::init_sync_structures(VulkanEngine* vk_engine) { | ||
| const VkFenceCreateInfo fenceCreateInfo = | ||
| vkinit::fence_create_info(VK_FENCE_CREATE_SIGNALED_BIT); | ||
| const VkSemaphoreCreateInfo semaphoreCreateInfo = | ||
| vkinit::semaphore_create_info(); | ||
|
|
||
| for (auto& _frame : _frames) { | ||
| VkFence renderFence; | ||
| VK_CHECK(vkCreateFence(vk_engine->_device, &fenceCreateInfo, nullptr, &renderFence)); | ||
| _frame._renderFence = std::make_unique<VulkanFence>(vk_engine->_device, renderFence); | ||
|
|
||
| VkSemaphore swapchainSemaphore, renderSemaphore; | ||
| VK_CHECK(vkCreateSemaphore(vk_engine->_device, &semaphoreCreateInfo, nullptr, &swapchainSemaphore)); | ||
| VK_CHECK(vkCreateSemaphore(vk_engine->_device, &semaphoreCreateInfo, nullptr, &renderSemaphore)); | ||
|
|
||
| _frame._swapchainSemaphore = std::make_unique<VulkanSemaphore>(vk_engine->_device, swapchainSemaphore); | ||
| _frame._renderSemaphore = std::make_unique<VulkanSemaphore>(vk_engine->_device, renderSemaphore); | ||
| } | ||
|
|
||
| VkFence immFence; | ||
| VK_CHECK(vkCreateFence(vk_engine->_device, &fenceCreateInfo, nullptr, &immFence)); | ||
| _immFence = std::make_unique<VulkanFence>(vk_engine->_device, immFence); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/include/graphics/vulkan/vk_command_buffers_container.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
| #include <memory> | ||
| #include <vector> | ||
| #include <vulkan/vulkan_core.h> | ||
|
|
||
| #include "vk_descriptors.h" | ||
| #include "vk_smart_wrappers.h" | ||
|
|
||
| constexpr unsigned int FRAME_OVERLAP = 2; | ||
|
|
||
| struct FrameData { | ||
| std::unique_ptr<VulkanCommandPool> _commandPool; | ||
| VkCommandBuffer _mainCommandBuffer; | ||
|
|
||
| std::unique_ptr<VulkanSemaphore> _swapchainSemaphore, _renderSemaphore; | ||
| std::unique_ptr<VulkanFence> _renderFence; | ||
|
|
||
| DescriptorAllocatorGrowable _frameDescriptors; | ||
| std::vector<std::unique_ptr<VulkanBuffer>> _frameBuffers; // For per-frame temporary buffers | ||
| }; | ||
|
|
||
| class VulkanEngine; | ||
|
|
||
| class CommandBuffersContainer { | ||
| public: | ||
| CommandBuffersContainer(); | ||
| ~CommandBuffersContainer() = default; | ||
|
|
||
| // Frame management | ||
| FrameData _frames[FRAME_OVERLAP]; | ||
|
|
||
| FrameData& get_current_frame(unsigned int frameNumber) { | ||
| return _frames[frameNumber % FRAME_OVERLAP]; | ||
| } | ||
|
|
||
| // Immediate command buffer members | ||
| std::unique_ptr<VulkanFence> _immFence; | ||
| VkCommandBuffer _immCommandBuffer; | ||
| std::unique_ptr<VulkanCommandPool> _immCommandPool; | ||
|
|
||
| // Initialization | ||
| void init_sync_structures(VulkanEngine* vk_engine); | ||
|
|
||
| private: | ||
| // No copying | ||
| CommandBuffersContainer(const CommandBuffersContainer&) = delete; | ||
| CommandBuffersContainer& operator=(const CommandBuffersContainer&) = delete; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.