mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Restoring preview and removing excessive GL state sync
This commit is contained in:
parent
c6848a1b55
commit
9cd1d69f1e
2 changed files with 36 additions and 26 deletions
|
@ -386,7 +386,6 @@ void OpenGLDisplayPlugin::customizeContext() {
|
|||
auto renderSize = getRecommendedRenderSize();
|
||||
_compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create(gpu::Element::COLOR_RGBA_32, renderSize.x, renderSize.y));
|
||||
_compositeTexture = _compositeFramebuffer->getRenderBuffer(0);
|
||||
|
||||
}
|
||||
|
||||
void OpenGLDisplayPlugin::uncustomizeContext() {
|
||||
|
@ -545,6 +544,7 @@ void OpenGLDisplayPlugin::compositeLayers() {
|
|||
PROFILE_RANGE_EX("compositeScene", 0xff0077ff, (uint64_t)presentCount())
|
||||
compositeScene();
|
||||
}
|
||||
|
||||
{
|
||||
PROFILE_RANGE_EX("compositeOverlay", 0xff0077ff, (uint64_t)presentCount())
|
||||
compositeOverlay();
|
||||
|
@ -554,6 +554,7 @@ void OpenGLDisplayPlugin::compositeLayers() {
|
|||
PROFILE_RANGE_EX("compositePointer", 0xff0077ff, (uint64_t)presentCount())
|
||||
compositePointer();
|
||||
}
|
||||
|
||||
{
|
||||
PROFILE_RANGE_EX("compositeExtra", 0xff0077ff, (uint64_t)presentCount())
|
||||
compositeExtra();
|
||||
|
@ -579,7 +580,6 @@ void OpenGLDisplayPlugin::present() {
|
|||
|
||||
incrementPresentCount();
|
||||
if (_currentFrame) {
|
||||
_backend->syncCache();
|
||||
_backend->setStereoState(_currentFrame->stereoState);
|
||||
{
|
||||
PROFILE_RANGE_EX("execute", 0xff00ff00, (uint64_t)presentCount())
|
||||
|
@ -587,7 +587,6 @@ void OpenGLDisplayPlugin::present() {
|
|||
for (auto& batch : _currentFrame->batches) {
|
||||
_backend->render(batch);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Write all layers to a local framebuffer
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2016/02/15
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
|
@ -124,10 +124,7 @@ void HmdDisplayPlugin::uncustomizeContext() {
|
|||
void HmdDisplayPlugin::internalPresent() {
|
||||
PROFILE_RANGE_EX(__FUNCTION__, 0xff00ff00, (uint64_t)presentCount())
|
||||
|
||||
// Composite together the scene, overlay and mouse cursor
|
||||
hmdPresent();
|
||||
|
||||
if (false && _enablePreview) {
|
||||
if (_enablePreview) {
|
||||
// screen preview mirroring
|
||||
auto window = _container->getPrimaryWidget();
|
||||
auto devicePixelRatio = window->devicePixelRatio();
|
||||
|
@ -154,25 +151,39 @@ void HmdDisplayPlugin::internalPresent() {
|
|||
targetViewportPosition.y = (windowSize.y - targetViewportSize.y) / 2;
|
||||
}
|
||||
|
||||
render([&](gpu::Batch& batch) {
|
||||
batch.enableStereo(false);
|
||||
batch.clearViewTransform();
|
||||
batch.setFramebuffer(gpu::FramebufferPointer());
|
||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(0));
|
||||
batch.setViewportTransform(ivec4(uvec2(0), windowSize));
|
||||
if (_monoPreview) {
|
||||
batch.setStateScissorRect(ivec4(targetViewportPosition, targetViewportSize));
|
||||
targetViewportSize.x *= 2;
|
||||
batch.setViewportTransform(ivec4(targetViewportPosition, targetViewportSize));
|
||||
} else {
|
||||
batch.setStateScissorRect(ivec4(targetViewportPosition, targetViewportSize));
|
||||
batch.setViewportTransform(ivec4(targetViewportPosition, targetViewportSize));
|
||||
}
|
||||
batch.setResourceTexture(0, _compositeTexture);
|
||||
batch.setPipeline(_presentPipeline);
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
});
|
||||
if (_currentFrame && _currentFrame->framebuffer) {
|
||||
render([&](gpu::Batch& batch) {
|
||||
batch.enableStereo(false);
|
||||
batch.clearViewTransform();
|
||||
batch.setFramebuffer(gpu::FramebufferPointer());
|
||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(0));
|
||||
batch.setViewportTransform(ivec4(uvec2(0), windowSize));
|
||||
if (_monoPreview) {
|
||||
batch.setStateScissorRect(ivec4(targetViewportPosition, targetViewportSize));
|
||||
targetViewportSize.x *= 2;
|
||||
batch.setViewportTransform(ivec4(targetViewportPosition, targetViewportSize));
|
||||
} else {
|
||||
batch.setStateScissorRect(ivec4(targetViewportPosition, targetViewportSize));
|
||||
batch.setViewportTransform(ivec4(targetViewportPosition, targetViewportSize));
|
||||
}
|
||||
batch.setResourceTexture(0, _compositeTexture);
|
||||
batch.setPipeline(_presentPipeline);
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Composite together the scene, overlay and mouse cursor
|
||||
hmdPresent();
|
||||
|
||||
if (_enablePreview) {
|
||||
glFinish();
|
||||
auto startSwapTime = usecTimestampNow();
|
||||
swapBuffers();
|
||||
auto swapTime = usecTimestampNow() - startSwapTime;
|
||||
if (swapTime > USECS_PER_MSEC) {
|
||||
qDebug() << "Swap took " << swapTime << " us";
|
||||
}
|
||||
}
|
||||
|
||||
postPreview();
|
||||
|
|
Loading…
Reference in a new issue