From be534f21271b112a7bf69547c36fdcb8533e6ee8 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 9 Aug 2019 16:42:51 -0700 Subject: [PATCH 1/6] Add --version to the Oven --- tools/oven/src/OvenCLIApplication.cpp | 67 ++++++++++++++++++++------- tools/oven/src/OvenCLIApplication.h | 7 +++ tools/oven/src/main.cpp | 11 +++-- 3 files changed, 64 insertions(+), 21 deletions(-) diff --git a/tools/oven/src/OvenCLIApplication.cpp b/tools/oven/src/OvenCLIApplication.cpp index eab8647e71..afcdfbfcd2 100644 --- a/tools/oven/src/OvenCLIApplication.cpp +++ b/tools/oven/src/OvenCLIApplication.cpp @@ -24,12 +24,23 @@ static const QString CLI_OUTPUT_PARAMETER = "o"; static const QString CLI_TYPE_PARAMETER = "t"; static const QString CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER = "disable-texture-compression"; +QUrl OvenCLIApplication::_inputUrlParameter; +QUrl OvenCLIApplication::_outputUrlParameter; +QString OvenCLIApplication::_typeParameter; + OvenCLIApplication::OvenCLIApplication(int argc, char* argv[]) : QCoreApplication(argc, argv) { + BakerCLI* cli = new BakerCLI(this); + QMetaObject::invokeMethod(cli, "bakeFile", Qt::QueuedConnection, Q_ARG(QUrl, _inputUrlParameter), + Q_ARG(QString, _outputUrlParameter.toString()), Q_ARG(QString, _typeParameter)); +} + +void OvenCLIApplication::parseCommandLine(int argc, char* argv[]) { // parse the command line parameters QCommandLineParser parser; + parser.setApplicationDescription("High Fidelity Oven"); parser.addOptions({ { CLI_INPUT_PARAMETER, "Path to file that you would like to bake.", "input" }, { CLI_OUTPUT_PARAMETER, "Path to folder that will be used as output.", "output" }, @@ -37,25 +48,45 @@ OvenCLIApplication::OvenCLIApplication(int argc, char* argv[]) : { CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER, "Disable texture compression." } }); - parser.addHelpOption(); - parser.process(*this); + auto versionOption = parser.addVersionOption(); + auto helpOption = parser.addHelpOption(); - if (parser.isSet(CLI_INPUT_PARAMETER) && parser.isSet(CLI_OUTPUT_PARAMETER)) { - BakerCLI* cli = new BakerCLI(this); - QUrl inputUrl(QDir::fromNativeSeparators(parser.value(CLI_INPUT_PARAMETER))); - QUrl outputUrl(QDir::fromNativeSeparators(parser.value(CLI_OUTPUT_PARAMETER))); - QString type = parser.isSet(CLI_TYPE_PARAMETER) ? parser.value(CLI_TYPE_PARAMETER) : QString::null; - - if (parser.isSet(CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER)) { - qDebug() << "Disabling texture compression"; - TextureBaker::setCompressionEnabled(false); - } - - QMetaObject::invokeMethod(cli, "bakeFile", Qt::QueuedConnection, Q_ARG(QUrl, inputUrl), - Q_ARG(QString, outputUrl.toString()), Q_ARG(QString, type)); - } else { - parser.showHelp(); - QCoreApplication::quit(); + QStringList arguments; + for (int i = 0; i < argc; ++i) { + arguments << argv[i]; } + if (!parser.parse(arguments)) { + std::cout << parser.errorText().toStdString() << std::endl; // Avoid Qt log spam + QCoreApplication mockApp(argc, argv); // required for call to showHelp() + parser.showHelp(); + Q_UNREACHABLE(); + } + + if (parser.isSet(versionOption)) { + parser.showVersion(); + Q_UNREACHABLE(); + } + if (parser.isSet(helpOption)) { + QCoreApplication mockApp(argc, argv); // required for call to showHelp() + parser.showHelp(); + Q_UNREACHABLE(); + } + + if (!parser.isSet(CLI_INPUT_PARAMETER) || !parser.isSet(CLI_OUTPUT_PARAMETER)) { + std::cout << "Error: Input and Output not set" << std::endl; // Avoid Qt log spam + QCoreApplication mockApp(argc, argv); // required for call to showHelp() + parser.showHelp(); + Q_UNREACHABLE(); + } + + _inputUrlParameter = QDir::fromNativeSeparators(parser.value(CLI_INPUT_PARAMETER)); + _outputUrlParameter = QDir::fromNativeSeparators(parser.value(CLI_OUTPUT_PARAMETER)); + + _typeParameter = parser.isSet(CLI_TYPE_PARAMETER) ? parser.value(CLI_TYPE_PARAMETER) : QString::null; + + if (parser.isSet(CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER)) { + qDebug() << "Disabling texture compression"; + TextureBaker::setCompressionEnabled(false); + } } diff --git a/tools/oven/src/OvenCLIApplication.h b/tools/oven/src/OvenCLIApplication.h index 5d81166f69..21fc9e9ba1 100644 --- a/tools/oven/src/OvenCLIApplication.h +++ b/tools/oven/src/OvenCLIApplication.h @@ -21,7 +21,14 @@ class OvenCLIApplication : public QCoreApplication, public Oven { public: OvenCLIApplication(int argc, char* argv[]); + static void parseCommandLine(int argc, char* argv[]); + static OvenCLIApplication* instance() { return dynamic_cast(QCoreApplication::instance()); } + +private: + static QUrl _inputUrlParameter; + static QUrl _outputUrlParameter; + static QString _typeParameter; }; #endif // hifi_OvenCLIApplication_h diff --git a/tools/oven/src/main.cpp b/tools/oven/src/main.cpp index 7009089402..586dae06a5 100644 --- a/tools/oven/src/main.cpp +++ b/tools/oven/src/main.cpp @@ -18,14 +18,19 @@ int main (int argc, char** argv) { setupHifiApplication("Oven"); - // init the settings interface so we can save and load settings - Setting::init(); - // figure out if we're launching our GUI application or just the simple command line interface if (argc > 1) { + OvenCLIApplication::parseCommandLine(argc, argv); + + // init the settings interface so we can save and load settings + Setting::init(); + OvenCLIApplication app { argc, argv }; return app.exec(); } else { + // init the settings interface so we can save and load settings + Setting::init(); + OvenGUIApplication app { argc, argv }; return app.exec(); } From 97038a71963c732dffb389ed7a746893633d1650 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 9 Aug 2019 17:20:41 -0700 Subject: [PATCH 2/6] Fix tracing warning spam --- libraries/shared/src/Profile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/shared/src/Profile.cpp b/libraries/shared/src/Profile.cpp index 1ad7b0785b..420b4ee54a 100644 --- a/libraries/shared/src/Profile.cpp +++ b/libraries/shared/src/Profile.cpp @@ -39,6 +39,10 @@ Q_LOGGING_CATEGORY(trace_baker, "trace.baker") #endif static bool tracingEnabled() { + if (!DependencyManager::isSet()) { + return false; + } + // Cheers, love! The cavalry's here! auto tracer = DependencyManager::get(); return (tracer && tracer->isEnabled()); From 44e2037e15b3886af66517ae3591bcc6fd65a6e5 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 12 Aug 2019 10:34:07 -0700 Subject: [PATCH 3/6] Quiet warnings, add convenience function --- libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.cpp | 9 +++++++-- libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.h | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.cpp index fef823718f..dd365efc16 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.cpp @@ -33,8 +33,8 @@ using namespace gpu::gl; #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F #endif -bool GLTexelFormat::isCompressed() const { - switch (internalFormat) { +bool GLTexelFormat::isCompressed(GLenum format) { + switch (format) { case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: @@ -92,6 +92,11 @@ bool GLTexelFormat::isCompressed() const { } } +bool GLTexelFormat::isCompressed() const { + return isCompressed(internalFormat); +} + + GLenum GLTexelFormat::evalGLTexelFormatInternal(const gpu::Element& dstFormat) { GLenum result = GL_RGBA8; switch (dstFormat.getDimension()) { diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.h b/libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.h index 8f37f6b604..b5c805c5b8 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLTexelFormat.h @@ -14,13 +14,15 @@ namespace gpu { namespace gl { class GLTexelFormat { public: - GLenum internalFormat; - GLenum format; - GLenum type; + GLenum internalFormat{ GL_RGBA8 }; + GLenum format{ GL_RGBA }; + GLenum type{ GL_UNSIGNED_BYTE }; GLTexelFormat(GLenum glinternalFormat, GLenum glformat, GLenum gltype) : internalFormat(glinternalFormat), format(glformat), type(gltype) {} GLTexelFormat(GLenum glinternalFormat) : internalFormat(glinternalFormat) {} + static bool isCompressed(GLenum glinternalFormat); + bool isCompressed() const; static GLTexelFormat evalGLTexelFormat(const Element& dstFormat) { From a01f1153578fc7facbf22053dc4b66a022266182 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 12 Aug 2019 10:34:37 -0700 Subject: [PATCH 4/6] Disable use of DSA to load cubemaps --- libraries/gpu-gl/src/gpu/gl45/GL45Backend.h | 1 + .../src/gpu/gl45/GL45BackendTexture.cpp | 82 ++++--------------- 2 files changed, 17 insertions(+), 66 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h index c1ce074188..3e7392e366 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h +++ b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h @@ -33,6 +33,7 @@ class GL45Backend : public GLBackend { friend class Context; public: + static const GLint RESOURCE_TRANSFER_TEX_UNIT { 32 }; static GLint MAX_COMBINED_SHADER_STORAGE_BLOCKS; static GLint MAX_UNIFORM_LOCATIONS; #if GPU_BINDLESS_TEXTURES diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index 81a6b100d0..bb31903d8e 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -226,81 +226,31 @@ void GL45Texture::generateMips() const { Size GL45Texture::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 = sourceSize; + bool compressed = GLTexelFormat::isCompressed(internalFormat); if (GL_TEXTURE_2D == _target) { - switch (internalFormat) { - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - 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: - case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: - case GL_COMPRESSED_RGB8_ETC2: - case GL_COMPRESSED_SRGB8_ETC2: - case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case GL_COMPRESSED_RGBA8_ETC2_EAC: - case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: - case GL_COMPRESSED_R11_EAC: - case GL_COMPRESSED_SIGNED_R11_EAC: - case GL_COMPRESSED_RG11_EAC: - case GL_COMPRESSED_SIGNED_RG11_EAC: - glCompressedTextureSubImage2D(_id, mip, 0, yOffset, size.x, size.y, internalFormat, - static_cast(sourceSize), sourcePointer); - break; - default: - glTextureSubImage2D(_id, mip, 0, yOffset, size.x, size.y, format, type, sourcePointer); - break; + if (compressed) { + glCompressedTextureSubImage2D(_id, mip, 0, yOffset, size.x, size.y, internalFormat, + static_cast(sourceSize), sourcePointer); + } else { + glTextureSubImage2D(_id, mip, 0, yOffset, size.x, size.y, format, type, sourcePointer); } } else if (GL_TEXTURE_CUBE_MAP == _target) { - switch (internalFormat) { - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - 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: - case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: - case GL_COMPRESSED_RGB8_ETC2: - case GL_COMPRESSED_SRGB8_ETC2: - case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: - case GL_COMPRESSED_RGBA8_ETC2_EAC: - case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: - case GL_COMPRESSED_R11_EAC: - case GL_COMPRESSED_SIGNED_R11_EAC: - case GL_COMPRESSED_RG11_EAC: - case GL_COMPRESSED_SIGNED_RG11_EAC: -#if AMD_CUBE_MAP_EXT_WORKAROUND - if (glCompressedTextureSubImage2DEXT) { - auto target = GLTexture::CUBE_FACE_LAYOUT[face]; - glCompressedTextureSubImage2DEXT(_id, target, mip, 0, yOffset, size.x, size.y, internalFormat, - static_cast(sourceSize), sourcePointer); - } else -#endif - { - glCompressedTextureSubImage3D(_id, mip, 0, yOffset, face, size.x, size.y, 1, internalFormat, - static_cast(sourceSize), sourcePointer); - } - break; - default: -#if AMD_CUBE_MAP_EXT_WORKAROUND - if (glTextureSubImage2DEXT) { - auto target = GLTexture::CUBE_FACE_LAYOUT[face]; - glTextureSubImage2DEXT(_id, target, mip, 0, yOffset, size.x, size.y, format, type, sourcePointer); - } else -#endif - { - glTextureSubImage3D(_id, mip, 0, yOffset, face, size.x, size.y, 1, format, type, sourcePointer); - } - break; + // DSA and cubemap functions are notoriously buggy. use the 4.1 compatible pathway + glActiveTexture(GL_TEXTURE0 + GL45Backend::RESOURCE_TRANSFER_TEX_UNIT); + glBindTexture(_target, _texture); + auto target = GLTexture::CUBE_FACE_LAYOUT[face]; + if (compressed) { + glCompressedTexSubImage2D(target, mip, 0, yOffset, size.x, size.y, internalFormat, + static_cast(sourceSize), sourcePointer); + } else { + glTexSubImage2D(target, mip, 0, yOffset, size.x, size.y, format, type, sourcePointer); } + glBindTexture(_target, 0); } else { assert(false); amountCopied = 0; } (void)CHECK_GL_ERROR(); - return amountCopied; } From a225a009cd430dbb1fd3899e10e402ccb3acbc09 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 12 Aug 2019 11:27:34 -0700 Subject: [PATCH 5/6] BUGZ-1233: Remove keyboard shortcut to LoD tools --- interface/src/Application.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 481975caac..062a8fa9c1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4418,8 +4418,6 @@ void Application::keyPressEvent(QKeyEvent* event) { } else if (isMeta) { auto dialogsManager = DependencyManager::get(); dialogsManager->toggleAddressBar(); - } else if (isShifted) { - Menu::getInstance()->triggerOption(MenuOption::LodTools); } break; From 90aeb636bd3a225fcffbe896fbffd786e6a7736f Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 12 Aug 2019 17:21:22 -0700 Subject: [PATCH 6/6] Delete reply after the callback is executed --- libraries/script-engine/src/XMLHttpRequestClass.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/script-engine/src/XMLHttpRequestClass.cpp b/libraries/script-engine/src/XMLHttpRequestClass.cpp index 51e3ef0759..571c0e2a0e 100644 --- a/libraries/script-engine/src/XMLHttpRequestClass.cpp +++ b/libraries/script-engine/src/XMLHttpRequestClass.cpp @@ -218,12 +218,12 @@ void XMLHttpRequestClass::requestFinished() { } } + setReadyState(DONE); + emit requestComplete(); + disconnectFromReply(_reply); _reply->deleteLater(); _reply = nullptr; - - setReadyState(DONE); - emit requestComplete(); } void XMLHttpRequestClass::abortRequest() {