@@ -99,15 +99,6 @@ bool dds2tex(const char* dds_path)
99
99
DDS_HEADER dds_header ;
100
100
assert (fread (& dds_header , sizeof (DDS_HEADER ), 1 , dds_file ) == 1 );
101
101
102
- if (dds_header .dwWidth % 4 != 0 || dds_header .dwHeight % 4 != 0 ) {
103
- if (dds_header .dwWidth % 4 != 0 )
104
- fprintf (stderr , "Error: Cannot convert to tex when width (%d) isn't divisible by 4!\n" , dds_header .dwWidth );
105
- if (dds_header .dwHeight % 4 != 0 )
106
- fprintf (stderr , "Error: Cannot convert to tex when height (%d) isn't divisible by 4!\n" , dds_header .dwHeight );
107
- fclose (dds_file );
108
- return false;
109
- }
110
-
111
102
TEX_HEADER tex_header = {
112
103
.magic = tex_magic ,
113
104
.image_width = dds_header .dwWidth ,
@@ -153,6 +144,17 @@ bool dds2tex(const char* dds_path)
153
144
fclose (dds_file );
154
145
return false;
155
146
}
147
+
148
+ const int block_size = get_block_size (tex_header .tex_format );
149
+ if (dds_header .dwWidth % block_size != 0 || dds_header .dwHeight % block_size != 0 ) {
150
+ if (dds_header .dwWidth % block_size != 0 )
151
+ fprintf (stderr , "Error: Cannot convert to tex when width (%d) isn't divisible by %d!\n" , dds_header .dwWidth , block_size );
152
+ if (dds_header .dwHeight % block_size != 0 )
153
+ fprintf (stderr , "Error: Cannot convert to tex when height (%d) isn't divisible by %d!\n" , dds_header .dwHeight , block_size );
154
+ fclose (dds_file );
155
+ return false;
156
+ }
157
+
156
158
if (dds_header .dwMipMapCount > 1 ) { // this value may be set to 1, which is equivalent to leaving it at 0 (no mipmaps)
157
159
tex_header .has_mipmaps = true;
158
160
if (dds_header .dwMipMapCount != 32u - __builtin_clz (max (dds_header .dwWidth , dds_header .dwHeight ))) {
0 commit comments