DirectXTex/Texenvmap/Shaders/CompileShaders.cmd
2025-04-24 11:15:25 -07:00

61 lines
1.5 KiB
Batchfile

@echo off
rem Copyright (c) Microsoft Corporation.
rem Licensed under the MIT License.
setlocal
set error=0
if %PROCESSOR_ARCHITECTURE%.==ARM64. (set FXCARCH=arm64) else (if %PROCESSOR_ARCHITECTURE%.==AMD64. (set FXCARCH=x64) else (set FXCARCH=x86))
set FXCOPTS=/nologo /WX /Ges /Zi /Zpc /Qstrip_reflect /Qstrip_debug
if defined LegacyShaderCompiler goto fxcviaenv
set PCFXC="%WindowsSdkVerBinPath%%FXCARCH%\fxc.exe"
if exist %PCFXC% goto continue
set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
if exist %PCFXC% goto continue
set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
if exist %PCFXC% goto continue
set PCFXC=fxc.exe
goto continue
:fxcviaenv
set PCFXC="%LegacyShaderCompiler%"
if not exist %PCFXC% goto needfxc
goto continue
:continue
if not defined CompileShadersOutput set CompileShadersOutput=Compiled
set StrTrim=%CompileShadersOutput%##
set StrTrim=%StrTrim: ##=%
set CompileShadersOutput=%StrTrim:##=%
@if not exist "%CompileShadersOutput%" mkdir "%CompileShadersOutput%"
call :CompileShader Texenvmap vs VSBasic
call :CompileShader Texenvmap ps PSBasic
call :CompileShader Texenvmap ps PSEquiRect
echo.
if %error% == 0 (
echo Shaders compiled ok
) else (
echo There were shader compilation errors!
exit /b 1
)
endlocal
exit /b 0
:CompileShader
set fxc=%PCFXC% "%1.hlsl" %FXCOPTS% /T%2_4_0 /E%3 "/Fh%CompileShadersOutput%\%1_%3.inc" "/Fd%CompileShadersOutput%\%1_%3.pdb" /Vn%1_%3
echo.
echo %fxc%
%fxc% || set error=1
exit /b
:needfxc
echo ERROR: CompileShaders requires FXC.EXE
exit /b 1