mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:08:47 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into textToSpeech
This commit is contained in:
commit
41742aaf9e
20 changed files with 281 additions and 64 deletions
|
@ -8484,6 +8484,16 @@ QUuid Application::getTabletFrameID() const {
|
||||||
return HMD->getCurrentTabletFrameID();
|
return HMD->getCurrentTabletFrameID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QUuid> Application::getTabletIDs() const {
|
||||||
|
// Most important overlays first.
|
||||||
|
QVector<QUuid> result;
|
||||||
|
auto HMD = DependencyManager::get<HMDScriptingInterface>();
|
||||||
|
result << HMD->getCurrentTabletScreenID();
|
||||||
|
result << HMD->getCurrentHomeButtonID();
|
||||||
|
result << HMD->getCurrentTabletFrameID();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void Application::setAvatarOverrideUrl(const QUrl& url, bool save) {
|
void Application::setAvatarOverrideUrl(const QUrl& url, bool save) {
|
||||||
_avatarOverrideUrl = url;
|
_avatarOverrideUrl = url;
|
||||||
_saveAvatarOverrideUrl = save;
|
_saveAvatarOverrideUrl = save;
|
||||||
|
|
|
@ -298,6 +298,7 @@ public:
|
||||||
OverlayID getTabletScreenID() const;
|
OverlayID getTabletScreenID() const;
|
||||||
OverlayID getTabletHomeButtonID() const;
|
OverlayID getTabletHomeButtonID() const;
|
||||||
QUuid getTabletFrameID() const; // may be an entity or an overlay
|
QUuid getTabletFrameID() const; // may be an entity or an overlay
|
||||||
|
QVector<QUuid> getTabletIDs() const; // In order of most important IDs first.
|
||||||
|
|
||||||
void setAvatarOverrideUrl(const QUrl& url, bool save);
|
void setAvatarOverrideUrl(const QUrl& url, bool save);
|
||||||
void clearAvatarOverrideUrl() { _avatarOverrideUrl = QUrl(); _saveAvatarOverrideUrl = false; }
|
void clearAvatarOverrideUrl() { _avatarOverrideUrl = QUrl(); _saveAvatarOverrideUrl = false; }
|
||||||
|
|
|
@ -532,6 +532,8 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionVector(const PickRay
|
||||||
bool visibleOnly, bool collidableOnly) {
|
bool visibleOnly, bool collidableOnly) {
|
||||||
float bestDistance = std::numeric_limits<float>::max();
|
float bestDistance = std::numeric_limits<float>::max();
|
||||||
bool bestIsFront = false;
|
bool bestIsFront = false;
|
||||||
|
bool bestIsTablet = false;
|
||||||
|
auto tabletIDs = qApp->getTabletIDs();
|
||||||
|
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
RayToOverlayIntersectionResult result;
|
RayToOverlayIntersectionResult result;
|
||||||
|
@ -554,10 +556,11 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionVector(const PickRay
|
||||||
if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance,
|
if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance,
|
||||||
thisFace, thisSurfaceNormal, thisExtraInfo, precisionPicking)) {
|
thisFace, thisSurfaceNormal, thisExtraInfo, precisionPicking)) {
|
||||||
bool isDrawInFront = thisOverlay->getDrawInFront();
|
bool isDrawInFront = thisOverlay->getDrawInFront();
|
||||||
if ((bestIsFront && isDrawInFront && thisDistance < bestDistance)
|
bool isTablet = tabletIDs.contains(thisID);
|
||||||
|| (!bestIsFront && (isDrawInFront || thisDistance < bestDistance))) {
|
if ((isDrawInFront && !bestIsFront && !bestIsTablet)
|
||||||
|
|| ((isTablet || isDrawInFront || !bestIsFront) && thisDistance < bestDistance)) {
|
||||||
bestIsFront = isDrawInFront;
|
bestIsFront = isDrawInFront;
|
||||||
|
bestIsTablet = isTablet;
|
||||||
bestDistance = thisDistance;
|
bestDistance = thisDistance;
|
||||||
result.intersects = true;
|
result.intersects = true;
|
||||||
result.distance = thisDistance;
|
result.distance = thisDistance;
|
||||||
|
@ -828,40 +831,12 @@ PointerEvent Overlays::calculateOverlayPointerEvent(OverlayID overlayID, PickRay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RayToOverlayIntersectionResult Overlays::findRayIntersectionForMouseEvent(PickRay ray) {
|
|
||||||
QVector<OverlayID> overlaysToInclude;
|
|
||||||
QVector<OverlayID> overlaysToDiscard;
|
|
||||||
RayToOverlayIntersectionResult rayPickResult;
|
|
||||||
|
|
||||||
// first priority is tablet screen
|
|
||||||
overlaysToInclude << qApp->getTabletScreenID();
|
|
||||||
rayPickResult = findRayIntersectionVector(ray, true, overlaysToInclude, overlaysToDiscard);
|
|
||||||
if (rayPickResult.intersects) {
|
|
||||||
return rayPickResult;
|
|
||||||
}
|
|
||||||
// then tablet home button
|
|
||||||
overlaysToInclude.clear();
|
|
||||||
overlaysToInclude << qApp->getTabletHomeButtonID();
|
|
||||||
rayPickResult = findRayIntersectionVector(ray, true, overlaysToInclude, overlaysToDiscard);
|
|
||||||
if (rayPickResult.intersects) {
|
|
||||||
return rayPickResult;
|
|
||||||
}
|
|
||||||
// then tablet frame
|
|
||||||
overlaysToInclude.clear();
|
|
||||||
overlaysToInclude << OverlayID(qApp->getTabletFrameID());
|
|
||||||
rayPickResult = findRayIntersectionVector(ray, true, overlaysToInclude, overlaysToDiscard);
|
|
||||||
if (rayPickResult.intersects) {
|
|
||||||
return rayPickResult;
|
|
||||||
}
|
|
||||||
// then whatever
|
|
||||||
return findRayIntersection(ray);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Overlays::mousePressEvent(QMouseEvent* event) {
|
bool Overlays::mousePressEvent(QMouseEvent* event) {
|
||||||
PerformanceTimer perfTimer("Overlays::mousePressEvent");
|
PerformanceTimer perfTimer("Overlays::mousePressEvent");
|
||||||
|
|
||||||
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||||
RayToOverlayIntersectionResult rayPickResult = findRayIntersectionForMouseEvent(ray);
|
RayToOverlayIntersectionResult rayPickResult = findRayIntersectionVector(ray, true, QVector<OverlayID>(),
|
||||||
|
QVector<OverlayID>());
|
||||||
if (rayPickResult.intersects) {
|
if (rayPickResult.intersects) {
|
||||||
_currentClickingOnOverlayID = rayPickResult.overlayID;
|
_currentClickingOnOverlayID = rayPickResult.overlayID;
|
||||||
|
|
||||||
|
@ -901,7 +876,8 @@ bool Overlays::mouseDoublePressEvent(QMouseEvent* event) {
|
||||||
PerformanceTimer perfTimer("Overlays::mouseDoublePressEvent");
|
PerformanceTimer perfTimer("Overlays::mouseDoublePressEvent");
|
||||||
|
|
||||||
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||||
RayToOverlayIntersectionResult rayPickResult = findRayIntersectionForMouseEvent(ray);
|
RayToOverlayIntersectionResult rayPickResult = findRayIntersectionVector(ray, true, QVector<OverlayID>(),
|
||||||
|
QVector<OverlayID>());
|
||||||
if (rayPickResult.intersects) {
|
if (rayPickResult.intersects) {
|
||||||
_currentClickingOnOverlayID = rayPickResult.overlayID;
|
_currentClickingOnOverlayID = rayPickResult.overlayID;
|
||||||
|
|
||||||
|
@ -964,7 +940,8 @@ bool Overlays::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
PerformanceTimer perfTimer("Overlays::mouseReleaseEvent");
|
PerformanceTimer perfTimer("Overlays::mouseReleaseEvent");
|
||||||
|
|
||||||
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||||
RayToOverlayIntersectionResult rayPickResult = findRayIntersectionForMouseEvent(ray);
|
RayToOverlayIntersectionResult rayPickResult = findRayIntersectionVector(ray, true, QVector<OverlayID>(),
|
||||||
|
QVector<OverlayID>());
|
||||||
if (rayPickResult.intersects) {
|
if (rayPickResult.intersects) {
|
||||||
auto pointerEvent = calculateOverlayPointerEvent(rayPickResult.overlayID, ray, rayPickResult, event, PointerEvent::Release);
|
auto pointerEvent = calculateOverlayPointerEvent(rayPickResult.overlayID, ray, rayPickResult, event, PointerEvent::Release);
|
||||||
mouseReleasePointerEvent(rayPickResult.overlayID, pointerEvent);
|
mouseReleasePointerEvent(rayPickResult.overlayID, pointerEvent);
|
||||||
|
@ -993,7 +970,8 @@ bool Overlays::mouseMoveEvent(QMouseEvent* event) {
|
||||||
PerformanceTimer perfTimer("Overlays::mouseMoveEvent");
|
PerformanceTimer perfTimer("Overlays::mouseMoveEvent");
|
||||||
|
|
||||||
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||||
RayToOverlayIntersectionResult rayPickResult = findRayIntersectionForMouseEvent(ray);
|
RayToOverlayIntersectionResult rayPickResult = findRayIntersectionVector(ray, true, QVector<OverlayID>(),
|
||||||
|
QVector<OverlayID>());
|
||||||
if (rayPickResult.intersects) {
|
if (rayPickResult.intersects) {
|
||||||
auto pointerEvent = calculateOverlayPointerEvent(rayPickResult.overlayID, ray, rayPickResult, event, PointerEvent::Move);
|
auto pointerEvent = calculateOverlayPointerEvent(rayPickResult.overlayID, ray, rayPickResult, event, PointerEvent::Move);
|
||||||
mouseMovePointerEvent(rayPickResult.overlayID, pointerEvent);
|
mouseMovePointerEvent(rayPickResult.overlayID, pointerEvent);
|
||||||
|
|
|
@ -44,8 +44,7 @@ void OverlayPropertyResultFromScriptValue(const QScriptValue& object, OverlayPro
|
||||||
const OverlayID UNKNOWN_OVERLAY_ID = OverlayID();
|
const OverlayID UNKNOWN_OVERLAY_ID = OverlayID();
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* The result of a {@link PickRay} search using {@link Overlays.findRayIntersection|findRayIntersection} or
|
* The result of a {@link PickRay} search using {@link Overlays.findRayIntersection|findRayIntersection}.
|
||||||
* {@link Overlays.findRayIntersectionVector|findRayIntersectionVector}.
|
|
||||||
* @typedef {object} Overlays.RayToOverlayIntersectionResult
|
* @typedef {object} Overlays.RayToOverlayIntersectionResult
|
||||||
* @property {boolean} intersects - <code>true</code> if the {@link PickRay} intersected with a 3D overlay, otherwise
|
* @property {boolean} intersects - <code>true</code> if the {@link PickRay} intersected with a 3D overlay, otherwise
|
||||||
* <code>false</code>.
|
* <code>false</code>.
|
||||||
|
@ -383,7 +382,11 @@ public slots:
|
||||||
OverlayPropertyResult getOverlaysProperties(const QVariant& overlaysProperties);
|
OverlayPropertyResult getOverlaysProperties(const QVariant& overlaysProperties);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Find the closest 3D overlay intersected by a {@link PickRay}.
|
* Find the closest 3D overlay intersected by a {@link PickRay}. Overlays with their <code>drawInFront</code> property set
|
||||||
|
* to <code>true</code> have priority over overlays that don't, except that tablet overlays have priority over any
|
||||||
|
* <code>drawInFront</code> overlays behind them. I.e., if a <code>drawInFront</code> overlay is behind one that isn't
|
||||||
|
* <code>drawInFront</code>, the <code>drawInFront</code> overlay is returned, but if a tablet overlay is in front of a
|
||||||
|
* <code>drawInFront</code> overlay, the tablet overlay is returned.
|
||||||
* @function Overlays.findRayIntersection
|
* @function Overlays.findRayIntersection
|
||||||
* @param {PickRay} pickRay - The PickRay to use for finding overlays.
|
* @param {PickRay} pickRay - The PickRay to use for finding overlays.
|
||||||
* @param {boolean} [precisionPicking=false] - <em>Unused</em>; exists to match Entity API.
|
* @param {boolean} [precisionPicking=false] - <em>Unused</em>; exists to match Entity API.
|
||||||
|
@ -750,8 +753,6 @@ private:
|
||||||
OverlayID _currentClickingOnOverlayID { UNKNOWN_OVERLAY_ID };
|
OverlayID _currentClickingOnOverlayID { UNKNOWN_OVERLAY_ID };
|
||||||
OverlayID _currentHoverOverOverlayID { UNKNOWN_OVERLAY_ID };
|
OverlayID _currentHoverOverOverlayID { UNKNOWN_OVERLAY_ID };
|
||||||
|
|
||||||
RayToOverlayIntersectionResult findRayIntersectionForMouseEvent(PickRay ray);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void mousePressPointerEvent(const OverlayID& overlayID, const PointerEvent& event);
|
void mousePressPointerEvent(const OverlayID& overlayID, const PointerEvent& event);
|
||||||
void mouseMovePointerEvent(const OverlayID& overlayID, const PointerEvent& event);
|
void mouseMovePointerEvent(const OverlayID& overlayID, const PointerEvent& event);
|
||||||
|
|
|
@ -67,6 +67,7 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] =
|
||||||
(&::gpu::gl::GLBackend::do_clearFramebuffer),
|
(&::gpu::gl::GLBackend::do_clearFramebuffer),
|
||||||
(&::gpu::gl::GLBackend::do_blit),
|
(&::gpu::gl::GLBackend::do_blit),
|
||||||
(&::gpu::gl::GLBackend::do_generateTextureMips),
|
(&::gpu::gl::GLBackend::do_generateTextureMips),
|
||||||
|
(&::gpu::gl::GLBackend::do_generateTextureMipsWithPipeline),
|
||||||
|
|
||||||
(&::gpu::gl::GLBackend::do_advance),
|
(&::gpu::gl::GLBackend::do_advance),
|
||||||
|
|
||||||
|
@ -166,6 +167,10 @@ GLBackend::GLBackend() {
|
||||||
GLBackend::~GLBackend() {}
|
GLBackend::~GLBackend() {}
|
||||||
|
|
||||||
void GLBackend::shutdown() {
|
void GLBackend::shutdown() {
|
||||||
|
if (_mipGenerationFramebufferId) {
|
||||||
|
glDeleteFramebuffers(1, &_mipGenerationFramebufferId);
|
||||||
|
_mipGenerationFramebufferId = 0;
|
||||||
|
}
|
||||||
killInput();
|
killInput();
|
||||||
killTransform();
|
killTransform();
|
||||||
killTextureManagementStage();
|
killTextureManagementStage();
|
||||||
|
|
|
@ -288,6 +288,7 @@ public:
|
||||||
virtual void do_setIndexBuffer(const Batch& batch, size_t paramOffset) final;
|
virtual void do_setIndexBuffer(const Batch& batch, size_t paramOffset) final;
|
||||||
virtual void do_setIndirectBuffer(const Batch& batch, size_t paramOffset) final;
|
virtual void do_setIndirectBuffer(const Batch& batch, size_t paramOffset) final;
|
||||||
virtual void do_generateTextureMips(const Batch& batch, size_t paramOffset) final;
|
virtual void do_generateTextureMips(const Batch& batch, size_t paramOffset) final;
|
||||||
|
virtual void do_generateTextureMipsWithPipeline(const Batch& batch, size_t paramOffset) final;
|
||||||
|
|
||||||
// Transform Stage
|
// Transform Stage
|
||||||
virtual void do_setModelTransform(const Batch& batch, size_t paramOffset) final;
|
virtual void do_setModelTransform(const Batch& batch, size_t paramOffset) final;
|
||||||
|
@ -407,6 +408,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual GLint getRealUniformLocation(GLint location) const;
|
virtual GLint getRealUniformLocation(GLint location) const;
|
||||||
|
|
||||||
|
virtual void draw(GLenum mode, uint32 numVertices, uint32 startVertex) = 0;
|
||||||
|
|
||||||
void recycle() const override;
|
void recycle() const override;
|
||||||
|
|
||||||
// FIXME instead of a single flag, create a features struct similar to
|
// FIXME instead of a single flag, create a features struct similar to
|
||||||
|
@ -696,6 +699,8 @@ protected:
|
||||||
virtual void initTextureManagementStage();
|
virtual void initTextureManagementStage();
|
||||||
virtual void killTextureManagementStage();
|
virtual void killTextureManagementStage();
|
||||||
|
|
||||||
|
GLuint _mipGenerationFramebufferId{ 0 };
|
||||||
|
|
||||||
typedef void (GLBackend::*CommandCall)(const Batch&, size_t);
|
typedef void (GLBackend::*CommandCall)(const Batch&, size_t);
|
||||||
static CommandCall _commandCalls[Batch::NUM_COMMANDS];
|
static CommandCall _commandCalls[Batch::NUM_COMMANDS];
|
||||||
friend class GLState;
|
friend class GLState;
|
||||||
|
|
|
@ -79,3 +79,55 @@ void GLBackend::do_generateTextureMips(const Batch& batch, size_t paramOffset) {
|
||||||
|
|
||||||
object->generateMips();
|
object->generateMips();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLBackend::do_generateTextureMipsWithPipeline(const Batch& batch, size_t paramOffset) {
|
||||||
|
TexturePointer resourceTexture = batch._textures.get(batch._params[paramOffset + 0]._uint);
|
||||||
|
if (!resourceTexture) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always make sure the GLObject is in sync
|
||||||
|
GLTexture* object = syncGPUObject(resourceTexture);
|
||||||
|
if (object) {
|
||||||
|
GLuint to = object->_texture;
|
||||||
|
glActiveTexture(GL_TEXTURE0 + gpu::slot::texture::MipCreationInput);
|
||||||
|
glBindTexture(object->_target, to);
|
||||||
|
(void)CHECK_GL_ERROR();
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto numMips = batch._params[paramOffset + 1]._int;
|
||||||
|
if (numMips < 0) {
|
||||||
|
numMips = resourceTexture->getNumMips();
|
||||||
|
} else {
|
||||||
|
numMips = std::min(numMips, (int)resourceTexture->getNumMips());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_mipGenerationFramebufferId == 0) {
|
||||||
|
glGenFramebuffers(1, &_mipGenerationFramebufferId);
|
||||||
|
Q_ASSERT(_mipGenerationFramebufferId > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, _mipGenerationFramebufferId);
|
||||||
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
|
||||||
|
|
||||||
|
for (int level = 1; level < numMips; level++) {
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, object->_id, level);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, level - 1);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level - 1);
|
||||||
|
|
||||||
|
const auto mipDimensions = resourceTexture->evalMipDimensions(level);
|
||||||
|
glViewport(0, 0, mipDimensions.x, mipDimensions.y);
|
||||||
|
draw(GL_TRIANGLE_STRIP, 4, 0);
|
||||||
|
}
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, numMips - 1);
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
|
resetOutputStage();
|
||||||
|
// Restore viewport
|
||||||
|
ivec4& vp = _transform._viewport;
|
||||||
|
glViewport(vp.x, vp.y, vp.z, vp.w);
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,29 @@ using namespace gpu::gl41;
|
||||||
|
|
||||||
const std::string GL41Backend::GL41_VERSION { "GL41" };
|
const std::string GL41Backend::GL41_VERSION { "GL41" };
|
||||||
|
|
||||||
|
void GL41Backend::draw(GLenum mode, uint32 numVertices, uint32 startVertex) {
|
||||||
|
if (isStereo()) {
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawArraysInstanced(mode, startVertex, numVertices, 2);
|
||||||
|
#else
|
||||||
|
setupStereoSide(0);
|
||||||
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
setupStereoSide(1);
|
||||||
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
#endif
|
||||||
|
_stats._DSNumTriangles += 2 * numVertices / 3;
|
||||||
|
_stats._DSNumDrawcalls += 2;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
_stats._DSNumTriangles += numVertices / 3;
|
||||||
|
_stats._DSNumDrawcalls++;
|
||||||
|
}
|
||||||
|
_stats._DSNumAPIDrawcalls++;
|
||||||
|
|
||||||
|
(void)CHECK_GL_ERROR();
|
||||||
|
}
|
||||||
|
|
||||||
void GL41Backend::do_draw(const Batch& batch, size_t paramOffset) {
|
void GL41Backend::do_draw(const Batch& batch, size_t paramOffset) {
|
||||||
Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
||||||
GLenum mode = gl::PRIMITIVE_TO_GL[primitiveType];
|
GLenum mode = gl::PRIMITIVE_TO_GL[primitiveType];
|
||||||
|
|
|
@ -130,6 +130,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void draw(GLenum mode, uint32 numVertices, uint32 startVertex) override;
|
||||||
|
|
||||||
GLuint getFramebufferID(const FramebufferPointer& framebuffer) override;
|
GLuint getFramebufferID(const FramebufferPointer& framebuffer) override;
|
||||||
GLFramebuffer* syncGPUObject(const Framebuffer& framebuffer) override;
|
GLFramebuffer* syncGPUObject(const Framebuffer& framebuffer) override;
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,30 @@ void GL45Backend::recycle() const {
|
||||||
Parent::recycle();
|
Parent::recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GL45Backend::draw(GLenum mode, uint32 numVertices, uint32 startVertex) {
|
||||||
|
if (isStereo()) {
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawArraysInstanced(mode, startVertex, numVertices, 2);
|
||||||
|
#else
|
||||||
|
setupStereoSide(0);
|
||||||
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
setupStereoSide(1);
|
||||||
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_stats._DSNumTriangles += 2 * numVertices / 3;
|
||||||
|
_stats._DSNumDrawcalls += 2;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
_stats._DSNumTriangles += numVertices / 3;
|
||||||
|
_stats._DSNumDrawcalls++;
|
||||||
|
}
|
||||||
|
_stats._DSNumAPIDrawcalls++;
|
||||||
|
|
||||||
|
(void)CHECK_GL_ERROR();
|
||||||
|
}
|
||||||
|
|
||||||
void GL45Backend::do_draw(const Batch& batch, size_t paramOffset) {
|
void GL45Backend::do_draw(const Batch& batch, size_t paramOffset) {
|
||||||
Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
||||||
GLenum mode = gl::PRIMITIVE_TO_GL[primitiveType];
|
GLenum mode = gl::PRIMITIVE_TO_GL[primitiveType];
|
||||||
|
|
|
@ -229,6 +229,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void draw(GLenum mode, uint32 numVertices, uint32 startVertex) override;
|
||||||
void recycle() const override;
|
void recycle() const override;
|
||||||
|
|
||||||
GLuint getFramebufferID(const FramebufferPointer& framebuffer) override;
|
GLuint getFramebufferID(const FramebufferPointer& framebuffer) override;
|
||||||
|
|
|
@ -20,6 +20,29 @@ using namespace gpu::gles;
|
||||||
|
|
||||||
const std::string GLESBackend::GLES_VERSION { "GLES" };
|
const std::string GLESBackend::GLES_VERSION { "GLES" };
|
||||||
|
|
||||||
|
void GLESBackend::draw(GLenum mode, uint32 numVertices, uint32 startVertex) {
|
||||||
|
if (isStereo()) {
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawArraysInstanced(mode, startVertex, numVertices, 2);
|
||||||
|
#else
|
||||||
|
setupStereoSide(0);
|
||||||
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
setupStereoSide(1);
|
||||||
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
#endif
|
||||||
|
_stats._DSNumTriangles += 2 * numVertices / 3;
|
||||||
|
_stats._DSNumDrawcalls += 2;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
_stats._DSNumTriangles += numVertices / 3;
|
||||||
|
_stats._DSNumDrawcalls++;
|
||||||
|
}
|
||||||
|
_stats._DSNumAPIDrawcalls++;
|
||||||
|
|
||||||
|
(void)CHECK_GL_ERROR();
|
||||||
|
}
|
||||||
|
|
||||||
void GLESBackend::do_draw(const Batch& batch, size_t paramOffset) {
|
void GLESBackend::do_draw(const Batch& batch, size_t paramOffset) {
|
||||||
Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
Primitive primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
||||||
GLenum mode = gl::PRIMITIVE_TO_GL[primitiveType];
|
GLenum mode = gl::PRIMITIVE_TO_GL[primitiveType];
|
||||||
|
|
|
@ -126,6 +126,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void draw(GLenum mode, uint32 numVertices, uint32 startVertex) override;
|
||||||
|
|
||||||
GLuint getFramebufferID(const FramebufferPointer& framebuffer) override;
|
GLuint getFramebufferID(const FramebufferPointer& framebuffer) override;
|
||||||
GLFramebuffer* syncGPUObject(const Framebuffer& framebuffer) override;
|
GLFramebuffer* syncGPUObject(const Framebuffer& framebuffer) override;
|
||||||
|
|
||||||
|
|
|
@ -426,6 +426,13 @@ void Batch::generateTextureMips(const TexturePointer& texture) {
|
||||||
_params.emplace_back(_textures.cache(texture));
|
_params.emplace_back(_textures.cache(texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Batch::generateTextureMipsWithPipeline(const TexturePointer& texture, int numMips) {
|
||||||
|
ADD_COMMAND(generateTextureMipsWithPipeline);
|
||||||
|
|
||||||
|
_params.emplace_back(_textures.cache(texture));
|
||||||
|
_params.emplace_back(numMips);
|
||||||
|
}
|
||||||
|
|
||||||
void Batch::beginQuery(const QueryPointer& query) {
|
void Batch::beginQuery(const QueryPointer& query) {
|
||||||
ADD_COMMAND(beginQuery);
|
ADD_COMMAND(beginQuery);
|
||||||
|
|
||||||
|
|
|
@ -226,6 +226,8 @@ public:
|
||||||
|
|
||||||
// Generate the mips for a texture
|
// Generate the mips for a texture
|
||||||
void generateTextureMips(const TexturePointer& texture);
|
void generateTextureMips(const TexturePointer& texture);
|
||||||
|
// Generate the mips for a texture using the current pipeline
|
||||||
|
void generateTextureMipsWithPipeline(const TexturePointer& destTexture, int numMips = -1);
|
||||||
|
|
||||||
// Query Section
|
// Query Section
|
||||||
void beginQuery(const QueryPointer& query);
|
void beginQuery(const QueryPointer& query);
|
||||||
|
@ -326,6 +328,7 @@ public:
|
||||||
COMMAND_clearFramebuffer,
|
COMMAND_clearFramebuffer,
|
||||||
COMMAND_blit,
|
COMMAND_blit,
|
||||||
COMMAND_generateTextureMips,
|
COMMAND_generateTextureMips,
|
||||||
|
COMMAND_generateTextureMipsWithPipeline,
|
||||||
|
|
||||||
COMMAND_advance,
|
COMMAND_advance,
|
||||||
|
|
||||||
|
|
20
libraries/gpu/src/gpu/MipGeneration.slh
Normal file
20
libraries/gpu/src/gpu/MipGeneration.slh
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<!
|
||||||
|
// MipGeneration.slh
|
||||||
|
// libraries/gpu/src
|
||||||
|
//
|
||||||
|
// Created by Olivier Prat on 10/16/18.
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
!>
|
||||||
|
<@if not MIP_GENERATION_SLH@>
|
||||||
|
<@def MIP_GENERATION_SLH@>
|
||||||
|
|
||||||
|
<@include gpu/ShaderConstants.h@>
|
||||||
|
|
||||||
|
layout(binding=GPU_TEXTURE_MIP_CREATION_INPUT) uniform sampler2D texMap;
|
||||||
|
|
||||||
|
in vec2 varTexCoord0;
|
||||||
|
|
||||||
|
<@endif@>
|
|
@ -21,6 +21,9 @@
|
||||||
|
|
||||||
#define GPU_TEXTURE_TRANSFORM_OBJECT 31
|
#define GPU_TEXTURE_TRANSFORM_OBJECT 31
|
||||||
|
|
||||||
|
// Mip creation
|
||||||
|
#define GPU_TEXTURE_MIP_CREATION_INPUT 30
|
||||||
|
|
||||||
#define GPU_STORAGE_TRANSFORM_OBJECT 7
|
#define GPU_STORAGE_TRANSFORM_OBJECT 7
|
||||||
|
|
||||||
#define GPU_ATTR_POSITION 0
|
#define GPU_ATTR_POSITION 0
|
||||||
|
@ -67,7 +70,8 @@ enum Buffer {
|
||||||
namespace texture {
|
namespace texture {
|
||||||
enum Texture {
|
enum Texture {
|
||||||
ObjectTransforms = GPU_TEXTURE_TRANSFORM_OBJECT,
|
ObjectTransforms = GPU_TEXTURE_TRANSFORM_OBJECT,
|
||||||
};
|
MipCreationInput = GPU_TEXTURE_MIP_CREATION_INPUT,
|
||||||
|
};
|
||||||
} // namespace texture
|
} // namespace texture
|
||||||
|
|
||||||
namespace storage {
|
namespace storage {
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
this.reticleMinY = MARGIN;
|
this.reticleMinY = MARGIN;
|
||||||
this.reticleMaxY;
|
this.reticleMaxY;
|
||||||
this.parameters = ControllerDispatcherUtils.makeDispatcherModuleParameters(
|
this.parameters = ControllerDispatcherUtils.makeDispatcherModuleParameters(
|
||||||
540,
|
160, // Same as webSurfaceLaserInput.
|
||||||
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
||||||
[],
|
[],
|
||||||
100,
|
100,
|
||||||
|
@ -63,7 +63,6 @@
|
||||||
|
|
||||||
this.processLaser = function(controllerData) {
|
this.processLaser = function(controllerData) {
|
||||||
var controllerLocation = controllerData.controllerLocations[this.hand];
|
var controllerLocation = controllerData.controllerLocations[this.hand];
|
||||||
// var otherModuleRunning = this.getOtherModule().running;
|
|
||||||
if ((controllerData.triggerValues[this.hand] < ControllerDispatcherUtils.TRIGGER_ON_VALUE || !controllerLocation.valid) ||
|
if ((controllerData.triggerValues[this.hand] < ControllerDispatcherUtils.TRIGGER_ON_VALUE || !controllerLocation.valid) ||
|
||||||
this.pointingAtTablet(controllerData)) {
|
this.pointingAtTablet(controllerData)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -28,7 +28,7 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
this.reticleMaxY = null;
|
this.reticleMaxY = null;
|
||||||
|
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
160,
|
165, // Lower priority than webSurfaceLaserInput and hudOverlayPointer.
|
||||||
this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"],
|
this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"],
|
||||||
[],
|
[],
|
||||||
100,
|
100,
|
||||||
|
@ -127,29 +127,41 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.run = function(controllerData) {
|
this.run = function(controllerData) {
|
||||||
var tabletStylusInput = getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightTabletStylusInput" : "LeftTabletStylusInput");
|
var tabletStylusInput = getEnabledModuleByName(this.hand === RIGHT_HAND
|
||||||
|
? "RightTabletStylusInput" : "LeftTabletStylusInput");
|
||||||
if (tabletStylusInput) {
|
if (tabletStylusInput) {
|
||||||
var tabletReady = tabletStylusInput.isReady(controllerData);
|
var tabletReady = tabletStylusInput.isReady(controllerData);
|
||||||
|
|
||||||
if (tabletReady.active) {
|
if (tabletReady.active) {
|
||||||
return this.exitModule();
|
return this.exitModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var overlayLaser = getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightWebSurfaceLaserInput" : "LeftWebSurfaceLaserInput");
|
var webLaser = getEnabledModuleByName(this.hand === RIGHT_HAND
|
||||||
if (overlayLaser) {
|
? "RightWebSurfaceLaserInput" : "LeftWebSurfaceLaserInput");
|
||||||
var overlayLaserReady = overlayLaser.isReady(controllerData);
|
if (webLaser) {
|
||||||
|
var webLaserReady = webLaser.isReady(controllerData);
|
||||||
var target = controllerData.rayPicks[this.hand].objectID;
|
var target = controllerData.rayPicks[this.hand].objectID;
|
||||||
this.sendPointingAtData(controllerData);
|
this.sendPointingAtData(controllerData);
|
||||||
if (overlayLaserReady.active && this.pointingAtTablet(target)) {
|
if (webLaserReady.active && this.pointingAtTablet(target)) {
|
||||||
return this.exitModule();
|
return this.exitModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var nearOverlay = getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay");
|
if (!controllerData.triggerClicks[this.hand]) { // Don't grab if trigger pressed when laser starts intersecting.
|
||||||
|
var hudLaser = getEnabledModuleByName(this.hand === RIGHT_HAND
|
||||||
|
? "RightHudOverlayPointer" : "LeftHudOverlayPointer");
|
||||||
|
if (hudLaser) {
|
||||||
|
var hudLaserReady = hudLaser.isReady(controllerData);
|
||||||
|
if (hudLaserReady.active) {
|
||||||
|
return this.exitModule();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var nearOverlay = getEnabledModuleByName(this.hand === RIGHT_HAND
|
||||||
|
? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay");
|
||||||
if (nearOverlay) {
|
if (nearOverlay) {
|
||||||
var nearOverlayReady = nearOverlay.isReady(controllerData);
|
var nearOverlayReady = nearOverlay.isReady(controllerData);
|
||||||
|
|
||||||
if (nearOverlayReady.active && HMD.tabletID && nearOverlay.grabbedThingID === HMD.tabletID) {
|
if (nearOverlayReady.active && HMD.tabletID && nearOverlay.grabbedThingID === HMD.tabletID) {
|
||||||
return this.exitModule();
|
return this.exitModule();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,13 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
function InVREditMode(hand) {
|
function InVREditMode(hand) {
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
this.disableModules = false;
|
this.disableModules = false;
|
||||||
var NO_HAND_LASER = -1; // Invalid hand parameter so that default laser is not displayed.
|
this.running = false;
|
||||||
|
var NO_HAND_LASER = -1; // Invalid hand parameter so that standard laser is not displayed.
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
200, // Not too high otherwise the tablet laser doesn't work.
|
166, // Slightly lower priority than inEditMode.
|
||||||
this.hand === RIGHT_HAND ?
|
this.hand === RIGHT_HAND
|
||||||
["rightHand", "rightHandEquip", "rightHandTrigger"] :
|
? ["rightHand", "rightHandEquip", "rightHandTrigger"]
|
||||||
["leftHand", "leftHandEquip", "leftHandTrigger"],
|
: ["leftHand", "leftHandEquip", "leftHandTrigger"],
|
||||||
[],
|
[],
|
||||||
100,
|
100,
|
||||||
makeLaserParams(NO_HAND_LASER, false)
|
makeLaserParams(NO_HAND_LASER, false)
|
||||||
|
@ -35,6 +36,35 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
(HMD.homeButtonID && objectID === HMD.homeButtonID);
|
(HMD.homeButtonID && objectID === HMD.homeButtonID);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The Shapes app has a non-standard laser: in particular, the laser end dot displays on its own when the laser is
|
||||||
|
// pointing at the Shapes UI. The laser on/off is controlled by this module but the laser is implemented in the Shapes
|
||||||
|
// app.
|
||||||
|
// If, in the future, the Shapes app laser interaction is adopted as a standard UI style then the laser could be
|
||||||
|
// implemented in the controller modules along side the other laser styles.
|
||||||
|
var INVREDIT_MODULE_RUNNING = "Hifi-InVREdit-Module-Running";
|
||||||
|
|
||||||
|
this.runModule = function () {
|
||||||
|
if (!this.running) {
|
||||||
|
Messages.sendLocalMessage(INVREDIT_MODULE_RUNNING, JSON.stringify({
|
||||||
|
hand: this.hand,
|
||||||
|
running: true
|
||||||
|
}));
|
||||||
|
this.running = true;
|
||||||
|
}
|
||||||
|
return makeRunningValues(true, [], []);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.exitModule = function () {
|
||||||
|
if (this.running) {
|
||||||
|
Messages.sendLocalMessage(INVREDIT_MODULE_RUNNING, JSON.stringify({
|
||||||
|
hand: this.hand,
|
||||||
|
running: false
|
||||||
|
}));
|
||||||
|
this.running = false;
|
||||||
|
}
|
||||||
|
return makeRunningValues(false, [], []);
|
||||||
|
};
|
||||||
|
|
||||||
this.isReady = function (controllerData) {
|
this.isReady = function (controllerData) {
|
||||||
if (this.disableModules) {
|
if (this.disableModules) {
|
||||||
return makeRunningValues(true, [], []);
|
return makeRunningValues(true, [], []);
|
||||||
|
@ -45,7 +75,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
this.run = function (controllerData) {
|
this.run = function (controllerData) {
|
||||||
// Default behavior if disabling is not enabled.
|
// Default behavior if disabling is not enabled.
|
||||||
if (!this.disableModules) {
|
if (!this.disableModules) {
|
||||||
return makeRunningValues(false, [], []);
|
return this.exitModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tablet stylus.
|
// Tablet stylus.
|
||||||
|
@ -55,7 +85,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
if (tabletStylusInput) {
|
if (tabletStylusInput) {
|
||||||
var tabletReady = tabletStylusInput.isReady(controllerData);
|
var tabletReady = tabletStylusInput.isReady(controllerData);
|
||||||
if (tabletReady.active) {
|
if (tabletReady.active) {
|
||||||
return makeRunningValues(false, [], []);
|
return this.exitModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +97,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
var overlayLaserReady = overlayLaser.isReady(controllerData);
|
var overlayLaserReady = overlayLaser.isReady(controllerData);
|
||||||
var target = controllerData.rayPicks[this.hand].objectID;
|
var target = controllerData.rayPicks[this.hand].objectID;
|
||||||
if (overlayLaserReady.active && this.pointingAtTablet(target)) {
|
if (overlayLaserReady.active && this.pointingAtTablet(target)) {
|
||||||
return makeRunningValues(false, [], []);
|
return this.exitModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +108,20 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
if (nearOverlay) {
|
if (nearOverlay) {
|
||||||
var nearOverlayReady = nearOverlay.isReady(controllerData);
|
var nearOverlayReady = nearOverlay.isReady(controllerData);
|
||||||
if (nearOverlayReady.active && HMD.tabletID && nearOverlay.grabbedThingID === HMD.tabletID) {
|
if (nearOverlayReady.active && HMD.tabletID && nearOverlay.grabbedThingID === HMD.tabletID) {
|
||||||
return makeRunningValues(false, [], []);
|
return this.exitModule();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HUD overlay.
|
||||||
|
if (!controllerData.triggerClicks[this.hand]) {
|
||||||
|
var hudLaser = getEnabledModuleByName(this.hand === RIGHT_HAND
|
||||||
|
? "RightHudOverlayPointer"
|
||||||
|
: "LeftHudOverlayPointer");
|
||||||
|
if (hudLaser) {
|
||||||
|
var hudLaserReady = hudLaser.isReady(controllerData);
|
||||||
|
if (hudLaserReady.active) {
|
||||||
|
return this.exitModule();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,12 +132,12 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
if (teleporter) {
|
if (teleporter) {
|
||||||
var teleporterReady = teleporter.isReady(controllerData);
|
var teleporterReady = teleporter.isReady(controllerData);
|
||||||
if (teleporterReady.active) {
|
if (teleporterReady.active) {
|
||||||
return makeRunningValues(false, [], []);
|
return this.exitModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other behaviors are disabled.
|
// Other behaviors are disabled.
|
||||||
return makeRunningValues(true, [], []);
|
return this.runModule();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue