From 9bce361b3eae51333a2814808734062bad5f2b47 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 20 Jun 2019 14:53:16 -0700 Subject: [PATCH] Remove RGBM support entirely from filament. :warning: this break c++ and java source compatibility --- RELEASE_NOTES.md | 3 +++ .../filament-android/src/main/cpp/Texture.cpp | 13 ------------- .../com/google/android/filament/Texture.java | 12 ++---------- filament/backend/include/backend/DriverEnums.h | 4 ++-- .../include/backend/PixelBufferDescriptor.h | 2 +- filament/backend/src/CommandStream.cpp | 1 - filament/backend/src/opengl/GLUtils.h | 2 +- filament/include/filament/IndirectLight.h | 8 ++------ filament/include/filament/Texture.h | 16 ---------------- filament/src/Texture.cpp | 11 ----------- filament/src/details/Texture.h | 2 -- libs/image/include/image/KtxUtility.h | 10 ++++------ web/filament-js/jsbindings.cpp | 6 ++---- web/filament-js/jsenums.cpp | 1 - 14 files changed, 17 insertions(+), 74 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d3be6bfdec..141129a2a1 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -8,6 +8,9 @@ A new header is inserted each time a *tag* is created. - Added JNI bindings for the gltfio library. - Fix support for parameter arrays in `.mat` files. +- Added support for `RGB_11_11_10` +- Removed support for `RGBM` (**warning:** source compatibility breakage) +- IBL cubemap can now be of any size ## sceneform-1.9pr3 diff --git a/android/filament-android/src/main/cpp/Texture.cpp b/android/filament-android/src/main/cpp/Texture.cpp index bb1ec43ff3..94c3f7d94d 100644 --- a/android/filament-android/src/main/cpp/Texture.cpp +++ b/android/filament-android/src/main/cpp/Texture.cpp @@ -106,13 +106,6 @@ Java_com_google_android_filament_Texture_nBuilderFormat(JNIEnv*, jclass, builder->format((Texture::InternalFormat) format); } -extern "C" JNIEXPORT void JNICALL -Java_com_google_android_filament_Texture_nBuilderRgbm(JNIEnv*, jclass, - jlong nativeBuilder, jboolean enable) { - Texture::Builder *builder = (Texture::Builder *) nativeBuilder; - builder->rgbm(enable); -} - extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Texture_nBuilderUsage(JNIEnv*, jclass, jlong nativeBuilder, jint flags) { @@ -170,12 +163,6 @@ Java_com_google_android_filament_Texture_nGetInternalFormat(JNIEnv*, jclass, return (jint) texture->getFormat(); } -extern "C" JNIEXPORT jboolean JNICALL -Java_com_google_android_filament_Texture_nGetRgbm(JNIEnv*, jclass, jlong nativeTexture) { - Texture *texture = (Texture *) nativeTexture; - return static_cast(texture->isRgbm()); -} - extern "C" JNIEXPORT jint JNICALL Java_com_google_android_filament_Texture_nSetImage(JNIEnv* env, jclass, jlong nativeTexture, jlong nativeEngine, jint level, jint xoffset, jint yoffset, jint width, jint height, diff --git a/android/filament-android/src/main/java/com/google/android/filament/Texture.java b/android/filament-android/src/main/java/com/google/android/filament/Texture.java index 2607fe7c99..8b03683554 100644 --- a/android/filament-android/src/main/java/com/google/android/filament/Texture.java +++ b/android/filament-android/src/main/java/com/google/android/filament/Texture.java @@ -62,7 +62,7 @@ public class Texture { RG16F, RG16UI, RG16I, R11F_G11F_B10F, RGBA8, SRGB8_A8, RGBA8_SNORM, - UNUSED, // The RGBM InternalFormat has been replaced with a flag (Texture.Builder.rgbm) + UNUSED, // used to be rgbm RGB10_A2, RGBA8UI, RGBA8I, DEPTH32F, DEPTH24_STENCIL8, DEPTH32F_STENCIL8, @@ -120,7 +120,7 @@ public class Texture { RGB_INTEGER, RGBA, RGBA_INTEGER, - RGBM, + UNUSED, DEPTH_COMPONENT, DEPTH_STENCIL, STENCIL_INDEX, @@ -254,7 +254,6 @@ public class Texture { break; case RGBA: case RGBA_INTEGER: - case RGBM: n = 4; break; } @@ -335,12 +334,6 @@ public class Texture { return this; } - @NonNull - public Builder rgbm(boolean enabled) { - nBuilderRgbm(mNativeBuilder, enabled); - return this; - } - /** * Sets the usage flags, which is necessary when attaching to {@link RenderTarget}. * @@ -515,7 +508,6 @@ public class Texture { private static native void nBuilderLevels(long nativeBuilder, int levels); private static native void nBuilderSampler(long nativeBuilder, int sampler); private static native void nBuilderFormat(long nativeBuilder, int format); - private static native void nBuilderRgbm(long nativeBuilder, boolean enabled); private static native void nBuilderUsage(long nativeBuilder, int flags); private static native long nBuilderBuild(long nativeBuilder, long nativeEngine); diff --git a/filament/backend/include/backend/DriverEnums.h b/filament/backend/include/backend/DriverEnums.h index 89d11032bd..4851fa4300 100644 --- a/filament/backend/include/backend/DriverEnums.h +++ b/filament/backend/include/backend/DriverEnums.h @@ -266,7 +266,7 @@ enum class PixelDataFormat : uint8_t { RGB_INTEGER, RGBA, RGBA_INTEGER, - RGBM, + UNUSED, // used to be rgbm DEPTH_COMPONENT, DEPTH_STENCIL, ALPHA @@ -420,7 +420,7 @@ enum class TextureFormat : uint16_t { RG16F, RG16UI, RG16I, R11F_G11F_B10F, RGBA8, SRGB8_A8,RGBA8_SNORM, - UNUSED, // The RGBM InternalFormat has been replaced with a flag (Texture::Builder::rgbm) + UNUSED, // used to be rgbm RGB10_A2, RGBA8UI, RGBA8I, DEPTH32F, DEPTH24_STENCIL8, DEPTH32F_STENCIL8, diff --git a/filament/backend/include/backend/PixelBufferDescriptor.h b/filament/backend/include/backend/PixelBufferDescriptor.h index 550388f9d1..56e27171f1 100644 --- a/filament/backend/include/backend/PixelBufferDescriptor.h +++ b/filament/backend/include/backend/PixelBufferDescriptor.h @@ -85,9 +85,9 @@ public: case PixelDataFormat::RGB_INTEGER: n = 3; break; + case PixelDataFormat::UNUSED: // shouldn't happen (used to be rgbm) case PixelDataFormat::RGBA: case PixelDataFormat::RGBA_INTEGER: - case PixelDataFormat::RGBM: n = 4; break; } diff --git a/filament/backend/src/CommandStream.cpp b/filament/backend/src/CommandStream.cpp index 1f6d5bc418..4e774a292c 100644 --- a/filament/backend/src/CommandStream.cpp +++ b/filament/backend/src/CommandStream.cpp @@ -269,7 +269,6 @@ io::ostream& operator<<(io::ostream& out, PixelDataFormat format) { CASE(PixelDataFormat, RGB_INTEGER) CASE(PixelDataFormat, RGBA) CASE(PixelDataFormat, RGBA_INTEGER) - CASE(PixelDataFormat, RGBM) CASE(PixelDataFormat, DEPTH_COMPONENT) CASE(PixelDataFormat, DEPTH_STENCIL) CASE(PixelDataFormat, ALPHA) diff --git a/filament/backend/src/opengl/GLUtils.h b/filament/backend/src/opengl/GLUtils.h index 7464318adc..c983c5cad8 100644 --- a/filament/backend/src/opengl/GLUtils.h +++ b/filament/backend/src/opengl/GLUtils.h @@ -244,7 +244,7 @@ constexpr inline GLenum getFormat(backend::PixelDataFormat format) noexcept { case PixelDataFormat::RGB_INTEGER: return GL_RGB_INTEGER; case PixelDataFormat::RGBA: return GL_RGBA; case PixelDataFormat::RGBA_INTEGER: return GL_RGBA_INTEGER; - case PixelDataFormat::RGBM: return GL_RGBA; + case PixelDataFormat::UNUSED: return GL_RGBA; // should never happen (used to be rgbm) case PixelDataFormat::DEPTH_COMPONENT: return GL_DEPTH_COMPONENT; case PixelDataFormat::DEPTH_STENCIL: return GL_DEPTH_STENCIL; case PixelDataFormat::ALPHA: return GL_ALPHA; diff --git a/filament/include/filament/IndirectLight.h b/filament/include/filament/IndirectLight.h index c30517b93f..e4e03bfad0 100644 --- a/filament/include/filament/IndirectLight.h +++ b/filament/include/filament/IndirectLight.h @@ -108,13 +108,9 @@ public: * * @param cubemap A mip-mapped cubemap generated by **cmgen**. Each cubemap level * encodes a the irradiance for a roughness level. - * The cubemap *must be* in `RGBM` format. * * @return This Builder, for chaining calls. * - * @attention - * \p cubemap *must* be encoded in `RGBM` format - * */ Builder& reflections(Texture const* cubemap) noexcept; @@ -224,7 +220,7 @@ public: /** * (optional) Environment intensity. * - * Because the environment is encoded in RGBM, it has a limited range and precision, the + * Because the environment is encoded usually relative to some reference, the * range can be adjusted with this method. * * @param envIntensity Scale factor applied to the environment and irradiance such that @@ -264,7 +260,7 @@ public: /** * Sets the environment's intensity. * - * Because the environment is encoded in RGBM, it has a limited range and precision, the + * Because the environment is encoded usually relative to some reference, the * range can be adjusted with this method. * * @param intensity Scale factor applied to the environment and irradiance such that diff --git a/filament/include/filament/Texture.h b/filament/include/filament/Texture.h index 6d67e91618..2b8aff8330 100644 --- a/filament/include/filament/Texture.h +++ b/filament/include/filament/Texture.h @@ -160,16 +160,6 @@ public: */ Builder& usage(Usage usage) noexcept; - /** - * Specifies that the alpha channel contains a color multiplier (e.g. for HDR) - * The default value is false. - * - * @param enabled True if the shader should interpret alpha as a color multiplier - * - * @return This Builder, for chaining calls. - */ - Builder& rgbm(bool enabled) noexcept; - /** * Creates the Texture object and returns a pointer to it. * @@ -235,12 +225,6 @@ public: */ InternalFormat getFormat() const noexcept; - /** - * Return if this texture has RGBM data as set by Builder::rgbm(). - * @return if this texture has RGBM data as set by Builder::rgbm(). - */ - bool isRgbm() const noexcept; - /** * Specify the image of a 2D texture for a level. * diff --git a/filament/src/Texture.cpp b/filament/src/Texture.cpp index c4286093d9..973bd4630b 100644 --- a/filament/src/Texture.cpp +++ b/filament/src/Texture.cpp @@ -35,7 +35,6 @@ struct Texture::BuilderDetails { uint8_t mLevels = 1; Sampler mTarget = Sampler::SAMPLER_2D; InternalFormat mFormat = InternalFormat::RGBA8; - bool mRgbm = false; Usage mUsage = Usage::DEFAULT; }; @@ -78,11 +77,6 @@ Texture::Builder& Texture::Builder::format(Texture::InternalFormat format) noexc return *this; } -Texture::Builder& Texture::Builder::rgbm(bool enabled) noexcept { - mImpl->mRgbm = enabled; - return *this; -} - Texture::Builder& Texture::Builder::usage(Texture::Usage usage) noexcept { mImpl->mUsage = Texture::Usage(usage); return *this; @@ -104,7 +98,6 @@ FTexture::FTexture(FEngine& engine, const Builder& builder) { mWidth = static_cast(builder->mWidth); mHeight = static_cast(builder->mHeight); mFormat = builder->mFormat; - mRgbm = builder->mRgbm; mUsage = builder->mUsage; mTarget = builder->mTarget; mDepth = static_cast(builder->mDepth); @@ -373,10 +366,6 @@ Texture::InternalFormat Texture::getFormat() const noexcept { return upcast(this)->getFormat(); } -bool Texture::isRgbm() const noexcept { - return upcast(this)->isRgbm(); -} - void Texture::setImage(Engine& engine, size_t level, Texture::PixelBufferDescriptor&& buffer) const noexcept { upcast(this)->setImage(upcast(engine), diff --git a/filament/src/details/Texture.h b/filament/src/details/Texture.h index e6b130d9eb..db64b17676 100644 --- a/filament/src/details/Texture.h +++ b/filament/src/details/Texture.h @@ -52,7 +52,6 @@ public: Sampler getTarget() const noexcept { return mTarget; } InternalFormat getFormat() const noexcept { return mFormat; } Usage getUsage() const noexcept { return mUsage; } - bool isRgbm() const noexcept { return mRgbm; } void setImage(FEngine& engine, size_t level, uint32_t xoffset, uint32_t yoffset, uint32_t width, uint32_t height, @@ -87,7 +86,6 @@ private: uint32_t mHeight = 1; uint32_t mDepth = 1; InternalFormat mFormat = InternalFormat::RGBA8; - bool mRgbm = false; Sampler mTarget = Sampler::SAMPLER_2D; uint8_t mLevelCount = 1; uint8_t mSampleCount = 1; diff --git a/libs/image/include/image/KtxUtility.h b/libs/image/include/image/KtxUtility.h index 97d35578b3..712defb44c 100644 --- a/libs/image/include/image/KtxUtility.h +++ b/libs/image/include/image/KtxUtility.h @@ -45,7 +45,7 @@ namespace KtxUtility { CompressedPixelDataType toCompressedPixelDataType(const KtxInfo& info); PixelDataType toPixelDataType(const KtxInfo& info); - PixelDataFormat toPixelDataFormat(const KtxInfo& info, bool rgbm); + PixelDataFormat toPixelDataFormat(const KtxInfo& info); bool isCompressed(const KtxInfo& info); TextureFormat toTextureFormat(const KtxInfo& info); @@ -66,7 +66,7 @@ namespace KtxUtility { const uint32_t nmips = ktx.getNumMipLevels(); const auto cdatatype = toCompressedPixelDataType(ktxinfo); const auto datatype = toPixelDataType(ktxinfo); - const auto dataformat = toPixelDataFormat(ktxinfo, rgbm); + const auto dataformat = toPixelDataFormat(ktxinfo); auto texformat = toTextureFormat(ktxinfo); if (srgb) { @@ -83,7 +83,6 @@ namespace KtxUtility { .height(ktxinfo.pixelHeight) .levels(static_cast(nmips)) .sampler(ktx.isCubemap() ? Sampler::SAMPLER_CUBEMAP : Sampler::SAMPLER_2D) - .rgbm(rgbm) .format(texformat) .build(*engine); @@ -223,14 +222,13 @@ namespace KtxUtility { return (PixelDataType) 0xff; } - inline PixelDataFormat toPixelDataFormat(const KtxInfo& info, bool rgbm) { + inline PixelDataFormat toPixelDataFormat(const KtxInfo& info) { switch (info.glFormat) { case KtxBundle::LUMINANCE: case KtxBundle::RED: return PixelDataFormat::R; case KtxBundle::RG: return PixelDataFormat::RG; case KtxBundle::RGB: return PixelDataFormat::RGB; - case KtxBundle::RGBA: - return rgbm ? PixelDataFormat::RGBM : PixelDataFormat::RGBA; + case KtxBundle::RGBA: return PixelDataFormat::RGBA; case KtxBundle::R11F_G11F_B10F: return PixelDataFormat::RGB; } return (PixelDataFormat) 0xff; diff --git a/web/filament-js/jsbindings.cpp b/web/filament-js/jsbindings.cpp index c4a3136b46..0008fab515 100644 --- a/web/filament-js/jsbindings.cpp +++ b/web/filament-js/jsbindings.cpp @@ -882,9 +882,7 @@ class_("Texture$Builder") .BUILDER_FUNCTION("format", TexBuilder, (TexBuilder* builder, Texture::InternalFormat fmt), { return &builder->format(fmt); }) .BUILDER_FUNCTION("usage", TexBuilder, (TexBuilder* builder, Texture::Usage usage), { - return &builder->usage(usage); }) - .BUILDER_FUNCTION("rgbm", TexBuilder, (TexBuilder* builder, bool rgbm), { - return &builder->rgbm(rgbm); }); + return &builder->usage(usage); }); class_("IndirectLight") .class_function("Builder", (IblBuilder (*)()) [] { return IblBuilder(); }) @@ -1012,7 +1010,7 @@ class_("KtxBundle") /// Returns "undefined" if no valid Filament enumerant exists. .function("getPixelDataFormat", EMBIND_LAMBDA(backend::PixelDataFormat, (KtxBundle* self, bool rgbm), { - return KtxUtility::toPixelDataFormat(self->getInfo(), rgbm); + return KtxUtility::toPixelDataFormat(self->getInfo()); }), allow_raw_pointers()) /// getPixelDataType ::method:: diff --git a/web/filament-js/jsenums.cpp b/web/filament-js/jsenums.cpp index 13282e5f51..35923ec8b5 100644 --- a/web/filament-js/jsenums.cpp +++ b/web/filament-js/jsenums.cpp @@ -238,7 +238,6 @@ enum_("PixelDataFormat") .value("RGB_INTEGER", backend::PixelDataFormat::RGB_INTEGER) .value("RGBA", backend::PixelDataFormat::RGBA) .value("RGBA_INTEGER", backend::PixelDataFormat::RGBA_INTEGER) - .value("RGBM", backend::PixelDataFormat::RGBM) .value("DEPTH_COMPONENT", backend::PixelDataFormat::DEPTH_COMPONENT) .value("DEPTH_STENCIL", backend::PixelDataFormat::DEPTH_STENCIL) .value("ALPHA", backend::PixelDataFormat::ALPHA);