@@ -118,7 +118,7 @@ static uint8_t * input_image_buffer = NULL;
118118static uint8_t * input_mask_buffer = NULL ;
119119
120120static std::string sdplatformenv, sddeviceenv, sdvulkandeviceenv;
121- static bool notiling = false ;
121+ static int cfg_tiled_vae_threshold = 0 ;
122122static int cfg_square_limit = 0 ;
123123static int cfg_side_limit = 0 ;
124124static bool sd_is_quiet = false ;
@@ -134,7 +134,7 @@ bool sdtype_load_model(const sd_load_model_inputs inputs) {
134134 std::string t5xxl_filename = inputs.t5xxl_filename ;
135135 std::string clipl_filename = inputs.clipl_filename ;
136136 std::string clipg_filename = inputs.clipg_filename ;
137- notiling = inputs.notile ;
137+ cfg_tiled_vae_threshold = inputs.tiled_vae_threshold ;
138138 cfg_side_limit = inputs.side_limit ;
139139 cfg_square_limit = inputs.square_limit ;
140140 printf (" \n ImageGen Init - Load Model: %s\n " ,inputs.model_filename );
@@ -474,7 +474,18 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
474474 printf (" \n KCPP SD: Requested dimensions %dx%d changed to %dx%d\n " , inputs.width , inputs.height , sd_params->width , sd_params->height );
475475 }
476476
477- bool dotile = (sd_params->width >768 || sd_params->height >768 ) && !notiling;
477+ int tiled_vae_threshold;
478+ if (cfg_tiled_vae_threshold == 0 ) {
479+ tiled_vae_threshold = 768 ;
480+ } else {
481+ if (cfg_tiled_vae_threshold > 0 ) {
482+ tiled_vae_threshold = cfg_tiled_vae_threshold;
483+ } else {
484+ tiled_vae_threshold = 8192 ; // effectively avoids tiling
485+ }
486+ }
487+
488+ bool dotile = (sd_params->width >tiled_vae_threshold || sd_params->height >tiled_vae_threshold);
478489 set_sd_vae_tiling (sd_ctx,dotile); // changes vae tiling, prevents memory related crash/oom
479490
480491 if (sd_params->clip_skip <= 0 ) {
0 commit comments