mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 22:43:50 +02:00
merge from upstream
This commit is contained in:
commit
b8b1127d55
29 changed files with 405 additions and 169 deletions
|
@ -130,6 +130,11 @@ Var AR_RegFlags
|
||||||
SectionSetFlags ${${SecName}} $AR_SecFlags
|
SectionSetFlags ${${SecName}} $AR_SecFlags
|
||||||
|
|
||||||
"default_${SecName}:"
|
"default_${SecName}:"
|
||||||
|
; The client is always selected by default
|
||||||
|
${If} ${SecName} == @CLIENT_COMPONENT_NAME@
|
||||||
|
SectionSetFlags ${${SecName}} 17
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
|
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
|
@ -243,6 +248,12 @@ FunctionEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
; Installation types
|
; Installation types
|
||||||
|
|
||||||
|
Section "-Previous Install Cleanup"
|
||||||
|
; Remove the resources folder so we don't end up including removed QML files
|
||||||
|
RMDir /r "$INSTDIR\resources"
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
@CPACK_NSIS_INSTALLATION_TYPES@
|
@CPACK_NSIS_INSTALLATION_TYPES@
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
|
@ -548,6 +548,15 @@ EntityItemProperties RenderableModelEntityItem::getProperties(EntityPropertyFlag
|
||||||
if (_originalTexturesRead) {
|
if (_originalTexturesRead) {
|
||||||
properties.setTextureNames(_originalTextures);
|
properties.setTextureNames(_originalTextures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_model) {
|
||||||
|
properties.setRenderInfoVertexCount(_model->getRenderInfoVertexCount());
|
||||||
|
properties.setRenderInfoTextureCount(_model->getRenderInfoTextureCount());
|
||||||
|
properties.setRenderInfoTextureSize(_model->getRenderInfoTextureSize());
|
||||||
|
properties.setRenderInfoDrawCalls(_model->getRenderInfoDrawCalls());
|
||||||
|
properties.setRenderInfoHasTransparent(_model->getRenderInfoHasTransparent());
|
||||||
|
}
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -580,6 +580,24 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_CLIENT_ONLY, clientOnly);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_CLIENT_ONLY, clientOnly);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID);
|
||||||
|
|
||||||
|
// Rendering info
|
||||||
|
if (!skipDefaults) {
|
||||||
|
QScriptValue renderInfo = engine->newObject();
|
||||||
|
|
||||||
|
// currently only supported by models
|
||||||
|
if (_type == EntityTypes::Model) {
|
||||||
|
renderInfo.setProperty("verticesCount", (int)getRenderInfoVertexCount()); // FIXME - theoretically the number of vertex could be > max int
|
||||||
|
renderInfo.setProperty("texturesSize", (int)getRenderInfoTextureSize()); // FIXME - theoretically the size of textures could be > max int
|
||||||
|
renderInfo.setProperty("hasTransparent", getRenderInfoHasTransparent());
|
||||||
|
renderInfo.setProperty("drawCalls", getRenderInfoDrawCalls());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_type == EntityTypes::Model || _type == EntityTypes::PolyLine || _type == EntityTypes::ParticleEffect) {
|
||||||
|
renderInfo.setProperty("texturesCount", QScriptValue(_textureNames.count()));
|
||||||
|
}
|
||||||
|
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_NO_SKIP(renderInfo, renderInfo); // Gettable but not settable
|
||||||
|
}
|
||||||
|
|
||||||
properties.setProperty("clientOnly", convertScriptValue(engine, getClientOnly()));
|
properties.setProperty("clientOnly", convertScriptValue(engine, getClientOnly()));
|
||||||
properties.setProperty("owningAvatarID", convertScriptValue(engine, getOwningAvatarID()));
|
properties.setProperty("owningAvatarID", convertScriptValue(engine, getOwningAvatarID()));
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,19 @@ public:
|
||||||
void setJointRotationsDirty() { _jointRotationsSetChanged = true; _jointRotationsChanged = true; }
|
void setJointRotationsDirty() { _jointRotationsSetChanged = true; _jointRotationsChanged = true; }
|
||||||
void setJointTranslationsDirty() { _jointTranslationsSetChanged = true; _jointTranslationsChanged = true; }
|
void setJointTranslationsDirty() { _jointTranslationsSetChanged = true; _jointTranslationsChanged = true; }
|
||||||
|
|
||||||
|
// render info related items
|
||||||
|
size_t getRenderInfoVertexCount() const { return _renderInfoVertexCount; }
|
||||||
|
void setRenderInfoVertexCount(size_t value) { _renderInfoVertexCount = value; }
|
||||||
|
int getRenderInfoTextureCount() const { return _renderInfoTextureCount; }
|
||||||
|
void setRenderInfoTextureCount(int value) { _renderInfoTextureCount = value; }
|
||||||
|
size_t getRenderInfoTextureSize() const { return _renderInfoTextureSize; }
|
||||||
|
void setRenderInfoTextureSize(size_t value) { _renderInfoTextureSize = value; }
|
||||||
|
int getRenderInfoDrawCalls() const { return _renderInfoDrawCalls; }
|
||||||
|
void setRenderInfoDrawCalls(int value) { _renderInfoDrawCalls = value; }
|
||||||
|
bool getRenderInfoHasTransparent() const { return _renderInfoHasTransparent; }
|
||||||
|
void setRenderInfoHasTransparent(bool value) { _renderInfoHasTransparent = value; }
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString getCollisionMaskAsString() const;
|
QString getCollisionMaskAsString() const;
|
||||||
void setCollisionMaskFromString(const QString& maskString);
|
void setCollisionMaskFromString(const QString& maskString);
|
||||||
|
@ -308,6 +321,12 @@ private:
|
||||||
glm::vec3 _naturalDimensions;
|
glm::vec3 _naturalDimensions;
|
||||||
glm::vec3 _naturalPosition;
|
glm::vec3 _naturalPosition;
|
||||||
|
|
||||||
|
size_t _renderInfoVertexCount { 0 };
|
||||||
|
int _renderInfoTextureCount { 0 };
|
||||||
|
size_t _renderInfoTextureSize { 0 };
|
||||||
|
int _renderInfoDrawCalls { 0 };
|
||||||
|
bool _renderInfoHasTransparent { false };
|
||||||
|
|
||||||
EntityPropertyFlags _desiredProperties; // if set will narrow scopes of copy/to/from to just these properties
|
EntityPropertyFlags _desiredProperties; // if set will narrow scopes of copy/to/from to just these properties
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ void GLBackend::do_beginQuery(const Batch& batch, size_t paramOffset) {
|
||||||
auto query = batch._queries.get(batch._params[paramOffset]._uint);
|
auto query = batch._queries.get(batch._params[paramOffset]._uint);
|
||||||
GLQuery* glquery = syncGPUObject(*query);
|
GLQuery* glquery = syncGPUObject(*query);
|
||||||
if (glquery) {
|
if (glquery) {
|
||||||
|
glGetInteger64v(GL_TIMESTAMP, (GLint64*)&glquery->_batchElapsedTime);
|
||||||
if (timeElapsed) {
|
if (timeElapsed) {
|
||||||
glBeginQuery(GL_TIME_ELAPSED, glquery->_endqo);
|
glBeginQuery(GL_TIME_ELAPSED, glquery->_endqo);
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,6 +44,10 @@ void GLBackend::do_endQuery(const Batch& batch, size_t paramOffset) {
|
||||||
} else {
|
} else {
|
||||||
glQueryCounter(glquery->_endqo, GL_TIMESTAMP);
|
glQueryCounter(glquery->_endqo, GL_TIMESTAMP);
|
||||||
}
|
}
|
||||||
|
GLint64 now;
|
||||||
|
glGetInteger64v(GL_TIMESTAMP, &now);
|
||||||
|
glquery->_batchElapsedTime = now - glquery->_batchElapsedTime;
|
||||||
|
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +66,7 @@ void GLBackend::do_getQuery(const Batch& batch, size_t paramOffset) {
|
||||||
glGetQueryObjectui64v(glquery->_endqo, GL_QUERY_RESULT, &end);
|
glGetQueryObjectui64v(glquery->_endqo, GL_QUERY_RESULT, &end);
|
||||||
glquery->_result = end - start;
|
glquery->_result = end - start;
|
||||||
}
|
}
|
||||||
query->triggerReturnHandler(glquery->_result);
|
query->triggerReturnHandler(glquery->_result, glquery->_batchElapsedTime);
|
||||||
}
|
}
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
const GLuint& _endqo = { _id };
|
const GLuint& _endqo = { _id };
|
||||||
const GLuint _beginqo = { 0 };
|
const GLuint _beginqo = { 0 };
|
||||||
GLuint64 _result { (GLuint64)-1 };
|
GLuint64 _result { (GLuint64)-1 };
|
||||||
|
GLuint64 _batchElapsedTime { (GLuint64) 0 };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GLQuery(const std::weak_ptr<GLBackend>& backend, const Query& query, GLuint endId, GLuint beginId) : Parent(backend, query, endId), _beginqo(beginId) {}
|
GLQuery(const std::weak_ptr<GLBackend>& backend, const Query& query, GLuint endId, GLuint beginId) : Parent(backend, query, endId), _beginqo(beginId) {}
|
||||||
|
|
|
@ -104,7 +104,7 @@ bool GLTextureTransferHelper::processQueueItems(const Queue& messages) {
|
||||||
QThread::usleep(1);
|
QThread::usleep(1);
|
||||||
result = glClientWaitSync(fence, 0, 0);
|
result = glClientWaitSync(fence, 0, 0);
|
||||||
}
|
}
|
||||||
glDeleteSync(package.fence);
|
glDeleteSync(fence);
|
||||||
}
|
}
|
||||||
|
|
||||||
object->_contentStamp = texturePointer->getDataStamp();
|
object->_contentStamp = texturePointer->getDataStamp();
|
||||||
|
|
|
@ -24,12 +24,16 @@ Query::~Query()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
double Query::getElapsedTime() const {
|
double Query::getGPUElapsedTime() const {
|
||||||
return ((double)_queryResult) / 1000000.0;
|
return ((double)_queryResult) / 1000000.0;
|
||||||
}
|
}
|
||||||
|
double Query::getBatchElapsedTime() const {
|
||||||
|
return ((double)_usecBatchElapsedTime) / 1000000.0;
|
||||||
|
}
|
||||||
|
|
||||||
void Query::triggerReturnHandler(uint64_t queryResult) {
|
void Query::triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime) {
|
||||||
_queryResult = queryResult;
|
_queryResult = queryResult;
|
||||||
|
_usecBatchElapsedTime = batchElapsedTime;
|
||||||
if (_returnHandler) {
|
if (_returnHandler) {
|
||||||
_returnHandler(*this);
|
_returnHandler(*this);
|
||||||
}
|
}
|
||||||
|
@ -40,8 +44,8 @@ RangeTimer::RangeTimer() {
|
||||||
for (int i = 0; i < QUERY_QUEUE_SIZE; i++) {
|
for (int i = 0; i < QUERY_QUEUE_SIZE; i++) {
|
||||||
_timerQueries.push_back(std::make_shared<gpu::Query>([&, i] (const Query& query) {
|
_timerQueries.push_back(std::make_shared<gpu::Query>([&, i] (const Query& query) {
|
||||||
_tailIndex ++;
|
_tailIndex ++;
|
||||||
auto elapsedTime = query.getElapsedTime();
|
_movingAverageGPU.addSample(query.getGPUElapsedTime());
|
||||||
_movingAverage.addSample(elapsedTime);
|
_movingAverageBatch.addSample(query.getBatchElapsedTime());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +70,10 @@ void RangeTimer::end(gpu::Batch& batch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double RangeTimer::getAverage() const {
|
double RangeTimer::getGPUAverage() const {
|
||||||
return _movingAverage.average;
|
return _movingAverageGPU.average;
|
||||||
|
}
|
||||||
|
|
||||||
|
double RangeTimer::getBatchAverage() const {
|
||||||
|
return _movingAverageBatch.average;
|
||||||
}
|
}
|
|
@ -30,14 +30,17 @@ namespace gpu {
|
||||||
Query(const Handler& returnHandler);
|
Query(const Handler& returnHandler);
|
||||||
~Query();
|
~Query();
|
||||||
|
|
||||||
double getElapsedTime() const;
|
double getGPUElapsedTime() const;
|
||||||
|
double getBatchElapsedTime() const;
|
||||||
|
|
||||||
|
// Only for gpu::Context
|
||||||
const GPUObjectPointer gpuObject {};
|
const GPUObjectPointer gpuObject {};
|
||||||
void triggerReturnHandler(uint64_t queryResult);
|
void triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime);
|
||||||
protected:
|
protected:
|
||||||
Handler _returnHandler;
|
Handler _returnHandler;
|
||||||
|
|
||||||
uint64_t _queryResult = 0;
|
uint64_t _queryResult { 0 };
|
||||||
|
uint64_t _usecBatchElapsedTime { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<Query> QueryPointer;
|
typedef std::shared_ptr<Query> QueryPointer;
|
||||||
|
@ -53,7 +56,8 @@ namespace gpu {
|
||||||
void begin(gpu::Batch& batch);
|
void begin(gpu::Batch& batch);
|
||||||
void end(gpu::Batch& batch);
|
void end(gpu::Batch& batch);
|
||||||
|
|
||||||
double getAverage() const;
|
double getGPUAverage() const;
|
||||||
|
double getBatchAverage() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -62,7 +66,8 @@ namespace gpu {
|
||||||
gpu::Queries _timerQueries;
|
gpu::Queries _timerQueries;
|
||||||
int _headIndex = -1;
|
int _headIndex = -1;
|
||||||
int _tailIndex = -1;
|
int _tailIndex = -1;
|
||||||
MovingAverage<double, QUERY_QUEUE_SIZE * 2> _movingAverage;
|
MovingAverage<double, QUERY_QUEUE_SIZE * 2> _movingAverageGPU;
|
||||||
|
MovingAverage<double, QUERY_QUEUE_SIZE * 2> _movingAverageBatch;
|
||||||
|
|
||||||
int rangeIndex(int index) const { return (index % QUERY_QUEUE_SIZE); }
|
int rangeIndex(int index) const { return (index % QUERY_QUEUE_SIZE); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
TextureMap() {}
|
TextureMap() {}
|
||||||
|
|
||||||
void setTextureSource(gpu::TextureSourcePointer& textureSource);
|
void setTextureSource(gpu::TextureSourcePointer& textureSource);
|
||||||
|
gpu::TextureSourcePointer getTextureSource() const { return _textureSource; }
|
||||||
|
|
||||||
bool isDefined() const;
|
bool isDefined() const;
|
||||||
gpu::TextureView getTextureView() const;
|
gpu::TextureView getTextureView() const;
|
||||||
|
|
|
@ -432,7 +432,8 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the timer
|
// Update the timer
|
||||||
std::static_pointer_cast<Config>(renderContext->jobConfig)->gpuTime = _gpuTimer.getAverage();
|
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||||
|
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ protected:
|
||||||
|
|
||||||
using AmbientOcclusionFramebufferPointer = std::shared_ptr<AmbientOcclusionFramebuffer>;
|
using AmbientOcclusionFramebufferPointer = std::shared_ptr<AmbientOcclusionFramebuffer>;
|
||||||
|
|
||||||
class AmbientOcclusionEffectConfig : public render::Job::Config::Persistent {
|
class AmbientOcclusionEffectConfig : public render::GPUJobConfig::Persistent {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty)
|
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty)
|
||||||
Q_PROPERTY(bool ditheringEnabled MEMBER ditheringEnabled NOTIFY dirty)
|
Q_PROPERTY(bool ditheringEnabled MEMBER ditheringEnabled NOTIFY dirty)
|
||||||
|
@ -68,9 +68,9 @@ class AmbientOcclusionEffectConfig : public render::Job::Config::Persistent {
|
||||||
Q_PROPERTY(int numSamples MEMBER numSamples WRITE setNumSamples)
|
Q_PROPERTY(int numSamples MEMBER numSamples WRITE setNumSamples)
|
||||||
Q_PROPERTY(int resolutionLevel MEMBER resolutionLevel WRITE setResolutionLevel)
|
Q_PROPERTY(int resolutionLevel MEMBER resolutionLevel WRITE setResolutionLevel)
|
||||||
Q_PROPERTY(int blurRadius MEMBER blurRadius WRITE setBlurRadius)
|
Q_PROPERTY(int blurRadius MEMBER blurRadius WRITE setBlurRadius)
|
||||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
|
||||||
public:
|
public:
|
||||||
AmbientOcclusionEffectConfig() : render::Job::Config::Persistent("Ambient Occlusion", false) {}
|
AmbientOcclusionEffectConfig() : render::GPUJobConfig::Persistent("Ambient Occlusion", false) {}
|
||||||
|
|
||||||
const int MAX_RESOLUTION_LEVEL = 4;
|
const int MAX_RESOLUTION_LEVEL = 4;
|
||||||
const int MAX_BLUR_RADIUS = 6;
|
const int MAX_BLUR_RADIUS = 6;
|
||||||
|
@ -84,7 +84,6 @@ public:
|
||||||
void setNumSamples(int samples) { numSamples = std::max(1.0f, (float)samples); emit dirty(); }
|
void setNumSamples(int samples) { numSamples = std::max(1.0f, (float)samples); emit dirty(); }
|
||||||
void setResolutionLevel(int level) { resolutionLevel = std::max(0, std::min(level, MAX_RESOLUTION_LEVEL)); emit dirty(); }
|
void setResolutionLevel(int level) { resolutionLevel = std::max(0, std::min(level, MAX_RESOLUTION_LEVEL)); emit dirty(); }
|
||||||
void setBlurRadius(int radius) { blurRadius = std::max(0, std::min(MAX_BLUR_RADIUS, radius)); emit dirty(); }
|
void setBlurRadius(int radius) { blurRadius = std::max(0, std::min(MAX_BLUR_RADIUS, radius)); emit dirty(); }
|
||||||
double getGpuTime() { return gpuTime; }
|
|
||||||
|
|
||||||
float radius{ 0.5f };
|
float radius{ 0.5f };
|
||||||
float perspectiveScale{ 1.0f };
|
float perspectiveScale{ 1.0f };
|
||||||
|
@ -99,7 +98,6 @@ public:
|
||||||
bool ditheringEnabled{ true }; // randomize the distribution of taps per pixel, should always be true
|
bool ditheringEnabled{ true }; // randomize the distribution of taps per pixel, should always be true
|
||||||
bool borderingEnabled{ true }; // avoid evaluating information from non existing pixels out of the frame, should always be true
|
bool borderingEnabled{ true }; // avoid evaluating information from non existing pixels out of the frame, should always be true
|
||||||
bool fetchMipsEnabled{ true }; // fetch taps in sub mips to otpimize cache, should always be true
|
bool fetchMipsEnabled{ true }; // fetch taps in sub mips to otpimize cache, should always be true
|
||||||
double gpuTime{ 0.0 };
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
|
|
@ -714,5 +714,5 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo
|
||||||
});
|
});
|
||||||
|
|
||||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||||
config->gpuTime = _gpuTimer.getAverage();
|
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,21 +161,7 @@ public:
|
||||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using RenderDeferredConfig = render::GPUJobConfig;
|
||||||
class RenderDeferredConfig : public render::Job::Config {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
|
||||||
public:
|
|
||||||
RenderDeferredConfig() : render::Job::Config(true) {}
|
|
||||||
|
|
||||||
double getGpuTime() { return gpuTime; }
|
|
||||||
|
|
||||||
double gpuTime{ 0.0 };
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void dirty();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class RenderDeferred {
|
class RenderDeferred {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -71,8 +71,37 @@ void MeshPartPayload::updateTransform(const Transform& transform, const Transfor
|
||||||
|
|
||||||
void MeshPartPayload::updateMaterial(model::MaterialPointer drawMaterial) {
|
void MeshPartPayload::updateMaterial(model::MaterialPointer drawMaterial) {
|
||||||
_drawMaterial = drawMaterial;
|
_drawMaterial = drawMaterial;
|
||||||
|
calculateMaterialSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MeshPartPayload::calculateMaterialSize() {
|
||||||
|
bool allTextures = true; // assume we got this...
|
||||||
|
_materialTextureSize = 0;
|
||||||
|
auto textureMaps = _drawMaterial->getTextureMaps();
|
||||||
|
for (auto const &textureMapItem : textureMaps) {
|
||||||
|
auto textureMap = textureMapItem.second;
|
||||||
|
if (textureMap) {
|
||||||
|
auto textureSoure = textureMap->getTextureSource();
|
||||||
|
if (textureSoure) {
|
||||||
|
auto texture = textureSoure->getGPUTexture();
|
||||||
|
if (texture) {
|
||||||
|
//auto storedSize = texture->getStoredSize();
|
||||||
|
auto size = texture->getSize();
|
||||||
|
_materialTextureSize += size;
|
||||||
|
} else {
|
||||||
|
allTextures = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
allTextures = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
allTextures = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return allTextures;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ItemKey MeshPartPayload::getKey() const {
|
ItemKey MeshPartPayload::getKey() const {
|
||||||
ItemKey::Builder builder;
|
ItemKey::Builder builder;
|
||||||
builder.withTypeShape();
|
builder.withTypeShape();
|
||||||
|
@ -347,8 +376,8 @@ void ModelMeshPartPayload::initCache() {
|
||||||
auto networkMaterial = _model->getGeometry()->getShapeMaterial(_shapeID);
|
auto networkMaterial = _model->getGeometry()->getShapeMaterial(_shapeID);
|
||||||
if (networkMaterial) {
|
if (networkMaterial) {
|
||||||
_drawMaterial = networkMaterial;
|
_drawMaterial = networkMaterial;
|
||||||
};
|
calculateMaterialSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelMeshPartPayload::notifyLocationChanged() {
|
void ModelMeshPartPayload::notifyLocationChanged() {
|
||||||
|
|
|
@ -64,6 +64,13 @@ public:
|
||||||
mutable model::Box _worldBound;
|
mutable model::Box _worldBound;
|
||||||
|
|
||||||
bool _hasColorAttrib = false;
|
bool _hasColorAttrib = false;
|
||||||
|
|
||||||
|
size_t getVerticesCount() const { return _drawMesh ? _drawMesh->getNumVertices() : 0; }
|
||||||
|
size_t getMaterialTextureSize() { return _materialTextureSize; }
|
||||||
|
bool calculateMaterialSize();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
size_t _materialTextureSize { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
|
@ -161,6 +161,23 @@ void Model::setOffset(const glm::vec3& offset) {
|
||||||
_snappedToRegistrationPoint = false;
|
_snappedToRegistrationPoint = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Model::getRenderInfoTextureSize() {
|
||||||
|
if (!_hasCalculatedTextureSize && isLoaded() && getGeometry()->areTexturesLoaded()) {
|
||||||
|
size_t textureSize = 0;
|
||||||
|
bool allTexturesLoaded = true;
|
||||||
|
foreach(auto renderItem, _modelMeshRenderItemsSet) {
|
||||||
|
auto meshPart = renderItem.get();
|
||||||
|
bool allTexturesForThisMesh = meshPart->calculateMaterialSize();
|
||||||
|
allTexturesLoaded = allTexturesLoaded & allTexturesForThisMesh;
|
||||||
|
textureSize += meshPart->getMaterialTextureSize();
|
||||||
|
}
|
||||||
|
_renderInfoTextureSize = textureSize;
|
||||||
|
_hasCalculatedTextureSize = allTexturesLoaded; // only do this once
|
||||||
|
}
|
||||||
|
return _renderInfoTextureSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Model::updateRenderItems() {
|
void Model::updateRenderItems() {
|
||||||
if (!_addedToScene) {
|
if (!_addedToScene) {
|
||||||
return;
|
return;
|
||||||
|
@ -615,16 +632,26 @@ bool Model::addToScene(std::shared_ptr<render::Scene> scene,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_modelMeshRenderItems.empty()) {
|
if (_modelMeshRenderItems.empty()) {
|
||||||
foreach (auto renderItem, _modelMeshRenderItemsSet) {
|
|
||||||
|
bool hasTransparent = false;
|
||||||
|
size_t verticesCount = 0;
|
||||||
|
foreach(auto renderItem, _modelMeshRenderItemsSet) {
|
||||||
auto item = scene->allocateID();
|
auto item = scene->allocateID();
|
||||||
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
||||||
if (statusGetters.size()) {
|
if (statusGetters.size()) {
|
||||||
renderPayload->addStatusGetters(statusGetters);
|
renderPayload->addStatusGetters(statusGetters);
|
||||||
}
|
}
|
||||||
pendingChanges.resetItem(item, renderPayload);
|
pendingChanges.resetItem(item, renderPayload);
|
||||||
|
|
||||||
|
hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent();
|
||||||
|
verticesCount += renderItem.get()->getVerticesCount();
|
||||||
_modelMeshRenderItems.insert(item, renderPayload);
|
_modelMeshRenderItems.insert(item, renderPayload);
|
||||||
}
|
}
|
||||||
somethingAdded = !_modelMeshRenderItems.empty();
|
somethingAdded = !_modelMeshRenderItems.empty();
|
||||||
|
|
||||||
|
_renderInfoVertexCount = verticesCount;
|
||||||
|
_renderInfoDrawCalls = _modelMeshRenderItems.count();
|
||||||
|
_renderInfoHasTransparent = hasTransparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,6 +677,11 @@ void Model::removeFromScene(std::shared_ptr<render::Scene> scene, render::Pendin
|
||||||
_collisionRenderItems.clear();
|
_collisionRenderItems.clear();
|
||||||
_collisionRenderItemsSet.clear();
|
_collisionRenderItemsSet.clear();
|
||||||
_addedToScene = false;
|
_addedToScene = false;
|
||||||
|
|
||||||
|
_renderInfoVertexCount = 0;
|
||||||
|
_renderInfoDrawCalls = 0;
|
||||||
|
_renderInfoTextureSize = 0;
|
||||||
|
_renderInfoHasTransparent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::renderDebugMeshBoxes(gpu::Batch& batch) {
|
void Model::renderDebugMeshBoxes(gpu::Batch& batch) {
|
||||||
|
@ -1332,13 +1364,21 @@ bool Model::initWhenReady(render::ScenePointer scene) {
|
||||||
}
|
}
|
||||||
addedPendingChanges = !_collisionRenderItems.empty();
|
addedPendingChanges = !_collisionRenderItems.empty();
|
||||||
} else {
|
} else {
|
||||||
|
bool hasTransparent = false;
|
||||||
|
size_t verticesCount = 0;
|
||||||
foreach (auto renderItem, _modelMeshRenderItemsSet) {
|
foreach (auto renderItem, _modelMeshRenderItemsSet) {
|
||||||
auto item = scene->allocateID();
|
auto item = scene->allocateID();
|
||||||
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
auto renderPayload = std::make_shared<ModelMeshPartPayload::Payload>(renderItem);
|
||||||
|
|
||||||
|
hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent();
|
||||||
|
verticesCount += renderItem.get()->getVerticesCount();
|
||||||
_modelMeshRenderItems.insert(item, renderPayload);
|
_modelMeshRenderItems.insert(item, renderPayload);
|
||||||
pendingChanges.resetItem(item, renderPayload);
|
pendingChanges.resetItem(item, renderPayload);
|
||||||
}
|
}
|
||||||
addedPendingChanges = !_modelMeshRenderItems.empty();
|
addedPendingChanges = !_modelMeshRenderItems.empty();
|
||||||
|
_renderInfoVertexCount = verticesCount;
|
||||||
|
_renderInfoDrawCalls = _modelMeshRenderItems.count();
|
||||||
|
_renderInfoHasTransparent = hasTransparent;
|
||||||
}
|
}
|
||||||
_addedToScene = addedPendingChanges;
|
_addedToScene = addedPendingChanges;
|
||||||
if (addedPendingChanges) {
|
if (addedPendingChanges) {
|
||||||
|
|
|
@ -232,6 +232,12 @@ public:
|
||||||
|
|
||||||
void setLoadingPriority(float priority) { _loadingPriority = priority; }
|
void setLoadingPriority(float priority) { _loadingPriority = priority; }
|
||||||
|
|
||||||
|
size_t getRenderInfoVertexCount() const { return _renderInfoVertexCount; }
|
||||||
|
int getRenderInfoTextureCount() const { return _renderInfoTextureCount; }
|
||||||
|
size_t getRenderInfoTextureSize();
|
||||||
|
int getRenderInfoDrawCalls() const { return _renderInfoDrawCalls; }
|
||||||
|
bool getRenderInfoHasTransparent() const { return _renderInfoHasTransparent; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadURLFinished(bool success);
|
void loadURLFinished(bool success);
|
||||||
|
|
||||||
|
@ -400,6 +406,13 @@ protected:
|
||||||
|
|
||||||
bool _renderItemsNeedUpdate { false };
|
bool _renderItemsNeedUpdate { false };
|
||||||
|
|
||||||
|
size_t _renderInfoVertexCount { 0 };
|
||||||
|
int _renderInfoTextureCount { 0 };
|
||||||
|
size_t _renderInfoTextureSize { 0 };
|
||||||
|
bool _hasCalculatedTextureSize { false };
|
||||||
|
int _renderInfoDrawCalls { 0 };
|
||||||
|
int _renderInfoHasTransparent { false };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _loadingPriority { 0.0f };
|
float _loadingPriority { 0.0f };
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ void EndGPURangeTimer::run(const render::SceneContextPointer& sceneContext, cons
|
||||||
});
|
});
|
||||||
|
|
||||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||||
config->gpuTime = timer->getAverage();
|
config->setGPUBatchRunTime(timer->getGPUAverage(), timer->getBatchAverage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,18 +29,8 @@ protected:
|
||||||
gpu::RangeTimerPointer _gpuTimer;
|
gpu::RangeTimerPointer _gpuTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using GPURangeTimerConfig = render::GPUJobConfig;
|
||||||
|
|
||||||
class GPURangeTimerConfig : public render::Job::Config {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
|
||||||
public:
|
|
||||||
double getGpuTime() { return gpuTime; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
friend class EndGPURangeTimer;
|
|
||||||
double gpuTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
class EndGPURangeTimer {
|
class EndGPURangeTimer {
|
||||||
public:
|
public:
|
||||||
using Config = GPURangeTimerConfig;
|
using Config = GPURangeTimerConfig;
|
||||||
|
@ -143,16 +133,7 @@ protected:
|
||||||
gpu::PipelinePointer getOpaquePipeline();
|
gpu::PipelinePointer getOpaquePipeline();
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawBackgroundDeferredConfig : public render::Job::Config {
|
using DrawBackgroundDeferredConfig = render::GPUJobConfig;
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
|
||||||
public:
|
|
||||||
double getGpuTime() { return gpuTime; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
friend class DrawBackgroundDeferred;
|
|
||||||
double gpuTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DrawBackgroundDeferred {
|
class DrawBackgroundDeferred {
|
||||||
public:
|
public:
|
||||||
|
@ -211,16 +192,7 @@ public:
|
||||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& srcFramebuffer);
|
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& srcFramebuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderDeferredTaskConfig : public render::Task::Config {
|
using RenderDeferredTaskConfig = render::GPUTaskConfig;
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
|
||||||
public:
|
|
||||||
double getGpuTime() { return gpuTime; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
friend class RenderDeferredTask;
|
|
||||||
double gpuTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
class RenderDeferredTask : public render::Task {
|
class RenderDeferredTask : public render::Task {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -201,7 +201,7 @@ void LinearDepthPass::run(const render::SceneContextPointer& sceneContext, const
|
||||||
});
|
});
|
||||||
|
|
||||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||||
config->gpuTime = _gpuTimer.getAverage();
|
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ void SurfaceGeometryPass::run(const render::SceneContextPointer& sceneContext, c
|
||||||
|
|
||||||
|
|
||||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||||
config->gpuTime = _gpuTimer.getAverage();
|
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,20 +62,7 @@ protected:
|
||||||
|
|
||||||
using LinearDepthFramebufferPointer = std::shared_ptr<LinearDepthFramebuffer>;
|
using LinearDepthFramebufferPointer = std::shared_ptr<LinearDepthFramebuffer>;
|
||||||
|
|
||||||
|
using LinearDepthPassConfig = render::GPUJobConfig;
|
||||||
class LinearDepthPassConfig : public render::Job::Config {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
|
||||||
public:
|
|
||||||
LinearDepthPassConfig() : render::Job::Config(true) {}
|
|
||||||
|
|
||||||
double getGpuTime() { return gpuTime; }
|
|
||||||
|
|
||||||
double gpuTime{ 0.0 };
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void dirty();
|
|
||||||
};
|
|
||||||
|
|
||||||
class LinearDepthPass {
|
class LinearDepthPass {
|
||||||
public:
|
public:
|
||||||
|
@ -148,7 +135,7 @@ protected:
|
||||||
|
|
||||||
using SurfaceGeometryFramebufferPointer = std::shared_ptr<SurfaceGeometryFramebuffer>;
|
using SurfaceGeometryFramebufferPointer = std::shared_ptr<SurfaceGeometryFramebuffer>;
|
||||||
|
|
||||||
class SurfaceGeometryPassConfig : public render::Job::Config {
|
class SurfaceGeometryPassConfig : public render::GPUJobConfig {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(float depthThreshold MEMBER depthThreshold NOTIFY dirty)
|
Q_PROPERTY(float depthThreshold MEMBER depthThreshold NOTIFY dirty)
|
||||||
Q_PROPERTY(float basisScale MEMBER basisScale NOTIFY dirty)
|
Q_PROPERTY(float basisScale MEMBER basisScale NOTIFY dirty)
|
||||||
|
@ -158,9 +145,8 @@ class SurfaceGeometryPassConfig : public render::Job::Config {
|
||||||
Q_PROPERTY(float diffuseFilterScale MEMBER diffuseFilterScale NOTIFY dirty)
|
Q_PROPERTY(float diffuseFilterScale MEMBER diffuseFilterScale NOTIFY dirty)
|
||||||
Q_PROPERTY(float diffuseDepthThreshold MEMBER diffuseDepthThreshold NOTIFY dirty)
|
Q_PROPERTY(float diffuseDepthThreshold MEMBER diffuseDepthThreshold NOTIFY dirty)
|
||||||
|
|
||||||
Q_PROPERTY(double gpuTime READ getGpuTime)
|
|
||||||
public:
|
public:
|
||||||
SurfaceGeometryPassConfig() : render::Job::Config(true) {}
|
SurfaceGeometryPassConfig() : render::GPUJobConfig(true) {}
|
||||||
|
|
||||||
float depthThreshold{ 5.0f }; // centimeters
|
float depthThreshold{ 5.0f }; // centimeters
|
||||||
float basisScale{ 1.0f };
|
float basisScale{ 1.0f };
|
||||||
|
@ -169,10 +155,6 @@ public:
|
||||||
float diffuseFilterScale{ 0.2f };
|
float diffuseFilterScale{ 0.2f };
|
||||||
float diffuseDepthThreshold{ 1.0f };
|
float diffuseDepthThreshold{ 1.0f };
|
||||||
|
|
||||||
double getGpuTime() { return gpuTime; }
|
|
||||||
|
|
||||||
double gpuTime{ 0.0 };
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
};
|
};
|
||||||
|
|
|
@ -334,9 +334,9 @@ protected:
|
||||||
// A default Config is always on; to create an enableable Config, use the ctor JobConfig(bool enabled)
|
// A default Config is always on; to create an enableable Config, use the ctor JobConfig(bool enabled)
|
||||||
class JobConfig : public QObject {
|
class JobConfig : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(quint64 cpuRunTime READ getCPUTRunTime NOTIFY newStats())
|
Q_PROPERTY(double cpuRunTime READ getCPURunTime NOTIFY newStats()) //ms
|
||||||
|
|
||||||
quint64 _CPURunTime{ 0 };
|
double _msCPURunTime{ 0.0 };
|
||||||
public:
|
public:
|
||||||
using Persistent = PersistentConfig<JobConfig>;
|
using Persistent = PersistentConfig<JobConfig>;
|
||||||
|
|
||||||
|
@ -364,8 +364,8 @@ public:
|
||||||
|
|
||||||
// Running Time measurement
|
// Running Time measurement
|
||||||
// The new stats signal is emitted once per run time of a job when stats (cpu runtime) are updated
|
// The new stats signal is emitted once per run time of a job when stats (cpu runtime) are updated
|
||||||
void setCPURunTime(quint64 ustime) { _CPURunTime = ustime; emit newStats(); }
|
void setCPURunTime(double mstime) { _msCPURunTime = mstime; emit newStats(); }
|
||||||
quint64 getCPUTRunTime() const { return _CPURunTime; }
|
double getCPURunTime() const { return _msCPURunTime; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); }
|
void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); }
|
||||||
|
@ -418,6 +418,46 @@ template <class T, class I, class O> void jobRun(T& data, const SceneContextPoin
|
||||||
data.run(sceneContext, renderContext, input, output);
|
data.run(sceneContext, renderContext, input, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GPUJobConfig : public JobConfig {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(double gpuRunTime READ getGPURunTime)
|
||||||
|
Q_PROPERTY(double batchRunTime READ getBatchRunTime)
|
||||||
|
|
||||||
|
double _msGPURunTime { 0.0 };
|
||||||
|
double _msBatchRunTime { 0.0 };
|
||||||
|
public:
|
||||||
|
using Persistent = PersistentConfig<GPUJobConfig>;
|
||||||
|
|
||||||
|
GPUJobConfig() = default;
|
||||||
|
GPUJobConfig(bool enabled) : JobConfig(enabled) {}
|
||||||
|
|
||||||
|
// Running Time measurement on GPU and for Batch execution
|
||||||
|
void setGPUBatchRunTime(double msGpuTime, double msBatchTime) { _msGPURunTime = msGpuTime; _msBatchRunTime = msBatchTime; }
|
||||||
|
double getGPURunTime() const { return _msGPURunTime; }
|
||||||
|
double getBatchRunTime() const { return _msBatchRunTime; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class GPUTaskConfig : public TaskConfig {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(double gpuRunTime READ getGPURunTime)
|
||||||
|
Q_PROPERTY(double batchRunTime READ getBatchRunTime)
|
||||||
|
|
||||||
|
double _msGPURunTime { 0.0 };
|
||||||
|
double _msBatchRunTime { 0.0 };
|
||||||
|
public:
|
||||||
|
|
||||||
|
using Persistent = PersistentConfig<GPUTaskConfig>;
|
||||||
|
|
||||||
|
|
||||||
|
GPUTaskConfig() = default;
|
||||||
|
GPUTaskConfig(bool enabled) : TaskConfig(enabled) {}
|
||||||
|
|
||||||
|
// Running Time measurement on GPU and for Batch execution
|
||||||
|
void setGPUBatchRunTime(double msGpuTime, double msBatchTime) { _msGPURunTime = msGpuTime; _msBatchRunTime = msBatchTime; }
|
||||||
|
double getGPURunTime() const { return _msGPURunTime; }
|
||||||
|
double getBatchRunTime() const { return _msBatchRunTime; }
|
||||||
|
};
|
||||||
|
|
||||||
class Job {
|
class Job {
|
||||||
public:
|
public:
|
||||||
using Config = JobConfig;
|
using Config = JobConfig;
|
||||||
|
@ -439,7 +479,7 @@ public:
|
||||||
virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) = 0;
|
virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setCPURunTime(quint64 ustime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(ustime); }
|
void setCPURunTime(double mstime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(mstime); }
|
||||||
|
|
||||||
QConfigPointer _config;
|
QConfigPointer _config;
|
||||||
|
|
||||||
|
@ -502,7 +542,7 @@ public:
|
||||||
|
|
||||||
_concept->run(sceneContext, renderContext);
|
_concept->run(sceneContext, renderContext);
|
||||||
|
|
||||||
_concept->setCPURunTime(usecTimestampNow() - start);
|
_concept->setCPURunTime((double)(usecTimestampNow() - start) / 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -37,49 +37,92 @@ var DEFAULT_SCRIPTS = [
|
||||||
// add a menu item for debugging
|
// add a menu item for debugging
|
||||||
var MENU_CATEGORY = "Developer";
|
var MENU_CATEGORY = "Developer";
|
||||||
var MENU_ITEM = "Debug defaultScripts.js";
|
var MENU_ITEM = "Debug defaultScripts.js";
|
||||||
var debuggingDefaultScripts = false;
|
|
||||||
|
var SETTINGS_KEY = '_debugDefaultScriptsIsChecked';
|
||||||
|
var previousSetting = Settings.getValue(SETTINGS_KEY);
|
||||||
|
|
||||||
|
if (previousSetting === '' || previousSetting === false || previousSetting === 'false') {
|
||||||
|
previousSetting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousSetting === true || previousSetting === 'true') {
|
||||||
|
previousSetting = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_ITEM)) {
|
if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_ITEM)) {
|
||||||
Menu.addMenuItem({
|
Menu.addMenuItem({
|
||||||
menuName: MENU_CATEGORY,
|
menuName: MENU_CATEGORY,
|
||||||
menuItemName: MENU_ITEM,
|
menuItemName: MENU_ITEM,
|
||||||
isCheckable: true,
|
isCheckable: true,
|
||||||
isChecked: false,
|
isChecked: previousSetting,
|
||||||
grouping: "Advanced"
|
grouping: "Advanced"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// start all scripts
|
function runDefaultsTogether() {
|
||||||
if (Menu.isOptionChecked(MENU_ITEM)) {
|
|
||||||
// we're debugging individual default scripts
|
|
||||||
// so we load each into its own ScriptEngine instance
|
|
||||||
debuggingDefaultScripts = true;
|
|
||||||
for (var i in DEFAULT_SCRIPTS) {
|
|
||||||
Script.load(DEFAULT_SCRIPTS[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// include all default scripts into this ScriptEngine
|
|
||||||
for (var j in DEFAULT_SCRIPTS) {
|
for (var j in DEFAULT_SCRIPTS) {
|
||||||
Script.include(DEFAULT_SCRIPTS[j]);
|
Script.include(DEFAULT_SCRIPTS[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopLoadedScripts() {
|
function runDefaultsSeparately() {
|
||||||
if (debuggingDefaultScripts) {
|
for (var i in DEFAULT_SCRIPTS) {
|
||||||
// remove debug script loads
|
Script.load(DEFAULT_SCRIPTS[i]);
|
||||||
var runningScripts = ScriptDiscoveryService.getRunning();
|
}
|
||||||
for (var i in runningScripts) {
|
}
|
||||||
var scriptName = runningScripts[i].name;
|
// start all scripts
|
||||||
for (var j in DEFAULT_SCRIPTS) {
|
if (Menu.isOptionChecked(MENU_ITEM)) {
|
||||||
if (DEFAULT_SCRIPTS[j].slice(-scriptName.length) === scriptName) {
|
// we're debugging individual default scripts
|
||||||
ScriptDiscoveryService.stopScript(runningScripts[i].url);
|
// so we load each into its own ScriptEngine instance
|
||||||
}
|
debuggingDefaultScripts = true;
|
||||||
}
|
runDefaultsSeparately();
|
||||||
|
} else {
|
||||||
|
// include all default scripts into this ScriptEngine
|
||||||
|
runDefaultsTogether();
|
||||||
|
}
|
||||||
|
|
||||||
|
function menuItemEvent(menuItem) {
|
||||||
|
if (menuItem == MENU_ITEM) {
|
||||||
|
|
||||||
|
isChecked = Menu.isOptionChecked(MENU_ITEM);
|
||||||
|
if (isChecked === true) {
|
||||||
|
Settings.setValue(SETTINGS_KEY, true);
|
||||||
|
} else if (isChecked === false) {
|
||||||
|
Settings.setValue(SETTINGS_KEY, false);
|
||||||
}
|
}
|
||||||
if (!Menu.isOptionChecked(MENU_ITEM)) {
|
Window.alert('You must reload all scripts for this to take effect.')
|
||||||
Menu.removeMenuItem(MENU_CATEGORY, MENU_ITEM);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function stopLoadedScripts() {
|
||||||
|
// remove debug script loads
|
||||||
|
var runningScripts = ScriptDiscoveryService.getRunning();
|
||||||
|
for (var i in runningScripts) {
|
||||||
|
var scriptName = runningScripts[i].name;
|
||||||
|
for (var j in DEFAULT_SCRIPTS) {
|
||||||
|
if (DEFAULT_SCRIPTS[j].slice(-scriptName.length) === scriptName) {
|
||||||
|
ScriptDiscoveryService.stopScript(runningScripts[i].url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(stopLoadedScripts);
|
function removeMenuItem() {
|
||||||
|
if (!Menu.isOptionChecked(MENU_ITEM)) {
|
||||||
|
Menu.removeMenuItem(MENU_CATEGORY, MENU_ITEM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(function() {
|
||||||
|
stopLoadedScripts();
|
||||||
|
removeMenuItem();
|
||||||
|
});
|
||||||
|
|
||||||
|
Menu.menuItemEvent.connect(menuItemEvent);
|
|
@ -75,10 +75,10 @@ Column {
|
||||||
object: Render.getConfig("AmbientOcclusion")
|
object: Render.getConfig("AmbientOcclusion")
|
||||||
valueUnit: "ms"
|
valueUnit: "ms"
|
||||||
valueScale: 1
|
valueScale: 1
|
||||||
valueNumDigits: "4"
|
valueNumDigits: "3"
|
||||||
plots: [
|
plots: [
|
||||||
{
|
{
|
||||||
prop: "gpuTime",
|
prop: "gpuRunTime",
|
||||||
label: "gpu",
|
label: "gpu",
|
||||||
color: "#FFFFFF"
|
color: "#FFFFFF"
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,8 +213,8 @@ Item {
|
||||||
height: parent.evalEvenHeight()
|
height: parent.evalEvenHeight()
|
||||||
object: parent.drawOpaqueConfig
|
object: parent.drawOpaqueConfig
|
||||||
valueUnit: "ms"
|
valueUnit: "ms"
|
||||||
valueScale: 1000
|
valueScale: 1
|
||||||
valueNumDigits: "1"
|
valueNumDigits: "2"
|
||||||
plots: [
|
plots: [
|
||||||
{
|
{
|
||||||
object: Render.getConfig("DrawOpaqueDeferred"),
|
object: Render.getConfig("DrawOpaqueDeferred"),
|
||||||
|
|
|
@ -30,7 +30,7 @@ Item {
|
||||||
|
|
||||||
|
|
||||||
PlotPerf {
|
PlotPerf {
|
||||||
title: "Timing"
|
title: "GPU Timing"
|
||||||
height: parent.evalEvenHeight()
|
height: parent.evalEvenHeight()
|
||||||
object: parent.drawOpaqueConfig
|
object: parent.drawOpaqueConfig
|
||||||
valueUnit: "ms"
|
valueUnit: "ms"
|
||||||
|
@ -39,31 +39,71 @@ Item {
|
||||||
plots: [
|
plots: [
|
||||||
{
|
{
|
||||||
object: Render.getConfig("OpaqueRangeTimer"),
|
object: Render.getConfig("OpaqueRangeTimer"),
|
||||||
prop: "gpuTime",
|
prop: "gpuRunTime",
|
||||||
label: "Opaque",
|
label: "Opaque",
|
||||||
color: "#FFFFFF"
|
color: "#FFFFFF"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
object: Render.getConfig("LinearDepth"),
|
object: Render.getConfig("LinearDepth"),
|
||||||
prop: "gpuTime",
|
prop: "gpuRunTime",
|
||||||
label: "LinearDepth",
|
label: "LinearDepth",
|
||||||
color: "#00FF00"
|
color: "#00FF00"
|
||||||
},{
|
},{
|
||||||
object: Render.getConfig("SurfaceGeometry"),
|
object: Render.getConfig("SurfaceGeometry"),
|
||||||
prop: "gpuTime",
|
prop: "gpuRunTime",
|
||||||
label: "SurfaceGeometry",
|
label: "SurfaceGeometry",
|
||||||
color: "#00FFFF"
|
color: "#00FFFF"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
object: Render.getConfig("RenderDeferred"),
|
object: Render.getConfig("RenderDeferred"),
|
||||||
prop: "gpuTime",
|
prop: "gpuRunTime",
|
||||||
label: "DeferredLighting",
|
label: "DeferredLighting",
|
||||||
color: "#FF00FF"
|
color: "#FF00FF"
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
{
|
{
|
||||||
object: Render.getConfig("ToneAndPostRangeTimer"),
|
object: Render.getConfig("ToneAndPostRangeTimer"),
|
||||||
prop: "gpuTime",
|
prop: "gpuRunTime",
|
||||||
|
label: "tone and post",
|
||||||
|
color: "#FF0000"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
PlotPerf {
|
||||||
|
title: "Batch Timing"
|
||||||
|
height: parent.evalEvenHeight()
|
||||||
|
object: parent.drawOpaqueConfig
|
||||||
|
valueUnit: "ms"
|
||||||
|
valueScale: 1
|
||||||
|
valueNumDigits: "3"
|
||||||
|
plots: [
|
||||||
|
{
|
||||||
|
object: Render.getConfig("OpaqueRangeTimer"),
|
||||||
|
prop: "batchRunTime",
|
||||||
|
label: "Opaque",
|
||||||
|
color: "#FFFFFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
object: Render.getConfig("LinearDepth"),
|
||||||
|
prop: "batchRunTime",
|
||||||
|
label: "LinearDepth",
|
||||||
|
color: "#00FF00"
|
||||||
|
},{
|
||||||
|
object: Render.getConfig("SurfaceGeometry"),
|
||||||
|
prop: "batchRunTime",
|
||||||
|
label: "SurfaceGeometry",
|
||||||
|
color: "#00FFFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
object: Render.getConfig("RenderDeferred"),
|
||||||
|
prop: "batchRunTime",
|
||||||
|
label: "DeferredLighting",
|
||||||
|
color: "#FF00FF"
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
object: Render.getConfig("ToneAndPostRangeTimer"),
|
||||||
|
prop: "batchRunTime",
|
||||||
label: "tone and post",
|
label: "tone and post",
|
||||||
color: "#FF0000"
|
color: "#FF0000"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
/* global setEntityCustomData, getEntityCustomData, vec3toStr, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, Reticle, Controller, Camera, Messages, Mat4 */
|
/* global setEntityCustomData, getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, Reticle, Controller, Camera, Messages, Mat4 */
|
||||||
|
|
||||||
(function() { // BEGIN LOCAL_SCOPE
|
(function() { // BEGIN LOCAL_SCOPE
|
||||||
|
|
||||||
|
@ -137,6 +137,12 @@ var ZERO_VEC = {
|
||||||
z: 0
|
z: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var ONE_VEC = {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
};
|
||||||
|
|
||||||
var NULL_UUID = "{00000000-0000-0000-0000-000000000000}";
|
var NULL_UUID = "{00000000-0000-0000-0000-000000000000}";
|
||||||
|
|
||||||
// these control how long an abandoned pointer line or action will hang around
|
// these control how long an abandoned pointer line or action will hang around
|
||||||
|
@ -243,6 +249,25 @@ CONTROLLER_STATE_MACHINE[STATE_ENTITY_TOUCHING] = {
|
||||||
updateMethod: "entityTouching"
|
updateMethod: "entityTouching"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function distanceBetweenPointAndEntityBoundingBox(point, entityProps) {
|
||||||
|
var entityXform = new Xform(entityProps.rotation, entityProps.position);
|
||||||
|
var localPoint = entityXform.inv().xformPoint(point);
|
||||||
|
var minOffset = Vec3.multiplyVbyV(entityProps.registrationPoint, entityProps.dimensions);
|
||||||
|
var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions);
|
||||||
|
var localMin = Vec3.subtract(entityXform.trans, minOffset);
|
||||||
|
var localMax = Vec3.sum(entityXform.trans, maxOffset);
|
||||||
|
|
||||||
|
var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z};
|
||||||
|
v.x = Math.max(v.x, localMin.x);
|
||||||
|
v.x = Math.min(v.x, localMax.x);
|
||||||
|
v.y = Math.max(v.y, localMin.y);
|
||||||
|
v.y = Math.min(v.y, localMax.y);
|
||||||
|
v.z = Math.max(v.z, localMin.z);
|
||||||
|
v.z = Math.min(v.z, localMax.z);
|
||||||
|
|
||||||
|
return Vec3.distance(v, localPoint);
|
||||||
|
}
|
||||||
|
|
||||||
function angleBetween(a, b) {
|
function angleBetween(a, b) {
|
||||||
return Math.acos(Vec3.dot(Vec3.normalize(a), Vec3.normalize(b)));
|
return Math.acos(Vec3.dot(Vec3.normalize(a), Vec3.normalize(b)));
|
||||||
}
|
}
|
||||||
|
@ -417,18 +442,6 @@ function removeMyAvatarFromCollidesWith(origCollidesWith) {
|
||||||
return collidesWithSplit.join();
|
return collidesWithSplit.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeAvatarsFromCollidesWith(origCollidesWith) {
|
|
||||||
var collidesWithSplit = origCollidesWith.split(",");
|
|
||||||
// remove myAvatar from the array
|
|
||||||
for (var i = collidesWithSplit.length - 1; i >= 0; i--) {
|
|
||||||
if (collidesWithSplit[i] === "myAvatar" || collidesWithSplit[i] === "otherAvatar") {
|
|
||||||
collidesWithSplit.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return collidesWithSplit.join();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// If another script is managing the reticle (as is done by HandControllerPointer), we should not be setting it here,
|
// If another script is managing the reticle (as is done by HandControllerPointer), we should not be setting it here,
|
||||||
// and we should not be showing lasers when someone else is using the Reticle to indicate a 2D minor mode.
|
// and we should not be showing lasers when someone else is using the Reticle to indicate a 2D minor mode.
|
||||||
var EXTERNALLY_MANAGED_2D_MINOR_MODE = true;
|
var EXTERNALLY_MANAGED_2D_MINOR_MODE = true;
|
||||||
|
@ -2056,7 +2069,8 @@ function MyController(hand) {
|
||||||
this.heartBeat(this.grabbedEntity);
|
this.heartBeat(this.grabbedEntity);
|
||||||
|
|
||||||
var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID",
|
var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID",
|
||||||
"position", "rotation", "dimensions"]);
|
"position", "rotation", "dimensions",
|
||||||
|
"registrationPoint"]);
|
||||||
if (!props.position) {
|
if (!props.position) {
|
||||||
// server may have reset, taking our equipped entity with it. move back to "off" state
|
// server may have reset, taking our equipped entity with it. move back to "off" state
|
||||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||||
|
@ -2069,34 +2083,25 @@ function MyController(hand) {
|
||||||
this.lastUnequipCheckTime = now;
|
this.lastUnequipCheckTime = now;
|
||||||
|
|
||||||
if (props.parentID == MyAvatar.sessionUUID) {
|
if (props.parentID == MyAvatar.sessionUUID) {
|
||||||
var heldItemPosition;
|
var handPosition;
|
||||||
var heldItemRotation;
|
|
||||||
if (this.ignoreIK) {
|
if (this.ignoreIK) {
|
||||||
var heldItemLocation = this.getControllerLocation(false);
|
handPosition = this.getControllerLocation(false).position;
|
||||||
heldItemPosition = heldItemLocation.position;
|
|
||||||
heldItemRotation = heldItemLocation.orientation;
|
|
||||||
} else {
|
} else {
|
||||||
heldItemPosition = this.getHandPosition();
|
handPosition = this.getHandPosition();
|
||||||
heldItemRotation = this.getHandRotation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// figure out where the center of the held object should be
|
var TEAR_AWAY_DISTANCE = 0.1;
|
||||||
heldItemPosition = Vec3.sum(heldItemPosition, Vec3.multiplyQbyV(heldItemRotation, this.offsetPosition));
|
var dist = distanceBetweenPointAndEntityBoundingBox(handPosition, props);
|
||||||
|
if (dist > TEAR_AWAY_DISTANCE) {
|
||||||
// the center of the equipped object being far from the hand isn't enough to auto-unequip -- we also
|
|
||||||
// need to fail the findEntities test.
|
|
||||||
var TEAR_AWAY_DISTANCE = 0.04;
|
|
||||||
var nearPickedCandidateEntities = Entities.findEntities(heldItemPosition, NEAR_GRAB_RADIUS + TEAR_AWAY_DISTANCE);
|
|
||||||
if (nearPickedCandidateEntities.indexOf(this.grabbedEntity) == -1) {
|
|
||||||
this.autoUnequipCounter += 1;
|
this.autoUnequipCounter += 1;
|
||||||
} else {
|
} else {
|
||||||
this.autoUnequipCounter = 0;
|
this.autoUnequipCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.autoUnequipCounter > 1) {
|
if (this.autoUnequipCounter > 1) {
|
||||||
// for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip.
|
// for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip.
|
||||||
print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." +
|
print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." +
|
||||||
props.parentID + " " + vec3toStr(props.position));
|
props.parentID + ", dist = " + dist);
|
||||||
|
|
||||||
if (this.state == STATE_NEAR_GRABBING) {
|
if (this.state == STATE_NEAR_GRABBING) {
|
||||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
var RAD_TO_DEG = 180 / Math.PI;
|
var RAD_TO_DEG = 180 / Math.PI;
|
||||||
var X_AXIS = {x: 1, y: 0, z: 0};
|
var X_AXIS = {x: 1, y: 0, z: 0};
|
||||||
var Y_AXIS = {x: 0, y: 1, z: 0};
|
var Y_AXIS = {x: 0, y: 1, z: 0};
|
||||||
|
var DEFAULT_DPI = 30;
|
||||||
|
var DEFAULT_WIDTH = 0.5;
|
||||||
|
|
||||||
var TABLET_URL = "https://s3.amazonaws.com/hifi-public/tony/tablet.fbx";
|
var TABLET_URL = "https://s3.amazonaws.com/hifi-public/tony/tablet.fbx";
|
||||||
|
|
||||||
|
@ -37,12 +39,13 @@ function calcSpawnInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ctor
|
// ctor
|
||||||
WebTablet = function (url) {
|
WebTablet = function (url, width, dpi) {
|
||||||
|
|
||||||
var ASPECT = 4.0 / 3.0;
|
var ASPECT = 4.0 / 3.0;
|
||||||
var WIDTH = 0.4;
|
var WIDTH = width || DEFAULT_WIDTH;
|
||||||
var HEIGHT = WIDTH * ASPECT;
|
var HEIGHT = WIDTH * ASPECT;
|
||||||
var DEPTH = 0.025;
|
var DEPTH = 0.025;
|
||||||
|
var DPI = dpi || DEFAULT_DPI;
|
||||||
|
|
||||||
var spawnInfo = calcSpawnInfo();
|
var spawnInfo = calcSpawnInfo();
|
||||||
|
|
||||||
|
@ -78,7 +81,7 @@ WebTablet = function (url) {
|
||||||
position: webEntityPosition,
|
position: webEntityPosition,
|
||||||
rotation: webEntityRotation,
|
rotation: webEntityRotation,
|
||||||
shapeType: "box",
|
shapeType: "box",
|
||||||
dpi: 45,
|
dpi: DPI,
|
||||||
parentID: this.tabletEntityID,
|
parentID: this.tabletEntityID,
|
||||||
parentJointIndex: -1
|
parentJointIndex: -1
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue