From 3e1ec8deac2d6fd3fb9c754d3cd5f6cb42c3b849 Mon Sep 17 00:00:00 2001 From: ink-soul Date: Thu, 25 May 2023 15:29:25 +0800 Subject: [PATCH] revert --- homework/homework1/homework1.cpp | 18 +++++++++--------- homework/homework1/homework1.h | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/homework/homework1/homework1.cpp b/homework/homework1/homework1.cpp index 5cfd033..e38e208 100644 --- a/homework/homework1/homework1.cpp +++ b/homework/homework1/homework1.cpp @@ -764,7 +764,7 @@ void VulkanExample::getEnabledFeatures() // 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, 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); vkCmdEndRenderPass(drawCmdBuffers[i]); @@ -781,7 +781,7 @@ void VulkanExample::getEnabledFeatures() vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport); vkCmdSetScissor(drawCmdBuffers[i], 0, 1, &scissor); 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); drawUI(drawCmdBuffers[i]); vkCmdEndRenderPass(drawCmdBuffers[i]); @@ -1066,15 +1066,15 @@ void VulkanExample::getEnabledFeatures() pipelineCI.pDynamicState = &dynamicStateCI; pipelineCI.stageCount = static_cast(shaderStages.size()); pipelineCI.pStages = shaderStages.data(); - + // 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 if (deviceFeatures.fillModeNonSolid) { rasterizationStateCI.polygonMode = VK_POLYGON_MODE_LINE; 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 prepareToneMappingPipeline(); @@ -1082,10 +1082,10 @@ void VulkanExample::getEnabledFeatures() void VulkanExample::prepareToneMappingPipeline() { - if (pipelines.toneMapping != VK_NULL_HANDLE) + if (toneMappingPipeline != VK_NULL_HANDLE) { - vkDestroyPipeline(device, pipelines.toneMapping, nullptr); - pipelines.toneMapping = VK_NULL_HANDLE; + vkDestroyPipeline(device, toneMappingPipeline, nullptr); + toneMappingPipeline = VK_NULL_HANDLE; } 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); @@ -1116,7 +1116,7 @@ void VulkanExample::getEnabledFeatures() pipelineCI.stageCount = static_cast(shaderStages.size()); 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 diff --git a/homework/homework1/homework1.h b/homework/homework1/homework1.h index 5b39c45..7a4500a 100644 --- a/homework/homework1/homework1.h +++ b/homework/homework1/homework1.h @@ -254,11 +254,11 @@ public: VkDeviceMemory memory; } vertexStaging, indexStaging; - struct Pipelines { - VkPipeline solid; - VkPipeline wireframe = VK_NULL_HANDLE; - VkPipeline toneMapping = VK_NULL_HANDLE; - } pipelines; + + VkPipeline solidPipeline; + VkPipeline wireframePipeline = VK_NULL_HANDLE; + VkPipeline toneMappingPipeline = VK_NULL_HANDLE; + struct PipelineLayouts { @@ -359,10 +359,10 @@ public: { // Clean up used Vulkan resources // Note : Inherited destructor cleans up resources stored in base class - vkDestroyPipeline(device, pipelines.solid, nullptr); - vkDestroyPipeline(device, pipelines.toneMapping, nullptr); - if (pipelines.wireframe != VK_NULL_HANDLE) { - vkDestroyPipeline(device, pipelines.wireframe, nullptr); + vkDestroyPipeline(device, solidPipeline, nullptr); + vkDestroyPipeline(device, toneMappingPipeline, nullptr); + if (wireframePipeline != VK_NULL_HANDLE) { + vkDestroyPipeline(device, wireframePipeline, nullptr); } vkDestroyPipelineLayout(device, pipelineLayouts.pbrLayout, nullptr);