Screw rendergraphs (for now)
This commit is contained in:
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
BasePassMeshProcessor::BasePassMeshProcessor(const PScene scene, Gfx::PViewport viewport, Gfx::PGraphics graphics, uint8 translucentBasePass)
|
BasePassMeshProcessor::BasePassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics, uint8 translucentBasePass)
|
||||||
: MeshProcessor(scene, graphics)
|
: MeshProcessor(graphics)
|
||||||
, target(viewport)
|
, target(viewport)
|
||||||
, translucentBasePass(translucentBasePass)
|
, translucentBasePass(translucentBasePass)
|
||||||
, cachedPrimitiveIndex(0)
|
, cachedPrimitiveIndex(0)
|
||||||
@@ -79,9 +79,9 @@ void BasePassMeshProcessor::clearCommands()
|
|||||||
cachedPrimitiveIndex = 0;
|
cachedPrimitiveIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BasePass::BasePass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
BasePass::BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
||||||
: RenderPass(renderGraph, graphics, viewport)
|
: RenderPass(graphics, viewport)
|
||||||
, processor(new BasePassMeshProcessor(scene, viewport, graphics, false))
|
, processor(new BasePassMeshProcessor(viewport, graphics, false))
|
||||||
, descriptorSets(4)
|
, descriptorSets(4)
|
||||||
, source(source->getCameraComponent())
|
, source(source->getCameraComponent())
|
||||||
{
|
{
|
||||||
@@ -124,11 +124,6 @@ BasePass::~BasePass()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePass::updateViewFrame(PViewFrame viewFrame)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void BasePass::beginFrame()
|
void BasePass::beginFrame()
|
||||||
{
|
{
|
||||||
processor->clearCommands();
|
processor->clearCommands();
|
||||||
@@ -149,10 +144,10 @@ void BasePass::beginFrame()
|
|||||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||||
/*for(auto &&meshBatch : scene->getStaticMeshes())
|
for(auto &&meshBatch : passData.staticDrawList)
|
||||||
{
|
{
|
||||||
meshBatch.material->updateDescriptorData();
|
meshBatch.material->updateDescriptorData();
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePass::render()
|
void BasePass::render()
|
||||||
@@ -173,10 +168,10 @@ void BasePass::render()
|
|||||||
descriptorSets[INDEX_LIGHT_ENV]->updateTexture(5, oLightGrid);
|
descriptorSets[INDEX_LIGHT_ENV]->updateTexture(5, oLightGrid);
|
||||||
descriptorSets[INDEX_LIGHT_ENV]->writeChanges();
|
descriptorSets[INDEX_LIGHT_ENV]->writeChanges();
|
||||||
graphics->beginRenderPass(renderPass);
|
graphics->beginRenderPass(renderPass);
|
||||||
/*for (auto &&meshBatch : scene->getStaticMeshes())
|
for (auto &&meshBatch : passData.staticDrawList)
|
||||||
{
|
{
|
||||||
processor->addMeshBatch(meshBatch, renderPass, basePassLayout, primitiveLayout, descriptorSets);
|
processor->addMeshBatch(meshBatch, renderPass, basePassLayout, primitiveLayout, descriptorSets);
|
||||||
}*/
|
}
|
||||||
graphics->executeCommands(processor->getRenderCommands());
|
graphics->executeCommands(processor->getRenderCommands());
|
||||||
graphics->endRenderPass();
|
graphics->endRenderPass();
|
||||||
}
|
}
|
||||||
@@ -188,21 +183,21 @@ void BasePass::endFrame()
|
|||||||
void BasePass::publishOutputs()
|
void BasePass::publishOutputs()
|
||||||
{
|
{
|
||||||
colorAttachment = new Gfx::SwapchainAttachment(viewport->getOwner());
|
colorAttachment = new Gfx::SwapchainAttachment(viewport->getOwner());
|
||||||
renderGraph->registerRenderPassOutput("BASEPASS_COLOR", colorAttachment);
|
resources->registerRenderPassOutput("BASEPASS_COLOR", colorAttachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePass::createRenderPass()
|
void BasePass::createRenderPass()
|
||||||
{
|
{
|
||||||
directLightBuffer = renderGraph->requestBuffer("DIRECTIONAL_LIGHTS");
|
directLightBuffer = resources->requestBuffer("DIRECTIONAL_LIGHTS");
|
||||||
pointLightBuffer = renderGraph->requestBuffer("POINT_LIGHTS");
|
pointLightBuffer = resources->requestBuffer("POINT_LIGHTS");
|
||||||
numDirLightBuffer = renderGraph->requestUniform("NUM_DIRECTIONAL_LIGHTS");
|
numDirLightBuffer = resources->requestUniform("NUM_DIRECTIONAL_LIGHTS");
|
||||||
numPointLightBuffer = renderGraph->requestUniform("NUM_POINT_LIGHTS");
|
numPointLightBuffer = resources->requestUniform("NUM_POINT_LIGHTS");
|
||||||
Gfx::PRenderTargetAttachment depthAttachment = renderGraph->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
Gfx::PRenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
||||||
depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
|
depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
Gfx::PRenderTargetLayout layout = new Gfx::RenderTargetLayout(colorAttachment, depthAttachment);
|
Gfx::PRenderTargetLayout layout = new Gfx::RenderTargetLayout(colorAttachment, depthAttachment);
|
||||||
renderPass = graphics->createRenderPass(layout, viewport);
|
renderPass = graphics->createRenderPass(layout, viewport);
|
||||||
oLightIndexList = renderGraph->requestBuffer("LIGHTCULLING_OLIGHTLIST");
|
oLightIndexList = resources->requestBuffer("LIGHTCULLING_OLIGHTLIST");
|
||||||
oLightGrid = renderGraph->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePass::modifyRenderPassMacros(Map<const char*, const char*>& defines)
|
void BasePass::modifyRenderPassMacros(Map<const char*, const char*>& defines)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Seele
|
|||||||
class BasePassMeshProcessor : public MeshProcessor
|
class BasePassMeshProcessor : public MeshProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BasePassMeshProcessor(const PScene scene, Gfx::PViewport viewport, Gfx::PGraphics graphics, uint8 translucentBasePass);
|
BasePassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics, uint8 translucentBasePass);
|
||||||
virtual ~BasePassMeshProcessor();
|
virtual ~BasePassMeshProcessor();
|
||||||
|
|
||||||
virtual void addMeshBatch(
|
virtual void addMeshBatch(
|
||||||
@@ -33,15 +33,13 @@ DECLARE_REF(CameraActor)
|
|||||||
DECLARE_REF(CameraComponent)
|
DECLARE_REF(CameraComponent)
|
||||||
struct BasePassData
|
struct BasePassData
|
||||||
{
|
{
|
||||||
const LightEnv lightEnv;
|
|
||||||
const Array<StaticMeshBatch> staticDrawList;
|
const Array<StaticMeshBatch> staticDrawList;
|
||||||
};
|
};
|
||||||
class BasePass : public RenderPass
|
class BasePass : public RenderPass<BasePassData>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BasePass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
|
BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
|
||||||
virtual ~BasePass();
|
virtual ~BasePass();
|
||||||
virtual void updateViewFrame(PViewFrame viewFrame) override;
|
|
||||||
virtual void beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
virtual void endFrame() override;
|
virtual void endFrame() override;
|
||||||
|
|||||||
@@ -11,6 +11,5 @@ target_sources(SeeleEngine
|
|||||||
RenderGraph.h
|
RenderGraph.h
|
||||||
RenderGraph.cpp
|
RenderGraph.cpp
|
||||||
RenderPass.h
|
RenderPass.h
|
||||||
RenderPass.cpp
|
|
||||||
UIPass.h
|
UIPass.h
|
||||||
UIPass.cpp)
|
UIPass.cpp)
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
DepthPrepassMeshProcessor::DepthPrepassMeshProcessor(const PScene scene, Gfx::PViewport viewport, Gfx::PGraphics graphics)
|
DepthPrepassMeshProcessor::DepthPrepassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics)
|
||||||
: MeshProcessor(scene, graphics)
|
: MeshProcessor(graphics)
|
||||||
, target(viewport)
|
, target(viewport)
|
||||||
, cachedPrimitiveIndex(0)
|
, cachedPrimitiveIndex(0)
|
||||||
{
|
{
|
||||||
@@ -78,9 +78,9 @@ void DepthPrepassMeshProcessor::clearCommands()
|
|||||||
cachedPrimitiveIndex = 0;
|
cachedPrimitiveIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DepthPrepass::DepthPrepass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
||||||
: RenderPass(renderGraph, graphics, viewport)
|
: RenderPass(graphics, viewport)
|
||||||
, processor(new DepthPrepassMeshProcessor(scene, viewport, graphics))
|
, processor(new DepthPrepassMeshProcessor(viewport, graphics))
|
||||||
, descriptorSets(3)
|
, descriptorSets(3)
|
||||||
, source(source->getCameraComponent())
|
, source(source->getCameraComponent())
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,7 @@ DepthPrepass::~DepthPrepass()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthPrepass::beginFrame(UPViewFrame& viewFrame)
|
void DepthPrepass::beginFrame()
|
||||||
{
|
{
|
||||||
processor->clearCommands();
|
processor->clearCommands();
|
||||||
primitiveLayout->reset();
|
primitiveLayout->reset();
|
||||||
@@ -125,13 +125,13 @@ void DepthPrepass::beginFrame(UPViewFrame& viewFrame)
|
|||||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||||
/*for(auto &&meshBatch : scene->getStaticMeshes())
|
for(auto &&meshBatch : passData.staticDrawList)
|
||||||
{
|
{
|
||||||
meshBatch.material->updateDescriptorData();
|
meshBatch.material->updateDescriptorData();
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthPrepass::render(UPViewFrame& viewFrame)
|
void DepthPrepass::render()
|
||||||
{
|
{
|
||||||
depthAttachment->getTexture()->pipelineBarrier(
|
depthAttachment->getTexture()->pipelineBarrier(
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
@@ -146,7 +146,7 @@ void DepthPrepass::render(UPViewFrame& viewFrame)
|
|||||||
graphics->endRenderPass();
|
graphics->endRenderPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthPrepass::endFrame(UPViewFrame& viewFrame)
|
void DepthPrepass::endFrame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ void DepthPrepass::publishOutputs()
|
|||||||
depthAttachment =
|
depthAttachment =
|
||||||
new Gfx::RenderTargetAttachment(depthBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
new Gfx::RenderTargetAttachment(depthBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||||
depthAttachment->clear.depthStencil.depth = 1.0f;
|
depthAttachment->clear.depthStencil.depth = 1.0f;
|
||||||
renderGraph->registerRenderPassOutput("DEPTHPREPASS_DEPTH", depthAttachment);
|
resources->registerRenderPassOutput("DEPTHPREPASS_DEPTH", depthAttachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthPrepass::createRenderPass()
|
void DepthPrepass::createRenderPass()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Seele
|
|||||||
class DepthPrepassMeshProcessor : public MeshProcessor
|
class DepthPrepassMeshProcessor : public MeshProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DepthPrepassMeshProcessor(const PScene scene, Gfx::PViewport viewport, Gfx::PGraphics graphics);
|
DepthPrepassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics);
|
||||||
virtual ~DepthPrepassMeshProcessor();
|
virtual ~DepthPrepassMeshProcessor();
|
||||||
|
|
||||||
virtual void addMeshBatch(
|
virtual void addMeshBatch(
|
||||||
@@ -30,10 +30,14 @@ private:
|
|||||||
DEFINE_REF(DepthPrepassMeshProcessor)
|
DEFINE_REF(DepthPrepassMeshProcessor)
|
||||||
DECLARE_REF(CameraActor)
|
DECLARE_REF(CameraActor)
|
||||||
DECLARE_REF(CameraComponent)
|
DECLARE_REF(CameraComponent)
|
||||||
class DepthPrepass : public RenderPass
|
struct DepthPrepassData
|
||||||
|
{
|
||||||
|
const Array<StaticMeshBatch> staticDrawList;
|
||||||
|
};
|
||||||
|
class DepthPrepass : public RenderPass<DepthPrepassData>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DepthPrepass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
|
DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
|
||||||
~DepthPrepass();
|
~DepthPrepass();
|
||||||
virtual void beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
LightCullingPass::LightCullingPass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera)
|
LightCullingPass::LightCullingPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera)
|
||||||
: RenderPass(renderGraph, graphics, viewport)
|
: RenderPass(graphics, viewport)
|
||||||
, source(camera->getCameraComponent())
|
, source(camera->getCameraComponent())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ LightCullingPass::~LightCullingPass()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightCullingPass::beginFrame(UPViewFrame& viewFrame)
|
void LightCullingPass::beginFrame()
|
||||||
{
|
{
|
||||||
uint32_t viewportWidth = viewport->getSizeX();
|
uint32_t viewportWidth = viewport->getSizeX();
|
||||||
uint32_t viewportHeight = viewport->getSizeY();
|
uint32_t viewportHeight = viewport->getSizeY();
|
||||||
@@ -33,7 +33,7 @@ void LightCullingPass::beginFrame(UPViewFrame& viewFrame)
|
|||||||
uniformUpdate.data = (uint8*)&viewParams;
|
uniformUpdate.data = (uint8*)&viewParams;
|
||||||
viewParamsBuffer->updateContents(uniformUpdate);
|
viewParamsBuffer->updateContents(uniformUpdate);
|
||||||
|
|
||||||
/*LightEnv lightEnv = scene->getLightBuffer();
|
LightEnv lightEnv = passData.lightEnv;
|
||||||
for(uint32 i = 0; i < lightEnv.numPointLights; ++i)
|
for(uint32 i = 0; i < lightEnv.numPointLights; ++i)
|
||||||
{
|
{
|
||||||
lightEnv.pointLights[i].positionVS = lightEnv.pointLights[i].positionWS;
|
lightEnv.pointLights[i].positionVS = lightEnv.pointLights[i].positionWS;
|
||||||
@@ -41,7 +41,7 @@ void LightCullingPass::beginFrame(UPViewFrame& viewFrame)
|
|||||||
uniformUpdate.size = sizeof(PointLight) * MAX_POINT_LIGHTS;
|
uniformUpdate.size = sizeof(PointLight) * MAX_POINT_LIGHTS;
|
||||||
uniformUpdate.data = (uint8*)&lightEnv.pointLights;
|
uniformUpdate.data = (uint8*)&lightEnv.pointLights;
|
||||||
pointLightBuffer->updateContents(uniformUpdate);
|
pointLightBuffer->updateContents(uniformUpdate);
|
||||||
*/
|
|
||||||
BulkResourceData counterReset;
|
BulkResourceData counterReset;
|
||||||
uint32 reset = 0;
|
uint32 reset = 0;
|
||||||
counterReset.data = (uint8*)&reset;
|
counterReset.data = (uint8*)&reset;
|
||||||
@@ -71,7 +71,7 @@ void LightCullingPass::beginFrame(UPViewFrame& viewFrame)
|
|||||||
lightEnvDescriptorSet->writeChanges();
|
lightEnvDescriptorSet->writeChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightCullingPass::render(UPViewFrame& viewFrame)
|
void LightCullingPass::render()
|
||||||
{
|
{
|
||||||
oLightIndexList->pipelineBarrier(
|
oLightIndexList->pipelineBarrier(
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
@@ -97,7 +97,7 @@ void LightCullingPass::render(UPViewFrame& viewFrame)
|
|||||||
depthAttachment->transferOwnership(Gfx::QueueType::GRAPHICS);
|
depthAttachment->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightCullingPass::endFrame(UPViewFrame& viewFrame)
|
void LightCullingPass::endFrame()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -130,32 +130,33 @@ void LightCullingPass::publishOutputs()
|
|||||||
structInfo.bDynamic = false;
|
structInfo.bDynamic = false;
|
||||||
oLightIndexList = graphics->createStructuredBuffer(structInfo);
|
oLightIndexList = graphics->createStructuredBuffer(structInfo);
|
||||||
tLightIndexList = graphics->createStructuredBuffer(structInfo);
|
tLightIndexList = graphics->createStructuredBuffer(structInfo);
|
||||||
renderGraph->registerBufferOutput("LIGHTCULLING_OLIGHTLIST", oLightIndexList);
|
resources->registerBufferOutput("LIGHTCULLING_OLIGHTLIST", oLightIndexList);
|
||||||
renderGraph->registerBufferOutput("LIGHTCULLING_TLIGHTLIST", tLightIndexList);
|
resources->registerBufferOutput("LIGHTCULLING_TLIGHTLIST", tLightIndexList);
|
||||||
/*const LightEnv& lightEnv = scene->getLightBuffer();
|
|
||||||
|
const LightEnv& lightEnv = passData.lightEnv;
|
||||||
resourceData.size = sizeof(DirectionalLight) * MAX_DIRECTIONAL_LIGHTS;
|
resourceData.size = sizeof(DirectionalLight) * MAX_DIRECTIONAL_LIGHTS;
|
||||||
resourceData.data = (uint8*)&lightEnv.directionalLights;*/
|
resourceData.data = (uint8*)&lightEnv.directionalLights;
|
||||||
structInfo.resourceData = resourceData;
|
structInfo.resourceData = resourceData;
|
||||||
structInfo.bDynamic = true;
|
structInfo.bDynamic = true;
|
||||||
directLightBuffer = graphics->createStructuredBuffer(structInfo);
|
directLightBuffer = graphics->createStructuredBuffer(structInfo);
|
||||||
resourceData.size = sizeof(PointLight) * MAX_POINT_LIGHTS;
|
resourceData.size = sizeof(PointLight) * MAX_POINT_LIGHTS;
|
||||||
//resourceData.data = (uint8*)&lightEnv.pointLights;
|
resourceData.data = (uint8*)&lightEnv.pointLights;
|
||||||
structInfo.resourceData = resourceData;
|
structInfo.resourceData = resourceData;
|
||||||
pointLightBuffer = graphics->createStructuredBuffer(structInfo);
|
pointLightBuffer = graphics->createStructuredBuffer(structInfo);
|
||||||
UniformBufferCreateInfo uniformInfo;
|
UniformBufferCreateInfo uniformInfo;
|
||||||
resourceData.size = sizeof(uint32);
|
resourceData.size = sizeof(uint32);
|
||||||
//resourceData.data = (uint8*)&lightEnv.numDirectionalLights;
|
resourceData.data = (uint8*)&lightEnv.numDirectionalLights;
|
||||||
uniformInfo.resourceData = resourceData;
|
uniformInfo.resourceData = resourceData;
|
||||||
uniformInfo.bDynamic = true;
|
uniformInfo.bDynamic = true;
|
||||||
numDirLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
numDirLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
||||||
//resourceData.data = (uint8*)&lightEnv.numPointLights;
|
resourceData.data = (uint8*)&lightEnv.numPointLights;
|
||||||
uniformInfo.resourceData = resourceData;
|
uniformInfo.resourceData = resourceData;
|
||||||
uniformInfo.bDynamic = true;
|
uniformInfo.bDynamic = true;
|
||||||
numPointLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
numPointLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
||||||
renderGraph->registerBufferOutput("DIRECTIONAL_LIGHTS", directLightBuffer);
|
resources->registerBufferOutput("DIRECTIONAL_LIGHTS", directLightBuffer);
|
||||||
renderGraph->registerUniformOutput("NUM_DIRECTIONAL_LIGHTS", numDirLightBuffer);
|
resources->registerUniformOutput("NUM_DIRECTIONAL_LIGHTS", numDirLightBuffer);
|
||||||
renderGraph->registerBufferOutput("POINT_LIGHTS", pointLightBuffer);
|
resources->registerBufferOutput("POINT_LIGHTS", pointLightBuffer);
|
||||||
renderGraph->registerUniformOutput("NUM_POINT_LIGHTS", numPointLightBuffer);
|
resources->registerUniformOutput("NUM_POINT_LIGHTS", numPointLightBuffer);
|
||||||
TextureCreateInfo textureInfo;
|
TextureCreateInfo textureInfo;
|
||||||
textureInfo.width = dispatchParams.numThreadGroups.x;
|
textureInfo.width = dispatchParams.numThreadGroups.x;
|
||||||
textureInfo.height = dispatchParams.numThreadGroups.y;
|
textureInfo.height = dispatchParams.numThreadGroups.y;
|
||||||
@@ -163,9 +164,8 @@ void LightCullingPass::publishOutputs()
|
|||||||
textureInfo.usage = Gfx::SE_IMAGE_USAGE_STORAGE_BIT;
|
textureInfo.usage = Gfx::SE_IMAGE_USAGE_STORAGE_BIT;
|
||||||
oLightGrid = graphics->createTexture2D(textureInfo);
|
oLightGrid = graphics->createTexture2D(textureInfo);
|
||||||
tLightGrid = graphics->createTexture2D(textureInfo);
|
tLightGrid = graphics->createTexture2D(textureInfo);
|
||||||
renderGraph->registerTextureOutput("LIGHTCULLING_OLIGHTGRID", oLightGrid);
|
resources->registerTextureOutput("LIGHTCULLING_OLIGHTGRID", oLightGrid);
|
||||||
renderGraph->registerTextureOutput("LIGHTCULLING_TLIGHTGRID", tLightGrid);
|
resources->registerTextureOutput("LIGHTCULLING_TLIGHTGRID", tLightGrid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ void LightCullingPass::createRenderPass()
|
|||||||
pipelineInfo.pipelineLayout = cullingLayout;
|
pipelineInfo.pipelineLayout = cullingLayout;
|
||||||
cullingPipeline = graphics->createComputePipeline(pipelineInfo);
|
cullingPipeline = graphics->createComputePipeline(pipelineInfo);
|
||||||
|
|
||||||
depthAttachment = renderGraph->requestRenderTarget("DEPTHPREPASS_DEPTH")->getTexture();
|
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH")->getTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightCullingPass::modifyRenderPassMacros(Map<const char*, const char*>& defines)
|
void LightCullingPass::modifyRenderPassMacros(Map<const char*, const char*>& defines)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "RenderPass.h"
|
#include "RenderPass.h"
|
||||||
#include "Graphics/GraphicsResources.h"
|
#include "Graphics/GraphicsResources.h"
|
||||||
|
#include "Scene/Scene.h"
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -8,10 +9,14 @@ DECLARE_REF(CameraActor)
|
|||||||
DECLARE_REF(CameraComponent)
|
DECLARE_REF(CameraComponent)
|
||||||
DECLARE_REF(Scene)
|
DECLARE_REF(Scene)
|
||||||
DECLARE_REF(Viewport)
|
DECLARE_REF(Viewport)
|
||||||
class LightCullingPass : public RenderPass
|
struct LightCullingPassData
|
||||||
|
{
|
||||||
|
const LightEnv lightEnv;
|
||||||
|
};
|
||||||
|
class LightCullingPass : public RenderPass<LightCullingPassData>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LightCullingPass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera);
|
LightCullingPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera);
|
||||||
virtual ~LightCullingPass();
|
virtual ~LightCullingPass();
|
||||||
virtual void beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
|
|||||||
@@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
MeshProcessor::MeshProcessor(const PScene scene, Gfx::PGraphics graphics)
|
MeshProcessor::MeshProcessor(Gfx::PGraphics graphics)
|
||||||
: scene(scene)
|
: graphics(graphics)
|
||||||
, graphics(graphics)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Seele
|
|||||||
class MeshProcessor
|
class MeshProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MeshProcessor(const PScene scene, Gfx::PGraphics graphics);
|
MeshProcessor(Gfx::PGraphics graphics);
|
||||||
virtual ~MeshProcessor();
|
virtual ~MeshProcessor();
|
||||||
protected:
|
protected:
|
||||||
PScene scene;
|
PScene scene;
|
||||||
|
|||||||
@@ -2,49 +2,17 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
|
RenderGraphResources::RenderGraphResources()
|
||||||
RenderGraph::RenderGraph()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderGraph::~RenderGraph()
|
RenderGraphResources::~RenderGraphResources()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderGraph::setup()
|
Gfx::PRenderTargetAttachment RenderGraphResources::requestRenderTarget(const std::string& outputName)
|
||||||
{
|
|
||||||
for(auto& pass : renderPasses)
|
|
||||||
{
|
|
||||||
pass->publishOutputs();
|
|
||||||
}
|
|
||||||
for(auto& pass : renderPasses)
|
|
||||||
{
|
|
||||||
pass->createRenderPass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderGraph::addRenderPass(UPRenderPass renderPass)
|
|
||||||
{
|
|
||||||
renderPasses.add(std::move(renderPass));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderGraph::render(PViewFrame viewFrame)
|
|
||||||
{
|
|
||||||
for(auto& pass : renderPasses)
|
|
||||||
{
|
|
||||||
pass->beginFrame(viewFrame);
|
|
||||||
}
|
|
||||||
for(auto& pass : renderPasses)
|
|
||||||
{
|
|
||||||
pass->render(viewFrame);
|
|
||||||
}
|
|
||||||
for(auto& pass : renderPasses)
|
|
||||||
{
|
|
||||||
pass->endFrame(viewFrame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Gfx::PRenderTargetAttachment RenderGraph::requestRenderTarget(const std::string& outputName)
|
|
||||||
{
|
{
|
||||||
if(registeredAttachments.find(outputName) == registeredAttachments.end())
|
if(registeredAttachments.find(outputName) == registeredAttachments.end())
|
||||||
{
|
{
|
||||||
@@ -54,7 +22,7 @@ Gfx::PRenderTargetAttachment RenderGraph::requestRenderTarget(const std::string&
|
|||||||
return registeredAttachments[outputName];
|
return registeredAttachments[outputName];
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::PTexture RenderGraph::requestTexture(const std::string& outputName)
|
Gfx::PTexture RenderGraphResources::requestTexture(const std::string& outputName)
|
||||||
{
|
{
|
||||||
if(registeredTextures.find(outputName) == registeredTextures.end())
|
if(registeredTextures.find(outputName) == registeredTextures.end())
|
||||||
{
|
{
|
||||||
@@ -64,7 +32,7 @@ Gfx::PTexture RenderGraph::requestTexture(const std::string& outputName)
|
|||||||
return registeredTextures[outputName];
|
return registeredTextures[outputName];
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::PStructuredBuffer RenderGraph::requestBuffer(const std::string& outputName)
|
Gfx::PStructuredBuffer RenderGraphResources::requestBuffer(const std::string& outputName)
|
||||||
{
|
{
|
||||||
if(registeredBuffers.find(outputName) == registeredBuffers.end())
|
if(registeredBuffers.find(outputName) == registeredBuffers.end())
|
||||||
{
|
{
|
||||||
@@ -74,7 +42,7 @@ Gfx::PStructuredBuffer RenderGraph::requestBuffer(const std::string& outputName)
|
|||||||
return registeredBuffers[outputName];
|
return registeredBuffers[outputName];
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::PUniformBuffer RenderGraph::requestUniform(const std::string& outputName)
|
Gfx::PUniformBuffer RenderGraphResources::requestUniform(const std::string& outputName)
|
||||||
{
|
{
|
||||||
if(registeredUniforms.find(outputName) == registeredUniforms.end())
|
if(registeredUniforms.find(outputName) == registeredUniforms.end())
|
||||||
{
|
{
|
||||||
@@ -84,21 +52,21 @@ Gfx::PUniformBuffer RenderGraph::requestUniform(const std::string& outputName)
|
|||||||
return registeredUniforms[outputName];
|
return registeredUniforms[outputName];
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderGraph::registerRenderPassOutput(const std::string& outputName, Gfx::PRenderTargetAttachment attachment)
|
void RenderGraphResources::registerRenderPassOutput(const std::string& outputName, Gfx::PRenderTargetAttachment attachment)
|
||||||
{
|
{
|
||||||
registeredAttachments[outputName] = attachment;
|
registeredAttachments[outputName] = attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderGraph::registerTextureOutput(const std::string& outputName, Gfx::PTexture texture)
|
void RenderGraphResources::registerTextureOutput(const std::string& outputName, Gfx::PTexture texture)
|
||||||
{
|
{
|
||||||
registeredTextures[outputName] = texture;
|
registeredTextures[outputName] = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderGraph::registerBufferOutput(const std::string& outputName, Gfx::PStructuredBuffer buffer)
|
void RenderGraphResources::registerBufferOutput(const std::string& outputName, Gfx::PStructuredBuffer buffer)
|
||||||
{
|
{
|
||||||
registeredBuffers[outputName] = buffer;
|
registeredBuffers[outputName] = buffer;
|
||||||
}
|
}
|
||||||
void RenderGraph::registerUniformOutput(const std::string& outputName, Gfx::PUniformBuffer buffer)
|
void RenderGraphResources::registerUniformOutput(const std::string& outputName, Gfx::PUniformBuffer buffer)
|
||||||
{
|
{
|
||||||
registeredUniforms[outputName] = buffer;
|
registeredUniforms[outputName] = buffer;
|
||||||
}
|
}
|
||||||
@@ -6,14 +6,12 @@
|
|||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
DECLARE_REF(ViewFrame)
|
DECLARE_REF(ViewFrame)
|
||||||
class RenderGraph
|
|
||||||
|
class RenderGraphResources
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderGraph();
|
RenderGraphResources();
|
||||||
~RenderGraph();
|
~RenderGraphResources();
|
||||||
void setup();
|
|
||||||
void addRenderPass(UPRenderPass renderPass);
|
|
||||||
void render(PViewFrame viewFrame);
|
|
||||||
Gfx::PRenderTargetAttachment requestRenderTarget(const std::string& outputName);
|
Gfx::PRenderTargetAttachment requestRenderTarget(const std::string& outputName);
|
||||||
Gfx::PTexture requestTexture(const std::string& outputName);
|
Gfx::PTexture requestTexture(const std::string& outputName);
|
||||||
Gfx::PStructuredBuffer requestBuffer(const std::string& outputName);
|
Gfx::PStructuredBuffer requestBuffer(const std::string& outputName);
|
||||||
@@ -22,12 +20,11 @@ public:
|
|||||||
void registerTextureOutput(const std::string& outputName, Gfx::PTexture buffer);
|
void registerTextureOutput(const std::string& outputName, Gfx::PTexture buffer);
|
||||||
void registerBufferOutput(const std::string& outputName, Gfx::PStructuredBuffer buffer);
|
void registerBufferOutput(const std::string& outputName, Gfx::PStructuredBuffer buffer);
|
||||||
void registerUniformOutput(const std::string& outputName, Gfx::PUniformBuffer buffer);
|
void registerUniformOutput(const std::string& outputName, Gfx::PUniformBuffer buffer);
|
||||||
private:
|
protected:
|
||||||
Map<std::string, Gfx::PRenderTargetAttachment> registeredAttachments;
|
Map<std::string, Gfx::PRenderTargetAttachment> registeredAttachments;
|
||||||
Map<std::string, Gfx::PTexture> registeredTextures;
|
Map<std::string, Gfx::PTexture> registeredTextures;
|
||||||
Map<std::string, Gfx::PStructuredBuffer> registeredBuffers;
|
Map<std::string, Gfx::PStructuredBuffer> registeredBuffers;
|
||||||
Map<std::string, Gfx::PUniformBuffer> registeredUniforms;
|
Map<std::string, Gfx::PUniformBuffer> registeredUniforms;
|
||||||
List<UPRenderPass> renderPasses;
|
|
||||||
};
|
};
|
||||||
DEFINE_REF(RenderGraph)
|
DEFINE_REF(RenderGraphResources)
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
#include "RenderPass.h"
|
|
||||||
|
|
||||||
using namespace Seele;
|
|
||||||
|
|
||||||
RenderPass::RenderPass(PRenderGraph renderGraph, Gfx::PGraphics graphics, Gfx::PViewport viewport)
|
|
||||||
: renderGraph(renderGraph), graphics(graphics), viewport(viewport)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderPass::~RenderPass()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -7,18 +7,26 @@ namespace Seele
|
|||||||
DECLARE_NAME_REF(Gfx, Viewport)
|
DECLARE_NAME_REF(Gfx, Viewport)
|
||||||
DECLARE_NAME_REF(Gfx, Graphics)
|
DECLARE_NAME_REF(Gfx, Graphics)
|
||||||
DECLARE_NAME_REF(Gfx, RenderPass)
|
DECLARE_NAME_REF(Gfx, RenderPass)
|
||||||
DECLARE_REF(RenderGraph)
|
DECLARE_REF(RenderGraphResources)
|
||||||
|
template<typename RenderPassDataType>
|
||||||
class RenderPass
|
class RenderPass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderPass(PRenderGraph rendergraph, Gfx::PGraphics graphics, Gfx::PViewport viewport);
|
RenderPass(Gfx::PGraphics graphics, Gfx::PViewport viewport)
|
||||||
virtual ~RenderPass();
|
: graphics(graphics)
|
||||||
virtual void updateViewFrame(PViewFrame viewFrame) = 0;
|
, viewport(viewport)
|
||||||
|
{}
|
||||||
|
virtual ~RenderPass()
|
||||||
|
{}
|
||||||
|
void updateViewFrame(RenderPassDataType viewFrame) {
|
||||||
|
passData = std::move(viewFrame);
|
||||||
|
}
|
||||||
virtual void beginFrame() = 0;
|
virtual void beginFrame() = 0;
|
||||||
virtual void render() = 0;
|
virtual void render() = 0;
|
||||||
virtual void endFrame() = 0;
|
virtual void endFrame() = 0;
|
||||||
virtual void publishOutputs() = 0;
|
virtual void publishOutputs() = 0;
|
||||||
virtual void createRenderPass() = 0;
|
virtual void createRenderPass() = 0;
|
||||||
|
void setResources(PRenderGraphResources resources) { this->resources = resources; }
|
||||||
protected:
|
protected:
|
||||||
_declspec(align(16)) struct ViewParameter
|
_declspec(align(16)) struct ViewParameter
|
||||||
{
|
{
|
||||||
@@ -28,10 +36,13 @@ protected:
|
|||||||
Vector4 cameraPosition;
|
Vector4 cameraPosition;
|
||||||
Vector2 screenDimensions;
|
Vector2 screenDimensions;
|
||||||
} viewParams;
|
} viewParams;
|
||||||
|
PRenderGraphResources resources;
|
||||||
|
RenderPassDataType passData;
|
||||||
Gfx::PRenderPass renderPass;
|
Gfx::PRenderPass renderPass;
|
||||||
PRenderGraph renderGraph;
|
|
||||||
Gfx::PGraphics graphics;
|
Gfx::PGraphics graphics;
|
||||||
Gfx::PViewport viewport;
|
Gfx::PViewport viewport;
|
||||||
};
|
};
|
||||||
DEFINE_REF(RenderPass)
|
template<typename T>
|
||||||
|
concept RenderPassType = true;
|
||||||
|
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
UIPass::UIPass(PRenderGraph renderGraph, Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment attachment)
|
UIPass::UIPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment attachment)
|
||||||
: RenderPass(renderGraph, graphics, viewport)
|
: RenderPass(graphics, viewport)
|
||||||
, renderTarget(attachment)
|
, renderTarget(attachment)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -15,12 +15,12 @@ UIPass::~UIPass()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIPass::beginFrame(UPViewFrame& viewFrame)
|
void UIPass::beginFrame()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIPass::render(UPViewFrame& viewFrame)
|
void UIPass::render()
|
||||||
{
|
{
|
||||||
graphics->beginRenderPass(renderPass);
|
graphics->beginRenderPass(renderPass);
|
||||||
Gfx::PRenderCommand command = graphics->createRenderCommand("UIPassCommand");
|
Gfx::PRenderCommand command = graphics->createRenderCommand("UIPassCommand");
|
||||||
@@ -31,7 +31,7 @@ void UIPass::render(UPViewFrame& viewFrame)
|
|||||||
graphics->endRenderPass();
|
graphics->endRenderPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIPass::endFrame(UPViewFrame& viewFrame)
|
void UIPass::endFrame()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ void UIPass::publishOutputs()
|
|||||||
depthAttachment =
|
depthAttachment =
|
||||||
new Gfx::RenderTargetAttachment(depthBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
new Gfx::RenderTargetAttachment(depthBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||||
depthAttachment->clear.depthStencil.depth = 1.0f;
|
depthAttachment->clear.depthStencil.depth = 1.0f;
|
||||||
renderGraph->registerRenderPassOutput("UIPASS_DEPTH", depthAttachment);
|
resources->registerRenderPassOutput("UIPASS_DEPTH", depthAttachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIPass::createRenderPass()
|
void UIPass::createRenderPass()
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ struct UIPassData
|
|||||||
{
|
{
|
||||||
const UI::RenderHierarchy hierarchy;
|
const UI::RenderHierarchy hierarchy;
|
||||||
};
|
};
|
||||||
class UIPass : public RenderPass
|
class UIPass : public RenderPass<UIPassData>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UIPass(PRenderGraph renderGraph, Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment renderTarget);
|
UIPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment renderTarget);
|
||||||
virtual ~UIPass();
|
virtual ~UIPass();
|
||||||
virtual void beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
@@ -22,7 +22,6 @@ public:
|
|||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
virtual void createRenderPass() override;
|
virtual void createRenderPass() override;
|
||||||
private:
|
private:
|
||||||
PUIViewFrame uiFrame;
|
|
||||||
Gfx::PRenderTargetAttachment renderTarget;
|
Gfx::PRenderTargetAttachment renderTarget;
|
||||||
Gfx::PRenderTargetAttachment depthAttachment;
|
Gfx::PRenderTargetAttachment depthAttachment;
|
||||||
Gfx::PTexture2D depthBuffer;
|
Gfx::PTexture2D depthBuffer;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "View.h"
|
||||||
|
|
||||||
|
namespace Seele
|
||||||
|
{
|
||||||
|
// A frame is the mutable data needed to
|
||||||
|
// process a time step for the game updates
|
||||||
|
// It contains all the game update relevant data
|
||||||
|
// and is handed over to the renderer for read only processing
|
||||||
|
// If the game loop runs faster than the renderer, the renderer
|
||||||
|
// simply discards old Frames and starts working on the more recent ones
|
||||||
|
// if the game loop runs slower than the renderer (bad), the renderer has to wait
|
||||||
|
struct Frame
|
||||||
|
{
|
||||||
|
uint64 frameNumber;
|
||||||
|
Array<PViewFrame> viewFrame;
|
||||||
|
};
|
||||||
|
} // namespace Seele
|
||||||
@@ -5,11 +5,8 @@ using namespace Seele;
|
|||||||
|
|
||||||
InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo)
|
InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo)
|
||||||
: View(graphics, window, createInfo)
|
: View(graphics, window, createInfo)
|
||||||
|
, renderGraph(UIPass(graphics, viewport, new Gfx::SwapchainAttachment(window->getGfxHandle())))
|
||||||
{
|
{
|
||||||
renderGraph = new RenderGraph();
|
|
||||||
Gfx::PRenderTargetAttachment attachment = new Gfx::SwapchainAttachment(window->getGfxHandle());
|
|
||||||
renderGraph->addRenderPass(new UIPass(renderGraph, graphics, viewport, attachment));
|
|
||||||
renderGraph->setup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectorView::~InspectorView()
|
InspectorView::~InspectorView()
|
||||||
@@ -20,12 +17,23 @@ void InspectorView::beginFrame()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorView::render()
|
void InspectorView::update()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorView::endFrame()
|
void InspectorView::endFrame()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectorView::prepareRender()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectorView::render()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier)
|
void InspectorView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier)
|
||||||
|
|||||||
@@ -7,24 +7,24 @@
|
|||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
DECLARE_REF(Actor)
|
DECLARE_REF(Actor)
|
||||||
class InspectorViewFrame : public ViewFrame
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
protected:
|
|
||||||
const UI::RenderHierarchy hierarchy;
|
|
||||||
};
|
|
||||||
|
|
||||||
class InspectorView : public View
|
class InspectorView : public View
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo);
|
InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo);
|
||||||
virtual ~InspectorView();
|
virtual ~InspectorView();
|
||||||
virtual void beginFrame();
|
|
||||||
virtual void render();
|
|
||||||
virtual void endFrame();
|
|
||||||
void selectActor();
|
|
||||||
|
|
||||||
|
virtual void beginFrame() override;
|
||||||
|
virtual void update() override;
|
||||||
|
virtual void endFrame() override;
|
||||||
|
|
||||||
|
virtual void prepareRender() override;
|
||||||
|
virtual void render() override;
|
||||||
|
void selectActor();
|
||||||
protected:
|
protected:
|
||||||
|
UIPass renderGraph;
|
||||||
|
|
||||||
|
UIPassData uiPassData;
|
||||||
|
|
||||||
UI::PPanel rootPanel;
|
UI::PPanel rootPanel;
|
||||||
PActor selectedActor;
|
PActor selectedActor;
|
||||||
|
|
||||||
|
|||||||
@@ -3,23 +3,18 @@
|
|||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Scene/Actor/CameraActor.h"
|
#include "Scene/Actor/CameraActor.h"
|
||||||
#include "Scene/Components/CameraComponent.h"
|
#include "Scene/Components/CameraComponent.h"
|
||||||
#include "Graphics/RenderPass/DepthPrepass.h"
|
|
||||||
#include "Graphics/RenderPass/LightCullingPass.h"
|
|
||||||
#include "Graphics/RenderPass/BasePass.h"
|
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo)
|
Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo)
|
||||||
: View(graphics, owner, createInfo)
|
: View(graphics, owner, createInfo)
|
||||||
|
, activeCamera(new CameraActor())
|
||||||
|
, depthPrepass(DepthPrepass(graphics, viewport, activeCamera))
|
||||||
|
, lightCullingPass(LightCullingPass(graphics, viewport, activeCamera))
|
||||||
|
, basePass(BasePass(graphics, viewport, activeCamera))
|
||||||
{
|
{
|
||||||
scene = new Scene(graphics);
|
scene = new Scene(graphics);
|
||||||
activeCamera = new CameraActor();
|
|
||||||
scene->addActor(activeCamera);
|
scene->addActor(activeCamera);
|
||||||
renderGraph = new RenderGraph();
|
|
||||||
renderGraph->addRenderPass(new DepthPrepass(renderGraph, scene, graphics, viewport, activeCamera));
|
|
||||||
renderGraph->addRenderPass(new LightCullingPass(renderGraph, scene, graphics, viewport, activeCamera));
|
|
||||||
renderGraph->addRenderPass(new BasePass(renderGraph, scene, graphics, viewport, activeCamera));
|
|
||||||
renderGraph->setup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Seele::SceneView::~SceneView()
|
Seele::SceneView::~SceneView()
|
||||||
@@ -32,6 +27,31 @@ void SceneView::beginFrame()
|
|||||||
scene->tick(Gfx::currentFrameDelta);
|
scene->tick(Gfx::currentFrameDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneView::update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneView::endFrame()
|
||||||
|
{
|
||||||
|
depthPrepassData.staticDrawList = scene->getStaticMeshes();
|
||||||
|
lightCullingPassData.lightEnv = scene->getLightBuffer();
|
||||||
|
basePassData.staticDrawList = scene->getStaticMeshes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneView::prepareRender()
|
||||||
|
{
|
||||||
|
depthPrepass.updateViewFrame(depthPrepassData);
|
||||||
|
lightCullingPass.updateViewFrame(lightCullingPassData);
|
||||||
|
basePass.updateViewFrame(basePassData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneView::render()
|
||||||
|
{
|
||||||
|
depthPrepass.render();
|
||||||
|
lightCullingPass.render();
|
||||||
|
basePass.render();
|
||||||
|
}
|
||||||
|
|
||||||
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
||||||
{
|
{
|
||||||
if(action != InputAction::RELEASE)
|
if(action != InputAction::RELEASE)
|
||||||
|
|||||||
@@ -1,29 +1,38 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "View.h"
|
#include "View.h"
|
||||||
|
#include "Graphics/RenderPass/DepthPrepass.h"
|
||||||
|
#include "Graphics/RenderPass/LightCullingPass.h"
|
||||||
|
#include "Graphics/RenderPass/BasePass.h"
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
DECLARE_REF(Scene)
|
DECLARE_REF(Scene)
|
||||||
DECLARE_REF(CameraActor)
|
DECLARE_REF(CameraActor)
|
||||||
|
|
||||||
class SceneViewFrame : public ViewFrame
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
protected:
|
|
||||||
const PScene scene;
|
|
||||||
};
|
|
||||||
DEFINE_REF(SceneViewFrame)
|
|
||||||
|
|
||||||
class SceneView : public View
|
class SceneView : public View
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo);
|
SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo);
|
||||||
~SceneView();
|
~SceneView();
|
||||||
virtual void beginFrame() override;
|
virtual void beginFrame() override;
|
||||||
|
virtual void update() override;
|
||||||
|
virtual void endFrame() override;
|
||||||
|
|
||||||
|
virtual void prepareRender() override;
|
||||||
|
virtual void render() override;
|
||||||
|
|
||||||
PScene getScene() const { return scene; }
|
PScene getScene() const { return scene; }
|
||||||
private:
|
private:
|
||||||
PScene scene;
|
PScene scene;
|
||||||
PCameraActor activeCamera;
|
PCameraActor activeCamera;
|
||||||
|
|
||||||
|
DepthPrepass depthPrepass;
|
||||||
|
LightCullingPass lightCullingPass;
|
||||||
|
BasePass basePass;
|
||||||
|
|
||||||
|
DepthPrepassData depthPrepassData;
|
||||||
|
LightCullingPassData lightCullingData;
|
||||||
|
BasePassData basePassData;
|
||||||
|
|
||||||
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) override;
|
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) override;
|
||||||
virtual void mouseMoveCallback(double xPos, double yPos) override;
|
virtual void mouseMoveCallback(double xPos, double yPos) override;
|
||||||
virtual void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) override;
|
virtual void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) override;
|
||||||
|
|||||||
@@ -2,30 +2,19 @@
|
|||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
|
|
||||||
Seele::View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &viewportInfo)
|
using namespace Seele;
|
||||||
|
|
||||||
|
View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &viewportInfo)
|
||||||
: graphics(graphics), owner(window)
|
: graphics(graphics), owner(window)
|
||||||
{
|
{
|
||||||
viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo);
|
viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
Seele::View::~View()
|
View::~View()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seele::View::beginFrame()
|
void View::applyArea(URect area)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Seele::View::render()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Seele::View::endFrame()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Seele::View::applyArea(URect area)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-13
@@ -5,32 +5,30 @@ namespace Seele
|
|||||||
{
|
{
|
||||||
DECLARE_REF(Window)
|
DECLARE_REF(Window)
|
||||||
|
|
||||||
// A ViewFrame is the render relevant data of a View
|
|
||||||
class ViewFrame
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
DEFINE_REF(ViewFrame)
|
|
||||||
|
|
||||||
// A view is a part of the window, which can be anything from a scene viewport to an inspector
|
// A view is a part of the window, which can be anything from a scene viewport to an inspector
|
||||||
class View
|
class View
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo);
|
View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo);
|
||||||
virtual ~View();
|
virtual ~View();
|
||||||
virtual void beginFrame();
|
|
||||||
virtual void render();
|
// These are called from the view thread, and handle updating game data
|
||||||
virtual void endFrame();
|
virtual void beginFrame() {}
|
||||||
|
virtual void update() {}
|
||||||
|
// End frame is called with a lock, so it is safe to write to shared memory
|
||||||
|
virtual void endFrame() {}
|
||||||
|
|
||||||
|
// These are called from the render thread
|
||||||
|
// prepare render is also locked, so reading from shared memory is also safe
|
||||||
|
virtual void prepareRender() {}
|
||||||
|
virtual void render() {}
|
||||||
void applyArea(URect area);
|
void applyArea(URect area);
|
||||||
void setFocused();
|
void setFocused();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UPViewFrame currentFrame;
|
|
||||||
Gfx::PGraphics graphics;
|
Gfx::PGraphics graphics;
|
||||||
Gfx::PViewport viewport;
|
Gfx::PViewport viewport;
|
||||||
PWindow owner;
|
PWindow owner;
|
||||||
PRenderGraph renderGraph;
|
|
||||||
|
|
||||||
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) = 0;
|
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) = 0;
|
||||||
virtual void mouseMoveCallback(double xPos, double yPos) = 0;
|
virtual void mouseMoveCallback(double xPos, double yPos) = 0;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ void Window::addView(PView view)
|
|||||||
{
|
{
|
||||||
WindowView* windowView = new WindowView();
|
WindowView* windowView = new WindowView();
|
||||||
windowView->view = view;
|
windowView->view = view;
|
||||||
windowView->renderGraph = view->renderGraph;
|
|
||||||
windowView->worker = std::thread(&Window::viewWorker, this, windowView);
|
windowView->worker = std::thread(&Window::viewWorker, this, windowView);
|
||||||
views.add(windowView);
|
views.add(windowView);
|
||||||
}
|
}
|
||||||
@@ -26,15 +25,11 @@ void Window::render()
|
|||||||
gfxHandle->beginFrame();
|
gfxHandle->beginFrame();
|
||||||
for(auto& windowView : views)
|
for(auto& windowView : views)
|
||||||
{
|
{
|
||||||
UPViewFrame frame;
|
|
||||||
{
|
{
|
||||||
std::lock_guard lock(windowView->workerMutex);
|
std::lock_guard lock(windowView->workerMutex);
|
||||||
frame = std::move(windowView->currentFrame);
|
windowView->view->prepareRender();
|
||||||
}
|
|
||||||
if(frame != nullptr)
|
|
||||||
{
|
|
||||||
windowView->renderGraph->render(std::move(frame));
|
|
||||||
}
|
}
|
||||||
|
windowView->view->render();
|
||||||
}
|
}
|
||||||
gfxHandle->endFrame();
|
gfxHandle->endFrame();
|
||||||
}
|
}
|
||||||
@@ -64,9 +59,8 @@ void Window::viewWorker(WindowView* windowView)
|
|||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
windowView->view->beginFrame();
|
windowView->view->beginFrame();
|
||||||
windowView->view->render();
|
windowView->view->update();
|
||||||
windowView->view->endFrame();
|
|
||||||
std::lock_guard lock(windowView->workerMutex);
|
std::lock_guard lock(windowView->workerMutex);
|
||||||
windowView->currentFrame = std::move(windowView->view->currentFrame);
|
windowView->view->endFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ namespace Seele
|
|||||||
struct WindowView
|
struct WindowView
|
||||||
{
|
{
|
||||||
PView view;
|
PView view;
|
||||||
PRenderGraph renderGraph;
|
|
||||||
UPViewFrame currentFrame;
|
|
||||||
std::thread worker;
|
std::thread worker;
|
||||||
std::mutex workerMutex;
|
std::mutex workerMutex;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user