完成SwapChain去除
parent
07487be2bf
commit
92d7b95f0f
|
@ -225,16 +225,17 @@ namespace vks
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult result = vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &logicalDevice);
|
VkResult result = vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &logicalDevice);
|
||||||
|
/*
|
||||||
if (result == VK_SUCCESS) {
|
if (result == VK_SUCCESS) {
|
||||||
commandPool = createCommandPool(queueFamilyIndices.graphics);
|
commandPool = createCommandPool(queueFamilyIndices.graphics);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
this->enabledFeatures = enabledFeatures;
|
this->enabledFeatures = enabledFeatures;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a buffer on the device
|
* Create a buffer on the device
|
||||||
*
|
*
|
||||||
|
@ -313,6 +314,11 @@ namespace vks
|
||||||
return cmdPool;
|
return cmdPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setCommandPool(VkCommandPool commandPool)
|
||||||
|
{
|
||||||
|
this->commandPool = commandPool;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a command buffer from the command pool
|
* Allocate a command buffer from the command pool
|
||||||
*
|
*
|
||||||
|
|
|
@ -126,7 +126,7 @@ void VulkanExampleBase::prepare()
|
||||||
cmdPoolInfo.queueFamilyIndex = queueFamilyIndex;
|
cmdPoolInfo.queueFamilyIndex = queueFamilyIndex;
|
||||||
cmdPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
cmdPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
||||||
VK_CHECK_RESULT(vkCreateCommandPool(device, &cmdPoolInfo, nullptr, &cmdPool));
|
VK_CHECK_RESULT(vkCreateCommandPool(device, &cmdPoolInfo, nullptr, &cmdPool));
|
||||||
|
vulkanDevice->setCommandPool(cmdPool);
|
||||||
/*
|
/*
|
||||||
Render pass
|
Render pass
|
||||||
*/
|
*/
|
||||||
|
@ -505,24 +505,6 @@ void VulkanExampleBase::initVulkan()
|
||||||
queueFamilyIndex creation
|
queueFamilyIndex creation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const float defaultQueuePriority(0.0f);
|
|
||||||
VkDeviceQueueCreateInfo queueCreateInfo = {};
|
|
||||||
uint32_t queueFamilyCount;
|
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, nullptr);
|
|
||||||
std::vector<VkQueueFamilyProperties> queueFamilyProperties(queueFamilyCount);
|
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, queueFamilyProperties.data());
|
|
||||||
for (uint32_t i = 0; i < static_cast<uint32_t>(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
|
Device creation
|
||||||
*/
|
*/
|
||||||
|
@ -543,9 +525,7 @@ void VulkanExampleBase::initVulkan()
|
||||||
Graphics queue
|
Graphics queue
|
||||||
*/
|
*/
|
||||||
vkGetDeviceQueue(device, vulkanDevice->queueFamilyIndices.graphics, 0, &queue);
|
vkGetDeviceQueue(device, vulkanDevice->queueFamilyIndices.graphics, 0, &queue);
|
||||||
|
queueFamilyIndex = vulkanDevice->queueFamilyIndices.graphics;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Suitable depth format
|
Suitable depth format
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -114,7 +114,7 @@ public:
|
||||||
|
|
||||||
VkFormat colorFormat = VK_FORMAT_R8G8B8A8_SRGB;
|
VkFormat colorFormat = VK_FORMAT_R8G8B8A8_SRGB;
|
||||||
uint32_t queueFamilyIndex;
|
uint32_t queueFamilyIndex;
|
||||||
uint32_t renderingFrameIndex;
|
uint32_t renderingFrameIndex = 3;
|
||||||
|
|
||||||
struct Signal
|
struct Signal
|
||||||
{
|
{
|
||||||
|
|
|
@ -321,14 +321,14 @@ PlumageRender::PlumageRender()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkDescriptorPoolSize> poolSizes = {
|
std::vector<VkDescriptorPoolSize> poolSizes = {
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, (4 + meshCount) * swapChain.imageCount },
|
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, (4 + meshCount) * renderingFrameIndex },
|
||||||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, imageSamplerCount * swapChain.imageCount }
|
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, imageSamplerCount * renderingFrameIndex }
|
||||||
};
|
};
|
||||||
VkDescriptorPoolCreateInfo descriptorPoolCI{};
|
VkDescriptorPoolCreateInfo descriptorPoolCI{};
|
||||||
descriptorPoolCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
descriptorPoolCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||||
descriptorPoolCI.poolSizeCount = 2;
|
descriptorPoolCI.poolSizeCount = 2;
|
||||||
descriptorPoolCI.pPoolSizes = poolSizes.data();
|
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));
|
VK_CHECK_RESULT(vkCreateDescriptorPool(device, &descriptorPoolCI, nullptr, &descriptorPool));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -357,7 +357,7 @@ PlumageRender::PlumageRender()
|
||||||
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
||||||
descriptorSetAllocInfo.pSetLayouts = &descriptorSetLayouts.scene;
|
descriptorSetAllocInfo.pSetLayouts = &descriptorSetLayouts.scene;
|
||||||
descriptorSetAllocInfo.descriptorSetCount = 1;
|
descriptorSetAllocInfo.descriptorSetCount = 1;
|
||||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &descriptorSets[i].scene));
|
vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &descriptorSets[i].scene);
|
||||||
|
|
||||||
std::array<VkWriteDescriptorSet, 5> writeDescriptorSets{};
|
std::array<VkWriteDescriptorSet, 5> writeDescriptorSets{};
|
||||||
|
|
||||||
|
@ -400,6 +400,7 @@ PlumageRender::PlumageRender()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Material (samplers)
|
// Material (samplers)
|
||||||
{
|
{
|
||||||
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings = {
|
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings = {
|
||||||
|
@ -1543,6 +1544,7 @@ PlumageRender::PlumageRender()
|
||||||
updateUIOverlay();
|
updateUIOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PlumageRender::prepare()
|
void PlumageRender::prepare()
|
||||||
{
|
{
|
||||||
VulkanExampleBase::prepare();
|
VulkanExampleBase::prepare();
|
||||||
|
@ -1986,7 +1988,7 @@ PlumageRender::PlumageRender()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUIOverlay();
|
//updateUIOverlay();
|
||||||
//加入写到文件的函数
|
//加入写到文件的函数
|
||||||
//swapChainImage = swapChain.images[frameIndex];
|
//swapChainImage = swapChain.images[frameIndex];
|
||||||
//outputImageSequeue(swapChainImage,filePath.imageSequenceFilePath);
|
//outputImageSequeue(swapChainImage,filePath.imageSequenceFilePath);
|
||||||
|
|
|
@ -142,8 +142,8 @@ public:
|
||||||
struct FilePath
|
struct FilePath
|
||||||
{ //model path
|
{ //model path
|
||||||
std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf";
|
std::string glTFModelFilePath = getAssetPath() + "models/DamagedHelmet/DamagedHelmet.gltf";
|
||||||
//std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv";
|
std::string modelVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.vert.spv";
|
||||||
//std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv";
|
std::string modelFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/mesh.frag.spv";
|
||||||
|
|
||||||
//ui
|
//ui
|
||||||
std::string uiVertShaderPath = getAssetPath() + "shaders/ui.vert.spv";
|
std::string uiVertShaderPath = getAssetPath() + "shaders/ui.vert.spv";
|
||||||
|
@ -154,7 +154,7 @@ public:
|
||||||
std::string skyboxVertShaderPath = getAssetPath() + "shaders/skybox.vert.spv";
|
std::string skyboxVertShaderPath = getAssetPath() + "shaders/skybox.vert.spv";
|
||||||
std::string skyboxFragShaderPath = getAssetPath() + "shaders/skybox.frag.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
|
//tonemapping
|
||||||
std::string tonemappingVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/genbrdflut.vert.spv";
|
std::string tonemappingVertShaderPath = getAssetPath() + "buster_drone/shaders/glsl/genbrdflut.vert.spv";
|
||||||
std::string tonemappingEnableFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/tonemapping_enable.frag.spv";
|
std::string tonemappingEnableFragShaderPath = getAssetPath() + "buster_drone/shaders/glsl/tonemapping_enable.frag.spv";
|
||||||
|
@ -342,7 +342,7 @@ public:
|
||||||
textures.prefilteredCube.destroy();
|
textures.prefilteredCube.destroy();
|
||||||
textures.lutBrdf.destroy();
|
textures.lutBrdf.destroy();
|
||||||
textures.empty.destroy();
|
textures.empty.destroy();
|
||||||
delete gui;
|
//delete gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue