@@ -169,43 +169,64 @@ def calculate_slider_range(self):
169169 # ----------------------------------------------
170170
171171 def generate_presets_gb (self ):
172- """Generates a list of sensible VRAM presets in GB tuples (GB, Label)."""
172+ """
173+ Generates a list of sensible VRAM presets in GB tuples (GB, Label).
174+ Includes standard presets and 1GB increments near the maximum.
175+ """
173176 presets = []
174- if not self .total_ram_mb or self .max_vram_mb <= self .min_vram_mb : return []
177+ if not self .total_ram_mb or self .max_vram_mb <= self .min_vram_mb :
178+ print ("[Presets] Cannot generate presets: Invalid RAM or VRAM range." )
179+ return []
175180
176- # Use the potentially updated max_vram_mb (which could be total RAM)
181+ # Use calculated max allocatable VRAM based on reserve config
177182 max_preset_mb = self .max_vram_mb
183+ # Calculate the theoretical macOS default for comparison
178184 calculated_default_mb = utils .calculate_default_vram_mb (self .total_ram_mb )
179185
180- potential_gbs = [4 , 6 , 8 , 12 , 16 , 24 , 32 , 48 , 64 , 96 , 128 , 192 , 256 ] # Added more higher potential values
181- labels = ["Basic" , "Balanced" , "More" , "Gaming" , "High" , "Very High" , "Extreme" , "Insane" , "Ludicrous" , "Plaid" ]
186+ print (f"[Presets] Max allocatable MB: { max_preset_mb } , Calculated default MB: { calculated_default_mb } , Min allowed MB: { self .min_vram_mb } " )
187+
188+ # --- Standard Presets ---
189+ # Added 256 and 512 here
190+ potential_gbs = [4 , 6 , 8 , 12 , 16 , 24 , 32 , 48 , 64 , 96 , 128 , 256 , 512 ] # Base points
191+ labels = ["Basic" , "Balanced" , "More" , "Gaming" , "High" , "Very High" , "Extreme" , "Insane" ] # Labels for standard points (fallback used for higher values)
182192 label_idx = 0
193+ added_gbs = set () # Keep track of GB values added
183194
184195 for gb in potential_gbs :
185196 mb = gb * 1024
186- # Check if within valid range [min_vram_mb, max_vram_mb]
187- if self .min_vram_mb <= mb <= max_preset_mb :
188- # Only add if significantly different from default
189- if abs (mb - calculated_default_mb ) > 1024 :
190- if not any (p [0 ] == gb for p in presets ):
191- label = labels [label_idx ] if label_idx < len (labels ) else f"{ gb } GB"
192- presets .append ((gb , label ))
197+ # Check if within valid range AND significantly different from default
198+ if self .min_vram_mb <= mb <= max_preset_mb and abs (mb - calculated_default_mb ) > 1024 :
199+ if gb not in added_gbs :
200+ # Assign labels sequentially or use GB value as fallback
201+ label = labels [label_idx ] if label_idx < len (labels ) else f"{ gb } GB"
202+ presets .append ((gb , label ))
203+ added_gbs .add (gb )
204+ # Only increment label_idx if we actually used a label from the list
205+ if label_idx < len (labels ):
193206 label_idx += 1
207+ print (f"[Presets] After standard points: { presets } " )
208+
209+ # --- Near-Maximum 1GB Increment Presets ---
210+ max_alloc_gb = int (max_preset_mb / 1024 ) # The highest whole GB possible
211+ num_near_max_presets = 4 # How many 1GB steps to add below the max (including max)
194212
195- # Consider adding the calculated maximum allocatable VRAM as a preset if it's useful
196- max_alloc_gb = int (max_preset_mb / 1024 )
197- # Check if max is valid, different from default, and not already added
198- if max_alloc_gb * 1024 >= self .min_vram_mb and abs (max_alloc_gb * 1024 - calculated_default_mb ) > 1024 :
199- # Check if it's meaningfully different from the last added preset
200- if not presets or abs (max_alloc_gb - presets [- 1 ][0 ]) >= 1 :
201- if not any (p [0 ] == max_alloc_gb for p in presets ):
202- label = labels [min (label_idx , len (labels )- 1 )] if label_idx < len (labels ) else "Max"
203- presets .append ((max_alloc_gb , label ))
204-
205- presets .sort (key = lambda x : x [0 ])
206- print (f"Generated Presets (using max_vram_mb={ max_preset_mb } ): { presets } " )
213+ # Iterate downwards from the max possible GB
214+ for i in range (num_near_max_presets ):
215+ gb = max_alloc_gb - i
216+ if gb <= 0 : break # Stop if we go below 1GB
217+
218+ mb = gb * 1024
219+ # Check conditions: within range, not too close to default, and not already added
220+ if gb not in added_gbs and self .min_vram_mb <= mb <= max_preset_mb and abs (mb - calculated_default_mb ) > 1024 :
221+ print (f"[Presets] Adding near-max preset: { gb } GB" )
222+ presets .append ((gb , f"{ gb } GB" )) # Use simple label for these
223+ added_gbs .add (gb )
224+
225+ # --- Final Sort ---
226+ presets .sort (key = lambda x : x [0 ]) # Sort all presets by GB value
227+ print (f"[Presets] Final generated list: { presets } " )
207228 return presets
208- # --- END PRESET MODIFICATION ---
229+ # --- END PRESET MODIFICATION ---
209230
210231 def create_menu_actions (self ):
211232 """Creates and adds actions and widgets to the menu."""
0 commit comments