Add some more perfs counter to post process
This commit is contained in:
parent
59f586c5ee
commit
94c65434df
@ -84,6 +84,10 @@ enum QueryPerf
|
||||
Q_TRANSPARENT,
|
||||
Q_PARTICLES,
|
||||
Q_DISPLACEMENT,
|
||||
Q_GODRAYS,
|
||||
Q_BLOOM,
|
||||
Q_TONEMAP,
|
||||
Q_MOTIONBLUR,
|
||||
Q_LAST
|
||||
};
|
||||
|
||||
|
@ -624,10 +624,8 @@ void PostProcessing::applyMLAA()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Render the post-processed scene */
|
||||
void PostProcessing::render()
|
||||
void PostProcessing::render(scene::ICameraSceneNode * const camnode)
|
||||
{
|
||||
if (!irr_driver->isGLSL()) return;
|
||||
|
||||
IVideoDriver * const drv = irr_driver->getVideoDriver();
|
||||
|
||||
MotionBlurProvider * const mocb = (MotionBlurProvider *) irr_driver->
|
||||
@ -635,29 +633,25 @@ void PostProcessing::render()
|
||||
GaussianBlurProvider * const gacb = (GaussianBlurProvider *) irr_driver->
|
||||
getCallback(ES_GAUSSIAN3H);
|
||||
|
||||
const u32 cams = Camera::getNumCameras();
|
||||
for(u32 cam = 0; cam < cams; cam++)
|
||||
GLuint in_rtt = irr_driver->getRenderTargetTexture(RTT_COLOR), in_fbo = irr_driver->getFBO(FBO_COLORS);
|
||||
GLuint out_rtt = irr_driver->getRenderTargetTexture(RTT_TMP1), out_fbo = irr_driver->getFBO(FBO_TMP1_WITH_DS);
|
||||
// Each effect uses these as named, and sets them up for the next effect.
|
||||
// This allows chaining effects where some may be disabled.
|
||||
|
||||
// As the original color shouldn't be touched, the first effect can't be disabled.
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
if (UserConfigParams::m_dof)
|
||||
{
|
||||
scene::ICameraSceneNode * const camnode =
|
||||
Camera::getCamera(cam)->getCameraSceneNode();
|
||||
mocb->setCurrentCamera(cam);
|
||||
GLuint in_rtt = irr_driver->getRenderTargetTexture(RTT_COLOR), in_fbo = irr_driver->getFBO(FBO_COLORS);
|
||||
GLuint out_rtt = irr_driver->getRenderTargetTexture(RTT_TMP1), out_fbo = irr_driver->getFBO(FBO_TMP1_WITH_DS);
|
||||
// Each effect uses these as named, and sets them up for the next effect.
|
||||
// This allows chaining effects where some may be disabled.
|
||||
|
||||
// As the original color shouldn't be touched, the first effect can't be disabled.
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
if (UserConfigParams::m_dof)
|
||||
{
|
||||
renderDoF(out_fbo, in_rtt);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
}
|
||||
renderDoF(out_fbo, in_rtt);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
}
|
||||
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Godrays", 0xFF, 0x00, 0x00);
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_GODRAYS));
|
||||
const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays();
|
||||
if (UserConfigParams::m_light_shaft && m_sunpixels > 30 && hasgodrays)
|
||||
{
|
||||
@ -665,7 +659,7 @@ void PostProcessing::render()
|
||||
// Grab the sky
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
// irr_driver->renderSkybox();
|
||||
irr_driver->renderSkybox(camnode);
|
||||
|
||||
// Set the sun's color
|
||||
const SColor col = World::getWorld()->getTrack()->getSunColor();
|
||||
@ -700,8 +694,8 @@ void PostProcessing::render()
|
||||
|
||||
trans.transformVect(ndc, pos);
|
||||
|
||||
const float texh = m_vertices[cam].v1.TCoords.Y - m_vertices[cam].v0.TCoords.Y;
|
||||
const float texw = m_vertices[cam].v3.TCoords.X - m_vertices[cam].v0.TCoords.X;
|
||||
const float texh = m_vertices[0].v1.TCoords.Y - m_vertices[0].v0.TCoords.Y;
|
||||
const float texw = m_vertices[0].v3.TCoords.X - m_vertices[0].v0.TCoords.X;
|
||||
|
||||
const float sunx = ((ndc[0] / ndc[3]) * 0.5f + 0.5f) * texw;
|
||||
const float suny = ((ndc[1] / ndc[3]) * 0.5f + 0.5f) * texh;
|
||||
@ -727,10 +721,13 @@ void PostProcessing::render()
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
// Simulate camera defects from there
|
||||
// Simulate camera defects from there
|
||||
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Bloom", 0xFF, 0x00, 0x00);
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_BLOOM));
|
||||
if (UserConfigParams::m_bloom)
|
||||
{
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
@ -784,53 +781,61 @@ void PostProcessing::render()
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_512));
|
||||
glDisable(GL_BLEND);
|
||||
} // end if bloom
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
computeLogLuminance(in_rtt);
|
||||
}
|
||||
|
||||
//computeLogLuminance(in_rtt);
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Tonemap", 0xFF, 0x00, 0x00);
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_TONEMAP));
|
||||
toneMap(out_fbo, in_rtt);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Motion blur", 0xFF, 0x00, 0x00);
|
||||
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_MOTIONBLUR));
|
||||
if (UserConfigParams::m_motionblur && m_any_boost) // motion blur
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- Motion blur", 0xFF, 0x00, 0x00);
|
||||
renderMotionBlur(cam, in_rtt, out_fbo);
|
||||
renderMotionBlur(0, in_rtt, out_fbo);
|
||||
std::swap(in_fbo, out_fbo);
|
||||
std::swap(in_rtt, out_rtt);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
if (irr_driver->getNormals())
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH));
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
else if (irr_driver->getSSAOViz())
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_SSAO));
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
else if (UserConfigParams::m_mlaa) // MLAA. Must be the last pp filter.
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- MLAA", 0xFF, 0x00, 0x00);
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_MLAA_COLORS));
|
||||
renderPassThrough(in_rtt);
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
applyMLAA();
|
||||
blitFBO(irr_driver->getFBO(FBO_MLAA_COLORS), 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderPassThrough(in_rtt);
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
if (irr_driver->getNormals())
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH));
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
else if (irr_driver->getSSAOViz())
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_SSAO));
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
else if (UserConfigParams::m_mlaa) // MLAA. Must be the last pp filter.
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("- MLAA", 0xFF, 0x00, 0x00);
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_MLAA_COLORS));
|
||||
renderPassThrough(in_rtt);
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
applyMLAA();
|
||||
blitFBO(irr_driver->getFBO(FBO_MLAA_COLORS), 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderPassThrough(in_rtt);
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
} // render
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "IShaderConstantSetCallBack.h"
|
||||
#include "S3DVertex.h"
|
||||
#include "SMaterial.h"
|
||||
#include "graphics/camera.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -92,7 +93,7 @@ public:
|
||||
void renderGlow(unsigned tex);
|
||||
|
||||
/** Render the post-processed scene */
|
||||
void render();
|
||||
void render(scene::ICameraSceneNode * const camnode);
|
||||
|
||||
/** Use motion blur for a short time */
|
||||
void giveBoost(unsigned int cam_index);
|
||||
|
@ -142,6 +142,12 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
renderScene(camnode, glows, dt, track->hasShadows());
|
||||
|
||||
// Render the post-processed scene
|
||||
if (UserConfigParams::m_dynamic_lights)
|
||||
m_post_processing->render(camnode);
|
||||
else
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
// Note that drawAll must be called before rendering
|
||||
@ -152,14 +158,6 @@ void IrrDriver::renderGLSL(float dt)
|
||||
World::getWorld()->getPhysics()->draw();
|
||||
} // for i<world->getNumKarts()
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("Postprocessing", 0xFF, 0xFF, 0x00);
|
||||
// Render the post-processed scene
|
||||
if (UserConfigParams::m_dynamic_lights)
|
||||
m_post_processing->render();
|
||||
else
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user