Skip to content

Latest commit

 

History

History
2570 lines (2263 loc) · 91 KB

SDL_render_d3d11.c

File metadata and controls

2570 lines (2263 loc) · 91 KB
 
1
2
/*
Simple DirectMedia Layer
Jan 5, 2019
Jan 5, 2019
3
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
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
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
#define COBJMACROS
#include "../../core/windows/SDL_windows.h"
#include "SDL_hints.h"
#include "SDL_loadso.h"
#include "SDL_syswm.h"
#include "../SDL_sysrender.h"
#include "../SDL_d3dmath.h"
#include <d3d11_1.h>
Nov 13, 2017
Nov 13, 2017
35
#include "SDL_shaders_d3d11.h"
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifdef __WINRT__
#if NTDDI_VERSION > NTDDI_WIN8
#include <DXGI1_3.h>
#endif
#include "SDL_render_winrt.h"
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
#include <windows.ui.xaml.media.dxinterop.h>
/* TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var */
extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative;
#endif /* WINAPI_FAMILY == WINAPI_FAMILY_APP */
#endif /* __WINRT__ */
Oct 1, 2016
Oct 1, 2016
54
55
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
56
57
58
#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; }
Oct 3, 2018
Oct 3, 2018
59
60
61
/* !!! FIXME: vertex buffer bandwidth could be significantly lower; move color to a uniform, only use UV coords
!!! FIXME: when textures are needed, and don't ever pass Z, since it's always zero. */
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
/* Vertex shader, common values */
typedef struct
{
Float4X4 model;
Float4X4 projectionAndView;
} VertexShaderConstants;
/* Per-vertex data */
typedef struct
{
Float3 pos;
Float2 tex;
Float4 color;
} VertexPositionColor;
/* Per-texture data */
typedef struct
{
ID3D11Texture2D *mainTexture;
ID3D11ShaderResourceView *mainTextureResourceView;
ID3D11RenderTargetView *mainTextureRenderTargetView;
ID3D11Texture2D *stagingTexture;
int lockedTexturePositionX;
int lockedTexturePositionY;
D3D11_FILTER scaleMode;
/* YV12 texture support */
SDL_bool yuv;
ID3D11Texture2D *mainTextureU;
ID3D11ShaderResourceView *mainTextureResourceViewU;
ID3D11Texture2D *mainTextureV;
ID3D11ShaderResourceView *mainTextureResourceViewV;
Nov 13, 2017
Nov 13, 2017
94
95
96
97
98
99
/* NV12 texture support */
SDL_bool nv12;
ID3D11Texture2D *mainTextureNV;
ID3D11ShaderResourceView *mainTextureResourceViewNV;
100
101
102
103
104
Uint8 *pixels;
int pitch;
SDL_Rect locked_rect;
} D3D11_TextureData;
Aug 14, 2017
Aug 14, 2017
105
106
107
108
109
110
111
/* Blend mode data */
typedef struct
{
SDL_BlendMode blendMode;
ID3D11BlendState *blendState;
} D3D11_BlendMode;
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* Private renderer data */
typedef struct
{
void *hDXGIMod;
void *hD3D11Mod;
IDXGIFactory2 *dxgiFactory;
IDXGIAdapter *dxgiAdapter;
ID3D11Device1 *d3dDevice;
ID3D11DeviceContext1 *d3dContext;
IDXGISwapChain1 *swapChain;
DXGI_SWAP_EFFECT swapEffect;
ID3D11RenderTargetView *mainRenderTargetView;
ID3D11RenderTargetView *currentOffscreenRenderTargetView;
ID3D11InputLayout *inputLayout;
Oct 3, 2018
Oct 3, 2018
126
127
ID3D11Buffer *vertexBuffers[8];
size_t vertexBufferSizes[8];
128
ID3D11VertexShader *vertexShader;
Nov 13, 2017
Nov 13, 2017
129
ID3D11PixelShader *pixelShaders[NUM_SHADERS];
Aug 14, 2017
Aug 14, 2017
130
131
int blendModesCount;
D3D11_BlendMode *blendModes;
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
ID3D11SamplerState *nearestPixelSampler;
ID3D11SamplerState *linearSampler;
D3D_FEATURE_LEVEL featureLevel;
/* Rasterizers */
ID3D11RasterizerState *mainRasterizer;
ID3D11RasterizerState *clippedRasterizer;
/* Vertex buffer constants */
VertexShaderConstants vertexShaderConstantsData;
ID3D11Buffer *vertexShaderConstants;
/* Cached renderer properties */
DXGI_MODE_ROTATION rotation;
ID3D11RenderTargetView *currentRenderTargetView;
ID3D11RasterizerState *currentRasterizerState;
ID3D11BlendState *currentBlendState;
ID3D11PixelShader *currentShader;
ID3D11ShaderResourceView *currentShaderResource;
ID3D11SamplerState *currentSampler;
Oct 3, 2018
Oct 3, 2018
152
153
154
155
156
157
SDL_bool cliprectDirty;
SDL_bool currentCliprectEnabled;
SDL_Rect currentCliprect;
SDL_Rect currentViewport;
int currentViewportRotation;
SDL_bool viewportDirty;
Oct 3, 2018
Oct 3, 2018
158
Float4X4 identity;
Oct 3, 2018
Oct 3, 2018
159
int currentVertexBuffer;
160
161
162
} D3D11_RenderData;
Oct 1, 2016
Oct 1, 2016
163
164
165
/* Define D3D GUIDs here so we don't have to include uuid.lib.
*
* Fix for SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3437:
Oct 1, 2016
Oct 1, 2016
166
* The extra 'SDL_' was added to the start of each IID's name, in order
Oct 1, 2016
Oct 1, 2016
167
168
169
170
171
* to prevent build errors on both MinGW-w64 and WinRT/UWP.
* (SDL bug https://bugzilla.libsdl.org/show_bug.cgi?id=3336 led to
* linker errors in WinRT/UWP builds.)
*/
Oct 1, 2016
Oct 1, 2016
172
173
174
175
176
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-const-variable"
#endif
Oct 1, 2016
Oct 1, 2016
177
178
179
180
181
182
183
static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
static const GUID SDL_IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } };
static const GUID SDL_IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } };
static const GUID SDL_IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } };
static const GUID SDL_IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } };
static const GUID SDL_IID_ID3D11Debug = { 0x79cf2233, 0x7536, 0x4948, { 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60 } };
Oct 1, 2016
Oct 1, 2016
185
186
187
188
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
Nov 26, 2015
Nov 26, 2015
191
Uint32
Nov 13, 2017
Nov 13, 2017
192
193
D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
{
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
switch (dxgiFormat) {
case DXGI_FORMAT_B8G8R8A8_UNORM:
return SDL_PIXELFORMAT_ARGB8888;
case DXGI_FORMAT_B8G8R8X8_UNORM:
return SDL_PIXELFORMAT_RGB888;
default:
return SDL_PIXELFORMAT_UNKNOWN;
}
}
static DXGI_FORMAT
SDLPixelFormatToDXGIFormat(Uint32 sdlFormat)
{
switch (sdlFormat) {
case SDL_PIXELFORMAT_ARGB8888:
return DXGI_FORMAT_B8G8R8A8_UNORM;
case SDL_PIXELFORMAT_RGB888:
return DXGI_FORMAT_B8G8R8X8_UNORM;
case SDL_PIXELFORMAT_YV12:
case SDL_PIXELFORMAT_IYUV:
Nov 13, 2017
Nov 13, 2017
214
215
case SDL_PIXELFORMAT_NV12: /* For the Y texture */
case SDL_PIXELFORMAT_NV21: /* For the Y texture */
216
217
218
219
220
221
return DXGI_FORMAT_R8_UNORM;
default:
return DXGI_FORMAT_UNKNOWN;
}
}
Oct 3, 2018
Oct 3, 2018
222
223
static void D3D11_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
224
225
226
227
228
229
230
231
232
233
234
235
236
static void
D3D11_ReleaseAll(SDL_Renderer * renderer)
{
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
SDL_Texture *texture = NULL;
/* Release all textures */
for (texture = renderer->textures; texture; texture = texture->next) {
D3D11_DestroyTexture(renderer, texture);
}
/* Release/reset everything else */
if (data) {
Aug 14, 2017
Aug 14, 2017
237
238
int i;
239
240
241
242
243
244
245
246
SAFE_RELEASE(data->dxgiFactory);
SAFE_RELEASE(data->dxgiAdapter);
SAFE_RELEASE(data->d3dDevice);
SAFE_RELEASE(data->d3dContext);
SAFE_RELEASE(data->swapChain);
SAFE_RELEASE(data->mainRenderTargetView);
SAFE_RELEASE(data->currentOffscreenRenderTargetView);
SAFE_RELEASE(data->inputLayout);
Oct 3, 2018
Oct 3, 2018
247
248
249
for (i = 0; i < SDL_arraysize(data->vertexBuffers); ++i) {
SAFE_RELEASE(data->vertexBuffers[i]);
}
250
SAFE_RELEASE(data->vertexShader);
Nov 13, 2017
Nov 13, 2017
251
252
253
for (i = 0; i < SDL_arraysize(data->pixelShaders); ++i) {
SAFE_RELEASE(data->pixelShaders[i]);
}
Aug 14, 2017
Aug 14, 2017
254
255
256
257
258
259
260
261
if (data->blendModesCount > 0) {
for (i = 0; i < data->blendModesCount; ++i) {
SAFE_RELEASE(data->blendModes[i].blendState);
}
SDL_free(data->blendModes);
data->blendModesCount = 0;
}
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
SAFE_RELEASE(data->nearestPixelSampler);
SAFE_RELEASE(data->linearSampler);
SAFE_RELEASE(data->mainRasterizer);
SAFE_RELEASE(data->clippedRasterizer);
SAFE_RELEASE(data->vertexShaderConstants);
data->swapEffect = (DXGI_SWAP_EFFECT) 0;
data->rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
data->currentRenderTargetView = NULL;
data->currentRasterizerState = NULL;
data->currentBlendState = NULL;
data->currentShader = NULL;
data->currentShaderResource = NULL;
data->currentSampler = NULL;
/* Unload the D3D libraries. This should be done last, in order
* to prevent IUnknown::Release() calls from crashing.
*/
if (data->hD3D11Mod) {
SDL_UnloadObject(data->hD3D11Mod);
data->hD3D11Mod = NULL;
}
if (data->hDXGIMod) {
SDL_UnloadObject(data->hDXGIMod);
data->hDXGIMod = NULL;
}
}
}
static void
D3D11_DestroyRenderer(SDL_Renderer * renderer)
{
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
D3D11_ReleaseAll(renderer);
if (data) {
SDL_free(data);
}
SDL_free(renderer);
}
Aug 14, 2017
Aug 14, 2017
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
static D3D11_BLEND GetBlendFunc(SDL_BlendFactor factor)
{
switch (factor) {
case SDL_BLENDFACTOR_ZERO:
return D3D11_BLEND_ZERO;
case SDL_BLENDFACTOR_ONE:
return D3D11_BLEND_ONE;
case SDL_BLENDFACTOR_SRC_COLOR:
return D3D11_BLEND_SRC_COLOR;
case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR:
return D3D11_BLEND_INV_SRC_COLOR;
case SDL_BLENDFACTOR_SRC_ALPHA:
return D3D11_BLEND_SRC_ALPHA;
case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA:
return D3D11_BLEND_INV_SRC_ALPHA;
case SDL_BLENDFACTOR_DST_COLOR:
return D3D11_BLEND_DEST_COLOR;
case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR:
return D3D11_BLEND_INV_DEST_COLOR;
case SDL_BLENDFACTOR_DST_ALPHA:
return D3D11_BLEND_DEST_ALPHA;
case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
return D3D11_BLEND_INV_DEST_ALPHA;
default:
return (D3D11_BLEND)0;
}
}
static D3D11_BLEND_OP GetBlendEquation(SDL_BlendOperation operation)
{
switch (operation) {
case SDL_BLENDOPERATION_ADD:
return D3D11_BLEND_OP_ADD;
case SDL_BLENDOPERATION_SUBTRACT:
return D3D11_BLEND_OP_SUBTRACT;
case SDL_BLENDOPERATION_REV_SUBTRACT:
return D3D11_BLEND_OP_REV_SUBTRACT;
case SDL_BLENDOPERATION_MINIMUM:
return D3D11_BLEND_OP_MIN;
case SDL_BLENDOPERATION_MAXIMUM:
return D3D11_BLEND_OP_MAX;
default:
return (D3D11_BLEND_OP)0;
}
}
Oct 3, 2018
Oct 3, 2018
348
static ID3D11BlendState *
Aug 14, 2017
Aug 14, 2017
349
D3D11_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode)
350
351
{
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
Aug 14, 2017
Aug 14, 2017
352
353
354
355
356
357
358
359
SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode);
SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode);
SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode);
ID3D11BlendState *blendState = NULL;
D3D11_BlendMode *blendModes;
360
361
362
363
364
365
HRESULT result = S_OK;
D3D11_BLEND_DESC blendDesc;
SDL_zero(blendDesc);
blendDesc.AlphaToCoverageEnable = FALSE;
blendDesc.IndependentBlendEnable = FALSE;
Aug 14, 2017
Aug 14, 2017
366
367
368
369
370
371
372
blendDesc.RenderTarget[0].BlendEnable = TRUE;
blendDesc.RenderTarget[0].SrcBlend = GetBlendFunc(srcColorFactor);
blendDesc.RenderTarget[0].DestBlend = GetBlendFunc(dstColorFactor);
blendDesc.RenderTarget[0].BlendOp = GetBlendEquation(colorOperation);
blendDesc.RenderTarget[0].SrcBlendAlpha = GetBlendFunc(srcAlphaFactor);
blendDesc.RenderTarget[0].DestBlendAlpha = GetBlendFunc(dstAlphaFactor);
blendDesc.RenderTarget[0].BlendOpAlpha = GetBlendEquation(alphaOperation);
373
blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
Aug 14, 2017
Aug 14, 2017
374
result = ID3D11Device_CreateBlendState(data->d3dDevice, &blendDesc, &blendState);
375
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
376
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBlendState"), result);
Oct 3, 2018
Oct 3, 2018
377
return NULL;
Aug 14, 2017
Aug 14, 2017
380
381
382
383
blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes));
if (!blendModes) {
SAFE_RELEASE(blendState);
SDL_OutOfMemory();
Oct 3, 2018
Oct 3, 2018
384
return NULL;
Aug 14, 2017
Aug 14, 2017
385
386
387
388
389
390
}
blendModes[data->blendModesCount].blendMode = blendMode;
blendModes[data->blendModesCount].blendState = blendState;
data->blendModes = blendModes;
++data->blendModesCount;
Oct 3, 2018
Oct 3, 2018
391
return blendState;
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
}
/* Create resources that depend on the device. */
static HRESULT
D3D11_CreateDeviceResources(SDL_Renderer * renderer)
{
typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory);
PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc;
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc;
ID3D11Device *d3dDevice = NULL;
ID3D11DeviceContext *d3dContext = NULL;
IDXGIDevice1 *dxgiDevice = NULL;
HRESULT result = S_OK;
UINT creationFlags;
Nov 13, 2017
Nov 13, 2017
407
int i;
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
/* This array defines the set of DirectX hardware feature levels this app will support.
* Note the ordering should be preserved.
* Don't forget to declare your application's minimum required feature level in its
* description. All applications are assumed to support 9.1 unless otherwise stated.
*/
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
};
D3D11_BUFFER_DESC constantBufferDesc;
D3D11_SAMPLER_DESC samplerDesc;
D3D11_RASTERIZER_DESC rasterDesc;
#ifdef __WINRT__
CreateDXGIFactoryFunc = CreateDXGIFactory1;
D3D11CreateDeviceFunc = D3D11CreateDevice;
#else
data->hDXGIMod = SDL_LoadObject("dxgi.dll");
if (!data->hDXGIMod) {
result = E_FAIL;
goto done;
}
Feb 12, 2018
Feb 12, 2018
439
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory");
440
441
442
443
444
445
446
447
448
449
450
if (!CreateDXGIFactoryFunc) {
result = E_FAIL;
goto done;
}
data->hD3D11Mod = SDL_LoadObject("d3d11.dll");
if (!data->hD3D11Mod) {
result = E_FAIL;
goto done;
}
Feb 12, 2018
Feb 12, 2018
451
D3D11CreateDeviceFunc = (PFN_D3D11_CREATE_DEVICE)SDL_LoadFunction(data->hD3D11Mod, "D3D11CreateDevice");
452
453
454
455
456
457
if (!D3D11CreateDeviceFunc) {
result = E_FAIL;
goto done;
}
#endif /* __WINRT__ */
Oct 1, 2016
Oct 1, 2016
458
result = CreateDXGIFactoryFunc(&SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory);
459
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
460
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("CreateDXGIFactory"), result);
461
462
463
464
465
466
goto done;
}
/* FIXME: Should we use the default adapter? */
result = IDXGIFactory2_EnumAdapters(data->dxgiFactory, 0, &data->dxgiAdapter);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
467
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result);
468
469
470
471
472
473
474
475
476
goto done;
}
/* This flag adds support for surfaces with a different color channel ordering
* than the API default. It is required for compatibility with Direct2D.
*/
creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
/* Make sure Direct3D's debugging feature gets used, if the app requests it. */
Oct 8, 2016
Oct 8, 2016
477
if (SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE)) {
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
}
/* Create the Direct3D 11 API device object and a corresponding context. */
result = D3D11CreateDeviceFunc(
data->dxgiAdapter,
D3D_DRIVER_TYPE_UNKNOWN,
NULL,
creationFlags, /* Set set debug and Direct2D compatibility flags. */
featureLevels, /* List of feature levels this app can support. */
SDL_arraysize(featureLevels),
D3D11_SDK_VERSION, /* Always set this to D3D11_SDK_VERSION for Windows Store apps. */
&d3dDevice, /* Returns the Direct3D device created. */
&data->featureLevel, /* Returns feature level of device created. */
&d3dContext /* Returns the device immediate context. */
);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
495
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result);
496
497
498
goto done;
}
Oct 1, 2016
Oct 1, 2016
499
result = ID3D11Device_QueryInterface(d3dDevice, &SDL_IID_ID3D11Device1, (void **)&data->d3dDevice);
500
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
501
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device to ID3D11Device1"), result);
502
503
504
goto done;
}
Oct 1, 2016
Oct 1, 2016
505
result = ID3D11DeviceContext_QueryInterface(d3dContext, &SDL_IID_ID3D11DeviceContext1, (void **)&data->d3dContext);
506
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
507
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext to ID3D11DeviceContext1"), result);
508
509
510
goto done;
}
Oct 1, 2016
Oct 1, 2016
511
result = ID3D11Device_QueryInterface(d3dDevice, &SDL_IID_IDXGIDevice1, (void **)&dxgiDevice);
512
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
513
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device to IDXGIDevice1"), result);
514
515
516
517
518
519
520
521
goto done;
}
/* Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
* ensures that the application will only render after each VSync, minimizing power consumption.
*/
result = IDXGIDevice1_SetMaximumFrameLatency(dxgiDevice, 1);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
522
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIDevice1::SetMaximumFrameLatency"), result);
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
goto done;
}
/* Make note of the maximum texture size
* Max texture sizes are documented on MSDN, at:
* http://msdn.microsoft.com/en-us/library/windows/apps/ff476876.aspx
*/
switch (data->featureLevel) {
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
renderer->info.max_texture_width = renderer->info.max_texture_height = 16384;
break;
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_10_0:
renderer->info.max_texture_width = renderer->info.max_texture_height = 8192;
break;
case D3D_FEATURE_LEVEL_9_3:
renderer->info.max_texture_width = renderer->info.max_texture_height = 4096;
break;
case D3D_FEATURE_LEVEL_9_2:
case D3D_FEATURE_LEVEL_9_1:
renderer->info.max_texture_width = renderer->info.max_texture_height = 2048;
break;
default:
Oct 1, 2016
Oct 1, 2016
551
SDL_SetError("%s, Unexpected feature level: %d", __FUNCTION__, data->featureLevel);
552
553
554
555
result = E_FAIL;
goto done;
}
Nov 13, 2017
Nov 13, 2017
556
if (D3D11_CreateVertexShader(data->d3dDevice, &data->vertexShader, &data->inputLayout) < 0) {
557
558
559
goto done;
}
Nov 13, 2017
Nov 13, 2017
560
561
562
563
for (i = 0; i < SDL_arraysize(data->pixelShaders); ++i) {
if (D3D11_CreatePixelShader(data->d3dDevice, (D3D11_Shader)i, &data->pixelShaders[i]) < 0) {
goto done;
}
564
565
566
567
568
569
570
571
572
573
574
575
576
}
/* Setup space to hold vertex shader constants: */
SDL_zero(constantBufferDesc);
constantBufferDesc.ByteWidth = sizeof(VertexShaderConstants);
constantBufferDesc.Usage = D3D11_USAGE_DEFAULT;
constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
result = ID3D11Device_CreateBuffer(data->d3dDevice,
&constantBufferDesc,
NULL,
&data->vertexShaderConstants
);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
577
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex shader constants]"), result);
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
goto done;
}
/* Create samplers to use when drawing textures: */
SDL_zero(samplerDesc);
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.MinLOD = 0.0f;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
result = ID3D11Device_CreateSamplerState(data->d3dDevice,
&samplerDesc,
&data->nearestPixelSampler
);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
597
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateSamplerState [nearest-pixel filter]"), result);
598
599
600
601
602
603
604
605
606
goto done;
}
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
result = ID3D11Device_CreateSamplerState(data->d3dDevice,
&samplerDesc,
&data->linearSampler
);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
607
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateSamplerState [linear filter]"), result);
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
goto done;
}
/* Setup Direct3D rasterizer states */
SDL_zero(rasterDesc);
rasterDesc.AntialiasedLineEnable = FALSE;
rasterDesc.CullMode = D3D11_CULL_NONE;
rasterDesc.DepthBias = 0;
rasterDesc.DepthBiasClamp = 0.0f;
rasterDesc.DepthClipEnable = TRUE;
rasterDesc.FillMode = D3D11_FILL_SOLID;
rasterDesc.FrontCounterClockwise = FALSE;
rasterDesc.MultisampleEnable = FALSE;
rasterDesc.ScissorEnable = FALSE;
rasterDesc.SlopeScaledDepthBias = 0.0f;
result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->mainRasterizer);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
625
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRasterizerState [main rasterizer]"), result);
626
627
628
629
630
631
goto done;
}
rasterDesc.ScissorEnable = TRUE;
result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->clippedRasterizer);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
632
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRasterizerState [clipped rasterizer]"), result);
633
634
635
636
goto done;
}
/* Create blending states: */
Aug 14, 2017
Aug 14, 2017
637
638
639
if (!D3D11_CreateBlendState(renderer, SDL_BLENDMODE_BLEND) ||
!D3D11_CreateBlendState(renderer, SDL_BLENDMODE_ADD) ||
!D3D11_CreateBlendState(renderer, SDL_BLENDMODE_MOD)) {
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
/* D3D11_CreateBlendMode will set the SDL error, if it fails */
goto done;
}
/* Setup render state that doesn't change */
ID3D11DeviceContext_IASetInputLayout(data->d3dContext, data->inputLayout);
ID3D11DeviceContext_VSSetShader(data->d3dContext, data->vertexShader, NULL, 0);
ID3D11DeviceContext_VSSetConstantBuffers(data->d3dContext, 0, 1, &data->vertexShaderConstants);
done:
SAFE_RELEASE(d3dDevice);
SAFE_RELEASE(d3dContext);
SAFE_RELEASE(dxgiDevice);
return result;
}
#ifdef __WIN32__
static DXGI_MODE_ROTATION
D3D11_GetCurrentRotation()
{
/* FIXME */
return DXGI_MODE_ROTATION_IDENTITY;
}
#endif /* __WIN32__ */
static BOOL
D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation)
{
switch (rotation) {
case DXGI_MODE_ROTATION_ROTATE90:
case DXGI_MODE_ROTATION_ROTATE270:
return TRUE;
default:
return FALSE;
}
}
static int
D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer)
{
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
if (data->currentOffscreenRenderTargetView) {
return DXGI_MODE_ROTATION_IDENTITY;
} else {
return data->rotation;
}
}
static int
D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect, BOOL includeViewportOffset)
{
const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
switch (rotation) {
case DXGI_MODE_ROTATION_IDENTITY:
outRect->left = sdlRect->x;
outRect->right = sdlRect->x + sdlRect->w;
outRect->top = sdlRect->y;
outRect->bottom = sdlRect->y + sdlRect->h;
if (includeViewportOffset) {
outRect->left += renderer->viewport.x;
outRect->right += renderer->viewport.x;
outRect->top += renderer->viewport.y;
outRect->bottom += renderer->viewport.y;
}
break;
case DXGI_MODE_ROTATION_ROTATE270:
outRect->left = sdlRect->y;
outRect->right = sdlRect->y + sdlRect->h;
outRect->top = renderer->viewport.w - sdlRect->x - sdlRect->w;
outRect->bottom = renderer->viewport.w - sdlRect->x;
break;
case DXGI_MODE_ROTATION_ROTATE180:
outRect->left = renderer->viewport.w - sdlRect->x - sdlRect->w;
outRect->right = renderer->viewport.w - sdlRect->x;
outRect->top = renderer->viewport.h - sdlRect->y - sdlRect->h;
outRect->bottom = renderer->viewport.h - sdlRect->y;
break;
case DXGI_MODE_ROTATION_ROTATE90:
outRect->left = renderer->viewport.h - sdlRect->y - sdlRect->h;
outRect->right = renderer->viewport.h - sdlRect->y;
outRect->top = sdlRect->x;
outRect->bottom = sdlRect->x + sdlRect->h;
break;
default:
return SDL_SetError("The physical display is in an unknown or unsupported rotation");
}
return 0;
}
static HRESULT
D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
{
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
#ifdef __WINRT__
IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer);
const BOOL usingXAML = (coreWindow == NULL);
#else
IUnknown *coreWindow = NULL;
const BOOL usingXAML = FALSE;
#endif
HRESULT result = S_OK;
/* Create a swap chain using the same adapter as the existing Direct3D device. */
DXGI_SWAP_CHAIN_DESC1 swapChainDesc;
SDL_zero(swapChainDesc);
swapChainDesc.Width = w;
swapChainDesc.Height = h;
swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; /* This is the most common swap chain format. */
swapChainDesc.Stereo = FALSE;
swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */
/* TODO, WinRT: see if Win 8.x DXGI_SWAP_CHAIN_DESC1 settings are available on Windows Phone 8.1, and if there's any advantage to having them on */
#else
if (usingXAML) {
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
} else {
swapChainDesc.Scaling = DXGI_SCALING_NONE;
}
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; /* All Windows Store apps must use this SwapEffect. */
#endif
swapChainDesc.Flags = 0;
if (coreWindow) {
result = IDXGIFactory2_CreateSwapChainForCoreWindow(data->dxgiFactory,
(IUnknown *)data->d3dDevice,
coreWindow,
&swapChainDesc,
NULL, /* Allow on all displays. */
&data->swapChain
);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
778
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForCoreWindow"), result);
779
780
781
782
783
784
785
786
787
goto done;
}
} else if (usingXAML) {
result = IDXGIFactory2_CreateSwapChainForComposition(data->dxgiFactory,
(IUnknown *)data->d3dDevice,
&swapChainDesc,
NULL,
&data->swapChain);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
788
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForComposition"), result);
789
790
791
792
793
794
goto done;
}
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
result = ISwapChainBackgroundPanelNative_SetSwapChain(WINRT_GlobalSwapChainBackgroundPanelNative, (IDXGISwapChain *) data->swapChain);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
795
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ISwapChainBackgroundPanelNative::SetSwapChain"), result);
796
797
798
goto done;
}
#else
Oct 1, 2016
Oct 1, 2016
799
SDL_SetError(SDL_COMPOSE_ERROR("XAML support is not yet available for Windows Phone"));
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
result = E_FAIL;
goto done;
#endif
} else {
#ifdef __WIN32__
SDL_SysWMinfo windowinfo;
SDL_VERSION(&windowinfo.version);
SDL_GetWindowWMInfo(renderer->window, &windowinfo);
result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
(IUnknown *)data->d3dDevice,
windowinfo.info.win.window,
&swapChainDesc,
NULL,
NULL, /* Allow on all displays. */
&data->swapChain
);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
818
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForHwnd"), result);
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
goto done;
}
IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES);
#else
SDL_SetError(__FUNCTION__", Unable to find something to attach a swap chain to");
goto done;
#endif /* ifdef __WIN32__ / else */
}
data->swapEffect = swapChainDesc.SwapEffect;
done:
SAFE_RELEASE(coreWindow);
return result;
}
Oct 3, 2018
Oct 3, 2018
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
static void
D3D11_ReleaseMainRenderTargetView(SDL_Renderer * renderer)
{
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
ID3D11DeviceContext_OMSetRenderTargets(data->d3dContext, 0, NULL, NULL);
SAFE_RELEASE(data->mainRenderTargetView);
}
static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer);
HRESULT
D3D11_HandleDeviceLost(SDL_Renderer * renderer)
{
HRESULT result = S_OK;
D3D11_ReleaseAll(renderer);
result = D3D11_CreateDeviceResources(renderer);
if (FAILED(result)) {
/* D3D11_CreateDeviceResources will set the SDL error */
return result;
}
result = D3D11_UpdateForWindowSizeChange(renderer);
if (FAILED(result)) {
/* D3D11_UpdateForWindowSizeChange will set the SDL error */
return result;
}
/* Let the application know that the device has been reset */
{
SDL_Event event;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
}
return S_OK;
}
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
/* Initialize all resources that change when the window's size changes. */
static HRESULT
D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
{
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
ID3D11Texture2D *backBuffer = NULL;
HRESULT result = S_OK;
int w, h;
/* Release the previous render target view */
D3D11_ReleaseMainRenderTargetView(renderer);
/* The width and height of the swap chain must be based on the display's
* non-rotated size.
*/
SDL_GetWindowSize(renderer->window, &w, &h);
data->rotation = D3D11_GetCurrentRotation();
/* SDL_Log("%s: windowSize={%d,%d}, orientation=%d\n", __FUNCTION__, w, h, (int)data->rotation); */
if (D3D11_IsDisplayRotated90Degrees(data->rotation)) {
int tmp = w;
w = h;
h = tmp;
}
if (data->swapChain) {
/* IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. */
#if !defined(__WINRT__) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP)
/* If the swap chain already exists, resize it. */
result = IDXGISwapChain_ResizeBuffers(data->swapChain,
0,
w, h,
DXGI_FORMAT_UNKNOWN,
0
);
if (result == DXGI_ERROR_DEVICE_REMOVED) {
/* If the device was removed for any reason, a new device and swap chain will need to be created. */
D3D11_HandleDeviceLost(renderer);
/* Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method
* and correctly set up the new device.
*/
goto done;
} else if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
918
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::ResizeBuffers"), result);
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
goto done;
}
#endif
} else {
result = D3D11_CreateSwapChain(renderer, w, h);
if (FAILED(result)) {
goto done;
}
}
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
/* Set the proper rotation for the swap chain.
*
* To note, the call for this, IDXGISwapChain1::SetRotation, is not necessary
* on Windows Phone 8.0, nor is it supported there.
*
* IDXGISwapChain1::SetRotation does seem to be available on Windows Phone 8.1,
* however I've yet to find a way to make it work. It might have something to
* do with IDXGISwapChain::ResizeBuffers appearing to not being available on
* Windows Phone 8.1 (it wasn't on Windows Phone 8.0), but I'm not 100% sure of this.
* The call doesn't appear to be entirely necessary though, and is a performance-related
* call, at least according to the following page on MSDN:
* http://code.msdn.microsoft.com/windowsapps/DXGI-swap-chain-rotation-21d13d71
* -- David L.
*
* TODO, WinRT: reexamine the docs for IDXGISwapChain1::SetRotation, see if might be available, usable, and prudent-to-call on WinPhone 8.1
*/
if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) {
result = IDXGISwapChain1_SetRotation(data->swapChain, data->rotation);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
949
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain1::SetRotation"), result);
950
951
952
953
954
955
956
goto done;
}
}
#endif
result = IDXGISwapChain_GetBuffer(data->swapChain,
0,
Oct 1, 2016
Oct 1, 2016
957
&SDL_IID_ID3D11Texture2D,
Oct 1, 2016
Oct 1, 2016
958
(void **)&backBuffer
959
960
);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
961
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::GetBuffer [back-buffer]"), result);
962
963
964
965
966
967
968
969
970
971
goto done;
}
/* Create a render target view of the swap chain back buffer. */
result = ID3D11Device_CreateRenderTargetView(data->d3dDevice,
(ID3D11Resource *)backBuffer,
NULL,
&data->mainRenderTargetView
);
if (FAILED(result)) {
Oct 1, 2016
Oct 1, 2016
972
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device::CreateRenderTargetView"), result);
973
974
975
goto done;
}
Oct 3, 2018
Oct 3, 2018
976
data->viewportDirty = SDL_TRUE;
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
done:
SAFE_RELEASE(backBuffer);
return result;
}
/* This method is called when the window's size changes. */
static HRESULT
D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer)
{
return D3D11_CreateWindowSizeDependentResources(renderer);
}
void
D3D11_Trim(SDL_Renderer * renderer)
{
#ifdef __WINRT__
#if NTDDI_VERSION > NTDDI_WIN8
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
HRESULT result = S_OK;
IDXGIDevice3 *dxgiDevice = NULL;
Oct 1, 2016
Oct 1, 2016
999
result = ID3D11Device_QueryInterface(data->d3dDevice, &SDL_IID_IDXGIDevice3, &dxgiDevice);
1000
if (FAILED(result)) {