Enabling other passes
This commit is contained in:
@@ -74,39 +74,37 @@ void BasePass::render()
|
||||
|
||||
graphics->beginRenderPass(renderPass);
|
||||
Gfx::ShaderPermutation permutation;
|
||||
permutation.hasFragment = true;
|
||||
if(graphics->supportMeshShading())
|
||||
if (graphics->supportMeshShading())
|
||||
{
|
||||
permutation.useMeshShading = true;
|
||||
permutation.hasTaskShader = true;
|
||||
std::memcpy(permutation.taskFile, "MeshletBasePass", sizeof("MeshletBasePass"));
|
||||
std::memcpy(permutation.vertexMeshFile, "MeshletBasePass", sizeof("MeshletBasePass"));
|
||||
permutation.setTaskFile("MeshletBasePass");
|
||||
permutation.setMeshFile("MeshletBasePass");
|
||||
}
|
||||
else
|
||||
{
|
||||
permutation.useMeshShading = false;
|
||||
std::memcpy(permutation.vertexMeshFile, "LegacyBasePass", sizeof("LegacyBasePass"));
|
||||
permutation.setVertexFile("LegacyBasePass");
|
||||
}
|
||||
std::memcpy(permutation.fragmentFile, "BasePass", std::strlen("BasePass"));
|
||||
permutation.setFragmentFile("BasePass");
|
||||
graphics->beginRenderPass(renderPass);
|
||||
Array<Gfx::PRenderCommand> commands;
|
||||
for (VertexData* vertexData : VertexData::getList())
|
||||
{
|
||||
std::memcpy(permutation.vertexDataName, vertexData->getTypeName().c_str(), std::strlen(vertexData->getTypeName().c_str()));
|
||||
permutation.setVertexData(vertexData->getTypeName());
|
||||
const auto& materials = vertexData->getMaterialData();
|
||||
for (const auto& [_, materialData] : materials)
|
||||
{
|
||||
// Create Pipeline(Material, VertexData)
|
||||
// Descriptors:
|
||||
// ViewData => global, static
|
||||
// LightEnv => global, static
|
||||
// LightCulling => global, static
|
||||
// Material => per material
|
||||
// VertexData => per meshtype
|
||||
// SceneData => per material instance
|
||||
|
||||
std::memcpy(permutation.materialName, materialData.material->getName().c_str(), std::strlen(materialData.material->getName().c_str()));
|
||||
// LightEnv => provided by scene
|
||||
// Material => per material
|
||||
// LightCulling => calculated by pass
|
||||
permutation.setMaterial(materialData.material->getName());
|
||||
Gfx::PermutationId id(permutation);
|
||||
|
||||
Gfx::PRenderCommand command = graphics->createRenderCommand("DepthRender");
|
||||
command->setViewport(viewport);
|
||||
Gfx::OPipelineLayout layout = graphics->createPipelineLayout(basePassLayout);
|
||||
layout->addDescriptorLayout(INDEX_MATERIAL, materialData.material->getDescriptorLayout());
|
||||
layout->addDescriptorLayout(INDEX_VERTEX_DATA, vertexData->getVertexDataLayout());
|
||||
@@ -115,7 +113,7 @@ void BasePass::render()
|
||||
|
||||
const Gfx::ShaderCollection* collection = graphics->getShaderCompiler()->findShaders(id);
|
||||
assert(collection != nullptr);
|
||||
if(graphics->supportMeshShading())
|
||||
if (graphics->supportMeshShading())
|
||||
{
|
||||
Gfx::MeshPipelineCreateInfo pipelineInfo;
|
||||
pipelineInfo.taskShader = collection->taskShader;
|
||||
@@ -146,14 +144,14 @@ void BasePass::render()
|
||||
descriptorSets[INDEX_MATERIAL] = instance.materialInstance->getDescriptorSet();
|
||||
descriptorSets[INDEX_SCENE_DATA] = instance.descriptorSet;
|
||||
command->bindDescriptor(descriptorSets);
|
||||
if(Gfx::useMeshShading)
|
||||
if (graphics->supportMeshShading())
|
||||
{
|
||||
command->dispatch(instance.numMeshes, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 instanceOffset = 0;
|
||||
for(const auto& mesh : instance.meshes)
|
||||
for (const auto& mesh : instance.meshes)
|
||||
{
|
||||
uint32 vertexOffset = vertexData->getMeshOffset(mesh.id);
|
||||
if (mesh.indexBuffer != nullptr)
|
||||
@@ -165,11 +163,14 @@ void BasePass::render()
|
||||
{
|
||||
command->draw(vertexData->getMeshVertexCount(mesh.id), 1, vertexOffset, instanceOffset);
|
||||
}
|
||||
instanceOffset += mesh.meshes;
|
||||
}
|
||||
}
|
||||
}
|
||||
commands.add(command);
|
||||
}
|
||||
}
|
||||
graphics->executeCommands(commands);
|
||||
graphics->endRenderPass();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,17 +31,17 @@ private:
|
||||
Gfx::OPipelineLayout basePassLayout;
|
||||
// Set 0: viewParameter, provided by renderpass
|
||||
static constexpr uint32 INDEX_VIEW_PARAMS = 0;
|
||||
// Set 1: light environment, provided by lightenv
|
||||
static constexpr uint32 INDEX_LIGHT_ENV = 1;
|
||||
// Set 2: light culling data
|
||||
static constexpr uint32 INDEX_LIGHT_CULLING = 2;
|
||||
// Set 1: vertex buffers, provided by vertexdata
|
||||
static constexpr uint32 INDEX_VERTEX_DATA = 1;
|
||||
// Set 2: instance data, provided by vertexdata
|
||||
static constexpr uint32 INDEX_SCENE_DATA = 2;
|
||||
// Set 3: light environment, provided by lightenv
|
||||
static constexpr uint32 INDEX_LIGHT_ENV = 3;
|
||||
// Set 4: material data, generated from material
|
||||
static constexpr uint32 INDEX_MATERIAL = 4;
|
||||
// Set 5: light culling data
|
||||
Gfx::ODescriptorLayout lightCullingLayout;
|
||||
// Set 3: material data, generated from material
|
||||
static constexpr uint32 INDEX_MATERIAL = 3;
|
||||
// Set 4: vertex buffers, provided by vertexdata
|
||||
static constexpr uint32 INDEX_VERTEX_DATA = 4;
|
||||
// Set 5: instance data, provided by vertexdata
|
||||
static constexpr uint32 INDEX_SCENE_DATA = 5;
|
||||
static constexpr uint32 INDEX_LIGHT_CULLING = 5;
|
||||
};
|
||||
DEFINE_REF(BasePass)
|
||||
} // namespace Seele
|
||||
|
||||
@@ -125,7 +125,7 @@ void LightCullingPass::publishOutputs()
|
||||
|
||||
ShaderCreateInfo createInfo;
|
||||
createInfo.name = "Culling";
|
||||
|
||||
createInfo.additionalModules.add("LightCulling");
|
||||
createInfo.mainModule = "LightCulling";
|
||||
createInfo.entryPoint = "cullLights";
|
||||
cullingShader = graphics->createComputeShader(createInfo);
|
||||
@@ -209,7 +209,7 @@ void LightCullingPass::setupFrustums()
|
||||
frustumLayout->create();
|
||||
ShaderCreateInfo createInfo;
|
||||
createInfo.name = "Frustum";
|
||||
|
||||
createInfo.additionalModules.add("ComputeFrustums");
|
||||
createInfo.mainModule = "ComputeFrustums";
|
||||
createInfo.entryPoint = "computeFrustums";
|
||||
frustumShader = graphics->createComputeShader(createInfo);
|
||||
|
||||
Reference in New Issue
Block a user