File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,26 @@ static bool conversion_needed(const DDS_HEADER &dds_header)
7474 return false ;
7575}
7676
77+ // Auto-determine max texture size based on avail device ram for software decompression
78+ // 128 for <4GB, 256 for < 8GB, 512 for < 12GB and finally 1024
79+ static size_t calculate_resize_max_size ()
80+ {
81+ size_t size = 1024 ;
82+ size_t ram_mib = SDL_GetSystemRAM ();
83+
84+ if (ram_mib > 0 )
85+ {
86+ if (ram_mib < 4 * 1024 ) // < 4GB
87+ return 128 ;
88+ if (ram_mib < 8 * 1024 ) // < 8GB
89+ return 256 ;
90+ if (ram_mib < 12 * 1024 ) // < 12GB
91+ return 512 ;
92+ }
93+
94+ return size;
95+ }
96+
7797// Memory usage for uncompressed textures is quite high. Some MVP assets can
7898// require well over a GB of VRAM for a single ship after conversion. To help
7999// alleviate this we need to resize those textures where possible. At 1024x1024
@@ -85,7 +105,7 @@ static bool conversion_needed(const DDS_HEADER &dds_header)
85105// returns: number of mipmap levels to skip
86106static uint conversion_resize (DDS_HEADER &dds_header)
87107{
88- const size_t MAX_SIZE = 1024 ;
108+ const size_t MAX_SIZE = calculate_resize_max_size () ;
89109 uint width, height, depth, offset = 0 ;
90110
91111 if (dds_header.dwMipMapCount <= 1 ) {
You can’t perform that action at this time.
0 commit comments