forked from pupbrained/vulkan-test
Framebuffers
This commit is contained in:
parent
e0b7e93bd8
commit
7648a55f8d
20
src/main.cpp
20
src/main.cpp
|
@ -66,6 +66,8 @@ class VulkanApp {
|
||||||
vk::UniquePipelineLayout mPipelineLayout;
|
vk::UniquePipelineLayout mPipelineLayout;
|
||||||
vk::UniquePipeline mGraphicsPipeline;
|
vk::UniquePipeline mGraphicsPipeline;
|
||||||
|
|
||||||
|
std::vector<vk::UniqueFramebuffer> mSwapChainFramebuffers;
|
||||||
|
|
||||||
struct QueueFamilyIndices {
|
struct QueueFamilyIndices {
|
||||||
std::optional<u32> graphics_family;
|
std::optional<u32> graphics_family;
|
||||||
std::optional<u32> present_family;
|
std::optional<u32> present_family;
|
||||||
|
@ -117,6 +119,7 @@ class VulkanApp {
|
||||||
createImageViews();
|
createImageViews();
|
||||||
createRenderPass();
|
createRenderPass();
|
||||||
createGraphicsPipeline();
|
createGraphicsPipeline();
|
||||||
|
createFramebuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mainLoop() -> void {
|
fn mainLoop() -> void {
|
||||||
|
@ -444,6 +447,23 @@ class VulkanApp {
|
||||||
mGraphicsPipeline = mDevice->createGraphicsPipelineUnique(nullptr, pipelineInfo).value;
|
mGraphicsPipeline = mDevice->createGraphicsPipelineUnique(nullptr, pipelineInfo).value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn createFramebuffers() -> void {
|
||||||
|
mSwapChainFramebuffers.resize(mSwapChainImageViews.size());
|
||||||
|
|
||||||
|
for (usize i = 0; i < mSwapChainImageViews.size(); i++) {
|
||||||
|
vk::FramebufferCreateInfo framebufferInfo {
|
||||||
|
.renderPass = mRenderPass.get(),
|
||||||
|
.attachmentCount = 1,
|
||||||
|
.pAttachments = &mSwapChainImageViews[i].get(),
|
||||||
|
.width = mSwapChainExtent.width,
|
||||||
|
.height = mSwapChainExtent.height,
|
||||||
|
.layers = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
mSwapChainFramebuffers[i] = mDevice->createFramebufferUnique(framebufferInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn createShaderModule(const std::vector<char>& code) -> vk::UniqueShaderModule {
|
fn createShaderModule(const std::vector<char>& code) -> vk::UniqueShaderModule {
|
||||||
vk::ShaderModuleCreateInfo createInfo { .codeSize = code.size(),
|
vk::ShaderModuleCreateInfo createInfo { .codeSize = code.size(),
|
||||||
.pCode = std::bit_cast<const u32*>(code.data()) };
|
.pCode = std::bit_cast<const u32*>(code.data()) };
|
||||||
|
|
Loading…
Reference in a new issue