Guest User

VRAMr v14 Linux

a guest
Apr 11th, 2025
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 17.60 KB | None | 0 0
  1. :::    ____      ____     _____        _____       ______  _______       _____    
  2. :::   |    |    |    |___|\    \   ___|\    \     |      \/       \  ___|\    \  
  3. :::   |    |    |    |    |\    \ /    /\    \   /          /\     \|    |\    \
  4. :::   |    |    |    |    | |    |    |  |    | /     /\   / /\     |    | |    |     v14.731
  5. :::   |    |    |    |    |/____/|    |__|    |/     /\ \_/ / /    /|    |/____/
  6. :::   |    |    |    |    |\    \|    .--.    |     |  \|_|/ /    / |    |\    \    gavwhittaker
  7. :::   |\    \  /    /|    | |    |    |  |    |     |       |    |  |    | |    |
  8. :::   | \ ___\/___ / |____| |____|____|  |____|\____\       |____|  |____| |____|    April 2025
  9. :::    \ |   ||   | /|    | |    |    |  |    | |    |      |    | /|    | |    |
  10. :::     \|___||___|/ |____| |____|____|  |____|\|____|      |____|/ |____| |____|
  11. :::
  12.  
  13. :: Changelog - Nexus Published
  14. :: ---------------------------
  15.  
  16. :: v14.731  - Tweaks and fix for post drive selection crash. Thanks to SnippyStockins for help testing this. It's a nightmare when you can't recreate an error yet need to fix it!
  17. :: v14.73   - Bugfixes Optimise.py division by zero, Folder Selection crash, Storage Calc miscalc and added --altgpu parameter
  18. :: v14.72   - Initial Python Implementation in a Batch Wrapper (StorageCalc, ExtractBSA, LooseCopy, Exclusions, Analyse, Filter, Optimise
  19.  
  20. :: Dv13.41      - Unicode fixes. Improvements/bugfixes for Copying Files, Renaming Output Folder and Calculating Storage Requirements
  21.  
  22. :: Dv13.4       - Key components re-coded to Python, SQLite and Powershell leveraging multi-threading, parallel processing and memory mapping ++
  23. ::      - Now a 2 part process to cut loose from MO2's Virtual File System restrictions
  24. ::      - Optimisation auto-resume should VRAMr be interrupted by user, crash or powercut
  25. ::      - Fixed cause of the wrong textures winning occasionally
  26. ::      - Auto-detection of PBR textures folder to determine if to optimise or skip
  27. ::      - Improved Skyrim EXE detection by reading Windows Registry (kudos Jilvane)
  28. ::      - GPU auto-detection and benchmarking for optimum BC7 encoding
  29. ::      - Intellgient aspect ratio resizing
  30. ::      - Advanced deduplication to reduce VRAMr Output size of unnecessary files
  31. ::      - Improved RGB file processing
  32. ::      - Summary.log to itemise VRAMr process, errors and outcomes by format and texture type
  33. ::      - Additional fixes and code improvements
  34.  
  35. :: v12      - Even more VRAM savings from truth table enhancements for possible faster/smaller output.
  36. ::      - PBR support. CPM / Extended Materials script bugfix (thx guildofone).
  37. ::      - Exclusions for DrJ grass mods, 4th Unknown creature textures and ice walls. Improved Logging during optimisation.
  38. ::      - Transitioned to Compressonator for full DDS format support including SRGB for PBR.
  39.  
  40. :: v11.1    - Alternative GPU capability and Vortex updates to the User Guide
  41. :: v11      - CPM support. TexConvx64. ImageMagick truth tables. Exclusions update. Logfile timestamps. Reverted to OpenFolderBox
  42. :: v10      - BC4 1K for HQ preset as plentiful for parallax. Delete parallax LODs as not used and frees up more VRAM
  43. :: v9.841   - Fine tuned exclusions for LotDB file causing CTD. Continued thanks to Phostwood and The Nolvus Discord
  44. :: v9.84    - With thanks to Phostwood, updated exclusions to include LotDB file 'gorehowl_01' causing CTD with Nolvus
  45. :: v9.83    - Balanced multi-threading. Optimisation counters increment. OpenFolderBox.exe and prevent sleep now via Powershell
  46. :: v9.78    - Robocopy multi-threading. Optimisation monitor improved to cater for HUGE WJ modlists. Small yet very important bugfixes
  47. :: v9.77    - Fixed negative counters. Parallelised copy/optimisations saving ~1/3rd time. Other bug fixes and improvements
  48. :: v9.4     - Removed all ZIP steps to rely on drag and drag of VRAMr'd Textures folder into Mod Manager
  49. :: v9.36    - Balanced power at exit. Some complex grass exclusions. Cancel option for GameDir. MT'd BSA extract. 7z & TexConv updated
  50. :: v9.3     - Fixed more artifacts. EXE GameDir check. ZIPr.BAT. Window title improvements. Removed Dummy files no longer needed
  51. :: v9.2     - Removed cause of AV alert. Fixed Normal Map artifacts. Optimised De-dupe and Exclusions. Improved zipping process
  52. :: v9.1     - Re-implemented HQ and Performance presets. Added Manual Zipper.bat and manual override of detected !GameDir!
  53. :: v9.0     - 1-step automated. Updated texconv and 7z DLL. Removed HQ/Perf presets and quick updating. Audio cues
  54. :: v8.6     - Removed EXE detection and added manual MO2 locator
  55. :: v8.53    - BSA bugfix and other tweaks
  56. :: v8.52    - MO2 layered extract, removed shine on rocks/mountains, dummy.dds bugfix, admin checks
  57. :: v8.21    - Fixed delayedexpansion, re-instated logfile, disk space reqs, BSA de-dupe, preset add/remove INI lock, User Guide update
  58. :: v8.2     - Visual cues, power profile, add HQ preset, optimised exclusions for more VRAM gain, 7z to Step 3, User Guide update
  59. :: v7.1     - AIO (DiffusR, ParallaxR integrated), add performance preset, 1st release of User Guide
  60. :: v7.0     - GPU and CPU optimisation, updated exclusions, large parts of code re-written
  61. :: v6.8     - ParallaxR BC4 implemented
  62. :: v6.7     - Further user exclusions (LotDB)
  63. :: v6.6     - User exclusion submissions to prevent CTD (Scoped Bows)
  64. :: v6.5     - ParallaxR integrated, user contributed exclusions integration
  65. :: v6.0     - auto CPU core allocation, ParallaxR and DiffuseR adopt main VRAMr code improvements
  66. :: v5.0     - DiffuseR added, forced root folder to reduce UAC and username, forced write cache flushes, improve logfile, TexA tweaks
  67. :: v4.0     - BSA extract added, MO2 and Vortex combined, 7z portable,
  68. :: v3.0     - Option to optimise interiors and clutter. 7z process optimised
  69. :: v2.0     - Removed Resource Pack, Large objects (dragons, giants and mountains not processed)
  70. :: v1.1     - ParallaxR added seperate to normal map optimisation
  71. :: v1.0     - Initial Release with seperate Resource Pack download
  72.  
  73. :: Thanks and Credit
  74. :: -----------------
  75.  
  76. :: Mayhem, PogIsDog, MrAnonymous, HOSE and the rest of the testing team!
  77. :: AlexxEG for BSA Browser
  78. :: the_XtR0 for MO2 layered extract idea, code contribution and testing
  79. :: Draconian69 for parallelised testing and code optimisation
  80. :: MSFT for TexConv
  81. :: Compressonator Github Contributors (see License.zip)
  82. :: Rob van der Woude for OpenFolderBox at https://www.robvanderwoude.com/
  83. :: ChatGPT
  84.  
  85. ::----------------------------------------------------------------------------------------------------------------------------------------
  86.  
  87. ::Initialise Environment
  88.  
  89. @echo off
  90. setlocal EnableDelayedExpansion
  91. chcp 65001 >nul
  92. mode CON: COLS=115 LINES=48
  93. set "ScriptDir=%~dp0"
  94. cd ..
  95. set "GameDir=%CD%"
  96.  
  97. color 0F
  98. cls
  99. for /f "delims=: tokens=*" %%a in ('findstr /b ::: "%~f0"') do @echo(%%a
  100.  
  101. taskkill /f /im powershell.exe >NUL 2>&1
  102.  
  103. :: start "VRAMr User Guide" "%ScriptDir%\tools\UserGuide" -u on -o on "%ScriptDir%\tools\User Guide\"
  104.  
  105. del "%TEMP%\StorageCalc.tmp" >NUL 2>&1
  106. del "%TEMP%\Unpack-Order.tmp" >NUL 2>&1
  107. del "%TEMP%\MO2Profile.tmp" >NUL 2>&1
  108. del "%TEMP%\VRAMrTEMP.tmp" >NUL 2>&1
  109. del "%TEMP%\GameDir.tmp" >NUL 2>&1
  110.  
  111. set "ModMgr=MO2"
  112. set "PBRExists=NotDefined"
  113. set "GPU2Use=0"
  114.  
  115. set "GameDir=Z:\home\ben\data\games\wabbajack\modlists\whatever\Stock Game\data"
  116. set "VRAMrTEMP=Z:\home\ben\data\games\VRAMROutput"
  117. set "MO2Profile=Z:\home\ben\data\games\wabbajack\modlists\whatever\profiles\Whatever Profile"
  118.  
  119. cd /d "%GameDir%"
  120. if exist ".\VRAMrOutput.tmp" (
  121.   color 4F
  122.   echo.
  123.   echo ERROR - Existing VRAMr Output Enabled in your Mod Manager. Disable and Restart VRAMr
  124.   goto Terminate
  125. )
  126.  
  127. if exist "%VRAMrTEMP%" (
  128.   color 60
  129.   echo WARNING - %FoundFolder% Exists from a Previous Session
  130.   echo.
  131.   echo You Must Delete or Rename the Folder Before VRAMr can Continue
  132.   echo.
  133.  
  134.   goto Terminate
  135. )
  136.  
  137. ::    ...........................................................................................................
  138. ::    :    Preset    : Diffuse : Normal : Parallax : Material :   RGB/PBR   :            Description            :
  139. ::    :..............:.........:........:..........:..........:.............:....................................
  140. ::    : High Quality : 2K      : 2K     : 1K       : 1K       :             : 4K Heavy Modlist Downscaled to 2K :
  141. ::    : Quality      : 2K      : 1K     : 1K       : 1K       :             : Balance of Quality / VRAM Savings :
  142. ::    : Optimum      : 2K      : 1K     : 512      : 512      :  Downscale  : Good Starting Preset if Unsure    :
  143. ::    : Performance  : 2K      : 512    : 512      : 512      :     Only    : Big Gains Lower Close Up Quality  :
  144. ::    : Vanilla      : 512     : 512    : 512      : 512      :             : I Just Want my PC to Play Skyrim  :
  145. ::    :..............:.........:........:..........:..........:.............:....................................
  146. :: CHANGE TO ChoseHQ/ChoseQuality/ChoseOptimum/ChosePerf/ChoseVanilla
  147. goto ChosePerf
  148.  
  149. :ChoseHQ
  150. set /a Diffuse=2048
  151. set /a Normal=2048
  152. set /a Parallax=1024
  153. set /a Material=1024
  154. set "Preset=HQ"
  155. goto CalcDiskSpace
  156.  
  157. :ChoseQuality
  158. set /a Diffuse=2048
  159. set /a Normal=1024
  160. set /a Parallax=1024
  161. set /a Material=1024
  162. set "Preset=Quality"
  163. goto CalcDiskSpace
  164.  
  165. :ChoseOptimum
  166. set /a Diffuse=2048
  167. set /a Normal=1024
  168. set /a Parallax=512
  169. set /a Material=512
  170. set "Preset=Optimum"
  171. goto CalcDiskSpace
  172.  
  173. :ChosePerf
  174. set /a Diffuse=2048
  175. set /a Normal=512
  176. set /a Parallax=512
  177. set /a Material=512
  178. set "Preset=Performance"
  179. goto CalcDiskSpace
  180.  
  181. :ChoseVanilla
  182. set /a Diffuse=512
  183. set /a Normal=512
  184. set /a Parallax=512
  185. set /a Material=512
  186. set "Preset=Vanilla"
  187.  
  188. ::----------------------------------------------------------------------------------------------------------------------------------------
  189.  
  190. :CalcDiskSpace
  191. echo.
  192. cd /d "%GameDir%"
  193. echo Calculating Approximate Initial Temporary Storage Requirement....Please Wait
  194. robocopy .\ c:\dummy /L /E *.dds | find "Bytes" >%TEMP%\StorageCalc.tmp
  195. set /p StorageCalc=<%TEMP%\StorageCalc.tmp
  196. echo %StorageCalc:~11,3% >%TEMP%\StorageCalc.tmp
  197. set /p StorageCalc=<%TEMP%\StorageCalc.tmp
  198. echo Select a Drive Root with atleast%StorageCalc%GB Space - ie. D: creates D:\VRAMr. Avoid C: due to Windows Security
  199.  
  200. ::----------------------------------------------------------------------------------------------------------------------------------------
  201.  
  202. :DefineVRAMrFolder
  203. mkdir "%VRAMrTEMP%.\Logfiles"
  204.  
  205. ::----------------------------------------------------------------------------------------------------------------------------------------
  206.  
  207. :DetectPBR
  208. call :ProgressBar 20
  209.  
  210. cd /d "%GameDir%\textures"
  211.  
  212. if exist ".\pbr\" (
  213.   set "PBRExists=1"
  214.   ) else (
  215.     set "PBRExists=0"
  216. )
  217.  
  218. ::----------------------------------------------------------------------------------------------------------------------------------------
  219.  
  220. :BuildVRAMrFolder
  221. call :ProgressBar 23
  222.  
  223. echo.
  224.  
  225. (
  226.   echo VRAMr Started       : %DATE% %TIME%
  227.   echo VRAMr Output folder : "%VRAMrTEMP%"
  228.   echo ScriptDir           : "%ScriptDir%"
  229.   echo GameDir             : "%GameDir%"
  230.   echo Optimisation Preset : "%Preset%"
  231.   echo Initial Storage Req : ~"%StorageCalc%GB"
  232.   if "%ModMgr%"=="MO2" (
  233.     echo Mod Manager         : Mod Organizer 2 Detected - Layered BSA Extract Available
  234.   ) else (
  235.     echo Mod Manager         : Vortex Compatibility Mode
  236.   )
  237.   if "%PBRExists%"=="1" (
  238.     echo PBR Textures        : Detected
  239.   ) else (
  240.     echo PBR Textures        : Not Detected
  241.   )
  242.   if "%GPU2Use%"=="1" (
  243.     echo Alternative GPU     : True
  244.   )
  245. ) > "%VRAMrTEMP%\Logfiles\VRAMr.log"
  246.  
  247.   echo. >> "%VRAMrTEMP%\Logfiles\VRAMr.log"
  248.  
  249.   echo VRAMr Started       : %DATE% %TIME%
  250.   echo VRAMr Output folder : "%VRAMrTEMP%"
  251.   echo ScriptDir           : "%ScriptDir%"
  252.   echo GameDir             : "%GameDir%"
  253.   if "%ModMgr%"=="MO2" (
  254.     echo Mod Manager         : Mod Organizer 2 Detected - Layered BSA Extract Available
  255.   ) else (
  256.     echo Mod Manager         : Vortex Compatibility Mode
  257.   )
  258.   if "%PBRExists%"=="1" (
  259.     echo PBR Textures        : Detected
  260.   ) else (
  261.     echo PBR Textures        : Not Detected
  262.   )
  263.  
  264. ::----------------------------------------------------------------------------------------------------------------------------------------
  265.  
  266. :ExtractBSAPrimer
  267. call :ProgressBar 25
  268. cd /d "%GameDir%"
  269. echo.
  270.  
  271. "%ScriptDir%\tools\MakeUnpack.exe" --profile "%MO2Profile%" --GameDir .\
  272.  
  273. color 1F
  274.  
  275. echo %DATE% %TIME% Extracting BSA Archives... >> "%VRAMrTEMP%\logfiles\VRAMr.log"
  276. "%ScriptDir%\tools\ExtractBSA.exe" --source .\*.bsa --dest "%VRAMrTEMP%\Output" --logfile "%VRAMrTEMP%\Logfiles" --layered %TEMP% --filter *.dds
  277. "%ScriptDir%\tools\ExtractBSA.exe" --source "%GameDir%\..\..\mods\*\*.bsa" --dest "%VRAMrTEMP%\Output" --logfile "%VRAMrTEMP%\Logfiles" --layered %TEMP% --filter *.dds
  278.  
  279. call :Flush
  280.  
  281. ::----------------------------------------------------------------------------------------------------------------------------------------
  282.  
  283. :LooseFilesCopy
  284. call :ProgressBar 40
  285.  
  286. color 5F
  287. echo %DATE% %TIME% Copying Loose Diffuse Textures... >> "%VRAMrTEMP%\logfiles\VRAMr.log"
  288.  
  289. for %%A in ("%GameDir%\..\..\mods") do set "modFolder=%%~fA"
  290. for /D %%f in (%modFolder%\*) do (
  291.   echo %%f
  292.   "%ScriptDir%\tools\LooseCopy.exe" --source "%%f\textures" --dest "%VRAMrTEMP%\Output\textures" --logfile "%VRAMrTEMP%\Logfiles" --verbose
  293. )
  294.  
  295. call :Flush
  296.  
  297. ::----------------------------------------------------------------------------------------------------------------------------------------
  298.  
  299. color CF
  300. call :ProgressBar 55
  301. echo %DATE% %TIME% Processing Exclusions... >> "%VRAMrTEMP%\logfiles\VRAMr.log"
  302. "%ScriptDir%\tools\Exclusions.exe" --Exclude "%ScriptDir%\tools\Exclusions.mod" --Dest "%VRAMrTEMP%\Output" --Logfile "%VRAMrTEMP%\Logfiles"
  303.  
  304. call :Flush
  305.  
  306. ::----------------------------------------------------------------------------------------------------------------------------------------
  307.  
  308. color F0
  309. call :ProgressBar 60
  310. "%ScriptDir%\tools\Analyse.exe" --Source "%VRAMrTEMP%\Output" --Logfile "%VRAMrTEMP%\Logfiles" --Tool "%ScriptDir%\tools\CLI"
  311.  
  312. call :Flush
  313.  
  314. ::----------------------------------------------------------------------------------------------------------------------------------------
  315.  
  316. color 9F
  317. call :ProgressBar 69
  318. "%ScriptDir%\tools\SQLiteFilter.exe" --dnpm %diffuse% %normal% %parallax% %material% --Filter "%ScriptDir%\tools\Filters.VRAMr" --Source "%VRAMrTEMP%\Output\VRAMr.db" --Logfiles "%VRAMrTEMP%\Logfiles"
  319.  
  320. call :Flush
  321.  
  322. ::----------------------------------------------------------------------------------------------------------------------------------------
  323.  
  324. color DF
  325. call :ProgressBar 74
  326.  
  327. if "%PBRExists%"=="1" (
  328.   "%ScriptDir%\tools\Optimise.exe" --dnpm %diffuse% %normal% %parallax% %material% --Source "%VRAMrTEMP%\Output\VRAMr.db" --Logfiles "%VRAMrTEMP%\Logfiles" --GPU %GPU2Use% --PBR 1 --Tool "%ScriptDir%\tools\texconv.exe"
  329.   ) else (
  330.   "%ScriptDir%\tools\Optimise.exe" --dnpm %diffuse% %normal% %parallax% %material% --Source "%VRAMrTEMP%\Output\VRAMr.db" --Logfiles "%VRAMrTEMP%\Logfiles" --GPU %GPU2Use% --PBR 0 --Tool "%ScriptDir%\tools\texconv.exe"
  331. )
  332.  
  333. call :Flush
  334.  
  335. ::----------------------------------------------------------------------------------------------------------------------------------------
  336.  
  337. :TidyUp
  338. color 0F
  339. call :ProgressBar 93
  340. cd /d "%VRAMrTEMP%"
  341. attrib -R -A -S -H -P *.* /s /d
  342.  
  343. call :ProgressBar 97
  344. cd Output
  345. for /f "usebackq delims=" %%d in ('dir /s /b /ad ^| sort /r') do rd "%%d" >NUL 2>&1
  346.  
  347. call :Flush
  348.  
  349. xcopy "%ScriptDir%\tools\VRAMrOutput.tmp" "%VRAMrTEMP%\Output" /v /q /y >NUL 2>&1
  350. echo %DATE% %TIME% Copying VRAMr Output Marker... >>%VRAMrTEMP%\logfiles\VRAMr.log
  351.  
  352. call :Flush
  353.  
  354. del *.db >NUL 2>&1
  355.  
  356. call :Flush
  357.  
  358. cd ..
  359. ren "Output" "DragNDropThisFolderIntoModManager"
  360. echo %DATE% %TIME% Renaming Your VRAMr Output Folder...  >>%VRAMrTEMP%\logfiles\VRAMr.log
  361.  
  362. echo %DATE% %TIME% VRAMr Output Ready... >>%VRAMrTEMP%\logfiles\VRAMr.log
  363.  
  364. call :ProgressBar 99
  365.  
  366. ::----------------------------------------------------------------------------------------------------------------------------------------
  367.  
  368. color 2F
  369. echo.
  370. echo VRAMr has finished
  371. echo Put 'DragNDropThisFolderIntoModManager' in %VRAMrTEMP% into your Mod Manager
  372. echo %DATE% %TIME% The VRAMr Process is Complete... >>%VRAMrTEMP%\logfiles\VRAMr.log
  373. call :ProgressBar 100
  374. goto Terminate
  375.  
  376. ::----------------------------------------------------------------------------------------------------------------------------------------
  377.  
  378. :ProgressBar
  379. set "ProgressPercent=%1"
  380. title VRAMr - Progress: %ProgressPercent%%%
  381. exit /B
  382.  
  383. ::----------------------------------------------------------------------------------------------------------------------------------------
  384.  
  385. :Flush
  386.  
  387. timeout /t 3 >NUL 2>&1
  388.  
  389. powershell -NoProfile -ExecutionPolicy Bypass -Command "$TempFile = [System.IO.Path]::GetTempFileName(); 'Triggering cache flush' | Set-Content -Path $TempFile; Remove-Item -Path $TempFile -Force"
  390.  
  391. powershell -NoProfile -ExecutionPolicy Bypass -Command "Get-Process | ForEach-Object { try  { [System.Diagnostics.Process]::GetProcessById($_.Id).MinWorkingSet = 0 } catch { } }"
  392.  
  393. exit /B
  394.  
  395. ::----------------------------------------------------------------------------------------------------------------------------------------
  396.  
  397. :Terminate
  398.  
  399. taskkill /f /im Powershell.exe >NUL 2>&1
  400. taskkill /f /im UserGuide.exe >NUL 2>&1
  401. taskkill /f /im texconv.exe >NUL 2>&1
  402. taskkill /f /im Compressonator.exe >NUL 2>&1
  403.  
  404. powershell -NoProfile -ExecutionPolicy Bypass -Command "$TempFile = [System.IO.Path]::GetTempFileName(); 'Triggering cache flush' | Set-Content -Path $TempFile; Remove-Item -Path $TempFile -Force"
  405.  
  406. powershell -NoProfile -ExecutionPolicy Bypass -Command "Get-Process | ForEach-Object { try  { [System.Diagnostics.Process]::GetProcessById($_.Id).MinWorkingSet = 0 } catch { } }"
  407.  
  408. echo.
  409. pause
  410. exit
Advertisement
Add Comment
Please, Sign In to add comment