mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:03:11 +02:00
Merge pull request #15803 from SamGondelman/setPipeline
BUGZ-703: Possible fix for do_setPipeline crash and other Mac fixes
This commit is contained in:
commit
a66bd04810
10 changed files with 45 additions and 76 deletions
|
@ -593,9 +593,10 @@ std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> OpenGL
|
||||||
hudEyeViewports[eye] = eyeViewport(eye);
|
hudEyeViewports[eye] = eyeViewport(eye);
|
||||||
});
|
});
|
||||||
return [=](gpu::Batch& batch, const gpu::TexturePointer& hudTexture, bool mirror) {
|
return [=](gpu::Batch& batch, const gpu::TexturePointer& hudTexture, bool mirror) {
|
||||||
if (hudPipeline && hudTexture) {
|
auto pipeline = mirror ? hudMirrorPipeline : hudPipeline;
|
||||||
|
if (pipeline && hudTexture) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.setPipeline(mirror ? hudMirrorPipeline : hudPipeline);
|
batch.setPipeline(pipeline);
|
||||||
batch.setResourceTexture(0, hudTexture);
|
batch.setResourceTexture(0, hudTexture);
|
||||||
if (hudStereo) {
|
if (hudStereo) {
|
||||||
for_each_eye([&](Eye eye) {
|
for_each_eye([&](Eye eye) {
|
||||||
|
@ -661,17 +662,6 @@ void OpenGLDisplayPlugin::compositeLayers() {
|
||||||
compositeScene();
|
compositeScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HIFI_ENABLE_NSIGHT_DEBUG
|
|
||||||
if (false) // do not draw the HUD if running nsight debug
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
PROFILE_RANGE_EX(render_detail, "handleHUDBatch", 0xff0077ff, (uint64_t)presentCount())
|
|
||||||
auto hudOperator = getHUDOperator();
|
|
||||||
withPresentThreadLock([&] {
|
|
||||||
_hudOperator = hudOperator;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
PROFILE_RANGE_EX(render_detail, "compositeExtra", 0xff0077ff, (uint64_t)presentCount())
|
PROFILE_RANGE_EX(render_detail, "compositeExtra", 0xff0077ff, (uint64_t)presentCount())
|
||||||
compositeExtra();
|
compositeExtra();
|
||||||
|
|
|
@ -86,6 +86,8 @@ public:
|
||||||
|
|
||||||
void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target, GLsync* fenceSync) override;
|
void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target, GLsync* fenceSync) override;
|
||||||
|
|
||||||
|
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class PresentThread;
|
friend class PresentThread;
|
||||||
|
|
||||||
|
@ -102,7 +104,6 @@ protected:
|
||||||
virtual QThread::Priority getPresentPriority() { return QThread::HighPriority; }
|
virtual QThread::Priority getPresentPriority() { return QThread::HighPriority; }
|
||||||
virtual void compositeLayers();
|
virtual void compositeLayers();
|
||||||
virtual void compositeScene();
|
virtual void compositeScene();
|
||||||
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator();
|
|
||||||
virtual void compositePointer();
|
virtual void compositePointer();
|
||||||
virtual void compositeExtra() {};
|
virtual void compositeExtra() {};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//
|
//
|
||||||
// Created by Bradley Austin Davis on 2016/02/15
|
// Created by Bradley Austin Davis on 2016/02/15
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
|
@ -402,25 +402,18 @@ void HmdDisplayPlugin::HUDRenderer::build() {
|
||||||
format->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0);
|
format->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0);
|
||||||
format->setAttribute(gpu::Stream::TEXCOORD, gpu::Stream::TEXCOORD, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
|
format->setAttribute(gpu::Stream::TEXCOORD, gpu::Stream::TEXCOORD, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
|
||||||
uniformsBuffer = std::make_shared<gpu::Buffer>(sizeof(Uniforms), nullptr);
|
uniformsBuffer = std::make_shared<gpu::Buffer>(sizeof(Uniforms), nullptr);
|
||||||
updatePipeline();
|
|
||||||
|
auto program = gpu::Shader::createProgram(shader::render_utils::program::hmd_ui);
|
||||||
|
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||||
|
state->setDepthTest(gpu::State::DepthTest(true, true, gpu::LESS_EQUAL));
|
||||||
|
state->setBlendFunction(true,
|
||||||
|
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||||
|
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||||
|
|
||||||
|
pipeline = gpu::Pipeline::create(program, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HmdDisplayPlugin::HUDRenderer::updatePipeline() {
|
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> HmdDisplayPlugin::HUDRenderer::render() {
|
||||||
if (!pipeline) {
|
|
||||||
auto program = gpu::Shader::createProgram(shader::render_utils::program::hmd_ui);
|
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
|
||||||
state->setDepthTest(gpu::State::DepthTest(true, true, gpu::LESS_EQUAL));
|
|
||||||
state->setBlendFunction(true,
|
|
||||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
|
||||||
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
|
||||||
|
|
||||||
pipeline = gpu::Pipeline::create(program, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> HmdDisplayPlugin::HUDRenderer::render(HmdDisplayPlugin& plugin) {
|
|
||||||
updatePipeline();
|
|
||||||
|
|
||||||
auto hudPipeline = pipeline;
|
auto hudPipeline = pipeline;
|
||||||
auto hudFormat = format;
|
auto hudFormat = format;
|
||||||
auto hudVertices = vertices;
|
auto hudVertices = vertices;
|
||||||
|
@ -479,7 +472,7 @@ void HmdDisplayPlugin::compositePointer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> HmdDisplayPlugin::getHUDOperator() {
|
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> HmdDisplayPlugin::getHUDOperator() {
|
||||||
return _hudRenderer.render(*this);
|
return _hudRenderer.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
HmdDisplayPlugin::~HmdDisplayPlugin() {
|
HmdDisplayPlugin::~HmdDisplayPlugin() {
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
|
|
||||||
void pluginUpdate() override {};
|
void pluginUpdate() override {};
|
||||||
|
|
||||||
|
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator() override;
|
||||||
virtual StencilMaskMode getStencilMaskMode() const override { return StencilMaskMode::PAINT; }
|
virtual StencilMaskMode getStencilMaskMode() const override { return StencilMaskMode::PAINT; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -62,7 +63,6 @@ protected:
|
||||||
|
|
||||||
bool internalActivate() override;
|
bool internalActivate() override;
|
||||||
void internalDeactivate() override;
|
void internalDeactivate() override;
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator() override;
|
|
||||||
void compositePointer() override;
|
void compositePointer() override;
|
||||||
void internalPresent() override;
|
void internalPresent() override;
|
||||||
void customizeContext() override;
|
void customizeContext() override;
|
||||||
|
@ -105,7 +105,7 @@ private:
|
||||||
gpu::BufferPointer vertices;
|
gpu::BufferPointer vertices;
|
||||||
gpu::BufferPointer indices;
|
gpu::BufferPointer indices;
|
||||||
uint32_t indexCount { 0 };
|
uint32_t indexCount { 0 };
|
||||||
gpu::PipelinePointer pipeline;
|
gpu::PipelinePointer pipeline { nullptr };
|
||||||
|
|
||||||
gpu::BufferPointer uniformsBuffer;
|
gpu::BufferPointer uniformsBuffer;
|
||||||
|
|
||||||
|
@ -123,7 +123,6 @@ private:
|
||||||
static const int VERTEX_STRIDE { sizeof(Vertex) };
|
static const int VERTEX_STRIDE { sizeof(Vertex) };
|
||||||
|
|
||||||
void build();
|
void build();
|
||||||
void updatePipeline();
|
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> render();
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> render(HmdDisplayPlugin& plugin);
|
|
||||||
} _hudRenderer;
|
} _hudRenderer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -309,20 +309,28 @@ void PhysicalEntitySimulation::buildMotionStatesForEntitiesThatNeedThem() {
|
||||||
SetOfEntities::iterator entityItr = _entitiesToAddToPhysics.begin();
|
SetOfEntities::iterator entityItr = _entitiesToAddToPhysics.begin();
|
||||||
while (entityItr != _entitiesToAddToPhysics.end()) {
|
while (entityItr != _entitiesToAddToPhysics.end()) {
|
||||||
EntityItemPointer entity = (*entityItr);
|
EntityItemPointer entity = (*entityItr);
|
||||||
assert(!entity->getPhysicsInfo());
|
|
||||||
if (entity->isDead()) {
|
if (entity->isDead()) {
|
||||||
prepareEntityForDelete(entity);
|
prepareEntityForDelete(entity);
|
||||||
entityItr = _entitiesToAddToPhysics.erase(entityItr);
|
entityItr = _entitiesToAddToPhysics.erase(entityItr);
|
||||||
} else if (!entity->shouldBePhysical()) {
|
continue;
|
||||||
// this entity should no longer be on _entitiesToAddToPhysics
|
}
|
||||||
|
if (entity->getPhysicsInfo()) {
|
||||||
entityItr = _entitiesToAddToPhysics.erase(entityItr);
|
entityItr = _entitiesToAddToPhysics.erase(entityItr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!entity->shouldBePhysical()) {
|
||||||
|
// this entity should no longer be on _entitiesToAddToPhysics
|
||||||
if (entity->isMovingRelativeToParent()) {
|
if (entity->isMovingRelativeToParent()) {
|
||||||
SetOfEntities::iterator itr = _simpleKinematicEntities.find(entity);
|
SetOfEntities::iterator itr = _simpleKinematicEntities.find(entity);
|
||||||
if (itr == _simpleKinematicEntities.end()) {
|
if (itr == _simpleKinematicEntities.end()) {
|
||||||
_simpleKinematicEntities.insert(entity);
|
_simpleKinematicEntities.insert(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (entity->isReadyToComputeShape()) {
|
entityItr = _entitiesToAddToPhysics.erase(entityItr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity->isReadyToComputeShape()) {
|
||||||
ShapeRequest shapeRequest(entity);
|
ShapeRequest shapeRequest(entity);
|
||||||
ShapeRequests::iterator requestItr = _shapeRequests.find(shapeRequest);
|
ShapeRequests::iterator requestItr = _shapeRequests.find(shapeRequest);
|
||||||
if (requestItr == _shapeRequests.end()) {
|
if (requestItr == _shapeRequests.end()) {
|
||||||
|
@ -332,18 +340,7 @@ void PhysicalEntitySimulation::buildMotionStatesForEntitiesThatNeedThem() {
|
||||||
uint32_t requestCount = ObjectMotionState::getShapeManager()->getWorkRequestCount();
|
uint32_t requestCount = ObjectMotionState::getShapeManager()->getWorkRequestCount();
|
||||||
btCollisionShape* shape = const_cast<btCollisionShape*>(ObjectMotionState::getShapeManager()->getShape(shapeInfo));
|
btCollisionShape* shape = const_cast<btCollisionShape*>(ObjectMotionState::getShapeManager()->getShape(shapeInfo));
|
||||||
if (shape) {
|
if (shape) {
|
||||||
EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo());
|
buildMotionState(shape, entity);
|
||||||
if (!motionState) {
|
|
||||||
buildMotionState(shape, entity);
|
|
||||||
} else {
|
|
||||||
// Is it possible to fall in here?
|
|
||||||
// entity shouldn't be on _entitiesToAddToPhysics list if it already has a motionState.
|
|
||||||
// but just in case...
|
|
||||||
motionState->setShape(shape);
|
|
||||||
motionState->setRegion(_space->getRegion(entity->getSpaceIndex()));
|
|
||||||
_physicalObjects.insert(motionState);
|
|
||||||
_incomingChanges.insert(motionState);
|
|
||||||
}
|
|
||||||
} else if (requestCount != ObjectMotionState::getShapeManager()->getWorkRequestCount()) {
|
} else if (requestCount != ObjectMotionState::getShapeManager()->getWorkRequestCount()) {
|
||||||
// shape doesn't exist but a new worker has been spawned to build it --> add to shapeRequests and wait
|
// shape doesn't exist but a new worker has been spawned to build it --> add to shapeRequests and wait
|
||||||
shapeRequest.shapeHash = shapeInfo.getHash();
|
shapeRequest.shapeHash = shapeInfo.getHash();
|
||||||
|
@ -354,6 +351,7 @@ void PhysicalEntitySimulation::buildMotionStatesForEntitiesThatNeedThem() {
|
||||||
}
|
}
|
||||||
entityItr = _entitiesToAddToPhysics.erase(entityItr);
|
entityItr = _entitiesToAddToPhysics.erase(entityItr);
|
||||||
} else {
|
} else {
|
||||||
|
// skip for later
|
||||||
++entityItr;
|
++entityItr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ void ThreadSafeDynamicsWorld::drawConnectedSpheres(btIDebugDraw* drawer, btScala
|
||||||
btVector3 xAxis = direction.cross(btVector3(0.0f, 1.0f, 0.0f));
|
btVector3 xAxis = direction.cross(btVector3(0.0f, 1.0f, 0.0f));
|
||||||
xAxis = xAxis.length() < EPSILON ? btVector3(1.0f, 0.0f, 0.0f) : xAxis.normalize();
|
xAxis = xAxis.length() < EPSILON ? btVector3(1.0f, 0.0f, 0.0f) : xAxis.normalize();
|
||||||
btVector3 zAxis = xAxis.cross(btVector3(0.0f, 1.0f, 0.0f));
|
btVector3 zAxis = xAxis.cross(btVector3(0.0f, 1.0f, 0.0f));
|
||||||
zAxis = (direction.normalize().getY() < EPSILON) ? btVector3(0.0f, 1.0f, 0.0f) : zAxis.normalize();
|
zAxis = (direction.length2() < EPSILON || direction.normalize().getY() < EPSILON) ? btVector3(0.0f, 1.0f, 0.0f) : zAxis.normalize();
|
||||||
float fullCircle = 2.0f * PI;
|
float fullCircle = 2.0f * PI;
|
||||||
for (float i = 0; i < fullCircle; i += stepRadians) {
|
for (float i = 0; i < fullCircle; i += stepRadians) {
|
||||||
float x1 = btSin(btScalar(i)) * radius1;
|
float x1 = btSin(btScalar(i)) * radius1;
|
||||||
|
|
|
@ -35,15 +35,6 @@ void DisplayPlugin::waitForPresent() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> DisplayPlugin::getHUDOperator() {
|
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> hudOperator;
|
|
||||||
{
|
|
||||||
QMutexLocker locker(&_presentMutex);
|
|
||||||
hudOperator = _hudOperator;
|
|
||||||
}
|
|
||||||
return hudOperator;
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 HmdDisplay::getEyeToHeadTransform(Eye eye) const {
|
glm::mat4 HmdDisplay::getEyeToHeadTransform(Eye eye) const {
|
||||||
static const glm::mat4 xform;
|
static const glm::mat4 xform;
|
||||||
return xform;
|
return xform;
|
||||||
|
|
|
@ -213,13 +213,12 @@ public:
|
||||||
void waitForPresent();
|
void waitForPresent();
|
||||||
float getAveragePresentTime() { return _movingAveragePresent.average / (float)USECS_PER_MSEC; } // in msec
|
float getAveragePresentTime() { return _movingAveragePresent.average / (float)USECS_PER_MSEC; } // in msec
|
||||||
|
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator();
|
|
||||||
|
|
||||||
static const QString& MENU_PATH();
|
static const QString& MENU_PATH();
|
||||||
|
|
||||||
// for updating plugin-related commands. Mimics the input plugin.
|
// for updating plugin-related commands. Mimics the input plugin.
|
||||||
virtual void pluginUpdate() = 0;
|
virtual void pluginUpdate() = 0;
|
||||||
|
|
||||||
|
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator() { return nullptr; }
|
||||||
virtual StencilMaskMode getStencilMaskMode() const { return StencilMaskMode::NONE; }
|
virtual StencilMaskMode getStencilMaskMode() const { return StencilMaskMode::NONE; }
|
||||||
using StencilMaskMeshOperator = std::function<void(gpu::Batch&)>;
|
using StencilMaskMeshOperator = std::function<void(gpu::Batch&)>;
|
||||||
virtual StencilMaskMeshOperator getStencilMaskMeshOperator() { return nullptr; }
|
virtual StencilMaskMeshOperator getStencilMaskMeshOperator() { return nullptr; }
|
||||||
|
@ -234,8 +233,6 @@ protected:
|
||||||
|
|
||||||
gpu::ContextPointer _gpuContext;
|
gpu::ContextPointer _gpuContext;
|
||||||
|
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> _hudOperator { std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)>() };
|
|
||||||
|
|
||||||
MovingAverage<float, 10> _movingAveragePresent;
|
MovingAverage<float, 10> _movingAveragePresent;
|
||||||
|
|
||||||
float _renderResolutionScale { 1.0f };
|
float _renderResolutionScale { 1.0f };
|
||||||
|
|
|
@ -111,7 +111,7 @@ void CompositeHUD::run(const RenderContextPointer& renderContext, const gpu::Fra
|
||||||
assert(renderContext->args->_context);
|
assert(renderContext->args->_context);
|
||||||
|
|
||||||
// We do not want to render HUD elements in secondary camera
|
// We do not want to render HUD elements in secondary camera
|
||||||
if (renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) {
|
if (nsightActive() || renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,20 +124,20 @@ namespace render {
|
||||||
DebugFlags _debugFlags { RENDER_DEBUG_NONE };
|
DebugFlags _debugFlags { RENDER_DEBUG_NONE };
|
||||||
gpu::Batch* _batch = nullptr;
|
gpu::Batch* _batch = nullptr;
|
||||||
|
|
||||||
uint32_t _globalShapeKey{ 0 };
|
uint32_t _globalShapeKey { 0 };
|
||||||
uint32_t _itemShapeKey{ 0 };
|
uint32_t _itemShapeKey { 0 };
|
||||||
bool _enableTexturing{ true };
|
bool _enableTexturing { true };
|
||||||
bool _enableBlendshape{ true };
|
bool _enableBlendshape { true };
|
||||||
bool _enableSkinning{ true };
|
bool _enableSkinning { true };
|
||||||
|
|
||||||
bool _enableFade{ false };
|
bool _enableFade { false };
|
||||||
|
|
||||||
RenderDetails _details;
|
RenderDetails _details;
|
||||||
render::ScenePointer _scene;
|
render::ScenePointer _scene;
|
||||||
int8_t _cameraMode { -1 };
|
int8_t _cameraMode { -1 };
|
||||||
|
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> _hudOperator;
|
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> _hudOperator { nullptr };
|
||||||
gpu::TexturePointer _hudTexture;
|
gpu::TexturePointer _hudTexture { nullptr };
|
||||||
|
|
||||||
bool _takingSnapshot { false };
|
bool _takingSnapshot { false };
|
||||||
StencilMaskMode _stencilMaskMode { StencilMaskMode::NONE };
|
StencilMaskMode _stencilMaskMode { StencilMaskMode::NONE };
|
||||||
|
|
Loading…
Reference in a new issue