mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 05:48:26 +02:00
more work on batch optimzation
This commit is contained in:
parent
b2bbaf4e7b
commit
85b2322acc
13 changed files with 138 additions and 112 deletions
|
@ -1037,6 +1037,8 @@ void Application::initializeUi() {
|
||||||
|
|
||||||
void Application::paintGL() {
|
void Application::paintGL() {
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
|
PerformanceTimer perfTimer("paintGL");
|
||||||
|
|
||||||
if (nullptr == _displayPlugin) {
|
if (nullptr == _displayPlugin) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1063,18 +1065,19 @@ void Application::paintGL() {
|
||||||
lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
|
lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
|
||||||
RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
|
RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
|
||||||
|
|
||||||
PerformanceTimer perfTimer("paintGL");
|
|
||||||
|
|
||||||
|
|
||||||
PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
|
PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
|
||||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||||
PerformanceWarning warn(showWarnings, "Application::paintGL()");
|
PerformanceWarning warn(showWarnings, "Application::paintGL()");
|
||||||
resizeGL();
|
resizeGL();
|
||||||
|
|
||||||
// Before anything else, let's sync up the gpuContext with the true glcontext used in case anything happened
|
// Before anything else, let's sync up the gpuContext with the true glcontext used in case anything happened
|
||||||
renderArgs._context->syncCache();
|
{
|
||||||
|
PerformanceTimer perfTimer("syncCache");
|
||||||
|
renderArgs._context->syncCache();
|
||||||
|
}
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
|
||||||
|
PerformanceTimer perfTimer("Mirror");
|
||||||
auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
|
auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
|
||||||
|
|
||||||
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
||||||
|
@ -1088,7 +1091,7 @@ void Application::paintGL() {
|
||||||
auto mirrorRectDest = glm::ivec4(mirrorRect.z, mirrorRect.y, mirrorRect.x, mirrorRect.w);
|
auto mirrorRectDest = glm::ivec4(mirrorRect.z, mirrorRect.y, mirrorRect.x, mirrorRect.w);
|
||||||
|
|
||||||
auto selfieFbo = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer();
|
auto selfieFbo = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer();
|
||||||
doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
|
||||||
batch.setFramebuffer(selfieFbo);
|
batch.setFramebuffer(selfieFbo);
|
||||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
|
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
batch.blit(primaryFbo, mirrorRect, selfieFbo, mirrorRectDest);
|
batch.blit(primaryFbo, mirrorRect, selfieFbo, mirrorRectDest);
|
||||||
|
@ -1106,81 +1109,86 @@ void Application::paintGL() {
|
||||||
_applicationOverlay.renderOverlay(&renderArgs);
|
_applicationOverlay.renderOverlay(&renderArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
_myAvatar->startCapture();
|
{
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
PerformanceTimer perfTimer("CameraUpdates");
|
||||||
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
|
|
||||||
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
|
|
||||||
Application::getInstance()->cameraMenuChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The render mode is default or mirror if the camera is in mirror mode, assigned further below
|
_myAvatar->startCapture();
|
||||||
renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
|
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||||
|
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
|
||||||
// Always use the default eye position, not the actual head eye position.
|
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
|
||||||
// Using the latter will cause the camera to wobble with idle animations,
|
Application::getInstance()->cameraMenuChanged();
|
||||||
// or with changes from the face tracker
|
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
|
||||||
if (isHMDMode()) {
|
|
||||||
mat4 camMat = _myAvatar->getSensorToWorldMatrix() * _myAvatar->getHMDSensorMatrix();
|
|
||||||
_myCamera.setPosition(extractTranslation(camMat));
|
|
||||||
_myCamera.setRotation(glm::quat_cast(camMat));
|
|
||||||
} else {
|
|
||||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition());
|
|
||||||
_myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation());
|
|
||||||
}
|
}
|
||||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
|
||||||
if (isHMDMode()) {
|
// The render mode is default or mirror if the camera is in mirror mode, assigned further below
|
||||||
glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix());
|
renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
|
||||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * hmdRotation);
|
|
||||||
// Ignore MenuOption::CenterPlayerInView in HMD view
|
// Always use the default eye position, not the actual head eye position.
|
||||||
glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix());
|
// Using the latter will cause the camera to wobble with idle animations,
|
||||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
// or with changes from the face tracker
|
||||||
+ _myAvatar->getOrientation()
|
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||||
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f) + hmdOffset));
|
if (isHMDMode()) {
|
||||||
} else {
|
mat4 camMat = _myAvatar->getSensorToWorldMatrix() * _myAvatar->getHMDSensorMatrix();
|
||||||
_myCamera.setRotation(_myAvatar->getHead()->getOrientation());
|
_myCamera.setPosition(extractTranslation(camMat));
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
|
_myCamera.setRotation(glm::quat_cast(camMat));
|
||||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
|
||||||
+ _myCamera.getRotation()
|
|
||||||
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
|
|
||||||
} else {
|
} else {
|
||||||
|
_myCamera.setPosition(_myAvatar->getDefaultEyePosition());
|
||||||
|
_myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation());
|
||||||
|
}
|
||||||
|
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||||
|
if (isHMDMode()) {
|
||||||
|
glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix());
|
||||||
|
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * hmdRotation);
|
||||||
|
// Ignore MenuOption::CenterPlayerInView in HMD view
|
||||||
|
glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix());
|
||||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||||
+ _myAvatar->getOrientation()
|
+ _myAvatar->getOrientation()
|
||||||
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
|
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f) + hmdOffset));
|
||||||
|
} else {
|
||||||
|
_myCamera.setRotation(_myAvatar->getHead()->getOrientation());
|
||||||
|
if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) {
|
||||||
|
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||||
|
+ _myCamera.getRotation()
|
||||||
|
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
|
||||||
|
} else {
|
||||||
|
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||||
|
+ _myAvatar->getOrientation()
|
||||||
|
* (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
|
if (isHMDMode()) {
|
||||||
|
glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix());
|
||||||
|
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()
|
||||||
|
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation);
|
||||||
|
glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix());
|
||||||
|
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||||
|
+ glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)
|
||||||
|
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
||||||
|
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
|
||||||
|
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset);
|
||||||
|
} else {
|
||||||
|
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()
|
||||||
|
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
||||||
|
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
||||||
|
+ glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)
|
||||||
|
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
||||||
|
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
|
||||||
|
}
|
||||||
|
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
||||||
}
|
}
|
||||||
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
// Update camera position
|
||||||
if (isHMDMode()) {
|
if (!isHMDMode()) {
|
||||||
glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix());
|
_myCamera.update(1.0f / _fps);
|
||||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()
|
|
||||||
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation);
|
|
||||||
glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix());
|
|
||||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
|
||||||
+ glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)
|
|
||||||
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
|
||||||
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror
|
|
||||||
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset);
|
|
||||||
} else {
|
|
||||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()
|
|
||||||
* glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
|
||||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition()
|
|
||||||
+ glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)
|
|
||||||
+ (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) *
|
|
||||||
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
|
|
||||||
}
|
}
|
||||||
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
_myAvatar->endCapture();
|
||||||
}
|
}
|
||||||
// Update camera position
|
|
||||||
if (!isHMDMode()) {
|
|
||||||
_myCamera.update(1.0f / _fps);
|
|
||||||
}
|
|
||||||
_myAvatar->endCapture();
|
|
||||||
|
|
||||||
// Primary rendering pass
|
// Primary rendering pass
|
||||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||||
const QSize size = framebufferCache->getFrameBufferSize();
|
const QSize size = framebufferCache->getFrameBufferSize();
|
||||||
{
|
{
|
||||||
PROFILE_RANGE(__FUNCTION__ "/mainRender");
|
PROFILE_RANGE(__FUNCTION__ "/mainRender");
|
||||||
|
PerformanceTimer perfTimer("mainRender");
|
||||||
// Viewport is assigned to the size of the framebuffer
|
// Viewport is assigned to the size of the framebuffer
|
||||||
renderArgs._viewport = ivec4(0, 0, size.width(), size.height());
|
renderArgs._viewport = ivec4(0, 0, size.width(), size.height());
|
||||||
if (displayPlugin->isStereo()) {
|
if (displayPlugin->isStereo()) {
|
||||||
|
@ -1217,7 +1225,7 @@ void Application::paintGL() {
|
||||||
}
|
}
|
||||||
displaySide(&renderArgs, _myCamera);
|
displaySide(&renderArgs, _myCamera);
|
||||||
renderArgs._context->enableStereo(false);
|
renderArgs._context->enableStereo(false);
|
||||||
doInBatch(renderArgs._context, [](gpu::Batch& batch) {
|
gpu::doInBatch(renderArgs._context, [](gpu::Batch& batch) {
|
||||||
batch.setFramebuffer(nullptr);
|
batch.setFramebuffer(nullptr);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1225,6 +1233,7 @@ void Application::paintGL() {
|
||||||
// Overlay Composition, needs to occur after screen space effects have completed
|
// Overlay Composition, needs to occur after screen space effects have completed
|
||||||
{
|
{
|
||||||
PROFILE_RANGE(__FUNCTION__ "/compositor");
|
PROFILE_RANGE(__FUNCTION__ "/compositor");
|
||||||
|
PerformanceTimer perfTimer("compositor");
|
||||||
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));
|
||||||
if (displayPlugin->isStereo()) {
|
if (displayPlugin->isStereo()) {
|
||||||
|
@ -1249,6 +1258,7 @@ void Application::paintGL() {
|
||||||
// deliver final composited scene to the display plugin
|
// deliver final composited scene to the display plugin
|
||||||
{
|
{
|
||||||
PROFILE_RANGE(__FUNCTION__ "/pluginOutput");
|
PROFILE_RANGE(__FUNCTION__ "/pluginOutput");
|
||||||
|
PerformanceTimer perfTimer("pluginOutput");
|
||||||
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
||||||
GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0));
|
GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0));
|
||||||
// Ensure the rendering context commands are completed when rendering
|
// Ensure the rendering context commands are completed when rendering
|
||||||
|
@ -1266,24 +1276,29 @@ void Application::paintGL() {
|
||||||
|
|
||||||
{
|
{
|
||||||
PROFILE_RANGE(__FUNCTION__ "/pluginDisplay");
|
PROFILE_RANGE(__FUNCTION__ "/pluginDisplay");
|
||||||
|
PerformanceTimer perfTimer("pluginDisplay");
|
||||||
displayPlugin->display(finalTexture, toGlm(size));
|
displayPlugin->display(finalTexture, toGlm(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
PROFILE_RANGE(__FUNCTION__ "/bufferSwap");
|
PROFILE_RANGE(__FUNCTION__ "/bufferSwap");
|
||||||
|
PerformanceTimer perfTimer("bufferSwap");
|
||||||
displayPlugin->finishFrame();
|
displayPlugin->finishFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_offscreenContext->makeCurrent();
|
{
|
||||||
_frameCount++;
|
PerformanceTimer perfTimer("makeCurrent");
|
||||||
Stats::getInstance()->setRenderDetails(renderArgs._details);
|
_offscreenContext->makeCurrent();
|
||||||
|
_frameCount++;
|
||||||
|
Stats::getInstance()->setRenderDetails(renderArgs._details);
|
||||||
|
|
||||||
// Reset the gpu::Context Stages
|
// Reset the gpu::Context Stages
|
||||||
// Back to the default framebuffer;
|
// Back to the default framebuffer;
|
||||||
doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
|
||||||
batch.resetStages();
|
batch.resetStages();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::runTests() {
|
void Application::runTests() {
|
||||||
|
|
|
@ -207,7 +207,7 @@ void ApplicationCompositor::displayOverlayTexture(RenderArgs* renderArgs) {
|
||||||
updateTooltips();
|
updateTooltips();
|
||||||
|
|
||||||
//Handle fading and deactivation/activation of UI
|
//Handle fading and deactivation/activation of UI
|
||||||
doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
||||||
|
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ void ApplicationCompositor::displayOverlayTextureHmd(RenderArgs* renderArgs, int
|
||||||
|
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
|
||||||
doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
||||||
geometryCache->useSimpleDrawPipeline(batch);
|
geometryCache->useSimpleDrawPipeline(batch);
|
||||||
|
|
||||||
batch.setResourceTexture(0, overlayFramebuffer->getRenderBuffer(0));
|
batch.setResourceTexture(0, overlayFramebuffer->getRenderBuffer(0));
|
||||||
|
|
|
@ -70,29 +70,28 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the batch into our framebuffer
|
// Execute the batch into our framebuffer
|
||||||
gpu::Batch batch;
|
doInBatch(renderArgs->_context, [=](gpu::Batch& batch) {
|
||||||
renderArgs->_batch = &batch;
|
renderArgs->_batch = &batch;
|
||||||
|
|
||||||
int width = _overlayFramebuffer->getWidth();
|
int width = _overlayFramebuffer->getWidth();
|
||||||
int height = _overlayFramebuffer->getHeight();
|
int height = _overlayFramebuffer->getHeight();
|
||||||
|
|
||||||
batch.setViewportTransform(glm::ivec4(0, 0, width, height));
|
batch.setViewportTransform(glm::ivec4(0, 0, width, height));
|
||||||
batch.setFramebuffer(_overlayFramebuffer);
|
batch.setFramebuffer(_overlayFramebuffer);
|
||||||
|
|
||||||
glm::vec4 color { 0.0f, 0.0f, 0.0f, 0.0f };
|
glm::vec4 color { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
float depth = 1.0f;
|
float depth = 1.0f;
|
||||||
int stencil = 0;
|
int stencil = 0;
|
||||||
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH, color, depth, stencil);
|
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH, color, depth, stencil);
|
||||||
|
|
||||||
// Now render the overlay components together into a single texture
|
// Now render the overlay components together into a single texture
|
||||||
renderDomainConnectionStatusBorder(renderArgs); // renders the connected domain line
|
renderDomainConnectionStatusBorder(renderArgs); // renders the connected domain line
|
||||||
renderAudioScope(renderArgs); // audio scope in the very back
|
renderAudioScope(renderArgs); // audio scope in the very back
|
||||||
renderRearView(renderArgs); // renders the mirror view selfie
|
renderRearView(renderArgs); // renders the mirror view selfie
|
||||||
renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
|
renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
|
||||||
renderOverlays(renderArgs); // renders Scripts Overlay and AudioScope
|
renderOverlays(renderArgs); // renders Scripts Overlay and AudioScope
|
||||||
renderStatsAndLogs(renderArgs); // currently renders nothing
|
renderStatsAndLogs(renderArgs); // currently renders nothing
|
||||||
|
});
|
||||||
renderArgs->_context->render(batch);
|
|
||||||
|
|
||||||
renderArgs->_batch = nullptr; // so future users of renderArgs don't try to use our batch
|
renderArgs->_batch = nullptr; // so future users of renderArgs don't try to use our batch
|
||||||
|
|
||||||
|
|
|
@ -215,8 +215,6 @@ protected:
|
||||||
};
|
};
|
||||||
typedef std::shared_ptr<Context> ContextPointer;
|
typedef std::shared_ptr<Context> ContextPointer;
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void doInBatch(std::shared_ptr<gpu::Context> context, F f) {
|
void doInBatch(std::shared_ptr<gpu::Context> context, F f) {
|
||||||
static gpu::Batch::CacheState cacheState;
|
static gpu::Batch::CacheState cacheState;
|
||||||
|
@ -226,4 +224,7 @@ void doInBatch(std::shared_ptr<gpu::Context> context, F f) {
|
||||||
cacheState = batch.getCacheState();
|
cacheState = batch.getCacheState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -173,7 +173,7 @@ void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePoint
|
||||||
UserInputMapper::PoseValue leftHand = _poseStateMap[makeInput(JointChannel::LEFT_HAND).getChannel()];
|
UserInputMapper::PoseValue leftHand = _poseStateMap[makeInput(JointChannel::LEFT_HAND).getChannel()];
|
||||||
UserInputMapper::PoseValue rightHand = _poseStateMap[makeInput(JointChannel::RIGHT_HAND).getChannel()];
|
UserInputMapper::PoseValue rightHand = _poseStateMap[makeInput(JointChannel::RIGHT_HAND).getChannel()];
|
||||||
|
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
geometryCache->useSimpleDrawPipeline(batch);
|
geometryCache->useSimpleDrawPipeline(batch);
|
||||||
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, true);
|
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch, true);
|
||||||
|
|
|
@ -179,7 +179,7 @@ void AmbientOcclusion::run(const render::SceneContextPointer& sceneContext, cons
|
||||||
assert(renderContext->args->_viewFrustum);
|
assert(renderContext->args->_viewFrustum);
|
||||||
|
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||||
QSize framebufferSize = framebufferCache->getFrameBufferSize();
|
QSize framebufferSize = framebufferCache->getFrameBufferSize();
|
||||||
float fbWidth = framebufferSize.width();
|
float fbWidth = framebufferSize.width();
|
||||||
|
|
|
@ -101,7 +101,7 @@ void Antialiasing::run(const render::SceneContextPointer& sceneContext, const re
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
|
|
||||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||||
|
|
|
@ -340,7 +340,7 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredLightingEffect::prepare(RenderArgs* args) {
|
void DeferredLightingEffect::prepare(RenderArgs* args) {
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.setStateScissorRect(args->_viewport);
|
batch.setStateScissorRect(args->_viewport);
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ void DeferredLightingEffect::prepare(RenderArgs* args) {
|
||||||
gpu::FramebufferPointer _copyFBO;
|
gpu::FramebufferPointer _copyFBO;
|
||||||
|
|
||||||
void DeferredLightingEffect::render(RenderArgs* args) {
|
void DeferredLightingEffect::render(RenderArgs* args) {
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
|
|
||||||
// Allocate the parameters buffer used by all the deferred shaders
|
// Allocate the parameters buffer used by all the deferred shaders
|
||||||
if (!_deferredTransformBuffer[0]._buffer) {
|
if (!_deferredTransformBuffer[0]._buffer) {
|
||||||
|
@ -685,7 +685,7 @@ void DeferredLightingEffect::render(RenderArgs* args) {
|
||||||
|
|
||||||
void DeferredLightingEffect::copyBack(RenderArgs* args) {
|
void DeferredLightingEffect::copyBack(RenderArgs* args) {
|
||||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
QSize framebufferSize = framebufferCache->getFrameBufferSize();
|
QSize framebufferSize = framebufferCache->getFrameBufferSize();
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ void HitEffect::run(const render::SceneContextPointer& sceneContext, const rende
|
||||||
assert(renderContext->args);
|
assert(renderContext->args);
|
||||||
assert(renderContext->args->_viewFrustum);
|
assert(renderContext->args->_viewFrustum);
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
|
|
||||||
glm::mat4 projMat;
|
glm::mat4 projMat;
|
||||||
Transform viewMat;
|
Transform viewMat;
|
||||||
|
|
|
@ -1272,6 +1272,8 @@ void Model::simulateInternal(float deltaTime) {
|
||||||
updateRig(deltaTime, parentTransform);
|
updateRig(deltaTime, parentTransform);
|
||||||
}
|
}
|
||||||
void Model::updateClusterMatrices() {
|
void Model::updateClusterMatrices() {
|
||||||
|
PerformanceTimer perfTimer("Model::updateClusterMatrices");
|
||||||
|
|
||||||
if (!_needsUpdateClusterMatrices) {
|
if (!_needsUpdateClusterMatrices) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1528,6 +1530,7 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape
|
||||||
|
|
||||||
{
|
{
|
||||||
if (!_showTrueJointTransforms) {
|
if (!_showTrueJointTransforms) {
|
||||||
|
PerformanceTimer perfTimer("_rig->updateVisibleJointStates()");
|
||||||
_rig->updateVisibleJointStates();
|
_rig->updateVisibleJointStates();
|
||||||
} // else no need to update visible transforms
|
} // else no need to update visible transforms
|
||||||
}
|
}
|
||||||
|
@ -1692,6 +1695,8 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape
|
||||||
|
|
||||||
// TODO: We should be able to do that just in the renderTransparentJob
|
// TODO: We should be able to do that just in the renderTransparentJob
|
||||||
if (translucentMesh && locations->lightBufferUnit >= 0) {
|
if (translucentMesh && locations->lightBufferUnit >= 0) {
|
||||||
|
PerformanceTimer perfTimer("DLE->setupTransparent()");
|
||||||
|
|
||||||
DependencyManager::get<DeferredLightingEffect>()->setupTransparent(args, locations->lightBufferUnit);
|
DependencyManager::get<DeferredLightingEffect>()->setupTransparent(args, locations->lightBufferUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1702,8 +1707,11 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.setIndexBuffer(gpu::UINT32, part.getMergedTriangles(), 0);
|
{
|
||||||
batch.drawIndexed(gpu::TRIANGLES, part.mergedTrianglesIndicesCount, 0);
|
PerformanceTimer perfTimer("batch.drawIndexed()");
|
||||||
|
batch.setIndexBuffer(gpu::UINT32, part.getMergedTriangles(), 0);
|
||||||
|
batch.drawIndexed(gpu::TRIANGLES, part.mergedTrianglesIndicesCount, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (args) {
|
if (args) {
|
||||||
const int INDICES_PER_TRIANGLE = 3;
|
const int INDICES_PER_TRIANGLE = 3;
|
||||||
|
@ -1743,6 +1751,9 @@ void Model::pickPrograms(gpu::Batch& batch, RenderMode mode, bool translucent, f
|
||||||
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, bool isWireframe, RenderArgs* args,
|
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, bool isWireframe, RenderArgs* args,
|
||||||
Locations*& locations) {
|
Locations*& locations) {
|
||||||
|
|
||||||
|
PerformanceTimer perfTimer("Model::pickPrograms");
|
||||||
|
|
||||||
|
|
||||||
RenderKey key(mode, translucent, alphaThreshold, hasLightmap, hasTangents, hasSpecular, isSkinned, isWireframe);
|
RenderKey key(mode, translucent, alphaThreshold, hasLightmap, hasTangents, hasSpecular, isSkinned, isWireframe);
|
||||||
if (mode == RenderArgs::MIRROR_RENDER_MODE) {
|
if (mode == RenderArgs::MIRROR_RENDER_MODE) {
|
||||||
key = RenderKey(key.getRaw() | RenderKey::IS_MIRROR);
|
key = RenderKey(key.getRaw() | RenderKey::IS_MIRROR);
|
||||||
|
|
|
@ -32,7 +32,7 @@ using namespace render;
|
||||||
|
|
||||||
void SetupDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
void SetupDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
|
|
||||||
auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
|
auto primaryFbo = DependencyManager::get<FramebufferCache>()->getPrimaryFramebufferDepthColor();
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ void DrawOpaqueDeferred::run(const SceneContextPointer& sceneContext, const Rend
|
||||||
assert(renderContext->args->_viewFrustum);
|
assert(renderContext->args->_viewFrustum);
|
||||||
|
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
batch.setViewportTransform(args->_viewport);
|
batch.setViewportTransform(args->_viewport);
|
||||||
batch.setStateScissorRect(args->_viewport);
|
batch.setStateScissorRect(args->_viewport);
|
||||||
args->_batch = &batch;
|
args->_batch = &batch;
|
||||||
|
@ -195,7 +195,7 @@ void DrawTransparentDeferred::run(const SceneContextPointer& sceneContext, const
|
||||||
assert(renderContext->args->_viewFrustum);
|
assert(renderContext->args->_viewFrustum);
|
||||||
|
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
batch.setViewportTransform(args->_viewport);
|
batch.setViewportTransform(args->_viewport);
|
||||||
batch.setStateScissorRect(args->_viewport);
|
batch.setStateScissorRect(args->_viewport);
|
||||||
args->_batch = &batch;
|
args->_batch = &batch;
|
||||||
|
@ -267,7 +267,7 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the items
|
// Render the items
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
args->_batch = &batch;
|
args->_batch = &batch;
|
||||||
args->_whiteTexture = DependencyManager::get<TextureCache>()->getWhiteTexture();
|
args->_whiteTexture = DependencyManager::get<TextureCache>()->getWhiteTexture();
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ void DrawStatus::run(const SceneContextPointer& sceneContext, const RenderContex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allright, something to render let's do it
|
// Allright, something to render let's do it
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
glm::mat4 projMat;
|
glm::mat4 projMat;
|
||||||
Transform viewMat;
|
Transform viewMat;
|
||||||
args->_viewFrustum->evalProjectionMatrix(projMat);
|
args->_viewFrustum->evalProjectionMatrix(projMat);
|
||||||
|
|
|
@ -236,7 +236,7 @@ void DrawLight::run(const SceneContextPointer& sceneContext, const RenderContext
|
||||||
cullItems(sceneContext, renderContext, inItems, culledItems);
|
cullItems(sceneContext, renderContext, inItems, culledItems);
|
||||||
|
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
args->_batch = &batch;
|
args->_batch = &batch;
|
||||||
renderItems(sceneContext, renderContext, culledItems);
|
renderItems(sceneContext, renderContext, culledItems);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue