Corrected stage flag for push constant range, removed descriptor sets (not used in this example)
This commit is contained in:
parent
52ffbb59bb
commit
2517a2b82e
3 changed files with 10 additions and 63 deletions
|
|
@ -600,7 +600,10 @@ VulkanExampleBase::~VulkanExampleBase()
|
||||||
{
|
{
|
||||||
// Clean up Vulkan resources
|
// Clean up Vulkan resources
|
||||||
swapChain.cleanup();
|
swapChain.cleanup();
|
||||||
vkDestroyDescriptorPool(device, descriptorPool, nullptr);
|
if (descriptorPool != VK_NULL_HANDLE)
|
||||||
|
{
|
||||||
|
vkDestroyDescriptorPool(device, descriptorPool, nullptr);
|
||||||
|
}
|
||||||
if (setupCmdBuffer != VK_NULL_HANDLE)
|
if (setupCmdBuffer != VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, cmdPool, 1, &setupCmdBuffer);
|
vkFreeCommandBuffers(device, cmdPool, 1, &setupCmdBuffer);
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ protected:
|
||||||
// Active frame buffer index
|
// Active frame buffer index
|
||||||
uint32_t currentBuffer = 0;
|
uint32_t currentBuffer = 0;
|
||||||
// Descriptor set pool
|
// Descriptor set pool
|
||||||
VkDescriptorPool descriptorPool;
|
VkDescriptorPool descriptorPool = VK_NULL_HANDLE;
|
||||||
// List of shader modules created (stored for cleanup)
|
// List of shader modules created (stored for cleanup)
|
||||||
std::vector<VkShaderModule> shaderModules;
|
std::vector<VkShaderModule> shaderModules;
|
||||||
// Pipeline cache object
|
// Pipeline cache object
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,6 @@ public:
|
||||||
} pipelines;
|
} pipelines;
|
||||||
|
|
||||||
VkPipelineLayout pipelineLayout;
|
VkPipelineLayout pipelineLayout;
|
||||||
VkDescriptorSet descriptorSet;
|
|
||||||
VkDescriptorSetLayout descriptorSetLayout;
|
|
||||||
|
|
||||||
VkCommandBuffer primaryCommandBuffer;
|
VkCommandBuffer primaryCommandBuffer;
|
||||||
VkCommandBuffer secondaryCommandBuffer;
|
VkCommandBuffer secondaryCommandBuffer;
|
||||||
|
|
@ -145,7 +143,6 @@ public:
|
||||||
vkDestroyPipeline(device, pipelines.starsphere, nullptr);
|
vkDestroyPipeline(device, pipelines.starsphere, nullptr);
|
||||||
|
|
||||||
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
||||||
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
|
|
||||||
|
|
||||||
vkFreeCommandBuffers(device, cmdPool, 1, &primaryCommandBuffer);
|
vkFreeCommandBuffers(device, cmdPool, 1, &primaryCommandBuffer);
|
||||||
vkFreeCommandBuffers(device, cmdPool, 1, &secondaryCommandBuffer);
|
vkFreeCommandBuffers(device, cmdPool, 1, &secondaryCommandBuffer);
|
||||||
|
|
@ -531,65 +528,15 @@ public:
|
||||||
vertices.inputState.pVertexAttributeDescriptions = vertices.attributeDescriptions.data();
|
vertices.inputState.pVertexAttributeDescriptions = vertices.attributeDescriptions.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupDescriptorPool()
|
void setupPipelineLayout()
|
||||||
{
|
{
|
||||||
std::vector<VkDescriptorPoolSize> poolSizes =
|
|
||||||
{
|
|
||||||
vkTools::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 3)
|
|
||||||
};
|
|
||||||
|
|
||||||
VkDescriptorPoolCreateInfo descriptorPoolInfo =
|
|
||||||
vkTools::initializers::descriptorPoolCreateInfo(
|
|
||||||
poolSizes.size(),
|
|
||||||
poolSizes.data(),
|
|
||||||
3);
|
|
||||||
|
|
||||||
VkResult vkRes = vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &descriptorPool);
|
|
||||||
assert(!vkRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setupDescriptorSet()
|
|
||||||
{
|
|
||||||
// todo :
|
|
||||||
VkDescriptorSetAllocateInfo allocInfo =
|
|
||||||
vkTools::initializers::descriptorSetAllocateInfo(
|
|
||||||
descriptorPool,
|
|
||||||
&descriptorSetLayout,
|
|
||||||
1);
|
|
||||||
|
|
||||||
vkTools::checkResult(vkAllocateDescriptorSets(device, &allocInfo, &descriptorSet));
|
|
||||||
|
|
||||||
vkUpdateDescriptorSets(device, 0, nullptr, 0, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setupDescriptorSetLayout()
|
|
||||||
{
|
|
||||||
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings =
|
|
||||||
{
|
|
||||||
// Binding 0 : Vertex shader uniform buffer
|
|
||||||
vkTools::initializers::descriptorSetLayoutBinding(
|
|
||||||
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
|
||||||
VK_SHADER_STAGE_VERTEX_BIT,
|
|
||||||
0)
|
|
||||||
};
|
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo descriptorLayout =
|
|
||||||
vkTools::initializers::descriptorSetLayoutCreateInfo(
|
|
||||||
setLayoutBindings.data(),
|
|
||||||
setLayoutBindings.size());
|
|
||||||
|
|
||||||
VkResult err = vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &descriptorSetLayout);
|
|
||||||
assert(!err);
|
|
||||||
|
|
||||||
VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo =
|
VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo =
|
||||||
vkTools::initializers::pipelineLayoutCreateInfo(
|
vkTools::initializers::pipelineLayoutCreateInfo(nullptr, 0);
|
||||||
&descriptorSetLayout,
|
|
||||||
1);
|
|
||||||
|
|
||||||
// Push constants for model matrices
|
// Push constants for model matrices
|
||||||
VkPushConstantRange pushConstantRange =
|
VkPushConstantRange pushConstantRange =
|
||||||
vkTools::initializers::pushConstantRange(
|
vkTools::initializers::pushConstantRange(
|
||||||
VK_PIPELINE_STAGE_VERTEX_SHADER_BIT,
|
VK_SHADER_STAGE_VERTEX_BIT,
|
||||||
sizeof(ThreadPushConstantBlock),
|
sizeof(ThreadPushConstantBlock),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
|
@ -597,8 +544,7 @@ public:
|
||||||
pPipelineLayoutCreateInfo.pushConstantRangeCount = 1;
|
pPipelineLayoutCreateInfo.pushConstantRangeCount = 1;
|
||||||
pPipelineLayoutCreateInfo.pPushConstantRanges = &pushConstantRange;
|
pPipelineLayoutCreateInfo.pPushConstantRanges = &pushConstantRange;
|
||||||
|
|
||||||
err = vkCreatePipelineLayout(device, &pPipelineLayoutCreateInfo, nullptr, &pipelineLayout);
|
vkTools::checkResult(vkCreatePipelineLayout(device, &pPipelineLayoutCreateInfo, nullptr, &pipelineLayout));
|
||||||
assert(!err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void preparePipelines()
|
void preparePipelines()
|
||||||
|
|
@ -698,10 +644,8 @@ public:
|
||||||
VulkanExampleBase::prepare();
|
VulkanExampleBase::prepare();
|
||||||
loadMeshes();
|
loadMeshes();
|
||||||
setupVertexDescriptions();
|
setupVertexDescriptions();
|
||||||
setupDescriptorSetLayout();
|
setupPipelineLayout();
|
||||||
preparePipelines();
|
preparePipelines();
|
||||||
setupDescriptorPool();
|
|
||||||
setupDescriptorSet();
|
|
||||||
prepareMultiThreadedRenderer();
|
prepareMultiThreadedRenderer();
|
||||||
updateMatrices();
|
updateMatrices();
|
||||||
prepared = true;
|
prepared = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue