mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 21:33:00 +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/LaserPointerScriptingInterface.h>
|
||||
|
||||
#include <FadeEffect.h>
|
||||
|
||||
#include "commerce/Ledger.h"
|
||||
#include "commerce/Wallet.h"
|
||||
#include "commerce/QmlCommerce.h"
|
||||
|
@ -682,6 +684,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
|||
DependencyManager::set<Ledger>();
|
||||
DependencyManager::set<Wallet>();
|
||||
|
||||
DependencyManager::set<FadeEffect>();
|
||||
|
||||
DependencyManager::set<LaserPointerScriptingInterface>();
|
||||
DependencyManager::set<RayPickScriptingInterface>();
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
using RenderArgsPointer = std::shared_ptr<RenderArgs>;
|
||||
|
||||
void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) {
|
||||
|
||||
task.addJob<RenderShadowTask>("RenderShadowTask", cullFunctor);
|
||||
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor);
|
||||
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.
|
||||
QUuid _attachedEntityId{};
|
||||
glm::vec3 _position{};
|
||||
glm::quat _orientation{};
|
||||
float _vFoV{};
|
||||
float _nearClipPlaneDistance{};
|
||||
float _farClipPlaneDistance{};
|
||||
EntityPropertyFlags _attachedEntityPropertyFlags;
|
||||
QSharedPointer<EntityScriptingInterface> _entityScriptingInterface;
|
||||
public:
|
||||
using Config = SecondaryCameraJobConfig;
|
||||
using JobModel = render::Job::ModelO<SecondaryCameraJob, RenderArgsPointer, Config>;
|
||||
|
@ -55,13 +46,15 @@ public:
|
|||
_vFoV = config.vFoV;
|
||||
_nearClipPlaneDistance = config.nearClipPlaneDistance;
|
||||
_farClipPlaneDistance = config.farClipPlaneDistance;
|
||||
_textureWidth = config.textureWidth;
|
||||
_textureHeight = config.textureHeight;
|
||||
}
|
||||
|
||||
void run(const render::RenderContextPointer& renderContext, RenderArgsPointer& cachedArgs) {
|
||||
auto args = renderContext->args;
|
||||
auto textureCache = DependencyManager::get<TextureCache>();
|
||||
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) {
|
||||
_cachedArgsPointer->_blitFramebuffer = args->_blitFramebuffer;
|
||||
_cachedArgsPointer->_viewport = args->_viewport;
|
||||
|
@ -98,6 +91,18 @@ public:
|
|||
protected:
|
||||
RenderArgs _cachedArgs;
|
||||
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) {
|
||||
|
@ -123,16 +128,10 @@ void SecondaryCameraJobConfig::enableSecondaryCameraRenderConfigs(bool enabled)
|
|||
setEnabled(enabled);
|
||||
}
|
||||
|
||||
void SecondaryCameraJobConfig::resetSizeSpectatorCamera(int width, int height) { // Carefully adjust the framebuffer / texture.
|
||||
qApp->getRenderEngine()->getConfiguration()->getConfig<SecondaryCameraRenderTask>()->resetSize(width, height);
|
||||
}
|
||||
|
||||
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);
|
||||
void SecondaryCameraJobConfig::resetSizeSpectatorCamera(int width, int height) {
|
||||
textureWidth = width;
|
||||
textureHeight = height;
|
||||
emit dirty();
|
||||
}
|
||||
|
||||
class EndSecondaryCameraFrame { // Restores renderContext.
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <RenderDeferredTask.h>
|
||||
#include <RenderForwardTask.h>
|
||||
|
||||
|
||||
class MainRenderTask {
|
||||
public:
|
||||
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 farClipPlaneDistance MEMBER farClipPlaneDistance NOTIFY dirty) // Secondary camera's far clip plane distance. In meters.
|
||||
public:
|
||||
QUuid attachedEntityId{};
|
||||
glm::vec3 position{};
|
||||
glm::quat orientation{};
|
||||
float vFoV{ DEFAULT_FIELD_OF_VIEW_DEGREES };
|
||||
float nearClipPlaneDistance{ DEFAULT_NEAR_CLIP };
|
||||
float farClipPlaneDistance{ DEFAULT_FAR_CLIP };
|
||||
QUuid attachedEntityId;
|
||||
glm::vec3 position;
|
||||
glm::quat orientation;
|
||||
float vFoV { DEFAULT_FIELD_OF_VIEW_DEGREES };
|
||||
float nearClipPlaneDistance { DEFAULT_NEAR_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) {}
|
||||
signals:
|
||||
void dirty();
|
||||
|
@ -59,9 +61,6 @@ class SecondaryCameraRenderTaskConfig : public render::Task::Config {
|
|||
Q_OBJECT
|
||||
public:
|
||||
SecondaryCameraRenderTaskConfig() : render::Task::Config(false) {}
|
||||
void resetSize(int width, int height);
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
|
||||
class SecondaryCameraRenderTask {
|
||||
|
|
|
@ -1003,6 +1003,7 @@ NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl)
|
|||
if (_spectatorCameraFramebuffer) {
|
||||
texture = _spectatorCameraFramebuffer->getRenderBuffer(0);
|
||||
if (texture) {
|
||||
texture->setSource(SPECTATOR_CAMERA_FRAME_URL.toString().toStdString());
|
||||
_spectatorCameraNetworkTexture->setImage(texture, texture->getWidth(), texture->getHeight());
|
||||
return _spectatorCameraNetworkTexture;
|
||||
}
|
||||
|
@ -1016,6 +1017,7 @@ NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl)
|
|||
if (_hmdPreviewFramebuffer) {
|
||||
texture = _hmdPreviewFramebuffer->getRenderBuffer(0);
|
||||
if (texture) {
|
||||
texture->setSource(HMD_PREVIEW_FRAME_URL.toString().toStdString());
|
||||
_hmdPreviewNetworkTexture->setImage(texture, texture->getWidth(), texture->getHeight());
|
||||
return _hmdPreviewNetworkTexture;
|
||||
}
|
||||
|
@ -1033,14 +1035,18 @@ const gpu::FramebufferPointer& TextureCache::getHmdPreviewFramebuffer(int width,
|
|||
}
|
||||
|
||||
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) {
|
||||
resetSpectatorCameraFramebuffer(2048, 1024);
|
||||
return getSpectatorCameraFramebuffer(DEFAULT_SPECTATOR_CAM_WIDTH, DEFAULT_SPECTATOR_CAM_HEIGHT);
|
||||
}
|
||||
return _spectatorCameraFramebuffer;
|
||||
}
|
||||
|
||||
void TextureCache::resetSpectatorCameraFramebuffer(int width, int height) {
|
||||
_spectatorCameraFramebuffer.reset(gpu::Framebuffer::create("spectatorCamera", gpu::Element::COLOR_SRGBA_32, width, height));
|
||||
_spectatorCameraNetworkTexture.reset();
|
||||
emit spectatorCameraFramebufferReset();
|
||||
const gpu::FramebufferPointer& TextureCache::getSpectatorCameraFramebuffer(int width, int height) {
|
||||
// If we aren't taking a screenshot, we might need to resize or create the camera buffer
|
||||
if (!_spectatorCameraFramebuffer || _spectatorCameraFramebuffer->getWidth() != width || _spectatorCameraFramebuffer->getHeight() != height) {
|
||||
_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 cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
|
||||
|
||||
|
||||
/// SpectatorCamera rendering targets.
|
||||
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& 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:
|
||||
void spectatorCameraFramebufferReset();
|
||||
|
|
|
@ -49,8 +49,8 @@ using namespace render;
|
|||
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);
|
||||
|
||||
RenderDeferredTask::RenderDeferredTask() {
|
||||
DependencyManager::set<FadeEffect>();
|
||||
RenderDeferredTask::RenderDeferredTask()
|
||||
{
|
||||
}
|
||||
|
||||
void RenderDeferredTask::configure(const Config& config)
|
||||
|
|
Loading…
Reference in a new issue