From c8ab2f335e7ff792740371fb81bb4b136aa574bd Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Thu, 7 Aug 2025 15:24:40 -0700 Subject: [PATCH] Fix places where generateMipmaps is called without proper usage (#9054) --- libs/filamentapp/src/MeshAssimp.cpp | 1 + samples/image_viewer.cpp | 1 + samples/sample_cloth.cpp | 1 + samples/sample_full_pbr.cpp | 1 + samples/sample_normal_map.cpp | 2 ++ samples/suzanne.cpp | 1 + 6 files changed, 7 insertions(+) diff --git a/libs/filamentapp/src/MeshAssimp.cpp b/libs/filamentapp/src/MeshAssimp.cpp index 2027d2fb10..f4c4498017 100644 --- a/libs/filamentapp/src/MeshAssimp.cpp +++ b/libs/filamentapp/src/MeshAssimp.cpp @@ -204,6 +204,7 @@ Texture* MeshAssimp::createOneByOneTexture(uint32_t pixel) { .height(uint32_t(1)) .levels(0xff) .format(Texture::InternalFormat::RGBA8) + .usage(Texture::Usage::DEFAULT | Texture::Usage::GEN_MIPMAPPABLE) .build(mEngine); Texture::PixelBufferDescriptor defaultNormalBuffer(textureData, diff --git a/samples/image_viewer.cpp b/samples/image_viewer.cpp index 2185a7199e..dfb8c3c811 100644 --- a/samples/image_viewer.cpp +++ b/samples/image_viewer.cpp @@ -245,6 +245,7 @@ static void loadImage(App& app, Engine* engine, const Path& filename) { .format(channels == 3 ? Texture::InternalFormat::RGB16F : Texture::InternalFormat::RGBA16F) .sampler(Texture::Sampler::SAMPLER_2D) + .usage(Texture::Usage::DEFAULT | Texture::Usage::GEN_MIPMAPPABLE) .build(*engine); Texture::PixelBufferDescriptor::Callback freeCallback = [](void* buf, size_t, void* data) { diff --git a/samples/sample_cloth.cpp b/samples/sample_cloth.cpp index 9f02da1113..cff2907640 100644 --- a/samples/sample_cloth.cpp +++ b/samples/sample_cloth.cpp @@ -169,6 +169,7 @@ Texture* loadMap(Engine* engine, const char* name, bool sRGB = true) { .height(uint32_t(h)) .levels(0xff) .format(sRGB ? Texture::InternalFormat::SRGB8 : Texture::InternalFormat::RGB8) + .usage(Texture::Usage::DEFAULT | Texture::Usage::GEN_MIPMAPPABLE) .build(*engine); Texture::PixelBufferDescriptor buffer(data, size_t(w * h * 3), Texture::Format::RGB, Texture::Type::UBYTE, diff --git a/samples/sample_full_pbr.cpp b/samples/sample_full_pbr.cpp index 9984dfd67a..8d48af3854 100644 --- a/samples/sample_full_pbr.cpp +++ b/samples/sample_full_pbr.cpp @@ -220,6 +220,7 @@ bool loadTexture(Engine* engine, const std::string& filePath, Texture** map, boo .height(uint32_t(h)) .levels(0xff) .format(sRGB ? Texture::InternalFormat::SRGB8 : Texture::InternalFormat::RGB8) + .usage(Texture::Usage::DEFAULT | Texture::Usage::GEN_MIPMAPPABLE) .build(*engine); Texture::PixelBufferDescriptor buffer(data, size_t(w * h * 3), Texture::Format::RGB, Texture::Type::UBYTE, diff --git a/samples/sample_normal_map.cpp b/samples/sample_normal_map.cpp index 5cf2bdf593..ef33a9a560 100644 --- a/samples/sample_normal_map.cpp +++ b/samples/sample_normal_map.cpp @@ -193,6 +193,7 @@ void loadNormalMap(Engine* engine, Texture** normalMap, const std::string& path) .height(uint32_t(h)) .levels(0xff) .format(Texture::InternalFormat::RGB8) + .usage(Texture::Usage::DEFAULT | Texture::Usage::GEN_MIPMAPPABLE) .build(*engine); Texture::PixelBufferDescriptor buffer(data, size_t(w * h * 3), Texture::Format::RGB, Texture::Type::UBYTE, @@ -220,6 +221,7 @@ void loadBaseColorMap(Engine* engine) { .height(uint32_t(h)) .levels(0xff) .format(Texture::InternalFormat::SRGB8) + .usage(Texture::Usage::DEFAULT | Texture::Usage::GEN_MIPMAPPABLE) .build(*engine); Texture::PixelBufferDescriptor buffer(data, size_t(w * h * 3), Texture::Format::RGB, Texture::Type::UBYTE, diff --git a/samples/suzanne.cpp b/samples/suzanne.cpp index 22b2f618c8..4eb5486520 100644 --- a/samples/suzanne.cpp +++ b/samples/suzanne.cpp @@ -120,6 +120,7 @@ static Texture* loadNormalMap(Engine* engine, const uint8_t* normals, size_t nby .height(uint32_t(h)) .levels(0xff) .format(Texture::InternalFormat::RGB8) + .usage(Texture::Usage::DEFAULT | Texture::Usage::GEN_MIPMAPPABLE) .build(*engine); Texture::PixelBufferDescriptor buffer(data, size_t(w * h * 3), Texture::Format::RGB, Texture::Type::UBYTE,