diff --git a/android/build.gradle b/android/build.gradle index e041142282..71d48e28d4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -146,9 +146,9 @@ def packages = [ includeLibs: ['libplugins_libhifiCodec.so'] ], etc2comp: [ - file: 'etc2comp-armv8-libcpp.tgz', - versionId: '1WfqJYWLOP0g22eikYjBzn62gza7MKE6', - checksum: '0b4c2e6de728546845f0e471dfdeb604' + file: 'etc2comp-patched-armv8-libcpp.tgz', + versionId: 'bHhGECRAQR1vkpshBcK6ByNc1BQIM8gU', + checksum: '14b02795d774457a33bbc60e00a786bc' ] ] diff --git a/cmake/externals/etc2comp/CMakeLists.txt b/cmake/externals/etc2comp/CMakeLists.txt index 9cee0652bc..1de4932380 100644 --- a/cmake/externals/etc2comp/CMakeLists.txt +++ b/cmake/externals/etc2comp/CMakeLists.txt @@ -5,10 +5,12 @@ if (ANDROID) endif () include(ExternalProject) +# We use a patched version of etc2comp that properly generates all the necessary mips +# See https://github.com/google/etc2comp/pull/29 ExternalProject_Add( ${EXTERNAL_NAME} - URL https://hifi-public.s3.amazonaws.com/dependencies/etc2comp-master.zip - URL_MD5 d0969e14af6b10b3306f880c8e2b1184 + URL https://hifi-public.s3.amazonaws.com/dependencies/etc2comp-patched.zip + URL_MD5 6fe3629de8ff99bc99f8c14558d841a3 CMAKE_ARGS ${ANDROID_CMAKE_ARGS} BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build INSTALL_COMMAND "" diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 129c125411..839cb915e2 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -352,7 +352,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) { if (!Texture::evalKTXFormat(mipFormat, texelFormat, header)) { return nullptr; } - + // Set Dimensions uint32_t numFaces = 1; switch (texture.getType()) { diff --git a/libraries/image/src/image/Image.cpp b/libraries/image/src/image/Image.cpp index 55cafe9571..2fc22b4eac 100644 --- a/libraries/image/src/image/Image.cpp +++ b/libraries/image/src/image/Image.cpp @@ -31,14 +31,14 @@ using namespace gpu; #define CPU_MIPMAPS 1 #include -#ifdef Q_OS_ANDROID +#ifdef USE_GLES #include #include #endif static const glm::uvec2 SPARSE_PAGE_SIZE(128); #ifdef Q_OS_ANDROID -static const glm::uvec2 MAX_TEXTURE_SIZE(1024); +static const glm::uvec2 MAX_TEXTURE_SIZE(2048); #else static const glm::uvec2 MAX_TEXTURE_SIZE(4096); #endif @@ -46,7 +46,6 @@ bool DEV_DECIMATE_TEXTURES = false; std::atomic DECIMATED_TEXTURE_COUNT{ 0 }; std::atomic RECTIFIED_TEXTURE_COUNT{ 0 }; -// TODO: pick compressed android hdr format static const auto HDR_FORMAT = gpu::Element::COLOR_R11G11B10; static std::atomic compressColorTextures { false }; @@ -563,10 +562,10 @@ void generateLDRMips(gpu::Texture* texture, QImage&& image, const std::atomic(localCopy.constBits()); auto mipFormat = texture->getStoredMipFormat(); -#ifndef Q_OS_ANDROID +#ifndef USE_GLES + const void* data = static_cast(localCopy.constBits()); nvtt::TextureType textureType = nvtt::TextureType_2D; nvtt::InputFormat inputFormat = nvtt::InputFormat_BGRA_8UB; nvtt::WrapMode wrapMode = nvtt::WrapMode_Mirror; @@ -681,43 +680,41 @@ void generateLDRMips(gpu::Texture* texture, QImage&& image, const std::atomic floatData; floatData.resize(width * height); @@ -725,27 +722,28 @@ void generateLDRMips(gpu::Texture* texture, QImage&& image, const std::atomic= 0) { - texture->assignStoredMipFace(i, face, mipMaps[i].uiEncodingBitsBytes, static_cast(mipMaps[i].paucEncodingBits.get())); - } else { - texture->assignStoredMip(i, mipMaps[i].uiEncodingBitsBytes, static_cast(mipMaps[i].paucEncodingBits.get())); + if (mipMaps[i].paucEncodingBits.get()) { + if (face >= 0) { + texture->assignStoredMipFace(i, face, mipMaps[i].uiEncodingBitsBytes, static_cast(mipMaps[i].paucEncodingBits.get())); + } else { + texture->assignStoredMip(i, mipMaps[i].uiEncodingBitsBytes, static_cast(mipMaps[i].paucEncodingBits.get())); + } } } @@ -755,8 +753,6 @@ void generateLDRMips(gpu::Texture* texture, QImage&& image, const std::atomic& abortProcessing = false, int face = -1) { #if CPU_MIPMAPS PROFILE_RANGE(resource_parse, "generateMips"); @@ -828,14 +824,15 @@ gpu::TexturePointer TextureUsage::process2DTextureColorFromImage(QImage&& srcIma formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_SRGB; } } else { -#ifdef Q_OS_ANDROID +#ifdef USE_GLES // GLES does not support GL_BGRA formatGPU = gpu::Element::COLOR_COMPRESSED_ETC2_SRGBA; + formatMip = formatGPU; #else - formatGPU = gpu::Element::COLOR_SBGRA_32; + formatGPU = gpu::Element::COLOR_SRGBA_32; + formatMip = gpu::Element::COLOR_SBGRA_32; #endif } - formatMip = formatGPU; if (isStrict) { theTexture = gpu::Texture::createStrict(formatGPU, image.width(), image.height(), gpu::Texture::MAX_NUM_MIPS, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)); @@ -954,7 +951,7 @@ gpu::TexturePointer TextureUsage::process2DTextureNormalMapFromImage(QImage&& sr if (isNormalTexturesCompressionEnabled()) { formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_XY; } else { -#ifdef Q_OS_ANDROID +#ifdef USE_GLES formatGPU = gpu::Element::COLOR_COMPRESSED_EAC_XY; #else formatGPU = gpu::Element::VEC2NU8_XY; @@ -994,7 +991,7 @@ gpu::TexturePointer TextureUsage::process2DTextureGrayscaleFromImage(QImage&& sr if (isGrayscaleTexturesCompressionEnabled()) { formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_RED; } else { -#ifdef Q_OS_ANDROID +#ifdef USE_GLES formatGPU = gpu::Element::COLOR_COMPRESSED_EAC_RED; #else formatGPU = gpu::Element::COLOR_R_8;