Skip to content

Commit

Permalink
Update DirectXTK, DirectXTex for October 2018 release
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Oct 29, 2018
1 parent 55797a6 commit 09fadf2
Show file tree
Hide file tree
Showing 17 changed files with 861 additions and 46 deletions.
2 changes: 2 additions & 0 deletions DirectXTK/Audio/DirectXTKAudio_Desktop_2017_DXSDK.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<SDLCheck>true</SDLCheck>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -147,6 +148,7 @@
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<SDLCheck>true</SDLCheck>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
2 changes: 2 additions & 0 deletions DirectXTK/Audio/DirectXTKAudio_Desktop_2017_Win8.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
<ConformanceMode>false</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -139,6 +140,7 @@
<ConformanceMode>false</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
2 changes: 2 additions & 0 deletions DirectXTK/DirectXTK_Desktop_2017.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -589,6 +590,7 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
2 changes: 2 additions & 0 deletions DirectXTK/DirectXTK_Desktop_2017_Win10.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@
<ConformanceMode>false</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -601,6 +602,7 @@
<ConformanceMode>false</ConformanceMode>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
4 changes: 2 additions & 2 deletions DirectXTK/Inc/DirectXHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace DirectX
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
#if defined(_XBOX_ONE) && defined(_TITLE)
wchar_t wname[MAX_PATH];
int result = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, TNameLength, wname, MAX_PATH);
int result = MultiByteToWideChar(CP_UTF8, 0, name, TNameLength, wname, MAX_PATH);
if (result > 0)
{
resource->SetName(wname);
Expand All @@ -132,7 +132,7 @@ namespace DirectX
resource->SetName( name );
#else
char aname[MAX_PATH];
int result = WideCharToMultiByte(CP_ACP, 0, name, TNameLength, aname, MAX_PATH, nullptr, nullptr);
int result = WideCharToMultiByte(CP_UTF8, 0, name, TNameLength, aname, MAX_PATH, nullptr, nullptr);
if (result > 0)
{
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, aname);
Expand Down
6 changes: 5 additions & 1 deletion DirectXTK/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DirectXTK - the DirectX Tool Kit for DirectX 11

Copyright (c) Microsoft Corporation. All rights reserved.

August 17, 2018
October 25, 2018

This package contains the "DirectX Tool Kit", a collection of helper classes for
writing Direct3D 11 C++ code for Universal Windows Platform (UWP) apps for Windows 10,
Expand Down Expand Up @@ -99,6 +99,10 @@ RELEASE NOTES
RELEASE HISTORY
---------------

October 25, 2018
Use UTF-8 instead of ANSI for narrow strings
Minor code review

August 17, 2018
Improved validation for 16k textures and other large resources
Improved debug output for failed texture loads and screengrabs
Expand Down
8 changes: 4 additions & 4 deletions DirectXTK/Src/DDSTextureLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,14 +1168,14 @@ HRESULT DirectX::CreateDDSTextureFromFileEx(ID3D11Device* d3dDevice,
}
#else
CHAR strFileA[MAX_PATH];
int result = WideCharToMultiByte(CP_ACP,
int result = WideCharToMultiByte(CP_UTF8,
WC_NO_BEST_FIT_CHARS,
fileName,
-1,
strFileA,
MAX_PATH,
nullptr,
FALSE
nullptr
);
if (result > 0)
{
Expand Down Expand Up @@ -1302,14 +1302,14 @@ HRESULT DirectX::CreateDDSTextureFromFileEx(ID3D11DeviceX* d3dDevice,
}
#else
CHAR strFileA[MAX_PATH];
int result = WideCharToMultiByte(CP_ACP,
int result = WideCharToMultiByte(CP_UTF8,
WC_NO_BEST_FIT_CHARS,
fileName,
-1,
strFileA,
MAX_PATH,
nullptr,
FALSE
nullptr
);
if (result > 0)
{
Expand Down
10 changes: 6 additions & 4 deletions DirectXTK/Src/GamePad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ using Microsoft::WRL::ComPtr;

namespace
{
const float c_XboxOneThumbDeadZone = .24f; // Recommended Xbox One controller deadzone

float ApplyLinearDeadZone(float value, float maxValue, float deadZoneSize)
{
if (value < -deadZoneSize)
Expand Down Expand Up @@ -205,11 +207,11 @@ class GamePad::Impl
state.dpad.left = (reading.Buttons & GamepadButtons::GamepadButtons_DPadLeft) != 0;

ApplyStickDeadZone(static_cast<float>(reading.LeftThumbstickX), static_cast<float>(reading.LeftThumbstickY),
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
state.thumbSticks.leftX, state.thumbSticks.leftY);

ApplyStickDeadZone(static_cast<float>(reading.RightThumbstickX), static_cast<float>(reading.RightThumbstickY),
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
state.thumbSticks.rightX, state.thumbSticks.rightY);

state.triggers.left = static_cast<float>(reading.LeftTrigger);
Expand Down Expand Up @@ -652,11 +654,11 @@ class GamePad::Impl
state.dpad.left = (reading.Buttons & GamepadButtons::GamepadButtons_DPadLeft) != 0;

ApplyStickDeadZone(reading.LeftThumbstickX, reading.LeftThumbstickY,
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
state.thumbSticks.leftX, state.thumbSticks.leftY);

ApplyStickDeadZone(reading.RightThumbstickX, reading.RightThumbstickY,
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
state.thumbSticks.rightX, state.thumbSticks.rightY);

state.triggers.left = reading.LeftTrigger;
Expand Down
20 changes: 10 additions & 10 deletions DirectXTK/Src/ModelLoadSDKMESH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ namespace
IEffectFactory& fxFactory,
MaterialRecordSDKMESH& m)
{
wchar_t matName[DXUT::MAX_MATERIAL_NAME];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, mh.Name, -1, matName, DXUT::MAX_MATERIAL_NAME);
wchar_t matName[DXUT::MAX_MATERIAL_NAME] = {};
MultiByteToWideChar(CP_UTF8, 0, mh.Name, -1, matName, DXUT::MAX_MATERIAL_NAME);

wchar_t diffuseName[DXUT::MAX_TEXTURE_NAME];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, mh.DiffuseTexture, -1, diffuseName, DXUT::MAX_TEXTURE_NAME);
wchar_t diffuseName[DXUT::MAX_TEXTURE_NAME] = {};
MultiByteToWideChar(CP_UTF8, 0, mh.DiffuseTexture, -1, diffuseName, DXUT::MAX_TEXTURE_NAME);

wchar_t specularName[DXUT::MAX_TEXTURE_NAME];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, mh.SpecularTexture, -1, specularName, DXUT::MAX_TEXTURE_NAME);
wchar_t specularName[DXUT::MAX_TEXTURE_NAME] = {};
MultiByteToWideChar(CP_UTF8, 0, mh.SpecularTexture, -1, specularName, DXUT::MAX_TEXTURE_NAME);

wchar_t normalName[DXUT::MAX_TEXTURE_NAME];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, mh.NormalTexture, -1, normalName, DXUT::MAX_TEXTURE_NAME);
wchar_t normalName[DXUT::MAX_TEXTURE_NAME] = {};
MultiByteToWideChar(CP_UTF8, 0, mh.NormalTexture, -1, normalName, DXUT::MAX_TEXTURE_NAME);

if (flags & DUAL_TEXTURE && !mh.SpecularTexture[0])
{
Expand Down Expand Up @@ -532,8 +532,8 @@ std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH(ID3D11Device* d3dDevice
}

auto mesh = std::make_shared<ModelMesh>();
wchar_t meshName[DXUT::MAX_MESH_NAME];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, mh.Name, -1, meshName, DXUT::MAX_MESH_NAME);
wchar_t meshName[DXUT::MAX_MESH_NAME] = {};
MultiByteToWideChar(CP_UTF8, 0, mh.Name, -1, meshName, DXUT::MAX_MESH_NAME);
mesh->name = meshName;
mesh->ccw = ccw;
mesh->pmalpha = pmalpha;
Expand Down
1 change: 1 addition & 0 deletions DirectXTK/Src/Shaders/CompileShaders.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if exist %PCFXC% goto continue
set PCFXC=fxc.exe

:continue
@if not exist Compiled mkdir Compiled
call :CompileShader%1 AlphaTestEffect vs VSAlphaTest
call :CompileShader%1 AlphaTestEffect vs VSAlphaTestNoFog
call :CompileShader%1 AlphaTestEffect vs VSAlphaTestVc
Expand Down
20 changes: 10 additions & 10 deletions DirectXTK/Src/WICTextureLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ namespace
return hr;

WICPixelFormatGUID convertGUID;
memcpy(&convertGUID, &pixelFormat, sizeof(WICPixelFormatGUID));
memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &pixelFormat, sizeof(GUID));

size_t bpp = 0;

Expand All @@ -355,14 +355,14 @@ namespace
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
if (g_WIC2)
{
memcpy(&convertGUID, &GUID_WICPixelFormat96bppRGBFloat, sizeof(WICPixelFormatGUID));
memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat96bppRGBFloat, sizeof(GUID));
format = DXGI_FORMAT_R32G32B32_FLOAT;
bpp = 96;
}
else
#endif
{
memcpy(&convertGUID, &GUID_WICPixelFormat128bppRGBAFloat, sizeof(WICPixelFormatGUID));
memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat128bppRGBAFloat, sizeof(GUID));
format = DXGI_FORMAT_R32G32B32A32_FLOAT;
bpp = 128;
}
Expand All @@ -373,7 +373,7 @@ namespace
{
if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0)
{
memcpy(&convertGUID, &g_WICConvert[i].target, sizeof(WICPixelFormatGUID));
memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &g_WICConvert[i].target, sizeof(GUID));

format = _WICToDXGI(g_WICConvert[i].target);
assert(format != DXGI_FORMAT_UNKNOWN);
Expand Down Expand Up @@ -406,7 +406,7 @@ namespace
if (FAILED(hr) || !(fmtSupport & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN))
{
// Use R32G32B32A32_FLOAT instead which is required for Feature Level 10.0 and up
memcpy(&convertGUID, &GUID_WICPixelFormat128bppRGBAFloat, sizeof(WICPixelFormatGUID));
memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat128bppRGBAFloat, sizeof(GUID));
format = DXGI_FORMAT_R32G32B32A32_FLOAT;
bpp = 128;
}
Expand Down Expand Up @@ -480,7 +480,7 @@ namespace
if (FAILED(hr) || !(support & D3D11_FORMAT_SUPPORT_TEXTURE2D))
{
// Fallback to RGBA 32-bit format which is supported by all devices
memcpy(&convertGUID, &GUID_WICPixelFormat32bppRGBA, sizeof(WICPixelFormatGUID));
memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA, sizeof(GUID));
format = DXGI_FORMAT_R8G8B8A8_UNORM;
bpp = 32;
}
Expand Down Expand Up @@ -993,14 +993,14 @@ HRESULT DirectX::CreateWICTextureFromFileEx(ID3D11Device* d3dDevice,
}
#else
CHAR strFileA[MAX_PATH];
int result = WideCharToMultiByte(CP_ACP,
int result = WideCharToMultiByte(CP_UTF8,
WC_NO_BEST_FIT_CHARS,
fileName,
-1,
strFileA,
MAX_PATH,
nullptr,
FALSE
nullptr
);
if (result > 0)
{
Expand Down Expand Up @@ -1116,14 +1116,14 @@ _Use_decl_annotations_
}
#else
CHAR strFileA[MAX_PATH];
int result = WideCharToMultiByte(CP_ACP,
int result = WideCharToMultiByte(CP_UTF8,
WC_NO_BEST_FIT_CHARS,
fileName,
-1,
strFileA,
MAX_PATH,
nullptr,
FALSE
nullptr
);
if (result > 0)
{
Expand Down
4 changes: 2 additions & 2 deletions DirectXTex/DirectXTexConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4358,8 +4358,8 @@ namespace
_Out_ WICPixelFormatGUID& pfGUID,
_Out_ WICPixelFormatGUID& targetGUID)
{
memcpy(&pfGUID, &GUID_NULL, sizeof(GUID));
memcpy(&targetGUID, &GUID_NULL, sizeof(GUID));
memset(&pfGUID, 0, sizeof(GUID));
memset(&targetGUID, 0, sizeof(GUID));

if (filter & TEX_FILTER_FORCE_NON_WIC)
{
Expand Down
2 changes: 1 addition & 1 deletion DirectXTex/DirectXTexUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ bool DirectX::_DXGIToWIC(DXGI_FORMAT format, GUID& guid, bool ignoreRGBvsBGR)
break;
}

memcpy(&guid, &GUID_NULL, sizeof(GUID));
memset(&guid, 0, sizeof(GUID));
return false;
}

Expand Down
14 changes: 7 additions & 7 deletions DirectXTex/DirectXTexWIC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace
if (iswic2)
{
if (pConvert)
memcpy(pConvert, &GUID_WICPixelFormat96bppRGBFloat, sizeof(WICPixelFormatGUID));
memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat96bppRGBFloat, sizeof(GUID));
format = DXGI_FORMAT_R32G32B32_FLOAT;
}
else
Expand All @@ -172,7 +172,7 @@ namespace
#endif
{
if (pConvert)
memcpy(pConvert, &GUID_WICPixelFormat128bppRGBAFloat, sizeof(WICPixelFormatGUID));
memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat128bppRGBAFloat, sizeof(GUID));
format = DXGI_FORMAT_R32G32B32A32_FLOAT;
}
}
Expand All @@ -183,7 +183,7 @@ namespace
if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0)
{
if (pConvert)
memcpy(pConvert, &g_WICConvert[i].target, sizeof(WICPixelFormatGUID));
memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &g_WICConvert[i].target, sizeof(GUID));

format = _WICToDXGI(g_WICConvert[i].target);
assert(format != DXGI_FORMAT_UNKNOWN);
Expand All @@ -202,7 +202,7 @@ namespace
{
format = DXGI_FORMAT_R8G8B8A8_UNORM;
if (pConvert)
memcpy(pConvert, &GUID_WICPixelFormat32bppRGBA, sizeof(WICPixelFormatGUID));
memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA, sizeof(GUID));
}
break;

Expand All @@ -211,7 +211,7 @@ namespace
{
format = DXGI_FORMAT_R10G10B10A2_UNORM;
if (pConvert)
memcpy(pConvert, &GUID_WICPixelFormat32bppRGBA1010102, sizeof(WICPixelFormatGUID));
memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA1010102, sizeof(GUID));
}
break;

Expand All @@ -221,7 +221,7 @@ namespace
{
format = DXGI_FORMAT_R8G8B8A8_UNORM;
if (pConvert)
memcpy(pConvert, &GUID_WICPixelFormat32bppRGBA, sizeof(WICPixelFormatGUID));
memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA, sizeof(GUID));
}
break;

Expand All @@ -231,7 +231,7 @@ namespace
// By default we want to promote a black & white to gresycale since R1 is not a generally supported D3D format
format = DXGI_FORMAT_R8_UNORM;
if (pConvert)
memcpy(pConvert, &GUID_WICPixelFormat8bppGray, sizeof(WICPixelFormatGUID));
memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat8bppGray, sizeof(GUID));
}
break;

Expand Down
Loading

0 comments on commit 09fadf2

Please sign in to comment.