diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5921cee34c56b1b8d791b9366c01489d01d325f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +*.psess +*.aps +*.vsp +*.log +*.err +*.wrn +*.suo +*.sdf +*.user +*.i +*.vspscc +*.opensdf +*.opendb +*.ipch +*.cache +*.tlog +*.lastbuildstate +*.ilk +ARM +"Generated Files" +Bin +ipch +Debug +Profile +Release +x64 +/wiki diff --git a/Kits/DirectXTK/Audio/AudioEngine.cpp b/Kits/DirectXTK/Audio/AudioEngine.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f26e2a6abb674c6d64aa59ed9856c787480278a7 --- /dev/null +++ b/Kits/DirectXTK/Audio/AudioEngine.cpp @@ -0,0 +1,1735 @@ +//-------------------------------------------------------------------------------------- +// File: AudioEngine.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Audio.h" +#include "SoundCommon.h" + +#include +#include + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + +//#define VERBOSE_TRACE + + +namespace +{ + struct EngineCallback : public IXAudio2EngineCallback + { + EngineCallback() + { +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + mCriticalError.reset( CreateEventEx( nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE ) ); +#else + mCriticalError.reset( CreateEvent( nullptr, FALSE, FALSE, nullptr ) ); +#endif + if ( !mCriticalError ) + { + throw std::exception( "CreateEvent" ); + } + }; + + virtual ~EngineCallback() + { + } + + STDMETHOD_(void, OnProcessingPassStart) () override {} + STDMETHOD_(void, OnProcessingPassEnd)() override {} + + STDMETHOD_(void, OnCriticalError) (THIS_ HRESULT error) + { +#ifndef _DEBUG + UNREFERENCED_PARAMETER(error); +#endif + DebugTrace( "ERROR: AudioEngine encountered critical error (%08X)\n", error ); + SetEvent( mCriticalError.get() ); + } + + ScopedHandle mCriticalError; + }; + + struct VoiceCallback : public IXAudio2VoiceCallback + { + VoiceCallback() + { +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + mBufferEnd.reset( CreateEventEx( nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE ) ); +#else + mBufferEnd.reset( CreateEvent( nullptr, FALSE, FALSE, nullptr ) ); +#endif + if ( !mBufferEnd ) + { + throw std::exception( "CreateEvent" ); + } + } + + virtual ~VoiceCallback() + { + } + + STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT32) override {} + STDMETHOD_(void, OnVoiceProcessingPassEnd)() override {} + STDMETHOD_(void, OnStreamEnd)() override {} + STDMETHOD_(void, OnBufferStart)( void* ) override {} + + STDMETHOD_(void, OnBufferEnd)( void* context ) override + { + if ( context ) + { + auto inotify = reinterpret_cast( context ); + inotify->OnBufferEnd(); + SetEvent( mBufferEnd.get() ); + } + } + + STDMETHOD_(void, OnLoopEnd)( void* ) override {} + STDMETHOD_(void, OnVoiceError)( void*, HRESULT ) override {} + + ScopedHandle mBufferEnd; + }; + + static const XAUDIO2FX_REVERB_I3DL2_PARAMETERS gReverbPresets[] = + { + XAUDIO2FX_I3DL2_PRESET_DEFAULT, // Reverb_Off + XAUDIO2FX_I3DL2_PRESET_DEFAULT, // Reverb_Default + XAUDIO2FX_I3DL2_PRESET_GENERIC, // Reverb_Generic + XAUDIO2FX_I3DL2_PRESET_FOREST, // Reverb_Forest + XAUDIO2FX_I3DL2_PRESET_PADDEDCELL, // Reverb_PaddedCell + XAUDIO2FX_I3DL2_PRESET_ROOM, // Reverb_Room + XAUDIO2FX_I3DL2_PRESET_BATHROOM, // Reverb_Bathroom + XAUDIO2FX_I3DL2_PRESET_LIVINGROOM, // Reverb_LivingRoom + XAUDIO2FX_I3DL2_PRESET_STONEROOM, // Reverb_StoneRoom + XAUDIO2FX_I3DL2_PRESET_AUDITORIUM, // Reverb_Auditorium + XAUDIO2FX_I3DL2_PRESET_CONCERTHALL, // Reverb_ConcertHall + XAUDIO2FX_I3DL2_PRESET_CAVE, // Reverb_Cave + XAUDIO2FX_I3DL2_PRESET_ARENA, // Reverb_Arena + XAUDIO2FX_I3DL2_PRESET_HANGAR, // Reverb_Hangar + XAUDIO2FX_I3DL2_PRESET_CARPETEDHALLWAY, // Reverb_CarpetedHallway + XAUDIO2FX_I3DL2_PRESET_HALLWAY, // Reverb_Hallway + XAUDIO2FX_I3DL2_PRESET_STONECORRIDOR, // Reverb_StoneCorridor + XAUDIO2FX_I3DL2_PRESET_ALLEY, // Reverb_Alley + XAUDIO2FX_I3DL2_PRESET_CITY, // Reverb_City + XAUDIO2FX_I3DL2_PRESET_MOUNTAINS, // Reverb_Mountains + XAUDIO2FX_I3DL2_PRESET_QUARRY, // Reverb_Quarry + XAUDIO2FX_I3DL2_PRESET_PLAIN, // Reverb_Plain + XAUDIO2FX_I3DL2_PRESET_PARKINGLOT, // Reverb_ParkingLot + XAUDIO2FX_I3DL2_PRESET_SEWERPIPE, // Reverb_SewerPipe + XAUDIO2FX_I3DL2_PRESET_UNDERWATER, // Reverb_Underwater + XAUDIO2FX_I3DL2_PRESET_SMALLROOM, // Reverb_SmallRoom + XAUDIO2FX_I3DL2_PRESET_MEDIUMROOM, // Reverb_MediumRoom + XAUDIO2FX_I3DL2_PRESET_LARGEROOM, // Reverb_LargeRoom + XAUDIO2FX_I3DL2_PRESET_MEDIUMHALL, // Reverb_MediumHall + XAUDIO2FX_I3DL2_PRESET_LARGEHALL, // Reverb_LargeHall + XAUDIO2FX_I3DL2_PRESET_PLATE, // Reverb_Plate + }; + + inline unsigned int makeVoiceKey( _In_ const WAVEFORMATEX* wfx ) + { + assert( IsValid(wfx) ); + + if ( wfx->nChannels > 0x7F ) + return 0; + + union KeyGen + { + struct + { + unsigned int tag : 9; + unsigned int channels : 7; + unsigned int bitsPerSample : 8; + } pcm; + + struct + { + unsigned int tag : 9; + unsigned int channels : 7; + unsigned int samplesPerBlock : 16; + } adpcm; + +#if defined(_XBOX_ONE) && defined(_TITLE) + struct + { + unsigned int tag : 9; + unsigned int channels : 7; + unsigned int encoderVersion : 8; + } xma; +#endif + + unsigned int key; + } result; + + static_assert( sizeof(KeyGen) == sizeof(unsigned int), "KeyGen is invalid" ); + + result.key = 0; + + if ( wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE ) + { + // We reuse EXTENSIBLE only if it is equivalent to the standard form + auto wfex = reinterpret_cast( wfx ); + if ( wfex->Samples.wValidBitsPerSample != 0 && wfex->Samples.wValidBitsPerSample != wfx->wBitsPerSample ) + return 0; + + if ( wfex->dwChannelMask != 0 && wfex->dwChannelMask != GetDefaultChannelMask( wfx->nChannels ) ) + return 0; + } + + uint32_t tag = GetFormatTag( wfx ); + switch( tag ) + { + case WAVE_FORMAT_PCM: + static_assert( WAVE_FORMAT_PCM < 0x1ff, "KeyGen tag is too small" ); + result.pcm.tag = WAVE_FORMAT_PCM; + result.pcm.channels = wfx->nChannels; + result.pcm.bitsPerSample = wfx->wBitsPerSample; + break; + + case WAVE_FORMAT_IEEE_FLOAT: + static_assert( WAVE_FORMAT_IEEE_FLOAT < 0x1ff, "KeyGen tag is too small" ); + + if ( wfx->wBitsPerSample != 32 ) + return 0; + + result.pcm.tag = WAVE_FORMAT_IEEE_FLOAT; + result.pcm.channels = wfx->nChannels; + result.pcm.bitsPerSample = 32; + break; + + case WAVE_FORMAT_ADPCM: + static_assert( WAVE_FORMAT_ADPCM < 0x1ff, "KeyGen tag is too small" ); + result.adpcm.tag = WAVE_FORMAT_ADPCM; + result.adpcm.channels = wfx->nChannels; + + { + auto wfadpcm = reinterpret_cast( wfx ); + result.adpcm.samplesPerBlock = wfadpcm->wSamplesPerBlock; + } + break; + +#if defined(_XBOX_ONE) && defined(_TITLE) + case WAVE_FORMAT_XMA2: + static_assert( WAVE_FORMAT_XMA2 < 0x1ff, "KeyGen tag is too small" ); + result.xma.tag = WAVE_FORMAT_XMA2; + result.xma.channels = wfx->nChannels; + + { + auto xmaFmt = reinterpret_cast( wfx ); + + if ( ( xmaFmt->LoopBegin > 0 ) + || ( xmaFmt->PlayBegin > 0 ) ) + return 0; + + result.xma.encoderVersion = xmaFmt->EncoderVersion; + } + break; +#endif + + default: + return 0; + } + + return result.key; + } +} + +static_assert( _countof(gReverbPresets) == Reverb_MAX, "AUDIO_ENGINE_REVERB enum mismatch" ); + + +//====================================================================================== +// AudioEngine +//====================================================================================== + +#define SAFE_DESTROY_VOICE(voice) if ( voice ) { voice->DestroyVoice(); voice = nullptr; } + +// Internal object implementation class. +class AudioEngine::Impl +{ +public: + Impl() : + mMasterVoice( nullptr ), + mReverbVoice( nullptr ), + masterChannelMask( 0 ), + masterChannels( 0 ), + masterRate( 0 ), + defaultRate( 44100 ), + maxVoiceOneshots( SIZE_MAX ), + maxVoiceInstances( SIZE_MAX ), + mMasterVolume( 1.f ), + mCriticalError( false ), + mReverbEnabled( false ), + mEngineFlags( AudioEngine_Default ), + mCategory( AudioCategory_GameEffects ), + mVoiceInstances( 0 ) +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + ,mDLL(nullptr) +#endif + { + memset( &mX3DAudio, 0, X3DAUDIO_HANDLE_BYTESIZE ); + }; + +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + ~Impl() + { + if (mDLL) + { + FreeLibrary(mDLL); + mDLL = nullptr; + } + } +#endif + + HRESULT Initialize( AUDIO_ENGINE_FLAGS flags, _In_opt_ const WAVEFORMATEX* wfx, _In_opt_z_ const wchar_t* deviceId, AUDIO_STREAM_CATEGORY category ); + + HRESULT Reset( _In_opt_ const WAVEFORMATEX* wfx, _In_opt_z_ const wchar_t* deviceId ); + + void SetSilentMode(); + + void Shutdown(); + + bool Update(); + + void SetReverb( _In_opt_ const XAUDIO2FX_REVERB_PARAMETERS* native ); + + void SetMasteringLimit( int release, int loudness ); + + AudioStatistics GetStatistics() const; + + void TrimVoicePool(); + + void AllocateVoice( _In_ const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags, bool oneshot, _Outptr_result_maybenull_ IXAudio2SourceVoice** voice ); + void DestroyVoice( _In_ IXAudio2SourceVoice* voice ); + + void RegisterNotify( _In_ IVoiceNotify* notify, bool usesUpdate ); + void UnregisterNotify( _In_ IVoiceNotify* notify, bool oneshots, bool usesUpdate ); + + ComPtr xaudio2; + IXAudio2MasteringVoice* mMasterVoice; + IXAudio2SubmixVoice* mReverbVoice; + + uint32_t masterChannelMask; + uint32_t masterChannels; + uint32_t masterRate; + + int defaultRate; + size_t maxVoiceOneshots; + size_t maxVoiceInstances; + float mMasterVolume; + + X3DAUDIO_HANDLE mX3DAudio; + + bool mCriticalError; + bool mReverbEnabled; + + AUDIO_ENGINE_FLAGS mEngineFlags; + +private: + typedef std::set notifylist_t; + typedef std::list> oneshotlist_t; + typedef std::unordered_multimap voicepool_t; + + AUDIO_STREAM_CATEGORY mCategory; + ComPtr mReverbEffect; + ComPtr mVolumeLimiter; + oneshotlist_t mOneShots; + voicepool_t mVoicePool; + notifylist_t mNotifyObjects; + notifylist_t mNotifyUpdates; + size_t mVoiceInstances; + VoiceCallback mVoiceCallback; + EngineCallback mEngineCallback; + +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + HMODULE mDLL; +#endif +}; + + +_Use_decl_annotations_ +HRESULT AudioEngine::Impl::Initialize( AUDIO_ENGINE_FLAGS flags, const WAVEFORMATEX* wfx, const wchar_t* deviceId, AUDIO_STREAM_CATEGORY category ) +{ + mEngineFlags = flags; + mCategory = category; + + return Reset( wfx, deviceId ); +} + + +_Use_decl_annotations_ +HRESULT AudioEngine::Impl::Reset( const WAVEFORMATEX* wfx, const wchar_t* deviceId ) +{ + if ( wfx ) + { + if ( wfx->wFormatTag != WAVE_FORMAT_PCM ) + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + + if ( !wfx->nChannels || wfx->nChannels > XAUDIO2_MAX_AUDIO_CHANNELS ) + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + + if ( wfx->nSamplesPerSec < XAUDIO2_MIN_SAMPLE_RATE || wfx->nSamplesPerSec > XAUDIO2_MAX_SAMPLE_RATE ) + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + + // We don't use other data members of WAVEFORMATEX here to describe the device format, so no need to fully validate + } + + assert( !xaudio2 ); + assert( !mMasterVoice ); + assert( !mReverbVoice ); + + masterChannelMask = masterChannels = masterRate = 0; + + memset( &mX3DAudio, 0, X3DAUDIO_HANDLE_BYTESIZE ); + + mCriticalError = false; + mReverbEnabled = false; + + // + // Create XAudio2 engine + // + UINT32 eflags = 0; +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + if ( mEngineFlags & AudioEngine_Debug ) + { + if ( !mDLL ) + { + mDLL = LoadLibraryEx( L"XAudioD2_7.DLL", nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ ); + if ( !mDLL ) + { + DebugTrace( "ERROR: XAudio 2.7 debug version not installed on system (install the DirectX SDK Developer Runtime)\n" ); + return HRESULT_FROM_WIN32( ERROR_NOT_FOUND ); + } + } + + eflags |= XAUDIO2_DEBUG_ENGINE; + } + else if ( !mDLL ) + { + mDLL = LoadLibraryEx( L"XAudio2_7.DLL", nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ ); + if ( !mDLL ) + { + DebugTrace( "ERROR: XAudio 2.7 not installed on system (install the DirectX End-user Runtimes (June 2010))\n" ); + return HRESULT_FROM_WIN32( ERROR_NOT_FOUND ); + } + } +#endif + + HRESULT hr = XAudio2Create( xaudio2.ReleaseAndGetAddressOf(), eflags ); + if( FAILED( hr ) ) + { +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + DebugTrace( "ERROR: XAudio 2.7 not found (have you called CoInitialize?)\n" ); +#endif + return hr; + } + + if ( mEngineFlags & AudioEngine_Debug ) + { + XAUDIO2_DEBUG_CONFIGURATION debug ={0}; + debug.TraceMask = XAUDIO2_LOG_ERRORS | XAUDIO2_LOG_WARNINGS; + debug.BreakMask = XAUDIO2_LOG_ERRORS; + xaudio2->SetDebugConfiguration( &debug, nullptr ); +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) || defined(_XBOX_ONE) + DebugTrace("INFO: XAudio 2.9 debugging enabled\n"); +#elif (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + // To see the trace output, you need to view ETW logs for this application: + // Go to Control Panel, Administrative Tools, Event Viewer. + // View->Show Analytic and Debug Logs. + // Applications and Services Logs / Microsoft / Windows / XAudio2. + // Right click on Microsoft Windows XAudio2 debug logging, Properties, then Enable Logging, and hit OK + DebugTrace( "INFO: XAudio 2.8 debugging enabled\n" ); +#else + // To see the trace output, see the debug output channel window + DebugTrace( "INFO: XAudio 2.7 debugging enabled\n" ); +#endif + } + + if ( mEngineFlags & AudioEngine_DisableVoiceReuse ) + { + DebugTrace( "INFO: Voice reuse is disabled\n" ); + } + + hr = xaudio2->RegisterForCallbacks( &mEngineCallback ); + if ( FAILED(hr) ) + { + xaudio2.Reset(); + return hr; + } + + // + // Create mastering voice for device + // + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + + hr = xaudio2->CreateMasteringVoice( &mMasterVoice, + (wfx) ? wfx->nChannels : XAUDIO2_DEFAULT_CHANNELS, + (wfx) ? wfx->nSamplesPerSec : XAUDIO2_DEFAULT_SAMPLERATE, + 0, deviceId, nullptr, mCategory ); + if ( FAILED(hr) ) + { + xaudio2.Reset(); + return hr; + } + + DWORD dwChannelMask; + hr = mMasterVoice->GetChannelMask( &dwChannelMask ); + if ( FAILED(hr) ) + { + SAFE_DESTROY_VOICE( mMasterVoice ); + xaudio2.Reset(); + return hr; + } + + XAUDIO2_VOICE_DETAILS details; + mMasterVoice->GetVoiceDetails( &details ); + + masterChannelMask = dwChannelMask; + masterChannels = details.InputChannels; + masterRate = details.InputSampleRate; + +#else + + UINT32 count = 0; + hr = xaudio2->GetDeviceCount( &count ); + if ( FAILED(hr) ) + { + xaudio2.Reset(); + return hr; + } + + if ( !count ) + { + xaudio2.Reset(); + return HRESULT_FROM_WIN32( ERROR_NOT_FOUND ); + } + + UINT32 devIndex = 0; + if ( deviceId ) + { + // Translate device ID back into device index + devIndex = UINT32(-1); + for( UINT32 j = 0; j < count; ++j ) + { + XAUDIO2_DEVICE_DETAILS details; + hr = xaudio2->GetDeviceDetails( j, &details ); + if ( SUCCEEDED(hr) ) + { + if ( wcsncmp( deviceId, details.DeviceID, 256 ) == 0 ) + { + devIndex = j; + masterChannelMask = details.OutputFormat.dwChannelMask; + break; + } + } + } + + if ( devIndex == UINT32(-1) ) + { + xaudio2.Reset(); + return HRESULT_FROM_WIN32( ERROR_NOT_FOUND ); + } + } + else + { + // No search needed + XAUDIO2_DEVICE_DETAILS details; + hr = xaudio2->GetDeviceDetails( 0, &details ); + if ( FAILED(hr) ) + { + xaudio2.Reset(); + return hr; + } + + masterChannelMask = details.OutputFormat.dwChannelMask; + } + + hr = xaudio2->CreateMasteringVoice( &mMasterVoice, + (wfx) ? wfx->nChannels : XAUDIO2_DEFAULT_CHANNELS, + (wfx) ? wfx->nSamplesPerSec : XAUDIO2_DEFAULT_SAMPLERATE, + 0, devIndex, nullptr ); + if ( FAILED(hr) ) + { + xaudio2.Reset(); + return hr; + } + + XAUDIO2_VOICE_DETAILS details; + mMasterVoice->GetVoiceDetails( &details ); + + masterChannels = details.InputChannels; + masterRate = details.InputSampleRate; + +#endif + + DebugTrace( "INFO: mastering voice has %u channels, %u sample rate, %08X channel mask\n", masterChannels, masterRate, masterChannelMask ); + + if ( mMasterVolume != 1.f ) + { + hr = mMasterVoice->SetVolume( mMasterVolume ); + if ( FAILED(hr) ) + { + SAFE_DESTROY_VOICE( mMasterVoice ); + xaudio2.Reset(); + return hr; + } + } + + // + // Setup mastering volume limiter (optional) + // + if ( mEngineFlags & AudioEngine_UseMasteringLimiter ) + { + FXMASTERINGLIMITER_PARAMETERS params = {0}; + params.Release = FXMASTERINGLIMITER_DEFAULT_RELEASE; + params.Loudness = FXMASTERINGLIMITER_DEFAULT_LOUDNESS; + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + hr = CreateFX( __uuidof(FXMasteringLimiter), mVolumeLimiter.ReleaseAndGetAddressOf(), ¶ms, sizeof(params) ); +#else + hr = CreateFX( __uuidof(FXMasteringLimiter), mVolumeLimiter.ReleaseAndGetAddressOf() ); +#endif + if ( FAILED(hr) ) + { + SAFE_DESTROY_VOICE( mMasterVoice ); + xaudio2.Reset(); + return hr; + } + + XAUDIO2_EFFECT_DESCRIPTOR desc = {0}; + desc.InitialState = TRUE; + desc.OutputChannels = masterChannels; + desc.pEffect = mVolumeLimiter.Get(); + + XAUDIO2_EFFECT_CHAIN chain = { 1, &desc }; + hr = mMasterVoice->SetEffectChain( &chain ); + if ( FAILED(hr) ) + { + SAFE_DESTROY_VOICE( mMasterVoice ); + mVolumeLimiter.Reset(); + xaudio2.Reset(); + return hr; + } + +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + hr = mMasterVoice->SetEffectParameters( 0, ¶ms, sizeof(params) ); + if ( FAILED(hr) ) + { + SAFE_DESTROY_VOICE( mMasterVoice ); + mVolumeLimiter.Reset(); + xaudio2.Reset(); + return hr; + } +#endif + + DebugTrace( "INFO: Mastering volume limiter enabled\n" ); + } + + // + // Setup environmental reverb for 3D audio (optional) + // + if ( mEngineFlags & AudioEngine_EnvironmentalReverb ) + { + UINT32 rflags = 0; +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + if ( mEngineFlags & AudioEngine_Debug ) + { + rflags |= XAUDIO2FX_DEBUG; + } +#endif + hr = XAudio2CreateReverb( mReverbEffect.ReleaseAndGetAddressOf(), rflags ); + if ( FAILED(hr) ) + { + SAFE_DESTROY_VOICE( mMasterVoice ); + mVolumeLimiter.Reset(); + xaudio2.Reset(); + return hr; + } + + XAUDIO2_EFFECT_DESCRIPTOR effects[] = { { mReverbEffect.Get(), TRUE, 1 } }; + XAUDIO2_EFFECT_CHAIN effectChain = { 1, effects }; + + mReverbEnabled = true; + + hr = xaudio2->CreateSubmixVoice( &mReverbVoice, 1, masterRate, + (mEngineFlags & AudioEngine_ReverbUseFilters ) ? XAUDIO2_VOICE_USEFILTER : 0, 0, + nullptr, &effectChain ); + if ( FAILED(hr) ) + { + SAFE_DESTROY_VOICE( mMasterVoice ); + mReverbEffect.Reset(); + mVolumeLimiter.Reset(); + xaudio2.Reset(); + return hr; + } + + XAUDIO2FX_REVERB_PARAMETERS native; + ReverbConvertI3DL2ToNative( &gReverbPresets[ Reverb_Default ], &native ); + hr = mReverbVoice->SetEffectParameters( 0, &native, sizeof( XAUDIO2FX_REVERB_PARAMETERS ) ); + if ( FAILED(hr) ) + { + SAFE_DESTROY_VOICE( mReverbVoice ); + SAFE_DESTROY_VOICE( mMasterVoice ); + mReverbEffect.Reset(); + mVolumeLimiter.Reset(); + xaudio2.Reset(); + return hr; + } + + DebugTrace( "INFO: I3DL2 reverb effect enabled for 3D positional audio\n" ); + } + + // + // Setup 3D audio + // + const float SPEEDOFSOUND = X3DAUDIO_SPEED_OF_SOUND; + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + hr = X3DAudioInitialize( masterChannelMask, SPEEDOFSOUND, mX3DAudio ); + if ( FAILED(hr) ) + { + SAFE_DESTROY_VOICE( mReverbVoice ); + SAFE_DESTROY_VOICE( mMasterVoice ); + mReverbEffect.Reset(); + mVolumeLimiter.Reset(); + xaudio2.Reset(); + return hr; + } +#else + X3DAudioInitialize( masterChannelMask, SPEEDOFSOUND, mX3DAudio ); +#endif + + // + // Inform any notify objects we are ready to go again + // + for( auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it ) + { + assert( *it != 0 ); + (*it)->OnReset(); + } + + return S_OK; +} + + +void AudioEngine::Impl::SetSilentMode() +{ + for( auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it ) + { + assert( *it != 0 ); + (*it)->OnCriticalError(); + } + + for( auto it = mOneShots.begin(); it != mOneShots.end(); ++it ) + { + assert( it->second != 0 ); + it->second->DestroyVoice(); + } + mOneShots.clear(); + + for( auto it = mVoicePool.begin(); it != mVoicePool.end(); ++it ) + { + assert( it->second != 0 ); + it->second->DestroyVoice(); + } + mVoicePool.clear(); + + mVoiceInstances = 0; + + SAFE_DESTROY_VOICE( mReverbVoice ); + SAFE_DESTROY_VOICE( mMasterVoice ); + + mReverbEffect.Reset(); + mVolumeLimiter.Reset(); + xaudio2.Reset(); +} + + +void AudioEngine::Impl::Shutdown() +{ + for( auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it ) + { + assert( *it != 0 ); + (*it)->OnDestroyEngine(); + } + + if ( xaudio2 ) + { + xaudio2->UnregisterForCallbacks( &mEngineCallback ); + + xaudio2->StopEngine(); + + for( auto it = mOneShots.begin(); it != mOneShots.end(); ++it ) + { + assert( it->second != 0 ); + it->second->DestroyVoice(); + } + mOneShots.clear(); + + for( auto it = mVoicePool.begin(); it != mVoicePool.end(); ++it ) + { + assert( it->second != 0 ); + it->second->DestroyVoice(); + } + mVoicePool.clear(); + + mVoiceInstances = 0; + + SAFE_DESTROY_VOICE( mReverbVoice ); + SAFE_DESTROY_VOICE( mMasterVoice ); + + mReverbEffect.Reset(); + mVolumeLimiter.Reset(); + xaudio2.Reset(); + + masterChannelMask = masterChannels = masterRate = 0; + + mCriticalError = false; + mReverbEnabled = false; + + memset( &mX3DAudio, 0, X3DAUDIO_HANDLE_BYTESIZE ); + } +} + + +bool AudioEngine::Impl::Update() +{ + if ( !xaudio2 ) + return false; + + HANDLE events[2] = { mEngineCallback.mCriticalError.get(), mVoiceCallback.mBufferEnd.get() }; + DWORD result = WaitForMultipleObjectsEx( 2, events, FALSE, 0, FALSE ); + switch( result ) + { + case WAIT_TIMEOUT: + break; + + case WAIT_OBJECT_0: // OnCritialError + mCriticalError = true; + + SetSilentMode(); + return false; + + case WAIT_OBJECT_0 + 1: // OnBufferEnd + // Scan for completed one-shot voices + for( auto it = mOneShots.begin(); it != mOneShots.end(); ) + { + assert( it->second != 0 ); + + XAUDIO2_VOICE_STATE xstate; +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + it->second->GetState( &xstate, XAUDIO2_VOICE_NOSAMPLESPLAYED ); +#else + it->second->GetState( &xstate ); +#endif + + if ( !xstate.BuffersQueued ) + { + it->second->Stop( 0 ); + if ( it->first ) + { + // Put voice back into voice pool for reuse since it has a non-zero voiceKey +#ifdef VERBOSE_TRACE + DebugTrace( "INFO: One-shot voice being saved for reuse (%08X)\n", it->first ); +#endif + voicepool_t::value_type v( it->first, it->second ); + mVoicePool.emplace( v ); + } + else + { + // Voice is to be destroyed rather than reused +#ifdef VERBOSE_TRACE + DebugTrace( "INFO: Destroying one-shot voice\n" ); +#endif + it->second->DestroyVoice(); + } + it = mOneShots.erase( it ); + } + else + ++it; + } + break; + + case WAIT_FAILED: + throw std::exception( "WaitForMultipleObjects" ); + } + + // + // Inform any notify objects of updates + // + for( auto it = mNotifyUpdates.begin(); it != mNotifyUpdates.end(); ++it ) + { + assert( *it != 0 ); + (*it)->OnUpdate(); + } + + return true; +} + + +_Use_decl_annotations_ +void AudioEngine::Impl::SetReverb( const XAUDIO2FX_REVERB_PARAMETERS* native ) +{ + if ( !mReverbVoice ) + return; + + if ( native ) + { + if ( !mReverbEnabled ) + { + mReverbEnabled = true; + mReverbVoice->EnableEffect( 0 ); + } + + mReverbVoice->SetEffectParameters( 0, native, sizeof( XAUDIO2FX_REVERB_PARAMETERS ) ); + } + else if ( mReverbEnabled ) + { + mReverbEnabled = false; + mReverbVoice->DisableEffect( 0 ); + } +} + + +void AudioEngine::Impl::SetMasteringLimit( int release, int loudness ) +{ + if ( !mVolumeLimiter || !mMasterVoice ) + return; + + if ( ( release < FXMASTERINGLIMITER_MIN_RELEASE ) || ( release > FXMASTERINGLIMITER_MAX_RELEASE ) ) + throw std::out_of_range( "AudioEngine::SetMasteringLimit" ); + + if ( ( loudness < FXMASTERINGLIMITER_MIN_LOUDNESS ) || ( loudness > FXMASTERINGLIMITER_MAX_LOUDNESS ) ) + throw std::out_of_range( "AudioEngine::SetMasteringLimit" ); + + FXMASTERINGLIMITER_PARAMETERS params = {0}; + params.Release = static_cast( release ); + params.Loudness = static_cast( loudness ); + + HRESULT hr = mMasterVoice->SetEffectParameters( 0, ¶ms, sizeof(params) ); + ThrowIfFailed( hr ); +} + + +AudioStatistics AudioEngine::Impl::GetStatistics() const +{ + AudioStatistics stats; + memset( &stats, 0, sizeof(stats) ); + + stats.allocatedVoices = stats.allocatedVoicesOneShot = mOneShots.size() + mVoicePool.size(); + stats.allocatedVoicesIdle = mVoicePool.size(); + + for( auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it ) + { + assert( *it != 0 ); + (*it)->GatherStatistics( stats ); + } + + assert( stats.allocatedVoices == ( mOneShots.size() + mVoicePool.size() + mVoiceInstances ) ); + + return stats; +} + + +void AudioEngine::Impl::TrimVoicePool() +{ + for( auto it = mNotifyObjects.begin(); it != mNotifyObjects.end(); ++it ) + { + assert( *it != 0 ); + (*it)->OnTrim(); + } + + for( auto it = mVoicePool.begin(); it != mVoicePool.end(); ++it ) + { + assert( it->second != 0 ); + it->second->DestroyVoice(); + } + mVoicePool.clear(); +} + + +_Use_decl_annotations_ +void AudioEngine::Impl::AllocateVoice( const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags, bool oneshot, IXAudio2SourceVoice** voice ) +{ + if ( !wfx ) + throw std::exception( "Wave format is required\n" ); + + // No need to call IsValid on wfx because CreateSourceVoice will do that + + if ( !voice ) + throw std::exception("Voice pointer must be non-null"); + + *voice = nullptr; + + if ( !xaudio2 || mCriticalError ) + return; + +#ifndef NDEBUG + float maxFrequencyRatio = XAudio2SemitonesToFrequencyRatio(12); + assert( maxFrequencyRatio <= XAUDIO2_DEFAULT_FREQ_RATIO ); +#endif + + unsigned int voiceKey = 0; + if ( oneshot ) + { + if ( flags & ( SoundEffectInstance_Use3D | SoundEffectInstance_ReverbUseFilters | SoundEffectInstance_NoSetPitch ) ) + { + DebugTrace( ( flags & SoundEffectInstance_NoSetPitch ) + ? "ERROR: One-shot voices must support pitch-shifting for voice reuse\n" + : "ERROR: One-use voices cannot use 3D positional audio\n" ); + throw std::exception( "Invalid flags for one-shot voice" ); + } + +#ifdef VERBOSE_TRACE + if ( wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE ) + { + DebugTrace( "INFO: Requesting one-shot: Format Tag EXTENSIBLE %u, %u channels, %u-bit, %u blkalign, %u Hz\n", GetFormatTag( wfx ), + wfx->nChannels, wfx->wBitsPerSample, wfx->nBlockAlign, wfx->nSamplesPerSec ); + } + else + { + DebugTrace( "INFO: Requesting one-shot: Format Tag %u, %u channels, %u-bit, %u blkalign, %u Hz\n", wfx->wFormatTag, + wfx->nChannels, wfx->wBitsPerSample, wfx->nBlockAlign, wfx->nSamplesPerSec ); + } +#endif + + if ( !( mEngineFlags & AudioEngine_DisableVoiceReuse ) ) + { + voiceKey = makeVoiceKey( wfx ); + if ( voiceKey != 0 ) + { + auto it = mVoicePool.find( voiceKey ); + if ( it != mVoicePool.end() ) + { + // Found a matching (stopped) voice to reuse + assert( it->second != 0 ); + *voice = it->second; + mVoicePool.erase( it ); + + // Reset any volume/pitch-shifting + HRESULT hr = (*voice)->SetVolume(1.f); + ThrowIfFailed( hr ); + + hr = (*voice)->SetFrequencyRatio(1.f); + ThrowIfFailed( hr ); + + if (wfx->nChannels == 1 || wfx->nChannels == 2) + { + // Reset any panning + float matrix[16]; + memset( matrix, 0, sizeof(float) * 16 ); + ComputePan( 0.f, wfx->nChannels, matrix ); + + hr = (*voice)->SetOutputMatrix(nullptr, wfx->nChannels, masterChannels, matrix); + ThrowIfFailed( hr ); + } + } + else if ( ( mVoicePool.size() + mOneShots.size() + 1 ) >= maxVoiceOneshots ) + { + DebugTrace( "WARNING: Too many one-shot voices in use (%Iu + %Iu >= %Iu); one-shot not played\n", + mVoicePool.size(), mOneShots.size() + 1, maxVoiceOneshots ); + return; + } + else + { + // makeVoiceKey already constrained the supported wfx formats to those supported for reuse + + char buff[64] = {0}; + auto wfmt = reinterpret_cast( buff ); + + uint32_t tag = GetFormatTag( wfx ); + switch( tag ) + { + case WAVE_FORMAT_PCM: + CreateIntegerPCM( wfmt, defaultRate, wfx->nChannels, wfx->wBitsPerSample ); + break; + + case WAVE_FORMAT_IEEE_FLOAT: + CreateFloatPCM( wfmt, defaultRate, wfx->nChannels ); + break; + + case WAVE_FORMAT_ADPCM: + { + auto wfadpcm = reinterpret_cast( wfx ); + CreateADPCM( wfmt, 64, defaultRate, wfx->nChannels, wfadpcm->wSamplesPerBlock ); + } + break; + +#if defined(_XBOX_ONE) && defined(_TITLE) + case WAVE_FORMAT_XMA2: + CreateXMA2( wfmt, 64, defaultRate, wfx->nChannels, 65536, 2, 0 ); + break; +#endif + } + +#ifdef VERBOSE_TRACE + DebugTrace( "INFO: Allocate reuse voice: Format Tag %u, %u channels, %u-bit, %u blkalign, %u Hz\n", wfmt->wFormatTag, + wfmt->nChannels, wfmt->wBitsPerSample, wfmt->nBlockAlign, wfmt->nSamplesPerSec ); +#endif + + assert( voiceKey == makeVoiceKey( wfmt ) ); + + HRESULT hr = xaudio2->CreateSourceVoice( voice, wfmt, 0, XAUDIO2_DEFAULT_FREQ_RATIO, &mVoiceCallback, nullptr, nullptr ); + if ( FAILED(hr) ) + { + DebugTrace( "ERROR: CreateSourceVoice (reuse) failed with error %08X\n", hr ); + throw std::exception( "CreateSourceVoice" ); + } + } + + assert( *voice != 0 ); + HRESULT hr = (*voice)->SetSourceSampleRate( wfx->nSamplesPerSec ); + if ( FAILED(hr) ) + { + DebugTrace( "ERROR: SetSourceSampleRate failed with error %08X\n", hr ); + throw std::exception( "SetSourceSampleRate" ); + } + } + } + } + + if ( !*voice ) + { + if ( oneshot ) + { + if ( ( mVoicePool.size() + mOneShots.size() + 1 ) >= maxVoiceOneshots ) + { + DebugTrace( "WARNING: Too many one-shot voices in use (%Iu + %Iu >= %Iu); one-shot not played; see TrimVoicePool\n", + mVoicePool.size(), mOneShots.size() + 1, maxVoiceOneshots ); + return; + } + } + else if ( ( mVoiceInstances + 1 ) >= maxVoiceInstances ) + { + DebugTrace( "ERROR: Too many instance voices (%Iu >= %Iu); see TrimVoicePool\n", mVoiceInstances + 1, maxVoiceInstances ); + throw std::exception( "Too many instance voices" ); + } + + UINT32 vflags = ( flags & SoundEffectInstance_NoSetPitch ) ? XAUDIO2_VOICE_NOPITCH : 0; + + HRESULT hr; + if ( flags & SoundEffectInstance_Use3D ) + { + XAUDIO2_SEND_DESCRIPTOR sendDescriptors[2]; + sendDescriptors[0].Flags = sendDescriptors[1].Flags = (flags & SoundEffectInstance_ReverbUseFilters) ? XAUDIO2_SEND_USEFILTER : 0; + sendDescriptors[0].pOutputVoice = mMasterVoice; + sendDescriptors[1].pOutputVoice = mReverbVoice; + const XAUDIO2_VOICE_SENDS sendList = { mReverbVoice ? 2U : 1U, sendDescriptors }; + +#ifdef VERBOSE_TRACE + DebugTrace( "INFO: Allocate voice 3D: Format Tag %u, %u channels, %u-bit, %u blkalign, %u Hz\n", wfx->wFormatTag, + wfx->nChannels, wfx->wBitsPerSample, wfx->nBlockAlign, wfx->nSamplesPerSec ); +#endif + + hr = xaudio2->CreateSourceVoice( voice, wfx, vflags, XAUDIO2_DEFAULT_FREQ_RATIO, &mVoiceCallback, &sendList, nullptr ); + } + else + { +#ifdef VERBOSE_TRACE + DebugTrace( "INFO: Allocate voice: Format Tag %u, %u channels, %u-bit, %u blkalign, %u Hz\n", wfx->wFormatTag, + wfx->nChannels, wfx->wBitsPerSample, wfx->nBlockAlign, wfx->nSamplesPerSec ); +#endif + + hr = xaudio2->CreateSourceVoice( voice, wfx, vflags, XAUDIO2_DEFAULT_FREQ_RATIO, &mVoiceCallback, nullptr, nullptr ); + } + + if ( FAILED(hr) ) + { + DebugTrace( "ERROR: CreateSourceVoice failed with error %08X\n", hr ); + throw std::exception( "CreateSourceVoice" ); + } + else if ( !oneshot ) + { + ++mVoiceInstances; + } + } + + if ( oneshot ) + { + assert( *voice != 0 ); + mOneShots.emplace_back( std::make_pair( voiceKey, *voice ) ); + } +} + + +void AudioEngine::Impl::DestroyVoice( _In_ IXAudio2SourceVoice* voice ) +{ + if ( !voice ) + return; + +#ifndef NDEBUG + for( auto it = mOneShots.cbegin(); it != mOneShots.cend(); ++it ) + { + if ( it->second == voice ) + { + DebugTrace( "ERROR: DestroyVoice should not be called for a one-shot voice\n" ); + throw std::exception( "DestroyVoice" ); + } + } + + for( auto it = mVoicePool.cbegin(); it != mVoicePool.cend(); ++it ) + { + if ( it->second == voice ) + { + DebugTrace( "ERROR: DestroyVoice should not be called for a one-shot voice; see TrimVoicePool\n" ); + throw std::exception( "DestroyVoice" ); + } + } +#endif + + assert( mVoiceInstances > 0 ); + --mVoiceInstances; + voice->DestroyVoice(); +} + + +void AudioEngine::Impl::RegisterNotify( _In_ IVoiceNotify* notify, bool usesUpdate ) +{ + assert( notify != 0 ); + mNotifyObjects.insert( notify ); + + if ( usesUpdate ) + { + mNotifyUpdates.insert( notify ); + } +} + + +void AudioEngine::Impl::UnregisterNotify( _In_ IVoiceNotify* notify, bool usesOneShots, bool usesUpdate ) +{ + assert( notify != 0 ); + mNotifyObjects.erase( notify ); + + // Check for any pending one-shots for this notification object + if ( usesOneShots ) + { + bool setevent = false; + + for( auto it = mOneShots.begin(); it != mOneShots.end(); ++it ) + { + assert( it->second != 0 ); + + XAUDIO2_VOICE_STATE state; +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + it->second->GetState(&state, XAUDIO2_VOICE_NOSAMPLESPLAYED ); +#else + it->second->GetState(&state); +#endif + + if ( state.pCurrentBufferContext == notify ) + { + it->second->Stop( 0 ); + it->second->FlushSourceBuffers(); + setevent = true; + } + } + + if (setevent) + { + // Trigger scan on next call to Update... + SetEvent( mVoiceCallback.mBufferEnd.get() ); + } + } + + if ( usesUpdate ) + { + mNotifyUpdates.erase( notify ); + } +} + + +//-------------------------------------------------------------------------------------- +// AudioEngine +//-------------------------------------------------------------------------------------- + +// Public constructor. +_Use_decl_annotations_ +AudioEngine::AudioEngine( AUDIO_ENGINE_FLAGS flags, const WAVEFORMATEX* wfx, const wchar_t* deviceId, AUDIO_STREAM_CATEGORY category ) + : pImpl(new Impl() ) +{ + HRESULT hr = pImpl->Initialize( flags, wfx, deviceId, category ); + if ( FAILED(hr) ) + { + if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) ) + { + if ( flags & AudioEngine_ThrowOnNoAudioHW ) + { + DebugTrace( "ERROR: AudioEngine found no default audio device\n" ); + throw std::exception( "AudioEngineNoAudioHW" ); + } + else + { + DebugTrace( "WARNING: AudioEngine found no default audio device; running in 'silent mode'\n" ); + } + } + else + { + DebugTrace( "ERROR: AudioEngine failed (%08X) to initialize using device [%ls]\n", hr, ( deviceId ) ? deviceId : L"default" ); + throw std::exception( "AudioEngine" ); + } + } +} + + +// Move constructor. +AudioEngine::AudioEngine(AudioEngine&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +AudioEngine& AudioEngine::operator= (AudioEngine&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +AudioEngine::~AudioEngine() +{ + if ( pImpl ) + { + pImpl->Shutdown(); + } +} + + +// Public methods. +bool AudioEngine::Update() +{ + return pImpl->Update(); +} + + +_Use_decl_annotations_ +bool AudioEngine::Reset( const WAVEFORMATEX* wfx, const wchar_t* deviceId ) +{ + if ( pImpl->xaudio2 ) + { + DebugTrace( "WARNING: Called Reset for active audio graph; going silent in preparation for migration\n" ); + pImpl->SetSilentMode(); + } + + HRESULT hr = pImpl->Reset( wfx, deviceId ); + if ( FAILED(hr) ) + { + if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) ) + { + if ( pImpl->mEngineFlags & AudioEngine_ThrowOnNoAudioHW ) + { + DebugTrace( "ERROR: AudioEngine found no default audio device on Reset\n" ); + throw std::exception( "AudioEngineNoAudioHW" ); + } + else + { + DebugTrace( "WARNING: AudioEngine found no default audio device on Reset; running in 'silent mode'\n" ); + return false; + } + } + else + { + DebugTrace( "ERROR: AudioEngine failed (%08X) to Reset using device [%ls]\n", hr, ( deviceId ) ? deviceId : L"default" ); + throw std::exception( "AudioEngine::Reset" ); + } + } + + DebugTrace( "INFO: AudioEngine Reset using device [%ls]\n", ( deviceId ) ? deviceId : L"default" ); + + return true; +} + + +void AudioEngine::Suspend() +{ + if ( !pImpl->xaudio2 ) + return; + + pImpl->xaudio2->StopEngine(); +} + + +void AudioEngine::Resume() +{ + if ( !pImpl->xaudio2 ) + return; + + HRESULT hr = pImpl->xaudio2->StartEngine(); + ThrowIfFailed( hr ); +} + + +float AudioEngine::GetMasterVolume() const +{ + return pImpl->mMasterVolume; +} + + +void AudioEngine::SetMasterVolume( float volume ) +{ + assert( volume >= -XAUDIO2_MAX_VOLUME_LEVEL && volume <= XAUDIO2_MAX_VOLUME_LEVEL ); + + pImpl->mMasterVolume = volume; + + if ( pImpl->mMasterVoice ) + { + HRESULT hr = pImpl->mMasterVoice->SetVolume( volume ); + ThrowIfFailed( hr ); + } +} + + +void AudioEngine::SetReverb( AUDIO_ENGINE_REVERB reverb ) +{ + if ( reverb < 0 || reverb >= Reverb_MAX ) + throw std::out_of_range( "AudioEngine::SetReverb" ); + + if ( reverb == Reverb_Off ) + { + pImpl->SetReverb( nullptr ); + } + else + { + XAUDIO2FX_REVERB_PARAMETERS native; + ReverbConvertI3DL2ToNative( &gReverbPresets[ reverb ], &native ); + pImpl->SetReverb( &native ); + } +} + + +_Use_decl_annotations_ +void AudioEngine::SetReverb( const XAUDIO2FX_REVERB_PARAMETERS* native ) +{ + pImpl->SetReverb( native ); +} + + +void AudioEngine::SetMasteringLimit( int release, int loudness ) +{ + pImpl->SetMasteringLimit( release, loudness ); +} + + +// Public accessors. +AudioStatistics AudioEngine::GetStatistics() const +{ + return pImpl->GetStatistics(); +} + + +WAVEFORMATEXTENSIBLE AudioEngine::GetOutputFormat() const +{ + WAVEFORMATEXTENSIBLE wfx; + memset( &wfx, 0, sizeof(WAVEFORMATEXTENSIBLE) ); + + if ( !pImpl->xaudio2 ) + return wfx; + + wfx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; + wfx.Format.wBitsPerSample = wfx.Samples.wValidBitsPerSample = 16; // This is a guess + wfx.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); + + wfx.Format.nChannels = static_cast( pImpl->masterChannels ); + wfx.Format.nSamplesPerSec = pImpl->masterRate; + wfx.dwChannelMask = pImpl->masterChannelMask; + + wfx.Format.nBlockAlign = WORD( wfx.Format.nChannels * wfx.Format.wBitsPerSample / 8 ); + wfx.Format.nAvgBytesPerSec = wfx.Format.nSamplesPerSec * wfx.Format.nBlockAlign; + + static const GUID s_pcm = { WAVE_FORMAT_PCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }; + memcpy( &wfx.SubFormat, &s_pcm, sizeof(GUID) ); + + return wfx; +} + + +uint32_t AudioEngine::GetChannelMask() const +{ + return pImpl->masterChannelMask; +} + + +int AudioEngine::GetOutputChannels() const +{ + return pImpl->masterChannels; +} + + +bool AudioEngine::IsAudioDevicePresent() const +{ + return ( pImpl->xaudio2.Get() != 0 ) && !pImpl->mCriticalError; +} + + +bool AudioEngine::IsCriticalError() const +{ + return pImpl->mCriticalError; +} + + +// Voice management. +void AudioEngine::SetDefaultSampleRate( int sampleRate ) +{ + if ( ( sampleRate < XAUDIO2_MIN_SAMPLE_RATE ) || ( sampleRate > XAUDIO2_MAX_SAMPLE_RATE ) ) + throw std::exception( "Default sample rate is out of range" ); + + pImpl->defaultRate = sampleRate; +} + + +void AudioEngine::SetMaxVoicePool( size_t maxOneShots, size_t maxInstances ) +{ + if ( maxOneShots > 0 ) + pImpl->maxVoiceOneshots = maxOneShots; + + if ( maxInstances > 0 ) + pImpl->maxVoiceInstances = maxInstances; +} + + +void AudioEngine::TrimVoicePool() +{ + pImpl->TrimVoicePool(); +} + + +_Use_decl_annotations_ +void AudioEngine::AllocateVoice( const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags, bool oneshot, IXAudio2SourceVoice** voice ) +{ + pImpl->AllocateVoice( wfx, flags, oneshot, voice ); +} + + +void AudioEngine::DestroyVoice( _In_ IXAudio2SourceVoice* voice ) +{ + pImpl->DestroyVoice( voice ); +} + + +void AudioEngine::RegisterNotify( _In_ IVoiceNotify* notify, bool usesUpdate ) +{ + pImpl->RegisterNotify( notify, usesUpdate ); +} + + +void AudioEngine::UnregisterNotify( _In_ IVoiceNotify* notify, bool oneshots, bool usesUpdate ) +{ + pImpl->UnregisterNotify( notify, oneshots, usesUpdate ); +} + + +IXAudio2* AudioEngine::GetInterface() const +{ + return pImpl->xaudio2.Get(); +} + + +IXAudio2MasteringVoice* AudioEngine::GetMasterVoice() const +{ + return pImpl->mMasterVoice; +} + + +IXAudio2SubmixVoice* AudioEngine::GetReverbVoice() const +{ + return pImpl->mReverbVoice; +} + + +X3DAUDIO_HANDLE& AudioEngine::Get3DHandle() const +{ + return pImpl->mX3DAudio; +} + + +// Static methods. +#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#include +#elif defined(_XBOX_ONE) +#include +#include +#elif (_WIN32_WINNT >= _WIN32_WINNT_WIN8) +#pragma comment(lib,"runtimeobject.lib") +#include +#include +#endif + +std::vector AudioEngine::GetRendererDetails() +{ + std::vector list; + +#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + + LPCWSTR id = GetDefaultAudioRenderId( Default ); + if ( !id ) + return list; + + RendererDetail device; + device.deviceId = id; + device.description = L"Default"; + + CoTaskMemFree( (LPVOID)id ); + +#elif defined(_XBOX_ONE) + + using namespace Microsoft::WRL; + using namespace Microsoft::WRL::Wrappers; + using namespace ABI::Windows::Foundation; + using namespace ABI::Windows::Media::Devices; + + ComPtr mdStatics; + HRESULT hr = GetActivationFactory( HStringReference(RuntimeClass_Windows_Media_Devices_MediaDevice).Get(), &mdStatics ); + ThrowIfFailed( hr ); + + HString id; + hr = mdStatics->GetDefaultAudioRenderId( AudioDeviceRole_Default, id.GetAddressOf() ); + ThrowIfFailed( hr ); + + RendererDetail device; + device.deviceId = id.GetRawBuffer( nullptr ); + device.description = L"Default"; + list.emplace_back( device ); + +#elif (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + +#if defined(__cplusplus_winrt) + + // Enumerating with WinRT using C++/CX (Windows Store apps) + using Windows::Devices::Enumeration::DeviceClass; + using Windows::Devices::Enumeration::DeviceInformation; + using Windows::Devices::Enumeration::DeviceInformationCollection; + + auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender); + while (operation->Status != Windows::Foundation::AsyncStatus::Completed) + ; + + DeviceInformationCollection^ devices = operation->GetResults(); + + for (unsigned i = 0; i < devices->Size; ++i) + { + using Windows::Devices::Enumeration::DeviceInformation; + + DeviceInformation^ d = devices->GetAt(i); + + RendererDetail device; + device.deviceId = d->Id->Data(); + device.description = d->Name->Data(); + list.emplace_back(device); + } +#else + + // Enumerating with WinRT using WRL (Win32 desktop app for Windows 8.x) + using namespace Microsoft::WRL; + using namespace Microsoft::WRL::Wrappers; + using namespace ABI::Windows::Foundation; + using namespace ABI::Windows::Foundation::Collections; + using namespace ABI::Windows::Devices::Enumeration; + + RoInitializeWrapper initialize(RO_INIT_MULTITHREADED); + HRESULT hr = initialize; + ThrowIfFailed( hr ); + + ComPtr diFactory; + hr = GetActivationFactory( HStringReference(RuntimeClass_Windows_Devices_Enumeration_DeviceInformation).Get(), &diFactory ); + ThrowIfFailed( hr ); + + Event findCompleted( CreateEventEx( nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, WRITE_OWNER | EVENT_ALL_ACCESS ) ); + if ( !findCompleted.IsValid() ) + throw std::exception( "CreateEventEx" ); + + auto callback = Callback>( + [&findCompleted,list]( IAsyncOperation* aDevices, AsyncStatus status ) -> HRESULT + { + UNREFERENCED_PARAMETER(aDevices); + UNREFERENCED_PARAMETER(status); + SetEvent( findCompleted.Get() ); + return S_OK; + }); + + ComPtr> operation; + hr = diFactory->FindAllAsyncDeviceClass( DeviceClass_AudioRender, operation.GetAddressOf() ); + ThrowIfFailed( hr ); + + operation->put_Completed( callback.Get() ); + + (void)WaitForSingleObjectEx( findCompleted.Get(), INFINITE, FALSE ); + + ComPtr> devices; + operation->GetResults( devices.GetAddressOf() ); + + unsigned int count = 0; + hr = devices->get_Size( &count ); + ThrowIfFailed( hr ); + + if ( !count ) + return list; + + for( unsigned int j = 0; j < count; ++j ) + { + ComPtr deviceInfo; + hr = devices->GetAt( j, deviceInfo.GetAddressOf() ); + if ( SUCCEEDED(hr) ) + { + HString id; + deviceInfo->get_Id( id.GetAddressOf() ); + + HString name; + deviceInfo->get_Name( name.GetAddressOf() ); + + RendererDetail device; + device.deviceId = id.GetRawBuffer( nullptr ); + device.description = name.GetRawBuffer( nullptr ); + list.emplace_back( device ); + } + } + +#endif + +#else // _WIN32_WINNT < _WIN32_WINNT_WIN8 + + // Enumerating with XAudio 2.7 + ComPtr pXAudio2; + + HRESULT hr = XAudio2Create( pXAudio2.GetAddressOf() ); + if ( FAILED(hr) ) + { + DebugTrace( "ERROR: XAudio 2.7 not found (have you called CoInitialize?)\n"); + throw std::exception( "XAudio2Create" ); + } + + UINT32 count = 0; + hr = pXAudio2->GetDeviceCount( &count ); + ThrowIfFailed(hr); + + if ( !count ) + return list; + + list.reserve( count ); + + for( UINT32 j = 0; j < count; ++j ) + { + XAUDIO2_DEVICE_DETAILS details; + hr = pXAudio2->GetDeviceDetails( j, &details ); + if ( SUCCEEDED(hr) ) + { + RendererDetail device; + device.deviceId = details.DeviceID; + device.description = details.DisplayName; + list.emplace_back( device ); + } + } + +#endif + + return list; +} \ No newline at end of file diff --git a/Kits/DirectXTK/Audio/DynamicSoundEffectInstance.cpp b/Kits/DirectXTK/Audio/DynamicSoundEffectInstance.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0135ffecd39169a09b9d4777e3b1b6480a80b922 --- /dev/null +++ b/Kits/DirectXTK/Audio/DynamicSoundEffectInstance.cpp @@ -0,0 +1,382 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "SoundCommon.h" + +using namespace DirectX; + + +//====================================================================================== +// DynamicSoundEffectInstance +//====================================================================================== + +// Internal object implementation class. +class DynamicSoundEffectInstance::Impl : public IVoiceNotify +{ +public: + Impl( _In_ AudioEngine* engine, + _In_ DynamicSoundEffectInstance* object, _In_opt_ std::function bufferNeeded, + int sampleRate, int channels, int sampleBits, SOUND_EFFECT_INSTANCE_FLAGS flags ) : + mBase(), + mBufferNeeded( nullptr ), + mObject( object ) + { + 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" ); + } + + if ( !channels || ( channels > 8 ) ) + { + DebugTrace( "DynamicSoundEffectInstance channels must be in range 1...8\n" ); + throw std::invalid_argument( "DynamicSoundEffectInstance" ); + } + + switch ( sampleBits ) + { + case 8: + case 16: + break; + + default: + DebugTrace( "DynamicSoundEffectInstance sampleBits must be 8-bit or 16-bit\n" ); + throw std::invalid_argument( "DynamicSoundEffectInstance" ); + } + +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + mBufferEvent.reset( CreateEventEx( nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE ) ); +#else + mBufferEvent.reset( CreateEvent( nullptr, FALSE, FALSE, nullptr ) ); +#endif + if ( !mBufferEvent ) + { + throw std::exception( "CreateEvent" ); + } + + CreateIntegerPCM( &mWaveFormat, sampleRate, channels, sampleBits ); + + assert( engine != 0 ); + engine->RegisterNotify( this, true ); + + mBase.Initialize( engine, &mWaveFormat, flags ); + + mBufferNeeded = bufferNeeded; + } + + virtual ~Impl() + { + mBase.DestroyVoice(); + + if ( mBase.engine ) + { + mBase.engine->UnregisterNotify( this, false, true ); + mBase.engine = nullptr; + } + } + + void Play(); + + void Resume(); + + void SubmitBuffer( _In_reads_bytes_(audioBytes) const uint8_t* pAudioData, uint32_t offset, size_t audioBytes ); + + const WAVEFORMATEX* GetFormat() const { return &mWaveFormat; } ; + + // IVoiceNotify + virtual void __cdecl OnBufferEnd() override + { + SetEvent( mBufferEvent.get() ); + } + + virtual void __cdecl OnCriticalError() override + { + mBase.OnCriticalError(); + } + + virtual void __cdecl OnReset() override + { + mBase.OnReset(); + } + + virtual void __cdecl OnUpdate() override; + + virtual void __cdecl OnDestroyEngine() override + { + mBase.OnDestroy(); + } + + virtual void __cdecl OnTrim() override + { + mBase.OnTrim(); + } + + virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const override + { + mBase.GatherStatistics(stats); + } + + SoundEffectInstanceBase mBase; + +private: + ScopedHandle mBufferEvent; + std::function mBufferNeeded; + DynamicSoundEffectInstance* mObject; + WAVEFORMATEX mWaveFormat; +}; + + +void DynamicSoundEffectInstance::Impl::Play() +{ + if ( !mBase.voice ) + { + mBase.AllocateVoice( &mWaveFormat ); + } + + (void)mBase.Play(); + + if ( mBase.voice && ( mBase.state == PLAYING ) && ( mBase.GetPendingBufferCount() <= 2 ) ) + { + SetEvent( mBufferEvent.get() ); + } +} + + +void DynamicSoundEffectInstance::Impl::Resume() +{ + if ( mBase.voice && ( mBase.state == PAUSED ) ) + { + mBase.Resume(); + + if ( ( mBase.state == PLAYING ) && ( mBase.GetPendingBufferCount() <= 2 ) ) + { + SetEvent( mBufferEvent.get() ); + } + } +} + + +_Use_decl_annotations_ +void DynamicSoundEffectInstance::Impl::SubmitBuffer( const uint8_t* pAudioData, uint32_t offset, size_t audioBytes ) +{ + if ( !pAudioData || !audioBytes ) + throw std::exception( "Invalid audio data buffer" ); + +#ifdef _M_X64 + if ( audioBytes > 0xFFFFFFFF ) + throw std::out_of_range( "SubmitBuffer" ); +#endif + + XAUDIO2_BUFFER buffer; + memset( &buffer, 0, sizeof(buffer) ); + + buffer.AudioBytes = static_cast( audioBytes ); + buffer.pAudioData = pAudioData; + + if( offset ) + { + assert( mWaveFormat.wFormatTag == WAVE_FORMAT_PCM ); + buffer.PlayBegin = offset / mWaveFormat.nBlockAlign; + buffer.PlayLength = static_cast( ( audioBytes - offset ) / mWaveFormat.nBlockAlign ); + } + + buffer.pContext = this; + + HRESULT hr = mBase.voice->SubmitSourceBuffer( &buffer, nullptr ); + if ( FAILED(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" ); + } +} + + +void DynamicSoundEffectInstance::Impl::OnUpdate() +{ + DWORD result = WaitForSingleObjectEx( mBufferEvent.get(), 0, FALSE ); + switch( result ) + { + 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" ); + } +} + + + +//-------------------------------------------------------------------------------------- +// DynamicSoundEffectInstance +//-------------------------------------------------------------------------------------- + +#pragma warning( disable : 4355 ) + +// Public constructors +_Use_decl_annotations_ +DynamicSoundEffectInstance::DynamicSoundEffectInstance( AudioEngine* engine, + std::function bufferNeeded, + int sampleRate, int channels, int sampleBits, SOUND_EFFECT_INSTANCE_FLAGS flags ) : + pImpl( new Impl( engine, this, bufferNeeded, sampleRate, channels, sampleBits, flags ) ) +{ +} + + +// Move constructor. +DynamicSoundEffectInstance::DynamicSoundEffectInstance(DynamicSoundEffectInstance&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +DynamicSoundEffectInstance& DynamicSoundEffectInstance::operator= (DynamicSoundEffectInstance&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +DynamicSoundEffectInstance::~DynamicSoundEffectInstance() +{ +} + + +// Public methods. +void DynamicSoundEffectInstance::Play() +{ + pImpl->Play(); +} + + +void DynamicSoundEffectInstance::Stop( bool immediate ) +{ + bool looped = false; + pImpl->mBase.Stop( immediate, looped ); +} + + +void DynamicSoundEffectInstance::Pause() +{ + pImpl->mBase.Pause(); +} + + +void DynamicSoundEffectInstance::Resume() +{ + pImpl->Resume(); +} + + +void DynamicSoundEffectInstance::SetVolume( float volume ) +{ + pImpl->mBase.SetVolume( volume ); +} + + +void DynamicSoundEffectInstance::SetPitch( float pitch ) +{ + pImpl->mBase.SetPitch( pitch ); +} + + +void DynamicSoundEffectInstance::SetPan( float pan ) +{ + pImpl->mBase.SetPan( pan ); +} + + +void DynamicSoundEffectInstance::Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords ) +{ + pImpl->mBase.Apply3D( listener, emitter, rhcoords ); +} + + +_Use_decl_annotations_ +void DynamicSoundEffectInstance::SubmitBuffer( const uint8_t* pAudioData, size_t audioBytes ) +{ + pImpl->SubmitBuffer( pAudioData, 0, audioBytes ); +} + + +_Use_decl_annotations_ +void DynamicSoundEffectInstance::SubmitBuffer( const uint8_t* pAudioData, uint32_t offset, size_t audioBytes ) +{ + pImpl->SubmitBuffer( pAudioData, offset, audioBytes ); +} + + +// Public accessors. +SoundState DynamicSoundEffectInstance::GetState() +{ + return pImpl->mBase.GetState( false ); +} + + +size_t DynamicSoundEffectInstance::GetSampleDuration( size_t bytes ) const +{ + auto wfx = pImpl->GetFormat(); + if ( !wfx || !wfx->wBitsPerSample || !wfx->nChannels ) + return 0; + + return static_cast( ( uint64_t( bytes ) * 8 ) + / uint64_t( wfx->wBitsPerSample * wfx->nChannels ) ); +} + + +size_t DynamicSoundEffectInstance::GetSampleDurationMS( size_t bytes ) const +{ + auto wfx = pImpl->GetFormat(); + if ( !wfx || !wfx->nAvgBytesPerSec ) + return 0; + + return static_cast( ( uint64_t(bytes) * 1000 ) / wfx->nAvgBytesPerSec ); +} + + +size_t DynamicSoundEffectInstance::GetSampleSizeInBytes( uint64_t duration ) const +{ + auto wfx = pImpl->GetFormat(); + if ( !wfx || !wfx->nSamplesPerSec ) + return 0; + + return static_cast( ( ( duration * wfx->nSamplesPerSec ) / 1000 ) * wfx->nBlockAlign ); +} + + +int DynamicSoundEffectInstance::GetPendingBufferCount() const +{ + return pImpl->mBase.GetPendingBufferCount(); +} + + +const WAVEFORMATEX* DynamicSoundEffectInstance::GetFormat() const +{ + return pImpl->GetFormat(); +} \ No newline at end of file diff --git a/Kits/DirectXTK/Audio/SoundCommon.cpp b/Kits/DirectXTK/Audio/SoundCommon.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3b32d648e2dcc394bdb465ee86d2b5ad9cc5af1d --- /dev/null +++ b/Kits/DirectXTK/Audio/SoundCommon.cpp @@ -0,0 +1,787 @@ +//-------------------------------------------------------------------------------------- +// File: SoundCommon.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "pch.h" +#include "SoundCommon.h" + +using namespace DirectX; + + +namespace +{ + template WORD ChannelsSpecifiedInMask(T x) + { + WORD bitCount = 0; + while (x) {++bitCount; x &= (x-1);} + return bitCount; + } +} + + +//====================================================================================== +// Wave format utilities +//====================================================================================== + +bool DirectX::IsValid( _In_ const WAVEFORMATEX* wfx ) +{ + if ( !wfx ) + return false; + + if ( !wfx->nChannels ) + { + DebugTrace( "ERROR: Wave format must have at least 1 channel\n" ); + return false; + } + + if ( wfx->nChannels > XAUDIO2_MAX_AUDIO_CHANNELS ) + { + DebugTrace( "ERROR: Wave format must have less than %u channels (%u)\n", XAUDIO2_MAX_AUDIO_CHANNELS, wfx->nChannels ); + return false; + } + + if ( !wfx->nSamplesPerSec ) + { + DebugTrace( "ERROR: Wave format cannot have a sample rate of 0\n" ); + return false; + } + + if ( ( wfx->nSamplesPerSec < XAUDIO2_MIN_SAMPLE_RATE ) + || ( wfx->nSamplesPerSec > XAUDIO2_MAX_SAMPLE_RATE ) ) + { + DebugTrace( "ERROR: Wave format channel count must be in range %u..%u (%u)\n", XAUDIO2_MIN_SAMPLE_RATE, XAUDIO2_MAX_SAMPLE_RATE, wfx->nSamplesPerSec ); + return false; + } + + switch ( wfx->wFormatTag ) + { + case WAVE_FORMAT_PCM: + + switch( wfx->wBitsPerSample ) + { + case 8: + case 16: + case 24: + case 32: + break; + + default: + DebugTrace( "ERROR: Wave format integer PCM must have 8, 16, 24, or 32 bits per sample (%u)\n", wfx->wBitsPerSample ); + return false; + } + + if ( wfx->nBlockAlign != ( wfx->nChannels * wfx->wBitsPerSample / 8 ) ) + { + DebugTrace( "ERROR: Wave format integer PCM - nBlockAlign (%u) != nChannels (%u) * wBitsPerSample (%u) / 8\n", + wfx->nBlockAlign, wfx->nChannels, wfx->wBitsPerSample ); + return false; + } + + if ( wfx->nAvgBytesPerSec != ( wfx->nSamplesPerSec * wfx->nBlockAlign ) ) + { + DebugTrace( "ERROR: Wave format integer PCM - nAvgBytesPerSec (%lu) != nSamplesPerSec (%lu) * nBlockAlign (%u)\n", + wfx->nAvgBytesPerSec, wfx->nSamplesPerSec, wfx->nBlockAlign ); + return false; + } + + return true; + + case WAVE_FORMAT_IEEE_FLOAT: + + if ( wfx->wBitsPerSample != 32 ) + { + DebugTrace( "ERROR: Wave format float PCM must have 32-bits per sample (%u)\n", wfx->wBitsPerSample ); + return false; + } + + if ( wfx->nBlockAlign != ( wfx->nChannels * wfx->wBitsPerSample / 8 ) ) + { + DebugTrace( "ERROR: Wave format float PCM - nBlockAlign (%u) != nChannels (%u) * wBitsPerSample (%u) / 8\n", + wfx->nBlockAlign, wfx->nChannels, wfx->wBitsPerSample ); + return false; + } + + if ( wfx->nAvgBytesPerSec != ( wfx->nSamplesPerSec * wfx->nBlockAlign ) ) + { + DebugTrace( "ERROR: Wave format float PCM - nAvgBytesPerSec (%lu) != nSamplesPerSec (%lu) * nBlockAlign (%u)\n", + wfx->nAvgBytesPerSec, wfx->nSamplesPerSec, wfx->nBlockAlign ); + return false; + } + + return true; + + case WAVE_FORMAT_ADPCM: + + if ( ( wfx->nChannels != 1 ) && ( wfx->nChannels != 2 ) ) + { + DebugTrace( "ERROR: Wave format ADPCM must have 1 or 2 channels (%u)\n", wfx->nChannels ); + return false; + } + + if ( wfx->wBitsPerSample != 4 /*MSADPCM_BITS_PER_SAMPLE*/ ) + { + DebugTrace( "ERROR: Wave format ADPCM must have 4 bits per sample (%u)\n", wfx->wBitsPerSample ); + return false; + } + + if ( wfx->cbSize != 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/ ) + { + DebugTrace( "ERROR: Wave format ADPCM must have cbSize = 32 (%u)\n", wfx->cbSize ); + return false; + } + else + { + auto wfadpcm = reinterpret_cast( wfx ); + + if ( wfadpcm->wNumCoef != 7 /*MSADPCM_NUM_COEFFICIENTS*/ ) + { + DebugTrace( "ERROR: Wave format ADPCM must have 7 coefficients (%u)\n", wfadpcm->wNumCoef ); + return false; + } + + bool valid = true; + for ( int j = 0; j < 7 /*MSADPCM_NUM_COEFFICIENTS*/; ++j ) + { + // Microsoft ADPCM standard encoding coefficients + static const short g_pAdpcmCoefficients1[] = {256, 512, 0, 192, 240, 460, 392}; + static const short g_pAdpcmCoefficients2[] = { 0, -256, 0, 64, 0, -208, -232}; + + if ( wfadpcm->aCoef[j].iCoef1 != g_pAdpcmCoefficients1[j] + || wfadpcm->aCoef[j].iCoef2 != g_pAdpcmCoefficients2[j] ) + { + valid = false; + } + } + + if ( !valid ) + { + DebugTrace( "ERROR: Wave formt ADPCM found non-standard coefficients\n" ); + return false; + } + + if ( ( wfadpcm->wSamplesPerBlock < 4 /*MSADPCM_MIN_SAMPLES_PER_BLOCK*/ ) + || ( wfadpcm->wSamplesPerBlock > 64000 /*MSADPCM_MAX_SAMPLES_PER_BLOCK*/ ) ) + { + DebugTrace( "ERROR: Wave format ADPCM wSamplesPerBlock must be 4..64000 (%u)\n", wfadpcm->wSamplesPerBlock ); + return false; + } + + if ( wfadpcm->wfx.nChannels == 1 && ( wfadpcm->wSamplesPerBlock % 2 ) ) + { + DebugTrace( "ERROR: Wave format ADPCM mono files must have even wSamplesPerBlock\n" ); + return false; + } + + int nHeaderBytes = 7 /*MSADPCM_HEADER_LENGTH*/ * wfx->nChannels; + int nBitsPerFrame = 4 /*MSADPCM_BITS_PER_SAMPLE*/ * wfx->nChannels; + int nPcmFramesPerBlock = (wfx->nBlockAlign - nHeaderBytes) * 8 / nBitsPerFrame + 2; + + if ( wfadpcm->wSamplesPerBlock != nPcmFramesPerBlock ) + { + DebugTrace( "ERROR: Wave format ADPCM %u-channel with nBlockAlign = %u must have wSamplesPerBlock = %u (%u)\n", + wfx->nChannels, wfx->nBlockAlign, nPcmFramesPerBlock, wfadpcm->wSamplesPerBlock ); + return false; + } + } + return true; + + case WAVE_FORMAT_WMAUDIO2: + case WAVE_FORMAT_WMAUDIO3: + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10) + + if ( wfx->wBitsPerSample != 16 ) + { + DebugTrace( "ERROR: Wave format xWMA only supports 16-bit data\n" ); + return false; + } + + if ( !wfx->nBlockAlign ) + { + DebugTrace( "ERROR: Wave format xWMA must have a non-zero nBlockAlign\n" ); + return false; + } + + if ( !wfx->nAvgBytesPerSec ) + { + DebugTrace( "ERROR: Wave format xWMA must have a non-zero nAvgBytesPerSec\n" ); + return false; + } + + return true; + +#else + DebugTrace( "ERROR: Wave format xWMA not supported by this version of DirectXTK for Audio\n" ); + return false; +#endif + + case 0x166 /* WAVE_FORMAT_XMA2 */: + +#if defined(_XBOX_ONE) && defined(_TITLE) + + if ( wfx->nBlockAlign != wfx->nChannels * XMA_OUTPUT_SAMPLE_BYTES) + { + DebugTrace( "ERROR: Wave format XMA2 - nBlockAlign (%u) != nChannels(%u) * %u\n", wfx->nBlockAlign, wfx->nChannels, XMA_OUTPUT_SAMPLE_BYTES ); + return false; + } + + if ( wfx->wBitsPerSample != XMA_OUTPUT_SAMPLE_BITS ) + { + DebugTrace( "ERROR: Wave format XMA2 wBitsPerSample (%u) should be %u\n", wfx->wBitsPerSample, XMA_OUTPUT_SAMPLE_BITS ); + return false; + } + + if ( wfx->cbSize != ( sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX) ) ) + { + DebugTrace( "ERROR: Wave format XMA2 - cbSize must be %Iu (%u)\n", ( sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX) ), wfx->cbSize ); + return false; + } + else + { + auto xmaFmt = reinterpret_cast( wfx ); + + if ( xmaFmt->EncoderVersion < 3 ) + { + DebugTrace( "ERROR: Wave format XMA2 encoder version (%u) - 3 or higher is required\n", xmaFmt->EncoderVersion ); + return false; + } + + if ( !xmaFmt->BlockCount ) + { + DebugTrace( "ERROR: Wave format XMA2 BlockCount must be non-zero\n" ); + return false; + } + + if ( !xmaFmt->BytesPerBlock || ( xmaFmt->BytesPerBlock > XMA_READBUFFER_MAX_BYTES ) ) + { + DebugTrace( "ERROR: Wave format XMA2 BytesPerBlock (%u) is invalid\n", xmaFmt->BytesPerBlock ); + return false; + } + + if ( xmaFmt->ChannelMask ) + { + auto channelBits = ChannelsSpecifiedInMask( xmaFmt->ChannelMask ); + if ( channelBits != wfx->nChannels ) + { + DebugTrace( "ERROR: Wave format XMA2 - nChannels=%u but ChannelMask (%08X) has %u bits set\n", + xmaFmt->ChannelMask, wfx->nChannels, channelBits ); + return false; + } + } + + if ( xmaFmt->NumStreams != ( ( wfx->nChannels + 1) / 2 ) ) + { + DebugTrace( "ERROR: Wave format XMA2 - NumStreams (%u) != ( nChannels(%u) + 1 ) / 2\n", xmaFmt->NumStreams, wfx->nChannels ); + return false; + } + + if ( ( xmaFmt->PlayBegin + xmaFmt->PlayLength ) > xmaFmt->SamplesEncoded ) + { + DebugTrace( "ERROR: Wave format XMA2 play region too large (%u + %u > %u)\n", xmaFmt->PlayBegin, xmaFmt->PlayLength, xmaFmt->SamplesEncoded ); + return false; + } + + if ( ( xmaFmt->LoopBegin + xmaFmt->LoopLength ) > xmaFmt->SamplesEncoded ) + { + DebugTrace( "ERROR: Wave format XMA2 loop region too large (%u + %u > %u)\n", xmaFmt->LoopBegin, xmaFmt->LoopLength, xmaFmt->SamplesEncoded ); + return false; + } + } + return true; + +#else + DebugTrace( "ERROR: Wave format XMA2 not supported by this version of DirectXTK for Audio\n" ); + return false; +#endif + + case WAVE_FORMAT_EXTENSIBLE: + if ( wfx->cbSize < ( sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) ) ) + { + DebugTrace( "ERROR: Wave format WAVE_FORMAT_EXTENSIBLE - cbSize must be %Iu (%u)\n", ( sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) ), wfx->cbSize ); + return false; + } + else + { + static const GUID s_wfexBase = {0x00000000, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}; + + auto wfex = reinterpret_cast( wfx ); + + if ( memcmp( reinterpret_cast(&wfex->SubFormat) + sizeof(DWORD), + reinterpret_cast(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD) ) != 0 ) + { + DebugTrace( "ERROR: Wave format WAVEFORMATEXTENSIBLE encountered with unknown GUID ({%8.8lX-%4.4X-%4.4X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X})\n", + wfex->SubFormat.Data1, wfex->SubFormat.Data2, wfex->SubFormat.Data3, + wfex->SubFormat.Data4[0], wfex->SubFormat.Data4[1], wfex->SubFormat.Data4[2], wfex->SubFormat.Data4[3], + wfex->SubFormat.Data4[4], wfex->SubFormat.Data4[5], wfex->SubFormat.Data4[6], wfex->SubFormat.Data4[7] ); + return false; + } + + switch( wfex->SubFormat.Data1 ) + { + case WAVE_FORMAT_PCM: + + switch( wfx->wBitsPerSample ) + { + case 8: + case 16: + case 24: + case 32: + break; + + default: + DebugTrace( "ERROR: Wave format integer PCM must have 8, 16, 24, or 32 bits per sample (%u)\n", wfx->wBitsPerSample ); + return false; + } + + switch( wfex->Samples.wValidBitsPerSample ) + { + case 0: + case 8: + case 16: + case 20: + case 24: + case 32: + break; + + default: + DebugTrace( "ERROR: Wave format integer PCM must have 8, 16, 20, 24, or 32 valid bits per sample (%u)\n", wfex->Samples.wValidBitsPerSample ); + return false; + } + + if ( wfex->Samples.wValidBitsPerSample + && ( wfex->Samples.wValidBitsPerSample > wfx->wBitsPerSample ) ) + { + DebugTrace( "ERROR: Wave format ingter PCM wValidBitsPerSample (%u) is greater than wBitsPerSample (%u)\n", wfex->Samples.wValidBitsPerSample, wfx->wBitsPerSample ); + return false; + } + + if ( wfx->nBlockAlign != ( wfx->nChannels * wfx->wBitsPerSample / 8 ) ) + { + DebugTrace( "ERROR: Wave format integer PCM - nBlockAlign (%u) != nChannels (%u) * wBitsPerSample (%u) / 8\n", + wfx->nBlockAlign, wfx->nChannels, wfx->wBitsPerSample ); + return false; + } + + if ( wfx->nAvgBytesPerSec != ( wfx->nSamplesPerSec * wfx->nBlockAlign ) ) + { + DebugTrace( "ERROR: Wave format integer PCM - nAvgBytesPerSec (%lu) != nSamplesPerSec (%lu) * nBlockAlign (%u)\n", + wfx->nAvgBytesPerSec, wfx->nSamplesPerSec, wfx->nBlockAlign ); + return false; + } + + break; + + case WAVE_FORMAT_IEEE_FLOAT: + + if ( wfx->wBitsPerSample != 32 ) + { + DebugTrace( "ERROR: Wave format float PCM must have 32-bits per sample (%u)\n", wfx->wBitsPerSample ); + return false; + } + + switch( wfex->Samples.wValidBitsPerSample ) + { + case 0: + case 32: + break; + + default: + DebugTrace( "ERROR: Wave format float PCM must have 32 valid bits per sample (%u)\n", wfex->Samples.wValidBitsPerSample ); + return false; + } + + if ( wfx->nBlockAlign != ( wfx->nChannels * wfx->wBitsPerSample / 8 ) ) + { + DebugTrace( "ERROR: Wave format float PCM - nBlockAlign (%u) != nChannels (%u) * wBitsPerSample (%u) / 8\n", + wfx->nBlockAlign, wfx->nChannels, wfx->wBitsPerSample ); + return false; + } + + if ( wfx->nAvgBytesPerSec != ( wfx->nSamplesPerSec * wfx->nBlockAlign ) ) + { + DebugTrace( "ERROR: Wave format float PCM - nAvgBytesPerSec (%lu) != nSamplesPerSec (%lu) * nBlockAlign (%u)\n", + wfx->nAvgBytesPerSec, wfx->nSamplesPerSec, wfx->nBlockAlign ); + return false; + } + + break; + + case WAVE_FORMAT_ADPCM: + DebugTrace( "ERROR: Wave format ADPCM is not supported as a WAVEFORMATEXTENSIBLE\n" ); + return false; + + case WAVE_FORMAT_WMAUDIO2: + case WAVE_FORMAT_WMAUDIO3: + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10) + + if ( wfx->wBitsPerSample != 16 ) + { + DebugTrace( "ERROR: Wave format xWMA only supports 16-bit data\n" ); + return false; + } + + if ( !wfx->nBlockAlign ) + { + DebugTrace( "ERROR: Wave format xWMA must have a non-zero nBlockAlign\n" ); + return false; + } + + if ( !wfx->nAvgBytesPerSec ) + { + DebugTrace( "ERROR: Wave format xWMA must have a non-zero nAvgBytesPerSec\n" ); + return false; + } + + break; + +#else + DebugTrace( "ERROR: Wave format xWMA not supported by this version of DirectXTK for Audio\n" ); + return false; +#endif + + case 0x166 /* WAVE_FORMAT_XMA2 */: + DebugTrace( "ERROR: Wave format XMA2 is not supported as a WAVEFORMATEXTENSIBLE\n" ); + return false; + + default: + DebugTrace( "ERROR: Unknown WAVEFORMATEXTENSIBLE format tag (%u)\n", wfex->SubFormat.Data1 ); + return false; + } + + if ( wfex->dwChannelMask ) + { + auto channelBits = ChannelsSpecifiedInMask( wfex->dwChannelMask ); + if ( channelBits != wfx->nChannels ) + { + DebugTrace( "ERROR: WAVEFORMATEXTENSIBLE: nChannels=%u but ChannelMask has %u bits set\n", + wfx->nChannels, channelBits ); + return false; + } + } + + return true; + } + + default: + DebugTrace( "ERROR: Unknown WAVEFORMATEX format tag (%u)\n", wfx->wFormatTag ); + return false; + } +} + + +uint32_t DirectX::GetDefaultChannelMask( int channels ) +{ + switch( channels ) + { + case 1: return SPEAKER_MONO; + case 2: return SPEAKER_STEREO; + case 3: return SPEAKER_2POINT1; + case 4: return SPEAKER_QUAD; + case 5: return SPEAKER_4POINT1; + case 6: return SPEAKER_5POINT1; + case 7: return SPEAKER_5POINT1 | SPEAKER_BACK_CENTER; + case 8: return SPEAKER_7POINT1; + default: return 0; + } +} + + +_Use_decl_annotations_ +void DirectX::CreateIntegerPCM( WAVEFORMATEX* wfx, int sampleRate, int channels, int sampleBits ) +{ + int blockAlign = channels * sampleBits / 8; + + wfx->wFormatTag = WAVE_FORMAT_PCM; + wfx->nChannels = static_cast( channels ); + wfx->nSamplesPerSec = static_cast( sampleRate ); + wfx->nAvgBytesPerSec = static_cast( blockAlign * sampleRate ); + wfx->nBlockAlign = static_cast( blockAlign ); + wfx->wBitsPerSample = static_cast( sampleBits ); + wfx->cbSize = 0; + + assert( IsValid( wfx ) ); +} + + +_Use_decl_annotations_ +void DirectX::CreateFloatPCM( WAVEFORMATEX* wfx, int sampleRate, int channels ) +{ + int blockAlign = channels * 4; + + wfx->wFormatTag = WAVE_FORMAT_IEEE_FLOAT; + wfx->nChannels = static_cast( channels ); + wfx->nSamplesPerSec = static_cast( sampleRate ); + wfx->nAvgBytesPerSec = static_cast( blockAlign * sampleRate ); + wfx->nBlockAlign = static_cast( blockAlign ); + wfx->wBitsPerSample = 32; + wfx->cbSize = 0; + + assert( IsValid( wfx ) ); +} + + +_Use_decl_annotations_ +void DirectX::CreateADPCM( WAVEFORMATEX* wfx, size_t wfxSize, int sampleRate, int channels, int samplesPerBlock ) +{ + if ( wfxSize < ( sizeof(WAVEFORMATEX) + 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/ ) ) + { + DebugTrace( "CreateADPCM needs at least %Iu bytes for the result\n", ( sizeof(WAVEFORMATEX) + 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/ ) ); + throw std::invalid_argument( "ADPCMWAVEFORMAT" ); + } + + if ( !samplesPerBlock ) + { + DebugTrace( "CreateADPCM needs a non-zero samples per block count\n" ); + throw std::invalid_argument( "ADPCMWAVEFORMAT" ); + } + + int blockAlign = (7 /*MSADPCM_HEADER_LENGTH*/) * channels + + (samplesPerBlock - 2) * (4 /* MSADPCM_BITS_PER_SAMPLE */) * channels / 8; + + wfx->wFormatTag = WAVE_FORMAT_ADPCM; + wfx->nChannels = static_cast( channels ); + wfx->nSamplesPerSec = static_cast( sampleRate ); + wfx->nAvgBytesPerSec = static_cast( blockAlign * sampleRate / samplesPerBlock ); + wfx->nBlockAlign = static_cast( blockAlign ); + wfx->wBitsPerSample = 4 /* MSADPCM_BITS_PER_SAMPLE */; + wfx->cbSize = 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/; + + auto adpcm = reinterpret_cast( wfx ); + adpcm->wSamplesPerBlock = static_cast( samplesPerBlock ); + adpcm->wNumCoef = 7 /* MSADPCM_NUM_COEFFICIENTS */; + + static ADPCMCOEFSET aCoef[7] = { { 256, 0}, {512, -256}, {0,0}, {192,64}, {240,0}, {460, -208}, {392,-232} }; + memcpy( &adpcm->aCoef, aCoef, sizeof(aCoef) ); + + assert( IsValid( wfx ) ); +} + + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10) +_Use_decl_annotations_ +void DirectX::CreateXWMA( WAVEFORMATEX* wfx, int sampleRate, int channels, int blockAlign, int avgBytes, bool wma3 ) +{ + wfx->wFormatTag = (wma3) ? WAVE_FORMAT_WMAUDIO3 : WAVE_FORMAT_WMAUDIO2; + wfx->nChannels = static_cast( channels ); + wfx->nSamplesPerSec = static_cast( sampleRate ); + wfx->nAvgBytesPerSec = static_cast( avgBytes ); + wfx->nBlockAlign = static_cast( blockAlign ); + wfx->wBitsPerSample = 16; + wfx->cbSize = 0; + + assert( IsValid( wfx ) ); +} +#endif + + +#if defined(_XBOX_ONE) && defined(_TITLE) +_Use_decl_annotations_ +void DirectX::CreateXMA2( WAVEFORMATEX* wfx, size_t wfxSize, int sampleRate, int channels, int bytesPerBlock, int blockCount, int samplesEncoded ) +{ + if ( wfxSize < sizeof(XMA2WAVEFORMATEX) ) + { + DebugTrace( "XMA2 needs at least %Iu bytes for the result\n", sizeof(XMA2WAVEFORMATEX) ); + throw std::invalid_argument( "XMA2WAVEFORMATEX" ); + } + + if ( !bytesPerBlock || ( bytesPerBlock > XMA_READBUFFER_MAX_BYTES ) ) + { + DebugTrace( "XMA2 needs a valid bytes per block\n" ); + throw std::invalid_argument( "XMA2WAVEFORMATEX" ); + } + + int blockAlign = (channels * ( 16 /*XMA_OUTPUT_SAMPLE_BITS*/ ) / 8); + + wfx->wFormatTag = WAVE_FORMAT_XMA2; + wfx->nChannels = static_cast( channels ); + wfx->nSamplesPerSec = static_cast( sampleRate ); + wfx->nAvgBytesPerSec = static_cast( blockAlign * sampleRate ); + wfx->nBlockAlign = static_cast( blockAlign ); + wfx->wBitsPerSample = 16 /* XMA_OUTPUT_SAMPLE_BITS */; + wfx->cbSize = sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX); + + auto xmaFmt = reinterpret_cast(wfx); + + xmaFmt->NumStreams = static_cast( (channels + 1) / 2 ); + + xmaFmt->ChannelMask = GetDefaultChannelMask( channels ); + + xmaFmt->SamplesEncoded = static_cast( samplesEncoded ); + xmaFmt->BytesPerBlock = bytesPerBlock; + xmaFmt->PlayBegin = xmaFmt->PlayLength = + xmaFmt->LoopBegin = xmaFmt->LoopLength = xmaFmt->LoopCount = 0; + xmaFmt->EncoderVersion = 4 /* XMAENCODER_VERSION_XMA2 */; + xmaFmt->BlockCount = static_cast( blockCount ); + + assert( IsValid( wfx ) ); +} +#endif // _XBOX_ONE && _TITLE + + +_Use_decl_annotations_ +bool DirectX::ComputePan( float pan, int channels, float* matrix ) +{ + memset( matrix, 0, sizeof(float) * 16 ); + + if (channels == 1) + { + // Mono panning + float left = ( pan >= 0 ) ? ( 1.f - pan ) : 1.f; + left = std::min( 1.f, left ); + left = std::max( -1.f, left ); + + float right = ( pan <= 0 ) ? ( - pan - 1.f ) : 1.f; + right = std::min( 1.f, right ); + right = std::max( -1.f, right ); + + matrix[0] = left; + matrix[1] = right; + } + else if (channels == 2) + { + // Stereo panning + if ( -1.f <= pan && pan <= 0.f ) + { + matrix[0] = .5f * pan + 1.f; // .5 when pan is -1, 1 when pan is 0 + matrix[1] = .5f * -pan; // .5 when pan is -1, 0 when pan is 0 + matrix[2] = 0.f; // 0 when pan is -1, 0 when pan is 0 + matrix[3] = pan + 1.f; // 0 when pan is -1, 1 when pan is 0 + } + else + { + matrix[0] = -pan + 1.f; // 1 when pan is 0, 0 when pan is 1 + matrix[1] = 0.f; // 0 when pan is 0, 0 when pan is 1 + matrix[2] = .5f * pan; // 0 when pan is 0, .5f when pan is 1 + matrix[3] = .5f * -pan + 1.f; // 1 when pan is 0. .5f when pan is 1 + } + } + else + { + if ( pan != 0.f ) + { + DebugTrace( "WARNING: Only supports panning on mono or stereo source data, ignored\n" ); + } + return false; + } + + return true; +} + + +//====================================================================================== +// SoundEffectInstanceBase +//====================================================================================== + +void SoundEffectInstanceBase::SetPan( float pan ) +{ + assert( pan >= -1.f && pan <= 1.f ); + + mPan = pan; + + if ( !voice ) + return; + + float matrix[16]; + if ( ComputePan( pan, mDSPSettings.SrcChannelCount, matrix ) ) + { + HRESULT hr = voice->SetOutputMatrix( nullptr, mDSPSettings.SrcChannelCount, mDSPSettings.DstChannelCount, matrix ); + ThrowIfFailed( hr ); + } +} + + +void SoundEffectInstanceBase::Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords ) +{ + if ( !voice ) + return; + + if ( !( mFlags & SoundEffectInstance_Use3D ) ) + { + DebugTrace( "ERROR: Apply3D called for an instance created without SoundEffectInstance_Use3D set\n" ); + throw std::exception( "Apply3D" ); + } + + DWORD dwCalcFlags = X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER | X3DAUDIO_CALCULATE_LPF_DIRECT; + + if ( mFlags & SoundEffectInstance_UseRedirectLFE ) + { + // On devices with an LFE channel, allow the mono source data to be routed to the LFE destination channel. + dwCalcFlags |= X3DAUDIO_CALCULATE_REDIRECT_TO_LFE; + } + + auto reverb = mReverbVoice; + if ( reverb ) + { + dwCalcFlags |= X3DAUDIO_CALCULATE_LPF_REVERB | X3DAUDIO_CALCULATE_REVERB; + } + + float matrix[ XAUDIO2_MAX_AUDIO_CHANNELS * 8 ]; + assert( mDSPSettings.SrcChannelCount <= XAUDIO2_MAX_AUDIO_CHANNELS ); + assert( mDSPSettings.DstChannelCount <= 8 ); + mDSPSettings.pMatrixCoefficients = matrix; + + assert( engine != 0 ); + if (rhcoords) + { + X3DAUDIO_EMITTER lhEmitter; + memcpy(&lhEmitter, &emitter, sizeof(X3DAUDIO_EMITTER)); + lhEmitter.OrientFront.z = -emitter.OrientFront.z; + lhEmitter.OrientTop.z = -emitter.OrientTop.z; + lhEmitter.Position.z = -emitter.Position.z; + lhEmitter.Velocity.z = -emitter.Velocity.z; + + X3DAUDIO_LISTENER lhListener; + memcpy(&lhListener, &listener, sizeof(X3DAUDIO_LISTENER)); + lhListener.OrientFront.z = -listener.OrientFront.z; + lhListener.OrientTop.z = -listener.OrientTop.z; + lhListener.Position.z = -listener.Position.z; + lhListener.Velocity.z = -listener.Velocity.z; + + X3DAudioCalculate( engine->Get3DHandle(), &lhListener, &lhEmitter, dwCalcFlags, &mDSPSettings ); + } + else + { + X3DAudioCalculate( engine->Get3DHandle(), &listener, &emitter, dwCalcFlags, &mDSPSettings ); + } + + mDSPSettings.pMatrixCoefficients = nullptr; + + voice->SetFrequencyRatio( mFreqRatio * mDSPSettings.DopplerFactor ); + + auto direct = mDirectVoice; + assert( direct != 0 ); + voice->SetOutputMatrix( direct, mDSPSettings.SrcChannelCount, mDSPSettings.DstChannelCount, matrix ); + + if ( reverb ) + { + voice->SetOutputMatrix( reverb, 1, 1, &mDSPSettings.ReverbLevel ); + } + + if ( mFlags & SoundEffectInstance_ReverbUseFilters ) + { + XAUDIO2_FILTER_PARAMETERS filterDirect = { LowPassFilter, 2.0f * sinf(X3DAUDIO_PI/6.0f * mDSPSettings.LPFDirectCoefficient), 1.0f }; + // see XAudio2CutoffFrequencyToRadians() in XAudio2.h for more information on the formula used here + voice->SetOutputFilterParameters( direct, &filterDirect ); + + if ( reverb ) + { + XAUDIO2_FILTER_PARAMETERS filterReverb = { LowPassFilter, 2.0f * sinf(X3DAUDIO_PI/6.0f * mDSPSettings.LPFReverbCoefficient), 1.0f }; + // see XAudio2CutoffFrequencyToRadians() in XAudio2.h for more information on the formula used here + voice->SetOutputFilterParameters( reverb, &filterReverb ); + } + } +} + + diff --git a/Kits/DirectXTK/Audio/SoundCommon.h b/Kits/DirectXTK/Audio/SoundCommon.h new file mode 100644 index 0000000000000000000000000000000000000000..c8f3b7d1b5347989f1597b55b479f6b9a4a59153 --- /dev/null +++ b/Kits/DirectXTK/Audio/SoundCommon.h @@ -0,0 +1,369 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "Audio.h" +#include "PlatformHelpers.h" + + +namespace DirectX +{ + // Helper for getting a format tag from a WAVEFORMATEX + inline uint32_t GetFormatTag( const WAVEFORMATEX* wfx ) + { + if ( wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE ) + { + 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}; + + auto wfex = reinterpret_cast( wfx ); + + if ( memcmp( reinterpret_cast(&wfex->SubFormat) + sizeof(DWORD), + reinterpret_cast(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD) ) != 0 ) + { + return 0; + } + + return wfex->SubFormat.Data1; + } + else + { + return wfx->wFormatTag; + } + } + + + // Helper for validating wave format structure + bool IsValid( _In_ const WAVEFORMATEX* wfx ); + + + // Helper for getting a default channel mask from 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 ); +#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 ); +#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 ); +#endif + + // Helper for computing pan volume 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() + { + assert( !voice ); + } + + void Initialize( _In_ AudioEngine* eng, _In_ const WAVEFORMATEX* wfx, SOUND_EFFECT_INSTANCE_FLAGS flags ) + { + assert( eng != 0 ); + engine = eng; + mDirectVoice = eng->GetMasterVoice(); + mReverbVoice = eng->GetReverbVoice(); + + if ( eng->GetChannelMask() & SPEAKER_LOW_FREQUENCY ) + mFlags = flags | SoundEffectInstance_UseRedirectLFE; + else + mFlags = static_cast( static_cast(flags) & ~SoundEffectInstance_UseRedirectLFE ); + + memset( &mDSPSettings, 0, sizeof(X3DAUDIO_DSP_SETTINGS) ); + assert( wfx != 0 ); + mDSPSettings.SrcChannelCount = wfx->nChannels; + mDSPSettings.DstChannelCount = eng->GetOutputChannels(); + } + + void AllocateVoice( _In_ const WAVEFORMATEX* wfx ) + { + if ( voice ) + return; + + assert( engine != 0 ); + engine->AllocateVoice( wfx, mFlags, false, &voice ); + } + + void DestroyVoice() + { + if ( voice ) + { + assert( engine != 0 ); + engine->DestroyVoice( voice ); + voice = nullptr; + } + } + + bool Play() // Returns true if STOPPED -> PLAYING + { + if ( voice ) + { + if ( state == PAUSED ) + { + HRESULT hr = voice->Start( 0 ); + ThrowIfFailed( hr ); + state = PLAYING; + } + else if ( state != PLAYING ) + { + if ( mVolume != 1.f ) + { + HRESULT hr = voice->SetVolume( mVolume ); + ThrowIfFailed( hr ); + } + + if ( mPitch != 0.f ) + { + mFreqRatio = XAudio2SemitonesToFrequencyRatio( mPitch * 12.f ); + + HRESULT hr = voice->SetFrequencyRatio( mFreqRatio ); + ThrowIfFailed( hr ); + } + + if ( mPan != 0.f ) + { + SetPan( mPan ); + } + + HRESULT hr = voice->Start( 0 ); + ThrowIfFailed( hr ); + state = PLAYING; + return true; + } + } + return false; + } + + void Stop( bool immediate, bool& looped ) + { + if ( !voice ) + { + state = STOPPED; + return; + } + + if ( immediate ) + { + state = STOPPED; + voice->Stop( 0 ); + voice->FlushSourceBuffers(); + } + else if ( looped ) + { + looped = false; + voice->ExitLoop(); + } + else + { + voice->Stop( XAUDIO2_PLAY_TAILS ); + } + } + + void Pause() + { + if ( voice && state == PLAYING ) + { + state = PAUSED; + + voice->Stop( 0 ); + } + } + + void Resume() + { + if ( voice && state == PAUSED ) + { + HRESULT hr = voice->Start( 0 ); + ThrowIfFailed( hr ); + state = PLAYING; + } + } + + void SetVolume( float volume ) + { + assert( volume >= -XAUDIO2_MAX_VOLUME_LEVEL && volume <= XAUDIO2_MAX_VOLUME_LEVEL ); + + mVolume = volume; + + if ( voice ) + { + HRESULT hr = voice->SetVolume( volume ); + ThrowIfFailed( hr ); + } + } + + void SetPitch( float pitch ) + { + assert( pitch >= -1.f && pitch <= 1.f ); + + if ( ( mFlags & SoundEffectInstance_NoSetPitch ) && pitch != 0.f ) + { + DebugTrace( "ERROR: Sound effect instance was created with the NoSetPitch flag\n" ); + throw std::exception( "SetPitch" ); + } + + mPitch = pitch; + + if ( voice ) + { + mFreqRatio = XAudio2SemitonesToFrequencyRatio( mPitch * 12.f ); + + HRESULT hr = voice->SetFrequencyRatio( mFreqRatio ); + ThrowIfFailed( hr ); + } + } + + void SetPan( float pan ); + + void Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords ); + + SoundState GetState( bool autostop ) + { + 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 ( !xstate.BuffersQueued ) + { + // Automatic stop if the buffer has finished playing + voice->Stop(); + state = STOPPED; + } + } + + return state; + } + + int GetPendingBufferCount() const + { + 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( xstate.BuffersQueued ); + } + + void OnCriticalError() + { + if ( voice ) + { + voice->DestroyVoice(); + voice = nullptr; + } + state = STOPPED; + mDirectVoice = nullptr; + mReverbVoice = nullptr; + } + + void OnReset() + { + assert( engine != 0 ); + mDirectVoice = engine->GetMasterVoice(); + mReverbVoice = engine->GetReverbVoice(); + + if ( engine->GetChannelMask() & SPEAKER_LOW_FREQUENCY ) + mFlags = mFlags | SoundEffectInstance_UseRedirectLFE; + else + mFlags = static_cast( static_cast(mFlags) & ~SoundEffectInstance_UseRedirectLFE ); + + mDSPSettings.DstChannelCount = engine->GetOutputChannels(); + } + + void OnDestroy() + { + if ( voice ) + { + voice->Stop( 0 ); + voice->FlushSourceBuffers(); + voice->DestroyVoice(); + voice = nullptr; + } + state = STOPPED; + engine = nullptr; + mDirectVoice = nullptr; + mReverbVoice = nullptr; + } + + void OnTrim() + { + if ( voice && ( state == STOPPED ) ) + { + engine->DestroyVoice( voice ); + voice = nullptr; + } + } + + void GatherStatistics( AudioStatistics& stats ) const + { + ++stats.allocatedInstances; + if ( voice ) + { + ++stats.allocatedVoices; + + if ( mFlags & SoundEffectInstance_Use3D ) + ++stats.allocatedVoices3d; + + if ( state == PLAYING ) + ++stats.playingInstances; + } + } + + IXAudio2SourceVoice* voice; + SoundState state; + AudioEngine* engine; + + private: + float mVolume; + float mPitch; + float mFreqRatio; + float mPan; + SOUND_EFFECT_INSTANCE_FLAGS mFlags; + IXAudio2Voice* mDirectVoice; + IXAudio2Voice* mReverbVoice; + X3DAUDIO_DSP_SETTINGS mDSPSettings; + }; +} \ No newline at end of file diff --git a/Kits/DirectXTK/Audio/SoundEffect.cpp b/Kits/DirectXTK/Audio/SoundEffect.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bb85a61db5fd232e44c258f7ded86fdd042f11ef --- /dev/null +++ b/Kits/DirectXTK/Audio/SoundEffect.cpp @@ -0,0 +1,620 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "WAVFileReader.h" +#include "SoundCommon.h" + +#include + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#endif + +using namespace DirectX; + + +//====================================================================================== +// SoundEffect +//====================================================================================== + +// Internal object implementation class. +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 + { + assert( mEngine != 0 ); + mEngine->RegisterNotify( this, false ); + } + + virtual ~Impl() + { + if ( !mInstances.empty() ) + { + DebugTrace( "WARNING: Destroying SoundEffect with %Iu outstanding SoundEffectInstances\n", mInstances.size() ); + + for( auto it = mInstances.begin(); it != mInstances.end(); ++it ) + { + assert( *it != 0 ); + (*it)->OnDestroyParent(); + } + + mInstances.clear(); + } + + if ( mOneShots > 0 ) + { + DebugTrace( "WARNING: Destroying SoundEffect with %u outstanding one shot effects\n", mOneShots ); + } + + if ( mEngine ) + { + mEngine->UnregisterNotify( this, true, false ); + mEngine = nullptr; + } + +#if defined(_XBOX_ONE) && defined(_TITLE) + if ( mXMAMemory ) + { + ApuFree( mXMAMemory ); + mXMAMemory = nullptr; + } +#endif + } + + HRESULT Initialize( _In_ AudioEngine* engine, _Inout_ std::unique_ptr& 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 ); + + // IVoiceNotify + virtual void __cdecl OnBufferEnd() override + { + InterlockedDecrement( &mOneShots ); + } + + virtual void __cdecl OnCriticalError() override + { + mOneShots = 0; + } + + virtual void __cdecl OnReset() override + { + // No action required + } + + virtual void __cdecl OnUpdate() override + { + // We do not register for update notification + assert(false); + } + + virtual void __cdecl OnDestroyEngine() override + { + mEngine = nullptr; + mOneShots = 0; + } + + virtual void __cdecl OnTrim() override + { + // No action required + } + + virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const override + { + stats.playingOneShots += mOneShots; + stats.audioBytes += mAudioBytes; + +#if defined(_XBOX_ONE) && defined(_TITLE) + if ( mXMAMemory ) + stats.xmaAudioBytes += mAudioBytes; +#endif + } + + const WAVEFORMATEX* mWaveFormat; + const uint8_t* mStartAudio; + uint32_t mAudioBytes; + uint32_t mLoopStart; + uint32_t mLoopLength; + AudioEngine* mEngine; + std::list mInstances; + uint32_t mOneShots; + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10) + uint32_t mSeekCount; + const uint32_t* mSeekTable; +#endif + +private: + std::unique_ptr mWavData; + +#if defined(_XBOX_ONE) && defined(_TITLE) + void* mXMAMemory; +#endif +}; + + +_Use_decl_annotations_ +HRESULT SoundEffect::Impl::Initialize( AudioEngine* engine, std::unique_ptr& 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 ) + return E_INVALIDARG; + +#ifdef _M_X64 + if ( audioBytes > 0xFFFFFFFF ) + return E_INVALIDARG; +#endif + + 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() ); + + // 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) + + case WAVE_FORMAT_WMAUDIO2: + case WAVE_FORMAT_WMAUDIO3: + if ( !seekCount || !seekTable ) + { + DebugTrace( "ERROR: SoundEffect format xWMA requires seek table\n" ); + return E_FAIL; + } + +#ifdef _M_X64 + if ( seekCount > 0xFFFFFFFF ) + return E_INVALIDARG; +#endif + + // 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( 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; + } + +#ifdef _M_X64 + if ( seekCount > 0xFFFFFFFF ) + return E_INVALIDARG; +#endif + + { + HRESULT hr = ApuAlloc( &mXMAMemory, nullptr, + static_cast( 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; + } + } + + memcpy( mXMAMemory, startAudio, audioBytes ); + mStartAudio = reinterpret_cast( mXMAMemory ); + + mWavData.reset( new uint8_t[ sizeof(XMA2WAVEFORMATEX) + ( seekCount * sizeof(uint32_t) ) ] ); + + memcpy( mWavData.get(), wfx, sizeof(XMA2WAVEFORMATEX) ); + mWaveFormat = reinterpret_cast( mWavData.get() ); + + // XMA seek table is Big-Endian + { + auto dest = reinterpret_cast( mWavData.get() + sizeof(XMA2WAVEFORMATEX) ); + for( size_t k = 0; k < seekCount; ++k ) + { + dest[ k ] = _byteswap_ulong( seekTable[ k ]) ; + } + } + + mSeekCount = static_cast( seekCount ); + mSeekTable = reinterpret_cast( 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 ); + } + } + + mAudioBytes = static_cast( audioBytes ); + mLoopStart = loopStart; + mLoopLength = loopLength; + + return S_OK; +} + + +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 ); + + IXAudio2SourceVoice* voice = nullptr; + mEngine->AllocateVoice( mWaveFormat, SoundEffectInstance_Default, true, &voice ); + + if ( !voice ) + return; + + if ( volume != 1.f ) + { + HRESULT hr = voice->SetVolume( volume ); + ThrowIfFailed( hr ); + } + + if ( pitch != 0.f ) + { + float fr = XAudio2SemitonesToFrequencyRatio( pitch * 12.f ); + + HRESULT hr = voice->SetFrequencyRatio( fr ); + ThrowIfFailed( hr ); + } + + 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 ); + } + } + + HRESULT hr = voice->Start( 0 ); + ThrowIfFailed( hr ); + + XAUDIO2_BUFFER buffer; + memset( &buffer, 0, sizeof(buffer) ); + buffer.AudioBytes = mAudioBytes; + buffer.pAudioData = mStartAudio; + buffer.Flags = XAUDIO2_END_OF_STREAM; + buffer.pContext = this; + +#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 ) + { + XAUDIO2_BUFFER_WMA wmaBuffer; + memset( &wmaBuffer, 0, sizeof(wmaBuffer) ); + + wmaBuffer.PacketCount = mSeekCount; + wmaBuffer.pDecodedPacketCumulativeBytes = mSeekTable; + + hr = voice->SubmitSourceBuffer( &buffer, &wmaBuffer ); + } + else +#endif + { + hr = voice->SubmitSourceBuffer( &buffer, nullptr ); + } + 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" ); + } + + InterlockedIncrement( &mOneShots ); +} + + +//-------------------------------------------------------------------------------------- +// SoundEffect +//-------------------------------------------------------------------------------------- + +// Public constructors. +_Use_decl_annotations_ +SoundEffect::SoundEffect( AudioEngine* engine, const wchar_t* waveFileName ) + : pImpl(new Impl(engine) ) +{ + WAVData wavInfo; + std::unique_ptr wavData; + 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" ); + } + +#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 ); +#else + hr = pImpl->Initialize( engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes, + wavInfo.loopStart, wavInfo.loopLength ); +#endif + + if ( FAILED(hr) ) + { + 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& wavData, + const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes ) + : pImpl(new 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 ); +#else + HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, 0, 0 ); +#endif + if ( FAILED(hr) ) + { + DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize\n", hr ); + throw std::exception( "SoundEffect" ); + } +} + + +_Use_decl_annotations_ +SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr& wavData, + const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes, + uint32_t loopStart, uint32_t loopLength ) + : pImpl(new 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 ); +#else + HRESULT hr = pImpl->Initialize( engine, wavData, wfx, startAudio, audioBytes, loopStart, loopLength ); +#endif + if ( FAILED(hr) ) + { + DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize\n", hr ); + throw std::exception( "SoundEffect" ); + } +} + + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10) + +_Use_decl_annotations_ +SoundEffect::SoundEffect( AudioEngine* engine, std::unique_ptr& 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) ) + { + DebugTrace( "ERROR: SoundEffect failed (%08X) to intialize\n", hr ); + throw std::exception( "SoundEffect" ); + } +} + +#endif + + +// Move constructor. +SoundEffect::SoundEffect(SoundEffect&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +SoundEffect& SoundEffect::operator= (SoundEffect&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +SoundEffect::~SoundEffect() +{ +} + + +// Public methods. +void SoundEffect::Play() +{ + pImpl->Play( 1.f, 0.f, 0.f ); +} + + +void SoundEffect::Play( float volume, float pitch, float pan ) +{ + pImpl->Play( volume, pitch, pan ); +} + + +std::unique_ptr 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( effect ); +} + + +void SoundEffect::UnregisterInstance( _In_ SoundEffectInstance* instance ) +{ + auto it = std::find( pImpl->mInstances.begin(), pImpl->mInstances.end(), instance ); + if ( it == pImpl->mInstances.end() ) + return; + + pImpl->mInstances.erase( it ); +} + + +// Public accessors. +bool SoundEffect::IsInUse() const +{ + return ( pImpl->mOneShots > 0 ) || !pImpl->mInstances.empty(); +} + + +size_t SoundEffect::GetSampleSizeInBytes() const +{ + return pImpl->mAudioBytes; +} + + +size_t SoundEffect::GetSampleDuration() const +{ + if ( !pImpl->mWaveFormat || !pImpl->mWaveFormat->nChannels ) + return 0; + + switch( GetFormatTag( pImpl->mWaveFormat ) ) + { + case WAVE_FORMAT_ADPCM: + { + auto adpcmFmt = reinterpret_cast( pImpl->mWaveFormat ); + + uint64_t duration = uint64_t( pImpl->mAudioBytes / adpcmFmt->wfx.nBlockAlign ) * adpcmFmt->wSamplesPerBlock; + int partial = pImpl->mAudioBytes % adpcmFmt->wfx.nBlockAlign; + if ( partial ) + { + if ( partial >= ( 7 * adpcmFmt->wfx.nChannels ) ) + duration += ( partial * 2 / adpcmFmt->wfx.nChannels - 12 ); + } + return static_cast( duration ); + } + +#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; + +#endif + +#if defined(_XBOX_ONE) && defined(_TITLE) + + case WAVE_FORMAT_XMA2: + return reinterpret_cast( pImpl->mWaveFormat )->SamplesEncoded; + +#endif + + default: + if ( pImpl->mWaveFormat->wBitsPerSample > 0 ) + { + return static_cast( ( uint64_t( pImpl->mAudioBytes ) * 8 ) + / uint64_t( pImpl->mWaveFormat->wBitsPerSample * pImpl->mWaveFormat->nChannels ) ); + } + } + + return 0; +} + + +size_t SoundEffect::GetSampleDurationMS() const +{ + if ( !pImpl->mWaveFormat || !pImpl->mWaveFormat->nSamplesPerSec ) + return 0; + + uint64_t samples = GetSampleDuration(); + return static_cast( ( samples * 1000 ) / pImpl->mWaveFormat->nSamplesPerSec ); +} + + +const WAVEFORMATEX* SoundEffect::GetFormat() const +{ + return pImpl->mWaveFormat; +} + + +#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 +{ + 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 ) + { + wmaBuffer.PacketCount = pImpl->mSeekCount; + wmaBuffer.pDecodedPacketCumulativeBytes = pImpl->mSeekTable; + return true; + } + + return false; +} + +#else + +void SoundEffect::FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer ) const +{ + memset( &buffer, 0, sizeof(buffer) ); + buffer.AudioBytes = pImpl->mAudioBytes; + buffer.pAudioData = pImpl->mStartAudio; + buffer.LoopBegin = pImpl->mLoopStart; + buffer.LoopLength = pImpl->mLoopLength; +} + +#endif diff --git a/Kits/DirectXTK/Audio/SoundEffectInstance.cpp b/Kits/DirectXTK/Audio/SoundEffectInstance.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d1add351e388177b77dd9b8299aef7417d789d9e --- /dev/null +++ b/Kits/DirectXTK/Audio/SoundEffectInstance.cpp @@ -0,0 +1,334 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "SoundCommon.h" + +using namespace DirectX; + + +//====================================================================================== +// SoundEffectInstance +//====================================================================================== + +// Internal object implementation class. +class SoundEffectInstance::Impl : public IVoiceNotify +{ +public: + Impl( _In_ AudioEngine* engine, _In_ SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags ) : + mBase(), + mEffect( effect ), + mWaveBank( nullptr ), + mIndex( 0 ), + mLooped( false ) + { + assert( engine != 0 ); + engine->RegisterNotify( this, false ); + + assert( mEffect != 0 ); + mBase.Initialize( engine, effect->GetFormat(), 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 ) + { + assert( engine != 0 ); + engine->RegisterNotify( this, false ); + + char buff[64]; + auto wfx = reinterpret_cast( buff ); + assert( mWaveBank != 0 ); + mBase.Initialize( engine, mWaveBank->GetFormat( index, wfx, 64 ), flags ); + } + + virtual ~Impl() + { + mBase.DestroyVoice(); + + if ( mBase.engine ) + { + mBase.engine->UnregisterNotify( this, false, false ); + mBase.engine = nullptr; + } + } + + 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 ); + } + + virtual void __cdecl OnCriticalError() override + { + mBase.OnCriticalError(); + } + + virtual void __cdecl OnReset() override + { + mBase.OnReset(); + } + + virtual void __cdecl OnUpdate() override + { + // We do not register for update notification + assert(false); + } + + virtual void __cdecl OnDestroyEngine() override + { + mBase.OnDestroy(); + } + + virtual void __cdecl OnTrim() override + { + mBase.OnTrim(); + } + + virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const override + { + mBase.GatherStatistics(stats); + } + + SoundEffectInstanceBase mBase; + SoundEffect* mEffect; + WaveBank* mWaveBank; + uint32_t mIndex; + bool mLooped; +}; + + +void SoundEffectInstance::Impl::Play( bool loop ) +{ + if ( !mBase.voice ) + { + if ( mWaveBank ) + { + char buff[64]; + auto wfx = reinterpret_cast( buff ); + mBase.AllocateVoice( mWaveBank->GetFormat( mIndex, wfx, 64) ); + } + else + { + assert( mEffect != 0 ); + mBase.AllocateVoice( mEffect->GetFormat() ); + } + } + + if ( !mBase.Play() ) + return; + + // Submit audio data for STOPPED -> PLAYING state transition + XAUDIO2_BUFFER buffer; + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10) + + bool iswma = false; + XAUDIO2_BUFFER_WMA wmaBuffer; + if ( mWaveBank ) + { + iswma = mWaveBank->FillSubmitBuffer( mIndex, buffer, wmaBuffer ); + } + else + { + assert( mEffect != 0 ); + iswma = mEffect->FillSubmitBuffer( buffer, wmaBuffer ); + } + +#else + + if ( mWaveBank ) + { + mWaveBank->FillSubmitBuffer( mIndex, buffer ); + } + else + { + assert( mEffect != 0 ); + mEffect->FillSubmitBuffer( buffer ); + } + +#endif + + buffer.Flags = XAUDIO2_END_OF_STREAM; + if ( loop ) + { + mLooped = true; + buffer.LoopCount = XAUDIO2_LOOP_INFINITE; + } + else + { + mLooped = false; + buffer.LoopCount = buffer.LoopBegin = buffer.LoopLength = 0; + } + buffer.pContext = nullptr; + + HRESULT hr; +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10) + if ( iswma ) + { + hr = mBase.voice->SubmitSourceBuffer( &buffer, &wmaBuffer ); + } + else +#endif + { + hr = mBase.voice->SubmitSourceBuffer( &buffer, nullptr ); + } + + if ( FAILED(hr) ) + { +#ifdef _DEBUG + DebugTrace( "ERROR: SoundEffectInstance failed (%08X) when submitting buffer:\n", hr ); + + char buff[64]; + auto wfx = ( mWaveBank ) ? mWaveBank->GetFormat( mIndex, reinterpret_cast( buff ), 64 ) + : mEffect->GetFormat(); + + 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" ); + } +} + + +//-------------------------------------------------------------------------------------- +// SoundEffectInstance +//-------------------------------------------------------------------------------------- + +// Private constructors +_Use_decl_annotations_ +SoundEffectInstance::SoundEffectInstance( AudioEngine* engine, SoundEffect* effect, SOUND_EFFECT_INSTANCE_FLAGS flags ) : + pImpl( new 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 ) ) +{ +} + + +// Move constructor. +SoundEffectInstance::SoundEffectInstance(SoundEffectInstance&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +SoundEffectInstance& SoundEffectInstance::operator= (SoundEffectInstance&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +SoundEffectInstance::~SoundEffectInstance() +{ + if( pImpl ) + { + if ( pImpl->mWaveBank ) + { + pImpl->mWaveBank->UnregisterInstance( this ); + pImpl->mWaveBank = nullptr; + } + + if ( pImpl->mEffect ) + { + pImpl->mEffect->UnregisterInstance( this ); + pImpl->mEffect = nullptr; + } + } +} + + +// Public methods. +void SoundEffectInstance::Play( bool loop ) +{ + pImpl->Play( loop ); +} + + +void SoundEffectInstance::Stop( bool immediate ) +{ + pImpl->mBase.Stop( immediate, pImpl->mLooped ); +} + + +void SoundEffectInstance::Pause() +{ + pImpl->mBase.Pause(); +} + + +void SoundEffectInstance::Resume() +{ + pImpl->mBase.Resume(); +} + + +void SoundEffectInstance::SetVolume( float volume ) +{ + pImpl->mBase.SetVolume( volume ); +} + + +void SoundEffectInstance::SetPitch( float pitch ) +{ + pImpl->mBase.SetPitch( pitch ); +} + + +void SoundEffectInstance::SetPan( float pan ) +{ + pImpl->mBase.SetPan( pan ); +} + + +void SoundEffectInstance::Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords ) +{ + pImpl->mBase.Apply3D( listener, emitter, rhcoords ); +} + + +// Public accessors. +bool SoundEffectInstance::IsLooped() const +{ + return pImpl->mLooped; +} + + +SoundState SoundEffectInstance::GetState() +{ + return pImpl->mBase.GetState( true ); +} + + +// Notifications. +void SoundEffectInstance::OnDestroyParent() +{ + pImpl->mBase.OnDestroy(); + pImpl->mWaveBank = nullptr; + pImpl->mEffect = nullptr; +} \ No newline at end of file diff --git a/Kits/DirectXTK/Audio/WAVFileReader.cpp b/Kits/DirectXTK/Audio/WAVFileReader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ebd91af815c808850d37dac772edea9451c72b31 --- /dev/null +++ b/Kits/DirectXTK/Audio/WAVFileReader.cpp @@ -0,0 +1,688 @@ +//-------------------------------------------------------------------------------------- +// File: WAVFileReader.cpp +// +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//------------------------------------------------------------------------------------- + +#include "pch.h" +#include "PlatformHelpers.h" +#include "WAVFileReader.h" + +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'; + +#pragma pack(push,1) +struct RIFFChunk +{ + uint32_t tag; + uint32_t size; +}; + +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; + + 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; + + 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; + + 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; +}; +#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 const RIFFChunk* FindChunk( _In_reads_bytes_(sizeBytes) const uint8_t* data, _In_ size_t sizeBytes, _In_ uint32_t tag ) +{ + if ( !data ) + return nullptr; + + const uint8_t* ptr = data; + const uint8_t* end = data + sizeBytes; + + while ( end > ( ptr + sizeof(RIFFChunk) ) ) + { + auto header = reinterpret_cast( ptr ); + if ( header->tag == tag ) + return header; + + ptrdiff_t offset = header->size + sizeof(RIFFChunk); + ptr += offset; + } + + return nullptr; +} + + +//-------------------------------------------------------------------------------------- +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 ) + return E_POINTER; + + dpds = seek = false; + + if (wavDataSize < (sizeof(RIFFChunk)*2 + sizeof(uint32_t) + sizeof(WAVEFORMAT) ) ) + { + return E_FAIL; + } + + const uint8_t* wavEnd = wavData + wavDataSize; + + // Locate RIFF 'WAVE' + auto riffChunk = FindChunk( wavData, wavDataSize, FOURCC_RIFF_TAG ); + if ( !riffChunk || riffChunk->size < 4 ) + { + return E_FAIL; + } + + auto riffHeader = reinterpret_cast( riffChunk ); + if ( riffHeader->riff != FOURCC_WAVE_FILE_TAG && riffHeader->riff != FOURCC_XWMA_FILE_TAG ) + { + return E_FAIL; + } + + // Locate 'fmt ' + auto ptr = reinterpret_cast( riffHeader ) + sizeof(RIFFChunkHeader); + if ( ( ptr + sizeof(RIFFChunk) ) > wavEnd ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + auto fmtChunk = FindChunk( ptr, riffHeader->size, FOURCC_FORMAT_TAG ); + if ( !fmtChunk || fmtChunk->size < sizeof(PCMWAVEFORMAT) ) + { + return E_FAIL; + } + + ptr = reinterpret_cast( fmtChunk ) + sizeof( RIFFChunk ); + if ( ptr + fmtChunk->size > wavEnd ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + auto wf = reinterpret_cast( ptr ); + + // Validate WAVEFORMAT (focused on chunk size and format tag, not other data that XAUDIO2 will validate) + 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; + + default: + { + if ( fmtChunk->size < sizeof(WAVEFORMATEX) ) + { + return E_FAIL; + } + + auto wfx = reinterpret_cast( ptr ); + + if ( fmtChunk->size < ( sizeof(WAVEFORMATEX) + wfx->cbSize ) ) + { + return E_FAIL; + } + + switch( wfx->wFormatTag ) + { + 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( ptr ); + + if ( memcmp( reinterpret_cast(&wfex->SubFormat) + sizeof(DWORD), + reinterpret_cast(&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( riffHeader ) + sizeof(RIFFChunkHeader); + if ( ( ptr + sizeof(RIFFChunk) ) > wavEnd ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + auto dataChunk = FindChunk( ptr, riffChunk->size, FOURCC_DATA_TAG ); + if ( !dataChunk || !dataChunk->size ) + { + return HRESULT_FROM_WIN32( ERROR_INVALID_DATA ); + } + + ptr = reinterpret_cast( dataChunk ) + sizeof( RIFFChunk ); + if ( ptr + dataChunk->size > wavEnd ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + *pwfx = reinterpret_cast( wf ); + *pdata = ptr; + *dataSize = dataChunk->size; + return S_OK; +} + + +//-------------------------------------------------------------------------------------- +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 ) + return E_POINTER; + + if (wavDataSize < ( sizeof(RIFFChunk) + sizeof(uint32_t) ) ) + { + return E_FAIL; + } + + *pLoopStart = 0; + *pLoopLength = 0; + + const uint8_t* wavEnd = wavData + wavDataSize; + + // Locate RIFF 'WAVE' + auto riffChunk = FindChunk( wavData, wavDataSize, FOURCC_RIFF_TAG ); + if ( !riffChunk || riffChunk->size < 4 ) + { + return E_FAIL; + } + + auto riffHeader = reinterpret_cast( 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 ) + { + return E_FAIL; + } + + // Locate 'wsmp' (DLS Chunk) + auto ptr = reinterpret_cast( riffHeader ) + sizeof(RIFFChunkHeader); + if ( ( ptr + sizeof(RIFFChunk) ) > wavEnd ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + auto dlsChunk = FindChunk( ptr, riffChunk->size, FOURCC_DLS_SAMPLE ); + if ( dlsChunk ) + { + ptr = reinterpret_cast( dlsChunk ) + sizeof( RIFFChunk ); + if ( ptr + dlsChunk->size > wavEnd ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + if ( dlsChunk->size >= sizeof(RIFFDLSSample) ) + { + auto dlsSample = reinterpret_cast( ptr ); + + if ( dlsChunk->size >= ( dlsSample->size + dlsSample->loopCount * sizeof(DLSLoop) ) ) + { + auto loops = reinterpret_cast( 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 ) ) + { + // Return 'forward' loop + *pLoopStart = loops[j].loopStart; + *pLoopLength = loops[j].loopLength; + return S_OK; + } + } + } + } + } + + // Locate 'smpl' (Sample Chunk) + auto midiChunk = FindChunk( ptr, riffChunk->size, FOURCC_MIDI_SAMPLE ); + if ( midiChunk ) + { + ptr = reinterpret_cast( midiChunk ) + sizeof( RIFFChunk ); + if ( ptr + midiChunk->size > wavEnd ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + if ( midiChunk->size >= sizeof(RIFFMIDISample) ) + { + auto midiSample = reinterpret_cast( ptr ); + + if ( midiChunk->size >= ( sizeof(RIFFMIDISample) + midiSample->loopCount * sizeof(MIDILoop) ) ) + { + auto loops = reinterpret_cast( ptr + sizeof(RIFFMIDISample) ); + for( uint32_t j = 0; j < midiSample->loopCount; ++j ) + { + if ( loops[j].type == MIDILoop::LOOP_TYPE_FORWARD ) + { + // Return 'forward' loop + *pLoopStart = loops[j].start; + *pLoopLength = loops[j].end + loops[j].start + 1; + return S_OK; + } + } + } + } + } + + return S_OK; +} + + +//-------------------------------------------------------------------------------------- +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 ) + return E_POINTER; + + if (wavDataSize < ( sizeof(RIFFChunk) + sizeof(uint32_t) ) ) + { + return E_FAIL; + } + + *pData = nullptr; + *dataCount = 0; + + const uint8_t* wavEnd = wavData + wavDataSize; + + // Locate RIFF 'WAVE' + auto riffChunk = FindChunk( wavData, wavDataSize, FOURCC_RIFF_TAG ); + if ( !riffChunk || riffChunk->size < 4 ) + { + return E_FAIL; + } + + auto riffHeader = reinterpret_cast( riffChunk ); + if ( riffHeader->riff != FOURCC_WAVE_FILE_TAG && riffHeader->riff != FOURCC_XWMA_FILE_TAG ) + { + return E_FAIL; + } + + // Locate tag + auto ptr = reinterpret_cast( riffHeader ) + sizeof(RIFFChunkHeader); + if ( ( ptr + sizeof(RIFFChunk) ) > wavEnd ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + auto tableChunk = FindChunk( ptr, riffChunk->size, tag ); + if ( tableChunk ) + { + ptr = reinterpret_cast( tableChunk ) + sizeof( RIFFChunk ); + if ( ptr + tableChunk->size > wavEnd ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + if ( ( tableChunk->size % sizeof(uint32_t) ) != 0 ) + { + return E_FAIL; + } + + *pData = reinterpret_cast( ptr ); + *dataCount = tableChunk->size / 4; + } + + return S_OK; +} + + +//-------------------------------------------------------------------------------------- +static HRESULT LoadAudioFromFile( _In_z_ const wchar_t* szFileName, _Inout_ std::unique_ptr& wavData, _Out_ DWORD* bytesRead ) +{ + 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 ) ) ); +#else + ScopedHandle hFile( safe_handle( CreateFileW( szFileName, + GENERIC_READ, + FILE_SHARE_READ, + nullptr, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + nullptr ) ) ); +#endif + + if ( !hFile ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + // Get the file size + LARGE_INTEGER FileSize = { 0 }; + +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + FILE_STANDARD_INFO fileInfo; + if ( !GetFileInformationByHandleEx( hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo) ) ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + FileSize = fileInfo.EndOfFile; +#else + GetFileSizeEx( hFile.get(), &FileSize ); +#endif + + // File is too big for 32-bit allocation, so reject read + if (FileSize.HighPart > 0) + { + return E_FAIL; + } + + // Need at least enough data to have a valid minimal WAV file + if (FileSize.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[ FileSize.LowPart ] ); + if (!wavData) + { + return E_OUTOFMEMORY; + } + + // read the data in + if (!ReadFile( hFile.get(), + wavData.get(), + FileSize.LowPart, + bytesRead, + nullptr + )) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + return (*bytesRead < FileSize.LowPart) ? E_FAIL : S_OK; +} + + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +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 ) + return E_INVALIDARG; + + *wfx = nullptr; + *startAudio = nullptr; + *audioBytes = 0; + + // Need at least enough data to have a valid minimal WAV file + 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) ) + return hr; + + return (dpds || seek) ? E_FAIL : S_OK; +} + + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +HRESULT DirectX::LoadWAVAudioFromFile( const wchar_t* szFileName, + std::unique_ptr& wavData, + const WAVEFORMATEX** wfx, + const uint8_t** startAudio, + uint32_t* audioBytes ) +{ + if ( !szFileName || !wfx || !startAudio || !audioBytes ) + return E_INVALIDARG; + + *wfx = nullptr; + *startAudio = nullptr; + *audioBytes = 0; + + DWORD bytesRead = 0; + 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) ) + return hr; + + return (dpds || seek) ? E_FAIL : S_OK; +} + + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +HRESULT DirectX::LoadWAVAudioInMemoryEx( const uint8_t* wavData, size_t wavDataSize, DirectX::WAVData& result ) +{ + if ( !wavData ) + return E_INVALIDARG; + + 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) ) ) + { + return E_FAIL; + } + + bool dpds, seek; + 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) ) + return hr; + + if ( dpds ) + { + hr = WaveFindTable( wavData, wavDataSize, FOURCC_XWMA_DPDS, &result.seek, &result.seekCount ); + if ( FAILED(hr) ) + return hr; + } + else if ( seek ) + { + hr = WaveFindTable( wavData, wavDataSize, FOURCC_XMA_SEEK, &result.seek, &result.seekCount ); + if ( FAILED(hr) ) + return hr; + } + + return S_OK; +} + + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +HRESULT DirectX::LoadWAVAudioFromFileEx( const wchar_t* szFileName, std::unique_ptr& wavData, DirectX::WAVData& result ) +{ + if ( !szFileName ) + return E_INVALIDARG; + + memset( &result, 0, sizeof(result) ); + + DWORD bytesRead = 0; + 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) ) + return hr; + + hr = WaveFindLoopInfo( wavData.get(), bytesRead, &result.loopStart, &result.loopLength ); + if ( FAILED(hr) ) + return hr; + + if ( dpds ) + { + hr = WaveFindTable( wavData.get(), bytesRead, FOURCC_XWMA_DPDS, &result.seek, &result.seekCount ); + if ( FAILED(hr) ) + return hr; + } + else if ( seek ) + { + hr = WaveFindTable( wavData.get(), bytesRead, FOURCC_XMA_SEEK, &result.seek, &result.seekCount ); + if ( FAILED(hr) ) + return hr; + } + + return S_OK; +} + diff --git a/Kits/DirectXTK/Audio/WAVFileReader.h b/Kits/DirectXTK/Audio/WAVFileReader.h new file mode 100644 index 0000000000000000000000000000000000000000..06067d8a708e3cbb47954e851abd951ce6c688e1 --- /dev/null +++ b/Kits/DirectXTK/Audio/WAVFileReader.h @@ -0,0 +1,59 @@ +//-------------------------------------------------------------------------------------- +// File: WAVFileReader.h +// +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//------------------------------------------------------------------------------------- + +#pragma once + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +#include +#include +#include + + +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 LoadWAVAudioFromFile( _In_z_ const wchar_t* szFileName, + _Inout_ std::unique_ptr& wavData, + _Outptr_ const WAVEFORMATEX** wfx, + _Outptr_ const uint8_t** startAudio, + _Out_ uint32_t* audioBytes ); + + struct WAVData + { + const WAVEFORMATEX* wfx; + const uint8_t* startAudio; + uint32_t audioBytes; + uint32_t loopStart; + uint32_t loopLength; + const uint32_t* seek; // Note: XMA Seek data is Big-Endian + uint32_t seekCount; + }; + + 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& wavData, + _Out_ WAVData& result ); +} \ No newline at end of file diff --git a/Kits/DirectXTK/Audio/WaveBank.cpp b/Kits/DirectXTK/Audio/WaveBank.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d67fd4e88cc4bc4183f5860f93dfbffffbc04383 --- /dev/null +++ b/Kits/DirectXTK/Audio/WaveBank.cpp @@ -0,0 +1,514 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Audio.h" +#include "WaveBankReader.h" +#include "SoundCommon.h" +#include "PlatformHelpers.h" + +#include + +using namespace DirectX; + + +//====================================================================================== +// WaveBank +//====================================================================================== + +// Internal object implementation class. +class WaveBank::Impl : public IVoiceNotify +{ +public: + explicit Impl( _In_ AudioEngine* engine ) : + mEngine( engine ), + mOneShots( 0 ), + mPrepared( false ), + mStreaming( false ) + { + assert( mEngine != 0 ); + mEngine->RegisterNotify( this, false ); + } + + virtual ~Impl() + { + if ( !mInstances.empty() ) + { + DebugTrace( "WARNING: Destroying WaveBank \"%hs\" with %Iu outstanding SoundEffectInstances\n", mReader.BankName(), mInstances.size() ); + + for( auto it = mInstances.begin(); it != mInstances.end(); ++it ) + { + assert( *it != 0 ); + (*it)->OnDestroyParent(); + } + + mInstances.clear(); + } + + if ( mOneShots > 0 ) + { + DebugTrace( "WARNING: Destroying WaveBank \"%hs\" with %u outstanding one shot effects\n", mReader.BankName(), mOneShots ); + } + + if ( mEngine ) + { + mEngine->UnregisterNotify( this, true, false ); + mEngine = nullptr; + } + } + + HRESULT Initialize( _In_ AudioEngine* engine, _In_z_ const wchar_t* wbFileName ); + + void Play( int index, float volume, float pitch, float pan ); + + // IVoiceNotify + virtual void __cdecl OnBufferEnd() override + { + InterlockedDecrement( &mOneShots ); + } + + virtual void __cdecl OnCriticalError() override + { + mOneShots = 0; + } + + virtual void __cdecl OnReset() override + { + // No action required + } + + virtual void __cdecl OnUpdate() override + { + // We do not register for update notification + assert(false); + } + + virtual void __cdecl OnDestroyEngine() override + { + mEngine = nullptr; + mOneShots = 0; + } + + virtual void __cdecl OnTrim() override + { + // No action required + } + + virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const override + { + stats.playingOneShots += mOneShots; + + if ( !mStreaming ) + { + stats.audioBytes += mReader.BankAudioSize(); + +#if defined(_XBOX_ONE) && defined(_TITLE) + if ( mReader.HasXMA() ) + stats.xmaAudioBytes += mReader.BankAudioSize(); +#endif + } + } + + AudioEngine* mEngine; + std::list mInstances; + WaveBankReader mReader; + uint32_t mOneShots; + bool mPrepared; + bool mStreaming; +}; + + +_Use_decl_annotations_ +HRESULT WaveBank::Impl::Initialize( AudioEngine* engine, const wchar_t* wbFileName ) +{ + if ( !engine || !wbFileName ) + return E_INVALIDARG; + + HRESULT hr = mReader.Open( wbFileName ); + if ( FAILED(hr) ) + return hr; + + mStreaming = mReader.IsStreamingBank(); + + return S_OK; +} + + +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 ); + + if ( mStreaming ) + { + 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() ) + { + DebugTrace( "WARNING: Index %d not found in wave bank with only %u entries, one-shot not triggered\n", index, mReader.Count() ); + return; + } + + if ( !mPrepared ) + { + mReader.WaitOnPrepare(); + mPrepared = true; + } + + char wfxbuff[64]; + auto wfx = reinterpret_cast( wfxbuff ); + HRESULT hr = mReader.GetFormat( index, wfx, 64 ); + ThrowIfFailed( hr ); + + IXAudio2SourceVoice* voice = nullptr; + mEngine->AllocateVoice( wfx, SoundEffectInstance_Default, true, &voice ); + + if ( !voice ) + return; + + if ( volume != 1.f ) + { + hr = voice->SetVolume( volume ); + ThrowIfFailed( hr ); + } + + if ( pitch != 0.f ) + { + float fr = XAudio2SemitonesToFrequencyRatio( pitch * 12.f ); + + hr = voice->SetFrequencyRatio( fr ); + ThrowIfFailed( hr ); + } + + if ( pan != 0.f ) + { + float matrix[16]; + if ( ComputePan( pan, wfx->nChannels, matrix ) ) + { + hr = voice->SetOutputMatrix( nullptr, wfx->nChannels, mEngine->GetOutputChannels(), matrix ); + ThrowIfFailed( hr ); + } + } + + hr = voice->Start( 0 ); + ThrowIfFailed( hr ); + + XAUDIO2_BUFFER buffer; + memset( &buffer, 0, sizeof(buffer) ); + + hr = mReader.GetWaveData( index, &buffer.pAudioData, buffer.AudioBytes ); + ThrowIfFailed( hr ); + + WaveBankReader::Metadata metadata; + hr = mReader.GetMetadata( index, metadata ); + ThrowIfFailed( hr ); + + buffer.Flags = XAUDIO2_END_OF_STREAM; + buffer.pContext = this; + +#if defined(_XBOX_ONE) || (_WIN32_WINNT < _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN10) + + XAUDIO2_BUFFER_WMA wmaBuffer; + memset( &wmaBuffer, 0, sizeof(wmaBuffer) ); + + uint32_t tag; + hr = mReader.GetSeekTable( index, &wmaBuffer.pDecodedPacketCumulativeBytes, wmaBuffer.PacketCount, tag ); + ThrowIfFailed( hr ); + + if ( tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3 ) + { + hr = voice->SubmitSourceBuffer( &buffer, &wmaBuffer ); + } + else +#endif + { + hr = voice->SubmitSourceBuffer( &buffer, nullptr ); + } + 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" ); + } + + InterlockedIncrement( &mOneShots ); +} + + +//-------------------------------------------------------------------------------------- +// WaveBank +//-------------------------------------------------------------------------------------- + +// Public constructors. +_Use_decl_annotations_ +WaveBank::WaveBank( AudioEngine* engine, const wchar_t* wbFileName ) + : pImpl(new Impl(engine) ) +{ + 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( "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)) +{ +} + + +// Move assignment. +WaveBank& WaveBank::operator= (WaveBank&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +WaveBank::~WaveBank() +{ +} + + +// Public methods. +void WaveBank::Play( int index ) +{ + pImpl->Play( index, 1.f, 0.f, 0.f ); +} + + +void WaveBank::Play( int index, float volume, float pitch, float pan ) +{ + pImpl->Play( index, volume, pitch, pan ); +} + + +void WaveBank::Play( _In_z_ const char* name ) +{ + int index = static_cast( pImpl->mReader.Find( name ) ); + if ( index == -1 ) + { + 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 ); +} + + +void WaveBank::Play( _In_z_ const char* name, float volume, float pitch, float pan ) +{ + int index = static_cast( pImpl->mReader.Find( name ) ); + if ( index == -1 ) + { + DebugTrace( "WARNING: Name '%hs' not found in wave bank, one-shot not triggered\n", name ); + return; + } + + pImpl->Play( index, volume, pitch, pan ); +} + + +std::unique_ptr WaveBank::CreateInstance( int index, SOUND_EFFECT_INSTANCE_FLAGS flags ) +{ + auto& wb = pImpl->mReader; + + if ( pImpl->mStreaming ) + { + 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() ) + { + // We don't throw an exception here as titles often simply ignore missing assets rather than fail + return std::unique_ptr(); + } + + 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( effect ); +} + + +std::unique_ptr WaveBank::CreateInstance( _In_z_ const char* name, SOUND_EFFECT_INSTANCE_FLAGS flags ) +{ + int index = static_cast( 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(); + } + + return CreateInstance( index, flags ); +} + + +void WaveBank::UnregisterInstance( _In_ SoundEffectInstance* instance ) +{ + auto it = std::find( pImpl->mInstances.begin(), pImpl->mInstances.end(), instance ); + if ( it == pImpl->mInstances.end() ) + return; + + pImpl->mInstances.erase( it ); +} + + +// Public accessors. +bool WaveBank::IsPrepared() const +{ + if ( pImpl->mPrepared ) + return true; + + if ( !pImpl->mReader.IsPrepared() ) + return false; + + pImpl->mPrepared = true; + return true; +} + + +bool WaveBank::IsInUse() const +{ + return ( pImpl->mOneShots > 0 ) || !pImpl->mInstances.empty(); +} + + +bool WaveBank::IsStreamingBank() const +{ + return pImpl->mReader.IsStreamingBank(); +} + + +size_t WaveBank::GetSampleSizeInBytes( int index ) const +{ + if ( index < 0 || uint32_t(index) >= pImpl->mReader.Count() ) + return 0; + + WaveBankReader::Metadata metadata; + HRESULT hr = pImpl->mReader.GetMetadata( index, metadata ); + ThrowIfFailed( hr ); + return metadata.lengthBytes; +} + + +size_t WaveBank::GetSampleDuration( int index ) const +{ + if ( index < 0 || uint32_t(index) >= pImpl->mReader.Count() ) + return 0; + + WaveBankReader::Metadata metadata; + HRESULT hr = pImpl->mReader.GetMetadata( index, metadata ); + ThrowIfFailed( hr ); + return metadata.duration; +} + + +size_t WaveBank::GetSampleDurationMS( int index ) const +{ + if ( index < 0 || uint32_t(index) >= pImpl->mReader.Count() ) + return 0; + + char buff[64]; + auto wfx = reinterpret_cast( buff ); + HRESULT hr = pImpl->mReader.GetFormat( index, wfx, 64 ); + ThrowIfFailed( hr ); + + WaveBankReader::Metadata metadata; + hr = pImpl->mReader.GetMetadata( index, metadata ); + ThrowIfFailed( hr ); + return static_cast( ( uint64_t(metadata.duration) * 1000 ) / wfx->nSamplesPerSec ); +} + + +_Use_decl_annotations_ +const WAVEFORMATEX* WaveBank::GetFormat( int index, WAVEFORMATEX* wfx, size_t maxsize ) const +{ + if ( index < 0 || uint32_t(index) >= pImpl->mReader.Count() ) + return nullptr; + + HRESULT hr = pImpl->mReader.GetFormat( index, wfx, maxsize ); + ThrowIfFailed( hr ); + return wfx; +} + + +_Use_decl_annotations_ +int WaveBank::Find( const char* name ) const +{ + return static_cast( 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 +{ + memset( &buffer, 0, sizeof(buffer) ); + memset( &wmaBuffer, 0, sizeof(wmaBuffer) ); + + HRESULT hr = pImpl->mReader.GetWaveData( index, &buffer.pAudioData, buffer.AudioBytes ); + ThrowIfFailed( hr ); + + WaveBankReader::Metadata metadata; + 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 ); + + return ( tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3 ); +} + +#else + +_Use_decl_annotations_ +void WaveBank::FillSubmitBuffer( int index, XAUDIO2_BUFFER& buffer ) const +{ + memset( &buffer, 0, sizeof(buffer) ); + + HRESULT hr = pImpl->mReader.GetWaveData( index, &buffer.pAudioData, buffer.AudioBytes ); + ThrowIfFailed( hr ); + + WaveBankReader::Metadata metadata; + hr = pImpl->mReader.GetMetadata( index, metadata ); + ThrowIfFailed( hr ); + + buffer.LoopBegin = metadata.loopStart; + buffer.LoopLength = metadata.loopLength; +} + +#endif diff --git a/Kits/DirectXTK/Audio/WaveBankReader.cpp b/Kits/DirectXTK/Audio/WaveBankReader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..087d6b49748550595e5d015a2449479695813a43 --- /dev/null +++ b/Kits/DirectXTK/Audio/WaveBankReader.cpp @@ -0,0 +1,1384 @@ +//-------------------------------------------------------------------------------------- +// File: WaveBankReader.cpp +// +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//------------------------------------------------------------------------------------- + +#include "pch.h" +#include "WaveBankReader.h" +#include "Audio.h" +#include "PlatformHelpers.h" + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#endif + + +namespace +{ + +//-------------------------------------------------------------------------------------- +#pragma pack(push, 1) + +static const size_t DVD_SECTOR_SIZE = 2048; +static const size_t DVD_BLOCK_SIZE = DVD_SECTOR_SIZE * 16; + +static const size_t ALIGNMENT_MIN = 4; +static const size_t ALIGNMENT_DVD = DVD_SECTOR_SIZE; + +static const size_t MAX_DATA_SEGMENT_SIZE = 0xFFFFFFFF; +static const size_t MAX_COMPACT_DATA_SEGMENT_SIZE = 0x001FFFFF; + +struct REGION +{ + uint32_t dwOffset; // Region offset, in bytes. + uint32_t dwLength; // Region length, in bytes. + + void BigEndian() + { + dwOffset = _byteswap_ulong( dwOffset ); + dwLength = _byteswap_ulong( dwLength ); + } +}; + +struct SAMPLEREGION +{ + uint32_t dwStartSample; // Start sample for the region. + uint32_t dwTotalSamples; // Region length in samples. + + void BigEndian() + { + dwStartSample = _byteswap_ulong( dwStartSample ); + dwTotalSamples = _byteswap_ulong( dwTotalSamples ); + } +}; + +struct HEADER +{ + static const uint32_t SIGNATURE = 'DNBW'; + static const uint32_t BE_SIGNATURE = 'WBND'; + static const uint32_t VERSION = 44; + + enum SEGIDX + { + SEGIDX_BANKDATA = 0, // Bank data + SEGIDX_ENTRYMETADATA, // Entry meta-data + SEGIDX_SEEKTABLES, // Storage for seek tables for the encoded waves. + SEGIDX_ENTRYNAMES, // Entry friendly names + SEGIDX_ENTRYWAVEDATA, // Entry wave data + SEGIDX_COUNT + }; + + uint32_t dwSignature; // File signature + uint32_t dwVersion; // Version of the tool that created the file + uint32_t dwHeaderVersion; // Version of the file format + REGION Segments[SEGIDX_COUNT]; // Segment lookup table + + void BigEndian() + { + // Leave dwSignature alone as indicator of BE vs. LE + + dwVersion = _byteswap_ulong( dwVersion ); + dwHeaderVersion =_byteswap_ulong( dwHeaderVersion ); + for( size_t j = 0; j < SEGIDX_COUNT; ++j ) + { + Segments[j].BigEndian(); + } + } +}; + +#pragma warning( disable : 4201 4203 ) + +union MINIWAVEFORMAT +{ + static const uint32_t TAG_PCM = 0x0; + static const uint32_t TAG_XMA = 0x1; + static const uint32_t TAG_ADPCM = 0x2; + static const uint32_t TAG_WMA = 0x3; + + static const uint32_t BITDEPTH_8 = 0x0; // PCM only + static const uint32_t BITDEPTH_16 = 0x1; // PCM only + + static const size_t ADPCM_BLOCKALIGN_CONVERSION_OFFSET = 22; + + struct + { + uint32_t wFormatTag : 2; // Format tag + uint32_t nChannels : 3; // Channel count (1 - 6) + uint32_t nSamplesPerSec : 18; // Sampling rate + uint32_t wBlockAlign : 8; // Block alignment. For WMA, lower 6 bits block alignment index, upper 2 bits bytes-per-second index. + uint32_t wBitsPerSample : 1; // Bits per sample (8 vs. 16, PCM only); WMAudio2/WMAudio3 (for WMA) + }; + + uint32_t dwValue; + + void BigEndian() + { + dwValue = _byteswap_ulong( dwValue ); + } + + WORD BitsPerSample() const + { + if (wFormatTag == TAG_XMA) + return 16; // XMA_OUTPUT_SAMPLE_BITS == 16 + if (wFormatTag == TAG_WMA) + return 16; + if (wFormatTag == TAG_ADPCM) + return 4; // MSADPCM_BITS_PER_SAMPLE == 4 + + // wFormatTag must be TAG_PCM (2 bits can only represent 4 different values) + return (wBitsPerSample == BITDEPTH_16) ? 16 : 8; + } + + DWORD BlockAlign() const + { + switch (wFormatTag) + { + case TAG_PCM: + return wBlockAlign; + + case TAG_XMA: + return (nChannels * 16 / 8); // XMA_OUTPUT_SAMPLE_BITS = 16 + + case TAG_ADPCM: + return (wBlockAlign + ADPCM_BLOCKALIGN_CONVERSION_OFFSET) * nChannels; + + case TAG_WMA: + { + static const uint32_t aWMABlockAlign[] = + { + 929, + 1487, + 1280, + 2230, + 8917, + 8192, + 4459, + 5945, + 2304, + 1536, + 1485, + 1008, + 2731, + 4096, + 6827, + 5462, + 1280 + }; + + uint32_t dwBlockAlignIndex = wBlockAlign & 0x1F; + if ( dwBlockAlignIndex < _countof(aWMABlockAlign) ) + return aWMABlockAlign[dwBlockAlignIndex]; + } + break; + } + + return 0; + } + + DWORD AvgBytesPerSec() const + { + switch (wFormatTag) + { + case TAG_PCM: + return nSamplesPerSec * wBlockAlign; + + case TAG_XMA: + return nSamplesPerSec * BlockAlign(); + + case TAG_ADPCM: + { + uint32_t blockAlign = BlockAlign(); + uint32_t samplesPerAdpcmBlock = AdpcmSamplesPerBlock(); + return blockAlign * nSamplesPerSec / samplesPerAdpcmBlock; + } + break; + + case TAG_WMA: + { + static const uint32_t aWMAAvgBytesPerSec[] = + { + 12000, + 24000, + 4000, + 6000, + 8000, + 20000, + 2500 + }; + // bitrate = entry * 8 + + uint32_t dwBytesPerSecIndex = wBlockAlign >> 5; + if ( dwBytesPerSecIndex < _countof(aWMAAvgBytesPerSec) ) + return aWMAAvgBytesPerSec[dwBytesPerSecIndex]; + } + break; + } + + return 0; + } + + DWORD AdpcmSamplesPerBlock() const + { + uint32_t nBlockAlign = (wBlockAlign + ADPCM_BLOCKALIGN_CONVERSION_OFFSET) * nChannels; + return nBlockAlign * 2 / (uint32_t)nChannels - 12; + } + + void AdpcmFillCoefficientTable(ADPCMWAVEFORMAT *fmt) const + { + // These are fixed since we are always using MS ADPCM + fmt->wNumCoef = 7 /* MSADPCM_NUM_COEFFICIENTS */; + + static ADPCMCOEFSET aCoef[7] = { { 256, 0}, {512, -256}, {0,0}, {192,64}, {240,0}, {460, -208}, {392,-232} }; + memcpy( &fmt->aCoef, aCoef, sizeof(aCoef) ); + } +}; + +struct BANKDATA +{ + static const size_t BANKNAME_LENGTH = 64; + + static const uint32_t TYPE_BUFFER = 0x00000000; + static const uint32_t TYPE_STREAMING = 0x00000001; + static const uint32_t TYPE_MASK = 0x00000001; + + static const uint32_t FLAGS_ENTRYNAMES = 0x00010000; + static const uint32_t FLAGS_COMPACT = 0x00020000; + static const uint32_t FLAGS_SYNC_DISABLED = 0x00040000; + static const uint32_t FLAGS_SEEKTABLES = 0x00080000; + static const uint32_t FLAGS_MASK = 0x000F0000; + + uint32_t dwFlags; // Bank flags + uint32_t dwEntryCount; // Number of entries in the bank + char szBankName[BANKNAME_LENGTH]; // Bank friendly name + uint32_t dwEntryMetaDataElementSize; // Size of each entry meta-data element, in bytes + uint32_t dwEntryNameElementSize; // Size of each entry name element, in bytes + uint32_t dwAlignment; // Entry alignment, in bytes + MINIWAVEFORMAT CompactFormat; // Format data for compact bank + FILETIME BuildTime; // Build timestamp + + void BigEndian() + { + dwFlags = _byteswap_ulong( dwFlags ); + dwEntryCount = _byteswap_ulong( dwEntryCount ); + dwEntryMetaDataElementSize = _byteswap_ulong( dwEntryMetaDataElementSize ); + dwEntryNameElementSize = _byteswap_ulong( dwEntryNameElementSize ); + dwAlignment = _byteswap_ulong( dwAlignment ); + CompactFormat.BigEndian(); + BuildTime.dwLowDateTime = _byteswap_ulong( BuildTime.dwLowDateTime ); + BuildTime.dwHighDateTime = _byteswap_ulong( BuildTime.dwHighDateTime ); + } +}; + +struct ENTRY +{ + static const uint32_t FLAGS_READAHEAD = 0x00000001; // Enable stream read-ahead + static const uint32_t FLAGS_LOOPCACHE = 0x00000002; // One or more looping sounds use this wave + static const uint32_t FLAGS_REMOVELOOPTAIL = 0x00000004;// Remove data after the end of the loop region + static const uint32_t FLAGS_IGNORELOOP = 0x00000008; // Used internally when the loop region can't be used + static const uint32_t FLAGS_MASK = 0x00000008; + + union + { + struct + { + // Entry flags + uint32_t dwFlags : 4; + + // Duration of the wave, in units of one sample. + // For instance, a ten second long wave sampled + // at 48KHz would have a duration of 480,000. + // This value is not affected by the number of + // channels, the number of bits per sample, or the + // compression format of the wave. + uint32_t Duration : 28; + }; + uint32_t dwFlagsAndDuration; + }; + + MINIWAVEFORMAT Format; // Entry format. + REGION PlayRegion; // Region within the wave data segment that contains this entry. + SAMPLEREGION LoopRegion; // Region within the wave data (in samples) that should loop. + + void BigEndian() + { + dwFlagsAndDuration = _byteswap_ulong( dwFlagsAndDuration ); + Format.BigEndian(); + PlayRegion.BigEndian(); + LoopRegion.BigEndian(); + } +}; + +struct ENTRYCOMPACT +{ + uint32_t dwOffset : 21; // Data offset, in multiplies of the bank alignment + uint32_t dwLengthDeviation : 11; // Data length deviation, in bytes + + void BigEndian() + { + *reinterpret_cast( this ) = _byteswap_ulong( *reinterpret_cast( this ) ); + } + + void ComputeLocations( DWORD& offset, DWORD& length, uint32_t index, const HEADER& header, const BANKDATA& data, const ENTRYCOMPACT* entries ) const + { + offset = dwOffset * data.dwAlignment; + + if ( index < ( data.dwEntryCount - 1 ) ) + { + length = ( entries[index + 1].dwOffset * data.dwAlignment ) - offset - dwLengthDeviation; + } + else + { + length = header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength - offset - dwLengthDeviation; + } + } + + static uint32_t GetDuration( DWORD length, const BANKDATA& data, const uint32_t* seekTable ) + { + switch( data.CompactFormat.wFormatTag ) + { + case MINIWAVEFORMAT::TAG_ADPCM: + { + uint32_t duration = ( length / data.CompactFormat.BlockAlign() ) * data.CompactFormat.AdpcmSamplesPerBlock(); + uint32_t partial = length % data.CompactFormat.BlockAlign(); + if ( partial ) + { + if ( partial >= ( 7 * data.CompactFormat.nChannels ) ) + duration += ( partial * 2 / data.CompactFormat.nChannels - 12 ); + } + return duration; + } + + case MINIWAVEFORMAT::TAG_WMA: + if ( seekTable ) + { + uint32_t seekCount = *seekTable; + if ( seekCount > 0 ) + { + return seekTable[ seekCount ] / uint32_t( 2 * data.CompactFormat.nChannels ); + } + } + return 0; + + case MINIWAVEFORMAT::TAG_XMA: + if ( seekTable ) + { + uint32_t seekCount = *seekTable; + if ( seekCount > 0 ) + { + return seekTable[ seekCount ]; + } + } + return 0; + + default: + return uint32_t( ( uint64_t( length ) * 8 ) + / uint64_t( data.CompactFormat.BitsPerSample() * data.CompactFormat.nChannels ) ); + } + } +}; + +#pragma pack(pop) + +inline const uint32_t* FindSeekTable( uint32_t index, const uint8_t* seekTable, const HEADER& header, const BANKDATA& data ) +{ + if ( !seekTable || index >= data.dwEntryCount ) + return nullptr; + + uint32_t seekSize = header.Segments[HEADER::SEGIDX_SEEKTABLES].dwLength; + + if ( ( index * sizeof(uint32_t) ) > seekSize ) + return nullptr; + + auto table = reinterpret_cast( seekTable ); + uint32_t offset = table[ index ]; + if ( offset == uint32_t(-1) ) + return nullptr; + + offset += sizeof(uint32_t) * data.dwEntryCount; + + if ( offset > seekSize ) + return nullptr; + + return reinterpret_cast( seekTable + offset ); +} + +}; + +static_assert( sizeof(REGION)==8, "Mismatch with xact3wb.h" ); +static_assert( sizeof(SAMPLEREGION)==8, "Mismatch with xact3wb.h" ); +static_assert( sizeof(HEADER)==52, "Mismatch with xact3wb.h" ); +static_assert( sizeof(ENTRY)==24, "Mismatch with xact3wb.h" ); +static_assert( sizeof(MINIWAVEFORMAT)==4, "Mismatch with xact3wb.h" ); +static_assert( sizeof(ENTRY)==24, "Mismatch with xact3wb.h" ); +static_assert( sizeof(ENTRYCOMPACT)==4, "Mismatch with xact3wb.h" ); +static_assert( sizeof(BANKDATA)==96, "Mismatch with xact3wb.h" ); + +using namespace DirectX; + +//-------------------------------------------------------------------------------------- +class WaveBankReader::Impl +{ +public: + Impl() : + m_async( INVALID_HANDLE_VALUE ), + m_prepared(false) +#if defined(_XBOX_ONE) && defined(_TITLE) + , m_xmaMemory(nullptr) +#endif + { + memset( &m_header, 0, sizeof(HEADER) ); + memset( &m_data, 0, sizeof(BANKDATA) ); + memset( &m_request, 0, sizeof(OVERLAPPED) ); + } + + ~Impl() { Close(); } + + HRESULT Open( _In_z_ const wchar_t* szFileName ); + void Close(); + + 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 GetSeekTable( _In_ uint32_t index, _Out_ const uint32_t** pData, _Out_ uint32_t& dataCount, _Out_ uint32_t& tag ) const; + + HRESULT GetMetadata( _In_ uint32_t index, _Out_ Metadata& metadata ) const; + + bool UpdatePrepared(); + + void Clear() + { + memset( &m_header, 0, sizeof(HEADER) ); + memset( &m_data, 0, sizeof(BANKDATA ) ); + + m_names.clear(); + m_entries.reset(); + m_seekData.reset(); + m_waveData.reset(); + +#if defined(_XBOX_ONE) && defined(_TITLE) + if ( m_xmaMemory ) + { + ApuFree( m_xmaMemory ); + m_xmaMemory = nullptr; + } +#endif + } + + HANDLE m_async; + ScopedHandle m_event; + OVERLAPPED m_request; + bool m_prepared; + + HEADER m_header; + BANKDATA m_data; + std::map m_names; + +private: + std::unique_ptr m_entries; + std::unique_ptr m_seekData; + std::unique_ptr m_waveData; + +#if defined(_XBOX_ONE) && defined(_TITLE) +public: + void* m_xmaMemory; +#endif +}; + + +_Use_decl_annotations_ +HRESULT WaveBankReader::Impl::Open( const wchar_t* szFileName ) +{ + Close(); + Clear(); + + m_prepared = false; + +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + m_event.reset( CreateEventEx( nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_MODIFY_STATE | SYNCHRONIZE ) ); +#else + m_event.reset( CreateEvent( nullptr, TRUE, FALSE, nullptr ) ); +#endif + + if ( !m_event ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + CREATEFILE2_EXTENDED_PARAMETERS params = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0 }; + params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; + params.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN; + ScopedHandle hFile( safe_handle( CreateFile2( szFileName, + GENERIC_READ, + FILE_SHARE_READ, + OPEN_EXISTING, + ¶ms ) ) ); +#else + ScopedHandle hFile( safe_handle( CreateFileW( szFileName, + GENERIC_READ, + FILE_SHARE_READ, + nullptr, + OPEN_EXISTING, + FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN, + nullptr ) ) ); +#endif + + if ( !hFile ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + // Read and verify header + OVERLAPPED request; + memset( &request, 0, sizeof(request) ); + request.hEvent = m_event.get(); + + bool wait = false; + if( !ReadFile( hFile.get(), &m_header, sizeof( m_header ), nullptr, &request ) ) + { + DWORD error = GetLastError(); + if ( error != ERROR_IO_PENDING ) + return HRESULT_FROM_WIN32( error ); + wait = true; + } + + DWORD bytes; +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + BOOL result = GetOverlappedResultEx( hFile.get(), &request, &bytes, INFINITE, FALSE ); +#else + if ( wait ) + (void)WaitForSingleObject( m_event.get(), INFINITE ); + + BOOL result = GetOverlappedResult( hFile.get(), &request, &bytes, FALSE ); +#endif + + if ( !result || ( bytes != sizeof( m_header ) ) ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + if ( m_header.dwSignature != HEADER::SIGNATURE && m_header.dwSignature != HEADER::BE_SIGNATURE ) + { + return E_FAIL; + } + + bool be = ( m_header.dwSignature == HEADER::BE_SIGNATURE ); + if ( be ) + { + DebugTrace( "INFO: \"%ls\" is a big-endian (Xbox 360) wave bank\n", szFileName ); + m_header.BigEndian(); + } + + if ( m_header.dwHeaderVersion != HEADER::VERSION ) + { + return E_FAIL; + } + + // Load bank data + memset( &request, 0, sizeof(request) ); + request.Offset = m_header.Segments[HEADER::SEGIDX_BANKDATA].dwOffset; + request.hEvent = m_event.get(); + + wait = false; + if( !ReadFile( hFile.get(), &m_data, sizeof( m_data ), nullptr, &request ) ) + { + DWORD error = GetLastError(); + if ( error != ERROR_IO_PENDING ) + return HRESULT_FROM_WIN32( error ); + wait = true; + } + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + result = GetOverlappedResultEx( hFile.get(), &request, &bytes, INFINITE, FALSE ); +#else + if ( wait ) + (void)WaitForSingleObject( m_event.get(), INFINITE ); + + result = GetOverlappedResult( hFile.get(), &request, &bytes, FALSE ); +#endif + + if ( !result || ( bytes != sizeof( m_data ) ) ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + if ( be ) + m_data.BigEndian(); + + if ( !m_data.dwEntryCount ) + { + return HRESULT_FROM_WIN32( ERROR_NO_DATA ); + } + + if ( m_data.dwFlags & BANKDATA::TYPE_STREAMING ) + { + if ( m_data.dwAlignment < ALIGNMENT_DVD ) + return E_FAIL; + if ( m_data.dwAlignment % DVD_SECTOR_SIZE ) + return E_FAIL; + } + else if ( m_data.dwAlignment < ALIGNMENT_MIN ) + { + return E_FAIL; + } + + if ( m_data.dwFlags & BANKDATA::FLAGS_COMPACT ) + { + if ( m_data.dwEntryMetaDataElementSize != sizeof(ENTRYCOMPACT) ) + { + return E_FAIL; + } + + if ( m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength > ( MAX_COMPACT_DATA_SEGMENT_SIZE * m_data.dwAlignment ) ) + { + // Data segment is too large to be valid compact wavebank + return E_FAIL; + } + } + else + { + if ( m_data.dwEntryMetaDataElementSize != sizeof(ENTRY) ) + { + return E_FAIL; + } + } + + DWORD metadataBytes = m_header.Segments[HEADER::SEGIDX_ENTRYMETADATA].dwLength; + if ( metadataBytes != ( m_data.dwEntryCount * m_data.dwEntryMetaDataElementSize ) ) + { + return E_FAIL; + } + + // Load names + DWORD namesBytes = m_header.Segments[HEADER::SEGIDX_ENTRYNAMES].dwLength; + if ( namesBytes > 0 ) + { + if ( namesBytes >= ( m_data.dwEntryNameElementSize * m_data.dwEntryCount ) ) + { + std::unique_ptr temp( new (std::nothrow) char[ namesBytes ] ); + if ( !temp ) + return E_OUTOFMEMORY; + + memset( &request, 0, sizeof(request) ); + request.Offset = m_header.Segments[HEADER::SEGIDX_ENTRYNAMES].dwOffset; + request.hEvent = m_event.get(); + + wait = false; + if ( !ReadFile( hFile.get(), temp.get(), namesBytes, nullptr, &request ) ) + { + DWORD error = GetLastError(); + if ( error != ERROR_IO_PENDING ) + return HRESULT_FROM_WIN32( error ); + wait = true; + } + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + result = GetOverlappedResultEx( hFile.get(), &request, &bytes, INFINITE, FALSE ); +#else + if ( wait ) + (void)WaitForSingleObject( m_event.get(), INFINITE ); + + result = GetOverlappedResult( hFile.get(), &request, &bytes, FALSE ); +#endif + + if ( !result || ( namesBytes != bytes ) ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + for( uint32_t j = 0; j < m_data.dwEntryCount; ++j ) + { + DWORD n = m_data.dwEntryNameElementSize * j; + + char name[ 64 ] = {0}; + strncpy_s( name, &temp[ n ], 64 ); + + m_names[ name ] = j; + } + } + } + + // Load entries + if ( m_data.dwFlags & BANKDATA::FLAGS_COMPACT ) + { + m_entries.reset( reinterpret_cast( new (std::nothrow) ENTRYCOMPACT[ m_data.dwEntryCount ] ) ); + } + else + { + m_entries.reset( reinterpret_cast( new (std::nothrow) ENTRY[ m_data.dwEntryCount ] ) ); + } + if ( !m_entries ) + return E_OUTOFMEMORY; + + memset( &request, 0, sizeof(request) ); + request.Offset = m_header.Segments[HEADER::SEGIDX_ENTRYMETADATA].dwOffset; + request.hEvent = m_event.get(); + + wait = false; + if ( !ReadFile( hFile.get(), m_entries.get(), metadataBytes, nullptr, &request ) ) + { + DWORD error = GetLastError(); + if ( error != ERROR_IO_PENDING ) + return HRESULT_FROM_WIN32( error ); + wait = true; + } + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + result = GetOverlappedResultEx( hFile.get(), &request, &bytes, INFINITE, FALSE ); +#else + if ( wait ) + (void)WaitForSingleObject( m_event.get(), INFINITE ); + + result = GetOverlappedResult( hFile.get(), &request, &bytes, FALSE ); +#endif + + if ( !result || ( metadataBytes != bytes ) ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + if ( be ) + { + if ( m_data.dwFlags & BANKDATA::FLAGS_COMPACT ) + { + auto ptr = reinterpret_cast( m_entries.get() ); + for( size_t j = 0; j < m_data.dwEntryCount; ++j, ++ptr ) + ptr->BigEndian(); + } + else + { + auto ptr = reinterpret_cast( m_entries.get() ); + for( size_t j = 0; j < m_data.dwEntryCount; ++j, ++ptr ) + ptr->BigEndian(); + } + } + + // Load seek tables (XMA2 / xWMA) + DWORD seekLen = m_header.Segments[HEADER::SEGIDX_SEEKTABLES].dwLength; + if ( seekLen > 0 ) + { + m_seekData.reset( new (std::nothrow) uint8_t[ seekLen ] ); + if ( !m_seekData ) + return E_OUTOFMEMORY; + + memset( &request, 0, sizeof(OVERLAPPED) ); + request.Offset = m_header.Segments[HEADER::SEGIDX_SEEKTABLES].dwOffset; + request.hEvent = m_event.get(); + + wait = false; + if ( !ReadFile( hFile.get(), m_seekData.get(), seekLen, nullptr, &request ) ) + { + DWORD error = GetLastError(); + if ( error != ERROR_IO_PENDING ) + return HRESULT_FROM_WIN32( error ); + wait = true; + } + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + result = GetOverlappedResultEx( hFile.get(), &request, &bytes, INFINITE, FALSE ); +#else + if ( wait ) + (void)WaitForSingleObject( m_event.get(), INFINITE ); + + result = GetOverlappedResult( hFile.get(), &request, &bytes, FALSE ); +#endif + + if ( !result || ( seekLen != bytes ) ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + if ( be ) + { + auto ptr = reinterpret_cast( m_seekData.get() ); + for( size_t j = 0; j < seekLen; j += 4, ++ptr ) + { + *ptr = _byteswap_ulong( *ptr ); + } + } + } + + DWORD waveLen = m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength; + if ( !waveLen ) + { + return HRESULT_FROM_WIN32( ERROR_NO_DATA ); + } + + if ( m_data.dwFlags & BANKDATA::TYPE_STREAMING ) + { + // If streaming, reopen without buffering + hFile.reset(); + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + CREATEFILE2_EXTENDED_PARAMETERS params2 = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0 }; + params2.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; + params2.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING; + m_async = CreateFile2( szFileName, + GENERIC_READ, + FILE_SHARE_READ, + OPEN_EXISTING, + ¶ms2 ); +#else + m_async = CreateFileW( szFileName, + GENERIC_READ, + FILE_SHARE_READ, + nullptr, + OPEN_EXISTING, + FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, + nullptr ); +#endif + + if ( m_async == INVALID_HANDLE_VALUE ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + m_prepared = true; + } + else + { + // If in-memory, kick off read of wave data + void *dest; + +#if defined(_XBOX_ONE) && defined(_TITLE) + bool xma = false; + if ( m_data.dwFlags & BANKDATA::FLAGS_COMPACT ) + { + if ( m_data.CompactFormat.wFormatTag == MINIWAVEFORMAT::TAG_XMA ) + xma = true; + } + else + { + for( uint32_t j = 0; j < m_data.dwEntryCount; ++j ) + { + auto& entry = reinterpret_cast( m_entries.get() )[ j ]; + if ( entry.Format.wFormatTag == MINIWAVEFORMAT::TAG_XMA ) + { + xma = true; + break; + } + } + } + + if ( xma ) + { + HRESULT hr = ApuAlloc( &m_xmaMemory, nullptr, waveLen, 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; + } + + dest = m_xmaMemory; + } + else +#endif // _XBOX_ONE && _TITLE + { + m_waveData.reset( new (std::nothrow) uint8_t[ waveLen ] ); + if ( !m_waveData ) + return E_OUTOFMEMORY; + + dest = m_waveData.get(); + } + + memset( &m_request, 0, sizeof(OVERLAPPED) ); + m_request.Offset = m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwOffset; + m_request.hEvent = m_event.get(); + + if ( !ReadFile( hFile.get(), dest, waveLen, nullptr, &m_request ) ) + { + DWORD error = GetLastError(); + if ( error != ERROR_IO_PENDING ) + return HRESULT_FROM_WIN32( error ); + } + else + { + m_prepared = true; + memset( &m_request, 0, sizeof(OVERLAPPED) ); + } + + m_async = hFile.release(); + } + + return S_OK; +} + + +void WaveBankReader::Impl::Close() +{ + if ( m_async != INVALID_HANDLE_VALUE ) + { + if ( m_request.hEvent != 0 ) + { + DWORD bytes; +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + (void)GetOverlappedResultEx( m_async, &m_request, &bytes, INFINITE, FALSE ); +#else + (void)WaitForSingleObject( m_request.hEvent, INFINITE ); + + (void)GetOverlappedResult( m_async, &m_request, &bytes, FALSE ); +#endif + } + + CloseHandle( m_async ); + m_async = INVALID_HANDLE_VALUE; + } + m_event.reset(); + +#if defined(_XBOX_ONE) && defined(_TITLE) + if ( m_xmaMemory ) + { + ApuFree( m_xmaMemory ); + m_xmaMemory = nullptr; + } +#endif +} + + +_Use_decl_annotations_ +HRESULT WaveBankReader::Impl::GetFormat( uint32_t index, WAVEFORMATEX* pFormat, size_t maxsize ) const +{ + if ( !pFormat || !maxsize ) + return E_INVALIDARG; + + if ( index >= m_data.dwEntryCount || !m_entries ) + { + return E_FAIL; + } + + auto& miniFmt = ( m_data.dwFlags & BANKDATA::FLAGS_COMPACT ) ? m_data.CompactFormat : ( reinterpret_cast( m_entries.get() )[ index ].Format ); + + switch( miniFmt.wFormatTag ) + { + case MINIWAVEFORMAT::TAG_PCM: + if ( maxsize < sizeof(PCMWAVEFORMAT) ) + return HRESULT_FROM_WIN32( ERROR_MORE_DATA ); + + pFormat->wFormatTag = WAVE_FORMAT_PCM; + + if ( maxsize >= sizeof(WAVEFORMATEX) ) + { + pFormat->cbSize = 0; + } + break; + + case MINIWAVEFORMAT::TAG_ADPCM: + if ( maxsize < ( sizeof(WAVEFORMATEX) + 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/ ) ) + return HRESULT_FROM_WIN32( ERROR_MORE_DATA ); + + pFormat->wFormatTag = WAVE_FORMAT_ADPCM; + pFormat->cbSize = 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/; + { + auto adpcmFmt = reinterpret_cast(pFormat); + adpcmFmt->wSamplesPerBlock = (WORD) miniFmt.AdpcmSamplesPerBlock(); + miniFmt.AdpcmFillCoefficientTable( adpcmFmt ); + } + break; + + case MINIWAVEFORMAT::TAG_WMA: + if ( maxsize < sizeof(WAVEFORMATEX) ) + return HRESULT_FROM_WIN32( ERROR_MORE_DATA ); + + pFormat->wFormatTag = (miniFmt.wBitsPerSample & 0x1) ? WAVE_FORMAT_WMAUDIO3 : WAVE_FORMAT_WMAUDIO2; + pFormat->cbSize = 0; + break; + + case MINIWAVEFORMAT::TAG_XMA: // XMA2 is supported by Xbox One +#if defined(_XBOX_ONE) && defined(_TITLE) + if ( maxsize < sizeof(XMA2WAVEFORMATEX) ) + return HRESULT_FROM_WIN32( ERROR_MORE_DATA ); + + pFormat->wFormatTag = WAVE_FORMAT_XMA2; + pFormat->cbSize = sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX); + { + auto xmaFmt = reinterpret_cast(pFormat); + + xmaFmt->NumStreams = static_cast( (miniFmt.nChannels + 1) / 2 ); + xmaFmt->BytesPerBlock = 65536 /* XACT_FIXED_XMA_BLOCK_SIZE */; + xmaFmt->EncoderVersion = 4 /* XMAENCODER_VERSION_XMA2 */; + + auto seekTable = FindSeekTable( index, m_seekData.get(), m_header, m_data ); + if ( seekTable ) + { + xmaFmt->BlockCount = static_cast( *seekTable ); + } + else + { + xmaFmt->BlockCount = 0; + } + + switch( miniFmt.nChannels ) + { + case 1: xmaFmt->ChannelMask = SPEAKER_MONO; break; + case 2: xmaFmt->ChannelMask = SPEAKER_STEREO; break; + case 3: xmaFmt->ChannelMask = SPEAKER_2POINT1; break; + case 4: xmaFmt->ChannelMask = SPEAKER_QUAD; break; + case 5: xmaFmt->ChannelMask = SPEAKER_4POINT1; break; + case 6: xmaFmt->ChannelMask = SPEAKER_5POINT1; break; + case 7: xmaFmt->ChannelMask = SPEAKER_5POINT1 | SPEAKER_BACK_CENTER; break; + case 8: xmaFmt->ChannelMask = SPEAKER_7POINT1; break; + default: xmaFmt->ChannelMask = DWORD(-1); break; + } + + if ( m_data.dwFlags & BANKDATA::FLAGS_COMPACT ) + { + auto& entry = reinterpret_cast( m_entries.get() )[ index ]; + + DWORD dwOffset, dwLength; + entry.ComputeLocations( dwOffset, dwLength, index, m_header, m_data, reinterpret_cast( m_entries.get() ) ); + + xmaFmt->SamplesEncoded = entry.GetDuration( dwLength, m_data, seekTable ); + + xmaFmt->PlayBegin = xmaFmt->PlayLength = + xmaFmt->LoopBegin = xmaFmt->LoopLength = xmaFmt->LoopCount = 0; + } + else + { + auto& entry = reinterpret_cast( m_entries.get() )[ index ]; + + xmaFmt->SamplesEncoded = entry.Duration; + xmaFmt->PlayBegin = 0; + xmaFmt->PlayLength = entry.PlayRegion.dwLength; + + if ( entry.LoopRegion.dwTotalSamples > 0 ) + { + xmaFmt->LoopBegin = entry.LoopRegion.dwStartSample; + xmaFmt->LoopLength = entry.LoopRegion.dwTotalSamples; + xmaFmt->LoopCount = 0xff /* XACTLOOPCOUNT_INFINITE */; + } + else + { + xmaFmt->LoopBegin = xmaFmt->LoopLength = xmaFmt->LoopCount = 0; + } + } + } + break; +#else + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); +#endif + + default: + return E_FAIL; + } + + pFormat->nChannels = miniFmt.nChannels; + pFormat->wBitsPerSample = miniFmt.BitsPerSample(); + pFormat->nBlockAlign = (WORD) miniFmt.BlockAlign(); + pFormat->nSamplesPerSec = miniFmt.nSamplesPerSec; + pFormat->nAvgBytesPerSec = miniFmt.AvgBytesPerSec(); + + return S_OK; +} + + +_Use_decl_annotations_ +HRESULT WaveBankReader::Impl::GetWaveData( uint32_t index, const uint8_t** pData, uint32_t& dataSize ) const +{ + if ( !pData ) + return E_INVALIDARG; + + if ( index >= m_data.dwEntryCount || !m_entries ) + { + return E_FAIL; + } + +#if defined(_XBOX_ONE) && defined(_TITLE) + const uint8_t* waveData = ( m_xmaMemory ) ? reinterpret_cast( m_xmaMemory ) : m_waveData.get(); +#else + const uint8_t* waveData = m_waveData.get(); +#endif + { + } + + if ( !waveData ) + return E_FAIL; + + if ( m_data.dwFlags & BANKDATA::TYPE_STREAMING ) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + + if ( !m_prepared ) + { + return HRESULT_FROM_WIN32( ERROR_IO_INCOMPLETE ); + } + + if ( m_data.dwFlags & BANKDATA::FLAGS_COMPACT ) + { + auto& entry = reinterpret_cast( m_entries.get() )[ index ]; + + DWORD dwOffset, dwLength; + entry.ComputeLocations( dwOffset, dwLength, index, m_header, m_data, reinterpret_cast( m_entries.get() ) ); + + if ( ( dwOffset + dwLength ) > m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + *pData = &waveData[ dwOffset ]; + dataSize = dwLength; + } + else + { + auto& entry = reinterpret_cast( m_entries.get() )[ index ]; + + if ( ( entry.PlayRegion.dwOffset + entry.PlayRegion.dwLength ) > m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength ) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + *pData = &waveData[ entry.PlayRegion.dwOffset ]; + dataSize = entry.PlayRegion.dwLength; + } + + return S_OK; +} + + +_Use_decl_annotations_ +HRESULT WaveBankReader::Impl::GetSeekTable( uint32_t index, const uint32_t** pData, uint32_t& dataCount, uint32_t& tag ) const +{ + if ( !pData ) + return E_INVALIDARG; + + *pData = nullptr; + dataCount = 0; + tag = 0; + + if ( index >= m_data.dwEntryCount || !m_entries ) + { + return E_FAIL; + } + + if ( !m_seekData ) + return S_OK; + + auto& miniFmt = ( m_data.dwFlags & BANKDATA::FLAGS_COMPACT ) ? m_data.CompactFormat : ( reinterpret_cast( m_entries.get() )[ index ].Format ); + + switch( miniFmt.wFormatTag ) + { + case MINIWAVEFORMAT::TAG_WMA: + tag = (miniFmt.wBitsPerSample & 0x1) ? WAVE_FORMAT_WMAUDIO3 : WAVE_FORMAT_WMAUDIO2; + break; + + case MINIWAVEFORMAT::TAG_XMA: + tag = 0x166 /* WAVE_FORMAT_XMA2 */; + break; + + default: + return S_OK; + } + + auto seekTable = FindSeekTable( index, m_seekData.get(), m_header, m_data ); + if ( !seekTable ) + return S_OK; + + dataCount = *seekTable; + *pData = seekTable + 1; + + return S_OK; +} + + +_Use_decl_annotations_ +HRESULT WaveBankReader::Impl::GetMetadata( uint32_t index, Metadata& metadata ) const +{ + if ( index >= m_data.dwEntryCount || !m_entries ) + { + return E_FAIL; + } + + if ( m_data.dwFlags & BANKDATA::FLAGS_COMPACT ) + { + auto& entry = reinterpret_cast( m_entries.get() )[ index ]; + + DWORD dwOffset, dwLength; + entry.ComputeLocations( dwOffset, dwLength, index, m_header, m_data, reinterpret_cast( m_entries.get() ) ); + + auto seekTable = FindSeekTable( index, m_seekData.get(), m_header, m_data ); + metadata.duration = entry.GetDuration( dwLength, m_data, seekTable ); + metadata.loopStart = metadata.loopLength = 0; + metadata.offsetBytes = dwOffset; + metadata.lengthBytes = dwLength; + } + else + { + auto& entry = reinterpret_cast( m_entries.get() )[ index ]; + + metadata.duration = entry.Duration; + metadata.loopStart = entry.LoopRegion.dwStartSample; + metadata.loopLength = entry.LoopRegion.dwTotalSamples; + metadata.offsetBytes = entry.PlayRegion.dwOffset; + metadata.lengthBytes = entry.PlayRegion.dwLength; + } + + return S_OK; +} + + +bool WaveBankReader::Impl::UpdatePrepared() +{ + if ( m_prepared ) + return true; + + if ( m_async == INVALID_HANDLE_VALUE ) + return false; + + if ( m_request.hEvent != 0 ) + { + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + DWORD bytes; + BOOL result = GetOverlappedResultEx( m_async, &m_request, &bytes, 0, FALSE ); +#else + bool result = HasOverlappedIoCompleted( &m_request ); +#endif + if ( result ) + { + m_prepared = true; + + memset( &m_request, 0, sizeof(OVERLAPPED) ); + } + } + + return m_prepared; +} + + + +//-------------------------------------------------------------------------------------- +WaveBankReader::WaveBankReader() : + pImpl( new Impl ) +{ +} + + +WaveBankReader::~WaveBankReader() +{ +} + + +_Use_decl_annotations_ +HRESULT WaveBankReader::Open( const wchar_t* szFileName ) +{ + return pImpl->Open( szFileName ); +} + + +_Use_decl_annotations_ +uint32_t WaveBankReader::Find( const char* name ) const +{ + auto it = pImpl->m_names.find( name ); + if ( it != pImpl->m_names.cend() ) + { + return it->second; + } + + return uint32_t(-1); +} + + +bool WaveBankReader::IsPrepared() +{ + if ( pImpl->m_prepared ) + return true; + + return pImpl->UpdatePrepared(); +} + + +void WaveBankReader::WaitOnPrepare() +{ + if ( pImpl->m_prepared ) + return; + + if ( pImpl->m_request.hEvent != 0 ) + { + WaitForSingleObjectEx( pImpl->m_request.hEvent, INFINITE, FALSE ); + + pImpl->UpdatePrepared(); + } +} + + +bool WaveBankReader::HasNames() const +{ + return !pImpl->m_names.empty(); +} + + +bool WaveBankReader::IsStreamingBank() const +{ + return (pImpl->m_data.dwFlags & BANKDATA::TYPE_STREAMING) != 0; +} + + +#if defined(_XBOX_ONE) && defined(_TITLE) +bool WaveBankReader::HasXMA() const +{ + return (pImpl->m_xmaMemory != 0); +} +#endif + + +const char* WaveBankReader::BankName() const +{ + return pImpl->m_data.szBankName; +} + + +uint32_t WaveBankReader::Count() const +{ + return pImpl->m_data.dwEntryCount; +} + + +uint32_t WaveBankReader::BankAudioSize() const +{ + return pImpl->m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength; +} + + +_Use_decl_annotations_ +HRESULT WaveBankReader::GetFormat( uint32_t index, WAVEFORMATEX* pFormat, size_t maxsize ) const +{ + return pImpl->GetFormat( index, pFormat, maxsize ); +} + + +_Use_decl_annotations_ +HRESULT WaveBankReader::GetWaveData( uint32_t index, const uint8_t** pData, uint32_t& dataSize ) const +{ + return pImpl->GetWaveData( index, pData, dataSize ); +} + + +_Use_decl_annotations_ +HRESULT WaveBankReader::GetSeekTable( uint32_t index, const uint32_t** pData, uint32_t& dataCount, uint32_t& tag ) const +{ + return pImpl->GetSeekTable( index, pData, dataCount, tag ); +} + + +_Use_decl_annotations_ +HRESULT WaveBankReader::GetMetadata( uint32_t index, Metadata& metadata ) const +{ + return pImpl->GetMetadata( index, metadata ); +} + + +HANDLE WaveBankReader::GetAsyncHandle() const +{ + return ( pImpl->m_data.dwFlags & BANKDATA::TYPE_STREAMING ) ? pImpl->m_async : INVALID_HANDLE_VALUE; +} diff --git a/Kits/DirectXTK/Audio/WaveBankReader.h b/Kits/DirectXTK/Audio/WaveBankReader.h new file mode 100644 index 0000000000000000000000000000000000000000..5824032ec2e1dd6badc9127979c4e01a68a82985 --- /dev/null +++ b/Kits/DirectXTK/Audio/WaveBankReader.h @@ -0,0 +1,84 @@ +//-------------------------------------------------------------------------------------- +// File: WaveBankReader.h +// +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//------------------------------------------------------------------------------------- + +#pragma once + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +#include +#include +#include + + +namespace DirectX +{ + class WaveBankReader + { + public: + WaveBankReader(); + ~WaveBankReader(); + + HRESULT Open( _In_z_ const wchar_t* szFileName ); + + uint32_t Find( _In_z_ const char* name ) const; + + bool IsPrepared(); + void WaitOnPrepare(); + + bool HasNames() const; + bool IsStreamingBank() const; + +#if defined(_XBOX_ONE) && defined(_TITLE) + bool HasXMA() const; +#endif + + const char* BankName() const; + + uint32_t Count() const; + + uint32_t BankAudioSize() 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 GetSeekTable( _In_ uint32_t index, _Out_ const uint32_t** pData, _Out_ uint32_t& dataCount, _Out_ uint32_t& tag ) const; + + HANDLE GetAsyncHandle() const; + + struct Metadata + { + uint32_t duration; + uint32_t loopStart; + uint32_t loopLength; + uint32_t offsetBytes; + uint32_t lengthBytes; + }; + HRESULT GetMetadata( _In_ uint32_t index, _Out_ Metadata& metadata ) const; + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + WaveBankReader(WaveBankReader const&) DIRECTX_CTOR_DELETE + WaveBankReader& operator= (WaveBankReader const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/DirectXTK_Windows10.vcxproj b/Kits/DirectXTK/DirectXTK_Windows10.vcxproj new file mode 100644 index 0000000000000000000000000000000000000000..70b661b05edd02379945b3f31d2030f5ac94c93d --- /dev/null +++ b/Kits/DirectXTK/DirectXTK_Windows10.vcxproj @@ -0,0 +1,465 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + Document + + + Document + + + Document + + + Document + + + Document + + + Document + + + Document + + + Document + + + Document + + + Document + + + + {f4776924-619c-42c7-88b2-82c947ccc9e7} + StaticLibrary + DirectXTK + DirectXTK + en-US + 14.0 + true + Windows Store + 10.0.10586.0 + 10.0.10240.0 + 10.0 + + + + StaticLibrary + true + v140 + + + StaticLibrary + true + v140 + + + StaticLibrary + true + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bin\Windows10\$(Platform)\$(Configuration)\ + Bin\Windows10\$(Platform)\$(Configuration)\ + DirectXTK + false + + + Bin\Windows10\$(Platform)\$(Configuration)\ + Bin\Windows10\$(Platform)\$(Configuration)\ + DirectXTK + false + + + Bin\Windows10\$(Platform)\$(Configuration)\ + Bin\Windows10\$(Platform)\$(Configuration)\ + DirectXTK + false + + + Bin\Windows10\$(Platform)\$(Configuration)\ + Bin\Windows10\$(Platform)\$(Configuration)\ + DirectXTK + false + + + Bin\Windows10\$(Platform)\$(Configuration)\ + Bin\Windows10\$(Platform)\$(Configuration)\ + DirectXTK + false + + + Bin\Windows10\$(Platform)\$(Configuration)\ + Bin\Windows10\$(Platform)\$(Configuration)\ + DirectXTK + false + + + + Use + true + true + $(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories) + Fast + StreamingSIMDExtensions2 + $(IntDir)$(TargetName).pdb + Level4 + _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + Use + true + true + $(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories) + Fast + StreamingSIMDExtensions2 + $(IntDir)$(TargetName).pdb + Level4 + _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + Use + true + true + $(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories) + Fast + $(IntDir)$(TargetName).pdb + Level4 + _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + Use + true + true + $(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories) + Fast + $(IntDir)$(TargetName).pdb + Level4 + _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + Use + true + true + $(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories) + Fast + $(IntDir)$(TargetName).pdb + Level4 + _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + Use + true + true + $(ProjectDir)Inc;$(ProjectDir)Src;%(AdditionalIncludeDirectories) + Fast + $(IntDir)$(TargetName).pdb + Level4 + _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + + diff --git a/Kits/DirectXTK/DirectXTK_Windows10.vcxproj.filters b/Kits/DirectXTK/DirectXTK_Windows10.vcxproj.filters new file mode 100644 index 0000000000000000000000000000000000000000..4ce83bde7494c4b2909c2cea8d3eeabb3972ae61 --- /dev/null +++ b/Kits/DirectXTK/DirectXTK_Windows10.vcxproj.filters @@ -0,0 +1,539 @@ + + + + + {a77af43b-f2ab-4dcc-b84e-70909b198d8a} + + + {4a81ebd8-dd1a-46fb-ad14-8b57d8e92774} + + + {a872f54e-e97f-4e14-a946-da034ce61f99} + + + {e536bb5b-5908-4d5a-b629-6a73cf2fc9ca} + + + {fe608244-a8ad-4cca-b766-e82f3d32405b} + + + + + Inc + + + Inc + + + Inc + + + Inc + + + Inc + + + Inc + + + Inc + + + Inc + + + Inc + + + Inc + + + Inc + + + Inc + + + Inc + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Audio + + + Audio + + + Audio + + + Audio + + + Inc + + + Inc + + + Inc + + + Inc + + + + + Inc + + + Src + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src\Shaders\Compiled + + + Src + + + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Src + + + Audio + + + Audio + + + Audio + + + Audio + + + Audio + + + Audio + + + Audio + + + Audio + + + Src + + + Src + + + Src + + + Src + + + \ No newline at end of file diff --git a/Kits/DirectXTK/Inc/Audio.h b/Kits/DirectXTK/Inc/Audio.h new file mode 100644 index 0000000000000000000000000000000000000000..5424ad055933e2f9f3ae9cd18105305d7f2c8478 --- /dev/null +++ b/Kits/DirectXTK/Inc/Audio.h @@ -0,0 +1,718 @@ +//-------------------------------------------------------------------------------------- +// File: Audio.h +// +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include +#include +#include + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#pragma comment(lib,"acphal.lib") +#endif + +#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#pragma comment(lib,"PhoneAudioSes.lib") +#endif + +#ifndef XAUDIO2_HELPER_FUNCTIONS +#define XAUDIO2_HELPER_FUNCTIONS +#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 +#include +#include +#include +#pragma comment(lib,"xaudio2.lib") +#else +// Using XAudio 2.7 requires the DirectX SDK +#include +#include +#include +#include +#pragma warning(push) +#pragma warning( disable : 4005 ) +#include +#pragma warning(pop) +#pragma comment(lib,"x3daudio.lib") +#pragma comment(lib,"xapofx.lib") +#endif + +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +#include +#include +#include +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#pragma warning(push) +#pragma warning(disable : 4481) +// VS 2010 considers 'override' to be a extension, but it's part of C++11 as of VS 2012 + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + class SoundEffectInstance; + + //---------------------------------------------------------------------------------- + struct AudioStatistics + { + size_t playingOneShots; // Number of one-shot sounds currently playing + size_t playingInstances; // Number of sound effect instances currently playing + size_t allocatedInstances; // Number of SoundEffectInstance allocated + size_t allocatedVoices; // Number of XAudio2 voices allocated (standard, 3D, one-shots, and idle one-shots) + size_t allocatedVoices3d; // Number of XAudio2 voices allocated for 3D + size_t allocatedVoicesOneShot; // Number of XAudio2 voices allocated for one-shot sounds + size_t allocatedVoicesIdle; // Number of XAudio2 voices allocated for one-shot sounds but not currently in use + size_t audioBytes; // Total wave data (in bytes) in SoundEffects and in-memory WaveBanks +#if defined(_XBOX_ONE) && defined(_TITLE) + size_t xmaAudioBytes; // Total wave data (in bytes) in SoundEffects and in-memory WaveBanks allocated with ApuAlloc +#endif + }; + + + //---------------------------------------------------------------------------------- + class IVoiceNotify + { + public: + virtual void __cdecl OnBufferEnd() = 0; + // Notfication that a voice buffer has finished + // Note this is called from XAudio2's worker thread, so it should perform very minimal and thread-safe operations + + virtual void __cdecl OnCriticalError() = 0; + // Notification that the audio engine encountered a critical error + + virtual void __cdecl OnReset() = 0; + // Notification of an audio engine reset + + virtual void __cdecl OnUpdate() = 0; + // Notification of an audio engine per-frame update (opt-in) + + virtual void __cdecl OnDestroyEngine() = 0; + // Notification that the audio engine is being destroyed + + virtual void __cdecl OnTrim() = 0; + // Notification of a request to trim the voice pool + + virtual void __cdecl GatherStatistics( AudioStatistics& stats ) const = 0; + // Contribute to statistics request + }; + + //---------------------------------------------------------------------------------- + enum AUDIO_ENGINE_FLAGS + { + AudioEngine_Default = 0x0, + + AudioEngine_EnvironmentalReverb = 0x1, + AudioEngine_ReverbUseFilters = 0x2, + AudioEngine_UseMasteringLimiter = 0x4, + + AudioEngine_Debug = 0x10000, + AudioEngine_ThrowOnNoAudioHW = 0x20000, + AudioEngine_DisableVoiceReuse = 0x40000, + }; + + inline AUDIO_ENGINE_FLAGS operator|(AUDIO_ENGINE_FLAGS a, AUDIO_ENGINE_FLAGS b) { return static_cast( static_cast(a) | static_cast(b) ); } + + enum SOUND_EFFECT_INSTANCE_FLAGS + { + SoundEffectInstance_Default = 0x0, + + SoundEffectInstance_Use3D = 0x1, + SoundEffectInstance_ReverbUseFilters = 0x2, + SoundEffectInstance_NoSetPitch = 0x4, + + SoundEffectInstance_UseRedirectLFE = 0x10000, + }; + + inline SOUND_EFFECT_INSTANCE_FLAGS operator|(SOUND_EFFECT_INSTANCE_FLAGS a, SOUND_EFFECT_INSTANCE_FLAGS b) { return static_cast( static_cast(a) | static_cast(b) ); } + + enum AUDIO_ENGINE_REVERB + { + Reverb_Off, + Reverb_Default, + Reverb_Generic, + Reverb_Forest, + Reverb_PaddedCell, + Reverb_Room, + Reverb_Bathroom, + Reverb_LivingRoom, + Reverb_StoneRoom, + Reverb_Auditorium, + Reverb_ConcertHall, + Reverb_Cave, + Reverb_Arena, + Reverb_Hangar, + Reverb_CarpetedHallway, + Reverb_Hallway, + Reverb_StoneCorridor, + Reverb_Alley, + Reverb_City, + Reverb_Mountains, + Reverb_Quarry, + Reverb_Plain, + Reverb_ParkingLot, + Reverb_SewerPipe, + Reverb_Underwater, + Reverb_SmallRoom, + Reverb_MediumRoom, + Reverb_LargeRoom, + Reverb_MediumHall, + Reverb_LargeHall, + Reverb_Plate, + Reverb_MAX + }; + + enum SoundState + { + STOPPED = 0, + PLAYING, + PAUSED + }; + + + //---------------------------------------------------------------------------------- + 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 ); + + AudioEngine(AudioEngine&& moveFrom); + AudioEngine& operator= (AudioEngine&& moveFrom); + virtual ~AudioEngine(); + + 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 ); + // 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 + + void __cdecl Suspend(); + void __cdecl Resume(); + // Suspend/resumes audio processing (i.e. global pause/resume) + + float __cdecl GetMasterVolume() const; + 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 ); + // Sets environmental reverb for 3D positional audio (if active) + + void __cdecl SetMasteringLimit( int release, int loudness ); + // Sets the mastering volume limiter properties (if active) + + AudioStatistics __cdecl GetStatistics() const; + // Gathers audio engine statistics + + WAVEFORMATEXTENSIBLE __cdecl GetOutputFormat() const; + // Returns the format consumed by the mastering voice (which is the same as the device output if defaults are used) + + uint32_t __cdecl GetChannelMask() const; + // Returns the output channel mask + + int __cdecl GetOutputChannels() const; + // Returns the number of output channels + + bool __cdecl IsAudioDevicePresent() const; + // Returns true if the audio graph is operating normally, false if in 'silent mode' + + bool __cdecl IsCriticalError() const; + // 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 ); + // Sample rate for voices in the reuse pool (defaults to 44100) + + 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 + + void __cdecl TrimVoicePool(); + // 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 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 ); + + // XAudio2 interface access + IXAudio2* __cdecl GetInterface() const; + IXAudio2MasteringVoice* __cdecl GetMasterVoice() const; + IXAudio2SubmixVoice* __cdecl GetReverbVoice() const; + X3DAUDIO_HANDLE& __cdecl Get3DHandle() const; + + // Static functions + struct RendererDetail + { + std::wstring deviceId; + std::wstring description; + }; + + static std::vector __cdecl GetRendererDetails(); + // Returns a list of valid audio endpoint devices + + private: + // Private implementation. + class Impl; + std::unique_ptr pImpl; + + // Prevent copying. + AudioEngine(AudioEngine const&) DIRECTX_CTOR_DELETE + AudioEngine& operator= (AudioEngine const&) DIRECTX_CTOR_DELETE + }; + + + //---------------------------------------------------------------------------------- + class WaveBank + { + public: + WaveBank( _In_ AudioEngine* engine, _In_z_ const wchar_t* wbFileName ); + + WaveBank(WaveBank&& moveFrom); + WaveBank& operator= (WaveBank&& moveFrom); + virtual ~WaveBank(); + + 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 ); + + std::unique_ptr __cdecl CreateInstance( int index, SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default ); + std::unique_ptr __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 GetSampleDuration( int index ) const; + // Returns the duration in samples + + 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; + + 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; +#else + void __cdecl FillSubmitBuffer( int index, _Out_ XAUDIO2_BUFFER& buffer ) const; +#endif + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + WaveBank(WaveBank const&) DIRECTX_CTOR_DELETE + WaveBank& operator= (WaveBank const&) DIRECTX_CTOR_DELETE + + // Private interface + void __cdecl UnregisterInstance( _In_ SoundEffectInstance* instance ); + + friend class SoundEffectInstance; + }; + + + //---------------------------------------------------------------------------------- + class SoundEffect + { + public: + SoundEffect( _In_ AudioEngine* engine, _In_z_ const wchar_t* waveFileName ); + + SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr& wavData, + _In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes ); + + SoundEffect( _In_ AudioEngine* engine, _Inout_ std::unique_ptr& 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& 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); + virtual ~SoundEffect(); + + void __cdecl Play(); + void __cdecl Play(float volume, float pitch, float pan); + + std::unique_ptr __cdecl CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default ); + + bool __cdecl IsInUse() const; + + size_t __cdecl GetSampleSizeInBytes() const; + // Returns size of wave audio data + + size_t __cdecl GetSampleDuration() const; + // Returns the duration in samples + + size_t __cdecl GetSampleDurationMS() const; + // 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; +#else + void __cdecl FillSubmitBuffer( _Out_ XAUDIO2_BUFFER& buffer ) const; +#endif + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + SoundEffect(SoundEffect const&) DIRECTX_CTOR_DELETE + SoundEffect& operator= (SoundEffect const&) DIRECTX_CTOR_DELETE + + // Private interface + void __cdecl UnregisterInstance( _In_ SoundEffectInstance* instance ); + + friend class SoundEffectInstance; + }; + + + //---------------------------------------------------------------------------------- + struct AudioListener : public X3DAUDIO_LISTENER + { + AudioListener() + { + memset( this, 0, sizeof(X3DAUDIO_LISTENER) ); + + OrientFront.z = -1.f; + + OrientTop.y = 1.f; + } + + void XM_CALLCONV SetPosition( FXMVECTOR v ) + { + XMStoreFloat3( reinterpret_cast( &Position ), v ); + } + void __cdecl SetPosition( const XMFLOAT3& pos ) + { + Position.x = pos.x; + Position.y = pos.y; + Position.z = pos.z; + } + + void XM_CALLCONV SetVelocity( FXMVECTOR v ) + { + XMStoreFloat3( reinterpret_cast( &Velocity ), v ); + } + 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 ) + { + XMStoreFloat3( reinterpret_cast( &OrientFront ), forward ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), 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 ) + { + XMVECTOR forward = XMVector3Rotate( g_XMIdentityR2, quat ); + XMStoreFloat3( reinterpret_cast( &OrientFront ), forward ); + + XMVECTOR up = XMVector3Rotate( g_XMIdentityR1, quat ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), up ); + } + + 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 ) + { + XMVECTOR lastPos = XMLoadFloat3( reinterpret_cast( &Position ) ); + + XMVECTOR vDelta = ( newPos - lastPos ); + XMVECTOR v = vDelta / dt; + XMStoreFloat3( reinterpret_cast( &Velocity ), v ); + + vDelta = XMVector3Normalize( vDelta ); + XMStoreFloat3( reinterpret_cast( &OrientFront ), vDelta ); + + v = XMVector3Cross( upDir, vDelta ); + v = XMVector3Normalize( v ); + + v = XMVector3Cross( vDelta, v ); + v = XMVector3Normalize( v ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), v ); + + XMStoreFloat3( reinterpret_cast( &Position ), newPos ); + } + } + }; + + + //---------------------------------------------------------------------------------- + struct AudioEmitter : public X3DAUDIO_EMITTER + { + float EmitterAzimuths[XAUDIO2_MAX_AUDIO_CHANNELS]; + + AudioEmitter() + { + memset( this, 0, sizeof(X3DAUDIO_EMITTER) ); + memset( EmitterAzimuths, 0, sizeof(EmitterAzimuths) ); + + OrientFront.z = -1.f; + + OrientTop.y = + ChannelRadius = + CurveDistanceScaler = + DopplerScaler = 1.f; + + ChannelCount = 1; + pChannelAzimuths = EmitterAzimuths; + + InnerRadiusAngle = X3DAUDIO_PI / 4.0f; + } + + void XM_CALLCONV SetPosition( FXMVECTOR v ) + { + XMStoreFloat3( reinterpret_cast( &Position ), v ); + } + void __cdecl SetPosition( const XMFLOAT3& pos ) + { + Position.x = pos.x; + Position.y = pos.y; + Position.z = pos.z; + } + + void XM_CALLCONV SetVelocity( FXMVECTOR v ) + { + XMStoreFloat3( reinterpret_cast( &Velocity ), v ); + } + 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 ) + { + XMStoreFloat3( reinterpret_cast( &OrientFront ), forward ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), 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 ) + { + XMVECTOR forward = XMVector3Rotate( g_XMIdentityR2, quat ); + XMStoreFloat3( reinterpret_cast( &OrientFront ), forward ); + + XMVECTOR up = XMVector3Rotate( g_XMIdentityR1, quat ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), up ); + } + + 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 ) + { + XMVECTOR lastPos = XMLoadFloat3( reinterpret_cast( &Position ) ); + + XMVECTOR vDelta = ( newPos - lastPos ); + XMVECTOR v = vDelta / dt; + XMStoreFloat3( reinterpret_cast( &Velocity ), v ); + + vDelta = XMVector3Normalize( vDelta ); + XMStoreFloat3( reinterpret_cast( &OrientFront ), vDelta ); + + v = XMVector3Cross( upDir, vDelta ); + v = XMVector3Normalize( v ); + + v = XMVector3Cross( vDelta, v ); + v = XMVector3Normalize( v ); + XMStoreFloat3( reinterpret_cast( &OrientTop ), v ); + + XMStoreFloat3( reinterpret_cast( &Position ), newPos ); + } + } + }; + + + //---------------------------------------------------------------------------------- + class SoundEffectInstance + { + public: + SoundEffectInstance(SoundEffectInstance&& moveFrom); + SoundEffectInstance& operator= (SoundEffectInstance&& moveFrom); + virtual ~SoundEffectInstance(); + + 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 Apply3D( const AudioListener& listener, const AudioEmitter& emitter, bool rhcoords = true ); + + bool __cdecl IsLooped() const; + + SoundState __cdecl GetState(); + + // Notifications. + void __cdecl OnDestroyParent(); + + private: + // Private implementation. + class Impl; + + std::unique_ptr 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 ); + + friend std::unique_ptr __cdecl SoundEffect::CreateInstance( SOUND_EFFECT_INSTANCE_FLAGS ); + friend std::unique_ptr __cdecl WaveBank::CreateInstance( int, SOUND_EFFECT_INSTANCE_FLAGS ); + + // Prevent copying. + SoundEffectInstance(SoundEffectInstance const&) DIRECTX_CTOR_DELETE + SoundEffectInstance& operator= (SoundEffectInstance const&) DIRECTX_CTOR_DELETE + }; + + + //---------------------------------------------------------------------------------- + class DynamicSoundEffectInstance + { + public: + DynamicSoundEffectInstance( _In_ AudioEngine* engine, + _In_opt_ std::function bufferNeeded, + int sampleRate, int channels, int sampleBits = 16, + SOUND_EFFECT_INSTANCE_FLAGS flags = SoundEffectInstance_Default ); + DynamicSoundEffectInstance(DynamicSoundEffectInstance&& moveFrom); + DynamicSoundEffectInstance& operator= (DynamicSoundEffectInstance&& moveFrom); + virtual ~DynamicSoundEffectInstance(); + + void __cdecl Play(); + 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 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 ); + + 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 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 + + int __cdecl GetPendingBufferCount() const; + + const WAVEFORMATEX* __cdecl GetFormat() const; + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + DynamicSoundEffectInstance(DynamicSoundEffectInstance const&) DIRECTX_CTOR_DELETE + DynamicSoundEffectInstance& operator= (DynamicSoundEffectInstance const&) DIRECTX_CTOR_DELETE + }; +} + +#pragma warning(pop) \ No newline at end of file diff --git a/Kits/DirectXTK/Inc/CommonStates.h b/Kits/DirectXTK/Inc/CommonStates.h new file mode 100644 index 0000000000000000000000000000000000000000..77fdc4906af3638f383bb8e6745ba3a00e9e384a --- /dev/null +++ b/Kits/DirectXTK/Inc/CommonStates.h @@ -0,0 +1,81 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include + + +namespace DirectX +{ + class CommonStates + { + public: + explicit CommonStates(_In_ ID3D11Device* device); + CommonStates(CommonStates&& moveFrom); + CommonStates& operator= (CommonStates&& moveFrom); + virtual ~CommonStates(); + + // Blend states. + ID3D11BlendState* __cdecl Opaque() const; + ID3D11BlendState* __cdecl AlphaBlend() const; + ID3D11BlendState* __cdecl Additive() const; + ID3D11BlendState* __cdecl NonPremultiplied() const; + + // Depth stencil states. + ID3D11DepthStencilState* __cdecl DepthNone() const; + ID3D11DepthStencilState* __cdecl DepthDefault() const; + ID3D11DepthStencilState* __cdecl DepthRead() const; + + // Rasterizer states. + ID3D11RasterizerState* __cdecl CullNone() const; + ID3D11RasterizerState* __cdecl CullClockwise() const; + ID3D11RasterizerState* __cdecl CullCounterClockwise() const; + ID3D11RasterizerState* __cdecl Wireframe() const; + + // Sampler states. + ID3D11SamplerState* __cdecl PointWrap() const; + ID3D11SamplerState* __cdecl PointClamp() const; + ID3D11SamplerState* __cdecl LinearWrap() const; + ID3D11SamplerState* __cdecl LinearClamp() const; + ID3D11SamplerState* __cdecl AnisotropicWrap() const; + ID3D11SamplerState* __cdecl AnisotropicClamp() const; + + private: + // Private implementation. + class Impl; + + std::shared_ptr pImpl; + + // Prevent copying. + CommonStates(CommonStates const&) DIRECTX_CTOR_DELETE + CommonStates& operator= (CommonStates const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Inc/DDSTextureLoader.h b/Kits/DirectXTK/Inc/DDSTextureLoader.h new file mode 100644 index 0000000000000000000000000000000000000000..683ab7c881de6aea32d1e56fcfd5653d5cf4e852 --- /dev/null +++ b/Kits/DirectXTK/Inc/DDSTextureLoader.h @@ -0,0 +1,160 @@ +//-------------------------------------------------------------------------------------- +// File: DDSTextureLoader.h +// +// Functions for loading a DDS texture and creating a Direct3D 11 runtime resource for it +// +// Note these functions are useful as a light-weight runtime loader for DDS files. 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +namespace DirectX +{ + enum DDS_ALPHA_MODE + { + DDS_ALPHA_MODE_UNKNOWN = 0, + DDS_ALPHA_MODE_STRAIGHT = 1, + DDS_ALPHA_MODE_PREMULTIPLIED = 2, + DDS_ALPHA_MODE_OPAQUE = 3, + DDS_ALPHA_MODE_CUSTOM = 4, + }; + + // Standard version + HRESULT __cdecl CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + // Standard version with optional auto-gen mipmap support + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateDDSTextureFromMemory( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_z_ const wchar_t* szFileName, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + // Extended version + HRESULT __cdecl CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + HRESULT __cdecl CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + // Extended version with optional auto-gen mipmap support + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateDDSTextureFromMemoryEx( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateDDSTextureFromFileEx( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); +} \ No newline at end of file diff --git a/Kits/DirectXTK/Inc/DirectXHelpers.h b/Kits/DirectXTK/Inc/DirectXHelpers.h new file mode 100644 index 0000000000000000000000000000000000000000..1b7c51351cd61cb197eb890d6779d7d84b209e77 --- /dev/null +++ b/Kits/DirectXTK/Inc/DirectXHelpers.h @@ -0,0 +1,150 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) +#if !defined(_XBOX_ONE) || !defined(_TITLE) +#pragma comment(lib,"dxguid.lib") +#endif +#endif + +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +// +// The core Direct3D headers provide the following helper C++ classes +// CD3D11_RECT +// CD3D11_BOX +// CD3D11_DEPTH_STENCIL_DESC +// CD3D11_BLEND_DESC, CD3D11_BLEND_DESC1 +// CD3D11_RASTERIZER_DESC, CD3D11_RASTERIZER_DESC1 +// CD3D11_BUFFER_DESC +// CD3D11_TEXTURE1D_DESC +// CD3D11_TEXTURE2D_DESC +// CD3D11_TEXTURE3D_DESC +// CD3D11_SHADER_RESOURCE_VIEW_DESC +// CD3D11_RENDER_TARGET_VIEW_DESC +// CD3D11_VIEWPORT +// CD3D11_DEPTH_STENCIL_VIEW_DESC +// CD3D11_UNORDERED_ACCESS_VIEW_DESC +// CD3D11_SAMPLER_DESC +// CD3D11_QUERY_DESC +// CD3D11_COUNTER_DESC +// + + +namespace DirectX +{ + // simliar to std::lock_guard for exception-safe Direct3D 11 resource locking + class MapGuard : public D3D11_MAPPED_SUBRESOURCE + { + public: + 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 ); + if (FAILED(hr)) + { + throw std::exception(); + } + } + + ~MapGuard() + { + mContext->Unmap( mResource, mSubresource ); + } + + uint8_t* get() const + { + return reinterpret_cast( pData ); + } + uint8_t* get(size_t slice) const + { + return reinterpret_cast( pData ) + ( slice * DepthPitch ); + } + + uint8_t* scanline(size_t row) const + { + return reinterpret_cast( pData ) + ( row * RowPitch ); + } + uint8_t* scanline(size_t slice, size_t row) const + { + return reinterpret_cast( pData ) + ( slice * DepthPitch ) + ( row * RowPitch ); + } + + private: + ID3D11DeviceContext* mContext; + ID3D11Resource* mResource; + UINT mSubresource; + + MapGuard(MapGuard const&); + MapGuard& operator= (MapGuard const&); + }; + + + // Helper sets a D3D resource name string (used by PIX and debug layer leak reporting). + template + inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_ const char (&name)[TNameLength]) + { + #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) + #if defined(_XBOX_ONE) && defined(_TITLE) + WCHAR wname[MAX_PATH]; + int result = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, name, TNameLength, wname, MAX_PATH ); + if ( result > 0 ) + { + resource->SetName( wname ); + } + #else + resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name); + #endif + #else + UNREFERENCED_PARAMETER(resource); + UNREFERENCED_PARAMETER(name); + #endif + } + + template + inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_ const wchar_t (&name)[TNameLength]) + { + #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) + #if defined(_XBOX_ONE) && defined(_TITLE) + resource->SetName( name ); + #else + char aname[MAX_PATH]; + int result = WideCharToMultiByte( CP_ACP, 0, name, TNameLength, aname, MAX_PATH, nullptr, nullptr ); + if ( result > 0 ) + { + resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, aname); + } + #endif + #else + UNREFERENCED_PARAMETER(resource); + UNREFERENCED_PARAMETER(name); + #endif + } +} \ No newline at end of file diff --git a/Kits/DirectXTK/Inc/Effects.h b/Kits/DirectXTK/Inc/Effects.h new file mode 100644 index 0000000000000000000000000000000000000000..d7e7dec3cfb44454a00457ae3d5c928352f5ea7a --- /dev/null +++ b/Kits/DirectXTK/Inc/Effects.h @@ -0,0 +1,612 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include +#include + +#pragma warning(push) +#pragma warning(disable : 4481) +// VS 2010 considers 'override' to be a extension, but it's part of C++11 as of VS 2012 + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + //---------------------------------------------------------------------------------- + // Abstract interface representing any effect which can be applied onto a D3D device context. + class IEffect + { + public: + virtual ~IEffect() { } + + virtual void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) = 0; + + virtual void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) = 0; + }; + + + // Abstract interface for effects with world, view, and projection matrices. + class IEffectMatrices + { + public: + virtual ~IEffectMatrices() { } + + virtual void XM_CALLCONV SetWorld(FXMMATRIX value) = 0; + virtual void XM_CALLCONV SetView(FXMMATRIX value) = 0; + virtual void XM_CALLCONV SetProjection(FXMMATRIX value) = 0; + }; + + + // Abstract interface for effects which support directional lighting. + class IEffectLights + { + public: + virtual ~IEffectLights() { } + + virtual void __cdecl SetLightingEnabled(bool value) = 0; + virtual void __cdecl SetPerPixelLighting(bool value) = 0; + virtual void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) = 0; + + virtual void __cdecl SetLightEnabled(int whichLight, bool value) = 0; + virtual void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) = 0; + virtual void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) = 0; + virtual void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) = 0; + + virtual void __cdecl EnableDefaultLighting() = 0; + + static const int MaxDirectionalLights = 3; + }; + + + // Abstract interface for effects which support fog. + class IEffectFog + { + public: + virtual ~IEffectFog() { } + + virtual void __cdecl SetFogEnabled(bool value) = 0; + virtual void __cdecl SetFogStart(float value) = 0; + virtual void __cdecl SetFogEnd(float value) = 0; + virtual void XM_CALLCONV SetFogColor(FXMVECTOR value) = 0; + }; + + + // Abstract interface for effects which support skinning + class IEffectSkinning + { + public: + virtual ~IEffectSkinning() { } + + virtual void __cdecl SetWeightsPerVertex(int value) = 0; + virtual void __cdecl SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) = 0; + virtual void __cdecl ResetBoneTransforms() = 0; + + static const int MaxBones = 72; + }; + + + //---------------------------------------------------------------------------------- + // Built-in shader supports optional texture mapping, vertex coloring, directional lighting, and fog. + class BasicEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectFog + { + public: + explicit BasicEffect(_In_ ID3D11Device* device); + BasicEffect(BasicEffect&& moveFrom); + BasicEffect& operator= (BasicEffect&& moveFrom); + virtual ~BasicEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void XM_CALLCONV SetEmissiveColor(FXMVECTOR value); + void XM_CALLCONV SetSpecularColor(FXMVECTOR value); + void __cdecl SetSpecularPower(float value); + void __cdecl DisableSpecular(); + void __cdecl SetAlpha(float value); + + // Light settings. + void __cdecl SetLightingEnabled(bool value) override; + void __cdecl SetPerPixelLighting(bool value) override; + void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override; + + void __cdecl SetLightEnabled(int whichLight, bool value) override; + void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override; + + void __cdecl EnableDefaultLighting() override; + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // Vertex color setting. + void __cdecl SetVertexColorEnabled(bool value); + + // Texture setting. + void __cdecl SetTextureEnabled(bool value); + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + BasicEffect(BasicEffect const&) DIRECTX_CTOR_DELETE + BasicEffect& operator= (BasicEffect const&) DIRECTX_CTOR_DELETE + }; + + + + // Built-in shader supports per-pixel alpha testing. + class AlphaTestEffect : public IEffect, public IEffectMatrices, public IEffectFog + { + public: + explicit AlphaTestEffect(_In_ ID3D11Device* device); + AlphaTestEffect(AlphaTestEffect&& moveFrom); + AlphaTestEffect& operator= (AlphaTestEffect&& moveFrom); + virtual ~AlphaTestEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void __cdecl SetAlpha(float value); + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // Vertex color setting. + void __cdecl SetVertexColorEnabled(bool value); + + // Texture setting. + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + + // Alpha test settings. + void __cdecl SetAlphaFunction(D3D11_COMPARISON_FUNC value); + void __cdecl SetReferenceAlpha(int value); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + AlphaTestEffect(AlphaTestEffect const&) DIRECTX_CTOR_DELETE + AlphaTestEffect& operator= (AlphaTestEffect const&) DIRECTX_CTOR_DELETE + }; + + + + // Built-in shader supports two layer multitexturing (eg. for lightmaps or detail textures). + class DualTextureEffect : public IEffect, public IEffectMatrices, public IEffectFog + { + public: + explicit DualTextureEffect(_In_ ID3D11Device* device); + DualTextureEffect(DualTextureEffect&& moveFrom); + DualTextureEffect& operator= (DualTextureEffect&& moveFrom); + ~DualTextureEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void __cdecl SetAlpha(float value); + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // Vertex color setting. + void __cdecl SetVertexColorEnabled(bool value); + + // Texture settings. + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + void __cdecl SetTexture2(_In_opt_ ID3D11ShaderResourceView* value); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + DualTextureEffect(DualTextureEffect const&) DIRECTX_CTOR_DELETE + DualTextureEffect& operator= (DualTextureEffect const&) DIRECTX_CTOR_DELETE + }; + + + + // Built-in shader supports cubic environment mapping. + class EnvironmentMapEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectFog + { + public: + explicit EnvironmentMapEffect(_In_ ID3D11Device* device); + EnvironmentMapEffect(EnvironmentMapEffect&& moveFrom); + EnvironmentMapEffect& operator= (EnvironmentMapEffect&& moveFrom); + virtual ~EnvironmentMapEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void XM_CALLCONV SetEmissiveColor(FXMVECTOR value); + void __cdecl SetAlpha(float value); + + // Light settings. + void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override; + + void __cdecl SetLightEnabled(int whichLight, bool value) override; + void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override; + + void __cdecl EnableDefaultLighting() override; + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // Texture setting. + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + + // Environment map settings. + void __cdecl SetEnvironmentMap(_In_opt_ ID3D11ShaderResourceView* value); + void __cdecl SetEnvironmentMapAmount(float value); + void XM_CALLCONV SetEnvironmentMapSpecular(FXMVECTOR value); + void __cdecl SetFresnelFactor(float value); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Unsupported interface methods. + void __cdecl SetLightingEnabled(bool value) override; + void __cdecl SetPerPixelLighting(bool value) override; + void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override; + + // Prevent copying. + EnvironmentMapEffect(EnvironmentMapEffect const&) DIRECTX_CTOR_DELETE + EnvironmentMapEffect& operator= (EnvironmentMapEffect const&) DIRECTX_CTOR_DELETE + }; + + + + // Built-in shader supports skinned animation. + class SkinnedEffect : public IEffect, public IEffectMatrices, public IEffectLights, public IEffectFog, public IEffectSkinning + { + public: + explicit SkinnedEffect(_In_ ID3D11Device* device); + SkinnedEffect(SkinnedEffect&& moveFrom); + SkinnedEffect& operator= (SkinnedEffect&& moveFrom); + virtual ~SkinnedEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void XM_CALLCONV SetEmissiveColor(FXMVECTOR value); + void XM_CALLCONV SetSpecularColor(FXMVECTOR value); + void __cdecl SetSpecularPower(float value); + void __cdecl DisableSpecular(); + void __cdecl SetAlpha(float value); + + // Light settings. + void __cdecl SetPerPixelLighting(bool value) override; + void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override; + + void __cdecl SetLightEnabled(int whichLight, bool value) override; + void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override; + + void __cdecl EnableDefaultLighting() override; + + // Fog settings. + void __cdecl SetFogEnabled(bool value) override; + void __cdecl SetFogStart(float value) override; + void __cdecl SetFogEnd(float value) override; + void XM_CALLCONV SetFogColor(FXMVECTOR value) override; + + // 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; + void __cdecl ResetBoneTransforms() override; + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Unsupported interface method. + void __cdecl SetLightingEnabled(bool value) override; + + // Prevent copying. + SkinnedEffect(SkinnedEffect const&) DIRECTX_CTOR_DELETE + SkinnedEffect& operator= (SkinnedEffect const&) DIRECTX_CTOR_DELETE + }; + + + + //---------------------------------------------------------------------------------- + // Built-in effect for Visual Studio Shader Designer (DGSL) shaders + 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); + virtual ~DGSLEffect(); + + // IEffect methods. + void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override; + + void __cdecl GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) override; + + // Camera settings. + void XM_CALLCONV SetWorld(FXMMATRIX value) override; + void XM_CALLCONV SetView(FXMMATRIX value) override; + void XM_CALLCONV SetProjection(FXMMATRIX value) override; + + // Material settings. + void XM_CALLCONV SetAmbientColor(FXMVECTOR value); + void XM_CALLCONV SetDiffuseColor(FXMVECTOR value); + void XM_CALLCONV SetEmissiveColor(FXMVECTOR value); + void XM_CALLCONV SetSpecularColor(FXMVECTOR value); + void __cdecl SetSpecularPower(float value); + void __cdecl DisableSpecular(); + void __cdecl SetAlpha(float value); + + // Additional settings. + void XM_CALLCONV SetUVTransform(FXMMATRIX value); + void __cdecl SetViewport( float width, float height ); + void __cdecl SetTime( float time ); + void __cdecl SetAlphaDiscardEnable(bool value); + + // Light settings. + void __cdecl SetLightingEnabled(bool value) override; + void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override; + + void __cdecl SetLightEnabled(int whichLight, bool value) override; + void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override; + void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override; + + void __cdecl EnableDefaultLighting() override; + + static const int MaxDirectionalLights = 4; + + // Vertex color setting. + void __cdecl SetVertexColorEnabled(bool value); + + // Texture settings. + void __cdecl SetTextureEnabled(bool value); + void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value); + void __cdecl SetTexture2(_In_opt_ ID3D11ShaderResourceView* value); + void __cdecl SetTexture(int whichTexture, _In_opt_ ID3D11ShaderResourceView* value); + + static const int MaxTextures = 8; + + // Animation setting. + void __cdecl SetWeightsPerVertex(int value) override; + void __cdecl SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) override; + void __cdecl ResetBoneTransforms() override; + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Unsupported interface methods. + void __cdecl SetPerPixelLighting(bool value) override; + + // Prevent copying. + DGSLEffect(DGSLEffect const&) DIRECTX_CTOR_DELETE + DGSLEffect& operator= (DGSLEffect const&) DIRECTX_CTOR_DELETE + }; + + + + //---------------------------------------------------------------------------------- + // Abstract interface to factory for sharing effects and texture resources + class IEffectFactory + { + public: + virtual ~IEffectFactory() {} + + struct EffectInfo + { + const WCHAR* name; + bool perVertexColor; + bool enableSkinning; + bool enableDualTexture; + float specularPower; + float alpha; + DirectX::XMFLOAT3 ambientColor; + DirectX::XMFLOAT3 diffuseColor; + DirectX::XMFLOAT3 specularColor; + DirectX::XMFLOAT3 emissiveColor; + const WCHAR* texture; + const WCHAR* texture2; + + EffectInfo() { memset( this, 0, sizeof(EffectInfo) ); }; + }; + + virtual std::shared_ptr __cdecl CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) = 0; + + virtual void __cdecl CreateTexture( _In_z_ const WCHAR* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) = 0; + }; + + + // Factory for sharing effects and texture resources + class EffectFactory : public IEffectFactory + { + public: + explicit EffectFactory(_In_ ID3D11Device* device); + EffectFactory(EffectFactory&& moveFrom); + EffectFactory& operator= (EffectFactory&& moveFrom); + virtual ~EffectFactory(); + + // IEffectFactory methods. + virtual std::shared_ptr __cdecl CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) override; + virtual void __cdecl CreateTexture( _In_z_ const WCHAR* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) override; + + // Settings. + void __cdecl ReleaseCache(); + + void __cdecl SetSharing( bool enabled ); + + void __cdecl SetDirectory( _In_opt_z_ const WCHAR* path ); + + private: + // Private implementation. + class Impl; + + std::shared_ptr pImpl; + + // Prevent copying. + EffectFactory(EffectFactory const&) DIRECTX_CTOR_DELETE + EffectFactory& operator= (EffectFactory const&) DIRECTX_CTOR_DELETE + }; + + + // Factory for sharing Visual Studio Shader Designer (DGSL) shaders and texture resources + class DGSLEffectFactory : public IEffectFactory + { + public: + explicit DGSLEffectFactory(_In_ ID3D11Device* device); + DGSLEffectFactory(DGSLEffectFactory&& moveFrom); + DGSLEffectFactory& operator= (DGSLEffectFactory&& moveFrom); + virtual ~DGSLEffectFactory(); + + // IEffectFactory methods. + virtual std::shared_ptr __cdecl CreateEffect( _In_ const EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ) override; + virtual void __cdecl CreateTexture( _In_z_ const WCHAR* name, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ) override; + + // DGSL methods. + struct DGSLEffectInfo : public EffectInfo + { + const WCHAR* textures[6]; + const WCHAR* pixelShader; + + DGSLEffectInfo() { memset( this, 0, sizeof(DGSLEffectInfo) ); }; + }; + + virtual std::shared_ptr __cdecl CreateDGSLEffect( _In_ const DGSLEffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ); + + virtual void __cdecl CreatePixelShader( _In_z_ const WCHAR* shader, _Outptr_ ID3D11PixelShader** pixelShader ); + + // Settings. + void __cdecl ReleaseCache(); + + void __cdecl SetSharing( bool enabled ); + + void __cdecl SetDirectory( _In_opt_z_ const WCHAR* path ); + + private: + // Private implementation. + class Impl; + + std::shared_ptr pImpl; + + // Prevent copying. + DGSLEffectFactory(DGSLEffectFactory const&) DIRECTX_CTOR_DELETE + DGSLEffectFactory& operator= (DGSLEffectFactory const&) DIRECTX_CTOR_DELETE + }; + +} + +#pragma warning(pop) diff --git a/Kits/DirectXTK/Inc/GamePad.h b/Kits/DirectXTK/Inc/GamePad.h new file mode 100644 index 0000000000000000000000000000000000000000..bfeebda291b4ba869c2cfc02047184589be16020 --- /dev/null +++ b/Kits/DirectXTK/Inc/GamePad.h @@ -0,0 +1,244 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if (_WIN32_WINNT < 0x0A00 /*_WIN32_WINNT_WIN10*/) +#ifndef _XBOX_ONE +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) +#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/ ) +#pragma comment(lib,"xinput.lib") +#else +#pragma comment(lib,"xinput9_1_0.lib") +#endif +#endif +#endif +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#include +#pragma warning(pop) + + +namespace DirectX +{ + class GamePad + { + public: + GamePad(); + GamePad(GamePad&& moveFrom); + GamePad& operator= (GamePad&& moveFrom); + virtual ~GamePad(); + +#if (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/ ) || defined(_XBOX_ONE) + static const int MAX_PLAYER_COUNT = 8; +#else + static const int MAX_PLAYER_COUNT = 4; +#endif + + enum DeadZone + { + DEAD_ZONE_INDEPENDENT_AXES = 0, + DEAD_ZONE_CIRCULAR, + DEAD_ZONE_NONE, + }; + + struct Buttons + { + bool a; + bool b; + bool x; + bool y; + bool leftStick; + bool rightStick; + bool leftShoulder; + bool rightShoulder; + bool back; + bool start; + }; + + struct DPad + { + bool up; + bool down; + bool right; + bool left; + }; + + struct ThumbSticks + { + float leftX; + float leftY; + float rightX; + float rightY; + }; + + struct Triggers + { + float left; + float right; + }; + + struct State + { + bool connected; + uint64_t packet; + Buttons buttons; + DPad dpad; + ThumbSticks thumbSticks; + Triggers triggers; + + bool __cdecl IsConnected() const { return connected; } + + // Is the button pressed currently? + bool __cdecl IsAPressed() const { return buttons.a; } + bool __cdecl IsBPressed() const { return buttons.b; } + bool __cdecl IsXPressed() const { return buttons.x; } + bool __cdecl IsYPressed() const { return buttons.y; } + + bool __cdecl IsLeftStickPressed() const { return buttons.leftStick; } + bool __cdecl IsRightStickPressed() const { return buttons.rightStick; } + + bool __cdecl IsLeftShoulderPressed() const { return buttons.leftShoulder; } + bool __cdecl IsRightShoulderPressed() const { return buttons.rightShoulder; } + + bool __cdecl IsBackPressed() const { return buttons.back; } + bool __cdecl IsViewPressed() const { return buttons.back; } + bool __cdecl IsStartPressed() const { return buttons.start; } + bool __cdecl IsMenuPressed() const { return buttons.start; } + + bool __cdecl IsDPadDownPressed() const { return dpad.down; }; + bool __cdecl IsDPadUpPressed() const { return dpad.up; }; + bool __cdecl IsDPadLeftPressed() const { return dpad.left; }; + bool __cdecl IsDPadRightPressed() const { return dpad.right; }; + + bool __cdecl IsLeftThumbStickUp() const { return (thumbSticks.leftY > 0.5f) != 0; } + bool __cdecl IsLeftThumbStickDown() const { return (thumbSticks.leftY < -0.5f) != 0; } + 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 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; } + + bool __cdecl IsLeftTriggerPressed() const { return (triggers.left > 0.5f) != 0; } + bool __cdecl IsRightTriggerPressed() const { return (triggers.right > 0.5f) != 0; } + }; + + struct Capabilities + { + enum Type + { + UNKNOWN = 0, + GAMEPAD, + WHEEL, + ARCADE_STICK, + FLIGHT_STICK, + DANCE_PAD, + GUITAR, + GUITAR_ALTERNATE, + DRUM_KIT, + GUITAR_BASS = 11, + ARCADE_PAD = 19, + }; + + bool connected; + Type gamepadType; + uint64_t id; + + bool __cdecl IsConnected() const { return connected; } + }; + + class ButtonStateTracker + { + public: + enum ButtonState + { + UP = 0, // Button is up + HELD = 1, // Button is held down + RELEASED = 2, // Button was just released + PRESSED = 3, // Buton was just pressed + }; + + ButtonState a; + ButtonState b; + ButtonState x; + ButtonState y; + + ButtonState leftStick; + ButtonState rightStick; + + ButtonState leftShoulder; + ButtonState rightShoulder; + + ButtonState back; + ButtonState start; + + ButtonState dpadUp; + ButtonState dpadDown; + ButtonState dpadLeft; + ButtonState dpadRight; + + ButtonStateTracker() { Reset(); } + + void __cdecl Update( const State& state ); + + void __cdecl Reset(); + + private: + State lastState; + }; + + // Retrieve the current state of the gamepad of the associated player index + State __cdecl GetState(int player, DeadZone deadZoneMode = DEAD_ZONE_INDEPENDENT_AXES); + + // Retrieve the current capabilities of the gamepad of the associated player index + 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 ); + + // Handle suspending/resuming + void __cdecl Suspend(); + void __cdecl Resume(); + + // Singleton + static GamePad& __cdecl Get(); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + GamePad(GamePad const&) DIRECTX_CTOR_DELETE + GamePad& operator=(GamePad const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Inc/GeometricPrimitive.h b/Kits/DirectXTK/Inc/GeometricPrimitive.h new file mode 100644 index 0000000000000000000000000000000000000000..1f4ff0a6b423ed3ae8d66e74aafe2fbb013e426a --- /dev/null +++ b/Kits/DirectXTK/Inc/GeometricPrimitive.h @@ -0,0 +1,110 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "VertexTypes.h" + +#include +#include +#include +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + class IEffect; + + class GeometricPrimitive + { + public: + virtual ~GeometricPrimitive(); + + // Factory methods. + static std::unique_ptr __cdecl CreateCube (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateBox (_In_ ID3D11DeviceContext* deviceContext, const XMFLOAT3& size, bool rhcoords = true, bool invertn = false); + static std::unique_ptr __cdecl CreateSphere (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 16, bool rhcoords = true, bool invertn = false); + static std::unique_ptr __cdecl CreateGeoSphere (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, size_t tessellation = 3, bool rhcoords = true); + static std::unique_ptr __cdecl CreateCylinder (_In_ ID3D11DeviceContext* deviceContext, float height = 1, float diameter = 1, size_t tessellation = 32, bool rhcoords = true); + static std::unique_ptr __cdecl CreateCone (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float height = 1, size_t tessellation = 32, bool rhcoords = true); + static std::unique_ptr __cdecl CreateTorus (_In_ ID3D11DeviceContext* deviceContext, float diameter = 1, float thickness = 0.333f, size_t tessellation = 32, bool rhcoords = true); + static std::unique_ptr __cdecl CreateTetrahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateOctahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateDodecahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateIcosahedron (_In_ ID3D11DeviceContext* deviceContext, float size = 1, bool rhcoords = true); + static std::unique_ptr __cdecl CreateTeapot (_In_ ID3D11DeviceContext* deviceContext, float size = 1, size_t tessellation = 8, bool rhcoords = true); + static std::unique_ptr __cdecl CreateCustom (_In_ ID3D11DeviceContext* deviceContext, const std::vector& vertices, const std::vector& indices); + + static void __cdecl CreateCube (std::vector& vertices, std::vector& indices, float size = 1, bool rhcoords = true); + static void __cdecl CreateBox (std::vector& vertices, std::vector& indices, const XMFLOAT3& size, bool rhcoords = true, bool invertn = false); + static void __cdecl CreateSphere (std::vector& vertices, std::vector& indices, float diameter = 1, size_t tessellation = 16, bool rhcoords = true, bool invertn = false); + static void __cdecl CreateGeoSphere (std::vector& vertices, std::vector& indices, float diameter = 1, size_t tessellation = 3, bool rhcoords = true); + static void __cdecl CreateCylinder (std::vector& vertices, std::vector& indices, float height = 1, float diameter = 1, size_t tessellation = 32, bool rhcoords = true); + static void __cdecl CreateCone (std::vector& vertices, std::vector& indices, float diameter = 1, float height = 1, size_t tessellation = 32, bool rhcoords = true); + static void __cdecl CreateTorus (std::vector& vertices, std::vector& indices, float diameter = 1, float thickness = 0.333f, size_t tessellation = 32, bool rhcoords = true); + static void __cdecl CreateTetrahedron (std::vector& vertices, std::vector& indices, float size = 1, bool rhcoords = true); + static void __cdecl CreateOctahedron (std::vector& vertices, std::vector& indices, float size = 1, bool rhcoords = true); + static void __cdecl CreateDodecahedron (std::vector& vertices, std::vector& indices, float size = 1, bool rhcoords = true); + static void __cdecl CreateIcosahedron (std::vector& vertices, std::vector& indices, float size = 1, bool rhcoords = true); + static void __cdecl CreateTeapot (std::vector& vertices, std::vector& 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 setCustomState = nullptr ); + + // 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 setCustomState = nullptr ); + + // Create input layout for drawing with a custom effect. + void __cdecl CreateInputLayout( _In_ IEffect* effect, _Outptr_ ID3D11InputLayout** inputLayout ); + + private: + GeometricPrimitive(); + + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + GeometricPrimitive(GeometricPrimitive const&) DIRECTX_CTOR_DELETE + GeometricPrimitive& operator= (GeometricPrimitive const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Inc/GraphicsMemory.h b/Kits/DirectXTK/Inc/GraphicsMemory.h new file mode 100644 index 0000000000000000000000000000000000000000..fc1e88aa8c9bf4ee528f444ef397256bd1f0c6d9 --- /dev/null +++ b/Kits/DirectXTK/Inc/GraphicsMemory.h @@ -0,0 +1,67 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include + + +namespace DirectX +{ + class GraphicsMemory + { + public: + #if defined(_XBOX_ONE) && defined(_TITLE) + GraphicsMemory(_In_ ID3D11DeviceX* device, UINT backBufferCount = 2); + #else + GraphicsMemory(_In_ ID3D11Device* device, UINT backBufferCount = 2); + #endif + GraphicsMemory(GraphicsMemory&& moveFrom); + GraphicsMemory& operator= (GraphicsMemory&& moveFrom); + virtual ~GraphicsMemory(); + + void* __cdecl Allocate(_In_opt_ ID3D11DeviceContext* context, size_t size, int alignment); + + void __cdecl Commit(); + + // Singleton + static GraphicsMemory& __cdecl Get(); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + GraphicsMemory(GraphicsMemory const&) DIRECTX_CTOR_DELETE + GraphicsMemory& operator=(GraphicsMemory const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Inc/Keyboard.h b/Kits/DirectXTK/Inc/Keyboard.h new file mode 100644 index 0000000000000000000000000000000000000000..c013391e66e806ab50f09bf51941375b1fd17fd0 --- /dev/null +++ b/Kits/DirectXTK/Inc/Keyboard.h @@ -0,0 +1,492 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +#include + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +namespace ABI { namespace Windows { namespace UI { namespace Core { struct ICoreWindow; } } } } +#endif + + +namespace DirectX +{ + class Keyboard + { + public: + Keyboard(); + Keyboard(Keyboard&& moveFrom); + Keyboard& operator= (Keyboard&& moveFrom); + virtual ~Keyboard(); + + enum Keys + { + None = 0, + + Back = 0x8, + Tab = 0x9, + + Enter = 0xd, + + Pause = 0x13, + CapsLock = 0x14, + Kana = 0x15, + + Kanji = 0x19, + + Escape = 0x1b, + ImeConvert = 0x1c, + ImeNoConvert = 0x1d, + + Space = 0x20, + PageUp = 0x21, + PageDown = 0x22, + End = 0x23, + Home = 0x24, + Left = 0x25, + Up = 0x26, + Right = 0x27, + Down = 0x28, + Select = 0x29, + Print = 0x2a, + Execute = 0x2b, + PrintScreen = 0x2c, + Insert = 0x2d, + Delete = 0x2e, + Help = 0x2f, + D0 = 0x30, + D1 = 0x31, + D2 = 0x32, + D3 = 0x33, + D4 = 0x34, + D5 = 0x35, + D6 = 0x36, + D7 = 0x37, + D8 = 0x38, + D9 = 0x39, + + A = 0x41, + B = 0x42, + C = 0x43, + D = 0x44, + E = 0x45, + F = 0x46, + G = 0x47, + H = 0x48, + I = 0x49, + J = 0x4a, + K = 0x4b, + L = 0x4c, + M = 0x4d, + N = 0x4e, + O = 0x4f, + P = 0x50, + Q = 0x51, + R = 0x52, + S = 0x53, + T = 0x54, + U = 0x55, + V = 0x56, + W = 0x57, + X = 0x58, + Y = 0x59, + Z = 0x5a, + LeftWindows = 0x5b, + RightWindows = 0x5c, + Apps = 0x5d, + + Sleep = 0x5f, + NumPad0 = 0x60, + NumPad1 = 0x61, + NumPad2 = 0x62, + NumPad3 = 0x63, + NumPad4 = 0x64, + NumPad5 = 0x65, + NumPad6 = 0x66, + NumPad7 = 0x67, + NumPad8 = 0x68, + NumPad9 = 0x69, + Multiply = 0x6a, + Add = 0x6b, + Separator = 0x6c, + Subtract = 0x6d, + + Decimal = 0x6e, + Divide = 0x6f, + F1 = 0x70, + F2 = 0x71, + F3 = 0x72, + F4 = 0x73, + F5 = 0x74, + F6 = 0x75, + F7 = 0x76, + F8 = 0x77, + F9 = 0x78, + F10 = 0x79, + F11 = 0x7a, + F12 = 0x7b, + F13 = 0x7c, + F14 = 0x7d, + F15 = 0x7e, + F16 = 0x7f, + F17 = 0x80, + F18 = 0x81, + F19 = 0x82, + F20 = 0x83, + F21 = 0x84, + F22 = 0x85, + F23 = 0x86, + F24 = 0x87, + + NumLock = 0x90, + Scroll = 0x91, + + LeftShift = 0xa0, + RightShift = 0xa1, + LeftControl = 0xa2, + RightControl = 0xa3, + LeftAlt = 0xa4, + RightAlt = 0xa5, + BrowserBack = 0xa6, + BrowserForward = 0xa7, + BrowserRefresh = 0xa8, + BrowserStop = 0xa9, + BrowserSearch = 0xaa, + BrowserFavorites = 0xab, + BrowserHome = 0xac, + VolumeMute = 0xad, + VolumeDown = 0xae, + VolumeUp = 0xaf, + MediaNextTrack = 0xb0, + MediaPreviousTrack = 0xb1, + MediaStop = 0xb2, + MediaPlayPause = 0xb3, + LaunchMail = 0xb4, + SelectMedia = 0xb5, + LaunchApplication1 = 0xb6, + LaunchApplication2 = 0xb7, + + OemSemicolon = 0xba, + OemPlus = 0xbb, + OemComma = 0xbc, + OemMinus = 0xbd, + OemPeriod = 0xbe, + OemQuestion = 0xbf, + OemTilde = 0xc0, + + OemOpenBrackets = 0xdb, + OemPipe = 0xdc, + OemCloseBrackets = 0xdd, + OemQuotes = 0xde, + Oem8 = 0xdf, + + OemBackslash = 0xe2, + + ProcessKey = 0xe5, + + OemCopy = 0xf2, + OemAuto = 0xf3, + OemEnlW = 0xf4, + + Attn = 0xf6, + Crsel = 0xf7, + Exsel = 0xf8, + EraseEof = 0xf9, + Play = 0xfa, + Zoom = 0xfb, + + Pa1 = 0xfd, + OemClear = 0xfe, + }; + + struct State + { + bool Reserved0 : 8; + bool Back : 1; // VK_BACK, 0x8 + bool Tab : 1; // VK_TAB, 0x9 + bool Reserved1 : 3; + bool Enter : 1; // VK_RETURN, 0xD + bool Reserved2 : 2; + bool Reserved3 : 3; + bool Pause : 1; // VK_PAUSE, 0x13 + bool CapsLock : 1; // VK_CAPITAL, 0x14 + bool Kana : 1; // VK_KANA, 0x15 + bool Reserved4 : 2; + bool Reserved5 : 1; + bool Kanji : 1; // VK_KANJI, 0x19 + bool Reserved6 : 1; + bool Escape : 1; // VK_ESCAPE, 0x1B + bool ImeConvert : 1; // VK_CONVERT, 0x1C + bool ImeNoConvert : 1; // VK_NONCONVERT, 0x1D + bool Reserved7 : 2; + bool Space : 1; // VK_SPACE, 0x20 + bool PageUp : 1; // VK_PRIOR, 0x21 + bool PageDown : 1; // VK_NEXT, 0x22 + bool End : 1; // VK_END, 0x23 + bool Home : 1; // VK_HOME, 0x24 + bool Left : 1; // VK_LEFT, 0x25 + bool Up : 1; // VK_UP, 0x26 + bool Right : 1; // VK_RIGHT, 0x27 + bool Down : 1; // VK_DOWN, 0x28 + bool Select : 1; // VK_SELECT, 0x29 + bool Print : 1; // VK_PRINT, 0x2A + bool Execute : 1; // VK_EXECUTE, 0x2B + bool PrintScreen : 1; // VK_SNAPSHOT, 0x2C + bool Insert : 1; // VK_INSERT, 0x2D + bool Delete : 1; // VK_DELETE, 0x2E + bool Help : 1; // VK_HELP, 0x2F + bool D0 : 1; // 0x30 + bool D1 : 1; // 0x31 + bool D2 : 1; // 0x32 + bool D3 : 1; // 0x33 + bool D4 : 1; // 0x34 + bool D5 : 1; // 0x35 + bool D6 : 1; // 0x36 + bool D7 : 1; // 0x37 + bool D8 : 1; // 0x38 + bool D9 : 1; // 0x39 + bool Reserved8 : 6; + bool Reserved9 : 1; + bool A : 1; // 0x41 + bool B : 1; // 0x42 + bool C : 1; // 0x43 + bool D : 1; // 0x44 + bool E : 1; // 0x45 + bool F : 1; // 0x46 + bool G : 1; // 0x47 + bool H : 1; // 0x48 + bool I : 1; // 0x49 + bool J : 1; // 0x4A + bool K : 1; // 0x4B + bool L : 1; // 0x4C + bool M : 1; // 0x4D + bool N : 1; // 0x4E + bool O : 1; // 0x4F + bool P : 1; // 0x50 + bool Q : 1; // 0x51 + bool R : 1; // 0x52 + bool S : 1; // 0x53 + bool T : 1; // 0x54 + bool U : 1; // 0x55 + bool V : 1; // 0x56 + bool W : 1; // 0x57 + bool X : 1; // 0x58 + bool Y : 1; // 0x59 + bool Z : 1; // 0x5A + bool LeftWindows : 1; // VK_LWIN, 0x5B + bool RightWindows : 1; // VK_RWIN, 0x5C + bool Apps : 1; // VK_APPS, 0x5D + bool Reserved10 : 1; + bool Sleep : 1; // VK_SLEEP, 0x5F + bool NumPad0 : 1; // VK_NUMPAD0, 0x60 + bool NumPad1 : 1; // VK_NUMPAD1, 0x61 + bool NumPad2 : 1; // VK_NUMPAD2, 0x62 + bool NumPad3 : 1; // VK_NUMPAD3, 0x63 + bool NumPad4 : 1; // VK_NUMPAD4, 0x64 + bool NumPad5 : 1; // VK_NUMPAD5, 0x65 + bool NumPad6 : 1; // VK_NUMPAD6, 0x66 + bool NumPad7 : 1; // VK_NUMPAD7, 0x67 + bool NumPad8 : 1; // VK_NUMPAD8, 0x68 + bool NumPad9 : 1; // VK_NUMPAD9, 0x69 + bool Multiply : 1; // VK_MULTIPLY, 0x6A + bool Add : 1; // VK_ADD, 0x6B + bool Separator : 1; // VK_SEPARATOR, 0x6C + bool Subtract : 1; // VK_SUBTRACT, 0x6D + bool Decimal : 1; // VK_DECIMANL, 0x6E + bool Divide : 1; // VK_DIVIDE, 0x6F + bool F1 : 1; // VK_F1, 0x70 + bool F2 : 1; // VK_F2, 0x71 + bool F3 : 1; // VK_F3, 0x72 + bool F4 : 1; // VK_F4, 0x73 + bool F5 : 1; // VK_F5, 0x74 + bool F6 : 1; // VK_F6, 0x75 + bool F7 : 1; // VK_F7, 0x76 + bool F8 : 1; // VK_F8, 0x77 + bool F9 : 1; // VK_F9, 0x78 + bool F10 : 1; // VK_F10, 0x79 + bool F11 : 1; // VK_F11, 0x7A + bool F12 : 1; // VK_F12, 0x7B + bool F13 : 1; // VK_F13, 0x7C + bool F14 : 1; // VK_F14, 0x7D + bool F15 : 1; // VK_F15, 0x7E + bool F16 : 1; // VK_F16, 0x7F + bool F17 : 1; // VK_F17, 0x80 + bool F18 : 1; // VK_F18, 0x81 + bool F19 : 1; // VK_F19, 0x82 + bool F20 : 1; // VK_F20, 0x83 + bool F21 : 1; // VK_F21, 0x84 + bool F22 : 1; // VK_F22, 0x85 + bool F23 : 1; // VK_F23, 0x86 + bool F24 : 1; // VK_F24, 0x87 + bool Reserved11 : 8; + bool NumLock : 1; // VK_NUMLOCK, 0x90 + bool Scroll : 1; // VK_SCROLL, 0x91 + bool Reserved12 : 6; + bool Reserved13 : 8; + bool LeftShift : 1; // VK_LSHIFT, 0xA0 + bool RightShift : 1; // VK_RSHIFT, 0xA1 + bool LeftControl : 1; // VK_LCONTROL, 0xA2 + bool RightControl : 1; // VK_RCONTROL, 0xA3 + bool LeftAlt : 1; // VK_LMENU, 0xA4 + bool RightAlt : 1; // VK_RMENU, 0xA5 + bool BrowserBack : 1; // VK_BROWSER_BACK, 0xA6 + bool BrowserForward : 1; // VK_BROWSER_FORWARD, 0xA7 + bool BrowserRefresh : 1; // VK_BROWSER_REFRESH, 0xA8 + bool BrowserStop : 1; // VK_BROWSER_STOP, 0xA9 + bool BrowserSearch : 1; // VK_BROWSER_SEARCH, 0xAA + bool BrowserFavorites : 1; // VK_BROWSER_FAVORITES, 0xAB + bool BrowserHome : 1; // VK_BROWSER_HOME, 0xAC + bool VolumeMute : 1; // VK_VOLUME_MUTE, 0xAD + bool VolumeDown : 1; // VK_VOLUME_DOWN, 0xAE + bool VolumeUp : 1; // VK_VOLUME_UP, 0xAF + bool MediaNextTrack : 1; // VK_MEDIA_NEXT_TRACK, 0xB0 + bool MediaPreviousTrack : 1;// VK_MEDIA_PREV_TRACK, 0xB1 + bool MediaStop : 1; // VK_MEDIA_STOP, 0xB2 + bool MediaPlayPause : 1; // VK_MEDIA_PLAY_PAUSE, 0xB3 + bool LaunchMail : 1; // VK_LAUNCH_MAIL, 0xB4 + bool SelectMedia : 1; // VK_LAUNCH_MEDIA_SELECT, 0xB5 + bool LaunchApplication1 : 1;// VK_LAUNCH_APP1, 0xB6 + bool LaunchApplication2 : 1;// VK_LAUNCH_APP2, 0xB7 + bool Reserved14 : 2; + bool OemSemicolon : 1; // VK_OEM_1, 0xBA + bool OemPlus : 1; // VK_OEM_PLUS, 0xBB + bool OemComma : 1; // VK_OEM_COMMA, 0xBC + bool OemMinus : 1; // VK_OEM_MINUS, 0xBD + bool OemPeriod : 1; // VK_OEM_PERIOD, 0xBE + bool OemQuestion : 1; // VK_OEM_2, 0xBF + bool OemTilde : 1; // VK_OEM_3, 0xC0 + bool Reserved15 : 7; + bool Reserved16 : 8; + bool Reserved17 : 8; + bool Reserved18 : 3; + bool OemOpenBrackets : 1; // VK_OEM_4, 0xDB + bool OemPipe : 1; // VK_OEM_5, 0xDC + bool OemCloseBrackets : 1; // VK_OEM_6, 0xDD + bool OemQuotes : 1; // VK_OEM_7, 0xDE + bool Oem8 : 1; // VK_OEM_8, 0xDF + bool Reserved19 : 2; + bool OemBackslash : 1; // VK_OEM_102, 0xE2 + bool Reserved20 : 2; + bool ProcessKey : 1; // VK_PROCESSKEY, 0xE5 + bool Reserved21 : 2; + bool Reserved22 : 8; + bool Reserved23 : 2; + bool OemCopy : 1; // 0XF2 + bool OemAuto : 1; // 0xF3 + bool OemEnlW : 1; // 0xF4 + bool Reserved24 : 1; + bool Attn : 1; // VK_ATTN, 0xF6 + bool Crsel : 1; // VK_CRSEL, 0xF7 + bool Exsel : 1; // VK_EXSEL, 0xF8 + bool EraseEof : 1; // VK_EREOF, 0xF9 + bool Play : 1; // VK_PLAY, 0xFA + bool Zoom : 1; // VK_ZOOM, 0xFB + bool Reserved25 : 1; + bool Pa1 : 1; // VK_PA1, 0xFD + bool OemClear : 1; // VK_OEM_CLEAR, 0xFE + bool Reserved26: 1; + + bool __cdecl IsKeyDown(Keys key) const + { + if (key >= 0 && key <= 0xff) + { + auto ptr = reinterpret_cast(this); + unsigned int bf = 1u << (key & 0x1f); + return (ptr[(key >> 5)] & bf) != 0; + } + return false; + } + + bool __cdecl IsKeyUp(Keys key) const + { + if (key >= 0 && key <= 0xfe) + { + auto ptr = reinterpret_cast(this); + unsigned int bf = 1u << (key & 0x1f); + return (ptr[(key >> 5)] & bf) == 0; + } + return false; + } + }; + + class KeyboardStateTracker + { + public: + State released; + State pressed; + + KeyboardStateTracker() { Reset(); } + + void __cdecl Update(const State& state); + + void __cdecl Reset(); + + bool __cdecl IsKeyPressed(Keys key) const { return pressed.IsKeyDown(key); } + bool __cdecl IsKeyReleased(Keys key) const { return released.IsKeyDown(key); } + + public: + State lastState; + }; + + // Retrieve the current state of the keyboard + State __cdecl GetState() const; + + // Reset the keyboard state + void __cdecl Reset(); + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) && defined(WM_USER) + static void __cdecl ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam); +#endif + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) + void __cdecl SetWindow(ABI::Windows::UI::Core::ICoreWindow* window); +#ifdef __cplusplus_winrt + void __cdecl SetWindow(Windows::UI::Core::CoreWindow^ window) + { + // See https://msdn.microsoft.com/en-us/library/hh755802.aspx + SetWindow(reinterpret_cast(window)); + } +#endif +#endif + + // Singleton + static Keyboard& __cdecl Get(); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + Keyboard(Keyboard const&) DIRECTX_CTOR_DELETE + Keyboard& operator=(Keyboard const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Inc/Model.h b/Kits/DirectXTK/Inc/Model.h new file mode 100644 index 0000000000000000000000000000000000000000..cc98c55e189043cd6cbe156b0182bb98b71a5622 --- /dev/null +++ b/Kits/DirectXTK/Inc/Model.h @@ -0,0 +1,163 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#include +#pragma warning(pop) + +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + class IEffect; + class IEffectFactory; + class CommonStates; + class ModelMesh; + + //---------------------------------------------------------------------------------- + // Each mesh part is a submesh with a single effect + class ModelMeshPart + { + public: + ModelMeshPart(); + virtual ~ModelMeshPart(); + + uint32_t indexCount; + uint32_t startIndex; + uint32_t vertexOffset; + uint32_t vertexStride; + D3D_PRIMITIVE_TOPOLOGY primitiveType; + DXGI_FORMAT indexFormat; + Microsoft::WRL::ComPtr inputLayout; + Microsoft::WRL::ComPtr indexBuffer; + Microsoft::WRL::ComPtr vertexBuffer; + std::shared_ptr effect; + std::shared_ptr> vbDecl; + bool isAlpha; + + typedef std::vector> Collection; + + // Draw mesh part with custom effect + void __cdecl Draw( _In_ ID3D11DeviceContext* deviceContext, _In_ IEffect* ieffect, _In_ ID3D11InputLayout* iinputLayout, + _In_opt_ std::function setCustomState = nullptr ) const; + + // Create input layout for drawing with a custom effect. + void __cdecl CreateInputLayout( _In_ ID3D11Device* d3dDevice, _In_ IEffect* ieffect, _Outptr_ ID3D11InputLayout** iinputLayout ); + + // 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, bool isalpha = false ); + }; + + + //---------------------------------------------------------------------------------- + // A mesh consists of one or more model mesh parts + class ModelMesh + { + public: + ModelMesh(); + virtual ~ModelMesh(); + + BoundingSphere boundingSphere; + BoundingBox boundingBox; + ModelMeshPart::Collection meshParts; + std::wstring name; + bool ccw; + bool pmalpha; + + typedef std::vector> Collection; + + // Setup states for drawing mesh + void __cdecl PrepareForRendering( _In_ ID3D11DeviceContext* deviceContext, 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 setCustomState = nullptr ) const; + }; + + + //---------------------------------------------------------------------------------- + // A model consists of one or more meshes + class Model + { + public: + virtual ~Model(); + + ModelMesh::Collection meshes; + std::wstring name; + + // Draw all the meshes in the model + void XM_CALLCONV Draw( _In_ ID3D11DeviceContext* deviceContext, CommonStates& states, FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, + bool wireframe = false, _In_opt_ std::function setCustomState = nullptr ) const; + + // 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 setEffect ); + + // Loads a model from a Visual Studio Starter Kit .CMO file + static std::unique_ptr __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 __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 __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 __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 __cdecl CreateFromVBO( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(dataSize) const uint8_t* meshData, _In_ size_t dataSize, + _In_opt_ std::shared_ptr ieffect = nullptr, bool ccw = false, bool pmalpha = false ); + static std::unique_ptr __cdecl CreateFromVBO( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName, + _In_opt_ std::shared_ptr ieffect = nullptr, bool ccw = false, bool pmalpha = false ); + + private: + std::set mEffectCache; + }; + } \ No newline at end of file diff --git a/Kits/DirectXTK/Inc/Mouse.h b/Kits/DirectXTK/Inc/Mouse.h new file mode 100644 index 0000000000000000000000000000000000000000..ed44947cf244e82fb5cf2de63988cb35f4117768 --- /dev/null +++ b/Kits/DirectXTK/Inc/Mouse.h @@ -0,0 +1,129 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +namespace ABI { namespace Windows { namespace UI { namespace Core { struct ICoreWindow; } } } } +#endif + + +namespace DirectX +{ + class Mouse + { + public: + Mouse(); + Mouse(Mouse&& moveFrom); + Mouse& operator= (Mouse&& moveFrom); + virtual ~Mouse(); + + enum Mode + { + MODE_ABSOLUTE = 0, + MODE_RELATIVE, + }; + + struct State + { + bool leftButton; + bool middleButton; + bool rightButton; + bool xButton1; + bool xButton2; + int x; + int y; + int scrollWheelValue; + Mode positionMode; + }; + + class ButtonStateTracker + { + public: + enum ButtonState + { + UP = 0, // Button is up + HELD = 1, // Button is held down + RELEASED = 2, // Button was just released + PRESSED = 3, // Buton was just pressed + }; + + ButtonState leftButton; + ButtonState middleButton; + ButtonState rightButton; + ButtonState xButton1; + ButtonState xButton2; + + ButtonStateTracker() { Reset(); } + + void __cdecl Update( const State& state ); + + void __cdecl Reset(); + + private: + State lastState; + }; + + // Retrieve the current state of the mouse + State __cdecl GetState() const; + + // Resets the accumulated scroll wheel value + void __cdecl ResetScrollWheelValue(); + + // Sets mouse mode (defaults to absolute) + void __cdecl SetMode(Mode mode); + +#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 + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) + void __cdecl SetWindow(ABI::Windows::UI::Core::ICoreWindow* window); +#ifdef __cplusplus_winrt + void __cdecl SetWindow(Windows::UI::Core::CoreWindow^ window) + { + // See https://msdn.microsoft.com/en-us/library/hh755802.aspx + SetWindow(reinterpret_cast(window)); + } +#endif + static void __cdecl SetDpi(float dpi); +#endif + + // Singleton + static Mouse& __cdecl Get(); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + Mouse(Mouse const&) DIRECTX_CTOR_DELETE + Mouse& operator=(Mouse const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Inc/PrimitiveBatch.h b/Kits/DirectXTK/Inc/PrimitiveBatch.h new file mode 100644 index 0000000000000000000000000000000000000000..5009b1d0e560528e7f9cc70b0f9dd84d09bab21a --- /dev/null +++ b/Kits/DirectXTK/Inc/PrimitiveBatch.h @@ -0,0 +1,158 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include +#include + +#pragma warning(push) +#pragma warning(disable: 4005) +#include +#pragma warning(pop) + + +namespace DirectX +{ + namespace Internal + { + // Base class, not to be used directly: clients should access this via the derived PrimitiveBatch. + class PrimitiveBatchBase + { + protected: + PrimitiveBatchBase(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices, size_t maxVertices, size_t vertexSize); + PrimitiveBatchBase(PrimitiveBatchBase&& moveFrom); + PrimitiveBatchBase& operator= (PrimitiveBatchBase&& moveFrom); + virtual ~PrimitiveBatchBase(); + + public: + // Begin/End a batch of primitive drawing operations. + void __cdecl Begin(); + void __cdecl End(); + + protected: + // Internal, untyped drawing method. + void __cdecl Draw(D3D11_PRIMITIVE_TOPOLOGY topology, bool isIndexed, _In_opt_count_(indexCount) uint16_t const* indices, size_t indexCount, size_t vertexCount, _Out_ void** pMappedVertices); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + // Prevent copying. + PrimitiveBatchBase(PrimitiveBatchBase const&) DIRECTX_CTOR_DELETE + PrimitiveBatchBase& operator= (PrimitiveBatchBase const&) DIRECTX_CTOR_DELETE + }; + } + + + // Template makes the API typesafe, eg. PrimitiveBatch. + template + class PrimitiveBatch : public Internal::PrimitiveBatchBase + { + static const size_t DefaultBatchSize = 2048; + + public: + PrimitiveBatch(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices = DefaultBatchSize * 3, size_t maxVertices = DefaultBatchSize) + : PrimitiveBatchBase(deviceContext, maxIndices, maxVertices, sizeof(TVertex)) + { } + + PrimitiveBatch(PrimitiveBatch&& moveFrom) + : PrimitiveBatchBase(std::move(moveFrom)) + { } + + PrimitiveBatch& __cdecl operator= (PrimitiveBatch&& moveFrom) + { + PrimitiveBatchBase::operator=(std::move(moveFrom)); + return *this; + } + + + // Similar to the D3D9 API DrawPrimitiveUP. + void __cdecl Draw(D3D11_PRIMITIVE_TOPOLOGY topology, _In_reads_(vertexCount) TVertex const* vertices, size_t vertexCount) + { + void* mappedVertices; + + PrimitiveBatchBase::Draw(topology, false, nullptr, 0, vertexCount, &mappedVertices); + + memcpy(mappedVertices, vertices, vertexCount * sizeof(TVertex)); + } + + + // Similar to the D3D9 API DrawIndexedPrimitiveUP. + void __cdecl DrawIndexed(D3D11_PRIMITIVE_TOPOLOGY topology, _In_reads_(indexCount) uint16_t const* indices, size_t indexCount, _In_reads_(vertexCount) TVertex const* vertices, size_t vertexCount) + { + void* mappedVertices; + + PrimitiveBatchBase::Draw(topology, true, indices, indexCount, vertexCount, &mappedVertices); + + memcpy(mappedVertices, vertices, vertexCount * sizeof(TVertex)); + } + + + void __cdecl DrawLine(TVertex const& v1, TVertex const& v2) + { + TVertex* mappedVertices; + + PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY_LINELIST, false, nullptr, 0, 2, reinterpret_cast(&mappedVertices)); + + mappedVertices[0] = v1; + mappedVertices[1] = v2; + } + + + void __cdecl DrawTriangle(TVertex const& v1, TVertex const& v2, TVertex const& v3) + { + TVertex* mappedVertices; + + PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, false, nullptr, 0, 3, reinterpret_cast(&mappedVertices)); + + mappedVertices[0] = v1; + mappedVertices[1] = v2; + mappedVertices[2] = v3; + } + + + void __cdecl DrawQuad(TVertex const& v1, TVertex const& v2, TVertex const& v3, TVertex const& v4) + { + static const uint16_t quadIndices[] = { 0, 1, 2, 0, 2, 3 }; + + TVertex* mappedVertices; + + PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, true, quadIndices, 6, 4, reinterpret_cast(&mappedVertices)); + + mappedVertices[0] = v1; + mappedVertices[1] = v2; + mappedVertices[2] = v3; + mappedVertices[3] = v4; + } + }; +} diff --git a/Kits/DirectXTK/Inc/ScreenGrab.h b/Kits/DirectXTK/Inc/ScreenGrab.h new file mode 100644 index 0000000000000000000000000000000000000000..9fa0c0a47d7307814821dff250fae5c8ae09adaf --- /dev/null +++ b/Kits/DirectXTK/Inc/ScreenGrab.h @@ -0,0 +1,64 @@ +//-------------------------------------------------------------------------------------- +// File: ScreenGrab.h +// +// Function for capturing a 2D texture and saving it to a file (aka a 'screenshot' +// when used on a Direct3D 11 Render Target). +// +// Note these functions are useful as a light-weight runtime screen grabber. For +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#include + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +namespace DirectX +{ + HRESULT __cdecl SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext, + _In_ ID3D11Resource* pSource, + _In_z_ LPCWSTR fileName ); + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) + + HRESULT __cdecl SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext, + _In_ ID3D11Resource* pSource, + _In_ REFGUID guidContainerFormat, + _In_z_ LPCWSTR fileName, + _In_opt_ const GUID* targetFormat = nullptr, + _In_opt_ std::function setCustomProps = nullptr ); + +#endif +} \ No newline at end of file diff --git a/Kits/DirectXTK/Inc/SimpleMath.h b/Kits/DirectXTK/Inc/SimpleMath.h new file mode 100644 index 0000000000000000000000000000000000000000..c6c3c4df97ec8fff754af26985d730cc11b6306a --- /dev/null +++ b/Kits/DirectXTK/Inc/SimpleMath.h @@ -0,0 +1,927 @@ +//------------------------------------------------------------------------------------- +// SimpleMath.h -- Simplified C++ Math wrapper for DirectXMath +// +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#include +#include + +#include +#include +#include + +namespace DirectX +{ + +namespace SimpleMath +{ + +struct Vector4; +struct Matrix; +struct Quaternion; +struct Plane; + +//------------------------------------------------------------------------------ +// 2D vector +struct Vector2 : public XMFLOAT2 +{ + Vector2() : XMFLOAT2(0.f, 0.f) {} + explicit Vector2(float x) : XMFLOAT2( x, x ) {} + Vector2(float _x, float _y) : XMFLOAT2(_x, _y) {} + explicit Vector2(_In_reads_(2) const float *pArray) : XMFLOAT2(pArray) {} + Vector2(FXMVECTOR V) { XMStoreFloat2( this, V ); } + Vector2(const XMFLOAT2& V) { this->x = V.x; this->y = V.y; } + + operator XMVECTOR() const { return XMLoadFloat2( this ); } + + // Comparison operators + bool operator == ( const Vector2& V ) const; + bool operator != ( const Vector2& V ) const; + + // Assignment operators + Vector2& operator= (const Vector2& V) { x = V.x; y = V.y; return *this; } + Vector2& operator= (const XMFLOAT2& V) { x = V.x; y = V.y; return *this; } + Vector2& operator+= (const Vector2& V); + Vector2& operator-= (const Vector2& V); + Vector2& operator*= (const Vector2& V); + Vector2& operator*= (float S); + Vector2& operator/= (float S); + + // Unary operators + Vector2 operator+ () const { return *this; } + Vector2 operator- () const { return Vector2(-x, -y); } + + // Vector operations + bool InBounds( const Vector2& Bounds ) const; + + float Length() const; + float LengthSquared() const; + + float Dot( const Vector2& V ) const; + void Cross( const Vector2& V, Vector2& result ) const; + Vector2 Cross( const Vector2& V ) const; + + void Normalize(); + void Normalize( Vector2& result ) const; + + void Clamp( const Vector2& vmin, const Vector2& vmax ); + void Clamp( const Vector2& vmin, const Vector2& vmax, Vector2& result ) const; + + // Static functions + static float Distance( const Vector2& v1, const Vector2& v2 ); + static float DistanceSquared( const Vector2& v1, const Vector2& v2 ); + + static void Min( const Vector2& v1, const Vector2& v2, Vector2& result ); + static Vector2 Min( const Vector2& v1, const Vector2& v2 ); + + static void Max( const Vector2& v1, const Vector2& v2, Vector2& result ); + static Vector2 Max( const Vector2& v1, const Vector2& v2 ); + + static void Lerp( const Vector2& v1, const Vector2& v2, float t, Vector2& result ); + static Vector2 Lerp( const Vector2& v1, const Vector2& v2, float t ); + + static void SmoothStep( const Vector2& v1, const Vector2& v2, float t, Vector2& result ); + static Vector2 SmoothStep( const Vector2& v1, const Vector2& v2, float t ); + + static void Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g, Vector2& result ); + static Vector2 Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g ); + + static void CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t, Vector2& result ); + static Vector2 CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t ); + + static void Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t, Vector2& result ); + static Vector2 Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t ); + + static void Reflect( const Vector2& ivec, const Vector2& nvec, Vector2& result ); + static Vector2 Reflect( const Vector2& ivec, const Vector2& nvec ); + + static void Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex, Vector2& result ); + static Vector2 Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex ); + + static void Transform( const Vector2& v, const Quaternion& quat, Vector2& result ); + static Vector2 Transform( const Vector2& v, const Quaternion& quat ); + + static void Transform( const Vector2& v, const Matrix& m, Vector2& result ); + static Vector2 Transform( const Vector2& v, const Matrix& m ); + static void Transform( _In_reads_(count) const Vector2* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector2* resultArray ); + + static void Transform( const Vector2& v, const Matrix& m, Vector4& result ); + static void Transform( _In_reads_(count) const Vector2* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector4* resultArray ); + + static void TransformNormal( const Vector2& v, const Matrix& m, Vector2& result ); + static Vector2 TransformNormal( const Vector2& v, const Matrix& m ); + static void TransformNormal( _In_reads_(count) const Vector2* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector2* resultArray ); + + // Constants + static const Vector2 Zero; + static const Vector2 One; + static const Vector2 UnitX; + static const Vector2 UnitY; +}; + +// Binary operators +Vector2 operator+ (const Vector2& V1, const Vector2& V2); +Vector2 operator- (const Vector2& V1, const Vector2& V2); +Vector2 operator* (const Vector2& V1, const Vector2& V2); +Vector2 operator* (const Vector2& V, float S); +Vector2 operator/ (const Vector2& V1, const Vector2& V2); +Vector2 operator* (float S, const Vector2& V); + +//------------------------------------------------------------------------------ +// 3D vector +struct Vector3 : public XMFLOAT3 +{ + Vector3() : XMFLOAT3(0.f, 0.f, 0.f) {} + explicit Vector3(float x) : XMFLOAT3( x, x, x ) {} + Vector3(float _x, float _y, float _z) : XMFLOAT3(_x, _y, _z) {} + explicit Vector3(_In_reads_(3) const float *pArray) : XMFLOAT3(pArray) {} + Vector3(FXMVECTOR V) { XMStoreFloat3( this, V ); } + Vector3(const XMFLOAT3& V) { this->x = V.x; this->y = V.y; this->z = V.z; } + + operator XMVECTOR() const { return XMLoadFloat3( this ); } + + // Comparison operators + bool operator == ( const Vector3& V ) const; + bool operator != ( const Vector3& V ) const; + + // Assignment operators + Vector3& operator= (const Vector3& V) { x = V.x; y = V.y; z = V.z; return *this; } + Vector3& operator= (const XMFLOAT3& V) { x = V.x; y = V.y; z = V.z; return *this; } + Vector3& operator+= (const Vector3& V); + Vector3& operator-= (const Vector3& V); + Vector3& operator*= (const Vector3& V); + Vector3& operator*= (float S); + Vector3& operator/= (float S); + + // Unary operators + Vector3 operator+ () const { return *this; } + Vector3 operator- () const; + + // Vector operations + bool InBounds( const Vector3& Bounds ) const; + + float Length() const; + float LengthSquared() const; + + float Dot( const Vector3& V ) const; + void Cross( const Vector3& V, Vector3& result ) const; + Vector3 Cross( const Vector3& V ) const; + + void Normalize(); + void Normalize( Vector3& result ) const; + + void Clamp( const Vector3& vmin, const Vector3& vmax ); + void Clamp( const Vector3& vmin, const Vector3& vmax, Vector3& result ) const; + + // Static functions + static float Distance( const Vector3& v1, const Vector3& v2 ); + static float DistanceSquared( const Vector3& v1, const Vector3& v2 ); + + static void Min( const Vector3& v1, const Vector3& v2, Vector3& result ); + static Vector3 Min( const Vector3& v1, const Vector3& v2 ); + + static void Max( const Vector3& v1, const Vector3& v2, Vector3& result ); + static Vector3 Max( const Vector3& v1, const Vector3& v2 ); + + static void Lerp( const Vector3& v1, const Vector3& v2, float t, Vector3& result ); + static Vector3 Lerp( const Vector3& v1, const Vector3& v2, float t ); + + static void SmoothStep( const Vector3& v1, const Vector3& v2, float t, Vector3& result ); + static Vector3 SmoothStep( const Vector3& v1, const Vector3& v2, float t ); + + static void Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g, Vector3& result ); + static Vector3 Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g ); + + static void CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t, Vector3& result ); + static Vector3 CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t ); + + static void Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t, Vector3& result ); + static Vector3 Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t ); + + static void Reflect( const Vector3& ivec, const Vector3& nvec, Vector3& result ); + static Vector3 Reflect( const Vector3& ivec, const Vector3& nvec ); + + static void Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex, Vector3& result ); + static Vector3 Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex ); + + static void Transform( const Vector3& v, const Quaternion& quat, Vector3& result ); + static Vector3 Transform( const Vector3& v, const Quaternion& quat ); + + static void Transform( const Vector3& v, const Matrix& m, Vector3& result ); + static Vector3 Transform( const Vector3& v, const Matrix& m ); + static void Transform( _In_reads_(count) const Vector3* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector3* resultArray ); + + static void Transform( const Vector3& v, const Matrix& m, Vector4& result ); + static void Transform( _In_reads_(count) const Vector3* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector4* resultArray ); + + static void TransformNormal( const Vector3& v, const Matrix& m, Vector3& result ); + static Vector3 TransformNormal( const Vector3& v, const Matrix& m ); + static void TransformNormal( _In_reads_(count) const Vector3* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector3* resultArray ); + + // Constants + static const Vector3 Zero; + static const Vector3 One; + static const Vector3 UnitX; + static const Vector3 UnitY; + static const Vector3 UnitZ; + static const Vector3 Up; + static const Vector3 Down; + static const Vector3 Right; + static const Vector3 Left; + static const Vector3 Forward; + static const Vector3 Backward; +}; + +// Binary operators +Vector3 operator+ (const Vector3& V1, const Vector3& V2); +Vector3 operator- (const Vector3& V1, const Vector3& V2); +Vector3 operator* (const Vector3& V1, const Vector3& V2); +Vector3 operator* (const Vector3& V, float S); +Vector3 operator/ (const Vector3& V1, const Vector3& V2); +Vector3 operator* (float S, const Vector3& V); + +//------------------------------------------------------------------------------ +// 4D vector +struct Vector4 : public XMFLOAT4 +{ + Vector4() : XMFLOAT4(0.f, 0.f, 0.f, 0.f) {} + explicit Vector4(float x) : XMFLOAT4( x, x, x, x ) {} + Vector4(float _x, float _y, float _z, float _w) : XMFLOAT4(_x, _y, _z, _w) {} + explicit Vector4(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {} + Vector4(FXMVECTOR V) { XMStoreFloat4( this, V ); } + Vector4(const XMFLOAT4& V) { this->x = V.x; this->y = V.y; this->z = V.z; this->w = V.w; } + + operator XMVECTOR() const { return XMLoadFloat4( this ); } + + // Comparison operators + bool operator == ( const Vector4& V ) const; + bool operator != ( const Vector4& V ) const; + + // Assignment operators + Vector4& operator= (const Vector4& V) { x = V.x; y = V.y; z = V.z; w = V.w; return *this; } + Vector4& operator= (const XMFLOAT4& V) { x = V.x; y = V.y; z = V.z; w = V.w; return *this; } + Vector4& operator+= (const Vector4& V); + Vector4& operator-= (const Vector4& V); + Vector4& operator*= (const Vector4& V); + Vector4& operator*= (float S); + Vector4& operator/= (float S); + + // Unary operators + Vector4 operator+ () const { return *this; } + Vector4 operator- () const; + + // Vector operations + bool InBounds( const Vector4& Bounds ) const; + + float Length() const; + float LengthSquared() const; + + float Dot( const Vector4& V ) const; + void Cross( const Vector4& v1, const Vector4& v2, Vector4& result ) const; + Vector4 Cross( const Vector4& v1, const Vector4& v2 ) const; + + void Normalize(); + void Normalize( Vector4& result ) const; + + void Clamp( const Vector4& vmin, const Vector4& vmax ); + void Clamp( const Vector4& vmin, const Vector4& vmax, Vector4& result ) const; + + // Static functions + static float Distance( const Vector4& v1, const Vector4& v2 ); + static float DistanceSquared( const Vector4& v1, const Vector4& v2 ); + + static void Min( const Vector4& v1, const Vector4& v2, Vector4& result ); + static Vector4 Min( const Vector4& v1, const Vector4& v2 ); + + static void Max( const Vector4& v1, const Vector4& v2, Vector4& result ); + static Vector4 Max( const Vector4& v1, const Vector4& v2 ); + + static void Lerp( const Vector4& v1, const Vector4& v2, float t, Vector4& result ); + static Vector4 Lerp( const Vector4& v1, const Vector4& v2, float t ); + + static void SmoothStep( const Vector4& v1, const Vector4& v2, float t, Vector4& result ); + static Vector4 SmoothStep( const Vector4& v1, const Vector4& v2, float t ); + + static void Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g, Vector4& result ); + static Vector4 Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g ); + + static void CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t, Vector4& result ); + static Vector4 CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t ); + + static void Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t, Vector4& result ); + static Vector4 Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t ); + + static void Reflect( const Vector4& ivec, const Vector4& nvec, Vector4& result ); + static Vector4 Reflect( const Vector4& ivec, const Vector4& nvec ); + + static void Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex, Vector4& result ); + static Vector4 Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex ); + + static void Transform( const Vector2& v, const Quaternion& quat, Vector4& result ); + static Vector4 Transform( const Vector2& v, const Quaternion& quat ); + + static void Transform( const Vector3& v, const Quaternion& quat, Vector4& result ); + static Vector4 Transform( const Vector3& v, const Quaternion& quat ); + + static void Transform( const Vector4& v, const Quaternion& quat, Vector4& result ); + static Vector4 Transform( const Vector4& v, const Quaternion& quat ); + + static void Transform( const Vector4& v, const Matrix& m, Vector4& result ); + static Vector4 Transform( const Vector4& v, const Matrix& m ); + static void Transform( _In_reads_(count) const Vector4* varray, size_t count, const Matrix& m, _Out_writes_(count) Vector4* resultArray ); + + // Constants + static const Vector4 Zero; + static const Vector4 One; + static const Vector4 UnitX; + static const Vector4 UnitY; + static const Vector4 UnitZ; + static const Vector4 UnitW; +}; + +// Binary operators +Vector4 operator+ (const Vector4& V1, const Vector4& V2); +Vector4 operator- (const Vector4& V1, const Vector4& V2); +Vector4 operator* (const Vector4& V1, const Vector4& V2); +Vector4 operator* (const Vector4& V, float S); +Vector4 operator/ (const Vector4& V1, const Vector4& V2); +Vector4 operator* (float S, const Vector4& V); + +//------------------------------------------------------------------------------ +// 4x4 Matrix (assumes right-handed cooordinates) +struct Matrix : public XMFLOAT4X4 +{ + Matrix() : XMFLOAT4X4( 1.f, 0, 0, 0, + 0, 1.f, 0, 0, + 0, 0, 1.f, 0, + 0, 0, 0, 1.f ) {} + Matrix(float m00, float m01, float m02, float m03, + float m10, float m11, float m12, float m13, + float m20, float m21, float m22, float m23, + float m30, float m31, float m32, float m33) : XMFLOAT4X4(m00, m01, m02, m03, + m10, m11, m12, m13, + m20, m21, m22, m23, + m30, m31, m32, m33) {} + explicit Matrix( const Vector3& r0, const Vector3& r1, const Vector3& r2 ) : XMFLOAT4X4( r0.x, r0.y, r0.z, 0, + r1.x, r1.y, r1.z, 0, + r2.x, r2.y, r2.z, 0, + 0, 0, 0, 1.f ) {} + explicit Matrix( const Vector4& r0, const Vector4& r1, const Vector4& r2, const Vector4& r3 ) : XMFLOAT4X4( r0.x, r0.y, r0.z, r0.w, + r1.x, r1.y, r1.z, r1.w, + r2.x, r2.y, r2.z, r2.w, + r3.x, r3.y, r3.z, r3.w ) {} + Matrix(const XMFLOAT4X4& M) { memcpy_s(this, sizeof(float)*16, &M, sizeof(XMFLOAT4X4)); } + Matrix(const XMFLOAT3X3& M); + Matrix(const XMFLOAT4X3& M); + + explicit Matrix(_In_reads_(16) const float *pArray) : XMFLOAT4X4(pArray) {} + Matrix( CXMMATRIX M ) { XMStoreFloat4x4( this, M ); } + + operator XMMATRIX() const { return XMLoadFloat4x4( this ); } + + // Comparison operators + bool operator == ( const Matrix& M ) const; + bool operator != ( const Matrix& M ) const; + + // Assignment operators + Matrix& operator= (const Matrix& M) { memcpy_s( this, sizeof(float)*16, &M, sizeof(float)*16 ); return *this; } + Matrix& operator= (const XMFLOAT4X4& M) { memcpy_s( this, sizeof(float)*16, &M, sizeof(XMFLOAT4X4) ); return *this; } + Matrix& operator= (const XMFLOAT3X3& M); + Matrix& operator= (const XMFLOAT4X3& M); + Matrix& operator+= (const Matrix& M); + Matrix& operator-= (const Matrix& M); + Matrix& operator*= (const Matrix& M); + Matrix& operator*= (float S); + Matrix& operator/= (float S); + + Matrix& operator/= (const Matrix& M); + // Element-wise divide + + // Unary operators + Matrix operator+ () const { return *this; } + Matrix operator- () const; + + // Properties + Vector3 Up() const { return Vector3( _21, _22, _23); } + void Up( const Vector3& v ) { _21 = v.x; _22 = v.y; _23 = v.z; } + + Vector3 Down() const { return Vector3( -_21, -_22, -_23); } + void Down( const Vector3& v ) { _21 = -v.x; _22 = -v.y; _23 = -v.z; } + + Vector3 Right() const { return Vector3( _11, _12, _13 ); } + void Right( const Vector3& v ) { _11 = v.x; _12 = v.y; _13 = v.z; } + + Vector3 Left() const { return Vector3( -_11, -_12, -_13 ); } + void Left( const Vector3& v ) { _11 = -v.x; _12 = -v.y; _13 = -v.z; } + + Vector3 Forward() const { return Vector3( -_31, -_32, -_33 ); } + void Forward( const Vector3& v ) { _31 = -v.x; _32 = -v.y; _33 = -v.z; } + + Vector3 Backward() const { return Vector3( _31, _32, _33 ); } + void Backward( const Vector3& v ) { _31 = v.x; _32 = v.y; _33 = v.z; } + + Vector3 Translation() const { return Vector3( _41, _42, _43 ); } + void Translation( const Vector3& v ) { _41 = v.x; _42 = v.y; _43 = v.z; } + + // Matrix operations + bool Decompose( Vector3& scale, Quaternion& rotation, Vector3& translation ); + + Matrix Transpose() const; + void Transpose( Matrix& result ) const; + + Matrix Invert() const; + void Invert( Matrix& result ) const; + + float Determinant() const; + + // Static functions + static Matrix CreateBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& cameraUp, _In_opt_ const Vector3* cameraForward = nullptr ); + + static Matrix CreateConstrainedBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& rotateAxis, + _In_opt_ const Vector3* cameraForward = nullptr, _In_opt_ const Vector3* objectForward = nullptr); + + static Matrix CreateTranslation( const Vector3& position ); + static Matrix CreateTranslation( float x, float y, float z ); + + static Matrix CreateScale( const Vector3& scales ); + static Matrix CreateScale( float xs, float ys, float zs ); + static Matrix CreateScale( float scale ); + + static Matrix CreateRotationX( float radians ); + static Matrix CreateRotationY( float radians ); + static Matrix CreateRotationZ( float radians ); + + static Matrix CreateFromAxisAngle( const Vector3& axis, float angle ); + + static Matrix CreatePerspectiveFieldOfView( float fov, float aspectRatio, float nearPlane, float farPlane ); + static Matrix CreatePerspective( float width, float height, float nearPlane, float farPlane ); + static Matrix CreatePerspectiveOffCenter( float left, float right, float bottom, float top, float nearPlane, float farPlane ); + static Matrix CreateOrthographic( float width, float height, float zNearPlane, float zFarPlane ); + static Matrix CreateOrthographicOffCenter( float left, float right, float bottom, float top, float zNearPlane, float zFarPlane ); + + static Matrix CreateLookAt( const Vector3& position, const Vector3& target, const Vector3& up ); + static Matrix CreateWorld( const Vector3& position, const Vector3& forward, const Vector3& up ); + + static Matrix CreateFromQuaternion( const Quaternion& quat ); + + static Matrix CreateFromYawPitchRoll( float yaw, float pitch, float roll ); + + static Matrix CreateShadow( const Vector3& lightDir, const Plane& plane ); + + static Matrix CreateReflection( const Plane& plane ); + + static void Lerp( const Matrix& M1, const Matrix& M2, float t, Matrix& result ); + static Matrix Lerp( const Matrix& M1, const Matrix& M2, float t ); + + static void Transform( const Matrix& M, const Quaternion& rotation, Matrix& result ); + static Matrix Transform( const Matrix& M, const Quaternion& rotation ); + + // Constants + static const Matrix Identity; +}; + +// Binary operators +Matrix operator+ (const Matrix& M1, const Matrix& M2); +Matrix operator- (const Matrix& M1, const Matrix& M2); +Matrix operator* (const Matrix& M1, const Matrix& M2); +Matrix operator* (const Matrix& M, float S); +Matrix operator/ (const Matrix& M, float S); +Matrix operator/ (const Matrix& M1, const Matrix& M2); + // Element-wise divide +Matrix operator* (float S, const Matrix& M); + + +//----------------------------------------------------------------------------- +// Plane +struct Plane : public XMFLOAT4 +{ + Plane() : XMFLOAT4(0.f, 1.f, 0.f, 0.f) {} + Plane(float _x, float _y, float _z, float _w) : XMFLOAT4(_x, _y, _z, _w) {} + Plane(const Vector3& normal, float d) : XMFLOAT4(normal.x, normal.y, normal.z, d) {} + Plane(const Vector3& point1, const Vector3& point2, const Vector3& point3 ); + Plane(const Vector3& point, const Vector3& normal); + explicit Plane(const Vector4& v) : XMFLOAT4(v.x, v.y, v.z, v.w) {} + explicit Plane(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {} + Plane(FXMVECTOR V) { XMStoreFloat4( this, V ); } + Plane(const XMFLOAT4& p) { this->x = p.x; this->y = p.y; this->z = p.z; this->w = p.w; } + + operator XMVECTOR() const { return XMLoadFloat4( this ); } + + // Comparison operators + bool operator == ( const Plane& p ) const; + bool operator != ( const Plane& p ) const; + + // Assignment operators + Plane& operator= (const Plane& p) { x = p.x; y = p.y; z = p.z; w = p.w; return *this; } + Plane& operator= (const XMFLOAT4& p) { x = p.x; y = p.y; z = p.z; w = p.w; return *this; } + + // Properties + Vector3 Normal() const { return Vector3( x, y, z ); } + void Normal( const Vector3& normal ) { x = normal.x; y = normal.y; z = normal.z; } + + float D() const { return w; } + void D(float d) { w = d; } + + // Plane operations + void Normalize(); + void Normalize( Plane& result ) const; + + float Dot( const Vector4& v ) const; + float DotCoordinate( const Vector3& position ) const; + float DotNormal( const Vector3& normal ) const; + + // Static functions + static void Transform( const Plane& plane, const Matrix& M, Plane& result ); + static Plane Transform( const Plane& plane, const Matrix& M ); + + static void Transform( const Plane& plane, const Quaternion& rotation, Plane& result ); + static Plane Transform( const Plane& plane, const Quaternion& rotation ); + // Input quaternion must be the inverse transpose of the transformation +}; + +//------------------------------------------------------------------------------ +// Quaternion +struct Quaternion : public XMFLOAT4 +{ + Quaternion() : XMFLOAT4(0, 0, 0, 1.f) {} + Quaternion( float _x, float _y, float _z, float _w ) : XMFLOAT4(_x, _y, _z, _w) {} + Quaternion( const Vector3& v, float scalar ) : XMFLOAT4( v.x, v.y, v.z, scalar ) {} + explicit Quaternion( const Vector4& v ) : XMFLOAT4( v.x, v.y, v.z, v.w ) {} + explicit Quaternion(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {} + Quaternion(FXMVECTOR V) { XMStoreFloat4( this, V ); } + Quaternion(const XMFLOAT4& q) { this->x = q.x; this->y = q.y; this->z = q.z; this->w = q.w; } + + operator XMVECTOR() const { return XMLoadFloat4( this ); } + + // Comparison operators + bool operator == ( const Quaternion& q ) const; + bool operator != ( const Quaternion& q ) const; + + // Assignment operators + Quaternion& operator= (const Quaternion& q) { x = q.x; y = q.y; z = q.z; w = q.w; return *this; } + Quaternion& operator= (const XMFLOAT4& q) { x = q.x; y = q.y; z = q.z; w = q.w; return *this; } + Quaternion& operator+= (const Quaternion& q); + Quaternion& operator-= (const Quaternion& q); + Quaternion& operator*= (const Quaternion& q); + Quaternion& operator*= (float S); + Quaternion& operator/= (const Quaternion& q); + + // Unary operators + Quaternion operator+ () const { return *this; } + Quaternion operator- () const; + + // Quaternion operations + float Length() const; + float LengthSquared() const; + + void Normalize(); + void Normalize( Quaternion& result ) const; + + void Conjugate(); + void Conjugate( Quaternion& result ) const; + + void Inverse( Quaternion& result ) const; + + float Dot( const Quaternion& Q ) const; + + // Static functions + static Quaternion CreateFromAxisAngle( const Vector3& axis, float angle ); + static Quaternion CreateFromYawPitchRoll( float yaw, float pitch, float roll ); + static Quaternion CreateFromRotationMatrix( const Matrix& M ); + + static void Lerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result ); + static Quaternion Lerp( const Quaternion& q1, const Quaternion& q2, float t ); + + static void Slerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result ); + static Quaternion Slerp( const Quaternion& q1, const Quaternion& q2, float t ); + + static void Concatenate( const Quaternion& q1, const Quaternion& q2, Quaternion& result ); + static Quaternion Concatenate( const Quaternion& q1, const Quaternion& q2 ); + + // Constants + static const Quaternion Identity; +}; + +// Binary operators +Quaternion operator+ (const Quaternion& Q1, const Quaternion& Q2); +Quaternion operator- (const Quaternion& Q1, const Quaternion& Q2); +Quaternion operator* (const Quaternion& Q1, const Quaternion& Q2); +Quaternion operator* (const Quaternion& Q, float S); +Quaternion operator/ (const Quaternion& Q1, const Quaternion& Q2); +Quaternion operator* (float S, const Quaternion& Q); + +//------------------------------------------------------------------------------ +// Color +struct Color : public XMFLOAT4 +{ + Color() : XMFLOAT4(0, 0, 0, 1.f) {} + Color( float _r, float _g, float _b ) : XMFLOAT4(_r, _g, _b, 1.f) {} + Color( float _r, float _g, float _b, float _a ) : XMFLOAT4(_r, _g, _b, _a) {} + explicit Color( const Vector3& clr ) : XMFLOAT4( clr.x, clr.y, clr.z, 1.f ) {} + explicit Color( const Vector4& clr ) : XMFLOAT4( clr.x, clr.y, clr.z, clr.w ) {} + explicit Color(_In_reads_(4) const float *pArray) : XMFLOAT4(pArray) {} + Color(FXMVECTOR V) { XMStoreFloat4( this, V ); } + Color(const XMFLOAT4& c) { this->x = c.x; this->y = c.y; this->z = c.z; this->w = c.w; } + + explicit Color( const DirectX::PackedVector::XMCOLOR& Packed ); + // BGRA Direct3D 9 D3DCOLOR packed color + + explicit Color( const DirectX::PackedVector::XMUBYTEN4& Packed ); + // RGBA XNA Game Studio packed color + + operator XMVECTOR() const { return XMLoadFloat4( this ); } + operator const float*() const { return reinterpret_cast(this); } + + // Comparison operators + bool operator == ( const Color& c ) const; + bool operator != ( const Color& c ) const; + + // Assignment operators + Color& operator= (const Color& c) { x = c.x; y = c.y; z = c.z; w = c.w; return *this; } + Color& operator= (const XMFLOAT4& c) { x = c.x; y = c.y; z = c.z; w = c.w; return *this; } + Color& operator= (const DirectX::PackedVector::XMCOLOR& Packed); + Color& operator= (const DirectX::PackedVector::XMUBYTEN4& Packed); + Color& operator+= (const Color& c); + Color& operator-= (const Color& c); + Color& operator*= (const Color& c); + Color& operator*= (float S); + Color& operator/= (const Color& c); + + // Unary operators + Color operator+ () const { return *this; } + Color operator- () const; + + // Properties + float R() const { return x; } + void R(float r) { x = r; } + + float G() const { return y; } + void G(float g) { y = g; } + + float B() const { return z; } + void B(float b) { z = b; } + + float A() const { return w; } + void A(float a) { w = a; } + + // Color operations + DirectX::PackedVector::XMCOLOR BGRA() const; + DirectX::PackedVector::XMUBYTEN4 RGBA() const; + + Vector3 ToVector3() const; + Vector4 ToVector4() const; + + void Negate(); + void Negate( Color& result ) const; + + void Saturate(); + void Saturate( Color& result ) const; + + void Premultiply(); + void Premultiply( Color& result ) const; + + void AdjustSaturation( float sat ); + void AdjustSaturation( float sat, Color& result ) const; + + void AdjustContrast( float contrast ); + void AdjustContrast( float contrast, Color& result ) const; + + // Static functions + static void Modulate( const Color& c1, const Color& c2, Color& result ); + static Color Modulate( const Color& c1, const Color& c2 ); + + static void Lerp( const Color& c1, const Color& c2, float t, Color& result ); + static Color Lerp( const Color& c1, const Color& c2, float t ); +}; + +// Binary operators +Color operator+ (const Color& C1, const Color& C2); +Color operator- (const Color& C1, const Color& C2); +Color operator* (const Color& C1, const Color& C2); +Color operator* (const Color& C, float S); +Color operator/ (const Color& C1, const Color& C2); +Color operator* (float S, const Color& C); + +//------------------------------------------------------------------------------ +// Ray +class Ray +{ +public: + Vector3 position; + Vector3 direction; + + Ray() : position(0,0,0), direction(0,0,1) {} + Ray( const Vector3& pos, const Vector3& dir ) : position(pos), direction(dir) {} + + // Comparison operators + bool operator == ( const Ray& r ) const; + bool operator != ( const Ray& r ) const; + + // Ray operations + bool Intersects( const BoundingSphere& sphere, _Out_ float& Dist ) const; + bool Intersects( const BoundingBox& box, _Out_ float& Dist ) const; + bool Intersects( const Vector3& tri0, const Vector3& tri1, const Vector3& tri2, _Out_ float& Dist ) const; + bool Intersects( const Plane& plane, _Out_ float& Dist ) const; +}; + +//------------------------------------------------------------------------------ +// Viewport +class Viewport +{ +public: + float x; + float y; + float width; + float height; + float minDepth; + float maxDepth; + + Viewport() : + x(0.f), y(0.f), width(0.f), height(0.f), minDepth(0.f), maxDepth(1.f) {} + Viewport( float ix, float iy, float iw, float ih, float iminz = 0.f, float imaxz = 1.f ) : + x(ix), y(iy), width(iw), height(ih), minDepth(iminz), maxDepth(imaxz) {} + explicit Viewport(const RECT& rct) : + x(float(rct.left)), y(float(rct.top)), + width(float(rct.right - rct.left)), + height(float(rct.bottom - rct.top)), + minDepth(0.f), maxDepth(1.f) {} + explicit Viewport(const D3D11_VIEWPORT& vp) : + x(vp.TopLeftX), y(vp.TopLeftY), + width(vp.Width), height(vp.Height), + minDepth(vp.MinDepth), maxDepth(vp.MaxDepth) {} + + // Direct3D 11 interop + operator D3D11_VIEWPORT() { return *reinterpret_cast(this); } + const D3D11_VIEWPORT* Get11() const { return reinterpret_cast(this); } + + // Comparison operators + bool operator == ( const Viewport& vp ) const; + bool operator != ( const Viewport& vp ) const; + + // Assignment operators + Viewport& operator= (const Viewport& vp); + Viewport& operator= (const RECT& rct); + Viewport& operator= (const D3D11_VIEWPORT& vp); + + // Viewport operations + float AspectRatio() const; + + Vector3 Project(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world ) const; + void Project(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world, Vector3& result ) const; + + Vector3 Unproject(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world ) const; + void Unproject(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world, Vector3& result ) const; + + // Static methods + static RECT __cdecl ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UINT backBufferHeight, int outputWidth, int outputHeight); + static RECT __cdecl ComputeTitleSafeArea(UINT backBufferWidth, UINT backBufferHeight); +}; + +#include "SimpleMath.inl" + +}; // namespace SimpleMath + +}; // namespace DirectX + +//------------------------------------------------------------------------------ +// Support for SimpleMath and Standard C++ Library containers +namespace std +{ + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Vector2& V1, const DirectX::SimpleMath::Vector2& V2) const + { + return ( (V1.x < V2.x) || ((V1.x == V2.x) && (V1.y < V2.y)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Vector3& V1, const DirectX::SimpleMath::Vector3& V2) const + { + return ( (V1.x < V2.x) + || ((V1.x == V2.x) && (V1.y < V2.y)) + || ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z < V2.z)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Vector4& V1, const DirectX::SimpleMath::Vector4& V2) const + { + return ( (V1.x < V2.x) + || ((V1.x == V2.x) && (V1.y < V2.y)) + || ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z < V2.z)) + || ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z == V2.z) && (V1.w < V2.w)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Matrix& M1, const DirectX::SimpleMath::Matrix& M2) const + { + if (M1._11 != M2._11) return M1._11 < M2._11; + if (M1._12 != M2._12) return M1._12 < M2._12; + if (M1._13 != M2._13) return M1._13 < M2._13; + if (M1._14 != M2._14) return M1._14 < M2._14; + if (M1._21 != M2._21) return M1._21 < M2._21; + if (M1._22 != M2._22) return M1._22 < M2._22; + if (M1._23 != M2._23) return M1._23 < M2._23; + if (M1._24 != M2._24) return M1._24 < M2._24; + if (M1._31 != M2._31) return M1._31 < M2._31; + if (M1._32 != M2._32) return M1._32 < M2._32; + if (M1._33 != M2._33) return M1._33 < M2._33; + if (M1._34 != M2._34) return M1._34 < M2._34; + if (M1._41 != M2._41) return M1._41 < M2._41; + if (M1._42 != M2._42) return M1._42 < M2._42; + if (M1._43 != M2._43) return M1._43 < M2._43; + if (M1._44 != M2._44) return M1._44 < M2._44; + + return false; + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Plane& P1, const DirectX::SimpleMath::Plane& P2) const + { + return ( (P1.x < P2.x) + || ((P1.x == P2.x) && (P1.y < P2.y)) + || ((P1.x == P2.x) && (P1.y == P2.y) && (P1.z < P2.z)) + || ((P1.x == P2.x) && (P1.y == P2.y) && (P1.z == P2.z) && (P1.w < P2.w)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Quaternion& Q1, const DirectX::SimpleMath::Quaternion& Q2) const + { + return ( (Q1.x < Q2.x) + || ((Q1.x == Q2.x) && (Q1.y < Q2.y)) + || ((Q1.x == Q2.x) && (Q1.y == Q2.y) && (Q1.z < Q2.z)) + || ((Q1.x == Q2.x) && (Q1.y == Q2.y) && (Q1.z == Q2.z) && (Q1.w < Q2.w)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Color& C1, const DirectX::SimpleMath::Color& C2) const + { + return ( (C1.x < C2.x) + || ((C1.x == C2.x) && (C1.y < C2.y)) + || ((C1.x == C2.x) && (C1.y == C2.y) && (C1.z < C2.z)) + || ((C1.x == C2.x) && (C1.y == C2.y) && (C1.z == C2.z) && (C1.w < C2.w)) ); + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Ray& R1, const DirectX::SimpleMath::Ray& R2) const + { + if (R1.position.x != R2.position.x) return R1.position.x < R2.position.x; + if (R1.position.y != R2.position.y) return R1.position.y < R2.position.y; + if (R1.position.z != R2.position.z) return R1.position.z < R2.position.z; + + if (R1.direction.x != R2.direction.x) return R1.direction.x < R2.direction.x; + if (R1.direction.y != R2.direction.y) return R1.direction.y < R2.direction.y; + if (R1.direction.z != R2.direction.z) return R1.direction.z < R2.direction.z; + + return false; + } + }; + + template<> struct less + { + bool operator()(const DirectX::SimpleMath::Viewport& vp1, const DirectX::SimpleMath::Viewport& vp2) const + { + if (vp1.x != vp2.x) return (vp1.x < vp2.x); + if (vp1.y != vp2.y) return (vp1.y < vp2.y); + + if (vp1.width != vp2.width) return (vp1.width < vp2.width); + if (vp1.height != vp2.height) return (vp1.height < vp2.height); + + if (vp1.minDepth != vp2.minDepth) return (vp1.minDepth < vp2.minDepth); + if (vp1.maxDepth != vp2.maxDepth) return (vp1.maxDepth < vp2.maxDepth); + + return false; + } + }; + +} // namespace std diff --git a/Kits/DirectXTK/Inc/SimpleMath.inl b/Kits/DirectXTK/Inc/SimpleMath.inl new file mode 100644 index 0000000000000000000000000000000000000000..4930602cb90394a37593c3cf2c630c8d4c8fbd34 --- /dev/null +++ b/Kits/DirectXTK/Inc/SimpleMath.inl @@ -0,0 +1,3563 @@ +//------------------------------------------------------------------------------------- +// SimpleMath.inl -- Simplified C++ Math wrapper for DirectXMath +// +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//------------------------------------------------------------------------------------- + +#pragma once + +/**************************************************************************** + * + * Vector2 + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Vector2::operator == ( const Vector2& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + return XMVector2Equal( v1, v2 ); +} + +inline bool Vector2::operator != ( const Vector2& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + return XMVector2NotEqual( v1, v2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Vector2& Vector2::operator+= (const Vector2& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorAdd(v1,v2); + XMStoreFloat2( this, X ); + return *this; +} + +inline Vector2& Vector2::operator-= (const Vector2& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorSubtract(v1,v2); + XMStoreFloat2( this, X ); + return *this; +} + +inline Vector2& Vector2::operator*= (const Vector2& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorMultiply(v1,v2); + XMStoreFloat2( this, X ); + return *this; +} + +inline Vector2& Vector2::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVectorScale(v1,S); + XMStoreFloat2( this, X ); + return *this; +} + +inline Vector2& Vector2::operator/= (float S) +{ + using namespace DirectX; + assert( S != 0.0f ); + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVectorScale(v1, 1.f/S); + XMStoreFloat2( this, X ); + return *this; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Vector2 operator+ (const Vector2& V1, const Vector2& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V1 ); + XMVECTOR v2 = XMLoadFloat2( &V2 ); + XMVECTOR X = XMVectorAdd(v1,v2); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator- (const Vector2& V1, const Vector2& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V1 ); + XMVECTOR v2 = XMLoadFloat2( &V2 ); + XMVECTOR X = XMVectorSubtract(v1,v2); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator* (const Vector2& V1, const Vector2& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V1 ); + XMVECTOR v2 = XMLoadFloat2( &V2 ); + XMVECTOR X = XMVectorMultiply(v1,v2); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator* (const Vector2& V, float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator/ (const Vector2& V1, const Vector2& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V1 ); + XMVECTOR v2 = XMLoadFloat2( &V2 ); + XMVECTOR X = XMVectorDivide(v1,v2); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +inline Vector2 operator* (float S, const Vector2& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector2 R; + XMStoreFloat2( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Vector operations +//------------------------------------------------------------------------------ + +inline bool Vector2::InBounds( const Vector2& Bounds ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &Bounds ); + return XMVector2InBounds( v1, v2 ); +} + +inline float Vector2::Length() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVector2Length( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector2::LengthSquared() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVector2LengthSq( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector2::Dot( const Vector2& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR X = XMVector2Dot( v1, v2 ); + return XMVectorGetX( X ); +} + +inline void Vector2::Cross( const Vector2& V, Vector2& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR R = XMVector2Cross( v1, v2 ); + XMStoreFloat2( &result, R ); +} + +inline Vector2 Vector2::Cross( const Vector2& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &V ); + XMVECTOR R = XMVector2Cross( v1, v2 ); + + Vector2 result; + XMStoreFloat2( &result, R ); + return result; +} + +inline void Vector2::Normalize() +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVector2Normalize( v1 ); + XMStoreFloat2( this, X ); +} + +inline void Vector2::Normalize( Vector2& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR X = XMVector2Normalize( v1 ); + XMStoreFloat2( &result, X ); +} + +inline void Vector2::Clamp( const Vector2& vmin, const Vector2& vmax ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &vmin ); + XMVECTOR v3 = XMLoadFloat2( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat2( this, X ); +} + +inline void Vector2::Clamp( const Vector2& vmin, const Vector2& vmax, Vector2& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( this ); + XMVECTOR v2 = XMLoadFloat2( &vmin ); + XMVECTOR v3 = XMLoadFloat2( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat2( &result, X ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline float Vector2::Distance( const Vector2& v1, const Vector2& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector2Length( V ); + return XMVectorGetX( X ); +} + +inline float Vector2::DistanceSquared( const Vector2& v1, const Vector2& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector2LengthSq( V ); + return XMVectorGetX( X ); +} + +inline void Vector2::Min( const Vector2& v1, const Vector2& v2, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Min( const Vector2& v1, const Vector2& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Max( const Vector2& v1, const Vector2& v2, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Max( const Vector2& v1, const Vector2& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Lerp( const Vector2& v1, const Vector2& v2, float t, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Lerp( const Vector2& v1, const Vector2& v2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::SmoothStep( const Vector2& v1, const Vector2& v2, float t, Vector2& result ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::SmoothStep( const Vector2& v1, const Vector2& v2, float t ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR x3 = XMLoadFloat2( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Barycentric( const Vector2& v1, const Vector2& v2, const Vector2& v3, float f, float g ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR x3 = XMLoadFloat2( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR x3 = XMLoadFloat2( &v3 ); + XMVECTOR x4 = XMLoadFloat2( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::CatmullRom( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &v2 ); + XMVECTOR x3 = XMLoadFloat2( &v3 ); + XMVECTOR x4 = XMLoadFloat2( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &t1 ); + XMVECTOR x3 = XMLoadFloat2( &v2 ); + XMVECTOR x4 = XMLoadFloat2( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Hermite( const Vector2& v1, const Vector2& t1, const Vector2& v2, const Vector2& t2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat2( &v1 ); + XMVECTOR x2 = XMLoadFloat2( &t1 ); + XMVECTOR x3 = XMLoadFloat2( &v2 ); + XMVECTOR x4 = XMLoadFloat2( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Reflect( const Vector2& ivec, const Vector2& nvec, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat2( &ivec ); + XMVECTOR n = XMLoadFloat2( &nvec ); + XMVECTOR X = XMVector2Reflect( i, n ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Reflect( const Vector2& ivec, const Vector2& nvec ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat2( &ivec ); + XMVECTOR n = XMLoadFloat2( &nvec ); + XMVECTOR X = XMVector2Reflect( i, n ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat2( &ivec ); + XMVECTOR n = XMLoadFloat2( &nvec ); + XMVECTOR X = XMVector2Refract( i, n, refractionIndex ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Refract( const Vector2& ivec, const Vector2& nvec, float refractionIndex ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat2( &ivec ); + XMVECTOR n = XMLoadFloat2( &nvec ); + XMVECTOR X = XMVector2Refract( i, n, refractionIndex ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Transform( const Vector2& v, const Quaternion& quat, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Transform( const Vector2& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +inline void Vector2::Transform( const Vector2& v, const Matrix& m, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2TransformCoord( v1, M ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::Transform( const Vector2& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2TransformCoord( v1, M ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector2::Transform( const Vector2* varray, size_t count, const Matrix& m, Vector2* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector2TransformCoordStream( resultArray, sizeof(XMFLOAT2), varray, sizeof(XMFLOAT2), count, M ); +} + +inline void Vector2::Transform( const Vector2& v, const Matrix& m, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2Transform( v1, M ); + XMStoreFloat4( &result, X ); +} + +_Use_decl_annotations_ +inline void Vector2::Transform( const Vector2* varray, size_t count, const Matrix& m, Vector4* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector2TransformStream( resultArray, sizeof(XMFLOAT4), varray, sizeof(XMFLOAT2), count, M ); +} + +inline void Vector2::TransformNormal( const Vector2& v, const Matrix& m, Vector2& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2TransformNormal( v1, M ); + XMStoreFloat2( &result, X ); +} + +inline Vector2 Vector2::TransformNormal( const Vector2& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector2TransformNormal( v1, M ); + + Vector2 result; + XMStoreFloat2( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector2::TransformNormal( const Vector2* varray, size_t count, const Matrix& m, Vector2* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector2TransformNormalStream( resultArray, sizeof(XMFLOAT2), varray, sizeof(XMFLOAT2), count, M ); +} + + +/**************************************************************************** + * + * Vector3 + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Vector3::operator == ( const Vector3& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + return XMVector3Equal( v1, v2 ); +} + +inline bool Vector3::operator != ( const Vector3& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + return XMVector3NotEqual( v1, v2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Vector3& Vector3::operator+= (const Vector3& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorAdd(v1,v2); + XMStoreFloat3( this, X ); + return *this; +} + +inline Vector3& Vector3::operator-= (const Vector3& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorSubtract(v1,v2); + XMStoreFloat3( this, X ); + return *this; +} + +inline Vector3& Vector3::operator*= (const Vector3& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorMultiply(v1,v2); + XMStoreFloat3( this, X ); + return *this; +} + +inline Vector3& Vector3::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVectorScale(v1,S); + XMStoreFloat3( this, X ); + return *this; +} + +inline Vector3& Vector3::operator/= (float S) +{ + using namespace DirectX; + assert( S != 0.0f ); + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVectorScale(v1, 1.f/S); + XMStoreFloat3( this, X ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Vector3 Vector3::operator- () const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVectorNegate( v1 ); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Vector3 operator+ (const Vector3& V1, const Vector3& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V1 ); + XMVECTOR v2 = XMLoadFloat3( &V2 ); + XMVECTOR X = XMVectorAdd(v1,v2); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator- (const Vector3& V1, const Vector3& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V1 ); + XMVECTOR v2 = XMLoadFloat3( &V2 ); + XMVECTOR X = XMVectorSubtract(v1,v2); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator* (const Vector3& V1, const Vector3& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V1 ); + XMVECTOR v2 = XMLoadFloat3( &V2 ); + XMVECTOR X = XMVectorMultiply(v1,v2); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator* (const Vector3& V, float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator/ (const Vector3& V1, const Vector3& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V1 ); + XMVECTOR v2 = XMLoadFloat3( &V2 ); + XMVECTOR X = XMVectorDivide(v1,v2); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +inline Vector3 operator* (float S, const Vector3& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector3 R; + XMStoreFloat3( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Vector operations +//------------------------------------------------------------------------------ + +inline bool Vector3::InBounds( const Vector3& Bounds ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &Bounds ); + return XMVector3InBounds( v1, v2 ); +} + +inline float Vector3::Length() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVector3Length( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector3::LengthSquared() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVector3LengthSq( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector3::Dot( const Vector3& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR X = XMVector3Dot( v1, v2 ); + return XMVectorGetX( X ); +} + +inline void Vector3::Cross( const Vector3& V, Vector3& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR R = XMVector3Cross( v1, v2 ); + XMStoreFloat3( &result, R ); +} + +inline Vector3 Vector3::Cross( const Vector3& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &V ); + XMVECTOR R = XMVector3Cross( v1, v2 ); + + Vector3 result; + XMStoreFloat3( &result, R ); + return result; +} + +inline void Vector3::Normalize() +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVector3Normalize( v1 ); + XMStoreFloat3( this, X ); +} + +inline void Vector3::Normalize( Vector3& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR X = XMVector3Normalize( v1 ); + XMStoreFloat3( &result, X ); +} + +inline void Vector3::Clamp( const Vector3& vmin, const Vector3& vmax ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &vmin ); + XMVECTOR v3 = XMLoadFloat3( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat3( this, X ); +} + +inline void Vector3::Clamp( const Vector3& vmin, const Vector3& vmax, Vector3& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( this ); + XMVECTOR v2 = XMLoadFloat3( &vmin ); + XMVECTOR v3 = XMLoadFloat3( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat3( &result, X ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline float Vector3::Distance( const Vector3& v1, const Vector3& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector3Length( V ); + return XMVectorGetX( X ); +} + +inline float Vector3::DistanceSquared( const Vector3& v1, const Vector3& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector3LengthSq( V ); + return XMVectorGetX( X ); +} + +inline void Vector3::Min( const Vector3& v1, const Vector3& v2, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Min( const Vector3& v1, const Vector3& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Max( const Vector3& v1, const Vector3& v2, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Max( const Vector3& v1, const Vector3& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Lerp( const Vector3& v1, const Vector3& v2, float t, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Lerp( const Vector3& v1, const Vector3& v2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::SmoothStep( const Vector3& v1, const Vector3& v2, float t, Vector3& result ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::SmoothStep( const Vector3& v1, const Vector3& v2, float t ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR x3 = XMLoadFloat3( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Barycentric( const Vector3& v1, const Vector3& v2, const Vector3& v3, float f, float g ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR x3 = XMLoadFloat3( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR x3 = XMLoadFloat3( &v3 ); + XMVECTOR x4 = XMLoadFloat3( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::CatmullRom( const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &v2 ); + XMVECTOR x3 = XMLoadFloat3( &v3 ); + XMVECTOR x4 = XMLoadFloat3( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &t1 ); + XMVECTOR x3 = XMLoadFloat3( &v2 ); + XMVECTOR x4 = XMLoadFloat3( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Hermite( const Vector3& v1, const Vector3& t1, const Vector3& v2, const Vector3& t2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat3( &v1 ); + XMVECTOR x2 = XMLoadFloat3( &t1 ); + XMVECTOR x3 = XMLoadFloat3( &v2 ); + XMVECTOR x4 = XMLoadFloat3( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Reflect( const Vector3& ivec, const Vector3& nvec, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat3( &ivec ); + XMVECTOR n = XMLoadFloat3( &nvec ); + XMVECTOR X = XMVector3Reflect( i, n ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Reflect( const Vector3& ivec, const Vector3& nvec ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat3( &ivec ); + XMVECTOR n = XMLoadFloat3( &nvec ); + XMVECTOR X = XMVector3Reflect( i, n ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat3( &ivec ); + XMVECTOR n = XMLoadFloat3( &nvec ); + XMVECTOR X = XMVector3Refract( i, n, refractionIndex ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Refract( const Vector3& ivec, const Vector3& nvec, float refractionIndex ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat3( &ivec ); + XMVECTOR n = XMLoadFloat3( &nvec ); + XMVECTOR X = XMVector3Refract( i, n, refractionIndex ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Transform( const Vector3& v, const Quaternion& quat, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Transform( const Vector3& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +inline void Vector3::Transform( const Vector3& v, const Matrix& m, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3TransformCoord( v1, M ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::Transform( const Vector3& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3TransformCoord( v1, M ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector3::Transform( const Vector3* varray, size_t count, const Matrix& m, Vector3* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector3TransformCoordStream( resultArray, sizeof(XMFLOAT3), varray, sizeof(XMFLOAT3), count, M ); +} + +inline void Vector3::Transform( const Vector3& v, const Matrix& m, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3Transform( v1, M ); + XMStoreFloat4( &result, X ); +} + +_Use_decl_annotations_ +inline void Vector3::Transform( const Vector3* varray, size_t count, const Matrix& m, Vector4* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector3TransformStream( resultArray, sizeof(XMFLOAT4), varray, sizeof(XMFLOAT3), count, M ); +} + +inline void Vector3::TransformNormal( const Vector3& v, const Matrix& m, Vector3& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3TransformNormal( v1, M ); + XMStoreFloat3( &result, X ); +} + +inline Vector3 Vector3::TransformNormal( const Vector3& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector3TransformNormal( v1, M ); + + Vector3 result; + XMStoreFloat3( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector3::TransformNormal( const Vector3* varray, size_t count, const Matrix& m, Vector3* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector3TransformNormalStream( resultArray, sizeof(XMFLOAT3), varray, sizeof(XMFLOAT3), count, M ); +} + + +/**************************************************************************** + * + * Vector4 + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Vector4::operator == ( const Vector4& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + return XMVector4Equal( v1, v2 ); +} + +inline bool Vector4::operator != ( const Vector4& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + return XMVector4NotEqual( v1, v2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Vector4& Vector4::operator+= (const Vector4& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorAdd(v1,v2); + XMStoreFloat4( this, X ); + return *this; +} + +inline Vector4& Vector4::operator-= (const Vector4& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorSubtract(v1,v2); + XMStoreFloat4( this, X ); + return *this; +} + +inline Vector4& Vector4::operator*= (const Vector4& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorMultiply(v1,v2); + XMStoreFloat4( this, X ); + return *this; +} + +inline Vector4& Vector4::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVectorScale(v1,S); + XMStoreFloat4( this, X ); + return *this; +} + +inline Vector4& Vector4::operator/= (float S) +{ + using namespace DirectX; + assert( S != 0.0f ); + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVectorScale(v1, 1.f/S); + XMStoreFloat4( this, X ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Vector4 Vector4::operator- () const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVectorNegate( v1 ); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Vector4 operator+ (const Vector4& V1, const Vector4& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V1 ); + XMVECTOR v2 = XMLoadFloat4( &V2 ); + XMVECTOR X = XMVectorAdd(v1,v2); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator- (const Vector4& V1, const Vector4& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V1 ); + XMVECTOR v2 = XMLoadFloat4( &V2 ); + XMVECTOR X = XMVectorSubtract(v1,v2); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator* (const Vector4& V1, const Vector4& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V1 ); + XMVECTOR v2 = XMLoadFloat4( &V2 ); + XMVECTOR X = XMVectorMultiply(v1,v2); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator* (const Vector4& V, float S) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator/ (const Vector4& V1, const Vector4& V2) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V1 ); + XMVECTOR v2 = XMLoadFloat4( &V2 ); + XMVECTOR X = XMVectorDivide(v1,v2); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +inline Vector4 operator* (float S, const Vector4& V) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &V ); + XMVECTOR X = XMVectorScale(v1,S); + Vector4 R; + XMStoreFloat4( &R, X ); + return R; +} + +//------------------------------------------------------------------------------ +// Vector operations +//------------------------------------------------------------------------------ + +inline bool Vector4::InBounds( const Vector4& Bounds ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &Bounds ); + return XMVector4InBounds( v1, v2 ); +} + +inline float Vector4::Length() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVector4Length( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector4::LengthSquared() const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVector4LengthSq( v1 ); + return XMVectorGetX( X ); +} + +inline float Vector4::Dot( const Vector4& V ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &V ); + XMVECTOR X = XMVector4Dot( v1, v2 ); + return XMVectorGetX( X ); +} + +inline void Vector4::Cross( const Vector4& v1, const Vector4& v2, Vector4& result ) const +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( this ); + XMVECTOR x2 = XMLoadFloat4( &v1 ); + XMVECTOR x3 = XMLoadFloat4( &v2 ); + XMVECTOR R = XMVector4Cross( x1, x2, x3 ); + XMStoreFloat4( &result, R ); +} + +inline Vector4 Vector4::Cross( const Vector4& v1, const Vector4& v2 ) const +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( this ); + XMVECTOR x2 = XMLoadFloat4( &v1 ); + XMVECTOR x3 = XMLoadFloat4( &v2 ); + XMVECTOR R = XMVector4Cross( x1, x2, x3 ); + + Vector4 result; + XMStoreFloat4( &result, R ); + return result; +} + +inline void Vector4::Normalize() +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVector4Normalize( v1 ); + XMStoreFloat4( this, X ); +} + +inline void Vector4::Normalize( Vector4& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR X = XMVector4Normalize( v1 ); + XMStoreFloat4( &result, X ); +} + +inline void Vector4::Clamp( const Vector4& vmin, const Vector4& vmax ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &vmin ); + XMVECTOR v3 = XMLoadFloat4( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat4( this, X ); +} + +inline void Vector4::Clamp( const Vector4& vmin, const Vector4& vmax, Vector4& result ) const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( this ); + XMVECTOR v2 = XMLoadFloat4( &vmin ); + XMVECTOR v3 = XMLoadFloat4( &vmax ); + XMVECTOR X = XMVectorClamp( v1, v2, v3 ); + XMStoreFloat4( &result, X ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline float Vector4::Distance( const Vector4& v1, const Vector4& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector4Length( V ); + return XMVectorGetX( X ); +} + +inline float Vector4::DistanceSquared( const Vector4& v1, const Vector4& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR V = XMVectorSubtract( x2, x1 ); + XMVECTOR X = XMVector4LengthSq( V ); + return XMVectorGetX( X ); +} + +inline void Vector4::Min( const Vector4& v1, const Vector4& v2, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Min( const Vector4& v1, const Vector4& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorMin( x1, x2 ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Max( const Vector4& v1, const Vector4& v2, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Max( const Vector4& v1, const Vector4& v2 ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorMax( x1, x2 ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Lerp( const Vector4& v1, const Vector4& v2, float t, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Lerp( const Vector4& v1, const Vector4& v2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::SmoothStep( const Vector4& v1, const Vector4& v2, float t, Vector4& result ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::SmoothStep( const Vector4& v1, const Vector4& v2, float t ) +{ + using namespace DirectX; + t = (t > 1.0f) ? 1.0f : ((t < 0.0f) ? 0.0f : t); // Clamp value to 0 to 1 + t = t*t*(3.f - 2.f*t); + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR X = XMVectorLerp( x1, x2, t ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR x3 = XMLoadFloat4( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Barycentric( const Vector4& v1, const Vector4& v2, const Vector4& v3, float f, float g ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR x3 = XMLoadFloat4( &v3 ); + XMVECTOR X = XMVectorBaryCentric( x1, x2, x3, f, g ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR x3 = XMLoadFloat4( &v3 ); + XMVECTOR x4 = XMLoadFloat4( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::CatmullRom( const Vector4& v1, const Vector4& v2, const Vector4& v3, const Vector4& v4, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &v2 ); + XMVECTOR x3 = XMLoadFloat4( &v3 ); + XMVECTOR x4 = XMLoadFloat4( &v4 ); + XMVECTOR X = XMVectorCatmullRom( x1, x2, x3, x4, t ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &t1 ); + XMVECTOR x3 = XMLoadFloat4( &v2 ); + XMVECTOR x4 = XMLoadFloat4( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Hermite( const Vector4& v1, const Vector4& t1, const Vector4& v2, const Vector4& t2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( &v1 ); + XMVECTOR x2 = XMLoadFloat4( &t1 ); + XMVECTOR x3 = XMLoadFloat4( &v2 ); + XMVECTOR x4 = XMLoadFloat4( &t2 ); + XMVECTOR X = XMVectorHermite( x1, x2, x3, x4, t ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Reflect( const Vector4& ivec, const Vector4& nvec, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat4( &ivec ); + XMVECTOR n = XMLoadFloat4( &nvec ); + XMVECTOR X = XMVector4Reflect( i, n ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Reflect( const Vector4& ivec, const Vector4& nvec ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat4( &ivec ); + XMVECTOR n = XMLoadFloat4( &nvec ); + XMVECTOR X = XMVector4Reflect( i, n ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat4( &ivec ); + XMVECTOR n = XMLoadFloat4( &nvec ); + XMVECTOR X = XMVector4Refract( i, n, refractionIndex ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Refract( const Vector4& ivec, const Vector4& nvec, float refractionIndex ) +{ + using namespace DirectX; + XMVECTOR i = XMLoadFloat4( &ivec ); + XMVECTOR n = XMLoadFloat4( &nvec ); + XMVECTOR X = XMVector4Refract( i, n, refractionIndex ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Transform( const Vector2& v, const Quaternion& quat, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Transform( const Vector2& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat2( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Transform( const Vector3& v, const Quaternion& quat, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Transform( const Vector3& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat3( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( g_XMIdentityR3, X, g_XMSelect1110 ); // result.w = 1.f + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Transform( const Vector4& v, const Quaternion& quat, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( v1, X, g_XMSelect1110 ); // result.w = v.w + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Transform( const Vector4& v, const Quaternion& quat ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &v ); + XMVECTOR q = XMLoadFloat4( &quat ); + XMVECTOR X = XMVector3Rotate( v1, q ); + X = XMVectorSelect( v1, X, g_XMSelect1110 ); // result.w = v.w + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +inline void Vector4::Transform( const Vector4& v, const Matrix& m, Vector4& result ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector4Transform( v1, M ); + XMStoreFloat4( &result, X ); +} + +inline Vector4 Vector4::Transform( const Vector4& v, const Matrix& m ) +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( &v ); + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVECTOR X = XMVector4Transform( v1, M ); + + Vector4 result; + XMStoreFloat4( &result, X ); + return result; +} + +_Use_decl_annotations_ +inline void Vector4::Transform( const Vector4* varray, size_t count, const Matrix& m, Vector4* resultArray ) +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( &m ); + XMVector4TransformStream( resultArray, sizeof(XMFLOAT4), varray, sizeof(XMFLOAT4), count, M ); +} + + +/**************************************************************************** + * + * Matrix + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Matrix::operator == ( const Matrix& M ) const +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + return ( XMVector4Equal( x1, y1 ) + && XMVector4Equal( x2, y2 ) + && XMVector4Equal( x3, y3 ) + && XMVector4Equal( x4, y4 ) ) != 0; +} + +inline bool Matrix::operator != ( const Matrix& M ) const +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + return ( XMVector4NotEqual( x1, y1 ) + || XMVector4NotEqual( x2, y2 ) + || XMVector4NotEqual( x3, y3 ) + || XMVector4NotEqual( x4, y4 ) ) != 0; +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Matrix::Matrix(const XMFLOAT3X3& M) +{ + _11 = M._11; _12 = M._12; _13 = M._13; _14 = 0.f; + _21 = M._21; _22 = M._22; _23 = M._23; _24 = 0.f; + _31 = M._31; _32 = M._32; _33 = M._33; _34 = 0.f; + _41 = 0.f; _42 = 0.f; _43 = 0.f; _44 = 1.f; +} + +inline Matrix::Matrix(const XMFLOAT4X3& M) +{ + _11 = M._11; _12 = M._12; _13 = M._13; _14 = 0.f; + _21 = M._21; _22 = M._22; _23 = M._23; _24 = 0.f; + _31 = M._31; _32 = M._32; _33 = M._33; _34 = 0.f; + _41 = M._41; _42 = M._42; _43 = M._43; _44 = 1.f; +} + +inline Matrix& Matrix::operator= (const XMFLOAT3X3& M) +{ + _11 = M._11; _12 = M._12; _13 = M._13; _14 = 0.f; + _21 = M._21; _22 = M._22; _23 = M._23; _24 = 0.f; + _31 = M._31; _32 = M._32; _33 = M._33; _34 = 0.f; + _41 = 0.f; _42 = 0.f; _43 = 0.f; _44 = 1.f; + return *this; +} + +inline Matrix& Matrix::operator= (const XMFLOAT4X3& M) +{ + _11 = M._11; _12 = M._12; _13 = M._13; _14 = 0.f; + _21 = M._21; _22 = M._22; _23 = M._23; _24 = 0.f; + _31 = M._31; _32 = M._32; _33 = M._33; _34 = 0.f; + _41 = M._41; _42 = M._42; _43 = M._43; _44 = 1.f; + return *this; +} + +inline Matrix& Matrix::operator+= (const Matrix& M) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorAdd( x1, y1 ); + x2 = XMVectorAdd( x2, y2 ); + x3 = XMVectorAdd( x3, y3 ); + x4 = XMVectorAdd( x4, y4 ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +inline Matrix& Matrix::operator-= (const Matrix& M) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorSubtract( x1, y1 ); + x2 = XMVectorSubtract( x2, y2 ); + x3 = XMVectorSubtract( x3, y3 ); + x4 = XMVectorSubtract( x4, y4 ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +inline Matrix& Matrix::operator*= (const Matrix& M) +{ + using namespace DirectX; + XMMATRIX M1 = XMLoadFloat4x4( this ); + XMMATRIX M2 = XMLoadFloat4x4( &M ); + XMMATRIX X = XMMatrixMultiply( M1, M2 ); + XMStoreFloat4x4( this, X ); + return *this; +} + +inline Matrix& Matrix::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + x1 = XMVectorScale( x1, S ); + x2 = XMVectorScale( x2, S ); + x3 = XMVectorScale( x3, S ); + x4 = XMVectorScale( x4, S ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +inline Matrix& Matrix::operator/= (float S) +{ + using namespace DirectX; + assert( S != 0.f ); + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + float rs = 1.f / S; + + x1 = XMVectorScale( x1, rs ); + x2 = XMVectorScale( x2, rs ); + x3 = XMVectorScale( x3, rs ); + x4 = XMVectorScale( x4, rs ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +inline Matrix& Matrix::operator/= (const Matrix& M) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorDivide( x1, y1 ); + x2 = XMVectorDivide( x2, y2 ); + x3 = XMVectorDivide( x3, y3 ); + x4 = XMVectorDivide( x4, y4 ); + + XMStoreFloat4( reinterpret_cast(&_11), x1 ); + XMStoreFloat4( reinterpret_cast(&_21), x2 ); + XMStoreFloat4( reinterpret_cast(&_31), x3 ); + XMStoreFloat4( reinterpret_cast(&_41), x4 ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Matrix Matrix::operator- () const +{ + using namespace DirectX; + XMVECTOR v1 = XMLoadFloat4( reinterpret_cast(&_11) ); + XMVECTOR v2 = XMLoadFloat4( reinterpret_cast(&_21) ); + XMVECTOR v3 = XMLoadFloat4( reinterpret_cast(&_31) ); + XMVECTOR v4 = XMLoadFloat4( reinterpret_cast(&_41) ); + + v1 = XMVectorNegate( v1 ); + v2 = XMVectorNegate( v2 ); + v3 = XMVectorNegate( v3 ); + v4 = XMVectorNegate( v4 ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), v1 ); + XMStoreFloat4( reinterpret_cast(&R._21), v2 ); + XMStoreFloat4( reinterpret_cast(&R._31), v3 ); + XMStoreFloat4( reinterpret_cast(&R._41), v4 ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Matrix operator+ (const Matrix& M1, const Matrix& M2) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorAdd( x1, y1 ); + x2 = XMVectorAdd( x2, y2 ); + x3 = XMVectorAdd( x3, y3 ); + x4 = XMVectorAdd( x4, y4 ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator- (const Matrix& M1, const Matrix& M2) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorSubtract( x1, y1 ); + x2 = XMVectorSubtract( x2, y2 ); + x3 = XMVectorSubtract( x3, y3 ); + x4 = XMVectorSubtract( x4, y4 ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator* (const Matrix& M1, const Matrix& M2) +{ + using namespace DirectX; + XMMATRIX m1 = XMLoadFloat4x4( &M1 ); + XMMATRIX m2 = XMLoadFloat4x4( &M2 ); + XMMATRIX X = XMMatrixMultiply( m1, m2 ); + + Matrix R; + XMStoreFloat4x4( &R, X ); + return R; +} + +inline Matrix operator* (const Matrix& M, float S) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorScale( x1, S ); + x2 = XMVectorScale( x2, S ); + x3 = XMVectorScale( x3, S ); + x4 = XMVectorScale( x4, S ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator/ (const Matrix& M, float S) +{ + using namespace DirectX; + assert( S != 0.f ); + + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + float rs = 1.f / S; + + x1 = XMVectorScale( x1, rs ); + x2 = XMVectorScale( x2, rs ); + x3 = XMVectorScale( x3, rs ); + x4 = XMVectorScale( x4, rs ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator/ (const Matrix& M1, const Matrix& M2) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorDivide( x1, y1 ); + x2 = XMVectorDivide( x2, y2 ); + x3 = XMVectorDivide( x3, y3 ); + x4 = XMVectorDivide( x4, y4 ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +inline Matrix operator* (float S, const Matrix& M) +{ + using namespace DirectX; + + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M._41) ); + + x1 = XMVectorScale( x1, S ); + x2 = XMVectorScale( x2, S ); + x3 = XMVectorScale( x3, S ); + x4 = XMVectorScale( x4, S ); + + Matrix R; + XMStoreFloat4( reinterpret_cast(&R._11), x1 ); + XMStoreFloat4( reinterpret_cast(&R._21), x2 ); + XMStoreFloat4( reinterpret_cast(&R._31), x3 ); + XMStoreFloat4( reinterpret_cast(&R._41), x4 ); + return R; +} + +//------------------------------------------------------------------------------ +// Matrix operations +//------------------------------------------------------------------------------ + +inline bool Matrix::Decompose( Vector3& scale, Quaternion& rotation, Vector3& translation ) +{ + using namespace DirectX; + + XMVECTOR s, r, t; + + if ( !XMMatrixDecompose( &s, &r, &t, *this ) ) + return false; + + XMStoreFloat3( &scale, s ); + XMStoreFloat4( &rotation, r ); + XMStoreFloat3( &translation, t ); + + return true; +} + +inline Matrix Matrix::Transpose() const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + Matrix R; + XMStoreFloat4x4( &R, XMMatrixTranspose( M ) ); + return R; +} + +inline void Matrix::Transpose( Matrix& result ) const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + XMStoreFloat4x4( &result, XMMatrixTranspose( M ) ); +} + +inline Matrix Matrix::Invert() const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + Matrix R; + XMVECTOR det; + XMStoreFloat4x4( &R, XMMatrixInverse( &det, M ) ); + return R; +} + +inline void Matrix::Invert( Matrix& result ) const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + XMVECTOR det; + XMStoreFloat4x4( &result, XMMatrixInverse( &det, M ) ); +} + +inline float Matrix::Determinant() const +{ + using namespace DirectX; + XMMATRIX M = XMLoadFloat4x4( this ); + return XMVectorGetX( XMMatrixDeterminant( M ) ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +_Use_decl_annotations_ +inline Matrix Matrix::CreateBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& cameraUp, const Vector3* cameraForward ) +{ + using namespace DirectX; + XMVECTOR O = XMLoadFloat3( &object ); + XMVECTOR C = XMLoadFloat3( &cameraPosition ); + XMVECTOR Z = XMVectorSubtract( O, C ); + + XMVECTOR N = XMVector3LengthSq( Z ); + if ( XMVector3Less( N, g_XMEpsilon ) ) + { + if ( cameraForward ) + { + XMVECTOR F = XMLoadFloat3( cameraForward ); + Z = XMVectorNegate( F ); + } + else + Z = g_XMNegIdentityR2; + } + else + { + Z = XMVector3Normalize( Z ); + } + + XMVECTOR up = XMLoadFloat3( &cameraUp ); + XMVECTOR X = XMVector3Cross( up, Z ); + X = XMVector3Normalize( X ); + + XMVECTOR Y = XMVector3Cross( Z, X ); + + XMMATRIX M; + M.r[0] = X; + M.r[1] = Y; + M.r[2] = Z; + M.r[3] = XMVectorSetW( O, 1.f ); + + Matrix R; + XMStoreFloat4x4( &R, M ); + return R; +} + +_Use_decl_annotations_ +inline Matrix Matrix::CreateConstrainedBillboard( const Vector3& object, const Vector3& cameraPosition, const Vector3& rotateAxis, + const Vector3* cameraForward, const Vector3* objectForward ) +{ + using namespace DirectX; + + static const XMVECTORF32 s_minAngle = { 0.99825467075f, 0.99825467075f, 0.99825467075f, 0.99825467075f }; // 1.0 - XMConvertToRadians( 0.1f ); + + XMVECTOR O = XMLoadFloat3( &object ); + XMVECTOR C = XMLoadFloat3( &cameraPosition ); + XMVECTOR faceDir = XMVectorSubtract( O, C ); + + XMVECTOR N = XMVector3LengthSq( faceDir ); + if (XMVector3Less(N, g_XMEpsilon)) + { + if (cameraForward) + { + XMVECTOR F = XMLoadFloat3( cameraForward ); + faceDir = XMVectorNegate( F ); + } + else + faceDir = g_XMNegIdentityR2; + } + else + { + faceDir = XMVector3Normalize( faceDir ); + } + + XMVECTOR Y = XMLoadFloat3( &rotateAxis ); + XMVECTOR X, Z; + + XMVECTOR dot = XMVectorAbs( XMVector3Dot( Y, faceDir ) ); + if ( XMVector3Greater( dot, s_minAngle ) ) + { + if ( objectForward ) + { + Z = XMLoadFloat3( objectForward ); + dot = XMVectorAbs( XMVector3Dot( Y, Z ) ); + if ( XMVector3Greater( dot, s_minAngle ) ) + { + dot = XMVectorAbs( XMVector3Dot( Y, g_XMNegIdentityR2 ) ); + Z = ( XMVector3Greater( dot, s_minAngle ) ) ? g_XMIdentityR0 : g_XMNegIdentityR2; + } + } + else + { + dot = XMVectorAbs( XMVector3Dot( Y, g_XMNegIdentityR2 ) ); + Z = ( XMVector3Greater( dot, s_minAngle ) ) ? g_XMIdentityR0 : g_XMNegIdentityR2; + } + + X = XMVector3Cross( Y, Z ); + X = XMVector3Normalize( X ); + + Z = XMVector3Cross( X, Y ); + Z = XMVector3Normalize( Z ); + } + else + { + X = XMVector3Cross( Y, faceDir ); + X = XMVector3Normalize( X ); + + Z = XMVector3Cross( X, Y ); + Z = XMVector3Normalize( Z ); + } + + XMMATRIX M; + M.r[0] = X; + M.r[1] = Y; + M.r[2] = Z; + M.r[3] = XMVectorSetW( O, 1.f ); + + Matrix R; + XMStoreFloat4x4( &R, M ); + return R; +} + +inline Matrix Matrix::CreateTranslation( const Vector3& position ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixTranslation( position.x, position.y, position.z ) ); + return R; +} + +inline Matrix Matrix::CreateTranslation( float x, float y, float z ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixTranslation( x, y, z ) ); + return R; +} + +inline Matrix Matrix::CreateScale( const Vector3& scales ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixScaling( scales.x, scales.y, scales.z ) ); + return R; +} + +inline Matrix Matrix::CreateScale( float xs, float ys, float zs ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixScaling( xs, ys, zs ) ); + return R; +} + +inline Matrix Matrix::CreateScale( float scale ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixScaling( scale, scale, scale ) ); + return R; +} + +inline Matrix Matrix::CreateRotationX( float radians ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixRotationX( radians ) ); + return R; +} + +inline Matrix Matrix::CreateRotationY( float radians ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixRotationY( radians ) ); + return R; +} + +inline Matrix Matrix::CreateRotationZ( float radians ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixRotationZ( radians ) ); + return R; +} + +inline Matrix Matrix::CreateFromAxisAngle( const Vector3& axis, float angle ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR a = XMLoadFloat3( &axis ); + XMStoreFloat4x4( &R, XMMatrixRotationAxis( a, angle ) ); + return R; +} + +inline Matrix Matrix::CreatePerspectiveFieldOfView( float fov, float aspectRatio, float nearPlane, float farPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixPerspectiveFovRH( fov, aspectRatio, nearPlane, farPlane ) ); + return R; +} + +inline Matrix Matrix::CreatePerspective( float width, float height, float nearPlane, float farPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixPerspectiveRH( width, height, nearPlane, farPlane ) ); + return R; +} + +inline Matrix Matrix::CreatePerspectiveOffCenter( float left, float right, float bottom, float top, float nearPlane, float farPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixPerspectiveOffCenterRH( left, right, bottom, top, nearPlane, farPlane ) ); + return R; +} + +inline Matrix Matrix::CreateOrthographic( float width, float height, float zNearPlane, float zFarPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixOrthographicRH( width, height, zNearPlane, zFarPlane ) ); + return R; +} + +inline Matrix Matrix::CreateOrthographicOffCenter( float left, float right, float bottom, float top, float zNearPlane, float zFarPlane ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixOrthographicOffCenterRH( left, right, bottom, top, zNearPlane, zFarPlane ) ); + return R; +} + +inline Matrix Matrix::CreateLookAt( const Vector3& eye, const Vector3& target, const Vector3& up ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR eyev = XMLoadFloat3( &eye ); + XMVECTOR targetv = XMLoadFloat3( &target ); + XMVECTOR upv = XMLoadFloat3( &up ); + XMStoreFloat4x4( &R, XMMatrixLookAtRH( eyev, targetv, upv ) ); + return R; +} + +inline Matrix Matrix::CreateWorld( const Vector3& position, const Vector3& forward, const Vector3& up ) +{ + using namespace DirectX; + XMVECTOR zaxis = XMVector3Normalize( XMVectorNegate( XMLoadFloat3( &forward ) ) ); + XMVECTOR yaxis = XMLoadFloat3( &up ); + XMVECTOR xaxis = XMVector3Normalize( XMVector3Cross( yaxis, zaxis ) ); + yaxis = XMVector3Cross( zaxis, xaxis ); + + Matrix R; + XMStoreFloat3( reinterpret_cast( &R._11 ), xaxis ); + XMStoreFloat3( reinterpret_cast( &R._21 ), yaxis ); + XMStoreFloat3( reinterpret_cast( &R._31 ), zaxis ); + R._14 = R._24 = R._34 = 0.f; + R._41 = position.x; R._42 = position.y; R._43 = position.z; + R._44 = 1.f; + return R; +} + +inline Matrix Matrix::CreateFromQuaternion( const Quaternion& rotation ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR quatv = XMLoadFloat4( &rotation ); + XMStoreFloat4x4( &R, XMMatrixRotationQuaternion( quatv ) ); + return R; +} + +inline Matrix Matrix::CreateFromYawPitchRoll( float yaw, float pitch, float roll ) +{ + using namespace DirectX; + Matrix R; + XMStoreFloat4x4( &R, XMMatrixRotationRollPitchYaw( pitch, yaw, roll ) ); + return R; +} + +inline Matrix Matrix::CreateShadow( const Vector3& lightDir, const Plane& plane ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR light = XMLoadFloat3( &lightDir ); + XMVECTOR planev = XMLoadFloat4( &plane ); + XMStoreFloat4x4( &R, XMMatrixShadow( planev, light ) ); + return R; +} + +inline Matrix Matrix::CreateReflection( const Plane& plane ) +{ + using namespace DirectX; + Matrix R; + XMVECTOR planev = XMLoadFloat4( &plane ); + XMStoreFloat4x4( &R, XMMatrixReflect( planev ) ); + return R; +} + +inline void Matrix::Lerp( const Matrix& M1, const Matrix& M2, float t, Matrix& result ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorLerp( x1, y1, t ); + x2 = XMVectorLerp( x2, y2, t ); + x3 = XMVectorLerp( x3, y3, t ); + x4 = XMVectorLerp( x4, y4, t ); + + XMStoreFloat4( reinterpret_cast(&result._11), x1 ); + XMStoreFloat4( reinterpret_cast(&result._21), x2 ); + XMStoreFloat4( reinterpret_cast(&result._31), x3 ); + XMStoreFloat4( reinterpret_cast(&result._41), x4 ); +} + +inline Matrix Matrix::Lerp( const Matrix& M1, const Matrix& M2, float t ) +{ + using namespace DirectX; + XMVECTOR x1 = XMLoadFloat4( reinterpret_cast(&M1._11) ); + XMVECTOR x2 = XMLoadFloat4( reinterpret_cast(&M1._21) ); + XMVECTOR x3 = XMLoadFloat4( reinterpret_cast(&M1._31) ); + XMVECTOR x4 = XMLoadFloat4( reinterpret_cast(&M1._41) ); + + XMVECTOR y1 = XMLoadFloat4( reinterpret_cast(&M2._11) ); + XMVECTOR y2 = XMLoadFloat4( reinterpret_cast(&M2._21) ); + XMVECTOR y3 = XMLoadFloat4( reinterpret_cast(&M2._31) ); + XMVECTOR y4 = XMLoadFloat4( reinterpret_cast(&M2._41) ); + + x1 = XMVectorLerp( x1, y1, t ); + x2 = XMVectorLerp( x2, y2, t ); + x3 = XMVectorLerp( x3, y3, t ); + x4 = XMVectorLerp( x4, y4, t ); + + Matrix result; + XMStoreFloat4( reinterpret_cast(&result._11), x1 ); + XMStoreFloat4( reinterpret_cast(&result._21), x2 ); + XMStoreFloat4( reinterpret_cast(&result._31), x3 ); + XMStoreFloat4( reinterpret_cast(&result._41), x4 ); + return result; +} + +inline void Matrix::Transform( const Matrix& M, const Quaternion& rotation, Matrix& result ) +{ + using namespace DirectX; + XMVECTOR quatv = XMLoadFloat4( &rotation ); + + XMMATRIX M0 = XMLoadFloat4x4( &M ); + XMMATRIX M1 = XMMatrixRotationQuaternion( quatv ); + + XMStoreFloat4x4( &result, XMMatrixMultiply( M0, M1 ) ); +} + +inline Matrix Matrix::Transform( const Matrix& M, const Quaternion& rotation ) +{ + using namespace DirectX; + XMVECTOR quatv = XMLoadFloat4( &rotation ); + + XMMATRIX M0 = XMLoadFloat4x4( &M ); + XMMATRIX M1 = XMMatrixRotationQuaternion( quatv ); + + Matrix result; + XMStoreFloat4x4( &result, XMMatrixMultiply( M0, M1 ) ); + return result; +} + + +/**************************************************************************** + * + * Plane + * + ****************************************************************************/ + +inline Plane::Plane(const Vector3& point1, const Vector3& point2, const Vector3& point3 ) +{ + using namespace DirectX; + XMVECTOR P0 = XMLoadFloat3( &point1 ); + XMVECTOR P1 = XMLoadFloat3( &point2 ); + XMVECTOR P2 = XMLoadFloat3( &point3 ); + XMStoreFloat4( this, XMPlaneFromPoints( P0, P1, P2 ) ); +} + +inline Plane::Plane(const Vector3& point, const Vector3& normal) +{ + using namespace DirectX; + XMVECTOR P = XMLoadFloat3( &point ); + XMVECTOR N = XMLoadFloat3( &normal ); + XMStoreFloat4( this, XMPlaneFromPointNormal( P, N ) ); +} + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Plane::operator == ( const Plane& p ) const +{ + using namespace DirectX; + XMVECTOR p1 = XMLoadFloat4( this ); + XMVECTOR p2 = XMLoadFloat4( &p ); + return XMPlaneEqual( p1, p2 ); +} + +inline bool Plane::operator != ( const Plane& p ) const +{ + using namespace DirectX; + XMVECTOR p1 = XMLoadFloat4( this ); + XMVECTOR p2 = XMLoadFloat4( &p ); + return XMPlaneNotEqual( p1, p2 ); +} + +//------------------------------------------------------------------------------ +// Plane operations +//------------------------------------------------------------------------------ + +inline void Plane::Normalize() +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMStoreFloat4( this, XMPlaneNormalize( p ) ); +} + +inline void Plane::Normalize( Plane& result ) const +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMPlaneNormalize( p ) ); +} + +inline float Plane::Dot( const Vector4& v ) const +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMVECTOR v0 = XMLoadFloat4( &v ); + return XMVectorGetX( XMPlaneDot( p, v0 ) ); +} + +inline float Plane::DotCoordinate( const Vector3& position ) const +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMVECTOR v0 = XMLoadFloat3( &position ); + return XMVectorGetX( XMPlaneDotCoord( p, v0 ) ); +} + +inline float Plane::DotNormal( const Vector3& normal ) const +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( this ); + XMVECTOR n0 = XMLoadFloat3( &normal ); + return XMVectorGetX( XMPlaneDotNormal( p, n0 ) ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline void Plane::Transform( const Plane& plane, const Matrix& M, Plane& result ) +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( &plane ); + XMMATRIX m0 = XMLoadFloat4x4( &M ); + XMStoreFloat4( &result, XMPlaneTransform( p, m0 ) ); +} + +inline Plane Plane::Transform( const Plane& plane, const Matrix& M ) +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( &plane ); + XMMATRIX m0 = XMLoadFloat4x4( &M ); + + Plane result; + XMStoreFloat4( &result, XMPlaneTransform( p, m0 ) ); + return result; +} + +inline void Plane::Transform( const Plane& plane, const Quaternion& rotation, Plane& result ) +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( &plane ); + XMVECTOR q = XMLoadFloat4( &rotation ); + XMVECTOR X = XMVector3Rotate( p, q ); + X = XMVectorSelect( p, X, g_XMSelect1110 ); // result.d = plane.d + XMStoreFloat4( &result, X ); +} + +inline Plane Plane::Transform( const Plane& plane, const Quaternion& rotation ) +{ + using namespace DirectX; + XMVECTOR p = XMLoadFloat4( &plane ); + XMVECTOR q = XMLoadFloat4( &rotation ); + XMVECTOR X = XMVector3Rotate( p, q ); + X = XMVectorSelect( p, X, g_XMSelect1110 ); // result.d = plane.d + + Plane result; + XMStoreFloat4( &result, X ); + return result; +} + + +/**************************************************************************** + * + * Quaternion + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Quaternion::operator == ( const Quaternion& q ) const +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + return XMQuaternionEqual( q1, q2 ); +} + +inline bool Quaternion::operator != ( const Quaternion& q ) const +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + return XMQuaternionNotEqual( q1, q2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Quaternion& Quaternion::operator+= (const Quaternion& q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + XMStoreFloat4( this, XMVectorAdd( q1, q2 ) ); + return *this; +} + +inline Quaternion& Quaternion::operator-= (const Quaternion& q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + XMStoreFloat4( this, XMVectorSubtract( q1, q2 ) ); + return *this; +} + +inline Quaternion& Quaternion::operator*= (const Quaternion& q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + XMStoreFloat4( this, XMQuaternionMultiply( q1, q2 ) ); + return *this; +} + +inline Quaternion& Quaternion::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( this, XMVectorScale( q, S ) ); + return *this; +} + +inline Quaternion& Quaternion::operator/= (const Quaternion& q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + q2 = XMQuaternionInverse( q2 ); + XMStoreFloat4( this, XMQuaternionMultiply( q1, q2 ) ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Quaternion Quaternion::operator- () const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorNegate( q ) ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Quaternion operator+ (const Quaternion& Q1, const Quaternion& Q2) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q1 ); + XMVECTOR q2 = XMLoadFloat4( &Q2 ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorAdd( q1, q2 ) ); + return R; +} + +inline Quaternion operator- (const Quaternion& Q1, const Quaternion& Q2) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q1 ); + XMVECTOR q2 = XMLoadFloat4( &Q2 ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorSubtract( q1, q2 ) ); + return R; +} + +inline Quaternion operator* (const Quaternion& Q1, const Quaternion& Q2) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q1 ); + XMVECTOR q2 = XMLoadFloat4( &Q2 ); + + Quaternion R; + XMStoreFloat4( &R, XMQuaternionMultiply( q1, q2 ) ); + return R; +} + +inline Quaternion operator* (const Quaternion& Q, float S) +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( &Q ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorScale( q, S ) ); + return R; +} + +inline Quaternion operator/ (const Quaternion& Q1, const Quaternion& Q2) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q1 ); + XMVECTOR q2 = XMLoadFloat4( &Q2 ); + q2 = XMQuaternionInverse( q2 ); + + Quaternion R; + XMStoreFloat4( &R, XMQuaternionMultiply( q1, q2 ) ); + return R; +} + +inline Quaternion operator* (float S, const Quaternion& Q) +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( &Q ); + + Quaternion R; + XMStoreFloat4( &R, XMVectorScale( q1, S ) ); + return R; +} + +//------------------------------------------------------------------------------ +// Quaternion operations +//------------------------------------------------------------------------------ + +inline float Quaternion::Length() const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + return XMVectorGetX( XMQuaternionLength( q ) ); +} + +inline float Quaternion::LengthSquared() const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + return XMVectorGetX( XMQuaternionLengthSq( q ) ); +} + +inline void Quaternion::Normalize() +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( this, XMQuaternionNormalize( q ) ); +} + +inline void Quaternion::Normalize( Quaternion& result ) const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMQuaternionNormalize( q ) ); +} + +inline void Quaternion::Conjugate() +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( this, XMQuaternionConjugate( q ) ); +} + +inline void Quaternion::Conjugate( Quaternion& result ) const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMQuaternionConjugate( q ) ); +} + +inline void Quaternion::Inverse( Quaternion& result ) const +{ + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMQuaternionInverse( q ) ); +} + +inline float Quaternion::Dot( const Quaternion& q ) const +{ + using namespace DirectX; + XMVECTOR q1 = XMLoadFloat4( this ); + XMVECTOR q2 = XMLoadFloat4( &q ); + return XMVectorGetX( XMQuaternionDot( q1, q2 ) ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline Quaternion Quaternion::CreateFromAxisAngle( const Vector3& axis, float angle ) +{ + using namespace DirectX; + XMVECTOR a = XMLoadFloat3( &axis ); + + Quaternion R; + XMStoreFloat4( &R, XMQuaternionRotationAxis( a, angle ) ); + return R; +} + +inline Quaternion Quaternion::CreateFromYawPitchRoll( float yaw, float pitch, float roll ) +{ + using namespace DirectX; + Quaternion R; + XMStoreFloat4( &R, XMQuaternionRotationRollPitchYaw( pitch, yaw, roll ) ); + return R; +} + +inline Quaternion Quaternion::CreateFromRotationMatrix( const Matrix& M ) +{ + using namespace DirectX; + XMMATRIX M0 = XMLoadFloat4x4( &M ); + + Quaternion R; + XMStoreFloat4( &R, XMQuaternionRotationMatrix( M0 ) ); + return R; +} + +inline void Quaternion::Lerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + + XMVECTOR dot = XMVector4Dot( Q0, Q1 ); + + XMVECTOR R; + if ( XMVector4GreaterOrEqual( dot, XMVectorZero() ) ) + { + R = XMVectorLerp( Q0, Q1, t ); + } + else + { + XMVECTOR tv = XMVectorReplicate( t ); + XMVECTOR t1v = XMVectorReplicate( 1.f - t ); + XMVECTOR X0 = XMVectorMultiply( Q0, t1v ); + XMVECTOR X1 = XMVectorMultiply( Q1, tv ); + R = XMVectorSubtract( X0, X1 ); + } + + XMStoreFloat4( &result, XMQuaternionNormalize( R ) ); +} + +inline Quaternion Quaternion::Lerp( const Quaternion& q1, const Quaternion& q2, float t ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + + XMVECTOR dot = XMVector4Dot( Q0, Q1 ); + + XMVECTOR R; + if ( XMVector4GreaterOrEqual( dot, XMVectorZero() ) ) + { + R = XMVectorLerp( Q0, Q1, t ); + } + else + { + XMVECTOR tv = XMVectorReplicate( t ); + XMVECTOR t1v = XMVectorReplicate( 1.f - t ); + XMVECTOR X0 = XMVectorMultiply( Q0, t1v ); + XMVECTOR X1 = XMVectorMultiply( Q1, tv ); + R = XMVectorSubtract( X0, X1 ); + } + + Quaternion result; + XMStoreFloat4( &result, XMQuaternionNormalize( R ) ); + return result; +} + +inline void Quaternion::Slerp( const Quaternion& q1, const Quaternion& q2, float t, Quaternion& result ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + XMStoreFloat4( &result, XMQuaternionSlerp( Q0, Q1, t ) ); +} + +inline Quaternion Quaternion::Slerp( const Quaternion& q1, const Quaternion& q2, float t ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + + Quaternion result; + XMStoreFloat4( &result, XMQuaternionSlerp( Q0, Q1, t ) ); + return result; +} + +inline void Quaternion::Concatenate( const Quaternion& q1, const Quaternion& q2, Quaternion& result ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + XMStoreFloat4( &result, XMQuaternionMultiply( Q1, Q0 ) ); +} + +inline Quaternion Quaternion::Concatenate( const Quaternion& q1, const Quaternion& q2 ) +{ + using namespace DirectX; + XMVECTOR Q0 = XMLoadFloat4( &q1 ); + XMVECTOR Q1 = XMLoadFloat4( &q2 ); + + Quaternion result; + XMStoreFloat4( &result, XMQuaternionMultiply( Q1, Q0 ) ); + return result; +} + + +/**************************************************************************** + * + * Color + * + ****************************************************************************/ + +inline Color::Color( const DirectX::PackedVector::XMCOLOR& Packed ) +{ + using namespace DirectX; + XMStoreFloat4( this, PackedVector::XMLoadColor( &Packed ) ); +} + +inline Color::Color( const DirectX::PackedVector::XMUBYTEN4& Packed ) +{ + using namespace DirectX; + XMStoreFloat4( this, PackedVector::XMLoadUByteN4( &Packed ) ); +} + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ +inline bool Color::operator == ( const Color& c ) const +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + return XMColorEqual( c1, c2 ); +} + +inline bool Color::operator != ( const Color& c ) const +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + return XMColorNotEqual( c1, c2 ); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Color& Color::operator= (const DirectX::PackedVector::XMCOLOR& Packed) +{ + using namespace DirectX; + XMStoreFloat4( this, PackedVector::XMLoadColor( &Packed ) ); + return *this; +} + +inline Color& Color::operator= (const DirectX::PackedVector::XMUBYTEN4& Packed) +{ + using namespace DirectX; + XMStoreFloat4( this, PackedVector::XMLoadUByteN4( &Packed ) ); + return *this; +} + +inline Color& Color::operator+= (const Color& c) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + XMStoreFloat4( this, XMVectorAdd( c1, c2 ) ); + return *this; +} + +inline Color& Color::operator-= (const Color& c) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + XMStoreFloat4( this, XMVectorSubtract( c1, c2 ) ); + return *this; +} + +inline Color& Color::operator*= (const Color& c) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + XMStoreFloat4( this, XMVectorMultiply( c1, c2 ) ); + return *this; +} + +inline Color& Color::operator*= (float S) +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMVectorScale( c, S ) ); + return *this; +} + +inline Color& Color::operator/= (const Color& c) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( this ); + XMVECTOR c2 = XMLoadFloat4( &c ); + XMStoreFloat4( this, XMVectorDivide( c1, c2 ) ); + return *this; +} + +//------------------------------------------------------------------------------ +// Urnary operators +//------------------------------------------------------------------------------ + +inline Color Color::operator- () const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + Color R; + XMStoreFloat4( &R, XMVectorNegate( c ) ); + return R; +} + +//------------------------------------------------------------------------------ +// Binary operators +//------------------------------------------------------------------------------ + +inline Color operator+ (const Color& C1, const Color& C2) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C1 ); + XMVECTOR c2 = XMLoadFloat4( &C2 ); + Color R; + XMStoreFloat4( &R, XMVectorAdd( c1, c2 ) ); + return R; +} + +inline Color operator- (const Color& C1, const Color& C2) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C1 ); + XMVECTOR c2 = XMLoadFloat4( &C2 ); + Color R; + XMStoreFloat4( &R, XMVectorSubtract( c1, c2 ) ); + return R; +} + +inline Color operator* (const Color& C1, const Color& C2) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C1 ); + XMVECTOR c2 = XMLoadFloat4( &C2 ); + Color R; + XMStoreFloat4( &R, XMVectorMultiply( c1, c2 ) ); + return R; +} + +inline Color operator* (const Color& C, float S) +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( &C ); + Color R; + XMStoreFloat4( &R, XMVectorScale( c, S ) ); + return R; +} + +inline Color operator/ (const Color& C1, const Color& C2) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C1 ); + XMVECTOR c2 = XMLoadFloat4( &C2 ); + Color R; + XMStoreFloat4( &R, XMVectorDivide( c1, c2 ) ); + return R; +} + +inline Color operator* (float S, const Color& C) +{ + using namespace DirectX; + XMVECTOR c1 = XMLoadFloat4( &C ); + Color R; + XMStoreFloat4( &R, XMVectorScale( c1, S ) ); + return R; +} + +//------------------------------------------------------------------------------ +// Color operations +//------------------------------------------------------------------------------ + +inline DirectX::PackedVector::XMCOLOR Color::BGRA() const +{ + using namespace DirectX; + XMVECTOR clr = XMLoadFloat4( this ); + PackedVector::XMCOLOR Packed; + PackedVector::XMStoreColor( &Packed, clr ); + return Packed; +} + +inline DirectX::PackedVector::XMUBYTEN4 Color::RGBA() const +{ + using namespace DirectX; + XMVECTOR clr = XMLoadFloat4( this ); + PackedVector::XMUBYTEN4 Packed; + PackedVector::XMStoreUByteN4( &Packed, clr ); + return Packed; +} + +inline Vector3 Color::ToVector3() const +{ + return Vector3( x, y, z ); +} + +inline Vector4 Color::ToVector4() const +{ + return Vector4( x, y, z, w ); +} + +inline void Color::Negate() +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMColorNegative( c) ); +} + +inline void Color::Negate( Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMColorNegative( c ) ); +} + +inline void Color::Saturate() +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMVectorSaturate( c ) ); +} + +inline void Color::Saturate( Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMVectorSaturate( c ) ); +} + +inline void Color::Premultiply() +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMVECTOR a = XMVectorSplatW( c ); + a = XMVectorSelect( g_XMIdentityR3, a, g_XMSelect1110 ); + XMStoreFloat4( this, XMVectorMultiply( c, a ) ); +} + +inline void Color::Premultiply( Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMVECTOR a = XMVectorSplatW( c ); + a = XMVectorSelect( g_XMIdentityR3, a, g_XMSelect1110 ); + XMStoreFloat4( &result, XMVectorMultiply( c, a ) ); +} + +inline void Color::AdjustSaturation( float sat ) +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMColorAdjustSaturation( c, sat ) ); +} + +inline void Color::AdjustSaturation( float sat, Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMColorAdjustSaturation( c, sat ) ); +} + +inline void Color::AdjustContrast( float contrast ) +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( this, XMColorAdjustContrast( c, contrast ) ); +} + +inline void Color::AdjustContrast( float contrast, Color& result ) const +{ + using namespace DirectX; + XMVECTOR c = XMLoadFloat4( this ); + XMStoreFloat4( &result, XMColorAdjustContrast( c, contrast ) ); +} + +//------------------------------------------------------------------------------ +// Static functions +//------------------------------------------------------------------------------ + +inline void Color::Modulate( const Color& c1, const Color& c2, Color& result ) +{ + using namespace DirectX; + XMVECTOR C0 = XMLoadFloat4( &c1 ); + XMVECTOR C1 = XMLoadFloat4( &c2 ); + XMStoreFloat4( &result, XMColorModulate( C0, C1 ) ); +} + +inline Color Color::Modulate( const Color& c1, const Color& c2 ) +{ + using namespace DirectX; + XMVECTOR C0 = XMLoadFloat4( &c1 ); + XMVECTOR C1 = XMLoadFloat4( &c2 ); + + Color result; + XMStoreFloat4( &result, XMColorModulate( C0, C1 ) ); + return result; +} + +inline void Color::Lerp( const Color& c1, const Color& c2, float t, Color& result ) +{ + using namespace DirectX; + XMVECTOR C0 = XMLoadFloat4( &c1 ); + XMVECTOR C1 = XMLoadFloat4( &c2 ); + XMStoreFloat4( &result, XMVectorLerp( C0, C1, t ) ); +} + +inline Color Color::Lerp( const Color& c1, const Color& c2, float t ) +{ + using namespace DirectX; + XMVECTOR C0 = XMLoadFloat4( &c1 ); + XMVECTOR C1 = XMLoadFloat4( &c2 ); + + Color result; + XMStoreFloat4( &result, XMVectorLerp( C0, C1, t ) ); + return result; +} + + +/**************************************************************************** + * + * Ray + * + ****************************************************************************/ + +//----------------------------------------------------------------------------- +// Comparision operators +//------------------------------------------------------------------------------ +inline bool Ray::operator == ( const Ray& r ) const +{ + using namespace DirectX; + XMVECTOR r1p = XMLoadFloat3( &position ); + XMVECTOR r2p = XMLoadFloat3( &r.position ); + XMVECTOR r1d = XMLoadFloat3( &direction ); + XMVECTOR r2d = XMLoadFloat3( &r.direction ); + return XMVector3Equal( r1p, r2p ) && XMVector3Equal( r1d, r2d ); +} + +inline bool Ray::operator != ( const Ray& r ) const +{ + using namespace DirectX; + XMVECTOR r1p = XMLoadFloat3( &position ); + XMVECTOR r2p = XMLoadFloat3( &r.position ); + XMVECTOR r1d = XMLoadFloat3( &direction ); + XMVECTOR r2d = XMLoadFloat3( &r.direction ); + return XMVector3NotEqual( r1p, r2p ) && XMVector3NotEqual( r1d, r2d ); +} + +//----------------------------------------------------------------------------- +// Ray operators +//------------------------------------------------------------------------------ + +inline bool Ray::Intersects( const BoundingSphere& sphere, _Out_ float& Dist ) const +{ + return sphere.Intersects( position, direction, Dist ); +} + +inline bool Ray::Intersects( const BoundingBox& box, _Out_ float& Dist ) const +{ + return box.Intersects( position, direction, Dist ); +} + +inline bool Ray::Intersects( const Vector3& tri0, const Vector3& tri1, const Vector3& tri2, _Out_ float& Dist ) const +{ + return DirectX::TriangleTests::Intersects( position, direction, tri0, tri1, tri2, Dist ); +} + +inline bool Ray::Intersects( const Plane& plane, _Out_ float& Dist ) const +{ + using namespace DirectX; + + XMVECTOR p = XMLoadFloat4( &plane ); + XMVECTOR dir = XMLoadFloat3( &direction ); + + XMVECTOR nd = XMPlaneDotNormal( p, dir ); + + if ( XMVector3LessOrEqual( XMVectorAbs( nd ), g_RayEpsilon ) ) + { + Dist = 0.f; + return false; + } + else + { + // t = -(dot(n,origin) + D) / dot(n,dir) + XMVECTOR pos = XMLoadFloat3( &position ); + XMVECTOR v = XMPlaneDotNormal( p, pos ); + v = XMVectorAdd( v, XMVectorSplatW(p) ); + v = XMVectorDivide( v, nd ); + float dist = - XMVectorGetX( v ); + if (dist < 0) + { + Dist = 0.f; + return false; + } + else + { + Dist = dist; + return true; + } + } +} + + +/**************************************************************************** + * + * Viewport + * + ****************************************************************************/ + +//------------------------------------------------------------------------------ +// Comparision operators +//------------------------------------------------------------------------------ + +inline bool Viewport::operator == ( const Viewport& vp ) const +{ + return (x == vp.x && y == vp.y + && width == vp.width && height == vp.height + && minDepth == vp.minDepth && maxDepth == vp.maxDepth); +} + +inline bool Viewport::operator != ( const Viewport& vp ) const +{ + return (x != vp.x || y != vp.y + || width != vp.width || height != vp.height + || minDepth != vp.minDepth || maxDepth != vp.maxDepth); +} + +//------------------------------------------------------------------------------ +// Assignment operators +//------------------------------------------------------------------------------ + +inline Viewport& Viewport::operator= (const Viewport& vp) +{ + x = vp.x; y = vp.y; + width = vp.width; height = vp.height; + minDepth = vp.minDepth; maxDepth = vp.maxDepth; + return *this; +} + +inline Viewport& Viewport::operator= (const RECT& rct) +{ + x = float(rct.left); y = float(rct.top); + width = float(rct.right - rct.left); + height = float(rct.bottom - rct.top); + minDepth = 0.f; maxDepth = 1.f; + return *this; +} + +inline Viewport& Viewport::operator= (const D3D11_VIEWPORT& vp) +{ + x = vp.TopLeftX; y = vp.TopLeftY; + width = vp.Width; height = vp.Height; + minDepth = vp.MinDepth; maxDepth = vp.MaxDepth; + return *this; +} + +//------------------------------------------------------------------------------ +// Viewport operations +//------------------------------------------------------------------------------ + +inline float Viewport::AspectRatio() const +{ + if (width == 0.f || height == 0.f) + return 0.f; + + return (width / height); +} + +inline Vector3 Viewport::Project(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world) const +{ + using namespace DirectX; + XMVECTOR v = XMLoadFloat3(&p); + XMMATRIX projection = XMLoadFloat4x4(&proj); + v = XMVector3Project(v, x, y, width, height, minDepth, maxDepth, projection, view, world); + Vector3 result; + XMStoreFloat3(&result, v); + return result; +} + +inline void Viewport::Project(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world, Vector3& result) const +{ + using namespace DirectX; + XMVECTOR v = XMLoadFloat3(&p); + XMMATRIX projection = XMLoadFloat4x4(&proj); + v = XMVector3Project(v, x, y, width, height, minDepth, maxDepth, projection, view, world); + XMStoreFloat3(&result, v); +} + +inline Vector3 Viewport::Unproject(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world) const +{ + using namespace DirectX; + XMVECTOR v = XMLoadFloat3(&p); + XMMATRIX projection = XMLoadFloat4x4(&proj); + v = XMVector3Unproject(v, x, y, width, height, minDepth, maxDepth, projection, view, world); + Vector3 result; + XMStoreFloat3(&result, v); + return result; +} + +inline void Viewport::Unproject(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world, Vector3& result) const +{ + using namespace DirectX; + XMVECTOR v = XMLoadFloat3(&p); + XMMATRIX projection = XMLoadFloat4x4(&proj); + v = XMVector3Unproject(v, x, y, width, height, minDepth, maxDepth, projection, view, world); + XMStoreFloat3(&result, v); +} diff --git a/Kits/DirectXTK/Inc/SpriteBatch.h b/Kits/DirectXTK/Inc/SpriteBatch.h new file mode 100644 index 0000000000000000000000000000000000000000..c21dee09c89a0c2a1efb779a05cfa60f63469cfa --- /dev/null +++ b/Kits/DirectXTK/Inc/SpriteBatch.h @@ -0,0 +1,121 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include +#include +#include +#include + +// VS 2010 doesn't support explicit calling convention for std::function +#ifndef DIRECTX_STD_CALLCONV +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define DIRECTX_STD_CALLCONV +#else +#define DIRECTX_STD_CALLCONV __cdecl +#endif +#endif + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + enum SpriteSortMode + { + SpriteSortMode_Deferred, + SpriteSortMode_Immediate, + SpriteSortMode_Texture, + SpriteSortMode_BackToFront, + SpriteSortMode_FrontToBack, + }; + + + enum SpriteEffects + { + SpriteEffects_None = 0, + SpriteEffects_FlipHorizontally = 1, + SpriteEffects_FlipVertically = 2, + SpriteEffects_FlipBoth = SpriteEffects_FlipHorizontally | SpriteEffects_FlipVertically, + }; + + + class SpriteBatch + { + public: + explicit SpriteBatch(_In_ ID3D11DeviceContext* deviceContext); + SpriteBatch(SpriteBatch&& moveFrom); + SpriteBatch& operator= (SpriteBatch&& moveFrom); + virtual ~SpriteBatch(); + + // Begin/End a batch of sprite drawing operations. + void XM_CALLCONV Begin(SpriteSortMode sortMode = SpriteSortMode_Deferred, _In_opt_ ID3D11BlendState* blendState = nullptr, _In_opt_ ID3D11SamplerState* samplerState = nullptr, _In_opt_ ID3D11DepthStencilState* depthStencilState = nullptr, _In_opt_ ID3D11RasterizerState* rasterizerState = nullptr, + _In_opt_ std::function setCustomShaders = nullptr, FXMMATRIX transformMatrix = MatrixIdentity); + void __cdecl End(); + + // Draw overloads specifying position, origin and scale as XMFLOAT2. + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, FXMVECTOR color = Colors::White); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, XMFLOAT2 const& scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + + // Draw overloads specifying position, origin and scale via the first two components of an XMVECTOR. + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, FXMVECTOR color = Colors::White); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, FXMVECTOR origin = g_XMZero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, FXMVECTOR origin, GXMVECTOR scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0); + + // Draw overloads specifying position as a RECT. + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, FXMVECTOR color = Colors::White); + 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 ); + DXGI_MODE_ROTATION __cdecl GetRotation() const; + + // Set viewport for sprite transformation + void __cdecl SetViewport( const D3D11_VIEWPORT& viewPort ); + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + static const XMMATRIX MatrixIdentity; + static const XMFLOAT2 Float2Zero; + + // Prevent copying. + SpriteBatch(SpriteBatch const&) DIRECTX_CTOR_DELETE + SpriteBatch& operator= (SpriteBatch const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Inc/SpriteFont.h b/Kits/DirectXTK/Inc/SpriteFont.h new file mode 100644 index 0000000000000000000000000000000000000000..397bd7d9bb81700e76cd0e93bddd5d5487c6f960 --- /dev/null +++ b/Kits/DirectXTK/Inc/SpriteFont.h @@ -0,0 +1,89 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "SpriteBatch.h" + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + + +namespace DirectX +{ + class SpriteFont + { + public: + struct Glyph; + + SpriteFont(_In_ ID3D11Device* device, _In_z_ wchar_t const* fileName); + SpriteFont(_In_ ID3D11Device* device, _In_reads_bytes_(dataSize) uint8_t const* dataBlob, _In_ size_t dataSize); + SpriteFont(_In_ ID3D11ShaderResourceView* texture, _In_reads_(glyphCount) Glyph const* glyphs, _In_ size_t glyphCount, _In_ float lineSpacing); + + SpriteFont(SpriteFont&& moveFrom); + SpriteFont& operator= (SpriteFont&& moveFrom); + virtual ~SpriteFont(); + + void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, XMFLOAT2 const& position, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0) const; + void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, XMFLOAT2 const& position, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, XMFLOAT2 const& scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0) const; + void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, FXMVECTOR position, FXMVECTOR color = Colors::White, float rotation = 0, FXMVECTOR origin = g_XMZero, float scale = 1, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0) const; + void XM_CALLCONV DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, FXMVECTOR position, FXMVECTOR color, float rotation, FXMVECTOR origin, GXMVECTOR scale, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0) const; + + XMVECTOR XM_CALLCONV MeasureString(_In_z_ wchar_t const* text) const; + + // Spacing properties + float __cdecl GetLineSpacing() const; + void __cdecl SetLineSpacing(float spacing); + + // Font properties + wchar_t __cdecl GetDefaultCharacter() const; + void __cdecl SetDefaultCharacter(wchar_t character); + + bool __cdecl ContainsCharacter(wchar_t character) const; + + // Custom layout/rendering + Glyph const* __cdecl FindGlyph(wchar_t character) const; + void GetSpriteSheet( ID3D11ShaderResourceView** texture ) const; + + // Describes a single character glyph. + struct Glyph + { + uint32_t Character; + RECT Subrect; + float XOffset; + float YOffset; + float XAdvance; + }; + + + private: + // Private implementation. + class Impl; + + std::unique_ptr pImpl; + + static const XMFLOAT2 Float2Zero; + + // Prevent copying. + SpriteFont(SpriteFont const&) DIRECTX_CTOR_DELETE + SpriteFont& operator= (SpriteFont const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Inc/VertexTypes.h b/Kits/DirectXTK/Inc/VertexTypes.h new file mode 100644 index 0000000000000000000000000000000000000000..4204d0bcc7e15476827ec338fca739614e002043 --- /dev/null +++ b/Kits/DirectXTK/Inc/VertexTypes.h @@ -0,0 +1,333 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#include + + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif + + // Vertex struct holding position and color information. + struct VertexPositionColor + { + VertexPositionColor() DIRECTX_CTOR_DEFAULT + + VertexPositionColor(XMFLOAT3 const& position, XMFLOAT4 const& color) + : position(position), + color(color) + { } + + VertexPositionColor(FXMVECTOR position, FXMVECTOR color) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat4(&this->color, color); + } + + XMFLOAT3 position; + XMFLOAT4 color; + + static const int InputElementCount = 2; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position and texture mapping information. + struct VertexPositionTexture + { + VertexPositionTexture() DIRECTX_CTOR_DEFAULT + + VertexPositionTexture(XMFLOAT3 const& position, XMFLOAT2 const& textureCoordinate) + : position(position), + textureCoordinate(textureCoordinate) + { } + + VertexPositionTexture(FXMVECTOR position, FXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 2; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position and normal vector. + struct VertexPositionNormal + { + VertexPositionNormal() DIRECTX_CTOR_DEFAULT + + VertexPositionNormal(XMFLOAT3 const& position, XMFLOAT3 const& normal) + : position(position), + normal(normal) + { } + + VertexPositionNormal(FXMVECTOR position, FXMVECTOR normal) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + + static const int InputElementCount = 2; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, color, and texture mapping information. + struct VertexPositionColorTexture + { + VertexPositionColorTexture() DIRECTX_CTOR_DEFAULT + + VertexPositionColorTexture(XMFLOAT3 const& position, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate) + : position(position), + color(color), + textureCoordinate(textureCoordinate) + { } + + VertexPositionColorTexture(FXMVECTOR position, FXMVECTOR color, FXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat4(&this->color, color); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT4 color; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 3; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, normal vector, and color information. + struct VertexPositionNormalColor + { + VertexPositionNormalColor() DIRECTX_CTOR_DEFAULT + + VertexPositionNormalColor(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& color) + : position(position), + normal(normal), + color(color) + { } + + VertexPositionNormalColor(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR color) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->color, color); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT4 color; + + static const int InputElementCount = 3; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, normal vector, and texture mapping information. + struct VertexPositionNormalTexture + { + VertexPositionNormalTexture() DIRECTX_CTOR_DEFAULT + + VertexPositionNormalTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + textureCoordinate(textureCoordinate) + { } + + VertexPositionNormalTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 3; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct holding position, normal vector, color, and texture mapping information. + struct VertexPositionNormalColorTexture + { + VertexPositionNormalColorTexture() DIRECTX_CTOR_DEFAULT + + VertexPositionNormalColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + color(color), + textureCoordinate(textureCoordinate) + { } + + VertexPositionNormalColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR color, CXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->color, color); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT4 color; + XMFLOAT2 textureCoordinate; + + static const int InputElementCount = 4; + static const D3D11_INPUT_ELEMENT_DESC InputElements[InputElementCount]; + }; + + + // Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, + // tangent, color (RGBA), and texture mapping information + struct VertexPositionNormalTangentColorTexture + { + VertexPositionNormalTangentColorTexture() DIRECTX_CTOR_DEFAULT + + XMFLOAT3 position; + XMFLOAT3 normal; + XMFLOAT4 tangent; + uint32_t color; + XMFLOAT2 textureCoordinate; + + VertexPositionNormalTangentColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, uint32_t rgba, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + tangent(tangent), + color(rgba), + textureCoordinate(textureCoordinate) + { + } + + VertexPositionNormalTangentColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, uint32_t rgba, CXMVECTOR textureCoordinate) + : color(rgba) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->tangent, tangent); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + } + + VertexPositionNormalTangentColorTexture(XMFLOAT3 const& position, XMFLOAT3 const& normal, XMFLOAT4 const& tangent, XMFLOAT4 const& color, XMFLOAT2 const& textureCoordinate) + : position(position), + normal(normal), + tangent(tangent), + textureCoordinate(textureCoordinate) + { + SetColor( color ); + } + + VertexPositionNormalTangentColorTexture(FXMVECTOR position, FXMVECTOR normal, FXMVECTOR tangent, CXMVECTOR color, CXMVECTOR textureCoordinate) + { + XMStoreFloat3(&this->position, position); + XMStoreFloat3(&this->normal, normal); + XMStoreFloat4(&this->tangent, tangent); + XMStoreFloat2(&this->textureCoordinate, textureCoordinate); + + SetColor( color ); + } + + 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]; + }; + + + // Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, + // tangent, color (RGBA), texture mapping information, and skinning weights + struct VertexPositionNormalTangentColorTextureSkinning : public VertexPositionNormalTangentColorTexture + { + VertexPositionNormalTangentColorTextureSkinning() DIRECTX_CTOR_DEFAULT + + 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) + { + 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) + { + 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) + { + 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) + { + SetBlendIndices( indices ); + SetBlendWeights( weights ); + } + + void __cdecl SetBlendIndices( XMUINT4 const& iindices ); + + 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]; + }; +} diff --git a/Kits/DirectXTK/Inc/WICTextureLoader.h b/Kits/DirectXTK/Inc/WICTextureLoader.h new file mode 100644 index 0000000000000000000000000000000000000000..5e96d3cb1312601cf2ea6794c0a6b552b8c649d8 --- /dev/null +++ b/Kits/DirectXTK/Inc/WICTextureLoader.h @@ -0,0 +1,154 @@ +//-------------------------------------------------------------------------------------- +// File: WICTextureLoader.h +// +// Function for loading a WIC image and creating a Direct3D 11 runtime texture for it +// (auto-generating mipmaps if possible) +// +// Note: Assumes application has already called CoInitializeEx +// +// Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for +// auto-gen mipmap support. +// +// Note these functions are useful for images created as simple 2D textures. For +// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (_WIN32_WINNT <= _WIN32_WINNT_WIN8) +#error WIC is not supported on Windows Phone 8.0 +#endif + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +namespace DirectX +{ + // Standard version + HRESULT __cdecl CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + HRESULT __cdecl CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + // Standard version with optional auto-gen mipmap support + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateWICTextureFromMemory( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateWICTextureFromFile( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_z_ const wchar_t* szFileName, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + // Extended version + HRESULT __cdecl CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); + + HRESULT __cdecl CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); + + // Extended version with optional auto-gen mipmap support + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateWICTextureFromMemoryEx( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); + + #if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT __cdecl CreateWICTextureFromFileEx( _In_ ID3D11DeviceX* d3dDevice, + _In_opt_ ID3D11DeviceContextX* d3dContext, + #else + HRESULT __cdecl CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + #endif + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); +} \ No newline at end of file diff --git a/Kits/DirectXTK/Readme.txt b/Kits/DirectXTK/Readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..3d6ff74c22ddf20e7c1fe879eac3579f52c1e06b --- /dev/null +++ b/Kits/DirectXTK/Readme.txt @@ -0,0 +1,282 @@ +-------------------------------- +DirectXTK - the DirectX Tool Kit +-------------------------------- + +Copyright (c) Microsoft Corporation. All rights reserved. + +February 23, 2016 + +This package contains the "DirectX Tool Kit", a collection of helper classes for +writing Direct3D 11 C++ code for universal Windows apps for Windows 10, +Windows Store apps, Windows phone 8.x applications, Xbox One exclusive apps, +Xbox One hub apps, Windows 8.x Win32 desktop applications, Windows 7 applications, +and Windows Vista Direct3D 11.0 applications. + +This code is designed to build with Visual Studio 2013 or 2015. It is recommended that you +make use of VS 2013 Update 5, VS 2015 Update 1, and Windows 7 Service Pack 1 or later. + +These components are designed to work without requiring any content from the DirectX SDK. For details, +see "Where is the DirectX SDK?" . + +Inc\ + Public Header Files (in the DirectX C++ namespace): + + Audio.h - low-level audio API using XAudio2 (DirectXTK for Audio public header) + CommonStates.h - factory providing commonly used D3D state objects + DirectXHelpers.h - misc C++ helpers for D3D programming + DDSTextureLoader.h - light-weight DDS file texture loader + Effects.h - set of built-in shaders for common rendering tasks + GamePad.h - gamepad controller helper using XInput + GeometricPrimitive.h - draws basic shapes such as cubes and spheres + GraphicsMemory.h - helper for managing dynamic graphics memory allocation + Keyboard.h - keyboard state tracking helper + Model.h - draws meshes loaded from .CMO, .SDKMESH, or .VBO files + Mouse.h - mouse helper + PrimitiveBatch.h - simple and efficient way to draw user primitives + ScreenGrab.h - light-weight screen shot saver + SimpleMath.h - simplified C++ wrapper for DirectXMath + SpriteBatch.h - simple & efficient 2D sprite rendering + SpriteFont.h - bitmap based text rendering + VertexTypes.h - structures for commonly used vertex data formats + WICTextureLoader.h - WIC-based image file texture loader + XboxDDSTextureLoader.h - Xbox One exclusive apps variant of DDSTextureLoader + +Src\ + DirectXTK source files and internal implementation headers + +Audio\ + DirectXTK for Audio source files and internal implementation headers + +MakeSpriteFont\ + Command line tool used to generate binary resources for use with SpriteFont + +XWBTool\ + Command line tool for building XACT-style wave banks for use with DirectXTK for Audio's WaveBank class + +All content and source code for this package are subject to the terms of the MIT License. +. + +Documentation is available at . + +For the latest version of DirectX Tool Kit, bug reports, etc. please visit the project site. + +http://go.microsoft.com/fwlink/?LinkId=248929 + +Note: Xbox One exclusive apps developers using the Xbox One XDK need to generate the + Src\Shaders\Compiled\XboxOne*.inc files to build the library as they are not + included in the distribution package. They are built by running the script + in Src\Shaders - "CompileShaders xbox", and should be generated with the matching + FXC compiler from the Xbox One XDK. While they will continue to work if outdated, + a mismatch will cause runtime compilation overhead that would otherwise be avoided. + + +--------------- +RELEASE HISTORY +--------------- + +February 23, 2016 + Fixed width computation bug in SpriteFont::MeasureString + Fix to clean up partial or zero-length image files on failed write + Fix to WaveBankReader for UWP platform + Retired VS 2012 projects + Xbox One platform updates + Minor code and project file cleanup + +January 5, 2016 + Xbox One platform updates + *breaking change* Need to add use of GraphicsMemory class to Xbox One titles + Minor code cleanup + +November 30, 2015 + SimpleMath improvements including Viewport class + Fixed bug with Keyboard for OpenBracket and later VK codes + Fixed bug with Mouse that reset the scrollwheel on app activate + MakeSpriteFont updated with /FastPack and /FeatureLevel switches + Updated for VS 2015 Update 1 and Windows 10 SDK (10586) + +October 30, 2015 + DirectXTK for Audio 3D updates + *breaking change* emitters/listeners now use RH coordinates by default + GeometricPrimitive support for custom geometry + SimpleMath Matrix class improvements + DDS support for legacy bumpmap formats (V8U8, Q8W8V8U8, V16U16) + Mouse fix for WinRT implementation with multiple buttons pressed + Wireframe CommonStates no longer does backface culling + Xbox One platform updates + Minor code cleanup + +August 18, 2015 + Xbox One platform updates + +July 29, 2015 + - Added CreateBox method to GeometricPrimitive + - Added 'invertn' optional parameter to CreateSphere + - Updates for Keyboard, Mouse class + - Fixed bug when loading older SDKMESH models + - Updated for VS 2015 and Windows 10 SDK RTM + - Retired VS 2010 and Windows Store 8.0 projects + +July 1, 2015 + - Added Keyboard, Mouse class + - Support for loading pre-lit models with SDKMESH + - GamePad implemented using Windows.Gaming.Input for Windows 10 + - DirectXTK for Audio updates for xWMA support with XAudio 2.9 + - Added FindGlyph and GetSpriteSheet methods to SpriteFont + +March 27, 2015 + Added projects for Windows apps Technical Preview + - GamePad temporarily uses 'null' device for universal Windows applicaton platform + +February 25, 2015 + DirectXTK for Audio updates + - *breaking change* pitch now defined as -1 to 1 with 0 as the default + - One-shot Play method with volume, pitch, and pan + - GetMasterVolume/SetMasterVolume method for AudioEngine + - Fix for compact wavebank validation + - Improved voice cleanup and shutdown + Minor code cleanup and C++11 =default/=delete usage + +January 26, 2015 + GamePad class: emulate XInputEnable behavior for XInput 9.1.0 + DirectXTK for Audio fix for Stop followed by Play doing a proper restart + DirectXTK for Audio fix when using XAudio 2.7 on a system with no audio device + Updates for Xbox One platform support + Minor code cleanup and C99 printf string conformance + +November 24, 2014 + SimpleMath fix for Matrix operator != + DirectXTK for Audio workaround for XAudio 2.7 on Windows 7 problem + Updates for Windows phone 8.1 platform support + Updates for Visual Studio 2015 Technical Preview + Minor code cleanup + +October 28, 2014 + Model support for loading from VBO files + Model render now sets samplers on slots 0,1 by default for dual-texture effects + Updates for Xbox One platform support + Minor code cleanup + +September 5, 2014 + GamePad class: gamepad controller helper using XInput on Windows, IGamepad for Xbox One + SimpleMath updates; Matrix billboard methods; *breaking change*: Matrix::Identity() -> Matrix::Identity + SpriteBatch new optional SetViewport method + SpriteFont fix for white-space character rendering optimization + DDSTextureLoader fix for auto-gen mipmaps for volume textures + Explicit calling-convention annotation for public headers + Updates for Xbox One platform support + Minor code and project cleanup + +July 15, 2014 + DirectXTK for Audio and XWBTool fixes + Updates to Xbox One platform support + +April 3, 2014 + Windows phone 8.1 platform support + +February 24, 2014 + DirectXHelper: new utility header with MapGuard and public version of SetDebugObjectName template + DDSTextureLoader: Optional support for auto-gen mipmaps + DDSTextureLoader/ScreenGrab: support for Direct3D 11 video formats including legacy "YUY2" DDS files + GeometricPrimtive: Handedness fix for tetrahedron, octahedron, dodecahedron, and icosahedron + SpriteBatch::SetRotation(DXGI_MODE_ROTATION_UNSPECIFIED) to disable viewport matrix + XboxDDSTextureLoader: optional forceSRGB parameter + +January 24, 2014 + DirectXTK for Audio updated with voice management and optional mastering volume limiter + Added orientation rotation support to SpriteBatch + Fixed a resource leak with GetDefaultTexture() used by some Effects + Code cleanup (removed DXGI_1_2_FORMATS control define; d2d1.h workaround not needed; ScopedObject typedef removed) + +December 24, 2013 + DirectXTK for Audio + Xbox One platform support + MakeSpriteFont tool updated with more progress feedback when capturing large fonts + Minor updates for .SDKMESH Model loader + Fixed bug in .CMO Model loader when handling multiple textures + Improved debugging output + +October 28, 2013 + Updated for Visual Studio 2013 and Windows 8.1 SDK RTM + Added DGSLEffect, DGSLEffectFactory, VertexPositionNormalTangentColorTexture, and VertexPositionNormalTangentColorTextureSkinning + Model loading and effect factories support loading skinned models + MakeSpriteFont now has a smooth vs. sharp antialiasing option: /sharp + Model loading from CMOs now handles UV transforms for texture coordinates + A number of small fixes for EffectFactory + Minor code and project cleanup + Added NO_D3D11_DEBUG_NAME compilation define to control population of Direct3D debug layer names for debug builds + +July 1, 2013 + VS 2013 Preview projects added and updates for DirectXMath 3.05 __vectorcall + Added use of sRGB WIC metadata for JPEG, PNG, and TIFF + SaveToWIC functions updated with new optional setCustomProps parameter and error check with optional targetFormat + +May 30, 2013 + Added more GeometricPrimitives: Cone, Tetrahedron, Octahedron, Dodecahedron, Icosahedron + Updated to support loading new metadata from DDS files (if present) + Fixed bug with loading of WIC 32bpp RGBE format images + Fixed bug when skipping mipmaps in a 1D or 2D array texture DDS file + +February 22, 2013 + Added SimpleMath header + Fixed bug that prevented properly overriding EffectFactory::CreateTexture + Fixed forceSRGB logic in DDSTextureLoader and WICTextureLoader + Break circular reference chains when using SpriteBatch with a setCustomShaders lambda + Updated projects with /fp:fast for all configs, /arch:SSE2 for Win32 configs + Sensibly named .pdb output files + Added WIC_USE_FACTORY_PROXY build option (uses WindowsCodecs.dll entrypoint rather than CoCreateInstance) + +January 25, 2013 + GeometricPrimitive support for left-handed coordinates and drawing with custom effects + Model, ModelMesh, and ModelMeshPart added with loading of rigid non-animating models from .CMO and .SDKMESH files + EffectFactory helper class added + +December 11, 2012 + Ex versions of DDSTextureLoader and WICTextureLoader + Removed use of ATL's CComPtr in favor of WRL's ComPtr for all platforms to support VS Express editions + Updated VS 2010 project for official 'property sheet' integration for Windows 8.0 SDK + Minor fix to CommonStates for Feature Level 9.1 + Tweaked AlphaTestEffect.cpp to work around ARM NEON compiler codegen bug + Added dxguid.lib as a default library for Debug builds to resolve GUID link issues + +November 15, 2012 + Added support for WIC2 when available on Windows 8 and Windows 7 with KB 2670838 + Cleaned up warning level 4 warnings + +October 30, 2012 + Added project files for Windows phone 8 + +October 12, 2012 + Added PrimitiveBatch for drawing user primitives + Debug object names for all D3D resources (for PIX and debug layer leak reporting) + +October 2, 2012 + Added ScreenGrab module + Added CreateGeoSphere for drawing a geodesic sphere + Put DDSTextureLoader and WICTextureLoader into the DirectX C++ namespace + +September 7, 2012 + Renamed project files for better naming consistency + Updated WICTextureLoader for Windows 8 96bpp floating-point formats + Win32 desktop projects updated to use Windows Vista (0x0600) rather than Windows 7 (0x0601) APIs + Tweaked SpriteBatch.cpp to workaround ARM NEON compiler codegen bug + +May 31, 2012 + Updated Metro project for Visual Studio 2012 Release Candidate changes + Cleaned up x64 Debug configuration warnings and switched to use "_DEBUG" instead of "DEBUG" + Minor fix for DDSTextureLoader's retry fallback that can happen with 10level9 feature levels + +May 2, 2012 + Added SpriteFont implementation and the MakeSpriteFont utility + +March 29, 2012 + WICTextureLoader updated with Windows 8 WIC native pixel formats + +March 6, 2012 + Fix for too much temp memory used by WICTextureLoader + Add separate Visual Studio 11 projects for Desktop vs. Metro builds + +March 5, 2012 + Bug fix for SpriteBatch with batches > 2048 + +February 24, 2012 + Original release diff --git a/Kits/DirectXTK/Src/AlignedNew.h b/Kits/DirectXTK/Src/AlignedNew.h new file mode 100644 index 0000000000000000000000000000000000000000..49c761f0b0f25d5b90bad1dfbe97a5d75372a7b9 --- /dev/null +++ b/Kits/DirectXTK/Src/AlignedNew.h @@ -0,0 +1,67 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include +#include + + +namespace DirectX +{ + // Derive from this to customize operator new and delete for + // types that have special heap alignment requirements. + // + // Example usage: + // + // __declspec(align(16)) struct MyAlignedType : public AlignedNew + + template + struct AlignedNew + { + // Allocate aligned memory. + static void* operator new (size_t size) + { + const size_t alignment = __alignof(TDerived); + + static_assert(alignment > 8, "AlignedNew is only useful for types with > 8 byte alignment. Did you forget a __declspec(align) on TDerived?"); + + void* ptr = _aligned_malloc(size, alignment); + + if (!ptr) + throw std::bad_alloc(); + + return ptr; + } + + + // Free aligned memory. + static void operator delete (void* ptr) + { + _aligned_free(ptr); + } + + + // Array overloads. + static void* operator new[] (size_t size) + { + return operator new(size); + } + + + static void operator delete[] (void* ptr) + { + operator delete(ptr); + } + }; +} diff --git a/Kits/DirectXTK/Src/AlphaTestEffect.cpp b/Kits/DirectXTK/Src/AlphaTestEffect.cpp new file mode 100644 index 0000000000000000000000000000000000000000..caeb09e4d8866bc5af6d4623dcda5c0b2bfa104f --- /dev/null +++ b/Kits/DirectXTK/Src/AlphaTestEffect.cpp @@ -0,0 +1,417 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "EffectCommon.h" + +using namespace DirectX; + + +// Constant buffer layout. Must match the shader! +struct AlphaTestEffectConstants +{ + XMVECTOR diffuseColor; + XMVECTOR alphaTest; + XMVECTOR fogColor; + XMVECTOR fogVector; + XMMATRIX worldViewProj; +}; + +static_assert( ( sizeof(AlphaTestEffectConstants) % 16 ) == 0, "CB size not padded correctly" ); + + +// Traits type describes our characteristics to the EffectBase template. +struct AlphaTestEffectTraits +{ + typedef AlphaTestEffectConstants ConstantBufferType; + + static const int VertexShaderCount = 4; + static const int PixelShaderCount = 4; + static const int ShaderPermutationCount = 8; +}; + + +// Internal AlphaTestEffect implementation class. +class AlphaTestEffect::Impl : public EffectBase +{ +public: + Impl(_In_ ID3D11Device* device); + + D3D11_COMPARISON_FUNC alphaFunction; + int referenceAlpha; + + bool vertexColorEnabled; + + EffectColor color; + + int GetCurrentShaderPermutation() const; + + void Apply(_In_ ID3D11DeviceContext* deviceContext); +}; + + +// Include the precompiled shader code. +namespace +{ +#if defined(_XBOX_ONE) && defined(_TITLE) + #include "Shaders/Compiled/XboxOneAlphaTestEffect_VSAlphaTest.inc" + #include "Shaders/Compiled/XboxOneAlphaTestEffect_VSAlphaTestNoFog.inc" + #include "Shaders/Compiled/XboxOneAlphaTestEffect_VSAlphaTestVc.inc" + #include "Shaders/Compiled/XboxOneAlphaTestEffect_VSAlphaTestVcNoFog.inc" + + #include "Shaders/Compiled/XboxOneAlphaTestEffect_PSAlphaTestLtGt.inc" + #include "Shaders/Compiled/XboxOneAlphaTestEffect_PSAlphaTestLtGtNoFog.inc" + #include "Shaders/Compiled/XboxOneAlphaTestEffect_PSAlphaTestEqNe.inc" + #include "Shaders/Compiled/XboxOneAlphaTestEffect_PSAlphaTestEqNeNoFog.inc" +#else + #include "Shaders/Compiled/AlphaTestEffect_VSAlphaTest.inc" + #include "Shaders/Compiled/AlphaTestEffect_VSAlphaTestNoFog.inc" + #include "Shaders/Compiled/AlphaTestEffect_VSAlphaTestVc.inc" + #include "Shaders/Compiled/AlphaTestEffect_VSAlphaTestVcNoFog.inc" + + #include "Shaders/Compiled/AlphaTestEffect_PSAlphaTestLtGt.inc" + #include "Shaders/Compiled/AlphaTestEffect_PSAlphaTestLtGtNoFog.inc" + #include "Shaders/Compiled/AlphaTestEffect_PSAlphaTestEqNe.inc" + #include "Shaders/Compiled/AlphaTestEffect_PSAlphaTestEqNeNoFog.inc" +#endif +} + + +const ShaderBytecode EffectBase::VertexShaderBytecode[] = +{ + { AlphaTestEffect_VSAlphaTest, sizeof(AlphaTestEffect_VSAlphaTest) }, + { AlphaTestEffect_VSAlphaTestNoFog, sizeof(AlphaTestEffect_VSAlphaTestNoFog) }, + { AlphaTestEffect_VSAlphaTestVc, sizeof(AlphaTestEffect_VSAlphaTestVc) }, + { AlphaTestEffect_VSAlphaTestVcNoFog, sizeof(AlphaTestEffect_VSAlphaTestVcNoFog) }, +}; + + +const int EffectBase::VertexShaderIndices[] = +{ + 0, // lt/gt + 1, // lt/gt, no fog + 2, // lt/gt, vertex color + 3, // lt/gt, vertex color, no fog + + 0, // eq/ne + 1, // eq/ne, no fog + 2, // eq/ne, vertex color + 3, // eq/ne, vertex color, no fog +}; + + +const ShaderBytecode EffectBase::PixelShaderBytecode[] = +{ + { AlphaTestEffect_PSAlphaTestLtGt, sizeof(AlphaTestEffect_PSAlphaTestLtGt) }, + { AlphaTestEffect_PSAlphaTestLtGtNoFog, sizeof(AlphaTestEffect_PSAlphaTestLtGtNoFog) }, + { AlphaTestEffect_PSAlphaTestEqNe, sizeof(AlphaTestEffect_PSAlphaTestEqNe) }, + { AlphaTestEffect_PSAlphaTestEqNeNoFog, sizeof(AlphaTestEffect_PSAlphaTestEqNeNoFog) }, +}; + + +const int EffectBase::PixelShaderIndices[] = +{ + 0, // lt/gt + 1, // lt/gt, no fog + 0, // lt/gt, vertex color + 1, // lt/gt, vertex color, no fog + + 2, // eq/ne + 3, // eq/ne, no fog + 2, // eq/ne, vertex color + 3, // eq/ne, vertex color, no fog +}; + + +// Global pool of per-device AlphaTestEffect resources. +SharedResourcePool::DeviceResources> EffectBase::deviceResourcesPool; + + +// Constructor. +AlphaTestEffect::Impl::Impl(_In_ ID3D11Device* device) + : EffectBase(device), + alphaFunction(D3D11_COMPARISON_GREATER), + referenceAlpha(0), + vertexColorEnabled(false) +{ + static_assert( _countof(EffectBase::VertexShaderIndices) == AlphaTestEffectTraits::ShaderPermutationCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::VertexShaderBytecode) == AlphaTestEffectTraits::VertexShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderBytecode) == AlphaTestEffectTraits::PixelShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderIndices) == AlphaTestEffectTraits::ShaderPermutationCount, "array/max mismatch" ); +} + + +int AlphaTestEffect::Impl::GetCurrentShaderPermutation() const +{ + int permutation = 0; + + // Use optimized shaders if fog is disabled. + if (!fog.enabled) + { + permutation += 1; + } + + // Support vertex coloring? + if (vertexColorEnabled) + { + permutation += 2; + } + + // Which alpha compare mode? + if (alphaFunction == D3D11_COMPARISON_EQUAL || + alphaFunction == D3D11_COMPARISON_NOT_EQUAL) + { + permutation += 4; + } + + return permutation; +} + + +// Sets our state onto the D3D device. +void AlphaTestEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + // Compute derived parameter values. + matrices.SetConstants(dirtyFlags, constants.worldViewProj); + + fog.SetConstants(dirtyFlags, matrices.worldView, constants.fogVector); + + color.SetConstants(dirtyFlags, constants.diffuseColor); + + // Recompute the alpha test settings? + if (dirtyFlags & EffectDirtyFlags::AlphaTest) + { + // Convert reference alpha from 8 bit integer to 0-1 float format. + float reference = (float)referenceAlpha / 255.0f; + + // Comparison tolerance of half the 8 bit integer precision. + const float threshold = 0.5f / 255.0f; + + // What to do if the alpha comparison passes or fails. Positive accepts the pixel, negative clips it. + static const XMVECTORF32 selectIfTrue = { 1, -1 }; + static const XMVECTORF32 selectIfFalse = { -1, 1 }; + static const XMVECTORF32 selectNever = { -1, -1 }; + static const XMVECTORF32 selectAlways = { 1, 1 }; + + float compareTo; + XMVECTOR resultSelector; + + switch (alphaFunction) + { + case D3D11_COMPARISON_LESS: + // Shader will evaluate: clip((a < x) ? z : w) + compareTo = reference - threshold; + resultSelector = selectIfTrue; + break; + + case D3D11_COMPARISON_LESS_EQUAL: + // Shader will evaluate: clip((a < x) ? z : w) + compareTo = reference + threshold; + resultSelector = selectIfTrue; + break; + + case D3D11_COMPARISON_GREATER_EQUAL: + // Shader will evaluate: clip((a < x) ? z : w) + compareTo = reference - threshold; + resultSelector = selectIfFalse; + break; + + case D3D11_COMPARISON_GREATER: + // Shader will evaluate: clip((a < x) ? z : w) + compareTo = reference + threshold; + resultSelector = selectIfFalse; + break; + + case D3D11_COMPARISON_EQUAL: + // Shader will evaluate: clip((abs(a - x) < y) ? z : w) + compareTo = reference; + resultSelector = selectIfTrue; + break; + + case D3D11_COMPARISON_NOT_EQUAL: + // Shader will evaluate: clip((abs(a - x) < y) ? z : w) + compareTo = reference; + resultSelector = selectIfFalse; + break; + + case D3D11_COMPARISON_NEVER: + // Shader will evaluate: clip((a < x) ? z : w) + compareTo = 0; + resultSelector = selectNever; + break; + + case D3D11_COMPARISON_ALWAYS: + // Shader will evaluate: clip((a < x) ? z : w) + compareTo = 0; + resultSelector = selectAlways; + break; + + default: + throw std::exception("Unknown alpha test function"); + } + + // x = compareTo, y = threshold, zw = resultSelector. + constants.alphaTest = XMVectorPermute<0, 1, 4, 5>(XMVectorSet(compareTo, threshold, 0, 0), resultSelector); + + dirtyFlags &= ~EffectDirtyFlags::AlphaTest; + dirtyFlags |= EffectDirtyFlags::ConstantBuffer; + } + + // Set the texture. + ID3D11ShaderResourceView* textures[1] = { texture.Get() }; + + deviceContext->PSSetShaderResources(0, 1, textures); + + // Set shaders and constant buffers. + ApplyShaders(deviceContext, GetCurrentShaderPermutation()); +} + + +// Public constructor. +AlphaTestEffect::AlphaTestEffect(_In_ ID3D11Device* device) + : pImpl(new Impl(device)) +{ +} + + +// Move constructor. +AlphaTestEffect::AlphaTestEffect(AlphaTestEffect&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +AlphaTestEffect& AlphaTestEffect::operator= (AlphaTestEffect&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +AlphaTestEffect::~AlphaTestEffect() +{ +} + + +void AlphaTestEffect::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + pImpl->Apply(deviceContext); +} + + +void AlphaTestEffect::GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) +{ + pImpl->GetVertexShaderBytecode(pImpl->GetCurrentShaderPermutation(), pShaderByteCode, pByteCodeLength); +} + + +void XM_CALLCONV AlphaTestEffect::SetWorld(FXMMATRIX value) +{ + pImpl->matrices.world = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::WorldInverseTranspose | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV AlphaTestEffect::SetView(FXMMATRIX value) +{ + pImpl->matrices.view = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::EyePosition | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV AlphaTestEffect::SetProjection(FXMMATRIX value) +{ + pImpl->matrices.projection = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj; +} + + +void XM_CALLCONV AlphaTestEffect::SetDiffuseColor(FXMVECTOR value) +{ + pImpl->color.diffuseColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void AlphaTestEffect::SetAlpha(float value) +{ + pImpl->color.alpha = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void AlphaTestEffect::SetFogEnabled(bool value) +{ + pImpl->fog.enabled = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogEnable; +} + + +void AlphaTestEffect::SetFogStart(float value) +{ + pImpl->fog.start = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void AlphaTestEffect::SetFogEnd(float value) +{ + pImpl->fog.end = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV AlphaTestEffect::SetFogColor(FXMVECTOR value) +{ + pImpl->constants.fogColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void AlphaTestEffect::SetVertexColorEnabled(bool value) +{ + pImpl->vertexColorEnabled = value; +} + + +void AlphaTestEffect::SetTexture(_In_opt_ ID3D11ShaderResourceView* value) +{ + pImpl->texture = value; +} + + +void AlphaTestEffect::SetAlphaFunction(D3D11_COMPARISON_FUNC value) +{ + pImpl->alphaFunction = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::AlphaTest; +} + + +void AlphaTestEffect::SetReferenceAlpha(int value) +{ + pImpl->referenceAlpha = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::AlphaTest; +} diff --git a/Kits/DirectXTK/Src/BasicEffect.cpp b/Kits/DirectXTK/Src/BasicEffect.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b9589d9d06d58d3f0548966cdfe563f0b657b14a --- /dev/null +++ b/Kits/DirectXTK/Src/BasicEffect.cpp @@ -0,0 +1,587 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "EffectCommon.h" + +using namespace DirectX; + + +// Constant buffer layout. Must match the shader! +struct BasicEffectConstants +{ + XMVECTOR diffuseColor; + XMVECTOR emissiveColor; + XMVECTOR specularColorAndPower; + + XMVECTOR lightDirection[IEffectLights::MaxDirectionalLights]; + XMVECTOR lightDiffuseColor[IEffectLights::MaxDirectionalLights]; + XMVECTOR lightSpecularColor[IEffectLights::MaxDirectionalLights]; + + XMVECTOR eyePosition; + + XMVECTOR fogColor; + XMVECTOR fogVector; + + XMMATRIX world; + XMVECTOR worldInverseTranspose[3]; + XMMATRIX worldViewProj; +}; + +static_assert( ( sizeof(BasicEffectConstants) % 16 ) == 0, "CB size not padded correctly" ); + + +// Traits type describes our characteristics to the EffectBase template. +struct BasicEffectTraits +{ + typedef BasicEffectConstants ConstantBufferType; + + static const int VertexShaderCount = 20; + static const int PixelShaderCount = 10; + static const int ShaderPermutationCount = 32; +}; + + +// Internal BasicEffect implementation class. +class BasicEffect::Impl : public EffectBase +{ +public: + Impl(_In_ ID3D11Device* device); + + bool lightingEnabled; + bool preferPerPixelLighting; + bool vertexColorEnabled; + bool textureEnabled; + + EffectLights lights; + + int GetCurrentShaderPermutation() const; + + void Apply(_In_ ID3D11DeviceContext* deviceContext); +}; + + +// Include the precompiled shader code. +namespace +{ +#if defined(_XBOX_ONE) && defined(_TITLE) + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasic.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicNoFog.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicVc.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicVcNoFog.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicTx.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicTxNoFog.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicTxVc.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicTxVcNoFog.inc" + + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicVertexLighting.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicVertexLightingVc.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicVertexLightingTx.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicVertexLightingTxVc.inc" + + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicOneLight.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicOneLightVc.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicOneLightTx.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicOneLightTxVc.inc" + + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicPixelLighting.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicPixelLightingVc.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicPixelLightingTx.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_VSBasicPixelLightingTxVc.inc" + + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasic.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasicNoFog.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasicTx.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasicTxNoFog.inc" + + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasicVertexLighting.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasicVertexLightingNoFog.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasicVertexLightingTx.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasicVertexLightingTxNoFog.inc" + + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasicPixelLighting.inc" + #include "Shaders/Compiled/XboxOneBasicEffect_PSBasicPixelLightingTx.inc" +#else + #include "Shaders/Compiled/BasicEffect_VSBasic.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicNoFog.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicVc.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicVcNoFog.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicTx.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicTxNoFog.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicTxVc.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicTxVcNoFog.inc" + + #include "Shaders/Compiled/BasicEffect_VSBasicVertexLighting.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicVertexLightingVc.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicVertexLightingTx.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicVertexLightingTxVc.inc" + + #include "Shaders/Compiled/BasicEffect_VSBasicOneLight.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicOneLightVc.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicOneLightTx.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicOneLightTxVc.inc" + + #include "Shaders/Compiled/BasicEffect_VSBasicPixelLighting.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicPixelLightingVc.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicPixelLightingTx.inc" + #include "Shaders/Compiled/BasicEffect_VSBasicPixelLightingTxVc.inc" + + #include "Shaders/Compiled/BasicEffect_PSBasic.inc" + #include "Shaders/Compiled/BasicEffect_PSBasicNoFog.inc" + #include "Shaders/Compiled/BasicEffect_PSBasicTx.inc" + #include "Shaders/Compiled/BasicEffect_PSBasicTxNoFog.inc" + + #include "Shaders/Compiled/BasicEffect_PSBasicVertexLighting.inc" + #include "Shaders/Compiled/BasicEffect_PSBasicVertexLightingNoFog.inc" + #include "Shaders/Compiled/BasicEffect_PSBasicVertexLightingTx.inc" + #include "Shaders/Compiled/BasicEffect_PSBasicVertexLightingTxNoFog.inc" + + #include "Shaders/Compiled/BasicEffect_PSBasicPixelLighting.inc" + #include "Shaders/Compiled/BasicEffect_PSBasicPixelLightingTx.inc" +#endif +} + + +const ShaderBytecode EffectBase::VertexShaderBytecode[] = +{ + { BasicEffect_VSBasic, sizeof(BasicEffect_VSBasic) }, + { BasicEffect_VSBasicNoFog, sizeof(BasicEffect_VSBasicNoFog) }, + { BasicEffect_VSBasicVc, sizeof(BasicEffect_VSBasicVc) }, + { BasicEffect_VSBasicVcNoFog, sizeof(BasicEffect_VSBasicVcNoFog) }, + { BasicEffect_VSBasicTx, sizeof(BasicEffect_VSBasicTx) }, + { BasicEffect_VSBasicTxNoFog, sizeof(BasicEffect_VSBasicTxNoFog) }, + { BasicEffect_VSBasicTxVc, sizeof(BasicEffect_VSBasicTxVc) }, + { BasicEffect_VSBasicTxVcNoFog, sizeof(BasicEffect_VSBasicTxVcNoFog) }, + + { BasicEffect_VSBasicVertexLighting, sizeof(BasicEffect_VSBasicVertexLighting) }, + { BasicEffect_VSBasicVertexLightingVc, sizeof(BasicEffect_VSBasicVertexLightingVc) }, + { BasicEffect_VSBasicVertexLightingTx, sizeof(BasicEffect_VSBasicVertexLightingTx) }, + { BasicEffect_VSBasicVertexLightingTxVc, sizeof(BasicEffect_VSBasicVertexLightingTxVc) }, + + { BasicEffect_VSBasicOneLight, sizeof(BasicEffect_VSBasicOneLight) }, + { BasicEffect_VSBasicOneLightVc, sizeof(BasicEffect_VSBasicOneLightVc) }, + { BasicEffect_VSBasicOneLightTx, sizeof(BasicEffect_VSBasicOneLightTx) }, + { BasicEffect_VSBasicOneLightTxVc, sizeof(BasicEffect_VSBasicOneLightTxVc) }, + + { BasicEffect_VSBasicPixelLighting, sizeof(BasicEffect_VSBasicPixelLighting) }, + { BasicEffect_VSBasicPixelLightingVc, sizeof(BasicEffect_VSBasicPixelLightingVc) }, + { BasicEffect_VSBasicPixelLightingTx, sizeof(BasicEffect_VSBasicPixelLightingTx) }, + { BasicEffect_VSBasicPixelLightingTxVc, sizeof(BasicEffect_VSBasicPixelLightingTxVc) }, +}; + + +const int EffectBase::VertexShaderIndices[] = +{ + 0, // basic + 1, // no fog + 2, // vertex color + 3, // vertex color, no fog + 4, // texture + 5, // texture, no fog + 6, // texture + vertex color + 7, // texture + vertex color, no fog + + 8, // vertex lighting + 8, // vertex lighting, no fog + 9, // vertex lighting + vertex color + 9, // vertex lighting + vertex color, no fog + 10, // vertex lighting + texture + 10, // vertex lighting + texture, no fog + 11, // vertex lighting + texture + vertex color + 11, // vertex lighting + texture + vertex color, no fog + + 12, // one light + 12, // one light, no fog + 13, // one light + vertex color + 13, // one light + vertex color, no fog + 14, // one light + texture + 14, // one light + texture, no fog + 15, // one light + texture + vertex color + 15, // one light + texture + vertex color, no fog + + 16, // pixel lighting + 16, // pixel lighting, no fog + 17, // pixel lighting + vertex color + 17, // pixel lighting + vertex color, no fog + 18, // pixel lighting + texture + 18, // pixel lighting + texture, no fog + 19, // pixel lighting + texture + vertex color + 19, // pixel lighting + texture + vertex color, no fog +}; + + +const ShaderBytecode EffectBase::PixelShaderBytecode[] = +{ + { BasicEffect_PSBasic, sizeof(BasicEffect_PSBasic) }, + { BasicEffect_PSBasicNoFog, sizeof(BasicEffect_PSBasicNoFog) }, + { BasicEffect_PSBasicTx, sizeof(BasicEffect_PSBasicTx) }, + { BasicEffect_PSBasicTxNoFog, sizeof(BasicEffect_PSBasicTxNoFog) }, + + { BasicEffect_PSBasicVertexLighting, sizeof(BasicEffect_PSBasicVertexLighting) }, + { BasicEffect_PSBasicVertexLightingNoFog, sizeof(BasicEffect_PSBasicVertexLightingNoFog) }, + { BasicEffect_PSBasicVertexLightingTx, sizeof(BasicEffect_PSBasicVertexLightingTx) }, + { BasicEffect_PSBasicVertexLightingTxNoFog, sizeof(BasicEffect_PSBasicVertexLightingTxNoFog) }, + + { BasicEffect_PSBasicPixelLighting, sizeof(BasicEffect_PSBasicPixelLighting) }, + { BasicEffect_PSBasicPixelLightingTx, sizeof(BasicEffect_PSBasicPixelLightingTx) }, +}; + + +const int EffectBase::PixelShaderIndices[] = +{ + 0, // basic + 1, // no fog + 0, // vertex color + 1, // vertex color, no fog + 2, // texture + 3, // texture, no fog + 2, // texture + vertex color + 3, // texture + vertex color, no fog + + 4, // vertex lighting + 5, // vertex lighting, no fog + 4, // vertex lighting + vertex color + 5, // vertex lighting + vertex color, no fog + 6, // vertex lighting + texture + 7, // vertex lighting + texture, no fog + 6, // vertex lighting + texture + vertex color + 7, // vertex lighting + texture + vertex color, no fog + + 4, // one light + 5, // one light, no fog + 4, // one light + vertex color + 5, // one light + vertex color, no fog + 6, // one light + texture + 7, // one light + texture, no fog + 6, // one light + texture + vertex color + 7, // one light + texture + vertex color, no fog + + 8, // pixel lighting + 8, // pixel lighting, no fog + 8, // pixel lighting + vertex color + 8, // pixel lighting + vertex color, no fog + 9, // pixel lighting + texture + 9, // pixel lighting + texture, no fog + 9, // pixel lighting + texture + vertex color + 9, // pixel lighting + texture + vertex color, no fog +}; + + +// Global pool of per-device BasicEffect resources. +SharedResourcePool::DeviceResources> EffectBase::deviceResourcesPool; + + +// Constructor. +BasicEffect::Impl::Impl(_In_ ID3D11Device* device) + : EffectBase(device), + lightingEnabled(false), + preferPerPixelLighting(false), + vertexColorEnabled(false), + textureEnabled(false) +{ + static_assert( _countof(EffectBase::VertexShaderIndices) == BasicEffectTraits::ShaderPermutationCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::VertexShaderBytecode) == BasicEffectTraits::VertexShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderBytecode) == BasicEffectTraits::PixelShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderIndices) == BasicEffectTraits::ShaderPermutationCount, "array/max mismatch" ); + + lights.InitializeConstants(constants.specularColorAndPower, constants.lightDirection, constants.lightDiffuseColor, constants.lightSpecularColor); +} + + +int BasicEffect::Impl::GetCurrentShaderPermutation() const +{ + int permutation = 0; + + // Use optimized shaders if fog is disabled. + if (!fog.enabled) + { + permutation += 1; + } + + // Support vertex coloring? + if (vertexColorEnabled) + { + permutation += 2; + } + + // Support texturing? + if (textureEnabled) + { + permutation += 4; + } + + if (lightingEnabled) + { + if (preferPerPixelLighting) + { + // Do lighting in the pixel shader. + permutation += 24; + } + else if (!lights.lightEnabled[1] && !lights.lightEnabled[2]) + { + // Use the only-bother-with-the-first-light shader optimization. + permutation += 16; + } + else + { + // Compute all three lights in the vertex shader. + permutation += 8; + } + } + + return permutation; +} + + +// Sets our state onto the D3D device. +void BasicEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + // Compute derived parameter values. + matrices.SetConstants(dirtyFlags, constants.worldViewProj); + + fog.SetConstants(dirtyFlags, matrices.worldView, constants.fogVector); + + lights.SetConstants(dirtyFlags, matrices, constants.world, constants.worldInverseTranspose, constants.eyePosition, constants.diffuseColor, constants.emissiveColor, lightingEnabled); + + // Set the texture. + if (textureEnabled) + { + ID3D11ShaderResourceView* textures[1] = { texture.Get() }; + + deviceContext->PSSetShaderResources(0, 1, textures); + } + + // Set shaders and constant buffers. + ApplyShaders(deviceContext, GetCurrentShaderPermutation()); +} + + +// Public constructor. +BasicEffect::BasicEffect(_In_ ID3D11Device* device) + : pImpl(new Impl(device)) +{ +} + + +// Move constructor. +BasicEffect::BasicEffect(BasicEffect&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +BasicEffect& BasicEffect::operator= (BasicEffect&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +BasicEffect::~BasicEffect() +{ +} + + +void BasicEffect::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + pImpl->Apply(deviceContext); +} + + +void BasicEffect::GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) +{ + pImpl->GetVertexShaderBytecode(pImpl->GetCurrentShaderPermutation(), pShaderByteCode, pByteCodeLength); +} + + +void XM_CALLCONV BasicEffect::SetWorld(FXMMATRIX value) +{ + pImpl->matrices.world = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::WorldInverseTranspose | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV BasicEffect::SetView(FXMMATRIX value) +{ + pImpl->matrices.view = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::EyePosition | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV BasicEffect::SetProjection(FXMMATRIX value) +{ + pImpl->matrices.projection = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj; +} + + +void XM_CALLCONV BasicEffect::SetDiffuseColor(FXMVECTOR value) +{ + pImpl->lights.diffuseColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void XM_CALLCONV BasicEffect::SetEmissiveColor(FXMVECTOR value) +{ + pImpl->lights.emissiveColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void XM_CALLCONV BasicEffect::SetSpecularColor(FXMVECTOR value) +{ + // Set xyz to new value, but preserve existing w (specular power). + pImpl->constants.specularColorAndPower = XMVectorSelect(pImpl->constants.specularColorAndPower, value, g_XMSelect1110); + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void BasicEffect::SetSpecularPower(float value) +{ + // Set w to new value, but preserve existing xyz (specular color). + pImpl->constants.specularColorAndPower = XMVectorSetW(pImpl->constants.specularColorAndPower, value); + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + +void BasicEffect::DisableSpecular() +{ + // Set specular color to black, power to 1 + // Note: Don't use a power of 0 or the shader will generate strange highlights on non-specular materials + + pImpl->constants.specularColorAndPower = g_XMIdentityR3; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + +void BasicEffect::SetAlpha(float value) +{ + pImpl->lights.alpha = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void BasicEffect::SetLightingEnabled(bool value) +{ + pImpl->lightingEnabled = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void BasicEffect::SetPerPixelLighting(bool value) +{ + pImpl->preferPerPixelLighting = value; +} + + +void XM_CALLCONV BasicEffect::SetAmbientLightColor(FXMVECTOR value) +{ + pImpl->lights.ambientLightColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void BasicEffect::SetLightEnabled(int whichLight, bool value) +{ + pImpl->dirtyFlags |= pImpl->lights.SetLightEnabled(whichLight, value, pImpl->constants.lightDiffuseColor, pImpl->constants.lightSpecularColor); +} + + +void XM_CALLCONV BasicEffect::SetLightDirection(int whichLight, FXMVECTOR value) +{ + EffectLights::ValidateLightIndex(whichLight); + + pImpl->constants.lightDirection[whichLight] = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void XM_CALLCONV BasicEffect::SetLightDiffuseColor(int whichLight, FXMVECTOR value) +{ + pImpl->dirtyFlags |= pImpl->lights.SetLightDiffuseColor(whichLight, value, pImpl->constants.lightDiffuseColor); +} + + +void XM_CALLCONV BasicEffect::SetLightSpecularColor(int whichLight, FXMVECTOR value) +{ + pImpl->dirtyFlags |= pImpl->lights.SetLightSpecularColor(whichLight, value, pImpl->constants.lightSpecularColor); +} + + +void BasicEffect::EnableDefaultLighting() +{ + EffectLights::EnableDefaultLighting(this); +} + + +void BasicEffect::SetFogEnabled(bool value) +{ + pImpl->fog.enabled = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogEnable; +} + + +void BasicEffect::SetFogStart(float value) +{ + pImpl->fog.start = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void BasicEffect::SetFogEnd(float value) +{ + pImpl->fog.end = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV BasicEffect::SetFogColor(FXMVECTOR value) +{ + pImpl->constants.fogColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void BasicEffect::SetVertexColorEnabled(bool value) +{ + pImpl->vertexColorEnabled = value; +} + + +void BasicEffect::SetTextureEnabled(bool value) +{ + pImpl->textureEnabled = value; +} + + +void BasicEffect::SetTexture(_In_opt_ ID3D11ShaderResourceView* value) +{ + pImpl->texture = value; +} diff --git a/Kits/DirectXTK/Src/Bezier.h b/Kits/DirectXTK/Src/Bezier.h new file mode 100644 index 0000000000000000000000000000000000000000..613210a65e0b4a5178ae73b23fb36b2555de9bb9 --- /dev/null +++ b/Kits/DirectXTK/Src/Bezier.h @@ -0,0 +1,169 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include +#include +#include + + +namespace Bezier +{ + // Performs a cubic bezier interpolation between four control points, + // returning the value at the specified time (t ranges 0 to 1). + // This template implementation can be used to interpolate XMVECTOR, + // float, or any other types that define suitable * and + operators. + template + T CubicInterpolate(T const& p1, T const& p2, T const& p3, T const& p4, float t) + { + using DirectX::operator*; + 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; + } + + + // Computes the tangent of a cubic bezier curve at the specified time. + // Template supports XMVECTOR, float, or any other types with * and + operators. + template + T CubicTangent(T const& p1, T const& p2, T const& p3, T const& p4, float t) + { + using DirectX::operator*; + 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); + } + + + // Creates vertices for a patch that is tessellated at the specified level. + // Calls the specified outputVertex function for each generated vertex, + // passing the position, normal, and texture coordinate as parameters. + template + void CreatePatchVertices(_In_reads_(16) DirectX::XMVECTOR patch[16], size_t tessellation, bool isMirrored, TOutputFunc outputVertex) + { + using namespace DirectX; + + for (size_t i = 0; i <= tessellation; i++) + { + float u = (float)i / tessellation; + + for (size_t j = 0; j <= tessellation; j++) + { + float v = (float)j / tessellation; + + // 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 p4 = CubicInterpolate(patch[12], patch[13], patch[14], patch[15], u); + + // Perform a vertical interpolation between the results of the + // previous horizontal interpolations, to compute the position. + XMVECTOR position = CubicInterpolate(p1, p2, p3, p4, v); + + // 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 q3 = CubicInterpolate(patch[2], patch[6], patch[10], patch[14], v); + XMVECTOR q4 = CubicInterpolate(patch[3], patch[7], patch[11], patch[15], v); + + // Compute vertical and horizontal tangent vectors. + XMVECTOR tangent1 = CubicTangent(p1, p2, p3, p4, v); + XMVECTOR tangent2 = CubicTangent(q1, q2, q3, q4, u); + + // Cross the two tangent vectors to compute the normal. + XMVECTOR normal = XMVector3Cross(tangent1, tangent2); + + if (!XMVector3NearEqual(normal, XMVectorZero(), g_XMEpsilon)) + { + normal = XMVector3Normalize(normal); + + // If this patch is mirrored, we must invert the normal. + if (isMirrored) + { + normal = -normal; + } + } + else + { + // In a tidy and well constructed bezier patch, the preceding + // normal computation will always work. But the classic teapot + // model is not tidy or well constructed! At the top and bottom + // of the teapot, it contains degenerate geometry where a patch + // has several control points in the same place, which causes + // the tangent computation to fail and produce a zero normal. + // We 'fix' these cases by just hard-coding a normal that points + // either straight up or straight down, depending on whether we + // are on the top or bottom of the teapot. This is not a robust + // solution for all possible degenerate bezier patches, but hey, + // it's good enough to make the teapot work correctly! + + normal = XMVectorSelect(g_XMIdentityR1, g_XMNegIdentityR1, XMVectorLess(position, XMVectorZero())); + } + + // Compute the texture coordinate. + float mirroredU = isMirrored ? 1 - u : u; + + XMVECTOR textureCoordinate = XMVectorSet(mirroredU, v, 0, 0); + + // Output this vertex. + outputVertex(position, normal, textureCoordinate); + } + } + } + + + // Creates indices for a patch that is tessellated at the specified level. + // Calls the specified outputIndex function for each generated index value. + template + void CreatePatchIndices(size_t tessellation, bool isMirrored, TOutputFunc outputIndex) + { + size_t stride = tessellation + 1; + + for (size_t i = 0; i < tessellation; i++) + { + for (size_t j = 0; j < tessellation; j++) + { + // Make a list of six index values (two triangles). + std::array indices = + { + i * stride + j, + (i + 1) * stride + j, + (i + 1) * stride + j + 1, + + i * stride + j, + (i + 1) * stride + j + 1, + i * stride + j + 1, + }; + + // If this patch is mirrored, reverse indices to fix the winding order. + if (isMirrored) + { + std::reverse(indices.begin(), indices.end()); + } + + // Output these index values. + std::for_each(indices.begin(), indices.end(), outputIndex); + } + } + } +} diff --git a/Kits/DirectXTK/Src/BinaryReader.cpp b/Kits/DirectXTK/Src/BinaryReader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1d84ab98c1ac05f4cf7b80df9871360723d906fe --- /dev/null +++ b/Kits/DirectXTK/Src/BinaryReader.cpp @@ -0,0 +1,99 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" + +#include "BinaryReader.h" + +using namespace DirectX; + + +// Constructor reads from the filesystem. +BinaryReader::BinaryReader(_In_z_ wchar_t const* fileName) +{ + size_t dataSize; + + HRESULT hr = ReadEntireFile(fileName, mOwnedData, &dataSize); + if ( FAILED(hr) ) + { + DebugTrace( "BinaryReader failed (%08X) to load '%ls'\n", hr, fileName ); + throw std::exception( "BinaryReader" ); + } + + mPos = mOwnedData.get(); + mEnd = mOwnedData.get() + dataSize; +} + + +// Constructor reads from an existing memory buffer. +BinaryReader::BinaryReader(_In_reads_bytes_(dataSize) uint8_t const* dataBlob, size_t dataSize) +{ + mPos = dataBlob; + mEnd = dataBlob + dataSize; +} + + +// Reads from the filesystem into memory. +HRESULT BinaryReader::ReadEntireFile(_In_z_ wchar_t const* fileName, _Inout_ std::unique_ptr& data, _Out_ size_t* dataSize) +{ + // Open the file. +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + ScopedHandle hFile(safe_handle(CreateFile2(fileName, 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 + + if (!hFile) + return HRESULT_FROM_WIN32(GetLastError()); + + // Get the file size. + LARGE_INTEGER fileSize = { 0 }; + +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + FILE_STANDARD_INFO fileInfo; + + if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) + { + return HRESULT_FROM_WIN32(GetLastError()); + } + + fileSize = fileInfo.EndOfFile; +#else + GetFileSizeEx(hFile.get(), &fileSize); +#endif + + // File is too big for 32-bit allocation, so reject read. + if (fileSize.HighPart > 0) + return E_FAIL; + + // Create enough space for the file data. + data.reset(new uint8_t[fileSize.LowPart]); + + if (!data) + return E_OUTOFMEMORY; + + // Read the data in. + DWORD bytesRead = 0; + + if (!ReadFile(hFile.get(), data.get(), fileSize.LowPart, &bytesRead, nullptr)) + { + return HRESULT_FROM_WIN32(GetLastError()); + } + + if (bytesRead < fileSize.LowPart) + return E_FAIL; + + *dataSize = bytesRead; + + return S_OK; +} diff --git a/Kits/DirectXTK/Src/BinaryReader.h b/Kits/DirectXTK/Src/BinaryReader.h new file mode 100644 index 0000000000000000000000000000000000000000..21e414afe73aa1f57217450af972b700132db947 --- /dev/null +++ b/Kits/DirectXTK/Src/BinaryReader.h @@ -0,0 +1,74 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include +#include +#include + +#include "PlatformHelpers.h" + + +namespace DirectX +{ + // Helper for reading binary data, either from the filesystem a memory buffer. + class BinaryReader + { + public: + explicit BinaryReader(_In_z_ wchar_t const* fileName); + BinaryReader(_In_reads_bytes_(dataSize) uint8_t const* dataBlob, size_t dataSize); + + + // Reads a single value. + template T const& Read() + { + return *ReadArray(1); + } + + + // Reads an array of values. + template T const* ReadArray(size_t elementCount) + { + static_assert(std::is_pod::value, "Can only read plain-old-data types"); + + uint8_t const* newPos = mPos + sizeof(T) * elementCount; + + if (newPos > mEnd) + throw std::exception("End of file"); + + auto result = reinterpret_cast(mPos); + + mPos = newPos; + + return result; + } + + + // Lower level helper reads directly from the filesystem into memory. + static HRESULT ReadEntireFile(_In_z_ wchar_t const* fileName, _Inout_ std::unique_ptr& data, _Out_ size_t* dataSize); + + + private: + // The data currently being read. + uint8_t const* mPos; + uint8_t const* mEnd; + + std::unique_ptr mOwnedData; + + + // Prevent copying. + BinaryReader(BinaryReader const&) DIRECTX_CTOR_DELETE + BinaryReader& operator= (BinaryReader const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Src/CommonStates.cpp b/Kits/DirectXTK/Src/CommonStates.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8259e4243e36bd366a4dee190eb31f433b2bb285 --- /dev/null +++ b/Kits/DirectXTK/Src/CommonStates.cpp @@ -0,0 +1,369 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "CommonStates.h" +#include "DemandCreate.h" +#include "DirectXHelpers.h" +#include "SharedResourcePool.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +// Internal state object implementation class. Only one of these helpers is allocated +// per D3D device, even if there are multiple public facing CommonStates instances. +class CommonStates::Impl +{ +public: + Impl(_In_ ID3D11Device* device) + : device(device) + { } + + HRESULT CreateBlendState(D3D11_BLEND srcBlend, D3D11_BLEND destBlend, _Out_ ID3D11BlendState** pResult); + HRESULT CreateDepthStencilState(bool enable, bool writeEnable, _Out_ ID3D11DepthStencilState** pResult); + HRESULT CreateRasterizerState(D3D11_CULL_MODE cullMode, D3D11_FILL_MODE fillMode, _Out_ ID3D11RasterizerState** pResult); + HRESULT CreateSamplerState(D3D11_FILTER filter, D3D11_TEXTURE_ADDRESS_MODE addressMode, _Out_ ID3D11SamplerState** pResult); + + ComPtr device; + + ComPtr opaque; + ComPtr alphaBlend; + ComPtr additive; + ComPtr nonPremultiplied; + + ComPtr depthNone; + ComPtr depthDefault; + ComPtr depthRead; + + ComPtr cullNone; + ComPtr cullClockwise; + ComPtr cullCounterClockwise; + ComPtr wireframe; + + ComPtr pointWrap; + ComPtr pointClamp; + ComPtr linearWrap; + ComPtr linearClamp; + ComPtr anisotropicWrap; + ComPtr anisotropicClamp; + + std::mutex mutex; + + static SharedResourcePool instancePool; +}; + + +// Global instance pool. +SharedResourcePool CommonStates::Impl::instancePool; + + +// Helper for creating blend state objects. +HRESULT CommonStates::Impl::CreateBlendState(D3D11_BLEND srcBlend, D3D11_BLEND destBlend, _Out_ ID3D11BlendState** pResult) +{ + D3D11_BLEND_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + + desc.RenderTarget[0].BlendEnable = (srcBlend != D3D11_BLEND_ONE) || + (destBlend != D3D11_BLEND_ZERO); + + desc.RenderTarget[0].SrcBlend = desc.RenderTarget[0].SrcBlendAlpha = srcBlend; + desc.RenderTarget[0].DestBlend = desc.RenderTarget[0].DestBlendAlpha = destBlend; + desc.RenderTarget[0].BlendOp = desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + + desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + HRESULT hr = device->CreateBlendState(&desc, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:CommonStates"); + + return hr; +} + + +// Helper for creating depth stencil state objects. +HRESULT CommonStates::Impl::CreateDepthStencilState(bool enable, bool writeEnable, _Out_ ID3D11DepthStencilState** pResult) +{ + D3D11_DEPTH_STENCIL_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + + desc.DepthEnable = enable; + desc.DepthWriteMask = writeEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; + desc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; + + desc.StencilEnable = false; + desc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; + desc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; + + desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; + desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + + desc.BackFace = desc.FrontFace; + + HRESULT hr = device->CreateDepthStencilState(&desc, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:CommonStates"); + + return hr; +} + + +// Helper for creating rasterizer state objects. +HRESULT CommonStates::Impl::CreateRasterizerState(D3D11_CULL_MODE cullMode, D3D11_FILL_MODE fillMode, _Out_ ID3D11RasterizerState** pResult) +{ + D3D11_RASTERIZER_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + + desc.CullMode = cullMode; + desc.FillMode = fillMode; + desc.DepthClipEnable = true; + desc.MultisampleEnable = true; + + HRESULT hr = device->CreateRasterizerState(&desc, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:CommonStates"); + + return hr; +} + + +// Helper for creating sampler state objects. +HRESULT CommonStates::Impl::CreateSamplerState(D3D11_FILTER filter, D3D11_TEXTURE_ADDRESS_MODE addressMode, _Out_ ID3D11SamplerState** pResult) +{ + D3D11_SAMPLER_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + + desc.Filter = filter; + + desc.AddressU = addressMode; + desc.AddressV = addressMode; + desc.AddressW = addressMode; + + desc.MaxAnisotropy = (device->GetFeatureLevel() > D3D_FEATURE_LEVEL_9_1) ? 16 : 2; + + desc.MaxLOD = FLT_MAX; + desc.ComparisonFunc = D3D11_COMPARISON_NEVER; + + HRESULT hr = device->CreateSamplerState(&desc, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:CommonStates"); + + return hr; +} + + +//-------------------------------------------------------------------------------------- +// CommonStates +//-------------------------------------------------------------------------------------- + +// Public constructor. +CommonStates::CommonStates(_In_ ID3D11Device* device) + : pImpl(Impl::instancePool.DemandCreate(device)) +{ +} + + +// Move constructor. +CommonStates::CommonStates(CommonStates&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +CommonStates& CommonStates::operator= (CommonStates&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +CommonStates::~CommonStates() +{ +} + + +//-------------------------------------------------------------------------------------- +// Blend states +//-------------------------------------------------------------------------------------- + +ID3D11BlendState* CommonStates::Opaque() const +{ + return DemandCreate(pImpl->opaque, pImpl->mutex, [&](ID3D11BlendState** pResult) + { + return pImpl->CreateBlendState(D3D11_BLEND_ONE, D3D11_BLEND_ZERO, pResult); + }); +} + + +ID3D11BlendState* CommonStates::AlphaBlend() const +{ + return DemandCreate(pImpl->alphaBlend, pImpl->mutex, [&](ID3D11BlendState** pResult) + { + return pImpl->CreateBlendState(D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC_ALPHA, pResult); + }); +} + + +ID3D11BlendState* CommonStates::Additive() const +{ + return DemandCreate(pImpl->additive, pImpl->mutex, [&](ID3D11BlendState** pResult) + { + return pImpl->CreateBlendState(D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_ONE, pResult); + }); +} + + +ID3D11BlendState* CommonStates::NonPremultiplied() const +{ + return DemandCreate(pImpl->nonPremultiplied, pImpl->mutex, [&](ID3D11BlendState** pResult) + { + return pImpl->CreateBlendState(D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA, pResult); + }); +} + + +//-------------------------------------------------------------------------------------- +// Depth stencil states +//-------------------------------------------------------------------------------------- + +ID3D11DepthStencilState* CommonStates::DepthNone() const +{ + return DemandCreate(pImpl->depthNone, pImpl->mutex, [&](ID3D11DepthStencilState** pResult) + { + return pImpl->CreateDepthStencilState(false, false, pResult); + }); +} + + +ID3D11DepthStencilState* CommonStates::DepthDefault() const +{ + return DemandCreate(pImpl->depthDefault, pImpl->mutex, [&](ID3D11DepthStencilState** pResult) + { + return pImpl->CreateDepthStencilState(true, true, pResult); + }); +} + + +ID3D11DepthStencilState* CommonStates::DepthRead() const +{ + return DemandCreate(pImpl->depthRead, pImpl->mutex, [&](ID3D11DepthStencilState** pResult) + { + return pImpl->CreateDepthStencilState(true, false, pResult); + }); +} + + +//-------------------------------------------------------------------------------------- +// Rasterizer states +//-------------------------------------------------------------------------------------- + +ID3D11RasterizerState* CommonStates::CullNone() const +{ + return DemandCreate(pImpl->cullNone, pImpl->mutex, [&](ID3D11RasterizerState** pResult) + { + return pImpl->CreateRasterizerState(D3D11_CULL_NONE, D3D11_FILL_SOLID, pResult); + }); +} + + +ID3D11RasterizerState* CommonStates::CullClockwise() const +{ + return DemandCreate(pImpl->cullClockwise, pImpl->mutex, [&](ID3D11RasterizerState** pResult) + { + return pImpl->CreateRasterizerState(D3D11_CULL_FRONT, D3D11_FILL_SOLID, pResult); + }); +} + + +ID3D11RasterizerState* CommonStates::CullCounterClockwise() const +{ + return DemandCreate(pImpl->cullCounterClockwise, pImpl->mutex, [&](ID3D11RasterizerState** pResult) + { + return pImpl->CreateRasterizerState(D3D11_CULL_BACK, D3D11_FILL_SOLID, pResult); + }); +} + + +ID3D11RasterizerState* CommonStates::Wireframe() const +{ + return DemandCreate(pImpl->wireframe, pImpl->mutex, [&](ID3D11RasterizerState** pResult) + { + return pImpl->CreateRasterizerState(D3D11_CULL_NONE, D3D11_FILL_WIREFRAME, pResult); + }); +} + + +//-------------------------------------------------------------------------------------- +// Sampler states +//-------------------------------------------------------------------------------------- + +ID3D11SamplerState* CommonStates::PointWrap() const +{ + return DemandCreate(pImpl->pointWrap, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_WRAP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::PointClamp() const +{ + return DemandCreate(pImpl->pointClamp, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_CLAMP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::LinearWrap() const +{ + return DemandCreate(pImpl->linearWrap, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_WRAP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::LinearClamp() const +{ + return DemandCreate(pImpl->linearClamp, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_CLAMP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::AnisotropicWrap() const +{ + return DemandCreate(pImpl->anisotropicWrap, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_ANISOTROPIC, D3D11_TEXTURE_ADDRESS_WRAP, pResult); + }); +} + + +ID3D11SamplerState* CommonStates::AnisotropicClamp() const +{ + return DemandCreate(pImpl->anisotropicClamp, pImpl->mutex, [&](ID3D11SamplerState** pResult) + { + return pImpl->CreateSamplerState(D3D11_FILTER_ANISOTROPIC, D3D11_TEXTURE_ADDRESS_CLAMP, pResult); + }); +} diff --git a/Kits/DirectXTK/Src/ConstantBuffer.h b/Kits/DirectXTK/Src/ConstantBuffer.h new file mode 100644 index 0000000000000000000000000000000000000000..4395082216cac9ccd8e14abd19d5119686a7aafc --- /dev/null +++ b/Kits/DirectXTK/Src/ConstantBuffer.h @@ -0,0 +1,118 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "DirectXHelpers.h" +#include "GraphicsMemory.h" +#include "PlatformHelpers.h" + + +namespace DirectX +{ + // Strongly typed wrapper around a D3D constant buffer. + template + class ConstantBuffer + { + public: + // Constructor. + ConstantBuffer() DIRECTX_CTOR_DEFAULT + explicit ConstantBuffer(_In_ ID3D11Device* device) + { + Create( device ); + } + + + #if defined(_XBOX_ONE) && defined(_TITLE) + void Create(_In_ ID3D11Device* device) + { + D3D11_BUFFER_DESC desc = { 0 }; + + desc.ByteWidth = sizeof(T); + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + Microsoft::WRL::ComPtr deviceX; + ThrowIfFailed(device->QueryInterface(IID_GRAPHICS_PPV_ARGS(deviceX.GetAddressOf()))); + + ThrowIfFailed(deviceX->CreatePlacementBuffer(&desc, nullptr, mConstantBuffer.ReleaseAndGetAddressOf())); + + SetDebugObjectName(mConstantBuffer.Get(), L"DirectXTK"); + } + + + // Writes new data into the constant buffer. + void SetData(_In_ ID3D11DeviceContext* deviceContext, T const& value, void** grfxMemory) + { + assert( grfxMemory != 0 ); + + void* ptr = GraphicsMemory::Get().Allocate( deviceContext, sizeof(T), 64 ); + assert( ptr != 0 ); + + *(T*)ptr = value; + + *grfxMemory = ptr; + } + #else + void Create(_In_ ID3D11Device* device) + { + D3D11_BUFFER_DESC desc = { 0 }; + + desc.ByteWidth = sizeof(T); + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + ThrowIfFailed( + device->CreateBuffer(&desc, nullptr, mConstantBuffer.ReleaseAndGetAddressOf() ) + ); + + SetDebugObjectName(mConstantBuffer.Get(), "DirectXTK"); + } + + + // Writes new data into the constant buffer. + void SetData(_In_ ID3D11DeviceContext* deviceContext, T const& value) + { + assert( mConstantBuffer.Get() != 0 ); + + D3D11_MAPPED_SUBRESOURCE mappedResource; + + ThrowIfFailed( + deviceContext->Map(mConstantBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource) + ); + + *(T*)mappedResource.pData = value; + + deviceContext->Unmap(mConstantBuffer.Get(), 0); + } + #endif + + // Looks up the underlying D3D constant buffer. + ID3D11Buffer* GetBuffer() + { + return mConstantBuffer.Get(); + } + + + private: + // The underlying D3D object. + Microsoft::WRL::ComPtr mConstantBuffer; + + + // Prevent copying. + ConstantBuffer(ConstantBuffer const&) DIRECTX_CTOR_DELETE + ConstantBuffer& operator= (ConstantBuffer const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Src/DDSTextureLoader.cpp b/Kits/DirectXTK/Src/DDSTextureLoader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..76ea2d5eed074c2e2558d69dae3c68d8f52f8287 --- /dev/null +++ b/Kits/DirectXTK/Src/DDSTextureLoader.cpp @@ -0,0 +1,2044 @@ +//-------------------------------------------------------------------------------------- +// File: DDSTextureLoader.cpp +// +// Functions for loading a DDS texture and creating a Direct3D 11 runtime resource for it +// +// Note these functions are useful as a light-weight runtime loader for DDS files. 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" + +#include "DDSTextureLoader.h" + +#include "dds.h" +#include "DirectXHelpers.h" +#include "PlatformHelpers.h" + +using namespace DirectX; + +//-------------------------------------------------------------------------------------- +static HRESULT LoadTextureDataFromFile( _In_z_ const wchar_t* fileName, + std::unique_ptr& ddsData, + DDS_HEADER** header, + uint8_t** bitData, + size_t* bitSize + ) +{ + if (!header || !bitData || !bitSize) + { + return E_POINTER; + } + + // open the file +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + ScopedHandle hFile( safe_handle( CreateFile2( fileName, + 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 + + if ( !hFile ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + // Get the file size + LARGE_INTEGER FileSize = { 0 }; + +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + FILE_STANDARD_INFO fileInfo; + if ( !GetFileInformationByHandleEx( hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo) ) ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + FileSize = fileInfo.EndOfFile; +#else + GetFileSizeEx( hFile.get(), &FileSize ); +#endif + + // File is too big for 32-bit allocation, so reject read + if (FileSize.HighPart > 0) + { + return E_FAIL; + } + + // Need at least enough data to fill the header and magic number to be a valid DDS + if (FileSize.LowPart < ( sizeof(DDS_HEADER) + sizeof(uint32_t) ) ) + { + return E_FAIL; + } + + // create enough space for the file data + ddsData.reset( new (std::nothrow) uint8_t[ FileSize.LowPart ] ); + if (!ddsData) + { + return E_OUTOFMEMORY; + } + + // read the data in + DWORD BytesRead = 0; + if (!ReadFile( hFile.get(), + ddsData.get(), + FileSize.LowPart, + &BytesRead, + nullptr + )) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + if (BytesRead < FileSize.LowPart) + { + return E_FAIL; + } + + // DDS files always start with the same magic number ("DDS ") + uint32_t dwMagicNumber = *( const uint32_t* )( ddsData.get() ); + if (dwMagicNumber != DDS_MAGIC) + { + return E_FAIL; + } + + auto hdr = reinterpret_cast( ddsData.get() + sizeof( uint32_t ) ); + + // Verify header to validate DDS file + if (hdr->size != sizeof(DDS_HEADER) || + hdr->ddspf.size != sizeof(DDS_PIXELFORMAT)) + { + return E_FAIL; + } + + // Check for DX10 extension + bool bDXT10Header = false; + if ((hdr->ddspf.flags & DDS_FOURCC) && + (MAKEFOURCC( 'D', 'X', '1', '0' ) == hdr->ddspf.fourCC)) + { + // Must be long enough for both headers and magic value + if (FileSize.LowPart < ( sizeof(DDS_HEADER) + sizeof(uint32_t) + sizeof(DDS_HEADER_DXT10) ) ) + { + return E_FAIL; + } + + bDXT10Header = true; + } + + // setup the pointers in the process request + *header = hdr; + ptrdiff_t offset = sizeof( uint32_t ) + sizeof( DDS_HEADER ) + + (bDXT10Header ? sizeof( DDS_HEADER_DXT10 ) : 0); + *bitData = ddsData.get() + offset; + *bitSize = FileSize.LowPart - offset; + + return S_OK; +} + + +//-------------------------------------------------------------------------------------- +// Return the BPP for a particular format +//-------------------------------------------------------------------------------------- +static size_t BitsPerPixel( _In_ DXGI_FORMAT fmt ) +{ + 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_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_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_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_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_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; + +#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_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; + +#endif // _XBOX_ONE && _TITLE + + default: + return 0; + } +} + + +//-------------------------------------------------------------------------------------- +// Get surface information for a particular format +//-------------------------------------------------------------------------------------- +static 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 ) +{ + size_t numBytes = 0; + size_t rowBytes = 0; + size_t numRows = 0; + + bool bc = false; + bool packed = false; + bool planar = false; + 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_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_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_P010: + case DXGI_FORMAT_P016: + planar = true; + bpe = 4; + break; + +#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; + +#endif + } + + if (bc) + { + size_t numBlocksWide = 0; + if (width > 0) + { + numBlocksWide = std::max( 1, (width + 3) / 4 ); + } + size_t numBlocksHigh = 0; + if (height > 0) + { + numBlocksHigh = std::max( 1, (height + 3) / 4 ); + } + rowBytes = numBlocksWide * bpe; + numRows = numBlocksHigh; + numBytes = rowBytes * numBlocksHigh; + } + else if (packed) + { + rowBytes = ( ( width + 1 ) >> 1 ) * bpe; + numRows = height; + numBytes = rowBytes * height; + } + else if ( fmt == DXGI_FORMAT_NV11 ) + { + rowBytes = ( ( width + 3 ) >> 2 ) * 4; + numRows = height * 2; // Direct3D makes this simplifying assumption, although it is larger than the 4:1:1 data + numBytes = rowBytes * numRows; + } + else if (planar) + { + rowBytes = ( ( width + 1 ) >> 1 ) * bpe; + numBytes = ( rowBytes * height ) + ( ( rowBytes * height + 1 ) >> 1 ); + numRows = height + ( ( height + 1 ) >> 1 ); + } + else + { + size_t bpp = BitsPerPixel( fmt ); + rowBytes = ( width * bpp + 7 ) / 8; // round up to nearest byte + numRows = height; + numBytes = rowBytes * height; + } + + if (outNumBytes) + { + *outNumBytes = numBytes; + } + if (outRowBytes) + { + *outRowBytes = rowBytes; + } + if (outNumRows) + { + *outNumRows = numRows; + } +} + + +//-------------------------------------------------------------------------------------- +#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a ) + +static DXGI_FORMAT GetDXGIFormat( const DDS_PIXELFORMAT& ddpf ) +{ + if (ddpf.flags & DDS_RGB) + { + // Note that sRGB formats are written using the "DX10" extended header + + switch (ddpf.RGBBitCount) + { + 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,0x00000000)) + { + return DXGI_FORMAT_B8G8R8X8_UNORM; + } + + // 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 + + // 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 + + 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; + + 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; + } + + // No DXGI format maps to ISBITMASK(0x7c00,0x03e0,0x001f,0x0000) aka D3DFMT_X1R5G5B5 + + 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 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) + { + if (8 == ddpf.RGBBitCount) + { + if (ISBITMASK(0x000000ff,0x00000000,0x00000000,0x00000000)) + { + return DXGI_FORMAT_R8_UNORM; // D3DX10/11 writes this out as DX10 extension + } + + // No DXGI format maps to ISBITMASK(0x0f,0x00,0x00,0xf0) aka D3DFMT_A4L4 + } + + if (16 == ddpf.RGBBitCount) + { + if (ISBITMASK(0x0000ffff,0x00000000,0x00000000,0x00000000)) + { + return DXGI_FORMAT_R16_UNORM; // D3DX10/11 writes this out as DX10 extension + } + if (ISBITMASK(0x000000ff,0x00000000,0x00000000,0x0000ff00)) + { + return DXGI_FORMAT_R8G8_UNORM; // D3DX10/11 writes this out as DX10 extension + } + } + } + else if (ddpf.flags & DDS_ALPHA) + { + if (8 == ddpf.RGBBitCount) + { + return DXGI_FORMAT_A8_UNORM; + } + } + else if (ddpf.flags & DDS_BUMPDUDV) + { + if (16 == ddpf.RGBBitCount) + { + if (ISBITMASK(0x00ff, 0xff00, 0x0000, 0x0000)) + { + return DXGI_FORMAT_R8G8_SNORM; // D3DX10/11 writes this out as DX10 extension + } + } + + if (32 == ddpf.RGBBitCount) + { + if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)) + { + return DXGI_FORMAT_R8G8B8A8_SNORM; // D3DX10/11 writes this out as DX10 extension + } + if (ISBITMASK(0x0000ffff, 0xffff0000, 0x00000000, 0x00000000)) + { + return DXGI_FORMAT_R16G16_SNORM; // D3DX10/11 writes this out as DX10 extension + } + + // No DXGI format maps to ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000) aka D3DFMT_A2W10V10U10 + } + } + else if (ddpf.flags & DDS_FOURCC) + { + if (MAKEFOURCC( 'D', 'X', 'T', '1' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC1_UNORM; + } + if (MAKEFOURCC( 'D', 'X', 'T', '3' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC2_UNORM; + } + if (MAKEFOURCC( 'D', 'X', 'T', '5' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC3_UNORM; + } + + // While pre-multiplied alpha isn't directly supported by the DXGI formats, + // they are basically the same as these BC formats so they can be mapped + if (MAKEFOURCC( 'D', 'X', 'T', '2' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC2_UNORM; + } + if (MAKEFOURCC( 'D', 'X', 'T', '4' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC3_UNORM; + } + + if (MAKEFOURCC( 'A', 'T', 'I', '1' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC4_UNORM; + } + if (MAKEFOURCC( 'B', 'C', '4', 'U' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC4_UNORM; + } + if (MAKEFOURCC( 'B', 'C', '4', 'S' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC4_SNORM; + } + + if (MAKEFOURCC( 'A', 'T', 'I', '2' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC5_UNORM; + } + if (MAKEFOURCC( 'B', 'C', '5', 'U' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC5_UNORM; + } + if (MAKEFOURCC( 'B', 'C', '5', 'S' ) == ddpf.fourCC) + { + return DXGI_FORMAT_BC5_SNORM; + } + + // BC6H and BC7 are written using the "DX10" extended header + + if (MAKEFOURCC( 'R', 'G', 'B', 'G' ) == ddpf.fourCC) + { + return DXGI_FORMAT_R8G8_B8G8_UNORM; + } + if (MAKEFOURCC( 'G', 'R', 'G', 'B' ) == ddpf.fourCC) + { + return DXGI_FORMAT_G8R8_G8B8_UNORM; + } + + if (MAKEFOURCC('Y','U','Y','2') == ddpf.fourCC) + { + return DXGI_FORMAT_YUY2; + } + + // Check for D3DFORMAT enums being set here + switch( ddpf.fourCC ) + { + case 36: // D3DFMT_A16B16G16R16 + return DXGI_FORMAT_R16G16B16A16_UNORM; + + case 110: // D3DFMT_Q16W16V16U16 + return DXGI_FORMAT_R16G16B16A16_SNORM; + + case 111: // D3DFMT_R16F + return DXGI_FORMAT_R16_FLOAT; + + case 112: // D3DFMT_G16R16F + return DXGI_FORMAT_R16G16_FLOAT; + + case 113: // D3DFMT_A16B16G16R16F + return DXGI_FORMAT_R16G16B16A16_FLOAT; + + case 114: // D3DFMT_R32F + return DXGI_FORMAT_R32_FLOAT; + + case 115: // D3DFMT_G32R32F + return DXGI_FORMAT_R32G32_FLOAT; + + case 116: // D3DFMT_A32B32G32R32F + return DXGI_FORMAT_R32G32B32A32_FLOAT; + } + } + + return DXGI_FORMAT_UNKNOWN; +} + + +//-------------------------------------------------------------------------------------- +static DXGI_FORMAT MakeSRGB( _In_ DXGI_FORMAT format ) +{ + switch( format ) + { + 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_BC2_UNORM: + return DXGI_FORMAT_BC2_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_B8G8R8X8_UNORM: + return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; + + case DXGI_FORMAT_BC7_UNORM: + return DXGI_FORMAT_BC7_UNORM_SRGB; + + default: + return format; + } +} + + +//-------------------------------------------------------------------------------------- +static HRESULT FillInitData( _In_ size_t width, + _In_ size_t height, + _In_ size_t depth, + _In_ size_t mipCount, + _In_ size_t arraySize, + _In_ DXGI_FORMAT format, + _In_ size_t maxsize, + _In_ size_t bitSize, + _In_reads_bytes_(bitSize) const uint8_t* bitData, + _Out_ size_t& twidth, + _Out_ size_t& theight, + _Out_ size_t& tdepth, + _Out_ size_t& skipMip, + _Out_writes_(mipCount*arraySize) D3D11_SUBRESOURCE_DATA* initData ) +{ + if ( !bitData || !initData ) + { + return E_POINTER; + } + + skipMip = 0; + twidth = 0; + theight = 0; + tdepth = 0; + + size_t NumBytes = 0; + size_t RowBytes = 0; + const uint8_t* pSrcBits = bitData; + const uint8_t* pEndBits = bitData + bitSize; + + size_t index = 0; + for( size_t j = 0; j < arraySize; j++ ) + { + size_t w = width; + size_t h = height; + size_t d = depth; + for( size_t i = 0; i < mipCount; i++ ) + { + GetSurfaceInfo( w, + h, + format, + &NumBytes, + &RowBytes, + nullptr + ); + + if ( (mipCount <= 1) || !maxsize || (w <= maxsize && h <= maxsize && d <= maxsize) ) + { + if ( !twidth ) + { + twidth = w; + theight = h; + tdepth = d; + } + + assert(index < mipCount * arraySize); + _Analysis_assume_(index < mipCount * arraySize); + initData[index].pSysMem = ( const void* )pSrcBits; + initData[index].SysMemPitch = static_cast( RowBytes ); + initData[index].SysMemSlicePitch = static_cast( NumBytes ); + ++index; + } + else if ( !j ) + { + // Count number of skipped mipmaps (first item only) + ++skipMip; + } + + if (pSrcBits + (NumBytes*d) > pEndBits) + { + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + pSrcBits += NumBytes * d; + + w = w >> 1; + h = h >> 1; + d = d >> 1; + if (w == 0) + { + w = 1; + } + if (h == 0) + { + h = 1; + } + if (d == 0) + { + d = 1; + } + } + } + + return (index > 0) ? S_OK : E_FAIL; +} + + +//-------------------------------------------------------------------------------------- +static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice, + _In_ uint32_t resDim, + _In_ size_t width, + _In_ size_t height, + _In_ size_t depth, + _In_ size_t mipCount, + _In_ size_t arraySize, + _In_ DXGI_FORMAT format, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _In_ bool isCubeMap, + _In_reads_opt_(mipCount*arraySize) D3D11_SUBRESOURCE_DATA* initData, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView ) +{ + if ( !d3dDevice ) + return E_POINTER; + + HRESULT hr = E_FAIL; + + if ( forceSRGB ) + { + format = MakeSRGB( format ); + } + + switch ( resDim ) + { + case D3D11_RESOURCE_DIMENSION_TEXTURE1D: + { + D3D11_TEXTURE1D_DESC desc; + desc.Width = static_cast( width ); + desc.MipLevels = static_cast( mipCount ); + desc.ArraySize = static_cast( arraySize ); + desc.Format = format; + desc.Usage = usage; + desc.BindFlags = bindFlags; + desc.CPUAccessFlags = cpuAccessFlags; + desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE; + + ID3D11Texture1D* tex = nullptr; + hr = d3dDevice->CreateTexture1D( &desc, + initData, + &tex + ); + if (SUCCEEDED( hr ) && tex != 0) + { + if (textureView != 0) + { + D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc; + memset( &SRVDesc, 0, sizeof( SRVDesc ) ); + SRVDesc.Format = format; + + if (arraySize > 1) + { + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY; + SRVDesc.Texture1DArray.MipLevels = (!mipCount) ? -1 : desc.MipLevels; + SRVDesc.Texture1DArray.ArraySize = static_cast( arraySize ); + } + else + { + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; + SRVDesc.Texture1D.MipLevels = (!mipCount) ? -1 : desc.MipLevels; + } + + hr = d3dDevice->CreateShaderResourceView( tex, + &SRVDesc, + textureView + ); + if ( FAILED(hr) ) + { + tex->Release(); + return hr; + } + } + + if (texture != 0) + { + *texture = tex; + } + else + { + SetDebugObjectName(tex, "DDSTextureLoader"); + tex->Release(); + } + } + } + break; + + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + { + D3D11_TEXTURE2D_DESC desc; + desc.Width = static_cast( width ); + desc.Height = static_cast( height ); + desc.MipLevels = static_cast( mipCount ); + desc.ArraySize = static_cast( arraySize ); + desc.Format = format; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Usage = usage; + desc.BindFlags = bindFlags; + desc.CPUAccessFlags = cpuAccessFlags; + if ( isCubeMap ) + { + desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_TEXTURECUBE; + } + else + { + desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE; + } + + ID3D11Texture2D* tex = nullptr; + hr = d3dDevice->CreateTexture2D( &desc, + initData, + &tex + ); + if (SUCCEEDED( hr ) && tex != 0) + { + if (textureView != 0) + { + D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc; + memset( &SRVDesc, 0, sizeof( SRVDesc ) ); + SRVDesc.Format = format; + + if ( isCubeMap ) + { + if (arraySize > 6) + { + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY; + SRVDesc.TextureCubeArray.MipLevels = (!mipCount) ? -1 : desc.MipLevels; + + // Earlier we set arraySize to (NumCubes * 6) + SRVDesc.TextureCubeArray.NumCubes = static_cast( arraySize / 6 ); + } + else + { + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; + SRVDesc.TextureCube.MipLevels = (!mipCount) ? -1 : desc.MipLevels; + } + } + else if (arraySize > 1) + { + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; + SRVDesc.Texture2DArray.MipLevels = (!mipCount) ? -1 : desc.MipLevels; + SRVDesc.Texture2DArray.ArraySize = static_cast( arraySize ); + } + else + { + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + SRVDesc.Texture2D.MipLevels = (!mipCount) ? -1 : desc.MipLevels; + } + + hr = d3dDevice->CreateShaderResourceView( tex, + &SRVDesc, + textureView + ); + if ( FAILED(hr) ) + { + tex->Release(); + return hr; + } + } + + if (texture != 0) + { + *texture = tex; + } + else + { + SetDebugObjectName(tex, "DDSTextureLoader"); + tex->Release(); + } + } + } + break; + + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + { + D3D11_TEXTURE3D_DESC desc; + desc.Width = static_cast( width ); + desc.Height = static_cast( height ); + desc.Depth = static_cast( depth ); + desc.MipLevels = static_cast( mipCount ); + desc.Format = format; + desc.Usage = usage; + desc.BindFlags = bindFlags; + desc.CPUAccessFlags = cpuAccessFlags; + desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE; + + ID3D11Texture3D* tex = nullptr; + hr = d3dDevice->CreateTexture3D( &desc, + initData, + &tex + ); + if (SUCCEEDED( hr ) && tex != 0) + { + if (textureView != 0) + { + D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc; + memset( &SRVDesc, 0, sizeof( SRVDesc ) ); + SRVDesc.Format = format; + + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; + SRVDesc.Texture3D.MipLevels = (!mipCount) ? -1 : desc.MipLevels; + + hr = d3dDevice->CreateShaderResourceView( tex, + &SRVDesc, + textureView + ); + if ( FAILED(hr) ) + { + tex->Release(); + return hr; + } + } + + if (texture != 0) + { + *texture = tex; + } + else + { + SetDebugObjectName(tex, "DDSTextureLoader"); + tex->Release(); + } + } + } + break; + } + + return hr; +} + + +//-------------------------------------------------------------------------------------- +static HRESULT CreateTextureFromDDS( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, +#if defined(_XBOX_ONE) && defined(_TITLE) + _In_opt_ ID3D11DeviceX* d3dDeviceX, + _In_opt_ ID3D11DeviceContextX* d3dContextX, +#endif + _In_ const DDS_HEADER* header, + _In_reads_bytes_(bitSize) const uint8_t* bitData, + _In_ size_t bitSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView ) +{ + HRESULT hr = S_OK; + + UINT width = header->width; + UINT height = header->height; + UINT depth = header->depth; + + uint32_t resDim = D3D11_RESOURCE_DIMENSION_UNKNOWN; + UINT arraySize = 1; + DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; + bool isCubeMap = false; + + size_t mipCount = header->mipMapCount; + if (0 == mipCount) + { + mipCount = 1; + } + + if ((header->ddspf.flags & DDS_FOURCC) && + (MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC )) + { + auto d3d10ext = reinterpret_cast( (const char*)header + sizeof(DDS_HEADER) ); + + arraySize = d3d10ext->arraySize; + if (arraySize == 0) + { + return HRESULT_FROM_WIN32( ERROR_INVALID_DATA ); + } + + switch( d3d10ext->dxgiFormat ) + { + case DXGI_FORMAT_AI44: + case DXGI_FORMAT_IA44: + case DXGI_FORMAT_P8: + case DXGI_FORMAT_A8P8: + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + + default: + if ( BitsPerPixel( d3d10ext->dxgiFormat ) == 0 ) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + } + + format = d3d10ext->dxgiFormat; + + switch ( d3d10ext->resourceDimension ) + { + case D3D11_RESOURCE_DIMENSION_TEXTURE1D: + // D3DX writes 1D textures with a fixed Height of 1 + if ((header->flags & DDS_HEIGHT) && height != 1) + { + return HRESULT_FROM_WIN32( ERROR_INVALID_DATA ); + } + height = depth = 1; + break; + + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + if (d3d10ext->miscFlag & D3D11_RESOURCE_MISC_TEXTURECUBE) + { + arraySize *= 6; + isCubeMap = true; + } + depth = 1; + break; + + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + if (!(header->flags & DDS_HEADER_FLAGS_VOLUME)) + { + return HRESULT_FROM_WIN32( ERROR_INVALID_DATA ); + } + + if (arraySize > 1) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + break; + + default: + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + + resDim = d3d10ext->resourceDimension; + } + else + { + format = GetDXGIFormat( header->ddspf ); + + if (format == DXGI_FORMAT_UNKNOWN) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + + if (header->flags & DDS_HEADER_FLAGS_VOLUME) + { + resDim = D3D11_RESOURCE_DIMENSION_TEXTURE3D; + } + else + { + if (header->caps2 & DDS_CUBEMAP) + { + // We require all six faces to be defined + if ((header->caps2 & DDS_CUBEMAP_ALLFACES ) != DDS_CUBEMAP_ALLFACES) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + + arraySize = 6; + isCubeMap = true; + } + + depth = 1; + resDim = D3D11_RESOURCE_DIMENSION_TEXTURE2D; + + // Note there's no way for a legacy Direct3D 9 DDS to express a '1D' texture + } + + assert( BitsPerPixel( format ) != 0 ); + } + + // Bound sizes (for security purposes we don't trust DDS file metadata larger than the D3D 11.x hardware requirements) + if (mipCount > D3D11_REQ_MIP_LEVELS) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + + switch ( resDim ) + { + case D3D11_RESOURCE_DIMENSION_TEXTURE1D: + if ((arraySize > D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION) || + (width > D3D11_REQ_TEXTURE1D_U_DIMENSION) ) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + break; + + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + if ( isCubeMap ) + { + // This is the right bound because we set arraySize to (NumCubes*6) above + if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || + (width > D3D11_REQ_TEXTURECUBE_DIMENSION) || + (height > D3D11_REQ_TEXTURECUBE_DIMENSION)) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + } + else if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || + (width > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION) || + (height > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION)) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + break; + + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + if ((arraySize > 1) || + (width > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || + (height > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || + (depth > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) ) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + break; + + default: + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + + bool autogen = false; + if ( mipCount == 1 && d3dContext != 0 && textureView != 0 ) // Must have context and shader-view to auto generate mipmaps + { + // See if format is supported for auto-gen mipmaps (varies by feature level) + UINT fmtSupport = 0; + hr = d3dDevice->CheckFormatSupport( format, &fmtSupport ); + if ( SUCCEEDED(hr) && ( fmtSupport & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN ) ) + { + // 10level9 feature levels do not support auto-gen mipgen for volume textures + if ( ( resDim != D3D11_RESOURCE_DIMENSION_TEXTURE3D ) + || ( d3dDevice->GetFeatureLevel() >= D3D_FEATURE_LEVEL_10_0 ) ) + { + autogen = true; +#if defined(_XBOX_ONE) && defined(_TITLE) + if ( !d3dDeviceX || !d3dContextX ) + return E_INVALIDARG; +#endif + } + } + } + + if ( autogen ) + { + // Create texture with auto-generated mipmaps + ID3D11Resource* tex = nullptr; + hr = CreateD3DResources( d3dDevice, resDim, width, height, depth, 0, arraySize, + format, usage, + bindFlags | D3D11_BIND_RENDER_TARGET, + cpuAccessFlags, + miscFlags | D3D11_RESOURCE_MISC_GENERATE_MIPS, forceSRGB, + isCubeMap, nullptr, &tex, textureView ); + if ( SUCCEEDED(hr) ) + { + size_t numBytes = 0; + size_t rowBytes = 0; + GetSurfaceInfo( width, height, format, &numBytes, &rowBytes, nullptr ); + + if ( numBytes > bitSize ) + { + (*textureView)->Release(); + *textureView = nullptr; + tex->Release(); + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + D3D11_SHADER_RESOURCE_VIEW_DESC desc; + (*textureView)->GetDesc( &desc ); + + UINT mipLevels = 1; + + switch( desc.ViewDimension ) + { + case D3D_SRV_DIMENSION_TEXTURE1D: mipLevels = desc.Texture1D.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURE1DARRAY: mipLevels = desc.Texture1DArray.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURE2D: mipLevels = desc.Texture2D.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURE2DARRAY: mipLevels = desc.Texture2DArray.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURECUBE: mipLevels = desc.TextureCube.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURECUBEARRAY:mipLevels = desc.TextureCubeArray.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURE3D: mipLevels = desc.Texture3D.MipLevels; break; + default: + (*textureView)->Release(); + *textureView = nullptr; + tex->Release(); + return E_UNEXPECTED; + } + +#if defined(_XBOX_ONE) && defined(_TITLE) + + std::unique_ptr initData( new (std::nothrow) D3D11_SUBRESOURCE_DATA[ arraySize ] ); + if ( !initData ) + { + return E_OUTOFMEMORY; + } + + const uint8_t* pSrcBits = bitData; + const uint8_t* pEndBits = bitData + bitSize; + for( UINT item = 0; item < arraySize; ++item ) + { + if ( (pSrcBits + numBytes) > pEndBits ) + { + (*textureView)->Release(); + *textureView = nullptr; + tex->Release(); + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + initData[item].pSysMem = pSrcBits; + initData[item].SysMemPitch = static_cast(rowBytes); + initData[item].SysMemSlicePitch = static_cast(numBytes); + pSrcBits += numBytes; + } + + ID3D11Resource* pStaging = nullptr; + switch( resDim ) + { + case D3D11_RESOURCE_DIMENSION_TEXTURE1D: + { + ID3D11Texture1D *temp = nullptr; + CD3D11_TEXTURE1D_DESC stagingDesc( format, width, arraySize, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ ); + hr = d3dDevice->CreateTexture1D( &stagingDesc, initData.get(), &temp ); + if ( SUCCEEDED(hr) ) + pStaging = temp; + } + break; + + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + { + ID3D11Texture2D *temp = nullptr; + CD3D11_TEXTURE2D_DESC stagingDesc( format, width, height, arraySize, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ, 1, 0, isCubeMap ? D3D11_RESOURCE_MISC_TEXTURECUBE : 0 ); + hr = d3dDevice->CreateTexture2D( &stagingDesc, initData.get(), &temp ); + if ( SUCCEEDED(hr) ) + pStaging = temp; + } + break; + + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + { + ID3D11Texture3D *temp = nullptr; + CD3D11_TEXTURE3D_DESC stagingDesc( format, width, height, depth, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ ); + hr = d3dDevice->CreateTexture3D( &stagingDesc, initData.get(), &temp ); + if ( SUCCEEDED(hr) ) + pStaging = temp; + } + break; + }; + + if ( SUCCEEDED(hr) ) + { + for( UINT item = 0; item < arraySize; ++item ) + { + UINT res = D3D11CalcSubresource( 0, item, mipLevels ); + d3dContext->CopySubresourceRegion( tex, res, 0, 0, 0, pStaging, item, nullptr ); + } + + UINT64 copyFence = d3dContextX->InsertFence(0); + while( d3dDeviceX->IsFencePending( copyFence ) ) { SwitchToThread(); } + pStaging->Release(); + } +#else + if ( arraySize > 1 ) + { + const uint8_t* pSrcBits = bitData; + const uint8_t* pEndBits = bitData + bitSize; + for( UINT item = 0; item < arraySize; ++item ) + { + if ( (pSrcBits + numBytes) > pEndBits ) + { + (*textureView)->Release(); + *textureView = nullptr; + tex->Release(); + return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); + } + + UINT res = D3D11CalcSubresource( 0, item, mipLevels ); + d3dContext->UpdateSubresource( tex, res, nullptr, pSrcBits, static_cast(rowBytes), static_cast(numBytes) ); + pSrcBits += numBytes; + } + } + else + { + d3dContext->UpdateSubresource( tex, 0, nullptr, bitData, static_cast(rowBytes), static_cast(numBytes) ); + } +#endif + + d3dContext->GenerateMips( *textureView ); + + if ( texture ) + { + *texture = tex; + } + else + { + tex->Release(); + } + } + } + else + { + // Create the texture + std::unique_ptr initData( new (std::nothrow) D3D11_SUBRESOURCE_DATA[ mipCount * arraySize ] ); + if ( !initData ) + { + return E_OUTOFMEMORY; + } + + size_t skipMip = 0; + size_t twidth = 0; + size_t theight = 0; + size_t tdepth = 0; + hr = FillInitData( width, height, depth, mipCount, arraySize, format, maxsize, bitSize, bitData, + twidth, theight, tdepth, skipMip, initData.get() ); + + if ( SUCCEEDED(hr) ) + { + hr = CreateD3DResources( d3dDevice, resDim, twidth, theight, tdepth, mipCount - skipMip, arraySize, + format, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + isCubeMap, initData.get(), texture, textureView ); + + if ( FAILED(hr) && !maxsize && (mipCount > 1) ) + { + // Retry with a maxsize determined by feature level + switch( d3dDevice->GetFeatureLevel() ) + { + case D3D_FEATURE_LEVEL_9_1: + case D3D_FEATURE_LEVEL_9_2: + if ( isCubeMap ) + { + maxsize = 512 /*D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION*/; + } + else + { + maxsize = (resDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D) + ? 256 /*D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/ + : 2048 /*D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; + } + break; + + case D3D_FEATURE_LEVEL_9_3: + maxsize = (resDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D) + ? 256 /*D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/ + : 4096 /*D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; + break; + + default: // D3D_FEATURE_LEVEL_10_0 & D3D_FEATURE_LEVEL_10_1 + maxsize = (resDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D) + ? 2048 /*D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/ + : 8192 /*D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; + break; + } + + hr = FillInitData( width, height, depth, mipCount, arraySize, format, maxsize, bitSize, bitData, + twidth, theight, tdepth, skipMip, initData.get() ); + if ( SUCCEEDED(hr) ) + { + hr = CreateD3DResources( d3dDevice, resDim, twidth, theight, tdepth, mipCount - skipMip, arraySize, + format, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + isCubeMap, initData.get(), texture, textureView ); + } + } + } + } + + return hr; +} + + +//-------------------------------------------------------------------------------------- +static DDS_ALPHA_MODE GetAlphaMode( _In_ const DDS_HEADER* header ) +{ + if ( header->ddspf.flags & DDS_FOURCC ) + { + if ( MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC ) + { + auto d3d10ext = reinterpret_cast( (const char*)header + sizeof(DDS_HEADER) ); + auto mode = static_cast( 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; + } + } + else if ( ( MAKEFOURCC( 'D', 'X', 'T', '2' ) == header->ddspf.fourCC ) + || ( MAKEFOURCC( 'D', 'X', 'T', '4' ) == header->ddspf.fourCC ) ) + { + return DDS_ALPHA_MODE_PREMULTIPLIED; + } + } + + return DDS_ALPHA_MODE_UNKNOWN; +} + + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +HRESULT DirectX::CreateDDSTextureFromMemory( ID3D11Device* d3dDevice, + const uint8_t* ddsData, + size_t ddsDataSize, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize, + DDS_ALPHA_MODE* alphaMode ) +{ + return CreateDDSTextureFromMemoryEx( d3dDevice, ddsData, ddsDataSize, maxsize, + D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, + texture, textureView, alphaMode ); +} + +_Use_decl_annotations_ +#if defined(_XBOX_ONE) && defined(_TITLE) +HRESULT DirectX::CreateDDSTextureFromMemory( ID3D11DeviceX* d3dDevice, + ID3D11DeviceContextX* d3dContext, +#else +HRESULT DirectX::CreateDDSTextureFromMemory( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, +#endif + const uint8_t* ddsData, + size_t ddsDataSize, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize, + DDS_ALPHA_MODE* alphaMode ) +{ + return CreateDDSTextureFromMemoryEx( d3dDevice, d3dContext, ddsData, ddsDataSize, maxsize, + D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, + texture, textureView, alphaMode ); +} + +_Use_decl_annotations_ +HRESULT DirectX::CreateDDSTextureFromMemoryEx( ID3D11Device* d3dDevice, + const uint8_t* ddsData, + size_t ddsDataSize, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + DDS_ALPHA_MODE* alphaMode ) +{ + if ( texture ) + { + *texture = nullptr; + } + if ( textureView ) + { + *textureView = nullptr; + } + if ( alphaMode ) + { + *alphaMode = DDS_ALPHA_MODE_UNKNOWN; + } + + if (!d3dDevice || !ddsData || (!texture && !textureView)) + { + return E_INVALIDARG; + } + + // Validate DDS file in memory + if (ddsDataSize < (sizeof(uint32_t) + sizeof(DDS_HEADER))) + { + return E_FAIL; + } + + uint32_t dwMagicNumber = *( const uint32_t* )( ddsData ); + if (dwMagicNumber != DDS_MAGIC) + { + return E_FAIL; + } + + auto header = reinterpret_cast( ddsData + sizeof( uint32_t ) ); + + // Verify header to validate DDS file + if (header->size != sizeof(DDS_HEADER) || + header->ddspf.size != sizeof(DDS_PIXELFORMAT)) + { + return E_FAIL; + } + + // Check for DX10 extension + bool bDXT10Header = false; + if ((header->ddspf.flags & DDS_FOURCC) && + (MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC) ) + { + // Must be long enough for both headers and magic value + if (ddsDataSize < (sizeof(DDS_HEADER) + sizeof(uint32_t) + sizeof(DDS_HEADER_DXT10))) + { + return E_FAIL; + } + + bDXT10Header = true; + } + + ptrdiff_t offset = sizeof( uint32_t ) + + sizeof( DDS_HEADER ) + + (bDXT10Header ? sizeof( DDS_HEADER_DXT10 ) : 0); + + HRESULT hr = CreateTextureFromDDS( d3dDevice, nullptr, +#if defined(_XBOX_ONE) && defined(_TITLE) + nullptr, nullptr, +#endif + header, ddsData + offset, ddsDataSize - offset, maxsize, + usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + texture, textureView ); + if ( SUCCEEDED(hr) ) + { + if (texture != 0 && *texture != 0) + { + SetDebugObjectName(*texture, "DDSTextureLoader"); + } + + if (textureView != 0 && *textureView != 0) + { + SetDebugObjectName(*textureView, "DDSTextureLoader"); + } + + if ( alphaMode ) + *alphaMode = GetAlphaMode( header ); + } + + return hr; +} + +_Use_decl_annotations_ +#if defined(_XBOX_ONE) && defined(_TITLE) +HRESULT DirectX::CreateDDSTextureFromMemoryEx( ID3D11DeviceX* d3dDevice, + ID3D11DeviceContextX* d3dContext, +#else +HRESULT DirectX::CreateDDSTextureFromMemoryEx( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, +#endif + const uint8_t* ddsData, + size_t ddsDataSize, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + DDS_ALPHA_MODE* alphaMode ) +{ + if ( texture ) + { + *texture = nullptr; + } + if ( textureView ) + { + *textureView = nullptr; + } + if ( alphaMode ) + { + *alphaMode = DDS_ALPHA_MODE_UNKNOWN; + } + + if (!d3dDevice || !ddsData || (!texture && !textureView)) + { + return E_INVALIDARG; + } + + // Validate DDS file in memory + if (ddsDataSize < (sizeof(uint32_t) + sizeof(DDS_HEADER))) + { + return E_FAIL; + } + + uint32_t dwMagicNumber = *( const uint32_t* )( ddsData ); + if (dwMagicNumber != DDS_MAGIC) + { + return E_FAIL; + } + + auto header = reinterpret_cast( ddsData + sizeof( uint32_t ) ); + + // Verify header to validate DDS file + if (header->size != sizeof(DDS_HEADER) || + header->ddspf.size != sizeof(DDS_PIXELFORMAT)) + { + return E_FAIL; + } + + // Check for DX10 extension + bool bDXT10Header = false; + if ((header->ddspf.flags & DDS_FOURCC) && + (MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC) ) + { + // Must be long enough for both headers and magic value + if (ddsDataSize < (sizeof(DDS_HEADER) + sizeof(uint32_t) + sizeof(DDS_HEADER_DXT10))) + { + return E_FAIL; + } + + bDXT10Header = true; + } + + ptrdiff_t offset = sizeof( uint32_t ) + + sizeof( DDS_HEADER ) + + (bDXT10Header ? sizeof( DDS_HEADER_DXT10 ) : 0); + + HRESULT hr = CreateTextureFromDDS( d3dDevice, d3dContext, +#if defined(_XBOX_ONE) && defined(_TITLE) + d3dDevice, d3dContext, +#endif + header, ddsData + offset, ddsDataSize - offset, maxsize, + usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + texture, textureView ); + if ( SUCCEEDED(hr) ) + { + if (texture != 0 && *texture != 0) + { + SetDebugObjectName(*texture, "DDSTextureLoader"); + } + + if (textureView != 0 && *textureView != 0) + { + SetDebugObjectName(*textureView, "DDSTextureLoader"); + } + + if ( alphaMode ) + *alphaMode = GetAlphaMode( header ); + } + + return hr; +} + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +HRESULT DirectX::CreateDDSTextureFromFile( ID3D11Device* d3dDevice, + const wchar_t* fileName, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize, + DDS_ALPHA_MODE* alphaMode ) +{ + return CreateDDSTextureFromFileEx( d3dDevice, fileName, maxsize, + D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, + texture, textureView, alphaMode ); +} + +_Use_decl_annotations_ +#if defined(_XBOX_ONE) && defined(_TITLE) +HRESULT DirectX::CreateDDSTextureFromFile( ID3D11DeviceX* d3dDevice, + ID3D11DeviceContextX* d3dContext, +#else +HRESULT DirectX::CreateDDSTextureFromFile( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, +#endif + const wchar_t* fileName, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize, + DDS_ALPHA_MODE* alphaMode ) +{ + return CreateDDSTextureFromFileEx( d3dDevice, d3dContext, fileName, maxsize, + D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, + texture, textureView, alphaMode ); +} + +_Use_decl_annotations_ +HRESULT DirectX::CreateDDSTextureFromFileEx( ID3D11Device* d3dDevice, + const wchar_t* fileName, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + DDS_ALPHA_MODE* alphaMode ) +{ + if ( texture ) + { + *texture = nullptr; + } + if ( textureView ) + { + *textureView = nullptr; + } + if ( alphaMode ) + { + *alphaMode = DDS_ALPHA_MODE_UNKNOWN; + } + + if (!d3dDevice || !fileName || (!texture && !textureView)) + { + return E_INVALIDARG; + } + + DDS_HEADER* header = nullptr; + uint8_t* bitData = nullptr; + size_t bitSize = 0; + + std::unique_ptr ddsData; + HRESULT hr = LoadTextureDataFromFile( fileName, + ddsData, + &header, + &bitData, + &bitSize + ); + if (FAILED(hr)) + { + return hr; + } + + hr = CreateTextureFromDDS( d3dDevice, nullptr, +#if defined(_XBOX_ONE) && defined(_TITLE) + nullptr, nullptr, +#endif + header, bitData, bitSize, maxsize, + usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + texture, textureView ); + + if ( SUCCEEDED(hr) ) + { +#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) + #if defined(_XBOX_ONE) && defined(_TITLE) + if (texture != 0 && *texture != 0) + { + (*texture)->SetName( fileName ); + } + if (textureView != 0 && *textureView != 0 ) + { + (*textureView)->SetName( fileName ); + } + #else + if (texture != 0 || textureView != 0) + { + CHAR strFileA[MAX_PATH]; + int result = WideCharToMultiByte( CP_ACP, + WC_NO_BEST_FIT_CHARS, + fileName, + -1, + strFileA, + MAX_PATH, + nullptr, + FALSE + ); + if ( result > 0 ) + { + const CHAR* pstrName = strrchr( strFileA, '\\' ); + if (!pstrName) + { + pstrName = strFileA; + } + else + { + pstrName++; + } + + if (texture != 0 && *texture != 0) + { + (*texture)->SetPrivateData( WKPDID_D3DDebugObjectName, + static_cast( strnlen_s(pstrName, MAX_PATH) ), + pstrName + ); + } + + if (textureView != 0 && *textureView != 0 ) + { + (*textureView)->SetPrivateData( WKPDID_D3DDebugObjectName, + static_cast( strnlen_s(pstrName, MAX_PATH) ), + pstrName + ); + } + } + } + #endif +#endif + + if ( alphaMode ) + *alphaMode = GetAlphaMode( header ); + } + + return hr; +} + +_Use_decl_annotations_ +#if defined(_XBOX_ONE) && defined(_TITLE) +HRESULT DirectX::CreateDDSTextureFromFileEx( ID3D11DeviceX* d3dDevice, + ID3D11DeviceContextX* d3dContext, +#else +HRESULT DirectX::CreateDDSTextureFromFileEx( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, +#endif + const wchar_t* fileName, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + DDS_ALPHA_MODE* alphaMode ) +{ + if ( texture ) + { + *texture = nullptr; + } + if ( textureView ) + { + *textureView = nullptr; + } + if ( alphaMode ) + { + *alphaMode = DDS_ALPHA_MODE_UNKNOWN; + } + + if (!d3dDevice || !fileName || (!texture && !textureView)) + { + return E_INVALIDARG; + } + + DDS_HEADER* header = nullptr; + uint8_t* bitData = nullptr; + size_t bitSize = 0; + + std::unique_ptr ddsData; + HRESULT hr = LoadTextureDataFromFile( fileName, + ddsData, + &header, + &bitData, + &bitSize + ); + if (FAILED(hr)) + { + return hr; + } + + hr = CreateTextureFromDDS( d3dDevice, d3dContext, +#if defined(_XBOX_ONE) && defined(_TITLE) + d3dDevice, d3dContext, +#endif + header, bitData, bitSize, maxsize, + usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + texture, textureView ); + + if ( SUCCEEDED(hr) ) + { +#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) + #if defined(_XBOX_ONE) && defined(_TITLE) + if (texture != 0 && *texture != 0) + { + (*texture)->SetName( fileName ); + } + if (textureView != 0 && *textureView != 0 ) + { + (*textureView)->SetName( fileName ); + } + #else + if (texture != 0 || textureView != 0) + { + CHAR strFileA[MAX_PATH]; + int result = WideCharToMultiByte( CP_ACP, + WC_NO_BEST_FIT_CHARS, + fileName, + -1, + strFileA, + MAX_PATH, + nullptr, + FALSE + ); + if ( result > 0 ) + { + const CHAR* pstrName = strrchr( strFileA, '\\' ); + if (!pstrName) + { + pstrName = strFileA; + } + else + { + pstrName++; + } + + if (texture != 0 && *texture != 0) + { + (*texture)->SetPrivateData( WKPDID_D3DDebugObjectName, + static_cast( strnlen_s(pstrName, MAX_PATH) ), + pstrName + ); + } + + if (textureView != 0 && *textureView != 0 ) + { + (*textureView)->SetPrivateData( WKPDID_D3DDebugObjectName, + static_cast( strnlen_s(pstrName, MAX_PATH) ), + pstrName + ); + } + } + } + #endif +#endif + + if ( alphaMode ) + *alphaMode = GetAlphaMode( header ); + } + + return hr; +} diff --git a/Kits/DirectXTK/Src/DGSLEffect.cpp b/Kits/DirectXTK/Src/DGSLEffect.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a82d7883072160f64e451809e1d7fc8cd6a2cfc8 --- /dev/null +++ b/Kits/DirectXTK/Src/DGSLEffect.cpp @@ -0,0 +1,929 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "EffectCommon.h" +#include "DemandCreate.h" + +// +// Based on the Visual Studio 3D Starter Kit +// +// http://aka.ms/vs3dkit +// + +namespace DirectX +{ + +namespace EffectDirtyFlags +{ + const int ConstantBufferMaterial = 0x10000; + const int ConstantBufferLight = 0x20000; + const int ConstantBufferObject = 0x40000; + const int ConstantBufferMisc = 0x80000; + const int ConstantBufferBones = 0x100000; +} + +} + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + +// Constant buffer layout. Must match the shader! +#pragma pack(push,1) + +// Slot 0 +struct MaterialConstants +{ + XMVECTOR Ambient; + XMVECTOR Diffuse; + XMVECTOR Specular; + XMVECTOR Emissive; + float SpecularPower; + float Padding0; + float Padding1; + float Padding2; +}; + +// Slot 1 +struct LightConstants +{ + XMVECTOR Ambient; + XMVECTOR LightColor[DGSLEffect::MaxDirectionalLights]; + XMVECTOR LightAttenuation[DGSLEffect::MaxDirectionalLights]; + XMVECTOR LightDirection[DGSLEffect::MaxDirectionalLights]; + XMVECTOR LightSpecularIntensity[DGSLEffect::MaxDirectionalLights]; + UINT IsPointLight[DGSLEffect::MaxDirectionalLights]; + UINT ActiveLights; + float Padding0; + float Padding1; + float Padding2; +}; + +// Note - DGSL does not appear to make use of LightAttenuation or IsPointLight. Not sure if it uses ActiveLights either. + +// Slot 2 +struct ObjectConstants +{ + XMMATRIX LocalToWorld4x4; + XMMATRIX LocalToProjected4x4; + XMMATRIX WorldToLocal4x4; + XMMATRIX WorldToView4x4; + XMMATRIX UvTransform4x4; + XMVECTOR EyePosition; +}; + +// Slot 3 +struct MiscConstants +{ + float ViewportWidth; + float ViewportHeight; + float Time; + float Padding1; +}; + +// Slot 4 +struct BoneConstants +{ + XMVECTOR Bones[DGSLEffect::MaxBones][3]; +}; + +#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" ); + +__declspec(align(16)) struct DGSLEffectConstants +{ + MaterialConstants material; + LightConstants light; + ObjectConstants object; + MiscConstants misc; + BoneConstants bones; +}; + +struct DGSLEffectTraits +{ + static const int VertexShaderCount = 8; + static const int PixelShaderCount = 12; + + static const ShaderBytecode VertexShaderBytecode[VertexShaderCount]; + static const ShaderBytecode PixelShaderBytecode[PixelShaderCount]; +}; + + +// Include the precompiled shader code. +namespace +{ +#if defined(_XBOX_ONE) && defined(_TITLE) + // VS + #include "Shaders/Compiled/XboxOneDGSLEffect_main.inc" + #include "Shaders/Compiled/XboxOneDGSLEffect_mainVc.inc" + #include "Shaders/Compiled/XboxOneDGSLEffect_main1Bones.inc" + #include "Shaders/Compiled/XboxOneDGSLEffect_main1BonesVc.inc" + #include "Shaders/Compiled/XboxOneDGSLEffect_main2Bones.inc" + #include "Shaders/Compiled/XboxOneDGSLEffect_main2BonesVc.inc" + #include "Shaders/Compiled/XboxOneDGSLEffect_main4Bones.inc" + #include "Shaders/Compiled/XboxOneDGSLEffect_main4BonesVc.inc" + + // PS + #include "Shaders/Compiled/XboxOneDGSLUnlit_main.inc" + #include "Shaders/Compiled/XboxOneDGSLLambert_main.inc" + #include "Shaders/Compiled/XboxOneDGSLPhong_main.inc" + + #include "Shaders/Compiled/XboxOneDGSLUnlit_mainTk.inc" + #include "Shaders/Compiled/XboxOneDGSLLambert_mainTk.inc" + #include "Shaders/Compiled/XboxOneDGSLPhong_mainTk.inc" + + #include "Shaders/Compiled/XboxOneDGSLUnlit_mainTx.inc" + #include "Shaders/Compiled/XboxOneDGSLLambert_mainTx.inc" + #include "Shaders/Compiled/XboxOneDGSLPhong_mainTx.inc" + + #include "Shaders/Compiled/XboxOneDGSLUnlit_mainTxTk.inc" + #include "Shaders/Compiled/XboxOneDGSLLambert_mainTxTk.inc" + #include "Shaders/Compiled/XboxOneDGSLPhong_mainTxTk.inc" +#else + // VS + #include "Shaders/Compiled/DGSLEffect_main.inc" + #include "Shaders/Compiled/DGSLEffect_mainVc.inc" + #include "Shaders/Compiled/DGSLEffect_main1Bones.inc" + #include "Shaders/Compiled/DGSLEffect_main1BonesVc.inc" + #include "Shaders/Compiled/DGSLEffect_main2Bones.inc" + #include "Shaders/Compiled/DGSLEffect_main2BonesVc.inc" + #include "Shaders/Compiled/DGSLEffect_main4Bones.inc" + #include "Shaders/Compiled/DGSLEffect_main4BonesVc.inc" + + // PS + #include "Shaders/Compiled/DGSLUnlit_main.inc" + #include "Shaders/Compiled/DGSLLambert_main.inc" + #include "Shaders/Compiled/DGSLPhong_main.inc" + + #include "Shaders/Compiled/DGSLUnlit_mainTk.inc" + #include "Shaders/Compiled/DGSLLambert_mainTk.inc" + #include "Shaders/Compiled/DGSLPhong_mainTk.inc" + + #include "Shaders/Compiled/DGSLUnlit_mainTx.inc" + #include "Shaders/Compiled/DGSLLambert_mainTx.inc" + #include "Shaders/Compiled/DGSLPhong_mainTx.inc" + + #include "Shaders/Compiled/DGSLUnlit_mainTxTk.inc" + #include "Shaders/Compiled/DGSLLambert_mainTxTk.inc" + #include "Shaders/Compiled/DGSLPhong_mainTxTk.inc" +#endif +} + + +const ShaderBytecode DGSLEffectTraits::VertexShaderBytecode[] = +{ + { DGSLEffect_main, sizeof(DGSLEffect_main) }, + { DGSLEffect_mainVc, sizeof(DGSLEffect_mainVc) }, + { DGSLEffect_main1Bones, sizeof(DGSLEffect_main1Bones) }, + { DGSLEffect_main1BonesVc, sizeof(DGSLEffect_main1BonesVc) }, + { DGSLEffect_main2Bones, sizeof(DGSLEffect_main2Bones) }, + { DGSLEffect_main2BonesVc, sizeof(DGSLEffect_main2BonesVc) }, + { DGSLEffect_main4Bones, sizeof(DGSLEffect_main4Bones) }, + { DGSLEffect_main4BonesVc, sizeof(DGSLEffect_main4BonesVc) }, +}; + + +const ShaderBytecode DGSLEffectTraits::PixelShaderBytecode[] = +{ + { DGSLUnlit_main, sizeof(DGSLUnlit_main) }, // UNLIT (no texture) + { DGSLLambert_main, sizeof(DGSLLambert_main) }, // LAMBERT (no texture) + { DGSLPhong_main, sizeof(DGSLPhong_main) }, // PHONG (no texture) + + { DGSLUnlit_mainTx, sizeof(DGSLUnlit_mainTx) }, // UNLIT (textured) + { DGSLLambert_mainTx, sizeof(DGSLLambert_mainTx) }, // LAMBERT (textured) + { DGSLPhong_mainTx, sizeof(DGSLPhong_mainTx) }, // PHONG (textured) + + { DGSLUnlit_mainTk, sizeof(DGSLUnlit_mainTk) }, // UNLIT (no texture, discard) + { DGSLLambert_mainTk, sizeof(DGSLLambert_mainTk) }, // LAMBERT (no texture, discard) + { DGSLPhong_mainTk, sizeof(DGSLPhong_mainTk) }, // PHONG (no texture, discard) + + { DGSLUnlit_mainTxTk, sizeof(DGSLUnlit_mainTxTk) }, // UNLIT (textured, discard) + { DGSLLambert_mainTxTk, sizeof(DGSLLambert_mainTxTk) }, // LAMBERT (textured, discard) + { DGSLPhong_mainTxTk, sizeof(DGSLPhong_mainTxTk) }, // PHONG (textured, discard) +}; + + +class DGSLEffect::Impl : public AlignedNew +{ +public: + 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 ), + mPixelShader( pixelShader ), + mCBMaterial( device ), + mCBLight( device ), + mCBObject( device ), + mCBMisc( device ), + mDeviceResources( deviceResourcesPool.DemandCreate(device) ) + { + 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) ); + + XMMATRIX id = XMMatrixIdentity(); + world = id; + view = id; + projection = id; + constants.material.Specular = g_XMOne; + constants.material.SpecularPower = 16; + constants.object.UvTransform4x4 = id; + + static_assert( MaxDirectionalLights == 4, "Mismatch with DGSL pipline" ); + for( int i = 0; i < MaxDirectionalLights; ++i ) + { + lightEnabled[i] = (i == 0); + lightDiffuseColor[i] = g_XMZero; + lightSpecularColor[i] = g_XMOne; + + constants.light.LightDirection[i] = g_XMNegIdentityR1; + constants.light.LightColor[i] = lightEnabled[i] ? lightDiffuseColor[i] : g_XMZero; + constants.light.LightSpecularIntensity[i] = lightEnabled[i] ? lightSpecularColor[i] : g_XMZero; + } + + if ( enableSkinning ) + { + mCBBone.Create( device ); + + 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; + } + } + } + + // Methods + void Apply( _In_ ID3D11DeviceContext* deviceContext ); + void GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength); + + // Fields + DGSLEffectConstants constants; + + XMMATRIX world; + XMMATRIX view; + XMMATRIX projection; + + bool lightEnabled[MaxDirectionalLights]; + XMVECTOR lightDiffuseColor[MaxDirectionalLights]; + XMVECTOR lightSpecularColor[MaxDirectionalLights]; + + ComPtr textures[MaxTextures]; + + int dirtyFlags; + + bool vertexColorEnabled; + bool textureEnabled; + bool specularEnabled; + bool alphaDiscardEnabled; + int weightsPerVertex; + +private: + ConstantBuffer mCBMaterial; + ConstantBuffer mCBLight; + ConstantBuffer mCBObject; + ConstantBuffer mCBMisc; + ConstantBuffer mCBBone; + ComPtr mPixelShader; + + int GetCurrentVSPermutation() const; + int GetCurrentPSPermutation() const; + + // Only one of these helpers is allocated per D3D device, even if there are multiple effect instances. + class DeviceResources : protected EffectDeviceResources + { + public: + DeviceResources(_In_ ID3D11Device* device) : EffectDeviceResources(device) {} + + // Gets or lazily creates the vertex shader. + ID3D11VertexShader* GetVertexShader( int permutation ) + { + assert( permutation < DGSLEffectTraits::VertexShaderCount ); + + return DemandCreateVertexShader(mVertexShaders[permutation], DGSLEffectTraits::VertexShaderBytecode[permutation]); + } + + // Gets or lazily creates the specified pixel shader permutation. + ID3D11PixelShader* GetPixelShader( int permutation ) + { + assert( permutation < DGSLEffectTraits::PixelShaderCount ); + + return DemandCreatePixelShader(mPixelShaders[permutation], DGSLEffectTraits::PixelShaderBytecode[permutation]); + } + + // Gets or lazily creates the default texture + ID3D11ShaderResourceView* GetDefaultTexture() { return EffectDeviceResources::GetDefaultTexture(); } + + + private: + ComPtr mVertexShaders[DGSLEffectTraits::VertexShaderCount]; + ComPtr mPixelShaders[DGSLEffectTraits::PixelShaderCount]; + ComPtr mDefaultTexture; + }; + + // Per-device resources. + std::shared_ptr mDeviceResources; + + static SharedResourcePool deviceResourcesPool; +}; + + +SharedResourcePool DGSLEffect::Impl::deviceResourcesPool; + + +void DGSLEffect::Impl::Apply( _In_ ID3D11DeviceContext* deviceContext ) +{ + auto vertexShader = mDeviceResources->GetVertexShader( GetCurrentVSPermutation() ); + auto pixelShader = mPixelShader.Get(); + if( !pixelShader ) + { + pixelShader = mDeviceResources->GetPixelShader( GetCurrentPSPermutation() ); + } + + 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 ); + + XMMATRIX worldView = XMMatrixMultiply( world, view ); + + constants.object.LocalToProjected4x4 = XMMatrixTranspose( XMMatrixMultiply( worldView, projection ) ); + + dirtyFlags &= ~EffectDirtyFlags::WorldViewProj; + dirtyFlags |= EffectDirtyFlags::ConstantBufferObject; + } + + if (dirtyFlags & EffectDirtyFlags::WorldInverseTranspose) + { + XMMATRIX worldInverse = XMMatrixInverse( nullptr, world ); + + constants.object.WorldToLocal4x4 = XMMatrixTranspose( worldInverse ); + + dirtyFlags &= ~EffectDirtyFlags::WorldInverseTranspose; + dirtyFlags |= EffectDirtyFlags::ConstantBufferObject; + } + + if (dirtyFlags & EffectDirtyFlags::EyePosition) + { + XMMATRIX viewInverse = XMMatrixInverse( nullptr, view ); + + constants.object.EyePosition = viewInverse.r[3]; + + dirtyFlags &= ~EffectDirtyFlags::EyePosition; + dirtyFlags |= EffectDirtyFlags::ConstantBufferObject; + } + +#if defined(_XBOX_ONE) && defined(_TITLE) + void* grfxMemoryMaterial; + mCBMaterial.SetData(deviceContext, constants.material, &grfxMemoryMaterial); + + void* grfxMemoryLight; + mCBLight.SetData(deviceContext, constants.light, &grfxMemoryLight); + + void* grfxMemoryObject; + mCBObject.SetData(deviceContext, constants.object, &grfxMemoryObject); + + void *grfxMemoryMisc; + mCBMisc.SetData(deviceContext, constants.misc, &grfxMemoryMisc); + + ComPtr deviceContextX; + ThrowIfFailed(deviceContext->QueryInterface(IID_GRAPHICS_PPV_ARGS(deviceContextX.GetAddressOf()))); + + auto buffer = mCBMaterial.GetBuffer(); + deviceContextX->VSSetPlacementConstantBuffer( 0, buffer, grfxMemoryMaterial ); + deviceContextX->PSSetPlacementConstantBuffer( 0, buffer, grfxMemoryMaterial ); + + buffer = mCBLight.GetBuffer(); + deviceContextX->VSSetPlacementConstantBuffer( 1, buffer, grfxMemoryMaterial ); + deviceContextX->PSSetPlacementConstantBuffer( 1, buffer, grfxMemoryMaterial ); + + buffer = mCBObject.GetBuffer(); + deviceContextX->VSSetPlacementConstantBuffer( 2, buffer, grfxMemoryObject ); + deviceContextX->PSSetPlacementConstantBuffer( 2, buffer, grfxMemoryObject ); + + buffer = mCBMisc.GetBuffer(); + deviceContextX->VSSetPlacementConstantBuffer( 3, buffer, grfxMemoryMisc ); + deviceContextX->PSSetPlacementConstantBuffer( 3, buffer, grfxMemoryMisc ); + + if ( weightsPerVertex > 0 ) + { + void* grfxMemoryBone; + mCBBone.SetData(deviceContext, constants.bones, &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 (dirtyFlags & EffectDirtyFlags::ConstantBufferBones) + { + mCBBone.SetData(deviceContext, constants.bones); + + dirtyFlags &= ~EffectDirtyFlags::ConstantBufferBones; + } + + ID3D11Buffer* buffers[5] = { mCBMaterial.GetBuffer(), mCBLight.GetBuffer(), mCBObject.GetBuffer(), + mCBMisc.GetBuffer(), mCBBone.GetBuffer() }; + + 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 ); + } +#endif + + // Set the textures + 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 ); + } + else + { + ID3D11ShaderResourceView* txt[MaxTextures] = { mDeviceResources->GetDefaultTexture(), 0 }; + deviceContext->PSSetShaderResources( 0, MaxTextures, txt ); + } +} + + +void DGSLEffect::Impl::GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) +{ + int permutation = GetCurrentVSPermutation(); + + assert( permutation < DGSLEffectTraits::VertexShaderCount ); + _Analysis_assume_( permutation < DGSLEffectTraits::VertexShaderCount ); + + auto shader = DGSLEffectTraits::VertexShaderBytecode[permutation]; + *pShaderByteCode = shader.code; + *pByteCodeLength = shader.length; +} + + +int DGSLEffect::Impl::GetCurrentVSPermutation() const +{ + int permutation = (vertexColorEnabled) ? 1 : 0; + + if( weightsPerVertex > 0 ) + { + // Evaluate 1, 2, or 4 weights per vertex? + permutation += 2; + + if (weightsPerVertex == 2) + { + permutation += 2; + } + else if (weightsPerVertex == 4) + { + permutation += 4; + } + } + + return permutation; +} + + +int DGSLEffect::Impl::GetCurrentPSPermutation() const +{ + int permutation = 0; + + if ( constants.light.ActiveLights > 0 ) + { + permutation = ( specularEnabled ) ? 2 : 1; + } + + if ( textureEnabled ) + permutation += 3; + + if ( alphaDiscardEnabled ) + permutation += 6; + + return permutation; +} + + + +//-------------------------------------------------------------------------------------- +// DGSLEffect +//-------------------------------------------------------------------------------------- + +DGSLEffect::DGSLEffect(_In_ ID3D11Device* device, _In_opt_ ID3D11PixelShader* pixelShader, _In_ bool enableSkinning) + : pImpl(new Impl(device, pixelShader, enableSkinning)) +{ +} + + +DGSLEffect::DGSLEffect(DGSLEffect&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +DGSLEffect& DGSLEffect::operator= (DGSLEffect&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +DGSLEffect::~DGSLEffect() +{ +} + + +// IEffect methods +void DGSLEffect::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + pImpl->Apply(deviceContext); +} + + +void DGSLEffect::GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) +{ + pImpl->GetVertexShaderBytecode( pShaderByteCode, pByteCodeLength ); +} + + +// Camera settings +void XM_CALLCONV DGSLEffect::SetWorld(FXMMATRIX value) +{ + pImpl->world = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::WorldInverseTranspose; +} + + +void XM_CALLCONV DGSLEffect::SetView(FXMMATRIX value) +{ + pImpl->view = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::EyePosition; +} + + +void XM_CALLCONV DGSLEffect::SetProjection(FXMMATRIX value) +{ + pImpl->projection = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj; +} + + +// Material settings +void XM_CALLCONV DGSLEffect::SetAmbientColor(FXMVECTOR value) +{ + pImpl->constants.material.Ambient = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferMaterial; +} + + +void XM_CALLCONV DGSLEffect::SetDiffuseColor(FXMVECTOR value) +{ + pImpl->constants.material.Diffuse = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferMaterial; +} + + +void XM_CALLCONV DGSLEffect::SetEmissiveColor(FXMVECTOR value) +{ + pImpl->constants.material.Emissive = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferMaterial; +} + + +void XM_CALLCONV DGSLEffect::SetSpecularColor(FXMVECTOR value) +{ + pImpl->specularEnabled = true; + pImpl->constants.material.Specular = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferMaterial; +} + + +void DGSLEffect::SetSpecularPower(float value) +{ + pImpl->specularEnabled = true; + pImpl->constants.material.SpecularPower = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferMaterial; +} + + +void DGSLEffect::DisableSpecular() +{ + pImpl->specularEnabled = false; + pImpl->constants.material.Specular = g_XMZero; + pImpl->constants.material.SpecularPower = 1.f; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferMaterial; +} + + +void DGSLEffect::SetAlpha(float value) +{ + // Set w to new value, but preserve existing xyz (diffuse color). + pImpl->constants.material.Diffuse = XMVectorSetW(pImpl->constants.material.Diffuse, value); + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferMaterial; +} + + +// Additional settings. +void XM_CALLCONV DGSLEffect::SetUVTransform(FXMMATRIX value) +{ + pImpl->constants.object.UvTransform4x4 = XMMatrixTranspose( value ); + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferObject; +} + + +void DGSLEffect::SetViewport( float width, float height ) +{ + pImpl->constants.misc.ViewportWidth = width; + pImpl->constants.misc.ViewportHeight = height; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferMisc; +} + + +void DGSLEffect::SetTime( float time ) +{ + pImpl->constants.misc.Time = time; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferMisc; +} + + +void DGSLEffect::SetAlphaDiscardEnable(bool value) +{ + pImpl->alphaDiscardEnabled = value; +} + + +// Light settings +void DGSLEffect::SetLightingEnabled(bool value) +{ + if (value) + { + if ( !pImpl->constants.light.ActiveLights ) + pImpl->constants.light.ActiveLights = 1; + } + else + { + pImpl->constants.light.ActiveLights = 0; + } + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferLight; +} + + +void DGSLEffect::SetPerPixelLighting(bool) +{ + // Unsupported interface method. +} + + +void XM_CALLCONV DGSLEffect::SetAmbientLightColor(FXMVECTOR value) +{ + pImpl->constants.light.Ambient = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferLight; +} + + +void DGSLEffect::SetLightEnabled(int whichLight, bool value) +{ + if ( whichLight < 0 || whichLight >= MaxDirectionalLights ) + throw std::out_of_range("whichLight parameter out of range"); + + if ( pImpl->lightEnabled[whichLight] == value ) + return; + + pImpl->lightEnabled[whichLight] = value; + + if ( value ) + { + if ( whichLight >= (int)pImpl->constants.light.ActiveLights ) + pImpl->constants.light.ActiveLights = static_cast( whichLight + 1 ); + + pImpl->constants.light.LightColor[whichLight] = pImpl->lightDiffuseColor[whichLight]; + pImpl->constants.light.LightSpecularIntensity[whichLight] = pImpl->lightSpecularColor[whichLight]; + } + else + { + pImpl->constants.light.LightColor[whichLight] = + pImpl->constants.light.LightSpecularIntensity[whichLight] = g_XMZero; + } + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferLight; +} + + +void XM_CALLCONV DGSLEffect::SetLightDirection(int whichLight, FXMVECTOR value) +{ + 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->dirtyFlags |= EffectDirtyFlags::ConstantBufferLight; +} + + +void XM_CALLCONV DGSLEffect::SetLightDiffuseColor(int whichLight, FXMVECTOR value) +{ + if ( whichLight < 0 || whichLight >= MaxDirectionalLights ) + throw std::out_of_range("whichLight parameter out of range"); + + pImpl->lightDiffuseColor[whichLight] = value; + + if ( pImpl->lightEnabled[whichLight] ) + { + pImpl->constants.light.LightColor[whichLight] = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferLight; + } +} + + +void XM_CALLCONV DGSLEffect::SetLightSpecularColor(int whichLight, FXMVECTOR value) +{ + if ( whichLight < 0 || whichLight >= MaxDirectionalLights ) + throw std::out_of_range("whichLight parameter out of range"); + + pImpl->lightSpecularColor[whichLight] = value; + + if ( pImpl->lightEnabled[whichLight] ) + { + pImpl->constants.light.LightSpecularIntensity[whichLight] = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferLight; + } +} + + +void DGSLEffect::EnableDefaultLighting() +{ + EffectLights::EnableDefaultLighting(this); +} + + +// Vertex color setting. +void DGSLEffect::SetVertexColorEnabled(bool value) +{ + pImpl->vertexColorEnabled = value; +} + + +// Texture settings +void DGSLEffect::SetTextureEnabled(bool value) +{ + pImpl->textureEnabled = value; +} + + +void DGSLEffect::SetTexture(_In_opt_ ID3D11ShaderResourceView* value) +{ + pImpl->textures[0] = value; +} + +void DGSLEffect::SetTexture2(_In_opt_ ID3D11ShaderResourceView* value) +{ + pImpl->textures[1] = value; +} + +void DGSLEffect::SetTexture(int whichTexture, _In_opt_ ID3D11ShaderResourceView* value) +{ + if ( whichTexture < 0 || whichTexture >= MaxTextures ) + throw std::out_of_range("whichTexture parameter out of range"); + + pImpl->textures[ whichTexture ] = value; +} + + +// Animation setting +void DGSLEffect::SetWeightsPerVertex(int value) +{ + if ( !pImpl->weightsPerVertex ) + { + // Safe to ignore since it's only an optimization hint + return; + } + + if ((value != 1) && + (value != 2) && + (value != 4)) + { + throw std::out_of_range("WeightsPerVertex must be 1, 2, or 4"); + } + + pImpl->weightsPerVertex = value; +} + + +void DGSLEffect::SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) +{ + if ( !pImpl->weightsPerVertex ) + throw std::exception("Skinning not enabled for this effect"); + + if (count > MaxBones) + throw std::out_of_range("count parameter out of range"); + + auto boneConstant = pImpl->constants.bones.Bones; + + for (size_t i = 0; i < count; i++) + { + XMMATRIX boneMatrix = XMMatrixTranspose(value[i]); + + boneConstant[i][0] = boneMatrix.r[0]; + boneConstant[i][1] = boneMatrix.r[1]; + boneConstant[i][2] = boneMatrix.r[2]; + } + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferBones; +} + + +void DGSLEffect::ResetBoneTransforms() +{ + if ( !pImpl->weightsPerVertex ) + { + // Safe to ignore since it just returns things back to default settings + return; + } + + auto boneConstant = pImpl->constants.bones.Bones; + + XMMATRIX id = XMMatrixIdentity(); + + for(size_t i = 0; i < MaxBones; ++i) + { + boneConstant[i][0] = g_XMIdentityR0; + boneConstant[i][1] = g_XMIdentityR1; + boneConstant[i][2] = g_XMIdentityR2; + } + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferBones; +} diff --git a/Kits/DirectXTK/Src/DGSLEffectFactory.cpp b/Kits/DirectXTK/Src/DGSLEffectFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..99957c76b40c2c1f5fbcbcba6bfbdaab0f22f1b1 --- /dev/null +++ b/Kits/DirectXTK/Src/DGSLEffectFactory.cpp @@ -0,0 +1,546 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Effects.h" +#include "DemandCreate.h" +#include "SharedResourcePool.h" + +#include "DDSTextureLoader.h" + +#include + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) +#include "WICTextureLoader.h" +#endif + +#include "BinaryReader.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +// Internal DGSLEffectFactory implementation class. Only one of these helpers is allocated +// per D3D device, even if there are multiple public facing DGSLEffectFactory instances. +class DGSLEffectFactory::Impl +{ +public: + Impl(_In_ ID3D11Device* device) + : device(device), mSharing(true) + { *mPath = 0; } + + std::shared_ptr CreateEffect( _In_ DGSLEffectFactory* factory, _In_ const IEffectFactory::EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ); + std::shared_ptr CreateDGSLEffect( _In_ DGSLEffectFactory* factory, _In_ const DGSLEffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ); + void CreateTexture( _In_z_ const WCHAR* texture, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ); + void CreatePixelShader( _In_z_ const WCHAR* shader, _Outptr_ ID3D11PixelShader** pixelShader ); + + void ReleaseCache(); + void SetSharing( bool enabled ) { mSharing = enabled; } + + static SharedResourcePool instancePool; + + WCHAR mPath[MAX_PATH]; + +private: + ComPtr device; + + typedef std::map< std::wstring, std::shared_ptr > EffectCache; + typedef std::map< std::wstring, ComPtr > TextureCache; + typedef std::map< std::wstring, ComPtr > ShaderCache; + + EffectCache mEffectCache; + EffectCache mEffectCacheSkinning; + TextureCache mTextureCache; + ShaderCache mShaderCache; + + bool mSharing; + + std::mutex mutex; +}; + + +// Global instance pool. +SharedResourcePool DGSLEffectFactory::Impl::instancePool; + + +_Use_decl_annotations_ +std::shared_ptr DGSLEffectFactory::Impl::CreateEffect( DGSLEffectFactory* factory, const DGSLEffectFactory::EffectInfo& info, ID3D11DeviceContext* deviceContext ) +{ + if ( info.enableDualTexture ) + { + throw std::exception( "DGSLEffect does not support multiple texcoords" ); + } + + if ( mSharing && info.name && *info.name ) + { + if ( info.enableSkinning ) + { + auto it = mEffectCacheSkinning.find( info.name ); + if ( it != mEffectCacheSkinning.end() ) + { + return it->second; + } + } + else + { + auto it = mEffectCache.find( info.name ); + if ( it != mEffectCache.end() ) + { + return it->second; + } + } + } + + std::shared_ptr effect = std::make_shared( device.Get(), nullptr, info.enableSkinning ); + + effect->EnableDefaultLighting(); + effect->SetLightingEnabled(true); + + XMVECTOR color = XMLoadFloat3( &info.ambientColor ); + effect->SetAmbientColor( color ); + + color = XMLoadFloat3( &info.diffuseColor ); + effect->SetDiffuseColor( color ); + + effect->SetAlpha( info.alpha ); + + if ( info.perVertexColor ) + { + effect->SetVertexColorEnabled( true ); + } + + if ( info.specularColor.x != 0 || info.specularColor.y != 0 || info.specularColor.z != 0 ) + { + color = XMLoadFloat3( &info.specularColor ); + effect->SetSpecularColor( color ); + effect->SetSpecularPower( info.specularPower ); + } + + if ( info.emissiveColor.x != 0 || info.emissiveColor.y != 0 || info.emissiveColor.z != 0 ) + { + color = XMLoadFloat3( &info.emissiveColor ); + effect->SetEmissiveColor( color ); + } + + if ( info.texture && *info.texture ) + { + ComPtr srv; + + factory->CreateTexture( info.texture, deviceContext, srv.GetAddressOf() ); + + effect->SetTexture( srv.Get() ); + effect->SetTextureEnabled(true); + } + + if ( mSharing && info.name && *info.name ) + { + std::lock_guard lock(mutex); + if ( info.enableSkinning ) + { + mEffectCacheSkinning.insert( EffectCache::value_type( info.name, effect ) ); + } + else + { + mEffectCache.insert( EffectCache::value_type( info.name, effect ) ); + } + } + + return effect; +} + + +_Use_decl_annotations_ +std::shared_ptr DGSLEffectFactory::Impl::CreateDGSLEffect( DGSLEffectFactory* factory, const DGSLEffectFactory::DGSLEffectInfo& info, ID3D11DeviceContext* deviceContext ) +{ + if ( mSharing && info.name && *info.name ) + { + if ( info.enableSkinning ) + { + auto it = mEffectCacheSkinning.find( info.name ); + if ( it != mEffectCacheSkinning.end() ) + { + return it->second; + } + } + else + { + auto it = mEffectCache.find( info.name ); + if ( it != mEffectCache.end() ) + { + return it->second; + } + } + } + + std::shared_ptr effect; + + bool lighting = true; + bool allowSpecular = true; + + if ( !info.pixelShader || !*info.pixelShader ) + { + effect = std::make_shared( device.Get(), nullptr, info.enableSkinning ); + } + else + { + wchar_t root[ MAX_PATH ] = {0}; + auto last = wcsrchr( info.pixelShader, '_' ); + if ( last ) + { + wcscpy_s( root, last+1 ); + } + else + { + wcscpy_s( root, info.pixelShader ); + } + + auto first = wcschr( root, '.' ); + if ( first ) + *first = 0; + + if ( !_wcsicmp( root, L"lambert" ) ) + { + allowSpecular = false; + effect = std::make_shared( device.Get(), nullptr, info.enableSkinning ); + } + else if ( !_wcsicmp( root, L"phong" ) ) + { + effect = std::make_shared( device.Get(), nullptr, info.enableSkinning ); + } + else if ( !_wcsicmp( root, L"unlit" ) ) + { + lighting = false; + effect = std::make_shared( device.Get(), nullptr, info.enableSkinning ); + } + else if ( device->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0 ) + { + // DGSL shaders are not compatible with Feature Level 9.x, use fallback shader + wcscat_s( root, L".cso" ); + + ComPtr ps; + factory->CreatePixelShader( root, ps.GetAddressOf() ); + + effect = std::make_shared( device.Get(), ps.Get(), info.enableSkinning ); + } + else + { + // Create DGSL shader and use it for the effect + ComPtr ps; + factory->CreatePixelShader( info.pixelShader, ps.GetAddressOf() ); + + effect = std::make_shared( device.Get(), ps.Get(), info.enableSkinning ); + } + } + + if ( lighting ) + { + effect->EnableDefaultLighting(); + effect->SetLightingEnabled(true); + } + + XMVECTOR color = XMLoadFloat3( &info.ambientColor ); + effect->SetAmbientColor( color ); + + color = XMLoadFloat3( &info.diffuseColor ); + effect->SetDiffuseColor( color ); + effect->SetAlpha( info.alpha ); + + if ( info.perVertexColor ) + { + effect->SetVertexColorEnabled( true ); + } + + effect->SetAlphaDiscardEnable(true); + + 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 ); + } + else + { + effect->DisableSpecular(); + } + + if ( info.emissiveColor.x != 0 || info.emissiveColor.y != 0 || info.emissiveColor.z != 0 ) + { + color = XMLoadFloat3( &info.emissiveColor ); + effect->SetEmissiveColor( color ); + } + + if ( info.texture && *info.texture ) + { + ComPtr srv; + + factory->CreateTexture( info.texture, deviceContext, srv.GetAddressOf() ); + + effect->SetTexture( srv.Get() ); + effect->SetTextureEnabled(true); + } + + if ( info.texture2 && *info.texture2 ) + { + ComPtr srv; + + factory->CreateTexture( info.texture2, deviceContext, srv.GetAddressOf() ); + + effect->SetTexture2( srv.Get() ); + effect->SetTextureEnabled(true); + } + + for( int j = 0; j < 6; ++j ) + { + if ( info.textures[j] && *info.textures[j] ) + { + ComPtr srv; + + factory->CreateTexture( info.textures[j], deviceContext, srv.GetAddressOf() ); + + effect->SetTexture( j+2, srv.Get() ); + effect->SetTextureEnabled(true); + } + } + + if ( mSharing && info.name && *info.name ) + { + std::lock_guard lock(mutex); + if ( info.enableSkinning ) + { + mEffectCacheSkinning.insert( EffectCache::value_type( info.name, effect ) ); + } + else + { + mEffectCache.insert( EffectCache::value_type( info.name, effect ) ); + } + } + + return effect; +} + + +_Use_decl_annotations_ +void DGSLEffectFactory::Impl::CreateTexture( const WCHAR* name, ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView** textureView ) +{ + if ( !name || !textureView ) + throw std::exception("invalid arguments"); + +#if defined(_XBOX_ONE) && defined(_TITLE) + UNREFERENCED_PARAMETER(deviceContext); +#endif + + auto it = mTextureCache.find( name ); + + if ( mSharing && it != mTextureCache.end() ) + { + ID3D11ShaderResourceView* srv = it->second.Get(); + srv->AddRef(); + *textureView = srv; + } + else + { + WCHAR fullName[MAX_PATH] = {0}; + wcscpy_s( fullName, mPath ); + wcscat_s( fullName, name ); + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) + WCHAR ext[_MAX_EXT]; + _wsplitpath_s( name, nullptr, 0, nullptr, 0, nullptr, 0, ext, _MAX_EXT ); + + if ( _wcsicmp( ext, L".dds" ) == 0 ) + { + HRESULT hr = CreateDDSTextureFromFile( device.Get(), fullName, nullptr, textureView ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateDDSTextureFromFile failed (%08X) for '%ls'\n", hr, fullName ); + throw std::exception( "CreateDDSTextureFromFile" ); + } + } +#if !defined(_XBOX_ONE) || !defined(_TITLE) + else if ( deviceContext ) + { + std::lock_guard lock(mutex); + HRESULT hr = CreateWICTextureFromFile( device.Get(), deviceContext, fullName, nullptr, textureView ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateWICTextureFromFile failed (%08X) for '%ls'\n", hr, fullName ); + throw std::exception( "CreateWICTextureFromFile" ); + } + } +#endif + else + { + HRESULT hr = CreateWICTextureFromFile( device.Get(), fullName, nullptr, textureView ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateWICTextureFromFile failed (%08X) for '%ls'\n", hr, fullName ); + throw std::exception( "CreateWICTextureFromFile" ); + } + } +#else + UNREFERENCED_PARAMETER( deviceContext ); + HRESULT hr = CreateDDSTextureFromFile( device.Get(), fullName, nullptr, textureView ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateDDSTextureFromFile failed (%08X) for '%ls'\n", hr, fullName ); + throw std::exception( "CreateDDSTextureFromFile" ); + } +#endif + + if ( mSharing && *name && it == mTextureCache.end() ) + { + std::lock_guard lock(mutex); + mTextureCache.insert( TextureCache::value_type( name, *textureView ) ); + } + } +} + + +_Use_decl_annotations_ +void DGSLEffectFactory::Impl::CreatePixelShader( const WCHAR* name, ID3D11PixelShader** pixelShader ) +{ + if ( !name || !pixelShader ) + throw std::exception("invalid arguments"); + + auto it = mShaderCache.find( name ); + + if ( mSharing && it != mShaderCache.end() ) + { + ID3D11PixelShader* ps = it->second.Get(); + ps->AddRef(); + *pixelShader = ps; + } + else + { + WCHAR fullName[MAX_PATH]={0}; + wcscpy_s( fullName, mPath ); + wcscat_s( fullName, name ); + + size_t dataSize = 0; + std::unique_ptr data; + 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" ); + } + + ThrowIfFailed( + device->CreatePixelShader( data.get(), dataSize, nullptr, pixelShader ) ); + + if ( mSharing && *name && it == mShaderCache.end() ) + { + std::lock_guard lock(mutex); + mShaderCache.insert( ShaderCache::value_type( name, *pixelShader ) ); + } + } +} + + +void DGSLEffectFactory::Impl::ReleaseCache() +{ + std::lock_guard lock(mutex); + mEffectCache.clear(); + mEffectCacheSkinning.clear(); + mTextureCache.clear(); + mShaderCache.clear(); +} + + + +//-------------------------------------------------------------------------------------- +// DGSLEffectFactory +//-------------------------------------------------------------------------------------- + +DGSLEffectFactory::DGSLEffectFactory(_In_ ID3D11Device* device) + : pImpl(Impl::instancePool.DemandCreate(device)) +{ +} + +DGSLEffectFactory::~DGSLEffectFactory() +{ +} + + +DGSLEffectFactory::DGSLEffectFactory(DGSLEffectFactory&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + +DGSLEffectFactory& DGSLEffectFactory::operator= (DGSLEffectFactory&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// IEffectFactory methods +_Use_decl_annotations_ +std::shared_ptr DGSLEffectFactory::CreateEffect( const EffectInfo& info, ID3D11DeviceContext* deviceContext ) +{ + return pImpl->CreateEffect( this, info, deviceContext ); +} + +_Use_decl_annotations_ +void DGSLEffectFactory::CreateTexture( const WCHAR* name, ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView** textureView ) +{ + return pImpl->CreateTexture( name, deviceContext, textureView ); +} + + +// DGSL methods. +_Use_decl_annotations_ +std::shared_ptr DGSLEffectFactory::CreateDGSLEffect( const DGSLEffectInfo& info, ID3D11DeviceContext* deviceContext ) +{ + return pImpl->CreateDGSLEffect( this, info, deviceContext ); +} + + +_Use_decl_annotations_ +void DGSLEffectFactory::CreatePixelShader( const WCHAR* shader, ID3D11PixelShader** pixelShader ) +{ + pImpl->CreatePixelShader( shader, pixelShader ); +} + + +// Settings +void DGSLEffectFactory::ReleaseCache() +{ + pImpl->ReleaseCache(); +} + +void DGSLEffectFactory::SetSharing( bool enabled ) +{ + pImpl->SetSharing( enabled ); +} + +void DGSLEffectFactory::SetDirectory( _In_opt_z_ const WCHAR* path ) +{ + if ( path && *path != 0 ) + { + 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'\\' ) + { + pImpl->mPath[len] = L'\\'; + pImpl->mPath[len+1] = 0; + } + } + } + else + *pImpl->mPath = 0; +} \ No newline at end of file diff --git a/Kits/DirectXTK/Src/DemandCreate.h b/Kits/DirectXTK/Src/DemandCreate.h new file mode 100644 index 0000000000000000000000000000000000000000..9caf052a1d06a9e6bbdc0e5f9d7e19d59fd00e5a --- /dev/null +++ b/Kits/DirectXTK/Src/DemandCreate.h @@ -0,0 +1,51 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "PlatformHelpers.h" + + +namespace DirectX +{ + // Helper for lazily creating a D3D resource. + template + static T* DemandCreate(Microsoft::WRL::ComPtr& comPtr, std::mutex& mutex, TCreateFunc createFunc) + { + T* result = comPtr.Get(); + + // Double-checked lock pattern. + MemoryBarrier(); + + if (!result) + { + std::lock_guard lock(mutex); + + result = comPtr.Get(); + + if (!result) + { + // Create the new object. + ThrowIfFailed( + createFunc(&result) + ); + + MemoryBarrier(); + + comPtr.Attach(result); + } + } + + return result; + } +} diff --git a/Kits/DirectXTK/Src/DualTextureEffect.cpp b/Kits/DirectXTK/Src/DualTextureEffect.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e36fe136485db79bb757e6ce75abad0d71f8efb7 --- /dev/null +++ b/Kits/DirectXTK/Src/DualTextureEffect.cpp @@ -0,0 +1,308 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "EffectCommon.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +// Constant buffer layout. Must match the shader! +struct DualTextureEffectConstants +{ + XMVECTOR diffuseColor; + XMVECTOR fogColor; + XMVECTOR fogVector; + XMMATRIX worldViewProj; +}; + +static_assert( ( sizeof(DualTextureEffectConstants) % 16 ) == 0, "CB size not padded correctly" ); + + +// Traits type describes our characteristics to the EffectBase template. +struct DualTextureEffectTraits +{ + typedef DualTextureEffectConstants ConstantBufferType; + + static const int VertexShaderCount = 4; + static const int PixelShaderCount = 2; + static const int ShaderPermutationCount = 4; +}; + + +// Internal DualTextureEffect implementation class. +class DualTextureEffect::Impl : public EffectBase +{ +public: + Impl(_In_ ID3D11Device* device); + + bool vertexColorEnabled; + + EffectColor color; + + ComPtr texture2; + + int GetCurrentShaderPermutation() const; + + void Apply(_In_ ID3D11DeviceContext* deviceContext); +}; + + +// Include the precompiled shader code. +namespace +{ +#if defined(_XBOX_ONE) && defined(_TITLE) + #include "Shaders/Compiled/XboxOneDualTextureEffect_VSDualTexture.inc" + #include "Shaders/Compiled/XboxOneDualTextureEffect_VSDualTextureNoFog.inc" + #include "Shaders/Compiled/XboxOneDualTextureEffect_VSDualTextureVc.inc" + #include "Shaders/Compiled/XboxOneDualTextureEffect_VSDualTextureVcNoFog.inc" + + #include "Shaders/Compiled/XboxOneDualTextureEffect_PSDualTexture.inc" + #include "Shaders/Compiled/XboxOneDualTextureEffect_PSDualTextureNoFog.inc" +#else + #include "Shaders/Compiled/DualTextureEffect_VSDualTexture.inc" + #include "Shaders/Compiled/DualTextureEffect_VSDualTextureNoFog.inc" + #include "Shaders/Compiled/DualTextureEffect_VSDualTextureVc.inc" + #include "Shaders/Compiled/DualTextureEffect_VSDualTextureVcNoFog.inc" + + #include "Shaders/Compiled/DualTextureEffect_PSDualTexture.inc" + #include "Shaders/Compiled/DualTextureEffect_PSDualTextureNoFog.inc" +#endif +} + + +const ShaderBytecode EffectBase::VertexShaderBytecode[] = +{ + { DualTextureEffect_VSDualTexture, sizeof(DualTextureEffect_VSDualTexture) }, + { DualTextureEffect_VSDualTextureNoFog, sizeof(DualTextureEffect_VSDualTextureNoFog) }, + { DualTextureEffect_VSDualTextureVc, sizeof(DualTextureEffect_VSDualTextureVc) }, + { DualTextureEffect_VSDualTextureVcNoFog, sizeof(DualTextureEffect_VSDualTextureVcNoFog) }, + +}; + + +const int EffectBase::VertexShaderIndices[] = +{ + 0, // basic + 1, // no fog + 2, // vertex color + 3, // vertex color, no fog +}; + + +const ShaderBytecode EffectBase::PixelShaderBytecode[] = +{ + { DualTextureEffect_PSDualTexture, sizeof(DualTextureEffect_PSDualTexture) }, + { DualTextureEffect_PSDualTextureNoFog, sizeof(DualTextureEffect_PSDualTextureNoFog) }, + +}; + + +const int EffectBase::PixelShaderIndices[] = +{ + 0, // basic + 1, // no fog + 0, // vertex color + 1, // vertex color, no fog +}; + + +// Global pool of per-device DualTextureEffect resources. +SharedResourcePool::DeviceResources> EffectBase::deviceResourcesPool; + + +// Constructor. +DualTextureEffect::Impl::Impl(_In_ ID3D11Device* device) + : EffectBase(device), + vertexColorEnabled(false) +{ + static_assert( _countof(EffectBase::VertexShaderIndices) == DualTextureEffectTraits::ShaderPermutationCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::VertexShaderBytecode) == DualTextureEffectTraits::VertexShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderBytecode) == DualTextureEffectTraits::PixelShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderIndices) == DualTextureEffectTraits::ShaderPermutationCount, "array/max mismatch" ); +} + + +int DualTextureEffect::Impl::GetCurrentShaderPermutation() const +{ + int permutation = 0; + + // Use optimized shaders if fog is disabled. + if (!fog.enabled) + { + permutation += 1; + } + + // Support vertex coloring? + if (vertexColorEnabled) + { + permutation += 2; + } + + return permutation; +} + + +// Sets our state onto the D3D device. +void DualTextureEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + // Compute derived parameter values. + matrices.SetConstants(dirtyFlags, constants.worldViewProj); + + fog.SetConstants(dirtyFlags, matrices.worldView, constants.fogVector); + + color.SetConstants(dirtyFlags, constants.diffuseColor); + + // Set the textures. + ID3D11ShaderResourceView* textures[2] = + { + texture.Get(), + texture2.Get(), + }; + + deviceContext->PSSetShaderResources(0, 2, textures); + + // Set shaders and constant buffers. + ApplyShaders(deviceContext, GetCurrentShaderPermutation()); +} + + +// Public constructor. +DualTextureEffect::DualTextureEffect(_In_ ID3D11Device* device) + : pImpl(new Impl(device)) +{ +} + + +// Move constructor. +DualTextureEffect::DualTextureEffect(DualTextureEffect&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +DualTextureEffect& DualTextureEffect::operator= (DualTextureEffect&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +DualTextureEffect::~DualTextureEffect() +{ +} + + +void DualTextureEffect::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + pImpl->Apply(deviceContext); +} + + +void DualTextureEffect::GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) +{ + pImpl->GetVertexShaderBytecode(pImpl->GetCurrentShaderPermutation(), pShaderByteCode, pByteCodeLength); +} + + +void XM_CALLCONV DualTextureEffect::SetWorld(FXMMATRIX value) +{ + pImpl->matrices.world = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::WorldInverseTranspose | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV DualTextureEffect::SetView(FXMMATRIX value) +{ + pImpl->matrices.view = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::EyePosition | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV DualTextureEffect::SetProjection(FXMMATRIX value) +{ + pImpl->matrices.projection = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj; +} + + +void XM_CALLCONV DualTextureEffect::SetDiffuseColor(FXMVECTOR value) +{ + pImpl->color.diffuseColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void DualTextureEffect::SetAlpha(float value) +{ + pImpl->color.alpha = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void DualTextureEffect::SetFogEnabled(bool value) +{ + pImpl->fog.enabled = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogEnable; +} + + +void DualTextureEffect::SetFogStart(float value) +{ + pImpl->fog.start = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void DualTextureEffect::SetFogEnd(float value) +{ + pImpl->fog.end = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV DualTextureEffect::SetFogColor(FXMVECTOR value) +{ + pImpl->constants.fogColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void DualTextureEffect::SetVertexColorEnabled(bool value) +{ + pImpl->vertexColorEnabled = value; +} + + +void DualTextureEffect::SetTexture(_In_opt_ ID3D11ShaderResourceView* value) +{ + pImpl->texture = value; +} + + +void DualTextureEffect::SetTexture2(_In_opt_ ID3D11ShaderResourceView* value) +{ + pImpl->texture2 = value; +} diff --git a/Kits/DirectXTK/Src/EffectCommon.cpp b/Kits/DirectXTK/Src/EffectCommon.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c4ef75e882355c111697a19310bc501550f6d2af --- /dev/null +++ b/Kits/DirectXTK/Src/EffectCommon.cpp @@ -0,0 +1,436 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "EffectCommon.h" +#include "DemandCreate.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +// Constructor initializes default matrix values. +EffectMatrices::EffectMatrices() +{ + world = XMMatrixIdentity(); + view = XMMatrixIdentity(); + projection = XMMatrixIdentity(); + worldView = XMMatrixIdentity(); +} + + +// Lazily recomputes the combined world+view+projection matrix. +_Use_decl_annotations_ void EffectMatrices::SetConstants(int& dirtyFlags, XMMATRIX& worldViewProjConstant) +{ + if (dirtyFlags & EffectDirtyFlags::WorldViewProj) + { + worldView = XMMatrixMultiply(world, view); + + worldViewProjConstant = XMMatrixTranspose(XMMatrixMultiply(worldView, projection)); + + dirtyFlags &= ~EffectDirtyFlags::WorldViewProj; + dirtyFlags |= EffectDirtyFlags::ConstantBuffer; + } +} + + +// Constructor initializes default fog settings. +EffectFog::EffectFog() +{ + enabled = false; + start = 0; + end = 1; +} + + +// Lazily recomputes the derived vector used by shader fog calculations. +_Use_decl_annotations_ +void XM_CALLCONV EffectFog::SetConstants(int& dirtyFlags, FXMMATRIX worldView, XMVECTOR& fogVectorConstant) +{ + if (enabled) + { + if (dirtyFlags & (EffectDirtyFlags::FogVector | EffectDirtyFlags::FogEnable)) + { + if (start == end) + { + // Degenerate case: force everything to 100% fogged if start and end are the same. + static const XMVECTORF32 fullyFogged = { 0, 0, 0, 1 }; + + fogVectorConstant = fullyFogged; + } + else + { + // We want to transform vertex positions into view space, take the resulting + // Z value, then scale and offset according to the fog start/end distances. + // Because we only care about the Z component, the shader can do all this + // with a single dot product, using only the Z row of the world+view matrix. + + // _13, _23, _33, _43 + XMVECTOR worldViewZ = XMVectorMergeXY(XMVectorMergeZW(worldView.r[0], worldView.r[2]), + XMVectorMergeZW(worldView.r[1], worldView.r[3])); + + // 0, 0, 0, fogStart + XMVECTOR wOffset = XMVectorSwizzle<1, 2, 3, 0>(XMLoadFloat(&start)); + + fogVectorConstant = (worldViewZ + wOffset) / (start - end); + } + + dirtyFlags &= ~(EffectDirtyFlags::FogVector | EffectDirtyFlags::FogEnable); + dirtyFlags |= EffectDirtyFlags::ConstantBuffer; + } + } + else + { + // When fog is disabled, make sure the fog vector is reset to zero. + if (dirtyFlags & EffectDirtyFlags::FogEnable) + { + fogVectorConstant = g_XMZero; + + dirtyFlags &= ~EffectDirtyFlags::FogEnable; + dirtyFlags |= EffectDirtyFlags::ConstantBuffer; + } + } +} + + +// Constructor initializes default material color settings. +EffectColor::EffectColor() +{ + diffuseColor = g_XMOne; + alpha = 1; +} + + +// Lazily recomputes the material color parameter for shaders that do not support realtime lighting. +void EffectColor::SetConstants(_Inout_ int& dirtyFlags, _Inout_ XMVECTOR& diffuseColorConstant) +{ + if (dirtyFlags & EffectDirtyFlags::MaterialColor) + { + XMVECTOR alphaVector = XMVectorReplicate(alpha); + + // xyz = diffuse * alpha, w = alpha. + diffuseColorConstant = XMVectorSelect(alphaVector, diffuseColor * alphaVector, g_XMSelect1110); + + dirtyFlags &= ~EffectDirtyFlags::MaterialColor; + dirtyFlags |= EffectDirtyFlags::ConstantBuffer; + } +} + + +// Constructor initializes default light settings. +EffectLights::EffectLights() +{ + emissiveColor = g_XMZero; + ambientLightColor = g_XMZero; + + for (int i = 0; i < MaxDirectionalLights; i++) + { + lightEnabled[i] = (i == 0); + lightDiffuseColor[i] = g_XMOne; + lightSpecularColor[i] = g_XMZero; + } +} + + +#pragma prefast(push) +#pragma prefast(disable:22103, "PREFAST doesn't understand buffer is bounded by a static const value even with SAL" ) + +// Initializes constant buffer fields to match the current lighting state. +_Use_decl_annotations_ void EffectLights::InitializeConstants(XMVECTOR& specularColorAndPowerConstant, XMVECTOR* lightDirectionConstant, XMVECTOR* lightDiffuseConstant, XMVECTOR* lightSpecularConstant) +{ + static const XMVECTORF32 defaultSpecular = { 1, 1, 1, 16 }; + static const XMVECTORF32 defaultLightDirection = { 0, -1, 0, 0 }; + + specularColorAndPowerConstant = defaultSpecular; + + for (int i = 0; i < MaxDirectionalLights; i++) + { + lightDirectionConstant[i] = defaultLightDirection; + + lightDiffuseConstant[i] = lightEnabled[i] ? lightDiffuseColor[i] : g_XMZero; + lightSpecularConstant[i] = lightEnabled[i] ? lightSpecularColor[i] : g_XMZero; + } +} + +#pragma prefast(pop) + + +// Lazily recomputes derived parameter values used by shader lighting calculations. +_Use_decl_annotations_ void EffectLights::SetConstants(int& dirtyFlags, EffectMatrices const& matrices, XMMATRIX& worldConstant, XMVECTOR worldInverseTransposeConstant[3], XMVECTOR& eyePositionConstant, XMVECTOR& diffuseColorConstant, XMVECTOR& emissiveColorConstant, bool lightingEnabled) +{ + if (lightingEnabled) + { + // World inverse transpose matrix. + if (dirtyFlags & EffectDirtyFlags::WorldInverseTranspose) + { + worldConstant = XMMatrixTranspose(matrices.world); + + XMMATRIX worldInverse = XMMatrixInverse(nullptr, matrices.world); + + worldInverseTransposeConstant[0] = worldInverse.r[0]; + worldInverseTransposeConstant[1] = worldInverse.r[1]; + worldInverseTransposeConstant[2] = worldInverse.r[2]; + + dirtyFlags &= ~EffectDirtyFlags::WorldInverseTranspose; + dirtyFlags |= EffectDirtyFlags::ConstantBuffer; + } + + // Eye position vector. + if (dirtyFlags & EffectDirtyFlags::EyePosition) + { + XMMATRIX viewInverse = XMMatrixInverse(nullptr, matrices.view); + + eyePositionConstant = viewInverse.r[3]; + + dirtyFlags &= ~EffectDirtyFlags::EyePosition; + dirtyFlags |= EffectDirtyFlags::ConstantBuffer; + } + } + + // Material color parameters. The desired lighting model is: + // + // ((ambientLightColor + sum(diffuse directional light)) * diffuseColor) + emissiveColor + // + // When lighting is disabled, ambient and directional lights are ignored, leaving: + // + // diffuseColor + emissiveColor + // + // For the lighting disabled case, we can save one shader instruction by precomputing + // diffuse+emissive on the CPU, after which the shader can use diffuseColor directly, + // ignoring its emissive parameter. + // + // When lighting is enabled, we can merge the ambient and emissive settings. If we + // set our emissive parameter to emissive+(ambient*diffuse), the shader no longer + // needs to bother adding the ambient contribution, simplifying its computation to: + // + // (sum(diffuse directional light) * diffuseColor) + emissiveColor + // + // For futher optimization goodness, we merge material alpha with the diffuse + // color parameter, and premultiply all color values by this alpha. + + if (dirtyFlags & EffectDirtyFlags::MaterialColor) + { + XMVECTOR diffuse = diffuseColor; + XMVECTOR alphaVector = XMVectorReplicate(alpha); + + if (lightingEnabled) + { + // Merge emissive and ambient light contributions. + emissiveColorConstant = (emissiveColor + ambientLightColor * diffuse) * alphaVector; + } + else + { + // Merge diffuse and emissive light contributions. + diffuse += emissiveColor; + } + + // xyz = diffuse * alpha, w = alpha. + diffuseColorConstant = XMVectorSelect(alphaVector, diffuse * alphaVector, g_XMSelect1110); + + dirtyFlags &= ~EffectDirtyFlags::MaterialColor; + dirtyFlags |= EffectDirtyFlags::ConstantBuffer; + } +} + + +#pragma prefast(push) +#pragma prefast(disable:26015, "PREFAST doesn't understand that ValidateLightIndex bounds whichLight" ) + +// Helper for turning one of the directional lights on or off. +_Use_decl_annotations_ int EffectLights::SetLightEnabled(int whichLight, bool value, XMVECTOR* lightDiffuseConstant, XMVECTOR* lightSpecularConstant) +{ + ValidateLightIndex(whichLight); + + if (lightEnabled[whichLight] == value) + return 0; + + lightEnabled[whichLight] = value; + + if (value) + { + // If this light is now on, store its color in the constant buffer. + lightDiffuseConstant[whichLight] = lightDiffuseColor[whichLight]; + lightSpecularConstant[whichLight] = lightSpecularColor[whichLight]; + } + else + { + // If the light is off, reset constant buffer colors to zero. + lightDiffuseConstant[whichLight] = g_XMZero; + lightSpecularConstant[whichLight] = g_XMZero; + } + + return EffectDirtyFlags::ConstantBuffer; +} + + +// Helper for setting diffuse color of one of the directional lights. +_Use_decl_annotations_ +int XM_CALLCONV EffectLights::SetLightDiffuseColor(int whichLight, FXMVECTOR value, XMVECTOR* lightDiffuseConstant) +{ + ValidateLightIndex(whichLight); + + // Locally store the new color. + lightDiffuseColor[whichLight] = value; + + // If this light is currently on, also update the constant buffer. + if (lightEnabled[whichLight]) + { + lightDiffuseConstant[whichLight] = value; + + return EffectDirtyFlags::ConstantBuffer; + } + + return 0; +} + + +// Helper for setting specular color of one of the directional lights. +_Use_decl_annotations_ +int XM_CALLCONV EffectLights::SetLightSpecularColor(int whichLight, FXMVECTOR value, XMVECTOR* lightSpecularConstant) +{ + ValidateLightIndex(whichLight); + + // Locally store the new color. + lightSpecularColor[whichLight] = value; + + // If this light is currently on, also update the constant buffer. + if (lightEnabled[whichLight]) + { + lightSpecularConstant[whichLight] = value; + + return EffectDirtyFlags::ConstantBuffer; + } + + return 0; +} + +#pragma prefast(pop) + + +// Parameter validation helper. +void EffectLights::ValidateLightIndex(int whichLight) +{ + if (whichLight < 0 || whichLight >= MaxDirectionalLights) + { + throw std::out_of_range("whichLight parameter out of range"); + } +} + + +// Activates the default lighting rig (key, fill, and back lights). +void EffectLights::EnableDefaultLighting(_In_ IEffectLights* effect) +{ + static const XMVECTORF32 defaultDirections[MaxDirectionalLights] = + { + { -0.5265408f, -0.5735765f, -0.6275069f }, + { 0.7198464f, 0.3420201f, 0.6040227f }, + { 0.4545195f, -0.7660444f, 0.4545195f }, + }; + + static const XMVECTORF32 defaultDiffuse[MaxDirectionalLights] = + { + { 1.0000000f, 0.9607844f, 0.8078432f }, + { 0.9647059f, 0.7607844f, 0.4078432f }, + { 0.3231373f, 0.3607844f, 0.3937255f }, + }; + + static const XMVECTORF32 defaultSpecular[MaxDirectionalLights] = + { + { 1.0000000f, 0.9607844f, 0.8078432f }, + { 0.0000000f, 0.0000000f, 0.0000000f }, + { 0.3231373f, 0.3607844f, 0.3937255f }, + }; + + static const XMVECTORF32 defaultAmbient = { 0.05333332f, 0.09882354f, 0.1819608f }; + + effect->SetLightingEnabled(true); + effect->SetAmbientLightColor(defaultAmbient); + + for (int i = 0; i < MaxDirectionalLights; i++) + { + effect->SetLightEnabled(i, true); + effect->SetLightDirection(i, defaultDirections[i]); + effect->SetLightDiffuseColor(i, defaultDiffuse[i]); + effect->SetLightSpecularColor(i, defaultSpecular[i]); + } +} + + +// Gets or lazily creates the specified vertex shader permutation. +ID3D11VertexShader* EffectDeviceResources::DemandCreateVertexShader(_Inout_ ComPtr& vertexShader, ShaderBytecode const& bytecode) +{ + return DemandCreate(vertexShader, mMutex, [&](ID3D11VertexShader** pResult) -> HRESULT + { + HRESULT hr = mDevice->CreateVertexShader(bytecode.code, bytecode.length, nullptr, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:Effect"); + + return hr; + }); +} + + +// Gets or lazily creates the specified pixel shader permutation. +ID3D11PixelShader* EffectDeviceResources::DemandCreatePixelShader(_Inout_ ComPtr& pixelShader, ShaderBytecode const& bytecode) +{ + return DemandCreate(pixelShader, mMutex, [&](ID3D11PixelShader** pResult) -> HRESULT + { + HRESULT hr = mDevice->CreatePixelShader(bytecode.code, bytecode.length, nullptr, pResult); + + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:Effect"); + + return hr; + }); +} + + +// Gets or lazily creates the default texture +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; + memset( &desc, 0, sizeof(desc) ); + desc.Width = desc.Height = desc.MipLevels = desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_IMMUTABLE; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + + ComPtr tex; + HRESULT hr = mDevice->CreateTexture2D( &desc, &initData, tex.GetAddressOf() ); + + if (SUCCEEDED(hr)) + { + SetDebugObjectName(tex.Get(), "DirectXTK:Effect"); + + D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc; + memset( &SRVDesc, 0, sizeof( SRVDesc ) ); + SRVDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + SRVDesc.Texture2D.MipLevels = 1; + + hr = mDevice->CreateShaderResourceView( tex.Get(), &SRVDesc, pResult ); + if (SUCCEEDED(hr)) + SetDebugObjectName(*pResult, "DirectXTK:Effect"); + } + + return hr; + }); +} diff --git a/Kits/DirectXTK/Src/EffectCommon.h b/Kits/DirectXTK/Src/EffectCommon.h new file mode 100644 index 0000000000000000000000000000000000000000..e829a629c6f7224dd3b7d7033e65716250e420d2 --- /dev/null +++ b/Kits/DirectXTK/Src/EffectCommon.h @@ -0,0 +1,281 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include + +#include "Effects.h" +#include "PlatformHelpers.h" +#include "ConstantBuffer.h" +#include "SharedResourcePool.h" +#include "AlignedNew.h" + + +// BasicEffect, SkinnedEffect, et al, have many things in common, but also significant +// differences (for instance, not all the effects support lighting). This header breaks +// out common functionality into a set of helpers which can be assembled in different +// combinations to build up whatever subset is needed by each effect. + + +namespace DirectX +{ + // Bitfield tracks which derived parameter values need to be recomputed. + namespace EffectDirtyFlags + { + const int ConstantBuffer = 0x01; + const int WorldViewProj = 0x02; + const int WorldInverseTranspose = 0x04; + const int EyePosition = 0x08; + const int MaterialColor = 0x10; + const int FogVector = 0x20; + const int FogEnable = 0x40; + const int AlphaTest = 0x80; + } + + + // Helper stores matrix parameter values, and computes derived matrices. + struct EffectMatrices + { + EffectMatrices(); + + XMMATRIX world; + XMMATRIX view; + XMMATRIX projection; + XMMATRIX worldView; + + void SetConstants(_Inout_ int& dirtyFlags, _Inout_ XMMATRIX& worldViewProjConstant); + }; + + + // Helper stores the current fog settings, and computes derived shader parameters. + struct EffectFog + { + EffectFog(); + + bool enabled; + float start; + float end; + + void XM_CALLCONV SetConstants(_Inout_ int& dirtyFlags, _In_ FXMMATRIX worldView, _Inout_ XMVECTOR& fogVectorConstant); + }; + + + // Helper stores material color settings, and computes derived parameters for shaders that do not support realtime lighting. + struct EffectColor + { + EffectColor(); + + XMVECTOR diffuseColor; + float alpha; + + void SetConstants(_Inout_ int& dirtyFlags, _Inout_ XMVECTOR& diffuseColorConstant); + }; + + + // Helper stores the current light settings, and computes derived shader parameters. + struct EffectLights : public EffectColor + { + EffectLights(); + + static const int MaxDirectionalLights = IEffectLights::MaxDirectionalLights; + + + // Fields. + XMVECTOR emissiveColor; + XMVECTOR ambientLightColor; + + bool lightEnabled[MaxDirectionalLights]; + XMVECTOR lightDiffuseColor[MaxDirectionalLights]; + XMVECTOR lightSpecularColor[MaxDirectionalLights]; + + + // Methods. + void InitializeConstants(_Out_ XMVECTOR& specularColorAndPowerConstant, _Out_writes_all_(MaxDirectionalLights) XMVECTOR* lightDirectionConstant, _Out_writes_all_(MaxDirectionalLights) XMVECTOR* lightDiffuseConstant, _Out_writes_all_(MaxDirectionalLights) XMVECTOR* lightSpecularConstant); + void SetConstants(_Inout_ int& dirtyFlags, _In_ EffectMatrices const& matrices, _Inout_ XMMATRIX& worldConstant, _Inout_updates_(3) XMVECTOR worldInverseTransposeConstant[3], _Inout_ XMVECTOR& eyePositionConstant, _Inout_ XMVECTOR& diffuseColorConstant, _Inout_ XMVECTOR& emissiveColorConstant, bool lightingEnabled); + + int SetLightEnabled(int whichLight, bool value, _Inout_updates_(MaxDirectionalLights) XMVECTOR* lightDiffuseConstant, _Inout_updates_(MaxDirectionalLights) XMVECTOR* lightSpecularConstant); + int XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value, _Inout_updates_(MaxDirectionalLights) XMVECTOR* lightDiffuseConstant); + int XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value, _Inout_updates_(MaxDirectionalLights) XMVECTOR* lightSpecularConstant); + + static void ValidateLightIndex(int whichLight); + static void EnableDefaultLighting(_In_ IEffectLights* effect); + }; + + + // Points to a precompiled vertex or pixel shader program. + struct ShaderBytecode + { + void const* code; + size_t length; + }; + + + // Factory for lazily instantiating shaders. BasicEffect supports many different + // shader permutations, so we only bother creating the ones that are actually used. + class EffectDeviceResources + { + public: + EffectDeviceResources(_In_ ID3D11Device* device) + : mDevice(device) + { } + + ID3D11VertexShader* DemandCreateVertexShader(_Inout_ Microsoft::WRL::ComPtr& vertexShader, ShaderBytecode const& bytecode); + ID3D11PixelShader * DemandCreatePixelShader (_Inout_ Microsoft::WRL::ComPtr & pixelShader, ShaderBytecode const& bytecode); + ID3D11ShaderResourceView* GetDefaultTexture(); + + protected: + Microsoft::WRL::ComPtr mDevice; + Microsoft::WRL::ComPtr mDefaultTexture; + + std::mutex mMutex; + }; + + + // Templated base class provides functionality common to all the built-in effects. + template + class EffectBase : public AlignedNew + { + public: + // Constructor. + EffectBase(_In_ ID3D11Device* device) + : dirtyFlags(INT_MAX), + mConstantBuffer(device), + mDeviceResources(deviceResourcesPool.DemandCreate(device)) + { + ZeroMemory(&constants, sizeof(constants)); + } + + + // Fields. + typename Traits::ConstantBufferType constants; + + EffectMatrices matrices; + EffectFog fog; + + Microsoft::WRL::ComPtr texture; + + int dirtyFlags; + + + // Helper looks up the bytecode for the specified vertex shader permutation. + // Client code needs this in order to create matching input layouts. + void GetVertexShaderBytecode(int permutation, _Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) + { + int shaderIndex = VertexShaderIndices[permutation]; + + ShaderBytecode const& bytecode = VertexShaderBytecode[shaderIndex]; + + *pShaderByteCode = bytecode.code; + *pByteCodeLength = bytecode.length; + } + + + // Helper sets our shaders and constant buffers onto the D3D device. + void ApplyShaders(_In_ ID3D11DeviceContext* deviceContext, int permutation) + { + // Set shaders. + auto vertexShader = mDeviceResources->GetVertexShader(permutation); + auto pixelShader = mDeviceResources->GetPixelShader(permutation); + + deviceContext->VSSetShader(vertexShader, nullptr, 0); + deviceContext->PSSetShader(pixelShader, nullptr, 0); + +#if defined(_XBOX_ONE) && defined(_TITLE) + void *grfxMemory; + mConstantBuffer.SetData(deviceContext, constants, &grfxMemory); + + Microsoft::WRL::ComPtr deviceContextX; + ThrowIfFailed(deviceContext->QueryInterface(IID_GRAPHICS_PPV_ARGS(deviceContextX.GetAddressOf()))); + + auto buffer = mConstantBuffer.GetBuffer(); + + deviceContextX->VSSetPlacementConstantBuffer(0, buffer, grfxMemory); + deviceContextX->PSSetPlacementConstantBuffer(0, buffer, grfxMemory); +#else + // Make sure the constant buffer is up to date. + if (dirtyFlags & EffectDirtyFlags::ConstantBuffer) + { + mConstantBuffer.SetData(deviceContext, constants); + + dirtyFlags &= ~EffectDirtyFlags::ConstantBuffer; + } + + // Set the constant buffer. + ID3D11Buffer* buffer = mConstantBuffer.GetBuffer(); + + deviceContext->VSSetConstantBuffers(0, 1, &buffer); + deviceContext->PSSetConstantBuffers(0, 1, &buffer); +#endif + } + + + // Helper returns the default texture. + ID3D11ShaderResourceView* GetDefaultTexture() { return mDeviceResources->GetDefaultTexture(); } + + + protected: + // Static arrays hold all the precompiled shader permutations. + static const ShaderBytecode VertexShaderBytecode[Traits::VertexShaderCount]; + static const ShaderBytecode PixelShaderBytecode[Traits::PixelShaderCount]; + + static const int VertexShaderIndices[Traits::ShaderPermutationCount]; + static const int PixelShaderIndices[Traits::ShaderPermutationCount]; + + private: + // D3D constant buffer holds a copy of the same data as the public 'constants' field. + ConstantBuffer mConstantBuffer; + + // Only one of these helpers is allocated per D3D device, even if there are multiple effect instances. + class DeviceResources : protected EffectDeviceResources + { + public: + DeviceResources(_In_ ID3D11Device* device) + : EffectDeviceResources(device) + { } + + + // Gets or lazily creates the specified vertex shader permutation. + ID3D11VertexShader* GetVertexShader(int permutation) + { + int shaderIndex = VertexShaderIndices[permutation]; + + return DemandCreateVertexShader(mVertexShaders[shaderIndex], VertexShaderBytecode[shaderIndex]); + } + + + // Gets or lazily creates the specified pixel shader permutation. + ID3D11PixelShader* GetPixelShader(int permutation) + { + int shaderIndex = PixelShaderIndices[permutation]; + + return DemandCreatePixelShader(mPixelShaders[shaderIndex], PixelShaderBytecode[shaderIndex]); + } + + + // Gets or lazily creates the default texture + ID3D11ShaderResourceView* GetDefaultTexture() { return EffectDeviceResources::GetDefaultTexture(); } + + + private: + Microsoft::WRL::ComPtr mVertexShaders[Traits::VertexShaderCount]; + Microsoft::WRL::ComPtr mPixelShaders[Traits::PixelShaderCount]; + }; + + + // Per-device resources. + std::shared_ptr mDeviceResources; + + static SharedResourcePool deviceResourcesPool; + }; +} diff --git a/Kits/DirectXTK/Src/EffectFactory.cpp b/Kits/DirectXTK/Src/EffectFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4d2a55762c4afb8772f78a340bc5e034f3ddd8e1 --- /dev/null +++ b/Kits/DirectXTK/Src/EffectFactory.cpp @@ -0,0 +1,399 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Effects.h" +#include "DemandCreate.h" +#include "SharedResourcePool.h" + +#include "DDSTextureLoader.h" + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) +#include "WICTextureLoader.h" +#endif + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +// Internal EffectFactory implementation class. Only one of these helpers is allocated +// per D3D device, even if there are multiple public facing EffectFactory instances. +class EffectFactory::Impl +{ +public: + Impl(_In_ ID3D11Device* device) + : device(device), mSharing(true) + { *mPath = 0; } + + std::shared_ptr CreateEffect( _In_ IEffectFactory* factory, _In_ const IEffectFactory::EffectInfo& info, _In_opt_ ID3D11DeviceContext* deviceContext ); + void CreateTexture( _In_z_ const WCHAR* texture, _In_opt_ ID3D11DeviceContext* deviceContext, _Outptr_ ID3D11ShaderResourceView** textureView ); + + void ReleaseCache(); + void SetSharing( bool enabled ) { mSharing = enabled; } + + static SharedResourcePool instancePool; + + WCHAR mPath[MAX_PATH]; + +private: + ComPtr device; + + typedef std::map< std::wstring, std::shared_ptr > EffectCache; + typedef std::map< std::wstring, ComPtr > TextureCache; + + EffectCache mEffectCache; + EffectCache mEffectCacheSkinning; + EffectCache mEffectCacheDualTexture; + TextureCache mTextureCache; + + bool mSharing; + + std::mutex mutex; +}; + + +// Global instance pool. +SharedResourcePool EffectFactory::Impl::instancePool; + + +_Use_decl_annotations_ +std::shared_ptr EffectFactory::Impl::CreateEffect( IEffectFactory* factory, const IEffectFactory::EffectInfo& info, ID3D11DeviceContext* deviceContext ) +{ + if ( info.enableSkinning ) + { + // SkinnedEffect + if ( mSharing && info.name && *info.name ) + { + auto it = mEffectCacheSkinning.find( info.name ); + if ( mSharing && it != mEffectCacheSkinning.end() ) + { + return it->second; + } + } + + std::shared_ptr effect = std::make_shared( device.Get() ); + + effect->EnableDefaultLighting(); + + effect->SetAlpha( info.alpha ); + + // Skinned Effect does not have an ambient material color, or per-vertex color support + + XMVECTOR color = XMLoadFloat3( &info.diffuseColor ); + effect->SetDiffuseColor( color ); + + if ( info.specularColor.x != 0 || info.specularColor.y != 0 || info.specularColor.z != 0 ) + { + 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 ) + { + color = XMLoadFloat3( &info.emissiveColor ); + effect->SetEmissiveColor( color ); + } + + if ( info.texture && *info.texture ) + { + ComPtr srv; + + factory->CreateTexture( info.texture, deviceContext, &srv ); + + effect->SetTexture( srv.Get() ); + } + + if ( mSharing && info.name && *info.name ) + { + std::lock_guard lock(mutex); + mEffectCacheSkinning.insert( EffectCache::value_type( info.name, effect ) ); + } + + return effect; + } + else if ( info.enableDualTexture ) + { + // DualTextureEffect + if ( mSharing && info.name && *info.name ) + { + auto it = mEffectCacheDualTexture.find( info.name ); + if ( mSharing && it != mEffectCacheDualTexture.end() ) + { + return it->second; + } + } + + std::shared_ptr effect = std::make_shared( device.Get() ); + + // Dual texture effect doesn't support lighting (usually it's lightmaps) + + effect->SetAlpha( info.alpha ); + + if ( info.perVertexColor ) + { + effect->SetVertexColorEnabled( true ); + } + + XMVECTOR color = XMLoadFloat3( &info.diffuseColor ); + effect->SetDiffuseColor( color ); + + if ( info.texture && *info.texture ) + { + ComPtr srv; + + factory->CreateTexture( info.texture, deviceContext, &srv ); + + effect->SetTexture( srv.Get() ); + } + + if ( info.texture2 && *info.texture2 ) + { + ComPtr srv; + + factory->CreateTexture( info.texture2, deviceContext, &srv ); + + effect->SetTexture2( srv.Get() ); + } + + if ( mSharing && info.name && *info.name ) + { + std::lock_guard lock(mutex); + mEffectCacheDualTexture.insert( EffectCache::value_type( info.name, effect ) ); + } + + return effect; + } + else + { + // BasicEffect + if ( mSharing && info.name && *info.name ) + { + auto it = mEffectCache.find( info.name ); + if ( mSharing && it != mEffectCache.end() ) + { + return it->second; + } + } + + std::shared_ptr effect = std::make_shared( device.Get() ); + + effect->EnableDefaultLighting(); + effect->SetLightingEnabled(true); + + effect->SetAlpha( info.alpha ); + + if ( info.perVertexColor ) + { + effect->SetVertexColorEnabled( true ); + } + + // Basic Effect does not have an ambient material color + + XMVECTOR color = XMLoadFloat3( &info.diffuseColor ); + effect->SetDiffuseColor( color ); + + if ( info.specularColor.x != 0 || info.specularColor.y != 0 || info.specularColor.z != 0 ) + { + 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 ) + { + color = XMLoadFloat3( &info.emissiveColor ); + effect->SetEmissiveColor( color ); + } + + if ( info.texture && *info.texture ) + { + ComPtr srv; + + factory->CreateTexture( info.texture, deviceContext, &srv ); + + effect->SetTexture( srv.Get() ); + effect->SetTextureEnabled( true ); + } + + if ( mSharing && info.name && *info.name ) + { + std::lock_guard lock(mutex); + mEffectCache.insert( EffectCache::value_type( info.name, effect ) ); + } + + return effect; + } +} + +_Use_decl_annotations_ +void EffectFactory::Impl::CreateTexture( const WCHAR* name, ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView** textureView ) +{ + if ( !name || !textureView ) + throw std::exception("invalid arguments"); + +#if defined(_XBOX_ONE) && defined(_TITLE) + UNREFERENCED_PARAMETER(deviceContext); +#endif + + auto it = mTextureCache.find( name ); + + if ( mSharing && it != mTextureCache.end() ) + { + ID3D11ShaderResourceView* srv = it->second.Get(); + srv->AddRef(); + *textureView = srv; + } + else + { + WCHAR fullName[MAX_PATH]={0}; + wcscpy_s( fullName, mPath ); + wcscat_s( fullName, name ); + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) + WCHAR ext[_MAX_EXT]; + _wsplitpath_s( name, nullptr, 0, nullptr, 0, nullptr, 0, ext, _MAX_EXT ); + + if ( _wcsicmp( ext, L".dds" ) == 0 ) + { + HRESULT hr = CreateDDSTextureFromFile( device.Get(), fullName, nullptr, textureView ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateDDSTextureFromFile failed (%08X) for '%ls'\n", hr, fullName ); + throw std::exception( "CreateDDSTextureFromFile" ); + } + } +#if !defined(_XBOX_ONE) || !defined(_TITLE) + else if ( deviceContext ) + { + std::lock_guard lock(mutex); + HRESULT hr = CreateWICTextureFromFile( device.Get(), deviceContext, fullName, nullptr, textureView ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateWICTextureFromFile failed (%08X) for '%ls'\n", hr, fullName ); + throw std::exception( "CreateWICTextureFromFile" ); + } + } +#endif + else + { + HRESULT hr = CreateWICTextureFromFile( device.Get(), fullName, nullptr, textureView ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateWICTextureFromFile failed (%08X) for '%ls'\n", hr, fullName ); + throw std::exception( "CreateWICTextureFromFile" ); + } + } +#else + UNREFERENCED_PARAMETER( deviceContext ); + HRESULT hr = CreateDDSTextureFromFile( device.Get(), fullName, nullptr, textureView ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateDDSTextureFromFile failed (%08X) for '%ls'\n", hr, fullName ); + throw std::exception( "CreateDDSTextureFromFile" ); + } +#endif + + if ( mSharing && *name && it == mTextureCache.end() ) + { + std::lock_guard lock(mutex); + mTextureCache.insert( TextureCache::value_type( name, *textureView ) ); + } + } +} + +void EffectFactory::Impl::ReleaseCache() +{ + std::lock_guard lock(mutex); + mEffectCache.clear(); + mEffectCacheSkinning.clear(); + mEffectCacheDualTexture.clear(); + mTextureCache.clear(); +} + + + +//-------------------------------------------------------------------------------------- +// EffectFactory +//-------------------------------------------------------------------------------------- + +EffectFactory::EffectFactory(_In_ ID3D11Device* device) + : pImpl(Impl::instancePool.DemandCreate(device)) +{ +} + +EffectFactory::~EffectFactory() +{ +} + + +EffectFactory::EffectFactory(EffectFactory&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + +EffectFactory& EffectFactory::operator= (EffectFactory&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + +_Use_decl_annotations_ +std::shared_ptr EffectFactory::CreateEffect( const EffectInfo& info, ID3D11DeviceContext* deviceContext ) +{ + return pImpl->CreateEffect( this, info, deviceContext ); +} + +_Use_decl_annotations_ +void EffectFactory::CreateTexture( const WCHAR* name, ID3D11DeviceContext* deviceContext, ID3D11ShaderResourceView** textureView ) +{ + return pImpl->CreateTexture( name, deviceContext, textureView ); +} + +void EffectFactory::ReleaseCache() +{ + pImpl->ReleaseCache(); +} + +void EffectFactory::SetSharing( bool enabled ) +{ + pImpl->SetSharing( enabled ); +} + +void EffectFactory::SetDirectory( _In_opt_z_ const WCHAR* path ) +{ + if ( path && *path != 0 ) + { + 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'\\' ) + { + pImpl->mPath[len] = L'\\'; + pImpl->mPath[len+1] = 0; + } + } + } + else + *pImpl->mPath = 0; +} \ No newline at end of file diff --git a/Kits/DirectXTK/Src/EnvironmentMapEffect.cpp b/Kits/DirectXTK/Src/EnvironmentMapEffect.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3c227b3910465d9601cc4dbb57c184f241b8853d --- /dev/null +++ b/Kits/DirectXTK/Src/EnvironmentMapEffect.cpp @@ -0,0 +1,463 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "EffectCommon.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +// Constant buffer layout. Must match the shader! +struct EnvironmentMapEffectConstants +{ + XMVECTOR environmentMapSpecular; + float environmentMapAmount; + float fresnelFactor; + float pad[2]; + + XMVECTOR diffuseColor; + XMVECTOR emissiveColor; + + XMVECTOR lightDirection[IEffectLights::MaxDirectionalLights]; + XMVECTOR lightDiffuseColor[IEffectLights::MaxDirectionalLights]; + + XMVECTOR eyePosition; + + XMVECTOR fogColor; + XMVECTOR fogVector; + + XMMATRIX world; + XMVECTOR worldInverseTranspose[3]; + XMMATRIX worldViewProj; +}; + +static_assert( ( sizeof(EnvironmentMapEffectConstants) % 16 ) == 0, "CB size not padded correctly" ); + + +// Traits type describes our characteristics to the EffectBase template. +struct EnvironmentMapEffectTraits +{ + typedef EnvironmentMapEffectConstants ConstantBufferType; + + static const int VertexShaderCount = 4; + static const int PixelShaderCount = 4; + static const int ShaderPermutationCount = 16; +}; + + +// Internal EnvironmentMapEffect implementation class. +class EnvironmentMapEffect::Impl : public EffectBase +{ +public: + Impl(_In_ ID3D11Device* device); + + bool fresnelEnabled; + bool specularEnabled; + + EffectLights lights; + + ComPtr environmentMap; + + int GetCurrentShaderPermutation() const; + + void Apply(_In_ ID3D11DeviceContext* deviceContext); +}; + + +// Include the precompiled shader code. +namespace +{ +#if defined(_XBOX_ONE) && defined(_TITLE) + #include "Shaders/Compiled/XboxOneEnvironmentMapEffect_VSEnvMap.inc" + #include "Shaders/Compiled/XboxOneEnvironmentMapEffect_VSEnvMapFresnel.inc" + #include "Shaders/Compiled/XboxOneEnvironmentMapEffect_VSEnvMapOneLight.inc" + #include "Shaders/Compiled/XboxOneEnvironmentMapEffect_VSEnvMapOneLightFresnel.inc" + + #include "Shaders/Compiled/XboxOneEnvironmentMapEffect_PSEnvMap.inc" + #include "Shaders/Compiled/XboxOneEnvironmentMapEffect_PSEnvMapNoFog.inc" + #include "Shaders/Compiled/XboxOneEnvironmentMapEffect_PSEnvMapSpecular.inc" + #include "Shaders/Compiled/XboxOneEnvironmentMapEffect_PSEnvMapSpecularNoFog.inc" +#else + #include "Shaders/Compiled/EnvironmentMapEffect_VSEnvMap.inc" + #include "Shaders/Compiled/EnvironmentMapEffect_VSEnvMapFresnel.inc" + #include "Shaders/Compiled/EnvironmentMapEffect_VSEnvMapOneLight.inc" + #include "Shaders/Compiled/EnvironmentMapEffect_VSEnvMapOneLightFresnel.inc" + + #include "Shaders/Compiled/EnvironmentMapEffect_PSEnvMap.inc" + #include "Shaders/Compiled/EnvironmentMapEffect_PSEnvMapNoFog.inc" + #include "Shaders/Compiled/EnvironmentMapEffect_PSEnvMapSpecular.inc" + #include "Shaders/Compiled/EnvironmentMapEffect_PSEnvMapSpecularNoFog.inc" +#endif +} + + +const ShaderBytecode EffectBase::VertexShaderBytecode[] = +{ + { EnvironmentMapEffect_VSEnvMap, sizeof(EnvironmentMapEffect_VSEnvMap) }, + { EnvironmentMapEffect_VSEnvMapFresnel, sizeof(EnvironmentMapEffect_VSEnvMapFresnel) }, + { EnvironmentMapEffect_VSEnvMapOneLight, sizeof(EnvironmentMapEffect_VSEnvMapOneLight) }, + { EnvironmentMapEffect_VSEnvMapOneLightFresnel, sizeof(EnvironmentMapEffect_VSEnvMapOneLightFresnel) }, +}; + + +const int EffectBase::VertexShaderIndices[] = +{ + 0, // basic + 0, // basic, no fog + 1, // fresnel + 1, // fresnel, no fog + 0, // specular + 0, // specular, no fog + 1, // fresnel + specular + 1, // fresnel + specular, no fog + + 2, // one light + 2, // one light, no fog + 3, // one light, fresnel + 3, // one light, fresnel, no fog + 2, // one light, specular + 2, // one light, specular, no fog + 3, // one light, fresnel + specular + 3, // one light, fresnel + specular, no fog + +}; + + +const ShaderBytecode EffectBase::PixelShaderBytecode[] = +{ + { EnvironmentMapEffect_PSEnvMap, sizeof(EnvironmentMapEffect_PSEnvMap) }, + { EnvironmentMapEffect_PSEnvMapNoFog, sizeof(EnvironmentMapEffect_PSEnvMapNoFog) }, + { EnvironmentMapEffect_PSEnvMapSpecular, sizeof(EnvironmentMapEffect_PSEnvMapSpecular) }, + { EnvironmentMapEffect_PSEnvMapSpecularNoFog, sizeof(EnvironmentMapEffect_PSEnvMapSpecularNoFog) }, +}; + + +const int EffectBase::PixelShaderIndices[] = +{ + 0, // basic + 1, // basic, no fog + 0, // fresnel + 1, // fresnel, no fog + 2, // specular + 3, // specular, no fog + 2, // fresnel + specular + 3, // fresnel + specular, no fog + + 0, // one light + 1, // one light, no fog + 0, // one light, fresnel + 1, // one light, fresnel, no fog + 2, // one light, specular + 3, // one light, specular, no fog + 2, // one light, fresnel + specular + 3, // one light, fresnel + specular, no fog +}; + + +// Global pool of per-device EnvironmentMapEffect resources. +SharedResourcePool::DeviceResources> EffectBase::deviceResourcesPool; + + +// Constructor. +EnvironmentMapEffect::Impl::Impl(_In_ ID3D11Device* device) + : EffectBase(device), + fresnelEnabled(true), + specularEnabled(false) +{ + static_assert( _countof(EffectBase::VertexShaderIndices) == EnvironmentMapEffectTraits::ShaderPermutationCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::VertexShaderBytecode) == EnvironmentMapEffectTraits::VertexShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderBytecode) == EnvironmentMapEffectTraits::PixelShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderIndices) == EnvironmentMapEffectTraits::ShaderPermutationCount, "array/max mismatch" ); + + constants.environmentMapAmount = 1; + constants.fresnelFactor = 1; + + XMVECTOR unwantedOutput[MaxDirectionalLights]; + + lights.InitializeConstants(unwantedOutput[0], constants.lightDirection, constants.lightDiffuseColor, unwantedOutput); +} + + +int EnvironmentMapEffect::Impl::GetCurrentShaderPermutation() const +{ + int permutation = 0; + + // Use optimized shaders if fog is disabled. + if (!fog.enabled) + { + permutation += 1; + } + + // Support fresnel or specular? + if (fresnelEnabled) + { + permutation += 2; + } + + if (specularEnabled) + { + permutation += 4; + } + + // Use the only-bother-with-the-first-light shader optimization? + if (!lights.lightEnabled[1] && !lights.lightEnabled[2]) + { + permutation += 8; + } + + return permutation; +} + + +// Sets our state onto the D3D device. +void EnvironmentMapEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + // Compute derived parameter values. + matrices.SetConstants(dirtyFlags, constants.worldViewProj); + + fog.SetConstants(dirtyFlags, matrices.worldView, constants.fogVector); + + lights.SetConstants(dirtyFlags, matrices, constants.world, constants.worldInverseTranspose, constants.eyePosition, constants.diffuseColor, constants.emissiveColor, true); + + // Set the textures. + ID3D11ShaderResourceView* textures[2] = + { + texture.Get(), + environmentMap.Get(), + }; + + deviceContext->PSSetShaderResources(0, 2, textures); + + // Set shaders and constant buffers. + ApplyShaders(deviceContext, GetCurrentShaderPermutation()); +} + + +// Public constructor. +EnvironmentMapEffect::EnvironmentMapEffect(_In_ ID3D11Device* device) + : pImpl(new Impl(device)) +{ +} + + +// Move constructor. +EnvironmentMapEffect::EnvironmentMapEffect(EnvironmentMapEffect&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +EnvironmentMapEffect& EnvironmentMapEffect::operator= (EnvironmentMapEffect&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +EnvironmentMapEffect::~EnvironmentMapEffect() +{ +} + + +void EnvironmentMapEffect::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + pImpl->Apply(deviceContext); +} + + +void EnvironmentMapEffect::GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) +{ + pImpl->GetVertexShaderBytecode(pImpl->GetCurrentShaderPermutation(), pShaderByteCode, pByteCodeLength); +} + + +void XM_CALLCONV EnvironmentMapEffect::SetWorld(FXMMATRIX value) +{ + pImpl->matrices.world = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::WorldInverseTranspose | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV EnvironmentMapEffect::SetView(FXMMATRIX value) +{ + pImpl->matrices.view = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::EyePosition | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV EnvironmentMapEffect::SetProjection(FXMMATRIX value) +{ + pImpl->matrices.projection = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj; +} + + +void XM_CALLCONV EnvironmentMapEffect::SetDiffuseColor(FXMVECTOR value) +{ + pImpl->lights.diffuseColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void XM_CALLCONV EnvironmentMapEffect::SetEmissiveColor(FXMVECTOR value) +{ + pImpl->lights.emissiveColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void EnvironmentMapEffect::SetAlpha(float value) +{ + pImpl->lights.alpha = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void EnvironmentMapEffect::SetLightingEnabled(bool value) +{ + if (!value) + { + throw std::exception("EnvironmentMapEffect does not support turning off lighting"); + } +} + + +void EnvironmentMapEffect::SetPerPixelLighting(bool) +{ + // Unsupported interface method. +} + + +void XM_CALLCONV EnvironmentMapEffect::SetAmbientLightColor(FXMVECTOR value) +{ + pImpl->lights.ambientLightColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void EnvironmentMapEffect::SetLightEnabled(int whichLight, bool value) +{ + XMVECTOR unwantedOutput[MaxDirectionalLights] = {}; + + pImpl->dirtyFlags |= pImpl->lights.SetLightEnabled(whichLight, value, pImpl->constants.lightDiffuseColor, unwantedOutput); +} + + +void XM_CALLCONV EnvironmentMapEffect::SetLightDirection(int whichLight, FXMVECTOR value) +{ + EffectLights::ValidateLightIndex(whichLight); + + pImpl->constants.lightDirection[whichLight] = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void XM_CALLCONV EnvironmentMapEffect::SetLightDiffuseColor(int whichLight, FXMVECTOR value) +{ + pImpl->dirtyFlags |= pImpl->lights.SetLightDiffuseColor(whichLight, value, pImpl->constants.lightDiffuseColor); +} + + +void XM_CALLCONV EnvironmentMapEffect::SetLightSpecularColor(int, FXMVECTOR) +{ + // Unsupported interface method. +} + + +void EnvironmentMapEffect::EnableDefaultLighting() +{ + EffectLights::EnableDefaultLighting(this); +} + + +void EnvironmentMapEffect::SetFogEnabled(bool value) +{ + pImpl->fog.enabled = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogEnable; +} + + +void EnvironmentMapEffect::SetFogStart(float value) +{ + pImpl->fog.start = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void EnvironmentMapEffect::SetFogEnd(float value) +{ + pImpl->fog.end = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV EnvironmentMapEffect::SetFogColor(FXMVECTOR value) +{ + pImpl->constants.fogColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void EnvironmentMapEffect::SetTexture(_In_opt_ ID3D11ShaderResourceView* value) +{ + pImpl->texture = value; +} + + +void EnvironmentMapEffect::SetEnvironmentMap(_In_opt_ ID3D11ShaderResourceView* value) +{ + pImpl->environmentMap = value; +} + + +void EnvironmentMapEffect::SetEnvironmentMapAmount(float value) +{ + pImpl->constants.environmentMapAmount = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void XM_CALLCONV EnvironmentMapEffect::SetEnvironmentMapSpecular(FXMVECTOR value) +{ + pImpl->constants.environmentMapSpecular = value; + + pImpl->specularEnabled = !XMVector3Equal(value, XMVectorZero()); + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void EnvironmentMapEffect::SetFresnelFactor(float value) +{ + pImpl->constants.fresnelFactor = value; + + pImpl->fresnelEnabled = (value != 0); + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} diff --git a/Kits/DirectXTK/Src/GamePad.cpp b/Kits/DirectXTK/Src/GamePad.cpp new file mode 100644 index 0000000000000000000000000000000000000000..75e1caf0b4d20d6821301c44c99623ebacfd0e99 --- /dev/null +++ b/Kits/DirectXTK/Src/GamePad.cpp @@ -0,0 +1,1207 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" + +#include "GamePad.h" +#include "PlatformHelpers.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +namespace +{ + float ApplyLinearDeadZone( float value, float maxValue, float deadZoneSize ) + { + if ( value < -deadZoneSize ) + { + // Increase negative values to remove the deadzone discontinuity. + value += deadZoneSize; + } + else if ( value > deadZoneSize ) + { + // Decrease positive values to remove the deadzone discontinuity. + value -= deadZoneSize; + } + else + { + // Values inside the deadzone come out zero. + return 0; + } + + // Scale into 0-1 range. + float scaledValue = value / (maxValue - deadZoneSize); + return std::max( -1.f, std::min( scaledValue, 1.f ) ); + } + + void ApplyStickDeadZone( float x, float y, GamePad::DeadZone deadZoneMode, float maxValue, float deadZoneSize, + _Out_ float& resultX, _Out_ float& resultY) + { + switch( deadZoneMode ) + { + 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; + + default: // GamePad::DEAD_ZONE_NONE + resultX = ApplyLinearDeadZone( x, maxValue, 0 ); + resultY = ApplyLinearDeadZone( y, maxValue, 0 ); + break; + } + } +} + + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) + +//====================================================================================== +// Windows::Gaming::Input (Windows 10) +//====================================================================================== + +#include + +class GamePad::Impl +{ +public: + Impl(GamePad* owner) : + mOwner(owner) + { + using namespace Microsoft::WRL; + using namespace Microsoft::WRL::Wrappers; + using namespace ABI::Windows::Foundation; + + mAddedToken.value = 0; + mRemovedToken.value = 0; + + if ( s_gamePad ) + { + throw std::exception( "GamePad is a singleton" ); + } + + s_gamePad = this; + + mChanged.reset( CreateEventEx( nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE ) ); + if ( !mChanged ) + { + throw std::exception( "CreateEventEx" ); + } + + HRESULT hr = GetActivationFactory( HStringReference(RuntimeClass_Windows_Gaming_Input_Gamepad).Get(), mStatics.GetAddressOf() ); + ThrowIfFailed( hr ); + + typedef __FIEventHandler_1_Windows__CGaming__CInput__CGamepad AddedHandler; + hr = mStatics->add_GamepadAdded(Callback(GamepadAdded).Get(), &mAddedToken ); + ThrowIfFailed( hr ); + + typedef __FIEventHandler_1_Windows__CGaming__CInput__CGamepad RemovedHandler; + hr = mStatics->add_GamepadRemoved(Callback(GamepadRemoved).Get(), &mRemovedToken ); + ThrowIfFailed( hr ); + + ScanGamePads(); + } + + ~Impl() + { + if ( mStatics ) + { + mStatics->remove_GamepadAdded( mAddedToken ); + mStatics->remove_GamepadRemoved( mRemovedToken ); + + mStatics.Reset(); + } + + s_gamePad = nullptr; + } + + void GetState( int player, _Out_ State& state, DeadZone deadZoneMode ) + { + using namespace Microsoft::WRL; + using namespace ABI::Windows::Gaming::Input; + + if ( WaitForSingleObjectEx( mChanged.get(), 0, FALSE ) == WAIT_OBJECT_0 ) + { + ScanGamePads(); + } + + if ( ( player >= 0 ) && ( player < MAX_PLAYER_COUNT ) ) + { + if ( mGamePad[ player ] ) + { + GamepadReading reading; + HRESULT hr = mGamePad[ player ]->GetCurrentReading( &reading ); + if ( SUCCEEDED(hr) ) + { + state.connected = true; + state.packet = reading.Timestamp; + + state.buttons.a = (reading.Buttons & GamepadButtons::GamepadButtons_A) != 0; + state.buttons.b = (reading.Buttons & GamepadButtons::GamepadButtons_B) != 0; + state.buttons.x = (reading.Buttons & GamepadButtons::GamepadButtons_X) != 0; + state.buttons.y = (reading.Buttons & GamepadButtons::GamepadButtons_Y) != 0; + + state.buttons.leftStick = (reading.Buttons & GamepadButtons::GamepadButtons_LeftThumbstick) != 0; + state.buttons.rightStick = (reading.Buttons & GamepadButtons::GamepadButtons_RightThumbstick) != 0; + + state.buttons.leftShoulder = (reading.Buttons & GamepadButtons::GamepadButtons_LeftShoulder) != 0; + state.buttons.rightShoulder = (reading.Buttons & GamepadButtons::GamepadButtons_RightShoulder) != 0; + + state.buttons.back = (reading.Buttons & GamepadButtons::GamepadButtons_View) != 0; + state.buttons.start = (reading.Buttons & GamepadButtons::GamepadButtons_Menu) != 0; + + state.dpad.up = (reading.Buttons & GamepadButtons::GamepadButtons_DPadUp) != 0; + state.dpad.down = (reading.Buttons & GamepadButtons::GamepadButtons_DPadDown) != 0; + state.dpad.right = (reading.Buttons & GamepadButtons::GamepadButtons_DPadRight) != 0; + state.dpad.left = (reading.Buttons & GamepadButtons::GamepadButtons_DPadLeft) != 0; + + ApplyStickDeadZone( static_cast(reading.LeftThumbstickX), static_cast(reading.LeftThumbstickY), + deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */, + static_cast(state.thumbSticks.leftX), static_cast(state.thumbSticks.leftY) ); + + ApplyStickDeadZone( static_cast(reading.RightThumbstickX), static_cast(reading.RightThumbstickY), + deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */, + static_cast(state.thumbSticks.rightX), static_cast(state.thumbSticks.rightY) ); + + state.triggers.left = static_cast(reading.LeftTrigger); + state.triggers.right = static_cast(reading.RightTrigger); + + return; + } + } + } + + memset( &state, 0, sizeof(State) ); + } + + void GetCapabilities( int player, _Out_ Capabilities& caps ) + { + if ( WaitForSingleObjectEx( mChanged.get(), 0, FALSE ) == WAIT_OBJECT_0 ) + { + ScanGamePads(); + } + + if ( ( player >= 0 ) && ( player < MAX_PLAYER_COUNT ) ) + { + if ( mGamePad[ player ] ) + { + caps.connected = true; + caps.gamepadType = Capabilities::GAMEPAD; + caps.id = 0; + return; + } + } + + memset( &caps, 0, sizeof(Capabilities) ); + } + + bool SetVibration( int player, float leftMotor, float rightMotor, float leftTrigger, float rightTrigger ) + { + using namespace ABI::Windows::Gaming::Input; + + if ( ( player >= 0 ) && ( player < MAX_PLAYER_COUNT ) ) + { + if ( mGamePad[ player ] ) + { + GamepadVibration vib; + vib.LeftMotor = leftMotor; + vib.RightMotor = rightMotor; + vib.LeftTrigger = leftTrigger; + vib.RightTrigger = rightTrigger; + HRESULT hr = mGamePad[ player ]->put_Vibration(vib); + + if ( SUCCEEDED(hr) ) + return true; + } + } + + return false; + } + + void Suspend() + { + for( size_t j = 0; j < MAX_PLAYER_COUNT; ++j ) + { + mGamePad[ j ].Reset(); + } + } + + void Resume() + { + // Make sure we rescan gamepads + SetEvent( mChanged.get() ); + } + + GamePad* mOwner; + + static GamePad::Impl* s_gamePad; + +private: + void ScanGamePads() + { + using namespace ABI::Windows::Foundation::Collections; + using namespace ABI::Windows::Gaming::Input; + + ComPtr> pads; + HRESULT hr = mStatics->get_Gamepads( pads.GetAddressOf() ); + ThrowIfFailed( hr ); + + unsigned int count = 0; + hr = pads->get_Size( &count ); + ThrowIfFailed( hr ); + + // Check for removed gamepads + for( size_t j = 0; j < MAX_PLAYER_COUNT; ++j ) + { + if ( mGamePad[ j ] ) + { + unsigned int k = 0; + for( ; k < count; ++k ) + { + ComPtr pad; + hr = pads->GetAt( k, pad.GetAddressOf() ); + if ( SUCCEEDED(hr) && ( pad == mGamePad[ j ] ) ) + { + break; + } + } + + if ( k >= count ) + { + mGamePad[ j ].Reset(); + } + } + } + + // Check for added gamepads + for( unsigned int j = 0; j < count; ++j ) + { + ComPtr pad; + hr = pads->GetAt( j, pad.GetAddressOf() ); + if ( SUCCEEDED(hr) ) + { + size_t empty = MAX_PLAYER_COUNT; + size_t k = 0; + for( ; k < MAX_PLAYER_COUNT; ++k ) + { + if ( mGamePad[ k ] == pad ) + { + break; + } + else if ( !mGamePad[ k ] ) + { + if ( empty >= MAX_PLAYER_COUNT ) + empty = k; + } + } + + if ( k >= MAX_PLAYER_COUNT ) + { + // Silently ignore "extra" gamepads as there's no hard limit + if ( empty < MAX_PLAYER_COUNT ) + { + mGamePad[ empty ] = pad; + } + } + } + } + } + + ComPtr mStatics; + ComPtr mGamePad[ MAX_PLAYER_COUNT ]; + + EventRegistrationToken mAddedToken; + EventRegistrationToken mRemovedToken; + + ScopedHandle mChanged; + + static HRESULT GamepadAdded( IInspectable *, ABI::Windows::Gaming::Input::IGamepad* ) + { + if ( s_gamePad ) + { + SetEvent( s_gamePad->mChanged.get() ); + } + return S_OK; + } + + static HRESULT GamepadRemoved( IInspectable *, ABI::Windows::Gaming::Input::IGamepad* ) + { + if ( s_gamePad ) + { + SetEvent( s_gamePad->mChanged.get() ); + } + return S_OK; + } +}; + +GamePad::Impl* GamePad::Impl::s_gamePad = nullptr; + +#elif defined(_XBOX_ONE) + +//====================================================================================== +// Windows::Xbox::Input (Xbox One) +//====================================================================================== + +#include + +#ifdef _TITLE +#include + +namespace +{ + +class GamepadAddedListener : public Microsoft::WRL::RuntimeClass, + ABI::Windows::Foundation::IEventHandler, + Microsoft::WRL::FtmBase> +{ +public: + GamepadAddedListener(HANDLE event) : mEvent(event) {} + + STDMETHOD(Invoke)(_In_ IInspectable *, _In_ ABI::Windows::Xbox::Input::IGamepadAddedEventArgs * ) override + { + SetEvent( mEvent ); + return S_OK; + } + +private: + HANDLE mEvent; +}; + +class GamepadRemovedListener : public Microsoft::WRL::RuntimeClass, + ABI::Windows::Foundation::IEventHandler, + Microsoft::WRL::FtmBase> +{ +public: + GamepadRemovedListener(HANDLE event) : mEvent(event) {} + + STDMETHOD(Invoke)(_In_ IInspectable *, _In_ ABI::Windows::Xbox::Input::IGamepadRemovedEventArgs * ) override + { + SetEvent( mEvent ); + return S_OK; + } + +private: + HANDLE mEvent; +}; + +} +#endif + +class GamePad::Impl +{ +public: + Impl(GamePad *owner) : + mOwner(owner) + { + using namespace Microsoft::WRL; + using namespace Microsoft::WRL::Wrappers; + using namespace ABI::Windows::Foundation; + + mAddedToken.value = 0; + mRemovedToken.value = 0; + + if ( s_gamePad ) + { + throw std::exception( "GamePad is a singleton" ); + } + + s_gamePad = this; + + mChanged.reset( CreateEventEx( nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE ) ); + if ( !mChanged ) + { + throw std::exception( "CreateEventEx" ); + } + + HRESULT hr = GetActivationFactory( HStringReference(RuntimeClass_Windows_Xbox_Input_Gamepad).Get(), mStatics.GetAddressOf() ); + ThrowIfFailed( hr ); + +#ifdef _TITLE + // This is a workaround for some registration issues in the GameOS + + hr = mStatics->add_GamepadAdded(Make(mChanged.get()).Get(), &mAddedToken ); + ThrowIfFailed( hr ); + + hr = mStatics->add_GamepadRemoved(Make(mChanged.get()).Get(), &mRemovedToken ); + ThrowIfFailed( hr ); +#else + typedef __FIEventHandler_1_Windows__CXbox__CInput__CGamepadAddedEventArgs AddedHandler; + hr = mStatics->add_GamepadAdded(Callback(GamepadAdded).Get(), &mAddedToken ); + ThrowIfFailed( hr ); + + typedef __FIEventHandler_1_Windows__CXbox__CInput__CGamepadRemovedEventArgs RemovedHandler; + hr = mStatics->add_GamepadRemoved(Callback(GamepadRemoved).Get(), &mRemovedToken ); + ThrowIfFailed( hr ); +#endif + + ScanGamePads(); + } + + ~Impl() + { + if ( mStatics ) + { + mStatics->remove_GamepadAdded( mAddedToken ); + mStatics->remove_GamepadRemoved( mRemovedToken ); + + mStatics.Reset(); + } + + s_gamePad = nullptr; + } + + void GetState( int player, _Out_ State& state, DeadZone deadZoneMode ) + { + using namespace Microsoft::WRL; + using namespace ABI::Windows::Xbox::Input; + + if ( WaitForSingleObjectEx( mChanged.get(), 0, FALSE ) == WAIT_OBJECT_0 ) + { + ScanGamePads(); + } + + if ( ( player >= 0 ) && ( player < MAX_PLAYER_COUNT ) ) + { + if ( mGamePad[ player ] ) + { + RawGamepadReading reading; + HRESULT hr = mGamePad[ player ]->GetRawCurrentReading( &reading ); + if ( SUCCEEDED(hr) ) + { + state.connected = true; + state.packet = reading.Timestamp; + + state.buttons.a = (reading.Buttons & GamepadButtons::GamepadButtons_A) != 0; + state.buttons.b = (reading.Buttons & GamepadButtons::GamepadButtons_B) != 0; + state.buttons.x = (reading.Buttons & GamepadButtons::GamepadButtons_X) != 0; + state.buttons.y = (reading.Buttons & GamepadButtons::GamepadButtons_Y) != 0; + + state.buttons.leftStick = (reading.Buttons & GamepadButtons::GamepadButtons_LeftThumbstick) != 0; + state.buttons.rightStick = (reading.Buttons & GamepadButtons::GamepadButtons_RightThumbstick) != 0; + + state.buttons.leftShoulder = (reading.Buttons & GamepadButtons::GamepadButtons_LeftShoulder) != 0; + state.buttons.rightShoulder = (reading.Buttons & GamepadButtons::GamepadButtons_RightShoulder) != 0; + + state.buttons.back = (reading.Buttons & GamepadButtons::GamepadButtons_View) != 0; + state.buttons.start = (reading.Buttons & GamepadButtons::GamepadButtons_Menu) != 0; + + state.dpad.up = (reading.Buttons & GamepadButtons::GamepadButtons_DPadUp) != 0; + state.dpad.down = (reading.Buttons & GamepadButtons::GamepadButtons_DPadDown) != 0; + state.dpad.right = (reading.Buttons & GamepadButtons::GamepadButtons_DPadRight) != 0; + 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 ); + + ApplyStickDeadZone( reading.RightThumbstickX, reading.RightThumbstickY, + deadZoneMode, 1.f, .24f /* Recommended Xbox One deadzone */, + state.thumbSticks.rightX, state.thumbSticks.rightY ); + + state.triggers.left = reading.LeftTrigger; + state.triggers.right = reading.RightTrigger; + + return; + } + } + } + + memset( &state, 0, sizeof(State) ); + } + + void GetCapabilities( int player, _Out_ Capabilities& caps ) + { + using namespace ABI::Windows::Xbox::Input; + + if ( WaitForSingleObjectEx( mChanged.get(), 0, FALSE ) == WAIT_OBJECT_0 ) + { + ScanGamePads(); + } + + if ( ( player >= 0 ) && ( player < MAX_PLAYER_COUNT ) ) + { + if ( mGamePad[ player ] ) + { + caps.connected = true; + caps.gamepadType = Capabilities::GAMEPAD; + + ComPtr ctrl; + HRESULT hr = mGamePad[ player ].As( &ctrl ); + if ( SUCCEEDED(hr) && ctrl ) + { + hr = ctrl->get_Id( &caps.id ); + if ( FAILED(hr) ) + caps.id = 0; + } + else + caps.id = 0; + + return; + } + } + + memset( &caps, 0, sizeof(Capabilities) ); + } + + bool SetVibration( int player, float leftMotor, float rightMotor, float leftTrigger, float rightTrigger ) + { + using namespace ABI::Windows::Xbox::Input; + + if ( ( player >= 0 ) && ( player < MAX_PLAYER_COUNT ) ) + { + if ( mGamePad[ player ] ) + { + HRESULT hr; + try + { + GamepadVibration vib; + vib.LeftMotorLevel = leftMotor; + vib.RightMotorLevel = rightMotor; + vib.LeftTriggerLevel = leftTrigger; + vib.RightTriggerLevel = rightTrigger; + hr = mGamePad[ player ]->SetVibration(vib); + } + catch( ... ) + { + // Handle case where gamepad might be invalid + hr = E_FAIL; + } + + if ( SUCCEEDED(hr) ) + return true; + } + } + + return false; + } + + void Suspend() + { + for( size_t j = 0; j < MAX_PLAYER_COUNT; ++j ) + { + mGamePad[ j ].Reset(); + } + } + + void Resume() + { + // Make sure we rescan gamepads + SetEvent( mChanged.get() ); + } + + GamePad* mOwner; + + static GamePad::Impl* s_gamePad; + +private: + void ScanGamePads() + { + using namespace ABI::Windows::Foundation::Collections; + using namespace ABI::Windows::Xbox::Input; + + ComPtr> pads; + HRESULT hr = mStatics->get_Gamepads( pads.GetAddressOf() ); + ThrowIfFailed( hr ); + + unsigned int count = 0; + hr = pads->get_Size( &count ); + ThrowIfFailed( hr ); + + // Check for removed gamepads + for( size_t j = 0; j < MAX_PLAYER_COUNT; ++j ) + { + if ( mGamePad[ j ] ) + { + unsigned int k = 0; + for( ; k < count; ++k ) + { + ComPtr pad; + hr = pads->GetAt( k, pad.GetAddressOf() ); + if ( SUCCEEDED(hr) && ( pad == mGamePad[ j ] ) ) + { + break; + } + } + + if ( k >= count ) + { + mGamePad[ j ].Reset(); + } + } + } + + // Check for added gamepads + for( unsigned int j = 0; j < count; ++j ) + { + ComPtr pad; + hr = pads->GetAt( j, pad.GetAddressOf() ); + if ( SUCCEEDED(hr) ) + { + size_t empty = MAX_PLAYER_COUNT; + size_t k = 0; + for( ; k < MAX_PLAYER_COUNT; ++k ) + { + if ( mGamePad[ k ] == pad ) + { + break; + } + else if ( !mGamePad[ k ] ) + { + if ( empty >= MAX_PLAYER_COUNT ) + empty = k; + } + } + + if ( k >= MAX_PLAYER_COUNT ) + { + if ( empty >= MAX_PLAYER_COUNT ) + { + throw std::exception( "Too many gamepads found" ); + } + + mGamePad[ empty ] = pad; + } + } + } + } + + ComPtr mStatics; + ComPtr mGamePad[ MAX_PLAYER_COUNT ]; + + EventRegistrationToken mAddedToken; + EventRegistrationToken mRemovedToken; + + ScopedHandle mChanged; + +#ifndef _TITLE + static HRESULT GamepadAdded( IInspectable *, ABI::Windows::Xbox::Input::IGamepadAddedEventArgs * ) + { + if ( s_gamePad ) + { + SetEvent( s_gamePad->mChanged.get() ); + } + return S_OK; + } + + static HRESULT GamepadRemoved( IInspectable *, ABI::Windows::Xbox::Input::IGamepadRemovedEventArgs* ) + { + if ( s_gamePad ) + { + SetEvent( s_gamePad->mChanged.get() ); + } + return S_OK; + } +#endif +}; + +GamePad::Impl* GamePad::Impl::s_gamePad = nullptr; + + +#elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) + +//====================================================================================== +// Null device for Windows Phone +//====================================================================================== + +class GamePad::Impl +{ +public: + Impl(GamePad* owner) : + mOwner(owner) + { + if ( s_gamePad ) + { + throw std::exception( "GamePad is a singleton" ); + } + + s_gamePad = this; + } + + ~Impl() + { + s_gamePad = nullptr; + } + + void GetState(int player, _Out_ State& state, DeadZone) + { + UNREFERENCED_PARAMETER(player); + + memset( &state, 0, sizeof(State) ); + } + + void GetCapabilities(int player, _Out_ Capabilities& caps) + { + UNREFERENCED_PARAMETER(player); + + memset( &caps, 0, sizeof(Capabilities) ); + } + + bool SetVibration(int player, float leftMotor, float rightMotor, float leftTrigger, float rightTrigger) + { + UNREFERENCED_PARAMETER(player); + UNREFERENCED_PARAMETER(leftMotor); + UNREFERENCED_PARAMETER(rightMotor); + UNREFERENCED_PARAMETER(leftTrigger); + UNREFERENCED_PARAMETER(rightTrigger); + + return false; + } + + void Suspend() + { + } + + void Resume() + { + } + + GamePad* mOwner; + + static GamePad::Impl* s_gamePad; +}; + +GamePad::Impl* GamePad::Impl::s_gamePad = nullptr; + + +#else + +//====================================================================================== +// XInput +//====================================================================================== + +#include + +static_assert( GamePad::MAX_PLAYER_COUNT == XUSER_MAX_COUNT, "xinput.h mismatch" ); + +class GamePad::Impl +{ +public: + Impl(GamePad* owner) : + mOwner(owner) + { + for( int j = 0; j < XUSER_MAX_COUNT; ++j ) + { + ClearSlot( j, 0 ); + } + +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + mSuspended = false; +#endif + + if ( s_gamePad ) + { + throw std::exception( "GamePad is a singleton" ); + } + + s_gamePad = this; + } + + ~Impl() + { + s_gamePad = nullptr; + } + + void GetState( int player, _Out_ State& state, DeadZone deadZoneMode ) + { + if ( !ThrottleRetry(player) ) + { +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + if ( mSuspended ) + { + memset( &state, 0, sizeof(State) ); + state.connected = mConnected[ player ]; + return; + } +#endif + + XINPUT_STATE xstate; + DWORD result = XInputGetState( DWORD(player), &xstate ); + if ( result == ERROR_DEVICE_NOT_CONNECTED ) + { + ClearSlot( player, GetTickCount64() ); + } + else + { + mConnected[ player ] = true; + + state.connected = true; + state.packet = xstate.dwPacketNumber; + + WORD xbuttons = xstate.Gamepad.wButtons; + state.buttons.a = (xbuttons & XINPUT_GAMEPAD_A) != 0; + state.buttons.b = (xbuttons & XINPUT_GAMEPAD_B) != 0; + state.buttons.x = (xbuttons & XINPUT_GAMEPAD_X) != 0; + state.buttons.y = (xbuttons & XINPUT_GAMEPAD_Y) != 0; + state.buttons.leftStick = (xbuttons & XINPUT_GAMEPAD_LEFT_THUMB) != 0; + state.buttons.rightStick = (xbuttons & XINPUT_GAMEPAD_RIGHT_THUMB) != 0; + state.buttons.leftShoulder = (xbuttons & XINPUT_GAMEPAD_LEFT_SHOULDER) != 0; + state.buttons.rightShoulder = (xbuttons & XINPUT_GAMEPAD_RIGHT_SHOULDER) != 0; + state.buttons.back = (xbuttons & XINPUT_GAMEPAD_BACK) != 0; + state.buttons.start = (xbuttons & XINPUT_GAMEPAD_START) != 0; + + state.dpad.up = (xbuttons & XINPUT_GAMEPAD_DPAD_UP) != 0; + state.dpad.down = (xbuttons & XINPUT_GAMEPAD_DPAD_DOWN) != 0; + state.dpad.right = (xbuttons & XINPUT_GAMEPAD_DPAD_RIGHT) != 0; + state.dpad.left = (xbuttons & XINPUT_GAMEPAD_DPAD_LEFT) != 0; + + if ( deadZoneMode == DEAD_ZONE_NONE ) + { + state.triggers.left = ApplyLinearDeadZone( float(xstate.Gamepad.bLeftTrigger), 255.f, 0.f ); + state.triggers.right = ApplyLinearDeadZone( float(xstate.Gamepad.bRightTrigger), 255.f, 0.f ); + } + else + { + state.triggers.left = ApplyLinearDeadZone( float(xstate.Gamepad.bLeftTrigger), 255.f, float(XINPUT_GAMEPAD_TRIGGER_THRESHOLD) ); + state.triggers.right = ApplyLinearDeadZone( float(xstate.Gamepad.bRightTrigger), 255.f, float(XINPUT_GAMEPAD_TRIGGER_THRESHOLD) ); + } + + ApplyStickDeadZone( float(xstate.Gamepad.sThumbLX), float(xstate.Gamepad.sThumbLY), + 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 ); + + return; + } + } + + memset( &state, 0, sizeof(State) ); + } + + void GetCapabilities( int player, _Out_ Capabilities& caps ) + { + if ( !ThrottleRetry(player) ) + { + XINPUT_CAPABILITIES xcaps; + DWORD result = XInputGetCapabilities( DWORD(player), 0, &xcaps ); + if ( result == ERROR_DEVICE_NOT_CONNECTED ) + { + ClearSlot( player, GetTickCount64() ); + } + else + { + mConnected[ player ] = true; + + caps.connected = true; + caps.id = uint64_t( player ); + if ( xcaps.Type == XINPUT_DEVTYPE_GAMEPAD ) + { + static_assert(Capabilities::GAMEPAD == XINPUT_DEVSUBTYPE_GAMEPAD, "xinput.h mismatch"); +#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"); + static_assert( XINPUT_DEVSUBTYPE_DANCE_PAD == Capabilities::DANCE_PAD, "xinput.h mismatch"); + static_assert( XINPUT_DEVSUBTYPE_GUITAR == Capabilities::GUITAR, "xinput.h mismatch"); + static_assert( XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE == Capabilities::GUITAR_ALTERNATE, "xinput.h mismatch"); + 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 + + caps.gamepadType = Capabilities::Type(xcaps.SubType); + } + + return; + } + } + + memset( &caps, 0, sizeof(Capabilities) ); + } + + bool SetVibration( int player, float leftMotor, float rightMotor, float leftTrigger, float rightTrigger ) + { + if ( ThrottleRetry(player) ) + { + return false; + } + + // XInput does not provide a way to set the left/right trigger impulse motors on the Xbox One Controller, + // and these motors are not present on the Xbox 360 Common Controller + UNREFERENCED_PARAMETER(leftTrigger); + UNREFERENCED_PARAMETER(rightTrigger); + +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + mLeftMotor[ player ] = leftMotor; + mRightMotor[ player ] = rightMotor; + + if ( mSuspended ) + return mConnected[ player ]; +#endif + + XINPUT_VIBRATION xvibration; + xvibration.wLeftMotorSpeed = WORD( leftMotor * 0xFFFF ); + xvibration.wRightMotorSpeed = WORD( rightMotor * 0xFFFF ); + DWORD result = XInputSetState( DWORD(player), &xvibration ); + if ( result == ERROR_DEVICE_NOT_CONNECTED ) + { + ClearSlot( player, GetTickCount64() ); + return false; + } + else + { + mConnected[ player ] = true; + return (result == ERROR_SUCCESS); + } + } + + void Suspend() + { +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + 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 ) + { + if ( mConnected[ j ] ) + { + XINPUT_VIBRATION xvibration; + xvibration.wLeftMotorSpeed = xvibration.wRightMotorSpeed = 0; + (void)XInputSetState( DWORD(j), &xvibration ); + } + } + + mSuspended = true; + } +#endif + } + + void Resume() + { +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) + XInputEnable( TRUE ); +#else + // For XInput 9.1.0, we have to emulate the behavior of XInputEnable( TRUE ) + if ( mSuspended ) + { + for( int j = 0; j < XUSER_MAX_COUNT; ++j ) + { + if ( mConnected[ j ] ) + { + XINPUT_VIBRATION xvibration; + xvibration.wLeftMotorSpeed = WORD( mLeftMotor[ j ] * 0xFFFF ); + xvibration.wRightMotorSpeed = WORD( mRightMotor[ j ] * 0xFFFF ); + DWORD result = XInputSetState( DWORD(j), &xvibration ); + if ( result == ERROR_DEVICE_NOT_CONNECTED ) + { + ClearSlot( j, GetTickCount64() ); + } + } + } + + mSuspended = false; + } +#endif + } + + GamePad* mOwner; + + static GamePad::Impl* s_gamePad; + +private: + bool mConnected[ XUSER_MAX_COUNT ]; + ULONGLONG mLastReadTime[ XUSER_MAX_COUNT ]; + +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + // Variables for emulating XInputEnable on XInput 9.1.0 + float mLeftMotor[ XUSER_MAX_COUNT ]; + float mRightMotor[ XUSER_MAX_COUNT ]; + bool mSuspended; +#endif + + bool ThrottleRetry( int player ) + { + // This function minimizes a potential performance issue with XInput on Windows when + // checking a disconnected controller slot which requires device enumeration. + // This throttling keeps checks for newly connected gamepads to about once a second + + if ( ( player < 0 ) || ( player >= XUSER_MAX_COUNT ) ) + return true; + + if ( mConnected[ player ] ) + return false; + + ULONGLONG time = GetTickCount64(); + + for( size_t j = 0; j < XUSER_MAX_COUNT; ++j ) + { + if ( !mConnected[j] ) + { + LONGLONG delta = time - mLastReadTime[j]; + + LONGLONG interval = 1000; + if ( (int)j != player ) + interval /= 4; + + if ( (delta >= 0) && (delta < interval) ) + return true; + } + } + + return false; + } + + void ClearSlot( int player, ULONGLONG time ) + { + mConnected[ player ] = false; + mLastReadTime[ player ] = time; +#if (_WIN32_WINNT < _WIN32_WINNT_WIN8) + mLeftMotor[ player ] = mRightMotor[ player ] = 0.f; +#endif + } +}; + +GamePad::Impl* GamePad::Impl::s_gamePad = nullptr; + +#endif + +#pragma warning( disable : 4355 ) + +// Public constructor. +GamePad::GamePad() + : pImpl( new Impl(this) ) +{ +} + + +// Move constructor. +GamePad::GamePad(GamePad&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ + pImpl->mOwner = this; +} + + +// Move assignment. +GamePad& GamePad::operator= (GamePad&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + pImpl->mOwner = this; + return *this; +} + + +// Public destructor. +GamePad::~GamePad() +{ +} + + +GamePad::State GamePad::GetState(int player, DeadZone deadZoneMode) +{ + State state; + pImpl->GetState(player, state, deadZoneMode); + return state; +} + + +GamePad::Capabilities GamePad::GetCapabilities(int player) +{ + Capabilities caps; + pImpl->GetCapabilities(player, caps); + return caps; +} + + +bool GamePad::SetVibration( int player, float leftMotor, float rightMotor, float leftTrigger, float rightTrigger ) +{ + return pImpl->SetVibration( player, leftMotor, rightMotor, leftTrigger, rightTrigger ); +} + + +void GamePad::Suspend() +{ + pImpl->Suspend(); +} + + +void GamePad::Resume() +{ + pImpl->Resume(); +} + + +GamePad& GamePad::Get() +{ + if ( !Impl::s_gamePad || !Impl::s_gamePad->mOwner ) + throw std::exception( "GamePad is a singleton" ); + + return *Impl::s_gamePad->mOwner; +} + + + +//====================================================================================== +// ButtonStateTracker +//====================================================================================== + +#define UPDATE_BUTTON_STATE(field) field = static_cast( ( !!state.buttons.field ) | ( ( !!state.buttons.field ^ !!lastState.buttons.field ) << 1 ) ); + +void GamePad::ButtonStateTracker::Update( const GamePad::State& state ) +{ + UPDATE_BUTTON_STATE(a); + + assert( ( !state.buttons.a && !lastState.buttons.a ) == ( a == UP ) ); + assert( ( state.buttons.a && lastState.buttons.a ) == ( a == HELD ) ); + assert( ( !state.buttons.a && lastState.buttons.a ) == ( a == RELEASED ) ); + assert( ( state.buttons.a && !lastState.buttons.a ) == ( a == PRESSED ) ); + + UPDATE_BUTTON_STATE(b); + UPDATE_BUTTON_STATE(x); + UPDATE_BUTTON_STATE(y); + + UPDATE_BUTTON_STATE(leftStick); + UPDATE_BUTTON_STATE(rightStick); + + UPDATE_BUTTON_STATE(leftShoulder); + UPDATE_BUTTON_STATE(rightShoulder); + + UPDATE_BUTTON_STATE(back); + UPDATE_BUTTON_STATE(start); + + dpadUp = static_cast( ( !!state.dpad.up ) | ( ( !!state.dpad.up ^ !!lastState.dpad.up ) << 1 ) ); + dpadDown = static_cast( ( !!state.dpad.down ) | ( ( !!state.dpad.down ^ !!lastState.dpad.down ) << 1 ) ); + dpadLeft = static_cast( ( !!state.dpad.left ) | ( ( !!state.dpad.left ^ !!lastState.dpad.left ) << 1 ) ); + dpadRight = static_cast( ( !!state.dpad.right ) | ( ( !!state.dpad.right ^ !!lastState.dpad.right ) << 1 ) ); + + assert( ( !state.dpad.up && !lastState.dpad.up ) == ( dpadUp == UP ) ); + assert( ( state.dpad.up && lastState.dpad.up ) == ( dpadUp == HELD ) ); + assert( ( !state.dpad.up && lastState.dpad.up ) == ( dpadUp == RELEASED ) ); + assert( ( state.dpad.up && !lastState.dpad.up ) == ( dpadUp == PRESSED ) ); + + lastState = state; +} + +#undef UPDATE_BUTTON_STATE + + +void GamePad::ButtonStateTracker::Reset() +{ + memset( this, 0, sizeof(ButtonStateTracker) ); +} diff --git a/Kits/DirectXTK/Src/GeometricPrimitive.cpp b/Kits/DirectXTK/Src/GeometricPrimitive.cpp new file mode 100644 index 0000000000000000000000000000000000000000..af3c6816c145120f23233076a9a6437b6822a1fc --- /dev/null +++ b/Kits/DirectXTK/Src/GeometricPrimitive.cpp @@ -0,0 +1,1715 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "GeometricPrimitive.h" +#include "Effects.h" +#include "CommonStates.h" +#include "DirectXHelpers.h" +#include "VertexTypes.h" +#include "SharedResourcePool.h" +#include "Bezier.h" + +#include + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +namespace +{ + static const float SQRT2 = 1.41421356237309504880f; + static const float SQRT3 = 1.73205080756887729352f; + static const float SQRT6 = 2.44948974278317809820f; + + + void CheckIndexOverflow(size_t value) + { + // Use >=, not > comparison, because some D3D level 9_x hardware does not support 0xFFFF index values. + if (value >= USHRT_MAX) + throw std::exception("Index value out of range: cannot tesselate primitive so finely"); + } + + + // Collection types used when generating the geometry. + typedef std::vector VertexCollection; + typedef std::vector IndexCollection; + + inline void index_push_back(IndexCollection& indices, size_t value) + { + CheckIndexOverflow(value); + indices.push_back((uint16_t)value); + } + + + // Helper for flipping winding of geometric primitives for LH vs. RH coords + static void ReverseWinding( IndexCollection& indices, VertexCollection& vertices ) + { + assert( (indices.size() % 3) == 0 ); + for( auto it = indices.begin(); it != indices.end(); it += 3 ) + { + std::swap( *it, *(it+2) ); + } + + for( auto it = vertices.begin(); it != vertices.end(); ++it ) + { + it->textureCoordinate.x = ( 1.f - it->textureCoordinate.x ); + } + } + + + // Helper for inverting normals of geometric primitives for 'inside' vs. 'outside' viewing + static void InvertNormals( VertexCollection& vertices ) + { + for( auto it = vertices.begin(); it != vertices.end(); ++it ) + { + it->normal.x = -it->normal.x; + it->normal.y = -it->normal.y; + it->normal.z = -it->normal.z; + } + } + + + // Helper for creating a D3D vertex or index buffer. + template + static void CreateBuffer(_In_ ID3D11Device* device, T const& data, D3D11_BIND_FLAG bindFlags, _Outptr_ ID3D11Buffer** pBuffer) + { + assert( pBuffer != 0 ); + + D3D11_BUFFER_DESC bufferDesc = { 0 }; + + bufferDesc.ByteWidth = (UINT)data.size() * sizeof(T::value_type); + bufferDesc.BindFlags = bindFlags; + bufferDesc.Usage = D3D11_USAGE_DEFAULT; + + D3D11_SUBRESOURCE_DATA dataDesc = { 0 }; + + dataDesc.pSysMem = data.data(); + + ThrowIfFailed( + device->CreateBuffer(&bufferDesc, &dataDesc, pBuffer) + ); + + SetDebugObjectName(*pBuffer, "DirectXTK:GeometricPrimitive"); + } + + + // Helper for creating a D3D input layout. + static void CreateInputLayout(_In_ ID3D11Device* device, IEffect* effect, _Outptr_ ID3D11InputLayout** pInputLayout) + { + assert( pInputLayout != 0 ); + + void const* shaderByteCode; + size_t byteCodeLength; + + effect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength); + + ThrowIfFailed( + device->CreateInputLayout(VertexPositionNormalTexture::InputElements, + VertexPositionNormalTexture::InputElementCount, + shaderByteCode, byteCodeLength, + pInputLayout) + ); + + SetDebugObjectName(*pInputLayout, "DirectXTK:GeometricPrimitive"); + } +} + + +// Internal GeometricPrimitive implementation class. +class GeometricPrimitive::Impl +{ +public: + 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, _In_opt_ std::function setCustomState); + + void Draw(_In_ IEffect* effect, _In_ ID3D11InputLayout* inputLayout, bool alpha, bool wireframe, _In_opt_ std::function setCustomState); + + void CreateInputLayout(_In_ IEffect* effect, _Outptr_ ID3D11InputLayout** inputLayout); + +private: + ComPtr mVertexBuffer; + ComPtr mIndexBuffer; + + UINT mIndexCount; + + // Only one of these helpers is allocated per D3D device context, even if there are multiple GeometricPrimitive instances. + class SharedResources + { + public: + SharedResources(_In_ ID3D11DeviceContext* deviceContext); + + void PrepareForRendering(bool alpha, bool wireframe); + + ComPtr deviceContext; + std::unique_ptr effect; + + ComPtr inputLayoutTextured; + ComPtr inputLayoutUntextured; + + std::unique_ptr stateObjects; + }; + + + // Per-device-context data. + std::shared_ptr mResources; + + static SharedResourcePool sharedResourcesPool; +}; + + +// Global pool of per-device-context GeometricPrimitive resources. +SharedResourcePool GeometricPrimitive::Impl::sharedResourcesPool; + + +// Per-device-context constructor. +GeometricPrimitive::Impl::SharedResources::SharedResources(_In_ ID3D11DeviceContext* deviceContext) + : deviceContext(deviceContext) +{ + ComPtr device; + deviceContext->GetDevice(&device); + + // Create the BasicEffect. + effect.reset(new BasicEffect(device.Get())); + + effect->EnableDefaultLighting(); + + // Create state objects. + stateObjects.reset(new CommonStates(device.Get())); + + // Create input layouts. + effect->SetTextureEnabled(true); + ::CreateInputLayout(device.Get(), effect.get(), &inputLayoutTextured); + + effect->SetTextureEnabled(false); + ::CreateInputLayout(device.Get(), effect.get(), &inputLayoutUntextured); +} + + +// Sets up D3D device state ready for drawing a primitive. +void GeometricPrimitive::Impl::SharedResources::PrepareForRendering(bool alpha, bool wireframe) +{ + // Set the blend and depth stencil state. + ID3D11BlendState* blendState; + ID3D11DepthStencilState* depthStencilState; + + if (alpha) + { + // Alpha blended rendering. + blendState = stateObjects->AlphaBlend(); + depthStencilState = stateObjects->DepthRead(); + } + else + { + // Opaque rendering. + blendState = stateObjects->Opaque(); + depthStencilState = stateObjects->DepthDefault(); + } + + deviceContext->OMSetBlendState(blendState, nullptr, 0xFFFFFFFF); + deviceContext->OMSetDepthStencilState(depthStencilState, 0); + + // Set the rasterizer state. + if ( wireframe ) + deviceContext->RSSetState( stateObjects->Wireframe() ); + else + deviceContext->RSSetState( stateObjects->CullCounterClockwise() ); + + ID3D11SamplerState* samplerState = stateObjects->LinearWrap(); + + deviceContext->PSSetSamplers(0, 1, &samplerState); +} + + +// Initializes a geometric primitive instance that will draw the specified vertex and index data. +_Use_decl_annotations_ +void GeometricPrimitive::Impl::Initialize(ID3D11DeviceContext* deviceContext, const VertexCollection& vertices, const IndexCollection& indices) +{ + if ( vertices.size() >= USHRT_MAX ) + throw std::exception("Too many vertices for 16-bit index buffer"); + + mResources = sharedResourcesPool.DemandCreate(deviceContext); + + ComPtr device; + deviceContext->GetDevice(&device); + + CreateBuffer(device.Get(), vertices, D3D11_BIND_VERTEX_BUFFER, &mVertexBuffer); + CreateBuffer(device.Get(), indices, D3D11_BIND_INDEX_BUFFER, &mIndexBuffer); + + mIndexCount = static_cast( indices.size() ); +} + + +// Draws the primitive. +_Use_decl_annotations_ +void XM_CALLCONV GeometricPrimitive::Impl::Draw(FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, FXMVECTOR color, + ID3D11ShaderResourceView* texture, bool wireframe, std::function setCustomState) +{ + assert( mResources != 0 ); + auto effect = mResources->effect.get(); + assert( effect != 0 ); + + ID3D11InputLayout *inputLayout; + if ( texture ) + { + effect->SetTextureEnabled(true); + effect->SetTexture(texture); + + inputLayout = mResources->inputLayoutTextured.Get(); + } + else + { + effect->SetTextureEnabled(false); + + inputLayout = mResources->inputLayoutUntextured.Get(); + } + + float alpha = XMVectorGetW(color); + + // Set effect parameters. + effect->SetWorld(world); + effect->SetView(view); + effect->SetProjection(projection); + + effect->SetDiffuseColor(color); + effect->SetAlpha(alpha); + + Draw( effect, inputLayout, (alpha < 1.f), wireframe, setCustomState ); +} + + +// Draw the primitive using a custom effect. +_Use_decl_annotations_ +void GeometricPrimitive::Impl::Draw(IEffect* effect, ID3D11InputLayout* inputLayout, bool alpha, bool wireframe, std::function setCustomState ) +{ + assert( mResources != 0 ); + auto deviceContext = mResources->deviceContext.Get(); + assert( deviceContext != 0 ); + + // Set state objects. + mResources->PrepareForRendering(alpha, wireframe); + + // Set input layout. + assert( inputLayout != 0 ); + deviceContext->IASetInputLayout(inputLayout); + + // Activate our shaders, constant buffers, texture, etc. + assert(effect != 0); + effect->Apply(deviceContext); + + // Set the vertex and index buffer. + auto vertexBuffer = mVertexBuffer.Get(); + UINT vertexStride = sizeof(VertexPositionNormalTexture); + UINT vertexOffset = 0; + + deviceContext->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset); + + deviceContext->IASetIndexBuffer(mIndexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0); + + // Hook lets the caller replace our shaders or state settings with whatever else they see fit. + if (setCustomState) + { + setCustomState(); + } + + // Draw the primitive. + deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + + deviceContext->DrawIndexed(mIndexCount, 0, 0); +} + + +// Create input layout for drawing with a custom effect. +_Use_decl_annotations_ +void GeometricPrimitive::Impl::CreateInputLayout( IEffect* effect, ID3D11InputLayout** inputLayout ) +{ + assert( effect != 0 ); + assert( inputLayout != 0 ); + + assert( mResources != 0 ); + auto deviceContext = mResources->deviceContext.Get(); + assert( deviceContext != 0 ); + + ComPtr device; + deviceContext->GetDevice(&device); + + ::CreateInputLayout( device.Get(), effect, inputLayout ); +} + + +//-------------------------------------------------------------------------------------- +// GeometricPrimitive +//-------------------------------------------------------------------------------------- + +// Constructor. +GeometricPrimitive::GeometricPrimitive() + : pImpl(new Impl()) +{ +} + + +// Destructor. +GeometricPrimitive::~GeometricPrimitive() +{ +} + + +// Public entrypoints. +_Use_decl_annotations_ +void XM_CALLCONV GeometricPrimitive::Draw(FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, FXMVECTOR color, ID3D11ShaderResourceView* texture, bool wireframe, std::function setCustomState) +{ + pImpl->Draw(world, view, projection, color, texture, wireframe, setCustomState); +} + + +_Use_decl_annotations_ +void GeometricPrimitive::Draw(IEffect* effect, ID3D11InputLayout* inputLayout, bool alpha, bool wireframe, std::function setCustomState ) +{ + pImpl->Draw(effect, inputLayout, alpha, wireframe, setCustomState); +} + + +_Use_decl_annotations_ +void GeometricPrimitive::CreateInputLayout(IEffect* effect, ID3D11InputLayout** inputLayout ) +{ + pImpl->CreateInputLayout(effect, inputLayout); +} + + +//-------------------------------------------------------------------------------------- +// Cube (aka a Hexahedron) or Box +//-------------------------------------------------------------------------------------- + +// Creates a cube primitive. +std::unique_ptr GeometricPrimitive::CreateCube(_In_ ID3D11DeviceContext* deviceContext, float size, bool rhcoords) +{ + return CreateBox(deviceContext, XMFLOAT3(size,size,size), rhcoords); +} + +void GeometricPrimitive::CreateCube(std::vector& vertices, std::vector& indices, float size, bool rhcoords) +{ + return CreateBox(vertices, indices, XMFLOAT3(size,size,size), rhcoords); +} + + +// Creates a box primitive. +std::unique_ptr GeometricPrimitive::CreateBox(_In_ ID3D11DeviceContext* deviceContext, const XMFLOAT3& size, bool rhcoords, bool invertn) +{ + VertexCollection vertices; + IndexCollection indices; + CreateBox(vertices, indices, size, rhcoords, invertn); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateBox(std::vector& vertices, std::vector& indices, const XMFLOAT3& size, bool rhcoords, bool invertn) +{ + vertices.clear(); + indices.clear(); + + // A box has six faces, each one pointing in a different direction. + const int FaceCount = 6; + + static const XMVECTORF32 faceNormals[FaceCount] = + { + { 0, 0, 1 }, + { 0, 0, -1 }, + { 1, 0, 0 }, + { -1, 0, 0 }, + { 0, 1, 0 }, + { 0, -1, 0 }, + }; + + static const XMVECTORF32 textureCoordinates[4] = + { + { 1, 0 }, + { 1, 1 }, + { 0, 1 }, + { 0, 0 }, + }; + + XMVECTOR tsize = XMLoadFloat3(&size); + tsize = XMVectorDivide(tsize, g_XMTwo); + + // Create each face in turn. + for (int i = 0; i < FaceCount; i++) + { + XMVECTOR normal = faceNormals[i]; + + // Get two vectors perpendicular both to the face normal and to each other. + XMVECTOR basis = (i >= 4) ? g_XMIdentityR2 : g_XMIdentityR1; + + XMVECTOR side1 = XMVector3Cross(normal, basis); + XMVECTOR side2 = XMVector3Cross(normal, side1); + + // Six indices (two triangles) per face. + size_t vbase = vertices.size(); + index_push_back(indices, vbase + 0); + index_push_back(indices, vbase + 1); + index_push_back(indices, vbase + 2); + + index_push_back(indices, vbase + 0); + index_push_back(indices, vbase + 2); + index_push_back(indices, vbase + 3); + + // Four vertices per face. + vertices.push_back(VertexPositionNormalTexture((normal - side1 - side2) * tsize, normal, textureCoordinates[0])); + vertices.push_back(VertexPositionNormalTexture((normal - side1 + side2) * tsize, normal, textureCoordinates[1])); + vertices.push_back(VertexPositionNormalTexture((normal + side1 + side2) * tsize, normal, textureCoordinates[2])); + vertices.push_back(VertexPositionNormalTexture((normal + side1 - side2) * tsize, normal, textureCoordinates[3])); + } + + // Build RH above + if ( !rhcoords ) + ReverseWinding( indices, vertices ); + + if ( invertn ) + InvertNormals( vertices ); +} + + +//-------------------------------------------------------------------------------------- +// Sphere +//-------------------------------------------------------------------------------------- + +// Creates a sphere primitive. +std::unique_ptr GeometricPrimitive::CreateSphere(_In_ ID3D11DeviceContext* deviceContext, float diameter, size_t tessellation, bool rhcoords, bool invertn) +{ + VertexCollection vertices; + IndexCollection indices; + CreateSphere(vertices, indices, diameter, tessellation, rhcoords, invertn); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateSphere(std::vector& vertices, std::vector& indices, float diameter, size_t tessellation, bool rhcoords, bool invertn) +{ + vertices.clear(); + indices.clear(); + + if (tessellation < 3) + throw std::out_of_range("tesselation parameter out of range"); + + size_t verticalSegments = tessellation; + size_t horizontalSegments = tessellation * 2; + + float radius = diameter / 2; + + // Create rings of vertices at progressively higher latitudes. + for (size_t i = 0; i <= verticalSegments; i++) + { + float v = 1 - (float)i / verticalSegments; + + float latitude = (i * XM_PI / verticalSegments) - XM_PIDIV2; + float dy, dxz; + + XMScalarSinCos(&dy, &dxz, latitude); + + // Create a single ring of vertices at this latitude. + for (size_t j = 0; j <= horizontalSegments; j++) + { + float u = (float)j / horizontalSegments; + + float longitude = j * XM_2PI / horizontalSegments; + float dx, dz; + + XMScalarSinCos(&dx, &dz, longitude); + + dx *= dxz; + dz *= dxz; + + XMVECTOR normal = XMVectorSet(dx, dy, dz, 0); + XMVECTOR textureCoordinate = XMVectorSet(u, v, 0, 0); + + vertices.push_back(VertexPositionNormalTexture(normal * radius, normal, textureCoordinate)); + } + } + + // Fill the index buffer with triangles joining each pair of latitude rings. + size_t stride = horizontalSegments + 1; + + for (size_t i = 0; i < verticalSegments; i++) + { + for (size_t j = 0; j <= horizontalSegments; j++) + { + size_t nextI = i + 1; + size_t nextJ = (j + 1) % stride; + + index_push_back(indices, i * stride + j); + index_push_back(indices, nextI * stride + j); + index_push_back(indices, i * stride + nextJ); + + index_push_back(indices, i * stride + nextJ); + index_push_back(indices, nextI * stride + j); + index_push_back(indices, nextI * stride + nextJ); + } + } + + // Build RH above + if ( !rhcoords ) + ReverseWinding( indices, vertices ); + + if ( invertn ) + InvertNormals( vertices ); +} + + +//-------------------------------------------------------------------------------------- +// Geodesic sphere +//-------------------------------------------------------------------------------------- + +// Creates a geosphere primitive. +std::unique_ptr GeometricPrimitive::CreateGeoSphere(_In_ ID3D11DeviceContext* deviceContext, float diameter, size_t tessellation, bool rhcoords) +{ + VertexCollection vertices; + IndexCollection indices; + CreateGeoSphere(vertices, indices, diameter, tessellation, rhcoords); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateGeoSphere(std::vector& vertices, std::vector& indices, float diameter, size_t tessellation, bool rhcoords) +{ + vertices.clear(); + indices.clear(); + + // An undirected edge between two vertices, represented by a pair of indexes into a vertex array. + // Becuse this edge is undirected, (a,b) is the same as (b,a). + typedef std::pair UndirectedEdge; + + // Makes an undirected edge. Rather than overloading comparison operators to give us the (a,b)==(b,a) property, + // we'll just ensure that the larger of the two goes first. This'll simplify things greatly. + auto makeUndirectedEdge = [](uint16_t a, uint16_t b) + { + return std::make_pair(std::max(a, b), std::min(a, b)); + }; + + // Key: an edge + // Value: the index of the vertex which lies midway between the two vertices pointed to by the key value + // This map is used to avoid duplicating vertices when subdividing triangles along edges. + typedef std::map EdgeSubdivisionMap; + + + static const XMFLOAT3 OctahedronVertices[] = + { + // when looking down the negative z-axis (into the screen) + XMFLOAT3( 0, 1, 0), // 0 top + XMFLOAT3( 0, 0, -1), // 1 front + XMFLOAT3( 1, 0, 0), // 2 right + XMFLOAT3( 0, 0, 1), // 3 back + XMFLOAT3(-1, 0, 0), // 4 left + XMFLOAT3( 0, -1, 0), // 5 bottom + }; + static const uint16_t OctahedronIndices[] = + { + 0, 1, 2, // top front-right face + 0, 2, 3, // top back-right face + 0, 3, 4, // top back-left face + 0, 4, 1, // top front-left face + 5, 1, 4, // bottom front-left face + 5, 4, 3, // bottom back-left face + 5, 3, 2, // bottom back-right face + 5, 2, 1, // bottom front-right face + }; + + const float radius = diameter / 2.0f; + + // Start with an octahedron; copy the data into the vertex/index collection. + + std::vector vertexPositions(std::begin(OctahedronVertices), std::end(OctahedronVertices)); + + indices.insert(indices.begin(), std::begin(OctahedronIndices), std::end(OctahedronIndices)); + + // We know these values by looking at the above index list for the octahedron. Despite the subdivisions that are + // about to go on, these values aren't ever going to change because the vertices don't move around in the array. + // We'll need these values later on to fix the singularities that show up at the poles. + const uint16_t northPoleIndex = 0; + const uint16_t southPoleIndex = 5; + + for (size_t iSubdivision = 0; iSubdivision < tessellation; ++iSubdivision) + { + assert(indices.size() % 3 == 0); // sanity + + // We use this to keep track of which edges have already been subdivided. + EdgeSubdivisionMap subdividedEdges; + + // The new index collection after subdivision. + IndexCollection newIndices; + + const size_t triangleCount = indices.size() / 3; + for (size_t iTriangle = 0; iTriangle < triangleCount; ++iTriangle) + { + // For each edge on this triangle, create a new vertex in the middle of that edge. + // The winding order of the triangles we output are the same as the winding order of the inputs. + + // Indices of the vertices making up this triangle + uint16_t iv0 = indices[iTriangle*3+0]; + uint16_t iv1 = indices[iTriangle*3+1]; + uint16_t iv2 = indices[iTriangle*3+2]; + + // Get the new vertices + XMFLOAT3 v01; // vertex on the midpoint of v0 and v1 + XMFLOAT3 v12; // ditto v1 and v2 + XMFLOAT3 v20; // ditto v2 and v0 + uint16_t iv01; // index of v01 + uint16_t iv12; // index of v12 + uint16_t iv20; // index of v20 + + // Function that, when given the index of two vertices, creates a new vertex at the midpoint of those vertices. + auto divideEdge = [&](uint16_t i0, uint16_t i1, XMFLOAT3& outVertex, uint16_t& outIndex) + { + const UndirectedEdge edge = makeUndirectedEdge(i0, i1); + + // Check to see if we've already generated this vertex + auto it = subdividedEdges.find(edge); + if (it != subdividedEdges.end()) + { + // We've already generated this vertex before + outIndex = it->second; // the index of this vertex + outVertex = vertexPositions[outIndex]; // and the vertex itself + } + else + { + // Haven't generated this vertex before: so add it now + + // outVertex = (vertices[i0] + vertices[i1]) / 2 + XMStoreFloat3( + &outVertex, + XMVectorScale( + XMVectorAdd(XMLoadFloat3(&vertexPositions[i0]), XMLoadFloat3(&vertexPositions[i1])), + 0.5f + ) + ); + + outIndex = static_cast( vertexPositions.size() ); + CheckIndexOverflow(outIndex); + vertexPositions.push_back(outVertex); + + // Now add it to the map. + subdividedEdges.insert(std::make_pair(edge, outIndex)); + } + }; + + // Add/get new vertices and their indices + divideEdge(iv0, iv1, v01, iv01); + divideEdge(iv1, iv2, v12, iv12); + divideEdge(iv0, iv2, v20, iv20); + + // Add the new indices. We have four new triangles from our original one: + // v0 + // o + // /a\ + // v20 o---o v01 + // /b\c/d\ + // v2 o---o---o v1 + // v12 + const uint16_t indicesToAdd[] = + { + iv0, iv01, iv20, // a + iv20, iv12, iv2, // b + iv20, iv01, iv12, // c + iv01, iv1, iv12, // d + }; + newIndices.insert(newIndices.end(), std::begin(indicesToAdd), std::end(indicesToAdd)); + } + + indices = std::move(newIndices); + } + + // Now that we've completed subdivision, fill in the final vertex collection + vertices.reserve(vertexPositions.size()); + for (auto it = vertexPositions.begin(); it != vertexPositions.end(); ++it) + { + auto vertexValue = *it; + + auto normal = XMVector3Normalize(XMLoadFloat3(&vertexValue)); + auto pos = XMVectorScale(normal, radius); + + XMFLOAT3 normalFloat3; + XMStoreFloat3(&normalFloat3, normal); + + // calculate texture coordinates for this vertex + float longitude = atan2(normalFloat3.x, -normalFloat3.z); + float latitude = acos(normalFloat3.y); + + float u = longitude / XM_2PI + 0.5f; + float v = latitude / XM_PI; + + auto texcoord = XMVectorSet(1.0f - u, v, 0.0f, 0.0f); + vertices.push_back(VertexPositionNormalTexture(pos, normal, texcoord)); + } + + // There are a couple of fixes to do. One is a texture coordinate wraparound fixup. At some point, there will be + // a set of triangles somewhere in the mesh with texture coordinates such that the wraparound across 0.0/1.0 + // occurs across that triangle. Eg. when the left hand side of the triangle has a U coordinate of 0.98 and the + // right hand side has a U coordinate of 0.0. The intent is that such a triangle should render with a U of 0.98 to + // 1.0, not 0.98 to 0.0. If we don't do this fixup, there will be a visible seam across one side of the sphere. + // + // Luckily this is relatively easy to fix. There is a straight edge which runs down the prime meridian of the + // completed sphere. If you imagine the vertices along that edge, they circumscribe a semicircular arc starting at + // y=1 and ending at y=-1, and sweeping across the range of z=0 to z=1. x stays zero. It's along this edge that we + // need to duplicate our vertices - and provide the correct texture coordinates. + size_t preFixupVertexCount = vertices.size(); + for (size_t i = 0; i < preFixupVertexCount; ++i) + { + // This vertex is on the prime meridian if position.x and texcoord.u are both zero (allowing for small epsilon). + bool isOnPrimeMeridian = XMVector2NearEqual( + XMVectorSet(vertices[i].position.x, vertices[i].textureCoordinate.x, 0.0f, 0.0f), + XMVectorZero(), + XMVectorSplatEpsilon()); + + if (isOnPrimeMeridian) + { + size_t newIndex = vertices.size(); // the index of this vertex that we're about to add + CheckIndexOverflow(newIndex); + + // copy this vertex, correct the texture coordinate, and add the vertex + VertexPositionNormalTexture v = vertices[i]; + v.textureCoordinate.x = 1.0f; + vertices.push_back(v); + + // Now find all the triangles which contain this vertex and update them if necessary + for (size_t j = 0; j < indices.size(); j += 3) + { + uint16_t* triIndex0 = &indices[j+0]; + uint16_t* triIndex1 = &indices[j+1]; + uint16_t* triIndex2 = &indices[j+2]; + + if (*triIndex0 == i) + { + // nothing; just keep going + } + else if (*triIndex1 == i) + { + std::swap(triIndex0, triIndex1); // swap the pointers (not the values) + } + else if (*triIndex2 == i) + { + std::swap(triIndex0, triIndex2); // swap the pointers (not the values) + } + else + { + // this triangle doesn't use the vertex we're interested in + continue; + } + + // If we got to this point then triIndex0 is the pointer to the index to the vertex we're looking at + assert(*triIndex0 == i); + assert(*triIndex1 != i && *triIndex2 != i); // assume no degenerate triangles + + const VertexPositionNormalTexture& v0 = vertices[*triIndex0]; + const VertexPositionNormalTexture& v1 = vertices[*triIndex1]; + const VertexPositionNormalTexture& v2 = vertices[*triIndex2]; + + // check the other two vertices to see if we might need to fix this triangle + + if (abs(v0.textureCoordinate.x - v1.textureCoordinate.x) > 0.5f || + abs(v0.textureCoordinate.x - v2.textureCoordinate.x) > 0.5f) + { + // yep; replace the specified index to point to the new, corrected vertex + *triIndex0 = static_cast(newIndex); + } + } + } + } + + // And one last fix we need to do: the poles. A common use-case of a sphere mesh is to map a rectangular texture onto + // it. If that happens, then the poles become singularities which map the entire top and bottom rows of the texture + // onto a single point. In general there's no real way to do that right. But to match the behavior of non-geodesic + // spheres, we need to duplicate the pole vertex for every triangle that uses it. This will introduce seams near the + // poles, but reduce stretching. + auto fixPole = [&](size_t poleIndex) + { + auto poleVertex = vertices[poleIndex]; + bool overwrittenPoleVertex = false; // overwriting the original pole vertex saves us one vertex + + for (size_t i = 0; i < indices.size(); i += 3) + { + // These pointers point to the three indices which make up this triangle. pPoleIndex is the pointer to the + // entry in the index array which represents the pole index, and the other two pointers point to the other + // two indices making up this triangle. + uint16_t* pPoleIndex; + uint16_t* pOtherIndex0; + uint16_t* pOtherIndex1; + if (indices[i + 0] == poleIndex) + { + pPoleIndex = &indices[i + 0]; + pOtherIndex0 = &indices[i + 1]; + pOtherIndex1 = &indices[i + 2]; + } + else if (indices[i + 1] == poleIndex) + { + pPoleIndex = &indices[i + 1]; + pOtherIndex0 = &indices[i + 2]; + pOtherIndex1 = &indices[i + 0]; + } + else if (indices[i + 2] == poleIndex) + { + pPoleIndex = &indices[i + 2]; + pOtherIndex0 = &indices[i + 0]; + pOtherIndex1 = &indices[i + 1]; + } + else + { + continue; + } + + const auto& otherVertex0 = vertices[*pOtherIndex0]; + const auto& otherVertex1 = vertices[*pOtherIndex1]; + + // Calculate the texcoords for the new pole vertex, add it to the vertices and update the index + VertexPositionNormalTexture newPoleVertex = poleVertex; + newPoleVertex.textureCoordinate.x = (otherVertex0.textureCoordinate.x + otherVertex1.textureCoordinate.x) / 2; + newPoleVertex.textureCoordinate.y = poleVertex.textureCoordinate.y; + + if (!overwrittenPoleVertex) + { + vertices[poleIndex] = newPoleVertex; + overwrittenPoleVertex = true; + } + else + { + CheckIndexOverflow(vertices.size()); + + *pPoleIndex = static_cast(vertices.size()); + vertices.push_back(newPoleVertex); + } + } + }; + + fixPole(northPoleIndex); + fixPole(southPoleIndex); + + // Build RH above + if ( !rhcoords ) + ReverseWinding( indices, vertices ); +} + + +//-------------------------------------------------------------------------------------- +// Cylinder / Cone +//-------------------------------------------------------------------------------------- + +// Helper computes a point on a unit circle, aligned to the x/z plane and centered on the origin. +static inline XMVECTOR GetCircleVector(size_t i, size_t tessellation) +{ + float angle = i * XM_2PI / tessellation; + float dx, dz; + + XMScalarSinCos(&dx, &dz, angle); + + XMVECTORF32 v = { dx, 0, dz, 0 }; + return v; +} + +static inline XMVECTOR GetCircleTangent(size_t i, size_t tessellation) +{ + float angle = ( i * XM_2PI / tessellation ) + XM_PIDIV2; + float dx, dz; + + XMScalarSinCos(&dx, &dz, angle); + + XMVECTORF32 v = { dx, 0, dz, 0 }; + return v; +} + + +// Helper creates a triangle fan to close the end of a cylinder / cone +static void CreateCylinderCap(VertexCollection& vertices, IndexCollection& indices, size_t tessellation, float height, float radius, bool isTop) +{ + // Create cap indices. + for (size_t i = 0; i < tessellation - 2; i++) + { + size_t i1 = (i + 1) % tessellation; + size_t i2 = (i + 2) % tessellation; + + if (isTop) + { + std::swap(i1, i2); + } + + size_t vbase = vertices.size(); + index_push_back(indices, vbase); + index_push_back(indices, vbase + i1); + index_push_back(indices, vbase + i2); + } + + // Which end of the cylinder is this? + XMVECTOR normal = g_XMIdentityR1; + XMVECTOR textureScale = g_XMNegativeOneHalf; + + if (!isTop) + { + normal = -normal; + textureScale *= g_XMNegateX; + } + + // Create cap vertices. + for (size_t i = 0; i < tessellation; i++) + { + XMVECTOR circleVector = GetCircleVector(i, tessellation); + + XMVECTOR position = (circleVector * radius) + (normal * height); + + XMVECTOR textureCoordinate = XMVectorMultiplyAdd(XMVectorSwizzle<0, 2, 3, 3>(circleVector), textureScale, g_XMOneHalf); + + vertices.push_back(VertexPositionNormalTexture(position, normal, textureCoordinate)); + } +} + + +// Creates a cylinder primitive. +std::unique_ptr GeometricPrimitive::CreateCylinder(_In_ ID3D11DeviceContext* deviceContext, float height, float diameter, size_t tessellation, bool rhcoords) +{ + VertexCollection vertices; + IndexCollection indices; + CreateCylinder(vertices, indices, height, diameter, tessellation, rhcoords); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateCylinder(std::vector& vertices, std::vector& indices, float height, float diameter, size_t tessellation, bool rhcoords) +{ + vertices.clear(); + indices.clear(); + + if (tessellation < 3) + throw std::out_of_range("tesselation parameter out of range"); + + height /= 2; + + XMVECTOR topOffset = g_XMIdentityR1 * height; + + float radius = diameter / 2; + size_t stride = tessellation + 1; + + // Create a ring of triangles around the outside of the cylinder. + for (size_t i = 0; i <= tessellation; i++) + { + XMVECTOR normal = GetCircleVector(i, tessellation); + + XMVECTOR sideOffset = normal * radius; + + float u = (float)i / tessellation; + + XMVECTOR textureCoordinate = XMLoadFloat(&u); + + vertices.push_back(VertexPositionNormalTexture(sideOffset + topOffset, normal, textureCoordinate)); + vertices.push_back(VertexPositionNormalTexture(sideOffset - topOffset, normal, textureCoordinate + g_XMIdentityR1)); + + index_push_back(indices, i * 2); + index_push_back(indices, (i * 2 + 2) % (stride * 2)); + index_push_back(indices, i * 2 + 1); + + index_push_back(indices, i * 2 + 1); + index_push_back(indices, (i * 2 + 2) % (stride * 2)); + index_push_back(indices, (i * 2 + 3) % (stride * 2)); + } + + // Create flat triangle fan caps to seal the top and bottom. + CreateCylinderCap(vertices, indices, tessellation, height, radius, true); + CreateCylinderCap(vertices, indices, tessellation, height, radius, false); + + // Build RH above + if ( !rhcoords ) + ReverseWinding( indices, vertices ); +} + + +// Creates a cone primitive. +std::unique_ptr GeometricPrimitive::CreateCone(_In_ ID3D11DeviceContext* deviceContext, float diameter, float height, size_t tessellation, bool rhcoords) +{ + VertexCollection vertices; + IndexCollection indices; + CreateCone(vertices, indices, diameter, height, tessellation, rhcoords); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateCone(std::vector& vertices, std::vector& indices, float diameter, float height, size_t tessellation, bool rhcoords) +{ + vertices.clear(); + indices.clear(); + + if (tessellation < 3) + throw std::out_of_range("tesselation parameter out of range"); + + height /= 2; + + XMVECTOR topOffset = g_XMIdentityR1 * height; + + float radius = diameter / 2; + size_t stride = tessellation + 1; + + // Create a ring of triangles around the outside of the cone. + for (size_t i = 0; i <= tessellation; i++) + { + XMVECTOR circlevec = GetCircleVector(i, tessellation); + + XMVECTOR sideOffset = circlevec * radius; + + float u = (float)i / tessellation; + + XMVECTOR textureCoordinate = XMLoadFloat(&u); + + XMVECTOR pt = sideOffset - topOffset; + + XMVECTOR normal = XMVector3Cross( GetCircleTangent( i, tessellation ), topOffset - pt ); + normal = XMVector3Normalize( normal ); + + // Duplicate the top vertex for distinct normals + vertices.push_back(VertexPositionNormalTexture(topOffset, normal, g_XMZero)); + vertices.push_back(VertexPositionNormalTexture(pt, normal, textureCoordinate + g_XMIdentityR1 )); + + index_push_back(indices, i * 2); + index_push_back(indices, (i * 2 + 3) % (stride * 2)); + index_push_back(indices, (i * 2 + 1) % (stride * 2)); + } + + // Create flat triangle fan caps to seal the bottom. + CreateCylinderCap(vertices, indices, tessellation, height, radius, false); + + // Build RH above + if ( !rhcoords ) + ReverseWinding( indices, vertices ); +} + + +//-------------------------------------------------------------------------------------- +// Torus +//-------------------------------------------------------------------------------------- + +// Creates a torus primitive. +std::unique_ptr GeometricPrimitive::CreateTorus(_In_ ID3D11DeviceContext* deviceContext, float diameter, float thickness, size_t tessellation, bool rhcoords) +{ + VertexCollection vertices; + IndexCollection indices; + CreateTorus( vertices, indices, diameter, thickness, tessellation, rhcoords ); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateTorus(std::vector& vertices, std::vector& indices, float diameter, float thickness, size_t tessellation, bool rhcoords) +{ + vertices.clear(); + indices.clear(); + + if (tessellation < 3) + throw std::out_of_range("tesselation parameter out of range"); + + size_t stride = tessellation + 1; + + // First we loop around the main ring of the torus. + for (size_t i = 0; i <= tessellation; i++) + { + float u = (float)i / tessellation; + + float outerAngle = i * XM_2PI / tessellation - XM_PIDIV2; + + // Create a transform matrix that will align geometry to + // slice perpendicularly though the current ring position. + XMMATRIX transform = XMMatrixTranslation(diameter / 2, 0, 0) * XMMatrixRotationY(outerAngle); + + // Now we loop along the other axis, around the side of the tube. + for (size_t j = 0; j <= tessellation; j++) + { + float v = 1 - (float)j / tessellation; + + float innerAngle = j * XM_2PI / tessellation + XM_PI; + float dx, dy; + + XMScalarSinCos(&dy, &dx, innerAngle); + + // Create a vertex. + XMVECTOR normal = XMVectorSet(dx, dy, 0, 0); + XMVECTOR position = normal * thickness / 2; + XMVECTOR textureCoordinate = XMVectorSet(u, v, 0, 0); + + position = XMVector3Transform(position, transform); + normal = XMVector3TransformNormal(normal, transform); + + vertices.push_back(VertexPositionNormalTexture(position, normal, textureCoordinate)); + + // And create indices for two triangles. + size_t nextI = (i + 1) % stride; + size_t nextJ = (j + 1) % stride; + + index_push_back(indices, i * stride + j); + index_push_back(indices, i * stride + nextJ); + index_push_back(indices, nextI * stride + j); + + index_push_back(indices, i * stride + nextJ); + index_push_back(indices, nextI * stride + nextJ); + index_push_back(indices, nextI * stride + j); + } + } + + // Build RH above + if ( !rhcoords ) + ReverseWinding( indices, vertices ); +} + + +//-------------------------------------------------------------------------------------- +// Tetrahedron +//-------------------------------------------------------------------------------------- + +std::unique_ptr GeometricPrimitive::CreateTetrahedron(_In_ ID3D11DeviceContext* deviceContext, float size, bool rhcoords) +{ + VertexCollection vertices; + IndexCollection indices; + CreateTetrahedron(vertices, indices, size, rhcoords); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateTetrahedron(std::vector& vertices, std::vector& indices, float size, bool rhcoords) +{ + vertices.clear(); + indices.clear(); + + static const XMVECTORF32 verts[4] = + { + { 0.f, 0.f, 1.f }, + { 2.f*SQRT2/3.f, 0.f, -1.f/3.f }, + { -SQRT2/3.f, SQRT6/3.f, -1.f/3.f }, + { -SQRT2/3.f, -SQRT6/3.f, -1.f/3.f } + }; + + static const uint32_t faces[4*3] = + { + 0, 1, 2, + 0, 2, 3, + 0, 3, 1, + 1, 3, 2, + }; + + for( size_t j = 0; j < _countof(faces); j += 3 ) + { + uint32_t v0 = faces[ j ]; + uint32_t v1 = faces[ j + 1 ]; + uint32_t v2 = faces[ j + 2 ]; + + XMVECTOR normal = XMVector3Cross( verts[ v1 ].v - verts[ v0 ].v, + verts[ v2 ].v - verts[ v0 ].v ); + normal = XMVector3Normalize( normal ); + + size_t base = vertices.size(); + index_push_back(indices, base ); + index_push_back(indices, base + 1 ); + index_push_back(indices, base + 2 ); + + // Duplicate vertices to use face normals + XMVECTOR position = XMVectorScale( verts[ v0 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, g_XMZero /* 0, 0 */ ) ); + + position = XMVectorScale( verts[ v1 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, g_XMIdentityR0 /* 1, 0 */ ) ); + + position = XMVectorScale( verts[ v2 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, g_XMIdentityR1 /* 0, 1 */ ) ); + } + + // Built LH above + if ( rhcoords ) + ReverseWinding( indices, vertices ); + + assert( vertices.size() == 4*3 ); + assert( indices.size() == 4*3 ); +} + + +//-------------------------------------------------------------------------------------- +// Octahedron +//-------------------------------------------------------------------------------------- +std::unique_ptr GeometricPrimitive::CreateOctahedron(_In_ ID3D11DeviceContext* deviceContext, float size, bool rhcoords ) +{ + VertexCollection vertices; + IndexCollection indices; + CreateOctahedron(vertices, indices, size, rhcoords ); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateOctahedron(std::vector& vertices, std::vector& indices, float size, bool rhcoords ) +{ + vertices.clear(); + indices.clear(); + + static const XMVECTORF32 verts[6] = + { + { 1, 0, 0 }, + { -1, 0, 0 }, + { 0, 1, 0 }, + { 0, -1, 0 }, + { 0, 0, 1 }, + { 0, 0, -1 } + }; + + static const uint32_t faces[8*3] = + { + 4, 0, 2, + 4, 2, 1, + 4, 1, 3, + 4, 3, 0, + 5, 2, 0, + 5, 1, 2, + 5, 3, 1, + 5, 0, 3 + }; + + for( size_t j = 0; j < _countof(faces); j += 3 ) + { + uint32_t v0 = faces[ j ]; + uint32_t v1 = faces[ j + 1 ]; + uint32_t v2 = faces[ j + 2 ]; + + XMVECTOR normal = XMVector3Cross( verts[ v1 ].v - verts[ v0 ].v, + verts[ v2 ].v - verts[ v0 ].v ); + normal = XMVector3Normalize( normal ); + + size_t base = vertices.size(); + index_push_back(indices, base ); + index_push_back(indices, base + 1 ); + index_push_back(indices, base + 2 ); + + // Duplicate vertices to use face normals + XMVECTOR position = XMVectorScale( verts[ v0 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, g_XMZero /* 0, 0 */ ) ); + + position = XMVectorScale( verts[ v1 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, g_XMIdentityR0 /* 1, 0 */ ) ); + + position = XMVectorScale( verts[ v2 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, g_XMIdentityR1 /* 0, 1*/ ) ); + } + + // Built LH above + if ( rhcoords ) + ReverseWinding( indices, vertices ); + + assert( vertices.size() == 8*3 ); + assert( indices.size() == 8*3 ); +} + + +//-------------------------------------------------------------------------------------- +// Dodecahedron +//-------------------------------------------------------------------------------------- + +std::unique_ptr GeometricPrimitive::CreateDodecahedron(_In_ ID3D11DeviceContext* deviceContext, float size, bool rhcoords ) +{ + VertexCollection vertices; + IndexCollection indices; + CreateDodecahedron( vertices, indices, size, rhcoords ); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateDodecahedron(std::vector& vertices, std::vector& indices, float size, bool rhcoords ) +{ + vertices.clear(); + indices.clear(); + + static const float a = 1.f/SQRT3; + static const float b = 0.356822089773089931942f; // sqrt( ( 3 - sqrt(5) ) / 6 ) + static const float c = 0.934172358962715696451f; // sqrt( ( 3 + sqrt(5) ) / 6 ); + + static const XMVECTORF32 verts[20] = + { + { a, a, a }, + { a, a, -a }, + { a, -a, a }, + { a, -a, -a }, + { -a, a, a }, + { -a, a, -a }, + { -a, -a, a }, + { -a, -a, -a }, + { b, c, 0 }, + { -b, c, 0 }, + { b, -c, 0 }, + { -b, -c, 0 }, + { c, 0, b }, + { c, 0, -b }, + { -c, 0, b }, + { -c, 0, -b }, + { 0, b, c }, + { 0, -b, c }, + { 0, b, -c }, + { 0, -b, -c } + }; + + static const uint32_t faces[12*5] = + { + 0, 8, 9, 4, 16, + 0, 16, 17, 2, 12, + 12, 2, 10, 3, 13, + 9, 5, 15, 14, 4, + 3, 19, 18, 1, 13, + 7, 11, 6, 14, 15, + 0, 12, 13, 1, 8, + 8, 1, 18, 5, 9, + 16, 4, 14, 6, 17, + 6, 11, 10, 2, 17, + 7, 15, 5, 18, 19, + 7, 19, 3, 10, 11, + }; + + static const XMVECTORF32 textureCoordinates[5] = + { + { 0.654508f, 0.0244717f }, + { 0.0954915f, 0.206107f }, + { 0.0954915f, 0.793893f }, + { 0.654508f, 0.975528f }, + { 1.f, 0.5f } + }; + + static const uint32_t textureIndex[12][5] = + { + { 0, 1, 2, 3, 4 }, + { 2, 3, 4, 0, 1 }, + { 4, 0, 1, 2, 3 }, + { 1, 2, 3, 4, 0 }, + { 2, 3, 4, 0, 1 }, + { 0, 1, 2, 3, 4 }, + { 1, 2, 3, 4, 0 }, + { 4, 0, 1, 2, 3 }, + { 4, 0, 1, 2, 3 }, + { 1, 2, 3, 4, 0 }, + { 0, 1, 2, 3, 4 }, + { 2, 3, 4, 0, 1 }, + }; + + size_t t = 0; + for( size_t j = 0; j < _countof(faces); j += 5, ++t ) + { + uint32_t v0 = faces[ j ]; + uint32_t v1 = faces[ j + 1 ]; + uint32_t v2 = faces[ j + 2 ]; + uint32_t v3 = faces[ j + 3 ]; + uint32_t v4 = faces[ j + 4 ]; + + XMVECTOR normal = XMVector3Cross( verts[ v1 ].v - verts[ v0 ].v, + verts[ v2 ].v - verts[ v0 ].v ); + normal = XMVector3Normalize( normal ); + + size_t base = vertices.size(); + + index_push_back(indices, base ); + index_push_back(indices, base + 1 ); + index_push_back(indices, base + 2 ); + + index_push_back(indices, base ); + index_push_back(indices, base + 2 ); + index_push_back(indices, base + 3 ); + + index_push_back(indices, base ); + index_push_back(indices, base + 3 ); + index_push_back(indices, base + 4 ); + + // Duplicate vertices to use face normals + XMVECTOR position = XMVectorScale( verts[ v0 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, textureCoordinates[ textureIndex[t][0] ] ) ); + + position = XMVectorScale( verts[ v1 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, textureCoordinates[ textureIndex[t][1] ] ) ); + + position = XMVectorScale( verts[ v2 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, textureCoordinates[ textureIndex[t][2] ] ) ); + + position = XMVectorScale( verts[ v3 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, textureCoordinates[ textureIndex[t][3] ] ) ); + + position = XMVectorScale( verts[ v4 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, textureCoordinates[ textureIndex[t][4] ] ) ); + } + + // Built LH above + if ( rhcoords ) + ReverseWinding( indices, vertices ); + + assert( vertices.size() == 12*5 ); + assert( indices.size() == 12*3*3 ); +} + + +//-------------------------------------------------------------------------------------- +// Icosahedron +//-------------------------------------------------------------------------------------- + +std::unique_ptr GeometricPrimitive::CreateIcosahedron(_In_ ID3D11DeviceContext* deviceContext, float size, bool rhcoords ) +{ + VertexCollection vertices; + IndexCollection indices; + CreateIcosahedron( vertices, indices, size, rhcoords ); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateIcosahedron(std::vector& vertices, std::vector& indices, float size, bool rhcoords ) +{ + vertices.clear(); + indices.clear(); + + static const float t = 1.618033988749894848205f; // (1 + sqrt(5)) / 2 + static const float t2 = 1.519544995837552493271f; // sqrt( 1 + sqr( (1 + sqrt(5)) / 2 ) ) + + static const XMVECTORF32 verts[12] = + { + { t/t2, 1.f/t2, 0 }, + { -t/t2, 1.f/t2, 0 }, + { t/t2, -1.f/t2, 0 }, + { -t/t2, -1.f/t2, 0 }, + { 1.f/t2, 0, t/t2 }, + { 1.f/t2, 0, -t/t2 }, + { -1.f/t2, 0, t/t2 }, + { -1.f/t2, 0, -t/t2 }, + { 0, t/t2, 1.f/t2 }, + { 0, -t/t2, 1.f/t2 }, + { 0, t/t2, -1.f/t2 }, + { 0, -t/t2, -1.f/t2 } + }; + + static const uint32_t faces[20*3] = + { + 0, 8, 4, + 0, 5, 10, + 2, 4, 9, + 2, 11, 5, + 1, 6, 8, + 1, 10, 7, + 3, 9, 6, + 3, 7, 11, + 0, 10, 8, + 1, 8, 10, + 2, 9, 11, + 3, 11, 9, + 4, 2, 0, + 5, 0, 2, + 6, 1, 3, + 7, 3, 1, + 8, 6, 4, + 9, 4, 6, + 10, 5, 7, + 11, 7, 5 + }; + + for( size_t j = 0; j < _countof(faces); j += 3 ) + { + uint32_t v0 = faces[ j ]; + uint32_t v1 = faces[ j + 1 ]; + uint32_t v2 = faces[ j + 2 ]; + + XMVECTOR normal = XMVector3Cross( verts[ v1 ].v - verts[ v0 ].v, + verts[ v2 ].v - verts[ v0 ].v ); + normal = XMVector3Normalize( normal ); + + size_t base = vertices.size(); + index_push_back(indices, base ); + index_push_back(indices, base + 1 ); + index_push_back(indices, base + 2 ); + + // Duplicate vertices to use face normals + XMVECTOR position = XMVectorScale( verts[ v0 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, g_XMZero /* 0, 0 */ ) ); + + position = XMVectorScale( verts[ v1 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, g_XMIdentityR0 /* 1, 0 */ ) ); + + position = XMVectorScale( verts[ v2 ], size ); + vertices.push_back( VertexPositionNormalTexture( position, normal, g_XMIdentityR1 /* 0, 1 */ ) ); + } + + // Built LH above + if ( rhcoords ) + ReverseWinding( indices, vertices ); + + assert( vertices.size() == 20*3 ); + assert( indices.size() == 20*3 ); +} + + +//-------------------------------------------------------------------------------------- +// Teapot +//-------------------------------------------------------------------------------------- + +// Include the teapot control point data. +namespace +{ + #include "TeapotData.inc" +} + + +// Tessellates the specified bezier patch. +static void XM_CALLCONV TessellatePatch(VertexCollection& vertices, IndexCollection& indices, TeapotPatch const& patch, size_t tessellation, FXMVECTOR scale, bool isMirrored) +{ + // Look up the 16 control points for this patch. + XMVECTOR controlPoints[16]; + + for (int i = 0; i < 16; i++) + { + controlPoints[i] = TeapotControlPoints[patch.indices[i]] * scale; + } + + // Create the index data. + size_t vbase = vertices.size(); + Bezier::CreatePatchIndices(tessellation, isMirrored, [&](size_t index) + { + index_push_back(indices, vbase + index); + }); + + // Create the vertex data. + Bezier::CreatePatchVertices(controlPoints, tessellation, isMirrored, [&](FXMVECTOR position, FXMVECTOR normal, FXMVECTOR textureCoordinate) + { + vertices.push_back(VertexPositionNormalTexture(position, normal, textureCoordinate)); + }); +} + + +// Creates a teapot primitive. +std::unique_ptr GeometricPrimitive::CreateTeapot(_In_ ID3D11DeviceContext* deviceContext, float size, size_t tessellation, bool rhcoords) +{ + VertexCollection vertices; + IndexCollection indices; + CreateTeapot(vertices, indices, size, tessellation, rhcoords); + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} + +void GeometricPrimitive::CreateTeapot(std::vector& vertices, std::vector& indices, float size, size_t tessellation, bool rhcoords) +{ + vertices.clear(); + indices.clear(); + + if (tessellation < 1) + throw std::out_of_range("tesselation parameter out of range"); + + XMVECTOR scaleVector = XMVectorReplicate(size); + + XMVECTOR scaleNegateX = scaleVector * g_XMNegateX; + XMVECTOR scaleNegateZ = scaleVector * g_XMNegateZ; + XMVECTOR scaleNegateXZ = scaleVector * g_XMNegateX * g_XMNegateZ; + + for (int i = 0; i < sizeof(TeapotPatches) / sizeof(TeapotPatches[0]); i++) + { + TeapotPatch const& patch = TeapotPatches[i]; + + // Because the teapot is symmetrical from left to right, we only store + // data for one side, then tessellate each patch twice, mirroring in X. + TessellatePatch(vertices, indices, patch, tessellation, scaleVector, false); + TessellatePatch(vertices, indices, patch, tessellation, scaleNegateX, true); + + if (patch.mirrorZ) + { + // Some parts of the teapot (the body, lid, and rim, but not the + // handle or spout) are also symmetrical from front to back, so + // we tessellate them four times, mirroring in Z as well as X. + TessellatePatch(vertices, indices, patch, tessellation, scaleNegateZ, true); + TessellatePatch(vertices, indices, patch, tessellation, scaleNegateXZ, false); + } + } + + // Built RH above + if ( !rhcoords ) + ReverseWinding( indices, vertices ); +} + + +//-------------------------------------------------------------------------------------- +// Custom +//-------------------------------------------------------------------------------------- + +std::unique_ptr GeometricPrimitive::CreateCustom(_In_ ID3D11DeviceContext* deviceContext, const std::vector& vertices, const std::vector& indices) +{ + // Extra validation + if ( vertices.empty() || indices.empty() ) + throw std::exception("Requires both vertices and indices"); + + if ( indices.size() % 3 ) + throw std::exception("Expected triangular faces"); + + size_t nVerts = vertices.size(); + if ( nVerts >= USHRT_MAX ) + throw std::exception("Too many vertices for 16-bit index buffer"); + + for( auto it = indices.cbegin(); it != indices.cend(); ++it ) + { + if ( *it >= nVerts ) + { + throw std::exception("Index not in vertices list"); + } + } + + // Create the primitive object. + std::unique_ptr primitive(new GeometricPrimitive()); + + primitive->pImpl->Initialize(deviceContext, vertices, indices); + + return primitive; +} diff --git a/Kits/DirectXTK/Src/GraphicsMemory.cpp b/Kits/DirectXTK/Src/GraphicsMemory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ec7789ee36ba45ab39c5a149933744280d60898b --- /dev/null +++ b/Kits/DirectXTK/Src/GraphicsMemory.cpp @@ -0,0 +1,334 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" + +#include "GraphicsMemory.h" +#include "PlatformHelpers.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +namespace +{ + template __forceinline T AlignUp(T value, size_t alignment) + { + assert(((alignment - 1) & alignment) == 0); + return static_cast( (static_cast(value) + alignment - 1) & ~(alignment - 1) ); + } +} + + +#if defined(_XBOX_ONE) && defined(_TITLE) + +//====================================================================================== +// Xbox One Direct3D 11.x +//====================================================================================== + +class GraphicsMemory::Impl +{ +public: + Impl(GraphicsMemory* owner) : + mOwner(owner), + mCurrentFrame(0) + { + if (s_graphicsMemory) + { + throw std::exception("GraphicsMemory is a singleton"); + } + + s_graphicsMemory = this; + } + + ~Impl() + { + if (mDevice && mDeviceContext) + { + UINT64 finalFence = mDeviceContext->InsertFence(0); + + while (mDevice->IsFencePending(finalFence)) + { + SwitchToThread(); + } + + mDeviceContext.Reset(); + mDevice.Reset(); + } + + s_graphicsMemory = nullptr; + } + + void Initialize(_In_ ID3D11DeviceX* device, UINT backBufferCount) + { + assert( device != 0 ); + mDevice = device; + + device->GetImmediateContextX( mDeviceContext.GetAddressOf() ); + + mFrames.resize( backBufferCount ); + } + + void* Allocate(_In_opt_ ID3D11DeviceContext* deviceContext, size_t size, int alignment) + { + // Currently use a single global allocator instead of a per-context allocator + UNREFERENCED_PARAMETER(deviceContext); + + std::lock_guard lock(mGuard); + + return mFrames[mCurrentFrame].Allocate(size, alignment); + } + + void Commit() + { + std::lock_guard lock(mGuard); + + mFrames[mCurrentFrame].mFence = mDeviceContext->InsertFence(D3D11_INSERT_FENCE_NO_KICKOFF); + + ++mCurrentFrame; + if (mCurrentFrame >= mFrames.size()) + { + mCurrentFrame = 0; + } + + mFrames[mCurrentFrame].WaitOnFence(mDevice.Get()); + + mFrames[mCurrentFrame].Clear(); + } + + GraphicsMemory* mOwner; + + std::mutex mGuard; + + struct MemoryPage + { + MemoryPage() : mPageSize(0), mGrfxMemory(nullptr) {} + + void Initialize(size_t reqSize) + { + mPageSize = 0x100000; // 1 MB general pages for Xbox One + if (mPageSize < reqSize) + { + mPageSize = AlignUp(reqSize, 65536); + } + + mGrfxMemory = VirtualAlloc(nullptr, mPageSize, + MEM_LARGE_PAGES | MEM_GRAPHICS | MEM_RESERVE | MEM_COMMIT, + PAGE_WRITECOMBINE | PAGE_READWRITE | PAGE_GPU_READONLY); + if (!mGrfxMemory) + throw std::bad_alloc(); + } + + size_t mPageSize; + void* mGrfxMemory; + }; + + struct MemoryFrame + { + MemoryFrame() : mCurOffset(0), mFence(0) {} + + ~MemoryFrame() { Clear(); } + + UINT mCurOffset; + + UINT64 mFence; + + void* Allocate(size_t size, size_t alignment) + { + size_t alignedSize = AlignUp(size, alignment); + + if (mPages.empty()) + { + MemoryPage newPage; + newPage.Initialize(alignedSize); + + mCurOffset = 0; + + mPages.emplace_back(newPage); + } + else + { + mCurOffset = AlignUp(mCurOffset, alignment); + + if (mCurOffset + alignedSize > mPages.front().mPageSize) + { + MemoryPage newPage; + newPage.Initialize(alignedSize); + + mCurOffset = 0; + + mPages.emplace_front(newPage); + } + } + + void* ptr = static_cast(mPages.front().mGrfxMemory) + mCurOffset; + + mCurOffset += static_cast( alignedSize ); + + return ptr; + } + + void WaitOnFence(ID3D11DeviceX* device) + { + if (mFence) + { + while (device->IsFencePending(mFence)) + { + SwitchToThread(); + } + + mFence = 0; + } + } + + void Clear() + { + for (auto it = mPages.begin(); it != mPages.end(); ++it) + { + if (it->mGrfxMemory) + { + VirtualFree(it->mGrfxMemory, 0, MEM_RELEASE); + it->mGrfxMemory = nullptr; + } + } + + mPages.clear(); + + mCurOffset = 0; + } + + std::list mPages; + }; + + UINT mCurrentFrame; + std::vector mFrames; + + ComPtr mDevice; + ComPtr mDeviceContext; + + static GraphicsMemory::Impl* s_graphicsMemory; +}; + +GraphicsMemory::Impl* GraphicsMemory::Impl::s_graphicsMemory = nullptr; + +#else + +//====================================================================================== +// Null allocator for standard Direct3D 11 +//====================================================================================== + +class GraphicsMemory::Impl +{ +public: + Impl(GraphicsMemory* owner) : + mOwner(owner) + { + if (s_graphicsMemory) + { + throw std::exception("GraphicsMemory is a singleton"); + } + + s_graphicsMemory = this; + } + + ~Impl() + { + s_graphicsMemory = nullptr; + } + + void Initialize(_In_ ID3D11Device* device, UINT backBufferCount) + { + UNREFERENCED_PARAMETER(device); + UNREFERENCED_PARAMETER(backBufferCount); + } + + void* Allocate(_In_opt_ ID3D11DeviceContext* context, size_t size, int alignment) + { + UNREFERENCED_PARAMETER(context); + UNREFERENCED_PARAMETER(size); + UNREFERENCED_PARAMETER(alignment); + return nullptr; + } + + void Commit() + { + } + + GraphicsMemory* mOwner; + + static GraphicsMemory::Impl* s_graphicsMemory; +}; + +GraphicsMemory::Impl* GraphicsMemory::Impl::s_graphicsMemory = nullptr; + +#endif + + +//-------------------------------------------------------------------------------------- + +#pragma warning( disable : 4355 ) + +// Public constructor. +#if defined(_XBOX_ONE) && defined(_TITLE) +GraphicsMemory::GraphicsMemory(_In_ ID3D11DeviceX* device, UINT backBufferCount) +#else +GraphicsMemory::GraphicsMemory(_In_ ID3D11Device* device, UINT backBufferCount) +#endif + : pImpl(new Impl(this)) +{ + pImpl->Initialize(device, backBufferCount); +} + + +// Move constructor. +GraphicsMemory::GraphicsMemory(GraphicsMemory&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ + pImpl->mOwner = this; +} + + +// Move assignment. +GraphicsMemory& GraphicsMemory::operator= (GraphicsMemory&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + pImpl->mOwner = this; + return *this; +} + + +// Public destructor. +GraphicsMemory::~GraphicsMemory() +{ +} + + +void* GraphicsMemory::Allocate(_In_opt_ ID3D11DeviceContext* context, size_t size, int alignment) +{ + return pImpl->Allocate(context, size, alignment); +} + + +void GraphicsMemory::Commit() +{ + pImpl->Commit(); +} + + +GraphicsMemory& GraphicsMemory::Get() +{ + if (!Impl::s_graphicsMemory || !Impl::s_graphicsMemory->mOwner) + throw std::exception("GraphicsMemory singleton not created"); + + return *Impl::s_graphicsMemory->mOwner; +} diff --git a/Kits/DirectXTK/Src/Keyboard.cpp b/Kits/DirectXTK/Src/Keyboard.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3ebf1766f8e513be64f5cbf11f79f93d5a999ac7 --- /dev/null +++ b/Kits/DirectXTK/Src/Keyboard.cpp @@ -0,0 +1,520 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Keyboard.h" + +#include "PlatformHelpers.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + +static_assert(sizeof(Keyboard::State) == (256 / 8), "Size mismatch for State"); + +namespace +{ + void KeyDown(int key, Keyboard::State& state) + { + if (key < 0 || key > 0xfe) + return; + + auto ptr = reinterpret_cast(&state); + + unsigned int bf = 1u << (key & 0x1f); + ptr[(key >> 5)] |= bf; + } + + void KeyUp(int key, Keyboard::State& state) + { + if (key < 0 || key > 0xfe) + return; + + auto ptr = reinterpret_cast(&state); + + unsigned int bf = 1u << (key & 0x1f); + ptr[(key >> 5)] &= ~bf; + } +} + + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) + +//====================================================================================== +// Windows Store or universal Windows app implementation +//====================================================================================== + +// +// For a Windows Store app or universal Windows app, add the following: +// +// void App::SetWindow(CoreWindow^ window ) +// { +// m_keyboard->SetWindow(window); +// } +// + +class Keyboard::Impl +{ +public: + Impl(Keyboard* owner) : + mOwner(owner) + { + mAcceleratorKeyToken.value = 0; + mActivatedToken.value = 0; + + if ( s_keyboard ) + { + throw std::exception( "Keyboard is a singleton" ); + } + + s_keyboard = this; + + memset( &mState, 0, sizeof(State) ); + } + + ~Impl() + { + s_keyboard = nullptr; + + RemoveHandlers(); + } + + void GetState(State& state) const + { + memcpy( &state, &mState, sizeof(State) ); + } + + void Reset() + { + memset( &mState, 0, sizeof(State) ); + } + + void SetWindow(ABI::Windows::UI::Core::ICoreWindow* window) + { + using namespace Microsoft::WRL; + using namespace Microsoft::WRL::Wrappers; + using namespace ABI::Windows::UI::Core; + + if (mWindow.Get() == window) + return; + + RemoveHandlers(); + + mWindow = window; + + if (!window) + return; + + typedef __FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowActivatedEventArgs ActivatedHandler; + HRESULT hr = window->add_Activated(Callback(Activated).Get(), &mActivatedToken); + ThrowIfFailed(hr); + + ComPtr dispatcher; + hr = window->get_Dispatcher( dispatcher.GetAddressOf() ); + ThrowIfFailed(hr); + + ComPtr keys; + hr = dispatcher.As(&keys); + ThrowIfFailed(hr); + + typedef __FITypedEventHandler_2_Windows__CUI__CCore__CCoreDispatcher_Windows__CUI__CCore__CAcceleratorKeyEventArgs AcceleratorKeyHandler; + hr = keys->add_AcceleratorKeyActivated( Callback(AcceleratorKeyEvent).Get(), &mAcceleratorKeyToken); + ThrowIfFailed(hr); + } + + State mState; + Keyboard* mOwner; + + static Keyboard::Impl* s_keyboard; + +private: + ComPtr mWindow; + + EventRegistrationToken mAcceleratorKeyToken; + EventRegistrationToken mActivatedToken; + + void RemoveHandlers() + { + if (mWindow) + { + using namespace ABI::Windows::UI::Core; + + ComPtr dispatcher; + HRESULT hr = mWindow->get_Dispatcher( dispatcher.GetAddressOf() ); + ThrowIfFailed(hr); + + mWindow->remove_Activated(mActivatedToken); + mActivatedToken.value = 0; + + ComPtr keys; + hr = dispatcher.As(&keys); + ThrowIfFailed(hr); + + keys->remove_AcceleratorKeyActivated(mAcceleratorKeyToken); + mAcceleratorKeyToken.value = 0; + } + } + + static HRESULT Activated( IInspectable *, ABI::Windows::UI::Core::IWindowActivatedEventArgs* ) + { + auto pImpl = Impl::s_keyboard; + + if (!pImpl) + return S_OK; + + pImpl->Reset(); + + return S_OK; + } + + static HRESULT AcceleratorKeyEvent( IInspectable *, ABI::Windows::UI::Core::IAcceleratorKeyEventArgs* args ) + { + using namespace ABI::Windows::System; + using namespace ABI::Windows::UI::Core; + + auto pImpl = Impl::s_keyboard; + + if (!pImpl) + return S_OK; + + CoreAcceleratorKeyEventType evtType; + HRESULT hr = args->get_EventType(&evtType); + ThrowIfFailed(hr); + + bool down = false; + + switch (evtType) + { + case CoreAcceleratorKeyEventType_KeyDown: + case CoreAcceleratorKeyEventType_SystemKeyDown: + down = true; + break; + + case CoreAcceleratorKeyEventType_KeyUp: + case CoreAcceleratorKeyEventType_SystemKeyUp: + break; + + default: + return S_OK; + } + + CorePhysicalKeyStatus status; + hr = args->get_KeyStatus(&status); + ThrowIfFailed(hr); + + VirtualKey virtualKey; + hr = args->get_VirtualKey(&virtualKey); + ThrowIfFailed(hr); + + int vk = static_cast( virtualKey ); + + 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_CONTROL: + vk = (status.IsExtendedKey) ? VK_RCONTROL : VK_LCONTROL; + break; + + case VK_MENU: + vk = (status.IsExtendedKey) ? VK_RMENU : VK_LMENU; + break; + } + + if (down) + { + KeyDown(vk, pImpl->mState); + } + else + { + KeyUp(vk, pImpl->mState); + } + + return S_OK; + } +}; + + +Keyboard::Impl* Keyboard::Impl::s_keyboard = nullptr; + + +void Keyboard::SetWindow(ABI::Windows::UI::Core::ICoreWindow* window) +{ + pImpl->SetWindow(window); +} + +#elif defined(_XBOX_ONE) || ( defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) ) + +//====================================================================================== +// Null device for Windows Phone and Xbox One +//====================================================================================== + +class Keyboard::Impl +{ +public: + Impl(Keyboard* owner) : + mOwner(owner) + { + if ( s_keyboard ) + { + throw std::exception( "Keyboard is a singleton" ); + } + + s_keyboard = this; + } + + ~Impl() + { + s_keyboard = nullptr; + } + + void GetState(State& state) const + { + memset( &state, 0, sizeof(State) ); + } + + void Reset() + { + } + + Keyboard* mOwner; + + static Keyboard::Impl* s_keyboard; +}; + +Keyboard::Impl* Keyboard::Impl::s_keyboard = nullptr; + +#else + +//====================================================================================== +// Win32 desktop implementation +//====================================================================================== + +// +// For a Win32 desktop application, call this function from your Window Message Procedure +// +// LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +// { +// switch (message) +// { +// +// case WM_ACTIVATEAPP: +// Keyboard::ProcessMessage(message, wParam, lParam); +// break; +// +// case WM_KEYDOWN: +// case WM_SYSKEYDOWN: +// case WM_KEYUP: +// case WM_SYSKEYUP: +// Keyboard::ProcessMessage(message, wParam, lParam); +// break; +// +// } +// } +// + +class Keyboard::Impl +{ +public: + Impl(Keyboard* owner) : + mOwner(owner) + { + if ( s_keyboard ) + { + throw std::exception( "Keyboard is a singleton" ); + } + + s_keyboard = this; + + memset( &mState, 0, sizeof(State) ); + } + + ~Impl() + { + s_keyboard = nullptr; + } + + void GetState(State& state) const + { + memcpy( &state, &mState, sizeof(State) ); + } + + void Reset() + { + memset( &mState, 0, sizeof(State) ); + } + + State mState; + Keyboard* mOwner; + + static Keyboard::Impl* s_keyboard; +}; + + +Keyboard::Impl* Keyboard::Impl::s_keyboard = nullptr; + + +void Keyboard::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) +{ + auto pImpl = Impl::s_keyboard; + + if (!pImpl) + return; + + bool down = false; + + switch (message) + { + case WM_ACTIVATEAPP: + pImpl->Reset(); + return; + + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + down = true; + break; + + case WM_KEYUP: + case WM_SYSKEYUP: + break; + + default: + return; + } + + int vk = static_cast( 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_CONTROL: + vk = (lParam & 0x01000000) ? VK_RCONTROL : VK_LCONTROL; + break; + + case VK_MENU: + vk = (lParam & 0x01000000) ? VK_RMENU : VK_LMENU; + break; + } + + if (down) + { + KeyDown(vk, pImpl->mState); + } + else + { + KeyUp(vk, pImpl->mState); + } +} + +#endif + +#pragma warning( disable : 4355 ) + +// Public constructor. +Keyboard::Keyboard() + : pImpl( new Impl(this) ) +{ +} + + +// Move constructor. +Keyboard::Keyboard(Keyboard&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ + pImpl->mOwner = this; +} + + +// Move assignment. +Keyboard& Keyboard::operator= (Keyboard&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + pImpl->mOwner = this; + return *this; +} + + +// Public destructor. +Keyboard::~Keyboard() +{ +} + + +Keyboard::State Keyboard::GetState() const +{ + State state; + pImpl->GetState(state); + return state; +} + + +void Keyboard::Reset() +{ + pImpl->Reset(); +} + + +Keyboard& Keyboard::Get() +{ + if ( !Impl::s_keyboard || !Impl::s_keyboard->mOwner ) + throw std::exception( "Keyboard is a singleton" ); + + return *Impl::s_keyboard->mOwner; +} + + + +//====================================================================================== +// KeyboardStateTracker +//====================================================================================== + +void Keyboard::KeyboardStateTracker::Update( const State& state ) +{ + auto currPtr = reinterpret_cast(&state); + auto prevPtr = reinterpret_cast(&lastState); + auto releasedPtr = reinterpret_cast(&released); + auto pressedPtr = reinterpret_cast(&pressed); + for (size_t j = 0; j < (256 / 32); ++j) + { + *pressedPtr = *currPtr & ~(*prevPtr); + *releasedPtr = ~(*currPtr) & *prevPtr; + + ++currPtr; + ++prevPtr; + ++releasedPtr; + ++pressedPtr; + } + + lastState = state; +} + + +void Keyboard::KeyboardStateTracker::Reset() +{ + memset( this, 0, sizeof(KeyboardStateTracker) ); +} diff --git a/Kits/DirectXTK/Src/Model.cpp b/Kits/DirectXTK/Src/Model.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e14bde1ff4efea805489bad50e98605b38d85108 --- /dev/null +++ b/Kits/DirectXTK/Src/Model.cpp @@ -0,0 +1,287 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Model.h" + +#include "CommonStates.h" +#include "DirectXHelpers.h" +#include "Effects.h" +#include "PlatformHelpers.h" + +using namespace DirectX; + +#ifndef _CPPRTTI +#error Model requires RTTI +#endif + +//-------------------------------------------------------------------------------------- +// ModelMeshPart +//-------------------------------------------------------------------------------------- + +ModelMeshPart::ModelMeshPart() : + indexCount(0), + startIndex(0), + vertexOffset(0), + vertexStride(0), + primitiveType(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST), + indexFormat(DXGI_FORMAT_R16_UINT), + isAlpha(false) +{ +} + + +ModelMeshPart::~ModelMeshPart() +{ +} + + +_Use_decl_annotations_ +void ModelMeshPart::Draw( ID3D11DeviceContext* deviceContext, IEffect* ieffect, ID3D11InputLayout* iinputLayout, std::function setCustomState ) const +{ + deviceContext->IASetInputLayout( iinputLayout ); + + auto vb = vertexBuffer.Get(); + UINT vbStride = vertexStride; + UINT vbOffset = 0; + deviceContext->IASetVertexBuffers( 0, 1, &vb, &vbStride, &vbOffset ); + + // Note that if indexFormat is DXGI_FORMAT_R32_UINT, this model mesh part requires a Feature Level 9.2 or greater device + deviceContext->IASetIndexBuffer( indexBuffer.Get(), indexFormat, 0 ); + + assert( ieffect != 0 ); + ieffect->Apply( deviceContext ); + + // Hook lets the caller replace our shaders or state settings with whatever else they see fit. + if ( setCustomState ) + { + setCustomState(); + } + + // Draw the primitive. + deviceContext->IASetPrimitiveTopology( primitiveType ); + + deviceContext->DrawIndexed( indexCount, startIndex, vertexOffset ); +} + + +_Use_decl_annotations_ +void ModelMeshPart::CreateInputLayout( ID3D11Device* d3dDevice, IEffect* ieffect, ID3D11InputLayout** iinputLayout ) +{ + if ( !vbDecl || vbDecl->empty() ) + throw std::exception("Model mesh part missing vertex buffer input elements data"); + + void const* shaderByteCode; + size_t byteCodeLength; + + assert( ieffect != 0 ); + ieffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength); + + assert( d3dDevice != 0 ); + + ThrowIfFailed( + d3dDevice->CreateInputLayout(vbDecl->data(), + static_cast( vbDecl->size() ), + shaderByteCode, byteCodeLength, + iinputLayout ) + ); +} + + +_Use_decl_annotations_ +void ModelMeshPart::ModifyEffect( ID3D11Device* d3dDevice, std::shared_ptr& ieffect, bool isalpha ) +{ + if ( !vbDecl || vbDecl->empty() ) + throw std::exception("Model mesh part missing vertex buffer input elements data"); + + assert( ieffect != 0 ); + this->effect = ieffect; + this->isAlpha = isalpha; + + void const* shaderByteCode; + size_t byteCodeLength; + + effect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength); + + assert( d3dDevice != 0 ); + + ThrowIfFailed( + d3dDevice->CreateInputLayout(vbDecl->data(), + static_cast( vbDecl->size() ), + shaderByteCode, byteCodeLength, + &inputLayout ) + ); +} + + +//-------------------------------------------------------------------------------------- +// ModelMesh +//-------------------------------------------------------------------------------------- + +ModelMesh::ModelMesh() : + ccw(true), + pmalpha(true) +{ +} + + +ModelMesh::~ModelMesh() +{ +} + + +_Use_decl_annotations_ +void ModelMesh::PrepareForRendering( ID3D11DeviceContext* deviceContext, CommonStates& states, bool alpha, bool wireframe ) const +{ + assert( deviceContext != 0 ); + + // Set the blend and depth stencil state. + ID3D11BlendState* blendState; + ID3D11DepthStencilState* depthStencilState; + + if ( alpha ) + { + if ( pmalpha ) + { + blendState = states.AlphaBlend(); + depthStencilState = states.DepthRead(); + } + else + { + blendState = states.NonPremultiplied(); + depthStencilState = states.DepthRead(); + } + } + else + { + blendState = states.Opaque(); + depthStencilState = states.DepthDefault(); + } + + deviceContext->OMSetBlendState(blendState, nullptr, 0xFFFFFFFF); + deviceContext->OMSetDepthStencilState(depthStencilState, 0); + + // Set the rasterizer state. + if ( wireframe ) + deviceContext->RSSetState( states.Wireframe() ); + else + deviceContext->RSSetState( ccw ? states.CullCounterClockwise() : states.CullClockwise() ); + + // Set sampler state. + ID3D11SamplerState* samplers[] = + { + states.LinearWrap(), + states.LinearWrap(), + }; + + deviceContext->PSSetSamplers( 0, 2, samplers ); +} + + +_Use_decl_annotations_ +void XM_CALLCONV ModelMesh::Draw( ID3D11DeviceContext* deviceContext, + FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, + bool alpha, + std::function setCustomState ) const +{ + assert( deviceContext != 0 ); + + for ( auto it = meshParts.cbegin(); it != meshParts.cend(); ++it ) + { + auto part = (*it).get(); + assert( part != 0 ); + + if ( part->isAlpha != alpha ) + { + // Skip alpha parts when drawing opaque or skip opaque parts if drawing alpha + continue; + } + + auto imatrices = dynamic_cast( part->effect.get() ); + if ( imatrices ) + { + imatrices->SetWorld( world ); + imatrices->SetView( view ); + imatrices->SetProjection( projection ); + } + + part->Draw( deviceContext, part->effect.get(), part->inputLayout.Get(), setCustomState ); + } +} + + +//-------------------------------------------------------------------------------------- +// Model +//-------------------------------------------------------------------------------------- + +Model::~Model() +{ +} + + +_Use_decl_annotations_ +void XM_CALLCONV Model::Draw( ID3D11DeviceContext* deviceContext, CommonStates& states, + FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection, + bool wireframe, std::function setCustomState ) const +{ + assert( deviceContext != 0 ); + + // Draw opaque parts + for( auto it = meshes.cbegin(); it != meshes.cend(); ++it ) + { + auto mesh = it->get(); + assert( mesh != 0 ); + + mesh->PrepareForRendering( deviceContext, states, false, wireframe ); + + mesh->Draw( deviceContext, world, view, projection, false, setCustomState ); + } + + // Draw alpha parts + for( auto it = meshes.cbegin(); it != meshes.cend(); ++it ) + { + auto mesh = it->get(); + assert( mesh != 0 ); + + mesh->PrepareForRendering( deviceContext, states, true, wireframe ); + + mesh->Draw( deviceContext, world, view, projection, true, setCustomState ); + } +} + + +void Model::UpdateEffects( _In_ std::function setEffect ) +{ + if ( mEffectCache.empty() ) + { + // This cache ensures we only set each effect once (could be shared) + for( auto mit = meshes.cbegin(); mit != meshes.cend(); ++mit ) + { + auto mesh = mit->get(); + assert( mesh != 0 ); + + for ( auto it = mesh->meshParts.cbegin(); it != mesh->meshParts.cend(); ++it ) + { + if ( (*it)->effect != 0 ) + mEffectCache.insert( (*it)->effect.get() ); + } + } + } + + assert( setEffect != 0 ); + + for( auto it = mEffectCache.begin(); it != mEffectCache.end(); ++it ) + { + setEffect( *it ); + } +} diff --git a/Kits/DirectXTK/Src/ModelLoadCMO.cpp b/Kits/DirectXTK/Src/ModelLoadCMO.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2a6a6bd92d4d1979aaa184d68684df3c55e7e22 --- /dev/null +++ b/Kits/DirectXTK/Src/ModelLoadCMO.cpp @@ -0,0 +1,849 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Model.h" + +#include "DDSTextureLoader.h" +#include "Effects.h" +#include "VertexTypes.h" + +#include "DirectXHelpers.h" +#include "PlatformHelpers.h" +#include "BinaryReader.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +//-------------------------------------------------------------------------------------- +// .CMO files are built by Visual Studio 2012 and an example renderer is provided +// in the VS Direct3D Starter Kit +// http://code.msdn.microsoft.com/Visual-Studio-3D-Starter-455a15f1 +//-------------------------------------------------------------------------------------- + +namespace VSD3DStarter +{ + // .CMO files + + // UINT - Mesh count + // { [Mesh count] + // UINT - Length of name + // wchar_t[] - Name of mesh (if length > 0) + // UINT - Material count + // { [Material count] + // UINT - Length of material name + // wchar_t[] - Name of material (if length > 0) + // Material structure + // UINT - Length of pixel shader name + // wchar_t[] - Name of pixel shader (if length > 0) + // { [8] + // UINT - Length of texture name + // wchar_t[] - Name of texture (if length > 0) + // } + // } + // BYTE - 1 if there is skeletal animation data present + // UINT - SubMesh count + // { [SubMesh count] + // SubMesh structure + // } + // UINT - IB Count + // { [IB Count] + // UINT - Number of USHORTs in IB + // USHORT[] - Array of indices + // } + // UINT - VB Count + // { [VB Count] + // UINT - Number of verts in VB + // Vertex[] - Array of vertices + // } + // UINT - Skinning VB Count + // { [Skinning VB Count] + // UINT - Number of verts in Skinning VB + // SkinningVertex[] - Array of skinning verts + // } + // MeshExtents structure + // [If skeleton animation data is not present, file ends here] + // UINT - Bone count + // { [Bone count] + // UINT - Length of bone name + // wchar_t[] - Bone name (if length > 0) + // Bone structure + // } + // UINT - Animation clip count + // { [Animation clip count] + // UINT - Length of clip name + // wchar_t[] - Clip name (if length > 0) + // float - Start time + // float - End time + // UINT - Keyframe count + // { [Keyframe count] + // Keyframe structure + // } + // } + // } + + #pragma pack(push,1) + + struct Material + { + DirectX::XMFLOAT4 Ambient; + DirectX::XMFLOAT4 Diffuse; + DirectX::XMFLOAT4 Specular; + float SpecularPower; + DirectX::XMFLOAT4 Emissive; + DirectX::XMFLOAT4X4 UVTransform; + }; + + const uint32_t MAX_TEXTURE = 8; + + struct SubMesh + { + UINT MaterialIndex; + UINT IndexBufferIndex; + UINT VertexBufferIndex; + UINT StartIndex; + UINT PrimCount; + }; + + const uint32_t NUM_BONE_INFLUENCES = 4; + + static_assert( sizeof(VertexPositionNormalTangentColorTexture) == 52, "mismatch with CMO vertex type" ); + + struct SkinningVertex + { + UINT boneIndex[NUM_BONE_INFLUENCES]; + float boneWeight[NUM_BONE_INFLUENCES]; + }; + + struct MeshExtents + { + float CenterX, CenterY, CenterZ; + float Radius; + + float MinX, MinY, MinZ; + float MaxX, MaxY, MaxZ; + }; + + struct Bone + { + INT ParentIndex; + DirectX::XMFLOAT4X4 InvBindPos; + DirectX::XMFLOAT4X4 BindPos; + DirectX::XMFLOAT4X4 LocalTransform; + }; + + struct Clip + { + float StartTime; + float EndTime; + UINT keys; + }; + + struct Keyframe + { + UINT BoneIndex; + float Time; + DirectX::XMFLOAT4X4 Transform; + }; + + #pragma pack(pop) + +}; // 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" ); + +//-------------------------------------------------------------------------------------- +struct MaterialRecordCMO +{ + const VSD3DStarter::Material* pMaterial; + std::wstring name; + std::wstring pixelShader; + std::wstring texture[VSD3DStarter::MAX_TEXTURE]; + std::shared_ptr effect; + ComPtr il; +}; + +// Helper for creating a D3D input layout. +static void CreateInputLayout(_In_ ID3D11Device* device, IEffect* effect, _Out_ ID3D11InputLayout** pInputLayout, bool skinning ) +{ + void const* shaderByteCode; + size_t byteCodeLength; + + effect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength); + + if ( skinning ) + { + ThrowIfFailed( + device->CreateInputLayout( VertexPositionNormalTangentColorTextureSkinning::InputElements, + VertexPositionNormalTangentColorTextureSkinning::InputElementCount, + shaderByteCode, byteCodeLength, + pInputLayout) + ); + } + else + { + ThrowIfFailed( + device->CreateInputLayout( VertexPositionNormalTangentColorTexture::InputElements, + VertexPositionNormalTangentColorTexture::InputElementCount, + shaderByteCode, byteCodeLength, + pInputLayout) + ); + } + + SetDebugObjectName(*pInputLayout, "ModelCMO"); +} + +// Shared VB input element description +static INIT_ONCE g_InitOnce = INIT_ONCE_STATIC_INIT; +static std::shared_ptr> g_vbdecl; +static std::shared_ptr> g_vbdeclSkinning; + +static BOOL CALLBACK InitializeDecl( PINIT_ONCE initOnce, PVOID Parameter, PVOID *lpContext ) +{ + UNREFERENCED_PARAMETER( initOnce ); + UNREFERENCED_PARAMETER( Parameter ); + UNREFERENCED_PARAMETER( lpContext ); + + g_vbdecl = std::make_shared>( VertexPositionNormalTangentColorTexture::InputElements, + VertexPositionNormalTangentColorTexture::InputElements + VertexPositionNormalTangentColorTexture::InputElementCount ); + + g_vbdeclSkinning = std::make_shared>( VertexPositionNormalTangentColorTextureSkinning::InputElements, + VertexPositionNormalTangentColorTextureSkinning::InputElements + VertexPositionNormalTangentColorTextureSkinning::InputElementCount ); + return TRUE; +} + + +//====================================================================================== +// Model Loader +//====================================================================================== + +_Use_decl_annotations_ +std::unique_ptr 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 ) ) + throw std::exception("One-time initialization failed"); + + if ( !d3dDevice || !meshData ) + throw std::exception("Device and meshData cannot be null"); + + auto fxFactoryDGSL = dynamic_cast( &fxFactory ); + + // Meshes + auto nMesh = reinterpret_cast( meshData ); + size_t usedSize = sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( !*nMesh ) + throw std::exception("No meshes found"); + + std::unique_ptr model(new Model()); + + for( UINT meshIndex = 0; meshIndex < *nMesh; ++meshIndex ) + { + // Mesh name + auto nName = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + auto meshName = reinterpret_cast( meshData + usedSize ); + + usedSize += sizeof(wchar_t)*(*nName); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + auto mesh = std::make_shared(); + mesh->name.assign( meshName, *nName ); + mesh->ccw = ccw; + mesh->pmalpha = pmalpha; + + // Materials + auto nMats = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + std::vector materials; + materials.reserve( *nMats ); + for( UINT j = 0; j < *nMats; ++j ) + { + MaterialRecordCMO m; + + // Material name + nName = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + auto matName = reinterpret_cast( meshData + usedSize ); + + usedSize += sizeof(wchar_t)*(*nName); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + m.name.assign( matName, *nName ); + + // Material settings + auto matSetting = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(VSD3DStarter::Material); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + m.pMaterial = matSetting; + + // Pixel shader name + nName = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + auto psName = reinterpret_cast( meshData + usedSize ); + + usedSize += sizeof(wchar_t)*(*nName); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + m.pixelShader.assign( psName, *nName ); + + for( UINT t = 0; t < VSD3DStarter::MAX_TEXTURE; ++t ) + { + nName = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + auto txtName = reinterpret_cast( meshData + usedSize ); + + usedSize += sizeof(wchar_t)*(*nName); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + m.texture[t].assign( txtName, *nName ); + } + + materials.emplace_back( m ); + } + + assert( materials.size() == *nMats ); + + // Skeletal data? + auto bSkeleton = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(BYTE); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + // Submeshes + auto nSubmesh = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( !*nSubmesh ) + throw std::exception("No submeshes found\n"); + + auto subMesh = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(VSD3DStarter::SubMesh) * (*nSubmesh); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + // Index buffers + auto nIBs = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( !*nIBs ) + throw std::exception("No index buffers found\n"); + + struct IBData + { + size_t nIndices; + const USHORT* ptr; + }; + + std::vector ibData; + ibData.reserve( *nIBs ); + + std::vector> ibs; + ibs.resize( *nIBs ); + + for( UINT j = 0; j < *nIBs; ++j ) + { + auto nIndexes = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( !*nIndexes ) + throw std::exception("Empty index buffer found\n"); + + size_t ibBytes = sizeof(USHORT) * (*(nIndexes)); + + auto indexes = reinterpret_cast( meshData + usedSize ); + usedSize += ibBytes; + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + IBData ib; + ib.nIndices = *nIndexes; + ib.ptr = indexes; + ibData.emplace_back( ib ); + + D3D11_BUFFER_DESC desc = {0}; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = static_cast( ibBytes ); + desc.BindFlags = D3D11_BIND_INDEX_BUFFER; + + D3D11_SUBRESOURCE_DATA initData = {0}; + initData.pSysMem = indexes; + + ThrowIfFailed( + d3dDevice->CreateBuffer( &desc, &initData, &ibs[j] ) + ); + + SetDebugObjectName( ibs[j].Get(), "ModelCMO" ); + } + + assert( ibData.size() == *nIBs ); + assert( ibs.size() == *nIBs ); + + // Vertex buffers + auto nVBs = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( !*nVBs ) + throw std::exception("No vertex buffers found\n"); + + struct VBData + { + size_t nVerts; + const VertexPositionNormalTangentColorTexture* ptr; + const VSD3DStarter::SkinningVertex* skinPtr; + }; + + std::vector vbData; + vbData.reserve( *nVBs ); + for( UINT j = 0; j < *nVBs; ++j ) + { + auto nVerts = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( !*nVerts ) + throw std::exception("Empty vertex buffer found\n"); + + size_t vbBytes = sizeof(VertexPositionNormalTangentColorTexture) * (*(nVerts)); + + auto verts = reinterpret_cast( meshData + usedSize ); + usedSize += vbBytes; + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + VBData vb; + vb.nVerts = *nVerts; + vb.ptr = verts; + vb.skinPtr = nullptr; + vbData.emplace_back( vb ); + } + + assert( vbData.size() == *nVBs ); + + // Skinning vertex buffers + auto nSkinVBs = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( *nSkinVBs ) + { + if ( *nSkinVBs != *nVBs ) + throw std::exception("Number of VBs not equal to number of skin VBs"); + + for( UINT j = 0; j < *nSkinVBs; ++j ) + { + auto nVerts = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( !*nVerts ) + throw std::exception("Empty skinning vertex buffer found\n"); + + 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( meshData + usedSize ); + usedSize += vbBytes; + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + vbData[j].skinPtr = verts; + } + } + + // Extents + auto extents = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(VSD3DStarter::MeshExtents); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + mesh->boundingSphere.Center.x = extents->CenterX; + mesh->boundingSphere.Center.y = extents->CenterY; + 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 ); + +#if 0 + // Animation data + if ( *bSkeleton ) + { + // Bones + auto nBones = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( !*nBones ) + throw std::exception("Animation bone data is missing\n"); + + for( UINT j = 0; j < *nBones; ++j ) + { + // Bone name + nName = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + auto boneName = reinterpret_cast( meshData + usedSize ); + + usedSize += sizeof(wchar_t)*(*nName); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + // TODO - What to do with bone name? + boneName; + + // Bone settings + auto bones = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(VSD3DStarter::Bone); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + // TODO - What to do with bone data? + bones; + } + + // Animation Clips + auto nClips = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + for( UINT j = 0; j < *nClips; ++j ) + { + // Clip name + nName = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(UINT); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + auto clipName = reinterpret_cast( meshData + usedSize ); + + usedSize += sizeof(wchar_t)*(*nName); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + // TODO - What to do with clip name? + clipName; + + auto clip = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(VSD3DStarter::Clip); + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + if ( !clip->keys ) + throw std::exception("Keyframes missing in clip"); + + auto keys = reinterpret_cast( meshData + usedSize ); + usedSize += sizeof(VSD3DStarter::Keyframe) * clip->keys; + if ( dataSize < usedSize ) + throw std::exception("End of file"); + + // TODO - What to do with keys and clip->StartTime, clip->EndTime? + keys; + } + } +#else + UNREFERENCED_PARAMETER(bSkeleton); +#endif + + bool enableSkinning = ( *nSkinVBs ) != 0; + + // Build vertex buffers + std::vector> vbs; + vbs.resize( *nVBs ); + + const size_t stride = enableSkinning ? sizeof(VertexPositionNormalTangentColorTextureSkinning) + : sizeof(VertexPositionNormalTangentColorTexture); + + for( UINT j = 0; j < *nVBs; ++j ) + { + size_t nVerts = vbData[ j ].nVerts; + + size_t bytes = stride * nVerts; + + D3D11_BUFFER_DESC desc = {0}; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = static_cast( bytes ); + desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + + if ( fxFactoryDGSL && !enableSkinning ) + { + // Can use CMO vertex data directly + D3D11_SUBRESOURCE_DATA initData = {0}; + initData.pSysMem = vbData[j].ptr; + + ThrowIfFailed( + d3dDevice->CreateBuffer( &desc, &initData, &vbs[j] ) + ); + } + else + { + std::unique_ptr temp( new uint8_t[ bytes + ( sizeof(UINT) * nVerts ) ] ); + + auto visited = reinterpret_cast( temp.get() + bytes ); + memset( visited, 0xff, sizeof(UINT) * nVerts ); + + assert( vbData[j].ptr != 0 ); + + if ( enableSkinning ) + { + // Combine CMO multi-stream data into a single stream + auto skinptr = vbData[j].skinPtr; + assert( skinptr != 0 ); + + uint8_t* ptr = temp.get(); + + auto sptr = vbData[j].ptr; + + for( size_t v = 0; v < nVerts; ++v ) + { + *reinterpret_cast( ptr ) = *sptr; + ++sptr; + + auto skinv = reinterpret_cast( ptr ); + skinv->SetBlendIndices( *reinterpret_cast( skinptr->boneIndex ) ); + skinv->SetBlendWeights( *reinterpret_cast( skinptr->boneWeight ) ); + + ptr += stride; + } + } + else + { + memcpy( temp.get(), vbData[j].ptr, bytes ); + } + + 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 ) + { + auto& sm = subMesh[ k ]; + + if ( sm.VertexBufferIndex != j ) + continue; + + if ( (sm.IndexBufferIndex >= *nIBs) + || (sm.MaterialIndex >= *nMats) ) + throw std::exception("Invalid submesh found\n"); + + XMMATRIX uvTransform = XMLoadFloat4x4( &materials[ sm.MaterialIndex ].pMaterial->UVTransform ); + + auto ib = ibData[ sm.IndexBufferIndex ].ptr; + + size_t count = ibData[ sm.IndexBufferIndex ].nIndices; + + for( size_t q = 0; q < count; ++q ) + { + size_t v = ib[ q ]; + + if ( v >= nVerts ) + throw std::exception("Invalid index found\n"); + + auto verts = reinterpret_cast( temp.get() + ( v * stride ) ); + if ( visited[v] == UINT(-1) ) + { + visited[v] = sm.MaterialIndex; + + XMVECTOR t = XMLoadFloat2( &verts->textureCoordinate ); + + t = XMVectorSelect( g_XMIdentityR3, t, g_XMSelect1110 ); + + t = XMVector4Transform( t, uvTransform ); + + XMStoreFloat2( &verts->textureCoordinate, t ); + } + else if ( visited[v] != sm.MaterialIndex ) + { +#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] ) ) + { + DebugTrace( "WARNING: %ls - mismatched UV transforms for the same vertex; texture coordinates may not be correct\n", mesh->name.c_str() ); + } +#endif + } + } + } + } + + // Create vertex buffer from temporary buffer + D3D11_SUBRESOURCE_DATA initData = {0}; + initData.pSysMem = temp.get(); + + ThrowIfFailed( + d3dDevice->CreateBuffer( &desc, &initData, &vbs[j] ) + ); + } + + SetDebugObjectName( vbs[j].Get(), "ModelCMO" ); + } + + assert( vbs.size() == *nVBs ); + + // Create Effects + for( UINT j = 0; j < *nMats; ++j ) + { + auto& m = materials[ j ]; + + if ( fxFactoryDGSL ) + { + DGSLEffectFactory::DGSLEffectInfo info; + info.name = m.name.c_str(); + info.specularPower = m.pMaterial->SpecularPower; + 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.texture = m.texture[0].empty() ? nullptr : m.texture[0].c_str(); + info.texture2 = m.texture[1].empty() ? nullptr : m.texture[1].c_str(); + info.pixelShader = m.pixelShader.c_str(); + + for( int i = 0; i < 6; ++i ) + { + info.textures[i] = m.texture[ i+2 ].empty() ? nullptr : m.texture[ i+2 ].c_str(); + } + + m.effect = fxFactoryDGSL->CreateDGSLEffect( info, nullptr ); + + auto dgslEffect = static_cast( m.effect.get() ); + dgslEffect->SetUVTransform( XMLoadFloat4x4( &m.pMaterial->UVTransform ) ); + } + else + { + EffectFactory::EffectInfo info; + info.name = m.name.c_str(); + info.specularPower = m.pMaterial->SpecularPower; + 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.texture = m.texture[0].c_str(); + + m.effect = fxFactory.CreateEffect( info, nullptr ); + } + + CreateInputLayout( d3dDevice, m.effect.get(), &m.il, enableSkinning ); + } + + // Build mesh parts + for( UINT j = 0; j < *nSubmesh; ++j ) + { + auto& sm = subMesh[j]; + + if ( (sm.IndexBufferIndex >= *nIBs) + || (sm.VertexBufferIndex >= *nVBs) + || (sm.MaterialIndex >= *nMats) ) + throw std::exception("Invalid submesh found\n"); + + auto& mat = materials[ sm.MaterialIndex ]; + + auto part = new ModelMeshPart(); + + if ( mat.pMaterial->Diffuse.w < 1 ) + part->isAlpha = true; + + part->indexCount = sm.PrimCount * 3; + part->startIndex = sm.StartIndex; + part->vertexStride = static_cast( stride ); + part->inputLayout = mat.il; + 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 ); + } + + model->meshes.emplace_back( mesh ); + } + + return model; +} + + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +std::unique_ptr DirectX::Model::CreateFromCMO( ID3D11Device* d3dDevice, const wchar_t* szFileName, IEffectFactory& fxFactory, bool ccw, bool pmalpha ) +{ + size_t dataSize = 0; + std::unique_ptr data; + HRESULT hr = BinaryReader::ReadEntireFile( szFileName, data, &dataSize ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateFromCMO failed (%08X) loading '%ls'\n", hr, szFileName ); + throw std::exception( "CreateFromCMO" ); + } + + auto model = CreateFromCMO( d3dDevice, data.get(), dataSize, fxFactory, ccw, pmalpha ); + + model->name = szFileName; + + return model; +} diff --git a/Kits/DirectXTK/Src/ModelLoadSDKMESH.cpp b/Kits/DirectXTK/Src/ModelLoadSDKMESH.cpp new file mode 100644 index 0000000000000000000000000000000000000000..051434a673323d0955f84897d32f94f912fa02a1 --- /dev/null +++ b/Kits/DirectXTK/Src/ModelLoadSDKMESH.cpp @@ -0,0 +1,935 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Model.h" + +#include "Effects.h" +#include "VertexTypes.h" + +#include "DirectXHelpers.h" +#include "PlatformHelpers.h" +#include "BinaryReader.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + +#pragma warning(disable : 4121) + +//-------------------------------------------------------------------------------------- +// SDKMESH format is generated by the legacy DirectX SDK's Content Exporter and +// originally rendered by the DXUT helper class SDKMesh +// +// http://go.microsoft.com/fwlink/?LinkId=226208 +//-------------------------------------------------------------------------------------- +namespace DXUT +{ + // .SDKMESH files + + // SDKMESH_HEADER + // SDKMESH_VERTEX_BUFFER_HEADER header->VertexStreamHeadersOffset + // SDKMESH_INDEX_BUFFER_HEADER header->IndexStreamHeadersOffset + // SDKMESH_MESH header->MeshDataOffset + // SDKMESH_SUBSET header->SubsetDataOffset + // SDKMESH_FRAME header->FrameDataOffset + // SDKMESH_MATERIAL header->MaterialDataOffset + // [header->NonBufferDataSize] + // { [ header->NumVertexBuffers] + // VB data + // } + // { [ header->NumIndexBuffers] + // IB data + // } + + + // .SDDKANIM files + + // SDKANIMATION_FILE_HEADER + // BYTE[] - Length of fileheader->AnimationDataSize + + // .SDKMESH uses Direct3D 9 decls, but only a subset of these is ever generated by the legacy DirectX SDK Content Exporter + + // D3DDECLUSAGE_POSITION / D3DDECLTYPE_FLOAT3 + // (D3DDECLUSAGE_BLENDWEIGHT / D3DDECLTYPE_UBYTE4N + // D3DDECLUSAGE_BLENDINDICES / D3DDECLTYPE_UBYTE4)? + // (D3DDECLUSAGE_NORMAL / D3DDECLTYPE_FLOAT3, D3DDECLTYPE_FLOAT16_4, D3DDECLTYPE_SHORT4N, D3DDECLTYPE_UBYTE4N, or D3DDECLTYPE_DEC3N [not supported])? + // (D3DDECLUSAGE_COLOR / D3DDECLTYPE_D3DCOLOR)? + // (D3DDECLUSAGE_TEXCOORD / D3DDECLTYPE_FLOAT1, D3DDECLTYPE_FLOAT2 or D3DDECLTYPE_FLOAT16_2, D3DDECLTYPE_FLOAT3 or D3DDECLTYPE_FLOAT16_4, D3DDECLTYPE_FLOAT4 or D3DDECLTYPE_FLOAT16_4)* + // (D3DDECLUSAGE_TANGENT / same as D3DDECLUSAGE_NORMAL)? + // (D3DDECLUSAGE_BINORMAL / same as D3DDECLUSAGE_NORMAL)? + + enum D3DDECLUSAGE + { + D3DDECLUSAGE_POSITION = 0, + D3DDECLUSAGE_BLENDWEIGHT =1, + D3DDECLUSAGE_BLENDINDICES =2, + D3DDECLUSAGE_NORMAL =3, + D3DDECLUSAGE_TEXCOORD = 5, + D3DDECLUSAGE_TANGENT = 6, + D3DDECLUSAGE_BINORMAL = 7, + D3DDECLUSAGE_COLOR = 10, + }; + + enum D3DDECLTYPE + { + D3DDECLTYPE_FLOAT1 = 0, // 1D float expanded to (value, 0., 0., 1.) + D3DDECLTYPE_FLOAT2 = 1, // 2D float expanded to (value, value, 0., 1.) + D3DDECLTYPE_FLOAT3 = 2, // 3D float expanded to (value, value, value, 1.) + D3DDECLTYPE_FLOAT4 = 3, // 4D float + D3DDECLTYPE_D3DCOLOR = 4, // 4D packed unsigned bytes mapped to 0. to 1. range + // Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A) + D3DDECLTYPE_UBYTE4 = 5, // 4D unsigned byte + D3DDECLTYPE_UBYTE4N = 8, // Each of 4 bytes is normalized by dividing to 255.0 + D3DDECLTYPE_SHORT4N = 10, // 4D signed short normalized (v[0]/32767.0,v[1]/32767.0,v[2]/32767.0,v[3]/32767.0) + // Note: There is no equivalent to D3DDECLTYPE_DEC3N (14) as a DXGI_FORMAT + D3DDECLTYPE_FLOAT16_2 = 15, // Two 16-bit floating point values, expanded to (value, value, 0, 1) + D3DDECLTYPE_FLOAT16_4 = 16, // Four 16-bit floating point values + + D3DDECLTYPE_UNUSED = 17, // When the type field in a decl is unused. + }; + + #pragma pack(push,4) + + struct D3DVERTEXELEMENT9 + { + WORD Stream; // Stream index + WORD Offset; // Offset in the stream in bytes + BYTE Type; // Data type + BYTE Method; // Processing method + BYTE Usage; // Semantics + BYTE UsageIndex; // Semantic index + }; + + #pragma pack(pop) + + //-------------------------------------------------------------------------------------- + // Hard Defines for the various structures + //-------------------------------------------------------------------------------------- + const uint32_t SDKMESH_FILE_VERSION = 101; + const uint32_t MAX_VERTEX_ELEMENTS = 32; + const uint32_t MAX_VERTEX_STREAMS = 16; + const uint32_t MAX_FRAME_NAME = 100; + const uint32_t MAX_MESH_NAME = 100; + const uint32_t MAX_SUBSET_NAME = 100; + const uint32_t MAX_MATERIAL_NAME = 100; + const uint32_t MAX_TEXTURE_NAME = MAX_PATH; + const uint32_t MAX_MATERIAL_PATH = MAX_PATH; + const uint32_t INVALID_FRAME = uint32_t(-1); + const uint32_t INVALID_MESH = uint32_t(-1); + const uint32_t INVALID_MATERIAL = uint32_t(-1); + const uint32_t INVALID_SUBSET = uint32_t(-1); + const uint32_t INVALID_ANIMATION_DATA = uint32_t(-1); + const uint32_t INVALID_SAMPLER_SLOT = uint32_t(-1); + const uint32_t ERROR_RESOURCE_VALUE = 1; + + template bool IsErrorResource( TYPE data ) + { + if( ( TYPE )ERROR_RESOURCE_VALUE == data ) + return true; + return false; + } + + //-------------------------------------------------------------------------------------- + // Enumerated Types. These will have mirrors in both D3D9 and D3D11 + //-------------------------------------------------------------------------------------- + enum SDKMESH_PRIMITIVE_TYPE + { + PT_TRIANGLE_LIST = 0, + PT_TRIANGLE_STRIP, + PT_LINE_LIST, + PT_LINE_STRIP, + PT_POINT_LIST, + PT_TRIANGLE_LIST_ADJ, + PT_TRIANGLE_STRIP_ADJ, + PT_LINE_LIST_ADJ, + PT_LINE_STRIP_ADJ, + PT_QUAD_PATCH_LIST, + PT_TRIANGLE_PATCH_LIST, + }; + + enum SDKMESH_INDEX_TYPE + { + IT_16BIT = 0, + IT_32BIT, + }; + + enum FRAME_TRANSFORM_TYPE + { + FTT_RELATIVE = 0, + FTT_ABSOLUTE, //This is not currently used but is here to support absolute transformations in the future + }; + + //-------------------------------------------------------------------------------------- + // Structures. + //-------------------------------------------------------------------------------------- + #pragma pack(push,8) + + struct SDKMESH_HEADER + { + //Basic Info and sizes + UINT Version; + BYTE IsBigEndian; + UINT64 HeaderSize; + UINT64 NonBufferDataSize; + UINT64 BufferDataSize; + + //Stats + UINT NumVertexBuffers; + UINT NumIndexBuffers; + UINT NumMeshes; + UINT NumTotalSubsets; + UINT NumFrames; + UINT NumMaterials; + + //Offsets to Data + UINT64 VertexStreamHeadersOffset; + UINT64 IndexStreamHeadersOffset; + UINT64 MeshDataOffset; + UINT64 SubsetDataOffset; + UINT64 FrameDataOffset; + UINT64 MaterialDataOffset; + }; + + struct SDKMESH_VERTEX_BUFFER_HEADER + { + UINT64 NumVertices; + UINT64 SizeBytes; + UINT64 StrideBytes; + D3DVERTEXELEMENT9 Decl[MAX_VERTEX_ELEMENTS]; + union + { + UINT64 DataOffset; + ID3D11Buffer* pVB11; + }; + }; + + struct SDKMESH_INDEX_BUFFER_HEADER + { + UINT64 NumIndices; + UINT64 SizeBytes; + UINT IndexType; + union + { + UINT64 DataOffset; + ID3D11Buffer* pIB11; + }; + }; + + struct SDKMESH_MESH + { + char Name[MAX_MESH_NAME]; + BYTE NumVertexBuffers; + UINT VertexBuffers[MAX_VERTEX_STREAMS]; + UINT IndexBuffer; + UINT NumSubsets; + UINT NumFrameInfluences; //aka bones + + DirectX::XMFLOAT3 BoundingBoxCenter; + DirectX::XMFLOAT3 BoundingBoxExtents; + + union + { + UINT64 SubsetOffset; + INT* pSubsets; + }; + union + { + UINT64 FrameInfluenceOffset; + UINT* pFrameInfluences; + }; + }; + + struct SDKMESH_SUBSET + { + char Name[MAX_SUBSET_NAME]; + UINT MaterialID; + UINT PrimitiveType; + UINT64 IndexStart; + UINT64 IndexCount; + UINT64 VertexStart; + UINT64 VertexCount; + }; + + struct SDKMESH_FRAME + { + char Name[MAX_FRAME_NAME]; + UINT Mesh; + UINT ParentFrame; + UINT ChildFrame; + UINT SiblingFrame; + DirectX::XMFLOAT4X4 Matrix; + UINT AnimationDataIndex; //Used to index which set of keyframes transforms this frame + }; + + struct SDKMESH_MATERIAL + { + char Name[MAX_MATERIAL_NAME]; + + // Use MaterialInstancePath + char MaterialInstancePath[MAX_MATERIAL_PATH]; + + // Or fall back to d3d8-type materials + char DiffuseTexture[MAX_TEXTURE_NAME]; + char NormalTexture[MAX_TEXTURE_NAME]; + char SpecularTexture[MAX_TEXTURE_NAME]; + + DirectX::XMFLOAT4 Diffuse; + DirectX::XMFLOAT4 Ambient; + DirectX::XMFLOAT4 Specular; + DirectX::XMFLOAT4 Emissive; + FLOAT Power; + + union + { + UINT64 Force64_1; //Force the union to 64bits + ID3D11Texture2D* pDiffuseTexture11; + }; + union + { + UINT64 Force64_2; //Force the union to 64bits + ID3D11Texture2D* pNormalTexture11; + }; + union + { + UINT64 Force64_3; //Force the union to 64bits + ID3D11Texture2D* pSpecularTexture11; + }; + + union + { + UINT64 Force64_4; //Force the union to 64bits + ID3D11ShaderResourceView* pDiffuseRV11; + }; + union + { + UINT64 Force64_5; //Force the union to 64bits + ID3D11ShaderResourceView* pNormalRV11; + }; + union + { + UINT64 Force64_6; //Force the union to 64bits + ID3D11ShaderResourceView* pSpecularRV11; + }; + }; + + struct SDKANIMATION_FILE_HEADER + { + UINT Version; + BYTE IsBigEndian; + UINT FrameTransformType; + UINT NumFrames; + UINT NumAnimationKeys; + UINT AnimationFPS; + UINT64 AnimationDataSize; + UINT64 AnimationDataOffset; + }; + + struct SDKANIMATION_DATA + { + DirectX::XMFLOAT3 Translation; + DirectX::XMFLOAT4 Orientation; + DirectX::XMFLOAT3 Scaling; + }; + + struct SDKANIMATION_FRAME_DATA + { + char FrameName[MAX_FRAME_NAME]; + union + { + UINT64 DataOffset; + SDKANIMATION_DATA* pAnimationData; + }; + }; + + #pragma pack(pop) + +}; // namespace + +static_assert( sizeof(DXUT::D3DVERTEXELEMENT9) == 8, "Direct3D9 Decl structure size incorrect" ); +static_assert( sizeof(DXUT::SDKMESH_HEADER)== 104, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(DXUT::SDKMESH_VERTEX_BUFFER_HEADER) == 288, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(DXUT::SDKMESH_INDEX_BUFFER_HEADER) == 32, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(DXUT::SDKMESH_MESH) == 224, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(DXUT::SDKMESH_SUBSET) == 144, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(DXUT::SDKMESH_FRAME) == 184, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(DXUT::SDKMESH_MATERIAL) == 1256, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(DXUT::SDKANIMATION_FILE_HEADER) == 40, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(DXUT::SDKANIMATION_DATA) == 40, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(DXUT::SDKANIMATION_FRAME_DATA) == 112, "SDK Mesh structure size incorrect" ); + + +//-------------------------------------------------------------------------------------- +struct MaterialRecordSDKMESH +{ + std::shared_ptr effect; + bool alpha; +}; + + +static void LoadMaterial( _In_ const DXUT::SDKMESH_MATERIAL& mh, + _In_ bool perVertexColor, _In_ bool enableSkinning, _In_ bool enableDualTexture, + _Inout_ IEffectFactory& fxFactory, _Inout_ MaterialRecordSDKMESH& m ) +{ + WCHAR matName[ DXUT::MAX_MATERIAL_NAME ]; + MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, mh.Name, -1, matName, DXUT::MAX_MATERIAL_NAME ); + + WCHAR txtName[ DXUT::MAX_TEXTURE_NAME ]; + MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, mh.DiffuseTexture, -1, txtName, DXUT::MAX_TEXTURE_NAME ); + + WCHAR txtName2[ DXUT::MAX_TEXTURE_NAME ]; + MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, mh.SpecularTexture, -1, txtName2, DXUT::MAX_TEXTURE_NAME ); + + EffectFactory::EffectInfo info; + info.name = matName; + info.perVertexColor = perVertexColor; + info.enableSkinning = enableSkinning; + info.enableDualTexture = enableDualTexture; + info.ambientColor = XMFLOAT3( mh.Ambient.x, mh.Ambient.y, mh.Ambient.z ); + info.diffuseColor = XMFLOAT3( mh.Diffuse.x, mh.Diffuse.y, mh.Diffuse.z ); + info.emissiveColor= XMFLOAT3( mh.Emissive.x, mh.Emissive.y, mh.Emissive.z ); + + if ( mh.Diffuse.w != 1.f && mh.Diffuse.w != 0.f ) + { + info.alpha = mh.Diffuse.w; + } + else + info.alpha = 1.f; + + if ( mh.Power ) + { + info.specularPower = mh.Power; + info.specularColor = XMFLOAT3( mh.Specular.x, mh.Specular.y, mh.Specular.z ); + } + + info.texture = txtName; + info.texture2 = txtName2; + + m.effect = fxFactory.CreateEffect( info, nullptr ); + m.alpha = (info.alpha < 1.f); +} + + +//-------------------------------------------------------------------------------------- +// Direct3D 9 Vertex Declaration to DirectInput 11 Input Layout mapping + +static void GetInputLayoutDesc( _In_reads_(32) const DXUT::D3DVERTEXELEMENT9 decl[], std::vector& inputDesc, + bool &perVertexColor, bool& enableSkinning, bool& dualTexture ) +{ + static const D3D11_INPUT_ELEMENT_DESC elements[] = + { + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_B8G8R8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BINORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BLENDINDICES",0, DXGI_FORMAT_R8G8B8A8_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BLENDWEIGHT", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + }; + + using namespace DXUT; + + uint32_t offset = 0; + uint32_t texcoords = 0; + + bool posfound = false; + + for( uint32_t index = 0; index < DXUT::MAX_VERTEX_ELEMENTS; ++index ) + { + if ( decl[index].Usage == 0xFF ) + break; + + if ( decl[index].Type == D3DDECLTYPE_UNUSED ) + break; + + if ( decl[index].Offset != offset ) + break; + + if ( decl[index].Usage == D3DDECLUSAGE_POSITION && decl[index].Type == D3DDECLTYPE_FLOAT3 ) + { + inputDesc.push_back( elements[0] ); + offset += 12; + posfound = true; + } + else if ( decl[index].Usage == D3DDECLUSAGE_NORMAL ) + { + if ( decl[index].Type == D3DDECLTYPE_FLOAT3 ) + { + inputDesc.push_back( elements[1] ); + offset += 12; + } + else if ( decl[index].Type == D3DDECLTYPE_FLOAT16_4 ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[1]; + desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; + inputDesc.push_back( desc ); + offset += 8; + } + else if ( decl[index].Type == D3DDECLTYPE_SHORT4N ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[1]; + desc.Format = DXGI_FORMAT_R16G16B16A16_SNORM; + inputDesc.push_back( desc ); + offset += 8; + } + else if ( decl[index].Type == D3DDECLTYPE_UBYTE4N ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[1]; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + inputDesc.push_back( desc ); + offset += 4; + } + else + break; + } + else if ( decl[index].Usage == D3DDECLUSAGE_COLOR && decl[index].Type == D3DDECLTYPE_D3DCOLOR ) + { + inputDesc.push_back( elements[2] ); + offset += 4; + perVertexColor = true; + } + else if ( decl[index].Usage == D3DDECLUSAGE_TANGENT ) + { + if ( decl[index].Type == D3DDECLTYPE_FLOAT3 ) + { + inputDesc.push_back( elements[3] ); + offset += 12; + } + else if ( decl[index].Type == D3DDECLTYPE_FLOAT16_4 ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[3]; + desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; + inputDesc.push_back( desc ); + offset += 8; + } + else if ( decl[index].Type == D3DDECLTYPE_SHORT4N ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[3]; + desc.Format = DXGI_FORMAT_R16G16B16A16_SNORM; + inputDesc.push_back( desc ); + offset += 8; + } + else if ( decl[index].Type == D3DDECLTYPE_UBYTE4N ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[3]; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + inputDesc.push_back( desc ); + offset += 4; + } + else + break; + } + else if ( decl[index].Usage == D3DDECLUSAGE_BINORMAL ) + { + if ( decl[index].Type == D3DDECLTYPE_FLOAT3 ) + { + inputDesc.push_back( elements[4] ); + offset += 12; + } + else if ( decl[index].Type == D3DDECLTYPE_FLOAT16_4 ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[4]; + desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; + inputDesc.push_back( desc ); + offset += 8; + } + else if ( decl[index].Type == D3DDECLTYPE_SHORT4N ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[4]; + desc.Format = DXGI_FORMAT_R16G16B16A16_SNORM; + inputDesc.push_back( desc ); + offset += 8; + } + else if ( decl[index].Type == D3DDECLTYPE_UBYTE4N ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[4]; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + inputDesc.push_back( desc ); + offset += 4; + } + else + break; + } + else if ( decl[index].Usage == D3DDECLUSAGE_TEXCOORD ) + { + D3D11_INPUT_ELEMENT_DESC desc = elements[5]; + desc.SemanticIndex = decl[index].UsageIndex; + + bool unk = false; + switch( decl[index].Type ) + { + case D3DDECLTYPE_FLOAT2: offset += 8; break; + case D3DDECLTYPE_FLOAT1: desc.Format = DXGI_FORMAT_R32_FLOAT; offset += 4; 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; + } + + if ( unk ) + break; + + ++texcoords; + + inputDesc.push_back( desc ); + } + else if ( decl[index].Usage == D3DDECLUSAGE_BLENDINDICES && decl[index].Type == D3DDECLTYPE_UBYTE4 ) + { + enableSkinning = true; + inputDesc.push_back( elements[6] ); + offset += 4; + } + else if ( decl[index].Usage == D3DDECLUSAGE_BLENDWEIGHT && decl[index].Type == D3DDECLTYPE_UBYTE4N ) + { + enableSkinning = true; + inputDesc.push_back( elements[7] ); + offset += 4; + } + else + break; + } + + if ( !posfound ) + throw std::exception("SV_Position is required"); + + if ( texcoords == 2 ) + { + dualTexture = true; + } +} + +// Helper for creating a D3D input layout. +static void CreateInputLayout(_In_ ID3D11Device* device, _In_ IEffect* effect, std::vector& inputDesc, _Out_ ID3D11InputLayout** pInputLayout) +{ + void const* shaderByteCode; + size_t byteCodeLength; + + effect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength); + + ThrowIfFailed( + device->CreateInputLayout(inputDesc.data(), + static_cast( inputDesc.size() ), + shaderByteCode, byteCodeLength, + pInputLayout) + ); + + SetDebugObjectName(*pInputLayout, "ModelSDKMESH"); +} + + +//====================================================================================== +// Model Loader +//====================================================================================== + +_Use_decl_annotations_ +std::unique_ptr DirectX::Model::CreateFromSDKMESH( ID3D11Device* d3dDevice, const uint8_t* meshData, size_t dataSize, IEffectFactory& fxFactory, bool ccw, bool pmalpha ) +{ + if ( !d3dDevice || !meshData ) + throw std::exception("Device and meshData cannot be null"); + + // File Headers + if ( dataSize < sizeof(DXUT::SDKMESH_HEADER) ) + throw std::exception("End of file"); + auto header = reinterpret_cast( 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 ) + throw std::exception("Not a valid SDKMESH file"); + + if ( dataSize < header->HeaderSize ) + throw std::exception("End of file"); + + if( header->Version != DXUT::SDKMESH_FILE_VERSION ) + throw std::exception("Not a supported SDKMESH version"); + + if ( header->IsBigEndian ) + throw std::exception("Loading BigEndian SDKMESH files not supported"); + + if ( !header->NumMeshes ) + throw std::exception("No meshes found"); + + if ( !header->NumVertexBuffers ) + throw std::exception("No vertex buffers found"); + + if ( !header->NumIndexBuffers ) + throw std::exception("No index buffers found"); + + if ( !header->NumTotalSubsets ) + throw std::exception("No subsets found"); + + 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) ) ) ) + throw std::exception("End of file"); + auto vbArray = reinterpret_cast( 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( meshData + header->IndexStreamHeadersOffset ); + + if ( dataSize < header->MeshDataOffset + || ( dataSize < (header->MeshDataOffset + header->NumMeshes * sizeof(DXUT::SDKMESH_MESH) ) ) ) + throw std::exception("End of file"); + auto meshArray = reinterpret_cast( meshData + header->MeshDataOffset ); + + if ( dataSize < header->SubsetDataOffset + || ( dataSize < (header->SubsetDataOffset + header->NumTotalSubsets * sizeof(DXUT::SDKMESH_SUBSET) ) ) ) + throw std::exception("End of file"); + auto subsetArray = reinterpret_cast( meshData + header->SubsetDataOffset ); + + if ( dataSize < header->FrameDataOffset + || (dataSize < (header->FrameDataOffset + header->NumFrames * sizeof(DXUT::SDKMESH_FRAME) ) ) ) + throw std::exception("End of file"); + // TODO - auto frameArray = reinterpret_cast( meshData + header->FrameDataOffset ); + + if ( dataSize < header->MaterialDataOffset + || (dataSize < (header->MaterialDataOffset + header->NumMaterials * sizeof(DXUT::SDKMESH_MATERIAL) ) ) ) + throw std::exception("End of file"); + auto materialArray = reinterpret_cast( meshData + header->MaterialDataOffset ); + + // Buffer data + uint64_t bufferDataOffset = header->HeaderSize + header->NonBufferDataSize; + if ( ( dataSize < bufferDataOffset ) + || ( dataSize < bufferDataOffset + header->BufferDataSize ) ) + throw std::exception("End of file"); + const uint8_t* bufferData = meshData + bufferDataOffset; + + // Create vertex buffers + std::vector> vbs; + vbs.resize( header->NumVertexBuffers ); + + std::vector>> vbDecls; + vbDecls.resize( header->NumVertexBuffers ); + + std::vector perVertexColor; + perVertexColor.resize( header->NumVertexBuffers ); + + std::vector enableSkinning; + enableSkinning.resize( header->NumVertexBuffers ); + + std::vector enableDualTexture; + enableDualTexture.resize( header->NumVertexBuffers ); + + for( UINT j=0; j < header->NumVertexBuffers; ++j ) + { + auto& vh = vbArray[j]; + + if ( dataSize < vh.DataOffset + || ( dataSize < vh.DataOffset + vh.SizeBytes ) ) + throw std::exception("End of file"); + + vbDecls[j] = std::make_shared>(); + bool vertColor = false; + bool skinning = false; + bool dualTexture = false; + GetInputLayoutDesc( vh.Decl, *vbDecls[j].get(), vertColor, skinning, dualTexture ); + perVertexColor[j] = vertColor; + enableSkinning[j] = skinning; + enableDualTexture[j] = dualTexture; + + auto verts = reinterpret_cast( bufferData + (vh.DataOffset - bufferDataOffset) ); + + D3D11_BUFFER_DESC desc = {0}; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = static_cast( vh.SizeBytes ); + desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + + D3D11_SUBRESOURCE_DATA initData = {0}; + initData.pSysMem = verts; + + ThrowIfFailed( + d3dDevice->CreateBuffer( &desc, &initData, &vbs[j] ) + ); + + SetDebugObjectName( vbs[j].Get(), "ModelSDKMESH" ); + } + + // Create index buffers + std::vector> ibs; + 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 ) ) + throw std::exception("End of file"); + + if ( ih.IndexType != DXUT::IT_16BIT && ih.IndexType != DXUT::IT_32BIT ) + throw std::exception("Invalid index buffer type found"); + + auto indices = reinterpret_cast( bufferData + (ih.DataOffset - bufferDataOffset) ); + + D3D11_BUFFER_DESC desc = {0}; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = static_cast( ih.SizeBytes ); + desc.BindFlags = D3D11_BIND_INDEX_BUFFER; + + D3D11_SUBRESOURCE_DATA initData = {0}; + initData.pSysMem = indices; + + ThrowIfFailed( + d3dDevice->CreateBuffer( &desc, &initData, &ibs[j] ) + ); + + SetDebugObjectName( ibs[j].Get(), "ModelSDKMESH" ); + } + + // Create meshes + std::vector materials; + materials.resize( header->NumMaterials ); + + std::unique_ptr model(new Model()); + model->meshes.reserve( header->NumMeshes ); + + for( UINT meshIndex = 0; meshIndex < header->NumMeshes; ++meshIndex ) + { + auto& mh = meshArray[ meshIndex ]; + + 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) ) ) + throw std::exception("End of file"); + + auto subsets = reinterpret_cast( meshData + mh.SubsetOffset ); + + if ( mh.NumFrameInfluences > 0 ) + { + if ( dataSize < mh.FrameInfluenceOffset + || (dataSize < mh.FrameInfluenceOffset + mh.NumFrameInfluences*sizeof(UINT) ) ) + throw std::exception("End of file"); + + // TODO - auto influences = reinterpret_cast( meshData + mh.FrameInfluenceOffset ); + } + + auto mesh = std::make_shared(); + WCHAR 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; + + // Extents + mesh->boundingBox.Center = mh.BoundingBoxCenter; + mesh->boundingBox.Extents = mh.BoundingBoxExtents; + BoundingSphere::CreateFromBoundingBox( mesh->boundingSphere, mesh->boundingBox ); + + // Create subsets + mesh->meshParts.reserve( mh.NumSubsets ); + for( UINT j = 0; j < mh.NumSubsets; ++j ) + { + auto sIndex = subsets[ j ]; + if ( sIndex >= header->NumTotalSubsets ) + throw std::exception("Invalid mesh found"); + + auto& subset = subsetArray[ sIndex ]; + + D3D11_PRIMITIVE_TOPOLOGY primType; + 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_QUAD_PATCH_LIST: + case DXUT::PT_TRIANGLE_PATCH_LIST: + throw std::exception("Direct3D9 era tessellation not supported"); + + default: + throw std::exception("Unknown primitive type"); + } + + if ( subset.MaterialID >= header->NumMaterials ) + throw std::exception("Invalid mesh found"); + + auto& mat = materials[ subset.MaterialID ]; + + if ( !mat.effect ) + { + size_t vi = mh.VertexBuffers[0]; + LoadMaterial( materialArray[ subset.MaterialID ], + perVertexColor[vi], enableSkinning[vi], enableDualTexture[vi], + fxFactory, mat ); + } + + ComPtr il; + CreateInputLayout( d3dDevice, mat.effect.get(), *vbDecls[ mh.VertexBuffers[0] ].get(), &il ); + + auto part = new ModelMeshPart(); + part->isAlpha = mat.alpha; + + part->indexCount = static_cast( subset.IndexCount ); + part->startIndex = static_cast( subset.IndexStart ); + part->vertexOffset = static_cast( subset.VertexStart ); + part->vertexStride = static_cast( 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->effect = mat.effect; + part->vbDecl = vbDecls[ mh.VertexBuffers[0] ]; + + mesh->meshParts.emplace_back( part ); + } + + model->meshes.emplace_back( mesh ); + } + + return model; +} + + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +std::unique_ptr DirectX::Model::CreateFromSDKMESH( ID3D11Device* d3dDevice, const wchar_t* szFileName, IEffectFactory& fxFactory, bool ccw, bool pmalpha ) +{ + size_t dataSize = 0; + std::unique_ptr data; + HRESULT hr = BinaryReader::ReadEntireFile( szFileName, data, &dataSize ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateFromSDKMESH failed (%08X) loading '%ls'\n", hr, szFileName ); + throw std::exception( "CreateFromSDKMESH" ); + } + + auto model = CreateFromSDKMESH( d3dDevice, data.get(), dataSize, fxFactory, ccw, pmalpha ); + + model->name = szFileName; + + return model; +} diff --git a/Kits/DirectXTK/Src/ModelLoadVBO.cpp b/Kits/DirectXTK/Src/ModelLoadVBO.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6c226b3533f324cab5cab2cb2d34f8655b56fabd --- /dev/null +++ b/Kits/DirectXTK/Src/ModelLoadVBO.cpp @@ -0,0 +1,208 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Model.h" + +#include "Effects.h" +#include "VertexTypes.h" + +#include "DirectXHelpers.h" +#include "PlatformHelpers.h" +#include "BinaryReader.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +//-------------------------------------------------------------------------------------- +// The VBO file format was introduced in the Windows 8.0 ResourceLoading sample. It's +// a simple binary file containing a 16-bit index buffer and a fixed-format vertex buffer. +// +// The meshconvert sample tool for DirectXMesh can produce this file type +// http://go.microsoft.com/fwlink/?LinkID=324981 +//-------------------------------------------------------------------------------------- + +namespace VBO +{ +#pragma pack(push,1) + + struct header_t + { + uint32_t numVertices; + uint32_t numIndices; + }; + +#pragma pack(pop) + +}; // namespace + +static_assert(sizeof(VBO::header_t) == 8, "VBO header size mismatch"); +static_assert(sizeof(VertexPositionNormalTexture) == 32, "VBO vertex size mismatch"); + + +//-------------------------------------------------------------------------------------- +// Shared VB input element description +static INIT_ONCE g_InitOnce = INIT_ONCE_STATIC_INIT; +static std::shared_ptr> g_vbdecl; + +static BOOL CALLBACK InitializeDecl(PINIT_ONCE initOnce, PVOID Parameter, PVOID *lpContext) +{ + UNREFERENCED_PARAMETER(initOnce); + UNREFERENCED_PARAMETER(Parameter); + UNREFERENCED_PARAMETER(lpContext); + + g_vbdecl = std::make_shared>(VertexPositionNormalTexture::InputElements, + VertexPositionNormalTexture::InputElements + VertexPositionNormalTexture::InputElementCount); + + return TRUE; +} + + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +std::unique_ptr DirectX::Model::CreateFromVBO(ID3D11Device* d3dDevice, const uint8_t* meshData, size_t dataSize, + std::shared_ptr ieffect, bool ccw, bool pmalpha) +{ + if (!InitOnceExecuteOnce(&g_InitOnce, InitializeDecl, nullptr, nullptr)) + throw std::exception("One-time initialization failed"); + + if ( !d3dDevice || !meshData ) + throw std::exception("Device and meshData cannot be null"); + + // File Header + if ( dataSize < sizeof(VBO::header_t) ) + throw std::exception("End of file"); + auto header = reinterpret_cast( meshData ); + + 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( 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( meshData + sizeof(VBO::header_t) + vertSize ); + + // Create vertex buffer + ComPtr vb; + { + D3D11_BUFFER_DESC desc = { 0 }; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = static_cast(vertSize); + desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + + D3D11_SUBRESOURCE_DATA initData = { 0 }; + initData.pSysMem = verts; + + ThrowIfFailed( + d3dDevice->CreateBuffer(&desc, &initData, vb.GetAddressOf()) + ); + + SetDebugObjectName(vb.Get(), "ModelVBO"); + } + + // Create index buffer + ComPtr ib; + { + D3D11_BUFFER_DESC desc = { 0 }; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = static_cast(indexSize); + desc.BindFlags = D3D11_BIND_INDEX_BUFFER; + + D3D11_SUBRESOURCE_DATA initData = { 0 }; + initData.pSysMem = indices; + + ThrowIfFailed( + d3dDevice->CreateBuffer(&desc, &initData, ib.GetAddressOf()) + ); + + SetDebugObjectName(ib.Get(), "ModelVBO"); + } + + // Create input layout and effect + if (!ieffect) + { + auto effect = std::make_shared(d3dDevice); + effect->EnableDefaultLighting(); + effect->SetLightingEnabled(true); + + ieffect = effect; + } + + ComPtr il; + { + void const* shaderByteCode; + size_t byteCodeLength; + + ieffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength); + + ThrowIfFailed( + d3dDevice->CreateInputLayout(VertexPositionNormalTexture::InputElements, + VertexPositionNormalTexture::InputElementCount, + shaderByteCode, byteCodeLength, + il.GetAddressOf())); + + SetDebugObjectName(il.Get(), "ModelVBO"); + } + + auto part = new ModelMeshPart(); + part->indexCount = header->numIndices; + part->startIndex = 0; + part->vertexStride = static_cast( sizeof(VertexPositionNormalTexture) ); + part->inputLayout = il; + part->indexBuffer = ib; + part->vertexBuffer = vb; + part->effect = ieffect; + part->vbDecl = g_vbdecl; + + auto mesh = std::make_shared(); + mesh->ccw = ccw; + mesh->pmalpha = pmalpha; + BoundingSphere::CreateFromPoints(mesh->boundingSphere, header->numVertices, &verts->position, sizeof(VertexPositionNormalTexture)); + BoundingBox::CreateFromPoints(mesh->boundingBox, header->numVertices, &verts->position, sizeof(VertexPositionNormalTexture)); + mesh->meshParts.emplace_back(part); + + std::unique_ptr model(new Model()); + model->meshes.emplace_back(mesh); + + return model; +} + + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +std::unique_ptr DirectX::Model::CreateFromVBO(ID3D11Device* d3dDevice, const wchar_t* szFileName, + std::shared_ptr ieffect, bool ccw, bool pmalpha) +{ + size_t dataSize = 0; + std::unique_ptr data; + HRESULT hr = BinaryReader::ReadEntireFile( szFileName, data, &dataSize ); + if ( FAILED(hr) ) + { + DebugTrace( "CreateFromVBO failed (%08X) loading '%ls'\n", hr, szFileName ); + throw std::exception( "CreateFromVBO" ); + } + + auto model = CreateFromVBO( d3dDevice, data.get(), dataSize, ieffect, ccw, pmalpha ); + + model->name = szFileName; + + return model; +} diff --git a/Kits/DirectXTK/Src/Mouse.cpp b/Kits/DirectXTK/Src/Mouse.cpp new file mode 100644 index 0000000000000000000000000000000000000000..82ceda1205d2b94f0bad3aeeefd9079ee0f19512 --- /dev/null +++ b/Kits/DirectXTK/Src/Mouse.cpp @@ -0,0 +1,961 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "Mouse.h" + +#include "PlatformHelpers.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) + +//====================================================================================== +// Windows Store or universal Windows app implementation +//====================================================================================== + +// +// For a Windows Store app or universal Windows app, add the following to your existing +// application methods: +// +// void App::SetWindow(CoreWindow^ window ) +// { +// m_mouse->SetWindow(window); +// } +// +// void App::OnDpiChanged(DisplayInformation^ sender, Object^ args) +// { +// m_mouse->SetDpi(sender->LogicalDpi); +// } +// + +#include + +class Mouse::Impl +{ +public: + Impl(Mouse* owner) : + mOwner(owner), + mDPI(96.f), + mMode(MODE_ABSOLUTE) + { + mPointerPressedToken.value = 0; + mPointerReleasedToken.value = 0; + mPointerMovedToken.value = 0; + mPointerWheelToken.value = 0; + mPointerMouseMovedToken.value = 0; + + if ( s_mouse ) + { + throw std::exception( "Mouse is a singleton" ); + } + + s_mouse = this; + + memset( &mState, 0, sizeof(State) ); + + mScrollWheelValue.reset( CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_MODIFY_STATE | SYNCHRONIZE) ); + mRelativeRead.reset( CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_MODIFY_STATE | SYNCHRONIZE) ); + if ( !mScrollWheelValue + || !mRelativeRead ) + { + throw std::exception( "CreateEventEx" ); + } + } + + ~Impl() + { + s_mouse = nullptr; + + RemoveHandlers(); + } + + void GetState(State& state) const + { + memcpy( &state, &mState, sizeof(State) ); + + DWORD result = WaitForSingleObjectEx( mScrollWheelValue.get(), 0, FALSE ); + if ( result == WAIT_FAILED ) + throw std::exception( "WaitForSingleObjectEx" ); + + if ( result == WAIT_OBJECT_0 ) + { + state.scrollWheelValue = 0; + } + + if (mMode == MODE_RELATIVE) + { + result = WaitForSingleObjectEx( mRelativeRead.get(), 0, FALSE ); + + if (result == WAIT_FAILED) + throw std::exception("WaitForSingleObjectEx"); + + if (result == WAIT_OBJECT_0) + { + state.x = 0; + state.y = 0; + } + else + { + SetEvent(mRelativeRead.get()); + } + } + + state.positionMode = mMode; + } + + void ResetScrollWheelValue() + { + SetEvent(mScrollWheelValue.get()); + } + + void SetMode(Mode mode) + { + using namespace Microsoft::WRL; + using namespace Microsoft::WRL::Wrappers; + using namespace ABI::Windows::UI::Core; + using namespace ABI::Windows::Foundation; + + if (mMode == mode) + return; + + ComPtr statics; + HRESULT hr = GetActivationFactory( HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get(), statics.GetAddressOf() ); + ThrowIfFailed( hr ); + + ComPtr window; + hr = statics->GetForCurrentThread( window.GetAddressOf() ); + ThrowIfFailed( hr ); + + if (mode == MODE_RELATIVE) + { + hr = window->get_PointerCursor( mCursor.ReleaseAndGetAddressOf() ); + ThrowIfFailed(hr); + + hr = window->put_PointerCursor(nullptr); + ThrowIfFailed(hr); + + SetEvent(mRelativeRead.get()); + + mMode = MODE_RELATIVE; + } + else + { + if (!mCursor) + { + ComPtr factory; + hr = GetActivationFactory( HStringReference(RuntimeClass_Windows_UI_Core_CoreCursor).Get(), factory.GetAddressOf() ); + ThrowIfFailed( hr ); + + hr = factory->CreateCursor( CoreCursorType_Arrow, 0, mCursor.GetAddressOf() ); + ThrowIfFailed( hr ); + } + + hr = window->put_PointerCursor( mCursor.Get() ); + ThrowIfFailed(hr); + + mCursor.Reset(); + + mMode = MODE_ABSOLUTE; + } + } + + void SetWindow(ABI::Windows::UI::Core::ICoreWindow* window) + { + using namespace Microsoft::WRL; + using namespace Microsoft::WRL::Wrappers; + using namespace ABI::Windows::Foundation; + using namespace ABI::Windows::Devices::Input; + + if (mWindow.Get() == window) + return; + + RemoveHandlers(); + + mWindow = window; + + if (!window) + { + mCursor.Reset(); + mMouse.Reset(); + return; + } + + ComPtr mouseStatics; + HRESULT hr = GetActivationFactory( HStringReference(RuntimeClass_Windows_Devices_Input_MouseDevice).Get(), mouseStatics.GetAddressOf() ); + ThrowIfFailed( hr ); + + hr = mouseStatics->GetForCurrentView(mMouse.ReleaseAndGetAddressOf()); + ThrowIfFailed(hr); + + typedef __FITypedEventHandler_2_Windows__CDevices__CInput__CMouseDevice_Windows__CDevices__CInput__CMouseEventArgs MouseMovedHandler; + hr = mMouse->add_MouseMoved( Callback(MouseMovedEvent).Get(), &mPointerMouseMovedToken ); + ThrowIfFailed(hr); + + typedef __FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CPointerEventArgs PointerHandler; + auto cb = Callback(PointerEvent); + + hr = window->add_PointerPressed(cb.Get(), &mPointerPressedToken); + ThrowIfFailed(hr); + + hr = window->add_PointerReleased(cb.Get(), &mPointerReleasedToken); + ThrowIfFailed(hr); + + hr = window->add_PointerMoved(cb.Get(), &mPointerMovedToken); + ThrowIfFailed(hr); + + hr = window->add_PointerWheelChanged(Callback(PointerWheel).Get(), &mPointerWheelToken); + ThrowIfFailed(hr); + } + + State mState; + float mDPI; + Mouse* mOwner; + + static Mouse::Impl* s_mouse; + +private: + Mode mMode; + + ComPtr mWindow; + ComPtr mMouse; + ComPtr mCursor; + + ScopedHandle mScrollWheelValue; + ScopedHandle mRelativeRead; + + EventRegistrationToken mPointerPressedToken; + EventRegistrationToken mPointerReleasedToken; + EventRegistrationToken mPointerMovedToken; + EventRegistrationToken mPointerWheelToken; + EventRegistrationToken mPointerMouseMovedToken; + + void RemoveHandlers() + { + if (mWindow) + { + mWindow->remove_PointerPressed(mPointerPressedToken); + mPointerPressedToken.value = 0; + + mWindow->remove_PointerReleased(mPointerReleasedToken); + mPointerReleasedToken.value = 0; + + mWindow->remove_PointerMoved(mPointerMovedToken); + mPointerMovedToken.value = 0; + + mWindow->remove_PointerWheelChanged(mPointerWheelToken); + mPointerWheelToken.value = 0; + } + + if (mMouse) + { + mMouse->remove_MouseMoved(mPointerMouseMovedToken); + mPointerMouseMovedToken.value = 0; + } + } + + static HRESULT PointerEvent( IInspectable *, ABI::Windows::UI::Core::IPointerEventArgs*args ) + { + using namespace ABI::Windows::Foundation; + using namespace ABI::Windows::UI::Input; + using namespace ABI::Windows::Devices::Input; + + if (!s_mouse) + return S_OK; + + ComPtr currentPoint; + HRESULT hr = args->get_CurrentPoint( currentPoint.GetAddressOf() ); + ThrowIfFailed(hr); + + ComPtr pointerDevice; + hr = currentPoint->get_PointerDevice( pointerDevice.GetAddressOf() ); + ThrowIfFailed(hr); + + PointerDeviceType devType; + hr = pointerDevice->get_PointerDeviceType( &devType ); + ThrowIfFailed(hr); + + if (devType == PointerDeviceType::PointerDeviceType_Mouse) + { + ComPtr props; + hr = currentPoint->get_Properties( props.GetAddressOf() ); + ThrowIfFailed(hr); + + boolean value; + hr = props->get_IsLeftButtonPressed(&value); + ThrowIfFailed(hr); + s_mouse->mState.leftButton = value != 0; + + hr = props->get_IsRightButtonPressed(&value); + ThrowIfFailed(hr); + s_mouse->mState.rightButton = value != 0; + + hr = props->get_IsMiddleButtonPressed(&value); + ThrowIfFailed(hr); + s_mouse->mState.middleButton = value != 0; + + hr = props->get_IsXButton1Pressed(&value); + ThrowIfFailed(hr); + s_mouse->mState.xButton1 = value != 0; + + hr = props->get_IsXButton2Pressed(&value); + ThrowIfFailed(hr); + s_mouse->mState.xButton2 = value != 0; + } + + if (s_mouse->mMode == MODE_ABSOLUTE) + { + Point pos; + hr = currentPoint->get_Position( &pos ); + ThrowIfFailed(hr); + + float dpi = s_mouse->mDPI; + + s_mouse->mState.x = static_cast( pos.X * dpi / 96.f + 0.5f ); + s_mouse->mState.y = static_cast( pos.Y * dpi / 96.f + 0.5f ); + } + + return S_OK; + } + + static HRESULT PointerWheel( IInspectable *, ABI::Windows::UI::Core::IPointerEventArgs*args ) + { + using namespace ABI::Windows::Foundation; + using namespace ABI::Windows::UI::Input; + using namespace ABI::Windows::Devices::Input; + + if (!s_mouse) + return S_OK; + + ComPtr currentPoint; + HRESULT hr = args->get_CurrentPoint( currentPoint.GetAddressOf() ); + ThrowIfFailed(hr); + + ComPtr pointerDevice; + hr = currentPoint->get_PointerDevice( pointerDevice.GetAddressOf() ); + ThrowIfFailed(hr); + + PointerDeviceType devType; + hr = pointerDevice->get_PointerDeviceType( &devType ); + ThrowIfFailed(hr); + + if (devType == PointerDeviceType::PointerDeviceType_Mouse) + { + ComPtr props; + hr = currentPoint->get_Properties( props.GetAddressOf() ); + ThrowIfFailed(hr); + + INT32 value; + hr = props->get_MouseWheelDelta(&value); + ThrowIfFailed(hr); + + HANDLE evt = s_mouse->mScrollWheelValue.get(); + if (WaitForSingleObjectEx(evt, 0, FALSE) == WAIT_OBJECT_0) + { + s_mouse->mState.scrollWheelValue = 0; + ResetEvent(evt); + } + + s_mouse->mState.scrollWheelValue += value; + + if (s_mouse->mMode == MODE_ABSOLUTE) + { + Point pos; + hr = currentPoint->get_Position( &pos ); + ThrowIfFailed(hr); + + float dpi = s_mouse->mDPI; + + s_mouse->mState.x = static_cast( pos.X * dpi / 96.f + 0.5f ); + s_mouse->mState.y = static_cast( pos.Y * dpi / 96.f + 0.5f ); + } + } + + return S_OK; + } + + static HRESULT MouseMovedEvent( IInspectable *, ABI::Windows::Devices::Input::IMouseEventArgs* args ) + { + using namespace ABI::Windows::Devices::Input; + + if (!s_mouse) + return S_OK; + + if (s_mouse->mMode == MODE_RELATIVE) + { + MouseDelta delta; + HRESULT hr = args->get_MouseDelta(&delta); + ThrowIfFailed(hr); + + s_mouse->mState.x = delta.X; + s_mouse->mState.y = delta.Y; + + ResetEvent( s_mouse->mRelativeRead.get() ); + } + + return S_OK; + } +}; + + +Mouse::Impl* Mouse::Impl::s_mouse = nullptr; + + +void Mouse::SetWindow(ABI::Windows::UI::Core::ICoreWindow* window) +{ + pImpl->SetWindow(window); +} + + +void Mouse::SetDpi(float dpi) +{ + auto pImpl = Impl::s_mouse; + + if (!pImpl) + return; + + pImpl->mDPI = dpi; +} + + +#elif defined(_XBOX_ONE) || ( defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) ) + +//====================================================================================== +// Null device for Windows Phone and Xbox One +//====================================================================================== + +class Mouse::Impl +{ +public: + Impl(Mouse* owner) : + mOwner(owner) + { + if ( s_mouse ) + { + throw std::exception( "Mouse is a singleton" ); + } + + s_mouse = this; + } + + ~Impl() + { + s_mouse = nullptr; + } + + void GetState(State& state) const + { + memset( &state, 0, sizeof(State) ); + } + + void ResetScrollWheelValue() + { + } + + void SetMode(Mode mode) + { + UNREFERENCED_PARAMETER(mode); + } + + Mouse* mOwner; + + static Mouse::Impl* s_mouse; +}; + +Mouse::Impl* Mouse::Impl::s_mouse = nullptr; + +#else + +//====================================================================================== +// Win32 desktop implementation +//====================================================================================== + +// +// For a Win32 desktop application, in your window setup be sure to call this method: +// +// m_mouse->SetWindow(hwnd); +// +// And call this static function from your Window Message Procedure +// +// LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +// { +// switch (message) +// { +// case WM_ACTIVATEAPP: +// case WM_INPUT: +// case WM_MOUSEMOVE: +// case WM_LBUTTONDOWN: +// case WM_LBUTTONUP: +// case WM_RBUTTONDOWN: +// case WM_RBUTTONUP: +// case WM_MBUTTONDOWN: +// case WM_MBUTTONUP: +// case WM_MOUSEWHEEL: +// case WM_XBUTTONDOWN: +// case WM_XBUTTONUP: +// case WM_MOUSEHOVER: +// Mouse::ProcessMessage(message, wParam, lParam); +// break; +// +// } +// } +// + +class Mouse::Impl +{ +public: + Impl(Mouse* owner) : + mOwner(owner), + mMode(MODE_ABSOLUTE), + mLastX(0), + mLastY(0), + mInFocus(true) + { + if ( s_mouse ) + { + throw std::exception( "Mouse is a singleton" ); + } + + s_mouse = this; + + memset( &mState, 0, sizeof(State) ); + + mScrollWheelValue.reset( CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_MODIFY_STATE | SYNCHRONIZE) ); + mRelativeRead.reset( CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_MODIFY_STATE | SYNCHRONIZE) ); + mAbsoluteMode.reset( CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE) ); + mRelativeMode.reset( CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE) ); + if ( !mScrollWheelValue + || !mRelativeRead + || !mAbsoluteMode + || !mRelativeMode ) + { + throw std::exception( "CreateEventEx" ); + } + } + + ~Impl() + { + s_mouse = nullptr; + } + + void GetState(State& state) const + { + memcpy( &state, &mState, sizeof(State) ); + state.positionMode = mMode; + + DWORD result = WaitForSingleObjectEx( mScrollWheelValue.get(), 0, FALSE ); + if ( result == WAIT_FAILED ) + throw std::exception( "WaitForSingleObjectEx" ); + + if ( result == WAIT_OBJECT_0 ) + { + state.scrollWheelValue = 0; + } + + if (state.positionMode == MODE_RELATIVE) + { + result = WaitForSingleObjectEx( mRelativeRead.get(), 0, FALSE ); + + if (result == WAIT_FAILED) + throw std::exception("WaitForSingleObjectEx"); + + if (result == WAIT_OBJECT_0) + { + state.x = 0; + state.y = 0; + } + else + { + SetEvent(mRelativeRead.get()); + } + } + } + + void ResetScrollWheelValue() + { + SetEvent(mScrollWheelValue.get()); + } + + void SetMode(Mode mode) + { + if (mMode == mode) + return; + + SetEvent((mode == MODE_ABSOLUTE) ? mAbsoluteMode.get() : mRelativeMode.get()); + + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(tme); + tme.dwFlags = TME_HOVER; + tme.hwndTrack = mWindow; + tme.dwHoverTime = 1; + if (!TrackMouseEvent(&tme)) + { + throw std::exception("TrackMouseEvent"); + } + } + + void SetWindow(HWND window) + { + if (mWindow == window) + return; + + RAWINPUTDEVICE Rid; + Rid.usUsagePage = 0x1 /* HID_USAGE_PAGE_GENERIC */; + Rid.usUsage = 0x2 /* HID_USAGE_GENERIC_MOUSE */; + Rid.dwFlags = RIDEV_INPUTSINK; + Rid.hwndTarget = window; + if ( !RegisterRawInputDevices(&Rid, 1, sizeof(RAWINPUTDEVICE)) ) + { + throw std::exception("RegisterRawInputDevices"); + } + + mWindow = window; + } + + State mState; + + Mouse* mOwner; + + static Mouse::Impl* s_mouse; + +private: + HWND mWindow; + Mode mMode; + + ScopedHandle mScrollWheelValue; + ScopedHandle mRelativeRead; + ScopedHandle mAbsoluteMode; + ScopedHandle mRelativeMode; + + int mLastX; + int mLastY; + + bool mInFocus; + + friend void Mouse::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam); + + void ClipToWindow() + { + RECT rect; + GetClientRect(mWindow, &rect); + + POINT ul; + ul.x = rect.left; + ul.y = rect.top; + + POINT lr; + lr.x = rect.right; + lr.y = rect.bottom; + + MapWindowPoints(mWindow, nullptr, &ul, 1); + MapWindowPoints(mWindow, nullptr, &lr, 1); + + rect.left = ul.x; + rect.top = ul.y; + + rect.right = lr.x; + rect.bottom = lr.y; + + ClipCursor(&rect); + } +}; + + +Mouse::Impl* Mouse::Impl::s_mouse = nullptr; + + +void Mouse::SetWindow( HWND window ) +{ + pImpl->SetWindow(window); +} + + +void Mouse::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) +{ + auto pImpl = Impl::s_mouse; + + if (!pImpl) + return; + + HANDLE evts[3]; + evts[0] = pImpl->mScrollWheelValue.get(); + evts[1] = pImpl->mAbsoluteMode.get(); + evts[2] = pImpl->mRelativeMode.get(); + switch (WaitForMultipleObjectsEx(_countof(evts), evts, FALSE, 0, FALSE)) + { + 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; + if (MapWindowPoints(pImpl->mWindow, nullptr, &point, 1)) + { + SetCursorPos(point.x, point.y); + } + ShowCursor(TRUE); + pImpl->mState.x = pImpl->mLastX; + pImpl->mState.y = pImpl->mLastY; + } + break; + + case (WAIT_OBJECT_0 + 2) : + { + ResetEvent( pImpl->mRelativeRead.get() ); + + pImpl->mMode = MODE_RELATIVE; + pImpl->mState.x = pImpl->mState.y = 0; + + ShowCursor(FALSE); + + pImpl->ClipToWindow(); + } + break; + + case WAIT_FAILED: + throw std::exception("WaitForMultipleObjectsEx"); + } + + switch (message) + { + case WM_ACTIVATEAPP: + if (wParam) + { + pImpl->mInFocus = true; + + if (pImpl->mMode == MODE_RELATIVE) + { + pImpl->mState.x = pImpl->mState.y = 0; + + 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(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) ) + { + pImpl->mState.x = raw.data.mouse.lLastX; + pImpl->mState.y = raw.data.mouse.lLastY; + + ResetEvent( pImpl->mRelativeRead.get() ); + } + + // Note that with Remote Desktop input comes through as MOUSE_MOVE_ABSOLUTE | MOUSE_VIRTUAL_DESKTOP, + // so this imlementation doesn't suport relative mode via remote desktop. + } + } + return; + + case WM_MOUSEMOVE: + break; + + case WM_LBUTTONDOWN: + pImpl->mState.leftButton = true; + break; + + case WM_LBUTTONUP: + pImpl->mState.leftButton = false; + break; + + case WM_RBUTTONDOWN: + pImpl->mState.rightButton = true; + break; + + 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) + { + // All mouse messages provide a new pointer position + int xPos = static_cast(LOWORD(lParam)); // GET_X_LPARAM(lParam); + int yPos = static_cast(HIWORD(lParam)); // GET_Y_LPARAM(lParam); + + pImpl->mState.x = pImpl->mLastX = xPos; + pImpl->mState.y = pImpl->mLastY = yPos; + } +} + +#endif + +#pragma warning( disable : 4355 ) + +// Public constructor. +Mouse::Mouse() + : pImpl( new Impl(this) ) +{ +} + + +// Move constructor. +Mouse::Mouse(Mouse&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ + pImpl->mOwner = this; +} + + +// Move assignment. +Mouse& Mouse::operator= (Mouse&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + pImpl->mOwner = this; + return *this; +} + + +// Public destructor. +Mouse::~Mouse() +{ +} + + +Mouse::State Mouse::GetState() const +{ + State state; + pImpl->GetState(state); + return state; +} + + +void Mouse::ResetScrollWheelValue() +{ + pImpl->ResetScrollWheelValue(); +} + + +void Mouse::SetMode(Mode mode) +{ + pImpl->SetMode(mode); +} + + +Mouse& Mouse::Get() +{ + if ( !Impl::s_mouse || !Impl::s_mouse->mOwner ) + throw std::exception( "Mouse is a singleton" ); + + return *Impl::s_mouse->mOwner; +} + + + +//====================================================================================== +// ButtonStateTracker +//====================================================================================== + +#define UPDATE_BUTTON_STATE(field) field = static_cast( ( !!state.field ) | ( ( !!state.field ^ !!lastState.field ) << 1 ) ); + +void Mouse::ButtonStateTracker::Update( const Mouse::State& state ) +{ + UPDATE_BUTTON_STATE(leftButton); + + assert( ( !state.leftButton && !lastState.leftButton ) == ( leftButton == UP ) ); + assert( ( state.leftButton && lastState.leftButton ) == ( leftButton == HELD ) ); + assert( ( !state.leftButton && lastState.leftButton ) == ( leftButton == RELEASED ) ); + assert( ( state.leftButton && !lastState.leftButton ) == ( leftButton == PRESSED ) ); + + UPDATE_BUTTON_STATE(middleButton); + UPDATE_BUTTON_STATE(rightButton); + UPDATE_BUTTON_STATE(xButton1); + UPDATE_BUTTON_STATE(xButton2); + + lastState = state; +} + +#undef UPDATE_BUTTON_STATE + + +void Mouse::ButtonStateTracker::Reset() +{ + memset( this, 0, sizeof(ButtonStateTracker) ); +} diff --git a/Kits/DirectXTK/Src/PlatformHelpers.h b/Kits/DirectXTK/Src/PlatformHelpers.h new file mode 100644 index 0000000000000000000000000000000000000000..a268c84993446431bcfe58f4c8558ba622c84527 --- /dev/null +++ b/Kits/DirectXTK/Src/PlatformHelpers.h @@ -0,0 +1,135 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#pragma warning(disable : 4324 4481) + +#include +#include + + +namespace DirectX +{ + // Helper class for COM exceptions + class com_exception : public std::exception + { + public: + com_exception(HRESULT hr) : result(hr) {} + + virtual const char* what() const override + { + static char s_str[64] = { 0 }; + sprintf_s(s_str, "Failure with HRESULT of %08X", result); + return s_str; + } + + private: + HRESULT result; + }; + + // Helper utility converts D3D API failures into exceptions. + inline void ThrowIfFailed(HRESULT hr) + { + if (FAILED(hr)) + { + throw com_exception(hr); + } + } + + + // Helper for output debug tracing + inline void DebugTrace( _In_z_ _Printf_format_string_ const char* format, ... ) + { +#ifdef _DEBUG + va_list args; + va_start( args, format ); + + char buff[1024]={0}; + vsprintf_s( buff, format, args ); + OutputDebugStringA( buff ); + va_end( args ); +#else + UNREFERENCED_PARAMETER( format ); +#endif + } + + + // Helper smart-pointers +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) || (defined(_XBOX_ONE) && defined(_TITLE)) || !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) + struct virtual_deleter { void operator()(void* p) { if (p) VirtualFree(p, 0, MEM_RELEASE); } }; +#endif + + struct aligned_deleter { void operator()(void* p) { _aligned_free(p); } }; + + struct handle_closer { void operator()(HANDLE h) { if (h) CloseHandle(h); } }; + + typedef public std::unique_ptr ScopedHandle; + + inline HANDLE safe_handle( HANDLE h ) { return (h == INVALID_HANDLE_VALUE) ? 0 : h; } +} + + +#if (defined(_MSC_VER) && (_MSC_VER < 1610)) || defined(DIRECTX_EMULATE_MUTEX) + +// Emulate the C++0x mutex and lock_guard types when building with Visual Studio 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 + 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 // _MSC_VER < 1610 + +#include + +#endif diff --git a/Kits/DirectXTK/Src/PrimitiveBatch.cpp b/Kits/DirectXTK/Src/PrimitiveBatch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..295f203dd1cba0b90fb9dcda155f80902f3ff19a --- /dev/null +++ b/Kits/DirectXTK/Src/PrimitiveBatch.cpp @@ -0,0 +1,431 @@ +//-------------------------------------------------------------------------------------- +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "PrimitiveBatch.h" +#include "DirectXHelpers.h" +#include "GraphicsMemory.h" +#include "PlatformHelpers.h" + +using namespace DirectX; +using namespace DirectX::Internal; +using Microsoft::WRL::ComPtr; + + +// Internal PrimitiveBatch implementation class. +class PrimitiveBatchBase::Impl +{ +public: + Impl(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices, size_t maxVertices, size_t vertexSize); + + void Begin(); + void End(); + + void Draw(D3D11_PRIMITIVE_TOPOLOGY topology, bool isIndexed, _In_opt_count_(indexCount) uint16_t const* indices, size_t indexCount, size_t vertexCount, _Out_ void** pMappedVertices); + +private: + void FlushBatch(); + +#if defined(_XBOX_ONE) && defined(_TITLE) + ComPtr mDeviceContext; +#else + ComPtr mDeviceContext; +#endif + ComPtr mIndexBuffer; + ComPtr mVertexBuffer; + + size_t mMaxIndices; + size_t mMaxVertices; + size_t mVertexSize; + + bool mInBeginEndPair; + + D3D11_PRIMITIVE_TOPOLOGY mCurrentTopology; + bool mCurrentlyIndexed; + + size_t mCurrentIndex; + size_t mCurrentVertex; + + size_t mBaseIndex; + size_t mBaseVertex; + +#if defined(_XBOX_ONE) && defined(_TITLE) + void *grfxMemoryIB; + void *grfxMemoryVB; +#else + D3D11_MAPPED_SUBRESOURCE mMappedIndices; + D3D11_MAPPED_SUBRESOURCE mMappedVertices; +#endif +}; + + +// Helper for creating a D3D vertex or index buffer. +#if defined(_XBOX_ONE) && defined(_TITLE) +static void CreateBuffer(_In_ ID3D11DeviceX* device, size_t bufferSize, D3D11_BIND_FLAG bindFlag, _Out_ ID3D11Buffer** pBuffer) +{ + D3D11_BUFFER_DESC desc = { 0 }; + + desc.ByteWidth = (UINT)bufferSize; + desc.BindFlags = bindFlag; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + ThrowIfFailed( + device->CreatePlacementBuffer(&desc, nullptr, pBuffer) + ); + + SetDebugObjectName(*pBuffer, "DirectXTK:PrimitiveBatch"); +} +#else +static void CreateBuffer(_In_ ID3D11Device* device, size_t bufferSize, D3D11_BIND_FLAG bindFlag, _Out_ ID3D11Buffer** pBuffer) +{ + D3D11_BUFFER_DESC desc = { 0 }; + + desc.ByteWidth = (UINT)bufferSize; + desc.BindFlags = bindFlag; + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + ThrowIfFailed( + device->CreateBuffer(&desc, nullptr, pBuffer) + ); + + SetDebugObjectName(*pBuffer, "DirectXTK:PrimitiveBatch"); +} +#endif + + +// Constructor. +PrimitiveBatchBase::Impl::Impl(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices, size_t maxVertices, size_t vertexSize) + : mMaxIndices(maxIndices), + mMaxVertices(maxVertices), + mVertexSize(vertexSize), + mInBeginEndPair(false), + mCurrentTopology(D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED), + mCurrentlyIndexed(false), + mCurrentIndex(0), + mCurrentVertex(0), + mBaseIndex(0), + mBaseVertex(0) +{ + ComPtr device; + deviceContext->GetDevice(&device); + +#if defined(_XBOX_ONE) && defined(_TITLE) + ThrowIfFailed(deviceContext->QueryInterface(IID_GRAPHICS_PPV_ARGS(mDeviceContext.GetAddressOf()))); + + ComPtr deviceX; + ThrowIfFailed(device.As(&deviceX)); + + // If you only intend to draw non-indexed geometry, specify maxIndices = 0 to skip creating the index buffer. + if (maxIndices > 0) + { + CreateBuffer(deviceX.Get(), maxIndices * sizeof(uint16_t), D3D11_BIND_INDEX_BUFFER, &mIndexBuffer); + } + + // Create the vertex buffer. + CreateBuffer(deviceX.Get(), maxVertices * vertexSize, D3D11_BIND_VERTEX_BUFFER, &mVertexBuffer); + + grfxMemoryIB = grfxMemoryVB = nullptr; +#else + mDeviceContext = deviceContext; + + // If you only intend to draw non-indexed geometry, specify maxIndices = 0 to skip creating the index buffer. + if (maxIndices > 0) + { + CreateBuffer(device.Get(), maxIndices * sizeof(uint16_t), D3D11_BIND_INDEX_BUFFER, &mIndexBuffer); + } + + // Create the vertex buffer. + CreateBuffer(device.Get(), maxVertices * vertexSize, D3D11_BIND_VERTEX_BUFFER, &mVertexBuffer); +#endif +} + + +// Begins a batch of primitive drawing operations. +void PrimitiveBatchBase::Impl::Begin() +{ + if (mInBeginEndPair) + throw std::exception("Cannot nest Begin calls"); + +#if !defined(_XBOX_ONE) || !defined(_TITLE) + // Bind the index buffer. + if (mMaxIndices > 0) + { + mDeviceContext->IASetIndexBuffer(mIndexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0); + } + + // Bind the vertex buffer. + auto vertexBuffer = mVertexBuffer.Get(); + UINT vertexStride = (UINT)mVertexSize; + UINT vertexOffset = 0; + + mDeviceContext->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset); +#endif + + // If this is a deferred D3D context, reset position so the first Map calls will use D3D11_MAP_WRITE_DISCARD. + if (mDeviceContext->GetType() == D3D11_DEVICE_CONTEXT_DEFERRED) + { + mCurrentIndex = 0; + mCurrentVertex = 0; + } + + mInBeginEndPair = true; +} + + +// Ends a batch of primitive drawing operations. +void PrimitiveBatchBase::Impl::End() +{ + if (!mInBeginEndPair) + throw std::exception("Begin must be called before End"); + + FlushBatch(); + + mInBeginEndPair = false; +} + + +// Can we combine adjacent primitives using this topology into a single draw call? +static bool CanBatchPrimitives(D3D11_PRIMITIVE_TOPOLOGY topology) +{ + switch (topology) + { + case D3D11_PRIMITIVE_TOPOLOGY_POINTLIST: + case D3D11_PRIMITIVE_TOPOLOGY_LINELIST: + case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST: + // Lists can easily be merged. + return true; + + default: + // Strips cannot. + return false; + } + + // We could also merge indexed strips by inserting degenerates, + // but that's not always a perf win, so let's keep things simple. +} + + +#if !defined(_XBOX_ONE) || !defined(_TITLE) +// Helper for locking a vertex or index buffer. +static void LockBuffer(_In_ ID3D11DeviceContext* deviceContext, _In_ ID3D11Buffer* buffer, size_t currentPosition, _Out_ size_t* basePosition, _Out_ D3D11_MAPPED_SUBRESOURCE* mappedResource) +{ + D3D11_MAP mapType = (currentPosition == 0) ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE; + + ThrowIfFailed( + deviceContext->Map(buffer, 0, mapType, 0, mappedResource) + ); + + *basePosition = currentPosition; +} +#endif + + +// Adds new geometry to the batch. +void PrimitiveBatchBase::Impl::Draw(D3D11_PRIMITIVE_TOPOLOGY topology, bool isIndexed, _In_opt_count_(indexCount) uint16_t const* indices, size_t indexCount, size_t vertexCount, _Out_ void** pMappedVertices) +{ + if (isIndexed && !indices) + throw std::exception("Indices cannot be null"); + + if (indexCount >= mMaxIndices) + throw std::exception("Too many indices"); + + if (vertexCount >= mMaxVertices) + throw std::exception("Too many vertices"); + + if (!mInBeginEndPair) + throw std::exception("Begin must be called before Draw"); + + // Can we merge this primitive in with an existing batch, or must we flush first? + bool wrapIndexBuffer = (mCurrentIndex + indexCount > mMaxIndices); + bool wrapVertexBuffer = (mCurrentVertex + vertexCount > mMaxVertices); + + if ((topology != mCurrentTopology) || + (isIndexed != mCurrentlyIndexed) || + !CanBatchPrimitives(topology) || + wrapIndexBuffer || wrapVertexBuffer) + { + FlushBatch(); + } + + if (wrapIndexBuffer) + mCurrentIndex = 0; + + if (wrapVertexBuffer) + mCurrentVertex = 0; + +#if defined(_XBOX_ONE) && defined(_TITLE) + if (mCurrentTopology == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED) + { + auto& grfxMem = GraphicsMemory::Get(); + + if (isIndexed) + { + grfxMemoryIB = grfxMem.Allocate(mDeviceContext.Get(), mMaxIndices * sizeof(uint16_t), 64); + } + + grfxMemoryVB = grfxMem.Allocate(mDeviceContext.Get(), mMaxVertices * mVertexSize, 64); + + mCurrentTopology = topology; + mCurrentlyIndexed = isIndexed; + } + + // Copy over the index data. + if (isIndexed) + { + assert(grfxMemoryIB != 0); + auto outputIndices = reinterpret_cast(grfxMemoryIB) + mCurrentIndex; + + for (size_t i = 0; i < indexCount; i++) + { + outputIndices[i] = (uint16_t)(indices[i] + mCurrentVertex - mBaseVertex); + } + + mCurrentIndex += indexCount; + } + + // Return the output vertex data location. + assert(grfxMemoryVB != 0); + *pMappedVertices = reinterpret_cast(grfxMemoryVB) + (mCurrentVertex * mVertexSize); + + mCurrentVertex += vertexCount; +#else + // If we are not already in a batch, lock the buffers. + if (mCurrentTopology == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED) + { + if (isIndexed) + { + LockBuffer(mDeviceContext.Get(), mIndexBuffer.Get(), mCurrentIndex, &mBaseIndex, &mMappedIndices); + } + + LockBuffer(mDeviceContext.Get(), mVertexBuffer.Get(), mCurrentVertex, &mBaseVertex, &mMappedVertices); + + mCurrentTopology = topology; + mCurrentlyIndexed = isIndexed; + } + + // Copy over the index data. + if (isIndexed) + { + auto outputIndices = reinterpret_cast(mMappedIndices.pData) + mCurrentIndex; + + for (size_t i = 0; i < indexCount; i++) + { + outputIndices[i] = (uint16_t)(indices[i] + mCurrentVertex - mBaseVertex); + } + + mCurrentIndex += indexCount; + } + + // Return the output vertex data location. + *pMappedVertices = reinterpret_cast(mMappedVertices.pData) + (mCurrentVertex * mVertexSize); + + mCurrentVertex += vertexCount; +#endif +} + + +// Sends queued primitives to the graphics device. +void PrimitiveBatchBase::Impl::FlushBatch() +{ + // Early out if there is nothing to flush. + if (mCurrentTopology == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED) + return; + + mDeviceContext->IASetPrimitiveTopology(mCurrentTopology); + +#if defined(_XBOX_ONE) && defined(_TITLE) + if (mCurrentlyIndexed) + { + // Draw indexed geometry. + mDeviceContext->IASetPlacementIndexBuffer(mIndexBuffer.Get(), grfxMemoryIB, DXGI_FORMAT_R16_UINT); + mDeviceContext->IASetPlacementVertexBuffer(0, mVertexBuffer.Get(), grfxMemoryVB, (UINT)mVertexSize); + + mDeviceContext->DrawIndexed((UINT)(mCurrentIndex - mBaseIndex), (UINT)mBaseIndex, (UINT)mBaseVertex); + } + else + { + // Draw non-indexed geometry. + mDeviceContext->IASetPlacementVertexBuffer(0, mVertexBuffer.Get(), grfxMemoryVB, (UINT)mVertexSize); + + mDeviceContext->Draw((UINT)(mCurrentVertex - mBaseVertex), (UINT)mBaseVertex); + } + + grfxMemoryIB = grfxMemoryVB = nullptr; +#else + mDeviceContext->Unmap(mVertexBuffer.Get(), 0); + + if (mCurrentlyIndexed) + { + // Draw indexed geometry. + mDeviceContext->Unmap(mIndexBuffer.Get(), 0); + + mDeviceContext->DrawIndexed((UINT)(mCurrentIndex - mBaseIndex), (UINT)mBaseIndex, (UINT)mBaseVertex); + } + else + { + // Draw non-indexed geometry. + mDeviceContext->Draw((UINT)(mCurrentVertex - mBaseVertex), (UINT)mBaseVertex); + } +#endif + + mCurrentTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; +} + + +// Public constructor. +PrimitiveBatchBase::PrimitiveBatchBase(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices, size_t maxVertices, size_t vertexSize) + : pImpl(new Impl(deviceContext, maxIndices, maxVertices, vertexSize)) +{ +} + + +// Move constructor. +PrimitiveBatchBase::PrimitiveBatchBase(PrimitiveBatchBase&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +PrimitiveBatchBase& PrimitiveBatchBase::operator= (PrimitiveBatchBase&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +PrimitiveBatchBase::~PrimitiveBatchBase() +{ +} + + +void PrimitiveBatchBase::Begin() +{ + pImpl->Begin(); +} + + +void PrimitiveBatchBase::End() +{ + pImpl->End(); +} + + +_Use_decl_annotations_ +void PrimitiveBatchBase::Draw(D3D11_PRIMITIVE_TOPOLOGY topology, bool isIndexed, uint16_t const* indices, size_t indexCount, size_t vertexCount, void** pMappedVertices) +{ + pImpl->Draw(topology, isIndexed, indices, indexCount, vertexCount, pMappedVertices); +} diff --git a/Kits/DirectXTK/Src/ScreenGrab.cpp b/Kits/DirectXTK/Src/ScreenGrab.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a150715c79c150795e08ef53eed86cd6c4890262 --- /dev/null +++ b/Kits/DirectXTK/Src/ScreenGrab.cpp @@ -0,0 +1,1086 @@ +//-------------------------------------------------------------------------------------- +// File: ScreenGrab.cpp +// +// Function for capturing a 2D texture and saving it to a file (aka a 'screenshot' +// when used on a Direct3D 11 Render Target). +// +// Note these functions are useful as a light-weight runtime screen grabber. For +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +// Does not capture 1D textures or 3D textures (volume maps) + +// Does not capture mipmap chains, only the top-most texture level is saved + +// For 2D array textures and cubemaps, it captures only the first image in the array + +#include "pch.h" + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) + +// VS 2010's stdint.h conflicts with intsafe.h +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) +#endif + +#include "ScreenGrab.h" + +#include "dds.h" +#include "PlatformHelpers.h" + +using Microsoft::WRL::ComPtr; +using namespace DirectX; + +namespace +{ + class auto_delete_file + { + public: + auto_delete_file(HANDLE hFile) : m_handle(hFile) {} + ~auto_delete_file() + { + if (m_handle) + { + FILE_DISPOSITION_INFO info = {0}; + info.DeleteFile = TRUE; + (void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); + } + } + + void clear() { m_handle = 0; } + + private: + HANDLE m_handle; + + auto_delete_file(const auto_delete_file&) DIRECTX_CTOR_DELETE; + auto_delete_file& operator=(const auto_delete_file&) DIRECTX_CTOR_DELETE; + }; + +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) + + class auto_delete_file_wic + { + public: + auto_delete_file_wic(ComPtr& hFile, LPCWSTR szFile) : m_handle(hFile), m_filename(szFile) {} + ~auto_delete_file_wic() + { + if (m_filename) + { + m_handle.Reset(); + DeleteFileW(m_filename); + } + } + + void clear() { m_filename = 0; } + + private: + LPCWSTR m_filename; + ComPtr& m_handle; + + auto_delete_file_wic(const auto_delete_file_wic&) DIRECTX_CTOR_DELETE; + auto_delete_file_wic& operator=(const auto_delete_file_wic&) DIRECTX_CTOR_DELETE; + }; + +#endif +} + +//-------------------------------------------------------------------------------------- +// Return the BPP for a particular format +//-------------------------------------------------------------------------------------- +static size_t BitsPerPixel( _In_ DXGI_FORMAT fmt ) +{ + 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_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_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_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_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_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; + +#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_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; + +#endif // _XBOX_ONE && _TITLE + + default: + return 0; + } +} + + +//-------------------------------------------------------------------------------------- +// Determines if the format is block compressed +//-------------------------------------------------------------------------------------- +static bool IsCompressed( _In_ DXGI_FORMAT fmt ) +{ + 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; + + default: + return false; + } +} + + +//-------------------------------------------------------------------------------------- +// Get surface information for a particular format +//-------------------------------------------------------------------------------------- +static 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 ) +{ + size_t numBytes = 0; + size_t rowBytes = 0; + size_t numRows = 0; + + bool bc = false; + bool packed = false; + bool planar = false; + 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_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_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_P010: + case DXGI_FORMAT_P016: + planar = true; + bpe = 4; + break; + +#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; + +#endif + } + + if (bc) + { + size_t numBlocksWide = 0; + if (width > 0) + { + numBlocksWide = std::max( 1, (width + 3) / 4 ); + } + size_t numBlocksHigh = 0; + if (height > 0) + { + numBlocksHigh = std::max( 1, (height + 3) / 4 ); + } + rowBytes = numBlocksWide * bpe; + numRows = numBlocksHigh; + numBytes = rowBytes * numBlocksHigh; + } + else if (packed) + { + rowBytes = ( ( width + 1 ) >> 1 ) * bpe; + numRows = height; + numBytes = rowBytes * height; + } + else if ( fmt == DXGI_FORMAT_NV11 ) + { + rowBytes = ( ( width + 3 ) >> 2 ) * 4; + numRows = height * 2; // Direct3D makes this simplifying assumption, although it is larger than the 4:1:1 data + numBytes = rowBytes * numRows; + } + else if (planar) + { + rowBytes = ( ( width + 1 ) >> 1 ) * bpe; + numBytes = ( rowBytes * height ) + ( ( rowBytes * height + 1 ) >> 1 ); + numRows = height + ( ( height + 1 ) >> 1 ); + } + else + { + size_t bpp = BitsPerPixel( fmt ); + rowBytes = ( width * bpp + 7 ) / 8; // round up to nearest byte + numRows = height; + numBytes = rowBytes * height; + } + + if (outNumBytes) + { + *outNumBytes = numBytes; + } + if (outRowBytes) + { + *outRowBytes = rowBytes; + } + if (outNumRows) + { + *outNumRows = numRows; + } +} + + +//-------------------------------------------------------------------------------------- +static DXGI_FORMAT EnsureNotTypeless( DXGI_FORMAT fmt ) +{ + // 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; + } +} + + +//-------------------------------------------------------------------------------------- +static HRESULT CaptureTexture( _In_ ID3D11DeviceContext* pContext, + _In_ ID3D11Resource* pSource, + _Inout_ D3D11_TEXTURE2D_DESC& desc, + _Inout_ ComPtr& pStaging ) +{ + if ( !pContext || !pSource ) + return E_INVALIDARG; + + D3D11_RESOURCE_DIMENSION resType = D3D11_RESOURCE_DIMENSION_UNKNOWN; + pSource->GetType( &resType ); + + if ( resType != D3D11_RESOURCE_DIMENSION_TEXTURE2D ) + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + + ComPtr pTexture; +#if defined(_XBOX_ONE) && defined(_TITLE) + HRESULT hr = pSource->QueryInterface(IID_GRAPHICS_PPV_ARGS(pTexture.GetAddressOf())); +#else + HRESULT hr = pSource->QueryInterface(IID_PPV_ARGS(pTexture.GetAddressOf())); +#endif + if ( FAILED(hr) ) + return hr; + + assert( pTexture ); + + pTexture->GetDesc( &desc ); + + ComPtr d3dDevice; + pContext->GetDevice( d3dDevice.GetAddressOf() ); + + if ( desc.SampleDesc.Count > 1 ) + { + // MSAA content must be resolved before being copied to a staging texture + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + + ComPtr pTemp; + hr = d3dDevice->CreateTexture2D( &desc, 0, pTemp.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + assert( pTemp ); + + DXGI_FORMAT fmt = EnsureNotTypeless( desc.Format ); + + UINT support = 0; + hr = d3dDevice->CheckFormatSupport( fmt, &support ); + if ( FAILED(hr) ) + return hr; + + if ( !(support & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE) ) + return E_FAIL; + + for( UINT item = 0; item < desc.ArraySize; ++item ) + { + for( UINT level = 0; level < desc.MipLevels; ++level ) + { + UINT index = D3D11CalcSubresource( level, item, desc.MipLevels ); + pContext->ResolveSubresource( pTemp.Get(), index, pSource, index, fmt ); + } + } + + desc.BindFlags = 0; + desc.MiscFlags &= D3D11_RESOURCE_MISC_TEXTURECUBE; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + desc.Usage = D3D11_USAGE_STAGING; + + hr = d3dDevice->CreateTexture2D( &desc, 0, pStaging.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + assert( pStaging ); + + pContext->CopyResource( pStaging.Get(), pTemp.Get() ); + } + else if ( (desc.Usage == D3D11_USAGE_STAGING) && (desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ) ) + { + // Handle case where the source is already a staging texture we can use directly + pStaging = pTexture; + } + else + { + // Otherwise, create a staging texture from the non-MSAA source + desc.BindFlags = 0; + desc.MiscFlags &= D3D11_RESOURCE_MISC_TEXTURECUBE; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + desc.Usage = D3D11_USAGE_STAGING; + + hr = d3dDevice->CreateTexture2D( &desc, 0, pStaging.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + assert( pStaging ); + + pContext->CopyResource( pStaging.Get(), pSource ); + } + +#if defined(_XBOX_ONE) && defined(_TITLE) + + if ( d3dDevice->GetCreationFlags() & D3D11_CREATE_DEVICE_IMMEDIATE_CONTEXT_FAST_SEMANTICS ) + { + ComPtr d3dDeviceX; + hr = d3dDevice.As( &d3dDeviceX ); + if ( FAILED(hr) ) + return hr; + + ComPtr d3dContextX; + hr = pContext->QueryInterface(IID_GRAPHICS_PPV_ARGS(d3dContextX.GetAddressOf())); + if ( FAILED(hr) ) + return hr; + + UINT64 copyFence = d3dContextX->InsertFence(0); + + while ( d3dDeviceX->IsFencePending( copyFence ) ) + { + SwitchToThread(); + } + } + +#endif + + return S_OK; +} + + +//-------------------------------------------------------------------------------------- +HRESULT DirectX::SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext, + _In_ ID3D11Resource* pSource, + _In_z_ LPCWSTR fileName ) +{ + if ( !fileName ) + return E_INVALIDARG; + + D3D11_TEXTURE2D_DESC desc = { 0 }; + ComPtr pStaging; + 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, 0 ) ) ); +#else + ScopedHandle hFile( safe_handle( CreateFileW( fileName, GENERIC_WRITE | DELETE, 0, 0, CREATE_ALWAYS, 0, 0 ) ) ); +#endif + 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 ]; + + *reinterpret_cast(&fileHeader[0]) = DDS_MAGIC; + + auto header = reinterpret_cast( &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 ); + header->flags = DDS_HEADER_FLAGS_TEXTURE | DDS_HEADER_FLAGS_MIPMAP; + header->height = desc.Height; + header->width = desc.Width; + header->mipMapCount = 1; + header->caps = DDS_SURFACE_FLAGS_TEXTURE; + + // 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 ) + { + 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 + + 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) ); + + headerSize += sizeof(DDS_HEADER_DXT10); + extHeader = reinterpret_cast( reinterpret_cast(&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; + } + + size_t rowPitch, slicePitch, rowCount; + GetSurfaceInfo( desc.Width, desc.Height, desc.Format, &slicePitch, &rowPitch, &rowCount ); + + if ( IsCompressed( desc.Format ) ) + { + header->flags |= DDS_HEADER_FLAGS_LINEARSIZE; + header->pitchOrLinearSize = static_cast( slicePitch ); + } + else + { + header->flags |= DDS_HEADER_FLAGS_PITCH; + header->pitchOrLinearSize = static_cast( rowPitch ); + } + + // Setup pixels + std::unique_ptr 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) ) + return hr; + + auto sptr = reinterpret_cast( mapped.pData ); + if ( !sptr ) + { + pContext->Unmap( pStaging.Get(), 0 ); + return E_POINTER; + } + + uint8_t* dptr = pixels.get(); + + size_t msize = std::min( rowPitch, mapped.RowPitch ); + for( size_t h = 0; h < rowCount; ++h ) + { + memcpy_s( dptr, rowPitch, sptr, msize ); + sptr += mapped.RowPitch; + dptr += rowPitch; + } + + pContext->Unmap( pStaging.Get(), 0 ); + + // Write header & pixels + DWORD bytesWritten; + if ( !WriteFile( hFile.get(), fileHeader, static_cast( headerSize ), &bytesWritten, 0 ) ) + return HRESULT_FROM_WIN32( GetLastError() ); + + if ( bytesWritten != headerSize ) + return E_FAIL; + + if ( !WriteFile( hFile.get(), pixels.get(), static_cast( slicePitch ), &bytesWritten, 0 ) ) + return HRESULT_FROM_WIN32( GetLastError() ); + + if ( bytesWritten != slicePitch ) + return E_FAIL; + + delonfail.clear(); + + return S_OK; +} + +//-------------------------------------------------------------------------------------- +#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) + +namespace DirectX +{ +extern bool _IsWIC2(); +extern IWICImagingFactory* _GetWIC(); +} + +HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext, + _In_ ID3D11Resource* pSource, + _In_ REFGUID guidContainerFormat, + _In_z_ LPCWSTR fileName, + _In_opt_ const GUID* targetFormat, + _In_opt_ std::function setCustomProps ) +{ + if ( !fileName ) + return E_INVALIDARG; + + D3D11_TEXTURE2D_DESC desc = { 0 }; + ComPtr pStaging; + 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 ) + { + 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_SRGB: + pfGuid = GUID_WICPixelFormat32bppRGBA; + sRGB = true; + 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_B8G8R8X8_UNORM: // DXGI 1.1 + pfGuid = GUID_WICPixelFormat32bppBGR; + break; + + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: // DXGI 1.1 + pfGuid = GUID_WICPixelFormat32bppBGR; + sRGB = true; + break; + + default: + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + + IWICImagingFactory* pWIC = _GetWIC(); + if ( !pWIC ) + return E_NOINTERFACE; + + ComPtr stream; + hr = pWIC->CreateStream( stream.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + hr = stream->InitializeFromFilename( fileName, GENERIC_WRITE ); + if ( FAILED(hr) ) + return hr; + + auto_delete_file_wic delonfail(stream, fileName); + + ComPtr encoder; + hr = pWIC->CreateEncoder( guidContainerFormat, 0, encoder.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + hr = encoder->Initialize( stream.Get(), WICBitmapEncoderNoCache ); + if ( FAILED(hr) ) + return hr; + + ComPtr frame; + ComPtr props; + hr = encoder->CreateNewFrame( frame.GetAddressOf(), props.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + 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 = { 0 }; + option.pstrName = L"EnableV5Header32bppBGRA"; + + VARIANT varValue; + varValue.vt = VT_BOOL; + varValue.boolVal = VARIANT_TRUE; + (void)props->Write( 1, &option, &varValue ); + } + + if ( setCustomProps ) + { + setCustomProps( props.Get() ); + } + + hr = frame->Initialize( props.Get() ); + if ( FAILED(hr) ) + return hr; + + hr = frame->SetSize( desc.Width , desc.Height ); + if ( FAILED(hr) ) + return hr; + + hr = frame->SetResolution( 72, 72 ); + if ( FAILED(hr) ) + return hr; + + // Pick a target format + WICPixelFormatGUID targetGuid; + if ( targetFormat ) + { + targetGuid = *targetFormat; + } + else + { + // 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 + { + 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; + } + } + + hr = frame->SetPixelFormat( &targetGuid ); + if ( FAILED(hr) ) + return hr; + + if ( targetFormat && memcmp( targetFormat, &targetGuid, sizeof(WICPixelFormatGUID) ) != 0 ) + { + // Requested output pixel format is not supported by the WIC codec + return E_FAIL; + } + + // Encode WIC metadata + ComPtr metawriter; + if ( SUCCEEDED( frame->GetMetadataQueryWriter( metawriter.GetAddressOf() ) ) ) + { + PROPVARIANT value; + PropVariantInit( &value ); + + value.vt = VT_LPSTR; + value.pszVal = "DirectXTK"; + + if ( memcmp( &guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID) ) == 0 ) + { + // Set Software name + (void)metawriter->SetMetadataByName( L"/tEXt/{str=Software}", &value ); + + // Set sRGB chunk + if ( sRGB ) + { + value.vt = VT_UI1; + value.bVal = 0; + (void)metawriter->SetMetadataByName( L"/sRGB/RenderingIntent", &value ); + } + } +#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 ); + + if ( sRGB ) + { + // Set EXIF Colorspace of sRGB + value.vt = VT_UI2; + value.uiVal = 1; + (void)metawriter->SetMetadataByName( L"/app1/ifd/exif/{ushort=40961}", &value ); + } + } + else if ( memcmp( &guidContainerFormat, &GUID_ContainerFormatTiff, sizeof(GUID) ) == 0 ) + { + // Set Software name + (void)metawriter->SetMetadataByName( L"/ifd/{ushort=305}", &value ); + + if ( sRGB ) + { + // Set EXIF Colorspace of sRGB + value.vt = VT_UI2; + value.uiVal = 1; + (void)metawriter->SetMetadataByName( L"/ifd/exif/{ushort=40961}", &value ); + } + } +#else + else + { + // Set Software name + (void)metawriter->SetMetadataByName( L"System.ApplicationName", &value ); + + if ( sRGB ) + { + // Set EXIF Colorspace of sRGB + value.vt = VT_UI2; + value.uiVal = 1; + (void)metawriter->SetMetadataByName( L"System.Image.ColorSpace", &value ); + } + } +#endif + } + + D3D11_MAPPED_SUBRESOURCE mapped; + hr = pContext->Map( pStaging.Get(), 0, D3D11_MAP_READ, 0, &mapped ); + if ( FAILED(hr) ) + return hr; + + if ( memcmp( &targetGuid, &pfGuid, sizeof(WICPixelFormatGUID) ) != 0 ) + { + // Conversion required to write + ComPtr source; + hr = pWIC->CreateBitmapFromMemory( desc.Width, desc.Height, pfGuid, + mapped.RowPitch, mapped.RowPitch * desc.Height, + reinterpret_cast( mapped.pData ), source.GetAddressOf() ); + if ( FAILED(hr) ) + { + pContext->Unmap( pStaging.Get(), 0 ); + return hr; + } + + ComPtr FC; + hr = pWIC->CreateFormatConverter( FC.GetAddressOf() ); + if ( FAILED(hr) ) + { + pContext->Unmap( pStaging.Get(), 0 ); + return hr; + } + + BOOL canConvert = FALSE; + hr = FC->CanConvert( pfGuid, targetGuid, &canConvert ); + if ( FAILED(hr) || !canConvert ) + { + return E_UNEXPECTED; + } + + hr = FC->Initialize( source.Get(), targetGuid, WICBitmapDitherTypeNone, 0, 0, WICBitmapPaletteTypeCustom ); + if ( FAILED(hr) ) + { + pContext->Unmap( pStaging.Get(), 0 ); + return hr; + } + + WICRect rect = { 0, 0, static_cast( desc.Width ), static_cast( desc.Height ) }; + hr = frame->WriteSource( FC.Get(), &rect ); + if ( FAILED(hr) ) + { + pContext->Unmap( pStaging.Get(), 0 ); + return hr; + } + } + else + { + // No conversion required + hr = frame->WritePixels( desc.Height, mapped.RowPitch, mapped.RowPitch * desc.Height, reinterpret_cast( mapped.pData ) ); + if ( FAILED(hr) ) + return hr; + } + + pContext->Unmap( pStaging.Get(), 0 ); + + hr = frame->Commit(); + if ( FAILED(hr) ) + return hr; + + hr = encoder->Commit(); + if ( FAILED(hr) ) + return hr; + + delonfail.clear(); + + return S_OK; +} + +#endif // !WINAPI_FAMILY || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (_WIN32_WINNT > _WIN32_WINNT_WIN8) diff --git a/Kits/DirectXTK/Src/Shaders/AlphaTestEffect.fx b/Kits/DirectXTK/Src/Shaders/AlphaTestEffect.fx new file mode 100644 index 0000000000000000000000000000000000000000..5179d2f2c2a00aa925fd164549882ce44639ab12 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/AlphaTestEffect.fx @@ -0,0 +1,133 @@ +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://create.msdn.com/en-US/education/catalog/sample/stock_effects + + +Texture2D Texture : register(t0); +sampler Sampler : register(s0); + + +cbuffer Parameters : register(b0) +{ + float4 DiffuseColor : packoffset(c0); + float4 AlphaTest : packoffset(c1); + float3 FogColor : packoffset(c2); + float4 FogVector : packoffset(c3); + float4x4 WorldViewProj : packoffset(c4); +}; + + +#include "Structures.fxh" +#include "Common.fxh" + + +// Vertex shader: basic. +VSOutputTx VSAlphaTest(VSInputTx vin) +{ + VSOutputTx vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: no fog. +VSOutputTxNoFog VSAlphaTestNoFog(VSInputTx vin) +{ + VSOutputTxNoFog vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParamsNoFog; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: vertex color. +VSOutputTx VSAlphaTestVc(VSInputTxVc vin) +{ + VSOutputTx vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: vertex color, no fog. +VSOutputTxNoFog VSAlphaTestVcNoFog(VSInputTxVc vin) +{ + VSOutputTxNoFog vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParamsNoFog; + + vout.TexCoord = vin.TexCoord; + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Pixel shader: less/greater compare function. +float4 PSAlphaTestLtGt(PSInputTx pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + clip((color.a < AlphaTest.x) ? AlphaTest.z : AlphaTest.w); + + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: less/greater compare function, no fog. +float4 PSAlphaTestLtGtNoFog(PSInputTxNoFog pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + clip((color.a < AlphaTest.x) ? AlphaTest.z : AlphaTest.w); + + return color; +} + + +// Pixel shader: equal/notequal compare function. +float4 PSAlphaTestEqNe(PSInputTx pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + clip((abs(color.a - AlphaTest.x) < AlphaTest.y) ? AlphaTest.z : AlphaTest.w); + + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: equal/notequal compare function, no fog. +float4 PSAlphaTestEqNeNoFog(PSInputTxNoFog pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + clip((abs(color.a - AlphaTest.x) < AlphaTest.y) ? AlphaTest.z : AlphaTest.w); + + return color; +} diff --git a/Kits/DirectXTK/Src/Shaders/BasicEffect.fx b/Kits/DirectXTK/Src/Shaders/BasicEffect.fx new file mode 100644 index 0000000000000000000000000000000000000000..b53df0df53730dba44f7432ad71a6d4e70248987 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/BasicEffect.fx @@ -0,0 +1,440 @@ +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://create.msdn.com/en-US/education/catalog/sample/stock_effects + + +Texture2D Texture : register(t0); +sampler Sampler : register(s0); + + +cbuffer Parameters : register(b0) +{ + float4 DiffuseColor : packoffset(c0); + float3 EmissiveColor : packoffset(c1); + float3 SpecularColor : packoffset(c2); + float SpecularPower : packoffset(c2.w); + + float3 LightDirection[3] : packoffset(c3); + float3 LightDiffuseColor[3] : packoffset(c6); + float3 LightSpecularColor[3] : packoffset(c9); + + float3 EyePosition : packoffset(c12); + + float3 FogColor : packoffset(c13); + float4 FogVector : packoffset(c14); + + float4x4 World : packoffset(c15); + float3x3 WorldInverseTranspose : packoffset(c19); + float4x4 WorldViewProj : packoffset(c22); +}; + + +#include "Structures.fxh" +#include "Common.fxh" +#include "Lighting.fxh" + + +// Vertex shader: basic. +VSOutput VSBasic(VSInput vin) +{ + VSOutput vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParams; + + return vout; +} + + +// Vertex shader: no fog. +VSOutputNoFog VSBasicNoFog(VSInput vin) +{ + VSOutputNoFog vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParamsNoFog; + + return vout; +} + + +// Vertex shader: vertex color. +VSOutput VSBasicVc(VSInputVc vin) +{ + VSOutput vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParams; + + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: vertex color, no fog. +VSOutputNoFog VSBasicVcNoFog(VSInputVc vin) +{ + VSOutputNoFog vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParamsNoFog; + + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: texture. +VSOutputTx VSBasicTx(VSInputTx vin) +{ + VSOutputTx vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: texture, no fog. +VSOutputTxNoFog VSBasicTxNoFog(VSInputTx vin) +{ + VSOutputTxNoFog vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParamsNoFog; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: texture + vertex color. +VSOutputTx VSBasicTxVc(VSInputTxVc vin) +{ + VSOutputTx vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: texture + vertex color, no fog. +VSOutputTxNoFog VSBasicTxVcNoFog(VSInputTxVc vin) +{ + VSOutputTxNoFog vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParamsNoFog; + + vout.TexCoord = vin.TexCoord; + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: vertex lighting. +VSOutput VSBasicVertexLighting(VSInputNm vin) +{ + VSOutput vout; + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); + SetCommonVSOutputParams; + + return vout; +} + + +// Vertex shader: vertex lighting + vertex color. +VSOutput VSBasicVertexLightingVc(VSInputNmVc vin) +{ + VSOutput vout; + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); + SetCommonVSOutputParams; + + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: vertex lighting + texture. +VSOutputTx VSBasicVertexLightingTx(VSInputNmTx vin) +{ + VSOutputTx vout; + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: vertex lighting + texture + vertex color. +VSOutputTx VSBasicVertexLightingTxVc(VSInputNmTxVc vin) +{ + VSOutputTx vout; + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: one light. +VSOutput VSBasicOneLight(VSInputNm vin) +{ + VSOutput vout; + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); + SetCommonVSOutputParams; + + return vout; +} + + +// Vertex shader: one light + vertex color. +VSOutput VSBasicOneLightVc(VSInputNmVc vin) +{ + VSOutput vout; + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); + SetCommonVSOutputParams; + + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: one light + texture. +VSOutputTx VSBasicOneLightTx(VSInputNmTx vin) +{ + VSOutputTx vout; + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: one light + texture + vertex color. +VSOutputTx VSBasicOneLightTxVc(VSInputNmTxVc vin) +{ + VSOutputTx vout; + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: pixel lighting. +VSOutputPixelLighting VSBasicPixelLighting(VSInputNm vin) +{ + VSOutputPixelLighting vout; + + CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); + SetCommonVSOutputParamsPixelLighting; + + vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); + + return vout; +} + + +// Vertex shader: pixel lighting + vertex color. +VSOutputPixelLighting VSBasicPixelLightingVc(VSInputNmVc vin) +{ + VSOutputPixelLighting vout; + + CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); + SetCommonVSOutputParamsPixelLighting; + + vout.Diffuse.rgb = vin.Color.rgb; + vout.Diffuse.a = vin.Color.a * DiffuseColor.a; + + return vout; +} + + +// Vertex shader: pixel lighting + texture. +VSOutputPixelLightingTx VSBasicPixelLightingTx(VSInputNmTx vin) +{ + VSOutputPixelLightingTx vout; + + CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); + SetCommonVSOutputParamsPixelLighting; + + vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: pixel lighting + texture + vertex color. +VSOutputPixelLightingTx VSBasicPixelLightingTxVc(VSInputNmTxVc vin) +{ + VSOutputPixelLightingTx vout; + + CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); + SetCommonVSOutputParamsPixelLighting; + + vout.Diffuse.rgb = vin.Color.rgb; + vout.Diffuse.a = vin.Color.a * DiffuseColor.a; + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Pixel shader: basic. +float4 PSBasic(PSInput pin) : SV_Target0 +{ + float4 color = pin.Diffuse; + + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: no fog. +float4 PSBasicNoFog(PSInputNoFog pin) : SV_Target0 +{ + return pin.Diffuse; +} + + +// Pixel shader: texture. +float4 PSBasicTx(PSInputTx pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: texture, no fog. +float4 PSBasicTxNoFog(PSInputTxNoFog pin) : SV_Target0 +{ + return Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; +} + + +// Pixel shader: vertex lighting. +float4 PSBasicVertexLighting(PSInput pin) : SV_Target0 +{ + float4 color = pin.Diffuse; + + AddSpecular(color, pin.Specular.rgb); + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: vertex lighting, no fog. +float4 PSBasicVertexLightingNoFog(PSInput pin) : SV_Target0 +{ + float4 color = pin.Diffuse; + + AddSpecular(color, pin.Specular.rgb); + + return color; +} + + +// Pixel shader: vertex lighting + texture. +float4 PSBasicVertexLightingTx(PSInputTx pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + AddSpecular(color, pin.Specular.rgb); + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: vertex lighting + texture, no fog. +float4 PSBasicVertexLightingTxNoFog(PSInputTx pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + AddSpecular(color, pin.Specular.rgb); + + return color; +} + + +// Pixel shader: pixel lighting. +float4 PSBasicPixelLighting(PSInputPixelLighting pin) : SV_Target0 +{ + float4 color = pin.Diffuse; + + float3 eyeVector = normalize(EyePosition - pin.PositionWS.xyz); + float3 worldNormal = normalize(pin.NormalWS); + + ColorPair lightResult = ComputeLights(eyeVector, worldNormal, 3); + + color.rgb *= lightResult.Diffuse; + + AddSpecular(color, lightResult.Specular); + ApplyFog(color, pin.PositionWS.w); + + return color; +} + + +// Pixel shader: pixel lighting + texture. +float4 PSBasicPixelLightingTx(PSInputPixelLightingTx pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + float3 eyeVector = normalize(EyePosition - pin.PositionWS.xyz); + float3 worldNormal = normalize(pin.NormalWS); + + ColorPair lightResult = ComputeLights(eyeVector, worldNormal, 3); + + color.rgb *= lightResult.Diffuse; + + AddSpecular(color, lightResult.Specular); + ApplyFog(color, pin.PositionWS.w); + + return color; +} diff --git a/Kits/DirectXTK/Src/Shaders/Common.fxh b/Kits/DirectXTK/Src/Shaders/Common.fxh new file mode 100644 index 0000000000000000000000000000000000000000..54ffe4e0871e76adab23b6baf35d9615689de3b4 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Common.fxh @@ -0,0 +1,60 @@ +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://create.msdn.com/en-US/education/catalog/sample/stock_effects + + +float ComputeFogFactor(float4 position) +{ + return saturate(dot(position, FogVector)); +} + + +void ApplyFog(inout float4 color, float fogFactor) +{ + color.rgb = lerp(color.rgb, FogColor * color.a, fogFactor); +} + + +void AddSpecular(inout float4 color, float3 specular) +{ + color.rgb += specular * color.a; +} + + +struct CommonVSOutput +{ + float4 Pos_ps; + float4 Diffuse; + float3 Specular; + float FogFactor; +}; + + +CommonVSOutput ComputeCommonVSOutput(float4 position) +{ + CommonVSOutput vout; + + vout.Pos_ps = mul(position, WorldViewProj); + vout.Diffuse = DiffuseColor; + vout.Specular = 0; + vout.FogFactor = ComputeFogFactor(position); + + return vout; +} + + +#define SetCommonVSOutputParams \ + vout.PositionPS = cout.Pos_ps; \ + vout.Diffuse = cout.Diffuse; \ + vout.Specular = float4(cout.Specular, cout.FogFactor); + + +#define SetCommonVSOutputParamsNoFog \ + vout.PositionPS = cout.Pos_ps; \ + vout.Diffuse = cout.Diffuse; diff --git a/Kits/DirectXTK/Src/Shaders/CompileShaders.cmd b/Kits/DirectXTK/Src/Shaders/CompileShaders.cmd new file mode 100644 index 0000000000000000000000000000000000000000..4d53b490f5eadf0789204a482d3975c6eeb5b8a9 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/CompileShaders.cmd @@ -0,0 +1,176 @@ +@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. + +setlocal +set error=0 + +if %1.==xbox. goto continuexbox +if %1.==. goto continue +echo usage: CompileShaders [xbox] +exit /b + +:continuexbox +set XBOXFXC="%XboxOneXDKLatest%xdk\FXC\amd64\FXC.exe" +if exist %XBOXFXC% goto continue +set XBOXFXC="%XboxOneXDKBuild%xdk\FXC\amd64\FXC.exe" +if exist %XBOXFXC% goto continue +set XBOXFXC="%DurangoXDK%xdk\FXC\amd64\FXC.exe" +if not exist %XBOXFXC% goto needxdk + +:continue + +call :CompileShader%1 AlphaTestEffect vs VSAlphaTest +call :CompileShader%1 AlphaTestEffect vs VSAlphaTestNoFog +call :CompileShader%1 AlphaTestEffect vs VSAlphaTestVc +call :CompileShader%1 AlphaTestEffect vs VSAlphaTestVcNoFog + +call :CompileShader%1 AlphaTestEffect ps PSAlphaTestLtGt +call :CompileShader%1 AlphaTestEffect ps PSAlphaTestLtGtNoFog +call :CompileShader%1 AlphaTestEffect ps PSAlphaTestEqNe +call :CompileShader%1 AlphaTestEffect ps PSAlphaTestEqNeNoFog + +call :CompileShader%1 BasicEffect vs VSBasic +call :CompileShader%1 BasicEffect vs VSBasicNoFog +call :CompileShader%1 BasicEffect vs VSBasicVc +call :CompileShader%1 BasicEffect vs VSBasicVcNoFog +call :CompileShader%1 BasicEffect vs VSBasicTx +call :CompileShader%1 BasicEffect vs VSBasicTxNoFog +call :CompileShader%1 BasicEffect vs VSBasicTxVc +call :CompileShader%1 BasicEffect vs VSBasicTxVcNoFog + +call :CompileShader%1 BasicEffect vs VSBasicVertexLighting +call :CompileShader%1 BasicEffect vs VSBasicVertexLightingVc +call :CompileShader%1 BasicEffect vs VSBasicVertexLightingTx +call :CompileShader%1 BasicEffect vs VSBasicVertexLightingTxVc + +call :CompileShader%1 BasicEffect vs VSBasicOneLight +call :CompileShader%1 BasicEffect vs VSBasicOneLightVc +call :CompileShader%1 BasicEffect vs VSBasicOneLightTx +call :CompileShader%1 BasicEffect vs VSBasicOneLightTxVc + +call :CompileShader%1 BasicEffect vs VSBasicPixelLighting +call :CompileShader%1 BasicEffect vs VSBasicPixelLightingVc +call :CompileShader%1 BasicEffect vs VSBasicPixelLightingTx +call :CompileShader%1 BasicEffect vs VSBasicPixelLightingTxVc + +call :CompileShader%1 BasicEffect ps PSBasic +call :CompileShader%1 BasicEffect ps PSBasicNoFog +call :CompileShader%1 BasicEffect ps PSBasicTx +call :CompileShader%1 BasicEffect ps PSBasicTxNoFog + +call :CompileShader%1 BasicEffect ps PSBasicVertexLighting +call :CompileShader%1 BasicEffect ps PSBasicVertexLightingNoFog +call :CompileShader%1 BasicEffect ps PSBasicVertexLightingTx +call :CompileShader%1 BasicEffect ps PSBasicVertexLightingTxNoFog + +call :CompileShader%1 BasicEffect ps PSBasicPixelLighting +call :CompileShader%1 BasicEffect ps PSBasicPixelLightingTx + +call :CompileShader%1 DualTextureEffect vs VSDualTexture +call :CompileShader%1 DualTextureEffect vs VSDualTextureNoFog +call :CompileShader%1 DualTextureEffect vs VSDualTextureVc +call :CompileShader%1 DualTextureEffect vs VSDualTextureVcNoFog + +call :CompileShader%1 DualTextureEffect ps PSDualTexture +call :CompileShader%1 DualTextureEffect ps PSDualTextureNoFog + +call :CompileShader%1 EnvironmentMapEffect vs VSEnvMap +call :CompileShader%1 EnvironmentMapEffect vs VSEnvMapFresnel +call :CompileShader%1 EnvironmentMapEffect vs VSEnvMapOneLight +call :CompileShader%1 EnvironmentMapEffect vs VSEnvMapOneLightFresnel + +call :CompileShader%1 EnvironmentMapEffect ps PSEnvMap +call :CompileShader%1 EnvironmentMapEffect ps PSEnvMapNoFog +call :CompileShader%1 EnvironmentMapEffect ps PSEnvMapSpecular +call :CompileShader%1 EnvironmentMapEffect ps PSEnvMapSpecularNoFog + +call :CompileShader%1 SkinnedEffect vs VSSkinnedVertexLightingOneBone +call :CompileShader%1 SkinnedEffect vs VSSkinnedVertexLightingTwoBones +call :CompileShader%1 SkinnedEffect vs VSSkinnedVertexLightingFourBones + +call :CompileShader%1 SkinnedEffect vs VSSkinnedOneLightOneBone +call :CompileShader%1 SkinnedEffect vs VSSkinnedOneLightTwoBones +call :CompileShader%1 SkinnedEffect vs VSSkinnedOneLightFourBones + +call :CompileShader%1 SkinnedEffect vs VSSkinnedPixelLightingOneBone +call :CompileShader%1 SkinnedEffect vs VSSkinnedPixelLightingTwoBones +call :CompileShader%1 SkinnedEffect vs VSSkinnedPixelLightingFourBones + +call :CompileShader%1 SkinnedEffect ps PSSkinnedVertexLighting +call :CompileShader%1 SkinnedEffect ps PSSkinnedVertexLightingNoFog +call :CompileShader%1 SkinnedEffect ps PSSkinnedPixelLighting + +call :CompileShader%1 SpriteEffect vs SpriteVertexShader +call :CompileShader%1 SpriteEffect ps SpritePixelShader + +call :CompileShader%1 DGSLEffect vs main +call :CompileShader%1 DGSLEffect vs mainVc +call :CompileShader%1 DGSLEffect vs main1Bones +call :CompileShader%1 DGSLEffect vs main1BonesVc +call :CompileShader%1 DGSLEffect vs main2Bones +call :CompileShader%1 DGSLEffect vs main2BonesVc +call :CompileShader%1 DGSLEffect vs main4Bones +call :CompileShader%1 DGSLEffect vs main4BonesVc + +call :CompileShaderHLSL%1 DGSLUnlit ps main +call :CompileShaderHLSL%1 DGSLLambert ps main +call :CompileShaderHLSL%1 DGSLPhong ps main + +call :CompileShaderHLSL%1 DGSLUnlit ps mainTk +call :CompileShaderHLSL%1 DGSLLambert ps mainTk +call :CompileShaderHLSL%1 DGSLPhong ps mainTk + +call :CompileShaderHLSL%1 DGSLUnlit ps mainTx +call :CompileShaderHLSL%1 DGSLLambert ps mainTx +call :CompileShaderHLSL%1 DGSLPhong ps mainTx + +call :CompileShaderHLSL%1 DGSLUnlit ps mainTxTk +call :CompileShaderHLSL%1 DGSLLambert ps mainTxTk +call :CompileShaderHLSL%1 DGSLPhong ps mainTxTk +echo. + +if %error% == 0 ( + echo Shaders compiled ok +) else ( + echo There were shader compilation errors! +) + +endlocal +exit /b + +:CompileShader +set fxc=fxc /nologo %1.fx /T%2_4_0_level_9_1 /Zpc /Qstrip_reflect /Qstrip_debug /E%3 /FhCompiled\%1_%3.inc /Vn%1_%3 +echo. +echo %fxc% +%fxc% || set error=1 +exit /b + +:CompileShaderHLSL +set fxc=fxc /nologo %1.hlsl /T%2_4_0_level_9_1 /Zpc /Qstrip_reflect /Qstrip_debug /E%3 /FhCompiled\%1_%3.inc /Vn%1_%3 +echo. +echo %fxc% +%fxc% || set error=1 +exit /b + +:CompileShaderxbox +set fxc=%XBOXFXC% /nologo %1.fx /T%2_5_0 /Zpc /Qstrip_reflect /Qstrip_debug /D__XBOX_DISABLE_SHADER_NAME_EMPLACEMENT /E%3 /FhCompiled\XboxOne%1_%3.inc /Vn%1_%3 +echo. +echo %fxc% +%fxc% || set error=1 +exit /b + +:CompileShaderHLSLxbox +set fxc=%XBOXFXC% /nologo %1.hlsl /T%2_5_0 /Zpc /Qstrip_reflect /Qstrip_debug /D__XBOX_DISABLE_SHADER_NAME_EMPLACEMENT /E%3 /FhCompiled\XboxOne%1_%3.inc /Vn%1_%3 +echo. +echo %fxc% +%fxc% || set error=1 +exit /b + +:needxdk +echo ERROR: CompileShaders xbox requires the Microsoft Xbox One XDK +echo (try re-running from the XDK Command Prompt) \ No newline at end of file diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestEqNe.inc b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestEqNe.inc new file mode 100644 index 0000000000000000000000000000000000000000..8b7bcac260614c049b9e654811402d80e9698647 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestEqNe.inc @@ -0,0 +1,235 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float w +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 1 2 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl_2d s0 + texld r0, t2, s0 + mad r1.w, r0.w, t0.w, -c0.x + mul r0, r0, t0 + abs r1.x, r1.w + add r1.x, r1.x, -c0.y + cmp r1, r1.x, c0.w, c0.z + texkill r1 + mad r1.xyz, c1, r0.w, -r0 + mad r0.xyz, t1.w, r1, r0 + mov oC0, r0 + +// approximately 10 instruction slots used (1 texture, 9 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[3], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.w +dcl_input_ps linear v2.xy +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mad r1.x, r0.w, v0.w, -cb0[1].x +mul r0.xyzw, r0.xyzw, v0.xyzw +lt r1.x, |r1.x|, cb0[1].y +movc r1.x, r1.x, cb0[1].z, cb0[1].w +lt r1.x, r1.x, l(0.000000) +discard_nz r1.x +mad r1.xyz, cb0[2].xyzx, r0.wwww, -r0.xyzx +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +mov o0.w, r0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE AlphaTestEffect_PSAlphaTestEqNe[] = +{ + 68, 88, 66, 67, 123, 41, + 156, 115, 172, 45, 94, 163, + 162, 165, 36, 203, 174, 182, + 166, 134, 1, 0, 0, 0, + 160, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 68, 1, 0, 0, 4, 3, + 0, 0, 108, 3, 0, 0, + 65, 111, 110, 57, 12, 1, + 0, 0, 12, 1, 0, 0, + 0, 2, 255, 255, 216, 0, + 0, 0, 52, 0, 0, 0, + 1, 0, 40, 0, 0, 0, + 52, 0, 0, 0, 52, 0, + 1, 0, 36, 0, 0, 0, + 52, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 228, 176, 0, 8, + 228, 160, 4, 0, 0, 4, + 1, 0, 8, 128, 0, 0, + 255, 128, 0, 0, 255, 176, + 0, 0, 0, 161, 5, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 128, 0, 0, + 228, 176, 35, 0, 0, 2, + 1, 0, 1, 128, 1, 0, + 255, 128, 2, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 0, 128, 0, 0, 85, 161, + 88, 0, 0, 4, 1, 0, + 15, 128, 1, 0, 0, 128, + 0, 0, 255, 160, 0, 0, + 170, 160, 65, 0, 0, 1, + 1, 0, 15, 128, 4, 0, + 0, 4, 1, 0, 7, 128, + 1, 0, 228, 160, 0, 0, + 255, 128, 0, 0, 228, 129, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 255, 176, + 1, 0, 228, 128, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 184, 1, + 0, 0, 64, 0, 0, 0, + 110, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 98, 16, 0, 3, 130, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 2, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 2, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 18, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 49, 0, 0, 9, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 128, + 129, 0, 0, 0, 1, 0, + 0, 0, 26, 128, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 55, 0, 0, 11, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 42, 128, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 58, 128, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 49, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 13, 0, 4, 3, + 10, 0, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 32, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 96, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 80, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 8, + 0, 0, 86, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestEqNeNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestEqNeNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..6e6f91e6036a34d35337b2e6dd7d4da9ef8de2ac --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestEqNeNoFog.inc @@ -0,0 +1,200 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 1 1 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1.xy + dcl_2d s0 + texld r0, t1, s0 + mad r1.w, r0.w, t0.w, -c0.x + mul r0, r0, t0 + mov oC0, r0 + abs r0.x, r1.w + add r0.x, r0.x, -c0.y + cmp r0, r0.x, c0.w, c0.z + texkill r0 + +// approximately 8 instruction slots used (1 texture, 7 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xy +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v1.xyxx, t0.xyzw, s0 +mad r1.x, r0.w, v0.w, -cb0[1].x +mul r0.xyzw, r0.xyzw, v0.xyzw +mov o0.xyzw, r0.xyzw +lt r0.x, |r1.x|, cb0[1].y +movc r0.x, r0.x, cb0[1].z, cb0[1].w +lt r0.x, r0.x, l(0.000000) +discard_nz r0.x +ret +// Approximately 0 instruction slots used +#endif + +const BYTE AlphaTestEffect_PSAlphaTestEqNeNoFog[] = +{ + 68, 88, 66, 67, 142, 41, + 152, 238, 100, 236, 167, 190, + 1, 194, 156, 60, 169, 254, + 95, 169, 1, 0, 0, 0, + 248, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 16, 1, 0, 0, 116, 2, + 0, 0, 196, 2, 0, 0, + 65, 111, 110, 57, 216, 0, + 0, 0, 216, 0, 0, 0, + 0, 2, 255, 255, 164, 0, + 0, 0, 52, 0, 0, 0, + 1, 0, 40, 0, 0, 0, + 52, 0, 0, 0, 52, 0, + 1, 0, 36, 0, 0, 0, + 52, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 4, 0, 0, 4, + 1, 0, 8, 128, 0, 0, + 255, 128, 0, 0, 255, 176, + 0, 0, 0, 161, 5, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 128, 0, 0, + 228, 176, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 35, 0, 0, 2, + 0, 0, 1, 128, 1, 0, + 255, 128, 2, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 0, 0, 85, 161, + 88, 0, 0, 4, 0, 0, + 15, 128, 0, 0, 0, 128, + 0, 0, 255, 160, 0, 0, + 170, 160, 65, 0, 0, 1, + 0, 0, 15, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 92, 1, 0, 0, 64, 0, + 0, 0, 87, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 2, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 1, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 18, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 58, 16, 16, 0, 0, 0, + 0, 0, 10, 128, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 49, 0, 0, 9, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 128, 129, 0, + 0, 0, 1, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 55, 0, 0, 11, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 42, 128, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 49, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 13, 0, 4, 3, 10, 0, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 72, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 62, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestLtGt.inc b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestLtGt.inc new file mode 100644 index 0000000000000000000000000000000000000000..4913c4f2a6d6e318cc5ba185917523768a547d3c --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestLtGt.inc @@ -0,0 +1,219 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float w +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 1 2 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl_2d s0 + texld r0, t2, s0 + mad r1.w, r0.w, t0.w, -c0.x + mul r0, r0, t0 + cmp r1, r1.w, c0.w, c0.z + texkill r1 + mad r1.xyz, c1, r0.w, -r0 + mad r0.xyz, t1.w, r1, r0 + mov oC0, r0 + +// approximately 8 instruction slots used (1 texture, 7 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[3], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.w +dcl_input_ps linear v2.xy +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul r0.xyzw, r0.xyzw, v0.xyzw +lt r1.x, r0.w, cb0[1].x +movc r1.x, r1.x, cb0[1].z, cb0[1].w +lt r1.x, r1.x, l(0.000000) +discard_nz r1.x +mad r1.xyz, cb0[2].xyzx, r0.wwww, -r0.xyzx +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +mov o0.w, r0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE AlphaTestEffect_PSAlphaTestLtGt[] = +{ + 68, 88, 66, 67, 132, 113, + 218, 60, 91, 20, 51, 146, + 238, 127, 172, 137, 199, 66, + 234, 195, 1, 0, 0, 0, + 84, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 40, 1, 0, 0, 184, 2, + 0, 0, 32, 3, 0, 0, + 65, 111, 110, 57, 240, 0, + 0, 0, 240, 0, 0, 0, + 0, 2, 255, 255, 188, 0, + 0, 0, 52, 0, 0, 0, + 1, 0, 40, 0, 0, 0, + 52, 0, 0, 0, 52, 0, + 1, 0, 36, 0, 0, 0, + 52, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 228, 176, 0, 8, + 228, 160, 4, 0, 0, 4, + 1, 0, 8, 128, 0, 0, + 255, 128, 0, 0, 255, 176, + 0, 0, 0, 161, 5, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 128, 0, 0, + 228, 176, 88, 0, 0, 4, + 1, 0, 15, 128, 1, 0, + 255, 128, 0, 0, 255, 160, + 0, 0, 170, 160, 65, 0, + 0, 1, 1, 0, 15, 128, + 4, 0, 0, 4, 1, 0, + 7, 128, 1, 0, 228, 160, + 0, 0, 255, 128, 0, 0, + 228, 129, 4, 0, 0, 4, + 0, 0, 7, 128, 1, 0, + 255, 176, 1, 0, 228, 128, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 8, 15, 128, + 0, 0, 228, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 136, 1, 0, 0, 64, 0, + 0, 0, 98, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 98, 16, 0, 3, + 130, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 2, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 49, 0, 0, 8, + 18, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 10, 128, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 55, 0, + 0, 11, 18, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 42, 128, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 49, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 13, 0, + 4, 3, 10, 0, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 50, 0, 0, 9, 114, 32, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 96, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 80, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 8, 0, 0, 86, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestLtGtNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestLtGtNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..8e267e565ba123a4aa666de75468c9e9a3c2ecbf --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_PSAlphaTestLtGtNoFog.inc @@ -0,0 +1,184 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 1 1 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1.xy + dcl_2d s0 + texld r0, t1, s0 + mad r1.w, r0.w, t0.w, -c0.x + mul r0, r0, t0 + mov oC0, r0 + cmp r0, r1.w, c0.w, c0.z + texkill r0 + +// approximately 6 instruction slots used (1 texture, 5 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xy +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v1.xyxx, t0.xyzw, s0 +mul r0.xyzw, r0.xyzw, v0.xyzw +lt r1.x, r0.w, cb0[1].x +mov o0.xyzw, r0.xyzw +movc r0.x, r1.x, cb0[1].z, cb0[1].w +lt r0.x, r0.x, l(0.000000) +discard_nz r0.x +ret +// Approximately 0 instruction slots used +#endif + +const BYTE AlphaTestEffect_PSAlphaTestLtGtNoFog[] = +{ + 68, 88, 66, 67, 217, 179, + 156, 255, 144, 2, 9, 89, + 233, 242, 157, 125, 191, 110, + 15, 216, 1, 0, 0, 0, + 172, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 244, 0, 0, 0, 40, 2, + 0, 0, 120, 2, 0, 0, + 65, 111, 110, 57, 188, 0, + 0, 0, 188, 0, 0, 0, + 0, 2, 255, 255, 136, 0, + 0, 0, 52, 0, 0, 0, + 1, 0, 40, 0, 0, 0, + 52, 0, 0, 0, 52, 0, + 1, 0, 36, 0, 0, 0, + 52, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 4, 0, 0, 4, + 1, 0, 8, 128, 0, 0, + 255, 128, 0, 0, 255, 176, + 0, 0, 0, 161, 5, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 128, 0, 0, + 228, 176, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 88, 0, 0, 4, + 0, 0, 15, 128, 1, 0, + 255, 128, 0, 0, 255, 160, + 0, 0, 170, 160, 65, 0, + 0, 1, 0, 0, 15, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 44, 1, 0, 0, + 64, 0, 0, 0, 75, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 2, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 49, 0, + 0, 8, 18, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 5, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 55, 0, 0, 11, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 42, 128, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 58, 128, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 49, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 13, 0, 4, 3, + 10, 0, 16, 0, 0, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 72, 0, + 0, 0, 2, 0, 0, 0, + 8, 0, 0, 0, 56, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 62, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 3, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTest.inc b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTest.inc new file mode 100644 index 0000000000000000000000000000000000000000..c2e32be006cf9e60af31eb31751d0e364a3d140c --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTest.inc @@ -0,0 +1,237 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 3 5 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c7, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dp4 oPos.z, v0, c5 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c7.x + min oT1.w, r0.x, c7.y + dp4 r0.x, v0, c3 + dp4 r0.y, v0, c4 + dp4 r0.z, v0, c6 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0, c1 + mov oT1.xyz, c7.x + mov oT2.xy, v1 + +// approximately 12 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[8], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +mov o0.xyzw, cb0[0].xyzw +dp4_sat o1.w, v0.xyzw, cb0[3].xyzw +mov o1.xyz, l(0,0,0,0) +mov o2.xy, v1.xyxx +dp4 o3.x, v0.xyzw, cb0[4].xyzw +dp4 o3.y, v0.xyzw, cb0[5].xyzw +dp4 o3.z, v0.xyzw, cb0[6].xyzw +dp4 o3.w, v0.xyzw, cb0[7].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE AlphaTestEffect_VSAlphaTest[] = +{ + 68, 88, 66, 67, 4, 149, + 62, 151, 78, 3, 139, 252, + 103, 187, 235, 135, 118, 107, + 194, 7, 1, 0, 0, 0, + 164, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 100, 1, 0, 0, 192, 2, + 0, 0, 24, 3, 0, 0, + 65, 111, 110, 57, 44, 1, + 0, 0, 44, 1, 0, 0, + 0, 2, 254, 255, 236, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 5, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 7, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 5, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 7, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 7, 0, + 85, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 3, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 4, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 6, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 1, 0, 228, 160, 1, 0, + 0, 2, 1, 0, 7, 224, + 7, 0, 0, 160, 1, 0, + 0, 2, 2, 0, 3, 224, + 1, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 84, 1, 0, 0, 64, 0, + 1, 0, 85, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 54, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 80, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 171, 171, + 79, 83, 71, 78, 132, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 110, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 119, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTestNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTestNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..308705f6b1ff26a55b0b77c2453ddd21c1f1d273 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTestNoFog.inc @@ -0,0 +1,197 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 4 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dp4 oPos.z, v0, c4 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c5 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0, c1 + mov oT1.xy, v1 + +// approximately 8 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[8], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_output o0.xyzw +dcl_output o1.xy +dcl_output_siv o2.xyzw, position +mov o0.xyzw, cb0[0].xyzw +mov o1.xy, v1.xyxx +dp4 o2.x, v0.xyzw, cb0[4].xyzw +dp4 o2.y, v0.xyzw, cb0[5].xyzw +dp4 o2.z, v0.xyzw, cb0[6].xyzw +dp4 o2.w, v0.xyzw, cb0[7].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE AlphaTestEffect_VSAlphaTestNoFog[] = +{ + 68, 88, 66, 67, 79, 234, + 189, 22, 246, 154, 20, 26, + 68, 213, 247, 236, 90, 124, + 169, 133, 1, 0, 0, 0, + 236, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 16, 1, 0, 0, 32, 2, + 0, 0, 120, 2, 0, 0, + 65, 111, 110, 57, 216, 0, + 0, 0, 216, 0, 0, 0, + 0, 2, 254, 255, 152, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 4, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 5, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 1, 0, 228, 160, 1, 0, + 0, 2, 1, 0, 3, 224, + 1, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 8, 1, 0, 0, 64, 0, + 1, 0, 66, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 7, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 80, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 79, 83, 71, 78, + 108, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 12, 0, 0, + 95, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTestVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTestVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..e2ac08e7d29f9441b2f4fe7e6743fd9fbcace005 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTestVc.inc @@ -0,0 +1,250 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// COLOR 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 3 5 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c7, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 oPos.z, v0, c5 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c7.x + min oT1.w, r0.x, c7.y + mul oT0, v2, c1 + dp4 r0.x, v0, c3 + dp4 r0.y, v0, c4 + dp4 r0.z, v0, c6 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT1.xyz, c7.x + mov oT2.xy, v1 + +// approximately 12 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[8], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +mul o0.xyzw, v2.xyzw, cb0[0].xyzw +dp4_sat o1.w, v0.xyzw, cb0[3].xyzw +mov o1.xyz, l(0,0,0,0) +mov o2.xy, v1.xyxx +dp4 o3.x, v0.xyzw, cb0[4].xyzw +dp4 o3.y, v0.xyzw, cb0[5].xyzw +dp4 o3.z, v0.xyzw, cb0[6].xyzw +dp4 o3.w, v0.xyzw, cb0[7].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE AlphaTestEffect_VSAlphaTestVc[] = +{ + 68, 88, 66, 67, 69, 205, + 186, 194, 49, 115, 174, 223, + 225, 69, 58, 248, 175, 79, + 119, 92, 1, 0, 0, 0, + 228, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 116, 1, 0, 0, 228, 2, + 0, 0, 88, 3, 0, 0, + 65, 111, 110, 57, 60, 1, + 0, 0, 60, 1, 0, 0, + 0, 2, 254, 255, 252, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 5, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 7, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 5, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 7, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 7, 0, + 85, 160, 5, 0, 0, 3, + 0, 0, 15, 224, 2, 0, + 228, 144, 1, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 4, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 6, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 1, 0, 7, 224, 7, 0, + 0, 160, 1, 0, 0, 2, + 2, 0, 3, 224, 1, 0, + 228, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 104, 1, + 0, 0, 64, 0, 1, 0, + 90, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 54, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 108, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 101, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 67, 79, 76, + 79, 82, 0, 171, 79, 83, + 71, 78, 132, 0, 0, 0, + 4, 0, 0, 0, 8, 0, + 0, 0, 104, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 104, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 110, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 12, + 0, 0, 119, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 0, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 83, + 86, 95, 80, 111, 115, 105, + 116, 105, 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTestVcNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTestVcNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..d80383f4abbeff952b228a5e19908264e68d803d --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/AlphaTestEffect_VSAlphaTestVcNoFog.inc @@ -0,0 +1,211 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// COLOR 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 4 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 oPos.z, v0, c4 + mul oT0, v2, c1 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c5 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT1.xy, v1 + +// approximately 8 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[8], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xyzw +dcl_output o0.xyzw +dcl_output o1.xy +dcl_output_siv o2.xyzw, position +mul o0.xyzw, v2.xyzw, cb0[0].xyzw +mov o1.xy, v1.xyxx +dp4 o2.x, v0.xyzw, cb0[4].xyzw +dp4 o2.y, v0.xyzw, cb0[5].xyzw +dp4 o2.z, v0.xyzw, cb0[6].xyzw +dp4 o2.w, v0.xyzw, cb0[7].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE AlphaTestEffect_VSAlphaTestVcNoFog[] = +{ + 68, 88, 66, 67, 74, 78, + 144, 38, 108, 118, 154, 251, + 203, 88, 218, 105, 165, 123, + 55, 217, 1, 0, 0, 0, + 44, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 32, 1, 0, 0, 68, 2, + 0, 0, 184, 2, 0, 0, + 65, 111, 110, 57, 232, 0, + 0, 0, 232, 0, 0, 0, + 0, 2, 254, 255, 168, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 4, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 224, 2, 0, + 228, 144, 1, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 3, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 5, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 1, 0, 3, 224, 1, 0, + 228, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 28, 1, + 0, 0, 64, 0, 1, 0, + 71, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 1, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 7, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 108, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 92, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 101, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 15, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 171, + 79, 83, 71, 78, 108, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 86, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 12, 0, 0, 95, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasic.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasic.inc new file mode 100644 index 0000000000000000000000000000000000000000..4781a8c5b2119bf4b2e61f1f12fa33be730af690 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasic.inc @@ -0,0 +1,141 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float w +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 13 1 ( FLT, FLT, FLT, FLT) +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + mad r0.xyz, c0, t0.w, -t0 + mov r1.xyz, t0 + mad r0.xyz, t1.w, r0, r1 + mov r0.w, t0.w + mov oC0, r0 + +// approximately 5 instruction slots used +ps_4_0 +dcl_constantbuffer CB0[14], immediateIndexed +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.w +dcl_output o0.xyzw +dcl_temps 1 +mad r0.xyz, cb0[13].xyzx, v0.wwww, -v0.xyzx +mad o0.xyz, v1.wwww, r0.xyzx, v0.xyzx +mov o0.w, v0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasic[] = +{ + 68, 88, 66, 67, 132, 106, + 64, 52, 44, 8, 201, 31, + 156, 78, 243, 147, 144, 166, + 2, 49, 1, 0, 0, 0, + 4, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 212, 0, 0, 0, 136, 1, + 0, 0, 208, 1, 0, 0, + 65, 111, 110, 57, 156, 0, + 0, 0, 156, 0, 0, 0, + 0, 2, 255, 255, 108, 0, + 0, 0, 48, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 13, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 2, 255, 255, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 1, 0, 15, 176, + 4, 0, 0, 4, 0, 0, + 7, 128, 0, 0, 228, 160, + 0, 0, 255, 176, 0, 0, + 228, 177, 1, 0, 0, 2, + 1, 0, 7, 128, 0, 0, + 228, 176, 4, 0, 0, 4, + 0, 0, 7, 128, 1, 0, + 255, 176, 0, 0, 228, 128, + 1, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 128, + 0, 0, 255, 176, 1, 0, + 0, 2, 0, 8, 15, 128, + 0, 0, 228, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 172, 0, 0, 0, 64, 0, + 0, 0, 43, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 98, 16, + 0, 3, 130, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 13, 0, 0, 0, + 246, 31, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 114, 32, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 16, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 64, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 56, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 8, 0, 0, + 67, 79, 76, 79, 82, 0, + 171, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..fa3eb521b258784409843bc076d679efb58891ea --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicNoFog.inc @@ -0,0 +1,85 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + mov oC0, t0 + +// approximately 1 instruction slot used +ps_4_0 +dcl_input_ps linear v0.xyzw +dcl_output o0.xyzw +mov o0.xyzw, v0.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasicNoFog[] = +{ + 68, 88, 66, 67, 218, 245, + 81, 3, 21, 86, 134, 132, + 242, 64, 147, 169, 186, 94, + 60, 67, 1, 0, 0, 0, + 32, 1, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 124, 0, 0, 0, 188, 0, + 0, 0, 236, 0, 0, 0, + 65, 111, 110, 57, 68, 0, + 0, 0, 68, 0, 0, 0, + 0, 2, 255, 255, 32, 0, + 0, 0, 36, 0, 0, 0, + 0, 0, 36, 0, 0, 0, + 36, 0, 0, 0, 36, 0, + 0, 0, 36, 0, 0, 0, + 36, 0, 0, 2, 255, 255, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 0, 0, 228, 176, + 255, 255, 0, 0, 83, 72, + 68, 82, 56, 0, 0, 0, + 64, 0, 0, 0, 14, 0, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 40, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 67, 79, 76, 79, 82, 0, + 171, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicPixelLighting.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicPixelLighting.inc new file mode 100644 index 0000000000000000000000000000000000000000..1cbd36cedcbddfadc32a880f876dfeb9e011aa05 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicPixelLighting.inc @@ -0,0 +1,557 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xyzw 0 NONE float xyzw +// TEXCOORD 1 xyz 1 NONE float xyz +// COLOR 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 14 ( FLT, FLT, FLT, FLT) +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c14, 1, 0, 0, 0 + dcl t0 + dcl t1.xyz + dcl t2 + nrm r0.xyz, t1 + dp3 r1.x, -c3, r0 + dp3 r1.y, -c4, r0 + dp3 r1.z, -c5, r0 + cmp r2.xyz, r1, c14.x, c14.y + mul r1.xyz, r1, r2 + add r3.xyz, -t0, c12 + dp3 r0.w, r3, r3 + rsq r0.w, r0.w + mad r4.xyz, r3, r0.w, -c3 + nrm r5.xyz, r4 + dp3 r4.x, r5, r0 + mad r5.xyz, r3, r0.w, -c4 + mad r3.xyz, r3, r0.w, -c5 + nrm r6.xyz, r3 + dp3 r4.z, r6, r0 + nrm r3.xyz, r5 + dp3 r4.y, r3, r0 + mul r0.xyz, r2, r4 + cmp r0.xyz, r4, r0, c14.y + log r2.x, r0.x + log r2.y, r0.y + log r2.z, r0.z + mul r0.xyz, r2, c2.w + exp r1.w, r0.y + mul r2.xyz, r1.w, c10 + exp r1.w, r0.x + exp r2.w, r0.z + mad r0.xyz, r1.w, c9, r2 + mad r0.xyz, r2.w, c11, r0 + mul r0.xyz, r0, c2 + mul r0.xyz, r0, t2.w + mul r2.xyz, r1.y, c7 + mad r2.xyz, r1.x, c6, r2 + mad r1.xyz, r1.z, c8, r2 + mov r2.xyz, c0 + mad r1.xyz, r1, r2, c1 + mad r0.xyz, t2, r1, r0 + mad r1.xyz, c13, t2.w, -r0 + mad r0.xyz, t0.w, r1, r0 + mov r0.w, t2.w + mov oC0, r0 + +// approximately 50 instruction slots used +ps_4_0 +dcl_constantbuffer CB0[14], immediateIndexed +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyz +dcl_input_ps linear v2.xyzw +dcl_output o0.xyzw +dcl_temps 4 +add r0.xyz, -v0.xyzx, cb0[12].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mad r1.xyz, r0.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r1.w, r1.xyzx, r1.xyzx +rsq r1.w, r1.w +mul r1.xyz, r1.wwww, r1.xyzx +dp3 r1.w, v1.xyzx, v1.xyzx +rsq r1.w, r1.w +mul r2.xyz, r1.wwww, v1.xyzx +dp3 r1.x, r1.xyzx, r2.xyzx +mad r3.xyz, r0.xyzx, r0.wwww, -cb0[4].xyzx +mad r0.xyz, r0.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r3.xyzx, r3.xyzx +rsq r0.w, r0.w +mul r3.xyz, r0.wwww, r3.xyzx +dp3 r1.y, r3.xyzx, r2.xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r1.z, r0.xyzx, r2.xyzx +max r0.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +dp3 r1.x, -cb0[3].xyzx, r2.xyzx +dp3 r1.y, -cb0[4].xyzx, r2.xyzx +dp3 r1.z, -cb0[5].xyzx, r2.xyzx +ge r2.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r0.xyz, r0.xyzx, r2.xyzx +mul r1.xyz, r1.xyzx, r2.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r2.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r2.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul r0.xyz, r0.xyzx, cb0[2].xyzx +mul r0.xyz, r0.xyzx, v2.wwww +mul r2.xyz, r1.yyyy, cb0[7].xyzx +mad r1.xyw, r1.xxxx, cb0[6].xyxz, r2.xyxz +mad r1.xyz, r1.zzzz, cb0[8].xyzx, r1.xywx +mad r1.xyz, r1.xyzx, cb0[0].xyzx, cb0[1].xyzx +mad r0.xyz, v2.xyzx, r1.xyzx, r0.xyzx +mad r1.xyz, cb0[13].xyzx, v2.wwww, -r0.xyzx +mad o0.xyz, v0.wwww, r1.xyzx, r0.xyzx +mov o0.w, v2.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasicPixelLighting[] = +{ + 68, 88, 66, 67, 202, 236, + 241, 26, 240, 245, 195, 184, + 101, 180, 221, 101, 7, 84, + 110, 89, 1, 0, 0, 0, + 208, 9, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 72, 3, 0, 0, 52, 9, + 0, 0, 156, 9, 0, 0, + 65, 111, 110, 57, 16, 3, + 0, 0, 16, 3, 0, 0, + 0, 2, 255, 255, 224, 2, + 0, 0, 48, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 0, 0, + 0, 0, 0, 2, 255, 255, + 81, 0, 0, 5, 14, 0, + 15, 160, 0, 0, 128, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 1, 0, 7, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 2, 0, 15, 176, + 36, 0, 0, 2, 0, 0, + 7, 128, 1, 0, 228, 176, + 8, 0, 0, 3, 1, 0, + 1, 128, 3, 0, 228, 161, + 0, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 2, 128, + 4, 0, 228, 161, 0, 0, + 228, 128, 8, 0, 0, 3, + 1, 0, 4, 128, 5, 0, + 228, 161, 0, 0, 228, 128, + 88, 0, 0, 4, 2, 0, + 7, 128, 1, 0, 228, 128, + 14, 0, 0, 160, 14, 0, + 85, 160, 5, 0, 0, 3, + 1, 0, 7, 128, 1, 0, + 228, 128, 2, 0, 228, 128, + 2, 0, 0, 3, 3, 0, + 7, 128, 0, 0, 228, 177, + 12, 0, 228, 160, 8, 0, + 0, 3, 0, 0, 8, 128, + 3, 0, 228, 128, 3, 0, + 228, 128, 7, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 128, 4, 0, 0, 4, + 4, 0, 7, 128, 3, 0, + 228, 128, 0, 0, 255, 128, + 3, 0, 228, 161, 36, 0, + 0, 2, 5, 0, 7, 128, + 4, 0, 228, 128, 8, 0, + 0, 3, 4, 0, 1, 128, + 5, 0, 228, 128, 0, 0, + 228, 128, 4, 0, 0, 4, + 5, 0, 7, 128, 3, 0, + 228, 128, 0, 0, 255, 128, + 4, 0, 228, 161, 4, 0, + 0, 4, 3, 0, 7, 128, + 3, 0, 228, 128, 0, 0, + 255, 128, 5, 0, 228, 161, + 36, 0, 0, 2, 6, 0, + 7, 128, 3, 0, 228, 128, + 8, 0, 0, 3, 4, 0, + 4, 128, 6, 0, 228, 128, + 0, 0, 228, 128, 36, 0, + 0, 2, 3, 0, 7, 128, + 5, 0, 228, 128, 8, 0, + 0, 3, 4, 0, 2, 128, + 3, 0, 228, 128, 0, 0, + 228, 128, 5, 0, 0, 3, + 0, 0, 7, 128, 2, 0, + 228, 128, 4, 0, 228, 128, + 88, 0, 0, 4, 0, 0, + 7, 128, 4, 0, 228, 128, + 0, 0, 228, 128, 14, 0, + 85, 160, 15, 0, 0, 2, + 2, 0, 1, 128, 0, 0, + 0, 128, 15, 0, 0, 2, + 2, 0, 2, 128, 0, 0, + 85, 128, 15, 0, 0, 2, + 2, 0, 4, 128, 0, 0, + 170, 128, 5, 0, 0, 3, + 0, 0, 7, 128, 2, 0, + 228, 128, 2, 0, 255, 160, + 14, 0, 0, 2, 1, 0, + 8, 128, 0, 0, 85, 128, + 5, 0, 0, 3, 2, 0, + 7, 128, 1, 0, 255, 128, + 10, 0, 228, 160, 14, 0, + 0, 2, 1, 0, 8, 128, + 0, 0, 0, 128, 14, 0, + 0, 2, 2, 0, 8, 128, + 0, 0, 170, 128, 4, 0, + 0, 4, 0, 0, 7, 128, + 1, 0, 255, 128, 9, 0, + 228, 160, 2, 0, 228, 128, + 4, 0, 0, 4, 0, 0, + 7, 128, 2, 0, 255, 128, + 11, 0, 228, 160, 0, 0, + 228, 128, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 228, 160, + 5, 0, 0, 3, 0, 0, + 7, 128, 0, 0, 228, 128, + 2, 0, 255, 176, 5, 0, + 0, 3, 2, 0, 7, 128, + 1, 0, 85, 128, 7, 0, + 228, 160, 4, 0, 0, 4, + 2, 0, 7, 128, 1, 0, + 0, 128, 6, 0, 228, 160, + 2, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 7, 128, + 1, 0, 170, 128, 8, 0, + 228, 160, 2, 0, 228, 128, + 1, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 1, 0, + 7, 128, 1, 0, 228, 128, + 2, 0, 228, 128, 1, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 128, 2, 0, + 228, 176, 1, 0, 228, 128, + 0, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 7, 128, + 13, 0, 228, 160, 2, 0, + 255, 176, 0, 0, 228, 129, + 4, 0, 0, 4, 0, 0, + 7, 128, 0, 0, 255, 176, + 1, 0, 228, 128, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 128, 2, 0, + 255, 176, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 228, 5, + 0, 0, 64, 0, 0, 0, + 121, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 4, 0, 0, 0, 0, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 52, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 16, 0, 0, 9, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 16, 0, 0, 9, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 29, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 10, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 47, 0, + 0, 5, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 143, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 2, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 136, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 70, 8, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 70, 3, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 2, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 86, 5, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 50, 0, + 0, 10, 178, 0, 16, 0, + 1, 0, 0, 0, 6, 0, + 16, 0, 1, 0, 0, 0, + 70, 136, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 70, 8, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 1, 0, + 0, 0, 166, 10, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 70, 3, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 50, 0, 0, 9, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 246, 31, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 32, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 2, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 96, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 80, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 89, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 15, + 0, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicPixelLightingTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicPixelLightingTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..1b5233391d638b4e749224187d93d951e0dbb128 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicPixelLightingTx.inc @@ -0,0 +1,602 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xy 0 NONE float xy +// TEXCOORD 1 xyzw 1 NONE float xyzw +// TEXCOORD 2 xyz 2 NONE float xyz +// COLOR 0 xyzw 3 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 14 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c14, 1, 0, 0, 0 + dcl t0.xyz + dcl t1 + dcl t2.xyz + dcl t3 + dcl_2d s0 + texld r0, t0, s0 + nrm r1.xyz, t2 + dp3 r2.x, -c3, r1 + dp3 r2.y, -c4, r1 + dp3 r2.z, -c5, r1 + cmp r3.xyz, r2, c14.x, c14.y + mul r2.xyz, r2, r3 + add r4.xyz, -t1, c12 + dp3 r1.w, r4, r4 + rsq r1.w, r1.w + mad r5.xyz, r4, r1.w, -c3 + nrm r6.xyz, r5 + dp3 r5.x, r6, r1 + mad r6.xyz, r4, r1.w, -c4 + mad r4.xyz, r4, r1.w, -c5 + nrm r7.xyz, r4 + dp3 r5.z, r7, r1 + nrm r4.xyz, r6 + dp3 r5.y, r4, r1 + mul r1.xyz, r3, r5 + cmp r1.xyz, r5, r1, c14.y + log r3.x, r1.x + log r3.y, r1.y + log r3.z, r1.z + mul r1.xyz, r3, c2.w + exp r2.w, r1.y + mul r3.xyz, r2.w, c10 + exp r2.w, r1.x + exp r3.w, r1.z + mad r1.xyz, r2.w, c9, r3 + mad r1.xyz, r3.w, c11, r1 + mul r1.xyz, r1, c2 + mul r0, r0, t3 + mul r1.xyz, r0.w, r1 + mul r3.xyz, r2.y, c7 + mad r3.xyz, r2.x, c6, r3 + mad r2.xyz, r2.z, c8, r3 + mov r3.xyz, c0 + mad r2.xyz, r2, r3, c1 + mad r1.xyz, r0, r2, r1 + mad r2.xyz, c13, r0.w, -r1 + mad r0.xyz, t1.w, r2, r1 + mov oC0, r0 + +// approximately 51 instruction slots used (1 texture, 50 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[14], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xy +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xyz +dcl_input_ps linear v3.xyzw +dcl_output o0.xyzw +dcl_temps 4 +add r0.xyz, -v1.xyzx, cb0[12].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mad r1.xyz, r0.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r1.w, r1.xyzx, r1.xyzx +rsq r1.w, r1.w +mul r1.xyz, r1.wwww, r1.xyzx +dp3 r1.w, v2.xyzx, v2.xyzx +rsq r1.w, r1.w +mul r2.xyz, r1.wwww, v2.xyzx +dp3 r1.x, r1.xyzx, r2.xyzx +mad r3.xyz, r0.xyzx, r0.wwww, -cb0[4].xyzx +mad r0.xyz, r0.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r3.xyzx, r3.xyzx +rsq r0.w, r0.w +mul r3.xyz, r0.wwww, r3.xyzx +dp3 r1.y, r3.xyzx, r2.xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r1.z, r0.xyzx, r2.xyzx +max r0.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +dp3 r1.x, -cb0[3].xyzx, r2.xyzx +dp3 r1.y, -cb0[4].xyzx, r2.xyzx +dp3 r1.z, -cb0[5].xyzx, r2.xyzx +ge r2.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r0.xyz, r0.xyzx, r2.xyzx +mul r1.xyz, r1.xyzx, r2.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r2.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r2.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul r0.xyz, r0.xyzx, cb0[2].xyzx +sample r2.xyzw, v0.xyxx, t0.xyzw, s0 +mul r2.xyzw, r2.xyzw, v3.xyzw +mul r0.xyz, r0.xyzx, r2.wwww +mul r3.xyz, r1.yyyy, cb0[7].xyzx +mad r1.xyw, r1.xxxx, cb0[6].xyxz, r3.xyxz +mad r1.xyz, r1.zzzz, cb0[8].xyzx, r1.xywx +mad r1.xyz, r1.xyzx, cb0[0].xyzx, cb0[1].xyzx +mad r0.xyz, r2.xyzx, r1.xyzx, r0.xyzx +mad r1.xyz, cb0[13].xyzx, r2.wwww, -r0.xyzx +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +mov o0.w, r2.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasicPixelLightingTx[] = +{ + 68, 88, 66, 67, 129, 164, + 9, 179, 158, 143, 193, 218, + 75, 230, 209, 15, 16, 58, + 111, 78, 1, 0, 0, 0, + 128, 10, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 120, 3, 0, 0, 204, 9, + 0, 0, 76, 10, 0, 0, + 65, 111, 110, 57, 64, 3, + 0, 0, 64, 3, 0, 0, + 0, 2, 255, 255, 12, 3, + 0, 0, 52, 0, 0, 0, + 1, 0, 40, 0, 0, 0, + 52, 0, 0, 0, 52, 0, + 1, 0, 36, 0, 0, 0, + 52, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 81, 0, + 0, 5, 14, 0, 15, 160, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 3, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 176, 0, 8, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 176, 8, 0, 0, 3, + 2, 0, 1, 128, 3, 0, + 228, 161, 1, 0, 228, 128, + 8, 0, 0, 3, 2, 0, + 2, 128, 4, 0, 228, 161, + 1, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 4, 128, + 5, 0, 228, 161, 1, 0, + 228, 128, 88, 0, 0, 4, + 3, 0, 7, 128, 2, 0, + 228, 128, 14, 0, 0, 160, + 14, 0, 85, 160, 5, 0, + 0, 3, 2, 0, 7, 128, + 2, 0, 228, 128, 3, 0, + 228, 128, 2, 0, 0, 3, + 4, 0, 7, 128, 1, 0, + 228, 177, 12, 0, 228, 160, + 8, 0, 0, 3, 1, 0, + 8, 128, 4, 0, 228, 128, + 4, 0, 228, 128, 7, 0, + 0, 2, 1, 0, 8, 128, + 1, 0, 255, 128, 4, 0, + 0, 4, 5, 0, 7, 128, + 4, 0, 228, 128, 1, 0, + 255, 128, 3, 0, 228, 161, + 36, 0, 0, 2, 6, 0, + 7, 128, 5, 0, 228, 128, + 8, 0, 0, 3, 5, 0, + 1, 128, 6, 0, 228, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 6, 0, 7, 128, + 4, 0, 228, 128, 1, 0, + 255, 128, 4, 0, 228, 161, + 4, 0, 0, 4, 4, 0, + 7, 128, 4, 0, 228, 128, + 1, 0, 255, 128, 5, 0, + 228, 161, 36, 0, 0, 2, + 7, 0, 7, 128, 4, 0, + 228, 128, 8, 0, 0, 3, + 5, 0, 4, 128, 7, 0, + 228, 128, 1, 0, 228, 128, + 36, 0, 0, 2, 4, 0, + 7, 128, 6, 0, 228, 128, + 8, 0, 0, 3, 5, 0, + 2, 128, 4, 0, 228, 128, + 1, 0, 228, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 3, 0, 228, 128, 5, 0, + 228, 128, 88, 0, 0, 4, + 1, 0, 7, 128, 5, 0, + 228, 128, 1, 0, 228, 128, + 14, 0, 85, 160, 15, 0, + 0, 2, 3, 0, 1, 128, + 1, 0, 0, 128, 15, 0, + 0, 2, 3, 0, 2, 128, + 1, 0, 85, 128, 15, 0, + 0, 2, 3, 0, 4, 128, + 1, 0, 170, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 3, 0, 228, 128, 2, 0, + 255, 160, 14, 0, 0, 2, + 2, 0, 8, 128, 1, 0, + 85, 128, 5, 0, 0, 3, + 3, 0, 7, 128, 2, 0, + 255, 128, 10, 0, 228, 160, + 14, 0, 0, 2, 2, 0, + 8, 128, 1, 0, 0, 128, + 14, 0, 0, 2, 3, 0, + 8, 128, 1, 0, 170, 128, + 4, 0, 0, 4, 1, 0, + 7, 128, 2, 0, 255, 128, + 9, 0, 228, 160, 3, 0, + 228, 128, 4, 0, 0, 4, + 1, 0, 7, 128, 3, 0, + 255, 128, 11, 0, 228, 160, + 1, 0, 228, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 1, 0, 228, 128, 2, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 3, 0, 228, 176, + 5, 0, 0, 3, 1, 0, + 7, 128, 0, 0, 255, 128, + 1, 0, 228, 128, 5, 0, + 0, 3, 3, 0, 7, 128, + 2, 0, 85, 128, 7, 0, + 228, 160, 4, 0, 0, 4, + 3, 0, 7, 128, 2, 0, + 0, 128, 6, 0, 228, 160, + 3, 0, 228, 128, 4, 0, + 0, 4, 2, 0, 7, 128, + 2, 0, 170, 128, 8, 0, + 228, 160, 3, 0, 228, 128, + 1, 0, 0, 2, 3, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 2, 0, + 7, 128, 2, 0, 228, 128, + 3, 0, 228, 128, 1, 0, + 228, 160, 4, 0, 0, 4, + 1, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 228, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 2, 0, 7, 128, + 13, 0, 228, 160, 0, 0, + 255, 128, 1, 0, 228, 129, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 255, 176, + 2, 0, 228, 128, 1, 0, + 228, 128, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 76, 6, + 0, 0, 64, 0, 0, 0, + 147, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 0, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 114, 16, + 16, 0, 2, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 3, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 4, 0, + 0, 0, 0, 0, 0, 9, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 7, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 52, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 9, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 9, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 29, 0, + 0, 10, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 10, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 47, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 143, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 86, 5, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 50, 0, + 0, 10, 178, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 136, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 70, 8, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 166, 10, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 70, 3, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 2, 0, + 0, 0, 70, 16, 16, 0, + 0, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 242, 0, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 3, 0, 0, 0, 86, 5, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 7, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 1, 0, + 0, 0, 70, 136, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 70, 8, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 1, 0, 0, 0, 166, 10, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 70, 3, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 246, 15, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 50, 0, 0, 9, 114, 32, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 120, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 3, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 15, 0, 0, 104, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 7, 7, 0, 0, 113, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 15, 0, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 67, 79, 76, 79, 82, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..0c79037e00e8a3f7575ae44805681cf3bc5378e5 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicTx.inc @@ -0,0 +1,185 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float w +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 13 1 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl_2d s0 + texld r0, t2, s0 + mul r0, r0, t0 + mad r1.xyz, c0, r0.w, -r0 + mad r0.xyz, t1.w, r1, r0 + mov oC0, r0 + +// approximately 5 instruction slots used (1 texture, 4 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[14], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.w +dcl_input_ps linear v2.xy +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul r0.xyzw, r0.xyzw, v0.xyzw +mad r1.xyz, cb0[13].xyzx, r0.wwww, -r0.xyzx +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +mov o0.w, r0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasicTx[] = +{ + 68, 88, 66, 67, 155, 204, + 24, 105, 141, 75, 77, 28, + 70, 59, 49, 201, 3, 51, + 69, 45, 1, 0, 0, 0, + 176, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 248, 0, 0, 0, 20, 2, + 0, 0, 124, 2, 0, 0, + 65, 111, 110, 57, 192, 0, + 0, 0, 192, 0, 0, 0, + 0, 2, 255, 255, 140, 0, + 0, 0, 52, 0, 0, 0, + 1, 0, 40, 0, 0, 0, + 52, 0, 0, 0, 52, 0, + 1, 0, 36, 0, 0, 0, + 52, 0, 0, 0, 0, 0, + 0, 0, 13, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 4, 0, 0, 4, 1, 0, + 7, 128, 0, 0, 228, 160, + 0, 0, 255, 128, 0, 0, + 228, 129, 4, 0, 0, 4, + 0, 0, 7, 128, 1, 0, + 255, 176, 1, 0, 228, 128, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 8, 15, 128, + 0, 0, 228, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 20, 1, 0, 0, 64, 0, + 0, 0, 69, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 98, 16, 0, 3, + 130, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 2, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 32, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 96, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 80, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 8, + 0, 0, 86, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicTxNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicTxNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..59bc50eb72e555a512cf1e7f705c227ea104bf7e --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicTxNoFog.inc @@ -0,0 +1,133 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1.xy + dcl_2d s0 + texld r0, t1, s0 + mul r0, r0, t0 + mov oC0, r0 + +// approximately 3 instruction slots used (1 texture, 2 arithmetic) +ps_4_0 +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xy +dcl_output o0.xyzw +dcl_temps 1 +sample r0.xyzw, v1.xyxx, t0.xyzw, s0 +mul o0.xyzw, r0.xyzw, v0.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasicTxNoFog[] = +{ + 68, 88, 66, 67, 194, 95, + 105, 234, 141, 247, 73, 209, + 137, 241, 142, 29, 26, 223, + 234, 193, 1, 0, 0, 0, + 216, 1, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 184, 0, 0, 0, 84, 1, + 0, 0, 164, 1, 0, 0, + 65, 111, 110, 57, 128, 0, + 0, 0, 128, 0, 0, 0, + 0, 2, 255, 255, 88, 0, + 0, 0, 40, 0, 0, 0, + 0, 0, 40, 0, 0, 0, + 40, 0, 0, 0, 40, 0, + 1, 0, 36, 0, 0, 0, + 40, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 0, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 148, 0, 0, 0, + 64, 0, 0, 0, 37, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 72, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 62, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLighting.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLighting.inc new file mode 100644 index 0000000000000000000000000000000000000000..e88bfff2b81a7652276f8b97075e499c4fd31a24 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLighting.inc @@ -0,0 +1,153 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 13 1 ( FLT, FLT, FLT, FLT) +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + mov r0, t0 + mad r0.xyz, t1, r0.w, r0 + mad r1.xyz, c0, t0.w, -r0 + mad r0.xyz, t1.w, r1, r0 + mov r0.w, t0.w + mov oC0, r0 + +// approximately 6 instruction slots used +ps_4_0 +dcl_constantbuffer CB0[14], immediateIndexed +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyzw +dcl_output o0.xyzw +dcl_temps 2 +mad r0.xyz, v1.xyzx, v0.wwww, v0.xyzx +mad r1.xyz, cb0[13].xyzx, v0.wwww, -r0.xyzx +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +mov o0.w, v0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasicVertexLighting[] = +{ + 68, 88, 66, 67, 1, 0, + 211, 175, 137, 211, 98, 125, + 71, 150, 248, 71, 185, 240, + 6, 94, 1, 0, 0, 0, + 60, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 232, 0, 0, 0, 192, 1, + 0, 0, 8, 2, 0, 0, + 65, 111, 110, 57, 176, 0, + 0, 0, 176, 0, 0, 0, + 0, 2, 255, 255, 128, 0, + 0, 0, 48, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 13, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 2, 255, 255, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 1, 0, 15, 176, + 1, 0, 0, 2, 0, 0, + 15, 128, 0, 0, 228, 176, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 228, 176, + 0, 0, 255, 128, 0, 0, + 228, 128, 4, 0, 0, 4, + 1, 0, 7, 128, 0, 0, + 228, 160, 0, 0, 255, 176, + 0, 0, 228, 129, 4, 0, + 0, 4, 0, 0, 7, 128, + 1, 0, 255, 176, 1, 0, + 228, 128, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 128, 0, 0, 255, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 0, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 208, 0, 0, 0, + 64, 0, 0, 0, 52, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 2, 0, + 0, 0, 50, 0, 0, 9, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 246, 31, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 246, 31, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 32, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 64, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 56, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 15, + 0, 0, 67, 79, 76, 79, + 82, 0, 171, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLightingNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLightingNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..b5339fe89e1468f7d85249595b222933964c31ad --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLightingNoFog.inc @@ -0,0 +1,114 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + mov r0, t0 + mad r0.xyz, t1, r0.w, r0 + mov r0.w, t0.w + mov oC0, r0 + +// approximately 4 instruction slots used +ps_4_0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyz +dcl_output o0.xyzw +mad o0.xyz, v1.xyzx, v0.wwww, v0.xyzx +mov o0.w, v0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasicVertexLightingNoFog[] = +{ + 68, 88, 66, 67, 196, 161, + 90, 12, 111, 37, 237, 2, + 236, 93, 13, 113, 105, 60, + 150, 154, 1, 0, 0, 0, + 160, 1, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 180, 0, 0, 0, 36, 1, + 0, 0, 108, 1, 0, 0, + 65, 111, 110, 57, 124, 0, + 0, 0, 124, 0, 0, 0, + 0, 2, 255, 255, 88, 0, + 0, 0, 36, 0, 0, 0, + 0, 0, 36, 0, 0, 0, + 36, 0, 0, 0, 36, 0, + 0, 0, 36, 0, 0, 0, + 36, 0, 0, 2, 255, 255, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 1, 0, 15, 176, + 1, 0, 0, 2, 0, 0, + 15, 128, 0, 0, 228, 176, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 228, 176, + 0, 0, 255, 128, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 176, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 104, 0, + 0, 0, 64, 0, 0, 0, + 26, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 246, 31, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 64, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 56, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 7, + 0, 0, 67, 79, 76, 79, + 82, 0, 171, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLightingTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLightingTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..0997605b70b324465b03250f82fc3c96fc8dd3cf --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLightingTx.inc @@ -0,0 +1,196 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 13 1 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl_2d s0 + texld r0, t2, s0 + mul r0, r0, t0 + mad r1.xyz, t1, r0.w, r0 + mad r2.xyz, c0, r0.w, -r1 + mad r0.xyz, t1.w, r2, r1 + mov oC0, r0 + +// approximately 6 instruction slots used (1 texture, 5 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[14], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul r0.xyzw, r0.xyzw, v0.xyzw +mad r0.xyz, v1.xyzx, r0.wwww, r0.xyzx +mad r1.xyz, cb0[13].xyzx, r0.wwww, -r0.xyzx +mov o0.w, r0.w +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasicVertexLightingTx[] = +{ + 68, 88, 66, 67, 168, 121, + 145, 162, 145, 142, 85, 167, + 84, 43, 205, 136, 70, 33, + 64, 152, 1, 0, 0, 0, + 232, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 12, 1, 0, 0, 76, 2, + 0, 0, 180, 2, 0, 0, + 65, 111, 110, 57, 212, 0, + 0, 0, 212, 0, 0, 0, + 0, 2, 255, 255, 160, 0, + 0, 0, 52, 0, 0, 0, + 1, 0, 40, 0, 0, 0, + 52, 0, 0, 0, 52, 0, + 1, 0, 36, 0, 0, 0, + 52, 0, 0, 0, 0, 0, + 0, 0, 13, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 4, 0, 0, 4, 1, 0, + 7, 128, 1, 0, 228, 176, + 0, 0, 255, 128, 0, 0, + 228, 128, 4, 0, 0, 4, + 2, 0, 7, 128, 0, 0, + 228, 160, 0, 0, 255, 128, + 1, 0, 228, 129, 4, 0, + 0, 4, 0, 0, 7, 128, + 1, 0, 255, 176, 2, 0, + 228, 128, 1, 0, 228, 128, + 1, 0, 0, 2, 0, 8, + 15, 128, 0, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 56, 1, 0, 0, + 64, 0, 0, 0, 78, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 2, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 114, 32, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 96, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 80, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 15, 0, 0, 86, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLightingTxNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLightingTxNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..cd891a2c782209032b34b12b9a8d4dc2addb12b4 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_PSBasicVertexLightingTxNoFog.inc @@ -0,0 +1,160 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl_2d s0 + texld r0, t2, s0 + mul r0, r0, t0 + mad r0.xyz, t1, r0.w, r0 + mov oC0, r0 + +// approximately 4 instruction slots used (1 texture, 3 arithmetic) +ps_4_0 +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyz +dcl_input_ps linear v2.xy +dcl_output o0.xyzw +dcl_temps 1 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul r0.xyzw, r0.xyzw, v0.xyzw +mad o0.xyz, v1.xyzx, r0.wwww, r0.xyzx +mov o0.w, r0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_PSBasicVertexLightingTxNoFog[] = +{ + 68, 88, 66, 67, 107, 144, + 128, 78, 118, 75, 88, 150, + 203, 179, 206, 252, 188, 119, + 149, 100, 1, 0, 0, 0, + 84, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 216, 0, 0, 0, 184, 1, + 0, 0, 32, 2, 0, 0, + 65, 111, 110, 57, 160, 0, + 0, 0, 160, 0, 0, 0, + 0, 2, 255, 255, 120, 0, + 0, 0, 40, 0, 0, 0, + 0, 0, 40, 0, 0, 0, + 40, 0, 0, 0, 40, 0, + 1, 0, 36, 0, 0, 0, + 40, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 228, 176, + 0, 0, 255, 128, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 216, 0, + 0, 0, 64, 0, 0, 0, + 54, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 96, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 80, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 7, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasic.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasic.inc new file mode 100644 index 0000000000000000000000000000000000000000..87ab32fb2f2b50b1d420508f0a3445574ddfb890 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasic.inc @@ -0,0 +1,210 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 14 1 ( FLT, FLT, FLT, FLT) +// c3 cb0 22 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c7, 0, 1, 0, 0 + dcl_texcoord v0 + dp4 oPos.z, v0, c5 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c7.x + min oT1.w, r0.x, c7.y + dp4 r0.x, v0, c3 + dp4 r0.y, v0, c4 + dp4 r0.z, v0, c6 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0, c1 + mov oT1.xyz, c7.x + +// approximately 11 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output_siv o2.xyzw, position +mov o0.xyzw, cb0[0].xyzw +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +mov o1.xyz, l(0,0,0,0) +dp4 o2.x, v0.xyzw, cb0[22].xyzw +dp4 o2.y, v0.xyzw, cb0[23].xyzw +dp4 o2.z, v0.xyzw, cb0[24].xyzw +dp4 o2.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasic[] = +{ + 68, 88, 66, 67, 188, 140, + 74, 180, 173, 123, 123, 133, + 113, 248, 140, 69, 65, 196, + 202, 186, 1, 0, 0, 0, + 40, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 88, 1, 0, 0, 136, 2, + 0, 0, 188, 2, 0, 0, + 65, 111, 110, 57, 32, 1, + 0, 0, 32, 1, 0, 0, + 0, 2, 254, 255, 212, 0, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 1, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 22, 0, + 4, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 7, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 5, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 7, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 7, 0, + 85, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 3, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 4, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 6, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 1, 0, 228, 160, 1, 0, + 0, 2, 1, 0, 7, 224, + 7, 0, 0, 160, 255, 255, + 0, 0, 83, 72, 68, 82, + 40, 1, 0, 0, 64, 0, + 1, 0, 74, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 54, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 79, 83, + 71, 78, 100, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 80, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 86, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 67, 79, 76, 79, + 82, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..cc8551320a8a610ca0ca9fa49f1676973affdc77 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicNoFog.inc @@ -0,0 +1,167 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// SV_Position 0 xyzw 1 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 22 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dp4 oPos.z, v0, c4 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c5 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0, c1 + +// approximately 7 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_output o0.xyzw +dcl_output_siv o1.xyzw, position +mov o0.xyzw, cb0[0].xyzw +dp4 o1.x, v0.xyzw, cb0[22].xyzw +dp4 o1.y, v0.xyzw, cb0[23].xyzw +dp4 o1.z, v0.xyzw, cb0[24].xyzw +dp4 o1.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicNoFog[] = +{ + 68, 88, 66, 67, 20, 3, + 221, 125, 108, 131, 107, 138, + 40, 72, 25, 121, 1, 41, + 145, 196, 1, 0, 0, 0, + 100, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 248, 0, 0, 0, 220, 1, + 0, 0, 16, 2, 0, 0, + 65, 111, 110, 57, 192, 0, + 0, 0, 192, 0, 0, 0, + 0, 2, 254, 255, 128, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 22, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 4, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 5, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 1, 0, 228, 160, 255, 255, + 0, 0, 83, 72, 68, 82, + 220, 0, 0, 0, 64, 0, + 1, 0, 55, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 79, 83, 71, 78, 76, 0, + 0, 0, 2, 0, 0, 0, + 8, 0, 0, 0, 56, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 62, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLight.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLight.inc new file mode 100644 index 0000000000000000000000000000000000000000..bd3a7a1f59c5a29886afdd019178296943b34d3d --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLight.inc @@ -0,0 +1,485 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 4 ( FLT, FLT, FLT, FLT) +// c5 cb0 6 1 ( FLT, FLT, FLT, FLT) +// c6 cb0 9 1 ( FLT, FLT, FLT, FLT) +// c7 cb0 12 1 ( FLT, FLT, FLT, FLT) +// c8 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c12 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c19, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dp3 r0.x, v1, c12 + dp3 r0.y, v1, c13 + dp3 r0.z, v1, c14 + nrm r1.xyz, r0 + dp3 r0.x, -c4, r1 + sge r0.y, r0.x, c19.x + mul r0.x, r0.x, r0.y + mul r0.xzw, r0.x, c5.xyyz + mov r2.xyz, c1 + mad oT0.xyz, r0.xzww, r2, c2 + dp4 r2.x, v0, c9 + dp4 r2.y, v0, c10 + dp4 r2.z, v0, c11 + add r0.xzw, -r2.xyyz, c7.xyyz + nrm r2.xyz, r0.xzww + add r0.xzw, r2.xyyz, -c4.xyyz + nrm r2.xyz, r0.xzww + dp3 r0.x, r2, r1 + max r0.x, r0.x, c19.x + mul r0.x, r0.y, r0.x + pow r1.x, r0.x, c3.w + mul r0.xyz, r1.x, c6 + mul oT1.xyz, r0, c3 + dp4 oPos.z, v0, c17 + dp4 r0.x, v0, c8 + max r0.x, r0.x, c19.x + min oT1.w, r0.x, c19.y + dp4 r0.x, v0, c15 + dp4 r0.y, v0, c16 + dp4 r0.z, v0, c18 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.w, c1.w + +// approximately 41 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output_siv o2.xyzw, position +dcl_temps 3 +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r0.w, -cb0[3].xyzx, r0.xyzx +ge r1.x, r0.w, l(0.000000) +and r1.x, r1.x, l(0x3f800000) +mul r0.w, r0.w, r1.x +mul r1.yzw, r0.wwww, cb0[6].xxyz +mad o0.xyz, r1.yzwy, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +dp4 r2.x, v0.xyzw, cb0[15].xyzw +dp4 r2.y, v0.xyzw, cb0[16].xyzw +dp4 r2.z, v0.xyzw, cb0[17].xyzw +add r1.yzw, -r2.xxyz, cb0[12].xxyz +dp3 r0.w, r1.yzwy, r1.yzwy +rsq r0.w, r0.w +mad r1.yzw, r1.yyzw, r0.wwww, -cb0[3].xxyz +dp3 r0.w, r1.yzwy, r1.yzwy +rsq r0.w, r0.w +mul r1.yzw, r0.wwww, r1.yyzw +dp3 r0.x, r1.yzwy, r0.xyzx +max r0.x, r0.x, l(0.000000) +mul r0.x, r1.x, r0.x +log r0.x, r0.x +mul r0.x, r0.x, cb0[2].w +exp r0.x, r0.x +mul r0.xyz, r0.xxxx, cb0[9].xyzx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +dp4 o2.x, v0.xyzw, cb0[22].xyzw +dp4 o2.y, v0.xyzw, cb0[23].xyzw +dp4 o2.z, v0.xyzw, cb0[24].xyzw +dp4 o2.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicOneLight[] = +{ + 68, 88, 66, 67, 84, 60, + 17, 149, 27, 169, 41, 235, + 61, 168, 242, 18, 208, 232, + 50, 117, 1, 0, 0, 0, + 60, 8, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 224, 2, 0, 0, 124, 7, + 0, 0, 208, 7, 0, 0, + 65, 111, 110, 57, 168, 2, + 0, 0, 168, 2, 0, 0, + 0, 2, 254, 255, 56, 2, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 0, 0, 0, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 1, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 9, 0, + 1, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 1, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 8, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 19, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 8, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 228, 144, 12, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 13, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 4, 128, 1, 0, 228, 144, + 14, 0, 228, 160, 36, 0, + 0, 2, 1, 0, 7, 128, + 0, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 1, 128, + 4, 0, 228, 161, 1, 0, + 228, 128, 13, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 0, 128, 19, 0, 0, 160, + 5, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 0, 0, 85, 128, 5, 0, + 0, 3, 0, 0, 13, 128, + 0, 0, 0, 128, 5, 0, + 148, 160, 1, 0, 0, 2, + 2, 0, 7, 128, 1, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 224, 0, 0, + 248, 128, 2, 0, 228, 128, + 2, 0, 228, 160, 9, 0, + 0, 3, 2, 0, 1, 128, + 0, 0, 228, 144, 9, 0, + 228, 160, 9, 0, 0, 3, + 2, 0, 2, 128, 0, 0, + 228, 144, 10, 0, 228, 160, + 9, 0, 0, 3, 2, 0, + 4, 128, 0, 0, 228, 144, + 11, 0, 228, 160, 2, 0, + 0, 3, 0, 0, 13, 128, + 2, 0, 148, 129, 7, 0, + 148, 160, 36, 0, 0, 2, + 2, 0, 7, 128, 0, 0, + 248, 128, 2, 0, 0, 3, + 0, 0, 13, 128, 2, 0, + 148, 128, 4, 0, 148, 161, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 248, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 128, + 1, 0, 228, 128, 11, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 0, 128, 19, 0, + 0, 160, 5, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 85, 128, 0, 0, 0, 128, + 32, 0, 0, 3, 1, 0, + 1, 128, 0, 0, 0, 128, + 3, 0, 255, 160, 5, 0, + 0, 3, 0, 0, 7, 128, + 1, 0, 0, 128, 6, 0, + 228, 160, 5, 0, 0, 3, + 1, 0, 7, 224, 0, 0, + 228, 128, 3, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 192, 0, 0, 228, 144, + 17, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 8, 0, + 228, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 19, 0, 0, 160, + 10, 0, 0, 3, 1, 0, + 8, 224, 0, 0, 0, 128, + 19, 0, 85, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 15, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 16, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 18, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 170, 128, 0, 0, + 228, 160, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 170, 128, + 1, 0, 0, 2, 0, 0, + 8, 224, 1, 0, 255, 160, + 255, 255, 0, 0, 83, 72, + 68, 82, 148, 4, 0, 0, + 64, 0, 1, 0, 37, 1, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 26, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 3, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 19, 0, + 0, 0, 16, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 16, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 21, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 29, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 226, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 50, 0, 0, 11, 114, 32, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 9, + 226, 0, 16, 0, 1, 0, + 0, 0, 6, 9, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 6, 137, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 1, 0, 0, 0, 150, 7, + 16, 0, 1, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 226, 0, 16, 0, 1, 0, + 0, 0, 86, 14, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 1, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 226, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 86, 14, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 52, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 47, 0, 0, 5, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 56, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 17, 32, 0, 8, 130, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 76, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 171, 79, 83, 71, 78, + 100, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 80, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLightTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLightTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..33bda7922d56aeee84a2fe1dbd331483583016d1 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLightTx.inc @@ -0,0 +1,514 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 4 ( FLT, FLT, FLT, FLT) +// c5 cb0 6 1 ( FLT, FLT, FLT, FLT) +// c6 cb0 9 1 ( FLT, FLT, FLT, FLT) +// c7 cb0 12 1 ( FLT, FLT, FLT, FLT) +// c8 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c12 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c19, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp3 r0.x, v1, c12 + dp3 r0.y, v1, c13 + dp3 r0.z, v1, c14 + nrm r1.xyz, r0 + dp3 r0.x, -c4, r1 + sge r0.y, r0.x, c19.x + mul r0.x, r0.x, r0.y + mul r0.xzw, r0.x, c5.xyyz + mov r2.xyz, c1 + mad oT0.xyz, r0.xzww, r2, c2 + dp4 r2.x, v0, c9 + dp4 r2.y, v0, c10 + dp4 r2.z, v0, c11 + add r0.xzw, -r2.xyyz, c7.xyyz + nrm r2.xyz, r0.xzww + add r0.xzw, r2.xyyz, -c4.xyyz + nrm r2.xyz, r0.xzww + dp3 r0.x, r2, r1 + max r0.x, r0.x, c19.x + mul r0.x, r0.y, r0.x + pow r1.x, r0.x, c3.w + mul r0.xyz, r1.x, c6 + mul oT1.xyz, r0, c3 + dp4 oPos.z, v0, c17 + dp4 r0.x, v0, c8 + max r0.x, r0.x, c19.x + min oT1.w, r0.x, c19.y + dp4 r0.x, v0, c15 + dp4 r0.y, v0, c16 + dp4 r0.z, v0, c18 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.w, c1.w + mov oT2.xy, v2 + +// approximately 42 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 3 +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r0.w, -cb0[3].xyzx, r0.xyzx +ge r1.x, r0.w, l(0.000000) +and r1.x, r1.x, l(0x3f800000) +mul r0.w, r0.w, r1.x +mul r1.yzw, r0.wwww, cb0[6].xxyz +mad o0.xyz, r1.yzwy, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +dp4 r2.x, v0.xyzw, cb0[15].xyzw +dp4 r2.y, v0.xyzw, cb0[16].xyzw +dp4 r2.z, v0.xyzw, cb0[17].xyzw +add r1.yzw, -r2.xxyz, cb0[12].xxyz +dp3 r0.w, r1.yzwy, r1.yzwy +rsq r0.w, r0.w +mad r1.yzw, r1.yyzw, r0.wwww, -cb0[3].xxyz +dp3 r0.w, r1.yzwy, r1.yzwy +rsq r0.w, r0.w +mul r1.yzw, r0.wwww, r1.yyzw +dp3 r0.x, r1.yzwy, r0.xyzx +max r0.x, r0.x, l(0.000000) +mul r0.x, r1.x, r0.x +log r0.x, r0.x +mul r0.x, r0.x, cb0[2].w +exp r0.x, r0.x +mul r0.xyz, r0.xxxx, cb0[9].xyzx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, v0.xyzw, cb0[22].xyzw +dp4 o3.y, v0.xyzw, cb0[23].xyzw +dp4 o3.z, v0.xyzw, cb0[24].xyzw +dp4 o3.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicOneLightTx[] = +{ + 68, 88, 66, 67, 151, 18, + 223, 247, 234, 221, 97, 109, + 91, 72, 11, 181, 222, 38, + 149, 27, 1, 0, 0, 0, + 192, 8, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 248, 2, 0, 0, 192, 7, + 0, 0, 52, 8, 0, 0, + 65, 111, 110, 57, 192, 2, + 0, 0, 192, 2, 0, 0, + 0, 2, 254, 255, 80, 2, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 0, 0, 0, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 1, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 9, 0, + 1, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 1, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 8, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 19, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 8, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 228, 144, 12, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 13, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 4, 128, 1, 0, 228, 144, + 14, 0, 228, 160, 36, 0, + 0, 2, 1, 0, 7, 128, + 0, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 1, 128, + 4, 0, 228, 161, 1, 0, + 228, 128, 13, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 0, 128, 19, 0, 0, 160, + 5, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 0, 0, 85, 128, 5, 0, + 0, 3, 0, 0, 13, 128, + 0, 0, 0, 128, 5, 0, + 148, 160, 1, 0, 0, 2, + 2, 0, 7, 128, 1, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 224, 0, 0, + 248, 128, 2, 0, 228, 128, + 2, 0, 228, 160, 9, 0, + 0, 3, 2, 0, 1, 128, + 0, 0, 228, 144, 9, 0, + 228, 160, 9, 0, 0, 3, + 2, 0, 2, 128, 0, 0, + 228, 144, 10, 0, 228, 160, + 9, 0, 0, 3, 2, 0, + 4, 128, 0, 0, 228, 144, + 11, 0, 228, 160, 2, 0, + 0, 3, 0, 0, 13, 128, + 2, 0, 148, 129, 7, 0, + 148, 160, 36, 0, 0, 2, + 2, 0, 7, 128, 0, 0, + 248, 128, 2, 0, 0, 3, + 0, 0, 13, 128, 2, 0, + 148, 128, 4, 0, 148, 161, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 248, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 128, + 1, 0, 228, 128, 11, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 0, 128, 19, 0, + 0, 160, 5, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 85, 128, 0, 0, 0, 128, + 32, 0, 0, 3, 1, 0, + 1, 128, 0, 0, 0, 128, + 3, 0, 255, 160, 5, 0, + 0, 3, 0, 0, 7, 128, + 1, 0, 0, 128, 6, 0, + 228, 160, 5, 0, 0, 3, + 1, 0, 7, 224, 0, 0, + 228, 128, 3, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 192, 0, 0, 228, 144, + 17, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 8, 0, + 228, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 19, 0, 0, 160, + 10, 0, 0, 3, 1, 0, + 8, 224, 0, 0, 0, 128, + 19, 0, 85, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 15, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 16, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 18, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 170, 128, 0, 0, + 228, 160, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 170, 128, + 1, 0, 0, 2, 0, 0, + 8, 224, 1, 0, 255, 160, + 1, 0, 0, 2, 2, 0, + 3, 224, 2, 0, 228, 144, + 255, 255, 0, 0, 83, 72, + 68, 82, 192, 4, 0, 0, + 64, 0, 1, 0, 48, 1, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 26, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 2, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 3, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 19, 0, + 0, 0, 16, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 16, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 21, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 29, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 226, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 50, 0, 0, 11, 114, 32, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 9, + 226, 0, 16, 0, 1, 0, + 0, 0, 6, 9, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 6, 137, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 1, 0, 0, 0, 150, 7, + 16, 0, 1, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 226, 0, 16, 0, 1, 0, + 0, 0, 86, 14, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 1, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 226, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 86, 14, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 52, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 47, 0, 0, 5, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 56, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 17, 32, 0, 8, 130, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 2, 0, + 0, 0, 70, 16, 16, 0, + 2, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 25, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 108, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 92, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 99, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 78, 79, 82, 77, + 65, 76, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 79, 83, 71, 78, 132, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 110, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 119, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLightTxVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLightTxVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..59f0ffd808f740d0d00ed2555a89be68634ef2e1 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLightTxVc.inc @@ -0,0 +1,534 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// COLOR 0 xyzw 3 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 4 ( FLT, FLT, FLT, FLT) +// c5 cb0 6 1 ( FLT, FLT, FLT, FLT) +// c6 cb0 9 1 ( FLT, FLT, FLT, FLT) +// c7 cb0 12 1 ( FLT, FLT, FLT, FLT) +// c8 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c12 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c19, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dp4 r0.x, v0, c9 + dp4 r0.y, v0, c10 + dp4 r0.z, v0, c11 + add r0.xyz, -r0, c7 + nrm r1.xyz, r0 + add r0.xyz, r1, -c4 + nrm r1.xyz, r0 + dp3 r0.x, v1, c12 + dp3 r0.y, v1, c13 + dp3 r0.z, v1, c14 + nrm r2.xyz, r0 + dp3 r0.x, r1, r2 + dp3 r0.y, -c4, r2 + max r0.x, r0.x, c19.x + sge r0.z, r0.y, c19.x + mul r0.xy, r0.zyzw, r0.xzzw + pow r1.x, r0.x, c3.w + mul r0.xzw, r1.x, c6.xyyz + mul oT1.xyz, r0.xzww, c3 + mul r0.xyz, r0.y, c5 + mov r1.xyz, c1 + mad r0.xyz, r0, r1, c2 + mul oT0.xyz, r0, v3 + dp4 oPos.z, v0, c17 + dp4 r0.x, v0, c8 + max r0.x, r0.x, c19.x + min oT1.w, r0.x, c19.y + mul oT0.w, v3.w, c1.w + dp4 r0.x, v0, c15 + dp4 r0.y, v0, c16 + dp4 r0.z, v0, c18 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT2.xy, v2 + +// approximately 42 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 3 +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r0.w, -cb0[3].xyzx, r0.xyzx +ge r1.x, r0.w, l(0.000000) +and r1.x, r1.x, l(0x3f800000) +mul r0.w, r0.w, r1.x +mul r1.yzw, r0.wwww, cb0[6].xxyz +mad r1.yzw, r1.yyzw, cb0[0].xxyz, cb0[1].xxyz +mul o0.xyz, r1.yzwy, v3.xyzx +mul o0.w, v3.w, cb0[0].w +dp4 r2.x, v0.xyzw, cb0[15].xyzw +dp4 r2.y, v0.xyzw, cb0[16].xyzw +dp4 r2.z, v0.xyzw, cb0[17].xyzw +add r1.yzw, -r2.xxyz, cb0[12].xxyz +dp3 r0.w, r1.yzwy, r1.yzwy +rsq r0.w, r0.w +mad r1.yzw, r1.yyzw, r0.wwww, -cb0[3].xxyz +dp3 r0.w, r1.yzwy, r1.yzwy +rsq r0.w, r0.w +mul r1.yzw, r0.wwww, r1.yyzw +dp3 r0.x, r1.yzwy, r0.xyzx +max r0.x, r0.x, l(0.000000) +mul r0.x, r1.x, r0.x +log r0.x, r0.x +mul r0.x, r0.x, cb0[2].w +exp r0.x, r0.x +mul r0.xyz, r0.xxxx, cb0[9].xyzx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, v0.xyzw, cb0[22].xyzw +dp4 o3.y, v0.xyzw, cb0[23].xyzw +dp4 o3.z, v0.xyzw, cb0[24].xyzw +dp4 o3.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicOneLightTxVc[] = +{ + 68, 88, 66, 67, 165, 177, + 219, 69, 28, 96, 206, 195, + 78, 39, 168, 253, 196, 43, + 71, 185, 1, 0, 0, 0, + 32, 9, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 8, 3, 0, 0, 0, 8, + 0, 0, 148, 8, 0, 0, + 65, 111, 110, 57, 208, 2, + 0, 0, 208, 2, 0, 0, + 0, 2, 254, 255, 96, 2, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 0, 0, 0, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 1, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 9, 0, + 1, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 1, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 8, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 19, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 9, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 10, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 11, 0, 228, 160, 2, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 228, 129, 7, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 0, 3, + 0, 0, 7, 128, 1, 0, + 228, 128, 4, 0, 228, 161, + 36, 0, 0, 2, 1, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 12, 0, 228, 160, 8, 0, + 0, 3, 0, 0, 2, 128, + 1, 0, 228, 144, 13, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 4, 128, 1, 0, + 228, 144, 14, 0, 228, 160, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 128, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 2, 128, + 4, 0, 228, 161, 2, 0, + 228, 128, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 19, 0, 0, 160, + 13, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 85, 128, + 19, 0, 0, 160, 5, 0, + 0, 3, 0, 0, 3, 128, + 0, 0, 230, 128, 0, 0, + 232, 128, 32, 0, 0, 3, + 1, 0, 1, 128, 0, 0, + 0, 128, 3, 0, 255, 160, + 5, 0, 0, 3, 0, 0, + 13, 128, 1, 0, 0, 128, + 6, 0, 148, 160, 5, 0, + 0, 3, 1, 0, 7, 224, + 0, 0, 248, 128, 3, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 85, 128, 5, 0, 228, 160, + 1, 0, 0, 2, 1, 0, + 7, 128, 1, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 128, 0, 0, 228, 128, + 1, 0, 228, 128, 2, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 7, 224, 0, 0, + 228, 128, 3, 0, 228, 144, + 9, 0, 0, 3, 0, 0, + 4, 192, 0, 0, 228, 144, + 17, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 8, 0, + 228, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 19, 0, 0, 160, + 10, 0, 0, 3, 1, 0, + 8, 224, 0, 0, 0, 128, + 19, 0, 85, 160, 5, 0, + 0, 3, 0, 0, 8, 224, + 3, 0, 255, 144, 1, 0, + 255, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 15, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 16, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 18, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 2, 0, 3, 224, + 2, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 240, 4, 0, 0, 64, 0, + 1, 0, 60, 1, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 3, 0, 0, 0, 16, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 19, 0, 0, 0, + 16, 0, 0, 8, 34, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 20, 0, + 0, 0, 16, 0, 0, 8, + 66, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 9, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 29, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 8, + 226, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 50, 0, + 0, 11, 226, 0, 16, 0, + 1, 0, 0, 0, 86, 14, + 16, 0, 1, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 114, 32, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 8, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 3, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 0, 0, 0, 9, 226, 0, + 16, 0, 1, 0, 0, 0, + 6, 9, 16, 128, 65, 0, + 0, 0, 2, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 12, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 150, 7, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 226, 0, + 16, 0, 1, 0, 0, 0, + 86, 14, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 6, 137, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 1, 0, 0, 0, 150, 7, + 16, 0, 1, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 226, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 86, 14, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 52, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 47, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 58, 128, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 25, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 56, 0, 0, 8, + 114, 32, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 140, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 116, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 123, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 132, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 67, 79, + 76, 79, 82, 0, 171, 171, + 79, 83, 71, 78, 132, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 110, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 119, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLightVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLightVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..e43ec69b6c5ac21741b2f8c14216a9d32dca90f3 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicOneLightVc.inc @@ -0,0 +1,505 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// COLOR 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 4 ( FLT, FLT, FLT, FLT) +// c5 cb0 6 1 ( FLT, FLT, FLT, FLT) +// c6 cb0 9 1 ( FLT, FLT, FLT, FLT) +// c7 cb0 12 1 ( FLT, FLT, FLT, FLT) +// c8 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c12 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c19, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 r0.x, v0, c9 + dp4 r0.y, v0, c10 + dp4 r0.z, v0, c11 + add r0.xyz, -r0, c7 + nrm r1.xyz, r0 + add r0.xyz, r1, -c4 + nrm r1.xyz, r0 + dp3 r0.x, v1, c12 + dp3 r0.y, v1, c13 + dp3 r0.z, v1, c14 + nrm r2.xyz, r0 + dp3 r0.x, r1, r2 + dp3 r0.y, -c4, r2 + max r0.x, r0.x, c19.x + sge r0.z, r0.y, c19.x + mul r0.xy, r0.zyzw, r0.xzzw + pow r1.x, r0.x, c3.w + mul r0.xzw, r1.x, c6.xyyz + mul oT1.xyz, r0.xzww, c3 + mul r0.xyz, r0.y, c5 + mov r1.xyz, c1 + mad r0.xyz, r0, r1, c2 + mul oT0.xyz, r0, v2 + dp4 oPos.z, v0, c17 + dp4 r0.x, v0, c8 + max r0.x, r0.x, c19.x + min oT1.w, r0.x, c19.y + mul oT0.w, v2.w, c1.w + dp4 r0.x, v0, c15 + dp4 r0.y, v0, c16 + dp4 r0.z, v0, c18 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + +// approximately 41 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output_siv o2.xyzw, position +dcl_temps 3 +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r0.w, -cb0[3].xyzx, r0.xyzx +ge r1.x, r0.w, l(0.000000) +and r1.x, r1.x, l(0x3f800000) +mul r0.w, r0.w, r1.x +mul r1.yzw, r0.wwww, cb0[6].xxyz +mad r1.yzw, r1.yyzw, cb0[0].xxyz, cb0[1].xxyz +mul o0.xyz, r1.yzwy, v2.xyzx +mul o0.w, v2.w, cb0[0].w +dp4 r2.x, v0.xyzw, cb0[15].xyzw +dp4 r2.y, v0.xyzw, cb0[16].xyzw +dp4 r2.z, v0.xyzw, cb0[17].xyzw +add r1.yzw, -r2.xxyz, cb0[12].xxyz +dp3 r0.w, r1.yzwy, r1.yzwy +rsq r0.w, r0.w +mad r1.yzw, r1.yyzw, r0.wwww, -cb0[3].xxyz +dp3 r0.w, r1.yzwy, r1.yzwy +rsq r0.w, r0.w +mul r1.yzw, r0.wwww, r1.yyzw +dp3 r0.x, r1.yzwy, r0.xyzx +max r0.x, r0.x, l(0.000000) +mul r0.x, r1.x, r0.x +log r0.x, r0.x +mul r0.x, r0.x, cb0[2].w +exp r0.x, r0.x +mul r0.xyz, r0.xxxx, cb0[9].xyzx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +dp4 o2.x, v0.xyzw, cb0[22].xyzw +dp4 o2.y, v0.xyzw, cb0[23].xyzw +dp4 o2.z, v0.xyzw, cb0[24].xyzw +dp4 o2.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicOneLightVc[] = +{ + 68, 88, 66, 67, 157, 229, + 30, 248, 170, 66, 14, 167, + 246, 135, 241, 9, 201, 147, + 148, 127, 1, 0, 0, 0, + 156, 8, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 240, 2, 0, 0, 188, 7, + 0, 0, 48, 8, 0, 0, + 65, 111, 110, 57, 184, 2, + 0, 0, 184, 2, 0, 0, + 0, 2, 254, 255, 72, 2, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 0, 0, 0, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 1, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 9, 0, + 1, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 1, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 8, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 19, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 9, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 10, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 11, 0, 228, 160, 2, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 228, 129, 7, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 0, 3, + 0, 0, 7, 128, 1, 0, + 228, 128, 4, 0, 228, 161, + 36, 0, 0, 2, 1, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 12, 0, 228, 160, 8, 0, + 0, 3, 0, 0, 2, 128, + 1, 0, 228, 144, 13, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 4, 128, 1, 0, + 228, 144, 14, 0, 228, 160, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 128, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 2, 128, + 4, 0, 228, 161, 2, 0, + 228, 128, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 19, 0, 0, 160, + 13, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 85, 128, + 19, 0, 0, 160, 5, 0, + 0, 3, 0, 0, 3, 128, + 0, 0, 230, 128, 0, 0, + 232, 128, 32, 0, 0, 3, + 1, 0, 1, 128, 0, 0, + 0, 128, 3, 0, 255, 160, + 5, 0, 0, 3, 0, 0, + 13, 128, 1, 0, 0, 128, + 6, 0, 148, 160, 5, 0, + 0, 3, 1, 0, 7, 224, + 0, 0, 248, 128, 3, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 85, 128, 5, 0, 228, 160, + 1, 0, 0, 2, 1, 0, + 7, 128, 1, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 128, 0, 0, 228, 128, + 1, 0, 228, 128, 2, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 7, 224, 0, 0, + 228, 128, 2, 0, 228, 144, + 9, 0, 0, 3, 0, 0, + 4, 192, 0, 0, 228, 144, + 17, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 8, 0, + 228, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 19, 0, 0, 160, + 10, 0, 0, 3, 1, 0, + 8, 224, 0, 0, 0, 128, + 19, 0, 85, 160, 5, 0, + 0, 3, 0, 0, 8, 224, + 2, 0, 255, 144, 1, 0, + 255, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 15, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 16, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 18, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 196, 4, 0, 0, 64, 0, + 1, 0, 49, 1, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 3, 0, 0, 0, 16, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 19, 0, 0, 0, + 16, 0, 0, 8, 34, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 20, 0, + 0, 0, 16, 0, 0, 8, + 66, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 9, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 29, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 56, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 8, + 226, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 50, 0, + 0, 11, 226, 0, 16, 0, + 1, 0, 0, 0, 86, 14, + 16, 0, 1, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 114, 32, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 8, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 2, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 0, 0, 0, 9, 226, 0, + 16, 0, 1, 0, 0, 0, + 6, 9, 16, 128, 65, 0, + 0, 0, 2, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 12, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 150, 7, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 226, 0, + 16, 0, 1, 0, 0, 0, + 86, 14, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 6, 137, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 1, 0, 0, 0, 150, 7, + 16, 0, 1, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 226, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 86, 14, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 52, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 47, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 58, 128, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 25, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 56, 0, 0, 8, + 114, 32, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 108, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 99, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 15, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 67, + 79, 76, 79, 82, 0, 171, + 171, 171, 79, 83, 71, 78, + 100, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 80, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLighting.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLighting.inc new file mode 100644 index 0000000000000000000000000000000000000000..a6f423f2ced9e903df91426c361ba8104d7e93d4 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLighting.inc @@ -0,0 +1,321 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xyzw 0 NONE float xyzw +// TEXCOORD 1 xyz 1 NONE float xyz +// COLOR 0 xyzw 2 NONE float xyzw +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c6 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c13, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dp4 oPos.z, v0, c11 + dp4 oT0.x, v0, c3 + dp4 oT0.y, v0, c4 + dp4 oT0.z, v0, c5 + dp3 r0.x, v1, c6 + dp3 r0.y, v1, c7 + dp3 r0.z, v1, c8 + dp3 r0.w, r0, r0 + rsq r0.w, r0.w + mul oT1.xyz, r0.w, r0 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c13.x + min oT0.w, r0.x, c13.y + dp4 r0.x, v0, c9 + dp4 r0.y, v0, c10 + dp4 r0.z, v0, c12 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov r0.xy, c13 + mad oT2, c1.w, r0.xxxy, r0.yyyx + +// approximately 20 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_output o0.xyzw +dcl_output o1.xyz +dcl_output o2.xyzw +dcl_output_siv o3.xyzw, position +dcl_temps 1 +dp4 o0.x, v0.xyzw, cb0[15].xyzw +dp4 o0.y, v0.xyzw, cb0[16].xyzw +dp4 o0.z, v0.xyzw, cb0[17].xyzw +dp4_sat o0.w, v0.xyzw, cb0[14].xyzw +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul o1.xyz, r0.wwww, r0.xyzx +mov o2.xyz, l(1.000000,1.000000,1.000000,0) +mov o2.w, cb0[0].w +dp4 o3.x, v0.xyzw, cb0[22].xyzw +dp4 o3.y, v0.xyzw, cb0[23].xyzw +dp4 o3.z, v0.xyzw, cb0[24].xyzw +dp4 o3.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicPixelLighting[] = +{ + 68, 88, 66, 67, 230, 104, + 5, 53, 228, 212, 38, 110, + 57, 156, 92, 76, 224, 255, + 252, 98, 1, 0, 0, 0, + 52, 5, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 248, 1, 0, 0, 84, 4, + 0, 0, 168, 4, 0, 0, + 65, 111, 110, 57, 192, 1, + 0, 0, 192, 1, 0, 0, + 0, 2, 254, 255, 116, 1, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 13, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 11, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 224, 0, 0, + 228, 144, 3, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 224, 0, 0, 228, 144, + 4, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 224, + 0, 0, 228, 144, 5, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 144, 6, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 2, 128, 1, 0, 228, 144, + 7, 0, 228, 160, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 8, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 8, 128, 0, 0, + 228, 128, 0, 0, 228, 128, + 7, 0, 0, 2, 0, 0, + 8, 128, 0, 0, 255, 128, + 5, 0, 0, 3, 1, 0, + 7, 224, 0, 0, 255, 128, + 0, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 2, 0, + 228, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 13, 0, 0, 160, + 10, 0, 0, 3, 0, 0, + 8, 224, 0, 0, 0, 128, + 13, 0, 85, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 9, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 10, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 12, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 170, 128, 0, 0, + 228, 160, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 170, 128, + 1, 0, 0, 2, 0, 0, + 3, 128, 13, 0, 228, 160, + 4, 0, 0, 4, 2, 0, + 15, 224, 1, 0, 255, 160, + 0, 0, 64, 128, 0, 0, + 21, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 84, 2, + 0, 0, 64, 0, 1, 0, + 149, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 2, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 16, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 19, 0, 0, 0, + 16, 0, 0, 8, 34, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 20, 0, + 0, 0, 16, 0, 0, 8, + 66, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 32, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 8, + 114, 32, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 0, 0, 54, 0, + 0, 6, 130, 32, 16, 0, + 2, 0, 0, 0, 58, 128, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 25, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 76, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 78, 79, 82, 77, + 65, 76, 0, 171, 79, 83, + 71, 78, 132, 0, 0, 0, + 4, 0, 0, 0, 8, 0, + 0, 0, 104, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 104, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 8, + 0, 0, 113, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 119, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 0, + 0, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 83, + 86, 95, 80, 111, 115, 105, + 116, 105, 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLightingTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLightingTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..622f02d0a6e3ea291c5d6b8d260b855c28ebfefc --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLightingTx.inc @@ -0,0 +1,349 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xy 0 NONE float xy +// TEXCOORD 1 xyzw 1 NONE float xyzw +// TEXCOORD 2 xyz 2 NONE float xyz +// COLOR 0 xyzw 3 NONE float xyzw +// SV_Position 0 xyzw 4 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c6 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c13, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 oPos.z, v0, c11 + dp4 oT1.x, v0, c3 + dp4 oT1.y, v0, c4 + dp4 oT1.z, v0, c5 + dp3 r0.x, v1, c6 + dp3 r0.y, v1, c7 + dp3 r0.z, v1, c8 + dp3 r0.w, r0, r0 + rsq r0.w, r0.w + mul oT2.xyz, r0.w, r0 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c13.x + min oT1.w, r0.x, c13.y + dp4 r0.x, v0, c9 + dp4 r0.y, v0, c10 + dp4 r0.z, v0, c12 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.xy, v2 + mov r0.xy, c13 + mad oT3, c1.w, r0.xxxy, r0.yyyx + +// approximately 21 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_output o0.xy +dcl_output o1.xyzw +dcl_output o2.xyz +dcl_output o3.xyzw +dcl_output_siv o4.xyzw, position +dcl_temps 1 +mov o0.xy, v2.xyxx +dp4 o1.x, v0.xyzw, cb0[15].xyzw +dp4 o1.y, v0.xyzw, cb0[16].xyzw +dp4 o1.z, v0.xyzw, cb0[17].xyzw +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul o2.xyz, r0.wwww, r0.xyzx +mov o3.xyz, l(1.000000,1.000000,1.000000,0) +mov o3.w, cb0[0].w +dp4 o4.x, v0.xyzw, cb0[22].xyzw +dp4 o4.y, v0.xyzw, cb0[23].xyzw +dp4 o4.z, v0.xyzw, cb0[24].xyzw +dp4 o4.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicPixelLightingTx[] = +{ + 68, 88, 66, 67, 204, 155, + 176, 218, 30, 165, 199, 151, + 192, 140, 191, 207, 203, 27, + 37, 64, 1, 0, 0, 0, + 176, 5, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 16, 2, 0, 0, 152, 4, + 0, 0, 12, 5, 0, 0, + 65, 111, 110, 57, 216, 1, + 0, 0, 216, 1, 0, 0, + 0, 2, 254, 255, 140, 1, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 13, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 11, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 1, 224, 0, 0, + 228, 144, 3, 0, 228, 160, + 9, 0, 0, 3, 1, 0, + 2, 224, 0, 0, 228, 144, + 4, 0, 228, 160, 9, 0, + 0, 3, 1, 0, 4, 224, + 0, 0, 228, 144, 5, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 144, 6, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 2, 128, 1, 0, 228, 144, + 7, 0, 228, 160, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 8, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 8, 128, 0, 0, + 228, 128, 0, 0, 228, 128, + 7, 0, 0, 2, 0, 0, + 8, 128, 0, 0, 255, 128, + 5, 0, 0, 3, 2, 0, + 7, 224, 0, 0, 255, 128, + 0, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 2, 0, + 228, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 13, 0, 0, 160, + 10, 0, 0, 3, 1, 0, + 8, 224, 0, 0, 0, 128, + 13, 0, 85, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 9, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 10, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 12, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 170, 128, 0, 0, + 228, 160, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 170, 128, + 1, 0, 0, 2, 0, 0, + 3, 224, 2, 0, 228, 144, + 1, 0, 0, 2, 0, 0, + 3, 128, 13, 0, 228, 160, + 4, 0, 0, 4, 3, 0, + 15, 224, 1, 0, 255, 160, + 0, 0, 64, 128, 0, 0, + 21, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 128, 2, + 0, 0, 64, 0, 1, 0, + 160, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 3, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 4, 0, + 0, 0, 1, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 2, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 16, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 19, 0, + 0, 0, 16, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 16, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 21, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 32, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 8, 114, 32, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 0, 0, + 54, 0, 0, 6, 130, 32, + 16, 0, 3, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 4, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 4, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 108, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 99, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 79, 83, 71, 78, + 156, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 12, 0, 0, + 128, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 128, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 7, 8, 0, 0, + 137, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 143, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 0, 0, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 67, 79, 76, + 79, 82, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLightingTxVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLightingTxVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..8a07e4996cb403431de860154b13460a1e646900 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLightingTxVc.inc @@ -0,0 +1,360 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// COLOR 0 xyzw 3 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xy 0 NONE float xy +// TEXCOORD 1 xyzw 1 NONE float xyzw +// TEXCOORD 2 xyz 2 NONE float xyz +// COLOR 0 xyzw 3 NONE float xyzw +// SV_Position 0 xyzw 4 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c6 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c13, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dp4 oPos.z, v0, c11 + dp4 oT1.x, v0, c3 + dp4 oT1.y, v0, c4 + dp4 oT1.z, v0, c5 + dp3 r0.x, v1, c6 + dp3 r0.y, v1, c7 + dp3 r0.z, v1, c8 + dp3 r0.w, r0, r0 + rsq r0.w, r0.w + mul oT2.xyz, r0.w, r0 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c13.x + min oT1.w, r0.x, c13.y + mul oT3.w, v3.w, c1.w + dp4 r0.x, v0, c9 + dp4 r0.y, v0, c10 + dp4 r0.z, v0, c12 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.xy, v2 + mov oT3.xyz, v3 + +// approximately 21 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xyzw +dcl_output o0.xy +dcl_output o1.xyzw +dcl_output o2.xyz +dcl_output o3.xyzw +dcl_output_siv o4.xyzw, position +dcl_temps 1 +mov o0.xy, v2.xyxx +dp4 o1.x, v0.xyzw, cb0[15].xyzw +dp4 o1.y, v0.xyzw, cb0[16].xyzw +dp4 o1.z, v0.xyzw, cb0[17].xyzw +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul o2.xyz, r0.wwww, r0.xyzx +mul o3.w, v3.w, cb0[0].w +mov o3.xyz, v3.xyzx +dp4 o4.x, v0.xyzw, cb0[22].xyzw +dp4 o4.y, v0.xyzw, cb0[23].xyzw +dp4 o4.z, v0.xyzw, cb0[24].xyzw +dp4 o4.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicPixelLightingTxVc[] = +{ + 68, 88, 66, 67, 65, 60, + 6, 224, 158, 7, 234, 93, + 193, 57, 237, 180, 6, 97, + 96, 230, 1, 0, 0, 0, + 224, 5, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 24, 2, 0, 0, 168, 4, + 0, 0, 60, 5, 0, 0, + 65, 111, 110, 57, 224, 1, + 0, 0, 224, 1, 0, 0, + 0, 2, 254, 255, 148, 1, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 13, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 11, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 1, 224, 0, 0, + 228, 144, 3, 0, 228, 160, + 9, 0, 0, 3, 1, 0, + 2, 224, 0, 0, 228, 144, + 4, 0, 228, 160, 9, 0, + 0, 3, 1, 0, 4, 224, + 0, 0, 228, 144, 5, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 144, 6, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 2, 128, 1, 0, 228, 144, + 7, 0, 228, 160, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 8, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 8, 128, 0, 0, + 228, 128, 0, 0, 228, 128, + 7, 0, 0, 2, 0, 0, + 8, 128, 0, 0, 255, 128, + 5, 0, 0, 3, 2, 0, + 7, 224, 0, 0, 255, 128, + 0, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 2, 0, + 228, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 13, 0, 0, 160, + 10, 0, 0, 3, 1, 0, + 8, 224, 0, 0, 0, 128, + 13, 0, 85, 160, 5, 0, + 0, 3, 3, 0, 8, 224, + 3, 0, 255, 144, 1, 0, + 255, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 9, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 10, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 12, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 3, 224, + 2, 0, 228, 144, 1, 0, + 0, 2, 3, 0, 7, 224, + 3, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 136, 2, 0, 0, 64, 0, + 1, 0, 162, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 3, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 4, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 54, 0, + 0, 5, 50, 32, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 17, 32, 0, 8, 130, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 32, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 130, 32, + 16, 0, 3, 0, 0, 0, + 58, 16, 16, 0, 3, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 4, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 25, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 140, 0, 0, 0, + 4, 0, 0, 0, 8, 0, + 0, 0, 104, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 116, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 123, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 132, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 15, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 78, 79, 82, 77, + 65, 76, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 67, 79, 76, 79, 82, 0, + 171, 171, 79, 83, 71, 78, + 156, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 12, 0, 0, + 128, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 128, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 7, 8, 0, 0, + 137, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 143, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 0, 0, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 67, 79, 76, + 79, 82, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLightingVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLightingVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..1ef54041b34d547bbf97de359bd110e38b80ae3d --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicPixelLightingVc.inc @@ -0,0 +1,332 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// COLOR 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xyzw 0 NONE float xyzw +// TEXCOORD 1 xyz 1 NONE float xyz +// COLOR 0 xyzw 2 NONE float xyzw +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c6 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c13, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 oPos.z, v0, c11 + dp4 oT0.x, v0, c3 + dp4 oT0.y, v0, c4 + dp4 oT0.z, v0, c5 + dp3 r0.x, v1, c6 + dp3 r0.y, v1, c7 + dp3 r0.z, v1, c8 + dp3 r0.w, r0, r0 + rsq r0.w, r0.w + mul oT1.xyz, r0.w, r0 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c13.x + min oT0.w, r0.x, c13.y + mul oT2.w, v2.w, c1.w + dp4 r0.x, v0, c9 + dp4 r0.y, v0, c10 + dp4 r0.z, v0, c12 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT2.xyz, v2 + +// approximately 20 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_output o0.xyzw +dcl_output o1.xyz +dcl_output o2.xyzw +dcl_output_siv o3.xyzw, position +dcl_temps 1 +dp4 o0.x, v0.xyzw, cb0[15].xyzw +dp4 o0.y, v0.xyzw, cb0[16].xyzw +dp4 o0.z, v0.xyzw, cb0[17].xyzw +dp4_sat o0.w, v0.xyzw, cb0[14].xyzw +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul o1.xyz, r0.wwww, r0.xyzx +mul o2.w, v2.w, cb0[0].w +mov o2.xyz, v2.xyzx +dp4 o3.x, v0.xyzw, cb0[22].xyzw +dp4 o3.y, v0.xyzw, cb0[23].xyzw +dp4 o3.z, v0.xyzw, cb0[24].xyzw +dp4 o3.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicPixelLightingVc[] = +{ + 68, 88, 66, 67, 0, 37, + 19, 114, 200, 71, 227, 13, + 38, 46, 161, 55, 143, 215, + 122, 186, 1, 0, 0, 0, + 100, 5, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 0, 2, 0, 0, 100, 4, + 0, 0, 216, 4, 0, 0, + 65, 111, 110, 57, 200, 1, + 0, 0, 200, 1, 0, 0, + 0, 2, 254, 255, 124, 1, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 13, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 11, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 224, 0, 0, + 228, 144, 3, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 224, 0, 0, 228, 144, + 4, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 224, + 0, 0, 228, 144, 5, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 144, 6, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 2, 128, 1, 0, 228, 144, + 7, 0, 228, 160, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 8, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 8, 128, 0, 0, + 228, 128, 0, 0, 228, 128, + 7, 0, 0, 2, 0, 0, + 8, 128, 0, 0, 255, 128, + 5, 0, 0, 3, 1, 0, + 7, 224, 0, 0, 255, 128, + 0, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 2, 0, + 228, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 13, 0, 0, 160, + 10, 0, 0, 3, 0, 0, + 8, 224, 0, 0, 0, 128, + 13, 0, 85, 160, 5, 0, + 0, 3, 2, 0, 8, 224, + 2, 0, 255, 144, 1, 0, + 255, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 9, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 10, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 12, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 2, 0, 7, 224, + 2, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 92, 2, 0, 0, 64, 0, + 1, 0, 151, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 16, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 19, 0, + 0, 0, 16, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 16, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 21, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 32, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 130, 32, 16, 0, + 2, 0, 0, 0, 58, 16, + 16, 0, 2, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 108, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 99, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 67, 79, 76, 79, 82, + 0, 171, 171, 171, 79, 83, + 71, 78, 132, 0, 0, 0, + 4, 0, 0, 0, 8, 0, + 0, 0, 104, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 104, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 8, + 0, 0, 113, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 119, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 0, + 0, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 83, + 86, 95, 80, 111, 115, 105, + 116, 105, 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..39bdcde8ad15eb8dbd747e9999151bc31caf9cb5 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTx.inc @@ -0,0 +1,240 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 14 1 ( FLT, FLT, FLT, FLT) +// c3 cb0 22 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c7, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dp4 oPos.z, v0, c5 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c7.x + min oT1.w, r0.x, c7.y + dp4 r0.x, v0, c3 + dp4 r0.y, v0, c4 + dp4 r0.z, v0, c6 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0, c1 + mov oT1.xyz, c7.x + mov oT2.xy, v1 + +// approximately 12 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +mov o0.xyzw, cb0[0].xyzw +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +mov o1.xyz, l(0,0,0,0) +mov o2.xy, v1.xyxx +dp4 o3.x, v0.xyzw, cb0[22].xyzw +dp4 o3.y, v0.xyzw, cb0[23].xyzw +dp4 o3.z, v0.xyzw, cb0[24].xyzw +dp4 o3.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicTx[] = +{ + 68, 88, 66, 67, 160, 62, + 87, 247, 158, 198, 70, 98, + 102, 170, 42, 202, 103, 175, + 31, 164, 1, 0, 0, 0, + 176, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 112, 1, 0, 0, 204, 2, + 0, 0, 36, 3, 0, 0, + 65, 111, 110, 57, 56, 1, + 0, 0, 56, 1, 0, 0, + 0, 2, 254, 255, 236, 0, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 1, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 22, 0, + 4, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 7, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 5, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 7, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 7, 0, + 85, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 3, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 4, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 6, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 1, 0, 228, 160, 1, 0, + 0, 2, 1, 0, 7, 224, + 7, 0, 0, 160, 1, 0, + 0, 2, 2, 0, 3, 224, + 1, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 84, 1, 0, 0, 64, 0, + 1, 0, 85, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 54, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 80, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 171, 171, + 79, 83, 71, 78, 132, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 110, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 119, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTxNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTxNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..553076ecc55bbc0d3abfddbd2f2f8935421259ef --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTxNoFog.inc @@ -0,0 +1,197 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 22 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dp4 oPos.z, v0, c4 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c5 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0, c1 + mov oT1.xy, v1 + +// approximately 8 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_output o0.xyzw +dcl_output o1.xy +dcl_output_siv o2.xyzw, position +mov o0.xyzw, cb0[0].xyzw +mov o1.xy, v1.xyxx +dp4 o2.x, v0.xyzw, cb0[22].xyzw +dp4 o2.y, v0.xyzw, cb0[23].xyzw +dp4 o2.z, v0.xyzw, cb0[24].xyzw +dp4 o2.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicTxNoFog[] = +{ + 68, 88, 66, 67, 221, 167, + 150, 144, 89, 19, 203, 62, + 35, 20, 208, 187, 193, 120, + 188, 253, 1, 0, 0, 0, + 236, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 16, 1, 0, 0, 32, 2, + 0, 0, 120, 2, 0, 0, + 65, 111, 110, 57, 216, 0, + 0, 0, 216, 0, 0, 0, + 0, 2, 254, 255, 152, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 22, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 4, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 5, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 1, 0, 228, 160, 1, 0, + 0, 2, 1, 0, 3, 224, + 1, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 8, 1, 0, 0, 64, 0, + 1, 0, 66, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 25, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 80, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 79, 83, 71, 78, + 108, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 12, 0, 0, + 95, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTxVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTxVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..3687a4a39a733dfa01f3d7ea2afdecd5d1a5478a --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTxVc.inc @@ -0,0 +1,253 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// COLOR 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 14 1 ( FLT, FLT, FLT, FLT) +// c3 cb0 22 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c7, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 oPos.z, v0, c5 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c7.x + min oT1.w, r0.x, c7.y + mul oT0, v2, c1 + dp4 r0.x, v0, c3 + dp4 r0.y, v0, c4 + dp4 r0.z, v0, c6 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT1.xyz, c7.x + mov oT2.xy, v1 + +// approximately 12 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +mul o0.xyzw, v2.xyzw, cb0[0].xyzw +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +mov o1.xyz, l(0,0,0,0) +mov o2.xy, v1.xyxx +dp4 o3.x, v0.xyzw, cb0[22].xyzw +dp4 o3.y, v0.xyzw, cb0[23].xyzw +dp4 o3.z, v0.xyzw, cb0[24].xyzw +dp4 o3.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicTxVc[] = +{ + 68, 88, 66, 67, 163, 240, + 73, 82, 1, 64, 234, 192, + 176, 202, 185, 166, 255, 149, + 255, 7, 1, 0, 0, 0, + 240, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 128, 1, 0, 0, 240, 2, + 0, 0, 100, 3, 0, 0, + 65, 111, 110, 57, 72, 1, + 0, 0, 72, 1, 0, 0, + 0, 2, 254, 255, 252, 0, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 1, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 22, 0, + 4, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 7, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 5, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 7, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 7, 0, + 85, 160, 5, 0, 0, 3, + 0, 0, 15, 224, 2, 0, + 228, 144, 1, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 4, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 6, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 1, 0, 7, 224, 7, 0, + 0, 160, 1, 0, 0, 2, + 2, 0, 3, 224, 1, 0, + 228, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 104, 1, + 0, 0, 64, 0, 1, 0, + 90, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 54, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 108, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 101, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 67, 79, 76, + 79, 82, 0, 171, 79, 83, + 71, 78, 132, 0, 0, 0, + 4, 0, 0, 0, 8, 0, + 0, 0, 104, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 104, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 110, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 12, + 0, 0, 119, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 0, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 83, + 86, 95, 80, 111, 115, 105, + 116, 105, 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTxVcNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTxVcNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..70eef7aee6fe776eaf8eb6af51fdce68b5d54eda --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicTxVcNoFog.inc @@ -0,0 +1,211 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// COLOR 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 22 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 oPos.z, v0, c4 + mul oT0, v2, c1 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c5 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT1.xy, v1 + +// approximately 8 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xyzw +dcl_output o0.xyzw +dcl_output o1.xy +dcl_output_siv o2.xyzw, position +mul o0.xyzw, v2.xyzw, cb0[0].xyzw +mov o1.xy, v1.xyxx +dp4 o2.x, v0.xyzw, cb0[22].xyzw +dp4 o2.y, v0.xyzw, cb0[23].xyzw +dp4 o2.z, v0.xyzw, cb0[24].xyzw +dp4 o2.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicTxVcNoFog[] = +{ + 68, 88, 66, 67, 117, 119, + 253, 103, 213, 37, 15, 215, + 73, 141, 241, 41, 247, 61, + 238, 21, 1, 0, 0, 0, + 44, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 32, 1, 0, 0, 68, 2, + 0, 0, 184, 2, 0, 0, + 65, 111, 110, 57, 232, 0, + 0, 0, 232, 0, 0, 0, + 0, 2, 254, 255, 168, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 22, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 4, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 224, 2, 0, + 228, 144, 1, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 3, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 5, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 1, 0, 3, 224, 1, 0, + 228, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 28, 1, + 0, 0, 64, 0, 1, 0, + 71, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 1, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 25, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 108, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 92, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 101, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 15, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 171, + 79, 83, 71, 78, 108, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 86, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 12, 0, 0, 95, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..1815e5d9e57ed6153ff9cc55b8f9399c72e67a54 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVc.inc @@ -0,0 +1,224 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 14 1 ( FLT, FLT, FLT, FLT) +// c3 cb0 22 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c7, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dp4 oPos.z, v0, c5 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c7.x + min oT1.w, r0.x, c7.y + mul oT0, v1, c1 + dp4 r0.x, v0, c3 + dp4 r0.y, v0, c4 + dp4 r0.z, v0, c6 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT1.xyz, c7.x + +// approximately 11 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output_siv o2.xyzw, position +mul o0.xyzw, v1.xyzw, cb0[0].xyzw +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +mov o1.xyz, l(0,0,0,0) +dp4 o2.x, v0.xyzw, cb0[22].xyzw +dp4 o2.y, v0.xyzw, cb0[23].xyzw +dp4 o2.z, v0.xyzw, cb0[24].xyzw +dp4 o2.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicVc[] = +{ + 68, 88, 66, 67, 10, 187, + 46, 163, 197, 75, 4, 52, + 117, 94, 32, 83, 139, 250, + 54, 33, 1, 0, 0, 0, + 108, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 104, 1, 0, 0, 172, 2, + 0, 0, 0, 3, 0, 0, + 65, 111, 110, 57, 48, 1, + 0, 0, 48, 1, 0, 0, + 0, 2, 254, 255, 228, 0, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 1, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 22, 0, + 4, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 7, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 5, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 7, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 7, 0, + 85, 160, 5, 0, 0, 3, + 0, 0, 15, 224, 1, 0, + 228, 144, 1, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 4, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 6, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 1, 0, 7, 224, 7, 0, + 0, 160, 255, 255, 0, 0, + 83, 72, 68, 82, 60, 1, + 0, 0, 64, 0, 1, 0, + 79, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 54, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 76, 0, + 0, 0, 2, 0, 0, 0, + 8, 0, 0, 0, 56, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 68, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 15, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 67, 79, + 76, 79, 82, 0, 171, 171, + 79, 83, 71, 78, 100, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 80, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 86, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVcNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVcNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..9fd1c404612a3e8e3b3d31162a472f44e97d52a0 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVcNoFog.inc @@ -0,0 +1,182 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// SV_Position 0 xyzw 1 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 22 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dp4 oPos.z, v0, c4 + mul oT0, v1, c1 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c5 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + +// approximately 7 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyzw +dcl_output o0.xyzw +dcl_output_siv o1.xyzw, position +mul o0.xyzw, v1.xyzw, cb0[0].xyzw +dp4 o1.x, v0.xyzw, cb0[22].xyzw +dp4 o1.y, v0.xyzw, cb0[23].xyzw +dp4 o1.z, v0.xyzw, cb0[24].xyzw +dp4 o1.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicVcNoFog[] = +{ + 68, 88, 66, 67, 84, 0, + 235, 58, 0, 107, 122, 79, + 253, 27, 44, 43, 109, 188, + 148, 111, 1, 0, 0, 0, + 168, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 8, 1, 0, 0, 0, 2, + 0, 0, 84, 2, 0, 0, + 65, 111, 110, 57, 208, 0, + 0, 0, 208, 0, 0, 0, + 0, 2, 254, 255, 144, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 22, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 4, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 224, 1, 0, + 228, 144, 1, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 3, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 5, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 240, 0, + 0, 0, 64, 0, 1, 0, + 60, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 76, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 67, 79, 76, 79, 82, 0, + 171, 171, 79, 83, 71, 78, + 76, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 62, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLighting.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLighting.inc new file mode 100644 index 0000000000000000000000000000000000000000..26e9db4316a60d8842f44d8ae22acabd33e1a72c --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLighting.inc @@ -0,0 +1,649 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 13 ( FLT, FLT, FLT, FLT) +// c14 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c18 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c25, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dp3 r0.x, v1, c18 + dp3 r0.y, v1, c19 + dp3 r0.z, v1, c20 + nrm r1.xyz, r0 + dp3 r0.x, -c4, r1 + dp3 r0.y, -c5, r1 + dp3 r0.z, -c6, r1 + sge r2.xyz, r0, c25.x + mul r0.xyz, r0, r2 + mul r3.xyz, r0.y, c8 + mad r0.xyw, r0.x, c7.xyzz, r3.xyzz + mad r0.xyz, r0.z, c9, r0.xyww + mov r3.xyz, c1 + mad oT0.xyz, r0, r3, c2 + dp4 r0.x, v0, c15 + dp4 r0.y, v0, c16 + dp4 r0.z, v0, c17 + add r0.xyz, -r0, c13 + nrm r3.xyz, r0 + add r0.xyz, r3, -c4 + nrm r4.xyz, r0 + dp3 r0.x, r4, r1 + add r4.xyz, r3, -c5 + add r3.xyz, r3, -c6 + nrm r5.xyz, r3 + dp3 r0.z, r5, r1 + nrm r3.xyz, r4 + dp3 r0.y, r3, r1 + max r0.xyz, r0, c25.x + mul r0.xyz, r2, r0 + log r1.x, r0.x + log r1.y, r0.y + log r1.z, r0.z + mul r0.xyz, r1, c3.w + exp r0.x, r0.x + exp r0.y, r0.y + exp r0.z, r0.z + mul r1.xyz, r0.y, c11 + mad r0.xyw, r0.x, c10.xyzz, r1.xyzz + mad r0.xyz, r0.z, c12, r0.xyww + mul oT1.xyz, r0, c3 + dp4 oPos.z, v0, c23 + dp4 r0.x, v0, c14 + max r0.x, r0.x, c25.x + min oT1.w, r0.x, c25.y + dp4 r0.x, v0, c21 + dp4 r0.y, v0, c22 + dp4 r0.z, v0, c24 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.w, c1.w + +// approximately 61 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output_siv o2.xyzw, position +dcl_temps 5 +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r1.x, -cb0[3].xyzx, r0.xyzx +dp3 r1.y, -cb0[4].xyzx, r0.xyzx +dp3 r1.z, -cb0[5].xyzx, r0.xyzx +ge r2.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r1.xyz, r1.xyzx, r2.xyzx +mul r3.xyz, r1.yyyy, cb0[7].xyzx +mad r1.xyw, r1.xxxx, cb0[6].xyxz, r3.xyxz +mad r1.xyz, r1.zzzz, cb0[8].xyzx, r1.xywx +mad o0.xyz, r1.xyzx, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +dp4 r1.x, v0.xyzw, cb0[15].xyzw +dp4 r1.y, v0.xyzw, cb0[16].xyzw +dp4 r1.z, v0.xyzw, cb0[17].xyzw +add r1.xyz, -r1.xyzx, cb0[12].xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mad r3.xyz, r1.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r1.w, r3.xyzx, r3.xyzx +rsq r1.w, r1.w +mul r3.xyz, r1.wwww, r3.xyzx +dp3 r3.x, r3.xyzx, r0.xyzx +mad r4.xyz, r1.xyzx, r0.wwww, -cb0[4].xyzx +mad r1.xyz, r1.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r4.xyzx, r4.xyzx +rsq r0.w, r0.w +mul r4.xyz, r0.wwww, r4.xyzx +dp3 r3.y, r4.xyzx, r0.xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mul r1.xyz, r0.wwww, r1.xyzx +dp3 r3.z, r1.xyzx, r0.xyzx +max r0.xyz, r3.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +mul r0.xyz, r2.xyzx, r0.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r1.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r1.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +dp4 o2.x, v0.xyzw, cb0[22].xyzw +dp4 o2.y, v0.xyzw, cb0[23].xyzw +dp4 o2.z, v0.xyzw, cb0[24].xyzw +dp4 o2.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicVertexLighting[] = +{ + 68, 88, 66, 67, 227, 79, + 10, 21, 150, 232, 101, 180, + 243, 182, 250, 185, 179, 99, + 49, 164, 1, 0, 0, 0, + 92, 11, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 204, 3, 0, 0, 156, 10, + 0, 0, 240, 10, 0, 0, + 65, 111, 110, 57, 148, 3, + 0, 0, 148, 3, 0, 0, + 0, 2, 254, 255, 72, 3, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 13, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 14, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 25, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 8, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 228, 144, 18, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 19, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 4, 128, 1, 0, 228, 144, + 20, 0, 228, 160, 36, 0, + 0, 2, 1, 0, 7, 128, + 0, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 1, 128, + 4, 0, 228, 161, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 5, 0, + 228, 161, 1, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 4, 128, 6, 0, 228, 161, + 1, 0, 228, 128, 13, 0, + 0, 3, 2, 0, 7, 128, + 0, 0, 228, 128, 25, 0, + 0, 160, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 228, 128, + 5, 0, 0, 3, 3, 0, + 7, 128, 0, 0, 85, 128, + 8, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 11, 128, + 0, 0, 0, 128, 7, 0, + 164, 160, 3, 0, 164, 128, + 4, 0, 0, 4, 0, 0, + 7, 128, 0, 0, 170, 128, + 9, 0, 228, 160, 0, 0, + 244, 128, 1, 0, 0, 2, + 3, 0, 7, 128, 1, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 224, 0, 0, + 228, 128, 3, 0, 228, 128, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 15, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 16, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 17, 0, 228, 160, 2, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 228, 129, 13, 0, + 228, 160, 36, 0, 0, 2, + 3, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 0, 3, + 0, 0, 7, 128, 3, 0, + 228, 128, 4, 0, 228, 161, + 36, 0, 0, 2, 4, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 4, 0, 228, 128, + 1, 0, 228, 128, 2, 0, + 0, 3, 4, 0, 7, 128, + 3, 0, 228, 128, 5, 0, + 228, 161, 2, 0, 0, 3, + 3, 0, 7, 128, 3, 0, + 228, 128, 6, 0, 228, 161, + 36, 0, 0, 2, 5, 0, + 7, 128, 3, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 4, 128, 5, 0, 228, 128, + 1, 0, 228, 128, 36, 0, + 0, 2, 3, 0, 7, 128, + 4, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 2, 128, + 3, 0, 228, 128, 1, 0, + 228, 128, 11, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 25, 0, 0, 160, + 5, 0, 0, 3, 0, 0, + 7, 128, 2, 0, 228, 128, + 0, 0, 228, 128, 15, 0, + 0, 2, 1, 0, 1, 128, + 0, 0, 0, 128, 15, 0, + 0, 2, 1, 0, 2, 128, + 0, 0, 85, 128, 15, 0, + 0, 2, 1, 0, 4, 128, + 0, 0, 170, 128, 5, 0, + 0, 3, 0, 0, 7, 128, + 1, 0, 228, 128, 3, 0, + 255, 160, 14, 0, 0, 2, + 0, 0, 1, 128, 0, 0, + 0, 128, 14, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 85, 128, 14, 0, 0, 2, + 0, 0, 4, 128, 0, 0, + 170, 128, 5, 0, 0, 3, + 1, 0, 7, 128, 0, 0, + 85, 128, 11, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 11, 128, 0, 0, 0, 128, + 10, 0, 164, 160, 1, 0, + 164, 128, 4, 0, 0, 4, + 0, 0, 7, 128, 0, 0, + 170, 128, 12, 0, 228, 160, + 0, 0, 244, 128, 5, 0, + 0, 3, 1, 0, 7, 224, + 0, 0, 228, 128, 3, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 192, 0, 0, + 228, 144, 23, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 14, 0, 228, 160, 11, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 0, 128, 25, 0, + 0, 160, 10, 0, 0, 3, + 1, 0, 8, 224, 0, 0, + 0, 128, 25, 0, 85, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 21, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 22, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 24, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 0, 0, 8, 224, 1, 0, + 255, 160, 255, 255, 0, 0, + 83, 72, 68, 82, 200, 6, + 0, 0, 64, 0, 1, 0, + 178, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 104, 0, 0, 2, 5, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 29, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 10, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 3, 0, 0, 0, + 86, 5, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 50, 0, 0, 10, + 178, 0, 16, 0, 1, 0, + 0, 0, 6, 0, 16, 0, + 1, 0, 0, 0, 70, 136, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 70, 8, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 1, 0, 0, 0, + 166, 10, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 70, 3, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 11, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 6, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 0, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 12, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 4, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 66, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 52, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 47, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 143, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 1, 0, + 0, 0, 86, 5, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 50, 0, + 0, 10, 178, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 136, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 70, 8, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 166, 10, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 70, 3, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 32, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 24, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 25, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 76, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 68, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 78, 79, 82, 77, + 65, 76, 0, 171, 79, 83, + 71, 78, 100, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 80, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 86, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 67, 79, 76, 79, + 82, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLightingTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLightingTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..f5b073f40d34317bad7ae6a93bb4d2de3c032a67 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLightingTx.inc @@ -0,0 +1,678 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 13 ( FLT, FLT, FLT, FLT) +// c14 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c18 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c25, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp3 r0.x, v1, c18 + dp3 r0.y, v1, c19 + dp3 r0.z, v1, c20 + nrm r1.xyz, r0 + dp3 r0.x, -c4, r1 + dp3 r0.y, -c5, r1 + dp3 r0.z, -c6, r1 + sge r2.xyz, r0, c25.x + mul r0.xyz, r0, r2 + mul r3.xyz, r0.y, c8 + mad r0.xyw, r0.x, c7.xyzz, r3.xyzz + mad r0.xyz, r0.z, c9, r0.xyww + mov r3.xyz, c1 + mad oT0.xyz, r0, r3, c2 + dp4 r0.x, v0, c15 + dp4 r0.y, v0, c16 + dp4 r0.z, v0, c17 + add r0.xyz, -r0, c13 + nrm r3.xyz, r0 + add r0.xyz, r3, -c4 + nrm r4.xyz, r0 + dp3 r0.x, r4, r1 + add r4.xyz, r3, -c5 + add r3.xyz, r3, -c6 + nrm r5.xyz, r3 + dp3 r0.z, r5, r1 + nrm r3.xyz, r4 + dp3 r0.y, r3, r1 + max r0.xyz, r0, c25.x + mul r0.xyz, r2, r0 + log r1.x, r0.x + log r1.y, r0.y + log r1.z, r0.z + mul r0.xyz, r1, c3.w + exp r0.x, r0.x + exp r0.y, r0.y + exp r0.z, r0.z + mul r1.xyz, r0.y, c11 + mad r0.xyw, r0.x, c10.xyzz, r1.xyzz + mad r0.xyz, r0.z, c12, r0.xyww + mul oT1.xyz, r0, c3 + dp4 oPos.z, v0, c23 + dp4 r0.x, v0, c14 + max r0.x, r0.x, c25.x + min oT1.w, r0.x, c25.y + dp4 r0.x, v0, c21 + dp4 r0.y, v0, c22 + dp4 r0.z, v0, c24 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.w, c1.w + mov oT2.xy, v2 + +// approximately 62 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 5 +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r1.x, -cb0[3].xyzx, r0.xyzx +dp3 r1.y, -cb0[4].xyzx, r0.xyzx +dp3 r1.z, -cb0[5].xyzx, r0.xyzx +ge r2.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r1.xyz, r1.xyzx, r2.xyzx +mul r3.xyz, r1.yyyy, cb0[7].xyzx +mad r1.xyw, r1.xxxx, cb0[6].xyxz, r3.xyxz +mad r1.xyz, r1.zzzz, cb0[8].xyzx, r1.xywx +mad o0.xyz, r1.xyzx, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +dp4 r1.x, v0.xyzw, cb0[15].xyzw +dp4 r1.y, v0.xyzw, cb0[16].xyzw +dp4 r1.z, v0.xyzw, cb0[17].xyzw +add r1.xyz, -r1.xyzx, cb0[12].xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mad r3.xyz, r1.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r1.w, r3.xyzx, r3.xyzx +rsq r1.w, r1.w +mul r3.xyz, r1.wwww, r3.xyzx +dp3 r3.x, r3.xyzx, r0.xyzx +mad r4.xyz, r1.xyzx, r0.wwww, -cb0[4].xyzx +mad r1.xyz, r1.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r4.xyzx, r4.xyzx +rsq r0.w, r0.w +mul r4.xyz, r0.wwww, r4.xyzx +dp3 r3.y, r4.xyzx, r0.xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mul r1.xyz, r0.wwww, r1.xyzx +dp3 r3.z, r1.xyzx, r0.xyzx +max r0.xyz, r3.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +mul r0.xyz, r2.xyzx, r0.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r1.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r1.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, v0.xyzw, cb0[22].xyzw +dp4 o3.y, v0.xyzw, cb0[23].xyzw +dp4 o3.z, v0.xyzw, cb0[24].xyzw +dp4 o3.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicVertexLightingTx[] = +{ + 68, 88, 66, 67, 47, 196, + 250, 120, 243, 184, 64, 199, + 182, 131, 36, 33, 211, 185, + 23, 197, 1, 0, 0, 0, + 224, 11, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 228, 3, 0, 0, 224, 10, + 0, 0, 84, 11, 0, 0, + 65, 111, 110, 57, 172, 3, + 0, 0, 172, 3, 0, 0, + 0, 2, 254, 255, 96, 3, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 13, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 14, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 25, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 8, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 228, 144, 18, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 19, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 4, 128, 1, 0, 228, 144, + 20, 0, 228, 160, 36, 0, + 0, 2, 1, 0, 7, 128, + 0, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 1, 128, + 4, 0, 228, 161, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 5, 0, + 228, 161, 1, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 4, 128, 6, 0, 228, 161, + 1, 0, 228, 128, 13, 0, + 0, 3, 2, 0, 7, 128, + 0, 0, 228, 128, 25, 0, + 0, 160, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 228, 128, + 5, 0, 0, 3, 3, 0, + 7, 128, 0, 0, 85, 128, + 8, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 11, 128, + 0, 0, 0, 128, 7, 0, + 164, 160, 3, 0, 164, 128, + 4, 0, 0, 4, 0, 0, + 7, 128, 0, 0, 170, 128, + 9, 0, 228, 160, 0, 0, + 244, 128, 1, 0, 0, 2, + 3, 0, 7, 128, 1, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 224, 0, 0, + 228, 128, 3, 0, 228, 128, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 15, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 16, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 17, 0, 228, 160, 2, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 228, 129, 13, 0, + 228, 160, 36, 0, 0, 2, + 3, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 0, 3, + 0, 0, 7, 128, 3, 0, + 228, 128, 4, 0, 228, 161, + 36, 0, 0, 2, 4, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 4, 0, 228, 128, + 1, 0, 228, 128, 2, 0, + 0, 3, 4, 0, 7, 128, + 3, 0, 228, 128, 5, 0, + 228, 161, 2, 0, 0, 3, + 3, 0, 7, 128, 3, 0, + 228, 128, 6, 0, 228, 161, + 36, 0, 0, 2, 5, 0, + 7, 128, 3, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 4, 128, 5, 0, 228, 128, + 1, 0, 228, 128, 36, 0, + 0, 2, 3, 0, 7, 128, + 4, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 2, 128, + 3, 0, 228, 128, 1, 0, + 228, 128, 11, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 25, 0, 0, 160, + 5, 0, 0, 3, 0, 0, + 7, 128, 2, 0, 228, 128, + 0, 0, 228, 128, 15, 0, + 0, 2, 1, 0, 1, 128, + 0, 0, 0, 128, 15, 0, + 0, 2, 1, 0, 2, 128, + 0, 0, 85, 128, 15, 0, + 0, 2, 1, 0, 4, 128, + 0, 0, 170, 128, 5, 0, + 0, 3, 0, 0, 7, 128, + 1, 0, 228, 128, 3, 0, + 255, 160, 14, 0, 0, 2, + 0, 0, 1, 128, 0, 0, + 0, 128, 14, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 85, 128, 14, 0, 0, 2, + 0, 0, 4, 128, 0, 0, + 170, 128, 5, 0, 0, 3, + 1, 0, 7, 128, 0, 0, + 85, 128, 11, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 11, 128, 0, 0, 0, 128, + 10, 0, 164, 160, 1, 0, + 164, 128, 4, 0, 0, 4, + 0, 0, 7, 128, 0, 0, + 170, 128, 12, 0, 228, 160, + 0, 0, 244, 128, 5, 0, + 0, 3, 1, 0, 7, 224, + 0, 0, 228, 128, 3, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 192, 0, 0, + 228, 144, 23, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 14, 0, 228, 160, 11, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 0, 128, 25, 0, + 0, 160, 10, 0, 0, 3, + 1, 0, 8, 224, 0, 0, + 0, 128, 25, 0, 85, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 21, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 22, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 24, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 0, 0, 8, 224, 1, 0, + 255, 160, 1, 0, 0, 2, + 2, 0, 3, 224, 2, 0, + 228, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 244, 6, + 0, 0, 64, 0, 1, 0, + 189, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 26, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 104, 0, 0, 2, 5, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 29, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 10, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 3, 0, 0, 0, + 86, 5, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 50, 0, 0, 10, + 178, 0, 16, 0, 1, 0, + 0, 0, 6, 0, 16, 0, + 1, 0, 0, 0, 70, 136, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 70, 8, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 1, 0, 0, 0, + 166, 10, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 70, 3, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 11, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 6, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 0, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 12, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 4, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 66, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 52, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 47, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 143, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 1, 0, + 0, 0, 86, 5, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 50, 0, + 0, 10, 178, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 136, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 70, 8, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 166, 10, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 70, 3, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 32, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 54, 0, + 0, 5, 50, 32, 16, 0, + 2, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 108, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 99, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 79, 83, 71, 78, + 132, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 104, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 110, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 12, 0, 0, + 119, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLightingTxVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLightingTxVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..d26ebf2bbfab573acdb3ec6f26965b1c880e7451 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLightingTxVc.inc @@ -0,0 +1,702 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// COLOR 0 xyzw 3 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 13 ( FLT, FLT, FLT, FLT) +// c14 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c18 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c25, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dp4 r0.x, v0, c15 + dp4 r0.y, v0, c16 + dp4 r0.z, v0, c17 + add r0.xyz, -r0, c13 + nrm r1.xyz, r0 + add r0.xyz, r1, -c4 + nrm r2.xyz, r0 + dp3 r0.x, v1, c18 + dp3 r0.y, v1, c19 + dp3 r0.z, v1, c20 + nrm r3.xyz, r0 + dp3 r0.x, r2, r3 + add r2.xyz, r1, -c5 + add r1.xyz, r1, -c6 + nrm r4.xyz, r1 + dp3 r0.z, r4, r3 + nrm r1.xyz, r2 + dp3 r0.y, r1, r3 + max r0.xyz, r0, c25.x + dp3 r1.x, -c4, r3 + dp3 r1.y, -c5, r3 + dp3 r1.z, -c6, r3 + sge r2.xyz, r1, c25.x + mul r1.xyz, r1, r2 + mul r0.xyz, r0, r2 + log r2.x, r0.x + log r2.y, r0.y + log r2.z, r0.z + mul r0.xyz, r2, c3.w + exp r0.y, r0.y + mul r2.xyz, r0.y, c11 + exp r0.x, r0.x + exp r0.y, r0.z + mad r0.xzw, r0.x, c10.xyyz, r2.xyyz + mad r0.xyz, r0.y, c12, r0.xzww + mul oT1.xyz, r0, c3 + dp4 oPos.z, v0, c23 + dp4 r0.x, v0, c14 + max r0.x, r0.x, c25.x + min oT1.w, r0.x, c25.y + mul r0.xyz, r1.y, c8 + mad r0.xyz, r1.x, c7, r0 + mad r0.xyz, r1.z, c9, r0 + mov r1.xyz, c1 + mad r0.xyz, r0, r1, c2 + mul oT0.xyz, r0, v3 + mul oT0.w, v3.w, c1.w + dp4 r0.x, v0, c21 + dp4 r0.y, v0, c22 + dp4 r0.z, v0, c24 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT2.xy, v2 + +// approximately 63 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 5 +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r1.x, -cb0[3].xyzx, r0.xyzx +dp3 r1.y, -cb0[4].xyzx, r0.xyzx +dp3 r1.z, -cb0[5].xyzx, r0.xyzx +ge r2.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r1.xyz, r1.xyzx, r2.xyzx +mul r3.xyz, r1.yyyy, cb0[7].xyzx +mad r1.xyw, r1.xxxx, cb0[6].xyxz, r3.xyxz +mad r1.xyz, r1.zzzz, cb0[8].xyzx, r1.xywx +mad r1.xyz, r1.xyzx, cb0[0].xyzx, cb0[1].xyzx +mul o0.xyz, r1.xyzx, v3.xyzx +mul o0.w, v3.w, cb0[0].w +dp4 r1.x, v0.xyzw, cb0[15].xyzw +dp4 r1.y, v0.xyzw, cb0[16].xyzw +dp4 r1.z, v0.xyzw, cb0[17].xyzw +add r1.xyz, -r1.xyzx, cb0[12].xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mad r3.xyz, r1.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r1.w, r3.xyzx, r3.xyzx +rsq r1.w, r1.w +mul r3.xyz, r1.wwww, r3.xyzx +dp3 r3.x, r3.xyzx, r0.xyzx +mad r4.xyz, r1.xyzx, r0.wwww, -cb0[4].xyzx +mad r1.xyz, r1.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r4.xyzx, r4.xyzx +rsq r0.w, r0.w +mul r4.xyz, r0.wwww, r4.xyzx +dp3 r3.y, r4.xyzx, r0.xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mul r1.xyz, r0.wwww, r1.xyzx +dp3 r3.z, r1.xyzx, r0.xyzx +max r0.xyz, r3.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +mul r0.xyz, r2.xyzx, r0.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r1.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r1.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, v0.xyzw, cb0[22].xyzw +dp4 o3.y, v0.xyzw, cb0[23].xyzw +dp4 o3.z, v0.xyzw, cb0[24].xyzw +dp4 o3.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicVertexLightingTxVc[] = +{ + 68, 88, 66, 67, 172, 92, + 161, 128, 77, 17, 34, 173, + 170, 124, 195, 216, 46, 216, + 135, 106, 1, 0, 0, 0, + 80, 12, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 4, 4, 0, 0, 48, 11, + 0, 0, 196, 11, 0, 0, + 65, 111, 110, 57, 204, 3, + 0, 0, 204, 3, 0, 0, + 0, 2, 254, 255, 128, 3, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 13, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 14, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 25, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 15, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 16, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 17, 0, 228, 160, 2, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 228, 129, 13, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 0, 3, + 0, 0, 7, 128, 1, 0, + 228, 128, 4, 0, 228, 161, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 18, 0, 228, 160, 8, 0, + 0, 3, 0, 0, 2, 128, + 1, 0, 228, 144, 19, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 4, 128, 1, 0, + 228, 144, 20, 0, 228, 160, + 36, 0, 0, 2, 3, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 128, + 3, 0, 228, 128, 2, 0, + 0, 3, 2, 0, 7, 128, + 1, 0, 228, 128, 5, 0, + 228, 161, 2, 0, 0, 3, + 1, 0, 7, 128, 1, 0, + 228, 128, 6, 0, 228, 161, + 36, 0, 0, 2, 4, 0, + 7, 128, 1, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 4, 128, 4, 0, 228, 128, + 3, 0, 228, 128, 36, 0, + 0, 2, 1, 0, 7, 128, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 2, 128, + 1, 0, 228, 128, 3, 0, + 228, 128, 11, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 25, 0, 0, 160, + 8, 0, 0, 3, 1, 0, + 1, 128, 4, 0, 228, 161, + 3, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 2, 128, + 5, 0, 228, 161, 3, 0, + 228, 128, 8, 0, 0, 3, + 1, 0, 4, 128, 6, 0, + 228, 161, 3, 0, 228, 128, + 13, 0, 0, 3, 2, 0, + 7, 128, 1, 0, 228, 128, + 25, 0, 0, 160, 5, 0, + 0, 3, 1, 0, 7, 128, + 1, 0, 228, 128, 2, 0, + 228, 128, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 228, 128, + 15, 0, 0, 2, 2, 0, + 1, 128, 0, 0, 0, 128, + 15, 0, 0, 2, 2, 0, + 2, 128, 0, 0, 85, 128, + 15, 0, 0, 2, 2, 0, + 4, 128, 0, 0, 170, 128, + 5, 0, 0, 3, 0, 0, + 7, 128, 2, 0, 228, 128, + 3, 0, 255, 160, 14, 0, + 0, 2, 0, 0, 2, 128, + 0, 0, 85, 128, 5, 0, + 0, 3, 2, 0, 7, 128, + 0, 0, 85, 128, 11, 0, + 228, 160, 14, 0, 0, 2, + 0, 0, 1, 128, 0, 0, + 0, 128, 14, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 170, 128, 4, 0, 0, 4, + 0, 0, 13, 128, 0, 0, + 0, 128, 10, 0, 148, 160, + 2, 0, 148, 128, 4, 0, + 0, 4, 0, 0, 7, 128, + 0, 0, 85, 128, 12, 0, + 228, 160, 0, 0, 248, 128, + 5, 0, 0, 3, 1, 0, + 7, 224, 0, 0, 228, 128, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 23, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 14, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 25, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 25, 0, + 85, 160, 5, 0, 0, 3, + 0, 0, 7, 128, 1, 0, + 85, 128, 8, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 0, 128, + 7, 0, 228, 160, 0, 0, + 228, 128, 4, 0, 0, 4, + 0, 0, 7, 128, 1, 0, + 170, 128, 9, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 1, 0, 7, 128, + 1, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 7, 128, + 0, 0, 228, 128, 1, 0, + 228, 128, 2, 0, 228, 160, + 5, 0, 0, 3, 0, 0, + 7, 224, 0, 0, 228, 128, + 3, 0, 228, 144, 5, 0, + 0, 3, 0, 0, 8, 224, + 3, 0, 255, 144, 1, 0, + 255, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 21, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 22, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 24, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 2, 0, 3, 224, + 2, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 36, 7, 0, 0, 64, 0, + 1, 0, 201, 1, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 5, 0, 0, 0, 16, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 19, 0, 0, 0, + 16, 0, 0, 8, 34, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 20, 0, + 0, 0, 16, 0, 0, 8, + 66, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 9, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 9, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 9, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 29, 0, 0, 10, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 3, 0, + 0, 0, 86, 5, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 50, 0, + 0, 10, 178, 0, 16, 0, + 1, 0, 0, 0, 6, 0, + 16, 0, 1, 0, 0, 0, + 70, 136, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 70, 8, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 1, 0, + 0, 0, 166, 10, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 70, 3, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 8, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 16, 16, 0, 3, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 9, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 16, 0, 0, 7, + 34, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 52, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 47, 0, + 0, 5, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 143, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 1, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 136, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 70, 8, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 70, 3, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 32, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 140, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 116, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 123, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 132, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 67, 79, + 76, 79, 82, 0, 171, 171, + 79, 83, 71, 78, 132, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 110, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 119, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLightingVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLightingVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..17a65302be32942a21319fc494d4cea9e34cfbaa --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/BasicEffect_VSBasicVertexLightingVc.inc @@ -0,0 +1,673 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// COLOR 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 13 ( FLT, FLT, FLT, FLT) +// c14 cb0 14 4 ( FLT, FLT, FLT, FLT) +// c18 cb0 19 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c25, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 r0.x, v0, c15 + dp4 r0.y, v0, c16 + dp4 r0.z, v0, c17 + add r0.xyz, -r0, c13 + nrm r1.xyz, r0 + add r0.xyz, r1, -c4 + nrm r2.xyz, r0 + dp3 r0.x, v1, c18 + dp3 r0.y, v1, c19 + dp3 r0.z, v1, c20 + nrm r3.xyz, r0 + dp3 r0.x, r2, r3 + add r2.xyz, r1, -c5 + add r1.xyz, r1, -c6 + nrm r4.xyz, r1 + dp3 r0.z, r4, r3 + nrm r1.xyz, r2 + dp3 r0.y, r1, r3 + max r0.xyz, r0, c25.x + dp3 r1.x, -c4, r3 + dp3 r1.y, -c5, r3 + dp3 r1.z, -c6, r3 + sge r2.xyz, r1, c25.x + mul r1.xyz, r1, r2 + mul r0.xyz, r0, r2 + log r2.x, r0.x + log r2.y, r0.y + log r2.z, r0.z + mul r0.xyz, r2, c3.w + exp r0.y, r0.y + mul r2.xyz, r0.y, c11 + exp r0.x, r0.x + exp r0.y, r0.z + mad r0.xzw, r0.x, c10.xyyz, r2.xyyz + mad r0.xyz, r0.y, c12, r0.xzww + mul oT1.xyz, r0, c3 + dp4 oPos.z, v0, c23 + dp4 r0.x, v0, c14 + max r0.x, r0.x, c25.x + min oT1.w, r0.x, c25.y + mul r0.xyz, r1.y, c8 + mad r0.xyz, r1.x, c7, r0 + mad r0.xyz, r1.z, c9, r0 + mov r1.xyz, c1 + mad r0.xyz, r0, r1, c2 + mul oT0.xyz, r0, v2 + mul oT0.w, v2.w, c1.w + dp4 r0.x, v0, c21 + dp4 r0.y, v0, c22 + dp4 r0.z, v0, c24 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + +// approximately 62 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[26], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output_siv o2.xyzw, position +dcl_temps 5 +dp3 r0.x, v1.xyzx, cb0[19].xyzx +dp3 r0.y, v1.xyzx, cb0[20].xyzx +dp3 r0.z, v1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r1.x, -cb0[3].xyzx, r0.xyzx +dp3 r1.y, -cb0[4].xyzx, r0.xyzx +dp3 r1.z, -cb0[5].xyzx, r0.xyzx +ge r2.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r1.xyz, r1.xyzx, r2.xyzx +mul r3.xyz, r1.yyyy, cb0[7].xyzx +mad r1.xyw, r1.xxxx, cb0[6].xyxz, r3.xyxz +mad r1.xyz, r1.zzzz, cb0[8].xyzx, r1.xywx +mad r1.xyz, r1.xyzx, cb0[0].xyzx, cb0[1].xyzx +mul o0.xyz, r1.xyzx, v2.xyzx +mul o0.w, v2.w, cb0[0].w +dp4 r1.x, v0.xyzw, cb0[15].xyzw +dp4 r1.y, v0.xyzw, cb0[16].xyzw +dp4 r1.z, v0.xyzw, cb0[17].xyzw +add r1.xyz, -r1.xyzx, cb0[12].xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mad r3.xyz, r1.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r1.w, r3.xyzx, r3.xyzx +rsq r1.w, r1.w +mul r3.xyz, r1.wwww, r3.xyzx +dp3 r3.x, r3.xyzx, r0.xyzx +mad r4.xyz, r1.xyzx, r0.wwww, -cb0[4].xyzx +mad r1.xyz, r1.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r4.xyzx, r4.xyzx +rsq r0.w, r0.w +mul r4.xyz, r0.wwww, r4.xyzx +dp3 r3.y, r4.xyzx, r0.xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mul r1.xyz, r0.wwww, r1.xyzx +dp3 r3.z, r1.xyzx, r0.xyzx +max r0.xyz, r3.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +mul r0.xyz, r2.xyzx, r0.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r1.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r1.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, v0.xyzw, cb0[14].xyzw +dp4 o2.x, v0.xyzw, cb0[22].xyzw +dp4 o2.y, v0.xyzw, cb0[23].xyzw +dp4 o2.z, v0.xyzw, cb0[24].xyzw +dp4 o2.w, v0.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE BasicEffect_VSBasicVertexLightingVc[] = +{ + 68, 88, 66, 67, 92, 146, + 63, 46, 34, 123, 33, 120, + 42, 40, 45, 83, 123, 166, + 131, 218, 1, 0, 0, 0, + 204, 11, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 236, 3, 0, 0, 236, 10, + 0, 0, 96, 11, 0, 0, + 65, 111, 110, 57, 180, 3, + 0, 0, 180, 3, 0, 0, + 0, 2, 254, 255, 104, 3, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 0, 0, + 13, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 4, 0, 14, 0, 0, 0, + 0, 0, 0, 0, 19, 0, + 7, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 25, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 15, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 16, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 17, 0, 228, 160, 2, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 228, 129, 13, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 0, 3, + 0, 0, 7, 128, 1, 0, + 228, 128, 4, 0, 228, 161, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 18, 0, 228, 160, 8, 0, + 0, 3, 0, 0, 2, 128, + 1, 0, 228, 144, 19, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 4, 128, 1, 0, + 228, 144, 20, 0, 228, 160, + 36, 0, 0, 2, 3, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 128, + 3, 0, 228, 128, 2, 0, + 0, 3, 2, 0, 7, 128, + 1, 0, 228, 128, 5, 0, + 228, 161, 2, 0, 0, 3, + 1, 0, 7, 128, 1, 0, + 228, 128, 6, 0, 228, 161, + 36, 0, 0, 2, 4, 0, + 7, 128, 1, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 4, 128, 4, 0, 228, 128, + 3, 0, 228, 128, 36, 0, + 0, 2, 1, 0, 7, 128, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 2, 128, + 1, 0, 228, 128, 3, 0, + 228, 128, 11, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 25, 0, 0, 160, + 8, 0, 0, 3, 1, 0, + 1, 128, 4, 0, 228, 161, + 3, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 2, 128, + 5, 0, 228, 161, 3, 0, + 228, 128, 8, 0, 0, 3, + 1, 0, 4, 128, 6, 0, + 228, 161, 3, 0, 228, 128, + 13, 0, 0, 3, 2, 0, + 7, 128, 1, 0, 228, 128, + 25, 0, 0, 160, 5, 0, + 0, 3, 1, 0, 7, 128, + 1, 0, 228, 128, 2, 0, + 228, 128, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 228, 128, + 15, 0, 0, 2, 2, 0, + 1, 128, 0, 0, 0, 128, + 15, 0, 0, 2, 2, 0, + 2, 128, 0, 0, 85, 128, + 15, 0, 0, 2, 2, 0, + 4, 128, 0, 0, 170, 128, + 5, 0, 0, 3, 0, 0, + 7, 128, 2, 0, 228, 128, + 3, 0, 255, 160, 14, 0, + 0, 2, 0, 0, 2, 128, + 0, 0, 85, 128, 5, 0, + 0, 3, 2, 0, 7, 128, + 0, 0, 85, 128, 11, 0, + 228, 160, 14, 0, 0, 2, + 0, 0, 1, 128, 0, 0, + 0, 128, 14, 0, 0, 2, + 0, 0, 2, 128, 0, 0, + 170, 128, 4, 0, 0, 4, + 0, 0, 13, 128, 0, 0, + 0, 128, 10, 0, 148, 160, + 2, 0, 148, 128, 4, 0, + 0, 4, 0, 0, 7, 128, + 0, 0, 85, 128, 12, 0, + 228, 160, 0, 0, 248, 128, + 5, 0, 0, 3, 1, 0, + 7, 224, 0, 0, 228, 128, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 23, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 14, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 25, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 25, 0, + 85, 160, 5, 0, 0, 3, + 0, 0, 7, 128, 1, 0, + 85, 128, 8, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 0, 128, + 7, 0, 228, 160, 0, 0, + 228, 128, 4, 0, 0, 4, + 0, 0, 7, 128, 1, 0, + 170, 128, 9, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 1, 0, 7, 128, + 1, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 7, 128, + 0, 0, 228, 128, 1, 0, + 228, 128, 2, 0, 228, 160, + 5, 0, 0, 3, 0, 0, + 7, 224, 0, 0, 228, 128, + 2, 0, 228, 144, 5, 0, + 0, 3, 0, 0, 8, 224, + 2, 0, 255, 144, 1, 0, + 255, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 21, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 22, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 24, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 248, 6, 0, 0, 64, 0, + 1, 0, 190, 1, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 26, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 5, 0, 0, 0, 16, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 19, 0, 0, 0, + 16, 0, 0, 8, 34, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 20, 0, + 0, 0, 16, 0, 0, 8, + 66, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 9, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 9, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 9, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 29, 0, 0, 10, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 3, 0, + 0, 0, 86, 5, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 50, 0, + 0, 10, 178, 0, 16, 0, + 1, 0, 0, 0, 6, 0, + 16, 0, 1, 0, 0, 0, + 70, 136, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 70, 8, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 1, 0, + 0, 0, 166, 10, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 70, 3, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 8, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 16, 16, 0, 2, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 9, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 16, 0, 0, 7, + 34, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 52, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 47, 0, + 0, 5, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 143, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 1, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 136, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 70, 8, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 70, 3, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 32, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 108, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 99, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 15, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 67, + 79, 76, 79, 82, 0, 171, + 171, 171, 79, 83, 71, 78, + 100, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 80, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main.inc new file mode 100644 index 0000000000000000000000000000000000000000..25b3781649513f8fb58f054c77db404026bcdab5 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main.inc @@ -0,0 +1,399 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TANGENT 0 xyzw 2 NONE float xyzw +// TEXCOORD 0 xy 3 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float xyz +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float xyzw +// TEXCOORD 5 xyz 7 NONE float xyz +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 1 1 ( FLT, FLT, FLT, FLT) +// c2 cb2 0 3 ( FLT, FLT, FLT, FLT) +// c5 cb2 4 4 ( FLT, FLT, FLT, FLT) +// c9 cb2 16 2 ( FLT, FLT, FLT, FLT) +// c11 cb2 20 1 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c12, 1, 0, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dp4 oPos.z, v0, c7 + mad r0.xyz, v3.xyxw, c12.xxyw, c12.yyxw + dp3 oT1.x, r0, c9.xyww + dp3 oT1.y, r0, c10.xyww + dp3 oT2.x, v1, c2 + dp3 oT2.y, v1, c3 + dp3 oT2.z, v1, c4 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c4 + add oT4.xyz, -r0, c11 + mov oT3.xyz, r0 + dp4 r0.x, v0, c5 + dp4 r0.y, v0, c6 + dp4 r0.z, v0, c8 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0, c1 + mov oT5, v2 + mov oT6.xyz, v1 + +// approximately 20 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_constantbuffer CB2[21], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_input v3.xy +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output o4.xyz +dcl_output o5.xyz +dcl_output o6.xyzw +dcl_output o7.xyz +dcl_temps 1 +dp4 o0.x, v0.xyzw, cb2[4].xyzw +dp4 o0.y, v0.xyzw, cb2[5].xyzw +dp4 o0.z, v0.xyzw, cb2[6].xyzw +dp4 o0.w, v0.xyzw, cb2[7].xyzw +mov o1.xyzw, cb0[1].xyzw +mov r0.xy, v3.xyxx +mov r0.z, l(1.000000) +dp3 o2.x, r0.xyzx, cb2[16].xywx +dp3 o2.y, r0.xyzx, cb2[17].xywx +dp3 o3.x, v1.xyzx, cb2[0].xyzx +dp3 o3.y, v1.xyzx, cb2[1].xyzx +dp3 o3.z, v1.xyzx, cb2[2].xyzx +dp4 r0.x, v0.xyzw, cb2[0].xyzw +dp4 r0.y, v0.xyzw, cb2[1].xyzw +dp4 r0.z, v0.xyzw, cb2[2].xyzw +mov o4.xyz, r0.xyzx +add o5.xyz, -r0.xyzx, cb2[20].xyzx +mov o6.xyzw, v2.xyzw +mov o7.xyz, v1.xyzx +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLEffect_main[] = +{ + 68, 88, 66, 67, 186, 106, + 164, 207, 220, 89, 167, 54, + 144, 180, 62, 36, 5, 95, + 42, 136, 1, 0, 0, 0, + 144, 6, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 32, 2, 0, 0, 16, 5, + 0, 0, 164, 5, 0, 0, + 65, 111, 110, 57, 232, 1, + 0, 0, 232, 1, 0, 0, + 0, 2, 254, 255, 132, 1, + 0, 0, 100, 0, 0, 0, + 5, 0, 36, 0, 0, 0, + 96, 0, 0, 0, 96, 0, + 0, 0, 36, 0, 1, 0, + 96, 0, 0, 0, 1, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 3, 0, 2, 0, 0, 0, + 0, 0, 2, 0, 4, 0, + 4, 0, 5, 0, 0, 0, + 0, 0, 2, 0, 16, 0, + 2, 0, 9, 0, 0, 0, + 0, 0, 2, 0, 20, 0, + 1, 0, 11, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 12, 0, 15, 160, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 7, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 128, 3, 0, + 196, 144, 12, 0, 208, 160, + 12, 0, 197, 160, 8, 0, + 0, 3, 1, 0, 1, 224, + 0, 0, 228, 128, 9, 0, + 244, 160, 8, 0, 0, 3, + 1, 0, 2, 224, 0, 0, + 228, 128, 10, 0, 244, 160, + 8, 0, 0, 3, 2, 0, + 1, 224, 1, 0, 228, 144, + 2, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 2, 224, + 1, 0, 228, 144, 3, 0, + 228, 160, 8, 0, 0, 3, + 2, 0, 4, 224, 1, 0, + 228, 144, 4, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 3, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 4, 0, 228, 160, + 2, 0, 0, 3, 4, 0, + 7, 224, 0, 0, 228, 129, + 11, 0, 228, 160, 1, 0, + 0, 2, 3, 0, 7, 224, + 0, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 5, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 6, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 8, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 170, 128, 0, 0, + 228, 160, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 170, 128, + 1, 0, 0, 2, 0, 0, + 15, 224, 1, 0, 228, 160, + 1, 0, 0, 2, 5, 0, + 15, 224, 2, 0, 228, 144, + 1, 0, 0, 2, 6, 0, + 7, 224, 1, 0, 228, 144, + 255, 255, 0, 0, 83, 72, + 68, 82, 232, 2, 0, 0, + 64, 0, 1, 0, 186, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 2, 0, 0, 0, + 21, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 3, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 4, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 5, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 6, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 7, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 4, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 6, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 7, 0, 0, 0, + 54, 0, 0, 6, 242, 32, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 5, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 3, 0, + 0, 0, 54, 0, 0, 5, + 66, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 16, 0, + 0, 8, 18, 32, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 131, 32, 0, 2, 0, + 0, 0, 16, 0, 0, 0, + 16, 0, 0, 8, 34, 32, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 131, 32, 0, + 2, 0, 0, 0, 17, 0, + 0, 0, 16, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 16, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 16, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 2, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 9, 114, 32, 16, 0, + 5, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 20, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 6, 0, 0, 0, 70, 30, + 16, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 7, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 140, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 116, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 123, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 15, 0, 0, 131, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 3, 3, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 84, + 65, 78, 71, 69, 78, 84, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 79, 83, + 71, 78, 228, 0, 0, 0, + 8, 0, 0, 0, 8, 0, + 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 12, + 0, 0, 218, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 7, 8, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main1Bones.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main1Bones.inc new file mode 100644 index 0000000000000000000000000000000000000000..e866958eab7baf4f5fc3285477260f84ed3a42e4 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main1Bones.inc @@ -0,0 +1,572 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TANGENT 0 xyzw 2 NONE float xyzw +// TEXCOORD 0 xy 3 NONE float xy +// BLENDINDICES 0 xyzw 4 NONE uint x +// BLENDWEIGHT 0 xyzw 5 NONE float x +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float xyz +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float xyzw +// TEXCOORD 5 xyz 7 NONE float xyz +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb4 0 216 ( FLT, FLT, FLT, FLT) +// c217 cb0 1 1 ( FLT, FLT, FLT, FLT) +// c218 cb2 0 3 ( FLT, FLT, FLT, FLT) +// c221 cb2 4 4 ( FLT, FLT, FLT, FLT) +// c225 cb2 16 2 ( FLT, FLT, FLT, FLT) +// c227 cb2 20 1 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c216 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c228, 3, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + dcl_texcoord5 v5 + mul r0.x, v4.x, c228.x + mova a0.x, r0.x + mul r0, v5.x, c0[a0.x] + dp3 oT5.x, v2, r0 + mul r1, v5.x, c1[a0.x] + mul r2, v5.x, c2[a0.x] + dp3 oT5.y, v2, r1 + dp3 oT5.z, v2, r2 + dp4 r3.x, v0, r0 + dp3 r0.x, v1, r0 + dp4 r3.y, v0, r1 + dp3 r0.y, v1, r1 + dp4 r3.z, v0, r2 + dp3 r0.z, v1, r2 + mov r3.w, v0.w + dp4 oPos.z, r3, c223 + mad r1.xyz, v3.xyxw, c228.yyzw, c228.zzyw + dp3 oT1.x, r1, c225.xyww + dp3 oT1.y, r1, c226.xyww + dp3 oT2.x, r0, c218 + dp3 oT2.y, r0, c219 + dp3 oT2.z, r0, c220 + mov oT6.xyz, r0 + dp4 r0.x, r3, c218 + dp4 r0.y, r3, c219 + dp4 r0.z, r3, c220 + add oT4.xyz, -r0, c227 + mov oT3.xyz, r0 + dp4 r0.x, r3, c221 + dp4 r0.y, r3, c222 + dp4 r0.z, r3, c224 + mad oPos.xy, r0.z, c216, r0 + mov oPos.w, r0.z + mov oT0, c217 + mov oT5.w, v2.w + +// approximately 35 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_constantbuffer CB2[21], immediateIndexed +dcl_constantbuffer CB4[216], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_input v3.xy +dcl_input v4.x +dcl_input v5.x +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output o4.xyz +dcl_output o5.xyz +dcl_output o6.xyzw +dcl_output o7.xyz +dcl_temps 5 +imul null, r0.x, v4.x, l(3) +mul r1.xyzw, v5.xxxx, cb4[r0.x + 0].xyzw +dp4 r2.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v5.xxxx, cb4[r0.x + 1].xyzw +mul r0.xyzw, v5.xxxx, cb4[r0.x + 2].xyzw +dp4 r2.y, v0.xyzw, r3.xyzw +dp4 r2.z, v0.xyzw, r0.xyzw +mov r2.w, v0.w +dp4 o0.x, r2.xyzw, cb2[4].xyzw +dp4 o0.y, r2.xyzw, cb2[5].xyzw +dp4 o0.z, r2.xyzw, cb2[6].xyzw +dp4 o0.w, r2.xyzw, cb2[7].xyzw +mov o1.xyzw, cb0[1].xyzw +mov r4.xy, v3.xyxx +mov r4.z, l(1.000000) +dp3 o2.x, r4.xyzx, cb2[16].xywx +dp3 o2.y, r4.xyzx, cb2[17].xywx +dp3 r4.x, v1.xyzx, r1.xyzx +dp3 o6.x, v2.xyzx, r1.xyzx +dp3 r4.y, v1.xyzx, r3.xyzx +dp3 o6.y, v2.xyzx, r3.xyzx +dp3 r4.z, v1.xyzx, r0.xyzx +dp3 o6.z, v2.xyzx, r0.xyzx +dp3 o3.x, r4.xyzx, cb2[0].xyzx +dp3 o3.y, r4.xyzx, cb2[1].xyzx +dp3 o3.z, r4.xyzx, cb2[2].xyzx +mov o7.xyz, r4.xyzx +dp4 r0.x, r2.xyzw, cb2[0].xyzw +dp4 r0.y, r2.xyzw, cb2[1].xyzw +dp4 r0.z, r2.xyzw, cb2[2].xyzw +mov o4.xyz, r0.xyzx +add o5.xyz, -r0.xyzx, cb2[20].xyzx +mov o6.w, v2.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLEffect_main1Bones[] = +{ + 68, 88, 66, 67, 197, 121, + 50, 131, 90, 182, 119, 8, + 10, 66, 229, 37, 38, 24, + 170, 137, 1, 0, 0, 0, + 192, 9, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 56, 3, 0, 0, 244, 7, + 0, 0, 212, 8, 0, 0, + 65, 111, 110, 57, 0, 3, + 0, 0, 0, 3, 0, 0, + 0, 2, 254, 255, 144, 2, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 4, 0, 0, 0, + 216, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 1, 0, 217, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 3, 0, 218, 0, 0, 0, + 0, 0, 2, 0, 4, 0, + 4, 0, 221, 0, 0, 0, + 0, 0, 2, 0, 16, 0, + 2, 0, 225, 0, 0, 0, + 0, 0, 2, 0, 20, 0, + 1, 0, 227, 0, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 228, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 5, 128, + 5, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 1, 128, + 4, 0, 0, 144, 228, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 1, 176, 0, 0, + 0, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 5, 0, + 0, 144, 0, 32, 228, 160, + 0, 0, 0, 176, 8, 0, + 0, 3, 5, 0, 1, 224, + 2, 0, 228, 144, 0, 0, + 228, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 5, 0, + 0, 144, 1, 32, 228, 160, + 0, 0, 0, 176, 5, 0, + 0, 4, 2, 0, 15, 128, + 5, 0, 0, 144, 2, 32, + 228, 160, 0, 0, 0, 176, + 8, 0, 0, 3, 5, 0, + 2, 224, 2, 0, 228, 144, + 1, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 4, 224, + 2, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 3, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 0, 0, 228, 128, 9, 0, + 0, 3, 3, 0, 2, 128, + 0, 0, 228, 144, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 1, 0, 228, 128, + 9, 0, 0, 3, 3, 0, + 4, 128, 0, 0, 228, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 1, 0, 0, 2, + 3, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 0, 0, 4, 192, 3, 0, + 228, 128, 223, 0, 228, 160, + 4, 0, 0, 4, 1, 0, + 7, 128, 3, 0, 196, 144, + 228, 0, 229, 160, 228, 0, + 218, 160, 8, 0, 0, 3, + 1, 0, 1, 224, 1, 0, + 228, 128, 225, 0, 244, 160, + 8, 0, 0, 3, 1, 0, + 2, 224, 1, 0, 228, 128, + 226, 0, 244, 160, 8, 0, + 0, 3, 2, 0, 1, 224, + 0, 0, 228, 128, 218, 0, + 228, 160, 8, 0, 0, 3, + 2, 0, 2, 224, 0, 0, + 228, 128, 219, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 4, 224, 0, 0, 228, 128, + 220, 0, 228, 160, 1, 0, + 0, 2, 6, 0, 7, 224, + 0, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 1, 128, + 3, 0, 228, 128, 218, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 3, 0, + 228, 128, 219, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 3, 0, 228, 128, + 220, 0, 228, 160, 2, 0, + 0, 3, 4, 0, 7, 224, + 0, 0, 228, 129, 227, 0, + 228, 160, 1, 0, 0, 2, + 3, 0, 7, 224, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 3, 0, + 228, 128, 221, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 3, 0, 228, 128, + 222, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 3, 0, 228, 128, 224, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 216, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 217, 0, 228, 160, 1, 0, + 0, 2, 5, 0, 8, 224, + 2, 0, 255, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 180, 4, 0, 0, 64, 0, + 1, 0, 45, 1, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 2, 0, 0, 0, 21, 0, + 0, 0, 89, 8, 0, 4, + 70, 142, 32, 0, 4, 0, + 0, 0, 216, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 18, 16, + 16, 0, 4, 0, 0, 0, + 95, 0, 0, 3, 18, 16, + 16, 0, 5, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 5, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 6, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 7, 0, 0, 0, 104, 0, + 0, 2, 5, 0, 0, 0, + 38, 0, 0, 8, 0, 208, + 0, 0, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 16, + 16, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 3, 0, + 0, 0, 56, 0, 0, 9, + 242, 0, 16, 0, 1, 0, + 0, 0, 6, 16, 16, 0, + 5, 0, 0, 0, 70, 142, + 32, 4, 4, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 6, 16, 16, 0, 5, 0, + 0, 0, 70, 142, 32, 6, + 4, 0, 0, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 5, 0, 0, 0, + 70, 142, 32, 6, 4, 0, + 0, 0, 2, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 7, + 34, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 17, 0, 0, 7, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 58, 16, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 4, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 5, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 6, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 7, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 16, 16, 0, + 3, 0, 0, 0, 54, 0, + 0, 5, 66, 0, 16, 0, + 4, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 16, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 131, 32, 0, + 2, 0, 0, 0, 16, 0, + 0, 0, 16, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 131, + 32, 0, 2, 0, 0, 0, + 17, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 4, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 32, 16, 0, 6, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 34, 32, 16, 0, + 6, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 66, 0, 16, 0, 4, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 66, 32, + 16, 0, 6, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 8, 18, 32, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 130, 32, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 34, 32, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 16, 0, 0, 8, + 66, 32, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 2, 0, 0, 0, 54, 0, + 0, 5, 114, 32, 16, 0, + 7, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 9, + 114, 32, 16, 0, 5, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 20, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 6, 0, + 0, 0, 58, 16, 16, 0, + 2, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 216, 0, 0, 0, 6, 0, + 0, 0, 8, 0, 0, 0, + 152, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 164, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 171, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 179, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 3, 3, 0, 0, + 188, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 4, 0, + 0, 0, 15, 1, 0, 0, + 201, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 15, 1, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 65, 78, 71, 69, + 78, 84, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 66, 76, 69, 78, 68, 73, + 78, 68, 73, 67, 69, 83, + 0, 66, 76, 69, 78, 68, + 87, 69, 73, 71, 72, 84, + 0, 171, 171, 171, 79, 83, + 71, 78, 228, 0, 0, 0, + 8, 0, 0, 0, 8, 0, + 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 12, + 0, 0, 218, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 7, 8, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main1BonesVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main1BonesVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..b12336a3c44b3632bb56dfad19ce7ceadaba971f --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main1BonesVc.inc @@ -0,0 +1,586 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TANGENT 0 xyzw 2 NONE float xyzw +// COLOR 0 xyzw 3 NONE float xyzw +// TEXCOORD 0 xy 4 NONE float xy +// BLENDINDICES 0 xyzw 5 NONE uint x +// BLENDWEIGHT 0 xyzw 6 NONE float x +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float xyz +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float xyzw +// TEXCOORD 5 xyz 7 NONE float xyz +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb4 0 216 ( FLT, FLT, FLT, FLT) +// c217 cb0 1 1 ( FLT, FLT, FLT, FLT) +// c218 cb2 0 3 ( FLT, FLT, FLT, FLT) +// c221 cb2 4 4 ( FLT, FLT, FLT, FLT) +// c225 cb2 16 2 ( FLT, FLT, FLT, FLT) +// c227 cb2 20 1 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c216 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c228, 3, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + dcl_texcoord5 v5 + dcl_texcoord6 v6 + mul r0.x, v5.x, c228.x + mova a0.x, r0.x + mul r0, v6.x, c0[a0.x] + dp3 oT5.x, v2, r0 + mul r1, v6.x, c1[a0.x] + mul r2, v6.x, c2[a0.x] + dp3 oT5.y, v2, r1 + dp3 oT5.z, v2, r2 + dp4 r3.x, v0, r0 + dp3 r0.x, v1, r0 + dp4 r3.y, v0, r1 + dp3 r0.y, v1, r1 + dp4 r3.z, v0, r2 + dp3 r0.z, v1, r2 + mov r3.w, v0.w + dp4 oPos.z, r3, c223 + mul oT0, v3, c217 + mad r1.xyz, v4.xyxw, c228.yyzw, c228.zzyw + dp3 oT1.x, r1, c225.xyww + dp3 oT1.y, r1, c226.xyww + dp3 oT2.x, r0, c218 + dp3 oT2.y, r0, c219 + dp3 oT2.z, r0, c220 + mov oT6.xyz, r0 + dp4 r0.x, r3, c218 + dp4 r0.y, r3, c219 + dp4 r0.z, r3, c220 + add oT4.xyz, -r0, c227 + mov oT3.xyz, r0 + dp4 r0.x, r3, c221 + dp4 r0.y, r3, c222 + dp4 r0.z, r3, c224 + mad oPos.xy, r0.z, c216, r0 + mov oPos.w, r0.z + mov oT5.w, v2.w + +// approximately 35 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_constantbuffer CB2[21], immediateIndexed +dcl_constantbuffer CB4[216], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_input v3.xyzw +dcl_input v4.xy +dcl_input v5.x +dcl_input v6.x +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output o4.xyz +dcl_output o5.xyz +dcl_output o6.xyzw +dcl_output o7.xyz +dcl_temps 5 +imul null, r0.x, v5.x, l(3) +mul r1.xyzw, v6.xxxx, cb4[r0.x + 0].xyzw +dp4 r2.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v6.xxxx, cb4[r0.x + 1].xyzw +mul r0.xyzw, v6.xxxx, cb4[r0.x + 2].xyzw +dp4 r2.y, v0.xyzw, r3.xyzw +dp4 r2.z, v0.xyzw, r0.xyzw +mov r2.w, v0.w +dp4 o0.x, r2.xyzw, cb2[4].xyzw +dp4 o0.y, r2.xyzw, cb2[5].xyzw +dp4 o0.z, r2.xyzw, cb2[6].xyzw +dp4 o0.w, r2.xyzw, cb2[7].xyzw +mul o1.xyzw, v3.xyzw, cb0[1].xyzw +mov r4.xy, v4.xyxx +mov r4.z, l(1.000000) +dp3 o2.x, r4.xyzx, cb2[16].xywx +dp3 o2.y, r4.xyzx, cb2[17].xywx +dp3 r4.x, v1.xyzx, r1.xyzx +dp3 o6.x, v2.xyzx, r1.xyzx +dp3 r4.y, v1.xyzx, r3.xyzx +dp3 o6.y, v2.xyzx, r3.xyzx +dp3 r4.z, v1.xyzx, r0.xyzx +dp3 o6.z, v2.xyzx, r0.xyzx +dp3 o3.x, r4.xyzx, cb2[0].xyzx +dp3 o3.y, r4.xyzx, cb2[1].xyzx +dp3 o3.z, r4.xyzx, cb2[2].xyzx +mov o7.xyz, r4.xyzx +dp4 r0.x, r2.xyzw, cb2[0].xyzw +dp4 r0.y, r2.xyzw, cb2[1].xyzw +dp4 r0.z, r2.xyzw, cb2[2].xyzw +mov o4.xyz, r0.xyzx +add o5.xyz, -r0.xyzx, cb2[20].xyzx +mov o6.w, v2.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLEffect_main1BonesVc[] = +{ + 68, 88, 66, 67, 122, 111, + 179, 134, 211, 148, 172, 150, + 73, 190, 170, 28, 244, 155, + 105, 24, 1, 0, 0, 0, + 0, 10, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 72, 3, 0, 0, 24, 8, + 0, 0, 20, 9, 0, 0, + 65, 111, 110, 57, 16, 3, + 0, 0, 16, 3, 0, 0, + 0, 2, 254, 255, 160, 2, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 4, 0, 0, 0, + 216, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 1, 0, 217, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 3, 0, 218, 0, 0, 0, + 0, 0, 2, 0, 4, 0, + 4, 0, 221, 0, 0, 0, + 0, 0, 2, 0, 16, 0, + 2, 0, 225, 0, 0, 0, + 0, 0, 2, 0, 20, 0, + 1, 0, 227, 0, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 228, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 5, 128, + 5, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 6, 128, + 6, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 1, 128, + 5, 0, 0, 144, 228, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 1, 176, 0, 0, + 0, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 6, 0, + 0, 144, 0, 32, 228, 160, + 0, 0, 0, 176, 8, 0, + 0, 3, 5, 0, 1, 224, + 2, 0, 228, 144, 0, 0, + 228, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 6, 0, + 0, 144, 1, 32, 228, 160, + 0, 0, 0, 176, 5, 0, + 0, 4, 2, 0, 15, 128, + 6, 0, 0, 144, 2, 32, + 228, 160, 0, 0, 0, 176, + 8, 0, 0, 3, 5, 0, + 2, 224, 2, 0, 228, 144, + 1, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 4, 224, + 2, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 3, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 0, 0, 228, 128, 9, 0, + 0, 3, 3, 0, 2, 128, + 0, 0, 228, 144, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 1, 0, 228, 128, + 9, 0, 0, 3, 3, 0, + 4, 128, 0, 0, 228, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 1, 0, 0, 2, + 3, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 0, 0, 4, 192, 3, 0, + 228, 128, 223, 0, 228, 160, + 5, 0, 0, 3, 0, 0, + 15, 224, 3, 0, 228, 144, + 217, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 4, 0, 196, 144, 228, 0, + 229, 160, 228, 0, 218, 160, + 8, 0, 0, 3, 1, 0, + 1, 224, 1, 0, 228, 128, + 225, 0, 244, 160, 8, 0, + 0, 3, 1, 0, 2, 224, + 1, 0, 228, 128, 226, 0, + 244, 160, 8, 0, 0, 3, + 2, 0, 1, 224, 0, 0, + 228, 128, 218, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 2, 224, 0, 0, 228, 128, + 219, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 4, 224, + 0, 0, 228, 128, 220, 0, + 228, 160, 1, 0, 0, 2, + 6, 0, 7, 224, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 3, 0, + 228, 128, 218, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 3, 0, 228, 128, + 219, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 3, 0, 228, 128, 220, 0, + 228, 160, 2, 0, 0, 3, + 4, 0, 7, 224, 0, 0, + 228, 129, 227, 0, 228, 160, + 1, 0, 0, 2, 3, 0, + 7, 224, 0, 0, 228, 128, + 9, 0, 0, 3, 0, 0, + 1, 128, 3, 0, 228, 128, + 221, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 3, 0, 228, 128, 222, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 3, 0, + 228, 128, 224, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 216, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 5, 0, 8, 224, 2, 0, + 255, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 200, 4, + 0, 0, 64, 0, 1, 0, + 50, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 2, 0, + 0, 0, 21, 0, 0, 0, + 89, 8, 0, 4, 70, 142, + 32, 0, 4, 0, 0, 0, + 216, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 4, 0, 0, 0, 95, 0, + 0, 3, 18, 16, 16, 0, + 5, 0, 0, 0, 95, 0, + 0, 3, 18, 16, 16, 0, + 6, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 4, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 5, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 6, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 7, 0, + 0, 0, 104, 0, 0, 2, + 5, 0, 0, 0, 38, 0, + 0, 8, 0, 208, 0, 0, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 16, 16, 0, + 5, 0, 0, 0, 1, 64, + 0, 0, 3, 0, 0, 0, + 56, 0, 0, 9, 242, 0, + 16, 0, 1, 0, 0, 0, + 6, 16, 16, 0, 6, 0, + 0, 0, 70, 142, 32, 4, + 4, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 7, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 3, 0, 0, 0, 6, 16, + 16, 0, 6, 0, 0, 0, + 70, 142, 32, 6, 4, 0, + 0, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 6, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 7, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 17, 0, + 0, 7, 66, 0, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 0, 16, 0, 2, 0, + 0, 0, 58, 16, 16, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 4, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 6, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 7, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 16, 16, 0, + 4, 0, 0, 0, 54, 0, + 0, 5, 66, 0, 16, 0, + 4, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 16, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 131, 32, 0, + 2, 0, 0, 0, 16, 0, + 0, 0, 16, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 131, + 32, 0, 2, 0, 0, 0, + 17, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 4, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 32, 16, 0, 6, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 34, 32, 16, 0, + 6, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 66, 0, 16, 0, 4, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 66, 32, + 16, 0, 6, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 8, 18, 32, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 130, 32, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 34, 32, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 16, 0, 0, 8, + 66, 32, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 2, 0, 0, 0, 54, 0, + 0, 5, 114, 32, 16, 0, + 7, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 9, + 114, 32, 16, 0, 5, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 20, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 6, 0, + 0, 0, 58, 16, 16, 0, + 2, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 244, 0, 0, 0, 7, 0, + 0, 0, 8, 0, 0, 0, + 176, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 188, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 195, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 203, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 15, 0, 0, + 209, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 3, 3, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 5, 0, + 0, 0, 15, 1, 0, 0, + 231, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 1, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 65, 78, 71, 69, + 78, 84, 0, 67, 79, 76, + 79, 82, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 66, 76, 69, 78, 68, 73, + 78, 68, 73, 67, 69, 83, + 0, 66, 76, 69, 78, 68, + 87, 69, 73, 71, 72, 84, + 0, 171, 79, 83, 71, 78, + 228, 0, 0, 0, 8, 0, + 0, 0, 8, 0, 0, 0, + 200, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 212, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 12, 0, 0, + 218, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 8, 0, 0, + 218, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 8, 0, 0, + 218, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 7, 8, 0, 0, + 218, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 7, 8, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main2Bones.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main2Bones.inc new file mode 100644 index 0000000000000000000000000000000000000000..847b128cf26f809e0d47e56104a459a55c5669cc --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main2Bones.inc @@ -0,0 +1,616 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TANGENT 0 xyzw 2 NONE float xyzw +// TEXCOORD 0 xy 3 NONE float xy +// BLENDINDICES 0 xyzw 4 NONE uint xy +// BLENDWEIGHT 0 xyzw 5 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float xyz +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float xyzw +// TEXCOORD 5 xyz 7 NONE float xyz +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb4 0 216 ( FLT, FLT, FLT, FLT) +// c217 cb0 1 1 ( FLT, FLT, FLT, FLT) +// c218 cb2 0 3 ( FLT, FLT, FLT, FLT) +// c221 cb2 4 4 ( FLT, FLT, FLT, FLT) +// c225 cb2 16 2 ( FLT, FLT, FLT, FLT) +// c227 cb2 20 1 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c216 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c228, 3, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + dcl_texcoord5 v5 + mul r0.xy, v4, c228.x + mova a0.xy, r0.yxzw + mul r0, v5.y, c0[a0.x] + mad r0, c0[a0.y], v5.x, r0 + dp3 oT5.x, v2, r0 + mul r1, v5.y, c1[a0.x] + mul r2, v5.y, c2[a0.x] + mad r2, c2[a0.y], v5.x, r2 + mad r1, c1[a0.y], v5.x, r1 + dp3 oT5.y, v2, r1 + dp3 oT5.z, v2, r2 + dp4 r3.x, v0, r0 + dp3 r0.x, v1, r0 + dp4 r3.y, v0, r1 + dp3 r0.y, v1, r1 + dp4 r3.z, v0, r2 + dp3 r0.z, v1, r2 + mov r3.w, v0.w + dp4 oPos.z, r3, c223 + mad r1.xyz, v3.xyxw, c228.yyzw, c228.zzyw + dp3 oT1.x, r1, c225.xyww + dp3 oT1.y, r1, c226.xyww + dp3 oT2.x, r0, c218 + dp3 oT2.y, r0, c219 + dp3 oT2.z, r0, c220 + mov oT6.xyz, r0 + dp4 r0.x, r3, c218 + dp4 r0.y, r3, c219 + dp4 r0.z, r3, c220 + add oT4.xyz, -r0, c227 + mov oT3.xyz, r0 + dp4 r0.x, r3, c221 + dp4 r0.y, r3, c222 + dp4 r0.z, r3, c224 + mad oPos.xy, r0.z, c216, r0 + mov oPos.w, r0.z + mov oT0, c217 + mov oT5.w, v2.w + +// approximately 38 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_constantbuffer CB2[21], immediateIndexed +dcl_constantbuffer CB4[216], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_input v3.xy +dcl_input v4.xy +dcl_input v5.xy +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output o4.xyz +dcl_output o5.xyz +dcl_output o6.xyzw +dcl_output o7.xyz +dcl_temps 5 +imul null, r0.xy, v4.xyxx, l(3, 3, 0, 0) +mul r1.xyzw, v5.yyyy, cb4[r0.y + 0].xyzw +mad r1.xyzw, cb4[r0.x + 0].xyzw, v5.xxxx, r1.xyzw +dp4 r2.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v5.yyyy, cb4[r0.y + 1].xyzw +mad r3.xyzw, cb4[r0.x + 1].xyzw, v5.xxxx, r3.xyzw +dp4 r2.y, v0.xyzw, r3.xyzw +mul r4.xyzw, v5.yyyy, cb4[r0.y + 2].xyzw +mad r0.xyzw, cb4[r0.x + 2].xyzw, v5.xxxx, r4.xyzw +dp4 r2.z, v0.xyzw, r0.xyzw +mov r2.w, v0.w +dp4 o0.x, r2.xyzw, cb2[4].xyzw +dp4 o0.y, r2.xyzw, cb2[5].xyzw +dp4 o0.z, r2.xyzw, cb2[6].xyzw +dp4 o0.w, r2.xyzw, cb2[7].xyzw +mov o1.xyzw, cb0[1].xyzw +mov r4.xy, v3.xyxx +mov r4.z, l(1.000000) +dp3 o2.x, r4.xyzx, cb2[16].xywx +dp3 o2.y, r4.xyzx, cb2[17].xywx +dp3 r4.x, v1.xyzx, r1.xyzx +dp3 o6.x, v2.xyzx, r1.xyzx +dp3 r4.y, v1.xyzx, r3.xyzx +dp3 o6.y, v2.xyzx, r3.xyzx +dp3 r4.z, v1.xyzx, r0.xyzx +dp3 o6.z, v2.xyzx, r0.xyzx +dp3 o3.x, r4.xyzx, cb2[0].xyzx +dp3 o3.y, r4.xyzx, cb2[1].xyzx +dp3 o3.z, r4.xyzx, cb2[2].xyzx +mov o7.xyz, r4.xyzx +dp4 r0.x, r2.xyzw, cb2[0].xyzw +dp4 r0.y, r2.xyzw, cb2[1].xyzw +dp4 r0.z, r2.xyzw, cb2[2].xyzw +mov o4.xyz, r0.xyzx +add o5.xyz, -r0.xyzx, cb2[20].xyzx +mov o6.w, v2.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLEffect_main2Bones[] = +{ + 68, 88, 66, 67, 200, 61, + 157, 197, 213, 10, 37, 211, + 99, 247, 63, 150, 248, 58, + 224, 166, 1, 0, 0, 0, + 160, 10, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 128, 3, 0, 0, 212, 8, + 0, 0, 180, 9, 0, 0, + 65, 111, 110, 57, 72, 3, + 0, 0, 72, 3, 0, 0, + 0, 2, 254, 255, 216, 2, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 4, 0, 0, 0, + 216, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 1, 0, 217, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 3, 0, 218, 0, 0, 0, + 0, 0, 2, 0, 4, 0, + 4, 0, 221, 0, 0, 0, + 0, 0, 2, 0, 16, 0, + 2, 0, 225, 0, 0, 0, + 0, 0, 2, 0, 20, 0, + 1, 0, 227, 0, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 228, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 5, 128, + 5, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 3, 128, + 4, 0, 228, 144, 228, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 3, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 5, 0, + 85, 144, 0, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 0, 0, 15, 128, + 0, 32, 228, 160, 0, 0, + 85, 176, 5, 0, 0, 144, + 0, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 1, 224, + 2, 0, 228, 144, 0, 0, + 228, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 5, 0, + 85, 144, 1, 32, 228, 160, + 0, 0, 0, 176, 5, 0, + 0, 4, 2, 0, 15, 128, + 5, 0, 85, 144, 2, 32, + 228, 160, 0, 0, 0, 176, + 4, 0, 0, 5, 2, 0, + 15, 128, 2, 32, 228, 160, + 0, 0, 85, 176, 5, 0, + 0, 144, 2, 0, 228, 128, + 4, 0, 0, 5, 1, 0, + 15, 128, 1, 32, 228, 160, + 0, 0, 85, 176, 5, 0, + 0, 144, 1, 0, 228, 128, + 8, 0, 0, 3, 5, 0, + 2, 224, 2, 0, 228, 144, + 1, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 4, 224, + 2, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 3, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 0, 0, 228, 128, 9, 0, + 0, 3, 3, 0, 2, 128, + 0, 0, 228, 144, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 1, 0, 228, 128, + 9, 0, 0, 3, 3, 0, + 4, 128, 0, 0, 228, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 1, 0, 0, 2, + 3, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 0, 0, 4, 192, 3, 0, + 228, 128, 223, 0, 228, 160, + 4, 0, 0, 4, 1, 0, + 7, 128, 3, 0, 196, 144, + 228, 0, 229, 160, 228, 0, + 218, 160, 8, 0, 0, 3, + 1, 0, 1, 224, 1, 0, + 228, 128, 225, 0, 244, 160, + 8, 0, 0, 3, 1, 0, + 2, 224, 1, 0, 228, 128, + 226, 0, 244, 160, 8, 0, + 0, 3, 2, 0, 1, 224, + 0, 0, 228, 128, 218, 0, + 228, 160, 8, 0, 0, 3, + 2, 0, 2, 224, 0, 0, + 228, 128, 219, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 4, 224, 0, 0, 228, 128, + 220, 0, 228, 160, 1, 0, + 0, 2, 6, 0, 7, 224, + 0, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 1, 128, + 3, 0, 228, 128, 218, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 3, 0, + 228, 128, 219, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 3, 0, 228, 128, + 220, 0, 228, 160, 2, 0, + 0, 3, 4, 0, 7, 224, + 0, 0, 228, 129, 227, 0, + 228, 160, 1, 0, 0, 2, + 3, 0, 7, 224, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 3, 0, + 228, 128, 221, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 3, 0, 228, 128, + 222, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 3, 0, 228, 128, 224, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 216, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 217, 0, 228, 160, 1, 0, + 0, 2, 5, 0, 8, 224, + 2, 0, 255, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 76, 5, 0, 0, 64, 0, + 1, 0, 83, 1, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 2, 0, 0, 0, 21, 0, + 0, 0, 89, 8, 0, 4, + 70, 142, 32, 0, 4, 0, + 0, 0, 216, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 4, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 5, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 5, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 6, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 7, 0, 0, 0, 104, 0, + 0, 2, 5, 0, 0, 0, + 38, 0, 0, 11, 0, 208, + 0, 0, 50, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 56, 0, 0, 9, + 242, 0, 16, 0, 1, 0, + 0, 0, 86, 21, 16, 0, + 5, 0, 0, 0, 70, 142, + 32, 4, 4, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 4, + 4, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 5, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 17, 0, + 0, 7, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 3, 0, + 0, 0, 86, 21, 16, 0, + 5, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 1, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 6, 4, 0, + 0, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 5, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 17, 0, 0, 7, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 4, 0, 0, 0, 86, 21, + 16, 0, 5, 0, 0, 0, + 70, 142, 32, 6, 4, 0, + 0, 0, 2, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 6, + 4, 0, 0, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 5, 0, 0, 0, + 70, 14, 16, 0, 4, 0, + 0, 0, 17, 0, 0, 7, + 66, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 0, + 16, 0, 2, 0, 0, 0, + 58, 16, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 4, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 5, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 6, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 7, 0, 0, 0, 54, 0, + 0, 6, 242, 32, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 16, + 16, 0, 3, 0, 0, 0, + 54, 0, 0, 5, 66, 0, + 16, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 16, 0, 0, 8, + 18, 32, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 131, + 32, 0, 2, 0, 0, 0, + 16, 0, 0, 0, 16, 0, + 0, 8, 34, 32, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 131, 32, 0, 2, 0, + 0, 0, 17, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 18, 32, 16, 0, + 6, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 34, 32, + 16, 0, 6, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 4, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 7, + 66, 32, 16, 0, 6, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 18, 32, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 16, 0, 0, 8, + 34, 32, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 16, 0, + 0, 8, 66, 32, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 130, 32, 0, 2, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 7, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 2, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 9, 114, 32, 16, 0, + 5, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 20, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 6, 0, 0, 0, 58, 16, + 16, 0, 2, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 216, 0, 0, 0, + 6, 0, 0, 0, 8, 0, + 0, 0, 152, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 164, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 171, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 15, + 0, 0, 179, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 3, 3, + 0, 0, 188, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 4, 0, 0, 0, 15, 3, + 0, 0, 201, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 15, 3, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 78, 79, 82, 77, + 65, 76, 0, 84, 65, 78, + 71, 69, 78, 84, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 66, 76, 69, 78, + 68, 73, 78, 68, 73, 67, + 69, 83, 0, 66, 76, 69, + 78, 68, 87, 69, 73, 71, + 72, 84, 0, 171, 171, 171, + 79, 83, 71, 78, 228, 0, + 0, 0, 8, 0, 0, 0, + 8, 0, 0, 0, 200, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 212, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 218, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 218, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 8, 0, 0, 218, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 7, 8, 0, 0, 218, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 5, 0, 0, 0, + 7, 8, 0, 0, 218, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 6, 0, 0, 0, + 15, 0, 0, 0, 218, 0, + 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 7, 0, 0, 0, + 7, 8, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main2BonesVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main2BonesVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..5b85c12c7c9287f3cbc6a157aa5fe3dad74df130 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main2BonesVc.inc @@ -0,0 +1,629 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TANGENT 0 xyzw 2 NONE float xyzw +// COLOR 0 xyzw 3 NONE float xyzw +// TEXCOORD 0 xy 4 NONE float xy +// BLENDINDICES 0 xyzw 5 NONE uint xy +// BLENDWEIGHT 0 xyzw 6 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float xyz +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float xyzw +// TEXCOORD 5 xyz 7 NONE float xyz +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb4 0 216 ( FLT, FLT, FLT, FLT) +// c217 cb0 1 1 ( FLT, FLT, FLT, FLT) +// c218 cb2 0 3 ( FLT, FLT, FLT, FLT) +// c221 cb2 4 4 ( FLT, FLT, FLT, FLT) +// c225 cb2 16 2 ( FLT, FLT, FLT, FLT) +// c227 cb2 20 1 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c216 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c228, 3, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + dcl_texcoord5 v5 + dcl_texcoord6 v6 + mul r0.xy, v5, c228.x + mova a0.xy, r0.yxzw + mul r0, v6.y, c0[a0.x] + mad r0, c0[a0.y], v6.x, r0 + dp3 oT5.x, v2, r0 + mul r1, v6.y, c1[a0.x] + mul r2, v6.y, c2[a0.x] + mad r2, c2[a0.y], v6.x, r2 + mad r1, c1[a0.y], v6.x, r1 + dp3 oT5.y, v2, r1 + dp3 oT5.z, v2, r2 + dp4 r3.x, v0, r0 + dp3 r0.x, v1, r0 + dp4 r3.y, v0, r1 + dp3 r0.y, v1, r1 + dp4 r3.z, v0, r2 + dp3 r0.z, v1, r2 + mov r3.w, v0.w + dp4 oPos.z, r3, c223 + mul oT0, v3, c217 + mad r1.xyz, v4.xyxw, c228.yyzw, c228.zzyw + dp3 oT1.x, r1, c225.xyww + dp3 oT1.y, r1, c226.xyww + dp3 oT2.x, r0, c218 + dp3 oT2.y, r0, c219 + dp3 oT2.z, r0, c220 + mov oT6.xyz, r0 + dp4 r0.x, r3, c218 + dp4 r0.y, r3, c219 + dp4 r0.z, r3, c220 + add oT4.xyz, -r0, c227 + mov oT3.xyz, r0 + dp4 r0.x, r3, c221 + dp4 r0.y, r3, c222 + dp4 r0.z, r3, c224 + mad oPos.xy, r0.z, c216, r0 + mov oPos.w, r0.z + mov oT5.w, v2.w + +// approximately 38 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_constantbuffer CB2[21], immediateIndexed +dcl_constantbuffer CB4[216], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_input v3.xyzw +dcl_input v4.xy +dcl_input v5.xy +dcl_input v6.xy +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output o4.xyz +dcl_output o5.xyz +dcl_output o6.xyzw +dcl_output o7.xyz +dcl_temps 5 +imul null, r0.xy, v5.xyxx, l(3, 3, 0, 0) +mul r1.xyzw, v6.yyyy, cb4[r0.y + 0].xyzw +mad r1.xyzw, cb4[r0.x + 0].xyzw, v6.xxxx, r1.xyzw +dp4 r2.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v6.yyyy, cb4[r0.y + 1].xyzw +mad r3.xyzw, cb4[r0.x + 1].xyzw, v6.xxxx, r3.xyzw +dp4 r2.y, v0.xyzw, r3.xyzw +mul r4.xyzw, v6.yyyy, cb4[r0.y + 2].xyzw +mad r0.xyzw, cb4[r0.x + 2].xyzw, v6.xxxx, r4.xyzw +dp4 r2.z, v0.xyzw, r0.xyzw +mov r2.w, v0.w +dp4 o0.x, r2.xyzw, cb2[4].xyzw +dp4 o0.y, r2.xyzw, cb2[5].xyzw +dp4 o0.z, r2.xyzw, cb2[6].xyzw +dp4 o0.w, r2.xyzw, cb2[7].xyzw +mul o1.xyzw, v3.xyzw, cb0[1].xyzw +mov r4.xy, v4.xyxx +mov r4.z, l(1.000000) +dp3 o2.x, r4.xyzx, cb2[16].xywx +dp3 o2.y, r4.xyzx, cb2[17].xywx +dp3 r4.x, v1.xyzx, r1.xyzx +dp3 o6.x, v2.xyzx, r1.xyzx +dp3 r4.y, v1.xyzx, r3.xyzx +dp3 o6.y, v2.xyzx, r3.xyzx +dp3 r4.z, v1.xyzx, r0.xyzx +dp3 o6.z, v2.xyzx, r0.xyzx +dp3 o3.x, r4.xyzx, cb2[0].xyzx +dp3 o3.y, r4.xyzx, cb2[1].xyzx +dp3 o3.z, r4.xyzx, cb2[2].xyzx +mov o7.xyz, r4.xyzx +dp4 r0.x, r2.xyzw, cb2[0].xyzw +dp4 r0.y, r2.xyzw, cb2[1].xyzw +dp4 r0.z, r2.xyzw, cb2[2].xyzw +mov o4.xyz, r0.xyzx +add o5.xyz, -r0.xyzx, cb2[20].xyzx +mov o6.w, v2.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLEffect_main2BonesVc[] = +{ + 68, 88, 66, 67, 23, 71, + 182, 185, 235, 186, 53, 182, + 76, 51, 4, 190, 219, 74, + 111, 156, 1, 0, 0, 0, + 224, 10, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 144, 3, 0, 0, 248, 8, + 0, 0, 244, 9, 0, 0, + 65, 111, 110, 57, 88, 3, + 0, 0, 88, 3, 0, 0, + 0, 2, 254, 255, 232, 2, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 4, 0, 0, 0, + 216, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 1, 0, 217, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 3, 0, 218, 0, 0, 0, + 0, 0, 2, 0, 4, 0, + 4, 0, 221, 0, 0, 0, + 0, 0, 2, 0, 16, 0, + 2, 0, 225, 0, 0, 0, + 0, 0, 2, 0, 20, 0, + 1, 0, 227, 0, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 228, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 5, 128, + 5, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 6, 128, + 6, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 3, 128, + 5, 0, 228, 144, 228, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 3, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 6, 0, + 85, 144, 0, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 0, 0, 15, 128, + 0, 32, 228, 160, 0, 0, + 85, 176, 6, 0, 0, 144, + 0, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 1, 224, + 2, 0, 228, 144, 0, 0, + 228, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 6, 0, + 85, 144, 1, 32, 228, 160, + 0, 0, 0, 176, 5, 0, + 0, 4, 2, 0, 15, 128, + 6, 0, 85, 144, 2, 32, + 228, 160, 0, 0, 0, 176, + 4, 0, 0, 5, 2, 0, + 15, 128, 2, 32, 228, 160, + 0, 0, 85, 176, 6, 0, + 0, 144, 2, 0, 228, 128, + 4, 0, 0, 5, 1, 0, + 15, 128, 1, 32, 228, 160, + 0, 0, 85, 176, 6, 0, + 0, 144, 1, 0, 228, 128, + 8, 0, 0, 3, 5, 0, + 2, 224, 2, 0, 228, 144, + 1, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 4, 224, + 2, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 3, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 0, 0, 228, 128, 9, 0, + 0, 3, 3, 0, 2, 128, + 0, 0, 228, 144, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 1, 0, 228, 128, + 9, 0, 0, 3, 3, 0, + 4, 128, 0, 0, 228, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 1, 0, 0, 2, + 3, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 0, 0, 4, 192, 3, 0, + 228, 128, 223, 0, 228, 160, + 5, 0, 0, 3, 0, 0, + 15, 224, 3, 0, 228, 144, + 217, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 4, 0, 196, 144, 228, 0, + 229, 160, 228, 0, 218, 160, + 8, 0, 0, 3, 1, 0, + 1, 224, 1, 0, 228, 128, + 225, 0, 244, 160, 8, 0, + 0, 3, 1, 0, 2, 224, + 1, 0, 228, 128, 226, 0, + 244, 160, 8, 0, 0, 3, + 2, 0, 1, 224, 0, 0, + 228, 128, 218, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 2, 224, 0, 0, 228, 128, + 219, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 4, 224, + 0, 0, 228, 128, 220, 0, + 228, 160, 1, 0, 0, 2, + 6, 0, 7, 224, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 3, 0, + 228, 128, 218, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 3, 0, 228, 128, + 219, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 3, 0, 228, 128, 220, 0, + 228, 160, 2, 0, 0, 3, + 4, 0, 7, 224, 0, 0, + 228, 129, 227, 0, 228, 160, + 1, 0, 0, 2, 3, 0, + 7, 224, 0, 0, 228, 128, + 9, 0, 0, 3, 0, 0, + 1, 128, 3, 0, 228, 128, + 221, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 3, 0, 228, 128, 222, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 3, 0, + 228, 128, 224, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 216, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 5, 0, 8, 224, 2, 0, + 255, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 96, 5, + 0, 0, 64, 0, 1, 0, + 88, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 2, 0, + 0, 0, 21, 0, 0, 0, + 89, 8, 0, 4, 70, 142, + 32, 0, 4, 0, 0, 0, + 216, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 4, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 5, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 6, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 4, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 5, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 6, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 7, 0, + 0, 0, 104, 0, 0, 2, + 5, 0, 0, 0, 38, 0, + 0, 11, 0, 208, 0, 0, + 50, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 5, 0, 0, 0, 2, 64, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 9, 242, 0, + 16, 0, 1, 0, 0, 0, + 86, 21, 16, 0, 6, 0, + 0, 0, 70, 142, 32, 4, + 4, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 4, 4, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 6, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 86, 21, 16, 0, 6, 0, + 0, 0, 70, 142, 32, 6, + 4, 0, 0, 0, 1, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 6, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 17, 0, + 0, 7, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 4, 0, + 0, 0, 86, 21, 16, 0, + 6, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 2, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 6, 4, 0, + 0, 0, 2, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 6, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 17, 0, 0, 7, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 58, 16, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 4, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 5, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 6, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 7, 0, + 0, 0, 56, 0, 0, 8, + 242, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 50, 0, 16, 0, + 4, 0, 0, 0, 70, 16, + 16, 0, 4, 0, 0, 0, + 54, 0, 0, 5, 66, 0, + 16, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 16, 0, 0, 8, + 18, 32, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 131, + 32, 0, 2, 0, 0, 0, + 16, 0, 0, 0, 16, 0, + 0, 8, 34, 32, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 131, 32, 0, 2, 0, + 0, 0, 17, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 18, 32, 16, 0, + 6, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 34, 32, + 16, 0, 6, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 4, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 7, + 66, 32, 16, 0, 6, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 18, 32, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 16, 0, 0, 8, + 34, 32, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 16, 0, + 0, 8, 66, 32, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 130, 32, 0, 2, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 7, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 2, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 9, 114, 32, 16, 0, + 5, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 20, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 6, 0, 0, 0, 58, 16, + 16, 0, 2, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 244, 0, 0, 0, + 7, 0, 0, 0, 8, 0, + 0, 0, 176, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 188, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 195, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 15, + 0, 0, 203, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 15, + 0, 0, 209, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 3, 3, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 5, 0, 0, 0, 15, 3, + 0, 0, 231, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 3, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 78, 79, 82, 77, + 65, 76, 0, 84, 65, 78, + 71, 69, 78, 84, 0, 67, + 79, 76, 79, 82, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 66, 76, 69, 78, + 68, 73, 78, 68, 73, 67, + 69, 83, 0, 66, 76, 69, + 78, 68, 87, 69, 73, 71, + 72, 84, 0, 171, 79, 83, + 71, 78, 228, 0, 0, 0, + 8, 0, 0, 0, 8, 0, + 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 12, + 0, 0, 218, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 7, 8, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main4Bones.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main4Bones.inc new file mode 100644 index 0000000000000000000000000000000000000000..0ba01e255726cd8306f3bb7dd8f69181a2165d52 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main4Bones.inc @@ -0,0 +1,698 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TANGENT 0 xyzw 2 NONE float xyzw +// TEXCOORD 0 xy 3 NONE float xy +// BLENDINDICES 0 xyzw 4 NONE uint xyzw +// BLENDWEIGHT 0 xyzw 5 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float xyz +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float xyzw +// TEXCOORD 5 xyz 7 NONE float xyz +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb4 0 216 ( FLT, FLT, FLT, FLT) +// c217 cb0 1 1 ( FLT, FLT, FLT, FLT) +// c218 cb2 0 3 ( FLT, FLT, FLT, FLT) +// c221 cb2 4 4 ( FLT, FLT, FLT, FLT) +// c225 cb2 16 2 ( FLT, FLT, FLT, FLT) +// c227 cb2 20 1 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c216 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c228, 3, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + dcl_texcoord5 v5 + mul r0, v4, c228.x + mova a0, r0.yxzw + mul r1, v5.y, c0[a0.x] + mad r1, c0[a0.y], v5.x, r1 + mad r0, c0[a0.z], v5.z, r1 + mad r0, c0[a0.w], v5.w, r0 + dp3 oT5.x, v2, r0 + mul r1, v5.y, c1[a0.x] + mul r2, v5.y, c2[a0.x] + mad r2, c2[a0.y], v5.x, r2 + mad r1, c1[a0.y], v5.x, r1 + mad r1, c1[a0.z], v5.z, r1 + mad r2, c2[a0.z], v5.z, r2 + mad r2, c2[a0.w], v5.w, r2 + mad r1, c1[a0.w], v5.w, r1 + dp3 oT5.y, v2, r1 + dp3 oT5.z, v2, r2 + dp4 r3.x, v0, r0 + dp3 r0.x, v1, r0 + dp4 r3.y, v0, r1 + dp3 r0.y, v1, r1 + dp4 r3.z, v0, r2 + dp3 r0.z, v1, r2 + mov r3.w, v0.w + dp4 oPos.z, r3, c223 + mad r1.xyz, v3.xyxw, c228.yyzw, c228.zzyw + dp3 oT1.x, r1, c225.xyww + dp3 oT1.y, r1, c226.xyww + dp3 oT2.x, r0, c218 + dp3 oT2.y, r0, c219 + dp3 oT2.z, r0, c220 + mov oT6.xyz, r0 + dp4 r0.x, r3, c218 + dp4 r0.y, r3, c219 + dp4 r0.z, r3, c220 + add oT4.xyz, -r0, c227 + mov oT3.xyz, r0 + dp4 r0.x, r3, c221 + dp4 r0.y, r3, c222 + dp4 r0.z, r3, c224 + mad oPos.xy, r0.z, c216, r0 + mov oPos.w, r0.z + mov oT0, c217 + mov oT5.w, v2.w + +// approximately 44 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_constantbuffer CB2[21], immediateIndexed +dcl_constantbuffer CB4[216], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_input v3.xy +dcl_input v4.xyzw +dcl_input v5.xyzw +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output o4.xyz +dcl_output o5.xyz +dcl_output o6.xyzw +dcl_output o7.xyz +dcl_temps 5 +imul null, r0.xyzw, v4.xyzw, l(3, 3, 3, 3) +mul r1.xyzw, v5.yyyy, cb4[r0.y + 0].xyzw +mad r1.xyzw, cb4[r0.x + 0].xyzw, v5.xxxx, r1.xyzw +mad r1.xyzw, cb4[r0.z + 0].xyzw, v5.zzzz, r1.xyzw +mad r1.xyzw, cb4[r0.w + 0].xyzw, v5.wwww, r1.xyzw +dp4 r2.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v5.yyyy, cb4[r0.y + 1].xyzw +mad r3.xyzw, cb4[r0.x + 1].xyzw, v5.xxxx, r3.xyzw +mad r3.xyzw, cb4[r0.z + 1].xyzw, v5.zzzz, r3.xyzw +mad r3.xyzw, cb4[r0.w + 1].xyzw, v5.wwww, r3.xyzw +dp4 r2.y, v0.xyzw, r3.xyzw +mul r4.xyzw, v5.yyyy, cb4[r0.y + 2].xyzw +mad r4.xyzw, cb4[r0.x + 2].xyzw, v5.xxxx, r4.xyzw +mad r4.xyzw, cb4[r0.z + 2].xyzw, v5.zzzz, r4.xyzw +mad r0.xyzw, cb4[r0.w + 2].xyzw, v5.wwww, r4.xyzw +dp4 r2.z, v0.xyzw, r0.xyzw +mov r2.w, v0.w +dp4 o0.x, r2.xyzw, cb2[4].xyzw +dp4 o0.y, r2.xyzw, cb2[5].xyzw +dp4 o0.z, r2.xyzw, cb2[6].xyzw +dp4 o0.w, r2.xyzw, cb2[7].xyzw +mov o1.xyzw, cb0[1].xyzw +mov r4.xy, v3.xyxx +mov r4.z, l(1.000000) +dp3 o2.x, r4.xyzx, cb2[16].xywx +dp3 o2.y, r4.xyzx, cb2[17].xywx +dp3 r4.x, v1.xyzx, r1.xyzx +dp3 o6.x, v2.xyzx, r1.xyzx +dp3 r4.y, v1.xyzx, r3.xyzx +dp3 o6.y, v2.xyzx, r3.xyzx +dp3 r4.z, v1.xyzx, r0.xyzx +dp3 o6.z, v2.xyzx, r0.xyzx +dp3 o3.x, r4.xyzx, cb2[0].xyzx +dp3 o3.y, r4.xyzx, cb2[1].xyzx +dp3 o3.z, r4.xyzx, cb2[2].xyzx +mov o7.xyz, r4.xyzx +dp4 r0.x, r2.xyzw, cb2[0].xyzw +dp4 r0.y, r2.xyzw, cb2[1].xyzw +dp4 r0.z, r2.xyzw, cb2[2].xyzw +mov o4.xyz, r0.xyzx +add o5.xyz, -r0.xyzx, cb2[20].xyzx +mov o6.w, v2.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLEffect_main4Bones[] = +{ + 68, 88, 66, 67, 232, 121, + 155, 180, 91, 47, 138, 234, + 110, 44, 58, 186, 214, 50, + 189, 50, 1, 0, 0, 0, + 72, 12, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 16, 4, 0, 0, 124, 10, + 0, 0, 92, 11, 0, 0, + 65, 111, 110, 57, 216, 3, + 0, 0, 216, 3, 0, 0, + 0, 2, 254, 255, 104, 3, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 4, 0, 0, 0, + 216, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 1, 0, 217, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 3, 0, 218, 0, 0, 0, + 0, 0, 2, 0, 4, 0, + 4, 0, 221, 0, 0, 0, + 0, 0, 2, 0, 16, 0, + 2, 0, 225, 0, 0, 0, + 0, 0, 2, 0, 20, 0, + 1, 0, 227, 0, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 228, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 5, 128, + 5, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 15, 128, + 4, 0, 228, 144, 228, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 15, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 5, 0, + 85, 144, 0, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 1, 0, 15, 128, + 0, 32, 228, 160, 0, 0, + 85, 176, 5, 0, 0, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 0, 32, 228, 160, 0, 0, + 170, 176, 5, 0, 170, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 0, 32, 228, 160, 0, 0, + 255, 176, 5, 0, 255, 144, + 0, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 1, 224, + 2, 0, 228, 144, 0, 0, + 228, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 5, 0, + 85, 144, 1, 32, 228, 160, + 0, 0, 0, 176, 5, 0, + 0, 4, 2, 0, 15, 128, + 5, 0, 85, 144, 2, 32, + 228, 160, 0, 0, 0, 176, + 4, 0, 0, 5, 2, 0, + 15, 128, 2, 32, 228, 160, + 0, 0, 85, 176, 5, 0, + 0, 144, 2, 0, 228, 128, + 4, 0, 0, 5, 1, 0, + 15, 128, 1, 32, 228, 160, + 0, 0, 85, 176, 5, 0, + 0, 144, 1, 0, 228, 128, + 4, 0, 0, 5, 1, 0, + 15, 128, 1, 32, 228, 160, + 0, 0, 170, 176, 5, 0, + 170, 144, 1, 0, 228, 128, + 4, 0, 0, 5, 2, 0, + 15, 128, 2, 32, 228, 160, + 0, 0, 170, 176, 5, 0, + 170, 144, 2, 0, 228, 128, + 4, 0, 0, 5, 2, 0, + 15, 128, 2, 32, 228, 160, + 0, 0, 255, 176, 5, 0, + 255, 144, 2, 0, 228, 128, + 4, 0, 0, 5, 1, 0, + 15, 128, 1, 32, 228, 160, + 0, 0, 255, 176, 5, 0, + 255, 144, 1, 0, 228, 128, + 8, 0, 0, 3, 5, 0, + 2, 224, 2, 0, 228, 144, + 1, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 4, 224, + 2, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 3, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 0, 0, 228, 128, 9, 0, + 0, 3, 3, 0, 2, 128, + 0, 0, 228, 144, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 1, 0, 228, 128, + 9, 0, 0, 3, 3, 0, + 4, 128, 0, 0, 228, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 1, 0, 0, 2, + 3, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 0, 0, 4, 192, 3, 0, + 228, 128, 223, 0, 228, 160, + 4, 0, 0, 4, 1, 0, + 7, 128, 3, 0, 196, 144, + 228, 0, 229, 160, 228, 0, + 218, 160, 8, 0, 0, 3, + 1, 0, 1, 224, 1, 0, + 228, 128, 225, 0, 244, 160, + 8, 0, 0, 3, 1, 0, + 2, 224, 1, 0, 228, 128, + 226, 0, 244, 160, 8, 0, + 0, 3, 2, 0, 1, 224, + 0, 0, 228, 128, 218, 0, + 228, 160, 8, 0, 0, 3, + 2, 0, 2, 224, 0, 0, + 228, 128, 219, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 4, 224, 0, 0, 228, 128, + 220, 0, 228, 160, 1, 0, + 0, 2, 6, 0, 7, 224, + 0, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 1, 128, + 3, 0, 228, 128, 218, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 3, 0, + 228, 128, 219, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 3, 0, 228, 128, + 220, 0, 228, 160, 2, 0, + 0, 3, 4, 0, 7, 224, + 0, 0, 228, 129, 227, 0, + 228, 160, 1, 0, 0, 2, + 3, 0, 7, 224, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 3, 0, + 228, 128, 221, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 3, 0, 228, 128, + 222, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 3, 0, 228, 128, 224, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 216, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 217, 0, 228, 160, 1, 0, + 0, 2, 5, 0, 8, 224, + 2, 0, 255, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 100, 6, 0, 0, 64, 0, + 1, 0, 153, 1, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 2, 0, 0, 0, 21, 0, + 0, 0, 89, 8, 0, 4, + 70, 142, 32, 0, 4, 0, + 0, 0, 216, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 4, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 5, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 5, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 6, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 7, 0, 0, 0, 104, 0, + 0, 2, 5, 0, 0, 0, + 38, 0, 0, 11, 0, 208, + 0, 0, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 56, 0, 0, 9, + 242, 0, 16, 0, 1, 0, + 0, 0, 86, 21, 16, 0, + 5, 0, 0, 0, 70, 142, + 32, 4, 4, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 4, + 4, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 5, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 11, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 4, 4, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 166, 26, 16, 0, + 5, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 11, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 4, 4, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 5, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 86, 21, 16, 0, 5, 0, + 0, 0, 70, 142, 32, 6, + 4, 0, 0, 0, 1, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 5, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 1, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 166, 26, 16, 0, 5, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 5, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 17, 0, + 0, 7, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 4, 0, + 0, 0, 86, 21, 16, 0, + 5, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 2, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 4, 0, + 0, 0, 2, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 5, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 4, 0, + 0, 0, 2, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 166, 26, 16, 0, + 5, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 6, 4, 0, + 0, 0, 2, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 5, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 17, 0, 0, 7, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 58, 16, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 4, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 5, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 6, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 7, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 16, 16, 0, + 3, 0, 0, 0, 54, 0, + 0, 5, 66, 0, 16, 0, + 4, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 16, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 131, 32, 0, + 2, 0, 0, 0, 16, 0, + 0, 0, 16, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 131, + 32, 0, 2, 0, 0, 0, + 17, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 4, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 32, 16, 0, 6, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 34, 32, 16, 0, + 6, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 66, 0, 16, 0, 4, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 66, 32, + 16, 0, 6, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 8, 18, 32, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 130, 32, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 34, 32, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 16, 0, 0, 8, + 66, 32, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 2, 0, 0, 0, 54, 0, + 0, 5, 114, 32, 16, 0, + 7, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 9, + 114, 32, 16, 0, 5, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 20, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 6, 0, + 0, 0, 58, 16, 16, 0, + 2, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 216, 0, 0, 0, 6, 0, + 0, 0, 8, 0, 0, 0, + 152, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 164, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 171, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 179, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 3, 3, 0, 0, + 188, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 4, 0, + 0, 0, 15, 15, 0, 0, + 201, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 65, 78, 71, 69, + 78, 84, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 66, 76, 69, 78, 68, 73, + 78, 68, 73, 67, 69, 83, + 0, 66, 76, 69, 78, 68, + 87, 69, 73, 71, 72, 84, + 0, 171, 171, 171, 79, 83, + 71, 78, 228, 0, 0, 0, + 8, 0, 0, 0, 8, 0, + 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 12, + 0, 0, 218, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 8, + 0, 0, 218, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 7, 8, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main4BonesVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main4BonesVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..edd96cd719baeb4e8c49062c9e7a67dc8d317b2d --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_main4BonesVc.inc @@ -0,0 +1,712 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TANGENT 0 xyzw 2 NONE float xyzw +// COLOR 0 xyzw 3 NONE float xyzw +// TEXCOORD 0 xy 4 NONE float xy +// BLENDINDICES 0 xyzw 5 NONE uint xyzw +// BLENDWEIGHT 0 xyzw 6 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float xyz +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float xyzw +// TEXCOORD 5 xyz 7 NONE float xyz +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb4 0 216 ( FLT, FLT, FLT, FLT) +// c217 cb0 1 1 ( FLT, FLT, FLT, FLT) +// c218 cb2 0 3 ( FLT, FLT, FLT, FLT) +// c221 cb2 4 4 ( FLT, FLT, FLT, FLT) +// c225 cb2 16 2 ( FLT, FLT, FLT, FLT) +// c227 cb2 20 1 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c216 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c228, 3, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + dcl_texcoord5 v5 + dcl_texcoord6 v6 + mul r0, v5, c228.x + mova a0, r0.yxzw + mul r1, v6.y, c0[a0.x] + mad r1, c0[a0.y], v6.x, r1 + mad r0, c0[a0.z], v6.z, r1 + mad r0, c0[a0.w], v6.w, r0 + dp3 oT5.x, v2, r0 + mul r1, v6.y, c1[a0.x] + mul r2, v6.y, c2[a0.x] + mad r2, c2[a0.y], v6.x, r2 + mad r1, c1[a0.y], v6.x, r1 + mad r1, c1[a0.z], v6.z, r1 + mad r2, c2[a0.z], v6.z, r2 + mad r2, c2[a0.w], v6.w, r2 + mad r1, c1[a0.w], v6.w, r1 + dp3 oT5.y, v2, r1 + dp3 oT5.z, v2, r2 + dp4 r3.x, v0, r0 + dp3 r0.x, v1, r0 + dp4 r3.y, v0, r1 + dp3 r0.y, v1, r1 + dp4 r3.z, v0, r2 + dp3 r0.z, v1, r2 + mov r3.w, v0.w + dp4 oPos.z, r3, c223 + mul oT0, v3, c217 + mad r1.xyz, v4.xyxw, c228.yyzw, c228.zzyw + dp3 oT1.x, r1, c225.xyww + dp3 oT1.y, r1, c226.xyww + dp3 oT2.x, r0, c218 + dp3 oT2.y, r0, c219 + dp3 oT2.z, r0, c220 + mov oT6.xyz, r0 + dp4 r0.x, r3, c218 + dp4 r0.y, r3, c219 + dp4 r0.z, r3, c220 + add oT4.xyz, -r0, c227 + mov oT3.xyz, r0 + dp4 r0.x, r3, c221 + dp4 r0.y, r3, c222 + dp4 r0.z, r3, c224 + mad oPos.xy, r0.z, c216, r0 + mov oPos.w, r0.z + mov oT5.w, v2.w + +// approximately 44 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_constantbuffer CB2[21], immediateIndexed +dcl_constantbuffer CB4[216], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_input v3.xyzw +dcl_input v4.xy +dcl_input v5.xyzw +dcl_input v6.xyzw +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output o4.xyz +dcl_output o5.xyz +dcl_output o6.xyzw +dcl_output o7.xyz +dcl_temps 5 +imul null, r0.xyzw, v5.xyzw, l(3, 3, 3, 3) +mul r1.xyzw, v6.yyyy, cb4[r0.y + 0].xyzw +mad r1.xyzw, cb4[r0.x + 0].xyzw, v6.xxxx, r1.xyzw +mad r1.xyzw, cb4[r0.z + 0].xyzw, v6.zzzz, r1.xyzw +mad r1.xyzw, cb4[r0.w + 0].xyzw, v6.wwww, r1.xyzw +dp4 r2.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v6.yyyy, cb4[r0.y + 1].xyzw +mad r3.xyzw, cb4[r0.x + 1].xyzw, v6.xxxx, r3.xyzw +mad r3.xyzw, cb4[r0.z + 1].xyzw, v6.zzzz, r3.xyzw +mad r3.xyzw, cb4[r0.w + 1].xyzw, v6.wwww, r3.xyzw +dp4 r2.y, v0.xyzw, r3.xyzw +mul r4.xyzw, v6.yyyy, cb4[r0.y + 2].xyzw +mad r4.xyzw, cb4[r0.x + 2].xyzw, v6.xxxx, r4.xyzw +mad r4.xyzw, cb4[r0.z + 2].xyzw, v6.zzzz, r4.xyzw +mad r0.xyzw, cb4[r0.w + 2].xyzw, v6.wwww, r4.xyzw +dp4 r2.z, v0.xyzw, r0.xyzw +mov r2.w, v0.w +dp4 o0.x, r2.xyzw, cb2[4].xyzw +dp4 o0.y, r2.xyzw, cb2[5].xyzw +dp4 o0.z, r2.xyzw, cb2[6].xyzw +dp4 o0.w, r2.xyzw, cb2[7].xyzw +mul o1.xyzw, v3.xyzw, cb0[1].xyzw +mov r4.xy, v4.xyxx +mov r4.z, l(1.000000) +dp3 o2.x, r4.xyzx, cb2[16].xywx +dp3 o2.y, r4.xyzx, cb2[17].xywx +dp3 r4.x, v1.xyzx, r1.xyzx +dp3 o6.x, v2.xyzx, r1.xyzx +dp3 r4.y, v1.xyzx, r3.xyzx +dp3 o6.y, v2.xyzx, r3.xyzx +dp3 r4.z, v1.xyzx, r0.xyzx +dp3 o6.z, v2.xyzx, r0.xyzx +dp3 o3.x, r4.xyzx, cb2[0].xyzx +dp3 o3.y, r4.xyzx, cb2[1].xyzx +dp3 o3.z, r4.xyzx, cb2[2].xyzx +mov o7.xyz, r4.xyzx +dp4 r0.x, r2.xyzw, cb2[0].xyzw +dp4 r0.y, r2.xyzw, cb2[1].xyzw +dp4 r0.z, r2.xyzw, cb2[2].xyzw +mov o4.xyz, r0.xyzx +add o5.xyz, -r0.xyzx, cb2[20].xyzx +mov o6.w, v2.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLEffect_main4BonesVc[] = +{ + 68, 88, 66, 67, 232, 20, + 197, 8, 28, 104, 152, 172, + 111, 129, 163, 88, 193, 142, + 231, 122, 1, 0, 0, 0, + 136, 12, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 32, 4, 0, 0, 160, 10, + 0, 0, 156, 11, 0, 0, + 65, 111, 110, 57, 232, 3, + 0, 0, 232, 3, 0, 0, + 0, 2, 254, 255, 120, 3, + 0, 0, 112, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 1, 0, + 108, 0, 4, 0, 0, 0, + 216, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 1, 0, 217, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 3, 0, 218, 0, 0, 0, + 0, 0, 2, 0, 4, 0, + 4, 0, 221, 0, 0, 0, + 0, 0, 2, 0, 16, 0, + 2, 0, 225, 0, 0, 0, + 0, 0, 2, 0, 20, 0, + 1, 0, 227, 0, 0, 0, + 0, 0, 0, 0, 216, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 228, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 5, 128, + 5, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 6, 128, + 6, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 15, 128, + 5, 0, 228, 144, 228, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 15, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 6, 0, + 85, 144, 0, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 1, 0, 15, 128, + 0, 32, 228, 160, 0, 0, + 85, 176, 6, 0, 0, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 0, 32, 228, 160, 0, 0, + 170, 176, 6, 0, 170, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 0, 32, 228, 160, 0, 0, + 255, 176, 6, 0, 255, 144, + 0, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 1, 224, + 2, 0, 228, 144, 0, 0, + 228, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 6, 0, + 85, 144, 1, 32, 228, 160, + 0, 0, 0, 176, 5, 0, + 0, 4, 2, 0, 15, 128, + 6, 0, 85, 144, 2, 32, + 228, 160, 0, 0, 0, 176, + 4, 0, 0, 5, 2, 0, + 15, 128, 2, 32, 228, 160, + 0, 0, 85, 176, 6, 0, + 0, 144, 2, 0, 228, 128, + 4, 0, 0, 5, 1, 0, + 15, 128, 1, 32, 228, 160, + 0, 0, 85, 176, 6, 0, + 0, 144, 1, 0, 228, 128, + 4, 0, 0, 5, 1, 0, + 15, 128, 1, 32, 228, 160, + 0, 0, 170, 176, 6, 0, + 170, 144, 1, 0, 228, 128, + 4, 0, 0, 5, 2, 0, + 15, 128, 2, 32, 228, 160, + 0, 0, 170, 176, 6, 0, + 170, 144, 2, 0, 228, 128, + 4, 0, 0, 5, 2, 0, + 15, 128, 2, 32, 228, 160, + 0, 0, 255, 176, 6, 0, + 255, 144, 2, 0, 228, 128, + 4, 0, 0, 5, 1, 0, + 15, 128, 1, 32, 228, 160, + 0, 0, 255, 176, 6, 0, + 255, 144, 1, 0, 228, 128, + 8, 0, 0, 3, 5, 0, + 2, 224, 2, 0, 228, 144, + 1, 0, 228, 128, 8, 0, + 0, 3, 5, 0, 4, 224, + 2, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 3, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 1, 0, 228, 144, + 0, 0, 228, 128, 9, 0, + 0, 3, 3, 0, 2, 128, + 0, 0, 228, 144, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 1, 0, 228, 128, + 9, 0, 0, 3, 3, 0, + 4, 128, 0, 0, 228, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 1, 0, 0, 2, + 3, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 0, 0, 4, 192, 3, 0, + 228, 128, 223, 0, 228, 160, + 5, 0, 0, 3, 0, 0, + 15, 224, 3, 0, 228, 144, + 217, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 4, 0, 196, 144, 228, 0, + 229, 160, 228, 0, 218, 160, + 8, 0, 0, 3, 1, 0, + 1, 224, 1, 0, 228, 128, + 225, 0, 244, 160, 8, 0, + 0, 3, 1, 0, 2, 224, + 1, 0, 228, 128, 226, 0, + 244, 160, 8, 0, 0, 3, + 2, 0, 1, 224, 0, 0, + 228, 128, 218, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 2, 224, 0, 0, 228, 128, + 219, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 4, 224, + 0, 0, 228, 128, 220, 0, + 228, 160, 1, 0, 0, 2, + 6, 0, 7, 224, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 3, 0, + 228, 128, 218, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 3, 0, 228, 128, + 219, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 3, 0, 228, 128, 220, 0, + 228, 160, 2, 0, 0, 3, + 4, 0, 7, 224, 0, 0, + 228, 129, 227, 0, 228, 160, + 1, 0, 0, 2, 3, 0, + 7, 224, 0, 0, 228, 128, + 9, 0, 0, 3, 0, 0, + 1, 128, 3, 0, 228, 128, + 221, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 3, 0, 228, 128, 222, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 3, 0, + 228, 128, 224, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 216, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 5, 0, 8, 224, 2, 0, + 255, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 120, 6, + 0, 0, 64, 0, 1, 0, + 158, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 2, 0, + 0, 0, 21, 0, 0, 0, + 89, 8, 0, 4, 70, 142, + 32, 0, 4, 0, 0, 0, + 216, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 4, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 5, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 6, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 4, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 5, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 6, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 7, 0, + 0, 0, 104, 0, 0, 2, + 5, 0, 0, 0, 38, 0, + 0, 11, 0, 208, 0, 0, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 5, 0, 0, 0, 2, 64, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 56, 0, 0, 9, 242, 0, + 16, 0, 1, 0, 0, 0, + 86, 21, 16, 0, 6, 0, + 0, 0, 70, 142, 32, 4, + 4, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 4, 4, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 6, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 4, + 4, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 166, 26, 16, 0, 6, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 11, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 4, 4, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 6, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 17, 0, 0, 7, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 3, 0, 0, 0, 86, 21, + 16, 0, 6, 0, 0, 0, + 70, 142, 32, 6, 4, 0, + 0, 0, 1, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 6, + 4, 0, 0, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 6, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 6, + 4, 0, 0, 0, 1, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 166, 26, + 16, 0, 6, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 6, + 4, 0, 0, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 6, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 17, 0, 0, 7, + 34, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 4, 0, 0, 0, + 86, 21, 16, 0, 6, 0, + 0, 0, 70, 142, 32, 6, + 4, 0, 0, 0, 2, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 6, 0, + 0, 0, 70, 14, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 2, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 166, 26, 16, 0, 6, 0, + 0, 0, 70, 14, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 6, 4, 0, 0, 0, + 2, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 6, 0, + 0, 0, 70, 14, 16, 0, + 4, 0, 0, 0, 17, 0, + 0, 7, 66, 0, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 0, 16, 0, 2, 0, + 0, 0, 58, 16, 16, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 4, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 6, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 7, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 50, 0, 16, 0, 4, 0, + 0, 0, 70, 16, 16, 0, + 4, 0, 0, 0, 54, 0, + 0, 5, 66, 0, 16, 0, + 4, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 16, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 131, 32, 0, + 2, 0, 0, 0, 16, 0, + 0, 0, 16, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 131, + 32, 0, 2, 0, 0, 0, + 17, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 4, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 32, 16, 0, 6, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 34, 32, 16, 0, + 6, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 16, 0, 0, 7, + 66, 0, 16, 0, 4, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 66, 32, + 16, 0, 6, 0, 0, 0, + 70, 18, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 8, 18, 32, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 130, 32, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 34, 32, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 16, 0, 0, 8, + 66, 32, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 2, 0, 0, 0, 54, 0, + 0, 5, 114, 32, 16, 0, + 7, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 9, + 114, 32, 16, 0, 5, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 20, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 6, 0, + 0, 0, 58, 16, 16, 0, + 2, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 244, 0, 0, 0, 7, 0, + 0, 0, 8, 0, 0, 0, + 176, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 188, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 195, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 203, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 15, 0, 0, + 209, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 3, 3, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 5, 0, + 0, 0, 15, 15, 0, 0, + 231, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 65, 78, 71, 69, + 78, 84, 0, 67, 79, 76, + 79, 82, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 66, 76, 69, 78, 68, 73, + 78, 68, 73, 67, 69, 83, + 0, 66, 76, 69, 78, 68, + 87, 69, 73, 71, 72, 84, + 0, 171, 79, 83, 71, 78, + 228, 0, 0, 0, 8, 0, + 0, 0, 8, 0, 0, 0, + 200, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 212, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 12, 0, 0, + 218, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 8, 0, 0, + 218, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 8, 0, 0, + 218, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 7, 8, 0, 0, + 218, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 7, 8, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_mainVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_mainVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..c117cac37ac593ed6b2ad9d873e7f51c1d86c9bd --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLEffect_mainVc.inc @@ -0,0 +1,414 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TANGENT 0 xyzw 2 NONE float xyzw +// COLOR 0 xyzw 3 NONE float xyzw +// TEXCOORD 0 xy 4 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float xyzw +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float xyz +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float xyzw +// TEXCOORD 5 xyz 7 NONE float xyz +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 1 1 ( FLT, FLT, FLT, FLT) +// c2 cb2 0 3 ( FLT, FLT, FLT, FLT) +// c5 cb2 4 4 ( FLT, FLT, FLT, FLT) +// c9 cb2 16 2 ( FLT, FLT, FLT, FLT) +// c11 cb2 20 1 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c12, 1, 0, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + dp4 oPos.z, v0, c7 + mul oT0, v3, c1 + mad r0.xyz, v4.xyxw, c12.xxyw, c12.yyxw + dp3 oT1.x, r0, c9.xyww + dp3 oT1.y, r0, c10.xyww + dp3 oT2.x, v1, c2 + dp3 oT2.y, v1, c3 + dp3 oT2.z, v1, c4 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c4 + add oT4.xyz, -r0, c11 + mov oT3.xyz, r0 + dp4 r0.x, v0, c5 + dp4 r0.y, v0, c6 + dp4 r0.z, v0, c8 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT5, v2 + mov oT6.xyz, v1 + +// approximately 20 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_constantbuffer CB2[21], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xyzw +dcl_input v3.xyzw +dcl_input v4.xy +dcl_output_siv o0.xyzw, position +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output o4.xyz +dcl_output o5.xyz +dcl_output o6.xyzw +dcl_output o7.xyz +dcl_temps 1 +dp4 o0.x, v0.xyzw, cb2[4].xyzw +dp4 o0.y, v0.xyzw, cb2[5].xyzw +dp4 o0.z, v0.xyzw, cb2[6].xyzw +dp4 o0.w, v0.xyzw, cb2[7].xyzw +mul o1.xyzw, v3.xyzw, cb0[1].xyzw +mov r0.xy, v4.xyxx +mov r0.z, l(1.000000) +dp3 o2.x, r0.xyzx, cb2[16].xywx +dp3 o2.y, r0.xyzx, cb2[17].xywx +dp3 o3.x, v1.xyzx, cb2[0].xyzx +dp3 o3.y, v1.xyzx, cb2[1].xyzx +dp3 o3.z, v1.xyzx, cb2[2].xyzx +dp4 r0.x, v0.xyzw, cb2[0].xyzw +dp4 r0.y, v0.xyzw, cb2[1].xyzw +dp4 r0.z, v0.xyzw, cb2[2].xyzw +mov o4.xyz, r0.xyzx +add o5.xyz, -r0.xyzx, cb2[20].xyzx +mov o6.xyzw, v2.xyzw +mov o7.xyz, v1.xyzx +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLEffect_mainVc[] = +{ + 68, 88, 66, 67, 46, 24, + 56, 107, 253, 204, 106, 97, + 79, 20, 243, 167, 246, 83, + 101, 20, 1, 0, 0, 0, + 212, 6, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 48, 2, 0, 0, 52, 5, + 0, 0, 232, 5, 0, 0, + 65, 111, 110, 57, 248, 1, + 0, 0, 248, 1, 0, 0, + 0, 2, 254, 255, 148, 1, + 0, 0, 100, 0, 0, 0, + 5, 0, 36, 0, 0, 0, + 96, 0, 0, 0, 96, 0, + 0, 0, 36, 0, 1, 0, + 96, 0, 0, 0, 1, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 3, 0, 2, 0, 0, 0, + 0, 0, 2, 0, 4, 0, + 4, 0, 5, 0, 0, 0, + 0, 0, 2, 0, 16, 0, + 2, 0, 9, 0, 0, 0, + 0, 0, 2, 0, 20, 0, + 1, 0, 11, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 12, 0, 15, 160, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 7, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 224, 3, 0, + 228, 144, 1, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 128, 4, 0, 196, 144, + 12, 0, 208, 160, 12, 0, + 197, 160, 8, 0, 0, 3, + 1, 0, 1, 224, 0, 0, + 228, 128, 9, 0, 244, 160, + 8, 0, 0, 3, 1, 0, + 2, 224, 0, 0, 228, 128, + 10, 0, 244, 160, 8, 0, + 0, 3, 2, 0, 1, 224, + 1, 0, 228, 144, 2, 0, + 228, 160, 8, 0, 0, 3, + 2, 0, 2, 224, 1, 0, + 228, 144, 3, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 4, 224, 1, 0, 228, 144, + 4, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 2, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 3, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 4, 0, 228, 160, 2, 0, + 0, 3, 4, 0, 7, 224, + 0, 0, 228, 129, 11, 0, + 228, 160, 1, 0, 0, 2, + 3, 0, 7, 224, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 5, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 6, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 8, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 5, 0, 15, 224, + 2, 0, 228, 144, 1, 0, + 0, 2, 6, 0, 7, 224, + 1, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 252, 2, 0, 0, 64, 0, + 1, 0, 191, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 2, 0, 0, 0, 21, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 2, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 3, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 4, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 3, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 4, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 5, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 6, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 7, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 4, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 5, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 6, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 7, 0, 0, 0, 56, 0, + 0, 8, 242, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 5, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 4, 0, + 0, 0, 54, 0, 0, 5, + 66, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 16, 0, + 0, 8, 18, 32, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 131, 32, 0, 2, 0, + 0, 0, 16, 0, 0, 0, + 16, 0, 0, 8, 34, 32, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 131, 32, 0, + 2, 0, 0, 0, 17, 0, + 0, 0, 16, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 16, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 16, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 2, 0, 0, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 2, 0, 0, 0, 2, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 9, 114, 32, 16, 0, + 5, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 2, 0, 0, 0, + 20, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 6, 0, 0, 0, 70, 30, + 16, 0, 2, 0, 0, 0, + 54, 0, 0, 5, 114, 32, + 16, 0, 7, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 172, 0, + 0, 0, 5, 0, 0, 0, + 8, 0, 0, 0, 128, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 140, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 147, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 15, 15, 0, 0, 155, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 15, 0, 0, 161, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 3, 3, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 84, + 65, 78, 71, 69, 78, 84, + 0, 67, 79, 76, 79, 82, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 171, 171, + 79, 83, 71, 78, 228, 0, + 0, 0, 8, 0, 0, 0, + 8, 0, 0, 0, 200, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 212, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 218, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 218, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 8, 0, 0, 218, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 7, 8, 0, 0, 218, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 5, 0, 0, 0, + 7, 8, 0, 0, 218, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 6, 0, 0, 0, + 15, 0, 0, 0, 218, 0, + 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 7, 0, 0, 0, + 7, 8, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_main.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_main.inc new file mode 100644 index 0000000000000000000000000000000000000000..fa7e69b4f34b6b429a03a573987b2b352bf0f277 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_main.inc @@ -0,0 +1,315 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c1 cb1 0 5 ( FLT, FLT, FLT, FLT) +// c6 cb1 9 4 ( FLT, FLT, FLT, FLT) +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t2.xyz + nrm r0.xyz, t2 + dp3_sat r0.w, c6, r0 + mul r1.xyz, r0.w, c2 + mul r1.xyz, r1, t0 + mov r2.xyz, c0 + mad r1.xyz, r2, c1, r1 + dp3_sat r0.w, c7, r0 + mul r2.xyz, r0.w, c3 + mad r1.xyz, r2, t0, r1 + dp3_sat r0.w, c8, r0 + dp3_sat r1.w, c9, r0 + mul r0.xyz, r1.w, c5 + mul r2.xyz, r0.w, c4 + mad r1.xyz, r2, t0, r1 + mad_sat r0.xyz, r0, t0, r1 + mov r0.w, t0.w + mov oC0, r0 + +// approximately 19 instruction slots used +ps_4_0 +dcl_constantbuffer CB0[1], immediateIndexed +dcl_constantbuffer CB1[13], immediateIndexed +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 3 +dp3 r0.x, v3.xyzx, v3.xyzx +rsq r0.x, r0.x +mul r0.xyz, r0.xxxx, v3.xyzx +dp3_sat r0.w, cb1[9].xyzx, r0.xyzx +mul r1.xyz, r0.wwww, cb1[1].xyzx +mul r1.xyz, r1.xyzx, v1.xyzx +mad r1.xyz, cb0[0].xyzx, cb1[0].xyzx, r1.xyzx +dp3_sat r0.w, cb1[10].xyzx, r0.xyzx +mul r2.xyz, r0.wwww, cb1[2].xyzx +mad r1.xyz, r2.xyzx, v1.xyzx, r1.xyzx +dp3_sat r0.w, cb1[11].xyzx, r0.xyzx +dp3_sat r0.x, cb1[12].xyzx, r0.xyzx +mul r0.xyz, r0.xxxx, cb1[4].xyzx +mul r2.xyz, r0.wwww, cb1[3].xyzx +mad r1.xyz, r2.xyzx, v1.xyzx, r1.xyzx +mad_sat o0.xyz, r0.xyzx, v1.xyzx, r1.xyzx +mov o0.w, v1.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLLambert_main[] = +{ + 68, 88, 66, 67, 187, 65, + 58, 0, 83, 56, 125, 10, + 111, 229, 99, 96, 154, 18, + 252, 50, 1, 0, 0, 0, + 68, 5, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 176, 1, 0, 0, 36, 4, + 0, 0, 16, 5, 0, 0, + 65, 111, 110, 57, 120, 1, + 0, 0, 120, 1, 0, 0, + 0, 2, 255, 255, 48, 1, + 0, 0, 72, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 5, 0, 1, 0, 0, 0, + 0, 0, 1, 0, 9, 0, + 4, 0, 6, 0, 0, 0, + 0, 0, 0, 2, 255, 255, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 2, 0, 7, 176, + 36, 0, 0, 2, 0, 0, + 7, 128, 2, 0, 228, 176, + 8, 0, 0, 3, 0, 0, + 24, 128, 6, 0, 228, 160, + 0, 0, 228, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 0, 0, 255, 128, 2, 0, + 228, 160, 5, 0, 0, 3, + 1, 0, 7, 128, 1, 0, + 228, 128, 0, 0, 228, 176, + 1, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 1, 0, + 7, 128, 2, 0, 228, 128, + 1, 0, 228, 160, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 24, 128, 7, 0, + 228, 160, 0, 0, 228, 128, + 5, 0, 0, 3, 2, 0, + 7, 128, 0, 0, 255, 128, + 3, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 2, 0, 228, 128, 0, 0, + 228, 176, 1, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 24, 128, 8, 0, 228, 160, + 0, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 24, 128, + 9, 0, 228, 160, 0, 0, + 228, 128, 5, 0, 0, 3, + 0, 0, 7, 128, 1, 0, + 255, 128, 5, 0, 228, 160, + 5, 0, 0, 3, 2, 0, + 7, 128, 0, 0, 255, 128, + 4, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 2, 0, 228, 128, 0, 0, + 228, 176, 1, 0, 228, 128, + 4, 0, 0, 4, 0, 0, + 23, 128, 0, 0, 228, 128, + 0, 0, 228, 176, 1, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 176, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 108, 2, + 0, 0, 64, 0, 0, 0, + 155, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 1, 0, + 0, 0, 13, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 114, 16, + 16, 0, 3, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 3, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 68, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 16, 32, 0, 8, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 9, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 32, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 10, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 2, 0, + 0, 0, 50, 0, 0, 9, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 32, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 11, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 32, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 12, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 4, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 50, 32, + 0, 9, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 228, 0, 0, 0, + 8, 0, 0, 0, 8, 0, + 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 15, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 0, + 0, 0, 218, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 7, + 0, 0, 218, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 7, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_mainTk.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_mainTk.inc new file mode 100644 index 0000000000000000000000000000000000000000..7efe50fbef710dea48febf5c208cb855e80b5701 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_mainTk.inc @@ -0,0 +1,339 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c1 cb1 0 5 ( FLT, FLT, FLT, FLT) +// c6 cb1 9 4 ( FLT, FLT, FLT, FLT) +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c10, -1, -0, 0, 0 + dcl t0 + dcl t2.xyz + mul r0.w, t0.w, t0.w + cmp r0, -r0.w, c10.x, c10.y + texkill r0 + nrm r0.xyz, t2 + dp3_sat r0.w, c6, r0 + mul r1.xyz, r0.w, c2 + mul r1.xyz, r1, t0 + mov r2.xyz, c0 + mad r1.xyz, r2, c1, r1 + dp3_sat r0.w, c7, r0 + mul r2.xyz, r0.w, c3 + mad r1.xyz, r2, t0, r1 + dp3_sat r0.w, c8, r0 + mul r2.xyz, r0.w, c4 + mad r1.xyz, r2, t0, r1 + dp3_sat r1.w, c9, r0 + mul r0.xyz, r1.w, c5 + mad_sat r0.xyz, r0, t0, r1 + mov r0.w, t0.w + mov oC0, r0 + +// approximately 22 instruction slots used +ps_4_0 +dcl_constantbuffer CB0[1], immediateIndexed +dcl_constantbuffer CB1[13], immediateIndexed +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 3 +eq r0.x, v1.w, l(0.000000) +discard_nz r0.x +dp3 r0.x, v3.xyzx, v3.xyzx +rsq r0.x, r0.x +mul r0.xyz, r0.xxxx, v3.xyzx +dp3_sat r0.w, cb1[9].xyzx, r0.xyzx +mul r1.xyz, r0.wwww, cb1[1].xyzx +mul r1.xyz, r1.xyzx, v1.xyzx +mad r1.xyz, cb0[0].xyzx, cb1[0].xyzx, r1.xyzx +dp3_sat r0.w, cb1[10].xyzx, r0.xyzx +mul r2.xyz, r0.wwww, cb1[2].xyzx +mad r1.xyz, r2.xyzx, v1.xyzx, r1.xyzx +dp3_sat r0.w, cb1[11].xyzx, r0.xyzx +mul r2.xyz, r0.wwww, cb1[3].xyzx +mad r1.xyz, r2.xyzx, v1.xyzx, r1.xyzx +dp3_sat r0.x, cb1[12].xyzx, r0.xyzx +mul r0.xyz, r0.xxxx, cb1[4].xyzx +mad_sat o0.xyz, r0.xyzx, v1.xyzx, r1.xyzx +mov o0.w, v1.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLLambert_mainTk[] = +{ + 68, 88, 66, 67, 28, 71, + 107, 235, 74, 190, 103, 118, + 132, 4, 112, 124, 14, 35, + 208, 217, 1, 0, 0, 0, + 176, 5, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 244, 1, 0, 0, 144, 4, + 0, 0, 124, 5, 0, 0, + 65, 111, 110, 57, 188, 1, + 0, 0, 188, 1, 0, 0, + 0, 2, 255, 255, 116, 1, + 0, 0, 72, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 5, 0, 1, 0, 0, 0, + 0, 0, 1, 0, 9, 0, + 4, 0, 6, 0, 0, 0, + 0, 0, 0, 2, 255, 255, + 81, 0, 0, 5, 10, 0, + 15, 160, 0, 0, 128, 191, + 0, 0, 0, 128, 0, 0, + 0, 0, 0, 0, 0, 0, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 2, 0, 7, 176, + 5, 0, 0, 3, 0, 0, + 8, 128, 0, 0, 255, 176, + 0, 0, 255, 176, 88, 0, + 0, 4, 0, 0, 15, 128, + 0, 0, 255, 129, 10, 0, + 0, 160, 10, 0, 85, 160, + 65, 0, 0, 1, 0, 0, + 15, 128, 36, 0, 0, 2, + 0, 0, 7, 128, 2, 0, + 228, 176, 8, 0, 0, 3, + 0, 0, 24, 128, 6, 0, + 228, 160, 0, 0, 228, 128, + 5, 0, 0, 3, 1, 0, + 7, 128, 0, 0, 255, 128, + 2, 0, 228, 160, 5, 0, + 0, 3, 1, 0, 7, 128, + 1, 0, 228, 128, 0, 0, + 228, 176, 1, 0, 0, 2, + 2, 0, 7, 128, 0, 0, + 228, 160, 4, 0, 0, 4, + 1, 0, 7, 128, 2, 0, + 228, 128, 1, 0, 228, 160, + 1, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 24, 128, + 7, 0, 228, 160, 0, 0, + 228, 128, 5, 0, 0, 3, + 2, 0, 7, 128, 0, 0, + 255, 128, 3, 0, 228, 160, + 4, 0, 0, 4, 1, 0, + 7, 128, 2, 0, 228, 128, + 0, 0, 228, 176, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 24, 128, 8, 0, + 228, 160, 0, 0, 228, 128, + 5, 0, 0, 3, 2, 0, + 7, 128, 0, 0, 255, 128, + 4, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 2, 0, 228, 128, 0, 0, + 228, 176, 1, 0, 228, 128, + 8, 0, 0, 3, 1, 0, + 24, 128, 9, 0, 228, 160, + 0, 0, 228, 128, 5, 0, + 0, 3, 0, 0, 7, 128, + 1, 0, 255, 128, 5, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 23, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 1, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 128, + 0, 0, 255, 176, 1, 0, + 0, 2, 0, 8, 15, 128, + 0, 0, 228, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 148, 2, 0, 0, 64, 0, + 0, 0, 165, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 1, 0, 0, 0, 13, 0, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 3, 0, 0, 0, 24, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 13, 0, 4, 3, + 10, 0, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 68, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 16, 32, 0, 8, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 9, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 32, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 10, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 2, 0, + 0, 0, 50, 0, 0, 9, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 32, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 11, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 50, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 16, 32, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 12, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 4, 0, 0, 0, 50, 32, + 0, 9, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 228, 0, 0, 0, + 8, 0, 0, 0, 8, 0, + 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 15, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 0, + 0, 0, 218, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 7, + 0, 0, 218, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 7, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_mainTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_mainTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..33d63773c738f887749816d812f5845197d1a14b --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_mainTx.inc @@ -0,0 +1,360 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c1 cb1 0 5 ( FLT, FLT, FLT, FLT) +// c6 cb1 9 4 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1.xy + dcl t2.xyz + dcl_2d s0 + texld r0, t1, s0 + nrm r1.xyz, t2 + dp3_sat r1.w, c6, r1 + mul r2.xyz, r1.w, c2 + mul r2.xyz, r2, t0 + mov r3.xyz, c0 + mad r2.xyz, r3, c1, r2 + dp3_sat r1.w, c7, r1 + mul r3.xyz, r1.w, c3 + mad r2.xyz, r3, t0, r2 + dp3_sat r1.w, c8, r1 + dp3_sat r2.w, c9, r1 + mul r1.xyz, r2.w, c5 + mul r3.xyz, r1.w, c4 + mad r2.xyz, r3, t0, r2 + mad_sat r1.xyz, r1, t0, r2 + mul r1.xyz, r0, r1 + mul r1.w, r0.w, t0.w + mov oC0, r1 + +// approximately 21 instruction slots used (1 texture, 20 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[1], immediateIndexed +dcl_constantbuffer CB1[13], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 3 +dp3 r0.x, v3.xyzx, v3.xyzx +rsq r0.x, r0.x +mul r0.xyz, r0.xxxx, v3.xyzx +dp3_sat r0.w, cb1[9].xyzx, r0.xyzx +mul r1.xyz, r0.wwww, cb1[1].xyzx +mul r1.xyz, r1.xyzx, v1.xyzx +mad r1.xyz, cb0[0].xyzx, cb1[0].xyzx, r1.xyzx +dp3_sat r0.w, cb1[10].xyzx, r0.xyzx +mul r2.xyz, r0.wwww, cb1[2].xyzx +mad r1.xyz, r2.xyzx, v1.xyzx, r1.xyzx +dp3_sat r0.w, cb1[11].xyzx, r0.xyzx +dp3_sat r0.x, cb1[12].xyzx, r0.xyzx +mul r0.xyz, r0.xxxx, cb1[4].xyzx +mul r2.xyz, r0.wwww, cb1[3].xyzx +mad r1.xyz, r2.xyzx, v1.xyzx, r1.xyzx +mad_sat r0.xyz, r0.xyzx, v1.xyzx, r1.xyzx +sample r1.xyzw, v2.xyxx, t0.xyzw, s0 +mul o0.xyz, r0.xyzx, r1.xyzx +mul o0.w, r1.w, v1.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLLambert_mainTx[] = +{ + 68, 88, 66, 67, 102, 190, + 51, 178, 209, 36, 176, 183, + 170, 53, 17, 30, 248, 77, + 247, 254, 1, 0, 0, 0, + 244, 5, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 240, 1, 0, 0, 212, 4, + 0, 0, 192, 5, 0, 0, + 65, 111, 110, 57, 184, 1, + 0, 0, 184, 1, 0, 0, + 0, 2, 255, 255, 108, 1, + 0, 0, 76, 0, 0, 0, + 3, 0, 40, 0, 0, 0, + 76, 0, 0, 0, 76, 0, + 1, 0, 36, 0, 0, 0, + 76, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 5, 0, + 1, 0, 0, 0, 0, 0, + 1, 0, 9, 0, 4, 0, + 6, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 176, 8, 0, 0, 3, + 1, 0, 24, 128, 6, 0, + 228, 160, 1, 0, 228, 128, + 5, 0, 0, 3, 2, 0, + 7, 128, 1, 0, 255, 128, + 2, 0, 228, 160, 5, 0, + 0, 3, 2, 0, 7, 128, + 2, 0, 228, 128, 0, 0, + 228, 176, 1, 0, 0, 2, + 3, 0, 7, 128, 0, 0, + 228, 160, 4, 0, 0, 4, + 2, 0, 7, 128, 3, 0, + 228, 128, 1, 0, 228, 160, + 2, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 24, 128, + 7, 0, 228, 160, 1, 0, + 228, 128, 5, 0, 0, 3, + 3, 0, 7, 128, 1, 0, + 255, 128, 3, 0, 228, 160, + 4, 0, 0, 4, 2, 0, + 7, 128, 3, 0, 228, 128, + 0, 0, 228, 176, 2, 0, + 228, 128, 8, 0, 0, 3, + 1, 0, 24, 128, 8, 0, + 228, 160, 1, 0, 228, 128, + 8, 0, 0, 3, 2, 0, + 24, 128, 9, 0, 228, 160, + 1, 0, 228, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 2, 0, 255, 128, 5, 0, + 228, 160, 5, 0, 0, 3, + 3, 0, 7, 128, 1, 0, + 255, 128, 4, 0, 228, 160, + 4, 0, 0, 4, 2, 0, + 7, 128, 3, 0, 228, 128, + 0, 0, 228, 176, 2, 0, + 228, 128, 4, 0, 0, 4, + 1, 0, 23, 128, 1, 0, + 228, 128, 0, 0, 228, 176, + 2, 0, 228, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 0, 0, 228, 128, 1, 0, + 228, 128, 5, 0, 0, 3, + 1, 0, 8, 128, 0, 0, + 255, 128, 0, 0, 255, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 1, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 220, 2, 0, 0, + 64, 0, 0, 0, 183, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 1, 0, 0, 0, + 13, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 3, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 68, 0, 0, 5, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 16, 32, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 9, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 16, 32, 0, 8, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 10, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 2, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 32, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 11, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 32, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 12, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 0, 0, + 0, 0, 6, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 4, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 50, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 50, 32, 0, 9, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 32, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 58, 16, 16, 0, 1, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 228, 0, + 0, 0, 8, 0, 0, 0, + 8, 0, 0, 0, 200, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 212, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 15, 0, 0, 218, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 218, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 7, 0, 0, 218, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 7, 0, 0, 0, 218, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 5, 0, 0, 0, + 7, 0, 0, 0, 218, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 6, 0, 0, 0, + 15, 0, 0, 0, 218, 0, + 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 7, 0, 0, 0, + 7, 0, 0, 0, 83, 86, + 95, 80, 79, 83, 73, 84, + 73, 79, 78, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_mainTxTk.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_mainTxTk.inc new file mode 100644 index 0000000000000000000000000000000000000000..62c457bba3c2d5480043e5c22d52a1976e97011c --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLLambert_mainTxTk.inc @@ -0,0 +1,389 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c1 cb1 0 5 ( FLT, FLT, FLT, FLT) +// c6 cb1 9 4 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c10, -1, -0, 0, 0 + dcl t0 + dcl t1.xy + dcl t2.xyz + dcl_2d s0 + texld r0, t1, s0 + mul r1.w, r0.w, t0.w + mul r0.w, r1.w, r1.w + cmp r2, -r0.w, c10.x, c10.y + texkill r2 + nrm r2.xyz, t2 + dp3_sat r0.w, c6, r2 + mul r3.xyz, r0.w, c2 + mul r3.xyz, r3, t0 + mov r4.xyz, c0 + mad r3.xyz, r4, c1, r3 + dp3_sat r0.w, c7, r2 + mul r4.xyz, r0.w, c3 + mad r3.xyz, r4, t0, r3 + dp3_sat r0.w, c8, r2 + mul r4.xyz, r0.w, c4 + mad r3.xyz, r4, t0, r3 + dp3_sat r0.w, c9, r2 + mul r2.xyz, r0.w, c5 + mad_sat r2.xyz, r2, t0, r3 + mul r1.xyz, r0, r2 + mov oC0, r1 + +// approximately 24 instruction slots used (1 texture, 23 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[1], immediateIndexed +dcl_constantbuffer CB1[13], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 4 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul r0.w, r0.w, v1.w +eq r1.x, r0.w, l(0.000000) +discard_nz r1.x +dp3 r1.x, v3.xyzx, v3.xyzx +rsq r1.x, r1.x +mul r1.xyz, r1.xxxx, v3.xyzx +dp3_sat r1.w, cb1[9].xyzx, r1.xyzx +mul r2.xyz, r1.wwww, cb1[1].xyzx +mul r2.xyz, r2.xyzx, v1.xyzx +mad r2.xyz, cb0[0].xyzx, cb1[0].xyzx, r2.xyzx +dp3_sat r1.w, cb1[10].xyzx, r1.xyzx +mul r3.xyz, r1.wwww, cb1[2].xyzx +mad r2.xyz, r3.xyzx, v1.xyzx, r2.xyzx +dp3_sat r1.w, cb1[11].xyzx, r1.xyzx +mul r3.xyz, r1.wwww, cb1[3].xyzx +mad r2.xyz, r3.xyzx, v1.xyzx, r2.xyzx +dp3_sat r1.x, cb1[12].xyzx, r1.xyzx +mul r1.xyz, r1.xxxx, cb1[4].xyzx +mad_sat r1.xyz, r1.xyzx, v1.xyzx, r2.xyzx +mul o0.xyz, r0.xyzx, r1.xyzx +mov o0.w, r0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLLambert_mainTxTk[] = +{ + 68, 88, 66, 67, 107, 124, + 177, 187, 78, 194, 93, 193, + 234, 37, 210, 51, 232, 235, + 240, 102, 1, 0, 0, 0, + 116, 6, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 52, 2, 0, 0, 84, 5, + 0, 0, 64, 6, 0, 0, + 65, 111, 110, 57, 252, 1, + 0, 0, 252, 1, 0, 0, + 0, 2, 255, 255, 176, 1, + 0, 0, 76, 0, 0, 0, + 3, 0, 40, 0, 0, 0, + 76, 0, 0, 0, 76, 0, + 1, 0, 36, 0, 0, 0, + 76, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 5, 0, + 1, 0, 0, 0, 0, 0, + 1, 0, 9, 0, 4, 0, + 6, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 81, 0, + 0, 5, 10, 0, 15, 160, + 0, 0, 128, 191, 0, 0, + 0, 128, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 1, 0, 8, 128, 0, 0, + 255, 128, 0, 0, 255, 176, + 5, 0, 0, 3, 0, 0, + 8, 128, 1, 0, 255, 128, + 1, 0, 255, 128, 88, 0, + 0, 4, 2, 0, 15, 128, + 0, 0, 255, 129, 10, 0, + 0, 160, 10, 0, 85, 160, + 65, 0, 0, 1, 2, 0, + 15, 128, 36, 0, 0, 2, + 2, 0, 7, 128, 2, 0, + 228, 176, 8, 0, 0, 3, + 0, 0, 24, 128, 6, 0, + 228, 160, 2, 0, 228, 128, + 5, 0, 0, 3, 3, 0, + 7, 128, 0, 0, 255, 128, + 2, 0, 228, 160, 5, 0, + 0, 3, 3, 0, 7, 128, + 3, 0, 228, 128, 0, 0, + 228, 176, 1, 0, 0, 2, + 4, 0, 7, 128, 0, 0, + 228, 160, 4, 0, 0, 4, + 3, 0, 7, 128, 4, 0, + 228, 128, 1, 0, 228, 160, + 3, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 24, 128, + 7, 0, 228, 160, 2, 0, + 228, 128, 5, 0, 0, 3, + 4, 0, 7, 128, 0, 0, + 255, 128, 3, 0, 228, 160, + 4, 0, 0, 4, 3, 0, + 7, 128, 4, 0, 228, 128, + 0, 0, 228, 176, 3, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 24, 128, 8, 0, + 228, 160, 2, 0, 228, 128, + 5, 0, 0, 3, 4, 0, + 7, 128, 0, 0, 255, 128, + 4, 0, 228, 160, 4, 0, + 0, 4, 3, 0, 7, 128, + 4, 0, 228, 128, 0, 0, + 228, 176, 3, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 24, 128, 9, 0, 228, 160, + 2, 0, 228, 128, 5, 0, + 0, 3, 2, 0, 7, 128, + 0, 0, 255, 128, 5, 0, + 228, 160, 4, 0, 0, 4, + 2, 0, 23, 128, 2, 0, + 228, 128, 0, 0, 228, 176, + 3, 0, 228, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 0, 0, 228, 128, 2, 0, + 228, 128, 1, 0, 0, 2, + 0, 8, 15, 128, 1, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 24, 3, + 0, 0, 64, 0, 0, 0, + 198, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 1, 0, + 0, 0, 13, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 4, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 58, 16, 16, 0, + 1, 0, 0, 0, 24, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 13, 0, 4, 3, + 10, 0, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 68, 0, 0, 5, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 6, 0, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 16, 32, 0, 8, 130, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 9, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 32, + 0, 8, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 10, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 3, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 2, 0, + 0, 0, 50, 0, 0, 9, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 16, 32, 0, 8, + 130, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 11, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 50, 0, 0, 9, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 16, 32, 0, 8, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 12, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 1, 0, + 0, 0, 6, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 4, 0, 0, 0, 50, 32, + 0, 9, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 228, 0, 0, 0, 8, 0, + 0, 0, 8, 0, 0, 0, + 200, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 212, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 218, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 7, 0, 0, + 218, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 7, 0, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_main.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_main.inc new file mode 100644 index 0000000000000000000000000000000000000000..91ae6888480b0bc6750a48a33906b725a46e8888 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_main.inc @@ -0,0 +1,614 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c1 cb0 2 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 4 1 ( FLT, FLT, FLT, FLT) +// c3 cb1 0 4 ( FLT, FLT, FLT, FLT) +// c7 cb1 9 3 ( FLT, FLT, FLT, FLT) +// c10 cb1 13 3 ( FLT, FLT, FLT, FLT) +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c13, 9.99999975e-005, 0, 0, 0 + dcl t0 + dcl t2.xyz + dcl t4.xyz + mov r0.xyz, c1 + mul r1.xyz, r0, c4 + mul r2.xyz, r0, c5 + dp3 r0.w, t4, t4 + rsq r0.w, r0.w + mad r3.xyz, t4, r0.w, c8 + nrm r4.xyz, r3 + nrm r3.xyz, t2 + dp3_sat r1.w, r3, r4 + mov r2.w, c2.x + max r3.w, r2.w, c13.x + pow r2.w, r1.w, r3.w + mul r1.w, r2.w, c11.x + mul r2.xyz, r1.w, r2 + mad r4.xyz, t4, r0.w, c7 + mad r5.xyz, t4, r0.w, c9 + nrm r6.xyz, r5 + dp3_sat r0.w, r3, r6 + pow r1.w, r0.w, r3.w + mul r0.w, r1.w, c12.x + nrm r5.xyz, r4 + dp3_sat r1.w, r3, r5 + pow r2.w, r1.w, r3.w + mul r1.w, r2.w, c10.x + mad r1.xyz, r1, r1.w, r2 + mul r0.xyz, r0, c6 + mad r0.xyz, r0, r0.w, r1 + dp3_sat r0.w, c7, r3 + mul r1.xyz, r0.w, c4 + mul r1.xyz, r1, t0 + mov r2.xyz, c0 + mad r1.xyz, r2, c3, r1 + dp3_sat r0.w, c8, r3 + dp3_sat r1.w, c9, r3 + mul r2.xyz, r1.w, c6 + mul r3.xyz, r0.w, c5 + mad r1.xyz, r3, t0, r1 + mad_sat r1.xyz, r2, t0, r1 + add r0.xyz, r0, r1 + mov r0.w, t0.w + mov oC0, r0 + +// approximately 55 instruction slots used +ps_4_0 +dcl_constantbuffer CB0[5], immediateIndexed +dcl_constantbuffer CB1[16], immediateIndexed +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v3.xyz +dcl_input_ps linear v5.xyz +dcl_output o0.xyzw +dcl_temps 5 +mul r0.xyz, cb0[2].xyzx, cb1[1].xyzx +mul r1.xyz, cb0[2].xyzx, cb1[2].xyzx +dp3 r0.w, v5.xyzx, v5.xyzx +rsq r0.w, r0.w +mad r2.xyz, v5.xyzx, r0.wwww, cb1[10].xyzx +dp3 r1.w, r2.xyzx, r2.xyzx +rsq r1.w, r1.w +mul r2.xyz, r1.wwww, r2.xyzx +dp3 r1.w, v3.xyzx, v3.xyzx +rsq r1.w, r1.w +mul r3.xyz, r1.wwww, v3.xyzx +dp3_sat r1.w, r3.xyzx, r2.xyzx +log r1.w, r1.w +max r2.x, cb0[4].x, l(0.000100) +mul r1.w, r1.w, r2.x +exp r1.w, r1.w +mul r1.w, r1.w, cb1[14].x +mul r1.xyz, r1.wwww, r1.xyzx +mad r2.yzw, v5.xxyz, r0.wwww, cb1[9].xxyz +mad r4.xyz, v5.xyzx, r0.wwww, cb1[11].xyzx +dp3 r0.w, r2.yzwy, r2.yzwy +rsq r0.w, r0.w +mul r2.yzw, r0.wwww, r2.yyzw +dp3_sat r0.w, r3.xyzx, r2.yzwy +log r0.w, r0.w +mul r0.w, r0.w, r2.x +exp r0.w, r0.w +mul r0.w, r0.w, cb1[13].x +mad r0.xyz, r0.xyzx, r0.wwww, r1.xyzx +mul r1.xyz, cb0[2].xyzx, cb1[3].xyzx +dp3 r0.w, r4.xyzx, r4.xyzx +rsq r0.w, r0.w +mul r2.yzw, r0.wwww, r4.xxyz +dp3_sat r0.w, r3.xyzx, r2.yzwy +log r0.w, r0.w +mul r0.w, r0.w, r2.x +exp r0.w, r0.w +mul r0.w, r0.w, cb1[15].x +mad r0.xyz, r1.xyzx, r0.wwww, r0.xyzx +dp3_sat r0.w, cb1[9].xyzx, r3.xyzx +mul r1.xyz, r0.wwww, cb1[1].xyzx +mul r1.xyz, r1.xyzx, v1.xyzx +mad r1.xyz, cb0[0].xyzx, cb1[0].xyzx, r1.xyzx +dp3_sat r0.w, cb1[10].xyzx, r3.xyzx +dp3_sat r1.w, cb1[11].xyzx, r3.xyzx +mul r2.xyz, r1.wwww, cb1[3].xyzx +mul r3.xyz, r0.wwww, cb1[2].xyzx +mad r1.xyz, r3.xyzx, v1.xyzx, r1.xyzx +mad_sat r1.xyz, r2.xyzx, v1.xyzx, r1.xyzx +add o0.xyz, r0.xyzx, r1.xyzx +mov o0.w, v1.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLPhong_main[] = +{ + 68, 88, 66, 67, 192, 92, + 10, 227, 116, 179, 173, 54, + 64, 25, 7, 160, 209, 177, + 147, 171, 1, 0, 0, 0, + 196, 10, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 112, 3, 0, 0, 164, 9, + 0, 0, 144, 10, 0, 0, + 65, 111, 110, 57, 56, 3, + 0, 0, 56, 3, 0, 0, + 0, 2, 255, 255, 204, 2, + 0, 0, 108, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 1, 0, 2, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 4, 0, 3, 0, 0, 0, + 0, 0, 1, 0, 9, 0, + 3, 0, 7, 0, 0, 0, + 0, 0, 1, 0, 13, 0, + 3, 0, 10, 0, 0, 0, + 0, 0, 0, 2, 255, 255, + 81, 0, 0, 5, 13, 0, + 15, 160, 23, 183, 209, 56, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 2, 0, 7, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 4, 0, 7, 176, + 1, 0, 0, 2, 0, 0, + 7, 128, 1, 0, 228, 160, + 5, 0, 0, 3, 1, 0, + 7, 128, 0, 0, 228, 128, + 4, 0, 228, 160, 5, 0, + 0, 3, 2, 0, 7, 128, + 0, 0, 228, 128, 5, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 8, 128, 4, 0, + 228, 176, 4, 0, 228, 176, + 7, 0, 0, 2, 0, 0, + 8, 128, 0, 0, 255, 128, + 4, 0, 0, 4, 3, 0, + 7, 128, 4, 0, 228, 176, + 0, 0, 255, 128, 8, 0, + 228, 160, 36, 0, 0, 2, + 4, 0, 7, 128, 3, 0, + 228, 128, 36, 0, 0, 2, + 3, 0, 7, 128, 2, 0, + 228, 176, 8, 0, 0, 3, + 1, 0, 24, 128, 3, 0, + 228, 128, 4, 0, 228, 128, + 1, 0, 0, 2, 2, 0, + 8, 128, 2, 0, 0, 160, + 11, 0, 0, 3, 3, 0, + 8, 128, 2, 0, 255, 128, + 13, 0, 0, 160, 32, 0, + 0, 3, 2, 0, 8, 128, + 1, 0, 255, 128, 3, 0, + 255, 128, 5, 0, 0, 3, + 1, 0, 8, 128, 2, 0, + 255, 128, 11, 0, 0, 160, + 5, 0, 0, 3, 2, 0, + 7, 128, 1, 0, 255, 128, + 2, 0, 228, 128, 4, 0, + 0, 4, 4, 0, 7, 128, + 4, 0, 228, 176, 0, 0, + 255, 128, 7, 0, 228, 160, + 4, 0, 0, 4, 5, 0, + 7, 128, 4, 0, 228, 176, + 0, 0, 255, 128, 9, 0, + 228, 160, 36, 0, 0, 2, + 6, 0, 7, 128, 5, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 24, 128, 3, 0, + 228, 128, 6, 0, 228, 128, + 32, 0, 0, 3, 1, 0, + 8, 128, 0, 0, 255, 128, + 3, 0, 255, 128, 5, 0, + 0, 3, 0, 0, 8, 128, + 1, 0, 255, 128, 12, 0, + 0, 160, 36, 0, 0, 2, + 5, 0, 7, 128, 4, 0, + 228, 128, 8, 0, 0, 3, + 1, 0, 24, 128, 3, 0, + 228, 128, 5, 0, 228, 128, + 32, 0, 0, 3, 2, 0, + 8, 128, 1, 0, 255, 128, + 3, 0, 255, 128, 5, 0, + 0, 3, 1, 0, 8, 128, + 2, 0, 255, 128, 10, 0, + 0, 160, 4, 0, 0, 4, + 1, 0, 7, 128, 1, 0, + 228, 128, 1, 0, 255, 128, + 2, 0, 228, 128, 5, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 228, 128, 6, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 128, 0, 0, + 228, 128, 0, 0, 255, 128, + 1, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 24, 128, + 7, 0, 228, 160, 3, 0, + 228, 128, 5, 0, 0, 3, + 1, 0, 7, 128, 0, 0, + 255, 128, 4, 0, 228, 160, + 5, 0, 0, 3, 1, 0, + 7, 128, 1, 0, 228, 128, + 0, 0, 228, 176, 1, 0, + 0, 2, 2, 0, 7, 128, + 0, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 2, 0, 228, 128, 3, 0, + 228, 160, 1, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 24, 128, 8, 0, 228, 160, + 3, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 24, 128, + 9, 0, 228, 160, 3, 0, + 228, 128, 5, 0, 0, 3, + 2, 0, 7, 128, 1, 0, + 255, 128, 6, 0, 228, 160, + 5, 0, 0, 3, 3, 0, + 7, 128, 0, 0, 255, 128, + 5, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 3, 0, 228, 128, 0, 0, + 228, 176, 1, 0, 228, 128, + 4, 0, 0, 4, 1, 0, + 23, 128, 2, 0, 228, 128, + 0, 0, 228, 176, 1, 0, + 228, 128, 2, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 1, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 128, 0, 0, 255, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 0, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 44, 6, 0, 0, + 64, 0, 0, 0, 139, 1, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 1, 0, 0, 0, + 16, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 3, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 5, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 5, 0, 0, 0, + 56, 0, 0, 9, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 2, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 5, 0, + 0, 0, 70, 18, 16, 0, + 5, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 5, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 10, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 16, 32, 0, 7, 130, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 47, 0, + 0, 5, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 52, 0, 0, 8, 18, 0, + 16, 0, 2, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 23, 183, + 209, 56, 56, 0, 0, 7, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 8, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 10, 128, + 32, 0, 1, 0, 0, 0, + 14, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 226, 0, 16, 0, 2, 0, + 0, 0, 6, 25, 16, 0, + 5, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 1, 0, + 0, 0, 9, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 5, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 11, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 226, 0, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 86, 14, 16, 0, 2, 0, + 0, 0, 16, 32, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 47, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 10, 128, + 32, 0, 1, 0, 0, 0, + 13, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 9, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 226, 0, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 6, 9, 16, 0, 4, 0, + 0, 0, 16, 32, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 47, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 10, 128, + 32, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 32, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 9, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 32, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 10, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 16, 32, + 0, 8, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 11, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 2, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 50, 32, + 0, 9, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 7, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 16, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 228, 0, 0, 0, 8, 0, + 0, 0, 8, 0, 0, 0, + 200, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 212, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 0, 0, 0, + 218, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 7, 0, 0, + 218, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 7, 7, 0, 0, + 218, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 7, 0, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_mainTk.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_mainTk.inc new file mode 100644 index 0000000000000000000000000000000000000000..5a3702c8cb6a82cd84df8b60a4ee5587b2ee1925 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_mainTk.inc @@ -0,0 +1,633 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c1 cb0 2 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 4 1 ( FLT, FLT, FLT, FLT) +// c3 cb1 0 4 ( FLT, FLT, FLT, FLT) +// c7 cb1 9 3 ( FLT, FLT, FLT, FLT) +// c10 cb1 13 3 ( FLT, FLT, FLT, FLT) +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c13, -1, -0, 9.99999975e-005, 0 + dcl t0 + dcl t2.xyz + dcl t4.xyz + mul r0.w, t0.w, t0.w + cmp r0, -r0.w, c13.x, c13.y + texkill r0 + dp3 r0.x, t4, t4 + rsq r0.x, r0.x + mad r1.xyz, t4, r0.x, c9 + nrm r2.xyz, r1 + nrm r1.xyz, t2 + dp3_sat r1.w, r1, r2 + dp3_sat r0.y, c7, r1 + mul r0.yzw, r0.y, c4.wzyx + mul r0.yzw, r0, t0.wzyx + mov r2.xyz, c0 + mad r0.yzw, r2.wzyx, c3.wzyx, r0 + mov r2.z, c13.z + max r3.w, c2.x, r2.z + dp3_sat r2.x, c8, r1 + mul r2.xyz, r2.x, c5 + mad r0.yzw, r2.wzyx, t0.wzyx, r0 + dp3_sat r2.x, c9, r1 + mul r2.xyz, r2.x, c6 + mad_sat r0.yzw, r2.wzyx, t0.wzyx, r0 + pow r2.x, r1.w, r3.w + mul r1.w, r2.x, c12.x + mad r2.xyz, t4, r0.x, c8 + nrm r3.xyz, r2 + dp3_sat r2.x, r1, r3 + pow r4.w, r2.x, r3.w + mul r2.x, r4.w, c11.x + mad r3.xyz, t4, r0.x, c7 + nrm r4.xyz, r3 + dp3_sat r0.x, r1, r4 + pow r1.x, r0.x, r3.w + mul r0.x, r1.x, c10.x + mov r1.xyz, c1 + mul r2.yzw, r1.wzyx, c5.wzyx + mul r2.xyz, r2.x, r2.wzyx + mul r3.xyz, r1, c4 + mad r2.xyz, r3, r0.x, r2 + mul r1.xyz, r1, c6 + mad r1.xyz, r1, r1.w, r2 + add r0.xyz, r0.wzyx, r1 + mov r0.w, t0.w + mov oC0, r0 + +// approximately 58 instruction slots used +ps_4_0 +dcl_constantbuffer CB0[5], immediateIndexed +dcl_constantbuffer CB1[16], immediateIndexed +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v3.xyz +dcl_input_ps linear v5.xyz +dcl_output o0.xyzw +dcl_temps 4 +eq r0.x, v1.w, l(0.000000) +discard_nz r0.x +dp3 r0.x, v3.xyzx, v3.xyzx +rsq r0.x, r0.x +mul r0.xyz, r0.xxxx, v3.xyzx +dp3 r0.w, v5.xyzx, v5.xyzx +rsq r0.w, r0.w +dp3_sat r1.x, cb1[9].xyzx, r0.xyzx +mul r1.xyz, r1.xxxx, cb1[1].xyzx +mul r1.xyz, r1.xyzx, v1.xyzx +mad r1.xyz, cb0[0].xyzx, cb1[0].xyzx, r1.xyzx +mad r2.xyz, v5.xyzx, r0.wwww, cb1[9].xyzx +dp3 r1.w, r2.xyzx, r2.xyzx +rsq r1.w, r1.w +mul r2.xyz, r1.wwww, r2.xyzx +dp3_sat r1.w, r0.xyzx, r2.xyzx +max r2.x, cb0[4].x, l(0.000100) +log r1.w, r1.w +mul r1.w, r1.w, r2.x +exp r1.w, r1.w +mul r1.w, r1.w, cb1[13].x +mul r2.yzw, cb0[2].xxyz, cb1[1].xxyz +dp3_sat r3.x, cb1[10].xyzx, r0.xyzx +mul r3.xyz, r3.xxxx, cb1[2].xyzx +mad r1.xyz, r3.xyzx, v1.xyzx, r1.xyzx +mad r3.xyz, v5.xyzx, r0.wwww, cb1[10].xyzx +dp3 r3.w, r3.xyzx, r3.xyzx +rsq r3.w, r3.w +mul r3.xyz, r3.wwww, r3.xyzx +dp3_sat r3.x, r0.xyzx, r3.xyzx +log r3.x, r3.x +mul r3.x, r2.x, r3.x +exp r3.x, r3.x +mul r3.x, r3.x, cb1[14].x +mul r3.yzw, cb0[2].xxyz, cb1[2].xxyz +mul r3.xyz, r3.xxxx, r3.yzwy +mad r2.yzw, r2.yyzw, r1.wwww, r3.xxyz +dp3_sat r1.w, cb1[11].xyzx, r0.xyzx +mul r3.xyz, r1.wwww, cb1[3].xyzx +mad_sat r1.xyz, r3.xyzx, v1.xyzx, r1.xyzx +mad r3.xyz, v5.xyzx, r0.wwww, cb1[11].xyzx +dp3 r0.w, r3.xyzx, r3.xyzx +rsq r0.w, r0.w +mul r3.xyz, r0.wwww, r3.xyzx +dp3_sat r0.x, r0.xyzx, r3.xyzx +log r0.x, r0.x +mul r0.x, r0.x, r2.x +exp r0.x, r0.x +mul r0.x, r0.x, cb1[15].x +mul r0.yzw, cb0[2].xxyz, cb1[3].xxyz +mad r0.xyz, r0.yzwy, r0.xxxx, r2.yzwy +add o0.xyz, r0.xyzx, r1.xyzx +mov o0.w, v1.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLPhong_mainTk[] = +{ + 68, 88, 66, 67, 221, 72, + 234, 251, 154, 213, 166, 22, + 92, 34, 162, 216, 59, 148, + 181, 251, 1, 0, 0, 0, + 24, 11, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 156, 3, 0, 0, 248, 9, + 0, 0, 228, 10, 0, 0, + 65, 111, 110, 57, 100, 3, + 0, 0, 100, 3, 0, 0, + 0, 2, 255, 255, 248, 2, + 0, 0, 108, 0, 0, 0, + 6, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 108, 0, + 0, 0, 36, 0, 0, 0, + 108, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 1, 0, 2, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 4, 0, 3, 0, 0, 0, + 0, 0, 1, 0, 9, 0, + 3, 0, 7, 0, 0, 0, + 0, 0, 1, 0, 13, 0, + 3, 0, 10, 0, 0, 0, + 0, 0, 0, 2, 255, 255, + 81, 0, 0, 5, 13, 0, + 15, 160, 0, 0, 128, 191, + 0, 0, 0, 128, 23, 183, + 209, 56, 0, 0, 0, 0, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 2, 0, 7, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 4, 0, 7, 176, + 5, 0, 0, 3, 0, 0, + 8, 128, 0, 0, 255, 176, + 0, 0, 255, 176, 88, 0, + 0, 4, 0, 0, 15, 128, + 0, 0, 255, 129, 13, 0, + 0, 160, 13, 0, 85, 160, + 65, 0, 0, 1, 0, 0, + 15, 128, 8, 0, 0, 3, + 0, 0, 1, 128, 4, 0, + 228, 176, 4, 0, 228, 176, + 7, 0, 0, 2, 0, 0, + 1, 128, 0, 0, 0, 128, + 4, 0, 0, 4, 1, 0, + 7, 128, 4, 0, 228, 176, + 0, 0, 0, 128, 9, 0, + 228, 160, 36, 0, 0, 2, + 2, 0, 7, 128, 1, 0, + 228, 128, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 176, 8, 0, 0, 3, + 1, 0, 24, 128, 1, 0, + 228, 128, 2, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 18, 128, 7, 0, 228, 160, + 1, 0, 228, 128, 5, 0, + 0, 3, 0, 0, 14, 128, + 0, 0, 85, 128, 4, 0, + 27, 160, 5, 0, 0, 3, + 0, 0, 14, 128, 0, 0, + 228, 128, 0, 0, 27, 176, + 1, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 14, 128, 2, 0, 27, 128, + 3, 0, 27, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 2, 0, 4, 128, 13, 0, + 170, 160, 11, 0, 0, 3, + 3, 0, 8, 128, 2, 0, + 0, 160, 2, 0, 170, 128, + 8, 0, 0, 3, 2, 0, + 17, 128, 8, 0, 228, 160, + 1, 0, 228, 128, 5, 0, + 0, 3, 2, 0, 7, 128, + 2, 0, 0, 128, 5, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 14, 128, 2, 0, + 27, 128, 0, 0, 27, 176, + 0, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 17, 128, + 9, 0, 228, 160, 1, 0, + 228, 128, 5, 0, 0, 3, + 2, 0, 7, 128, 2, 0, + 0, 128, 6, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 30, 128, 2, 0, 27, 128, + 0, 0, 27, 176, 0, 0, + 228, 128, 32, 0, 0, 3, + 2, 0, 1, 128, 1, 0, + 255, 128, 3, 0, 255, 128, + 5, 0, 0, 3, 1, 0, + 8, 128, 2, 0, 0, 128, + 12, 0, 0, 160, 4, 0, + 0, 4, 2, 0, 7, 128, + 4, 0, 228, 176, 0, 0, + 0, 128, 8, 0, 228, 160, + 36, 0, 0, 2, 3, 0, + 7, 128, 2, 0, 228, 128, + 8, 0, 0, 3, 2, 0, + 17, 128, 1, 0, 228, 128, + 3, 0, 228, 128, 32, 0, + 0, 3, 4, 0, 8, 128, + 2, 0, 0, 128, 3, 0, + 255, 128, 5, 0, 0, 3, + 2, 0, 1, 128, 4, 0, + 255, 128, 11, 0, 0, 160, + 4, 0, 0, 4, 3, 0, + 7, 128, 4, 0, 228, 176, + 0, 0, 0, 128, 7, 0, + 228, 160, 36, 0, 0, 2, + 4, 0, 7, 128, 3, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 17, 128, 1, 0, + 228, 128, 4, 0, 228, 128, + 32, 0, 0, 3, 1, 0, + 1, 128, 0, 0, 0, 128, + 3, 0, 255, 128, 5, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 0, 128, 10, 0, + 0, 160, 1, 0, 0, 2, + 1, 0, 7, 128, 1, 0, + 228, 160, 5, 0, 0, 3, + 2, 0, 14, 128, 1, 0, + 27, 128, 5, 0, 27, 160, + 5, 0, 0, 3, 2, 0, + 7, 128, 2, 0, 0, 128, + 2, 0, 27, 128, 5, 0, + 0, 3, 3, 0, 7, 128, + 1, 0, 228, 128, 4, 0, + 228, 160, 4, 0, 0, 4, + 2, 0, 7, 128, 3, 0, + 228, 128, 0, 0, 0, 128, + 2, 0, 228, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 1, 0, 228, 128, 6, 0, + 228, 160, 4, 0, 0, 4, + 1, 0, 7, 128, 1, 0, + 228, 128, 1, 0, 255, 128, + 2, 0, 228, 128, 2, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 27, 128, 1, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 176, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 84, 6, + 0, 0, 64, 0, 0, 0, + 149, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 1, 0, + 0, 0, 16, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 114, 16, + 16, 0, 3, 0, 0, 0, + 98, 16, 0, 3, 114, 16, + 16, 0, 5, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 4, 0, + 0, 0, 24, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 58, 16, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 13, 0, 4, 3, 10, 0, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 68, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 5, 0, 0, 0, + 70, 18, 16, 0, 5, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 16, 32, + 0, 8, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 9, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 18, 16, 0, + 5, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 9, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 32, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 52, 0, 0, 8, + 18, 0, 16, 0, 2, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 1, 64, 0, 0, + 23, 183, 209, 56, 47, 0, + 0, 5, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 25, 0, + 0, 5, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 10, 128, 32, 0, + 1, 0, 0, 0, 13, 0, + 0, 0, 56, 0, 0, 9, + 226, 0, 16, 0, 2, 0, + 0, 0, 6, 137, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 6, 137, 32, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 16, 32, 0, 8, + 18, 0, 16, 0, 3, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 10, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 3, 0, 0, 0, 6, 0, + 16, 0, 3, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 2, 0, 0, 0, + 50, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 3, 0, 0, 0, + 70, 18, 16, 0, 5, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 10, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 3, 0, + 0, 0, 58, 0, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 16, 32, 0, 7, + 18, 0, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 47, 0, 0, 5, 18, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 3, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 25, 0, 0, 5, 18, 0, + 16, 0, 3, 0, 0, 0, + 10, 0, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 8, + 18, 0, 16, 0, 3, 0, + 0, 0, 10, 0, 16, 0, + 3, 0, 0, 0, 10, 128, + 32, 0, 1, 0, 0, 0, + 14, 0, 0, 0, 56, 0, + 0, 9, 226, 0, 16, 0, + 3, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 6, 137, + 32, 0, 1, 0, 0, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 3, 0, 0, 0, 6, 0, + 16, 0, 3, 0, 0, 0, + 150, 7, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 9, + 226, 0, 16, 0, 2, 0, + 0, 0, 86, 14, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 6, 9, 16, 0, 3, 0, + 0, 0, 16, 32, 0, 8, + 130, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 11, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 50, 32, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 3, 0, 0, 0, + 70, 18, 16, 0, 5, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 11, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 16, 32, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 47, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 10, 128, + 32, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 56, 0, + 0, 9, 226, 0, 16, 0, + 0, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 6, 137, + 32, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 150, 7, 16, 0, + 2, 0, 0, 0, 0, 0, + 0, 7, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 16, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 228, 0, 0, 0, 8, 0, + 0, 0, 8, 0, 0, 0, + 200, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 212, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 0, 0, 0, + 218, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 7, 0, 0, + 218, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 7, 7, 0, 0, + 218, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 7, 0, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_mainTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_mainTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..9a85634b6e98ec80912027974b639d7b169e37b9 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_mainTx.inc @@ -0,0 +1,652 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c1 cb0 2 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 4 1 ( FLT, FLT, FLT, FLT) +// c3 cb1 0 4 ( FLT, FLT, FLT, FLT) +// c7 cb1 9 3 ( FLT, FLT, FLT, FLT) +// c10 cb1 13 3 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c13, 9.99999975e-005, 0, 0, 0 + dcl t0 + dcl t1.xy + dcl t2.xyz + dcl t4.xyz + dcl_2d s0 + texld r0, t1, s0 + mov r1.xyz, c1 + mul r2.xyz, r1, c4 + mul r3.xyz, r1, c5 + dp3 r1.w, t4, t4 + rsq r1.w, r1.w + mad r4.xyz, t4, r1.w, c8 + nrm r5.xyz, r4 + nrm r4.xyz, t2 + dp3_sat r2.w, r4, r5 + mov r3.w, c2.x + max r4.w, r3.w, c13.x + pow r3.w, r2.w, r4.w + mul r2.w, r3.w, c11.x + mul r3.xyz, r2.w, r3 + mad r5.xyz, t4, r1.w, c7 + mad r6.xyz, t4, r1.w, c9 + nrm r7.xyz, r6 + dp3_sat r1.w, r4, r7 + pow r2.w, r1.w, r4.w + mul r1.w, r2.w, c12.x + nrm r6.xyz, r5 + dp3_sat r2.w, r4, r6 + pow r3.w, r2.w, r4.w + mul r2.w, r3.w, c10.x + mad r2.xyz, r2, r2.w, r3 + mul r1.xyz, r1, c6 + mad r1.xyz, r1, r1.w, r2 + dp3_sat r1.w, c7, r4 + mul r2.xyz, r1.w, c4 + mul r2.xyz, r2, t0 + mov r3.xyz, c0 + mad r2.xyz, r3, c3, r2 + dp3_sat r1.w, c8, r4 + dp3_sat r2.w, c9, r4 + mul r3.xyz, r2.w, c6 + mul r4.xyz, r1.w, c5 + mad r2.xyz, r4, t0, r2 + mad_sat r2.xyz, r3, t0, r2 + mad r1.xyz, r2, r0, r1 + mul r1.w, r0.w, t0.w + mov oC0, r1 + +// approximately 56 instruction slots used (1 texture, 55 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[5], immediateIndexed +dcl_constantbuffer CB1[16], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_input_ps linear v3.xyz +dcl_input_ps linear v5.xyz +dcl_output o0.xyzw +dcl_temps 5 +mul r0.xyz, cb0[2].xyzx, cb1[1].xyzx +mul r1.xyz, cb0[2].xyzx, cb1[2].xyzx +dp3 r0.w, v5.xyzx, v5.xyzx +rsq r0.w, r0.w +mad r2.xyz, v5.xyzx, r0.wwww, cb1[10].xyzx +dp3 r1.w, r2.xyzx, r2.xyzx +rsq r1.w, r1.w +mul r2.xyz, r1.wwww, r2.xyzx +dp3 r1.w, v3.xyzx, v3.xyzx +rsq r1.w, r1.w +mul r3.xyz, r1.wwww, v3.xyzx +dp3_sat r1.w, r3.xyzx, r2.xyzx +log r1.w, r1.w +max r2.x, cb0[4].x, l(0.000100) +mul r1.w, r1.w, r2.x +exp r1.w, r1.w +mul r1.w, r1.w, cb1[14].x +mul r1.xyz, r1.wwww, r1.xyzx +mad r2.yzw, v5.xxyz, r0.wwww, cb1[9].xxyz +mad r4.xyz, v5.xyzx, r0.wwww, cb1[11].xyzx +dp3 r0.w, r2.yzwy, r2.yzwy +rsq r0.w, r0.w +mul r2.yzw, r0.wwww, r2.yyzw +dp3_sat r0.w, r3.xyzx, r2.yzwy +log r0.w, r0.w +mul r0.w, r0.w, r2.x +exp r0.w, r0.w +mul r0.w, r0.w, cb1[13].x +mad r0.xyz, r0.xyzx, r0.wwww, r1.xyzx +mul r1.xyz, cb0[2].xyzx, cb1[3].xyzx +dp3 r0.w, r4.xyzx, r4.xyzx +rsq r0.w, r0.w +mul r2.yzw, r0.wwww, r4.xxyz +dp3_sat r0.w, r3.xyzx, r2.yzwy +log r0.w, r0.w +mul r0.w, r0.w, r2.x +exp r0.w, r0.w +mul r0.w, r0.w, cb1[15].x +mad r0.xyz, r1.xyzx, r0.wwww, r0.xyzx +dp3_sat r0.w, cb1[9].xyzx, r3.xyzx +mul r1.xyz, r0.wwww, cb1[1].xyzx +mul r1.xyz, r1.xyzx, v1.xyzx +mad r1.xyz, cb0[0].xyzx, cb1[0].xyzx, r1.xyzx +dp3_sat r0.w, cb1[10].xyzx, r3.xyzx +dp3_sat r1.w, cb1[11].xyzx, r3.xyzx +mul r2.xyz, r1.wwww, cb1[3].xyzx +mul r3.xyz, r0.wwww, cb1[2].xyzx +mad r1.xyz, r3.xyzx, v1.xyzx, r1.xyzx +mad_sat r1.xyz, r2.xyzx, v1.xyzx, r1.xyzx +sample r2.xyzw, v2.xyxx, t0.xyzw, s0 +mad o0.xyz, r1.xyzx, r2.xyzx, r0.xyzx +mul o0.w, r2.w, v1.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLPhong_mainTx[] = +{ + 68, 88, 66, 67, 122, 182, + 73, 74, 63, 27, 235, 112, + 1, 112, 173, 226, 75, 153, + 17, 221, 1, 0, 0, 0, + 84, 11, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 164, 3, 0, 0, 52, 10, + 0, 0, 32, 11, 0, 0, + 65, 111, 110, 57, 108, 3, + 0, 0, 108, 3, 0, 0, + 0, 2, 255, 255, 252, 2, + 0, 0, 112, 0, 0, 0, + 6, 0, 40, 0, 0, 0, + 112, 0, 0, 0, 112, 0, + 1, 0, 36, 0, 0, 0, + 112, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 1, 0, + 2, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 4, 0, + 3, 0, 0, 0, 0, 0, + 1, 0, 9, 0, 3, 0, + 7, 0, 0, 0, 0, 0, + 1, 0, 13, 0, 3, 0, + 10, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 81, 0, + 0, 5, 13, 0, 15, 160, + 23, 183, 209, 56, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 4, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 1, 0, 0, 2, + 1, 0, 7, 128, 1, 0, + 228, 160, 5, 0, 0, 3, + 2, 0, 7, 128, 1, 0, + 228, 128, 4, 0, 228, 160, + 5, 0, 0, 3, 3, 0, + 7, 128, 1, 0, 228, 128, + 5, 0, 228, 160, 8, 0, + 0, 3, 1, 0, 8, 128, + 4, 0, 228, 176, 4, 0, + 228, 176, 7, 0, 0, 2, + 1, 0, 8, 128, 1, 0, + 255, 128, 4, 0, 0, 4, + 4, 0, 7, 128, 4, 0, + 228, 176, 1, 0, 255, 128, + 8, 0, 228, 160, 36, 0, + 0, 2, 5, 0, 7, 128, + 4, 0, 228, 128, 36, 0, + 0, 2, 4, 0, 7, 128, + 2, 0, 228, 176, 8, 0, + 0, 3, 2, 0, 24, 128, + 4, 0, 228, 128, 5, 0, + 228, 128, 1, 0, 0, 2, + 3, 0, 8, 128, 2, 0, + 0, 160, 11, 0, 0, 3, + 4, 0, 8, 128, 3, 0, + 255, 128, 13, 0, 0, 160, + 32, 0, 0, 3, 3, 0, + 8, 128, 2, 0, 255, 128, + 4, 0, 255, 128, 5, 0, + 0, 3, 2, 0, 8, 128, + 3, 0, 255, 128, 11, 0, + 0, 160, 5, 0, 0, 3, + 3, 0, 7, 128, 2, 0, + 255, 128, 3, 0, 228, 128, + 4, 0, 0, 4, 5, 0, + 7, 128, 4, 0, 228, 176, + 1, 0, 255, 128, 7, 0, + 228, 160, 4, 0, 0, 4, + 6, 0, 7, 128, 4, 0, + 228, 176, 1, 0, 255, 128, + 9, 0, 228, 160, 36, 0, + 0, 2, 7, 0, 7, 128, + 6, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 24, 128, + 4, 0, 228, 128, 7, 0, + 228, 128, 32, 0, 0, 3, + 2, 0, 8, 128, 1, 0, + 255, 128, 4, 0, 255, 128, + 5, 0, 0, 3, 1, 0, + 8, 128, 2, 0, 255, 128, + 12, 0, 0, 160, 36, 0, + 0, 2, 6, 0, 7, 128, + 5, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 24, 128, + 4, 0, 228, 128, 6, 0, + 228, 128, 32, 0, 0, 3, + 3, 0, 8, 128, 2, 0, + 255, 128, 4, 0, 255, 128, + 5, 0, 0, 3, 2, 0, + 8, 128, 3, 0, 255, 128, + 10, 0, 0, 160, 4, 0, + 0, 4, 2, 0, 7, 128, + 2, 0, 228, 128, 2, 0, + 255, 128, 3, 0, 228, 128, + 5, 0, 0, 3, 1, 0, + 7, 128, 1, 0, 228, 128, + 6, 0, 228, 160, 4, 0, + 0, 4, 1, 0, 7, 128, + 1, 0, 228, 128, 1, 0, + 255, 128, 2, 0, 228, 128, + 8, 0, 0, 3, 1, 0, + 24, 128, 7, 0, 228, 160, + 4, 0, 228, 128, 5, 0, + 0, 3, 2, 0, 7, 128, + 1, 0, 255, 128, 4, 0, + 228, 160, 5, 0, 0, 3, + 2, 0, 7, 128, 2, 0, + 228, 128, 0, 0, 228, 176, + 1, 0, 0, 2, 3, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 2, 0, + 7, 128, 3, 0, 228, 128, + 3, 0, 228, 160, 2, 0, + 228, 128, 8, 0, 0, 3, + 1, 0, 24, 128, 8, 0, + 228, 160, 4, 0, 228, 128, + 8, 0, 0, 3, 2, 0, + 24, 128, 9, 0, 228, 160, + 4, 0, 228, 128, 5, 0, + 0, 3, 3, 0, 7, 128, + 2, 0, 255, 128, 6, 0, + 228, 160, 5, 0, 0, 3, + 4, 0, 7, 128, 1, 0, + 255, 128, 5, 0, 228, 160, + 4, 0, 0, 4, 2, 0, + 7, 128, 4, 0, 228, 128, + 0, 0, 228, 176, 2, 0, + 228, 128, 4, 0, 0, 4, + 2, 0, 23, 128, 3, 0, + 228, 128, 0, 0, 228, 176, + 2, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 7, 128, + 2, 0, 228, 128, 0, 0, + 228, 128, 1, 0, 228, 128, + 5, 0, 0, 3, 1, 0, + 8, 128, 0, 0, 255, 128, + 0, 0, 255, 176, 1, 0, + 0, 2, 0, 8, 15, 128, + 1, 0, 228, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 136, 6, 0, 0, 64, 0, + 0, 0, 162, 1, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 1, 0, 0, 0, 16, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 98, 16, 0, 3, 114, 16, + 16, 0, 3, 0, 0, 0, + 98, 16, 0, 3, 114, 16, + 16, 0, 5, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 5, 0, + 0, 0, 56, 0, 0, 9, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 56, 0, 0, 9, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 2, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 5, 0, 0, 0, 70, 18, + 16, 0, 5, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 18, 16, 0, + 5, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 10, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 16, 32, 0, 7, + 130, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 47, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 52, 0, 0, 8, + 18, 0, 16, 0, 2, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 1, 64, 0, 0, + 23, 183, 209, 56, 56, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 130, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 10, 128, 32, 0, 1, 0, + 0, 0, 14, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 226, 0, 16, 0, + 2, 0, 0, 0, 6, 25, + 16, 0, 5, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 6, 137, 32, 0, + 1, 0, 0, 0, 9, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 4, 0, + 0, 0, 70, 18, 16, 0, + 5, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 11, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 150, 7, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 226, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 2, 0, 0, 0, 16, 32, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 47, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 0, 1, 0, + 0, 0, 13, 0, 0, 0, + 50, 0, 0, 9, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 226, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 6, 9, 16, 0, + 4, 0, 0, 0, 16, 32, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 47, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 10, 128, 32, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 50, 0, 0, 9, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 32, 0, 8, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 9, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 32, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 10, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 16, 32, 0, 8, 130, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 11, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 2, 0, 0, 0, + 50, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 50, 32, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 9, 114, 32, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 58, 16, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 228, 0, 0, 0, 8, 0, + 0, 0, 8, 0, 0, 0, + 200, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 212, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 218, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 7, 0, 0, + 218, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 7, 7, 0, 0, + 218, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 7, 0, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_mainTxTk.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_mainTxTk.inc new file mode 100644 index 0000000000000000000000000000000000000000..1c88a023fc034121e324f52be5afe7b7360ef884 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLPhong_mainTxTk.inc @@ -0,0 +1,675 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float xyz +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c1 cb0 2 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 4 1 ( FLT, FLT, FLT, FLT) +// c3 cb1 0 4 ( FLT, FLT, FLT, FLT) +// c7 cb1 9 3 ( FLT, FLT, FLT, FLT) +// c10 cb1 13 3 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c13, -1, -0, 9.99999975e-005, 0 + dcl t0 + dcl t1.xy + dcl t2.xyz + dcl t4.xyz + dcl_2d s0 + texld r0, t1, s0 + mul r1.w, r0.w, t0.w + mul r0.w, r1.w, r1.w + cmp r2, -r0.w, c13.x, c13.y + texkill r2 + dp3 r0.w, t4, t4 + rsq r0.w, r0.w + mad r2.xyz, t4, r0.w, c9 + nrm r3.xyz, r2 + nrm r2.xyz, t2 + dp3_sat r2.w, r2, r3 + dp3_sat r3.x, c7, r2 + mul r3.xyz, r3.x, c4 + mul r3.xyz, r3, t0 + mov r4.xyz, c0 + mad r3.xyz, r4, c3, r3 + mov r3.w, c13.z + max r4.x, c2.x, r3.w + dp3_sat r3.w, c8, r2 + mul r4.yzw, r3.w, c5.wzyx + mad r3.xyz, r4.wzyx, t0, r3 + dp3_sat r3.w, c9, r2 + mul r4.yzw, r3.w, c6.wzyx + mad_sat r3.xyz, r4.wzyx, t0, r3 + pow r3.w, r2.w, r4.x + mul r2.w, r3.w, c12.x + mad r5.xyz, t4, r0.w, c8 + nrm r6.xyz, r5 + dp3_sat r3.w, r2, r6 + pow r5.x, r3.w, r4.x + mul r3.w, r5.x, c11.x + mad r5.xyz, t4, r0.w, c7 + nrm r6.xyz, r5 + dp3_sat r0.w, r2, r6 + pow r2.x, r0.w, r4.x + mul r0.w, r2.x, c10.x + mov r2.xyz, c1 + mul r4.xyz, r2, c5 + mul r4.xyz, r3.w, r4 + mul r5.xyz, r2, c4 + mad r4.xyz, r5, r0.w, r4 + mul r2.xyz, r2, c6 + mad r2.xyz, r2, r2.w, r4 + mad r1.xyz, r3, r0, r2 + mov oC0, r1 + +// approximately 59 instruction slots used (1 texture, 58 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[5], immediateIndexed +dcl_constantbuffer CB1[16], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_input_ps linear v3.xyz +dcl_input_ps linear v5.xyz +dcl_output o0.xyzw +dcl_temps 5 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul r0.w, r0.w, v1.w +eq r1.x, r0.w, l(0.000000) +discard_nz r1.x +dp3 r1.x, v3.xyzx, v3.xyzx +rsq r1.x, r1.x +mul r1.xyz, r1.xxxx, v3.xyzx +dp3 r1.w, v5.xyzx, v5.xyzx +rsq r1.w, r1.w +dp3_sat r2.x, cb1[9].xyzx, r1.xyzx +mul r2.xyz, r2.xxxx, cb1[1].xyzx +mul r2.xyz, r2.xyzx, v1.xyzx +mad r2.xyz, cb0[0].xyzx, cb1[0].xyzx, r2.xyzx +mad r3.xyz, v5.xyzx, r1.wwww, cb1[9].xyzx +dp3 r2.w, r3.xyzx, r3.xyzx +rsq r2.w, r2.w +mul r3.xyz, r2.wwww, r3.xyzx +dp3_sat r2.w, r1.xyzx, r3.xyzx +max r3.x, cb0[4].x, l(0.000100) +log r2.w, r2.w +mul r2.w, r2.w, r3.x +exp r2.w, r2.w +mul r2.w, r2.w, cb1[13].x +mul r3.yzw, cb0[2].xxyz, cb1[1].xxyz +dp3_sat r4.x, cb1[10].xyzx, r1.xyzx +mul r4.xyz, r4.xxxx, cb1[2].xyzx +mad r2.xyz, r4.xyzx, v1.xyzx, r2.xyzx +mad r4.xyz, v5.xyzx, r1.wwww, cb1[10].xyzx +dp3 r4.w, r4.xyzx, r4.xyzx +rsq r4.w, r4.w +mul r4.xyz, r4.wwww, r4.xyzx +dp3_sat r4.x, r1.xyzx, r4.xyzx +log r4.x, r4.x +mul r4.x, r3.x, r4.x +exp r4.x, r4.x +mul r4.x, r4.x, cb1[14].x +mul r4.yzw, cb0[2].xxyz, cb1[2].xxyz +mul r4.xyz, r4.xxxx, r4.yzwy +mad r3.yzw, r3.yyzw, r2.wwww, r4.xxyz +dp3_sat r2.w, cb1[11].xyzx, r1.xyzx +mul r4.xyz, r2.wwww, cb1[3].xyzx +mad_sat r2.xyz, r4.xyzx, v1.xyzx, r2.xyzx +mad r4.xyz, v5.xyzx, r1.wwww, cb1[11].xyzx +dp3 r1.w, r4.xyzx, r4.xyzx +rsq r1.w, r1.w +mul r4.xyz, r1.wwww, r4.xyzx +dp3_sat r1.x, r1.xyzx, r4.xyzx +log r1.x, r1.x +mul r1.x, r1.x, r3.x +exp r1.x, r1.x +mul r1.x, r1.x, cb1[15].x +mul r1.yzw, cb0[2].xxyz, cb1[3].xxyz +mad r1.xyz, r1.yzwy, r1.xxxx, r3.yzwy +mad o0.xyz, r2.xyzx, r0.xyzx, r1.xyzx +mov o0.w, r0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLPhong_mainTxTk[] = +{ + 68, 88, 66, 67, 53, 254, + 197, 217, 98, 158, 242, 162, + 169, 189, 161, 231, 187, 201, + 56, 15, 1, 0, 0, 0, + 188, 11, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 208, 3, 0, 0, 156, 10, + 0, 0, 136, 11, 0, 0, + 65, 111, 110, 57, 152, 3, + 0, 0, 152, 3, 0, 0, + 0, 2, 255, 255, 40, 3, + 0, 0, 112, 0, 0, 0, + 6, 0, 40, 0, 0, 0, + 112, 0, 0, 0, 112, 0, + 1, 0, 36, 0, 0, 0, + 112, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 1, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 1, 0, + 2, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 4, 0, + 3, 0, 0, 0, 0, 0, + 1, 0, 9, 0, 3, 0, + 7, 0, 0, 0, 0, 0, + 1, 0, 13, 0, 3, 0, + 10, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 81, 0, + 0, 5, 13, 0, 15, 160, + 0, 0, 128, 191, 0, 0, + 0, 128, 23, 183, 209, 56, + 0, 0, 0, 0, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 4, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 1, 0, 8, 128, 0, 0, + 255, 128, 0, 0, 255, 176, + 5, 0, 0, 3, 0, 0, + 8, 128, 1, 0, 255, 128, + 1, 0, 255, 128, 88, 0, + 0, 4, 2, 0, 15, 128, + 0, 0, 255, 129, 13, 0, + 0, 160, 13, 0, 85, 160, + 65, 0, 0, 1, 2, 0, + 15, 128, 8, 0, 0, 3, + 0, 0, 8, 128, 4, 0, + 228, 176, 4, 0, 228, 176, + 7, 0, 0, 2, 0, 0, + 8, 128, 0, 0, 255, 128, + 4, 0, 0, 4, 2, 0, + 7, 128, 4, 0, 228, 176, + 0, 0, 255, 128, 9, 0, + 228, 160, 36, 0, 0, 2, + 3, 0, 7, 128, 2, 0, + 228, 128, 36, 0, 0, 2, + 2, 0, 7, 128, 2, 0, + 228, 176, 8, 0, 0, 3, + 2, 0, 24, 128, 2, 0, + 228, 128, 3, 0, 228, 128, + 8, 0, 0, 3, 3, 0, + 17, 128, 7, 0, 228, 160, + 2, 0, 228, 128, 5, 0, + 0, 3, 3, 0, 7, 128, + 3, 0, 0, 128, 4, 0, + 228, 160, 5, 0, 0, 3, + 3, 0, 7, 128, 3, 0, + 228, 128, 0, 0, 228, 176, + 1, 0, 0, 2, 4, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 3, 0, + 7, 128, 4, 0, 228, 128, + 3, 0, 228, 160, 3, 0, + 228, 128, 1, 0, 0, 2, + 3, 0, 8, 128, 13, 0, + 170, 160, 11, 0, 0, 3, + 4, 0, 1, 128, 2, 0, + 0, 160, 3, 0, 255, 128, + 8, 0, 0, 3, 3, 0, + 24, 128, 8, 0, 228, 160, + 2, 0, 228, 128, 5, 0, + 0, 3, 4, 0, 14, 128, + 3, 0, 255, 128, 5, 0, + 27, 160, 4, 0, 0, 4, + 3, 0, 7, 128, 4, 0, + 27, 128, 0, 0, 228, 176, + 3, 0, 228, 128, 8, 0, + 0, 3, 3, 0, 24, 128, + 9, 0, 228, 160, 2, 0, + 228, 128, 5, 0, 0, 3, + 4, 0, 14, 128, 3, 0, + 255, 128, 6, 0, 27, 160, + 4, 0, 0, 4, 3, 0, + 23, 128, 4, 0, 27, 128, + 0, 0, 228, 176, 3, 0, + 228, 128, 32, 0, 0, 3, + 3, 0, 8, 128, 2, 0, + 255, 128, 4, 0, 0, 128, + 5, 0, 0, 3, 2, 0, + 8, 128, 3, 0, 255, 128, + 12, 0, 0, 160, 4, 0, + 0, 4, 5, 0, 7, 128, + 4, 0, 228, 176, 0, 0, + 255, 128, 8, 0, 228, 160, + 36, 0, 0, 2, 6, 0, + 7, 128, 5, 0, 228, 128, + 8, 0, 0, 3, 3, 0, + 24, 128, 2, 0, 228, 128, + 6, 0, 228, 128, 32, 0, + 0, 3, 5, 0, 1, 128, + 3, 0, 255, 128, 4, 0, + 0, 128, 5, 0, 0, 3, + 3, 0, 8, 128, 5, 0, + 0, 128, 11, 0, 0, 160, + 4, 0, 0, 4, 5, 0, + 7, 128, 4, 0, 228, 176, + 0, 0, 255, 128, 7, 0, + 228, 160, 36, 0, 0, 2, + 6, 0, 7, 128, 5, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 24, 128, 2, 0, + 228, 128, 6, 0, 228, 128, + 32, 0, 0, 3, 2, 0, + 1, 128, 0, 0, 255, 128, + 4, 0, 0, 128, 5, 0, + 0, 3, 0, 0, 8, 128, + 2, 0, 0, 128, 10, 0, + 0, 160, 1, 0, 0, 2, + 2, 0, 7, 128, 1, 0, + 228, 160, 5, 0, 0, 3, + 4, 0, 7, 128, 2, 0, + 228, 128, 5, 0, 228, 160, + 5, 0, 0, 3, 4, 0, + 7, 128, 3, 0, 255, 128, + 4, 0, 228, 128, 5, 0, + 0, 3, 5, 0, 7, 128, + 2, 0, 228, 128, 4, 0, + 228, 160, 4, 0, 0, 4, + 4, 0, 7, 128, 5, 0, + 228, 128, 0, 0, 255, 128, + 4, 0, 228, 128, 5, 0, + 0, 3, 2, 0, 7, 128, + 2, 0, 228, 128, 6, 0, + 228, 160, 4, 0, 0, 4, + 2, 0, 7, 128, 2, 0, + 228, 128, 2, 0, 255, 128, + 4, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 7, 128, + 3, 0, 228, 128, 0, 0, + 228, 128, 2, 0, 228, 128, + 1, 0, 0, 2, 0, 8, + 15, 128, 1, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 196, 6, 0, 0, + 64, 0, 0, 0, 177, 1, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 1, 0, 0, 0, + 16, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 3, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 5, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 5, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 58, 16, 16, 0, 1, 0, + 0, 0, 24, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 13, 0, 4, 3, 10, 0, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 68, 0, + 0, 5, 18, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 5, 0, 0, 0, + 70, 18, 16, 0, 5, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 16, 32, + 0, 8, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 9, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 2, 0, 0, 0, + 6, 0, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 3, 0, + 0, 0, 70, 18, 16, 0, + 5, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 9, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 58, 0, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 3, 0, 0, 0, + 246, 15, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 16, 32, + 0, 7, 130, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 52, 0, 0, 8, + 18, 0, 16, 0, 3, 0, + 0, 0, 10, 128, 32, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 1, 64, 0, 0, + 23, 183, 209, 56, 47, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 58, 0, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 7, 130, 0, + 16, 0, 2, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 3, 0, 0, 0, 25, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 58, 0, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 8, 130, 0, + 16, 0, 2, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 10, 128, 32, 0, + 1, 0, 0, 0, 13, 0, + 0, 0, 56, 0, 0, 9, + 226, 0, 16, 0, 3, 0, + 0, 0, 6, 137, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 6, 137, 32, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 16, 32, 0, 8, + 18, 0, 16, 0, 4, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 10, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 4, 0, 0, 0, 6, 0, + 16, 0, 4, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 2, 0, 0, 0, + 50, 0, 0, 9, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 5, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 10, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 4, 0, + 0, 0, 58, 0, 16, 0, + 4, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 16, 32, 0, 7, + 18, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 47, 0, 0, 5, 18, 0, + 16, 0, 4, 0, 0, 0, + 10, 0, 16, 0, 4, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 4, 0, + 0, 0, 10, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 4, 0, 0, 0, + 25, 0, 0, 5, 18, 0, + 16, 0, 4, 0, 0, 0, + 10, 0, 16, 0, 4, 0, + 0, 0, 56, 0, 0, 8, + 18, 0, 16, 0, 4, 0, + 0, 0, 10, 0, 16, 0, + 4, 0, 0, 0, 10, 128, + 32, 0, 1, 0, 0, 0, + 14, 0, 0, 0, 56, 0, + 0, 9, 226, 0, 16, 0, + 4, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 6, 137, + 32, 0, 1, 0, 0, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 4, 0, 0, 0, 6, 0, + 16, 0, 4, 0, 0, 0, + 150, 7, 16, 0, 4, 0, + 0, 0, 50, 0, 0, 9, + 226, 0, 16, 0, 3, 0, + 0, 0, 86, 14, 16, 0, + 3, 0, 0, 0, 246, 15, + 16, 0, 2, 0, 0, 0, + 6, 9, 16, 0, 4, 0, + 0, 0, 16, 32, 0, 8, + 130, 0, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 1, 0, 0, 0, 11, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 50, 32, 0, 9, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 4, 0, 0, 0, + 70, 18, 16, 0, 5, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 1, 0, 0, 0, + 11, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 16, 32, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 47, 0, 0, 5, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 3, 0, 0, 0, + 25, 0, 0, 5, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 8, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 10, 128, + 32, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 56, 0, + 0, 9, 226, 0, 16, 0, + 1, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 6, 137, + 32, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 1, 0, 0, 0, 150, 7, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 1, 0, + 0, 0, 150, 7, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 9, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 228, 0, 0, 0, + 8, 0, 0, 0, 8, 0, + 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 15, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 218, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 7, + 0, 0, 218, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 7, + 0, 0, 218, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 7, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_main.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_main.inc new file mode 100644 index 0000000000000000000000000000000000000000..907ab9e37d995d2e298da14597975b16d5937758 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_main.inc @@ -0,0 +1,124 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float +// TEXCOORD 1 xyz 3 NONE float +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + mov oC0, t0 + +// approximately 1 instruction slot used +ps_4_0 +dcl_input_ps linear v1.xyzw +dcl_output o0.xyzw +mov o0.xyzw, v1.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLUnlit_main[] = +{ + 68, 88, 66, 67, 105, 73, + 81, 57, 5, 7, 232, 104, + 47, 198, 245, 104, 91, 126, + 113, 199, 1, 0, 0, 0, + 220, 1, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 124, 0, 0, 0, 188, 0, + 0, 0, 168, 1, 0, 0, + 65, 111, 110, 57, 68, 0, + 0, 0, 68, 0, 0, 0, + 0, 2, 255, 255, 32, 0, + 0, 0, 36, 0, 0, 0, + 0, 0, 36, 0, 0, 0, + 36, 0, 0, 0, 36, 0, + 0, 0, 36, 0, 0, 0, + 36, 0, 0, 2, 255, 255, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 0, 0, 228, 176, + 255, 255, 0, 0, 83, 72, + 68, 82, 56, 0, 0, 0, + 64, 0, 0, 0, 14, 0, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 228, 0, 0, 0, 8, 0, + 0, 0, 8, 0, 0, 0, + 200, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 212, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 0, 0, 0, + 218, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 7, 0, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_mainTk.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_mainTk.inc new file mode 100644 index 0000000000000000000000000000000000000000..c1091a4d4a186c2670a4403f5543154ed7db068a --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_mainTk.inc @@ -0,0 +1,153 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float +// TEXCOORD 1 xyz 3 NONE float +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c0, -1, -0, 0, 0 + dcl t0 + mul r0.w, t0.w, t0.w + cmp r0, -r0.w, c0.x, c0.y + texkill r0 + mov r0, t0 + mov oC0, r0 + +// approximately 5 instruction slots used +ps_4_0 +dcl_input_ps linear v1.xyzw +dcl_output o0.xyzw +dcl_temps 1 +eq r0.x, v1.w, l(0.000000) +discard_nz r0.x +mov o0.xyzw, v1.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLUnlit_mainTk[] = +{ + 68, 88, 66, 67, 46, 130, + 120, 130, 191, 217, 78, 124, + 7, 169, 79, 105, 72, 21, + 223, 236, 1, 0, 0, 0, + 92, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 204, 0, 0, 0, 60, 1, + 0, 0, 40, 2, 0, 0, + 65, 111, 110, 57, 148, 0, + 0, 0, 148, 0, 0, 0, + 0, 2, 255, 255, 112, 0, + 0, 0, 36, 0, 0, 0, + 0, 0, 36, 0, 0, 0, + 36, 0, 0, 0, 36, 0, + 0, 0, 36, 0, 0, 0, + 36, 0, 0, 2, 255, 255, + 81, 0, 0, 5, 0, 0, + 15, 160, 0, 0, 128, 191, + 0, 0, 0, 128, 0, 0, + 0, 0, 0, 0, 0, 0, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 15, 176, + 5, 0, 0, 3, 0, 0, + 8, 128, 0, 0, 255, 176, + 0, 0, 255, 176, 88, 0, + 0, 4, 0, 0, 15, 128, + 0, 0, 255, 129, 0, 0, + 0, 160, 0, 0, 85, 160, + 65, 0, 0, 1, 0, 0, + 15, 128, 1, 0, 0, 2, + 0, 0, 15, 128, 0, 0, + 228, 176, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 104, 0, + 0, 0, 64, 0, 0, 0, + 26, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 24, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 58, 16, 16, 0, 1, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 13, 0, + 4, 3, 10, 0, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 228, 0, 0, 0, + 8, 0, 0, 0, 8, 0, + 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 15, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 0, + 0, 0, 218, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 7, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_mainTx.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_mainTx.inc new file mode 100644 index 0000000000000000000000000000000000000000..00083ed59688d9aa839eb1e589054b663cefda2b --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_mainTx.inc @@ -0,0 +1,165 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1.xy + dcl_2d s0 + texld r0, t1, s0 + mul r1, r0, t0 + mov oC0, r1 + +// approximately 3 instruction slots used (1 texture, 2 arithmetic) +ps_4_0 +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_output o0.xyzw +dcl_temps 1 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul o0.xyzw, r0.xyzw, v1.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLUnlit_mainTx[] = +{ + 68, 88, 66, 67, 17, 52, + 170, 45, 63, 249, 46, 7, + 141, 68, 209, 179, 128, 184, + 205, 30, 1, 0, 0, 0, + 116, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 184, 0, 0, 0, 84, 1, + 0, 0, 64, 2, 0, 0, + 65, 111, 110, 57, 128, 0, + 0, 0, 128, 0, 0, 0, + 0, 2, 255, 255, 88, 0, + 0, 0, 40, 0, 0, 0, + 0, 0, 40, 0, 0, 0, + 40, 0, 0, 0, 40, 0, + 1, 0, 36, 0, 0, 0, + 40, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 1, 0, 15, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 1, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 148, 0, 0, 0, + 64, 0, 0, 0, 37, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 2, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 1, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 228, 0, 0, 0, + 8, 0, 0, 0, 8, 0, + 0, 0, 200, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 15, + 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 218, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 5, 0, 0, 0, 7, 0, + 0, 0, 218, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 6, 0, 0, 0, 15, 0, + 0, 0, 218, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 7, 0, 0, 0, 7, 0, + 0, 0, 83, 86, 95, 80, + 79, 83, 73, 84, 73, 79, + 78, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_mainTxTk.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_mainTxTk.inc new file mode 100644 index 0000000000000000000000000000000000000000..a3fd01ee096f313fe571ab1b7aca76d29e855426 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DGSLUnlit_mainTxTk.inc @@ -0,0 +1,203 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_POSITION 0 xyzw 0 POS float +// COLOR 0 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float +// TEXCOORD 2 xyz 4 NONE float +// TEXCOORD 3 xyz 5 NONE float +// TEXCOORD 4 xyzw 6 NONE float +// TEXCOORD 5 xyz 7 NONE float +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c0, -1, -0, 0, 0 + dcl t0 + dcl t1.xy + dcl_2d s0 + texld r0, t1, s0 + mul r1.w, r0.w, t0.w + mul r0.w, r1.w, r1.w + cmp r2, -r0.w, c0.x, c0.y + texkill r2 + mul r1.xyz, r0, t0 + mov oC0, r1 + +// approximately 7 instruction slots used (1 texture, 6 arithmetic) +ps_4_0 +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul r0.w, r0.w, v1.w +eq r1.x, r0.w, l(0.000000) +discard_nz r1.x +mul o0.xyz, r0.xyzx, v1.xyzx +mov o0.w, r0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DGSLUnlit_mainTxTk[] = +{ + 68, 88, 66, 67, 219, 12, + 49, 38, 225, 45, 150, 107, + 89, 0, 123, 21, 83, 4, + 147, 41, 1, 0, 0, 0, + 32, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 12, 1, 0, 0, 0, 2, + 0, 0, 236, 2, 0, 0, + 65, 111, 110, 57, 212, 0, + 0, 0, 212, 0, 0, 0, + 0, 2, 255, 255, 172, 0, + 0, 0, 40, 0, 0, 0, + 0, 0, 40, 0, 0, 0, + 40, 0, 0, 0, 40, 0, + 1, 0, 36, 0, 0, 0, + 40, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 81, 0, + 0, 5, 0, 0, 15, 160, + 0, 0, 128, 191, 0, 0, + 0, 128, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 1, 0, 8, 128, 0, 0, + 255, 128, 0, 0, 255, 176, + 5, 0, 0, 3, 0, 0, + 8, 128, 1, 0, 255, 128, + 1, 0, 255, 128, 88, 0, + 0, 4, 2, 0, 15, 128, + 0, 0, 255, 129, 0, 0, + 0, 160, 0, 0, 85, 160, + 65, 0, 0, 1, 2, 0, + 15, 128, 5, 0, 0, 3, + 1, 0, 7, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 1, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 236, 0, 0, 0, + 64, 0, 0, 0, 59, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 2, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 2, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 58, 16, + 16, 0, 1, 0, 0, 0, + 24, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 13, 0, + 4, 3, 10, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 228, 0, 0, 0, 8, 0, + 0, 0, 8, 0, 0, 0, + 200, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 212, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 218, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 5, 0, + 0, 0, 7, 0, 0, 0, + 218, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 6, 0, + 0, 0, 15, 0, 0, 0, + 218, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 7, 0, + 0, 0, 7, 0, 0, 0, + 83, 86, 95, 80, 79, 83, + 73, 84, 73, 79, 78, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_PSDualTexture.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_PSDualTexture.inc new file mode 100644 index 0000000000000000000000000000000000000000..b06c1c87be632d44f5e612fe3239f72291cbbcc9 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_PSDualTexture.inc @@ -0,0 +1,244 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float w +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 zw 2 NONE float zw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 1 1 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// s1 s1 t1 +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c1, 2, 2, 2, 1 + dcl t0 + dcl t1 + dcl t2 + dcl_2d s0 + dcl_2d s1 + mov r0.xy, t2.wzyx + texld r0, r0, s1 + texld r1, t2, s0 + mul r0, r0, t0 + mul r1, r1, c1 + mul r0, r0, r1 + mad r1.xyz, c0, r0.w, -r0 + mad r0.xyz, t1.w, r1, r0 + mov oC0, r0 + +// approximately 9 instruction slots used (2 texture, 7 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[2], immediateIndexed +dcl_sampler s0, mode_default +dcl_sampler s1, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_resource_texture2d (float,float,float,float) t1 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.w +dcl_input_ps linear v2.xy +dcl_input_ps linear v2.zw +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v2.zwzz, t1.xyzw, s1 +mul r0.xyzw, r0.xyzw, v0.xyzw +sample r1.xyzw, v2.xyxx, t0.xyzw, s0 +mul r1.xyzw, r1.xyzw, l(2.000000, 2.000000, 2.000000, 1.000000) +mul r0.xyzw, r0.xyzw, r1.xyzw +mad r1.xyz, cb0[1].xyzx, r0.wwww, -r0.xyzx +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +mov o0.w, r0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DualTextureEffect_PSDualTexture[] = +{ + 68, 88, 66, 67, 174, 36, + 68, 110, 51, 2, 130, 217, + 225, 159, 194, 118, 191, 73, + 0, 2, 1, 0, 0, 0, + 188, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 92, 1, 0, 0, 8, 3, + 0, 0, 136, 3, 0, 0, + 65, 111, 110, 57, 36, 1, + 0, 0, 36, 1, 0, 0, + 0, 2, 255, 255, 236, 0, + 0, 0, 56, 0, 0, 0, + 1, 0, 44, 0, 0, 0, + 56, 0, 0, 0, 56, 0, + 2, 0, 36, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 2, + 255, 255, 81, 0, 0, 5, + 1, 0, 15, 160, 0, 0, + 0, 64, 0, 0, 0, 64, + 0, 0, 0, 64, 0, 0, + 128, 63, 31, 0, 0, 2, + 0, 0, 0, 128, 0, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 1, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 2, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 144, 0, 8, + 15, 160, 31, 0, 0, 2, + 0, 0, 0, 144, 1, 8, + 15, 160, 1, 0, 0, 2, + 0, 0, 3, 128, 2, 0, + 27, 176, 66, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 1, 8, 228, 160, + 66, 0, 0, 3, 1, 0, + 15, 128, 2, 0, 228, 176, + 0, 8, 228, 160, 5, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 128, 0, 0, + 228, 176, 5, 0, 0, 3, + 1, 0, 15, 128, 1, 0, + 228, 128, 1, 0, 228, 160, + 5, 0, 0, 3, 0, 0, + 15, 128, 0, 0, 228, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 7, 128, + 0, 0, 228, 160, 0, 0, + 255, 128, 0, 0, 228, 129, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 255, 176, + 1, 0, 228, 128, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 164, 1, + 0, 0, 64, 0, 0, 0, + 105, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 1, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 1, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 98, 16, + 0, 3, 130, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 98, 16, + 0, 3, 194, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 2, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 230, 26, 16, 0, 2, 0, + 0, 0, 70, 126, 16, 0, + 1, 0, 0, 0, 0, 96, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 64, 0, 0, 0, 64, + 0, 0, 0, 64, 0, 0, + 128, 63, 56, 0, 0, 7, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 114, 32, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 120, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 104, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 8, 0, 0, + 110, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 110, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 12, 12, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_PSDualTextureNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_PSDualTextureNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..9e10a36a5095739251809c5dff04cd9c9681f5e4 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_PSDualTextureNoFog.inc @@ -0,0 +1,192 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 zw 1 NONE float zw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// s1 s1 t1 +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c0, 2, 2, 2, 1 + dcl t0 + dcl t1 + dcl_2d s0 + dcl_2d s1 + mov r0.xy, t1.wzyx + texld r0, r0, s1 + texld r1, t1, s0 + mul r0, r0, t0 + mul r1, r1, c0 + mul r0, r0, r1 + mov oC0, r0 + +// approximately 7 instruction slots used (2 texture, 5 arithmetic) +ps_4_0 +dcl_sampler s0, mode_default +dcl_sampler s1, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_resource_texture2d (float,float,float,float) t1 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xy +dcl_input_ps linear v1.zw +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v1.zwzz, t1.xyzw, s1 +mul r0.xyzw, r0.xyzw, v0.xyzw +sample r1.xyzw, v1.xyxx, t0.xyzw, s0 +mul r1.xyzw, r1.xyzw, l(2.000000, 2.000000, 2.000000, 1.000000) +mul o0.xyzw, r0.xyzw, r1.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DualTextureEffect_PSDualTextureNoFog[] = +{ + 68, 88, 66, 67, 153, 27, + 95, 207, 68, 212, 28, 53, + 52, 118, 247, 86, 20, 184, + 20, 234, 1, 0, 0, 0, + 228, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 28, 1, 0, 0, 72, 2, + 0, 0, 176, 2, 0, 0, + 65, 111, 110, 57, 228, 0, + 0, 0, 228, 0, 0, 0, + 0, 2, 255, 255, 184, 0, + 0, 0, 44, 0, 0, 0, + 0, 0, 44, 0, 0, 0, + 44, 0, 0, 0, 44, 0, + 2, 0, 36, 0, 0, 0, + 44, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 2, + 255, 255, 81, 0, 0, 5, + 0, 0, 15, 160, 0, 0, + 0, 64, 0, 0, 0, 64, + 0, 0, 0, 64, 0, 0, + 128, 63, 31, 0, 0, 2, + 0, 0, 0, 128, 0, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 1, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 144, 0, 8, + 15, 160, 31, 0, 0, 2, + 0, 0, 0, 144, 1, 8, + 15, 160, 1, 0, 0, 2, + 0, 0, 3, 128, 1, 0, + 27, 176, 66, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 1, 8, 228, 160, + 66, 0, 0, 3, 1, 0, + 15, 128, 1, 0, 228, 176, + 0, 8, 228, 160, 5, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 128, 0, 0, + 228, 176, 5, 0, 0, 3, + 1, 0, 15, 128, 1, 0, + 228, 128, 0, 0, 228, 160, + 5, 0, 0, 3, 0, 0, + 15, 128, 0, 0, 228, 128, + 1, 0, 228, 128, 1, 0, + 0, 2, 0, 8, 15, 128, + 0, 0, 228, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 36, 1, 0, 0, 64, 0, + 0, 0, 73, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 1, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 1, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 194, 16, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 2, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 230, 26, + 16, 0, 1, 0, 0, 0, + 70, 126, 16, 0, 1, 0, + 0, 0, 0, 96, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 64, + 0, 0, 0, 64, 0, 0, + 0, 64, 0, 0, 128, 63, + 56, 0, 0, 7, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 96, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 86, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 12, 12, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTexture.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTexture.inc new file mode 100644 index 0000000000000000000000000000000000000000..46b8d4975d9233457f3603ddd249d2aecb46f290 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTexture.inc @@ -0,0 +1,263 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 zw 2 NONE float zw +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 2 5 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c7, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 oPos.z, v0, c5 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c7.x + min oT1.w, r0.x, c7.y + dp4 r0.x, v0, c3 + dp4 r0.y, v0, c4 + dp4 r0.z, v0, c6 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0, c1 + mov oT1.xyz, c7.x + mov oT2.xy, v1 + mov oT2.zw, v2.xyyx + +// approximately 13 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[7], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o2.zw +dcl_output_siv o3.xyzw, position +mov o0.xyzw, cb0[0].xyzw +dp4_sat o1.w, v0.xyzw, cb0[2].xyzw +mov o1.xyz, l(0,0,0,0) +mov o2.xy, v1.xyxx +mov o2.zw, v2.xxxy +dp4 o3.x, v0.xyzw, cb0[3].xyzw +dp4 o3.y, v0.xyzw, cb0[4].xyzw +dp4 o3.z, v0.xyzw, cb0[5].xyzw +dp4 o3.w, v0.xyzw, cb0[6].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DualTextureEffect_VSDualTexture[] = +{ + 68, 88, 66, 67, 88, 79, + 46, 165, 110, 4, 103, 119, + 19, 141, 88, 31, 26, 233, + 211, 116, 1, 0, 0, 0, + 24, 4, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 124, 1, 0, 0, 4, 3, + 0, 0, 116, 3, 0, 0, + 65, 111, 110, 57, 68, 1, + 0, 0, 68, 1, 0, 0, + 0, 2, 254, 255, 4, 1, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 5, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 7, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 5, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 7, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 7, 0, + 85, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 3, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 4, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 6, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 1, 0, 228, 160, 1, 0, + 0, 2, 1, 0, 7, 224, + 7, 0, 0, 160, 1, 0, + 0, 2, 2, 0, 3, 224, + 1, 0, 228, 144, 1, 0, + 0, 2, 2, 0, 12, 224, + 2, 0, 20, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 128, 1, 0, 0, 64, 0, + 1, 0, 96, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 194, 32, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 54, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 194, 32, 16, 0, 2, 0, + 0, 0, 6, 20, 16, 0, + 2, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 104, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 92, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 92, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 79, 83, 71, 78, + 156, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 128, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 134, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 12, 0, 0, + 134, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 12, 3, 0, 0, + 143, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTextureNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTextureNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..7cce460de87aabdf6d042b471d1f172149f540b3 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTextureNoFog.inc @@ -0,0 +1,223 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 zw 1 NONE float zw +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 3 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp4 oPos.z, v0, c4 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c5 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0, c1 + mov oT1.xy, v1 + mov oT1.zw, v2.xyyx + +// approximately 9 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[7], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xy +dcl_output o0.xyzw +dcl_output o1.xy +dcl_output o1.zw +dcl_output_siv o2.xyzw, position +mov o0.xyzw, cb0[0].xyzw +mov o1.xy, v1.xyxx +mov o1.zw, v2.xxxy +dp4 o2.x, v0.xyzw, cb0[3].xyzw +dp4 o2.y, v0.xyzw, cb0[4].xyzw +dp4 o2.z, v0.xyzw, cb0[5].xyzw +dp4 o2.w, v0.xyzw, cb0[6].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DualTextureEffect_VSDualTextureNoFog[] = +{ + 68, 88, 66, 67, 30, 75, + 216, 234, 121, 215, 229, 59, + 247, 49, 209, 178, 22, 248, + 155, 79, 1, 0, 0, 0, + 96, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 40, 1, 0, 0, 100, 2, + 0, 0, 212, 2, 0, 0, + 65, 111, 110, 57, 240, 0, + 0, 0, 240, 0, 0, 0, + 0, 2, 254, 255, 176, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 4, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 5, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 1, 0, 228, 160, 1, 0, + 0, 2, 1, 0, 3, 224, + 1, 0, 228, 144, 1, 0, + 0, 2, 1, 0, 12, 224, + 2, 0, 20, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 52, 1, 0, 0, 64, 0, + 1, 0, 77, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 194, 32, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 194, 32, 16, 0, + 1, 0, 0, 0, 6, 20, + 16, 0, 2, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 104, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 3, 0, 0, 92, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 171, 171, 79, 83, + 71, 78, 132, 0, 0, 0, + 4, 0, 0, 0, 8, 0, + 0, 0, 104, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 110, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 12, + 0, 0, 110, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 12, 3, + 0, 0, 119, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 83, + 86, 95, 80, 111, 115, 105, + 116, 105, 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTextureVc.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTextureVc.inc new file mode 100644 index 0000000000000000000000000000000000000000..96288618c932beb4a2b763dcfc0d2d36b9b34a2e --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTextureVc.inc @@ -0,0 +1,277 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 xy 2 NONE float xy +// COLOR 0 xyzw 3 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 zw 2 NONE float zw +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 2 5 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c7, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dp4 oPos.z, v0, c5 + dp4 r0.x, v0, c2 + max r0.x, r0.x, c7.x + min oT1.w, r0.x, c7.y + mul oT0, v3, c1 + dp4 r0.x, v0, c3 + dp4 r0.y, v0, c4 + dp4 r0.z, v0, c6 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT1.xyz, c7.x + mov oT2.xy, v1 + mov oT2.zw, v2.xyyx + +// approximately 13 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[7], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xy +dcl_input v3.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o2.zw +dcl_output_siv o3.xyzw, position +mul o0.xyzw, v3.xyzw, cb0[0].xyzw +dp4_sat o1.w, v0.xyzw, cb0[2].xyzw +mov o1.xyz, l(0,0,0,0) +mov o2.xy, v1.xyxx +mov o2.zw, v2.xxxy +dp4 o3.x, v0.xyzw, cb0[3].xyzw +dp4 o3.y, v0.xyzw, cb0[4].xyzw +dp4 o3.z, v0.xyzw, cb0[5].xyzw +dp4 o3.w, v0.xyzw, cb0[6].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DualTextureEffect_VSDualTextureVc[] = +{ + 68, 88, 66, 67, 203, 16, + 198, 231, 197, 220, 255, 190, + 38, 217, 54, 1, 67, 218, + 120, 110, 1, 0, 0, 0, + 88, 4, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 140, 1, 0, 0, 40, 3, + 0, 0, 180, 3, 0, 0, + 65, 111, 110, 57, 84, 1, + 0, 0, 84, 1, 0, 0, + 0, 2, 254, 255, 20, 1, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 5, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 7, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 5, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 2, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 7, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 7, 0, + 85, 160, 5, 0, 0, 3, + 0, 0, 15, 224, 3, 0, + 228, 144, 1, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 4, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 6, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 1, 0, 7, 224, 7, 0, + 0, 160, 1, 0, 0, 2, + 2, 0, 3, 224, 1, 0, + 228, 144, 1, 0, 0, 2, + 2, 0, 12, 224, 2, 0, + 20, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 148, 1, + 0, 0, 64, 0, 1, 0, + 101, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 194, 32, 16, 0, 2, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 54, 0, + 0, 8, 114, 32, 16, 0, + 1, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 194, 32, 16, 0, 2, 0, + 0, 0, 6, 20, 16, 0, + 2, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 3, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 3, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 3, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 132, 0, 0, 0, + 4, 0, 0, 0, 8, 0, + 0, 0, 104, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 116, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 116, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 125, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 15, 15, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 171, + 79, 83, 71, 78, 156, 0, + 0, 0, 5, 0, 0, 0, + 8, 0, 0, 0, 128, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 128, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 134, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 134, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 12, 3, 0, 0, 143, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTextureVcNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTextureVcNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..1b59843186ddb902aa30446af8f65e30a28e958b --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/DualTextureEffect_VSDualTextureVcNoFog.inc @@ -0,0 +1,237 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 xy 2 NONE float xy +// COLOR 0 xyzw 3 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 zw 1 NONE float zw +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c2 cb0 3 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dp4 oPos.z, v0, c4 + mul oT0, v3, c1 + dp4 r0.x, v0, c2 + dp4 r0.y, v0, c3 + dp4 r0.z, v0, c5 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT1.xy, v1 + mov oT1.zw, v2.xyyx + +// approximately 9 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[7], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xy +dcl_input v3.xyzw +dcl_output o0.xyzw +dcl_output o1.xy +dcl_output o1.zw +dcl_output_siv o2.xyzw, position +mul o0.xyzw, v3.xyzw, cb0[0].xyzw +mov o1.xy, v1.xyxx +mov o1.zw, v2.xxxy +dp4 o2.x, v0.xyzw, cb0[3].xyzw +dp4 o2.y, v0.xyzw, cb0[4].xyzw +dp4 o2.z, v0.xyzw, cb0[5].xyzw +dp4 o2.w, v0.xyzw, cb0[6].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE DualTextureEffect_VSDualTextureVcNoFog[] = +{ + 68, 88, 66, 67, 96, 251, + 156, 208, 35, 81, 22, 155, + 149, 224, 122, 115, 231, 51, + 123, 227, 1, 0, 0, 0, + 160, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 56, 1, 0, 0, 136, 2, + 0, 0, 20, 3, 0, 0, + 65, 111, 110, 57, 0, 1, + 0, 0, 0, 1, 0, 0, + 0, 2, 254, 255, 192, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 36, 0, 0, 0, + 60, 0, 0, 0, 60, 0, + 0, 0, 36, 0, 1, 0, + 60, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 4, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 4, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 224, 3, 0, + 228, 144, 1, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 3, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 5, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 1, 0, 3, 224, 1, 0, + 228, 144, 1, 0, 0, 2, + 1, 0, 12, 224, 2, 0, + 20, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 72, 1, + 0, 0, 64, 0, 1, 0, + 82, 0, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 194, 32, 16, 0, 1, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 2, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 32, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 50, 32, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 194, 32, 16, 0, + 1, 0, 0, 0, 6, 20, + 16, 0, 2, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 132, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 116, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 3, 0, 0, 116, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 125, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 15, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 67, 79, 76, 79, 82, + 0, 171, 79, 83, 71, 78, + 132, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 110, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 12, 0, 0, + 110, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 12, 3, 0, 0, + 119, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMap.inc b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMap.inc new file mode 100644 index 0000000000000000000000000000000000000000..bafad923d0ad39487eb47b0a32b37f98a1c94e30 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMap.inc @@ -0,0 +1,241 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 11 1 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// s1 s1 t1 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl t3.xyz + dcl_2d s0 + dcl_cube s1 + texld r0, t3, s1 + texld r1, t2, s0 + mul r1, r1, t0 + mad r0.xyz, r0, r1.w, -r1 + mad r0.xyz, t1, r0, r1 + mad r2.xyz, c0, r1.w, -r0 + mad r1.xyz, t1.w, r2, r0 + mov oC0, r1 + +// approximately 8 instruction slots used (2 texture, 6 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[12], immediateIndexed +dcl_sampler s0, mode_default +dcl_sampler s1, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_resource_texturecube (float,float,float,float) t1 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v3.xyzx, t1.xyzw, s1 +sample r1.xyzw, v2.xyxx, t0.xyzw, s0 +mul r1.xyzw, r1.xyzw, v0.xyzw +mad r0.xyz, r0.xyzx, r1.wwww, -r1.xyzx +mad r0.xyz, v1.xyzx, r0.xyzx, r1.xyzx +mad r1.xyz, cb0[11].xyzx, r1.wwww, -r0.xyzx +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +mov o0.w, r1.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE EnvironmentMapEffect_PSEnvMap[] = +{ + 68, 88, 66, 67, 153, 99, + 255, 64, 191, 118, 42, 252, + 62, 108, 243, 191, 43, 234, + 97, 92, 1, 0, 0, 0, + 180, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 76, 1, 0, 0, 0, 3, + 0, 0, 128, 3, 0, 0, + 65, 111, 110, 57, 20, 1, + 0, 0, 20, 1, 0, 0, + 0, 2, 255, 255, 220, 0, + 0, 0, 56, 0, 0, 0, + 1, 0, 44, 0, 0, 0, + 56, 0, 0, 0, 56, 0, + 2, 0, 36, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, + 11, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 2, + 255, 255, 31, 0, 0, 2, + 0, 0, 0, 128, 0, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 1, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 2, 0, + 3, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 3, 0, + 7, 176, 31, 0, 0, 2, + 0, 0, 0, 144, 0, 8, + 15, 160, 31, 0, 0, 2, + 0, 0, 0, 152, 1, 8, + 15, 160, 66, 0, 0, 3, + 0, 0, 15, 128, 3, 0, + 228, 176, 1, 8, 228, 160, + 66, 0, 0, 3, 1, 0, + 15, 128, 2, 0, 228, 176, + 0, 8, 228, 160, 5, 0, + 0, 3, 1, 0, 15, 128, + 1, 0, 228, 128, 0, 0, + 228, 176, 4, 0, 0, 4, + 0, 0, 7, 128, 0, 0, + 228, 128, 1, 0, 255, 128, + 1, 0, 228, 129, 4, 0, + 0, 4, 0, 0, 7, 128, + 1, 0, 228, 176, 0, 0, + 228, 128, 1, 0, 228, 128, + 4, 0, 0, 4, 2, 0, + 7, 128, 0, 0, 228, 160, + 1, 0, 255, 128, 0, 0, + 228, 129, 4, 0, 0, 4, + 1, 0, 7, 128, 1, 0, + 255, 176, 2, 0, 228, 128, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 8, 15, 128, + 1, 0, 228, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 172, 1, 0, 0, 64, 0, + 0, 0, 107, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 1, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 88, 48, 0, 4, + 0, 112, 16, 0, 1, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 98, 16, 0, 3, 114, 16, + 16, 0, 3, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 2, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 70, 126, + 16, 0, 1, 0, 0, 0, + 0, 96, 16, 0, 1, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 2, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 1, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 50, 0, 0, 9, 114, 32, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 120, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 15, 0, 0, 110, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 110, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 7, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMapNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMapNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..3e1db0199f7dcbcae53235744f05cb2b08111a67 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMapNoFog.inc @@ -0,0 +1,205 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// s1 s1 t1 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl t3.xyz + dcl_2d s0 + dcl_cube s1 + texld r0, t3, s1 + texld r1, t2, s0 + mul r1, r1, t0 + mad r0.xyz, r0, r1.w, -r1 + mad r1.xyz, t1, r0, r1 + mov oC0, r1 + +// approximately 6 instruction slots used (2 texture, 4 arithmetic) +ps_4_0 +dcl_sampler s0, mode_default +dcl_sampler s1, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_resource_texturecube (float,float,float,float) t1 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyz +dcl_input_ps linear v2.xy +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v3.xyzx, t1.xyzw, s1 +sample r1.xyzw, v2.xyxx, t0.xyzw, s0 +mul r1.xyzw, r1.xyzw, v0.xyzw +mad r0.xyz, r0.xyzx, r1.wwww, -r1.xyzx +mad o0.xyz, v1.xyzx, r0.xyzx, r1.xyzx +mov o0.w, r1.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE EnvironmentMapEffect_PSEnvMapNoFog[] = +{ + 68, 88, 66, 67, 25, 234, + 244, 32, 119, 100, 210, 163, + 96, 109, 215, 177, 129, 6, + 74, 172, 1, 0, 0, 0, + 32, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 24, 1, 0, 0, 108, 2, + 0, 0, 236, 2, 0, 0, + 65, 111, 110, 57, 224, 0, + 0, 0, 224, 0, 0, 0, + 0, 2, 255, 255, 180, 0, + 0, 0, 44, 0, 0, 0, + 0, 0, 44, 0, 0, 0, + 44, 0, 0, 0, 44, 0, + 2, 0, 36, 0, 0, 0, + 44, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 2, + 255, 255, 31, 0, 0, 2, + 0, 0, 0, 128, 0, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 1, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 2, 0, + 3, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 3, 0, + 7, 176, 31, 0, 0, 2, + 0, 0, 0, 144, 0, 8, + 15, 160, 31, 0, 0, 2, + 0, 0, 0, 152, 1, 8, + 15, 160, 66, 0, 0, 3, + 0, 0, 15, 128, 3, 0, + 228, 176, 1, 8, 228, 160, + 66, 0, 0, 3, 1, 0, + 15, 128, 2, 0, 228, 176, + 0, 8, 228, 160, 5, 0, + 0, 3, 1, 0, 15, 128, + 1, 0, 228, 128, 0, 0, + 228, 176, 4, 0, 0, 4, + 0, 0, 7, 128, 0, 0, + 228, 128, 1, 0, 255, 128, + 1, 0, 228, 129, 4, 0, + 0, 4, 1, 0, 7, 128, + 1, 0, 228, 176, 0, 0, + 228, 128, 1, 0, 228, 128, + 1, 0, 0, 2, 0, 8, + 15, 128, 1, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 76, 1, 0, 0, + 64, 0, 0, 0, 83, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 1, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 88, 48, 0, 4, 0, 112, + 16, 0, 1, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 98, 16, + 0, 3, 114, 16, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 2, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 3, 0, + 0, 0, 70, 126, 16, 0, + 1, 0, 0, 0, 0, 96, + 16, 0, 1, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 50, 0, 0, 9, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 120, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 104, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 7, 0, 0, + 110, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 110, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 7, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMapSpecular.inc b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMapSpecular.inc new file mode 100644 index 0000000000000000000000000000000000000000..f48dfaf89ebf301628cf97744bc20c99149f14e9 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMapSpecular.inc @@ -0,0 +1,266 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// c1 cb0 11 1 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// s1 s1 t1 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl t3.xyz + dcl_2d s0 + dcl_cube s1 + texld r0, t3, s1 + texld r1, t2, s0 + mul r1, r1, t0 + mad r0.xyz, r0, r1.w, -r1 + mul r0.w, r0.w, r1.w + mad r0.xyz, t1, r0, r1 + mad r0.xyz, c0, r0.w, r0 + mad r2.xyz, c1, r1.w, -r0 + mad r1.xyz, t1.w, r2, r0 + mov oC0, r1 + +// approximately 10 instruction slots used (2 texture, 8 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[12], immediateIndexed +dcl_sampler s0, mode_default +dcl_sampler s1, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_resource_texturecube (float,float,float,float) t1 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v3.xyzx, t1.xyzw, s1 +sample r1.xyzw, v2.xyxx, t0.xyzw, s0 +mul r1.xyzw, r1.xyzw, v0.xyzw +mad r0.xyz, r0.xyzx, r1.wwww, -r1.xyzx +mul r0.w, r0.w, r1.w +mad r0.xyz, v1.xyzx, r0.xyzx, r1.xyzx +mad r0.xyz, cb0[0].xyzx, r0.wwww, r0.xyzx +mad r1.xyz, cb0[11].xyzx, r1.wwww, -r0.xyzx +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +mov o0.w, r1.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE EnvironmentMapEffect_PSEnvMapSpecular[] = +{ + 68, 88, 66, 67, 7, 168, + 166, 133, 74, 140, 213, 194, + 234, 125, 176, 230, 98, 133, + 220, 152, 1, 0, 0, 0, + 40, 4, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 124, 1, 0, 0, 116, 3, + 0, 0, 244, 3, 0, 0, + 65, 111, 110, 57, 68, 1, + 0, 0, 68, 1, 0, 0, + 0, 2, 255, 255, 0, 1, + 0, 0, 68, 0, 0, 0, + 2, 0, 44, 0, 0, 0, + 68, 0, 0, 0, 68, 0, + 2, 0, 36, 0, 0, 0, + 68, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 11, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 2, + 255, 255, 31, 0, 0, 2, + 0, 0, 0, 128, 0, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 1, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 2, 0, + 3, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 3, 0, + 7, 176, 31, 0, 0, 2, + 0, 0, 0, 144, 0, 8, + 15, 160, 31, 0, 0, 2, + 0, 0, 0, 152, 1, 8, + 15, 160, 66, 0, 0, 3, + 0, 0, 15, 128, 3, 0, + 228, 176, 1, 8, 228, 160, + 66, 0, 0, 3, 1, 0, + 15, 128, 2, 0, 228, 176, + 0, 8, 228, 160, 5, 0, + 0, 3, 1, 0, 15, 128, + 1, 0, 228, 128, 0, 0, + 228, 176, 4, 0, 0, 4, + 0, 0, 7, 128, 0, 0, + 228, 128, 1, 0, 255, 128, + 1, 0, 228, 129, 5, 0, + 0, 3, 0, 0, 8, 128, + 0, 0, 255, 128, 1, 0, + 255, 128, 4, 0, 0, 4, + 0, 0, 7, 128, 1, 0, + 228, 176, 0, 0, 228, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 0, 0, 7, 128, + 0, 0, 228, 160, 0, 0, + 255, 128, 0, 0, 228, 128, + 4, 0, 0, 4, 2, 0, + 7, 128, 1, 0, 228, 160, + 1, 0, 255, 128, 0, 0, + 228, 129, 4, 0, 0, 4, + 1, 0, 7, 128, 1, 0, + 255, 176, 2, 0, 228, 128, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 8, 15, 128, + 1, 0, 228, 128, 255, 255, + 0, 0, 83, 72, 68, 82, + 240, 1, 0, 0, 64, 0, + 0, 0, 124, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 1, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 88, 48, 0, 4, + 0, 112, 16, 0, 1, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 98, 16, 0, 3, 114, 16, + 16, 0, 3, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 2, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 3, 0, 0, 0, 70, 126, + 16, 0, 1, 0, 0, 0, + 0, 96, 16, 0, 1, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 2, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 9, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 246, 15, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 114, 32, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 120, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 104, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 15, 0, 0, + 110, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 110, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 7, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMapSpecularNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMapSpecularNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..332618c40b4036e76c9c67db2455b561181a8253 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_PSEnvMapSpecularNoFog.inc @@ -0,0 +1,239 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 1 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// s1 s1 t1 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl t3.xyz + dcl_2d s0 + dcl_cube s1 + texld r0, t3, s1 + texld r1, t2, s0 + mul r1, r1, t0 + mad r0.xyz, r0, r1.w, -r1 + mul r0.w, r0.w, r1.w + mad r0.xyz, t1, r0, r1 + mad r1.xyz, c0, r0.w, r0 + mov oC0, r1 + +// approximately 8 instruction slots used (2 texture, 6 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[1], immediateIndexed +dcl_sampler s0, mode_default +dcl_sampler s1, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_resource_texturecube (float,float,float,float) t1 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyz +dcl_input_ps linear v2.xy +dcl_input_ps linear v3.xyz +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v3.xyzx, t1.xyzw, s1 +sample r1.xyzw, v2.xyxx, t0.xyzw, s0 +mul r1.xyzw, r1.xyzw, v0.xyzw +mad r0.xyz, r0.xyzx, r1.wwww, -r1.xyzx +mul r0.w, r0.w, r1.w +mad r0.xyz, v1.xyzx, r0.xyzx, r1.xyzx +mov o0.w, r1.w +mad o0.xyz, cb0[0].xyzx, r0.wwww, r0.xyzx +ret +// Approximately 0 instruction slots used +#endif + +const BYTE EnvironmentMapEffect_PSEnvMapSpecularNoFog[] = +{ + 68, 88, 66, 67, 187, 250, + 231, 5, 121, 80, 60, 173, + 98, 18, 212, 255, 189, 173, + 239, 11, 1, 0, 0, 0, + 164, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 72, 1, 0, 0, 240, 2, + 0, 0, 112, 3, 0, 0, + 65, 111, 110, 57, 16, 1, + 0, 0, 16, 1, 0, 0, + 0, 2, 255, 255, 216, 0, + 0, 0, 56, 0, 0, 0, + 1, 0, 44, 0, 0, 0, + 56, 0, 0, 0, 56, 0, + 2, 0, 36, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 2, + 255, 255, 31, 0, 0, 2, + 0, 0, 0, 128, 0, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 1, 0, + 15, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 2, 0, + 3, 176, 31, 0, 0, 2, + 0, 0, 0, 128, 3, 0, + 7, 176, 31, 0, 0, 2, + 0, 0, 0, 144, 0, 8, + 15, 160, 31, 0, 0, 2, + 0, 0, 0, 152, 1, 8, + 15, 160, 66, 0, 0, 3, + 0, 0, 15, 128, 3, 0, + 228, 176, 1, 8, 228, 160, + 66, 0, 0, 3, 1, 0, + 15, 128, 2, 0, 228, 176, + 0, 8, 228, 160, 5, 0, + 0, 3, 1, 0, 15, 128, + 1, 0, 228, 128, 0, 0, + 228, 176, 4, 0, 0, 4, + 0, 0, 7, 128, 0, 0, + 228, 128, 1, 0, 255, 128, + 1, 0, 228, 129, 5, 0, + 0, 3, 0, 0, 8, 128, + 0, 0, 255, 128, 1, 0, + 255, 128, 4, 0, 0, 4, + 0, 0, 7, 128, 1, 0, + 228, 176, 0, 0, 228, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 1, 0, 7, 128, + 0, 0, 228, 160, 0, 0, + 255, 128, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 8, + 15, 128, 1, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 160, 1, 0, 0, + 64, 0, 0, 0, 104, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 1, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 88, 48, + 0, 4, 0, 112, 16, 0, + 1, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 3, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 2, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 3, 0, 0, 0, + 70, 126, 16, 0, 1, 0, + 0, 0, 0, 96, 16, 0, + 1, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 10, 114, 32, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 120, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 104, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 7, 0, 0, + 110, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 110, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 7, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMap.inc b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMap.inc new file mode 100644 index 0000000000000000000000000000000000000000..29e263d7871d112fc91a496d5650d88b48e4e891 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMap.inc @@ -0,0 +1,510 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// SV_Position 0 xyzw 4 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 1 10 ( FLT, FLT, FLT, FLT) +// c11 cb0 12 4 ( FLT, FLT, FLT, FLT) +// c15 cb0 17 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c22, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp3 r0.x, v1, c15 + dp3 r0.y, v1, c16 + dp3 r0.z, v1, c17 + nrm r1.xyz, r0 + dp3 r0.x, -c4, r1 + dp3 r0.y, -c5, r1 + dp3 r0.z, -c6, r1 + sge r2.xyz, r0, c22.x + mul r0.xyz, r0, r2 + mul r2.xyz, r0.y, c8 + mad r0.xyw, r0.x, c7.xyzz, r2.xyzz + mad r0.xyz, r0.z, c9, r0.xyww + mov r2.xyz, c2 + mad oT0.xyz, r0, r2, c3 + dp4 oPos.z, v0, c20 + dp4 r0.x, v0, c11 + max r0.x, r0.x, c22.x + min oT1.w, r0.x, c22.y + dp4 r0.x, v0, c12 + dp4 r0.y, v0, c13 + dp4 r0.z, v0, c14 + add r0.xyz, -r0, c10 + nrm r2.xyz, r0 + dp3 r0.x, -r2, r1 + add r0.x, r0.x, r0.x + mad oT3.xyz, r1, -r0.x, -r2 + dp4 r0.x, v0, c18 + dp4 r0.y, v0, c19 + dp4 r0.z, v0, c21 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.w, c2.w + mov oT1.xyz, c1.x + mov oT2.xy, v2 + +// approximately 38 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[24], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output_siv o4.xyzw, position +dcl_temps 3 +dp3 r0.x, v1.xyzx, cb0[17].xyzx +dp3 r0.y, v1.xyzx, cb0[18].xyzx +dp3 r0.z, v1.xyzx, cb0[19].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r1.x, -cb0[4].xyzx, r0.xyzx +dp3 r1.y, -cb0[5].xyzx, r0.xyzx +dp3 r1.z, -cb0[6].xyzx, r0.xyzx +ge r2.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r1.xyz, r1.xyzx, r2.xyzx +mul r2.xyz, r1.yyyy, cb0[8].xyzx +mad r1.xyw, r1.xxxx, cb0[7].xyxz, r2.xyxz +mad r1.xyz, r1.zzzz, cb0[9].xyzx, r1.xywx +mad o0.xyz, r1.xyzx, cb0[2].xyzx, cb0[3].xyzx +mov o0.w, cb0[2].w +dp4_sat o1.w, v0.xyzw, cb0[12].xyzw +mov o1.xyz, cb0[1].xxxx +mov o2.xy, v2.xyxx +dp4 r1.x, v0.xyzw, cb0[13].xyzw +dp4 r1.y, v0.xyzw, cb0[14].xyzw +dp4 r1.z, v0.xyzw, cb0[15].xyzw +add r1.xyz, -r1.xyzx, cb0[10].xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mul r1.xyz, r0.wwww, r1.xyzx +dp3 r0.w, -r1.xyzx, r0.xyzx +add r0.w, r0.w, r0.w +mad o3.xyz, r0.xyzx, -r0.wwww, -r1.xyzx +dp4 o4.x, v0.xyzw, cb0[20].xyzw +dp4 o4.y, v0.xyzw, cb0[21].xyzw +dp4 o4.z, v0.xyzw, cb0[22].xyzw +dp4 o4.w, v0.xyzw, cb0[23].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE EnvironmentMapEffect_VSEnvMap[] = +{ + 68, 88, 66, 67, 29, 224, + 82, 121, 115, 234, 195, 135, + 61, 109, 154, 38, 63, 150, + 90, 155, 1, 0, 0, 0, + 196, 8, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 224, 2, 0, 0, 172, 7, + 0, 0, 32, 8, 0, 0, + 65, 111, 110, 57, 168, 2, + 0, 0, 168, 2, 0, 0, + 0, 2, 254, 255, 92, 2, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 1, 0, + 10, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 4, 0, 11, 0, 0, 0, + 0, 0, 0, 0, 17, 0, + 7, 0, 15, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 22, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 8, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 228, 144, 15, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 16, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 4, 128, 1, 0, 228, 144, + 17, 0, 228, 160, 36, 0, + 0, 2, 1, 0, 7, 128, + 0, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 1, 128, + 4, 0, 228, 161, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 5, 0, + 228, 161, 1, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 4, 128, 6, 0, 228, 161, + 1, 0, 228, 128, 13, 0, + 0, 3, 2, 0, 7, 128, + 0, 0, 228, 128, 22, 0, + 0, 160, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 228, 128, + 5, 0, 0, 3, 2, 0, + 7, 128, 0, 0, 85, 128, + 8, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 11, 128, + 0, 0, 0, 128, 7, 0, + 164, 160, 2, 0, 164, 128, + 4, 0, 0, 4, 0, 0, + 7, 128, 0, 0, 170, 128, + 9, 0, 228, 160, 0, 0, + 244, 128, 1, 0, 0, 2, + 2, 0, 7, 128, 2, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 224, 0, 0, + 228, 128, 2, 0, 228, 128, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 20, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 11, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 22, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 22, 0, + 85, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 12, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 13, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 14, 0, + 228, 160, 2, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 129, 10, 0, 228, 160, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 129, + 1, 0, 228, 128, 2, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 0, 128, 0, 0, + 0, 128, 4, 0, 0, 4, + 3, 0, 7, 224, 1, 0, + 228, 128, 0, 0, 0, 129, + 2, 0, 228, 129, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 18, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 19, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 21, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 170, 128, 0, 0, + 228, 160, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 170, 128, + 1, 0, 0, 2, 0, 0, + 8, 224, 2, 0, 255, 160, + 1, 0, 0, 2, 1, 0, + 7, 224, 1, 0, 0, 160, + 1, 0, 0, 2, 2, 0, + 3, 224, 2, 0, 228, 144, + 255, 255, 0, 0, 83, 72, + 68, 82, 196, 4, 0, 0, + 64, 0, 1, 0, 49, 1, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 3, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 4, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 3, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 16, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 18, 0, 0, 0, 16, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 19, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 29, 0, + 0, 10, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 10, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 2, 0, 0, 0, 86, 5, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 1, 0, + 0, 0, 70, 136, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 70, 8, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 1, 0, 0, 0, 166, 10, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 70, 3, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 54, 0, + 0, 6, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 128, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 12, 0, 0, 0, + 54, 0, 0, 6, 114, 32, + 16, 0, 1, 0, 0, 0, + 6, 128, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 0, 0, 0, 9, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 10, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 8, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 32, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 21, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 4, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 108, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 99, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 79, 83, + 71, 78, 156, 0, 0, 0, + 5, 0, 0, 0, 8, 0, + 0, 0, 128, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 128, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 134, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 12, + 0, 0, 134, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 8, + 0, 0, 143, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 15, 0, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 83, + 86, 95, 80, 111, 115, 105, + 116, 105, 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMapFresnel.inc b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMapFresnel.inc new file mode 100644 index 0000000000000000000000000000000000000000..3e4bbeef0668cbde349eef334534f07525df3c4a --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMapFresnel.inc @@ -0,0 +1,563 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// SV_Position 0 xyzw 4 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 1 10 ( FLT, FLT, FLT, FLT) +// c11 cb0 12 4 ( FLT, FLT, FLT, FLT) +// c15 cb0 17 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c22, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp3 r0.x, v1, c15 + dp3 r0.y, v1, c16 + dp3 r0.z, v1, c17 + nrm r1.xyz, r0 + dp3 r0.x, -c4, r1 + dp3 r0.y, -c5, r1 + dp3 r0.z, -c6, r1 + sge r2.xyz, r0, c22.x + mul r0.xyz, r0, r2 + mul r2.xyz, r0.y, c8 + mad r0.xyw, r0.x, c7.xyzz, r2.xyzz + mad r0.xyz, r0.z, c9, r0.xyww + mov r2.xyz, c2 + mad oT0.xyz, r0, r2, c3 + dp4 oPos.z, v0, c20 + dp4 r0.x, v0, c12 + dp4 r0.y, v0, c13 + dp4 r0.z, v0, c14 + add r0.xyz, -r0, c10 + nrm r2.xyz, r0 + dp3 r0.x, r2, r1 + abs r0.x, r0.x + add r0.x, -r0.x, c22.y + max r0.x, r0.x, c22.x + pow r1.w, r0.x, c1.y + mul oT1.xyz, r1.w, c1.x + dp4 r0.x, v0, c11 + max r0.x, r0.x, c22.x + min oT1.w, r0.x, c22.y + dp3 r0.x, -r2, r1 + add r0.x, r0.x, r0.x + mad oT3.xyz, r1, -r0.x, -r2 + dp4 r0.x, v0, c18 + dp4 r0.y, v0, c19 + dp4 r0.z, v0, c21 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.w, c2.w + mov oT2.xy, v2 + +// approximately 45 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[24], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output_siv o4.xyzw, position +dcl_temps 3 +dp3 r0.x, v1.xyzx, cb0[17].xyzx +dp3 r0.y, v1.xyzx, cb0[18].xyzx +dp3 r0.z, v1.xyzx, cb0[19].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r1.x, -cb0[4].xyzx, r0.xyzx +dp3 r1.y, -cb0[5].xyzx, r0.xyzx +dp3 r1.z, -cb0[6].xyzx, r0.xyzx +ge r2.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r1.xyz, r1.xyzx, r2.xyzx +mul r2.xyz, r1.yyyy, cb0[8].xyzx +mad r1.xyw, r1.xxxx, cb0[7].xyxz, r2.xyxz +mad r1.xyz, r1.zzzz, cb0[9].xyzx, r1.xywx +mad o0.xyz, r1.xyzx, cb0[2].xyzx, cb0[3].xyzx +mov o0.w, cb0[2].w +dp4 r1.x, v0.xyzw, cb0[13].xyzw +dp4 r1.y, v0.xyzw, cb0[14].xyzw +dp4 r1.z, v0.xyzw, cb0[15].xyzw +add r1.xyz, -r1.xyzx, cb0[10].xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mul r1.xyz, r0.wwww, r1.xyzx +dp3 r0.w, r1.xyzx, r0.xyzx +add r0.w, -|r0.w|, l(1.000000) +max r0.w, r0.w, l(0.000000) +log r0.w, r0.w +mul r0.w, r0.w, cb0[1].y +exp r0.w, r0.w +mul o1.xyz, r0.wwww, cb0[1].xxxx +dp4_sat o1.w, v0.xyzw, cb0[12].xyzw +mov o2.xy, v2.xyxx +dp3 r0.w, -r1.xyzx, r0.xyzx +add r0.w, r0.w, r0.w +mad o3.xyz, r0.xyzx, -r0.wwww, -r1.xyzx +dp4 o4.x, v0.xyzw, cb0[20].xyzw +dp4 o4.y, v0.xyzw, cb0[21].xyzw +dp4 o4.z, v0.xyzw, cb0[22].xyzw +dp4 o4.w, v0.xyzw, cb0[23].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE EnvironmentMapEffect_VSEnvMapFresnel[] = +{ + 68, 88, 66, 67, 203, 164, + 21, 36, 185, 120, 53, 136, + 169, 70, 68, 18, 136, 26, + 75, 250, 1, 0, 0, 0, + 188, 9, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 48, 3, 0, 0, 164, 8, + 0, 0, 24, 9, 0, 0, + 65, 111, 110, 57, 248, 2, + 0, 0, 248, 2, 0, 0, + 0, 2, 254, 255, 172, 2, + 0, 0, 76, 0, 0, 0, + 3, 0, 36, 0, 0, 0, + 72, 0, 0, 0, 72, 0, + 0, 0, 36, 0, 1, 0, + 72, 0, 0, 0, 1, 0, + 10, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 4, 0, 11, 0, 0, 0, + 0, 0, 0, 0, 17, 0, + 7, 0, 15, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 22, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 8, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 228, 144, 15, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 16, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 4, 128, 1, 0, 228, 144, + 17, 0, 228, 160, 36, 0, + 0, 2, 1, 0, 7, 128, + 0, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 1, 128, + 4, 0, 228, 161, 1, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 5, 0, + 228, 161, 1, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 4, 128, 6, 0, 228, 161, + 1, 0, 228, 128, 13, 0, + 0, 3, 2, 0, 7, 128, + 0, 0, 228, 128, 22, 0, + 0, 160, 5, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 228, 128, + 5, 0, 0, 3, 2, 0, + 7, 128, 0, 0, 85, 128, + 8, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 11, 128, + 0, 0, 0, 128, 7, 0, + 164, 160, 2, 0, 164, 128, + 4, 0, 0, 4, 0, 0, + 7, 128, 0, 0, 170, 128, + 9, 0, 228, 160, 0, 0, + 244, 128, 1, 0, 0, 2, + 2, 0, 7, 128, 2, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 224, 0, 0, + 228, 128, 2, 0, 228, 128, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 20, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 12, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 13, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 14, 0, + 228, 160, 2, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 129, 10, 0, 228, 160, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 128, + 1, 0, 228, 128, 35, 0, + 0, 2, 0, 0, 1, 128, + 0, 0, 0, 128, 2, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 0, 129, 22, 0, + 85, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 22, 0, 0, 160, + 32, 0, 0, 3, 1, 0, + 8, 128, 0, 0, 0, 128, + 1, 0, 85, 160, 5, 0, + 0, 3, 1, 0, 7, 224, + 1, 0, 255, 128, 1, 0, + 0, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 11, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 22, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 22, 0, + 85, 160, 8, 0, 0, 3, + 0, 0, 1, 128, 2, 0, + 228, 129, 1, 0, 228, 128, + 2, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 0, 0, 0, 128, 4, 0, + 0, 4, 3, 0, 7, 224, + 1, 0, 228, 128, 0, 0, + 0, 129, 2, 0, 228, 129, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 18, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 19, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 21, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 0, 0, 8, 224, 2, 0, + 255, 160, 1, 0, 0, 2, + 2, 0, 3, 224, 2, 0, + 228, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 108, 5, + 0, 0, 64, 0, 1, 0, + 91, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 3, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 4, 0, + 0, 0, 1, 0, 0, 0, + 104, 0, 0, 2, 3, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 18, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 19, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 29, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 10, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 2, 0, 0, 0, + 86, 5, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 50, 0, 0, 10, + 178, 0, 16, 0, 1, 0, + 0, 0, 6, 0, 16, 0, + 1, 0, 0, 0, 70, 136, + 32, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 70, 8, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 1, 0, 0, 0, + 166, 10, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 70, 3, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 11, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 54, 0, 0, 6, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 0, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 128, + 193, 0, 0, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 52, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 47, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 25, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 32, 16, 0, 1, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 6, 128, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 12, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 16, 0, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 0, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 32, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 1, 0, 0, 0, 17, 0, + 0, 8, 18, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 17, 0, 0, 8, 34, 32, + 16, 0, 4, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 17, 0, 0, 8, + 66, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 130, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 108, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 92, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 99, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 3, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 78, 79, 82, 77, + 65, 76, 0, 84, 69, 88, + 67, 79, 79, 82, 68, 0, + 79, 83, 71, 78, 156, 0, + 0, 0, 5, 0, 0, 0, + 8, 0, 0, 0, 128, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 128, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 134, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 134, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 8, 0, 0, 143, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMapOneLight.inc b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMapOneLight.inc new file mode 100644 index 0000000000000000000000000000000000000000..cf045b4434705dc56b82816a766308dd52a761fb --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMapOneLight.inc @@ -0,0 +1,467 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// SV_Position 0 xyzw 4 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 1 4 ( FLT, FLT, FLT, FLT) +// c5 cb0 7 1 ( FLT, FLT, FLT, FLT) +// c6 cb0 10 1 ( FLT, FLT, FLT, FLT) +// c7 cb0 12 4 ( FLT, FLT, FLT, FLT) +// c11 cb0 17 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c18, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp3 r0.x, v1, c11 + dp3 r0.y, v1, c12 + dp3 r0.z, v1, c13 + nrm r1.xyz, r0 + dp3 r0.x, -c4, r1 + sge r0.y, r0.x, c18.x + mul r0.x, r0.x, r0.y + mul r0.xyz, r0.x, c5 + mov r2.xyz, c2 + mad oT0.xyz, r0, r2, c3 + dp4 oPos.z, v0, c16 + dp4 r0.x, v0, c7 + max r0.x, r0.x, c18.x + min oT1.w, r0.x, c18.y + dp4 r0.x, v0, c8 + dp4 r0.y, v0, c9 + dp4 r0.z, v0, c10 + add r0.xyz, -r0, c6 + nrm r2.xyz, r0 + dp3 r0.x, -r2, r1 + add r0.x, r0.x, r0.x + mad oT3.xyz, r1, -r0.x, -r2 + dp4 r0.x, v0, c14 + dp4 r0.y, v0, c15 + dp4 r0.z, v0, c17 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.w, c2.w + mov oT1.xyz, c1.x + mov oT2.xy, v2 + +// approximately 34 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[24], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output_siv o4.xyzw, position +dcl_temps 2 +dp3 r0.x, v1.xyzx, cb0[17].xyzx +dp3 r0.y, v1.xyzx, cb0[18].xyzx +dp3 r0.z, v1.xyzx, cb0[19].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r0.w, -cb0[4].xyzx, r0.xyzx +ge r1.x, r0.w, l(0.000000) +and r1.x, r1.x, l(0x3f800000) +mul r0.w, r0.w, r1.x +mul r1.xyz, r0.wwww, cb0[7].xyzx +mad o0.xyz, r1.xyzx, cb0[2].xyzx, cb0[3].xyzx +mov o0.w, cb0[2].w +dp4_sat o1.w, v0.xyzw, cb0[12].xyzw +mov o1.xyz, cb0[1].xxxx +mov o2.xy, v2.xyxx +dp4 r1.x, v0.xyzw, cb0[13].xyzw +dp4 r1.y, v0.xyzw, cb0[14].xyzw +dp4 r1.z, v0.xyzw, cb0[15].xyzw +add r1.xyz, -r1.xyzx, cb0[10].xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mul r1.xyz, r0.wwww, r1.xyzx +dp3 r0.w, -r1.xyzx, r0.xyzx +add r0.w, r0.w, r0.w +mad o3.xyz, r0.xyzx, -r0.wwww, -r1.xyzx +dp4 o4.x, v0.xyzw, cb0[20].xyzw +dp4 o4.y, v0.xyzw, cb0[21].xyzw +dp4 o4.z, v0.xyzw, cb0[22].xyzw +dp4 o4.w, v0.xyzw, cb0[23].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE EnvironmentMapEffect_VSEnvMapOneLight[] = +{ + 68, 88, 66, 67, 27, 62, + 114, 163, 209, 76, 199, 240, + 199, 93, 202, 210, 161, 55, + 236, 164, 1, 0, 0, 0, + 228, 7, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 176, 2, 0, 0, 204, 6, + 0, 0, 64, 7, 0, 0, + 65, 111, 110, 57, 120, 2, + 0, 0, 120, 2, 0, 0, + 0, 2, 254, 255, 20, 2, + 0, 0, 100, 0, 0, 0, + 5, 0, 36, 0, 0, 0, + 96, 0, 0, 0, 96, 0, + 0, 0, 36, 0, 1, 0, + 96, 0, 0, 0, 1, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 7, 0, + 1, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 10, 0, + 1, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 4, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 17, 0, + 7, 0, 11, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 18, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 8, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 228, 144, 11, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 12, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 4, 128, 1, 0, 228, 144, + 13, 0, 228, 160, 36, 0, + 0, 2, 1, 0, 7, 128, + 0, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 1, 128, + 4, 0, 228, 161, 1, 0, + 228, 128, 13, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 0, 128, 18, 0, 0, 160, + 5, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 0, 0, 85, 128, 5, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 0, 128, 5, 0, + 228, 160, 1, 0, 0, 2, + 2, 0, 7, 128, 2, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 224, 0, 0, + 228, 128, 2, 0, 228, 128, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 16, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 7, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 18, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 18, 0, + 85, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 8, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 9, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 10, 0, + 228, 160, 2, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 129, 6, 0, 228, 160, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 129, + 1, 0, 228, 128, 2, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 0, 128, 0, 0, + 0, 128, 4, 0, 0, 4, + 3, 0, 7, 224, 1, 0, + 228, 128, 0, 0, 0, 129, + 2, 0, 228, 129, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 144, 14, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 15, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 128, 0, 0, 228, 144, + 17, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 170, 128, 0, 0, + 228, 160, 0, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 170, 128, + 1, 0, 0, 2, 0, 0, + 8, 224, 2, 0, 255, 160, + 1, 0, 0, 2, 1, 0, + 7, 224, 1, 0, 0, 160, + 1, 0, 0, 2, 2, 0, + 3, 224, 2, 0, 228, 144, + 255, 255, 0, 0, 83, 72, + 68, 82, 20, 4, 0, 0, + 64, 0, 1, 0, 5, 1, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 3, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 4, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 2, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 16, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 18, 0, 0, 0, 16, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 19, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 29, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 7, 0, 0, 0, + 50, 0, 0, 11, 114, 32, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 54, 0, 0, 6, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 54, 0, + 0, 6, 114, 32, 16, 0, + 1, 0, 0, 0, 6, 128, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 54, 0, + 0, 5, 50, 32, 16, 0, + 2, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 17, 0, 0, 8, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 17, 0, 0, 8, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 17, 0, + 0, 8, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 0, 0, 0, 9, 114, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 8, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 114, 32, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 4, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 20, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 22, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 4, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 23, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 108, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 92, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 99, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 79, 83, 71, 78, + 156, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 128, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 134, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 12, 0, 0, + 134, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 7, 8, 0, 0, + 143, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMapOneLightFresnel.inc b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMapOneLightFresnel.inc new file mode 100644 index 0000000000000000000000000000000000000000..7eb6fe0466d25564e34d62d9518fbac508022683 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/EnvironmentMapEffect_VSEnvMapOneLightFresnel.inc @@ -0,0 +1,519 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// TEXCOORD 1 xyz 3 NONE float xyz +// SV_Position 0 xyzw 4 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 1 4 ( FLT, FLT, FLT, FLT) +// c5 cb0 7 1 ( FLT, FLT, FLT, FLT) +// c6 cb0 10 1 ( FLT, FLT, FLT, FLT) +// c7 cb0 12 4 ( FLT, FLT, FLT, FLT) +// c11 cb0 17 7 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c18, 0, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dp3 r0.x, v1, c11 + dp3 r0.y, v1, c12 + dp3 r0.z, v1, c13 + nrm r1.xyz, r0 + dp3 r0.x, -c4, r1 + sge r0.y, r0.x, c18.x + mul r0.x, r0.x, r0.y + mul r0.xyz, r0.x, c5 + mov r2.xyz, c2 + mad oT0.xyz, r0, r2, c3 + dp4 oPos.z, v0, c16 + dp4 r0.x, v0, c8 + dp4 r0.y, v0, c9 + dp4 r0.z, v0, c10 + add r0.xyz, -r0, c6 + nrm r2.xyz, r0 + dp3 r0.x, r2, r1 + abs r0.x, r0.x + add r0.x, -r0.x, c18.y + max r0.x, r0.x, c18.x + pow r1.w, r0.x, c1.y + mul oT1.xyz, r1.w, c1.x + dp4 r0.x, v0, c7 + max r0.x, r0.x, c18.x + min oT1.w, r0.x, c18.y + dp3 r0.x, -r2, r1 + add r0.x, r0.x, r0.x + mad oT3.xyz, r1, -r0.x, -r2 + dp4 r0.x, v0, c14 + dp4 r0.y, v0, c15 + dp4 r0.z, v0, c17 + mad oPos.xy, r0.z, c0, r0 + mov oPos.w, r0.z + mov oT0.w, c2.w + mov oT2.xy, v2 + +// approximately 41 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[24], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output o3.xyz +dcl_output_siv o4.xyzw, position +dcl_temps 2 +dp3 r0.x, v1.xyzx, cb0[17].xyzx +dp3 r0.y, v1.xyzx, cb0[18].xyzx +dp3 r0.z, v1.xyzx, cb0[19].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r0.w, -cb0[4].xyzx, r0.xyzx +ge r1.x, r0.w, l(0.000000) +and r1.x, r1.x, l(0x3f800000) +mul r0.w, r0.w, r1.x +mul r1.xyz, r0.wwww, cb0[7].xyzx +mad o0.xyz, r1.xyzx, cb0[2].xyzx, cb0[3].xyzx +mov o0.w, cb0[2].w +dp4 r1.x, v0.xyzw, cb0[13].xyzw +dp4 r1.y, v0.xyzw, cb0[14].xyzw +dp4 r1.z, v0.xyzw, cb0[15].xyzw +add r1.xyz, -r1.xyzx, cb0[10].xyzx +dp3 r0.w, r1.xyzx, r1.xyzx +rsq r0.w, r0.w +mul r1.xyz, r0.wwww, r1.xyzx +dp3 r0.w, r1.xyzx, r0.xyzx +add r0.w, -|r0.w|, l(1.000000) +max r0.w, r0.w, l(0.000000) +log r0.w, r0.w +mul r0.w, r0.w, cb0[1].y +exp r0.w, r0.w +mul o1.xyz, r0.wwww, cb0[1].xxxx +dp4_sat o1.w, v0.xyzw, cb0[12].xyzw +mov o2.xy, v2.xyxx +dp3 r0.w, -r1.xyzx, r0.xyzx +add r0.w, r0.w, r0.w +mad o3.xyz, r0.xyzx, -r0.wwww, -r1.xyzx +dp4 o4.x, v0.xyzw, cb0[20].xyzw +dp4 o4.y, v0.xyzw, cb0[21].xyzw +dp4 o4.z, v0.xyzw, cb0[22].xyzw +dp4 o4.w, v0.xyzw, cb0[23].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE EnvironmentMapEffect_VSEnvMapOneLightFresnel[] = +{ + 68, 88, 66, 67, 244, 71, + 81, 193, 116, 157, 204, 48, + 101, 140, 234, 141, 158, 237, + 10, 203, 1, 0, 0, 0, + 220, 8, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 0, 3, 0, 0, 196, 7, + 0, 0, 56, 8, 0, 0, + 65, 111, 110, 57, 200, 2, + 0, 0, 200, 2, 0, 0, + 0, 2, 254, 255, 100, 2, + 0, 0, 100, 0, 0, 0, + 5, 0, 36, 0, 0, 0, + 96, 0, 0, 0, 96, 0, + 0, 0, 36, 0, 1, 0, + 96, 0, 0, 0, 1, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 7, 0, + 1, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 10, 0, + 1, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 12, 0, + 4, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 17, 0, + 7, 0, 11, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 18, 0, 15, 160, + 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 8, 0, + 0, 3, 0, 0, 1, 128, + 1, 0, 228, 144, 11, 0, + 228, 160, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 12, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 4, 128, 1, 0, 228, 144, + 13, 0, 228, 160, 36, 0, + 0, 2, 1, 0, 7, 128, + 0, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 1, 128, + 4, 0, 228, 161, 1, 0, + 228, 128, 13, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 0, 128, 18, 0, 0, 160, + 5, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 0, 0, 85, 128, 5, 0, + 0, 3, 0, 0, 7, 128, + 0, 0, 0, 128, 5, 0, + 228, 160, 1, 0, 0, 2, + 2, 0, 7, 128, 2, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 7, 224, 0, 0, + 228, 128, 2, 0, 228, 128, + 3, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 144, 16, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 8, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 0, 0, 228, 144, + 9, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 10, 0, + 228, 160, 2, 0, 0, 3, + 0, 0, 7, 128, 0, 0, + 228, 129, 6, 0, 228, 160, + 36, 0, 0, 2, 2, 0, + 7, 128, 0, 0, 228, 128, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 128, + 1, 0, 228, 128, 35, 0, + 0, 2, 0, 0, 1, 128, + 0, 0, 0, 128, 2, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 0, 129, 18, 0, + 85, 160, 11, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 0, 128, 18, 0, 0, 160, + 32, 0, 0, 3, 1, 0, + 8, 128, 0, 0, 0, 128, + 1, 0, 85, 160, 5, 0, + 0, 3, 1, 0, 7, 224, + 1, 0, 255, 128, 1, 0, + 0, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 7, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 18, 0, 0, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 18, 0, + 85, 160, 8, 0, 0, 3, + 0, 0, 1, 128, 2, 0, + 228, 129, 1, 0, 228, 128, + 2, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 0, 0, 0, 128, 4, 0, + 0, 4, 3, 0, 7, 224, + 1, 0, 228, 128, 0, 0, + 0, 129, 2, 0, 228, 129, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 144, + 14, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 2, 128, + 0, 0, 228, 144, 15, 0, + 228, 160, 9, 0, 0, 3, + 0, 0, 4, 128, 0, 0, + 228, 144, 17, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 192, 0, 0, 170, 128, + 0, 0, 228, 160, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 0, 8, 192, 0, 0, + 170, 128, 1, 0, 0, 2, + 0, 0, 8, 224, 2, 0, + 255, 160, 1, 0, 0, 2, + 2, 0, 3, 224, 2, 0, + 228, 144, 255, 255, 0, 0, + 83, 72, 68, 82, 188, 4, + 0, 0, 64, 0, 1, 0, + 47, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 95, 0, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 95, 0, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 95, 0, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 1, 0, + 0, 0, 101, 0, 0, 3, + 50, 32, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 114, 32, 16, 0, 3, 0, + 0, 0, 103, 0, 0, 4, + 242, 32, 16, 0, 4, 0, + 0, 0, 1, 0, 0, 0, + 104, 0, 0, 2, 2, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 18, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 19, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 29, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 56, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 50, 0, 0, 11, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 54, 0, + 0, 6, 130, 32, 16, 0, + 0, 0, 0, 0, 58, 128, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 17, 0, + 0, 8, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 13, 0, 0, 0, + 17, 0, 0, 8, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 17, 0, 0, 8, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 0, 0, + 0, 9, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 128, 65, 0, 0, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 128, 193, 0, + 0, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 52, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 47, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 26, 128, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 25, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 32, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 6, 128, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 54, 0, + 0, 5, 50, 32, 16, 0, + 2, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 16, 0, 0, 8, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 32, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 4, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 21, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 4, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 108, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 99, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 79, 83, + 71, 78, 156, 0, 0, 0, + 5, 0, 0, 0, 8, 0, + 0, 0, 128, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 128, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 15, 0, + 0, 0, 134, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 3, 12, + 0, 0, 134, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 8, + 0, 0, 143, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 15, 0, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 83, + 86, 95, 80, 111, 115, 105, + 116, 105, 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_PSSkinnedPixelLighting.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_PSSkinnedPixelLighting.inc new file mode 100644 index 0000000000000000000000000000000000000000..5eba921b908d706bd19176ea3aa944de357dc76a --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_PSSkinnedPixelLighting.inc @@ -0,0 +1,602 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xy 0 NONE float xy +// TEXCOORD 1 xyzw 1 NONE float xyzw +// TEXCOORD 2 xyz 2 NONE float xyz +// COLOR 0 xyzw 3 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 14 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + def c14, 1, 0, 0, 0 + dcl t0.xyz + dcl t1 + dcl t2.xyz + dcl t3 + dcl_2d s0 + texld r0, t0, s0 + nrm r1.xyz, t2 + dp3 r2.x, -c3, r1 + dp3 r2.y, -c4, r1 + dp3 r2.z, -c5, r1 + cmp r3.xyz, r2, c14.x, c14.y + mul r2.xyz, r2, r3 + add r4.xyz, -t1, c12 + dp3 r1.w, r4, r4 + rsq r1.w, r1.w + mad r5.xyz, r4, r1.w, -c3 + nrm r6.xyz, r5 + dp3 r5.x, r6, r1 + mad r6.xyz, r4, r1.w, -c4 + mad r4.xyz, r4, r1.w, -c5 + nrm r7.xyz, r4 + dp3 r5.z, r7, r1 + nrm r4.xyz, r6 + dp3 r5.y, r4, r1 + mul r1.xyz, r3, r5 + cmp r1.xyz, r5, r1, c14.y + log r3.x, r1.x + log r3.y, r1.y + log r3.z, r1.z + mul r1.xyz, r3, c2.w + exp r2.w, r1.y + mul r3.xyz, r2.w, c10 + exp r2.w, r1.x + exp r3.w, r1.z + mad r1.xyz, r2.w, c9, r3 + mad r1.xyz, r3.w, c11, r1 + mul r1.xyz, r1, c2 + mul r0, r0, t3 + mul r1.xyz, r0.w, r1 + mul r3.xyz, r2.y, c7 + mad r3.xyz, r2.x, c6, r3 + mad r2.xyz, r2.z, c8, r3 + mov r3.xyz, c0 + mad r2.xyz, r2, r3, c1 + mad r1.xyz, r0, r2, r1 + mad r2.xyz, c13, r0.w, -r1 + mad r0.xyz, t1.w, r2, r1 + mov oC0, r0 + +// approximately 51 instruction slots used (1 texture, 50 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[14], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xy +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xyz +dcl_input_ps linear v3.xyzw +dcl_output o0.xyzw +dcl_temps 4 +add r0.xyz, -v1.xyzx, cb0[12].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mad r1.xyz, r0.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r1.w, r1.xyzx, r1.xyzx +rsq r1.w, r1.w +mul r1.xyz, r1.wwww, r1.xyzx +dp3 r1.w, v2.xyzx, v2.xyzx +rsq r1.w, r1.w +mul r2.xyz, r1.wwww, v2.xyzx +dp3 r1.x, r1.xyzx, r2.xyzx +mad r3.xyz, r0.xyzx, r0.wwww, -cb0[4].xyzx +mad r0.xyz, r0.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r3.xyzx, r3.xyzx +rsq r0.w, r0.w +mul r3.xyz, r0.wwww, r3.xyzx +dp3 r1.y, r3.xyzx, r2.xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r1.z, r0.xyzx, r2.xyzx +max r0.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +dp3 r1.x, -cb0[3].xyzx, r2.xyzx +dp3 r1.y, -cb0[4].xyzx, r2.xyzx +dp3 r1.z, -cb0[5].xyzx, r2.xyzx +ge r2.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r2.xyz, r2.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r0.xyz, r0.xyzx, r2.xyzx +mul r1.xyz, r1.xyzx, r2.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r2.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r2.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul r0.xyz, r0.xyzx, cb0[2].xyzx +sample r2.xyzw, v0.xyxx, t0.xyzw, s0 +mul r2.xyzw, r2.xyzw, v3.xyzw +mul r0.xyz, r0.xyzx, r2.wwww +mul r3.xyz, r1.yyyy, cb0[7].xyzx +mad r1.xyw, r1.xxxx, cb0[6].xyxz, r3.xyxz +mad r1.xyz, r1.zzzz, cb0[8].xyzx, r1.xywx +mad r1.xyz, r1.xyzx, cb0[0].xyzx, cb0[1].xyzx +mad r0.xyz, r2.xyzx, r1.xyzx, r0.xyzx +mad r1.xyz, cb0[13].xyzx, r2.wwww, -r0.xyzx +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +mov o0.w, r2.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_PSSkinnedPixelLighting[] = +{ + 68, 88, 66, 67, 129, 164, + 9, 179, 158, 143, 193, 218, + 75, 230, 209, 15, 16, 58, + 111, 78, 1, 0, 0, 0, + 128, 10, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 120, 3, 0, 0, 204, 9, + 0, 0, 76, 10, 0, 0, + 65, 111, 110, 57, 64, 3, + 0, 0, 64, 3, 0, 0, + 0, 2, 255, 255, 12, 3, + 0, 0, 52, 0, 0, 0, + 1, 0, 40, 0, 0, 0, + 52, 0, 0, 0, 52, 0, + 1, 0, 36, 0, 0, 0, + 52, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 81, 0, + 0, 5, 14, 0, 15, 160, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 7, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 3, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 176, 0, 8, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 176, 8, 0, 0, 3, + 2, 0, 1, 128, 3, 0, + 228, 161, 1, 0, 228, 128, + 8, 0, 0, 3, 2, 0, + 2, 128, 4, 0, 228, 161, + 1, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 4, 128, + 5, 0, 228, 161, 1, 0, + 228, 128, 88, 0, 0, 4, + 3, 0, 7, 128, 2, 0, + 228, 128, 14, 0, 0, 160, + 14, 0, 85, 160, 5, 0, + 0, 3, 2, 0, 7, 128, + 2, 0, 228, 128, 3, 0, + 228, 128, 2, 0, 0, 3, + 4, 0, 7, 128, 1, 0, + 228, 177, 12, 0, 228, 160, + 8, 0, 0, 3, 1, 0, + 8, 128, 4, 0, 228, 128, + 4, 0, 228, 128, 7, 0, + 0, 2, 1, 0, 8, 128, + 1, 0, 255, 128, 4, 0, + 0, 4, 5, 0, 7, 128, + 4, 0, 228, 128, 1, 0, + 255, 128, 3, 0, 228, 161, + 36, 0, 0, 2, 6, 0, + 7, 128, 5, 0, 228, 128, + 8, 0, 0, 3, 5, 0, + 1, 128, 6, 0, 228, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 6, 0, 7, 128, + 4, 0, 228, 128, 1, 0, + 255, 128, 4, 0, 228, 161, + 4, 0, 0, 4, 4, 0, + 7, 128, 4, 0, 228, 128, + 1, 0, 255, 128, 5, 0, + 228, 161, 36, 0, 0, 2, + 7, 0, 7, 128, 4, 0, + 228, 128, 8, 0, 0, 3, + 5, 0, 4, 128, 7, 0, + 228, 128, 1, 0, 228, 128, + 36, 0, 0, 2, 4, 0, + 7, 128, 6, 0, 228, 128, + 8, 0, 0, 3, 5, 0, + 2, 128, 4, 0, 228, 128, + 1, 0, 228, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 3, 0, 228, 128, 5, 0, + 228, 128, 88, 0, 0, 4, + 1, 0, 7, 128, 5, 0, + 228, 128, 1, 0, 228, 128, + 14, 0, 85, 160, 15, 0, + 0, 2, 3, 0, 1, 128, + 1, 0, 0, 128, 15, 0, + 0, 2, 3, 0, 2, 128, + 1, 0, 85, 128, 15, 0, + 0, 2, 3, 0, 4, 128, + 1, 0, 170, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 3, 0, 228, 128, 2, 0, + 255, 160, 14, 0, 0, 2, + 2, 0, 8, 128, 1, 0, + 85, 128, 5, 0, 0, 3, + 3, 0, 7, 128, 2, 0, + 255, 128, 10, 0, 228, 160, + 14, 0, 0, 2, 2, 0, + 8, 128, 1, 0, 0, 128, + 14, 0, 0, 2, 3, 0, + 8, 128, 1, 0, 170, 128, + 4, 0, 0, 4, 1, 0, + 7, 128, 2, 0, 255, 128, + 9, 0, 228, 160, 3, 0, + 228, 128, 4, 0, 0, 4, + 1, 0, 7, 128, 3, 0, + 255, 128, 11, 0, 228, 160, + 1, 0, 228, 128, 5, 0, + 0, 3, 1, 0, 7, 128, + 1, 0, 228, 128, 2, 0, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 3, 0, 228, 176, + 5, 0, 0, 3, 1, 0, + 7, 128, 0, 0, 255, 128, + 1, 0, 228, 128, 5, 0, + 0, 3, 3, 0, 7, 128, + 2, 0, 85, 128, 7, 0, + 228, 160, 4, 0, 0, 4, + 3, 0, 7, 128, 2, 0, + 0, 128, 6, 0, 228, 160, + 3, 0, 228, 128, 4, 0, + 0, 4, 2, 0, 7, 128, + 2, 0, 170, 128, 8, 0, + 228, 160, 3, 0, 228, 128, + 1, 0, 0, 2, 3, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 2, 0, + 7, 128, 2, 0, 228, 128, + 3, 0, 228, 128, 1, 0, + 228, 160, 4, 0, 0, 4, + 1, 0, 7, 128, 0, 0, + 228, 128, 2, 0, 228, 128, + 1, 0, 228, 128, 4, 0, + 0, 4, 2, 0, 7, 128, + 13, 0, 228, 160, 0, 0, + 255, 128, 1, 0, 228, 129, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 255, 176, + 2, 0, 228, 128, 1, 0, + 228, 128, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 76, 6, + 0, 0, 64, 0, 0, 0, + 147, 1, 0, 0, 89, 0, + 0, 4, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 0, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 114, 16, + 16, 0, 2, 0, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 3, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 4, 0, + 0, 0, 0, 0, 0, 9, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 128, + 65, 0, 0, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 2, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 3, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 0, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 7, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 52, 0, 0, 10, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 9, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 9, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 29, 0, + 0, 10, 114, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 10, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 47, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 246, 143, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 25, 0, 0, 5, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 86, 5, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 50, 0, + 0, 10, 178, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 136, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 70, 8, 16, 0, 2, 0, + 0, 0, 50, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 166, 10, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 70, 3, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 2, 0, + 0, 0, 70, 16, 16, 0, + 0, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 242, 0, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 30, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 3, 0, 0, 0, 86, 5, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 7, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 1, 0, + 0, 0, 70, 136, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 70, 8, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 1, 0, 0, 0, 166, 10, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 70, 3, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 246, 15, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 50, 0, 0, 9, 114, 32, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 2, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 120, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 3, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 15, 0, 0, 104, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 7, 7, 0, 0, 113, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 15, 0, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 67, 79, 76, 79, 82, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_PSSkinnedVertexLighting.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_PSSkinnedVertexLighting.inc new file mode 100644 index 0000000000000000000000000000000000000000..18e05529f5191e990ea5df283800bdb226d878ad --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_PSSkinnedVertexLighting.inc @@ -0,0 +1,196 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 13 1 ( FLT, FLT, FLT, FLT) +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl_2d s0 + texld r0, t2, s0 + mul r0, r0, t0 + mad r1.xyz, t1, r0.w, r0 + mad r2.xyz, c0, r0.w, -r1 + mad r0.xyz, t1.w, r2, r1 + mov oC0, r0 + +// approximately 6 instruction slots used (1 texture, 5 arithmetic) +ps_4_0 +dcl_constantbuffer CB0[14], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyzw +dcl_input_ps linear v2.xy +dcl_output o0.xyzw +dcl_temps 2 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul r0.xyzw, r0.xyzw, v0.xyzw +mad r0.xyz, v1.xyzx, r0.wwww, r0.xyzx +mad r1.xyz, cb0[13].xyzx, r0.wwww, -r0.xyzx +mov o0.w, r0.w +mad o0.xyz, v1.wwww, r1.xyzx, r0.xyzx +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_PSSkinnedVertexLighting[] = +{ + 68, 88, 66, 67, 168, 121, + 145, 162, 145, 142, 85, 167, + 84, 43, 205, 136, 70, 33, + 64, 152, 1, 0, 0, 0, + 232, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 12, 1, 0, 0, 76, 2, + 0, 0, 180, 2, 0, 0, + 65, 111, 110, 57, 212, 0, + 0, 0, 212, 0, 0, 0, + 0, 2, 255, 255, 160, 0, + 0, 0, 52, 0, 0, 0, + 1, 0, 40, 0, 0, 0, + 52, 0, 0, 0, 52, 0, + 1, 0, 36, 0, 0, 0, + 52, 0, 0, 0, 0, 0, + 0, 0, 13, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 4, 0, 0, 4, 1, 0, + 7, 128, 1, 0, 228, 176, + 0, 0, 255, 128, 0, 0, + 228, 128, 4, 0, 0, 4, + 2, 0, 7, 128, 0, 0, + 228, 160, 0, 0, 255, 128, + 1, 0, 228, 129, 4, 0, + 0, 4, 0, 0, 7, 128, + 1, 0, 255, 176, 2, 0, + 228, 128, 1, 0, 228, 128, + 1, 0, 0, 2, 0, 8, + 15, 128, 0, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 56, 1, 0, 0, + 64, 0, 0, 0, 78, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 98, 16, + 0, 3, 242, 16, 16, 0, + 1, 0, 0, 0, 98, 16, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 104, 0, + 0, 2, 2, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 114, 0, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 114, 32, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 96, 0, + 0, 0, 3, 0, 0, 0, + 8, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 80, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 15, 0, 0, 86, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_PSSkinnedVertexLightingNoFog.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_PSSkinnedVertexLightingNoFog.inc new file mode 100644 index 0000000000000000000000000000000000000000..a722008b0fba9cdbcad0e872291921752bd60a52 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_PSSkinnedVertexLightingNoFog.inc @@ -0,0 +1,160 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1 + dcl t2.xy + dcl_2d s0 + texld r0, t2, s0 + mul r0, r0, t0 + mad r0.xyz, t1, r0.w, r0 + mov oC0, r0 + +// approximately 4 instruction slots used (1 texture, 3 arithmetic) +ps_4_0 +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xyz +dcl_input_ps linear v2.xy +dcl_output o0.xyzw +dcl_temps 1 +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul r0.xyzw, r0.xyzw, v0.xyzw +mad o0.xyz, v1.xyzx, r0.wwww, r0.xyzx +mov o0.w, r0.w +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_PSSkinnedVertexLightingNoFog[] = +{ + 68, 88, 66, 67, 107, 144, + 128, 78, 118, 75, 88, 150, + 203, 179, 206, 252, 188, 119, + 149, 100, 1, 0, 0, 0, + 84, 2, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 216, 0, 0, 0, 184, 1, + 0, 0, 32, 2, 0, 0, + 65, 111, 110, 57, 160, 0, + 0, 0, 160, 0, 0, 0, + 0, 2, 255, 255, 120, 0, + 0, 0, 40, 0, 0, 0, + 0, 0, 40, 0, 0, 0, + 40, 0, 0, 0, 40, 0, + 1, 0, 36, 0, 0, 0, + 40, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 2, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 4, 0, 0, 4, 0, 0, + 7, 128, 1, 0, 228, 176, + 0, 0, 255, 128, 0, 0, + 228, 128, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0, + 83, 72, 68, 82, 216, 0, + 0, 0, 64, 0, 0, 0, + 54, 0, 0, 0, 90, 0, + 0, 3, 0, 96, 16, 0, + 0, 0, 0, 0, 88, 24, + 0, 4, 0, 112, 16, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 98, 16, 0, 3, + 242, 16, 16, 0, 0, 0, + 0, 0, 98, 16, 0, 3, + 114, 16, 16, 0, 1, 0, + 0, 0, 98, 16, 0, 3, + 50, 16, 16, 0, 2, 0, + 0, 0, 101, 0, 0, 3, + 242, 32, 16, 0, 0, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 114, 32, 16, 0, 0, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 96, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 80, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 7, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 79, 83, + 71, 78, 44, 0, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 84, + 97, 114, 103, 101, 116, 0, + 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightFourBones.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightFourBones.inc new file mode 100644 index 0000000000000000000000000000000000000000..7009b63dea8d70b75f2d8db53fac05c4d514dff9 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightFourBones.inc @@ -0,0 +1,766 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// BLENDINDICES 0 xyzw 3 NONE uint xyzw +// BLENDWEIGHT 0 xyzw 4 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 242 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c242 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c243, 3, 0, 1, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mul r0, v3, c243.x + mova a0, r0.yxzw + mul r1, v4.y, c26[a0.x] + mad r1, c26[a0.y], v4.x, r1 + mad r0, c26[a0.z], v4.z, r1 + mad r0, c26[a0.w], v4.w, r0 + dp3 r1.x, v1, r0 + dp4 r0.x, v0, r0 + mul r2, v4.y, c27[a0.x] + mul r3, v4.y, c28[a0.x] + mad r3, c28[a0.y], v4.x, r3 + mad r2, c27[a0.y], v4.x, r2 + mad r2, c27[a0.z], v4.z, r2 + mad r3, c28[a0.z], v4.z, r3 + mad r3, c28[a0.w], v4.w, r3 + mad r2, c27[a0.w], v4.w, r2 + dp3 r1.y, v1, r2 + dp4 r0.y, v0, r2 + dp3 r1.z, v1, r3 + dp4 r0.z, v0, r3 + dp3 r2.x, r1, c19 + dp3 r2.y, r1, c20 + dp3 r2.z, r1, c21 + nrm r1.xyz, r2 + dp3 r1.w, -c3, r1 + sge r2.x, r1.w, c243.y + mul r1.w, r1.w, r2.x + mul r2.yzw, r1.w, c6.xxyz + mov r3.xyz, c0 + mad oT0.xyz, r2.yzww, r3, c1 + mov r0.w, v0.w + dp4 r3.x, r0, c15 + dp4 r3.y, r0, c16 + dp4 r3.z, r0, c17 + add r2.yzw, -r3.xxyz, c12.xxyz + nrm r3.xyz, r2.yzww + add r2.yzw, r3.xxyz, -c3.xxyz + nrm r3.xyz, r2.yzww + dp3 r1.x, r3, r1 + max r1.x, r1.x, c243.y + mul r1.x, r2.x, r1.x + pow r2.x, r1.x, c2.w + mul r1.xyz, r2.x, c9 + mul oT1.xyz, r1, c2 + dp4 oPos.z, r0, c24 + dp4 r1.x, r0, c14 + max r1.x, r1.x, c243.y + min oT1.w, r1.x, c243.z + dp4 r1.x, r0, c22 + dp4 r1.y, r0, c23 + dp4 r0.x, r0, c25 + mad oPos.xy, r0.x, c242, r1 + mov oPos.w, r0.x + mov oT0.w, c0.w + mov oT2.xy, v2 + +// approximately 63 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[242], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xyzw +dcl_input v4.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 4 +imul null, r0.xyzw, v3.xyzw, l(3, 3, 3, 3) +mul r1.xyzw, v4.yyyy, cb0[r0.y + 26].xyzw +mad r1.xyzw, cb0[r0.x + 26].xyzw, v4.xxxx, r1.xyzw +mad r1.xyzw, cb0[r0.z + 26].xyzw, v4.zzzz, r1.xyzw +mad r1.xyzw, cb0[r0.w + 26].xyzw, v4.wwww, r1.xyzw +dp3 r2.x, v1.xyzx, r1.xyzx +dp4 r1.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v4.yyyy, cb0[r0.y + 27].xyzw +mad r3.xyzw, cb0[r0.x + 27].xyzw, v4.xxxx, r3.xyzw +mad r3.xyzw, cb0[r0.z + 27].xyzw, v4.zzzz, r3.xyzw +mad r3.xyzw, cb0[r0.w + 27].xyzw, v4.wwww, r3.xyzw +dp3 r2.y, v1.xyzx, r3.xyzx +dp4 r1.y, v0.xyzw, r3.xyzw +mul r3.xyzw, v4.yyyy, cb0[r0.y + 28].xyzw +mad r3.xyzw, cb0[r0.x + 28].xyzw, v4.xxxx, r3.xyzw +mad r3.xyzw, cb0[r0.z + 28].xyzw, v4.zzzz, r3.xyzw +mad r0.xyzw, cb0[r0.w + 28].xyzw, v4.wwww, r3.xyzw +dp3 r2.z, v1.xyzx, r0.xyzx +dp4 r1.z, v0.xyzw, r0.xyzw +dp3 r0.x, r2.xyzx, cb0[19].xyzx +dp3 r0.y, r2.xyzx, cb0[20].xyzx +dp3 r0.z, r2.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r0.w, -cb0[3].xyzx, r0.xyzx +ge r2.x, r0.w, l(0.000000) +and r2.x, r2.x, l(0x3f800000) +mul r0.w, r0.w, r2.x +mul r2.yzw, r0.wwww, cb0[6].xxyz +mad o0.xyz, r2.yzwy, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +mov r1.w, v0.w +dp4 r3.x, r1.xyzw, cb0[15].xyzw +dp4 r3.y, r1.xyzw, cb0[16].xyzw +dp4 r3.z, r1.xyzw, cb0[17].xyzw +add r2.yzw, -r3.xxyz, cb0[12].xxyz +dp3 r0.w, r2.yzwy, r2.yzwy +rsq r0.w, r0.w +mad r2.yzw, r2.yyzw, r0.wwww, -cb0[3].xxyz +dp3 r0.w, r2.yzwy, r2.yzwy +rsq r0.w, r0.w +mul r2.yzw, r0.wwww, r2.yyzw +dp3 r0.x, r2.yzwy, r0.xyzx +max r0.x, r0.x, l(0.000000) +mul r0.x, r2.x, r0.x +log r0.x, r0.x +mul r0.x, r0.x, cb0[2].w +exp r0.x, r0.x +mul r0.xyz, r0.xxxx, cb0[9].xyzx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, r1.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, r1.xyzw, cb0[22].xyzw +dp4 o3.y, r1.xyzw, cb0[23].xyzw +dp4 o3.z, r1.xyzw, cb0[24].xyzw +dp4 o3.w, r1.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_VSSkinnedOneLightFourBones[] = +{ + 68, 88, 66, 67, 63, 163, + 154, 32, 18, 207, 16, 79, + 179, 141, 167, 248, 204, 90, + 92, 25, 1, 0, 0, 0, + 172, 13, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 112, 4, 0, 0, 96, 12, + 0, 0, 32, 13, 0, 0, + 65, 111, 110, 57, 56, 4, + 0, 0, 56, 4, 0, 0, + 0, 2, 254, 255, 4, 4, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 242, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 243, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 15, 128, + 3, 0, 228, 144, 243, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 15, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 4, 0, + 85, 144, 26, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 1, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 170, 176, 4, 0, 170, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 255, 176, 4, 0, 255, 144, + 0, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 1, 128, + 1, 0, 228, 144, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 5, 0, 0, 4, 2, 0, + 15, 128, 4, 0, 85, 144, + 27, 32, 228, 160, 0, 0, + 0, 176, 5, 0, 0, 4, + 3, 0, 15, 128, 4, 0, + 85, 144, 28, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 2, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 170, 176, 4, 0, 170, 144, + 2, 0, 228, 128, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 170, 176, 4, 0, 170, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 255, 176, 4, 0, 255, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 255, 176, 4, 0, 255, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 2, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 2, 0, 228, 128, + 8, 0, 0, 3, 1, 0, + 4, 128, 1, 0, 228, 144, + 3, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 3, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 1, 128, 1, 0, + 228, 128, 19, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 2, 128, 1, 0, 228, 128, + 20, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 4, 128, + 1, 0, 228, 128, 21, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 128, 8, 0, 0, 3, + 1, 0, 8, 128, 3, 0, + 228, 161, 1, 0, 228, 128, + 13, 0, 0, 3, 2, 0, + 1, 128, 1, 0, 255, 128, + 243, 0, 85, 160, 5, 0, + 0, 3, 1, 0, 8, 128, + 1, 0, 255, 128, 2, 0, + 0, 128, 5, 0, 0, 3, + 2, 0, 14, 128, 1, 0, + 255, 128, 6, 0, 144, 160, + 1, 0, 0, 2, 3, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 224, 2, 0, 249, 128, + 3, 0, 228, 128, 1, 0, + 228, 160, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 3, 0, 1, 128, 0, 0, + 228, 128, 15, 0, 228, 160, + 9, 0, 0, 3, 3, 0, + 2, 128, 0, 0, 228, 128, + 16, 0, 228, 160, 9, 0, + 0, 3, 3, 0, 4, 128, + 0, 0, 228, 128, 17, 0, + 228, 160, 2, 0, 0, 3, + 2, 0, 14, 128, 3, 0, + 144, 129, 12, 0, 144, 160, + 36, 0, 0, 2, 3, 0, + 7, 128, 2, 0, 249, 128, + 2, 0, 0, 3, 2, 0, + 14, 128, 3, 0, 144, 128, + 3, 0, 144, 161, 36, 0, + 0, 2, 3, 0, 7, 128, + 2, 0, 249, 128, 8, 0, + 0, 3, 1, 0, 1, 128, + 3, 0, 228, 128, 1, 0, + 228, 128, 11, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 0, 128, 243, 0, 85, 160, + 5, 0, 0, 3, 1, 0, + 1, 128, 2, 0, 0, 128, + 1, 0, 0, 128, 32, 0, + 0, 3, 2, 0, 1, 128, + 1, 0, 0, 128, 2, 0, + 255, 160, 5, 0, 0, 3, + 1, 0, 7, 128, 2, 0, + 0, 128, 9, 0, 228, 160, + 5, 0, 0, 3, 1, 0, + 7, 224, 1, 0, 228, 128, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 128, 24, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 1, 128, 0, 0, + 228, 128, 14, 0, 228, 160, + 11, 0, 0, 3, 1, 0, + 1, 128, 1, 0, 0, 128, + 243, 0, 85, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 1, 0, 0, 128, 243, 0, + 170, 160, 9, 0, 0, 3, + 1, 0, 1, 128, 0, 0, + 228, 128, 22, 0, 228, 160, + 9, 0, 0, 3, 1, 0, + 2, 128, 0, 0, 228, 128, + 23, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 128, 25, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 0, 128, 242, 0, 228, 160, + 1, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 0, 128, 1, 0, + 0, 2, 0, 0, 8, 224, + 0, 0, 255, 160, 1, 0, + 0, 2, 2, 0, 3, 224, + 2, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 232, 7, 0, 0, 64, 0, + 1, 0, 250, 1, 0, 0, + 89, 8, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 3, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 4, 0, 0, 0, 38, 0, + 0, 11, 0, 208, 0, 0, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 30, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 1, 0, 0, 0, + 86, 21, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 26, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 26, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 26, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 166, 26, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 26, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 86, 21, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 27, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 27, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 27, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 166, 26, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 27, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 17, 0, 0, 7, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 86, 21, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 28, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 28, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 28, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 166, 26, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 28, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 246, 31, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 7, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 19, 0, + 0, 0, 16, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 16, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 21, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 29, 0, + 0, 7, 18, 0, 16, 0, + 2, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 8, 226, 0, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 50, 0, 0, 11, 114, 32, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 16, 16, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 18, 0, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 17, 0, 0, 8, 34, 0, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 16, 0, + 0, 0, 17, 0, 0, 8, + 66, 0, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 0, 0, + 0, 9, 226, 0, 16, 0, + 2, 0, 0, 0, 6, 9, + 16, 128, 65, 0, 0, 0, + 3, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 226, 0, 16, 0, + 2, 0, 0, 0, 86, 14, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 6, 137, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 150, 7, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 226, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 52, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 47, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 56, 0, 0, 8, 114, 32, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 54, 0, + 0, 5, 50, 32, 16, 0, + 2, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 184, 0, + 0, 0, 5, 0, 0, 0, + 8, 0, 0, 0, 128, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 140, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 147, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 156, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 15, 15, 0, 0, 169, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 15, 15, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 66, 76, 69, 78, + 68, 73, 78, 68, 73, 67, + 69, 83, 0, 66, 76, 69, + 78, 68, 87, 69, 73, 71, + 72, 84, 0, 171, 171, 171, + 79, 83, 71, 78, 132, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 110, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 119, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightOneBone.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightOneBone.inc new file mode 100644 index 0000000000000000000000000000000000000000..2e7e63714197ded6d347169aa24111c3316f87ab --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightOneBone.inc @@ -0,0 +1,638 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// BLENDINDICES 0 xyzw 3 NONE uint x +// BLENDWEIGHT 0 xyzw 4 NONE float x +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 242 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c242 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c243, 3, 0, 1, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mul r0.x, v3.x, c243.x + mova a0.x, r0.x + mul r0, v4.x, c26[a0.x] + dp3 r1.x, v1, r0 + dp4 r0.x, v0, r0 + mul r2, v4.x, c27[a0.x] + mul r3, v4.x, c28[a0.x] + dp3 r1.y, v1, r2 + dp4 r0.y, v0, r2 + dp3 r1.z, v1, r3 + dp4 r0.z, v0, r3 + dp3 r2.x, r1, c19 + dp3 r2.y, r1, c20 + dp3 r2.z, r1, c21 + nrm r1.xyz, r2 + dp3 r1.w, -c3, r1 + sge r2.x, r1.w, c243.y + mul r1.w, r1.w, r2.x + mul r2.yzw, r1.w, c6.xxyz + mov r3.xyz, c0 + mad oT0.xyz, r2.yzww, r3, c1 + mov r0.w, v0.w + dp4 r3.x, r0, c15 + dp4 r3.y, r0, c16 + dp4 r3.z, r0, c17 + add r2.yzw, -r3.xxyz, c12.xxyz + nrm r3.xyz, r2.yzww + add r2.yzw, r3.xxyz, -c3.xxyz + nrm r3.xyz, r2.yzww + dp3 r1.x, r3, r1 + max r1.x, r1.x, c243.y + mul r1.x, r2.x, r1.x + pow r2.x, r1.x, c2.w + mul r1.xyz, r2.x, c9 + mul oT1.xyz, r1, c2 + dp4 oPos.z, r0, c24 + dp4 r1.x, r0, c14 + max r1.x, r1.x, c243.y + min oT1.w, r1.x, c243.z + dp4 r1.x, r0, c22 + dp4 r1.y, r0, c23 + dp4 r0.x, r0, c25 + mad oPos.xy, r0.x, c242, r1 + mov oPos.w, r0.x + mov oT0.w, c0.w + mov oT2.xy, v2 + +// approximately 54 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[242], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.x +dcl_input v4.x +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 4 +imul null, r0.x, v3.x, l(3) +mul r1.xyzw, v4.xxxx, cb0[r0.x + 26].xyzw +dp3 r2.x, v1.xyzx, r1.xyzx +dp4 r1.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v4.xxxx, cb0[r0.x + 27].xyzw +mul r0.xyzw, v4.xxxx, cb0[r0.x + 28].xyzw +dp3 r2.y, v1.xyzx, r3.xyzx +dp4 r1.y, v0.xyzw, r3.xyzw +dp3 r2.z, v1.xyzx, r0.xyzx +dp4 r1.z, v0.xyzw, r0.xyzw +dp3 r0.x, r2.xyzx, cb0[19].xyzx +dp3 r0.y, r2.xyzx, cb0[20].xyzx +dp3 r0.z, r2.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r0.w, -cb0[3].xyzx, r0.xyzx +ge r2.x, r0.w, l(0.000000) +and r2.x, r2.x, l(0x3f800000) +mul r0.w, r0.w, r2.x +mul r2.yzw, r0.wwww, cb0[6].xxyz +mad o0.xyz, r2.yzwy, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +mov r1.w, v0.w +dp4 r3.x, r1.xyzw, cb0[15].xyzw +dp4 r3.y, r1.xyzw, cb0[16].xyzw +dp4 r3.z, r1.xyzw, cb0[17].xyzw +add r2.yzw, -r3.xxyz, cb0[12].xxyz +dp3 r0.w, r2.yzwy, r2.yzwy +rsq r0.w, r0.w +mad r2.yzw, r2.yyzw, r0.wwww, -cb0[3].xxyz +dp3 r0.w, r2.yzwy, r2.yzwy +rsq r0.w, r0.w +mul r2.yzw, r0.wwww, r2.yyzw +dp3 r0.x, r2.yzwy, r0.xyzx +max r0.x, r0.x, l(0.000000) +mul r0.x, r2.x, r0.x +log r0.x, r0.x +mul r0.x, r0.x, cb0[2].w +exp r0.x, r0.x +mul r0.xyz, r0.xxxx, cb0[9].xyzx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, r1.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, r1.xyzw, cb0[22].xyzw +dp4 o3.y, r1.xyzw, cb0[23].xyzw +dp4 o3.z, r1.xyzw, cb0[24].xyzw +dp4 o3.w, r1.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_VSSkinnedOneLightOneBone[] = +{ + 68, 88, 66, 67, 245, 19, + 153, 62, 142, 216, 232, 222, + 208, 186, 205, 184, 189, 51, + 85, 159, 1, 0, 0, 0, + 24, 11, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 152, 3, 0, 0, 204, 9, + 0, 0, 140, 10, 0, 0, + 65, 111, 110, 57, 96, 3, + 0, 0, 96, 3, 0, 0, + 0, 2, 254, 255, 44, 3, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 242, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 243, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 1, 128, + 3, 0, 0, 144, 243, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 1, 176, 0, 0, + 0, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 4, 0, + 0, 144, 26, 32, 228, 160, + 0, 0, 0, 176, 8, 0, + 0, 3, 1, 0, 1, 128, + 1, 0, 228, 144, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 5, 0, 0, 4, 2, 0, + 15, 128, 4, 0, 0, 144, + 27, 32, 228, 160, 0, 0, + 0, 176, 5, 0, 0, 4, + 3, 0, 15, 128, 4, 0, + 0, 144, 28, 32, 228, 160, + 0, 0, 0, 176, 8, 0, + 0, 3, 1, 0, 2, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 2, 0, 228, 128, + 8, 0, 0, 3, 1, 0, + 4, 128, 1, 0, 228, 144, + 3, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 3, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 1, 128, 1, 0, + 228, 128, 19, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 2, 128, 1, 0, 228, 128, + 20, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 4, 128, + 1, 0, 228, 128, 21, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 128, 8, 0, 0, 3, + 1, 0, 8, 128, 3, 0, + 228, 161, 1, 0, 228, 128, + 13, 0, 0, 3, 2, 0, + 1, 128, 1, 0, 255, 128, + 243, 0, 85, 160, 5, 0, + 0, 3, 1, 0, 8, 128, + 1, 0, 255, 128, 2, 0, + 0, 128, 5, 0, 0, 3, + 2, 0, 14, 128, 1, 0, + 255, 128, 6, 0, 144, 160, + 1, 0, 0, 2, 3, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 224, 2, 0, 249, 128, + 3, 0, 228, 128, 1, 0, + 228, 160, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 3, 0, 1, 128, 0, 0, + 228, 128, 15, 0, 228, 160, + 9, 0, 0, 3, 3, 0, + 2, 128, 0, 0, 228, 128, + 16, 0, 228, 160, 9, 0, + 0, 3, 3, 0, 4, 128, + 0, 0, 228, 128, 17, 0, + 228, 160, 2, 0, 0, 3, + 2, 0, 14, 128, 3, 0, + 144, 129, 12, 0, 144, 160, + 36, 0, 0, 2, 3, 0, + 7, 128, 2, 0, 249, 128, + 2, 0, 0, 3, 2, 0, + 14, 128, 3, 0, 144, 128, + 3, 0, 144, 161, 36, 0, + 0, 2, 3, 0, 7, 128, + 2, 0, 249, 128, 8, 0, + 0, 3, 1, 0, 1, 128, + 3, 0, 228, 128, 1, 0, + 228, 128, 11, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 0, 128, 243, 0, 85, 160, + 5, 0, 0, 3, 1, 0, + 1, 128, 2, 0, 0, 128, + 1, 0, 0, 128, 32, 0, + 0, 3, 2, 0, 1, 128, + 1, 0, 0, 128, 2, 0, + 255, 160, 5, 0, 0, 3, + 1, 0, 7, 128, 2, 0, + 0, 128, 9, 0, 228, 160, + 5, 0, 0, 3, 1, 0, + 7, 224, 1, 0, 228, 128, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 128, 24, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 1, 128, 0, 0, + 228, 128, 14, 0, 228, 160, + 11, 0, 0, 3, 1, 0, + 1, 128, 1, 0, 0, 128, + 243, 0, 85, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 1, 0, 0, 128, 243, 0, + 170, 160, 9, 0, 0, 3, + 1, 0, 1, 128, 0, 0, + 228, 128, 22, 0, 228, 160, + 9, 0, 0, 3, 1, 0, + 2, 128, 0, 0, 228, 128, + 23, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 128, 25, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 0, 128, 242, 0, 228, 160, + 1, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 0, 128, 1, 0, + 0, 2, 0, 0, 8, 224, + 0, 0, 255, 160, 1, 0, + 0, 2, 2, 0, 3, 224, + 2, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 44, 6, 0, 0, 64, 0, + 1, 0, 139, 1, 0, 0, + 89, 8, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 18, 16, 16, 0, + 3, 0, 0, 0, 95, 0, + 0, 3, 18, 16, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 4, 0, 0, 0, 38, 0, + 0, 8, 0, 208, 0, 0, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 16, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 3, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 1, 0, 0, 0, + 6, 16, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 26, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 6, 16, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 27, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 28, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 7, + 34, 0, 16, 0, 2, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 17, 0, 0, 7, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 7, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 19, 0, + 0, 0, 16, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 16, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 21, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 29, 0, + 0, 7, 18, 0, 16, 0, + 2, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 8, 226, 0, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 50, 0, 0, 11, 114, 32, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 16, 16, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 18, 0, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 17, 0, 0, 8, 34, 0, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 16, 0, + 0, 0, 17, 0, 0, 8, + 66, 0, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 0, 0, + 0, 9, 226, 0, 16, 0, + 2, 0, 0, 0, 6, 9, + 16, 128, 65, 0, 0, 0, + 3, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 226, 0, 16, 0, + 2, 0, 0, 0, 86, 14, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 6, 137, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 150, 7, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 226, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 52, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 47, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 56, 0, 0, 8, 114, 32, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 54, 0, + 0, 5, 50, 32, 16, 0, + 2, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 184, 0, + 0, 0, 5, 0, 0, 0, + 8, 0, 0, 0, 128, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 140, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 147, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 156, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 15, 1, 0, 0, 169, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 15, 1, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 66, 76, 69, 78, + 68, 73, 78, 68, 73, 67, + 69, 83, 0, 66, 76, 69, + 78, 68, 87, 69, 73, 71, + 72, 84, 0, 171, 171, 171, + 79, 83, 71, 78, 132, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 110, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 119, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightTwoBones.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightTwoBones.inc new file mode 100644 index 0000000000000000000000000000000000000000..9652cf93bd12bd171c4b0174632d283a09b6d3b6 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightTwoBones.inc @@ -0,0 +1,682 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// BLENDINDICES 0 xyzw 3 NONE uint xy +// BLENDWEIGHT 0 xyzw 4 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 242 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c242 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c243, 3, 0, 1, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mul r0.xy, v3, c243.x + mova a0.xy, r0.yxzw + mul r0, v4.y, c26[a0.x] + mad r0, c26[a0.y], v4.x, r0 + dp3 r1.x, v1, r0 + dp4 r0.x, v0, r0 + mul r2, v4.y, c27[a0.x] + mul r3, v4.y, c28[a0.x] + mad r3, c28[a0.y], v4.x, r3 + mad r2, c27[a0.y], v4.x, r2 + dp3 r1.y, v1, r2 + dp4 r0.y, v0, r2 + dp3 r1.z, v1, r3 + dp4 r0.z, v0, r3 + dp3 r2.x, r1, c19 + dp3 r2.y, r1, c20 + dp3 r2.z, r1, c21 + nrm r1.xyz, r2 + dp3 r1.w, -c3, r1 + sge r2.x, r1.w, c243.y + mul r1.w, r1.w, r2.x + mul r2.yzw, r1.w, c6.xxyz + mov r3.xyz, c0 + mad oT0.xyz, r2.yzww, r3, c1 + mov r0.w, v0.w + dp4 r3.x, r0, c15 + dp4 r3.y, r0, c16 + dp4 r3.z, r0, c17 + add r2.yzw, -r3.xxyz, c12.xxyz + nrm r3.xyz, r2.yzww + add r2.yzw, r3.xxyz, -c3.xxyz + nrm r3.xyz, r2.yzww + dp3 r1.x, r3, r1 + max r1.x, r1.x, c243.y + mul r1.x, r2.x, r1.x + pow r2.x, r1.x, c2.w + mul r1.xyz, r2.x, c9 + mul oT1.xyz, r1, c2 + dp4 oPos.z, r0, c24 + dp4 r1.x, r0, c14 + max r1.x, r1.x, c243.y + min oT1.w, r1.x, c243.z + dp4 r1.x, r0, c22 + dp4 r1.y, r0, c23 + dp4 r0.x, r0, c25 + mad oPos.xy, r0.x, c242, r1 + mov oPos.w, r0.x + mov oT0.w, c0.w + mov oT2.xy, v2 + +// approximately 57 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[242], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xy +dcl_input v4.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 4 +imul null, r0.xy, v3.xyxx, l(3, 3, 0, 0) +mul r1.xyzw, v4.yyyy, cb0[r0.y + 26].xyzw +mad r1.xyzw, cb0[r0.x + 26].xyzw, v4.xxxx, r1.xyzw +dp3 r2.x, v1.xyzx, r1.xyzx +dp4 r1.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v4.yyyy, cb0[r0.y + 27].xyzw +mad r3.xyzw, cb0[r0.x + 27].xyzw, v4.xxxx, r3.xyzw +dp3 r2.y, v1.xyzx, r3.xyzx +dp4 r1.y, v0.xyzw, r3.xyzw +mul r3.xyzw, v4.yyyy, cb0[r0.y + 28].xyzw +mad r0.xyzw, cb0[r0.x + 28].xyzw, v4.xxxx, r3.xyzw +dp3 r2.z, v1.xyzx, r0.xyzx +dp4 r1.z, v0.xyzw, r0.xyzw +dp3 r0.x, r2.xyzx, cb0[19].xyzx +dp3 r0.y, r2.xyzx, cb0[20].xyzx +dp3 r0.z, r2.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r0.w, -cb0[3].xyzx, r0.xyzx +ge r2.x, r0.w, l(0.000000) +and r2.x, r2.x, l(0x3f800000) +mul r0.w, r0.w, r2.x +mul r2.yzw, r0.wwww, cb0[6].xxyz +mad o0.xyz, r2.yzwy, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +mov r1.w, v0.w +dp4 r3.x, r1.xyzw, cb0[15].xyzw +dp4 r3.y, r1.xyzw, cb0[16].xyzw +dp4 r3.z, r1.xyzw, cb0[17].xyzw +add r2.yzw, -r3.xxyz, cb0[12].xxyz +dp3 r0.w, r2.yzwy, r2.yzwy +rsq r0.w, r0.w +mad r2.yzw, r2.yyzw, r0.wwww, -cb0[3].xxyz +dp3 r0.w, r2.yzwy, r2.yzwy +rsq r0.w, r0.w +mul r2.yzw, r0.wwww, r2.yyzw +dp3 r0.x, r2.yzwy, r0.xyzx +max r0.x, r0.x, l(0.000000) +mul r0.x, r2.x, r0.x +log r0.x, r0.x +mul r0.x, r0.x, cb0[2].w +exp r0.x, r0.x +mul r0.xyz, r0.xxxx, cb0[9].xyzx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, r1.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, r1.xyzw, cb0[22].xyzw +dp4 o3.y, r1.xyzw, cb0[23].xyzw +dp4 o3.z, r1.xyzw, cb0[24].xyzw +dp4 o3.w, r1.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_VSSkinnedOneLightTwoBones[] = +{ + 68, 88, 66, 67, 116, 238, + 17, 228, 239, 21, 135, 196, + 157, 218, 29, 152, 151, 204, + 151, 178, 1, 0, 0, 0, + 252, 11, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 224, 3, 0, 0, 176, 10, + 0, 0, 112, 11, 0, 0, + 65, 111, 110, 57, 168, 3, + 0, 0, 168, 3, 0, 0, + 0, 2, 254, 255, 116, 3, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 242, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 243, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 3, 128, + 3, 0, 228, 144, 243, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 3, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 4, 0, + 85, 144, 26, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 0, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 0, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 1, 128, + 1, 0, 228, 144, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 5, 0, 0, 4, 2, 0, + 15, 128, 4, 0, 85, 144, + 27, 32, 228, 160, 0, 0, + 0, 176, 5, 0, 0, 4, + 3, 0, 15, 128, 4, 0, + 85, 144, 28, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 2, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 2, 0, 228, 128, + 8, 0, 0, 3, 1, 0, + 4, 128, 1, 0, 228, 144, + 3, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 3, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 1, 128, 1, 0, + 228, 128, 19, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 2, 128, 1, 0, 228, 128, + 20, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 4, 128, + 1, 0, 228, 128, 21, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 128, 8, 0, 0, 3, + 1, 0, 8, 128, 3, 0, + 228, 161, 1, 0, 228, 128, + 13, 0, 0, 3, 2, 0, + 1, 128, 1, 0, 255, 128, + 243, 0, 85, 160, 5, 0, + 0, 3, 1, 0, 8, 128, + 1, 0, 255, 128, 2, 0, + 0, 128, 5, 0, 0, 3, + 2, 0, 14, 128, 1, 0, + 255, 128, 6, 0, 144, 160, + 1, 0, 0, 2, 3, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 224, 2, 0, 249, 128, + 3, 0, 228, 128, 1, 0, + 228, 160, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 3, 0, 1, 128, 0, 0, + 228, 128, 15, 0, 228, 160, + 9, 0, 0, 3, 3, 0, + 2, 128, 0, 0, 228, 128, + 16, 0, 228, 160, 9, 0, + 0, 3, 3, 0, 4, 128, + 0, 0, 228, 128, 17, 0, + 228, 160, 2, 0, 0, 3, + 2, 0, 14, 128, 3, 0, + 144, 129, 12, 0, 144, 160, + 36, 0, 0, 2, 3, 0, + 7, 128, 2, 0, 249, 128, + 2, 0, 0, 3, 2, 0, + 14, 128, 3, 0, 144, 128, + 3, 0, 144, 161, 36, 0, + 0, 2, 3, 0, 7, 128, + 2, 0, 249, 128, 8, 0, + 0, 3, 1, 0, 1, 128, + 3, 0, 228, 128, 1, 0, + 228, 128, 11, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 0, 128, 243, 0, 85, 160, + 5, 0, 0, 3, 1, 0, + 1, 128, 2, 0, 0, 128, + 1, 0, 0, 128, 32, 0, + 0, 3, 2, 0, 1, 128, + 1, 0, 0, 128, 2, 0, + 255, 160, 5, 0, 0, 3, + 1, 0, 7, 128, 2, 0, + 0, 128, 9, 0, 228, 160, + 5, 0, 0, 3, 1, 0, + 7, 224, 1, 0, 228, 128, + 2, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 192, + 0, 0, 228, 128, 24, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 1, 128, 0, 0, + 228, 128, 14, 0, 228, 160, + 11, 0, 0, 3, 1, 0, + 1, 128, 1, 0, 0, 128, + 243, 0, 85, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 1, 0, 0, 128, 243, 0, + 170, 160, 9, 0, 0, 3, + 1, 0, 1, 128, 0, 0, + 228, 128, 22, 0, 228, 160, + 9, 0, 0, 3, 1, 0, + 2, 128, 0, 0, 228, 128, + 23, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 1, 128, + 0, 0, 228, 128, 25, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 0, 128, 242, 0, 228, 160, + 1, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 0, 128, 1, 0, + 0, 2, 0, 0, 8, 224, + 0, 0, 255, 160, 1, 0, + 0, 2, 2, 0, 3, 224, + 2, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 200, 6, 0, 0, 64, 0, + 1, 0, 178, 1, 0, 0, + 89, 8, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 114, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 2, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 3, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 4, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 2, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 4, 0, 0, 0, 38, 0, + 0, 11, 0, 208, 0, 0, + 50, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 1, 0, 0, 0, + 86, 21, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 26, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 26, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 7, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 86, 21, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 27, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 27, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 17, 0, 0, 7, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 86, 21, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 28, 0, + 0, 0, 26, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 28, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 7, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 19, 0, + 0, 0, 16, 0, 0, 8, + 34, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 16, 0, + 0, 8, 66, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 21, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 29, 0, + 0, 7, 18, 0, 16, 0, + 2, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 56, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 8, 226, 0, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 6, 137, 32, 0, 0, 0, + 0, 0, 6, 0, 0, 0, + 50, 0, 0, 11, 114, 32, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 54, 0, 0, 6, + 130, 32, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 130, 0, 16, 0, 1, 0, + 0, 0, 58, 16, 16, 0, + 0, 0, 0, 0, 17, 0, + 0, 8, 18, 0, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 17, 0, 0, 8, 34, 0, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 16, 0, + 0, 0, 17, 0, 0, 8, + 66, 0, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 0, 0, + 0, 9, 226, 0, 16, 0, + 2, 0, 0, 0, 6, 9, + 16, 128, 65, 0, 0, 0, + 3, 0, 0, 0, 6, 137, + 32, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 11, 226, 0, 16, 0, + 2, 0, 0, 0, 86, 14, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 6, 137, 32, 128, + 65, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 150, 7, 16, 0, 2, 0, + 0, 0, 150, 7, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 226, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 86, 14, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 18, 0, 16, 0, + 0, 0, 0, 0, 150, 7, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 52, 0, 0, 7, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 2, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 47, 0, + 0, 5, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 0, 0, 0, 0, 6, 0, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 9, 0, 0, 0, + 56, 0, 0, 8, 114, 32, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 17, 32, 0, 8, + 130, 32, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 54, 0, + 0, 5, 50, 32, 16, 0, + 2, 0, 0, 0, 70, 16, + 16, 0, 2, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 22, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 23, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 24, 0, 0, 0, + 17, 0, 0, 8, 130, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 25, 0, + 0, 0, 62, 0, 0, 1, + 73, 83, 71, 78, 184, 0, + 0, 0, 5, 0, 0, 0, + 8, 0, 0, 0, 128, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 140, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 7, 0, 0, 147, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 156, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 15, 3, 0, 0, 169, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 15, 3, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 78, 79, + 82, 77, 65, 76, 0, 84, + 69, 88, 67, 79, 79, 82, + 68, 0, 66, 76, 69, 78, + 68, 73, 78, 68, 73, 67, + 69, 83, 0, 66, 76, 69, + 78, 68, 87, 69, 73, 71, + 72, 84, 0, 171, 171, 171, + 79, 83, 71, 78, 132, 0, + 0, 0, 4, 0, 0, 0, + 8, 0, 0, 0, 104, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 104, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 15, 0, 0, 0, 110, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 12, 0, 0, 119, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 15, 0, 0, 0, 67, 79, + 76, 79, 82, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 83, 86, 95, 80, 111, + 115, 105, 116, 105, 111, 110, + 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingFourBones.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingFourBones.inc new file mode 100644 index 0000000000000000000000000000000000000000..573d8941c888c65b751f54e8fb9971a72a179875 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingFourBones.inc @@ -0,0 +1,610 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// BLENDINDICES 0 xyzw 3 NONE uint xyzw +// BLENDWEIGHT 0 xyzw 4 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xy 0 NONE float xy +// TEXCOORD 1 xyzw 1 NONE float xyzw +// TEXCOORD 2 xyz 2 NONE float xyz +// COLOR 0 xyzw 3 NONE float xyzw +// SV_Position 0 xyzw 4 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 242 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c242 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c243, 3, 0, 1, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mul r0, v3, c243.x + mova a0, r0.yxzw + mul r1, v4.y, c26[a0.x] + mad r1, c26[a0.y], v4.x, r1 + mad r0, c26[a0.z], v4.z, r1 + mad r0, c26[a0.w], v4.w, r0 + dp4 r1.x, v0, r0 + dp3 r0.x, v1, r0 + mul r2, v4.y, c27[a0.x] + mul r3, v4.y, c28[a0.x] + mad r3, c28[a0.y], v4.x, r3 + mad r2, c27[a0.y], v4.x, r2 + mad r2, c27[a0.z], v4.z, r2 + mad r3, c28[a0.z], v4.z, r3 + mad r3, c28[a0.w], v4.w, r3 + mad r2, c27[a0.w], v4.w, r2 + dp4 r1.y, v0, r2 + dp3 r0.y, v1, r2 + dp4 r1.z, v0, r3 + dp3 r0.z, v1, r3 + mov r1.w, v0.w + dp4 oPos.z, r1, c24 + dp4 oT1.x, r1, c15 + dp4 oT1.y, r1, c16 + dp4 oT1.z, r1, c17 + dp3 r2.x, r0, c19 + dp3 r2.y, r0, c20 + dp3 r2.z, r0, c21 + dp3 r0.x, r2, r2 + rsq r0.x, r0.x + mul oT2.xyz, r0.x, r2 + dp4 r0.x, r1, c14 + max r0.x, r0.x, c243.y + min oT1.w, r0.x, c243.z + dp4 r0.x, r1, c22 + dp4 r0.y, r1, c23 + dp4 r0.z, r1, c25 + mad oPos.xy, r0.z, c242, r0 + mov oPos.w, r0.z + mov oT0.xy, v2 + mov r0.yz, c243 + mad oT3, c0.w, r0.yyyz, r0.zzzy + +// approximately 42 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[242], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xyzw +dcl_input v4.xyzw +dcl_output o0.xy +dcl_output o1.xyzw +dcl_output o2.xyz +dcl_output o3.xyzw +dcl_output_siv o4.xyzw, position +dcl_temps 4 +mov o0.xy, v2.xyxx +imul null, r0.xyzw, v3.xyzw, l(3, 3, 3, 3) +mul r1.xyzw, v4.yyyy, cb0[r0.y + 26].xyzw +mad r1.xyzw, cb0[r0.x + 26].xyzw, v4.xxxx, r1.xyzw +mad r1.xyzw, cb0[r0.z + 26].xyzw, v4.zzzz, r1.xyzw +mad r1.xyzw, cb0[r0.w + 26].xyzw, v4.wwww, r1.xyzw +dp4 r2.x, v0.xyzw, r1.xyzw +dp3 r1.x, v1.xyzx, r1.xyzx +mul r3.xyzw, v4.yyyy, cb0[r0.y + 27].xyzw +mad r3.xyzw, cb0[r0.x + 27].xyzw, v4.xxxx, r3.xyzw +mad r3.xyzw, cb0[r0.z + 27].xyzw, v4.zzzz, r3.xyzw +mad r3.xyzw, cb0[r0.w + 27].xyzw, v4.wwww, r3.xyzw +dp4 r2.y, v0.xyzw, r3.xyzw +dp3 r1.y, v1.xyzx, r3.xyzx +mul r3.xyzw, v4.yyyy, cb0[r0.y + 28].xyzw +mad r3.xyzw, cb0[r0.x + 28].xyzw, v4.xxxx, r3.xyzw +mad r3.xyzw, cb0[r0.z + 28].xyzw, v4.zzzz, r3.xyzw +mad r0.xyzw, cb0[r0.w + 28].xyzw, v4.wwww, r3.xyzw +dp4 r2.z, v0.xyzw, r0.xyzw +dp3 r1.z, v1.xyzx, r0.xyzx +mov r2.w, v0.w +dp4 o1.x, r2.xyzw, cb0[15].xyzw +dp4 o1.y, r2.xyzw, cb0[16].xyzw +dp4 o1.z, r2.xyzw, cb0[17].xyzw +dp4_sat o1.w, r2.xyzw, cb0[14].xyzw +dp3 r0.x, r1.xyzx, cb0[19].xyzx +dp3 r0.y, r1.xyzx, cb0[20].xyzx +dp3 r0.z, r1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul o2.xyz, r0.wwww, r0.xyzx +mov o3.xyz, l(1.000000,1.000000,1.000000,0) +mov o3.w, cb0[0].w +dp4 o4.x, r2.xyzw, cb0[22].xyzw +dp4 o4.y, r2.xyzw, cb0[23].xyzw +dp4 o4.z, r2.xyzw, cb0[24].xyzw +dp4 o4.w, r2.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_VSSkinnedPixelLightingFourBones[] = +{ + 68, 88, 66, 67, 233, 44, + 158, 107, 210, 54, 99, 13, + 195, 145, 49, 151, 59, 119, + 254, 187, 1, 0, 0, 0, + 192, 10, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 172, 3, 0, 0, 92, 9, + 0, 0, 28, 10, 0, 0, + 65, 111, 110, 57, 116, 3, + 0, 0, 116, 3, 0, 0, + 0, 2, 254, 255, 64, 3, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 242, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 243, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 15, 128, + 3, 0, 228, 144, 243, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 15, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 4, 0, + 85, 144, 26, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 1, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 170, 176, 4, 0, 170, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 255, 176, 4, 0, 255, 144, + 0, 0, 228, 128, 9, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 228, 144, 0, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 144, 0, 0, 228, 128, + 5, 0, 0, 4, 2, 0, + 15, 128, 4, 0, 85, 144, + 27, 32, 228, 160, 0, 0, + 0, 176, 5, 0, 0, 4, + 3, 0, 15, 128, 4, 0, + 85, 144, 28, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 2, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 170, 176, 4, 0, 170, 144, + 2, 0, 228, 128, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 170, 176, 4, 0, 170, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 255, 176, 4, 0, 255, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 255, 176, 4, 0, 255, 144, + 2, 0, 228, 128, 9, 0, + 0, 3, 1, 0, 2, 128, + 0, 0, 228, 144, 2, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 2, 0, 228, 128, + 9, 0, 0, 3, 1, 0, + 4, 128, 0, 0, 228, 144, + 3, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 3, 0, + 228, 128, 1, 0, 0, 2, + 1, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 0, 0, 4, 192, 1, 0, + 228, 128, 24, 0, 228, 160, + 9, 0, 0, 3, 1, 0, + 1, 224, 1, 0, 228, 128, + 15, 0, 228, 160, 9, 0, + 0, 3, 1, 0, 2, 224, + 1, 0, 228, 128, 16, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 4, 224, 1, 0, + 228, 128, 17, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 1, 128, 0, 0, 228, 128, + 19, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 2, 128, + 0, 0, 228, 128, 20, 0, + 228, 160, 8, 0, 0, 3, + 2, 0, 4, 128, 0, 0, + 228, 128, 21, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 128, + 2, 0, 228, 128, 7, 0, + 0, 2, 0, 0, 1, 128, + 0, 0, 0, 128, 5, 0, + 0, 3, 2, 0, 7, 224, + 0, 0, 0, 128, 2, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 128, 14, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 243, 0, 85, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 243, 0, + 170, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 128, 22, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 1, 0, 228, 128, + 23, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 128, 25, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 242, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 3, 224, + 2, 0, 228, 144, 1, 0, + 0, 2, 0, 0, 6, 128, + 243, 0, 228, 160, 4, 0, + 0, 4, 3, 0, 15, 224, + 0, 0, 255, 160, 0, 0, + 149, 128, 0, 0, 106, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 168, 5, 0, 0, + 64, 0, 1, 0, 106, 1, + 0, 0, 89, 8, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 242, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 4, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 3, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 4, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 4, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 38, 0, 0, 11, + 0, 208, 0, 0, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 30, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 1, 0, 0, 0, 86, 21, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 26, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 26, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 26, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 166, 26, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 26, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 3, 0, 0, 0, 86, 21, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 27, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 27, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 27, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 166, 26, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 27, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 17, 0, 0, 7, + 34, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 3, 0, 0, 0, 86, 21, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 28, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 28, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 28, 0, + 0, 0, 42, 0, 16, 0, + 0, 0, 0, 0, 166, 26, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 28, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 17, 0, 0, 7, + 66, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 58, 16, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 17, 32, 0, 8, 130, 32, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 32, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 8, 114, 32, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 54, 0, 0, 6, + 130, 32, 16, 0, 3, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 184, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 140, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 147, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 156, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 15, 15, 0, 0, + 169, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 66, 76, + 69, 78, 68, 73, 78, 68, + 73, 67, 69, 83, 0, 66, + 76, 69, 78, 68, 87, 69, + 73, 71, 72, 84, 0, 171, + 171, 171, 79, 83, 71, 78, + 156, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 12, 0, 0, + 128, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 128, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 7, 8, 0, 0, + 137, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 143, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 0, 0, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 67, 79, 76, + 79, 82, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingOneBone.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingOneBone.inc new file mode 100644 index 0000000000000000000000000000000000000000..837d71861738818bdb7834a4fcc34ac733f6ef52 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingOneBone.inc @@ -0,0 +1,482 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// BLENDINDICES 0 xyzw 3 NONE uint x +// BLENDWEIGHT 0 xyzw 4 NONE float x +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xy 0 NONE float xy +// TEXCOORD 1 xyzw 1 NONE float xyzw +// TEXCOORD 2 xyz 2 NONE float xyz +// COLOR 0 xyzw 3 NONE float xyzw +// SV_Position 0 xyzw 4 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 242 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c242 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c243, 3, 0, 1, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mul r0.x, v3.x, c243.x + mova a0.x, r0.x + mul r0, v4.x, c26[a0.x] + dp4 r1.x, v0, r0 + dp3 r0.x, v1, r0 + mul r2, v4.x, c27[a0.x] + mul r3, v4.x, c28[a0.x] + dp4 r1.y, v0, r2 + dp3 r0.y, v1, r2 + dp4 r1.z, v0, r3 + dp3 r0.z, v1, r3 + mov r1.w, v0.w + dp4 oPos.z, r1, c24 + dp4 oT1.x, r1, c15 + dp4 oT1.y, r1, c16 + dp4 oT1.z, r1, c17 + dp3 r2.x, r0, c19 + dp3 r2.y, r0, c20 + dp3 r2.z, r0, c21 + dp3 r0.x, r2, r2 + rsq r0.x, r0.x + mul oT2.xyz, r0.x, r2 + dp4 r0.x, r1, c14 + max r0.x, r0.x, c243.y + min oT1.w, r0.x, c243.z + dp4 r0.x, r1, c22 + dp4 r0.y, r1, c23 + dp4 r0.z, r1, c25 + mad oPos.xy, r0.z, c242, r0 + mov oPos.w, r0.z + mov oT0.xy, v2 + mov r0.yz, c243 + mad oT3, c0.w, r0.yyyz, r0.zzzy + +// approximately 33 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[242], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.x +dcl_input v4.x +dcl_output o0.xy +dcl_output o1.xyzw +dcl_output o2.xyz +dcl_output o3.xyzw +dcl_output_siv o4.xyzw, position +dcl_temps 4 +mov o0.xy, v2.xyxx +imul null, r0.x, v3.x, l(3) +mul r1.xyzw, v4.xxxx, cb0[r0.x + 26].xyzw +dp4 r2.x, v0.xyzw, r1.xyzw +dp3 r1.x, v1.xyzx, r1.xyzx +mul r3.xyzw, v4.xxxx, cb0[r0.x + 27].xyzw +mul r0.xyzw, v4.xxxx, cb0[r0.x + 28].xyzw +dp4 r2.y, v0.xyzw, r3.xyzw +dp3 r1.y, v1.xyzx, r3.xyzx +dp4 r2.z, v0.xyzw, r0.xyzw +dp3 r1.z, v1.xyzx, r0.xyzx +mov r2.w, v0.w +dp4 o1.x, r2.xyzw, cb0[15].xyzw +dp4 o1.y, r2.xyzw, cb0[16].xyzw +dp4 o1.z, r2.xyzw, cb0[17].xyzw +dp4_sat o1.w, r2.xyzw, cb0[14].xyzw +dp3 r0.x, r1.xyzx, cb0[19].xyzx +dp3 r0.y, r1.xyzx, cb0[20].xyzx +dp3 r0.z, r1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul o2.xyz, r0.wwww, r0.xyzx +mov o3.xyz, l(1.000000,1.000000,1.000000,0) +mov o3.w, cb0[0].w +dp4 o4.x, r2.xyzw, cb0[22].xyzw +dp4 o4.y, r2.xyzw, cb0[23].xyzw +dp4 o4.z, r2.xyzw, cb0[24].xyzw +dp4 o4.w, r2.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_VSSkinnedPixelLightingOneBone[] = +{ + 68, 88, 66, 67, 41, 197, + 48, 64, 51, 72, 196, 249, + 192, 213, 70, 47, 196, 138, + 134, 101, 1, 0, 0, 0, + 44, 8, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 212, 2, 0, 0, 200, 6, + 0, 0, 136, 7, 0, 0, + 65, 111, 110, 57, 156, 2, + 0, 0, 156, 2, 0, 0, + 0, 2, 254, 255, 104, 2, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 242, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 243, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 1, 128, + 3, 0, 0, 144, 243, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 1, 176, 0, 0, + 0, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 4, 0, + 0, 144, 26, 32, 228, 160, + 0, 0, 0, 176, 9, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 228, 144, 0, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 144, 0, 0, 228, 128, + 5, 0, 0, 4, 2, 0, + 15, 128, 4, 0, 0, 144, + 27, 32, 228, 160, 0, 0, + 0, 176, 5, 0, 0, 4, + 3, 0, 15, 128, 4, 0, + 0, 144, 28, 32, 228, 160, + 0, 0, 0, 176, 9, 0, + 0, 3, 1, 0, 2, 128, + 0, 0, 228, 144, 2, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 2, 0, 228, 128, + 9, 0, 0, 3, 1, 0, + 4, 128, 0, 0, 228, 144, + 3, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 3, 0, + 228, 128, 1, 0, 0, 2, + 1, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 0, 0, 4, 192, 1, 0, + 228, 128, 24, 0, 228, 160, + 9, 0, 0, 3, 1, 0, + 1, 224, 1, 0, 228, 128, + 15, 0, 228, 160, 9, 0, + 0, 3, 1, 0, 2, 224, + 1, 0, 228, 128, 16, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 4, 224, 1, 0, + 228, 128, 17, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 1, 128, 0, 0, 228, 128, + 19, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 2, 128, + 0, 0, 228, 128, 20, 0, + 228, 160, 8, 0, 0, 3, + 2, 0, 4, 128, 0, 0, + 228, 128, 21, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 128, + 2, 0, 228, 128, 7, 0, + 0, 2, 0, 0, 1, 128, + 0, 0, 0, 128, 5, 0, + 0, 3, 2, 0, 7, 224, + 0, 0, 0, 128, 2, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 128, 14, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 243, 0, 85, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 243, 0, + 170, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 128, 22, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 1, 0, 228, 128, + 23, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 128, 25, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 242, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 3, 224, + 2, 0, 228, 144, 1, 0, + 0, 2, 0, 0, 6, 128, + 243, 0, 228, 160, 4, 0, + 0, 4, 3, 0, 15, 224, + 0, 0, 255, 160, 0, 0, + 149, 128, 0, 0, 106, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 236, 3, 0, 0, + 64, 0, 1, 0, 251, 0, + 0, 0, 89, 8, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 242, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 18, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 18, 16, + 16, 0, 4, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 3, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 4, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 4, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 38, 0, 0, 8, + 0, 208, 0, 0, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 16, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 3, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 1, 0, 0, 0, 6, 16, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 26, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 3, 0, 0, 0, 6, 16, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 27, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 28, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 7, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 30, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 17, 0, 0, 7, + 66, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 58, 16, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 17, 32, 0, 8, 130, 32, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 32, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 8, 114, 32, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 54, 0, 0, 6, + 130, 32, 16, 0, 3, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 184, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 140, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 147, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 156, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 15, 1, 0, 0, + 169, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 1, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 66, 76, + 69, 78, 68, 73, 78, 68, + 73, 67, 69, 83, 0, 66, + 76, 69, 78, 68, 87, 69, + 73, 71, 72, 84, 0, 171, + 171, 171, 79, 83, 71, 78, + 156, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 12, 0, 0, + 128, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 128, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 7, 8, 0, 0, + 137, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 143, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 0, 0, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 67, 79, 76, + 79, 82, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingTwoBones.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingTwoBones.inc new file mode 100644 index 0000000000000000000000000000000000000000..9473c2ae02a8c370b5b29412f9339bb1ccafae4c --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingTwoBones.inc @@ -0,0 +1,526 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// BLENDINDICES 0 xyzw 3 NONE uint xy +// BLENDWEIGHT 0 xyzw 4 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xy 0 NONE float xy +// TEXCOORD 1 xyzw 1 NONE float xyzw +// TEXCOORD 2 xyz 2 NONE float xyz +// COLOR 0 xyzw 3 NONE float xyzw +// SV_Position 0 xyzw 4 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 242 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c242 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c243, 3, 0, 1, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mul r0.xy, v3, c243.x + mova a0.xy, r0.yxzw + mul r0, v4.y, c26[a0.x] + mad r0, c26[a0.y], v4.x, r0 + dp4 r1.x, v0, r0 + dp3 r0.x, v1, r0 + mul r2, v4.y, c27[a0.x] + mul r3, v4.y, c28[a0.x] + mad r3, c28[a0.y], v4.x, r3 + mad r2, c27[a0.y], v4.x, r2 + dp4 r1.y, v0, r2 + dp3 r0.y, v1, r2 + dp4 r1.z, v0, r3 + dp3 r0.z, v1, r3 + mov r1.w, v0.w + dp4 oPos.z, r1, c24 + dp4 oT1.x, r1, c15 + dp4 oT1.y, r1, c16 + dp4 oT1.z, r1, c17 + dp3 r2.x, r0, c19 + dp3 r2.y, r0, c20 + dp3 r2.z, r0, c21 + dp3 r0.x, r2, r2 + rsq r0.x, r0.x + mul oT2.xyz, r0.x, r2 + dp4 r0.x, r1, c14 + max r0.x, r0.x, c243.y + min oT1.w, r0.x, c243.z + dp4 r0.x, r1, c22 + dp4 r0.y, r1, c23 + dp4 r0.z, r1, c25 + mad oPos.xy, r0.z, c242, r0 + mov oPos.w, r0.z + mov oT0.xy, v2 + mov r0.yz, c243 + mad oT3, c0.w, r0.yyyz, r0.zzzy + +// approximately 36 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[242], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xy +dcl_input v4.xy +dcl_output o0.xy +dcl_output o1.xyzw +dcl_output o2.xyz +dcl_output o3.xyzw +dcl_output_siv o4.xyzw, position +dcl_temps 4 +mov o0.xy, v2.xyxx +imul null, r0.xy, v3.xyxx, l(3, 3, 0, 0) +mul r1.xyzw, v4.yyyy, cb0[r0.y + 26].xyzw +mad r1.xyzw, cb0[r0.x + 26].xyzw, v4.xxxx, r1.xyzw +dp4 r2.x, v0.xyzw, r1.xyzw +dp3 r1.x, v1.xyzx, r1.xyzx +mul r3.xyzw, v4.yyyy, cb0[r0.y + 27].xyzw +mad r3.xyzw, cb0[r0.x + 27].xyzw, v4.xxxx, r3.xyzw +dp4 r2.y, v0.xyzw, r3.xyzw +dp3 r1.y, v1.xyzx, r3.xyzx +mul r3.xyzw, v4.yyyy, cb0[r0.y + 28].xyzw +mad r0.xyzw, cb0[r0.x + 28].xyzw, v4.xxxx, r3.xyzw +dp4 r2.z, v0.xyzw, r0.xyzw +dp3 r1.z, v1.xyzx, r0.xyzx +mov r2.w, v0.w +dp4 o1.x, r2.xyzw, cb0[15].xyzw +dp4 o1.y, r2.xyzw, cb0[16].xyzw +dp4 o1.z, r2.xyzw, cb0[17].xyzw +dp4_sat o1.w, r2.xyzw, cb0[14].xyzw +dp3 r0.x, r1.xyzx, cb0[19].xyzx +dp3 r0.y, r1.xyzx, cb0[20].xyzx +dp3 r0.z, r1.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul o2.xyz, r0.wwww, r0.xyzx +mov o3.xyz, l(1.000000,1.000000,1.000000,0) +mov o3.w, cb0[0].w +dp4 o4.x, r2.xyzw, cb0[22].xyzw +dp4 o4.y, r2.xyzw, cb0[23].xyzw +dp4 o4.z, r2.xyzw, cb0[24].xyzw +dp4 o4.w, r2.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_VSSkinnedPixelLightingTwoBones[] = +{ + 68, 88, 66, 67, 163, 194, + 247, 169, 98, 146, 170, 161, + 181, 157, 159, 161, 31, 127, + 1, 147, 1, 0, 0, 0, + 16, 9, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 28, 3, 0, 0, 172, 7, + 0, 0, 108, 8, 0, 0, + 65, 111, 110, 57, 228, 2, + 0, 0, 228, 2, 0, 0, + 0, 2, 254, 255, 176, 2, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 242, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 243, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 3, 128, + 3, 0, 228, 144, 243, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 3, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 4, 0, + 85, 144, 26, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 0, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 0, 0, 228, 128, 9, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 228, 144, 0, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 144, 0, 0, 228, 128, + 5, 0, 0, 4, 2, 0, + 15, 128, 4, 0, 85, 144, + 27, 32, 228, 160, 0, 0, + 0, 176, 5, 0, 0, 4, + 3, 0, 15, 128, 4, 0, + 85, 144, 28, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 2, 0, 228, 128, 9, 0, + 0, 3, 1, 0, 2, 128, + 0, 0, 228, 144, 2, 0, + 228, 128, 8, 0, 0, 3, + 0, 0, 2, 128, 1, 0, + 228, 144, 2, 0, 228, 128, + 9, 0, 0, 3, 1, 0, + 4, 128, 0, 0, 228, 144, + 3, 0, 228, 128, 8, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 144, 3, 0, + 228, 128, 1, 0, 0, 2, + 1, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 0, 0, 4, 192, 1, 0, + 228, 128, 24, 0, 228, 160, + 9, 0, 0, 3, 1, 0, + 1, 224, 1, 0, 228, 128, + 15, 0, 228, 160, 9, 0, + 0, 3, 1, 0, 2, 224, + 1, 0, 228, 128, 16, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 4, 224, 1, 0, + 228, 128, 17, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 1, 128, 0, 0, 228, 128, + 19, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 2, 128, + 0, 0, 228, 128, 20, 0, + 228, 160, 8, 0, 0, 3, + 2, 0, 4, 128, 0, 0, + 228, 128, 21, 0, 228, 160, + 8, 0, 0, 3, 0, 0, + 1, 128, 2, 0, 228, 128, + 2, 0, 228, 128, 7, 0, + 0, 2, 0, 0, 1, 128, + 0, 0, 0, 128, 5, 0, + 0, 3, 2, 0, 7, 224, + 0, 0, 0, 128, 2, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 128, 14, 0, 228, 160, + 11, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 0, 128, + 243, 0, 85, 160, 10, 0, + 0, 3, 1, 0, 8, 224, + 0, 0, 0, 128, 243, 0, + 170, 160, 9, 0, 0, 3, + 0, 0, 1, 128, 1, 0, + 228, 128, 22, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 2, 128, 1, 0, 228, 128, + 23, 0, 228, 160, 9, 0, + 0, 3, 0, 0, 4, 128, + 1, 0, 228, 128, 25, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 170, 128, 242, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 8, 192, + 0, 0, 170, 128, 1, 0, + 0, 2, 0, 0, 3, 224, + 2, 0, 228, 144, 1, 0, + 0, 2, 0, 0, 6, 128, + 243, 0, 228, 160, 4, 0, + 0, 4, 3, 0, 15, 224, + 0, 0, 255, 160, 0, 0, + 149, 128, 0, 0, 106, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 136, 4, 0, 0, + 64, 0, 1, 0, 34, 1, + 0, 0, 89, 8, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 242, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 4, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 114, 32, + 16, 0, 2, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 3, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 4, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 4, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 38, 0, 0, 11, + 0, 208, 0, 0, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 1, 0, 0, 0, 86, 21, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 26, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 26, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 17, 0, 0, 7, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 3, 0, 0, 0, 86, 21, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 27, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 27, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 17, 0, 0, 7, + 34, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 3, 0, 0, 0, 86, 21, + 16, 0, 4, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 28, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 12, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 28, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 17, 0, 0, 7, + 66, 0, 16, 0, 2, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 130, 0, 16, 0, + 2, 0, 0, 0, 58, 16, + 16, 0, 0, 0, 0, 0, + 17, 0, 0, 8, 18, 32, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 17, 0, 0, 8, + 34, 32, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 16, 0, 0, 0, 17, 0, + 0, 8, 66, 32, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 17, 0, 0, 0, + 17, 32, 0, 8, 130, 32, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 14, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 1, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 32, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 8, 114, 32, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 54, 0, 0, 6, + 130, 32, 16, 0, 3, 0, + 0, 0, 58, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 184, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 140, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 147, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 156, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 15, 3, 0, 0, + 169, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 3, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 66, 76, + 69, 78, 68, 73, 78, 68, + 73, 67, 69, 83, 0, 66, + 76, 69, 78, 68, 87, 69, + 73, 71, 72, 84, 0, 171, + 171, 171, 79, 83, 71, 78, + 156, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 3, 12, 0, 0, + 128, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 128, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 7, 8, 0, 0, + 137, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 143, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 0, 0, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 67, 79, 76, + 79, 82, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingFourBones.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingFourBones.inc new file mode 100644 index 0000000000000000000000000000000000000000..e2f3bc77e8d21db70a363c1fbbb1a7b605293698 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingFourBones.inc @@ -0,0 +1,939 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// BLENDINDICES 0 xyzw 3 NONE uint xyzw +// BLENDWEIGHT 0 xyzw 4 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 242 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c242 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c243, 3, 0, 1, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mul r0, v3, c243.x + mova a0, r0.yxzw + mul r1, v4.y, c26[a0.x] + mad r1, c26[a0.y], v4.x, r1 + mad r0, c26[a0.z], v4.z, r1 + mad r0, c26[a0.w], v4.w, r0 + dp3 r1.x, v1, r0 + dp4 r0.x, v0, r0 + mul r2, v4.y, c27[a0.x] + mul r3, v4.y, c28[a0.x] + mad r3, c28[a0.y], v4.x, r3 + mad r2, c27[a0.y], v4.x, r2 + mad r2, c27[a0.z], v4.z, r2 + mad r3, c28[a0.z], v4.z, r3 + mad r3, c28[a0.w], v4.w, r3 + mad r2, c27[a0.w], v4.w, r2 + dp3 r1.y, v1, r2 + dp4 r0.y, v0, r2 + dp3 r1.z, v1, r3 + dp4 r0.z, v0, r3 + dp3 r2.x, r1, c19 + dp3 r2.y, r1, c20 + dp3 r2.z, r1, c21 + nrm r1.xyz, r2 + dp3 r2.x, -c3, r1 + dp3 r2.y, -c4, r1 + dp3 r2.z, -c5, r1 + sge r3.xyz, r2, c243.y + mul r2.xyz, r2, r3 + mul r4.xyz, r2.y, c7 + mad r2.xyw, r2.x, c6.xyzz, r4.xyzz + mad r2.xyz, r2.z, c8, r2.xyww + mov r4.xyz, c0 + mad oT0.xyz, r2, r4, c1 + mov r0.w, v0.w + dp4 r2.x, r0, c15 + dp4 r2.y, r0, c16 + dp4 r2.z, r0, c17 + add r2.xyz, -r2, c12 + nrm r4.xyz, r2 + add r2.xyz, r4, -c3 + nrm r5.xyz, r2 + dp3 r2.x, r5, r1 + add r5.xyz, r4, -c4 + add r4.xyz, r4, -c5 + nrm r6.xyz, r4 + dp3 r2.z, r6, r1 + nrm r4.xyz, r5 + dp3 r2.y, r4, r1 + max r1.xyz, r2, c243.y + mul r1.xyz, r3, r1 + log r2.x, r1.x + log r2.y, r1.y + log r2.z, r1.z + mul r1.xyz, r2, c2.w + exp r1.y, r1.y + mul r2.xyz, r1.y, c10 + exp r1.x, r1.x + exp r1.y, r1.z + mad r1.xzw, r1.x, c9.xyyz, r2.xyyz + mad r1.xyz, r1.y, c11, r1.xzww + mul oT1.xyz, r1, c2 + dp4 oPos.z, r0, c24 + dp4 r1.x, r0, c14 + max r1.x, r1.x, c243.y + min oT1.w, r1.x, c243.z + dp4 r1.x, r0, c22 + dp4 r1.y, r0, c23 + dp4 r0.x, r0, c25 + mad oPos.xy, r0.x, c242, r1 + mov oPos.w, r0.x + mov oT0.w, c0.w + mov oT2.xy, v2 + +// approximately 83 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[242], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xyzw +dcl_input v4.xyzw +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 6 +imul null, r0.xyzw, v3.xyzw, l(3, 3, 3, 3) +mul r1.xyzw, v4.yyyy, cb0[r0.y + 26].xyzw +mad r1.xyzw, cb0[r0.x + 26].xyzw, v4.xxxx, r1.xyzw +mad r1.xyzw, cb0[r0.z + 26].xyzw, v4.zzzz, r1.xyzw +mad r1.xyzw, cb0[r0.w + 26].xyzw, v4.wwww, r1.xyzw +dp3 r2.x, v1.xyzx, r1.xyzx +dp4 r1.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v4.yyyy, cb0[r0.y + 27].xyzw +mad r3.xyzw, cb0[r0.x + 27].xyzw, v4.xxxx, r3.xyzw +mad r3.xyzw, cb0[r0.z + 27].xyzw, v4.zzzz, r3.xyzw +mad r3.xyzw, cb0[r0.w + 27].xyzw, v4.wwww, r3.xyzw +dp3 r2.y, v1.xyzx, r3.xyzx +dp4 r1.y, v0.xyzw, r3.xyzw +mul r3.xyzw, v4.yyyy, cb0[r0.y + 28].xyzw +mad r3.xyzw, cb0[r0.x + 28].xyzw, v4.xxxx, r3.xyzw +mad r3.xyzw, cb0[r0.z + 28].xyzw, v4.zzzz, r3.xyzw +mad r0.xyzw, cb0[r0.w + 28].xyzw, v4.wwww, r3.xyzw +dp3 r2.z, v1.xyzx, r0.xyzx +dp4 r1.z, v0.xyzw, r0.xyzw +dp3 r0.x, r2.xyzx, cb0[19].xyzx +dp3 r0.y, r2.xyzx, cb0[20].xyzx +dp3 r0.z, r2.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r2.x, -cb0[3].xyzx, r0.xyzx +dp3 r2.y, -cb0[4].xyzx, r0.xyzx +dp3 r2.z, -cb0[5].xyzx, r0.xyzx +ge r3.xyz, r2.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r3.xyz, r3.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r2.xyz, r2.xyzx, r3.xyzx +mul r4.xyz, r2.yyyy, cb0[7].xyzx +mad r2.xyw, r2.xxxx, cb0[6].xyxz, r4.xyxz +mad r2.xyz, r2.zzzz, cb0[8].xyzx, r2.xywx +mad o0.xyz, r2.xyzx, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +mov r1.w, v0.w +dp4 r2.x, r1.xyzw, cb0[15].xyzw +dp4 r2.y, r1.xyzw, cb0[16].xyzw +dp4 r2.z, r1.xyzw, cb0[17].xyzw +add r2.xyz, -r2.xyzx, cb0[12].xyzx +dp3 r0.w, r2.xyzx, r2.xyzx +rsq r0.w, r0.w +mad r4.xyz, r2.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r2.w, r4.xyzx, r4.xyzx +rsq r2.w, r2.w +mul r4.xyz, r2.wwww, r4.xyzx +dp3 r4.x, r4.xyzx, r0.xyzx +mad r5.xyz, r2.xyzx, r0.wwww, -cb0[4].xyzx +mad r2.xyz, r2.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r5.xyzx, r5.xyzx +rsq r0.w, r0.w +mul r5.xyz, r0.wwww, r5.xyzx +dp3 r4.y, r5.xyzx, r0.xyzx +dp3 r0.w, r2.xyzx, r2.xyzx +rsq r0.w, r0.w +mul r2.xyz, r0.wwww, r2.xyzx +dp3 r4.z, r2.xyzx, r0.xyzx +max r0.xyz, r4.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +mul r0.xyz, r3.xyzx, r0.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r2.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r2.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, r1.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, r1.xyzw, cb0[22].xyzw +dp4 o3.y, r1.xyzw, cb0[23].xyzw +dp4 o3.z, r1.xyzw, cb0[24].xyzw +dp4 o3.w, r1.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_VSSkinnedVertexLightingFourBones[] = +{ + 68, 88, 66, 67, 53, 121, + 126, 89, 215, 5, 76, 254, + 128, 205, 221, 247, 111, 179, + 122, 93, 1, 0, 0, 0, + 240, 16, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 128, 5, 0, 0, 164, 15, + 0, 0, 100, 16, 0, 0, + 65, 111, 110, 57, 72, 5, + 0, 0, 72, 5, 0, 0, + 0, 2, 254, 255, 20, 5, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 242, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 243, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 15, 128, + 3, 0, 228, 144, 243, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 15, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 1, 0, 15, 128, 4, 0, + 85, 144, 26, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 1, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 170, 176, 4, 0, 170, 144, + 1, 0, 228, 128, 4, 0, + 0, 5, 0, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 255, 176, 4, 0, 255, 144, + 0, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 1, 128, + 1, 0, 228, 144, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 5, 0, 0, 4, 2, 0, + 15, 128, 4, 0, 85, 144, + 27, 32, 228, 160, 0, 0, + 0, 176, 5, 0, 0, 4, + 3, 0, 15, 128, 4, 0, + 85, 144, 28, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 2, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 170, 176, 4, 0, 170, 144, + 2, 0, 228, 128, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 170, 176, 4, 0, 170, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 255, 176, 4, 0, 255, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 255, 176, 4, 0, 255, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 2, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 2, 0, 228, 128, + 8, 0, 0, 3, 1, 0, + 4, 128, 1, 0, 228, 144, + 3, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 3, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 1, 128, 1, 0, + 228, 128, 19, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 2, 128, 1, 0, 228, 128, + 20, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 4, 128, + 1, 0, 228, 128, 21, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 1, 128, 3, 0, + 228, 161, 1, 0, 228, 128, + 8, 0, 0, 3, 2, 0, + 2, 128, 4, 0, 228, 161, + 1, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 4, 128, + 5, 0, 228, 161, 1, 0, + 228, 128, 13, 0, 0, 3, + 3, 0, 7, 128, 2, 0, + 228, 128, 243, 0, 85, 160, + 5, 0, 0, 3, 2, 0, + 7, 128, 2, 0, 228, 128, + 3, 0, 228, 128, 5, 0, + 0, 3, 4, 0, 7, 128, + 2, 0, 85, 128, 7, 0, + 228, 160, 4, 0, 0, 4, + 2, 0, 11, 128, 2, 0, + 0, 128, 6, 0, 164, 160, + 4, 0, 164, 128, 4, 0, + 0, 4, 2, 0, 7, 128, + 2, 0, 170, 128, 8, 0, + 228, 160, 2, 0, 244, 128, + 1, 0, 0, 2, 4, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 224, 2, 0, 228, 128, + 4, 0, 228, 128, 1, 0, + 228, 160, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 2, 0, 1, 128, 0, 0, + 228, 128, 15, 0, 228, 160, + 9, 0, 0, 3, 2, 0, + 2, 128, 0, 0, 228, 128, + 16, 0, 228, 160, 9, 0, + 0, 3, 2, 0, 4, 128, + 0, 0, 228, 128, 17, 0, + 228, 160, 2, 0, 0, 3, + 2, 0, 7, 128, 2, 0, + 228, 129, 12, 0, 228, 160, + 36, 0, 0, 2, 4, 0, + 7, 128, 2, 0, 228, 128, + 2, 0, 0, 3, 2, 0, + 7, 128, 4, 0, 228, 128, + 3, 0, 228, 161, 36, 0, + 0, 2, 5, 0, 7, 128, + 2, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 1, 128, + 5, 0, 228, 128, 1, 0, + 228, 128, 2, 0, 0, 3, + 5, 0, 7, 128, 4, 0, + 228, 128, 4, 0, 228, 161, + 2, 0, 0, 3, 4, 0, + 7, 128, 4, 0, 228, 128, + 5, 0, 228, 161, 36, 0, + 0, 2, 6, 0, 7, 128, + 4, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 4, 128, + 6, 0, 228, 128, 1, 0, + 228, 128, 36, 0, 0, 2, + 4, 0, 7, 128, 5, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 2, 128, 4, 0, + 228, 128, 1, 0, 228, 128, + 11, 0, 0, 3, 1, 0, + 7, 128, 2, 0, 228, 128, + 243, 0, 85, 160, 5, 0, + 0, 3, 1, 0, 7, 128, + 3, 0, 228, 128, 1, 0, + 228, 128, 15, 0, 0, 2, + 2, 0, 1, 128, 1, 0, + 0, 128, 15, 0, 0, 2, + 2, 0, 2, 128, 1, 0, + 85, 128, 15, 0, 0, 2, + 2, 0, 4, 128, 1, 0, + 170, 128, 5, 0, 0, 3, + 1, 0, 7, 128, 2, 0, + 228, 128, 2, 0, 255, 160, + 14, 0, 0, 2, 1, 0, + 2, 128, 1, 0, 85, 128, + 5, 0, 0, 3, 2, 0, + 7, 128, 1, 0, 85, 128, + 10, 0, 228, 160, 14, 0, + 0, 2, 1, 0, 1, 128, + 1, 0, 0, 128, 14, 0, + 0, 2, 1, 0, 2, 128, + 1, 0, 170, 128, 4, 0, + 0, 4, 1, 0, 13, 128, + 1, 0, 0, 128, 9, 0, + 148, 160, 2, 0, 148, 128, + 4, 0, 0, 4, 1, 0, + 7, 128, 1, 0, 85, 128, + 11, 0, 228, 160, 1, 0, + 248, 128, 5, 0, 0, 3, + 1, 0, 7, 224, 1, 0, + 228, 128, 2, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 192, 0, 0, 228, 128, + 24, 0, 228, 160, 9, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 228, 128, 14, 0, + 228, 160, 11, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 0, 128, 243, 0, 85, 160, + 10, 0, 0, 3, 1, 0, + 8, 224, 1, 0, 0, 128, + 243, 0, 170, 160, 9, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 228, 128, 22, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 2, 128, 0, 0, + 228, 128, 23, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 128, + 25, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 0, 128, 242, 0, + 228, 160, 1, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 0, 128, + 1, 0, 0, 2, 0, 0, + 8, 224, 0, 0, 255, 160, + 1, 0, 0, 2, 2, 0, + 3, 224, 2, 0, 228, 144, + 255, 255, 0, 0, 83, 72, + 68, 82, 28, 10, 0, 0, + 64, 0, 1, 0, 135, 2, + 0, 0, 89, 8, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 242, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 4, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 2, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 6, 0, 0, 0, + 38, 0, 0, 11, 0, 208, + 0, 0, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 1, 0, + 0, 0, 86, 21, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 26, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 26, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 26, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 166, 26, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 26, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 17, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 3, 0, + 0, 0, 86, 21, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 27, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 27, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 27, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 166, 26, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 27, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 17, 0, + 0, 7, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 3, 0, + 0, 0, 86, 21, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 28, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 28, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 28, 0, 0, 0, + 42, 0, 16, 0, 0, 0, + 0, 0, 166, 26, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 28, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 246, 31, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 17, 0, + 0, 7, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 29, 0, 0, 10, 114, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 10, 114, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 4, 0, 0, 0, + 86, 5, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 50, 0, 0, 10, + 178, 0, 16, 0, 2, 0, + 0, 0, 6, 0, 16, 0, + 2, 0, 0, 0, 70, 136, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 70, 8, + 16, 0, 4, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 166, 10, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 70, 3, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 11, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 6, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 16, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 9, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 5, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 5, 0, 0, 0, + 70, 2, 16, 0, 5, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 5, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 5, 0, + 0, 0, 16, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 52, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 47, 0, + 0, 5, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 143, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 2, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 136, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 70, 8, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 70, 3, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 32, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 184, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 140, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 147, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 156, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 15, 15, 0, 0, + 169, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 15, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 66, 76, + 69, 78, 68, 73, 78, 68, + 73, 67, 69, 83, 0, 66, + 76, 69, 78, 68, 87, 69, + 73, 71, 72, 84, 0, 171, + 171, 171, 79, 83, 71, 78, + 132, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 104, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 110, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 12, 0, 0, + 119, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingOneBone.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingOneBone.inc new file mode 100644 index 0000000000000000000000000000000000000000..af4be94946065d523148099cbb2b59085f621504 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingOneBone.inc @@ -0,0 +1,811 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// BLENDINDICES 0 xyzw 3 NONE uint x +// BLENDWEIGHT 0 xyzw 4 NONE float x +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 242 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c242 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c243, 3, 0, 1, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mul r0.x, v3.x, c243.x + mova a0.x, r0.x + mul r0, v4.x, c26[a0.x] + dp3 r1.x, v1, r0 + dp4 r0.x, v0, r0 + mul r2, v4.x, c27[a0.x] + mul r3, v4.x, c28[a0.x] + dp3 r1.y, v1, r2 + dp4 r0.y, v0, r2 + dp3 r1.z, v1, r3 + dp4 r0.z, v0, r3 + dp3 r2.x, r1, c19 + dp3 r2.y, r1, c20 + dp3 r2.z, r1, c21 + nrm r1.xyz, r2 + dp3 r2.x, -c3, r1 + dp3 r2.y, -c4, r1 + dp3 r2.z, -c5, r1 + sge r3.xyz, r2, c243.y + mul r2.xyz, r2, r3 + mul r4.xyz, r2.y, c7 + mad r2.xyw, r2.x, c6.xyzz, r4.xyzz + mad r2.xyz, r2.z, c8, r2.xyww + mov r4.xyz, c0 + mad oT0.xyz, r2, r4, c1 + mov r0.w, v0.w + dp4 r2.x, r0, c15 + dp4 r2.y, r0, c16 + dp4 r2.z, r0, c17 + add r2.xyz, -r2, c12 + nrm r4.xyz, r2 + add r2.xyz, r4, -c3 + nrm r5.xyz, r2 + dp3 r2.x, r5, r1 + add r5.xyz, r4, -c4 + add r4.xyz, r4, -c5 + nrm r6.xyz, r4 + dp3 r2.z, r6, r1 + nrm r4.xyz, r5 + dp3 r2.y, r4, r1 + max r1.xyz, r2, c243.y + mul r1.xyz, r3, r1 + log r2.x, r1.x + log r2.y, r1.y + log r2.z, r1.z + mul r1.xyz, r2, c2.w + exp r1.y, r1.y + mul r2.xyz, r1.y, c10 + exp r1.x, r1.x + exp r1.y, r1.z + mad r1.xzw, r1.x, c9.xyyz, r2.xyyz + mad r1.xyz, r1.y, c11, r1.xzww + mul oT1.xyz, r1, c2 + dp4 oPos.z, r0, c24 + dp4 r1.x, r0, c14 + max r1.x, r1.x, c243.y + min oT1.w, r1.x, c243.z + dp4 r1.x, r0, c22 + dp4 r1.y, r0, c23 + dp4 r0.x, r0, c25 + mad oPos.xy, r0.x, c242, r1 + mov oPos.w, r0.x + mov oT0.w, c0.w + mov oT2.xy, v2 + +// approximately 74 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[242], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.x +dcl_input v4.x +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 6 +imul null, r0.x, v3.x, l(3) +mul r1.xyzw, v4.xxxx, cb0[r0.x + 26].xyzw +dp3 r2.x, v1.xyzx, r1.xyzx +dp4 r1.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v4.xxxx, cb0[r0.x + 27].xyzw +mul r0.xyzw, v4.xxxx, cb0[r0.x + 28].xyzw +dp3 r2.y, v1.xyzx, r3.xyzx +dp4 r1.y, v0.xyzw, r3.xyzw +dp3 r2.z, v1.xyzx, r0.xyzx +dp4 r1.z, v0.xyzw, r0.xyzw +dp3 r0.x, r2.xyzx, cb0[19].xyzx +dp3 r0.y, r2.xyzx, cb0[20].xyzx +dp3 r0.z, r2.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r2.x, -cb0[3].xyzx, r0.xyzx +dp3 r2.y, -cb0[4].xyzx, r0.xyzx +dp3 r2.z, -cb0[5].xyzx, r0.xyzx +ge r3.xyz, r2.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r3.xyz, r3.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r2.xyz, r2.xyzx, r3.xyzx +mul r4.xyz, r2.yyyy, cb0[7].xyzx +mad r2.xyw, r2.xxxx, cb0[6].xyxz, r4.xyxz +mad r2.xyz, r2.zzzz, cb0[8].xyzx, r2.xywx +mad o0.xyz, r2.xyzx, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +mov r1.w, v0.w +dp4 r2.x, r1.xyzw, cb0[15].xyzw +dp4 r2.y, r1.xyzw, cb0[16].xyzw +dp4 r2.z, r1.xyzw, cb0[17].xyzw +add r2.xyz, -r2.xyzx, cb0[12].xyzx +dp3 r0.w, r2.xyzx, r2.xyzx +rsq r0.w, r0.w +mad r4.xyz, r2.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r2.w, r4.xyzx, r4.xyzx +rsq r2.w, r2.w +mul r4.xyz, r2.wwww, r4.xyzx +dp3 r4.x, r4.xyzx, r0.xyzx +mad r5.xyz, r2.xyzx, r0.wwww, -cb0[4].xyzx +mad r2.xyz, r2.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r5.xyzx, r5.xyzx +rsq r0.w, r0.w +mul r5.xyz, r0.wwww, r5.xyzx +dp3 r4.y, r5.xyzx, r0.xyzx +dp3 r0.w, r2.xyzx, r2.xyzx +rsq r0.w, r0.w +mul r2.xyz, r0.wwww, r2.xyzx +dp3 r4.z, r2.xyzx, r0.xyzx +max r0.xyz, r4.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +mul r0.xyz, r3.xyzx, r0.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r2.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r2.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, r1.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, r1.xyzw, cb0[22].xyzw +dp4 o3.y, r1.xyzw, cb0[23].xyzw +dp4 o3.z, r1.xyzw, cb0[24].xyzw +dp4 o3.w, r1.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_VSSkinnedVertexLightingOneBone[] = +{ + 68, 88, 66, 67, 87, 31, + 224, 191, 86, 93, 247, 204, + 34, 99, 246, 236, 244, 110, + 198, 124, 1, 0, 0, 0, + 92, 14, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 168, 4, 0, 0, 16, 13, + 0, 0, 208, 13, 0, 0, + 65, 111, 110, 57, 112, 4, + 0, 0, 112, 4, 0, 0, + 0, 2, 254, 255, 60, 4, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 242, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 243, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 1, 128, + 3, 0, 0, 144, 243, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 1, 176, 0, 0, + 0, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 4, 0, + 0, 144, 26, 32, 228, 160, + 0, 0, 0, 176, 8, 0, + 0, 3, 1, 0, 1, 128, + 1, 0, 228, 144, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 5, 0, 0, 4, 2, 0, + 15, 128, 4, 0, 0, 144, + 27, 32, 228, 160, 0, 0, + 0, 176, 5, 0, 0, 4, + 3, 0, 15, 128, 4, 0, + 0, 144, 28, 32, 228, 160, + 0, 0, 0, 176, 8, 0, + 0, 3, 1, 0, 2, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 2, 0, 228, 128, + 8, 0, 0, 3, 1, 0, + 4, 128, 1, 0, 228, 144, + 3, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 3, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 1, 128, 1, 0, + 228, 128, 19, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 2, 128, 1, 0, 228, 128, + 20, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 4, 128, + 1, 0, 228, 128, 21, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 1, 128, 3, 0, + 228, 161, 1, 0, 228, 128, + 8, 0, 0, 3, 2, 0, + 2, 128, 4, 0, 228, 161, + 1, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 4, 128, + 5, 0, 228, 161, 1, 0, + 228, 128, 13, 0, 0, 3, + 3, 0, 7, 128, 2, 0, + 228, 128, 243, 0, 85, 160, + 5, 0, 0, 3, 2, 0, + 7, 128, 2, 0, 228, 128, + 3, 0, 228, 128, 5, 0, + 0, 3, 4, 0, 7, 128, + 2, 0, 85, 128, 7, 0, + 228, 160, 4, 0, 0, 4, + 2, 0, 11, 128, 2, 0, + 0, 128, 6, 0, 164, 160, + 4, 0, 164, 128, 4, 0, + 0, 4, 2, 0, 7, 128, + 2, 0, 170, 128, 8, 0, + 228, 160, 2, 0, 244, 128, + 1, 0, 0, 2, 4, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 224, 2, 0, 228, 128, + 4, 0, 228, 128, 1, 0, + 228, 160, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 2, 0, 1, 128, 0, 0, + 228, 128, 15, 0, 228, 160, + 9, 0, 0, 3, 2, 0, + 2, 128, 0, 0, 228, 128, + 16, 0, 228, 160, 9, 0, + 0, 3, 2, 0, 4, 128, + 0, 0, 228, 128, 17, 0, + 228, 160, 2, 0, 0, 3, + 2, 0, 7, 128, 2, 0, + 228, 129, 12, 0, 228, 160, + 36, 0, 0, 2, 4, 0, + 7, 128, 2, 0, 228, 128, + 2, 0, 0, 3, 2, 0, + 7, 128, 4, 0, 228, 128, + 3, 0, 228, 161, 36, 0, + 0, 2, 5, 0, 7, 128, + 2, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 1, 128, + 5, 0, 228, 128, 1, 0, + 228, 128, 2, 0, 0, 3, + 5, 0, 7, 128, 4, 0, + 228, 128, 4, 0, 228, 161, + 2, 0, 0, 3, 4, 0, + 7, 128, 4, 0, 228, 128, + 5, 0, 228, 161, 36, 0, + 0, 2, 6, 0, 7, 128, + 4, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 4, 128, + 6, 0, 228, 128, 1, 0, + 228, 128, 36, 0, 0, 2, + 4, 0, 7, 128, 5, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 2, 128, 4, 0, + 228, 128, 1, 0, 228, 128, + 11, 0, 0, 3, 1, 0, + 7, 128, 2, 0, 228, 128, + 243, 0, 85, 160, 5, 0, + 0, 3, 1, 0, 7, 128, + 3, 0, 228, 128, 1, 0, + 228, 128, 15, 0, 0, 2, + 2, 0, 1, 128, 1, 0, + 0, 128, 15, 0, 0, 2, + 2, 0, 2, 128, 1, 0, + 85, 128, 15, 0, 0, 2, + 2, 0, 4, 128, 1, 0, + 170, 128, 5, 0, 0, 3, + 1, 0, 7, 128, 2, 0, + 228, 128, 2, 0, 255, 160, + 14, 0, 0, 2, 1, 0, + 2, 128, 1, 0, 85, 128, + 5, 0, 0, 3, 2, 0, + 7, 128, 1, 0, 85, 128, + 10, 0, 228, 160, 14, 0, + 0, 2, 1, 0, 1, 128, + 1, 0, 0, 128, 14, 0, + 0, 2, 1, 0, 2, 128, + 1, 0, 170, 128, 4, 0, + 0, 4, 1, 0, 13, 128, + 1, 0, 0, 128, 9, 0, + 148, 160, 2, 0, 148, 128, + 4, 0, 0, 4, 1, 0, + 7, 128, 1, 0, 85, 128, + 11, 0, 228, 160, 1, 0, + 248, 128, 5, 0, 0, 3, + 1, 0, 7, 224, 1, 0, + 228, 128, 2, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 192, 0, 0, 228, 128, + 24, 0, 228, 160, 9, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 228, 128, 14, 0, + 228, 160, 11, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 0, 128, 243, 0, 85, 160, + 10, 0, 0, 3, 1, 0, + 8, 224, 1, 0, 0, 128, + 243, 0, 170, 160, 9, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 228, 128, 22, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 2, 128, 0, 0, + 228, 128, 23, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 128, + 25, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 0, 128, 242, 0, + 228, 160, 1, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 0, 128, + 1, 0, 0, 2, 0, 0, + 8, 224, 0, 0, 255, 160, + 1, 0, 0, 2, 2, 0, + 3, 224, 2, 0, 228, 144, + 255, 255, 0, 0, 83, 72, + 68, 82, 96, 8, 0, 0, + 64, 0, 1, 0, 24, 2, + 0, 0, 89, 8, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 242, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 18, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 18, 16, + 16, 0, 4, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 2, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 6, 0, 0, 0, + 38, 0, 0, 8, 0, 208, + 0, 0, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 16, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 3, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 1, 0, + 0, 0, 6, 16, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 26, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 17, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 3, 0, + 0, 0, 6, 16, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 27, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 0, 0, 0, 0, + 6, 16, 16, 0, 4, 0, + 0, 0, 70, 142, 32, 6, + 0, 0, 0, 0, 28, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 16, 0, + 0, 7, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 18, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 17, 0, 0, 7, + 34, 0, 16, 0, 1, 0, + 0, 0, 70, 30, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 17, 0, + 0, 7, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 29, 0, 0, 10, 114, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 10, 114, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 4, 0, 0, 0, + 86, 5, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 50, 0, 0, 10, + 178, 0, 16, 0, 2, 0, + 0, 0, 6, 0, 16, 0, + 2, 0, 0, 0, 70, 136, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 70, 8, + 16, 0, 4, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 166, 10, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 70, 3, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 11, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 6, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 16, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 9, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 5, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 5, 0, 0, 0, + 70, 2, 16, 0, 5, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 5, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 5, 0, + 0, 0, 16, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 52, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 47, 0, + 0, 5, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 143, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 2, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 136, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 70, 8, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 70, 3, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 32, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 184, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 140, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 147, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 156, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 15, 1, 0, 0, + 169, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 1, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 66, 76, + 69, 78, 68, 73, 78, 68, + 73, 67, 69, 83, 0, 66, + 76, 69, 78, 68, 87, 69, + 73, 71, 72, 84, 0, 171, + 171, 171, 79, 83, 71, 78, + 132, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 104, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 110, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 12, 0, 0, + 119, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingTwoBones.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingTwoBones.inc new file mode 100644 index 0000000000000000000000000000000000000000..9606fa319bd5d041744fe698820b4802cab5ae68 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingTwoBones.inc @@ -0,0 +1,855 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 NONE float xyzw +// NORMAL 0 xyz 1 NONE float xyz +// TEXCOORD 0 xy 2 NONE float xy +// BLENDINDICES 0 xyzw 3 NONE uint xy +// BLENDWEIGHT 0 xyzw 4 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// COLOR 1 xyzw 1 NONE float xyzw +// TEXCOORD 0 xy 2 NONE float xy +// SV_Position 0 xyzw 3 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c0 cb0 0 242 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c242 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + def c243, 3, 0, 1, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mul r0.xy, v3, c243.x + mova a0.xy, r0.yxzw + mul r0, v4.y, c26[a0.x] + mad r0, c26[a0.y], v4.x, r0 + dp3 r1.x, v1, r0 + dp4 r0.x, v0, r0 + mul r2, v4.y, c27[a0.x] + mul r3, v4.y, c28[a0.x] + mad r3, c28[a0.y], v4.x, r3 + mad r2, c27[a0.y], v4.x, r2 + dp3 r1.y, v1, r2 + dp4 r0.y, v0, r2 + dp3 r1.z, v1, r3 + dp4 r0.z, v0, r3 + dp3 r2.x, r1, c19 + dp3 r2.y, r1, c20 + dp3 r2.z, r1, c21 + nrm r1.xyz, r2 + dp3 r2.x, -c3, r1 + dp3 r2.y, -c4, r1 + dp3 r2.z, -c5, r1 + sge r3.xyz, r2, c243.y + mul r2.xyz, r2, r3 + mul r4.xyz, r2.y, c7 + mad r2.xyw, r2.x, c6.xyzz, r4.xyzz + mad r2.xyz, r2.z, c8, r2.xyww + mov r4.xyz, c0 + mad oT0.xyz, r2, r4, c1 + mov r0.w, v0.w + dp4 r2.x, r0, c15 + dp4 r2.y, r0, c16 + dp4 r2.z, r0, c17 + add r2.xyz, -r2, c12 + nrm r4.xyz, r2 + add r2.xyz, r4, -c3 + nrm r5.xyz, r2 + dp3 r2.x, r5, r1 + add r5.xyz, r4, -c4 + add r4.xyz, r4, -c5 + nrm r6.xyz, r4 + dp3 r2.z, r6, r1 + nrm r4.xyz, r5 + dp3 r2.y, r4, r1 + max r1.xyz, r2, c243.y + mul r1.xyz, r3, r1 + log r2.x, r1.x + log r2.y, r1.y + log r2.z, r1.z + mul r1.xyz, r2, c2.w + exp r1.y, r1.y + mul r2.xyz, r1.y, c10 + exp r1.x, r1.x + exp r1.y, r1.z + mad r1.xzw, r1.x, c9.xyyz, r2.xyyz + mad r1.xyz, r1.y, c11, r1.xzww + mul oT1.xyz, r1, c2 + dp4 oPos.z, r0, c24 + dp4 r1.x, r0, c14 + max r1.x, r1.x, c243.y + min oT1.w, r1.x, c243.z + dp4 r1.x, r0, c22 + dp4 r1.y, r0, c23 + dp4 r0.x, r0, c25 + mad oPos.xy, r0.x, c242, r1 + mov oPos.w, r0.x + mov oT0.w, c0.w + mov oT2.xy, v2 + +// approximately 77 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[242], dynamicIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_input v2.xy +dcl_input v3.xy +dcl_input v4.xy +dcl_output o0.xyzw +dcl_output o1.xyzw +dcl_output o2.xy +dcl_output_siv o3.xyzw, position +dcl_temps 6 +imul null, r0.xy, v3.xyxx, l(3, 3, 0, 0) +mul r1.xyzw, v4.yyyy, cb0[r0.y + 26].xyzw +mad r1.xyzw, cb0[r0.x + 26].xyzw, v4.xxxx, r1.xyzw +dp3 r2.x, v1.xyzx, r1.xyzx +dp4 r1.x, v0.xyzw, r1.xyzw +mul r3.xyzw, v4.yyyy, cb0[r0.y + 27].xyzw +mad r3.xyzw, cb0[r0.x + 27].xyzw, v4.xxxx, r3.xyzw +dp3 r2.y, v1.xyzx, r3.xyzx +dp4 r1.y, v0.xyzw, r3.xyzw +mul r3.xyzw, v4.yyyy, cb0[r0.y + 28].xyzw +mad r0.xyzw, cb0[r0.x + 28].xyzw, v4.xxxx, r3.xyzw +dp3 r2.z, v1.xyzx, r0.xyzx +dp4 r1.z, v0.xyzw, r0.xyzw +dp3 r0.x, r2.xyzx, cb0[19].xyzx +dp3 r0.y, r2.xyzx, cb0[20].xyzx +dp3 r0.z, r2.xyzx, cb0[21].xyzx +dp3 r0.w, r0.xyzx, r0.xyzx +rsq r0.w, r0.w +mul r0.xyz, r0.wwww, r0.xyzx +dp3 r2.x, -cb0[3].xyzx, r0.xyzx +dp3 r2.y, -cb0[4].xyzx, r0.xyzx +dp3 r2.z, -cb0[5].xyzx, r0.xyzx +ge r3.xyz, r2.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +and r3.xyz, r3.xyzx, l(0x3f800000, 0x3f800000, 0x3f800000, 0) +mul r2.xyz, r2.xyzx, r3.xyzx +mul r4.xyz, r2.yyyy, cb0[7].xyzx +mad r2.xyw, r2.xxxx, cb0[6].xyxz, r4.xyxz +mad r2.xyz, r2.zzzz, cb0[8].xyzx, r2.xywx +mad o0.xyz, r2.xyzx, cb0[0].xyzx, cb0[1].xyzx +mov o0.w, cb0[0].w +mov r1.w, v0.w +dp4 r2.x, r1.xyzw, cb0[15].xyzw +dp4 r2.y, r1.xyzw, cb0[16].xyzw +dp4 r2.z, r1.xyzw, cb0[17].xyzw +add r2.xyz, -r2.xyzx, cb0[12].xyzx +dp3 r0.w, r2.xyzx, r2.xyzx +rsq r0.w, r0.w +mad r4.xyz, r2.xyzx, r0.wwww, -cb0[3].xyzx +dp3 r2.w, r4.xyzx, r4.xyzx +rsq r2.w, r2.w +mul r4.xyz, r2.wwww, r4.xyzx +dp3 r4.x, r4.xyzx, r0.xyzx +mad r5.xyz, r2.xyzx, r0.wwww, -cb0[4].xyzx +mad r2.xyz, r2.xyzx, r0.wwww, -cb0[5].xyzx +dp3 r0.w, r5.xyzx, r5.xyzx +rsq r0.w, r0.w +mul r5.xyz, r0.wwww, r5.xyzx +dp3 r4.y, r5.xyzx, r0.xyzx +dp3 r0.w, r2.xyzx, r2.xyzx +rsq r0.w, r0.w +mul r2.xyz, r0.wwww, r2.xyzx +dp3 r4.z, r2.xyzx, r0.xyzx +max r0.xyz, r4.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) +mul r0.xyz, r3.xyzx, r0.xyzx +log r0.xyz, r0.xyzx +mul r0.xyz, r0.xyzx, cb0[2].wwww +exp r0.xyz, r0.xyzx +mul r2.xyz, r0.yyyy, cb0[10].xyzx +mad r0.xyw, r0.xxxx, cb0[9].xyxz, r2.xyxz +mad r0.xyz, r0.zzzz, cb0[11].xyzx, r0.xywx +mul o1.xyz, r0.xyzx, cb0[2].xyzx +dp4_sat o1.w, r1.xyzw, cb0[14].xyzw +mov o2.xy, v2.xyxx +dp4 o3.x, r1.xyzw, cb0[22].xyzw +dp4 o3.y, r1.xyzw, cb0[23].xyzw +dp4 o3.z, r1.xyzw, cb0[24].xyzw +dp4 o3.w, r1.xyzw, cb0[25].xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SkinnedEffect_VSSkinnedVertexLightingTwoBones[] = +{ + 68, 88, 66, 67, 166, 103, + 187, 213, 206, 42, 30, 135, + 227, 229, 242, 216, 73, 40, + 224, 75, 1, 0, 0, 0, + 64, 15, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 240, 4, 0, 0, 244, 13, + 0, 0, 180, 14, 0, 0, + 65, 111, 110, 57, 184, 4, + 0, 0, 184, 4, 0, 0, + 0, 2, 254, 255, 132, 4, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 242, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 242, 0, + 0, 2, 254, 255, 81, 0, + 0, 5, 243, 0, 15, 160, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 3, 128, + 3, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 4, 128, + 4, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 3, 128, + 3, 0, 228, 144, 243, 0, + 0, 160, 46, 0, 0, 2, + 0, 0, 3, 176, 0, 0, + 225, 128, 5, 0, 0, 4, + 0, 0, 15, 128, 4, 0, + 85, 144, 26, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 0, 0, 15, 128, + 26, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 0, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 1, 128, + 1, 0, 228, 144, 0, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 1, 128, 0, 0, + 228, 144, 0, 0, 228, 128, + 5, 0, 0, 4, 2, 0, + 15, 128, 4, 0, 85, 144, + 27, 32, 228, 160, 0, 0, + 0, 176, 5, 0, 0, 4, + 3, 0, 15, 128, 4, 0, + 85, 144, 28, 32, 228, 160, + 0, 0, 0, 176, 4, 0, + 0, 5, 3, 0, 15, 128, + 28, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 3, 0, 228, 128, 4, 0, + 0, 5, 2, 0, 15, 128, + 27, 32, 228, 160, 0, 0, + 85, 176, 4, 0, 0, 144, + 2, 0, 228, 128, 8, 0, + 0, 3, 1, 0, 2, 128, + 1, 0, 228, 144, 2, 0, + 228, 128, 9, 0, 0, 3, + 0, 0, 2, 128, 0, 0, + 228, 144, 2, 0, 228, 128, + 8, 0, 0, 3, 1, 0, + 4, 128, 1, 0, 228, 144, + 3, 0, 228, 128, 9, 0, + 0, 3, 0, 0, 4, 128, + 0, 0, 228, 144, 3, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 1, 128, 1, 0, + 228, 128, 19, 0, 228, 160, + 8, 0, 0, 3, 2, 0, + 2, 128, 1, 0, 228, 128, + 20, 0, 228, 160, 8, 0, + 0, 3, 2, 0, 4, 128, + 1, 0, 228, 128, 21, 0, + 228, 160, 36, 0, 0, 2, + 1, 0, 7, 128, 2, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 1, 128, 3, 0, + 228, 161, 1, 0, 228, 128, + 8, 0, 0, 3, 2, 0, + 2, 128, 4, 0, 228, 161, + 1, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 4, 128, + 5, 0, 228, 161, 1, 0, + 228, 128, 13, 0, 0, 3, + 3, 0, 7, 128, 2, 0, + 228, 128, 243, 0, 85, 160, + 5, 0, 0, 3, 2, 0, + 7, 128, 2, 0, 228, 128, + 3, 0, 228, 128, 5, 0, + 0, 3, 4, 0, 7, 128, + 2, 0, 85, 128, 7, 0, + 228, 160, 4, 0, 0, 4, + 2, 0, 11, 128, 2, 0, + 0, 128, 6, 0, 164, 160, + 4, 0, 164, 128, 4, 0, + 0, 4, 2, 0, 7, 128, + 2, 0, 170, 128, 8, 0, + 228, 160, 2, 0, 244, 128, + 1, 0, 0, 2, 4, 0, + 7, 128, 0, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 7, 224, 2, 0, 228, 128, + 4, 0, 228, 128, 1, 0, + 228, 160, 1, 0, 0, 2, + 0, 0, 8, 128, 0, 0, + 255, 144, 9, 0, 0, 3, + 2, 0, 1, 128, 0, 0, + 228, 128, 15, 0, 228, 160, + 9, 0, 0, 3, 2, 0, + 2, 128, 0, 0, 228, 128, + 16, 0, 228, 160, 9, 0, + 0, 3, 2, 0, 4, 128, + 0, 0, 228, 128, 17, 0, + 228, 160, 2, 0, 0, 3, + 2, 0, 7, 128, 2, 0, + 228, 129, 12, 0, 228, 160, + 36, 0, 0, 2, 4, 0, + 7, 128, 2, 0, 228, 128, + 2, 0, 0, 3, 2, 0, + 7, 128, 4, 0, 228, 128, + 3, 0, 228, 161, 36, 0, + 0, 2, 5, 0, 7, 128, + 2, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 1, 128, + 5, 0, 228, 128, 1, 0, + 228, 128, 2, 0, 0, 3, + 5, 0, 7, 128, 4, 0, + 228, 128, 4, 0, 228, 161, + 2, 0, 0, 3, 4, 0, + 7, 128, 4, 0, 228, 128, + 5, 0, 228, 161, 36, 0, + 0, 2, 6, 0, 7, 128, + 4, 0, 228, 128, 8, 0, + 0, 3, 2, 0, 4, 128, + 6, 0, 228, 128, 1, 0, + 228, 128, 36, 0, 0, 2, + 4, 0, 7, 128, 5, 0, + 228, 128, 8, 0, 0, 3, + 2, 0, 2, 128, 4, 0, + 228, 128, 1, 0, 228, 128, + 11, 0, 0, 3, 1, 0, + 7, 128, 2, 0, 228, 128, + 243, 0, 85, 160, 5, 0, + 0, 3, 1, 0, 7, 128, + 3, 0, 228, 128, 1, 0, + 228, 128, 15, 0, 0, 2, + 2, 0, 1, 128, 1, 0, + 0, 128, 15, 0, 0, 2, + 2, 0, 2, 128, 1, 0, + 85, 128, 15, 0, 0, 2, + 2, 0, 4, 128, 1, 0, + 170, 128, 5, 0, 0, 3, + 1, 0, 7, 128, 2, 0, + 228, 128, 2, 0, 255, 160, + 14, 0, 0, 2, 1, 0, + 2, 128, 1, 0, 85, 128, + 5, 0, 0, 3, 2, 0, + 7, 128, 1, 0, 85, 128, + 10, 0, 228, 160, 14, 0, + 0, 2, 1, 0, 1, 128, + 1, 0, 0, 128, 14, 0, + 0, 2, 1, 0, 2, 128, + 1, 0, 170, 128, 4, 0, + 0, 4, 1, 0, 13, 128, + 1, 0, 0, 128, 9, 0, + 148, 160, 2, 0, 148, 128, + 4, 0, 0, 4, 1, 0, + 7, 128, 1, 0, 85, 128, + 11, 0, 228, 160, 1, 0, + 248, 128, 5, 0, 0, 3, + 1, 0, 7, 224, 1, 0, + 228, 128, 2, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 4, 192, 0, 0, 228, 128, + 24, 0, 228, 160, 9, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 228, 128, 14, 0, + 228, 160, 11, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 0, 128, 243, 0, 85, 160, + 10, 0, 0, 3, 1, 0, + 8, 224, 1, 0, 0, 128, + 243, 0, 170, 160, 9, 0, + 0, 3, 1, 0, 1, 128, + 0, 0, 228, 128, 22, 0, + 228, 160, 9, 0, 0, 3, + 1, 0, 2, 128, 0, 0, + 228, 128, 23, 0, 228, 160, + 9, 0, 0, 3, 0, 0, + 1, 128, 0, 0, 228, 128, + 25, 0, 228, 160, 4, 0, + 0, 4, 0, 0, 3, 192, + 0, 0, 0, 128, 242, 0, + 228, 160, 1, 0, 228, 128, + 1, 0, 0, 2, 0, 0, + 8, 192, 0, 0, 0, 128, + 1, 0, 0, 2, 0, 0, + 8, 224, 0, 0, 255, 160, + 1, 0, 0, 2, 2, 0, + 3, 224, 2, 0, 228, 144, + 255, 255, 0, 0, 83, 72, + 68, 82, 252, 8, 0, 0, + 64, 0, 1, 0, 63, 2, + 0, 0, 89, 8, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 242, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 4, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 50, 32, + 16, 0, 2, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 6, 0, 0, 0, + 38, 0, 0, 11, 0, 208, + 0, 0, 50, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 1, 0, + 0, 0, 86, 21, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 26, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 26, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 16, 0, 0, 7, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 1, 0, 0, 0, 17, 0, + 0, 7, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 3, 0, + 0, 0, 86, 21, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 27, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 27, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 3, 0, 0, 0, 17, 0, + 0, 7, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 3, 0, + 0, 0, 86, 21, 16, 0, + 4, 0, 0, 0, 70, 142, + 32, 6, 0, 0, 0, 0, + 28, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 12, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 6, 0, 0, + 0, 0, 28, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 16, 0, 0, 7, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 18, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 17, 0, + 0, 7, 66, 0, 16, 0, + 1, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 20, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 21, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 0, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 18, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 9, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 29, 0, 0, 10, 114, 0, + 16, 0, 3, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 10, 114, 0, 16, 0, + 3, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 56, 0, 0, 7, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 3, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 4, 0, 0, 0, + 86, 5, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 7, 0, + 0, 0, 50, 0, 0, 10, + 178, 0, 16, 0, 2, 0, + 0, 0, 6, 0, 16, 0, + 2, 0, 0, 0, 70, 136, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 70, 8, + 16, 0, 4, 0, 0, 0, + 50, 0, 0, 10, 114, 0, + 16, 0, 2, 0, 0, 0, + 166, 10, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 70, 3, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 11, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 6, 130, 32, + 16, 0, 0, 0, 0, 0, + 58, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 0, + 16, 0, 1, 0, 0, 0, + 58, 16, 16, 0, 0, 0, + 0, 0, 17, 0, 0, 8, + 18, 0, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 17, 0, + 0, 8, 34, 0, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 16, 0, 0, 0, + 17, 0, 0, 8, 66, 0, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 9, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 12, 0, + 0, 0, 16, 0, 0, 7, + 130, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 68, 0, 0, 5, 130, 0, + 16, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 2, 0, 0, 0, 70, 2, + 16, 0, 4, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 2, 0, + 0, 0, 58, 0, 16, 0, + 2, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 4, 0, 0, 0, 246, 15, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 4, 0, + 0, 0, 16, 0, 0, 7, + 18, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 11, 114, 0, + 16, 0, 5, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 246, 15, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 128, 65, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 50, 0, 0, 11, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 128, 65, 0, + 0, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 16, 0, + 0, 7, 130, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 5, 0, 0, 0, + 70, 2, 16, 0, 5, 0, + 0, 0, 68, 0, 0, 5, + 130, 0, 16, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 114, 0, 16, 0, + 5, 0, 0, 0, 246, 15, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 5, 0, + 0, 0, 16, 0, 0, 7, + 34, 0, 16, 0, 4, 0, + 0, 0, 70, 2, 16, 0, + 5, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 16, 0, 0, 7, 130, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 68, 0, + 0, 5, 130, 0, 16, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 2, 0, 0, 0, + 246, 15, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 16, 0, + 0, 7, 66, 0, 16, 0, + 4, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 52, 0, 0, 10, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 4, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 3, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 47, 0, + 0, 5, 114, 0, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 8, 114, 0, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 0, 0, + 0, 0, 246, 143, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 25, 0, 0, 5, + 114, 0, 16, 0, 0, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 114, 0, 16, 0, + 2, 0, 0, 0, 86, 5, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 10, 0, 0, 0, + 50, 0, 0, 10, 178, 0, + 16, 0, 0, 0, 0, 0, + 6, 0, 16, 0, 0, 0, + 0, 0, 70, 136, 32, 0, + 0, 0, 0, 0, 9, 0, + 0, 0, 70, 8, 16, 0, + 2, 0, 0, 0, 50, 0, + 0, 10, 114, 0, 16, 0, + 0, 0, 0, 0, 166, 10, + 16, 0, 0, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 11, 0, 0, 0, + 70, 3, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 8, + 114, 32, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 0, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 17, 32, + 0, 8, 130, 32, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 14, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 17, 0, 0, 8, + 18, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 17, 0, + 0, 8, 34, 32, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 23, 0, 0, 0, + 17, 0, 0, 8, 66, 32, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 24, 0, + 0, 0, 17, 0, 0, 8, + 130, 32, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 25, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 184, 0, 0, 0, 5, 0, + 0, 0, 8, 0, 0, 0, + 128, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 140, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 7, 0, 0, + 147, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 3, 0, 0, + 156, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 15, 3, 0, 0, + 169, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 4, 0, + 0, 0, 15, 3, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 78, 79, 82, 77, 65, 76, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 66, 76, + 69, 78, 68, 73, 78, 68, + 73, 67, 69, 83, 0, 66, + 76, 69, 78, 68, 87, 69, + 73, 71, 72, 84, 0, 171, + 171, 171, 79, 83, 71, 78, + 132, 0, 0, 0, 4, 0, + 0, 0, 8, 0, 0, 0, + 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 104, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 15, 0, 0, 0, + 110, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 3, 12, 0, 0, + 119, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 15, 0, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SpriteEffect_SpritePixelShader.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SpriteEffect_SpritePixelShader.inc new file mode 100644 index 0000000000000000000000000000000000000000..078a85eabfb30ec9ade7713a6394ea0429dce81e --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SpriteEffect_SpritePixelShader.inc @@ -0,0 +1,133 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_0 + dcl t0 + dcl t1.xy + dcl_2d s0 + texld r0, t1, s0 + mul r0, r0, t0 + mov oC0, r0 + +// approximately 3 instruction slots used (1 texture, 2 arithmetic) +ps_4_0 +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v0.xyzw +dcl_input_ps linear v1.xy +dcl_output o0.xyzw +dcl_temps 1 +sample r0.xyzw, v1.xyxx, t0.xyzw, s0 +mul o0.xyzw, r0.xyzw, v0.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SpriteEffect_SpritePixelShader[] = +{ + 68, 88, 66, 67, 194, 95, + 105, 234, 141, 247, 73, 209, + 137, 241, 142, 29, 26, 223, + 234, 193, 1, 0, 0, 0, + 216, 1, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 184, 0, 0, 0, 84, 1, + 0, 0, 164, 1, 0, 0, + 65, 111, 110, 57, 128, 0, + 0, 0, 128, 0, 0, 0, + 0, 2, 255, 255, 88, 0, + 0, 0, 40, 0, 0, 0, + 0, 0, 40, 0, 0, 0, + 40, 0, 0, 0, 40, 0, + 1, 0, 36, 0, 0, 0, + 40, 0, 0, 0, 0, 0, + 0, 2, 255, 255, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 15, 176, 31, 0, + 0, 2, 0, 0, 0, 128, + 1, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 1, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 0, 0, 15, 128, 0, 0, + 228, 128, 0, 0, 228, 176, + 1, 0, 0, 2, 0, 8, + 15, 128, 0, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 148, 0, 0, 0, + 64, 0, 0, 0, 37, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 1, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 242, 32, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 62, 0, 0, 1, 73, 83, + 71, 78, 72, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 62, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 3, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 79, 83, 71, 78, 44, 0, + 0, 0, 1, 0, 0, 0, + 8, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 83, 86, + 95, 84, 97, 114, 103, 101, + 116, 0, 171, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc b/Kits/DirectXTK/Src/Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc new file mode 100644 index 0000000000000000000000000000000000000000..68e1db17df995ef0fd547c116a24d009fc538a43 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc @@ -0,0 +1,213 @@ +#if 0 +// +// Generated by Microsoft (R) D3D Shader Disassembler +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// SV_Position 0 xyzw 2 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// COLOR 0 xyzw 0 NONE float xyzw +// TEXCOORD 0 xy 1 NONE float xy +// SV_Position 0 xyzw 2 POS float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 4 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + mul r0, v2.y, c2 + mad r0, v2.x, c1, r0 + mad r0, v2.z, c3, r0 + mad r0, v2.w, c4, r0 + mad oPos.xy, r0.w, c0, r0 + mov oPos.zw, r0 + mov oT0, v0 + mov oT1.xy, v1 + +// approximately 8 instruction slots used +vs_4_0 +dcl_constantbuffer CB0[4], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xy +dcl_input v2.xyzw +dcl_output o0.xyzw +dcl_output o1.xy +dcl_output_siv o2.xyzw, position +dcl_temps 1 +mov o0.xyzw, v0.xyzw +mov o1.xy, v1.xyxx +mul r0.xyzw, v2.yyyy, cb0[1].xyzw +mad r0.xyzw, v2.xxxx, cb0[0].xyzw, r0.xyzw +mad r0.xyzw, v2.zzzz, cb0[2].xyzw, r0.xyzw +mad o2.xyzw, v2.wwww, cb0[3].xyzw, r0.xyzw +ret +// Approximately 0 instruction slots used +#endif + +const BYTE SpriteEffect_SpriteVertexShader[] = +{ + 68, 88, 66, 67, 53, 15, + 108, 68, 10, 30, 79, 231, + 153, 9, 61, 10, 198, 154, + 8, 125, 1, 0, 0, 0, + 60, 3, 0, 0, 4, 0, + 0, 0, 48, 0, 0, 0, + 28, 1, 0, 0, 84, 2, + 0, 0, 200, 2, 0, 0, + 65, 111, 110, 57, 228, 0, + 0, 0, 228, 0, 0, 0, + 0, 2, 254, 255, 176, 0, + 0, 0, 52, 0, 0, 0, + 1, 0, 36, 0, 0, 0, + 48, 0, 0, 0, 48, 0, + 0, 0, 36, 0, 1, 0, + 48, 0, 0, 0, 0, 0, + 4, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 2, 254, 255, 31, 0, + 0, 2, 5, 0, 0, 128, + 0, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 1, 128, + 1, 0, 15, 144, 31, 0, + 0, 2, 5, 0, 2, 128, + 2, 0, 15, 144, 5, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 85, 144, 2, 0, + 228, 160, 4, 0, 0, 4, + 0, 0, 15, 128, 2, 0, + 0, 144, 1, 0, 228, 160, + 0, 0, 228, 128, 4, 0, + 0, 4, 0, 0, 15, 128, + 2, 0, 170, 144, 3, 0, + 228, 160, 0, 0, 228, 128, + 4, 0, 0, 4, 0, 0, + 15, 128, 2, 0, 255, 144, + 4, 0, 228, 160, 0, 0, + 228, 128, 4, 0, 0, 4, + 0, 0, 3, 192, 0, 0, + 255, 128, 0, 0, 228, 160, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 12, 192, + 0, 0, 228, 128, 1, 0, + 0, 2, 0, 0, 15, 224, + 0, 0, 228, 144, 1, 0, + 0, 2, 1, 0, 3, 224, + 1, 0, 228, 144, 255, 255, + 0, 0, 83, 72, 68, 82, + 48, 1, 0, 0, 64, 0, + 1, 0, 76, 0, 0, 0, + 89, 0, 0, 4, 70, 142, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 0, 0, 0, 0, 95, 0, + 0, 3, 50, 16, 16, 0, + 1, 0, 0, 0, 95, 0, + 0, 3, 242, 16, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 0, 0, 0, 0, 101, 0, + 0, 3, 50, 32, 16, 0, + 1, 0, 0, 0, 103, 0, + 0, 4, 242, 32, 16, 0, + 2, 0, 0, 0, 1, 0, + 0, 0, 104, 0, 0, 2, + 1, 0, 0, 0, 54, 0, + 0, 5, 242, 32, 16, 0, + 0, 0, 0, 0, 70, 30, + 16, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 50, 32, + 16, 0, 1, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 8, + 242, 0, 16, 0, 0, 0, + 0, 0, 86, 21, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 50, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 6, 16, + 16, 0, 2, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 166, 26, 16, 0, + 2, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 242, 32, + 16, 0, 2, 0, 0, 0, + 246, 31, 16, 0, 2, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 73, 83, 71, 78, + 108, 0, 0, 0, 3, 0, + 0, 0, 8, 0, 0, 0, + 80, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 15, 0, 0, + 86, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 3, 3, 0, 0, + 95, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 2, 0, + 0, 0, 15, 15, 0, 0, + 67, 79, 76, 79, 82, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 83, 86, 95, + 80, 111, 115, 105, 116, 105, + 111, 110, 0, 171, 79, 83, + 71, 78, 108, 0, 0, 0, + 3, 0, 0, 0, 8, 0, + 0, 0, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 86, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 3, 12, + 0, 0, 95, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 15, 0, + 0, 0, 67, 79, 76, 79, + 82, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 83, + 86, 95, 80, 111, 115, 105, + 116, 105, 111, 110, 0, 171 +}; diff --git a/Kits/DirectXTK/Src/Shaders/DGSLEffect.fx b/Kits/DirectXTK/Src/Shaders/DGSLEffect.fx new file mode 100644 index 0000000000000000000000000000000000000000..1bc35d03456f95260951663d73487e90aea34367 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/DGSLEffect.fx @@ -0,0 +1,294 @@ +// 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. + +// +// Based on the Visual Studio 3D Starter Kit +// +// http://aka.ms/vs3dkit +// + +cbuffer MaterialVars : register (b0) +{ + float4 MaterialAmbient; + float4 MaterialDiffuse; + float4 MaterialSpecular; + float4 MaterialEmissive; + float MaterialSpecularPower; +}; + +cbuffer ObjectVars : register(b2) +{ + float4x4 LocalToWorld4x4; + float4x4 LocalToProjected4x4; + float4x4 WorldToLocal4x4; + float4x4 WorldToView4x4; + float4x4 UVTransform4x4; + float3 EyePosition; +}; + +cbuffer BoneVars : register(b4) +{ + float4x3 Bones[72]; +}; + +struct A2V +{ + float4 pos : SV_Position; + float3 normal : NORMAL0; + float4 tangent : TANGENT0; + float2 uv : TEXCOORD0; +}; + +struct A2V_Vc +{ + float4 pos : SV_Position; + float3 normal : NORMAL0; + float4 tangent : TANGENT0; + float4 color : COLOR0; + float2 uv : TEXCOORD0; +}; + +struct A2V_Weights +{ + float4 pos : SV_Position; + float3 normal : NORMAL0; + float4 tangent : TANGENT0; + float2 uv : TEXCOORD0; + uint4 boneIndices : BLENDINDICES0; + float4 blendWeights : BLENDWEIGHT0; +}; + +struct A2V_WeightsVc +{ + float4 pos : SV_Position; + float3 normal : NORMAL0; + float4 tangent : TANGENT0; + float4 color : COLOR0; + float2 uv : TEXCOORD0; + uint4 boneIndices : BLENDINDICES0; + float4 blendWeights : BLENDWEIGHT0; +}; + +struct V2P +{ + float4 pos : SV_POSITION; + float4 diffuse : COLOR; + float2 uv : TEXCOORD0; + float3 worldNorm : TEXCOORD1; + float3 worldPos : TEXCOORD2; + float3 toEye : TEXCOORD3; + float4 tangent : TEXCOORD4; + float3 normal : TEXCOORD5; +}; + + +// Skinning helper functions +void Skin(inout A2V_Weights vertex, uniform int boneCount) +{ + float4x3 skinning = 0; + + [unroll] + for (int i = 0; i < boneCount; i++) + { + skinning += Bones[ vertex.boneIndices[i] ] * vertex.blendWeights[ i ]; + } + + vertex.pos.xyz = mul(vertex.pos, skinning); + vertex.normal = mul(vertex.normal, (float3x3)skinning); + vertex.tangent.xyz = mul((float3)vertex.tangent, (float3x3)skinning); +} + +void SkinVc(inout A2V_WeightsVc vertex, uniform int boneCount) +{ + float4x3 skinning = 0; + + [unroll] + for (int i = 0; i < boneCount; i++) + { + skinning += Bones[vertex.boneIndices[i]] * vertex.blendWeights[i]; + } + + vertex.pos.xyz = mul(vertex.pos, skinning); + vertex.normal = mul(vertex.normal, (float3x3)skinning); + vertex.tangent.xyz = mul((float3)vertex.tangent, (float3x3)skinning); +} + + +// Vertex shader: no per-vertex-color, no skinning +V2P main(A2V vertex) +{ + V2P result; + + float3 wp = mul(vertex.pos, LocalToWorld4x4).xyz; + + // set output data + result.pos = mul(vertex.pos, LocalToProjected4x4); + result.diffuse = MaterialDiffuse; + result.uv = mul(float4(vertex.uv.x, vertex.uv.y, 0, 1), UVTransform4x4).xy; + result.worldNorm = mul(vertex.normal, (float3x3)LocalToWorld4x4); + result.worldPos = wp; + result.toEye = EyePosition - wp; + result.tangent = vertex.tangent; + result.normal = vertex.normal; + + return result; +} + + +// Vertex shader: per-vertex-color, no skinning +V2P mainVc(A2V_Vc vertex) +{ + V2P result; + + float3 wp = mul(vertex.pos, LocalToWorld4x4).xyz; + + // set output data + result.pos = mul(vertex.pos, LocalToProjected4x4); + result.diffuse = vertex.color * MaterialDiffuse; + result.uv = mul(float4(vertex.uv.x, vertex.uv.y, 0, 1), UVTransform4x4).xy; + result.worldNorm = mul(vertex.normal, (float3x3)LocalToWorld4x4); + result.worldPos = wp; + result.toEye = EyePosition - wp; + result.tangent = vertex.tangent; + result.normal = vertex.normal; + + return result; +} + + +// Vertex shader: no per-vertex-color, 1-bone skinning +V2P main1Bones(A2V_Weights vertex) +{ + V2P result; + + Skin(vertex, 1); + + float3 wp = mul(vertex.pos, LocalToWorld4x4).xyz; + + // set output data + result.pos = mul(vertex.pos, LocalToProjected4x4); + result.diffuse = MaterialDiffuse; + result.uv = mul(float4(vertex.uv.x, vertex.uv.y, 0, 1), UVTransform4x4).xy; + result.worldNorm = mul(vertex.normal, (float3x3)LocalToWorld4x4); + result.worldPos = wp; + result.toEye = EyePosition - wp; + result.tangent = vertex.tangent; + result.normal = vertex.normal; + + return result; +} + +// Vertex shader: no per-vertex-color, 2-bone skinning +V2P main2Bones(A2V_Weights vertex) +{ + V2P result; + + Skin(vertex, 2); + + float3 wp = mul(vertex.pos, LocalToWorld4x4).xyz; + + // set output data + result.pos = mul(vertex.pos, LocalToProjected4x4); + result.diffuse = MaterialDiffuse; + result.uv = mul(float4(vertex.uv.x, vertex.uv.y, 0, 1), UVTransform4x4).xy; + result.worldNorm = mul(vertex.normal, (float3x3)LocalToWorld4x4); + result.worldPos = wp; + result.toEye = EyePosition - wp; + result.tangent = vertex.tangent; + result.normal = vertex.normal; + + return result; +} + +// Vertex shader: no per-vertex-color, 4-bone skinning +V2P main4Bones(A2V_Weights vertex) +{ + V2P result; + + Skin(vertex, 4); + + float3 wp = mul(vertex.pos, LocalToWorld4x4).xyz; + + // set output data + result.pos = mul(vertex.pos, LocalToProjected4x4); + result.diffuse = MaterialDiffuse; + result.uv = mul(float4(vertex.uv.x, vertex.uv.y, 0, 1), UVTransform4x4).xy; + result.worldNorm = mul(vertex.normal, (float3x3)LocalToWorld4x4); + result.worldPos = wp; + result.toEye = EyePosition - wp; + result.tangent = vertex.tangent; + result.normal = vertex.normal; + + return result; +} + + +// Vertex shader: per-vertex-color, 1-bone skinning +V2P main1BonesVc(A2V_WeightsVc vertex) +{ + V2P result; + + SkinVc(vertex, 1); + + float3 wp = mul(vertex.pos, LocalToWorld4x4).xyz; + + // set output data + result.pos = mul(vertex.pos, LocalToProjected4x4); + result.diffuse = vertex.color * MaterialDiffuse; + result.uv = mul(float4(vertex.uv.x, vertex.uv.y, 0, 1), UVTransform4x4).xy; + result.worldNorm = mul(vertex.normal, (float3x3)LocalToWorld4x4); + result.worldPos = wp; + result.toEye = EyePosition - wp; + result.tangent = vertex.tangent; + result.normal = vertex.normal; + + return result; +} + +// Vertex shader: per-vertex-color, 2-bone skinning +V2P main2BonesVc(A2V_WeightsVc vertex) +{ + V2P result; + + SkinVc(vertex, 2); + + float3 wp = mul(vertex.pos, LocalToWorld4x4).xyz; + + // set output data + result.pos = mul(vertex.pos, LocalToProjected4x4); + result.diffuse = vertex.color * MaterialDiffuse; + result.uv = mul(float4(vertex.uv.x, vertex.uv.y, 0, 1), UVTransform4x4).xy; + result.worldNorm = mul(vertex.normal, (float3x3)LocalToWorld4x4); + result.worldPos = wp; + result.toEye = EyePosition - wp; + result.tangent = vertex.tangent; + result.normal = vertex.normal; + + return result; +} + +// Vertex shader: per-vertex-color, 4-bone skinning +V2P main4BonesVc(A2V_WeightsVc vertex) +{ + V2P result; + + SkinVc(vertex, 4); + + float3 wp = mul(vertex.pos, LocalToWorld4x4).xyz; + + // set output data + result.pos = mul(vertex.pos, LocalToProjected4x4); + result.diffuse = vertex.color * MaterialDiffuse; + result.uv = mul(float4(vertex.uv.x, vertex.uv.y, 0, 1), UVTransform4x4).xy; + result.worldNorm = mul(vertex.normal, (float3x3)LocalToWorld4x4); + result.worldPos = wp; + result.toEye = EyePosition - wp; + result.tangent = vertex.tangent; + result.normal = vertex.normal; + + return result; +} \ No newline at end of file diff --git a/Kits/DirectXTK/Src/Shaders/DGSLLambert.hlsl b/Kits/DirectXTK/Src/Shaders/DGSLLambert.hlsl new file mode 100644 index 0000000000000000000000000000000000000000..a9551a00806f985495b8901c9daa7bd79e4d2f5f --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/DGSLLambert.hlsl @@ -0,0 +1,178 @@ +// 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. + +// +// This file was generated by exporting HLSL from Visual Studio's default "Lambert" material, and then modified to handle both texture scenarios, multiple lights, and work with FL 9.x +// \Common7\IDE\Extensions\Microsoft\VsGraphics\Assets\Effects\Lambert.dgsl +// + +Texture2D Texture1 : register( t0 ); + +SamplerState TexSampler : register( s0 ); + +cbuffer MaterialVars : register (b0) +{ + float4 MaterialAmbient; + float4 MaterialDiffuse; + float4 MaterialSpecular; + float4 MaterialEmissive; + float MaterialSpecularPower; +}; + +cbuffer LightVars : register (b1) +{ + float4 AmbientLight; + float4 LightColor[4]; + float4 LightAttenuation[4]; + float3 LightDirection[4]; + float LightSpecularIntensity[4]; + uint IsPointLight[4]; + uint ActiveLights; +} + +cbuffer ObjectVars : register(b2) +{ + float4x4 LocalToWorld4x4; + float4x4 LocalToProjected4x4; + float4x4 WorldToLocal4x4; + float4x4 WorldToView4x4; + float4x4 UVTransform4x4; + float3 EyePosition; +}; + +cbuffer MiscVars : register(b3) +{ + float ViewportWidth; + float ViewportHeight; + float Time; +}; + +struct V2P +{ + float4 pos : SV_POSITION; + float4 diffuse : COLOR; + float2 uv : TEXCOORD0; + float3 worldNorm : TEXCOORD1; + float3 worldPos : TEXCOORD2; + float3 toEye : TEXCOORD3; + float4 tangent : TEXCOORD4; + float3 normal : TEXCOORD5; +}; + +struct P2F +{ + float4 fragment : SV_Target; +}; + +// +// lambert lighting function +// +float3 LambertLighting( + float3 lightNormal, + float3 surfaceNormal, + float3 lightColor, + float3 pixelColor + ) +{ + // compute amount of contribution per light + float diffuseAmount = saturate(dot(lightNormal, surfaceNormal)); + float3 diffuse = diffuseAmount * lightColor * pixelColor; + return diffuse; +} + +// +// combines a float3 RGB value with an alpha value into a float4 +// +float4 CombineRGBWithAlpha(float3 rgb, float a) +{ + return float4(rgb.r, rgb.g, rgb.b, a); +} + +P2F main(V2P pixel) +{ + P2F result; + + float3 worldNormal = normalize(pixel.worldNorm); + + float3 local3 = MaterialAmbient.rgb * AmbientLight.rgb; + [unroll] + for (int i = 0; i < 4; i++) + { + local3 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb); + } + + local3 = saturate(local3); + result.fragment = CombineRGBWithAlpha(local3, pixel.diffuse.a); + + return result; +} + +P2F mainTk(V2P pixel) +{ + P2F result; + + float3 worldNormal = normalize(pixel.worldNorm); + + float3 local3 = MaterialAmbient.rgb * AmbientLight.rgb; + [unroll] + for (int i = 0; i < 4; i++) + { + local3 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb); + } + + local3 = saturate(local3); + result.fragment = CombineRGBWithAlpha(local3, pixel.diffuse.a); + + if (result.fragment.a == 0.0f) discard; + + return result; +} + +P2F mainTx(V2P pixel) +{ + P2F result; + + float3 worldNormal = normalize(pixel.worldNorm); + + float3 local3 = MaterialAmbient.rgb * AmbientLight.rgb; + [unroll] + for (int i = 0; i < 4; i++) + { + local3 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb); + } + + local3 = saturate(local3); + float3 local4 = Texture1.Sample(TexSampler, pixel.uv).rgb * local3; + float local5 = Texture1.Sample(TexSampler, pixel.uv).a * pixel.diffuse.a; + result.fragment = CombineRGBWithAlpha(local4, local5); + + return result; +} + +P2F mainTxTk(V2P pixel) +{ + P2F result; + + float3 worldNormal = normalize(pixel.worldNorm); + + float3 local3 = MaterialAmbient.rgb * AmbientLight.rgb; + [unroll] + for (int i = 0; i < 4; i++) + { + local3 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb); + } + + local3 = saturate(local3); + float3 local4 = Texture1.Sample(TexSampler, pixel.uv).rgb * local3; + float local5 = Texture1.Sample(TexSampler, pixel.uv).a * pixel.diffuse.a; + result.fragment = CombineRGBWithAlpha(local4, local5); + + if (result.fragment.a == 0.0f) discard; + + return result; +} + diff --git a/Kits/DirectXTK/Src/Shaders/DGSLPhong.hlsl b/Kits/DirectXTK/Src/Shaders/DGSLPhong.hlsl new file mode 100644 index 0000000000000000000000000000000000000000..cb3cd28bfcb91dca99bfc863766fc448b3f00d28 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/DGSLPhong.hlsl @@ -0,0 +1,211 @@ +// 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. + +// +// This file was generated by exporting HLSL from Visual Studio's default "Phong" material, and then modified to handle no texture scenarios, multiple lights, and work with FL 9.x +// \Common7\IDE\Extensions\Microsoft\VsGraphics\Assets\Effects\Phong.dgsl +// + +Texture2D Texture1 : register( t0 ); + +SamplerState TexSampler : register( s0 ); + +cbuffer MaterialVars : register (b0) +{ + float4 MaterialAmbient; + float4 MaterialDiffuse; + float4 MaterialSpecular; + float4 MaterialEmissive; + float MaterialSpecularPower; +}; + +cbuffer LightVars : register (b1) +{ + float4 AmbientLight; + float4 LightColor[4]; + float4 LightAttenuation[4]; + float3 LightDirection[4]; + float LightSpecularIntensity[4]; + uint IsPointLight[4]; + uint ActiveLights; +} + +cbuffer ObjectVars : register(b2) +{ + float4x4 LocalToWorld4x4; + float4x4 LocalToProjected4x4; + float4x4 WorldToLocal4x4; + float4x4 WorldToView4x4; + float4x4 UVTransform4x4; + float3 EyePosition; +}; + +cbuffer MiscVars : register(b3) +{ + float ViewportWidth; + float ViewportHeight; + float Time; +}; + +struct V2P +{ + float4 pos : SV_POSITION; + float4 diffuse : COLOR; + float2 uv : TEXCOORD0; + float3 worldNorm : TEXCOORD1; + float3 worldPos : TEXCOORD2; + float3 toEye : TEXCOORD3; + float4 tangent : TEXCOORD4; + float3 normal : TEXCOORD5; +}; + +struct P2F +{ + float4 fragment : SV_Target; +}; + +// +// lambert lighting function +// +float3 LambertLighting( + float3 lightNormal, + float3 surfaceNormal, + float3 lightColor, + float3 pixelColor + ) +{ + // compute amount of contribution per light + float diffuseAmount = saturate(dot(lightNormal, surfaceNormal)); + float3 diffuse = diffuseAmount * lightColor * pixelColor; + return diffuse; +} + +// +// specular contribution function +// +float3 SpecularContribution( + float3 toEye, + float3 lightNormal, + float3 surfaceNormal, + float3 materialSpecularColor, + float materialSpecularPower, + float lightSpecularIntensity, + float3 lightColor + ) +{ + // compute specular contribution + float3 vHalf = normalize(lightNormal + toEye); + float specularAmount = saturate(dot(surfaceNormal, vHalf)); + specularAmount = pow(specularAmount, max(materialSpecularPower,0.0001f)) * lightSpecularIntensity; + float3 specular = materialSpecularColor * lightColor * specularAmount; + + return specular; +} + +// +// combines a float3 RGB value with an alpha value into a float4 +// +float4 CombineRGBWithAlpha(float3 rgb, float a) +{ + return float4(rgb.r, rgb.g, rgb.b, a); +} + +P2F main(V2P pixel) +{ + P2F result; + + float3 worldNormal = normalize(pixel.worldNorm); + float3 toEyeVector = normalize(pixel.toEye); + + float3 local1 = MaterialAmbient.rgb * AmbientLight.rgb; + float3 local4 = 0; + [unroll] + for (int i = 0; i < 3; i++) + { + local1 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb); + local4 += SpecularContribution(toEyeVector, LightDirection[i], worldNormal, MaterialSpecular.rgb, MaterialSpecularPower, LightSpecularIntensity[i], LightColor[i].rgb); + } + + local1 = saturate(local1); + result.fragment = CombineRGBWithAlpha(local1 + local4, pixel.diffuse.a); + + return result; +} + +P2F mainTk(V2P pixel) +{ + P2F result; + + float3 worldNormal = normalize(pixel.worldNorm); + float3 toEyeVector = normalize(pixel.toEye); + + float3 local1 = MaterialAmbient.rgb * AmbientLight.rgb; + float3 local4 = 0; + [unroll] + for (int i = 0; i < 3; i++) + { + local1 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb); + local4 += SpecularContribution(toEyeVector, LightDirection[i], worldNormal, MaterialSpecular.rgb, MaterialSpecularPower, LightSpecularIntensity[i], LightColor[i].rgb); + } + + local1 = saturate(local1); + result.fragment = CombineRGBWithAlpha(local1 + local4, pixel.diffuse.a); + + if (result.fragment.a == 0.0f) discard; + + return result; +} + +P2F mainTx(V2P pixel) +{ + P2F result; + + float3 worldNormal = normalize(pixel.worldNorm); + float3 toEyeVector = normalize(pixel.toEye); + + float3 local1 = MaterialAmbient.rgb * AmbientLight.rgb; + float3 local4 = 0; + [unroll] + for (int i = 0; i < 3; i++) + { + local1 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb); + local4 += SpecularContribution(toEyeVector, LightDirection[i], worldNormal, MaterialSpecular.rgb, MaterialSpecularPower, LightSpecularIntensity[i], LightColor[i].rgb); + } + + local1 = saturate(local1); + float3 local5 = mad(local1, Texture1.Sample(TexSampler, pixel.uv).rgb, local4); + float local6 = Texture1.Sample(TexSampler, pixel.uv).a * pixel.diffuse.a; + result.fragment = CombineRGBWithAlpha(local5, local6); + + return result; +} + +P2F mainTxTk(V2P pixel) +{ + P2F result; + + float3 worldNormal = normalize(pixel.worldNorm); + float3 toEyeVector = normalize(pixel.toEye); + + float3 local1 = MaterialAmbient.rgb * AmbientLight.rgb; + float3 local4 = 0; + [unroll] + for (int i = 0; i < 3; i++) + { + local1 += LambertLighting(LightDirection[i], worldNormal, LightColor[i].rgb, pixel.diffuse.rgb); + local4 += SpecularContribution(toEyeVector, LightDirection[i], worldNormal, MaterialSpecular.rgb, MaterialSpecularPower, LightSpecularIntensity[i], LightColor[i].rgb); + } + + local1 = saturate(local1); + float3 local5 = mad(local1, Texture1.Sample(TexSampler, pixel.uv).rgb, local4); + float local6 = Texture1.Sample(TexSampler, pixel.uv).a * pixel.diffuse.a; + result.fragment = CombineRGBWithAlpha(local5, local6); + + if (result.fragment.a == 0.0f) discard; + + return result; +} diff --git a/Kits/DirectXTK/Src/Shaders/DGSLUnlit.hlsl b/Kits/DirectXTK/Src/Shaders/DGSLUnlit.hlsl new file mode 100644 index 0000000000000000000000000000000000000000..37ac9b98f0dd9ab5fa9cd585b8c10cafbd98f013 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/DGSLUnlit.hlsl @@ -0,0 +1,153 @@ +// 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. + +// +// This file was generated by exporting HLSL from Visual Studio's default "Unlit" material, and then modified to handle both texture scenarios +// \Common7\IDE\Extensions\Microsoft\VsGraphics\Assets\Effects\Unlit.dgsl +// + +Texture2D Texture1 : register( t0 ); + +SamplerState TexSampler : register( s0 ); + +cbuffer MaterialVars : register (b0) +{ + float4 MaterialAmbient; + float4 MaterialDiffuse; + float4 MaterialSpecular; + float4 MaterialEmissive; + float MaterialSpecularPower; +}; + +cbuffer LightVars : register (b1) +{ + float4 AmbientLight; + float4 LightColor[4]; + float4 LightAttenuation[4]; + float3 LightDirection[4]; + float LightSpecularIntensity[4]; + uint IsPointLight[4]; + uint ActiveLights; +} + +cbuffer ObjectVars : register(b2) +{ + float4x4 LocalToWorld4x4; + float4x4 LocalToProjected4x4; + float4x4 WorldToLocal4x4; + float4x4 WorldToView4x4; + float4x4 UVTransform4x4; + float3 EyePosition; +}; + +cbuffer MiscVars : register(b3) +{ + float ViewportWidth; + float ViewportHeight; + float Time; +}; + +struct V2P +{ + float4 pos : SV_POSITION; + float4 diffuse : COLOR; + float2 uv : TEXCOORD0; + float3 worldNorm : TEXCOORD1; + float3 worldPos : TEXCOORD2; + float3 toEye : TEXCOORD3; + float4 tangent : TEXCOORD4; + float3 normal : TEXCOORD5; +}; + +struct P2F +{ + float4 fragment : SV_Target; +}; + +// +// combines a float3 RGB value with an alpha value into a float4 +// +float4 CombineRGBWithAlpha(float3 rgb, float a) +{ + return float4(rgb.r, rgb.g, rgb.b, a); +} + +P2F main(V2P pixel) +{ + P2F result; + + result.fragment = pixel.diffuse; + + return result; +} + +P2F mainTk(V2P pixel) +{ + P2F result; + + result.fragment = pixel.diffuse; + if (result.fragment.a == 0.0f) discard; + + return result; +} + +P2F mainTx(V2P pixel) +{ + P2F result; + + // we need to normalize incoming vectors + float3 surfaceNormal = normalize(pixel.normal); + float3 surfaceTangent = normalize(pixel.tangent.xyz); + float3 worldNormal = normalize(pixel.worldNorm); + float3 toEyeVector = normalize(pixel.toEye); + + // construct tangent matrix + float3x3 localToTangent = transpose(float3x3(surfaceTangent, cross(surfaceNormal, surfaceTangent) * pixel.tangent.w, surfaceNormal)); + float3x3 worldToTangent = mul((float3x3)WorldToLocal4x4, localToTangent); + + // transform some vectors into tangent space + float3 tangentLightDir = normalize(mul(LightDirection[0], worldToTangent)); + float3 tangentToEyeVec = normalize(mul(toEyeVector, worldToTangent)); + + // BEGIN GENERATED CODE + float3 local3 = pixel.diffuse.rgb * Texture1.Sample(TexSampler, pixel.uv).rgb; + float local4 = pixel.diffuse.a * Texture1.Sample(TexSampler, pixel.uv).a; + result.fragment = CombineRGBWithAlpha(local3, local4); + // END GENERATED CODE + + return result; +} + +P2F mainTxTk(V2P pixel) +{ + P2F result; + + // we need to normalize incoming vectors + float3 surfaceNormal = normalize(pixel.normal); + float3 surfaceTangent = normalize(pixel.tangent.xyz); + float3 worldNormal = normalize(pixel.worldNorm); + float3 toEyeVector = normalize(pixel.toEye); + + // construct tangent matrix + float3x3 localToTangent = transpose(float3x3(surfaceTangent, cross(surfaceNormal, surfaceTangent) * pixel.tangent.w, surfaceNormal)); + float3x3 worldToTangent = mul((float3x3)WorldToLocal4x4, localToTangent); + + // transform some vectors into tangent space + float3 tangentLightDir = normalize(mul(LightDirection[0], worldToTangent)); + float3 tangentToEyeVec = normalize(mul(toEyeVector, worldToTangent)); + + // BEGIN GENERATED CODE + float3 local3 = pixel.diffuse.rgb * Texture1.Sample(TexSampler, pixel.uv).rgb; + float local4 = pixel.diffuse.a * Texture1.Sample(TexSampler, pixel.uv).a; + result.fragment = CombineRGBWithAlpha(local3, local4); + // END GENERATED CODE + + if (result.fragment.a == 0.0f) discard; + + return result; +} + diff --git a/Kits/DirectXTK/Src/Shaders/DualTextureEffect.fx b/Kits/DirectXTK/Src/Shaders/DualTextureEffect.fx new file mode 100644 index 0000000000000000000000000000000000000000..dbf96424322f449d4fb4dd504d6272bcf4ea9816 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/DualTextureEffect.fx @@ -0,0 +1,119 @@ +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://create.msdn.com/en-US/education/catalog/sample/stock_effects + + +Texture2D Texture : register(t0); +Texture2D Texture2 : register(t1); + +sampler Sampler : register(s0); +sampler Sampler2 : register(s1); + + +cbuffer Parameters : register(b0) +{ + float4 DiffuseColor : packoffset(c0); + float3 FogColor : packoffset(c1); + float4 FogVector : packoffset(c2); + float4x4 WorldViewProj : packoffset(c3); +}; + + +#include "Structures.fxh" +#include "Common.fxh" + + +// Vertex shader: basic. +VSOutputTx2 VSDualTexture(VSInputTx2 vin) +{ + VSOutputTx2 vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + vout.TexCoord2 = vin.TexCoord2; + + return vout; +} + + +// Vertex shader: no fog. +VSOutputTx2NoFog VSDualTextureNoFog(VSInputTx2 vin) +{ + VSOutputTx2NoFog vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParamsNoFog; + + vout.TexCoord = vin.TexCoord; + vout.TexCoord2 = vin.TexCoord2; + + return vout; +} + + +// Vertex shader: vertex color. +VSOutputTx2 VSDualTextureVc(VSInputTx2Vc vin) +{ + VSOutputTx2 vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + vout.TexCoord2 = vin.TexCoord2; + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Vertex shader: vertex color, no fog. +VSOutputTx2NoFog VSDualTextureVcNoFog(VSInputTx2Vc vin) +{ + VSOutputTx2NoFog vout; + + CommonVSOutput cout = ComputeCommonVSOutput(vin.Position); + SetCommonVSOutputParamsNoFog; + + vout.TexCoord = vin.TexCoord; + vout.TexCoord2 = vin.TexCoord2; + vout.Diffuse *= vin.Color; + + return vout; +} + + +// Pixel shader: basic. +float4 PSDualTexture(PSInputTx2 pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord); + float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2); + + color.rgb *= 2; + color *= overlay * pin.Diffuse; + + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: no fog. +float4 PSDualTextureNoFog(PSInputTx2NoFog pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord); + float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2); + + color.rgb *= 2; + color *= overlay * pin.Diffuse; + + return color; +} diff --git a/Kits/DirectXTK/Src/Shaders/EnvironmentMapEffect.fx b/Kits/DirectXTK/Src/Shaders/EnvironmentMapEffect.fx new file mode 100644 index 0000000000000000000000000000000000000000..6dfa2906491ecd5e36f86dda49c6dc5e49a8f962 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/EnvironmentMapEffect.fx @@ -0,0 +1,166 @@ +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://create.msdn.com/en-US/education/catalog/sample/stock_effects + + +Texture2D Texture : register(t0); +TextureCube EnvironmentMap : register(t1); + +sampler Sampler : register(s0); +sampler EnvMapSampler : register(s1); + + +cbuffer Parameters : register(b0) +{ + float3 EnvironmentMapSpecular : packoffset(c0); + float EnvironmentMapAmount : packoffset(c1.x); + float FresnelFactor : packoffset(c1.y); + + float4 DiffuseColor : packoffset(c2); + float3 EmissiveColor : packoffset(c3); + + float3 LightDirection[3] : packoffset(c4); + float3 LightDiffuseColor[3] : packoffset(c7); + + float3 EyePosition : packoffset(c10); + + float3 FogColor : packoffset(c11); + float4 FogVector : packoffset(c12); + + float4x4 World : packoffset(c13); + float3x3 WorldInverseTranspose : packoffset(c17); + float4x4 WorldViewProj : packoffset(c20); +}; + + +// We don't use these parameters, but Lighting.fxh won't compile without them. +#define SpecularPower 0 +#define SpecularColor 0 +#define LightSpecularColor float3(0, 0, 0) + + +#include "Structures.fxh" +#include "Common.fxh" +#include "Lighting.fxh" + + +float ComputeFresnelFactor(float3 eyeVector, float3 worldNormal) +{ + float viewAngle = dot(eyeVector, worldNormal); + + return pow(max(1 - abs(viewAngle), 0), FresnelFactor) * EnvironmentMapAmount; +} + + +VSOutputTxEnvMap ComputeEnvMapVSOutput(VSInputNmTx vin, uniform bool useFresnel, uniform int numLights) +{ + VSOutputTxEnvMap vout; + + float4 pos_ws = mul(vin.Position, World); + float3 eyeVector = normalize(EyePosition - pos_ws.xyz); + float3 worldNormal = normalize(mul(vin.Normal, WorldInverseTranspose)); + + ColorPair lightResult = ComputeLights(eyeVector, worldNormal, numLights); + + vout.PositionPS = mul(vin.Position, WorldViewProj); + vout.Diffuse = float4(lightResult.Diffuse, DiffuseColor.a); + + if (useFresnel) + vout.Specular.rgb = ComputeFresnelFactor(eyeVector, worldNormal); + else + vout.Specular.rgb = EnvironmentMapAmount; + + vout.Specular.a = ComputeFogFactor(vin.Position); + vout.TexCoord = vin.TexCoord; + vout.EnvCoord = reflect(-eyeVector, worldNormal); + + return vout; +} + + +// Vertex shader: basic. +VSOutputTxEnvMap VSEnvMap(VSInputNmTx vin) +{ + return ComputeEnvMapVSOutput(vin, false, 3); +} + + +// Vertex shader: fresnel. +VSOutputTxEnvMap VSEnvMapFresnel(VSInputNmTx vin) +{ + return ComputeEnvMapVSOutput(vin, true, 3); +} + + +// Vertex shader: one light. +VSOutputTxEnvMap VSEnvMapOneLight(VSInputNmTx vin) +{ + return ComputeEnvMapVSOutput(vin, false, 1); +} + + +// Vertex shader: one light, fresnel. +VSOutputTxEnvMap VSEnvMapOneLightFresnel(VSInputNmTx vin) +{ + return ComputeEnvMapVSOutput(vin, true, 1); +} + + +// Pixel shader: basic. +float4 PSEnvMap(PSInputTxEnvMap pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + float4 envmap = EnvironmentMap.Sample(EnvMapSampler, pin.EnvCoord) * color.a; + + color.rgb = lerp(color.rgb, envmap.rgb, pin.Specular.rgb); + + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: no fog. +float4 PSEnvMapNoFog(PSInputTxEnvMap pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + float4 envmap = EnvironmentMap.Sample(EnvMapSampler, pin.EnvCoord) * color.a; + + color.rgb = lerp(color.rgb, envmap.rgb, pin.Specular.rgb); + + return color; +} + + +// Pixel shader: specular. +float4 PSEnvMapSpecular(PSInputTxEnvMap pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + float4 envmap = EnvironmentMap.Sample(EnvMapSampler, pin.EnvCoord) * color.a; + + color.rgb = lerp(color.rgb, envmap.rgb, pin.Specular.rgb); + color.rgb += EnvironmentMapSpecular * envmap.a; + + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: specular, no fog. +float4 PSEnvMapSpecularNoFog(PSInputTxEnvMap pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + float4 envmap = EnvironmentMap.Sample(EnvMapSampler, pin.EnvCoord) * color.a; + + color.rgb = lerp(color.rgb, envmap.rgb, pin.Specular.rgb); + color.rgb += EnvironmentMapSpecular * envmap.a; + + return color; +} diff --git a/Kits/DirectXTK/Src/Shaders/Lighting.fxh b/Kits/DirectXTK/Src/Shaders/Lighting.fxh new file mode 100644 index 0000000000000000000000000000000000000000..d5b8452c07c87c20556897c184157d44dfa26969 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Lighting.fxh @@ -0,0 +1,97 @@ +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://create.msdn.com/en-US/education/catalog/sample/stock_effects + + +struct ColorPair +{ + float3 Diffuse; + float3 Specular; +}; + + +ColorPair ComputeLights(float3 eyeVector, float3 worldNormal, uniform int numLights) +{ + float3x3 lightDirections = 0; + float3x3 lightDiffuse = 0; + float3x3 lightSpecular = 0; + float3x3 halfVectors = 0; + + [unroll] + for (int i = 0; i < numLights; i++) + { + lightDirections[i] = LightDirection[i]; + lightDiffuse[i] = LightDiffuseColor[i]; + lightSpecular[i] = LightSpecularColor[i]; + + halfVectors[i] = normalize(eyeVector - lightDirections[i]); + } + + float3 dotL = mul(-lightDirections, worldNormal); + float3 dotH = mul(halfVectors, worldNormal); + + float3 zeroL = step(0, dotL); + + float3 diffuse = zeroL * dotL; + float3 specular = pow(max(dotH, 0) * zeroL, SpecularPower); + + ColorPair result; + + result.Diffuse = mul(diffuse, lightDiffuse) * DiffuseColor.rgb + EmissiveColor; + result.Specular = mul(specular, lightSpecular) * SpecularColor; + + return result; +} + + +CommonVSOutput ComputeCommonVSOutputWithLighting(float4 position, float3 normal, uniform int numLights) +{ + CommonVSOutput vout; + + float4 pos_ws = mul(position, World); + float3 eyeVector = normalize(EyePosition - pos_ws.xyz); + float3 worldNormal = normalize(mul(normal, WorldInverseTranspose)); + + ColorPair lightResult = ComputeLights(eyeVector, worldNormal, numLights); + + vout.Pos_ps = mul(position, WorldViewProj); + vout.Diffuse = float4(lightResult.Diffuse, DiffuseColor.a); + vout.Specular = lightResult.Specular; + vout.FogFactor = ComputeFogFactor(position); + + return vout; +} + + +struct CommonVSOutputPixelLighting +{ + float4 Pos_ps; + float3 Pos_ws; + float3 Normal_ws; + float FogFactor; +}; + + +CommonVSOutputPixelLighting ComputeCommonVSOutputPixelLighting(float4 position, float3 normal) +{ + CommonVSOutputPixelLighting vout; + + vout.Pos_ps = mul(position, WorldViewProj); + vout.Pos_ws = mul(position, World).xyz; + vout.Normal_ws = normalize(mul(normal, WorldInverseTranspose)); + vout.FogFactor = ComputeFogFactor(position); + + return vout; +} + + +#define SetCommonVSOutputParamsPixelLighting \ + vout.PositionPS = cout.Pos_ps; \ + vout.PositionWS = float4(cout.Pos_ws, cout.FogFactor); \ + vout.NormalWS = cout.Normal_ws; diff --git a/Kits/DirectXTK/Src/Shaders/SkinnedEffect.fx b/Kits/DirectXTK/Src/Shaders/SkinnedEffect.fx new file mode 100644 index 0000000000000000000000000000000000000000..c961a82901d31fd9a55bccf4940035dc6b7c579e --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/SkinnedEffect.fx @@ -0,0 +1,246 @@ +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://create.msdn.com/en-US/education/catalog/sample/stock_effects + + +Texture2D Texture : register(t0); +sampler Sampler : register(s0); + + +cbuffer Parameters : register(b0) +{ + float4 DiffuseColor : packoffset(c0); + float3 EmissiveColor : packoffset(c1); + float3 SpecularColor : packoffset(c2); + float SpecularPower : packoffset(c2.w); + + float3 LightDirection[3] : packoffset(c3); + float3 LightDiffuseColor[3] : packoffset(c6); + float3 LightSpecularColor[3] : packoffset(c9); + + float3 EyePosition : packoffset(c12); + + float3 FogColor : packoffset(c13); + float4 FogVector : packoffset(c14); + + float4x4 World : packoffset(c15); + float3x3 WorldInverseTranspose : packoffset(c19); + float4x4 WorldViewProj : packoffset(c22); + + float4x3 Bones[72] : packoffset(c26); +}; + + +#include "Structures.fxh" +#include "Common.fxh" +#include "Lighting.fxh" + + +void Skin(inout VSInputNmTxWeights vin, uniform int boneCount) +{ + float4x3 skinning = 0; + + [unroll] + for (int i = 0; i < boneCount; i++) + { + skinning += Bones[vin.Indices[i]] * vin.Weights[i]; + } + + vin.Position.xyz = mul(vin.Position, skinning); + vin.Normal = mul(vin.Normal, (float3x3)skinning); +} + + +// Vertex shader: vertex lighting, one bone. +VSOutputTx VSSkinnedVertexLightingOneBone(VSInputNmTxWeights vin) +{ + VSOutputTx vout; + + Skin(vin, 1); + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: vertex lighting, two bones. +VSOutputTx VSSkinnedVertexLightingTwoBones(VSInputNmTxWeights vin) +{ + VSOutputTx vout; + + Skin(vin, 2); + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: vertex lighting, four bones. +VSOutputTx VSSkinnedVertexLightingFourBones(VSInputNmTxWeights vin) +{ + VSOutputTx vout; + + Skin(vin, 4); + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 3); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: one light, one bone. +VSOutputTx VSSkinnedOneLightOneBone(VSInputNmTxWeights vin) +{ + VSOutputTx vout; + + Skin(vin, 1); + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: one light, two bones. +VSOutputTx VSSkinnedOneLightTwoBones(VSInputNmTxWeights vin) +{ + VSOutputTx vout; + + Skin(vin, 2); + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: one light, four bones. +VSOutputTx VSSkinnedOneLightFourBones(VSInputNmTxWeights vin) +{ + VSOutputTx vout; + + Skin(vin, 4); + + CommonVSOutput cout = ComputeCommonVSOutputWithLighting(vin.Position, vin.Normal, 1); + SetCommonVSOutputParams; + + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: pixel lighting, one bone. +VSOutputPixelLightingTx VSSkinnedPixelLightingOneBone(VSInputNmTxWeights vin) +{ + VSOutputPixelLightingTx vout; + + Skin(vin, 1); + + CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); + SetCommonVSOutputParamsPixelLighting; + + vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: pixel lighting, two bones. +VSOutputPixelLightingTx VSSkinnedPixelLightingTwoBones(VSInputNmTxWeights vin) +{ + VSOutputPixelLightingTx vout; + + Skin(vin, 2); + + CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); + SetCommonVSOutputParamsPixelLighting; + + vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Vertex shader: pixel lighting, four bones. +VSOutputPixelLightingTx VSSkinnedPixelLightingFourBones(VSInputNmTxWeights vin) +{ + VSOutputPixelLightingTx vout; + + Skin(vin, 4); + + CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal); + SetCommonVSOutputParamsPixelLighting; + + vout.Diffuse = float4(1, 1, 1, DiffuseColor.a); + vout.TexCoord = vin.TexCoord; + + return vout; +} + + +// Pixel shader: vertex lighting. +float4 PSSkinnedVertexLighting(PSInputTx pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + AddSpecular(color, pin.Specular.rgb); + ApplyFog(color, pin.Specular.w); + + return color; +} + + +// Pixel shader: vertex lighting, no fog. +float4 PSSkinnedVertexLightingNoFog(PSInputTx pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + AddSpecular(color, pin.Specular.rgb); + + return color; +} + + +// Pixel shader: pixel lighting. +float4 PSSkinnedPixelLighting(PSInputPixelLightingTx pin) : SV_Target0 +{ + float4 color = Texture.Sample(Sampler, pin.TexCoord) * pin.Diffuse; + + float3 eyeVector = normalize(EyePosition - pin.PositionWS.xyz); + float3 worldNormal = normalize(pin.NormalWS); + + ColorPair lightResult = ComputeLights(eyeVector, worldNormal, 3); + + color.rgb *= lightResult.Diffuse; + + AddSpecular(color, lightResult.Specular); + ApplyFog(color, pin.PositionWS.w); + + return color; +} diff --git a/Kits/DirectXTK/Src/Shaders/SpriteEffect.fx b/Kits/DirectXTK/Src/Shaders/SpriteEffect.fx new file mode 100644 index 0000000000000000000000000000000000000000..d294fd643d5cf845dcdd87940e52b657ad819bd0 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/SpriteEffect.fx @@ -0,0 +1,34 @@ +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://create.msdn.com/en-US/education/catalog/sample/stock_effects + + +Texture2D Texture : register(t0); +sampler TextureSampler : register(s0); + + +cbuffer Parameters : register(b0) +{ + row_major float4x4 MatrixTransform; +}; + + +void SpriteVertexShader(inout float4 color : COLOR0, + inout float2 texCoord : TEXCOORD0, + inout float4 position : SV_Position) +{ + position = mul(position, MatrixTransform); +} + + +float4 SpritePixelShader(float4 color : COLOR0, + float2 texCoord : TEXCOORD0) : SV_Target0 +{ + return Texture.Sample(TextureSampler, texCoord) * color; +} diff --git a/Kits/DirectXTK/Src/Shaders/Structures.fxh b/Kits/DirectXTK/Src/Shaders/Structures.fxh new file mode 100644 index 0000000000000000000000000000000000000000..e7815b523730705b87a492c743891f61b7e7e863 --- /dev/null +++ b/Kits/DirectXTK/Src/Shaders/Structures.fxh @@ -0,0 +1,229 @@ +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://create.msdn.com/en-US/education/catalog/sample/stock_effects + + +// Vertex shader input structures. + +struct VSInput +{ + float4 Position : SV_Position; +}; + +struct VSInputVc +{ + float4 Position : SV_Position; + float4 Color : COLOR; +}; + +struct VSInputTx +{ + float4 Position : SV_Position; + float2 TexCoord : TEXCOORD0; +}; + +struct VSInputTxVc +{ + float4 Position : SV_Position; + float2 TexCoord : TEXCOORD0; + float4 Color : COLOR; +}; + +struct VSInputNm +{ + float4 Position : SV_Position; + float3 Normal : NORMAL; +}; + +struct VSInputNmVc +{ + float4 Position : SV_Position; + float3 Normal : NORMAL; + float4 Color : COLOR; +}; + +struct VSInputNmTx +{ + float4 Position : SV_Position; + float3 Normal : NORMAL; + float2 TexCoord : TEXCOORD0; +}; + +struct VSInputNmTxVc +{ + float4 Position : SV_Position; + float3 Normal : NORMAL; + float2 TexCoord : TEXCOORD0; + float4 Color : COLOR; +}; + +struct VSInputTx2 +{ + float4 Position : SV_Position; + float2 TexCoord : TEXCOORD0; + float2 TexCoord2 : TEXCOORD1; +}; + +struct VSInputTx2Vc +{ + float4 Position : SV_Position; + float2 TexCoord : TEXCOORD0; + float2 TexCoord2 : TEXCOORD1; + float4 Color : COLOR; +}; + +struct VSInputNmTxWeights +{ + float4 Position : SV_Position; + float3 Normal : NORMAL; + float2 TexCoord : TEXCOORD0; + uint4 Indices : BLENDINDICES0; + float4 Weights : BLENDWEIGHT0; +}; + + + +// Vertex shader output structures. + +struct VSOutput +{ + float4 Diffuse : COLOR0; + float4 Specular : COLOR1; + float4 PositionPS : SV_Position; +}; + +struct VSOutputNoFog +{ + float4 Diffuse : COLOR0; + float4 PositionPS : SV_Position; +}; + +struct VSOutputTx +{ + float4 Diffuse : COLOR0; + float4 Specular : COLOR1; + float2 TexCoord : TEXCOORD0; + float4 PositionPS : SV_Position; +}; + +struct VSOutputTxNoFog +{ + float4 Diffuse : COLOR0; + float2 TexCoord : TEXCOORD0; + float4 PositionPS : SV_Position; +}; + +struct VSOutputPixelLighting +{ + float4 PositionWS : TEXCOORD0; + float3 NormalWS : TEXCOORD1; + float4 Diffuse : COLOR0; + float4 PositionPS : SV_Position; +}; + +struct VSOutputPixelLightingTx +{ + float2 TexCoord : TEXCOORD0; + float4 PositionWS : TEXCOORD1; + float3 NormalWS : TEXCOORD2; + float4 Diffuse : COLOR0; + float4 PositionPS : SV_Position; +}; + +struct VSOutputTx2 +{ + float4 Diffuse : COLOR0; + float4 Specular : COLOR1; + float2 TexCoord : TEXCOORD0; + float2 TexCoord2 : TEXCOORD1; + float4 PositionPS : SV_Position; +}; + +struct VSOutputTx2NoFog +{ + float4 Diffuse : COLOR0; + float2 TexCoord : TEXCOORD0; + float2 TexCoord2 : TEXCOORD1; + float4 PositionPS : SV_Position; +}; + +struct VSOutputTxEnvMap +{ + float4 Diffuse : COLOR0; + float4 Specular : COLOR1; + float2 TexCoord : TEXCOORD0; + float3 EnvCoord : TEXCOORD1; + float4 PositionPS : SV_Position; +}; + + + +// Pixel shader input structures. + +struct PSInput +{ + float4 Diffuse : COLOR0; + float4 Specular : COLOR1; +}; + +struct PSInputNoFog +{ + float4 Diffuse : COLOR0; +}; + +struct PSInputTx +{ + float4 Diffuse : COLOR0; + float4 Specular : COLOR1; + float2 TexCoord : TEXCOORD0; +}; + +struct PSInputTxNoFog +{ + float4 Diffuse : COLOR0; + float2 TexCoord : TEXCOORD0; +}; + +struct PSInputPixelLighting +{ + float4 PositionWS : TEXCOORD0; + float3 NormalWS : TEXCOORD1; + float4 Diffuse : COLOR0; +}; + +struct PSInputPixelLightingTx +{ + float2 TexCoord : TEXCOORD0; + float4 PositionWS : TEXCOORD1; + float3 NormalWS : TEXCOORD2; + float4 Diffuse : COLOR0; +}; + +struct PSInputTx2 +{ + float4 Diffuse : COLOR0; + float4 Specular : COLOR1; + float2 TexCoord : TEXCOORD0; + float2 TexCoord2 : TEXCOORD1; +}; + +struct PSInputTx2NoFog +{ + float4 Diffuse : COLOR0; + float2 TexCoord : TEXCOORD0; + float2 TexCoord2 : TEXCOORD1; +}; + +struct PSInputTxEnvMap +{ + float4 Diffuse : COLOR0; + float4 Specular : COLOR1; + float2 TexCoord : TEXCOORD0; + float3 EnvCoord : TEXCOORD1; +}; diff --git a/Kits/DirectXTK/Src/SharedResourcePool.h b/Kits/DirectXTK/Src/SharedResourcePool.h new file mode 100644 index 0000000000000000000000000000000000000000..b4feb03442a60b6ee8e7a90f93bef955126c907e --- /dev/null +++ b/Kits/DirectXTK/Src/SharedResourcePool.h @@ -0,0 +1,108 @@ +//-------------------------------------------------------------------------------------- +// File: SharedResourcePool.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include +#include + +#include "PlatformHelpers.h" + + +namespace DirectX +{ + // Pool manager ensures that only a single TData instance is created for each unique TKey. + // This is used to avoid duplicate resource creation, so that for instance a caller can + // create any number of SpriteBatch instances, but these can internally share shaders and + // vertex buffer if more than one SpriteBatch uses the same underlying D3D device. + template + class SharedResourcePool + { + public: + SharedResourcePool() + : mResourceMap(std::make_shared()) + { } + + + // Allocates or looks up the shared TData instance for the specified key. + std::shared_ptr DemandCreate(TKey key) + { + std::lock_guard lock(mResourceMap->mutex); + + // Return an existing instance? + auto pos = mResourceMap->find(key); + + if (pos != mResourceMap->end()) + { + auto existingValue = pos->second.lock(); + + if (existingValue) + return existingValue; + else + mResourceMap->erase(pos); + } + + // Allocate a new instance. + auto newValue = std::make_shared(key, mResourceMap); + + mResourceMap->insert(std::make_pair(key, newValue)); + + return newValue; + } + + + private: + // Keep track of all allocated TData instances. + struct ResourceMap : public std::map> + { + std::mutex mutex; + }; + + std::shared_ptr mResourceMap; + + + // Wrap TData with our own subclass, so we can hook the destructor + // to remove instances from our pool before they are freed. + struct WrappedData : public TData + { + WrappedData(TKey key, std::shared_ptr const& resourceMap) + : mKey(key), + mResourceMap(resourceMap), + TData(key) + { } + + ~WrappedData() + { + std::lock_guard lock(mResourceMap->mutex); + + auto pos = mResourceMap->find(mKey); + + // Check for weak reference expiry before erasing, in case DemandCreate runs on + // a different thread at the same time as a previous instance is being destroyed. + // We mustn't erase replacement objects that have just been added! + if (pos != mResourceMap->end() && pos->second.expired()) + { + mResourceMap->erase(pos); + } + } + + TKey mKey; + std::shared_ptr mResourceMap; + }; + + + // Prevent copying. + SharedResourcePool(SharedResourcePool const&) DIRECTX_CTOR_DELETE + SharedResourcePool& operator= (SharedResourcePool const&) DIRECTX_CTOR_DELETE + }; +} diff --git a/Kits/DirectXTK/Src/SimpleMath.cpp b/Kits/DirectXTK/Src/SimpleMath.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9d1ff4f61cf94ed0f6bb2d8e6bc7c7beb1836fb4 --- /dev/null +++ b/Kits/DirectXTK/Src/SimpleMath.cpp @@ -0,0 +1,180 @@ +//------------------------------------------------------------------------------------- +// SimpleMath.cpp -- Simplified C++ Math wrapper for DirectXMath +// +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//------------------------------------------------------------------------------------- + +#include "pch.h" +#include "SimpleMath.h" + +/**************************************************************************** + * + * Constants + * + ****************************************************************************/ + +namespace DirectX +{ + namespace SimpleMath + { + #if defined(_MSC_VER) && (_MSC_VER < 1800) + const Vector2 Vector2::Zero(0.f, 0.f); + const Vector2 Vector2::One(1.f, 1.f); + const Vector2 Vector2::UnitX(1.f, 0.f); + const Vector2 Vector2::UnitY(0.f, 1.f); + + const Vector3 Vector3::Zero(0.f, 0.f, 0.f); + const Vector3 Vector3::One(1.f, 1.f, 1.f); + const Vector3 Vector3::UnitX(1.f, 0.f, 0.f); + const Vector3 Vector3::UnitY(0.f, 1.f, 0.f); + const Vector3 Vector3::UnitZ(0.f, 0.f, 1.f); + const Vector3 Vector3::Up(0.f, 1.f, 0.f); + const Vector3 Vector3::Down(0.f, -1.f, 0.f); + const Vector3 Vector3::Right(1.f, 0.f, 0.f); + const Vector3 Vector3::Left(-1.f, 0.f, 0.f); + const Vector3 Vector3::Forward(0.f, 0.f, -1.f); + const Vector3 Vector3::Backward(0.f, 0.f, 1.f); + + const Vector4 Vector4::Zero(0.f, 0.f, 0.f, 0.f); + const Vector4 Vector4::One(1.f, 1.f, 1.f, 1.f); + const Vector4 Vector4::UnitX(1.f, 0.f, 0.f, 0.f); + const Vector4 Vector4::UnitY(0.f, 1.f, 0.f, 0.f); + const Vector4 Vector4::UnitZ(0.f, 0.f, 1.f, 0.f); + const Vector4 Vector4::UnitW(0.f, 0.f, 0.f, 1.f); + + const Matrix Matrix::Identity(1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f); + + const Quaternion Quaternion::Identity(0.f, 0.f, 0.f, 1.f); + #else + const Vector2 Vector2::Zero = { 0.f, 0.f }; + const Vector2 Vector2::One = { 1.f, 1.f }; + const Vector2 Vector2::UnitX = { 1.f, 0.f }; + const Vector2 Vector2::UnitY = { 0.f, 1.f }; + + const Vector3 Vector3::Zero = { 0.f, 0.f, 0.f }; + const Vector3 Vector3::One = { 1.f, 1.f, 1.f }; + const Vector3 Vector3::UnitX = { 1.f, 0.f, 0.f }; + const Vector3 Vector3::UnitY = { 0.f, 1.f, 0.f }; + const Vector3 Vector3::UnitZ = { 0.f, 0.f, 1.f }; + const Vector3 Vector3::Up = { 0.f, 1.f, 0.f }; + const Vector3 Vector3::Down = { 0.f, -1.f, 0.f }; + const Vector3 Vector3::Right = { 1.f, 0.f, 0.f }; + const Vector3 Vector3::Left = { -1.f, 0.f, 0.f }; + const Vector3 Vector3::Forward = { 0.f, 0.f, -1.f }; + const Vector3 Vector3::Backward = { 0.f, 0.f, 1.f }; + + const Vector4 Vector4::Zero = { 0.f, 0.f, 0.f, 0.f }; + const Vector4 Vector4::One = { 1.f, 1.f, 1.f, 1.f }; + const Vector4 Vector4::UnitX = { 1.f, 0.f, 0.f, 0.f }; + const Vector4 Vector4::UnitY = { 0.f, 1.f, 0.f, 0.f }; + const Vector4 Vector4::UnitZ = { 0.f, 0.f, 1.f, 0.f }; + const Vector4 Vector4::UnitW = { 0.f, 0.f, 0.f, 1.f }; + + const Matrix Matrix::Identity = { 1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f }; + + const Quaternion Quaternion::Identity = { 0.f, 0.f, 0.f, 1.f }; + #endif + } +} + + +/**************************************************************************** + * + * Viewport + * + ****************************************************************************/ + +static_assert(sizeof(DirectX::SimpleMath::Viewport) == sizeof(D3D11_VIEWPORT), "Size mismatch"); +static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, x) == FIELD_OFFSET(D3D11_VIEWPORT, TopLeftX), "Layout mismatch"); +static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, y) == FIELD_OFFSET(D3D11_VIEWPORT, TopLeftY), "Layout mismatch"); +static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, width) == FIELD_OFFSET(D3D11_VIEWPORT, Width), "Layout mismatch"); +static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, height) == FIELD_OFFSET(D3D11_VIEWPORT, Height), "Layout mismatch"); +static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, minDepth) == FIELD_OFFSET(D3D11_VIEWPORT, MinDepth), "Layout mismatch"); +static_assert(FIELD_OFFSET(DirectX::SimpleMath::Viewport, maxDepth) == FIELD_OFFSET(D3D11_VIEWPORT, MaxDepth), "Layout mismatch"); + +RECT DirectX::SimpleMath::Viewport::ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UINT backBufferHeight, int outputWidth, int outputHeight) +{ + RECT rct; + + switch (int(scaling)) + { + case DXGI_SCALING_STRETCH: + // Output fills the entire window area + rct.top = 0; + rct.left = 0; + rct.right = outputWidth; + rct.bottom = outputHeight; + break; + + case 2 /*DXGI_SCALING_ASPECT_RATIO_STRETCH*/: + // Output fills the window area but respects the original aspect ratio, using pillar boxing or letter boxing as required + // Note: This scaling option is not supported for legacy Win32 windows swap chains + { + assert(backBufferHeight > 0); + float aspectRatio = float(backBufferWidth) / float(backBufferHeight); + + // Horizontal fill + float scaledWidth = float(outputWidth); + float scaledHeight = float(outputWidth) / aspectRatio; + if (scaledHeight >= outputHeight) + { + // Do vertical fill + scaledWidth = float(outputHeight) * aspectRatio; + scaledHeight = float(outputHeight); + } + + float offsetX = (float(outputWidth) - scaledWidth) * 0.5f; + float offsetY = (float(outputHeight) - scaledHeight) * 0.5f; + + rct.left = static_cast( offsetX ); + rct.top = static_cast( offsetY ); + rct.right = static_cast( offsetX + scaledWidth ); + rct.bottom = static_cast( offsetY + scaledHeight ); + + // Clip to display window + rct.left = std::max( 0, rct.left ); + rct.top = std::max( 0, rct.top ); + rct.right = std::min( outputWidth, rct.right ); + rct.bottom = std::min( outputHeight, rct.bottom ); + } + break; + + case DXGI_SCALING_NONE: + default: + // Output is displayed in the upper left corner of the window area + rct.top = 0; + rct.left = 0; + rct.right = std::min( backBufferWidth, UINT(outputWidth) ); + rct.bottom = std::min( backBufferHeight, UINT(outputHeight) ); + break; + } + + return rct; +} + +RECT DirectX::SimpleMath::Viewport::ComputeTitleSafeArea(UINT backBufferWidth, UINT backBufferHeight) +{ + float safew = (float(backBufferWidth) + 9.f) / 10.f; + float safeh = (float(backBufferHeight) + 9.f) / 10.f; + + RECT rct; + rct.left = static_cast(safew); + rct.top = static_cast(safeh); + rct.right = static_cast(float(backBufferWidth) - safew + 0.5f); + rct.bottom = static_cast(float(backBufferHeight) - safeh + 0.5f); + + return rct; +} diff --git a/Kits/DirectXTK/Src/SkinnedEffect.cpp b/Kits/DirectXTK/Src/SkinnedEffect.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4f0282d664327f97a54f5e18bd53205251888193 --- /dev/null +++ b/Kits/DirectXTK/Src/SkinnedEffect.cpp @@ -0,0 +1,527 @@ +//-------------------------------------------------------------------------------------- +// File: SkinnedEffect.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "EffectCommon.h" + +using namespace DirectX; + + +// Constant buffer layout. Must match the shader! +struct SkinnedEffectConstants +{ + XMVECTOR diffuseColor; + XMVECTOR emissiveColor; + XMVECTOR specularColorAndPower; + + XMVECTOR lightDirection[IEffectLights::MaxDirectionalLights]; + XMVECTOR lightDiffuseColor[IEffectLights::MaxDirectionalLights]; + XMVECTOR lightSpecularColor[IEffectLights::MaxDirectionalLights]; + + XMVECTOR eyePosition; + + XMVECTOR fogColor; + XMVECTOR fogVector; + + XMMATRIX world; + XMVECTOR worldInverseTranspose[3]; + XMMATRIX worldViewProj; + + XMVECTOR bones[SkinnedEffect::MaxBones][3]; +}; + +static_assert( ( sizeof(SkinnedEffectConstants) % 16 ) == 0, "CB size not padded correctly" ); + + +// Traits type describes our characteristics to the EffectBase template. +struct SkinnedEffectTraits +{ + typedef SkinnedEffectConstants ConstantBufferType; + + static const int VertexShaderCount = 9; + static const int PixelShaderCount = 3; + static const int ShaderPermutationCount = 18; +}; + + +// Internal SkinnedEffect implementation class. +class SkinnedEffect::Impl : public EffectBase +{ +public: + Impl(_In_ ID3D11Device* device); + + bool preferPerPixelLighting; + int weightsPerVertex; + + EffectLights lights; + + int GetCurrentShaderPermutation() const; + + void Apply(_In_ ID3D11DeviceContext* deviceContext); +}; + + +// Include the precompiled shader code. +namespace +{ +#if defined(_XBOX_ONE) && defined(_TITLE) + #include "Shaders/Compiled/XboxOneSkinnedEffect_VSSkinnedVertexLightingOneBone.inc" + #include "Shaders/Compiled/XboxOneSkinnedEffect_VSSkinnedVertexLightingTwoBones.inc" + #include "Shaders/Compiled/XboxOneSkinnedEffect_VSSkinnedVertexLightingFourBones.inc" + + #include "Shaders/Compiled/XboxOneSkinnedEffect_VSSkinnedOneLightOneBone.inc" + #include "Shaders/Compiled/XboxOneSkinnedEffect_VSSkinnedOneLightTwoBones.inc" + #include "Shaders/Compiled/XboxOneSkinnedEffect_VSSkinnedOneLightFourBones.inc" + + #include "Shaders/Compiled/XboxOneSkinnedEffect_VSSkinnedPixelLightingOneBone.inc" + #include "Shaders/Compiled/XboxOneSkinnedEffect_VSSkinnedPixelLightingTwoBones.inc" + #include "Shaders/Compiled/XboxOneSkinnedEffect_VSSkinnedPixelLightingFourBones.inc" + + #include "Shaders/Compiled/XboxOneSkinnedEffect_PSSkinnedVertexLighting.inc" + #include "Shaders/Compiled/XboxOneSkinnedEffect_PSSkinnedVertexLightingNoFog.inc" + #include "Shaders/Compiled/XboxOneSkinnedEffect_PSSkinnedPixelLighting.inc" +#else + #include "Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingOneBone.inc" + #include "Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingTwoBones.inc" + #include "Shaders/Compiled/SkinnedEffect_VSSkinnedVertexLightingFourBones.inc" + + #include "Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightOneBone.inc" + #include "Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightTwoBones.inc" + #include "Shaders/Compiled/SkinnedEffect_VSSkinnedOneLightFourBones.inc" + + #include "Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingOneBone.inc" + #include "Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingTwoBones.inc" + #include "Shaders/Compiled/SkinnedEffect_VSSkinnedPixelLightingFourBones.inc" + + #include "Shaders/Compiled/SkinnedEffect_PSSkinnedVertexLighting.inc" + #include "Shaders/Compiled/SkinnedEffect_PSSkinnedVertexLightingNoFog.inc" + #include "Shaders/Compiled/SkinnedEffect_PSSkinnedPixelLighting.inc" +#endif +} + + +const ShaderBytecode EffectBase::VertexShaderBytecode[] = +{ + { SkinnedEffect_VSSkinnedVertexLightingOneBone, sizeof(SkinnedEffect_VSSkinnedVertexLightingOneBone) }, + { SkinnedEffect_VSSkinnedVertexLightingTwoBones, sizeof(SkinnedEffect_VSSkinnedVertexLightingTwoBones) }, + { SkinnedEffect_VSSkinnedVertexLightingFourBones, sizeof(SkinnedEffect_VSSkinnedVertexLightingFourBones) }, + + { SkinnedEffect_VSSkinnedOneLightOneBone, sizeof(SkinnedEffect_VSSkinnedOneLightOneBone) }, + { SkinnedEffect_VSSkinnedOneLightTwoBones, sizeof(SkinnedEffect_VSSkinnedOneLightTwoBones) }, + { SkinnedEffect_VSSkinnedOneLightFourBones, sizeof(SkinnedEffect_VSSkinnedOneLightFourBones) }, + + { SkinnedEffect_VSSkinnedPixelLightingOneBone, sizeof(SkinnedEffect_VSSkinnedPixelLightingOneBone) }, + { SkinnedEffect_VSSkinnedPixelLightingTwoBones, sizeof(SkinnedEffect_VSSkinnedPixelLightingTwoBones) }, + { SkinnedEffect_VSSkinnedPixelLightingFourBones, sizeof(SkinnedEffect_VSSkinnedPixelLightingFourBones) }, +}; + + +const int EffectBase::VertexShaderIndices[] = +{ + 0, // vertex lighting, one bone + 0, // vertex lighting, one bone, no fog + 1, // vertex lighting, two bones + 1, // vertex lighting, two bones, no fog + 2, // vertex lighting, four bones + 2, // vertex lighting, four bones, no fog + + 3, // one light, one bone + 3, // one light, one bone, no fog + 4, // one light, two bones + 4, // one light, two bones, no fog + 5, // one light, four bones + 5, // one light, four bones, no fog + + 6, // pixel lighting, one bone + 6, // pixel lighting, one bone, no fog + 7, // pixel lighting, two bones + 7, // pixel lighting, two bones, no fog + 8, // pixel lighting, four bones + 8, // pixel lighting, four bones, no fog +}; + + +const ShaderBytecode EffectBase::PixelShaderBytecode[] = +{ + { SkinnedEffect_PSSkinnedVertexLighting, sizeof(SkinnedEffect_PSSkinnedVertexLighting) }, + { SkinnedEffect_PSSkinnedVertexLightingNoFog, sizeof(SkinnedEffect_PSSkinnedVertexLightingNoFog) }, + { SkinnedEffect_PSSkinnedPixelLighting, sizeof(SkinnedEffect_PSSkinnedPixelLighting) }, +}; + + +const int EffectBase::PixelShaderIndices[] = +{ + 0, // vertex lighting, one bone + 1, // vertex lighting, one bone, no fog + 0, // vertex lighting, two bones + 1, // vertex lighting, two bones, no fog + 0, // vertex lighting, four bones + 1, // vertex lighting, four bones, no fog + + 0, // one light, one bone + 1, // one light, one bone, no fog + 0, // one light, two bones + 1, // one light, two bones, no fog + 0, // one light, four bones + 1, // one light, four bones, no fog + + 2, // pixel lighting, one bone + 2, // pixel lighting, one bone, no fog + 2, // pixel lighting, two bones + 2, // pixel lighting, two bones, no fog + 2, // pixel lighting, four bones + 2, // pixel lighting, four bones, no fog +}; + + +// Global pool of per-device SkinnedEffect resources. +SharedResourcePool::DeviceResources> EffectBase::deviceResourcesPool; + + +// Constructor. +SkinnedEffect::Impl::Impl(_In_ ID3D11Device* device) + : EffectBase(device), + preferPerPixelLighting(false), + weightsPerVertex(4) +{ + static_assert( _countof(EffectBase::VertexShaderIndices) == SkinnedEffectTraits::ShaderPermutationCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::VertexShaderBytecode) == SkinnedEffectTraits::VertexShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderBytecode) == SkinnedEffectTraits::PixelShaderCount, "array/max mismatch" ); + static_assert( _countof(EffectBase::PixelShaderIndices) == SkinnedEffectTraits::ShaderPermutationCount, "array/max mismatch" ); + + lights.InitializeConstants(constants.specularColorAndPower, constants.lightDirection, constants.lightDiffuseColor, constants.lightSpecularColor); + + for (int i = 0; i < MaxBones; i++) + { + constants.bones[i][0] = g_XMIdentityR0; + constants.bones[i][1] = g_XMIdentityR1; + constants.bones[i][2] = g_XMIdentityR2; + } +} + + +int SkinnedEffect::Impl::GetCurrentShaderPermutation() const +{ + int permutation = 0; + + // Use optimized shaders if fog is disabled. + if (!fog.enabled) + { + permutation += 1; + } + + // Evaluate 1, 2, or 4 weights per vertex? + if (weightsPerVertex == 2) + { + permutation += 2; + } + else if (weightsPerVertex == 4) + { + permutation += 4; + } + + if (preferPerPixelLighting) + { + // Do lighting in the pixel shader. + permutation += 12; + } + else if (!lights.lightEnabled[1] && !lights.lightEnabled[2]) + { + // Use the only-bother-with-the-first-light shader optimization. + permutation += 6; + } + + return permutation; +} + + +// Sets our state onto the D3D device. +void SkinnedEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + // Compute derived parameter values. + matrices.SetConstants(dirtyFlags, constants.worldViewProj); + + fog.SetConstants(dirtyFlags, matrices.worldView, constants.fogVector); + + lights.SetConstants(dirtyFlags, matrices, constants.world, constants.worldInverseTranspose, constants.eyePosition, constants.diffuseColor, constants.emissiveColor, true); + + // Set the texture. + auto textures = texture.Get(); + if ( !textures ) + textures = GetDefaultTexture(); + + deviceContext->PSSetShaderResources(0, 1, &textures ); + + // Set shaders and constant buffers. + ApplyShaders(deviceContext, GetCurrentShaderPermutation()); +} + + +// Public constructor. +SkinnedEffect::SkinnedEffect(_In_ ID3D11Device* device) + : pImpl(new Impl(device)) +{ +} + + +// Move constructor. +SkinnedEffect::SkinnedEffect(SkinnedEffect&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +SkinnedEffect& SkinnedEffect::operator= (SkinnedEffect&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +SkinnedEffect::~SkinnedEffect() +{ +} + + +void SkinnedEffect::Apply(_In_ ID3D11DeviceContext* deviceContext) +{ + pImpl->Apply(deviceContext); +} + + +void SkinnedEffect::GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength) +{ + pImpl->GetVertexShaderBytecode(pImpl->GetCurrentShaderPermutation(), pShaderByteCode, pByteCodeLength); +} + + +void XM_CALLCONV SkinnedEffect::SetWorld(FXMMATRIX value) +{ + pImpl->matrices.world = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::WorldInverseTranspose | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV SkinnedEffect::SetView(FXMMATRIX value) +{ + pImpl->matrices.view = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::EyePosition | EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV SkinnedEffect::SetProjection(FXMMATRIX value) +{ + pImpl->matrices.projection = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj; +} + + +void XM_CALLCONV SkinnedEffect::SetDiffuseColor(FXMVECTOR value) +{ + pImpl->lights.diffuseColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void XM_CALLCONV SkinnedEffect::SetEmissiveColor(FXMVECTOR value) +{ + pImpl->lights.emissiveColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void XM_CALLCONV SkinnedEffect::SetSpecularColor(FXMVECTOR value) +{ + // Set xyz to new value, but preserve existing w (specular power). + pImpl->constants.specularColorAndPower = XMVectorSelect(pImpl->constants.specularColorAndPower, value, g_XMSelect1110); + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void SkinnedEffect::SetSpecularPower(float value) +{ + // Set w to new value, but preserve existing xyz (specular color). + pImpl->constants.specularColorAndPower = XMVectorSetW(pImpl->constants.specularColorAndPower, value); + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + +void SkinnedEffect::DisableSpecular() +{ + // Set specular color to black, power to 1 + // Note: Don't use a power of 0 or the shader will generate strange highlights on non-specular materials + + pImpl->constants.specularColorAndPower = g_XMIdentityR3; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + +void SkinnedEffect::SetAlpha(float value) +{ + pImpl->lights.alpha = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void SkinnedEffect::SetLightingEnabled(bool value) +{ + if (!value) + { + throw std::exception("SkinnedEffect does not support turning off lighting"); + } +} + + +void SkinnedEffect::SetPerPixelLighting(bool value) +{ + pImpl->preferPerPixelLighting = value; +} + + +void XM_CALLCONV SkinnedEffect::SetAmbientLightColor(FXMVECTOR value) +{ + pImpl->lights.ambientLightColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor; +} + + +void SkinnedEffect::SetLightEnabled(int whichLight, bool value) +{ + pImpl->dirtyFlags |= pImpl->lights.SetLightEnabled(whichLight, value, pImpl->constants.lightDiffuseColor, pImpl->constants.lightSpecularColor); +} + + +void XM_CALLCONV SkinnedEffect::SetLightDirection(int whichLight, FXMVECTOR value) +{ + EffectLights::ValidateLightIndex(whichLight); + + pImpl->constants.lightDirection[whichLight] = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void XM_CALLCONV SkinnedEffect::SetLightDiffuseColor(int whichLight, FXMVECTOR value) +{ + pImpl->dirtyFlags |= pImpl->lights.SetLightDiffuseColor(whichLight, value, pImpl->constants.lightDiffuseColor); +} + + +void XM_CALLCONV SkinnedEffect::SetLightSpecularColor(int whichLight, FXMVECTOR value) +{ + pImpl->dirtyFlags |= pImpl->lights.SetLightSpecularColor(whichLight, value, pImpl->constants.lightSpecularColor); +} + + +void SkinnedEffect::EnableDefaultLighting() +{ + EffectLights::EnableDefaultLighting(this); +} + + +void SkinnedEffect::SetFogEnabled(bool value) +{ + pImpl->fog.enabled = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogEnable; +} + + +void SkinnedEffect::SetFogStart(float value) +{ + pImpl->fog.start = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void SkinnedEffect::SetFogEnd(float value) +{ + pImpl->fog.end = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::FogVector; +} + + +void XM_CALLCONV SkinnedEffect::SetFogColor(FXMVECTOR value) +{ + pImpl->constants.fogColor = value; + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void SkinnedEffect::SetTexture(_In_opt_ ID3D11ShaderResourceView* value) +{ + pImpl->texture = value; +} + + +void SkinnedEffect::SetWeightsPerVertex(int value) +{ + if ((value != 1) && + (value != 2) && + (value != 4)) + { + throw std::out_of_range("WeightsPerVertex must be 1, 2, or 4"); + } + + pImpl->weightsPerVertex = value; +} + + +void SkinnedEffect::SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) +{ + if (count > MaxBones) + throw std::out_of_range("count parameter out of range"); + + auto boneConstant = pImpl->constants.bones; + + for (size_t i = 0; i < count; i++) + { + XMMATRIX boneMatrix = XMMatrixTranspose(value[i]); + + boneConstant[i][0] = boneMatrix.r[0]; + boneConstant[i][1] = boneMatrix.r[1]; + boneConstant[i][2] = boneMatrix.r[2]; + } + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} + + +void SkinnedEffect::ResetBoneTransforms() +{ + auto boneConstant = pImpl->constants.bones; + + XMMATRIX id = XMMatrixIdentity(); + + for(size_t i = 0; i < MaxBones; ++i) + { + boneConstant[i][0] = g_XMIdentityR0; + boneConstant[i][1] = g_XMIdentityR1; + boneConstant[i][2] = g_XMIdentityR2; + } + + pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer; +} diff --git a/Kits/DirectXTK/Src/SpriteBatch.cpp b/Kits/DirectXTK/Src/SpriteBatch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e36b61c74ab00d928c88cfbe68651896596e0895 --- /dev/null +++ b/Kits/DirectXTK/Src/SpriteBatch.cpp @@ -0,0 +1,1115 @@ +//-------------------------------------------------------------------------------------- +// File: SpriteBatch.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" + +#include +#include + +#include "SpriteBatch.h" +#include "ConstantBuffer.h" +#include "CommonStates.h" +#include "VertexTypes.h" +#include "SharedResourcePool.h" +#include "AlignedNew.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +// Internal SpriteBatch implementation class. +__declspec(align(16)) class SpriteBatch::Impl : public AlignedNew +{ +public: + Impl(_In_ ID3D11DeviceContext* deviceContext); + + void XM_CALLCONV Begin(SpriteSortMode sortMode, _In_opt_ ID3D11BlendState* blendState, _In_opt_ ID3D11SamplerState* samplerState, _In_opt_ ID3D11DepthStencilState* depthStencilState, _In_opt_ ID3D11RasterizerState* rasterizerState, _In_opt_ std::function setCustomShaders, FXMMATRIX transformMatrix); + void End(); + + void XM_CALLCONV Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR destination, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, FXMVECTOR originRotationDepth, int flags); + + + // Info about a single sprite that is waiting to be drawn. + __declspec(align(16)) struct SpriteInfo : public AlignedNew + { + XMFLOAT4A source; + XMFLOAT4A destination; + XMFLOAT4A color; + XMFLOAT4A originRotationDepth; + ID3D11ShaderResourceView* texture; + int flags; + + + // Combine values from the public SpriteEffects enum with these internal-only flags. + static const int SourceInTexels = 4; + static const int DestSizeInPixels = 8; + + static_assert((SpriteEffects_FlipBoth & (SourceInTexels | DestSizeInPixels)) == 0, "Flag bits must not overlap"); + }; + + DXGI_MODE_ROTATION mRotation; + + bool mSetViewport; + D3D11_VIEWPORT mViewPort; + +private: + // Implementation helper methods. + void GrowSpriteQueue(); + void PrepareForRendering(); + void FlushBatch(); + void SortSprites(); + void GrowSortedSprites(); + + void RenderBatch(_In_ ID3D11ShaderResourceView* texture, _In_reads_(count) SpriteInfo const* const* sprites, size_t count); + + static void XM_CALLCONV RenderSprite(_In_ SpriteInfo const* sprite, _Out_cap_c_(VerticesPerSprite) VertexPositionColorTexture* vertices, FXMVECTOR textureSize, FXMVECTOR inverseTextureSize); + + static XMVECTOR GetTextureSize(_In_ ID3D11ShaderResourceView* texture); + XMMATRIX GetViewportTransform(_In_ ID3D11DeviceContext* deviceContext, DXGI_MODE_ROTATION rotation ); + + + // Constants. + static const size_t MaxBatchSize = 2048; + static const size_t MinBatchSize = 128; + static const size_t InitialQueueSize = 64; + static const size_t VerticesPerSprite = 4; + static const size_t IndicesPerSprite = 6; + + + // Queue of sprites waiting to be drawn. + std::unique_ptr mSpriteQueue; + + size_t mSpriteQueueCount; + size_t mSpriteQueueArraySize; + + + // To avoid needlessly copying around bulky SpriteInfo structures, we leave that + // actual data alone and just sort this array of pointers instead. But we want contiguous + // memory for cache efficiency, so these pointers are just shortcuts into the single + // mSpriteQueue array, and we take care to keep them in order when sorting is disabled. + std::vector mSortedSprites; + + + // If each SpriteInfo instance held a refcount on its texture, could end up with + // many redundant AddRef/Release calls on the same object, so instead we use + // this separate list to hold just a single refcount each time we change texture. + std::vector> mSpriteTextureReferences; + + + // Mode settings from the last Begin call. + bool mInBeginEndPair; + + SpriteSortMode mSortMode; + ComPtr mBlendState; + ComPtr mSamplerState; + ComPtr mDepthStencilState; + ComPtr mRasterizerState; + std::function mSetCustomShaders; + XMMATRIX mTransformMatrix; + + + // Only one of these helpers is allocated per D3D device, even if there are multiple SpriteBatch instances. + struct DeviceResources + { + DeviceResources(_In_ ID3D11Device* device); + + ComPtr vertexShader; + ComPtr pixelShader; + ComPtr inputLayout; + ComPtr indexBuffer; + + CommonStates stateObjects; + + private: + void CreateShaders(_In_ ID3D11Device* device); + void CreateIndexBuffer(_In_ ID3D11Device* device); + + static std::vector CreateIndexValues(); + }; + + + // Only one of these helpers is allocated per D3D device context, even if there are multiple SpriteBatch instances. + struct ContextResources + { + ContextResources(_In_ ID3D11DeviceContext* deviceContext); + +#if defined(_XBOX_ONE) && defined(_TITLE) + ComPtr deviceContext; +#else + ComPtr deviceContext; +#endif + + ComPtr vertexBuffer; + + ConstantBuffer constantBuffer; + + size_t vertexBufferPosition; + + bool inImmediateMode; + + private: + void CreateVertexBuffer(); + }; + + + // Per-device and per-context data. + std::shared_ptr mDeviceResources; + std::shared_ptr mContextResources; + + static SharedResourcePool deviceResourcesPool; + static SharedResourcePool contextResourcesPool; +}; + + +// Global pools of per-device and per-context SpriteBatch resources. +SharedResourcePool SpriteBatch::Impl::deviceResourcesPool; +SharedResourcePool SpriteBatch::Impl::contextResourcesPool; + + +// Constants. +const XMMATRIX SpriteBatch::MatrixIdentity = XMMatrixIdentity(); +const XMFLOAT2 SpriteBatch::Float2Zero(0, 0); + + +namespace +{ + // Include the precompiled shader code. +#if defined(_XBOX_ONE) && defined(_TITLE) + #include "Shaders/Compiled/XboxOneSpriteEffect_SpriteVertexShader.inc" + #include "Shaders/Compiled/XboxOneSpriteEffect_SpritePixelShader.inc" +#else + #include "Shaders/Compiled/SpriteEffect_SpriteVertexShader.inc" + #include "Shaders/Compiled/SpriteEffect_SpritePixelShader.inc" +#endif + + + // Helper looks up the D3D device corresponding to a context interface. + inline ComPtr GetDevice(_In_ ID3D11DeviceContext* deviceContext) + { + ComPtr device; + + deviceContext->GetDevice(&device); + + return device; + } + + + // Helper converts a RECT to XMVECTOR. + inline XMVECTOR LoadRect(_In_ RECT const* rect) + { + XMVECTOR v = XMLoadInt4(reinterpret_cast(rect)); + + v = XMConvertVectorIntToFloat(v, 0); + + // Convert right/bottom to width/height. + v -= XMVectorPermute<0, 1, 4, 5>(XMVectorZero(), v); + + return v; + } +} + + +// Per-device constructor. +SpriteBatch::Impl::DeviceResources::DeviceResources(_In_ ID3D11Device* device) + : stateObjects(device) +{ + CreateShaders(device); + CreateIndexBuffer(device); +} + + +// Creates the SpriteBatch shaders and input layout. +void SpriteBatch::Impl::DeviceResources::CreateShaders(_In_ ID3D11Device* device) +{ + ThrowIfFailed( + device->CreateVertexShader(SpriteEffect_SpriteVertexShader, + sizeof(SpriteEffect_SpriteVertexShader), + nullptr, + &vertexShader) + ); + + ThrowIfFailed( + device->CreatePixelShader(SpriteEffect_SpritePixelShader, + sizeof(SpriteEffect_SpritePixelShader), + nullptr, + &pixelShader) + ); + + ThrowIfFailed( + device->CreateInputLayout(VertexPositionColorTexture::InputElements, + VertexPositionColorTexture::InputElementCount, + SpriteEffect_SpriteVertexShader, + sizeof(SpriteEffect_SpriteVertexShader), + &inputLayout) + ); + + SetDebugObjectName(vertexShader.Get(), "DirectXTK:SpriteBatch"); + SetDebugObjectName(pixelShader.Get(), "DirectXTK:SpriteBatch"); + SetDebugObjectName(inputLayout.Get(), "DirectXTK:SpriteBatch"); +} + + +// Creates the SpriteBatch index buffer. +void SpriteBatch::Impl::DeviceResources::CreateIndexBuffer(_In_ ID3D11Device* device) +{ + D3D11_BUFFER_DESC indexBufferDesc = { 0 }; + + static_assert( ( MaxBatchSize * VerticesPerSprite ) < USHRT_MAX, "MaxBatchSize too large for 16-bit indices" ); + + indexBufferDesc.ByteWidth = sizeof(short) * MaxBatchSize * IndicesPerSprite; + indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; + indexBufferDesc.Usage = D3D11_USAGE_DEFAULT; + + auto indexValues = CreateIndexValues(); + + D3D11_SUBRESOURCE_DATA indexDataDesc = { 0 }; + + indexDataDesc.pSysMem = indexValues.data(); + + ThrowIfFailed( + device->CreateBuffer(&indexBufferDesc, &indexDataDesc, &indexBuffer) + ); + + SetDebugObjectName(indexBuffer.Get(), "DirectXTK:SpriteBatch"); +} + + +// Helper for populating the SpriteBatch index buffer. +std::vector SpriteBatch::Impl::DeviceResources::CreateIndexValues() +{ + std::vector indices; + + indices.reserve(MaxBatchSize * IndicesPerSprite); + + for (short i = 0; i < MaxBatchSize * VerticesPerSprite; i += VerticesPerSprite) + { + indices.push_back(i); + indices.push_back(i + 1); + indices.push_back(i + 2); + + indices.push_back(i + 1); + indices.push_back(i + 3); + indices.push_back(i + 2); + } + + return indices; +} + + +// Per-context constructor. +SpriteBatch::Impl::ContextResources::ContextResources(_In_ ID3D11DeviceContext* context) + :constantBuffer(GetDevice(context).Get()), + vertexBufferPosition(0), + inImmediateMode(false) +{ +#if defined(_XBOX_ONE) && defined(_TITLE) + ThrowIfFailed(context->QueryInterface(IID_GRAPHICS_PPV_ARGS(deviceContext.GetAddressOf()))); +#else + deviceContext = context; +#endif + + CreateVertexBuffer(); +} + + +// Creates the SpriteBatch vertex buffer. +void SpriteBatch::Impl::ContextResources::CreateVertexBuffer() +{ +#if defined(_XBOX_ONE) && defined(_TITLE) + D3D11_BUFFER_DESC vertexBufferDesc = { 0 }; + + vertexBufferDesc.ByteWidth = sizeof(VertexPositionColorTexture) * MaxBatchSize * VerticesPerSprite; + vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT; + vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + auto device = GetDevice(deviceContext.Get()); + + ComPtr deviceX; + ThrowIfFailed(device.As(&deviceX)); + + ThrowIfFailed( + deviceX->CreatePlacementBuffer(&vertexBufferDesc, nullptr, &vertexBuffer) + ); + + SetDebugObjectName(vertexBuffer.Get(), "DirectXTK:SpriteBatch"); +#else + D3D11_BUFFER_DESC vertexBufferDesc = { 0 }; + + vertexBufferDesc.ByteWidth = sizeof(VertexPositionColorTexture) * MaxBatchSize * VerticesPerSprite; + vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; + vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + ThrowIfFailed( + GetDevice(deviceContext.Get())->CreateBuffer(&vertexBufferDesc, nullptr, &vertexBuffer) + ); + + SetDebugObjectName(vertexBuffer.Get(), "DirectXTK:SpriteBatch"); +#endif +} + + +// Per-SpriteBatch constructor. +SpriteBatch::Impl::Impl(_In_ ID3D11DeviceContext* deviceContext) + : mRotation( DXGI_MODE_ROTATION_IDENTITY ), + mSetViewport(false), + mSpriteQueueCount(0), + mSpriteQueueArraySize(0), + mInBeginEndPair(false), + mSortMode(SpriteSortMode_Deferred), + mTransformMatrix(MatrixIdentity), + mDeviceResources(deviceResourcesPool.DemandCreate(GetDevice(deviceContext).Get())), + mContextResources(contextResourcesPool.DemandCreate(deviceContext)) +{ +} + + +// Begins a batch of sprite drawing operations. +void XM_CALLCONV SpriteBatch::Impl::Begin(SpriteSortMode sortMode, _In_opt_ ID3D11BlendState* blendState, _In_opt_ ID3D11SamplerState* samplerState, _In_opt_ ID3D11DepthStencilState* depthStencilState, _In_opt_ ID3D11RasterizerState* rasterizerState, _In_opt_ std::function setCustomShaders, FXMMATRIX transformMatrix) +{ + if (mInBeginEndPair) + throw std::exception("Cannot nest Begin calls on a single SpriteBatch"); + + mSortMode = sortMode; + mBlendState = blendState; + mSamplerState = samplerState; + mDepthStencilState = depthStencilState; + mRasterizerState = rasterizerState; + mSetCustomShaders = setCustomShaders; + mTransformMatrix = transformMatrix; + + if (sortMode == SpriteSortMode_Immediate) + { + // If we are in immediate mode, set device state ready for drawing. + if (mContextResources->inImmediateMode) + throw std::exception("Only one SpriteBatch at a time can use SpriteSortMode_Immediate"); + + PrepareForRendering(); + + mContextResources->inImmediateMode = true; + } + + mInBeginEndPair = true; +} + + +// Ends a batch of sprite drawing operations. +void SpriteBatch::Impl::End() +{ + if (!mInBeginEndPair) + throw std::exception("Begin must be called before End"); + + if (mSortMode == SpriteSortMode_Immediate) + { + // If we are in immediate mode, sprites have already been drawn. + mContextResources->inImmediateMode = false; + } + else + { + // Draw the queued sprites now. + if (mContextResources->inImmediateMode) + throw std::exception("Cannot end one SpriteBatch while another is using SpriteSortMode_Immediate"); + + PrepareForRendering(); + FlushBatch(); + } + + // Break circular reference chains, in case the state lambda closed + // over an object that holds a reference to this SpriteBatch. + mSetCustomShaders = nullptr; + + mInBeginEndPair = false; +} + + +// Adds a single sprite to the queue. +void XM_CALLCONV SpriteBatch::Impl::Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR destination, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, FXMVECTOR originRotationDepth, int flags) +{ + if (!texture) + throw std::exception("Texture cannot be null"); + + if (!mInBeginEndPair) + throw std::exception("Begin must be called before Draw"); + + // Get a pointer to the output sprite. + if (mSpriteQueueCount >= mSpriteQueueArraySize) + { + GrowSpriteQueue(); + } + + SpriteInfo* sprite = &mSpriteQueue[mSpriteQueueCount]; + + XMVECTOR dest = destination; + + if (sourceRectangle) + { + // User specified an explicit source region. + XMVECTOR source = LoadRect(sourceRectangle); + + XMStoreFloat4A(&sprite->source, source); + + // If the destination size is relative to the source region, convert it to pixels. + if (!(flags & SpriteInfo::DestSizeInPixels)) + { + dest = XMVectorPermute<0, 1, 6, 7>(dest, dest * source); // dest.zw *= source.zw + } + + flags |= SpriteInfo::SourceInTexels | SpriteInfo::DestSizeInPixels; + } + else + { + // No explicit source region, so use the entire texture. + static const XMVECTORF32 wholeTexture = { 0, 0, 1, 1 }; + + XMStoreFloat4A(&sprite->source, wholeTexture); + } + + // Store sprite parameters. + XMStoreFloat4A(&sprite->destination, dest); + XMStoreFloat4A(&sprite->color, color); + XMStoreFloat4A(&sprite->originRotationDepth, originRotationDepth); + + sprite->texture = texture; + sprite->flags = flags; + + if (mSortMode == SpriteSortMode_Immediate) + { + // If we are in immediate mode, draw this sprite straight away. + RenderBatch(texture, &sprite, 1); + } + else + { + // Queue this sprite for later sorting and batched rendering. + mSpriteQueueCount++; + + // Make sure we hold a refcount on this texture until the sprite has been drawn. Only checking the + // back of the vector means we will add duplicate references if the caller switches back and forth + // between multiple repeated textures, but calling AddRef more times than strictly necessary hurts + // nothing, and is faster than scanning the whole list or using a map to detect all duplicates. + if (mSpriteTextureReferences.empty() || texture != mSpriteTextureReferences.back().Get()) + { + mSpriteTextureReferences.emplace_back(texture); + } + } +} + + +// Dynamically expands the array used to store pending sprite information. +void SpriteBatch::Impl::GrowSpriteQueue() +{ + // Grow by a factor of 2. + size_t newSize = std::max(InitialQueueSize, mSpriteQueueArraySize * 2); + + // Allocate the new array. + std::unique_ptr newArray(new SpriteInfo[newSize]); + + // Copy over any existing sprites. + for (size_t i = 0; i < mSpriteQueueCount; i++) + { + newArray[i] = mSpriteQueue[i]; + } + + // Replace the previous array with the new one. + mSpriteQueue = std::move(newArray); + mSpriteQueueArraySize = newSize; + + // Clear any dangling SpriteInfo pointers left over from previous rendering. + mSortedSprites.clear(); +} + + +// Sets up D3D device state ready for drawing sprites. +void SpriteBatch::Impl::PrepareForRendering() +{ + auto deviceContext = mContextResources->deviceContext.Get(); + + // Set state objects. + auto blendState = mBlendState ? mBlendState.Get() : mDeviceResources->stateObjects.AlphaBlend(); + auto depthStencilState = mDepthStencilState ? mDepthStencilState.Get() : mDeviceResources->stateObjects.DepthNone(); + auto rasterizerState = mRasterizerState ? mRasterizerState.Get() : mDeviceResources->stateObjects.CullCounterClockwise(); + auto samplerState = mSamplerState ? mSamplerState.Get() : mDeviceResources->stateObjects.LinearClamp(); + + deviceContext->OMSetBlendState(blendState, nullptr, 0xFFFFFFFF); + deviceContext->OMSetDepthStencilState(depthStencilState, 0); + deviceContext->RSSetState(rasterizerState); + deviceContext->PSSetSamplers(0, 1, &samplerState); + + // Set shaders. + deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + deviceContext->IASetInputLayout(mDeviceResources->inputLayout.Get()); + deviceContext->VSSetShader(mDeviceResources->vertexShader.Get(), nullptr, 0); + deviceContext->PSSetShader(mDeviceResources->pixelShader.Get(), nullptr, 0); + + // Set the vertex and index buffer. +#if !defined(_XBOX_ONE) || !defined(_TITLE) + auto vertexBuffer = mContextResources->vertexBuffer.Get(); + UINT vertexStride = sizeof(VertexPositionColorTexture); + UINT vertexOffset = 0; + + deviceContext->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset); +#endif + + deviceContext->IASetIndexBuffer(mDeviceResources->indexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0); + + // Set the transform matrix. + XMMATRIX transformMatrix = (mRotation == DXGI_MODE_ROTATION_UNSPECIFIED) + ? mTransformMatrix + : ( mTransformMatrix * GetViewportTransform(deviceContext, mRotation) ); + +#if defined(_XBOX_ONE) && defined(_TITLE) + void* grfxMemory; + mContextResources->constantBuffer.SetData(deviceContext, transformMatrix, &grfxMemory); + + deviceContext->VSSetPlacementConstantBuffer( 0, mContextResources->constantBuffer.GetBuffer(), grfxMemory ); +#else + mContextResources->constantBuffer.SetData(deviceContext, transformMatrix); + + ID3D11Buffer* constantBuffer = mContextResources->constantBuffer.GetBuffer(); + + deviceContext->VSSetConstantBuffers(0, 1, &constantBuffer); +#endif + + // If this is a deferred D3D context, reset position so the first Map call will use D3D11_MAP_WRITE_DISCARD. + if (deviceContext->GetType() == D3D11_DEVICE_CONTEXT_DEFERRED) + { + mContextResources->vertexBufferPosition = 0; + } + + // Hook lets the caller replace our settings with their own custom shaders. + if (mSetCustomShaders) + { + mSetCustomShaders(); + } +} + + +// Sends queued sprites to the graphics device. +void SpriteBatch::Impl::FlushBatch() +{ + if (!mSpriteQueueCount) + return; + + SortSprites(); + + // Walk through the sorted sprite list, looking for adjacent entries that share a texture. + ID3D11ShaderResourceView* batchTexture = nullptr; + size_t batchStart = 0; + + for (size_t pos = 0; pos < mSpriteQueueCount; pos++) + { + ID3D11ShaderResourceView* texture = mSortedSprites[pos]->texture; + + _Analysis_assume_(texture != nullptr); + + // Flush whenever the texture changes. + if (texture != batchTexture) + { + if (pos > batchStart) + { + RenderBatch(batchTexture, &mSortedSprites[batchStart], pos - batchStart); + } + + batchTexture = texture; + batchStart = pos; + } + } + + // Flush the final batch. + RenderBatch(batchTexture, &mSortedSprites[batchStart], mSpriteQueueCount - batchStart); + + // Reset the queue. + mSpriteQueueCount = 0; + mSpriteTextureReferences.clear(); + + // When sorting is disabled, we persist mSortedSprites data from one batch to the next, to avoid + // uneccessary work in GrowSortedSprites. But we never reuse these when sorting, because re-sorting + // previously sorted items gives unstable ordering if some sprites have identical sort keys. + if (mSortMode != SpriteSortMode_Deferred) + { + mSortedSprites.clear(); + } +} + + +// Sorts the array of queued sprites. +void SpriteBatch::Impl::SortSprites() +{ + // Fill the mSortedSprites vector. + if (mSortedSprites.size() < mSpriteQueueCount) + { + GrowSortedSprites(); + } + + switch (mSortMode) + { + case SpriteSortMode_Texture: + // Sort by texture. + std::sort(mSortedSprites.begin(), mSortedSprites.begin() + mSpriteQueueCount, [](SpriteInfo const* x, SpriteInfo const* y) -> bool + { + return x->texture < y->texture; + }); + break; + + case SpriteSortMode_BackToFront: + // Sort back to front. + std::sort(mSortedSprites.begin(), mSortedSprites.begin() + mSpriteQueueCount, [](SpriteInfo const* x, SpriteInfo const* y) -> bool + { + return x->originRotationDepth.w > y->originRotationDepth.w; + }); + break; + + case SpriteSortMode_FrontToBack: + // Sort front to back. + std::sort(mSortedSprites.begin(), mSortedSprites.begin() + mSpriteQueueCount, [](SpriteInfo const* x, SpriteInfo const* y) -> bool + { + return x->originRotationDepth.w < y->originRotationDepth.w; + }); + break; + } +} + + +// Populates the mSortedSprites vector with pointers to individual elements of the mSpriteQueue array. +void SpriteBatch::Impl::GrowSortedSprites() +{ + size_t previousSize = mSortedSprites.size(); + + mSortedSprites.resize(mSpriteQueueCount); + + for (size_t i = previousSize; i < mSpriteQueueCount; i++) + { + mSortedSprites[i] = &mSpriteQueue[i]; + } +} + + +// Submits a batch of sprites to the GPU. +void SpriteBatch::Impl::RenderBatch(_In_ ID3D11ShaderResourceView* texture, _In_reads_(count) SpriteInfo const* const* sprites, size_t count) +{ + auto deviceContext = mContextResources->deviceContext.Get(); + + // Draw using the specified texture. + deviceContext->PSSetShaderResources(0, 1, &texture); + + XMVECTOR textureSize = GetTextureSize(texture); + XMVECTOR inverseTextureSize = XMVectorReciprocal(textureSize); + + while (count > 0) + { + // How many sprites do we want to draw? + size_t batchSize = count; + + // How many sprites does the D3D vertex buffer have room for? + size_t remainingSpace = MaxBatchSize - mContextResources->vertexBufferPosition; + + if (batchSize > remainingSpace) + { + if (remainingSpace < MinBatchSize) + { + // If we are out of room, or about to submit an excessively small batch, wrap back to the start of the vertex buffer. + mContextResources->vertexBufferPosition = 0; + + batchSize = std::min(count, MaxBatchSize); + } + else + { + // Take however many sprites fit in what's left of the vertex buffer. + batchSize = remainingSpace; + } + } + +#if defined(_XBOX_ONE) && defined(_TITLE) + void *grfxMemory = GraphicsMemory::Get().Allocate(deviceContext, sizeof(VertexPositionColorTexture) * batchSize * VerticesPerSprite, 64); + + auto vertices = static_cast(grfxMemory); +#else + // Lock the vertex buffer. + D3D11_MAP mapType = (mContextResources->vertexBufferPosition == 0) ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE; + + D3D11_MAPPED_SUBRESOURCE mappedBuffer; + + ThrowIfFailed( + deviceContext->Map(mContextResources->vertexBuffer.Get(), 0, mapType, 0, &mappedBuffer) + ); + + auto vertices = static_cast(mappedBuffer.pData) + mContextResources->vertexBufferPosition * VerticesPerSprite; +#endif + + // Generate sprite vertex data. + for (size_t i = 0; i < batchSize; i++) + { + assert(i < count); + _Analysis_assume_(i < count); + RenderSprite(sprites[i], vertices, textureSize, inverseTextureSize); + + vertices += VerticesPerSprite; + } + +#if defined(_XBOX_ONE) && defined(_TITLE) + deviceContext->IASetPlacementVertexBuffer(0, mContextResources->vertexBuffer.Get(), grfxMemory, sizeof(VertexPositionColorTexture)); +#else + deviceContext->Unmap(mContextResources->vertexBuffer.Get(), 0); +#endif + + // Ok lads, the time has come for us draw ourselves some sprites! + UINT startIndex = (UINT)mContextResources->vertexBufferPosition * IndicesPerSprite; + UINT indexCount = (UINT)batchSize * IndicesPerSprite; + + deviceContext->DrawIndexed(indexCount, startIndex, 0); + + // Advance the buffer position. +#if !defined(_XBOX_ONE) || !defined(_TITLE) + mContextResources->vertexBufferPosition += batchSize; +#endif + + sprites += batchSize; + count -= batchSize; + } +} + + +// Generates vertex data for drawing a single sprite. +void XM_CALLCONV SpriteBatch::Impl::RenderSprite(_In_ SpriteInfo const* sprite, _Out_cap_c_(VerticesPerSprite) VertexPositionColorTexture* vertices, FXMVECTOR textureSize, FXMVECTOR inverseTextureSize) +{ + // Load sprite parameters into SIMD registers. + XMVECTOR source = XMLoadFloat4A(&sprite->source); + XMVECTOR destination = XMLoadFloat4A(&sprite->destination); + XMVECTOR color = XMLoadFloat4A(&sprite->color); + XMVECTOR originRotationDepth = XMLoadFloat4A(&sprite->originRotationDepth); + + float rotation = sprite->originRotationDepth.z; + int flags = sprite->flags; + + // Extract the source and destination sizes into separate vectors. + XMVECTOR sourceSize = XMVectorSwizzle<2, 3, 2, 3>(source); + XMVECTOR destinationSize = XMVectorSwizzle<2, 3, 2, 3>(destination); + + // Scale the origin offset by source size, taking care to avoid overflow if the source region is zero. + XMVECTOR isZeroMask = XMVectorEqual(sourceSize, XMVectorZero()); + XMVECTOR nonZeroSourceSize = XMVectorSelect(sourceSize, g_XMEpsilon, isZeroMask); + + XMVECTOR origin = XMVectorDivide(originRotationDepth, nonZeroSourceSize); + + // Convert the source region from texels to mod-1 texture coordinate format. + if (flags & SpriteInfo::SourceInTexels) + { + source *= inverseTextureSize; + sourceSize *= inverseTextureSize; + } + else + { + origin *= inverseTextureSize; + } + + // If the destination size is relative to the source region, convert it to pixels. + if (!(flags & SpriteInfo::DestSizeInPixels)) + { + destinationSize *= textureSize; + } + + // Compute a 2x2 rotation matrix. + XMVECTOR rotationMatrix1; + XMVECTOR rotationMatrix2; + + if (rotation != 0) + { + float sin, cos; + + XMScalarSinCos(&sin, &cos, rotation); + + XMVECTOR sinV = XMLoadFloat(&sin); + XMVECTOR cosV = XMLoadFloat(&cos); + + rotationMatrix1 = XMVectorMergeXY(cosV, sinV); + rotationMatrix2 = XMVectorMergeXY(-sinV, cosV); + } + else + { + rotationMatrix1 = g_XMIdentityR0; + rotationMatrix2 = g_XMIdentityR1; + } + + // The four corner vertices are computed by transforming these unit-square positions. + static XMVECTORF32 cornerOffsets[VerticesPerSprite] = + { + { 0, 0 }, + { 1, 0 }, + { 0, 1 }, + { 1, 1 }, + }; + + // Tricksy alert! Texture coordinates are computed from the same cornerOffsets + // table as vertex positions, but if the sprite is mirrored, this table + // must be indexed in a different order. This is done as follows: + // + // position = cornerOffsets[i] + // texcoord = cornerOffsets[i ^ SpriteEffects] + + static_assert(SpriteEffects_FlipHorizontally == 1 && + SpriteEffects_FlipVertically == 2, "If you change these enum values, the mirroring implementation must be updated to match"); + + int mirrorBits = flags & 3; + + // Generate the four output vertices. + for (int i = 0; i < VerticesPerSprite; i++) + { + // Calculate position. + XMVECTOR cornerOffset = (cornerOffsets[i] - origin) * destinationSize; + + // Apply 2x2 rotation matrix. + XMVECTOR position1 = XMVectorMultiplyAdd(XMVectorSplatX(cornerOffset), rotationMatrix1, destination); + XMVECTOR position2 = XMVectorMultiplyAdd(XMVectorSplatY(cornerOffset), rotationMatrix2, position1); + + // Set z = depth. + XMVECTOR position = XMVectorPermute<0, 1, 7, 6>(position2, originRotationDepth); + + // Write position as a Float4, even though VertexPositionColor::position is an XMFLOAT3. + // This is faster, and harmless as we are just clobbering the first element of the + // following color field, which will immediately be overwritten with its correct value. + XMStoreFloat4(reinterpret_cast(&vertices[i].position), position); + + // Write the color. + XMStoreFloat4(&vertices[i].color, color); + + // Compute and write the texture coordinate. + XMVECTOR textureCoordinate = XMVectorMultiplyAdd(cornerOffsets[i ^ mirrorBits], sourceSize, source); + + XMStoreFloat2(&vertices[i].textureCoordinate, textureCoordinate); + } +} + + +// Helper looks up the size of the specified texture. +XMVECTOR SpriteBatch::Impl::GetTextureSize(_In_ ID3D11ShaderResourceView* texture) +{ + // Convert resource view to underlying resource. + ComPtr resource; + + texture->GetResource(&resource); + + // Cast to texture. + ComPtr texture2D; + + if (FAILED(resource.As(&texture2D))) + { + throw std::exception("SpriteBatch can only draw Texture2D resources"); + } + + // Query the texture size. + D3D11_TEXTURE2D_DESC desc; + + texture2D->GetDesc(&desc); + + // Convert to vector format. + XMVECTOR size = XMVectorMergeXY(XMLoadInt(&desc.Width), + XMLoadInt(&desc.Height)); + + return XMConvertVectorUIntToFloat(size, 0); +} + + +// Generates a viewport transform matrix for rendering sprites using x-right y-down screen pixel coordinates. +XMMATRIX SpriteBatch::Impl::GetViewportTransform(_In_ ID3D11DeviceContext* deviceContext, DXGI_MODE_ROTATION rotation ) +{ + // Look up the current viewport. + if ( !mSetViewport ) + { + UINT viewportCount = 1; + + deviceContext->RSGetViewports(&viewportCount, &mViewPort); + + if (viewportCount != 1) + throw std::exception("No viewport is set"); + } + + // Compute the matrix. + float xScale = (mViewPort.Width > 0) ? 2.0f / mViewPort.Width : 0.0f; + float yScale = (mViewPort.Height > 0) ? 2.0f / mViewPort.Height : 0.0f; + + switch( rotation ) + { + case DXGI_MODE_ROTATION_ROTATE90: + return XMMATRIX + ( + 0, -yScale, 0, 0, + -xScale, 0, 0, 0, + 0, 0, 1, 0, + 1, 1, 0, 1 + ); + + case DXGI_MODE_ROTATION_ROTATE270: + return XMMATRIX + ( + 0, yScale, 0, 0, + xScale, 0, 0, 0, + 0, 0, 1, 0, + -1, -1, 0, 1 + ); + + case DXGI_MODE_ROTATION_ROTATE180: + return XMMATRIX + ( + -xScale, 0, 0, 0, + 0, yScale, 0, 0, + 0, 0, 1, 0, + 1, -1, 0, 1 + ); + + default: + return XMMATRIX + ( + xScale, 0, 0, 0, + 0, -yScale, 0, 0, + 0, 0, 1, 0, + -1, 1, 0, 1 + ); + } +} + + +// Public constructor. +SpriteBatch::SpriteBatch(_In_ ID3D11DeviceContext* deviceContext) + : pImpl(new Impl(deviceContext)) +{ +} + + +// Move constructor. +SpriteBatch::SpriteBatch(SpriteBatch&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +SpriteBatch& SpriteBatch::operator= (SpriteBatch&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +SpriteBatch::~SpriteBatch() +{ +} + + +void XM_CALLCONV SpriteBatch::Begin(SpriteSortMode sortMode, _In_opt_ ID3D11BlendState* blendState, _In_opt_ ID3D11SamplerState* samplerState, _In_opt_ ID3D11DepthStencilState* depthStencilState, _In_opt_ ID3D11RasterizerState* rasterizerState, _In_opt_ std::function setCustomShaders, FXMMATRIX transformMatrix) +{ + pImpl->Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, setCustomShaders, transformMatrix); +} + + +void SpriteBatch::End() +{ + pImpl->End(); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, FXMVECTOR color) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 5>(XMLoadFloat2(&position), g_XMOne); // x, y, 1, 1 + + pImpl->Draw(texture, destination, nullptr, color, g_XMZero, 0); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, float scale, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 4>(XMLoadFloat2(&position), XMLoadFloat(&scale)); // x, y, scale, scale + + XMVECTOR originRotationDepth = XMVectorSet(origin.x, origin.y, rotation, layerDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, XMFLOAT2 const& position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, XMFLOAT2 const& scale, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 5>(XMLoadFloat2(&position), XMLoadFloat2(&scale)); // x, y, scale.x, scale.y + + XMVECTOR originRotationDepth = XMVectorSet(origin.x, origin.y, rotation, layerDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, FXMVECTOR color) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 5>(position, g_XMOne); // x, y, 1, 1 + + pImpl->Draw(texture, destination, nullptr, color, g_XMZero, 0); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, FXMVECTOR origin, float scale, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 4>(position, XMLoadFloat(&scale)); // x, y, scale, scale + + XMVECTOR rotationDepth = XMVectorMergeXY(XMVectorReplicate(rotation), XMVectorReplicate(layerDepth)); + + XMVECTOR originRotationDepth = XMVectorPermute<0, 1, 4, 5>(origin, rotationDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, FXMVECTOR position, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, FXMVECTOR origin, GXMVECTOR scale, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = XMVectorPermute<0, 1, 4, 5>(position, scale); // x, y, scale.x, scale.y + + XMVECTOR rotationDepth = XMVectorMergeXY(XMVectorReplicate(rotation), XMVectorReplicate(layerDepth)); + + XMVECTOR originRotationDepth = XMVectorPermute<0, 1, 4, 5>(origin, rotationDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, FXMVECTOR color) +{ + XMVECTOR destination = LoadRect(&destinationRectangle); // x, y, w, h + + pImpl->Draw(texture, destination, nullptr, color, g_XMZero, Impl::SpriteInfo::DestSizeInPixels); +} + + +void XM_CALLCONV SpriteBatch::Draw(_In_ ID3D11ShaderResourceView* texture, RECT const& destinationRectangle, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, SpriteEffects effects, float layerDepth) +{ + XMVECTOR destination = LoadRect(&destinationRectangle); // x, y, w, h + + XMVECTOR originRotationDepth = XMVectorSet(origin.x, origin.y, rotation, layerDepth); + + pImpl->Draw(texture, destination, sourceRectangle, color, originRotationDepth, effects | Impl::SpriteInfo::DestSizeInPixels); +} + + +void SpriteBatch::SetRotation( DXGI_MODE_ROTATION mode ) +{ + pImpl->mRotation = mode; +} + + +DXGI_MODE_ROTATION SpriteBatch::GetRotation() const +{ + return pImpl->mRotation; +} + + +void SpriteBatch::SetViewport( const D3D11_VIEWPORT& viewPort ) +{ + pImpl->mSetViewport = true; + pImpl->mViewPort = viewPort; +} diff --git a/Kits/DirectXTK/Src/SpriteFont.cpp b/Kits/DirectXTK/Src/SpriteFont.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e16002273033d3543af014d47dff6cc65b9891f4 --- /dev/null +++ b/Kits/DirectXTK/Src/SpriteFont.cpp @@ -0,0 +1,398 @@ +//-------------------------------------------------------------------------------------- +// File: SpriteFont.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" + +#include +#include + +#include "SpriteFont.h" +#include "DirectXHelpers.h" +#include "BinaryReader.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + + +// Internal SpriteFont implementation class. +class SpriteFont::Impl +{ +public: + Impl(_In_ ID3D11Device* device, _In_ BinaryReader* reader); + Impl(_In_ ID3D11ShaderResourceView* texture, _In_reads_(glyphCount) Glyph const* glyphs, _In_ size_t glyphCount, _In_ float lineSpacing); + + Glyph const* FindGlyph(wchar_t character) const; + + void SetDefaultCharacter(wchar_t character); + + template + void ForEachGlyph(_In_z_ wchar_t const* text, TAction action) const; + + + // Fields. + ComPtr texture; + std::vector glyphs; + Glyph const* defaultGlyph; + float lineSpacing; +}; + + +// Constants. +const XMFLOAT2 SpriteFont::Float2Zero(0, 0); + +static const char spriteFontMagic[] = "DXTKfont"; + + +// Comparison operators make our sorted glyph vector work with std::binary_search and lower_bound. +namespace DirectX +{ + static inline bool operator< (SpriteFont::Glyph const& left, SpriteFont::Glyph const& right) + { + return left.Character < right.Character; + } + + static inline bool operator< (wchar_t left, SpriteFont::Glyph const& right) + { + return left < right.Character; + } + + static inline bool operator< (SpriteFont::Glyph const& left, wchar_t right) + { + return left.Character < right; + } +} + + +// Reads a SpriteFont from the binary format created by the MakeSpriteFont utility. +SpriteFont::Impl::Impl(_In_ ID3D11Device* device, _In_ BinaryReader* reader) +{ + // Validate the header. + for (char const* magic = spriteFontMagic; *magic; magic++) + { + if (reader->Read() != *magic) + { + DebugTrace( "SpriteFont provided with an invalid .spritefont file\n" ); + throw std::exception("Not a MakeSpriteFont output binary"); + } + } + + // Read the glyph data. + auto glyphCount = reader->Read(); + auto glyphData = reader->ReadArray(glyphCount); + + glyphs.assign(glyphData, glyphData + glyphCount); + + // Read font properties. + lineSpacing = reader->Read(); + + SetDefaultCharacter((wchar_t)reader->Read()); + + // Read the texture data. + auto textureWidth = reader->Read(); + auto textureHeight = reader->Read(); + auto textureFormat = reader->Read(); + auto textureStride = reader->Read(); + auto textureRows = reader->Read(); + auto textureData = reader->ReadArray(textureStride * textureRows); + + // Create the D3D texture. + CD3D11_TEXTURE2D_DESC textureDesc(textureFormat, textureWidth, textureHeight, 1, 1, D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_IMMUTABLE); + CD3D11_SHADER_RESOURCE_VIEW_DESC viewDesc(D3D11_SRV_DIMENSION_TEXTURE2D, textureFormat); + D3D11_SUBRESOURCE_DATA initData = { textureData, textureStride }; + ComPtr texture2D; + + ThrowIfFailed( + device->CreateTexture2D(&textureDesc, &initData, &texture2D) + ); + + ThrowIfFailed( + device->CreateShaderResourceView(texture2D.Get(), &viewDesc, &texture) + ); + + SetDebugObjectName(texture.Get(), "DirectXTK:SpriteFont"); + SetDebugObjectName(texture2D.Get(), "DirectXTK:SpriteFont"); +} + + +// Constructs a SpriteFont from arbitrary user specified glyph data. +SpriteFont::Impl::Impl(_In_ ID3D11ShaderResourceView* texture, _In_reads_(glyphCount) Glyph const* glyphs, _In_ size_t glyphCount, _In_ float lineSpacing) + : texture(texture), + glyphs(glyphs, glyphs + glyphCount), + lineSpacing(lineSpacing), + defaultGlyph(nullptr) +{ + if (!std::is_sorted(glyphs, glyphs + glyphCount)) + { + throw std::exception("Glyphs must be in ascending codepoint order"); + } +} + + +// Looks up the requested glyph, falling back to the default character if it is not in the font. +SpriteFont::Glyph const* SpriteFont::Impl::FindGlyph(wchar_t character) const +{ + auto glyph = std::lower_bound(glyphs.begin(), glyphs.end(), character); + + if (glyph != glyphs.end() && glyph->Character == character) + { + return &*glyph; + } + + if (defaultGlyph) + { + return defaultGlyph; + } + + DebugTrace( "SpriteFont encountered a character not in the font (%u, %C), and no default glyph was provided\n", character, character ); + throw std::exception("Character not in font"); +} + + +// Sets the missing-character fallback glyph. +void SpriteFont::Impl::SetDefaultCharacter(wchar_t character) +{ + defaultGlyph = nullptr; + + if (character) + { + defaultGlyph = FindGlyph(character); + } +} + + +// The core glyph layout algorithm, shared between DrawString and MeasureString. +template +void SpriteFont::Impl::ForEachGlyph(_In_z_ wchar_t const* text, TAction action) const +{ + float x = 0; + float y = 0; + + for (; *text; text++) + { + wchar_t character = *text; + + switch (character) + { + case '\r': + // Skip carriage returns. + continue; + + case '\n': + // New line. + x = 0; + y += lineSpacing; + break; + + default: + // Output this character. + auto glyph = FindGlyph(character); + + x += glyph->XOffset; + + if (x < 0) + x = 0; + + if ( !iswspace(character) + || ( ( glyph->Subrect.right - glyph->Subrect.left ) > 1 ) + || ( ( glyph->Subrect.bottom - glyph->Subrect.top ) > 1 ) ) + { + action(glyph, x, y); + } + + x += glyph->Subrect.right - glyph->Subrect.left + glyph->XAdvance; + break; + } + } +} + + +// Construct from a binary file created by the MakeSpriteFont utility. +SpriteFont::SpriteFont(_In_ ID3D11Device* device, _In_z_ wchar_t const* fileName) +{ + BinaryReader reader(fileName); + + pImpl.reset(new Impl(device, &reader)); +} + + +// Construct from a binary blob created by the MakeSpriteFont utility and already loaded into memory. +SpriteFont::SpriteFont(_In_ ID3D11Device* device, _In_reads_bytes_(dataSize) uint8_t const* dataBlob, _In_ size_t dataSize) +{ + BinaryReader reader(dataBlob, dataSize); + + pImpl.reset(new Impl(device, &reader)); +} + + +// Construct from arbitrary user specified glyph data (for those not using the MakeSpriteFont utility). +SpriteFont::SpriteFont(_In_ ID3D11ShaderResourceView* texture, _In_reads_(glyphCount) Glyph const* glyphs, _In_ size_t glyphCount, _In_ float lineSpacing) + : pImpl(new Impl(texture, glyphs, glyphCount, lineSpacing)) +{ +} + + +// Move constructor. +SpriteFont::SpriteFont(SpriteFont&& moveFrom) + : pImpl(std::move(moveFrom.pImpl)) +{ +} + + +// Move assignment. +SpriteFont& SpriteFont::operator= (SpriteFont&& moveFrom) +{ + pImpl = std::move(moveFrom.pImpl); + return *this; +} + + +// Public destructor. +SpriteFont::~SpriteFont() +{ +} + + +void XM_CALLCONV SpriteFont::DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, XMFLOAT2 const& position, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, float scale, SpriteEffects effects, float layerDepth) const +{ + DrawString(spriteBatch, text, XMLoadFloat2(&position), color, rotation, XMLoadFloat2(&origin), XMVectorReplicate(scale), effects, layerDepth); +} + + +void XM_CALLCONV SpriteFont::DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, XMFLOAT2 const& position, FXMVECTOR color, float rotation, XMFLOAT2 const& origin, XMFLOAT2 const& scale, SpriteEffects effects, float layerDepth) const +{ + DrawString(spriteBatch, text, XMLoadFloat2(&position), color, rotation, XMLoadFloat2(&origin), XMLoadFloat2(&scale), effects, layerDepth); +} + + +void XM_CALLCONV SpriteFont::DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, FXMVECTOR position, FXMVECTOR color, float rotation, FXMVECTOR origin, float scale, SpriteEffects effects, float layerDepth) const +{ + DrawString(spriteBatch, text, position, color, rotation, origin, XMVectorReplicate(scale), effects, layerDepth); +} + + +void XM_CALLCONV SpriteFont::DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wchar_t const* text, FXMVECTOR position, FXMVECTOR color, float rotation, FXMVECTOR origin, GXMVECTOR scale, SpriteEffects effects, float layerDepth) const +{ + static_assert(SpriteEffects_FlipHorizontally == 1 && + SpriteEffects_FlipVertically == 2, "If you change these enum values, the following tables must be updated to match"); + + // Lookup table indicates which way to move along each axis per SpriteEffects enum value. + static XMVECTORF32 axisDirectionTable[4] = + { + { -1, -1 }, + { 1, -1 }, + { -1, 1 }, + { 1, 1 }, + }; + + // Lookup table indicates which axes are mirrored for each SpriteEffects enum value. + static XMVECTORF32 axisIsMirroredTable[4] = + { + { 0, 0 }, + { 1, 0 }, + { 0, 1 }, + { 1, 1 }, + }; + + XMVECTOR baseOffset = origin; + + // If the text is mirrored, offset the start position accordingly. + if (effects) + { + baseOffset -= MeasureString(text) * axisIsMirroredTable[effects & 3]; + } + + // Draw each character in turn. + pImpl->ForEachGlyph(text, [&](Glyph const* glyph, float x, float y) + { + XMVECTOR offset = XMVectorMultiplyAdd(XMVectorSet(x, y + glyph->YOffset, 0, 0), axisDirectionTable[effects & 3], baseOffset); + + if (effects) + { + // For mirrored characters, specify bottom and/or right instead of top left. + XMVECTOR glyphRect = XMConvertVectorIntToFloat(XMLoadInt4(reinterpret_cast(&glyph->Subrect)), 0); + + // xy = glyph width/height. + glyphRect = XMVectorSwizzle<2, 3, 0, 1>(glyphRect) - glyphRect; + + offset = XMVectorMultiplyAdd(glyphRect, axisIsMirroredTable[effects & 3], offset); + } + + spriteBatch->Draw(pImpl->texture.Get(), position, &glyph->Subrect, color, rotation, offset, scale, effects, layerDepth); + }); +} + + +XMVECTOR XM_CALLCONV SpriteFont::MeasureString(_In_z_ wchar_t const* text) const +{ + XMVECTOR result = XMVectorZero(); + + pImpl->ForEachGlyph(text, [&](Glyph const* glyph, float x, float y) + { + float w = (float)(glyph->Subrect.right - glyph->Subrect.left) + glyph->XAdvance; + float h = (float)(glyph->Subrect.bottom - glyph->Subrect.top) + glyph->YOffset; + + h = std::max(h, pImpl->lineSpacing); + + result = XMVectorMax(result, XMVectorSet(x + w, y + h, 0, 0)); + }); + + return result; +} + + +// Spacing properties +float SpriteFont::GetLineSpacing() const +{ + return pImpl->lineSpacing; +} + + +void SpriteFont::SetLineSpacing(float spacing) +{ + pImpl->lineSpacing = spacing; +} + + +// Font properties +wchar_t SpriteFont::GetDefaultCharacter() const +{ + return pImpl->defaultGlyph ? (wchar_t)pImpl->defaultGlyph->Character : 0; +} + + +void SpriteFont::SetDefaultCharacter(wchar_t character) +{ + pImpl->SetDefaultCharacter(character); +} + + +bool SpriteFont::ContainsCharacter(wchar_t character) const +{ + return std::binary_search(pImpl->glyphs.begin(), pImpl->glyphs.end(), character); +} + + +// Custom layout/rendering +SpriteFont::Glyph const* SpriteFont::FindGlyph(wchar_t character) const +{ + return pImpl->FindGlyph(character); +} + + +void SpriteFont::GetSpriteSheet( ID3D11ShaderResourceView** texture ) const +{ + if ( !texture ) + return; + + ThrowIfFailed( pImpl->texture.CopyTo( texture ) ); +} diff --git a/Kits/DirectXTK/Src/TeapotData.inc b/Kits/DirectXTK/Src/TeapotData.inc new file mode 100644 index 0000000000000000000000000000000000000000..00def9c9228a62e5befb54df38cefeefe65c3bb2 --- /dev/null +++ b/Kits/DirectXTK/Src/TeapotData.inc @@ -0,0 +1,185 @@ +//-------------------------------------------------------------------------------------- +// File: TeapotData.inc +// +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + + +// The teapot model consists of 10 bezier patches. Each patch has 16 control +// points, plus a flag indicating whether it should be mirrored in the Z axis +// as well as in X (all of the teapot is symmetrical from left to right, but +// only some parts are symmetrical from front to back). The control points +// are stored as integer indices into the TeapotControlPoints array. + +struct TeapotPatch +{ + bool mirrorZ; + int indices[16]; +}; + + +// Static data array defines the bezier patches that make up the teapot. +const TeapotPatch TeapotPatches[] = +{ + // Rim. + { true, { 102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } }, + + // Body. + { true, { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 } }, + { true, { 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 } }, + + // Lid. + { true, { 96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101, 101, 0, 1, 2, 3 } }, + { true, { 0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117 } }, + + // Handle. + { false, { 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56 } }, + { false, { 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 28, 65, 66, 67 } }, + + // Spout. + { false, { 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83 } }, + { false, { 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95 } }, + + // Bottom. + { true, { 118, 118, 118, 118, 124, 122, 119, 121, 123, 126, 125, 120, 40, 39, 38, 37 } }, +}; + + +// Static array defines the control point positions that make up the teapot. +const DirectX::XMVECTORF32 TeapotControlPoints[] = +{ + { 0, 0.345f, -0.05f }, + { -0.028f, 0.345f, -0.05f }, + { -0.05f, 0.345f, -0.028f }, + { -0.05f, 0.345f, -0 }, + { 0, 0.3028125f, -0.334375f }, + { -0.18725f, 0.3028125f, -0.334375f }, + { -0.334375f, 0.3028125f, -0.18725f }, + { -0.334375f, 0.3028125f, -0 }, + { 0, 0.3028125f, -0.359375f }, + { -0.20125f, 0.3028125f, -0.359375f }, + { -0.359375f, 0.3028125f, -0.20125f }, + { -0.359375f, 0.3028125f, -0 }, + { 0, 0.27f, -0.375f }, + { -0.21f, 0.27f, -0.375f }, + { -0.375f, 0.27f, -0.21f }, + { -0.375f, 0.27f, -0 }, + { 0, 0.13875f, -0.4375f }, + { -0.245f, 0.13875f, -0.4375f }, + { -0.4375f, 0.13875f, -0.245f }, + { -0.4375f, 0.13875f, -0 }, + { 0, 0.007499993f, -0.5f }, + { -0.28f, 0.007499993f, -0.5f }, + { -0.5f, 0.007499993f, -0.28f }, + { -0.5f, 0.007499993f, -0 }, + { 0, -0.105f, -0.5f }, + { -0.28f, -0.105f, -0.5f }, + { -0.5f, -0.105f, -0.28f }, + { -0.5f, -0.105f, -0 }, + { 0, -0.105f, 0.5f }, + { 0, -0.2175f, -0.5f }, + { -0.28f, -0.2175f, -0.5f }, + { -0.5f, -0.2175f, -0.28f }, + { -0.5f, -0.2175f, -0 }, + { 0, -0.27375f, -0.375f }, + { -0.21f, -0.27375f, -0.375f }, + { -0.375f, -0.27375f, -0.21f }, + { -0.375f, -0.27375f, -0 }, + { 0, -0.2925f, -0.375f }, + { -0.21f, -0.2925f, -0.375f }, + { -0.375f, -0.2925f, -0.21f }, + { -0.375f, -0.2925f, -0 }, + { 0, 0.17625f, 0.4f }, + { -0.075f, 0.17625f, 0.4f }, + { -0.075f, 0.2325f, 0.375f }, + { 0, 0.2325f, 0.375f }, + { 0, 0.17625f, 0.575f }, + { -0.075f, 0.17625f, 0.575f }, + { -0.075f, 0.2325f, 0.625f }, + { 0, 0.2325f, 0.625f }, + { 0, 0.17625f, 0.675f }, + { -0.075f, 0.17625f, 0.675f }, + { -0.075f, 0.2325f, 0.75f }, + { 0, 0.2325f, 0.75f }, + { 0, 0.12f, 0.675f }, + { -0.075f, 0.12f, 0.675f }, + { -0.075f, 0.12f, 0.75f }, + { 0, 0.12f, 0.75f }, + { 0, 0.06375f, 0.675f }, + { -0.075f, 0.06375f, 0.675f }, + { -0.075f, 0.007499993f, 0.75f }, + { 0, 0.007499993f, 0.75f }, + { 0, -0.04875001f, 0.625f }, + { -0.075f, -0.04875001f, 0.625f }, + { -0.075f, -0.09562501f, 0.6625f }, + { 0, -0.09562501f, 0.6625f }, + { -0.075f, -0.105f, 0.5f }, + { -0.075f, -0.18f, 0.475f }, + { 0, -0.18f, 0.475f }, + { 0, 0.02624997f, -0.425f }, + { -0.165f, 0.02624997f, -0.425f }, + { -0.165f, -0.18f, -0.425f }, + { 0, -0.18f, -0.425f }, + { 0, 0.02624997f, -0.65f }, + { -0.165f, 0.02624997f, -0.65f }, + { -0.165f, -0.12375f, -0.775f }, + { 0, -0.12375f, -0.775f }, + { 0, 0.195f, -0.575f }, + { -0.0625f, 0.195f, -0.575f }, + { -0.0625f, 0.17625f, -0.6f }, + { 0, 0.17625f, -0.6f }, + { 0, 0.27f, -0.675f }, + { -0.0625f, 0.27f, -0.675f }, + { -0.0625f, 0.27f, -0.825f }, + { 0, 0.27f, -0.825f }, + { 0, 0.28875f, -0.7f }, + { -0.0625f, 0.28875f, -0.7f }, + { -0.0625f, 0.2934375f, -0.88125f }, + { 0, 0.2934375f, -0.88125f }, + { 0, 0.28875f, -0.725f }, + { -0.0375f, 0.28875f, -0.725f }, + { -0.0375f, 0.298125f, -0.8625f }, + { 0, 0.298125f, -0.8625f }, + { 0, 0.27f, -0.7f }, + { -0.0375f, 0.27f, -0.7f }, + { -0.0375f, 0.27f, -0.8f }, + { 0, 0.27f, -0.8f }, + { 0, 0.4575f, -0 }, + { 0, 0.4575f, -0.2f }, + { -0.1125f, 0.4575f, -0.2f }, + { -0.2f, 0.4575f, -0.1125f }, + { -0.2f, 0.4575f, -0 }, + { 0, 0.3825f, -0 }, + { 0, 0.27f, -0.35f }, + { -0.196f, 0.27f, -0.35f }, + { -0.35f, 0.27f, -0.196f }, + { -0.35f, 0.27f, -0 }, + { 0, 0.3075f, -0.1f }, + { -0.056f, 0.3075f, -0.1f }, + { -0.1f, 0.3075f, -0.056f }, + { -0.1f, 0.3075f, -0 }, + { 0, 0.3075f, -0.325f }, + { -0.182f, 0.3075f, -0.325f }, + { -0.325f, 0.3075f, -0.182f }, + { -0.325f, 0.3075f, -0 }, + { 0, 0.27f, -0.325f }, + { -0.182f, 0.27f, -0.325f }, + { -0.325f, 0.27f, -0.182f }, + { -0.325f, 0.27f, -0 }, + { 0, -0.33f, -0 }, + { -0.1995f, -0.33f, -0.35625f }, + { 0, -0.31125f, -0.375f }, + { 0, -0.33f, -0.35625f }, + { -0.35625f, -0.33f, -0.1995f }, + { -0.375f, -0.31125f, -0 }, + { -0.35625f, -0.33f, -0 }, + { -0.21f, -0.31125f, -0.375f }, + { -0.375f, -0.31125f, -0.21f }, +}; diff --git a/Kits/DirectXTK/Src/VertexTypes.cpp b/Kits/DirectXTK/Src/VertexTypes.cpp new file mode 100644 index 0000000000000000000000000000000000000000..576780bc48d57a479a81d582abafeb6ec2c4ce86 --- /dev/null +++ b/Kits/DirectXTK/Src/VertexTypes.cpp @@ -0,0 +1,155 @@ +//-------------------------------------------------------------------------------------- +// File: VertexTypes.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "VertexTypes.h" + +#include + +using namespace DirectX; +using namespace DirectX::PackedVector; + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position and color information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionColor::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionColor) == 28, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position and texture mapping information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionTexture) == 20, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position and normal vector. +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormal::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormal) == 24, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position, color, and texture mapping information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionColorTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionColorTexture) == 36, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position, normal vector, and color information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalColor::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormalColor) == 40, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position, normal vector, and texture mapping information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormalTexture) == 32, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct holding position, normal vector, color, and texture mapping information. +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalColorTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormalColorTexture) == 48, "Vertex struct/layout mismatch" ); + + +//-------------------------------------------------------------------------------------- +// Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, +// tangent, color (RGBA), and texture mapping information +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalTangentColorTexture::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TANGENT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( sizeof(VertexPositionNormalTangentColorTexture) == 52, "Vertex struct/layout mismatch" ); + +void XM_CALLCONV VertexPositionNormalTangentColorTexture::SetColor( FXMVECTOR icolor ) +{ + XMUBYTEN4 rgba; + XMStoreUByteN4( &rgba, icolor ); + this->color = rgba.v; +} + + +//-------------------------------------------------------------------------------------- +// Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, +// tangent, color (RGBA), texture mapping information, and skinning weights +const D3D11_INPUT_ELEMENT_DESC VertexPositionNormalTangentColorTextureSkinning::InputElements[] = +{ + { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TANGENT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BLENDINDICES",0, DXGI_FORMAT_R8G8B8A8_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BLENDWEIGHT", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, +}; + +static_assert( VertexPositionNormalTangentColorTextureSkinning::InputElementCount == VertexPositionNormalTangentColorTexture::InputElementCount + 2, "layout mismatch"); + +static_assert( sizeof(VertexPositionNormalTangentColorTextureSkinning) == 60, "Vertex struct/layout mismatch" ); + +void VertexPositionNormalTangentColorTextureSkinning::SetBlendIndices( XMUINT4 const& iindices ) +{ + this->indices = ( (iindices.w & 0xff) << 24 ) | ( (iindices.z & 0xff) << 16 ) | ( (iindices.y & 0xff) << 8 ) | ( iindices.x & 0xff ); +} + +void XM_CALLCONV VertexPositionNormalTangentColorTextureSkinning::SetBlendWeights( FXMVECTOR iweights ) +{ + XMUBYTEN4 packed; + XMStoreUByteN4( &packed, iweights ); + this->weights = packed.v; +} diff --git a/Kits/DirectXTK/Src/WICTextureLoader.cpp b/Kits/DirectXTK/Src/WICTextureLoader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4bfde87eedc423f7ff62ff965ae697136da19f48 --- /dev/null +++ b/Kits/DirectXTK/Src/WICTextureLoader.cpp @@ -0,0 +1,1172 @@ +//-------------------------------------------------------------------------------------- +// File: WICTextureLoader.cpp +// +// Function for loading a WIC image and creating a Direct3D 11 runtime texture for it +// (auto-generating mipmaps if possible) +// +// Note: Assumes application has already called CoInitializeEx +// +// Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for +// auto-gen mipmap support. +// +// Note these functions are useful for images created as simple 2D textures. For +// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. +// 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. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +// We could load multi-frame images (TIFF/GIF) into a texture array. +// For now, we just load the first frame (note: DirectXTex supports multi-frame images) + +#include "pch.h" + +// VS 2010's stdint.h conflicts with intsafe.h +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +#include "WICTextureLoader.h" + +#include "DirectXHelpers.h" +#include "PlatformHelpers.h" + +using namespace DirectX; +using Microsoft::WRL::ComPtr; + +//------------------------------------------------------------------------------------- +// WIC Pixel Format Translation Data +//------------------------------------------------------------------------------------- +struct WICTranslate +{ + GUID wic; + DXGI_FORMAT format; +}; + +static WICTranslate g_WICFormats[] = +{ + { GUID_WICPixelFormat128bppRGBAFloat, DXGI_FORMAT_R32G32B32A32_FLOAT }, + + { GUID_WICPixelFormat64bppRGBAHalf, DXGI_FORMAT_R16G16B16A16_FLOAT }, + { GUID_WICPixelFormat64bppRGBA, DXGI_FORMAT_R16G16B16A16_UNORM }, + + { GUID_WICPixelFormat32bppRGBA, DXGI_FORMAT_R8G8B8A8_UNORM }, + { GUID_WICPixelFormat32bppBGRA, DXGI_FORMAT_B8G8R8A8_UNORM }, // DXGI 1.1 + { GUID_WICPixelFormat32bppBGR, DXGI_FORMAT_B8G8R8X8_UNORM }, // DXGI 1.1 + + { GUID_WICPixelFormat32bppRGBA1010102XR, DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM }, // DXGI 1.1 + { GUID_WICPixelFormat32bppRGBA1010102, DXGI_FORMAT_R10G10B10A2_UNORM }, + + { GUID_WICPixelFormat16bppBGRA5551, DXGI_FORMAT_B5G5R5A1_UNORM }, + { GUID_WICPixelFormat16bppBGR565, DXGI_FORMAT_B5G6R5_UNORM }, + + { GUID_WICPixelFormat32bppGrayFloat, DXGI_FORMAT_R32_FLOAT }, + { GUID_WICPixelFormat16bppGrayHalf, DXGI_FORMAT_R16_FLOAT }, + { GUID_WICPixelFormat16bppGray, DXGI_FORMAT_R16_UNORM }, + { GUID_WICPixelFormat8bppGray, DXGI_FORMAT_R8_UNORM }, + + { GUID_WICPixelFormat8bppAlpha, DXGI_FORMAT_A8_UNORM }, +}; + +//------------------------------------------------------------------------------------- +// WIC Pixel Format nearest conversion table +//------------------------------------------------------------------------------------- + +struct WICConvert +{ + GUID source; + GUID target; +}; + +static WICConvert g_WICConvert[] = +{ + // Note target GUID in this conversion table must be one of those directly supported formats (above). + + { GUID_WICPixelFormatBlackWhite, GUID_WICPixelFormat8bppGray }, // DXGI_FORMAT_R8_UNORM + + { GUID_WICPixelFormat1bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + { GUID_WICPixelFormat2bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + { GUID_WICPixelFormat4bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + { GUID_WICPixelFormat8bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + + { GUID_WICPixelFormat2bppGray, GUID_WICPixelFormat8bppGray }, // DXGI_FORMAT_R8_UNORM + { GUID_WICPixelFormat4bppGray, GUID_WICPixelFormat8bppGray }, // DXGI_FORMAT_R8_UNORM + + { GUID_WICPixelFormat16bppGrayFixedPoint, GUID_WICPixelFormat16bppGrayHalf }, // DXGI_FORMAT_R16_FLOAT + { GUID_WICPixelFormat32bppGrayFixedPoint, GUID_WICPixelFormat32bppGrayFloat }, // DXGI_FORMAT_R32_FLOAT + + { GUID_WICPixelFormat16bppBGR555, GUID_WICPixelFormat16bppBGRA5551 }, // DXGI_FORMAT_B5G5R5A1_UNORM + + { GUID_WICPixelFormat32bppBGR101010, GUID_WICPixelFormat32bppRGBA1010102 }, // DXGI_FORMAT_R10G10B10A2_UNORM + + { GUID_WICPixelFormat24bppBGR, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + { GUID_WICPixelFormat24bppRGB, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + { GUID_WICPixelFormat32bppPBGRA, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + { GUID_WICPixelFormat32bppPRGBA, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + + { GUID_WICPixelFormat48bppRGB, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM + { GUID_WICPixelFormat48bppBGR, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM + { GUID_WICPixelFormat64bppBGRA, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM + { GUID_WICPixelFormat64bppPRGBA, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM + { GUID_WICPixelFormat64bppPBGRA, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM + + { GUID_WICPixelFormat48bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT + { GUID_WICPixelFormat48bppBGRFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT + { GUID_WICPixelFormat64bppRGBAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT + { GUID_WICPixelFormat64bppBGRAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT + { GUID_WICPixelFormat64bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT + { GUID_WICPixelFormat64bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT + { GUID_WICPixelFormat48bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT + + { GUID_WICPixelFormat128bppPRGBAFloat, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT + { GUID_WICPixelFormat128bppRGBFloat, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT + { GUID_WICPixelFormat128bppRGBAFixedPoint, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT + { GUID_WICPixelFormat128bppRGBFixedPoint, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT + { GUID_WICPixelFormat32bppRGBE, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT + + { GUID_WICPixelFormat32bppCMYK, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + { GUID_WICPixelFormat64bppCMYK, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM + { GUID_WICPixelFormat40bppCMYKAlpha, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM + { GUID_WICPixelFormat80bppCMYKAlpha, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) + { GUID_WICPixelFormat32bppRGB, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM + { GUID_WICPixelFormat64bppRGB, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM + { GUID_WICPixelFormat64bppPRGBAHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT +#endif + + // We don't support n-channel formats +}; + +static bool g_WIC2 = false; + +//-------------------------------------------------------------------------------------- +namespace DirectX +{ + +bool _IsWIC2() +{ + return g_WIC2; +} + +IWICImagingFactory* _GetWIC() +{ + static IWICImagingFactory* s_Factory = nullptr; + + if ( s_Factory ) + return s_Factory; + +#if(_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) + HRESULT hr = CoCreateInstance( + CLSID_WICImagingFactory2, + nullptr, + CLSCTX_INPROC_SERVER, + __uuidof(IWICImagingFactory2), + (LPVOID*)&s_Factory + ); + + if ( SUCCEEDED(hr) ) + { + // WIC2 is available on Windows 8 and Windows 7 SP1 with KB 2670838 installed + g_WIC2 = true; + } + else + { + hr = CoCreateInstance( + CLSID_WICImagingFactory1, + nullptr, + CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(&s_Factory) + ); + + if ( FAILED(hr) ) + { + s_Factory = nullptr; + return nullptr; + } + } +#else + HRESULT hr = CoCreateInstance( + CLSID_WICImagingFactory, + nullptr, + CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(&s_Factory) + ); + + if ( FAILED(hr) ) + { + s_Factory = nullptr; + return nullptr; + } +#endif + + return s_Factory; +} + +} // namespace DirectX + + +//--------------------------------------------------------------------------------- +static DXGI_FORMAT _WICToDXGI( const GUID& guid ) +{ + for( size_t i=0; i < _countof(g_WICFormats); ++i ) + { + if ( memcmp( &g_WICFormats[i].wic, &guid, sizeof(GUID) ) == 0 ) + return g_WICFormats[i].format; + } + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) + if ( g_WIC2 ) + { + if ( memcmp( &GUID_WICPixelFormat96bppRGBFloat, &guid, sizeof(GUID) ) == 0 ) + return DXGI_FORMAT_R32G32B32_FLOAT; + } +#endif + + return DXGI_FORMAT_UNKNOWN; +} + +//--------------------------------------------------------------------------------- +static size_t _WICBitsPerPixel( REFGUID targetGuid ) +{ + IWICImagingFactory* pWIC = _GetWIC(); + if ( !pWIC ) + return 0; + + ComPtr cinfo; + if ( FAILED( pWIC->CreateComponentInfo( targetGuid, cinfo.GetAddressOf() ) ) ) + return 0; + + WICComponentType type; + if ( FAILED( cinfo->GetComponentType( &type ) ) ) + return 0; + + if ( type != WICPixelFormat ) + return 0; + + ComPtr pfinfo; + if ( FAILED( cinfo.As( &pfinfo ) ) ) + return 0; + + UINT bpp; + if ( FAILED( pfinfo->GetBitsPerPixel( &bpp ) ) ) + return 0; + + return bpp; +} + + +//-------------------------------------------------------------------------------------- +static DXGI_FORMAT MakeSRGB( _In_ DXGI_FORMAT format ) +{ + switch( format ) + { + 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_BC2_UNORM: + return DXGI_FORMAT_BC2_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_B8G8R8X8_UNORM: + return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; + + case DXGI_FORMAT_BC7_UNORM: + return DXGI_FORMAT_BC7_UNORM_SRGB; + + default: + return format; + } +} + + +//--------------------------------------------------------------------------------- +static HRESULT CreateTextureFromWIC( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, +#if defined(_XBOX_ONE) && defined(_TITLE) + _In_opt_ ID3D11DeviceX* d3dDeviceX, + _In_opt_ ID3D11DeviceContextX* d3dContextX, +#endif + _In_ IWICBitmapFrameDecode *frame, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView ) +{ + UINT width, height; + HRESULT hr = frame->GetSize( &width, &height ); + if ( FAILED(hr) ) + return hr; + + assert( width > 0 && height > 0 ); + + if ( !maxsize ) + { + // This is a bit conservative because the hardware could support larger textures than + // the Feature Level defined minimums, but doing it this way is much easier and more + // performant for WIC than the 'fail and retry' model used by DDSTextureLoader + + switch( d3dDevice->GetFeatureLevel() ) + { + case D3D_FEATURE_LEVEL_9_1: + case D3D_FEATURE_LEVEL_9_2: + maxsize = 2048 /*D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; + break; + + case D3D_FEATURE_LEVEL_9_3: + maxsize = 4096 /*D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; + break; + + case D3D_FEATURE_LEVEL_10_0: + case D3D_FEATURE_LEVEL_10_1: + maxsize = 8192 /*D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; + break; + + default: + maxsize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; + break; + } + } + + assert( maxsize > 0 ); + + UINT twidth, theight; + if ( width > maxsize || height > maxsize ) + { + float ar = static_cast(height) / static_cast(width); + if ( width > height ) + { + twidth = static_cast( maxsize ); + theight = static_cast( static_cast(maxsize) * ar ); + } + else + { + theight = static_cast( maxsize ); + twidth = static_cast( static_cast(maxsize) / ar ); + } + assert( twidth <= maxsize && theight <= maxsize ); + } + else + { + twidth = width; + theight = height; + } + + // Determine format + WICPixelFormatGUID pixelFormat; + hr = frame->GetPixelFormat( &pixelFormat ); + if ( FAILED(hr) ) + return hr; + + WICPixelFormatGUID convertGUID; + memcpy( &convertGUID, &pixelFormat, sizeof(WICPixelFormatGUID) ); + + size_t bpp = 0; + + DXGI_FORMAT format = _WICToDXGI( pixelFormat ); + if ( format == DXGI_FORMAT_UNKNOWN ) + { + if ( memcmp( &GUID_WICPixelFormat96bppRGBFixedPoint, &pixelFormat, sizeof(WICPixelFormatGUID) ) == 0 ) + { +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) + if ( g_WIC2 ) + { + memcpy( &convertGUID, &GUID_WICPixelFormat96bppRGBFloat, sizeof(WICPixelFormatGUID) ); + format = DXGI_FORMAT_R32G32B32_FLOAT; + } + else +#endif + { + memcpy( &convertGUID, &GUID_WICPixelFormat128bppRGBAFloat, sizeof(WICPixelFormatGUID) ); + format = DXGI_FORMAT_R32G32B32A32_FLOAT; + } + } + else + { + for( size_t i=0; i < _countof(g_WICConvert); ++i ) + { + if ( memcmp( &g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID) ) == 0 ) + { + memcpy( &convertGUID, &g_WICConvert[i].target, sizeof(WICPixelFormatGUID) ); + + format = _WICToDXGI( g_WICConvert[i].target ); + assert( format != DXGI_FORMAT_UNKNOWN ); + bpp = _WICBitsPerPixel( convertGUID ); + break; + } + } + } + + if ( format == DXGI_FORMAT_UNKNOWN ) + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + else + { + bpp = _WICBitsPerPixel( pixelFormat ); + } + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) + if ( (format == DXGI_FORMAT_R32G32B32_FLOAT) && d3dContext != 0 && textureView != 0 ) + { + // Special case test for optional device support for autogen mipchains for R32G32B32_FLOAT + UINT fmtSupport = 0; + hr = d3dDevice->CheckFormatSupport( DXGI_FORMAT_R32G32B32_FLOAT, &fmtSupport ); + if ( FAILED(hr) || !( fmtSupport & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN ) ) + { + // Use R32G32B32A32_FLOAT instead which is required for Feature Level 10.0 and up + memcpy( &convertGUID, &GUID_WICPixelFormat128bppRGBAFloat, sizeof(WICPixelFormatGUID) ); + format = DXGI_FORMAT_R32G32B32A32_FLOAT; + bpp = 128; + } + } +#endif + + if ( !bpp ) + return E_FAIL; + + // Handle sRGB formats + if ( forceSRGB ) + { + format = MakeSRGB( format ); + } + else + { + ComPtr metareader; + if ( SUCCEEDED( frame->GetMetadataQueryReader( metareader.GetAddressOf() ) ) ) + { + GUID containerFormat; + if ( SUCCEEDED( metareader->GetContainerFormat( &containerFormat ) ) ) + { + // Check for sRGB colorspace metadata + bool sRGB = false; + + PROPVARIANT value; + PropVariantInit( &value ); + + if ( memcmp( &containerFormat, &GUID_ContainerFormatPng, sizeof(GUID) ) == 0 ) + { + // Check for sRGB chunk + if ( SUCCEEDED( metareader->GetMetadataByName( L"/sRGB/RenderingIntent", &value ) ) && value.vt == VT_UI1 ) + { + sRGB = true; + } + } +#if defined(_XBOX_ONE) && defined(_TITLE) + else if ( memcmp( &containerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID) ) == 0 ) + { + if ( SUCCEEDED( metareader->GetMetadataByName( L"/app1/ifd/exif/{ushort=40961}", &value ) ) && value.vt == VT_UI2 && value.uiVal == 1 ) + { + sRGB = true; + } + } + else if ( memcmp( &containerFormat, &GUID_ContainerFormatTiff, sizeof(GUID) ) == 0 ) + { + if ( SUCCEEDED( metareader->GetMetadataByName( L"/ifd/exif/{ushort=40961}", &value ) ) && value.vt == VT_UI2 && value.uiVal == 1 ) + { + sRGB = true; + } + } +#else + else if ( SUCCEEDED( metareader->GetMetadataByName( L"System.Image.ColorSpace", &value ) ) && value.vt == VT_UI2 && value.uiVal == 1 ) + { + sRGB = true; + } +#endif + + PropVariantClear( &value ); + + if ( sRGB ) + format = MakeSRGB( format ); + } + } + } + + // Verify our target format is supported by the current device + // (handles WDDM 1.0 or WDDM 1.1 device driver cases as well as DirectX 11.0 Runtime without 16bpp format support) + UINT support = 0; + hr = d3dDevice->CheckFormatSupport( format, &support ); + if ( FAILED(hr) || !(support & D3D11_FORMAT_SUPPORT_TEXTURE2D) ) + { + // Fallback to RGBA 32-bit format which is supported by all devices + memcpy( &convertGUID, &GUID_WICPixelFormat32bppRGBA, sizeof(WICPixelFormatGUID) ); + format = DXGI_FORMAT_R8G8B8A8_UNORM; + bpp = 32; + } + + // Allocate temporary memory for image + size_t rowPitch = ( twidth * bpp + 7 ) / 8; + size_t imageSize = rowPitch * theight; + + std::unique_ptr temp( new (std::nothrow) uint8_t[ imageSize ] ); + if (!temp) + return E_OUTOFMEMORY; + + // Load image data + if ( memcmp( &convertGUID, &pixelFormat, sizeof(GUID) ) == 0 + && twidth == width + && theight == height ) + { + // No format conversion or resize needed + hr = frame->CopyPixels( 0, static_cast( rowPitch ), static_cast( imageSize ), temp.get() ); + if ( FAILED(hr) ) + return hr; + } + else if ( twidth != width || theight != height ) + { + // Resize + IWICImagingFactory* pWIC = _GetWIC(); + if ( !pWIC ) + return E_NOINTERFACE; + + ComPtr scaler; + hr = pWIC->CreateBitmapScaler( scaler.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + hr = scaler->Initialize( frame, twidth, theight, WICBitmapInterpolationModeFant ); + if ( FAILED(hr) ) + return hr; + + WICPixelFormatGUID pfScaler; + hr = scaler->GetPixelFormat( &pfScaler ); + if ( FAILED(hr) ) + return hr; + + if ( memcmp( &convertGUID, &pfScaler, sizeof(GUID) ) == 0 ) + { + // No format conversion needed + hr = scaler->CopyPixels( 0, static_cast( rowPitch ), static_cast( imageSize ), temp.get() ); + if ( FAILED(hr) ) + return hr; + } + else + { + ComPtr FC; + hr = pWIC->CreateFormatConverter( FC.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + BOOL canConvert = FALSE; + hr = FC->CanConvert( pfScaler, convertGUID, &canConvert ); + if ( FAILED(hr) || !canConvert ) + { + return E_UNEXPECTED; + } + + hr = FC->Initialize( scaler.Get(), convertGUID, WICBitmapDitherTypeErrorDiffusion, 0, 0, WICBitmapPaletteTypeCustom ); + if ( FAILED(hr) ) + return hr; + + hr = FC->CopyPixels( 0, static_cast( rowPitch ), static_cast( imageSize ), temp.get() ); + if ( FAILED(hr) ) + return hr; + } + } + else + { + // Format conversion but no resize + IWICImagingFactory* pWIC = _GetWIC(); + if ( !pWIC ) + return E_NOINTERFACE; + + ComPtr FC; + hr = pWIC->CreateFormatConverter( FC.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + BOOL canConvert = FALSE; + hr = FC->CanConvert( pixelFormat, convertGUID, &canConvert ); + if ( FAILED(hr) || !canConvert ) + { + return E_UNEXPECTED; + } + + hr = FC->Initialize( frame, convertGUID, WICBitmapDitherTypeErrorDiffusion, 0, 0, WICBitmapPaletteTypeCustom ); + if ( FAILED(hr) ) + return hr; + + hr = FC->CopyPixels( 0, static_cast( rowPitch ), static_cast( imageSize ), temp.get() ); + if ( FAILED(hr) ) + return hr; + } + + // See if format is supported for auto-gen mipmaps (varies by feature level) + bool autogen = false; + if ( d3dContext != 0 && textureView != 0 ) // Must have context and shader-view to auto generate mipmaps + { + UINT fmtSupport = 0; + hr = d3dDevice->CheckFormatSupport( format, &fmtSupport ); + if ( SUCCEEDED(hr) && ( fmtSupport & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN ) ) + { + autogen = true; +#if defined(_XBOX_ONE) && defined(_TITLE) + if ( !d3dDeviceX || !d3dContextX ) + return E_INVALIDARG; +#endif + } + } + + // Create texture + D3D11_TEXTURE2D_DESC desc; + desc.Width = twidth; + desc.Height = theight; + desc.MipLevels = (autogen) ? 0 : 1; + desc.ArraySize = 1; + desc.Format = format; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Usage = usage; + desc.CPUAccessFlags = cpuAccessFlags; + + if ( autogen ) + { + desc.BindFlags = bindFlags | D3D11_BIND_RENDER_TARGET; + desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_GENERATE_MIPS; + } + else + { + desc.BindFlags = bindFlags; + desc.MiscFlags = miscFlags; + } + + D3D11_SUBRESOURCE_DATA initData; + initData.pSysMem = temp.get(); + initData.SysMemPitch = static_cast( rowPitch ); + initData.SysMemSlicePitch = static_cast( imageSize ); + + ID3D11Texture2D* tex = nullptr; + hr = d3dDevice->CreateTexture2D( &desc, (autogen) ? nullptr : &initData, &tex ); + if ( SUCCEEDED(hr) && tex != 0 ) + { + if (textureView != 0) + { + D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc; + memset( &SRVDesc, 0, sizeof( SRVDesc ) ); + SRVDesc.Format = desc.Format; + + SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + SRVDesc.Texture2D.MipLevels = (autogen) ? -1 : 1; + + hr = d3dDevice->CreateShaderResourceView( tex, &SRVDesc, textureView ); + if ( FAILED(hr) ) + { + tex->Release(); + return hr; + } + + if ( autogen ) + { + assert( d3dContext != 0 ); + +#if defined(_XBOX_ONE) && defined(_TITLE) + ID3D11Texture2D *pStaging = nullptr; + CD3D11_TEXTURE2D_DESC stagingDesc( format, twidth, theight, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ, 1, 0, 0 ); + initData.pSysMem = temp.get(); + initData.SysMemPitch = static_cast(rowPitch); + initData.SysMemSlicePitch = static_cast(imageSize); + + hr = d3dDevice->CreateTexture2D( &stagingDesc, &initData, &pStaging ); + if ( SUCCEEDED(hr) ) + { + d3dContext->CopySubresourceRegion( tex, 0, 0, 0, 0, pStaging, 0, nullptr ); + + UINT64 copyFence = d3dContextX->InsertFence(0); + while( d3dDeviceX->IsFencePending( copyFence ) ) { SwitchToThread(); } + pStaging->Release(); + } +#else + d3dContext->UpdateSubresource( tex, 0, nullptr, temp.get(), static_cast(rowPitch), static_cast(imageSize) ); +#endif + d3dContext->GenerateMips( *textureView ); + } + } + + if (texture != 0) + { + *texture = tex; + } + else + { + SetDebugObjectName(tex, "WICTextureLoader"); + tex->Release(); + } + } + + return hr; +} + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +HRESULT DirectX::CreateWICTextureFromMemory( ID3D11Device* d3dDevice, + const uint8_t* wicData, + size_t wicDataSize, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize ) +{ + return CreateWICTextureFromMemoryEx( d3dDevice, wicData, wicDataSize, maxsize, + D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, + texture, textureView ); +} + +_Use_decl_annotations_ +#if defined(_XBOX_ONE) && defined(_TITLE) +HRESULT DirectX::CreateWICTextureFromMemory( ID3D11DeviceX* d3dDevice, + ID3D11DeviceContextX* d3dContext, +#else +HRESULT DirectX::CreateWICTextureFromMemory( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, +#endif + const uint8_t* wicData, + size_t wicDataSize, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize ) +{ + return CreateWICTextureFromMemoryEx( d3dDevice, d3dContext, wicData, wicDataSize, maxsize, + D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, + texture, textureView ); +} + +_Use_decl_annotations_ +HRESULT DirectX::CreateWICTextureFromMemoryEx( ID3D11Device* d3dDevice, + const uint8_t* wicData, + size_t wicDataSize, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView ) +{ + if ( texture ) + { + *texture = nullptr; + } + if ( textureView ) + { + *textureView = nullptr; + } + + if (!d3dDevice || !wicData || (!texture && !textureView)) + return E_INVALIDARG; + + if ( !wicDataSize ) + return E_FAIL; + +#ifdef _M_AMD64 + if ( wicDataSize > 0xFFFFFFFF ) + return HRESULT_FROM_WIN32( ERROR_FILE_TOO_LARGE ); +#endif + + IWICImagingFactory* pWIC = _GetWIC(); + if ( !pWIC ) + return E_NOINTERFACE; + + // Create input stream for memory + ComPtr stream; + HRESULT hr = pWIC->CreateStream( stream.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + hr = stream->InitializeFromMemory( const_cast( wicData ), static_cast( wicDataSize ) ); + if ( FAILED(hr) ) + return hr; + + // Initialize WIC + ComPtr decoder; + hr = pWIC->CreateDecoderFromStream( stream.Get(), 0, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + ComPtr frame; + hr = decoder->GetFrame( 0, frame.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + hr = CreateTextureFromWIC( d3dDevice, nullptr, +#if defined(_XBOX_ONE) && defined(_TITLE) + nullptr, nullptr, +#endif + frame.Get(), maxsize, + usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + texture, textureView ); + if ( FAILED(hr)) + return hr; + + if (texture != 0 && *texture != 0) + { + SetDebugObjectName(*texture, "WICTextureLoader"); + } + + if (textureView != 0 && *textureView != 0) + { + SetDebugObjectName(*textureView, "WICTextureLoader"); + } + + return hr; +} + +_Use_decl_annotations_ +#if defined(_XBOX_ONE) && defined(_TITLE) +HRESULT DirectX::CreateWICTextureFromMemoryEx( ID3D11DeviceX* d3dDevice, + ID3D11DeviceContextX* d3dContext, +#else +HRESULT DirectX::CreateWICTextureFromMemoryEx( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, +#endif + const uint8_t* wicData, + size_t wicDataSize, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView ) +{ + if ( texture ) + { + *texture = nullptr; + } + if ( textureView ) + { + *textureView = nullptr; + } + + if (!d3dDevice || !wicData || (!texture && !textureView)) + return E_INVALIDARG; + + if ( !wicDataSize ) + return E_FAIL; + +#ifdef _M_AMD64 + if ( wicDataSize > 0xFFFFFFFF ) + return HRESULT_FROM_WIN32( ERROR_FILE_TOO_LARGE ); +#endif + + IWICImagingFactory* pWIC = _GetWIC(); + if ( !pWIC ) + return E_NOINTERFACE; + + // Create input stream for memory + ComPtr stream; + HRESULT hr = pWIC->CreateStream( stream.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + hr = stream->InitializeFromMemory( const_cast( wicData ), static_cast( wicDataSize ) ); + if ( FAILED(hr) ) + return hr; + + // Initialize WIC + ComPtr decoder; + hr = pWIC->CreateDecoderFromStream( stream.Get(), 0, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + ComPtr frame; + hr = decoder->GetFrame( 0, frame.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + hr = CreateTextureFromWIC( d3dDevice, d3dContext, +#if defined(_XBOX_ONE) && defined(_TITLE) + d3dDevice, d3dContext, +#endif + frame.Get(), maxsize, + usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + texture, textureView ); + if ( FAILED(hr)) + return hr; + + if (texture != 0 && *texture != 0) + { + SetDebugObjectName(*texture, "WICTextureLoader"); + } + + if (textureView != 0 && *textureView != 0) + { + SetDebugObjectName(*textureView, "WICTextureLoader"); + } + + return hr; +} + +//-------------------------------------------------------------------------------------- +_Use_decl_annotations_ +HRESULT DirectX::CreateWICTextureFromFile( ID3D11Device* d3dDevice, + const wchar_t* fileName, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize ) +{ + return CreateWICTextureFromFileEx( d3dDevice, fileName, maxsize, + D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, + texture, textureView ); +} + +_Use_decl_annotations_ +#if defined(_XBOX_ONE) && defined(_TITLE) +HRESULT DirectX::CreateWICTextureFromFile( ID3D11DeviceX* d3dDevice, + ID3D11DeviceContextX* d3dContext, +#else +HRESULT DirectX::CreateWICTextureFromFile( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, +#endif + const wchar_t* fileName, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView, + size_t maxsize ) +{ + return CreateWICTextureFromFileEx( d3dDevice, d3dContext, fileName, maxsize, + D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, + texture, textureView ); +} + +_Use_decl_annotations_ +HRESULT DirectX::CreateWICTextureFromFileEx( ID3D11Device* d3dDevice, + const wchar_t* fileName, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView ) +{ + if ( texture ) + { + *texture = nullptr; + } + if ( textureView ) + { + *textureView = nullptr; + } + + if (!d3dDevice || !fileName || (!texture && !textureView)) + return E_INVALIDARG; + + IWICImagingFactory* pWIC = _GetWIC(); + if ( !pWIC ) + return E_NOINTERFACE; + + // Initialize WIC + ComPtr decoder; + HRESULT hr = pWIC->CreateDecoderFromFilename( fileName, 0, GENERIC_READ, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + ComPtr frame; + hr = decoder->GetFrame( 0, frame.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + hr = CreateTextureFromWIC( d3dDevice, nullptr, +#if defined(_XBOX_ONE) && defined(_TITLE) + nullptr, nullptr, +#endif + frame.Get(), maxsize, + usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + texture, textureView ); + +#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) + if ( SUCCEEDED(hr) ) + { + #if defined(_XBOX_ONE) && defined(_TITLE) + if (texture != 0 && *texture != 0) + { + (*texture)->SetName( fileName ); + } + if (textureView != 0 && *textureView != 0 ) + { + (*textureView)->SetName( fileName ); + } + #else + if (texture != 0 || textureView != 0) + { + CHAR strFileA[MAX_PATH]; + int result = WideCharToMultiByte( CP_ACP, + WC_NO_BEST_FIT_CHARS, + fileName, + -1, + strFileA, + MAX_PATH, + nullptr, + FALSE + ); + if ( result > 0 ) + { + const CHAR* pstrName = strrchr( strFileA, '\\' ); + if (!pstrName) + { + pstrName = strFileA; + } + else + { + pstrName++; + } + + if (texture != 0 && *texture != 0) + { + (*texture)->SetPrivateData( WKPDID_D3DDebugObjectName, + static_cast( strnlen_s(pstrName, MAX_PATH) ), + pstrName + ); + } + + if (textureView != 0 && *textureView != 0 ) + { + (*textureView)->SetPrivateData( WKPDID_D3DDebugObjectName, + static_cast( strnlen_s(pstrName, MAX_PATH) ), + pstrName + ); + } + } + } + #endif + } +#endif + + return hr; +} + +_Use_decl_annotations_ +#if defined(_XBOX_ONE) && defined(_TITLE) +HRESULT DirectX::CreateWICTextureFromFileEx( ID3D11DeviceX* d3dDevice, + ID3D11DeviceContextX* d3dContext, +#else +HRESULT DirectX::CreateWICTextureFromFileEx( ID3D11Device* d3dDevice, + ID3D11DeviceContext* d3dContext, +#endif + const wchar_t* fileName, + size_t maxsize, + D3D11_USAGE usage, + unsigned int bindFlags, + unsigned int cpuAccessFlags, + unsigned int miscFlags, + bool forceSRGB, + ID3D11Resource** texture, + ID3D11ShaderResourceView** textureView ) +{ + if ( texture ) + { + *texture = nullptr; + } + if ( textureView ) + { + *textureView = nullptr; + } + + if (!d3dDevice || !fileName || (!texture && !textureView)) + return E_INVALIDARG; + + IWICImagingFactory* pWIC = _GetWIC(); + if ( !pWIC ) + return E_NOINTERFACE; + + // Initialize WIC + ComPtr decoder; + HRESULT hr = pWIC->CreateDecoderFromFilename( fileName, 0, GENERIC_READ, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + ComPtr frame; + hr = decoder->GetFrame( 0, frame.GetAddressOf() ); + if ( FAILED(hr) ) + return hr; + + hr = CreateTextureFromWIC( d3dDevice, d3dContext, +#if defined(_XBOX_ONE) && defined(_TITLE) + d3dDevice, d3dContext, +#endif + frame.Get(), maxsize, + usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, + texture, textureView ); + +#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) + if ( SUCCEEDED(hr) ) + { + #if defined(_XBOX_ONE) && defined(_TITLE) + if (texture != 0 && *texture != 0) + { + (*texture)->SetName( fileName ); + } + if (textureView != 0 && *textureView != 0 ) + { + (*textureView)->SetName( fileName ); + } + #else + if (texture != 0 || textureView != 0) + { + CHAR strFileA[MAX_PATH]; + int result = WideCharToMultiByte( CP_ACP, + WC_NO_BEST_FIT_CHARS, + fileName, + -1, + strFileA, + MAX_PATH, + nullptr, + FALSE + ); + if ( result > 0 ) + { + const CHAR* pstrName = strrchr( strFileA, '\\' ); + if (!pstrName) + { + pstrName = strFileA; + } + else + { + pstrName++; + } + + if (texture != 0 && *texture != 0) + { + (*texture)->SetPrivateData( WKPDID_D3DDebugObjectName, + static_cast( strnlen_s(pstrName, MAX_PATH) ), + pstrName + ); + } + + if (textureView != 0 && *textureView != 0 ) + { + (*textureView)->SetPrivateData( WKPDID_D3DDebugObjectName, + static_cast( strnlen_s(pstrName, MAX_PATH) ), + pstrName + ); + } + } + } + #endif + } +#endif + + return hr; +} diff --git a/Kits/DirectXTK/Src/dds.h b/Kits/DirectXTK/Src/dds.h new file mode 100644 index 0000000000000000000000000000000000000000..bee3f8174b950bffc90de05ec5a8254fc6c1a99f --- /dev/null +++ b/Kits/DirectXTK/Src/dds.h @@ -0,0 +1,239 @@ +//-------------------------------------------------------------------------------------- +// dds.h +// +// This header defines constants and structures that are useful when parsing +// DDS files. DDS files were originally designed to use several structures +// and constants that are native to DirectDraw and are defined in ddraw.h, +// such as DDSURFACEDESC2 and DDSCAPS2. This file defines similar +// (compatible) constants and structures so that one can use DDS files +// without needing to include ddraw.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#else +#include +#endif + +// VS 2010's stdint.h conflicts with intsafe.h +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#pragma warning(pop) + +namespace DirectX +{ + +#pragma pack(push,1) + +const uint32_t DDS_MAGIC = 0x20534444; // "DDS " + +struct DDS_PIXELFORMAT +{ + uint32_t size; + uint32_t flags; + uint32_t fourCC; + uint32_t RGBBitCount; + uint32_t RBitMask; + uint32_t GBitMask; + uint32_t BBitMask; + uint32_t ABitMask; +}; + +#define DDS_FOURCC 0x00000004 // DDPF_FOURCC +#define DDS_RGB 0x00000040 // DDPF_RGB +#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS +#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE +#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS +#define DDS_ALPHA 0x00000002 // DDPF_ALPHA +#define DDS_PAL8 0x00000020 // DDPF_PALETTEINDEXED8 +#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV + +#ifndef MAKEFOURCC + #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \ + ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 )) +#endif /* defined(MAKEFOURCC) */ + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT1 = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT2 = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT3 = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT4 = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT5 = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC4_UNORM = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC4_SNORM = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC5_UNORM = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC5_SNORM = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R8G8_B8G8 = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_G8R8_G8B8 = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_YUY2 = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8R8G8B8 = + { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_X8R8G8B8 = + { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8B8G8R8 = + { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_X8B8G8R8 = + { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_G16R16 = + { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R5G6B5 = + { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A1R5G5B5 = + { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A4R4G4B4 = + { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00000f00, 0x000000f0, 0x0000000f, 0x0000f000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R8G8B8 = + { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_L8 = + { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0x00, 0x00, 0x00 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_L16 = + { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0x0000, 0x0000, 0x0000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8L8 = + { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0x0000, 0x0000, 0xff00 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8 = + { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0x00, 0x00, 0x00, 0xff }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_V8U8 = + { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0x0000, 0x0000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_Q8W8V8U8 = + { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; + +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_V16U16 = + { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000 }; + +// D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue + +// This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat) +extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DX10 = + { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 }; + +#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT +#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT +#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH +#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH +#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE + +#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT +#define DDS_WIDTH 0x00000004 // DDSD_WIDTH + +#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE +#define DDS_SURFACE_FLAGS_MIPMAP 0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP +#define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX + +#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX +#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX +#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY +#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY +#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ +#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ + +#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\ + DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\ + DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ ) + +#define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP + +#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME + +// Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION +enum DDS_RESOURCE_DIMENSION +{ + DDS_DIMENSION_TEXTURE1D = 2, + DDS_DIMENSION_TEXTURE2D = 3, + DDS_DIMENSION_TEXTURE3D = 4, +}; + +// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG +enum DDS_RESOURCE_MISC_FLAG +{ + DDS_RESOURCE_MISC_TEXTURECUBE = 0x4L, +}; + +enum DDS_MISC_FLAGS2 +{ + DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L, +}; + +struct DDS_HEADER +{ + uint32_t size; + uint32_t flags; + uint32_t height; + uint32_t width; + uint32_t pitchOrLinearSize; + uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags + uint32_t mipMapCount; + uint32_t reserved1[11]; + DDS_PIXELFORMAT ddspf; + uint32_t caps; + uint32_t caps2; + uint32_t caps3; + uint32_t caps4; + uint32_t reserved2; +}; + +struct DDS_HEADER_DXT10 +{ + DXGI_FORMAT dxgiFormat; + uint32_t resourceDimension; + uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG + uint32_t arraySize; + uint32_t miscFlags2; // see DDS_MISC_FLAGS2 +} ; + +#pragma pack(pop) + +static_assert( sizeof(DDS_HEADER) == 124, "DDS Header size mismatch" ); +static_assert( sizeof(DDS_HEADER_DXT10) == 20, "DDS DX10 Extended Header size mismatch"); + +}; // namespace diff --git a/Kits/DirectXTK/Src/pch.cpp b/Kits/DirectXTK/Src/pch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9236a2b6ab7d3ffb2d4e27a75b0c2321727ad3c2 --- /dev/null +++ b/Kits/DirectXTK/Src/pch.cpp @@ -0,0 +1,14 @@ +//-------------------------------------------------------------------------------------- +// File: pch.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#include "pch.h" diff --git a/Kits/DirectXTK/Src/pch.h b/Kits/DirectXTK/Src/pch.h new file mode 100644 index 0000000000000000000000000000000000000000..ab1c6c61399b5c3f855be9a569ba1db64346ede6 --- /dev/null +++ b/Kits/DirectXTK/Src/pch.h @@ -0,0 +1,81 @@ +//-------------------------------------------------------------------------------------- +// File: pch.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. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#if !defined(WIN32_LEAN_AND_MEAN) +#define WIN32_LEAN_AND_MEAN +#endif + +#if !defined(NOMINMAX) +#define NOMINMAX +#endif + +#ifndef _WIN32_WINNT_WIN10 +#define _WIN32_WINNT_WIN10 0x0A00 +#endif + +// VS 2010/2012 do not support =default =delete +#ifndef DIRECTX_CTOR_DEFAULT +#if defined(_MSC_VER) && (_MSC_VER < 1800) +#define DIRECTX_CTOR_DEFAULT {} +#define DIRECTX_CTOR_DELETE ; +#else +#define DIRECTX_CTOR_DEFAULT =default; +#define DIRECTX_CTOR_DELETE =delete; +#endif +#endif + +#if defined(_XBOX_ONE) && defined(_TITLE) +#include +#define DCOMMON_H_INCLUDED +#else +#include +#endif + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +#include +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// VS 2010's stdint.h conflicts with intsafe.h +#pragma warning(push) +#pragma warning(disable : 4005) +#include +#include +#pragma warning(pop) + +#include + +namespace DirectX +{ + #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV) + #define XM_CALLCONV __fastcall + typedef const XMVECTOR& HXMVECTOR; + typedef const XMMATRIX& FXMMATRIX; + #endif +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..96e5e146a68ac92c016102e43aab167c89a50099 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ + The MIT License (MIT) + +Copyright (c) 2016 Microsoft Corp + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/Media/Fonts/Courier_36.spritefont b/Media/Fonts/Courier_36.spritefont new file mode 100644 index 0000000000000000000000000000000000000000..986333eb992f664deb2b1baae790e10d823c4ad6 Binary files /dev/null and b/Media/Fonts/Courier_36.spritefont differ diff --git a/Media/Fonts/SegoeUI_22.spritefont b/Media/Fonts/SegoeUI_22.spritefont new file mode 100644 index 0000000000000000000000000000000000000000..61bac081df4cb67e93e48ad789786b2ce38e58eb Binary files /dev/null and b/Media/Fonts/SegoeUI_22.spritefont differ diff --git a/Media/Fonts/SegoeUI_24.spritefont b/Media/Fonts/SegoeUI_24.spritefont new file mode 100644 index 0000000000000000000000000000000000000000..e769acbcb81545a055016ca40ee8be9407582d1f Binary files /dev/null and b/Media/Fonts/SegoeUI_24.spritefont differ diff --git a/Media/Fonts/SegoeUI_34.spritefont b/Media/Fonts/SegoeUI_34.spritefont new file mode 100644 index 0000000000000000000000000000000000000000..aa8a43a7cd565d0918249ddf131081616a28bf2b Binary files /dev/null and b/Media/Fonts/SegoeUI_34.spritefont differ diff --git a/Media/Meshes/FPSRoom/ABox001LightingMap.dds b/Media/Meshes/FPSRoom/ABox001LightingMap.dds new file mode 100644 index 0000000000000000000000000000000000000000..3e6b96fd4a3a31073b2061e9c59d9d9dbec89cfa Binary files /dev/null and b/Media/Meshes/FPSRoom/ABox001LightingMap.dds differ diff --git a/Media/Meshes/FPSRoom/ACeilingLightingMap.dds b/Media/Meshes/FPSRoom/ACeilingLightingMap.dds new file mode 100644 index 0000000000000000000000000000000000000000..ecd4d2766304b059e31ba98bd110f7f9429e6613 Binary files /dev/null and b/Media/Meshes/FPSRoom/ACeilingLightingMap.dds differ diff --git a/Media/Meshes/FPSRoom/AFloortLightingMap.dds b/Media/Meshes/FPSRoom/AFloortLightingMap.dds new file mode 100644 index 0000000000000000000000000000000000000000..554a48c1ad7014c6bce727b727113edc2a1ad922 Binary files /dev/null and b/Media/Meshes/FPSRoom/AFloortLightingMap.dds differ diff --git a/Media/Meshes/FPSRoom/AWallsLightingMap.dds b/Media/Meshes/FPSRoom/AWallsLightingMap.dds new file mode 100644 index 0000000000000000000000000000000000000000..a4f17d35da040c1f77ae7a3bc7a1c51387975d95 Binary files /dev/null and b/Media/Meshes/FPSRoom/AWallsLightingMap.dds differ diff --git a/Media/Meshes/FPSRoom/Ceiling.dds b/Media/Meshes/FPSRoom/Ceiling.dds new file mode 100644 index 0000000000000000000000000000000000000000..9c16cd705039b0a3724b6a216155c7df85a71aac Binary files /dev/null and b/Media/Meshes/FPSRoom/Ceiling.dds differ diff --git a/Media/Meshes/FPSRoom/Cement.dds b/Media/Meshes/FPSRoom/Cement.dds new file mode 100644 index 0000000000000000000000000000000000000000..abb1fcf535574260a6912f98b69eabfbe2b39068 Binary files /dev/null and b/Media/Meshes/FPSRoom/Cement.dds differ diff --git a/Media/Meshes/FPSRoom/FPSRoom.sdkmesh b/Media/Meshes/FPSRoom/FPSRoom.sdkmesh new file mode 100644 index 0000000000000000000000000000000000000000..dcf99f719f88a79da175ae2b707676cba9340e43 Binary files /dev/null and b/Media/Meshes/FPSRoom/FPSRoom.sdkmesh differ diff --git a/Media/Meshes/FPSRoom/Pillar.dds b/Media/Meshes/FPSRoom/Pillar.dds new file mode 100644 index 0000000000000000000000000000000000000000..28dfd92c882afbf722fddbc18670304103f10901 Binary files /dev/null and b/Media/Meshes/FPSRoom/Pillar.dds differ diff --git a/Media/Meshes/FPSRoom/clouds.dds b/Media/Meshes/FPSRoom/clouds.dds new file mode 100644 index 0000000000000000000000000000000000000000..ce80bf0813c42df5a706df039e709e3f9156405c Binary files /dev/null and b/Media/Meshes/FPSRoom/clouds.dds differ diff --git a/Media/Meshes/RTSMap/3DRTSMap.sdkmesh b/Media/Meshes/RTSMap/3DRTSMap.sdkmesh new file mode 100644 index 0000000000000000000000000000000000000000..ba8af6ac733a2c56ac401d7b63a41b61e525a294 Binary files /dev/null and b/Media/Meshes/RTSMap/3DRTSMap.sdkmesh differ diff --git a/Media/Meshes/RTSMap/LabelBase.dds b/Media/Meshes/RTSMap/LabelBase.dds new file mode 100644 index 0000000000000000000000000000000000000000..8b26a4191e80e510ceac9fd5e705f37251adf6ea Binary files /dev/null and b/Media/Meshes/RTSMap/LabelBase.dds differ diff --git a/Media/Meshes/RTSMap/Labels.dds b/Media/Meshes/RTSMap/Labels.dds new file mode 100644 index 0000000000000000000000000000000000000000..72bb40b6d096ca8096794e745375fe6142a6cb7d Binary files /dev/null and b/Media/Meshes/RTSMap/Labels.dds differ diff --git a/Media/Meshes/RTSMap/Map3DColor.dds b/Media/Meshes/RTSMap/Map3DColor.dds new file mode 100644 index 0000000000000000000000000000000000000000..2f5f3ed86543b46312d9d46244e989fe1898ae79 Binary files /dev/null and b/Media/Meshes/RTSMap/Map3DColor.dds differ diff --git a/README.md b/README.md index 372c9a1867a3638609e8c59be7b42143af4f4368..839e1747f48ea72c21afd340d9f02a2b14f0eb10 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,12 @@ -# Xbox-ATG-Samples -Xbox-ATG will create UWP samples for game development. +# Xbox-ATG-Samples + +This repo contains game development samples written by the Microsoft Xbox Advanced Technology Group. + +## MouseCursor + +This sample demonstrates how to implement mouse controls in Universal Windows Platform apps. See ``Samples\System\MouseCursor\MouseCursor_Readme.docx`` for more information. + +# Requirements + +* Windows 10 November 2015 +* Visual Studio 2015 with the Windows 10 SDK (10586) diff --git a/Samples/System/MouseCursor/Assets/Logo.png b/Samples/System/MouseCursor/Assets/Logo.png new file mode 100644 index 0000000000000000000000000000000000000000..f4bec67650eda77f0349b8805f94792c3d11e147 Binary files /dev/null and b/Samples/System/MouseCursor/Assets/Logo.png differ diff --git a/Samples/System/MouseCursor/Assets/SmallLogo.png b/Samples/System/MouseCursor/Assets/SmallLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..06f25b5e43b329e180932c134e9396eac162b9d7 Binary files /dev/null and b/Samples/System/MouseCursor/Assets/SmallLogo.png differ diff --git a/Samples/System/MouseCursor/Assets/SplashScreen.scale-100.png b/Samples/System/MouseCursor/Assets/SplashScreen.scale-100.png new file mode 100644 index 0000000000000000000000000000000000000000..591ab5e9e522dfd5f1a3298e3af6434d13671a15 Binary files /dev/null and b/Samples/System/MouseCursor/Assets/SplashScreen.scale-100.png differ diff --git a/Samples/System/MouseCursor/Assets/SplashScreen.scale-140.png b/Samples/System/MouseCursor/Assets/SplashScreen.scale-140.png new file mode 100644 index 0000000000000000000000000000000000000000..f3b9f33b1186f8d5b565745fc319feb5e51d8021 Binary files /dev/null and b/Samples/System/MouseCursor/Assets/SplashScreen.scale-140.png differ diff --git a/Samples/System/MouseCursor/Assets/SplashScreen.scale-180.png b/Samples/System/MouseCursor/Assets/SplashScreen.scale-180.png new file mode 100644 index 0000000000000000000000000000000000000000..e919e070b97da41595c34f5354aedb2e239c982c Binary files /dev/null and b/Samples/System/MouseCursor/Assets/SplashScreen.scale-180.png differ diff --git a/Samples/System/MouseCursor/Assets/WideLogo.png b/Samples/System/MouseCursor/Assets/WideLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..6c034b18943251b1b487d612eaa6a72faf9677e5 Binary files /dev/null and b/Samples/System/MouseCursor/Assets/WideLogo.png differ diff --git a/Samples/System/MouseCursor/Assets/background_flat.png b/Samples/System/MouseCursor/Assets/background_flat.png new file mode 100644 index 0000000000000000000000000000000000000000..32c3da904e842f07271c6ef2036016996449d73c Binary files /dev/null and b/Samples/System/MouseCursor/Assets/background_flat.png differ diff --git a/Samples/System/MouseCursor/Assets/green_tile.png b/Samples/System/MouseCursor/Assets/green_tile.png new file mode 100644 index 0000000000000000000000000000000000000000..2603400d51550c5a4ebfc12ad0904ba63abfe52b Binary files /dev/null and b/Samples/System/MouseCursor/Assets/green_tile.png differ diff --git a/Samples/System/MouseCursor/Assets/green_tile_border.png b/Samples/System/MouseCursor/Assets/green_tile_border.png new file mode 100644 index 0000000000000000000000000000000000000000..99e1430f3aed4b76f822731bff7bb302d046cc26 Binary files /dev/null and b/Samples/System/MouseCursor/Assets/green_tile_border.png differ diff --git a/Samples/System/MouseCursor/DeviceResources.cpp b/Samples/System/MouseCursor/DeviceResources.cpp new file mode 100644 index 0000000000000000000000000000000000000000..397176aabbe21063889bc999a242e817fc7857b4 --- /dev/null +++ b/Samples/System/MouseCursor/DeviceResources.cpp @@ -0,0 +1,563 @@ +// +// DeviceResources.cpp - A wrapper for the Direct3D 11 device and swapchain +// (requires DirectX 11.3 Runtime) +// + + +#include "pch.h" +#include "DeviceResources.h" + +using namespace DirectX; + +using Microsoft::WRL::ComPtr; + +namespace +{ +#if defined(_DEBUG) + // Check for SDK Layer support. + inline bool SdkLayersAvailable() + { + HRESULT hr = D3D11CreateDevice( + nullptr, + D3D_DRIVER_TYPE_NULL, // There is no need to create a real hardware device. + 0, + D3D11_CREATE_DEVICE_DEBUG, // Check for the SDK layers. + nullptr, // Any feature level will do. + 0, + D3D11_SDK_VERSION, + nullptr, // No need to keep the D3D device reference. + nullptr, // No need to know the feature level. + nullptr // No need to keep the D3D device context reference. + ); + + return SUCCEEDED(hr); + } +#endif +}; + +// Constants used to calculate screen rotations +namespace ScreenRotation +{ + // 0-degree Z-rotation + static const XMFLOAT4X4 Rotation0( + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f + ); + + // 90-degree Z-rotation + static const XMFLOAT4X4 Rotation90( + 0.0f, 1.0f, 0.0f, 0.0f, + -1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f + ); + + // 180-degree Z-rotation + static const XMFLOAT4X4 Rotation180( + -1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, -1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f + ); + + // 270-degree Z-rotation + static const XMFLOAT4X4 Rotation270( + 0.0f, -1.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f + ); +}; + +// Constructor for DeviceResources. +DX::DeviceResources::DeviceResources(DXGI_FORMAT backBufferFormat, DXGI_FORMAT depthBufferFormat, UINT backBufferCount, D3D_FEATURE_LEVEL minFeatureLevel) : + m_screenViewport{}, + m_backBufferFormat(backBufferFormat), + m_depthBufferFormat(depthBufferFormat), + m_backBufferCount(backBufferCount), + m_d3dMinFeatureLevel(minFeatureLevel), + m_window(nullptr), + m_d3dFeatureLevel(D3D_FEATURE_LEVEL_9_1), + m_rotation(DXGI_MODE_ROTATION_IDENTITY), + m_outputSize{0, 0, 1, 1}, + m_orientationTransform3D(ScreenRotation::Rotation0), + m_deviceNotify(nullptr) +{ +} + +// Configures the Direct3D device, and stores handles to it and the device context. +void DX::DeviceResources::CreateDeviceResources() +{ + UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; + +#if defined(_DEBUG) + if (SdkLayersAvailable()) + { + // If the project is in a debug build, enable debugging via SDK Layers with this flag. + creationFlags |= D3D11_CREATE_DEVICE_DEBUG; + } + else + { + OutputDebugStringA("WARNING: Direct3D Debug Device is not available\n"); + } +#endif + + // Determine DirectX hardware feature levels this app will support. + static const D3D_FEATURE_LEVEL s_featureLevels[] = + { + D3D_FEATURE_LEVEL_12_1, + D3D_FEATURE_LEVEL_12_0, + D3D_FEATURE_LEVEL_11_1, + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + D3D_FEATURE_LEVEL_9_3, + D3D_FEATURE_LEVEL_9_2, + D3D_FEATURE_LEVEL_9_1, + }; + + UINT featLevelCount = 0; + for (; featLevelCount < _countof(s_featureLevels); ++featLevelCount) + { + if (s_featureLevels[featLevelCount] < m_d3dMinFeatureLevel) + break; + } + + if (!featLevelCount) + { + throw std::out_of_range("minFeatureLevel too high"); + } + + ComPtr adapter; + GetHardwareAdapter(adapter.GetAddressOf()); + + // Create the Direct3D 11 API device object and a corresponding context. + ComPtr device; + ComPtr context; + + HRESULT hr = E_FAIL; + if (adapter) + { + hr = D3D11CreateDevice( + adapter.Get(), + D3D_DRIVER_TYPE_UNKNOWN, + 0, + creationFlags, // Set debug and Direct2D compatibility flags. + s_featureLevels, + featLevelCount, + D3D11_SDK_VERSION, + device.GetAddressOf(), // Returns the Direct3D device created. + &m_d3dFeatureLevel, // Returns feature level of device created. + context.GetAddressOf() // Returns the device immediate context. + ); + } +#if defined(NDEBUG) + else + { + throw std::exception("No Direct3D hardware device found"); + } +#else + if (FAILED(hr)) + { + // If the initialization fails, fall back to the WARP device. + // For more information on WARP, see: + // http://go.microsoft.com/fwlink/?LinkId=286690 + hr = D3D11CreateDevice( + nullptr, + D3D_DRIVER_TYPE_WARP, // Create a WARP device instead of a hardware device. + 0, + creationFlags, + s_featureLevels, + featLevelCount, + D3D11_SDK_VERSION, + device.GetAddressOf(), + &m_d3dFeatureLevel, + context.GetAddressOf() + ); + + if (SUCCEEDED(hr)) + { + OutputDebugStringA("Direct3D Adapter - WARP\n"); + } + } +#endif + + DX::ThrowIfFailed(hr); + +#ifndef NDEBUG + ComPtr d3dDebug; + if (SUCCEEDED(device.As(&d3dDebug))) + { + ComPtr d3dInfoQueue; + if (SUCCEEDED(d3dDebug.As(&d3dInfoQueue))) + { +#ifdef _DEBUG + d3dInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true); + d3dInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true); +#endif + D3D11_MESSAGE_ID hide[] = + { + D3D11_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS, + }; + D3D11_INFO_QUEUE_FILTER filter; + memset(&filter, 0, sizeof(filter)); + filter.DenyList.NumIDs = _countof(hide); + filter.DenyList.pIDList = hide; + d3dInfoQueue->AddStorageFilterEntries(&filter); + } + } +#endif + + DX::ThrowIfFailed(device.As(&m_d3dDevice)); + DX::ThrowIfFailed(context.As(&m_d3dContext)); +} + +// These resources need to be recreated every time the window size is changed. +void DX::DeviceResources::CreateWindowSizeDependentResources() +{ + if (!m_window) + { + throw std::exception("Call SetWindow with a valid CoreWindow pointer"); + } + + // Clear the previous window size specific context. + ID3D11RenderTargetView* nullViews[] = {nullptr}; + m_d3dContext->OMSetRenderTargets(_countof(nullViews), nullViews, nullptr); + m_d3dRenderTargetView.Reset(); + m_d3dDepthStencilView.Reset(); + m_d3dContext->Flush(); + + // Determine the render target size in pixels. + UINT backBufferWidth = std::max(m_outputSize.right - m_outputSize.left, 1); + UINT backBufferHeight = std::max(m_outputSize.bottom - m_outputSize.top, 1); + + if (m_swapChain) + { + // If the swap chain already exists, resize it. + HRESULT hr = m_swapChain->ResizeBuffers( + m_backBufferCount, + backBufferWidth, + backBufferHeight, + m_backBufferFormat, + 0 + ); + + if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) + { +#ifdef _DEBUG + char buff[64] = {}; + sprintf_s(buff, "Device Lost on ResizeBuffers: Reason code 0x%08X\n", (hr == DXGI_ERROR_DEVICE_REMOVED) ? m_d3dDevice->GetDeviceRemovedReason() : hr); + OutputDebugStringA(buff); +#endif + // If the device was removed for any reason, a new device and swap chain will need to be created. + HandleDeviceLost(); + + // Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method + // and correctly set up the new device. + return; + } + else + { + DX::ThrowIfFailed(hr); + } + } + else + { + // Otherwise, create a new one using the same adapter as the existing Direct3D device. + + // This sequence obtains the DXGI factory that was used to create the Direct3D device above. + ComPtr dxgiDevice; + DX::ThrowIfFailed(m_d3dDevice.As(&dxgiDevice)); + + ComPtr dxgiAdapter; + DX::ThrowIfFailed(dxgiDevice->GetAdapter(dxgiAdapter.GetAddressOf())); + + ComPtr dxgiFactory; + DX::ThrowIfFailed(dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.GetAddressOf()))); + + DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {}; + swapChainDesc.Width = backBufferWidth; + swapChainDesc.Height = backBufferHeight; + swapChainDesc.Format = m_backBufferFormat; + swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swapChainDesc.BufferCount = m_backBufferCount; + swapChainDesc.SampleDesc.Count = 1; + swapChainDesc.SampleDesc.Quality = 0; + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; + swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE; + + ComPtr swapChain; + DX::ThrowIfFailed(dxgiFactory->CreateSwapChainForCoreWindow( + m_d3dDevice.Get(), + m_window, + &swapChainDesc, + nullptr, + swapChain.GetAddressOf() + )); + + DX::ThrowIfFailed(swapChain.As(&m_swapChain)); + + // Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and + // ensures that the application will only render after each VSync, minimizing power consumption. + DX::ThrowIfFailed(dxgiDevice->SetMaximumFrameLatency(1)); + } + + // Set the proper orientation for the swap chain, and generate + // matrix transformations for rendering to the rotated swap chain. + switch (m_rotation) + { + default: + case DXGI_MODE_ROTATION_IDENTITY: + m_orientationTransform3D = ScreenRotation::Rotation0; + break; + + case DXGI_MODE_ROTATION_ROTATE90: + m_orientationTransform3D = ScreenRotation::Rotation270; + break; + + case DXGI_MODE_ROTATION_ROTATE180: + m_orientationTransform3D = ScreenRotation::Rotation180; + break; + + case DXGI_MODE_ROTATION_ROTATE270: + m_orientationTransform3D = ScreenRotation::Rotation90; + break; + } + + DX::ThrowIfFailed(m_swapChain->SetRotation(m_rotation)); + + // Create a render target view of the swap chain back buffer. + ComPtr backBuffer; + DX::ThrowIfFailed(m_swapChain->GetBuffer(0, IID_PPV_ARGS(backBuffer.GetAddressOf()))); + + DX::ThrowIfFailed(m_d3dDevice->CreateRenderTargetView( + backBuffer.Get(), + nullptr, + m_d3dRenderTargetView.ReleaseAndGetAddressOf() + )); + + // Create a depth stencil view for use with 3D rendering if needed. + CD3D11_TEXTURE2D_DESC depthStencilDesc( + m_depthBufferFormat, + backBufferWidth, + backBufferHeight, + 1, // This depth stencil view has only one texture. + 1, // Use a single mipmap level. + D3D11_BIND_DEPTH_STENCIL + ); + + ComPtr depthStencil; + DX::ThrowIfFailed(m_d3dDevice->CreateTexture2D( + &depthStencilDesc, + nullptr, + depthStencil.GetAddressOf() + )); + + CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(D3D11_DSV_DIMENSION_TEXTURE2D); + DX::ThrowIfFailed(m_d3dDevice->CreateDepthStencilView( + depthStencil.Get(), + &depthStencilViewDesc, + m_d3dDepthStencilView.ReleaseAndGetAddressOf() + )); + + // Set the 3D rendering viewport to target the entire window. + m_screenViewport = CD3D11_VIEWPORT( + 0.0f, + 0.0f, + static_cast(backBufferWidth), + static_cast(backBufferHeight) + ); +} + +// This method is called when the CoreWindow is created (or re-created). +void DX::DeviceResources::SetWindow(IUnknown* window, int width, int height, DXGI_MODE_ROTATION rotation) +{ + m_window = window; + + m_outputSize.left = m_outputSize.top = 0; + m_outputSize.right = width; + m_outputSize.bottom = height; + + m_rotation = rotation; +} + +// This method is called when the window changes size +bool DX::DeviceResources::WindowSizeChanged(int width, int height, DXGI_MODE_ROTATION rotation) +{ + RECT newRc; + newRc.left = newRc.top = 0; + newRc.right = width; + newRc.bottom = height; + if (newRc == m_outputSize && rotation == m_rotation) + { + return false; + } + + m_outputSize = newRc; + m_rotation = rotation; + CreateWindowSizeDependentResources(); + return true; +} + +// This method is called in the event handler for the DisplayContentsInvalidated event. +void DX::DeviceResources::ValidateDevice() +{ + // The D3D Device is no longer valid if the default adapter changed since the device + // was created or if the device has been removed. + + DXGI_ADAPTER_DESC previousDesc; + { + ComPtr dxgiDevice; + DX::ThrowIfFailed(m_d3dDevice.As(&dxgiDevice)); + + ComPtr deviceAdapter; + DX::ThrowIfFailed(dxgiDevice->GetAdapter(deviceAdapter.GetAddressOf())); + + ComPtr deviceFactory; + DX::ThrowIfFailed(deviceAdapter->GetParent(IID_PPV_ARGS(deviceFactory.GetAddressOf()))); + + ComPtr previousDefaultAdapter; + DX::ThrowIfFailed(deviceFactory->EnumAdapters1(0, previousDefaultAdapter.GetAddressOf())); + + DX::ThrowIfFailed(previousDefaultAdapter->GetDesc(&previousDesc)); + } + + DXGI_ADAPTER_DESC currentDesc; + { + ComPtr currentFactory; + DX::ThrowIfFailed(CreateDXGIFactory1(IID_PPV_ARGS(currentFactory.GetAddressOf()))); + + ComPtr currentDefaultAdapter; + DX::ThrowIfFailed(currentFactory->EnumAdapters1(0, currentDefaultAdapter.GetAddressOf())); + + DX::ThrowIfFailed(currentDefaultAdapter->GetDesc(¤tDesc)); + } + + // If the adapter LUIDs don't match, or if the device reports that it has been removed, + // a new D3D device must be created. + + if (previousDesc.AdapterLuid.LowPart != currentDesc.AdapterLuid.LowPart + || previousDesc.AdapterLuid.HighPart != currentDesc.AdapterLuid.HighPart + || FAILED(m_d3dDevice->GetDeviceRemovedReason())) + { +#ifdef _DEBUG + OutputDebugStringA("Device Lost on ValidateDevice\n"); +#endif + + // Create a new device and swap chain. + HandleDeviceLost(); + } +} + +// Recreate all device resources and set them back to the current state. +void DX::DeviceResources::HandleDeviceLost() +{ + if (m_deviceNotify) + { + m_deviceNotify->OnDeviceLost(); + } + + m_d3dDepthStencilView.Reset(); + m_d3dRenderTargetView.Reset(); + m_swapChain.Reset(); + m_d3dContext.Reset(); + m_d3dDevice.Reset(); + +#ifdef _DEBUG + { + ComPtr dxgiDebug; + if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&dxgiDebug)))) + { + dxgiDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_FLAGS(DXGI_DEBUG_RLO_SUMMARY | DXGI_DEBUG_RLO_IGNORE_INTERNAL)); + } + } +#endif + + CreateDeviceResources(); + CreateWindowSizeDependentResources(); + + if (m_deviceNotify) + { + m_deviceNotify->OnDeviceRestored(); + } +} + +// Call this method when the app suspends. It provides a hint to the driver that the app +// is entering an idle state and that temporary buffers can be reclaimed for use by other apps. +void DX::DeviceResources::Trim() +{ + ComPtr dxgiDevice; + if (SUCCEEDED(m_d3dDevice.As(&dxgiDevice))) + { + dxgiDevice->Trim(); + } +} + +// Present the contents of the swap chain to the screen. +void DX::DeviceResources::Present() +{ + // The first argument instructs DXGI to block until VSync, putting the application + // to sleep until the next VSync. This ensures we don't waste any cycles rendering + // frames that will never be displayed to the screen. + HRESULT hr = m_swapChain->Present(1, 0); + + // Discard the contents of the render target. + // This is a valid operation only when the existing contents will be entirely + // overwritten. If dirty or scroll rects are used, this call should be removed. + m_d3dContext->DiscardView(m_d3dRenderTargetView.Get()); + + // Discard the contents of the depth stencil. + m_d3dContext->DiscardView(m_d3dDepthStencilView.Get()); + + // If the device was removed either by a disconnection or a driver upgrade, we + // must recreate all device resources. + if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) + { +#ifdef _DEBUG + char buff[64] = {}; + sprintf_s(buff, "Device Lost on Present: Reason code 0x%08X\n", (hr == DXGI_ERROR_DEVICE_REMOVED) ? m_d3dDevice->GetDeviceRemovedReason() : hr); + OutputDebugStringA(buff); +#endif + HandleDeviceLost(); + } + else + { + DX::ThrowIfFailed(hr); + } +} + +// This method acquires the first available hardware adapter. +// If no such adapter can be found, *ppAdapter will be set to nullptr. +void DX::DeviceResources::GetHardwareAdapter(IDXGIAdapter1** ppAdapter) +{ + *ppAdapter = nullptr; + + ComPtr dxgiFactory; + DX::ThrowIfFailed(CreateDXGIFactory1(IID_PPV_ARGS(dxgiFactory.GetAddressOf()))); + + ComPtr adapter; + for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != dxgiFactory->EnumAdapters1(adapterIndex, adapter.ReleaseAndGetAddressOf()); adapterIndex++) + { + DXGI_ADAPTER_DESC1 desc; + adapter->GetDesc1(&desc); + + if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) + { + // Don't select the Basic Render Driver adapter. + continue; + } + +#ifdef _DEBUG + WCHAR buff[256] = {}; + swprintf_s(buff, L"Direct3D Adapter (%u): VID:%04X, PID:%04X - %ls\n", adapterIndex, desc.VendorId, desc.DeviceId, desc.Description); + OutputDebugStringW(buff); +#endif + + break; + } + + *ppAdapter = adapter.Detach(); +} \ No newline at end of file diff --git a/Samples/System/MouseCursor/DeviceResources.h b/Samples/System/MouseCursor/DeviceResources.h new file mode 100644 index 0000000000000000000000000000000000000000..1da562cac922f3a6421d6bb23ab08ac66697fe44 --- /dev/null +++ b/Samples/System/MouseCursor/DeviceResources.h @@ -0,0 +1,83 @@ +// +// DeviceResources.h - A wrapper for the Direct3D 11 device and swapchain +// + +#pragma once + +namespace DX +{ + // Provides an interface for an application that owns DeviceResources to be notified of the device being lost or created. + interface IDeviceNotify + { + virtual void OnDeviceLost() = 0; + virtual void OnDeviceRestored() = 0; + }; + + // Controls all the DirectX device resources. + class DeviceResources + { + public: + DeviceResources(DXGI_FORMAT backBufferFormat = DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT depthBufferFormat = DXGI_FORMAT_D24_UNORM_S8_UINT, + UINT backBufferCount = 2, + D3D_FEATURE_LEVEL minFeatureLevel = D3D_FEATURE_LEVEL_9_3); + + void CreateDeviceResources(); + void CreateWindowSizeDependentResources(); + void SetWindow(IUnknown* window, int width, int height, DXGI_MODE_ROTATION rotation); + bool WindowSizeChanged(int width, int height, DXGI_MODE_ROTATION rotation); + void ValidateDevice(); + void HandleDeviceLost(); + void RegisterDeviceNotify(IDeviceNotify* deviceNotify) { m_deviceNotify = deviceNotify; } + void Trim(); + void Present(); + + // Device Accessors. + RECT GetOutputSize() const { return m_outputSize; } + DXGI_MODE_ROTATION GetRotation() const { return m_rotation; } + + // Direct3D Accessors. + ID3D11Device2* GetD3DDevice() const { return m_d3dDevice.Get(); } + ID3D11DeviceContext2* GetD3DDeviceContext() const { return m_d3dContext.Get(); } + IDXGISwapChain3* GetSwapChain() const { return m_swapChain.Get(); } + D3D_FEATURE_LEVEL GetDeviceFeatureLevel() const { return m_d3dFeatureLevel; } + ID3D11RenderTargetView* GetBackBufferRenderTargetView() const { return m_d3dRenderTargetView.Get(); } + ID3D11DepthStencilView* GetDepthStencilView() const { return m_d3dDepthStencilView.Get(); } + DXGI_FORMAT GetBackBufferFormat() const { return m_backBufferFormat; } + DXGI_FORMAT GetDepthBufferFormat() const { return m_depthBufferFormat; } + D3D11_VIEWPORT GetScreenViewport() const { return m_screenViewport; } + UINT GetBackBufferCount() const { return m_backBufferCount; } + DirectX::XMFLOAT4X4 GetOrientationTransform3D() const { return m_orientationTransform3D; } + + private: + void GetHardwareAdapter(IDXGIAdapter1** ppAdapter); + + // Direct3D objects. + Microsoft::WRL::ComPtr m_d3dDevice; + Microsoft::WRL::ComPtr m_d3dContext; + Microsoft::WRL::ComPtr m_swapChain; + + // Direct3D rendering objects. Required for 3D. + Microsoft::WRL::ComPtr m_d3dRenderTargetView; + Microsoft::WRL::ComPtr m_d3dDepthStencilView; + D3D11_VIEWPORT m_screenViewport; + + // Direct3D properties. + DXGI_FORMAT m_backBufferFormat; + DXGI_FORMAT m_depthBufferFormat; + UINT m_backBufferCount; + D3D_FEATURE_LEVEL m_d3dMinFeatureLevel; + + // Cached device properties. + IUnknown* m_window; + D3D_FEATURE_LEVEL m_d3dFeatureLevel; + DXGI_MODE_ROTATION m_rotation; + RECT m_outputSize; + + // Transforms used for display orientation. + DirectX::XMFLOAT4X4 m_orientationTransform3D; + + // The IDeviceNotify can be held directly as it owns the DeviceResources. + IDeviceNotify* m_deviceNotify; + }; +} \ No newline at end of file diff --git a/Samples/System/MouseCursor/Main.cpp b/Samples/System/MouseCursor/Main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8da1e43caba34245d32a70aacdab9891bf5b63fd --- /dev/null +++ b/Samples/System/MouseCursor/Main.cpp @@ -0,0 +1,549 @@ +//-------------------------------------------------------------------------------------- +// Main.cpp +// +// Entry point for universal Windows app. +// +// Initialize the mouse cursor object and implements the event handling for +// necessary mouse cursor events to implement clip cursor or relative mouse mode. +// Keyboard handling is also implemented here. +// +// Advanced Technology Group (ATG) +// Copyright (C) Microsoft Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "MouseCursor.h" + +#include + +using namespace concurrency; +using namespace Windows::ApplicationModel; +using namespace Windows::ApplicationModel::Core; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::UI::Core; +using namespace Windows::UI::Input; +using namespace Windows::UI::ViewManagement; +using namespace Windows::System; +using namespace Windows::Foundation; +using namespace Windows::Graphics::Display; +using namespace DirectX; +using namespace DirectX::SimpleMath; + + +ref class ViewProvider sealed : public IFrameworkView +{ +public: + ViewProvider() : + m_exit( false ), + m_visible( true ), + m_DPI( 96.f ), + m_logicalWidth( 800.f ), + m_logicalHeight( 600.f ), + m_nativeOrientation( DisplayOrientations::None ), + m_currentOrientation( DisplayOrientations::None ) + { + m_outputWidthPixels = ConvertDipsToPixels(m_logicalWidth); + m_outputHeightPixels = ConvertDipsToPixels(m_logicalHeight); + } + + // IFrameworkView methods + virtual void Initialize( CoreApplicationView^ applicationView ) + { + applicationView->Activated += ref new + TypedEventHandler( this, &ViewProvider::OnActivated ); + + CoreApplication::Suspending += + ref new EventHandler( this, &ViewProvider::OnSuspending ); + + CoreApplication::Resuming += + ref new EventHandler( this, &ViewProvider::OnResuming ); + + m_sample = std::make_unique(); + } + + virtual void Uninitialize() + { + m_sample.reset(); + } + + virtual void SetWindow( CoreWindow^ window ) + { + window->SizeChanged += + ref new TypedEventHandler( this, &ViewProvider::OnWindowSizeChanged ); + + window->VisibilityChanged += + ref new TypedEventHandler( this, &ViewProvider::OnVisibilityChanged ); + + window->Closed += + ref new TypedEventHandler( this, &ViewProvider::OnWindowClosed ); + + auto dispatcher = CoreWindow::GetForCurrentThread()->Dispatcher; + + dispatcher->AcceleratorKeyActivated += + ref new TypedEventHandler(this, &ViewProvider::OnAcceleratorKeyActivated); + + auto currentDisplayInformation = DisplayInformation::GetForCurrentView(); + + currentDisplayInformation->DpiChanged += + ref new TypedEventHandler( this, &ViewProvider::OnDpiChanged ); + + currentDisplayInformation->OrientationChanged += + ref new TypedEventHandler( this, &ViewProvider::OnOrientationChanged ); + + DisplayInformation::DisplayContentsInvalidated += + ref new TypedEventHandler( this, &ViewProvider::OnDisplayContentsInvalidated ); + + // Mouse press and move handlers for the uncaptured mouse + window->PointerPressed += + ref new Windows::Foundation::TypedEventHandler( this, &ViewProvider::OnPointerPressed ); + + window->PointerMoved += + ref new Windows::Foundation::TypedEventHandler( this, &ViewProvider::OnPointerMoved ); + + // Handler for mouse movement when the mouse is captured + Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += + ref new Windows::Foundation::TypedEventHandler( this, &ViewProvider::OnMouseMoved ); + + // Handler for dealing with losing the capture mode + window->PointerCaptureLost += + ref new Windows::Foundation::TypedEventHandler( this, &ViewProvider::OnPointerCaptureLost ); + + window->KeyDown += + ref new Windows::Foundation::TypedEventHandler( this, &ViewProvider::OnKeyDown ); + + m_DPI = currentDisplayInformation->LogicalDpi; + + + + m_logicalWidth = window->Bounds.Width; + m_logicalHeight = window->Bounds.Height; + + m_nativeOrientation = currentDisplayInformation->NativeOrientation; + m_currentOrientation = currentDisplayInformation->CurrentOrientation; + + m_outputWidthPixels = ConvertDipsToPixels( m_logicalWidth ); + m_outputHeightPixels = ConvertDipsToPixels( m_logicalHeight ); + + DXGI_MODE_ROTATION rotation = ComputeDisplayRotation(); + + if ( rotation == DXGI_MODE_ROTATION_ROTATE90 || rotation == DXGI_MODE_ROTATION_ROTATE270 ) + { + std::swap(m_outputWidthPixels, m_outputHeightPixels); + } + + m_sample->Initialize( reinterpret_cast( window ), + m_outputWidthPixels, m_outputHeightPixels, rotation ); + } + + virtual void Load( Platform::String^ entryPoint ) + { + } + + virtual void Run() + { + while ( !m_exit ) + { + if ( m_visible ) + { + m_sample->Tick(); + + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents( CoreProcessEventsOption::ProcessAllIfPresent ); + } + else + { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents( CoreProcessEventsOption::ProcessOneAndAllPending ); + } + } + } + +protected: + // Event handlers + void OnActivated( CoreApplicationView^ applicationView, IActivatedEventArgs^ args ) + { + if (args->Kind == ActivationKind::Launch) + { + auto launchArgs = static_cast(args); + + if (launchArgs->PrelaunchActivated) + { + // Opt-out of Prelaunch + CoreApplication::Exit(); + return; + } + } + + int w, h; + m_sample->GetDefaultSize( w, h ); + + m_DPI = DisplayInformation::GetForCurrentView()->LogicalDpi; + + ApplicationView::PreferredLaunchWindowingMode = ApplicationViewWindowingMode::PreferredLaunchViewSize; + // Change to ApplicationViewWindowingMode::FullScreen to default to full screen + + auto desiredSize = Size( ConvertPixelsToDips( w ), + ConvertPixelsToDips( h ) ); + + ApplicationView::PreferredLaunchViewSize = desiredSize; + + auto view = ApplicationView::GetForCurrentView(); + + auto minSize = Size( ConvertPixelsToDips( 320 ), + ConvertPixelsToDips( 200 ) ); + + view->SetPreferredMinSize( minSize ); + + CoreWindow::GetForCurrentThread()->Activate(); + + view->FullScreenSystemOverlayMode = FullScreenSystemOverlayMode::Standard; + + CoreApplication::GetCurrentView()->TitleBar->ExtendViewIntoTitleBar = true; + + view->TryResizeView(desiredSize); + } + + void OnSuspending( Platform::Object^ sender, SuspendingEventArgs^ args ) + { + SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral(); + + create_task( [ this, deferral ] () + { + m_sample->OnSuspending(); + + deferral->Complete(); + } ); + } + + void OnResuming( Platform::Object^ sender, Platform::Object^ args ) + { + m_sample->OnResuming(); + } + + void OnWindowSizeChanged( CoreWindow^ sender, WindowSizeChangedEventArgs^ args ) + { + float prevWidth = (float) m_outputWidthPixels; + float prevHeight = (float) m_outputHeightPixels; + + m_logicalWidth = sender->Bounds.Width; + m_logicalHeight = sender->Bounds.Height; + + m_outputWidthPixels = ConvertDipsToPixels(m_logicalWidth); + m_outputHeightPixels = ConvertDipsToPixels(m_logicalHeight); + + // Adjust drawn cursor location based on size change + if (m_relative) + { + m_virtualCursorOnscreenPosition.X = m_outputWidthPixels / 2.0f; + m_virtualCursorOnscreenPosition.Y = m_outputHeightPixels / 2.0f; + } + else if (m_clipCursor) + { + m_virtualCursorOnscreenPosition.X = m_virtualCursorOnscreenPosition.X * (m_outputWidthPixels / prevWidth); + m_virtualCursorOnscreenPosition.Y = m_virtualCursorOnscreenPosition.Y * (m_outputHeightPixels / prevHeight); + m_sample->UpdatePointer(m_virtualCursorOnscreenPosition); + } + HandleWindowSizeChanged(); + } + + void OnVisibilityChanged( CoreWindow^ sender, VisibilityChangedEventArgs^ args ) + { + m_visible = args->Visible; + if ( m_visible ) + m_sample->OnActivated(); + else + m_sample->OnDeactivated(); + } + + void OnWindowClosed( CoreWindow^ sender, CoreWindowEventArgs^ args ) + { + m_exit = true; + } + + void OnAcceleratorKeyActivated(CoreDispatcher^, AcceleratorKeyEventArgs^ args) + { + if (args->EventType == CoreAcceleratorKeyEventType::SystemKeyDown + && args->VirtualKey == VirtualKey::Enter + && args->KeyStatus.IsMenuKeyDown + && !args->KeyStatus.WasKeyDown) + { + // Implements the classic ALT+ENTER fullscreen toggle + auto view = ApplicationView::GetForCurrentView(); + + if (view->IsFullScreenMode) + view->ExitFullScreenMode(); + else + view->TryEnterFullScreenMode(); + + args->Handled = true; + } + } + + + void OnDpiChanged( DisplayInformation^ sender, Object^ args ) + { + m_DPI = sender->LogicalDpi; + + HandleWindowSizeChanged(); + } + + void OnOrientationChanged( DisplayInformation^ sender, Object^ args ) + { + m_currentOrientation = sender->CurrentOrientation; + + HandleWindowSizeChanged(); + } + + void OnDisplayContentsInvalidated( DisplayInformation^ sender, Object^ args ) + { + m_sample->ValidateDevice(); + } + + // This handler is for the uncaptured windows mouse. When the mouse is still uncaptured ( in absolute mode ) + // pointer pressed events are handled to check if the user selected either UI option. + // If a UI tile is selected, the mouse is captured and either relative or clip cursor mode is entered. + // + void OnPointerPressed( Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^args ) + { + if ( m_absolute ) + { + // Check which mode the user selected + float newX = (float) ConvertDipsToPixels( args->CurrentPoint->Position.X ); + float newY = (float) ConvertDipsToPixels( args->CurrentPoint->Position.Y ); + + Sample::MouseMode mode = m_sample->SetMode( Windows::Foundation::Point( newX, newY ) ); + + // if the user selected relative mode, capture the mouse + if ( mode == Sample::RELATIVE_MOUSE ) + { + m_absolute = false; + m_relative = true; + + // Set the pointer cursor to null. This causes the windows mouse to disappear so the + // app or game's mouse can then be drawn. + sender->SetPointerCapture(); + sender->PointerCursor = nullptr; + + // Save the pointers position + m_virtualCursorOnscreenPosition.X = newX; + m_virtualCursorOnscreenPosition.Y = newY; + + m_virtualCursorOnscreenPosition.X = fmaxf( 0.f, fminf( m_virtualCursorOnscreenPosition.X, (float) m_outputWidthPixels ) ); + m_virtualCursorOnscreenPosition.Y = fmaxf( 0.f, fminf( m_virtualCursorOnscreenPosition.Y, (float) m_outputHeightPixels ) ); + + } + // If the user selected clip cursor mode, capture the mouse + else if ( mode == Sample::CLIPCURSOR_MOUSE ) + { + m_absolute = false; + m_clipCursor = true; + + // Set the pointer cursor to null. This causes the windows mouse to disappear so the + // app or game's mouse can then be drawn. + sender->SetPointerCapture(); + sender->PointerCursor = nullptr; + + // Save the pointers position + m_virtualCursorOnscreenPosition.X = newX; + m_virtualCursorOnscreenPosition.Y = newY; + + m_virtualCursorOnscreenPosition.X = fmaxf( 0.f, fminf( m_virtualCursorOnscreenPosition.X, (float) m_outputWidthPixels ) ); + m_virtualCursorOnscreenPosition.Y = fmaxf( 0.f, fminf( m_virtualCursorOnscreenPosition.Y, (float) m_outputHeightPixels ) ); + } + } + } + + // When ESC is pressed, exit clip cursor or relative mode and return to absolute mode + void OnKeyDown( Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::KeyEventArgs ^args ) + { + if ( args->VirtualKey == Windows::System::VirtualKey::Escape && !m_absolute ) + { + sender->ReleasePointerCapture(); + sender->PointerCursor = ref new CoreCursor( CoreCursorType::Arrow, 0 ); + + // Use the window location and the virtual cursors location to reposition the windows mouse + Windows::Foundation::Point newPoint; + newPoint.X = sender->Bounds.X + m_virtualCursorOnscreenPosition.X; + newPoint.Y = sender->Bounds.Y + m_virtualCursorOnscreenPosition.Y; + sender->PointerPosition = newPoint; + + m_clipCursor = false; + m_relative = false; + m_absolute = true; + Windows::Foundation::Point pt( 0,0 ); + m_sample->SetMode( pt ); + } + } + + // When the pointer capture is lost exit clip cursor or relative mode and return to absolute mode + void OnPointerCaptureLost( Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^args ) + { + sender->ReleasePointerCapture(); + sender->PointerCursor = ref new CoreCursor( CoreCursorType::Arrow, 0 ); + + // Use the window location and the virtual cursors location to reposition the windows mouse + Windows::Foundation::Point newPoint; + newPoint.X = sender->Bounds.X + m_virtualCursorOnscreenPosition.X; + newPoint.Y = sender->Bounds.Y + m_virtualCursorOnscreenPosition.Y; + sender->PointerPosition = newPoint; + + m_clipCursor = false; + m_relative = false; + m_absolute = true; + Windows::Foundation::Point pt( 0, 0 ); + m_sample->SetMode( pt ); + } + + // When the mouse moves in absolute mode check to see if it is hovering over a selection box + void OnPointerMoved( Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs ^args ) + { + if ( m_absolute ) + { + float newX = (float) ConvertDipsToPixels( args->CurrentPoint->Position.X ); + float newY = (float) ConvertDipsToPixels( args->CurrentPoint->Position.Y ); + + m_sample->CheckLocation( Windows::Foundation::Point( newX, newY ) ); + + } + } + + // When the mouse moves in captured mode update the on screen position for clip cursor or update the camera/target for relative mode + void OnMouseMoved( Windows::Devices::Input::MouseDevice ^sender, Windows::Devices::Input::MouseEventArgs ^args ) + { + float newX = (float)ConvertDipsToPixels((float)args->MouseDelta.X); + float newY = (float)ConvertDipsToPixels((float)args->MouseDelta.Y); + + if ( m_clipCursor ) + { + m_virtualCursorOnscreenPosition.X = m_virtualCursorOnscreenPosition.X + newX; + m_virtualCursorOnscreenPosition.Y = m_virtualCursorOnscreenPosition.Y + newY; + + m_virtualCursorOnscreenPosition.X = fmaxf( 0.f, fminf( m_virtualCursorOnscreenPosition.X, (float) m_outputWidthPixels ) ); + m_virtualCursorOnscreenPosition.Y = fmaxf( 0.f, fminf( m_virtualCursorOnscreenPosition.Y, (float) m_outputHeightPixels ) ); + + + m_sample->UpdatePointer( m_virtualCursorOnscreenPosition ); + } + else if ( m_relative ) + { + m_sample->UpdateCamera( Vector3( newX, newY, 0.f ) ); + } + } + +private: + bool m_exit; + bool m_visible; + float m_DPI; + float m_logicalWidth; + float m_logicalHeight; + int m_outputHeightPixels; + int m_outputWidthPixels; + std::unique_ptr m_sample; + + // Mode + bool m_clipCursor = false; + bool m_relative = false; + bool m_absolute = true; + + Windows::Foundation::Point m_virtualCursorOnscreenPosition; + Windows::Graphics::Display::DisplayOrientations m_nativeOrientation; + Windows::Graphics::Display::DisplayOrientations m_currentOrientation; + + inline int ConvertDipsToPixels( float dips ) const + { + return int( dips * m_DPI / 96.f + 0.5f ); + } + + inline float ConvertPixelsToDips(int pixels) const + { + return (float(pixels) * 96.f / m_DPI); + } + + DXGI_MODE_ROTATION ComputeDisplayRotation() const + { + DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED; + + switch ( m_nativeOrientation ) + { + case DisplayOrientations::Landscape: + switch ( m_currentOrientation ) + { + case DisplayOrientations::Landscape: + rotation = DXGI_MODE_ROTATION_IDENTITY; + break; + + case DisplayOrientations::Portrait: + rotation = DXGI_MODE_ROTATION_ROTATE270; + break; + + case DisplayOrientations::LandscapeFlipped: + rotation = DXGI_MODE_ROTATION_ROTATE180; + break; + + case DisplayOrientations::PortraitFlipped: + rotation = DXGI_MODE_ROTATION_ROTATE90; + break; + } + break; + + case DisplayOrientations::Portrait: + switch ( m_currentOrientation ) + { + case DisplayOrientations::Landscape: + rotation = DXGI_MODE_ROTATION_ROTATE90; + break; + + case DisplayOrientations::Portrait: + rotation = DXGI_MODE_ROTATION_IDENTITY; + break; + + case DisplayOrientations::LandscapeFlipped: + rotation = DXGI_MODE_ROTATION_ROTATE270; + break; + + case DisplayOrientations::PortraitFlipped: + rotation = DXGI_MODE_ROTATION_ROTATE180; + break; + } + break; + } + + return rotation; + } + + void HandleWindowSizeChanged() + { + m_outputWidthPixels = ConvertDipsToPixels( m_logicalWidth ); + m_outputHeightPixels = ConvertDipsToPixels( m_logicalHeight ); + + + DXGI_MODE_ROTATION rotation = ComputeDisplayRotation(); + + if ( rotation == DXGI_MODE_ROTATION_ROTATE90 || rotation == DXGI_MODE_ROTATION_ROTATE270 ) + { + std::swap(m_outputWidthPixels, m_outputHeightPixels); + } + + m_sample->OnWindowSizeChanged(m_outputWidthPixels, m_outputHeightPixels, rotation ); + } + +}; + +ref class ViewProviderFactory : IFrameworkViewSource +{ +public: + virtual IFrameworkView^ CreateView() + { + return ref new ViewProvider(); + } +}; + + +// Entry point +[ Platform::MTAThread ] +int main( Platform::Array^ argv ) +{ + UNREFERENCED_PARAMETER( argv ); + + auto viewProviderFactory = ref new ViewProviderFactory(); + CoreApplication::Run( viewProviderFactory ); + return 0; +} diff --git a/Samples/System/MouseCursor/MouseCursor.cpp b/Samples/System/MouseCursor/MouseCursor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..466645dd1b5659f45c7bb95fad784282551636b1 --- /dev/null +++ b/Samples/System/MouseCursor/MouseCursor.cpp @@ -0,0 +1,495 @@ +//-------------------------------------------------------------------------------------- +// MouseCursor.cpp +// +// MouseCursor UWP sample +// +// Advanced Technology Group (ATG) +// Copyright (C) Microsoft Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- + +#include "pch.h" +#include "MouseCursor.h" + +using namespace DirectX; +using namespace DirectX::SimpleMath; + +using Microsoft::WRL::ComPtr; + +#define ROTATION_GAIN 0.004f // sensitivity adjustment + +Sample::Sample() : + m_isAbsolute(true), + m_isRelative(false), + m_isClipCursor(false), + m_highlightFPS(false), + m_highlightRTS(false), + m_eyeFPS( 0.f, 20.f, -20.f ), + m_targetFPS( 0.f, 20.f, 0.f ), + m_eyeRTS( 0.f, 300.f, 0.f ), + m_targetRTS( 0.01f, 300.1f, 0.01f ), + m_eye( 0.f, 20.f, 0.f ), + m_target( 0.01f, 20.1f, 0.01f ), + m_pitch( 0 ), + m_yaw( 0 ) +{ + m_deviceResources = std::make_unique(); + m_deviceResources->RegisterDeviceNotify(this); +} + +// Initialize the Direct3D resources required to run. +void Sample::Initialize( IUnknown* window, int width, int height, DXGI_MODE_ROTATION rotation ) +{ + m_deviceResources->SetWindow(window, width, height, rotation); + + m_deviceResources->CreateDeviceResources(); + CreateDeviceDependentResources(); + + m_deviceResources->CreateWindowSizeDependentResources(); + CreateWindowSizeDependentResources(); + +} + +// Executes basic render loop. +void Sample::Tick() +{ + // In clip cursor mode implement screen scrolling when the mouse is near the edge of the screen + if ( m_isClipCursor ) + { + if ( m_screenLocation.X < 20.f ) + MoveRight( -25.f ); + + else if ( m_screenLocation.X > m_deviceResources->GetOutputSize().right - m_deviceResources->GetOutputSize().left - 20.f ) + MoveRight( 25.f ); + + if ( m_screenLocation.Y < 20.f ) + MoveForward( 25.f ); + else if ( m_screenLocation.Y > m_deviceResources->GetOutputSize().bottom - m_deviceResources->GetOutputSize().top - 20.f ) + MoveForward( -25.f ); + } + + m_timer.Tick( [ & ] () + { + Update( m_timer ); + } ); + + Render(); +} + +// Updates the world. +void Sample::Update( DX::StepTimer const&) +{ +} + +// Draws the scene. +void Sample::Render() +{ + + // Don't try to render anything before the first Update. + if ( m_timer.GetFrameCount() == 0 ) + { + return; + } + + Clear(); + + m_spriteBatch->Begin(); + + std::wstring text = L"+"; + + const wchar_t* output = text.c_str(); + Vector2 origin = m_font->MeasureString( output ) / 2.f; + + m_fontPos.x = m_screenLocation.X; + m_fontPos.y = m_screenLocation.Y; + + if ( m_isAbsolute ) + { + m_spriteBatch->Draw( m_texture_background.Get(), m_fullscreenRect ); + m_spriteBatch->Draw( m_texture_tile.Get(), m_FPStile ); + m_spriteBatch->Draw( m_texture_tile.Get(), m_RTStile ); + + if ( m_highlightFPS ) + { + m_spriteBatch->Draw( m_texture_tile_border.Get(), m_FPStile ); + } + else if ( m_highlightRTS ) + { + m_spriteBatch->Draw( m_texture_tile_border.Get(), m_RTStile ); + } + + std::wstring text1 = L"Mouse Cursor Sample"; + const wchar_t* outputTitle = text1.c_str(); + Vector2 originTitle = m_font64->MeasureString( outputTitle ) / 2.f; + std::wstring text2 = L"Choose a game mode"; + const wchar_t* outputSubtitle = text2.c_str(); + Vector2 originSubtitle = m_font32->MeasureString( outputSubtitle ) / 2.f; + + std::wstring text3 = L"First-person \n Shooter"; + const wchar_t* outputFPS = text3.c_str(); + Vector2 originFPS = m_font28->MeasureString( outputFPS ) / 2.f; + std::wstring text4 = L"Real-time \n Strategy"; + const wchar_t* outputRTS = text4.c_str(); + Vector2 originRTS = m_font28->MeasureString( outputRTS ) / 2.f; + + m_font64->DrawString( m_spriteBatch.get(), outputTitle, m_fontPosTitle, Colors::White, 0.f, originTitle ); + m_font32->DrawString( m_spriteBatch.get(), outputSubtitle, m_fontPosSubtitle, Colors::White, 0.f, originSubtitle ); + m_font28->DrawString( m_spriteBatch.get(), outputFPS, m_fontPosFPS, Colors::White, 0.f, originFPS ); + m_font28->DrawString( m_spriteBatch.get(), outputRTS, m_fontPosRTS, Colors::White, 0.f, originRTS ); + + } + else + { + m_font->DrawString( m_spriteBatch.get(), output, m_fontPos, Colors::White, 0.f, origin ); + + if ( m_isRelative ) + { + m_modelFPS->Draw( m_deviceResources->GetD3DDeviceContext(), *m_states, m_world, m_view, m_proj ); + } + else if ( m_isClipCursor ) + { + m_modelRTS->Draw( m_deviceResources->GetD3DDeviceContext(), *m_states, m_world, m_view, m_proj ); + } + } + + m_spriteBatch->End(); + + m_deviceResources->Present(); +} + +// Helper method to clear the back buffers. +void Sample::Clear() +{ + // Clear the views + auto context = m_deviceResources->GetD3DDeviceContext(); + auto renderTarget = m_deviceResources->GetBackBufferRenderTargetView(); + auto depthStencil = m_deviceResources->GetDepthStencilView(); + + context->ClearRenderTargetView(renderTarget, Colors::CornflowerBlue); + context->ClearDepthStencilView(depthStencil, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); + context->OMSetRenderTargets(1, &renderTarget, depthStencil); + + // Set the viewport. + auto viewport = m_deviceResources->GetScreenViewport(); + context->RSSetViewports(1, &viewport); + +} + + +// Message handlers +void Sample::OnActivated() +{ +} + +void Sample::OnDeactivated() +{ +} + +void Sample::OnSuspending() +{ + auto context = m_deviceResources->GetD3DDeviceContext(); + context->ClearState(); + + m_deviceResources->Trim(); +} + +void Sample::OnResuming() +{ + m_timer.ResetElapsedTime(); +} + +void Sample::OnWindowSizeChanged( int width, int height, DXGI_MODE_ROTATION rotation ) +{ + if ( !m_deviceResources->WindowSizeChanged( width, height, rotation ) ) + return; + + CreateWindowSizeDependentResources(); +} + +void Sample::ValidateDevice() +{ + m_deviceResources->ValidateDevice(); +} + +// Properties +void Sample::GetDefaultSize( int& width, int& height ) const +{ + width = 1280; + height = 720; +} + +// These are the resources that depend on the device. +void Sample::CreateDeviceDependentResources() +{ + auto context = m_deviceResources->GetD3DDeviceContext(); + auto device = m_deviceResources->GetD3DDevice(); + + // Device dependent object initialization ( independent of window size ) + m_font = std::make_unique(device, L"Courier_36.spritefont"); + m_font64 = std::make_unique(device, L"SegoeUI_34.spritefont"); + m_font32 = std::make_unique(device, L"SegoeUI_24.spritefont"); + m_font28 = std::make_unique(device, L"SegoeUI_22.spritefont"); + m_spriteBatch = std::make_unique(context); + + m_states = std::make_unique(device); + m_fxFactory = std::make_unique(device); + + m_modelFPS = Model::CreateFromSDKMESH( device, L"FPSRoom.sdkmesh", *m_fxFactory, true ); + + // Note that this model uses 32-bit index buffers so it can't be used w/ Feature Level 9.1 + m_modelRTS = Model::CreateFromSDKMESH(device, L"3DRTSMap.sdkmesh", *m_fxFactory, true ); + + DX::ThrowIfFailed( + CreateWICTextureFromFile(device, L"Assets//background_flat.png", + nullptr, m_texture_background.ReleaseAndGetAddressOf() ) ); + DX::ThrowIfFailed( + CreateWICTextureFromFile(device, L"Assets//green_tile.png", nullptr, + m_texture_tile.ReleaseAndGetAddressOf() ) ); + DX::ThrowIfFailed( + CreateWICTextureFromFile(device, L"Assets//green_tile_border.png", nullptr, + m_texture_tile_border.ReleaseAndGetAddressOf() ) ); + + m_world = Matrix::Identity; +} + +// Allocate all memory resources that change on a window SizeChanged event. +void Sample::CreateWindowSizeDependentResources() +{ + // Initialization of background image + m_fullscreenRect = m_deviceResources->GetOutputSize(); + + UINT backBufferWidth = static_cast(m_fullscreenRect.right - m_fullscreenRect.left); + UINT backBufferHeight = static_cast(m_fullscreenRect.bottom - m_fullscreenRect.top); + + // Update pointer location + if (m_isRelative) + { + m_screenLocation.X = backBufferWidth / 2.f; + m_screenLocation.Y = backBufferHeight / 2.f; + } + + // Initialize UI tiles and font locations + m_FPStile.left = ( LONG ) ( 0.325f*backBufferWidth ); + m_FPStile.top = ( LONG ) ( 0.44f*backBufferHeight ); + m_FPStile.right = ( LONG ) ( 0.495f*backBufferWidth ); + m_FPStile.bottom = ( LONG ) ( 0.66f*backBufferHeight ); + m_FPStile.bottom = std::max( m_FPStile.bottom, m_FPStile.top + 150 ); + m_FPStile.left = std::min( m_FPStile.left, ( LONG ) ( m_FPStile.right - ( ( m_FPStile.bottom - m_FPStile.top ) * 4 / 3.f ) ) ); + + m_RTStile.left = ( LONG ) ( 0.505f*backBufferWidth ); + m_RTStile.top = m_FPStile.top; + m_RTStile.right = ( LONG ) ( 0.675f*backBufferWidth ); + m_RTStile.bottom = m_FPStile.bottom; + m_RTStile.right = std::max( m_RTStile.right, ( LONG )( m_RTStile.left + ( ( m_RTStile.bottom - m_RTStile.top ) * 4 / 3.f ) ) ); + + m_fontPos.x = backBufferWidth / 2.f; + m_fontPos.y = backBufferHeight / 2.f; + + m_fontPosTitle.x = backBufferWidth / 2.f; + m_fontPosTitle.y = backBufferHeight * 0.27f; + + m_fontPosSubtitle.x = backBufferWidth / 2.f; + m_fontPosSubtitle.y = backBufferHeight * 0.36f; + + m_fontPosFPS.x = m_FPStile.left + ( m_FPStile.right - m_FPStile.left )/2.f; + m_fontPosFPS.y = m_FPStile.top + ( m_FPStile.bottom - m_FPStile.top ) / 2.f; + + m_fontPosRTS.x = m_RTStile.left + ( m_RTStile.right - m_RTStile.left )/2.f; + m_fontPosRTS.y = m_fontPosFPS.y; + + m_spriteBatch->SetRotation( m_deviceResources->GetRotation() ); +} + +void Sample::OnDeviceLost() +{ + m_font.reset(); + m_font64.reset(); + m_font32.reset(); + m_font28.reset(); + m_spriteBatch.reset(); + m_states.reset(); + m_fxFactory.reset(); + m_modelFPS.reset(); + m_modelRTS.reset(); + m_texture_background.Reset(); + m_texture_tile.Reset(); + m_texture_tile_border.Reset(); +} + +void Sample::OnDeviceRestored() +{ + CreateDeviceDependentResources(); + + CreateWindowSizeDependentResources(); +} + +// Update the pointer location in clip cursor mode +void Sample::UpdatePointer( Windows::Foundation::Point screen ) +{ + m_screenLocation = screen; +} + +// Change the target value based on the mouse movement for move-look/relative mouse mode +void Sample::UpdateCamera( Vector3 movement ) +{ + // Adjust pitch and yaw based on the mouse movement + Vector3 rotationDelta = movement * ROTATION_GAIN; + m_pitch += rotationDelta.y; + m_yaw += rotationDelta.x; + + // Limit to avoid looking directly up or down + float limit = XM_PI / 2.0f - 0.01f; + m_pitch = std::max( -limit, m_pitch ); + m_pitch = std::min( +limit, m_pitch ); + + if ( m_yaw > XM_PI ) + { + m_yaw -= XM_PI * 2.f; + } + else if ( m_yaw < -XM_PI ) + { + m_yaw += XM_PI * 2.f; + } + + float y = sinf( m_pitch ); + float r = cosf( m_pitch ); + float z = r*cosf( m_yaw ); + float x = r*sinf( m_yaw ); + + m_target = m_eye + Vector3( x, y, z ); + + SetView(); +} + +// Move the camera forward or backward +void Sample::MoveForward( float amount ) +{ + Vector3 movement = m_target - m_eye; + movement.y = 0.f; + Vector3 m_eye_temp = m_eye - amount*movement; + + if ( ( m_eye_temp.z < -1*m_eye_temp.x + 400 ) && ( m_eye_temp.z < m_eye_temp.x + 800 ) + && ( m_eye_temp.z > -1 * m_eye_temp.x - 300 ) && ( m_eye_temp.z > m_eye_temp.x - 800 ) ) + { + m_eye = m_eye_temp; + m_target = m_target - amount*movement; + + SetView(); + } +} + +// Move the camera to the right or left +void Sample::MoveRight( float amount ) +{ + Vector3 movement1 = m_target - m_eye; + movement1.y = 0.f; + Vector3 movement; + movement.x = -movement1.z; + movement.y = 0.f; + movement.z = movement1.x; + + + Vector3 m_eye_temp = m_eye + amount*movement; + + if ( ( m_eye_temp.z < ( -1 * m_eye_temp.x + 400 ) ) && ( m_eye_temp.z < ( m_eye_temp.x + 800 ) ) + && ( m_eye_temp.z > ( -1 * m_eye_temp.x - 300 ) ) && ( m_eye_temp.z > ( m_eye_temp.x - 800 ) ) ) + { + m_eye = m_eye_temp; + m_target = m_target + amount*movement; + + SetView(); + } +} + +// Update the viewport based on the updated eye and target values +void Sample::SetView() +{ + UINT backBufferWidth = static_cast( m_deviceResources->GetOutputSize().right - m_deviceResources->GetOutputSize().left ); + UINT backBufferHeight = static_cast( m_deviceResources->GetOutputSize().bottom - m_deviceResources->GetOutputSize().top ); + + m_view = Matrix::CreateLookAt( m_eye, m_target, Vector3::UnitY ); + Matrix proj = XMMatrixPerspectiveFovLH( XM_PI / 4.f, float( backBufferWidth ) / float( backBufferHeight ), 0.1f, 10000.f ); + + m_proj = proj * m_deviceResources->GetOrientationTransform3D(); +} + +// Set mode to relative ( 1 ), absolute ( 0 ), or clip cursor ( 2 ) +Sample::MouseMode Sample::SetMode( Windows::Foundation::Point mouseLocation ) +{ + // If entering FPS or relative mode + if ( mouseLocation.X < m_FPStile.right && mouseLocation.X > m_FPStile.left + && mouseLocation.Y > m_FPStile.top && mouseLocation.Y < m_FPStile.bottom ) + { + UINT backBufferWidth = static_cast( m_deviceResources->GetOutputSize().right - m_deviceResources->GetOutputSize().left ); + UINT backBufferHeight = static_cast( m_deviceResources->GetOutputSize().bottom - m_deviceResources->GetOutputSize().top ); + + m_screenLocation.X = backBufferWidth / 2.f; + m_screenLocation.Y = backBufferHeight / 2.f; + + m_isRelative = true; + m_isAbsolute = false; + m_isClipCursor = false; + m_highlightFPS = false; + m_highlightRTS = false; + m_world = Matrix::CreateRotationX( XM_PI / 2.f )*Matrix::CreateRotationY( XM_PI ); + m_eye = m_eyeFPS; + m_target = m_targetFPS; + UpdateCamera( Vector3::Zero ); + SetView(); + return RELATIVE_MOUSE; + } + // If entering RTS or clipCursor mode + else if ( mouseLocation.X < m_RTStile.right && mouseLocation.X > m_RTStile.left + && mouseLocation.Y > m_RTStile.top && mouseLocation.Y < m_RTStile.bottom ) + { + m_isRelative = false; + m_isAbsolute = false; + m_isClipCursor = true; + m_highlightFPS = false; + m_highlightRTS = false; + m_world = Matrix::CreateRotationX( XM_PI / 2.f )*Matrix::CreateRotationY( 5 * XM_PI / 4 ); + m_eye = m_eyeRTS; + m_target = m_targetRTS; + SetView(); + return CLIPCURSOR_MOUSE; + } + // Entering absolute mode + else + { + if ( m_isClipCursor ) + { + m_eyeRTS = m_eye; + m_targetRTS = m_target; + } + m_isRelative = false; + m_isAbsolute = true; + m_isClipCursor = false; + return ABSOLUTE_MOUSE; + } +} + +// When the mouse moves, check to see if it is on top of the FPS or RTS selection tiles +void Sample::CheckLocation( Windows::Foundation::Point mouseLocation ) +{ + if ( m_isAbsolute ) + { + // If hovering over FPS or relative selection + if ( mouseLocation.X < m_FPStile.right && mouseLocation.X > m_FPStile.left + && mouseLocation.Y > m_FPStile.top && mouseLocation.Y < m_FPStile.bottom ) + { + m_highlightFPS = true; + m_highlightRTS = false; + } + // If hovering over RTS or clipCursor selection + else if ( mouseLocation.X < m_RTStile.right && mouseLocation.X > m_RTStile.left + && mouseLocation.Y > m_RTStile.top && mouseLocation.Y < m_RTStile.bottom ) + { + m_highlightRTS = true; + m_highlightFPS = false; + } + else + { + m_highlightFPS = false; + m_highlightRTS = false; + } + } +} diff --git a/Samples/System/MouseCursor/MouseCursor.h b/Samples/System/MouseCursor/MouseCursor.h new file mode 100644 index 0000000000000000000000000000000000000000..7bd365b31769893db5e3a0a3c3d21a118a5cb712 --- /dev/null +++ b/Samples/System/MouseCursor/MouseCursor.h @@ -0,0 +1,123 @@ +//-------------------------------------------------------------------------------------- +// MouseCursor.h +// +// MouseCursor UWP sample +// +// Advanced Technology Group (ATG) +// Copyright (C) Microsoft Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- + +#pragma once + +#include "DeviceResources.h" +#include "StepTimer.h" + + +// A basic sample implementation that creates a D3D11 device and +// provides a render loop. +class Sample : public DX::IDeviceNotify +{ +public: + + Sample(); + + enum MouseMode {ABSOLUTE_MOUSE, RELATIVE_MOUSE, CLIPCURSOR_MOUSE}; + + // Initialization and management + void Initialize( IUnknown* window, int width, int height, DXGI_MODE_ROTATION rotation ); + + // Basic render loop + void Tick(); + void Render(); + + // Rendering helpers + void Clear(); + + //IDeviceNotify + virtual void OnDeviceLost() override; + virtual void OnDeviceRestored() override; + + // Mouse cursor camera and target updates + void UpdatePointer( Windows::Foundation::Point screen ); + void UpdateCamera( DirectX::SimpleMath::Vector3 movement ); + void MoveForward( float amount ); + void MoveRight( float amount ); + + // Sample logic + MouseMode SetMode( Windows::Foundation::Point mouseLocation ); + void CheckLocation( Windows::Foundation::Point mouseLocation ); + + // Messages + void OnActivated(); + void OnDeactivated(); + void OnSuspending(); + void OnResuming(); + void OnWindowSizeChanged( int width, int height, DXGI_MODE_ROTATION rotation ); + void ValidateDevice(); + + // Properties + void GetDefaultSize( int& width, int& height ) const; + +private: + + void Update(DX::StepTimer const& timer); + + void CreateDeviceDependentResources(); + void CreateWindowSizeDependentResources(); + + // Device resources. + std::unique_ptr m_deviceResources; + + // Rendering loop timer. + DX::StepTimer m_timer; + + // MouseCursor sample + void SetView(); + + bool m_isAbsolute; + bool m_isRelative; + bool m_isClipCursor; + bool m_highlightFPS; + bool m_highlightRTS; + + // FPS + DirectX::SimpleMath::Vector3 m_eyeFPS; + DirectX::SimpleMath::Vector3 m_targetFPS; + // RTS + DirectX::SimpleMath::Vector3 m_eyeRTS; + DirectX::SimpleMath::Vector3 m_targetRTS; + + DirectX::SimpleMath::Vector3 m_eye; + DirectX::SimpleMath::Vector3 m_target; + + float m_pitch, m_yaw; + + DirectX::SimpleMath::Matrix m_world; + DirectX::SimpleMath::Matrix m_view; + DirectX::SimpleMath::Matrix m_proj; + + Windows::Foundation::Point m_absoluteLocation; + Windows::Foundation::Point m_screenLocation; + + // DirectXTK rendering + std::unique_ptr m_font; + std::unique_ptr m_font64; + std::unique_ptr m_font32; + std::unique_ptr m_font28; + DirectX::SimpleMath::Vector2 m_fontPos; + DirectX::SimpleMath::Vector2 m_fontPosTitle; + DirectX::SimpleMath::Vector2 m_fontPosSubtitle; + DirectX::SimpleMath::Vector2 m_fontPosFPS; + DirectX::SimpleMath::Vector2 m_fontPosRTS; + std::unique_ptr m_spriteBatch; + std::unique_ptr m_states; + std::unique_ptr m_fxFactory; + std::unique_ptr m_modelFPS; + std::unique_ptr m_modelRTS; + Microsoft::WRL::ComPtr m_texture_background; + Microsoft::WRL::ComPtr m_texture_tile; + Microsoft::WRL::ComPtr m_texture_tile_border; + RECT m_fullscreenRect; + RECT m_FPStile; + RECT m_RTStile; +}; \ No newline at end of file diff --git a/Samples/System/MouseCursor/MouseCursor.sln b/Samples/System/MouseCursor/MouseCursor.sln new file mode 100644 index 0000000000000000000000000000000000000000..17c15a2a5d096a8207a022ee1a970a6fd0dfbc70 --- /dev/null +++ b/Samples/System/MouseCursor/MouseCursor.sln @@ -0,0 +1,54 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MouseCursor", "MouseCursor.vcxproj", "{D6509BBC-0AA1-44F0-A597-5784AD1276E4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTK", "..\..\..\Kits\DirectXTK\DirectXTK_Windows10.vcxproj", "{F4776924-619C-42C7-88B2-82C947CCC9E7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Debug|ARM.ActiveCfg = Debug|ARM + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Debug|ARM.Build.0 = Debug|ARM + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Debug|ARM.Deploy.0 = Debug|ARM + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Debug|x64.ActiveCfg = Debug|x64 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Debug|x64.Build.0 = Debug|x64 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Debug|x64.Deploy.0 = Debug|x64 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Debug|x86.ActiveCfg = Debug|Win32 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Debug|x86.Build.0 = Debug|Win32 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Debug|x86.Deploy.0 = Debug|Win32 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Release|ARM.ActiveCfg = Release|ARM + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Release|ARM.Build.0 = Release|ARM + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Release|ARM.Deploy.0 = Release|ARM + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Release|x64.ActiveCfg = Release|x64 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Release|x64.Build.0 = Release|x64 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Release|x64.Deploy.0 = Release|x64 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Release|x86.ActiveCfg = Release|Win32 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Release|x86.Build.0 = Release|Win32 + {D6509BBC-0AA1-44F0-A597-5784AD1276E4}.Release|x86.Deploy.0 = Release|Win32 + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|ARM.ActiveCfg = Debug|ARM + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|ARM.Build.0 = Debug|ARM + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|x64.ActiveCfg = Debug|x64 + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|x64.Build.0 = Debug|x64 + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|x86.ActiveCfg = Debug|Win32 + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Debug|x86.Build.0 = Debug|Win32 + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|ARM.ActiveCfg = Release|ARM + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|ARM.Build.0 = Release|ARM + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|x64.ActiveCfg = Release|x64 + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|x64.Build.0 = Release|x64 + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|x86.ActiveCfg = Release|Win32 + {F4776924-619C-42C7-88B2-82C947CCC9E7}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/System/MouseCursor/MouseCursor.vcxproj b/Samples/System/MouseCursor/MouseCursor.vcxproj new file mode 100644 index 0000000000000000000000000000000000000000..333641fa74739e83fe7bab75371b5a2767fab466 --- /dev/null +++ b/Samples/System/MouseCursor/MouseCursor.vcxproj @@ -0,0 +1,307 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + + {d6509bbc-0aa1-44f0-a597-5784ad1276e4} + DirectXApp + MouseCursor + en-US + 14.0 + true + Windows Store + 10.0 + 10.0.10586.0 + 10.0.10586.0 + true + 100 + + + + Application + true + v140 + + + Application + true + v140 + + + Application + true + v140 + + + Application + false + true + v140 + true + + + Application + false + true + v140 + true + + + Application + false + true + v140 + true + + + + + + + + + + + + + + + + + + + + + + + + MouseCursor_TemporaryKey.pfx + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm; $(VCInstallDir)\lib\arm + + + pch.h + $(IntDir)pch.pch + ..\..\..\Kits\DirectXTK\Inc;$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + Level4 + Fast + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm; $(VCInstallDir)\lib\arm + + + pch.h + $(IntDir)pch.pch + ..\..\..\Kits\DirectXTK\Inc;$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + Level4 + Fast + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store; $(VCInstallDir)\lib + + + pch.h + $(IntDir)pch.pch + ..\..\..\Kits\DirectXTK\Inc;$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + Level4 + Fast + StreamingSIMDExtensions2 + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store; $(VCInstallDir)\lib + + + pch.h + $(IntDir)pch.pch + ..\..\..\Kits\DirectXTK\Inc;$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + Level4 + Fast + StreamingSIMDExtensions2 + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\amd64; $(VCInstallDir)\lib\amd64 + + + pch.h + $(IntDir)pch.pch + ..\..\..\Kits\DirectXTK\Inc;$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + Level4 + Fast + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\amd64; $(VCInstallDir)\lib\amd64 + + + pch.h + $(IntDir)pch.pch + ..\..\..\Kits\DirectXTK\Inc;$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + Level4 + Fast + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + + + + + Designer + + + true + true + true + true + true + true + + + true + true + true + true + true + true + + + true + true + true + true + true + true + + + true + true + true + true + true + true + + + true + true + true + true + true + true + + + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {f4776924-619c-42c7-88b2-82c947ccc9e7} + + + + + diff --git a/Samples/System/MouseCursor/MouseCursor.vcxproj.filters b/Samples/System/MouseCursor/MouseCursor.vcxproj.filters new file mode 100644 index 0000000000000000000000000000000000000000..bae0b997ea1122da8aa90f28d60fd295c7c10db4 --- /dev/null +++ b/Samples/System/MouseCursor/MouseCursor.vcxproj.filters @@ -0,0 +1,122 @@ + + + + + fa5e4e28-fb89-4c14-9295-017714dc16f9 + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png + + + {32f25e5b-b27e-46b1-a91c-5508065bfa7a} + + + {89490c62-3dda-441f-92db-00b0c96208e5} + + + + + + + + + + + + + + + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets\FPSRoom + + + Assets\FPSRoom + + + Assets\FPSRoom + + + Assets\FPSRoom + + + Assets\FPSRoom + + + Assets\FPSRoom + + + Assets\FPSRoom + + + Assets\FPSRoom + + + Assets\RTSMap + + + Assets\RTSMap + + + Assets\RTSMap + + + + + + + + + Assets\FPSRoom + + + Assets\RTSMap + + + Assets + + + Assets + + + Assets + + + Assets + + + + + + Assets + + + Assets + + + \ No newline at end of file diff --git a/Samples/System/MouseCursor/MouseCursor_Readme.docx b/Samples/System/MouseCursor/MouseCursor_Readme.docx new file mode 100644 index 0000000000000000000000000000000000000000..c3d7fa962966205feca036cd6337924e14a9784a Binary files /dev/null and b/Samples/System/MouseCursor/MouseCursor_Readme.docx differ diff --git a/Samples/System/MouseCursor/MouseCursor_TemporaryKey.pfx b/Samples/System/MouseCursor/MouseCursor_TemporaryKey.pfx new file mode 100644 index 0000000000000000000000000000000000000000..1bf40357a086c7b6203c6df3b985c601585b4636 Binary files /dev/null and b/Samples/System/MouseCursor/MouseCursor_TemporaryKey.pfx differ diff --git a/Samples/System/MouseCursor/Package.appxmanifest b/Samples/System/MouseCursor/Package.appxmanifest new file mode 100644 index 0000000000000000000000000000000000000000..28ad01a9a65e69e735e77572690215fefdb8eec7 --- /dev/null +++ b/Samples/System/MouseCursor/Package.appxmanifest @@ -0,0 +1,49 @@ + + + + + + + + + + MouseCursor + Microsoft ATG + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/System/MouseCursor/StepTimer.h b/Samples/System/MouseCursor/StepTimer.h new file mode 100644 index 0000000000000000000000000000000000000000..e6f7acf56417f3184f8c17beecfbb1aaa124cdaf --- /dev/null +++ b/Samples/System/MouseCursor/StepTimer.h @@ -0,0 +1,188 @@ +// +// StepTimer.h - A simple timer that provides elapsed time information +// + +#pragma once + +#include +#include + +namespace DX +{ + // Helper class for animation and simulation timing. + class StepTimer + { + public: + StepTimer() : + m_elapsedTicks(0), + m_totalTicks(0), + m_leftOverTicks(0), + m_frameCount(0), + m_framesPerSecond(0), + m_framesThisSecond(0), + m_qpcSecondCounter(0), + m_isFixedTimeStep(false), + m_targetElapsedTicks(TicksPerSecond / 60) + { + if (!QueryPerformanceFrequency(&m_qpcFrequency)) + { + throw std::exception( "QueryPerformanceFrequency" ); + } + + if (!QueryPerformanceCounter(&m_qpcLastTime)) + { + throw std::exception( "QueryPerformanceCounter" ); + } + + // Initialize max delta to 1/10 of a second. + m_qpcMaxDelta = m_qpcFrequency.QuadPart / 10; + } + + // Get elapsed time since the previous Update call. + uint64_t GetElapsedTicks() const { return m_elapsedTicks; } + double GetElapsedSeconds() const { return TicksToSeconds(m_elapsedTicks); } + + // Get total time since the start of the program. + uint64_t GetTotalTicks() const { return m_totalTicks; } + double GetTotalSeconds() const { return TicksToSeconds(m_totalTicks); } + + // Get total number of updates since start of the program. + uint32_t GetFrameCount() const { return m_frameCount; } + + // Get the current framerate. + uint32_t GetFramesPerSecond() const { return m_framesPerSecond; } + + // Set whether to use fixed or variable timestep mode. + void SetFixedTimeStep(bool isFixedTimestep) { m_isFixedTimeStep = isFixedTimestep; } + + // Set how often to call Update when in fixed timestep mode. + void SetTargetElapsedTicks(uint64_t targetElapsed) { m_targetElapsedTicks = targetElapsed; } + void SetTargetElapsedSeconds(double targetElapsed) { m_targetElapsedTicks = SecondsToTicks(targetElapsed); } + + // Integer format represents time using 10,000,000 ticks per second. + static const uint64_t TicksPerSecond = 10000000; + + static double TicksToSeconds(uint64_t ticks) { return static_cast(ticks) / TicksPerSecond; } + static uint64_t SecondsToTicks(double seconds) { return static_cast(seconds * TicksPerSecond); } + + // After an intentional timing discontinuity (for instance a blocking IO operation) + // call this to avoid having the fixed timestep logic attempt a set of catch-up + // Update calls. + + void ResetElapsedTime() + { + if (!QueryPerformanceCounter(&m_qpcLastTime)) + { + throw std::exception("QueryPerformanceCounter"); + } + + m_leftOverTicks = 0; + m_framesPerSecond = 0; + m_framesThisSecond = 0; + m_qpcSecondCounter = 0; + } + + // Update timer state, calling the specified Update function the appropriate number of times. + template + void Tick(const TUpdate& update) + { + // Query the current time. + LARGE_INTEGER currentTime; + + if (!QueryPerformanceCounter(¤tTime)) + { + throw std::exception( "QueryPerformanceCounter" ); + } + + uint64_t timeDelta = currentTime.QuadPart - m_qpcLastTime.QuadPart; + + m_qpcLastTime = currentTime; + m_qpcSecondCounter += timeDelta; + + // Clamp excessively large time deltas (e.g. after paused in the debugger). + if (timeDelta > m_qpcMaxDelta) + { + timeDelta = m_qpcMaxDelta; + } + + // Convert QPC units into a canonical tick format. This cannot overflow due to the previous clamp. + timeDelta *= TicksPerSecond; + timeDelta /= m_qpcFrequency.QuadPart; + + uint32_t lastFrameCount = m_frameCount; + + if (m_isFixedTimeStep) + { + // Fixed timestep update logic + + // If the app is running very close to the target elapsed time (within 1/4 of a millisecond) just clamp + // the clock to exactly match the target value. This prevents tiny and irrelevant errors + // from accumulating over time. Without this clamping, a game that requested a 60 fps + // fixed update, running with vsync enabled on a 59.94 NTSC display, would eventually + // accumulate enough tiny errors that it would drop a frame. It is better to just round + // small deviations down to zero to leave things running smoothly. + + if (abs(static_cast(timeDelta - m_targetElapsedTicks)) < TicksPerSecond / 4000) + { + timeDelta = m_targetElapsedTicks; + } + + m_leftOverTicks += timeDelta; + + while (m_leftOverTicks >= m_targetElapsedTicks) + { + m_elapsedTicks = m_targetElapsedTicks; + m_totalTicks += m_targetElapsedTicks; + m_leftOverTicks -= m_targetElapsedTicks; + m_frameCount++; + + update(); + } + } + else + { + // Variable timestep update logic. + m_elapsedTicks = timeDelta; + m_totalTicks += timeDelta; + m_leftOverTicks = 0; + m_frameCount++; + + update(); + } + + // Track the current framerate. + if (m_frameCount != lastFrameCount) + { + m_framesThisSecond++; + } + + if (m_qpcSecondCounter >= static_cast(m_qpcFrequency.QuadPart)) + { + m_framesPerSecond = m_framesThisSecond; + m_framesThisSecond = 0; + m_qpcSecondCounter %= m_qpcFrequency.QuadPart; + } + } + + private: + // Source timing data uses QPC units. + LARGE_INTEGER m_qpcFrequency; + LARGE_INTEGER m_qpcLastTime; + uint64_t m_qpcMaxDelta; + + // Derived timing data uses a canonical tick format. + uint64_t m_elapsedTicks; + uint64_t m_totalTicks; + uint64_t m_leftOverTicks; + + // Members for tracking the framerate. + uint32_t m_frameCount; + uint32_t m_framesPerSecond; + uint32_t m_framesThisSecond; + uint64_t m_qpcSecondCounter; + + // Members for configuring fixed timestep mode. + bool m_isFixedTimeStep; + uint64_t m_targetElapsedTicks; + }; +} diff --git a/Samples/System/MouseCursor/pch.cpp b/Samples/System/MouseCursor/pch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..851c81be9b30ae3e8175fb950b95a1c9508580a3 --- /dev/null +++ b/Samples/System/MouseCursor/pch.cpp @@ -0,0 +1,10 @@ +//-------------------------------------------------------------------------------------- +// pch.cpp +// +// Include the standard header and generate the precompiled header. +// +// Advanced Technology Group (ATG) +// Copyright (C) Microsoft Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- + +#include "pch.h" diff --git a/Samples/System/MouseCursor/pch.h b/Samples/System/MouseCursor/pch.h new file mode 100644 index 0000000000000000000000000000000000000000..e31c0f18a2facc354b8ce05aef938c91b7556800 --- /dev/null +++ b/Samples/System/MouseCursor/pch.h @@ -0,0 +1,69 @@ +//-------------------------------------------------------------------------------------- +// pch.h +// +// Header for standard system include files. +// +// Advanced Technology Group (ATG) +// Copyright (C) Microsoft Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- + +#pragma once + +// Use the C++ standard templated min/max +#define NOMINMAX + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#ifdef _DEBUG +#include +#endif + +#include "CommonStates.h" +#include "Effects.h" +#include "Model.h" +#include "SimpleMath.h" +#include "SpriteFont.h" +#include "WICTextureLoader.h" + +namespace DX +{ + + // Helper class for COM exceptions + class com_exception : public std::exception + { + public: + com_exception(HRESULT hr) : result(hr) {} + + virtual const char* what() const override + { + static char s_str[64] = { 0 }; + sprintf_s(s_str, "Failure with HRESULT of %08X", result); + return s_str; + } + + private: + HRESULT result; + }; + + // Helper utility converts D3D API failures into exceptions. + inline void ThrowIfFailed(HRESULT hr) + { + if (FAILED(hr)) + { + throw com_exception(hr); + } + } + +} \ No newline at end of file