summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-08-24 22:05:16 -0400
committerJonathan Bradley <jcb@pikum.xyz>2023-08-24 22:05:16 -0400
commit1642e319e241b41246442adc3bc780261dd612c0 (patch)
treeffe8a90ea4e004026748864403b897ef2390c88a /src
parent91e15d7f97d24fec6ff5c299de8b9cd116778aae (diff)
vkUpdateDescriptorSets checkpoint
Diffstat (limited to 'src')
-rw-r--r--src/window.cpp60
1 files changed, 50 insertions, 10 deletions
diff --git a/src/window.cpp b/src/window.cpp
index a56ae9b..dda6efe 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1,3 +1,4 @@
+#include <vulkan/vulkan_core.h>
#define GLFW_INCLUDE_NONE
#define GLFW_INCLUDE_VULKAN
@@ -482,13 +483,24 @@ void CreateRenderPass() {
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &colorAttachmentRef;
- VkSubpassDependency dependency{};
- dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
- dependency.dstSubpass = 0;
- dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- dependency.srcAccessMask = 0;
- dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
- dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+ VkSubpassDependency subpassDependencies[2];
+ for (long i = 0; i < 2; ++i) {
+ subpassDependencies[i].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
+ }
+
+ subpassDependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
+ subpassDependencies[0].dstSubpass = 0U;
+ subpassDependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
+ subpassDependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ subpassDependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
+ subpassDependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+
+ subpassDependencies[1].srcSubpass = 0U;
+ subpassDependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL;
+ subpassDependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ subpassDependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
+ subpassDependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+ subpassDependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
VkRenderPassCreateInfo renderPassInfo{};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
@@ -496,8 +508,8 @@ void CreateRenderPass() {
renderPassInfo.pAttachments = &colorAttachment;
renderPassInfo.subpassCount = 1;
renderPassInfo.pSubpasses = &subpass;
- renderPassInfo.dependencyCount = 1;
- renderPassInfo.pDependencies = &dependency;
+ renderPassInfo.dependencyCount = 2;
+ renderPassInfo.pDependencies = subpassDependencies;
if (vkCreateRenderPass(vkDevice, &renderPassInfo, vkAllocator, &renderPass) != VK_SUCCESS) {
throw "failed to create render pass!";
@@ -649,6 +661,7 @@ void CreateGraphicsPipeline() {
pipelineInfo.pVertexInputState = &vertexInputInfo;
pipelineInfo.pInputAssemblyState = &inputAssembly;
+ pipelineInfo.pTessellationState = nullptr;
pipelineInfo.pViewportState = &viewportState;
pipelineInfo.pRasterizationState = &rasterizer;
pipelineInfo.pMultisampleState = &multisampling;
@@ -660,13 +673,40 @@ void CreateGraphicsPipeline() {
pipelineInfo.renderPass = renderPass;
pipelineInfo.subpass = 0;
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
- pipelineInfo.basePipelineIndex = -1;
+ pipelineInfo.basePipelineIndex = {};
result = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &pipelineInfo, vkAllocator, &graphicsPipeline);
if (result != VK_SUCCESS) {
throw "failed to create graphics pipeline.";
}
+ VkWriteDescriptorSet writeDescriptorSets[2];
+ VkDescriptorImageInfo descriptorImageInfo[2];
+ for (long i = 0; i < 2; ++i) {
+ writeDescriptorSets[i].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ // writeDescriptorSets[i].dstSet = VK_NULL_HANDLE;
+ writeDescriptorSets[i].dstBinding = 0U;
+ writeDescriptorSets[i].dstArrayElement = 0U;
+ writeDescriptorSets[i].descriptorCount = 1;
+ writeDescriptorSets[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+ // writeDescriptorSets[i].pImageInfo = nullptr;
+ writeDescriptorSets[i].pBufferInfo = nullptr;
+ writeDescriptorSets[i].pTexelBufferView = nullptr;
+ // descriptorImageInfo[i].sampler = nullptr;
+ // descriptorImageInfo[i].imageView = nullptr;
+ descriptorImageInfo[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+ }
+
+ for (long i = 0; i < 2; ++i) {
+ descriptorImageInfo[i].sampler = nullptr; // TODO
+ descriptorImageInfo[i].imageView = swapchainImageViews[i];
+
+ writeDescriptorSets[i].pImageInfo = &descriptorImageInfo[i];
+ writeDescriptorSets[i].dstSet = nullptr; // TODO
+ }
+
+ vkUpdateDescriptorSets(vkDevice, 2, writeDescriptorSets, 0, nullptr);
+
vkDestroyShaderModule(vkDevice, fragShader, vkAllocator);
vkDestroyShaderModule(vkDevice, vertShader, vkAllocator);
DestroyAsset(fragShaderAsset);