Skip to content
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

Vk pipeline initialization #55

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Vk pipeline initialization #55

wants to merge 10 commits into from

Conversation

Rinzii
Copy link
Owner

@Rinzii Rinzii commented Aug 21, 2023

This PR is primarily focused on the creation of the Vulkan pipeline, but there is also some small additional add ons bundled with the PR for the future.

@Rinzii Rinzii self-assigned this Aug 21, 2023
@Rinzii Rinzii added this to the MVP milestone Aug 21, 2023
Copy link
Collaborator

@karnkaul karnkaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some code changes requested. Additionally, since the app now relies on loading data from the filesystem, we need to establish systems and/or conventions for it to be able to locate that data when debugging. Usually debuggers will use the project's root directory as the working directory, but may also use the directory where the executable was built. I've been using the project root in my .vscode/launch.json, but that fails to load the shaders since they are inside ./editor. Changing the pwd to that works, but it's currently undocumented in the repo.

engine/include/graphics/device.hpp Show resolved Hide resolved
Comment on lines +54 to +55
GEN_NODISCARD std::vector<vk::Image> const & getSwapChainImages() const { return m_swapChainImages; }
GEN_NODISCARD std::vector<vk::UniqueImageView> const & getSwapChainImageViews() const { return m_swapChainImageViews; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use std::span<T const> instead of std::vector<T> const& (in general, everywhere).

@@ -69,6 +76,8 @@ namespace gen
vk::UniqueSurfaceKHR m_surface{};
Gpu m_gpu{};
vk::UniqueDevice m_device{};
vk::UniqueCommandPool m_commandPool{};
vk::UniqueCommandBuffer m_commandBuffer{};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command buffers are owned by command pools, we don't need RAII here. (AKA just use vk::CommandBuffer.)

Comment on lines +18 to +19
vk::Viewport viewport{};
vk::Rect2D scissor{};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be dynamic states (vk::DynamicState). Otherwise you'll need a new pipeline every time the window resizes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: config is missing vk::PipelineDynamicStateCreateInfo.

vk::Viewport viewport{};
vk::Rect2D scissor{};
vk::PipelineInputAssemblyStateCreateInfo inputAssemblyInfo{};
vk::PipelineTessellationStateCreateInfo tessellationInfo{};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required, we won't be using tesselation.

Comment on lines +185 to +186
m_commandBuffer =
std::move(m_device->allocateCommandBuffersUnique(vk::CommandBufferAllocateInfo(m_commandPool.get(), vk::CommandBufferLevel::ePrimary, 1)).front());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VulkanHPP offers overloads for such functions that take a pointer and count instead of returning a vector. It's not a big deal here as this only happens once, but later on we'll be creating command buffers on the fly for various stuff, where it will add needless allocation overhead.

Comment on lines +31 to +34
configInfo.viewport.x = 0.0F;
configInfo.viewport.y = 0.0F;
configInfo.viewport.width = static_cast<float>(extent.x);
configInfo.viewport.height = static_cast<float>(extent.y);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

engine/src/graphics/pipeline.cpp Show resolved Hide resolved
engine/src/graphics/pipeline.cpp Show resolved Hide resolved

std::array<vk::PipelineShaderStageCreateInfo, 2> shaderStages = {vertShaderStageInfo, fragShaderStageInfo};

std::vector<vk::DynamicState> dynamicStates = {vk::DynamicState::eViewport, vk::DynamicState::eScissor};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why vector if you know you want just two entries?

@Rinzii
Copy link
Owner Author

Rinzii commented Aug 22, 2023

Putting this as blocking until restructure is finished.

@Rinzii Rinzii added Status: Blocked This PR is being blocked by another issue. Status: DO NOT MERGE Don't merge this PR. labels Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Blocked This PR is being blocked by another issue. Status: DO NOT MERGE Don't merge this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants