Code cleanup for improved C++ conformance

This commit is contained in:
Chuck Walbourn 2018-06-11 15:42:45 -07:00
Родитель 4b770a7038
Коммит 8aba96f6fb
39 изменённых файлов: 126 добавлений и 131 удалений

Просмотреть файл

@ -371,8 +371,8 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
}
assert(!xaudio2);
assert(!mMasterVoice);
assert(!mReverbVoice);
assert(mMasterVoice == nullptr);
assert(mReverbVoice == nullptr);
masterChannelMask = masterChannels = masterRate = 0;
@ -701,7 +701,7 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
//
for (auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it)
{
assert(*it != 0);
assert(*it != nullptr);
(*it)->OnReset();
}
@ -713,20 +713,20 @@ void AudioEngine::Impl::SetSilentMode()
{
for (auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it)
{
assert(*it != 0);
assert(*it != nullptr);
(*it)->OnCriticalError();
}
for (auto it = mOneShots.begin(); it != mOneShots.end(); ++it)
{
assert(it->second != 0);
assert(it->second != nullptr);
it->second->DestroyVoice();
}
mOneShots.clear();
for (auto it = mVoicePool.begin(); it != mVoicePool.end(); ++it)
{
assert(it->second != 0);
assert(it->second != nullptr);
it->second->DestroyVoice();
}
mVoicePool.clear();
@ -746,7 +746,7 @@ void AudioEngine::Impl::Shutdown()
{
for (auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it)
{
assert(*it != 0);
assert(*it != nullptr);
(*it)->OnDestroyEngine();
}
@ -758,14 +758,14 @@ void AudioEngine::Impl::Shutdown()
for (auto it = mOneShots.begin(); it != mOneShots.end(); ++it)
{
assert(it->second != 0);
assert(it->second != nullptr);
it->second->DestroyVoice();
}
mOneShots.clear();
for (auto it = mVoicePool.begin(); it != mVoicePool.end(); ++it)
{
assert(it->second != 0);
assert(it->second != nullptr);
it->second->DestroyVoice();
}
mVoicePool.clear();
@ -811,7 +811,7 @@ bool AudioEngine::Impl::Update()
// Scan for completed one-shot voices
for (auto it = mOneShots.begin(); it != mOneShots.end(); )
{
assert(it->second != 0);
assert(it->second != nullptr);
XAUDIO2_VOICE_STATE xstate;
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
@ -856,7 +856,7 @@ bool AudioEngine::Impl::Update()
//
for (auto it = mNotifyUpdates.begin(); it != mNotifyUpdates.end(); ++it)
{
assert(*it != 0);
assert(*it != nullptr);
(*it)->OnUpdate();
}
@ -917,7 +917,7 @@ AudioStatistics AudioEngine::Impl::GetStatistics() const
for (auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it)
{
assert(*it != 0);
assert(*it != nullptr);
(*it)->GatherStatistics(stats);
}
@ -931,13 +931,13 @@ void AudioEngine::Impl::TrimVoicePool()
{
for (auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it)
{
assert(*it != 0);
assert(*it != nullptr);
(*it)->OnTrim();
}
for (auto it = mVoicePool.begin(); it != mVoicePool.end(); ++it)
{
assert(it->second != 0);
assert(it->second != nullptr);
it->second->DestroyVoice();
}
mVoicePool.clear();
@ -998,7 +998,7 @@ void AudioEngine::Impl::AllocateVoice(const WAVEFORMATEX* wfx, SOUND_EFFECT_INST
if (it != mVoicePool.end())
{
// Found a matching (stopped) voice to reuse
assert(it->second != 0);
assert(it->second != nullptr);
*voice = it->second;
mVoicePool.erase(it);
@ -1072,7 +1072,7 @@ void AudioEngine::Impl::AllocateVoice(const WAVEFORMATEX* wfx, SOUND_EFFECT_INST
}
}
assert(*voice != 0);
assert(*voice != nullptr);
HRESULT hr = (*voice)->SetSourceSampleRate(wfx->nSamplesPerSec);
if (FAILED(hr))
{
@ -1141,7 +1141,7 @@ void AudioEngine::Impl::AllocateVoice(const WAVEFORMATEX* wfx, SOUND_EFFECT_INST
if (oneshot)
{
assert(*voice != 0);
assert(*voice != nullptr);
mOneShots.emplace_back(std::make_pair(voiceKey, *voice));
}
}
@ -1180,7 +1180,7 @@ void AudioEngine::Impl::DestroyVoice(_In_ IXAudio2SourceVoice* voice)
void AudioEngine::Impl::RegisterNotify(_In_ IVoiceNotify* notify, bool usesUpdate)
{
assert(notify != 0);
assert(notify != nullptr);
mNotifyObjects.insert(notify);
if (usesUpdate)
@ -1192,7 +1192,7 @@ void AudioEngine::Impl::RegisterNotify(_In_ IVoiceNotify* notify, bool usesUpdat
void AudioEngine::Impl::UnregisterNotify(_In_ IVoiceNotify* notify, bool usesOneShots, bool usesUpdate)
{
assert(notify != 0);
assert(notify != nullptr);
mNotifyObjects.erase(notify);
// Check for any pending one-shots for this notification object
@ -1202,7 +1202,7 @@ void AudioEngine::Impl::UnregisterNotify(_In_ IVoiceNotify* notify, bool usesOne
for (auto it = mOneShots.begin(); it != mOneShots.end(); ++it)
{
assert(it->second != 0);
assert(it->second != nullptr);
XAUDIO2_VOICE_STATE state;
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
@ -1452,7 +1452,7 @@ int AudioEngine::GetOutputChannels() const
bool AudioEngine::IsAudioDevicePresent() const
{
return (pImpl->xaudio2.Get() != 0) && !pImpl->mCriticalError;
return pImpl->xaudio2 && !pImpl->mCriticalError;
}

Просмотреть файл

@ -61,7 +61,7 @@ public:
CreateIntegerPCM(&mWaveFormat, sampleRate, channels, sampleBits);
assert(engine != 0);
assert(engine != nullptr);
engine->RegisterNotify(this, true);
mBase.Initialize(engine, &mWaveFormat, flags);
@ -69,7 +69,7 @@ public:
mBufferNeeded = bufferNeeded;
}
virtual ~Impl()
virtual ~Impl() override
{
mBase.DestroyVoice();

Просмотреть файл

@ -727,7 +727,7 @@ void SoundEffectInstanceBase::Apply3D(const AudioListener& listener, const Audio
assert(mDSPSettings.DstChannelCount <= 8);
mDSPSettings.pMatrixCoefficients = matrix;
assert(engine != 0);
assert(engine != nullptr);
if (rhcoords)
{
X3DAUDIO_EMITTER lhEmitter;
@ -756,7 +756,7 @@ void SoundEffectInstanceBase::Apply3D(const AudioListener& listener, const Audio
(void)voice->SetFrequencyRatio(mFreqRatio * mDSPSettings.DopplerFactor);
auto direct = mDirectVoice;
assert(direct != 0);
assert(direct != nullptr);
(void)voice->SetOutputMatrix(direct, mDSPSettings.SrcChannelCount, mDSPSettings.DstChannelCount, matrix);
if (reverb)

Просмотреть файл

@ -86,12 +86,12 @@ namespace DirectX
~SoundEffectInstanceBase()
{
assert(!voice);
assert(voice == nullptr);
}
void Initialize(_In_ AudioEngine* eng, _In_ const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags)
{
assert(eng != 0);
assert(eng != nullptr);
engine = eng;
mDirectVoice = eng->GetMasterVoice();
mReverbVoice = eng->GetReverbVoice();
@ -102,7 +102,7 @@ namespace DirectX
mFlags = static_cast<SOUND_EFFECT_INSTANCE_FLAGS>(static_cast<int>(flags) & ~SoundEffectInstance_UseRedirectLFE);
memset(&mDSPSettings, 0, sizeof(X3DAUDIO_DSP_SETTINGS));
assert(wfx != 0);
assert(wfx != nullptr);
mDSPSettings.SrcChannelCount = wfx->nChannels;
mDSPSettings.DstChannelCount = eng->GetOutputChannels();
}
@ -112,7 +112,7 @@ namespace DirectX
if (voice)
return;
assert(engine != 0);
assert(engine != nullptr);
engine->AllocateVoice(wfx, mFlags, false, &voice);
}
@ -120,7 +120,7 @@ namespace DirectX
{
if (voice)
{
assert(engine != 0);
assert(engine != nullptr);
engine->DestroyVoice(voice);
voice = nullptr;
}
@ -299,7 +299,7 @@ namespace DirectX
void OnReset()
{
assert(engine != 0);
assert(engine != nullptr);
mDirectVoice = engine->GetMasterVoice();
mReverbVoice = engine->GetReverbVoice();

Просмотреть файл

@ -45,11 +45,11 @@ public:
, mXMAMemory(nullptr)
#endif
{
assert(mEngine != 0);
assert(mEngine != nullptr);
mEngine->RegisterNotify(this, false);
}
virtual ~Impl()
virtual ~Impl() override
{
if (!mInstances.empty())
{
@ -57,7 +57,7 @@ public:
for (auto it = mInstances.begin(); it != mInstances.end(); ++it)
{
assert(*it != 0);
assert(*it != nullptr);
(*it)->OnDestroyParent();
}
@ -474,7 +474,7 @@ void SoundEffect::Play(float volume, float pitch, float pan)
std::unique_ptr<SoundEffectInstance> SoundEffect::CreateInstance(SOUND_EFFECT_INSTANCE_FLAGS flags)
{
auto effect = new SoundEffectInstance(pImpl->mEngine, this, flags);
assert(effect != 0);
assert(effect != nullptr);
pImpl->mInstances.emplace_back(effect);
return std::unique_ptr<SoundEffectInstance>(effect);
}

Просмотреть файл

@ -29,10 +29,10 @@ public:
mIndex(0),
mLooped(false)
{
assert(engine != 0);
assert(engine != nullptr);
engine->RegisterNotify(this, false);
assert(mEffect != 0);
assert(mEffect != nullptr);
mBase.Initialize(engine, effect->GetFormat(), flags);
}
@ -43,16 +43,16 @@ public:
mIndex(index),
mLooped(false)
{
assert(engine != 0);
assert(engine != nullptr);
engine->RegisterNotify(this, false);
char buff[64] = {};
auto wfx = reinterpret_cast<WAVEFORMATEX*>(buff);
assert(mWaveBank != 0);
assert(mWaveBank != nullptr);
mBase.Initialize(engine, mWaveBank->GetFormat(index, wfx, sizeof(buff)), flags);
}
virtual ~Impl()
virtual ~Impl() override
{
mBase.DestroyVoice();
@ -123,7 +123,7 @@ void SoundEffectInstance::Impl::Play(bool loop)
}
else
{
assert(mEffect != 0);
assert(mEffect != nullptr);
mBase.AllocateVoice(mEffect->GetFormat());
}
}
@ -144,7 +144,7 @@ void SoundEffectInstance::Impl::Play(bool loop)
}
else
{
assert(mEffect != 0);
assert(mEffect != nullptr);
iswma = mEffect->FillSubmitBuffer(buffer, wmaBuffer);
}

Просмотреть файл

@ -33,11 +33,11 @@ public:
mPrepared(false),
mStreaming(false)
{
assert(mEngine != 0);
assert(mEngine != nullptr);
mEngine->RegisterNotify(this, false);
}
virtual ~Impl()
virtual ~Impl() override
{
if (!mInstances.empty())
{
@ -45,7 +45,7 @@ public:
for (auto it = mInstances.begin(); it != mInstances.end(); ++it)
{
assert(*it != 0);
assert(*it != nullptr);
(*it)->OnDestroyParent();
}
@ -347,7 +347,7 @@ std::unique_ptr<SoundEffectInstance> WaveBank::CreateInstance(int index, SOUND_E
}
auto effect = new SoundEffectInstance(pImpl->mEngine, this, index, flags);
assert(effect != 0);
assert(effect != nullptr);
pImpl->mInstances.emplace_back(effect);
return std::unique_ptr<SoundEffectInstance>(effect);
}

Просмотреть файл

@ -201,7 +201,6 @@ namespace
uint32_t samplesPerAdpcmBlock = AdpcmSamplesPerBlock();
return blockAlign * nSamplesPerSec / samplesPerAdpcmBlock;
}
break;
case TAG_WMA:
{
@ -510,7 +509,7 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName)
}
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
CREATEFILE2_EXTENDED_PARAMETERS params = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0 };
CREATEFILE2_EXTENDED_PARAMETERS params = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0, 0, 0, {}, nullptr };
params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
params.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN;
ScopedHandle hFile(safe_handle(CreateFile2(szFileName,
@ -814,7 +813,7 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName)
hFile.reset();
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
CREATEFILE2_EXTENDED_PARAMETERS params2 = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0 };
CREATEFILE2_EXTENDED_PARAMETERS params2 = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0, 0, 0, {}, nullptr };
params2.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
params2.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING;
m_async = CreateFile2(szFileName,
@ -912,7 +911,7 @@ void WaveBankReader::Impl::Close()
{
if (m_async != INVALID_HANDLE_VALUE)
{
if (m_request.hEvent != 0)
if (m_request.hEvent)
{
DWORD bytes;
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
@ -1226,7 +1225,7 @@ bool WaveBankReader::Impl::UpdatePrepared()
if (m_async == INVALID_HANDLE_VALUE)
return false;
if (m_request.hEvent != 0)
if (m_request.hEvent)
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
@ -1294,7 +1293,7 @@ void WaveBankReader::WaitOnPrepare()
if (pImpl->m_prepared)
return;
if (pImpl->m_request.hEvent != 0)
if (pImpl->m_request.hEvent)
{
WaitForSingleObjectEx(pImpl->m_request.hEvent, INFINITE, FALSE);

Просмотреть файл

@ -71,19 +71,19 @@ namespace DirectX
D3D12_GPU_DESCRIPTOR_HANDLE GetFirstGpuHandle() const
{
assert(m_desc.Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE);
assert(m_pHeap != 0);
assert(m_pHeap != nullptr);
return m_hGPU;
}
D3D12_CPU_DESCRIPTOR_HANDLE GetFirstCpuHandle() const
{
assert(m_pHeap != 0);
assert(m_pHeap != nullptr);
return m_hCPU;
}
D3D12_GPU_DESCRIPTOR_HANDLE GetGpuHandle(_In_ size_t index) const
{
assert(m_pHeap != 0);
assert(m_pHeap != nullptr);
if (index >= m_desc.NumDescriptors)
{
throw std::out_of_range("D3DX12_GPU_DESCRIPTOR_HANDLE");
@ -94,7 +94,7 @@ namespace DirectX
D3D12_CPU_DESCRIPTOR_HANDLE GetCpuHandle(_In_ size_t index) const
{
assert(m_pHeap != 0);
assert(m_pHeap != nullptr);
if (index >= m_desc.NumDescriptors)
{
throw std::out_of_range("D3DX12_CPU_DESCRIPTOR_HANDLE");

Просмотреть файл

@ -160,8 +160,8 @@ namespace DirectX
D3D12_RESOURCE_STATES stateBefore,
D3D12_RESOURCE_STATES stateAfter)
{
assert(commandList != 0);
assert(resource != 0);
assert(commandList != nullptr);
assert(resource != nullptr);
if (stateBefore == stateAfter)
return;

Просмотреть файл

@ -167,7 +167,7 @@ namespace DirectX
BasicEffect(BasicEffect const&) = delete;
BasicEffect& operator= (BasicEffect const&) = delete;
virtual ~BasicEffect();
virtual ~BasicEffect() override;
// IEffect methods.
void __cdecl Apply(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -225,7 +225,7 @@ namespace DirectX
AlphaTestEffect(AlphaTestEffect const&) = delete;
AlphaTestEffect& operator= (AlphaTestEffect const&) = delete;
virtual ~AlphaTestEffect();
virtual ~AlphaTestEffect() override;
// IEffect methods.
void __cdecl Apply(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -271,7 +271,7 @@ namespace DirectX
DualTextureEffect(DualTextureEffect const&) = delete;
DualTextureEffect& operator= (DualTextureEffect const&) = delete;
~DualTextureEffect();
virtual ~DualTextureEffect() override;
// IEffect methods.
void __cdecl Apply(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -315,7 +315,7 @@ namespace DirectX
EnvironmentMapEffect(EnvironmentMapEffect const&) = delete;
EnvironmentMapEffect& operator= (EnvironmentMapEffect const&) = delete;
virtual ~EnvironmentMapEffect();
virtual ~EnvironmentMapEffect() override;
// IEffect methods.
void __cdecl Apply(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -377,7 +377,7 @@ namespace DirectX
SkinnedEffect(SkinnedEffect const&) = delete;
SkinnedEffect& operator= (SkinnedEffect const&) = delete;
virtual ~SkinnedEffect();
virtual ~SkinnedEffect() override;
// IEffect methods.
void __cdecl Apply(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -439,7 +439,7 @@ namespace DirectX
NormalMapEffect(NormalMapEffect const&) = delete;
NormalMapEffect& operator= (NormalMapEffect const&) = delete;
virtual ~NormalMapEffect();
virtual ~NormalMapEffect() override;
// IEffect methods.
void __cdecl Apply(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -499,7 +499,7 @@ namespace DirectX
PBREffect(PBREffect const&) = delete;
PBREffect& operator= (PBREffect const&) = delete;
virtual ~PBREffect();
virtual ~PBREffect() override;
// IEffect methods.
void __cdecl Apply(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -573,7 +573,7 @@ namespace DirectX
DebugEffect(DebugEffect const&) = delete;
DebugEffect& operator= (DebugEffect const&) = delete;
virtual ~DebugEffect();
virtual ~DebugEffect() override;
// IEffect methods.
void __cdecl Apply(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -637,7 +637,7 @@ namespace DirectX
EffectTextureFactory(EffectTextureFactory const&) = delete;
EffectTextureFactory& operator= (EffectTextureFactory const&) = delete;
virtual ~EffectTextureFactory();
virtual ~EffectTextureFactory() override;
virtual void __cdecl CreateTexture(_In_z_ const wchar_t* name, int descriptorIndex) override;
@ -753,7 +753,7 @@ namespace DirectX
EffectFactory(EffectFactory const&) = delete;
EffectFactory& operator= (EffectFactory const&) = delete;
virtual ~EffectFactory();
virtual ~EffectFactory() override;
// IEffectFactory methods.
virtual std::shared_ptr<IEffect> __cdecl CreateEffect(

Просмотреть файл

@ -81,7 +81,7 @@ namespace DirectX
// Draw the mesh with a range of effects that mesh parts will index into.
// Effects can be any IEffect pointer type (including smart pointer). Value or reference types will not compile.
// The iterator passed to this method should have random access capabilities for best performance.
template<typename TEffectIterator, typename TEffectIteratorCategory = TEffectIterator::iterator_category>
template<typename TEffectIterator, typename TEffectIteratorCategory = typename TEffectIterator::iterator_category>
static void DrawMeshParts(
_In_ ID3D12GraphicsCommandList* commandList,
_In_ const ModelMeshPart::Collection& meshParts,
@ -139,12 +139,12 @@ namespace DirectX
// Draw the mesh with a range of effects that mesh parts will index into.
// TEffectPtr can be any IEffect pointer type (including smart pointer). Value or reference types will not compile.
template<typename TEffectIterator, typename TEffectIteratorCategory = TEffectIterator::iterator_category>
template<typename TEffectIterator, typename TEffectIteratorCategory = typename TEffectIterator::iterator_category>
void DrawOpaque(_In_ ID3D12GraphicsCommandList* commandList, TEffectIterator effects) const
{
ModelMeshPart::DrawMeshParts<TEffectIterator, TEffectIteratorCategory>(commandList, opaqueMeshParts, effects);
}
template<typename TEffectIterator, typename TEffectIteratorCategory = TEffectIterator::iterator_category>
template<typename TEffectIterator, typename TEffectIteratorCategory = typename TEffectIterator::iterator_category>
void DrawAlpha(_In_ ID3D12GraphicsCommandList* commandList, TEffectIterator effects) const
{
ModelMeshPart::DrawMeshParts<TEffectIterator, TEffectIteratorCategory>(commandList, alphaMeshParts, effects);

Просмотреть файл

@ -68,7 +68,7 @@ namespace DirectX
BasicPostProcess(BasicPostProcess const&) = delete;
BasicPostProcess& operator= (BasicPostProcess const&) = delete;
virtual ~BasicPostProcess();
virtual ~BasicPostProcess() override;
// IPostProcess methods.
void __cdecl Process(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -112,7 +112,7 @@ namespace DirectX
DualPostProcess(DualPostProcess const&) = delete;
DualPostProcess& operator= (DualPostProcess const&) = delete;
virtual ~DualPostProcess();
virtual ~DualPostProcess() override;
// IPostProcess methods.
void __cdecl Process(_In_ ID3D12GraphicsCommandList* commandList) override;
@ -170,7 +170,7 @@ namespace DirectX
ToneMapPostProcess(ToneMapPostProcess const&) = delete;
ToneMapPostProcess& operator= (ToneMapPostProcess const&) = delete;
virtual ~ToneMapPostProcess();
virtual ~ToneMapPostProcess() override;
// IPostProcess methods.
void __cdecl Process(_In_ ID3D12GraphicsCommandList* commandList) override;

Просмотреть файл

@ -44,4 +44,4 @@ namespace DirectX
D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET,
_In_opt_ const GUID* targetFormat = nullptr,
_In_opt_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
}
}

Просмотреть файл

@ -183,7 +183,7 @@ AlphaTestEffect::Impl::Impl(_In_ ID3D12Device* device,
mRootSignature = GetRootSignature(0, rsigDesc);
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
fog.enabled = (effectFlags & EffectFlags::Fog) != 0;

Просмотреть файл

@ -379,7 +379,7 @@ BasicEffect::Impl::Impl(_In_ ID3D12Device* device, int effectFlags, const Effect
}
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
// Create pipeline state.
int sp = GetPipelineStatePermutation(

Просмотреть файл

@ -273,7 +273,7 @@ BasicPostProcess::Impl::Impl(_In_ ID3D12Device* device, const RenderTargetState&
}
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
// Create pipeline state.
EffectPipelineStateDescription psd(nullptr,

Просмотреть файл

@ -595,7 +595,7 @@ HRESULT DirectX::LoadDDSTextureFromMemoryEx(
return E_FAIL;
}
uint32_t dwMagicNumber = *(const uint32_t*)(ddsData);
const uint32_t dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData);
if (dwMagicNumber != DDS_MAGIC)
{
return E_FAIL;
@ -634,7 +634,7 @@ HRESULT DirectX::LoadDDSTextureFromMemoryEx(
texture, subresources, isCubeMap);
if (SUCCEEDED(hr))
{
if (texture != 0 && *texture != 0)
if (texture && *texture)
{
SetDebugObjectName(*texture, L"DDSTextureLoader");
}
@ -732,7 +732,7 @@ HRESULT DirectX::LoadDDSTextureFromFileEx(
(*texture)->SetName(fileName);
}
#else
if (texture != 0)
if (texture)
{
CHAR strFileA[MAX_PATH];
int result = WideCharToMultiByte(CP_ACP,
@ -756,7 +756,7 @@ HRESULT DirectX::LoadDDSTextureFromFileEx(
pstrName++;
}
if (texture != 0 && *texture != 0)
if (texture && *texture)
{
(*texture)->SetName(pstrName);
}

Просмотреть файл

@ -171,7 +171,7 @@ DebugEffect::Impl::Impl(_In_ ID3D12Device* device, int effectFlags, const Effect
static_assert(_countof(EffectBase<DebugEffectTraits>::PixelShaderBytecode) == DebugEffectTraits::PixelShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<DebugEffectTraits>::PixelShaderIndices) == DebugEffectTraits::ShaderPermutationCount, "array/max mismatch");
static const XMVECTORF32 s_lower = { 0.f, 0.f, 0.f, 1.f };
static const XMVECTORF32 s_lower = { { { 0.f, 0.f, 0.f, 1.f } } };
constants.ambientDownAndAlpha = s_lower;
constants.ambientRange = g_XMOne;
@ -196,7 +196,7 @@ DebugEffect::Impl::Impl(_In_ ID3D12Device* device, int effectFlags, const Effect
mRootSignature = GetRootSignature(0, rsigDesc);
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
// Create pipeline state.
int sp = GetPipelineStatePermutation(

Просмотреть файл

@ -142,7 +142,7 @@ void DescriptorHeap::Create(
ID3D12Device* pDevice,
const D3D12_DESCRIPTOR_HEAP_DESC* pDesc)
{
assert(pDesc != 0);
assert(pDesc != nullptr);
m_desc = *pDesc;
m_increment = pDevice->GetDescriptorHandleIncrementSize(pDesc->Type);

Просмотреть файл

@ -210,7 +210,7 @@ DualPostProcess::Impl::Impl(_In_ ID3D12Device* device, const RenderTargetState&
mRootSignature = mDeviceResources->GetRootSignature(rsigDesc);
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
// Create pipeline state.
EffectPipelineStateDescription psd(nullptr,

Просмотреть файл

@ -178,7 +178,7 @@ DualTextureEffect::Impl::Impl(_In_ ID3D12Device* device, int effectFlags, const
mRootSignature = GetRootSignature(0, rsigDesc);
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
// Validate flags & state.
fog.enabled = (effectFlags & EffectFlags::Fog) != 0;

Просмотреть файл

@ -273,7 +273,7 @@ EnvironmentMapEffect::Impl::Impl(
mRootSignature = GetRootSignature(0, rsigDesc);
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
fog.enabled = (effectFlags & EffectFlags::Fog) != 0;

Просмотреть файл

@ -31,11 +31,6 @@ namespace
static_assert((MinAllocSize & (MinAllocSize - 1)) == 0, "MinAllocSize size must be a power of 2");
static_assert(MinAllocSize >= (4 * 1024), "MinAllocSize size must be greater than 4K");
inline constexpr bool WordSize64()
{
return sizeof(size_t) == 8;
}
inline size_t NextPow2(size_t x)
{
x--;

Просмотреть файл

@ -105,9 +105,9 @@ LinearAllocatorPage* LinearAllocator::FindPageForAlloc(_In_ size_t size, _In_ si
{
#ifdef _DEBUG
if (size > m_increment)
throw std::out_of_range(__FUNCTION__ " size must be less or equal to the allocator's increment");
throw std::out_of_range("Size must be less or equal to the allocator's increment");
if (alignment > m_increment)
throw std::out_of_range(__FUNCTION__ " alignment must be less or equal to the allocator's increment");
throw std::out_of_range("Alignment must be less or equal to the allocator's increment");
if (size == 0)
throw std::exception("Cannot honor zero size allocation request.");
#endif

Просмотреть файл

@ -837,7 +837,7 @@ namespace DirectX
}
}
void clear() { m_handle = 0; }
void clear() { m_handle = nullptr; }
private:
HANDLE m_handle;
@ -860,7 +860,7 @@ namespace DirectX
}
}
void clear() { m_filename = 0; }
void clear() { m_filename = nullptr; }
private:
LPCWSTR m_filename;

Просмотреть файл

@ -73,7 +73,7 @@ void ModelMeshPart::DrawMeshParts(ID3D12GraphicsCommandList* commandList, const
for (auto it = meshParts.cbegin(); it != meshParts.cend(); ++it)
{
auto part = (*it).get();
assert(part != 0);
assert(part != nullptr);
part->Draw(commandList);
}
@ -89,7 +89,7 @@ void ModelMeshPart::DrawMeshParts(
for (auto it = meshParts.cbegin(); it != meshParts.cend(); ++it)
{
auto part = (*it).get();
assert(part != 0);
assert(part != nullptr);
callback(commandList, *part);
part->Draw(commandList);

Просмотреть файл

@ -119,7 +119,7 @@ namespace
else
m.alphaValue = 1.f;
if (mh.Power)
if (mh.Power > 0)
{
m.specularPower = mh.Power;
m.specularColor = XMFLOAT3(mh.Specular.x, mh.Specular.y, mh.Specular.z);

Просмотреть файл

@ -1,4 +1,4 @@
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
// File: Mouse.cpp
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@ -138,7 +138,7 @@ public:
SetEvent((mode == MODE_ABSOLUTE) ? mAbsoluteMode.get() : mRelativeMode.get());
assert(mWindow != 0);
assert(mWindow != nullptr);
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
@ -161,7 +161,7 @@ public:
if (mMode == MODE_RELATIVE)
return false;
CURSORINFO info = { sizeof(CURSORINFO) };
CURSORINFO info = { sizeof(CURSORINFO), 0, nullptr, {} };
if (!GetCursorInfo(&info))
{
throw std::exception("GetCursorInfo");
@ -175,7 +175,7 @@ public:
if (mMode == MODE_RELATIVE)
return;
CURSORINFO info = { sizeof(CURSORINFO) };
CURSORINFO info = { sizeof(CURSORINFO), 0, nullptr, {} };
if (!GetCursorInfo(&info))
{
throw std::exception("GetCursorInfo");
@ -193,7 +193,7 @@ public:
if (mWindow == window)
return;
assert(window != 0);
assert(window != nullptr);
RAWINPUTDEVICE Rid;
Rid.usUsagePage = 0x1 /* HID_USAGE_PAGE_GENERIC */;
@ -234,7 +234,7 @@ private:
void ClipToWindow()
{
assert(mWindow != 0);
assert(mWindow != nullptr);
RECT rect;
GetClientRect(mWindow, &rect);

Просмотреть файл

@ -252,7 +252,7 @@ NormalMapEffect::Impl::Impl(_In_ ID3D12Device* device, int effectFlags, const Ef
}
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
fog.enabled = (effectFlags & EffectFlags::Fog) != 0;

Просмотреть файл

@ -192,7 +192,7 @@ PBREffect::Impl::Impl(_In_ ID3D12Device* device,
static_assert(_countof(EffectBase<PBREffectTraits>::PixelShaderIndices) == PBREffectTraits::ShaderPermutationCount, "array/max mismatch");
// Lighting
static const XMVECTORF32 defaultLightDirection = { 0, -1, 0, 0 };
static const XMVECTORF32 defaultLightDirection = { { { 0, -1, 0, 0 } } };
for (int i = 0; i < MaxDirectionalLights; i++)
{
lightColor[i] = g_XMOne;
@ -244,12 +244,12 @@ PBREffect::Impl::Impl(_In_ ID3D12Device* device,
CD3DX12_DESCRIPTOR_RANGE(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 1, 1)
};
for (int i = 0; i < _countof(textureSRV); i++)
for (size_t i = 0; i < _countof(textureSRV); i++)
{
rootParameters[i].InitAsDescriptorTable(1, &textureSRV[i]);
}
for (int i = 0; i < _countof(textureSampler); i++)
for (size_t i = 0; i < _countof(textureSampler); i++)
{
rootParameters[i + SurfaceSampler].InitAsDescriptorTable(1, &textureSampler[i]);
}
@ -262,7 +262,7 @@ PBREffect::Impl::Impl(_In_ ID3D12Device* device,
mRootSignature = GetRootSignature(0, rsigDesc);
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
if (effectFlags & EffectFlags::Fog)
{

Просмотреть файл

@ -430,7 +430,7 @@ public:
mList.Reset();
mCmdAlloc.Reset();
return std::move(future);
return future;
}
private:
@ -819,6 +819,6 @@ void ResourceUploadBatch::Transition(
std::future<void> ResourceUploadBatch::End(_In_ ID3D12CommandQueue* commandQueue)
{
return std::move(pImpl->End(commandQueue));
return pImpl->End(commandQueue);
}

Просмотреть файл

@ -136,7 +136,7 @@ namespace
DXGI_FORMAT fmt = EnsureNotTypeless(desc.Format);
D3D12_FEATURE_DATA_FORMAT_SUPPORT formatInfo = { fmt };
D3D12_FEATURE_DATA_FORMAT_SUPPORT formatInfo = { fmt, D3D12_FORMAT_SUPPORT1_NONE, D3D12_FORMAT_SUPPORT2_NONE };
hr = device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &formatInfo, sizeof(formatInfo));
if (FAILED(hr))
return hr;

Просмотреть файл

@ -63,22 +63,22 @@ namespace DirectX
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
static_assert(sizeof(DirectX::SimpleMath::Viewport) == sizeof(D3D11_VIEWPORT), "Size mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, x) == FIELD_OFFSET(D3D11_VIEWPORT, TopLeftX), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, y) == FIELD_OFFSET(D3D11_VIEWPORT, TopLeftY), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, width) == FIELD_OFFSET(D3D11_VIEWPORT, Width), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, height) == FIELD_OFFSET(D3D11_VIEWPORT, Height), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, minDepth) == FIELD_OFFSET(D3D11_VIEWPORT, MinDepth), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, maxDepth) == FIELD_OFFSET(D3D11_VIEWPORT, MaxDepth), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, x) == offsetof(D3D11_VIEWPORT, TopLeftX), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, y) == offsetof(D3D11_VIEWPORT, TopLeftY), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, width) == offsetof(D3D11_VIEWPORT, Width), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, height) == offsetof(D3D11_VIEWPORT, Height), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, minDepth) == offsetof(D3D11_VIEWPORT, MinDepth), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, maxDepth) == offsetof(D3D11_VIEWPORT, MaxDepth), "Layout mismatch");
#endif
#if defined(__d3d12_h__) || defined(__d3d12_x_h__)
static_assert(sizeof(DirectX::SimpleMath::Viewport) == sizeof(D3D12_VIEWPORT), "Size mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, x) == FIELD_OFFSET(D3D12_VIEWPORT, TopLeftX), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, y) == FIELD_OFFSET(D3D12_VIEWPORT, TopLeftY), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, width) == FIELD_OFFSET(D3D12_VIEWPORT, Width), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, height) == FIELD_OFFSET(D3D12_VIEWPORT, Height), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, minDepth) == FIELD_OFFSET(D3D12_VIEWPORT, MinDepth), "Layout mismatch");
static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, maxDepth) == FIELD_OFFSET(D3D12_VIEWPORT, MaxDepth), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, x) == offsetof(D3D12_VIEWPORT, TopLeftX), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, y) == offsetof(D3D12_VIEWPORT, TopLeftY), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, width) == offsetof(D3D12_VIEWPORT, Width), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, height) == offsetof(D3D12_VIEWPORT, Height), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, minDepth) == offsetof(D3D12_VIEWPORT, MinDepth), "Layout mismatch");
static_assert(offsetof(DirectX::SimpleMath::Viewport, maxDepth) == offsetof(D3D12_VIEWPORT, MaxDepth), "Layout mismatch");
#endif
RECT DirectX::SimpleMath::Viewport::ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UINT backBufferHeight, int outputWidth, int outputHeight)

Просмотреть файл

@ -274,7 +274,7 @@ SkinnedEffect::Impl::Impl(_In_ ID3D12Device* device, int effectFlags, const Effe
mRootSignature = GetRootSignature(0, rsigDesc);
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
fog.enabled = (effectFlags & EffectFlags::Fog) != 0;

Просмотреть файл

@ -286,7 +286,7 @@ ToneMapPostProcess::Impl::Impl(_In_ ID3D12Device* device, const RenderTargetStat
mRootSignature = mDeviceResources->GetRootSignature(rsigDesc);
}
assert(mRootSignature != 0);
assert(mRootSignature != nullptr);
// Determine shader permutation.
#if defined(_XBOX_ONE) && defined(_TITLE)

Просмотреть файл

@ -159,4 +159,4 @@ const D3D12_INPUT_LAYOUT_DESC VertexPositionNormalColorTexture::InputLayout =
//--------------------------------------------------------------------------------------
// VertexPositionNormalTangentColorTexture, VertexPositionNormalTangentColorTextureSkinning are not
// supported for DirectX 12 since they were only present for DGSL
// supported for DirectX 12 since they were only present for DGSL

Просмотреть файл

@ -745,7 +745,7 @@ HRESULT DirectX::LoadWICTextureFromFileEx(
pstrName++;
}
if (texture != 0 && *texture != 0)
if (texture && *texture)
{
(*texture)->SetName(pstrName);
}
@ -798,4 +798,4 @@ HRESULT DirectX::CreateWICTextureFromFileEx(
}
return hr;
}
}

Просмотреть файл

@ -115,6 +115,7 @@
#pragma warning(pop)
#include <malloc.h>
#include <stddef.h>
#include <stdint.h>
#pragma warning(push)