Updated DirectX Tool Kit and DirectXTex for April 2018 releases

This commit is contained in:
Chuck Walbourn 2018-04-24 17:15:30 -07:00
Родитель 99cb0aa9fa
Коммит 722d907d93
697 изменённых файлов: 24533 добавлений и 27291 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: DynamicSoundEffectInstance.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "pch.h"
@ -25,49 +22,49 @@ using namespace DirectX;
class DynamicSoundEffectInstance::Impl : public IVoiceNotify
{
public:
Impl( _In_ AudioEngine* engine,
_In_ DynamicSoundEffectInstance* object, std::function<void(DynamicSoundEffectInstance*)>& bufferNeeded,
int sampleRate, int channels, int sampleBits, SOUND_EFFECT_INSTANCE_FLAGS flags ) :
Impl(_In_ AudioEngine* engine,
_In_ DynamicSoundEffectInstance* object, std::function<void(DynamicSoundEffectInstance*)>& bufferNeeded,
int sampleRate, int channels, int sampleBits, SOUND_EFFECT_INSTANCE_FLAGS flags) :
mBase(),
mBufferNeeded( nullptr ),
mObject( object )
mBufferNeeded(nullptr),
mObject(object)
{
if ( ( sampleRate < XAUDIO2_MIN_SAMPLE_RATE )
|| ( sampleRate > XAUDIO2_MAX_SAMPLE_RATE ) )
if ((sampleRate < XAUDIO2_MIN_SAMPLE_RATE)
|| (sampleRate > XAUDIO2_MAX_SAMPLE_RATE))
{
DebugTrace( "DynamicSoundEffectInstance sampleRate must be in range %u...%u\n", XAUDIO2_MIN_SAMPLE_RATE, XAUDIO2_MAX_SAMPLE_RATE );
throw std::invalid_argument( "DynamicSoundEffectInstance" );
DebugTrace("DynamicSoundEffectInstance sampleRate must be in range %u...%u\n", XAUDIO2_MIN_SAMPLE_RATE, XAUDIO2_MAX_SAMPLE_RATE);
throw std::invalid_argument("DynamicSoundEffectInstance");
}
if ( !channels || ( channels > 8 ) )
if (!channels || (channels > 8))
{
DebugTrace( "DynamicSoundEffectInstance channels must be in range 1...8\n" );
throw std::invalid_argument( "DynamicSoundEffectInstance" );
DebugTrace("DynamicSoundEffectInstance channels must be in range 1...8\n");
throw std::invalid_argument("DynamicSoundEffectInstance");
}
switch ( sampleBits )
switch (sampleBits)
{
case 8:
case 16:
break;
case 8:
case 16:
break;
default:
DebugTrace( "DynamicSoundEffectInstance sampleBits must be 8-bit or 16-bit\n" );
throw std::invalid_argument( "DynamicSoundEffectInstance" );
default:
DebugTrace("DynamicSoundEffectInstance sampleBits must be 8-bit or 16-bit\n");
throw std::invalid_argument("DynamicSoundEffectInstance");
}
mBufferEvent.reset( CreateEventEx( nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE ) );
if ( !mBufferEvent )
mBufferEvent.reset(CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE));
if (!mBufferEvent)
{
throw std::exception( "CreateEvent" );
throw std::exception("CreateEvent");
}
CreateIntegerPCM( &mWaveFormat, sampleRate, channels, sampleBits );
CreateIntegerPCM(&mWaveFormat, sampleRate, channels, sampleBits);
assert( engine != 0 );
engine->RegisterNotify( this, true );
assert(engine != 0);
engine->RegisterNotify(this, true);
mBase.Initialize( engine, &mWaveFormat, flags );
mBase.Initialize(engine, &mWaveFormat, flags);
mBufferNeeded = bufferNeeded;
}
@ -76,9 +73,9 @@ public:
{
mBase.DestroyVoice();
if ( mBase.engine )
if (mBase.engine)
{
mBase.engine->UnregisterNotify( this, false, true );
mBase.engine->UnregisterNotify(this, false, true);
mBase.engine = nullptr;
}
}
@ -87,14 +84,14 @@ public:
void Resume();
void SubmitBuffer( _In_reads_bytes_(audioBytes) const uint8_t* pAudioData, uint32_t offset, size_t audioBytes );
void SubmitBuffer(_In_reads_bytes_(audioBytes) const uint8_t* pAudioData, uint32_t offset, size_t audioBytes);
const WAVEFORMATEX* GetFormat() const { return &mWaveFormat; } ;
const WAVEFORMATEX* GetFormat() const { return &mWaveFormat; };
// IVoiceNotify
virtual void __cdecl OnBufferEnd() override
{
SetEvent( mBufferEvent.get() );
SetEvent(mBufferEvent.get());
}
virtual void __cdecl OnCriticalError() override
@ -119,7 +116,7 @@ public:
mBase.OnTrim();
}
virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const override
virtual void __cdecl GatherStatistics(AudioStatistics& stats) const override
{
mBase.GatherStatistics(stats);
}
@ -136,88 +133,88 @@ private:
void DynamicSoundEffectInstance::Impl::Play()
{
if ( !mBase.voice )
if (!mBase.voice)
{
mBase.AllocateVoice( &mWaveFormat );
mBase.AllocateVoice(&mWaveFormat);
}
(void)mBase.Play();
if ( mBase.voice && ( mBase.state == PLAYING ) && ( mBase.GetPendingBufferCount() <= 2 ) )
if (mBase.voice && (mBase.state == PLAYING) && (mBase.GetPendingBufferCount() <= 2))
{
SetEvent( mBufferEvent.get() );
SetEvent(mBufferEvent.get());
}
}
void DynamicSoundEffectInstance::Impl::Resume()
{
if ( mBase.voice && ( mBase.state == PAUSED ) )
if (mBase.voice && (mBase.state == PAUSED))
{
mBase.Resume();
if ( ( mBase.state == PLAYING ) && ( mBase.GetPendingBufferCount() <= 2 ) )
if ((mBase.state == PLAYING) && (mBase.GetPendingBufferCount() <= 2))
{
SetEvent( mBufferEvent.get() );
SetEvent(mBufferEvent.get());
}
}
}
_Use_decl_annotations_
void DynamicSoundEffectInstance::Impl::SubmitBuffer( const uint8_t* pAudioData, uint32_t offset, size_t audioBytes )
void DynamicSoundEffectInstance::Impl::SubmitBuffer(const uint8_t* pAudioData, uint32_t offset, size_t audioBytes)
{
if ( !pAudioData || !audioBytes )
throw std::exception( "Invalid audio data buffer" );
if (!pAudioData || !audioBytes)
throw std::exception("Invalid audio data buffer");
if ( audioBytes > UINT32_MAX )
throw std::out_of_range( "SubmitBuffer" );
if (audioBytes > UINT32_MAX)
throw std::out_of_range("SubmitBuffer");
XAUDIO2_BUFFER buffer = {};
buffer.AudioBytes = static_cast<UINT32>( audioBytes );
buffer.AudioBytes = static_cast<UINT32>(audioBytes);
buffer.pAudioData = pAudioData;
if( offset )
if (offset)
{
assert( mWaveFormat.wFormatTag == WAVE_FORMAT_PCM );
assert(mWaveFormat.wFormatTag == WAVE_FORMAT_PCM);
buffer.PlayBegin = offset / mWaveFormat.nBlockAlign;
buffer.PlayLength = static_cast<UINT32>( ( audioBytes - offset ) / mWaveFormat.nBlockAlign );
buffer.PlayLength = static_cast<UINT32>((audioBytes - offset) / mWaveFormat.nBlockAlign);
}
buffer.pContext = this;
HRESULT hr = mBase.voice->SubmitSourceBuffer( &buffer, nullptr );
if ( FAILED(hr) )
HRESULT hr = mBase.voice->SubmitSourceBuffer(&buffer, nullptr);
if (FAILED(hr))
{
#ifdef _DEBUG
DebugTrace( "ERROR: DynamicSoundEffectInstance failed (%08X) when submitting buffer:\n", hr );
#ifdef _DEBUG
DebugTrace("ERROR: DynamicSoundEffectInstance failed (%08X) when submitting buffer:\n", hr);
DebugTrace( "\tFormat Tag %u, %u channels, %u-bit, %u Hz, %Iu bytes [%u offset)\n", mWaveFormat.wFormatTag,
mWaveFormat.nChannels, mWaveFormat.wBitsPerSample, mWaveFormat.nSamplesPerSec, audioBytes, offset );
#endif
throw std::exception( "SubmitSourceBuffer" );
DebugTrace("\tFormat Tag %u, %u channels, %u-bit, %u Hz, %Iu bytes [%u offset)\n", mWaveFormat.wFormatTag,
mWaveFormat.nChannels, mWaveFormat.wBitsPerSample, mWaveFormat.nSamplesPerSec, audioBytes, offset);
#endif
throw std::exception("SubmitSourceBuffer");
}
}
void DynamicSoundEffectInstance::Impl::OnUpdate()
{
DWORD result = WaitForSingleObjectEx( mBufferEvent.get(), 0, FALSE );
switch( result )
DWORD result = WaitForSingleObjectEx(mBufferEvent.get(), 0, FALSE);
switch (result)
{
case WAIT_TIMEOUT:
break;
case WAIT_TIMEOUT:
break;
case WAIT_OBJECT_0:
if( mBufferNeeded )
{
// This callback happens on the same thread that called AudioEngine::Update()
mBufferNeeded( mObject );
}
break;
case WAIT_FAILED:
throw std::exception( "WaitForSingleObjectEx" );
case WAIT_OBJECT_0:
if (mBufferNeeded)
{
// This callback happens on the same thread that called AudioEngine::Update()
mBufferNeeded(mObject);
}
break;
case WAIT_FAILED:
throw std::exception("WaitForSingleObjectEx");
}
}
@ -231,23 +228,23 @@ void DynamicSoundEffectInstance::Impl::OnUpdate()
// Public constructors
_Use_decl_annotations_
DynamicSoundEffectInstance::DynamicSoundEffectInstance( AudioEngine* engine,
std::function<void(DynamicSoundEffectInstance*)> bufferNeeded,
int sampleRate, int channels, int sampleBits, SOUND_EFFECT_INSTANCE_FLAGS flags ) :
pImpl( new Impl( engine, this, bufferNeeded, sampleRate, channels, sampleBits, flags ) )
DynamicSoundEffectInstance::DynamicSoundEffectInstance(AudioEngine* engine,
std::function<void(DynamicSoundEffectInstance*)> bufferNeeded,
int sampleRate, int channels, int sampleBits, SOUND_EFFECT_INSTANCE_FLAGS flags) :
pImpl(std::make_unique<Impl>(engine, this, bufferNeeded, sampleRate, channels, sampleBits, flags))
{
}
// Move constructor.
DynamicSoundEffectInstance::DynamicSoundEffectInstance(DynamicSoundEffectInstance&& moveFrom)
: pImpl(std::move(moveFrom.pImpl))
DynamicSoundEffectInstance::DynamicSoundEffectInstance(DynamicSoundEffectInstance&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
DynamicSoundEffectInstance& DynamicSoundEffectInstance::operator= (DynamicSoundEffectInstance&& moveFrom)
DynamicSoundEffectInstance& DynamicSoundEffectInstance::operator= (DynamicSoundEffectInstance&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;
@ -267,10 +264,10 @@ void DynamicSoundEffectInstance::Play()
}
void DynamicSoundEffectInstance::Stop( bool immediate )
void DynamicSoundEffectInstance::Stop(bool immediate)
{
bool looped = false;
pImpl->mBase.Stop( immediate, looped );
pImpl->mBase.Stop(immediate, looped);
}
@ -286,79 +283,79 @@ void DynamicSoundEffectInstance::Resume()
}
void DynamicSoundEffectInstance::SetVolume( float volume )
void DynamicSoundEffectInstance::SetVolume(float volume)
{
pImpl->mBase.SetVolume( volume );
pImpl->mBase.SetVolume(volume);
}
void DynamicSoundEffectInstance::SetPitch( float pitch )
void DynamicSoundEffectInstance::SetPitch(float pitch)
{
pImpl->mBase.SetPitch( pitch );
pImpl->mBase.SetPitch(pitch);
}
void DynamicSoundEffectInstance::SetPan( float pan )
void DynamicSoundEffectInstance::SetPan(float pan)
{
pImpl->mBase.SetPan( pan );
pImpl->mBase.SetPan(pan);
}
void DynamicSoundEffectInstance::Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords )
void DynamicSoundEffectInstance::Apply3D(const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords)
{
pImpl->mBase.Apply3D( listener, emitter, rhcoords );
pImpl->mBase.Apply3D(listener, emitter, rhcoords);
}
_Use_decl_annotations_
void DynamicSoundEffectInstance::SubmitBuffer( const uint8_t* pAudioData, size_t audioBytes )
void DynamicSoundEffectInstance::SubmitBuffer(const uint8_t* pAudioData, size_t audioBytes)
{
pImpl->SubmitBuffer( pAudioData, 0, audioBytes );
pImpl->SubmitBuffer(pAudioData, 0, audioBytes);
}
_Use_decl_annotations_
void DynamicSoundEffectInstance::SubmitBuffer( const uint8_t* pAudioData, uint32_t offset, size_t audioBytes )
void DynamicSoundEffectInstance::SubmitBuffer(const uint8_t* pAudioData, uint32_t offset, size_t audioBytes)
{
pImpl->SubmitBuffer( pAudioData, offset, audioBytes );
pImpl->SubmitBuffer(pAudioData, offset, audioBytes);
}
// Public accessors.
SoundState DynamicSoundEffectInstance::GetState()
{
return pImpl->mBase.GetState( false );
return pImpl->mBase.GetState(false);
}
size_t DynamicSoundEffectInstance::GetSampleDuration( size_t bytes ) const
size_t DynamicSoundEffectInstance::GetSampleDuration(size_t bytes) const
{
auto wfx = pImpl->GetFormat();
if ( !wfx || !wfx->wBitsPerSample || !wfx->nChannels )
if (!wfx || !wfx->wBitsPerSample || !wfx->nChannels)
return 0;
return static_cast<size_t>( ( uint64_t( bytes ) * 8 )
/ uint64_t( wfx->wBitsPerSample * wfx->nChannels ) );
return static_cast<size_t>((uint64_t(bytes) * 8)
/ (uint64_t(wfx->wBitsPerSample) * uint64_t(wfx->nChannels)));
}
size_t DynamicSoundEffectInstance::GetSampleDurationMS( size_t bytes ) const
size_t DynamicSoundEffectInstance::GetSampleDurationMS(size_t bytes) const
{
auto wfx = pImpl->GetFormat();
if ( !wfx || !wfx->nAvgBytesPerSec )
if (!wfx || !wfx->nAvgBytesPerSec)
return 0;
return static_cast<size_t>( ( uint64_t(bytes) * 1000 ) / wfx->nAvgBytesPerSec );
return static_cast<size_t>((uint64_t(bytes) * 1000) / wfx->nAvgBytesPerSec);
}
size_t DynamicSoundEffectInstance::GetSampleSizeInBytes( uint64_t duration ) const
size_t DynamicSoundEffectInstance::GetSampleSizeInBytes(uint64_t duration) const
{
auto wfx = pImpl->GetFormat();
if ( !wfx || !wfx->nSamplesPerSec )
if (!wfx || !wfx->nSamplesPerSec)
return 0;
return static_cast<size_t>( ( ( duration * wfx->nSamplesPerSec ) / 1000 ) * wfx->nBlockAlign );
return static_cast<size_t>(((duration * wfx->nSamplesPerSec) / 1000) * wfx->nBlockAlign);
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: SoundCommon.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
@ -20,19 +17,19 @@
namespace DirectX
{
// Helper for getting a format tag from a WAVEFORMATEX
inline uint32_t GetFormatTag( const WAVEFORMATEX* wfx )
inline uint32_t GetFormatTag(const WAVEFORMATEX* wfx)
{
if ( wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE )
if (wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{
if ( wfx->cbSize < ( sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) ) )
if (wfx->cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)))
return 0;
static const GUID s_wfexBase = {0x00000000, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71};
static const GUID s_wfexBase = { 0x00000000, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 };
auto wfex = reinterpret_cast<const WAVEFORMATEXTENSIBLE*>( wfx );
auto wfex = reinterpret_cast<const WAVEFORMATEXTENSIBLE*>(wfx);
if ( memcmp( reinterpret_cast<const BYTE*>(&wfex->SubFormat) + sizeof(DWORD),
reinterpret_cast<const BYTE*>(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD) ) != 0 )
if (memcmp(reinterpret_cast<const BYTE*>(&wfex->SubFormat) + sizeof(DWORD),
reinterpret_cast<const BYTE*>(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD)) != 0)
{
return 0;
}
@ -47,121 +44,121 @@ namespace DirectX
// Helper for validating wave format structure
bool IsValid( _In_ const WAVEFORMATEX* wfx );
bool IsValid(_In_ const WAVEFORMATEX* wfx);
// Helper for getting a default channel mask from channels
uint32_t GetDefaultChannelMask( int channels );
uint32_t GetDefaultChannelMask(int channels);
// Helpers for creating various wave format structures
void CreateIntegerPCM( _Out_ WAVEFORMATEX* wfx, int sampleRate, int channels, int sampleBits );
void CreateFloatPCM( _Out_ WAVEFORMATEX* wfx, int sampleRate, int channels );
void CreateADPCM( _Out_writes_bytes_(wfxSize) WAVEFORMATEX* wfx, size_t wfxSize, int sampleRate, int channels, int samplesPerBlock );
void CreateIntegerPCM(_Out_ WAVEFORMATEX* wfx, int sampleRate, int channels, int sampleBits);
void CreateFloatPCM(_Out_ WAVEFORMATEX* wfx, int sampleRate, int channels);
void CreateADPCM(_Out_writes_bytes_(wfxSize) WAVEFORMATEX* wfx, size_t wfxSize, int sampleRate, int channels, int samplesPerBlock);
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
void CreateXWMA( _Out_ WAVEFORMATEX* wfx, int sampleRate, int channels, int blockAlign, int avgBytes, bool wma3 );
void CreateXWMA(_Out_ WAVEFORMATEX* wfx, int sampleRate, int channels, int blockAlign, int avgBytes, bool wma3);
#endif
#if defined(_XBOX_ONE) && defined(_TITLE)
void CreateXMA2( _Out_writes_bytes_(wfxSize) WAVEFORMATEX* wfx, size_t wfxSize, int sampleRate, int channels, int bytesPerBlock, int blockCount, int samplesEncoded );
void CreateXMA2(_Out_writes_bytes_(wfxSize) WAVEFORMATEX* wfx, size_t wfxSize, int sampleRate, int channels, int bytesPerBlock, int blockCount, int samplesEncoded);
#endif
// Helper for computing pan volume matrix
bool ComputePan( float pan, int channels, _Out_writes_(16) float* matrix );
bool ComputePan(float pan, int channels, _Out_writes_(16) float* matrix);
// Helper class for implementing SoundEffectInstance
class SoundEffectInstanceBase
{
public:
SoundEffectInstanceBase() :
voice( nullptr ),
state( STOPPED ),
engine( nullptr ),
mVolume( 1.f ),
mPitch( 0.f ),
mFreqRatio( 1.f ),
mPan( 0.f ),
mFlags( SoundEffectInstance_Default ),
mDirectVoice( nullptr ),
mReverbVoice( nullptr ),
SoundEffectInstanceBase() throw() :
voice(nullptr),
state(STOPPED),
engine(nullptr),
mVolume(1.f),
mPitch(0.f),
mFreqRatio(1.f),
mPan(0.f),
mFlags(SoundEffectInstance_Default),
mDirectVoice(nullptr),
mReverbVoice(nullptr),
mDSPSettings{}
{
}
~SoundEffectInstanceBase()
{
assert( !voice );
assert(!voice);
}
void Initialize( _In_ AudioEngine* eng, _In_ const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags )
void Initialize(_In_ AudioEngine* eng, _In_ const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags)
{
assert( eng != 0 );
assert(eng != 0);
engine = eng;
mDirectVoice = eng->GetMasterVoice();
mReverbVoice = eng->GetReverbVoice();
if ( eng->GetChannelMask() & SPEAKER_LOW_FREQUENCY )
if (eng->GetChannelMask() & SPEAKER_LOW_FREQUENCY)
mFlags = flags | SoundEffectInstance_UseRedirectLFE;
else
mFlags = static_cast<SOUND_EFFECT_INSTANCE_FLAGS>( static_cast<int>(flags) & ~SoundEffectInstance_UseRedirectLFE );
mFlags = static_cast<SOUND_EFFECT_INSTANCE_FLAGS>(static_cast<int>(flags) & ~SoundEffectInstance_UseRedirectLFE);
memset( &mDSPSettings, 0, sizeof(X3DAUDIO_DSP_SETTINGS) );
assert( wfx != 0 );
memset(&mDSPSettings, 0, sizeof(X3DAUDIO_DSP_SETTINGS));
assert(wfx != 0);
mDSPSettings.SrcChannelCount = wfx->nChannels;
mDSPSettings.DstChannelCount = eng->GetOutputChannels();
}
void AllocateVoice( _In_ const WAVEFORMATEX* wfx )
void AllocateVoice(_In_ const WAVEFORMATEX* wfx)
{
if ( voice )
if (voice)
return;
assert( engine != 0 );
engine->AllocateVoice( wfx, mFlags, false, &voice );
assert(engine != 0);
engine->AllocateVoice(wfx, mFlags, false, &voice);
}
void DestroyVoice()
{
if ( voice )
if (voice)
{
assert( engine != 0 );
engine->DestroyVoice( voice );
assert(engine != 0);
engine->DestroyVoice(voice);
voice = nullptr;
}
}
bool Play() // Returns true if STOPPED -> PLAYING
{
if ( voice )
if (voice)
{
if ( state == PAUSED )
if (state == PAUSED)
{
HRESULT hr = voice->Start( 0 );
ThrowIfFailed( hr );
HRESULT hr = voice->Start(0);
ThrowIfFailed(hr);
state = PLAYING;
}
else if ( state != PLAYING )
else if (state != PLAYING)
{
if ( mVolume != 1.f )
if (mVolume != 1.f)
{
HRESULT hr = voice->SetVolume( mVolume );
ThrowIfFailed( hr );
HRESULT hr = voice->SetVolume(mVolume);
ThrowIfFailed(hr);
}
if ( mPitch != 0.f )
if (mPitch != 0.f)
{
mFreqRatio = XAudio2SemitonesToFrequencyRatio( mPitch * 12.f );
mFreqRatio = XAudio2SemitonesToFrequencyRatio(mPitch * 12.f);
HRESULT hr = voice->SetFrequencyRatio( mFreqRatio );
ThrowIfFailed( hr );
HRESULT hr = voice->SetFrequencyRatio(mFreqRatio);
ThrowIfFailed(hr);
}
if ( mPan != 0.f )
if (mPan != 0.f)
{
SetPan( mPan );
SetPan(mPan);
}
HRESULT hr = voice->Start( 0 );
ThrowIfFailed( hr );
HRESULT hr = voice->Start(0);
ThrowIfFailed(hr);
state = PLAYING;
return true;
}
@ -169,101 +166,101 @@ namespace DirectX
return false;
}
void Stop( bool immediate, bool& looped )
void Stop(bool immediate, bool& looped)
{
if ( !voice )
if (!voice)
{
state = STOPPED;
return;
}
if ( immediate )
if (immediate)
{
state = STOPPED;
(void)voice->Stop( 0 );
(void)voice->Stop(0);
(void)voice->FlushSourceBuffers();
}
else if ( looped )
else if (looped)
{
looped = false;
(void)voice->ExitLoop();
}
else
{
(void)voice->Stop( XAUDIO2_PLAY_TAILS );
(void)voice->Stop(XAUDIO2_PLAY_TAILS);
}
}
void Pause()
{
if ( voice && state == PLAYING )
if (voice && state == PLAYING)
{
state = PAUSED;
(void)voice->Stop( 0 );
(void)voice->Stop(0);
}
}
void Resume()
{
if ( voice && state == PAUSED )
if (voice && state == PAUSED)
{
HRESULT hr = voice->Start( 0 );
ThrowIfFailed( hr );
HRESULT hr = voice->Start(0);
ThrowIfFailed(hr);
state = PLAYING;
}
}
void SetVolume( float volume )
void SetVolume(float volume)
{
assert( volume >= -XAUDIO2_MAX_VOLUME_LEVEL && volume <= XAUDIO2_MAX_VOLUME_LEVEL );
assert(volume >= -XAUDIO2_MAX_VOLUME_LEVEL && volume <= XAUDIO2_MAX_VOLUME_LEVEL);
mVolume = volume;
if ( voice )
if (voice)
{
HRESULT hr = voice->SetVolume( volume );
ThrowIfFailed( hr );
HRESULT hr = voice->SetVolume(volume);
ThrowIfFailed(hr);
}
}
void SetPitch( float pitch )
void SetPitch(float pitch)
{
assert( pitch >= -1.f && pitch <= 1.f );
assert(pitch >= -1.f && pitch <= 1.f);
if ( ( mFlags & SoundEffectInstance_NoSetPitch ) && pitch != 0.f )
if ((mFlags & SoundEffectInstance_NoSetPitch) && pitch != 0.f)
{
DebugTrace( "ERROR: Sound effect instance was created with the NoSetPitch flag\n" );
throw std::exception( "SetPitch" );
DebugTrace("ERROR: Sound effect instance was created with the NoSetPitch flag\n");
throw std::exception("SetPitch");
}
mPitch = pitch;
if ( voice )
if (voice)
{
mFreqRatio = XAudio2SemitonesToFrequencyRatio( mPitch * 12.f );
mFreqRatio = XAudio2SemitonesToFrequencyRatio(mPitch * 12.f);
HRESULT hr = voice->SetFrequencyRatio( mFreqRatio );
ThrowIfFailed( hr );
HRESULT hr = voice->SetFrequencyRatio(mFreqRatio);
ThrowIfFailed(hr);
}
}
void SetPan( float pan );
void SetPan(float pan);
void Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords );
void Apply3D(const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords);
SoundState GetState( bool autostop )
SoundState GetState(bool autostop)
{
if ( autostop && voice && ( state == PLAYING ) )
if (autostop && voice && (state == PLAYING))
{
XAUDIO2_VOICE_STATE xstate;
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
voice->GetState( &xstate, XAUDIO2_VOICE_NOSAMPLESPLAYED );
#else
voice->GetState( &xstate );
#endif
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
voice->GetState(&xstate, XAUDIO2_VOICE_NOSAMPLESPLAYED);
#else
voice->GetState(&xstate);
#endif
if ( !xstate.BuffersQueued )
if (!xstate.BuffersQueued)
{
// Automatic stop if the buffer has finished playing
(void)voice->Stop();
@ -276,21 +273,21 @@ namespace DirectX
int GetPendingBufferCount() const
{
if ( !voice )
if (!voice)
return 0;
XAUDIO2_VOICE_STATE xstate;
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
voice->GetState( &xstate, XAUDIO2_VOICE_NOSAMPLESPLAYED );
#else
voice->GetState( &xstate );
#endif
return static_cast<int>( xstate.BuffersQueued );
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
voice->GetState(&xstate, XAUDIO2_VOICE_NOSAMPLESPLAYED);
#else
voice->GetState(&xstate);
#endif
return static_cast<int>(xstate.BuffersQueued);
}
void OnCriticalError()
{
if ( voice )
if (voice)
{
voice->DestroyVoice();
voice = nullptr;
@ -302,23 +299,23 @@ namespace DirectX
void OnReset()
{
assert( engine != 0 );
assert(engine != 0);
mDirectVoice = engine->GetMasterVoice();
mReverbVoice = engine->GetReverbVoice();
if ( engine->GetChannelMask() & SPEAKER_LOW_FREQUENCY )
if (engine->GetChannelMask() & SPEAKER_LOW_FREQUENCY)
mFlags = mFlags | SoundEffectInstance_UseRedirectLFE;
else
mFlags = static_cast<SOUND_EFFECT_INSTANCE_FLAGS>( static_cast<int>(mFlags) & ~SoundEffectInstance_UseRedirectLFE );
mFlags = static_cast<SOUND_EFFECT_INSTANCE_FLAGS>(static_cast<int>(mFlags) & ~SoundEffectInstance_UseRedirectLFE);
mDSPSettings.DstChannelCount = engine->GetOutputChannels();
}
void OnDestroy()
{
if ( voice )
if (voice)
{
(void)voice->Stop( 0 );
(void)voice->Stop(0);
(void)voice->FlushSourceBuffers();
voice->DestroyVoice();
voice = nullptr;
@ -331,24 +328,24 @@ namespace DirectX
void OnTrim()
{
if ( voice && ( state == STOPPED ) )
if (voice && (state == STOPPED))
{
engine->DestroyVoice( voice );
engine->DestroyVoice(voice);
voice = nullptr;
}
}
void GatherStatistics( AudioStatistics& stats ) const
void GatherStatistics(AudioStatistics& stats) const
{
++stats.allocatedInstances;
if ( voice )
if (voice)
{
++stats.allocatedVoices;
if ( mFlags & SoundEffectInstance_Use3D )
if (mFlags & SoundEffectInstance_Use3D)
++stats.allocatedVoices3d;
if ( state == PLAYING )
if (state == PLAYING)
++stats.playingInstances;
}
}
@ -366,5 +363,5 @@ namespace DirectX
IXAudio2Voice* mDirectVoice;
IXAudio2Voice* mReverbVoice;
X3DAUDIO_DSP_SETTINGS mDSPSettings;
};
};
}

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: SoundEffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "pch.h"
@ -32,74 +29,74 @@ using namespace DirectX;
class SoundEffect::Impl : public IVoiceNotify
{
public:
explicit Impl( _In_ AudioEngine* engine ) :
mWaveFormat( nullptr ),
mStartAudio( nullptr ),
mAudioBytes( 0 ),
mLoopStart( 0 ),
mLoopLength( 0 ),
mEngine( engine ),
mOneShots( 0 )
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
, mSeekCount( 0 )
, mSeekTable( nullptr )
#endif
#if defined(_XBOX_ONE) && defined(_TITLE)
, mXMAMemory( nullptr )
#endif
explicit Impl(_In_ AudioEngine* engine) :
mWaveFormat(nullptr),
mStartAudio(nullptr),
mAudioBytes(0),
mLoopStart(0),
mLoopLength(0),
mEngine(engine),
mOneShots(0)
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
, mSeekCount(0)
, mSeekTable(nullptr)
#endif
#if defined(_XBOX_ONE) && defined(_TITLE)
, mXMAMemory(nullptr)
#endif
{
assert( mEngine != 0 );
mEngine->RegisterNotify( this, false );
assert(mEngine != 0);
mEngine->RegisterNotify(this, false);
}
virtual ~Impl()
{
if ( !mInstances.empty() )
if (!mInstances.empty())
{
DebugTrace( "WARNING: Destroying SoundEffect with %Iu outstanding SoundEffectInstances\n", mInstances.size() );
DebugTrace("WARNING: Destroying SoundEffect with %Iu outstanding SoundEffectInstances\n", mInstances.size());
for( auto it = mInstances.begin(); it != mInstances.end(); ++it )
for (auto it = mInstances.begin(); it != mInstances.end(); ++it)
{
assert( *it != 0 );
assert(*it != 0);
(*it)->OnDestroyParent();
}
mInstances.clear();
}
if ( mOneShots > 0 )
if (mOneShots > 0)
{
DebugTrace( "WARNING: Destroying SoundEffect with %u outstanding one shot effects\n", mOneShots );
DebugTrace("WARNING: Destroying SoundEffect with %u outstanding one shot effects\n", mOneShots);
}
if ( mEngine )
if (mEngine)
{
mEngine->UnregisterNotify( this, true, false );
mEngine->UnregisterNotify(this, true, false);
mEngine = nullptr;
}
#if defined(_XBOX_ONE) && defined(_TITLE)
if ( mXMAMemory )
#if defined(_XBOX_ONE) && defined(_TITLE)
if (mXMAMemory)
{
ApuFree( mXMAMemory );
ApuFree(mXMAMemory);
mXMAMemory = nullptr;
}
#endif
#endif
}
HRESULT Initialize( _In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
_In_reads_opt_(seekCount) const uint32_t* seekTable, size_t seekCount,
#endif
uint32_t loopStart, uint32_t loopLength );
HRESULT Initialize(_In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
_In_reads_opt_(seekCount) const uint32_t* seekTable, size_t seekCount,
#endif
uint32_t loopStart, uint32_t loopLength);
void Play( float volume, float pitch, float pan );
void Play(float volume, float pitch, float pan);
// IVoiceNotify
virtual void __cdecl OnBufferEnd() override
{
InterlockedDecrement( &mOneShots );
InterlockedDecrement(&mOneShots);
}
virtual void __cdecl OnCriticalError() override
@ -129,15 +126,15 @@ public:
// No action required
}
virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const override
virtual void __cdecl GatherStatistics(AudioStatistics& stats) const override
{
stats.playingOneShots += mOneShots;
stats.audioBytes += mAudioBytes;
#if defined(_XBOX_ONE) && defined(_TITLE)
if ( mXMAMemory )
#if defined(_XBOX_ONE) && defined(_TITLE)
if (mXMAMemory)
stats.xmaAudioBytes += mAudioBytes;
#endif
#endif
}
const WAVEFORMATEX* mWaveFormat;
@ -164,112 +161,112 @@ private:
_Use_decl_annotations_
HRESULT SoundEffect::Impl::Initialize( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
const uint32_t* seekTable, size_t seekCount,
#endif
uint32_t loopStart, uint32_t loopLength )
HRESULT SoundEffect::Impl::Initialize(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
const uint32_t* seekTable, size_t seekCount,
#endif
uint32_t loopStart, uint32_t loopLength)
{
if ( !engine || !IsValid( wfx ) || !startAudio || !audioBytes || !wavData )
if (!engine || !IsValid(wfx) || !startAudio || !audioBytes || !wavData)
return E_INVALIDARG;
if ( audioBytes > UINT32_MAX )
if (audioBytes > UINT32_MAX)
return E_INVALIDARG;
switch( GetFormatTag( wfx ) )
switch (GetFormatTag(wfx))
{
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_IEEE_FLOAT:
case WAVE_FORMAT_ADPCM:
// Take ownership of the buffer
mWavData.reset( wavData.release() );
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_IEEE_FLOAT:
case WAVE_FORMAT_ADPCM:
// Take ownership of the buffer
mWavData.reset(wavData.release());
// WARNING: We assume the wfx and startAudio parameters are pointers into the wavData memory buffer
mWaveFormat = wfx;
mStartAudio = startAudio;
break;
// WARNING: We assume the wfx and startAudio parameters are pointers into the wavData memory buffer
mWaveFormat = wfx;
mStartAudio = startAudio;
break;
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
if ( !seekCount || !seekTable )
{
DebugTrace( "ERROR: SoundEffect format xWMA requires seek table\n" );
return E_FAIL;
}
if ( seekCount > UINT32_MAX )
return E_INVALIDARG;
// Take ownership of the buffer
mWavData.reset( wavData.release() );
// WARNING: We assume the wfx, startAudio, and mSeekTable parameters are pointers into the wavData memory buffer
mWaveFormat = wfx;
mStartAudio = startAudio;
mSeekCount = static_cast<uint32_t>( seekCount );
mSeekTable = seekTable;
break;
#endif // _XBOX_ONE || _WIN32_WINNT < _WIN32_WINNT_WIN8 || _WIN32_WINNT >= _WIN32_WINNT_WIN10
#if defined(_XBOX_ONE) && defined(_TITLE)
case WAVE_FORMAT_XMA2:
if ( !seekCount || !seekTable )
{
DebugTrace( "ERROR: SoundEffect format XMA2 requires seek table\n" );
return E_FAIL;
}
if ( seekCount > UINT32_MAX )
return E_INVALIDARG;
{
HRESULT hr = ApuAlloc( &mXMAMemory, nullptr,
static_cast<UINT32>( audioBytes ), SHAPE_XMA_INPUT_BUFFER_ALIGNMENT );
if ( FAILED(hr) )
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
if (!seekCount || !seekTable)
{
DebugTrace( "ERROR: ApuAlloc failed. Did you allocate a large enough heap with ApuCreateHeap for all your XMA wave data?\n" );
return hr;
DebugTrace("ERROR: SoundEffect format xWMA requires seek table\n");
return E_FAIL;
}
}
memcpy( mXMAMemory, startAudio, audioBytes );
mStartAudio = reinterpret_cast<const uint8_t*>( mXMAMemory );
if (seekCount > UINT32_MAX)
return E_INVALIDARG;
mWavData.reset( new uint8_t[ sizeof(XMA2WAVEFORMATEX) + ( seekCount * sizeof(uint32_t) ) ] );
// Take ownership of the buffer
mWavData.reset(wavData.release());
memcpy( mWavData.get(), wfx, sizeof(XMA2WAVEFORMATEX) );
mWaveFormat = reinterpret_cast<WAVEFORMATEX*>( mWavData.get() );
// WARNING: We assume the wfx, startAudio, and mSeekTable parameters are pointers into the wavData memory buffer
mWaveFormat = wfx;
mStartAudio = startAudio;
mSeekCount = static_cast<uint32_t>(seekCount);
mSeekTable = seekTable;
break;
// XMA seek table is Big-Endian
{
auto dest = reinterpret_cast<uint32_t*>( mWavData.get() + sizeof(XMA2WAVEFORMATEX) );
for( size_t k = 0; k < seekCount; ++k )
#endif // _XBOX_ONE || _WIN32_WINNT < _WIN32_WINNT_WIN8 || _WIN32_WINNT >= _WIN32_WINNT_WIN10
#if defined(_XBOX_ONE) && defined(_TITLE)
case WAVE_FORMAT_XMA2:
if (!seekCount || !seekTable)
{
dest[ k ] = _byteswap_ulong( seekTable[ k ]) ;
DebugTrace("ERROR: SoundEffect format XMA2 requires seek table\n");
return E_FAIL;
}
}
mSeekCount = static_cast<uint32_t>( seekCount );
mSeekTable = reinterpret_cast<const uint32_t*>( mWavData.get() + sizeof(XMA2WAVEFORMATEX) );
if (seekCount > UINT32_MAX)
return E_INVALIDARG;
wavData.reset();
break;
{
HRESULT hr = ApuAlloc(&mXMAMemory, nullptr,
static_cast<UINT32>(audioBytes), SHAPE_XMA_INPUT_BUFFER_ALIGNMENT);
if (FAILED(hr))
{
DebugTrace("ERROR: ApuAlloc failed. Did you allocate a large enough heap with ApuCreateHeap for all your XMA wave data?\n");
return hr;
}
}
#endif // _XBOX_ONE && _TITLE
memcpy(mXMAMemory, startAudio, audioBytes);
mStartAudio = reinterpret_cast<const uint8_t*>(mXMAMemory);
default:
mWavData.reset(new uint8_t[sizeof(XMA2WAVEFORMATEX) + (seekCount * sizeof(uint32_t))]);
memcpy(mWavData.get(), wfx, sizeof(XMA2WAVEFORMATEX));
mWaveFormat = reinterpret_cast<WAVEFORMATEX*>(mWavData.get());
// XMA seek table is Big-Endian
{
auto dest = reinterpret_cast<uint32_t*>(mWavData.get() + sizeof(XMA2WAVEFORMATEX));
for (size_t k = 0; k < seekCount; ++k)
{
dest[k] = _byteswap_ulong(seekTable[k]);
}
}
mSeekCount = static_cast<uint32_t>(seekCount);
mSeekTable = reinterpret_cast<const uint32_t*>(mWavData.get() + sizeof(XMA2WAVEFORMATEX));
wavData.reset();
break;
#endif // _XBOX_ONE && _TITLE
default:
{
DebugTrace( "ERROR: SoundEffect encountered an unsupported format tag (%u)\n", wfx->wFormatTag );
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
DebugTrace("ERROR: SoundEffect encountered an unsupported format tag (%u)\n", wfx->wFormatTag);
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
}
mAudioBytes = static_cast<uint32_t>( audioBytes );
mAudioBytes = static_cast<uint32_t>(audioBytes);
mLoopStart = loopStart;
mLoopLength = loopLength;
@ -277,44 +274,44 @@ HRESULT SoundEffect::Impl::Initialize( AudioEngine* engine, std::unique_ptr<uint
}
void SoundEffect::Impl::Play( float volume, float pitch, float pan )
void SoundEffect::Impl::Play(float volume, float pitch, float pan)
{
assert( volume >= -XAUDIO2_MAX_VOLUME_LEVEL && volume <= XAUDIO2_MAX_VOLUME_LEVEL );
assert( pitch >= -1.f && pitch <= 1.f );
assert( pan >= -1.f && pan <= 1.f );
assert(volume >= -XAUDIO2_MAX_VOLUME_LEVEL && volume <= XAUDIO2_MAX_VOLUME_LEVEL);
assert(pitch >= -1.f && pitch <= 1.f);
assert(pan >= -1.f && pan <= 1.f);
IXAudio2SourceVoice* voice = nullptr;
mEngine->AllocateVoice( mWaveFormat, SoundEffectInstance_Default, true, &voice );
if ( !voice )
mEngine->AllocateVoice(mWaveFormat, SoundEffectInstance_Default, true, &voice);
if (!voice)
return;
if ( volume != 1.f )
if (volume != 1.f)
{
HRESULT hr = voice->SetVolume( volume );
ThrowIfFailed( hr );
HRESULT hr = voice->SetVolume(volume);
ThrowIfFailed(hr);
}
if ( pitch != 0.f )
if (pitch != 0.f)
{
float fr = XAudio2SemitonesToFrequencyRatio( pitch * 12.f );
float fr = XAudio2SemitonesToFrequencyRatio(pitch * 12.f);
HRESULT hr = voice->SetFrequencyRatio( fr );
ThrowIfFailed( hr );
HRESULT hr = voice->SetFrequencyRatio(fr);
ThrowIfFailed(hr);
}
if ( pan != 0.f )
if (pan != 0.f)
{
float matrix[16];
if (ComputePan(pan, mWaveFormat->nChannels, matrix))
{
HRESULT hr = voice->SetOutputMatrix(nullptr, mWaveFormat->nChannels, mEngine->GetOutputChannels(), matrix);
ThrowIfFailed( hr );
ThrowIfFailed(hr);
}
}
HRESULT hr = voice->Start( 0 );
ThrowIfFailed( hr );
HRESULT hr = voice->Start(0);
ThrowIfFailed(hr);
XAUDIO2_BUFFER buffer = {};
buffer.AudioBytes = mAudioBytes;
@ -324,29 +321,29 @@ void SoundEffect::Impl::Play( float volume, float pitch, float pan )
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
uint32_t tag = GetFormatTag( mWaveFormat );
if ( tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3 )
uint32_t tag = GetFormatTag(mWaveFormat);
if (tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3)
{
XAUDIO2_BUFFER_WMA wmaBuffer = {};
wmaBuffer.PacketCount = mSeekCount;
wmaBuffer.pDecodedPacketCumulativeBytes = mSeekTable;
hr = voice->SubmitSourceBuffer( &buffer, &wmaBuffer );
hr = voice->SubmitSourceBuffer(&buffer, &wmaBuffer);
}
else
#endif
#endif
{
hr = voice->SubmitSourceBuffer( &buffer, nullptr );
hr = voice->SubmitSourceBuffer(&buffer, nullptr);
}
if ( FAILED(hr) )
if (FAILED(hr))
{
DebugTrace( "ERROR: SoundEffect failed (%08X) when submitting buffer:\n", hr );
DebugTrace( "\tFormat Tag %u, %u channels, %u-bit, %u Hz, %u bytes\n", mWaveFormat->wFormatTag,
mWaveFormat->nChannels, mWaveFormat->wBitsPerSample, mWaveFormat->nSamplesPerSec, mAudioBytes );
throw std::exception( "SubmitSourceBuffer" );
DebugTrace("ERROR: SoundEffect failed (%08X) when submitting buffer:\n", hr);
DebugTrace("\tFormat Tag %u, %u channels, %u-bit, %u Hz, %u bytes\n", mWaveFormat->wFormatTag,
mWaveFormat->nChannels, mWaveFormat->wBitsPerSample, mWaveFormat->nSamplesPerSec, mAudioBytes);
throw std::exception("SubmitSourceBuffer");
}
InterlockedIncrement( &mOneShots );
InterlockedIncrement(&mOneShots);
}
@ -356,68 +353,68 @@ void SoundEffect::Impl::Play( float volume, float pitch, float pan )
// Public constructors.
_Use_decl_annotations_
SoundEffect::SoundEffect( AudioEngine* engine, const wchar_t* waveFileName )
: pImpl(new Impl(engine) )
SoundEffect::SoundEffect(AudioEngine* engine, const wchar_t* waveFileName)
: pImpl(std::make_unique<Impl>(engine))
{
WAVData wavInfo;
std::unique_ptr<uint8_t[]> wavData;
HRESULT hr = LoadWAVAudioFromFileEx( waveFileName, wavData, wavInfo );
if ( FAILED(hr) )
HRESULT hr = LoadWAVAudioFromFileEx(waveFileName, wavData, wavInfo);
if (FAILED(hr))
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to load from .wav file \"%ls\"\n", hr, waveFileName );
throw std::exception( "SoundEffect" );
DebugTrace("ERROR: SoundEffect failed (%08X) to load from .wav file \"%ls\"\n", hr, waveFileName);
throw std::exception("SoundEffect");
}
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
hr = pImpl->Initialize( engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
wavInfo.seek, wavInfo.seekCount,
wavInfo.loopStart, wavInfo.loopLength );
hr = pImpl->Initialize(engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
wavInfo.seek, wavInfo.seekCount,
wavInfo.loopStart, wavInfo.loopLength);
#else
hr = pImpl->Initialize( engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
wavInfo.loopStart, wavInfo.loopLength );
hr = pImpl->Initialize(engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
wavInfo.loopStart, wavInfo.loopLength);
#endif
if ( FAILED(hr) )
if (FAILED(hr))
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize from .wav file \"%ls\"\n", hr, waveFileName );
throw std::exception( "SoundEffect" );
DebugTrace("ERROR: SoundEffect failed (%08X) to intialize from .wav file \"%ls\"\n", hr, waveFileName);
throw std::exception("SoundEffect");
}
}
_Use_decl_annotations_
SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes )
: pImpl(new Impl(engine) )
SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes)
: pImpl(std::make_unique<Impl>(engine))
{
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, nullptr, 0, 0, 0 );
HRESULT hr = pImpl->Initialize(engine, wavData, wfx, startAudio, audioBytes, nullptr, 0, 0, 0);
#else
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, 0, 0 );
HRESULT hr = pImpl->Initialize(engine, wavData, wfx, startAudio, audioBytes, 0, 0);
#endif
if ( FAILED(hr) )
if (FAILED(hr))
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize\n", hr );
throw std::exception( "SoundEffect" );
DebugTrace("ERROR: SoundEffect failed (%08X) to intialize\n", hr);
throw std::exception("SoundEffect");
}
}
_Use_decl_annotations_
SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
uint32_t loopStart, uint32_t loopLength )
: pImpl(new Impl(engine) )
SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
uint32_t loopStart, uint32_t loopLength)
: pImpl(std::make_unique<Impl>(engine))
{
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, nullptr, 0, loopStart, loopLength );
HRESULT hr = pImpl->Initialize(engine, wavData, wfx, startAudio, audioBytes, nullptr, 0, loopStart, loopLength);
#else
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, loopStart, loopLength );
HRESULT hr = pImpl->Initialize(engine, wavData, wfx, startAudio, audioBytes, loopStart, loopLength);
#endif
if ( FAILED(hr) )
if (FAILED(hr))
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize\n", hr );
throw std::exception( "SoundEffect" );
DebugTrace("ERROR: SoundEffect failed (%08X) to intialize\n", hr);
throw std::exception("SoundEffect");
}
}
@ -425,15 +422,15 @@ SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavDa
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
_Use_decl_annotations_
SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
const uint32_t* seekTable, size_t seekCount )
SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
const uint32_t* seekTable, size_t seekCount)
{
HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, seekTable, seekCount, 0, 0 );
if ( FAILED(hr) )
HRESULT hr = pImpl->Initialize(engine, wavData, wfx, startAudio, audioBytes, seekTable, seekCount, 0, 0);
if (FAILED(hr))
{
DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize\n", hr );
throw std::exception( "SoundEffect" );
DebugTrace("ERROR: SoundEffect failed (%08X) to intialize\n", hr);
throw std::exception("SoundEffect");
}
}
@ -441,14 +438,14 @@ SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavDa
// Move constructor.
SoundEffect::SoundEffect(SoundEffect&& moveFrom)
: pImpl(std::move(moveFrom.pImpl))
SoundEffect::SoundEffect(SoundEffect&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
SoundEffect& SoundEffect::operator= (SoundEffect&& moveFrom)
SoundEffect& SoundEffect::operator= (SoundEffect&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;
@ -464,39 +461,39 @@ SoundEffect::~SoundEffect()
// Public methods.
void SoundEffect::Play()
{
pImpl->Play( 1.f, 0.f, 0.f );
pImpl->Play(1.f, 0.f, 0.f);
}
void SoundEffect::Play( float volume, float pitch, float pan )
void SoundEffect::Play(float volume, float pitch, float pan)
{
pImpl->Play( volume, pitch, pan );
pImpl->Play(volume, pitch, pan);
}
std::unique_ptr<SoundEffectInstance> SoundEffect::CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS flags )
std::unique_ptr<SoundEffectInstance> SoundEffect::CreateInstance(SOUND_EFFECT_INSTANCE_FLAGS flags)
{
auto effect = new SoundEffectInstance( pImpl->mEngine, this, flags );
assert( effect != 0 );
pImpl->mInstances.emplace_back( effect );
return std::unique_ptr<SoundEffectInstance>( effect );
auto effect = new SoundEffectInstance(pImpl->mEngine, this, flags);
assert(effect != 0);
pImpl->mInstances.emplace_back(effect);
return std::unique_ptr<SoundEffectInstance>(effect);
}
void SoundEffect::UnregisterInstance( _In_ SoundEffectInstance* instance )
void SoundEffect::UnregisterInstance(_In_ SoundEffectInstance* instance)
{
auto it = std::find( pImpl->mInstances.begin(), pImpl->mInstances.end(), instance );
if ( it == pImpl->mInstances.end() )
auto it = std::find(pImpl->mInstances.begin(), pImpl->mInstances.end(), instance);
if (it == pImpl->mInstances.end())
return;
pImpl->mInstances.erase( it );
pImpl->mInstances.erase(it);
}
// Public accessors.
bool SoundEffect::IsInUse() const
{
return ( pImpl->mOneShots > 0 ) || !pImpl->mInstances.empty();
return (pImpl->mOneShots > 0) || !pImpl->mInstances.empty();
}
@ -508,50 +505,50 @@ size_t SoundEffect::GetSampleSizeInBytes() const
size_t SoundEffect::GetSampleDuration() const
{
if ( !pImpl->mWaveFormat || !pImpl->mWaveFormat->nChannels )
if (!pImpl->mWaveFormat || !pImpl->mWaveFormat->nChannels)
return 0;
switch( GetFormatTag( pImpl->mWaveFormat ) )
switch (GetFormatTag(pImpl->mWaveFormat))
{
case WAVE_FORMAT_ADPCM:
case WAVE_FORMAT_ADPCM:
{
auto adpcmFmt = reinterpret_cast<const ADPCMWAVEFORMAT*>( pImpl->mWaveFormat );
auto adpcmFmt = reinterpret_cast<const ADPCMWAVEFORMAT*>(pImpl->mWaveFormat);
uint64_t duration = uint64_t( pImpl->mAudioBytes / adpcmFmt->wfx.nBlockAlign ) * adpcmFmt->wSamplesPerBlock;
uint64_t duration = uint64_t(pImpl->mAudioBytes / adpcmFmt->wfx.nBlockAlign) * adpcmFmt->wSamplesPerBlock;
int partial = pImpl->mAudioBytes % adpcmFmt->wfx.nBlockAlign;
if ( partial )
if (partial)
{
if ( partial >= ( 7 * adpcmFmt->wfx.nChannels ) )
duration += ( partial * 2 / adpcmFmt->wfx.nChannels - 12 );
if (partial >= (7 * adpcmFmt->wfx.nChannels))
duration += (uint64_t(partial) * 2 / uint64_t(adpcmFmt->wfx.nChannels - 12));
}
return static_cast<size_t>( duration );
return static_cast<size_t>(duration);
}
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
if ( pImpl->mSeekTable && pImpl->mSeekCount > 0 )
{
return pImpl->mSeekTable[ pImpl->mSeekCount - 1 ] / uint32_t( 2 * pImpl->mWaveFormat->nChannels );
}
break;
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
if (pImpl->mSeekTable && pImpl->mSeekCount > 0)
{
return pImpl->mSeekTable[pImpl->mSeekCount - 1] / uint32_t(2 * pImpl->mWaveFormat->nChannels);
}
break;
#endif
#endif
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
case WAVE_FORMAT_XMA2:
return reinterpret_cast<const XMA2WAVEFORMATEX*>( pImpl->mWaveFormat )->SamplesEncoded;
case WAVE_FORMAT_XMA2:
return reinterpret_cast<const XMA2WAVEFORMATEX*>(pImpl->mWaveFormat)->SamplesEncoded;
#endif
#endif
default:
if ( pImpl->mWaveFormat->wBitsPerSample > 0 )
{
return static_cast<size_t>( ( uint64_t( pImpl->mAudioBytes ) * 8 )
/ uint64_t( pImpl->mWaveFormat->wBitsPerSample * pImpl->mWaveFormat->nChannels ) );
}
default:
if (pImpl->mWaveFormat->wBitsPerSample > 0)
{
return static_cast<size_t>((uint64_t(pImpl->mAudioBytes) * 8)
/ (uint64_t(pImpl->mWaveFormat->wBitsPerSample) * uint64_t(pImpl->mWaveFormat->nChannels)));
}
}
return 0;
@ -560,11 +557,11 @@ size_t SoundEffect::GetSampleDuration() const
size_t SoundEffect::GetSampleDurationMS() const
{
if ( !pImpl->mWaveFormat || !pImpl->mWaveFormat->nSamplesPerSec )
if (!pImpl->mWaveFormat || !pImpl->mWaveFormat->nSamplesPerSec)
return 0;
uint64_t samples = GetSampleDuration();
return static_cast<size_t>( ( samples * 1000 ) / pImpl->mWaveFormat->nSamplesPerSec );
return static_cast<size_t>((samples * 1000) / pImpl->mWaveFormat->nSamplesPerSec);
}
@ -576,18 +573,18 @@ const WAVEFORMATEX* SoundEffect::GetFormat() const
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
bool SoundEffect::FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer ) const
bool SoundEffect::FillSubmitBuffer(_Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer) const
{
memset( &buffer, 0, sizeof(buffer) );
memset( &wmaBuffer, 0, sizeof(wmaBuffer) );
memset(&buffer, 0, sizeof(buffer));
memset(&wmaBuffer, 0, sizeof(wmaBuffer));
buffer.AudioBytes = pImpl->mAudioBytes;
buffer.pAudioData = pImpl->mStartAudio;
buffer.LoopBegin = pImpl->mLoopStart;
buffer.LoopLength = pImpl->mLoopLength;
uint32_t tag = GetFormatTag( pImpl->mWaveFormat );
if ( tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3 )
uint32_t tag = GetFormatTag(pImpl->mWaveFormat);
if (tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3)
{
wmaBuffer.PacketCount = pImpl->mSeekCount;
wmaBuffer.pDecodedPacketCumulativeBytes = pImpl->mSeekTable;
@ -599,9 +596,9 @@ bool SoundEffect::FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_
#else
void SoundEffect::FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer ) const
void SoundEffect::FillSubmitBuffer(_Out_ XAUDIO2_BUFFER& buffer) const
{
memset( &buffer, 0, sizeof(buffer) );
memset(&buffer, 0, sizeof(buffer));
buffer.AudioBytes = pImpl->mAudioBytes;
buffer.pAudioData = pImpl->mStartAudio;
buffer.LoopBegin = pImpl->mLoopStart;

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: SoundEffectInstance.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "pch.h"
@ -25,54 +22,54 @@ using namespace DirectX;
class SoundEffectInstance::Impl : public IVoiceNotify
{
public:
Impl( _In_ AudioEngine* engine, _In_ SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags ) :
Impl(_In_ AudioEngine* engine, _In_ SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags) :
mBase(),
mEffect( effect ),
mWaveBank( nullptr ),
mIndex( 0 ),
mLooped( false )
mEffect(effect),
mWaveBank(nullptr),
mIndex(0),
mLooped(false)
{
assert( engine != 0 );
engine->RegisterNotify( this, false );
assert(engine != 0);
engine->RegisterNotify(this, false);
assert( mEffect != 0 );
mBase.Initialize( engine, effect->GetFormat(), flags );
assert(mEffect != 0);
mBase.Initialize(engine, effect->GetFormat(), flags);
}
Impl( _In_ AudioEngine* engine, _In_ WaveBank* waveBank, uint32_t index, SOUND_EFFECT_INSTANCE_FLAGS flags ) :
Impl(_In_ AudioEngine* engine, _In_ WaveBank* waveBank, uint32_t index, SOUND_EFFECT_INSTANCE_FLAGS flags) :
mBase(),
mEffect( nullptr ),
mWaveBank( waveBank ),
mIndex( index ),
mLooped( false )
mEffect(nullptr),
mWaveBank(waveBank),
mIndex(index),
mLooped(false)
{
assert( engine != 0 );
engine->RegisterNotify( this, false );
assert(engine != 0);
engine->RegisterNotify(this, false);
char buff[64] = {};
auto wfx = reinterpret_cast<WAVEFORMATEX*>( buff );
assert( mWaveBank != 0 );
mBase.Initialize( engine, mWaveBank->GetFormat( index, wfx, sizeof(buff) ), flags );
auto wfx = reinterpret_cast<WAVEFORMATEX*>(buff);
assert(mWaveBank != 0);
mBase.Initialize(engine, mWaveBank->GetFormat(index, wfx, sizeof(buff)), flags);
}
virtual ~Impl()
{
mBase.DestroyVoice();
if ( mBase.engine )
if (mBase.engine)
{
mBase.engine->UnregisterNotify( this, false, false );
mBase.engine->UnregisterNotify(this, false, false);
mBase.engine = nullptr;
}
}
void Play( bool loop );
void Play(bool loop);
// IVoiceNotify
virtual void __cdecl OnBufferEnd() override
{
// We don't register for this notification for SoundEffectInstances, so this should not be invoked
assert( false );
assert(false);
}
virtual void __cdecl OnCriticalError() override
@ -101,7 +98,7 @@ public:
mBase.OnTrim();
}
virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const override
virtual void __cdecl GatherStatistics(AudioStatistics& stats) const override
{
mBase.GatherStatistics(stats);
}
@ -114,24 +111,24 @@ public:
};
void SoundEffectInstance::Impl::Play( bool loop )
void SoundEffectInstance::Impl::Play(bool loop)
{
if ( !mBase.voice )
if (!mBase.voice)
{
if ( mWaveBank )
if (mWaveBank)
{
char buff[64] = {};
auto wfx = reinterpret_cast<WAVEFORMATEX*>( buff );
mBase.AllocateVoice( mWaveBank->GetFormat( mIndex, wfx, sizeof(buff) ) );
auto wfx = reinterpret_cast<WAVEFORMATEX*>(buff);
mBase.AllocateVoice(mWaveBank->GetFormat(mIndex, wfx, sizeof(buff)));
}
else
{
assert( mEffect != 0 );
mBase.AllocateVoice( mEffect->GetFormat() );
assert(mEffect != 0);
mBase.AllocateVoice(mEffect->GetFormat());
}
}
if ( !mBase.Play() )
if (!mBase.Play())
return;
// Submit audio data for STOPPED -> PLAYING state transition
@ -141,32 +138,32 @@ void SoundEffectInstance::Impl::Play( bool loop )
bool iswma = false;
XAUDIO2_BUFFER_WMA wmaBuffer;
if ( mWaveBank )
if (mWaveBank)
{
iswma = mWaveBank->FillSubmitBuffer( mIndex, buffer, wmaBuffer );
iswma = mWaveBank->FillSubmitBuffer(mIndex, buffer, wmaBuffer);
}
else
{
assert( mEffect != 0 );
iswma = mEffect->FillSubmitBuffer( buffer, wmaBuffer );
assert(mEffect != 0);
iswma = mEffect->FillSubmitBuffer(buffer, wmaBuffer);
}
#else
if ( mWaveBank )
if (mWaveBank)
{
mWaveBank->FillSubmitBuffer( mIndex, buffer );
mWaveBank->FillSubmitBuffer(mIndex, buffer);
}
else
{
assert( mEffect != 0 );
mEffect->FillSubmitBuffer( buffer );
assert(mEffect != 0);
mEffect->FillSubmitBuffer(buffer);
}
#endif
buffer.Flags = XAUDIO2_END_OF_STREAM;
if ( loop )
if (loop)
{
mLooped = true;
buffer.LoopCount = XAUDIO2_LOOP_INFINITE;
@ -180,32 +177,32 @@ void SoundEffectInstance::Impl::Play( bool loop )
HRESULT hr;
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
if ( iswma )
if (iswma)
{
hr = mBase.voice->SubmitSourceBuffer( &buffer, &wmaBuffer );
hr = mBase.voice->SubmitSourceBuffer(&buffer, &wmaBuffer);
}
else
#endif
#endif
{
hr = mBase.voice->SubmitSourceBuffer( &buffer, nullptr );
hr = mBase.voice->SubmitSourceBuffer(&buffer, nullptr);
}
if ( FAILED(hr) )
if (FAILED(hr))
{
#ifdef _DEBUG
DebugTrace( "ERROR: SoundEffectInstance failed (%08X) when submitting buffer:\n", hr );
#ifdef _DEBUG
DebugTrace("ERROR: SoundEffectInstance failed (%08X) when submitting buffer:\n", hr);
char buff[64] = {};
auto wfx = ( mWaveBank ) ? mWaveBank->GetFormat( mIndex, reinterpret_cast<WAVEFORMATEX*>( buff ), sizeof(buff) )
: mEffect->GetFormat();
auto wfx = (mWaveBank) ? mWaveBank->GetFormat(mIndex, reinterpret_cast<WAVEFORMATEX*>(buff), sizeof(buff))
: mEffect->GetFormat();
size_t length = ( mWaveBank ) ? mWaveBank->GetSampleSizeInBytes( mIndex ) : mEffect->GetSampleSizeInBytes();
size_t length = (mWaveBank) ? mWaveBank->GetSampleSizeInBytes(mIndex) : mEffect->GetSampleSizeInBytes();
DebugTrace( "\tFormat Tag %u, %u channels, %u-bit, %u Hz, %Iu bytes\n", wfx->wFormatTag,
wfx->nChannels, wfx->wBitsPerSample, wfx->nSamplesPerSec, length );
#endif
mBase.Stop( true, mLooped );
throw std::exception( "SubmitSourceBuffer" );
DebugTrace("\tFormat Tag %u, %u channels, %u-bit, %u Hz, %Iu bytes\n", wfx->wFormatTag,
wfx->nChannels, wfx->wBitsPerSample, wfx->nSamplesPerSec, length);
#endif
mBase.Stop(true, mLooped);
throw std::exception("SubmitSourceBuffer");
}
}
@ -216,27 +213,27 @@ void SoundEffectInstance::Impl::Play( bool loop )
// Private constructors
_Use_decl_annotations_
SoundEffectInstance::SoundEffectInstance( AudioEngine* engine, SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags ) :
pImpl( new Impl( engine, effect, flags ) )
SoundEffectInstance::SoundEffectInstance(AudioEngine* engine, SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags) :
pImpl(std::make_unique<Impl>(engine, effect, flags))
{
}
_Use_decl_annotations_
SoundEffectInstance::SoundEffectInstance( AudioEngine* engine, WaveBank* waveBank, int index, SOUND_EFFECT_INSTANCE_FLAGS flags ) :
pImpl( new Impl( engine, waveBank, index, flags ) )
SoundEffectInstance::SoundEffectInstance(AudioEngine* engine, WaveBank* waveBank, int index, SOUND_EFFECT_INSTANCE_FLAGS flags) :
pImpl(std::make_unique<Impl>(engine, waveBank, index, flags))
{
}
// Move constructor.
SoundEffectInstance::SoundEffectInstance(SoundEffectInstance&& moveFrom)
: pImpl(std::move(moveFrom.pImpl))
SoundEffectInstance::SoundEffectInstance(SoundEffectInstance&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
SoundEffectInstance& SoundEffectInstance::operator= (SoundEffectInstance&& moveFrom)
SoundEffectInstance& SoundEffectInstance::operator= (SoundEffectInstance&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;
@ -246,17 +243,17 @@ SoundEffectInstance& SoundEffectInstance::operator= (SoundEffectInstance&& moveF
// Public destructor.
SoundEffectInstance::~SoundEffectInstance()
{
if( pImpl )
if (pImpl)
{
if ( pImpl->mWaveBank )
if (pImpl->mWaveBank)
{
pImpl->mWaveBank->UnregisterInstance( this );
pImpl->mWaveBank->UnregisterInstance(this);
pImpl->mWaveBank = nullptr;
}
if ( pImpl->mEffect )
if (pImpl->mEffect)
{
pImpl->mEffect->UnregisterInstance( this );
pImpl->mEffect->UnregisterInstance(this);
pImpl->mEffect = nullptr;
}
}
@ -264,15 +261,15 @@ SoundEffectInstance::~SoundEffectInstance()
// Public methods.
void SoundEffectInstance::Play( bool loop )
void SoundEffectInstance::Play(bool loop)
{
pImpl->Play( loop );
pImpl->Play(loop);
}
void SoundEffectInstance::Stop( bool immediate )
void SoundEffectInstance::Stop(bool immediate)
{
pImpl->mBase.Stop( immediate, pImpl->mLooped );
pImpl->mBase.Stop(immediate, pImpl->mLooped);
}
@ -288,27 +285,27 @@ void SoundEffectInstance::Resume()
}
void SoundEffectInstance::SetVolume( float volume )
void SoundEffectInstance::SetVolume(float volume)
{
pImpl->mBase.SetVolume( volume );
pImpl->mBase.SetVolume(volume);
}
void SoundEffectInstance::SetPitch( float pitch )
void SoundEffectInstance::SetPitch(float pitch)
{
pImpl->mBase.SetPitch( pitch );
pImpl->mBase.SetPitch(pitch);
}
void SoundEffectInstance::SetPan( float pan )
void SoundEffectInstance::SetPan(float pan)
{
pImpl->mBase.SetPan( pan );
pImpl->mBase.SetPan(pan);
}
void SoundEffectInstance::Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords )
void SoundEffectInstance::Apply3D(const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords)
{
pImpl->mBase.Apply3D( listener, emitter, rhcoords );
pImpl->mBase.Apply3D(listener, emitter, rhcoords);
}
@ -321,7 +318,7 @@ bool SoundEffectInstance::IsLooped() const
SoundState SoundEffectInstance::GetState()
{
return pImpl->mBase.GetState( true );
return pImpl->mBase.GetState(true);
}

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

@ -3,14 +3,11 @@
//
// Functions for loading WAV audio files
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//-------------------------------------------------------------------------------------
#include "pch.h"
@ -22,109 +19,109 @@ using namespace DirectX;
namespace
{
//--------------------------------------------------------------------------------------
// .WAV files
//--------------------------------------------------------------------------------------
const uint32_t FOURCC_RIFF_TAG = 'FFIR';
const uint32_t FOURCC_FORMAT_TAG = ' tmf';
const uint32_t FOURCC_DATA_TAG = 'atad';
const uint32_t FOURCC_WAVE_FILE_TAG = 'EVAW';
const uint32_t FOURCC_XWMA_FILE_TAG = 'AMWX';
const uint32_t FOURCC_DLS_SAMPLE = 'pmsw';
const uint32_t FOURCC_MIDI_SAMPLE = 'lpms';
const uint32_t FOURCC_XWMA_DPDS = 'sdpd';
const uint32_t FOURCC_XMA_SEEK = 'kees';
const uint32_t FOURCC_RIFF_TAG = 'FFIR';
const uint32_t FOURCC_FORMAT_TAG = ' tmf';
const uint32_t FOURCC_DATA_TAG = 'atad';
const uint32_t FOURCC_WAVE_FILE_TAG = 'EVAW';
const uint32_t FOURCC_XWMA_FILE_TAG = 'AMWX';
const uint32_t FOURCC_DLS_SAMPLE = 'pmsw';
const uint32_t FOURCC_MIDI_SAMPLE = 'lpms';
const uint32_t FOURCC_XWMA_DPDS = 'sdpd';
const uint32_t FOURCC_XMA_SEEK = 'kees';
#pragma pack(push,1)
struct RIFFChunk
{
uint32_t tag;
uint32_t size;
};
struct RIFFChunk
{
uint32_t tag;
uint32_t size;
};
struct RIFFChunkHeader
{
uint32_t tag;
uint32_t size;
uint32_t riff;
};
struct RIFFChunkHeader
{
uint32_t tag;
uint32_t size;
uint32_t riff;
};
struct DLSLoop
{
static const uint32_t LOOP_TYPE_FORWARD = 0x00000000;
static const uint32_t LOOP_TYPE_RELEASE = 0x00000001;
struct DLSLoop
{
static const uint32_t LOOP_TYPE_FORWARD = 0x00000000;
static const uint32_t LOOP_TYPE_RELEASE = 0x00000001;
uint32_t size;
uint32_t loopType;
uint32_t loopStart;
uint32_t loopLength;
};
uint32_t size;
uint32_t loopType;
uint32_t loopStart;
uint32_t loopLength;
};
struct RIFFDLSSample
{
static const uint32_t OPTIONS_NOTRUNCATION = 0x00000001;
static const uint32_t OPTIONS_NOCOMPRESSION = 0x00000002;
struct RIFFDLSSample
{
static const uint32_t OPTIONS_NOTRUNCATION = 0x00000001;
static const uint32_t OPTIONS_NOCOMPRESSION = 0x00000002;
uint32_t size;
uint16_t unityNote;
int16_t fineTune;
int32_t gain;
uint32_t options;
uint32_t loopCount;
};
uint32_t size;
uint16_t unityNote;
int16_t fineTune;
int32_t gain;
uint32_t options;
uint32_t loopCount;
};
struct MIDILoop
{
static const uint32_t LOOP_TYPE_FORWARD = 0x00000000;
static const uint32_t LOOP_TYPE_ALTERNATING = 0x00000001;
static const uint32_t LOOP_TYPE_BACKWARD = 0x00000002;
struct MIDILoop
{
static const uint32_t LOOP_TYPE_FORWARD = 0x00000000;
static const uint32_t LOOP_TYPE_ALTERNATING = 0x00000001;
static const uint32_t LOOP_TYPE_BACKWARD = 0x00000002;
uint32_t cuePointId;
uint32_t type;
uint32_t start;
uint32_t end;
uint32_t fraction;
uint32_t playCount;
};
uint32_t cuePointId;
uint32_t type;
uint32_t start;
uint32_t end;
uint32_t fraction;
uint32_t playCount;
};
struct RIFFMIDISample
{
uint32_t manufacturerId;
uint32_t productId;
uint32_t samplePeriod;
uint32_t unityNode;
uint32_t pitchFraction;
uint32_t SMPTEFormat;
uint32_t SMPTEOffset;
uint32_t loopCount;
uint32_t samplerData;
};
struct RIFFMIDISample
{
uint32_t manufacturerId;
uint32_t productId;
uint32_t samplePeriod;
uint32_t unityNode;
uint32_t pitchFraction;
uint32_t SMPTEFormat;
uint32_t SMPTEOffset;
uint32_t loopCount;
uint32_t samplerData;
};
#pragma pack(pop)
static_assert( sizeof(RIFFChunk) == 8, "structure size mismatch");
static_assert( sizeof(RIFFChunkHeader) == 12, "structure size mismatch");
static_assert( sizeof(DLSLoop) == 16, "structure size mismatch");
static_assert( sizeof(RIFFDLSSample) == 20, "structure size mismatch");
static_assert( sizeof(MIDILoop) == 24, "structure size mismatch");
static_assert( sizeof(RIFFMIDISample) == 36, "structure size mismatch");
static_assert(sizeof(RIFFChunk) == 8, "structure size mismatch");
static_assert(sizeof(RIFFChunkHeader) == 12, "structure size mismatch");
static_assert(sizeof(DLSLoop) == 16, "structure size mismatch");
static_assert(sizeof(RIFFDLSSample) == 20, "structure size mismatch");
static_assert(sizeof(MIDILoop) == 24, "structure size mismatch");
static_assert(sizeof(RIFFMIDISample) == 36, "structure size mismatch");
};
//--------------------------------------------------------------------------------------
static const RIFFChunk* FindChunk( _In_reads_bytes_(sizeBytes) const uint8_t* data, _In_ size_t sizeBytes, _In_ uint32_t tag )
static const RIFFChunk* FindChunk(_In_reads_bytes_(sizeBytes) const uint8_t* data, _In_ size_t sizeBytes, _In_ uint32_t tag)
{
if ( !data )
if (!data)
return nullptr;
const uint8_t* ptr = data;
const uint8_t* end = data + sizeBytes;
while ( end > ( ptr + sizeof(RIFFChunk) ) )
while (end > (ptr + sizeof(RIFFChunk)))
{
auto header = reinterpret_cast<const RIFFChunk*>( ptr );
if ( header->tag == tag )
auto header = reinterpret_cast<const RIFFChunk*>(ptr);
if (header->tag == tag)
return header;
ptrdiff_t offset = header->size + sizeof(RIFFChunk);
@ -136,16 +133,16 @@ static const RIFFChunk* FindChunk( _In_reads_bytes_(sizeBytes) const uint8_t* da
//--------------------------------------------------------------------------------------
static HRESULT WaveFindFormatAndData( _In_reads_bytes_(wavDataSize) const uint8_t* wavData, _In_ size_t wavDataSize,
_Outptr_ const WAVEFORMATEX** pwfx, _Outptr_ const uint8_t** pdata, _Out_ uint32_t* dataSize,
_Out_ bool& dpds, _Out_ bool& seek )
static HRESULT WaveFindFormatAndData(_In_reads_bytes_(wavDataSize) const uint8_t* wavData, _In_ size_t wavDataSize,
_Outptr_ const WAVEFORMATEX** pwfx, _Outptr_ const uint8_t** pdata, _Out_ uint32_t* dataSize,
_Out_ bool& dpds, _Out_ bool& seek)
{
if ( !wavData || !pwfx )
if (!wavData || !pwfx)
return E_POINTER;
dpds = seek = false;
if (wavDataSize < (sizeof(RIFFChunk)*2 + sizeof(uint32_t) + sizeof(WAVEFORMAT) ) )
if (wavDataSize < (sizeof(RIFFChunk) * 2 + sizeof(uint32_t) + sizeof(WAVEFORMAT)))
{
return E_FAIL;
}
@ -153,147 +150,147 @@ static HRESULT WaveFindFormatAndData( _In_reads_bytes_(wavDataSize) const uint8_
const uint8_t* wavEnd = wavData + wavDataSize;
// Locate RIFF 'WAVE'
auto riffChunk = FindChunk( wavData, wavDataSize, FOURCC_RIFF_TAG );
if ( !riffChunk || riffChunk->size < 4 )
auto riffChunk = FindChunk(wavData, wavDataSize, FOURCC_RIFF_TAG);
if (!riffChunk || riffChunk->size < 4)
{
return E_FAIL;
}
auto riffHeader = reinterpret_cast<const RIFFChunkHeader*>( riffChunk );
if ( riffHeader->riff != FOURCC_WAVE_FILE_TAG && riffHeader->riff != FOURCC_XWMA_FILE_TAG )
auto riffHeader = reinterpret_cast<const RIFFChunkHeader*>(riffChunk);
if (riffHeader->riff != FOURCC_WAVE_FILE_TAG && riffHeader->riff != FOURCC_XWMA_FILE_TAG)
{
return E_FAIL;
}
// Locate 'fmt '
auto ptr = reinterpret_cast<const uint8_t*>( riffHeader ) + sizeof(RIFFChunkHeader);
if ( ( ptr + sizeof(RIFFChunk) ) > wavEnd )
auto ptr = reinterpret_cast<const uint8_t*>(riffHeader) + sizeof(RIFFChunkHeader);
if ((ptr + sizeof(RIFFChunk)) > wavEnd)
{
return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
auto fmtChunk = FindChunk( ptr, riffHeader->size, FOURCC_FORMAT_TAG );
if ( !fmtChunk || fmtChunk->size < sizeof(PCMWAVEFORMAT) )
auto fmtChunk = FindChunk(ptr, riffHeader->size, FOURCC_FORMAT_TAG);
if (!fmtChunk || fmtChunk->size < sizeof(PCMWAVEFORMAT))
{
return E_FAIL;
}
ptr = reinterpret_cast<const uint8_t*>( fmtChunk ) + sizeof( RIFFChunk );
if ( ptr + fmtChunk->size > wavEnd )
ptr = reinterpret_cast<const uint8_t*>(fmtChunk) + sizeof(RIFFChunk);
if (ptr + fmtChunk->size > wavEnd)
{
return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
auto wf = reinterpret_cast<const WAVEFORMAT*>( ptr );
auto wf = reinterpret_cast<const WAVEFORMAT*>(ptr);
// Validate WAVEFORMAT (focused on chunk size and format tag, not other data that XAUDIO2 will validate)
switch( wf->wFormatTag )
switch (wf->wFormatTag)
{
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_IEEE_FLOAT:
// Can be a PCMWAVEFORMAT (8 bytes) or WAVEFORMATEX (10 bytes)
// We validiated chunk as at least sizeof(PCMWAVEFORMAT) above
break;
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_IEEE_FLOAT:
// Can be a PCMWAVEFORMAT (8 bytes) or WAVEFORMATEX (10 bytes)
// We validiated chunk as at least sizeof(PCMWAVEFORMAT) above
break;
default:
default:
{
if ( fmtChunk->size < sizeof(WAVEFORMATEX) )
if (fmtChunk->size < sizeof(WAVEFORMATEX))
{
return E_FAIL;
}
auto wfx = reinterpret_cast<const WAVEFORMATEX*>( ptr );
auto wfx = reinterpret_cast<const WAVEFORMATEX*>(ptr);
if ( fmtChunk->size < ( sizeof(WAVEFORMATEX) + wfx->cbSize ) )
if (fmtChunk->size < (sizeof(WAVEFORMATEX) + wfx->cbSize))
{
return E_FAIL;
}
switch( wfx->wFormatTag )
switch (wfx->wFormatTag)
{
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
dpds = true;
break;
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
dpds = true;
break;
case 0x166 /*WAVE_FORMAT_XMA2*/: // XMA2 is supported by Xbox One
if ( ( fmtChunk->size < 52 /*sizeof(XMA2WAVEFORMATEX)*/ ) || ( wfx->cbSize < 34 /*( sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX) )*/ ) )
{
return E_FAIL;
}
seek = true;
break;
case WAVE_FORMAT_ADPCM:
if ( ( fmtChunk->size < ( sizeof(WAVEFORMATEX) + 32 ) ) || ( wfx->cbSize < 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/ ) )
{
return E_FAIL;
}
break;
case WAVE_FORMAT_EXTENSIBLE:
if ( ( fmtChunk->size < sizeof(WAVEFORMATEXTENSIBLE) ) || ( wfx->cbSize < ( sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) ) ) )
{
return E_FAIL;
}
else
{
static const GUID s_wfexBase = {0x00000000, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71};
auto wfex = reinterpret_cast<const WAVEFORMATEXTENSIBLE*>( ptr );
if ( memcmp( reinterpret_cast<const BYTE*>(&wfex->SubFormat) + sizeof(DWORD),
reinterpret_cast<const BYTE*>(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD) ) != 0 )
case 0x166 /*WAVE_FORMAT_XMA2*/: // XMA2 is supported by Xbox One
if ((fmtChunk->size < 52 /*sizeof(XMA2WAVEFORMATEX)*/) || (wfx->cbSize < 34 /*( sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX) )*/))
{
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
return E_FAIL;
}
seek = true;
break;
switch( wfex->SubFormat.Data1 )
case WAVE_FORMAT_ADPCM:
if ((fmtChunk->size < (sizeof(WAVEFORMATEX) + 32)) || (wfx->cbSize < 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/))
{
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_IEEE_FLOAT:
break;
// MS-ADPCM and XMA2 are not supported as WAVEFORMATEXTENSIBLE
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
dpds = true;
break;
default:
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
return E_FAIL;
}
break;
}
break;
case WAVE_FORMAT_EXTENSIBLE:
if ((fmtChunk->size < sizeof(WAVEFORMATEXTENSIBLE)) || (wfx->cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))))
{
return E_FAIL;
}
else
{
static const GUID s_wfexBase = { 0x00000000, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 };
default:
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
auto wfex = reinterpret_cast<const WAVEFORMATEXTENSIBLE*>(ptr);
if (memcmp(reinterpret_cast<const BYTE*>(&wfex->SubFormat) + sizeof(DWORD),
reinterpret_cast<const BYTE*>(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD)) != 0)
{
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
switch (wfex->SubFormat.Data1)
{
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_IEEE_FLOAT:
break;
// MS-ADPCM and XMA2 are not supported as WAVEFORMATEXTENSIBLE
case WAVE_FORMAT_WMAUDIO2:
case WAVE_FORMAT_WMAUDIO3:
dpds = true;
break;
default:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
}
break;
default:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
}
}
// Locate 'data'
ptr = reinterpret_cast<const uint8_t*>( riffHeader ) + sizeof(RIFFChunkHeader);
if ( ( ptr + sizeof(RIFFChunk) ) > wavEnd )
ptr = reinterpret_cast<const uint8_t*>(riffHeader) + sizeof(RIFFChunkHeader);
if ((ptr + sizeof(RIFFChunk)) > wavEnd)
{
return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
auto dataChunk = FindChunk( ptr, riffChunk->size, FOURCC_DATA_TAG );
if ( !dataChunk || !dataChunk->size )
auto dataChunk = FindChunk(ptr, riffChunk->size, FOURCC_DATA_TAG);
if (!dataChunk || !dataChunk->size)
{
return HRESULT_FROM_WIN32( ERROR_INVALID_DATA );
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
}
ptr = reinterpret_cast<const uint8_t*>( dataChunk ) + sizeof( RIFFChunk );
if ( ptr + dataChunk->size > wavEnd )
ptr = reinterpret_cast<const uint8_t*>(dataChunk) + sizeof(RIFFChunk);
if (ptr + dataChunk->size > wavEnd)
{
return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
*pwfx = reinterpret_cast<const WAVEFORMATEX*>( wf );
*pwfx = reinterpret_cast<const WAVEFORMATEX*>(wf);
*pdata = ptr;
*dataSize = dataChunk->size;
return S_OK;
@ -301,13 +298,13 @@ static HRESULT WaveFindFormatAndData( _In_reads_bytes_(wavDataSize) const uint8_
//--------------------------------------------------------------------------------------
static HRESULT WaveFindLoopInfo( _In_reads_bytes_(wavDataSize) const uint8_t* wavData, _In_ size_t wavDataSize,
_Out_ uint32_t* pLoopStart, _Out_ uint32_t* pLoopLength )
static HRESULT WaveFindLoopInfo(_In_reads_bytes_(wavDataSize) const uint8_t* wavData, _In_ size_t wavDataSize,
_Out_ uint32_t* pLoopStart, _Out_ uint32_t* pLoopLength)
{
if ( !wavData || !pLoopStart || !pLoopLength )
if (!wavData || !pLoopStart || !pLoopLength)
return E_POINTER;
if (wavDataSize < ( sizeof(RIFFChunk) + sizeof(uint32_t) ) )
if (wavDataSize < (sizeof(RIFFChunk) + sizeof(uint32_t)))
{
return E_FAIL;
}
@ -318,50 +315,50 @@ static HRESULT WaveFindLoopInfo( _In_reads_bytes_(wavDataSize) const uint8_t* wa
const uint8_t* wavEnd = wavData + wavDataSize;
// Locate RIFF 'WAVE'
auto riffChunk = FindChunk( wavData, wavDataSize, FOURCC_RIFF_TAG );
if ( !riffChunk || riffChunk->size < 4 )
auto riffChunk = FindChunk(wavData, wavDataSize, FOURCC_RIFF_TAG);
if (!riffChunk || riffChunk->size < 4)
{
return E_FAIL;
}
auto riffHeader = reinterpret_cast<const RIFFChunkHeader*>( riffChunk );
if ( riffHeader->riff == FOURCC_XWMA_FILE_TAG )
auto riffHeader = reinterpret_cast<const RIFFChunkHeader*>(riffChunk);
if (riffHeader->riff == FOURCC_XWMA_FILE_TAG)
{
// xWMA files do not contain loop information
return S_OK;
}
if ( riffHeader->riff != FOURCC_WAVE_FILE_TAG )
if (riffHeader->riff != FOURCC_WAVE_FILE_TAG)
{
return E_FAIL;
}
// Locate 'wsmp' (DLS Chunk)
auto ptr = reinterpret_cast<const uint8_t*>( riffHeader ) + sizeof(RIFFChunkHeader);
if ( ( ptr + sizeof(RIFFChunk) ) > wavEnd )
auto ptr = reinterpret_cast<const uint8_t*>(riffHeader) + sizeof(RIFFChunkHeader);
if ((ptr + sizeof(RIFFChunk)) > wavEnd)
{
return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
auto dlsChunk = FindChunk( ptr, riffChunk->size, FOURCC_DLS_SAMPLE );
if ( dlsChunk )
auto dlsChunk = FindChunk(ptr, riffChunk->size, FOURCC_DLS_SAMPLE);
if (dlsChunk)
{
ptr = reinterpret_cast<const uint8_t*>( dlsChunk ) + sizeof( RIFFChunk );
if ( ptr + dlsChunk->size > wavEnd )
ptr = reinterpret_cast<const uint8_t*>(dlsChunk) + sizeof(RIFFChunk);
if (ptr + dlsChunk->size > wavEnd)
{
return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
if ( dlsChunk->size >= sizeof(RIFFDLSSample) )
if (dlsChunk->size >= sizeof(RIFFDLSSample))
{
auto dlsSample = reinterpret_cast<const RIFFDLSSample*>( ptr );
auto dlsSample = reinterpret_cast<const RIFFDLSSample*>(ptr);
if ( dlsChunk->size >= ( dlsSample->size + dlsSample->loopCount * sizeof(DLSLoop) ) )
if (dlsChunk->size >= (dlsSample->size + dlsSample->loopCount * sizeof(DLSLoop)))
{
auto loops = reinterpret_cast<const DLSLoop*>( ptr + dlsSample->size );
for( uint32_t j = 0; j < dlsSample->loopCount; ++j )
auto loops = reinterpret_cast<const DLSLoop*>(ptr + dlsSample->size);
for (uint32_t j = 0; j < dlsSample->loopCount; ++j)
{
if ( ( loops[j].loopType == DLSLoop::LOOP_TYPE_FORWARD || loops[j].loopType == DLSLoop::LOOP_TYPE_RELEASE ) )
if ((loops[j].loopType == DLSLoop::LOOP_TYPE_FORWARD || loops[j].loopType == DLSLoop::LOOP_TYPE_RELEASE))
{
// Return 'forward' loop
*pLoopStart = loops[j].loopStart;
@ -374,25 +371,25 @@ static HRESULT WaveFindLoopInfo( _In_reads_bytes_(wavDataSize) const uint8_t* wa
}
// Locate 'smpl' (Sample Chunk)
auto midiChunk = FindChunk( ptr, riffChunk->size, FOURCC_MIDI_SAMPLE );
if ( midiChunk )
auto midiChunk = FindChunk(ptr, riffChunk->size, FOURCC_MIDI_SAMPLE);
if (midiChunk)
{
ptr = reinterpret_cast<const uint8_t*>( midiChunk ) + sizeof( RIFFChunk );
if ( ptr + midiChunk->size > wavEnd )
ptr = reinterpret_cast<const uint8_t*>(midiChunk) + sizeof(RIFFChunk);
if (ptr + midiChunk->size > wavEnd)
{
return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
if ( midiChunk->size >= sizeof(RIFFMIDISample) )
if (midiChunk->size >= sizeof(RIFFMIDISample))
{
auto midiSample = reinterpret_cast<const RIFFMIDISample*>( ptr );
auto midiSample = reinterpret_cast<const RIFFMIDISample*>(ptr);
if ( midiChunk->size >= ( sizeof(RIFFMIDISample) + midiSample->loopCount * sizeof(MIDILoop) ) )
if (midiChunk->size >= (sizeof(RIFFMIDISample) + midiSample->loopCount * sizeof(MIDILoop)))
{
auto loops = reinterpret_cast<const MIDILoop*>( ptr + sizeof(RIFFMIDISample) );
for( uint32_t j = 0; j < midiSample->loopCount; ++j )
auto loops = reinterpret_cast<const MIDILoop*>(ptr + sizeof(RIFFMIDISample));
for (uint32_t j = 0; j < midiSample->loopCount; ++j)
{
if ( loops[j].type == MIDILoop::LOOP_TYPE_FORWARD )
if (loops[j].type == MIDILoop::LOOP_TYPE_FORWARD)
{
// Return 'forward' loop
*pLoopStart = loops[j].start;
@ -409,13 +406,13 @@ static HRESULT WaveFindLoopInfo( _In_reads_bytes_(wavDataSize) const uint8_t* wa
//--------------------------------------------------------------------------------------
static HRESULT WaveFindTable( _In_reads_bytes_(wavDataSize) const uint8_t* wavData, _In_ size_t wavDataSize, _In_ uint32_t tag,
_Outptr_result_maybenull_ const uint32_t** pData, _Out_ uint32_t* dataCount )
static HRESULT WaveFindTable(_In_reads_bytes_(wavDataSize) const uint8_t* wavData, _In_ size_t wavDataSize, _In_ uint32_t tag,
_Outptr_result_maybenull_ const uint32_t** pData, _Out_ uint32_t* dataCount)
{
if ( !wavData || !pData || !dataCount )
if (!wavData || !pData || !dataCount)
return E_POINTER;
if (wavDataSize < ( sizeof(RIFFChunk) + sizeof(uint32_t) ) )
if (wavDataSize < (sizeof(RIFFChunk) + sizeof(uint32_t)))
{
return E_FAIL;
}
@ -426,40 +423,40 @@ static HRESULT WaveFindTable( _In_reads_bytes_(wavDataSize) const uint8_t* wavDa
const uint8_t* wavEnd = wavData + wavDataSize;
// Locate RIFF 'WAVE'
auto riffChunk = FindChunk( wavData, wavDataSize, FOURCC_RIFF_TAG );
if ( !riffChunk || riffChunk->size < 4 )
auto riffChunk = FindChunk(wavData, wavDataSize, FOURCC_RIFF_TAG);
if (!riffChunk || riffChunk->size < 4)
{
return E_FAIL;
}
auto riffHeader = reinterpret_cast<const RIFFChunkHeader*>( riffChunk );
if ( riffHeader->riff != FOURCC_WAVE_FILE_TAG && riffHeader->riff != FOURCC_XWMA_FILE_TAG )
auto riffHeader = reinterpret_cast<const RIFFChunkHeader*>(riffChunk);
if (riffHeader->riff != FOURCC_WAVE_FILE_TAG && riffHeader->riff != FOURCC_XWMA_FILE_TAG)
{
return E_FAIL;
}
// Locate tag
auto ptr = reinterpret_cast<const uint8_t*>( riffHeader ) + sizeof(RIFFChunkHeader);
if ( ( ptr + sizeof(RIFFChunk) ) > wavEnd )
auto ptr = reinterpret_cast<const uint8_t*>(riffHeader) + sizeof(RIFFChunkHeader);
if ((ptr + sizeof(RIFFChunk)) > wavEnd)
{
return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
auto tableChunk = FindChunk( ptr, riffChunk->size, tag );
if ( tableChunk )
auto tableChunk = FindChunk(ptr, riffChunk->size, tag);
if (tableChunk)
{
ptr = reinterpret_cast<const uint8_t*>( tableChunk ) + sizeof( RIFFChunk );
if ( ptr + tableChunk->size > wavEnd )
ptr = reinterpret_cast<const uint8_t*>(tableChunk) + sizeof(RIFFChunk);
if (ptr + tableChunk->size > wavEnd)
{
return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
if ( ( tableChunk->size % sizeof(uint32_t) ) != 0 )
if ((tableChunk->size % sizeof(uint32_t)) != 0)
{
return E_FAIL;
}
*pData = reinterpret_cast<const uint32_t*>( ptr );
*pData = reinterpret_cast<const uint32_t*>(ptr);
*dataCount = tableChunk->size / 4;
}
@ -468,38 +465,38 @@ static HRESULT WaveFindTable( _In_reads_bytes_(wavDataSize) const uint8_t* wavDa
//--------------------------------------------------------------------------------------
static HRESULT LoadAudioFromFile( _In_z_ const wchar_t* szFileName, _Inout_ std::unique_ptr<uint8_t[]>& wavData, _Out_ DWORD* bytesRead )
static HRESULT LoadAudioFromFile(_In_z_ const wchar_t* szFileName, _Inout_ std::unique_ptr<uint8_t[]>& wavData, _Out_ DWORD* bytesRead)
{
if ( !szFileName )
if (!szFileName)
return E_INVALIDARG;
// open the file
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
ScopedHandle hFile( safe_handle( CreateFile2( szFileName,
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
nullptr ) ) );
ScopedHandle hFile(safe_handle(CreateFile2(szFileName,
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
nullptr)));
#else
ScopedHandle hFile( safe_handle( CreateFileW( szFileName,
GENERIC_READ,
FILE_SHARE_READ,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr ) ) );
ScopedHandle hFile(safe_handle(CreateFileW(szFileName,
GENERIC_READ,
FILE_SHARE_READ,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr)));
#endif
if ( !hFile )
if (!hFile)
{
return HRESULT_FROM_WIN32( GetLastError() );
return HRESULT_FROM_WIN32(GetLastError());
}
// Get the file size
FILE_STANDARD_INFO fileInfo;
if ( !GetFileInformationByHandleEx( hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo) ) )
if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo)))
{
return HRESULT_FROM_WIN32( GetLastError() );
return HRESULT_FROM_WIN32(GetLastError());
}
// File is too big for 32-bit allocation, so reject read
@ -509,27 +506,27 @@ static HRESULT LoadAudioFromFile( _In_z_ const wchar_t* szFileName, _Inout_ std:
}
// Need at least enough data to have a valid minimal WAV file
if (fileInfo.EndOfFile.LowPart < ( sizeof(RIFFChunk)*2 + sizeof(DWORD) + sizeof(WAVEFORMAT) ) )
if (fileInfo.EndOfFile.LowPart < (sizeof(RIFFChunk) * 2 + sizeof(DWORD) + sizeof(WAVEFORMAT)))
{
return E_FAIL;
}
// create enough space for the file data
wavData.reset( new (std::nothrow) uint8_t[ fileInfo.EndOfFile.LowPart ] );
wavData.reset(new (std::nothrow) uint8_t[fileInfo.EndOfFile.LowPart]);
if (!wavData)
{
return E_OUTOFMEMORY;
}
// read the data in
if (!ReadFile( hFile.get(),
wavData.get(),
fileInfo.EndOfFile.LowPart,
bytesRead,
nullptr
))
if (!ReadFile(hFile.get(),
wavData.get(),
fileInfo.EndOfFile.LowPart,
bytesRead,
nullptr
))
{
return HRESULT_FROM_WIN32( GetLastError() );
return HRESULT_FROM_WIN32(GetLastError());
}
return (*bytesRead < fileInfo.EndOfFile.LowPart) ? E_FAIL : S_OK;
@ -538,13 +535,13 @@ static HRESULT LoadAudioFromFile( _In_z_ const wchar_t* szFileName, _Inout_ std:
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::LoadWAVAudioInMemory( const uint8_t* wavData,
size_t wavDataSize,
const WAVEFORMATEX** wfx,
const uint8_t** startAudio,
uint32_t* audioBytes )
HRESULT DirectX::LoadWAVAudioInMemory(const uint8_t* wavData,
size_t wavDataSize,
const WAVEFORMATEX** wfx,
const uint8_t** startAudio,
uint32_t* audioBytes)
{
if ( !wavData || !wfx || !startAudio || !audioBytes )
if (!wavData || !wfx || !startAudio || !audioBytes)
return E_INVALIDARG;
*wfx = nullptr;
@ -552,14 +549,14 @@ HRESULT DirectX::LoadWAVAudioInMemory( const uint8_t* wavData,
*audioBytes = 0;
// Need at least enough data to have a valid minimal WAV file
if (wavDataSize < (sizeof(RIFFChunk)*2 + sizeof(DWORD) + sizeof(WAVEFORMAT) ) )
if (wavDataSize < (sizeof(RIFFChunk) * 2 + sizeof(DWORD) + sizeof(WAVEFORMAT)))
{
return E_FAIL;
}
bool dpds, seek;
HRESULT hr = WaveFindFormatAndData( wavData, wavDataSize, wfx, startAudio, audioBytes, dpds, seek );
if ( FAILED(hr) )
HRESULT hr = WaveFindFormatAndData(wavData, wavDataSize, wfx, startAudio, audioBytes, dpds, seek);
if (FAILED(hr))
return hr;
return (dpds || seek) ? E_FAIL : S_OK;
@ -568,13 +565,13 @@ HRESULT DirectX::LoadWAVAudioInMemory( const uint8_t* wavData,
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::LoadWAVAudioFromFile( const wchar_t* szFileName,
std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX** wfx,
const uint8_t** startAudio,
uint32_t* audioBytes )
HRESULT DirectX::LoadWAVAudioFromFile(const wchar_t* szFileName,
std::unique_ptr<uint8_t[]>& wavData,
const WAVEFORMATEX** wfx,
const uint8_t** startAudio,
uint32_t* audioBytes)
{
if ( !szFileName || !wfx || !startAudio || !audioBytes )
if (!szFileName || !wfx || !startAudio || !audioBytes)
return E_INVALIDARG;
*wfx = nullptr;
@ -582,15 +579,15 @@ HRESULT DirectX::LoadWAVAudioFromFile( const wchar_t* szFileName,
*audioBytes = 0;
DWORD bytesRead = 0;
HRESULT hr = LoadAudioFromFile( szFileName, wavData, &bytesRead );
if ( FAILED(hr) )
HRESULT hr = LoadAudioFromFile(szFileName, wavData, &bytesRead);
if (FAILED(hr))
{
return hr;
}
bool dpds, seek;
hr = WaveFindFormatAndData( wavData.get(), bytesRead, wfx, startAudio, audioBytes, dpds, seek );
if ( FAILED(hr) )
hr = WaveFindFormatAndData(wavData.get(), bytesRead, wfx, startAudio, audioBytes, dpds, seek);
if (FAILED(hr))
return hr;
return (dpds || seek) ? E_FAIL : S_OK;
@ -599,38 +596,38 @@ HRESULT DirectX::LoadWAVAudioFromFile( const wchar_t* szFileName,
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::LoadWAVAudioInMemoryEx( const uint8_t* wavData, size_t wavDataSize, DirectX::WAVData& result )
HRESULT DirectX::LoadWAVAudioInMemoryEx(const uint8_t* wavData, size_t wavDataSize, DirectX::WAVData& result)
{
if ( !wavData )
if (!wavData)
return E_INVALIDARG;
memset( &result, 0, sizeof(result) );
memset(&result, 0, sizeof(result));
// Need at least enough data to have a valid minimal WAV file
if (wavDataSize < (sizeof(RIFFChunk)*2 + sizeof(DWORD) + sizeof(WAVEFORMAT) ) )
if (wavDataSize < (sizeof(RIFFChunk) * 2 + sizeof(DWORD) + sizeof(WAVEFORMAT)))
{
return E_FAIL;
}
bool dpds, seek;
HRESULT hr = WaveFindFormatAndData( wavData, wavDataSize, &result.wfx, &result.startAudio, &result.audioBytes, dpds, seek );
if ( FAILED(hr) )
HRESULT hr = WaveFindFormatAndData(wavData, wavDataSize, &result.wfx, &result.startAudio, &result.audioBytes, dpds, seek);
if (FAILED(hr))
return hr;
hr = WaveFindLoopInfo( wavData, wavDataSize, &result.loopStart, &result.loopLength );
if ( FAILED(hr) )
hr = WaveFindLoopInfo(wavData, wavDataSize, &result.loopStart, &result.loopLength);
if (FAILED(hr))
return hr;
if ( dpds )
if (dpds)
{
hr = WaveFindTable( wavData, wavDataSize, FOURCC_XWMA_DPDS, &result.seek, &result.seekCount );
if ( FAILED(hr) )
hr = WaveFindTable(wavData, wavDataSize, FOURCC_XWMA_DPDS, &result.seek, &result.seekCount);
if (FAILED(hr))
return hr;
}
else if ( seek )
else if (seek)
{
hr = WaveFindTable( wavData, wavDataSize, FOURCC_XMA_SEEK, &result.seek, &result.seekCount );
if ( FAILED(hr) )
hr = WaveFindTable(wavData, wavDataSize, FOURCC_XMA_SEEK, &result.seek, &result.seekCount);
if (FAILED(hr))
return hr;
}
@ -640,39 +637,39 @@ HRESULT DirectX::LoadWAVAudioInMemoryEx( const uint8_t* wavData, size_t wavDataS
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::LoadWAVAudioFromFileEx( const wchar_t* szFileName, std::unique_ptr<uint8_t[]>& wavData, DirectX::WAVData& result )
HRESULT DirectX::LoadWAVAudioFromFileEx(const wchar_t* szFileName, std::unique_ptr<uint8_t[]>& wavData, DirectX::WAVData& result)
{
if ( !szFileName )
if (!szFileName)
return E_INVALIDARG;
memset( &result, 0, sizeof(result) );
memset(&result, 0, sizeof(result));
DWORD bytesRead = 0;
HRESULT hr = LoadAudioFromFile( szFileName, wavData, &bytesRead );
if ( FAILED(hr) )
HRESULT hr = LoadAudioFromFile(szFileName, wavData, &bytesRead);
if (FAILED(hr))
{
return hr;
}
bool dpds, seek;
hr = WaveFindFormatAndData( wavData.get(), bytesRead, &result.wfx, &result.startAudio, &result.audioBytes, dpds, seek );
if ( FAILED(hr) )
hr = WaveFindFormatAndData(wavData.get(), bytesRead, &result.wfx, &result.startAudio, &result.audioBytes, dpds, seek);
if (FAILED(hr))
return hr;
hr = WaveFindLoopInfo( wavData.get(), bytesRead, &result.loopStart, &result.loopLength );
if ( FAILED(hr) )
hr = WaveFindLoopInfo(wavData.get(), bytesRead, &result.loopStart, &result.loopLength);
if (FAILED(hr))
return hr;
if ( dpds )
if (dpds)
{
hr = WaveFindTable( wavData.get(), bytesRead, FOURCC_XWMA_DPDS, &result.seek, &result.seekCount );
if ( FAILED(hr) )
hr = WaveFindTable(wavData.get(), bytesRead, FOURCC_XWMA_DPDS, &result.seek, &result.seekCount);
if (FAILED(hr))
return hr;
}
else if ( seek )
else if (seek)
{
hr = WaveFindTable( wavData.get(), bytesRead, FOURCC_XMA_SEEK, &result.seek, &result.seekCount );
if ( FAILED(hr) )
hr = WaveFindTable(wavData.get(), bytesRead, FOURCC_XMA_SEEK, &result.seek, &result.seekCount);
if (FAILED(hr))
return hr;
}

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

@ -3,14 +3,11 @@
//
// Functions for loading WAV audio files
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//-------------------------------------------------------------------------------------
#pragma once
@ -23,17 +20,17 @@
namespace DirectX
{
HRESULT LoadWAVAudioInMemory( _In_reads_bytes_(wavDataSize) const uint8_t* wavData,
_In_ size_t wavDataSize,
_Outptr_ const WAVEFORMATEX** wfx,
_Outptr_ const uint8_t** startAudio,
_Out_ uint32_t* audioBytes );
HRESULT LoadWAVAudioInMemory(_In_reads_bytes_(wavDataSize) const uint8_t* wavData,
_In_ size_t wavDataSize,
_Outptr_ const WAVEFORMATEX** wfx,
_Outptr_ const uint8_t** startAudio,
_Out_ uint32_t* audioBytes);
HRESULT LoadWAVAudioFromFile( _In_z_ const wchar_t* szFileName,
_Inout_ std::unique_ptr<uint8_t[]>& wavData,
_Outptr_ const WAVEFORMATEX** wfx,
_Outptr_ const uint8_t** startAudio,
_Out_ uint32_t* audioBytes );
HRESULT LoadWAVAudioFromFile(_In_z_ const wchar_t* szFileName,
_Inout_ std::unique_ptr<uint8_t[]>& wavData,
_Outptr_ const WAVEFORMATEX** wfx,
_Outptr_ const uint8_t** startAudio,
_Out_ uint32_t* audioBytes);
struct WAVData
{
@ -46,10 +43,10 @@ namespace DirectX
uint32_t seekCount;
};
HRESULT LoadWAVAudioInMemoryEx( _In_reads_bytes_(wavDataSize) const uint8_t* wavData,
_In_ size_t wavDataSize, _Out_ WAVData& result );
HRESULT LoadWAVAudioInMemoryEx(_In_reads_bytes_(wavDataSize) const uint8_t* wavData,
_In_ size_t wavDataSize, _Out_ WAVData& result);
HRESULT LoadWAVAudioFromFileEx( _In_z_ const wchar_t* szFileName,
_Inout_ std::unique_ptr<uint8_t[]>& wavData,
_Out_ WAVData& result );
HRESULT LoadWAVAudioFromFileEx(_In_z_ const wchar_t* szFileName,
_Inout_ std::unique_ptr<uint8_t[]>& wavData,
_Out_ WAVData& result);
}

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: WaveBank.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "pch.h"
@ -30,51 +27,51 @@ using namespace DirectX;
class WaveBank::Impl : public IVoiceNotify
{
public:
explicit Impl( _In_ AudioEngine* engine ) :
mEngine( engine ),
mOneShots( 0 ),
mPrepared( false ),
mStreaming( false )
explicit Impl(_In_ AudioEngine* engine) :
mEngine(engine),
mOneShots(0),
mPrepared(false),
mStreaming(false)
{
assert( mEngine != 0 );
mEngine->RegisterNotify( this, false );
assert(mEngine != 0);
mEngine->RegisterNotify(this, false);
}
virtual ~Impl()
{
if ( !mInstances.empty() )
if (!mInstances.empty())
{
DebugTrace( "WARNING: Destroying WaveBank \"%hs\" with %Iu outstanding SoundEffectInstances\n", mReader.BankName(), mInstances.size() );
DebugTrace("WARNING: Destroying WaveBank \"%hs\" with %Iu outstanding SoundEffectInstances\n", mReader.BankName(), mInstances.size());
for( auto it = mInstances.begin(); it != mInstances.end(); ++it )
for (auto it = mInstances.begin(); it != mInstances.end(); ++it)
{
assert( *it != 0 );
assert(*it != 0);
(*it)->OnDestroyParent();
}
mInstances.clear();
}
if ( mOneShots > 0 )
if (mOneShots > 0)
{
DebugTrace( "WARNING: Destroying WaveBank \"%hs\" with %u outstanding one shot effects\n", mReader.BankName(), mOneShots );
DebugTrace("WARNING: Destroying WaveBank \"%hs\" with %u outstanding one shot effects\n", mReader.BankName(), mOneShots);
}
if ( mEngine )
if (mEngine)
{
mEngine->UnregisterNotify( this, true, false );
mEngine->UnregisterNotify(this, true, false);
mEngine = nullptr;
}
}
HRESULT Initialize( _In_ AudioEngine* engine, _In_z_ const wchar_t* wbFileName );
HRESULT Initialize(_In_ AudioEngine* engine, _In_z_ const wchar_t* wbFileName);
void Play( int index, float volume, float pitch, float pan );
void Play(int index, float volume, float pitch, float pan);
// IVoiceNotify
virtual void __cdecl OnBufferEnd() override
{
InterlockedDecrement( &mOneShots );
InterlockedDecrement(&mOneShots);
}
virtual void __cdecl OnCriticalError() override
@ -104,18 +101,18 @@ public:
// No action required
}
virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const override
virtual void __cdecl GatherStatistics(AudioStatistics& stats) const override
{
stats.playingOneShots += mOneShots;
if ( !mStreaming )
if (!mStreaming)
{
stats.audioBytes += mReader.BankAudioSize();
#if defined(_XBOX_ONE) && defined(_TITLE)
if ( mReader.HasXMA() )
stats.xmaAudioBytes += mReader.BankAudioSize();
#endif
#if defined(_XBOX_ONE) && defined(_TITLE)
if (mReader.HasXMA())
stats.xmaAudioBytes += mReader.BankAudioSize();
#endif
}
}
@ -129,13 +126,13 @@ public:
_Use_decl_annotations_
HRESULT WaveBank::Impl::Initialize( AudioEngine* engine, const wchar_t* wbFileName )
HRESULT WaveBank::Impl::Initialize(AudioEngine* engine, const wchar_t* wbFileName)
{
if ( !engine || !wbFileName )
if (!engine || !wbFileName)
return E_INVALIDARG;
HRESULT hr = mReader.Open( wbFileName );
if ( FAILED(hr) )
HRESULT hr = mReader.Open(wbFileName);
if (FAILED(hr))
return hr;
mStreaming = mReader.IsStreamingBank();
@ -144,75 +141,75 @@ HRESULT WaveBank::Impl::Initialize( AudioEngine* engine, const wchar_t* wbFileNa
}
void WaveBank::Impl::Play( int index, float volume, float pitch, float pan )
void WaveBank::Impl::Play(int index, float volume, float pitch, float pan)
{
assert( volume >= -XAUDIO2_MAX_VOLUME_LEVEL && volume <= XAUDIO2_MAX_VOLUME_LEVEL );
assert( pitch >= -1.f && pitch <= 1.f );
assert( pan >= -1.f && pan <= 1.f );
assert(volume >= -XAUDIO2_MAX_VOLUME_LEVEL && volume <= XAUDIO2_MAX_VOLUME_LEVEL);
assert(pitch >= -1.f && pitch <= 1.f);
assert(pan >= -1.f && pan <= 1.f);
if ( mStreaming )
if (mStreaming)
{
DebugTrace( "ERROR: One-shots can only be created from an in-memory wave bank\n");
throw std::exception( "WaveBank::Play" );
DebugTrace("ERROR: One-shots can only be created from an in-memory wave bank\n");
throw std::exception("WaveBank::Play");
}
if ( index < 0 || uint32_t(index) >= mReader.Count() )
if (index < 0 || uint32_t(index) >= mReader.Count())
{
DebugTrace( "WARNING: Index %d not found in wave bank with only %u entries, one-shot not triggered\n", index, mReader.Count() );
DebugTrace("WARNING: Index %d not found in wave bank with only %u entries, one-shot not triggered\n", index, mReader.Count());
return;
}
if ( !mPrepared )
if (!mPrepared)
{
mReader.WaitOnPrepare();
mPrepared = true;
}
char wfxbuff[64] = {};
auto wfx = reinterpret_cast<WAVEFORMATEX*>( wfxbuff );
HRESULT hr = mReader.GetFormat( index, wfx, sizeof(wfxbuff) );
ThrowIfFailed( hr );
auto wfx = reinterpret_cast<WAVEFORMATEX*>(wfxbuff);
HRESULT hr = mReader.GetFormat(index, wfx, sizeof(wfxbuff));
ThrowIfFailed(hr);
IXAudio2SourceVoice* voice = nullptr;
mEngine->AllocateVoice( wfx, SoundEffectInstance_Default, true, &voice );
mEngine->AllocateVoice(wfx, SoundEffectInstance_Default, true, &voice);
if ( !voice )
if (!voice)
return;
if ( volume != 1.f )
if (volume != 1.f)
{
hr = voice->SetVolume( volume );
ThrowIfFailed( hr );
hr = voice->SetVolume(volume);
ThrowIfFailed(hr);
}
if ( pitch != 0.f )
if (pitch != 0.f)
{
float fr = XAudio2SemitonesToFrequencyRatio( pitch * 12.f );
float fr = XAudio2SemitonesToFrequencyRatio(pitch * 12.f);
hr = voice->SetFrequencyRatio( fr );
ThrowIfFailed( hr );
hr = voice->SetFrequencyRatio(fr);
ThrowIfFailed(hr);
}
if ( pan != 0.f )
if (pan != 0.f)
{
float matrix[16];
if ( ComputePan( pan, wfx->nChannels, matrix ) )
if (ComputePan(pan, wfx->nChannels, matrix))
{
hr = voice->SetOutputMatrix( nullptr, wfx->nChannels, mEngine->GetOutputChannels(), matrix );
ThrowIfFailed( hr );
hr = voice->SetOutputMatrix(nullptr, wfx->nChannels, mEngine->GetOutputChannels(), matrix);
ThrowIfFailed(hr);
}
}
hr = voice->Start( 0 );
ThrowIfFailed( hr );
hr = voice->Start(0);
ThrowIfFailed(hr);
XAUDIO2_BUFFER buffer = {};
hr = mReader.GetWaveData( index, &buffer.pAudioData, buffer.AudioBytes );
ThrowIfFailed( hr );
hr = mReader.GetWaveData(index, &buffer.pAudioData, buffer.AudioBytes);
ThrowIfFailed(hr);
WaveBankReader::Metadata metadata;
hr = mReader.GetMetadata( index, metadata );
ThrowIfFailed( hr );
hr = mReader.GetMetadata(index, metadata);
ThrowIfFailed(hr);
buffer.Flags = XAUDIO2_END_OF_STREAM;
buffer.pContext = this;
@ -222,27 +219,27 @@ void WaveBank::Impl::Play( int index, float volume, float pitch, float pan )
XAUDIO2_BUFFER_WMA wmaBuffer = {};
uint32_t tag;
hr = mReader.GetSeekTable( index, &wmaBuffer.pDecodedPacketCumulativeBytes, wmaBuffer.PacketCount, tag );
ThrowIfFailed( hr );
hr = mReader.GetSeekTable(index, &wmaBuffer.pDecodedPacketCumulativeBytes, wmaBuffer.PacketCount, tag);
ThrowIfFailed(hr);
if ( tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3 )
if (tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3)
{
hr = voice->SubmitSourceBuffer( &buffer, &wmaBuffer );
hr = voice->SubmitSourceBuffer(&buffer, &wmaBuffer);
}
else
#endif
#endif
{
hr = voice->SubmitSourceBuffer( &buffer, nullptr );
hr = voice->SubmitSourceBuffer(&buffer, nullptr);
}
if ( FAILED(hr) )
if (FAILED(hr))
{
DebugTrace( "ERROR: WaveBank failed (%08X) when submitting buffer:\n", hr );
DebugTrace( "\tFormat Tag %u, %u channels, %u-bit, %u Hz, %u bytes\n", wfx->wFormatTag,
wfx->nChannels, wfx->wBitsPerSample, wfx->nSamplesPerSec, metadata.lengthBytes );
throw std::exception( "SubmitSourceBuffer" );
DebugTrace("ERROR: WaveBank failed (%08X) when submitting buffer:\n", hr);
DebugTrace("\tFormat Tag %u, %u channels, %u-bit, %u Hz, %u bytes\n", wfx->wFormatTag,
wfx->nChannels, wfx->wBitsPerSample, wfx->nSamplesPerSec, metadata.lengthBytes);
throw std::exception("SubmitSourceBuffer");
}
InterlockedIncrement( &mOneShots );
InterlockedIncrement(&mOneShots);
}
@ -252,30 +249,30 @@ void WaveBank::Impl::Play( int index, float volume, float pitch, float pan )
// Public constructors.
_Use_decl_annotations_
WaveBank::WaveBank( AudioEngine* engine, const wchar_t* wbFileName )
: pImpl(new Impl(engine) )
WaveBank::WaveBank(AudioEngine* engine, const wchar_t* wbFileName)
: pImpl(std::make_unique<Impl>(engine))
{
HRESULT hr = pImpl->Initialize( engine, wbFileName );
if ( FAILED(hr) )
HRESULT hr = pImpl->Initialize(engine, wbFileName);
if (FAILED(hr))
{
DebugTrace( "ERROR: WaveBank failed (%08X) to intialize from .xwb file \"%ls\"\n", hr, wbFileName );
throw std::exception( "WaveBank" );
DebugTrace("ERROR: WaveBank failed (%08X) to intialize from .xwb file \"%ls\"\n", hr, wbFileName);
throw std::exception("WaveBank");
}
DebugTrace( "INFO: WaveBank \"%hs\" with %u entries loaded from .xwb file \"%ls\"\n",
pImpl->mReader.BankName(), pImpl->mReader.Count(), wbFileName );
DebugTrace("INFO: WaveBank \"%hs\" with %u entries loaded from .xwb file \"%ls\"\n",
pImpl->mReader.BankName(), pImpl->mReader.Count(), wbFileName);
}
// Move constructor.
WaveBank::WaveBank(WaveBank&& moveFrom)
: pImpl(std::move(moveFrom.pImpl))
WaveBank::WaveBank(WaveBank&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
WaveBank& WaveBank::operator= (WaveBank&& moveFrom)
WaveBank& WaveBank::operator= (WaveBank&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;
@ -289,103 +286,103 @@ WaveBank::~WaveBank()
// Public methods.
void WaveBank::Play( int index )
void WaveBank::Play(int index)
{
pImpl->Play( index, 1.f, 0.f, 0.f );
pImpl->Play(index, 1.f, 0.f, 0.f);
}
void WaveBank::Play( int index, float volume, float pitch, float pan )
void WaveBank::Play(int index, float volume, float pitch, float pan)
{
pImpl->Play( index, volume, pitch, pan );
pImpl->Play(index, volume, pitch, pan);
}
void WaveBank::Play( _In_z_ const char* name )
void WaveBank::Play(_In_z_ const char* name)
{
int index = static_cast<int>( pImpl->mReader.Find( name ) );
if ( index == -1 )
int index = static_cast<int>(pImpl->mReader.Find(name));
if (index == -1)
{
DebugTrace( "WARNING: Name '%hs' not found in wave bank, one-shot not triggered\n", name );
DebugTrace("WARNING: Name '%hs' not found in wave bank, one-shot not triggered\n", name);
return;
}
pImpl->Play( index, 1.f, 0.f, 0.f );
pImpl->Play(index, 1.f, 0.f, 0.f);
}
void WaveBank::Play( _In_z_ const char* name, float volume, float pitch, float pan )
void WaveBank::Play(_In_z_ const char* name, float volume, float pitch, float pan)
{
int index = static_cast<int>( pImpl->mReader.Find( name ) );
if ( index == -1 )
int index = static_cast<int>(pImpl->mReader.Find(name));
if (index == -1)
{
DebugTrace( "WARNING: Name '%hs' not found in wave bank, one-shot not triggered\n", name );
DebugTrace("WARNING: Name '%hs' not found in wave bank, one-shot not triggered\n", name);
return;
}
pImpl->Play( index, volume, pitch, pan );
pImpl->Play(index, volume, pitch, pan);
}
std::unique_ptr<SoundEffectInstance> WaveBank::CreateInstance( int index, SOUND_EFFECT_INSTANCE_FLAGS flags )
std::unique_ptr<SoundEffectInstance> WaveBank::CreateInstance(int index, SOUND_EFFECT_INSTANCE_FLAGS flags)
{
auto& wb = pImpl->mReader;
if ( pImpl->mStreaming )
if (pImpl->mStreaming)
{
DebugTrace( "ERROR: SoundEffectInstances can only be created from an in-memory wave bank\n");
throw std::exception( "WaveBank::CreateInstance" );
DebugTrace("ERROR: SoundEffectInstances can only be created from an in-memory wave bank\n");
throw std::exception("WaveBank::CreateInstance");
}
if ( index < 0 || uint32_t(index) >= wb.Count() )
if (index < 0 || uint32_t(index) >= wb.Count())
{
// We don't throw an exception here as titles often simply ignore missing assets rather than fail
return std::unique_ptr<SoundEffectInstance>();
}
if ( !pImpl->mPrepared )
if (!pImpl->mPrepared)
{
wb.WaitOnPrepare();
pImpl->mPrepared = true;
}
auto effect = new SoundEffectInstance( pImpl->mEngine, this, index, flags );
assert( effect != 0 );
pImpl->mInstances.emplace_back( effect );
return std::unique_ptr<SoundEffectInstance>( effect );
auto effect = new SoundEffectInstance(pImpl->mEngine, this, index, flags);
assert(effect != 0);
pImpl->mInstances.emplace_back(effect);
return std::unique_ptr<SoundEffectInstance>(effect);
}
std::unique_ptr<SoundEffectInstance> WaveBank::CreateInstance( _In_z_ const char* name, SOUND_EFFECT_INSTANCE_FLAGS flags )
std::unique_ptr<SoundEffectInstance> WaveBank::CreateInstance(_In_z_ const char* name, SOUND_EFFECT_INSTANCE_FLAGS flags)
{
int index = static_cast<int>( pImpl->mReader.Find( name ) );
if ( index == -1 )
int index = static_cast<int>(pImpl->mReader.Find(name));
if (index == -1)
{
// We don't throw an exception here as titles often simply ignore missing assets rather than fail
return std::unique_ptr<SoundEffectInstance>();
}
return CreateInstance( index, flags );
return CreateInstance(index, flags);
}
void WaveBank::UnregisterInstance( _In_ SoundEffectInstance* instance )
void WaveBank::UnregisterInstance(_In_ SoundEffectInstance* instance)
{
auto it = std::find( pImpl->mInstances.begin(), pImpl->mInstances.end(), instance );
if ( it == pImpl->mInstances.end() )
auto it = std::find(pImpl->mInstances.begin(), pImpl->mInstances.end(), instance);
if (it == pImpl->mInstances.end())
return;
pImpl->mInstances.erase( it );
pImpl->mInstances.erase(it);
}
// Public accessors.
bool WaveBank::IsPrepared() const
{
if ( pImpl->mPrepared )
if (pImpl->mPrepared)
return true;
if ( !pImpl->mReader.IsPrepared() )
if (!pImpl->mReader.IsPrepared())
return false;
pImpl->mPrepared = true;
@ -395,7 +392,7 @@ bool WaveBank::IsPrepared() const
bool WaveBank::IsInUse() const
{
return ( pImpl->mOneShots > 0 ) || !pImpl->mInstances.empty();
return (pImpl->mOneShots > 0) || !pImpl->mInstances.empty();
}
@ -405,104 +402,104 @@ bool WaveBank::IsStreamingBank() const
}
size_t WaveBank::GetSampleSizeInBytes( int index ) const
size_t WaveBank::GetSampleSizeInBytes(int index) const
{
if ( index < 0 || uint32_t(index) >= pImpl->mReader.Count() )
if (index < 0 || uint32_t(index) >= pImpl->mReader.Count())
return 0;
WaveBankReader::Metadata metadata;
HRESULT hr = pImpl->mReader.GetMetadata( index, metadata );
ThrowIfFailed( hr );
HRESULT hr = pImpl->mReader.GetMetadata(index, metadata);
ThrowIfFailed(hr);
return metadata.lengthBytes;
}
size_t WaveBank::GetSampleDuration( int index ) const
size_t WaveBank::GetSampleDuration(int index) const
{
if ( index < 0 || uint32_t(index) >= pImpl->mReader.Count() )
if (index < 0 || uint32_t(index) >= pImpl->mReader.Count())
return 0;
WaveBankReader::Metadata metadata;
HRESULT hr = pImpl->mReader.GetMetadata( index, metadata );
ThrowIfFailed( hr );
HRESULT hr = pImpl->mReader.GetMetadata(index, metadata);
ThrowIfFailed(hr);
return metadata.duration;
}
size_t WaveBank::GetSampleDurationMS( int index ) const
size_t WaveBank::GetSampleDurationMS(int index) const
{
if ( index < 0 || uint32_t(index) >= pImpl->mReader.Count() )
if (index < 0 || uint32_t(index) >= pImpl->mReader.Count())
return 0;
char buff[64] = {};
auto wfx = reinterpret_cast<WAVEFORMATEX*>( buff );
HRESULT hr = pImpl->mReader.GetFormat( index, wfx, sizeof(buff) );
ThrowIfFailed( hr );
auto wfx = reinterpret_cast<WAVEFORMATEX*>(buff);
HRESULT hr = pImpl->mReader.GetFormat(index, wfx, sizeof(buff));
ThrowIfFailed(hr);
WaveBankReader::Metadata metadata;
hr = pImpl->mReader.GetMetadata( index, metadata );
ThrowIfFailed( hr );
return static_cast<size_t>( ( uint64_t(metadata.duration) * 1000 ) / wfx->nSamplesPerSec );
hr = pImpl->mReader.GetMetadata(index, metadata);
ThrowIfFailed(hr);
return static_cast<size_t>((uint64_t(metadata.duration) * 1000) / wfx->nSamplesPerSec);
}
_Use_decl_annotations_
const WAVEFORMATEX* WaveBank::GetFormat( int index, WAVEFORMATEX* wfx, size_t maxsize ) const
const WAVEFORMATEX* WaveBank::GetFormat(int index, WAVEFORMATEX* wfx, size_t maxsize) const
{
if ( index < 0 || uint32_t(index) >= pImpl->mReader.Count() )
if (index < 0 || uint32_t(index) >= pImpl->mReader.Count())
return nullptr;
HRESULT hr = pImpl->mReader.GetFormat( index, wfx, maxsize );
ThrowIfFailed( hr );
HRESULT hr = pImpl->mReader.GetFormat(index, wfx, maxsize);
ThrowIfFailed(hr);
return wfx;
}
_Use_decl_annotations_
int WaveBank::Find( const char* name ) const
int WaveBank::Find(const char* name) const
{
return static_cast<int>( pImpl->mReader.Find( name ) );
return static_cast<int>(pImpl->mReader.Find(name));
}
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
_Use_decl_annotations_
bool WaveBank::FillSubmitBuffer( int index, XAUDIO2_BUFFER& buffer, XAUDIO2_BUFFER_WMA& wmaBuffer ) const
bool WaveBank::FillSubmitBuffer(int index, XAUDIO2_BUFFER& buffer, XAUDIO2_BUFFER_WMA& wmaBuffer) const
{
memset( &buffer, 0, sizeof(buffer) );
memset( &wmaBuffer, 0, sizeof(wmaBuffer) );
memset(&buffer, 0, sizeof(buffer));
memset(&wmaBuffer, 0, sizeof(wmaBuffer));
HRESULT hr = pImpl->mReader.GetWaveData( index, &buffer.pAudioData, buffer.AudioBytes );
ThrowIfFailed( hr );
HRESULT hr = pImpl->mReader.GetWaveData(index, &buffer.pAudioData, buffer.AudioBytes);
ThrowIfFailed(hr);
WaveBankReader::Metadata metadata;
hr = pImpl->mReader.GetMetadata( index, metadata );
ThrowIfFailed( hr );
hr = pImpl->mReader.GetMetadata(index, metadata);
ThrowIfFailed(hr);
buffer.LoopBegin = metadata.loopStart;
buffer.LoopLength = metadata.loopLength;
uint32_t tag;
hr = pImpl->mReader.GetSeekTable( index, &wmaBuffer.pDecodedPacketCumulativeBytes, wmaBuffer.PacketCount, tag );
ThrowIfFailed( hr );
hr = pImpl->mReader.GetSeekTable(index, &wmaBuffer.pDecodedPacketCumulativeBytes, wmaBuffer.PacketCount, tag);
ThrowIfFailed(hr);
return ( tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3 );
return (tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3);
}
#else
_Use_decl_annotations_
void WaveBank::FillSubmitBuffer( int index, XAUDIO2_BUFFER& buffer ) const
void WaveBank::FillSubmitBuffer(int index, XAUDIO2_BUFFER& buffer) const
{
memset( &buffer, 0, sizeof(buffer) );
memset(&buffer, 0, sizeof(buffer));
HRESULT hr = pImpl->mReader.GetWaveData( index, &buffer.pAudioData, buffer.AudioBytes );
ThrowIfFailed( hr );
HRESULT hr = pImpl->mReader.GetWaveData(index, &buffer.pAudioData, buffer.AudioBytes);
ThrowIfFailed(hr);
WaveBankReader::Metadata metadata;
hr = pImpl->mReader.GetMetadata( index, metadata );
ThrowIfFailed( hr );
hr = pImpl->mReader.GetMetadata(index, metadata);
ThrowIfFailed(hr);
buffer.LoopBegin = metadata.loopStart;
buffer.LoopLength = metadata.loopLength;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -3,14 +3,11 @@
//
// Functions for loading audio data from Wave Banks
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//-------------------------------------------------------------------------------------
#pragma once
@ -28,19 +25,19 @@ namespace DirectX
public:
WaveBankReader();
#if !defined(_MSC_VER) || _MSC_VER >= 1900
#if !defined(_MSC_VER) || _MSC_VER >= 1900
WaveBankReader(WaveBankReader&&) = default;
WaveBankReader& operator= (WaveBankReader&&) = default;
#endif
#endif
WaveBankReader(WaveBankReader const&) = delete;
WaveBankReader& operator= (WaveBankReader const&) = delete;
~WaveBankReader();
HRESULT Open( _In_z_ const wchar_t* szFileName );
HRESULT Open(_In_z_ const wchar_t* szFileName);
uint32_t Find( _In_z_ const char* name ) const;
uint32_t Find(_In_z_ const char* name) const;
bool IsPrepared();
void WaitOnPrepare();
@ -48,9 +45,9 @@ namespace DirectX
bool HasNames() const;
bool IsStreamingBank() const;
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
bool HasXMA() const;
#endif
#endif
const char* BankName() const;
@ -58,11 +55,11 @@ namespace DirectX
uint32_t BankAudioSize() const;
HRESULT GetFormat( _In_ uint32_t index, _Out_writes_bytes_(maxsize) WAVEFORMATEX* pFormat, _In_ size_t maxsize ) const;
HRESULT GetFormat(_In_ uint32_t index, _Out_writes_bytes_(maxsize) WAVEFORMATEX* pFormat, _In_ size_t maxsize) const;
HRESULT GetWaveData( _In_ uint32_t index, _Outptr_ const uint8_t** pData, _Out_ uint32_t& dataSize ) const;
HRESULT GetWaveData(_In_ uint32_t index, _Outptr_ const uint8_t** pData, _Out_ uint32_t& dataSize) const;
HRESULT GetSeekTable( _In_ uint32_t index, _Out_ const uint32_t** pData, _Out_ uint32_t& dataCount, _Out_ uint32_t& tag ) const;
HRESULT GetSeekTable(_In_ uint32_t index, _Out_ const uint32_t** pData, _Out_ uint32_t& dataCount, _Out_ uint32_t& tag) const;
HANDLE GetAsyncHandle() const;
@ -74,7 +71,7 @@ namespace DirectX
uint32_t offsetBytes;
uint32_t lengthBytes;
};
HRESULT GetMetadata( _In_ uint32_t index, _Out_ Metadata& metadata ) const;
HRESULT GetMetadata(_In_ uint32_t index, _Out_ Metadata& metadata) const;
private:
// Private implementation.

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

@ -1,651 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Audio\SoundCommon.h" />
<ClInclude Include="Audio\WaveBankReader.h" />
<ClInclude Include="Audio\WAVFileReader.h" />
<ClInclude Include="Inc\Audio.h" />
<ClInclude Include="Inc\CommonStates.h" />
<ClInclude Include="Inc\DDSTextureLoader.h" />
<ClInclude Include="Inc\DirectXHelpers.h" />
<ClInclude Include="Inc\Effects.h" />
<ClInclude Include="Inc\GamePad.h" />
<ClInclude Include="Inc\GeometricPrimitive.h" />
<ClInclude Include="Inc\GraphicsMemory.h" />
<ClInclude Include="Inc\Keyboard.h" />
<ClInclude Include="Inc\Model.h" />
<ClInclude Include="Inc\Mouse.h" />
<ClInclude Include="Inc\PostProcess.h" />
<ClInclude Include="Inc\SimpleMath.h" />
<ClInclude Include="Inc\SimpleMath.inl" />
<ClInclude Include="Inc\ScreenGrab.h" />
<ClInclude Include="Inc\SpriteBatch.h" />
<ClInclude Include="Inc\PrimitiveBatch.h" />
<ClInclude Include="Inc\SpriteFont.h" />
<ClInclude Include="Inc\VertexTypes.h" />
<ClInclude Include="Inc\WICTextureLoader.h" />
<ClInclude Include="Src\AlignedNew.h" />
<ClInclude Include="Src\Bezier.h" />
<ClInclude Include="Src\ConstantBuffer.h" />
<ClInclude Include="Src\BinaryReader.h" />
<ClInclude Include="Src\DemandCreate.h" />
<ClInclude Include="Src\EffectCommon.h" />
<ClInclude Include="Src\Geometry.h" />
<ClInclude Include="Src\LoaderHelpers.h" />
<ClInclude Include="Src\pch.h" />
<ClInclude Include="Src\PlatformHelpers.h" />
<ClInclude Include="Src\SDKMesh.h" />
<ClInclude Include="Src\SharedResourcePool.h" />
<ClInclude Include="Src\DDS.h" />
<ClInclude Include="Src\vbo.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Audio\AudioEngine.cpp" />
<ClCompile Include="Audio\DynamicSoundEffectInstance.cpp" />
<ClCompile Include="Audio\SoundCommon.cpp" />
<ClCompile Include="Audio\SoundEffect.cpp" />
<ClCompile Include="Audio\SoundEffectInstance.cpp" />
<ClCompile Include="Audio\WaveBank.cpp" />
<ClCompile Include="Audio\WaveBankReader.cpp" />
<ClCompile Include="Audio\WAVFileReader.cpp" />
<ClCompile Include="Src\AlphaTestEffect.cpp" />
<ClCompile Include="Src\BasicEffect.cpp" />
<ClCompile Include="Src\BasicPostProcess.cpp" />
<ClCompile Include="Src\CommonStates.cpp" />
<ClCompile Include="Src\DDSTextureLoader.cpp" />
<ClCompile Include="Src\DebugEffect.cpp" />
<ClCompile Include="Src\DGSLEffect.cpp" />
<ClCompile Include="Src\DGSLEffectFactory.cpp" />
<ClCompile Include="Src\DualPostProcess.cpp" />
<ClCompile Include="Src\DualTextureEffect.cpp" />
<ClCompile Include="Src\BinaryReader.cpp" />
<ClCompile Include="Src\EffectCommon.cpp" />
<ClCompile Include="Src\EffectFactory.cpp" />
<ClCompile Include="Src\EnvironmentMapEffect.cpp" />
<ClCompile Include="Src\GamePad.cpp" />
<ClCompile Include="Src\GeometricPrimitive.cpp" />
<ClCompile Include="Src\Geometry.cpp" />
<ClCompile Include="Src\GraphicsMemory.cpp" />
<ClCompile Include="Src\Keyboard.cpp" />
<ClCompile Include="Src\Model.cpp" />
<ClCompile Include="Src\ModelLoadCMO.cpp" />
<ClCompile Include="Src\ModelLoadSDKMESH.cpp" />
<ClCompile Include="Src\ModelLoadVBO.cpp" />
<ClCompile Include="Src\Mouse.cpp" />
<ClCompile Include="Src\NormalMapEffect.cpp" />
<ClCompile Include="Src\PBREffect.cpp" />
<ClCompile Include="Src\pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Src\ScreenGrab.cpp" />
<ClCompile Include="Src\SimpleMath.cpp" />
<ClCompile Include="Src\SkinnedEffect.cpp" />
<ClCompile Include="Src\SpriteBatch.cpp" />
<ClCompile Include="Src\PrimitiveBatch.cpp" />
<ClCompile Include="Src\SpriteFont.cpp" />
<ClCompile Include="Src\ToneMapPostProcess.cpp" />
<ClCompile Include="Src\VertexTypes.cpp" />
<ClCompile Include="Src\WICTextureLoader.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="Readme.txt" />
<None Include="Src\Shaders\Common.fxh" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestEqNe.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestEqNe.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestEqNeNoFog.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestEqNeNoFog.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestLtGt.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestLtGt.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestLtGtNoFog.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestLtGtNoFog.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTest.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTest.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestNoFog.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestNoFog.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestVc.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestVc.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestVcNoFog.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestVcNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasic.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasic.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicPixelLightingTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicPixelLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicTxNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicTxNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLighting.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLighting.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingTxNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingTxNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasic.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasic.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLight.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLight.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxVcNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxVcNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVcNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVcNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLighting.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLighting.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingVcBn.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSHemiAmbient.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSHemiAmbient.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBBiTangents.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBBiTangents.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBNormals.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBNormals.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBTangents.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBTangents.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebug.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebug.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugBn.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugBn.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugVc.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugVc.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugVcBn.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugVcBn.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main1Bones.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main1Bones.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main1BonesVc.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main1BonesVc.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main2Bones.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main2Bones.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main2BonesVc.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main2BonesVc.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main4Bones.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main4Bones.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main4BonesVc.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main4BonesVc.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_mainVc.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_mainVc.pdb" />
<None Include="Src\Shaders\Compiled\DGSLLambert_main.inc" />
<None Include="Src\Shaders\Compiled\DGSLLambert_main.pdb" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTx.inc" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTx.pdb" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTxTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTxTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLPhong_main.inc" />
<None Include="Src\Shaders\Compiled\DGSLPhong_main.pdb" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTx.inc" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTx.pdb" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTxTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTxTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_main.inc" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_main.pdb" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTx.inc" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTx.pdb" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTxTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTxTk.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_PSDualTexture.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_PSDualTexture.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_PSDualTextureNoFog.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_PSDualTextureNoFog.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTexture.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTexture.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureNoFog.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureNoFog.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureVc.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureVc.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureVcNoFog.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureVcNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMap.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMap.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapNoFog.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingFresnel.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapSpecular.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapSpecular.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapSpecularNoFog.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapSpecularNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMap.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMap.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapBn.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapFresnel.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapFresnel.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapFresnelBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapFresnelBn.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLight.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLight.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightBn.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightFresnel.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightFresnel.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightFresnelBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightFresnelBn.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapPixelLightingBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapPixelLightingBn.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTx.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoFog.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoFog.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoFogSpec.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoSpec.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoSpec.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTx.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxBn.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxBn.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxVc.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxVc.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxVcBn.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxVcBn.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSConstant.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSConstant.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTextured.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTextured.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedEmissive.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedEmissive.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedEmissiveVelocity.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedEmissiveVelocity.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedVelocity.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedVelocity.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstant.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstant.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantBn.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantBn.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantVelocity.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantVelocity.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantVelocityBn.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantVelocityBn.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomBlur.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomBlur.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomCombine.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomCombine.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomExtract.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomExtract.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSCopy.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSCopy.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSDownScale2x2.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSDownScale2x2.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSDownScale4x4.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSDownScale4x4.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSGaussianBlur5x5.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSGaussianBlur5x5.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSMerge.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSMerge.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSMonochrome.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSMonochrome.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSSepia.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSSepia.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_VSQuad.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_VSQuad.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedVertexLighting.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedVertexLighting.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedVertexLightingNoFog.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedVertexLightingNoFog.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightFourBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightFourBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightFourBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightFourBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightOneBone.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightOneBone.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightOneBoneBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightOneBoneBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightTwoBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightTwoBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightTwoBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightTwoBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingFourBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingFourBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingFourBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingOneBone.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingOneBone.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingOneBoneBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingOneBoneBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingTwoBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingTwoBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingTwoBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingTwoBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingFourBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingFourBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingFourBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingOneBone.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingOneBone.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingOneBoneBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingOneBoneBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingTwoBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingTwoBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingTwoBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingTwoBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SpriteEffect_SpritePixelShader.inc" />
<None Include="Src\Shaders\Compiled\SpriteEffect_SpritePixelShader.pdb" />
<None Include="Src\Shaders\Compiled\SpriteEffect_SpriteVertexShader.inc" />
<None Include="Src\Shaders\Compiled\SpriteEffect_SpriteVertexShader.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSACESFilmic.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSACESFilmic.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSACESFilmic_SRGB.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSACESFilmic_SRGB.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSCopy.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSCopy.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSHDR10.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSHDR10.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSReinhard.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSReinhard.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSReinhard_SRGB.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSReinhard_SRGB.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSSaturate.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSSaturate.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSSaturate_SRGB.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSSaturate_SRGB.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PS_SRGB.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PS_SRGB.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_VSQuad.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_VSQuad.pdb" />
<None Include="Src\Shaders\CompileShaders.cmd" />
<None Include="Src\Shaders\Lighting.fxh" />
<None Include="Src\Shaders\PBRCommon.fxh" />
<None Include="Src\Shaders\PixelPacking_Velocity.hlsli" />
<None Include="Src\Shaders\SpriteEffect.fx" />
<None Include="Src\Shaders\Structures.fxh" />
<None Include="Src\Shaders\Utilities.fxh" />
<None Include="Src\TeapotData.inc" />
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\BasicEffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\AlphaTestEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DualTextureEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\EnvironmentMapEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\SkinnedEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DGSLEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DGSLLambert.hlsl">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DGSLPhong.hlsl">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DGSLUnlit.hlsl">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\NormalMapEffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\PostProcess.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\ToneMap.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\PBREffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\DebugEffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<PropertyGroup Label="Globals" />
<PropertyGroup Label="Globals">
<ProjectGuid>{E0B52AE7-E160-4D32-BF3F-910B785E5A8E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>DirectXTK</RootNamespace>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>Bin\Desktop_2015_Win10\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2015_Win10\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>Bin\Desktop_2015_Win10\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2015_Win10\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>Bin\Desktop_2015_Win10\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2015_Win10\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>Bin\Desktop_2015_Win10\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Desktop_2015_Win10\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>EnableAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WIN32_WINNT=0x0A00;_WIN7_PLATFORM_UPDATE;WIN32;_DEBUG;_LIB;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>EnableAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WIN32_WINNT=0x0A00;_WIN7_PLATFORM_UPDATE;WIN32;_DEBUG;_LIB;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_WIN32_WINNT=0x0A00;_WIN7_PLATFORM_UPDATE;WIN32;NDEBUG;_LIB;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_WIN32_WINNT=0x0A00;_WIN7_PLATFORM_UPDATE;WIN32;NDEBUG;_LIB;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Target Name="ATGEnsureShaders" BeforeTargets="PrepareForBuild">
<Exec Condition="!Exists('src/Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc')" WorkingDirectory="$(ProjectDir)src/Shaders" Command="CompileShaders" />
</Target>
</Project>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -622,6 +622,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<ForcedUsingFiles />
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -641,6 +642,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<ForcedUsingFiles />
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -660,6 +662,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<ForcedUsingFiles />
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -678,6 +681,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<ForcedUsingFiles />
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -696,6 +700,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<ForcedUsingFiles />
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -714,6 +719,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<ForcedUsingFiles />
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

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

@ -1,732 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Audio\SoundCommon.h" />
<ClInclude Include="Audio\WaveBankReader.h" />
<ClInclude Include="Audio\WAVFileReader.h" />
<ClInclude Include="Inc\Audio.h" />
<ClInclude Include="Inc\CommonStates.h" />
<ClInclude Include="Inc\DDSTextureLoader.h" />
<ClInclude Include="Inc\DirectXHelpers.h" />
<ClInclude Include="Inc\Effects.h" />
<ClInclude Include="Inc\GamePad.h" />
<ClInclude Include="Inc\GeometricPrimitive.h" />
<ClInclude Include="Inc\GraphicsMemory.h" />
<ClInclude Include="Inc\Keyboard.h" />
<ClInclude Include="Inc\Model.h" />
<ClInclude Include="Inc\Mouse.h" />
<ClInclude Include="Inc\PostProcess.h" />
<ClInclude Include="Inc\PrimitiveBatch.h" />
<ClInclude Include="Inc\ScreenGrab.h" />
<ClInclude Include="Inc\SimpleMath.h" />
<ClInclude Include="Inc\SpriteBatch.h" />
<ClInclude Include="Inc\SpriteFont.h" />
<ClInclude Include="Inc\VertexTypes.h" />
<ClInclude Include="Inc\WICTextureLoader.h" />
<ClInclude Include="Src\AlignedNew.h" />
<ClInclude Include="Src\Bezier.h" />
<ClInclude Include="Src\BinaryReader.h" />
<ClInclude Include="Src\ConstantBuffer.h" />
<ClInclude Include="Src\dds.h" />
<ClInclude Include="Src\DemandCreate.h" />
<ClInclude Include="Src\EffectCommon.h" />
<ClInclude Include="Src\Geometry.h" />
<ClInclude Include="Src\LoaderHelpers.h" />
<ClInclude Include="Src\pch.h" />
<ClInclude Include="Src\PlatformHelpers.h" />
<ClInclude Include="Src\SDKMesh.h" />
<ClInclude Include="Src\SharedResourcePool.h" />
<ClInclude Include="Src\vbo.h" />
</ItemGroup>
<ItemGroup>
<None Include="Inc\SimpleMath.inl" />
<None Include="Src\Shaders\Common.fxh" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestEqNe.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestEqNe.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestEqNeNoFog.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestEqNeNoFog.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestLtGt.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestLtGt.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestLtGtNoFog.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_PSAlphaTestLtGtNoFog.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTest.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTest.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestNoFog.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestNoFog.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestVc.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestVc.pdb" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestVcNoFog.inc" />
<None Include="Src\Shaders\Compiled\AlphaTestEffect_VSAlphaTestVcNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasic.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasic.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicPixelLightingTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicPixelLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicTxNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicTxNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLighting.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLighting.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingTxNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_PSBasicVertexLightingTxNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasic.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasic.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLight.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLight.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightTxVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicOneLightVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingTxVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicPixelLightingVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxVcNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicTxVcNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVcNoFog.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVcNoFog.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLighting.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLighting.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTx.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingTxVcBn.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingVc.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingVc.pdb" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingVcBn.inc" />
<None Include="Src\Shaders\Compiled\BasicEffect_VSBasicVertexLightingVcBn.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSHemiAmbient.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSHemiAmbient.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBBiTangents.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBBiTangents.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBNormals.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBNormals.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBTangents.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_PSRGBTangents.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebug.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebug.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugBn.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugBn.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugVc.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugVc.pdb" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugVcBn.inc" />
<None Include="Src\Shaders\Compiled\DebugEffect_VSDebugVcBn.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main1Bones.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main1Bones.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main1BonesVc.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main1BonesVc.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main2Bones.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main2Bones.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main2BonesVc.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main2BonesVc.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main4Bones.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main4Bones.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main4BonesVc.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_main4BonesVc.pdb" />
<None Include="Src\Shaders\Compiled\DGSLEffect_mainVc.inc" />
<None Include="Src\Shaders\Compiled\DGSLEffect_mainVc.pdb" />
<None Include="Src\Shaders\Compiled\DGSLLambert_main.inc" />
<None Include="Src\Shaders\Compiled\DGSLLambert_main.pdb" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTx.inc" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTx.pdb" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTxTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLLambert_mainTxTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLPhong_main.inc" />
<None Include="Src\Shaders\Compiled\DGSLPhong_main.pdb" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTx.inc" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTx.pdb" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTxTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLPhong_mainTxTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_main.inc" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_main.pdb" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTk.pdb" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTx.inc" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTx.pdb" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTxTk.inc" />
<None Include="Src\Shaders\Compiled\DGSLUnlit_mainTxTk.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_PSDualTexture.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_PSDualTexture.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_PSDualTextureNoFog.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_PSDualTextureNoFog.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTexture.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTexture.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureNoFog.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureNoFog.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureVc.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureVc.pdb" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureVcNoFog.inc" />
<None Include="Src\Shaders\Compiled\DualTextureEffect_VSDualTextureVcNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMap.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMap.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapNoFog.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingFresnel.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapPixelLightingNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapSpecular.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapSpecular.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapSpecularNoFog.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_PSEnvMapSpecularNoFog.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMap.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMap.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapBn.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapFresnel.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapFresnel.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapFresnelBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapFresnelBn.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLight.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLight.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightBn.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightFresnel.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightFresnel.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightFresnelBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapOneLightFresnelBn.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapPixelLightingBn.inc" />
<None Include="Src\Shaders\Compiled\EnvironmentMapEffect_VSEnvMapPixelLightingBn.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTx.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoFog.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoFog.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoFogSpec.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoSpec.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_PSNormalPixelLightingTxNoSpec.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTx.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTx.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxBn.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxBn.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxVc.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxVc.pdb" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxVcBn.inc" />
<None Include="Src\Shaders\Compiled\NormalMapEffect_VSNormalPixelLightingTxVcBn.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSConstant.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSConstant.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTextured.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTextured.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedEmissive.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedEmissive.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedEmissiveVelocity.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedEmissiveVelocity.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedVelocity.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_PSTexturedVelocity.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstant.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstant.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantBn.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantBn.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantVelocity.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantVelocity.pdb" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantVelocityBn.inc" />
<None Include="Src\Shaders\Compiled\PBREffect_VSConstantVelocityBn.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomBlur.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomBlur.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomCombine.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomCombine.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomExtract.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSBloomExtract.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSCopy.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSCopy.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSDownScale2x2.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSDownScale2x2.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSDownScale4x4.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSDownScale4x4.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSGaussianBlur5x5.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSGaussianBlur5x5.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSMerge.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSMerge.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSMonochrome.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSMonochrome.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_PSSepia.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_PSSepia.pdb" />
<None Include="Src\Shaders\Compiled\PostProcess_VSQuad.inc" />
<None Include="Src\Shaders\Compiled\PostProcess_VSQuad.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedPixelLighting.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedPixelLighting.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedVertexLighting.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedVertexLighting.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedVertexLightingNoFog.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_PSSkinnedVertexLightingNoFog.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightFourBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightFourBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightFourBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightFourBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightOneBone.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightOneBone.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightOneBoneBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightOneBoneBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightTwoBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightTwoBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightTwoBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedOneLightTwoBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingFourBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingFourBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingFourBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingOneBone.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingOneBone.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingOneBoneBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingOneBoneBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingTwoBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingTwoBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingTwoBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedPixelLightingTwoBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingFourBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingFourBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingFourBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingOneBone.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingOneBone.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingOneBoneBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingOneBoneBn.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingTwoBones.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingTwoBones.pdb" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingTwoBonesBn.inc" />
<None Include="Src\Shaders\Compiled\SkinnedEffect_VSSkinnedVertexLightingTwoBonesBn.pdb" />
<None Include="Src\Shaders\Compiled\SpriteEffect_SpritePixelShader.inc" />
<None Include="Src\Shaders\Compiled\SpriteEffect_SpritePixelShader.pdb" />
<None Include="Src\Shaders\Compiled\SpriteEffect_SpriteVertexShader.inc" />
<None Include="Src\Shaders\Compiled\SpriteEffect_SpriteVertexShader.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSACESFilmic.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSACESFilmic.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSACESFilmic_SRGB.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSACESFilmic_SRGB.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSCopy.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSCopy.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSHDR10.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSHDR10.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSReinhard.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSReinhard.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSReinhard_SRGB.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSReinhard_SRGB.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSSaturate.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSSaturate.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PSSaturate_SRGB.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PSSaturate_SRGB.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_PS_SRGB.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_PS_SRGB.pdb" />
<None Include="Src\Shaders\Compiled\ToneMap_VSQuad.inc" />
<None Include="Src\Shaders\Compiled\ToneMap_VSQuad.pdb" />
<None Include="Src\Shaders\CompileShaders.cmd" />
<None Include="Src\Shaders\Lighting.fxh" />
<None Include="Src\Shaders\PBRCommon.fxh" />
<None Include="Src\Shaders\PixelPacking_Velocity.hlsli" />
<None Include="Src\Shaders\Structures.fxh" />
<None Include="Src\Shaders\Utilities.fxh" />
<None Include="Src\TeapotData.inc" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Audio\AudioEngine.cpp" />
<ClCompile Include="Audio\DynamicSoundEffectInstance.cpp" />
<ClCompile Include="Audio\SoundCommon.cpp" />
<ClCompile Include="Audio\SoundEffect.cpp" />
<ClCompile Include="Audio\SoundEffectInstance.cpp" />
<ClCompile Include="Audio\WaveBank.cpp" />
<ClCompile Include="Audio\WaveBankReader.cpp" />
<ClCompile Include="Audio\WAVFileReader.cpp" />
<ClCompile Include="Src\AlphaTestEffect.cpp" />
<ClCompile Include="Src\BasicEffect.cpp" />
<ClCompile Include="Src\BasicPostProcess.cpp" />
<ClCompile Include="Src\BinaryReader.cpp" />
<ClCompile Include="Src\CommonStates.cpp" />
<ClCompile Include="Src\DDSTextureLoader.cpp" />
<ClCompile Include="Src\DebugEffect.cpp" />
<ClCompile Include="Src\DGSLEffect.cpp" />
<ClCompile Include="Src\DGSLEffectFactory.cpp" />
<ClCompile Include="Src\DualPostProcess.cpp" />
<ClCompile Include="Src\DualTextureEffect.cpp" />
<ClCompile Include="Src\EffectCommon.cpp" />
<ClCompile Include="Src\EffectFactory.cpp" />
<ClCompile Include="Src\EnvironmentMapEffect.cpp" />
<ClCompile Include="Src\GamePad.cpp" />
<ClCompile Include="Src\GeometricPrimitive.cpp" />
<ClCompile Include="Src\Geometry.cpp" />
<ClCompile Include="Src\GraphicsMemory.cpp" />
<ClCompile Include="Src\Keyboard.cpp" />
<ClCompile Include="Src\Model.cpp" />
<ClCompile Include="Src\ModelLoadCMO.cpp" />
<ClCompile Include="Src\ModelLoadSDKMESH.cpp" />
<ClCompile Include="Src\ModelLoadVBO.cpp" />
<ClCompile Include="Src\Mouse.cpp" />
<ClCompile Include="Src\NormalMapEffect.cpp" />
<ClCompile Include="Src\PBREffect.cpp" />
<ClCompile Include="Src\pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Src\PrimitiveBatch.cpp" />
<ClCompile Include="Src\ScreenGrab.cpp" />
<ClCompile Include="Src\SimpleMath.cpp" />
<ClCompile Include="Src\SkinnedEffect.cpp" />
<ClCompile Include="Src\SpriteBatch.cpp" />
<ClCompile Include="Src\SpriteFont.cpp" />
<ClCompile Include="Src\ToneMapPostProcess.cpp" />
<ClCompile Include="Src\VertexTypes.cpp" />
<ClCompile Include="Src\WICTextureLoader.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\AlphaTestEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\BasicEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DGSLEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DGSLLambert.hlsl">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DGSLPhong.hlsl">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DGSLUnlit.hlsl">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\DualTextureEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\EnvironmentMapEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\SkinnedEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\SpriteEffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="Readme.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\NormalMapEffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\PostProcess.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\ToneMap.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\PBREffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\DebugEffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{f4776924-619c-42c7-88b2-82c947ccc9e7}</ProjectGuid>
<Keyword>StaticLibrary</Keyword>
<ProjectName>DirectXTK</ProjectName>
<RootNamespace>DirectXTK</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.14393.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<OutDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<OutDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Bin\Windows10_2015\$(Platform)\$(Configuration)\</IntDir>
<TargetName>DirectXTK</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<CompileAsWinRT>false</CompileAsWinRT>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FloatingPointModel>Fast</FloatingPointModel>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Target Name="ATGEnsureShaders" BeforeTargets="PrepareForBuild">
<Exec Condition="!Exists('src/Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc')" WorkingDirectory="$(ProjectDir)src/Shaders" Command="CompileShaders" />
</Target>
</Project>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -604,7 +604,8 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalUsingDirectories>$(Console_SdkPackagesRoot);$(Console_SdkWindowsMetadataPath);%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<AdditionalUsingDirectories />
<ForcedUsingFiles />
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>EnableAllWarnings</WarningLevel>
@ -629,7 +630,8 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalUsingDirectories>$(Console_SdkPackagesRoot);$(Console_SdkWindowsMetadataPath);%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<AdditionalUsingDirectories />
<ForcedUsingFiles />
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>EnableAllWarnings</WarningLevel>
@ -651,7 +653,8 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeader>Use</PrecompiledHeader>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalUsingDirectories>$(Console_SdkPackagesRoot);$(Console_SdkWindowsMetadataPath);%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<AdditionalUsingDirectories />
<ForcedUsingFiles />
<WarningLevel>EnableAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>

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

@ -604,7 +604,8 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalUsingDirectories>$(Console_SdkPackagesRoot);$(Console_SdkWindowsMetadataPath);%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<AdditionalUsingDirectories />
<ForcedUsingFiles />
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>EnableAllWarnings</WarningLevel>
@ -629,7 +630,8 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalUsingDirectories>$(Console_SdkPackagesRoot);$(Console_SdkWindowsMetadataPath);%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<AdditionalUsingDirectories />
<ForcedUsingFiles />
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>EnableAllWarnings</WarningLevel>
@ -651,7 +653,8 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeader>Use</PrecompiledHeader>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalUsingDirectories>$(Console_SdkPackagesRoot);$(Console_SdkWindowsMetadataPath);%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<AdditionalUsingDirectories />
<ForcedUsingFiles />
<WarningLevel>EnableAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>

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

@ -3,14 +3,11 @@
//
// DirectXTK for Audio header
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
@ -33,9 +30,6 @@
#endif
#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
#if defined(_MSC_VER) && (_MSC_VER < 1700)
#error DirectX Tool Kit for Audio does not support VS 2010 without the DirectX SDK
#endif
#include <xaudio2.h>
#include <xaudio2fx.h>
#include <x3daudio.h>
@ -63,6 +57,7 @@
#include <string>
#include <vector>
namespace DirectX
{
class SoundEffectInstance;
@ -107,7 +102,7 @@ namespace DirectX
virtual void __cdecl OnTrim() = 0;
// Notification of a request to trim the voice pool
virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const = 0;
virtual void __cdecl GatherStatistics(AudioStatistics& stats) const = 0;
// Contribute to statistics request
};
@ -138,7 +133,7 @@ namespace DirectX
SoundEffectInstance_UseRedirectLFE = 0x10000,
};
inline SOUND_EFFECT_INSTANCE_FLAGS operator|(SOUND_EFFECT_INSTANCE_FLAGS a, SOUND_EFFECT_INSTANCE_FLAGS b) { return static_cast<SOUND_EFFECT_INSTANCE_FLAGS>( static_cast<int>(a) | static_cast<int>(b) ); }
inline SOUND_EFFECT_INSTANCE_FLAGS operator|(SOUND_EFFECT_INSTANCE_FLAGS a, SOUND_EFFECT_INSTANCE_FLAGS b) { return static_cast<SOUND_EFFECT_INSTANCE_FLAGS>(static_cast<int>(a) | static_cast<int>(b)); }
enum AUDIO_ENGINE_REVERB
{
@ -188,11 +183,12 @@ namespace DirectX
class AudioEngine
{
public:
explicit AudioEngine( AUDIO_ENGINE_FLAGS flags = AudioEngine_Default, _In_opt_ const WAVEFORMATEX* wfx = nullptr, _In_opt_z_ const wchar_t* deviceId = nullptr,
AUDIO_STREAM_CATEGORY category = AudioCategory_GameEffects );
explicit AudioEngine(
AUDIO_ENGINE_FLAGS flags = AudioEngine_Default, _In_opt_ const WAVEFORMATEX* wfx = nullptr, _In_opt_z_ const wchar_t* deviceId = nullptr,
AUDIO_STREAM_CATEGORY category = AudioCategory_GameEffects);
AudioEngine(AudioEngine&& moveFrom);
AudioEngine& operator= (AudioEngine&& moveFrom);
AudioEngine(AudioEngine&& moveFrom) throw();
AudioEngine& operator= (AudioEngine&& moveFrom) throw();
AudioEngine(AudioEngine const&) = delete;
AudioEngine& operator= (AudioEngine const&) = delete;
@ -202,7 +198,7 @@ namespace DirectX
bool __cdecl Update();
// Performs per-frame processing for the audio engine, returns false if in 'silent mode'
bool __cdecl Reset( _In_opt_ const WAVEFORMATEX* wfx = nullptr, _In_opt_z_ const wchar_t* deviceId = nullptr );
bool __cdecl Reset(_In_opt_ const WAVEFORMATEX* wfx = nullptr, _In_opt_z_ const wchar_t* deviceId = nullptr);
// Reset audio engine from critical error/silent mode using a new device; can also 'migrate' the graph
// Returns true if succesfully reset, false if in 'silent mode' due to no default device
// Note: One shots are lost, all SoundEffectInstances are in the STOPPED state after successful reset
@ -212,14 +208,14 @@ namespace DirectX
// Suspend/resumes audio processing (i.e. global pause/resume)
float __cdecl GetMasterVolume() const;
void __cdecl SetMasterVolume( float volume );
void __cdecl SetMasterVolume(float volume);
// Master volume property for all sounds
void __cdecl SetReverb( AUDIO_ENGINE_REVERB reverb );
void __cdecl SetReverb( _In_opt_ const XAUDIO2FX_REVERB_PARAMETERS* native );
void __cdecl SetReverb(AUDIO_ENGINE_REVERB reverb);
void __cdecl SetReverb(_In_opt_ const XAUDIO2FX_REVERB_PARAMETERS* native);
// Sets environmental reverb for 3D positional audio (if active)
void __cdecl SetMasteringLimit( int release, int loudness );
void __cdecl SetMasteringLimit(int release, int loudness);
// Sets the mastering volume limiter properties (if active)
AudioStatistics __cdecl GetStatistics() const;
@ -241,10 +237,10 @@ namespace DirectX
// Returns true if the audio graph is halted due to a critical error (which also places the engine into 'silent mode')
// Voice pool management.
void __cdecl SetDefaultSampleRate( int sampleRate );
void __cdecl SetDefaultSampleRate(int sampleRate);
// Sample rate for voices in the reuse pool (defaults to 44100)
void __cdecl SetMaxVoicePool( size_t maxOneShots, size_t maxInstances );
void __cdecl SetMaxVoicePool(size_t maxOneShots, size_t maxInstances);
// Maximum number of voices to allocate for one-shots and instances
// Note: one-shots over this limit are ignored; too many instance voices throws an exception
@ -252,13 +248,13 @@ namespace DirectX
// Releases any currently unused voices
// Internal-use functions
void __cdecl AllocateVoice( _In_ const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags, bool oneshot, _Outptr_result_maybenull_ IXAudio2SourceVoice** voice );
void __cdecl AllocateVoice(_In_ const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags, bool oneshot, _Outptr_result_maybenull_ IXAudio2SourceVoice** voice);
void __cdecl DestroyVoice( _In_ IXAudio2SourceVoice* voice );
void __cdecl DestroyVoice(_In_ IXAudio2SourceVoice* voice);
// Should only be called for instance voices, not one-shots
void __cdecl RegisterNotify( _In_ IVoiceNotify* notify, bool usesUpdate );
void __cdecl UnregisterNotify( _In_ IVoiceNotify* notify, bool usesOneShots, bool usesUpdate );
void __cdecl RegisterNotify(_In_ IVoiceNotify* notify, bool usesUpdate);
void __cdecl UnregisterNotify(_In_ IVoiceNotify* notify, bool usesOneShots, bool usesUpdate);
// XAudio2 interface access
IXAudio2* __cdecl GetInterface() const;
@ -287,46 +283,46 @@ namespace DirectX
class WaveBank
{
public:
WaveBank( _In_ AudioEngine* engine, _In_z_ const wchar_t* wbFileName );
WaveBank(_In_ AudioEngine* engine, _In_z_ const wchar_t* wbFileName);
WaveBank(WaveBank&& moveFrom);
WaveBank& operator= (WaveBank&& moveFrom);
WaveBank(WaveBank&& moveFrom) throw();
WaveBank& operator= (WaveBank&& moveFrom) throw();
WaveBank(WaveBank const&) = delete;
WaveBank& operator= (WaveBank const&) = delete;
virtual ~WaveBank();
void __cdecl Play( int index );
void __cdecl Play( int index, float volume, float pitch, float pan );
void __cdecl Play(int index);
void __cdecl Play(int index, float volume, float pitch, float pan);
void __cdecl Play( _In_z_ const char* name );
void __cdecl Play( _In_z_ const char* name, float volume, float pitch, float pan );
void __cdecl Play(_In_z_ const char* name);
void __cdecl Play(_In_z_ const char* name, float volume, float pitch, float pan);
std::unique_ptr<SoundEffectInstance> __cdecl CreateInstance( int index, SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default );
std::unique_ptr<SoundEffectInstance> __cdecl CreateInstance( _In_z_ const char* name, SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default );
std::unique_ptr<SoundEffectInstance> __cdecl CreateInstance(int index, SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default);
std::unique_ptr<SoundEffectInstance> __cdecl CreateInstance(_In_z_ const char* name, SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default);
bool __cdecl IsPrepared() const;
bool __cdecl IsInUse() const;
bool __cdecl IsStreamingBank() const;
size_t __cdecl GetSampleSizeInBytes( int index ) const;
// Returns size of wave audio data
size_t __cdecl GetSampleSizeInBytes(int index) const;
// Returns size of wave audio data
size_t __cdecl GetSampleDuration( int index ) const;
// Returns the duration in samples
size_t __cdecl GetSampleDuration(int index) const;
// Returns the duration in samples
size_t __cdecl GetSampleDurationMS( int index ) const;
// Returns the duration in milliseconds
size_t __cdecl GetSampleDurationMS(int index) const;
// Returns the duration in milliseconds
const WAVEFORMATEX* __cdecl GetFormat( int index, _Out_writes_bytes_(maxsize) WAVEFORMATEX* wfx, size_t maxsize ) const;
const WAVEFORMATEX* __cdecl GetFormat(int index, _Out_writes_bytes_(maxsize) WAVEFORMATEX* wfx, size_t maxsize) const;
int __cdecl Find( _In_z_ const char* name ) const;
int __cdecl Find(_In_z_ const char* name) const;
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/ )
bool __cdecl FillSubmitBuffer( int index, _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer ) const;
bool __cdecl FillSubmitBuffer(int index, _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer) const;
#else
void __cdecl FillSubmitBuffer( int index, _Out_ XAUDIO2_BUFFER& buffer ) const;
void __cdecl FillSubmitBuffer(int index, _Out_ XAUDIO2_BUFFER& buffer) const;
#endif
private:
@ -336,7 +332,7 @@ namespace DirectX
std::unique_ptr<Impl> pImpl;
// Private interface
void __cdecl UnregisterInstance( _In_ SoundEffectInstance* instance );
void __cdecl UnregisterInstance(_In_ SoundEffectInstance* instance);
friend class SoundEffectInstance;
};
@ -346,25 +342,25 @@ namespace DirectX
class SoundEffect
{
public:
SoundEffect( _In_ AudioEngine* engine, _In_z_ const wchar_t* waveFileName );
SoundEffect(_In_ AudioEngine* engine, _In_z_ const wchar_t* waveFileName);
SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes );
SoundEffect(_In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes);
SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
uint32_t loopStart, uint32_t loopLength );
SoundEffect(_In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
uint32_t loopStart, uint32_t loopLength);
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/)
SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
_In_reads_(seekCount) const uint32_t* seekTable, size_t seekCount );
SoundEffect(_In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
_In_reads_(seekCount) const uint32_t* seekTable, size_t seekCount);
#endif
SoundEffect(SoundEffect&& moveFrom);
SoundEffect& operator= (SoundEffect&& moveFrom);
SoundEffect(SoundEffect&& moveFrom) throw();
SoundEffect& operator= (SoundEffect&& moveFrom) throw();
SoundEffect(SoundEffect const&) = delete;
SoundEffect& operator= (SoundEffect const&) = delete;
@ -374,25 +370,25 @@ namespace DirectX
void __cdecl Play();
void __cdecl Play(float volume, float pitch, float pan);
std::unique_ptr<SoundEffectInstance> __cdecl CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default );
std::unique_ptr<SoundEffectInstance> __cdecl CreateInstance(SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default);
bool __cdecl IsInUse() const;
size_t __cdecl GetSampleSizeInBytes() const;
// Returns size of wave audio data
// Returns size of wave audio data
size_t __cdecl GetSampleDuration() const;
// Returns the duration in samples
// Returns the duration in samples
size_t __cdecl GetSampleDurationMS() const;
// Returns the duration in milliseconds
// Returns the duration in milliseconds
const WAVEFORMATEX* __cdecl GetFormat() const;
#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/)
bool __cdecl FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer ) const;
bool __cdecl FillSubmitBuffer(_Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer) const;
#else
void __cdecl FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer ) const;
void __cdecl FillSubmitBuffer(_Out_ XAUDIO2_BUFFER& buffer) const;
#endif
private:
@ -402,7 +398,7 @@ namespace DirectX
std::unique_ptr<Impl> pImpl;
// Private interface
void __cdecl UnregisterInstance( _In_ SoundEffectInstance* instance );
void __cdecl UnregisterInstance(_In_ SoundEffectInstance* instance);
friend class SoundEffectInstance;
};
@ -411,80 +407,80 @@ namespace DirectX
//----------------------------------------------------------------------------------
struct AudioListener : public X3DAUDIO_LISTENER
{
AudioListener()
AudioListener() throw()
{
memset( this, 0, sizeof(X3DAUDIO_LISTENER) );
memset(this, 0, sizeof(X3DAUDIO_LISTENER));
OrientFront.z = -1.f;
OrientTop.y = 1.f;
}
void XM_CALLCONV SetPosition( FXMVECTOR v )
void XM_CALLCONV SetPosition(FXMVECTOR v)
{
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Position ), v );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&Position), v);
}
void __cdecl SetPosition( const XMFLOAT3& pos )
void __cdecl SetPosition(const XMFLOAT3& pos)
{
Position.x = pos.x;
Position.y = pos.y;
Position.z = pos.z;
}
void XM_CALLCONV SetVelocity( FXMVECTOR v )
void XM_CALLCONV SetVelocity(FXMVECTOR v)
{
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Velocity ), v );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&Velocity), v);
}
void __cdecl SetVelocity( const XMFLOAT3& vel )
void __cdecl SetVelocity(const XMFLOAT3& vel)
{
Velocity.x = vel.x;
Velocity.y = vel.y;
Velocity.z = vel.z;
}
void XM_CALLCONV SetOrientation( FXMVECTOR forward, FXMVECTOR up )
void XM_CALLCONV SetOrientation(FXMVECTOR forward, FXMVECTOR up)
{
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), forward );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), up );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientFront), forward);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientTop), up);
}
void __cdecl SetOrientation( const XMFLOAT3& forward, const XMFLOAT3& up )
void __cdecl SetOrientation(const XMFLOAT3& forward, const XMFLOAT3& up)
{
OrientFront.x = forward.x; OrientTop.x = up.x;
OrientFront.y = forward.y; OrientTop.y = up.y;
OrientFront.z = forward.z; OrientTop.z = up.z;
}
void XM_CALLCONV SetOrientationFromQuaternion( FXMVECTOR quat )
void XM_CALLCONV SetOrientationFromQuaternion(FXMVECTOR quat)
{
XMVECTOR forward = XMVector3Rotate( g_XMIdentityR2, quat );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), forward );
XMVECTOR forward = XMVector3Rotate(g_XMIdentityR2, quat);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientFront), forward);
XMVECTOR up = XMVector3Rotate( g_XMIdentityR1, quat );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), up );
XMVECTOR up = XMVector3Rotate(g_XMIdentityR1, quat);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientTop), up);
}
void XM_CALLCONV Update( FXMVECTOR newPos, XMVECTOR upDir, float dt )
void XM_CALLCONV Update(FXMVECTOR newPos, XMVECTOR upDir, float dt)
// Updates velocity and orientation by tracking changes in position over time...
{
if ( dt > 0.f )
if (dt > 0.f)
{
XMVECTOR lastPos = XMLoadFloat3( reinterpret_cast<const XMFLOAT3*>( &Position ) );
XMVECTOR lastPos = XMLoadFloat3(reinterpret_cast<const XMFLOAT3*>(&Position));
XMVECTOR vDelta = ( newPos - lastPos );
XMVECTOR vDelta = (newPos - lastPos);
XMVECTOR v = vDelta / dt;
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Velocity ), v );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&Velocity), v);
vDelta = XMVector3Normalize( vDelta );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), vDelta );
vDelta = XMVector3Normalize(vDelta);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientFront), vDelta);
v = XMVector3Cross( upDir, vDelta );
v = XMVector3Normalize( v );
v = XMVector3Cross(upDir, vDelta);
v = XMVector3Normalize(v);
v = XMVector3Cross( vDelta, v );
v = XMVector3Normalize( v );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), v );
v = XMVector3Cross(vDelta, v);
v = XMVector3Normalize(v);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientTop), v);
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Position ), newPos );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&Position), newPos);
}
}
};
@ -495,17 +491,17 @@ namespace DirectX
{
float EmitterAzimuths[XAUDIO2_MAX_AUDIO_CHANNELS];
AudioEmitter()
AudioEmitter() throw()
{
memset( this, 0, sizeof(X3DAUDIO_EMITTER) );
memset( EmitterAzimuths, 0, sizeof(EmitterAzimuths) );
memset(this, 0, sizeof(X3DAUDIO_EMITTER));
memset(EmitterAzimuths, 0, sizeof(EmitterAzimuths));
OrientFront.z = -1.f;
OrientTop.y =
ChannelRadius =
CurveDistanceScaler =
DopplerScaler = 1.f;
ChannelRadius =
CurveDistanceScaler =
DopplerScaler = 1.f;
ChannelCount = 1;
pChannelAzimuths = EmitterAzimuths;
@ -513,71 +509,71 @@ namespace DirectX
InnerRadiusAngle = X3DAUDIO_PI / 4.0f;
}
void XM_CALLCONV SetPosition( FXMVECTOR v )
void XM_CALLCONV SetPosition(FXMVECTOR v)
{
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Position ), v );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&Position), v);
}
void __cdecl SetPosition( const XMFLOAT3& pos )
void __cdecl SetPosition(const XMFLOAT3& pos)
{
Position.x = pos.x;
Position.y = pos.y;
Position.z = pos.z;
}
void XM_CALLCONV SetVelocity( FXMVECTOR v )
void XM_CALLCONV SetVelocity(FXMVECTOR v)
{
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Velocity ), v );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&Velocity), v);
}
void __cdecl SetVelocity( const XMFLOAT3& vel )
void __cdecl SetVelocity(const XMFLOAT3& vel)
{
Velocity.x = vel.x;
Velocity.y = vel.y;
Velocity.z = vel.z;
}
void XM_CALLCONV SetOrientation( FXMVECTOR forward, FXMVECTOR up )
void XM_CALLCONV SetOrientation(FXMVECTOR forward, FXMVECTOR up)
{
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), forward );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), up );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientFront), forward);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientTop), up);
}
void __cdecl SetOrientation( const XMFLOAT3& forward, const XMFLOAT3& up )
void __cdecl SetOrientation(const XMFLOAT3& forward, const XMFLOAT3& up)
{
OrientFront.x = forward.x; OrientTop.x = up.x;
OrientFront.y = forward.y; OrientTop.y = up.y;
OrientFront.z = forward.z; OrientTop.z = up.z;
}
void XM_CALLCONV SetOrientationFromQuaternion( FXMVECTOR quat )
void XM_CALLCONV SetOrientationFromQuaternion(FXMVECTOR quat)
{
XMVECTOR forward = XMVector3Rotate( g_XMIdentityR2, quat );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), forward );
XMVECTOR forward = XMVector3Rotate(g_XMIdentityR2, quat);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientFront), forward);
XMVECTOR up = XMVector3Rotate( g_XMIdentityR1, quat );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), up );
XMVECTOR up = XMVector3Rotate(g_XMIdentityR1, quat);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientTop), up);
}
void XM_CALLCONV Update( FXMVECTOR newPos, XMVECTOR upDir, float dt )
void XM_CALLCONV Update(FXMVECTOR newPos, XMVECTOR upDir, float dt)
// Updates velocity and orientation by tracking changes in position over time...
{
if ( dt > 0.f )
if (dt > 0.f)
{
XMVECTOR lastPos = XMLoadFloat3( reinterpret_cast<const XMFLOAT3*>( &Position ) );
XMVECTOR lastPos = XMLoadFloat3(reinterpret_cast<const XMFLOAT3*>(&Position));
XMVECTOR vDelta = ( newPos - lastPos );
XMVECTOR vDelta = (newPos - lastPos);
XMVECTOR v = vDelta / dt;
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Velocity ), v );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&Velocity), v);
vDelta = XMVector3Normalize( vDelta );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientFront ), vDelta );
vDelta = XMVector3Normalize(vDelta);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientFront), vDelta);
v = XMVector3Cross( upDir, vDelta );
v = XMVector3Normalize( v );
v = XMVector3Cross(upDir, vDelta);
v = XMVector3Normalize(v);
v = XMVector3Cross( vDelta, v );
v = XMVector3Normalize( v );
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &OrientTop ), v );
v = XMVector3Cross(vDelta, v);
v = XMVector3Normalize(v);
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&OrientTop), v);
XMStoreFloat3( reinterpret_cast<XMFLOAT3*>( &Position ), newPos );
XMStoreFloat3(reinterpret_cast<XMFLOAT3*>(&Position), newPos);
}
}
};
@ -587,24 +583,24 @@ namespace DirectX
class SoundEffectInstance
{
public:
SoundEffectInstance(SoundEffectInstance&& moveFrom);
SoundEffectInstance& operator= (SoundEffectInstance&& moveFrom);
SoundEffectInstance(SoundEffectInstance&& moveFrom) throw();
SoundEffectInstance& operator= (SoundEffectInstance&& moveFrom) throw();
SoundEffectInstance(SoundEffectInstance const&) = delete;
SoundEffectInstance& operator= (SoundEffectInstance const&) = delete;
virtual ~SoundEffectInstance();
void __cdecl Play( bool loop = false );
void __cdecl Stop( bool immediate = true );
void __cdecl Play(bool loop = false);
void __cdecl Stop(bool immediate = true);
void __cdecl Pause();
void __cdecl Resume();
void __cdecl SetVolume( float volume );
void __cdecl SetPitch( float pitch );
void __cdecl SetPan( float pan );
void __cdecl SetVolume(float volume);
void __cdecl SetPitch(float pitch);
void __cdecl SetPan(float pan);
void __cdecl Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords = true );
void __cdecl Apply3D(const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords = true);
bool __cdecl IsLooped() const;
@ -620,11 +616,11 @@ namespace DirectX
std::unique_ptr<Impl> pImpl;
// Private constructors
SoundEffectInstance( _In_ AudioEngine* engine, _In_ SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags );
SoundEffectInstance( _In_ AudioEngine* engine, _In_ WaveBank* effect, int index, SOUND_EFFECT_INSTANCE_FLAGS flags );
SoundEffectInstance(_In_ AudioEngine* engine, _In_ SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags);
SoundEffectInstance(_In_ AudioEngine* engine, _In_ WaveBank* effect, int index, SOUND_EFFECT_INSTANCE_FLAGS flags);
friend std::unique_ptr<SoundEffectInstance> __cdecl SoundEffect::CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS );
friend std::unique_ptr<SoundEffectInstance> __cdecl WaveBank::CreateInstance( int, SOUND_EFFECT_INSTANCE_FLAGS );
friend std::unique_ptr<SoundEffectInstance> __cdecl SoundEffect::CreateInstance(SOUND_EFFECT_INSTANCE_FLAGS);
friend std::unique_ptr<SoundEffectInstance> __cdecl WaveBank::CreateInstance(int, SOUND_EFFECT_INSTANCE_FLAGS);
};
@ -632,12 +628,12 @@ namespace DirectX
class DynamicSoundEffectInstance
{
public:
DynamicSoundEffectInstance( _In_ AudioEngine* engine,
_In_opt_ std::function<void __cdecl(DynamicSoundEffectInstance*)> bufferNeeded,
int sampleRate, int channels, int sampleBits = 16,
SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default );
DynamicSoundEffectInstance(DynamicSoundEffectInstance&& moveFrom);
DynamicSoundEffectInstance& operator= (DynamicSoundEffectInstance&& moveFrom);
DynamicSoundEffectInstance(_In_ AudioEngine* engine,
_In_opt_ std::function<void __cdecl(DynamicSoundEffectInstance*)> bufferNeeded,
int sampleRate, int channels, int sampleBits = 16,
SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default);
DynamicSoundEffectInstance(DynamicSoundEffectInstance&& moveFrom) throw();
DynamicSoundEffectInstance& operator= (DynamicSoundEffectInstance&& moveFrom) throw();
DynamicSoundEffectInstance(DynamicSoundEffectInstance const&) = delete;
DynamicSoundEffectInstance& operator= (DynamicSoundEffectInstance const&) = delete;
@ -645,29 +641,29 @@ namespace DirectX
virtual ~DynamicSoundEffectInstance();
void __cdecl Play();
void __cdecl Stop( bool immediate = true );
void __cdecl Stop(bool immediate = true);
void __cdecl Pause();
void __cdecl Resume();
void __cdecl SetVolume( float volume );
void __cdecl SetPitch( float pitch );
void __cdecl SetPan( float pan );
void __cdecl SetVolume(float volume);
void __cdecl SetPitch(float pitch);
void __cdecl SetPan(float pan);
void __cdecl Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords = true );
void __cdecl Apply3D(const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords = true);
void __cdecl SubmitBuffer( _In_reads_bytes_(audioBytes) const uint8_t* pAudioData, size_t audioBytes );
void __cdecl SubmitBuffer( _In_reads_bytes_(audioBytes) const uint8_t* pAudioData, uint32_t offset, size_t audioBytes );
void __cdecl SubmitBuffer(_In_reads_bytes_(audioBytes) const uint8_t* pAudioData, size_t audioBytes);
void __cdecl SubmitBuffer(_In_reads_bytes_(audioBytes) const uint8_t* pAudioData, uint32_t offset, size_t audioBytes);
SoundState __cdecl GetState();
size_t __cdecl GetSampleDuration( size_t bytes ) const;
// Returns duration in samples of a buffer of a given size
size_t __cdecl GetSampleDuration(size_t bytes) const;
// Returns duration in samples of a buffer of a given size
size_t __cdecl GetSampleDurationMS( size_t bytes ) const;
// Returns duration in milliseconds of a buffer of a given size
size_t __cdecl GetSampleDurationMS(size_t bytes) const;
// Returns duration in milliseconds of a buffer of a given size
size_t __cdecl GetSampleSizeInBytes( uint64_t duration ) const;
// Returns size of a buffer for a duration given in milliseconds
size_t __cdecl GetSampleSizeInBytes(uint64_t duration) const;
// Returns size of a buffer for a duration given in milliseconds
int __cdecl GetPendingBufferCount() const;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: CommonStates.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -28,8 +24,8 @@ namespace DirectX
{
public:
explicit CommonStates(_In_ ID3D11Device* device);
CommonStates(CommonStates&& moveFrom);
CommonStates& operator= (CommonStates&& moveFrom);
CommonStates(CommonStates&& moveFrom) throw();
CommonStates& operator= (CommonStates&& moveFrom) throw();
CommonStates(CommonStates const&) = delete;
CommonStates& operator= (CommonStates const&) = delete;

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

@ -7,12 +7,8 @@
// a full-featured DDS file reader, writer, and texture processing pipeline see
// the 'Texconv' sample and the 'DirectXTex' library.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
// http://go.microsoft.com/fwlink/?LinkId=248929

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: DirectXHelpers.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -60,14 +56,14 @@ namespace DirectX
class MapGuard : public D3D11_MAPPED_SUBRESOURCE
{
public:
MapGuard( _In_ ID3D11DeviceContext* context,
_In_ ID3D11Resource *resource,
_In_ UINT subresource,
_In_ D3D11_MAP mapType,
_In_ UINT mapFlags )
MapGuard(_In_ ID3D11DeviceContext* context,
_In_ ID3D11Resource *resource,
_In_ UINT subresource,
_In_ D3D11_MAP mapType,
_In_ UINT mapFlags)
: mContext(context), mResource(resource), mSubresource(subresource)
{
HRESULT hr = mContext->Map( resource, subresource, mapType, mapFlags, this );
HRESULT hr = mContext->Map(resource, subresource, mapType, mapFlags, this);
if (FAILED(hr))
{
throw std::exception();
@ -76,25 +72,25 @@ namespace DirectX
~MapGuard()
{
mContext->Unmap( mResource, mSubresource );
mContext->Unmap(mResource, mSubresource);
}
uint8_t* get() const
{
return reinterpret_cast<uint8_t*>( pData );
return static_cast<uint8_t*>(pData);
}
uint8_t* get(size_t slice) const
{
return reinterpret_cast<uint8_t*>( pData ) + ( slice * DepthPitch );
return static_cast<uint8_t*>(pData) + (slice * DepthPitch);
}
uint8_t* scanline(size_t row) const
{
return reinterpret_cast<uint8_t*>( pData ) + ( row * RowPitch );
return static_cast<uint8_t*>(pData) + (row * RowPitch);
}
uint8_t* scanline(size_t slice, size_t row) const
{
return reinterpret_cast<uint8_t*>( pData ) + ( slice * DepthPitch ) + ( row * RowPitch );
return static_cast<uint8_t*>(pData) + (slice * DepthPitch) + (row * RowPitch);
}
private:
@ -114,10 +110,10 @@ 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 );
if ( result > 0 )
int result = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, TNameLength, wname, MAX_PATH);
if (result > 0)
{
resource->SetName( wname );
resource->SetName(wname);
}
#else
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
@ -136,8 +132,8 @@ namespace DirectX
resource->SetName( name );
#else
char aname[MAX_PATH];
int result = WideCharToMultiByte( CP_ACP, 0, name, TNameLength, aname, MAX_PATH, nullptr, nullptr );
if ( result > 0 )
int result = WideCharToMultiByte(CP_ACP, 0, name, TNameLength, aname, MAX_PATH, nullptr, nullptr);
if (result > 0)
{
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, aname);
}
@ -172,4 +168,4 @@ namespace DirectX
}
return size;
}
}
}

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: Effects.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -89,7 +85,7 @@ namespace DirectX
class IEffectSkinning
{
public:
virtual ~IEffectSkinning() { }
virtual ~IEffectSkinning() { }
virtual void __cdecl SetWeightsPerVertex(int value) = 0;
virtual void __cdecl SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) = 0;
@ -104,8 +100,8 @@ namespace DirectX
{
public:
explicit BasicEffect(_In_ ID3D11Device* device);
BasicEffect(BasicEffect&& moveFrom);
BasicEffect& operator= (BasicEffect&& moveFrom);
BasicEffect(BasicEffect&& moveFrom) throw();
BasicEffect& operator= (BasicEffect&& moveFrom) throw();
BasicEffect(BasicEffect const&) = delete;
BasicEffect& operator= (BasicEffect const&) = delete;
@ -131,7 +127,7 @@ namespace DirectX
void __cdecl DisableSpecular();
void __cdecl SetAlpha(float value);
void XM_CALLCONV SetColorAndAlpha(FXMVECTOR value);
// Light settings.
void __cdecl SetLightingEnabled(bool value) override;
void __cdecl SetPerPixelLighting(bool value) override;
@ -156,7 +152,7 @@ namespace DirectX
// Texture setting.
void __cdecl SetTextureEnabled(bool value);
void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
// Normal compression settings.
void __cdecl SetBiasedVertexNormals(bool value);
@ -174,8 +170,8 @@ namespace DirectX
{
public:
explicit AlphaTestEffect(_In_ ID3D11Device* device);
AlphaTestEffect(AlphaTestEffect&& moveFrom);
AlphaTestEffect& operator= (AlphaTestEffect&& moveFrom);
AlphaTestEffect(AlphaTestEffect&& moveFrom) throw();
AlphaTestEffect& operator= (AlphaTestEffect&& moveFrom) throw();
AlphaTestEffect(AlphaTestEffect const&) = delete;
AlphaTestEffect& operator= (AlphaTestEffect const&) = delete;
@ -197,7 +193,7 @@ namespace DirectX
void XM_CALLCONV SetDiffuseColor(FXMVECTOR value);
void __cdecl SetAlpha(float value);
void XM_CALLCONV SetColorAndAlpha(FXMVECTOR value);
// Fog settings.
void __cdecl SetFogEnabled(bool value) override;
void __cdecl SetFogStart(float value) override;
@ -209,7 +205,7 @@ namespace DirectX
// Texture setting.
void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
// Alpha test settings.
void __cdecl SetAlphaFunction(D3D11_COMPARISON_FUNC value);
void __cdecl SetReferenceAlpha(int value);
@ -228,8 +224,8 @@ namespace DirectX
{
public:
explicit DualTextureEffect(_In_ ID3D11Device* device);
DualTextureEffect(DualTextureEffect&& moveFrom);
DualTextureEffect& operator= (DualTextureEffect&& moveFrom);
DualTextureEffect(DualTextureEffect&& moveFrom) throw();
DualTextureEffect& operator= (DualTextureEffect&& moveFrom) throw();
DualTextureEffect(DualTextureEffect const&) = delete;
DualTextureEffect& operator= (DualTextureEffect const&) = delete;
@ -251,7 +247,7 @@ namespace DirectX
void XM_CALLCONV SetDiffuseColor(FXMVECTOR value);
void __cdecl SetAlpha(float value);
void XM_CALLCONV SetColorAndAlpha(FXMVECTOR value);
// Fog settings.
void __cdecl SetFogEnabled(bool value) override;
void __cdecl SetFogStart(float value) override;
@ -264,7 +260,7 @@ namespace DirectX
// Texture settings.
void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
void __cdecl SetTexture2(_In_opt_ ID3D11ShaderResourceView* value);
private:
// Private implementation.
class Impl;
@ -279,8 +275,8 @@ namespace DirectX
{
public:
explicit EnvironmentMapEffect(_In_ ID3D11Device* device);
EnvironmentMapEffect(EnvironmentMapEffect&& moveFrom);
EnvironmentMapEffect& operator= (EnvironmentMapEffect&& moveFrom);
EnvironmentMapEffect(EnvironmentMapEffect&& moveFrom) throw();
EnvironmentMapEffect& operator= (EnvironmentMapEffect&& moveFrom) throw();
EnvironmentMapEffect(EnvironmentMapEffect const&) = delete;
EnvironmentMapEffect& operator= (EnvironmentMapEffect const&) = delete;
@ -303,7 +299,7 @@ namespace DirectX
void XM_CALLCONV SetEmissiveColor(FXMVECTOR value);
void __cdecl SetAlpha(float value);
void XM_CALLCONV SetColorAndAlpha(FXMVECTOR value);
// Light settings.
void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override;
@ -350,8 +346,8 @@ namespace DirectX
{
public:
explicit SkinnedEffect(_In_ ID3D11Device* device);
SkinnedEffect(SkinnedEffect&& moveFrom);
SkinnedEffect& operator= (SkinnedEffect&& moveFrom);
SkinnedEffect(SkinnedEffect&& moveFrom) throw();
SkinnedEffect& operator= (SkinnedEffect&& moveFrom) throw();
SkinnedEffect(SkinnedEffect const&) = delete;
SkinnedEffect& operator= (SkinnedEffect const&) = delete;
@ -377,7 +373,7 @@ namespace DirectX
void __cdecl DisableSpecular();
void __cdecl SetAlpha(float value);
void XM_CALLCONV SetColorAndAlpha(FXMVECTOR value);
// Light settings.
void __cdecl SetPerPixelLighting(bool value) override;
void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override;
@ -397,7 +393,7 @@ namespace DirectX
// Texture setting.
void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value);
// Animation settings.
void __cdecl SetWeightsPerVertex(int value) override;
void __cdecl SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) override;
@ -421,10 +417,10 @@ namespace DirectX
class DGSLEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectSkinning
{
public:
explicit DGSLEffect( _In_ ID3D11Device* device, _In_opt_ ID3D11PixelShader* pixelShader = nullptr,
_In_ bool enableSkinning = false );
DGSLEffect(DGSLEffect&& moveFrom);
DGSLEffect& operator= (DGSLEffect&& moveFrom);
explicit DGSLEffect(_In_ ID3D11Device* device, _In_opt_ ID3D11PixelShader* pixelShader = nullptr,
_In_ bool enableSkinning = false);
DGSLEffect(DGSLEffect&& moveFrom) throw();
DGSLEffect& operator= (DGSLEffect&& moveFrom) throw();
DGSLEffect(DGSLEffect const&) = delete;
DGSLEffect& operator= (DGSLEffect const&) = delete;
@ -454,8 +450,8 @@ namespace DirectX
// Additional settings.
void XM_CALLCONV SetUVTransform(FXMMATRIX value);
void __cdecl SetViewport( float width, float height );
void __cdecl SetTime( float time );
void __cdecl SetViewport(float width, float height);
void __cdecl SetTime(float time);
void __cdecl SetAlphaDiscardEnable(bool value);
// Light settings.
@ -502,8 +498,8 @@ namespace DirectX
{
public:
explicit NormalMapEffect(_In_ ID3D11Device* device);
NormalMapEffect(NormalMapEffect&& moveFrom);
NormalMapEffect& operator= (NormalMapEffect&& moveFrom);
NormalMapEffect(NormalMapEffect&& moveFrom) throw();
NormalMapEffect& operator= (NormalMapEffect&& moveFrom) throw();
NormalMapEffect(NormalMapEffect const&) = delete;
NormalMapEffect& operator= (NormalMapEffect const&) = delete;
@ -574,8 +570,8 @@ namespace DirectX
{
public:
explicit PBREffect(_In_ ID3D11Device* device);
PBREffect(PBREffect&& moveFrom);
PBREffect& operator= (PBREffect&& moveFrom);
PBREffect(PBREffect&& moveFrom) throw();
PBREffect& operator= (PBREffect&& moveFrom) throw();
PBREffect(PBREffect const&) = delete;
PBREffect& operator= (PBREffect const&) = delete;
@ -655,8 +651,8 @@ namespace DirectX
};
explicit DebugEffect(_In_ ID3D11Device* device);
DebugEffect(DebugEffect&& moveFrom);
DebugEffect& operator= (DebugEffect&& moveFrom);
DebugEffect(DebugEffect&& moveFrom) throw();
DebugEffect& operator= (DebugEffect&& moveFrom) throw();
DebugEffect(DebugEffect const&) = delete;
DebugEffect& operator= (DebugEffect const&) = delete;
@ -717,12 +713,12 @@ namespace DirectX
const wchar_t* specularTexture;
const wchar_t* normalTexture;
EffectInfo() { memset( this, 0, sizeof(EffectInfo) ); };
EffectInfo() throw() { memset(this, 0, sizeof(EffectInfo)); };
};
virtual std::shared_ptr<IEffect> __cdecl CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) = 0;
virtual std::shared_ptr<IEffect> __cdecl CreateEffect(_In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext) = 0;
virtual void __cdecl CreateTexture( _In_z_ const wchar_t* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) = 0;
virtual void __cdecl CreateTexture(_In_z_ const wchar_t* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView) = 0;
};
@ -731,8 +727,8 @@ namespace DirectX
{
public:
explicit EffectFactory(_In_ ID3D11Device* device);
EffectFactory(EffectFactory&& moveFrom);
EffectFactory& operator= (EffectFactory&& moveFrom);
EffectFactory(EffectFactory&& moveFrom) throw();
EffectFactory& operator= (EffectFactory&& moveFrom) throw();
EffectFactory(EffectFactory const&) = delete;
EffectFactory& operator= (EffectFactory const&) = delete;
@ -740,18 +736,21 @@ namespace DirectX
virtual ~EffectFactory();
// IEffectFactory methods.
virtual std::shared_ptr<IEffect> __cdecl CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) override;
virtual void __cdecl CreateTexture( _In_z_ const wchar_t* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) override;
virtual std::shared_ptr<IEffect> __cdecl CreateEffect(_In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext) override;
virtual void __cdecl CreateTexture(_In_z_ const wchar_t* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView) override;
// Settings.
void __cdecl ReleaseCache();
void __cdecl SetSharing( bool enabled );
void __cdecl SetSharing(bool enabled);
void __cdecl EnableNormalMapEffect( bool enabled );
void __cdecl EnableForceSRGB( bool forceSRGB );
void __cdecl EnableNormalMapEffect(bool enabled);
void __cdecl EnableForceSRGB(bool forceSRGB);
void __cdecl SetDirectory( _In_opt_z_ const wchar_t* path );
void __cdecl SetDirectory(_In_opt_z_ const wchar_t* path);
// Properties.
ID3D11Device* GetDevice() const;
private:
// Private implementation.
@ -766,8 +765,8 @@ namespace DirectX
{
public:
explicit DGSLEffectFactory(_In_ ID3D11Device* device);
DGSLEffectFactory(DGSLEffectFactory&& moveFrom);
DGSLEffectFactory& operator= (DGSLEffectFactory&& moveFrom);
DGSLEffectFactory(DGSLEffectFactory&& moveFrom) throw();
DGSLEffectFactory& operator= (DGSLEffectFactory&& moveFrom) throw();
DGSLEffectFactory(DGSLEffectFactory const&) = delete;
DGSLEffectFactory& operator= (DGSLEffectFactory const&) = delete;
@ -775,8 +774,8 @@ namespace DirectX
virtual ~DGSLEffectFactory();
// IEffectFactory methods.
virtual std::shared_ptr<IEffect> __cdecl CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) override;
virtual void __cdecl CreateTexture( _In_z_ const wchar_t* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) override;
virtual std::shared_ptr<IEffect> __cdecl CreateEffect(_In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext) override;
virtual void __cdecl CreateTexture(_In_z_ const wchar_t* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView) override;
// DGSL methods.
struct DGSLEffectInfo : public EffectInfo
@ -786,21 +785,24 @@ namespace DirectX
const wchar_t* textures[DGSLEffect::MaxTextures - BaseTextureOffset];
const wchar_t* pixelShader;
DGSLEffectInfo() { memset( this, 0, sizeof(DGSLEffectInfo) ); };
DGSLEffectInfo() throw() { memset(this, 0, sizeof(DGSLEffectInfo)); };
};
virtual std::shared_ptr<IEffect> __cdecl CreateDGSLEffect( _In_ const DGSLEffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext );
virtual std::shared_ptr<IEffect> __cdecl CreateDGSLEffect(_In_ const DGSLEffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext);
virtual void __cdecl CreatePixelShader( _In_z_ const wchar_t* shader, _Outptr_ ID3D11PixelShader** pixelShader );
virtual void __cdecl CreatePixelShader(_In_z_ const wchar_t* shader, _Outptr_ ID3D11PixelShader** pixelShader);
// Settings.
void __cdecl ReleaseCache();
void __cdecl SetSharing( bool enabled );
void __cdecl SetSharing(bool enabled);
void __cdecl EnableForceSRGB( bool forceSRGB );
void __cdecl EnableForceSRGB(bool forceSRGB);
void __cdecl SetDirectory( _In_opt_z_ const wchar_t* path );
void __cdecl SetDirectory(_In_opt_z_ const wchar_t* path);
// Properties.
ID3D11Device* GetDevice() const;
private:
// Private implementation.

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: GamePad.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
@ -39,19 +36,19 @@ namespace DirectX
{
public:
GamePad();
GamePad(GamePad&& moveFrom);
GamePad& operator= (GamePad&& moveFrom);
GamePad(GamePad&& moveFrom) throw();
GamePad& operator= (GamePad&& moveFrom) throw();
GamePad(GamePad const&) = delete;
GamePad& operator=(GamePad const&) = delete;
virtual ~GamePad();
#if (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/ ) || defined(_XBOX_ONE)
#if (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/ ) || defined(_XBOX_ONE)
static const int MAX_PLAYER_COUNT = 8;
#else
#else
static const int MAX_PLAYER_COUNT = 4;
#endif
#endif
enum DeadZone
{
@ -103,7 +100,7 @@ namespace DirectX
float left;
float right;
};
struct State
{
bool connected;
@ -142,7 +139,7 @@ namespace DirectX
bool __cdecl IsLeftThumbStickLeft() const { return (thumbSticks.leftX < -0.5f) != 0; }
bool __cdecl IsLeftThumbStickRight() const { return (thumbSticks.leftX > 0.5f) != 0; }
bool __cdecl IsRightThumbStickUp() const { return (thumbSticks.rightY > 0.5f ) != 0; }
bool __cdecl IsRightThumbStickUp() const { return (thumbSticks.rightY > 0.5f) != 0; }
bool __cdecl IsRightThumbStickDown() const { return (thumbSticks.rightY < -0.5f) != 0; }
bool __cdecl IsRightThumbStickLeft() const { return (thumbSticks.rightX < -0.5f) != 0; }
bool __cdecl IsRightThumbStickRight() const { return (thumbSticks.rightX > 0.5f) != 0; }
@ -170,11 +167,11 @@ namespace DirectX
bool connected;
Type gamepadType;
#if (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/)
#if (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/)
std::wstring id;
#else
#else
uint64_t id;
#endif
#endif
bool __cdecl IsConnected() const { return connected; }
};
@ -231,9 +228,9 @@ namespace DirectX
ButtonState leftTrigger;
ButtonState rightTrigger;
ButtonStateTracker() { Reset(); }
ButtonStateTracker() throw() { Reset(); }
void __cdecl Update( const State& state );
void __cdecl Update(const State& state);
void __cdecl Reset();
@ -250,15 +247,15 @@ namespace DirectX
Capabilities __cdecl GetCapabilities(int player);
// Set the vibration motor speeds of the gamepad
bool __cdecl SetVibration( int player, float leftMotor, float rightMotor, float leftTrigger = 0.f, float rightTrigger = 0.f );
bool __cdecl SetVibration(int player, float leftMotor, float rightMotor, float leftTrigger = 0.f, float rightTrigger = 0.f);
// Handle suspending/resuming
void __cdecl Suspend();
void __cdecl Resume();
#if (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/ ) || defined(_XBOX_ONE)
#if (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/ ) || defined(_XBOX_ONE)
void __cdecl RegisterEvents(void* ctrlChanged, void* userChanged);
#endif
#endif
// Singleton
static GamePad& __cdecl Get();

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: GeometricPrimitive.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -34,46 +30,46 @@ namespace DirectX
using VertexType = VertexPositionNormalTexture;
virtual ~GeometricPrimitive();
// Factory methods.
static std::unique_ptr<GeometricPrimitive> __cdecl CreateCube (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateBox (_In_ ID3D11DeviceContext* deviceContext, const XMFLOAT3& size, bool rhcoords = true, bool invertn = false);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateSphere (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 16, bool rhcoords = true, bool invertn = false);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateGeoSphere (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 3, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateCylinder (_In_ ID3D11DeviceContext* deviceContext, float height = 1, float diameter = 1, size_t tessellation = 32, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateCone (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float height = 1, size_t tessellation = 32, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateTorus (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float thickness = 0.333f, size_t tessellation = 32, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateTetrahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateOctahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateDodecahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateIcosahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateTeapot (_In_ ID3D11DeviceContext* deviceContext, float size = 1, size_t tessellation = 8, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateCustom (_In_ ID3D11DeviceContext* deviceContext, const std::vector<VertexType>& vertices, const std::vector<uint16_t>& indices);
static void __cdecl CreateCube (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateBox (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, const XMFLOAT3& size, bool rhcoords = true, bool invertn = false);
static void __cdecl CreateSphere (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float diameter = 1, size_t tessellation = 16, bool rhcoords = true, bool invertn = false);
static void __cdecl CreateGeoSphere (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float diameter = 1, size_t tessellation = 3, bool rhcoords = true);
static void __cdecl CreateCylinder (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float height = 1, float diameter = 1, size_t tessellation = 32, bool rhcoords = true);
static void __cdecl CreateCone (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float diameter = 1, float height = 1, size_t tessellation = 32, bool rhcoords = true);
static void __cdecl CreateTorus (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float diameter = 1, float thickness = 0.333f, size_t tessellation = 32, bool rhcoords = true);
static void __cdecl CreateTetrahedron (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateOctahedron (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateDodecahedron (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateIcosahedron (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateTeapot (std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, size_t tessellation = 8, bool rhcoords = true);
// Factory methods.
static std::unique_ptr<GeometricPrimitive> __cdecl CreateCube(_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateBox(_In_ ID3D11DeviceContext* deviceContext, const XMFLOAT3& size, bool rhcoords = true, bool invertn = false);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateSphere(_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 16, bool rhcoords = true, bool invertn = false);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateGeoSphere(_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 3, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateCylinder(_In_ ID3D11DeviceContext* deviceContext, float height = 1, float diameter = 1, size_t tessellation = 32, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateCone(_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float height = 1, size_t tessellation = 32, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateTorus(_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float thickness = 0.333f, size_t tessellation = 32, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateTetrahedron(_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateOctahedron(_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateDodecahedron(_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateIcosahedron(_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateTeapot(_In_ ID3D11DeviceContext* deviceContext, float size = 1, size_t tessellation = 8, bool rhcoords = true);
static std::unique_ptr<GeometricPrimitive> __cdecl CreateCustom(_In_ ID3D11DeviceContext* deviceContext, const std::vector<VertexType>& vertices, const std::vector<uint16_t>& indices);
static void __cdecl CreateCube(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateBox(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, const XMFLOAT3& size, bool rhcoords = true, bool invertn = false);
static void __cdecl CreateSphere(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float diameter = 1, size_t tessellation = 16, bool rhcoords = true, bool invertn = false);
static void __cdecl CreateGeoSphere(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float diameter = 1, size_t tessellation = 3, bool rhcoords = true);
static void __cdecl CreateCylinder(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float height = 1, float diameter = 1, size_t tessellation = 32, bool rhcoords = true);
static void __cdecl CreateCone(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float diameter = 1, float height = 1, size_t tessellation = 32, bool rhcoords = true);
static void __cdecl CreateTorus(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float diameter = 1, float thickness = 0.333f, size_t tessellation = 32, bool rhcoords = true);
static void __cdecl CreateTetrahedron(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateOctahedron(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateDodecahedron(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateIcosahedron(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, bool rhcoords = true);
static void __cdecl CreateTeapot(std::vector<VertexType>& vertices, std::vector<uint16_t>& indices, float size = 1, size_t tessellation = 8, bool rhcoords = true);
// Draw the primitive.
void XM_CALLCONV Draw(FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, FXMVECTOR color = Colors::White, _In_opt_ ID3D11ShaderResourceView* texture = nullptr, bool wireframe = false,
_In_opt_ std::function<void __cdecl()> setCustomState = nullptr ) const;
_In_opt_ std::function<void __cdecl()> setCustomState = nullptr) const;
// Draw the primitive using a custom effect.
void __cdecl Draw( _In_ IEffect* effect, _In_ ID3D11InputLayout* inputLayout, bool alpha = false, bool wireframe = false,
_In_opt_ std::function<void __cdecl()> setCustomState = nullptr ) const;
void __cdecl Draw(_In_ IEffect* effect, _In_ ID3D11InputLayout* inputLayout, bool alpha = false, bool wireframe = false,
_In_opt_ std::function<void __cdecl()> setCustomState = nullptr) const;
// Create input layout for drawing with a custom effect.
void __cdecl CreateInputLayout(_In_ IEffect* effect, _Outptr_ ID3D11InputLayout** inputLayout) const;
// Create input layout for drawing with a custom effect.
void __cdecl CreateInputLayout( _In_ IEffect* effect, _Outptr_ ID3D11InputLayout** inputLayout ) const;
private:
GeometricPrimitive();

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: GraphicsMemory.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -27,13 +23,13 @@ namespace DirectX
class GraphicsMemory
{
public:
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
GraphicsMemory(_In_ ID3D11DeviceX* device, UINT backBufferCount = 2);
#else
#else
GraphicsMemory(_In_ ID3D11Device* device, UINT backBufferCount = 2);
#endif
GraphicsMemory(GraphicsMemory&& moveFrom);
GraphicsMemory& operator= (GraphicsMemory&& moveFrom);
#endif
GraphicsMemory(GraphicsMemory&& moveFrom) throw();
GraphicsMemory& operator= (GraphicsMemory&& moveFrom) throw();
GraphicsMemory(GraphicsMemory const&) = delete;
GraphicsMemory& operator=(GraphicsMemory const&) = delete;

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: Keyboard.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
@ -27,8 +24,8 @@ namespace DirectX
{
public:
Keyboard();
Keyboard(Keyboard&& moveFrom);
Keyboard& operator= (Keyboard&& moveFrom);
Keyboard(Keyboard&& moveFrom) throw();
Keyboard& operator= (Keyboard&& moveFrom) throw();
Keyboard(Keyboard const&) = delete;
Keyboard& operator=(Keyboard const&) = delete;
@ -431,7 +428,7 @@ namespace DirectX
State released;
State pressed;
KeyboardStateTracker() { Reset(); }
KeyboardStateTracker() throw() { Reset(); }
void __cdecl Update(const State& state);
@ -455,20 +452,20 @@ namespace DirectX
// Feature detection
bool __cdecl IsConnected() const;
#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) && defined(WM_USER)
#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) && defined(WM_USER)
static void __cdecl ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam);
#endif
#endif
#if (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)) || (defined(_XBOX_ONE) && defined(_TITLE))
#if (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)) || (defined(_XBOX_ONE) && defined(_TITLE))
void __cdecl SetWindow(ABI::Windows::UI::Core::ICoreWindow* window);
#ifdef __cplusplus_winrt
#ifdef __cplusplus_winrt
void __cdecl SetWindow(Windows::UI::Core::CoreWindow^ window)
{
// See https://msdn.microsoft.com/en-us/library/hh755802.aspx
SetWindow(reinterpret_cast<ABI::Windows::UI::Core::ICoreWindow*>(window));
}
#endif
#endif
#endif
#endif
// Singleton
static Keyboard& __cdecl Get();

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: Model.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -45,7 +41,7 @@ namespace DirectX
class ModelMeshPart
{
public:
ModelMeshPart();
ModelMeshPart() throw();
virtual ~ModelMeshPart();
uint32_t indexCount;
@ -64,14 +60,14 @@ namespace DirectX
typedef std::vector<std::unique_ptr<ModelMeshPart>> Collection;
// Draw mesh part with custom effect
void __cdecl Draw( _In_ ID3D11DeviceContext* deviceContext, _In_ IEffect* ieffect, _In_ ID3D11InputLayout* iinputLayout,
_In_opt_ std::function<void __cdecl()> setCustomState = nullptr ) const;
void __cdecl Draw(_In_ ID3D11DeviceContext* deviceContext, _In_ IEffect* ieffect, _In_ ID3D11InputLayout* iinputLayout,
_In_opt_ std::function<void __cdecl()> setCustomState = nullptr) const;
// Create input layout for drawing with a custom effect.
void __cdecl CreateInputLayout( _In_ ID3D11Device* d3dDevice, _In_ IEffect* ieffect, _Outptr_ ID3D11InputLayout** iinputLayout ) const;
// Create input layout for drawing with a custom effect.
void __cdecl CreateInputLayout(_In_ ID3D11Device* d3dDevice, _In_ IEffect* ieffect, _Outptr_ ID3D11InputLayout** iinputLayout) const;
// Change effect used by part and regenerate input layout (be sure to call Model::Modified as well)
void __cdecl ModifyEffect( _In_ ID3D11Device* d3dDevice, _In_ std::shared_ptr<IEffect>& ieffect, bool isalpha = false );
void __cdecl ModifyEffect(_In_ ID3D11Device* d3dDevice, _In_ std::shared_ptr<IEffect>& ieffect, bool isalpha = false);
};
@ -80,7 +76,7 @@ namespace DirectX
class ModelMesh
{
public:
ModelMesh();
ModelMesh() throw();
virtual ~ModelMesh();
BoundingSphere boundingSphere;
@ -93,11 +89,11 @@ namespace DirectX
typedef std::vector<std::shared_ptr<ModelMesh>> Collection;
// Setup states for drawing mesh
void __cdecl PrepareForRendering( _In_ ID3D11DeviceContext* deviceContext, const CommonStates& states, bool alpha = false, bool wireframe = false ) const;
void __cdecl PrepareForRendering(_In_ ID3D11DeviceContext* deviceContext, const CommonStates& states, bool alpha = false, bool wireframe = false) const;
// Draw the mesh
void XM_CALLCONV Draw( _In_ ID3D11DeviceContext* deviceContext, FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection,
bool alpha = false, _In_opt_ std::function<void __cdecl()> setCustomState = nullptr ) const;
void XM_CALLCONV Draw(_In_ ID3D11DeviceContext* deviceContext, FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection,
bool alpha = false, _In_opt_ std::function<void __cdecl()> setCustomState = nullptr) const;
};
@ -112,34 +108,34 @@ namespace DirectX
std::wstring name;
// Draw all the meshes in the model
void XM_CALLCONV Draw( _In_ ID3D11DeviceContext* deviceContext, const CommonStates& states, FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection,
bool wireframe = false, _In_opt_ std::function<void __cdecl()> setCustomState = nullptr ) const;
void XM_CALLCONV Draw(_In_ ID3D11DeviceContext* deviceContext, const CommonStates& states, FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection,
bool wireframe = false, _In_opt_ std::function<void __cdecl()> setCustomState = nullptr) const;
// Notify model that effects, parts list, or mesh list has changed
// Notify model that effects, parts list, or mesh list has changed
void __cdecl Modified() { mEffectCache.clear(); }
// Update all effects used by the model
void __cdecl UpdateEffects( _In_ std::function<void __cdecl(IEffect*)> setEffect );
void __cdecl UpdateEffects(_In_ std::function<void __cdecl(IEffect*)> setEffect);
// Loads a model from a Visual Studio Starter Kit .CMO file
static std::unique_ptr<Model> __cdecl CreateFromCMO( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, size_t dataSize,
_In_ IEffectFactory& fxFactory, bool ccw = true, bool pmalpha = false );
static std::unique_ptr<Model> __cdecl CreateFromCMO( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName,
_In_ IEffectFactory& fxFactory, bool ccw = true, bool pmalpha = false );
static std::unique_ptr<Model> __cdecl CreateFromCMO(_In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, size_t dataSize,
_In_ IEffectFactory& fxFactory, bool ccw = true, bool pmalpha = false);
static std::unique_ptr<Model> __cdecl CreateFromCMO(_In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName,
_In_ IEffectFactory& fxFactory, bool ccw = true, bool pmalpha = false);
// Loads a model from a DirectX SDK .SDKMESH file
static std::unique_ptr<Model> __cdecl CreateFromSDKMESH( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, _In_ size_t dataSize,
_In_ IEffectFactory& fxFactory, bool ccw = false, bool pmalpha = false );
static std::unique_ptr<Model> __cdecl CreateFromSDKMESH( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName,
_In_ IEffectFactory& fxFactory, bool ccw = false, bool pmalpha = false );
// Loads a model from a DirectX SDK .SDKMESH file
static std::unique_ptr<Model> __cdecl CreateFromSDKMESH(_In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, _In_ size_t dataSize,
_In_ IEffectFactory& fxFactory, bool ccw = false, bool pmalpha = false);
static std::unique_ptr<Model> __cdecl CreateFromSDKMESH(_In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName,
_In_ IEffectFactory& fxFactory, bool ccw = false, bool pmalpha = false);
// Loads a model from a .VBO file
static std::unique_ptr<Model> __cdecl CreateFromVBO( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, _In_ size_t dataSize,
_In_opt_ std::shared_ptr<IEffect> ieffect = nullptr, bool ccw = false, bool pmalpha = false );
static std::unique_ptr<Model> __cdecl CreateFromVBO( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName,
_In_opt_ std::shared_ptr<IEffect> ieffect = nullptr, bool ccw = false, bool pmalpha = false );
// Loads a model from a .VBO file
static std::unique_ptr<Model> __cdecl CreateFromVBO(_In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, _In_ size_t dataSize,
_In_opt_ std::shared_ptr<IEffect> ieffect = nullptr, bool ccw = false, bool pmalpha = false);
static std::unique_ptr<Model> __cdecl CreateFromVBO(_In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName,
_In_opt_ std::shared_ptr<IEffect> ieffect = nullptr, bool ccw = false, bool pmalpha = false);
private:
std::set<IEffect*> mEffectCache;
};
}
}

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

@ -1,21 +1,18 @@
//--------------------------------------------------------------------------------------
// File: Mouse.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
#include <memory>
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
#if (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)) || (defined(_XBOX_ONE) && defined(_TITLE) && (_XDK_VER >= 0x42D907D1))
namespace ABI { namespace Windows { namespace UI { namespace Core { struct ICoreWindow; } } } }
#endif
@ -26,8 +23,8 @@ namespace DirectX
{
public:
Mouse();
Mouse(Mouse&& moveFrom);
Mouse& operator= (Mouse&& moveFrom);
Mouse(Mouse&& moveFrom) throw();
Mouse& operator= (Mouse&& moveFrom) throw();
Mouse(Mouse const&) = delete;
Mouse& operator=(Mouse const&) = delete;
@ -70,9 +67,9 @@ namespace DirectX
ButtonState xButton1;
ButtonState xButton2;
ButtonStateTracker() { Reset(); }
ButtonStateTracker() throw() { Reset(); }
void __cdecl Update( const State& state );
void __cdecl Update(const State& state);
void __cdecl Reset();
@ -94,22 +91,26 @@ namespace DirectX
// Feature detection
bool __cdecl IsConnected() const;
#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) && defined(WM_USER)
// Cursor visibility
bool __cdecl IsVisible() const;
void __cdecl SetVisible(bool visible);
#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) && defined(WM_USER)
void __cdecl SetWindow(HWND window);
static void __cdecl ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam);
#endif
#endif
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
#if (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)) || (defined(_XBOX_ONE) && defined(_TITLE) && (_XDK_VER >= 0x42D907D1))
void __cdecl SetWindow(ABI::Windows::UI::Core::ICoreWindow* window);
#ifdef __cplusplus_winrt
#ifdef __cplusplus_winrt
void __cdecl SetWindow(Windows::UI::Core::CoreWindow^ window)
{
// See https://msdn.microsoft.com/en-us/library/hh755802.aspx
SetWindow(reinterpret_cast<ABI::Windows::UI::Core::ICoreWindow*>(window));
}
#endif
#endif
static void __cdecl SetDpi(float dpi);
#endif
#endif
// Singleton
static Mouse& __cdecl Get();

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: PostProcess.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -60,8 +56,8 @@ namespace DirectX
};
explicit BasicPostProcess(_In_ ID3D11Device* device);
BasicPostProcess(BasicPostProcess&& moveFrom);
BasicPostProcess& operator= (BasicPostProcess&& moveFrom);
BasicPostProcess(BasicPostProcess&& moveFrom) throw();
BasicPostProcess& operator= (BasicPostProcess&& moveFrom) throw();
BasicPostProcess(BasicPostProcess const&) = delete;
BasicPostProcess& operator= (BasicPostProcess const&) = delete;
@ -107,8 +103,8 @@ namespace DirectX
};
explicit DualPostProcess(_In_ ID3D11Device* device);
DualPostProcess(DualPostProcess&& moveFrom);
DualPostProcess& operator= (DualPostProcess&& moveFrom);
DualPostProcess(DualPostProcess&& moveFrom) throw();
DualPostProcess& operator= (DualPostProcess&& moveFrom) throw();
DualPostProcess(DualPostProcess const&) = delete;
DualPostProcess& operator= (DualPostProcess const&) = delete;
@ -162,8 +158,8 @@ namespace DirectX
};
explicit ToneMapPostProcess(_In_ ID3D11Device* device);
ToneMapPostProcess(ToneMapPostProcess&& moveFrom);
ToneMapPostProcess& operator= (ToneMapPostProcess&& moveFrom);
ToneMapPostProcess(ToneMapPostProcess&& moveFrom) throw();
ToneMapPostProcess& operator= (ToneMapPostProcess&& moveFrom) throw();
ToneMapPostProcess(ToneMapPostProcess const&) = delete;
ToneMapPostProcess& operator= (ToneMapPostProcess const&) = delete;
@ -178,10 +174,10 @@ namespace DirectX
void __cdecl SetTransferFunction(TransferFunction func);
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
// Uses Multiple Render Targets to generate both HDR10 and GameDVR SDR signals
void __cdecl SetMRTOutput(bool value = true);
#endif
#endif
// Properties
void __cdecl SetHDRSourceTexture(_In_opt_ ID3D11ShaderResourceView* value);

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: PrimitiveBatch.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -33,8 +29,8 @@ namespace DirectX
{
protected:
PrimitiveBatchBase(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices, size_t maxVertices, size_t vertexSize);
PrimitiveBatchBase(PrimitiveBatchBase&& moveFrom);
PrimitiveBatchBase& operator= (PrimitiveBatchBase&& moveFrom);
PrimitiveBatchBase(PrimitiveBatchBase&& moveFrom) throw();
PrimitiveBatchBase& operator= (PrimitiveBatchBase&& moveFrom) throw();
PrimitiveBatchBase(PrimitiveBatchBase const&) = delete;
PrimitiveBatchBase& operator= (PrimitiveBatchBase const&) = delete;
@ -67,14 +63,14 @@ namespace DirectX
public:
explicit PrimitiveBatch(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices = DefaultBatchSize * 3, size_t maxVertices = DefaultBatchSize)
: PrimitiveBatchBase(deviceContext, maxIndices, maxVertices, sizeof(TVertex))
: PrimitiveBatchBase(deviceContext, maxIndices, maxVertices, sizeof(TVertex))
{ }
PrimitiveBatch(PrimitiveBatch&& moveFrom)
: PrimitiveBatchBase(std::move(moveFrom))
PrimitiveBatch(PrimitiveBatch&& moveFrom) throw()
: PrimitiveBatchBase(std::move(moveFrom))
{ }
PrimitiveBatch& operator= (PrimitiveBatch&& moveFrom)
PrimitiveBatch& operator= (PrimitiveBatch&& moveFrom) throw()
{
PrimitiveBatchBase::operator=(std::move(moveFrom));
return *this;

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

@ -8,12 +8,8 @@
// full-featured texture capture, DDS writer, and texture processing pipeline,
// see the 'Texconv' sample and the 'DirectXTex' library.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
// http://go.microsoft.com/fwlink/?LinkId=248929

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: SpriteBatch.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -35,8 +31,8 @@ namespace DirectX
SpriteSortMode_BackToFront,
SpriteSortMode_FrontToBack,
};
enum SpriteEffects
{
SpriteEffects_None = 0,
@ -45,13 +41,13 @@ namespace DirectX
SpriteEffects_FlipBoth = SpriteEffects_FlipHorizontally | SpriteEffects_FlipVertically,
};
class SpriteBatch
{
public:
explicit SpriteBatch(_In_ ID3D11DeviceContext* deviceContext);
SpriteBatch(SpriteBatch&& moveFrom);
SpriteBatch& operator= (SpriteBatch&& moveFrom);
SpriteBatch(SpriteBatch&& moveFrom) throw();
SpriteBatch& operator= (SpriteBatch&& moveFrom) throw();
SpriteBatch(SpriteBatch const&) = delete;
SpriteBatch& operator= (SpriteBatch const&) = delete;
@ -78,11 +74,11 @@ namespace DirectX
void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0);
// Rotation mode to be applied to the sprite transformation
void __cdecl SetRotation( DXGI_MODE_ROTATION mode );
void __cdecl SetRotation(DXGI_MODE_ROTATION mode);
DXGI_MODE_ROTATION __cdecl GetRotation() const;
// Set viewport for sprite transformation
void __cdecl SetViewport( const D3D11_VIEWPORT& viewPort );
void __cdecl SetViewport(const D3D11_VIEWPORT& viewPort);
private:
// Private implementation.

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: SpriteFont.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -27,8 +23,8 @@ namespace DirectX
SpriteFont(_In_ ID3D11Device* device, _In_reads_bytes_(dataSize) uint8_t const* dataBlob, _In_ size_t dataSize, bool forceSRGB = false);
SpriteFont(_In_ ID3D11ShaderResourceView* texture, _In_reads_(glyphCount) Glyph const* glyphs, _In_ size_t glyphCount, _In_ float lineSpacing);
SpriteFont(SpriteFont&& moveFrom);
SpriteFont& operator= (SpriteFont&& moveFrom);
SpriteFont(SpriteFont&& moveFrom) throw();
SpriteFont& operator= (SpriteFont&& moveFrom) throw();
SpriteFont(SpriteFont const&) = delete;
SpriteFont& operator= (SpriteFont const&) = delete;
@ -57,7 +53,7 @@ namespace DirectX
// Custom layout/rendering
Glyph const* __cdecl FindGlyph(wchar_t character) const;
void __cdecl GetSpriteSheet( ID3D11ShaderResourceView** texture ) const;
void __cdecl GetSpriteSheet(ID3D11ShaderResourceView** texture) const;
// Describes a single character glyph.
struct Glyph

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: VertexTypes.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -29,6 +25,14 @@ namespace DirectX
{
VertexPosition() = default;
VertexPosition(const VertexPosition&) = default;
VertexPosition& operator=(const VertexPosition&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPosition(VertexPosition&&) = default;
VertexPosition& operator=(VertexPosition&&) = default;
#endif
VertexPosition(XMFLOAT3 const& position)
: position(position)
{ }
@ -50,8 +54,16 @@ namespace DirectX
{
VertexPositionColor() = default;
VertexPositionColor(const VertexPositionColor&) = default;
VertexPositionColor& operator=(const VertexPositionColor&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionColor(VertexPositionColor&&) = default;
VertexPositionColor& operator=(VertexPositionColor&&) = default;
#endif
VertexPositionColor(XMFLOAT3 const& position, XMFLOAT4 const& color)
: position(position),
: position(position),
color(color)
{ }
@ -74,8 +86,16 @@ namespace DirectX
{
VertexPositionTexture() = default;
VertexPositionTexture(const VertexPositionTexture&) = default;
VertexPositionTexture& operator=(const VertexPositionTexture&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionTexture(VertexPositionTexture&&) = default;
VertexPositionTexture& operator=(VertexPositionTexture&&) = default;
#endif
VertexPositionTexture(XMFLOAT3 const& position, XMFLOAT2 const& textureCoordinate)
: position(position),
: position(position),
textureCoordinate(textureCoordinate)
{ }
@ -98,6 +118,14 @@ namespace DirectX
{
VertexPositionDualTexture() = default;
VertexPositionDualTexture(const VertexPositionDualTexture&) = default;
VertexPositionDualTexture& operator=(const VertexPositionDualTexture&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionDualTexture(VertexPositionDualTexture&&) = default;
VertexPositionDualTexture& operator=(VertexPositionDualTexture&&) = default;
#endif
VertexPositionDualTexture(XMFLOAT3 const& position, XMFLOAT2 const& textureCoordinate0, XMFLOAT2 const& textureCoordinate1)
: position(position),
textureCoordinate0(textureCoordinate0),
@ -105,8 +133,8 @@ namespace DirectX
{ }
VertexPositionDualTexture(FXMVECTOR position,
FXMVECTOR textureCoordinate0,
FXMVECTOR textureCoordinate1)
FXMVECTOR textureCoordinate0,
FXMVECTOR textureCoordinate1)
{
XMStoreFloat3(&this->position, position);
XMStoreFloat2(&this->textureCoordinate0, textureCoordinate0);
@ -127,8 +155,16 @@ namespace DirectX
{
VertexPositionNormal() = default;
VertexPositionNormal(const VertexPositionNormal&) = default;
VertexPositionNormal& operator=(const VertexPositionNormal&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionNormal(VertexPositionNormal&&) = default;
VertexPositionNormal& operator=(VertexPositionNormal&&) = default;
#endif
VertexPositionNormal(XMFLOAT3 const& position, XMFLOAT3 const& normal)
: position(position),
: position(position),
normal(normal)
{ }
@ -151,8 +187,16 @@ namespace DirectX
{
VertexPositionColorTexture() = default;
VertexPositionColorTexture(const VertexPositionColorTexture&) = default;
VertexPositionColorTexture& operator=(const VertexPositionColorTexture&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionColorTexture(VertexPositionColorTexture&&) = default;
VertexPositionColorTexture& operator=(VertexPositionColorTexture&&) = default;
#endif
VertexPositionColorTexture(XMFLOAT3 const& position, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate)
: position(position),
: position(position),
color(color),
textureCoordinate(textureCoordinate)
{ }
@ -178,8 +222,16 @@ namespace DirectX
{
VertexPositionNormalColor() = default;
VertexPositionNormalColor(const VertexPositionNormalColor&) = default;
VertexPositionNormalColor& operator=(const VertexPositionNormalColor&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionNormalColor(VertexPositionNormalColor&&) = default;
VertexPositionNormalColor& operator=(VertexPositionNormalColor&&) = default;
#endif
VertexPositionNormalColor(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& color)
: position(position),
: position(position),
normal(normal),
color(color)
{ }
@ -205,8 +257,16 @@ namespace DirectX
{
VertexPositionNormalTexture() = default;
VertexPositionNormalTexture(const VertexPositionNormalTexture&) = default;
VertexPositionNormalTexture& operator=(const VertexPositionNormalTexture&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionNormalTexture(VertexPositionNormalTexture&&) = default;
VertexPositionNormalTexture& operator=(VertexPositionNormalTexture&&) = default;
#endif
VertexPositionNormalTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT2 const& textureCoordinate)
: position(position),
: position(position),
normal(normal),
textureCoordinate(textureCoordinate)
{ }
@ -232,8 +292,16 @@ namespace DirectX
{
VertexPositionNormalColorTexture() = default;
VertexPositionNormalColorTexture(const VertexPositionNormalColorTexture&) = default;
VertexPositionNormalColorTexture& operator=(const VertexPositionNormalColorTexture&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionNormalColorTexture(VertexPositionNormalColorTexture&&) = default;
VertexPositionNormalColorTexture& operator=(VertexPositionNormalColorTexture&&) = default;
#endif
VertexPositionNormalColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate)
: position(position),
: position(position),
normal(normal),
color(color),
textureCoordinate(textureCoordinate)
@ -263,6 +331,14 @@ namespace DirectX
{
VertexPositionNormalTangentColorTexture() = default;
VertexPositionNormalTangentColorTexture(const VertexPositionNormalTangentColorTexture&) = default;
VertexPositionNormalTangentColorTexture& operator=(const VertexPositionNormalTangentColorTexture&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionNormalTangentColorTexture(VertexPositionNormalTangentColorTexture&&) = default;
VertexPositionNormalTangentColorTexture& operator=(VertexPositionNormalTangentColorTexture&&) = default;
#endif
XMFLOAT3 position;
XMFLOAT3 normal;
XMFLOAT4 tangent;
@ -270,7 +346,7 @@ namespace DirectX
XMFLOAT2 textureCoordinate;
VertexPositionNormalTangentColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, uint32_t rgba, XMFLOAT2 const& textureCoordinate)
: position(position),
: position(position),
normal(normal),
tangent(tangent),
color(rgba),
@ -279,7 +355,7 @@ namespace DirectX
}
VertexPositionNormalTangentColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, uint32_t rgba, CXMVECTOR textureCoordinate)
: color(rgba)
: color(rgba)
{
XMStoreFloat3(&this->position, position);
XMStoreFloat3(&this->normal, normal);
@ -288,12 +364,12 @@ namespace DirectX
}
VertexPositionNormalTangentColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate)
: position(position),
: position(position),
normal(normal),
tangent(tangent),
textureCoordinate(textureCoordinate)
{
SetColor( color );
SetColor(color);
}
VertexPositionNormalTangentColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, CXMVECTOR color, CXMVECTOR textureCoordinate)
@ -303,11 +379,11 @@ namespace DirectX
XMStoreFloat4(&this->tangent, tangent);
XMStoreFloat2(&this->textureCoordinate, textureCoordinate);
SetColor( color );
SetColor(color);
}
void __cdecl SetColor( XMFLOAT4 const& icolor ) { SetColor( XMLoadFloat4( &icolor ) ); }
void XM_CALLCONV SetColor( FXMVECTOR icolor );
void __cdecl SetColor(XMFLOAT4 const& icolor) { SetColor(XMLoadFloat4(&icolor)); }
void XM_CALLCONV SetColor(FXMVECTOR icolor);
static const int InputElementCount = 5;
static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount];
@ -320,45 +396,53 @@ namespace DirectX
{
VertexPositionNormalTangentColorTextureSkinning() = default;
VertexPositionNormalTangentColorTextureSkinning(const VertexPositionNormalTangentColorTextureSkinning&) = default;
VertexPositionNormalTangentColorTextureSkinning& operator=(const VertexPositionNormalTangentColorTextureSkinning&) = default;
#if !defined(_MSC_VER) || _MSC_VER >= 1900
VertexPositionNormalTangentColorTextureSkinning(VertexPositionNormalTangentColorTextureSkinning&&) = default;
VertexPositionNormalTangentColorTextureSkinning& operator=(VertexPositionNormalTangentColorTextureSkinning&&) = default;
#endif
uint32_t indices;
uint32_t weights;
VertexPositionNormalTangentColorTextureSkinning(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, uint32_t rgba,
XMFLOAT2 const& textureCoordinate, XMUINT4 const& indices, XMFLOAT4 const& weights)
: VertexPositionNormalTangentColorTexture(position,normal,tangent,rgba,textureCoordinate)
: VertexPositionNormalTangentColorTexture(position, normal, tangent, rgba, textureCoordinate)
{
SetBlendIndices( indices );
SetBlendWeights( weights );
SetBlendIndices(indices);
SetBlendWeights(weights);
}
VertexPositionNormalTangentColorTextureSkinning(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, uint32_t rgba, CXMVECTOR textureCoordinate,
XMUINT4 const& indices, CXMVECTOR weights)
: VertexPositionNormalTangentColorTexture(position,normal,tangent,rgba,textureCoordinate)
: VertexPositionNormalTangentColorTexture(position, normal, tangent, rgba, textureCoordinate)
{
SetBlendIndices( indices );
SetBlendWeights( weights );
SetBlendIndices(indices);
SetBlendWeights(weights);
}
VertexPositionNormalTangentColorTextureSkinning(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, XMFLOAT4 const& color,
XMFLOAT2 const& textureCoordinate, XMUINT4 const& indices, XMFLOAT4 const& weights)
: VertexPositionNormalTangentColorTexture(position,normal,tangent,color,textureCoordinate)
: VertexPositionNormalTangentColorTexture(position, normal, tangent, color, textureCoordinate)
{
SetBlendIndices( indices );
SetBlendWeights( weights );
SetBlendIndices(indices);
SetBlendWeights(weights);
}
VertexPositionNormalTangentColorTextureSkinning(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, CXMVECTOR color, CXMVECTOR textureCoordinate,
XMUINT4 const& indices, CXMVECTOR weights)
: VertexPositionNormalTangentColorTexture(position,normal,tangent,color,textureCoordinate)
: VertexPositionNormalTangentColorTexture(position, normal, tangent, color, textureCoordinate)
{
SetBlendIndices( indices );
SetBlendWeights( weights );
SetBlendIndices(indices);
SetBlendWeights(weights);
}
void __cdecl SetBlendIndices( XMUINT4 const& iindices );
void __cdecl SetBlendIndices(XMUINT4 const& iindices);
void __cdecl SetBlendWeights( XMFLOAT4 const& iweights ) { SetBlendWeights( XMLoadFloat4( &iweights ) ); }
void XM_CALLCONV SetBlendWeights( FXMVECTOR iweights );
void __cdecl SetBlendWeights(XMFLOAT4 const& iweights) { SetBlendWeights(XMLoadFloat4(&iweights)); }
void XM_CALLCONV SetBlendWeights(FXMVECTOR iweights);
static const int InputElementCount = 7;
static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount];

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

@ -14,12 +14,8 @@
// For a full-featured DDS file reader, writer, and texture processing pipeline see
// the 'Texconv' sample and the 'DirectXTex' library.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
// http://go.microsoft.com/fwlink/?LinkId=248929
@ -117,7 +113,7 @@ namespace DirectX
// Extended version with optional auto-gen mipmap support
HRESULT __cdecl CreateWICTextureFromMemoryEx(
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
_In_ ID3D11DeviceX* d3dDevice,
_In_opt_ ID3D11DeviceContextX* d3dContext,
#else

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

@ -8,12 +8,8 @@
// module in the DirectXTex package or as part of the DirectXTK library to load
// these files which use standard Direct3D resource creation APIs.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
// http://go.microsoft.com/fwlink/?LinkId=248929

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

@ -4,7 +4,7 @@ DirectXTK - the DirectX Tool Kit for DirectX 11
Copyright (c) Microsoft Corporation. All rights reserved.
February 7, 2018
April 23, 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,
@ -92,6 +92,17 @@ RELEASE NOTES
RELEASE HISTORY
---------------
April 23, 2018
AlignUp, AlignDown template functions in DirectXHelpers.h
Mouse support for cursor visibility
SimpleMath and VertexTypes updated with default copy and move ctors
SimpleMath updates to use constexpr
EffectFactory updated with GetDevice method
PostProcess updated with 'big triangle' optimization
Fix for CMO handling of skinning vertex data
Code and project file cleanup
xwbtool: Fixed Windows 7 compatibility issue
February 7, 2018
Mouse fix for cursor behavior when using Remote Desktop for Win32
Updated for a few more VS 2017 warnings

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: AlignedNew.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
@ -53,13 +50,13 @@ namespace DirectX
// Array overloads.
static void* operator new[] (size_t size)
static void* operator new[](size_t size)
{
return operator new(size);
}
static void operator delete[] (void* ptr)
static void operator delete[](void* ptr)
{
operator delete(ptr);
}

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: AlphaTestEffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -27,7 +23,7 @@ struct AlphaTestEffectConstants
XMMATRIX worldViewProj;
};
static_assert( ( sizeof(AlphaTestEffectConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert((sizeof(AlphaTestEffectConstants) % 16) == 0, "CB size not padded correctly");
// Traits type describes our characteristics to the EffectBase template.
@ -149,10 +145,10 @@ AlphaTestEffect::Impl::Impl(_In_ ID3D11Device* device)
referenceAlpha(0),
vertexColorEnabled(false)
{
static_assert( _countof(EffectBase<AlphaTestEffectTraits>::VertexShaderIndices) == AlphaTestEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert( _countof(EffectBase<AlphaTestEffectTraits>::VertexShaderBytecode) == AlphaTestEffectTraits::VertexShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<AlphaTestEffectTraits>::PixelShaderBytecode) == AlphaTestEffectTraits::PixelShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<AlphaTestEffectTraits>::PixelShaderIndices) == AlphaTestEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert(_countof(EffectBase<AlphaTestEffectTraits>::VertexShaderIndices) == AlphaTestEffectTraits::ShaderPermutationCount, "array/max mismatch");
static_assert(_countof(EffectBase<AlphaTestEffectTraits>::VertexShaderBytecode) == AlphaTestEffectTraits::VertexShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<AlphaTestEffectTraits>::PixelShaderBytecode) == AlphaTestEffectTraits::PixelShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<AlphaTestEffectTraits>::PixelShaderIndices) == AlphaTestEffectTraits::ShaderPermutationCount, "array/max mismatch");
}
@ -284,20 +280,20 @@ void AlphaTestEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
// Public constructor.
AlphaTestEffect::AlphaTestEffect(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
: pImpl(std::make_unique<Impl>(device))
{
}
// Move constructor.
AlphaTestEffect::AlphaTestEffect(AlphaTestEffect&& moveFrom)
AlphaTestEffect::AlphaTestEffect(AlphaTestEffect&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
AlphaTestEffect& AlphaTestEffect::operator= (AlphaTestEffect&& moveFrom)
AlphaTestEffect& AlphaTestEffect::operator= (AlphaTestEffect&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: BasicEffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -38,7 +34,7 @@ struct BasicEffectConstants
XMMATRIX worldViewProj;
};
static_assert( ( sizeof(BasicEffectConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert((sizeof(BasicEffectConstants) % 16) == 0, "CB size not padded correctly");
// Traits type describes our characteristics to the EffectBase template.
@ -479,20 +475,20 @@ void BasicEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
// Public constructor.
BasicEffect::BasicEffect(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
: pImpl(std::make_unique<Impl>(device))
{
}
// Move constructor.
BasicEffect::BasicEffect(BasicEffect&& moveFrom)
BasicEffect::BasicEffect(BasicEffect&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
BasicEffect& BasicEffect::operator= (BasicEffect&& moveFrom)
BasicEffect& BasicEffect::operator= (BasicEffect&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: BasicPostProcess.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -302,9 +298,10 @@ void BasicPostProcess::Impl::Process(_In_ ID3D11DeviceContext* deviceContext, st
}
// Draw quad.
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
deviceContext->IASetInputLayout(nullptr);
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
deviceContext->Draw(4, 0);
deviceContext->Draw(3, 0);
}
@ -312,7 +309,7 @@ void BasicPostProcess::Impl::DownScale2x2()
{
mUseConstants = true;
if ( !texWidth || !texHeight)
if (!texWidth || !texHeight)
{
throw std::exception("Call SetSourceTexture before setting post-process effect");
}
@ -332,7 +329,6 @@ void BasicPostProcess::Impl::DownScale2x2()
++ptr;
}
}
}
@ -466,20 +462,20 @@ void BasicPostProcess::Impl::Bloom(bool horizontal, float size, float brightnes
// Public constructor.
BasicPostProcess::BasicPostProcess(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
: pImpl(std::make_unique<Impl>(device))
{
}
// Move constructor.
BasicPostProcess::BasicPostProcess(BasicPostProcess&& moveFrom)
BasicPostProcess::BasicPostProcess(BasicPostProcess&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
BasicPostProcess& BasicPostProcess::operator= (BasicPostProcess&& moveFrom)
BasicPostProcess& BasicPostProcess::operator= (BasicPostProcess&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: Bezier.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
@ -31,9 +28,9 @@ namespace Bezier
using DirectX::operator+;
return p1 * (1 - t) * (1 - t) * (1 - t) +
p2 * 3 * t * (1 - t) * (1 - t) +
p3 * 3 * t * t * (1 - t) +
p4 * t * t * t;
p2 * 3 * t * (1 - t) * (1 - t) +
p3 * 3 * t * t * (1 - t) +
p4 * t * t * t;
}
@ -46,9 +43,9 @@ namespace Bezier
using DirectX::operator+;
return p1 * (-1 + 2 * t - t * t) +
p2 * (1 - 4 * t + 3 * t * t) +
p3 * (2 * t - 3 * t * t) +
p4 * (t * t);
p2 * (1 - 4 * t + 3 * t * t) +
p3 * (2 * t - 3 * t * t) +
p4 * (t * t);
}
@ -70,9 +67,9 @@ namespace Bezier
// Perform four horizontal bezier interpolations
// between the control points of this patch.
XMVECTOR p1 = CubicInterpolate(patch[0], patch[1], patch[2], patch[3], u);
XMVECTOR p2 = CubicInterpolate(patch[4], patch[5], patch[6], patch[7], u);
XMVECTOR p3 = CubicInterpolate(patch[8], patch[9], patch[10], patch[11], u);
XMVECTOR p1 = CubicInterpolate(patch[0], patch[1], patch[2], patch[3], u);
XMVECTOR p2 = CubicInterpolate(patch[4], patch[5], patch[6], patch[7], u);
XMVECTOR p3 = CubicInterpolate(patch[8], patch[9], patch[10], patch[11], u);
XMVECTOR p4 = CubicInterpolate(patch[12], patch[13], patch[14], patch[15], u);
// Perform a vertical interpolation between the results of the
@ -81,8 +78,8 @@ namespace Bezier
// Perform another four bezier interpolations between the control
// points, but this time vertically rather than horizontally.
XMVECTOR q1 = CubicInterpolate(patch[0], patch[4], patch[8], patch[12], v);
XMVECTOR q2 = CubicInterpolate(patch[1], patch[5], patch[9], patch[13], v);
XMVECTOR q1 = CubicInterpolate(patch[0], patch[4], patch[8], patch[12], v);
XMVECTOR q2 = CubicInterpolate(patch[1], patch[5], patch[9], patch[13], v);
XMVECTOR q3 = CubicInterpolate(patch[2], patch[6], patch[10], patch[14], v);
XMVECTOR q4 = CubicInterpolate(patch[3], patch[7], patch[11], patch[15], v);
@ -131,7 +128,7 @@ namespace Bezier
}
}
// Creates indices for a patch that is tessellated at the specified level.
// Calls the specified outputIndex function for each generated index value.
template<typename TOutputFunc>

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: BinaryReader.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "pch.h"
@ -26,10 +23,10 @@ BinaryReader::BinaryReader(_In_z_ wchar_t const* fileName) :
size_t dataSize;
HRESULT hr = ReadEntireFile(fileName, mOwnedData, &dataSize);
if ( FAILED(hr) )
if (FAILED(hr))
{
DebugTrace( "BinaryReader failed (%08X) to load '%ls'\n", hr, fileName );
throw std::exception( "BinaryReader" );
DebugTrace("BinaryReader failed (%08X) to load '%ls'\n", hr, fileName);
throw std::exception("BinaryReader");
}
mPos = mOwnedData.get();
@ -87,6 +84,6 @@ HRESULT BinaryReader::ReadEntireFile(_In_z_ wchar_t const* fileName, _Inout_ std
return E_FAIL;
*dataSize = bytesRead;
return S_OK;
}

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: BinaryReader.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: CommonStates.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -176,14 +172,14 @@ CommonStates::CommonStates(_In_ ID3D11Device* device)
// Move constructor.
CommonStates::CommonStates(CommonStates&& moveFrom)
CommonStates::CommonStates(CommonStates&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
CommonStates& CommonStates::operator= (CommonStates&& moveFrom)
CommonStates& CommonStates::operator= (CommonStates&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: ConstantBuffer.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -29,13 +25,13 @@ namespace DirectX
ConstantBuffer() = default;
explicit ConstantBuffer(_In_ ID3D11Device* device)
{
Create( device );
Create(device);
}
ConstantBuffer(ConstantBuffer const&) = delete;
ConstantBuffer& operator= (ConstantBuffer const&) = delete;
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
void Create(_In_ ID3D11Device* device)
{
D3D11_BUFFER_DESC desc = {};
@ -57,16 +53,16 @@ namespace DirectX
// Writes new data into the constant buffer.
void SetData(_In_ ID3D11DeviceContext* deviceContext, T const& value, void** grfxMemory)
{
assert( grfxMemory != 0 );
assert(grfxMemory != 0);
void* ptr = GraphicsMemory::Get().Allocate( deviceContext, sizeof(T), 64 );
assert( ptr != 0 );
void* ptr = GraphicsMemory::Get().Allocate(deviceContext, sizeof(T), 64);
assert(ptr != 0);
*(T*)ptr = value;
*grfxMemory = ptr;
}
#else
#else
void Create(_In_ ID3D11Device* device)
{
D3D11_BUFFER_DESC desc = {};
@ -77,7 +73,7 @@ namespace DirectX
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
ThrowIfFailed(
device->CreateBuffer(&desc, nullptr, mConstantBuffer.ReleaseAndGetAddressOf() )
device->CreateBuffer(&desc, nullptr, mConstantBuffer.ReleaseAndGetAddressOf())
);
SetDebugObjectName(mConstantBuffer.Get(), "DirectXTK");
@ -87,21 +83,21 @@ namespace DirectX
// Writes new data into the constant buffer.
void SetData(_In_ ID3D11DeviceContext* deviceContext, T const& value)
{
assert( mConstantBuffer.Get() != 0 );
assert(mConstantBuffer.Get() != 0);
D3D11_MAPPED_SUBRESOURCE mappedResource;
ThrowIfFailed(
deviceContext->Map(mConstantBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)
);
*(T*)mappedResource.pData = value;
*static_cast<T*>(mappedResource.pData) = value;
deviceContext->Unmap(mConstantBuffer.Get(), 0);
}
#endif
#endif
// Looks up the underlying D3D constant buffer.
// Looks up the underlying D3D constant buffer.
ID3D11Buffer* GetBuffer()
{
return mConstantBuffer.Get();

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: DGSLEffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -99,11 +95,11 @@ struct BoneConstants
#pragma pack(pop)
static_assert( ( sizeof(MaterialConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert( ( sizeof(LightConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert( ( sizeof(ObjectConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert( ( sizeof(MiscConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert( ( sizeof(BoneConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert((sizeof(MaterialConstants) % 16) == 0, "CB size not padded correctly");
static_assert((sizeof(LightConstants) % 16) == 0, "CB size not padded correctly");
static_assert((sizeof(ObjectConstants) % 16) == 0, "CB size not padded correctly");
static_assert((sizeof(MiscConstants) % 16) == 0, "CB size not padded correctly");
static_assert((sizeof(BoneConstants) % 16) == 0, "CB size not padded correctly");
__declspec(align(16)) struct DGSLEffectConstants
{
@ -221,24 +217,24 @@ const ShaderBytecode DGSLEffectTraits::PixelShaderBytecode[] =
class DGSLEffect::Impl : public AlignedNew<DGSLEffectConstants>
{
public:
Impl( _In_ ID3D11Device* device, _In_opt_ ID3D11PixelShader* pixelShader, _In_ bool enableSkinning ) :
dirtyFlags( INT_MAX ),
Impl(_In_ ID3D11Device* device, _In_opt_ ID3D11PixelShader* pixelShader, _In_ bool enableSkinning) :
dirtyFlags(INT_MAX),
vertexColorEnabled(false),
textureEnabled(false),
specularEnabled(false),
alphaDiscardEnabled(false),
weightsPerVertex( enableSkinning ? 4 : 0 ),
mCBMaterial( device ),
mCBLight( device ),
mCBObject( device ),
mCBMisc( device ),
mPixelShader( pixelShader ),
mDeviceResources( deviceResourcesPool.DemandCreate(device) )
weightsPerVertex(enableSkinning ? 4 : 0),
mCBMaterial(device),
mCBLight(device),
mCBObject(device),
mCBMisc(device),
mPixelShader(pixelShader),
mDeviceResources(deviceResourcesPool.DemandCreate(device))
{
static_assert( _countof(DGSLEffectTraits::VertexShaderBytecode) == DGSLEffectTraits::VertexShaderCount, "array/max mismatch" );
static_assert( _countof(DGSLEffectTraits::PixelShaderBytecode) == DGSLEffectTraits::PixelShaderCount, "array/max mismatch" );
static_assert(_countof(DGSLEffectTraits::VertexShaderBytecode) == DGSLEffectTraits::VertexShaderCount, "array/max mismatch");
static_assert(_countof(DGSLEffectTraits::PixelShaderBytecode) == DGSLEffectTraits::PixelShaderCount, "array/max mismatch");
memset( &constants, 0, sizeof(constants) );
memset(&constants, 0, sizeof(constants));
XMMATRIX id = XMMatrixIdentity();
world = id;
@ -249,8 +245,8 @@ public:
constants.material.SpecularPower = 16;
constants.object.UvTransform4x4 = id;
static_assert( MaxDirectionalLights == 4, "Mismatch with DGSL pipline" );
for( int i = 0; i < MaxDirectionalLights; ++i )
static_assert(MaxDirectionalLights == 4, "Mismatch with DGSL pipline");
for (int i = 0; i < MaxDirectionalLights; ++i)
{
lightEnabled[i] = (i == 0);
lightDiffuseColor[i] = g_XMZero;
@ -261,21 +257,21 @@ public:
constants.light.LightSpecularIntensity[i] = lightEnabled[i] ? lightSpecularColor[i] : g_XMZero;
}
if ( enableSkinning )
if (enableSkinning)
{
mCBBone.Create( device );
mCBBone.Create(device);
for( size_t j = 0; j < MaxBones; ++j )
for (size_t j = 0; j < MaxBones; ++j)
{
constants.bones.Bones[ j ][0] = g_XMIdentityR0;
constants.bones.Bones[ j ][1] = g_XMIdentityR1;
constants.bones.Bones[ j ][2] = g_XMIdentityR2;
constants.bones.Bones[j][0] = g_XMIdentityR0;
constants.bones.Bones[j][1] = g_XMIdentityR1;
constants.bones.Bones[j][2] = g_XMIdentityR2;
}
}
}
// Methods
void Apply( _In_ ID3D11DeviceContext* deviceContext );
void Apply(_In_ ID3D11DeviceContext* deviceContext);
void GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength);
// Fields
@ -317,7 +313,7 @@ private:
DeviceResources(_In_ ID3D11Device* device) : EffectDeviceResources(device) {}
// Gets or lazily creates the vertex shader.
ID3D11VertexShader* GetVertexShader( int permutation )
ID3D11VertexShader* GetVertexShader(int permutation)
{
assert(permutation >= 0 && permutation < DGSLEffectTraits::VertexShaderCount);
@ -325,7 +321,7 @@ private:
}
// Gets or lazily creates the specified pixel shader permutation.
ID3D11PixelShader* GetPixelShader( int permutation )
ID3D11PixelShader* GetPixelShader(int permutation)
{
assert(permutation >= 0 && permutation < DGSLEffectTraits::PixelShaderCount);
@ -352,37 +348,37 @@ private:
SharedResourcePool<ID3D11Device*, DGSLEffect::Impl::DeviceResources> DGSLEffect::Impl::deviceResourcesPool;
void DGSLEffect::Impl::Apply( _In_ ID3D11DeviceContext* deviceContext )
void DGSLEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
{
auto vertexShader = mDeviceResources->GetVertexShader( GetCurrentVSPermutation() );
auto vertexShader = mDeviceResources->GetVertexShader(GetCurrentVSPermutation());
auto pixelShader = mPixelShader.Get();
if( !pixelShader )
if (!pixelShader)
{
pixelShader = mDeviceResources->GetPixelShader( GetCurrentPSPermutation() );
pixelShader = mDeviceResources->GetPixelShader(GetCurrentPSPermutation());
}
deviceContext->VSSetShader( vertexShader, nullptr, 0 );
deviceContext->PSSetShader( pixelShader, nullptr, 0 );
deviceContext->VSSetShader(vertexShader, nullptr, 0);
deviceContext->PSSetShader(pixelShader, nullptr, 0);
// Check for any required matrices updates
if (dirtyFlags & EffectDirtyFlags::WorldViewProj)
{
constants.object.LocalToWorld4x4 = XMMatrixTranspose( world );
constants.object.WorldToView4x4 = XMMatrixTranspose( view );
constants.object.LocalToWorld4x4 = XMMatrixTranspose(world);
constants.object.WorldToView4x4 = XMMatrixTranspose(view);
XMMATRIX worldView = XMMatrixMultiply( world, view );
XMMATRIX worldView = XMMatrixMultiply(world, view);
constants.object.LocalToProjected4x4 = XMMatrixTranspose(XMMatrixMultiply(worldView, projection));
constants.object.LocalToProjected4x4 = XMMatrixTranspose( XMMatrixMultiply( worldView, projection ) );
dirtyFlags &= ~EffectDirtyFlags::WorldViewProj;
dirtyFlags |= EffectDirtyFlags::ConstantBufferObject;
}
if (dirtyFlags & EffectDirtyFlags::WorldInverseTranspose)
{
XMMATRIX worldInverse = XMMatrixInverse( nullptr, world );
XMMATRIX worldInverse = XMMatrixInverse(nullptr, world);
constants.object.WorldToLocal4x4 = XMMatrixTranspose( worldInverse );
constants.object.WorldToLocal4x4 = XMMatrixTranspose(worldInverse);
dirtyFlags &= ~EffectDirtyFlags::WorldInverseTranspose;
dirtyFlags |= EffectDirtyFlags::ConstantBufferObject;
@ -390,8 +386,8 @@ void DGSLEffect::Impl::Apply( _In_ ID3D11DeviceContext* deviceContext )
if (dirtyFlags & EffectDirtyFlags::EyePosition)
{
XMMATRIX viewInverse = XMMatrixInverse( nullptr, view );
XMMATRIX viewInverse = XMMatrixInverse(nullptr, view);
constants.object.EyePosition = viewInverse.r[3];
dirtyFlags &= ~EffectDirtyFlags::EyePosition;
@ -415,59 +411,59 @@ void DGSLEffect::Impl::Apply( _In_ ID3D11DeviceContext* deviceContext )
ThrowIfFailed(deviceContext->QueryInterface(IID_GRAPHICS_PPV_ARGS(deviceContextX.GetAddressOf())));
auto buffer = mCBMaterial.GetBuffer();
deviceContextX->VSSetPlacementConstantBuffer( 0, buffer, grfxMemoryMaterial );
deviceContextX->PSSetPlacementConstantBuffer( 0, buffer, grfxMemoryMaterial );
deviceContextX->VSSetPlacementConstantBuffer(0, buffer, grfxMemoryMaterial);
deviceContextX->PSSetPlacementConstantBuffer(0, buffer, grfxMemoryMaterial);
buffer = mCBLight.GetBuffer();
deviceContextX->VSSetPlacementConstantBuffer( 1, buffer, grfxMemoryMaterial );
deviceContextX->PSSetPlacementConstantBuffer( 1, buffer, grfxMemoryMaterial );
deviceContextX->VSSetPlacementConstantBuffer(1, buffer, grfxMemoryMaterial);
deviceContextX->PSSetPlacementConstantBuffer(1, buffer, grfxMemoryMaterial);
buffer = mCBObject.GetBuffer();
deviceContextX->VSSetPlacementConstantBuffer( 2, buffer, grfxMemoryObject );
deviceContextX->PSSetPlacementConstantBuffer( 2, buffer, grfxMemoryObject );
deviceContextX->VSSetPlacementConstantBuffer(2, buffer, grfxMemoryObject);
deviceContextX->PSSetPlacementConstantBuffer(2, buffer, grfxMemoryObject);
buffer = mCBMisc.GetBuffer();
deviceContextX->VSSetPlacementConstantBuffer( 3, buffer, grfxMemoryMisc );
deviceContextX->PSSetPlacementConstantBuffer( 3, buffer, grfxMemoryMisc );
deviceContextX->VSSetPlacementConstantBuffer(3, buffer, grfxMemoryMisc);
deviceContextX->PSSetPlacementConstantBuffer(3, buffer, grfxMemoryMisc);
if ( weightsPerVertex > 0 )
if (weightsPerVertex > 0)
{
void* grfxMemoryBone;
mCBBone.SetData(deviceContext, constants.bones, &grfxMemoryBone);
deviceContextX->VSSetPlacementConstantBuffer( 4, mCBBone.GetBuffer(), grfxMemoryBone );
deviceContextX->VSSetPlacementConstantBuffer(4, mCBBone.GetBuffer(), grfxMemoryBone);
}
#else
// Make sure the constant buffers are up to date.
if (dirtyFlags & EffectDirtyFlags::ConstantBufferMaterial)
{
mCBMaterial.SetData(deviceContext, constants.material);
dirtyFlags &= ~EffectDirtyFlags::ConstantBufferMaterial;
}
if (dirtyFlags & EffectDirtyFlags::ConstantBufferLight)
{
mCBLight.SetData(deviceContext, constants.light);
dirtyFlags &= ~EffectDirtyFlags::ConstantBufferLight;
}
if (dirtyFlags & EffectDirtyFlags::ConstantBufferObject)
{
mCBObject.SetData(deviceContext, constants.object);
dirtyFlags &= ~EffectDirtyFlags::ConstantBufferObject;
}
if (dirtyFlags & EffectDirtyFlags::ConstantBufferMisc)
{
mCBMisc.SetData(deviceContext, constants.misc);
dirtyFlags &= ~EffectDirtyFlags::ConstantBufferMisc;
}
if ( weightsPerVertex > 0 )
if (weightsPerVertex > 0)
{
if (dirtyFlags & EffectDirtyFlags::ConstantBufferBones)
{
@ -479,29 +475,29 @@ void DGSLEffect::Impl::Apply( _In_ ID3D11DeviceContext* deviceContext )
ID3D11Buffer* buffers[5] = { mCBMaterial.GetBuffer(), mCBLight.GetBuffer(), mCBObject.GetBuffer(),
mCBMisc.GetBuffer(), mCBBone.GetBuffer() };
deviceContext->VSSetConstantBuffers( 0, 5, buffers );
deviceContext->PSSetConstantBuffers( 0, 4, buffers );
deviceContext->VSSetConstantBuffers(0, 5, buffers);
deviceContext->PSSetConstantBuffers(0, 4, buffers);
}
else
{
ID3D11Buffer* buffers[4] = { mCBMaterial.GetBuffer(), mCBLight.GetBuffer(), mCBObject.GetBuffer(), mCBMisc.GetBuffer() };
deviceContext->VSSetConstantBuffers( 0, 4, buffers );
deviceContext->PSSetConstantBuffers( 0, 4, buffers );
deviceContext->VSSetConstantBuffers(0, 4, buffers);
deviceContext->PSSetConstantBuffers(0, 4, buffers);
}
#endif
// Set the textures
if ( textureEnabled )
if (textureEnabled)
{
ID3D11ShaderResourceView* txt[MaxTextures] = { textures[0].Get(), textures[1].Get(), textures[2].Get(), textures[3].Get(),
textures[4].Get(), textures[5].Get(), textures[6].Get(), textures[7].Get() };
deviceContext->PSSetShaderResources( 0, MaxTextures, txt );
deviceContext->PSSetShaderResources(0, MaxTextures, txt);
}
else
{
ID3D11ShaderResourceView* txt[MaxTextures] = { mDeviceResources->GetDefaultTexture(), 0 };
deviceContext->PSSetShaderResources( 0, MaxTextures, txt );
deviceContext->PSSetShaderResources(0, MaxTextures, txt);
}
}
@ -510,8 +506,8 @@ void DGSLEffect::Impl::GetVertexShaderBytecode(_Out_ void const** pShaderByteCod
{
int permutation = GetCurrentVSPermutation();
assert( permutation < DGSLEffectTraits::VertexShaderCount );
_Analysis_assume_( permutation < DGSLEffectTraits::VertexShaderCount );
assert(permutation < DGSLEffectTraits::VertexShaderCount);
_Analysis_assume_(permutation < DGSLEffectTraits::VertexShaderCount);
auto shader = DGSLEffectTraits::VertexShaderBytecode[permutation];
*pShaderByteCode = shader.code;
@ -523,7 +519,7 @@ int DGSLEffect::Impl::GetCurrentVSPermutation() const
{
int permutation = (vertexColorEnabled) ? 1 : 0;
if( weightsPerVertex > 0 )
if (weightsPerVertex > 0)
{
// Evaluate 1, 2, or 4 weights per vertex?
permutation += 2;
@ -546,15 +542,15 @@ int DGSLEffect::Impl::GetCurrentPSPermutation() const
{
int permutation = 0;
if ( constants.light.ActiveLights > 0 )
if (constants.light.ActiveLights > 0)
{
permutation = ( specularEnabled ) ? 2 : 1;
permutation = (specularEnabled) ? 2 : 1;
}
if ( textureEnabled )
if (textureEnabled)
permutation += 3;
if ( alphaDiscardEnabled )
if (alphaDiscardEnabled)
permutation += 6;
return permutation;
@ -567,18 +563,18 @@ int DGSLEffect::Impl::GetCurrentPSPermutation() const
//--------------------------------------------------------------------------------------
DGSLEffect::DGSLEffect(_In_ ID3D11Device* device, _In_opt_ ID3D11PixelShader* pixelShader, _In_ bool enableSkinning)
: pImpl(new Impl(device, pixelShader, enableSkinning))
: pImpl(std::make_unique<Impl>(device, pixelShader, enableSkinning))
{
}
DGSLEffect::DGSLEffect(DGSLEffect&& moveFrom)
DGSLEffect::DGSLEffect(DGSLEffect&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
DGSLEffect& DGSLEffect::operator= (DGSLEffect&& moveFrom)
DGSLEffect& DGSLEffect::operator= (DGSLEffect&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;
@ -599,7 +595,7 @@ void DGSLEffect::Apply(_In_ ID3D11DeviceContext* deviceContext)
void DGSLEffect::GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength)
{
pImpl->GetVertexShaderBytecode( pShaderByteCode, pByteCodeLength );
pImpl->GetVertexShaderBytecode(pShaderByteCode, pByteCodeLength);
}
@ -711,13 +707,13 @@ void XM_CALLCONV DGSLEffect::SetColorAndAlpha(FXMVECTOR value)
// Additional settings.
void XM_CALLCONV DGSLEffect::SetUVTransform(FXMMATRIX value)
{
pImpl->constants.object.UvTransform4x4 = XMMatrixTranspose( value );
pImpl->constants.object.UvTransform4x4 = XMMatrixTranspose(value);
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferObject;
}
void DGSLEffect::SetViewport( float width, float height )
void DGSLEffect::SetViewport(float width, float height)
{
pImpl->constants.misc.ViewportWidth = width;
pImpl->constants.misc.ViewportHeight = height;
@ -726,7 +722,7 @@ void DGSLEffect::SetViewport( float width, float height )
}
void DGSLEffect::SetTime( float time )
void DGSLEffect::SetTime(float time)
{
pImpl->constants.misc.Time = time;
@ -745,7 +741,7 @@ void DGSLEffect::SetLightingEnabled(bool value)
{
if (value)
{
if ( !pImpl->constants.light.ActiveLights )
if (!pImpl->constants.light.ActiveLights)
pImpl->constants.light.ActiveLights = 1;
}
else
@ -773,18 +769,18 @@ void XM_CALLCONV DGSLEffect::SetAmbientLightColor(FXMVECTOR value)
void DGSLEffect::SetLightEnabled(int whichLight, bool value)
{
if ( whichLight < 0 || whichLight >= MaxDirectionalLights )
if (whichLight < 0 || whichLight >= MaxDirectionalLights)
throw std::out_of_range("whichLight parameter out of range");
if ( pImpl->lightEnabled[whichLight] == value )
if (pImpl->lightEnabled[whichLight] == value)
return;
pImpl->lightEnabled[whichLight] = value;
if ( value )
if (value)
{
if ( whichLight >= (int)pImpl->constants.light.ActiveLights )
pImpl->constants.light.ActiveLights = static_cast<UINT>( whichLight + 1 );
if (whichLight >= static_cast<int>(pImpl->constants.light.ActiveLights))
pImpl->constants.light.ActiveLights = static_cast<UINT>(whichLight + 1);
pImpl->constants.light.LightColor[whichLight] = pImpl->lightDiffuseColor[whichLight];
pImpl->constants.light.LightSpecularIntensity[whichLight] = pImpl->lightSpecularColor[whichLight];
@ -792,7 +788,7 @@ void DGSLEffect::SetLightEnabled(int whichLight, bool value)
else
{
pImpl->constants.light.LightColor[whichLight] =
pImpl->constants.light.LightSpecularIntensity[whichLight] = g_XMZero;
pImpl->constants.light.LightSpecularIntensity[whichLight] = g_XMZero;
}
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferLight;
@ -801,11 +797,11 @@ void DGSLEffect::SetLightEnabled(int whichLight, bool value)
void XM_CALLCONV DGSLEffect::SetLightDirection(int whichLight, FXMVECTOR value)
{
if ( whichLight < 0 || whichLight >= MaxDirectionalLights )
if (whichLight < 0 || whichLight >= MaxDirectionalLights)
throw std::out_of_range("whichLight parameter out of range");
// DGSL effects lights do not negate the direction like BasicEffect
pImpl->constants.light.LightDirection[whichLight] = XMVectorNegate( value );
pImpl->constants.light.LightDirection[whichLight] = XMVectorNegate(value);
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferLight;
}
@ -813,12 +809,12 @@ void XM_CALLCONV DGSLEffect::SetLightDirection(int whichLight, FXMVECTOR value)
void XM_CALLCONV DGSLEffect::SetLightDiffuseColor(int whichLight, FXMVECTOR value)
{
if ( whichLight < 0 || whichLight >= MaxDirectionalLights )
if (whichLight < 0 || whichLight >= MaxDirectionalLights)
throw std::out_of_range("whichLight parameter out of range");
pImpl->lightDiffuseColor[whichLight] = value;
if ( pImpl->lightEnabled[whichLight] )
if (pImpl->lightEnabled[whichLight])
{
pImpl->constants.light.LightColor[whichLight] = value;
@ -829,12 +825,12 @@ void XM_CALLCONV DGSLEffect::SetLightDiffuseColor(int whichLight, FXMVECTOR valu
void XM_CALLCONV DGSLEffect::SetLightSpecularColor(int whichLight, FXMVECTOR value)
{
if ( whichLight < 0 || whichLight >= MaxDirectionalLights )
if (whichLight < 0 || whichLight >= MaxDirectionalLights)
throw std::out_of_range("whichLight parameter out of range");
pImpl->lightSpecularColor[whichLight] = value;
if ( pImpl->lightEnabled[whichLight] )
if (pImpl->lightEnabled[whichLight])
{
pImpl->constants.light.LightSpecularIntensity[whichLight] = value;
@ -870,17 +866,17 @@ void DGSLEffect::SetTexture(_In_opt_ ID3D11ShaderResourceView* value)
void DGSLEffect::SetTexture(int whichTexture, _In_opt_ ID3D11ShaderResourceView* value)
{
if ( whichTexture < 0 || whichTexture >= MaxTextures )
if (whichTexture < 0 || whichTexture >= MaxTextures)
throw std::out_of_range("whichTexture parameter out of range");
pImpl->textures[ whichTexture ] = value;
pImpl->textures[whichTexture] = value;
}
// Animation settings.
void DGSLEffect::SetWeightsPerVertex(int value)
{
if ( !pImpl->weightsPerVertex )
if (!pImpl->weightsPerVertex)
{
// Safe to ignore since it's only an optimization hint
return;
@ -899,7 +895,7 @@ void DGSLEffect::SetWeightsPerVertex(int value)
void DGSLEffect::SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count)
{
if ( !pImpl->weightsPerVertex )
if (!pImpl->weightsPerVertex)
throw std::exception("Skinning not enabled for this effect");
if (count > MaxBones)
@ -922,7 +918,7 @@ void DGSLEffect::SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size
void DGSLEffect::ResetBoneTransforms()
{
if ( !pImpl->weightsPerVertex )
if (!pImpl->weightsPerVertex)
{
// Safe to ignore since it just returns things back to default settings
return;
@ -930,7 +926,7 @@ void DGSLEffect::ResetBoneTransforms()
auto boneConstant = pImpl->constants.bones.Bones;
for(size_t i = 0; i < MaxBones; ++i)
for (size_t i = 0; i < MaxBones; ++i)
{
boneConstant[i][0] = g_XMIdentityR0;
boneConstant[i][1] = g_XMIdentityR1;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: DGSLEffectFactory.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -36,28 +32,28 @@ class DGSLEffectFactory::Impl
{
public:
Impl(_In_ ID3D11Device* device)
: mPath{},
device(device),
: mPath{},
mDevice(device),
mSharing(true),
mForceSRGB(false)
{}
std::shared_ptr<IEffect> CreateEffect( _In_ DGSLEffectFactory* factory, _In_ const IEffectFactory::EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext );
std::shared_ptr<IEffect> CreateDGSLEffect( _In_ DGSLEffectFactory* factory, _In_ const DGSLEffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext );
void CreateTexture( _In_z_ const wchar_t* texture, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView );
void CreatePixelShader( _In_z_ const wchar_t* shader, _Outptr_ ID3D11PixelShader** pixelShader );
std::shared_ptr<IEffect> CreateEffect(_In_ DGSLEffectFactory* factory, _In_ const IEffectFactory::EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext);
std::shared_ptr<IEffect> CreateDGSLEffect(_In_ DGSLEffectFactory* factory, _In_ const DGSLEffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext);
void CreateTexture(_In_z_ const wchar_t* texture, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView);
void CreatePixelShader(_In_z_ const wchar_t* shader, _Outptr_ ID3D11PixelShader** pixelShader);
void ReleaseCache();
void SetSharing( bool enabled ) { mSharing = enabled; }
void SetSharing(bool enabled) { mSharing = enabled; }
void EnableForceSRGB(bool forceSRGB) { mForceSRGB = forceSRGB; }
static SharedResourcePool<ID3D11Device*, Impl> instancePool;
wchar_t mPath[MAX_PATH];
private:
ComPtr<ID3D11Device> device;
ComPtr<ID3D11Device> mDevice;
private:
typedef std::map< std::wstring, std::shared_ptr<IEffect> > EffectCache;
typedef std::map< std::wstring, ComPtr<ID3D11ShaderResourceView> > TextureCache;
typedef std::map< std::wstring, ComPtr<ID3D11PixelShader> > ShaderCache;
@ -79,84 +75,84 @@ SharedResourcePool<ID3D11Device*, DGSLEffectFactory::Impl> DGSLEffectFactory::Im
_Use_decl_annotations_
std::shared_ptr<IEffect> DGSLEffectFactory::Impl::CreateEffect( DGSLEffectFactory* factory, const DGSLEffectFactory::EffectInfo& info, ID3D11DeviceContext* deviceContext )
std::shared_ptr<IEffect> DGSLEffectFactory::Impl::CreateEffect(DGSLEffectFactory* factory, const DGSLEffectFactory::EffectInfo& info, ID3D11DeviceContext* deviceContext)
{
if ( info.enableDualTexture )
if (info.enableDualTexture)
{
throw std::exception( "DGSLEffect does not support multiple texcoords" );
throw std::exception("DGSLEffect does not support multiple texcoords");
}
if ( mSharing && info.name && *info.name )
if (mSharing && info.name && *info.name)
{
if ( info.enableSkinning )
if (info.enableSkinning)
{
auto it = mEffectCacheSkinning.find( info.name );
if ( it != mEffectCacheSkinning.end() )
auto it = mEffectCacheSkinning.find(info.name);
if (it != mEffectCacheSkinning.end())
{
return it->second;
}
}
else
{
auto it = mEffectCache.find( info.name );
if ( it != mEffectCache.end() )
auto it = mEffectCache.find(info.name);
if (it != mEffectCache.end())
{
return it->second;
}
}
}
auto effect = std::make_shared<DGSLEffect>( device.Get(), nullptr, info.enableSkinning );
auto effect = std::make_shared<DGSLEffect>(mDevice.Get(), nullptr, info.enableSkinning);
effect->EnableDefaultLighting();
effect->SetLightingEnabled(true);
XMVECTOR color = XMLoadFloat3( &info.ambientColor );
effect->SetAmbientColor( color );
XMVECTOR color = XMLoadFloat3(&info.ambientColor);
effect->SetAmbientColor(color);
color = XMLoadFloat3( &info.diffuseColor );
effect->SetDiffuseColor( color );
color = XMLoadFloat3(&info.diffuseColor);
effect->SetDiffuseColor(color);
effect->SetAlpha( info.alpha );
effect->SetAlpha(info.alpha);
if ( info.perVertexColor )
if (info.perVertexColor)
{
effect->SetVertexColorEnabled( true );
effect->SetVertexColorEnabled(true);
}
if ( info.specularColor.x != 0 || info.specularColor.y != 0 || info.specularColor.z != 0 )
if (info.specularColor.x != 0 || info.specularColor.y != 0 || info.specularColor.z != 0)
{
color = XMLoadFloat3( &info.specularColor );
effect->SetSpecularColor( color );
effect->SetSpecularPower( info.specularPower );
color = XMLoadFloat3(&info.specularColor);
effect->SetSpecularColor(color);
effect->SetSpecularPower(info.specularPower);
}
if ( info.emissiveColor.x != 0 || info.emissiveColor.y != 0 || info.emissiveColor.z != 0 )
if (info.emissiveColor.x != 0 || info.emissiveColor.y != 0 || info.emissiveColor.z != 0)
{
color = XMLoadFloat3( &info.emissiveColor );
effect->SetEmissiveColor( color );
color = XMLoadFloat3(&info.emissiveColor);
effect->SetEmissiveColor(color);
}
if ( info.diffuseTexture && *info.diffuseTexture )
if (info.diffuseTexture && *info.diffuseTexture)
{
ComPtr<ID3D11ShaderResourceView> srv;
factory->CreateTexture( info.diffuseTexture, deviceContext, srv.GetAddressOf() );
factory->CreateTexture(info.diffuseTexture, deviceContext, srv.GetAddressOf());
effect->SetTexture( srv.Get() );
effect->SetTexture(srv.Get());
effect->SetTextureEnabled(true);
}
if ( mSharing && info.name && *info.name )
if (mSharing && info.name && *info.name)
{
std::lock_guard<std::mutex> lock(mutex);
if ( info.enableSkinning )
if (info.enableSkinning)
{
mEffectCacheSkinning.insert( EffectCache::value_type( info.name, effect ) );
mEffectCacheSkinning.insert(EffectCache::value_type(info.name, effect));
}
else
{
mEffectCache.insert( EffectCache::value_type( info.name, effect ) );
mEffectCache.insert(EffectCache::value_type(info.name, effect));
}
}
@ -165,22 +161,22 @@ std::shared_ptr<IEffect> DGSLEffectFactory::Impl::CreateEffect( DGSLEffectFactor
_Use_decl_annotations_
std::shared_ptr<IEffect> DGSLEffectFactory::Impl::CreateDGSLEffect( DGSLEffectFactory* factory, const DGSLEffectFactory::DGSLEffectInfo& info, ID3D11DeviceContext* deviceContext )
std::shared_ptr<IEffect> DGSLEffectFactory::Impl::CreateDGSLEffect(DGSLEffectFactory* factory, const DGSLEffectFactory::DGSLEffectInfo& info, ID3D11DeviceContext* deviceContext)
{
if ( mSharing && info.name && *info.name )
if (mSharing && info.name && *info.name)
{
if ( info.enableSkinning )
if (info.enableSkinning)
{
auto it = mEffectCacheSkinning.find( info.name );
if ( it != mEffectCacheSkinning.end() )
auto it = mEffectCacheSkinning.find(info.name);
if (it != mEffectCacheSkinning.end())
{
return it->second;
}
}
else
{
auto it = mEffectCache.find( info.name );
if ( it != mEffectCache.end() )
auto it = mEffectCache.find(info.name);
if (it != mEffectCache.end())
{
return it->second;
}
@ -192,152 +188,152 @@ std::shared_ptr<IEffect> DGSLEffectFactory::Impl::CreateDGSLEffect( DGSLEffectFa
bool lighting = true;
bool allowSpecular = true;
if ( !info.pixelShader || !*info.pixelShader )
if (!info.pixelShader || !*info.pixelShader)
{
effect = std::make_shared<DGSLEffect>( device.Get(), nullptr, info.enableSkinning );
effect = std::make_shared<DGSLEffect>(mDevice.Get(), nullptr, info.enableSkinning);
}
else
{
wchar_t root[ MAX_PATH ] = {};
auto last = wcsrchr( info.pixelShader, '_' );
if ( last )
wchar_t root[MAX_PATH] = {};
auto last = wcsrchr(info.pixelShader, '_');
if (last)
{
wcscpy_s( root, last+1 );
wcscpy_s(root, last + 1);
}
else
{
wcscpy_s( root, info.pixelShader );
wcscpy_s(root, info.pixelShader);
}
auto first = wcschr( root, '.' );
if ( first )
auto first = wcschr(root, '.');
if (first)
*first = 0;
if ( !_wcsicmp( root, L"lambert" ) )
if (!_wcsicmp(root, L"lambert"))
{
allowSpecular = false;
effect = std::make_shared<DGSLEffect>( device.Get(), nullptr, info.enableSkinning );
effect = std::make_shared<DGSLEffect>(mDevice.Get(), nullptr, info.enableSkinning);
}
else if ( !_wcsicmp( root, L"phong" ) )
else if (!_wcsicmp(root, L"phong"))
{
effect = std::make_shared<DGSLEffect>( device.Get(), nullptr, info.enableSkinning );
effect = std::make_shared<DGSLEffect>(mDevice.Get(), nullptr, info.enableSkinning);
}
else if ( !_wcsicmp( root, L"unlit" ) )
else if (!_wcsicmp(root, L"unlit"))
{
lighting = false;
effect = std::make_shared<DGSLEffect>( device.Get(), nullptr, info.enableSkinning );
effect = std::make_shared<DGSLEffect>(mDevice.Get(), nullptr, info.enableSkinning);
}
else if ( device->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0 )
else if (mDevice->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0)
{
// DGSL shaders are not compatible with Feature Level 9.x, use fallback shader
wcscat_s( root, L".cso" );
wcscat_s(root, L".cso");
ComPtr<ID3D11PixelShader> ps;
factory->CreatePixelShader( root, ps.GetAddressOf() );
factory->CreatePixelShader(root, ps.GetAddressOf());
effect = std::make_shared<DGSLEffect>( device.Get(), ps.Get(), info.enableSkinning );
effect = std::make_shared<DGSLEffect>(mDevice.Get(), ps.Get(), info.enableSkinning);
}
else
{
// Create DGSL shader and use it for the effect
ComPtr<ID3D11PixelShader> ps;
factory->CreatePixelShader( info.pixelShader, ps.GetAddressOf() );
factory->CreatePixelShader(info.pixelShader, ps.GetAddressOf());
effect = std::make_shared<DGSLEffect>( device.Get(), ps.Get(), info.enableSkinning );
effect = std::make_shared<DGSLEffect>(mDevice.Get(), ps.Get(), info.enableSkinning);
}
}
if ( lighting )
if (lighting)
{
effect->EnableDefaultLighting();
effect->SetLightingEnabled(true);
}
XMVECTOR color = XMLoadFloat3( &info.ambientColor );
effect->SetAmbientColor( color );
XMVECTOR color = XMLoadFloat3(&info.ambientColor);
effect->SetAmbientColor(color);
color = XMLoadFloat3( &info.diffuseColor );
effect->SetDiffuseColor( color );
effect->SetAlpha( info.alpha );
color = XMLoadFloat3(&info.diffuseColor);
effect->SetDiffuseColor(color);
effect->SetAlpha(info.alpha);
if ( info.perVertexColor )
if (info.perVertexColor)
{
effect->SetVertexColorEnabled( true );
effect->SetVertexColorEnabled(true);
}
effect->SetAlphaDiscardEnable(true);
if ( allowSpecular
&& ( info.specularColor.x != 0 || info.specularColor.y != 0 || info.specularColor.z != 0 ) )
if (allowSpecular
&& (info.specularColor.x != 0 || info.specularColor.y != 0 || info.specularColor.z != 0))
{
color = XMLoadFloat3( &info.specularColor );
effect->SetSpecularColor( color );
effect->SetSpecularPower( info.specularPower );
color = XMLoadFloat3(&info.specularColor);
effect->SetSpecularColor(color);
effect->SetSpecularPower(info.specularPower);
}
else
{
effect->DisableSpecular();
}
if ( info.emissiveColor.x != 0 || info.emissiveColor.y != 0 || info.emissiveColor.z != 0 )
if (info.emissiveColor.x != 0 || info.emissiveColor.y != 0 || info.emissiveColor.z != 0)
{
color = XMLoadFloat3( &info.emissiveColor );
effect->SetEmissiveColor( color );
color = XMLoadFloat3(&info.emissiveColor);
effect->SetEmissiveColor(color);
}
if ( info.diffuseTexture && *info.diffuseTexture )
if (info.diffuseTexture && *info.diffuseTexture)
{
ComPtr<ID3D11ShaderResourceView> srv;
factory->CreateTexture( info.diffuseTexture, deviceContext, srv.GetAddressOf() );
factory->CreateTexture(info.diffuseTexture, deviceContext, srv.GetAddressOf());
effect->SetTexture( srv.Get() );
effect->SetTexture(srv.Get());
effect->SetTextureEnabled(true);
}
if ( info.specularTexture && *info.specularTexture )
if (info.specularTexture && *info.specularTexture)
{
ComPtr<ID3D11ShaderResourceView> srv;
factory->CreateTexture( info.specularTexture, deviceContext, srv.GetAddressOf() );
factory->CreateTexture(info.specularTexture, deviceContext, srv.GetAddressOf());
effect->SetTexture( 1, srv.Get() );
effect->SetTexture(1, srv.Get());
effect->SetTextureEnabled(true);
}
if ( info.normalTexture && *info.normalTexture )
if (info.normalTexture && *info.normalTexture)
{
ComPtr<ID3D11ShaderResourceView> srv;
factory->CreateTexture( info.normalTexture, deviceContext, srv.GetAddressOf() );
factory->CreateTexture(info.normalTexture, deviceContext, srv.GetAddressOf());
effect->SetTexture( 2, srv.Get() );
effect->SetTexture(2, srv.Get());
effect->SetTextureEnabled(true);
}
for( int j = 0; j < _countof(info.textures); ++j )
for (int j = 0; j < _countof(info.textures); ++j)
{
if ( info.textures[j] && *info.textures[j] )
if (info.textures[j] && *info.textures[j])
{
ComPtr<ID3D11ShaderResourceView> srv;
factory->CreateTexture( info.textures[j], deviceContext, srv.GetAddressOf() );
factory->CreateTexture(info.textures[j], deviceContext, srv.GetAddressOf());
effect->SetTexture( j + DGSLEffectInfo::BaseTextureOffset, srv.Get() );
effect->SetTexture(j + DGSLEffectInfo::BaseTextureOffset, srv.Get());
effect->SetTextureEnabled(true);
}
}
if ( mSharing && info.name && *info.name )
if (mSharing && info.name && *info.name)
{
std::lock_guard<std::mutex> lock(mutex);
if ( info.enableSkinning )
if (info.enableSkinning)
{
mEffectCacheSkinning.insert( EffectCache::value_type( info.name, effect ) );
mEffectCacheSkinning.insert(EffectCache::value_type(info.name, effect));
}
else
{
mEffectCache.insert( EffectCache::value_type( info.name, effect ) );
mEffectCache.insert(EffectCache::value_type(info.name, effect));
}
}
@ -346,18 +342,18 @@ std::shared_ptr<IEffect> DGSLEffectFactory::Impl::CreateDGSLEffect( DGSLEffectFa
_Use_decl_annotations_
void DGSLEffectFactory::Impl::CreateTexture( const wchar_t* name, ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView** textureView )
void DGSLEffectFactory::Impl::CreateTexture(const wchar_t* name, ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView** textureView)
{
if ( !name || !textureView )
if (!name || !textureView)
throw std::exception("invalid arguments");
#if defined(_XBOX_ONE) && defined(_TITLE)
UNREFERENCED_PARAMETER(deviceContext);
#endif
auto it = mTextureCache.find( name );
auto it = mTextureCache.find(name);
if ( mSharing && it != mTextureCache.end() )
if (mSharing && it != mTextureCache.end())
{
ID3D11ShaderResourceView* srv = it->second.Get();
srv->AddRef();
@ -366,82 +362,82 @@ void DGSLEffectFactory::Impl::CreateTexture( const wchar_t* name, ID3D11DeviceCo
else
{
wchar_t fullName[MAX_PATH] = {};
wcscpy_s( fullName, mPath );
wcscat_s( fullName, name );
wcscpy_s(fullName, mPath);
wcscat_s(fullName, name);
WIN32_FILE_ATTRIBUTE_DATA fileAttr = {};
if ( !GetFileAttributesExW(fullName, GetFileExInfoStandard, &fileAttr) )
if (!GetFileAttributesExW(fullName, GetFileExInfoStandard, &fileAttr))
{
// Try Current Working Directory (CWD)
wcscpy_s( fullName, name );
if ( !GetFileAttributesExW(fullName, GetFileExInfoStandard, &fileAttr) )
wcscpy_s(fullName, name);
if (!GetFileAttributesExW(fullName, GetFileExInfoStandard, &fileAttr))
{
DebugTrace( "DGSLEffectFactory could not find texture file '%ls'\n", name );
throw std::exception( "CreateTexture" );
DebugTrace("DGSLEffectFactory could not find texture file '%ls'\n", name);
throw std::exception("CreateTexture");
}
}
wchar_t ext[_MAX_EXT];
_wsplitpath_s( name, nullptr, 0, nullptr, 0, nullptr, 0, ext, _MAX_EXT );
_wsplitpath_s(name, nullptr, 0, nullptr, 0, nullptr, 0, ext, _MAX_EXT);
if ( _wcsicmp( ext, L".dds" ) == 0 )
if (_wcsicmp(ext, L".dds") == 0)
{
HRESULT hr = CreateDDSTextureFromFileEx(
device.Get(), fullName, 0,
mDevice.Get(), fullName, 0,
D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0,
mForceSRGB, nullptr, textureView);
if ( FAILED(hr) )
if (FAILED(hr))
{
DebugTrace( "CreateDDSTextureFromFile failed (%08X) for '%ls'\n", hr, fullName );
throw std::exception( "CreateDDSTextureFromFile" );
DebugTrace("CreateDDSTextureFromFile failed (%08X) for '%ls'\n", hr, fullName);
throw std::exception("CreateDDSTextureFromFile");
}
}
#if !defined(_XBOX_ONE) || !defined(_TITLE)
else if ( deviceContext )
#if !defined(_XBOX_ONE) || !defined(_TITLE)
else if (deviceContext)
{
std::lock_guard<std::mutex> lock(mutex);
HRESULT hr = CreateWICTextureFromFileEx(
device.Get(), deviceContext, fullName, 0,
mDevice.Get(), deviceContext, fullName, 0,
D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0,
mForceSRGB ? WIC_LOADER_FORCE_SRGB : WIC_LOADER_DEFAULT, nullptr, textureView );
if ( FAILED(hr) )
mForceSRGB ? WIC_LOADER_FORCE_SRGB : WIC_LOADER_DEFAULT, nullptr, textureView);
if (FAILED(hr))
{
DebugTrace( "CreateWICTextureFromFile failed (%08X) for '%ls'\n", hr, fullName );
throw std::exception( "CreateWICTextureFromFile" );
DebugTrace("CreateWICTextureFromFile failed (%08X) for '%ls'\n", hr, fullName);
throw std::exception("CreateWICTextureFromFile");
}
}
#endif
#endif
else
{
HRESULT hr = CreateWICTextureFromFileEx(
device.Get(), fullName, 0,
mDevice.Get(), fullName, 0,
D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0,
mForceSRGB ? WIC_LOADER_FORCE_SRGB : WIC_LOADER_DEFAULT, nullptr, textureView );
if ( FAILED(hr) )
mForceSRGB ? WIC_LOADER_FORCE_SRGB : WIC_LOADER_DEFAULT, nullptr, textureView);
if (FAILED(hr))
{
DebugTrace( "CreateWICTextureFromFile failed (%08X) for '%ls'\n", hr, fullName );
throw std::exception( "CreateWICTextureFromFile" );
DebugTrace("CreateWICTextureFromFile failed (%08X) for '%ls'\n", hr, fullName);
throw std::exception("CreateWICTextureFromFile");
}
}
if ( mSharing && *name && it == mTextureCache.end() )
{
if (mSharing && *name && it == mTextureCache.end())
{
std::lock_guard<std::mutex> lock(mutex);
mTextureCache.insert( TextureCache::value_type( name, *textureView ) );
mTextureCache.insert(TextureCache::value_type(name, *textureView));
}
}
}
_Use_decl_annotations_
void DGSLEffectFactory::Impl::CreatePixelShader( const wchar_t* name, ID3D11PixelShader** pixelShader )
void DGSLEffectFactory::Impl::CreatePixelShader(const wchar_t* name, ID3D11PixelShader** pixelShader)
{
if ( !name || !pixelShader )
if (!name || !pixelShader)
throw std::exception("invalid arguments");
auto it = mShaderCache.find( name );
auto it = mShaderCache.find(name);
if ( mSharing && it != mShaderCache.end() )
if (mSharing && it != mShaderCache.end())
{
ID3D11PixelShader* ps = it->second.Get();
ps->AddRef();
@ -450,39 +446,39 @@ void DGSLEffectFactory::Impl::CreatePixelShader( const wchar_t* name, ID3D11Pixe
else
{
wchar_t fullName[MAX_PATH] = {};
wcscpy_s( fullName, mPath );
wcscat_s( fullName, name );
wcscpy_s(fullName, mPath);
wcscat_s(fullName, name);
WIN32_FILE_ATTRIBUTE_DATA fileAttr = {};
if ( !GetFileAttributesExW(fullName, GetFileExInfoStandard, &fileAttr) )
if (!GetFileAttributesExW(fullName, GetFileExInfoStandard, &fileAttr))
{
// Try Current Working Directory (CWD)
wcscpy_s( fullName, name );
if ( !GetFileAttributesExW(fullName, GetFileExInfoStandard, &fileAttr) )
wcscpy_s(fullName, name);
if (!GetFileAttributesExW(fullName, GetFileExInfoStandard, &fileAttr))
{
DebugTrace( "DGSLEffectFactory could not find shader file '%ls'\n", name );
throw std::exception( "CreatePixelShader" );
DebugTrace("DGSLEffectFactory could not find shader file '%ls'\n", name);
throw std::exception("CreatePixelShader");
}
}
size_t dataSize = 0;
std::unique_ptr<uint8_t[]> data;
HRESULT hr = BinaryReader::ReadEntireFile( fullName, data, &dataSize );
if ( FAILED(hr) )
HRESULT hr = BinaryReader::ReadEntireFile(fullName, data, &dataSize);
if (FAILED(hr))
{
DebugTrace( "CreatePixelShader failed (%08X) to load shader file '%ls'\n", hr, fullName );
throw std::exception( "CreatePixelShader" );
DebugTrace("CreatePixelShader failed (%08X) to load shader file '%ls'\n", hr, fullName);
throw std::exception("CreatePixelShader");
}
ThrowIfFailed(
device->CreatePixelShader( data.get(), dataSize, nullptr, pixelShader ) );
mDevice->CreatePixelShader(data.get(), dataSize, nullptr, pixelShader));
_Analysis_assume_(*pixelShader != 0);
if ( mSharing && *name && it == mShaderCache.end() )
{
if (mSharing && *name && it == mShaderCache.end())
{
std::lock_guard<std::mutex> lock(mutex);
mShaderCache.insert( ShaderCache::value_type( name, *pixelShader ) );
mShaderCache.insert(ShaderCache::value_type(name, *pixelShader));
}
}
}
@ -513,12 +509,12 @@ DGSLEffectFactory::~DGSLEffectFactory()
}
DGSLEffectFactory::DGSLEffectFactory(DGSLEffectFactory&& moveFrom)
DGSLEffectFactory::DGSLEffectFactory(DGSLEffectFactory&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
DGSLEffectFactory& DGSLEffectFactory::operator= (DGSLEffectFactory&& moveFrom)
DGSLEffectFactory& DGSLEffectFactory::operator= (DGSLEffectFactory&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;
@ -527,30 +523,30 @@ DGSLEffectFactory& DGSLEffectFactory::operator= (DGSLEffectFactory&& moveFrom)
// IEffectFactory methods
_Use_decl_annotations_
std::shared_ptr<IEffect> DGSLEffectFactory::CreateEffect( const EffectInfo& info, ID3D11DeviceContext* deviceContext )
std::shared_ptr<IEffect> DGSLEffectFactory::CreateEffect(const EffectInfo& info, ID3D11DeviceContext* deviceContext)
{
return pImpl->CreateEffect( this, info, deviceContext );
return pImpl->CreateEffect(this, info, deviceContext);
}
_Use_decl_annotations_
void DGSLEffectFactory::CreateTexture( const wchar_t* name, ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView** textureView )
void DGSLEffectFactory::CreateTexture(const wchar_t* name, ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView** textureView)
{
return pImpl->CreateTexture( name, deviceContext, textureView );
return pImpl->CreateTexture(name, deviceContext, textureView);
}
// DGSL methods.
_Use_decl_annotations_
std::shared_ptr<IEffect> DGSLEffectFactory::CreateDGSLEffect( const DGSLEffectInfo& info, ID3D11DeviceContext* deviceContext )
std::shared_ptr<IEffect> DGSLEffectFactory::CreateDGSLEffect(const DGSLEffectInfo& info, ID3D11DeviceContext* deviceContext)
{
return pImpl->CreateDGSLEffect( this, info, deviceContext );
return pImpl->CreateDGSLEffect(this, info, deviceContext);
}
_Use_decl_annotations_
void DGSLEffectFactory::CreatePixelShader( const wchar_t* shader, ID3D11PixelShader** pixelShader )
void DGSLEffectFactory::CreatePixelShader(const wchar_t* shader, ID3D11PixelShader** pixelShader)
{
pImpl->CreatePixelShader( shader, pixelShader );
pImpl->CreatePixelShader(shader, pixelShader);
}
@ -560,32 +556,37 @@ void DGSLEffectFactory::ReleaseCache()
pImpl->ReleaseCache();
}
void DGSLEffectFactory::SetSharing( bool enabled )
void DGSLEffectFactory::SetSharing(bool enabled)
{
pImpl->SetSharing( enabled );
pImpl->SetSharing(enabled);
}
void DGSLEffectFactory::EnableForceSRGB(bool forceSRGB)
{
pImpl->EnableForceSRGB( forceSRGB );
pImpl->EnableForceSRGB(forceSRGB);
}
void DGSLEffectFactory::SetDirectory( _In_opt_z_ const wchar_t* path )
void DGSLEffectFactory::SetDirectory(_In_opt_z_ const wchar_t* path)
{
if ( path && *path != 0 )
if (path && *path != 0)
{
wcscpy_s( pImpl->mPath, path );
size_t len = wcsnlen( pImpl->mPath, MAX_PATH );
if ( len > 0 && len < (MAX_PATH-1) )
wcscpy_s(pImpl->mPath, path);
size_t len = wcsnlen(pImpl->mPath, MAX_PATH);
if (len > 0 && len < (MAX_PATH - 1))
{
// Ensure it has a trailing slash
if ( pImpl->mPath[len-1] != L'\\' )
if (pImpl->mPath[len - 1] != L'\\')
{
pImpl->mPath[len] = L'\\';
pImpl->mPath[len+1] = 0;
pImpl->mPath[len + 1] = 0;
}
}
}
else
*pImpl->mPath = 0;
}
ID3D11Device* DGSLEffectFactory::GetDevice() const
{
return pImpl->mDevice.Get();
}

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: DebugEffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -28,7 +24,7 @@ struct DebugEffectConstants
XMMATRIX worldViewProj;
};
static_assert( ( sizeof(DebugEffectConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert((sizeof(DebugEffectConstants) % 16) == 0, "CB size not padded correctly");
// Traits type describes our characteristics to the EffectBase template.
@ -175,10 +171,10 @@ DebugEffect::Impl::Impl(_In_ ID3D11Device* device)
throw std::exception("DebugEffect requires Feature Level 10.0 or later");
}
static_assert( _countof(EffectBase<DebugEffectTraits>::VertexShaderIndices) ==DebugEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert( _countof(EffectBase<DebugEffectTraits>::VertexShaderBytecode) ==DebugEffectTraits::VertexShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<DebugEffectTraits>::PixelShaderBytecode) ==DebugEffectTraits::PixelShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<DebugEffectTraits>::PixelShaderIndices) ==DebugEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert(_countof(EffectBase<DebugEffectTraits>::VertexShaderIndices) == DebugEffectTraits::ShaderPermutationCount, "array/max mismatch");
static_assert(_countof(EffectBase<DebugEffectTraits>::VertexShaderBytecode) == DebugEffectTraits::VertexShaderCount, "array/max mismatch");
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 };
@ -235,20 +231,20 @@ void DebugEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
// Public constructor.
DebugEffect::DebugEffect(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
: pImpl(std::make_unique<Impl>(device))
{
}
// Move constructor.
DebugEffect::DebugEffect(DebugEffect&& moveFrom)
DebugEffect::DebugEffect(DebugEffect&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
DebugEffect& DebugEffect::operator= (DebugEffect&& moveFrom)
DebugEffect& DebugEffect::operator= (DebugEffect&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: DemandCreate.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: DualPostProcess.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -257,28 +253,29 @@ void DualPostProcess::Impl::Process(_In_ ID3D11DeviceContext* deviceContext, std
}
// Draw quad.
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
deviceContext->IASetInputLayout(nullptr);
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
deviceContext->Draw(4, 0);
deviceContext->Draw(3, 0);
}
// Public constructor.
DualPostProcess::DualPostProcess(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
: pImpl(std::make_unique<Impl>(device))
{
}
// Move constructor.
DualPostProcess::DualPostProcess(DualPostProcess&& moveFrom)
DualPostProcess::DualPostProcess(DualPostProcess&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
DualPostProcess& DualPostProcess::operator= (DualPostProcess&& moveFrom)
DualPostProcess& DualPostProcess::operator= (DualPostProcess&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: DualTextureEffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -27,7 +23,7 @@ struct DualTextureEffectConstants
XMMATRIX worldViewProj;
};
static_assert( ( sizeof(DualTextureEffectConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert((sizeof(DualTextureEffectConstants) % 16) == 0, "CB size not padded correctly");
// Traits type describes our characteristics to the EffectBase template.
@ -132,10 +128,10 @@ DualTextureEffect::Impl::Impl(_In_ ID3D11Device* device)
: EffectBase(device),
vertexColorEnabled(false)
{
static_assert( _countof(EffectBase<DualTextureEffectTraits>::VertexShaderIndices) == DualTextureEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert( _countof(EffectBase<DualTextureEffectTraits>::VertexShaderBytecode) == DualTextureEffectTraits::VertexShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<DualTextureEffectTraits>::PixelShaderBytecode) == DualTextureEffectTraits::PixelShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<DualTextureEffectTraits>::PixelShaderIndices) == DualTextureEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert(_countof(EffectBase<DualTextureEffectTraits>::VertexShaderIndices) == DualTextureEffectTraits::ShaderPermutationCount, "array/max mismatch");
static_assert(_countof(EffectBase<DualTextureEffectTraits>::VertexShaderBytecode) == DualTextureEffectTraits::VertexShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<DualTextureEffectTraits>::PixelShaderBytecode) == DualTextureEffectTraits::PixelShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<DualTextureEffectTraits>::PixelShaderIndices) == DualTextureEffectTraits::ShaderPermutationCount, "array/max mismatch");
}
@ -185,20 +181,20 @@ void DualTextureEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
// Public constructor.
DualTextureEffect::DualTextureEffect(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
: pImpl(std::make_unique<Impl>(device))
{
}
// Move constructor.
DualTextureEffect::DualTextureEffect(DualTextureEffect&& moveFrom)
DualTextureEffect::DualTextureEffect(DualTextureEffect&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
DualTextureEffect& DualTextureEffect::operator= (DualTextureEffect&& moveFrom)
DualTextureEffect& DualTextureEffect::operator= (DualTextureEffect&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: EffectCommon.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -29,7 +25,7 @@ void XM_CALLCONV IEffectMatrices::SetMatrices(FXMMATRIX world, CXMMATRIX view, C
// Constructor initializes default matrix values.
EffectMatrices::EffectMatrices()
EffectMatrices::EffectMatrices() throw()
{
world = XMMatrixIdentity();
view = XMMatrixIdentity();
@ -54,7 +50,7 @@ _Use_decl_annotations_ void EffectMatrices::SetConstants(int& dirtyFlags, XMMATR
// Constructor initializes default fog settings.
EffectFog::EffectFog() :
EffectFog::EffectFog() throw() :
enabled(false),
start(0),
end(1.f)
@ -113,7 +109,7 @@ void XM_CALLCONV EffectFog::SetConstants(int& dirtyFlags, FXMMATRIX worldView, X
// Constructor initializes default material color settings.
EffectColor::EffectColor() :
EffectColor::EffectColor() throw() :
alpha(1.f)
{
diffuseColor = g_XMOne;
@ -137,7 +133,7 @@ void EffectColor::SetConstants(_Inout_ int& dirtyFlags, _Inout_ XMVECTOR& diffus
// Constructor initializes default light settings.
EffectLights::EffectLights()
EffectLights::EffectLights() throw()
{
emissiveColor = g_XMZero;
ambientLightColor = g_XMZero;
@ -419,7 +415,7 @@ ID3D11ShaderResourceView* EffectDeviceResources::GetDefaultTexture()
return DemandCreate(mDefaultTexture, mMutex, [&](ID3D11ShaderResourceView** pResult) -> HRESULT
{
static const uint32_t s_pixel = 0xffffffff;
D3D11_SUBRESOURCE_DATA initData = { &s_pixel, sizeof(uint32_t), 0 };
D3D11_TEXTURE2D_DESC desc = {};
@ -430,7 +426,7 @@ ID3D11ShaderResourceView* EffectDeviceResources::GetDefaultTexture()
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
ComPtr<ID3D11Texture2D> tex;
HRESULT hr = mDevice->CreateTexture2D( &desc, &initData, tex.GetAddressOf() );
HRESULT hr = mDevice->CreateTexture2D(&desc, &initData, tex.GetAddressOf());
if (SUCCEEDED(hr))
{
@ -441,7 +437,7 @@ ID3D11ShaderResourceView* EffectDeviceResources::GetDefaultTexture()
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
SRVDesc.Texture2D.MipLevels = 1;
hr = mDevice->CreateShaderResourceView( tex.Get(), &SRVDesc, pResult );
hr = mDevice->CreateShaderResourceView(tex.Get(), &SRVDesc, pResult);
if (SUCCEEDED(hr))
SetDebugObjectName(*pResult, "DirectXTK:Effect");
}

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: EffectCommon.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -47,7 +43,7 @@ namespace DirectX
// Helper stores matrix parameter values, and computes derived matrices.
struct EffectMatrices
{
EffectMatrices();
EffectMatrices() throw();
XMMATRIX world;
XMMATRIX view;
@ -61,7 +57,7 @@ namespace DirectX
// Helper stores the current fog settings, and computes derived shader parameters.
struct EffectFog
{
EffectFog();
EffectFog() throw();
bool enabled;
float start;
@ -74,7 +70,7 @@ namespace DirectX
// Helper stores material color settings, and computes derived parameters for shaders that do not support realtime lighting.
struct EffectColor
{
EffectColor();
EffectColor() throw();
XMVECTOR diffuseColor;
float alpha;
@ -86,7 +82,7 @@ namespace DirectX
// Helper stores the current light settings, and computes derived shader parameters.
struct EffectLights : public EffectColor
{
EffectLights();
EffectLights() throw();
static const int MaxDirectionalLights = IEffectLights::MaxDirectionalLights;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: EffectFactory.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -28,28 +24,28 @@ class EffectFactory::Impl
{
public:
Impl(_In_ ID3D11Device* device)
: mPath{},
device(device),
: mPath{},
mDevice(device),
mSharing(true),
mUseNormalMapEffect(true),
mForceSRGB(false)
{}
std::shared_ptr<IEffect> CreateEffect( _In_ IEffectFactory* factory, _In_ const IEffectFactory::EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext );
void CreateTexture( _In_z_ const wchar_t* texture, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView );
std::shared_ptr<IEffect> CreateEffect(_In_ IEffectFactory* factory, _In_ const IEffectFactory::EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext);
void CreateTexture(_In_z_ const wchar_t* texture, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView);
void ReleaseCache();
void SetSharing( bool enabled ) { mSharing = enabled; }
void EnableNormalMapEffect( bool enabled ) { mUseNormalMapEffect = enabled; }
void SetSharing(bool enabled) { mSharing = enabled; }
void EnableNormalMapEffect(bool enabled) { mUseNormalMapEffect = enabled; }
void EnableForceSRGB(bool forceSRGB) { mForceSRGB = forceSRGB; }
static SharedResourcePool<ID3D11Device*, Impl> instancePool;
wchar_t mPath[MAX_PATH];
private:
ComPtr<ID3D11Device> device;
ComPtr<ID3D11Device> mDevice;
private:
typedef std::map< std::wstring, std::shared_ptr<IEffect> > EffectCache;
typedef std::map< std::wstring, ComPtr<ID3D11ShaderResourceView> > TextureCache;
@ -86,7 +82,7 @@ std::shared_ptr<IEffect> EffectFactory::Impl::CreateEffect(IEffectFactory* facto
}
}
auto effect = std::make_shared<SkinnedEffect>(device.Get());
auto effect = std::make_shared<SkinnedEffect>(mDevice.Get());
effect->EnableDefaultLighting();
@ -148,7 +144,7 @@ std::shared_ptr<IEffect> EffectFactory::Impl::CreateEffect(IEffectFactory* facto
}
}
auto effect = std::make_shared<DualTextureEffect>(device.Get());
auto effect = std::make_shared<DualTextureEffect>(mDevice.Get());
// Dual texture effect doesn't support lighting (usually it's lightmaps)
@ -200,7 +196,7 @@ std::shared_ptr<IEffect> EffectFactory::Impl::CreateEffect(IEffectFactory* facto
}
}
auto effect = std::make_shared<NormalMapEffect>(device.Get());
auto effect = std::make_shared<NormalMapEffect>(mDevice.Get());
effect->EnableDefaultLighting();
@ -285,7 +281,7 @@ std::shared_ptr<IEffect> EffectFactory::Impl::CreateEffect(IEffectFactory* facto
}
}
auto effect = std::make_shared<BasicEffect>(device.Get());
auto effect = std::make_shared<BasicEffect>(mDevice.Get());
effect->EnableDefaultLighting();
effect->SetLightingEnabled(true);
@ -386,7 +382,7 @@ void EffectFactory::Impl::CreateTexture(const wchar_t* name, ID3D11DeviceContext
if (_wcsicmp(ext, L".dds") == 0)
{
HRESULT hr = CreateDDSTextureFromFileEx(
device.Get(), fullName, 0,
mDevice.Get(), fullName, 0,
D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0,
mForceSRGB, nullptr, textureView);
if (FAILED(hr))
@ -395,12 +391,12 @@ void EffectFactory::Impl::CreateTexture(const wchar_t* name, ID3D11DeviceContext
throw std::exception("CreateDDSTextureFromFile");
}
}
#if !defined(_XBOX_ONE) || !defined(_TITLE)
#if !defined(_XBOX_ONE) || !defined(_TITLE)
else if (deviceContext)
{
std::lock_guard<std::mutex> lock(mutex);
HRESULT hr = CreateWICTextureFromFileEx(
device.Get(), deviceContext, fullName, 0,
mDevice.Get(), deviceContext, fullName, 0,
D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0,
mForceSRGB ? WIC_LOADER_FORCE_SRGB : WIC_LOADER_DEFAULT, nullptr, textureView);
if (FAILED(hr))
@ -409,11 +405,11 @@ void EffectFactory::Impl::CreateTexture(const wchar_t* name, ID3D11DeviceContext
throw std::exception("CreateWICTextureFromFile");
}
}
#endif
#endif
else
{
HRESULT hr = CreateWICTextureFromFileEx(
device.Get(), fullName, 0,
mDevice.Get(), fullName, 0,
D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0,
mForceSRGB ? WIC_LOADER_FORCE_SRGB : WIC_LOADER_DEFAULT, nullptr, textureView);
if (FAILED(hr))
@ -457,12 +453,12 @@ EffectFactory::~EffectFactory()
}
EffectFactory::EffectFactory(EffectFactory&& moveFrom)
EffectFactory::EffectFactory(EffectFactory&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
EffectFactory& EffectFactory::operator= (EffectFactory&& moveFrom)
EffectFactory& EffectFactory::operator= (EffectFactory&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;
@ -492,12 +488,12 @@ void EffectFactory::SetSharing(bool enabled)
void EffectFactory::EnableNormalMapEffect(bool enabled)
{
pImpl->EnableNormalMapEffect( enabled );
pImpl->EnableNormalMapEffect(enabled);
}
void EffectFactory::EnableForceSRGB(bool forceSRGB)
{
pImpl->EnableForceSRGB( forceSRGB );
pImpl->EnableForceSRGB(forceSRGB);
}
void EffectFactory::SetDirectory(_In_opt_z_ const wchar_t* path)
@ -518,4 +514,9 @@ void EffectFactory::SetDirectory(_In_opt_z_ const wchar_t* path)
}
else
*pImpl->mPath = 0;
}
}
ID3D11Device* EffectFactory::GetDevice() const
{
return pImpl->mDevice.Get();
}

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: EnvironmentMapEffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -42,7 +38,7 @@ struct EnvironmentMapEffectConstants
XMMATRIX worldViewProj;
};
static_assert( ( sizeof(EnvironmentMapEffectConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert((sizeof(EnvironmentMapEffectConstants) % 16) == 0, "CB size not padded correctly");
// Traits type describes our characteristics to the EffectBase template.
@ -265,16 +261,16 @@ SharedResourcePool<ID3D11Device*, EffectBase<EnvironmentMapEffectTraits>::Device
// Constructor.
EnvironmentMapEffect::Impl::Impl(_In_ ID3D11Device* device)
: EffectBase(device),
: EffectBase(device),
preferPerPixelLighting(false),
fresnelEnabled(true),
specularEnabled(false),
biasedVertexNormals(false)
{
static_assert( _countof(EffectBase<EnvironmentMapEffectTraits>::VertexShaderIndices) == EnvironmentMapEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert( _countof(EffectBase<EnvironmentMapEffectTraits>::VertexShaderBytecode) == EnvironmentMapEffectTraits::VertexShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<EnvironmentMapEffectTraits>::PixelShaderBytecode) == EnvironmentMapEffectTraits::PixelShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<EnvironmentMapEffectTraits>::PixelShaderIndices) == EnvironmentMapEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert(_countof(EffectBase<EnvironmentMapEffectTraits>::VertexShaderIndices) == EnvironmentMapEffectTraits::ShaderPermutationCount, "array/max mismatch");
static_assert(_countof(EffectBase<EnvironmentMapEffectTraits>::VertexShaderBytecode) == EnvironmentMapEffectTraits::VertexShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<EnvironmentMapEffectTraits>::PixelShaderBytecode) == EnvironmentMapEffectTraits::PixelShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<EnvironmentMapEffectTraits>::PixelShaderIndices) == EnvironmentMapEffectTraits::ShaderPermutationCount, "array/max mismatch");
constants.environmentMapAmount = 1;
constants.fresnelFactor = 1;
@ -356,20 +352,20 @@ void EnvironmentMapEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
// Public constructor.
EnvironmentMapEffect::EnvironmentMapEffect(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
: pImpl(std::make_unique<Impl>(device))
{
}
// Move constructor.
EnvironmentMapEffect::EnvironmentMapEffect(EnvironmentMapEffect&& moveFrom)
EnvironmentMapEffect::EnvironmentMapEffect(EnvironmentMapEffect&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
EnvironmentMapEffect& EnvironmentMapEffect::operator= (EnvironmentMapEffect&& moveFrom)
EnvironmentMapEffect& EnvironmentMapEffect::operator= (EnvironmentMapEffect&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: GamePad.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "pch.h"
@ -46,31 +43,31 @@ namespace
}
void ApplyStickDeadZone(float x, float y, GamePad::DeadZone deadZoneMode, float maxValue, float deadZoneSize,
_Out_ float& resultX, _Out_ float& resultY)
_Out_ float& resultX, _Out_ float& resultY)
{
switch (deadZoneMode)
{
case GamePad::DEAD_ZONE_INDEPENDENT_AXES:
resultX = ApplyLinearDeadZone(x, maxValue, deadZoneSize);
resultY = ApplyLinearDeadZone(y, maxValue, deadZoneSize);
case GamePad::DEAD_ZONE_INDEPENDENT_AXES:
resultX = ApplyLinearDeadZone(x, maxValue, deadZoneSize);
resultY = ApplyLinearDeadZone(y, maxValue, deadZoneSize);
break;
case GamePad::DEAD_ZONE_CIRCULAR:
{
float dist = sqrtf(x*x + y * y);
float wanted = ApplyLinearDeadZone(dist, maxValue, deadZoneSize);
float scale = (wanted > 0.f) ? (wanted / dist) : 0.f;
resultX = std::max(-1.f, std::min(x * scale, 1.f));
resultY = std::max(-1.f, std::min(y * scale, 1.f));
}
break;
case GamePad::DEAD_ZONE_CIRCULAR:
{
float dist = sqrtf(x*x + y*y);
float wanted = ApplyLinearDeadZone(dist, maxValue, deadZoneSize);
float scale = (wanted > 0.f) ? (wanted / dist) : 0.f;
resultX = std::max(-1.f, std::min(x * scale, 1.f));
resultY = std::max(-1.f, std::min(y * scale, 1.f));
}
break;
default: // GamePad::DEAD_ZONE_NONE
resultX = ApplyLinearDeadZone(x, maxValue, 0);
resultY = ApplyLinearDeadZone(y, maxValue, 0);
break;
default: // GamePad::DEAD_ZONE_NONE
resultX = ApplyLinearDeadZone(x, maxValue, 0);
resultY = ApplyLinearDeadZone(y, maxValue, 0);
break;
}
}
}
@ -207,12 +204,12 @@ public:
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 */,
state.thumbSticks.leftX, state.thumbSticks.leftY);
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
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 */,
state.thumbSticks.rightX, state.thumbSticks.rightY);
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
state.thumbSticks.rightX, state.thumbSticks.rightY);
state.triggers.left = static_cast<float>(reading.LeftTrigger);
state.triggers.right = static_cast<float>(reading.RightTrigger);
@ -651,12 +648,12 @@ public:
state.dpad.left = (reading.Buttons & GamepadButtons::GamepadButtons_DPadLeft) != 0;
ApplyStickDeadZone(reading.LeftThumbstickX, reading.LeftThumbstickY,
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
state.thumbSticks.leftX, state.thumbSticks.leftY);
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
state.thumbSticks.leftX, state.thumbSticks.leftY);
ApplyStickDeadZone(reading.RightThumbstickX, reading.RightThumbstickY,
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
state.thumbSticks.rightX, state.thumbSticks.rightY);
deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */,
state.thumbSticks.rightX, state.thumbSticks.rightY);
state.triggers.left = reading.LeftTrigger;
state.triggers.right = reading.RightTrigger;
@ -959,9 +956,9 @@ public:
ClearSlot(j, 0);
}
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
mSuspended = false;
#endif
#endif
if (s_gamePad)
{
@ -985,14 +982,14 @@ public:
if (!ThrottleRetry(player, time))
{
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
if (mSuspended)
{
memset(&state, 0, sizeof(State));
state.connected = mConnected[player];
return;
}
#endif
#endif
XINPUT_STATE xstate;
DWORD result = XInputGetState(DWORD(player), &xstate);
@ -1039,12 +1036,12 @@ public:
}
ApplyStickDeadZone(float(xstate.Gamepad.sThumbLX), float(xstate.Gamepad.sThumbLY),
deadZoneMode, 32767.f, float(XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE),
state.thumbSticks.leftX, state.thumbSticks.leftY);
deadZoneMode, 32767.f, float(XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE),
state.thumbSticks.leftX, state.thumbSticks.leftY);
ApplyStickDeadZone(float(xstate.Gamepad.sThumbRX), float(xstate.Gamepad.sThumbRY),
deadZoneMode, 32767.f, float(XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE),
state.thumbSticks.rightX, state.thumbSticks.rightY);
deadZoneMode, 32767.f, float(XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE),
state.thumbSticks.rightX, state.thumbSticks.rightY);
return;
}
@ -1080,7 +1077,7 @@ public:
if (xcaps.Type == XINPUT_DEVTYPE_GAMEPAD)
{
static_assert(Capabilities::GAMEPAD == XINPUT_DEVSUBTYPE_GAMEPAD, "xinput.h mismatch");
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
static_assert(XINPUT_DEVSUBTYPE_WHEEL == Capabilities::WHEEL, "xinput.h mismatch");
static_assert(XINPUT_DEVSUBTYPE_ARCADE_STICK == Capabilities::ARCADE_STICK, "xinput.h mismatch");
static_assert(XINPUT_DEVSUBTYPE_FLIGHT_STICK == Capabilities::FLIGHT_STICK, "xinput.h mismatch");
@ -1090,7 +1087,7 @@ public:
static_assert(XINPUT_DEVSUBTYPE_DRUM_KIT == Capabilities::DRUM_KIT, "xinput.h mismatch");
static_assert(XINPUT_DEVSUBTYPE_GUITAR_BASS == Capabilities::GUITAR_BASS, "xinput.h mismatch");
static_assert(XINPUT_DEVSUBTYPE_ARCADE_PAD == Capabilities::ARCADE_PAD, "xinput.h mismatch");
#endif
#endif
caps.gamepadType = Capabilities::Type(xcaps.SubType);
}
@ -1119,13 +1116,13 @@ public:
UNREFERENCED_PARAMETER(leftTrigger);
UNREFERENCED_PARAMETER(rightTrigger);
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
mLeftMotor[player] = leftMotor;
mRightMotor[player] = rightMotor;
if (mSuspended)
return mConnected[player];
#endif
#endif
XINPUT_VIBRATION xvibration;
xvibration.wLeftMotorSpeed = WORD(leftMotor * 0xFFFF);
@ -1148,10 +1145,10 @@ public:
void Suspend()
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
XInputEnable(FALSE);
#else
// For XInput 9.1.0, we have to emulate the behavior of XInputEnable( FALSE )
#else
// For XInput 9.1.0, we have to emulate the behavior of XInputEnable( FALSE )
if (!mSuspended)
{
for (size_t j = 0; j < XUSER_MAX_COUNT; ++j)
@ -1166,15 +1163,15 @@ public:
mSuspended = true;
}
#endif
#endif
}
void Resume()
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
XInputEnable(TRUE);
#else
// For XInput 9.1.0, we have to emulate the behavior of XInputEnable( TRUE )
#else
// For XInput 9.1.0, we have to emulate the behavior of XInputEnable( TRUE )
if (mSuspended)
{
ULONGLONG time = GetTickCount64();
@ -1196,7 +1193,7 @@ public:
mSuspended = false;
}
#endif
#endif
}
GamePad* mOwner;
@ -1248,9 +1245,9 @@ private:
{
mConnected[player] = false;
mLastReadTime[player] = time;
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
mLeftMotor[player] = mRightMotor[player] = 0.f;
#endif
#endif
}
int GetMostRecent()
@ -1279,13 +1276,13 @@ GamePad::Impl* GamePad::Impl::s_gamePad = nullptr;
// Public constructor.
GamePad::GamePad()
: pImpl(new Impl(this))
: pImpl(std::make_unique<Impl>(this))
{
}
// Move constructor.
GamePad::GamePad(GamePad&& moveFrom)
GamePad::GamePad(GamePad&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
pImpl->mOwner = this;
@ -1293,7 +1290,7 @@ GamePad::GamePad(GamePad&& moveFrom)
// Move assignment.
GamePad& GamePad::operator= (GamePad&& moveFrom)
GamePad& GamePad::operator= (GamePad&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
pImpl->mOwner = this;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: GeometricPrimitive.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -67,7 +63,7 @@ namespace
GeometricPrimitive::VertexType::InputElementCount,
shaderByteCode, byteCodeLength,
pInputLayout)
);
);
_Analysis_assume_(*pInputLayout != 0);
@ -80,6 +76,8 @@ namespace
class GeometricPrimitive::Impl
{
public:
Impl() throw() : mIndexCount(0) {}
void Initialize(_In_ ID3D11DeviceContext* deviceContext, const VertexCollection& vertices, const IndexCollection& indices);
void XM_CALLCONV Draw(FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, FXMVECTOR color, _In_opt_ ID3D11ShaderResourceView* texture, bool wireframe, std::function<void()>& setCustomState) const;
@ -311,7 +309,7 @@ void GeometricPrimitive::Impl::CreateInputLayout(IEffect* effect, ID3D11InputLay
// Constructor.
GeometricPrimitive::GeometricPrimitive()
: pImpl(new Impl())
: pImpl(std::make_unique<Impl>())
{
}

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: Geometry.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "pch.h"
@ -323,9 +320,9 @@ void DirectX::ComputeGeoSphere(VertexCollection& vertices, IndexCollection& indi
XMStoreFloat3(
&outVertex,
XMVectorScale(
XMVectorAdd(XMLoadFloat3(&vertexPositions[i0]), XMLoadFloat3(&vertexPositions[i1])),
0.5f
)
XMVectorAdd(XMLoadFloat3(&vertexPositions[i0]), XMLoadFloat3(&vertexPositions[i1])),
0.5f
)
);
outIndex = static_cast<uint16_t>(vertexPositions.size());
@ -799,7 +796,7 @@ void DirectX::ComputeTetrahedron(VertexCollection& vertices, IndexCollection& in
uint32_t v2 = faces[j + 2];
XMVECTOR normal = XMVector3Cross(verts[v1].v - verts[v0].v,
verts[v2].v - verts[v0].v);
verts[v2].v - verts[v0].v);
normal = XMVector3Normalize(normal);
size_t base = vertices.size();
@ -864,7 +861,7 @@ void DirectX::ComputeOctahedron(VertexCollection& vertices, IndexCollection& ind
uint32_t v2 = faces[j + 2];
XMVECTOR normal = XMVector3Cross(verts[v1].v - verts[v0].v,
verts[v2].v - verts[v0].v);
verts[v2].v - verts[v0].v);
normal = XMVector3Normalize(normal);
size_t base = vertices.size();
@ -979,7 +976,7 @@ void DirectX::ComputeDodecahedron(VertexCollection& vertices, IndexCollection& i
uint32_t v4 = faces[j + 4];
XMVECTOR normal = XMVector3Cross(verts[v1].v - verts[v0].v,
verts[v2].v - verts[v0].v);
verts[v2].v - verts[v0].v);
normal = XMVector3Normalize(normal);
size_t base = vertices.size();
@ -1080,7 +1077,7 @@ void DirectX::ComputeIcosahedron(VertexCollection& vertices, IndexCollection& in
uint32_t v2 = faces[j + 2];
XMVECTOR normal = XMVector3Cross(verts[v1].v - verts[v0].v,
verts[v2].v - verts[v0].v);
verts[v2].v - verts[v0].v);
normal = XMVector3Normalize(normal);
size_t base = vertices.size();
@ -1131,19 +1128,19 @@ namespace
// Create the index data.
size_t vbase = vertices.size();
Bezier::CreatePatchIndices(tessellation, isMirrored, [&](size_t index)
{
index_push_back(indices, vbase + index);
});
{
index_push_back(indices, vbase + index);
});
// Create the vertex data.
// Create the vertex data.
Bezier::CreatePatchVertices(controlPoints, tessellation, isMirrored, [&](FXMVECTOR position, FXMVECTOR normal, FXMVECTOR textureCoordinate)
{
vertices.push_back(VertexPositionNormalTexture(position, normal, textureCoordinate));
});
{
vertices.push_back(VertexPositionNormalTexture(position, normal, textureCoordinate));
});
}
}
// Creates a teapot primitive.
void DirectX::ComputeTeapot(VertexCollection& vertices, IndexCollection& indices, float size, size_t tessellation, bool rhcoords)
{

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: Geometry.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "VertexTypes.h"

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: GraphicsMemory.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -62,12 +58,12 @@ public:
void Initialize(_In_ ID3D11DeviceX* device, UINT backBufferCount)
{
assert( device != 0 );
assert(device != 0);
mDevice = device;
device->GetImmediateContextX( mDeviceContext.GetAddressOf() );
device->GetImmediateContextX(mDeviceContext.GetAddressOf());
mFrames.resize( backBufferCount );
mFrames.resize(backBufferCount);
}
void* Allocate(_In_opt_ ID3D11DeviceContext* deviceContext, size_t size, int alignment)
@ -164,7 +160,7 @@ public:
void* ptr = static_cast<uint8_t*>(mPages.front().mGrfxMemory) + mCurOffset;
mCurOffset += static_cast<UINT>( alignedSize );
mCurOffset += static_cast<UINT>(alignedSize);
return ptr;
}
@ -206,7 +202,7 @@ public:
ComPtr<ID3D11DeviceX> mDevice;
ComPtr<ID3D11DeviceContextX> mDeviceContext;
static GraphicsMemory::Impl* s_graphicsMemory;
};
@ -275,14 +271,14 @@ GraphicsMemory::GraphicsMemory(_In_ ID3D11DeviceX* device, UINT backBufferCount)
#else
GraphicsMemory::GraphicsMemory(_In_ ID3D11Device* device, UINT backBufferCount)
#endif
: pImpl(new Impl(this))
: pImpl(std::make_unique<Impl>(this))
{
pImpl->Initialize(device, backBufferCount);
}
// Move constructor.
GraphicsMemory::GraphicsMemory(GraphicsMemory&& moveFrom)
GraphicsMemory::GraphicsMemory(GraphicsMemory&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
pImpl->mOwner = this;
@ -290,7 +286,7 @@ GraphicsMemory::GraphicsMemory(GraphicsMemory&& moveFrom)
// Move assignment.
GraphicsMemory& GraphicsMemory::operator= (GraphicsMemory&& moveFrom)
GraphicsMemory& GraphicsMemory::operator= (GraphicsMemory&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
pImpl->mOwner = this;

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: Keyboard.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "pch.h"
@ -133,43 +130,43 @@ void Keyboard::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
switch (message)
{
case WM_ACTIVATEAPP:
pImpl->Reset();
return;
case WM_ACTIVATEAPP:
pImpl->Reset();
return;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
down = true;
break;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
down = true;
break;
case WM_KEYUP:
case WM_SYSKEYUP:
break;
case WM_KEYUP:
case WM_SYSKEYUP:
break;
default:
return;
default:
return;
}
int vk = static_cast<int>(wParam);
switch (vk)
{
case VK_SHIFT:
vk = MapVirtualKey((lParam & 0x00ff0000) >> 16, MAPVK_VSC_TO_VK_EX);
if (!down)
{
// Workaround to ensure left vs. right shift get cleared when both were pressed at same time
KeyUp(VK_LSHIFT, pImpl->mState);
KeyUp(VK_RSHIFT, pImpl->mState);
}
break;
case VK_SHIFT:
vk = MapVirtualKey((lParam & 0x00ff0000) >> 16, MAPVK_VSC_TO_VK_EX);
if (!down)
{
// Workaround to ensure left vs. right shift get cleared when both were pressed at same time
KeyUp(VK_LSHIFT, pImpl->mState);
KeyUp(VK_RSHIFT, pImpl->mState);
}
break;
case VK_CONTROL:
vk = (lParam & 0x01000000) ? VK_RCONTROL : VK_LCONTROL;
break;
case VK_CONTROL:
vk = (lParam & 0x01000000) ? VK_RCONTROL : VK_LCONTROL;
break;
case VK_MENU:
vk = (lParam & 0x01000000) ? VK_RMENU : VK_LMENU;
break;
case VK_MENU:
vk = (lParam & 0x01000000) ? VK_RMENU : VK_LMENU;
break;
}
if (down)
@ -399,17 +396,17 @@ private:
switch (evtType)
{
case CoreAcceleratorKeyEventType_KeyDown:
case CoreAcceleratorKeyEventType_SystemKeyDown:
down = true;
break;
case CoreAcceleratorKeyEventType_KeyDown:
case CoreAcceleratorKeyEventType_SystemKeyDown:
down = true;
break;
case CoreAcceleratorKeyEventType_KeyUp:
case CoreAcceleratorKeyEventType_SystemKeyUp:
break;
case CoreAcceleratorKeyEventType_KeyUp:
case CoreAcceleratorKeyEventType_SystemKeyUp:
break;
default:
return S_OK;
default:
return S_OK;
}
CorePhysicalKeyStatus status;
@ -424,23 +421,23 @@ private:
switch (vk)
{
case VK_SHIFT:
vk = (status.ScanCode == 0x36) ? VK_RSHIFT : VK_LSHIFT;
if (!down)
{
// Workaround to ensure left vs. right shift get cleared when both were pressed at same time
KeyUp(VK_LSHIFT, pImpl->mState);
KeyUp(VK_RSHIFT, pImpl->mState);
}
break;
case VK_SHIFT:
vk = (status.ScanCode == 0x36) ? VK_RSHIFT : VK_LSHIFT;
if (!down)
{
// Workaround to ensure left vs. right shift get cleared when both were pressed at same time
KeyUp(VK_LSHIFT, pImpl->mState);
KeyUp(VK_RSHIFT, pImpl->mState);
}
break;
case VK_CONTROL:
vk = (status.IsExtendedKey) ? VK_RCONTROL : VK_LCONTROL;
break;
case VK_CONTROL:
vk = (status.IsExtendedKey) ? VK_RCONTROL : VK_LCONTROL;
break;
case VK_MENU:
vk = (status.IsExtendedKey) ? VK_RMENU : VK_LMENU;
break;
case VK_MENU:
vk = (status.IsExtendedKey) ? VK_RMENU : VK_LMENU;
break;
}
if (down)
@ -471,13 +468,13 @@ void Keyboard::SetWindow(ABI::Windows::UI::Core::ICoreWindow* window)
// Public constructor.
Keyboard::Keyboard()
: pImpl(new Impl(this))
: pImpl(std::make_unique<Impl>(this))
{
}
// Move constructor.
Keyboard::Keyboard(Keyboard&& moveFrom)
Keyboard::Keyboard(Keyboard&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
pImpl->mOwner = this;
@ -485,7 +482,7 @@ Keyboard::Keyboard(Keyboard&& moveFrom)
// Move assignment.
Keyboard& Keyboard::operator= (Keyboard&& moveFrom)
Keyboard& Keyboard::operator= (Keyboard&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
pImpl->mOwner = this;

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

@ -3,14 +3,11 @@
//
// Helper functions for texture loaders and screen grabber
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
@ -31,162 +28,162 @@ namespace DirectX
{
switch (fmt)
{
case DXGI_FORMAT_R32G32B32A32_TYPELESS:
case DXGI_FORMAT_R32G32B32A32_FLOAT:
case DXGI_FORMAT_R32G32B32A32_UINT:
case DXGI_FORMAT_R32G32B32A32_SINT:
return 128;
case DXGI_FORMAT_R32G32B32A32_TYPELESS:
case DXGI_FORMAT_R32G32B32A32_FLOAT:
case DXGI_FORMAT_R32G32B32A32_UINT:
case DXGI_FORMAT_R32G32B32A32_SINT:
return 128;
case DXGI_FORMAT_R32G32B32_TYPELESS:
case DXGI_FORMAT_R32G32B32_FLOAT:
case DXGI_FORMAT_R32G32B32_UINT:
case DXGI_FORMAT_R32G32B32_SINT:
return 96;
case DXGI_FORMAT_R32G32B32_TYPELESS:
case DXGI_FORMAT_R32G32B32_FLOAT:
case DXGI_FORMAT_R32G32B32_UINT:
case DXGI_FORMAT_R32G32B32_SINT:
return 96;
case DXGI_FORMAT_R16G16B16A16_TYPELESS:
case DXGI_FORMAT_R16G16B16A16_FLOAT:
case DXGI_FORMAT_R16G16B16A16_UNORM:
case DXGI_FORMAT_R16G16B16A16_UINT:
case DXGI_FORMAT_R16G16B16A16_SNORM:
case DXGI_FORMAT_R16G16B16A16_SINT:
case DXGI_FORMAT_R32G32_TYPELESS:
case DXGI_FORMAT_R32G32_FLOAT:
case DXGI_FORMAT_R32G32_UINT:
case DXGI_FORMAT_R32G32_SINT:
case DXGI_FORMAT_R32G8X24_TYPELESS:
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
case DXGI_FORMAT_Y416:
case DXGI_FORMAT_Y210:
case DXGI_FORMAT_Y216:
return 64;
case DXGI_FORMAT_R16G16B16A16_TYPELESS:
case DXGI_FORMAT_R16G16B16A16_FLOAT:
case DXGI_FORMAT_R16G16B16A16_UNORM:
case DXGI_FORMAT_R16G16B16A16_UINT:
case DXGI_FORMAT_R16G16B16A16_SNORM:
case DXGI_FORMAT_R16G16B16A16_SINT:
case DXGI_FORMAT_R32G32_TYPELESS:
case DXGI_FORMAT_R32G32_FLOAT:
case DXGI_FORMAT_R32G32_UINT:
case DXGI_FORMAT_R32G32_SINT:
case DXGI_FORMAT_R32G8X24_TYPELESS:
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
case DXGI_FORMAT_Y416:
case DXGI_FORMAT_Y210:
case DXGI_FORMAT_Y216:
return 64;
case DXGI_FORMAT_R10G10B10A2_TYPELESS:
case DXGI_FORMAT_R10G10B10A2_UNORM:
case DXGI_FORMAT_R10G10B10A2_UINT:
case DXGI_FORMAT_R11G11B10_FLOAT:
case DXGI_FORMAT_R8G8B8A8_TYPELESS:
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
case DXGI_FORMAT_R8G8B8A8_UINT:
case DXGI_FORMAT_R8G8B8A8_SNORM:
case DXGI_FORMAT_R8G8B8A8_SINT:
case DXGI_FORMAT_R16G16_TYPELESS:
case DXGI_FORMAT_R16G16_FLOAT:
case DXGI_FORMAT_R16G16_UNORM:
case DXGI_FORMAT_R16G16_UINT:
case DXGI_FORMAT_R16G16_SNORM:
case DXGI_FORMAT_R16G16_SINT:
case DXGI_FORMAT_R32_TYPELESS:
case DXGI_FORMAT_D32_FLOAT:
case DXGI_FORMAT_R32_FLOAT:
case DXGI_FORMAT_R32_UINT:
case DXGI_FORMAT_R32_SINT:
case DXGI_FORMAT_R24G8_TYPELESS:
case DXGI_FORMAT_D24_UNORM_S8_UINT:
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
case DXGI_FORMAT_R8G8_B8G8_UNORM:
case DXGI_FORMAT_G8R8_G8B8_UNORM:
case DXGI_FORMAT_B8G8R8A8_UNORM:
case DXGI_FORMAT_B8G8R8X8_UNORM:
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
case DXGI_FORMAT_B8G8R8X8_TYPELESS:
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
case DXGI_FORMAT_AYUV:
case DXGI_FORMAT_Y410:
case DXGI_FORMAT_YUY2:
return 32;
case DXGI_FORMAT_R10G10B10A2_TYPELESS:
case DXGI_FORMAT_R10G10B10A2_UNORM:
case DXGI_FORMAT_R10G10B10A2_UINT:
case DXGI_FORMAT_R11G11B10_FLOAT:
case DXGI_FORMAT_R8G8B8A8_TYPELESS:
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
case DXGI_FORMAT_R8G8B8A8_UINT:
case DXGI_FORMAT_R8G8B8A8_SNORM:
case DXGI_FORMAT_R8G8B8A8_SINT:
case DXGI_FORMAT_R16G16_TYPELESS:
case DXGI_FORMAT_R16G16_FLOAT:
case DXGI_FORMAT_R16G16_UNORM:
case DXGI_FORMAT_R16G16_UINT:
case DXGI_FORMAT_R16G16_SNORM:
case DXGI_FORMAT_R16G16_SINT:
case DXGI_FORMAT_R32_TYPELESS:
case DXGI_FORMAT_D32_FLOAT:
case DXGI_FORMAT_R32_FLOAT:
case DXGI_FORMAT_R32_UINT:
case DXGI_FORMAT_R32_SINT:
case DXGI_FORMAT_R24G8_TYPELESS:
case DXGI_FORMAT_D24_UNORM_S8_UINT:
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
case DXGI_FORMAT_R8G8_B8G8_UNORM:
case DXGI_FORMAT_G8R8_G8B8_UNORM:
case DXGI_FORMAT_B8G8R8A8_UNORM:
case DXGI_FORMAT_B8G8R8X8_UNORM:
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
case DXGI_FORMAT_B8G8R8X8_TYPELESS:
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
case DXGI_FORMAT_AYUV:
case DXGI_FORMAT_Y410:
case DXGI_FORMAT_YUY2:
return 32;
case DXGI_FORMAT_P010:
case DXGI_FORMAT_P016:
return 24;
case DXGI_FORMAT_P010:
case DXGI_FORMAT_P016:
return 24;
case DXGI_FORMAT_R8G8_TYPELESS:
case DXGI_FORMAT_R8G8_UNORM:
case DXGI_FORMAT_R8G8_UINT:
case DXGI_FORMAT_R8G8_SNORM:
case DXGI_FORMAT_R8G8_SINT:
case DXGI_FORMAT_R16_TYPELESS:
case DXGI_FORMAT_R16_FLOAT:
case DXGI_FORMAT_D16_UNORM:
case DXGI_FORMAT_R16_UNORM:
case DXGI_FORMAT_R16_UINT:
case DXGI_FORMAT_R16_SNORM:
case DXGI_FORMAT_R16_SINT:
case DXGI_FORMAT_B5G6R5_UNORM:
case DXGI_FORMAT_B5G5R5A1_UNORM:
case DXGI_FORMAT_A8P8:
case DXGI_FORMAT_B4G4R4A4_UNORM:
return 16;
case DXGI_FORMAT_R8G8_TYPELESS:
case DXGI_FORMAT_R8G8_UNORM:
case DXGI_FORMAT_R8G8_UINT:
case DXGI_FORMAT_R8G8_SNORM:
case DXGI_FORMAT_R8G8_SINT:
case DXGI_FORMAT_R16_TYPELESS:
case DXGI_FORMAT_R16_FLOAT:
case DXGI_FORMAT_D16_UNORM:
case DXGI_FORMAT_R16_UNORM:
case DXGI_FORMAT_R16_UINT:
case DXGI_FORMAT_R16_SNORM:
case DXGI_FORMAT_R16_SINT:
case DXGI_FORMAT_B5G6R5_UNORM:
case DXGI_FORMAT_B5G5R5A1_UNORM:
case DXGI_FORMAT_A8P8:
case DXGI_FORMAT_B4G4R4A4_UNORM:
return 16;
case DXGI_FORMAT_NV12:
case DXGI_FORMAT_420_OPAQUE:
case DXGI_FORMAT_NV11:
return 12;
case DXGI_FORMAT_NV12:
case DXGI_FORMAT_420_OPAQUE:
case DXGI_FORMAT_NV11:
return 12;
case DXGI_FORMAT_R8_TYPELESS:
case DXGI_FORMAT_R8_UNORM:
case DXGI_FORMAT_R8_UINT:
case DXGI_FORMAT_R8_SNORM:
case DXGI_FORMAT_R8_SINT:
case DXGI_FORMAT_A8_UNORM:
case DXGI_FORMAT_AI44:
case DXGI_FORMAT_IA44:
case DXGI_FORMAT_P8:
return 8;
case DXGI_FORMAT_R8_TYPELESS:
case DXGI_FORMAT_R8_UNORM:
case DXGI_FORMAT_R8_UINT:
case DXGI_FORMAT_R8_SNORM:
case DXGI_FORMAT_R8_SINT:
case DXGI_FORMAT_A8_UNORM:
case DXGI_FORMAT_AI44:
case DXGI_FORMAT_IA44:
case DXGI_FORMAT_P8:
return 8;
case DXGI_FORMAT_R1_UNORM:
return 1;
case DXGI_FORMAT_R1_UNORM:
return 1;
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT_BC4_SNORM:
return 4;
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT_BC4_SNORM:
return 4;
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT_BC7_TYPELESS:
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
return 8;
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT_BC7_TYPELESS:
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
return 8;
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
case DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT:
case DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT:
case DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM:
return 32;
case DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT:
case DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT:
case DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM:
return 32;
case DXGI_FORMAT_D16_UNORM_S8_UINT:
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
return 24;
case DXGI_FORMAT_D16_UNORM_S8_UINT:
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
return 24;
case DXGI_FORMAT_R4G4_UNORM:
return 8;
case DXGI_FORMAT_R4G4_UNORM:
return 8;
#endif // _XBOX_ONE && _TITLE
#endif // _XBOX_ONE && _TITLE
default:
return 0;
default:
return 0;
}
}
@ -195,29 +192,29 @@ namespace DirectX
{
switch (format)
{
case DXGI_FORMAT_R8G8B8A8_UNORM:
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
case DXGI_FORMAT_R8G8B8A8_UNORM:
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
case DXGI_FORMAT_BC1_UNORM:
return DXGI_FORMAT_BC1_UNORM_SRGB;
case DXGI_FORMAT_BC1_UNORM:
return DXGI_FORMAT_BC1_UNORM_SRGB;
case DXGI_FORMAT_BC2_UNORM:
return DXGI_FORMAT_BC2_UNORM_SRGB;
case DXGI_FORMAT_BC2_UNORM:
return DXGI_FORMAT_BC2_UNORM_SRGB;
case DXGI_FORMAT_BC3_UNORM:
return DXGI_FORMAT_BC3_UNORM_SRGB;
case DXGI_FORMAT_BC3_UNORM:
return DXGI_FORMAT_BC3_UNORM_SRGB;
case DXGI_FORMAT_B8G8R8A8_UNORM:
return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
case DXGI_FORMAT_B8G8R8A8_UNORM:
return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
case DXGI_FORMAT_B8G8R8X8_UNORM:
return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB;
case DXGI_FORMAT_B8G8R8X8_UNORM:
return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB;
case DXGI_FORMAT_BC7_UNORM:
return DXGI_FORMAT_BC7_UNORM_SRGB;
case DXGI_FORMAT_BC7_UNORM:
return DXGI_FORMAT_BC7_UNORM_SRGB;
default:
return format;
default:
return format;
}
}
@ -226,31 +223,31 @@ namespace DirectX
{
switch (fmt)
{
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT_BC4_SNORM:
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT_BC7_TYPELESS:
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
return true;
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT_BC4_SNORM:
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT_BC7_TYPELESS:
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
return true;
default:
return false;
default:
return false;
}
}
@ -260,35 +257,35 @@ namespace DirectX
// Assumes UNORM or FLOAT; doesn't use UINT or SINT
switch (fmt)
{
case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT;
case DXGI_FORMAT_R32G32B32_TYPELESS: return DXGI_FORMAT_R32G32B32_FLOAT;
case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_UNORM;
case DXGI_FORMAT_R32G32_TYPELESS: return DXGI_FORMAT_R32G32_FLOAT;
case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM;
case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM;
case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_UNORM;
case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT;
case DXGI_FORMAT_R8G8_TYPELESS: return DXGI_FORMAT_R8G8_UNORM;
case DXGI_FORMAT_R16_TYPELESS: return DXGI_FORMAT_R16_UNORM;
case DXGI_FORMAT_R8_TYPELESS: return DXGI_FORMAT_R8_UNORM;
case DXGI_FORMAT_BC1_TYPELESS: return DXGI_FORMAT_BC1_UNORM;
case DXGI_FORMAT_BC2_TYPELESS: return DXGI_FORMAT_BC2_UNORM;
case DXGI_FORMAT_BC3_TYPELESS: return DXGI_FORMAT_BC3_UNORM;
case DXGI_FORMAT_BC4_TYPELESS: return DXGI_FORMAT_BC4_UNORM;
case DXGI_FORMAT_BC5_TYPELESS: return DXGI_FORMAT_BC5_UNORM;
case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM;
case DXGI_FORMAT_B8G8R8X8_TYPELESS: return DXGI_FORMAT_B8G8R8X8_UNORM;
case DXGI_FORMAT_BC7_TYPELESS: return DXGI_FORMAT_BC7_UNORM;
default: return fmt;
case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT;
case DXGI_FORMAT_R32G32B32_TYPELESS: return DXGI_FORMAT_R32G32B32_FLOAT;
case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_UNORM;
case DXGI_FORMAT_R32G32_TYPELESS: return DXGI_FORMAT_R32G32_FLOAT;
case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM;
case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM;
case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_UNORM;
case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT;
case DXGI_FORMAT_R8G8_TYPELESS: return DXGI_FORMAT_R8G8_UNORM;
case DXGI_FORMAT_R16_TYPELESS: return DXGI_FORMAT_R16_UNORM;
case DXGI_FORMAT_R8_TYPELESS: return DXGI_FORMAT_R8_UNORM;
case DXGI_FORMAT_BC1_TYPELESS: return DXGI_FORMAT_BC1_UNORM;
case DXGI_FORMAT_BC2_TYPELESS: return DXGI_FORMAT_BC2_UNORM;
case DXGI_FORMAT_BC3_TYPELESS: return DXGI_FORMAT_BC3_UNORM;
case DXGI_FORMAT_BC4_TYPELESS: return DXGI_FORMAT_BC4_UNORM;
case DXGI_FORMAT_BC5_TYPELESS: return DXGI_FORMAT_BC5_UNORM;
case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM;
case DXGI_FORMAT_B8G8R8X8_TYPELESS: return DXGI_FORMAT_B8G8R8X8_UNORM;
case DXGI_FORMAT_BC7_TYPELESS: return DXGI_FORMAT_BC7_UNORM;
default: return fmt;
}
}
//--------------------------------------------------------------------------------------
inline HRESULT LoadTextureDataFromFile(_In_z_ const wchar_t* fileName,
std::unique_ptr<uint8_t[]>& ddsData,
const DDS_HEADER** header,
const uint8_t** bitData,
size_t* bitSize
std::unique_ptr<uint8_t[]>& ddsData,
const DDS_HEADER** header,
const uint8_t** bitData,
size_t* bitSize
)
{
if (!header || !bitData || !bitSize)
@ -297,21 +294,21 @@ namespace DirectX
}
// open the file
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
ScopedHandle hFile(safe_handle(CreateFile2(fileName,
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
nullptr)));
#else
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
nullptr)));
#else
ScopedHandle hFile(safe_handle(CreateFileW(fileName,
GENERIC_READ,
FILE_SHARE_READ,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr)));
#endif
GENERIC_READ,
FILE_SHARE_READ,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr)));
#endif
if (!hFile)
{
@ -351,7 +348,7 @@ namespace DirectX
fileInfo.EndOfFile.LowPart,
&BytesRead,
nullptr
))
))
{
return HRESULT_FROM_WIN32(GetLastError());
}
@ -405,11 +402,11 @@ namespace DirectX
// Get surface information for a particular format
//--------------------------------------------------------------------------------------
inline void GetSurfaceInfo(_In_ size_t width,
_In_ size_t height,
_In_ DXGI_FORMAT fmt,
_Out_opt_ size_t* outNumBytes,
_Out_opt_ size_t* outRowBytes,
_Out_opt_ size_t* outNumRows)
_In_ size_t height,
_In_ DXGI_FORMAT fmt,
_Out_opt_ size_t* outNumBytes,
_Out_opt_ size_t* outRowBytes,
_Out_opt_ size_t* outNumRows)
{
size_t numBytes = 0;
size_t rowBytes = 0;
@ -421,73 +418,73 @@ namespace DirectX
size_t bpe = 0;
switch (fmt)
{
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT_BC4_SNORM:
bc = true;
bpe = 8;
break;
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT_BC4_SNORM:
bc = true;
bpe = 8;
break;
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT_BC7_TYPELESS:
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
bc = true;
bpe = 16;
break;
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT_BC7_TYPELESS:
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
bc = true;
bpe = 16;
break;
case DXGI_FORMAT_R8G8_B8G8_UNORM:
case DXGI_FORMAT_G8R8_G8B8_UNORM:
case DXGI_FORMAT_YUY2:
packed = true;
bpe = 4;
break;
case DXGI_FORMAT_R8G8_B8G8_UNORM:
case DXGI_FORMAT_G8R8_G8B8_UNORM:
case DXGI_FORMAT_YUY2:
packed = true;
bpe = 4;
break;
case DXGI_FORMAT_Y210:
case DXGI_FORMAT_Y216:
packed = true;
bpe = 8;
break;
case DXGI_FORMAT_Y210:
case DXGI_FORMAT_Y216:
packed = true;
bpe = 8;
break;
case DXGI_FORMAT_NV12:
case DXGI_FORMAT_420_OPAQUE:
planar = true;
bpe = 2;
break;
case DXGI_FORMAT_NV12:
case DXGI_FORMAT_420_OPAQUE:
planar = true;
bpe = 2;
break;
case DXGI_FORMAT_P010:
case DXGI_FORMAT_P016:
planar = true;
bpe = 4;
break;
case DXGI_FORMAT_P010:
case DXGI_FORMAT_P016:
planar = true;
bpe = 4;
break;
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
case DXGI_FORMAT_D16_UNORM_S8_UINT:
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
planar = true;
bpe = 4;
break;
case DXGI_FORMAT_D16_UNORM_S8_UINT:
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
planar = true;
bpe = 4;
break;
#endif
#endif
default:
break;
default:
break;
}
if (bc)
@ -547,7 +544,7 @@ namespace DirectX
}
//--------------------------------------------------------------------------------------
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
inline DXGI_FORMAT GetDXGIFormat(const DDS_PIXELFORMAT& ddpf)
{
@ -557,75 +554,75 @@ namespace DirectX
switch (ddpf.RGBBitCount)
{
case 32:
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))
{
return DXGI_FORMAT_R8G8B8A8_UNORM;
}
case 32:
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))
{
return DXGI_FORMAT_R8G8B8A8_UNORM;
}
if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000))
{
return DXGI_FORMAT_B8G8R8A8_UNORM;
}
if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000))
{
return DXGI_FORMAT_B8G8R8A8_UNORM;
}
if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000))
{
return DXGI_FORMAT_B8G8R8X8_UNORM;
}
if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000))
{
return DXGI_FORMAT_B8G8R8X8_UNORM;
}
// No DXGI format maps to ISBITMASK(0x000000ff,0x0000ff00,0x00ff0000,0x00000000) aka D3DFMT_X8B8G8R8
// No DXGI format maps to ISBITMASK(0x000000ff,0x0000ff00,0x00ff0000,0x00000000) aka D3DFMT_X8B8G8R8
// Note that many common DDS reader/writers (including D3DX) swap the
// the RED/BLUE masks for 10:10:10:2 formats. We assume
// below that the 'backwards' header mask is being used since it is most
// likely written by D3DX. The more robust solution is to use the 'DX10'
// header extension and specify the DXGI_FORMAT_R10G10B10A2_UNORM format directly
// Note that many common DDS reader/writers (including D3DX) swap the
// the RED/BLUE masks for 10:10:10:2 formats. We assume
// below that the 'backwards' header mask is being used since it is most
// likely written by D3DX. The more robust solution is to use the 'DX10'
// header extension and specify the DXGI_FORMAT_R10G10B10A2_UNORM format directly
// For 'correct' writers, this should be 0x000003ff,0x000ffc00,0x3ff00000 for RGB data
if (ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000))
{
return DXGI_FORMAT_R10G10B10A2_UNORM;
}
// For 'correct' writers, this should be 0x000003ff,0x000ffc00,0x3ff00000 for RGB data
if (ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000))
{
return DXGI_FORMAT_R10G10B10A2_UNORM;
}
// No DXGI format maps to ISBITMASK(0x000003ff,0x000ffc00,0x3ff00000,0xc0000000) aka D3DFMT_A2R10G10B10
// No DXGI format maps to ISBITMASK(0x000003ff,0x000ffc00,0x3ff00000,0xc0000000) aka D3DFMT_A2R10G10B10
if (ISBITMASK(0x0000ffff, 0xffff0000, 0x00000000, 0x00000000))
{
return DXGI_FORMAT_R16G16_UNORM;
}
if (ISBITMASK(0x0000ffff, 0xffff0000, 0x00000000, 0x00000000))
{
return DXGI_FORMAT_R16G16_UNORM;
}
if (ISBITMASK(0xffffffff, 0x00000000, 0x00000000, 0x00000000))
{
// Only 32-bit color channel format in D3D9 was R32F
return DXGI_FORMAT_R32_FLOAT; // D3DX writes this out as a FourCC of 114
}
break;
if (ISBITMASK(0xffffffff, 0x00000000, 0x00000000, 0x00000000))
{
// Only 32-bit color channel format in D3D9 was R32F
return DXGI_FORMAT_R32_FLOAT; // D3DX writes this out as a FourCC of 114
}
break;
case 24:
// No 24bpp DXGI formats aka D3DFMT_R8G8B8
break;
case 24:
// No 24bpp DXGI formats aka D3DFMT_R8G8B8
break;
case 16:
if (ISBITMASK(0x7c00, 0x03e0, 0x001f, 0x8000))
{
return DXGI_FORMAT_B5G5R5A1_UNORM;
}
if (ISBITMASK(0xf800, 0x07e0, 0x001f, 0x0000))
{
return DXGI_FORMAT_B5G6R5_UNORM;
}
case 16:
if (ISBITMASK(0x7c00, 0x03e0, 0x001f, 0x8000))
{
return DXGI_FORMAT_B5G5R5A1_UNORM;
}
if (ISBITMASK(0xf800, 0x07e0, 0x001f, 0x0000))
{
return DXGI_FORMAT_B5G6R5_UNORM;
}
// No DXGI format maps to ISBITMASK(0x7c00,0x03e0,0x001f,0x0000) aka D3DFMT_X1R5G5B5
// No DXGI format maps to ISBITMASK(0x7c00,0x03e0,0x001f,0x0000) aka D3DFMT_X1R5G5B5
if (ISBITMASK(0x0f00, 0x00f0, 0x000f, 0xf000))
{
return DXGI_FORMAT_B4G4R4A4_UNORM;
}
if (ISBITMASK(0x0f00, 0x00f0, 0x000f, 0xf000))
{
return DXGI_FORMAT_B4G4R4A4_UNORM;
}
// No DXGI format maps to ISBITMASK(0x0f00,0x00f0,0x000f,0x0000) aka D3DFMT_X4R4G4B4
// No DXGI format maps to ISBITMASK(0x0f00,0x00f0,0x000f,0x0000) aka D3DFMT_X4R4G4B4
// No 3:3:2, 3:3:2:8, or paletted DXGI formats aka D3DFMT_A8R3G3B2, D3DFMT_R3G3B2, D3DFMT_P8, D3DFMT_A8P8, etc.
break;
// No 3:3:2, 3:3:2:8, or paletted DXGI formats aka D3DFMT_A8R3G3B2, D3DFMT_R3G3B2, D3DFMT_P8, D3DFMT_A8P8, etc.
break;
}
}
else if (ddpf.flags & DDS_LUMINANCE)
@ -759,38 +756,38 @@ namespace DirectX
// Check for D3DFORMAT enums being set here
switch (ddpf.fourCC)
{
case 36: // D3DFMT_A16B16G16R16
return DXGI_FORMAT_R16G16B16A16_UNORM;
case 36: // D3DFMT_A16B16G16R16
return DXGI_FORMAT_R16G16B16A16_UNORM;
case 110: // D3DFMT_Q16W16V16U16
return DXGI_FORMAT_R16G16B16A16_SNORM;
case 110: // D3DFMT_Q16W16V16U16
return DXGI_FORMAT_R16G16B16A16_SNORM;
case 111: // D3DFMT_R16F
return DXGI_FORMAT_R16_FLOAT;
case 111: // D3DFMT_R16F
return DXGI_FORMAT_R16_FLOAT;
case 112: // D3DFMT_G16R16F
return DXGI_FORMAT_R16G16_FLOAT;
case 112: // D3DFMT_G16R16F
return DXGI_FORMAT_R16G16_FLOAT;
case 113: // D3DFMT_A16B16G16R16F
return DXGI_FORMAT_R16G16B16A16_FLOAT;
case 113: // D3DFMT_A16B16G16R16F
return DXGI_FORMAT_R16G16B16A16_FLOAT;
case 114: // D3DFMT_R32F
return DXGI_FORMAT_R32_FLOAT;
case 114: // D3DFMT_R32F
return DXGI_FORMAT_R32_FLOAT;
case 115: // D3DFMT_G32R32F
return DXGI_FORMAT_R32G32_FLOAT;
case 115: // D3DFMT_G32R32F
return DXGI_FORMAT_R32G32_FLOAT;
case 116: // D3DFMT_A32B32G32R32F
return DXGI_FORMAT_R32G32B32A32_FLOAT;
case 116: // D3DFMT_A32B32G32R32F
return DXGI_FORMAT_R32G32B32A32_FLOAT;
}
}
return DXGI_FORMAT_UNKNOWN;
}
#undef ISBITMASK
#undef ISBITMASK
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
inline DirectX::DDS_ALPHA_MODE GetAlphaMode(_In_ const DDS_HEADER* header)
{
if (header->ddspf.flags & DDS_FOURCC)
@ -801,18 +798,18 @@ namespace DirectX
auto mode = static_cast<DDS_ALPHA_MODE>(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
switch (mode)
{
case DDS_ALPHA_MODE_STRAIGHT:
case DDS_ALPHA_MODE_PREMULTIPLIED:
case DDS_ALPHA_MODE_OPAQUE:
case DDS_ALPHA_MODE_CUSTOM:
return mode;
case DDS_ALPHA_MODE_STRAIGHT:
case DDS_ALPHA_MODE_PREMULTIPLIED:
case DDS_ALPHA_MODE_OPAQUE:
case DDS_ALPHA_MODE_CUSTOM:
return mode;
default:
break;
default:
break;
}
}
else if ((MAKEFOURCC('D', 'X', 'T', '2') == header->ddspf.fourCC)
|| (MAKEFOURCC('D', 'X', 'T', '4') == header->ddspf.fourCC))
|| (MAKEFOURCC('D', 'X', 'T', '4') == header->ddspf.fourCC))
{
return DDS_ALPHA_MODE_PREMULTIPLIED;
}

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: Model.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -29,7 +25,7 @@ using namespace DirectX;
// ModelMeshPart
//--------------------------------------------------------------------------------------
ModelMeshPart::ModelMeshPart() :
ModelMeshPart::ModelMeshPart() throw() :
indexCount(0),
startIndex(0),
vertexOffset(0),
@ -95,9 +91,9 @@ void ModelMeshPart::CreateInputLayout(ID3D11Device* d3dDevice, IEffect* ieffect,
ThrowIfFailed(
d3dDevice->CreateInputLayout(vbDecl->data(),
static_cast<UINT>(vbDecl->size()),
shaderByteCode, byteCodeLength,
iinputLayout)
static_cast<UINT>(vbDecl->size()),
shaderByteCode, byteCodeLength,
iinputLayout)
);
_Analysis_assume_(*iinputLayout != 0);
@ -123,9 +119,9 @@ void ModelMeshPart::ModifyEffect(ID3D11Device* d3dDevice, std::shared_ptr<IEffec
ThrowIfFailed(
d3dDevice->CreateInputLayout(vbDecl->data(),
static_cast<UINT>(vbDecl->size()),
shaderByteCode, byteCodeLength,
&inputLayout)
static_cast<UINT>(vbDecl->size()),
shaderByteCode, byteCodeLength,
&inputLayout)
);
}
@ -134,7 +130,7 @@ void ModelMeshPart::ModifyEffect(ID3D11Device* d3dDevice, std::shared_ptr<IEffec
// ModelMesh
//--------------------------------------------------------------------------------------
ModelMesh::ModelMesh() :
ModelMesh::ModelMesh() throw() :
ccw(true),
pmalpha(true)
{

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: ModelLoadCMO.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -93,7 +89,7 @@ namespace VSD3DStarter
// }
// }
#pragma pack(push,1)
#pragma pack(push,1)
struct Material
{
@ -118,7 +114,7 @@ namespace VSD3DStarter
const uint32_t NUM_BONE_INFLUENCES = 4;
static_assert( sizeof(VertexPositionNormalTangentColorTexture) == 52, "mismatch with CMO vertex type" );
static_assert(sizeof(VertexPositionNormalTangentColorTexture) == 52, "mismatch with CMO vertex type");
struct SkinningVertex
{
@ -142,7 +138,7 @@ namespace VSD3DStarter
DirectX::XMFLOAT4X4 BindPos;
DirectX::XMFLOAT4X4 LocalTransform;
};
struct Clip
{
float StartTime;
@ -157,7 +153,7 @@ namespace VSD3DStarter
DirectX::XMFLOAT4X4 Transform;
};
#pragma pack(pop)
#pragma pack(pop)
const Material s_defMaterial =
{
@ -171,15 +167,15 @@ namespace VSD3DStarter
0.f, 0.f, 1.f, 0.f,
0.f, 0.f, 0.f, 1.f },
};
}; // namespace
} // namespace
static_assert( sizeof(VSD3DStarter::Material) == 132, "CMO Mesh structure size incorrect" );
static_assert( sizeof(VSD3DStarter::SubMesh) == 20, "CMO Mesh structure size incorrect" );
static_assert( sizeof(VSD3DStarter::SkinningVertex)== 32, "CMO Mesh structure size incorrect" );
static_assert( sizeof(VSD3DStarter::MeshExtents)== 40, "CMO Mesh structure size incorrect" );
static_assert( sizeof(VSD3DStarter::Bone) == 196, "CMO Mesh structure size incorrect" );
static_assert( sizeof(VSD3DStarter::Clip) == 12, "CMO Mesh structure size incorrect" );
static_assert( sizeof(VSD3DStarter::Keyframe)== 72, "CMO Mesh structure size incorrect" );
static_assert(sizeof(VSD3DStarter::Material) == 132, "CMO Mesh structure size incorrect");
static_assert(sizeof(VSD3DStarter::SubMesh) == 20, "CMO Mesh structure size incorrect");
static_assert(sizeof(VSD3DStarter::SkinningVertex) == 32, "CMO Mesh structure size incorrect");
static_assert(sizeof(VSD3DStarter::MeshExtents) == 40, "CMO Mesh structure size incorrect");
static_assert(sizeof(VSD3DStarter::Bone) == 196, "CMO Mesh structure size incorrect");
static_assert(sizeof(VSD3DStarter::Clip) == 12, "CMO Mesh structure size incorrect");
static_assert(sizeof(VSD3DStarter::Keyframe) == 72, "CMO Mesh structure size incorrect");
namespace
{
@ -192,6 +188,8 @@ namespace
std::wstring texture[VSD3DStarter::MAX_TEXTURE];
std::shared_ptr<IEffect> effect;
ComPtr<ID3D11InputLayout> il;
MaterialRecordCMO() throw() : pMaterial(nullptr) {}
};
// Helper for creating a D3D input layout.
@ -206,18 +204,18 @@ namespace
{
ThrowIfFailed(
device->CreateInputLayout(VertexPositionNormalTangentColorTextureSkinning::InputElements,
VertexPositionNormalTangentColorTextureSkinning::InputElementCount,
shaderByteCode, byteCodeLength,
pInputLayout)
VertexPositionNormalTangentColorTextureSkinning::InputElementCount,
shaderByteCode, byteCodeLength,
pInputLayout)
);
}
else
{
ThrowIfFailed(
device->CreateInputLayout(VertexPositionNormalTangentColorTexture::InputElements,
VertexPositionNormalTangentColorTexture::InputElementCount,
shaderByteCode, byteCodeLength,
pInputLayout)
VertexPositionNormalTangentColorTexture::InputElementCount,
shaderByteCode, byteCodeLength,
pInputLayout)
);
}
@ -237,10 +235,12 @@ namespace
UNREFERENCED_PARAMETER(Parameter);
UNREFERENCED_PARAMETER(lpContext);
g_vbdecl = std::make_shared<std::vector<D3D11_INPUT_ELEMENT_DESC>>(VertexPositionNormalTangentColorTexture::InputElements,
g_vbdecl = std::make_shared<std::vector<D3D11_INPUT_ELEMENT_DESC>>(
VertexPositionNormalTangentColorTexture::InputElements,
VertexPositionNormalTangentColorTexture::InputElements + VertexPositionNormalTangentColorTexture::InputElementCount);
g_vbdeclSkinning = std::make_shared<std::vector<D3D11_INPUT_ELEMENT_DESC>>(VertexPositionNormalTangentColorTextureSkinning::InputElements,
g_vbdeclSkinning = std::make_shared<std::vector<D3D11_INPUT_ELEMENT_DESC>>(
VertexPositionNormalTangentColorTextureSkinning::InputElements,
VertexPositionNormalTangentColorTextureSkinning::InputElements + VertexPositionNormalTangentColorTextureSkinning::InputElementCount);
return TRUE;
}
@ -252,114 +252,114 @@ namespace
//======================================================================================
_Use_decl_annotations_
std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, const uint8_t* meshData, size_t dataSize, IEffectFactory& fxFactory, bool ccw, bool pmalpha )
std::unique_ptr<Model> DirectX::Model::CreateFromCMO(ID3D11Device* d3dDevice, const uint8_t* meshData, size_t dataSize, IEffectFactory& fxFactory, bool ccw, bool pmalpha)
{
if ( !InitOnceExecuteOnce( &g_InitOnce, InitializeDecl, nullptr, nullptr ) )
if (!InitOnceExecuteOnce(&g_InitOnce, InitializeDecl, nullptr, nullptr))
throw std::exception("One-time initialization failed");
if ( !d3dDevice || !meshData )
if (!d3dDevice || !meshData)
throw std::exception("Device and meshData cannot be null");
auto fxFactoryDGSL = dynamic_cast<DGSLEffectFactory*>( &fxFactory );
auto fxFactoryDGSL = dynamic_cast<DGSLEffectFactory*>(&fxFactory);
// Meshes
auto nMesh = reinterpret_cast<const UINT*>( meshData );
auto nMesh = reinterpret_cast<const UINT*>(meshData);
size_t usedSize = sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( !*nMesh )
if (!*nMesh)
throw std::exception("No meshes found");
std::unique_ptr<Model> model(new Model());
for( UINT meshIndex = 0; meshIndex < *nMesh; ++meshIndex )
for (UINT meshIndex = 0; meshIndex < *nMesh; ++meshIndex)
{
// Mesh name
auto nName = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nName = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
auto meshName = reinterpret_cast<const wchar_t*>( meshData + usedSize );
auto meshName = reinterpret_cast<const wchar_t*>(meshData + usedSize);
usedSize += sizeof(wchar_t)*(*nName);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
auto mesh = std::make_shared<ModelMesh>();
mesh->name.assign( meshName, *nName );
mesh->name.assign(meshName, *nName);
mesh->ccw = ccw;
mesh->pmalpha = pmalpha;
// Materials
auto nMats = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nMats = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
std::vector<MaterialRecordCMO> materials;
materials.reserve( *nMats );
for( UINT j = 0; j < *nMats; ++j )
materials.reserve(*nMats);
for (UINT j = 0; j < *nMats; ++j)
{
MaterialRecordCMO m;
// Material name
nName = reinterpret_cast<const UINT*>( meshData + usedSize );
nName = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
auto matName = reinterpret_cast<const wchar_t*>( meshData + usedSize );
auto matName = reinterpret_cast<const wchar_t*>(meshData + usedSize);
usedSize += sizeof(wchar_t)*(*nName);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
m.name.assign( matName, *nName );
m.name.assign(matName, *nName);
// Material settings
auto matSetting = reinterpret_cast<const VSD3DStarter::Material*>( meshData + usedSize );
auto matSetting = reinterpret_cast<const VSD3DStarter::Material*>(meshData + usedSize);
usedSize += sizeof(VSD3DStarter::Material);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
m.pMaterial = matSetting;
// Pixel shader name
nName = reinterpret_cast<const UINT*>( meshData + usedSize );
nName = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
auto psName = reinterpret_cast<const wchar_t*>( meshData + usedSize );
auto psName = reinterpret_cast<const wchar_t*>(meshData + usedSize);
usedSize += sizeof(wchar_t)*(*nName);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
m.pixelShader.assign( psName, *nName );
m.pixelShader.assign(psName, *nName);
for( UINT t = 0; t < VSD3DStarter::MAX_TEXTURE; ++t )
for (UINT t = 0; t < VSD3DStarter::MAX_TEXTURE; ++t)
{
nName = reinterpret_cast<const UINT*>( meshData + usedSize );
nName = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
auto txtName = reinterpret_cast<const wchar_t*>( meshData + usedSize );
auto txtName = reinterpret_cast<const wchar_t*>(meshData + usedSize);
usedSize += sizeof(wchar_t)*(*nName);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
m.texture[t].assign( txtName, *nName );
m.texture[t].assign(txtName, *nName);
}
materials.emplace_back( m );
materials.emplace_back(m);
}
assert( materials.size() == *nMats );
assert(materials.size() == *nMats);
if (materials.empty())
{
@ -371,32 +371,32 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
}
// Skeletal data?
auto bSkeleton = reinterpret_cast<const BYTE*>( meshData + usedSize );
const BYTE* bSkeleton = meshData + usedSize;
usedSize += sizeof(BYTE);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
// Submeshes
auto nSubmesh = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nSubmesh = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( !*nSubmesh )
if (!*nSubmesh)
throw std::exception("No submeshes found\n");
auto subMesh = reinterpret_cast<const VSD3DStarter::SubMesh*>( meshData + usedSize );
auto subMesh = reinterpret_cast<const VSD3DStarter::SubMesh*>(meshData + usedSize);
usedSize += sizeof(VSD3DStarter::SubMesh) * (*nSubmesh);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
// Index buffers
auto nIBs = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nIBs = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( !*nIBs )
if (!*nIBs)
throw std::exception("No index buffers found\n");
struct IBData
@ -406,58 +406,58 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
};
std::vector<IBData> ibData;
ibData.reserve( *nIBs );
ibData.reserve(*nIBs);
std::vector<ComPtr<ID3D11Buffer>> ibs;
ibs.resize( *nIBs );
ibs.resize(*nIBs);
for( UINT j = 0; j < *nIBs; ++j )
for (UINT j = 0; j < *nIBs; ++j)
{
auto nIndexes = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nIndexes = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( !*nIndexes )
if (!*nIndexes)
throw std::exception("Empty index buffer found\n");
size_t ibBytes = sizeof(USHORT) * (*(nIndexes));
auto indexes = reinterpret_cast<const USHORT*>( meshData + usedSize );
auto indexes = reinterpret_cast<const USHORT*>(meshData + usedSize);
usedSize += ibBytes;
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
IBData ib;
ib.nIndices = *nIndexes;
ib.ptr = indexes;
ibData.emplace_back( ib );
ibData.emplace_back(ib);
D3D11_BUFFER_DESC desc = {};
desc.Usage = D3D11_USAGE_DEFAULT;
desc.ByteWidth = static_cast<UINT>( ibBytes );
desc.ByteWidth = static_cast<UINT>(ibBytes);
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
D3D11_SUBRESOURCE_DATA initData = {};
initData.pSysMem = indexes;
ThrowIfFailed(
d3dDevice->CreateBuffer( &desc, &initData, &ibs[j] )
);
d3dDevice->CreateBuffer(&desc, &initData, &ibs[j])
);
SetDebugObjectName( ibs[j].Get(), "ModelCMO" );
SetDebugObjectName(ibs[j].Get(), "ModelCMO");
}
assert( ibData.size() == *nIBs );
assert( ibs.size() == *nIBs );
assert(ibData.size() == *nIBs);
assert(ibs.size() == *nIBs);
// Vertex buffers
auto nVBs = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nVBs = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( !*nVBs )
if (!*nVBs)
throw std::exception("No vertex buffers found\n");
struct VBData
@ -468,62 +468,62 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
};
std::vector<VBData> vbData;
vbData.reserve( *nVBs );
for( UINT j = 0; j < *nVBs; ++j )
vbData.reserve(*nVBs);
for (UINT j = 0; j < *nVBs; ++j)
{
auto nVerts = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nVerts = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( !*nVerts )
if (!*nVerts)
throw std::exception("Empty vertex buffer found\n");
size_t vbBytes = sizeof(VertexPositionNormalTangentColorTexture) * (*(nVerts));
auto verts = reinterpret_cast<const VertexPositionNormalTangentColorTexture*>( meshData + usedSize );
auto verts = reinterpret_cast<const VertexPositionNormalTangentColorTexture*>(meshData + usedSize);
usedSize += vbBytes;
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
VBData vb;
vb.nVerts = *nVerts;
vb.ptr = verts;
vb.skinPtr = nullptr;
vbData.emplace_back( vb );
vbData.emplace_back(vb);
}
assert( vbData.size() == *nVBs );
assert(vbData.size() == *nVBs);
// Skinning vertex buffers
auto nSkinVBs = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nSkinVBs = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( *nSkinVBs )
if (*nSkinVBs)
{
if ( *nSkinVBs != *nVBs )
if (*nSkinVBs != *nVBs)
throw std::exception("Number of VBs not equal to number of skin VBs");
for( UINT j = 0; j < *nSkinVBs; ++j )
for (UINT j = 0; j < *nSkinVBs; ++j)
{
auto nVerts = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nVerts = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( !*nVerts )
if (!*nVerts)
throw std::exception("Empty skinning vertex buffer found\n");
if ( vbData[ j ].nVerts != *nVerts )
if (vbData[j].nVerts != *nVerts)
throw std::exception("Mismatched number of verts for skin VBs");
size_t vbBytes = sizeof(VSD3DStarter::SkinningVertex) * (*(nVerts));
auto verts = reinterpret_cast<const VSD3DStarter::SkinningVertex*>( meshData + usedSize );
auto verts = reinterpret_cast<const VSD3DStarter::SkinningVertex*>(meshData + usedSize);
usedSize += vbBytes;
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
vbData[j].skinPtr = verts;
@ -531,9 +531,9 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
}
// Extents
auto extents = reinterpret_cast<const VSD3DStarter::MeshExtents*>( meshData + usedSize );
auto extents = reinterpret_cast<const VSD3DStarter::MeshExtents*>(meshData + usedSize);
usedSize += sizeof(VSD3DStarter::MeshExtents);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
mesh->boundingSphere.Center.x = extents->CenterX;
@ -541,44 +541,44 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
mesh->boundingSphere.Center.z = extents->CenterZ;
mesh->boundingSphere.Radius = extents->Radius;
XMVECTOR min = XMVectorSet( extents->MinX, extents->MinY, extents->MinZ, 0.f );
XMVECTOR max = XMVectorSet( extents->MaxX, extents->MaxY, extents->MaxZ, 0.f );
BoundingBox::CreateFromPoints( mesh->boundingBox, min, max );
XMVECTOR min = XMVectorSet(extents->MinX, extents->MinY, extents->MinZ, 0.f);
XMVECTOR max = XMVectorSet(extents->MaxX, extents->MaxY, extents->MaxZ, 0.f);
BoundingBox::CreateFromPoints(mesh->boundingBox, min, max);
#if 0
// Animation data
if ( *bSkeleton )
#if 0
// Animation data
if (*bSkeleton)
{
// Bones
auto nBones = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nBones = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( !*nBones )
if (!*nBones)
throw std::exception("Animation bone data is missing\n");
for( UINT j = 0; j < *nBones; ++j )
for (UINT j = 0; j < *nBones; ++j)
{
// Bone name
nName = reinterpret_cast<const UINT*>( meshData + usedSize );
nName = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
auto boneName = reinterpret_cast<const wchar_t*>( meshData + usedSize );
auto boneName = reinterpret_cast<const wchar_t*>(meshData + usedSize);
usedSize += sizeof(wchar_t)*(*nName);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
// TODO - What to do with bone name?
boneName;
// Bone settings
auto bones = reinterpret_cast<const VSD3DStarter::Bone*>( meshData + usedSize );
auto bones = reinterpret_cast<const VSD3DStarter::Bone*>(meshData + usedSize);
usedSize += sizeof(VSD3DStarter::Bone);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
// TODO - What to do with bone data?
@ -586,167 +586,167 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
}
// Animation Clips
auto nClips = reinterpret_cast<const UINT*>( meshData + usedSize );
auto nClips = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
for( UINT j = 0; j < *nClips; ++j )
for (UINT j = 0; j < *nClips; ++j)
{
// Clip name
nName = reinterpret_cast<const UINT*>( meshData + usedSize );
nName = reinterpret_cast<const UINT*>(meshData + usedSize);
usedSize += sizeof(UINT);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
auto clipName = reinterpret_cast<const wchar_t*>( meshData + usedSize );
auto clipName = reinterpret_cast<const wchar_t*>(meshData + usedSize);
usedSize += sizeof(wchar_t)*(*nName);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
// TODO - What to do with clip name?
clipName;
auto clip = reinterpret_cast<const VSD3DStarter::Clip*>( meshData + usedSize );
auto clip = reinterpret_cast<const VSD3DStarter::Clip*>(meshData + usedSize);
usedSize += sizeof(VSD3DStarter::Clip);
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
if ( !clip->keys )
if (!clip->keys)
throw std::exception("Keyframes missing in clip");
auto keys = reinterpret_cast<const VSD3DStarter::Keyframe*>( meshData + usedSize );
auto keys = reinterpret_cast<const VSD3DStarter::Keyframe*>(meshData + usedSize);
usedSize += sizeof(VSD3DStarter::Keyframe) * clip->keys;
if ( dataSize < usedSize )
if (dataSize < usedSize)
throw std::exception("End of file");
// TODO - What to do with keys and clip->StartTime, clip->EndTime?
keys;
}
}
#else
#else
UNREFERENCED_PARAMETER(bSkeleton);
#endif
#endif
bool enableSkinning = ( *nSkinVBs ) != 0;
bool enableSkinning = (*nSkinVBs) != 0;
// Build vertex buffers
std::vector<ComPtr<ID3D11Buffer>> vbs;
vbs.resize( *nVBs );
vbs.resize(*nVBs);
const size_t stride = enableSkinning ? sizeof(VertexPositionNormalTangentColorTextureSkinning)
: sizeof(VertexPositionNormalTangentColorTexture);
: sizeof(VertexPositionNormalTangentColorTexture);
for( UINT j = 0; j < *nVBs; ++j )
for (UINT j = 0; j < *nVBs; ++j)
{
size_t nVerts = vbData[ j ].nVerts;
size_t nVerts = vbData[j].nVerts;
size_t bytes = stride * nVerts;
D3D11_BUFFER_DESC desc = {};
desc.Usage = D3D11_USAGE_DEFAULT;
desc.ByteWidth = static_cast<UINT>( bytes );
desc.ByteWidth = static_cast<UINT>(bytes);
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
if ( fxFactoryDGSL && !enableSkinning )
if (fxFactoryDGSL && !enableSkinning)
{
// Can use CMO vertex data directly
D3D11_SUBRESOURCE_DATA initData = {};
initData.pSysMem = vbData[j].ptr;
ThrowIfFailed(
d3dDevice->CreateBuffer( &desc, &initData, &vbs[j] )
);
d3dDevice->CreateBuffer(&desc, &initData, &vbs[j])
);
}
else
{
std::unique_ptr<uint8_t[]> temp( new uint8_t[ bytes + ( sizeof(UINT) * nVerts ) ] );
std::unique_ptr<uint8_t[]> temp(new uint8_t[bytes + (sizeof(UINT) * nVerts)]);
auto visited = reinterpret_cast<UINT*>( temp.get() + bytes );
memset( visited, 0xff, sizeof(UINT) * nVerts );
auto visited = reinterpret_cast<UINT*>(temp.get() + bytes);
memset(visited, 0xff, sizeof(UINT) * nVerts);
assert( vbData[j].ptr != 0 );
assert(vbData[j].ptr != 0);
if ( enableSkinning )
if (enableSkinning)
{
// Combine CMO multi-stream data into a single stream
auto skinptr = vbData[j].skinPtr;
assert( skinptr != 0 );
assert(skinptr != 0);
uint8_t* ptr = temp.get();
auto sptr = vbData[j].ptr;
for( size_t v = 0; v < nVerts; ++v )
for (size_t v = 0; v < nVerts; ++v)
{
*reinterpret_cast<VertexPositionNormalTangentColorTexture*>( ptr ) = sptr[v];
*reinterpret_cast<VertexPositionNormalTangentColorTexture*>(ptr) = sptr[v];
auto skinv = reinterpret_cast<VertexPositionNormalTangentColorTextureSkinning*>( ptr );
skinv->SetBlendIndices( *reinterpret_cast<const XMUINT4*>( skinptr[v].boneIndex ) );
skinv->SetBlendWeights( *reinterpret_cast<const XMFLOAT4*>( skinptr[v].boneWeight ) );
auto skinv = reinterpret_cast<VertexPositionNormalTangentColorTextureSkinning*>(ptr);
skinv->SetBlendIndices(*reinterpret_cast<const XMUINT4*>(skinptr[v].boneIndex));
skinv->SetBlendWeights(*reinterpret_cast<const XMFLOAT4*>(skinptr[v].boneWeight));
ptr += stride;
}
}
else
{
memcpy( temp.get(), vbData[j].ptr, bytes );
memcpy(temp.get(), vbData[j].ptr, bytes);
}
if ( !fxFactoryDGSL )
if (!fxFactoryDGSL)
{
// Need to fix up VB tex coords for UV transform which is not supported by basic effects
for( UINT k = 0; k < *nSubmesh; ++k )
for (UINT k = 0; k < *nSubmesh; ++k)
{
auto& sm = subMesh[ k ];
auto& sm = subMesh[k];
if ( sm.VertexBufferIndex != j )
if (sm.VertexBufferIndex != j)
continue;
if ( (sm.IndexBufferIndex >= *nIBs)
|| (sm.MaterialIndex >= materials.size()) )
throw std::exception("Invalid submesh found\n");
if ((sm.IndexBufferIndex >= *nIBs)
|| (sm.MaterialIndex >= materials.size()))
throw std::exception("Invalid submesh found\n");
XMMATRIX uvTransform = XMLoadFloat4x4( &materials[ sm.MaterialIndex ].pMaterial->UVTransform );
XMMATRIX uvTransform = XMLoadFloat4x4(&materials[sm.MaterialIndex].pMaterial->UVTransform);
auto ib = ibData[ sm.IndexBufferIndex ].ptr;
auto ib = ibData[sm.IndexBufferIndex].ptr;
size_t count = ibData[ sm.IndexBufferIndex ].nIndices;
size_t count = ibData[sm.IndexBufferIndex].nIndices;
for( size_t q = 0; q < count; ++q )
for (size_t q = 0; q < count; ++q)
{
size_t v = ib[ q ];
size_t v = ib[q];
if ( v >= nVerts )
if (v >= nVerts)
throw std::exception("Invalid index found\n");
auto verts = reinterpret_cast<VertexPositionNormalTangentColorTexture*>( temp.get() + ( v * stride ) );
if ( visited[v] == UINT(-1) )
auto verts = reinterpret_cast<VertexPositionNormalTangentColorTexture*>(temp.get() + (v * stride));
if (visited[v] == UINT(-1))
{
visited[v] = sm.MaterialIndex;
XMVECTOR t = XMLoadFloat2( &verts->textureCoordinate );
XMVECTOR t = XMLoadFloat2(&verts->textureCoordinate);
t = XMVectorSelect( g_XMIdentityR3, t, g_XMSelect1110 );
t = XMVectorSelect(g_XMIdentityR3, t, g_XMSelect1110);
t = XMVector4Transform( t, uvTransform );
t = XMVector4Transform(t, uvTransform);
XMStoreFloat2( &verts->textureCoordinate, t );
XMStoreFloat2(&verts->textureCoordinate, t);
}
else if ( visited[v] != sm.MaterialIndex )
else if (visited[v] != sm.MaterialIndex)
{
#ifdef _DEBUG
XMMATRIX uv2 = XMLoadFloat4x4( &materials[ visited[v] ].pMaterial->UVTransform );
#ifdef _DEBUG
XMMATRIX uv2 = XMLoadFloat4x4(&materials[visited[v]].pMaterial->UVTransform);
if ( XMVector4NotEqual( uvTransform.r[0], uv2.r[0] )
|| XMVector4NotEqual( uvTransform.r[1], uv2.r[1] )
|| XMVector4NotEqual( uvTransform.r[2], uv2.r[2] )
|| XMVector4NotEqual( uvTransform.r[3], uv2.r[3] ) )
if (XMVector4NotEqual(uvTransform.r[0], uv2.r[0])
|| XMVector4NotEqual(uvTransform.r[1], uv2.r[1])
|| XMVector4NotEqual(uvTransform.r[2], uv2.r[2])
|| XMVector4NotEqual(uvTransform.r[3], uv2.r[3]))
{
DebugTrace( "WARNING: %ls - mismatched UV transforms for the same vertex; texture coordinates may not be correct\n", mesh->name.c_str() );
DebugTrace("WARNING: %ls - mismatched UV transforms for the same vertex; texture coordinates may not be correct\n", mesh->name.c_str());
}
#endif
#endif
}
}
}
@ -757,21 +757,21 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
initData.pSysMem = temp.get();
ThrowIfFailed(
d3dDevice->CreateBuffer( &desc, &initData, &vbs[j] )
);
d3dDevice->CreateBuffer(&desc, &initData, &vbs[j])
);
}
SetDebugObjectName( vbs[j].Get(), "ModelCMO" );
SetDebugObjectName(vbs[j].Get(), "ModelCMO");
}
assert( vbs.size() == *nVBs );
// Create Effects
for( size_t j = 0; j < materials.size(); ++j )
{
auto& m = materials[ j ];
assert(vbs.size() == *nVBs);
if ( fxFactoryDGSL )
// Create Effects
for (size_t j = 0; j < materials.size(); ++j)
{
auto& m = materials[j];
if (fxFactoryDGSL)
{
DGSLEffectFactory::DGSLEffectInfo info;
info.name = m.name.c_str();
@ -779,25 +779,25 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
info.perVertexColor = true;
info.enableSkinning = enableSkinning;
info.alpha = m.pMaterial->Diffuse.w;
info.ambientColor = XMFLOAT3( m.pMaterial->Ambient.x, m.pMaterial->Ambient.y, m.pMaterial->Ambient.z );
info.diffuseColor = XMFLOAT3( m.pMaterial->Diffuse.x, m.pMaterial->Diffuse.y, m.pMaterial->Diffuse.z );
info.specularColor = XMFLOAT3( m.pMaterial->Specular.x, m.pMaterial->Specular.y, m.pMaterial->Specular.z );
info.emissiveColor = XMFLOAT3( m.pMaterial->Emissive.x, m.pMaterial->Emissive.y, m.pMaterial->Emissive.z );
info.ambientColor = XMFLOAT3(m.pMaterial->Ambient.x, m.pMaterial->Ambient.y, m.pMaterial->Ambient.z);
info.diffuseColor = XMFLOAT3(m.pMaterial->Diffuse.x, m.pMaterial->Diffuse.y, m.pMaterial->Diffuse.z);
info.specularColor = XMFLOAT3(m.pMaterial->Specular.x, m.pMaterial->Specular.y, m.pMaterial->Specular.z);
info.emissiveColor = XMFLOAT3(m.pMaterial->Emissive.x, m.pMaterial->Emissive.y, m.pMaterial->Emissive.z);
info.diffuseTexture = m.texture[0].empty() ? nullptr : m.texture[0].c_str();
info.specularTexture = m.texture[1].empty() ? nullptr : m.texture[1].c_str();
info.normalTexture = m.texture[2].empty() ? nullptr : m.texture[2].c_str();
info.pixelShader = m.pixelShader.c_str();
const int offset = DGSLEffectFactory::DGSLEffectInfo::BaseTextureOffset;
for( int i = 0; i < (DGSLEffect::MaxTextures - offset); ++i )
for (int i = 0; i < (DGSLEffect::MaxTextures - offset); ++i)
{
info.textures[i] = m.texture[ i + offset ].empty() ? nullptr : m.texture[ i + offset ].c_str();
info.textures[i] = m.texture[i + offset].empty() ? nullptr : m.texture[i + offset].c_str();
}
m.effect = fxFactoryDGSL->CreateDGSLEffect( info, nullptr );
m.effect = fxFactoryDGSL->CreateDGSLEffect(info, nullptr);
auto dgslEffect = static_cast<DGSLEffect*>( m.effect.get() );
dgslEffect->SetUVTransform( XMLoadFloat4x4( &m.pMaterial->UVTransform ) );
auto dgslEffect = static_cast<DGSLEffect*>(m.effect.get());
dgslEffect->SetUVTransform(XMLoadFloat4x4(&m.pMaterial->UVTransform));
}
else
{
@ -807,48 +807,48 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
info.perVertexColor = true;
info.enableSkinning = enableSkinning;
info.alpha = m.pMaterial->Diffuse.w;
info.ambientColor = XMFLOAT3( m.pMaterial->Ambient.x, m.pMaterial->Ambient.y, m.pMaterial->Ambient.z );
info.diffuseColor = XMFLOAT3( m.pMaterial->Diffuse.x, m.pMaterial->Diffuse.y, m.pMaterial->Diffuse.z );
info.specularColor = XMFLOAT3( m.pMaterial->Specular.x, m.pMaterial->Specular.y, m.pMaterial->Specular.z );
info.emissiveColor = XMFLOAT3( m.pMaterial->Emissive.x, m.pMaterial->Emissive.y, m.pMaterial->Emissive.z );
info.ambientColor = XMFLOAT3(m.pMaterial->Ambient.x, m.pMaterial->Ambient.y, m.pMaterial->Ambient.z);
info.diffuseColor = XMFLOAT3(m.pMaterial->Diffuse.x, m.pMaterial->Diffuse.y, m.pMaterial->Diffuse.z);
info.specularColor = XMFLOAT3(m.pMaterial->Specular.x, m.pMaterial->Specular.y, m.pMaterial->Specular.z);
info.emissiveColor = XMFLOAT3(m.pMaterial->Emissive.x, m.pMaterial->Emissive.y, m.pMaterial->Emissive.z);
info.diffuseTexture = m.texture[0].c_str();
m.effect = fxFactory.CreateEffect( info, nullptr );
m.effect = fxFactory.CreateEffect(info, nullptr);
}
CreateInputLayout( d3dDevice, m.effect.get(), &m.il, enableSkinning );
CreateInputLayout(d3dDevice, m.effect.get(), &m.il, enableSkinning);
}
// Build mesh parts
for( UINT j = 0; j < *nSubmesh; ++j )
for (UINT j = 0; j < *nSubmesh; ++j)
{
auto& sm = subMesh[j];
if ( (sm.IndexBufferIndex >= *nIBs)
|| (sm.VertexBufferIndex >= *nVBs)
|| (sm.MaterialIndex >= materials.size()) )
throw std::exception("Invalid submesh found\n");
if ((sm.IndexBufferIndex >= *nIBs)
|| (sm.VertexBufferIndex >= *nVBs)
|| (sm.MaterialIndex >= materials.size()))
throw std::exception("Invalid submesh found\n");
auto& mat = materials[ sm.MaterialIndex ];
auto& mat = materials[sm.MaterialIndex];
auto part = new ModelMeshPart();
if ( mat.pMaterial->Diffuse.w < 1 )
if (mat.pMaterial->Diffuse.w < 1)
part->isAlpha = true;
part->indexCount = sm.PrimCount * 3;
part->startIndex = sm.StartIndex;
part->vertexStride = static_cast<UINT>( stride );
part->vertexStride = static_cast<UINT>(stride);
part->inputLayout = mat.il;
part->indexBuffer = ibs[ sm.IndexBufferIndex ];
part->vertexBuffer = vbs[ sm.VertexBufferIndex ];
part->indexBuffer = ibs[sm.IndexBufferIndex];
part->vertexBuffer = vbs[sm.VertexBufferIndex];
part->effect = mat.effect;
part->vbDecl = enableSkinning ? g_vbdeclSkinning : g_vbdecl;
mesh->meshParts.emplace_back( part );
mesh->meshParts.emplace_back(part);
}
model->meshes.emplace_back( mesh );
model->meshes.emplace_back(mesh);
}
return model;
@ -857,18 +857,18 @@ std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, c
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
std::unique_ptr<Model> DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, const wchar_t* szFileName, IEffectFactory& fxFactory, bool ccw, bool pmalpha )
std::unique_ptr<Model> DirectX::Model::CreateFromCMO(ID3D11Device* d3dDevice, const wchar_t* szFileName, IEffectFactory& fxFactory, bool ccw, bool pmalpha)
{
size_t dataSize = 0;
std::unique_ptr<uint8_t[]> data;
HRESULT hr = BinaryReader::ReadEntireFile( szFileName, data, &dataSize );
if ( FAILED(hr) )
HRESULT hr = BinaryReader::ReadEntireFile(szFileName, data, &dataSize);
if (FAILED(hr))
{
DebugTrace( "CreateFromCMO failed (%08X) loading '%ls'\n", hr, szFileName );
throw std::exception( "CreateFromCMO" );
DebugTrace("CreateFromCMO failed (%08X) loading '%ls'\n", hr, szFileName);
throw std::exception("CreateFromCMO");
}
auto model = CreateFromCMO( d3dDevice, data.get(), dataSize, fxFactory, ccw, pmalpha );
auto model = CreateFromCMO(d3dDevice, data.get(), dataSize, fxFactory, ccw, pmalpha);
model->name = szFileName;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: ModelLoadSDKMESH.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -41,12 +37,14 @@ namespace
{
std::shared_ptr<IEffect> effect;
bool alpha;
MaterialRecordSDKMESH() throw() : alpha(false) {}
};
void LoadMaterial(const DXUT::SDKMESH_MATERIAL& mh,
unsigned int flags,
IEffectFactory& fxFactory,
MaterialRecordSDKMESH& m)
unsigned int flags,
IEffectFactory& fxFactory,
MaterialRecordSDKMESH& m)
{
wchar_t matName[DXUT::MAX_MATERIAL_NAME];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, mh.Name, -1, matName, DXUT::MAX_MATERIAL_NAME);
@ -174,8 +172,8 @@ namespace
break;
}
else if (decl[index].Usage == D3DDECLUSAGE_NORMAL
|| decl[index].Usage == D3DDECLUSAGE_TANGENT
|| decl[index].Usage == D3DDECLUSAGE_BINORMAL)
|| decl[index].Usage == D3DDECLUSAGE_TANGENT
|| decl[index].Usage == D3DDECLUSAGE_BINORMAL)
{
size_t base = 1;
if (decl[index].Usage == D3DDECLUSAGE_TANGENT)
@ -188,21 +186,21 @@ namespace
bool unk = false;
switch (decl[index].Type)
{
case D3DDECLTYPE_FLOAT3: assert(desc.Format == DXGI_FORMAT_R32G32B32_FLOAT); offset += 12; break;
case D3DDECLTYPE_UBYTE4N: desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
case D3DDECLTYPE_SHORT4N: desc.Format = DXGI_FORMAT_R16G16B16A16_SNORM; offset += 8; break;
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
case D3DDECLTYPE_DXGI_R10G10B10A2_UNORM: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
case D3DDECLTYPE_DXGI_R11G11B10_FLOAT: desc.Format = DXGI_FORMAT_R11G11B10_FLOAT; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
case D3DDECLTYPE_DXGI_R8G8B8A8_SNORM: desc.Format = DXGI_FORMAT_R8G8B8A8_SNORM; offset += 4; break;
case D3DDECLTYPE_FLOAT3: assert(desc.Format == DXGI_FORMAT_R32G32B32_FLOAT); offset += 12; break;
case D3DDECLTYPE_UBYTE4N: desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
case D3DDECLTYPE_SHORT4N: desc.Format = DXGI_FORMAT_R16G16B16A16_SNORM; offset += 8; break;
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
case D3DDECLTYPE_DXGI_R10G10B10A2_UNORM: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
case D3DDECLTYPE_DXGI_R11G11B10_FLOAT: desc.Format = DXGI_FORMAT_R11G11B10_FLOAT; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
case D3DDECLTYPE_DXGI_R8G8B8A8_SNORM: desc.Format = DXGI_FORMAT_R8G8B8A8_SNORM; offset += 4; break;
#if defined(_XBOX_ONE) && defined(_TITLE)
case (32 + DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM): desc.Format = DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM; offset += 4; break;
#endif
#if defined(_XBOX_ONE) && defined(_TITLE)
case (32 + DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM): desc.Format = DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM; offset += 4; break;
#endif
default:
unk = true;
break;
default:
unk = true;
break;
}
if (unk)
@ -222,16 +220,16 @@ namespace
bool unk = false;
switch (decl[index].Type)
{
case D3DDECLTYPE_FLOAT4: desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; offset += 16; break;
case D3DDECLTYPE_D3DCOLOR: assert(desc.Format == DXGI_FORMAT_B8G8R8A8_UNORM); offset += 4; break;
case D3DDECLTYPE_UBYTE4N: desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; offset += 4; break;
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
case D3DDECLTYPE_DXGI_R10G10B10A2_UNORM: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; offset += 4; break;
case D3DDECLTYPE_DXGI_R11G11B10_FLOAT: desc.Format = DXGI_FORMAT_R11G11B10_FLOAT; offset += 4; break;
case D3DDECLTYPE_FLOAT4: desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; offset += 16; break;
case D3DDECLTYPE_D3DCOLOR: assert(desc.Format == DXGI_FORMAT_B8G8R8A8_UNORM); offset += 4; break;
case D3DDECLTYPE_UBYTE4N: desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; offset += 4; break;
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
case D3DDECLTYPE_DXGI_R10G10B10A2_UNORM: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; offset += 4; break;
case D3DDECLTYPE_DXGI_R11G11B10_FLOAT: desc.Format = DXGI_FORMAT_R11G11B10_FLOAT; offset += 4; break;
default:
unk = true;
break;
default:
unk = true;
break;
}
if (unk)
@ -249,16 +247,16 @@ namespace
bool unk = false;
switch (decl[index].Type)
{
case D3DDECLTYPE_FLOAT1: desc.Format = DXGI_FORMAT_R32_FLOAT; offset += 4; break;
case D3DDECLTYPE_FLOAT2: assert(desc.Format == DXGI_FORMAT_R32G32_FLOAT); offset += 8; break;
case D3DDECLTYPE_FLOAT3: desc.Format = DXGI_FORMAT_R32G32B32_FLOAT; offset += 12; break;
case D3DDECLTYPE_FLOAT4: desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; offset += 16; break;
case D3DDECLTYPE_FLOAT16_2: desc.Format = DXGI_FORMAT_R16G16_FLOAT; offset += 4; break;
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
case D3DDECLTYPE_FLOAT1: desc.Format = DXGI_FORMAT_R32_FLOAT; offset += 4; break;
case D3DDECLTYPE_FLOAT2: assert(desc.Format == DXGI_FORMAT_R32G32_FLOAT); offset += 8; break;
case D3DDECLTYPE_FLOAT3: desc.Format = DXGI_FORMAT_R32G32B32_FLOAT; offset += 12; break;
case D3DDECLTYPE_FLOAT4: desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; offset += 16; break;
case D3DDECLTYPE_FLOAT16_2: desc.Format = DXGI_FORMAT_R16G16_FLOAT; offset += 4; break;
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
default:
unk = true;
break;
default:
unk = true;
break;
}
if (unk)
@ -315,9 +313,9 @@ namespace
ThrowIfFailed(
device->CreateInputLayout(inputDesc.data(),
static_cast<UINT>(inputDesc.size()),
shaderByteCode, byteCodeLength,
pInputLayout)
static_cast<UINT>(inputDesc.size()),
shaderByteCode, byteCodeLength,
pInputLayout)
);
_Analysis_assume_(*pInputLayout != 0);
@ -332,100 +330,100 @@ namespace
//======================================================================================
_Use_decl_annotations_
std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH( ID3D11Device* d3dDevice, const uint8_t* meshData, size_t dataSize, IEffectFactory& fxFactory, bool ccw, bool pmalpha )
std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH(ID3D11Device* d3dDevice, const uint8_t* meshData, size_t dataSize, IEffectFactory& fxFactory, bool ccw, bool pmalpha)
{
if ( !d3dDevice || !meshData )
if (!d3dDevice || !meshData)
throw std::exception("Device and meshData cannot be null");
// File Headers
if ( dataSize < sizeof(DXUT::SDKMESH_HEADER) )
if (dataSize < sizeof(DXUT::SDKMESH_HEADER))
throw std::exception("End of file");
auto header = reinterpret_cast<const DXUT::SDKMESH_HEADER*>( meshData );
auto header = reinterpret_cast<const DXUT::SDKMESH_HEADER*>(meshData);
size_t headerSize = sizeof( DXUT::SDKMESH_HEADER )
+ header->NumVertexBuffers * sizeof(DXUT::SDKMESH_VERTEX_BUFFER_HEADER)
+ header->NumIndexBuffers * sizeof(DXUT::SDKMESH_INDEX_BUFFER_HEADER);
if ( header->HeaderSize != headerSize )
size_t headerSize = sizeof(DXUT::SDKMESH_HEADER)
+ header->NumVertexBuffers * sizeof(DXUT::SDKMESH_VERTEX_BUFFER_HEADER)
+ header->NumIndexBuffers * sizeof(DXUT::SDKMESH_INDEX_BUFFER_HEADER);
if (header->HeaderSize != headerSize)
throw std::exception("Not a valid SDKMESH file");
if ( dataSize < header->HeaderSize )
if (dataSize < header->HeaderSize)
throw std::exception("End of file");
if( header->Version != DXUT::SDKMESH_FILE_VERSION )
if (header->Version != DXUT::SDKMESH_FILE_VERSION)
throw std::exception("Not a supported SDKMESH version");
if ( header->IsBigEndian )
if (header->IsBigEndian)
throw std::exception("Loading BigEndian SDKMESH files not supported");
if ( !header->NumMeshes )
if (!header->NumMeshes)
throw std::exception("No meshes found");
if ( !header->NumVertexBuffers )
if (!header->NumVertexBuffers)
throw std::exception("No vertex buffers found");
if ( !header->NumIndexBuffers )
if (!header->NumIndexBuffers)
throw std::exception("No index buffers found");
if ( !header->NumTotalSubsets )
if (!header->NumTotalSubsets)
throw std::exception("No subsets found");
if ( !header->NumMaterials )
if (!header->NumMaterials)
throw std::exception("No materials found");
// Sub-headers
if ( dataSize < header->VertexStreamHeadersOffset
|| ( dataSize < (header->VertexStreamHeadersOffset + header->NumVertexBuffers * sizeof(DXUT::SDKMESH_VERTEX_BUFFER_HEADER) ) ) )
if (dataSize < header->VertexStreamHeadersOffset
|| (dataSize < (header->VertexStreamHeadersOffset + uint64_t(header->NumVertexBuffers) * sizeof(DXUT::SDKMESH_VERTEX_BUFFER_HEADER))))
throw std::exception("End of file");
auto vbArray = reinterpret_cast<const DXUT::SDKMESH_VERTEX_BUFFER_HEADER*>( meshData + header->VertexStreamHeadersOffset );
if ( dataSize < header->IndexStreamHeadersOffset
|| ( dataSize < (header->IndexStreamHeadersOffset + header->NumIndexBuffers * sizeof(DXUT::SDKMESH_INDEX_BUFFER_HEADER) ) ) )
throw std::exception("End of file");
auto ibArray = reinterpret_cast<const DXUT::SDKMESH_INDEX_BUFFER_HEADER*>( meshData + header->IndexStreamHeadersOffset );
auto vbArray = reinterpret_cast<const DXUT::SDKMESH_VERTEX_BUFFER_HEADER*>(meshData + header->VertexStreamHeadersOffset);
if ( dataSize < header->MeshDataOffset
|| ( dataSize < (header->MeshDataOffset + header->NumMeshes * sizeof(DXUT::SDKMESH_MESH) ) ) )
if (dataSize < header->IndexStreamHeadersOffset
|| (dataSize < (header->IndexStreamHeadersOffset + uint64_t(header->NumIndexBuffers) * sizeof(DXUT::SDKMESH_INDEX_BUFFER_HEADER))))
throw std::exception("End of file");
auto meshArray = reinterpret_cast<const DXUT::SDKMESH_MESH*>( meshData + header->MeshDataOffset );
auto ibArray = reinterpret_cast<const DXUT::SDKMESH_INDEX_BUFFER_HEADER*>(meshData + header->IndexStreamHeadersOffset);
if ( dataSize < header->SubsetDataOffset
|| ( dataSize < (header->SubsetDataOffset + header->NumTotalSubsets * sizeof(DXUT::SDKMESH_SUBSET) ) ) )
if (dataSize < header->MeshDataOffset
|| (dataSize < (header->MeshDataOffset + uint64_t(header->NumMeshes) * sizeof(DXUT::SDKMESH_MESH))))
throw std::exception("End of file");
auto subsetArray = reinterpret_cast<const DXUT::SDKMESH_SUBSET*>( meshData + header->SubsetDataOffset );
auto meshArray = reinterpret_cast<const DXUT::SDKMESH_MESH*>(meshData + header->MeshDataOffset);
if ( dataSize < header->FrameDataOffset
|| (dataSize < (header->FrameDataOffset + header->NumFrames * sizeof(DXUT::SDKMESH_FRAME) ) ) )
if (dataSize < header->SubsetDataOffset
|| (dataSize < (header->SubsetDataOffset + uint64_t(header->NumTotalSubsets) * sizeof(DXUT::SDKMESH_SUBSET))))
throw std::exception("End of file");
auto subsetArray = reinterpret_cast<const DXUT::SDKMESH_SUBSET*>(meshData + header->SubsetDataOffset);
if (dataSize < header->FrameDataOffset
|| (dataSize < (header->FrameDataOffset + uint64_t(header->NumFrames) * sizeof(DXUT::SDKMESH_FRAME))))
throw std::exception("End of file");
// TODO - auto frameArray = reinterpret_cast<const DXUT::SDKMESH_FRAME*>( meshData + header->FrameDataOffset );
if ( dataSize < header->MaterialDataOffset
|| (dataSize < (header->MaterialDataOffset + header->NumMaterials * sizeof(DXUT::SDKMESH_MATERIAL) ) ) )
if (dataSize < header->MaterialDataOffset
|| (dataSize < (header->MaterialDataOffset + uint64_t(header->NumMaterials) * sizeof(DXUT::SDKMESH_MATERIAL))))
throw std::exception("End of file");
auto materialArray = reinterpret_cast<const DXUT::SDKMESH_MATERIAL*>( meshData + header->MaterialDataOffset );
auto materialArray = reinterpret_cast<const DXUT::SDKMESH_MATERIAL*>(meshData + header->MaterialDataOffset);
// Buffer data
uint64_t bufferDataOffset = header->HeaderSize + header->NonBufferDataSize;
if ( ( dataSize < bufferDataOffset )
|| ( dataSize < bufferDataOffset + header->BufferDataSize ) )
if ((dataSize < bufferDataOffset)
|| (dataSize < bufferDataOffset + header->BufferDataSize))
throw std::exception("End of file");
const uint8_t* bufferData = meshData + bufferDataOffset;
const uint8_t* bufferData = meshData + bufferDataOffset;
// Create vertex buffers
std::vector<ComPtr<ID3D11Buffer>> vbs;
vbs.resize( header->NumVertexBuffers );
vbs.resize(header->NumVertexBuffers);
std::vector<std::shared_ptr<std::vector<D3D11_INPUT_ELEMENT_DESC>>> vbDecls;
vbDecls.resize( header->NumVertexBuffers );
vbDecls.resize(header->NumVertexBuffers);
std::vector<unsigned int> materialFlags;
materialFlags.resize( header->NumVertexBuffers );
materialFlags.resize(header->NumVertexBuffers);
for( UINT j=0; j < header->NumVertexBuffers; ++j )
for (UINT j = 0; j < header->NumVertexBuffers; ++j)
{
auto& vh = vbArray[j];
if ( dataSize < vh.DataOffset
|| ( dataSize < vh.DataOffset + vh.SizeBytes ) )
if (dataSize < vh.DataOffset
|| (dataSize < vh.DataOffset + vh.SizeBytes))
throw std::exception("End of file");
vbDecls[j] = std::make_shared<std::vector<D3D11_INPUT_ELEMENT_DESC>>();
@ -442,92 +440,92 @@ std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH( ID3D11Device* d3dDevic
materialFlags[j] = flags;
auto verts = reinterpret_cast<const uint8_t*>( bufferData + (vh.DataOffset - bufferDataOffset) );
auto verts = bufferData + (vh.DataOffset - bufferDataOffset);
D3D11_BUFFER_DESC desc = {};
desc.Usage = D3D11_USAGE_DEFAULT;
desc.ByteWidth = static_cast<UINT>( vh.SizeBytes );
desc.ByteWidth = static_cast<UINT>(vh.SizeBytes);
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
D3D11_SUBRESOURCE_DATA initData = {};
initData.pSysMem = verts;
ThrowIfFailed(
d3dDevice->CreateBuffer( &desc, &initData, &vbs[j] )
);
d3dDevice->CreateBuffer(&desc, &initData, &vbs[j])
);
SetDebugObjectName( vbs[j].Get(), "ModelSDKMESH" );
SetDebugObjectName(vbs[j].Get(), "ModelSDKMESH");
}
// Create index buffers
std::vector<ComPtr<ID3D11Buffer>> ibs;
ibs.resize( header->NumIndexBuffers );
for( UINT j=0; j < header->NumIndexBuffers; ++j )
ibs.resize(header->NumIndexBuffers);
for (UINT j = 0; j < header->NumIndexBuffers; ++j)
{
auto& ih = ibArray[j];
if ( dataSize < ih.DataOffset
|| ( dataSize < ih.DataOffset + ih.SizeBytes ) )
if (dataSize < ih.DataOffset
|| (dataSize < ih.DataOffset + ih.SizeBytes))
throw std::exception("End of file");
if ( ih.IndexType != DXUT::IT_16BIT && ih.IndexType != DXUT::IT_32BIT )
if (ih.IndexType != DXUT::IT_16BIT && ih.IndexType != DXUT::IT_32BIT)
throw std::exception("Invalid index buffer type found");
auto indices = reinterpret_cast<const uint8_t*>( bufferData + (ih.DataOffset - bufferDataOffset) );
auto indices = bufferData + (ih.DataOffset - bufferDataOffset);
D3D11_BUFFER_DESC desc = {};
desc.Usage = D3D11_USAGE_DEFAULT;
desc.ByteWidth = static_cast<UINT>( ih.SizeBytes );
desc.ByteWidth = static_cast<UINT>(ih.SizeBytes);
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
D3D11_SUBRESOURCE_DATA initData = {};
initData.pSysMem = indices;
ThrowIfFailed(
d3dDevice->CreateBuffer( &desc, &initData, &ibs[j] )
);
d3dDevice->CreateBuffer(&desc, &initData, &ibs[j])
);
SetDebugObjectName( ibs[j].Get(), "ModelSDKMESH" );
SetDebugObjectName(ibs[j].Get(), "ModelSDKMESH");
}
// Create meshes
std::vector<MaterialRecordSDKMESH> materials;
materials.resize( header->NumMaterials );
materials.resize(header->NumMaterials);
std::unique_ptr<Model> model(new Model());
model->meshes.reserve( header->NumMeshes );
model->meshes.reserve(header->NumMeshes);
for( UINT meshIndex = 0; meshIndex < header->NumMeshes; ++meshIndex )
for (UINT meshIndex = 0; meshIndex < header->NumMeshes; ++meshIndex)
{
auto& mh = meshArray[ meshIndex ];
auto& mh = meshArray[meshIndex];
if ( !mh.NumSubsets
|| !mh.NumVertexBuffers
|| mh.IndexBuffer >= header->NumIndexBuffers
|| mh.VertexBuffers[0] >= header->NumVertexBuffers )
if (!mh.NumSubsets
|| !mh.NumVertexBuffers
|| mh.IndexBuffer >= header->NumIndexBuffers
|| mh.VertexBuffers[0] >= header->NumVertexBuffers)
throw std::exception("Invalid mesh found");
// mh.NumVertexBuffers is sometimes not what you'd expect, so we skip validating it
if ( dataSize < mh.SubsetOffset
|| (dataSize < mh.SubsetOffset + mh.NumSubsets*sizeof(UINT) ) )
if (dataSize < mh.SubsetOffset
|| (dataSize < mh.SubsetOffset + uint64_t(mh.NumSubsets) * sizeof(UINT)))
throw std::exception("End of file");
auto subsets = reinterpret_cast<const UINT*>( meshData + mh.SubsetOffset );
auto subsets = reinterpret_cast<const UINT*>(meshData + mh.SubsetOffset);
if ( mh.NumFrameInfluences > 0 )
if (mh.NumFrameInfluences > 0)
{
if ( dataSize < mh.FrameInfluenceOffset
|| (dataSize < mh.FrameInfluenceOffset + mh.NumFrameInfluences*sizeof(UINT) ) )
if (dataSize < mh.FrameInfluenceOffset
|| (dataSize < mh.FrameInfluenceOffset + uint64_t(mh.NumFrameInfluences) * sizeof(UINT)))
throw std::exception("End of file");
// TODO - auto influences = reinterpret_cast<const UINT*>( meshData + mh.FrameInfluenceOffset );
}
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_ACP, MB_PRECOMPOSED, mh.Name, -1, meshName, DXUT::MAX_MESH_NAME);
mesh->name = meshName;
mesh->ccw = ccw;
mesh->pmalpha = pmalpha;
@ -535,76 +533,76 @@ std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH( ID3D11Device* d3dDevic
// Extents
mesh->boundingBox.Center = mh.BoundingBoxCenter;
mesh->boundingBox.Extents = mh.BoundingBoxExtents;
BoundingSphere::CreateFromBoundingBox( mesh->boundingSphere, mesh->boundingBox );
BoundingSphere::CreateFromBoundingBox(mesh->boundingSphere, mesh->boundingBox);
// Create subsets
mesh->meshParts.reserve( mh.NumSubsets );
for( UINT j = 0; j < mh.NumSubsets; ++j )
mesh->meshParts.reserve(mh.NumSubsets);
for (UINT j = 0; j < mh.NumSubsets; ++j)
{
auto sIndex = subsets[ j ];
if ( sIndex >= header->NumTotalSubsets )
auto sIndex = subsets[j];
if (sIndex >= header->NumTotalSubsets)
throw std::exception("Invalid mesh found");
auto& subset = subsetArray[ sIndex ];
auto& subset = subsetArray[sIndex];
D3D11_PRIMITIVE_TOPOLOGY primType;
switch( subset.PrimitiveType )
switch (subset.PrimitiveType)
{
case DXUT::PT_TRIANGLE_LIST: primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; break;
case DXUT::PT_TRIANGLE_STRIP: primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; break;
case DXUT::PT_LINE_LIST: primType = D3D11_PRIMITIVE_TOPOLOGY_LINELIST; break;
case DXUT::PT_LINE_STRIP: primType = D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP; break;
case DXUT::PT_POINT_LIST: primType = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; break;
case DXUT::PT_TRIANGLE_LIST_ADJ: primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ; break;
case DXUT::PT_TRIANGLE_STRIP_ADJ: primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ; break;
case DXUT::PT_LINE_LIST_ADJ: primType = D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; break;
case DXUT::PT_LINE_STRIP_ADJ: primType = D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ; break;
case DXUT::PT_TRIANGLE_LIST: primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; break;
case DXUT::PT_TRIANGLE_STRIP: primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; break;
case DXUT::PT_LINE_LIST: primType = D3D11_PRIMITIVE_TOPOLOGY_LINELIST; break;
case DXUT::PT_LINE_STRIP: primType = D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP; break;
case DXUT::PT_POINT_LIST: primType = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; break;
case DXUT::PT_TRIANGLE_LIST_ADJ: primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ; break;
case DXUT::PT_TRIANGLE_STRIP_ADJ: primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ; break;
case DXUT::PT_LINE_LIST_ADJ: primType = D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; break;
case DXUT::PT_LINE_STRIP_ADJ: primType = D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ; break;
case DXUT::PT_QUAD_PATCH_LIST:
case DXUT::PT_TRIANGLE_PATCH_LIST:
throw std::exception("Direct3D9 era tessellation not supported");
case DXUT::PT_QUAD_PATCH_LIST:
case DXUT::PT_TRIANGLE_PATCH_LIST:
throw std::exception("Direct3D9 era tessellation not supported");
default:
throw std::exception("Unknown primitive type");
default:
throw std::exception("Unknown primitive type");
}
if ( subset.MaterialID >= header->NumMaterials )
if (subset.MaterialID >= header->NumMaterials)
throw std::exception("Invalid mesh found");
auto& mat = materials[ subset.MaterialID ];
auto& mat = materials[subset.MaterialID];
if ( !mat.effect )
if (!mat.effect)
{
size_t vi = mh.VertexBuffers[0];
LoadMaterial(
materialArray[ subset.MaterialID ],
materialArray[subset.MaterialID],
materialFlags[vi],
fxFactory,
mat );
mat);
}
ComPtr<ID3D11InputLayout> il;
CreateInputLayout( d3dDevice, mat.effect.get(), *vbDecls[ mh.VertexBuffers[0] ].get(), &il );
CreateInputLayout(d3dDevice, mat.effect.get(), *vbDecls[mh.VertexBuffers[0]].get(), &il);
auto part = new ModelMeshPart();
part->isAlpha = mat.alpha;
part->indexCount = static_cast<uint32_t>( subset.IndexCount );
part->startIndex = static_cast<uint32_t>( subset.IndexStart );
part->vertexOffset = static_cast<uint32_t>( subset.VertexStart );
part->vertexStride = static_cast<uint32_t>( vbArray[ mh.VertexBuffers[0] ].StrideBytes );
part->indexFormat = ( ibArray[ mh.IndexBuffer ].IndexType == DXUT::IT_32BIT ) ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT;
part->primitiveType = primType;
part->indexCount = static_cast<uint32_t>(subset.IndexCount);
part->startIndex = static_cast<uint32_t>(subset.IndexStart);
part->vertexOffset = static_cast<uint32_t>(subset.VertexStart);
part->vertexStride = static_cast<uint32_t>(vbArray[mh.VertexBuffers[0]].StrideBytes);
part->indexFormat = (ibArray[mh.IndexBuffer].IndexType == DXUT::IT_32BIT) ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT;
part->primitiveType = primType;
part->inputLayout = il;
part->indexBuffer = ibs[ mh.IndexBuffer ];
part->vertexBuffer = vbs[ mh.VertexBuffers[0] ];
part->indexBuffer = ibs[mh.IndexBuffer];
part->vertexBuffer = vbs[mh.VertexBuffers[0]];
part->effect = mat.effect;
part->vbDecl = vbDecls[ mh.VertexBuffers[0] ];
part->vbDecl = vbDecls[mh.VertexBuffers[0]];
mesh->meshParts.emplace_back( part );
mesh->meshParts.emplace_back(part);
}
model->meshes.emplace_back( mesh );
model->meshes.emplace_back(mesh);
}
return model;
@ -613,18 +611,18 @@ std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH( ID3D11Device* d3dDevic
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH( ID3D11Device* d3dDevice, const wchar_t* szFileName, IEffectFactory& fxFactory, bool ccw, bool pmalpha )
std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH(ID3D11Device* d3dDevice, const wchar_t* szFileName, IEffectFactory& fxFactory, bool ccw, bool pmalpha)
{
size_t dataSize = 0;
std::unique_ptr<uint8_t[]> data;
HRESULT hr = BinaryReader::ReadEntireFile( szFileName, data, &dataSize );
if ( FAILED(hr) )
HRESULT hr = BinaryReader::ReadEntireFile(szFileName, data, &dataSize);
if (FAILED(hr))
{
DebugTrace( "CreateFromSDKMESH failed (%08X) loading '%ls'\n", hr, szFileName );
throw std::exception( "CreateFromSDKMESH" );
DebugTrace("CreateFromSDKMESH failed (%08X) loading '%ls'\n", hr, szFileName);
throw std::exception("CreateFromSDKMESH");
}
auto model = CreateFromSDKMESH( d3dDevice, data.get(), dataSize, fxFactory, ccw, pmalpha );
auto model = CreateFromSDKMESH(d3dDevice, data.get(), dataSize, fxFactory, ccw, pmalpha);
model->name = szFileName;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: ModelLoadVBO.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -41,7 +37,8 @@ namespace
UNREFERENCED_PARAMETER(Parameter);
UNREFERENCED_PARAMETER(lpContext);
g_vbdecl = std::make_shared<std::vector<D3D11_INPUT_ELEMENT_DESC>>(VertexPositionNormalTexture::InputElements,
g_vbdecl = std::make_shared<std::vector<D3D11_INPUT_ELEMENT_DESC>>(
VertexPositionNormalTexture::InputElements,
VertexPositionNormalTexture::InputElements + VertexPositionNormalTexture::InputElementCount);
return TRUE;
@ -57,28 +54,28 @@ std::unique_ptr<Model> DirectX::Model::CreateFromVBO(ID3D11Device* d3dDevice, co
if (!InitOnceExecuteOnce(&g_InitOnce, InitializeDecl, nullptr, nullptr))
throw std::exception("One-time initialization failed");
if ( !d3dDevice || !meshData )
if (!d3dDevice || !meshData)
throw std::exception("Device and meshData cannot be null");
// File Header
if ( dataSize < sizeof(VBO::header_t) )
if (dataSize < sizeof(VBO::header_t))
throw std::exception("End of file");
auto header = reinterpret_cast<const VBO::header_t*>( meshData );
auto header = reinterpret_cast<const VBO::header_t*>(meshData);
if ( !header->numVertices || !header->numIndices )
if (!header->numVertices || !header->numIndices)
throw std::exception("No vertices or indices found");
size_t vertSize = sizeof(VertexPositionNormalTexture) * header->numVertices;
if (dataSize < (vertSize + sizeof(VBO::header_t)))
throw std::exception("End of file");
auto verts = reinterpret_cast<const VertexPositionNormalTexture*>( meshData + sizeof(VBO::header_t) );
auto verts = reinterpret_cast<const VertexPositionNormalTexture*>(meshData + sizeof(VBO::header_t));
size_t indexSize = sizeof(uint16_t) * header->numIndices;
if (dataSize < (sizeof(VBO::header_t) + vertSize + indexSize))
throw std::exception("End of file");
auto indices = reinterpret_cast<const uint16_t*>( meshData + sizeof(VBO::header_t) + vertSize );
auto indices = reinterpret_cast<const uint16_t*>(meshData + sizeof(VBO::header_t) + vertSize);
// Create vertex buffer
ComPtr<ID3D11Buffer> vb;
@ -93,7 +90,7 @@ std::unique_ptr<Model> DirectX::Model::CreateFromVBO(ID3D11Device* d3dDevice, co
ThrowIfFailed(
d3dDevice->CreateBuffer(&desc, &initData, vb.GetAddressOf())
);
);
SetDebugObjectName(vb.Get(), "ModelVBO");
}
@ -111,7 +108,7 @@ std::unique_ptr<Model> DirectX::Model::CreateFromVBO(ID3D11Device* d3dDevice, co
ThrowIfFailed(
d3dDevice->CreateBuffer(&desc, &initData, ib.GetAddressOf())
);
);
SetDebugObjectName(ib.Get(), "ModelVBO");
}
@ -145,7 +142,7 @@ std::unique_ptr<Model> DirectX::Model::CreateFromVBO(ID3D11Device* d3dDevice, co
auto part = new ModelMeshPart();
part->indexCount = header->numIndices;
part->startIndex = 0;
part->vertexStride = static_cast<UINT>( sizeof(VertexPositionNormalTexture) );
part->vertexStride = static_cast<UINT>(sizeof(VertexPositionNormalTexture));
part->inputLayout = il;
part->indexBuffer = ib;
part->vertexBuffer = vb;
@ -161,7 +158,7 @@ std::unique_ptr<Model> DirectX::Model::CreateFromVBO(ID3D11Device* d3dDevice, co
std::unique_ptr<Model> model(new Model());
model->meshes.emplace_back(mesh);
return model;
}
@ -173,14 +170,14 @@ std::unique_ptr<Model> DirectX::Model::CreateFromVBO(ID3D11Device* d3dDevice, co
{
size_t dataSize = 0;
std::unique_ptr<uint8_t[]> data;
HRESULT hr = BinaryReader::ReadEntireFile( szFileName, data, &dataSize );
if ( FAILED(hr) )
HRESULT hr = BinaryReader::ReadEntireFile(szFileName, data, &dataSize);
if (FAILED(hr))
{
DebugTrace( "CreateFromVBO failed (%08X) loading '%ls'\n", hr, szFileName );
throw std::exception( "CreateFromVBO" );
DebugTrace("CreateFromVBO failed (%08X) loading '%ls'\n", hr, szFileName);
throw std::exception("CreateFromVBO");
}
auto model = CreateFromVBO( d3dDevice, data.get(), dataSize, ieffect, ccw, pmalpha );
auto model = CreateFromVBO(d3dDevice, data.get(), dataSize, ieffect, ccw, pmalpha);
model->name = szFileName;

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: Mouse.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#include "pch.h"
@ -160,6 +157,38 @@ public:
return GetSystemMetrics(SM_MOUSEPRESENT) != 0;
}
bool IsVisible() const
{
if (mMode == MODE_RELATIVE)
return false;
CURSORINFO info = { sizeof(CURSORINFO) };
if (!GetCursorInfo(&info))
{
throw std::exception("GetCursorInfo");
}
return (info.flags & CURSOR_SHOWING) != 0;
}
void SetVisible(bool visible)
{
if (mMode == MODE_RELATIVE)
return;
CURSORINFO info = { sizeof(CURSORINFO) };
if (!GetCursorInfo(&info))
{
throw std::exception("GetCursorInfo");
}
bool isvisible = (info.flags & CURSOR_SHOWING) != 0;
if (isvisible != visible)
{
ShowCursor(visible);
}
}
void SetWindow(HWND window)
{
if (mWindow == window)
@ -255,189 +284,189 @@ void Mouse::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
evts[2] = pImpl->mRelativeMode.get();
switch (WaitForMultipleObjectsEx(_countof(evts), evts, FALSE, 0, FALSE))
{
case WAIT_OBJECT_0:
pImpl->mState.scrollWheelValue = 0;
ResetEvent(evts[0]);
case WAIT_OBJECT_0:
pImpl->mState.scrollWheelValue = 0;
ResetEvent(evts[0]);
break;
case (WAIT_OBJECT_0 + 1):
{
pImpl->mMode = MODE_ABSOLUTE;
ClipCursor(nullptr);
POINT point;
point.x = pImpl->mLastX;
point.y = pImpl->mLastY;
// We show the cursor before moving it to support Remote Desktop
ShowCursor(TRUE);
if (MapWindowPoints(pImpl->mWindow, nullptr, &point, 1))
{
SetCursorPos(point.x, point.y);
}
pImpl->mState.x = pImpl->mLastX;
pImpl->mState.y = pImpl->mLastY;
}
break;
case (WAIT_OBJECT_0 + 1):
{
pImpl->mMode = MODE_ABSOLUTE;
ClipCursor(nullptr);
POINT point;
point.x = pImpl->mLastX;
point.y = pImpl->mLastY;
// We show the cursor before moving it to support Remote Desktop
ShowCursor(TRUE);
if (MapWindowPoints(pImpl->mWindow, nullptr, &point, 1))
case (WAIT_OBJECT_0 + 2):
{
SetCursorPos(point.x, point.y);
ResetEvent(pImpl->mRelativeRead.get());
pImpl->mMode = MODE_RELATIVE;
pImpl->mState.x = pImpl->mState.y = 0;
pImpl->mRelativeX = INT32_MAX;
pImpl->mRelativeY = INT32_MAX;
ShowCursor(FALSE);
pImpl->ClipToWindow();
}
pImpl->mState.x = pImpl->mLastX;
pImpl->mState.y = pImpl->mLastY;
}
break;
break;
case (WAIT_OBJECT_0 + 2):
{
ResetEvent(pImpl->mRelativeRead.get());
pImpl->mMode = MODE_RELATIVE;
pImpl->mState.x = pImpl->mState.y = 0;
pImpl->mRelativeX = INT32_MAX;
pImpl->mRelativeY = INT32_MAX;
ShowCursor(FALSE);
pImpl->ClipToWindow();
}
break;
case WAIT_FAILED:
throw std::exception("WaitForMultipleObjectsEx");
case WAIT_FAILED:
throw std::exception("WaitForMultipleObjectsEx");
}
switch (message)
{
case WM_ACTIVATEAPP:
if (wParam)
{
pImpl->mInFocus = true;
if (pImpl->mMode == MODE_RELATIVE)
case WM_ACTIVATEAPP:
if (wParam)
{
pImpl->mState.x = pImpl->mState.y = 0;
pImpl->mInFocus = true;
ShowCursor(FALSE);
pImpl->ClipToWindow();
}
}
else
{
int scrollWheel = pImpl->mState.scrollWheelValue;
memset(&pImpl->mState, 0, sizeof(State));
pImpl->mState.scrollWheelValue = scrollWheel;
pImpl->mInFocus = false;
}
return;
case WM_INPUT:
if (pImpl->mInFocus && pImpl->mMode == MODE_RELATIVE)
{
RAWINPUT raw;
UINT rawSize = sizeof(raw);
UINT resultData = GetRawInputData(reinterpret_cast<HRAWINPUT>(lParam), RID_INPUT, &raw, &rawSize, sizeof(RAWINPUTHEADER));
if (resultData == UINT(-1))
{
throw std::exception("GetRawInputData");
}
if (raw.header.dwType == RIM_TYPEMOUSE)
{
if (!(raw.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE))
if (pImpl->mMode == MODE_RELATIVE)
{
pImpl->mState.x = raw.data.mouse.lLastX;
pImpl->mState.y = raw.data.mouse.lLastY;
pImpl->mState.x = pImpl->mState.y = 0;
ResetEvent(pImpl->mRelativeRead.get());
}
else if (raw.data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP)
{
// This is used to make Remote Desktop sessons work
const int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
const int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
ShowCursor(FALSE);
int x = static_cast<int>((float(raw.data.mouse.lLastX) / 65535.0f) * width);
int y = static_cast<int>((float(raw.data.mouse.lLastY) / 65535.0f) * height);
if (pImpl->mRelativeX == INT32_MAX)
{
pImpl->mState.x = pImpl->mState.y = 0;
}
else
{
pImpl->mState.x = x - pImpl->mRelativeX;
pImpl->mState.y = y - pImpl->mRelativeY;
}
pImpl->mRelativeX = x;
pImpl->mRelativeY = y;
ResetEvent(pImpl->mRelativeRead.get());
pImpl->ClipToWindow();
}
}
}
return;
else
{
int scrollWheel = pImpl->mState.scrollWheelValue;
memset(&pImpl->mState, 0, sizeof(State));
pImpl->mState.scrollWheelValue = scrollWheel;
case WM_MOUSEMOVE:
break;
pImpl->mInFocus = false;
}
return;
case WM_LBUTTONDOWN:
pImpl->mState.leftButton = true;
break;
case WM_INPUT:
if (pImpl->mInFocus && pImpl->mMode == MODE_RELATIVE)
{
RAWINPUT raw;
UINT rawSize = sizeof(raw);
case WM_LBUTTONUP:
pImpl->mState.leftButton = false;
break;
UINT resultData = GetRawInputData(reinterpret_cast<HRAWINPUT>(lParam), RID_INPUT, &raw, &rawSize, sizeof(RAWINPUTHEADER));
if (resultData == UINT(-1))
{
throw std::exception("GetRawInputData");
}
case WM_RBUTTONDOWN:
pImpl->mState.rightButton = true;
break;
if (raw.header.dwType == RIM_TYPEMOUSE)
{
if (!(raw.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE))
{
pImpl->mState.x = raw.data.mouse.lLastX;
pImpl->mState.y = raw.data.mouse.lLastY;
case WM_RBUTTONUP:
pImpl->mState.rightButton = false;
break;
ResetEvent(pImpl->mRelativeRead.get());
}
else if (raw.data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP)
{
// This is used to make Remote Desktop sessons work
const int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
const int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
case WM_MBUTTONDOWN:
pImpl->mState.middleButton = true;
break;
int x = static_cast<int>((float(raw.data.mouse.lLastX) / 65535.0f) * width);
int y = static_cast<int>((float(raw.data.mouse.lLastY) / 65535.0f) * height);
case WM_MBUTTONUP:
pImpl->mState.middleButton = false;
break;
if (pImpl->mRelativeX == INT32_MAX)
{
pImpl->mState.x = pImpl->mState.y = 0;
}
else
{
pImpl->mState.x = x - pImpl->mRelativeX;
pImpl->mState.y = y - pImpl->mRelativeY;
}
case WM_MOUSEWHEEL:
pImpl->mState.scrollWheelValue += GET_WHEEL_DELTA_WPARAM(wParam);
return;
pImpl->mRelativeX = x;
pImpl->mRelativeY = y;
case WM_XBUTTONDOWN:
switch (GET_XBUTTON_WPARAM(wParam))
{
case XBUTTON1:
pImpl->mState.xButton1 = true;
ResetEvent(pImpl->mRelativeRead.get());
}
}
}
return;
case WM_MOUSEMOVE:
break;
case XBUTTON2:
pImpl->mState.xButton2 = true;
break;
}
break;
case WM_XBUTTONUP:
switch (GET_XBUTTON_WPARAM(wParam))
{
case XBUTTON1:
pImpl->mState.xButton1 = false;
case WM_LBUTTONDOWN:
pImpl->mState.leftButton = true;
break;
case XBUTTON2:
pImpl->mState.xButton2 = false;
case WM_LBUTTONUP:
pImpl->mState.leftButton = false;
break;
}
break;
case WM_MOUSEHOVER:
break;
case WM_RBUTTONDOWN:
pImpl->mState.rightButton = true;
break;
default:
// Not a mouse message, so exit
return;
case WM_RBUTTONUP:
pImpl->mState.rightButton = false;
break;
case WM_MBUTTONDOWN:
pImpl->mState.middleButton = true;
break;
case WM_MBUTTONUP:
pImpl->mState.middleButton = false;
break;
case WM_MOUSEWHEEL:
pImpl->mState.scrollWheelValue += GET_WHEEL_DELTA_WPARAM(wParam);
return;
case WM_XBUTTONDOWN:
switch (GET_XBUTTON_WPARAM(wParam))
{
case XBUTTON1:
pImpl->mState.xButton1 = true;
break;
case XBUTTON2:
pImpl->mState.xButton2 = true;
break;
}
break;
case WM_XBUTTONUP:
switch (GET_XBUTTON_WPARAM(wParam))
{
case XBUTTON1:
pImpl->mState.xButton1 = false;
break;
case XBUTTON2:
pImpl->mState.xButton2 = false;
break;
}
break;
case WM_MOUSEHOVER:
break;
default:
// Not a mouse message, so exit
return;
}
if (pImpl->mMode == MODE_ABSOLUTE)
@ -452,7 +481,7 @@ void Mouse::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
}
#elif defined(_XBOX_ONE) || ( defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) )
#elif (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)) || (defined(_XBOX_ONE) && (!defined(_TITLE) || (_XDK_VER < 0x42D907D1)))
//======================================================================================
// Null device for Windows Phone
@ -486,9 +515,8 @@ public:
{
}
void SetMode(Mode mode)
void SetMode(Mode)
{
UNREFERENCED_PARAMETER(mode);
}
bool IsConnected() const
@ -496,6 +524,15 @@ public:
return false;
}
bool IsVisible() const
{
return false;
}
void SetVisible(bool)
{
}
Mouse* mOwner;
static Mouse::Impl* s_mouse;
@ -676,6 +713,49 @@ public:
return false;
}
bool IsVisible() const
{
if (mMode == MODE_RELATIVE)
return false;
ComPtr<ABI::Windows::UI::Core::ICoreCursor> cursor;
HRESULT hr = mWindow->get_PointerCursor(cursor.GetAddressOf());
ThrowIfFailed(hr);
return cursor != 0;
}
void SetVisible(bool visible)
{
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::UI::Core;
if (mMode == MODE_RELATIVE)
return;
if (visible)
{
if (!mCursor)
{
ComPtr<ICoreCursorFactory> factory;
HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreCursor).Get(), factory.GetAddressOf());
ThrowIfFailed(hr);
hr = factory->CreateCursor(CoreCursorType_Arrow, 0, mCursor.GetAddressOf());
ThrowIfFailed(hr);
}
HRESULT hr = mWindow->put_PointerCursor(mCursor.Get());
ThrowIfFailed(hr);
}
else
{
HRESULT hr = mWindow->put_PointerCursor(nullptr);
ThrowIfFailed(hr);
}
}
void SetWindow(ABI::Windows::UI::Core::ICoreWindow* window)
{
using namespace Microsoft::WRL;
@ -939,13 +1019,13 @@ void Mouse::SetDpi(float dpi)
// Public constructor.
Mouse::Mouse()
: pImpl(new Impl(this))
: pImpl(std::make_unique<Impl>(this))
{
}
// Move constructor.
Mouse::Mouse(Mouse&& moveFrom)
Mouse::Mouse(Mouse&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
pImpl->mOwner = this;
@ -953,7 +1033,7 @@ Mouse::Mouse(Mouse&& moveFrom)
// Move assignment.
Mouse& Mouse::operator= (Mouse&& moveFrom)
Mouse& Mouse::operator= (Mouse&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
pImpl->mOwner = this;
@ -992,6 +1072,15 @@ bool Mouse::IsConnected() const
return pImpl->IsConnected();
}
bool Mouse::IsVisible() const
{
return pImpl->IsVisible();
}
void Mouse::SetVisible(bool visible)
{
pImpl->SetVisible(visible);
}
Mouse& Mouse::Get()
{

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: NormalMapEffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -38,7 +34,7 @@ struct NormalMapEffectConstants
XMMATRIX worldViewProj;
};
static_assert( ( sizeof(NormalMapEffectConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert((sizeof(NormalMapEffectConstants) % 16) == 0, "CB size not padded correctly");
// Traits type describes our characteristics to the EffectBase template.
@ -179,7 +175,7 @@ SharedResourcePool<ID3D11Device*, EffectBase<NormalMapEffectTraits>::DeviceResou
// Constructor.
NormalMapEffect::Impl::Impl(_In_ ID3D11Device* device)
: EffectBase(device),
: EffectBase(device),
vertexColorEnabled(false),
biasedVertexNormals(false)
{
@ -188,10 +184,10 @@ NormalMapEffect::Impl::Impl(_In_ ID3D11Device* device)
throw std::exception("NormalMapEffect requires Feature Level 10.0 or later");
}
static_assert( _countof(EffectBase<NormalMapEffectTraits>::VertexShaderIndices) == NormalMapEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert( _countof(EffectBase<NormalMapEffectTraits>::VertexShaderBytecode) == NormalMapEffectTraits::VertexShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<NormalMapEffectTraits>::PixelShaderBytecode) == NormalMapEffectTraits::PixelShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<NormalMapEffectTraits>::PixelShaderIndices) == NormalMapEffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert(_countof(EffectBase<NormalMapEffectTraits>::VertexShaderIndices) == NormalMapEffectTraits::ShaderPermutationCount, "array/max mismatch");
static_assert(_countof(EffectBase<NormalMapEffectTraits>::VertexShaderBytecode) == NormalMapEffectTraits::VertexShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<NormalMapEffectTraits>::PixelShaderBytecode) == NormalMapEffectTraits::PixelShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<NormalMapEffectTraits>::PixelShaderIndices) == NormalMapEffectTraits::ShaderPermutationCount, "array/max mismatch");
lights.InitializeConstants(constants.specularColorAndPower, constants.lightDirection, constants.lightDiffuseColor, constants.lightSpecularColor);
}
@ -250,20 +246,20 @@ void NormalMapEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
// Public constructor.
NormalMapEffect::NormalMapEffect(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
: pImpl(std::make_unique<Impl>(device))
{
}
// Move constructor.
NormalMapEffect::NormalMapEffect(NormalMapEffect&& moveFrom)
NormalMapEffect::NormalMapEffect(NormalMapEffect&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
NormalMapEffect& NormalMapEffect::operator= (NormalMapEffect&& moveFrom)
NormalMapEffect& NormalMapEffect::operator= (NormalMapEffect&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: PBREffect.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
@ -40,7 +36,7 @@ struct PBREffectConstants
float targetHeight;
};
static_assert( ( sizeof(PBREffectConstants) % 16 ) == 0, "CB size not padded correctly" );
static_assert((sizeof(PBREffectConstants) % 16) == 0, "CB size not padded correctly");
// Traits type describes our characteristics to the EffectBase template.
@ -178,10 +174,10 @@ PBREffect::Impl::Impl(_In_ ID3D11Device* device)
throw std::exception("PBREffect requires Feature Level 10.0 or later");
}
static_assert( _countof(EffectBase<PBREffectTraits>::VertexShaderIndices) == PBREffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert( _countof(EffectBase<PBREffectTraits>::VertexShaderBytecode) == PBREffectTraits::VertexShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<PBREffectTraits>::PixelShaderBytecode) == PBREffectTraits::PixelShaderCount, "array/max mismatch" );
static_assert( _countof(EffectBase<PBREffectTraits>::PixelShaderIndices) == PBREffectTraits::ShaderPermutationCount, "array/max mismatch" );
static_assert(_countof(EffectBase<PBREffectTraits>::VertexShaderIndices) == PBREffectTraits::ShaderPermutationCount, "array/max mismatch");
static_assert(_countof(EffectBase<PBREffectTraits>::VertexShaderBytecode) == PBREffectTraits::VertexShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<PBREffectTraits>::PixelShaderBytecode) == PBREffectTraits::PixelShaderCount, "array/max mismatch");
static_assert(_countof(EffectBase<PBREffectTraits>::PixelShaderIndices) == PBREffectTraits::ShaderPermutationCount, "array/max mismatch");
// Lighting
static const XMVECTORF32 defaultLightDirection = { 0, -1, 0, 0 };
@ -290,20 +286,20 @@ void PBREffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
// Public constructor.
PBREffect::PBREffect(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
: pImpl(std::make_unique<Impl>(device))
{
}
// Move constructor.
PBREffect::PBREffect(PBREffect&& moveFrom)
PBREffect::PBREffect(PBREffect&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
PBREffect& PBREffect::operator= (PBREffect&& moveFrom)
PBREffect& PBREffect::operator= (PBREffect&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -1,14 +1,11 @@
//--------------------------------------------------------------------------------------
// File: PlatformHelpers.h
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
@ -49,19 +46,19 @@ namespace DirectX
// Helper for output debug tracing
inline void DebugTrace( _In_z_ _Printf_format_string_ const char* format, ... )
inline void DebugTrace(_In_z_ _Printf_format_string_ const char* format, ...)
{
#ifdef _DEBUG
#ifdef _DEBUG
va_list args;
va_start( args, format );
va_start(args, format);
char buff[1024] = {};
vsprintf_s( buff, format, args );
OutputDebugStringA( buff );
va_end( args );
#else
UNREFERENCED_PARAMETER( format );
#endif
vsprintf_s(buff, format, args);
OutputDebugStringA(buff);
va_end(args);
#else
UNREFERENCED_PARAMETER(format);
#endif
}
@ -76,77 +73,5 @@ namespace DirectX
typedef std::unique_ptr<void, handle_closer> ScopedHandle;
inline HANDLE safe_handle( HANDLE h ) { return (h == INVALID_HANDLE_VALUE) ? 0 : h; }
inline HANDLE safe_handle(HANDLE h) { return (h == INVALID_HANDLE_VALUE) ? 0 : h; }
}
#ifdef DIRECTX_EMULATE_MUTEX
// Emulate the C++0x mutex and lock_guard types when building with Visual Studio CRT versions < 2012.
namespace std
{
class mutex
{
public:
mutex() { InitializeCriticalSection(&mCriticalSection); }
~mutex() { DeleteCriticalSection(&mCriticalSection); }
void lock() { EnterCriticalSection(&mCriticalSection); }
void unlock() { LeaveCriticalSection(&mCriticalSection); }
bool try_lock() { return TryEnterCriticalSection(&mCriticalSection) != 0; }
private:
CRITICAL_SECTION mCriticalSection;
mutex(mutex const&);
mutex& operator= (mutex const&);
};
template<typename Mutex>
class lock_guard
{
public:
typedef Mutex mutex_type;
explicit lock_guard(mutex_type& mutex)
: mMutex(mutex)
{
mMutex.lock();
}
~lock_guard()
{
mMutex.unlock();
}
private:
mutex_type& mMutex;
lock_guard(lock_guard const&);
lock_guard& operator= (lock_guard const&);
};
}
#else
#include <mutex>
#endif
#ifdef DIRECTX_EMULATE_MAKE_UNIQUE
// Emulate make_unique when building with Visual Studio CRT versions < 2012.
namespace std
{
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
}
#endif

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

@ -1,12 +1,8 @@
//--------------------------------------------------------------------------------------
// File: PrimitiveBatch.cpp
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
@ -120,7 +116,14 @@ PrimitiveBatchBase::Impl::Impl(_In_ ID3D11DeviceContext* deviceContext, size_t m
mCurrentIndex(0),
mCurrentVertex(0),
mBaseIndex(0),
mBaseVertex(0)
mBaseVertex(0),
#if defined(_XBOX_ONE) && defined(_TITLE)
grfxMemoryIB(nullptr),
grfxMemoryVB(nullptr)
#else
mMappedIndices{},
mMappedVertices{}
#endif
{
ComPtr<ID3D11Device> device;
deviceContext->GetDevice(&device);
@ -329,7 +332,7 @@ void PrimitiveBatchBase::Impl::Draw(D3D11_PRIMITIVE_TOPOLOGY topology, bool isIn
// Copy over the index data.
if (isIndexed)
{
auto outputIndices = reinterpret_cast<uint16_t*>(mMappedIndices.pData) + mCurrentIndex;
auto outputIndices = static_cast<uint16_t*>(mMappedIndices.pData) + mCurrentIndex;
for (size_t i = 0; i < indexCount; i++)
{
@ -340,7 +343,7 @@ void PrimitiveBatchBase::Impl::Draw(D3D11_PRIMITIVE_TOPOLOGY topology, bool isIn
}
// Return the output vertex data location.
*pMappedVertices = reinterpret_cast<uint8_t*>(mMappedVertices.pData) + (mCurrentVertex * mVertexSize);
*pMappedVertices = static_cast<uint8_t*>(mMappedVertices.pData) + (mCurrentVertex * mVertexSize);
mCurrentVertex += vertexCount;
#endif
@ -397,20 +400,20 @@ void PrimitiveBatchBase::Impl::FlushBatch()
// Public constructor.
PrimitiveBatchBase::PrimitiveBatchBase(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices, size_t maxVertices, size_t vertexSize)
: pImpl(new Impl(deviceContext, maxIndices, maxVertices, vertexSize))
: pImpl(std::make_unique<Impl>(deviceContext, maxIndices, maxVertices, vertexSize))
{
}
// Move constructor.
PrimitiveBatchBase::PrimitiveBatchBase(PrimitiveBatchBase&& moveFrom)
PrimitiveBatchBase::PrimitiveBatchBase(PrimitiveBatchBase&& moveFrom) throw()
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
PrimitiveBatchBase& PrimitiveBatchBase::operator= (PrimitiveBatchBase&& moveFrom)
PrimitiveBatchBase& PrimitiveBatchBase::operator= (PrimitiveBatchBase&& moveFrom) throw()
{
pImpl = std::move(moveFrom.pImpl);
return *this;

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

@ -6,14 +6,11 @@
//
// http://go.microsoft.com/fwlink/?LinkId=226208
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once

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

@ -8,12 +8,8 @@
// full-featured texture capture, DDS writer, and texture processing pipeline,
// see the 'Texconv' sample and the 'DirectXTex' library.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
// http://go.microsoft.com/fwlink/?LinkId=248929
@ -41,7 +37,8 @@ using namespace DirectX::LoaderHelpers;
namespace
{
//--------------------------------------------------------------------------------------
HRESULT CaptureTexture(_In_ ID3D11DeviceContext* pContext,
HRESULT CaptureTexture(
_In_ ID3D11DeviceContext* pContext,
_In_ ID3D11Resource* pSource,
D3D11_TEXTURE2D_DESC& desc,
ComPtr<ID3D11Texture2D>& pStaging)
@ -134,7 +131,7 @@ namespace
pContext->CopyResource(pStaging.Get(), pSource);
}
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
if (d3dDevice->GetCreationFlags() & D3D11_CREATE_DEVICE_IMMEDIATE_CONTEXT_FAST_SEMANTICS)
{
@ -156,7 +153,7 @@ namespace
}
}
#endif
#endif
return S_OK;
}
@ -165,40 +162,41 @@ namespace
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::SaveDDSTextureToFile( ID3D11DeviceContext* pContext,
ID3D11Resource* pSource,
const wchar_t* fileName )
HRESULT DirectX::SaveDDSTextureToFile(
ID3D11DeviceContext* pContext,
ID3D11Resource* pSource,
const wchar_t* fileName)
{
if ( !fileName )
if (!fileName)
return E_INVALIDARG;
D3D11_TEXTURE2D_DESC desc = {};
ComPtr<ID3D11Texture2D> pStaging;
HRESULT hr = CaptureTexture( pContext, pSource, desc, pStaging );
if ( FAILED(hr) )
HRESULT hr = CaptureTexture(pContext, pSource, desc, pStaging);
if (FAILED(hr))
return hr;
// Create file
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
ScopedHandle hFile( safe_handle( CreateFile2( fileName, GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr ) ) );
ScopedHandle hFile(safe_handle(CreateFile2(fileName, GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr)));
#else
ScopedHandle hFile( safe_handle( CreateFileW( fileName, GENERIC_WRITE | DELETE, 0, nullptr, CREATE_ALWAYS, 0, nullptr ) ) );
ScopedHandle hFile(safe_handle(CreateFileW(fileName, GENERIC_WRITE | DELETE, 0, nullptr, CREATE_ALWAYS, 0, nullptr)));
#endif
if ( !hFile )
return HRESULT_FROM_WIN32( GetLastError() );
if (!hFile)
return HRESULT_FROM_WIN32(GetLastError());
auto_delete_file delonfail(hFile.get());
// Setup header
const size_t MAX_HEADER_SIZE = sizeof(uint32_t) + sizeof(DDS_HEADER) + sizeof(DDS_HEADER_DXT10);
uint8_t fileHeader[ MAX_HEADER_SIZE ];
uint8_t fileHeader[MAX_HEADER_SIZE];
*reinterpret_cast<uint32_t*>(&fileHeader[0]) = DDS_MAGIC;
auto header = reinterpret_cast<DDS_HEADER*>( &fileHeader[0] + sizeof(uint32_t) );
auto header = reinterpret_cast<DDS_HEADER*>(&fileHeader[0] + sizeof(uint32_t));
size_t headerSize = sizeof(uint32_t) + sizeof(DDS_HEADER);
memset( header, 0, sizeof(DDS_HEADER) );
header->size = sizeof( DDS_HEADER );
memset(header, 0, sizeof(DDS_HEADER));
header->size = sizeof(DDS_HEADER);
header->flags = DDS_HEADER_FLAGS_TEXTURE | DDS_HEADER_FLAGS_MIPMAP;
header->height = desc.Height;
header->width = desc.Width;
@ -207,116 +205,116 @@ HRESULT DirectX::SaveDDSTextureToFile( ID3D11DeviceContext* pContext,
// Try to use a legacy .DDS pixel format for better tools support, otherwise fallback to 'DX10' header extension
DDS_HEADER_DXT10* extHeader = nullptr;
switch( desc.Format )
switch (desc.Format)
{
case DXGI_FORMAT_R8G8B8A8_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_R16G16_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_R8G8_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_R16_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_L16, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_R8_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_L8, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_A8_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_A8, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_R8G8_B8G8_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_G8R8_G8B8_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_BC1_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_BC2_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_DXT3, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_BC3_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_DXT5, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_BC4_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_BC4_UNORM, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_BC4_SNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_BC4_SNORM, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_BC5_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_BC5_UNORM, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_BC5_SNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_B5G6R5_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_R8G8_SNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_R16G16_SNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT) ); break;
case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT) ); break; // DXGI 1.1
case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT) ); break; // DXGI 1.1
case DXGI_FORMAT_YUY2: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT) ); break; // DXGI 1.2
case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT) ); break; // DXGI 1.2
case DXGI_FORMAT_R8G8B8A8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_R16G16_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_R8G8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_R16_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_L16, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_R8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_L8, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_A8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_R8G8_B8G8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_G8R8_G8B8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_BC1_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_BC2_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT3, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_BC3_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT5, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_BC4_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC4_UNORM, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_BC4_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC4_SNORM, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_BC5_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC5_UNORM, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_BC5_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_B5G6R5_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_R8G8_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_R16G16_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT)); break;
case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.1
case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.1
case DXGI_FORMAT_YUY2: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.2
case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.2
// Legacy D3DX formats using D3DFMT enum value as FourCC
case DXGI_FORMAT_R32G32B32A32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 116; break; // D3DFMT_A32B32G32R32F
case DXGI_FORMAT_R16G16B16A16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 113; break; // D3DFMT_A16B16G16R16F
case DXGI_FORMAT_R16G16B16A16_UNORM: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 36; break; // D3DFMT_A16B16G16R16
case DXGI_FORMAT_R16G16B16A16_SNORM: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 110; break; // D3DFMT_Q16W16V16U16
case DXGI_FORMAT_R32G32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 115; break; // D3DFMT_G32R32F
case DXGI_FORMAT_R16G16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 112; break; // D3DFMT_G16R16F
case DXGI_FORMAT_R32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 114; break; // D3DFMT_R32F
case DXGI_FORMAT_R16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 111; break; // D3DFMT_R16F
// Legacy D3DX formats using D3DFMT enum value as FourCC
case DXGI_FORMAT_R32G32B32A32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 116; break; // D3DFMT_A32B32G32R32F
case DXGI_FORMAT_R16G16B16A16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 113; break; // D3DFMT_A16B16G16R16F
case DXGI_FORMAT_R16G16B16A16_UNORM: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 36; break; // D3DFMT_A16B16G16R16
case DXGI_FORMAT_R16G16B16A16_SNORM: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 110; break; // D3DFMT_Q16W16V16U16
case DXGI_FORMAT_R32G32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 115; break; // D3DFMT_G32R32F
case DXGI_FORMAT_R16G16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 112; break; // D3DFMT_G16R16F
case DXGI_FORMAT_R32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 114; break; // D3DFMT_R32F
case DXGI_FORMAT_R16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 111; break; // D3DFMT_R16F
case DXGI_FORMAT_AI44:
case DXGI_FORMAT_IA44:
case DXGI_FORMAT_P8:
case DXGI_FORMAT_A8P8:
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
case DXGI_FORMAT_AI44:
case DXGI_FORMAT_IA44:
case DXGI_FORMAT_P8:
case DXGI_FORMAT_A8P8:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
default:
memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_DX10, sizeof(DDS_PIXELFORMAT) );
default:
memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DX10, sizeof(DDS_PIXELFORMAT));
headerSize += sizeof(DDS_HEADER_DXT10);
extHeader = reinterpret_cast<DDS_HEADER_DXT10*>( reinterpret_cast<uint8_t*>(&fileHeader[0]) + sizeof(uint32_t) + sizeof(DDS_HEADER) );
memset( extHeader, 0, sizeof(DDS_HEADER_DXT10) );
extHeader->dxgiFormat = desc.Format;
extHeader->resourceDimension = D3D11_RESOURCE_DIMENSION_TEXTURE2D;
extHeader->arraySize = 1;
break;
headerSize += sizeof(DDS_HEADER_DXT10);
extHeader = reinterpret_cast<DDS_HEADER_DXT10*>(fileHeader + sizeof(uint32_t) + sizeof(DDS_HEADER));
memset(extHeader, 0, sizeof(DDS_HEADER_DXT10));
extHeader->dxgiFormat = desc.Format;
extHeader->resourceDimension = D3D11_RESOURCE_DIMENSION_TEXTURE2D;
extHeader->arraySize = 1;
break;
}
size_t rowPitch, slicePitch, rowCount;
GetSurfaceInfo( desc.Width, desc.Height, desc.Format, &slicePitch, &rowPitch, &rowCount );
GetSurfaceInfo(desc.Width, desc.Height, desc.Format, &slicePitch, &rowPitch, &rowCount);
if ( IsCompressed( desc.Format ) )
if (IsCompressed(desc.Format))
{
header->flags |= DDS_HEADER_FLAGS_LINEARSIZE;
header->pitchOrLinearSize = static_cast<uint32_t>( slicePitch );
header->pitchOrLinearSize = static_cast<uint32_t>(slicePitch);
}
else
{
header->flags |= DDS_HEADER_FLAGS_PITCH;
header->pitchOrLinearSize = static_cast<uint32_t>( rowPitch );
header->pitchOrLinearSize = static_cast<uint32_t>(rowPitch);
}
// Setup pixels
std::unique_ptr<uint8_t[]> pixels( new (std::nothrow) uint8_t[ slicePitch ] );
std::unique_ptr<uint8_t[]> pixels(new (std::nothrow) uint8_t[slicePitch]);
if (!pixels)
return E_OUTOFMEMORY;
D3D11_MAPPED_SUBRESOURCE mapped;
hr = pContext->Map( pStaging.Get(), 0, D3D11_MAP_READ, 0, &mapped );
if ( FAILED(hr) )
hr = pContext->Map(pStaging.Get(), 0, D3D11_MAP_READ, 0, &mapped);
if (FAILED(hr))
return hr;
auto sptr = reinterpret_cast<const uint8_t*>( mapped.pData );
if ( !sptr )
auto sptr = static_cast<const uint8_t*>(mapped.pData);
if (!sptr)
{
pContext->Unmap( pStaging.Get(), 0 );
pContext->Unmap(pStaging.Get(), 0);
return E_POINTER;
}
uint8_t* dptr = pixels.get();
size_t msize = std::min<size_t>( rowPitch, mapped.RowPitch );
for( size_t h = 0; h < rowCount; ++h )
size_t msize = std::min<size_t>(rowPitch, mapped.RowPitch);
for (size_t h = 0; h < rowCount; ++h)
{
memcpy_s( dptr, rowPitch, sptr, msize );
memcpy_s(dptr, rowPitch, sptr, msize);
sptr += mapped.RowPitch;
dptr += rowPitch;
}
pContext->Unmap( pStaging.Get(), 0 );
pContext->Unmap(pStaging.Get(), 0);
// Write header & pixels
DWORD bytesWritten;
if ( !WriteFile( hFile.get(), fileHeader, static_cast<DWORD>( headerSize ), &bytesWritten, nullptr ) )
return HRESULT_FROM_WIN32( GetLastError() );
if (!WriteFile(hFile.get(), fileHeader, static_cast<DWORD>(headerSize), &bytesWritten, nullptr))
return HRESULT_FROM_WIN32(GetLastError());
if ( bytesWritten != headerSize )
if (bytesWritten != headerSize)
return E_FAIL;
if ( !WriteFile( hFile.get(), pixels.get(), static_cast<DWORD>( slicePitch ), &bytesWritten, nullptr ) )
return HRESULT_FROM_WIN32( GetLastError() );
if (!WriteFile(hFile.get(), pixels.get(), static_cast<DWORD>(slicePitch), &bytesWritten, nullptr))
return HRESULT_FROM_WIN32(GetLastError());
if ( bytesWritten != slicePitch )
if (bytesWritten != slicePitch)
return E_FAIL;
delonfail.clear();
@ -327,183 +325,184 @@ HRESULT DirectX::SaveDDSTextureToFile( ID3D11DeviceContext* pContext,
//--------------------------------------------------------------------------------------
namespace DirectX
{
extern bool _IsWIC2();
extern IWICImagingFactory* _GetWIC();
extern bool _IsWIC2();
extern IWICImagingFactory* _GetWIC();
}
_Use_decl_annotations_
HRESULT DirectX::SaveWICTextureToFile( ID3D11DeviceContext* pContext,
ID3D11Resource* pSource,
REFGUID guidContainerFormat,
const wchar_t* fileName,
const GUID* targetFormat,
std::function<void(IPropertyBag2*)> setCustomProps )
HRESULT DirectX::SaveWICTextureToFile(
ID3D11DeviceContext* pContext,
ID3D11Resource* pSource,
REFGUID guidContainerFormat,
const wchar_t* fileName,
const GUID* targetFormat,
std::function<void(IPropertyBag2*)> setCustomProps)
{
if ( !fileName )
if (!fileName)
return E_INVALIDARG;
D3D11_TEXTURE2D_DESC desc = {};
ComPtr<ID3D11Texture2D> pStaging;
HRESULT hr = CaptureTexture( pContext, pSource, desc, pStaging );
if ( FAILED(hr) )
HRESULT hr = CaptureTexture(pContext, pSource, desc, pStaging);
if (FAILED(hr))
return hr;
// Determine source format's WIC equivalent
WICPixelFormatGUID pfGuid;
bool sRGB = false;
switch ( desc.Format )
switch (desc.Format)
{
case DXGI_FORMAT_R32G32B32A32_FLOAT: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break;
case DXGI_FORMAT_R16G16B16A16_FLOAT: pfGuid = GUID_WICPixelFormat64bppRGBAHalf; break;
case DXGI_FORMAT_R16G16B16A16_UNORM: pfGuid = GUID_WICPixelFormat64bppRGBA; break;
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102XR; break; // DXGI 1.1
case DXGI_FORMAT_R10G10B10A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102; break;
case DXGI_FORMAT_B5G5R5A1_UNORM: pfGuid = GUID_WICPixelFormat16bppBGRA5551; break;
case DXGI_FORMAT_B5G6R5_UNORM: pfGuid = GUID_WICPixelFormat16bppBGR565; break;
case DXGI_FORMAT_R32_FLOAT: pfGuid = GUID_WICPixelFormat32bppGrayFloat; break;
case DXGI_FORMAT_R16_FLOAT: pfGuid = GUID_WICPixelFormat16bppGrayHalf; break;
case DXGI_FORMAT_R16_UNORM: pfGuid = GUID_WICPixelFormat16bppGray; break;
case DXGI_FORMAT_R8_UNORM: pfGuid = GUID_WICPixelFormat8bppGray; break;
case DXGI_FORMAT_A8_UNORM: pfGuid = GUID_WICPixelFormat8bppAlpha; break;
case DXGI_FORMAT_R32G32B32A32_FLOAT: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break;
case DXGI_FORMAT_R16G16B16A16_FLOAT: pfGuid = GUID_WICPixelFormat64bppRGBAHalf; break;
case DXGI_FORMAT_R16G16B16A16_UNORM: pfGuid = GUID_WICPixelFormat64bppRGBA; break;
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102XR; break; // DXGI 1.1
case DXGI_FORMAT_R10G10B10A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102; break;
case DXGI_FORMAT_B5G5R5A1_UNORM: pfGuid = GUID_WICPixelFormat16bppBGRA5551; break;
case DXGI_FORMAT_B5G6R5_UNORM: pfGuid = GUID_WICPixelFormat16bppBGR565; break;
case DXGI_FORMAT_R32_FLOAT: pfGuid = GUID_WICPixelFormat32bppGrayFloat; break;
case DXGI_FORMAT_R16_FLOAT: pfGuid = GUID_WICPixelFormat16bppGrayHalf; break;
case DXGI_FORMAT_R16_UNORM: pfGuid = GUID_WICPixelFormat16bppGray; break;
case DXGI_FORMAT_R8_UNORM: pfGuid = GUID_WICPixelFormat8bppGray; break;
case DXGI_FORMAT_A8_UNORM: pfGuid = GUID_WICPixelFormat8bppAlpha; break;
case DXGI_FORMAT_R8G8B8A8_UNORM:
pfGuid = GUID_WICPixelFormat32bppRGBA;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM:
pfGuid = GUID_WICPixelFormat32bppRGBA;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
pfGuid = GUID_WICPixelFormat32bppRGBA;
sRGB = true;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
pfGuid = GUID_WICPixelFormat32bppRGBA;
sRGB = true;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM: // DXGI 1.1
pfGuid = GUID_WICPixelFormat32bppBGRA;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM: // DXGI 1.1
pfGuid = GUID_WICPixelFormat32bppBGRA;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: // DXGI 1.1
pfGuid = GUID_WICPixelFormat32bppBGRA;
sRGB = true;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: // DXGI 1.1
pfGuid = GUID_WICPixelFormat32bppBGRA;
sRGB = true;
break;
case DXGI_FORMAT_B8G8R8X8_UNORM: // DXGI 1.1
pfGuid = GUID_WICPixelFormat32bppBGR;
break;
case DXGI_FORMAT_B8G8R8X8_UNORM: // DXGI 1.1
pfGuid = GUID_WICPixelFormat32bppBGR;
break;
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: // DXGI 1.1
pfGuid = GUID_WICPixelFormat32bppBGR;
sRGB = true;
break;
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: // DXGI 1.1
pfGuid = GUID_WICPixelFormat32bppBGR;
sRGB = true;
break;
default:
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
default:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
auto pWIC = _GetWIC();
if ( !pWIC )
if (!pWIC)
return E_NOINTERFACE;
ComPtr<IWICStream> stream;
hr = pWIC->CreateStream( stream.GetAddressOf() );
if ( FAILED(hr) )
hr = pWIC->CreateStream(stream.GetAddressOf());
if (FAILED(hr))
return hr;
hr = stream->InitializeFromFilename( fileName, GENERIC_WRITE );
if ( FAILED(hr) )
hr = stream->InitializeFromFilename(fileName, GENERIC_WRITE);
if (FAILED(hr))
return hr;
auto_delete_file_wic delonfail(stream, fileName);
ComPtr<IWICBitmapEncoder> encoder;
hr = pWIC->CreateEncoder( guidContainerFormat, 0, encoder.GetAddressOf() );
if ( FAILED(hr) )
hr = pWIC->CreateEncoder(guidContainerFormat, 0, encoder.GetAddressOf());
if (FAILED(hr))
return hr;
hr = encoder->Initialize( stream.Get(), WICBitmapEncoderNoCache );
if ( FAILED(hr) )
hr = encoder->Initialize(stream.Get(), WICBitmapEncoderNoCache);
if (FAILED(hr))
return hr;
ComPtr<IWICBitmapFrameEncode> frame;
ComPtr<IPropertyBag2> props;
hr = encoder->CreateNewFrame( frame.GetAddressOf(), props.GetAddressOf() );
if ( FAILED(hr) )
hr = encoder->CreateNewFrame(frame.GetAddressOf(), props.GetAddressOf());
if (FAILED(hr))
return hr;
if ( targetFormat && memcmp( &guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID) ) == 0 && _IsWIC2() )
if (targetFormat && memcmp(&guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID)) == 0 && _IsWIC2())
{
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
PROPBAG2 option = {};
option.pstrName = const_cast<wchar_t*>(L"EnableV5Header32bppBGRA");
VARIANT varValue;
VARIANT varValue;
varValue.vt = VT_BOOL;
varValue.boolVal = VARIANT_TRUE;
(void)props->Write( 1, &option, &varValue );
varValue.boolVal = VARIANT_TRUE;
(void)props->Write(1, &option, &varValue);
}
if ( setCustomProps )
if (setCustomProps)
{
setCustomProps( props.Get() );
setCustomProps(props.Get());
}
hr = frame->Initialize( props.Get() );
if ( FAILED(hr) )
hr = frame->Initialize(props.Get());
if (FAILED(hr))
return hr;
hr = frame->SetSize( desc.Width , desc.Height );
if ( FAILED(hr) )
hr = frame->SetSize(desc.Width, desc.Height);
if (FAILED(hr))
return hr;
hr = frame->SetResolution( 72, 72 );
if ( FAILED(hr) )
hr = frame->SetResolution(72, 72);
if (FAILED(hr))
return hr;
// Pick a target format
WICPixelFormatGUID targetGuid;
if ( targetFormat )
if (targetFormat)
{
targetGuid = *targetFormat;
}
else
{
// Screenshots dont typically include the alpha channel of the render target
switch ( desc.Format )
// Screenshots don't typically include the alpha channel of the render target
switch (desc.Format)
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
case DXGI_FORMAT_R32G32B32A32_FLOAT:
case DXGI_FORMAT_R16G16B16A16_FLOAT:
if ( _IsWIC2() )
{
targetGuid = GUID_WICPixelFormat96bppRGBFloat;
}
else
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
case DXGI_FORMAT_R32G32B32A32_FLOAT:
case DXGI_FORMAT_R16G16B16A16_FLOAT:
if (_IsWIC2())
{
targetGuid = GUID_WICPixelFormat96bppRGBFloat;
}
else
{
targetGuid = GUID_WICPixelFormat24bppBGR;
}
break;
#endif
case DXGI_FORMAT_R16G16B16A16_UNORM: targetGuid = GUID_WICPixelFormat48bppBGR; break;
case DXGI_FORMAT_B5G5R5A1_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR555; break;
case DXGI_FORMAT_B5G6R5_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR565; break;
case DXGI_FORMAT_R32_FLOAT:
case DXGI_FORMAT_R16_FLOAT:
case DXGI_FORMAT_R16_UNORM:
case DXGI_FORMAT_R8_UNORM:
case DXGI_FORMAT_A8_UNORM:
targetGuid = GUID_WICPixelFormat8bppGray;
break;
default:
targetGuid = GUID_WICPixelFormat24bppBGR;
}
break;
#endif
case DXGI_FORMAT_R16G16B16A16_UNORM: targetGuid = GUID_WICPixelFormat48bppBGR; break;
case DXGI_FORMAT_B5G5R5A1_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR555; break;
case DXGI_FORMAT_B5G6R5_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR565; break;
case DXGI_FORMAT_R32_FLOAT:
case DXGI_FORMAT_R16_FLOAT:
case DXGI_FORMAT_R16_UNORM:
case DXGI_FORMAT_R8_UNORM:
case DXGI_FORMAT_A8_UNORM:
targetGuid = GUID_WICPixelFormat8bppGray;
break;
default:
targetGuid = GUID_WICPixelFormat24bppBGR;
break;
break;
}
}
hr = frame->SetPixelFormat( &targetGuid );
if ( FAILED(hr) )
hr = frame->SetPixelFormat(&targetGuid);
if (FAILED(hr))
return hr;
if ( targetFormat && memcmp( targetFormat, &targetGuid, sizeof(WICPixelFormatGUID) ) != 0 )
if (targetFormat && memcmp(targetFormat, &targetGuid, sizeof(WICPixelFormatGUID)) != 0)
{
// Requested output pixel format is not supported by the WIC codec
return E_FAIL;
@ -511,18 +510,18 @@ HRESULT DirectX::SaveWICTextureToFile( ID3D11DeviceContext* pContext,
// Encode WIC metadata
ComPtr<IWICMetadataQueryWriter> metawriter;
if ( SUCCEEDED( frame->GetMetadataQueryWriter( metawriter.GetAddressOf() ) ) )
if (SUCCEEDED(frame->GetMetadataQueryWriter(metawriter.GetAddressOf())))
{
PROPVARIANT value;
PropVariantInit( &value );
PropVariantInit(&value);
value.vt = VT_LPSTR;
value.pszVal = const_cast<char*>("DirectXTK");
if ( memcmp( &guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID) ) == 0 )
if (memcmp(&guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0)
{
// Set Software name
(void)metawriter->SetMetadataByName( L"/tEXt/{str=Software}", &value );
(void)metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value);
// Set sRGB chunk
if (sRGB)
@ -542,114 +541,114 @@ HRESULT DirectX::SaveWICTextureToFile( ID3D11DeviceContext* pContext,
(void)metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent");
}
}
#if defined(_XBOX_ONE) && defined(_TITLE)
else if ( memcmp( &guidContainerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID) ) == 0 )
#if defined(_XBOX_ONE) && defined(_TITLE)
else if (memcmp(&guidContainerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID)) == 0)
{
// Set Software name
(void)metawriter->SetMetadataByName( L"/app1/ifd/{ushort=305}", &value );
(void)metawriter->SetMetadataByName(L"/app1/ifd/{ushort=305}", &value);
if ( sRGB )
if (sRGB)
{
// Set EXIF Colorspace of sRGB
value.vt = VT_UI2;
value.uiVal = 1;
(void)metawriter->SetMetadataByName( L"/app1/ifd/exif/{ushort=40961}", &value );
(void)metawriter->SetMetadataByName(L"/app1/ifd/exif/{ushort=40961}", &value);
}
}
else if ( memcmp( &guidContainerFormat, &GUID_ContainerFormatTiff, sizeof(GUID) ) == 0 )
else if (memcmp(&guidContainerFormat, &GUID_ContainerFormatTiff, sizeof(GUID)) == 0)
{
// Set Software name
(void)metawriter->SetMetadataByName( L"/ifd/{ushort=305}", &value );
(void)metawriter->SetMetadataByName(L"/ifd/{ushort=305}", &value);
if ( sRGB )
if (sRGB)
{
// Set EXIF Colorspace of sRGB
value.vt = VT_UI2;
value.uiVal = 1;
(void)metawriter->SetMetadataByName( L"/ifd/exif/{ushort=40961}", &value );
(void)metawriter->SetMetadataByName(L"/ifd/exif/{ushort=40961}", &value);
}
}
#else
#else
else
{
// Set Software name
(void)metawriter->SetMetadataByName( L"System.ApplicationName", &value );
(void)metawriter->SetMetadataByName(L"System.ApplicationName", &value);
if ( sRGB )
if (sRGB)
{
// Set EXIF Colorspace of sRGB
value.vt = VT_UI2;
value.uiVal = 1;
(void)metawriter->SetMetadataByName( L"System.Image.ColorSpace", &value );
(void)metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value);
}
}
#endif
#endif
}
D3D11_MAPPED_SUBRESOURCE mapped;
hr = pContext->Map( pStaging.Get(), 0, D3D11_MAP_READ, 0, &mapped );
if ( FAILED(hr) )
hr = pContext->Map(pStaging.Get(), 0, D3D11_MAP_READ, 0, &mapped);
if (FAILED(hr))
return hr;
if ( memcmp( &targetGuid, &pfGuid, sizeof(WICPixelFormatGUID) ) != 0 )
if (memcmp(&targetGuid, &pfGuid, sizeof(WICPixelFormatGUID)) != 0)
{
// Conversion required to write
ComPtr<IWICBitmap> source;
hr = pWIC->CreateBitmapFromMemory( desc.Width, desc.Height, pfGuid,
mapped.RowPitch, mapped.RowPitch * desc.Height,
reinterpret_cast<BYTE*>( mapped.pData ), source.GetAddressOf() );
if ( FAILED(hr) )
hr = pWIC->CreateBitmapFromMemory(desc.Width, desc.Height, pfGuid,
mapped.RowPitch, mapped.RowPitch * desc.Height,
static_cast<BYTE*>(mapped.pData), source.GetAddressOf());
if (FAILED(hr))
{
pContext->Unmap( pStaging.Get(), 0 );
pContext->Unmap(pStaging.Get(), 0);
return hr;
}
ComPtr<IWICFormatConverter> FC;
hr = pWIC->CreateFormatConverter( FC.GetAddressOf() );
if ( FAILED(hr) )
hr = pWIC->CreateFormatConverter(FC.GetAddressOf());
if (FAILED(hr))
{
pContext->Unmap( pStaging.Get(), 0 );
pContext->Unmap(pStaging.Get(), 0);
return hr;
}
BOOL canConvert = FALSE;
hr = FC->CanConvert( pfGuid, targetGuid, &canConvert );
if ( FAILED(hr) || !canConvert )
hr = FC->CanConvert(pfGuid, targetGuid, &canConvert);
if (FAILED(hr) || !canConvert)
{
return E_UNEXPECTED;
}
hr = FC->Initialize( source.Get(), targetGuid, WICBitmapDitherTypeNone, nullptr, 0, WICBitmapPaletteTypeMedianCut );
if ( FAILED(hr) )
hr = FC->Initialize(source.Get(), targetGuid, WICBitmapDitherTypeNone, nullptr, 0, WICBitmapPaletteTypeMedianCut);
if (FAILED(hr))
{
pContext->Unmap( pStaging.Get(), 0 );
pContext->Unmap(pStaging.Get(), 0);
return hr;
}
WICRect rect = { 0, 0, static_cast<INT>( desc.Width ), static_cast<INT>( desc.Height ) };
hr = frame->WriteSource( FC.Get(), &rect );
if ( FAILED(hr) )
WICRect rect = { 0, 0, static_cast<INT>(desc.Width), static_cast<INT>(desc.Height) };
hr = frame->WriteSource(FC.Get(), &rect);
if (FAILED(hr))
{
pContext->Unmap( pStaging.Get(), 0 );
pContext->Unmap(pStaging.Get(), 0);
return hr;
}
}
else
{
// No conversion required
hr = frame->WritePixels( desc.Height, mapped.RowPitch, mapped.RowPitch * desc.Height, reinterpret_cast<BYTE*>( mapped.pData ) );
if ( FAILED(hr) )
hr = frame->WritePixels(desc.Height, mapped.RowPitch, mapped.RowPitch * desc.Height, static_cast<BYTE*>(mapped.pData));
if (FAILED(hr))
return hr;
}
pContext->Unmap( pStaging.Get(), 0 );
pContext->Unmap(pStaging.Get(), 0);
hr = frame->Commit();
if ( FAILED(hr) )
if (FAILED(hr))
return hr;
hr = encoder->Commit();
if ( FAILED(hr) )
if (FAILED(hr))
return hr;
delonfail.clear();

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

@ -1,9 +1,5 @@
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://create.msdn.com/en-US/education/catalog/sample/stock_effects

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

@ -1,9 +1,5 @@
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://create.msdn.com/en-US/education/catalog/sample/stock_effects

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

@ -1,11 +1,9 @@
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248926
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
// http://create.msdn.com/en-US/education/catalog/sample/stock_effects

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

@ -1,10 +1,6 @@
@echo off
rem THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
rem ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
rem THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
rem PARTICULAR PURPOSE.
rem
rem Copyright (c) Microsoft Corporation. All rights reserved.
rem Licensed under the MIT License.
setlocal
set error=0

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

@ -41,7 +41,7 @@
dcl t2.xy // pin<8,9>
dcl_2d s0
#line 115 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 111 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
texld r0, t2, s0
mad r1.w, r0.w, t0.w, -c0.x
mul r0, r0, t0 // ::color<0,1,2,3>
@ -50,7 +50,7 @@
cmp r1, r1.x, c0.w, c0.z
texkill r1
#line 20 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 18 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
mad r1.xyz, c1, r0.w, -r0
mad r0.xyz, t1.w, r1, r0 // ApplyFog::color<0,1,2>
mov oC0, r0 // ::PSAlphaTestEqNe<0,1,2,3>
@ -81,10 +81,10 @@ ret
const BYTE AlphaTestEffect_PSAlphaTestEqNe[] =
{
68, 88, 66, 67, 4, 162,
13, 139, 204, 139, 237, 107,
120, 146, 165, 30, 105, 221,
97, 27, 1, 0, 0, 0,
68, 88, 66, 67, 65, 153,
224, 77, 127, 159, 122, 32,
3, 97, 172, 234, 185, 5,
105, 111, 1, 0, 0, 0,
16, 6, 0, 0, 4, 0,
0, 0, 48, 0, 0, 0,
180, 3, 0, 0, 116, 5,
@ -133,19 +133,19 @@ const BYTE AlphaTestEffect_PSAlphaTestEqNe[] =
0, 0, 0, 0, 255, 255,
140, 2, 0, 0, 0, 0,
255, 255, 152, 2, 0, 0,
115, 0, 0, 0, 164, 2,
0, 0, 117, 0, 0, 0,
180, 2, 0, 0, 115, 0,
111, 0, 0, 0, 164, 2,
0, 0, 113, 0, 0, 0,
180, 2, 0, 0, 111, 0,
0, 0, 200, 2, 0, 0,
117, 0, 0, 0, 216, 2,
0, 0, 117, 0, 0, 0,
228, 2, 0, 0, 117, 0,
113, 0, 0, 0, 216, 2,
0, 0, 113, 0, 0, 0,
228, 2, 0, 0, 113, 0,
0, 0, 244, 2, 0, 0,
117, 0, 0, 0, 8, 3,
0, 0, 20, 0, 1, 0,
16, 3, 0, 0, 20, 0,
113, 0, 0, 0, 8, 3,
0, 0, 18, 0, 1, 0,
16, 3, 0, 0, 18, 0,
1, 0, 36, 3, 0, 0,
20, 0, 1, 0, 56, 3,
18, 0, 1, 0, 56, 3,
0, 0, 80, 83, 65, 108,
112, 104, 97, 84, 101, 115,
116, 69, 113, 78, 101, 0,

Двоичный файл не отображается.

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

@ -39,7 +39,7 @@
dcl t1.xy // pin<4,5>
dcl_2d s0
#line 128 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 124 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
texld r0, t1, s0
mad r1.w, r0.w, t0.w, -c0.x
mul r0, r0, t0 // ::color<0,1,2,3>
@ -72,10 +72,10 @@ ret
const BYTE AlphaTestEffect_PSAlphaTestEqNeNoFog[] =
{
68, 88, 66, 67, 52, 40,
0, 181, 251, 126, 42, 165,
196, 170, 19, 103, 67, 108,
228, 56, 1, 0, 0, 0,
68, 88, 66, 67, 51, 166,
176, 29, 155, 181, 178, 64,
208, 217, 33, 166, 4, 202,
58, 59, 1, 0, 0, 0,
220, 4, 0, 0, 4, 0,
0, 0, 48, 0, 0, 0,
244, 2, 0, 0, 88, 4,
@ -113,16 +113,16 @@ const BYTE AlphaTestEffect_PSAlphaTestEqNeNoFog[] =
232, 1, 0, 0, 0, 0,
255, 255, 244, 1, 0, 0,
0, 0, 255, 255, 0, 2,
0, 0, 128, 0, 0, 0,
12, 2, 0, 0, 130, 0,
0, 0, 124, 0, 0, 0,
12, 2, 0, 0, 126, 0,
0, 0, 28, 2, 0, 0,
128, 0, 0, 0, 48, 2,
0, 0, 128, 0, 0, 0,
64, 2, 0, 0, 130, 0,
124, 0, 0, 0, 48, 2,
0, 0, 124, 0, 0, 0,
64, 2, 0, 0, 126, 0,
0, 0, 76, 2, 0, 0,
130, 0, 0, 0, 88, 2,
0, 0, 130, 0, 0, 0,
104, 2, 0, 0, 130, 0,
126, 0, 0, 0, 88, 2,
0, 0, 126, 0, 0, 0,
104, 2, 0, 0, 126, 0,
0, 0, 124, 2, 0, 0,
80, 83, 65, 108, 112, 104,
97, 84, 101, 115, 116, 69,

Двоичный файл не отображается.

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

@ -41,14 +41,14 @@
dcl t2.xy // pin<8,9>
dcl_2d s0
#line 91 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 87 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
texld r0, t2, s0
mad r1.w, r0.w, t0.w, -c0.x
mul r0, r0, t0 // ::color<0,1,2,3>
cmp r1, r1.w, c0.w, c0.z
texkill r1
#line 20 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 18 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
mad r1.xyz, c1, r0.w, -r0
mad r0.xyz, t1.w, r1, r0 // ApplyFog::color<0,1,2>
mov oC0, r0 // ::PSAlphaTestLtGt<0,1,2,3>
@ -78,10 +78,10 @@ ret
const BYTE AlphaTestEffect_PSAlphaTestLtGt[] =
{
68, 88, 66, 67, 88, 214,
60, 78, 4, 80, 104, 211,
157, 39, 0, 174, 110, 64,
49, 145, 1, 0, 0, 0,
68, 88, 66, 67, 98, 25,
91, 169, 6, 124, 199, 15,
68, 135, 172, 93, 172, 15,
224, 179, 1, 0, 0, 0,
180, 5, 0, 0, 4, 0,
0, 0, 48, 0, 0, 0,
136, 3, 0, 0, 24, 5,
@ -130,16 +130,16 @@ const BYTE AlphaTestEffect_PSAlphaTestLtGt[] =
0, 0, 0, 0, 255, 255,
124, 2, 0, 0, 0, 0,
255, 255, 136, 2, 0, 0,
91, 0, 0, 0, 148, 2,
0, 0, 93, 0, 0, 0,
164, 2, 0, 0, 91, 0,
87, 0, 0, 0, 148, 2,
0, 0, 89, 0, 0, 0,
164, 2, 0, 0, 87, 0,
0, 0, 184, 2, 0, 0,
93, 0, 0, 0, 200, 2,
0, 0, 93, 0, 0, 0,
220, 2, 0, 0, 20, 0,
89, 0, 0, 0, 200, 2,
0, 0, 89, 0, 0, 0,
220, 2, 0, 0, 18, 0,
1, 0, 228, 2, 0, 0,
20, 0, 1, 0, 248, 2,
0, 0, 20, 0, 1, 0,
18, 0, 1, 0, 248, 2,
0, 0, 18, 0, 1, 0,
12, 3, 0, 0, 80, 83,
65, 108, 112, 104, 97, 84,
101, 115, 116, 76, 116, 71,

Двоичный файл не отображается.

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

@ -39,7 +39,7 @@
dcl t1.xy // pin<4,5>
dcl_2d s0
#line 104 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 100 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
texld r0, t1, s0
mad r1.w, r0.w, t0.w, -c0.x
mul r0, r0, t0 // ::color<0,1,2,3>
@ -69,10 +69,10 @@ ret
const BYTE AlphaTestEffect_PSAlphaTestLtGtNoFog[] =
{
68, 88, 66, 67, 152, 76,
217, 138, 186, 94, 113, 46,
170, 245, 46, 36, 187, 253,
169, 200, 1, 0, 0, 0,
68, 88, 66, 67, 170, 255,
28, 65, 185, 81, 67, 189,
96, 124, 184, 113, 42, 100,
175, 111, 1, 0, 0, 0,
128, 4, 0, 0, 4, 0,
0, 0, 48, 0, 0, 0,
200, 2, 0, 0, 252, 3,
@ -110,14 +110,14 @@ const BYTE AlphaTestEffect_PSAlphaTestLtGtNoFog[] =
216, 1, 0, 0, 0, 0,
255, 255, 228, 1, 0, 0,
0, 0, 255, 255, 240, 1,
0, 0, 104, 0, 0, 0,
252, 1, 0, 0, 106, 0,
0, 0, 100, 0, 0, 0,
252, 1, 0, 0, 102, 0,
0, 0, 12, 2, 0, 0,
104, 0, 0, 0, 32, 2,
0, 0, 104, 0, 0, 0,
48, 2, 0, 0, 106, 0,
100, 0, 0, 0, 32, 2,
0, 0, 100, 0, 0, 0,
48, 2, 0, 0, 102, 0,
0, 0, 60, 2, 0, 0,
106, 0, 0, 0, 80, 2,
102, 0, 0, 0, 80, 2,
0, 0, 80, 83, 65, 108,
112, 104, 97, 84, 101, 115,
116, 76, 116, 71, 116, 78,

Двоичный файл не отображается.

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

@ -43,28 +43,28 @@
dcl_texcoord v0 // vin<0,1,2,3>
dcl_texcoord1 v1 // vin<4,5>
#line 43 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 41 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
dp4 oPos.z, v0, c5 // ::VSAlphaTest<12>
#line 14
#line 12
dp4 r0.x, v0, c2
max r0.x, r0.x, c7.x
min oT1.w, r0.x, c7.y // ::VSAlphaTest<7>
#line 43
#line 41
dp4 r0.x, v0, c3 // ::vout<0>
dp4 r0.y, v0, c4 // ::vout<1>
dp4 r0.z, v0, c6 // ::vout<3>
#line 31 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 27 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
mad oPos.xy, r0.z, c0, r0 // ::VSAlphaTest<10,11>
mov oPos.w, r0.z // ::VSAlphaTest<13>
#line 44 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 42 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
mov oT0, c1 // ::VSAlphaTest<0,1,2,3>
mov oT1.xyz, c7.x // ::VSAlphaTest<4,5,6>
#line 38 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 34 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
mov oT2.xy, v1 // ::VSAlphaTest<8,9>
// approximately 12 instruction slots used
@ -90,10 +90,10 @@ ret
const BYTE AlphaTestEffect_VSAlphaTest[] =
{
68, 88, 66, 67, 26, 63,
48, 3, 206, 77, 246, 54,
10, 156, 130, 234, 179, 96,
57, 180, 1, 0, 0, 0,
68, 88, 66, 67, 170, 156,
121, 135, 165, 39, 185, 129,
69, 71, 189, 172, 36, 194,
240, 89, 1, 0, 0, 0,
212, 6, 0, 0, 4, 0,
0, 0, 48, 0, 0, 0,
148, 4, 0, 0, 240, 5,
@ -142,22 +142,22 @@ const BYTE AlphaTestEffect_VSAlphaTest[] =
255, 255, 52, 3, 0, 0,
0, 0, 255, 255, 76, 3,
0, 0, 0, 0, 255, 255,
88, 3, 0, 0, 43, 0,
88, 3, 0, 0, 41, 0,
0, 0, 100, 3, 0, 0,
14, 0, 0, 0, 116, 3,
0, 0, 14, 0, 0, 0,
132, 3, 0, 0, 14, 0,
12, 0, 0, 0, 116, 3,
0, 0, 12, 0, 0, 0,
132, 3, 0, 0, 12, 0,
0, 0, 148, 3, 0, 0,
43, 0, 0, 0, 164, 3,
0, 0, 43, 0, 0, 0,
180, 3, 0, 0, 43, 0,
41, 0, 0, 0, 164, 3,
0, 0, 41, 0, 0, 0,
180, 3, 0, 0, 41, 0,
0, 0, 196, 3, 0, 0,
31, 0, 1, 0, 212, 3,
0, 0, 31, 0, 1, 0,
232, 3, 0, 0, 44, 0,
27, 0, 1, 0, 212, 3,
0, 0, 27, 0, 1, 0,
232, 3, 0, 0, 42, 0,
0, 0, 244, 3, 0, 0,
45, 0, 0, 0, 0, 4,
0, 0, 38, 0, 1, 0,
43, 0, 0, 0, 0, 4,
0, 0, 34, 0, 1, 0,
12, 4, 0, 0, 86, 83,
65, 108, 112, 104, 97, 84,
101, 115, 116, 0, 68, 105,

Двоичный файл не отображается.

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

@ -41,20 +41,20 @@
dcl_texcoord v0 // vin<0,1,2,3>
dcl_texcoord1 v1 // vin<4,5>
#line 43 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 41 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
dp4 oPos.z, v0, c4 // ::VSAlphaTestNoFog<8>
dp4 r0.x, v0, c2 // ::vout<0>
dp4 r0.y, v0, c3 // ::vout<1>
dp4 r0.z, v0, c5 // ::vout<3>
#line 45 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 41 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
mad oPos.xy, r0.z, c0, r0 // ::VSAlphaTestNoFog<6,7>
mov oPos.w, r0.z // ::VSAlphaTestNoFog<9>
#line 44 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 42 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
mov oT0, c1 // ::VSAlphaTestNoFog<0,1,2,3>
#line 52 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 48 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
mov oT1.xy, v1 // ::VSAlphaTestNoFog<4,5>
// approximately 8 instruction slots used
@ -77,10 +77,10 @@ ret
const BYTE AlphaTestEffect_VSAlphaTestNoFog[] =
{
68, 88, 66, 67, 226, 77,
141, 135, 14, 46, 51, 77,
20, 164, 113, 178, 130, 191,
10, 159, 1, 0, 0, 0,
68, 88, 66, 67, 72, 198,
27, 255, 77, 234, 218, 158,
207, 27, 93, 94, 98, 153,
22, 100, 1, 0, 0, 0,
224, 5, 0, 0, 4, 0,
0, 0, 48, 0, 0, 0,
4, 4, 0, 0, 20, 5,
@ -128,16 +128,16 @@ const BYTE AlphaTestEffect_VSAlphaTestNoFog[] =
92, 0, 0, 0, 0, 0,
255, 255, 248, 2, 0, 0,
0, 0, 255, 255, 4, 3,
0, 0, 43, 0, 0, 0,
16, 3, 0, 0, 43, 0,
0, 0, 41, 0, 0, 0,
16, 3, 0, 0, 41, 0,
0, 0, 32, 3, 0, 0,
43, 0, 0, 0, 48, 3,
0, 0, 43, 0, 0, 0,
64, 3, 0, 0, 45, 0,
41, 0, 0, 0, 48, 3,
0, 0, 41, 0, 0, 0,
64, 3, 0, 0, 41, 0,
1, 0, 80, 3, 0, 0,
45, 0, 1, 0, 100, 3,
0, 0, 44, 0, 0, 0,
112, 3, 0, 0, 52, 0,
41, 0, 1, 0, 100, 3,
0, 0, 42, 0, 0, 0,
112, 3, 0, 0, 48, 0,
1, 0, 124, 3, 0, 0,
86, 83, 65, 108, 112, 104,
97, 84, 101, 115, 116, 78,

Двоичный файл не отображается.

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

@ -45,30 +45,30 @@
dcl_texcoord1 v1 // vin<4,5>
dcl_texcoord2 v2 // vin<6,7,8,9>
#line 43 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 41 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
dp4 oPos.z, v0, c5 // ::VSAlphaTestVc<12>
#line 14
#line 12
dp4 r0.x, v0, c2
max r0.x, r0.x, c7.x
min oT1.w, r0.x, c7.y // ::VSAlphaTestVc<7>
#line 67 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 63 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
mul oT0, v2, c1 // ::VSAlphaTestVc<0,1,2,3>
#line 43 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 41 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
dp4 r0.x, v0, c3 // ::vout<0>
dp4 r0.y, v0, c4 // ::vout<1>
dp4 r0.z, v0, c6 // ::vout<3>
#line 59 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 55 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
mad oPos.xy, r0.z, c0, r0 // ::VSAlphaTestVc<10,11>
mov oPos.w, r0.z // ::VSAlphaTestVc<13>
#line 45 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 43 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
mov oT1.xyz, c7.x // ::VSAlphaTestVc<4,5,6>
#line 66 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 62 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
mov oT2.xy, v1 // ::VSAlphaTestVc<8,9>
// approximately 12 instruction slots used
@ -95,10 +95,10 @@ ret
const BYTE AlphaTestEffect_VSAlphaTestVc[] =
{
68, 88, 66, 67, 30, 69,
55, 65, 83, 79, 93, 185,
227, 96, 91, 140, 77, 44,
208, 255, 1, 0, 0, 0,
68, 88, 66, 67, 236, 163,
225, 145, 199, 203, 224, 231,
78, 157, 76, 71, 53, 217,
112, 45, 1, 0, 0, 0,
56, 7, 0, 0, 4, 0,
0, 0, 48, 0, 0, 0,
200, 4, 0, 0, 56, 6,
@ -149,21 +149,21 @@ const BYTE AlphaTestEffect_VSAlphaTestVc[] =
0, 0, 0, 0, 255, 255,
124, 3, 0, 0, 0, 0,
255, 255, 136, 3, 0, 0,
43, 0, 0, 0, 148, 3,
0, 0, 14, 0, 0, 0,
164, 3, 0, 0, 14, 0,
41, 0, 0, 0, 148, 3,
0, 0, 12, 0, 0, 0,
164, 3, 0, 0, 12, 0,
0, 0, 180, 3, 0, 0,
14, 0, 0, 0, 196, 3,
0, 0, 67, 0, 1, 0,
212, 3, 0, 0, 43, 0,
12, 0, 0, 0, 196, 3,
0, 0, 63, 0, 1, 0,
212, 3, 0, 0, 41, 0,
0, 0, 228, 3, 0, 0,
43, 0, 0, 0, 244, 3,
0, 0, 43, 0, 0, 0,
4, 4, 0, 0, 59, 0,
41, 0, 0, 0, 244, 3,
0, 0, 41, 0, 0, 0,
4, 4, 0, 0, 55, 0,
1, 0, 20, 4, 0, 0,
59, 0, 1, 0, 40, 4,
0, 0, 45, 0, 0, 0,
52, 4, 0, 0, 66, 0,
55, 0, 1, 0, 40, 4,
0, 0, 43, 0, 0, 0,
52, 4, 0, 0, 62, 0,
1, 0, 64, 4, 0, 0,
86, 83, 65, 108, 112, 104,
97, 84, 101, 115, 116, 86,

Двоичный файл не отображается.

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

@ -43,22 +43,22 @@
dcl_texcoord1 v1 // vin<4,5>
dcl_texcoord2 v2 // vin<6,7,8,9>
#line 43 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 41 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
dp4 oPos.z, v0, c4 // ::VSAlphaTestVcNoFog<8>
#line 82 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 78 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
mul oT0, v2, c1 // ::VSAlphaTestVcNoFog<0,1,2,3>
#line 43 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 41 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
dp4 r0.x, v0, c2 // ::vout<0>
dp4 r0.y, v0, c3 // ::vout<1>
dp4 r0.z, v0, c5 // ::vout<3>
#line 74 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
#line 70 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\AlphaTestEffect.fx"
mad oPos.xy, r0.z, c0, r0 // ::VSAlphaTestVcNoFog<6,7>
mov oPos.w, r0.z // ::VSAlphaTestVcNoFog<9>
#line 81
#line 77
mov oT1.xy, v1 // ::VSAlphaTestVcNoFog<4,5>
// approximately 8 instruction slots used
@ -82,10 +82,10 @@ ret
const BYTE AlphaTestEffect_VSAlphaTestVcNoFog[] =
{
68, 88, 66, 67, 106, 5,
49, 27, 249, 111, 188, 70,
158, 124, 69, 161, 111, 42,
252, 236, 1, 0, 0, 0,
68, 88, 66, 67, 107, 73,
29, 244, 176, 239, 177, 9,
182, 10, 121, 142, 20, 136,
157, 251, 1, 0, 0, 0,
64, 6, 0, 0, 4, 0,
0, 0, 48, 0, 0, 0,
52, 4, 0, 0, 88, 5,
@ -134,17 +134,17 @@ const BYTE AlphaTestEffect_VSAlphaTestVcNoFog[] =
255, 255, 24, 3, 0, 0,
0, 0, 255, 255, 36, 3,
0, 0, 0, 0, 255, 255,
48, 3, 0, 0, 43, 0,
48, 3, 0, 0, 41, 0,
0, 0, 60, 3, 0, 0,
82, 0, 1, 0, 76, 3,
0, 0, 43, 0, 0, 0,
92, 3, 0, 0, 43, 0,
78, 0, 1, 0, 76, 3,
0, 0, 41, 0, 0, 0,
92, 3, 0, 0, 41, 0,
0, 0, 108, 3, 0, 0,
43, 0, 0, 0, 124, 3,
0, 0, 74, 0, 1, 0,
140, 3, 0, 0, 74, 0,
41, 0, 0, 0, 124, 3,
0, 0, 70, 0, 1, 0,
140, 3, 0, 0, 70, 0,
1, 0, 160, 3, 0, 0,
81, 0, 1, 0, 172, 3,
77, 0, 1, 0, 172, 3,
0, 0, 86, 83, 65, 108,
112, 104, 97, 84, 101, 115,
116, 86, 99, 78, 111, 70,

Двоичный файл не отображается.

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

@ -31,7 +31,7 @@
dcl t0 // pin<0,1,2,3>
dcl t1 // pin<4,5,6,7>
#line 20 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
#line 18 "D:\ATG\st_dev\Kits\DirectXTK\Src\Shaders\Common.fxh"
mad r0.xyz, c0, t0.w, -t0
mov r1.xyz, t0 // pin<0,1,2>
mad r0.xyz, t1.w, r0, r1 // ApplyFog::color<0,1,2>
@ -54,10 +54,10 @@ ret
const BYTE BasicEffect_PSBasic[] =
{
68, 88, 66, 67, 69, 188,
57, 72, 167, 28, 156, 175,
162, 21, 90, 51, 132, 77,
151, 156, 1, 0, 0, 0,
68, 88, 66, 67, 67, 11,
97, 9, 94, 188, 60, 134,
230, 6, 143, 129, 176, 112,
108, 135, 1, 0, 0, 0,
180, 3, 0, 0, 4, 0,
0, 0, 48, 0, 0, 0,
132, 2, 0, 0, 56, 3,
@ -92,12 +92,12 @@ const BYTE BasicEffect_PSBasic[] =
0, 0, 0, 0, 255, 255,
180, 1, 0, 0, 0, 0,
255, 255, 192, 1, 0, 0,
20, 0, 0, 0, 204, 1,
0, 0, 20, 0, 0, 0,
224, 1, 0, 0, 20, 0,
18, 0, 0, 0, 204, 1,
0, 0, 18, 0, 0, 0,
224, 1, 0, 0, 18, 0,
0, 0, 236, 1, 0, 0,
20, 0, 0, 0, 0, 2,
0, 0, 20, 0, 0, 0,
18, 0, 0, 0, 0, 2,
0, 0, 18, 0, 0, 0,
12, 2, 0, 0, 80, 83,
66, 97, 115, 105, 99, 0,
1, 0, 3, 0, 1, 0,

Двоичный файл не отображается.

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше