Enabling other passes
This commit is contained in:
@@ -11,6 +11,7 @@ struct LightCullingData
|
||||
RWTexture2D<uint2> oLightGrid;
|
||||
RWTexture2D<uint2> tLightGrid;
|
||||
};
|
||||
layout(set=5)
|
||||
ParameterBlock<LightCullingData> pLightCullingData;
|
||||
|
||||
[shader("pixel")]
|
||||
|
||||
@@ -68,5 +68,5 @@ struct LightEnv
|
||||
StructuredBuffer<PointLight> pointLights;
|
||||
uint numPointLights;
|
||||
};
|
||||
|
||||
layout(set=3)
|
||||
ParameterBlock<LightEnv> pLightEnv;
|
||||
|
||||
@@ -8,4 +8,5 @@ interface IMaterial
|
||||
BRDF prepare(MaterialParameter input);
|
||||
};
|
||||
|
||||
layout(set=4)
|
||||
ParameterBlock<IMaterial> pMaterial;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -32,21 +32,22 @@ void DescriptorLayout::create()
|
||||
for (size_t i = 0; i < descriptorBindings.size(); ++i)
|
||||
{
|
||||
VkDescriptorSetLayoutBinding &binding = bindings[i];
|
||||
const Gfx::DescriptorBinding &rhiBinding = descriptorBindings[i];
|
||||
binding.binding = rhiBinding.binding;
|
||||
binding.descriptorCount = rhiBinding.descriptorCount;
|
||||
binding.descriptorType = cast(rhiBinding.descriptorType);
|
||||
binding.stageFlags = rhiBinding.shaderStages;
|
||||
const Gfx::DescriptorBinding &gfxBinding = descriptorBindings[i];
|
||||
binding.binding = gfxBinding.binding;
|
||||
binding.descriptorCount = gfxBinding.descriptorCount;
|
||||
binding.descriptorType = cast(gfxBinding.descriptorType);
|
||||
binding.stageFlags = gfxBinding.shaderStages;
|
||||
binding.pImmutableSamplers = nullptr;
|
||||
bindingFlags[i] = rhiBinding.bindingFlags;
|
||||
bindingFlags[i] = gfxBinding.bindingFlags;
|
||||
}
|
||||
VkDescriptorSetLayoutCreateInfo createInfo =
|
||||
init::DescriptorSetLayoutCreateInfo(bindings.data(), (uint32)bindings.size());
|
||||
VkDescriptorSetLayoutBindingFlagsCreateInfo bindingFlagsInfo = {};
|
||||
bindingFlagsInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO;
|
||||
bindingFlagsInfo.pNext = nullptr;
|
||||
bindingFlagsInfo.bindingCount = static_cast<uint32>(bindingFlags.size());
|
||||
bindingFlagsInfo.pBindingFlags = bindingFlags.data();
|
||||
VkDescriptorSetLayoutBindingFlagsCreateInfo bindingFlagsInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.bindingCount = static_cast<uint32>(bindingFlags.size()),
|
||||
.pBindingFlags = bindingFlags.data(),
|
||||
};
|
||||
createInfo.pNext = &bindingFlagsInfo;
|
||||
VK_CHECK(vkCreateDescriptorSetLayout(graphics->getDevice(), &createInfo, nullptr, &layoutHandle));
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate
|
||||
, scene(new Scene(graphics))
|
||||
, gameInterface(dllPath)
|
||||
, renderGraph(RenderGraphBuilder::build(
|
||||
DepthPrepass(graphics, scene)
|
||||
//LightCullingPass(graphics, scene),
|
||||
//BasePass(graphics, scene),
|
||||
//SkyboxRenderPass(graphics, scene)
|
||||
DepthPrepass(graphics, scene),
|
||||
LightCullingPass(graphics, scene),
|
||||
BasePass(graphics, scene),
|
||||
SkyboxRenderPass(graphics, scene)
|
||||
))
|
||||
{
|
||||
camera = new CameraActor(scene);
|
||||
|
||||
@@ -31,10 +31,10 @@ private:
|
||||
OEntity camera;
|
||||
GameInterface gameInterface;
|
||||
RenderGraph<
|
||||
DepthPrepass
|
||||
//LightCullingPass,
|
||||
//BasePass,
|
||||
//SkyboxRenderPass
|
||||
DepthPrepass,
|
||||
LightCullingPass,
|
||||
BasePass,
|
||||
SkyboxRenderPass
|
||||
> renderGraph;
|
||||
|
||||
PSystemGraph systemGraph;
|
||||
|
||||
Reference in New Issue
Block a user