.edtiorconfig driven reformat of source (#123)
This commit is contained in:
Родитель
1135875b05
Коммит
5505e6b920
|
@ -1,9 +1,74 @@
|
||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*.{cpp,h,inl,fx,fxh,hlsl,hlsli}]
|
[*.{fx,fxh,hlsl,hlsli}]
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
indent_style = space
|
indent_style = space
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
end_of_line = crlf
|
end_of_line = crlf
|
||||||
charset = latin1
|
charset = latin1
|
||||||
|
cpp_space_before_function_open_parenthesis = remove
|
||||||
|
cpp_space_around_binary_operator = ignore
|
||||||
|
cpp_space_pointer_reference_alignment = ignore
|
||||||
|
|
||||||
|
[*.{cpp,h,hpp,inl}]
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
end_of_line = crlf
|
||||||
|
charset = latin1
|
||||||
|
cpp_indent_braces = false
|
||||||
|
cpp_indent_multi_line_relative_to = innermost_parenthesis
|
||||||
|
cpp_indent_within_parentheses = indent
|
||||||
|
cpp_indent_preserve_within_parentheses = false
|
||||||
|
cpp_indent_case_contents = true
|
||||||
|
cpp_indent_case_labels = false
|
||||||
|
cpp_indent_case_contents_when_block = true
|
||||||
|
cpp_indent_lambda_braces_when_parameter = true
|
||||||
|
cpp_indent_preprocessor = one_left
|
||||||
|
cpp_indent_access_specifiers = false
|
||||||
|
cpp_indent_namespace_contents = true
|
||||||
|
cpp_indent_preserve_comments = true
|
||||||
|
cpp_new_line_before_open_brace_namespace = new_line
|
||||||
|
cpp_new_line_before_open_brace_type = new_line
|
||||||
|
cpp_new_line_before_open_brace_function = new_line
|
||||||
|
cpp_new_line_before_open_brace_block = new_line
|
||||||
|
cpp_new_line_before_open_brace_lambda = new_line
|
||||||
|
cpp_new_line_scope_braces_on_separate_lines = true
|
||||||
|
cpp_new_line_close_brace_same_line_empty_type = true
|
||||||
|
cpp_new_line_close_brace_same_line_empty_function = true
|
||||||
|
cpp_new_line_before_catch = true
|
||||||
|
cpp_new_line_before_else = true
|
||||||
|
cpp_new_line_before_while_in_do_while = true
|
||||||
|
cpp_space_before_function_open_parenthesis = remove
|
||||||
|
cpp_space_within_parameter_list_parentheses = false
|
||||||
|
cpp_space_between_empty_parameter_list_parentheses = false
|
||||||
|
cpp_space_after_keywords_in_control_flow_statements = true
|
||||||
|
cpp_space_within_control_flow_statement_parentheses = false
|
||||||
|
cpp_space_before_lambda_open_parenthesis = false
|
||||||
|
cpp_space_within_cast_parentheses = false
|
||||||
|
cpp_space_after_cast_close_parenthesis = false
|
||||||
|
cpp_space_within_expression_parentheses = false
|
||||||
|
cpp_space_before_initializer_list_open_brace = false
|
||||||
|
cpp_space_within_initializer_list_braces = true
|
||||||
|
cpp_space_before_open_square_bracket = false
|
||||||
|
cpp_space_within_square_brackets = false
|
||||||
|
cpp_space_before_empty_square_brackets = false
|
||||||
|
cpp_space_between_empty_square_brackets = false
|
||||||
|
cpp_space_group_square_brackets = true
|
||||||
|
cpp_space_within_lambda_brackets = false
|
||||||
|
cpp_space_between_empty_lambda_brackets = false
|
||||||
|
cpp_space_before_comma = false
|
||||||
|
cpp_space_after_comma = true
|
||||||
|
cpp_space_remove_around_member_operators = true
|
||||||
|
cpp_space_before_inheritance_colon = true
|
||||||
|
cpp_space_before_constructor_colon = true
|
||||||
|
cpp_space_remove_before_semicolon = true
|
||||||
|
cpp_space_after_semicolon = false
|
||||||
|
cpp_space_remove_around_unary_operator = false
|
||||||
|
cpp_space_around_binary_operator = ignore
|
||||||
|
cpp_space_around_assignment_operator = insert
|
||||||
|
cpp_space_pointer_reference_alignment = ignore
|
||||||
|
cpp_space_around_ternary_operator = insert
|
||||||
|
cpp_wrap_preserve_blocks = one_liners
|
||||||
|
|
|
@ -193,55 +193,55 @@ namespace
|
||||||
const uint32_t tag = GetFormatTag(wfx);
|
const uint32_t tag = GetFormatTag(wfx);
|
||||||
switch (tag)
|
switch (tag)
|
||||||
{
|
{
|
||||||
case WAVE_FORMAT_PCM:
|
case WAVE_FORMAT_PCM:
|
||||||
static_assert(WAVE_FORMAT_PCM < 0x1ff, "KeyGen tag is too small");
|
static_assert(WAVE_FORMAT_PCM < 0x1ff, "KeyGen tag is too small");
|
||||||
result.pcm.tag = WAVE_FORMAT_PCM;
|
result.pcm.tag = WAVE_FORMAT_PCM;
|
||||||
result.pcm.channels = wfx->nChannels;
|
result.pcm.channels = wfx->nChannels;
|
||||||
result.pcm.bitsPerSample = wfx->wBitsPerSample;
|
result.pcm.bitsPerSample = wfx->wBitsPerSample;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAVE_FORMAT_IEEE_FLOAT:
|
case WAVE_FORMAT_IEEE_FLOAT:
|
||||||
static_assert(WAVE_FORMAT_IEEE_FLOAT < 0x1ff, "KeyGen tag is too small");
|
static_assert(WAVE_FORMAT_IEEE_FLOAT < 0x1ff, "KeyGen tag is too small");
|
||||||
|
|
||||||
if (wfx->wBitsPerSample != 32)
|
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<const ADPCMWAVEFORMAT*>(wfx);
|
||||||
|
result.adpcm.samplesPerBlock = wfadpcm->wSamplesPerBlock;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef DIRECTX_ENABLE_XMA2
|
||||||
|
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<const XMA2WAVEFORMATEX*>(wfx);
|
||||||
|
|
||||||
|
if ((xmaFmt->LoopBegin > 0)
|
||||||
|
|| (xmaFmt->PlayBegin > 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
result.pcm.tag = WAVE_FORMAT_IEEE_FLOAT;
|
result.xma.encoderVersion = xmaFmt->EncoderVersion;
|
||||||
result.pcm.channels = wfx->nChannels;
|
}
|
||||||
result.pcm.bitsPerSample = 32;
|
break;
|
||||||
break;
|
#endif
|
||||||
|
|
||||||
case WAVE_FORMAT_ADPCM:
|
default:
|
||||||
static_assert(WAVE_FORMAT_ADPCM < 0x1ff, "KeyGen tag is too small");
|
return 0;
|
||||||
result.adpcm.tag = WAVE_FORMAT_ADPCM;
|
|
||||||
result.adpcm.channels = wfx->nChannels;
|
|
||||||
|
|
||||||
{
|
|
||||||
auto wfadpcm = reinterpret_cast<const ADPCMWAVEFORMAT*>(wfx);
|
|
||||||
result.adpcm.samplesPerBlock = wfadpcm->wSamplesPerBlock;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XMA2
|
|
||||||
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<const XMA2WAVEFORMATEX*>(wfx);
|
|
||||||
|
|
||||||
if ((xmaFmt->LoopBegin > 0)
|
|
||||||
|| (xmaFmt->PlayBegin > 0))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
result.xma.encoderVersion = xmaFmt->EncoderVersion;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.key;
|
return result.key;
|
||||||
|
@ -257,6 +257,10 @@ static_assert(static_cast<unsigned int>(std::size(gReverbPresets)) == Reverb_MAX
|
||||||
|
|
||||||
#define SAFE_DESTROY_VOICE(voice) if ( voice ) { voice->DestroyVoice(); voice = nullptr; }
|
#define SAFE_DESTROY_VOICE(voice) if ( voice ) { voice->DestroyVoice(); voice = nullptr; }
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Internal object implementation class.
|
// Internal object implementation class.
|
||||||
class AudioEngine::Impl
|
class AudioEngine::Impl
|
||||||
{
|
{
|
||||||
|
@ -451,7 +455,7 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
|
||||||
hr = mMasterVoice->GetChannelMask(&dwChannelMask);
|
hr = mMasterVoice->GetChannelMask(&dwChannelMask);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
xaudio2.Reset();
|
xaudio2.Reset();
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +475,7 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
|
||||||
hr = mMasterVoice->SetVolume(mMasterVolume);
|
hr = mMasterVoice->SetVolume(mMasterVolume);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
xaudio2.Reset();
|
xaudio2.Reset();
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -489,7 +493,7 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
|
||||||
hr = CreateFX(__uuidof(FXMasteringLimiter), mVolumeLimiter.ReleaseAndGetAddressOf(), ¶ms, sizeof(params));
|
hr = CreateFX(__uuidof(FXMasteringLimiter), mVolumeLimiter.ReleaseAndGetAddressOf(), ¶ms, sizeof(params));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
xaudio2.Reset();
|
xaudio2.Reset();
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -503,7 +507,7 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
|
||||||
hr = mMasterVoice->SetEffectChain(&chain);
|
hr = mMasterVoice->SetEffectChain(&chain);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
mVolumeLimiter.Reset();
|
mVolumeLimiter.Reset();
|
||||||
xaudio2.Reset();
|
xaudio2.Reset();
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -520,7 +524,7 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
|
||||||
hr = XAudio2CreateReverb(mReverbEffect.ReleaseAndGetAddressOf(), 0u);
|
hr = XAudio2CreateReverb(mReverbEffect.ReleaseAndGetAddressOf(), 0u);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
mVolumeLimiter.Reset();
|
mVolumeLimiter.Reset();
|
||||||
xaudio2.Reset();
|
xaudio2.Reset();
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -536,7 +540,7 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
|
||||||
nullptr, &effectChain);
|
nullptr, &effectChain);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
mReverbEffect.Reset();
|
mReverbEffect.Reset();
|
||||||
mVolumeLimiter.Reset();
|
mVolumeLimiter.Reset();
|
||||||
xaudio2.Reset();
|
xaudio2.Reset();
|
||||||
|
@ -548,8 +552,8 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
|
||||||
hr = mReverbVoice->SetEffectParameters(0, &native, sizeof(XAUDIO2FX_REVERB_PARAMETERS));
|
hr = mReverbVoice->SetEffectParameters(0, &native, sizeof(XAUDIO2FX_REVERB_PARAMETERS));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
SAFE_DESTROY_VOICE(mReverbVoice)
|
SAFE_DESTROY_VOICE(mReverbVoice);
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
mReverbEffect.Reset();
|
mReverbEffect.Reset();
|
||||||
mVolumeLimiter.Reset();
|
mVolumeLimiter.Reset();
|
||||||
xaudio2.Reset();
|
xaudio2.Reset();
|
||||||
|
@ -567,8 +571,8 @@ HRESULT AudioEngine::Impl::Reset(const WAVEFORMATEX* wfx, const wchar_t* deviceI
|
||||||
hr = X3DAudioInitialize(masterChannelMask, SPEEDOFSOUND, mX3DAudio);
|
hr = X3DAudioInitialize(masterChannelMask, SPEEDOFSOUND, mX3DAudio);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
SAFE_DESTROY_VOICE(mReverbVoice)
|
SAFE_DESTROY_VOICE(mReverbVoice);
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
mReverbEffect.Reset();
|
mReverbEffect.Reset();
|
||||||
mVolumeLimiter.Reset();
|
mVolumeLimiter.Reset();
|
||||||
xaudio2.Reset();
|
xaudio2.Reset();
|
||||||
|
@ -612,8 +616,8 @@ void AudioEngine::Impl::SetSilentMode()
|
||||||
|
|
||||||
mVoiceInstances = 0;
|
mVoiceInstances = 0;
|
||||||
|
|
||||||
SAFE_DESTROY_VOICE(mReverbVoice)
|
SAFE_DESTROY_VOICE(mReverbVoice);
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
|
|
||||||
mReverbEffect.Reset();
|
mReverbEffect.Reset();
|
||||||
mVolumeLimiter.Reset();
|
mVolumeLimiter.Reset();
|
||||||
|
@ -651,8 +655,8 @@ void AudioEngine::Impl::Shutdown() noexcept
|
||||||
|
|
||||||
mVoiceInstances = 0;
|
mVoiceInstances = 0;
|
||||||
|
|
||||||
SAFE_DESTROY_VOICE(mReverbVoice)
|
SAFE_DESTROY_VOICE(mReverbVoice);
|
||||||
SAFE_DESTROY_VOICE(mMasterVoice)
|
SAFE_DESTROY_VOICE(mMasterVoice);
|
||||||
|
|
||||||
mReverbEffect.Reset();
|
mReverbEffect.Reset();
|
||||||
mVolumeLimiter.Reset();
|
mVolumeLimiter.Reset();
|
||||||
|
@ -676,54 +680,54 @@ bool AudioEngine::Impl::Update()
|
||||||
HANDLE events[2] = { mEngineCallback.mCriticalError.get(), mVoiceCallback.mBufferEnd.get() };
|
HANDLE events[2] = { mEngineCallback.mCriticalError.get(), mVoiceCallback.mBufferEnd.get() };
|
||||||
switch (WaitForMultipleObjectsEx(static_cast<DWORD>(std::size(events)), events, FALSE, 0, FALSE))
|
switch (WaitForMultipleObjectsEx(static_cast<DWORD>(std::size(events)), events, FALSE, 0, FALSE))
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case WAIT_TIMEOUT:
|
case WAIT_TIMEOUT:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAIT_OBJECT_0: // OnCritialError
|
case WAIT_OBJECT_0: // OnCritialError
|
||||||
mCriticalError = true;
|
mCriticalError = true;
|
||||||
|
|
||||||
SetSilentMode();
|
SetSilentMode();
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case WAIT_OBJECT_0 + 1: // OnBufferEnd
|
case WAIT_OBJECT_0 + 1: // OnBufferEnd
|
||||||
// Scan for completed one-shot voices
|
// Scan for completed one-shot voices
|
||||||
for (auto it = mOneShots.begin(); it != mOneShots.end(); )
|
for (auto it = mOneShots.begin(); it != mOneShots.end(); )
|
||||||
|
{
|
||||||
|
assert(it->second != nullptr);
|
||||||
|
|
||||||
|
XAUDIO2_VOICE_STATE xstate;
|
||||||
|
it->second->GetState(&xstate, XAUDIO2_VOICE_NOSAMPLESPLAYED);
|
||||||
|
|
||||||
|
if (!xstate.BuffersQueued)
|
||||||
{
|
{
|
||||||
assert(it->second != nullptr);
|
std::ignore = it->second->Stop(0);
|
||||||
|
if (it->first)
|
||||||
XAUDIO2_VOICE_STATE xstate;
|
|
||||||
it->second->GetState(&xstate, XAUDIO2_VOICE_NOSAMPLESPLAYED);
|
|
||||||
|
|
||||||
if (!xstate.BuffersQueued)
|
|
||||||
{
|
{
|
||||||
std::ignore = it->second->Stop(0);
|
// Put voice back into voice pool for reuse since it has a non-zero voiceKey
|
||||||
if (it->first)
|
#ifdef VERBOSE_TRACE
|
||||||
{
|
DebugTrace("INFO: One-shot voice being saved for reuse (%08X)\n", it->first);
|
||||||
// Put voice back into voice pool for reuse since it has a non-zero voiceKey
|
#endif
|
||||||
#ifdef VERBOSE_TRACE
|
voicepool_t::value_type v(it->first, it->second);
|
||||||
DebugTrace("INFO: One-shot voice being saved for reuse (%08X)\n", it->first);
|
mVoicePool.emplace(v);
|
||||||
#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
|
else
|
||||||
++it;
|
{
|
||||||
|
// 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);
|
||||||
}
|
}
|
||||||
break;
|
else
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WAIT_FAILED:
|
case WAIT_FAILED:
|
||||||
throw std::system_error(std::error_code(static_cast<int>(GetLastError()), std::system_category()), "WaitForMultipleObjectsEx");
|
throw std::system_error(std::error_code(static_cast<int>(GetLastError()), std::system_category()), "WaitForMultipleObjectsEx");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -850,8 +854,8 @@ void AudioEngine::Impl::AllocateVoice(
|
||||||
if (flags & (SoundEffectInstance_Use3D | SoundEffectInstance_ReverbUseFilters | SoundEffectInstance_NoSetPitch))
|
if (flags & (SoundEffectInstance_Use3D | SoundEffectInstance_ReverbUseFilters | SoundEffectInstance_NoSetPitch))
|
||||||
{
|
{
|
||||||
DebugTrace((flags & SoundEffectInstance_NoSetPitch)
|
DebugTrace((flags & SoundEffectInstance_NoSetPitch)
|
||||||
? "ERROR: One-shot voices must support pitch-shifting for voice reuse\n"
|
? "ERROR: One-shot voices must support pitch-shifting for voice reuse\n"
|
||||||
: "ERROR: One-use voices cannot use 3D positional audio\n");
|
: "ERROR: One-use voices cannot use 3D positional audio\n");
|
||||||
throw std::invalid_argument("Invalid flags for one-shot voice");
|
throw std::invalid_argument("Invalid flags for one-shot voice");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,7 +905,7 @@ void AudioEngine::Impl::AllocateVoice(
|
||||||
else if ((mVoicePool.size() + mOneShots.size() + 1) >= maxVoiceOneshots)
|
else if ((mVoicePool.size() + mOneShots.size() + 1) >= maxVoiceOneshots)
|
||||||
{
|
{
|
||||||
DebugTrace("WARNING: Too many one-shot voices in use (%zu + %zu >= %zu); one-shot not played\n",
|
DebugTrace("WARNING: Too many one-shot voices in use (%zu + %zu >= %zu); one-shot not played\n",
|
||||||
mVoicePool.size(), mOneShots.size() + 1, maxVoiceOneshots);
|
mVoicePool.size(), mOneShots.size() + 1, maxVoiceOneshots);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -914,26 +918,26 @@ void AudioEngine::Impl::AllocateVoice(
|
||||||
const uint32_t tag = GetFormatTag(wfx);
|
const uint32_t tag = GetFormatTag(wfx);
|
||||||
switch (tag)
|
switch (tag)
|
||||||
{
|
{
|
||||||
case WAVE_FORMAT_PCM:
|
case WAVE_FORMAT_PCM:
|
||||||
CreateIntegerPCM(wfmt, defaultRate, wfx->nChannels, wfx->wBitsPerSample);
|
CreateIntegerPCM(wfmt, defaultRate, wfx->nChannels, wfx->wBitsPerSample);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAVE_FORMAT_IEEE_FLOAT:
|
case WAVE_FORMAT_IEEE_FLOAT:
|
||||||
CreateFloatPCM(wfmt, defaultRate, wfx->nChannels);
|
CreateFloatPCM(wfmt, defaultRate, wfx->nChannels);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAVE_FORMAT_ADPCM:
|
case WAVE_FORMAT_ADPCM:
|
||||||
{
|
{
|
||||||
auto wfadpcm = reinterpret_cast<const ADPCMWAVEFORMAT*>(wfx);
|
auto wfadpcm = reinterpret_cast<const ADPCMWAVEFORMAT*>(wfx);
|
||||||
CreateADPCM(wfmt, sizeof(buff), defaultRate, wfx->nChannels, wfadpcm->wSamplesPerBlock);
|
CreateADPCM(wfmt, sizeof(buff), defaultRate, wfx->nChannels, wfadpcm->wSamplesPerBlock);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XMA2
|
#ifdef DIRECTX_ENABLE_XMA2
|
||||||
case WAVE_FORMAT_XMA2:
|
case WAVE_FORMAT_XMA2:
|
||||||
CreateXMA2(wfmt, sizeof(buff), defaultRate, wfx->nChannels, 65536, 2, 0);
|
CreateXMA2(wfmt, sizeof(buff), defaultRate, wfx->nChannels, 65536, 2, 0);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE_TRACE
|
#ifdef VERBOSE_TRACE
|
||||||
|
@ -969,7 +973,7 @@ void AudioEngine::Impl::AllocateVoice(
|
||||||
if ((mVoicePool.size() + mOneShots.size() + 1) >= maxVoiceOneshots)
|
if ((mVoicePool.size() + mOneShots.size() + 1) >= maxVoiceOneshots)
|
||||||
{
|
{
|
||||||
DebugTrace("WARNING: Too many one-shot voices in use (%zu + %zu >= %zu); one-shot not played; see TrimVoicePool\n",
|
DebugTrace("WARNING: Too many one-shot voices in use (%zu + %zu >= %zu); one-shot not played; see TrimVoicePool\n",
|
||||||
mVoicePool.size(), mOneShots.size() + 1, maxVoiceOneshots);
|
mVoicePool.size(), mOneShots.size() + 1, maxVoiceOneshots);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ class DynamicSoundEffectInstance::Impl : public IVoiceNotify
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(_In_ AudioEngine* engine,
|
Impl(_In_ AudioEngine* engine,
|
||||||
_In_ DynamicSoundEffectInstance* object,
|
_In_ DynamicSoundEffectInstance* object,
|
||||||
std::function<void(DynamicSoundEffectInstance*)>& bufferNeeded,
|
std::function<void(DynamicSoundEffectInstance*)>& bufferNeeded,
|
||||||
int sampleRate, int channels, int sampleBits,
|
int sampleRate, int channels, int sampleBits,
|
||||||
SOUND_EFFECT_INSTANCE_FLAGS flags) :
|
SOUND_EFFECT_INSTANCE_FLAGS flags) :
|
||||||
mBase(),
|
mBase(),
|
||||||
mBufferNeeded(nullptr),
|
mBufferNeeded(nullptr),
|
||||||
|
@ -46,13 +46,13 @@ public:
|
||||||
|
|
||||||
switch (sampleBits)
|
switch (sampleBits)
|
||||||
{
|
{
|
||||||
case 8:
|
case 8:
|
||||||
case 16:
|
case 16:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DebugTrace("DynamicSoundEffectInstance sampleBits must be 8-bit or 16-bit\n");
|
DebugTrace("DynamicSoundEffectInstance sampleBits must be 8-bit or 16-bit\n");
|
||||||
throw std::invalid_argument("DynamicSoundEffectInstance supports 8 or 16 bit");
|
throw std::invalid_argument("DynamicSoundEffectInstance supports 8 or 16 bit");
|
||||||
}
|
}
|
||||||
|
|
||||||
mBufferEvent.reset(CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE));
|
mBufferEvent.reset(CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE));
|
||||||
|
@ -214,19 +214,19 @@ void DynamicSoundEffectInstance::Impl::OnUpdate()
|
||||||
const DWORD result = WaitForSingleObjectEx(mBufferEvent.get(), 0, FALSE);
|
const DWORD result = WaitForSingleObjectEx(mBufferEvent.get(), 0, FALSE);
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case WAIT_TIMEOUT:
|
case WAIT_TIMEOUT:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
if (mBufferNeeded)
|
if (mBufferNeeded)
|
||||||
{
|
{
|
||||||
// This callback happens on the same thread that called AudioEngine::Update()
|
// This callback happens on the same thread that called AudioEngine::Update()
|
||||||
mBufferNeeded(mObject);
|
mBufferNeeded(mObject);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAIT_FAILED:
|
case WAIT_FAILED:
|
||||||
throw std::system_error(std::error_code(static_cast<int>(GetLastError()), std::system_category()), "WaitForSingleObjectEx");
|
throw std::system_error(std::error_code(static_cast<int>(GetLastError()), std::system_category()), "WaitForSingleObjectEx");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ size_t DynamicSoundEffectInstance::GetSampleDuration(size_t bytes) const noexcep
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return static_cast<size_t>((uint64_t(bytes) * 8)
|
return static_cast<size_t>((uint64_t(bytes) * 8)
|
||||||
/ (uint64_t(wfx->wBitsPerSample) * uint64_t(wfx->nChannels)));
|
/ (uint64_t(wfx->wBitsPerSample) * uint64_t(wfx->nChannels)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,279 @@ bool DirectX::IsValid(_In_ const WAVEFORMATEX* wfx) noexcept
|
||||||
|
|
||||||
switch (wfx->wFormatTag)
|
switch (wfx->wFormatTag)
|
||||||
{
|
{
|
||||||
case WAVE_FORMAT_PCM:
|
case WAVE_FORMAT_PCM:
|
||||||
|
|
||||||
switch (wfx->wBitsPerSample)
|
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<const ADPCMWAVEFORMAT*>(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int nHeaderBytes = 7 /*MSADPCM_HEADER_LENGTH*/ * wfx->nChannels;
|
||||||
|
const int nBitsPerFrame = 4 /*MSADPCM_BITS_PER_SAMPLE*/ * wfx->nChannels;
|
||||||
|
const 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 = %d (%u)\n",
|
||||||
|
wfx->nChannels, wfx->nBlockAlign, nPcmFramesPerBlock, wfadpcm->wSamplesPerBlock);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case WAVE_FORMAT_WMAUDIO2:
|
||||||
|
case WAVE_FORMAT_WMAUDIO3:
|
||||||
|
|
||||||
|
#ifdef DIRECTX_ENABLE_XWMA
|
||||||
|
|
||||||
|
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 */:
|
||||||
|
|
||||||
|
#ifdef DIRECTX_ENABLE_XMA2
|
||||||
|
|
||||||
|
static_assert(WAVE_FORMAT_XMA2 == 0x166, "Unrecognized XMA2 tag");
|
||||||
|
|
||||||
|
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 %zu (%u)\n", (sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX)), wfx->cbSize);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto xmaFmt = reinterpret_cast<const XMA2WAVEFORMATEX*>(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 %zu (%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<const WAVEFORMATEXTENSIBLE*>(wfx);
|
||||||
|
|
||||||
|
if (memcmp(reinterpret_cast<const BYTE*>(&wfex->SubFormat) + sizeof(DWORD),
|
||||||
|
reinterpret_cast<const BYTE*>(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD)) != 0)
|
||||||
|
{
|
||||||
|
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 8:
|
||||||
case 16:
|
case 16:
|
||||||
case 24:
|
case 24:
|
||||||
|
@ -73,416 +342,147 @@ bool DirectX::IsValid(_In_ const WAVEFORMATEX* wfx) noexcept
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DebugTrace("ERROR: Wave format integer PCM must have 8, 16, 24, or 32 bits per sample (%u)\n", wfx->wBitsPerSample);
|
DebugTrace("ERROR: Wave format integer PCM must have 8, 16, 24, or 32 bits per sample (%u)\n",
|
||||||
|
wfx->wBitsPerSample);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wfx->nBlockAlign != (wfx->nChannels * wfx->wBitsPerSample / 8))
|
switch (wfex->Samples.wValidBitsPerSample)
|
||||||
{
|
{
|
||||||
DebugTrace("ERROR: Wave format integer PCM - nBlockAlign (%u) != nChannels (%u) * wBitsPerSample (%u) / 8\n",
|
case 0:
|
||||||
wfx->nBlockAlign, wfx->nChannels, wfx->wBitsPerSample);
|
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:
|
||||||
|
|
||||||
|
#ifdef DIRECTX_ENABLE_XWMA
|
||||||
|
|
||||||
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wfx->nAvgBytesPerSec != (wfx->nSamplesPerSec * wfx->nBlockAlign))
|
if (wfex->dwChannelMask)
|
||||||
{
|
{
|
||||||
DebugTrace("ERROR: Wave format integer PCM - nAvgBytesPerSec (%lu) != nSamplesPerSec (%lu) * nBlockAlign (%u)\n",
|
auto const channelBits = ChannelsSpecifiedInMask(wfex->dwChannelMask);
|
||||||
wfx->nAvgBytesPerSec, wfx->nSamplesPerSec, wfx->nBlockAlign);
|
if (channelBits != wfx->nChannels)
|
||||||
return false;
|
{
|
||||||
|
DebugTrace("ERROR: WAVEFORMATEXTENSIBLE: nChannels=%u but ChannelMask has %u bits set\n",
|
||||||
|
wfx->nChannels, channelBits);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case WAVE_FORMAT_IEEE_FLOAT:
|
default:
|
||||||
|
DebugTrace("ERROR: Unknown WAVEFORMATEX format tag (%u)\n", wfx->wFormatTag);
|
||||||
if (wfx->wBitsPerSample != 32)
|
return false;
|
||||||
{
|
|
||||||
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<const ADPCMWAVEFORMAT*>(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int nHeaderBytes = 7 /*MSADPCM_HEADER_LENGTH*/ * wfx->nChannels;
|
|
||||||
const int nBitsPerFrame = 4 /*MSADPCM_BITS_PER_SAMPLE*/ * wfx->nChannels;
|
|
||||||
const 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 = %d (%u)\n",
|
|
||||||
wfx->nChannels, wfx->nBlockAlign, nPcmFramesPerBlock, wfadpcm->wSamplesPerBlock);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case WAVE_FORMAT_WMAUDIO2:
|
|
||||||
case WAVE_FORMAT_WMAUDIO3:
|
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XWMA
|
|
||||||
|
|
||||||
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 */:
|
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XMA2
|
|
||||||
|
|
||||||
static_assert(WAVE_FORMAT_XMA2 == 0x166, "Unrecognized XMA2 tag");
|
|
||||||
|
|
||||||
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 %zu (%u)\n", (sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX)), wfx->cbSize);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto xmaFmt = reinterpret_cast<const XMA2WAVEFORMATEX*>(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 %zu (%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<const WAVEFORMATEXTENSIBLE*>(wfx);
|
|
||||||
|
|
||||||
if (memcmp(reinterpret_cast<const BYTE*>(&wfex->SubFormat) + sizeof(DWORD),
|
|
||||||
reinterpret_cast<const BYTE*>(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD)) != 0)
|
|
||||||
{
|
|
||||||
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:
|
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XWMA
|
|
||||||
|
|
||||||
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 const 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,15 +491,15 @@ uint32_t DirectX::GetDefaultChannelMask(int channels) noexcept
|
||||||
{
|
{
|
||||||
switch (channels)
|
switch (channels)
|
||||||
{
|
{
|
||||||
case 1: return SPEAKER_MONO;
|
case 1: return SPEAKER_MONO;
|
||||||
case 2: return SPEAKER_STEREO;
|
case 2: return SPEAKER_STEREO;
|
||||||
case 3: return SPEAKER_2POINT1;
|
case 3: return SPEAKER_2POINT1;
|
||||||
case 4: return SPEAKER_QUAD;
|
case 4: return SPEAKER_QUAD;
|
||||||
case 5: return SPEAKER_4POINT1;
|
case 5: return SPEAKER_4POINT1;
|
||||||
case 6: return SPEAKER_5POINT1;
|
case 6: return SPEAKER_5POINT1;
|
||||||
case 7: return SPEAKER_5POINT1 | SPEAKER_BACK_CENTER;
|
case 7: return SPEAKER_5POINT1 | SPEAKER_BACK_CENTER;
|
||||||
case 8: return SPEAKER_7POINT1;
|
case 8: return SPEAKER_7POINT1;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,9 +100,9 @@ public:
|
||||||
_Inout_ std::unique_ptr<uint8_t[]>& wavData,
|
_Inout_ std::unique_ptr<uint8_t[]>& wavData,
|
||||||
_In_ const WAVEFORMATEX* wfx,
|
_In_ const WAVEFORMATEX* wfx,
|
||||||
_In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
|
_In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
|
||||||
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
||||||
_In_reads_opt_(seekCount) const uint32_t* seekTable, size_t seekCount,
|
_In_reads_opt_(seekCount) const uint32_t* seekTable, size_t seekCount,
|
||||||
#endif
|
#endif
|
||||||
uint32_t loopStart, uint32_t loopLength) noexcept;
|
uint32_t loopStart, uint32_t loopLength) noexcept;
|
||||||
|
|
||||||
void Play(float volume, float pitch, float pan);
|
void Play(float volume, float pitch, float pan);
|
||||||
|
@ -208,7 +208,7 @@ HRESULT SoundEffect::Impl::Initialize(
|
||||||
mStartAudio = startAudio;
|
mStartAudio = startAudio;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XWMA
|
#ifdef DIRECTX_ENABLE_XWMA
|
||||||
|
|
||||||
case WAVE_FORMAT_WMAUDIO2:
|
case WAVE_FORMAT_WMAUDIO2:
|
||||||
case WAVE_FORMAT_WMAUDIO3:
|
case WAVE_FORMAT_WMAUDIO3:
|
||||||
|
@ -231,9 +231,9 @@ HRESULT SoundEffect::Impl::Initialize(
|
||||||
mSeekTable = seekTable;
|
mSeekTable = seekTable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endif // xWMA
|
#endif // xWMA
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XMA2
|
#ifdef DIRECTX_ENABLE_XMA2
|
||||||
|
|
||||||
case WAVE_FORMAT_XMA2:
|
case WAVE_FORMAT_XMA2:
|
||||||
if (!seekCount || !seekTable)
|
if (!seekCount || !seekTable)
|
||||||
|
@ -280,13 +280,13 @@ HRESULT SoundEffect::Impl::Initialize(
|
||||||
wavData.reset();
|
wavData.reset();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endif // XMA2
|
#endif // XMA2
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
DebugTrace("ERROR: SoundEffect encountered an unsupported format tag (%u)\n", wfx->wFormatTag);
|
DebugTrace("ERROR: SoundEffect encountered an unsupported format tag (%u)\n", wfx->wFormatTag);
|
||||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mAudioBytes = static_cast<uint32_t>(audioBytes);
|
mAudioBytes = static_cast<uint32_t>(audioBytes);
|
||||||
|
@ -342,7 +342,7 @@ void SoundEffect::Impl::Play(float volume, float pitch, float pan)
|
||||||
buffer.Flags = XAUDIO2_END_OF_STREAM;
|
buffer.Flags = XAUDIO2_END_OF_STREAM;
|
||||||
buffer.pContext = this;
|
buffer.pContext = this;
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XWMA
|
#ifdef DIRECTX_ENABLE_XWMA
|
||||||
const uint32_t tag = GetFormatTag(mWaveFormat);
|
const uint32_t tag = GetFormatTag(mWaveFormat);
|
||||||
if (tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3)
|
if (tag == WAVE_FORMAT_WMAUDIO2 || tag == WAVE_FORMAT_WMAUDIO3)
|
||||||
{
|
{
|
||||||
|
@ -390,11 +390,11 @@ SoundEffect::SoundEffect(AudioEngine* engine, const wchar_t* waveFileName)
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
||||||
hr = pImpl->Initialize(engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
|
hr = pImpl->Initialize(engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
|
||||||
wavInfo.seek, wavInfo.seekCount,
|
wavInfo.seek, wavInfo.seekCount,
|
||||||
wavInfo.loopStart, wavInfo.loopLength);
|
wavInfo.loopStart, wavInfo.loopLength);
|
||||||
#else
|
#else
|
||||||
hr = pImpl->Initialize(engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
|
hr = pImpl->Initialize(engine, wavData, wavInfo.wfx, wavInfo.startAudio, wavInfo.audioBytes,
|
||||||
wavInfo.loopStart, wavInfo.loopLength);
|
wavInfo.loopStart, wavInfo.loopLength);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
|
@ -408,7 +408,7 @@ SoundEffect::SoundEffect(AudioEngine* engine, const wchar_t* waveFileName)
|
||||||
|
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
|
SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
|
||||||
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes)
|
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes)
|
||||||
: pImpl(std::make_unique<Impl>(engine))
|
: pImpl(std::make_unique<Impl>(engine))
|
||||||
{
|
{
|
||||||
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
||||||
|
@ -426,8 +426,8 @@ SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavDat
|
||||||
|
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
|
SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
|
||||||
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
|
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
|
||||||
uint32_t loopStart, uint32_t loopLength)
|
uint32_t loopStart, uint32_t loopLength)
|
||||||
: pImpl(std::make_unique<Impl>(engine))
|
: pImpl(std::make_unique<Impl>(engine))
|
||||||
{
|
{
|
||||||
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
||||||
|
@ -447,8 +447,8 @@ SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavDat
|
||||||
|
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
|
SoundEffect::SoundEffect(AudioEngine* engine, std::unique_ptr<uint8_t[]>& wavData,
|
||||||
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
|
const WAVEFORMATEX* wfx, const uint8_t* startAudio, size_t audioBytes,
|
||||||
const uint32_t* seekTable, size_t seekCount)
|
const uint32_t* seekTable, size_t seekCount)
|
||||||
{
|
{
|
||||||
HRESULT hr = pImpl->Initialize(engine, wavData, wfx, startAudio, audioBytes, seekTable, seekCount, 0, 0);
|
HRESULT hr = pImpl->Initialize(engine, wavData, wfx, startAudio, audioBytes, seekTable, seekCount, 0, 0);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
|
@ -518,7 +518,7 @@ size_t SoundEffect::GetSampleDuration() const noexcept
|
||||||
|
|
||||||
switch (GetFormatTag(pImpl->mWaveFormat))
|
switch (GetFormatTag(pImpl->mWaveFormat))
|
||||||
{
|
{
|
||||||
case WAVE_FORMAT_ADPCM:
|
case WAVE_FORMAT_ADPCM:
|
||||||
{
|
{
|
||||||
auto adpcmFmt = reinterpret_cast<const ADPCMWAVEFORMAT*>(pImpl->mWaveFormat);
|
auto adpcmFmt = reinterpret_cast<const ADPCMWAVEFORMAT*>(pImpl->mWaveFormat);
|
||||||
|
|
||||||
|
@ -532,31 +532,31 @@ size_t SoundEffect::GetSampleDuration() const noexcept
|
||||||
return static_cast<size_t>(duration);
|
return static_cast<size_t>(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XWMA
|
#ifdef DIRECTX_ENABLE_XWMA
|
||||||
|
|
||||||
case WAVE_FORMAT_WMAUDIO2:
|
case WAVE_FORMAT_WMAUDIO2:
|
||||||
case WAVE_FORMAT_WMAUDIO3:
|
case WAVE_FORMAT_WMAUDIO3:
|
||||||
if (pImpl->mSeekTable && pImpl->mSeekCount > 0)
|
if (pImpl->mSeekTable && pImpl->mSeekCount > 0)
|
||||||
{
|
{
|
||||||
return pImpl->mSeekTable[pImpl->mSeekCount - 1] / uint32_t(2 * pImpl->mWaveFormat->nChannels);
|
return pImpl->mSeekTable[pImpl->mSeekCount - 1] / uint32_t(2 * pImpl->mWaveFormat->nChannels);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XMA2
|
#ifdef DIRECTX_ENABLE_XMA2
|
||||||
|
|
||||||
case WAVE_FORMAT_XMA2:
|
case WAVE_FORMAT_XMA2:
|
||||||
return reinterpret_cast<const XMA2WAVEFORMATEX*>(pImpl->mWaveFormat)->SamplesEncoded;
|
return reinterpret_cast<const XMA2WAVEFORMATEX*>(pImpl->mWaveFormat)->SamplesEncoded;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (pImpl->mWaveFormat->wBitsPerSample > 0)
|
if (pImpl->mWaveFormat->wBitsPerSample > 0)
|
||||||
{
|
{
|
||||||
return static_cast<size_t>((uint64_t(pImpl->mAudioBytes) * 8)
|
return static_cast<size_t>((uint64_t(pImpl->mAudioBytes) * 8)
|
||||||
/ (uint64_t(pImpl->mWaveFormat->wBitsPerSample) * uint64_t(pImpl->mWaveFormat->nChannels)));
|
/ (uint64_t(pImpl->mWaveFormat->wBitsPerSample) * uint64_t(pImpl->mWaveFormat->nChannels)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -189,7 +189,7 @@ void SoundEffectInstance::Impl::Play(bool loop)
|
||||||
buffer.pContext = nullptr;
|
buffer.pContext = nullptr;
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
#ifdef DIRECTX_ENABLE_XWMA
|
#ifdef DIRECTX_ENABLE_XWMA
|
||||||
if (iswma)
|
if (iswma)
|
||||||
{
|
{
|
||||||
hr = mBase.voice->SubmitSourceBuffer(&buffer, &wmaBuffer);
|
hr = mBase.voice->SubmitSourceBuffer(&buffer, &wmaBuffer);
|
||||||
|
|
|
@ -43,15 +43,15 @@ namespace
|
||||||
constexpr size_t ADVANCED_FORMAT_SECTOR_SIZE = 4096;
|
constexpr size_t ADVANCED_FORMAT_SECTOR_SIZE = 4096;
|
||||||
constexpr size_t MAX_BUFFER_COUNT = 3;
|
constexpr size_t MAX_BUFFER_COUNT = 3;
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
||||||
constexpr size_t MAX_STREAMING_SEEK_PACKETS = 2048;
|
constexpr size_t MAX_STREAMING_SEEK_PACKETS = 2048;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XMA2
|
#ifdef DIRECTX_ENABLE_XMA2
|
||||||
constexpr size_t XMA2_64KBLOCKINBYTES = 65536;
|
constexpr size_t XMA2_64KBLOCKINBYTES = 65536;
|
||||||
|
|
||||||
struct apu_deleter { void operator()(void* p) noexcept { if (p) ApuFree(p); } };
|
struct apu_deleter { void operator()(void* p) noexcept { if (p) ApuFree(p); } };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t ComputeAsyncPacketSize(_In_ const WAVEFORMATEX* wfx, uint32_t tag, uint32_t alignment)
|
size_t ComputeAsyncPacketSize(_In_ const WAVEFORMATEX* wfx, uint32_t tag, uint32_t alignment)
|
||||||
{
|
{
|
||||||
|
@ -129,7 +129,7 @@ public:
|
||||||
mLengthInBytes = metadata.lengthBytes;
|
mLengthInBytes = metadata.lengthBytes;
|
||||||
mAsyncAlign = mWaveBank->IsAdvancedFormat() ? ADVANCED_FORMAT_SECTOR_SIZE : DVD_SECTOR_SIZE;
|
mAsyncAlign = mWaveBank->IsAdvancedFormat() ? ADVANCED_FORMAT_SECTOR_SIZE : DVD_SECTOR_SIZE;
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
#ifdef DIRECTX_ENABLE_SEEK_TABLES
|
||||||
WaveBankSeekData seekData = {};
|
WaveBankSeekData seekData = {};
|
||||||
std::ignore = mWaveBank->GetPrivateData(index, &seekData, sizeof(seekData));
|
std::ignore = mWaveBank->GetPrivateData(index, &seekData, sizeof(seekData));
|
||||||
if (seekData.tag == WAVE_FORMAT_WMAUDIO2 || seekData.tag == WAVE_FORMAT_WMAUDIO3)
|
if (seekData.tag == WAVE_FORMAT_WMAUDIO2 || seekData.tag == WAVE_FORMAT_WMAUDIO3)
|
||||||
|
@ -137,7 +137,7 @@ public:
|
||||||
mSeekCount = seekData.seekCount;
|
mSeekCount = seekData.seekCount;
|
||||||
mSeekTable = seekData.seekTable;
|
mSeekTable = seekData.seekTable;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mBufferEnd.reset(CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE));
|
mBufferEnd.reset(CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE));
|
||||||
mBufferRead.reset(CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE));
|
mBufferRead.reset(CreateEventEx(nullptr, nullptr, 0, EVENT_MODIFY_STATE | SYNCHRONIZE));
|
||||||
|
@ -148,9 +148,9 @@ public:
|
||||||
|
|
||||||
ThrowIfFailed(AllocateStreamingBuffers(wfx));
|
ThrowIfFailed(AllocateStreamingBuffers(wfx));
|
||||||
|
|
||||||
#ifdef VERBOSE_TRACE
|
#ifdef VERBOSE_TRACE
|
||||||
DebugTrace("INFO (Streaming): packet size %zu, play length %zu\n", mPacketSize, mLengthInBytes);
|
DebugTrace("INFO (Streaming): packet size %zu, play length %zu\n", mPacketSize, mLengthInBytes);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mPrefetch = true;
|
mPrefetch = true;
|
||||||
ThrowIfFailed(ReadBuffers());
|
ThrowIfFailed(ReadBuffers());
|
||||||
|
@ -241,27 +241,27 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAIT_OBJECT_0: // Read completed
|
case WAIT_OBJECT_0: // Read completed
|
||||||
#ifdef VERBOSE_TRACE
|
#ifdef VERBOSE_TRACE
|
||||||
DebugTrace("INFO (Streaming): Playing... (readpos %zu) [", mCurrentPosition);
|
DebugTrace("INFO (Streaming): Playing... (readpos %zu) [", mCurrentPosition);
|
||||||
for (uint32_t k = 0; k < MAX_BUFFER_COUNT; ++k)
|
for (uint32_t k = 0; k < MAX_BUFFER_COUNT; ++k)
|
||||||
{
|
{
|
||||||
DebugTrace("%ls ", s_debugState[static_cast<int>(mPackets[k].state)]);
|
DebugTrace("%ls ", s_debugState[static_cast<int>(mPackets[k].state)]);
|
||||||
}
|
}
|
||||||
DebugTrace("]\n");
|
DebugTrace("]\n");
|
||||||
#endif
|
#endif
|
||||||
mPrefetch = false;
|
mPrefetch = false;
|
||||||
ThrowIfFailed(PlayBuffers());
|
ThrowIfFailed(PlayBuffers());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (WAIT_OBJECT_0 + 1): // Play completed
|
case (WAIT_OBJECT_0 + 1): // Play completed
|
||||||
#ifdef VERBOSE_TRACE
|
#ifdef VERBOSE_TRACE
|
||||||
DebugTrace("INFO (Streaming): Reading... (readpos %zu) [", mCurrentPosition);
|
DebugTrace("INFO (Streaming): Reading... (readpos %zu) [", mCurrentPosition);
|
||||||
for (uint32_t k = 0; k < MAX_BUFFER_COUNT; ++k)
|
for (uint32_t k = 0; k < MAX_BUFFER_COUNT; ++k)
|
||||||
{
|
{
|
||||||
DebugTrace("%ls ", s_debugState[static_cast<int>(mPackets[k].state)]);
|
DebugTrace("%ls ", s_debugState[static_cast<int>(mPackets[k].state)]);
|
||||||
}
|
}
|
||||||
DebugTrace("]\n");
|
DebugTrace("]\n");
|
||||||
#endif
|
#endif
|
||||||
ThrowIfFailed(ReadBuffers());
|
ThrowIfFailed(ReadBuffers());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ HRESULT SoundStreamInstance::Impl::AllocateStreamingBuffers(const WAVEFORMATEX*
|
||||||
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XMA2
|
#ifdef DIRECTX_ENABLE_XMA2
|
||||||
if ((mTotalSize < totalSize) || (tag == WAVE_FORMAT_XMA2 && !mXMAMemory) || (tag != WAVE_FORMAT_XMA2 && !mStreamBuffer))
|
if ((mTotalSize < totalSize) || (tag == WAVE_FORMAT_XMA2 && !mXMAMemory) || (tag != WAVE_FORMAT_XMA2 && !mStreamBuffer))
|
||||||
#else
|
#else
|
||||||
if (mTotalSize < totalSize)
|
if (mTotalSize < totalSize)
|
||||||
|
@ -447,7 +447,7 @@ HRESULT SoundStreamInstance::Impl::AllocateStreamingBuffers(const WAVEFORMATEX*
|
||||||
mXMAMemory.reset(static_cast<uint8_t*>(xmaMemory));
|
mXMAMemory.reset(static_cast<uint8_t*>(xmaMemory));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
mStreamBuffer.reset(reinterpret_cast<uint8_t*>(
|
mStreamBuffer.reset(reinterpret_cast<uint8_t*>(
|
||||||
VirtualAlloc(nullptr, static_cast<SIZE_T>(totalSize), MEM_COMMIT, PAGE_READWRITE)
|
VirtualAlloc(nullptr, static_cast<SIZE_T>(totalSize), MEM_COMMIT, PAGE_READWRITE)
|
||||||
|
@ -502,9 +502,9 @@ HRESULT SoundStreamInstance::Impl::ReadBuffers() noexcept
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE_TRACE
|
#ifdef VERBOSE_TRACE
|
||||||
DebugTrace("INFO (Streaming): Loop restart\n");
|
DebugTrace("INFO (Streaming): Loop restart\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mCurrentPosition = 0;
|
mCurrentPosition = 0;
|
||||||
}
|
}
|
||||||
|
@ -531,13 +531,13 @@ HRESULT SoundStreamInstance::Impl::ReadBuffers() noexcept
|
||||||
const DWORD error = GetLastError();
|
const DWORD error = GetLastError();
|
||||||
if (error != ERROR_IO_PENDING)
|
if (error != ERROR_IO_PENDING)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (error == ERROR_INVALID_PARAMETER)
|
if (error == ERROR_INVALID_PARAMETER)
|
||||||
{
|
{
|
||||||
// May be due to Advanced Format (4Kn) vs. DVD sector size. See the xwbtool -af switch.
|
// May be due to Advanced Format (4Kn) vs. DVD sector size. See the xwbtool -af switch.
|
||||||
OutputDebugStringA("ERROR: non-buffered async I/O failed: check disk sector size vs. streaming wave bank alignment!\n");
|
OutputDebugStringA("ERROR: non-buffered async I/O failed: check disk sector size vs. streaming wave bank alignment!\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return HRESULT_FROM_WIN32(error);
|
return HRESULT_FROM_WIN32(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -550,9 +550,9 @@ HRESULT SoundStreamInstance::Impl::ReadBuffers() noexcept
|
||||||
|
|
||||||
if ((cbValid < mPacketSize) && mLooped)
|
if ((cbValid < mPacketSize) && mLooped)
|
||||||
{
|
{
|
||||||
#ifdef VERBOSE_TRACE
|
#ifdef VERBOSE_TRACE
|
||||||
DebugTrace("INFO (Streaming): Loop restart\n");
|
DebugTrace("INFO (Streaming): Loop restart\n");
|
||||||
#endif
|
#endif
|
||||||
mCurrentPosition = 0;
|
mCurrentPosition = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,11 +572,11 @@ HRESULT SoundStreamInstance::Impl::PlayBuffers() noexcept
|
||||||
if (mPackets[j].state == State::PENDING)
|
if (mPackets[j].state == State::PENDING)
|
||||||
{
|
{
|
||||||
DWORD cb = 0;
|
DWORD cb = 0;
|
||||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||||
const BOOL result = GetOverlappedResultEx(async, &mPackets[j].request, &cb, 0, FALSE);
|
const BOOL result = GetOverlappedResultEx(async, &mPackets[j].request, &cb, 0, FALSE);
|
||||||
#else
|
#else
|
||||||
const BOOL result = GetOverlappedResult(async, &mPackets[j].request, &cb, FALSE);
|
const BOOL result = GetOverlappedResult(async, &mPackets[j].request, &cb, FALSE);
|
||||||
#endif
|
#endif
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
mPackets[j].state = State::READY;
|
mPackets[j].state = State::READY;
|
||||||
|
@ -607,9 +607,9 @@ HRESULT SoundStreamInstance::Impl::PlayBuffers() noexcept
|
||||||
if (valid < mPacketSize)
|
if (valid < mPacketSize)
|
||||||
{
|
{
|
||||||
endstream = true;
|
endstream = true;
|
||||||
#ifdef VERBOSE_TRACE
|
#ifdef VERBOSE_TRACE
|
||||||
DebugTrace("INFO (Streaming): End of stream (%u of %zu bytes)\n", mPackets[mCurrentPlayBuffer].valid, mPacketSize);
|
DebugTrace("INFO (Streaming): End of stream (%u of %zu bytes)\n", mPackets[mCurrentPlayBuffer].valid, mPacketSize);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t thisFrameStitch = 0;
|
uint32_t thisFrameStitch = 0;
|
||||||
|
@ -649,10 +649,10 @@ HRESULT SoundStreamInstance::Impl::PlayBuffers() noexcept
|
||||||
buf.Flags = XAUDIO2_END_OF_STREAM;
|
buf.Flags = XAUDIO2_END_OF_STREAM;
|
||||||
buf.pContext = &mPackets[mCurrentPlayBuffer].notify;
|
buf.pContext = &mPackets[mCurrentPlayBuffer].notify;
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE_TRACE
|
#ifdef VERBOSE_TRACE
|
||||||
DebugTrace("INFO (Streaming): Stitch packet (%u + %u = %u)\n", prevFrameStitch, thisFrameStitch, mBlockAlign);
|
DebugTrace("INFO (Streaming): Stitch packet (%u + %u = %u)\n", prevFrameStitch, thisFrameStitch, mBlockAlign);
|
||||||
#endif
|
#endif
|
||||||
#ifdef DIRECTX_ENABLE_XWMA
|
#ifdef DIRECTX_ENABLE_XWMA
|
||||||
if (mSeekCount > 0)
|
if (mSeekCount > 0)
|
||||||
{
|
{
|
||||||
XAUDIO2_BUFFER_WMA wmaBuf = {};
|
XAUDIO2_BUFFER_WMA wmaBuf = {};
|
||||||
|
@ -690,7 +690,7 @@ HRESULT SoundStreamInstance::Impl::PlayBuffers() noexcept
|
||||||
buf.pAudioData = ptr;
|
buf.pAudioData = ptr;
|
||||||
buf.pContext = &mPackets[mCurrentPlayBuffer].notify;
|
buf.pContext = &mPackets[mCurrentPlayBuffer].notify;
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XWMA
|
#ifdef DIRECTX_ENABLE_XWMA
|
||||||
if (mSeekCount > 0)
|
if (mSeekCount > 0)
|
||||||
{
|
{
|
||||||
XAUDIO2_BUFFER_WMA wmaBuf = {};
|
XAUDIO2_BUFFER_WMA wmaBuf = {};
|
||||||
|
|
|
@ -190,13 +190,13 @@ namespace
|
||||||
// Validate WAVEFORMAT (focused on chunk size and format tag, not other data that XAUDIO2 will validate)
|
// Validate WAVEFORMAT (focused on chunk size and format tag, not other data that XAUDIO2 will validate)
|
||||||
switch (wf->wFormatTag)
|
switch (wf->wFormatTag)
|
||||||
{
|
{
|
||||||
case WAVE_FORMAT_PCM:
|
case WAVE_FORMAT_PCM:
|
||||||
case WAVE_FORMAT_IEEE_FLOAT:
|
case WAVE_FORMAT_IEEE_FLOAT:
|
||||||
// Can be a PCMWAVEFORMAT (16 bytes) or WAVEFORMATEX (18 bytes)
|
// Can be a PCMWAVEFORMAT (16 bytes) or WAVEFORMATEX (18 bytes)
|
||||||
// We validiated chunk as at least sizeof(PCMWAVEFORMAT) above
|
// We validiated chunk as at least sizeof(PCMWAVEFORMAT) above
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (fmtChunk->size < sizeof(WAVEFORMATEX))
|
if (fmtChunk->size < sizeof(WAVEFORMATEX))
|
||||||
{
|
{
|
||||||
|
@ -212,65 +212,65 @@ namespace
|
||||||
|
|
||||||
switch (wfx->wFormatTag)
|
switch (wfx->wFormatTag)
|
||||||
{
|
{
|
||||||
case WAVE_FORMAT_WMAUDIO2:
|
case WAVE_FORMAT_WMAUDIO2:
|
||||||
case WAVE_FORMAT_WMAUDIO3:
|
case WAVE_FORMAT_WMAUDIO3:
|
||||||
dpds = true;
|
dpds = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x166 /*WAVE_FORMAT_XMA2*/: // XMA2 is supported by Xbox One
|
case 0x166 /*WAVE_FORMAT_XMA2*/: // XMA2 is supported by Xbox One
|
||||||
if ((fmtChunk->size < 52 /*sizeof(XMA2WAVEFORMATEX)*/) || (wfx->cbSize < 34 /*( sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX) )*/))
|
if ((fmtChunk->size < 52 /*sizeof(XMA2WAVEFORMATEX)*/) || (wfx->cbSize < 34 /*( sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX) )*/))
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
seek = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAVE_FORMAT_ADPCM:
|
||||||
|
if ((fmtChunk->size < (sizeof(WAVEFORMATEX) + 32)) || (wfx->cbSize < 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/))
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAVE_FORMAT_EXTENSIBLE:
|
||||||
|
if ((fmtChunk->size < sizeof(WAVEFORMATEXTENSIBLE)) || (wfx->cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))))
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
static const GUID s_wfexBase = { 0x00000000, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 } };
|
||||||
|
|
||||||
|
auto wfex = reinterpret_cast<const WAVEFORMATEXTENSIBLE*>(ptr);
|
||||||
|
|
||||||
|
if (memcmp(reinterpret_cast<const BYTE*>(&wfex->SubFormat) + sizeof(DWORD),
|
||||||
|
reinterpret_cast<const BYTE*>(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD)) != 0)
|
||||||
{
|
{
|
||||||
return E_FAIL;
|
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
seek = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WAVE_FORMAT_ADPCM:
|
switch (wfex->SubFormat.Data1)
|
||||||
if ((fmtChunk->size < (sizeof(WAVEFORMATEX) + 32)) || (wfx->cbSize < 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/))
|
|
||||||
{
|
{
|
||||||
return E_FAIL;
|
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;
|
|
||||||
|
|
||||||
case WAVE_FORMAT_EXTENSIBLE:
|
}
|
||||||
if ((fmtChunk->size < sizeof(WAVEFORMATEXTENSIBLE)) || (wfx->cbSize < (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))))
|
break;
|
||||||
{
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static const GUID s_wfexBase = { 0x00000000, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 } };
|
|
||||||
|
|
||||||
auto wfex = reinterpret_cast<const WAVEFORMATEXTENSIBLE*>(ptr);
|
default:
|
||||||
|
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||||
if (memcmp(reinterpret_cast<const BYTE*>(&wfex->SubFormat) + sizeof(DWORD),
|
|
||||||
reinterpret_cast<const BYTE*>(&s_wfexBase) + sizeof(DWORD), sizeof(GUID) - sizeof(DWORD)) != 0)
|
|
||||||
{
|
|
||||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (wfex->SubFormat.Data1)
|
|
||||||
{
|
|
||||||
case WAVE_FORMAT_PCM:
|
|
||||||
case WAVE_FORMAT_IEEE_FLOAT:
|
|
||||||
break;
|
|
||||||
|
|
||||||
// MS-ADPCM and XMA2 are not supported as WAVEFORMATEXTENSIBLE
|
|
||||||
|
|
||||||
case WAVE_FORMAT_WMAUDIO2:
|
|
||||||
case WAVE_FORMAT_WMAUDIO3:
|
|
||||||
dpds = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ namespace
|
||||||
fileInfo.EndOfFile.LowPart,
|
fileInfo.EndOfFile.LowPart,
|
||||||
bytesRead,
|
bytesRead,
|
||||||
nullptr
|
nullptr
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
return HRESULT_FROM_WIN32(GetLastError());
|
return HRESULT_FROM_WIN32(GetLastError());
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,7 @@ void WaveBank::Impl::Play(unsigned int index, float volume, float pitch, float p
|
||||||
buffer.Flags = XAUDIO2_END_OF_STREAM;
|
buffer.Flags = XAUDIO2_END_OF_STREAM;
|
||||||
buffer.pContext = this;
|
buffer.pContext = this;
|
||||||
|
|
||||||
#ifdef DIRECTX_ENABLE_XWMA
|
#ifdef DIRECTX_ENABLE_XWMA
|
||||||
|
|
||||||
XAUDIO2_BUFFER_WMA wmaBuffer = {};
|
XAUDIO2_BUFFER_WMA wmaBuffer = {};
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ WaveBank::WaveBank(AudioEngine* engine, const wchar_t* wbFileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugTrace("INFO: WaveBank \"%hs\" with %u entries loaded from .xwb file \"%ls\"\n",
|
DebugTrace("INFO: WaveBank \"%hs\" with %u entries loaded from .xwb file \"%ls\"\n",
|
||||||
pImpl->mReader.BankName(), pImpl->mReader.Count(), wbFileName);
|
pImpl->mReader.BankName(), pImpl->mReader.Count(), wbFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -587,13 +587,13 @@ bool WaveBank::GetPrivateData(unsigned int index, void* data, size_t datasize)
|
||||||
|
|
||||||
switch (datasize)
|
switch (datasize)
|
||||||
{
|
{
|
||||||
case sizeof(WaveBankReader::Metadata):
|
case sizeof(WaveBankReader::Metadata) :
|
||||||
{
|
{
|
||||||
auto ptr = reinterpret_cast<WaveBankReader::Metadata*>(data);
|
auto ptr = reinterpret_cast<WaveBankReader::Metadata*>(data);
|
||||||
return SUCCEEDED(pImpl->mReader.GetMetadata(index, *ptr));
|
return SUCCEEDED(pImpl->mReader.GetMetadata(index, *ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
case sizeof(WaveBankSeekData):
|
case sizeof(WaveBankSeekData) :
|
||||||
{
|
{
|
||||||
auto ptr = reinterpret_cast<WaveBankSeekData*>(data);
|
auto ptr = reinterpret_cast<WaveBankSeekData*>(data);
|
||||||
return SUCCEEDED(pImpl->mReader.GetSeekTable(index, &ptr->seekTable, ptr->seekCount, ptr->tag));
|
return SUCCEEDED(pImpl->mReader.GetSeekTable(index, &ptr->seekTable, ptr->seekCount, ptr->tag));
|
||||||
|
|
|
@ -144,16 +144,16 @@ namespace
|
||||||
{
|
{
|
||||||
switch (wFormatTag)
|
switch (wFormatTag)
|
||||||
{
|
{
|
||||||
case TAG_PCM:
|
case TAG_PCM:
|
||||||
return wBlockAlign;
|
return wBlockAlign;
|
||||||
|
|
||||||
case TAG_XMA:
|
case TAG_XMA:
|
||||||
return (nChannels * 16 / 8); // XMA_OUTPUT_SAMPLE_BITS = 16
|
return (nChannels * 16 / 8); // XMA_OUTPUT_SAMPLE_BITS = 16
|
||||||
|
|
||||||
case TAG_ADPCM:
|
case TAG_ADPCM:
|
||||||
return (wBlockAlign + ADPCM_BLOCKALIGN_CONVERSION_OFFSET) * nChannels;
|
return (wBlockAlign + ADPCM_BLOCKALIGN_CONVERSION_OFFSET) * nChannels;
|
||||||
|
|
||||||
case TAG_WMA:
|
case TAG_WMA:
|
||||||
{
|
{
|
||||||
static const uint32_t aWMABlockAlign[17] =
|
static const uint32_t aWMABlockAlign[17] =
|
||||||
{
|
{
|
||||||
|
@ -190,20 +190,20 @@ namespace
|
||||||
{
|
{
|
||||||
switch (wFormatTag)
|
switch (wFormatTag)
|
||||||
{
|
{
|
||||||
case TAG_PCM:
|
case TAG_PCM:
|
||||||
return nSamplesPerSec * wBlockAlign;
|
return nSamplesPerSec * wBlockAlign;
|
||||||
|
|
||||||
case TAG_XMA:
|
case TAG_XMA:
|
||||||
return nSamplesPerSec * BlockAlign();
|
return nSamplesPerSec * BlockAlign();
|
||||||
|
|
||||||
case TAG_ADPCM:
|
case TAG_ADPCM:
|
||||||
{
|
{
|
||||||
const uint32_t blockAlign = BlockAlign();
|
const uint32_t blockAlign = BlockAlign();
|
||||||
const uint32_t samplesPerAdpcmBlock = AdpcmSamplesPerBlock();
|
const uint32_t samplesPerAdpcmBlock = AdpcmSamplesPerBlock();
|
||||||
return blockAlign * nSamplesPerSec / samplesPerAdpcmBlock;
|
return blockAlign * nSamplesPerSec / samplesPerAdpcmBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TAG_WMA:
|
case TAG_WMA:
|
||||||
{
|
{
|
||||||
static const uint32_t aWMAAvgBytesPerSec[7] =
|
static const uint32_t aWMAAvgBytesPerSec[7] =
|
||||||
{
|
{
|
||||||
|
@ -346,7 +346,7 @@ namespace
|
||||||
{
|
{
|
||||||
switch (data.CompactFormat.wFormatTag)
|
switch (data.CompactFormat.wFormatTag)
|
||||||
{
|
{
|
||||||
case MINIWAVEFORMAT::TAG_ADPCM:
|
case MINIWAVEFORMAT::TAG_ADPCM:
|
||||||
{
|
{
|
||||||
uint32_t duration = (length / data.CompactFormat.BlockAlign()) * data.CompactFormat.AdpcmSamplesPerBlock();
|
uint32_t duration = (length / data.CompactFormat.BlockAlign()) * data.CompactFormat.AdpcmSamplesPerBlock();
|
||||||
const uint32_t partial = length % data.CompactFormat.BlockAlign();
|
const uint32_t partial = length % data.CompactFormat.BlockAlign();
|
||||||
|
@ -358,31 +358,31 @@ namespace
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MINIWAVEFORMAT::TAG_WMA:
|
case MINIWAVEFORMAT::TAG_WMA:
|
||||||
if (seekTable)
|
if (seekTable)
|
||||||
|
{
|
||||||
|
const uint32_t seekCount = *seekTable;
|
||||||
|
if (seekCount > 0)
|
||||||
{
|
{
|
||||||
const uint32_t seekCount = *seekTable;
|
return seekTable[seekCount] / uint32_t(2 * data.CompactFormat.nChannels);
|
||||||
if (seekCount > 0)
|
|
||||||
{
|
|
||||||
return seekTable[seekCount] / uint32_t(2 * data.CompactFormat.nChannels);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
case MINIWAVEFORMAT::TAG_XMA:
|
case MINIWAVEFORMAT::TAG_XMA:
|
||||||
if (seekTable)
|
if (seekTable)
|
||||||
|
{
|
||||||
|
const uint32_t seekCount = *seekTable;
|
||||||
|
if (seekCount > 0)
|
||||||
{
|
{
|
||||||
const uint32_t seekCount = *seekTable;
|
return seekTable[seekCount];
|
||||||
if (seekCount > 0)
|
|
||||||
{
|
|
||||||
return seekTable[seekCount];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return uint32_t((uint64_t(length) * 8)
|
return uint32_t((uint64_t(length) * 8)
|
||||||
/ (uint64_t(data.CompactFormat.BitsPerSample()) * uint64_t(data.CompactFormat.nChannels)));
|
/ (uint64_t(data.CompactFormat.BitsPerSample()) * uint64_t(data.CompactFormat.nChannels)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -834,18 +834,18 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false)
|
||||||
params2.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
|
params2.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||||
params2.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING;
|
params2.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING;
|
||||||
m_async = CreateFile2(szFileName,
|
m_async = CreateFile2(szFileName,
|
||||||
GENERIC_READ,
|
GENERIC_READ,
|
||||||
FILE_SHARE_READ,
|
FILE_SHARE_READ,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
¶ms2);
|
¶ms2);
|
||||||
#else
|
#else
|
||||||
m_async = CreateFileW(szFileName,
|
m_async = CreateFileW(szFileName,
|
||||||
GENERIC_READ,
|
GENERIC_READ,
|
||||||
FILE_SHARE_READ,
|
FILE_SHARE_READ,
|
||||||
nullptr,
|
nullptr,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING,
|
FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING,
|
||||||
nullptr);
|
nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_async == INVALID_HANDLE_VALUE)
|
if (m_async == INVALID_HANDLE_VALUE)
|
||||||
|
@ -970,115 +970,115 @@ HRESULT WaveBankReader::Impl::GetFormat(uint32_t index, WAVEFORMATEX* pFormat, s
|
||||||
|
|
||||||
switch (miniFmt.wFormatTag)
|
switch (miniFmt.wFormatTag)
|
||||||
{
|
{
|
||||||
case MINIWAVEFORMAT::TAG_PCM:
|
case MINIWAVEFORMAT::TAG_PCM:
|
||||||
if (maxsize < sizeof(PCMWAVEFORMAT))
|
if (maxsize < sizeof(PCMWAVEFORMAT))
|
||||||
return HRESULT_FROM_WIN32(ERROR_MORE_DATA);
|
return HRESULT_FROM_WIN32(ERROR_MORE_DATA);
|
||||||
|
|
||||||
pFormat->wFormatTag = WAVE_FORMAT_PCM;
|
pFormat->wFormatTag = WAVE_FORMAT_PCM;
|
||||||
|
|
||||||
if (maxsize >= sizeof(WAVEFORMATEX))
|
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<ADPCMWAVEFORMAT*>(pFormat);
|
|
||||||
adpcmFmt->wSamplesPerBlock = static_cast<WORD>(miniFmt.AdpcmSamplesPerBlock());
|
|
||||||
miniFmt.AdpcmFillCoefficientTable(adpcmFmt);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MINIWAVEFORMAT::TAG_WMA:
|
|
||||||
if (maxsize < sizeof(WAVEFORMATEX))
|
|
||||||
return HRESULT_FROM_WIN32(ERROR_MORE_DATA);
|
|
||||||
|
|
||||||
pFormat->wFormatTag = static_cast<WORD>((miniFmt.wBitsPerSample & 0x1) ? WAVE_FORMAT_WMAUDIO3 : WAVE_FORMAT_WMAUDIO2);
|
|
||||||
pFormat->cbSize = 0;
|
pFormat->cbSize = 0;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case MINIWAVEFORMAT::TAG_XMA: // XMA2 is supported by Xbox One
|
case MINIWAVEFORMAT::TAG_ADPCM:
|
||||||
#ifdef DIRECTX_ENABLE_XMA2
|
if (maxsize < (sizeof(WAVEFORMATEX) + 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/))
|
||||||
if (maxsize < sizeof(XMA2WAVEFORMATEX))
|
return HRESULT_FROM_WIN32(ERROR_MORE_DATA);
|
||||||
return HRESULT_FROM_WIN32(ERROR_MORE_DATA);
|
|
||||||
|
|
||||||
pFormat->wFormatTag = WAVE_FORMAT_XMA2;
|
pFormat->wFormatTag = WAVE_FORMAT_ADPCM;
|
||||||
pFormat->cbSize = sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX);
|
pFormat->cbSize = 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/;
|
||||||
|
{
|
||||||
|
auto adpcmFmt = reinterpret_cast<ADPCMWAVEFORMAT*>(pFormat);
|
||||||
|
adpcmFmt->wSamplesPerBlock = static_cast<WORD>(miniFmt.AdpcmSamplesPerBlock());
|
||||||
|
miniFmt.AdpcmFillCoefficientTable(adpcmFmt);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MINIWAVEFORMAT::TAG_WMA:
|
||||||
|
if (maxsize < sizeof(WAVEFORMATEX))
|
||||||
|
return HRESULT_FROM_WIN32(ERROR_MORE_DATA);
|
||||||
|
|
||||||
|
pFormat->wFormatTag = static_cast<WORD>((miniFmt.wBitsPerSample & 0x1) ? WAVE_FORMAT_WMAUDIO3 : WAVE_FORMAT_WMAUDIO2);
|
||||||
|
pFormat->cbSize = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MINIWAVEFORMAT::TAG_XMA: // XMA2 is supported by Xbox One
|
||||||
|
#ifdef DIRECTX_ENABLE_XMA2
|
||||||
|
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<XMA2WAVEFORMATEX*>(pFormat);
|
||||||
|
|
||||||
|
xmaFmt->NumStreams = static_cast<WORD>((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)
|
||||||
{
|
{
|
||||||
auto xmaFmt = reinterpret_cast<XMA2WAVEFORMATEX*>(pFormat);
|
xmaFmt->BlockCount = static_cast<WORD>(*seekTable);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xmaFmt->BlockCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
xmaFmt->NumStreams = static_cast<WORD>((miniFmt.nChannels + 1) / 2);
|
switch (miniFmt.nChannels)
|
||||||
xmaFmt->BytesPerBlock = 65536 /* XACT_FIXED_XMA_BLOCK_SIZE */;
|
{
|
||||||
xmaFmt->EncoderVersion = 4 /* XMAENCODER_VERSION_XMA2 */;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
auto seekTable = FindSeekTable(index, m_seekData.get(), m_header, m_data);
|
if (m_data.dwFlags & BANKDATA::FLAGS_COMPACT)
|
||||||
if (seekTable)
|
{
|
||||||
|
auto& entry = reinterpret_cast<const ENTRYCOMPACT*>(m_entries.get())[index];
|
||||||
|
|
||||||
|
DWORD dwOffset, dwLength;
|
||||||
|
entry.ComputeLocations(dwOffset, dwLength, index, m_header, m_data, reinterpret_cast<const ENTRYCOMPACT*>(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<const ENTRY*>(m_entries.get())[index];
|
||||||
|
|
||||||
|
xmaFmt->SamplesEncoded = entry.Duration;
|
||||||
|
xmaFmt->PlayBegin = 0;
|
||||||
|
xmaFmt->PlayLength = entry.PlayRegion.dwLength;
|
||||||
|
|
||||||
|
if (entry.LoopRegion.dwTotalSamples > 0)
|
||||||
{
|
{
|
||||||
xmaFmt->BlockCount = static_cast<WORD>(*seekTable);
|
xmaFmt->LoopBegin = entry.LoopRegion.dwStartSample;
|
||||||
|
xmaFmt->LoopLength = entry.LoopRegion.dwTotalSamples;
|
||||||
|
xmaFmt->LoopCount = 0xff /* XACTLOOPCOUNT_INFINITE */;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xmaFmt->BlockCount = 0;
|
xmaFmt->LoopBegin = xmaFmt->LoopLength = xmaFmt->LoopCount = 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<const ENTRYCOMPACT*>(m_entries.get())[index];
|
|
||||||
|
|
||||||
DWORD dwOffset, dwLength;
|
|
||||||
entry.ComputeLocations(dwOffset, dwLength, index, m_header, m_data, reinterpret_cast<const ENTRYCOMPACT*>(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<const ENTRY*>(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
|
break;
|
||||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
#else
|
||||||
#endif
|
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFormat->nChannels = miniFmt.nChannels;
|
pFormat->nChannels = miniFmt.nChannels;
|
||||||
|
@ -1175,16 +1175,16 @@ HRESULT WaveBankReader::Impl::GetSeekTable(uint32_t index, const uint32_t** pDat
|
||||||
|
|
||||||
switch (miniFmt.wFormatTag)
|
switch (miniFmt.wFormatTag)
|
||||||
{
|
{
|
||||||
case MINIWAVEFORMAT::TAG_WMA:
|
case MINIWAVEFORMAT::TAG_WMA:
|
||||||
tag = static_cast<uint32_t>((miniFmt.wBitsPerSample & 0x1) ? WAVE_FORMAT_WMAUDIO3 : WAVE_FORMAT_WMAUDIO2);
|
tag = static_cast<uint32_t>((miniFmt.wBitsPerSample & 0x1) ? WAVE_FORMAT_WMAUDIO3 : WAVE_FORMAT_WMAUDIO2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MINIWAVEFORMAT::TAG_XMA:
|
case MINIWAVEFORMAT::TAG_XMA:
|
||||||
tag = 0x166 /* WAVE_FORMAT_XMA2 */;
|
tag = 0x166 /* WAVE_FORMAT_XMA2 */;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto seekTable = FindSeekTable(index, m_seekData.get(), m_header, m_data);
|
auto seekTable = FindSeekTable(index, m_seekData.get(), m_header, m_data);
|
||||||
|
|
40
Inc/Audio.h
40
Inc/Audio.h
|
@ -80,9 +80,9 @@ namespace DirectX
|
||||||
size_t allocatedVoicesOneShot; // Number of XAudio2 voices allocated for one-shot sounds
|
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 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
|
size_t audioBytes; // Total wave data (in bytes) in SoundEffects and in-memory WaveBanks
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
size_t xmaAudioBytes; // Total wave data (in bytes) in SoundEffects and in-memory WaveBanks allocated with ApuAlloc
|
size_t xmaAudioBytes; // Total wave data (in bytes) in SoundEffects and in-memory WaveBanks allocated with ApuAlloc
|
||||||
#endif
|
#endif
|
||||||
size_t streamingBytes; // Total size of streaming buffers (in bytes) in streaming WaveBanks
|
size_t streamingBytes; // Total size of streaming buffers (in bytes) in streaming WaveBanks
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -131,26 +131,26 @@ namespace DirectX
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
enum AUDIO_ENGINE_FLAGS : uint32_t
|
enum AUDIO_ENGINE_FLAGS : uint32_t
|
||||||
{
|
{
|
||||||
AudioEngine_Default = 0x0,
|
AudioEngine_Default = 0x0,
|
||||||
|
|
||||||
AudioEngine_EnvironmentalReverb = 0x1,
|
AudioEngine_EnvironmentalReverb = 0x1,
|
||||||
AudioEngine_ReverbUseFilters = 0x2,
|
AudioEngine_ReverbUseFilters = 0x2,
|
||||||
AudioEngine_UseMasteringLimiter = 0x4,
|
AudioEngine_UseMasteringLimiter = 0x4,
|
||||||
|
|
||||||
AudioEngine_Debug = 0x10000,
|
AudioEngine_Debug = 0x10000,
|
||||||
AudioEngine_ThrowOnNoAudioHW = 0x20000,
|
AudioEngine_ThrowOnNoAudioHW = 0x20000,
|
||||||
AudioEngine_DisableVoiceReuse = 0x40000,
|
AudioEngine_DisableVoiceReuse = 0x40000,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SOUND_EFFECT_INSTANCE_FLAGS : uint32_t
|
enum SOUND_EFFECT_INSTANCE_FLAGS : uint32_t
|
||||||
{
|
{
|
||||||
SoundEffectInstance_Default = 0x0,
|
SoundEffectInstance_Default = 0x0,
|
||||||
|
|
||||||
SoundEffectInstance_Use3D = 0x1,
|
SoundEffectInstance_Use3D = 0x1,
|
||||||
SoundEffectInstance_ReverbUseFilters = 0x2,
|
SoundEffectInstance_ReverbUseFilters = 0x2,
|
||||||
SoundEffectInstance_NoSetPitch = 0x4,
|
SoundEffectInstance_NoSetPitch = 0x4,
|
||||||
|
|
||||||
SoundEffectInstance_UseRedirectLFE = 0x10000,
|
SoundEffectInstance_UseRedirectLFE = 0x10000,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AUDIO_ENGINE_REVERB : unsigned int
|
enum AUDIO_ENGINE_REVERB : unsigned int
|
||||||
|
@ -348,11 +348,11 @@ namespace DirectX
|
||||||
|
|
||||||
int __cdecl Find(_In_z_ const char* name) const;
|
int __cdecl Find(_In_z_ const char* name) const;
|
||||||
|
|
||||||
#ifdef USING_XAUDIO2_9
|
#ifdef USING_XAUDIO2_9
|
||||||
bool __cdecl FillSubmitBuffer(unsigned int index, _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer) const;
|
bool __cdecl FillSubmitBuffer(unsigned int index, _Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer) const;
|
||||||
#else
|
#else
|
||||||
void __cdecl FillSubmitBuffer(unsigned int index, _Out_ XAUDIO2_BUFFER& buffer) const;
|
void __cdecl FillSubmitBuffer(unsigned int index, _Out_ XAUDIO2_BUFFER& buffer) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void __cdecl UnregisterInstance(_In_ IVoiceNotify* instance);
|
void __cdecl UnregisterInstance(_In_ IVoiceNotify* instance);
|
||||||
|
|
||||||
|
@ -381,13 +381,13 @@ namespace DirectX
|
||||||
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
|
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
|
||||||
uint32_t loopStart, uint32_t loopLength);
|
uint32_t loopStart, uint32_t loopLength);
|
||||||
|
|
||||||
#ifdef USING_XAUDIO2_9
|
#ifdef USING_XAUDIO2_9
|
||||||
|
|
||||||
SoundEffect(_In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
|
SoundEffect(_In_ AudioEngine* engine, _Inout_ std::unique_ptr<uint8_t[]>& wavData,
|
||||||
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
|
_In_ const WAVEFORMATEX* wfx, _In_reads_bytes_(audioBytes) const uint8_t* startAudio, size_t audioBytes,
|
||||||
_In_reads_(seekCount) const uint32_t* seekTable, size_t seekCount);
|
_In_reads_(seekCount) const uint32_t* seekTable, size_t seekCount);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SoundEffect(SoundEffect&&) noexcept;
|
SoundEffect(SoundEffect&&) noexcept;
|
||||||
SoundEffect& operator= (SoundEffect&&) noexcept;
|
SoundEffect& operator= (SoundEffect&&) noexcept;
|
||||||
|
@ -415,11 +415,11 @@ namespace DirectX
|
||||||
|
|
||||||
const WAVEFORMATEX* __cdecl GetFormat() const noexcept;
|
const WAVEFORMATEX* __cdecl GetFormat() const noexcept;
|
||||||
|
|
||||||
#ifdef USING_XAUDIO2_9
|
#ifdef USING_XAUDIO2_9
|
||||||
bool __cdecl FillSubmitBuffer(_Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer) const;
|
bool __cdecl FillSubmitBuffer(_Out_ XAUDIO2_BUFFER& buffer, _Out_ XAUDIO2_BUFFER_WMA& wmaBuffer) const;
|
||||||
#else
|
#else
|
||||||
void __cdecl FillSubmitBuffer(_Out_ XAUDIO2_BUFFER& buffer) const;
|
void __cdecl FillSubmitBuffer(_Out_ XAUDIO2_BUFFER& buffer) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void __cdecl UnregisterInstance(_In_ IVoiceNotify* instance);
|
void __cdecl UnregisterInstance(_In_ IVoiceNotify* instance);
|
||||||
|
|
||||||
|
|
|
@ -37,20 +37,20 @@ namespace DirectX
|
||||||
#define DDS_ALPHA_MODE_DEFINED
|
#define DDS_ALPHA_MODE_DEFINED
|
||||||
enum DDS_ALPHA_MODE : uint32_t
|
enum DDS_ALPHA_MODE : uint32_t
|
||||||
{
|
{
|
||||||
DDS_ALPHA_MODE_UNKNOWN = 0,
|
DDS_ALPHA_MODE_UNKNOWN = 0,
|
||||||
DDS_ALPHA_MODE_STRAIGHT = 1,
|
DDS_ALPHA_MODE_STRAIGHT = 1,
|
||||||
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
|
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
|
||||||
DDS_ALPHA_MODE_OPAQUE = 3,
|
DDS_ALPHA_MODE_OPAQUE = 3,
|
||||||
DDS_ALPHA_MODE_CUSTOM = 4,
|
DDS_ALPHA_MODE_CUSTOM = 4,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum DDS_LOADER_FLAGS : uint32_t
|
enum DDS_LOADER_FLAGS : uint32_t
|
||||||
{
|
{
|
||||||
DDS_LOADER_DEFAULT = 0,
|
DDS_LOADER_DEFAULT = 0,
|
||||||
DDS_LOADER_FORCE_SRGB = 0x1,
|
DDS_LOADER_FORCE_SRGB = 0x1,
|
||||||
DDS_LOADER_MIP_AUTOGEN = 0x8,
|
DDS_LOADER_MIP_AUTOGEN = 0x8,
|
||||||
DDS_LOADER_MIP_RESERVE = 0x10,
|
DDS_LOADER_MIP_RESERVE = 0x10,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Standard version
|
// Standard version
|
||||||
|
|
|
@ -46,7 +46,9 @@ namespace DirectX
|
||||||
size_t count) noexcept(false) :
|
size_t count) noexcept(false) :
|
||||||
DescriptorHeap(device,
|
DescriptorHeap(device,
|
||||||
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
||||||
D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, count) {}
|
D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, count)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
DescriptorHeap(DescriptorHeap&&) = default;
|
DescriptorHeap(DescriptorHeap&&) = default;
|
||||||
DescriptorHeap& operator=(DescriptorHeap&&) = default;
|
DescriptorHeap& operator=(DescriptorHeap&&) = default;
|
||||||
|
@ -190,7 +192,9 @@ namespace DirectX
|
||||||
size_t reserve = 0) noexcept(false) :
|
size_t reserve = 0) noexcept(false) :
|
||||||
DescriptorPile(device,
|
DescriptorPile(device,
|
||||||
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
||||||
D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, count, reserve) {}
|
D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, count, reserve)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
DescriptorPile(const DescriptorPile&) = delete;
|
DescriptorPile(const DescriptorPile&) = delete;
|
||||||
DescriptorPile& operator=(const DescriptorPile&) = delete;
|
DescriptorPile& operator=(const DescriptorPile&) = delete;
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace DirectX
|
||||||
{
|
{
|
||||||
hr = device->CreateRootSignature(0, pSignature->GetBufferPointer(), pSignature->GetBufferSize(),
|
hr = device->CreateRootSignature(0, pSignature->GetBufferPointer(), pSignature->GetBufferSize(),
|
||||||
IID_GRAPHICS_PPV_ARGS(rootSignature)
|
IID_GRAPHICS_PPV_ARGS(rootSignature)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,20 +144,31 @@ namespace DirectX
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
namespace EffectFlags
|
namespace EffectFlags
|
||||||
{
|
{
|
||||||
constexpr uint32_t None = 0x00;
|
constexpr uint32_t None = 0x00;
|
||||||
constexpr uint32_t Fog = 0x01;
|
constexpr uint32_t Fog = 0x01;
|
||||||
constexpr uint32_t Lighting = 0x02;
|
constexpr uint32_t Lighting = 0x02;
|
||||||
constexpr uint32_t PerPixelLighting = 0x04 | Lighting; // per pixel lighting implies lighting enabled
|
|
||||||
constexpr uint32_t VertexColor = 0x08;
|
|
||||||
constexpr uint32_t Texture = 0x10;
|
|
||||||
constexpr uint32_t Instancing = 0x20;
|
|
||||||
|
|
||||||
constexpr uint32_t Specular = 0x100; // enable optional specular/specularMap feature
|
constexpr uint32_t PerPixelLighting = 0x04 | Lighting;
|
||||||
constexpr uint32_t Emissive = 0x200; // enable optional emissive/emissiveMap feature
|
// per pixel lighting implies lighting enabled
|
||||||
constexpr uint32_t Fresnel = 0x400; // enable optional Fresnel feature
|
|
||||||
constexpr uint32_t Velocity = 0x800; // enable optional velocity feature
|
|
||||||
|
|
||||||
constexpr uint32_t BiasedVertexNormals = 0x10000; // compressed vertex normals need x2 bias
|
constexpr uint32_t VertexColor = 0x08;
|
||||||
|
constexpr uint32_t Texture = 0x10;
|
||||||
|
constexpr uint32_t Instancing = 0x20;
|
||||||
|
|
||||||
|
constexpr uint32_t Specular = 0x100;
|
||||||
|
// enable optional specular/specularMap feature
|
||||||
|
|
||||||
|
constexpr uint32_t Emissive = 0x200;
|
||||||
|
// enable optional emissive/emissiveMap feature
|
||||||
|
|
||||||
|
constexpr uint32_t Fresnel = 0x400;
|
||||||
|
// enable optional Fresnel feature
|
||||||
|
|
||||||
|
constexpr uint32_t Velocity = 0x800;
|
||||||
|
// enable optional velocity feature
|
||||||
|
|
||||||
|
constexpr uint32_t BiasedVertexNormals = 0x10000;
|
||||||
|
// compressed vertex normals need x2 bias
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -457,7 +468,9 @@ namespace DirectX
|
||||||
public:
|
public:
|
||||||
NormalMapEffect(_In_ ID3D12Device* device, uint32_t effectFlags,
|
NormalMapEffect(_In_ ID3D12Device* device, uint32_t effectFlags,
|
||||||
const EffectPipelineStateDescription& pipelineDescription) :
|
const EffectPipelineStateDescription& pipelineDescription) :
|
||||||
NormalMapEffect(device, effectFlags, pipelineDescription, false) {}
|
NormalMapEffect(device, effectFlags, pipelineDescription, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NormalMapEffect(NormalMapEffect&&) noexcept;
|
NormalMapEffect(NormalMapEffect&&) noexcept;
|
||||||
NormalMapEffect& operator= (NormalMapEffect&&) noexcept;
|
NormalMapEffect& operator= (NormalMapEffect&&) noexcept;
|
||||||
|
@ -520,7 +533,9 @@ namespace DirectX
|
||||||
public:
|
public:
|
||||||
SkinnedNormalMapEffect(_In_ ID3D12Device* device, uint32_t effectFlags,
|
SkinnedNormalMapEffect(_In_ ID3D12Device* device, uint32_t effectFlags,
|
||||||
const EffectPipelineStateDescription& pipelineDescription) :
|
const EffectPipelineStateDescription& pipelineDescription) :
|
||||||
NormalMapEffect(device, effectFlags, pipelineDescription, true) {}
|
NormalMapEffect(device, effectFlags, pipelineDescription, true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SkinnedNormalMapEffect(SkinnedNormalMapEffect&&) = default;
|
SkinnedNormalMapEffect(SkinnedNormalMapEffect&&) = default;
|
||||||
SkinnedNormalMapEffect& operator= (SkinnedNormalMapEffect&&) = default;
|
SkinnedNormalMapEffect& operator= (SkinnedNormalMapEffect&&) = default;
|
||||||
|
@ -541,7 +556,9 @@ namespace DirectX
|
||||||
public:
|
public:
|
||||||
PBREffect(_In_ ID3D12Device* device, uint32_t effectFlags,
|
PBREffect(_In_ ID3D12Device* device, uint32_t effectFlags,
|
||||||
const EffectPipelineStateDescription& pipelineDescription) :
|
const EffectPipelineStateDescription& pipelineDescription) :
|
||||||
PBREffect(device, effectFlags, pipelineDescription, false) {}
|
PBREffect(device, effectFlags, pipelineDescription, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
PBREffect(PBREffect&&) noexcept;
|
PBREffect(PBREffect&&) noexcept;
|
||||||
PBREffect& operator= (PBREffect&&) noexcept;
|
PBREffect& operator= (PBREffect&&) noexcept;
|
||||||
|
@ -614,7 +631,9 @@ namespace DirectX
|
||||||
public:
|
public:
|
||||||
SkinnedPBREffect(_In_ ID3D12Device* device, uint32_t effectFlags,
|
SkinnedPBREffect(_In_ ID3D12Device* device, uint32_t effectFlags,
|
||||||
const EffectPipelineStateDescription& pipelineDescription) :
|
const EffectPipelineStateDescription& pipelineDescription) :
|
||||||
PBREffect(device, effectFlags, pipelineDescription, true) {}
|
PBREffect(device, effectFlags, pipelineDescription, true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SkinnedPBREffect(SkinnedPBREffect&&) = default;
|
SkinnedPBREffect(SkinnedPBREffect&&) = default;
|
||||||
SkinnedPBREffect& operator= (SkinnedPBREffect&&) = default;
|
SkinnedPBREffect& operator= (SkinnedPBREffect&&) = default;
|
||||||
|
|
|
@ -253,7 +253,7 @@ namespace DirectX
|
||||||
ButtonState leftTrigger;
|
ButtonState leftTrigger;
|
||||||
ButtonState rightTrigger;
|
ButtonState rightTrigger;
|
||||||
|
|
||||||
#pragma prefast(suppress: 26495, "Reset() performs the initialization")
|
#pragma prefast(suppress: 26495, "Reset() performs the initialization")
|
||||||
ButtonStateTracker() noexcept { Reset(); }
|
ButtonStateTracker() noexcept { Reset(); }
|
||||||
|
|
||||||
void __cdecl Update(const State& state) noexcept;
|
void __cdecl Update(const State& state) noexcept;
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace DirectX
|
||||||
size_t ResourceOffset() const noexcept { return mBufferOffset; }
|
size_t ResourceOffset() const noexcept { return mBufferOffset; }
|
||||||
size_t Size() const noexcept { return mSize; }
|
size_t Size() const noexcept { return mSize; }
|
||||||
|
|
||||||
explicit operator bool () const noexcept { return mResource != nullptr; }
|
explicit operator bool() const noexcept { return mResource != nullptr; }
|
||||||
|
|
||||||
// Clear the pointer. Using operator -> will produce bad results.
|
// Clear the pointer. Using operator -> will produce bad results.
|
||||||
void __cdecl Reset() noexcept;
|
void __cdecl Reset() noexcept;
|
||||||
|
@ -94,7 +94,7 @@ namespace DirectX
|
||||||
size_t ResourceOffset() const noexcept { return mSharedResource->ResourceOffset(); }
|
size_t ResourceOffset() const noexcept { return mSharedResource->ResourceOffset(); }
|
||||||
size_t Size() const noexcept { return mSharedResource->Size(); }
|
size_t Size() const noexcept { return mSharedResource->Size(); }
|
||||||
|
|
||||||
explicit operator bool () const noexcept { return mSharedResource != nullptr; }
|
explicit operator bool() const noexcept { return mSharedResource != nullptr; }
|
||||||
|
|
||||||
bool operator == (const SharedGraphicsResource& other) const noexcept { return mSharedResource.get() == other.mSharedResource.get(); }
|
bool operator == (const SharedGraphicsResource& other) const noexcept { return mSharedResource.get() == other.mSharedResource.get(); }
|
||||||
bool operator != (const SharedGraphicsResource& other) const noexcept { return mSharedResource.get() != other.mSharedResource.get(); }
|
bool operator != (const SharedGraphicsResource& other) const noexcept { return mSharedResource.get() != other.mSharedResource.get(); }
|
||||||
|
|
324
Inc/Keyboard.h
324
Inc/Keyboard.h
|
@ -46,184 +46,184 @@ namespace DirectX
|
||||||
|
|
||||||
enum Keys : unsigned char
|
enum Keys : unsigned char
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
||||||
Back = 0x8,
|
Back = 0x8,
|
||||||
Tab = 0x9,
|
Tab = 0x9,
|
||||||
|
|
||||||
Enter = 0xd,
|
Enter = 0xd,
|
||||||
|
|
||||||
Pause = 0x13,
|
Pause = 0x13,
|
||||||
CapsLock = 0x14,
|
CapsLock = 0x14,
|
||||||
Kana = 0x15,
|
Kana = 0x15,
|
||||||
ImeOn = 0x16,
|
ImeOn = 0x16,
|
||||||
|
|
||||||
Kanji = 0x19,
|
Kanji = 0x19,
|
||||||
|
|
||||||
ImeOff = 0x1a,
|
ImeOff = 0x1a,
|
||||||
Escape = 0x1b,
|
Escape = 0x1b,
|
||||||
ImeConvert = 0x1c,
|
ImeConvert = 0x1c,
|
||||||
ImeNoConvert = 0x1d,
|
ImeNoConvert = 0x1d,
|
||||||
|
|
||||||
Space = 0x20,
|
Space = 0x20,
|
||||||
PageUp = 0x21,
|
PageUp = 0x21,
|
||||||
PageDown = 0x22,
|
PageDown = 0x22,
|
||||||
End = 0x23,
|
End = 0x23,
|
||||||
Home = 0x24,
|
Home = 0x24,
|
||||||
Left = 0x25,
|
Left = 0x25,
|
||||||
Up = 0x26,
|
Up = 0x26,
|
||||||
Right = 0x27,
|
Right = 0x27,
|
||||||
Down = 0x28,
|
Down = 0x28,
|
||||||
Select = 0x29,
|
Select = 0x29,
|
||||||
Print = 0x2a,
|
Print = 0x2a,
|
||||||
Execute = 0x2b,
|
Execute = 0x2b,
|
||||||
PrintScreen = 0x2c,
|
PrintScreen = 0x2c,
|
||||||
Insert = 0x2d,
|
Insert = 0x2d,
|
||||||
Delete = 0x2e,
|
Delete = 0x2e,
|
||||||
Help = 0x2f,
|
Help = 0x2f,
|
||||||
D0 = 0x30,
|
D0 = 0x30,
|
||||||
D1 = 0x31,
|
D1 = 0x31,
|
||||||
D2 = 0x32,
|
D2 = 0x32,
|
||||||
D3 = 0x33,
|
D3 = 0x33,
|
||||||
D4 = 0x34,
|
D4 = 0x34,
|
||||||
D5 = 0x35,
|
D5 = 0x35,
|
||||||
D6 = 0x36,
|
D6 = 0x36,
|
||||||
D7 = 0x37,
|
D7 = 0x37,
|
||||||
D8 = 0x38,
|
D8 = 0x38,
|
||||||
D9 = 0x39,
|
D9 = 0x39,
|
||||||
|
|
||||||
A = 0x41,
|
A = 0x41,
|
||||||
B = 0x42,
|
B = 0x42,
|
||||||
C = 0x43,
|
C = 0x43,
|
||||||
D = 0x44,
|
D = 0x44,
|
||||||
E = 0x45,
|
E = 0x45,
|
||||||
F = 0x46,
|
F = 0x46,
|
||||||
G = 0x47,
|
G = 0x47,
|
||||||
H = 0x48,
|
H = 0x48,
|
||||||
I = 0x49,
|
I = 0x49,
|
||||||
J = 0x4a,
|
J = 0x4a,
|
||||||
K = 0x4b,
|
K = 0x4b,
|
||||||
L = 0x4c,
|
L = 0x4c,
|
||||||
M = 0x4d,
|
M = 0x4d,
|
||||||
N = 0x4e,
|
N = 0x4e,
|
||||||
O = 0x4f,
|
O = 0x4f,
|
||||||
P = 0x50,
|
P = 0x50,
|
||||||
Q = 0x51,
|
Q = 0x51,
|
||||||
R = 0x52,
|
R = 0x52,
|
||||||
S = 0x53,
|
S = 0x53,
|
||||||
T = 0x54,
|
T = 0x54,
|
||||||
U = 0x55,
|
U = 0x55,
|
||||||
V = 0x56,
|
V = 0x56,
|
||||||
W = 0x57,
|
W = 0x57,
|
||||||
X = 0x58,
|
X = 0x58,
|
||||||
Y = 0x59,
|
Y = 0x59,
|
||||||
Z = 0x5a,
|
Z = 0x5a,
|
||||||
LeftWindows = 0x5b,
|
LeftWindows = 0x5b,
|
||||||
RightWindows = 0x5c,
|
RightWindows = 0x5c,
|
||||||
Apps = 0x5d,
|
Apps = 0x5d,
|
||||||
|
|
||||||
Sleep = 0x5f,
|
Sleep = 0x5f,
|
||||||
NumPad0 = 0x60,
|
NumPad0 = 0x60,
|
||||||
NumPad1 = 0x61,
|
NumPad1 = 0x61,
|
||||||
NumPad2 = 0x62,
|
NumPad2 = 0x62,
|
||||||
NumPad3 = 0x63,
|
NumPad3 = 0x63,
|
||||||
NumPad4 = 0x64,
|
NumPad4 = 0x64,
|
||||||
NumPad5 = 0x65,
|
NumPad5 = 0x65,
|
||||||
NumPad6 = 0x66,
|
NumPad6 = 0x66,
|
||||||
NumPad7 = 0x67,
|
NumPad7 = 0x67,
|
||||||
NumPad8 = 0x68,
|
NumPad8 = 0x68,
|
||||||
NumPad9 = 0x69,
|
NumPad9 = 0x69,
|
||||||
Multiply = 0x6a,
|
Multiply = 0x6a,
|
||||||
Add = 0x6b,
|
Add = 0x6b,
|
||||||
Separator = 0x6c,
|
Separator = 0x6c,
|
||||||
Subtract = 0x6d,
|
Subtract = 0x6d,
|
||||||
|
|
||||||
Decimal = 0x6e,
|
Decimal = 0x6e,
|
||||||
Divide = 0x6f,
|
Divide = 0x6f,
|
||||||
F1 = 0x70,
|
F1 = 0x70,
|
||||||
F2 = 0x71,
|
F2 = 0x71,
|
||||||
F3 = 0x72,
|
F3 = 0x72,
|
||||||
F4 = 0x73,
|
F4 = 0x73,
|
||||||
F5 = 0x74,
|
F5 = 0x74,
|
||||||
F6 = 0x75,
|
F6 = 0x75,
|
||||||
F7 = 0x76,
|
F7 = 0x76,
|
||||||
F8 = 0x77,
|
F8 = 0x77,
|
||||||
F9 = 0x78,
|
F9 = 0x78,
|
||||||
F10 = 0x79,
|
F10 = 0x79,
|
||||||
F11 = 0x7a,
|
F11 = 0x7a,
|
||||||
F12 = 0x7b,
|
F12 = 0x7b,
|
||||||
F13 = 0x7c,
|
F13 = 0x7c,
|
||||||
F14 = 0x7d,
|
F14 = 0x7d,
|
||||||
F15 = 0x7e,
|
F15 = 0x7e,
|
||||||
F16 = 0x7f,
|
F16 = 0x7f,
|
||||||
F17 = 0x80,
|
F17 = 0x80,
|
||||||
F18 = 0x81,
|
F18 = 0x81,
|
||||||
F19 = 0x82,
|
F19 = 0x82,
|
||||||
F20 = 0x83,
|
F20 = 0x83,
|
||||||
F21 = 0x84,
|
F21 = 0x84,
|
||||||
F22 = 0x85,
|
F22 = 0x85,
|
||||||
F23 = 0x86,
|
F23 = 0x86,
|
||||||
F24 = 0x87,
|
F24 = 0x87,
|
||||||
|
|
||||||
NumLock = 0x90,
|
NumLock = 0x90,
|
||||||
Scroll = 0x91,
|
Scroll = 0x91,
|
||||||
|
|
||||||
LeftShift = 0xa0,
|
LeftShift = 0xa0,
|
||||||
RightShift = 0xa1,
|
RightShift = 0xa1,
|
||||||
LeftControl = 0xa2,
|
LeftControl = 0xa2,
|
||||||
RightControl = 0xa3,
|
RightControl = 0xa3,
|
||||||
LeftAlt = 0xa4,
|
LeftAlt = 0xa4,
|
||||||
RightAlt = 0xa5,
|
RightAlt = 0xa5,
|
||||||
BrowserBack = 0xa6,
|
BrowserBack = 0xa6,
|
||||||
BrowserForward = 0xa7,
|
BrowserForward = 0xa7,
|
||||||
BrowserRefresh = 0xa8,
|
BrowserRefresh = 0xa8,
|
||||||
BrowserStop = 0xa9,
|
BrowserStop = 0xa9,
|
||||||
BrowserSearch = 0xaa,
|
BrowserSearch = 0xaa,
|
||||||
BrowserFavorites = 0xab,
|
BrowserFavorites = 0xab,
|
||||||
BrowserHome = 0xac,
|
BrowserHome = 0xac,
|
||||||
VolumeMute = 0xad,
|
VolumeMute = 0xad,
|
||||||
VolumeDown = 0xae,
|
VolumeDown = 0xae,
|
||||||
VolumeUp = 0xaf,
|
VolumeUp = 0xaf,
|
||||||
MediaNextTrack = 0xb0,
|
MediaNextTrack = 0xb0,
|
||||||
MediaPreviousTrack = 0xb1,
|
MediaPreviousTrack = 0xb1,
|
||||||
MediaStop = 0xb2,
|
MediaStop = 0xb2,
|
||||||
MediaPlayPause = 0xb3,
|
MediaPlayPause = 0xb3,
|
||||||
LaunchMail = 0xb4,
|
LaunchMail = 0xb4,
|
||||||
SelectMedia = 0xb5,
|
SelectMedia = 0xb5,
|
||||||
LaunchApplication1 = 0xb6,
|
LaunchApplication1 = 0xb6,
|
||||||
LaunchApplication2 = 0xb7,
|
LaunchApplication2 = 0xb7,
|
||||||
|
|
||||||
OemSemicolon = 0xba,
|
OemSemicolon = 0xba,
|
||||||
OemPlus = 0xbb,
|
OemPlus = 0xbb,
|
||||||
OemComma = 0xbc,
|
OemComma = 0xbc,
|
||||||
OemMinus = 0xbd,
|
OemMinus = 0xbd,
|
||||||
OemPeriod = 0xbe,
|
OemPeriod = 0xbe,
|
||||||
OemQuestion = 0xbf,
|
OemQuestion = 0xbf,
|
||||||
OemTilde = 0xc0,
|
OemTilde = 0xc0,
|
||||||
|
|
||||||
OemOpenBrackets = 0xdb,
|
OemOpenBrackets = 0xdb,
|
||||||
OemPipe = 0xdc,
|
OemPipe = 0xdc,
|
||||||
OemCloseBrackets = 0xdd,
|
OemCloseBrackets = 0xdd,
|
||||||
OemQuotes = 0xde,
|
OemQuotes = 0xde,
|
||||||
Oem8 = 0xdf,
|
Oem8 = 0xdf,
|
||||||
|
|
||||||
OemBackslash = 0xe2,
|
OemBackslash = 0xe2,
|
||||||
|
|
||||||
ProcessKey = 0xe5,
|
ProcessKey = 0xe5,
|
||||||
|
|
||||||
OemCopy = 0xf2,
|
OemCopy = 0xf2,
|
||||||
OemAuto = 0xf3,
|
OemAuto = 0xf3,
|
||||||
OemEnlW = 0xf4,
|
OemEnlW = 0xf4,
|
||||||
|
|
||||||
Attn = 0xf6,
|
Attn = 0xf6,
|
||||||
Crsel = 0xf7,
|
Crsel = 0xf7,
|
||||||
Exsel = 0xf8,
|
Exsel = 0xf8,
|
||||||
EraseEof = 0xf9,
|
EraseEof = 0xf9,
|
||||||
Play = 0xfa,
|
Play = 0xfa,
|
||||||
Zoom = 0xfb,
|
Zoom = 0xfb,
|
||||||
|
|
||||||
Pa1 = 0xfd,
|
Pa1 = 0xfd,
|
||||||
OemClear = 0xfe,
|
OemClear = 0xfe,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct State
|
struct State
|
||||||
|
@ -412,7 +412,7 @@ namespace DirectX
|
||||||
bool Reserved25 : 1;
|
bool Reserved25 : 1;
|
||||||
bool Pa1 : 1; // VK_PA1, 0xFD
|
bool Pa1 : 1; // VK_PA1, 0xFD
|
||||||
bool OemClear : 1; // VK_OEM_CLEAR, 0xFE
|
bool OemClear : 1; // VK_OEM_CLEAR, 0xFE
|
||||||
bool Reserved26: 1;
|
bool Reserved26 : 1;
|
||||||
|
|
||||||
bool __cdecl IsKeyDown(Keys key) const noexcept
|
bool __cdecl IsKeyDown(Keys key) const noexcept
|
||||||
{
|
{
|
||||||
|
@ -443,7 +443,7 @@ namespace DirectX
|
||||||
State released;
|
State released;
|
||||||
State pressed;
|
State pressed;
|
||||||
|
|
||||||
#pragma prefast(suppress: 26495, "Reset() performs the initialization")
|
#pragma prefast(suppress: 26495, "Reset() performs the initialization")
|
||||||
KeyboardStateTracker() noexcept { Reset(); }
|
KeyboardStateTracker() noexcept { Reset(); }
|
||||||
|
|
||||||
void __cdecl Update(const State& state) noexcept;
|
void __cdecl Update(const State& state) noexcept;
|
||||||
|
|
16
Inc/Model.h
16
Inc/Model.h
|
@ -51,11 +51,11 @@ namespace DirectX
|
||||||
// Model loading options
|
// Model loading options
|
||||||
enum ModelLoaderFlags : uint32_t
|
enum ModelLoaderFlags : uint32_t
|
||||||
{
|
{
|
||||||
ModelLoader_Default = 0x0,
|
ModelLoader_Default = 0x0,
|
||||||
ModelLoader_MaterialColorsSRGB = 0x1,
|
ModelLoader_MaterialColorsSRGB = 0x1,
|
||||||
ModelLoader_AllowLargeModels = 0x2,
|
ModelLoader_AllowLargeModels = 0x2,
|
||||||
ModelLoader_IncludeBones = 0x4,
|
ModelLoader_IncludeBones = 0x4,
|
||||||
ModelLoader_DisableSkinning = 0x8,
|
ModelLoader_DisableSkinning = 0x8,
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -66,13 +66,15 @@ namespace DirectX
|
||||||
parentIndex(c_Invalid),
|
parentIndex(c_Invalid),
|
||||||
childIndex(c_Invalid),
|
childIndex(c_Invalid),
|
||||||
siblingIndex(c_Invalid)
|
siblingIndex(c_Invalid)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ModelBone(uint32_t parent, uint32_t child, uint32_t sibling) noexcept :
|
ModelBone(uint32_t parent, uint32_t child, uint32_t sibling) noexcept :
|
||||||
parentIndex(parent),
|
parentIndex(parent),
|
||||||
childIndex(child),
|
childIndex(child),
|
||||||
siblingIndex(sibling)
|
siblingIndex(sibling)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t parentIndex;
|
uint32_t parentIndex;
|
||||||
uint32_t childIndex;
|
uint32_t childIndex;
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace DirectX
|
||||||
ButtonState xButton1;
|
ButtonState xButton1;
|
||||||
ButtonState xButton2;
|
ButtonState xButton2;
|
||||||
|
|
||||||
#pragma prefast(suppress: 26495, "Reset() performs the initialization")
|
#pragma prefast(suppress: 26495, "Reset() performs the initialization")
|
||||||
ButtonStateTracker() noexcept { Reset(); }
|
ButtonStateTracker() noexcept { Reset(); }
|
||||||
|
|
||||||
void __cdecl Update(const State& state) noexcept;
|
void __cdecl Update(const State& state) noexcept;
|
||||||
|
@ -130,9 +130,9 @@ namespace DirectX
|
||||||
void __cdecl SetWindow(HWND window);
|
void __cdecl SetWindow(HWND window);
|
||||||
static void __cdecl ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam);
|
static void __cdecl ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
#ifdef _GAMING_XBOX
|
#ifdef _GAMING_XBOX
|
||||||
static void __cdecl SetResolution(float scale);
|
static void __cdecl SetResolution(float scale);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
|
|
|
@ -71,7 +71,8 @@ namespace DirectX
|
||||||
size_t maxIndices = DefaultBatchSize * 3,
|
size_t maxIndices = DefaultBatchSize * 3,
|
||||||
size_t maxVertices = DefaultBatchSize)
|
size_t maxVertices = DefaultBatchSize)
|
||||||
: PrimitiveBatchBase(device, maxIndices, maxVertices, sizeof(TVertex))
|
: PrimitiveBatchBase(device, maxIndices, maxVertices, sizeof(TVertex))
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
PrimitiveBatch(PrimitiveBatch&&) = default;
|
PrimitiveBatch(PrimitiveBatch&&) = default;
|
||||||
PrimitiveBatch& operator= (PrimitiveBatch&&) = default;
|
PrimitiveBatch& operator= (PrimitiveBatch&&) = default;
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace DirectX
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convenience constructors converting from DXGI_SWAPCHAIN_DESC
|
// Convenience constructors converting from DXGI_SWAPCHAIN_DESC
|
||||||
#if defined(__dxgi_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
#if defined(__dxgi_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||||
RenderTargetState(
|
RenderTargetState(
|
||||||
_In_ const DXGI_SWAP_CHAIN_DESC* desc,
|
_In_ const DXGI_SWAP_CHAIN_DESC* desc,
|
||||||
_In_ DXGI_FORMAT dsFormat) noexcept
|
_In_ DXGI_FORMAT dsFormat) noexcept
|
||||||
|
@ -73,9 +73,9 @@ namespace DirectX
|
||||||
rtvFormats[0] = desc->BufferDesc.Format;
|
rtvFormats[0] = desc->BufferDesc.Format;
|
||||||
sampleDesc = desc->SampleDesc;
|
sampleDesc = desc->SampleDesc;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||||
RenderTargetState(
|
RenderTargetState(
|
||||||
_In_ const DXGI_SWAP_CHAIN_DESC1* desc,
|
_In_ const DXGI_SWAP_CHAIN_DESC1* desc,
|
||||||
_In_ DXGI_FORMAT dsFormat) noexcept
|
_In_ DXGI_FORMAT dsFormat) noexcept
|
||||||
|
@ -89,7 +89,7 @@ namespace DirectX
|
||||||
rtvFormats[0] = desc->Format;
|
rtvFormats[0] = desc->Format;
|
||||||
sampleDesc = desc->SampleDesc;
|
sampleDesc = desc->SampleDesc;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t sampleMask;
|
uint32_t sampleMask;
|
||||||
uint32_t numRenderTargets;
|
uint32_t numRenderTargets;
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace DirectX
|
||||||
void __cdecl Upload(
|
void __cdecl Upload(
|
||||||
_In_ ID3D12Resource* resource,
|
_In_ ID3D12Resource* resource,
|
||||||
const SharedGraphicsResource& buffer
|
const SharedGraphicsResource& buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
// Asynchronously generate mips from a resource.
|
// Asynchronously generate mips from a resource.
|
||||||
// Resource must be in the PIXEL_SHADER_RESOURCE state
|
// Resource must be in the PIXEL_SHADER_RESOURCE state
|
||||||
|
|
|
@ -453,27 +453,35 @@ namespace DirectX
|
||||||
{
|
{
|
||||||
Matrix() noexcept
|
Matrix() noexcept
|
||||||
: XMFLOAT4X4(1.f, 0, 0, 0,
|
: XMFLOAT4X4(1.f, 0, 0, 0,
|
||||||
0, 1.f, 0, 0,
|
0, 1.f, 0, 0,
|
||||||
0, 0, 1.f, 0,
|
0, 0, 1.f, 0,
|
||||||
0, 0, 0, 1.f) {}
|
0, 0, 0, 1.f)
|
||||||
|
{
|
||||||
|
}
|
||||||
constexpr Matrix(float m00, float m01, float m02, float m03,
|
constexpr Matrix(float m00, float m01, float m02, float m03,
|
||||||
float m10, float m11, float m12, float m13,
|
float m10, float m11, float m12, float m13,
|
||||||
float m20, float m21, float m22, float m23,
|
float m20, float m21, float m22, float m23,
|
||||||
float m30, float m31, float m32, float m33) noexcept
|
float m30, float m31, float m32, float m33) noexcept
|
||||||
: XMFLOAT4X4(m00, m01, m02, m03,
|
: XMFLOAT4X4(m00, m01, m02, m03,
|
||||||
m10, m11, m12, m13,
|
m10, m11, m12, m13,
|
||||||
m20, m21, m22, m23,
|
m20, m21, m22, m23,
|
||||||
m30, m31, m32, m33) {}
|
m30, m31, m32, m33)
|
||||||
|
{
|
||||||
|
}
|
||||||
explicit Matrix(const Vector3& r0, const Vector3& r1, const Vector3& r2) noexcept
|
explicit Matrix(const Vector3& r0, const Vector3& r1, const Vector3& r2) noexcept
|
||||||
: XMFLOAT4X4(r0.x, r0.y, r0.z, 0,
|
: XMFLOAT4X4(r0.x, r0.y, r0.z, 0,
|
||||||
r1.x, r1.y, r1.z, 0,
|
r1.x, r1.y, r1.z, 0,
|
||||||
r2.x, r2.y, r2.z, 0,
|
r2.x, r2.y, r2.z, 0,
|
||||||
0, 0, 0, 1.f) {}
|
0, 0, 0, 1.f)
|
||||||
|
{
|
||||||
|
}
|
||||||
explicit Matrix(const Vector4& r0, const Vector4& r1, const Vector4& r2, const Vector4& r3) noexcept
|
explicit Matrix(const Vector4& r0, const Vector4& r1, const Vector4& r2, const Vector4& r3) noexcept
|
||||||
: XMFLOAT4X4(r0.x, r0.y, r0.z, r0.w,
|
: XMFLOAT4X4(r0.x, r0.y, r0.z, r0.w,
|
||||||
r1.x, r1.y, r1.z, r1.w,
|
r1.x, r1.y, r1.z, r1.w,
|
||||||
r2.x, r2.y, r2.z, r2.w,
|
r2.x, r2.y, r2.z, r2.w,
|
||||||
r3.x, r3.y, r3.z, r3.w) {}
|
r3.x, r3.y, r3.z, r3.w)
|
||||||
|
{
|
||||||
|
}
|
||||||
Matrix(const XMFLOAT4X4& M) noexcept { memcpy(this, &M, sizeof(XMFLOAT4X4)); }
|
Matrix(const XMFLOAT4X4& M) noexcept { memcpy(this, &M, sizeof(XMFLOAT4X4)); }
|
||||||
Matrix(const XMFLOAT3X3& M) noexcept;
|
Matrix(const XMFLOAT3X3& M) noexcept;
|
||||||
Matrix(const XMFLOAT4X3& M) noexcept;
|
Matrix(const XMFLOAT4X3& M) noexcept;
|
||||||
|
@ -898,21 +906,29 @@ namespace DirectX
|
||||||
float maxDepth;
|
float maxDepth;
|
||||||
|
|
||||||
Viewport() noexcept :
|
Viewport() noexcept :
|
||||||
x(0.f), y(0.f), width(0.f), height(0.f), minDepth(0.f), maxDepth(1.f) {}
|
x(0.f), y(0.f), width(0.f), height(0.f), minDepth(0.f), maxDepth(1.f)
|
||||||
|
{
|
||||||
|
}
|
||||||
constexpr Viewport(float ix, float iy, float iw, float ih, float iminz = 0.f, float imaxz = 1.f) noexcept :
|
constexpr Viewport(float ix, float iy, float iw, float ih, float iminz = 0.f, float imaxz = 1.f) noexcept :
|
||||||
x(ix), y(iy), width(iw), height(ih), minDepth(iminz), maxDepth(imaxz) {}
|
x(ix), y(iy), width(iw), height(ih), minDepth(iminz), maxDepth(imaxz)
|
||||||
|
{
|
||||||
|
}
|
||||||
explicit Viewport(const RECT& rct) noexcept :
|
explicit Viewport(const RECT& rct) noexcept :
|
||||||
x(float(rct.left)), y(float(rct.top)),
|
x(float(rct.left)), y(float(rct.top)),
|
||||||
width(float(rct.right - rct.left)),
|
width(float(rct.right - rct.left)),
|
||||||
height(float(rct.bottom - rct.top)),
|
height(float(rct.bottom - rct.top)),
|
||||||
minDepth(0.f), maxDepth(1.f) {}
|
minDepth(0.f), maxDepth(1.f)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
||||||
// Direct3D 11 interop
|
// Direct3D 11 interop
|
||||||
explicit Viewport(const D3D11_VIEWPORT& vp) noexcept :
|
explicit Viewport(const D3D11_VIEWPORT& vp) noexcept :
|
||||||
x(vp.TopLeftX), y(vp.TopLeftY),
|
x(vp.TopLeftX), y(vp.TopLeftY),
|
||||||
width(vp.Width), height(vp.Height),
|
width(vp.Width), height(vp.Height),
|
||||||
minDepth(vp.MinDepth), maxDepth(vp.MaxDepth) {}
|
minDepth(vp.MinDepth), maxDepth(vp.MaxDepth)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
operator D3D11_VIEWPORT() noexcept { return *reinterpret_cast<const D3D11_VIEWPORT*>(this); }
|
operator D3D11_VIEWPORT() noexcept { return *reinterpret_cast<const D3D11_VIEWPORT*>(this); }
|
||||||
const D3D11_VIEWPORT* Get11() const noexcept { return reinterpret_cast<const D3D11_VIEWPORT*>(this); }
|
const D3D11_VIEWPORT* Get11() const noexcept { return reinterpret_cast<const D3D11_VIEWPORT*>(this); }
|
||||||
|
@ -924,7 +940,9 @@ namespace DirectX
|
||||||
explicit Viewport(const D3D12_VIEWPORT& vp) noexcept :
|
explicit Viewport(const D3D12_VIEWPORT& vp) noexcept :
|
||||||
x(vp.TopLeftX), y(vp.TopLeftY),
|
x(vp.TopLeftX), y(vp.TopLeftY),
|
||||||
width(vp.Width), height(vp.Height),
|
width(vp.Width), height(vp.Height),
|
||||||
minDepth(vp.MinDepth), maxDepth(vp.MaxDepth) {}
|
minDepth(vp.MinDepth), maxDepth(vp.MaxDepth)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
operator D3D12_VIEWPORT() noexcept { return *reinterpret_cast<const D3D12_VIEWPORT*>(this); }
|
operator D3D12_VIEWPORT() noexcept { return *reinterpret_cast<const D3D12_VIEWPORT*>(this); }
|
||||||
const D3D12_VIEWPORT* Get12() const noexcept { return reinterpret_cast<const D3D12_VIEWPORT*>(this); }
|
const D3D12_VIEWPORT* Get12() const noexcept { return reinterpret_cast<const D3D12_VIEWPORT*>(this); }
|
||||||
|
@ -954,9 +972,9 @@ namespace DirectX
|
||||||
void Unproject(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world, Vector3& result) const noexcept;
|
void Unproject(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world, Vector3& result) const noexcept;
|
||||||
|
|
||||||
// Static methods
|
// Static methods
|
||||||
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||||
static RECT __cdecl ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UINT backBufferHeight, int outputWidth, int outputHeight) noexcept;
|
static RECT __cdecl ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UINT backBufferHeight, int outputWidth, int outputHeight) noexcept;
|
||||||
#endif
|
#endif
|
||||||
static RECT __cdecl ComputeTitleSafeArea(UINT backBufferWidth, UINT backBufferHeight) noexcept;
|
static RECT __cdecl ComputeTitleSafeArea(UINT backBufferWidth, UINT backBufferHeight) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -976,9 +994,9 @@ namespace std
|
||||||
bool operator()(const DirectX::SimpleMath::Rectangle& r1, const DirectX::SimpleMath::Rectangle& r2) const noexcept
|
bool operator()(const DirectX::SimpleMath::Rectangle& r1, const DirectX::SimpleMath::Rectangle& r2) const noexcept
|
||||||
{
|
{
|
||||||
return ((r1.x < r2.x)
|
return ((r1.x < r2.x)
|
||||||
|| ((r1.x == r2.x) && (r1.y < r2.y))
|
|| ((r1.x == r2.x) && (r1.y < r2.y))
|
||||||
|| ((r1.x == r2.x) && (r1.y == r2.y) && (r1.width < r2.width))
|
|| ((r1.x == r2.x) && (r1.y == r2.y) && (r1.width < r2.width))
|
||||||
|| ((r1.x == r2.x) && (r1.y == r2.y) && (r1.width == r2.width) && (r1.height < r2.height)));
|
|| ((r1.x == r2.x) && (r1.y == r2.y) && (r1.width == r2.width) && (r1.height < r2.height)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -995,8 +1013,8 @@ namespace std
|
||||||
bool operator()(const DirectX::SimpleMath::Vector3& V1, const DirectX::SimpleMath::Vector3& V2) const noexcept
|
bool operator()(const DirectX::SimpleMath::Vector3& V1, const DirectX::SimpleMath::Vector3& V2) const noexcept
|
||||||
{
|
{
|
||||||
return ((V1.x < V2.x)
|
return ((V1.x < V2.x)
|
||||||
|| ((V1.x == V2.x) && (V1.y < V2.y))
|
|| ((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)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1005,9 +1023,9 @@ namespace std
|
||||||
bool operator()(const DirectX::SimpleMath::Vector4& V1, const DirectX::SimpleMath::Vector4& V2) const noexcept
|
bool operator()(const DirectX::SimpleMath::Vector4& V1, const DirectX::SimpleMath::Vector4& V2) const noexcept
|
||||||
{
|
{
|
||||||
return ((V1.x < V2.x)
|
return ((V1.x < V2.x)
|
||||||
|| ((V1.x == V2.x) && (V1.y < V2.y))
|
|| ((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.x == V2.x) && (V1.y == V2.y) && (V1.z == V2.z) && (V1.w < V2.w)));
|
|| ((V1.x == V2.x) && (V1.y == V2.y) && (V1.z == V2.z) && (V1.w < V2.w)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1041,9 +1059,9 @@ namespace std
|
||||||
bool operator()(const DirectX::SimpleMath::Plane& P1, const DirectX::SimpleMath::Plane& P2) const noexcept
|
bool operator()(const DirectX::SimpleMath::Plane& P1, const DirectX::SimpleMath::Plane& P2) const noexcept
|
||||||
{
|
{
|
||||||
return ((P1.x < P2.x)
|
return ((P1.x < P2.x)
|
||||||
|| ((P1.x == P2.x) && (P1.y < P2.y))
|
|| ((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.x == P2.x) && (P1.y == P2.y) && (P1.z == P2.z) && (P1.w < P2.w)));
|
|| ((P1.x == P2.x) && (P1.y == P2.y) && (P1.z == P2.z) && (P1.w < P2.w)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1052,9 +1070,9 @@ namespace std
|
||||||
bool operator()(const DirectX::SimpleMath::Quaternion& Q1, const DirectX::SimpleMath::Quaternion& Q2) const noexcept
|
bool operator()(const DirectX::SimpleMath::Quaternion& Q1, const DirectX::SimpleMath::Quaternion& Q2) const noexcept
|
||||||
{
|
{
|
||||||
return ((Q1.x < Q2.x)
|
return ((Q1.x < Q2.x)
|
||||||
|| ((Q1.x == Q2.x) && (Q1.y < Q2.y))
|
|| ((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.x == Q2.x) && (Q1.y == Q2.y) && (Q1.z == Q2.z) && (Q1.w < Q2.w)));
|
|| ((Q1.x == Q2.x) && (Q1.y == Q2.y) && (Q1.z == Q2.z) && (Q1.w < Q2.w)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1063,9 +1081,9 @@ namespace std
|
||||||
bool operator()(const DirectX::SimpleMath::Color& C1, const DirectX::SimpleMath::Color& C2) const noexcept
|
bool operator()(const DirectX::SimpleMath::Color& C1, const DirectX::SimpleMath::Color& C2) const noexcept
|
||||||
{
|
{
|
||||||
return ((C1.x < C2.x)
|
return ((C1.x < C2.x)
|
||||||
|| ((C1.x == C2.x) && (C1.y < C2.y))
|
|| ((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.x == C2.x) && (C1.y == C2.y) && (C1.z == C2.z) && (C1.w < C2.w)));
|
|| ((C1.x == C2.x) && (C1.y == C2.y) && (C1.z == C2.z) && (C1.w < C2.w)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1922,9 +1922,9 @@ inline bool Matrix::operator == (const Matrix& M) const noexcept
|
||||||
const XMVECTOR y4 = XMLoadFloat4(reinterpret_cast<const XMFLOAT4*>(&M._41));
|
const XMVECTOR y4 = XMLoadFloat4(reinterpret_cast<const XMFLOAT4*>(&M._41));
|
||||||
|
|
||||||
return (XMVector4Equal(x1, y1)
|
return (XMVector4Equal(x1, y1)
|
||||||
&& XMVector4Equal(x2, y2)
|
&& XMVector4Equal(x2, y2)
|
||||||
&& XMVector4Equal(x3, y3)
|
&& XMVector4Equal(x3, y3)
|
||||||
&& XMVector4Equal(x4, y4)) != 0;
|
&& XMVector4Equal(x4, y4)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Matrix::operator != (const Matrix& M) const noexcept
|
inline bool Matrix::operator != (const Matrix& M) const noexcept
|
||||||
|
@ -1941,9 +1941,9 @@ inline bool Matrix::operator != (const Matrix& M) const noexcept
|
||||||
const XMVECTOR y4 = XMLoadFloat4(reinterpret_cast<const XMFLOAT4*>(&M._41));
|
const XMVECTOR y4 = XMLoadFloat4(reinterpret_cast<const XMFLOAT4*>(&M._41));
|
||||||
|
|
||||||
return (XMVector4NotEqual(x1, y1)
|
return (XMVector4NotEqual(x1, y1)
|
||||||
|| XMVector4NotEqual(x2, y2)
|
|| XMVector4NotEqual(x2, y2)
|
||||||
|| XMVector4NotEqual(x3, y3)
|
|| XMVector4NotEqual(x3, y3)
|
||||||
|| XMVector4NotEqual(x4, y4)) != 0;
|
|| XMVector4NotEqual(x4, y4)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -3727,15 +3727,15 @@ inline bool Ray::Intersects(const Plane& plane, _Out_ float& Dist) const noexcep
|
||||||
inline bool Viewport::operator == (const Viewport& vp) const noexcept
|
inline bool Viewport::operator == (const Viewport& vp) const noexcept
|
||||||
{
|
{
|
||||||
return (x == vp.x && y == vp.y
|
return (x == vp.x && y == vp.y
|
||||||
&& width == vp.width && height == vp.height
|
&& width == vp.width && height == vp.height
|
||||||
&& minDepth == vp.minDepth && maxDepth == vp.maxDepth);
|
&& minDepth == vp.minDepth && maxDepth == vp.maxDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Viewport::operator != (const Viewport& vp) const noexcept
|
inline bool Viewport::operator != (const Viewport& vp) const noexcept
|
||||||
{
|
{
|
||||||
return (x != vp.x || y != vp.y
|
return (x != vp.x || y != vp.y
|
||||||
|| width != vp.width || height != vp.height
|
|| width != vp.width || height != vp.height
|
||||||
|| minDepth != vp.minDepth || maxDepth != vp.maxDepth);
|
|| minDepth != vp.minDepth || maxDepth != vp.maxDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
|
@ -129,10 +129,10 @@ namespace DirectX
|
||||||
void XM_CALLCONV Draw(D3D12_GPU_DESCRIPTOR_HANDLE textureSRV, XMUINT2 const& textureSize, 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);
|
void XM_CALLCONV Draw(D3D12_GPU_DESCRIPTOR_HANDLE textureSRV, XMUINT2 const& textureSize, 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
|
// Rotation mode to be applied to the sprite transformation
|
||||||
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||||
void __cdecl SetRotation(DXGI_MODE_ROTATION mode);
|
void __cdecl SetRotation(DXGI_MODE_ROTATION mode);
|
||||||
DXGI_MODE_ROTATION __cdecl GetRotation() const noexcept;
|
DXGI_MODE_ROTATION __cdecl GetRotation() const noexcept;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set viewport for sprite transformation
|
// Set viewport for sprite transformation
|
||||||
void __cdecl SetViewport(const D3D12_VIEWPORT& viewPort);
|
void __cdecl SetViewport(const D3D12_VIEWPORT& viewPort);
|
||||||
|
|
|
@ -35,7 +35,8 @@ namespace DirectX
|
||||||
|
|
||||||
VertexPosition(XMFLOAT3 const& iposition) noexcept
|
VertexPosition(XMFLOAT3 const& iposition) noexcept
|
||||||
: position(iposition)
|
: position(iposition)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VertexPosition(FXMVECTOR iposition) noexcept
|
VertexPosition(FXMVECTOR iposition) noexcept
|
||||||
{
|
{
|
||||||
|
@ -66,7 +67,8 @@ namespace DirectX
|
||||||
VertexPositionColor(XMFLOAT3 const& iposition, XMFLOAT4 const& icolor) noexcept
|
VertexPositionColor(XMFLOAT3 const& iposition, XMFLOAT4 const& icolor) noexcept
|
||||||
: position(iposition),
|
: position(iposition),
|
||||||
color(icolor)
|
color(icolor)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VertexPositionColor(FXMVECTOR iposition, FXMVECTOR icolor) noexcept
|
VertexPositionColor(FXMVECTOR iposition, FXMVECTOR icolor) noexcept
|
||||||
{
|
{
|
||||||
|
@ -99,7 +101,8 @@ namespace DirectX
|
||||||
VertexPositionTexture(XMFLOAT3 const& iposition, XMFLOAT2 const& itextureCoordinate) noexcept
|
VertexPositionTexture(XMFLOAT3 const& iposition, XMFLOAT2 const& itextureCoordinate) noexcept
|
||||||
: position(iposition),
|
: position(iposition),
|
||||||
textureCoordinate(itextureCoordinate)
|
textureCoordinate(itextureCoordinate)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VertexPositionTexture(FXMVECTOR iposition, FXMVECTOR itextureCoordinate) noexcept
|
VertexPositionTexture(FXMVECTOR iposition, FXMVECTOR itextureCoordinate) noexcept
|
||||||
{
|
{
|
||||||
|
@ -133,10 +136,11 @@ namespace DirectX
|
||||||
XMFLOAT3 const& iposition,
|
XMFLOAT3 const& iposition,
|
||||||
XMFLOAT2 const& itextureCoordinate0,
|
XMFLOAT2 const& itextureCoordinate0,
|
||||||
XMFLOAT2 const& itextureCoordinate1) noexcept
|
XMFLOAT2 const& itextureCoordinate1) noexcept
|
||||||
: position(iposition),
|
: position(iposition),
|
||||||
textureCoordinate0(itextureCoordinate0),
|
textureCoordinate0(itextureCoordinate0),
|
||||||
textureCoordinate1(itextureCoordinate1)
|
textureCoordinate1(itextureCoordinate1)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VertexPositionDualTexture(
|
VertexPositionDualTexture(
|
||||||
FXMVECTOR iposition,
|
FXMVECTOR iposition,
|
||||||
|
@ -174,7 +178,8 @@ namespace DirectX
|
||||||
VertexPositionNormal(XMFLOAT3 const& iposition, XMFLOAT3 const& inormal) noexcept
|
VertexPositionNormal(XMFLOAT3 const& iposition, XMFLOAT3 const& inormal) noexcept
|
||||||
: position(iposition),
|
: position(iposition),
|
||||||
normal(inormal)
|
normal(inormal)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VertexPositionNormal(FXMVECTOR iposition, FXMVECTOR inormal) noexcept
|
VertexPositionNormal(FXMVECTOR iposition, FXMVECTOR inormal) noexcept
|
||||||
{
|
{
|
||||||
|
@ -208,7 +213,8 @@ namespace DirectX
|
||||||
: position(iposition),
|
: position(iposition),
|
||||||
color(icolor),
|
color(icolor),
|
||||||
textureCoordinate(itextureCoordinate)
|
textureCoordinate(itextureCoordinate)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VertexPositionColorTexture(FXMVECTOR iposition, FXMVECTOR icolor, FXMVECTOR itextureCoordinate) noexcept
|
VertexPositionColorTexture(FXMVECTOR iposition, FXMVECTOR icolor, FXMVECTOR itextureCoordinate) noexcept
|
||||||
{
|
{
|
||||||
|
@ -244,7 +250,8 @@ namespace DirectX
|
||||||
: position(iposition),
|
: position(iposition),
|
||||||
normal(inormal),
|
normal(inormal),
|
||||||
color(icolor)
|
color(icolor)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VertexPositionNormalColor(FXMVECTOR iposition, FXMVECTOR inormal, FXMVECTOR icolor) noexcept
|
VertexPositionNormalColor(FXMVECTOR iposition, FXMVECTOR inormal, FXMVECTOR icolor) noexcept
|
||||||
{
|
{
|
||||||
|
@ -280,7 +287,8 @@ namespace DirectX
|
||||||
: position(iposition),
|
: position(iposition),
|
||||||
normal(inormal),
|
normal(inormal),
|
||||||
textureCoordinate(itextureCoordinate)
|
textureCoordinate(itextureCoordinate)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VertexPositionNormalTexture(FXMVECTOR iposition, FXMVECTOR inormal, FXMVECTOR itextureCoordinate) noexcept
|
VertexPositionNormalTexture(FXMVECTOR iposition, FXMVECTOR inormal, FXMVECTOR itextureCoordinate) noexcept
|
||||||
{
|
{
|
||||||
|
@ -317,11 +325,12 @@ namespace DirectX
|
||||||
XMFLOAT3 const& inormal,
|
XMFLOAT3 const& inormal,
|
||||||
XMFLOAT4 const& icolor,
|
XMFLOAT4 const& icolor,
|
||||||
XMFLOAT2 const& itextureCoordinate) noexcept
|
XMFLOAT2 const& itextureCoordinate) noexcept
|
||||||
: position(iposition),
|
: position(iposition),
|
||||||
normal(inormal),
|
normal(inormal),
|
||||||
color(icolor),
|
color(icolor),
|
||||||
textureCoordinate(itextureCoordinate)
|
textureCoordinate(itextureCoordinate)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VertexPositionNormalColorTexture(FXMVECTOR iposition, FXMVECTOR inormal, FXMVECTOR icolor, CXMVECTOR itextureCoordinate) noexcept
|
VertexPositionNormalColorTexture(FXMVECTOR iposition, FXMVECTOR inormal, FXMVECTOR icolor, CXMVECTOR itextureCoordinate) noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,14 +38,14 @@ namespace DirectX
|
||||||
{
|
{
|
||||||
enum WIC_LOADER_FLAGS : uint32_t
|
enum WIC_LOADER_FLAGS : uint32_t
|
||||||
{
|
{
|
||||||
WIC_LOADER_DEFAULT = 0,
|
WIC_LOADER_DEFAULT = 0,
|
||||||
WIC_LOADER_FORCE_SRGB = 0x1,
|
WIC_LOADER_FORCE_SRGB = 0x1,
|
||||||
WIC_LOADER_IGNORE_SRGB = 0x2,
|
WIC_LOADER_IGNORE_SRGB = 0x2,
|
||||||
WIC_LOADER_SRGB_DEFAULT = 0x4,
|
WIC_LOADER_SRGB_DEFAULT = 0x4,
|
||||||
WIC_LOADER_MIP_AUTOGEN = 0x8,
|
WIC_LOADER_MIP_AUTOGEN = 0x8,
|
||||||
WIC_LOADER_MIP_RESERVE = 0x10,
|
WIC_LOADER_MIP_RESERVE = 0x10,
|
||||||
WIC_LOADER_FIT_POW2 = 0x20,
|
WIC_LOADER_FIT_POW2 = 0x20,
|
||||||
WIC_LOADER_MAKE_SQUARE = 0x40,
|
WIC_LOADER_MAKE_SQUARE = 0x40,
|
||||||
WIC_LOADER_FORCE_RGBA32 = 0x80,
|
WIC_LOADER_FORCE_RGBA32 = 0x80,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ namespace DirectX
|
||||||
// Standard version with resource upload
|
// Standard version with resource upload
|
||||||
HRESULT __cdecl CreateWICTextureFromMemory(
|
HRESULT __cdecl CreateWICTextureFromMemory(
|
||||||
_In_ ID3D12Device* d3dDevice,
|
_In_ ID3D12Device* d3dDevice,
|
||||||
ResourceUploadBatch& resourceUpload,
|
ResourceUploadBatch& resourceUpload,
|
||||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||||
size_t wicDataSize,
|
size_t wicDataSize,
|
||||||
_Outptr_ ID3D12Resource** texture,
|
_Outptr_ ID3D12Resource** texture,
|
||||||
|
|
|
@ -39,13 +39,13 @@ namespace DirectX
|
||||||
static_assert(alignment > 8, "AlignedNew is only useful for types with > 8 byte alignment. Did you forget a __declspec(align) on TDerived?");
|
static_assert(alignment > 8, "AlignedNew is only useful for types with > 8 byte alignment. Did you forget a __declspec(align) on TDerived?");
|
||||||
static_assert(((alignment - 1) & alignment) == 0, "AlignedNew only works with power of two alignment");
|
static_assert(((alignment - 1) & alignment) == 0, "AlignedNew only works with power of two alignment");
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
void* ptr = _aligned_malloc(size, alignment);
|
void* ptr = _aligned_malloc(size, alignment);
|
||||||
#else
|
#else
|
||||||
// This C++17 Standard Library function is currently NOT
|
// This C++17 Standard Library function is currently NOT
|
||||||
// implemented for the Microsoft Standard C++ Library.
|
// implemented for the Microsoft Standard C++ Library.
|
||||||
void* ptr = aligned_alloc(alignment, size);
|
void* ptr = aligned_alloc(alignment, size);
|
||||||
#endif
|
#endif
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
|
||||||
|
@ -56,11 +56,11 @@ namespace DirectX
|
||||||
// Free aligned memory.
|
// Free aligned memory.
|
||||||
static void operator delete (void* ptr)
|
static void operator delete (void* ptr)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
_aligned_free(ptr);
|
_aligned_free(ptr);
|
||||||
#else
|
#else
|
||||||
free(ptr);
|
free(ptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ namespace DirectX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void operator delete[](void* ptr)
|
static void operator delete[](void* ptr)
|
||||||
{
|
{
|
||||||
operator delete(ptr);
|
operator delete(ptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,49 +68,50 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettAlphaTestEffect_VSAlphaTest.inc"
|
#include "XboxGamingScarlettAlphaTestEffect_VSAlphaTest.inc"
|
||||||
#include "XboxGamingScarlettAlphaTestEffect_VSAlphaTestNoFog.inc"
|
#include "XboxGamingScarlettAlphaTestEffect_VSAlphaTestNoFog.inc"
|
||||||
#include "XboxGamingScarlettAlphaTestEffect_VSAlphaTestVc.inc"
|
#include "XboxGamingScarlettAlphaTestEffect_VSAlphaTestVc.inc"
|
||||||
#include "XboxGamingScarlettAlphaTestEffect_VSAlphaTestVcNoFog.inc"
|
#include "XboxGamingScarlettAlphaTestEffect_VSAlphaTestVcNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettAlphaTestEffect_PSAlphaTestLtGt.inc"
|
#include "XboxGamingScarlettAlphaTestEffect_PSAlphaTestLtGt.inc"
|
||||||
#include "XboxGamingScarlettAlphaTestEffect_PSAlphaTestLtGtNoFog.inc"
|
#include "XboxGamingScarlettAlphaTestEffect_PSAlphaTestLtGtNoFog.inc"
|
||||||
#include "XboxGamingScarlettAlphaTestEffect_PSAlphaTestEqNe.inc"
|
#include "XboxGamingScarlettAlphaTestEffect_PSAlphaTestEqNe.inc"
|
||||||
#include "XboxGamingScarlettAlphaTestEffect_PSAlphaTestEqNeNoFog.inc"
|
#include "XboxGamingScarlettAlphaTestEffect_PSAlphaTestEqNeNoFog.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneAlphaTestEffect_VSAlphaTest.inc"
|
#include "XboxGamingXboxOneAlphaTestEffect_VSAlphaTest.inc"
|
||||||
#include "XboxGamingXboxOneAlphaTestEffect_VSAlphaTestNoFog.inc"
|
#include "XboxGamingXboxOneAlphaTestEffect_VSAlphaTestNoFog.inc"
|
||||||
#include "XboxGamingXboxOneAlphaTestEffect_VSAlphaTestVc.inc"
|
#include "XboxGamingXboxOneAlphaTestEffect_VSAlphaTestVc.inc"
|
||||||
#include "XboxGamingXboxOneAlphaTestEffect_VSAlphaTestVcNoFog.inc"
|
#include "XboxGamingXboxOneAlphaTestEffect_VSAlphaTestVcNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneAlphaTestEffect_PSAlphaTestLtGt.inc"
|
#include "XboxGamingXboxOneAlphaTestEffect_PSAlphaTestLtGt.inc"
|
||||||
#include "XboxGamingXboxOneAlphaTestEffect_PSAlphaTestLtGtNoFog.inc"
|
#include "XboxGamingXboxOneAlphaTestEffect_PSAlphaTestLtGtNoFog.inc"
|
||||||
#include "XboxGamingXboxOneAlphaTestEffect_PSAlphaTestEqNe.inc"
|
#include "XboxGamingXboxOneAlphaTestEffect_PSAlphaTestEqNe.inc"
|
||||||
#include "XboxGamingXboxOneAlphaTestEffect_PSAlphaTestEqNeNoFog.inc"
|
#include "XboxGamingXboxOneAlphaTestEffect_PSAlphaTestEqNeNoFog.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneAlphaTestEffect_VSAlphaTest.inc"
|
#include "XboxOneAlphaTestEffect_VSAlphaTest.inc"
|
||||||
#include "XboxOneAlphaTestEffect_VSAlphaTestNoFog.inc"
|
#include "XboxOneAlphaTestEffect_VSAlphaTestNoFog.inc"
|
||||||
#include "XboxOneAlphaTestEffect_VSAlphaTestVc.inc"
|
#include "XboxOneAlphaTestEffect_VSAlphaTestVc.inc"
|
||||||
#include "XboxOneAlphaTestEffect_VSAlphaTestVcNoFog.inc"
|
#include "XboxOneAlphaTestEffect_VSAlphaTestVcNoFog.inc"
|
||||||
|
|
||||||
#include "XboxOneAlphaTestEffect_PSAlphaTestLtGt.inc"
|
#include "XboxOneAlphaTestEffect_PSAlphaTestLtGt.inc"
|
||||||
#include "XboxOneAlphaTestEffect_PSAlphaTestLtGtNoFog.inc"
|
#include "XboxOneAlphaTestEffect_PSAlphaTestLtGtNoFog.inc"
|
||||||
#include "XboxOneAlphaTestEffect_PSAlphaTestEqNe.inc"
|
#include "XboxOneAlphaTestEffect_PSAlphaTestEqNe.inc"
|
||||||
#include "XboxOneAlphaTestEffect_PSAlphaTestEqNeNoFog.inc"
|
#include "XboxOneAlphaTestEffect_PSAlphaTestEqNeNoFog.inc"
|
||||||
#else
|
#else
|
||||||
#include "AlphaTestEffect_VSAlphaTest.inc"
|
#include "AlphaTestEffect_VSAlphaTest.inc"
|
||||||
#include "AlphaTestEffect_VSAlphaTestNoFog.inc"
|
#include "AlphaTestEffect_VSAlphaTestNoFog.inc"
|
||||||
#include "AlphaTestEffect_VSAlphaTestVc.inc"
|
#include "AlphaTestEffect_VSAlphaTestVc.inc"
|
||||||
#include "AlphaTestEffect_VSAlphaTestVcNoFog.inc"
|
#include "AlphaTestEffect_VSAlphaTestVcNoFog.inc"
|
||||||
|
|
||||||
#include "AlphaTestEffect_PSAlphaTestLtGt.inc"
|
#include "AlphaTestEffect_PSAlphaTestLtGt.inc"
|
||||||
#include "AlphaTestEffect_PSAlphaTestLtGtNoFog.inc"
|
#include "AlphaTestEffect_PSAlphaTestLtGtNoFog.inc"
|
||||||
#include "AlphaTestEffect_PSAlphaTestEqNe.inc"
|
#include "AlphaTestEffect_PSAlphaTestEqNe.inc"
|
||||||
#include "AlphaTestEffect_PSAlphaTestEqNeNoFog.inc"
|
#include "AlphaTestEffect_PSAlphaTestEqNeNoFog.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +164,7 @@ const int EffectBase<AlphaTestEffectTraits>::PixelShaderIndices[] =
|
||||||
2, // eq/ne, vertex color
|
2, // eq/ne, vertex color
|
||||||
3, // eq/ne, vertex color, no fog
|
3, // eq/ne, vertex color, no fog
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
// Global pool of per-device AlphaTestEffect resources.
|
// Global pool of per-device AlphaTestEffect resources.
|
||||||
template<>
|
template<>
|
||||||
|
@ -176,10 +177,10 @@ AlphaTestEffect::Impl::Impl(
|
||||||
const EffectPipelineStateDescription& pipelineDescription,
|
const EffectPipelineStateDescription& pipelineDescription,
|
||||||
D3D12_COMPARISON_FUNC alphaFunction)
|
D3D12_COMPARISON_FUNC alphaFunction)
|
||||||
: EffectBase(device),
|
: EffectBase(device),
|
||||||
mAlphaFunction(alphaFunction),
|
mAlphaFunction(alphaFunction),
|
||||||
referenceAlpha(0),
|
referenceAlpha(0),
|
||||||
texture{},
|
texture{},
|
||||||
textureSampler{}
|
textureSampler{}
|
||||||
{
|
{
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<AlphaTestEffectTraits>::VertexShaderIndices)) == AlphaTestEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<AlphaTestEffectTraits>::VertexShaderIndices)) == AlphaTestEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<AlphaTestEffectTraits>::VertexShaderBytecode)) == AlphaTestEffectTraits::VertexShaderCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<AlphaTestEffectTraits>::VertexShaderBytecode)) == AlphaTestEffectTraits::VertexShaderCount, "array/max mismatch");
|
||||||
|
@ -298,66 +299,66 @@ void AlphaTestEffect::Impl::Apply(_In_ ID3D12GraphicsCommandList* commandList)
|
||||||
constexpr float threshold = 0.5f / 255.0f;
|
constexpr float threshold = 0.5f / 255.0f;
|
||||||
|
|
||||||
// What to do if the alpha comparison passes or fails. Positive accepts the pixel, negative clips it.
|
// 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 selectIfTrue = { { { 1, -1 } } };
|
||||||
static const XMVECTORF32 selectIfFalse = { { { -1, 1 } } };
|
static const XMVECTORF32 selectIfFalse = { { { -1, 1 } } };
|
||||||
static const XMVECTORF32 selectNever = { { { -1, -1 } } };
|
static const XMVECTORF32 selectNever = { { { -1, -1 } } };
|
||||||
static const XMVECTORF32 selectAlways = { { { 1, 1 } } };
|
static const XMVECTORF32 selectAlways = { { { 1, 1 } } };
|
||||||
|
|
||||||
float compareTo;
|
float compareTo;
|
||||||
XMVECTOR resultSelector;
|
XMVECTOR resultSelector;
|
||||||
|
|
||||||
switch (mAlphaFunction)
|
switch (mAlphaFunction)
|
||||||
{
|
{
|
||||||
case D3D12_COMPARISON_FUNC_LESS:
|
case D3D12_COMPARISON_FUNC_LESS:
|
||||||
// Shader will evaluate: clip((a < x) ? z : w)
|
// Shader will evaluate: clip((a < x) ? z : w)
|
||||||
compareTo = reference - threshold;
|
compareTo = reference - threshold;
|
||||||
resultSelector = selectIfTrue;
|
resultSelector = selectIfTrue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_COMPARISON_FUNC_LESS_EQUAL:
|
case D3D12_COMPARISON_FUNC_LESS_EQUAL:
|
||||||
// Shader will evaluate: clip((a < x) ? z : w)
|
// Shader will evaluate: clip((a < x) ? z : w)
|
||||||
compareTo = reference + threshold;
|
compareTo = reference + threshold;
|
||||||
resultSelector = selectIfTrue;
|
resultSelector = selectIfTrue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_COMPARISON_FUNC_GREATER_EQUAL:
|
case D3D12_COMPARISON_FUNC_GREATER_EQUAL:
|
||||||
// Shader will evaluate: clip((a < x) ? z : w)
|
// Shader will evaluate: clip((a < x) ? z : w)
|
||||||
compareTo = reference - threshold;
|
compareTo = reference - threshold;
|
||||||
resultSelector = selectIfFalse;
|
resultSelector = selectIfFalse;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_COMPARISON_FUNC_GREATER:
|
case D3D12_COMPARISON_FUNC_GREATER:
|
||||||
// Shader will evaluate: clip((a < x) ? z : w)
|
// Shader will evaluate: clip((a < x) ? z : w)
|
||||||
compareTo = reference + threshold;
|
compareTo = reference + threshold;
|
||||||
resultSelector = selectIfFalse;
|
resultSelector = selectIfFalse;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_COMPARISON_FUNC_EQUAL:
|
case D3D12_COMPARISON_FUNC_EQUAL:
|
||||||
// Shader will evaluate: clip((abs(a - x) < y) ? z : w)
|
// Shader will evaluate: clip((abs(a - x) < y) ? z : w)
|
||||||
compareTo = reference;
|
compareTo = reference;
|
||||||
resultSelector = selectIfTrue;
|
resultSelector = selectIfTrue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_COMPARISON_FUNC_NOT_EQUAL:
|
case D3D12_COMPARISON_FUNC_NOT_EQUAL:
|
||||||
// Shader will evaluate: clip((abs(a - x) < y) ? z : w)
|
// Shader will evaluate: clip((abs(a - x) < y) ? z : w)
|
||||||
compareTo = reference;
|
compareTo = reference;
|
||||||
resultSelector = selectIfFalse;
|
resultSelector = selectIfFalse;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_COMPARISON_FUNC_NEVER:
|
case D3D12_COMPARISON_FUNC_NEVER:
|
||||||
// Shader will evaluate: clip((a < x) ? z : w)
|
// Shader will evaluate: clip((a < x) ? z : w)
|
||||||
compareTo = 0;
|
compareTo = 0;
|
||||||
resultSelector = selectNever;
|
resultSelector = selectNever;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_COMPARISON_FUNC_ALWAYS:
|
case D3D12_COMPARISON_FUNC_ALWAYS:
|
||||||
// Shader will evaluate: clip((a < x) ? z : w)
|
// Shader will evaluate: clip((a < x) ? z : w)
|
||||||
compareTo = 0;
|
compareTo = 0;
|
||||||
resultSelector = selectAlways;
|
resultSelector = selectAlways;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Unknown alpha test function");
|
throw std::runtime_error("Unknown alpha test function");
|
||||||
}
|
}
|
||||||
|
|
||||||
// x = compareTo, y = threshold, zw = resultSelector.
|
// x = compareTo, y = threshold, zw = resultSelector.
|
||||||
|
|
|
@ -78,177 +78,178 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasic.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasic.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicNoFog.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicNoFog.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVc.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVc.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVcNoFog.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVcNoFog.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicTx.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicTx.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicTxNoFog.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicTxNoFog.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicTxVc.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicTxVc.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicTxVcNoFog.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicTxVcNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLighting.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLighting.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingVc.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingVc.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingTx.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingTx.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingTxVc.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingTxVc.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLighting.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLighting.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingVc.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingVc.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingTx.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingTx.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingTxVc.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingTxVc.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingBn.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingBn.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingVcBn.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingVcBn.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingTxBn.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingTxBn.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingTxVcBn.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicVertexLightingTxVcBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingBn.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingBn.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingVcBn.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingVcBn.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingTxBn.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingTxBn.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingTxVcBn.inc"
|
#include "XboxGamingScarlettBasicEffect_VSBasicPixelLightingTxVcBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasic.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasic.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasicNoFog.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasicNoFog.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasicTx.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasicTx.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasicTxNoFog.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasicTxNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasicVertexLighting.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasicVertexLighting.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasicVertexLightingNoFog.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasicVertexLightingNoFog.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasicVertexLightingTx.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasicVertexLightingTx.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasicVertexLightingTxNoFog.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasicVertexLightingTxNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasicPixelLighting.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasicPixelLighting.inc"
|
||||||
#include "XboxGamingScarlettBasicEffect_PSBasicPixelLightingTx.inc"
|
#include "XboxGamingScarlettBasicEffect_PSBasicPixelLightingTx.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasic.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasic.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicNoFog.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicNoFog.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVc.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVc.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVcNoFog.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVcNoFog.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicTx.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicTx.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicTxNoFog.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicTxNoFog.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicTxVc.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicTxVc.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicTxVcNoFog.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicTxVcNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLighting.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLighting.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingVc.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingVc.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingTx.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingTx.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingTxVc.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingTxVc.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLighting.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLighting.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingVc.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingVc.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingTx.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingTx.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingTxVc.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingTxVc.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingBn.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingBn.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingVcBn.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingVcBn.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingTxBn.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingTxBn.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingTxVcBn.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicVertexLightingTxVcBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingBn.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingBn.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingVcBn.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingVcBn.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingTxBn.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingTxBn.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingTxVcBn.inc"
|
#include "XboxGamingXboxOneBasicEffect_VSBasicPixelLightingTxVcBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasic.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasic.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasicNoFog.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasicNoFog.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasicTx.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasicTx.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasicTxNoFog.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasicTxNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasicVertexLighting.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasicVertexLighting.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasicVertexLightingNoFog.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasicVertexLightingNoFog.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasicVertexLightingTx.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasicVertexLightingTx.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasicVertexLightingTxNoFog.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasicVertexLightingTxNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasicPixelLighting.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasicPixelLighting.inc"
|
||||||
#include "XboxGamingXboxOneBasicEffect_PSBasicPixelLightingTx.inc"
|
#include "XboxGamingXboxOneBasicEffect_PSBasicPixelLightingTx.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneBasicEffect_VSBasic.inc"
|
#include "XboxOneBasicEffect_VSBasic.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicNoFog.inc"
|
#include "XboxOneBasicEffect_VSBasicNoFog.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicVc.inc"
|
#include "XboxOneBasicEffect_VSBasicVc.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicVcNoFog.inc"
|
#include "XboxOneBasicEffect_VSBasicVcNoFog.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicTx.inc"
|
#include "XboxOneBasicEffect_VSBasicTx.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicTxNoFog.inc"
|
#include "XboxOneBasicEffect_VSBasicTxNoFog.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicTxVc.inc"
|
#include "XboxOneBasicEffect_VSBasicTxVc.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicTxVcNoFog.inc"
|
#include "XboxOneBasicEffect_VSBasicTxVcNoFog.inc"
|
||||||
|
|
||||||
#include "XboxOneBasicEffect_VSBasicVertexLighting.inc"
|
#include "XboxOneBasicEffect_VSBasicVertexLighting.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicVertexLightingVc.inc"
|
#include "XboxOneBasicEffect_VSBasicVertexLightingVc.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicVertexLightingTx.inc"
|
#include "XboxOneBasicEffect_VSBasicVertexLightingTx.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicVertexLightingTxVc.inc"
|
#include "XboxOneBasicEffect_VSBasicVertexLightingTxVc.inc"
|
||||||
|
|
||||||
#include "XboxOneBasicEffect_VSBasicPixelLighting.inc"
|
#include "XboxOneBasicEffect_VSBasicPixelLighting.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicPixelLightingVc.inc"
|
#include "XboxOneBasicEffect_VSBasicPixelLightingVc.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicPixelLightingTx.inc"
|
#include "XboxOneBasicEffect_VSBasicPixelLightingTx.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicPixelLightingTxVc.inc"
|
#include "XboxOneBasicEffect_VSBasicPixelLightingTxVc.inc"
|
||||||
|
|
||||||
#include "XboxOneBasicEffect_VSBasicVertexLightingBn.inc"
|
#include "XboxOneBasicEffect_VSBasicVertexLightingBn.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicVertexLightingVcBn.inc"
|
#include "XboxOneBasicEffect_VSBasicVertexLightingVcBn.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicVertexLightingTxBn.inc"
|
#include "XboxOneBasicEffect_VSBasicVertexLightingTxBn.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicVertexLightingTxVcBn.inc"
|
#include "XboxOneBasicEffect_VSBasicVertexLightingTxVcBn.inc"
|
||||||
|
|
||||||
#include "XboxOneBasicEffect_VSBasicPixelLightingBn.inc"
|
#include "XboxOneBasicEffect_VSBasicPixelLightingBn.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicPixelLightingVcBn.inc"
|
#include "XboxOneBasicEffect_VSBasicPixelLightingVcBn.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicPixelLightingTxBn.inc"
|
#include "XboxOneBasicEffect_VSBasicPixelLightingTxBn.inc"
|
||||||
#include "XboxOneBasicEffect_VSBasicPixelLightingTxVcBn.inc"
|
#include "XboxOneBasicEffect_VSBasicPixelLightingTxVcBn.inc"
|
||||||
|
|
||||||
#include "XboxOneBasicEffect_PSBasic.inc"
|
#include "XboxOneBasicEffect_PSBasic.inc"
|
||||||
#include "XboxOneBasicEffect_PSBasicNoFog.inc"
|
#include "XboxOneBasicEffect_PSBasicNoFog.inc"
|
||||||
#include "XboxOneBasicEffect_PSBasicTx.inc"
|
#include "XboxOneBasicEffect_PSBasicTx.inc"
|
||||||
#include "XboxOneBasicEffect_PSBasicTxNoFog.inc"
|
#include "XboxOneBasicEffect_PSBasicTxNoFog.inc"
|
||||||
|
|
||||||
#include "XboxOneBasicEffect_PSBasicVertexLighting.inc"
|
#include "XboxOneBasicEffect_PSBasicVertexLighting.inc"
|
||||||
#include "XboxOneBasicEffect_PSBasicVertexLightingNoFog.inc"
|
#include "XboxOneBasicEffect_PSBasicVertexLightingNoFog.inc"
|
||||||
#include "XboxOneBasicEffect_PSBasicVertexLightingTx.inc"
|
#include "XboxOneBasicEffect_PSBasicVertexLightingTx.inc"
|
||||||
#include "XboxOneBasicEffect_PSBasicVertexLightingTxNoFog.inc"
|
#include "XboxOneBasicEffect_PSBasicVertexLightingTxNoFog.inc"
|
||||||
|
|
||||||
#include "XboxOneBasicEffect_PSBasicPixelLighting.inc"
|
#include "XboxOneBasicEffect_PSBasicPixelLighting.inc"
|
||||||
#include "XboxOneBasicEffect_PSBasicPixelLightingTx.inc"
|
#include "XboxOneBasicEffect_PSBasicPixelLightingTx.inc"
|
||||||
#else
|
#else
|
||||||
#include "BasicEffect_VSBasic.inc"
|
#include "BasicEffect_VSBasic.inc"
|
||||||
#include "BasicEffect_VSBasicNoFog.inc"
|
#include "BasicEffect_VSBasicNoFog.inc"
|
||||||
#include "BasicEffect_VSBasicVc.inc"
|
#include "BasicEffect_VSBasicVc.inc"
|
||||||
#include "BasicEffect_VSBasicVcNoFog.inc"
|
#include "BasicEffect_VSBasicVcNoFog.inc"
|
||||||
#include "BasicEffect_VSBasicTx.inc"
|
#include "BasicEffect_VSBasicTx.inc"
|
||||||
#include "BasicEffect_VSBasicTxNoFog.inc"
|
#include "BasicEffect_VSBasicTxNoFog.inc"
|
||||||
#include "BasicEffect_VSBasicTxVc.inc"
|
#include "BasicEffect_VSBasicTxVc.inc"
|
||||||
#include "BasicEffect_VSBasicTxVcNoFog.inc"
|
#include "BasicEffect_VSBasicTxVcNoFog.inc"
|
||||||
|
|
||||||
#include "BasicEffect_VSBasicVertexLighting.inc"
|
#include "BasicEffect_VSBasicVertexLighting.inc"
|
||||||
#include "BasicEffect_VSBasicVertexLightingVc.inc"
|
#include "BasicEffect_VSBasicVertexLightingVc.inc"
|
||||||
#include "BasicEffect_VSBasicVertexLightingTx.inc"
|
#include "BasicEffect_VSBasicVertexLightingTx.inc"
|
||||||
#include "BasicEffect_VSBasicVertexLightingTxVc.inc"
|
#include "BasicEffect_VSBasicVertexLightingTxVc.inc"
|
||||||
|
|
||||||
#include "BasicEffect_VSBasicPixelLighting.inc"
|
#include "BasicEffect_VSBasicPixelLighting.inc"
|
||||||
#include "BasicEffect_VSBasicPixelLightingVc.inc"
|
#include "BasicEffect_VSBasicPixelLightingVc.inc"
|
||||||
#include "BasicEffect_VSBasicPixelLightingTx.inc"
|
#include "BasicEffect_VSBasicPixelLightingTx.inc"
|
||||||
#include "BasicEffect_VSBasicPixelLightingTxVc.inc"
|
#include "BasicEffect_VSBasicPixelLightingTxVc.inc"
|
||||||
|
|
||||||
#include "BasicEffect_VSBasicVertexLightingBn.inc"
|
#include "BasicEffect_VSBasicVertexLightingBn.inc"
|
||||||
#include "BasicEffect_VSBasicVertexLightingVcBn.inc"
|
#include "BasicEffect_VSBasicVertexLightingVcBn.inc"
|
||||||
#include "BasicEffect_VSBasicVertexLightingTxBn.inc"
|
#include "BasicEffect_VSBasicVertexLightingTxBn.inc"
|
||||||
#include "BasicEffect_VSBasicVertexLightingTxVcBn.inc"
|
#include "BasicEffect_VSBasicVertexLightingTxVcBn.inc"
|
||||||
|
|
||||||
#include "BasicEffect_VSBasicPixelLightingBn.inc"
|
#include "BasicEffect_VSBasicPixelLightingBn.inc"
|
||||||
#include "BasicEffect_VSBasicPixelLightingVcBn.inc"
|
#include "BasicEffect_VSBasicPixelLightingVcBn.inc"
|
||||||
#include "BasicEffect_VSBasicPixelLightingTxBn.inc"
|
#include "BasicEffect_VSBasicPixelLightingTxBn.inc"
|
||||||
#include "BasicEffect_VSBasicPixelLightingTxVcBn.inc"
|
#include "BasicEffect_VSBasicPixelLightingTxVcBn.inc"
|
||||||
|
|
||||||
#include "BasicEffect_PSBasic.inc"
|
#include "BasicEffect_PSBasic.inc"
|
||||||
#include "BasicEffect_PSBasicNoFog.inc"
|
#include "BasicEffect_PSBasicNoFog.inc"
|
||||||
#include "BasicEffect_PSBasicTx.inc"
|
#include "BasicEffect_PSBasicTx.inc"
|
||||||
#include "BasicEffect_PSBasicTxNoFog.inc"
|
#include "BasicEffect_PSBasicTxNoFog.inc"
|
||||||
|
|
||||||
#include "BasicEffect_PSBasicVertexLighting.inc"
|
#include "BasicEffect_PSBasicVertexLighting.inc"
|
||||||
#include "BasicEffect_PSBasicVertexLightingNoFog.inc"
|
#include "BasicEffect_PSBasicVertexLightingNoFog.inc"
|
||||||
#include "BasicEffect_PSBasicVertexLightingTx.inc"
|
#include "BasicEffect_PSBasicVertexLightingTx.inc"
|
||||||
#include "BasicEffect_PSBasicVertexLightingTxNoFog.inc"
|
#include "BasicEffect_PSBasicVertexLightingTxNoFog.inc"
|
||||||
|
|
||||||
#include "BasicEffect_PSBasicPixelLighting.inc"
|
#include "BasicEffect_PSBasicPixelLighting.inc"
|
||||||
#include "BasicEffect_PSBasicPixelLightingTx.inc"
|
#include "BasicEffect_PSBasicPixelLightingTx.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,6 +404,7 @@ const int EffectBase<BasicEffectTraits>::PixelShaderIndices[] =
|
||||||
9, // pixel lighting (biased vertex normals) + texture + vertex color
|
9, // pixel lighting (biased vertex normals) + texture + vertex color
|
||||||
9, // pixel lighting (biased vertex normals) + texture + vertex color, no fog
|
9, // pixel lighting (biased vertex normals) + texture + vertex color, no fog
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
// Global pool of per-device BasicEffect resources.
|
// Global pool of per-device BasicEffect resources.
|
||||||
template<>
|
template<>
|
||||||
|
@ -415,8 +417,8 @@ BasicEffect::Impl::Impl(
|
||||||
uint32_t effectFlags,
|
uint32_t effectFlags,
|
||||||
const EffectPipelineStateDescription& pipelineDescription)
|
const EffectPipelineStateDescription& pipelineDescription)
|
||||||
: EffectBase(device),
|
: EffectBase(device),
|
||||||
texture{},
|
texture{},
|
||||||
sampler{}
|
sampler{}
|
||||||
{
|
{
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<BasicEffectTraits>::VertexShaderIndices)) == BasicEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<BasicEffectTraits>::VertexShaderIndices)) == BasicEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<BasicEffectTraits>::VertexShaderBytecode)) == BasicEffectTraits::VertexShaderCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<BasicEffectTraits>::VertexShaderBytecode)) == BasicEffectTraits::VertexShaderCount, "array/max mismatch");
|
||||||
|
@ -583,7 +585,7 @@ BasicEffect::BasicEffect(
|
||||||
_In_ ID3D12Device* device,
|
_In_ ID3D12Device* device,
|
||||||
uint32_t effectFlags,
|
uint32_t effectFlags,
|
||||||
const EffectPipelineStateDescription& pipelineDescription)
|
const EffectPipelineStateDescription& pipelineDescription)
|
||||||
: pImpl(std::make_unique<Impl>(device, effectFlags, pipelineDescription))
|
: pImpl(std::make_unique<Impl>(device, effectFlags, pipelineDescription))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ namespace
|
||||||
{
|
{
|
||||||
constexpr int c_MaxSamples = 16;
|
constexpr int c_MaxSamples = 16;
|
||||||
|
|
||||||
constexpr int Dirty_ConstantBuffer = 0x01;
|
constexpr int Dirty_ConstantBuffer = 0x01;
|
||||||
constexpr int Dirty_Parameters = 0x02;
|
constexpr int Dirty_Parameters = 0x02;
|
||||||
|
|
||||||
constexpr int RootSignatureCount = 2;
|
constexpr int RootSignatureCount = 2;
|
||||||
|
|
||||||
|
@ -48,57 +48,58 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettPostProcess_VSQuadNoCB.inc"
|
#include "XboxGamingScarlettPostProcess_VSQuadNoCB.inc"
|
||||||
#include "XboxGamingScarlettPostProcess_VSQuad.inc"
|
#include "XboxGamingScarlettPostProcess_VSQuad.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettPostProcess_PSCopy.inc"
|
#include "XboxGamingScarlettPostProcess_PSCopy.inc"
|
||||||
#include "XboxGamingScarlettPostProcess_PSMonochrome.inc"
|
#include "XboxGamingScarlettPostProcess_PSMonochrome.inc"
|
||||||
#include "XboxGamingScarlettPostProcess_PSSepia.inc"
|
#include "XboxGamingScarlettPostProcess_PSSepia.inc"
|
||||||
#include "XboxGamingScarlettPostProcess_PSDownScale2x2.inc"
|
#include "XboxGamingScarlettPostProcess_PSDownScale2x2.inc"
|
||||||
#include "XboxGamingScarlettPostProcess_PSDownScale4x4.inc"
|
#include "XboxGamingScarlettPostProcess_PSDownScale4x4.inc"
|
||||||
#include "XboxGamingScarlettPostProcess_PSGaussianBlur5x5.inc"
|
#include "XboxGamingScarlettPostProcess_PSGaussianBlur5x5.inc"
|
||||||
#include "XboxGamingScarlettPostProcess_PSBloomExtract.inc"
|
#include "XboxGamingScarlettPostProcess_PSBloomExtract.inc"
|
||||||
#include "XboxGamingScarlettPostProcess_PSBloomBlur.inc"
|
#include "XboxGamingScarlettPostProcess_PSBloomBlur.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOnePostProcess_VSQuadNoCB.inc"
|
#include "XboxGamingXboxOnePostProcess_VSQuadNoCB.inc"
|
||||||
#include "XboxGamingXboxOnePostProcess_VSQuad.inc"
|
#include "XboxGamingXboxOnePostProcess_VSQuad.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOnePostProcess_PSCopy.inc"
|
#include "XboxGamingXboxOnePostProcess_PSCopy.inc"
|
||||||
#include "XboxGamingXboxOnePostProcess_PSMonochrome.inc"
|
#include "XboxGamingXboxOnePostProcess_PSMonochrome.inc"
|
||||||
#include "XboxGamingXboxOnePostProcess_PSSepia.inc"
|
#include "XboxGamingXboxOnePostProcess_PSSepia.inc"
|
||||||
#include "XboxGamingXboxOnePostProcess_PSDownScale2x2.inc"
|
#include "XboxGamingXboxOnePostProcess_PSDownScale2x2.inc"
|
||||||
#include "XboxGamingXboxOnePostProcess_PSDownScale4x4.inc"
|
#include "XboxGamingXboxOnePostProcess_PSDownScale4x4.inc"
|
||||||
#include "XboxGamingXboxOnePostProcess_PSGaussianBlur5x5.inc"
|
#include "XboxGamingXboxOnePostProcess_PSGaussianBlur5x5.inc"
|
||||||
#include "XboxGamingXboxOnePostProcess_PSBloomExtract.inc"
|
#include "XboxGamingXboxOnePostProcess_PSBloomExtract.inc"
|
||||||
#include "XboxGamingXboxOnePostProcess_PSBloomBlur.inc"
|
#include "XboxGamingXboxOnePostProcess_PSBloomBlur.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOnePostProcess_VSQuadNoCB.inc"
|
#include "XboxOnePostProcess_VSQuadNoCB.inc"
|
||||||
#include "XboxOnePostProcess_VSQuad.inc"
|
#include "XboxOnePostProcess_VSQuad.inc"
|
||||||
|
|
||||||
#include "XboxOnePostProcess_PSCopy.inc"
|
#include "XboxOnePostProcess_PSCopy.inc"
|
||||||
#include "XboxOnePostProcess_PSMonochrome.inc"
|
#include "XboxOnePostProcess_PSMonochrome.inc"
|
||||||
#include "XboxOnePostProcess_PSSepia.inc"
|
#include "XboxOnePostProcess_PSSepia.inc"
|
||||||
#include "XboxOnePostProcess_PSDownScale2x2.inc"
|
#include "XboxOnePostProcess_PSDownScale2x2.inc"
|
||||||
#include "XboxOnePostProcess_PSDownScale4x4.inc"
|
#include "XboxOnePostProcess_PSDownScale4x4.inc"
|
||||||
#include "XboxOnePostProcess_PSGaussianBlur5x5.inc"
|
#include "XboxOnePostProcess_PSGaussianBlur5x5.inc"
|
||||||
#include "XboxOnePostProcess_PSBloomExtract.inc"
|
#include "XboxOnePostProcess_PSBloomExtract.inc"
|
||||||
#include "XboxOnePostProcess_PSBloomBlur.inc"
|
#include "XboxOnePostProcess_PSBloomBlur.inc"
|
||||||
#else
|
#else
|
||||||
#include "PostProcess_VSQuadNoCB.inc"
|
#include "PostProcess_VSQuadNoCB.inc"
|
||||||
#include "PostProcess_VSQuad.inc"
|
#include "PostProcess_VSQuad.inc"
|
||||||
|
|
||||||
#include "PostProcess_PSCopy.inc"
|
#include "PostProcess_PSCopy.inc"
|
||||||
#include "PostProcess_PSMonochrome.inc"
|
#include "PostProcess_PSMonochrome.inc"
|
||||||
#include "PostProcess_PSSepia.inc"
|
#include "PostProcess_PSSepia.inc"
|
||||||
#include "PostProcess_PSDownScale2x2.inc"
|
#include "PostProcess_PSDownScale2x2.inc"
|
||||||
#include "PostProcess_PSDownScale4x4.inc"
|
#include "PostProcess_PSDownScale4x4.inc"
|
||||||
#include "PostProcess_PSGaussianBlur5x5.inc"
|
#include "PostProcess_PSGaussianBlur5x5.inc"
|
||||||
#include "PostProcess_PSBloomExtract.inc"
|
#include "PostProcess_PSBloomExtract.inc"
|
||||||
#include "PostProcess_PSBloomBlur.inc"
|
#include "PostProcess_PSBloomBlur.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,14 +141,14 @@ namespace
|
||||||
_Analysis_assume_(slot >= 0 && slot < RootSignatureCount);
|
_Analysis_assume_(slot >= 0 && slot < RootSignatureCount);
|
||||||
|
|
||||||
return DemandCreate(mRootSignature[slot], mMutex, [&](ID3D12RootSignature** pResult) noexcept -> HRESULT
|
return DemandCreate(mRootSignature[slot], mMutex, [&](ID3D12RootSignature** pResult) noexcept -> HRESULT
|
||||||
{
|
{
|
||||||
HRESULT hr = CreateRootSignature(mDevice.Get(), &desc, pResult);
|
HRESULT hr = CreateRootSignature(mDevice.Get(), &desc, pResult);
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
SetDebugObjectName(*pResult, L"BasicPostProcess");
|
SetDebugObjectName(*pResult, L"BasicPostProcess");
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D12Device* GetDevice() const noexcept { return mDevice.Get(); }
|
ID3D12Device* GetDevice() const noexcept { return mDevice.Get(); }
|
||||||
|
@ -158,6 +159,7 @@ namespace
|
||||||
std::mutex mMutex;
|
std::mutex mMutex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
class BasicPostProcess::Impl : public AlignedNew<PostProcessConstants>
|
class BasicPostProcess::Impl : public AlignedNew<PostProcessConstants>
|
||||||
{
|
{
|
||||||
|
@ -545,7 +547,7 @@ void BasicPostProcess::Impl::Bloom(bool horizontal, float size, float brightnes
|
||||||
|
|
||||||
// Public constructor.
|
// Public constructor.
|
||||||
BasicPostProcess::BasicPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Effect fx)
|
BasicPostProcess::BasicPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Effect fx)
|
||||||
: pImpl(std::make_unique<Impl>(device, rtState, fx))
|
: pImpl(std::make_unique<Impl>(device, rtState, fx))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ namespace Bezier
|
||||||
p4 * t * t * t;
|
p4 * t * t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline DirectX::XMVECTOR CubicInterpolate(DirectX::XMVECTOR const& p1, DirectX::XMVECTOR const& p2, DirectX::XMVECTOR const& p3, DirectX::XMVECTOR const& p4, float t) noexcept
|
inline DirectX::XMVECTOR CubicInterpolate(DirectX::XMVECTOR const& p1, DirectX::XMVECTOR const& p2, DirectX::XMVECTOR const& p3, DirectX::XMVECTOR const& p4, float t) noexcept
|
||||||
{
|
{
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
|
|
||||||
|
|
218
Src/DDS.h
218
Src/DDS.h
|
@ -25,19 +25,19 @@ namespace DirectX
|
||||||
|
|
||||||
#pragma pack(push,1)
|
#pragma pack(push,1)
|
||||||
|
|
||||||
constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS "
|
constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS "
|
||||||
|
|
||||||
struct DDS_PIXELFORMAT
|
struct DDS_PIXELFORMAT
|
||||||
{
|
{
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t fourCC;
|
uint32_t fourCC;
|
||||||
uint32_t RGBBitCount;
|
uint32_t RGBBitCount;
|
||||||
uint32_t RBitMask;
|
uint32_t RBitMask;
|
||||||
uint32_t GBitMask;
|
uint32_t GBitMask;
|
||||||
uint32_t BBitMask;
|
uint32_t BBitMask;
|
||||||
uint32_t ABitMask;
|
uint32_t ABitMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
|
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
|
||||||
#define DDS_RGB 0x00000040 // DDPF_RGB
|
#define DDS_RGB 0x00000040 // DDPF_RGB
|
||||||
|
@ -52,7 +52,7 @@ struct DDS_PIXELFORMAT
|
||||||
// DDS_BUMPLUMINANCE 0x00040000
|
// DDS_BUMPLUMINANCE 0x00040000
|
||||||
|
|
||||||
#ifndef MAKEFOURCC
|
#ifndef MAKEFOURCC
|
||||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||||
(static_cast<uint32_t>(static_cast<uint8_t>(ch0)) \
|
(static_cast<uint32_t>(static_cast<uint8_t>(ch0)) \
|
||||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch1)) << 8) \
|
| (static_cast<uint32_t>(static_cast<uint8_t>(ch1)) << 8) \
|
||||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch2)) << 16) \
|
| (static_cast<uint32_t>(static_cast<uint8_t>(ch2)) << 16) \
|
||||||
|
@ -60,131 +60,131 @@ struct DDS_PIXELFORMAT
|
||||||
#endif /* MAKEFOURCC */
|
#endif /* MAKEFOURCC */
|
||||||
|
|
||||||
#ifndef DDSGLOBALCONST
|
#ifndef DDSGLOBALCONST
|
||||||
#if defined(__GNUC__) && !defined(__MINGW32__)
|
#if defined(__GNUC__) && !defined(__MINGW32__)
|
||||||
#define DDSGLOBALCONST extern const __attribute__((weak))
|
#define DDSGLOBALCONST extern const __attribute__((weak))
|
||||||
#else
|
#else
|
||||||
#define DDSGLOBALCONST extern const __declspec(selectany)
|
#define DDSGLOBALCONST extern const __declspec(selectany)
|
||||||
#endif
|
#endif
|
||||||
#endif /* DDSGLOBALCONST */
|
#endif /* DDSGLOBALCONST */
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT1 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT1 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT2 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT2 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT3 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT3 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT4 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT4 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT5 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT5 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_UNORM =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_UNORM =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_SNORM =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_SNORM =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_UNORM =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_UNORM =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_SNORM =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_SNORM =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8_B8G8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8_B8G8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G8R8_G8B8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G8R8_G8B8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_YUY2 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_YUY2 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_UYVY =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_UYVY =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8R8G8B8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8R8G8B8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8B8G8R8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8B8G8R8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8B8G8R8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8B8G8R8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G16R16 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G16R16 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R5G6B5 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R5G6B5 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X1R5G5B5 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X1R5G5B5 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x7c00, 0x03e0, 0x001f, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x7c00, 0x03e0, 0x001f, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X4R4G4B4 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X4R4G4B4 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0f00, 0x00f0, 0x000f, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0f00, 0x00f0, 0x000f, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8B8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8B8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0xff0000, 0x00ff00, 0x0000ff, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0xff0000, 0x00ff00, 0x0000ff, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R3G3B2 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R3G3B2 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00e0, 0x001c, 0x0003, 0xff00 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00e0, 0x001c, 0x0003, 0xff00 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R3G3B2 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R3G3B2 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xe0, 0x1c, 0x03, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xe0, 0x1c, 0x03, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4L4 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4L4 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x0f, 0, 0, 0xf0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x0f, 0, 0, 0xf0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0, 0, 0xff00 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0, 0, 0xff00 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_ALT =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_ALT =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x00ff, 0, 0, 0xff00 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x00ff, 0, 0, 0xff00 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8_NVTT1 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8_NVTT1 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xff, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xff, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16_NVTT1 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16_NVTT1 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xffff, 0, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xffff, 0, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_NVTT1 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_NVTT1 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00ff, 0, 0, 0xff00 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00ff, 0, 0, 0xff00 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0, 0, 0, 0xff };
|
{ sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0, 0, 0, 0xff };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V8U8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V8U8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_Q8W8V8U8 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_Q8W8V8U8 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
|
||||||
|
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V16U16 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V16U16 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 };
|
||||||
|
|
||||||
// D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue
|
// D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2R10G10B10 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2R10G10B10 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000 };
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2B10G10R10 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2B10G10R10 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 };
|
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 };
|
||||||
|
|
||||||
// We do not support the following legacy Direct3D 9 formats:
|
// We do not support the following legacy Direct3D 9 formats:
|
||||||
|
@ -193,7 +193,7 @@ DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2B10G10R10 =
|
||||||
// DDSPF_X8L8V8U8 = { sizeof(DDS_PIXELFORMAT), DDS_BUMPLUMINANCE, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 };
|
// DDSPF_X8L8V8U8 = { sizeof(DDS_PIXELFORMAT), DDS_BUMPLUMINANCE, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 };
|
||||||
|
|
||||||
// This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat)
|
// This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat)
|
||||||
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DX10 =
|
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DX10 =
|
||||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 };
|
{ 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_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
|
||||||
|
@ -225,66 +225,66 @@ DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DX10 =
|
||||||
#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
|
#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
|
||||||
|
|
||||||
// Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION
|
// Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION
|
||||||
enum DDS_RESOURCE_DIMENSION : uint32_t
|
enum DDS_RESOURCE_DIMENSION : uint32_t
|
||||||
{
|
{
|
||||||
DDS_DIMENSION_TEXTURE1D = 2,
|
DDS_DIMENSION_TEXTURE1D = 2,
|
||||||
DDS_DIMENSION_TEXTURE2D = 3,
|
DDS_DIMENSION_TEXTURE2D = 3,
|
||||||
DDS_DIMENSION_TEXTURE3D = 4,
|
DDS_DIMENSION_TEXTURE3D = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
|
// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
|
||||||
enum DDS_RESOURCE_MISC_FLAG : uint32_t
|
enum DDS_RESOURCE_MISC_FLAG : uint32_t
|
||||||
{
|
{
|
||||||
DDS_RESOURCE_MISC_TEXTURECUBE = 0x4L,
|
DDS_RESOURCE_MISC_TEXTURECUBE = 0x4L,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DDS_MISC_FLAGS2 : uint32_t
|
enum DDS_MISC_FLAGS2 : uint32_t
|
||||||
{
|
{
|
||||||
DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L,
|
DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef DDS_ALPHA_MODE_DEFINED
|
#ifndef DDS_ALPHA_MODE_DEFINED
|
||||||
#define DDS_ALPHA_MODE_DEFINED
|
#define DDS_ALPHA_MODE_DEFINED
|
||||||
enum DDS_ALPHA_MODE : uint32_t
|
enum DDS_ALPHA_MODE : uint32_t
|
||||||
{
|
{
|
||||||
DDS_ALPHA_MODE_UNKNOWN = 0,
|
DDS_ALPHA_MODE_UNKNOWN = 0,
|
||||||
DDS_ALPHA_MODE_STRAIGHT = 1,
|
DDS_ALPHA_MODE_STRAIGHT = 1,
|
||||||
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
|
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
|
||||||
DDS_ALPHA_MODE_OPAQUE = 3,
|
DDS_ALPHA_MODE_OPAQUE = 3,
|
||||||
DDS_ALPHA_MODE_CUSTOM = 4,
|
DDS_ALPHA_MODE_CUSTOM = 4,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct DDS_HEADER
|
struct DDS_HEADER
|
||||||
{
|
{
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t pitchOrLinearSize;
|
uint32_t pitchOrLinearSize;
|
||||||
uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags
|
uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags
|
||||||
uint32_t mipMapCount;
|
uint32_t mipMapCount;
|
||||||
uint32_t reserved1[11];
|
uint32_t reserved1[11];
|
||||||
DDS_PIXELFORMAT ddspf;
|
DDS_PIXELFORMAT ddspf;
|
||||||
uint32_t caps;
|
uint32_t caps;
|
||||||
uint32_t caps2;
|
uint32_t caps2;
|
||||||
uint32_t caps3;
|
uint32_t caps3;
|
||||||
uint32_t caps4;
|
uint32_t caps4;
|
||||||
uint32_t reserved2;
|
uint32_t reserved2;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DDS_HEADER_DXT10
|
struct DDS_HEADER_DXT10
|
||||||
{
|
{
|
||||||
DXGI_FORMAT dxgiFormat;
|
DXGI_FORMAT dxgiFormat;
|
||||||
uint32_t resourceDimension;
|
uint32_t resourceDimension;
|
||||||
uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG
|
uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG
|
||||||
uint32_t arraySize;
|
uint32_t arraySize;
|
||||||
uint32_t miscFlags2; // see DDS_MISC_FLAGS2
|
uint32_t miscFlags2; // see DDS_MISC_FLAGS2
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
static_assert( sizeof(DDS_HEADER) == 124, "DDS Header size mismatch" );
|
static_assert(sizeof(DDS_HEADER) == 124, "DDS Header size mismatch");
|
||||||
static_assert( sizeof(DDS_HEADER_DXT10) == 20, "DDS DX10 Extended Header size mismatch");
|
static_assert(sizeof(DDS_HEADER_DXT10) == 20, "DDS DX10 Extended Header size mismatch");
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -47,11 +47,11 @@ namespace
|
||||||
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
|
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
|
||||||
case DXGI_FORMAT_D16_UNORM:
|
case DXGI_FORMAT_D16_UNORM:
|
||||||
|
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
case DXGI_FORMAT_D16_UNORM_S8_UINT:
|
case DXGI_FORMAT_D16_UNORM_S8_UINT:
|
||||||
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
||||||
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
|
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -72,11 +72,11 @@ namespace
|
||||||
case DXGI_FORMAT_P010:
|
case DXGI_FORMAT_P010:
|
||||||
case DXGI_FORMAT_P016:
|
case DXGI_FORMAT_P016:
|
||||||
|
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
case DXGI_FORMAT_D16_UNORM_S8_UINT:
|
case DXGI_FORMAT_D16_UNORM_S8_UINT:
|
||||||
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
||||||
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
|
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
|
||||||
#endif
|
#endif
|
||||||
if (!slicePlane)
|
if (!slicePlane)
|
||||||
{
|
{
|
||||||
// Plane 0
|
// Plane 0
|
||||||
|
@ -554,7 +554,7 @@ namespace
|
||||||
_In_z_ const wchar_t* fileName,
|
_In_z_ const wchar_t* fileName,
|
||||||
_In_ ID3D12Resource** texture) noexcept
|
_In_ ID3D12Resource** texture) noexcept
|
||||||
{
|
{
|
||||||
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||||
if (texture && *texture)
|
if (texture && *texture)
|
||||||
{
|
{
|
||||||
const wchar_t* pstrName = wcsrchr(fileName, '\\');
|
const wchar_t* pstrName = wcsrchr(fileName, '\\');
|
||||||
|
@ -569,10 +569,10 @@ namespace
|
||||||
|
|
||||||
(*texture)->SetName(pstrName);
|
(*texture)->SetName(pstrName);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UNREFERENCED_PARAMETER(fileName);
|
UNREFERENCED_PARAMETER(fileName);
|
||||||
UNREFERENCED_PARAMETER(texture);
|
UNREFERENCED_PARAMETER(texture);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -59,77 +59,78 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettDebugEffect_VSDebug.inc"
|
#include "XboxGamingScarlettDebugEffect_VSDebug.inc"
|
||||||
#include "XboxGamingScarlettDebugEffect_VSDebugInst.inc"
|
#include "XboxGamingScarlettDebugEffect_VSDebugInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettDebugEffect_VSDebugVc.inc"
|
#include "XboxGamingScarlettDebugEffect_VSDebugVc.inc"
|
||||||
#include "XboxGamingScarlettDebugEffect_VSDebugVcInst.inc"
|
#include "XboxGamingScarlettDebugEffect_VSDebugVcInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettDebugEffect_VSDebugBn.inc"
|
#include "XboxGamingScarlettDebugEffect_VSDebugBn.inc"
|
||||||
#include "XboxGamingScarlettDebugEffect_VSDebugBnInst.inc"
|
#include "XboxGamingScarlettDebugEffect_VSDebugBnInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettDebugEffect_VSDebugVcBn.inc"
|
#include "XboxGamingScarlettDebugEffect_VSDebugVcBn.inc"
|
||||||
#include "XboxGamingScarlettDebugEffect_VSDebugVcBnInst.inc"
|
#include "XboxGamingScarlettDebugEffect_VSDebugVcBnInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettDebugEffect_PSHemiAmbient.inc"
|
#include "XboxGamingScarlettDebugEffect_PSHemiAmbient.inc"
|
||||||
#include "XboxGamingScarlettDebugEffect_PSRGBNormals.inc"
|
#include "XboxGamingScarlettDebugEffect_PSRGBNormals.inc"
|
||||||
#include "XboxGamingScarlettDebugEffect_PSRGBTangents.inc"
|
#include "XboxGamingScarlettDebugEffect_PSRGBTangents.inc"
|
||||||
#include "XboxGamingScarlettDebugEffect_PSRGBBiTangents.inc"
|
#include "XboxGamingScarlettDebugEffect_PSRGBBiTangents.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneDebugEffect_VSDebug.inc"
|
#include "XboxGamingXboxOneDebugEffect_VSDebug.inc"
|
||||||
#include "XboxGamingXboxOneDebugEffect_VSDebugInst.inc"
|
#include "XboxGamingXboxOneDebugEffect_VSDebugInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneDebugEffect_VSDebugVc.inc"
|
#include "XboxGamingXboxOneDebugEffect_VSDebugVc.inc"
|
||||||
#include "XboxGamingXboxOneDebugEffect_VSDebugVcInst.inc"
|
#include "XboxGamingXboxOneDebugEffect_VSDebugVcInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneDebugEffect_VSDebugBn.inc"
|
#include "XboxGamingXboxOneDebugEffect_VSDebugBn.inc"
|
||||||
#include "XboxGamingXboxOneDebugEffect_VSDebugBnInst.inc"
|
#include "XboxGamingXboxOneDebugEffect_VSDebugBnInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneDebugEffect_VSDebugVcBn.inc"
|
#include "XboxGamingXboxOneDebugEffect_VSDebugVcBn.inc"
|
||||||
#include "XboxGamingXboxOneDebugEffect_VSDebugVcBnInst.inc"
|
#include "XboxGamingXboxOneDebugEffect_VSDebugVcBnInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneDebugEffect_PSHemiAmbient.inc"
|
#include "XboxGamingXboxOneDebugEffect_PSHemiAmbient.inc"
|
||||||
#include "XboxGamingXboxOneDebugEffect_PSRGBNormals.inc"
|
#include "XboxGamingXboxOneDebugEffect_PSRGBNormals.inc"
|
||||||
#include "XboxGamingXboxOneDebugEffect_PSRGBTangents.inc"
|
#include "XboxGamingXboxOneDebugEffect_PSRGBTangents.inc"
|
||||||
#include "XboxGamingXboxOneDebugEffect_PSRGBBiTangents.inc"
|
#include "XboxGamingXboxOneDebugEffect_PSRGBBiTangents.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneDebugEffect_VSDebug.inc"
|
#include "XboxOneDebugEffect_VSDebug.inc"
|
||||||
#include "XboxOneDebugEffect_VSDebugInst.inc"
|
#include "XboxOneDebugEffect_VSDebugInst.inc"
|
||||||
|
|
||||||
#include "XboxOneDebugEffect_VSDebugVc.inc"
|
#include "XboxOneDebugEffect_VSDebugVc.inc"
|
||||||
#include "XboxOneDebugEffect_VSDebugVcInst.inc"
|
#include "XboxOneDebugEffect_VSDebugVcInst.inc"
|
||||||
|
|
||||||
#include "XboxOneDebugEffect_VSDebugBn.inc"
|
#include "XboxOneDebugEffect_VSDebugBn.inc"
|
||||||
#include "XboxOneDebugEffect_VSDebugBnInst.inc"
|
#include "XboxOneDebugEffect_VSDebugBnInst.inc"
|
||||||
|
|
||||||
#include "XboxOneDebugEffect_VSDebugVcBn.inc"
|
#include "XboxOneDebugEffect_VSDebugVcBn.inc"
|
||||||
#include "XboxOneDebugEffect_VSDebugVcBnInst.inc"
|
#include "XboxOneDebugEffect_VSDebugVcBnInst.inc"
|
||||||
|
|
||||||
#include "XboxOneDebugEffect_PSHemiAmbient.inc"
|
#include "XboxOneDebugEffect_PSHemiAmbient.inc"
|
||||||
#include "XboxOneDebugEffect_PSRGBNormals.inc"
|
#include "XboxOneDebugEffect_PSRGBNormals.inc"
|
||||||
#include "XboxOneDebugEffect_PSRGBTangents.inc"
|
#include "XboxOneDebugEffect_PSRGBTangents.inc"
|
||||||
#include "XboxOneDebugEffect_PSRGBBiTangents.inc"
|
#include "XboxOneDebugEffect_PSRGBBiTangents.inc"
|
||||||
#else
|
#else
|
||||||
#include "DebugEffect_VSDebug.inc"
|
#include "DebugEffect_VSDebug.inc"
|
||||||
#include "DebugEffect_VSDebugInst.inc"
|
#include "DebugEffect_VSDebugInst.inc"
|
||||||
|
|
||||||
#include "DebugEffect_VSDebugVc.inc"
|
#include "DebugEffect_VSDebugVc.inc"
|
||||||
#include "DebugEffect_VSDebugVcInst.inc"
|
#include "DebugEffect_VSDebugVcInst.inc"
|
||||||
|
|
||||||
#include "DebugEffect_VSDebugBn.inc"
|
#include "DebugEffect_VSDebugBn.inc"
|
||||||
#include "DebugEffect_VSDebugBnInst.inc"
|
#include "DebugEffect_VSDebugBnInst.inc"
|
||||||
|
|
||||||
#include "DebugEffect_VSDebugVcBn.inc"
|
#include "DebugEffect_VSDebugVcBn.inc"
|
||||||
#include "DebugEffect_VSDebugVcBnInst.inc"
|
#include "DebugEffect_VSDebugVcBnInst.inc"
|
||||||
|
|
||||||
#include "DebugEffect_PSHemiAmbient.inc"
|
#include "DebugEffect_PSHemiAmbient.inc"
|
||||||
#include "DebugEffect_PSRGBNormals.inc"
|
#include "DebugEffect_PSRGBNormals.inc"
|
||||||
#include "DebugEffect_PSRGBTangents.inc"
|
#include "DebugEffect_PSRGBTangents.inc"
|
||||||
#include "DebugEffect_PSRGBBiTangents.inc"
|
#include "DebugEffect_PSRGBBiTangents.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +246,7 @@ const int EffectBase<DebugEffectTraits>::PixelShaderIndices[] =
|
||||||
2, // instancing + vertex color (biased vertex normal) + tangents
|
2, // instancing + vertex color (biased vertex normal) + tangents
|
||||||
3, // instancing + vertex color (biased vertex normal) + bitangents
|
3, // instancing + vertex color (biased vertex normal) + bitangents
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
// Global pool of per-deviceDebugEffect resources.
|
// Global pool of per-deviceDebugEffect resources.
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -22,13 +22,13 @@ namespace DirectX
|
||||||
T* result = comPtr.Get();
|
T* result = comPtr.Get();
|
||||||
|
|
||||||
// Double-checked lock pattern.
|
// Double-checked lock pattern.
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
MemoryBarrier();
|
MemoryBarrier();
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
__sync_synchronize();
|
__sync_synchronize();
|
||||||
#else
|
#else
|
||||||
#error Unknown memory barrier syntax
|
#error Unknown memory barrier syntax
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
@ -43,11 +43,11 @@ namespace DirectX
|
||||||
createFunc(&result)
|
createFunc(&result)
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
MemoryBarrier();
|
MemoryBarrier();
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
__sync_synchronize();
|
__sync_synchronize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
comPtr.Attach(result);
|
comPtr.Attach(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,61 +29,61 @@ void DirectX::CreateShaderResourceView(
|
||||||
|
|
||||||
switch (desc.Dimension)
|
switch (desc.Dimension)
|
||||||
{
|
{
|
||||||
case D3D12_RESOURCE_DIMENSION_TEXTURE1D:
|
case D3D12_RESOURCE_DIMENSION_TEXTURE1D:
|
||||||
if (desc.DepthOrArraySize > 1)
|
if (desc.DepthOrArraySize > 1)
|
||||||
|
{
|
||||||
|
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1DARRAY;
|
||||||
|
srvDesc.Texture1DArray.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
||||||
|
srvDesc.Texture1DArray.ArraySize = static_cast<UINT>(desc.DepthOrArraySize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D;
|
||||||
|
srvDesc.Texture1D.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case D3D12_RESOURCE_DIMENSION_TEXTURE2D:
|
||||||
|
if (isCubeMap)
|
||||||
|
{
|
||||||
|
if (desc.DepthOrArraySize > 6)
|
||||||
{
|
{
|
||||||
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1DARRAY;
|
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
|
||||||
srvDesc.Texture1DArray.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
srvDesc.TextureCubeArray.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
||||||
srvDesc.Texture1DArray.ArraySize = static_cast<UINT>(desc.DepthOrArraySize);
|
srvDesc.TextureCubeArray.NumCubes = static_cast<UINT>(desc.DepthOrArraySize / 6);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D;
|
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE;
|
||||||
srvDesc.Texture1D.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
srvDesc.TextureCube.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
else if (desc.DepthOrArraySize > 1)
|
||||||
|
{
|
||||||
|
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
|
||||||
|
srvDesc.Texture2DArray.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
||||||
|
srvDesc.Texture2DArray.ArraySize = static_cast<UINT>(desc.DepthOrArraySize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
||||||
|
srvDesc.Texture2D.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case D3D12_RESOURCE_DIMENSION_TEXTURE2D:
|
case D3D12_RESOURCE_DIMENSION_TEXTURE3D:
|
||||||
if (isCubeMap)
|
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D;
|
||||||
{
|
srvDesc.Texture3D.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
||||||
if (desc.DepthOrArraySize > 6)
|
break;
|
||||||
{
|
|
||||||
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
|
|
||||||
srvDesc.TextureCubeArray.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
|
||||||
srvDesc.TextureCubeArray.NumCubes = static_cast<UINT>(desc.DepthOrArraySize / 6);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE;
|
|
||||||
srvDesc.TextureCube.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (desc.DepthOrArraySize > 1)
|
|
||||||
{
|
|
||||||
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
|
|
||||||
srvDesc.Texture2DArray.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
|
||||||
srvDesc.Texture2DArray.ArraySize = static_cast<UINT>(desc.DepthOrArraySize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
|
||||||
srvDesc.Texture2D.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case D3D12_RESOURCE_DIMENSION_TEXTURE3D:
|
case D3D12_RESOURCE_DIMENSION_BUFFER:
|
||||||
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D;
|
DebugTrace("ERROR: CreateShaderResourceView cannot be used with DIMENSION_BUFFER.\n");
|
||||||
srvDesc.Texture3D.MipLevels = (!desc.MipLevels) ? UINT(-1) : desc.MipLevels;
|
throw std::invalid_argument("buffer resources not supported");
|
||||||
break;
|
|
||||||
|
|
||||||
case D3D12_RESOURCE_DIMENSION_BUFFER:
|
case D3D12_RESOURCE_DIMENSION_UNKNOWN:
|
||||||
DebugTrace("ERROR: CreateShaderResourceView cannot be used with DIMENSION_BUFFER.\n");
|
default:
|
||||||
throw std::invalid_argument("buffer resources not supported");
|
DebugTrace("ERROR: CreateShaderResourceView cannot be used with DIMENSION_UNKNOWN (%d).\n", desc.Dimension);
|
||||||
|
throw std::invalid_argument("unknown resource dimension");
|
||||||
case D3D12_RESOURCE_DIMENSION_UNKNOWN:
|
|
||||||
default:
|
|
||||||
DebugTrace("ERROR: CreateShaderResourceView cannot be used with DIMENSION_UNKNOWN (%d).\n", desc.Dimension);
|
|
||||||
throw std::invalid_argument("unknown resource dimension");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
device->CreateShaderResourceView(tex, &srvDesc, srvDescriptor);
|
device->CreateShaderResourceView(tex, &srvDesc, srvDescriptor);
|
||||||
|
|
|
@ -27,8 +27,8 @@ namespace
|
||||||
{
|
{
|
||||||
constexpr int c_MaxSamples = 16;
|
constexpr int c_MaxSamples = 16;
|
||||||
|
|
||||||
constexpr int Dirty_ConstantBuffer = 0x01;
|
constexpr int Dirty_ConstantBuffer = 0x01;
|
||||||
constexpr int Dirty_Parameters = 0x02;
|
constexpr int Dirty_Parameters = 0x02;
|
||||||
|
|
||||||
// Constant buffer layout. Must match the shader!
|
// Constant buffer layout. Must match the shader!
|
||||||
XM_ALIGNED_STRUCT(16) PostProcessConstants
|
XM_ALIGNED_STRUCT(16) PostProcessConstants
|
||||||
|
@ -40,36 +40,37 @@ namespace
|
||||||
static_assert((sizeof(PostProcessConstants) % 16) == 0, "CB size not padded correctly");
|
static_assert((sizeof(PostProcessConstants) % 16) == 0, "CB size not padded correctly");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettPostProcess_VSQuadDual.inc"
|
#include "XboxGamingScarlettPostProcess_VSQuadDual.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettPostProcess_PSMerge.inc"
|
#include "XboxGamingScarlettPostProcess_PSMerge.inc"
|
||||||
#include "XboxGamingScarlettPostProcess_PSBloomCombine.inc"
|
#include "XboxGamingScarlettPostProcess_PSBloomCombine.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOnePostProcess_VSQuadDual.inc"
|
#include "XboxGamingXboxOnePostProcess_VSQuadDual.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOnePostProcess_PSMerge.inc"
|
#include "XboxGamingXboxOnePostProcess_PSMerge.inc"
|
||||||
#include "XboxGamingXboxOnePostProcess_PSBloomCombine.inc"
|
#include "XboxGamingXboxOnePostProcess_PSBloomCombine.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOnePostProcess_VSQuadDual.inc"
|
#include "XboxOnePostProcess_VSQuadDual.inc"
|
||||||
|
|
||||||
#include "XboxOnePostProcess_PSMerge.inc"
|
#include "XboxOnePostProcess_PSMerge.inc"
|
||||||
#include "XboxOnePostProcess_PSBloomCombine.inc"
|
#include "XboxOnePostProcess_PSBloomCombine.inc"
|
||||||
#else
|
#else
|
||||||
#include "PostProcess_VSQuadDual.inc"
|
#include "PostProcess_VSQuadDual.inc"
|
||||||
|
|
||||||
#include "PostProcess_PSMerge.inc"
|
#include "PostProcess_PSMerge.inc"
|
||||||
#include "PostProcess_PSBloomCombine.inc"
|
#include "PostProcess_PSBloomCombine.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const D3D12_SHADER_BYTECODE vertexShader =
|
const D3D12_SHADER_BYTECODE vertexShader =
|
||||||
{ PostProcess_VSQuadDual, sizeof(PostProcess_VSQuadDual) };
|
{ PostProcess_VSQuadDual, sizeof(PostProcess_VSQuadDual) };
|
||||||
|
|
||||||
const D3D12_SHADER_BYTECODE pixelShaders[] =
|
const D3D12_SHADER_BYTECODE pixelShaders[] =
|
||||||
{
|
{
|
||||||
|
@ -85,19 +86,20 @@ namespace
|
||||||
public:
|
public:
|
||||||
DeviceResources(_In_ ID3D12Device* device) noexcept
|
DeviceResources(_In_ ID3D12Device* device) noexcept
|
||||||
: mDevice(device)
|
: mDevice(device)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ID3D12RootSignature* GetRootSignature(const D3D12_ROOT_SIGNATURE_DESC& desc)
|
ID3D12RootSignature* GetRootSignature(const D3D12_ROOT_SIGNATURE_DESC& desc)
|
||||||
{
|
{
|
||||||
return DemandCreate(mRootSignature, mMutex, [&](ID3D12RootSignature** pResult) noexcept -> HRESULT
|
return DemandCreate(mRootSignature, mMutex, [&](ID3D12RootSignature** pResult) noexcept -> HRESULT
|
||||||
{
|
{
|
||||||
HRESULT hr = CreateRootSignature(mDevice.Get(), &desc, pResult);
|
HRESULT hr = CreateRootSignature(mDevice.Get(), &desc, pResult);
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
SetDebugObjectName(*pResult, L"DualPostProcess");
|
SetDebugObjectName(*pResult, L"DualPostProcess");
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D12Device* GetDevice() const noexcept { return mDevice.Get(); }
|
ID3D12Device* GetDevice() const noexcept { return mDevice.Get(); }
|
||||||
|
@ -108,6 +110,7 @@ namespace
|
||||||
std::mutex mMutex;
|
std::mutex mMutex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
class DualPostProcess::Impl : public AlignedNew<PostProcessConstants>
|
class DualPostProcess::Impl : public AlignedNew<PostProcessConstants>
|
||||||
{
|
{
|
||||||
|
@ -300,7 +303,7 @@ void DualPostProcess::Impl::Process(_In_ ID3D12GraphicsCommandList* commandList)
|
||||||
|
|
||||||
// Public constructor.
|
// Public constructor.
|
||||||
DualPostProcess::DualPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Effect fx)
|
DualPostProcess::DualPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Effect fx)
|
||||||
: pImpl(std::make_unique<Impl>(device, rtState, fx))
|
: pImpl(std::make_unique<Impl>(device, rtState, fx))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,41 +68,42 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettDualTextureEffect_VSDualTexture.inc"
|
#include "XboxGamingScarlettDualTextureEffect_VSDualTexture.inc"
|
||||||
#include "XboxGamingScarlettDualTextureEffect_VSDualTextureNoFog.inc"
|
#include "XboxGamingScarlettDualTextureEffect_VSDualTextureNoFog.inc"
|
||||||
#include "XboxGamingScarlettDualTextureEffect_VSDualTextureVc.inc"
|
#include "XboxGamingScarlettDualTextureEffect_VSDualTextureVc.inc"
|
||||||
#include "XboxGamingScarlettDualTextureEffect_VSDualTextureVcNoFog.inc"
|
#include "XboxGamingScarlettDualTextureEffect_VSDualTextureVcNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettDualTextureEffect_PSDualTexture.inc"
|
#include "XboxGamingScarlettDualTextureEffect_PSDualTexture.inc"
|
||||||
#include "XboxGamingScarlettDualTextureEffect_PSDualTextureNoFog.inc"
|
#include "XboxGamingScarlettDualTextureEffect_PSDualTextureNoFog.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneDualTextureEffect_VSDualTexture.inc"
|
#include "XboxGamingXboxOneDualTextureEffect_VSDualTexture.inc"
|
||||||
#include "XboxGamingXboxOneDualTextureEffect_VSDualTextureNoFog.inc"
|
#include "XboxGamingXboxOneDualTextureEffect_VSDualTextureNoFog.inc"
|
||||||
#include "XboxGamingXboxOneDualTextureEffect_VSDualTextureVc.inc"
|
#include "XboxGamingXboxOneDualTextureEffect_VSDualTextureVc.inc"
|
||||||
#include "XboxGamingXboxOneDualTextureEffect_VSDualTextureVcNoFog.inc"
|
#include "XboxGamingXboxOneDualTextureEffect_VSDualTextureVcNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneDualTextureEffect_PSDualTexture.inc"
|
#include "XboxGamingXboxOneDualTextureEffect_PSDualTexture.inc"
|
||||||
#include "XboxGamingXboxOneDualTextureEffect_PSDualTextureNoFog.inc"
|
#include "XboxGamingXboxOneDualTextureEffect_PSDualTextureNoFog.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneDualTextureEffect_VSDualTexture.inc"
|
#include "XboxOneDualTextureEffect_VSDualTexture.inc"
|
||||||
#include "XboxOneDualTextureEffect_VSDualTextureNoFog.inc"
|
#include "XboxOneDualTextureEffect_VSDualTextureNoFog.inc"
|
||||||
#include "XboxOneDualTextureEffect_VSDualTextureVc.inc"
|
#include "XboxOneDualTextureEffect_VSDualTextureVc.inc"
|
||||||
#include "XboxOneDualTextureEffect_VSDualTextureVcNoFog.inc"
|
#include "XboxOneDualTextureEffect_VSDualTextureVcNoFog.inc"
|
||||||
|
|
||||||
#include "XboxOneDualTextureEffect_PSDualTexture.inc"
|
#include "XboxOneDualTextureEffect_PSDualTexture.inc"
|
||||||
#include "XboxOneDualTextureEffect_PSDualTextureNoFog.inc"
|
#include "XboxOneDualTextureEffect_PSDualTextureNoFog.inc"
|
||||||
#else
|
#else
|
||||||
#include "DualTextureEffect_VSDualTexture.inc"
|
#include "DualTextureEffect_VSDualTexture.inc"
|
||||||
#include "DualTextureEffect_VSDualTextureNoFog.inc"
|
#include "DualTextureEffect_VSDualTextureNoFog.inc"
|
||||||
#include "DualTextureEffect_VSDualTextureVc.inc"
|
#include "DualTextureEffect_VSDualTextureVc.inc"
|
||||||
#include "DualTextureEffect_VSDualTextureVcNoFog.inc"
|
#include "DualTextureEffect_VSDualTextureVcNoFog.inc"
|
||||||
|
|
||||||
#include "DualTextureEffect_PSDualTexture.inc"
|
#include "DualTextureEffect_PSDualTexture.inc"
|
||||||
#include "DualTextureEffect_PSDualTextureNoFog.inc"
|
#include "DualTextureEffect_PSDualTextureNoFog.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ const int EffectBase<DualTextureEffectTraits>::PixelShaderIndices[] =
|
||||||
0, // vertex color
|
0, // vertex color
|
||||||
1, // vertex color, no fog
|
1, // vertex color, no fog
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
// Global pool of per-device DualTextureEffect resources.
|
// Global pool of per-device DualTextureEffect resources.
|
||||||
template<>
|
template<>
|
||||||
|
@ -158,10 +159,10 @@ DualTextureEffect::Impl::Impl(
|
||||||
uint32_t effectFlags,
|
uint32_t effectFlags,
|
||||||
const EffectPipelineStateDescription& pipelineDescription)
|
const EffectPipelineStateDescription& pipelineDescription)
|
||||||
: EffectBase(device),
|
: EffectBase(device),
|
||||||
texture1{},
|
texture1{},
|
||||||
texture1Sampler{},
|
texture1Sampler{},
|
||||||
texture2{},
|
texture2{},
|
||||||
texture2Sampler{}
|
texture2Sampler{}
|
||||||
{
|
{
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<DualTextureEffectTraits>::VertexShaderIndices)) == DualTextureEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<DualTextureEffectTraits>::VertexShaderIndices)) == DualTextureEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<DualTextureEffectTraits>::VertexShaderBytecode)) == DualTextureEffectTraits::VertexShaderCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<DualTextureEffectTraits>::VertexShaderBytecode)) == DualTextureEffectTraits::VertexShaderCount, "array/max mismatch");
|
||||||
|
|
|
@ -169,7 +169,7 @@ _Use_decl_annotations_ void EffectLights::InitializeConstants(XMVECTOR& specular
|
||||||
{
|
{
|
||||||
lightDirectionConstant[i] = defaultLightDirection;
|
lightDirectionConstant[i] = defaultLightDirection;
|
||||||
|
|
||||||
lightDiffuseConstant[i] = lightEnabled[i] ? lightDiffuseColor[i] : g_XMZero;
|
lightDiffuseConstant[i] = lightEnabled[i] ? lightDiffuseColor[i] : g_XMZero;
|
||||||
lightSpecularConstant[i] = lightEnabled[i] ? lightSpecularColor[i] : g_XMZero;
|
lightSpecularConstant[i] = lightEnabled[i] ? lightSpecularColor[i] : g_XMZero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -391,12 +391,12 @@ ID3D12RootSignature* EffectDeviceResources::DemandCreateRootSig(
|
||||||
D3D12_ROOT_SIGNATURE_DESC const& desc)
|
D3D12_ROOT_SIGNATURE_DESC const& desc)
|
||||||
{
|
{
|
||||||
return DemandCreate(rootSig, mMutex, [&](ID3D12RootSignature** pResult) noexcept -> HRESULT
|
return DemandCreate(rootSig, mMutex, [&](ID3D12RootSignature** pResult) noexcept -> HRESULT
|
||||||
{
|
{
|
||||||
HRESULT hr = CreateRootSignature(mDevice.Get(), &desc, pResult);
|
HRESULT hr = CreateRootSignature(mDevice.Get(), &desc, pResult);
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
SetDebugObjectName(*pResult, L"DirectXTK:Effect");
|
SetDebugObjectName(*pResult, L"DirectXTK:Effect");
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,19 +34,19 @@ namespace DirectX
|
||||||
constexpr int PerPixelLightingBit = 0x04;
|
constexpr int PerPixelLightingBit = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_assert(((EffectFlags::PerPixelLighting) & EffectFlags::PerPixelLightingBit) != 0, "PerPixelLighting enum flags mismatch");
|
static_assert(((EffectFlags::PerPixelLighting)& EffectFlags::PerPixelLightingBit) != 0, "PerPixelLighting enum flags mismatch");
|
||||||
|
|
||||||
// Bitfield tracks which derived parameter values need to be recomputed.
|
// Bitfield tracks which derived parameter values need to be recomputed.
|
||||||
namespace EffectDirtyFlags
|
namespace EffectDirtyFlags
|
||||||
{
|
{
|
||||||
constexpr int ConstantBuffer = 0x01;
|
constexpr int ConstantBuffer = 0x01;
|
||||||
constexpr int WorldViewProj = 0x02;
|
constexpr int WorldViewProj = 0x02;
|
||||||
constexpr int WorldInverseTranspose = 0x04;
|
constexpr int WorldInverseTranspose = 0x04;
|
||||||
constexpr int EyePosition = 0x08;
|
constexpr int EyePosition = 0x08;
|
||||||
constexpr int MaterialColor = 0x10;
|
constexpr int MaterialColor = 0x10;
|
||||||
constexpr int FogVector = 0x20;
|
constexpr int FogVector = 0x20;
|
||||||
constexpr int FogEnable = 0x40;
|
constexpr int FogEnable = 0x40;
|
||||||
constexpr int AlphaTest = 0x80;
|
constexpr int AlphaTest = 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper stores matrix parameter values, and computes derived matrices.
|
// Helper stores matrix parameter values, and computes derived matrices.
|
||||||
|
@ -123,7 +123,8 @@ namespace DirectX
|
||||||
public:
|
public:
|
||||||
EffectDeviceResources(_In_ ID3D12Device* device) noexcept
|
EffectDeviceResources(_In_ ID3D12Device* device) noexcept
|
||||||
: mDevice(device)
|
: mDevice(device)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ID3D12RootSignature* DemandCreateRootSig(_Inout_ Microsoft::WRL::ComPtr<ID3D12RootSignature>& rootSig, D3D12_ROOT_SIGNATURE_DESC const& desc);
|
ID3D12RootSignature* DemandCreateRootSig(_Inout_ Microsoft::WRL::ComPtr<ID3D12RootSignature>& rootSig, D3D12_ROOT_SIGNATURE_DESC const& desc);
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ EffectTextureFactory::EffectTextureFactory(
|
||||||
ID3D12Device* device,
|
ID3D12Device* device,
|
||||||
ResourceUploadBatch& resourceUploadBatch,
|
ResourceUploadBatch& resourceUploadBatch,
|
||||||
ID3D12DescriptorHeap* descriptorHeap) noexcept(false) :
|
ID3D12DescriptorHeap* descriptorHeap) noexcept(false) :
|
||||||
pImpl(std::make_unique<Impl>(device, resourceUploadBatch, descriptorHeap))
|
pImpl(std::make_unique<Impl>(device, resourceUploadBatch, descriptorHeap))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ EffectTextureFactory::EffectTextureFactory(
|
||||||
ResourceUploadBatch& resourceUploadBatch,
|
ResourceUploadBatch& resourceUploadBatch,
|
||||||
size_t numDescriptors,
|
size_t numDescriptors,
|
||||||
D3D12_DESCRIPTOR_HEAP_FLAGS descriptorHeapFlags) noexcept(false) :
|
D3D12_DESCRIPTOR_HEAP_FLAGS descriptorHeapFlags) noexcept(false) :
|
||||||
pImpl(std::make_unique<Impl>(device, resourceUploadBatch, numDescriptors, descriptorHeapFlags))
|
pImpl(std::make_unique<Impl>(device, resourceUploadBatch, numDescriptors, descriptorHeapFlags))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,9 @@ class EnvironmentMapEffect::Impl : public EffectBase<EnvironmentMapEffectTraits>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(_In_ ID3D12Device* device,
|
Impl(_In_ ID3D12Device* device,
|
||||||
uint32_t effectFlags,
|
uint32_t effectFlags,
|
||||||
const EffectPipelineStateDescription& pipelineDescription,
|
const EffectPipelineStateDescription& pipelineDescription,
|
||||||
EnvironmentMapEffect::Mapping mapping);
|
EnvironmentMapEffect::Mapping mapping);
|
||||||
|
|
||||||
enum RootParameterIndex
|
enum RootParameterIndex
|
||||||
{
|
{
|
||||||
|
@ -86,117 +86,118 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMap.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMap.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapFresnel.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapFresnel.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapPixelLighting.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapPixelLighting.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapBn.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapBn.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapFresnelBn.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapFresnelBn.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapPixelLightingBn.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_VSEnvMapPixelLightingBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMap.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMap.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapNoFog.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapNoFog.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpecular.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpecular.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpecularNoFog.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpecularNoFog.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapPixelLighting.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapPixelLighting.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpherePixelLighting.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpherePixelLighting.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpherePixelLightingNoFog.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpherePixelLightingNoFog.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnel.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnel.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnelNoFog.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnelNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapDualParabolaPixelLighting.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapDualParabolaPixelLighting.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingNoFog.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingNoFog.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnel.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnel.inc"
|
||||||
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnelNoFog.inc"
|
#include "XboxGamingScarlettEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnelNoFog.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMap.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMap.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapFresnel.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapFresnel.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapPixelLighting.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapPixelLighting.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapBn.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapBn.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapFresnelBn.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapFresnelBn.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapPixelLightingBn.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_VSEnvMapPixelLightingBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMap.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMap.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapNoFog.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapNoFog.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpecular.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpecular.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpecularNoFog.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpecularNoFog.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapPixelLighting.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapPixelLighting.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLighting.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLighting.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingNoFog.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingNoFog.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnel.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnel.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnelNoFog.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnelNoFog.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLighting.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLighting.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingNoFog.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingNoFog.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnel.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnel.inc"
|
||||||
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnelNoFog.inc"
|
#include "XboxGamingXboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnelNoFog.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneEnvironmentMapEffect_VSEnvMap.inc"
|
#include "XboxOneEnvironmentMapEffect_VSEnvMap.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_VSEnvMapFresnel.inc"
|
#include "XboxOneEnvironmentMapEffect_VSEnvMapFresnel.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_VSEnvMapPixelLighting.inc"
|
#include "XboxOneEnvironmentMapEffect_VSEnvMapPixelLighting.inc"
|
||||||
|
|
||||||
#include "XboxOneEnvironmentMapEffect_VSEnvMapBn.inc"
|
#include "XboxOneEnvironmentMapEffect_VSEnvMapBn.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_VSEnvMapFresnelBn.inc"
|
#include "XboxOneEnvironmentMapEffect_VSEnvMapFresnelBn.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_VSEnvMapPixelLightingBn.inc"
|
#include "XboxOneEnvironmentMapEffect_VSEnvMapPixelLightingBn.inc"
|
||||||
|
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMap.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMap.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapNoFog.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapNoFog.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpecular.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpecular.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpecularNoFog.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpecularNoFog.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapPixelLighting.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapPixelLighting.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc"
|
||||||
|
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLighting.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLighting.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingNoFog.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingNoFog.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnel.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnel.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnelNoFog.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnelNoFog.inc"
|
||||||
|
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLighting.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLighting.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingNoFog.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingNoFog.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnel.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnel.inc"
|
||||||
#include "XboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnelNoFog.inc"
|
#include "XboxOneEnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnelNoFog.inc"
|
||||||
#else
|
#else
|
||||||
#include "EnvironmentMapEffect_VSEnvMap.inc"
|
#include "EnvironmentMapEffect_VSEnvMap.inc"
|
||||||
#include "EnvironmentMapEffect_VSEnvMapFresnel.inc"
|
#include "EnvironmentMapEffect_VSEnvMapFresnel.inc"
|
||||||
#include "EnvironmentMapEffect_VSEnvMapPixelLighting.inc"
|
#include "EnvironmentMapEffect_VSEnvMapPixelLighting.inc"
|
||||||
|
|
||||||
#include "EnvironmentMapEffect_VSEnvMapBn.inc"
|
#include "EnvironmentMapEffect_VSEnvMapBn.inc"
|
||||||
#include "EnvironmentMapEffect_VSEnvMapFresnelBn.inc"
|
#include "EnvironmentMapEffect_VSEnvMapFresnelBn.inc"
|
||||||
#include "EnvironmentMapEffect_VSEnvMapPixelLightingBn.inc"
|
#include "EnvironmentMapEffect_VSEnvMapPixelLightingBn.inc"
|
||||||
|
|
||||||
#include "EnvironmentMapEffect_PSEnvMap.inc"
|
#include "EnvironmentMapEffect_PSEnvMap.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapNoFog.inc"
|
#include "EnvironmentMapEffect_PSEnvMapNoFog.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapSpecular.inc"
|
#include "EnvironmentMapEffect_PSEnvMapSpecular.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapSpecularNoFog.inc"
|
#include "EnvironmentMapEffect_PSEnvMapSpecularNoFog.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapPixelLighting.inc"
|
#include "EnvironmentMapEffect_PSEnvMapPixelLighting.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc"
|
#include "EnvironmentMapEffect_PSEnvMapPixelLightingNoFog.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc"
|
#include "EnvironmentMapEffect_PSEnvMapPixelLightingFresnel.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc"
|
#include "EnvironmentMapEffect_PSEnvMapPixelLightingFresnelNoFog.inc"
|
||||||
|
|
||||||
#include "EnvironmentMapEffect_PSEnvMapSpherePixelLighting.inc"
|
#include "EnvironmentMapEffect_PSEnvMapSpherePixelLighting.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapSpherePixelLightingNoFog.inc"
|
#include "EnvironmentMapEffect_PSEnvMapSpherePixelLightingNoFog.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnel.inc"
|
#include "EnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnel.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnelNoFog.inc"
|
#include "EnvironmentMapEffect_PSEnvMapSpherePixelLightingFresnelNoFog.inc"
|
||||||
|
|
||||||
#include "EnvironmentMapEffect_PSEnvMapDualParabolaPixelLighting.inc"
|
#include "EnvironmentMapEffect_PSEnvMapDualParabolaPixelLighting.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingNoFog.inc"
|
#include "EnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingNoFog.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnel.inc"
|
#include "EnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnel.inc"
|
||||||
#include "EnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnelNoFog.inc"
|
#include "EnvironmentMapEffect_PSEnvMapDualParabolaPixelLightingFresnelNoFog.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +343,7 @@ const int EffectBase<EnvironmentMapEffectTraits>::PixelShaderIndices[] =
|
||||||
14, // dual-parabola pixel lighting (biased vertex normals), fresnel
|
14, // dual-parabola pixel lighting (biased vertex normals), fresnel
|
||||||
15, // dual-parabola pixel lighting (biased vertex normals), fresnel, no fog
|
15, // dual-parabola pixel lighting (biased vertex normals), fresnel, no fog
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
// Global pool of per-device EnvironmentMapEffect resources.
|
// Global pool of per-device EnvironmentMapEffect resources.
|
||||||
template<>
|
template<>
|
||||||
|
@ -356,10 +357,10 @@ EnvironmentMapEffect::Impl::Impl(
|
||||||
const EffectPipelineStateDescription& pipelineDescription,
|
const EffectPipelineStateDescription& pipelineDescription,
|
||||||
EnvironmentMapEffect::Mapping mapping)
|
EnvironmentMapEffect::Mapping mapping)
|
||||||
: EffectBase(device),
|
: EffectBase(device),
|
||||||
texture{},
|
texture{},
|
||||||
textureSampler{},
|
textureSampler{},
|
||||||
environmentMap{},
|
environmentMap{},
|
||||||
environmentMapSampler{}
|
environmentMapSampler{}
|
||||||
{
|
{
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<EnvironmentMapEffectTraits>::VertexShaderIndices)) == EnvironmentMapEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<EnvironmentMapEffectTraits>::VertexShaderIndices)) == EnvironmentMapEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<EnvironmentMapEffectTraits>::VertexShaderBytecode)) == EnvironmentMapEffectTraits::VertexShaderCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<EnvironmentMapEffectTraits>::VertexShaderBytecode)) == EnvironmentMapEffectTraits::VertexShaderCount, "array/max mismatch");
|
||||||
|
|
|
@ -55,12 +55,12 @@ namespace
|
||||||
{
|
{
|
||||||
switch (deadZoneMode)
|
switch (deadZoneMode)
|
||||||
{
|
{
|
||||||
case GamePad::DEAD_ZONE_INDEPENDENT_AXES:
|
case GamePad::DEAD_ZONE_INDEPENDENT_AXES:
|
||||||
resultX = ApplyLinearDeadZone(x, maxValue, deadZoneSize);
|
resultX = ApplyLinearDeadZone(x, maxValue, deadZoneSize);
|
||||||
resultY = ApplyLinearDeadZone(y, maxValue, deadZoneSize);
|
resultY = ApplyLinearDeadZone(y, maxValue, deadZoneSize);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GamePad::DEAD_ZONE_CIRCULAR:
|
case GamePad::DEAD_ZONE_CIRCULAR:
|
||||||
{
|
{
|
||||||
const float dist = sqrtf(x*x + y * y);
|
const float dist = sqrtf(x*x + y * y);
|
||||||
const float wanted = ApplyLinearDeadZone(dist, maxValue, deadZoneSize);
|
const float wanted = ApplyLinearDeadZone(dist, maxValue, deadZoneSize);
|
||||||
|
@ -72,15 +72,16 @@ namespace
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // GamePad::DEAD_ZONE_NONE
|
default: // GamePad::DEAD_ZONE_NONE
|
||||||
resultX = ApplyLinearDeadZone(x, maxValue, 0);
|
resultX = ApplyLinearDeadZone(x, maxValue, 0);
|
||||||
resultY = ApplyLinearDeadZone(y, maxValue, 0);
|
resultY = ApplyLinearDeadZone(y, maxValue, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Implementations
|
||||||
#ifdef USING_GAMEINPUT
|
#ifdef USING_GAMEINPUT
|
||||||
|
|
||||||
#include <GameInput.h>
|
#include <GameInput.h>
|
||||||
|
@ -289,7 +290,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
_Success_(return)
|
_Success_(return)
|
||||||
bool GetDevice(int player, _Outptr_ IGameInputDevice** device) noexcept
|
bool GetDevice(int player, _Outptr_ IGameInputDevice** device) noexcept
|
||||||
{
|
{
|
||||||
if (!device)
|
if (!device)
|
||||||
return false;
|
return false;
|
||||||
|
@ -536,12 +537,12 @@ public:
|
||||||
state.dpad.left = (reading.Buttons & GamepadButtons::GamepadButtons_DPadLeft) != 0;
|
state.dpad.left = (reading.Buttons & GamepadButtons::GamepadButtons_DPadLeft) != 0;
|
||||||
|
|
||||||
ApplyStickDeadZone(static_cast<float>(reading.LeftThumbstickX), static_cast<float>(reading.LeftThumbstickY),
|
ApplyStickDeadZone(static_cast<float>(reading.LeftThumbstickX), static_cast<float>(reading.LeftThumbstickY),
|
||||||
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
|
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
|
||||||
state.thumbSticks.leftX, state.thumbSticks.leftY);
|
state.thumbSticks.leftX, state.thumbSticks.leftY);
|
||||||
|
|
||||||
ApplyStickDeadZone(static_cast<float>(reading.RightThumbstickX), static_cast<float>(reading.RightThumbstickY),
|
ApplyStickDeadZone(static_cast<float>(reading.RightThumbstickX), static_cast<float>(reading.RightThumbstickY),
|
||||||
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
|
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
|
||||||
state.thumbSticks.rightX, state.thumbSticks.rightY);
|
state.thumbSticks.rightX, state.thumbSticks.rightY);
|
||||||
|
|
||||||
state.triggers.left = static_cast<float>(reading.LeftTrigger);
|
state.triggers.left = static_cast<float>(reading.LeftTrigger);
|
||||||
state.triggers.right = static_cast<float>(reading.RightTrigger);
|
state.triggers.right = static_cast<float>(reading.RightTrigger);
|
||||||
|
@ -1011,12 +1012,12 @@ public:
|
||||||
state.dpad.left = (reading.Buttons & GamepadButtons::GamepadButtons_DPadLeft) != 0;
|
state.dpad.left = (reading.Buttons & GamepadButtons::GamepadButtons_DPadLeft) != 0;
|
||||||
|
|
||||||
ApplyStickDeadZone(reading.LeftThumbstickX, reading.LeftThumbstickY,
|
ApplyStickDeadZone(reading.LeftThumbstickX, reading.LeftThumbstickY,
|
||||||
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
|
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
|
||||||
state.thumbSticks.leftX, state.thumbSticks.leftY);
|
state.thumbSticks.leftX, state.thumbSticks.leftY);
|
||||||
|
|
||||||
ApplyStickDeadZone(reading.RightThumbstickX, reading.RightThumbstickY,
|
ApplyStickDeadZone(reading.RightThumbstickX, reading.RightThumbstickY,
|
||||||
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
|
deadZoneMode, 1.f, c_XboxOneThumbDeadZone,
|
||||||
state.thumbSticks.rightX, state.thumbSticks.rightY);
|
state.thumbSticks.rightX, state.thumbSticks.rightY);
|
||||||
|
|
||||||
state.triggers.left = reading.LeftTrigger;
|
state.triggers.left = reading.LeftTrigger;
|
||||||
state.triggers.right = reading.RightTrigger;
|
state.triggers.right = reading.RightTrigger;
|
||||||
|
@ -1353,12 +1354,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyStickDeadZone(float(xstate.Gamepad.sThumbLX), float(xstate.Gamepad.sThumbLY),
|
ApplyStickDeadZone(float(xstate.Gamepad.sThumbLX), float(xstate.Gamepad.sThumbLY),
|
||||||
deadZoneMode, 32767.f, float(XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE),
|
deadZoneMode, 32767.f, float(XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE),
|
||||||
state.thumbSticks.leftX, state.thumbSticks.leftY);
|
state.thumbSticks.leftX, state.thumbSticks.leftY);
|
||||||
|
|
||||||
ApplyStickDeadZone(float(xstate.Gamepad.sThumbRX), float(xstate.Gamepad.sThumbRY),
|
ApplyStickDeadZone(float(xstate.Gamepad.sThumbRX), float(xstate.Gamepad.sThumbRY),
|
||||||
deadZoneMode, 32767.f, float(XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE),
|
deadZoneMode, 32767.f, float(XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE),
|
||||||
state.thumbSticks.rightX, state.thumbSticks.rightY);
|
state.thumbSticks.rightX, state.thumbSticks.rightY);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1600,6 +1601,7 @@ private:
|
||||||
GamePad::Impl* GamePad::Impl::s_gamePad = nullptr;
|
GamePad::Impl* GamePad::Impl::s_gamePad = nullptr;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
#pragma warning( disable : 4355 )
|
#pragma warning( disable : 4355 )
|
||||||
|
|
||||||
|
@ -1681,27 +1683,31 @@ GamePad& GamePad::Get()
|
||||||
|
|
||||||
#define UPDATE_BUTTON_STATE(field) field = static_cast<ButtonState>( ( !!state.buttons.field ) | ( ( !!state.buttons.field ^ !!lastState.buttons.field ) << 1 ) );
|
#define UPDATE_BUTTON_STATE(field) field = static_cast<ButtonState>( ( !!state.buttons.field ) | ( ( !!state.buttons.field ^ !!lastState.buttons.field ) << 1 ) );
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
|
||||||
|
#endif
|
||||||
|
|
||||||
void GamePad::ButtonStateTracker::Update(const GamePad::State& state) noexcept
|
void GamePad::ButtonStateTracker::Update(const GamePad::State& state) noexcept
|
||||||
{
|
{
|
||||||
UPDATE_BUTTON_STATE(a)
|
UPDATE_BUTTON_STATE(a);
|
||||||
|
|
||||||
assert((!state.buttons.a && !lastState.buttons.a) == (a == UP));
|
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 == HELD));
|
||||||
assert((!state.buttons.a && lastState.buttons.a) == (a == RELEASED));
|
assert((!state.buttons.a && lastState.buttons.a) == (a == RELEASED));
|
||||||
assert((state.buttons.a && !lastState.buttons.a) == (a == PRESSED));
|
assert((state.buttons.a && !lastState.buttons.a) == (a == PRESSED));
|
||||||
|
|
||||||
UPDATE_BUTTON_STATE(b)
|
UPDATE_BUTTON_STATE(b);
|
||||||
UPDATE_BUTTON_STATE(x)
|
UPDATE_BUTTON_STATE(x);
|
||||||
UPDATE_BUTTON_STATE(y)
|
UPDATE_BUTTON_STATE(y);
|
||||||
|
|
||||||
UPDATE_BUTTON_STATE(leftStick)
|
UPDATE_BUTTON_STATE(leftStick);
|
||||||
UPDATE_BUTTON_STATE(rightStick)
|
UPDATE_BUTTON_STATE(rightStick);
|
||||||
|
|
||||||
UPDATE_BUTTON_STATE(leftShoulder)
|
UPDATE_BUTTON_STATE(leftShoulder);
|
||||||
UPDATE_BUTTON_STATE(rightShoulder)
|
UPDATE_BUTTON_STATE(rightShoulder);
|
||||||
|
|
||||||
UPDATE_BUTTON_STATE(back)
|
UPDATE_BUTTON_STATE(back);
|
||||||
UPDATE_BUTTON_STATE(start)
|
UPDATE_BUTTON_STATE(start);
|
||||||
|
|
||||||
dpadUp = static_cast<ButtonState>((!!state.dpad.up) | ((!!state.dpad.up ^ !!lastState.dpad.up) << 1));
|
dpadUp = static_cast<ButtonState>((!!state.dpad.up) | ((!!state.dpad.up ^ !!lastState.dpad.up) << 1));
|
||||||
dpadDown = static_cast<ButtonState>((!!state.dpad.down) | ((!!state.dpad.down ^ !!lastState.dpad.down) << 1));
|
dpadDown = static_cast<ButtonState>((!!state.dpad.down) | ((!!state.dpad.down ^ !!lastState.dpad.down) << 1));
|
||||||
|
|
|
@ -327,9 +327,9 @@ void DirectX::ComputeGeoSphere(VertexCollection& vertices, IndexCollection& indi
|
||||||
XMStoreFloat3(
|
XMStoreFloat3(
|
||||||
&outVertex,
|
&outVertex,
|
||||||
XMVectorScale(
|
XMVectorScale(
|
||||||
XMVectorAdd(XMLoadFloat3(&vertexPositions[i0]), XMLoadFloat3(&vertexPositions[i1])),
|
XMVectorAdd(XMLoadFloat3(&vertexPositions[i0]), XMLoadFloat3(&vertexPositions[i1])),
|
||||||
0.5f
|
0.5f
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
outIndex = static_cast<uint16_t>(vertexPositions.size());
|
outIndex = static_cast<uint16_t>(vertexPositions.size());
|
||||||
|
@ -1140,15 +1140,15 @@ namespace
|
||||||
// Create the index data.
|
// Create the index data.
|
||||||
size_t vbase = vertices.size();
|
size_t vbase = vertices.size();
|
||||||
Bezier::CreatePatchIndices(tessellation, isMirrored, [&](size_t index)
|
Bezier::CreatePatchIndices(tessellation, isMirrored, [&](size_t index)
|
||||||
{
|
{
|
||||||
index_push_back(indices, vbase + index);
|
index_push_back(indices, vbase + index);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the vertex data.
|
// Create the vertex data.
|
||||||
Bezier::CreatePatchVertices(controlPoints, tessellation, isMirrored, [&](FXMVECTOR position, FXMVECTOR normal, FXMVECTOR textureCoordinate)
|
Bezier::CreatePatchVertices(controlPoints, tessellation, isMirrored, [&](FXMVECTOR position, FXMVECTOR normal, FXMVECTOR textureCoordinate)
|
||||||
{
|
{
|
||||||
vertices.push_back(VertexPositionNormalTexture(position, normal, textureCoordinate));
|
vertices.push_back(VertexPositionNormalTexture(position, normal, textureCoordinate));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,9 @@ namespace
|
||||||
x |= x >> 4;
|
x |= x >> 4;
|
||||||
x |= x >> 8;
|
x |= x >> 8;
|
||||||
x |= x >> 16;
|
x |= x >> 16;
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
x |= x >> 32;
|
x |= x >> 32;
|
||||||
#endif
|
#endif
|
||||||
return ++x;
|
return ++x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,26 +54,26 @@ namespace
|
||||||
// etc...
|
// etc...
|
||||||
// Need to convert to an index.
|
// Need to convert to an index.
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
unsigned long bitIndex = 0;
|
unsigned long bitIndex = 0;
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
return _BitScanForward64(&bitIndex, allocatorPageSize) ? bitIndex + 1 : 0;
|
return _BitScanForward64(&bitIndex, allocatorPageSize) ? bitIndex + 1 : 0;
|
||||||
#else
|
#else
|
||||||
return _BitScanForward(&bitIndex, static_cast<unsigned long>(allocatorPageSize)) ? bitIndex + 1 : 0;
|
return _BitScanForward(&bitIndex, static_cast<unsigned long>(allocatorPageSize)) ? bitIndex + 1 : 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
|
|
||||||
#ifdef __LP64__
|
#ifdef __LP64__
|
||||||
return static_cast<size_t>(__builtin_ffsll(static_cast<long long>(allocatorPageSize)));
|
return static_cast<size_t>(__builtin_ffsll(static_cast<long long>(allocatorPageSize)));
|
||||||
#else
|
#else
|
||||||
return static_cast<size_t>(__builtin_ffs(static_cast<int>(allocatorPageSize)));
|
return static_cast<size_t>(__builtin_ffs(static_cast<int>(allocatorPageSize)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Unknown forward bit-scan syntax
|
#error Unknown forward bit-scan syntax
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline size_t GetPageSizeFromPoolIndex(size_t x) noexcept
|
inline size_t GetPageSizeFromPoolIndex(size_t x) noexcept
|
||||||
|
@ -315,7 +315,7 @@ public:
|
||||||
m_peakCommited = 0;
|
m_peakCommited = 0;
|
||||||
m_peakBytes = 0;
|
m_peakBytes = 0;
|
||||||
m_peakPages = 0;
|
m_peakPages = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsMemory* mOwner;
|
GraphicsMemory* mOwner;
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
|
@ -443,7 +443,7 @@ GraphicsMemory& GraphicsMemory::Get(_In_opt_ ID3D12Device* device)
|
||||||
|
|
||||||
GraphicsResource::GraphicsResource() noexcept
|
GraphicsResource::GraphicsResource() noexcept
|
||||||
: mPage(nullptr)
|
: mPage(nullptr)
|
||||||
, mGpuAddress {}
|
, mGpuAddress{}
|
||||||
, mResource(nullptr)
|
, mResource(nullptr)
|
||||||
, mMemory(nullptr)
|
, mMemory(nullptr)
|
||||||
, mBufferOffset(0)
|
, mBufferOffset(0)
|
||||||
|
|
|
@ -48,6 +48,7 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Implementations
|
||||||
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_GAMES)
|
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_GAMES)
|
||||||
|
|
||||||
#include <GameInput.h>
|
#include <GameInput.h>
|
||||||
|
@ -515,46 +516,46 @@ void Keyboard::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
case WM_ACTIVATEAPP:
|
case WM_ACTIVATEAPP:
|
||||||
pImpl->Reset();
|
pImpl->Reset();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
down = true;
|
down = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vk = static_cast<int>(wParam);
|
int vk = static_cast<int>(wParam);
|
||||||
switch (vk)
|
switch (vk)
|
||||||
{
|
{
|
||||||
case VK_SHIFT:
|
case VK_SHIFT:
|
||||||
vk = static_cast<int>(
|
vk = static_cast<int>(
|
||||||
MapVirtualKeyW((static_cast<UINT>(lParam) & 0x00ff0000) >> 16u,
|
MapVirtualKeyW((static_cast<UINT>(lParam) & 0x00ff0000) >> 16u,
|
||||||
MAPVK_VSC_TO_VK_EX));
|
MAPVK_VSC_TO_VK_EX));
|
||||||
if (!down)
|
if (!down)
|
||||||
{
|
{
|
||||||
// Workaround to ensure left vs. right shift get cleared when both were pressed at same time
|
// Workaround to ensure left vs. right shift get cleared when both were pressed at same time
|
||||||
KeyUp(VK_LSHIFT, pImpl->mState);
|
KeyUp(VK_LSHIFT, pImpl->mState);
|
||||||
KeyUp(VK_RSHIFT, pImpl->mState);
|
KeyUp(VK_RSHIFT, pImpl->mState);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_CONTROL:
|
case VK_CONTROL:
|
||||||
vk = (static_cast<UINT>(lParam) & 0x01000000) ? VK_RCONTROL : VK_LCONTROL;
|
vk = (static_cast<UINT>(lParam) & 0x01000000) ? VK_RCONTROL : VK_LCONTROL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_MENU:
|
case VK_MENU:
|
||||||
vk = (static_cast<UINT>(lParam) & 0x01000000) ? VK_RMENU : VK_LMENU;
|
vk = (static_cast<UINT>(lParam) & 0x01000000) ? VK_RMENU : VK_LMENU;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (down)
|
if (down)
|
||||||
|
@ -568,6 +569,7 @@ void Keyboard::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
#pragma warning( disable : 4355 )
|
#pragma warning( disable : 4355 )
|
||||||
|
|
||||||
|
|
|
@ -125,12 +125,12 @@ namespace DirectX
|
||||||
size_t TotalMemoryUsage() const noexcept { return m_totalPages * m_increment; }
|
size_t TotalMemoryUsage() const noexcept { return m_totalPages * m_increment; }
|
||||||
size_t PageSize() const noexcept { return m_increment; }
|
size_t PageSize() const noexcept { return m_increment; }
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(PROFILE)
|
#if defined(_DEBUG) || defined(PROFILE)
|
||||||
// Debug info
|
// Debug info
|
||||||
const wchar_t* GetDebugName() const noexcept { return m_debugName.c_str(); }
|
const wchar_t* GetDebugName() const noexcept { return m_debugName.c_str(); }
|
||||||
void SetDebugName(const wchar_t* name);
|
void SetDebugName(const wchar_t* name);
|
||||||
void SetDebugName(const char* name);
|
void SetDebugName(const char* name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LinearAllocatorPage* m_pendingPages; // Pages in use by the GPU
|
LinearAllocatorPage* m_pendingPages; // Pages in use by the GPU
|
||||||
|
@ -156,13 +156,13 @@ namespace DirectX
|
||||||
void ReleasePage(LinearAllocatorPage* page) noexcept;
|
void ReleasePage(LinearAllocatorPage* page) noexcept;
|
||||||
void FreePages(LinearAllocatorPage* list) noexcept;
|
void FreePages(LinearAllocatorPage* list) noexcept;
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(PROFILE)
|
#if defined(_DEBUG) || defined(PROFILE)
|
||||||
std::wstring m_debugName;
|
std::wstring m_debugName;
|
||||||
|
|
||||||
static void ValidateList(LinearAllocatorPage* list);
|
static void ValidateList(LinearAllocatorPage* list);
|
||||||
void ValidatePageLists();
|
void ValidatePageLists();
|
||||||
|
|
||||||
void SetPageDebugName(LinearAllocatorPage* list) noexcept;
|
void SetPageDebugName(LinearAllocatorPage* list) noexcept;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,165 +28,165 @@ namespace DirectX
|
||||||
{
|
{
|
||||||
switch (fmt)
|
switch (fmt)
|
||||||
{
|
{
|
||||||
case DXGI_FORMAT_R32G32B32A32_TYPELESS:
|
case DXGI_FORMAT_R32G32B32A32_TYPELESS:
|
||||||
case DXGI_FORMAT_R32G32B32A32_FLOAT:
|
case DXGI_FORMAT_R32G32B32A32_FLOAT:
|
||||||
case DXGI_FORMAT_R32G32B32A32_UINT:
|
case DXGI_FORMAT_R32G32B32A32_UINT:
|
||||||
case DXGI_FORMAT_R32G32B32A32_SINT:
|
case DXGI_FORMAT_R32G32B32A32_SINT:
|
||||||
return 128;
|
return 128;
|
||||||
|
|
||||||
case DXGI_FORMAT_R32G32B32_TYPELESS:
|
case DXGI_FORMAT_R32G32B32_TYPELESS:
|
||||||
case DXGI_FORMAT_R32G32B32_FLOAT:
|
case DXGI_FORMAT_R32G32B32_FLOAT:
|
||||||
case DXGI_FORMAT_R32G32B32_UINT:
|
case DXGI_FORMAT_R32G32B32_UINT:
|
||||||
case DXGI_FORMAT_R32G32B32_SINT:
|
case DXGI_FORMAT_R32G32B32_SINT:
|
||||||
return 96;
|
return 96;
|
||||||
|
|
||||||
case DXGI_FORMAT_R16G16B16A16_TYPELESS:
|
case DXGI_FORMAT_R16G16B16A16_TYPELESS:
|
||||||
case DXGI_FORMAT_R16G16B16A16_FLOAT:
|
case DXGI_FORMAT_R16G16B16A16_FLOAT:
|
||||||
case DXGI_FORMAT_R16G16B16A16_UNORM:
|
case DXGI_FORMAT_R16G16B16A16_UNORM:
|
||||||
case DXGI_FORMAT_R16G16B16A16_UINT:
|
case DXGI_FORMAT_R16G16B16A16_UINT:
|
||||||
case DXGI_FORMAT_R16G16B16A16_SNORM:
|
case DXGI_FORMAT_R16G16B16A16_SNORM:
|
||||||
case DXGI_FORMAT_R16G16B16A16_SINT:
|
case DXGI_FORMAT_R16G16B16A16_SINT:
|
||||||
case DXGI_FORMAT_R32G32_TYPELESS:
|
case DXGI_FORMAT_R32G32_TYPELESS:
|
||||||
case DXGI_FORMAT_R32G32_FLOAT:
|
case DXGI_FORMAT_R32G32_FLOAT:
|
||||||
case DXGI_FORMAT_R32G32_UINT:
|
case DXGI_FORMAT_R32G32_UINT:
|
||||||
case DXGI_FORMAT_R32G32_SINT:
|
case DXGI_FORMAT_R32G32_SINT:
|
||||||
case DXGI_FORMAT_R32G8X24_TYPELESS:
|
case DXGI_FORMAT_R32G8X24_TYPELESS:
|
||||||
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
|
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
|
||||||
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
|
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
|
||||||
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
|
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
|
||||||
case DXGI_FORMAT_Y416:
|
case DXGI_FORMAT_Y416:
|
||||||
case DXGI_FORMAT_Y210:
|
case DXGI_FORMAT_Y210:
|
||||||
case DXGI_FORMAT_Y216:
|
case DXGI_FORMAT_Y216:
|
||||||
return 64;
|
return 64;
|
||||||
|
|
||||||
case DXGI_FORMAT_R10G10B10A2_TYPELESS:
|
case DXGI_FORMAT_R10G10B10A2_TYPELESS:
|
||||||
case DXGI_FORMAT_R10G10B10A2_UNORM:
|
case DXGI_FORMAT_R10G10B10A2_UNORM:
|
||||||
case DXGI_FORMAT_R10G10B10A2_UINT:
|
case DXGI_FORMAT_R10G10B10A2_UINT:
|
||||||
case DXGI_FORMAT_R11G11B10_FLOAT:
|
case DXGI_FORMAT_R11G11B10_FLOAT:
|
||||||
case DXGI_FORMAT_R8G8B8A8_TYPELESS:
|
case DXGI_FORMAT_R8G8B8A8_TYPELESS:
|
||||||
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
||||||
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
|
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_R8G8B8A8_UINT:
|
case DXGI_FORMAT_R8G8B8A8_UINT:
|
||||||
case DXGI_FORMAT_R8G8B8A8_SNORM:
|
case DXGI_FORMAT_R8G8B8A8_SNORM:
|
||||||
case DXGI_FORMAT_R8G8B8A8_SINT:
|
case DXGI_FORMAT_R8G8B8A8_SINT:
|
||||||
case DXGI_FORMAT_R16G16_TYPELESS:
|
case DXGI_FORMAT_R16G16_TYPELESS:
|
||||||
case DXGI_FORMAT_R16G16_FLOAT:
|
case DXGI_FORMAT_R16G16_FLOAT:
|
||||||
case DXGI_FORMAT_R16G16_UNORM:
|
case DXGI_FORMAT_R16G16_UNORM:
|
||||||
case DXGI_FORMAT_R16G16_UINT:
|
case DXGI_FORMAT_R16G16_UINT:
|
||||||
case DXGI_FORMAT_R16G16_SNORM:
|
case DXGI_FORMAT_R16G16_SNORM:
|
||||||
case DXGI_FORMAT_R16G16_SINT:
|
case DXGI_FORMAT_R16G16_SINT:
|
||||||
case DXGI_FORMAT_R32_TYPELESS:
|
case DXGI_FORMAT_R32_TYPELESS:
|
||||||
case DXGI_FORMAT_D32_FLOAT:
|
case DXGI_FORMAT_D32_FLOAT:
|
||||||
case DXGI_FORMAT_R32_FLOAT:
|
case DXGI_FORMAT_R32_FLOAT:
|
||||||
case DXGI_FORMAT_R32_UINT:
|
case DXGI_FORMAT_R32_UINT:
|
||||||
case DXGI_FORMAT_R32_SINT:
|
case DXGI_FORMAT_R32_SINT:
|
||||||
case DXGI_FORMAT_R24G8_TYPELESS:
|
case DXGI_FORMAT_R24G8_TYPELESS:
|
||||||
case DXGI_FORMAT_D24_UNORM_S8_UINT:
|
case DXGI_FORMAT_D24_UNORM_S8_UINT:
|
||||||
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
|
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
|
||||||
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
|
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
|
||||||
case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
|
case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
|
||||||
case DXGI_FORMAT_R8G8_B8G8_UNORM:
|
case DXGI_FORMAT_R8G8_B8G8_UNORM:
|
||||||
case DXGI_FORMAT_G8R8_G8B8_UNORM:
|
case DXGI_FORMAT_G8R8_G8B8_UNORM:
|
||||||
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
||||||
case DXGI_FORMAT_B8G8R8X8_UNORM:
|
case DXGI_FORMAT_B8G8R8X8_UNORM:
|
||||||
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
|
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
|
||||||
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
|
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
|
||||||
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
|
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_B8G8R8X8_TYPELESS:
|
case DXGI_FORMAT_B8G8R8X8_TYPELESS:
|
||||||
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
|
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_AYUV:
|
case DXGI_FORMAT_AYUV:
|
||||||
case DXGI_FORMAT_Y410:
|
case DXGI_FORMAT_Y410:
|
||||||
case DXGI_FORMAT_YUY2:
|
case DXGI_FORMAT_YUY2:
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
case DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT:
|
case DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT:
|
||||||
case DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT:
|
case DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT:
|
||||||
case DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM:
|
case DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM:
|
||||||
#endif
|
#endif
|
||||||
return 32;
|
return 32;
|
||||||
|
|
||||||
case DXGI_FORMAT_P010:
|
case DXGI_FORMAT_P010:
|
||||||
case DXGI_FORMAT_P016:
|
case DXGI_FORMAT_P016:
|
||||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
|
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
|
||||||
case DXGI_FORMAT_V408:
|
case DXGI_FORMAT_V408:
|
||||||
#endif
|
#endif
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
case DXGI_FORMAT_D16_UNORM_S8_UINT:
|
case DXGI_FORMAT_D16_UNORM_S8_UINT:
|
||||||
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
||||||
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
|
case DXGI_FORMAT_X16_TYPELESS_G8_UINT:
|
||||||
#endif
|
#endif
|
||||||
return 24;
|
return 24;
|
||||||
|
|
||||||
case DXGI_FORMAT_R8G8_TYPELESS:
|
case DXGI_FORMAT_R8G8_TYPELESS:
|
||||||
case DXGI_FORMAT_R8G8_UNORM:
|
case DXGI_FORMAT_R8G8_UNORM:
|
||||||
case DXGI_FORMAT_R8G8_UINT:
|
case DXGI_FORMAT_R8G8_UINT:
|
||||||
case DXGI_FORMAT_R8G8_SNORM:
|
case DXGI_FORMAT_R8G8_SNORM:
|
||||||
case DXGI_FORMAT_R8G8_SINT:
|
case DXGI_FORMAT_R8G8_SINT:
|
||||||
case DXGI_FORMAT_R16_TYPELESS:
|
case DXGI_FORMAT_R16_TYPELESS:
|
||||||
case DXGI_FORMAT_R16_FLOAT:
|
case DXGI_FORMAT_R16_FLOAT:
|
||||||
case DXGI_FORMAT_D16_UNORM:
|
case DXGI_FORMAT_D16_UNORM:
|
||||||
case DXGI_FORMAT_R16_UNORM:
|
case DXGI_FORMAT_R16_UNORM:
|
||||||
case DXGI_FORMAT_R16_UINT:
|
case DXGI_FORMAT_R16_UINT:
|
||||||
case DXGI_FORMAT_R16_SNORM:
|
case DXGI_FORMAT_R16_SNORM:
|
||||||
case DXGI_FORMAT_R16_SINT:
|
case DXGI_FORMAT_R16_SINT:
|
||||||
case DXGI_FORMAT_B5G6R5_UNORM:
|
case DXGI_FORMAT_B5G6R5_UNORM:
|
||||||
case DXGI_FORMAT_B5G5R5A1_UNORM:
|
case DXGI_FORMAT_B5G5R5A1_UNORM:
|
||||||
case DXGI_FORMAT_A8P8:
|
case DXGI_FORMAT_A8P8:
|
||||||
case DXGI_FORMAT_B4G4R4A4_UNORM:
|
case DXGI_FORMAT_B4G4R4A4_UNORM:
|
||||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
|
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
|
||||||
case DXGI_FORMAT_P208:
|
case DXGI_FORMAT_P208:
|
||||||
case DXGI_FORMAT_V208:
|
case DXGI_FORMAT_V208:
|
||||||
#endif
|
#endif
|
||||||
return 16;
|
return 16;
|
||||||
|
|
||||||
case DXGI_FORMAT_NV12:
|
case DXGI_FORMAT_NV12:
|
||||||
case DXGI_FORMAT_420_OPAQUE:
|
case DXGI_FORMAT_420_OPAQUE:
|
||||||
case DXGI_FORMAT_NV11:
|
case DXGI_FORMAT_NV11:
|
||||||
return 12;
|
return 12;
|
||||||
|
|
||||||
case DXGI_FORMAT_R8_TYPELESS:
|
case DXGI_FORMAT_R8_TYPELESS:
|
||||||
case DXGI_FORMAT_R8_UNORM:
|
case DXGI_FORMAT_R8_UNORM:
|
||||||
case DXGI_FORMAT_R8_UINT:
|
case DXGI_FORMAT_R8_UINT:
|
||||||
case DXGI_FORMAT_R8_SNORM:
|
case DXGI_FORMAT_R8_SNORM:
|
||||||
case DXGI_FORMAT_R8_SINT:
|
case DXGI_FORMAT_R8_SINT:
|
||||||
case DXGI_FORMAT_A8_UNORM:
|
case DXGI_FORMAT_A8_UNORM:
|
||||||
case DXGI_FORMAT_BC2_TYPELESS:
|
case DXGI_FORMAT_BC2_TYPELESS:
|
||||||
case DXGI_FORMAT_BC2_UNORM:
|
case DXGI_FORMAT_BC2_UNORM:
|
||||||
case DXGI_FORMAT_BC2_UNORM_SRGB:
|
case DXGI_FORMAT_BC2_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_BC3_TYPELESS:
|
case DXGI_FORMAT_BC3_TYPELESS:
|
||||||
case DXGI_FORMAT_BC3_UNORM:
|
case DXGI_FORMAT_BC3_UNORM:
|
||||||
case DXGI_FORMAT_BC3_UNORM_SRGB:
|
case DXGI_FORMAT_BC3_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_BC5_TYPELESS:
|
case DXGI_FORMAT_BC5_TYPELESS:
|
||||||
case DXGI_FORMAT_BC5_UNORM:
|
case DXGI_FORMAT_BC5_UNORM:
|
||||||
case DXGI_FORMAT_BC5_SNORM:
|
case DXGI_FORMAT_BC5_SNORM:
|
||||||
case DXGI_FORMAT_BC6H_TYPELESS:
|
case DXGI_FORMAT_BC6H_TYPELESS:
|
||||||
case DXGI_FORMAT_BC6H_UF16:
|
case DXGI_FORMAT_BC6H_UF16:
|
||||||
case DXGI_FORMAT_BC6H_SF16:
|
case DXGI_FORMAT_BC6H_SF16:
|
||||||
case DXGI_FORMAT_BC7_TYPELESS:
|
case DXGI_FORMAT_BC7_TYPELESS:
|
||||||
case DXGI_FORMAT_BC7_UNORM:
|
case DXGI_FORMAT_BC7_UNORM:
|
||||||
case DXGI_FORMAT_BC7_UNORM_SRGB:
|
case DXGI_FORMAT_BC7_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_AI44:
|
case DXGI_FORMAT_AI44:
|
||||||
case DXGI_FORMAT_IA44:
|
case DXGI_FORMAT_IA44:
|
||||||
case DXGI_FORMAT_P8:
|
case DXGI_FORMAT_P8:
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
case DXGI_FORMAT_R4G4_UNORM:
|
case DXGI_FORMAT_R4G4_UNORM:
|
||||||
#endif
|
#endif
|
||||||
return 8;
|
return 8;
|
||||||
|
|
||||||
case DXGI_FORMAT_R1_UNORM:
|
case DXGI_FORMAT_R1_UNORM:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case DXGI_FORMAT_BC1_TYPELESS:
|
case DXGI_FORMAT_BC1_TYPELESS:
|
||||||
case DXGI_FORMAT_BC1_UNORM:
|
case DXGI_FORMAT_BC1_UNORM:
|
||||||
case DXGI_FORMAT_BC1_UNORM_SRGB:
|
case DXGI_FORMAT_BC1_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_BC4_TYPELESS:
|
case DXGI_FORMAT_BC4_TYPELESS:
|
||||||
case DXGI_FORMAT_BC4_UNORM:
|
case DXGI_FORMAT_BC4_UNORM:
|
||||||
case DXGI_FORMAT_BC4_SNORM:
|
case DXGI_FORMAT_BC4_SNORM:
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
case DXGI_FORMAT_UNKNOWN:
|
case DXGI_FORMAT_UNKNOWN:
|
||||||
case DXGI_FORMAT_FORCE_UINT:
|
case DXGI_FORMAT_FORCE_UINT:
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,29 +195,29 @@ namespace DirectX
|
||||||
{
|
{
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
||||||
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||||
|
|
||||||
case DXGI_FORMAT_BC1_UNORM:
|
case DXGI_FORMAT_BC1_UNORM:
|
||||||
return DXGI_FORMAT_BC1_UNORM_SRGB;
|
return DXGI_FORMAT_BC1_UNORM_SRGB;
|
||||||
|
|
||||||
case DXGI_FORMAT_BC2_UNORM:
|
case DXGI_FORMAT_BC2_UNORM:
|
||||||
return DXGI_FORMAT_BC2_UNORM_SRGB;
|
return DXGI_FORMAT_BC2_UNORM_SRGB;
|
||||||
|
|
||||||
case DXGI_FORMAT_BC3_UNORM:
|
case DXGI_FORMAT_BC3_UNORM:
|
||||||
return DXGI_FORMAT_BC3_UNORM_SRGB;
|
return DXGI_FORMAT_BC3_UNORM_SRGB;
|
||||||
|
|
||||||
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
||||||
return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
||||||
|
|
||||||
case DXGI_FORMAT_B8G8R8X8_UNORM:
|
case DXGI_FORMAT_B8G8R8X8_UNORM:
|
||||||
return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB;
|
return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB;
|
||||||
|
|
||||||
case DXGI_FORMAT_BC7_UNORM:
|
case DXGI_FORMAT_BC7_UNORM:
|
||||||
return DXGI_FORMAT_BC7_UNORM_SRGB;
|
return DXGI_FORMAT_BC7_UNORM_SRGB;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,31 +226,31 @@ namespace DirectX
|
||||||
{
|
{
|
||||||
switch (fmt)
|
switch (fmt)
|
||||||
{
|
{
|
||||||
case DXGI_FORMAT_BC1_TYPELESS:
|
case DXGI_FORMAT_BC1_TYPELESS:
|
||||||
case DXGI_FORMAT_BC1_UNORM:
|
case DXGI_FORMAT_BC1_UNORM:
|
||||||
case DXGI_FORMAT_BC1_UNORM_SRGB:
|
case DXGI_FORMAT_BC1_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_BC2_TYPELESS:
|
case DXGI_FORMAT_BC2_TYPELESS:
|
||||||
case DXGI_FORMAT_BC2_UNORM:
|
case DXGI_FORMAT_BC2_UNORM:
|
||||||
case DXGI_FORMAT_BC2_UNORM_SRGB:
|
case DXGI_FORMAT_BC2_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_BC3_TYPELESS:
|
case DXGI_FORMAT_BC3_TYPELESS:
|
||||||
case DXGI_FORMAT_BC3_UNORM:
|
case DXGI_FORMAT_BC3_UNORM:
|
||||||
case DXGI_FORMAT_BC3_UNORM_SRGB:
|
case DXGI_FORMAT_BC3_UNORM_SRGB:
|
||||||
case DXGI_FORMAT_BC4_TYPELESS:
|
case DXGI_FORMAT_BC4_TYPELESS:
|
||||||
case DXGI_FORMAT_BC4_UNORM:
|
case DXGI_FORMAT_BC4_UNORM:
|
||||||
case DXGI_FORMAT_BC4_SNORM:
|
case DXGI_FORMAT_BC4_SNORM:
|
||||||
case DXGI_FORMAT_BC5_TYPELESS:
|
case DXGI_FORMAT_BC5_TYPELESS:
|
||||||
case DXGI_FORMAT_BC5_UNORM:
|
case DXGI_FORMAT_BC5_UNORM:
|
||||||
case DXGI_FORMAT_BC5_SNORM:
|
case DXGI_FORMAT_BC5_SNORM:
|
||||||
case DXGI_FORMAT_BC6H_TYPELESS:
|
case DXGI_FORMAT_BC6H_TYPELESS:
|
||||||
case DXGI_FORMAT_BC6H_UF16:
|
case DXGI_FORMAT_BC6H_UF16:
|
||||||
case DXGI_FORMAT_BC6H_SF16:
|
case DXGI_FORMAT_BC6H_SF16:
|
||||||
case DXGI_FORMAT_BC7_TYPELESS:
|
case DXGI_FORMAT_BC7_TYPELESS:
|
||||||
case DXGI_FORMAT_BC7_UNORM:
|
case DXGI_FORMAT_BC7_UNORM:
|
||||||
case DXGI_FORMAT_BC7_UNORM_SRGB:
|
case DXGI_FORMAT_BC7_UNORM_SRGB:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,26 +260,26 @@ namespace DirectX
|
||||||
// Assumes UNORM or FLOAT; doesn't use UINT or SINT
|
// Assumes UNORM or FLOAT; doesn't use UINT or SINT
|
||||||
switch (fmt)
|
switch (fmt)
|
||||||
{
|
{
|
||||||
case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||||
case DXGI_FORMAT_R32G32B32_TYPELESS: return DXGI_FORMAT_R32G32B32_FLOAT;
|
case DXGI_FORMAT_R32G32B32_TYPELESS: return DXGI_FORMAT_R32G32B32_FLOAT;
|
||||||
case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_UNORM;
|
case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_UNORM;
|
||||||
case DXGI_FORMAT_R32G32_TYPELESS: return DXGI_FORMAT_R32G32_FLOAT;
|
case DXGI_FORMAT_R32G32_TYPELESS: return DXGI_FORMAT_R32G32_FLOAT;
|
||||||
case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM;
|
case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||||
case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM;
|
case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_UNORM;
|
case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_UNORM;
|
||||||
case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT;
|
case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT;
|
||||||
case DXGI_FORMAT_R8G8_TYPELESS: return DXGI_FORMAT_R8G8_UNORM;
|
case DXGI_FORMAT_R8G8_TYPELESS: return DXGI_FORMAT_R8G8_UNORM;
|
||||||
case DXGI_FORMAT_R16_TYPELESS: return DXGI_FORMAT_R16_UNORM;
|
case DXGI_FORMAT_R16_TYPELESS: return DXGI_FORMAT_R16_UNORM;
|
||||||
case DXGI_FORMAT_R8_TYPELESS: return DXGI_FORMAT_R8_UNORM;
|
case DXGI_FORMAT_R8_TYPELESS: return DXGI_FORMAT_R8_UNORM;
|
||||||
case DXGI_FORMAT_BC1_TYPELESS: return DXGI_FORMAT_BC1_UNORM;
|
case DXGI_FORMAT_BC1_TYPELESS: return DXGI_FORMAT_BC1_UNORM;
|
||||||
case DXGI_FORMAT_BC2_TYPELESS: return DXGI_FORMAT_BC2_UNORM;
|
case DXGI_FORMAT_BC2_TYPELESS: return DXGI_FORMAT_BC2_UNORM;
|
||||||
case DXGI_FORMAT_BC3_TYPELESS: return DXGI_FORMAT_BC3_UNORM;
|
case DXGI_FORMAT_BC3_TYPELESS: return DXGI_FORMAT_BC3_UNORM;
|
||||||
case DXGI_FORMAT_BC4_TYPELESS: return DXGI_FORMAT_BC4_UNORM;
|
case DXGI_FORMAT_BC4_TYPELESS: return DXGI_FORMAT_BC4_UNORM;
|
||||||
case DXGI_FORMAT_BC5_TYPELESS: return DXGI_FORMAT_BC5_UNORM;
|
case DXGI_FORMAT_BC5_TYPELESS: return DXGI_FORMAT_BC5_UNORM;
|
||||||
case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM;
|
case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||||
case DXGI_FORMAT_B8G8R8X8_TYPELESS: return DXGI_FORMAT_B8G8R8X8_UNORM;
|
case DXGI_FORMAT_B8G8R8X8_TYPELESS: return DXGI_FORMAT_B8G8R8X8_UNORM;
|
||||||
case DXGI_FORMAT_BC7_TYPELESS: return DXGI_FORMAT_BC7_UNORM;
|
case DXGI_FORMAT_BC7_TYPELESS: return DXGI_FORMAT_BC7_UNORM;
|
||||||
default: return fmt;
|
default: return fmt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ namespace DirectX
|
||||||
fileInfo.EndOfFile.LowPart,
|
fileInfo.EndOfFile.LowPart,
|
||||||
&bytesRead,
|
&bytesRead,
|
||||||
nullptr
|
nullptr
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
ddsData.reset();
|
ddsData.reset();
|
||||||
return HRESULT_FROM_WIN32(GetLastError());
|
return HRESULT_FROM_WIN32(GetLastError());
|
||||||
|
@ -537,9 +537,9 @@ namespace DirectX
|
||||||
|
|
||||||
case DXGI_FORMAT_NV12:
|
case DXGI_FORMAT_NV12:
|
||||||
case DXGI_FORMAT_420_OPAQUE:
|
case DXGI_FORMAT_420_OPAQUE:
|
||||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
|
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
|
||||||
case DXGI_FORMAT_P208:
|
case DXGI_FORMAT_P208:
|
||||||
#endif
|
#endif
|
||||||
planar = true;
|
planar = true;
|
||||||
bpe = 2;
|
bpe = 2;
|
||||||
break;
|
break;
|
||||||
|
@ -550,7 +550,7 @@ namespace DirectX
|
||||||
bpe = 4;
|
bpe = 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
|
|
||||||
case DXGI_FORMAT_D16_UNORM_S8_UINT:
|
case DXGI_FORMAT_D16_UNORM_S8_UINT:
|
||||||
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
case DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
||||||
|
@ -559,7 +559,7 @@ namespace DirectX
|
||||||
bpe = 4;
|
bpe = 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -644,7 +644,7 @@ namespace DirectX
|
||||||
// Note that sRGB formats are written using the "DX10" extended header
|
// Note that sRGB formats are written using the "DX10" extended header
|
||||||
|
|
||||||
switch (ddpf.RGBBitCount)
|
switch (ddpf.RGBBitCount)
|
||||||
{
|
{
|
||||||
case 32:
|
case 32:
|
||||||
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))
|
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))
|
||||||
{
|
{
|
||||||
|
@ -871,31 +871,31 @@ namespace DirectX
|
||||||
// Check for D3DFORMAT enums being set here
|
// Check for D3DFORMAT enums being set here
|
||||||
switch (ddpf.fourCC)
|
switch (ddpf.fourCC)
|
||||||
{
|
{
|
||||||
case 36: // D3DFMT_A16B16G16R16
|
case 36: // D3DFMT_A16B16G16R16
|
||||||
return DXGI_FORMAT_R16G16B16A16_UNORM;
|
return DXGI_FORMAT_R16G16B16A16_UNORM;
|
||||||
|
|
||||||
case 110: // D3DFMT_Q16W16V16U16
|
case 110: // D3DFMT_Q16W16V16U16
|
||||||
return DXGI_FORMAT_R16G16B16A16_SNORM;
|
return DXGI_FORMAT_R16G16B16A16_SNORM;
|
||||||
|
|
||||||
case 111: // D3DFMT_R16F
|
case 111: // D3DFMT_R16F
|
||||||
return DXGI_FORMAT_R16_FLOAT;
|
return DXGI_FORMAT_R16_FLOAT;
|
||||||
|
|
||||||
case 112: // D3DFMT_G16R16F
|
case 112: // D3DFMT_G16R16F
|
||||||
return DXGI_FORMAT_R16G16_FLOAT;
|
return DXGI_FORMAT_R16G16_FLOAT;
|
||||||
|
|
||||||
case 113: // D3DFMT_A16B16G16R16F
|
case 113: // D3DFMT_A16B16G16R16F
|
||||||
return DXGI_FORMAT_R16G16B16A16_FLOAT;
|
return DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||||
|
|
||||||
case 114: // D3DFMT_R32F
|
case 114: // D3DFMT_R32F
|
||||||
return DXGI_FORMAT_R32_FLOAT;
|
return DXGI_FORMAT_R32_FLOAT;
|
||||||
|
|
||||||
case 115: // D3DFMT_G32R32F
|
case 115: // D3DFMT_G32R32F
|
||||||
return DXGI_FORMAT_R32G32_FLOAT;
|
return DXGI_FORMAT_R32G32_FLOAT;
|
||||||
|
|
||||||
case 116: // D3DFMT_A32B32G32R32F
|
case 116: // D3DFMT_A32B32G32R32F
|
||||||
return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||||
|
|
||||||
// No DXGI format maps to D3DFMT_CxV8U8
|
// No DXGI format maps to D3DFMT_CxV8U8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -915,19 +915,19 @@ namespace DirectX
|
||||||
auto const mode = static_cast<DDS_ALPHA_MODE>(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
|
auto const mode = static_cast<DDS_ALPHA_MODE>(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case DDS_ALPHA_MODE_STRAIGHT:
|
case DDS_ALPHA_MODE_STRAIGHT:
|
||||||
case DDS_ALPHA_MODE_PREMULTIPLIED:
|
case DDS_ALPHA_MODE_PREMULTIPLIED:
|
||||||
case DDS_ALPHA_MODE_OPAQUE:
|
case DDS_ALPHA_MODE_OPAQUE:
|
||||||
case DDS_ALPHA_MODE_CUSTOM:
|
case DDS_ALPHA_MODE_CUSTOM:
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
case DDS_ALPHA_MODE_UNKNOWN:
|
case DDS_ALPHA_MODE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((MAKEFOURCC('D', 'X', 'T', '2') == header->ddspf.fourCC)
|
else if ((MAKEFOURCC('D', 'X', 'T', '2') == header->ddspf.fourCC)
|
||||||
|| (MAKEFOURCC('D', 'X', 'T', '4') == header->ddspf.fourCC))
|
|| (MAKEFOURCC('D', 'X', 'T', '4') == header->ddspf.fourCC))
|
||||||
{
|
{
|
||||||
return DDS_ALPHA_MODE_PREMULTIPLIED;
|
return DDS_ALPHA_MODE_PREMULTIPLIED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,12 @@ namespace
|
||||||
{
|
{
|
||||||
enum : unsigned int
|
enum : unsigned int
|
||||||
{
|
{
|
||||||
PER_VERTEX_COLOR = 0x1,
|
PER_VERTEX_COLOR = 0x1,
|
||||||
SKINNING = 0x2,
|
SKINNING = 0x2,
|
||||||
DUAL_TEXTURE = 0x4,
|
DUAL_TEXTURE = 0x4,
|
||||||
NORMAL_MAPS = 0x8,
|
NORMAL_MAPS = 0x8,
|
||||||
BIASED_VERTEX_NORMALS = 0x10,
|
BIASED_VERTEX_NORMALS = 0x10,
|
||||||
USES_OBSOLETE_DEC3N = 0x20,
|
USES_OBSOLETE_DEC3N = 0x20,
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetUniqueTextureIndex(const wchar_t* textureName, std::map<std::wstring, int>& textureDictionary)
|
int GetUniqueTextureIndex(const wchar_t* textureName, std::map<std::wstring, int>& textureDictionary)
|
||||||
|
@ -72,7 +72,7 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t sizeOfBuffer>
|
template<size_t sizeOfBuffer>
|
||||||
inline void ASCIIToWChar(wchar_t (&buffer)[sizeOfBuffer], const char *ascii)
|
inline void ASCIIToWChar(wchar_t(&buffer)[sizeOfBuffer], const char *ascii)
|
||||||
{
|
{
|
||||||
MultiByteToWideChar(CP_UTF8, 0, ascii, -1, buffer, sizeOfBuffer);
|
MultiByteToWideChar(CP_UTF8, 0, ascii, -1, buffer, sizeOfBuffer);
|
||||||
}
|
}
|
||||||
|
@ -255,24 +255,24 @@ namespace
|
||||||
bool unk = false;
|
bool unk = false;
|
||||||
switch (decl[index].Type)
|
switch (decl[index].Type)
|
||||||
{
|
{
|
||||||
case D3DDECLTYPE_FLOAT3: assert(desc.Format == DXGI_FORMAT_R32G32B32_FLOAT); offset += 12; break;
|
case D3DDECLTYPE_FLOAT3: assert(desc.Format == DXGI_FORMAT_R32G32B32_FLOAT); offset += 12; break;
|
||||||
case D3DDECLTYPE_UBYTE4N: desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
|
case D3DDECLTYPE_UBYTE4N: desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
|
||||||
case D3DDECLTYPE_SHORT4N: desc.Format = DXGI_FORMAT_R16G16B16A16_SNORM; offset += 8; break;
|
case D3DDECLTYPE_SHORT4N: desc.Format = DXGI_FORMAT_R16G16B16A16_SNORM; offset += 8; break;
|
||||||
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
|
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
|
||||||
case D3DDECLTYPE_DXGI_R10G10B10A2_UNORM: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
|
case D3DDECLTYPE_DXGI_R10G10B10A2_UNORM: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
|
||||||
case D3DDECLTYPE_DXGI_R11G11B10_FLOAT: desc.Format = DXGI_FORMAT_R11G11B10_FLOAT; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
|
case D3DDECLTYPE_DXGI_R11G11B10_FLOAT: desc.Format = DXGI_FORMAT_R11G11B10_FLOAT; flags |= BIASED_VERTEX_NORMALS; offset += 4; break;
|
||||||
case D3DDECLTYPE_DXGI_R8G8B8A8_SNORM: desc.Format = DXGI_FORMAT_R8G8B8A8_SNORM; offset += 4; break;
|
case D3DDECLTYPE_DXGI_R8G8B8A8_SNORM: desc.Format = DXGI_FORMAT_R8G8B8A8_SNORM; offset += 4; break;
|
||||||
|
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
case D3DDECLTYPE_DEC3N: desc.Format = DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM; offset += 4; break;
|
case D3DDECLTYPE_DEC3N: desc.Format = DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM; offset += 4; break;
|
||||||
case (32 + DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM): desc.Format = DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM; offset += 4; break;
|
case (32 + DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM): desc.Format = DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM; offset += 4; break;
|
||||||
#else
|
#else
|
||||||
case D3DDECLTYPE_DEC3N: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; flags |= USES_OBSOLETE_DEC3N; offset += 4; break;
|
case D3DDECLTYPE_DEC3N: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; flags |= USES_OBSOLETE_DEC3N; offset += 4; break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
unk = true;
|
unk = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unk)
|
if (unk)
|
||||||
|
@ -287,16 +287,16 @@ namespace
|
||||||
bool unk = false;
|
bool unk = false;
|
||||||
switch (decl[index].Type)
|
switch (decl[index].Type)
|
||||||
{
|
{
|
||||||
case D3DDECLTYPE_FLOAT4: desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; offset += 16; break;
|
case D3DDECLTYPE_FLOAT4: desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; offset += 16; break;
|
||||||
case D3DDECLTYPE_D3DCOLOR: assert(desc.Format == DXGI_FORMAT_B8G8R8A8_UNORM); offset += 4; break;
|
case D3DDECLTYPE_D3DCOLOR: assert(desc.Format == DXGI_FORMAT_B8G8R8A8_UNORM); offset += 4; break;
|
||||||
case D3DDECLTYPE_UBYTE4N: desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; offset += 4; break;
|
case D3DDECLTYPE_UBYTE4N: desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; offset += 4; break;
|
||||||
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
|
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
|
||||||
case D3DDECLTYPE_DXGI_R10G10B10A2_UNORM: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; offset += 4; break;
|
case D3DDECLTYPE_DXGI_R10G10B10A2_UNORM: desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; offset += 4; break;
|
||||||
case D3DDECLTYPE_DXGI_R11G11B10_FLOAT: desc.Format = DXGI_FORMAT_R11G11B10_FLOAT; offset += 4; break;
|
case D3DDECLTYPE_DXGI_R11G11B10_FLOAT: desc.Format = DXGI_FORMAT_R11G11B10_FLOAT; offset += 4; break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
unk = true;
|
unk = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unk)
|
if (unk)
|
||||||
|
@ -314,16 +314,16 @@ namespace
|
||||||
bool unk = false;
|
bool unk = false;
|
||||||
switch (decl[index].Type)
|
switch (decl[index].Type)
|
||||||
{
|
{
|
||||||
case D3DDECLTYPE_FLOAT1: desc.Format = DXGI_FORMAT_R32_FLOAT; offset += 4; break;
|
case D3DDECLTYPE_FLOAT1: desc.Format = DXGI_FORMAT_R32_FLOAT; offset += 4; break;
|
||||||
case D3DDECLTYPE_FLOAT2: assert(desc.Format == DXGI_FORMAT_R32G32_FLOAT); offset += 8; break;
|
case D3DDECLTYPE_FLOAT2: assert(desc.Format == DXGI_FORMAT_R32G32_FLOAT); offset += 8; break;
|
||||||
case D3DDECLTYPE_FLOAT3: desc.Format = DXGI_FORMAT_R32G32B32_FLOAT; offset += 12; break;
|
case D3DDECLTYPE_FLOAT3: desc.Format = DXGI_FORMAT_R32G32B32_FLOAT; offset += 12; break;
|
||||||
case D3DDECLTYPE_FLOAT4: desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; offset += 16; 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_2: desc.Format = DXGI_FORMAT_R16G16_FLOAT; offset += 4; break;
|
||||||
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
|
case D3DDECLTYPE_FLOAT16_4: desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; offset += 8; break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
unk = true;
|
unk = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unk)
|
if (unk)
|
||||||
|
@ -526,7 +526,7 @@ std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH(
|
||||||
if (dec3nwarning)
|
if (dec3nwarning)
|
||||||
{
|
{
|
||||||
DebugTrace("WARNING: Vertex declaration uses legacy Direct3D 9 D3DDECLTYPE_DEC3N which has no DXGI equivalent\n"
|
DebugTrace("WARNING: Vertex declaration uses legacy Direct3D 9 D3DDECLTYPE_DEC3N which has no DXGI equivalent\n"
|
||||||
" (treating as DXGI_FORMAT_R10G10B10A2_UNORM which is not a signed format)\n");
|
" (treating as DXGI_FORMAT_R10G10B10A2_UNORM which is not a signed format)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate index buffers
|
// Validate index buffers
|
||||||
|
@ -622,22 +622,22 @@ std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH(
|
||||||
D3D_PRIMITIVE_TOPOLOGY primType;
|
D3D_PRIMITIVE_TOPOLOGY primType;
|
||||||
switch (subset.PrimitiveType)
|
switch (subset.PrimitiveType)
|
||||||
{
|
{
|
||||||
case DXUT::PT_TRIANGLE_LIST: primType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; break;
|
case DXUT::PT_TRIANGLE_LIST: primType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; break;
|
||||||
case DXUT::PT_TRIANGLE_STRIP: primType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; break;
|
case DXUT::PT_TRIANGLE_STRIP: primType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; break;
|
||||||
case DXUT::PT_LINE_LIST: primType = D3D_PRIMITIVE_TOPOLOGY_LINELIST; break;
|
case DXUT::PT_LINE_LIST: primType = D3D_PRIMITIVE_TOPOLOGY_LINELIST; break;
|
||||||
case DXUT::PT_LINE_STRIP: primType = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; break;
|
case DXUT::PT_LINE_STRIP: primType = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; break;
|
||||||
case DXUT::PT_POINT_LIST: primType = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; break;
|
case DXUT::PT_POINT_LIST: primType = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; break;
|
||||||
case DXUT::PT_TRIANGLE_LIST_ADJ: primType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ; break;
|
case DXUT::PT_TRIANGLE_LIST_ADJ: primType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ; break;
|
||||||
case DXUT::PT_TRIANGLE_STRIP_ADJ: primType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ; break;
|
case DXUT::PT_TRIANGLE_STRIP_ADJ: primType = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ; break;
|
||||||
case DXUT::PT_LINE_LIST_ADJ: primType = D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; break;
|
case DXUT::PT_LINE_LIST_ADJ: primType = D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; break;
|
||||||
case DXUT::PT_LINE_STRIP_ADJ: primType = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ; break;
|
case DXUT::PT_LINE_STRIP_ADJ: primType = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ; break;
|
||||||
|
|
||||||
case DXUT::PT_QUAD_PATCH_LIST:
|
case DXUT::PT_QUAD_PATCH_LIST:
|
||||||
case DXUT::PT_TRIANGLE_PATCH_LIST:
|
case DXUT::PT_TRIANGLE_PATCH_LIST:
|
||||||
throw std::runtime_error("Direct3D9 era tessellation not supported");
|
throw std::runtime_error("Direct3D9 era tessellation not supported");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Unknown primitive type");
|
throw std::runtime_error("Unknown primitive type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subset.MaterialID >= header->NumMaterials)
|
if (subset.MaterialID >= header->NumMaterials)
|
||||||
|
|
271
Src/Mouse.cpp
271
Src/Mouse.cpp
|
@ -16,7 +16,7 @@
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
|
|
||||||
|
#pragma region Implementations
|
||||||
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_GAMES)
|
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_GAMES)
|
||||||
|
|
||||||
#include <GameInput.h>
|
#include <GameInput.h>
|
||||||
|
@ -1148,16 +1148,16 @@ void Mouse::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
HANDLE events[3] = { pImpl->mScrollWheelValue.get(), pImpl->mAbsoluteMode.get(), pImpl->mRelativeMode.get() };
|
HANDLE events[3] = { pImpl->mScrollWheelValue.get(), pImpl->mAbsoluteMode.get(), pImpl->mRelativeMode.get() };
|
||||||
switch (WaitForMultipleObjectsEx(static_cast<DWORD>(std::size(events)), events, FALSE, 0, FALSE))
|
switch (WaitForMultipleObjectsEx(static_cast<DWORD>(std::size(events)), events, FALSE, 0, FALSE))
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case WAIT_TIMEOUT:
|
case WAIT_TIMEOUT:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
pImpl->mState.scrollWheelValue = 0;
|
pImpl->mState.scrollWheelValue = 0;
|
||||||
ResetEvent(events[0]);
|
ResetEvent(events[0]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (WAIT_OBJECT_0 + 1):
|
case (WAIT_OBJECT_0 + 1):
|
||||||
{
|
{
|
||||||
pImpl->mMode = MODE_ABSOLUTE;
|
pImpl->mMode = MODE_ABSOLUTE;
|
||||||
ClipCursor(nullptr);
|
ClipCursor(nullptr);
|
||||||
|
@ -1178,7 +1178,7 @@ void Mouse::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (WAIT_OBJECT_0 + 2):
|
case (WAIT_OBJECT_0 + 2):
|
||||||
{
|
{
|
||||||
ResetEvent(pImpl->mRelativeRead.get());
|
ResetEvent(pImpl->mRelativeRead.get());
|
||||||
|
|
||||||
|
@ -1193,154 +1193,154 @@ void Mouse::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAIT_FAILED:
|
case WAIT_FAILED:
|
||||||
throw std::system_error(std::error_code(static_cast<int>(GetLastError()), std::system_category()), "WaitForMultipleObjectsEx");
|
throw std::system_error(std::error_code(static_cast<int>(GetLastError()), std::system_category()), "WaitForMultipleObjectsEx");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
case WM_ACTIVATEAPP:
|
case WM_ACTIVATEAPP:
|
||||||
if (wParam)
|
if (wParam)
|
||||||
|
{
|
||||||
|
pImpl->mInFocus = true;
|
||||||
|
|
||||||
|
if (pImpl->mMode == MODE_RELATIVE)
|
||||||
{
|
{
|
||||||
pImpl->mInFocus = true;
|
pImpl->mState.x = pImpl->mState.y = 0;
|
||||||
|
|
||||||
if (pImpl->mMode == MODE_RELATIVE)
|
ShowCursor(FALSE);
|
||||||
{
|
|
||||||
pImpl->mState.x = pImpl->mState.y = 0;
|
|
||||||
|
|
||||||
ShowCursor(FALSE);
|
pImpl->ClipToWindow();
|
||||||
|
|
||||||
pImpl->ClipToWindow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int scrollWheel = pImpl->mState.scrollWheelValue;
|
||||||
|
memset(&pImpl->mState, 0, sizeof(State));
|
||||||
|
pImpl->mState.scrollWheelValue = scrollWheel;
|
||||||
|
|
||||||
|
if (pImpl->mMode == MODE_RELATIVE)
|
||||||
{
|
{
|
||||||
const int scrollWheel = pImpl->mState.scrollWheelValue;
|
ClipCursor(nullptr);
|
||||||
memset(&pImpl->mState, 0, sizeof(State));
|
|
||||||
pImpl->mState.scrollWheelValue = scrollWheel;
|
|
||||||
|
|
||||||
if (pImpl->mMode == MODE_RELATIVE)
|
|
||||||
{
|
|
||||||
ClipCursor(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
pImpl->mInFocus = false;
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
case WM_INPUT:
|
pImpl->mInFocus = false;
|
||||||
if (pImpl->mInFocus && pImpl->mMode == MODE_RELATIVE)
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
case WM_INPUT:
|
||||||
|
if (pImpl->mInFocus && pImpl->mMode == MODE_RELATIVE)
|
||||||
|
{
|
||||||
|
RAWINPUT raw;
|
||||||
|
UINT rawSize = sizeof(raw);
|
||||||
|
|
||||||
|
const UINT resultData = GetRawInputData(reinterpret_cast<HRAWINPUT>(lParam), RID_INPUT, &raw, &rawSize, sizeof(RAWINPUTHEADER));
|
||||||
|
if (resultData == UINT(-1))
|
||||||
{
|
{
|
||||||
RAWINPUT raw;
|
throw std::runtime_error("GetRawInputData");
|
||||||
UINT rawSize = sizeof(raw);
|
}
|
||||||
|
|
||||||
const UINT resultData = GetRawInputData(reinterpret_cast<HRAWINPUT>(lParam), RID_INPUT, &raw, &rawSize, sizeof(RAWINPUTHEADER));
|
if (raw.header.dwType == RIM_TYPEMOUSE)
|
||||||
if (resultData == UINT(-1))
|
{
|
||||||
|
if (!(raw.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE))
|
||||||
{
|
{
|
||||||
throw std::runtime_error("GetRawInputData");
|
pImpl->mState.x = raw.data.mouse.lLastX;
|
||||||
|
pImpl->mState.y = raw.data.mouse.lLastY;
|
||||||
|
|
||||||
|
ResetEvent(pImpl->mRelativeRead.get());
|
||||||
}
|
}
|
||||||
|
else if (raw.data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP)
|
||||||
if (raw.header.dwType == RIM_TYPEMOUSE)
|
|
||||||
{
|
{
|
||||||
if (!(raw.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE))
|
// This is used to make Remote Desktop sessons work
|
||||||
|
const int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||||
|
const int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||||
|
|
||||||
|
auto const x = static_cast<int>((float(raw.data.mouse.lLastX) / 65535.0f) * float(width));
|
||||||
|
auto const y = static_cast<int>((float(raw.data.mouse.lLastY) / 65535.0f) * float(height));
|
||||||
|
|
||||||
|
if (pImpl->mRelativeX == INT32_MAX)
|
||||||
{
|
{
|
||||||
pImpl->mState.x = raw.data.mouse.lLastX;
|
pImpl->mState.x = pImpl->mState.y = 0;
|
||||||
pImpl->mState.y = raw.data.mouse.lLastY;
|
|
||||||
|
|
||||||
ResetEvent(pImpl->mRelativeRead.get());
|
|
||||||
}
|
}
|
||||||
else if (raw.data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP)
|
else
|
||||||
{
|
{
|
||||||
// This is used to make Remote Desktop sessons work
|
pImpl->mState.x = x - pImpl->mRelativeX;
|
||||||
const int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
pImpl->mState.y = y - pImpl->mRelativeY;
|
||||||
const int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
|
||||||
|
|
||||||
auto const x = static_cast<int>((float(raw.data.mouse.lLastX) / 65535.0f) * float(width));
|
|
||||||
auto const y = static_cast<int>((float(raw.data.mouse.lLastY) / 65535.0f) * float(height));
|
|
||||||
|
|
||||||
if (pImpl->mRelativeX == INT32_MAX)
|
|
||||||
{
|
|
||||||
pImpl->mState.x = pImpl->mState.y = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pImpl->mState.x = x - pImpl->mRelativeX;
|
|
||||||
pImpl->mState.y = y - pImpl->mRelativeY;
|
|
||||||
}
|
|
||||||
|
|
||||||
pImpl->mRelativeX = x;
|
|
||||||
pImpl->mRelativeY = y;
|
|
||||||
|
|
||||||
ResetEvent(pImpl->mRelativeRead.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pImpl->mRelativeX = x;
|
||||||
|
pImpl->mRelativeY = y;
|
||||||
|
|
||||||
|
ResetEvent(pImpl->mRelativeRead.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
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;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case XBUTTON2:
|
||||||
pImpl->mState.leftButton = true;
|
pImpl->mState.xButton2 = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_XBUTTONUP:
|
||||||
|
switch (GET_XBUTTON_WPARAM(wParam))
|
||||||
|
{
|
||||||
|
case XBUTTON1:
|
||||||
|
pImpl->mState.xButton1 = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case XBUTTON2:
|
||||||
pImpl->mState.leftButton = false;
|
pImpl->mState.xButton2 = false;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_MOUSEHOVER:
|
||||||
pImpl->mState.rightButton = true;
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_RBUTTONUP:
|
default:
|
||||||
pImpl->mState.rightButton = false;
|
// Not a mouse message, so exit
|
||||||
break;
|
return;
|
||||||
|
|
||||||
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)
|
if (pImpl->mMode == MODE_ABSOLUTE)
|
||||||
|
@ -1355,6 +1355,7 @@ void Mouse::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
#pragma warning( disable : 4355 )
|
#pragma warning( disable : 4355 )
|
||||||
|
|
||||||
|
@ -1437,19 +1438,23 @@ Mouse& Mouse::Get()
|
||||||
|
|
||||||
#define UPDATE_BUTTON_STATE(field) field = static_cast<ButtonState>( ( !!state.field ) | ( ( !!state.field ^ !!lastState.field ) << 1 ) );
|
#define UPDATE_BUTTON_STATE(field) field = static_cast<ButtonState>( ( !!state.field ) | ( ( !!state.field ^ !!lastState.field ) << 1 ) );
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
|
||||||
|
#endif
|
||||||
|
|
||||||
void Mouse::ButtonStateTracker::Update(const Mouse::State& state) noexcept
|
void Mouse::ButtonStateTracker::Update(const Mouse::State& state) noexcept
|
||||||
{
|
{
|
||||||
UPDATE_BUTTON_STATE(leftButton)
|
UPDATE_BUTTON_STATE(leftButton);
|
||||||
|
|
||||||
assert((!state.leftButton && !lastState.leftButton) == (leftButton == UP));
|
assert((!state.leftButton && !lastState.leftButton) == (leftButton == UP));
|
||||||
assert((state.leftButton && lastState.leftButton) == (leftButton == HELD));
|
assert((state.leftButton && lastState.leftButton) == (leftButton == HELD));
|
||||||
assert((!state.leftButton && lastState.leftButton) == (leftButton == RELEASED));
|
assert((!state.leftButton && lastState.leftButton) == (leftButton == RELEASED));
|
||||||
assert((state.leftButton && !lastState.leftButton) == (leftButton == PRESSED));
|
assert((state.leftButton && !lastState.leftButton) == (leftButton == PRESSED));
|
||||||
|
|
||||||
UPDATE_BUTTON_STATE(middleButton)
|
UPDATE_BUTTON_STATE(middleButton);
|
||||||
UPDATE_BUTTON_STATE(rightButton)
|
UPDATE_BUTTON_STATE(rightButton);
|
||||||
UPDATE_BUTTON_STATE(xButton1)
|
UPDATE_BUTTON_STATE(xButton1);
|
||||||
UPDATE_BUTTON_STATE(xButton2)
|
UPDATE_BUTTON_STATE(xButton2);
|
||||||
|
|
||||||
lastState = state;
|
lastState = state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,129 +109,130 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTx.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTx.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVc.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVc.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxNoSpec.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxNoSpec.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcNoSpec.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcNoSpec.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxBn.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxBn.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcBn.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcBn.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxNoSpecBn.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxNoSpecBn.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBn.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxInst.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxInst.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcInst.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcInst.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxNoSpecInst.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxNoSpecInst.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcNoSpecInst.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcNoSpecInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxBnInst.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxBnInst.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcBnInst.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcBnInst.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxNoSpecBnInst.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxNoSpecBnInst.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBnInst.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBnInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSSkinnedPixelLightingTx.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSSkinnedPixelLightingTx.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSSkinnedPixelLightingTxBn.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSSkinnedPixelLightingTxBn.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSSkinnedPixelLightingTxNoSpec.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSSkinnedPixelLightingTxNoSpec.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_VSSkinnedPixelLightingTxNoSpecBn.inc"
|
#include "XboxGamingScarlettNormalMapEffect_VSSkinnedPixelLightingTxNoSpecBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettNormalMapEffect_PSNormalPixelLightingTx.inc"
|
#include "XboxGamingScarlettNormalMapEffect_PSNormalPixelLightingTx.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_PSNormalPixelLightingTxNoFog.inc"
|
#include "XboxGamingScarlettNormalMapEffect_PSNormalPixelLightingTxNoFog.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_PSNormalPixelLightingTxNoSpec.inc"
|
#include "XboxGamingScarlettNormalMapEffect_PSNormalPixelLightingTxNoSpec.inc"
|
||||||
#include "XboxGamingScarlettNormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc"
|
#include "XboxGamingScarlettNormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTx.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTx.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVc.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVc.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpec.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpec.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpec.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpec.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxBn.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxBn.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcBn.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcBn.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecBn.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecBn.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBn.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxInst.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxInst.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcInst.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcInst.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecInst.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecInst.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecInst.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxBnInst.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxBnInst.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcBnInst.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcBnInst.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecBnInst.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecBnInst.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBnInst.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBnInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSSkinnedPixelLightingTx.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSSkinnedPixelLightingTx.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSSkinnedPixelLightingTxBn.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSSkinnedPixelLightingTxBn.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSSkinnedPixelLightingTxNoSpec.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSSkinnedPixelLightingTxNoSpec.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_VSSkinnedPixelLightingTxNoSpecBn.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_VSSkinnedPixelLightingTxNoSpecBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_PSNormalPixelLightingTx.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_PSNormalPixelLightingTx.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_PSNormalPixelLightingTxNoFog.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_PSNormalPixelLightingTxNoFog.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_PSNormalPixelLightingTxNoSpec.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_PSNormalPixelLightingTxNoSpec.inc"
|
||||||
#include "XboxGamingXboxOneNormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc"
|
#include "XboxGamingXboxOneNormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTx.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTx.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVc.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVc.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpec.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpec.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpec.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpec.inc"
|
||||||
|
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxBn.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxBn.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcBn.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcBn.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecBn.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecBn.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBn.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBn.inc"
|
||||||
|
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxInst.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxInst.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcInst.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcInst.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecInst.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecInst.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecInst.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecInst.inc"
|
||||||
|
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxBnInst.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxBnInst.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcBnInst.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcBnInst.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecBnInst.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxNoSpecBnInst.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBnInst.inc"
|
#include "XboxOneNormalMapEffect_VSNormalPixelLightingTxVcNoSpecBnInst.inc"
|
||||||
|
|
||||||
#include "XboxOneNormalMapEffect_VSSkinnedPixelLightingTx.inc"
|
#include "XboxOneNormalMapEffect_VSSkinnedPixelLightingTx.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSSkinnedPixelLightingTxBn.inc"
|
#include "XboxOneNormalMapEffect_VSSkinnedPixelLightingTxBn.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSSkinnedPixelLightingTxNoSpec.inc"
|
#include "XboxOneNormalMapEffect_VSSkinnedPixelLightingTxNoSpec.inc"
|
||||||
#include "XboxOneNormalMapEffect_VSSkinnedPixelLightingTxNoSpecBn.inc"
|
#include "XboxOneNormalMapEffect_VSSkinnedPixelLightingTxNoSpecBn.inc"
|
||||||
|
|
||||||
#include "XboxOneNormalMapEffect_PSNormalPixelLightingTx.inc"
|
#include "XboxOneNormalMapEffect_PSNormalPixelLightingTx.inc"
|
||||||
#include "XboxOneNormalMapEffect_PSNormalPixelLightingTxNoFog.inc"
|
#include "XboxOneNormalMapEffect_PSNormalPixelLightingTxNoFog.inc"
|
||||||
#include "XboxOneNormalMapEffect_PSNormalPixelLightingTxNoSpec.inc"
|
#include "XboxOneNormalMapEffect_PSNormalPixelLightingTxNoSpec.inc"
|
||||||
#include "XboxOneNormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc"
|
#include "XboxOneNormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc"
|
||||||
#else
|
#else
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTx.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTx.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxVc.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxVc.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxNoSpec.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxNoSpec.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxVcNoSpec.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxVcNoSpec.inc"
|
||||||
|
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxBn.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxBn.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxVcBn.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxVcBn.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxNoSpecBn.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxNoSpecBn.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxVcNoSpecBn.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxVcNoSpecBn.inc"
|
||||||
|
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxInst.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxInst.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxVcInst.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxVcInst.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxNoSpecInst.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxNoSpecInst.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxVcNoSpecInst.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxVcNoSpecInst.inc"
|
||||||
|
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxBnInst.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxBnInst.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxVcBnInst.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxVcBnInst.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxNoSpecBnInst.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxNoSpecBnInst.inc"
|
||||||
#include "NormalMapEffect_VSNormalPixelLightingTxVcNoSpecBnInst.inc"
|
#include "NormalMapEffect_VSNormalPixelLightingTxVcNoSpecBnInst.inc"
|
||||||
|
|
||||||
#include "NormalMapEffect_VSSkinnedPixelLightingTx.inc"
|
#include "NormalMapEffect_VSSkinnedPixelLightingTx.inc"
|
||||||
#include "NormalMapEffect_VSSkinnedPixelLightingTxBn.inc"
|
#include "NormalMapEffect_VSSkinnedPixelLightingTxBn.inc"
|
||||||
#include "NormalMapEffect_VSSkinnedPixelLightingTxNoSpec.inc"
|
#include "NormalMapEffect_VSSkinnedPixelLightingTxNoSpec.inc"
|
||||||
#include "NormalMapEffect_VSSkinnedPixelLightingTxNoSpecBn.inc"
|
#include "NormalMapEffect_VSSkinnedPixelLightingTxNoSpecBn.inc"
|
||||||
|
|
||||||
#include "NormalMapEffect_PSNormalPixelLightingTx.inc"
|
#include "NormalMapEffect_PSNormalPixelLightingTx.inc"
|
||||||
#include "NormalMapEffect_PSNormalPixelLightingTxNoFog.inc"
|
#include "NormalMapEffect_PSNormalPixelLightingTxNoFog.inc"
|
||||||
#include "NormalMapEffect_PSNormalPixelLightingTxNoSpec.inc"
|
#include "NormalMapEffect_PSNormalPixelLightingTxNoSpec.inc"
|
||||||
#include "NormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc"
|
#include "NormalMapEffect_PSNormalPixelLightingTxNoFogSpec.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,6 +389,7 @@ const int EffectBase<NormalMapEffectTraits>::PixelShaderIndices[] =
|
||||||
2, // skinning + pixel lighting (biased vertex normal) + texture, no specular
|
2, // skinning + pixel lighting (biased vertex normal) + texture, no specular
|
||||||
3, // skinning + pixel lighting (biased vertex normal) + texture, no fog or specular
|
3, // skinning + pixel lighting (biased vertex normal) + texture, no fog or specular
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
// Global pool of per-device NormalMapEffect resources.
|
// Global pool of per-device NormalMapEffect resources.
|
||||||
template<>
|
template<>
|
||||||
|
@ -398,13 +400,13 @@ SharedResourcePool<ID3D12Device*, EffectBase<NormalMapEffectTraits>::DeviceResou
|
||||||
NormalMapEffect::Impl::Impl(
|
NormalMapEffect::Impl::Impl(
|
||||||
_In_ ID3D12Device* device)
|
_In_ ID3D12Device* device)
|
||||||
: EffectBase(device),
|
: EffectBase(device),
|
||||||
weightsPerVertex(0),
|
weightsPerVertex(0),
|
||||||
specularMap(false),
|
specularMap(false),
|
||||||
texture{},
|
texture{},
|
||||||
normal{},
|
normal{},
|
||||||
specular{},
|
specular{},
|
||||||
sampler{},
|
sampler{},
|
||||||
boneConstants{}
|
boneConstants{}
|
||||||
{
|
{
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<NormalMapEffectTraits>::VertexShaderIndices)) == NormalMapEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<NormalMapEffectTraits>::VertexShaderIndices)) == NormalMapEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<NormalMapEffectTraits>::VertexShaderBytecode)) == NormalMapEffectTraits::VertexShaderCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<NormalMapEffectTraits>::VertexShaderBytecode)) == NormalMapEffectTraits::VertexShaderCount, "array/max mismatch");
|
||||||
|
@ -849,16 +851,16 @@ void SkinnedNormalMapEffect::SetBoneTransforms(_In_reads_(count) XMMATRIX const*
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
#if DIRECTX_MATH_VERSION >= 313
|
#if DIRECTX_MATH_VERSION >= 313
|
||||||
XMStoreFloat3x4A(reinterpret_cast<XMFLOAT3X4A*>(&boneConstant[i]), value[i]);
|
XMStoreFloat3x4A(reinterpret_cast<XMFLOAT3X4A*>(&boneConstant[i]), value[i]);
|
||||||
#else
|
#else
|
||||||
// Xbox One XDK has an older version of DirectXMath
|
// Xbox One XDK has an older version of DirectXMath
|
||||||
XMMATRIX boneMatrix = XMMatrixTranspose(value[i]);
|
XMMATRIX boneMatrix = XMMatrixTranspose(value[i]);
|
||||||
|
|
||||||
boneConstant[i][0] = boneMatrix.r[0];
|
boneConstant[i][0] = boneMatrix.r[0];
|
||||||
boneConstant[i][1] = boneMatrix.r[1];
|
boneConstant[i][1] = boneMatrix.r[1];
|
||||||
boneConstant[i][2] = boneMatrix.r[2];
|
boneConstant[i][2] = boneMatrix.r[2];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferBones;
|
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferBones;
|
||||||
|
|
|
@ -113,81 +113,82 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettPBREffect_VSConstant.inc"
|
#include "XboxGamingScarlettPBREffect_VSConstant.inc"
|
||||||
#include "XboxGamingScarlettPBREffect_VSConstantBn.inc"
|
#include "XboxGamingScarlettPBREffect_VSConstantBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettPBREffect_VSConstantInst.inc"
|
#include "XboxGamingScarlettPBREffect_VSConstantInst.inc"
|
||||||
#include "XboxGamingScarlettPBREffect_VSConstantBnInst.inc"
|
#include "XboxGamingScarlettPBREffect_VSConstantBnInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettPBREffect_VSConstantVelocity.inc"
|
#include "XboxGamingScarlettPBREffect_VSConstantVelocity.inc"
|
||||||
#include "XboxGamingScarlettPBREffect_VSConstantVelocityBn.inc"
|
#include "XboxGamingScarlettPBREffect_VSConstantVelocityBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettPBREffect_VSSkinned.inc"
|
#include "XboxGamingScarlettPBREffect_VSSkinned.inc"
|
||||||
#include "XboxGamingScarlettPBREffect_VSSkinnedBn.inc"
|
#include "XboxGamingScarlettPBREffect_VSSkinnedBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettPBREffect_PSConstant.inc"
|
#include "XboxGamingScarlettPBREffect_PSConstant.inc"
|
||||||
#include "XboxGamingScarlettPBREffect_PSTextured.inc"
|
#include "XboxGamingScarlettPBREffect_PSTextured.inc"
|
||||||
#include "XboxGamingScarlettPBREffect_PSTexturedEmissive.inc"
|
#include "XboxGamingScarlettPBREffect_PSTexturedEmissive.inc"
|
||||||
#include "XboxGamingScarlettPBREffect_PSTexturedVelocity.inc"
|
#include "XboxGamingScarlettPBREffect_PSTexturedVelocity.inc"
|
||||||
#include "XboxGamingScarlettPBREffect_PSTexturedEmissiveVelocity.inc"
|
#include "XboxGamingScarlettPBREffect_PSTexturedEmissiveVelocity.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOnePBREffect_VSConstant.inc"
|
#include "XboxGamingXboxOnePBREffect_VSConstant.inc"
|
||||||
#include "XboxGamingXboxOnePBREffect_VSConstantBn.inc"
|
#include "XboxGamingXboxOnePBREffect_VSConstantBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOnePBREffect_VSConstantInst.inc"
|
#include "XboxGamingXboxOnePBREffect_VSConstantInst.inc"
|
||||||
#include "XboxGamingXboxOnePBREffect_VSConstantBnInst.inc"
|
#include "XboxGamingXboxOnePBREffect_VSConstantBnInst.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOnePBREffect_VSConstantVelocity.inc"
|
#include "XboxGamingXboxOnePBREffect_VSConstantVelocity.inc"
|
||||||
#include "XboxGamingXboxOnePBREffect_VSConstantVelocityBn.inc"
|
#include "XboxGamingXboxOnePBREffect_VSConstantVelocityBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOnePBREffect_VSSkinned.inc"
|
#include "XboxGamingXboxOnePBREffect_VSSkinned.inc"
|
||||||
#include "XboxGamingXboxOnePBREffect_VSSkinnedBn.inc"
|
#include "XboxGamingXboxOnePBREffect_VSSkinnedBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOnePBREffect_PSConstant.inc"
|
#include "XboxGamingXboxOnePBREffect_PSConstant.inc"
|
||||||
#include "XboxGamingXboxOnePBREffect_PSTextured.inc"
|
#include "XboxGamingXboxOnePBREffect_PSTextured.inc"
|
||||||
#include "XboxGamingXboxOnePBREffect_PSTexturedEmissive.inc"
|
#include "XboxGamingXboxOnePBREffect_PSTexturedEmissive.inc"
|
||||||
#include "XboxGamingXboxOnePBREffect_PSTexturedVelocity.inc"
|
#include "XboxGamingXboxOnePBREffect_PSTexturedVelocity.inc"
|
||||||
#include "XboxGamingXboxOnePBREffect_PSTexturedEmissiveVelocity.inc"
|
#include "XboxGamingXboxOnePBREffect_PSTexturedEmissiveVelocity.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOnePBREffect_VSConstant.inc"
|
#include "XboxOnePBREffect_VSConstant.inc"
|
||||||
#include "XboxOnePBREffect_VSConstantBn.inc"
|
#include "XboxOnePBREffect_VSConstantBn.inc"
|
||||||
|
|
||||||
#include "XboxOnePBREffect_VSConstantInst.inc"
|
#include "XboxOnePBREffect_VSConstantInst.inc"
|
||||||
#include "XboxOnePBREffect_VSConstantBnInst.inc"
|
#include "XboxOnePBREffect_VSConstantBnInst.inc"
|
||||||
|
|
||||||
#include "XboxOnePBREffect_VSConstantVelocity.inc"
|
#include "XboxOnePBREffect_VSConstantVelocity.inc"
|
||||||
#include "XboxOnePBREffect_VSConstantVelocityBn.inc"
|
#include "XboxOnePBREffect_VSConstantVelocityBn.inc"
|
||||||
|
|
||||||
#include "XboxOnePBREffect_VSSkinned.inc"
|
#include "XboxOnePBREffect_VSSkinned.inc"
|
||||||
#include "XboxOnePBREffect_VSSkinnedBn.inc"
|
#include "XboxOnePBREffect_VSSkinnedBn.inc"
|
||||||
|
|
||||||
#include "XboxOnePBREffect_PSConstant.inc"
|
#include "XboxOnePBREffect_PSConstant.inc"
|
||||||
#include "XboxOnePBREffect_PSTextured.inc"
|
#include "XboxOnePBREffect_PSTextured.inc"
|
||||||
#include "XboxOnePBREffect_PSTexturedEmissive.inc"
|
#include "XboxOnePBREffect_PSTexturedEmissive.inc"
|
||||||
#include "XboxOnePBREffect_PSTexturedVelocity.inc"
|
#include "XboxOnePBREffect_PSTexturedVelocity.inc"
|
||||||
#include "XboxOnePBREffect_PSTexturedEmissiveVelocity.inc"
|
#include "XboxOnePBREffect_PSTexturedEmissiveVelocity.inc"
|
||||||
#else
|
#else
|
||||||
#include "PBREffect_VSConstant.inc"
|
#include "PBREffect_VSConstant.inc"
|
||||||
#include "PBREffect_VSConstantBn.inc"
|
#include "PBREffect_VSConstantBn.inc"
|
||||||
|
|
||||||
#include "PBREffect_VSConstantInst.inc"
|
#include "PBREffect_VSConstantInst.inc"
|
||||||
#include "PBREffect_VSConstantBnInst.inc"
|
#include "PBREffect_VSConstantBnInst.inc"
|
||||||
|
|
||||||
#include "PBREffect_VSConstantVelocity.inc"
|
#include "PBREffect_VSConstantVelocity.inc"
|
||||||
#include "PBREffect_VSConstantVelocityBn.inc"
|
#include "PBREffect_VSConstantVelocityBn.inc"
|
||||||
|
|
||||||
#include "PBREffect_VSSkinned.inc"
|
#include "PBREffect_VSSkinned.inc"
|
||||||
#include "PBREffect_VSSkinnedBn.inc"
|
#include "PBREffect_VSSkinnedBn.inc"
|
||||||
|
|
||||||
#include "PBREffect_PSConstant.inc"
|
#include "PBREffect_PSConstant.inc"
|
||||||
#include "PBREffect_PSTextured.inc"
|
#include "PBREffect_PSTextured.inc"
|
||||||
#include "PBREffect_PSTexturedEmissive.inc"
|
#include "PBREffect_PSTexturedEmissive.inc"
|
||||||
#include "PBREffect_PSTexturedVelocity.inc"
|
#include "PBREffect_PSTexturedVelocity.inc"
|
||||||
#include "PBREffect_PSTexturedEmissiveVelocity.inc"
|
#include "PBREffect_PSTexturedEmissiveVelocity.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,6 +288,7 @@ const int EffectBase<PBREffectTraits>::PixelShaderIndices[] =
|
||||||
3, // textured + velocity (biased vertex normals)
|
3, // textured + velocity (biased vertex normals)
|
||||||
4, // textured + emissive + velocity (biased vertex normals)
|
4, // textured + emissive + velocity (biased vertex normals)
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
// Global pool of per-device PBREffect resources. Required by EffectBase<>, but not used.
|
// Global pool of per-device PBREffect resources. Required by EffectBase<>, but not used.
|
||||||
template<>
|
template<>
|
||||||
|
@ -295,12 +297,12 @@ SharedResourcePool<ID3D12Device*, EffectBase<PBREffectTraits>::DeviceResources>
|
||||||
// Constructor.
|
// Constructor.
|
||||||
PBREffect::Impl::Impl(_In_ ID3D12Device* device)
|
PBREffect::Impl::Impl(_In_ ID3D12Device* device)
|
||||||
: EffectBase(device),
|
: EffectBase(device),
|
||||||
weightsPerVertex(0),
|
weightsPerVertex(0),
|
||||||
textureEnabled(false),
|
textureEnabled(false),
|
||||||
emissiveMap(false),
|
emissiveMap(false),
|
||||||
descriptors{},
|
descriptors{},
|
||||||
lightColor{},
|
lightColor{},
|
||||||
boneConstants{}
|
boneConstants{}
|
||||||
{
|
{
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<PBREffectTraits>::VertexShaderIndices)) == PBREffectTraits::ShaderPermutationCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<PBREffectTraits>::VertexShaderIndices)) == PBREffectTraits::ShaderPermutationCount, "array/max mismatch");
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<PBREffectTraits>::VertexShaderBytecode)) == PBREffectTraits::VertexShaderCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<PBREffectTraits>::VertexShaderBytecode)) == PBREffectTraits::VertexShaderCount, "array/max mismatch");
|
||||||
|
@ -821,9 +823,9 @@ void PBREffect::SetSurfaceTextures(
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE roughnessMetallicAmbientOcclusion,
|
D3D12_GPU_DESCRIPTOR_HANDLE roughnessMetallicAmbientOcclusion,
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE sampler)
|
D3D12_GPU_DESCRIPTOR_HANDLE sampler)
|
||||||
{
|
{
|
||||||
pImpl->descriptors[Impl::RootParameterIndex::AlbedoTexture] = albedo;
|
pImpl->descriptors[Impl::RootParameterIndex::AlbedoTexture] = albedo;
|
||||||
pImpl->descriptors[Impl::RootParameterIndex::NormalTexture] = normal;
|
pImpl->descriptors[Impl::RootParameterIndex::NormalTexture] = normal;
|
||||||
pImpl->descriptors[Impl::RootParameterIndex::RMATexture] = roughnessMetallicAmbientOcclusion;
|
pImpl->descriptors[Impl::RootParameterIndex::RMATexture] = roughnessMetallicAmbientOcclusion;
|
||||||
pImpl->descriptors[Impl::RootParameterIndex::SurfaceSampler] = sampler;
|
pImpl->descriptors[Impl::RootParameterIndex::SurfaceSampler] = sampler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,16 +870,16 @@ void SkinnedPBREffect::SetBoneTransforms(_In_reads_(count) XMMATRIX const* value
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
#if DIRECTX_MATH_VERSION >= 313
|
#if DIRECTX_MATH_VERSION >= 313
|
||||||
XMStoreFloat3x4A(reinterpret_cast<XMFLOAT3X4A*>(&boneConstant[i]), value[i]);
|
XMStoreFloat3x4A(reinterpret_cast<XMFLOAT3X4A*>(&boneConstant[i]), value[i]);
|
||||||
#else
|
#else
|
||||||
// Xbox One XDK has an older version of DirectXMath
|
// Xbox One XDK has an older version of DirectXMath
|
||||||
XMMATRIX boneMatrix = XMMatrixTranspose(value[i]);
|
XMMATRIX boneMatrix = XMMatrixTranspose(value[i]);
|
||||||
|
|
||||||
boneConstant[i][0] = boneMatrix.r[0];
|
boneConstant[i][0] = boneMatrix.r[0];
|
||||||
boneConstant[i][1] = boneMatrix.r[1];
|
boneConstant[i][1] = boneMatrix.r[1];
|
||||||
boneConstant[i][2] = boneMatrix.r[2];
|
boneConstant[i][2] = boneMatrix.r[2];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferBones;
|
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBufferBones;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#ifndef MAKEFOURCC
|
#ifndef MAKEFOURCC
|
||||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||||
(static_cast<uint32_t>(static_cast<uint8_t>(ch0)) \
|
(static_cast<uint32_t>(static_cast<uint8_t>(ch0)) \
|
||||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch1)) << 8) \
|
| (static_cast<uint32_t>(static_cast<uint8_t>(ch1)) << 8) \
|
||||||
| (static_cast<uint32_t>(static_cast<uint8_t>(ch2)) << 16) \
|
| (static_cast<uint32_t>(static_cast<uint8_t>(ch2)) << 16) \
|
||||||
|
@ -25,11 +25,11 @@
|
||||||
|
|
||||||
// See https://walbourn.github.io/modern-c++-bitmask-types/
|
// See https://walbourn.github.io/modern-c++-bitmask-types/
|
||||||
#ifndef ENUM_FLAGS_CONSTEXPR
|
#ifndef ENUM_FLAGS_CONSTEXPR
|
||||||
#ifdef NTDDI_WIN10_RS1
|
#ifdef NTDDI_WIN10_RS1
|
||||||
#define ENUM_FLAGS_CONSTEXPR constexpr
|
#define ENUM_FLAGS_CONSTEXPR constexpr
|
||||||
#else
|
#else
|
||||||
#define ENUM_FLAGS_CONSTEXPR const
|
#define ENUM_FLAGS_CONSTEXPR const
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace DirectX
|
namespace DirectX
|
||||||
|
|
|
@ -120,15 +120,15 @@ static bool CanBatchPrimitives(D3D_PRIMITIVE_TOPOLOGY topology) noexcept
|
||||||
{
|
{
|
||||||
switch (topology)
|
switch (topology)
|
||||||
{
|
{
|
||||||
case D3D_PRIMITIVE_TOPOLOGY_POINTLIST:
|
case D3D_PRIMITIVE_TOPOLOGY_POINTLIST:
|
||||||
case D3D_PRIMITIVE_TOPOLOGY_LINELIST:
|
case D3D_PRIMITIVE_TOPOLOGY_LINELIST:
|
||||||
case D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST:
|
case D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST:
|
||||||
// Lists can easily be merged.
|
// Lists can easily be merged.
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Strips cannot.
|
// Strips cannot.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We could also merge indexed strips by inserting degenerates,
|
// We could also merge indexed strips by inserting degenerates,
|
||||||
|
|
|
@ -21,13 +21,13 @@ using Microsoft::WRL::ComPtr;
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettGenerateMips_main.inc"
|
#include "XboxGamingScarlettGenerateMips_main.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneGenerateMips_main.inc"
|
#include "XboxGamingXboxOneGenerateMips_main.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneGenerateMips_main.inc"
|
#include "XboxOneGenerateMips_main.inc"
|
||||||
#else
|
#else
|
||||||
#include "GenerateMips_main.inc"
|
#include "GenerateMips_main.inc"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool FormatIsUAVCompatible(_In_ ID3D12Device* device, bool typedUAVLoadAdditionalFormats, DXGI_FORMAT format) noexcept
|
bool FormatIsUAVCompatible(_In_ ID3D12Device* device, bool typedUAVLoadAdditionalFormats, DXGI_FORMAT format) noexcept
|
||||||
|
@ -205,13 +205,13 @@ namespace
|
||||||
RootParameterCount
|
RootParameterCount
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push, 4)
|
#pragma pack(push, 4)
|
||||||
struct ConstantData
|
struct ConstantData
|
||||||
{
|
{
|
||||||
XMFLOAT2 InvOutTexelSize;
|
XMFLOAT2 InvOutTexelSize;
|
||||||
uint32_t SrcMipIndex;
|
uint32_t SrcMipIndex;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
static constexpr uint32_t Num32BitConstants = static_cast<uint32_t>(sizeof(ConstantData) / sizeof(uint32_t));
|
static constexpr uint32_t Num32BitConstants = static_cast<uint32_t>(sizeof(ConstantData) / sizeof(uint32_t));
|
||||||
static constexpr uint32_t ThreadGroupSize = 8;
|
static constexpr uint32_t ThreadGroupSize = 8;
|
||||||
|
@ -370,12 +370,12 @@ public:
|
||||||
|
|
||||||
// Submit resource copy to command list
|
// Submit resource copy to command list
|
||||||
UpdateSubresources(mList.Get(), resource, scratchResource.Get(), 0, subresourceIndexStart, numSubresources,
|
UpdateSubresources(mList.Get(), resource, scratchResource.Get(), 0, subresourceIndexStart, numSubresources,
|
||||||
#if defined(_XBOX_ONE) && defined(_TITLE)
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
// Workaround for header constness issue
|
// Workaround for header constness issue
|
||||||
const_cast<D3D12_SUBRESOURCE_DATA*>(subRes)
|
const_cast<D3D12_SUBRESOURCE_DATA*>(subRes)
|
||||||
#else
|
#else
|
||||||
subRes
|
subRes
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remember this upload object for delayed release
|
// Remember this upload object for delayed release
|
||||||
|
@ -459,12 +459,12 @@ public:
|
||||||
}
|
}
|
||||||
else if (FormatIsBGR(desc.Format))
|
else if (FormatIsBGR(desc.Format))
|
||||||
{
|
{
|
||||||
#if !defined(_GAMING_XBOX) && !(defined(_XBOX_ONE) && defined(_TITLE))
|
#if !defined(_GAMING_XBOX) && !(defined(_XBOX_ONE) && defined(_TITLE))
|
||||||
if (!mStandardSwizzle64KBSupported)
|
if (!mStandardSwizzle64KBSupported)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("GenerateMips needs StandardSwizzle64KBSupported device support for BGR");
|
throw std::runtime_error("GenerateMips needs StandardSwizzle64KBSupported device support for BGR");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GenerateMips_TexturePathBGR(resource);
|
GenerateMips_TexturePathBGR(resource);
|
||||||
}
|
}
|
||||||
|
@ -555,28 +555,28 @@ public:
|
||||||
// Kick off a thread that waits for the upload to complete on the GPU timeline.
|
// Kick off a thread that waits for the upload to complete on the GPU timeline.
|
||||||
// Let the thread run autonomously, but provide a future the user can wait on.
|
// Let the thread run autonomously, but provide a future the user can wait on.
|
||||||
std::future<void> future = std::async(std::launch::async, [uploadBatch]()
|
std::future<void> future = std::async(std::launch::async, [uploadBatch]()
|
||||||
{
|
|
||||||
// Wait on the GPU-complete notification
|
|
||||||
const DWORD wr = WaitForSingleObject(uploadBatch->GpuCompleteEvent.get(), INFINITE);
|
|
||||||
if (wr != WAIT_OBJECT_0)
|
|
||||||
{
|
{
|
||||||
if (wr == WAIT_FAILED)
|
// Wait on the GPU-complete notification
|
||||||
|
const DWORD wr = WaitForSingleObject(uploadBatch->GpuCompleteEvent.get(), INFINITE);
|
||||||
|
if (wr != WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
throw std::system_error(std::error_code(static_cast<int>(GetLastError()), std::system_category()), "WaitForSingleObject");
|
if (wr == WAIT_FAILED)
|
||||||
|
{
|
||||||
|
throw std::system_error(std::error_code(static_cast<int>(GetLastError()), std::system_category()), "WaitForSingleObject");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error("WaitForSingleObject");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
throw std::runtime_error("WaitForSingleObject");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the batch
|
// Delete the batch
|
||||||
// Because the vectors contain smart-pointers, their destructors will
|
// Because the vectors contain smart-pointers, their destructors will
|
||||||
// fire and the resources will be released.
|
// fire and the resources will be released.
|
||||||
delete uploadBatch;
|
delete uploadBatch;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset our state
|
// Reset our state
|
||||||
mCommandType = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
mCommandType = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||||
mInBeginEndBlock = false;
|
mInBeginEndBlock = false;
|
||||||
mList.Reset();
|
mList.Reset();
|
||||||
|
@ -599,13 +599,13 @@ public:
|
||||||
|
|
||||||
if (FormatIsBGR(format))
|
if (FormatIsBGR(format))
|
||||||
{
|
{
|
||||||
#if defined(_GAMING_XBOX) || (defined(_XBOX_ONE) && defined(_TITLE))
|
#if defined(_GAMING_XBOX) || (defined(_XBOX_ONE) && defined(_TITLE))
|
||||||
// We know the RGB and BGR memory layouts match for Xbox One
|
// We know the RGB and BGR memory layouts match for Xbox One
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
// BGR path requires DXGI_FORMAT_R8G8B8A8_UNORM support for UAV load/store plus matching layouts
|
// BGR path requires DXGI_FORMAT_R8G8B8A8_UNORM support for UAV load/store plus matching layouts
|
||||||
return mTypedUAVLoadAdditionalFormats && mStandardSwizzle64KBSupported;
|
return mTypedUAVLoadAdditionalFormats && mStandardSwizzle64KBSupported;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FormatIsSRGB(format))
|
if (FormatIsSRGB(format))
|
||||||
|
@ -891,9 +891,9 @@ private:
|
||||||
auto copyDesc = resourceDesc;
|
auto copyDesc = resourceDesc;
|
||||||
copyDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
copyDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
copyDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
copyDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
||||||
#if !defined(_GAMING_XBOX) && !(defined(_XBOX_ONE) && defined(_TITLE))
|
#if !defined(_GAMING_XBOX) && !(defined(_XBOX_ONE) && defined(_TITLE))
|
||||||
copyDesc.Layout = D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE;
|
copyDesc.Layout = D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
D3D12_HEAP_DESC heapDesc = {};
|
D3D12_HEAP_DESC heapDesc = {};
|
||||||
auto const allocInfo = mDevice->GetResourceAllocationInfo(0, 1, ©Desc);
|
auto const allocInfo = mDevice->GetResourceAllocationInfo(0, 1, ©Desc);
|
||||||
|
|
100
Src/SDKMesh.h
100
Src/SDKMesh.h
|
@ -56,9 +56,9 @@ namespace DXUT
|
||||||
enum D3DDECLUSAGE
|
enum D3DDECLUSAGE
|
||||||
{
|
{
|
||||||
D3DDECLUSAGE_POSITION = 0,
|
D3DDECLUSAGE_POSITION = 0,
|
||||||
D3DDECLUSAGE_BLENDWEIGHT =1,
|
D3DDECLUSAGE_BLENDWEIGHT = 1,
|
||||||
D3DDECLUSAGE_BLENDINDICES =2,
|
D3DDECLUSAGE_BLENDINDICES = 2,
|
||||||
D3DDECLUSAGE_NORMAL =3,
|
D3DDECLUSAGE_NORMAL = 3,
|
||||||
D3DDECLUSAGE_TEXCOORD = 5,
|
D3DDECLUSAGE_TEXCOORD = 5,
|
||||||
D3DDECLUSAGE_TANGENT = 6,
|
D3DDECLUSAGE_TANGENT = 6,
|
||||||
D3DDECLUSAGE_BINORMAL = 7,
|
D3DDECLUSAGE_BINORMAL = 7,
|
||||||
|
@ -67,29 +67,51 @@ namespace DXUT
|
||||||
|
|
||||||
enum D3DDECLTYPE
|
enum D3DDECLTYPE
|
||||||
{
|
{
|
||||||
D3DDECLTYPE_FLOAT1 = 0, // 1D float expanded to (value, 0., 0., 1.)
|
D3DDECLTYPE_FLOAT1 = 0,
|
||||||
D3DDECLTYPE_FLOAT2 = 1, // 2D float expanded to (value, value, 0., 1.)
|
// 1D float expanded to (value, 0., 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 uint8_t
|
|
||||||
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)
|
|
||||||
D3DDECLTYPE_DEC3N = 14, // 3D signed normalized (v[0]/511.0, v[1]/511.0, v[2]/511.0, 1.)
|
|
||||||
// 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.
|
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 uint8_t
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
D3DDECLTYPE_DEC3N = 14,
|
||||||
|
// 3D signed normalized (v[0]/511.0, v[1]/511.0, v[2]/511.0, 1.)
|
||||||
|
// 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.
|
||||||
|
|
||||||
// These are extensions for DXGI-based versions of Direct3D
|
// These are extensions for DXGI-based versions of Direct3D
|
||||||
D3DDECLTYPE_DXGI_R10G10B10A2_UNORM = 32 + DXGI_FORMAT_R10G10B10A2_UNORM,
|
D3DDECLTYPE_DXGI_R10G10B10A2_UNORM = 32 + DXGI_FORMAT_R10G10B10A2_UNORM,
|
||||||
D3DDECLTYPE_DXGI_R11G11B10_FLOAT = 32 + DXGI_FORMAT_R11G11B10_FLOAT,
|
D3DDECLTYPE_DXGI_R11G11B10_FLOAT = 32 + DXGI_FORMAT_R11G11B10_FLOAT,
|
||||||
D3DDECLTYPE_DXGI_R8G8B8A8_SNORM = 32 + DXGI_FORMAT_R8G8B8A8_SNORM,
|
D3DDECLTYPE_DXGI_R8G8B8A8_SNORM = 32 + DXGI_FORMAT_R8G8B8A8_SNORM,
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push,4)
|
#pragma pack(push,4)
|
||||||
|
|
||||||
struct D3DVERTEXELEMENT9
|
struct D3DVERTEXELEMENT9
|
||||||
{
|
{
|
||||||
|
@ -101,11 +123,11 @@ namespace DXUT
|
||||||
uint8_t UsageIndex; // Semantic index
|
uint8_t UsageIndex; // Semantic index
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Hard Defines for the various structures
|
// Hard Defines for the various structures
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
constexpr uint32_t SDKMESH_FILE_VERSION = 101;
|
constexpr uint32_t SDKMESH_FILE_VERSION = 101;
|
||||||
constexpr uint32_t SDKMESH_FILE_VERSION_V2 = 200;
|
constexpr uint32_t SDKMESH_FILE_VERSION_V2 = 200;
|
||||||
|
|
||||||
|
@ -118,7 +140,7 @@ namespace DXUT
|
||||||
constexpr uint32_t MAX_TEXTURE_NAME = MAX_PATH;
|
constexpr uint32_t MAX_TEXTURE_NAME = MAX_PATH;
|
||||||
constexpr uint32_t MAX_MATERIAL_PATH = MAX_PATH;
|
constexpr uint32_t MAX_MATERIAL_PATH = MAX_PATH;
|
||||||
constexpr uint32_t INVALID_FRAME = uint32_t(-1);
|
constexpr uint32_t INVALID_FRAME = uint32_t(-1);
|
||||||
constexpr uint32_t INVALID_MESH = uint32_t(-1);
|
constexpr uint32_t INVALID_MESH = uint32_t(-1);
|
||||||
constexpr uint32_t INVALID_MATERIAL = uint32_t(-1);
|
constexpr uint32_t INVALID_MATERIAL = uint32_t(-1);
|
||||||
constexpr uint32_t INVALID_SUBSET = uint32_t(-1);
|
constexpr uint32_t INVALID_SUBSET = uint32_t(-1);
|
||||||
constexpr uint32_t INVALID_ANIMATION_DATA = uint32_t(-1);
|
constexpr uint32_t INVALID_ANIMATION_DATA = uint32_t(-1);
|
||||||
|
@ -156,7 +178,7 @@ namespace DXUT
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Structures.
|
// Structures.
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
#pragma pack(push,8)
|
#pragma pack(push,8)
|
||||||
|
|
||||||
struct SDKMESH_HEADER
|
struct SDKMESH_HEADER
|
||||||
{
|
{
|
||||||
|
@ -320,19 +342,19 @@ namespace DXUT
|
||||||
uint64_t DataOffset;
|
uint64_t DataOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
static_assert( sizeof(DXUT::D3DVERTEXELEMENT9) == 8, "Direct3D9 Decl structure size incorrect" );
|
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_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_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_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_MESH) == 224, "SDK Mesh structure size incorrect");
|
||||||
static_assert( sizeof(DXUT::SDKMESH_SUBSET) == 144, "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_FRAME) == 184, "SDK Mesh structure size incorrect");
|
||||||
static_assert( sizeof(DXUT::SDKMESH_MATERIAL) == 1256, "SDK Mesh structure size incorrect" );
|
static_assert(sizeof(DXUT::SDKMESH_MATERIAL) == 1256, "SDK Mesh structure size incorrect");
|
||||||
static_assert( sizeof(DXUT::SDKMESH_MATERIAL_V2) == sizeof(DXUT::SDKMESH_MATERIAL), "SDK Mesh structure size incorrect" );
|
static_assert(sizeof(DXUT::SDKMESH_MATERIAL_V2) == sizeof(DXUT::SDKMESH_MATERIAL), "SDK Mesh structure size incorrect");
|
||||||
static_assert( sizeof(DXUT::SDKANIMATION_FILE_HEADER) == 40, "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_DATA) == 40, "SDK Mesh structure size incorrect");
|
||||||
static_assert( sizeof(DXUT::SDKANIMATION_FRAME_DATA) == 112, "SDK Mesh structure size incorrect" );
|
static_assert(sizeof(DXUT::SDKANIMATION_FRAME_DATA) == 112, "SDK Mesh structure size incorrect");
|
||||||
|
|
|
@ -298,57 +298,57 @@ HRESULT DirectX::SaveDDSTextureToFile(
|
||||||
DDS_HEADER_DXT10* extHeader = nullptr;
|
DDS_HEADER_DXT10* extHeader = nullptr;
|
||||||
switch (desc.Format)
|
switch (desc.Format)
|
||||||
{
|
{
|
||||||
case DXGI_FORMAT_R8G8B8A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_R8G8B8A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_R16G16_UNORM: memcpy(&header->ddspf, &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_R16G16_UNORM: memcpy(&header->ddspf, &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_R8G8_UNORM: memcpy(&header->ddspf, &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_R8G8_UNORM: memcpy(&header->ddspf, &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_R16_UNORM: memcpy(&header->ddspf, &DDSPF_L16, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_R16_UNORM: memcpy(&header->ddspf, &DDSPF_L16, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_R8_UNORM: memcpy(&header->ddspf, &DDSPF_L8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_R8_UNORM: memcpy(&header->ddspf, &DDSPF_L8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_R8G8_B8G8_UNORM: memcpy(&header->ddspf, &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_R8G8_B8G8_UNORM: memcpy(&header->ddspf, &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_G8R8_G8B8_UNORM: memcpy(&header->ddspf, &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_G8R8_G8B8_UNORM: memcpy(&header->ddspf, &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_BC1_UNORM: memcpy(&header->ddspf, &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_BC1_UNORM: memcpy(&header->ddspf, &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_BC2_UNORM: memcpy(&header->ddspf, &DDSPF_DXT3, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_BC2_UNORM: memcpy(&header->ddspf, &DDSPF_DXT3, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_BC3_UNORM: memcpy(&header->ddspf, &DDSPF_DXT5, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_BC3_UNORM: memcpy(&header->ddspf, &DDSPF_DXT5, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_BC4_UNORM: memcpy(&header->ddspf, &DDSPF_BC4_UNORM, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_BC4_UNORM: memcpy(&header->ddspf, &DDSPF_BC4_UNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_BC4_SNORM: memcpy(&header->ddspf, &DDSPF_BC4_SNORM, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_BC4_SNORM: memcpy(&header->ddspf, &DDSPF_BC4_SNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_BC5_UNORM: memcpy(&header->ddspf, &DDSPF_BC5_UNORM, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_BC5_UNORM: memcpy(&header->ddspf, &DDSPF_BC5_UNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_BC5_SNORM: memcpy(&header->ddspf, &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_BC5_SNORM: memcpy(&header->ddspf, &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_B5G6R5_UNORM: memcpy(&header->ddspf, &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_B5G6R5_UNORM: memcpy(&header->ddspf, &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy(&header->ddspf, &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy(&header->ddspf, &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_R8G8_SNORM: memcpy(&header->ddspf, &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_R8G8_SNORM: memcpy(&header->ddspf, &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy(&header->ddspf, &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy(&header->ddspf, &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_R16G16_SNORM: memcpy(&header->ddspf, &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_R16G16_SNORM: memcpy(&header->ddspf, &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy(&header->ddspf, &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy(&header->ddspf, &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_YUY2: memcpy(&header->ddspf, &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_YUY2: memcpy(&header->ddspf, &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy(&header->ddspf, &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT)); break;
|
case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy(&header->ddspf, &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT)); break;
|
||||||
|
|
||||||
// Legacy D3DX formats using D3DFMT enum value as FourCC
|
// 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_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_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_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_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_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_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_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_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_AI44:
|
||||||
case DXGI_FORMAT_IA44:
|
case DXGI_FORMAT_IA44:
|
||||||
case DXGI_FORMAT_P8:
|
case DXGI_FORMAT_P8:
|
||||||
case DXGI_FORMAT_A8P8:
|
case DXGI_FORMAT_A8P8:
|
||||||
DebugTrace("ERROR: ScreenGrab does not support video textures. Consider using DirectXTex.\n");
|
DebugTrace("ERROR: ScreenGrab does not support video textures. Consider using DirectXTex.\n");
|
||||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
memcpy(&header->ddspf, &DDSPF_DX10, sizeof(DDS_PIXELFORMAT));
|
memcpy(&header->ddspf, &DDSPF_DX10, sizeof(DDS_PIXELFORMAT));
|
||||||
|
|
||||||
headerSize += sizeof(DDS_HEADER_DXT10);
|
headerSize += sizeof(DDS_HEADER_DXT10);
|
||||||
extHeader = reinterpret_cast<DDS_HEADER_DXT10*>(fileHeader + sizeof(uint32_t) + sizeof(DDS_HEADER));
|
extHeader = reinterpret_cast<DDS_HEADER_DXT10*>(fileHeader + sizeof(uint32_t) + sizeof(DDS_HEADER));
|
||||||
extHeader->dxgiFormat = desc.Format;
|
extHeader->dxgiFormat = desc.Format;
|
||||||
extHeader->resourceDimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
extHeader->resourceDimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||||
extHeader->arraySize = 1;
|
extHeader->arraySize = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t rowPitch, slicePitch, rowCount;
|
size_t rowPitch, slicePitch, rowCount;
|
||||||
|
@ -497,49 +497,49 @@ HRESULT DirectX::SaveWICTextureToFile(
|
||||||
bool sRGB = forceSRGB;
|
bool sRGB = forceSRGB;
|
||||||
switch (desc.Format)
|
switch (desc.Format)
|
||||||
{
|
{
|
||||||
case DXGI_FORMAT_R32G32B32A32_FLOAT: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break;
|
case DXGI_FORMAT_R32G32B32A32_FLOAT: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break;
|
||||||
case DXGI_FORMAT_R16G16B16A16_FLOAT: pfGuid = GUID_WICPixelFormat64bppRGBAHalf; break;
|
case DXGI_FORMAT_R16G16B16A16_FLOAT: pfGuid = GUID_WICPixelFormat64bppRGBAHalf; break;
|
||||||
case DXGI_FORMAT_R16G16B16A16_UNORM: pfGuid = GUID_WICPixelFormat64bppRGBA; break;
|
case DXGI_FORMAT_R16G16B16A16_UNORM: pfGuid = GUID_WICPixelFormat64bppRGBA; break;
|
||||||
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102XR; break;
|
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102XR; break;
|
||||||
case DXGI_FORMAT_R10G10B10A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102; break;
|
case DXGI_FORMAT_R10G10B10A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102; break;
|
||||||
case DXGI_FORMAT_B5G5R5A1_UNORM: pfGuid = GUID_WICPixelFormat16bppBGRA5551; break;
|
case DXGI_FORMAT_B5G5R5A1_UNORM: pfGuid = GUID_WICPixelFormat16bppBGRA5551; break;
|
||||||
case DXGI_FORMAT_B5G6R5_UNORM: pfGuid = GUID_WICPixelFormat16bppBGR565; break;
|
case DXGI_FORMAT_B5G6R5_UNORM: pfGuid = GUID_WICPixelFormat16bppBGR565; break;
|
||||||
case DXGI_FORMAT_R32_FLOAT: pfGuid = GUID_WICPixelFormat32bppGrayFloat; break;
|
case DXGI_FORMAT_R32_FLOAT: pfGuid = GUID_WICPixelFormat32bppGrayFloat; break;
|
||||||
case DXGI_FORMAT_R16_FLOAT: pfGuid = GUID_WICPixelFormat16bppGrayHalf; break;
|
case DXGI_FORMAT_R16_FLOAT: pfGuid = GUID_WICPixelFormat16bppGrayHalf; break;
|
||||||
case DXGI_FORMAT_R16_UNORM: pfGuid = GUID_WICPixelFormat16bppGray; break;
|
case DXGI_FORMAT_R16_UNORM: pfGuid = GUID_WICPixelFormat16bppGray; break;
|
||||||
case DXGI_FORMAT_R8_UNORM: pfGuid = GUID_WICPixelFormat8bppGray; break;
|
case DXGI_FORMAT_R8_UNORM: pfGuid = GUID_WICPixelFormat8bppGray; break;
|
||||||
case DXGI_FORMAT_A8_UNORM: pfGuid = GUID_WICPixelFormat8bppAlpha; break;
|
case DXGI_FORMAT_A8_UNORM: pfGuid = GUID_WICPixelFormat8bppAlpha; break;
|
||||||
|
|
||||||
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
||||||
pfGuid = GUID_WICPixelFormat32bppRGBA;
|
pfGuid = GUID_WICPixelFormat32bppRGBA;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
|
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
|
||||||
pfGuid = GUID_WICPixelFormat32bppRGBA;
|
pfGuid = GUID_WICPixelFormat32bppRGBA;
|
||||||
sRGB = true;
|
sRGB = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
||||||
pfGuid = GUID_WICPixelFormat32bppBGRA;
|
pfGuid = GUID_WICPixelFormat32bppBGRA;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
|
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
|
||||||
pfGuid = GUID_WICPixelFormat32bppBGRA;
|
pfGuid = GUID_WICPixelFormat32bppBGRA;
|
||||||
sRGB = true;
|
sRGB = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DXGI_FORMAT_B8G8R8X8_UNORM:
|
case DXGI_FORMAT_B8G8R8X8_UNORM:
|
||||||
pfGuid = GUID_WICPixelFormat32bppBGR;
|
pfGuid = GUID_WICPixelFormat32bppBGR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
|
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
|
||||||
pfGuid = GUID_WICPixelFormat32bppBGR;
|
pfGuid = GUID_WICPixelFormat32bppBGR;
|
||||||
sRGB = true;
|
sRGB = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DebugTrace("ERROR: ScreenGrab does not support all DXGI formats (%u). Consider using DirectXTex.\n", static_cast<uint32_t>(desc.Format));
|
DebugTrace("ERROR: ScreenGrab does not support all DXGI formats (%u). Consider using DirectXTex.\n", static_cast<uint32_t>(desc.Format));
|
||||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pWIC = GetWIC();
|
auto pWIC = GetWIC();
|
||||||
|
@ -612,26 +612,26 @@ HRESULT DirectX::SaveWICTextureToFile(
|
||||||
// Screenshots don't typically include the alpha channel of the render target
|
// Screenshots don't typically include the alpha channel of the render target
|
||||||
switch (desc.Format)
|
switch (desc.Format)
|
||||||
{
|
{
|
||||||
case DXGI_FORMAT_R32G32B32A32_FLOAT:
|
case DXGI_FORMAT_R32G32B32A32_FLOAT:
|
||||||
case DXGI_FORMAT_R16G16B16A16_FLOAT:
|
case DXGI_FORMAT_R16G16B16A16_FLOAT:
|
||||||
targetGuid = GUID_WICPixelFormat96bppRGBFloat; // WIC 2
|
targetGuid = GUID_WICPixelFormat96bppRGBFloat; // WIC 2
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DXGI_FORMAT_R16G16B16A16_UNORM: targetGuid = GUID_WICPixelFormat48bppBGR; break;
|
case DXGI_FORMAT_R16G16B16A16_UNORM: targetGuid = GUID_WICPixelFormat48bppBGR; break;
|
||||||
case DXGI_FORMAT_B5G5R5A1_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR555; break;
|
case DXGI_FORMAT_B5G5R5A1_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR555; break;
|
||||||
case DXGI_FORMAT_B5G6R5_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR565; break;
|
case DXGI_FORMAT_B5G6R5_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR565; break;
|
||||||
|
|
||||||
case DXGI_FORMAT_R32_FLOAT:
|
case DXGI_FORMAT_R32_FLOAT:
|
||||||
case DXGI_FORMAT_R16_FLOAT:
|
case DXGI_FORMAT_R16_FLOAT:
|
||||||
case DXGI_FORMAT_R16_UNORM:
|
case DXGI_FORMAT_R16_UNORM:
|
||||||
case DXGI_FORMAT_R8_UNORM:
|
case DXGI_FORMAT_R8_UNORM:
|
||||||
case DXGI_FORMAT_A8_UNORM:
|
case DXGI_FORMAT_A8_UNORM:
|
||||||
targetGuid = GUID_WICPixelFormat8bppGray;
|
targetGuid = GUID_WICPixelFormat8bppGray;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
targetGuid = GUID_WICPixelFormat24bppBGR;
|
targetGuid = GUID_WICPixelFormat24bppBGR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,12 @@ struct CommonVSOutput
|
||||||
CommonVSOutput ComputeCommonVSOutput(float4 position)
|
CommonVSOutput ComputeCommonVSOutput(float4 position)
|
||||||
{
|
{
|
||||||
CommonVSOutput vout;
|
CommonVSOutput vout;
|
||||||
|
|
||||||
vout.Pos_ps = mul(position, WorldViewProj);
|
vout.Pos_ps = mul(position, WorldViewProj);
|
||||||
vout.Diffuse = DiffuseColor;
|
vout.Diffuse = DiffuseColor;
|
||||||
vout.Specular = 0;
|
vout.Specular = 0;
|
||||||
vout.FogFactor = ComputeFogFactor(position);
|
vout.FogFactor = ComputeFogFactor(position);
|
||||||
|
|
||||||
return vout;
|
return vout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ float4 PSDualTexture(PSInputTx2 pin) : SV_Target0
|
||||||
float4 color = Texture.Sample(Sampler, pin.TexCoord);
|
float4 color = Texture.Sample(Sampler, pin.TexCoord);
|
||||||
float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2);
|
float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2);
|
||||||
|
|
||||||
color.rgb *= 2;
|
color.rgb *= 2;
|
||||||
color *= overlay * pin.Diffuse;
|
color *= overlay * pin.Diffuse;
|
||||||
|
|
||||||
ApplyFog(color, pin.Specular.w);
|
ApplyFog(color, pin.Specular.w);
|
||||||
|
@ -114,7 +114,7 @@ float4 PSDualTextureNoFog(PSInputTx2NoFog pin) : SV_Target0
|
||||||
float4 color = Texture.Sample(Sampler, pin.TexCoord);
|
float4 color = Texture.Sample(Sampler, pin.TexCoord);
|
||||||
float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2);
|
float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2);
|
||||||
|
|
||||||
color.rgb *= 2;
|
color.rgb *= 2;
|
||||||
color *= overlay * pin.Diffuse;
|
color *= overlay * pin.Diffuse;
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
|
|
|
@ -19,28 +19,28 @@ ColorPair ComputeLights(float3 eyeVector, float3 worldNormal, uniform int numLig
|
||||||
float3x3 lightDiffuse = 0;
|
float3x3 lightDiffuse = 0;
|
||||||
float3x3 lightSpecular = 0;
|
float3x3 lightSpecular = 0;
|
||||||
float3x3 halfVectors = 0;
|
float3x3 halfVectors = 0;
|
||||||
|
|
||||||
[unroll]
|
[unroll]
|
||||||
for (int i = 0; i < numLights; i++)
|
for (int i = 0; i < numLights; i++)
|
||||||
{
|
{
|
||||||
lightDirections[i] = LightDirection[i];
|
lightDirections[i] = LightDirection[i];
|
||||||
lightDiffuse[i] = LightDiffuseColor[i];
|
lightDiffuse[i] = LightDiffuseColor[i];
|
||||||
lightSpecular[i] = LightSpecularColor[i];
|
lightSpecular[i] = LightSpecularColor[i];
|
||||||
|
|
||||||
halfVectors[i] = normalize(eyeVector - lightDirections[i]);
|
halfVectors[i] = normalize(eyeVector - lightDirections[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 dotL = mul(-lightDirections, worldNormal);
|
float3 dotL = mul(-lightDirections, worldNormal);
|
||||||
float3 dotH = mul(halfVectors, worldNormal);
|
float3 dotH = mul(halfVectors, worldNormal);
|
||||||
|
|
||||||
float3 zeroL = step(0, dotL);
|
float3 zeroL = step(0, dotL);
|
||||||
|
|
||||||
float3 diffuse = zeroL * dotL;
|
float3 diffuse = zeroL * dotL;
|
||||||
float3 specular = pow(max(dotH, 0) * zeroL, SpecularPower) * dotL;
|
float3 specular = pow(max(dotH, 0) * zeroL, SpecularPower) * dotL;
|
||||||
|
|
||||||
ColorPair result;
|
ColorPair result;
|
||||||
|
|
||||||
result.Diffuse = mul(diffuse, lightDiffuse) * DiffuseColor.rgb + EmissiveColor;
|
result.Diffuse = mul(diffuse, lightDiffuse) * DiffuseColor.rgb + EmissiveColor;
|
||||||
result.Specular = mul(specular, lightSpecular) * SpecularColor;
|
result.Specular = mul(specular, lightSpecular) * SpecularColor;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -50,18 +50,18 @@ ColorPair ComputeLights(float3 eyeVector, float3 worldNormal, uniform int numLig
|
||||||
CommonVSOutput ComputeCommonVSOutputWithLighting(float4 position, float3 normal, uniform int numLights)
|
CommonVSOutput ComputeCommonVSOutputWithLighting(float4 position, float3 normal, uniform int numLights)
|
||||||
{
|
{
|
||||||
CommonVSOutput vout;
|
CommonVSOutput vout;
|
||||||
|
|
||||||
float4 pos_ws = mul(position, World);
|
float4 pos_ws = mul(position, World);
|
||||||
float3 eyeVector = normalize(EyePosition - pos_ws.xyz);
|
float3 eyeVector = normalize(EyePosition - pos_ws.xyz);
|
||||||
float3 worldNormal = normalize(mul(normal, WorldInverseTranspose));
|
float3 worldNormal = normalize(mul(normal, WorldInverseTranspose));
|
||||||
|
|
||||||
ColorPair lightResult = ComputeLights(eyeVector, worldNormal, numLights);
|
ColorPair lightResult = ComputeLights(eyeVector, worldNormal, numLights);
|
||||||
|
|
||||||
vout.Pos_ps = mul(position, WorldViewProj);
|
vout.Pos_ps = mul(position, WorldViewProj);
|
||||||
vout.Diffuse = float4(lightResult.Diffuse, DiffuseColor.a);
|
vout.Diffuse = float4(lightResult.Diffuse, DiffuseColor.a);
|
||||||
vout.Specular = lightResult.Specular;
|
vout.Specular = lightResult.Specular;
|
||||||
vout.FogFactor = ComputeFogFactor(position);
|
vout.FogFactor = ComputeFogFactor(position);
|
||||||
|
|
||||||
return vout;
|
return vout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,12 +78,12 @@ struct CommonVSOutputPixelLighting
|
||||||
CommonVSOutputPixelLighting ComputeCommonVSOutputPixelLighting(float4 position, float3 normal)
|
CommonVSOutputPixelLighting ComputeCommonVSOutputPixelLighting(float4 position, float3 normal)
|
||||||
{
|
{
|
||||||
CommonVSOutputPixelLighting vout;
|
CommonVSOutputPixelLighting vout;
|
||||||
|
|
||||||
vout.Pos_ps = mul(position, WorldViewProj);
|
vout.Pos_ps = mul(position, WorldViewProj);
|
||||||
vout.Pos_ws = mul(position, World).xyz;
|
vout.Pos_ws = mul(position, World).xyz;
|
||||||
vout.Normal_ws = normalize(mul(normal, WorldInverseTranspose));
|
vout.Normal_ws = normalize(mul(normal, WorldInverseTranspose));
|
||||||
vout.FogFactor = ComputeFogFactor(position);
|
vout.FogFactor = ComputeFogFactor(position);
|
||||||
|
|
||||||
return vout;
|
return vout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,14 +126,14 @@ float3 LightSurface(
|
||||||
const float NdotV = saturate(dot(N, V));
|
const float NdotV = saturate(dot(N, V));
|
||||||
|
|
||||||
// Burley roughness bias
|
// Burley roughness bias
|
||||||
const float alpha = roughness * roughness;
|
const float alpha = roughness * roughness;
|
||||||
|
|
||||||
// Blend base colors
|
// Blend base colors
|
||||||
const float3 c_diff = lerp(albedo, float3(0, 0, 0), metallic) * ambientOcclusion;
|
const float3 c_diff = lerp(albedo, float3(0, 0, 0), metallic) * ambientOcclusion;
|
||||||
const float3 c_spec = lerp(kSpecularCoefficient, albedo, metallic) * ambientOcclusion;
|
const float3 c_spec = lerp(kSpecularCoefficient, albedo, metallic) * ambientOcclusion;
|
||||||
|
|
||||||
// Output color
|
// Output color
|
||||||
float3 acc_color = 0;
|
float3 acc_color = 0;
|
||||||
|
|
||||||
// Accumulate light values
|
// Accumulate light values
|
||||||
for (int i = 0; i < numLights; i++)
|
for (int i = 0; i < numLights; i++)
|
||||||
|
@ -151,7 +151,7 @@ float3 LightSurface(
|
||||||
|
|
||||||
// Diffuse & specular factors
|
// Diffuse & specular factors
|
||||||
float diffuse_factor = Diffuse_Burley(NdotL, NdotV, LdotH, roughness);
|
float diffuse_factor = Diffuse_Burley(NdotL, NdotV, LdotH, roughness);
|
||||||
float3 specular = Specular_BRDF(alpha, c_spec, NdotV, NdotL, LdotH, NdotH);
|
float3 specular = Specular_BRDF(alpha, c_spec, NdotV, NdotL, LdotH, NdotH);
|
||||||
|
|
||||||
// Directional light
|
// Directional light
|
||||||
acc_color += NdotL * lightColor[i] * (((c_diff * diffuse_factor) + specular));
|
acc_color += NdotL * lightColor[i] * (((c_diff * diffuse_factor) + specular));
|
||||||
|
|
|
@ -26,7 +26,7 @@ cbuffer Constants : register(b0)
|
||||||
|
|
||||||
float3 LightDirection[3] : packoffset(c16);
|
float3 LightDirection[3] : packoffset(c16);
|
||||||
float3 LightColor[3] : packoffset(c19); // "Specular and diffuse light" in PBR
|
float3 LightColor[3] : packoffset(c19); // "Specular and diffuse light" in PBR
|
||||||
|
|
||||||
float3 ConstantAlbedo : packoffset(c22); // Constant values if not a textured effect
|
float3 ConstantAlbedo : packoffset(c22); // Constant values if not a textured effect
|
||||||
float Alpha : packoffset(c22.w);
|
float Alpha : packoffset(c22.w);
|
||||||
float ConstantMetallic : packoffset(c23.x);
|
float ConstantMetallic : packoffset(c23.x);
|
||||||
|
@ -35,8 +35,8 @@ cbuffer Constants : register(b0)
|
||||||
int NumRadianceMipLevels : packoffset(c23.z);
|
int NumRadianceMipLevels : packoffset(c23.z);
|
||||||
|
|
||||||
// Size of render target
|
// Size of render target
|
||||||
float TargetWidth : packoffset(c23.w);
|
float TargetWidth : packoffset(c23.w);
|
||||||
float TargetHeight : packoffset(c24.x);
|
float TargetHeight : packoffset(c24.x);
|
||||||
};
|
};
|
||||||
|
|
||||||
cbuffer SkinningParameters : register(b1)
|
cbuffer SkinningParameters : register(b1)
|
||||||
|
@ -59,7 +59,7 @@ VSOutputPixelLightingTx VSConstant(VSInputNmTx vin)
|
||||||
VSOutputPixelLightingTx vout;
|
VSOutputPixelLightingTx vout;
|
||||||
|
|
||||||
CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal);
|
CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal);
|
||||||
|
|
||||||
vout.PositionPS = cout.Pos_ps;
|
vout.PositionPS = cout.Pos_ps;
|
||||||
vout.PositionWS = float4(cout.Pos_ws, 1);
|
vout.PositionWS = float4(cout.Pos_ws, 1);
|
||||||
vout.NormalWS = cout.Normal_ws;
|
vout.NormalWS = cout.Normal_ws;
|
||||||
|
@ -97,7 +97,7 @@ VSOut_Velocity VSConstantVelocity(VSInputNmTx vin)
|
||||||
VSOut_Velocity vout;
|
VSOut_Velocity vout;
|
||||||
|
|
||||||
CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal);
|
CommonVSOutputPixelLighting cout = ComputeCommonVSOutputPixelLighting(vin.Position, vin.Normal);
|
||||||
|
|
||||||
vout.current.PositionPS = cout.Pos_ps;
|
vout.current.PositionPS = cout.Pos_ps;
|
||||||
vout.current.PositionWS = float4(cout.Pos_ws, 1);
|
vout.current.PositionWS = float4(cout.Pos_ws, 1);
|
||||||
vout.current.NormalWS = cout.Normal_ws;
|
vout.current.NormalWS = cout.Normal_ws;
|
||||||
|
|
|
@ -22,39 +22,39 @@
|
||||||
#define packed_velocity_t uint
|
#define packed_velocity_t uint
|
||||||
|
|
||||||
// Designed to compress (-256.0, +256.0) with a signed 6e3 float
|
// Designed to compress (-256.0, +256.0) with a signed 6e3 float
|
||||||
uint PackXY( float x )
|
uint PackXY(float x)
|
||||||
{
|
{
|
||||||
uint signbit = asuint(x) >> 31;
|
uint signbit = asuint(x) >> 31;
|
||||||
x = clamp(abs(x / 32768.0), 0, asfloat(0x3BFFE000));
|
x = clamp(abs(x / 32768.0), 0, asfloat(0x3BFFE000));
|
||||||
return (f32tof16(x) + 8) >> 4 | signbit << 9;
|
return (f32tof16(x) + 8) >> 4 | signbit << 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
float UnpackXY( uint x )
|
float UnpackXY(uint x)
|
||||||
{
|
{
|
||||||
return f16tof32((x & 0x1FF) << 4 | (x >> 9) << 15) * 32768.0;
|
return f16tof32((x & 0x1FF) << 4 | (x >> 9) << 15) * 32768.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Designed to compress (-1.0, 1.0) with a signed 8e3 float
|
// Designed to compress (-1.0, 1.0) with a signed 8e3 float
|
||||||
uint PackZ( float x )
|
uint PackZ(float x)
|
||||||
{
|
{
|
||||||
uint signbit = asuint(x) >> 31;
|
uint signbit = asuint(x) >> 31;
|
||||||
x = clamp(abs(x / 128.0), 0, asfloat(0x3BFFE000));
|
x = clamp(abs(x / 128.0), 0, asfloat(0x3BFFE000));
|
||||||
return (f32tof16(x) + 2) >> 2 | signbit << 11;
|
return (f32tof16(x) + 2) >> 2 | signbit << 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
float UnpackZ( uint x )
|
float UnpackZ(uint x)
|
||||||
{
|
{
|
||||||
return f16tof32((x & 0x7FF) << 2 | (x >> 11) << 15) * 128.0;
|
return f16tof32((x & 0x7FF) << 2 | (x >> 11) << 15) * 128.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pack the velocity to write to R10G10B10A2_UNORM
|
// Pack the velocity to write to R10G10B10A2_UNORM
|
||||||
packed_velocity_t PackVelocity( float3 Velocity )
|
packed_velocity_t PackVelocity(float3 Velocity)
|
||||||
{
|
{
|
||||||
return PackXY(Velocity.x) | PackXY(Velocity.y) << 10 | PackZ(Velocity.z) << 20;
|
return PackXY(Velocity.x) | PackXY(Velocity.y) << 10 | PackZ(Velocity.z) << 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack the velocity from R10G10B10A2_UNORM
|
// Unpack the velocity from R10G10B10A2_UNORM
|
||||||
float3 UnpackVelocity( packed_velocity_t Velocity )
|
float3 UnpackVelocity(packed_velocity_t Velocity)
|
||||||
{
|
{
|
||||||
return float3(UnpackXY(Velocity & 0x3FF), UnpackXY((Velocity >> 10) & 0x3FF), UnpackZ(Velocity >> 20));
|
return float3(UnpackXY(Velocity & 0x3FF), UnpackXY((Velocity >> 10) & 0x3FF), UnpackZ(Velocity >> 20));
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ float3 UnpackVelocity( packed_velocity_t Velocity )
|
||||||
#define packed_velocity_t float4
|
#define packed_velocity_t float4
|
||||||
|
|
||||||
// Pack the velocity to write to R10G10B10A2_UNORM
|
// Pack the velocity to write to R10G10B10A2_UNORM
|
||||||
packed_velocity_t PackVelocity( float3 Velocity )
|
packed_velocity_t PackVelocity(float3 Velocity)
|
||||||
{
|
{
|
||||||
// Stretch dx,dy from [-64, 63.875] to [-512, 511] to [-0.5, 0.5) to [0, 1)
|
// Stretch dx,dy from [-64, 63.875] to [-512, 511] to [-0.5, 0.5) to [0, 1)
|
||||||
// Velocity.xy = (0,0) must be representable.
|
// Velocity.xy = (0,0) must be representable.
|
||||||
|
@ -71,7 +71,7 @@ packed_velocity_t PackVelocity( float3 Velocity )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack the velocity from R10G10B10A2_UNORM
|
// Unpack the velocity from R10G10B10A2_UNORM
|
||||||
float3 UnpackVelocity( packed_velocity_t Velocity )
|
float3 UnpackVelocity(packed_velocity_t Velocity)
|
||||||
{
|
{
|
||||||
return (Velocity.xyz - 512.0 / 1023.0) * float3(1024, 1024, 2) / 8.0;
|
return (Velocity.xyz - 512.0 / 1023.0) * float3(1024, 1024, 2) / 8.0;
|
||||||
}
|
}
|
||||||
|
@ -79,13 +79,13 @@ float3 UnpackVelocity( packed_velocity_t Velocity )
|
||||||
#define packed_velocity_t float4
|
#define packed_velocity_t float4
|
||||||
|
|
||||||
// Pack the velocity to write to R16G16B16A16_FLOAT
|
// Pack the velocity to write to R16G16B16A16_FLOAT
|
||||||
packed_velocity_t PackVelocity( float3 Velocity )
|
packed_velocity_t PackVelocity(float3 Velocity)
|
||||||
{
|
{
|
||||||
return float4(Velocity * float3(16, 16, 32*1024), 0);
|
return float4(Velocity * float3(16, 16, 32*1024), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack the velocity from R10G10B10A2_UNORM
|
// Unpack the velocity from R10G10B10A2_UNORM
|
||||||
float3 UnpackVelocity( packed_velocity_t Velocity )
|
float3 UnpackVelocity(packed_velocity_t Velocity)
|
||||||
{
|
{
|
||||||
return Velocity.xyz / float3(16, 16, 32*1024);
|
return Velocity.xyz / float3(16, 16, 32*1024);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,11 +94,11 @@ float4 PSDownScale2x2(VSInputTx pin) : SV_Target0
|
||||||
const int NUM_SAMPLES = 4;
|
const int NUM_SAMPLES = 4;
|
||||||
float4 vColor = 0.0f;
|
float4 vColor = 0.0f;
|
||||||
|
|
||||||
for( int i=0; i < NUM_SAMPLES; i++ )
|
for (int i = 0; i < NUM_SAMPLES; i++)
|
||||||
{
|
{
|
||||||
vColor += Texture.Sample(Sampler, pin.TexCoord + sampleOffsets[i].xy);
|
vColor += Texture.Sample(Sampler, pin.TexCoord + sampleOffsets[i].xy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vColor / NUM_SAMPLES;
|
return vColor / NUM_SAMPLES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,15 +17,15 @@ cbuffer Parameters : register(b0)
|
||||||
|
|
||||||
[RootSignature(SpriteStaticRS)]
|
[RootSignature(SpriteStaticRS)]
|
||||||
void SpriteVertexShader(inout float4 color : COLOR0,
|
void SpriteVertexShader(inout float4 color : COLOR0,
|
||||||
inout float2 texCoord : TEXCOORD0,
|
inout float2 texCoord : TEXCOORD0,
|
||||||
inout float4 position : SV_Position)
|
inout float4 position : SV_Position)
|
||||||
{
|
{
|
||||||
position = mul(position, MatrixTransform);
|
position = mul(position, MatrixTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RootSignature(SpriteStaticRS)]
|
[RootSignature(SpriteStaticRS)]
|
||||||
float4 SpritePixelShader(float4 color : COLOR0,
|
float4 SpritePixelShader(float4 color : COLOR0,
|
||||||
float2 texCoord : TEXCOORD0) : SV_Target0
|
float2 texCoord : TEXCOORD0) : SV_Target0
|
||||||
{
|
{
|
||||||
return Texture.Sample(TextureSampler, texCoord) * color;
|
return Texture.Sample(TextureSampler, texCoord) * color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
|
|
||||||
float3 BiasX2(float3 x)
|
float3 BiasX2(float3 x)
|
||||||
{
|
{
|
||||||
return 2.0f * x - 1.0f;
|
return 2.0f * x - 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 BiasD2(float3 x)
|
float3 BiasD2(float3 x)
|
||||||
{
|
{
|
||||||
return 0.5f * x + 0.5f;
|
return 0.5f * x + 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ namespace DirectX
|
||||||
public:
|
public:
|
||||||
SharedResourcePool() noexcept(false)
|
SharedResourcePool() noexcept(false)
|
||||||
: mResourceMap(std::make_shared<ResourceMap>())
|
: mResourceMap(std::make_shared<ResourceMap>())
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SharedResourcePool(SharedResourcePool const&) = delete;
|
SharedResourcePool(SharedResourcePool const&) = delete;
|
||||||
SharedResourcePool& operator= (SharedResourcePool const&) = delete;
|
SharedResourcePool& operator= (SharedResourcePool const&) = delete;
|
||||||
|
@ -79,7 +80,8 @@ namespace DirectX
|
||||||
: TData(key, args...),
|
: TData(key, args...),
|
||||||
mKey(key),
|
mKey(key),
|
||||||
mResourceMap(resourceMap)
|
mResourceMap(resourceMap)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
WrappedData(WrappedData&&) = default;
|
WrappedData(WrappedData&&) = default;
|
||||||
WrappedData& operator= (WrappedData&&) = default;
|
WrappedData& operator= (WrappedData&&) = default;
|
||||||
|
|
|
@ -177,17 +177,17 @@ RECT Viewport::ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UI
|
||||||
|
|
||||||
switch (int(scaling))
|
switch (int(scaling))
|
||||||
{
|
{
|
||||||
case DXGI_SCALING_STRETCH:
|
case DXGI_SCALING_STRETCH:
|
||||||
// Output fills the entire window area
|
// Output fills the entire window area
|
||||||
rct.top = 0;
|
rct.top = 0;
|
||||||
rct.left = 0;
|
rct.left = 0;
|
||||||
rct.right = outputWidth;
|
rct.right = outputWidth;
|
||||||
rct.bottom = outputHeight;
|
rct.bottom = outputHeight;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2 /*DXGI_SCALING_ASPECT_RATIO_STRETCH*/:
|
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
|
// 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
|
// Note: This scaling option is not supported for legacy Win32 windows swap chains
|
||||||
{
|
{
|
||||||
assert(backBufferHeight > 0);
|
assert(backBufferHeight > 0);
|
||||||
const float aspectRatio = float(backBufferWidth) / float(backBufferHeight);
|
const float aspectRatio = float(backBufferWidth) / float(backBufferHeight);
|
||||||
|
@ -218,14 +218,14 @@ RECT Viewport::ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UI
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DXGI_SCALING_NONE:
|
case DXGI_SCALING_NONE:
|
||||||
default:
|
default:
|
||||||
// Output is displayed in the upper left corner of the window area
|
// Output is displayed in the upper left corner of the window area
|
||||||
rct.top = 0;
|
rct.top = 0;
|
||||||
rct.left = 0;
|
rct.left = 0;
|
||||||
rct.right = std::min<LONG>(static_cast<LONG>(backBufferWidth), outputWidth);
|
rct.right = std::min<LONG>(static_cast<LONG>(backBufferWidth), outputWidth);
|
||||||
rct.bottom = std::min<LONG>(static_cast<LONG>(backBufferHeight), outputHeight);
|
rct.bottom = std::min<LONG>(static_cast<LONG>(backBufferHeight), outputHeight);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rct;
|
return rct;
|
||||||
|
|
|
@ -77,45 +77,46 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettSkinnedEffect_VSSkinnedVertexLightingFourBones.inc"
|
#include "XboxGamingScarlettSkinnedEffect_VSSkinnedVertexLightingFourBones.inc"
|
||||||
#include "XboxGamingScarlettSkinnedEffect_VSSkinnedPixelLightingFourBones.inc"
|
#include "XboxGamingScarlettSkinnedEffect_VSSkinnedPixelLightingFourBones.inc"
|
||||||
#include "XboxGamingScarlettSkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc"
|
#include "XboxGamingScarlettSkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc"
|
||||||
#include "XboxGamingScarlettSkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc"
|
#include "XboxGamingScarlettSkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettSkinnedEffect_PSSkinnedVertexLighting.inc"
|
#include "XboxGamingScarlettSkinnedEffect_PSSkinnedVertexLighting.inc"
|
||||||
#include "XboxGamingScarlettSkinnedEffect_PSSkinnedVertexLightingNoFog.inc"
|
#include "XboxGamingScarlettSkinnedEffect_PSSkinnedVertexLightingNoFog.inc"
|
||||||
#include "XboxGamingScarlettSkinnedEffect_PSSkinnedPixelLighting.inc"
|
#include "XboxGamingScarlettSkinnedEffect_PSSkinnedPixelLighting.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneSkinnedEffect_VSSkinnedVertexLightingFourBones.inc"
|
#include "XboxGamingXboxOneSkinnedEffect_VSSkinnedVertexLightingFourBones.inc"
|
||||||
#include "XboxGamingXboxOneSkinnedEffect_VSSkinnedPixelLightingFourBones.inc"
|
#include "XboxGamingXboxOneSkinnedEffect_VSSkinnedPixelLightingFourBones.inc"
|
||||||
#include "XboxGamingXboxOneSkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc"
|
#include "XboxGamingXboxOneSkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc"
|
||||||
#include "XboxGamingXboxOneSkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc"
|
#include "XboxGamingXboxOneSkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneSkinnedEffect_PSSkinnedVertexLighting.inc"
|
#include "XboxGamingXboxOneSkinnedEffect_PSSkinnedVertexLighting.inc"
|
||||||
#include "XboxGamingXboxOneSkinnedEffect_PSSkinnedVertexLightingNoFog.inc"
|
#include "XboxGamingXboxOneSkinnedEffect_PSSkinnedVertexLightingNoFog.inc"
|
||||||
#include "XboxGamingXboxOneSkinnedEffect_PSSkinnedPixelLighting.inc"
|
#include "XboxGamingXboxOneSkinnedEffect_PSSkinnedPixelLighting.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneSkinnedEffect_VSSkinnedVertexLightingFourBones.inc"
|
#include "XboxOneSkinnedEffect_VSSkinnedVertexLightingFourBones.inc"
|
||||||
#include "XboxOneSkinnedEffect_VSSkinnedPixelLightingFourBones.inc"
|
#include "XboxOneSkinnedEffect_VSSkinnedPixelLightingFourBones.inc"
|
||||||
#include "XboxOneSkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc"
|
#include "XboxOneSkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc"
|
||||||
#include "XboxOneSkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc"
|
#include "XboxOneSkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc"
|
||||||
|
|
||||||
#include "XboxOneSkinnedEffect_PSSkinnedVertexLighting.inc"
|
#include "XboxOneSkinnedEffect_PSSkinnedVertexLighting.inc"
|
||||||
#include "XboxOneSkinnedEffect_PSSkinnedVertexLightingNoFog.inc"
|
#include "XboxOneSkinnedEffect_PSSkinnedVertexLightingNoFog.inc"
|
||||||
#include "XboxOneSkinnedEffect_PSSkinnedPixelLighting.inc"
|
#include "XboxOneSkinnedEffect_PSSkinnedPixelLighting.inc"
|
||||||
#else
|
#else
|
||||||
#include "SkinnedEffect_VSSkinnedVertexLightingFourBones.inc"
|
#include "SkinnedEffect_VSSkinnedVertexLightingFourBones.inc"
|
||||||
#include "SkinnedEffect_VSSkinnedPixelLightingFourBones.inc"
|
#include "SkinnedEffect_VSSkinnedPixelLightingFourBones.inc"
|
||||||
#include "SkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc"
|
#include "SkinnedEffect_VSSkinnedVertexLightingFourBonesBn.inc"
|
||||||
#include "SkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc"
|
#include "SkinnedEffect_VSSkinnedPixelLightingFourBonesBn.inc"
|
||||||
|
|
||||||
#include "SkinnedEffect_PSSkinnedVertexLighting.inc"
|
#include "SkinnedEffect_PSSkinnedVertexLighting.inc"
|
||||||
#include "SkinnedEffect_PSSkinnedVertexLightingNoFog.inc"
|
#include "SkinnedEffect_PSSkinnedVertexLightingNoFog.inc"
|
||||||
#include "SkinnedEffect_PSSkinnedPixelLighting.inc"
|
#include "SkinnedEffect_PSSkinnedPixelLighting.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ const int EffectBase<SkinnedEffectTraits>::PixelShaderIndices[] =
|
||||||
2, // pixel lighting (biased vertex normals), four bones
|
2, // pixel lighting (biased vertex normals), four bones
|
||||||
2, // pixel lighting (biased vertex normals), four bones, no fog
|
2, // pixel lighting (biased vertex normals), four bones, no fog
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
// Global pool of per-device SkinnedEffect resources.
|
// Global pool of per-device SkinnedEffect resources.
|
||||||
template<>
|
template<>
|
||||||
|
@ -184,8 +185,8 @@ SkinnedEffect::Impl::Impl(
|
||||||
uint32_t effectFlags,
|
uint32_t effectFlags,
|
||||||
const EffectPipelineStateDescription& pipelineDescription)
|
const EffectPipelineStateDescription& pipelineDescription)
|
||||||
: EffectBase(device),
|
: EffectBase(device),
|
||||||
texture{},
|
texture{},
|
||||||
sampler{}
|
sampler{}
|
||||||
{
|
{
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<SkinnedEffectTraits>::VertexShaderIndices)) == SkinnedEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<SkinnedEffectTraits>::VertexShaderIndices)) == SkinnedEffectTraits::ShaderPermutationCount, "array/max mismatch");
|
||||||
static_assert(static_cast<int>(std::size(EffectBase<SkinnedEffectTraits>::VertexShaderBytecode)) == SkinnedEffectTraits::VertexShaderCount, "array/max mismatch");
|
static_assert(static_cast<int>(std::size(EffectBase<SkinnedEffectTraits>::VertexShaderBytecode)) == SkinnedEffectTraits::VertexShaderCount, "array/max mismatch");
|
||||||
|
@ -525,16 +526,16 @@ void SkinnedEffect::SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, s
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
#if DIRECTX_MATH_VERSION >= 313
|
#if DIRECTX_MATH_VERSION >= 313
|
||||||
XMStoreFloat3x4A(reinterpret_cast<XMFLOAT3X4A*>(&boneConstant[i]), value[i]);
|
XMStoreFloat3x4A(reinterpret_cast<XMFLOAT3X4A*>(&boneConstant[i]), value[i]);
|
||||||
#else
|
#else
|
||||||
// Xbox One XDK has an older version of DirectXMath
|
// Xbox One XDK has an older version of DirectXMath
|
||||||
XMMATRIX boneMatrix = XMMatrixTranspose(value[i]);
|
XMMATRIX boneMatrix = XMMatrixTranspose(value[i]);
|
||||||
|
|
||||||
boneConstant[i][0] = boneMatrix.r[0];
|
boneConstant[i][0] = boneMatrix.r[0];
|
||||||
boneConstant[i][1] = boneMatrix.r[1];
|
boneConstant[i][1] = boneMatrix.r[1];
|
||||||
boneConstant[i][2] = boneMatrix.r[2];
|
boneConstant[i][2] = boneMatrix.r[2];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer;
|
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer;
|
||||||
|
@ -545,7 +546,7 @@ void SkinnedEffect::ResetBoneTransforms()
|
||||||
{
|
{
|
||||||
auto boneConstant = pImpl->constants.bones;
|
auto boneConstant = pImpl->constants.bones;
|
||||||
|
|
||||||
for(size_t i = 0; i < MaxBones; ++i)
|
for (size_t i = 0; i < MaxBones; ++i)
|
||||||
{
|
{
|
||||||
boneConstant[i][0] = g_XMIdentityR0;
|
boneConstant[i][0] = g_XMIdentityR0;
|
||||||
boneConstant[i][1] = g_XMIdentityR1;
|
boneConstant[i][1] = g_XMIdentityR1;
|
||||||
|
|
|
@ -26,25 +26,25 @@ namespace
|
||||||
{
|
{
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettSpriteEffect_SpriteVertexShader.inc"
|
#include "XboxGamingScarlettSpriteEffect_SpriteVertexShader.inc"
|
||||||
#include "XboxGamingScarlettSpriteEffect_SpritePixelShader.inc"
|
#include "XboxGamingScarlettSpriteEffect_SpritePixelShader.inc"
|
||||||
#include "XboxGamingScarlettSpriteEffect_SpriteVertexShaderHeap.inc"
|
#include "XboxGamingScarlettSpriteEffect_SpriteVertexShaderHeap.inc"
|
||||||
#include "XboxGamingScarlettSpriteEffect_SpritePixelShaderHeap.inc"
|
#include "XboxGamingScarlettSpriteEffect_SpritePixelShaderHeap.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneSpriteEffect_SpriteVertexShader.inc"
|
#include "XboxGamingXboxOneSpriteEffect_SpriteVertexShader.inc"
|
||||||
#include "XboxGamingXboxOneSpriteEffect_SpritePixelShader.inc"
|
#include "XboxGamingXboxOneSpriteEffect_SpritePixelShader.inc"
|
||||||
#include "XboxGamingXboxOneSpriteEffect_SpriteVertexShaderHeap.inc"
|
#include "XboxGamingXboxOneSpriteEffect_SpriteVertexShaderHeap.inc"
|
||||||
#include "XboxGamingXboxOneSpriteEffect_SpritePixelShaderHeap.inc"
|
#include "XboxGamingXboxOneSpriteEffect_SpritePixelShaderHeap.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneSpriteEffect_SpriteVertexShader.inc"
|
#include "XboxOneSpriteEffect_SpriteVertexShader.inc"
|
||||||
#include "XboxOneSpriteEffect_SpritePixelShader.inc"
|
#include "XboxOneSpriteEffect_SpritePixelShader.inc"
|
||||||
#include "XboxOneSpriteEffect_SpriteVertexShaderHeap.inc"
|
#include "XboxOneSpriteEffect_SpriteVertexShaderHeap.inc"
|
||||||
#include "XboxOneSpriteEffect_SpritePixelShaderHeap.inc"
|
#include "XboxOneSpriteEffect_SpritePixelShaderHeap.inc"
|
||||||
#else
|
#else
|
||||||
#include "SpriteEffect_SpriteVertexShader.inc"
|
#include "SpriteEffect_SpriteVertexShader.inc"
|
||||||
#include "SpriteEffect_SpritePixelShader.inc"
|
#include "SpriteEffect_SpritePixelShader.inc"
|
||||||
#include "SpriteEffect_SpriteVertexShaderHeap.inc"
|
#include "SpriteEffect_SpriteVertexShaderHeap.inc"
|
||||||
#include "SpriteEffect_SpritePixelShaderHeap.inc"
|
#include "SpriteEffect_SpritePixelShaderHeap.inc"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline bool operator != (D3D12_GPU_DESCRIPTOR_HANDLE a, D3D12_GPU_DESCRIPTOR_HANDLE b) noexcept
|
inline bool operator != (D3D12_GPU_DESCRIPTOR_HANDLE a, D3D12_GPU_DESCRIPTOR_HANDLE b) noexcept
|
||||||
|
@ -225,8 +225,8 @@ SharedResourcePool<ID3D12Device*, SpriteBatch::Impl::DeviceResources, ResourceUp
|
||||||
const XMMATRIX SpriteBatch::MatrixIdentity = XMMatrixIdentity();
|
const XMMATRIX SpriteBatch::MatrixIdentity = XMMatrixIdentity();
|
||||||
const XMFLOAT2 SpriteBatch::Float2Zero(0, 0);
|
const XMFLOAT2 SpriteBatch::Float2Zero(0, 0);
|
||||||
|
|
||||||
const D3D12_SHADER_BYTECODE SpriteBatch::Impl::s_DefaultVertexShaderByteCodeStatic = {SpriteEffect_SpriteVertexShader, sizeof(SpriteEffect_SpriteVertexShader)};
|
const D3D12_SHADER_BYTECODE SpriteBatch::Impl::s_DefaultVertexShaderByteCodeStatic = { SpriteEffect_SpriteVertexShader, sizeof(SpriteEffect_SpriteVertexShader) };
|
||||||
const D3D12_SHADER_BYTECODE SpriteBatch::Impl::s_DefaultPixelShaderByteCodeStatic = {SpriteEffect_SpritePixelShader, sizeof(SpriteEffect_SpritePixelShader)};
|
const D3D12_SHADER_BYTECODE SpriteBatch::Impl::s_DefaultPixelShaderByteCodeStatic = { SpriteEffect_SpritePixelShader, sizeof(SpriteEffect_SpritePixelShader) };
|
||||||
|
|
||||||
const D3D12_SHADER_BYTECODE SpriteBatch::Impl::s_DefaultVertexShaderByteCodeHeap = { SpriteEffect_SpriteVertexShaderHeap, sizeof(SpriteEffect_SpriteVertexShaderHeap) };
|
const D3D12_SHADER_BYTECODE SpriteBatch::Impl::s_DefaultVertexShaderByteCodeHeap = { SpriteEffect_SpriteVertexShaderHeap, sizeof(SpriteEffect_SpriteVertexShaderHeap) };
|
||||||
const D3D12_SHADER_BYTECODE SpriteBatch::Impl::s_DefaultPixelShaderByteCodeHeap = { SpriteEffect_SpritePixelShaderHeap, sizeof(SpriteEffect_SpritePixelShaderHeap) };
|
const D3D12_SHADER_BYTECODE SpriteBatch::Impl::s_DefaultPixelShaderByteCodeHeap = { SpriteEffect_SpritePixelShaderHeap, sizeof(SpriteEffect_SpritePixelShaderHeap) };
|
||||||
|
@ -991,39 +991,39 @@ XMMATRIX SpriteBatch::Impl::GetViewportTransform(_In_ DXGI_MODE_ROTATION rotatio
|
||||||
{
|
{
|
||||||
case DXGI_MODE_ROTATION_ROTATE90:
|
case DXGI_MODE_ROTATION_ROTATE90:
|
||||||
return XMMATRIX
|
return XMMATRIX
|
||||||
(
|
(
|
||||||
0, -yScale, 0, 0,
|
0, -yScale, 0, 0,
|
||||||
-xScale, 0, 0, 0,
|
-xScale, 0, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
1, 1, 0, 1
|
1, 1, 0, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
case DXGI_MODE_ROTATION_ROTATE270:
|
case DXGI_MODE_ROTATION_ROTATE270:
|
||||||
return XMMATRIX
|
return XMMATRIX
|
||||||
(
|
(
|
||||||
0, yScale, 0, 0,
|
0, yScale, 0, 0,
|
||||||
xScale, 0, 0, 0,
|
xScale, 0, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
-1, -1, 0, 1
|
-1, -1, 0, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
case DXGI_MODE_ROTATION_ROTATE180:
|
case DXGI_MODE_ROTATION_ROTATE180:
|
||||||
return XMMATRIX
|
return XMMATRIX
|
||||||
(
|
(
|
||||||
-xScale, 0, 0, 0,
|
-xScale, 0, 0, 0,
|
||||||
0, yScale, 0, 0,
|
0, yScale, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
1, -1, 0, 1
|
1, -1, 0, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return XMMATRIX
|
return XMMATRIX
|
||||||
(
|
(
|
||||||
xScale, 0, 0, 0,
|
xScale, 0, 0, 0,
|
||||||
0, -yScale, 0, 0,
|
0, -yScale, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
-1, 1, 0, 1
|
-1, 1, 0, 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,11 +105,11 @@ SpriteFont::Impl::Impl(
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE cpuDesc,
|
D3D12_CPU_DESCRIPTOR_HANDLE cpuDesc,
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE gpuDesc,
|
D3D12_GPU_DESCRIPTOR_HANDLE gpuDesc,
|
||||||
bool forceSRGB) noexcept(false) :
|
bool forceSRGB) noexcept(false) :
|
||||||
texture{},
|
texture{},
|
||||||
textureSize{},
|
textureSize{},
|
||||||
defaultGlyph(nullptr),
|
defaultGlyph(nullptr),
|
||||||
lineSpacing(0),
|
lineSpacing(0),
|
||||||
utfBufferSize(0)
|
utfBufferSize(0)
|
||||||
{
|
{
|
||||||
// Validate the header.
|
// Validate the header.
|
||||||
for (char const* magic = spriteFontMagic; *magic; magic++)
|
for (char const* magic = spriteFontMagic; *magic; magic++)
|
||||||
|
@ -187,12 +187,12 @@ SpriteFont::Impl::Impl(
|
||||||
Glyph const* iglyphs,
|
Glyph const* iglyphs,
|
||||||
size_t glyphCount,
|
size_t glyphCount,
|
||||||
float ilineSpacing) noexcept(false) :
|
float ilineSpacing) noexcept(false) :
|
||||||
texture(itexture),
|
texture(itexture),
|
||||||
textureSize(itextureSize),
|
textureSize(itextureSize),
|
||||||
glyphs(iglyphs, iglyphs + glyphCount),
|
glyphs(iglyphs, iglyphs + glyphCount),
|
||||||
defaultGlyph(nullptr),
|
defaultGlyph(nullptr),
|
||||||
lineSpacing(ilineSpacing),
|
lineSpacing(ilineSpacing),
|
||||||
utfBufferSize(0)
|
utfBufferSize(0)
|
||||||
{
|
{
|
||||||
if (!std::is_sorted(iglyphs, iglyphs + glyphCount))
|
if (!std::is_sorted(iglyphs, iglyphs + glyphCount))
|
||||||
{
|
{
|
||||||
|
@ -281,37 +281,37 @@ void SpriteFont::Impl::ForEachGlyph(_In_z_ wchar_t const* text, TAction action,
|
||||||
|
|
||||||
switch (character)
|
switch (character)
|
||||||
{
|
{
|
||||||
case '\r':
|
case '\r':
|
||||||
// Skip carriage returns.
|
// Skip carriage returns.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
// New line.
|
// New line.
|
||||||
|
x = 0;
|
||||||
|
y += lineSpacing;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Output this character.
|
||||||
|
auto glyph = FindGlyph(character);
|
||||||
|
|
||||||
|
x += glyph->XOffset;
|
||||||
|
|
||||||
|
if (x < 0)
|
||||||
x = 0;
|
x = 0;
|
||||||
y += lineSpacing;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
const float advance = float(glyph->Subrect.right) - float(glyph->Subrect.left) + glyph->XAdvance;
|
||||||
// Output this character.
|
|
||||||
auto glyph = FindGlyph(character);
|
|
||||||
|
|
||||||
x += glyph->XOffset;
|
if (!ignoreWhitespace
|
||||||
|
|| !iswspace(character)
|
||||||
|
|| ((glyph->Subrect.right - glyph->Subrect.left) > 1)
|
||||||
|
|| ((glyph->Subrect.bottom - glyph->Subrect.top) > 1))
|
||||||
|
{
|
||||||
|
action(glyph, x, y, advance);
|
||||||
|
}
|
||||||
|
|
||||||
if (x < 0)
|
x += advance;
|
||||||
x = 0;
|
break;
|
||||||
|
|
||||||
const float advance = float(glyph->Subrect.right) - float(glyph->Subrect.left) + glyph->XAdvance;
|
|
||||||
|
|
||||||
if (!ignoreWhitespace
|
|
||||||
|| !iswspace(character)
|
|
||||||
|| ((glyph->Subrect.right - glyph->Subrect.left) > 1)
|
|
||||||
|| ((glyph->Subrect.bottom - glyph->Subrect.top) > 1))
|
|
||||||
{
|
|
||||||
action(glyph, x, y, advance);
|
|
||||||
}
|
|
||||||
|
|
||||||
x += advance;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,9 +453,9 @@ void XM_CALLCONV SpriteFont::DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wc
|
||||||
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
|
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 &&
|
static_assert(SpriteEffects_FlipHorizontally == 1 &&
|
||||||
SpriteEffects_FlipVertically == 2, "If you change these enum values, the following tables must be updated to match");
|
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.
|
// Lookup table indicates which way to move along each axis per SpriteEffects enum value.
|
||||||
static XMVECTORF32 axisDirectionTable[4] =
|
static XMVECTORF32 axisDirectionTable[4] =
|
||||||
{
|
{
|
||||||
{ { { -1, -1, 0, 0 } } },
|
{ { { -1, -1, 0, 0 } } },
|
||||||
|
@ -486,24 +486,24 @@ void XM_CALLCONV SpriteFont::DrawString(_In_ SpriteBatch* spriteBatch, _In_z_ wc
|
||||||
|
|
||||||
// Draw each character in turn.
|
// Draw each character in turn.
|
||||||
pImpl->ForEachGlyph(text, [&](Glyph const* glyph, float x, float y, float advance)
|
pImpl->ForEachGlyph(text, [&](Glyph const* glyph, float x, float y, float advance)
|
||||||
{
|
|
||||||
UNREFERENCED_PARAMETER(advance);
|
|
||||||
|
|
||||||
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.
|
UNREFERENCED_PARAMETER(advance);
|
||||||
XMVECTOR glyphRect = XMConvertVectorIntToFloat(XMLoadInt4(reinterpret_cast<uint32_t const*>(&glyph->Subrect)), 0);
|
|
||||||
|
|
||||||
// xy = glyph width/height.
|
XMVECTOR offset = XMVectorMultiplyAdd(XMVectorSet(x, y + glyph->YOffset, 0, 0), axisDirectionTable[effects & 3], baseOffset);
|
||||||
glyphRect = XMVectorSubtract(XMVectorSwizzle<2, 3, 0, 1>(glyphRect), glyphRect);
|
|
||||||
|
|
||||||
offset = XMVectorMultiplyAdd(glyphRect, axisIsMirroredTable[effects & 3], offset);
|
if (effects)
|
||||||
}
|
{
|
||||||
|
// For mirrored characters, specify bottom and/or right instead of top left.
|
||||||
|
XMVECTOR glyphRect = XMConvertVectorIntToFloat(XMLoadInt4(reinterpret_cast<uint32_t const*>(&glyph->Subrect)), 0);
|
||||||
|
|
||||||
spriteBatch->Draw(pImpl->texture, pImpl->textureSize, position, &glyph->Subrect, color, rotation, offset, scale, effects, layerDepth);
|
// xy = glyph width/height.
|
||||||
}, true);
|
glyphRect = XMVectorSubtract(XMVectorSwizzle<2, 3, 0, 1>(glyphRect), glyphRect);
|
||||||
|
|
||||||
|
offset = XMVectorMultiplyAdd(glyphRect, axisIsMirroredTable[effects & 3], offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
spriteBatch->Draw(pImpl->texture, pImpl->textureSize, position, &glyph->Subrect, color, rotation, offset, scale, effects, layerDepth);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ using Microsoft::WRL::ComPtr;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
constexpr int Dirty_ConstantBuffer = 0x01;
|
constexpr int Dirty_ConstantBuffer = 0x01;
|
||||||
constexpr int Dirty_Parameters = 0x02;
|
constexpr int Dirty_Parameters = 0x02;
|
||||||
|
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
constexpr int PixelShaderCount = 15;
|
constexpr int PixelShaderCount = 15;
|
||||||
|
@ -72,82 +72,83 @@ namespace
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma region Shaders
|
||||||
// Include the precompiled shader code.
|
// Include the precompiled shader code.
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#ifdef _GAMING_XBOX_SCARLETT
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
#include "XboxGamingScarlettToneMap_VSQuad.inc"
|
#include "XboxGamingScarlettToneMap_VSQuad.inc"
|
||||||
|
|
||||||
#include "XboxGamingScarlettToneMap_PSCopy.inc"
|
#include "XboxGamingScarlettToneMap_PSCopy.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSSaturate.inc"
|
#include "XboxGamingScarlettToneMap_PSSaturate.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSReinhard.inc"
|
#include "XboxGamingScarlettToneMap_PSReinhard.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSACESFilmic.inc"
|
#include "XboxGamingScarlettToneMap_PSACESFilmic.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PS_SRGB.inc"
|
#include "XboxGamingScarlettToneMap_PS_SRGB.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSSaturate_SRGB.inc"
|
#include "XboxGamingScarlettToneMap_PSSaturate_SRGB.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSReinhard_SRGB.inc"
|
#include "XboxGamingScarlettToneMap_PSReinhard_SRGB.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSACESFilmic_SRGB.inc"
|
#include "XboxGamingScarlettToneMap_PSACESFilmic_SRGB.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSHDR10.inc"
|
#include "XboxGamingScarlettToneMap_PSHDR10.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSHDR10_Saturate.inc"
|
#include "XboxGamingScarlettToneMap_PSHDR10_Saturate.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSHDR10_Reinhard.inc"
|
#include "XboxGamingScarlettToneMap_PSHDR10_Reinhard.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSHDR10_ACESFilmic.inc"
|
#include "XboxGamingScarlettToneMap_PSHDR10_ACESFilmic.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSHDR10_Saturate_SRGB.inc"
|
#include "XboxGamingScarlettToneMap_PSHDR10_Saturate_SRGB.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSHDR10_Reinhard_SRGB.inc"
|
#include "XboxGamingScarlettToneMap_PSHDR10_Reinhard_SRGB.inc"
|
||||||
#include "XboxGamingScarlettToneMap_PSHDR10_ACESFilmic_SRGB.inc"
|
#include "XboxGamingScarlettToneMap_PSHDR10_ACESFilmic_SRGB.inc"
|
||||||
#elif defined(_GAMING_XBOX)
|
#elif defined(_GAMING_XBOX)
|
||||||
#include "XboxGamingXboxOneToneMap_VSQuad.inc"
|
#include "XboxGamingXboxOneToneMap_VSQuad.inc"
|
||||||
|
|
||||||
#include "XboxGamingXboxOneToneMap_PSCopy.inc"
|
#include "XboxGamingXboxOneToneMap_PSCopy.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSSaturate.inc"
|
#include "XboxGamingXboxOneToneMap_PSSaturate.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSReinhard.inc"
|
#include "XboxGamingXboxOneToneMap_PSReinhard.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSACESFilmic.inc"
|
#include "XboxGamingXboxOneToneMap_PSACESFilmic.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PS_SRGB.inc"
|
#include "XboxGamingXboxOneToneMap_PS_SRGB.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSSaturate_SRGB.inc"
|
#include "XboxGamingXboxOneToneMap_PSSaturate_SRGB.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSReinhard_SRGB.inc"
|
#include "XboxGamingXboxOneToneMap_PSReinhard_SRGB.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSACESFilmic_SRGB.inc"
|
#include "XboxGamingXboxOneToneMap_PSACESFilmic_SRGB.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSHDR10.inc"
|
#include "XboxGamingXboxOneToneMap_PSHDR10.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSHDR10_Saturate.inc"
|
#include "XboxGamingXboxOneToneMap_PSHDR10_Saturate.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSHDR10_Reinhard.inc"
|
#include "XboxGamingXboxOneToneMap_PSHDR10_Reinhard.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSHDR10_ACESFilmic.inc"
|
#include "XboxGamingXboxOneToneMap_PSHDR10_ACESFilmic.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSHDR10_Saturate_SRGB.inc"
|
#include "XboxGamingXboxOneToneMap_PSHDR10_Saturate_SRGB.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSHDR10_Reinhard_SRGB.inc"
|
#include "XboxGamingXboxOneToneMap_PSHDR10_Reinhard_SRGB.inc"
|
||||||
#include "XboxGamingXboxOneToneMap_PSHDR10_ACESFilmic_SRGB.inc"
|
#include "XboxGamingXboxOneToneMap_PSHDR10_ACESFilmic_SRGB.inc"
|
||||||
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "XboxOneToneMap_VSQuad.inc"
|
#include "XboxOneToneMap_VSQuad.inc"
|
||||||
|
|
||||||
#include "XboxOneToneMap_PSCopy.inc"
|
#include "XboxOneToneMap_PSCopy.inc"
|
||||||
#include "XboxOneToneMap_PSSaturate.inc"
|
#include "XboxOneToneMap_PSSaturate.inc"
|
||||||
#include "XboxOneToneMap_PSReinhard.inc"
|
#include "XboxOneToneMap_PSReinhard.inc"
|
||||||
#include "XboxOneToneMap_PSACESFilmic.inc"
|
#include "XboxOneToneMap_PSACESFilmic.inc"
|
||||||
#include "XboxOneToneMap_PS_SRGB.inc"
|
#include "XboxOneToneMap_PS_SRGB.inc"
|
||||||
#include "XboxOneToneMap_PSSaturate_SRGB.inc"
|
#include "XboxOneToneMap_PSSaturate_SRGB.inc"
|
||||||
#include "XboxOneToneMap_PSReinhard_SRGB.inc"
|
#include "XboxOneToneMap_PSReinhard_SRGB.inc"
|
||||||
#include "XboxOneToneMap_PSACESFilmic_SRGB.inc"
|
#include "XboxOneToneMap_PSACESFilmic_SRGB.inc"
|
||||||
#include "XboxOneToneMap_PSHDR10.inc"
|
#include "XboxOneToneMap_PSHDR10.inc"
|
||||||
#include "XboxOneToneMap_PSHDR10_Saturate.inc"
|
#include "XboxOneToneMap_PSHDR10_Saturate.inc"
|
||||||
#include "XboxOneToneMap_PSHDR10_Reinhard.inc"
|
#include "XboxOneToneMap_PSHDR10_Reinhard.inc"
|
||||||
#include "XboxOneToneMap_PSHDR10_ACESFilmic.inc"
|
#include "XboxOneToneMap_PSHDR10_ACESFilmic.inc"
|
||||||
#include "XboxOneToneMap_PSHDR10_Saturate_SRGB.inc"
|
#include "XboxOneToneMap_PSHDR10_Saturate_SRGB.inc"
|
||||||
#include "XboxOneToneMap_PSHDR10_Reinhard_SRGB.inc"
|
#include "XboxOneToneMap_PSHDR10_Reinhard_SRGB.inc"
|
||||||
#include "XboxOneToneMap_PSHDR10_ACESFilmic_SRGB.inc"
|
#include "XboxOneToneMap_PSHDR10_ACESFilmic_SRGB.inc"
|
||||||
#else
|
#else
|
||||||
#include "ToneMap_VSQuad.inc"
|
#include "ToneMap_VSQuad.inc"
|
||||||
|
|
||||||
#include "ToneMap_PSCopy.inc"
|
#include "ToneMap_PSCopy.inc"
|
||||||
#include "ToneMap_PSSaturate.inc"
|
#include "ToneMap_PSSaturate.inc"
|
||||||
#include "ToneMap_PSReinhard.inc"
|
#include "ToneMap_PSReinhard.inc"
|
||||||
#include "ToneMap_PSACESFilmic.inc"
|
#include "ToneMap_PSACESFilmic.inc"
|
||||||
#include "ToneMap_PS_SRGB.inc"
|
#include "ToneMap_PS_SRGB.inc"
|
||||||
#include "ToneMap_PSSaturate_SRGB.inc"
|
#include "ToneMap_PSSaturate_SRGB.inc"
|
||||||
#include "ToneMap_PSReinhard_SRGB.inc"
|
#include "ToneMap_PSReinhard_SRGB.inc"
|
||||||
#include "ToneMap_PSACESFilmic_SRGB.inc"
|
#include "ToneMap_PSACESFilmic_SRGB.inc"
|
||||||
#include "ToneMap_PSHDR10.inc"
|
#include "ToneMap_PSHDR10.inc"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const D3D12_SHADER_BYTECODE vertexShader =
|
const D3D12_SHADER_BYTECODE vertexShader =
|
||||||
{ ToneMap_VSQuad, sizeof(ToneMap_VSQuad) };
|
{ ToneMap_VSQuad, sizeof(ToneMap_VSQuad) };
|
||||||
|
|
||||||
const D3D12_SHADER_BYTECODE pixelShaders[] =
|
const D3D12_SHADER_BYTECODE pixelShaders[] =
|
||||||
{
|
{
|
||||||
|
@ -223,19 +224,20 @@ namespace
|
||||||
public:
|
public:
|
||||||
DeviceResources(_In_ ID3D12Device* device) noexcept
|
DeviceResources(_In_ ID3D12Device* device) noexcept
|
||||||
: mDevice(device)
|
: mDevice(device)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ID3D12RootSignature* GetRootSignature(const D3D12_ROOT_SIGNATURE_DESC& desc)
|
ID3D12RootSignature* GetRootSignature(const D3D12_ROOT_SIGNATURE_DESC& desc)
|
||||||
{
|
{
|
||||||
return DemandCreate(mRootSignature, mMutex, [&](ID3D12RootSignature** pResult) noexcept -> HRESULT
|
return DemandCreate(mRootSignature, mMutex, [&](ID3D12RootSignature** pResult) noexcept -> HRESULT
|
||||||
{
|
{
|
||||||
HRESULT hr = CreateRootSignature(mDevice.Get(), &desc, pResult);
|
HRESULT hr = CreateRootSignature(mDevice.Get(), &desc, pResult);
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
SetDebugObjectName(*pResult, L"ToneMapPostProcess");
|
SetDebugObjectName(*pResult, L"ToneMapPostProcess");
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D12Device* GetDevice() const noexcept { return mDevice.Get(); }
|
ID3D12Device* GetDevice() const noexcept { return mDevice.Get(); }
|
||||||
|
@ -246,6 +248,7 @@ namespace
|
||||||
std::mutex mMutex;
|
std::mutex mMutex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
class ToneMapPostProcess::Impl : public AlignedNew<ToneMapConstants>
|
class ToneMapPostProcess::Impl : public AlignedNew<ToneMapConstants>
|
||||||
{
|
{
|
||||||
|
@ -430,7 +433,7 @@ void ToneMapPostProcess::Impl::Process(_In_ ID3D12GraphicsCommandList* commandLi
|
||||||
// Public constructor.
|
// Public constructor.
|
||||||
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
|
||||||
ToneMapPostProcess::ToneMapPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Operator op, TransferFunction func, bool mrt)
|
ToneMapPostProcess::ToneMapPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Operator op, TransferFunction func, bool mrt)
|
||||||
: pImpl(std::make_unique<Impl>(device, rtState, op, func, mrt))
|
: pImpl(std::make_unique<Impl>(device, rtState, op, func, mrt))
|
||||||
#else
|
#else
|
||||||
ToneMapPostProcess::ToneMapPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Operator op, TransferFunction func)
|
ToneMapPostProcess::ToneMapPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Operator op, TransferFunction func)
|
||||||
: pImpl(std::make_unique<Impl>(device, rtState, op, func))
|
: pImpl(std::make_unique<Impl>(device, rtState, op, func))
|
||||||
|
|
|
@ -554,7 +554,7 @@ namespace
|
||||||
_In_z_ const wchar_t* fileName,
|
_In_z_ const wchar_t* fileName,
|
||||||
_In_ ID3D12Resource** texture) noexcept
|
_In_ ID3D12Resource** texture) noexcept
|
||||||
{
|
{
|
||||||
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||||
if (texture && *texture)
|
if (texture && *texture)
|
||||||
{
|
{
|
||||||
const wchar_t* pstrName = wcsrchr(fileName, '\\');
|
const wchar_t* pstrName = wcsrchr(fileName, '\\');
|
||||||
|
@ -569,10 +569,10 @@ namespace
|
||||||
|
|
||||||
(*texture)->SetName(pstrName);
|
(*texture)->SetName(pstrName);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UNREFERENCED_PARAMETER(fileName);
|
UNREFERENCED_PARAMETER(fileName);
|
||||||
UNREFERENCED_PARAMETER(texture);
|
UNREFERENCED_PARAMETER(texture);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
Загрузка…
Ссылка в новой задаче