Adding benchmark
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "BasePass.h"
|
||||
#include "Actor/CameraActor.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Component/Camera.h"
|
||||
#include "Component/Mesh.h"
|
||||
#include "Graphics/Command.h"
|
||||
@@ -7,6 +8,7 @@
|
||||
#include "Graphics/Enums.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/Initializer.h"
|
||||
#include "Graphics/Pipeline.h"
|
||||
#include "Graphics/Shader.h"
|
||||
#include "Graphics/StaticMeshVertexData.h"
|
||||
#include "Material/MaterialInstance.h"
|
||||
@@ -16,6 +18,12 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Array<DebugVertex> gDebugVertices;
|
||||
|
||||
void Seele::addDebugVertex(DebugVertex vert) { gDebugVertices.add(vert); }
|
||||
|
||||
void Seele::addDebugVertices(Array<DebugVertex> verts) { gDebugVertices.addAll(verts); }
|
||||
|
||||
BasePass::BasePass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics, scene) {
|
||||
basePassLayout = graphics->createPipelineLayout("BasePassLayout");
|
||||
|
||||
@@ -68,6 +76,12 @@ BasePass::BasePass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics,
|
||||
.useVisibility = false,
|
||||
});
|
||||
}
|
||||
skybox = Seele::Component::Skybox{
|
||||
.day = AssetRegistry::findTexture("", "skyboxsun5deg_tn")->getTexture().cast<Gfx::TextureCube>(),
|
||||
.night = AssetRegistry::findTexture("", "skyboxsun5deg_tn")->getTexture().cast<Gfx::TextureCube>(),
|
||||
.fogColor = Vector(0.1, 0.1, 0.8),
|
||||
.blendFactor = 0,
|
||||
};
|
||||
}
|
||||
|
||||
BasePass::~BasePass() {}
|
||||
@@ -81,6 +95,41 @@ void BasePass::beginFrame(const Component::Camera& cam) {
|
||||
lightCullingLayout->reset();
|
||||
opaqueCulling = lightCullingLayout->allocateDescriptorSet();
|
||||
transparentCulling = lightCullingLayout->allocateDescriptorSet();
|
||||
|
||||
// Debug vertices
|
||||
VertexBufferCreateInfo vertexBufferInfo = {
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(DebugVertex) * gDebugVertices.size(),
|
||||
.data = (uint8*)gDebugVertices.data(),
|
||||
},
|
||||
.vertexSize = sizeof(DebugVertex),
|
||||
.numVertices = (uint32)gDebugVertices.size(),
|
||||
.name = "DebugVertices",
|
||||
};
|
||||
debugVertices = graphics->createVertexBuffer(vertexBufferInfo);
|
||||
debugVertices->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, Gfx::SE_PIPELINE_STAGE_VERTEX_INPUT_BIT);
|
||||
|
||||
// Skybox
|
||||
skyboxDataLayout->reset();
|
||||
textureLayout->reset();
|
||||
skyboxData.transformMatrix = glm::rotate(skyboxData.transformMatrix, (float)(Gfx::getCurrentFrameDelta()), Vector(0, 1, 0));
|
||||
skyboxBuffer->rotateBuffer(sizeof(SkyboxData));
|
||||
skyboxBuffer->updateContents(DataSource{
|
||||
.size = sizeof(SkyboxData),
|
||||
.data = (uint8*)&skyboxData,
|
||||
});
|
||||
skyboxDataSet = skyboxDataLayout->allocateDescriptorSet();
|
||||
skyboxDataSet->updateBuffer(0, skyboxBuffer);
|
||||
skyboxDataSet->writeChanges();
|
||||
skyboxBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_UNIFORM_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
textureSet = textureLayout->allocateDescriptorSet();
|
||||
textureSet->updateTexture(0, skybox.day);
|
||||
textureSet->updateTexture(1, skybox.night);
|
||||
textureSet->updateSampler(2, skyboxSampler);
|
||||
textureSet->writeChanges();
|
||||
}
|
||||
|
||||
void BasePass::render() {
|
||||
@@ -95,7 +144,6 @@ void BasePass::render() {
|
||||
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "BASEPASS");
|
||||
graphics->beginRenderPass(renderPass);
|
||||
Array<Gfx::ORenderCommand> commands;
|
||||
|
||||
Gfx::ShaderPermutation permutation = graphics->getShaderCompiler()->getTemplate("BasePass");
|
||||
permutation.setDepthCulling(true); // always use the culling info
|
||||
permutation.setPositionOnly(false);
|
||||
@@ -193,110 +241,137 @@ void BasePass::render() {
|
||||
commands.add(std::move(command));
|
||||
}
|
||||
}
|
||||
|
||||
graphics->executeCommands(std::move(commands));
|
||||
|
||||
Map<float, VertexData::TransparentDraw> sortedDraws;
|
||||
for (const auto& t : transparentData) {
|
||||
Vector toCenter = Vector(t.worldPosition) - cameraPos;
|
||||
float dist = glm::length(toCenter) * glm::dot(glm::normalize(toCenter), cameraForward);
|
||||
sortedDraws[dist] = t;
|
||||
commands.clear();
|
||||
// Transparent rendering
|
||||
{
|
||||
Map<float, VertexData::TransparentDraw> sortedDraws;
|
||||
for (const auto& t : transparentData) {
|
||||
Vector toCenter = Vector(t.worldPosition) - cameraPos;
|
||||
float dist = glm::length(toCenter) * glm::dot(glm::normalize(toCenter), cameraForward);
|
||||
sortedDraws[dist] = t;
|
||||
}
|
||||
Gfx::ORenderCommand transparentCommand = graphics->createRenderCommand("TransparentDraw");
|
||||
transparentCommand->setViewport(viewport);
|
||||
for (const auto& [_, t] : sortedDraws) {
|
||||
permutation.setVertexData(t.vertexData->getTypeName());
|
||||
permutation.setMaterial(t.matInst->getBaseMaterial()->getName());
|
||||
Gfx::PermutationId id(permutation);
|
||||
|
||||
const Gfx::ShaderCollection* collection = graphics->getShaderCompiler()->findShaders(id);
|
||||
assert(collection != nullptr);
|
||||
|
||||
bool twoSided = t.matInst->getBaseMaterial()->isTwoSided();
|
||||
|
||||
if (graphics->supportMeshShading()) {
|
||||
Gfx::MeshPipelineCreateInfo pipelineInfo = {
|
||||
.taskShader = collection->taskShader,
|
||||
.meshShader = collection->meshShader,
|
||||
.fragmentShader = collection->fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = collection->pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.rasterizationState =
|
||||
{
|
||||
.cullMode = Gfx::SeCullModeFlags(twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT),
|
||||
},
|
||||
.depthStencilState =
|
||||
{
|
||||
.depthCompareOp = Gfx::SE_COMPARE_OP_GREATER_OR_EQUAL,
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
.blendAttachments =
|
||||
{
|
||||
Gfx::ColorBlendState::BlendAttachment{
|
||||
.blendEnable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
|
||||
transparentCommand->bindPipeline(pipeline);
|
||||
} else {
|
||||
Gfx::LegacyPipelineCreateInfo pipelineInfo = {
|
||||
.vertexShader = collection->vertexShader,
|
||||
.fragmentShader = collection->fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = collection->pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.rasterizationState =
|
||||
{
|
||||
.cullMode = Gfx::SeCullModeFlags(twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT),
|
||||
},
|
||||
.depthStencilState =
|
||||
{
|
||||
.depthCompareOp = Gfx::SE_COMPARE_OP_GREATER_OR_EQUAL,
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
.blendAttachments =
|
||||
{
|
||||
Gfx::ColorBlendState::BlendAttachment{
|
||||
.blendEnable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
|
||||
transparentCommand->bindPipeline(pipeline);
|
||||
}
|
||||
transparentCommand->bindDescriptor({viewParamsSet, t.vertexData->getVertexDataSet(), t.vertexData->getInstanceDataSet(),
|
||||
scene->getLightEnvironment()->getDescriptorSet(), Material::getDescriptorSet(),
|
||||
transparentCulling});
|
||||
transparentCommand->pushConstants(Gfx::SE_SHADER_STAGE_TASK_BIT_EXT | Gfx::SE_SHADER_STAGE_VERTEX_BIT |
|
||||
Gfx::SE_SHADER_STAGE_FRAGMENT_BIT,
|
||||
0, sizeof(VertexData::DrawCallOffsets), &t.offsets);
|
||||
if (graphics->supportMeshShading()) {
|
||||
transparentCommand->drawMesh(1, 1, 1);
|
||||
} else {
|
||||
// command->bindIndexBuffer(t.vertexData->getIndexBuffer());
|
||||
// for (const auto& meshData : drawCall.instanceMeshData) {
|
||||
// // all meshlets of a mesh share the same indices offset
|
||||
// command->drawIndexed(meshData.numIndices, 1, meshData.firstIndex,
|
||||
// vertexData->getIndicesOffset(meshData.meshletOffset), 0);
|
||||
// }
|
||||
}
|
||||
}
|
||||
commands.add(std::move(transparentCommand));
|
||||
}
|
||||
Gfx::ORenderCommand command = graphics->createRenderCommand("TransparentDraw");
|
||||
command->setViewport(viewport);
|
||||
for (const auto& [_, t] : sortedDraws) {
|
||||
permutation.setVertexData(t.vertexData->getTypeName());
|
||||
permutation.setMaterial(t.matInst->getBaseMaterial()->getName());
|
||||
Gfx::PermutationId id(permutation);
|
||||
|
||||
const Gfx::ShaderCollection* collection = graphics->getShaderCompiler()->findShaders(id);
|
||||
assert(collection != nullptr);
|
||||
|
||||
bool twoSided = t.matInst->getBaseMaterial()->isTwoSided();
|
||||
|
||||
if (graphics->supportMeshShading()) {
|
||||
Gfx::MeshPipelineCreateInfo pipelineInfo = {
|
||||
.taskShader = collection->taskShader,
|
||||
.meshShader = collection->meshShader,
|
||||
.fragmentShader = collection->fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = collection->pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.rasterizationState =
|
||||
{
|
||||
.cullMode = Gfx::SeCullModeFlags(twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT),
|
||||
},
|
||||
.depthStencilState =
|
||||
{
|
||||
.depthCompareOp = Gfx::SE_COMPARE_OP_GREATER_OR_EQUAL,
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
.blendAttachments =
|
||||
{
|
||||
Gfx::ColorBlendState::BlendAttachment{
|
||||
.blendEnable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
|
||||
command->bindPipeline(pipeline);
|
||||
} else {
|
||||
Gfx::LegacyPipelineCreateInfo pipelineInfo = {
|
||||
.vertexShader = collection->vertexShader,
|
||||
.fragmentShader = collection->fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = collection->pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.rasterizationState =
|
||||
{
|
||||
.cullMode = Gfx::SeCullModeFlags(twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT),
|
||||
},
|
||||
.depthStencilState =
|
||||
{
|
||||
.depthCompareOp = Gfx::SE_COMPARE_OP_GREATER_OR_EQUAL,
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
.blendAttachments =
|
||||
{
|
||||
Gfx::ColorBlendState::BlendAttachment{
|
||||
.blendEnable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
|
||||
command->bindPipeline(pipeline);
|
||||
}
|
||||
command->bindDescriptor({viewParamsSet, t.vertexData->getVertexDataSet(), t.vertexData->getInstanceDataSet(),
|
||||
scene->getLightEnvironment()->getDescriptorSet(), Material::getDescriptorSet(), transparentCulling});
|
||||
command->pushConstants(Gfx::SE_SHADER_STAGE_TASK_BIT_EXT | Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, 0,
|
||||
sizeof(VertexData::DrawCallOffsets), &t.offsets);
|
||||
if (graphics->supportMeshShading()) {
|
||||
command->drawMesh(1, 1, 1);
|
||||
} else {
|
||||
// command->bindIndexBuffer(t.vertexData->getIndexBuffer());
|
||||
// for (const auto& meshData : drawCall.instanceMeshData) {
|
||||
// // all meshlets of a mesh share the same indices offset
|
||||
// command->drawIndexed(meshData.numIndices, 1, meshData.firstIndex, vertexData->getIndicesOffset(meshData.meshletOffset),
|
||||
// 0);
|
||||
// }
|
||||
}
|
||||
// Debug vertices
|
||||
if (gDebugVertices.size() > 0) {
|
||||
Gfx::ORenderCommand debugCommand = graphics->createRenderCommand("DebugRender");
|
||||
debugCommand->setViewport(viewport);
|
||||
debugCommand->bindPipeline(debugPipeline);
|
||||
debugCommand->bindDescriptor(viewParamsSet);
|
||||
debugCommand->bindVertexBuffer({debugVertices});
|
||||
debugCommand->draw((uint32)gDebugVertices.size(), 1, 0, 0);
|
||||
commands.add(std::move(debugCommand));
|
||||
}
|
||||
|
||||
Gfx::ORenderCommand skyboxCommand = graphics->createRenderCommand("SkyboxRender");
|
||||
skyboxCommand->setViewport(viewport);
|
||||
skyboxCommand->bindPipeline(pipeline);
|
||||
skyboxCommand->bindDescriptor({viewParamsSet, skyboxDataSet, textureSet});
|
||||
skyboxCommand->draw(36, 1, 0, 0);
|
||||
|
||||
commands.add(std::move(skyboxCommand));
|
||||
graphics->executeCommands(std::move(commands));
|
||||
graphics->endRenderPass();
|
||||
query->endQuery();
|
||||
timestamps->write(Gfx::SE_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, "END");
|
||||
timestamps->end();
|
||||
gDebugVertices.clear();
|
||||
}
|
||||
|
||||
void BasePass::endFrame() {}
|
||||
@@ -306,17 +381,44 @@ void BasePass::publishOutputs() {
|
||||
.format = Gfx::SE_FORMAT_D32_SFLOAT,
|
||||
.width = viewport->getOwner()->getFramebufferWidth(),
|
||||
.height = viewport->getOwner()->getFramebufferHeight(),
|
||||
.samples = viewport->getSamples(),
|
||||
.usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||
};
|
||||
basePassDepth = graphics->createTexture2D(depthBufferInfo);
|
||||
|
||||
colorAttachment = Gfx::RenderTargetAttachment(viewport, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
resources->registerRenderPassOutput("BASEPASS_COLOR", colorAttachment);
|
||||
TextureCreateInfo msDepthInfo = {
|
||||
.format = Gfx::SE_FORMAT_D32_SFLOAT,
|
||||
.width = viewport->getOwner()->getFramebufferWidth(),
|
||||
.height = viewport->getOwner()->getFramebufferHeight(),
|
||||
.samples = viewport->getSamples(),
|
||||
.usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | Gfx::SE_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
|
||||
};
|
||||
msBasePassDepth = graphics->createTexture2D(msDepthInfo);
|
||||
|
||||
TextureCreateInfo msBaseColorInfo = {
|
||||
.format = viewport->getOwner()->getSwapchainFormat(),
|
||||
.width = viewport->getOwner()->getFramebufferWidth(),
|
||||
.height = viewport->getOwner()->getFramebufferHeight(),
|
||||
.samples = viewport->getSamples(),
|
||||
.usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | Gfx::SE_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
|
||||
};
|
||||
msBasePassColor = graphics->createTexture2D(msBaseColorInfo);
|
||||
|
||||
depthAttachment =
|
||||
Gfx::RenderTargetAttachment(basePassDepth, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
|
||||
msDepthAttachment =
|
||||
Gfx::RenderTargetAttachment(msBasePassDepth, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
||||
|
||||
colorAttachment = Gfx::RenderTargetAttachment(viewport, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||
|
||||
msColorAttachment =
|
||||
Gfx::RenderTargetAttachment(msBasePassColor, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
||||
|
||||
resources->registerRenderPassOutput("BASEPASS_COLOR", colorAttachment);
|
||||
resources->registerRenderPassOutput("BASEPASS_DEPTH", depthAttachment);
|
||||
|
||||
query = graphics->createPipelineStatisticsQuery("BasePassPipelineStatistics");
|
||||
@@ -328,15 +430,19 @@ void BasePass::createRenderPass() {
|
||||
cullingBuffer = resources->requestBuffer("CULLINGBUFFER");
|
||||
|
||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
||||
.colorAttachments = {colorAttachment},
|
||||
.depthAttachment = depthAttachment,
|
||||
.colorAttachments = {msColorAttachment},
|
||||
.resolveAttachments = {colorAttachment},
|
||||
.depthAttachment = msDepthAttachment,
|
||||
.depthResolveAttachment = {depthAttachment},
|
||||
};
|
||||
Array<Gfx::SubPassDependency> dependency = {
|
||||
{
|
||||
.srcSubpass = ~0U,
|
||||
.dstSubpass = 0,
|
||||
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.dstStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
|
||||
Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.dstStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
|
||||
Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
@@ -345,8 +451,10 @@ void BasePass::createRenderPass() {
|
||||
{
|
||||
.srcSubpass = 0,
|
||||
.dstSubpass = ~0U,
|
||||
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.dstStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
|
||||
Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.dstStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
|
||||
Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
@@ -358,4 +466,151 @@ void BasePass::createRenderPass() {
|
||||
tLightIndexList = resources->requestBuffer("LIGHTCULLING_TLIGHTLIST");
|
||||
oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
||||
tLightGrid = resources->requestTexture("LIGHTCULLING_TLIGHTGRID");
|
||||
|
||||
// Debug rendering
|
||||
{
|
||||
debugPipelineLayout = graphics->createPipelineLayout("DebugPassLayout");
|
||||
debugPipelineLayout->addDescriptorLayout(viewParamsLayout);
|
||||
|
||||
ShaderCreateInfo createInfo = {
|
||||
.name = "DebugVertex",
|
||||
.mainModule = "Debug",
|
||||
.entryPoint = "vertexMain",
|
||||
.rootSignature = debugPipelineLayout,
|
||||
};
|
||||
debugVertexShader = graphics->createVertexShader(createInfo);
|
||||
|
||||
createInfo.name = "DebugFragment";
|
||||
createInfo.entryPoint = "fragmentMain";
|
||||
debugFragmentShader = graphics->createFragmentShader(createInfo);
|
||||
debugPipelineLayout->create();
|
||||
|
||||
VertexInputStateCreateInfo inputCreate = {
|
||||
.bindings =
|
||||
{
|
||||
VertexInputBinding{
|
||||
.binding = 0,
|
||||
.stride = sizeof(DebugVertex),
|
||||
.inputRate = Gfx::SE_VERTEX_INPUT_RATE_VERTEX,
|
||||
},
|
||||
},
|
||||
.attributes =
|
||||
{
|
||||
VertexInputAttribute{
|
||||
.location = 0,
|
||||
.binding = 0,
|
||||
.format = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
|
||||
.offset = 0,
|
||||
},
|
||||
VertexInputAttribute{
|
||||
.location = 1,
|
||||
.binding = 0,
|
||||
.format = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
|
||||
.offset = sizeof(Vector),
|
||||
},
|
||||
},
|
||||
};
|
||||
debugVertexInput = graphics->createVertexInput(inputCreate);
|
||||
Gfx::LegacyPipelineCreateInfo gfxInfo = {
|
||||
.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST,
|
||||
.vertexInput = debugVertexInput,
|
||||
.vertexShader = debugVertexShader,
|
||||
.fragmentShader = debugFragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = debugPipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.rasterizationState =
|
||||
{
|
||||
.polygonMode = Gfx::SE_POLYGON_MODE_LINE,
|
||||
.lineWidth = 5.f,
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
},
|
||||
};
|
||||
debugPipeline = graphics->createGraphicsPipeline(std::move(gfxInfo));
|
||||
}
|
||||
|
||||
// Skybox
|
||||
{
|
||||
skyboxDataLayout = graphics->createDescriptorLayout("pSkyboxData");
|
||||
skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 0,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
});
|
||||
skyboxDataLayout->create();
|
||||
textureLayout = graphics->createDescriptorLayout("pSkyboxTextures");
|
||||
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 0,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
});
|
||||
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 1,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
});
|
||||
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 2,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
|
||||
});
|
||||
textureLayout->create();
|
||||
|
||||
skyboxSampler = graphics->createSampler({});
|
||||
|
||||
skyboxData.transformMatrix = Matrix4(1);
|
||||
skyboxData.fogColor = skybox.fogColor;
|
||||
skyboxData.blendFactor = skybox.blendFactor;
|
||||
|
||||
skyboxBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(SkyboxData),
|
||||
.data = (uint8*)&skyboxData,
|
||||
},
|
||||
.dynamic = true,
|
||||
});
|
||||
|
||||
pipelineLayout = graphics->createPipelineLayout("SkyboxLayout");
|
||||
pipelineLayout->addDescriptorLayout(viewParamsLayout);
|
||||
pipelineLayout->addDescriptorLayout(skyboxDataLayout);
|
||||
pipelineLayout->addDescriptorLayout(textureLayout);
|
||||
|
||||
ShaderCreateInfo createInfo = {
|
||||
.name = "SkyboxVertex",
|
||||
.mainModule = "Skybox",
|
||||
.entryPoint = "vertexMain",
|
||||
.rootSignature = pipelineLayout,
|
||||
};
|
||||
vertexShader = graphics->createVertexShader(createInfo);
|
||||
|
||||
createInfo.name = "SkyboxFragment";
|
||||
createInfo.entryPoint = "fragmentMain";
|
||||
fragmentShader = graphics->createFragmentShader(createInfo);
|
||||
|
||||
pipelineLayout->create();
|
||||
|
||||
Gfx::LegacyPipelineCreateInfo gfxInfo = {
|
||||
.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
|
||||
.vertexShader = vertexShader,
|
||||
.fragmentShader = fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.rasterizationState =
|
||||
{
|
||||
.polygonMode = Gfx::SE_POLYGON_MODE_FILL,
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
},
|
||||
};
|
||||
pipeline = graphics->createGraphicsPipeline(std::move(gfxInfo));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ class BasePass : public RenderPass {
|
||||
virtual void createRenderPass() override;
|
||||
|
||||
private:
|
||||
Gfx::RenderTargetAttachment msColorAttachment;
|
||||
Gfx::RenderTargetAttachment colorAttachment;
|
||||
Gfx::RenderTargetAttachment msDepthAttachment;
|
||||
Gfx::RenderTargetAttachment depthAttachment;
|
||||
Gfx::RenderTargetAttachment visibilityAttachment;
|
||||
Gfx::PShaderBuffer oLightIndexList;
|
||||
@@ -29,7 +31,9 @@ class BasePass : public RenderPass {
|
||||
Gfx::PDescriptorSet transparentCulling;
|
||||
|
||||
// use a different texture here so we can do multisampling
|
||||
Gfx::OTexture2D msBasePassDepth;
|
||||
Gfx::OTexture2D basePassDepth;
|
||||
Gfx::OTexture2D msBasePassColor;
|
||||
|
||||
// used for transparency sorting
|
||||
Vector cameraPos;
|
||||
@@ -43,6 +47,32 @@ class BasePass : public RenderPass {
|
||||
Gfx::PTimestampQuery timestamps;
|
||||
|
||||
Gfx::PShaderBuffer cullingBuffer;
|
||||
|
||||
// Debug rendering
|
||||
Gfx::OVertexInput debugVertexInput;
|
||||
Gfx::OVertexBuffer debugVertices;
|
||||
Gfx::OVertexShader debugVertexShader;
|
||||
Gfx::OFragmentShader debugFragmentShader;
|
||||
Gfx::PGraphicsPipeline debugPipeline;
|
||||
Gfx::OPipelineLayout debugPipelineLayout;
|
||||
|
||||
// Skybox
|
||||
Gfx::ODescriptorLayout skyboxDataLayout;
|
||||
Gfx::PDescriptorSet skyboxDataSet;
|
||||
Gfx::ODescriptorLayout textureLayout;
|
||||
Gfx::PDescriptorSet textureSet;
|
||||
Gfx::OVertexShader vertexShader;
|
||||
Gfx::OFragmentShader fragmentShader;
|
||||
Gfx::OPipelineLayout pipelineLayout;
|
||||
Gfx::PGraphicsPipeline pipeline;
|
||||
Gfx::OSampler skyboxSampler;
|
||||
struct SkyboxData {
|
||||
Matrix4 transformMatrix;
|
||||
Vector fogColor;
|
||||
float blendFactor;
|
||||
} skyboxData;
|
||||
Gfx::OUniformBuffer skyboxBuffer;
|
||||
Component::Skybox skybox;
|
||||
};
|
||||
DEFINE_REF(BasePass)
|
||||
} // namespace Seele
|
||||
|
||||
@@ -4,8 +4,6 @@ target_sources(Engine
|
||||
BasePass.cpp
|
||||
CachedDepthPass.h
|
||||
CachedDepthPass.cpp
|
||||
DebugPass.h
|
||||
DebugPass.cpp
|
||||
DepthCullingPass.h
|
||||
DepthCullingPass.cpp
|
||||
LightCullingPass.h
|
||||
@@ -17,8 +15,6 @@ target_sources(Engine
|
||||
RenderGraphResources.cpp
|
||||
RenderPass.h
|
||||
RenderPass.cpp
|
||||
SkyboxRenderPass.h
|
||||
SkyboxRenderPass.cpp
|
||||
TextPass.h
|
||||
TextPass.cpp
|
||||
UIPass.h
|
||||
@@ -31,14 +27,12 @@ target_sources(Engine
|
||||
FILES
|
||||
BasePass.h
|
||||
CachedDepthPass.h
|
||||
DebugPass.h
|
||||
DepthCullingPass.h
|
||||
LightCullingPass.h
|
||||
RayTracingPass.h
|
||||
RenderGraph.h
|
||||
RenderGraphResources.h
|
||||
RenderPass.h
|
||||
SkyboxRenderPass.h
|
||||
TextPass.h
|
||||
UIPass.h
|
||||
VisibilityPass.h)
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
extern bool usePositionOnly;
|
||||
extern bool useDepthCulling;
|
||||
|
||||
CachedDepthPass::CachedDepthPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics, scene) {
|
||||
depthPrepassLayout = graphics->createPipelineLayout("CachedDepthLayout");
|
||||
depthPrepassLayout->addDescriptorLayout(viewParamsLayout);
|
||||
@@ -43,7 +40,9 @@ CachedDepthPass::CachedDepthPass(Gfx::PGraphics graphics, PScene scene) : Render
|
||||
|
||||
CachedDepthPass::~CachedDepthPass() {}
|
||||
|
||||
void CachedDepthPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); }
|
||||
void CachedDepthPass::beginFrame(const Component::Camera& cam) {
|
||||
RenderPass::beginFrame(cam);
|
||||
}
|
||||
|
||||
void CachedDepthPass::render() {
|
||||
query->beginQuery();
|
||||
@@ -53,8 +52,8 @@ void CachedDepthPass::render() {
|
||||
Array<Gfx::ORenderCommand> commands;
|
||||
|
||||
Gfx::ShaderPermutation permutation = graphics->getShaderCompiler()->getTemplate("CachedDepthPass");
|
||||
permutation.setPositionOnly(usePositionOnly);
|
||||
permutation.setDepthCulling(useDepthCulling);
|
||||
permutation.setPositionOnly(getGlobals().usePositionOnly);
|
||||
permutation.setDepthCulling(getGlobals().useDepthCulling);
|
||||
for (VertexData* vertexData : VertexData::getList()) {
|
||||
permutation.setVertexData(vertexData->getTypeName());
|
||||
vertexData->getInstanceDataSet()->updateBuffer(6, cullingBuffer);
|
||||
@@ -79,10 +78,6 @@ void CachedDepthPass::render() {
|
||||
.fragmentShader = collection->fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = collection->pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
@@ -96,10 +91,6 @@ void CachedDepthPass::render() {
|
||||
.fragmentShader = collection->fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = collection->pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
#include "DebugPass.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Graphics/Pipeline.h"
|
||||
#include "Graphics/RenderTarget.h"
|
||||
#include "Graphics/Shader.h"
|
||||
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Array<DebugVertex> gDebugVertices;
|
||||
|
||||
void Seele::addDebugVertex(DebugVertex vert) { gDebugVertices.add(vert); }
|
||||
|
||||
void Seele::addDebugVertices(Array<DebugVertex> verts) { gDebugVertices.addAll(verts); }
|
||||
|
||||
DebugPass::DebugPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics, scene) {}
|
||||
|
||||
DebugPass::~DebugPass() {}
|
||||
|
||||
void DebugPass::beginFrame(const Component::Camera& cam) {
|
||||
RenderPass::beginFrame(cam);
|
||||
|
||||
VertexBufferCreateInfo vertexBufferInfo = {
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(DebugVertex) * gDebugVertices.size(),
|
||||
.data = (uint8*)gDebugVertices.data(),
|
||||
},
|
||||
.vertexSize = sizeof(DebugVertex),
|
||||
.numVertices = (uint32)gDebugVertices.size(),
|
||||
.name = "DebugVertices",
|
||||
};
|
||||
debugVertices = graphics->createVertexBuffer(vertexBufferInfo);
|
||||
}
|
||||
|
||||
void DebugPass::render() {
|
||||
graphics->beginRenderPass(renderPass);
|
||||
if (gDebugVertices.size() > 0) {
|
||||
Gfx::ORenderCommand renderCommand = graphics->createRenderCommand("DebugRender");
|
||||
renderCommand->setViewport(viewport);
|
||||
renderCommand->bindPipeline(pipeline);
|
||||
renderCommand->bindDescriptor(viewParamsSet);
|
||||
renderCommand->bindVertexBuffer({debugVertices});
|
||||
renderCommand->draw((uint32)gDebugVertices.size(), 1, 0, 0);
|
||||
Array<Gfx::ORenderCommand> commands;
|
||||
commands.add(std::move(renderCommand));
|
||||
graphics->executeCommands({std::move(commands)});
|
||||
}
|
||||
graphics->endRenderPass();
|
||||
gDebugVertices.clear();
|
||||
// Sync color write with next pass/swapchain present
|
||||
// colorAttachment.getTexture()->pipelineBarrier(
|
||||
// Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||
// Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
// Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||
// Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
|
||||
//);
|
||||
// Sync depth with next pass/next frame
|
||||
// depthAttachment.getTexture()->pipelineBarrier(
|
||||
// Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
// Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
// Gfx::SE_ACCESS_MEMORY_WRITE_BIT,
|
||||
// Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT
|
||||
//);
|
||||
}
|
||||
|
||||
void DebugPass::endFrame() {}
|
||||
|
||||
void DebugPass::publishOutputs() {}
|
||||
|
||||
void DebugPass::createRenderPass() {
|
||||
colorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
|
||||
colorAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
colorAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
colorAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
|
||||
depthAttachment = resources->requestRenderTarget("BASEPASS_DEPTH");
|
||||
depthAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
depthAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
depthAttachment.setFinalLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
||||
.colorAttachments = {colorAttachment},
|
||||
.depthAttachment = depthAttachment,
|
||||
};
|
||||
|
||||
Array<Gfx::SubPassDependency> dependency = {
|
||||
{
|
||||
.srcSubpass = ~0U,
|
||||
.dstSubpass = 0,
|
||||
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.dstStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
},
|
||||
{
|
||||
.srcSubpass = 0,
|
||||
.dstSubpass = ~0U,
|
||||
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.dstStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
},
|
||||
};
|
||||
renderPass = graphics->createRenderPass(std::move(layout), dependency, viewport);
|
||||
|
||||
pipelineLayout = graphics->createPipelineLayout("DebugPassLayout");
|
||||
pipelineLayout->addDescriptorLayout(viewParamsLayout);
|
||||
|
||||
ShaderCreateInfo createInfo = {
|
||||
.name = "DebugVertex",
|
||||
.mainModule = "Debug",
|
||||
.entryPoint = "vertexMain",
|
||||
.rootSignature = pipelineLayout,
|
||||
};
|
||||
vertexShader = graphics->createVertexShader(createInfo);
|
||||
|
||||
createInfo.name = "DebugFragment";
|
||||
createInfo.entryPoint = "fragmentMain";
|
||||
fragmentShader = graphics->createFragmentShader(createInfo);
|
||||
pipelineLayout->create();
|
||||
|
||||
VertexInputStateCreateInfo inputCreate = {
|
||||
.bindings =
|
||||
{
|
||||
VertexInputBinding{
|
||||
.binding = 0,
|
||||
.stride = sizeof(DebugVertex),
|
||||
.inputRate = Gfx::SE_VERTEX_INPUT_RATE_VERTEX,
|
||||
},
|
||||
},
|
||||
.attributes = {VertexInputAttribute{
|
||||
.location = 0,
|
||||
.binding = 0,
|
||||
.format = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
|
||||
.offset = 0,
|
||||
},
|
||||
VertexInputAttribute{
|
||||
.location = 1, .binding = 0, .format = Gfx::SE_FORMAT_R32G32B32_SFLOAT, .offset = sizeof(Vector)}},
|
||||
};
|
||||
vertexInput = graphics->createVertexInput(inputCreate);
|
||||
Gfx::LegacyPipelineCreateInfo gfxInfo;
|
||||
gfxInfo.vertexInput = vertexInput;
|
||||
gfxInfo.vertexShader = vertexShader;
|
||||
gfxInfo.fragmentShader = fragmentShader;
|
||||
gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE;
|
||||
gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST;
|
||||
gfxInfo.pipelineLayout = std::move(pipelineLayout);
|
||||
gfxInfo.renderPass = renderPass;
|
||||
gfxInfo.colorBlend.attachmentCount = 1;
|
||||
gfxInfo.rasterizationState.lineWidth = 5.f;
|
||||
pipeline = graphics->createGraphicsPipeline(std::move(gfxInfo));
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
#include "Graphics/DebugVertex.h"
|
||||
#include "Graphics/Pipeline.h"
|
||||
#include "RenderPass.h"
|
||||
#include "Scene/Scene.h"
|
||||
|
||||
|
||||
namespace Seele {
|
||||
DECLARE_REF(CameraActor)
|
||||
DECLARE_REF(Scene)
|
||||
DECLARE_REF(Viewport)
|
||||
class DebugPass : public RenderPass {
|
||||
public:
|
||||
DebugPass(Gfx::PGraphics graphics, PScene scene);
|
||||
DebugPass(DebugPass&&) = default;
|
||||
DebugPass& operator=(DebugPass&&) = default;
|
||||
virtual ~DebugPass();
|
||||
virtual void beginFrame(const Component::Camera& cam) override;
|
||||
virtual void render() override;
|
||||
virtual void endFrame() override;
|
||||
virtual void publishOutputs() override;
|
||||
virtual void createRenderPass() override;
|
||||
|
||||
private:
|
||||
Gfx::RenderTargetAttachment colorAttachment;
|
||||
Gfx::RenderTargetAttachment depthAttachment;
|
||||
Gfx::OVertexInput vertexInput;
|
||||
Gfx::OVertexBuffer debugVertices;
|
||||
Gfx::OVertexShader vertexShader;
|
||||
Gfx::OFragmentShader fragmentShader;
|
||||
Gfx::PGraphicsPipeline pipeline;
|
||||
Gfx::OPipelineLayout pipelineLayout;
|
||||
};
|
||||
DEFINE_REF(DebugPass)
|
||||
} // namespace Seele
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
extern bool usePositionOnly;
|
||||
extern bool useDepthCulling;
|
||||
|
||||
DepthCullingPass::DepthCullingPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics, scene) {
|
||||
depthAttachmentLayout = graphics->createDescriptorLayout("pDepthAttachment");
|
||||
depthAttachmentLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
@@ -68,13 +65,15 @@ DepthCullingPass::DepthCullingPass(Gfx::PGraphics graphics, PScene scene) : Rend
|
||||
|
||||
DepthCullingPass::~DepthCullingPass() {}
|
||||
|
||||
void DepthCullingPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); }
|
||||
void DepthCullingPass::beginFrame(const Component::Camera& cam) {
|
||||
RenderPass::beginFrame(cam);
|
||||
}
|
||||
|
||||
void DepthCullingPass::render() {
|
||||
query->beginQuery();
|
||||
depthAttachment.getTexture()->changeLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL, Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, Gfx::SE_ACCESS_TRANSFER_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
|
||||
Gfx::PDescriptorSet set = depthAttachmentLayout->allocateDescriptorSet();
|
||||
set->updateTexture(0, Gfx::PTexture2D(depthAttachment.getTexture()));
|
||||
@@ -123,8 +122,8 @@ void DepthCullingPass::render() {
|
||||
Array<Gfx::ORenderCommand> commands;
|
||||
|
||||
Gfx::ShaderPermutation permutation = graphics->getShaderCompiler()->getTemplate("DepthPass");
|
||||
permutation.setPositionOnly(usePositionOnly);
|
||||
permutation.setDepthCulling(useDepthCulling);
|
||||
permutation.setPositionOnly(getGlobals().usePositionOnly);
|
||||
permutation.setDepthCulling(getGlobals().useDepthCulling);
|
||||
for (VertexData* vertexData : VertexData::getList()) {
|
||||
permutation.setVertexData(vertexData->getTypeName());
|
||||
vertexData->getInstanceDataSet()->updateBuffer(6, cullingBuffer);
|
||||
@@ -148,10 +147,6 @@ void DepthCullingPass::render() {
|
||||
.fragmentShader = collection->fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = collection->pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
@@ -165,10 +160,6 @@ void DepthCullingPass::render() {
|
||||
.fragmentShader = collection->fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = collection->pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
extern bool useLightCulling;
|
||||
|
||||
LightCullingPass::LightCullingPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics, scene) {}
|
||||
|
||||
LightCullingPass::~LightCullingPass() {}
|
||||
@@ -25,7 +23,13 @@ void LightCullingPass::beginFrame(const Component::Camera& cam) {
|
||||
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
uint32 reset = 0;
|
||||
ShaderBufferCreateInfo counterReset = {
|
||||
.sourceData = {.size = sizeof(uint32), .data = (uint8*)&reset, .owner = Gfx::QueueType::COMPUTE}};
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(uint32),
|
||||
.data = (uint8*)&reset,
|
||||
.owner = Gfx::QueueType::COMPUTE,
|
||||
},
|
||||
};
|
||||
oLightIndexCounter->rotateBuffer(sizeof(uint32));
|
||||
oLightIndexCounter->updateContents(counterReset);
|
||||
tLightIndexCounter->rotateBuffer(sizeof(uint32));
|
||||
@@ -42,7 +46,10 @@ void LightCullingPass::beginFrame(const Component::Camera& cam) {
|
||||
void LightCullingPass::render() {
|
||||
query->beginQuery();
|
||||
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "LIGHTCULL");
|
||||
depthAttachment->transferOwnership(Gfx::QueueType::COMPUTE);
|
||||
oLightGrid->pipelineBarrier(Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, Gfx::SE_ACCESS_SHADER_WRITE_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
tLightGrid->pipelineBarrier(Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, Gfx::SE_ACCESS_SHADER_WRITE_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
cullingDescriptorSet->updateTexture(0, depthAttachment);
|
||||
cullingDescriptorSet->updateBuffer(1, oLightIndexCounter);
|
||||
cullingDescriptorSet->updateBuffer(2, tLightIndexCounter);
|
||||
@@ -52,7 +59,7 @@ void LightCullingPass::render() {
|
||||
cullingDescriptorSet->updateTexture(6, Gfx::PTexture2D(tLightGrid));
|
||||
cullingDescriptorSet->writeChanges();
|
||||
Gfx::OComputeCommand computeCommand = graphics->createComputeCommand("CullingCommand");
|
||||
if (useLightCulling) {
|
||||
if (getGlobals().useLightCulling) {
|
||||
computeCommand->bindPipeline(cullingEnabledPipeline);
|
||||
} else {
|
||||
computeCommand->bindPipeline(cullingPipeline);
|
||||
@@ -84,11 +91,17 @@ void LightCullingPass::publishOutputs() {
|
||||
dispatchParams.numThreadGroups = numThreadGroups;
|
||||
dispatchParams.numThreads = numThreadGroups * glm::uvec3(BLOCK_SIZE, BLOCK_SIZE, 1);
|
||||
dispatchParamsBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
.sourceData = {.size = sizeof(DispatchParams), .data = (uint8*)&dispatchParams, .owner = Gfx::QueueType::COMPUTE},
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(DispatchParams),
|
||||
.data = (uint8*)&dispatchParams,
|
||||
.owner = Gfx::QueueType::COMPUTE,
|
||||
},
|
||||
.dynamic = false,
|
||||
.name = "DispatchParams",
|
||||
});
|
||||
|
||||
dispatchParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
|
||||
dispatchParamsSet->updateBuffer(0, dispatchParamsBuffer);
|
||||
dispatchParamsSet->updateBuffer(1, frustumBuffer);
|
||||
@@ -209,6 +222,10 @@ void LightCullingPass::publishOutputs() {
|
||||
};
|
||||
oLightGrid = graphics->createTexture2D(textureInfo);
|
||||
tLightGrid = graphics->createTexture2D(textureInfo);
|
||||
oLightGrid->changeLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL, Gfx::SE_ACCESS_NONE, Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT | Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
tLightGrid->changeLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL, Gfx::SE_ACCESS_NONE, Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT | Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
|
||||
resources->registerTextureOutput("LIGHTCULLING_OLIGHTGRID", Gfx::PTexture2D(oLightGrid));
|
||||
resources->registerTextureOutput("LIGHTCULLING_TLIGHTGRID", Gfx::PTexture2D(tLightGrid));
|
||||
@@ -230,6 +247,8 @@ void LightCullingPass::setupFrustums() {
|
||||
glm::uvec3 numThreadGroups = glm::ceil(glm::vec3(numThreads.x / (float)BLOCK_SIZE, numThreads.y / (float)BLOCK_SIZE, 1));
|
||||
|
||||
RenderPass::beginFrame(Component::Camera());
|
||||
viewParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
dispatchParams.numThreads = numThreads;
|
||||
dispatchParams.numThreadGroups = numThreadGroups;
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ class LightCullingPass : public RenderPass {
|
||||
|
||||
Gfx::OShaderBuffer frustumBuffer;
|
||||
Gfx::OUniformBuffer dispatchParamsBuffer;
|
||||
Gfx::OUniformBuffer viewParamsBuffer;
|
||||
Gfx::ODescriptorLayout dispatchParamsLayout;
|
||||
Gfx::PDescriptorSet dispatchParamsSet;
|
||||
Gfx::OComputeShader frustumShader;
|
||||
|
||||
@@ -40,7 +40,9 @@ void RenderPass::beginFrame(const Component::Camera& cam) {
|
||||
viewParamsBuffer->rotateBuffer(sizeof(ViewParameter));
|
||||
viewParamsBuffer->updateContents(uniformUpdate);
|
||||
viewParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
Gfx::SE_ACCESS_UNIFORM_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_TASK_SHADER_BIT_EXT | Gfx::SE_PIPELINE_STAGE_MESH_SHADER_BIT_EXT |
|
||||
Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
viewParamsLayout->reset();
|
||||
viewParamsSet = viewParamsLayout->allocateDescriptorSet();
|
||||
viewParamsSet->updateBuffer(0, viewParamsBuffer);
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
#include "SkyboxRenderPass.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Graphics/Command.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
SkyboxRenderPass::SkyboxRenderPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics, scene) {
|
||||
skybox = Seele::Component::Skybox{
|
||||
.day = AssetRegistry::findTexture("", "skyboxsun5deg_tn")->getTexture().cast<Gfx::TextureCube>(),
|
||||
.night = AssetRegistry::findTexture("", "skyboxsun5deg_tn")->getTexture().cast<Gfx::TextureCube>(),
|
||||
.fogColor = Vector(0.1, 0.1, 0.8),
|
||||
.blendFactor = 0,
|
||||
};
|
||||
}
|
||||
SkyboxRenderPass::~SkyboxRenderPass() {}
|
||||
|
||||
void SkyboxRenderPass::beginFrame(const Component::Camera& cam) {
|
||||
RenderPass::beginFrame(cam);
|
||||
|
||||
skyboxDataLayout->reset();
|
||||
textureLayout->reset();
|
||||
skyboxData.transformMatrix = glm::rotate(skyboxData.transformMatrix, (float)(Gfx::getCurrentFrameDelta()), Vector(0, 1, 0));
|
||||
skyboxBuffer->updateContents(DataSource{
|
||||
.size = sizeof(SkyboxData),
|
||||
.data = (uint8*)&skyboxData,
|
||||
});
|
||||
skyboxDataSet = skyboxDataLayout->allocateDescriptorSet();
|
||||
skyboxDataSet->updateBuffer(0, skyboxBuffer);
|
||||
skyboxDataSet->writeChanges();
|
||||
skyboxBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_MEMORY_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT);
|
||||
textureSet = textureLayout->allocateDescriptorSet();
|
||||
textureSet->updateTexture(0, skybox.day);
|
||||
textureSet->updateTexture(1, skybox.night);
|
||||
textureSet->updateSampler(2, skyboxSampler);
|
||||
textureSet->writeChanges();
|
||||
}
|
||||
|
||||
void SkyboxRenderPass::render() {
|
||||
colorAttachment.getTexture()->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
Gfx::SE_ACCESS_COLOR_ATTACHMENT_READ_BIT, Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
|
||||
depthAttachment.getTexture()->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
||||
graphics->beginRenderPass(renderPass);
|
||||
Gfx::ORenderCommand renderCommand = graphics->createRenderCommand("SkyboxRender");
|
||||
renderCommand->setViewport(viewport);
|
||||
renderCommand->bindPipeline(pipeline);
|
||||
renderCommand->bindDescriptor({viewParamsSet, skyboxDataSet, textureSet});
|
||||
renderCommand->draw(36, 1, 0, 0);
|
||||
Array<Gfx::ORenderCommand> commands;
|
||||
commands.add(std::move(renderCommand));
|
||||
graphics->executeCommands(std::move(commands));
|
||||
graphics->endRenderPass();
|
||||
}
|
||||
|
||||
void SkyboxRenderPass::endFrame() {}
|
||||
|
||||
void SkyboxRenderPass::publishOutputs() {
|
||||
skyboxDataLayout = graphics->createDescriptorLayout("pSkyboxData");
|
||||
skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 0,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
});
|
||||
skyboxDataLayout->create();
|
||||
textureLayout = graphics->createDescriptorLayout("pSkyboxTextures");
|
||||
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 0,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
});
|
||||
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 1,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
});
|
||||
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 2,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
|
||||
});
|
||||
textureLayout->create();
|
||||
|
||||
skyboxSampler = graphics->createSampler({});
|
||||
}
|
||||
|
||||
void SkyboxRenderPass::createRenderPass() {
|
||||
colorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
|
||||
colorAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
colorAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
colorAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
|
||||
depthAttachment = resources->requestRenderTarget("BASEPASS_DEPTH");
|
||||
depthAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||
depthAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
depthAttachment.setFinalLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
||||
.colorAttachments = {colorAttachment},
|
||||
.depthAttachment = depthAttachment,
|
||||
};
|
||||
Array<Gfx::SubPassDependency> dependency = {
|
||||
{
|
||||
.srcSubpass = ~0U,
|
||||
.dstSubpass = 0,
|
||||
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.dstStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
},
|
||||
{
|
||||
.srcSubpass = 0,
|
||||
.dstSubpass = ~0U,
|
||||
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||
.dstStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||
},
|
||||
};
|
||||
renderPass = graphics->createRenderPass(std::move(layout), dependency, viewport);
|
||||
|
||||
skyboxData.transformMatrix = Matrix4(1);
|
||||
skyboxData.fogColor = skybox.fogColor;
|
||||
skyboxData.blendFactor = skybox.blendFactor;
|
||||
|
||||
skyboxBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
.sourceData =
|
||||
{
|
||||
.size = sizeof(SkyboxData),
|
||||
.data = (uint8*)&skyboxData,
|
||||
},
|
||||
.dynamic = true,
|
||||
});
|
||||
|
||||
pipelineLayout = graphics->createPipelineLayout("SkyboxLayout");
|
||||
pipelineLayout->addDescriptorLayout(viewParamsLayout);
|
||||
pipelineLayout->addDescriptorLayout(skyboxDataLayout);
|
||||
pipelineLayout->addDescriptorLayout(textureLayout);
|
||||
|
||||
ShaderCreateInfo createInfo = {
|
||||
.name = "SkyboxVertex",
|
||||
.mainModule = "Skybox",
|
||||
.entryPoint = "vertexMain",
|
||||
.rootSignature = pipelineLayout,
|
||||
};
|
||||
vertexShader = graphics->createVertexShader(createInfo);
|
||||
|
||||
createInfo.name = "SkyboxFragment";
|
||||
createInfo.entryPoint = "fragmentMain";
|
||||
fragmentShader = graphics->createFragmentShader(createInfo);
|
||||
|
||||
pipelineLayout->create();
|
||||
|
||||
Gfx::LegacyPipelineCreateInfo gfxInfo = {
|
||||
.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
|
||||
.vertexShader = vertexShader,
|
||||
.fragmentShader = fragmentShader,
|
||||
.renderPass = renderPass,
|
||||
.pipelineLayout = pipelineLayout,
|
||||
.multisampleState =
|
||||
{
|
||||
.samples = viewport->getSamples(),
|
||||
},
|
||||
.rasterizationState =
|
||||
{
|
||||
.polygonMode = Gfx::SE_POLYGON_MODE_FILL,
|
||||
},
|
||||
.colorBlend =
|
||||
{
|
||||
.attachmentCount = 1,
|
||||
},
|
||||
};
|
||||
pipeline = graphics->createGraphicsPipeline(std::move(gfxInfo));
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
#include "Component/Skybox.h"
|
||||
#include "Graphics/Shader.h"
|
||||
#include "RenderPass.h"
|
||||
|
||||
|
||||
namespace Seele {
|
||||
class SkyboxRenderPass : public RenderPass {
|
||||
public:
|
||||
SkyboxRenderPass(Gfx::PGraphics graphics, PScene scene);
|
||||
SkyboxRenderPass(SkyboxRenderPass&&) = default;
|
||||
SkyboxRenderPass& operator=(SkyboxRenderPass&&) = default;
|
||||
virtual ~SkyboxRenderPass();
|
||||
virtual void beginFrame(const Component::Camera& cam) override;
|
||||
virtual void render() override;
|
||||
virtual void endFrame() override;
|
||||
virtual void publishOutputs() override;
|
||||
virtual void createRenderPass() override;
|
||||
|
||||
private:
|
||||
Gfx::RenderTargetAttachment colorAttachment;
|
||||
Gfx::RenderTargetAttachment depthAttachment;
|
||||
Gfx::ODescriptorLayout skyboxDataLayout;
|
||||
Gfx::PDescriptorSet skyboxDataSet;
|
||||
Gfx::ODescriptorLayout textureLayout;
|
||||
Gfx::PDescriptorSet textureSet;
|
||||
Gfx::OVertexShader vertexShader;
|
||||
Gfx::OFragmentShader fragmentShader;
|
||||
Gfx::OPipelineLayout pipelineLayout;
|
||||
Gfx::PGraphicsPipeline pipeline;
|
||||
Gfx::OSampler skyboxSampler;
|
||||
struct SkyboxData {
|
||||
Matrix4 transformMatrix;
|
||||
Vector fogColor;
|
||||
float blendFactor;
|
||||
} skyboxData;
|
||||
Gfx::OUniformBuffer skyboxBuffer;
|
||||
Component::Skybox skybox;
|
||||
};
|
||||
DEFINE_REF(SkyboxRenderPass)
|
||||
} // namespace Seele
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
extern bool resetVisibility;
|
||||
|
||||
VisibilityPass::VisibilityPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics, scene) {}
|
||||
|
||||
VisibilityPass::~VisibilityPass() {}
|
||||
|
||||
Reference in New Issue
Block a user