pull/2/head
ink-soul 2023-05-25 15:29:25 +08:00
parent 054599f6b0
commit 3e1ec8deac
2 changed files with 18 additions and 18 deletions

View File

@ -764,7 +764,7 @@ void VulkanExample::getEnabledFeatures()
// Bind scene matrices descriptor to set 0 // Bind scene matrices descriptor to set 0
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.pbrLayout, 0, 1, &descriptorSet, 0, nullptr); vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.pbrLayout, 0, 1, &descriptorSet, 0, nullptr);
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.pbrLayout, 6, 1, &skinDescriptorSet, 0, nullptr); vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.pbrLayout, 6, 1, &skinDescriptorSet, 0, nullptr);
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, wireframe ? pipelines.wireframe : pipelines.solid); vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, wireframe ? wireframePipeline : solidPipeline);
glTFModel.draw(drawCmdBuffers[i], pipelineLayouts.pbrLayout); glTFModel.draw(drawCmdBuffers[i], pipelineLayouts.pbrLayout);
vkCmdEndRenderPass(drawCmdBuffers[i]); vkCmdEndRenderPass(drawCmdBuffers[i]);
@ -781,7 +781,7 @@ void VulkanExample::getEnabledFeatures()
vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport); vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport);
vkCmdSetScissor(drawCmdBuffers[i], 0, 1, &scissor); vkCmdSetScissor(drawCmdBuffers[i], 0, 1, &scissor);
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.tonemappingLayout, 0, 1, &tonemappingDescriptorSet, 0, NULL); vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.tonemappingLayout, 0, 1, &tonemappingDescriptorSet, 0, NULL);
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.toneMapping); vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, toneMappingPipeline);
vkCmdDraw(drawCmdBuffers[i], 3, 1, 0, 0); vkCmdDraw(drawCmdBuffers[i], 3, 1, 0, 0);
drawUI(drawCmdBuffers[i]); drawUI(drawCmdBuffers[i]);
vkCmdEndRenderPass(drawCmdBuffers[i]); vkCmdEndRenderPass(drawCmdBuffers[i]);
@ -1066,15 +1066,15 @@ void VulkanExample::getEnabledFeatures()
pipelineCI.pDynamicState = &dynamicStateCI; pipelineCI.pDynamicState = &dynamicStateCI;
pipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size()); pipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());
pipelineCI.pStages = shaderStages.data(); pipelineCI.pStages = shaderStages.data();
// Solid rendering pipeline // Solid rendering pipeline
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.solid)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &solidPipeline));
// Wire frame rendering pipeline // Wire frame rendering pipeline
if (deviceFeatures.fillModeNonSolid) { if (deviceFeatures.fillModeNonSolid) {
rasterizationStateCI.polygonMode = VK_POLYGON_MODE_LINE; rasterizationStateCI.polygonMode = VK_POLYGON_MODE_LINE;
rasterizationStateCI.lineWidth = 1.0f; rasterizationStateCI.lineWidth = 1.0f;
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.wireframe)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &wireframePipeline));
} }
//Create Tone Mapping render pipeline //Create Tone Mapping render pipeline
prepareToneMappingPipeline(); prepareToneMappingPipeline();
@ -1082,10 +1082,10 @@ void VulkanExample::getEnabledFeatures()
void VulkanExample::prepareToneMappingPipeline() void VulkanExample::prepareToneMappingPipeline()
{ {
if (pipelines.toneMapping != VK_NULL_HANDLE) if (toneMappingPipeline != VK_NULL_HANDLE)
{ {
vkDestroyPipeline(device, pipelines.toneMapping, nullptr); vkDestroyPipeline(device, toneMappingPipeline, nullptr);
pipelines.toneMapping = VK_NULL_HANDLE; toneMappingPipeline = VK_NULL_HANDLE;
} }
VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCI = vks::initializers::pipelineInputAssemblyStateCreateInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 0, VK_FALSE); VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCI = vks::initializers::pipelineInputAssemblyStateCreateInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 0, VK_FALSE);
VkPipelineRasterizationStateCreateInfo rasterizationStateCI = vks::initializers::pipelineRasterizationStateCreateInfo(VK_POLYGON_MODE_FILL, VK_CULL_MODE_BACK_BIT, VK_FRONT_FACE_COUNTER_CLOCKWISE, 0); VkPipelineRasterizationStateCreateInfo rasterizationStateCI = vks::initializers::pipelineRasterizationStateCreateInfo(VK_POLYGON_MODE_FILL, VK_CULL_MODE_BACK_BIT, VK_FRONT_FACE_COUNTER_CLOCKWISE, 0);
@ -1116,7 +1116,7 @@ void VulkanExample::getEnabledFeatures()
pipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size()); pipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());
pipelineCI.pStages = shaderStages.data(); pipelineCI.pStages = shaderStages.data();
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.toneMapping)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &toneMappingPipeline));
} }
// Prepare and initialize uniform buffer containing shader uniforms // Prepare and initialize uniform buffer containing shader uniforms

View File

@ -254,11 +254,11 @@ public:
VkDeviceMemory memory; VkDeviceMemory memory;
} vertexStaging, indexStaging; } vertexStaging, indexStaging;
struct Pipelines {
VkPipeline solid; VkPipeline solidPipeline;
VkPipeline wireframe = VK_NULL_HANDLE; VkPipeline wireframePipeline = VK_NULL_HANDLE;
VkPipeline toneMapping = VK_NULL_HANDLE; VkPipeline toneMappingPipeline = VK_NULL_HANDLE;
} pipelines;
struct PipelineLayouts struct PipelineLayouts
{ {
@ -359,10 +359,10 @@ public:
{ {
// Clean up used Vulkan resources // Clean up used Vulkan resources
// Note : Inherited destructor cleans up resources stored in base class // Note : Inherited destructor cleans up resources stored in base class
vkDestroyPipeline(device, pipelines.solid, nullptr); vkDestroyPipeline(device, solidPipeline, nullptr);
vkDestroyPipeline(device, pipelines.toneMapping, nullptr); vkDestroyPipeline(device, toneMappingPipeline, nullptr);
if (pipelines.wireframe != VK_NULL_HANDLE) { if (wireframePipeline != VK_NULL_HANDLE) {
vkDestroyPipeline(device, pipelines.wireframe, nullptr); vkDestroyPipeline(device, wireframePipeline, nullptr);
} }
vkDestroyPipelineLayout(device, pipelineLayouts.pbrLayout, nullptr); vkDestroyPipelineLayout(device, pipelineLayouts.pbrLayout, nullptr);