Skip to content

Commit 3d95571

Browse files
committed
Separate resolution tests for 2D, cube face, and volume DDS
Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 9bb580c commit 3d95571

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

src/dds.imageio/ddsinput.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,33 @@ DDSInput::seek_subimage(int subimage, int miplevel)
899899
}
900900

901901
// Check validity of resolutions.
902-
if (!check_open(m_spec, { 0, 32768, 0, 32768, 0, 16384, 0, 4 }))
903-
return false;
902+
if (m_dds.caps.flags2 & DDS_CAPS2_CUBEMAP) {
903+
// cube maps must be square and each face can be up to 16384x16384
904+
// (currently). But remember that they are stored in a 3x2 or 1x6
905+
// layout.
906+
#ifdef DDS_3X2_CUBE_MAP_LAYOUT
907+
if (!check_open(m_spec, { 0, 16384 * 3, 0, 16384 * 2, 0, 1, 0, 4 }))
908+
return false;
909+
#else
910+
if (!check_open(m_spec, { 0, 16384, 0, 16384 * 6, 0, 1, 0, 4 }))
911+
return false;
912+
#endif
913+
if (m_spec.full_width != m_spec.full_height) {
914+
errorfmt(
915+
"Invalid cube map layout: width {} does not match height {}",
916+
m_spec.full_width, m_spec.full_height);
917+
return false;
918+
}
919+
} else if (m_dds.caps.flags2 & DDS_CAPS2_VOLUME) {
920+
// volume textures are limited to 4096x4096x4096 (currently)
921+
if (!check_open(m_spec, { 0, 4096, 0, 4096, 0, 4096, 0, 4 })) {
922+
return false;
923+
}
924+
} else {
925+
// 2D textures can be up to 32768x32768
926+
if (!check_open(m_spec, { 0, 32768, 0, 32768, 0, 1, 0, 4 }))
927+
return false;
928+
}
904929

905930
m_subimage = subimage;
906931
m_miplevel = miplevel;

0 commit comments

Comments
 (0)