```
refactor(render): 移除getter方法的const限定符并重构管线和描述符集获取方式 移除了RenderPipelineList中所有getter方法的const限定符,并更新了render.cpp中对 管线对象和描述符集合的访问方式。通过引入新的布局与管线管理类,如 RenderDescriptorSetLayoutList、RenderPipelineList等,替换原有的直接成员变量访问, 使代码结构更清晰且便于维护。同时添加了必要的头文件包含以支持新增的类引用。 ```reconstruct-gltfLoader
parent
d2d9db4aff
commit
1c207b7fab
|
|
@ -9,37 +9,37 @@ RenderPipelineList::~RenderPipelineList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getter method definitions
|
// Getter method definitions
|
||||||
VkPipeline RenderPipelineList::getSkybox() const
|
VkPipeline RenderPipelineList::getSkybox()
|
||||||
{
|
{
|
||||||
return skybox;
|
return skybox;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipeline RenderPipelineList::getPbr() const
|
VkPipeline RenderPipelineList::getPbr()
|
||||||
{
|
{
|
||||||
return pbr;
|
return pbr;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipeline RenderPipelineList::getPbrDoubleSided() const
|
VkPipeline RenderPipelineList::getPbrDoubleSided()
|
||||||
{
|
{
|
||||||
return pbrDoubleSided;
|
return pbrDoubleSided;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipeline RenderPipelineList::getPbrAlphaBlend() const
|
VkPipeline RenderPipelineList::getPbrAlphaBlend()
|
||||||
{
|
{
|
||||||
return pbrAlphaBlend;
|
return pbrAlphaBlend;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipeline RenderPipelineList::getSolid() const
|
VkPipeline RenderPipelineList::getSolid()
|
||||||
{
|
{
|
||||||
return solid;
|
return solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipeline RenderPipelineList::getWireframe() const
|
VkPipeline RenderPipelineList::getWireframe()
|
||||||
{
|
{
|
||||||
return wireframe;
|
return wireframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipeline RenderPipelineList::getToneMapping() const
|
VkPipeline RenderPipelineList::getToneMapping()
|
||||||
{
|
{
|
||||||
return toneMapping;
|
return toneMapping;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ public:
|
||||||
~RenderPipelineList();
|
~RenderPipelineList();
|
||||||
|
|
||||||
// Getter methods
|
// Getter methods
|
||||||
VkPipeline getSkybox() const;
|
VkPipeline getSkybox();
|
||||||
VkPipeline getPbr() const;
|
VkPipeline getPbr();
|
||||||
VkPipeline getPbrDoubleSided() const;
|
VkPipeline getPbrDoubleSided();
|
||||||
VkPipeline getPbrAlphaBlend() const;
|
VkPipeline getPbrAlphaBlend();
|
||||||
VkPipeline getSolid() const;
|
VkPipeline getSolid();
|
||||||
VkPipeline getWireframe() const;
|
VkPipeline getWireframe();
|
||||||
VkPipeline getToneMapping() const;
|
VkPipeline getToneMapping();
|
||||||
|
|
||||||
// Setter methods
|
// Setter methods
|
||||||
void setSkybox(VkPipeline pipeline);
|
void setSkybox(VkPipeline pipeline);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include "glTFModel.h"
|
#include "glTFModel.h"
|
||||||
#include "glm/gtc/matrix_transform.hpp"
|
#include "glm/gtc/matrix_transform.hpp"
|
||||||
#include "renderUniformBufferSet.h"
|
#include "renderUniformBufferSet.h"
|
||||||
|
#include "vulkan/vulkan_core.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
@ -43,10 +44,17 @@ void PlumageRender::renderNode(glTFModel::Node *node, uint32_t cbIndex, glTFMode
|
||||||
{
|
{
|
||||||
case glTFModel::Material::ALPHAMODE_OPAQUE:
|
case glTFModel::Material::ALPHAMODE_OPAQUE:
|
||||||
case glTFModel::Material::ALPHAMODE_MASK:
|
case glTFModel::Material::ALPHAMODE_MASK:
|
||||||
pipeline = primitive->material.doubleSided ? pipelines.pbrDoubleSided : pipelines.pbr;
|
if (primitive->material.doubleSided)
|
||||||
|
{
|
||||||
|
pipeline = m_pipelineList.getPbrDoubleSided();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pipeline = m_pipelineList.getPbr();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case glTFModel::Material::ALPHAMODE_BLEND:
|
case glTFModel::Material::ALPHAMODE_BLEND:
|
||||||
pipeline = pipelines.pbrAlphaBlend;
|
pipeline = m_pipelineList.getPbrAlphaBlend();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,7 +65,7 @@ void PlumageRender::renderNode(glTFModel::Node *node, uint32_t cbIndex, glTFMode
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<VkDescriptorSet> descriptorsets = {
|
const std::vector<VkDescriptorSet> descriptorsets = {
|
||||||
descriptorSets[cbIndex].scene,
|
descriptorSets[cbIndex].getScene(),
|
||||||
primitive->material.descriptorSet,
|
primitive->material.descriptorSet,
|
||||||
node->mesh->uniformBuffer.descriptorSet,
|
node->mesh->uniformBuffer.descriptorSet,
|
||||||
};
|
};
|
||||||
|
|
@ -235,8 +243,9 @@ void PlumageRender::buildCommandBuffers()
|
||||||
|
|
||||||
if (displayBackground)
|
if (displayBackground)
|
||||||
{
|
{
|
||||||
vkCmdBindDescriptorSets(currentCB, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets[i].skybox, 0, nullptr);
|
VkDescriptorSet skyboxDescriptorSet = descriptorSets[i].getSkybox();
|
||||||
vkCmdBindPipeline(currentCB, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.skybox);
|
vkCmdBindDescriptorSets(currentCB, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &skyboxDescriptorSet, 0, nullptr);
|
||||||
|
vkCmdBindPipeline(currentCB, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineList.getSkybox());
|
||||||
m_sceneModel.getSkyBox().draw(currentCB);
|
m_sceneModel.getSkyBox().draw(currentCB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,7 +379,8 @@ void PlumageRender::setupNodeDescriptorSet(glTFModel::Node *node)
|
||||||
VkDescriptorSetAllocateInfo descriptorSetAllocInfo{};
|
VkDescriptorSetAllocateInfo descriptorSetAllocInfo{};
|
||||||
descriptorSetAllocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
descriptorSetAllocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
||||||
descriptorSetAllocInfo.pSetLayouts = &descriptorSetLayouts.node;
|
VkDescriptorSetLayout nodeDescriptorSetLayout = m_descriptorSetLayoutList.getNode();
|
||||||
|
descriptorSetAllocInfo.pSetLayouts = &nodeDescriptorSetLayout;
|
||||||
descriptorSetAllocInfo.descriptorSetCount = 1;
|
descriptorSetAllocInfo.descriptorSetCount = 1;
|
||||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &node->mesh->uniformBuffer.descriptorSet));
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &node->mesh->uniformBuffer.descriptorSet));
|
||||||
|
|
||||||
|
|
@ -446,7 +456,8 @@ void PlumageRender::setupDescriptors()
|
||||||
descriptorSetLayoutCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
descriptorSetLayoutCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||||
descriptorSetLayoutCI.pBindings = setLayoutBindings.data();
|
descriptorSetLayoutCI.pBindings = setLayoutBindings.data();
|
||||||
descriptorSetLayoutCI.bindingCount = static_cast<uint32_t>(setLayoutBindings.size());
|
descriptorSetLayoutCI.bindingCount = static_cast<uint32_t>(setLayoutBindings.size());
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &descriptorSetLayouts.scene));
|
VkDescriptorSetLayout sceneDescriptorSetLayout = m_descriptorSetLayoutList.getScene();
|
||||||
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &sceneDescriptorSetLayout));
|
||||||
|
|
||||||
vks::TextureCubeMap refIrradianceCube = m_sceneTextures.getIrradianceCube();
|
vks::TextureCubeMap refIrradianceCube = m_sceneTextures.getIrradianceCube();
|
||||||
for (auto i = 0; i < descriptorSets.size(); i++)
|
for (auto i = 0; i < descriptorSets.size(); i++)
|
||||||
|
|
@ -455,44 +466,46 @@ void PlumageRender::setupDescriptors()
|
||||||
VkDescriptorSetAllocateInfo descriptorSetAllocInfo{};
|
VkDescriptorSetAllocateInfo descriptorSetAllocInfo{};
|
||||||
descriptorSetAllocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
descriptorSetAllocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
||||||
descriptorSetAllocInfo.pSetLayouts = &descriptorSetLayouts.scene;
|
VkDescriptorSetLayout sceneDescriptorSetLayout = m_descriptorSetLayoutList.getScene();
|
||||||
|
descriptorSetAllocInfo.pSetLayouts = &sceneDescriptorSetLayout;
|
||||||
descriptorSetAllocInfo.descriptorSetCount = 1;
|
descriptorSetAllocInfo.descriptorSetCount = 1;
|
||||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &descriptorSets[i].scene));
|
VkDescriptorSet sceneDescriptorSet = descriptorSets[i].getScene();
|
||||||
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &sceneDescriptorSet));
|
||||||
|
|
||||||
std::array<VkWriteDescriptorSet, 5> writeDescriptorSets{};
|
std::array<VkWriteDescriptorSet, 5> writeDescriptorSets{};
|
||||||
|
|
||||||
writeDescriptorSets[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
writeDescriptorSets[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
writeDescriptorSets[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
writeDescriptorSets[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
writeDescriptorSets[0].descriptorCount = 1;
|
writeDescriptorSets[0].descriptorCount = 1;
|
||||||
writeDescriptorSets[0].dstSet = descriptorSets[i].scene;
|
writeDescriptorSets[0].dstSet = descriptorSets[i].getScene();
|
||||||
writeDescriptorSets[0].dstBinding = 0;
|
writeDescriptorSets[0].dstBinding = 0;
|
||||||
writeDescriptorSets[0].pBufferInfo = &uniformBuffers[i].getScene().descriptor;
|
writeDescriptorSets[0].pBufferInfo = &uniformBuffers[i].getScene().descriptor;
|
||||||
|
|
||||||
writeDescriptorSets[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
writeDescriptorSets[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
writeDescriptorSets[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
writeDescriptorSets[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
writeDescriptorSets[1].descriptorCount = 1;
|
writeDescriptorSets[1].descriptorCount = 1;
|
||||||
writeDescriptorSets[1].dstSet = descriptorSets[i].scene;
|
writeDescriptorSets[1].dstSet = descriptorSets[i].getScene();
|
||||||
writeDescriptorSets[1].dstBinding = 1;
|
writeDescriptorSets[1].dstBinding = 1;
|
||||||
writeDescriptorSets[1].pBufferInfo = &uniformBuffers[i].getParams().descriptor;
|
writeDescriptorSets[1].pBufferInfo = &uniformBuffers[i].getParams().descriptor;
|
||||||
|
|
||||||
writeDescriptorSets[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
writeDescriptorSets[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
writeDescriptorSets[2].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
writeDescriptorSets[2].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
writeDescriptorSets[2].descriptorCount = 1;
|
writeDescriptorSets[2].descriptorCount = 1;
|
||||||
writeDescriptorSets[2].dstSet = descriptorSets[i].scene;
|
writeDescriptorSets[2].dstSet = descriptorSets[i].getScene();
|
||||||
writeDescriptorSets[2].dstBinding = 2;
|
writeDescriptorSets[2].dstBinding = 2;
|
||||||
writeDescriptorSets[2].pImageInfo = &refIrradianceCube.descriptor;
|
writeDescriptorSets[2].pImageInfo = &refIrradianceCube.descriptor;
|
||||||
|
|
||||||
writeDescriptorSets[3].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
writeDescriptorSets[3].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
writeDescriptorSets[3].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
writeDescriptorSets[3].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
writeDescriptorSets[3].descriptorCount = 1;
|
writeDescriptorSets[3].descriptorCount = 1;
|
||||||
writeDescriptorSets[3].dstSet = descriptorSets[i].scene;
|
writeDescriptorSets[3].dstSet = descriptorSets[i].getScene();
|
||||||
writeDescriptorSets[3].dstBinding = 3;
|
writeDescriptorSets[3].dstBinding = 3;
|
||||||
writeDescriptorSets[3].pImageInfo = &refIrradianceCube.descriptor;
|
writeDescriptorSets[3].pImageInfo = &refIrradianceCube.descriptor;
|
||||||
|
|
||||||
writeDescriptorSets[4].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
writeDescriptorSets[4].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
writeDescriptorSets[4].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
writeDescriptorSets[4].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
writeDescriptorSets[4].descriptorCount = 1;
|
writeDescriptorSets[4].descriptorCount = 1;
|
||||||
writeDescriptorSets[4].dstSet = descriptorSets[i].scene;
|
writeDescriptorSets[4].dstSet = descriptorSets[i].getScene();
|
||||||
writeDescriptorSets[4].dstBinding = 4;
|
writeDescriptorSets[4].dstBinding = 4;
|
||||||
writeDescriptorSets[4].pImageInfo = &refIrradianceCube.descriptor;
|
writeDescriptorSets[4].pImageInfo = &refIrradianceCube.descriptor;
|
||||||
|
|
||||||
|
|
@ -513,7 +526,8 @@ void PlumageRender::setupDescriptors()
|
||||||
descriptorSetLayoutCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
descriptorSetLayoutCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||||
descriptorSetLayoutCI.pBindings = setLayoutBindings.data();
|
descriptorSetLayoutCI.pBindings = setLayoutBindings.data();
|
||||||
descriptorSetLayoutCI.bindingCount = static_cast<uint32_t>(setLayoutBindings.size());
|
descriptorSetLayoutCI.bindingCount = static_cast<uint32_t>(setLayoutBindings.size());
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &descriptorSetLayouts.material));
|
VkDescriptorSetLayout materialDescriptorSetLayout = m_descriptorSetLayoutList.getMaterial();
|
||||||
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &materialDescriptorSetLayout));
|
||||||
|
|
||||||
// Per-Material descriptor sets
|
// Per-Material descriptor sets
|
||||||
for (auto &material : m_sceneModel.getScene().materials)
|
for (auto &material : m_sceneModel.getScene().materials)
|
||||||
|
|
@ -521,7 +535,8 @@ void PlumageRender::setupDescriptors()
|
||||||
VkDescriptorSetAllocateInfo descriptorSetAllocInfo{};
|
VkDescriptorSetAllocateInfo descriptorSetAllocInfo{};
|
||||||
descriptorSetAllocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
descriptorSetAllocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
||||||
descriptorSetAllocInfo.pSetLayouts = &descriptorSetLayouts.material;
|
VkDescriptorSetLayout materialDescriptorSetLayout = m_descriptorSetLayoutList.getMaterial();
|
||||||
|
descriptorSetAllocInfo.pSetLayouts = &materialDescriptorSetLayout;
|
||||||
descriptorSetAllocInfo.descriptorSetCount = 1;
|
descriptorSetAllocInfo.descriptorSetCount = 1;
|
||||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &material.descriptorSet));
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &material.descriptorSet));
|
||||||
VkDescriptorImageInfo emptyTexDescriptor = m_sceneTextures.getEmpty().descriptor;
|
VkDescriptorImageInfo emptyTexDescriptor = m_sceneTextures.getEmpty().descriptor;
|
||||||
|
|
@ -579,7 +594,8 @@ void PlumageRender::setupDescriptors()
|
||||||
descriptorSetLayoutCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
descriptorSetLayoutCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||||
descriptorSetLayoutCI.pBindings = setLayoutBindings.data();
|
descriptorSetLayoutCI.pBindings = setLayoutBindings.data();
|
||||||
descriptorSetLayoutCI.bindingCount = static_cast<uint32_t>(setLayoutBindings.size());
|
descriptorSetLayoutCI.bindingCount = static_cast<uint32_t>(setLayoutBindings.size());
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &descriptorSetLayouts.node));
|
VkDescriptorSetLayout nodeDescriptorSetLayout = m_descriptorSetLayoutList.getNode();
|
||||||
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &nodeDescriptorSetLayout));
|
||||||
|
|
||||||
// Per-Node descriptor set
|
// Per-Node descriptor set
|
||||||
for (auto &node : m_sceneModel.getScene().nodes)
|
for (auto &node : m_sceneModel.getScene().nodes)
|
||||||
|
|
@ -596,30 +612,32 @@ void PlumageRender::setupDescriptors()
|
||||||
VkDescriptorSetAllocateInfo descriptorSetAllocInfo{};
|
VkDescriptorSetAllocateInfo descriptorSetAllocInfo{};
|
||||||
descriptorSetAllocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
descriptorSetAllocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
descriptorSetAllocInfo.descriptorPool = descriptorPool;
|
||||||
descriptorSetAllocInfo.pSetLayouts = &descriptorSetLayouts.scene;
|
VkDescriptorSetLayout sceneDescriptorSetLayouts = m_descriptorSetLayoutList.getScene();
|
||||||
|
descriptorSetAllocInfo.pSetLayouts = &sceneDescriptorSetLayouts;
|
||||||
descriptorSetAllocInfo.descriptorSetCount = 1;
|
descriptorSetAllocInfo.descriptorSetCount = 1;
|
||||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &descriptorSets[i].skybox));
|
VkDescriptorSet skyboxDescriptorSet = descriptorSets[i].getSkybox();
|
||||||
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &skyboxDescriptorSet));
|
||||||
|
|
||||||
std::array<VkWriteDescriptorSet, 3> writeDescriptorSets{};
|
std::array<VkWriteDescriptorSet, 3> writeDescriptorSets{};
|
||||||
|
|
||||||
writeDescriptorSets[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
writeDescriptorSets[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
writeDescriptorSets[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
writeDescriptorSets[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
writeDescriptorSets[0].descriptorCount = 1;
|
writeDescriptorSets[0].descriptorCount = 1;
|
||||||
writeDescriptorSets[0].dstSet = descriptorSets[i].skybox;
|
writeDescriptorSets[0].dstSet = descriptorSets[i].getSkybox();
|
||||||
writeDescriptorSets[0].dstBinding = 0;
|
writeDescriptorSets[0].dstBinding = 0;
|
||||||
writeDescriptorSets[0].pBufferInfo = &uniformBuffers[i].getSkybox().descriptor;
|
writeDescriptorSets[0].pBufferInfo = &uniformBuffers[i].getSkybox().descriptor;
|
||||||
|
|
||||||
writeDescriptorSets[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
writeDescriptorSets[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
writeDescriptorSets[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
writeDescriptorSets[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
writeDescriptorSets[1].descriptorCount = 1;
|
writeDescriptorSets[1].descriptorCount = 1;
|
||||||
writeDescriptorSets[1].dstSet = descriptorSets[i].skybox;
|
writeDescriptorSets[1].dstSet = descriptorSets[i].getSkybox();
|
||||||
writeDescriptorSets[1].dstBinding = 1;
|
writeDescriptorSets[1].dstBinding = 1;
|
||||||
writeDescriptorSets[1].pBufferInfo = &uniformBuffers[i].getParams().descriptor;
|
writeDescriptorSets[1].pBufferInfo = &uniformBuffers[i].getParams().descriptor;
|
||||||
|
|
||||||
writeDescriptorSets[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
writeDescriptorSets[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
writeDescriptorSets[2].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
writeDescriptorSets[2].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
writeDescriptorSets[2].descriptorCount = 1;
|
writeDescriptorSets[2].descriptorCount = 1;
|
||||||
writeDescriptorSets[2].dstSet = descriptorSets[i].skybox;
|
writeDescriptorSets[2].dstSet = descriptorSets[i].getSkybox();
|
||||||
writeDescriptorSets[2].dstBinding = 2;
|
writeDescriptorSets[2].dstBinding = 2;
|
||||||
writeDescriptorSets[2].pImageInfo = &refPrefilterCube.descriptor;
|
writeDescriptorSets[2].pImageInfo = &refPrefilterCube.descriptor;
|
||||||
|
|
||||||
|
|
@ -680,7 +698,7 @@ void PlumageRender::preparePipelines()
|
||||||
|
|
||||||
// Pipeline layout
|
// Pipeline layout
|
||||||
const std::vector<VkDescriptorSetLayout> setLayouts = {
|
const std::vector<VkDescriptorSetLayout> setLayouts = {
|
||||||
descriptorSetLayouts.scene, descriptorSetLayouts.material, descriptorSetLayouts.node};
|
m_descriptorSetLayoutList.getScene(), m_descriptorSetLayoutList.getMaterial(), m_descriptorSetLayoutList.getNode()};
|
||||||
VkPipelineLayoutCreateInfo pipelineLayoutCI{};
|
VkPipelineLayoutCreateInfo pipelineLayoutCI{};
|
||||||
pipelineLayoutCI.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
pipelineLayoutCI.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||||
pipelineLayoutCI.setLayoutCount = static_cast<uint32_t>(setLayouts.size());
|
pipelineLayoutCI.setLayoutCount = static_cast<uint32_t>(setLayouts.size());
|
||||||
|
|
@ -736,7 +754,8 @@ void PlumageRender::preparePipelines()
|
||||||
shaderStages = {
|
shaderStages = {
|
||||||
loadShader(device, m_configFilePath.getSkyboxVertShaderPath(), VK_SHADER_STAGE_VERTEX_BIT),
|
loadShader(device, m_configFilePath.getSkyboxVertShaderPath(), VK_SHADER_STAGE_VERTEX_BIT),
|
||||||
loadShader(device, m_configFilePath.getSkyboxFragShaderPath(), VK_SHADER_STAGE_FRAGMENT_BIT)};
|
loadShader(device, m_configFilePath.getSkyboxFragShaderPath(), VK_SHADER_STAGE_FRAGMENT_BIT)};
|
||||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.skybox));
|
VkPipeline skyboxPipeline = m_pipelineList.getSkybox();
|
||||||
|
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &skyboxPipeline));
|
||||||
for (auto shaderStage : shaderStages)
|
for (auto shaderStage : shaderStages)
|
||||||
{
|
{
|
||||||
vkDestroyShaderModule(device, shaderStage.module, nullptr);
|
vkDestroyShaderModule(device, shaderStage.module, nullptr);
|
||||||
|
|
@ -748,9 +767,11 @@ void PlumageRender::preparePipelines()
|
||||||
loadShader(device, m_configFilePath.getPbrFragShaderPath(), VK_SHADER_STAGE_FRAGMENT_BIT)};
|
loadShader(device, m_configFilePath.getPbrFragShaderPath(), VK_SHADER_STAGE_FRAGMENT_BIT)};
|
||||||
depthStencilStateCI.depthWriteEnable = VK_TRUE;
|
depthStencilStateCI.depthWriteEnable = VK_TRUE;
|
||||||
depthStencilStateCI.depthTestEnable = VK_TRUE;
|
depthStencilStateCI.depthTestEnable = VK_TRUE;
|
||||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.pbr));
|
VkPipeline pbrPipeline = m_pipelineList.getPbr();
|
||||||
|
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pbrPipeline));
|
||||||
rasterizationStateCI.cullMode = VK_CULL_MODE_NONE;
|
rasterizationStateCI.cullMode = VK_CULL_MODE_NONE;
|
||||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.pbrDoubleSided));
|
VkPipeline pbrDoubleSidedPipeline = m_pipelineList.getPbrDoubleSided();
|
||||||
|
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pbrDoubleSidedPipeline));
|
||||||
|
|
||||||
rasterizationStateCI.cullMode = VK_CULL_MODE_NONE;
|
rasterizationStateCI.cullMode = VK_CULL_MODE_NONE;
|
||||||
blendAttachmentState.blendEnable = VK_TRUE;
|
blendAttachmentState.blendEnable = VK_TRUE;
|
||||||
|
|
@ -761,7 +782,8 @@ void PlumageRender::preparePipelines()
|
||||||
blendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
blendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||||
blendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
blendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
||||||
blendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD;
|
blendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD;
|
||||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.pbrAlphaBlend));
|
VkPipeline pbrAlphaBlendPipeline = m_pipelineList.getPbrAlphaBlend();
|
||||||
|
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pbrAlphaBlendPipeline));
|
||||||
|
|
||||||
for (auto shaderStage : shaderStages)
|
for (auto shaderStage : shaderStages)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ConfigFilePath.h"
|
#include "ConfigFilePath.h"
|
||||||
|
#include "RenderDescriptorSetLayoutList.h"
|
||||||
|
#include "RenderPipelineList.h"
|
||||||
#include "RenderSceneTextures.h"
|
#include "RenderSceneTextures.h"
|
||||||
#include "renderShaderData.h"
|
#include "renderShaderData.h"
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
@ -41,9 +43,15 @@
|
||||||
#include "LocalizationStrings.h"
|
#include "LocalizationStrings.h"
|
||||||
|
|
||||||
#include "ConfigFilePath.h"
|
#include "ConfigFilePath.h"
|
||||||
|
#include "IndexStagingBuffer.h"
|
||||||
|
#include "RenderDescriptorSetLayoutList.h"
|
||||||
|
#include "RenderDescriptorSetList.h"
|
||||||
|
#include "RenderPipelineLayoutList.h"
|
||||||
|
#include "RenderPipelineList.h"
|
||||||
#include "RenderSceneTextures.h"
|
#include "RenderSceneTextures.h"
|
||||||
#include "SceneUBOMatrices.h"
|
#include "SceneUBOMatrices.h"
|
||||||
#include "SkyboxUBOMatrices.h"
|
#include "SkyboxUBOMatrices.h"
|
||||||
|
#include "VertexStagingBuffer.h"
|
||||||
#include "renderEffectState.h"
|
#include "renderEffectState.h"
|
||||||
#include "renderSceneModel.h"
|
#include "renderSceneModel.h"
|
||||||
#include "renderShaderData.h"
|
#include "renderShaderData.h"
|
||||||
|
|
@ -64,6 +72,13 @@ private:
|
||||||
SkyboxUBOMatrices m_shaderDataSkybox;
|
SkyboxUBOMatrices m_shaderDataSkybox;
|
||||||
|
|
||||||
ConfigFilePath m_configFilePath;
|
ConfigFilePath m_configFilePath;
|
||||||
|
IndexStagingBuffer m_IndexStagingBuffer;
|
||||||
|
VertexStagingBuffer m_VertexStagingBuffer;
|
||||||
|
|
||||||
|
RenderPipelineList m_pipelineList;
|
||||||
|
RenderPipelineLayoutList m_pipelineLayoutList;
|
||||||
|
|
||||||
|
RenderDescriptorSetLayoutList m_descriptorSetLayoutList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
float modelrot = 0.0f;
|
float modelrot = 0.0f;
|
||||||
|
|
@ -83,50 +98,11 @@ public:
|
||||||
int32_t debugViewInputs = 0;
|
int32_t debugViewInputs = 0;
|
||||||
int32_t debugViewEquation = 0;
|
int32_t debugViewEquation = 0;
|
||||||
|
|
||||||
struct StagingBuffer
|
|
||||||
{
|
|
||||||
VkBuffer buffer;
|
|
||||||
VkDeviceMemory memory;
|
|
||||||
} vertexStaging, indexStaging;
|
|
||||||
|
|
||||||
struct Pipelines
|
|
||||||
{
|
|
||||||
VkPipeline skybox;
|
|
||||||
VkPipeline pbr;
|
|
||||||
VkPipeline pbrDoubleSided;
|
|
||||||
VkPipeline pbrAlphaBlend;
|
|
||||||
VkPipeline solid;
|
|
||||||
VkPipeline wireframe = VK_NULL_HANDLE;
|
|
||||||
VkPipeline toneMapping = VK_NULL_HANDLE;
|
|
||||||
} pipelines;
|
|
||||||
|
|
||||||
VkPipeline boundPipeline = VK_NULL_HANDLE;
|
VkPipeline boundPipeline = VK_NULL_HANDLE;
|
||||||
|
|
||||||
struct PipelineLayouts
|
|
||||||
{
|
|
||||||
VkDescriptorSetLayout scene;
|
|
||||||
VkDescriptorSetLayout material;
|
|
||||||
VkDescriptorSetLayout node;
|
|
||||||
VkPipelineLayout tonemappingLayout;
|
|
||||||
} pipelineLayouts;
|
|
||||||
|
|
||||||
VkPipelineLayout pipelineLayout;
|
VkPipelineLayout pipelineLayout;
|
||||||
|
|
||||||
struct DescriptorSets
|
std::vector<RenderDescriptorSetList> descriptorSets;
|
||||||
{
|
|
||||||
VkDescriptorSet scene;
|
|
||||||
VkDescriptorSet skybox;
|
|
||||||
VkDescriptorSet tonemappingDescriptorSet = VK_NULL_HANDLE;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DescriptorSetLayouts
|
|
||||||
{
|
|
||||||
VkDescriptorSetLayout scene;
|
|
||||||
VkDescriptorSetLayout material;
|
|
||||||
VkDescriptorSetLayout node;
|
|
||||||
} descriptorSetLayouts;
|
|
||||||
|
|
||||||
std::vector<DescriptorSets> descriptorSets;
|
|
||||||
|
|
||||||
std::vector<VkCommandBuffer> commandBuffers;
|
std::vector<VkCommandBuffer> commandBuffers;
|
||||||
std::vector<RenderUniformBufferSet> uniformBuffers;
|
std::vector<RenderUniformBufferSet> uniformBuffers;
|
||||||
|
|
@ -186,14 +162,14 @@ 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.skybox, nullptr);
|
vkDestroyPipeline(device, m_pipelineList.getSkybox(), nullptr);
|
||||||
vkDestroyPipeline(device, pipelines.pbr, nullptr);
|
vkDestroyPipeline(device, m_pipelineList.getPbr(), nullptr);
|
||||||
vkDestroyPipeline(device, pipelines.pbrAlphaBlend, nullptr);
|
vkDestroyPipeline(device, m_pipelineList.getPbrAlphaBlend(), nullptr);
|
||||||
|
|
||||||
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
||||||
vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.scene, nullptr);
|
vkDestroyDescriptorSetLayout(device, m_descriptorSetLayoutList.getScene(), nullptr);
|
||||||
vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.material, nullptr);
|
vkDestroyDescriptorSetLayout(device, m_descriptorSetLayoutList.getMaterial(), nullptr);
|
||||||
vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.node, nullptr);
|
vkDestroyDescriptorSetLayout(device, m_descriptorSetLayoutList.getNode(), nullptr);
|
||||||
|
|
||||||
m_sceneModel.destroyScene(device);
|
m_sceneModel.destroyScene(device);
|
||||||
m_sceneModel.destroySkyBox(device);
|
m_sceneModel.destroySkyBox(device);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue