|
@@ -30,17 +30,15 @@ Ms::~Ms()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
-Error Ms::createRt(U32 index, U32 samples)
|
|
|
|
|
|
|
+Error Ms::createRt(U32 samples)
|
|
|
{
|
|
{
|
|
|
- Plane& plane = m_planes[index];
|
|
|
|
|
-
|
|
|
|
|
m_r->createRenderTarget(m_r->getWidth(),
|
|
m_r->createRenderTarget(m_r->getWidth(),
|
|
|
m_r->getHeight(),
|
|
m_r->getHeight(),
|
|
|
DEPTH_RT_PIXEL_FORMAT,
|
|
DEPTH_RT_PIXEL_FORMAT,
|
|
|
samples,
|
|
samples,
|
|
|
SamplingFilter::NEAREST,
|
|
SamplingFilter::NEAREST,
|
|
|
4,
|
|
4,
|
|
|
- plane.m_depthRt);
|
|
|
|
|
|
|
+ m_depthRt);
|
|
|
|
|
|
|
|
m_r->createRenderTarget(m_r->getWidth(),
|
|
m_r->createRenderTarget(m_r->getWidth(),
|
|
|
m_r->getHeight(),
|
|
m_r->getHeight(),
|
|
@@ -48,7 +46,7 @@ Error Ms::createRt(U32 index, U32 samples)
|
|
|
samples,
|
|
samples,
|
|
|
SamplingFilter::NEAREST,
|
|
SamplingFilter::NEAREST,
|
|
|
2,
|
|
2,
|
|
|
- plane.m_rt0);
|
|
|
|
|
|
|
+ m_rt0);
|
|
|
|
|
|
|
|
m_r->createRenderTarget(m_r->getWidth(),
|
|
m_r->createRenderTarget(m_r->getWidth(),
|
|
|
m_r->getHeight(),
|
|
m_r->getHeight(),
|
|
@@ -56,7 +54,7 @@ Error Ms::createRt(U32 index, U32 samples)
|
|
|
samples,
|
|
samples,
|
|
|
SamplingFilter::NEAREST,
|
|
SamplingFilter::NEAREST,
|
|
|
2,
|
|
2,
|
|
|
- plane.m_rt1);
|
|
|
|
|
|
|
+ m_rt1);
|
|
|
|
|
|
|
|
m_r->createRenderTarget(m_r->getWidth(),
|
|
m_r->createRenderTarget(m_r->getWidth(),
|
|
|
m_r->getHeight(),
|
|
m_r->getHeight(),
|
|
@@ -64,7 +62,7 @@ Error Ms::createRt(U32 index, U32 samples)
|
|
|
samples,
|
|
samples,
|
|
|
SamplingFilter::NEAREST,
|
|
SamplingFilter::NEAREST,
|
|
|
2,
|
|
2,
|
|
|
- plane.m_rt2);
|
|
|
|
|
|
|
+ m_rt2);
|
|
|
|
|
|
|
|
AttachmentLoadOperation loadop = AttachmentLoadOperation::DONT_CARE;
|
|
AttachmentLoadOperation loadop = AttachmentLoadOperation::DONT_CARE;
|
|
|
#if ANKI_DEBUG
|
|
#if ANKI_DEBUG
|
|
@@ -73,21 +71,21 @@ Error Ms::createRt(U32 index, U32 samples)
|
|
|
|
|
|
|
|
FramebufferInitializer fbInit;
|
|
FramebufferInitializer fbInit;
|
|
|
fbInit.m_colorAttachmentsCount = ATTACHMENT_COUNT;
|
|
fbInit.m_colorAttachmentsCount = ATTACHMENT_COUNT;
|
|
|
- fbInit.m_colorAttachments[0].m_texture = plane.m_rt0;
|
|
|
|
|
|
|
+ fbInit.m_colorAttachments[0].m_texture = m_rt0;
|
|
|
fbInit.m_colorAttachments[0].m_loadOperation = loadop;
|
|
fbInit.m_colorAttachments[0].m_loadOperation = loadop;
|
|
|
fbInit.m_colorAttachments[0].m_clearValue.m_colorf = {{1.0, 0.0, 0.0, 0.0}};
|
|
fbInit.m_colorAttachments[0].m_clearValue.m_colorf = {{1.0, 0.0, 0.0, 0.0}};
|
|
|
- fbInit.m_colorAttachments[1].m_texture = plane.m_rt1;
|
|
|
|
|
|
|
+ fbInit.m_colorAttachments[1].m_texture = m_rt1;
|
|
|
fbInit.m_colorAttachments[1].m_loadOperation = loadop;
|
|
fbInit.m_colorAttachments[1].m_loadOperation = loadop;
|
|
|
fbInit.m_colorAttachments[1].m_clearValue.m_colorf = {{0.0, 1.0, 0.0, 0.0}};
|
|
fbInit.m_colorAttachments[1].m_clearValue.m_colorf = {{0.0, 1.0, 0.0, 0.0}};
|
|
|
- fbInit.m_colorAttachments[2].m_texture = plane.m_rt2;
|
|
|
|
|
|
|
+ fbInit.m_colorAttachments[2].m_texture = m_rt2;
|
|
|
fbInit.m_colorAttachments[2].m_loadOperation = loadop;
|
|
fbInit.m_colorAttachments[2].m_loadOperation = loadop;
|
|
|
fbInit.m_colorAttachments[2].m_clearValue.m_colorf = {{0.0, 0.0, 1.0, 0.0}};
|
|
fbInit.m_colorAttachments[2].m_clearValue.m_colorf = {{0.0, 0.0, 1.0, 0.0}};
|
|
|
- fbInit.m_depthStencilAttachment.m_texture = plane.m_depthRt;
|
|
|
|
|
|
|
+ fbInit.m_depthStencilAttachment.m_texture = m_depthRt;
|
|
|
fbInit.m_depthStencilAttachment.m_loadOperation =
|
|
fbInit.m_depthStencilAttachment.m_loadOperation =
|
|
|
AttachmentLoadOperation::CLEAR;
|
|
AttachmentLoadOperation::CLEAR;
|
|
|
fbInit.m_depthStencilAttachment.m_clearValue.m_depthStencil.m_depth = 1.0;
|
|
fbInit.m_depthStencilAttachment.m_clearValue.m_depthStencil.m_depth = 1.0;
|
|
|
|
|
|
|
|
- plane.m_fb = getGrManager().newInstance<Framebuffer>(fbInit);
|
|
|
|
|
|
|
+ m_fb = getGrManager().newInstance<Framebuffer>(fbInit);
|
|
|
|
|
|
|
|
return ErrorCode::NONE;
|
|
return ErrorCode::NONE;
|
|
|
}
|
|
}
|
|
@@ -107,12 +105,7 @@ Error Ms::init(const ConfigSet& initializer)
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
Error Ms::initInternal(const ConfigSet& initializer)
|
|
Error Ms::initInternal(const ConfigSet& initializer)
|
|
|
{
|
|
{
|
|
|
- if(initializer.getNumber("samples") > 1)
|
|
|
|
|
- {
|
|
|
|
|
- ANKI_CHECK(createRt(0, initializer.getNumber("samples")));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- ANKI_CHECK(createRt(1, 1));
|
|
|
|
|
|
|
+ ANKI_CHECK(createRt(initializer.getNumber("samples")));
|
|
|
|
|
|
|
|
m_secondLevelCmdbs.create(
|
|
m_secondLevelCmdbs.create(
|
|
|
getAllocator(), m_r->getThreadPool().getThreadsCount());
|
|
getAllocator(), m_r->getThreadPool().getThreadsCount());
|
|
@@ -125,13 +118,6 @@ Error Ms::initInternal(const ConfigSet& initializer)
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
Error Ms::run(CommandBufferPtr& cmdb)
|
|
Error Ms::run(CommandBufferPtr& cmdb)
|
|
|
{
|
|
{
|
|
|
- // Chose the multisampled or the singlesampled framebuffer
|
|
|
|
|
- U planeId = 0;
|
|
|
|
|
- if(m_r->getSamples() == 1)
|
|
|
|
|
- {
|
|
|
|
|
- planeId = 1;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// Create 2nd level cmdbs
|
|
// Create 2nd level cmdbs
|
|
|
U threadCount = m_r->getThreadPool().getThreadsCount();
|
|
U threadCount = m_r->getThreadPool().getThreadsCount();
|
|
|
GrManager& gr = m_r->getGrManager();
|
|
GrManager& gr = m_r->getGrManager();
|
|
@@ -143,7 +129,7 @@ Error Ms::run(CommandBufferPtr& cmdb)
|
|
|
|
|
|
|
|
cmdb->setViewport(0, 0, m_r->getWidth(), m_r->getHeight());
|
|
cmdb->setViewport(0, 0, m_r->getWidth(), m_r->getHeight());
|
|
|
|
|
|
|
|
- cmdb->bindFramebuffer(m_planes[planeId].m_fb);
|
|
|
|
|
|
|
+ cmdb->bindFramebuffer(m_fb);
|
|
|
|
|
|
|
|
// render all
|
|
// render all
|
|
|
FrustumComponent& frc = m_r->getActiveFrustumComponent();
|
|
FrustumComponent& frc = m_r->getActiveFrustumComponent();
|
|
@@ -152,18 +138,6 @@ Error Ms::run(CommandBufferPtr& cmdb)
|
|
|
ANKI_CHECK(m_r->getSceneDrawer().render(
|
|
ANKI_CHECK(m_r->getSceneDrawer().render(
|
|
|
frc, RenderingStage::MATERIAL, Pass::MS_FS, cmdbs));
|
|
frc, RenderingStage::MATERIAL, Pass::MS_FS, cmdbs));
|
|
|
|
|
|
|
|
- // If there is multisampling then resolve to singlesampled
|
|
|
|
|
- if(m_r->getSamples() > 1)
|
|
|
|
|
- {
|
|
|
|
|
-#if 0
|
|
|
|
|
- fbo[1].blitFrom(fbo[0], UVec2(0U), UVec2(r->getWidth(), r->getHeight()),
|
|
|
|
|
- UVec2(0U), UVec2(r->getWidth(), r->getHeight()),
|
|
|
|
|
- GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
|
|
|
|
|
- GL_NEAREST_BASE);
|
|
|
|
|
-#endif
|
|
|
|
|
- ANKI_ASSERT(0 && "TODO");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
for(U i = 0; i < m_secondLevelCmdbs.getSize(); ++i)
|
|
for(U i = 0; i < m_secondLevelCmdbs.getSize(); ++i)
|
|
|
{
|
|
{
|
|
|
if(!m_secondLevelCmdbs[i]->isEmpty())
|
|
if(!m_secondLevelCmdbs[i]->isEmpty())
|
|
@@ -177,13 +151,12 @@ Error Ms::run(CommandBufferPtr& cmdb)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
-void Ms::generateMipmaps(CommandBufferPtr& cmdb)
|
|
|
|
|
|
|
+void Ms::downScaleGBuffer(CommandBufferPtr& cmdb)
|
|
|
{
|
|
{
|
|
|
- U planeId = (m_r->getSamples() == 1) ? 1 : 0;
|
|
|
|
|
- cmdb->generateMipmaps(m_planes[planeId].m_depthRt);
|
|
|
|
|
- cmdb->generateMipmaps(m_planes[planeId].m_rt0);
|
|
|
|
|
- cmdb->generateMipmaps(m_planes[planeId].m_rt1);
|
|
|
|
|
- cmdb->generateMipmaps(m_planes[planeId].m_rt2);
|
|
|
|
|
|
|
+ cmdb->generateMipmaps(m_depthRt);
|
|
|
|
|
+ cmdb->generateMipmaps(m_rt0);
|
|
|
|
|
+ cmdb->generateMipmaps(m_rt1);
|
|
|
|
|
+ cmdb->generateMipmaps(m_rt2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} // end namespace anki
|
|
} // end namespace anki
|