From 9f8ae536d47401f5a586614dd8e88a2b5eaa4388 Mon Sep 17 00:00:00 2001 From: Rami Tabbara Date: Mon, 27 Jan 2025 15:48:40 +0100 Subject: [PATCH 1/2] Re-enable FP16 support for bitmap textures * Prior to Mitsuba 3.6, FP16 storage for bitmaps was disabled due to observed degradation in performance (particularly on LLVM backends) * Changes with Dr.Jit textures now using PacketOps (https://github.com/mitsuba-renderer/drjit/pull/329) means we can re-enable support for FP16 bitmap textures --- ext/drjit | 2 +- src/textures/bitmap.cpp | 21 +++++++++++++-------- tutorials | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ext/drjit b/ext/drjit index b656011cb..41a01e4dd 160000 --- a/ext/drjit +++ b/ext/drjit @@ -1 +1 @@ -Subproject commit b656011cb027c7571416c6094ae1a54c57c402bd +Subproject commit 41a01e4dd46230c5b785360d13aa22e0984efa13 diff --git a/src/textures/bitmap.cpp b/src/textures/bitmap.cpp index 700025b51..2c77c6792 100644 --- a/src/textures/bitmap.cpp +++ b/src/textures/bitmap.cpp @@ -65,7 +65,13 @@ Bitmap texture (:monosp:`bitmap`) - Specifies the underlying texture storage format. The following options are currently available: - - ``variant``(default): Use the corresponding native floating point representation + - ``auto`` (default): If loading a texture from a bitmap, use half + precision for bitmap data with 16 or lower bit depth, otherwise use + the native floating point representation of the Mitsuba variant. For + variants using a spectral color representation this option is the same + as `variant`. + + - ``variant``: Use the corresponding native floating point representation of the Mitsuba variant - ``fp16``: Forcibly store the texture in half precision @@ -167,13 +173,15 @@ class BitmapTexture final : public Texture { // Format { - std::string format_str = props.string("format", "variant"); - if (format_str == "variant") + std::string format_str = props.string("format", "auto"); + if (format_str == "auto") + m_format = Format::Auto; + else if (format_str == "variant") m_format = Format::Variant; else if (format_str == "fp16") m_format = Format::Float16; else - Throw("Invalid format \"%s\", must be one of: " + Throw("Invalid format \"%s\", must be one of: \"auto\", " "\"variant\", or \"fp16\"!", format_str); } @@ -221,9 +229,6 @@ class BitmapTexture final : public Texture { Object* expand_1() const { if (m_bitmap) { Format format = m_format; - -// TODO: Temporarily disable this as LLVM FP16 gather/scatter operations are costly -#if 0 // Format auto means we store texture as FP16 when possible. // Skip this conversion for spectral variants as we want to perform // spectral upsampling in the variant's native FP representation @@ -233,7 +238,6 @@ class BitmapTexture final : public Texture { if (m_format == Format::Auto && bytes_p_ch <= 2) format = Format::Float16; } -#endif if (format == Format::Float16) return expand_bitmap>(); @@ -338,6 +342,7 @@ class BitmapTexture final : public Texture { } enum class Format { + Auto, Variant, Float16 } m_format; diff --git a/tutorials b/tutorials index 905a3b289..916b03ed7 160000 --- a/tutorials +++ b/tutorials @@ -1 +1 @@ -Subproject commit 905a3b289acf75e6d9aa82792bc39976646a15a9 +Subproject commit 916b03ed7a8ff42567f80dd56a218c6a68dc95ae From 4d58157b22613b213258ff95acd237d3330e74ca Mon Sep 17 00:00:00 2001 From: Nicolas Roussel Date: Thu, 6 Feb 2025 16:28:28 +0100 Subject: [PATCH 2/2] Update drjit submodule Rewrite of Dr.Jit textures to make use of packet-operations --- ext/drjit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/drjit b/ext/drjit index 41a01e4dd..a1e4cf53a 160000 --- a/ext/drjit +++ b/ext/drjit @@ -1 +1 @@ -Subproject commit 41a01e4dd46230c5b785360d13aa22e0984efa13 +Subproject commit a1e4cf53a1c3f2604397d4d383b30b4b17e264e2