Fixed creating the rendering context on a specific device
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
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index d3c37cf..6871f19 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -44,7 +44,7 @@ using namespace Windows::Graphics::Display;
#include <d3d11_1.h>
-#define SAFE_RELEASE(X) if ( (X) ) { IUnknown_Release( SDL_static_cast(IUnknown*, X ) ); X = NULL; }
+#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; }
typedef struct
{
@@ -120,7 +120,10 @@ typedef struct
/* Private renderer data */
typedef struct
{
+ void *hDXGIMod;
void *hD3D11Mod;
+ IDXGIFactory2 *dxgiFactory;
+ IDXGIAdapter *dxgiAdapter;
ID3D11Device1 *d3dDevice;
ID3D11DeviceContext1 *d3dContext;
IDXGISwapChain1 *swapChain;
@@ -383,159 +386,159 @@ static const DWORD D3D11_PixelShader_Textures[] = {
float4 color : COLOR0;
};
- float4 main(PixelShaderInput input) : SV_TARGET
- {
- const float3 offset = {-0.0625, -0.5, -0.5};
- const float3 Rcoeff = {1.164, 0.000, 1.596};
- const float3 Gcoeff = {1.164, -0.391, -0.813};
- const float3 Bcoeff = {1.164, 2.018, 0.000};
-
- float4 Output;
-
- float3 yuv;
- yuv.x = theTextureY.Sample(theSampler, input.tex).r;
- yuv.y = theTextureU.Sample(theSampler, input.tex).r;
- yuv.z = theTextureV.Sample(theSampler, input.tex).r;
-
- yuv += offset;
- Output.r = dot(yuv, Rcoeff);
- Output.g = dot(yuv, Gcoeff);
- Output.b = dot(yuv, Bcoeff);
- Output.a = 1.0f;
-
- return Output * input.color;
- }
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {-0.0625, -0.5, -0.5};
+ const float3 Rcoeff = {1.164, 0.000, 1.596};
+ const float3 Gcoeff = {1.164, -0.391, -0.813};
+ const float3 Bcoeff = {1.164, 2.018, 0.000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.y = theTextureU.Sample(theSampler, input.tex).r;
+ yuv.z = theTextureV.Sample(theSampler, input.tex).r;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
*/
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_PixelShader_YUV[] = {
- 0x43425844, 0x04e69cba, 0x74ce6dd2, 0x7fcf84cb, 0x3003d677, 0x00000001,
- 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
- 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
- 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
- 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
- 0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000, 0x3f800000, 0x05000051,
- 0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051,
- 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x05000051,
- 0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x0200001f,
- 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
- 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
- 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800,
- 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002,
- 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001,
- 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000,
- 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001,
- 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000,
- 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
- 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
- 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853,
- 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000,
- 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
- 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555,
- 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
- 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
- 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
- 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
- 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
- 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2,
- 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
- 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
- 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
- 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000, 0x0a00000f, 0x00100012,
- 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f94fdf4, 0x3fcc49ba,
- 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
- 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000,
- 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002,
- 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x05000036, 0x00100082,
- 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000,
- 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453,
- 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005,
- 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c,
- 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7,
- 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001,
- 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
- 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005,
- 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874,
- 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568,
- 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369,
- 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320,
- 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00,
- 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
- 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
- 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
- 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
- 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
- 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
+ 0x43425844, 0x04e69cba, 0x74ce6dd2, 0x7fcf84cb, 0x3003d677, 0x00000001,
+ 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
+ 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
+ 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
+ 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
+ 0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000, 0x3f800000, 0x05000051,
+ 0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051,
+ 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x05000051,
+ 0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x0200001f,
+ 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
+ 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
+ 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800,
+ 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002,
+ 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001,
+ 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000,
+ 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001,
+ 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000,
+ 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
+ 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
+ 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853,
+ 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000,
+ 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
+ 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555,
+ 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
+ 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
+ 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
+ 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
+ 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2,
+ 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
+ 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
+ 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
+ 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000, 0x0a00000f, 0x00100012,
+ 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f94fdf4, 0x3fcc49ba,
+ 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
+ 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000,
+ 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002,
+ 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x05000036, 0x00100082,
+ 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000,
+ 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453,
+ 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005,
+ 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c,
+ 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001,
+ 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
+ 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874,
+ 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568,
+ 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369,
+ 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320,
+ 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00,
+ 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
+ 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
+ 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
};
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_PixelShader_YUV[] = {
- 0x43425844, 0xe6d969fc, 0x63cac33c, 0xa4926502, 0x5d788135, 0x00000001,
- 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
- 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
- 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
- 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
- 0xa00f0000, 0xbd800000, 0xbf000000, 0x3f800000, 0x00000000, 0x05000051,
- 0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x400126e9, 0x05000051,
- 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x0200001f,
- 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
- 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
- 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801,
- 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001,
- 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001,
- 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000,
- 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008,
- 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000,
- 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005,
- 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000,
- 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a,
- 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
- 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000,
- 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062,
- 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
- 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
- 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2,
- 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000,
- 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001,
- 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
- 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
- 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
- 0x00000000, 0x00004002, 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000,
- 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
- 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
- 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127,
- 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046,
- 0x00000000, 0x00004002, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000,
- 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038,
- 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002,
- 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000,
- 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000,
- 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c,
- 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
- 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
- 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005,
- 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf,
- 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001,
- 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
- 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478,
- 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
- 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030,
- 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
- 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
- 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
- 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
- 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
- 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
- 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
+ 0x43425844, 0xe6d969fc, 0x63cac33c, 0xa4926502, 0x5d788135, 0x00000001,
+ 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
+ 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
+ 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
+ 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
+ 0xa00f0000, 0xbd800000, 0xbf000000, 0x3f800000, 0x00000000, 0x05000051,
+ 0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x400126e9, 0x05000051,
+ 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x0200001f,
+ 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
+ 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
+ 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801,
+ 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001,
+ 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001,
+ 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000,
+ 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008,
+ 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000,
+ 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005,
+ 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000,
+ 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a,
+ 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
+ 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000,
+ 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062,
+ 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
+ 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2,
+ 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000,
+ 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001,
+ 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
+ 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
+ 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
+ 0x00000000, 0x00004002, 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000,
+ 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
+ 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
+ 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127,
+ 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046,
+ 0x00000000, 0x00004002, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000,
+ 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038,
+ 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002,
+ 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000,
+ 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000,
+ 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c,
+ 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
+ 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001,
+ 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
+ 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478,
+ 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
+ 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030,
+ 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
+ 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
+ 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
+ 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
+ 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
+ 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
0x45475241, 0xabab0054
};
#else
@@ -985,6 +988,8 @@ D3D11_DestroyRenderer(SDL_Renderer * renderer)
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
if (data) {
+ SAFE_RELEASE(data->dxgiFactory);
+ SAFE_RELEASE(data->dxgiAdapter);
SAFE_RELEASE(data->d3dDevice);
SAFE_RELEASE(data->d3dContext);
SAFE_RELEASE(data->swapChain);
@@ -1008,6 +1013,9 @@ D3D11_DestroyRenderer(SDL_Renderer * renderer)
if (data->hD3D11Mod) {
SDL_UnloadObject(data->hD3D11Mod);
}
+ if (data->hDXGIMod) {
+ SDL_UnloadObject(data->hDXGIMod);
+ }
SDL_free(data);
}
SDL_free(renderer);
@@ -1049,16 +1057,33 @@ D3D11_CreateBlendMode(SDL_Renderer * renderer,
/* 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;
+ IDXGIAdapter *d3dAdapter = NULL;
ID3D11Device *d3dDevice = NULL;
ID3D11DeviceContext *d3dContext = NULL;
+ IDXGIDevice1 *dxgiDevice = NULL;
HRESULT result = S_OK;
#ifdef __WINRT__
+ CreateDXGIFactoryFunc = CreateDXGIFactory;
D3D11CreateDeviceFunc = D3D11CreateDevice;
-#else
+#else
+ data->hDXGIMod = SDL_LoadObject("dxgi.dll");
+ if (!data->hDXGIMod) {
+ result = E_FAIL;
+ goto done;
+ }
+
+ CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory");
+ if (!CreateDXGIFactoryFunc) {
+ result = E_FAIL;
+ goto done;
+ }
+
data->hD3D11Mod = SDL_LoadObject("d3d11.dll");
if (!data->hD3D11Mod) {
result = E_FAIL;
@@ -1070,7 +1095,20 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
result = E_FAIL;
goto done;
}
-#endif /* __WINRT__ */
+#endif /* __WINRT__ */
+
+ result = CreateDXGIFactoryFunc(&IID_IDXGIFactory2, &data->dxgiFactory);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory", result);
+ goto done;
+ }
+
+ /* FIXME: Should we use the default adapter? */
+ result = IDXGIFactory2_EnumAdapters(data->dxgiFactory, 0, &data->dxgiAdapter);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", D3D11CreateDevice", result);
+ 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.
@@ -1101,8 +1139,8 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
/* Create the Direct3D 11 API device object and a corresponding context. */
result = D3D11CreateDeviceFunc(
- NULL, /* Specify NULL to use the default adapter */
- D3D_DRIVER_TYPE_HARDWARE,
+ data->dxgiAdapter,
+ D3D_DRIVER_TYPE_UNKNOWN,
NULL,
creationFlags, /* Set set debug and Direct2D compatibility flags. */
featureLevels, /* List of feature levels this app can support. */
@@ -1129,6 +1167,21 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
goto done;
}
+ result = ID3D11Device_QueryInterface(d3dDevice, &IID_IDXGIDevice1, &dxgiDevice);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice1", result);
+ 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)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIDevice1::SetMaximumFrameLatency", result);
+ 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
@@ -1232,10 +1285,10 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
constantBufferDesc.Usage = D3D11_USAGE_DEFAULT;
constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
result = ID3D11Device_CreateBuffer(data->d3dDevice,
- &constantBufferDesc,
- NULL,
+ &constantBufferDesc,
+ NULL,
&data->vertexShaderConstants
- );
+ );
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBuffer [vertex shader constants]", result);
goto done;
@@ -1275,25 +1328,25 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
/* Setup Direct3D rasterizer states */
D3D11_RASTERIZER_DESC rasterDesc;
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.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;
+ rasterDesc.SlopeScaledDepthBias = 0.0f;
result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->mainRasterizer);
- if (FAILED(result)) {
+ if (FAILED(result)) {
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRasterizerState [main rasterizer]", result);
goto done;
}
rasterDesc.ScissorEnable = TRUE;
result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->clippedRasterizer);
- if (FAILED(result)) {
+ if (FAILED(result)) {
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRasterizerState [clipped rasterizer]", result);
goto done;
}
@@ -1346,6 +1399,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
done:
SAFE_RELEASE(d3dDevice);
SAFE_RELEASE(d3dContext);
+ SAFE_RELEASE(dxgiDevice);
return result;
}
@@ -1360,13 +1414,13 @@ static IUnknown *
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
{
SDL_Window * sdlWindow = renderer->window;
- if ( ! renderer->window ) {
+ if (!renderer->window) {
return NULL;
}
SDL_SysWMinfo sdlWindowInfo;
SDL_VERSION(&sdlWindowInfo.version);
- if ( ! SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo) ) {
+ if (!SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo)) {
return NULL;
}
@@ -1490,9 +1544,6 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
IUnknown *coreWindow = NULL;
const BOOL usingXAML = FALSE;
#endif
- IDXGIDevice1 *dxgiDevice = NULL;
- IDXGIAdapter *dxgiAdapter = NULL;
- IDXGIFactory2 *dxgiFactory = NULL;
HRESULT result = S_OK;
/* Create a swap chain using the same adapter as the existing Direct3D device. */
@@ -1519,26 +1570,8 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
#endif
swapChainDesc.Flags = 0;
- result = ID3D11Device_QueryInterface(data->d3dDevice, &IID_IDXGIDevice1, &dxgiDevice);
- if (FAILED(result)) {
- WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice1", result);
- goto done;
- }
-
- result = IDXGIDevice1_GetAdapter(dxgiDevice, &dxgiAdapter);
- if (FAILED(result)) {
- WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIDevice1::GetAdapter", result);
- goto done;
- }
-
- result = IDXGIAdapter_GetParent(dxgiAdapter, &IID_IDXGIFactory2, &dxgiFactory);
- if (FAILED(result)) {
- WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIAdapter::GetParent", result);
- goto done;
- }
-
if (coreWindow) {
- result = IDXGIFactory2_CreateSwapChainForCoreWindow(dxgiFactory,
+ result = IDXGIFactory2_CreateSwapChainForCoreWindow(data->dxgiFactory,
(IUnknown *)data->d3dDevice,
coreWindow,
&swapChainDesc,
@@ -1550,7 +1583,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
goto done;
}
} else if (usingXAML) {
- result = IDXGIFactory2_CreateSwapChainForComposition(dxgiFactory,
+ result = IDXGIFactory2_CreateSwapChainForComposition(data->dxgiFactory,
(IUnknown *)data->d3dDevice,
&swapChainDesc,
NULL,
@@ -1564,7 +1597,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
result = WINRT_GlobalSwapChainBackgroundPanelNative->SetSwapChain(data->swapChain);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ISwapChainBackgroundPanelNative::SetSwapChain", result);
- return result;
+ goto done;
}
#else
SDL_SetError(__FUNCTION__ ", XAML support is not yet available for Windows Phone");
@@ -1576,7 +1609,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
SDL_VERSION(&windowinfo.version);
SDL_GetWindowWMInfo(renderer->window, &windowinfo);
- result = IDXGIFactory2_CreateSwapChainForHwnd(dxgiFactory,
+ result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
(IUnknown *)data->d3dDevice,
windowinfo.info.win.window,
&swapChainDesc,
@@ -1591,20 +1624,8 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
}
data->swapEffect = swapChainDesc.SwapEffect;
- /* 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)) {
- WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIDevice1::SetMaximumFrameLatency", result);
- goto done;
- }
-
done:
SAFE_RELEASE(coreWindow);
- SAFE_RELEASE(dxgiDevice);
- SAFE_RELEASE(dxgiAdapter);
- SAFE_RELEASE(dxgiFactory);
return result;
}