move render pass to PTK_OPTION
This commit is contained in:
parent
2e8a490fbe
commit
854416f651
5 changed files with 23 additions and 17 deletions
|
@ -913,11 +913,15 @@ bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!vk_create_render_pass()) {
|
||||
PTK_OPTION(VkRenderPass) render_pass_opt = vk_create_render_pass(g_dev, g_swapchain_image_format);
|
||||
|
||||
if (!render_pass_opt.exists) {
|
||||
PTK_ERR("failed creating render pass");
|
||||
return false;
|
||||
}
|
||||
|
||||
VkRenderPass render_pass = render_pass_opt.value;
|
||||
|
||||
if (!create_descriptor_set_layout()) {
|
||||
PTK_ERR("failed creating descriptor set layout");
|
||||
return false;
|
||||
|
@ -928,7 +932,7 @@ bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!vk_create_framebuffers()) {
|
||||
if (!vk_create_framebuffers(render_pass)) {
|
||||
PTK_ERR("failed creating framebuffers");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
#include <ptk_vk/device.h>
|
||||
#include <ptk_vk/utils.h>
|
||||
|
||||
VkRenderPass g_render_pass;
|
||||
PTK_OPTION(VkRenderPass) vk_create_render_pass(VkDevice dev, VkFormat format) {
|
||||
VkRenderPass ret;
|
||||
|
||||
bool vk_create_render_pass(void) {
|
||||
VK_TRY(false,
|
||||
VK_TRY(PTK_OPTION_NONE(VkRenderPass),
|
||||
vkCreateRenderPass(
|
||||
g_dev,
|
||||
dev,
|
||||
&(VkRenderPassCreateInfo){
|
||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
|
||||
.pNext = NULL,
|
||||
|
@ -20,7 +20,7 @@ bool vk_create_render_pass(void) {
|
|||
.attachmentCount = 1,
|
||||
.pAttachments = &(VkAttachmentDescription){
|
||||
.flags = 0,
|
||||
.format = g_swapchain_image_format,
|
||||
.format = format,
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
|
@ -57,10 +57,10 @@ bool vk_create_render_pass(void) {
|
|||
},
|
||||
},
|
||||
NULL,
|
||||
&g_render_pass
|
||||
&ret
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
return PTK_OPTION_SOME(VkRenderPass, ret);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
extern VkRenderPass g_render_pass;
|
||||
#include <ptk_option.h>
|
||||
|
||||
bool vk_create_render_pass(void);
|
||||
PTK_OPTION_DEFINE(VkRenderPass);
|
||||
|
||||
PTK_OPTION(VkRenderPass) vk_create_render_pass(VkDevice dev, VkFormat format);
|
||||
|
||||
#endif // PTK_PTK_VK_RENDER_PASS_H_
|
||||
|
|
|
@ -218,7 +218,7 @@ bool vk_create_swapchain(GLFWwindow *window, VkDevice dev, VkPhysicalDevice phys
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, VkSurfaceKHR surface) {
|
||||
bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, VkSurfaceKHR surface, VkRenderPass render_pass) {
|
||||
int width = 0, height = 0;
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
|
||||
|
@ -241,7 +241,7 @@ bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, Vk
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!vk_create_framebuffers()) {
|
||||
if (!vk_create_framebuffers(render_pass)) {
|
||||
PTK_ERR("failed creating new framebuffers");
|
||||
return false;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, Vk
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vk_create_framebuffers(void) {
|
||||
bool vk_create_framebuffers(VkRenderPass render_pass) {
|
||||
g_swapchain_framebuffers = PTK_LIST_NEW(VkFramebuffer, m_swapchain_image_views.size);
|
||||
|
||||
VkFramebuffer fb;
|
||||
|
@ -262,7 +262,7 @@ bool vk_create_framebuffers(void) {
|
|||
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
|
||||
.pNext = NULL,
|
||||
.flags = 0,
|
||||
.renderPass = g_render_pass,
|
||||
.renderPass = render_pass,
|
||||
.attachmentCount = 1,
|
||||
.pAttachments = &swapchain_image_view,
|
||||
.width = g_swapchain_extent.width,
|
||||
|
|
|
@ -31,9 +31,9 @@ bool vk_create_swapchain(GLFWwindow *window, VkDevice dev, VkPhysicalDevice phys
|
|||
|
||||
bool vk_create_image_views(VkDevice dev);
|
||||
|
||||
bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, VkSurfaceKHR surface);
|
||||
bool vk_recreate_swapchain(GLFWwindow *window, VkPhysicalDevice physical_dev, VkSurfaceKHR surface, VkRenderPass render_pass);
|
||||
|
||||
bool vk_create_framebuffers(void);
|
||||
bool vk_create_framebuffers(VkRenderPass render_pass);
|
||||
|
||||
void vk_cleanup_swapchain(VkDevice dev);
|
||||
|
||||
|
|
Loading…
Reference in a new issue