Implement quick shader switch hotkeys

This commit is contained in:
Dynamitos
2024-05-23 14:58:14 +02:00
parent 8399b176bb
commit e0961bce24
20 changed files with 160 additions and 110 deletions
+6 -4
View File
@@ -16,6 +16,8 @@
using namespace Seele;
extern bool useViewCulling;
BasePass::BasePass(Gfx::PGraphics graphics, PScene scene)
: RenderPass(graphics, scene)
{
@@ -40,11 +42,11 @@ BasePass::BasePass(Gfx::PGraphics graphics, PScene scene)
if (graphics->supportMeshShading())
{
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "MeshletPass", false, true, true, "BasePass", true, true, "ViewCullingTask");
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "MeshletPass", true, true, "BasePass", true, true, "ViewCullingTask");
}
else
{
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "LegacyPass", false, true, true, "BasePass");
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "LegacyPass", true, true, "BasePass");
}
}
@@ -97,6 +99,7 @@ void BasePass::render()
permutation.setVertexFile("LegacyPass");
}
permutation.setFragmentFile("BasePass");
permutation.setViewCulling(useViewCulling);
for (VertexData* vertexData : VertexData::getList())
{
permutation.setVertexData(vertexData->getTypeName());
@@ -168,7 +171,6 @@ void BasePass::render()
command->bindDescriptor(scene->getLightEnvironment()->getDescriptorSet());
command->bindDescriptor(opaqueCulling);
command->bindDescriptor(vertexData->getInstanceDataSet());
command->bindDescriptor(vertexData->getInstanceDataSet());
for (const auto& drawCall : materialData.instances)
{
command->bindDescriptor(drawCall.materialInstance->getDescriptorSet());
@@ -222,7 +224,7 @@ void BasePass::publishOutputs()
void BasePass::createRenderPass()
{
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
depthAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR);
depthAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
depthAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL);
depthAttachment.setFinalLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
@@ -15,10 +15,10 @@ target_sources(Engine
RenderPass.cpp
SkyboxRenderPass.h
SkyboxRenderPass.cpp
StaticDepthPrepass.h
StaticDepthPrepass.cpp
StaticBasePass.h
StaticBasePass.cpp
#StaticDepthPrepass.h
#StaticDepthPrepass.cpp
#StaticBasePass.h
#StaticBasePass.cpp
TextPass.h
TextPass.cpp
UIPass.h
@@ -35,7 +35,7 @@ target_sources(Engine
RenderGraphResources.h
RenderPass.h
SkyboxRenderPass.h
StaticDepthPrepass.h
StaticBasePass.h
#StaticDepthPrepass.h
#StaticBasePass.h
TextPass.h
UIPass.h)
@@ -13,6 +13,9 @@
using namespace Seele;
extern bool usePositionOnly;
extern bool useViewCulling;
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, PScene scene)
: RenderPass(graphics, scene)
{
@@ -25,11 +28,11 @@ DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, PScene scene)
});
if (graphics->supportMeshShading())
{
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "MeshletPass", true, false, false, "", true, true, "ViewCullingTask");
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "MeshletPass", false, false, "", true, true, "ViewCullingTask");
}
else
{
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "LegacyPass", true);
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "LegacyPass");
}
}
@@ -48,7 +51,8 @@ void DepthPrepass::render()
Array<Gfx::ORenderCommand> commands;
Gfx::ShaderPermutation permutation;
permutation.setPositionOnly();
permutation.setPositionOnly(usePositionOnly);
permutation.setViewCulling(useViewCulling);
if (graphics->supportMeshShading())
{
permutation.setTaskFile("ViewCullingTask");
@@ -22,11 +22,11 @@ StaticBasePass::StaticBasePass(Gfx::PGraphics graphics, PScene scene)
basePassLayout->addDescriptorLayout(lightCullingLayout);
if (graphics->supportMeshShading())
{
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "StaticMeshletPass", false, true, true, "BasePass", true);
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "StaticMeshletPass", false, true, "BasePass", true);
}
else
{
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "StaticBasePass", "StaticLegacyPass", false, true, true, "BasePass");
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "StaticBasePass", "StaticLegacyPass", false, true, "BasePass");
}
}
@@ -16,11 +16,11 @@ StaticDepthPrepass::StaticDepthPrepass(Gfx::PGraphics graphics, PScene scene)
depthPrepassLayout->addDescriptorLayout(meshletCullingLayout);
if (graphics->supportMeshShading())
{
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "MeshletPass", true, false, false, "", true);
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "MeshletPass", false, false, "", true);
}
else
{
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "LegacyPass", true);
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "LegacyPass");
}
}