Debug fade management moved out of the inner render loop

This commit is contained in:
Olivier Prat 2017-06-06 14:57:52 +02:00
parent 1936c209a5
commit e7eca7728f
3 changed files with 36 additions and 32 deletions

View file

@ -533,7 +533,7 @@ float ModelMeshPartPayload::computeFadePercent() const {
return 0.0f;
}
float fadeAlpha = 1.0f;
const double INV_FADE_PERIOD = 1.0 / (double)(10 * USECS_PER_SECOND);
const double INV_FADE_PERIOD = 1.0 / (double)(3 * USECS_PER_SECOND);
double fraction = (double)(usecTimestampNow() - _fadeStartTime) * INV_FADE_PERIOD;
if (fraction < 1.0) {
fadeAlpha = Interpolate::simpleNonLinearBlend(fraction);

View file

@ -252,6 +252,15 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs&
const auto& lightingModel = inputs.get1();
RenderArgs* args = renderContext->args;
ShapeKey::Builder defaultKeyBuilder;
if (_debugFade) {
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags |
static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
args->_debugFadePercent = _debugFadePercent;
// Force fade for everyone
defaultKeyBuilder.withFade();
}
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
args->_batch = &batch;
@ -272,19 +281,12 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs&
batch.setUniformBuffer(render::ShapePipeline::Slot::LIGHTING_MODEL, lightingModel->getParametersBuffer());
// From the lighting model define a global shapKey ORED with individiual keys
ShapeKey::Builder keyBuilder;
ShapeKey::Builder keyBuilder = defaultKeyBuilder;
if (lightingModel->isWireframeEnabled()) {
keyBuilder.withWireframe();
}
// Prepare fade effect
batch.setResourceTexture(ShapePipeline::Slot::MAP::FADE_MASK, _fadeMaskMap);
if (_debugFade) {
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags |
static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
args->_debugFadePercent = _debugFadePercent;
// Force fade for everyone
keyBuilder.withFade();
}
ShapeKey globalKey = keyBuilder.build();
args->_globalShapeKey = globalKey._flags.to_ulong();
@ -293,15 +295,15 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs&
args->_batch = nullptr;
args->_globalShapeKey = 0;
// Not sure this is really needed...
if (_debugFade) {
// Turn off fade debug
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags &
~static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
}
});
// Not sure this is really needed...
if (_debugFade) {
// Turn off fade debug
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags &
~static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
}
config->setNumDrawn((int)inItems.size());
}
@ -315,6 +317,15 @@ void DrawStateSortDeferred::run(const RenderContextPointer& renderContext, const
const auto& lightingModel = inputs.get1();
RenderArgs* args = renderContext->args;
ShapeKey::Builder defaultKeyBuilder;
if (_debugFade) {
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags |
static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
args->_debugFadePercent = _debugFadePercent;
// Force fade for everyone
defaultKeyBuilder.withFade();
}
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
args->_batch = &batch;
@ -335,20 +346,13 @@ void DrawStateSortDeferred::run(const RenderContextPointer& renderContext, const
batch.setUniformBuffer(render::ShapePipeline::Slot::LIGHTING_MODEL, lightingModel->getParametersBuffer());
// From the lighting model define a global shapeKey ORED with individiual keys
ShapeKey::Builder keyBuilder;
ShapeKey::Builder keyBuilder = defaultKeyBuilder;
if (lightingModel->isWireframeEnabled()) {
keyBuilder.withWireframe();
}
// Prepare fade effect
batch.setResourceTexture(ShapePipeline::Slot::MAP::FADE_MASK, _fadeMaskMap);
if (_debugFade) {
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags |
static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
args->_debugFadePercent = _debugFadePercent;
// Force fade for everyone
keyBuilder.withFade();
}
ShapeKey globalKey = keyBuilder.build();
args->_globalShapeKey = globalKey._flags.to_ulong();
@ -360,15 +364,15 @@ void DrawStateSortDeferred::run(const RenderContextPointer& renderContext, const
}
args->_batch = nullptr;
args->_globalShapeKey = 0;
// Not sure this is really needed...
if (_debugFade) {
// Turn off fade debug
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags &
~static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
}
});
// Not sure this is really needed...
if (_debugFade) {
// Turn off fade debug
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags &
~static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
}
config->setNumDrawn((int)inItems.size());
}

View file

@ -51,7 +51,6 @@ protected:
gpu::TexturePointer _fadeMaskMap;
float _debugFadePercent;
bool _stateSort;
bool _debugFade;
};
@ -135,6 +134,7 @@ public:
protected:
render::ShapePlumberPointer _shapePlumber;
int _maxDrawn; // initialized by Config
bool _stateSort;
};
class DeferredFramebuffer;