diff --git a/base/VulkanDevice.hpp b/base/VulkanDevice.hpp index e9b45c5..3d9736f 100644 --- a/base/VulkanDevice.hpp +++ b/base/VulkanDevice.hpp @@ -225,16 +225,17 @@ namespace vks } VkResult result = vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &logicalDevice); - + /* if (result == VK_SUCCESS) { commandPool = createCommandPool(queueFamilyIndices.graphics); } - + */ this->enabledFeatures = enabledFeatures; return result; } + /** * Create a buffer on the device * @@ -313,6 +314,11 @@ namespace vks return cmdPool; } + void setCommandPool(VkCommandPool commandPool) + { + this->commandPool = commandPool; + } + /** * Allocate a command buffer from the command pool * diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index d152d33..cc28f52 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -126,7 +126,7 @@ void VulkanExampleBase::prepare() cmdPoolInfo.queueFamilyIndex = queueFamilyIndex; cmdPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; VK_CHECK_RESULT(vkCreateCommandPool(device, &cmdPoolInfo, nullptr, &cmdPool)); - + vulkanDevice->setCommandPool(cmdPool); /* Render pass */ @@ -505,24 +505,6 @@ void VulkanExampleBase::initVulkan() queueFamilyIndex creation */ - const float defaultQueuePriority(0.0f); - VkDeviceQueueCreateInfo queueCreateInfo = {}; - uint32_t queueFamilyCount; - vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, nullptr); - std::vector queueFamilyProperties(queueFamilyCount); - vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, queueFamilyProperties.data()); - for (uint32_t i = 0; i < static_cast(queueFamilyProperties.size()); i++) { - if (queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { - queueFamilyIndex = i; - queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; - queueCreateInfo.queueFamilyIndex = i; - queueCreateInfo.queueCount = 1; - queueCreateInfo.pQueuePriorities = &defaultQueuePriority; - break; - } - } - - /* Device creation */ @@ -538,14 +520,12 @@ void VulkanExampleBase::initVulkan() exit(res); } device = vulkanDevice->logicalDevice; - + /* Graphics queue */ vkGetDeviceQueue(device, vulkanDevice->queueFamilyIndices.graphics, 0, &queue); - - - + queueFamilyIndex = vulkanDevice->queueFamilyIndices.graphics; /* Suitable depth format */ diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 7bf0d18..fb7f7fd 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -114,7 +114,7 @@ public: VkFormat colorFormat = VK_FORMAT_R8G8B8A8_SRGB; uint32_t queueFamilyIndex; - uint32_t renderingFrameIndex; + uint32_t renderingFrameIndex = 3; struct Signal { diff --git a/src/render/render.cpp b/src/render/render.cpp index b763bec..4ca6795 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -321,14 +321,14 @@ PlumageRender::PlumageRender() } std::vector poolSizes = { - { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, (4 + meshCount) * swapChain.imageCount }, - { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, imageSamplerCount * swapChain.imageCount } + { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, (4 + meshCount) * renderingFrameIndex }, + { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, imageSamplerCount * renderingFrameIndex } }; VkDescriptorPoolCreateInfo descriptorPoolCI{}; descriptorPoolCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; descriptorPoolCI.poolSizeCount = 2; descriptorPoolCI.pPoolSizes = poolSizes.data(); - descriptorPoolCI.maxSets = (2 + materialCount + meshCount) * swapChain.imageCount; + descriptorPoolCI.maxSets = (2 + materialCount + meshCount) * renderingFrameIndex; VK_CHECK_RESULT(vkCreateDescriptorPool(device, &descriptorPoolCI, nullptr, &descriptorPool)); /* @@ -357,7 +357,7 @@ PlumageRender::PlumageRender() descriptorSetAllocInfo.descriptorPool = descriptorPool; descriptorSetAllocInfo.pSetLayouts = &descriptorSetLayouts.scene; descriptorSetAllocInfo.descriptorSetCount = 1; - VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &descriptorSets[i].scene)); + vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &descriptorSets[i].scene); std::array writeDescriptorSets{}; @@ -399,6 +399,7 @@ PlumageRender::PlumageRender() vkUpdateDescriptorSets(device, static_cast(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, NULL); } } + // Material (samplers) { @@ -1533,7 +1534,7 @@ PlumageRender::PlumageRender() 0.0f); } - + void PlumageRender::windowResized() { buildCommandBuffers(); @@ -1542,6 +1543,7 @@ PlumageRender::PlumageRender() //update UI updateUIOverlay(); } + void PlumageRender::prepare() { @@ -1986,7 +1988,7 @@ PlumageRender::PlumageRender() return; } - updateUIOverlay(); + //updateUIOverlay(); //加入写到文件的函数 //swapChainImage = swapChain.images[frameIndex]; //outputImageSequeue(swapChainImage,filePath.imageSequenceFilePath); diff --git a/src/render/render.h b/src/render/render.h index 6b3142f..39e8b35 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -142,8 +142,8 @@ public: struct FilePath { //model path std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf"; - //std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv"; - //std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv"; + std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv"; + std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv"; //ui std::string uiVertShaderPath = getAssetPath() + "shaders/ui.vert.spv"; @@ -154,7 +154,7 @@ public: std::string skyboxVertShaderPath = getAssetPath() + "shaders/skybox.vert.spv"; std::string skyboxFragShaderPath = getAssetPath() + "shaders/skybox.frag.spv"; - //std::string iblTexturesFilePath = getAssetPath() + "textures/hdr/gcanyon_cube.ktx"; + std::string iblTexturesFilePath = getAssetPath() + "textures/hdr/gcanyon_cube.ktx"; //tonemapping std::string tonemappingVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/genbrdflut.vert.spv"; std::string tonemappingEnableFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/tonemapping_enable.frag.spv"; @@ -342,7 +342,7 @@ public: textures.prefilteredCube.destroy(); textures.lutBrdf.destroy(); textures.empty.destroy(); - delete gui; + //delete gui; }