Merge branch 'warnings-win' of github.com:Atlante45/hifi into warnings-win

This commit is contained in:
Atlante45 2015-12-11 17:02:57 -08:00
commit 4bfa279b1b
5 changed files with 74 additions and 46 deletions

View file

@ -3431,10 +3431,10 @@ namespace render {
// Background rendering decision
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
auto skybox = model::SkyboxPointer();
if (skyStage->getBackgroundMode() == model::SunSkyStage::NO_BACKGROUND) {
// this line intentionally left blank
} else if (skyStage->getBackgroundMode() == model::SunSkyStage::SKY_DOME) {
if (/*!selfAvatarOnly &&*/ Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
PerformanceTimer perfTimer("stars");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::payloadRender<BackgroundRenderData>() ... stars...");
@ -3500,8 +3500,7 @@ namespace render {
}
} else if (skyStage->getBackgroundMode() == model::SunSkyStage::SKY_BOX) {
PerformanceTimer perfTimer("skybox");
skybox = skyStage->getSkybox();
auto skybox = skyStage->getSkybox();
if (skybox) {
skybox->render(batch, *(qApp->getDisplayViewFrustum()));
}
@ -3767,6 +3766,10 @@ void Application::clearDomainOctreeDetails() {
// reset the model renderer
getEntities()->clear();
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME);
}
void Application::domainChanged(const QString& domainHostname) {

View file

@ -55,7 +55,7 @@ static const float LATE_MIX_RIGHT_DEFAULT = 90.0f;
static const float WET_DRY_MIX_DEFAULT = 50.0f;
static void setOption(QScriptValue arguments, const QString name, float defaultValue, float& variable) {
variable = arguments.property(name).isNumber() ? arguments.property(name).toNumber() : defaultValue;
variable = arguments.property(name).isNumber() ? (float)arguments.property(name).toNumber() : defaultValue;
}
AudioEffectOptions::AudioEffectOptions(QScriptValue arguments) {

View file

@ -226,9 +226,16 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
while (!toProcess.empty()) {
EntityItemPointer childEntity = std::static_pointer_cast<EntityItem>(toProcess.dequeue());
if (!childEntity) {
continue;
}
BoundingBoxRelatedProperties newChildBBRelProperties(childEntity);
EntityTreeElementPointer containingElement = childEntity->getElement();
if (!containingElement) {
continue;
}
UpdateEntityOperator theChildOperator(getThisPointer(),
childEntity->getElement(),
containingElement,
childEntity, newChildBBRelProperties);
recurseTreeWithOperator(&theChildOperator);
foreach (SpatiallyNestablePointer childChild, childEntity->getChildren()) {

View file

@ -48,35 +48,32 @@ template <
>
class GLEscrow {
public:
static const uint64_t MAX_UNSIGNALED_TIME = USECS_PER_SECOND / 2;
struct Item {
T _value;
const T _value;
GLsync _sync;
uint64_t _created;
const uint64_t _created;
Item(T value, GLsync sync) :
_value(value), _sync(sync), _created(usecTimestampNow())
{
}
uint64_t age() {
uint64_t age() const {
return usecTimestampNow() - _created;
}
bool signaled() {
bool signaled() const {
auto result = glClientWaitSync(_sync, 0, 0);
if (GL_TIMEOUT_EXPIRED != result && GL_WAIT_FAILED != result) {
return true;
}
if (age() > (USECS_PER_SECOND / 2)) {
qWarning() << "Long unsignaled sync";
}
return false;
}
};
using Mutex = std::recursive_mutex;
using Lock = std::unique_lock<Mutex>;
using Mutex = std::mutex;
using Recycler = std::function<void(T t)>;
// deque gives us random access, double ended push & pop and size, all in constant time
using Deque = std::deque<Item>;
@ -86,9 +83,32 @@ public:
_recycler = recycler;
}
size_t depth() {
template <typename F>
void withLock(F f) {
using Lock = std::unique_lock<Mutex>;
Lock lock(_mutex);
return _submits.size();
f();
}
template <typename F>
bool tryLock(F f) {
using Lock = std::unique_lock<Mutex>;
bool result = false;
Lock lock(_mutex, std::try_to_lock_t());
if (lock.owns_lock()) {
f();
result = true;
}
return result;
}
size_t depth() {
size_t result{ 0 };
withLock([&]{
result = _submits.size();
});
return result;
}
// Submit a new resource from the producer context
@ -103,11 +123,9 @@ public:
glFlush();
}
{
Lock lock(_mutex);
withLock([&]{
_submits.push_back(Item(t, writeSync));
}
});
return cleanTrash();
}
@ -119,13 +137,13 @@ public:
// On the one hand using try_lock() reduces the chance of blocking the consumer thread,
// but if the produce thread is going fast enough, it could effectively
// starve the consumer out of ever actually getting resources.
if (_mutex.try_lock()) {
tryLock([&]{
// May be called on any thread, but must be inside a locked section
if (signaled(_submits, 0)) {
result = _submits.at(0)._value;
_submits.pop_front();
}
_mutex.unlock();
}
});
return result;
}
@ -153,37 +171,45 @@ public:
glFlush();
}
Lock lock(_mutex);
_releases.push_back(Item(t, readSync));
withLock([&]{
_releases.push_back(Item(t, readSync));
});
}
private:
size_t cleanTrash() {
size_t wastedWork{ 0 };
List trash;
{
tryLock([&]{
while (!_submits.empty()) {
const auto& item = _submits.front();
if (!item._sync || item.age() < MAX_UNSIGNALED_TIME) {
break;
}
qWarning() << "Long unsignaled sync " << item._sync << " unsignaled for " << item.age();
_trash.push_front(item);
_submits.pop_front();
}
// We only ever need one ready item available in the list, so if the
// second item is signaled (implying the first is as well, remove the first
// item. Iterate until the SECOND item in the list is not in the ready state
// The signaled function takes care of checking against the deque size
while (signaled(_submits, 1)) {
pop(_submits);
_trash.push_front(_submits.front());
_submits.pop_front();
++wastedWork;
}
// Stuff in the release queue can be cleared out as soon as it's signaled
while (signaled(_releases, 0)) {
pop(_releases);
_trash.push_front(_releases.front());
_releases.pop_front();
}
{
// FIXME I don't think this lock should be necessary, only the submitting thread
// touches the trash
Lock lock(_mutex);
trash.swap(_trash);
}
}
trash.swap(_trash);
});
// FIXME maybe doing a timing on the deleters and warn if it's taking excessive time?
// although we are out of the lock, so it shouldn't be blocking anything
std::for_each(trash.begin(), trash.end(), [&](typename List::const_reference item) {
@ -197,14 +223,6 @@ private:
return wastedWork;
}
// May be called on any thread, but must be inside a locked section
void pop(Deque& deque) {
Lock lock(_mutex);
auto& item = deque.front();
_trash.push_front(item);
deque.pop_front();
}
// May be called on any thread, but must be inside a locked section
bool signaled(Deque& deque, size_t i) {
if (i >= deque.size()) {

View file

@ -216,7 +216,7 @@ void renderItems(const SceneContextPointer& sceneContext, const RenderContextPoi
class FetchItems {
public:
typedef std::function<void (const RenderContextPointer& context, int count)> ProbeNumItems;
typedef std::function<void (const RenderContextPointer& context, size_t count)> ProbeNumItems;
FetchItems(const ProbeNumItems& probe): _probeNumItems(probe) {}
FetchItems(const ItemFilter& filter, const ProbeNumItems& probe): _filter(filter), _probeNumItems(probe) {}