Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(renderer): mip chains for compressed textures

esengine75309811b2a8
diff --git a/native/host_js/ktx2_decode.cpp b/native/host_js/ktx2_decode.cpp
index 86f50ec1a..54a9136cd 100644
--- a/native/host_js/ktx2_decode.cpp
+++ b/native/host_js/ktx2_decode.cpp
@@ -70,17 +70,35 @@ KTX2Result transcodeKTX2(const uint8_t* bytes, size_t n, bool srgb,
}
}
+ // A compressed texture keeps the KTX2's pre-baked mip chain (basis cannot
+ // generate mips for block formats); the RGBA32 fallback uploads base only.
// output_blocks_buf_size counts blocks (block formats) or pixels (RGBA32);
- // block_width/height is 1 for RGBA32, so this expression covers both.
+ // block_width/height is 1 for RGBA32, so this covers both.
const uint32_t bw = basist::basis_get_block_width(basisFmt);
const uint32_t bh = basist::basis_get_block_height(basisFmt);
- const uint32_t units = ((w + bw - 1) / bw) * ((h + bh - 1) / bh);
- std::vector<uint8_t> out(static_cast<size_t>(units) * basist::basis_get_bytes_per_block_or_pixel(basisFmt));
- if (!t.transcode_image_level(0, 0, 0, out.data(), units, basisFmt)) return fail;
+ const uint32_t bpb = basist::basis_get_bytes_per_block_or_pixel(basisFmt);
+ const uint32_t numLevels = compressed ? (t.get_levels() ? t.get_levels() : 1u) : 1u;
+
+ // Pack each level tightly, level 0 first — the layout the device unpacks.
+ std::vector<uint8_t> out;
+ uint32_t uploaded = 0;
+ for (uint32_t level = 0; level < numLevels; ++level) {
+ const uint32_t lw = (w >> level) ? (w >> level) : 1u;
+ const uint32_t lh = (h >> level) ? (h >> level) : 1u;
+ const uint32_t units = ((lw + bw - 1) / bw) * ((lh + bh - 1) / bh);
+ const size_t off = out.size();
+ out.resize(off + static_cast<size_t>(units) * bpb);
+ if (!t.transcode_image_level(level, 0, 0, out.data() + off, units, basisFmt)) {
+ out.resize(off); // drop the partial level and stop
+ break;
+ }
+ ++uploaded;
+ }
+ if (uploaded == 0) return fail;
const ConstSpan<u8> span(out.data(), out.size());
const resource::TextureHandle handle = compressed
- ? rm.createCompressedTexture(w, h, gfxFmt, span)
+ ? rm.createCompressedTexture(w, h, gfxFmt, span, uploaded)
: rm.createTexture(w, h, span, srgb ? TextureFormat::SRGB8A8 : TextureFormat::RGBA8, false);
if (!handle.isValid()) return fail;
return KTX2Result{static_cast<int>(handle.id()), static_cast<int>(w), static_cast<int>(h)};
diff --git a/src/esengine/renderer/GLDevice.cpp b/src/esengine/renderer/GLDevice.cpp
index 245419e49..2c3b1670f 100644
--- a/src/esengine/renderer/GLDevice.cpp
+++ b/src/esengine/renderer/GLDevice.cpp
@@ -894,17 +894,34 @@ TextureHandle GLDevice::createTexture(const TextureDesc& desc, const void* pixel
}
TextureHandle GLDevice::createCompressedTexture(const TextureDesc& desc, GfxCompressedFormat format,
- const void* data, u32 byteLength) {
+ const void* data, u32 byteLength, u32 mipLevels) {
GLuint id = 0;
glGenTextures(1, &id);
texture_formats_[id] = desc.format;
-
bindTextureForEdit(id);
- glCompressedTexImage2D(GL_TEXTURE_2D, 0, toGLCompressedFormat(format),
- static_cast<GLsizei>(desc.width), static_cast<GLsizei>(desc.height),
- 0, static_cast<GLsizei>(byteLength), data);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, toGLFilter(desc.minFilter));
+ // Upload each mip level from the concatenated, block-aligned pyramid.
+ const u32 levels = mipLevels ? mipLevels : 1;
+ const GfxBlockInfo bi = gfxCompressedBlockInfo(format);
+ const GLenum glFmt = toGLCompressedFormat(format);
+ const u8* ptr = static_cast<const u8*>(data);
+ const u8* end = ptr + byteLength;
+ for (u32 level = 0; level < levels; ++level) {
+ const u32 lw = (desc.width >> level) ? (desc.width >> level) : 1u;
+ const u32 lh = (desc.height >> level) ? (desc.height >> level) : 1u;
+ const u32 blocksX = (lw + bi.blockWidth - 1) / bi.blockWidth;
+ const u32 blocksY = (lh + bi.blockHeight - 1) / bi.blockHeight;
+ const u32 levelBytes = blocksX * blocksY * bi.bytesPerBlock;
+ if (ptr + levelBytes > end) break;
+ glCompressedTexImage2D(GL_TEXTURE_2D, static_cast<GLint>(level), glFmt,
+ static_cast<GLsizei>(lw), static_cast<GLsizei>(lh),
+ 0, static_cast<GLsizei>(levelBytes), ptr);
+ ptr += levelBytes;
+ }
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, static_cast<GLint>(levels - 1));
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ levels > 1 ? GL_LINEAR_MIPMAP_LINEAR : toGLFilter(desc.minFilter));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, toGLFilter(desc.magFilter));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, toGLWrap(desc.wrapS));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, toGLWrap(desc.wrapT));
diff --git a/src/esengine/renderer/GLDevice.hpp b/src/esengine/renderer/GLDevice.hpp
index 2ed93526a..a6e79d99c 100644
--- a/src/esengine/renderer/GLDevice.hpp
+++ b/src/esengine/renderer/GLDevice.hpp
@@ -58,7 +58,7 @@ public:
TextureHandle createTexture(const TextureDesc& desc, const void* pixels) override;
TextureHandle createCompressedTexture(const TextureDesc& desc, GfxCompressedFormat format,
- const void* data, u32 byteLength) override;
+ const void* data, u32 byteLength, u32 mipLevels) override;
TextureHandle importExternalTexture(u32 nativeId, const TextureDesc& desc) override;
void deleteTexture(TextureHandle texture) override;
void updateTexture(TextureHandle texture, i32 x, i32 y, u32 width, u32 height,
diff --git a/src/esengine/renderer/GfxDevice.hpp b/src/esengine/renderer/GfxDevice.hpp
index edccc2f74..2bbf96bcc 100644
--- a/src/esengine/renderer/GfxDevice.hpp
+++ b/src/esengine/renderer/GfxDevice.hpp
@@ -152,9 +152,13 @@ public:
* @details The caller must first confirm the backend supports `format`
* (see supportsCompressedFormat) and fall back to an uncompressed
* createTexture otherwise. Data is uploaded as-is; no CPU-side decode.
+ * @param data All @p mipLevels concatenated, level 0 (base) first, each block-
+ * aligned (`gfxCompressedPyramidBytes`). Level i has size
+ * `max(1, width>>i) x max(1, height>>i)`.
+ * @param mipLevels Number of mip levels present (1 = base only).
*/
virtual TextureHandle createCompressedTexture(const TextureDesc& desc, GfxCompressedFormat format,
- const void* data, u32 byteLength) = 0;
+ const void* data, u32 byteLength, u32 mipLevels) = 0;
/**
* @brief Wraps a texture created outside the device (e.g. a JS-side WebGL upload).
diff --git a/src/esengine/renderer/GfxEnums.hpp b/src/esengine/renderer/GfxEnums.hpp
index fc53cfe25..82fc6d215 100644
--- a/src/esengine/renderer/GfxEnums.hpp
+++ b/src/esengine/renderer/GfxEnums.hpp
@@ -205,6 +205,44 @@ enum class GfxCompressedFormat : u8 {
S3TC_DXT5_SRGB, ///< GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT (extension)
};
+/** @brief Block footprint of a compressed format, the single source both backends
+ * use to size each mip level's upload. BC1/ETC2_RGB are 4x4x8B, the RGBA
+ * block formats 4x4x16B, ASTC's block matches its name. */
+struct GfxBlockInfo {
+ u32 blockWidth;
+ u32 blockHeight;
+ u32 bytesPerBlock;
+};
+inline GfxBlockInfo gfxCompressedBlockInfo(GfxCompressedFormat fmt) {
+ switch (fmt) {
+ case GfxCompressedFormat::S3TC_DXT1: return {4, 4, 8}; // BC1
+ case GfxCompressedFormat::ETC2_RGB8: return {4, 4, 8};
+ case GfxCompressedFormat::ASTC_8x8: return {8, 8, 16};
+ case GfxCompressedFormat::S3TC_DXT5:
+ case GfxCompressedFormat::S3TC_DXT5_SRGB:
+ case GfxCompressedFormat::ETC2_RGBA8:
+ case GfxCompressedFormat::ETC2_RGBA8_SRGB:
+ case GfxCompressedFormat::ASTC_4x4:
+ case GfxCompressedFormat::ASTC_4x4_SRGB:
+ default: return {4, 4, 16};
+ }
+}
+
+/** @brief Total bytes of a full mip pyramid (levels 0..mipLevels-1) for a
+ * base-size compressed texture — the block-aligned sum both the transcoder
+ * (packing) and the device (uploading) agree on. */
+inline u32 gfxCompressedPyramidBytes(GfxCompressedFormat fmt, u32 width, u32 height, u32 mipLevels) {
+ const GfxBlockInfo bi = gfxCompressedBlockInfo(fmt);
+ u32 total = 0;
+ for (u32 level = 0; level < (mipLevels ? mipLevels : 1); ++level) {
+ const u32 lw = (width >> level) ? (width >> level) : 1u;
+ const u32 lh = (height >> level) ? (height >> level) : 1u;
+ total += ((lw + bi.blockWidth - 1) / bi.blockWidth)
+ * ((lh + bi.blockHeight - 1) / bi.blockHeight) * bi.bytesPerBlock;
+ }
+ return total;
+}
+
// =============================================================================
// Resource Descriptors
// =============================================================================
diff --git a/src/esengine/renderer/Texture.cpp b/src/esengine/renderer/Texture.cpp
index 50ce957a4..011665ea2 100644
--- a/src/esengine/renderer/Texture.cpp
+++ b/src/esengine/renderer/Texture.cpp
@@ -124,7 +124,8 @@ Unique<Texture> Texture::createRaw(GfxDevice& device, u32 width, u32 height, con
}
Unique<Texture> Texture::createCompressed(GfxDevice& device, u32 width, u32 height,
- GfxCompressedFormat format, std::span<const u8> data) {
+ GfxCompressedFormat format, std::span<const u8> data,
+ u32 mipLevels) {
auto texture = makeUnique<Texture>();
texture->device_ = &device;
texture->width_ = width;
@@ -138,9 +139,10 @@ Unique<Texture> Texture::createCompressed(GfxDevice& device, u32 width, u32 heig
desc.magFilter = TextureFilter::Linear;
desc.wrapS = TextureWrap::ClampToEdge;
desc.wrapT = TextureWrap::ClampToEdge;
- desc.mipmaps = false;
+ desc.mipmaps = mipLevels > 1;
- texture->handle_ = device.createCompressedTexture(desc, format, data.data(), static_cast<u32>(data.size()));
+ texture->handle_ = device.createCompressedTexture(desc, format, data.data(),
+ static_cast<u32>(data.size()), mipLevels);
if (texture->handle_ == TextureHandle::Invalid) {
ES_LOG_ERROR("Texture::createCompressed: failed for {}x{}", width, height);
return nullptr;
diff --git a/src/esengine/renderer/Texture.hpp b/src/esengine/renderer/Texture.hpp
index 40840acdd..7cf4da5d6 100644
--- a/src/esengine/renderer/Texture.hpp
+++ b/src/esengine/renderer/Texture.hpp
@@ -247,7 +247,8 @@ public:
* @param data Compressed block data for mip level 0.
*/
static Unique<Texture> createCompressed(GfxDevice& device, u32 width, u32 height,
- GfxCompressedFormat format, std::span<const u8> data);
+ GfxCompressedFormat format, std::span<const u8> data,
+ u32 mipLevels = 1);
/**
* @brief Wraps an existing GL texture ID
diff --git a/src/esengine/renderer/webgpu/WebGPUDevice.cpp b/src/esengine/renderer/webgpu/WebGPUDevice.cpp
index 78ee8a08a..f418ef8b8 100644
--- a/src/esengine/renderer/webgpu/WebGPUDevice.cpp
+++ b/src/esengine/renderer/webgpu/WebGPUDevice.cpp
@@ -517,7 +517,7 @@ TextureHandle WebGPUDevice::createTexture(const TextureDesc& desc, const void* p
}
TextureHandle WebGPUDevice::createCompressedTexture(const TextureDesc& desc, GfxCompressedFormat format,
- const void* data, u32 byteLength) {
+ const void* data, u32 byteLength, u32 mipLevels) {
if (!device_ || !queue_) {
ES_LOG_ERROR("WebGPUDevice::createCompressedTexture: no device");
return TextureHandle::Invalid;
@@ -527,12 +527,13 @@ TextureHandle WebGPUDevice::createCompressedTexture(const TextureDesc& desc, Gfx
ES_LOG_ERROR("WebGPUDevice::createCompressedTexture: unmapped format");
return TextureHandle::Invalid;
}
+ const u32 levels = mipLevels ? mipLevels : 1;
WGPUTextureDescriptor td{};
td.dimension = WGPUTextureDimension_2D;
td.format = wgpuFmt;
td.size = WGPUExtent3D{desc.width, desc.height, 1};
- td.mipLevelCount = 1;
+ td.mipLevelCount = levels;
td.sampleCount = 1;
td.usage = WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopyDst; // compressed = sampled, never a target
@@ -542,18 +543,29 @@ TextureHandle WebGPUDevice::createCompressedTexture(const TextureDesc& desc, Gfx
return TextureHandle::Invalid;
}
- // writeTexture counts BLOCKS, not pixels: a partial edge block still counts.
- const CompressedBlockInfo bi = compressedBlockInfo(format);
- const u32 blocksX = (desc.width + bi.blockWidth - 1) / bi.blockWidth;
- const u32 blocksY = (desc.height + bi.blockHeight - 1) / bi.blockHeight;
- WGPUTexelCopyTextureInfo dst{};
- dst.texture = texture;
- dst.origin = WGPUOrigin3D{0, 0, 0};
- WGPUTexelCopyBufferLayout layout{};
- layout.bytesPerRow = blocksX * bi.bytesPerBlock;
- layout.rowsPerImage = blocksY;
- WGPUExtent3D extent{desc.width, desc.height, 1};
- wgpuQueueWriteTexture(queue_, &dst, data, byteLength, &layout, &extent);
+ // Upload each mip level from the concatenated pyramid. writeTexture counts
+ // BLOCKS, not pixels (a partial edge block still counts a whole block).
+ const GfxBlockInfo bi = gfxCompressedBlockInfo(format);
+ const u8* ptr = static_cast<const u8*>(data);
+ const u8* end = ptr + byteLength;
+ for (u32 level = 0; level < levels; ++level) {
+ const u32 lw = (desc.width >> level) ? (desc.width >> level) : 1u;
+ const u32 lh = (desc.height >> level) ? (desc.height >> level) : 1u;
+ const u32 blocksX = (lw + bi.blockWidth - 1) / bi.blockWidth;
+ const u32 blocksY = (lh + bi.blockHeight - 1) / bi.blockHeight;
+ const u32 levelBytes = blocksX * blocksY * bi.bytesPerBlock;
+ if (ptr + levelBytes > end) break; // truncated pyramid: stop cleanly
+ WGPUTexelCopyTextureInfo dst{};
+ dst.texture = texture;
+ dst.mipLevel = level;
+ dst.origin = WGPUOrigin3D{0, 0, 0};
+ WGPUTexelCopyBufferLayout layout{};
+ layout.bytesPerRow = blocksX * bi.bytesPerBlock;
+ layout.rowsPerImage = blocksY;
+ WGPUExtent3D extent{lw, lh, 1};
+ wgpuQueueWriteTexture(queue_, &dst, ptr, levelBytes, &layout, &extent);
+ ptr += levelBytes;
+ }
const u32 id = next_id_++;
textures_[id] = TextureRec{texture, wgpuTextureCreateView(texture, nullptr),
@@ -861,9 +873,10 @@ WGPUSampler WebGPUDevice::samplerFor(u8 key) {
sd.addressModeU = toWGPUAddressMode(static_cast<TextureWrap>((key >> 2) & 3u));
sd.addressModeV = toWGPUAddressMode(static_cast<TextureWrap>((key >> 4) & 3u));
sd.addressModeW = WGPUAddressMode_ClampToEdge;
- // Every texture is single-mip today (generateMipmaps pending), so the mip
- // filter never engages; Nearest mirrors GL's non-mipmapped min filters.
- sd.mipmapFilter = WGPUMipmapFilterMode_Nearest;
+ // Trilinear across mips when a texture has them (compressed KTX2 pyramids);
+ // with a single mip WebGPU samples level 0 unchanged, so this is harmless for
+ // the still-common single-mip textures.
+ sd.mipmapFilter = WGPUMipmapFilterMode_Linear;
sd.lodMinClamp = 0.0f;
sd.lodMaxClamp = 32.0f;
sd.maxAnisotropy = 1;
diff --git a/src/esengine/renderer/webgpu/WebGPUDevice.hpp b/src/esengine/renderer/webgpu/WebGPUDevice.hpp
index 653b6a602..32d33bf20 100644
--- a/src/esengine/renderer/webgpu/WebGPUDevice.hpp
+++ b/src/esengine/renderer/webgpu/WebGPUDevice.hpp
@@ -86,7 +86,7 @@ public:
TextureHandle createTexture(const TextureDesc& desc, const void* pixels) override;
TextureHandle createCompressedTexture(const TextureDesc& desc, GfxCompressedFormat format,
- const void* data, u32 byteLength) override;
+ const void* data, u32 byteLength, u32 mipLevels) override;
TextureHandle importExternalTexture(u32 nativeId, const TextureDesc& desc) override;
void deleteTexture(TextureHandle texture) override;
void updateTexture(TextureHandle texture, i32 x, i32 y, u32 width, u32 height,
diff --git a/src/esengine/renderer/webgpu/WebGPUMappings.hpp b/src/esengine/renderer/webgpu/WebGPUMappings.hpp
index 498015768..d93c524ec 100644
--- a/src/esengine/renderer/webgpu/WebGPUMappings.hpp
+++ b/src/esengine/renderer/webgpu/WebGPUMappings.hpp
@@ -181,28 +181,6 @@ inline WGPUTextureFormat toWGPUCompressedFormat(GfxCompressedFormat fmt) {
}
}
-/** Block footprint of a compressed format: writeTexture's bytesPerRow/rowsPerImage
- * count blocks, not pixels. BC/ETC2 are 4x4; ASTC's block matches its name. */
-struct CompressedBlockInfo {
- u32 blockWidth;
- u32 blockHeight;
- u32 bytesPerBlock;
-};
-inline CompressedBlockInfo compressedBlockInfo(GfxCompressedFormat fmt) {
- switch (fmt) {
- case GfxCompressedFormat::S3TC_DXT1: return {4, 4, 8}; // BC1
- case GfxCompressedFormat::ETC2_RGB8: return {4, 4, 8};
- case GfxCompressedFormat::ASTC_8x8: return {8, 8, 16};
- case GfxCompressedFormat::S3TC_DXT5:
- case GfxCompressedFormat::S3TC_DXT5_SRGB: return {4, 4, 16}; // BC3
- case GfxCompressedFormat::ETC2_RGBA8:
- case GfxCompressedFormat::ETC2_RGBA8_SRGB: return {4, 4, 16};
- case GfxCompressedFormat::ASTC_4x4:
- case GfxCompressedFormat::ASTC_4x4_SRGB:
- default: return {4, 4, 16};
- }
-}
-
/** The device feature that gates a compressed-format family (BC / ETC2 / ASTC). */
inline WGPUFeatureName compressionFeatureFor(GfxCompressedFormat fmt) {
switch (fmt) {
diff --git a/src/esengine/resource/ResourceManager.cpp b/src/esengine/resource/ResourceManager.cpp
index 41fba21de..6e6351a75 100644
--- a/src/esengine/resource/ResourceManager.cpp
+++ b/src/esengine/resource/ResourceManager.cpp
@@ -193,10 +193,11 @@ TextureHandle ResourceManager::createTexture(u32 width, u32 height, ConstSpan<u8
}
TextureHandle ResourceManager::createCompressedTexture(u32 width, u32 height,
- GfxCompressedFormat format, ConstSpan<u8> data) {
+ GfxCompressedFormat format, ConstSpan<u8> data,
+ u32 mipLevels) {
if (!device_) return {};
auto texture = Texture::createCompressed(*device_, width, height, format,
- std::span<const u8>(data.data(), data.size()));
+ std::span<const u8>(data.data(), data.size()), mipLevels);
if (!texture) {
ES_LOG_ERROR("Failed to create compressed texture");
return TextureHandle();
diff --git a/src/esengine/resource/ResourceManager.hpp b/src/esengine/resource/ResourceManager.hpp
index 5251f99c7..94757ed57 100644
--- a/src/esengine/resource/ResourceManager.hpp
+++ b/src/esengine/resource/ResourceManager.hpp
@@ -224,11 +224,12 @@ public:
* @brief Creates a block-compressed texture (KTX2 → ETC2/ASTC/BC), uploading
* the pre-compressed blocks for mip level 0. Tracked like any texture;
* its residency cost is the real (compressed) byte size.
- * @param data Compressed block data.
+ * @param data All @p mipLevels concatenated (level 0 first, block-aligned).
+ * @param mipLevels Mip levels present (1 = base only).
* @return Handle to the texture, or invalid handle on failure.
*/
TextureHandle createCompressedTexture(u32 width, u32 height, GfxCompressedFormat format,
- ConstSpan<u8> data);
+ ConstSpan<u8> data, u32 mipLevels = 1);
/**
* @brief Loads a texture from file (with caching)
diff --git a/tests/renderer/MockGfxDevice.hpp b/tests/renderer/MockGfxDevice.hpp
index 006c2df91..4bc760edd 100644
--- a/tests/renderer/MockGfxDevice.hpp
+++ b/tests/renderer/MockGfxDevice.hpp
@@ -82,6 +82,7 @@ struct MockGfxDevice final : GfxDevice {
TextureHandle lastDeletedTexture = TextureHandle::Invalid;
GfxCompressedFormat lastCompressedFormat = GfxCompressedFormat::ETC2_RGBA8;
u32 lastCompressedByteLength = 0;
+ u32 lastCompressedMipLevels = 0;
FramebufferDesc lastFramebufferDesc{};
u32 lastDrawIndexCount = 0;
u32 lastDrawIndexByteOffset = 0;
@@ -130,11 +131,12 @@ struct MockGfxDevice final : GfxDevice {
return createTextureFails ? TextureHandle::Invalid : TextureHandle{nextTextureId++};
}
TextureHandle createCompressedTexture(const TextureDesc& desc, GfxCompressedFormat format,
- const void*, u32 byteLength) override {
+ const void*, u32 byteLength, u32 mipLevels) override {
++createCompressedTextureCalls;
lastTextureDesc = desc;
lastCompressedFormat = format;
lastCompressedByteLength = byteLength;
+ lastCompressedMipLevels = mipLevels;
return TextureHandle{nextTextureId++};
}
TextureHandle importExternalTexture(u32 nativeId, const TextureDesc& desc) override {
diff --git a/tests/renderer/test_compressed_format.cpp b/tests/renderer/test_compressed_format.cpp
index f413f6963..92da0d206 100644
--- a/tests/renderer/test_compressed_format.cpp
+++ b/tests/renderer/test_compressed_format.cpp
@@ -29,7 +29,7 @@ static TextureHandle uploadTexture(GfxDevice& d, u32 w, u32 h,
desc.width = w;
desc.height = h;
if (d.supportsCompressedFormat(fmt)) {
- return d.createCompressedTexture(desc, fmt, compressed, compressedLen);
+ return d.createCompressedTexture(desc, fmt, compressed, compressedLen, 1);
}
return d.createTexture(desc, rgba);
}
@@ -69,7 +69,7 @@ int main() {
TextureDesc desc;
desc.width = 32;
desc.height = 32;
- d.createCompressedTexture(desc, GfxCompressedFormat::ETC2_RGBA8, blocks.data(), 512);
+ d.createCompressedTexture(desc, GfxCompressedFormat::ETC2_RGBA8, blocks.data(), 512, 1);
CHECK(d.createCompressedTextureCalls == 1, "ETC2_RGBA8 routes through device");
CHECK(d.lastCompressedFormat == GfxCompressedFormat::ETC2_RGBA8, "ETC2 format forwarded");
CHECK(d.lastCompressedByteLength == 512, "ETC2 byte length forwarded");