forked from opdenkamp/xbmc
/
RenderSystemDX.cpp
1690 lines (1410 loc) · 55.6 KB
/
RenderSystemDX.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2005-2013 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#ifdef HAS_DX
#include <DirectXPackedVector.h>
#include "Application.h"
#include "RenderSystemDX.h"
#include "cores/VideoPlayer/VideoRenderers/RenderManager.h"
#include "guilib/D3DResource.h"
#include "guilib/GUIShaderDX.h"
#include "guilib/GUITextureD3D.h"
#include "guilib/GUIWindowManager.h"
#include "settings/AdvancedSettings.h"
#include "threads/SingleLock.h"
#include "utils/MathUtils.h"
#include "utils/TimeUtils.h"
#include "utils/log.h"
#include "win32/WIN32Util.h"
#include "win32/dxerr.h"
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "dxguid.lib")
#define RATIONAL_TO_FLOAT(rational) ((rational.Denominator != 0) ? (float)rational.Numerator / (float)rational.Denominator : 0.0)
using namespace DirectX::PackedVector;
CRenderSystemDX::CRenderSystemDX() : CRenderSystemBase()
{
m_enumRenderingSystem = RENDERING_SYSTEM_DIRECTX;
m_hFocusWnd = NULL;
m_hDeviceWnd = NULL;
m_nBackBufferWidth = 0;
m_nBackBufferHeight = 0;
m_bFullScreenDevice = false;
m_bVSync = true;
m_nDeviceStatus = S_OK;
m_inScene = false;
m_needNewDevice = false;
m_resizeInProgress = false;
m_screenHeight = 0;
m_systemFreq = CurrentHostFrequency();
m_defaultD3DUsage = D3D11_USAGE_DEFAULT;
m_featureLevel = D3D_FEATURE_LEVEL_11_1;
m_driverType = D3D_DRIVER_TYPE_HARDWARE;
m_adapter = NULL;
m_adapterIndex = -1;
m_pOutput = NULL;
m_dxgiFactory = NULL;
m_pD3DDev = NULL;
m_pImdContext = NULL;
m_pContext = NULL;
m_pSwapChain = NULL;
m_pSwapChain1 = NULL;
m_pRenderTargetView = NULL;
m_depthStencilState = NULL;
m_depthStencilView = NULL;
m_BlendEnableState = NULL;
m_BlendDisableState = NULL;
m_BlendEnabled = false;
m_RSScissorDisable = NULL;
m_RSScissorEnable = NULL;
m_ScissorsEnabled = false;
m_pTextureRight = NULL;
m_pRenderTargetViewRight = NULL;
m_pShaderResourceViewRight = NULL;
m_pGUIShader = NULL;
m_bResizeRequred = false;
m_bHWStereoEnabled = false;
ZeroMemory(&m_cachedMode, sizeof(m_cachedMode));
ZeroMemory(&m_viewPort, sizeof(m_viewPort));
ZeroMemory(&m_scissor, sizeof(CRect));
}
CRenderSystemDX::~CRenderSystemDX()
{
}
bool CRenderSystemDX::InitRenderSystem()
{
m_bVSync = true;
CLog::Log(LOGDEBUG, __FUNCTION__" - Initializing D3D11 Factory...");
HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), reinterpret_cast<void**>(&m_dxgiFactory));
if (FAILED(hr))
{
CLog::Log(LOGERROR, __FUNCTION__" - D3D11 initialization failed.");
return false;
}
UpdateMonitor();
return CreateDevice();
}
void CRenderSystemDX::SetRenderParams(unsigned int width, unsigned int height, bool fullScreen, float refreshRate)
{
m_nBackBufferWidth = width;
m_nBackBufferHeight = height;
m_bFullScreenDevice = fullScreen;
m_refreshRate = refreshRate;
}
void CRenderSystemDX::SetMonitor(HMONITOR monitor)
{
if (!m_dxgiFactory)
return;
DXGI_OUTPUT_DESC outputDesc;
if (m_pOutput && SUCCEEDED(m_pOutput->GetDesc(&outputDesc)) && outputDesc.Monitor == monitor)
return;
// find the appropriate screen
IDXGIAdapter1* pAdapter;
for (unsigned i = 0; m_dxgiFactory->EnumAdapters1(i, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++i)
{
IDXGIOutput* pOutput;
for (unsigned j = 0; pAdapter->EnumOutputs(j, &pOutput) != DXGI_ERROR_NOT_FOUND; ++j)
{
if (FAILED(pOutput->GetDesc(&outputDesc)))
break;
if (outputDesc.Monitor == monitor)
{
// update monitor info
SAFE_RELEASE(m_pOutput);
m_pOutput = pOutput;
CLog::Log(LOGDEBUG, __FUNCTION__" - Selected %S output. ", outputDesc.DeviceName);
// check if adapter is changed
if (m_adapterIndex != i)
{
pAdapter->GetDesc(&m_adapterDesc);
CLog::Log(LOGDEBUG, __FUNCTION__" - Selected %S adapter. ", m_adapterDesc.Description, outputDesc.DeviceName);
SAFE_RELEASE(m_adapter);
m_adapter = pAdapter;
m_needNewDevice = true;
m_adapterIndex = i;
return;
}
return;
}
pOutput->Release();
}
pAdapter->Release();
}
}
bool CRenderSystemDX::ResetRenderSystem(int width, int height, bool fullScreen, float refreshRate)
{
if (!m_pD3DDev)
return false;
if (m_hDeviceWnd != NULL)
{
HMONITOR hMonitor = MonitorFromWindow(m_hDeviceWnd, MONITOR_DEFAULTTONULL);
if (hMonitor)
SetMonitor(hMonitor);
}
SetRenderParams(width, height, fullScreen, refreshRate);
CRect rc(0, 0, float(width), float(height));
SetViewPort(rc);
if (!m_needNewDevice)
{
CreateWindowSizeDependentResources();
SetFullScreenInternal();
if (m_bResizeRequred)
CreateWindowSizeDependentResources();
}
else
{
OnDeviceLost();
OnDeviceReset();
}
return true;
}
void CRenderSystemDX::OnMove()
{
if (!m_bRenderCreated)
return;
DXGI_OUTPUT_DESC outputDesc;
m_pOutput->GetDesc(&outputDesc);
HMONITOR newMonitor = MonitorFromWindow(m_hDeviceWnd, MONITOR_DEFAULTTONULL);
if (newMonitor != NULL && outputDesc.Monitor != newMonitor)
{
SetMonitor(newMonitor);
if (m_needNewDevice)
{
CLog::Log(LOGDEBUG, "%s - Adapter changed, reseting render system.", __FUNCTION__);
ResetRenderSystem(m_nBackBufferWidth, m_nBackBufferHeight, m_bFullScreenDevice, m_refreshRate);
}
}
}
void CRenderSystemDX::OnResize(unsigned int width, unsigned int height)
{
if (!m_bRenderCreated)
return;
m_nBackBufferWidth = width;
m_nBackBufferHeight = height;
CreateWindowSizeDependentResources();
}
void CRenderSystemDX::GetClosestDisplayModeToCurrent(IDXGIOutput* output, DXGI_MODE_DESC* outCurrentDisplayMode, bool useCached /*= false*/)
{
DXGI_OUTPUT_DESC outputDesc;
output->GetDesc(&outputDesc);
HMONITOR hMonitor = outputDesc.Monitor;
MONITORINFOEX monitorInfo;
monitorInfo.cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(hMonitor, &monitorInfo);
DEVMODE devMode;
devMode.dmSize = sizeof(DEVMODE);
devMode.dmDriverExtra = 0;
EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode);
bool useDefaultRefreshRate = 1 == devMode.dmDisplayFrequency || 0 == devMode.dmDisplayFrequency;
float refreshRate = RATIONAL_TO_FLOAT(m_cachedMode.RefreshRate);
// this needed to improve performance for VideoSync bacause FindClosestMatchingMode is very slow
if (!useCached
|| m_cachedMode.Width != devMode.dmPelsWidth
|| m_cachedMode.Height != devMode.dmPelsHeight
|| long(refreshRate) != devMode.dmDisplayFrequency)
{
DXGI_MODE_DESC current;
current.Width = devMode.dmPelsWidth;
current.Height = devMode.dmPelsHeight;
current.RefreshRate.Numerator = useDefaultRefreshRate ? 0 : devMode.dmDisplayFrequency;
current.RefreshRate.Denominator = useDefaultRefreshRate ? 0 : 1;
current.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
current.ScanlineOrdering = m_interlaced ? DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST : DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE;
current.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
output->FindClosestMatchingMode(¤t, &m_cachedMode, m_pD3DDev);
}
ZeroMemory(outCurrentDisplayMode, sizeof(DXGI_MODE_DESC));
outCurrentDisplayMode->Width = m_cachedMode.Width;
outCurrentDisplayMode->Height = m_cachedMode.Height;
outCurrentDisplayMode->RefreshRate.Numerator = m_cachedMode.RefreshRate.Numerator;
outCurrentDisplayMode->RefreshRate.Denominator = m_cachedMode.RefreshRate.Denominator;
outCurrentDisplayMode->Format = m_cachedMode.Format;
outCurrentDisplayMode->ScanlineOrdering = m_cachedMode.ScanlineOrdering;
outCurrentDisplayMode->Scaling = m_cachedMode.Scaling;
}
void CRenderSystemDX::GetDisplayMode(DXGI_MODE_DESC *mode, bool useCached /*= false*/)
{
GetClosestDisplayModeToCurrent(m_pOutput, mode, useCached);
}
inline void DXWait(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
ID3D11Query* wait = NULL;
CD3D11_QUERY_DESC qd(D3D11_QUERY_EVENT);
if (SUCCEEDED(pDevice->CreateQuery(&qd, &wait)))
{
pContext->End(wait);
while (S_FALSE == pContext->GetData(wait, NULL, 0, 0))
Sleep(1);
}
SAFE_RELEASE(wait);
}
void CRenderSystemDX::SetFullScreenInternal()
{
if (!m_bRenderCreated)
return;
HRESULT hr;
BOOL bFullScreen;
m_pSwapChain->GetFullscreenState(&bFullScreen, NULL);
// full-screen to windowed translation. Only change FS state and return
if (!!bFullScreen && m_useWindowedDX)
{
CLog::Log(LOGDEBUG, "%s - Switching swap chain to windowed mode.", __FUNCTION__);
hr = m_pSwapChain->SetFullscreenState(false, NULL);
m_bResizeRequred = S_OK == hr;
if (S_OK != hr)
CLog::Log(LOGERROR, "%s - Failed switch full screen state: %s.", __FUNCTION__, GetErrorDescription(hr).c_str());
// wait until switching screen state is done
DXWait(m_pD3DDev, m_pImdContext);
return;
}
// true full-screen
if (m_bFullScreenDevice && !m_useWindowedDX)
{
IDXGIOutput* pOutput = NULL;
m_pSwapChain->GetContainingOutput(&pOutput);
DXGI_OUTPUT_DESC trgDesc, currDesc;
m_pOutput->GetDesc(&trgDesc);
pOutput->GetDesc(&currDesc);
if (trgDesc.Monitor != currDesc.Monitor || !bFullScreen)
{
// swap chain requires to change FS mode after resize or transition from windowed to full-screen.
CLog::Log(LOGDEBUG, "%s - Switching swap chain to fullscreen state.", __FUNCTION__);
hr = m_pSwapChain->SetFullscreenState(true, m_pOutput);
m_bResizeRequred = S_OK == hr;
if (S_OK != hr)
CLog::Log(LOGERROR, "%s - Failed switch full screen state: %s.", __FUNCTION__, GetErrorDescription(hr).c_str());
}
SAFE_RELEASE(pOutput);
// do not change modes if hw stereo
if (g_graphicsContext.GetStereoMode() == RENDER_STEREO_MODE_HARDWAREBASED)
return;
DXGI_SWAP_CHAIN_DESC scDesc;
m_pSwapChain->GetDesc(&scDesc);
DXGI_MODE_DESC currentMode, // closest to current mode
toMatchMode, // required mode
matchedMode; // closest to required mode
// find current mode on target output
GetClosestDisplayModeToCurrent(m_pOutput, ¤tMode);
float currentRefreshRate = RATIONAL_TO_FLOAT(currentMode.RefreshRate);
CLog::Log(LOGDEBUG, "%s - Current display mode is: %dx%d@%0.3f", __FUNCTION__, currentMode.Width, currentMode.Height, currentRefreshRate);
// use backbuffer dimention to find required display mode
toMatchMode.Width = m_nBackBufferWidth;
toMatchMode.Height = m_nBackBufferHeight;
bool useDefaultRefreshRate = 0 == m_refreshRate;
toMatchMode.RefreshRate.Numerator = useDefaultRefreshRate ? 0 : m_refreshRate;
toMatchMode.RefreshRate.Denominator = useDefaultRefreshRate ? 0 : 1;
toMatchMode.Format = scDesc.BufferDesc.Format;
toMatchMode.Scaling = scDesc.BufferDesc.Scaling;
toMatchMode.ScanlineOrdering = scDesc.BufferDesc.ScanlineOrdering;
// find closest mode
m_pOutput->FindClosestMatchingMode(&toMatchMode, &matchedMode, m_pD3DDev);
float matchedRefreshRate = RATIONAL_TO_FLOAT(matchedMode.RefreshRate);
CLog::Log(LOGDEBUG, "%s - Found matched mode: %dx%d@%0.3f", __FUNCTION__, matchedMode.Width, matchedMode.Height, matchedRefreshRate);
// change mode if required (current != required)
if ( currentMode.Width != matchedMode.Width
|| currentMode.Height != matchedMode.Height
|| currentRefreshRate != matchedRefreshRate)
{
CLog::Log(LOGDEBUG, "%s - Switching mode to %dx%d@%0.3f.", __FUNCTION__, matchedMode.Width, matchedMode.Height, matchedRefreshRate);
// resize window (in windowed mode) or monitor resolution (in fullscreen mode) to required mode
hr = m_pSwapChain->ResizeTarget(&matchedMode);
m_bResizeRequred = S_OK == hr;
if (FAILED(hr))
CLog::Log(LOGERROR, "%s - Failed to switch output mode: %s", __FUNCTION__, GetErrorDescription(hr).c_str());
}
// wait until switching screen state is done
DXWait(m_pD3DDev, m_pImdContext);
}
}
bool CRenderSystemDX::IsFormatSupport(DXGI_FORMAT format, unsigned int usage)
{
UINT supported;
m_pD3DDev->CheckFormatSupport(format, &supported);
return (supported & usage) != 0;
}
bool CRenderSystemDX::DestroyRenderSystem()
{
DeleteDevice();
SAFE_RELEASE(m_pOutput);
SAFE_RELEASE(m_adapter);
SAFE_RELEASE(m_dxgiFactory);
#ifdef _DEBUG
if (m_d3dDebug)
{
m_d3dDebug->ReportLiveDeviceObjects(D3D11_RLDO_SUMMARY | D3D11_RLDO_DETAIL);
m_d3dDebug->Release();
}
#endif
return true;
}
void CRenderSystemDX::DeleteDevice()
{
CSingleLock lock(m_resourceSection);
if (m_pGUIShader)
m_pGUIShader->End();
// tell any shared resources
for (std::vector<ID3DResource *>::iterator i = m_resources.begin(); i != m_resources.end(); ++i)
(*i)->OnDestroyDevice();
SAFE_DELETE(m_pGUIShader);
SAFE_RELEASE(m_pTextureRight);
SAFE_RELEASE(m_pRenderTargetViewRight);
SAFE_RELEASE(m_pShaderResourceViewRight);
SAFE_RELEASE(m_BlendEnableState);
SAFE_RELEASE(m_BlendDisableState);
SAFE_RELEASE(m_RSScissorDisable);
SAFE_RELEASE(m_RSScissorEnable);
SAFE_RELEASE(m_depthStencilState);
SAFE_RELEASE(m_depthStencilView);
SAFE_RELEASE(m_pRenderTargetView);
if (m_pSwapChain)
{
m_pSwapChain->SetFullscreenState(false, NULL);
SAFE_RELEASE(m_pSwapChain);
}
SAFE_RELEASE(m_pSwapChain1);
SAFE_RELEASE(m_pD3DDev);
if (m_pContext && m_pContext != m_pImdContext)
{
FinishCommandList(false);
m_pContext->ClearState();
m_pContext->Flush();
SAFE_RELEASE(m_pContext);
}
if (m_pImdContext)
{
m_pImdContext->ClearState();
m_pImdContext->Flush();
SAFE_RELEASE(m_pImdContext);
}
m_bResizeRequred = false;
m_bHWStereoEnabled = false;
m_bRenderCreated = false;
}
void CRenderSystemDX::OnDeviceLost()
{
CSingleLock lock(m_resourceSection);
g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_RENDERER_LOST);
if (m_needNewDevice)
DeleteDevice();
else
{
// just resetting the device
for (std::vector<ID3DResource *>::iterator i = m_resources.begin(); i != m_resources.end(); ++i)
(*i)->OnLostDevice();
}
}
void CRenderSystemDX::OnDeviceReset()
{
CSingleLock lock(m_resourceSection);
if (m_needNewDevice)
CreateDevice();
else
{ // we're back
for (std::vector<ID3DResource *>::iterator i = m_resources.begin(); i != m_resources.end(); ++i)
(*i)->OnResetDevice();
}
//g_renderManager.Flush();
g_windowManager.SendMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_RENDERER_RESET);
}
bool CRenderSystemDX::CreateDevice()
{
CSingleLock lock(m_resourceSection);
HRESULT hr;
SAFE_RELEASE(m_pD3DDev);
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1,
};
// the VIDEO_SUPPORT flag force lowering feature level if current env not support video on 11_1
UINT createDeviceFlags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT;
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
// we should specify D3D_DRIVER_TYPE_UNKNOWN if create device with specified adapter.
hr = D3D11CreateDevice(m_adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, createDeviceFlags, featureLevels, ARRAYSIZE(featureLevels),
D3D11_SDK_VERSION, &m_pD3DDev, &m_featureLevel, &m_pImdContext);
if (FAILED(hr))
{
// DirectX 11.0 platforms will not recognize D3D_FEATURE_LEVEL_11_1 so we need to retry without it
CLog::Log(LOGDEBUG, "%s - First try to create device failed with error: %s.", __FUNCTION__, GetErrorDescription(hr).c_str());
CLog::Log(LOGDEBUG, "%s - Trying to create device with lowest feature level: %#x.", __FUNCTION__, featureLevels[1]);
hr = D3D11CreateDevice(m_adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, createDeviceFlags, &featureLevels[1], ARRAYSIZE(featureLevels) - 1,
D3D11_SDK_VERSION, &m_pD3DDev, &m_featureLevel, &m_pImdContext);
if (FAILED(hr))
{
// still failed. seems driver doesn't support video API acceleration, try without VIDEO_SUPPORT flag
CLog::Log(LOGDEBUG, "%s - Next try to create device failed with error: %s.", __FUNCTION__, GetErrorDescription(hr).c_str());
CLog::Log(LOGDEBUG, "%s - Trying to create device without video API support.", __FUNCTION__);
createDeviceFlags &= ~D3D11_CREATE_DEVICE_VIDEO_SUPPORT;
hr = D3D11CreateDevice(m_adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, createDeviceFlags, &featureLevels[1], ARRAYSIZE(featureLevels) - 1,
D3D11_SDK_VERSION, &m_pD3DDev, &m_featureLevel, &m_pImdContext);
if (SUCCEEDED(hr))
CLog::Log(LOGNOTICE, "%s - Your video driver doesn't support DirectX 11 Video Acceleration API. Application is not be able to use hardware video processing and decoding", __FUNCTION__);
}
}
if (FAILED(hr))
{
CLog::Log(LOGERROR, "%s - D3D11 device creation failure with error %s.", __FUNCTION__, GetErrorDescription(hr).c_str());
return false;
}
if ( g_advancedSettings.m_bAllowDeferredRendering
&& FAILED(m_pD3DDev->CreateDeferredContext(0, &m_pContext)))
{
CLog::Log(LOGERROR, "%s - Failed to create deferred context, deferred rendering is not possible, fallback to immediate rendering.", __FUNCTION__);
}
// make immediate context as default context if deferred context was not created
if (!m_pContext)
m_pContext = m_pImdContext;
if (m_featureLevel < D3D_FEATURE_LEVEL_9_3)
m_maxTextureSize = D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION;
else if (m_featureLevel < D3D_FEATURE_LEVEL_10_0)
m_maxTextureSize = D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION;
else if (m_featureLevel < D3D_FEATURE_LEVEL_11_0)
m_maxTextureSize = D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION;
else
// 11_x and greater feature level. Limit this size to avoid memory overheads
m_maxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION >> 1;
// use multi-thread protection on the device context to prevent deadlock issues that can sometimes happen
// when decoder call ID3D11VideoContext::GetDecoderBuffer or ID3D11VideoContext::ReleaseDecoderBuffer.
ID3D10Multithread *pMultiThreading = NULL;
if (SUCCEEDED(m_pD3DDev->QueryInterface(__uuidof(ID3D10Multithread), reinterpret_cast<void**>(&pMultiThreading))))
{
pMultiThreading->SetMultithreadProtected(true);
pMultiThreading->Release();
}
IDXGIDevice1* pDXGIDevice = NULL;
if (SUCCEEDED(m_pD3DDev->QueryInterface(__uuidof(IDXGIDevice1), reinterpret_cast<void**>(&pDXGIDevice))))
{
// Not sure the following actually does something but this exists in dx9 implementation
pDXGIDevice->SetGPUThreadPriority(7);
// Ensure that DXGI does not queue more than one frame at a time. This both reduces
// latency and ensures that the application will only render after each VSync
pDXGIDevice->SetMaximumFrameLatency(1);
SAFE_RELEASE(pDXGIDevice);
}
#ifdef _DEBUG
if (SUCCEEDED(m_pD3DDev->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&m_d3dDebug))))
{
ID3D11InfoQueue *d3dInfoQueue = nullptr;
if (SUCCEEDED(m_d3dDebug->QueryInterface(__uuidof(ID3D11InfoQueue), reinterpret_cast<void**>(&d3dInfoQueue))))
{
D3D11_MESSAGE_ID hide[] =
{
D3D11_MESSAGE_ID_GETVIDEOPROCESSORFILTERRANGE_UNSUPPORTED, // avoid GETVIDEOPROCESSORFILTERRANGE_UNSUPPORTED (dx bug)
D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_NEGATIVESCISSOR // avoid warning for some labels out of screen
// Add more message IDs here as needed
};
D3D11_INFO_QUEUE_FILTER filter;
ZeroMemory(&filter, sizeof(filter));
filter.DenyList.NumIDs = _countof(hide);
filter.DenyList.pIDList = hide;
d3dInfoQueue->AddStorageFilterEntries(&filter);
d3dInfoQueue->Release();
}
}
#endif
m_adapterDesc = {};
if (SUCCEEDED(m_adapter->GetDesc(&m_adapterDesc)))
{
CLog::Log(LOGDEBUG, "%s - on adapter %S (VendorId: %#x DeviceId: %#x) with feature level %#x.", __FUNCTION__,
m_adapterDesc.Description, m_adapterDesc.VendorId, m_adapterDesc.DeviceId, m_featureLevel);
m_RenderRenderer = StringUtils::Format("%S", m_adapterDesc.Description);
IDXGIFactory2* dxgiFactory2 = nullptr;
m_dxgiFactory->QueryInterface(__uuidof(IDXGIFactory2), reinterpret_cast<void**>(&dxgiFactory2));
m_RenderVersion = StringUtils::Format("DirectX %s (FL %d.%d)",
dxgiFactory2 != nullptr ? "11.1" : "11.0",
(m_featureLevel >> 12) & 0xF,
(m_featureLevel >> 8) & 0xF);
SAFE_RELEASE(dxgiFactory2);
}
m_renderCaps = 0;
unsigned int usage = D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_SHADER_SAMPLE;
if ( IsFormatSupport(DXGI_FORMAT_BC1_UNORM, usage)
&& IsFormatSupport(DXGI_FORMAT_BC2_UNORM, usage)
&& IsFormatSupport(DXGI_FORMAT_BC3_UNORM, usage))
m_renderCaps |= RENDER_CAPS_DXT;
// MSDN: At feature levels 9_1, 9_2 and 9_3, the display device supports the use of 2D textures with dimensions that are not powers of two under two conditions.
// First, only one MIP-map level for each texture can be created - we are using only 1 mip level)
// Second, no wrap sampler modes for textures are allowed - we are using clamp everywhere
// At feature levels 10_0, 10_1 and 11_0, the display device unconditionally supports the use of 2D textures with dimensions that are not powers of two.
// so, setup caps NPOT
m_renderCaps |= RENDER_CAPS_NPOT;
if ((m_renderCaps & RENDER_CAPS_DXT) != 0)
m_renderCaps |= RENDER_CAPS_DXT_NPOT;
// Temporary - allow limiting the caps to debug a texture problem
if (g_advancedSettings.m_RestrictCapsMask != 0)
m_renderCaps &= ~g_advancedSettings.m_RestrictCapsMask;
if (m_renderCaps & RENDER_CAPS_DXT)
CLog::Log(LOGDEBUG, "%s - RENDER_CAPS_DXT", __FUNCTION__);
if (m_renderCaps & RENDER_CAPS_NPOT)
CLog::Log(LOGDEBUG, "%s - RENDER_CAPS_NPOT", __FUNCTION__);
if (m_renderCaps & RENDER_CAPS_DXT_NPOT)
CLog::Log(LOGDEBUG, "%s - RENDER_CAPS_DXT_NPOT", __FUNCTION__);
/* All the following quirks need to be tested
// nVidia quirk: some NPOT DXT textures of the GUI display with corruption
// when using D3DPOOL_DEFAULT + D3DUSAGE_DYNAMIC textures (no other choice with D3D9Ex for example)
// most likely xbmc bug, but no hw to repro & fix properly.
// affects lots of hw generations - 6xxx, 7xxx, GT220, ION1
// see ticket #9269
if (m_adapterDesc.VendorId == PCIV_nVidia)
{
CLog::Log(LOGDEBUG, __FUNCTION__" - nVidia workaround - disabling RENDER_CAPS_DXT_NPOT");
m_renderCaps &= ~RENDER_CAPS_DXT_NPOT;
}
// Intel quirk: DXT texture pitch must be > 64
// when using D3DPOOL_DEFAULT + D3DUSAGE_DYNAMIC textures (no other choice with D3D9Ex)
// DXT1: 32 pixels wide is the largest non-working texture width
// DXT3/5: 16 pixels wide ----------------------------------------
// Both equal to a pitch of 64. So far no Intel has DXT NPOT (including i3/i5/i7, so just go with the next higher POT.
// See ticket #9578
if (m_adapterDesc.VendorId == PCIV_Intel)
{
CLog::Log(LOGDEBUG, __FUNCTION__" - Intel workaround - specifying minimum pitch for compressed textures.");
m_minDXTPitch = 128;
}*/
if (!CreateStates() || !InitGUIShader() || !CreateWindowSizeDependentResources())
return false;
m_bRenderCreated = true;
m_needNewDevice = false;
// tell any shared objects about our resurrection
for (std::vector<ID3DResource *>::iterator i = m_resources.begin(); i != m_resources.end(); ++i)
(*i)->OnCreateDevice();
RestoreViewPort();
return true;
}
bool CRenderSystemDX::CreateWindowSizeDependentResources()
{
if (m_resizeInProgress)
return false;
HRESULT hr;
DXGI_SWAP_CHAIN_DESC scDesc = { 0 };
bool bNeedRecreate = false;
bool bNeedResize = false;
bool bHWStereoEnabled = RENDER_STEREO_MODE_HARDWAREBASED == g_graphicsContext.GetStereoMode();
if (m_pSwapChain)
{
m_pSwapChain->GetDesc(&scDesc);
bNeedResize = m_bResizeRequred || m_nBackBufferWidth != scDesc.BufferDesc.Width || m_nBackBufferHeight != scDesc.BufferDesc.Height;
}
else
bNeedResize = true;
if (m_pSwapChain1)
{
DXGI_SWAP_CHAIN_DESC1 scDesc;
m_pSwapChain1->GetDesc1(&scDesc);
bNeedRecreate = (scDesc.Stereo && !bHWStereoEnabled) || (!scDesc.Stereo && bHWStereoEnabled);
}
if (!bNeedRecreate && !bNeedResize)
{
CheckInterlasedStereoView();
return true;
}
m_resizeInProgress = true;
CLog::Log(LOGDEBUG, "%s - (Re)Create window size (%dx%d) dependent resources.", __FUNCTION__, m_nBackBufferWidth, m_nBackBufferHeight);
bool bRestoreRTView = false;
{
ID3D11RenderTargetView* pRTView; ID3D11DepthStencilView* pDSView;
m_pContext->OMGetRenderTargets(1, &pRTView, &pDSView);
bRestoreRTView = NULL != pRTView || NULL != pDSView;
SAFE_RELEASE(pRTView);
SAFE_RELEASE(pDSView);
}
m_pContext->OMSetRenderTargets(0, NULL, NULL);
FinishCommandList(false);
SAFE_RELEASE(m_pRenderTargetView);
SAFE_RELEASE(m_depthStencilView);
SAFE_RELEASE(m_pRenderTargetViewRight);
SAFE_RELEASE(m_pShaderResourceViewRight);
SAFE_RELEASE(m_pTextureRight);
if (bNeedRecreate)
{
BOOL fullScreen;
m_pSwapChain1->GetFullscreenState(&fullScreen, NULL);
if (fullScreen)
m_pSwapChain1->SetFullscreenState(false, NULL);
CLog::Log(LOGDEBUG, "%s - Destroying swapchain in order to switch %s stereoscopic 3D.", __FUNCTION__, bHWStereoEnabled ? "to" : "from");
SAFE_RELEASE(m_pSwapChain);
SAFE_RELEASE(m_pSwapChain1);
m_pImdContext->Flush();
// flush command is asynchronous, so wait until destruction is completed
// otherwise it can cause problems with flip presentation model swap chains.
DXWait(m_pD3DDev, m_pImdContext);
}
if (!m_pSwapChain)
{
CLog::Log(LOGDEBUG, "%s - Creating swapchain in %s mode.", __FUNCTION__, bHWStereoEnabled ? "Stereoscopic 3D" : "Mono");
// Create swap chain
IDXGIFactory2* dxgiFactory2 = NULL;
hr = m_dxgiFactory->QueryInterface(__uuidof(IDXGIFactory2), reinterpret_cast<void**>(&dxgiFactory2));
if (SUCCEEDED(hr) && dxgiFactory2)
{
// DirectX 11.1 or later
DXGI_SWAP_CHAIN_DESC1 scDesc1 = { 0 };
scDesc1.Width = m_nBackBufferWidth;
scDesc1.Height = m_nBackBufferHeight;
scDesc1.BufferCount = 2; // Use double buffering to minimize latency.
scDesc1.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
scDesc1.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scDesc1.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
scDesc1.Stereo = bHWStereoEnabled;
scDesc1.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
scDesc1.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
scDesc1.SampleDesc.Count = 1;
scDesc1.SampleDesc.Quality = 0;
DXGI_SWAP_CHAIN_FULLSCREEN_DESC scFSDesc = { 0 };
scFSDesc.ScanlineOrdering = m_interlaced ? DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST : DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE;
scFSDesc.Windowed = m_useWindowedDX;
hr = dxgiFactory2->CreateSwapChainForHwnd(m_pD3DDev, m_hFocusWnd, &scDesc1, &scFSDesc, NULL, &m_pSwapChain1);
if (SUCCEEDED(hr))
{
m_pSwapChain1->QueryInterface(__uuidof(IDXGISwapChain), reinterpret_cast<void**>(&m_pSwapChain));
m_bHWStereoEnabled = bHWStereoEnabled;
}
dxgiFactory2->Release();
// this hackish way to disable stereo in windowed mode:
// - restart presenting, 0 in sync interval discards current frame also
// - wait until new frame will be drawn
// sleep value possible depends on hardware m.b. need a setting in as.xml
if (!bHWStereoEnabled && m_useWindowedDX && bNeedRecreate)
{
DXGI_PRESENT_PARAMETERS presentParams = {};
presentParams.DirtyRectsCount = 0;
presentParams.pDirtyRects = NULL;
presentParams.pScrollRect = NULL;
m_pSwapChain1->Present1(0, DXGI_PRESENT_RESTART, &presentParams);
Sleep(100);
}
}
else
{
// DirectX 11.0 systems
scDesc.BufferCount = 2; // Use double buffering to minimize latency.
scDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scDesc.OutputWindow = m_hFocusWnd;
scDesc.Windowed = m_useWindowedDX;
scDesc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL;
scDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
scDesc.BufferDesc.Width = m_nBackBufferWidth;
scDesc.BufferDesc.Height = m_nBackBufferHeight;
scDesc.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
scDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
scDesc.BufferDesc.ScanlineOrdering = m_interlaced ? DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST : DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE;
scDesc.SampleDesc.Count = 1;
scDesc.SampleDesc.Quality = 0;
hr = m_dxgiFactory->CreateSwapChain(m_pD3DDev, &scDesc, &m_pSwapChain);
}
if (FAILED(hr))
{
CLog::Log(LOGERROR, "%s - Creating swap chain failed with error: %s.", __FUNCTION__, GetErrorDescription(hr).c_str());
m_bRenderCreated = false;
return false;
}
// tell DXGI to not interfere with application's handling of window mode changes
m_dxgiFactory->MakeWindowAssociation(m_hFocusWnd, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER);
}
else
{
// resize swap chain buffers with preserving the existing buffer count and format.
hr = m_pSwapChain->ResizeBuffers(scDesc.BufferCount, m_nBackBufferWidth, m_nBackBufferHeight, scDesc.BufferDesc.Format, scDesc.Flags);
if (FAILED(hr))
{
CLog::Log(LOGERROR, "%s - Failed to resize buffers (%s).", __FUNCTION__, GetErrorDescription(hr).c_str());
if (DXGI_ERROR_DEVICE_REMOVED == hr)
OnDeviceLost();
return false;
}
}
// Create a render target view
ID3D11Texture2D* pBackBuffer = nullptr;
hr = m_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&pBackBuffer));
if (FAILED(hr))
{
CLog::Log(LOGERROR, "%s - Failed to get back buffer (%s).", __FUNCTION__, GetErrorDescription(hr).c_str());
return false;
}
// Create a view interface on the rendertarget to use on bind for mono or left eye view.
CD3D11_RENDER_TARGET_VIEW_DESC rtDesc(D3D11_RTV_DIMENSION_TEXTURE2DARRAY, DXGI_FORMAT_UNKNOWN, 0, 0, 1);
hr = m_pD3DDev->CreateRenderTargetView(pBackBuffer, &rtDesc, &m_pRenderTargetView);
if (FAILED(hr))
{
CLog::Log(LOGERROR, "%s - Failed to create render target view (%s).", __FUNCTION__, GetErrorDescription(hr).c_str());
pBackBuffer->Release();
return false;
}
if (m_bHWStereoEnabled)
{
// Stereo swapchains have an arrayed resource, so create a second Render Target for the right eye buffer.
CD3D11_RENDER_TARGET_VIEW_DESC rtDesc(D3D11_RTV_DIMENSION_TEXTURE2DARRAY, DXGI_FORMAT_UNKNOWN, 0, 1, 1);
hr = m_pD3DDev->CreateRenderTargetView(pBackBuffer, &rtDesc, &m_pRenderTargetViewRight);
if (FAILED(hr))
{
CLog::Log(LOGERROR, "%s - Failed to create right eye buffer (%s).", __FUNCTION__, GetErrorDescription(hr).c_str());
pBackBuffer->Release();
g_graphicsContext.SetStereoMode(RENDER_STEREO_MODE_OFF); // try fallback to mono
}
}
pBackBuffer->Release();
DXGI_FORMAT zFormat = DXGI_FORMAT_D16_UNORM;
if (IsFormatSupport(DXGI_FORMAT_D32_FLOAT, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)) zFormat = DXGI_FORMAT_D32_FLOAT;
else if (IsFormatSupport(DXGI_FORMAT_D24_UNORM_S8_UINT, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)) zFormat = DXGI_FORMAT_D24_UNORM_S8_UINT;
else if (IsFormatSupport(DXGI_FORMAT_D16_UNORM, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL)) zFormat = DXGI_FORMAT_D16_UNORM;
ID3D11Texture2D* depthStencilBuffer = NULL;
// Initialize the description of the depth buffer.
CD3D11_TEXTURE2D_DESC depthBufferDesc(zFormat, m_nBackBufferWidth, m_nBackBufferHeight, 1, 1, D3D11_BIND_DEPTH_STENCIL);
// Create the texture for the depth buffer using the filled out description.
hr = m_pD3DDev->CreateTexture2D(&depthBufferDesc, NULL, &depthStencilBuffer);
if (FAILED(hr))
{
CLog::Log(LOGERROR, "%s - Failed to create depth stencil buffer (%s).", __FUNCTION__, GetErrorDescription(hr).c_str());
return false;
}
// Create the depth stencil view.
CD3D11_DEPTH_STENCIL_VIEW_DESC viewDesc(D3D11_DSV_DIMENSION_TEXTURE2D);
hr = m_pD3DDev->CreateDepthStencilView(depthStencilBuffer, &viewDesc, &m_depthStencilView);
depthStencilBuffer->Release();
if (FAILED(hr))
{
CLog::Log(LOGERROR, "%s - Failed to create depth stencil view (%s).", __FUNCTION__, GetErrorDescription(hr).c_str());
return false;
}
if (m_viewPort.Height == 0 || m_viewPort.Width == 0)
{
CRect rect(0, 0, m_nBackBufferWidth, m_nBackBufferHeight);
SetViewPort(rect);
}
// set camera to center of screen
CPoint camPoint = { m_nBackBufferWidth * 0.5f, m_nBackBufferHeight * 0.5f };
SetCameraPosition(camPoint, m_nBackBufferWidth, m_nBackBufferHeight);
CheckInterlasedStereoView();
if (bRestoreRTView)
m_pContext->OMSetRenderTargets(1, &m_pRenderTargetView, m_depthStencilView);
m_resizeInProgress = false;
m_bResizeRequred = false;
return true;
}
void CRenderSystemDX::CheckInterlasedStereoView(void)
{
RENDER_STEREO_MODE stereoMode = g_graphicsContext.GetStereoMode();
if ( m_pRenderTargetViewRight
&& RENDER_STEREO_MODE_INTERLACED != stereoMode
&& RENDER_STEREO_MODE_CHECKERBOARD != stereoMode
&& RENDER_STEREO_MODE_HARDWAREBASED != stereoMode)
{
// release resources
SAFE_RELEASE(m_pRenderTargetViewRight);
SAFE_RELEASE(m_pShaderResourceViewRight);
SAFE_RELEASE(m_pTextureRight);
}
if ( !m_pRenderTargetViewRight
&& ( RENDER_STEREO_MODE_INTERLACED == stereoMode
|| RENDER_STEREO_MODE_CHECKERBOARD == stereoMode))
{
// Create a second Render Target for the right eye buffer
HRESULT hr;
CD3D11_TEXTURE2D_DESC texDesc(DXGI_FORMAT_B8G8R8A8_UNORM, m_nBackBufferWidth, m_nBackBufferHeight, 1, 1,
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE);
hr = m_pD3DDev->CreateTexture2D(&texDesc, NULL, &m_pTextureRight);
if (SUCCEEDED(hr))
{
CD3D11_RENDER_TARGET_VIEW_DESC rtDesc(D3D11_RTV_DIMENSION_TEXTURE2D);
hr = m_pD3DDev->CreateRenderTargetView(m_pTextureRight, &rtDesc, &m_pRenderTargetViewRight);
if (SUCCEEDED(hr))
{
CD3D11_SHADER_RESOURCE_VIEW_DESC srDesc(D3D11_SRV_DIMENSION_TEXTURE2D);
hr = m_pD3DDev->CreateShaderResourceView(m_pTextureRight, &srDesc, &m_pShaderResourceViewRight);
if (FAILED(hr))
CLog::Log(LOGERROR, "%s - Failed to create right view shader resource.", __FUNCTION__);
}
else
CLog::Log(LOGERROR, "%s - Failed to create right view render target.", __FUNCTION__);
}