Skip to content

Commit 1fb4a1a

Browse files
committed
Update for recent tool improvements
1 parent a0eba39 commit 1fb4a1a

8 files changed

+48
-23
lines changed

CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,9 @@ if(BUILD_TOOLS AND BUILD_DX11 AND WIN32)
428428
add_custom_command(
429429
OUTPUT "${COMPILED_SHADERS}/Texenvmap_VSBasic.inc"
430430
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/Texenvmap/Shaders/CompileShaders.cmd"
431-
DEPENDS "${PROJECT_SOURCE_DIR}/Texenvmap/Shaders/Texenvmap.fx"
431+
DEPENDS "Texenvmap/Shaders/Texenvmap.hlsl"
432432
COMMENT "Generating HLSL shaders for texenvmap..."
433-
COMMAND set CompileShadersOutput=${COMPILED_SHADERS}
434-
COMMAND CompileShaders.cmd
433+
COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" $<$<BOOL:${DIRECTX_FXC_TOOL}>:LegacyShaderCompiler=${DIRECTX_FXC_TOOL}> CompileShaders.cmd > "${COMPILED_SHADERS}/compileshaders_envmap.log"
435434
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/Texenvmap/Shaders"
436435
USES_TERMINAL)
437436
endif()

Texenvmap/Shaders/CompileShaders.cmd

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if %PROCESSOR_ARCHITECTURE%.==ARM64. (set FXCARCH=arm64) else (if %PROCESSOR_ARC
99

1010
set FXCOPTS=/nologo /WX /Ges /Zi /Zpc /Qstrip_reflect /Qstrip_debug
1111

12+
if defined LegacyShaderCompiler goto fxcviaenv
1213
set PCFXC="%WindowsSdkVerBinPath%%FXCARCH%\fxc.exe"
1314
if exist %PCFXC% goto continue
1415
set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
@@ -17,6 +18,12 @@ set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\%FXCARCH%\fxc.exe"
1718
if exist %PCFXC% goto continue
1819

1920
set PCFXC=fxc.exe
21+
goto continue
22+
23+
:fxcviaenv
24+
set PCFXC="%LegacyShaderCompiler%"
25+
if not exist %PCFXC% goto needfxc
26+
goto continue
2027

2128
:continue
2229
if not defined CompileShadersOutput set CompileShadersOutput=Compiled
@@ -42,8 +49,12 @@ endlocal
4249
exit /b 0
4350

4451
:CompileShader
45-
set fxc=%PCFXC% %1.fx %FXCOPTS% /T%2_4_0 /E%3 /Fh%CompileShadersOutput%\%1_%3.inc /Fd%CompileShadersOutput%\%1_%3.pdb /Vn%1_%3
52+
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
4653
echo.
4754
echo %fxc%
4855
%fxc% || set error=1
4956
exit /b
57+
58+
:needfxc
59+
echo ERROR: CompileShaders requires FXC.EXE
60+
exit /b 1
File renamed without changes.

Texenvmap/Texenvmap_Desktop_2019.vcxproj

+5-2
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,13 @@
306306
<_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0])</_ATGFXCPath>
307307
<_ATGFXCPath>$(_ATGFXCPath.Replace("x64",""))</_ATGFXCPath>
308308
<_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\</_ATGFXCPath>
309+
<_ATGFXCVer>$([System.Text.RegularExpressions.Regex]::Match($(_ATGFXCPath), `10\.0\.\d+\.0`))</_ATGFXCVer>
310+
<_ATGFXCVer Condition="'$(_ATGFXCVer)' != '' and !HasTrailingSlash('$(_ATGFXCVer)')">$(_ATGFXCVer)\</_ATGFXCVer>
309311
</PropertyGroup>
310-
<Exec Condition="!Exists('Shaders/Compiled/Texenvmap_VSBasic.inc')" WorkingDirectory="$(ProjectDir)Shaders" Command="CompileShaders" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath)" />
312+
<Exec Condition="!Exists('Shaders/Compiled/Texenvmap_VSBasic.inc')" WorkingDirectory="$(ProjectDir)Shaders" Command="CompileShaders" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath);WindowsSDKVersion=$(_ATGFXCVer);CompileShadersOutput=$(ProjectDir)Shaders/Compiled" LogStandardErrorAsError="true" />
311313
<PropertyGroup>
312314
<_ATGFXCPath />
315+
<_ATGFXCVer />
313316
</PropertyGroup>
314317
</Target>
315318
<Target Name="ATGDeleteShaders" AfterTargets="Clean">
@@ -319,5 +322,5 @@
319322
</ItemGroup>
320323
<Delete Files="@(_ATGShaderHeaders)" />
321324
<Delete Files="@(_ATGShaderSymbols)" />
322-
</Target>
325+
</Target>
323326
</Project>

Texenvmap/Texenvmap_Desktop_2019_Win10.vcxproj

+5-2
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,13 @@
436436
<_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0])</_ATGFXCPath>
437437
<_ATGFXCPath>$(_ATGFXCPath.Replace("x64",""))</_ATGFXCPath>
438438
<_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\</_ATGFXCPath>
439+
<_ATGFXCVer>$([System.Text.RegularExpressions.Regex]::Match($(_ATGFXCPath), `10\.0\.\d+\.0`))</_ATGFXCVer>
440+
<_ATGFXCVer Condition="'$(_ATGFXCVer)' != '' and !HasTrailingSlash('$(_ATGFXCVer)')">$(_ATGFXCVer)\</_ATGFXCVer>
439441
</PropertyGroup>
440-
<Exec Condition="!Exists('Shaders/Compiled/Texenvmap_VSBasic.inc')" WorkingDirectory="$(ProjectDir)Shaders" Command="CompileShaders" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath)" />
442+
<Exec Condition="!Exists('Shaders/Compiled/Texenvmap_VSBasic.inc')" WorkingDirectory="$(ProjectDir)Shaders" Command="CompileShaders" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath);WindowsSDKVersion=$(_ATGFXCVer);CompileShadersOutput=$(ProjectDir)Shaders/Compiled" LogStandardErrorAsError="true" />
441443
<PropertyGroup>
442444
<_ATGFXCPath />
445+
<_ATGFXCVer />
443446
</PropertyGroup>
444447
</Target>
445448
<Target Name="ATGDeleteShaders" AfterTargets="Clean">
@@ -449,5 +452,5 @@
449452
</ItemGroup>
450453
<Delete Files="@(_ATGShaderHeaders)" />
451454
<Delete Files="@(_ATGShaderSymbols)" />
452-
</Target>
455+
</Target>
453456
</Project>

Texenvmap/Texenvmap_Desktop_2022.vcxproj

+5-2
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,13 @@
306306
<_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0])</_ATGFXCPath>
307307
<_ATGFXCPath>$(_ATGFXCPath.Replace("x64",""))</_ATGFXCPath>
308308
<_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\</_ATGFXCPath>
309+
<_ATGFXCVer>$([System.Text.RegularExpressions.Regex]::Match($(_ATGFXCPath), `10\.0\.\d+\.0`))</_ATGFXCVer>
310+
<_ATGFXCVer Condition="'$(_ATGFXCVer)' != '' and !HasTrailingSlash('$(_ATGFXCVer)')">$(_ATGFXCVer)\</_ATGFXCVer>
309311
</PropertyGroup>
310-
<Exec Condition="!Exists('Shaders/Compiled/Texenvmap_VSBasic.inc')" WorkingDirectory="$(ProjectDir)Shaders" Command="CompileShaders" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath)" />
312+
<Exec Condition="!Exists('Shaders/Compiled/Texenvmap_VSBasic.inc')" WorkingDirectory="$(ProjectDir)Shaders" Command="CompileShaders" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath);WindowsSDKVersion=$(_ATGFXCVer);CompileShadersOutput=$(ProjectDir)Shaders/Compiled" LogStandardErrorAsError="true" />
311313
<PropertyGroup>
312314
<_ATGFXCPath />
315+
<_ATGFXCVer />
313316
</PropertyGroup>
314317
</Target>
315318
<Target Name="ATGDeleteShaders" AfterTargets="Clean">
@@ -319,5 +322,5 @@
319322
</ItemGroup>
320323
<Delete Files="@(_ATGShaderHeaders)" />
321324
<Delete Files="@(_ATGShaderSymbols)" />
322-
</Target>
325+
</Target>
323326
</Project>

Texenvmap/Texenvmap_Desktop_2022_Win10.vcxproj

+5-2
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,13 @@
436436
<_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0])</_ATGFXCPath>
437437
<_ATGFXCPath>$(_ATGFXCPath.Replace("x64",""))</_ATGFXCPath>
438438
<_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\</_ATGFXCPath>
439+
<_ATGFXCVer>$([System.Text.RegularExpressions.Regex]::Match($(_ATGFXCPath), `10\.0\.\d+\.0`))</_ATGFXCVer>
440+
<_ATGFXCVer Condition="'$(_ATGFXCVer)' != '' and !HasTrailingSlash('$(_ATGFXCVer)')">$(_ATGFXCVer)\</_ATGFXCVer>
439441
</PropertyGroup>
440-
<Exec Condition="!Exists('Shaders/Compiled/Texenvmap_VSBasic.inc')" WorkingDirectory="$(ProjectDir)Shaders" Command="CompileShaders" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath)" />
442+
<Exec Condition="!Exists('Shaders/Compiled/Texenvmap_VSBasic.inc')" WorkingDirectory="$(ProjectDir)Shaders" Command="CompileShaders" EnvironmentVariables="WindowsSdkVerBinPath=$(_ATGFXCPath);WindowsSDKVersion=$(_ATGFXCVer);CompileShadersOutput=$(ProjectDir)Shaders/Compiled" LogStandardErrorAsError="true" />
441443
<PropertyGroup>
442444
<_ATGFXCPath />
445+
<_ATGFXCVer />
443446
</PropertyGroup>
444447
</Target>
445448
<Target Name="ATGDeleteShaders" AfterTargets="Clean">
@@ -449,5 +452,5 @@
449452
</ItemGroup>
450453
<Delete Files="@(_ATGShaderHeaders)" />
451454
<Delete Files="@(_ATGShaderSymbols)" />
452-
</Target>
455+
</Target>
453456
</Project>

Texenvmap/texenvmap.cpp

+14-11
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@
6464

6565
#include "DirectXTex.h"
6666

67-
//Uncomment to add support for OpenEXR (.exr)
68-
//#define USE_OPENEXR
69-
7067
#ifdef USE_OPENEXR
7168
// See <https://github.com/Microsoft/DirectXTex/wiki/Adding-OpenEXR> for details
7269
#include "DirectXTexEXR.h"
@@ -242,7 +239,6 @@ namespace
242239
#ifdef USE_OPENEXR
243240
#define CODEC_EXR 0xFFFF0006
244241
#endif
245-
246242
#ifdef USE_LIBJPEG
247243
#define CODEC_JPEG 0xFFFF0007
248244
#endif
@@ -537,7 +533,7 @@ namespace
537533
{
538534
while (pValue->name)
539535
{
540-
size_t cchName = wcslen(pValue->name);
536+
const size_t cchName = wcslen(pValue->name);
541537

542538
if (cch + cchName + 2 >= 80)
543539
{
@@ -602,7 +598,7 @@ namespace
602598

603599
LPWSTR errorText = nullptr;
604600

605-
DWORD result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER,
601+
const DWORD result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER,
606602
nullptr, static_cast<DWORD>(hr),
607603
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPWSTR>(&errorText), 0, nullptr);
608604

@@ -613,14 +609,21 @@ namespace
613609
swprintf_s(desc, L": %ls", errorText);
614610

615611
size_t len = wcslen(desc);
616-
if (len >= 2)
612+
if (len >= 1)
617613
{
618-
desc[len - 2] = 0;
619614
desc[len - 1] = 0;
620615
}
621616

622617
if (errorText)
623618
LocalFree(errorText);
619+
620+
for (wchar_t* ptr = desc; *ptr != 0; ++ptr)
621+
{
622+
if (*ptr == L'\r' || *ptr == L'\n')
623+
{
624+
*ptr = L' ';
625+
}
626+
}
624627
}
625628

626629
return desc;
@@ -1763,7 +1766,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
17631766
}
17641767
}
17651768
#endif
1766-
1769+
17671770
else
17681771
{
17691772
// WIC shares the same filter values for mode and dither
@@ -1961,7 +1964,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
19611964
if (info.width > maxWidth)
19621965
maxWidth = info.width;
19631966
if (info.height > maxHeight)
1964-
maxHeight = info.height;
1967+
maxHeight = info.height;
19651968
}
19661969

19671970
if (images > 6)
@@ -2024,7 +2027,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
20242027
pContext->RSSetState(stateObjects.CullNone());
20252028
auto linear = stateObjects.LinearClamp();
20262029

2027-
for (size_t face = 0; face < 6; ++face)
2030+
for (size_t face = 0; face < 6; ++face)
20282031
{
20292032
ComPtr<ID3D11ShaderResourceView> srv;
20302033
auto& input = loadedImages[face];

0 commit comments

Comments
 (0)