mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:56:25 +02:00
Merge pull request #11466 from SamGondelman/mirrorCrash
Fix mirror and fade threading crashes
This commit is contained in:
commit
287f4f1d71
6 changed files with 50 additions and 41 deletions
|
@ -198,6 +198,8 @@
|
||||||
#include <raypick/RayPickScriptingInterface.h>
|
#include <raypick/RayPickScriptingInterface.h>
|
||||||
#include <raypick/LaserPointerScriptingInterface.h>
|
#include <raypick/LaserPointerScriptingInterface.h>
|
||||||
|
|
||||||
|
#include <FadeEffect.h>
|
||||||
|
|
||||||
#include "commerce/Ledger.h"
|
#include "commerce/Ledger.h"
|
||||||
#include "commerce/Wallet.h"
|
#include "commerce/Wallet.h"
|
||||||
#include "commerce/QmlCommerce.h"
|
#include "commerce/QmlCommerce.h"
|
||||||
|
@ -682,6 +684,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
||||||
DependencyManager::set<Ledger>();
|
DependencyManager::set<Ledger>();
|
||||||
DependencyManager::set<Wallet>();
|
DependencyManager::set<Wallet>();
|
||||||
|
|
||||||
|
DependencyManager::set<FadeEffect>();
|
||||||
|
|
||||||
DependencyManager::set<LaserPointerScriptingInterface>();
|
DependencyManager::set<LaserPointerScriptingInterface>();
|
||||||
DependencyManager::set<RayPickScriptingInterface>();
|
DependencyManager::set<RayPickScriptingInterface>();
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
using RenderArgsPointer = std::shared_ptr<RenderArgs>;
|
using RenderArgsPointer = std::shared_ptr<RenderArgs>;
|
||||||
|
|
||||||
void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) {
|
void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) {
|
||||||
|
|
||||||
task.addJob<RenderShadowTask>("RenderShadowTask", cullFunctor);
|
task.addJob<RenderShadowTask>("RenderShadowTask", cullFunctor);
|
||||||
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor);
|
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor);
|
||||||
assert(items.canCast<RenderFetchCullSortTask::Output>());
|
assert(items.canCast<RenderFetchCullSortTask::Output>());
|
||||||
|
@ -30,14 +29,6 @@ void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render
|
||||||
}
|
}
|
||||||
|
|
||||||
class SecondaryCameraJob { // Changes renderContext for our framebuffer and view.
|
class SecondaryCameraJob { // Changes renderContext for our framebuffer and view.
|
||||||
QUuid _attachedEntityId{};
|
|
||||||
glm::vec3 _position{};
|
|
||||||
glm::quat _orientation{};
|
|
||||||
float _vFoV{};
|
|
||||||
float _nearClipPlaneDistance{};
|
|
||||||
float _farClipPlaneDistance{};
|
|
||||||
EntityPropertyFlags _attachedEntityPropertyFlags;
|
|
||||||
QSharedPointer<EntityScriptingInterface> _entityScriptingInterface;
|
|
||||||
public:
|
public:
|
||||||
using Config = SecondaryCameraJobConfig;
|
using Config = SecondaryCameraJobConfig;
|
||||||
using JobModel = render::Job::ModelO<SecondaryCameraJob, RenderArgsPointer, Config>;
|
using JobModel = render::Job::ModelO<SecondaryCameraJob, RenderArgsPointer, Config>;
|
||||||
|
@ -55,13 +46,15 @@ public:
|
||||||
_vFoV = config.vFoV;
|
_vFoV = config.vFoV;
|
||||||
_nearClipPlaneDistance = config.nearClipPlaneDistance;
|
_nearClipPlaneDistance = config.nearClipPlaneDistance;
|
||||||
_farClipPlaneDistance = config.farClipPlaneDistance;
|
_farClipPlaneDistance = config.farClipPlaneDistance;
|
||||||
|
_textureWidth = config.textureWidth;
|
||||||
|
_textureHeight = config.textureHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(const render::RenderContextPointer& renderContext, RenderArgsPointer& cachedArgs) {
|
void run(const render::RenderContextPointer& renderContext, RenderArgsPointer& cachedArgs) {
|
||||||
auto args = renderContext->args;
|
auto args = renderContext->args;
|
||||||
auto textureCache = DependencyManager::get<TextureCache>();
|
auto textureCache = DependencyManager::get<TextureCache>();
|
||||||
gpu::FramebufferPointer destFramebuffer;
|
gpu::FramebufferPointer destFramebuffer;
|
||||||
destFramebuffer = textureCache->getSpectatorCameraFramebuffer(); // FIXME: Change the destination based on some unimplemented config var
|
destFramebuffer = textureCache->getSpectatorCameraFramebuffer(_textureWidth, _textureHeight); // FIXME: Change the destination based on some unimplemented config var
|
||||||
if (destFramebuffer) {
|
if (destFramebuffer) {
|
||||||
_cachedArgsPointer->_blitFramebuffer = args->_blitFramebuffer;
|
_cachedArgsPointer->_blitFramebuffer = args->_blitFramebuffer;
|
||||||
_cachedArgsPointer->_viewport = args->_viewport;
|
_cachedArgsPointer->_viewport = args->_viewport;
|
||||||
|
@ -98,6 +91,18 @@ public:
|
||||||
protected:
|
protected:
|
||||||
RenderArgs _cachedArgs;
|
RenderArgs _cachedArgs;
|
||||||
RenderArgsPointer _cachedArgsPointer;
|
RenderArgsPointer _cachedArgsPointer;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QUuid _attachedEntityId;
|
||||||
|
glm::vec3 _position;
|
||||||
|
glm::quat _orientation;
|
||||||
|
float _vFoV;
|
||||||
|
float _nearClipPlaneDistance;
|
||||||
|
float _farClipPlaneDistance;
|
||||||
|
int _textureWidth;
|
||||||
|
int _textureHeight;
|
||||||
|
EntityPropertyFlags _attachedEntityPropertyFlags;
|
||||||
|
QSharedPointer<EntityScriptingInterface> _entityScriptingInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SecondaryCameraJobConfig::setPosition(glm::vec3 pos) {
|
void SecondaryCameraJobConfig::setPosition(glm::vec3 pos) {
|
||||||
|
@ -123,16 +128,10 @@ void SecondaryCameraJobConfig::enableSecondaryCameraRenderConfigs(bool enabled)
|
||||||
setEnabled(enabled);
|
setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecondaryCameraJobConfig::resetSizeSpectatorCamera(int width, int height) { // Carefully adjust the framebuffer / texture.
|
void SecondaryCameraJobConfig::resetSizeSpectatorCamera(int width, int height) {
|
||||||
qApp->getRenderEngine()->getConfiguration()->getConfig<SecondaryCameraRenderTask>()->resetSize(width, height);
|
textureWidth = width;
|
||||||
}
|
textureHeight = height;
|
||||||
|
emit dirty();
|
||||||
void SecondaryCameraRenderTaskConfig::resetSize(int width, int height) { // FIXME: Add an arg here for "destinationFramebuffer"
|
|
||||||
bool wasEnabled = isEnabled();
|
|
||||||
setEnabled(false);
|
|
||||||
auto textureCache = DependencyManager::get<TextureCache>();
|
|
||||||
textureCache->resetSpectatorCameraFramebuffer(width, height); // FIXME: Call the correct reset function based on the "destinationFramebuffer" arg
|
|
||||||
setEnabled(wasEnabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class EndSecondaryCameraFrame { // Restores renderContext.
|
class EndSecondaryCameraFrame { // Restores renderContext.
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <RenderDeferredTask.h>
|
#include <RenderDeferredTask.h>
|
||||||
#include <RenderForwardTask.h>
|
#include <RenderForwardTask.h>
|
||||||
|
|
||||||
|
|
||||||
class MainRenderTask {
|
class MainRenderTask {
|
||||||
public:
|
public:
|
||||||
using JobModel = render::Task::Model<MainRenderTask>;
|
using JobModel = render::Task::Model<MainRenderTask>;
|
||||||
|
@ -37,12 +36,15 @@ class SecondaryCameraJobConfig : public render::Task::Config { // Exposes second
|
||||||
Q_PROPERTY(float nearClipPlaneDistance MEMBER nearClipPlaneDistance NOTIFY dirty) // Secondary camera's near clip plane distance. In meters.
|
Q_PROPERTY(float nearClipPlaneDistance MEMBER nearClipPlaneDistance NOTIFY dirty) // Secondary camera's near clip plane distance. In meters.
|
||||||
Q_PROPERTY(float farClipPlaneDistance MEMBER farClipPlaneDistance NOTIFY dirty) // Secondary camera's far clip plane distance. In meters.
|
Q_PROPERTY(float farClipPlaneDistance MEMBER farClipPlaneDistance NOTIFY dirty) // Secondary camera's far clip plane distance. In meters.
|
||||||
public:
|
public:
|
||||||
QUuid attachedEntityId{};
|
QUuid attachedEntityId;
|
||||||
glm::vec3 position{};
|
glm::vec3 position;
|
||||||
glm::quat orientation{};
|
glm::quat orientation;
|
||||||
float vFoV{ DEFAULT_FIELD_OF_VIEW_DEGREES };
|
float vFoV { DEFAULT_FIELD_OF_VIEW_DEGREES };
|
||||||
float nearClipPlaneDistance{ DEFAULT_NEAR_CLIP };
|
float nearClipPlaneDistance { DEFAULT_NEAR_CLIP };
|
||||||
float farClipPlaneDistance{ DEFAULT_FAR_CLIP };
|
float farClipPlaneDistance { DEFAULT_FAR_CLIP };
|
||||||
|
int textureWidth { TextureCache::DEFAULT_SPECTATOR_CAM_WIDTH };
|
||||||
|
int textureHeight { TextureCache::DEFAULT_SPECTATOR_CAM_HEIGHT };
|
||||||
|
|
||||||
SecondaryCameraJobConfig() : render::Task::Config(false) {}
|
SecondaryCameraJobConfig() : render::Task::Config(false) {}
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
@ -59,9 +61,6 @@ class SecondaryCameraRenderTaskConfig : public render::Task::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SecondaryCameraRenderTaskConfig() : render::Task::Config(false) {}
|
SecondaryCameraRenderTaskConfig() : render::Task::Config(false) {}
|
||||||
void resetSize(int width, int height);
|
|
||||||
signals:
|
|
||||||
void dirty();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SecondaryCameraRenderTask {
|
class SecondaryCameraRenderTask {
|
||||||
|
|
|
@ -1003,6 +1003,7 @@ NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl)
|
||||||
if (_spectatorCameraFramebuffer) {
|
if (_spectatorCameraFramebuffer) {
|
||||||
texture = _spectatorCameraFramebuffer->getRenderBuffer(0);
|
texture = _spectatorCameraFramebuffer->getRenderBuffer(0);
|
||||||
if (texture) {
|
if (texture) {
|
||||||
|
texture->setSource(SPECTATOR_CAMERA_FRAME_URL.toString().toStdString());
|
||||||
_spectatorCameraNetworkTexture->setImage(texture, texture->getWidth(), texture->getHeight());
|
_spectatorCameraNetworkTexture->setImage(texture, texture->getWidth(), texture->getHeight());
|
||||||
return _spectatorCameraNetworkTexture;
|
return _spectatorCameraNetworkTexture;
|
||||||
}
|
}
|
||||||
|
@ -1016,6 +1017,7 @@ NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl)
|
||||||
if (_hmdPreviewFramebuffer) {
|
if (_hmdPreviewFramebuffer) {
|
||||||
texture = _hmdPreviewFramebuffer->getRenderBuffer(0);
|
texture = _hmdPreviewFramebuffer->getRenderBuffer(0);
|
||||||
if (texture) {
|
if (texture) {
|
||||||
|
texture->setSource(HMD_PREVIEW_FRAME_URL.toString().toStdString());
|
||||||
_hmdPreviewNetworkTexture->setImage(texture, texture->getWidth(), texture->getHeight());
|
_hmdPreviewNetworkTexture->setImage(texture, texture->getWidth(), texture->getHeight());
|
||||||
return _hmdPreviewNetworkTexture;
|
return _hmdPreviewNetworkTexture;
|
||||||
}
|
}
|
||||||
|
@ -1033,14 +1035,18 @@ const gpu::FramebufferPointer& TextureCache::getHmdPreviewFramebuffer(int width,
|
||||||
}
|
}
|
||||||
|
|
||||||
const gpu::FramebufferPointer& TextureCache::getSpectatorCameraFramebuffer() {
|
const gpu::FramebufferPointer& TextureCache::getSpectatorCameraFramebuffer() {
|
||||||
|
// If we're taking a screenshot and the spectator cam buffer hasn't been created yet, reset to the default size
|
||||||
if (!_spectatorCameraFramebuffer) {
|
if (!_spectatorCameraFramebuffer) {
|
||||||
resetSpectatorCameraFramebuffer(2048, 1024);
|
return getSpectatorCameraFramebuffer(DEFAULT_SPECTATOR_CAM_WIDTH, DEFAULT_SPECTATOR_CAM_HEIGHT);
|
||||||
}
|
}
|
||||||
return _spectatorCameraFramebuffer;
|
return _spectatorCameraFramebuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::resetSpectatorCameraFramebuffer(int width, int height) {
|
const gpu::FramebufferPointer& TextureCache::getSpectatorCameraFramebuffer(int width, int height) {
|
||||||
_spectatorCameraFramebuffer.reset(gpu::Framebuffer::create("spectatorCamera", gpu::Element::COLOR_SRGBA_32, width, height));
|
// If we aren't taking a screenshot, we might need to resize or create the camera buffer
|
||||||
_spectatorCameraNetworkTexture.reset();
|
if (!_spectatorCameraFramebuffer || _spectatorCameraFramebuffer->getWidth() != width || _spectatorCameraFramebuffer->getHeight() != height) {
|
||||||
emit spectatorCameraFramebufferReset();
|
_spectatorCameraFramebuffer.reset(gpu::Framebuffer::create("spectatorCamera", gpu::Element::COLOR_SRGBA_32, width, height));
|
||||||
|
emit spectatorCameraFramebufferReset();
|
||||||
|
}
|
||||||
|
return _spectatorCameraFramebuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,12 +167,13 @@ public:
|
||||||
gpu::TexturePointer getTextureByHash(const std::string& hash);
|
gpu::TexturePointer getTextureByHash(const std::string& hash);
|
||||||
gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
|
gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
|
||||||
|
|
||||||
|
|
||||||
/// SpectatorCamera rendering targets.
|
|
||||||
NetworkTexturePointer getResourceTexture(QUrl resourceTextureUrl);
|
NetworkTexturePointer getResourceTexture(QUrl resourceTextureUrl);
|
||||||
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer();
|
|
||||||
void resetSpectatorCameraFramebuffer(int width, int height);
|
|
||||||
const gpu::FramebufferPointer& getHmdPreviewFramebuffer(int width, int height);
|
const gpu::FramebufferPointer& getHmdPreviewFramebuffer(int width, int height);
|
||||||
|
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer();
|
||||||
|
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer(int width, int height);
|
||||||
|
|
||||||
|
static const int DEFAULT_SPECTATOR_CAM_WIDTH { 2048 };
|
||||||
|
static const int DEFAULT_SPECTATOR_CAM_HEIGHT { 1024 };
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void spectatorCameraFramebufferReset();
|
void spectatorCameraFramebufferReset();
|
||||||
|
|
|
@ -49,8 +49,8 @@ using namespace render;
|
||||||
extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false);
|
extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false);
|
||||||
extern void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter);
|
extern void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter);
|
||||||
|
|
||||||
RenderDeferredTask::RenderDeferredTask() {
|
RenderDeferredTask::RenderDeferredTask()
|
||||||
DependencyManager::set<FadeEffect>();
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderDeferredTask::configure(const Config& config)
|
void RenderDeferredTask::configure(const Config& config)
|
||||||
|
|
Loading…
Reference in a new issue