diff --git a/CMakeLists.txt b/CMakeLists.txt index 406fb5aeb1..3c90256134 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,9 +208,10 @@ foreach(CUSTOM_MACRO ${HIFI_CUSTOM_MACROS}) include(${CUSTOM_MACRO}) endforeach() -file(GLOB_RECURSE JS_SRC scripts/*.js) +file(GLOB_RECURSE JS_SRC scripts/*.js unpublishedScripts/*.js) add_custom_target(js SOURCES ${JS_SRC}) GroupSources("scripts") +GroupSources("unpublishedScripts") if (UNIX) install( diff --git a/interface/resources/images/Default-Sky-9-cubemap.ktx b/interface/resources/images/Default-Sky-9-cubemap.ktx index 476d381a8c..70f495c3ab 100644 Binary files a/interface/resources/images/Default-Sky-9-cubemap.ktx and b/interface/resources/images/Default-Sky-9-cubemap.ktx differ diff --git a/libraries/gpu-gl/src/gpu/gl/GLTexelFormat.cpp b/libraries/gpu-gl/src/gpu/gl/GLTexelFormat.cpp index a5beca8dfd..b42ffedf37 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTexelFormat.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTexelFormat.cpp @@ -18,11 +18,10 @@ bool GLTexelFormat::isCompressed() const { case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: case GL_COMPRESSED_RED_RGTC1: case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: return true; - break; default: return false; - break; } } @@ -238,6 +237,9 @@ GLenum GLTexelFormat::evalGLTexelFormatInternal(const gpu::Element& dstFormat) { case gpu::COMPRESSED_BC5_XY: result = GL_COMPRESSED_RG_RGTC2; break; + case gpu::COMPRESSED_BC7_SRGBA: + result = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM; + break; default: qCWarning(gpugllogging) << "Unknown combination of texel format"; @@ -387,6 +389,9 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E case gpu::COMPRESSED_BC5_XY: texel.internalFormat = GL_COMPRESSED_RG_RGTC2; break; + case gpu::COMPRESSED_BC7_SRGBA: + texel.internalFormat = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM; + break; default: qCWarning(gpugllogging) << "Unknown combination of texel format"; } @@ -679,6 +684,10 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E case gpu::COMPRESSED_BC5_XY: texel.internalFormat = GL_COMPRESSED_RG_RGTC2; break; + case gpu::COMPRESSED_BC7_SRGBA: + texel.internalFormat = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM; + break; + default: qCWarning(gpugllogging) << "Unknown combination of texel format"; } diff --git a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp index 15fdbace4c..8920a3ea76 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp @@ -539,12 +539,14 @@ void GLVariableAllocationSupport::processWorkQueue(WorkQueue& workQueue) { vartexture->demote(); workQueue.pop(); addToWorkQueue(texture); + _memoryPressureStateStale = true; break; case MemoryPressureState::Undersubscribed: vartexture->promote(); workQueue.pop(); addToWorkQueue(texture); + _memoryPressureStateStale = true; break; case MemoryPressureState::Transfer: diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h b/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h index e5c8b07aa8..53598e3b93 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h +++ b/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h @@ -110,10 +110,15 @@ public: void promote() override; void demote() override; void populateTransferQueue() override; + Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override; + Size copyMipsFromTexture(); Size size() const override { return _size; } Size _size { 0 }; + void incrementPopulatedSize(Size delta) const; + void decrementPopulatedSize(Size delta) const; + mutable Size _populatedSize { 0 }; }; class GL41ResourceTexture : public GL41VariableAllocationTexture { diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp index 6cc8c0afb7..ec687ade9f 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp @@ -112,6 +112,7 @@ Size GL41Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: case GL_COMPRESSED_RED_RGTC1: case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: glCompressedTexSubImage2D(_target, mip, 0, yOffset, size.x, size.y, internalFormat, static_cast(sourceSize), sourcePointer); break; @@ -128,6 +129,7 @@ Size GL41Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: case GL_COMPRESSED_RED_RGTC1: case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: glCompressedTexSubImage2D(target, mip, 0, yOffset, size.x, size.y, internalFormat, static_cast(sourceSize), sourcePointer); break; @@ -276,15 +278,7 @@ GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr allocateStorage(allocatedMip); _memoryPressureStateStale = true; - size_t maxFace = GLTexture::getFaceCount(_target); - Size amount = 0; - for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) { - uint16_t targetMip = sourceMip - _allocatedMip; - for (uint8_t face = 0; face < maxFace; ++face) { - amount += copyMipFaceFromTexture(sourceMip, targetMip, face); - } - } - Backend::textureResourcePopulatedGPUMemSize.update(0, amount); + copyMipsFromTexture(); syncSampler(); } @@ -294,6 +288,25 @@ GL41VariableAllocationTexture::~GL41VariableAllocationTexture() { Backend::textureResourcePopulatedGPUMemSize.update(_size, 0); } +void GL41VariableAllocationTexture::incrementPopulatedSize(Size delta) const { + _populatedSize += delta; + // Keep the 2 code paths to be able to debug + if (_size < _populatedSize) { + Backend::textureResourcePopulatedGPUMemSize.update(0, delta); + } else { + Backend::textureResourcePopulatedGPUMemSize.update(0, delta); + } +} +void GL41VariableAllocationTexture::decrementPopulatedSize(Size delta) const { + _populatedSize -= delta; + // Keep the 2 code paths to be able to debug + if (_size < _populatedSize) { + Backend::textureResourcePopulatedGPUMemSize.update(delta, 0); + } else { + Backend::textureResourcePopulatedGPUMemSize.update(delta, 0); + } +} + void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) { _allocatedMip = allocatedMip; @@ -314,12 +327,25 @@ void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) { } +Size GL41VariableAllocationTexture::copyMipsFromTexture() { + auto mipLevels = _gpuObject.getNumMips(); + size_t maxFace = GLTexture::getFaceCount(_target); + Size amount = 0; + for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) { + uint16_t targetMip = sourceMip - _allocatedMip; + for (uint8_t face = 0; face < maxFace; ++face) { + amount += copyMipFaceFromTexture(sourceMip, targetMip, face); + } + } + return amount; +} Size GL41VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const { Size amountCopied = 0; withPreservedTexture([&] { amountCopied = Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer); }); + incrementPopulatedSize(amountCopied); return amountCopied; } @@ -494,6 +520,7 @@ void GL41VariableAllocationTexture::demote() { Q_ASSERT(_allocatedMip < _maxAllocatedMip); auto oldId = _id; auto oldSize = _size; + auto oldPopulatedMip = _populatedMip; // allocate new texture const_cast(_id) = allocate(_gpuObject); @@ -517,7 +544,15 @@ void GL41VariableAllocationTexture::demote() { glDeleteTextures(1, &oldId); // update the memory usage Backend::textureResourceGPUMemSize.update(oldSize, 0); - Backend::textureResourcePopulatedGPUMemSize.update(oldSize, _size); // Demoting unpopulate the memory delta old - _size + // Demoting unpopulate the memory delta + if (oldPopulatedMip != _populatedMip) { + auto numPopulatedDemoted = _populatedMip - oldPopulatedMip; + Size amountUnpopulated = 0; + for (int i = 0; i < numPopulatedDemoted; i++) { + amountUnpopulated += _gpuObject.evalMipSize(oldPopulatedMip + i); + } + decrementPopulatedSize(amountUnpopulated); + } populateTransferQueue(); } diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index 7dbd5c0ace..ad54ccc3e9 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -142,6 +142,7 @@ Size GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: case GL_COMPRESSED_RED_RGTC1: case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: glCompressedTextureSubImage2D(_id, mip, 0, yOffset, size.x, size.y, internalFormat, static_cast(sourceSize), sourcePointer); break; @@ -156,6 +157,7 @@ Size GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: case GL_COMPRESSED_RED_RGTC1: case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: if (glCompressedTextureSubImage2DEXT) { auto target = GLTexture::CUBE_FACE_LAYOUT[face]; glCompressedTextureSubImage2DEXT(_id, target, mip, 0, yOffset, size.x, size.y, internalFormat, diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp index 1ae3b405c3..d3088c8341 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp @@ -41,6 +41,7 @@ GL45VariableAllocationTexture::~GL45VariableAllocationTexture() { } void GL45VariableAllocationTexture::incrementPopulatedSize(Size delta) const { _populatedSize += delta; + // Keep the 2 code paths to be able to debug if (_size < _populatedSize) { Backend::textureResourcePopulatedGPUMemSize.update(0, delta); } else { @@ -49,6 +50,7 @@ void GL45VariableAllocationTexture::incrementPopulatedSize(Size delta) const { } void GL45VariableAllocationTexture::decrementPopulatedSize(Size delta) const { _populatedSize -= delta; + // Keep the 2 code paths to be able to debug if (_size < _populatedSize) { Backend::textureResourcePopulatedGPUMemSize.update(delta, 0); } else { @@ -98,11 +100,7 @@ void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) { glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); auto mipLevels = _gpuObject.getNumMips(); _size = 0; - bool wtf = false; for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) { - if (_gpuObject.evalMipSize(mip) == 0) { - wtf = true; - } _size += _gpuObject.evalMipSize(mip); } Backend::textureResourceGPUMemSize.update(0, _size); diff --git a/libraries/gpu/src/gpu/Format.cpp b/libraries/gpu/src/gpu/Format.cpp index 787c09c63e..b15f8d929f 100644 --- a/libraries/gpu/src/gpu/Format.cpp +++ b/libraries/gpu/src/gpu/Format.cpp @@ -24,6 +24,7 @@ const Element Element::COLOR_COMPRESSED_SRGB { TILE4x4, COMPRESSED, COMPRESSED_B const Element Element::COLOR_COMPRESSED_SRGBA_MASK { TILE4x4, COMPRESSED, COMPRESSED_BC1_SRGBA }; const Element Element::COLOR_COMPRESSED_SRGBA { TILE4x4, COMPRESSED, COMPRESSED_BC3_SRGBA }; const Element Element::COLOR_COMPRESSED_XY { TILE4x4, COMPRESSED, COMPRESSED_BC5_XY }; +const Element Element::COLOR_COMPRESSED_SRGBA_HIGH { TILE4x4, COMPRESSED, COMPRESSED_BC7_SRGBA }; const Element Element::VEC2NU8_XY{ VEC2, NUINT8, XY }; diff --git a/libraries/gpu/src/gpu/Format.h b/libraries/gpu/src/gpu/Format.h index b2f2252119..c4d88236da 100644 --- a/libraries/gpu/src/gpu/Format.h +++ b/libraries/gpu/src/gpu/Format.h @@ -187,6 +187,7 @@ enum Semantic : uint8_t { COMPRESSED_BC3_SRGBA, COMPRESSED_BC4_RED, COMPRESSED_BC5_XY, + COMPRESSED_BC7_SRGBA, _LAST_COMPRESSED, @@ -239,6 +240,7 @@ static const int SEMANTIC_SIZE_FACTOR[NUM_SEMANTICS] = { 16, //COMPRESSED_BC3_SRGBA, 1 byte/pixel * 4x4 pixels = 16 bytes 8, //COMPRESSED_BC4_RED, 1/2 byte/pixel * 4x4 pixels = 8 bytes 16, //COMPRESSED_BC5_XY, 1 byte/pixel * 4x4 pixels = 16 bytes + 16, //COMPRESSED_BC7_SRGBA, 1 byte/pixel * 4x4 pixels = 16 bytes 1, //_LAST_COMPRESSED, @@ -309,6 +311,7 @@ public: static const Element COLOR_COMPRESSED_SRGBA_MASK; static const Element COLOR_COMPRESSED_SRGBA; static const Element COLOR_COMPRESSED_XY; + static const Element COLOR_COMPRESSED_SRGBA_HIGH; static const Element VEC2NU8_XY; static const Element VEC4F_COLOR_RGBA; static const Element VEC2F_UV; diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 14282ec525..5f677d7424 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -531,6 +531,8 @@ bool Texture::evalKTXFormat(const Element& mipFormat, const Element& texelFormat header.setCompressed(ktx::GLInternalFormat_Compressed::COMPRESSED_RED_RGTC1, ktx::GLBaseInternalFormat::RED); } else if (texelFormat == Format::COLOR_COMPRESSED_XY && mipFormat == Format::COLOR_COMPRESSED_XY) { header.setCompressed(ktx::GLInternalFormat_Compressed::COMPRESSED_RG_RGTC2, ktx::GLBaseInternalFormat::RG); + } else if (texelFormat == Format::COLOR_COMPRESSED_SRGBA_HIGH && mipFormat == Format::COLOR_COMPRESSED_SRGBA_HIGH) { + header.setCompressed(ktx::GLInternalFormat_Compressed::COMPRESSED_SRGB_ALPHA_BPTC_UNORM, ktx::GLBaseInternalFormat::RGBA); } else { return false; } @@ -589,6 +591,9 @@ bool Texture::evalTextureFormat(const ktx::Header& header, Element& mipFormat, E } else if (header.getGLInternaFormat_Compressed() == ktx::GLInternalFormat_Compressed::COMPRESSED_RG_RGTC2) { mipFormat = Format::COLOR_COMPRESSED_XY; texelFormat = Format::COLOR_COMPRESSED_XY; + } else if (header.getGLInternaFormat_Compressed() == ktx::GLInternalFormat_Compressed::COMPRESSED_SRGB_ALPHA_BPTC_UNORM) { + mipFormat = Format::COLOR_COMPRESSED_SRGBA_HIGH; + texelFormat = Format::COLOR_COMPRESSED_SRGBA_HIGH; } else { return false; } diff --git a/libraries/image/src/image/Image.cpp b/libraries/image/src/image/Image.cpp index 32184dfe79..7f0674b17d 100644 --- a/libraries/image/src/image/Image.cpp +++ b/libraries/image/src/image/Image.cpp @@ -344,7 +344,7 @@ void generateMips(gpu::Texture* texture, QImage& image, int face = -1) { nvtt::TextureType textureType = nvtt::TextureType_2D; nvtt::InputFormat inputFormat = nvtt::InputFormat_BGRA_8UB; - nvtt::WrapMode wrapMode = nvtt::WrapMode_Repeat; + nvtt::WrapMode wrapMode = nvtt::WrapMode_Mirror; nvtt::RoundMode roundMode = nvtt::RoundMode_None; nvtt::AlphaMode alphaMode = nvtt::AlphaMode_None; @@ -380,6 +380,9 @@ void generateMips(gpu::Texture* texture, QImage& image, int face = -1) { compressionOptions.setFormat(nvtt::Format_BC4); } else if (mipFormat == gpu::Element::COLOR_COMPRESSED_XY) { compressionOptions.setFormat(nvtt::Format_BC5); + } else if (mipFormat == gpu::Element::COLOR_COMPRESSED_SRGBA_HIGH) { + alphaMode = nvtt::AlphaMode_Transparency; + compressionOptions.setFormat(nvtt::Format_BC7); } else if (mipFormat == gpu::Element::COLOR_RGBA_32) { compressionOptions.setFormat(nvtt::Format_RGBA); compressionOptions.setPixelType(nvtt::PixelType_UnsignedNorm); @@ -934,8 +937,8 @@ gpu::TexturePointer TextureUsage::processCubeTextureColorFromImage(const QImage& gpu::Element formatMip; gpu::Element formatGPU; if (isCubeTexturesCompressionEnabled()) { - formatMip = gpu::Element::COLOR_COMPRESSED_SRGBA; - formatGPU = gpu::Element::COLOR_COMPRESSED_SRGBA; + formatMip = gpu::Element::COLOR_COMPRESSED_SRGBA_HIGH; + formatGPU = gpu::Element::COLOR_COMPRESSED_SRGBA_HIGH; } else { formatMip = gpu::Element::COLOR_SRGBA_32; formatGPU = gpu::Element::COLOR_SRGBA_32; diff --git a/libraries/ktx/src/ktx/KTX.cpp b/libraries/ktx/src/ktx/KTX.cpp index b43d015d65..c366daf7ed 100644 --- a/libraries/ktx/src/ktx/KTX.cpp +++ b/libraries/ktx/src/ktx/KTX.cpp @@ -56,6 +56,7 @@ uint32_t Header::evalPixelOrBlockHeight(uint32_t level) const { case GLInternalFormat_Compressed::COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: // BC3 case GLInternalFormat_Compressed::COMPRESSED_RED_RGTC1: // BC4 case GLInternalFormat_Compressed::COMPRESSED_RG_RGTC2: // BC5 + case GLInternalFormat_Compressed::COMPRESSED_SRGB_ALPHA_BPTC_UNORM: // BC7 return (pixelWidth + 3) / 4; default: throw std::runtime_error("Unknown format"); @@ -81,6 +82,8 @@ size_t Header::evalPixelOrBlockSize() const { return 8; } else if (format == GLInternalFormat_Compressed::COMPRESSED_RG_RGTC2) { return 16; + } else if (format == GLInternalFormat_Compressed::COMPRESSED_SRGB_ALPHA_BPTC_UNORM) { + return 16; } } else { auto baseFormat = getGLBaseInternalFormat(); diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 83f1504f00..c614c8537f 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -28,6 +28,7 @@ #include +#include "NetworkingConstants.h" #include "NetworkLogging.h" #include "NodeList.h" #include "udt/PacketHeaders.h" @@ -225,6 +226,10 @@ void AccountManager::sendRequest(const QString& path, uuidStringWithoutCurlyBraces(_sessionID).toLocal8Bit()); QUrl requestURL = _authURL; + + if (requestURL.isEmpty()) { // Assignment client doesn't set _authURL. + requestURL = NetworkingConstants::METAVERSE_SERVER_URL; + } if (path.startsWith("/")) { requestURL.setPath(path); diff --git a/scripts/developer/utilities/render/textureMonitor.js b/scripts/developer/utilities/render/textureMonitor.js index 779e3b8950..7f08eb1eea 100644 --- a/scripts/developer/utilities/render/textureMonitor.js +++ b/scripts/developer/utilities/render/textureMonitor.js @@ -15,7 +15,7 @@ var window = new OverlayWindow({ title: 'Textures', source: qml, width: 320, - height: 400 + height: 300, }); window.setPosition(500, 50); window.closed.connect(function() { Script.stop(); }); \ No newline at end of file