Skip to content

Commit 915f034

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

File tree

5 files changed

+32
-19
lines changed

5 files changed

+32
-19
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()

DirectXTex/Shaders/CompileShaders.cmd

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ if exist %PCFXC% goto continue
2020
set PCFXC=fxc.exe
2121
goto continue
2222

23-
:fxcviaenv
24-
set PCFXC="%LegacyShaderCompiler%"
25-
if not exist %PCFXC% goto needfxc
26-
goto continue
23+
:fxcviaenv
24+
set PCFXC="%LegacyShaderCompiler%"
25+
if not exist %PCFXC% goto needfxc
26+
goto continue
2727

2828
:continue
2929
if not defined CompileShadersOutput set CompileShadersOutput=Compiled

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.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)