blender/build_files/build_environment/patches/openimageio_dds_3d_5133.diff
Jonas Holzman d5d927b670 Deps: Library changes for Blender 5.2 LTS
### New libraries
- meshoptimizer v1.0
- tomli-w 1.2.0
- Tracy 0.13.1

### Updates of existing libraries
- OpenShadingLanguage 1.15.3.0
- OpenPGL 0.7.1
- ThorVG 1.0.3
- OpenUSD 26.03
- OpenImageIO 3.1.13.1
- libpng 1.6.58
- DPC++ 6.3.0
- Embree 4.4.1
- Intel Graphics Compiler v2.30.1
- Manifold 3.4.1
- x265 4.1
- ROCm / HIP 7.1.1 / 7.1.51803
- libexpat 2.7.5
- libtiff 4.7.1
- mesa 25.3.6
- OpenEXR 3.4.10
- OpenSSL 3.5.6
- Python 3.13.13
- sqlite 3.51.3
- libxml2 2.14.6
- ffmpeg 8.1
- Draco 1.5.7
- SDL 3.4.2

Library changes tracking issue ref: #153974

Co-authored-by: Sebastian Parborg <sebastian@blender.org>
Co-authored-by: Ray Molenkamp <github@lazydodo.com>
Co-authored-by: Sahar A. Kashi <salipour@noreply.localhost>
Co-authored-by: Nikita Sirgienko <nikita.sirgienko@intel.com>
Co-authored-by: Bart van der Braak <bart@blender.org>
Co-authored-by: Thomas Dinges <thomas@blender.org>
Co-authored-by: Alaska <Alaskayou01@gmail.com>

Pull Request: https://projects.blender.org/blender/blender/pulls/157180
2026-05-11 19:04:45 +02:00

75 lines
3.1 KiB
Diff

From e626fab243ab7772fbd33d63777fd4bd9b2cfa99 Mon Sep 17 00:00:00 2001
From: Larry Gritz <lg@larrygritz.com>
Date: Mon, 6 Apr 2026 23:11:39 -0700
Subject: [PATCH] fix(dds): Fix broken reading of volumetric DDS files by
emulating tiles
Fixes #5132.
Reading DDS volumetric files used to work, but was broken by PR #4669
last year, the one where we added all the span-oriented API calls.
At that time, I did not realize/remember that DDS files could be
volumetric, observed that all the (other) volumetric files only
supported tiled access, and so in the course of that API refactor, I
removed the z parameter from the new read_scanlines API.
I don't want to break ABI compatibility again for this, so the
solution I came up with in this PR is just to make DDS volume files
report themselves as "tiled", with each tile being (width x 1 x 1),
i.e. what used to be one scanline, and it all just works out.
Signed-off-by: Larry Gritz <lg@larrygritz.com>
---
src/dds.imageio/ddsinput.cpp | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/dds.imageio/ddsinput.cpp b/src/dds.imageio/ddsinput.cpp
index 53f80ed487..efc31323cc 100644
--- a/src/dds.imageio/ddsinput.cpp
+++ b/src/dds.imageio/ddsinput.cpp
@@ -862,6 +862,11 @@ DDSInput::seek_subimage(int subimage, int miplevel)
// detect texture type
if (m_dds.caps.flags2 & DDS_CAPS2_VOLUME) {
m_spec.attribute("textureformat", "Volume Texture");
+ // Because we don't support reading scanlines from volume textures,
+ // pretend it's tiled with width x 1 x 1 tiles.
+ m_spec.tile_width = m_spec.width;
+ m_spec.tile_height = 1;
+ m_spec.tile_depth = 1;
} else if (m_dds.caps.flags2 & DDS_CAPS2_CUBEMAP) {
m_spec.attribute("textureformat", "CubeFace Environment");
// check available cube map sides
@@ -1042,12 +1047,29 @@ DDSInput::read_native_tile(int subimage, int miplevel, int x, int y, int z,
if (!seek_subimage(subimage, miplevel))
return false;
+ // don't proceed if not tiled
+ if (m_spec.tile_width == 0)
+ return false;
+
+ if (m_dds.caps.flags2 & DDS_CAPS2_VOLUME) {
+ // This is a 3D volume file. For DDS files, we are emulating tiles,
+ // with each scanline as a tile.
+ if (m_buf.empty())
+ readimg_scanlines();
+ // We reported scanlines as tiles, so x must be 0.
+ if (x != 0)
+ return false;
+ size_t size = spec().scanline_bytes();
+ size_t offset = size * (size_t(z) * size_t(m_spec.height) + y);
+ if (offset + size > m_buf.size()) // Bounds check
+ return false;
+ memcpy(data, m_buf.data() + offset, size);
+ return true;
+ }
+
// static ints to keep track of the current cube face and re-seek and
// re-read face
static int lastx = -1, lasty = -1, lastz = -1;
- // don't proceed if not a cube map - use scanlines then instead
- if (!(m_dds.caps.flags2 & DDS_CAPS2_CUBEMAP))
- return false;
// make sure we get the right dimensions
if (x % m_spec.tile_width || y % m_spec.tile_height
|| z % m_spec.tile_width)