Skip to content

Commit 236157c

Browse files
committed
Minor code review
1 parent d507978 commit 236157c

File tree

22 files changed

+100
-94
lines changed

22 files changed

+100
-94
lines changed

Kits/ATGTK/PerformanceTimersXbox.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,12 @@ void GPUCommandListTimer<t_CommandList>::Frame::Stop(_In_ t_CommandList* command
393393
}
394394

395395
// Force compilation of these template instantiations
396-
template class GPUCommandListTimer<ID3D12GraphicsCommandList>;
397-
template class GPUCommandListTimer<ID3D12XboxDmaCommandList>;
398-
template class GPUCommandListTimer<ID3D12GraphicsCommandList>;
396+
namespace DX
397+
{
398+
template class GPUCommandListTimer<ID3D12GraphicsCommandList>;
399+
template class GPUCommandListTimer<ID3D12XboxDmaCommandList>;
400+
template class GPUCommandListTimer<ID3D12GraphicsCommandList>;
401+
}
399402

400403

401404
//======================================================================================
@@ -606,9 +609,12 @@ void GPUContextTimer<t_Context>::Frame::Stop(_In_ t_Context* context, uint32_t t
606609
}
607610

608611
// Force compilation of these template instantiations
609-
template class GPUContextTimer<ID3D11DeviceContextX>;
610-
template class GPUContextTimer<ID3D11DmaEngineContextX>;
611-
template class GPUContextTimer<ID3D11ComputeContextX>;
612+
namespace DX
613+
{
614+
template class GPUContextTimer<ID3D11DeviceContextX>;
615+
template class GPUContextTimer<ID3D11DmaEngineContextX>;
616+
template class GPUContextTimer<ID3D11ComputeContextX>;
617+
}
612618

613619
#else
614620
#error Must include d3d11*.h or d3d12*.h in pch.h

Kits/ATGTK/d3dx12.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ struct CD3DX12_CLEAR_VALUE : public D3D12_CLEAR_VALUE
555555
UINT8 stencil )
556556
{
557557
Format = format;
558+
memset( &Color, 0, sizeof( Color ) );
558559
/* Use memcpy to preserve NAN values */
559560
memcpy( &DepthStencil.Depth, &depth, sizeof( depth ) );
560561
DepthStencil.Stencil = stencil;
@@ -844,6 +845,7 @@ struct CD3DX12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION
844845
{
845846
pResource = pRes;
846847
Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
848+
PlacedFootprint = {};
847849
SubresourceIndex = Sub;
848850
}
849851
};

UWPSamples/Audio/SimpleWASAPICaptureUWP/Common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
static const GUID AUDIOSESSIONGUID =
1818
{ 0xb3954ae8, 0xc3c3, 0x4094,{ 0x82, 0x1c, 0xc7, 0xbd, 0xf4, 0xab, 0x15, 0x8a } };
1919

20-
// release and zero out a possible NULL pointer. note this will
20+
// release and zero out a possible nullptr pointer. note this will
2121
// do the release on a temp copy to avoid reentrancy issues that can result from
2222
// callbacks durring the release
2323
template <class T> void SafeRelease( __deref_inout_opt T **ppT )
@@ -70,7 +70,7 @@ public: \
7070
AddRef(); \
7171
return S_OK; \
7272
} \
73-
*ppvObject = NULL; \
73+
*ppvObject = nullptr; \
7474
return E_NOINTERFACE; \
7575
} \
7676
STDMETHOD( GetParameters )( \

UWPSamples/Audio/SimpleWASAPIPlaySoundUWP/ToneSampleGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void ToneSampleGenerator::GenerateSineSamples(unsigned char *Buffer, size_t Buff
116116
{
117117
double sampleIncrement = (Frequency * (M_PI*2)) / (double)SamplesPerSecond;
118118
T *dataBuffer = reinterpret_cast<T *>(Buffer);
119-
double theta = (InitialTheta != NULL ? *InitialTheta : 0);
119+
double theta = (InitialTheta != nullptr ? *InitialTheta : 0);
120120

121121
for (size_t i = 0 ; i < BufferLength / sizeof(T) ; i += ChannelCount)
122122
{
@@ -128,7 +128,7 @@ void ToneSampleGenerator::GenerateSineSamples(unsigned char *Buffer, size_t Buff
128128
theta += sampleIncrement;
129129
}
130130

131-
if (InitialTheta != NULL)
131+
if (InitialTheta != nullptr)
132132
{
133133
*InitialTheta = theta;
134134
}

UWPSamples/Audio/SimpleWASAPIPlaySoundUWP/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <mmreg.h>
1313
#include <mfapi.h>
1414

15-
// release and zero out a possible NULL pointer. note this will
15+
// release and zero out a possible nullptr pointer. note this will
1616
// do the release on a temp copy to avoid reentrancy issues that can result from
1717
// callbacks durring the release
1818
template <class T> void SafeRelease( __deref_inout_opt T **ppT )
@@ -61,7 +61,7 @@ public: \
6161
AddRef(); \
6262
return S_OK; \
6363
} \
64-
*ppvObject = NULL; \
64+
*ppvObject = nullptr; \
6565
return E_NOINTERFACE; \
6666
} \
6767
STDMETHOD( GetParameters )( \

UWPSamples/System/NLSAndLocalizationUWP/NLSAndLocalizationUWP.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ void Sample::Initialize(IUnknown* window, int width, int height, DXGI_MODE_ROTAT
3636
int retVal = GetUserDefaultLocaleName(m_localeName, ARRAYSIZE(m_localeName));
3737
if (retVal == 0)
3838
throw std::exception("Failed to get locale in CreateDeviceDependenciesResources");
39-
swprintf_s(m_imagePrepend, _countof(m_imagePrepend), L"Assets\\Images\\%s\\", m_localeName);
40-
swprintf_s(m_resFileName, _countof(m_resFileName), L"Assets\\Resources\\%s.resources", m_localeName);
39+
swprintf_s(m_imagePrepend, _countof(m_imagePrepend), L"Assets\\Images\\%ls\\", m_localeName);
40+
swprintf_s(m_resFileName, _countof(m_resFileName), L"Assets\\Resources\\%ls.resources", m_localeName);
4141

4242
m_deviceResources->CreateDeviceResources();
4343
CreateDeviceDependentResources();
@@ -59,7 +59,7 @@ void Sample::InitializeLocalization()
5959
// Get Package Details using the Package Id
6060
Windows::ApplicationModel::Package^ package = Windows::ApplicationModel::Package::Current;
6161
Windows::ApplicationModel::PackageId^ packageId = package->Id;
62-
m_textConsole->Format(L"The Package Full Name is: %s\n", packageId->FullName->Data());
62+
m_textConsole->Format(L"The Package Full Name is: %ls\n", packageId->FullName->Data());
6363

6464
// Get the locale name for the system using GetUserDefaultLocaleName(). This will return the locale selected through the
6565
// Settings app only if that locale has been added to the Resources section of the application's package manifest.
@@ -69,7 +69,7 @@ void Sample::InitializeLocalization()
6969
int retVal = GetUserDefaultLocaleName(userLocaleName, ARRAYSIZE(userLocaleName));
7070
if (FunctionSucceeded(retVal, L"GetUserDefaultLocaleName"))
7171
{
72-
swprintf_s(message, L"GetUserDefaultLocaleName succeeded: %s\n", userLocaleName);
72+
swprintf_s(message, L"GetUserDefaultLocaleName succeeded: %ls\n", userLocaleName);
7373
OutputDebugString(message);
7474
m_textConsole->Write(message);
7575
}
@@ -93,14 +93,14 @@ void Sample::InitializeLocalization()
9393
throw std::exception("LocaleNameToLCID failed!");
9494
}
9595

96-
// The GetUserGeoID() API can be used to get the actual country the kit is in.
97-
// It gives you the country selected through the Settings app
96+
// The GetUserGeoID() API can be used to get the actual country/region the kit is in.
97+
// It gives you the country/region selected through the Settings app
9898
long geoID = GetUserGeoID(GEOCLASS_NATION);
9999
wchar_t geoData[LOCALE_NAME_MAX_LENGTH];
100100
retVal = GetGeoInfoW(geoID, GEO_LATITUDE, geoData, ARRAYSIZE(geoData), primary);
101101
if (FunctionSucceeded(retVal, L"GetGeoInfoW"))
102102
{
103-
swprintf_s(message, L"Lattitude query succeeded: %s\n", geoData);
103+
swprintf_s(message, L"Lattitude query succeeded: %ls\n", geoData);
104104
OutputDebugString(message);
105105
m_textConsole->Write(message);
106106
}
@@ -112,7 +112,7 @@ void Sample::InitializeLocalization()
112112
retVal = GetGeoInfoW(geoID, GEO_LONGITUDE, geoData, ARRAYSIZE(geoData), primary);
113113
if (FunctionSucceeded(retVal, L"GetGeoInfoW"))
114114
{
115-
swprintf_s(message, L"Longitude query succeeded: %s\n", geoData);
115+
swprintf_s(message, L"Longitude query succeeded: %ls\n", geoData);
116116
OutputDebugString(message);
117117
m_textConsole->Write(message);
118118
}
@@ -124,7 +124,7 @@ void Sample::InitializeLocalization()
124124
retVal = GetGeoInfoW(geoID, GEO_NATION, geoData, ARRAYSIZE(geoData), primary);
125125
if (FunctionSucceeded(retVal, L"GetGeoInfoW"))
126126
{
127-
swprintf_s(message, L"Nation query succeeded: %s\n", geoData);
127+
swprintf_s(message, L"Nation query succeeded: %ls\n", geoData);
128128
OutputDebugString(message);
129129
m_textConsole->Write(message);
130130
}
@@ -137,7 +137,7 @@ void Sample::InitializeLocalization()
137137
retVal = GetGeoInfoW(geoID, GEO_ISO2, iso2, ARRAYSIZE(iso2), primary);
138138
if (FunctionSucceeded(retVal, L"GetGeoInfoW"))
139139
{
140-
swprintf_s(message, L"Iso2 query succeeded: %s\n", iso2);
140+
swprintf_s(message, L"Iso2 query succeeded: %ls\n", iso2);
141141
OutputDebugString(message);
142142
m_textConsole->Write(message);
143143
}
@@ -150,7 +150,7 @@ void Sample::InitializeLocalization()
150150
retVal = GetGeoInfoW(geoID, GEO_ISO3, iso3, ARRAYSIZE(iso3), primary);
151151
if (FunctionSucceeded(retVal, L"GetGeoInfoW"))
152152
{
153-
swprintf_s(message, L"Iso3 query succeeded: %s\n", iso3);
153+
swprintf_s(message, L"Iso3 query succeeded: %ls\n", iso3);
154154
OutputDebugString(message);
155155
m_textConsole->Write(message);
156156
}
@@ -159,25 +159,25 @@ void Sample::InitializeLocalization()
159159
throw std::exception("GetGeoInfoW failed on GEO_ISO3!");
160160
}
161161

162-
// The country values returned from GetUserDefaultLocaleName() and GetUserGeoID() can be compared
163-
// to determine if the country selected by the user is supported by the app or not
162+
// The country/region values returned from GetUserDefaultLocaleName() and GetUserGeoID() can be compared
163+
// to determine if the country/region selected by the user is supported by the app or not
164164
std::wstring localeNameStr(userLocaleName);
165165
std::wstring::size_type pos = localeNameStr.find(L'-');
166166
localeNameStr = localeNameStr.substr(pos + 1);
167167
if (_wcsicmp(localeNameStr.c_str(), iso2) == 0 || _wcsicmp(localeNameStr.c_str(), iso3) == 0)
168168
{
169-
m_textConsole->Format(L"Selected locale in manifest. Country: %s\n", iso2);
169+
m_textConsole->Format(L"Selected locale in manifest. Country/region: %ls\n", iso2);
170170
}
171171
else
172172
{
173-
m_textConsole->Format(L"The selected locale (Country: %s) is NOT present in the manifest, so the fallback locale (Country: %s) is selected for localization\n", iso2, localeNameStr.c_str());
173+
m_textConsole->Format(L"The selected locale (Country/region: %s) is NOT present in the manifest, so the fallback locale (Country: %ls) is selected for localization\n", iso2, localeNameStr.c_str());
174174
}
175175

176176
wchar_t lcpData[LOCALE_NAME_MAX_LENGTH];
177177
retVal = GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SISO639LANGNAME, lcpData, ARRAYSIZE(lcpData));
178178
if (FunctionSucceeded(retVal, L"GetLocaleInfoEx"))
179179
{
180-
m_textConsole->Format(L"GetLocaleInfoEx() - LOCALE_SISO639LANGNAME: %s\n", lcpData);
180+
m_textConsole->Format(L"GetLocaleInfoEx() - LOCALE_SISO639LANGNAME: %ls\n", lcpData);
181181
}
182182
else
183183
{
@@ -187,7 +187,7 @@ void Sample::InitializeLocalization()
187187
retVal = GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, lcpData, ARRAYSIZE(lcpData));
188188
if (FunctionSucceeded(retVal, L"GetLocaleInfoEx"))
189189
{
190-
m_textConsole->Format(L"GetLocaleInfoEx() - LOCALE_IDEFAULTLANGUAGE: %s\n", lcpData);
190+
m_textConsole->Format(L"GetLocaleInfoEx() - LOCALE_IDEFAULTLANGUAGE: %ls\n", lcpData);
191191
}
192192
else
193193
{
@@ -389,7 +389,7 @@ bool Sample::FunctionSucceeded(int returned, const wchar_t* function)
389389
{
390390
unsigned long error = GetLastError();
391391
wchar_t message[1024] = { L'\0' };
392-
swprintf_s(message, L"%s failed with error: %u\n", function, error);
392+
swprintf_s(message, L"%ls failed with error: %u\n", function, error);
393393
OutputDebugString(message);
394394
return false;
395395
}

XDKSamples/Audio/AdvancedSpatialSoundsXDK/AdvancedSpatialSoundsXDK.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ Sample::Sample() :
274274
m_usedObjects(0),
275275
m_frame(0),
276276
m_fileLoaded(false),
277-
m_curFile(0),
278277
m_workThread(nullptr)
279278
{
280279
m_deviceResources = std::make_unique<DX::DeviceResources>();

XDKSamples/Audio/AdvancedSpatialSoundsXDK/AdvancedSpatialSoundsXDK.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ class Sample
154154
std::unique_ptr<DirectX::GraphicsMemory> m_graphicsMemory;
155155

156156
bool m_fileLoaded;
157-
int m_curFile;
158157

159158
//worker thread for spatial system
160159
PTP_WORK m_workThread;

XDKSamples/Audio/SimpleWASAPICaptureXDK/Common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
static const GUID AUDIOSESSIONGUID =
1818
{ 0xb3954ae8, 0xc3c3, 0x4094,{ 0x82, 0x1c, 0xc7, 0xbd, 0xf4, 0xab, 0x15, 0x8a } };
1919

20-
// release and zero out a possible NULL pointer. note this will
20+
// release and zero out a possible nullptr pointer. note this will
2121
// do the release on a temp copy to avoid reentrancy issues that can result from
2222
// callbacks durring the release
2323
template <class T> void SafeRelease( __deref_inout_opt T **ppT )
@@ -70,7 +70,7 @@ public: \
7070
AddRef(); \
7171
return S_OK; \
7272
} \
73-
*ppvObject = NULL; \
73+
*ppvObject = nullptr; \
7474
return E_NOINTERFACE; \
7575
} \
7676
STDMETHOD( GetParameters )( \

XDKSamples/Audio/SimpleWASAPICaptureXDK/DeviceManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ DeviceManager::DeviceManager() :
2323
{
2424
ComPtr<IMMDeviceCollection> deviceCollectionInterface;
2525

26-
CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&m_deviceEnum);
26+
CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&m_deviceEnum);
2727

2828
if (!InitializeCriticalSectionEx( &m_CritSec, 0, 0 ))
2929
{

0 commit comments

Comments
 (0)