-
Notifications
You must be signed in to change notification settings - Fork 3
/
hlsl_decompiler_wrapper.bat
55 lines (48 loc) · 1.7 KB
/
hlsl_decompiler_wrapper.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@echo off
setlocal enabledelayedexpansion
rem USAGE:
rem 1. Put this batch file and cmd_Decompiler.exe in the same directory
rem 2. Drag and drop multiple files (e.g., sky_system.o18724, sky_system.o62273) onto this batch file to process them
rem 3. Output files will be named like sky_system.18724.hlsl, sky_system.62273.hlsl
rem 4. For use with Renderdoc:
rem 4.1. Renderdoc -> Tools -> Settings -> Shader Viewer -> Add
rem 4.2. Name: whatever you like
rem 4.3. Tool Type: Custom Tool
rem 4.4. Executable: Choose this batch file instead of cmd_Decompiler.exe
rem 4.5. Command Line: {input_file}
rem 4.6. Input/Output: DXBC/HLSL
rem 5. Renderdoc -> Pipeline State View -> Choose Any Shader Stage
rem 5.1. Edit -> Decompile with ${Name}
rem 6. Modify shader as you wish, and click Refresh button to see the change
:process_files
if "%~1"=="" goto end
rem Extract base name and number from file name
for %%f in ("%~1") do (
set "baseName=%%~nf"
set "extension=%%~xf"
set "number=!extension:~2!"
)
rem Decompile input file
"%~dp0cmd_Decompiler.exe" -D "%~1"
rem Rename the output file
if exist "%~dp1!baseName!.hlsl" (
move "%~dp1!baseName!.hlsl" "%~dp1!baseName!.!number!.hlsl" > nul
if exist "%~dp1!baseName!.!number!.hlsl" (
type "%~dp1!baseName!.!number!.hlsl"
echo.
echo Processing completed for: %~nx1
echo Output file: !baseName!.!number!.hlsl
echo -------------------------------
) else (
echo Error: Failed to rename output file for %~nx1
echo -------------------------------
)
) else (
echo Error: Decompiled file not found for %~nx1
echo -------------------------------
)
shift
goto process_files
:end
echo All files processed.
pause