Fixed building D3D12 renderer with latest mingw-64
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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c
index 707b8a0..ac191f1 100644
--- a/src/render/direct3d12/SDL_render_d3d12.c
+++ b/src/render/direct3d12/SDL_render_d3d12.c
@@ -31,7 +31,6 @@
#define SDL_D3D12_MAX_NUM_TEXTURES 16384
#define SDL_D3D12_NUM_UPLOAD_BUFFERS 32
-#define COBJMACROS
#include "../../core/windows/SDL_windows.h"
#include "../../video/windows/SDL_windowswindow.h"
#include "SDL_hints.h"
@@ -53,7 +52,7 @@
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
#endif
-#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; }
+#define SAFE_RELEASE(X) if (X) { (X)->lpVtbl->Release(X); X = NULL; }
/* !!! FIXME: vertex buffer bandwidth could be lower; only use UV coords when
@@ -142,9 +141,9 @@ typedef struct
void *hD3D12Mod;
IDXGIFactory6 *dxgiFactory;
IDXGIAdapter4 *dxgiAdapter;
- ID3D12Device5 *d3dDevice;
+ ID3D12Device1 *d3dDevice;
ID3D12Debug *debugInterface;
- IDXGIDebug1 *dxgiDebug;
+ IDXGIDebug *dxgiDebug;
ID3D12CommandQueue *commandQueue;
ID3D12GraphicsCommandList2 *commandList;
IDXGISwapChain4 *swapChain;
@@ -336,7 +335,7 @@ D3D12_ReleaseAll(SDL_Renderer * renderer)
/* Check for any leaks if in debug mode */
if (data->dxgiDebug) {
- IDXGIDebug1_ReportLiveObjects(data->dxgiDebug, SDL_DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_SUMMARY | DXGI_DEBUG_RLO_IGNORE_INTERNAL);
+ data->dxgiDebug->lpVtbl->ReportLiveObjects(data->dxgiDebug, SDL_DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_SUMMARY | DXGI_DEBUG_RLO_IGNORE_INTERNAL);
SAFE_RELEASE(data->dxgiDebug);
}
@@ -362,10 +361,10 @@ D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap * heap, D3D12_CPU_DESCRIPTOR_HANDLE CP
SIZE_T offset;
/* Calculate the correct offset into the heap */
- ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap, &CPUHeapStart);
+ heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(heap, &CPUHeapStart);
offset = CPUHandle.ptr - CPUHeapStart.ptr;
- ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(heap, &GPUHandle);
+ heap->lpVtbl->GetGPUDescriptorHandleForHeapStart(heap, &GPUHandle);
GPUHandle.ptr += offset;
return GPUHandle;
@@ -374,13 +373,11 @@ D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap * heap, D3D12_CPU_DESCRIPTOR_HANDLE CP
static void
D3D12_WaitForGPU(D3D12_RenderData * data)
{
- HRESULT result;
-
if (data->commandQueue && data->fence && data->fenceEvent)
{
- result = ID3D12CommandQueue_Signal(data->commandQueue, data->fence, data->fenceValue);
- if (ID3D12Fence_GetCompletedValue(data->fence) < data->fenceValue) {
- result = ID3D12Fence_SetEventOnCompletion(
+ data->commandQueue->lpVtbl->Signal(data->commandQueue, data->fence, data->fenceValue);
+ if (data->fence->lpVtbl->GetCompletedValue(data->fence) < data->fenceValue) {
+ data->fence->lpVtbl->SetEventOnCompletion(
data->fence,
data->fenceValue,
data->fenceEvent
@@ -403,7 +400,7 @@ D3D12_GetCurrentRenderTargetView(SDL_Renderer * renderer)
}
SDL_zero(rtvDescriptor);
- ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor);
+ data->rtvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor);
rtvDescriptor.ptr += data->currentBackBufferIndex * data->rtvDescriptorSize;
return rtvDescriptor;
}
@@ -425,7 +422,7 @@ D3D12_TransitionResource(D3D12_RenderData * data,
barrier.Transition.StateAfter = afterState;
barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
- ID3D12GraphicsCommandList2_ResourceBarrier(data->commandList, 1, &barrier);
+ data->commandList->lpVtbl->ResourceBarrier(data->commandList, 1, &barrier);
}
}
@@ -434,9 +431,10 @@ D3D12_ResetCommandList(D3D12_RenderData * data)
{
int i;
ID3D12DescriptorHeap *rootDescriptorHeaps[] = { data->srvDescriptorHeap, data->samplerDescriptorHeap };
+ ID3D12CommandAllocator *commandAllocator = data->commandAllocators[data->currentBackBufferIndex];
- ID3D12CommandAllocator_Reset(data->commandAllocators[data->currentBackBufferIndex]);
- ID3D12GraphicsCommandList2_Reset(data->commandList, data->commandAllocators[data->currentBackBufferIndex], NULL);
+ commandAllocator->lpVtbl->Reset(commandAllocator);
+ data->commandList->lpVtbl->Reset(data->commandList, commandAllocator, NULL);
data->currentPipelineState = NULL;
data->currentVertexBuffer = 0;
data->issueBatch = SDL_FALSE;
@@ -450,7 +448,7 @@ D3D12_ResetCommandList(D3D12_RenderData * data)
}
data->currentUploadBuffer = 0;
- ID3D12GraphicsCommandList2_SetDescriptorHeaps(data->commandList, 2, rootDescriptorHeaps);
+ data->commandList->lpVtbl->SetDescriptorHeaps(data->commandList, 2, rootDescriptorHeaps);
}
static int
@@ -459,12 +457,12 @@ D3D12_IssueBatch(D3D12_RenderData * data)
HRESULT result = S_OK;
/* Issue the command list */
- result = ID3D12GraphicsCommandList2_Close(data->commandList);
+ result = data->commandList->lpVtbl->Close(data->commandList);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12_IssueBatch"), result);
return result;
}
- ID3D12CommandQueue_ExecuteCommandLists(data->commandQueue, 1, (ID3D12CommandList* const*)&data->commandList);
+ data->commandQueue->lpVtbl->ExecuteCommandLists(data->commandQueue, 1, (ID3D12CommandList* const*)&data->commandList);
D3D12_WaitForGPU(data);
@@ -543,7 +541,6 @@ GetBlendEquation(SDL_BlendOperation operation)
static void
D3D12_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode, D3D12_BLEND_DESC * outBlendDesc)
{
- D3D12_RenderData *data = (D3D12_RenderData *) renderer->driverdata;
SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
@@ -551,7 +548,7 @@ D3D12_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode, D3D12_B
SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode);
SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode);
- SDL_zero(*outBlendDesc);
+ SDL_zerop(outBlendDesc);
outBlendDesc->AlphaToCoverageEnable = FALSE;
outBlendDesc->IndependentBlendEnable = FALSE;
outBlendDesc->RenderTarget[0].BlendEnable = TRUE;
@@ -610,11 +607,11 @@ D3D12_CreatePipelineState(SDL_Renderer * renderer,
pipelineDesc.SampleDesc.Count = 1;
pipelineDesc.SampleDesc.Quality = 0;
- result = ID3D12Device_CreateGraphicsPipelineState(
+ result = data->d3dDevice->lpVtbl->CreateGraphicsPipelineState(
data->d3dDevice,
&pipelineDesc,
&SDL_IID_ID3D12PipelineState,
- &pipelineState
+ (void **)&pipelineState
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateGraphicsPipelineState"), result);
@@ -701,9 +698,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE);
if (createDebug) {
- IDXGIInfoQueue* dxgiInfoQueue = NULL;
PFN_D3D12_GET_DEBUG_INTERFACE D3D12GetDebugInterfaceFunc;
- PFN_CREATE_DXGI_FACTORY DXGIGetDebugInterfaceFunc;
D3D12GetDebugInterfaceFunc = (PFN_D3D12_GET_DEBUG_INTERFACE)SDL_LoadFunction(data->hD3D12Mod, "D3D12GetDebugInterface");
if (!D3D12GetDebugInterfaceFunc) {
@@ -711,7 +706,13 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
goto done;
}
D3D12GetDebugInterfaceFunc(&SDL_IID_ID3D12Debug, (void**)&data->debugInterface);
- ID3D12Debug_EnableDebugLayer(data->debugInterface);
+ data->debugInterface->lpVtbl->EnableDebugLayer(data->debugInterface);
+ }
+
+ if (createDebug) {
+#ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__
+ IDXGIInfoQueue *dxgiInfoQueue = NULL;
+ PFN_CREATE_DXGI_FACTORY DXGIGetDebugInterfaceFunc;
/* If the debug hint is set, also create the DXGI factory in debug mode */
DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1");
@@ -732,10 +733,11 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
goto done;
}
- IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, TRUE);
- IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, TRUE);
- creationFlags = DXGI_CREATE_FACTORY_DEBUG;
+ dxgiInfoQueue->lpVtbl->SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, TRUE);
+ dxgiInfoQueue->lpVtbl->SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, TRUE);
SAFE_RELEASE(dxgiInfoQueue);
+#endif /* __IDXGIInfoQueue_INTERFACE_DEFINED__ */
+ creationFlags = DXGI_CREATE_FACTORY_DEBUG;
}
result = CreateDXGIFactoryFunc(creationFlags, &SDL_IID_IDXGIFactory6, (void**)&data->dxgiFactory);
@@ -745,11 +747,11 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
}
/* Prefer a high performance adapter if there are multiple choices */
- result = IDXGIFactory6_EnumAdapterByGpuPreference(data->dxgiFactory,
+ result = data->dxgiFactory->lpVtbl->EnumAdapterByGpuPreference(data->dxgiFactory,
0,
DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE,
&SDL_IID_IDXGIAdapter4,
- &data->dxgiAdapter
+ (void **)&data->dxgiAdapter
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12CreateDevice"), result);
@@ -759,7 +761,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
result = D3D12CreateDeviceFunc((IUnknown *)data->dxgiAdapter,
D3D_FEATURE_LEVEL_11_0, /* Request minimum feature level 11.0 for maximum compatibility */
&SDL_IID_ID3D12Device5,
- &d3dDevice
+ (void **)&d3dDevice
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12CreateDevice"), result);
@@ -772,7 +774,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
D3D12_MESSAGE_SEVERITY severities[] = { D3D12_MESSAGE_SEVERITY_INFO };
D3D12_INFO_QUEUE_FILTER filter;
- result = ID3D12Device_QueryInterface(d3dDevice, &SDL_IID_ID3D12InfoQueue, (void **)&infoQueue);
+ result = d3dDevice->lpVtbl->QueryInterface(d3dDevice, &SDL_IID_ID3D12InfoQueue, (void **)&infoQueue);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device to ID3D12InfoQueue"), result);
goto done;
@@ -781,15 +783,15 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
SDL_zero(filter);
filter.DenyList.NumSeverities = 1;
filter.DenyList.pSeverityList = severities;
- ID3D12InfoQueue_PushStorageFilter(infoQueue, &filter);
+ infoQueue->lpVtbl->PushStorageFilter(infoQueue, &filter);
- ID3D12InfoQueue_SetBreakOnSeverity(infoQueue, D3D12_MESSAGE_SEVERITY_ERROR, TRUE);
- ID3D12InfoQueue_SetBreakOnSeverity(infoQueue, D3D12_MESSAGE_SEVERITY_CORRUPTION, TRUE);
+ infoQueue->lpVtbl->SetBreakOnSeverity(infoQueue, D3D12_MESSAGE_SEVERITY_ERROR, TRUE);
+ infoQueue->lpVtbl->SetBreakOnSeverity(infoQueue, D3D12_MESSAGE_SEVERITY_CORRUPTION, TRUE);
SAFE_RELEASE(infoQueue);
}
- result = ID3D12Device_QueryInterface(d3dDevice, &SDL_IID_ID3D12Device5, (void **)&data->d3dDevice);
+ result = d3dDevice->lpVtbl->QueryInterface(d3dDevice, &SDL_IID_ID3D12Device5, (void **)&data->d3dDevice);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device to ID3D12Device5"), result);
goto done;
@@ -800,10 +802,10 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
- result = ID3D12Device_CreateCommandQueue(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateCommandQueue(data->d3dDevice,
&queueDesc,
&SDL_IID_ID3D12CommandQueue,
- &data->commandQueue
+ (void **)&data->commandQueue
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommandQueue"), result);
@@ -814,22 +816,22 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
SDL_zero(descriptorHeapDesc);
descriptorHeapDesc.NumDescriptors = SDL_D3D12_NUM_BUFFERS;
descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
- result = ID3D12Device_CreateDescriptorHeap(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateDescriptorHeap(data->d3dDevice,
&descriptorHeapDesc,
&SDL_IID_ID3D12DescriptorHeap,
- &data->rtvDescriptorHeap
+ (void **)&data->rtvDescriptorHeap
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateDescriptorHeap [rtv]"), result);
goto done;
}
- data->rtvDescriptorSize = ID3D12Device_GetDescriptorHandleIncrementSize(d3dDevice, D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
+ data->rtvDescriptorSize = d3dDevice->lpVtbl->GetDescriptorHandleIncrementSize(d3dDevice, D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
descriptorHeapDesc.NumDescriptors = SDL_D3D12_MAX_NUM_TEXTURES;
- result = ID3D12Device_CreateDescriptorHeap(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateDescriptorHeap(data->d3dDevice,
&descriptorHeapDesc,
&SDL_IID_ID3D12DescriptorHeap,
- &data->textureRTVDescriptorHeap
+ (void **)&data->textureRTVDescriptorHeap
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateDescriptorHeap [texture rtv]"), result);
@@ -840,40 +842,40 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
descriptorHeapDesc.NumDescriptors = SDL_D3D12_MAX_NUM_TEXTURES;
descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
- result = ID3D12Device_CreateDescriptorHeap(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateDescriptorHeap(data->d3dDevice,
&descriptorHeapDesc,
&SDL_IID_ID3D12DescriptorHeap,
- &data->srvDescriptorHeap
+ (void **)&data->srvDescriptorHeap
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateDescriptorHeap [srv]"), result);
goto done;
}
rootDescriptorHeaps[0] = data->srvDescriptorHeap;
- data->srvDescriptorSize = ID3D12Device_GetDescriptorHandleIncrementSize(d3dDevice, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
+ data->srvDescriptorSize = d3dDevice->lpVtbl->GetDescriptorHandleIncrementSize(d3dDevice, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
SDL_zero(descriptorHeapDesc);
descriptorHeapDesc.NumDescriptors = 2;
descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER;
descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
- result = ID3D12Device_CreateDescriptorHeap(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateDescriptorHeap(data->d3dDevice,
&descriptorHeapDesc,
&SDL_IID_ID3D12DescriptorHeap,
- &data->samplerDescriptorHeap
+ (void **)&data->samplerDescriptorHeap
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateDescriptorHeap [sampler]"), result);
goto done;
}
rootDescriptorHeaps[1] = data->samplerDescriptorHeap;
- data->samplerDescriptorSize = ID3D12Device_GetDescriptorHandleIncrementSize(d3dDevice, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
+ data->samplerDescriptorSize = d3dDevice->lpVtbl->GetDescriptorHandleIncrementSize(d3dDevice, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
/* Create a command allocator for each back buffer */
for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) {
- result = ID3D12Device_CreateCommandAllocator(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateCommandAllocator(data->d3dDevice,
D3D12_COMMAND_LIST_TYPE_DIRECT,
&SDL_IID_ID3D12CommandAllocator,
- &data->commandAllocators[i]
+ (void **)&data->commandAllocators[i]
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommandAllocator"), result);
@@ -882,13 +884,13 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
}
/* Create the command list */
- result = ID3D12Device_CreateCommandList(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateCommandList(data->d3dDevice,
0,
D3D12_COMMAND_LIST_TYPE_DIRECT,
data->commandAllocators[0],
NULL,
&SDL_IID_ID3D12GraphicsCommandList2,
- &data->commandList
+ (void **)&data->commandList
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommandList"), result);
@@ -896,14 +898,14 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
}
/* Set the descriptor heaps to the correct initial value */
- ID3D12GraphicsCommandList2_SetDescriptorHeaps(data->commandList, 2, rootDescriptorHeaps);
+ data->commandList->lpVtbl->SetDescriptorHeaps(data->commandList, 2, rootDescriptorHeaps);
/* Create the fence and fence event */
- result = ID3D12Device_CreateFence(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateFence(data->d3dDevice,
data->fenceValue,
D3D12_FENCE_FLAG_NONE,
&SDL_IID_ID3D12Fence,
- &data->fence
+ (void **)&data->fence
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateFence"), result);
@@ -922,12 +924,12 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
for (i = 0; i < NUM_ROOTSIGS; ++i) {
D3D12_SHADER_BYTECODE rootSigData;
D3D12_GetRootSignatureData(i, &rootSigData);
- result = ID3D12Device_CreateRootSignature(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateRootSignature(data->d3dDevice,
0,
rootSigData.pShaderBytecode,
rootSigData.BytecodeLength,
&SDL_IID_ID3D12RootSignature,
- &data->rootSignatures[i]
+ (void **)&data->rootSignatures[i]
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateRootSignature"), result);
@@ -953,10 +955,10 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
/* Create a vertex buffer heap and populate it with resources */
SDL_zero(vbufferHeapDesc);
vbufferHeapDesc.SizeInBytes = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT * SDL_D3D12_NUM_VERTEX_BUFFERS;
- ID3D12Device_GetCustomHeapProperties(data->d3dDevice, &vbufferHeapDesc.Properties, 0, D3D12_HEAP_TYPE_UPLOAD);
+ data->d3dDevice->lpVtbl->GetCustomHeapProperties(data->d3dDevice, &vbufferHeapDesc.Properties, 0, D3D12_HEAP_TYPE_UPLOAD);
vbufferHeapDesc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
vbufferHeapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS;
- result = ID3D12Device_CreateHeap(data->d3dDevice, &vbufferHeapDesc, &SDL_IID_ID3D12Heap, &data->vertexBufferHeap);
+ result = data->d3dDevice->lpVtbl->CreateHeap(data->d3dDevice, &vbufferHeapDesc, &SDL_IID_ID3D12Heap, (void **)&data->vertexBufferHeap);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateHeap"), result);
goto done;
@@ -976,14 +978,14 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
vbufferDesc.Flags = D3D12_RESOURCE_FLAG_NONE;
for (i = 0; i < SDL_D3D12_NUM_VERTEX_BUFFERS; ++i) {
- result = ID3D12Device_CreatePlacedResource(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreatePlacedResource(data->d3dDevice,
data->vertexBufferHeap,
i * D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
&vbufferDesc,
D3D12_RESOURCE_STATE_GENERIC_READ,
NULL,
&SDL_IID_ID3D12Resource,
- &data->vertexBuffers[i].resource
+ (void **)&data->vertexBuffers[i].resource
);
if (FAILED(result)) {
@@ -991,7 +993,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
goto done;
}
- data->vertexBuffers[i].view.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(data->vertexBuffers[i].resource);
+ data->vertexBuffers[i].view.BufferLocation = data->vertexBuffers[i].resource->lpVtbl->GetGPUVirtualAddress(data->vertexBuffers[i].resource);
data->vertexBuffers[i].view.StrideInBytes = sizeof(VertexPositionColor);
}
@@ -1006,12 +1008,12 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
samplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
samplerDesc.MinLOD = 0.0f;
samplerDesc.MaxLOD = D3D12_FLOAT32_MAX;
- ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->samplerDescriptorHeap, &data->nearestPixelSampler);
- ID3D12Device_CreateSampler(data->d3dDevice, &samplerDesc, data->nearestPixelSampler);
+ data->samplerDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(data->samplerDescriptorHeap, &data->nearestPixelSampler);
+ data->d3dDevice->lpVtbl->CreateSampler(data->d3dDevice, &samplerDesc, data->nearestPixelSampler);
samplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
data->linearSampler.ptr = data->nearestPixelSampler.ptr + data->samplerDescriptorSize;
- ID3D12Device_CreateSampler(data->d3dDevice, &samplerDesc, data->linearSampler);
+ data->d3dDevice->lpVtbl->CreateSampler(data->d3dDevice, &samplerDesc, data->linearSampler);
/* Initialize the pool allocator for SRVs */
for (i = 0; i < SDL_D3D12_MAX_NUM_TEXTURES; ++i) {
@@ -1106,6 +1108,7 @@ D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata;
IDXGISwapChain1* swapChain;
HRESULT result = S_OK;
+ SDL_SysWMinfo windowinfo;
/* Create a swap chain using the same adapter as the existing Direct3D device. */
DXGI_SWAP_CHAIN_DESC1 swapChainDesc;
@@ -1127,11 +1130,10 @@ D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT | /* To support SetMaximumFrameLatency */
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; /* To support presenting with allow tearing on */
- SDL_SysWMinfo windowinfo;
SDL_VERSION(&windowinfo.version);
SDL_GetWindowWMInfo(renderer->window, &windowinfo);
- result = IDXGIFactory6_CreateSwapChainForHwnd(data->dxgiFactory,
+ result = data->dxgiFactory->lpVtbl->CreateSwapChainForHwnd(data->dxgiFactory,
(IUnknown *)data->commandQueue,
windowinfo.info.win.window,
&swapChainDesc,
@@ -1144,9 +1146,9 @@ D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
goto done;
}
- IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES);
+ data->dxgiFactory->lpVtbl->MakeWindowAssociation(data->dxgiFactory, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES);
- result = IDXGISwapChain1_QueryInterface(swapChain, &SDL_IID_IDXGISwapChain4, (void **)&data->swapChain);
+ result = swapChain->lpVtbl->QueryInterface(swapChain, &SDL_IID_IDXGISwapChain4, (void **)&data->swapChain);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain1::QueryInterface"), result);
goto done;
@@ -1155,7 +1157,7 @@ D3D12_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
/* Ensure that the swapchain 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 = IDXGISwapChain4_SetMaximumFrameLatency(data->swapChain, 1);
+ result = data->swapChain->lpVtbl->SetMaximumFrameLatency(data->swapChain, 1);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain4::SetMaximumFrameLatency"), result);
goto done;
@@ -1228,7 +1230,7 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
if (data->swapChain) {
/* If the swap chain already exists, resize it. */
- result = IDXGISwapChain_ResizeBuffers(data->swapChain,
+ result = data->swapChain->lpVtbl->ResizeBuffers(data->swapChain,
0,
w, h,
DXGI_FORMAT_UNKNOWN,
@@ -1256,7 +1258,7 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
/* Set the proper rotation for the swap chain. */
if (WIN_IsWindows8OrGreater()) {
if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) {
- result = IDXGISwapChain4_SetRotation(data->swapChain, data->rotation);
+ result = data->swapChain->lpVtbl->SetRotation(data->swapChain, data->rotation);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain4::SetRotation"), result);
goto done;
@@ -1266,8 +1268,7 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
/* Get each back buffer render target and create render target views */
for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) {
- result = IDXGISwapChain4_GetBuffer(
- data->swapChain,
+ result = data->swapChain->lpVtbl->GetBuffer(data->swapChain,
i,
&SDL_IID_ID3D12Resource,
(void **) &data->renderTargets[i]
@@ -1282,20 +1283,20 @@ D3D12_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
SDL_zero(rtvDescriptor);
- ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor);
+ data->rtvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor);
rtvDescriptor.ptr += i * data->rtvDescriptorSize;
- ID3D12Device5_CreateRenderTargetView(data->d3dDevice, data->renderTargets[i], &rtvDesc, rtvDescriptor);
+ data->d3dDevice->lpVtbl->CreateRenderTargetView(data->d3dDevice, data->renderTargets[i], &rtvDesc, rtvDescriptor);
}
/* Set back buffer index to current buffer */
- data->currentBackBufferIndex = IDXGISwapChain4_GetCurrentBackBufferIndex(data->swapChain);
+ data->currentBackBufferIndex = data->swapChain->lpVtbl->GetCurrentBackBufferIndex(data->swapChain);
/* Set the swap chain target immediately, so that a target is always set
* even before we get to SetDrawState. Without this it's possible to hit
* null references in places like ReadPixels!
*/
data->currentRenderTargetView = D3D12_GetCurrentRenderTargetView(renderer);
- ID3D12GraphicsCommandList2_OMSetRenderTargets(data->commandList, 1, &data->currentRenderTargetView, FALSE, NULL);
+ data->commandList->lpVtbl->OMSetRenderTargets(data->commandList, 1, &data->currentRenderTargetView, FALSE, NULL);
D3D12_TransitionResource(data,
data->renderTargets[data->currentBackBufferIndex],
D3D12_RESOURCE_STATE_PRESENT,
@@ -1413,14 +1414,14 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
heapProps.CreationNodeMask = 1;
heapProps.VisibleNodeMask = 1;
- result = ID3D12Device_CreateCommittedResource(rendererData->d3dDevice,
+ result = rendererData->d3dDevice->lpVtbl->CreateCommittedResource(rendererData->d3dDevice,
&heapProps,
D3D12_HEAP_FLAG_NONE,
&textureDesc,
D3D12_RESOURCE_STATE_COPY_DEST,
NULL,
&SDL_IID_ID3D12Resource,
- &textureData->mainTexture
+ (void **)&textureData->mainTexture
);
textureData->mainResourceState = D3D12_RESOURCE_STATE_COPY_DEST;
if (FAILED(result)) {
@@ -1435,14 +1436,14 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
textureDesc.Width = (textureDesc.Width + 1) / 2;
textureDesc.Height = (textureDesc.Height + 1) / 2;
- result = ID3D12Device_CreateCommittedResource(rendererData->d3dDevice,
+ result = rendererData->d3dDevice->lpVtbl->CreateCommittedResource(rendererData->d3dDevice,
&heapProps,
D3D12_HEAP_FLAG_NONE,
&textureDesc,
D3D12_RESOURCE_STATE_COPY_DEST,
NULL,
&SDL_IID_ID3D12Resource,
- &textureData->mainTextureU
+ (void **)&textureData->mainTextureU
);
textureData->mainResourceStateU = D3D12_RESOURCE_STATE_COPY_DEST;
if (FAILED(result)) {
@@ -1450,14 +1451,14 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [texture]"), result);
}
- result = ID3D12Device_CreateCommittedResource(rendererData->d3dDevice,
+ result = rendererData->d3dDevice->lpVtbl->CreateCommittedResource(rendererData->d3dDevice,
&heapProps,
D3D12_HEAP_FLAG_NONE,
&textureDesc,
D3D12_RESOURCE_STATE_COPY_DEST,
NULL,
&SDL_IID_ID3D12Resource,
- &textureData->mainTextureV
+ (void **)&textureData->mainTextureV
);
textureData->mainResourceStateV = D3D12_RESOURCE_STATE_COPY_DEST;
if (FAILED(result)) {
@@ -1476,19 +1477,19 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
nvTextureDesc.Width = (textureDesc.Width + 1) / 2;
nvTextureDesc.Height = (textureDesc.Height + 1) / 2;
- result = ID3D12Device_CreateCommittedResource(rendererData->d3dDevice,
+ result = rendererData->d3dDevice->lpVtbl->CreateCommittedResource(rendererData->d3dDevice,
&heapProps,
D3D12_HEAP_FLAG_NONE,
&nvTextureDesc,
D3D12_RESOURCE_STATE_COPY_DEST,
NULL,
&SDL_IID_ID3D12Resource,
- &textureData->mainTextureNV
+ (void **)&textureData->mainTextureNV
);
textureData->mainResourceStateNV = D3D12_RESOURCE_STATE_COPY_DEST;
if (FAILED(result)) {
D3D12_DestroyTexture(renderer, texture);
- return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device1::CreateTexture2D"), result);
+ return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateTexture2D"), result);
}
}
#endif /* SDL_HAVE_YUV */
@@ -1500,29 +1501,29 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
textureData->mainSRVIndex = D3D12_GetAvailableSRVIndex(renderer);
- ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceView);
+ rendererData->srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceView);
textureData->mainTextureResourceView.ptr += textureData->mainSRVIndex * rendererData->srvDescriptorSize;
- ID3D12Device_CreateShaderResourceView(rendererData->d3dDevice,
+ rendererData->d3dDevice->lpVtbl->CreateShaderResourceView(rendererData->d3dDevice,
textureData->mainTexture,
&resourceViewDesc,
textureData->mainTextureResourceView
);
#if SDL_HAVE_YUV
if (textureData->yuv) {
- ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewU);
+ rendererData->srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewU);
textureData->mainSRVIndexU = D3D12_GetAvailableSRVIndex(renderer);
textureData->mainTextureResourceViewU.ptr += textureData->mainSRVIndexU * rendererData->srvDescriptorSize;
- ID3D12Device_CreateShaderResourceView(rendererData->d3dDevice,
+ rendererData->d3dDevice->lpVtbl->CreateShaderResourceView(rendererData->d3dDevice,
textureData->mainTextureU,
&resourceViewDesc,
textureData->mainTextureResourceViewU
);
- ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewV);
+ rendererData->srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewV);
textureData->mainSRVIndexV = D3D12_GetAvailableSRVIndex(renderer);
textureData->mainTextureResourceViewV.ptr += textureData->mainSRVIndexV * rendererData->srvDescriptorSize;
- ID3D12Device_CreateShaderResourceView(rendererData->d3dDevice,
+ rendererData->d3dDevice->lpVtbl->CreateShaderResourceView(rendererData->d3dDevice,
textureData->mainTextureV,
&resourceViewDesc,
textureData->mainTextureResourceViewV
@@ -1534,10 +1535,10 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM;
- ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewNV);
+ rendererData->srvDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewNV);
textureData->mainSRVIndexNV = D3D12_GetAvailableSRVIndex(renderer);
textureData->mainTextureResourceViewNV.ptr += textureData->mainSRVIndexNV * rendererData->srvDescriptorSize;
- ID3D12Device_CreateShaderResourceView(rendererData->d3dDevice,
+ rendererData->d3dDevice->lpVtbl->CreateShaderResourceView(rendererData->d3dDevice,
textureData->mainTextureNV,
&nvResourceViewDesc,
textureData->mainTextureResourceViewNV
@@ -1552,10 +1553,10 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
renderTargetViewDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
renderTargetViewDesc.Texture2D.MipSlice = 0;
- ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->textureRTVDescriptorHeap, &textureData->mainTextureRenderTargetView);
+ rendererData->textureRTVDescriptorHeap->lpVtbl->GetCPUDescriptorHandleForHeapStart(rendererData->textureRTVDescriptorHeap, &textureData->mainTextureRenderTargetView);
textureData->mainTextureRenderTargetView.ptr += textureData->mainSRVIndex * rendererData->rtvDescriptorSize;
- ID3D12Device_CreateRenderTargetView(rendererData->d3dDevice,
+ rendererData->d3dDevice->lpVtbl->CreateRenderTargetView(rendererData->d3dDevice,
(ID3D12Resource*)textureData->mainTexture,
&renderTargetViewDesc,
textureData->mainTextureRenderTargetView);
@@ -1615,9 +1616,11 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te
D3D12_TEXTURE_COPY_LOCATION srcLocation;
D3D12_TEXTURE_COPY_LOCATION dstLocation;
BYTE *textureMemory;
+ ID3D12Resource *uploadBuffer;
/* Create an upload buffer, which will be used to write to the main texture. */
- ID3D12Resource_GetDesc(texture, &textureDesc);
+ SDL_zero(textureDesc);
+ texture->lpVtbl->GetDesc(texture, &textureDesc);
textureDesc.Width = w;
textureDesc.Height = h;
@@ -1634,7 +1637,7 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te
uploadDesc.Flags = D3D12_RESOURCE_FLAG_NONE;
/* Figure out how much we need to allocate for the upload buffer */
- ID3D12Device_GetCopyableFootprints(rendererData->d3dDevice,
+ rendererData->d3dDevice->lpVtbl->GetCopyableFootprints(rendererData->d3dDevice,
&textureDesc,
0,
1,
@@ -1651,21 +1654,22 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te
heapProps.VisibleNodeMask = 1;
/* Create the upload buffer */
- result = ID3D12Device_CreateCommittedResource(rendererData->d3dDevice,
+ result = rendererData->d3dDevice->lpVtbl->CreateCommittedResource(rendererData->d3dDevice,
&heapProps,
D3D12_HEAP_FLAG_NONE,
&uploadDesc,
D3D12_RESOURCE_STATE_GENERIC_READ,
NULL,
&SDL_IID_ID3D12Resource,
- &rendererData->uploadBuffers[rendererData->currentUploadBuffer]
+ (void **)&rendererData->uploadBuffers[rendererData->currentUploadBuffer]
);
if (FAILED(result)) {
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [create upload buffer]"), result);
}
/* Get a write-only pointer to data in the upload buffer: */
- result = ID3D12Resource_Map(rendererData->uploadBuffers[rendererData->currentUploadBuffer],
+ uploadBuffer = rendererData->uploadBuffers[rendererData->currentUploadBuffer];
+ result = uploadBuffer->lpVtbl->Map(uploadBuffer,
0,
NULL,
(void **)&textureMemory
@@ -1706,7 +1710,7 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te
}
/* Commit the changes back to the upload buffer: */
- ID3D12Resource_Unmap(rendererData->uploadBuffers[rendererData->currentUploadBuffer], 0, NULL);
+ uploadBuffer->lpVtbl->Unmap(uploadBuffer, 0, NULL);
/* Make sure the destination is in the correct resource state */
D3D12_TransitionResource(rendererData, texture, *resourceState, D3D12_RESOURCE_STATE_COPY_DEST);
@@ -1722,7 +1726,7 @@ D3D12_UpdateTextureInternal(D3D12_RenderData * rendererData, ID3D12Resource * te
srcLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
srcLocation.PlacedFootprint = placedTextureDesc;
- ID3D12GraphicsCommandList_CopyTextureRegion(rendererData->commandList,
+ rendererData->commandList->lpVtbl->CopyTextureRegion(rendererData->commandList,
&dstLocation,
x,
y,
@@ -1879,7 +1883,8 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
}
/* Create an upload buffer, which will be used to write to the main texture. */
- ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc);
+ SDL_zero(textureDesc);
+ textureData->mainTexture->lpVtbl->GetDesc(textureData->mainTexture, &textureDesc);
textureDesc.Width = rect->w;
textureDesc.Height = rect->h;
@@ -1896,7 +1901,7 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
uploadDesc.Flags = D3D12_RESOURCE_FLAG_NONE;
/* Figure out how much we need to allocate for the upload buffer */
- ID3D12Device_GetCopyableFootprints(rendererData->d3dDevice,
+ rendererData->d3dDevice->lpVtbl->GetCopyableFootprints(rendererData->d3dDevice,
&textureDesc,
0,
1,
@@ -1913,21 +1918,21 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
heapProps.VisibleNodeMask = 1;
/* Create the upload buffer */
- result = ID3D12Device_CreateCommittedResource(rendererData->d3dDevice,
+ result = rendererData->d3dDevice->lpVtbl->CreateCommittedResource(rendererData->d3dDevice,
&heapProps,
D3D12_HEAP_FLAG_NONE,
&uploadDesc,
D3D12_RESOURCE_STATE_GENERIC_READ,
NULL,
&SDL_IID_ID3D12Resource,
- &textureData->stagingBuffer
+ (void **)&textureData->stagingBuffer
);
if (FAILED(result)) {
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [create upload buffer]"), result);
}
/* Get a write-only pointer to data in the upload buffer: */
- result = ID3D12Resource_Map(textureData->stagingBuffer,
+ result = textureData->stagingBuffer->lpVtbl->Map(textureData->stagingBuffer,
0,
NULL,
(void **)&textureMemory
@@ -1990,9 +1995,10 @@ D3D12_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
}
#endif
/* Commit the pixel buffer's changes back to the staging texture: */
- ID3D12Resource_Unmap(textureData->stagingBuffer, 0, NULL);
+ textureData->stagingBuffer->lpVtbl->Unmap(textureData->stagingBuffer, 0, NULL);
- ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc);
+ SDL_zero(textureDesc);
+ textureData->mainTexture->lpVtbl->GetDesc(textureData->mainTexture, &textureDesc);
textureDesc.Width = textureData->lockedRect.w;
textureDesc.Height = textureData->lockedRect.h;
@@ -2026,7 +2032,7 @@ D3D12_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
srcLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
srcLocation.PlacedFootprint = placedTextureDesc;
- ID3D12GraphicsCommandList_CopyTextureRegion(rendererData->commandList,
+ rendererData->commandList->lpVtbl->CopyTextureRegion(rendererData->commandList,
&dstLocation,
textureData->lockedRect.x,
textureData->lockedRect.y,
@@ -2188,6 +2194,7 @@ D3D12_UpdateVertexBuffer(SDL_Renderer *renderer,
const UINT stride = sizeof(VertexPositionColor);
UINT8* vertexBufferData = NULL;
D3D12_RANGE range;
+ ID3D12Resource *vertexBuffer;
range.Begin = 0;
range.End = 0;
@@ -2208,16 +2215,17 @@ D3D12_UpdateVertexBuffer(SDL_Renderer *renderer,
return E_FAIL;
}
- result = ID3D12Resource_Map(rendererData->vertexBuffers[vbidx].resource, 0, &range, (void **)&vertexBufferData);
+ vertexBuffer = rendererData->vertexBuffers[vbidx].resource;
+ result = vertexBuffer->lpVtbl->Map(vertexBuffer, 0, &range, (void **)&vertexBufferData);
if (FAILED(result)) {
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Resource::Map [vertex buffer]"), result);
}
SDL_memcpy(vertexBufferData, vertexData, dataSizeInBytes);
- ID3D12Resource_Unmap(rendererData->vertexBuffers[vbidx].resource, 0, NULL);
+ vertexBuffer->lpVtbl->Unmap(vertexBuffer, 0, NULL);
rendererData->vertexBuffers[vbidx].view.SizeInBytes = (UINT)dataSizeInBytes;
- ID3D12GraphicsCommandList_IASetVertexBuffers(rendererData->commandList, 0, 1, &rendererData->vertexBuffers[vbidx].view);
+ rendererData->commandList->lpVtbl->IASetVertexBuffers(rendererData->commandList, 0, 1, &rendererData->vertexBuffers[vbidx].view);
rendererData->currentVertexBuffer++;
if (rendererData->currentVertexBuffer >= SDL_D3D12_NUM_VERTEX_BUFFERS) {
@@ -2313,7 +2321,7 @@ D3D12_UpdateViewport(SDL_Renderer * renderer)
d3dviewport.MinDepth = 0.0f;
d3dviewport.MaxDepth = 1.0f;
/* SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height); */
- ID3D12GraphicsCommandList_RSSetViewports(data->commandList, 1, &d3dviewport);
+ data->commandList->lpVtbl->RSSetViewports(data->commandList, 1, &d3dviewport);
data->viewportDirty = SDL_FALSE;
@@ -2374,8 +2382,8 @@ D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_
return SDL_SetError("[direct3d12] Unable to create required pipeline state");
}
- ID3D12GraphicsCommandList2_SetPipelineState(rendererData->commandList, rendererData->currentPipelineState->pipelineState);
- ID3D12GraphicsCommandList2_SetGraphicsRootSignature(rendererData->commandList,
+ rendererData->commandList->lpVtbl->SetPipelineState(rendererData->commandList, rendererData->currentPipelineState->pipelineState);
+ rendererData->commandList->lpVtbl->SetGraphicsRootSignature(rendererData->commandList,
rendererData->rootSignatures[D3D12_GetRootSignatureType(rendererData->currentPipelineState->shader)]);
/* When we change these we will need to re-upload the constant buffer and reset any descriptors */
updateSubresource = SDL_TRUE;
@@ -2384,7 +2392,7 @@ D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_
}
if (renderTargetView.ptr != rendererData->currentRenderTargetView.ptr) {
- ID3D12GraphicsCommandList2_OMSetRenderTargets(rendererData->commandList, 1, &renderTargetView, FALSE, NULL);
+ rendererData->commandList->lpVtbl->OMSetRenderTargets(rendererData->commandList, 1, &renderTargetView, FALSE, NULL);
rendererData->currentRenderTargetView = renderTargetView;
}
@@ -2401,7 +2409,7 @@ D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_
/* D3D12_GetViewportAlignedD3DRect will have set the SDL error */
return -1;
}
- ID3D12GraphicsCommandList2_RSSetScissorRects(rendererData->commandList, 1, &scissorRect);
+ rendererData->commandList->lpVtbl->RSSetScissorRects(rendererData->commandList, 1, &scissorRect);
rendererData->cliprectDirty = SDL_FALSE;
}
@@ -2413,7 +2421,7 @@ D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_
if (firstShaderResource.ptr != rendererData->currentShaderResource.ptr) {
for (i = 0; i < numShaderResources; ++i) {
D3D12_GPU_DESCRIPTOR_HANDLE GPUHandle = D3D12_CPUtoGPUHandle(rendererData->srvDescriptorHeap, shaderResources[i]);
- ID3D12GraphicsCommandList2_SetGraphicsRootDescriptorTable(rendererData->commandList, i + 1, GPUHandle);
+ rendererData->commandList->lpVtbl->SetGraphicsRootDescriptorTable(rendererData->commandList, i + 1, GPUHandle);
}
rendererData->currentShaderResource.ptr = firstShaderResource.ptr;
}
@@ -2447,13 +2455,13 @@ D3D12_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, D3D12_
break;
}
- ID3D12GraphicsCommandList2_SetGraphicsRootDescriptorTable(rendererData->commandList, tableIndex, GPUHandle);
+ rendererData->commandList->lpVtbl->SetGraphicsRootDescriptorTable(rendererData->commandList, tableIndex, GPUHandle);
rendererData->currentSampler = *sampler;
}
if (updateSubresource == SDL_TRUE || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix)) != 0) {
SDL_memcpy(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof (*newmatrix));
- ID3D12GraphicsCommandList2_SetGraphicsRoot32BitConstants(rendererData->commandList,
+ rendererData->commandList->lpVtbl->SetGraphicsRoot32BitConstants(rendererData->commandList,
0,
32,
&rendererData->vertexShaderConstantsData,
@@ -2556,8 +2564,8 @@ static void
D3D12_DrawPrimitives(SDL_Renderer * renderer, D3D12_PRIMITIVE_TOPOLOGY primitiveTopology, const size_t vertexStart, const size_t vertexCount)
{
D3D12_RenderData *rendererData = (D3D12_RenderData *) renderer->driverdata;
- ID3D12GraphicsCommandList_IASetPrimitiveTopology(rendererData->commandList, primitiveTopology);
- ID3D12GraphicsCommandList_DrawInstanced(rendererData->commandList, (UINT)vertexCount, 1, 0, 0);
+ rendererData->commandList->lpVtbl->IASetPrimitiveTopology(rendererData->commandList, primitiveTopology);
+ rendererData->commandList->lpVtbl->DrawInstanced(rendererData->commandList, (UINT)vertexCount, 1, 0, 0);
}
static int
@@ -2617,7 +2625,7 @@ D3D12_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver
};
D3D12_CPU_DESCRIPTOR_HANDLE rtvDescriptor = D3D12_GetCurrentRenderTargetView(renderer);
- ID3D12GraphicsCommandList2_ClearRenderTargetView(rendererData->commandList, rtvDescriptor, colorRGBA, 0, NULL);
+ rendererData->commandList->lpVtbl->ClearRenderTargetView(rendererData->commandList, rtvDescriptor, colorRGBA, 0, NULL);
break;
}
@@ -2706,7 +2714,8 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
}
/* Create a staging texture to copy the screen's data to: */
- ID3D12Resource_GetDesc(backBuffer, &textureDesc);
+ SDL_zero(textureDesc);
+ backBuffer->lpVtbl->GetDesc(backBuffer, &textureDesc);
textureDesc.Width = rect->w;
textureDesc.Height = rect->h;
@@ -2723,7 +2732,7 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
readbackDesc.Flags = D3D12_RESOURCE_FLAG_NONE;
/* Figure out how much we need to allocate for the upload buffer */
- ID3D12Device_GetCopyableFootprints(data->d3dDevice,
+ data->d3dDevice->lpVtbl->GetCopyableFootprints(data->d3dDevice,
&textureDesc,
0,
1,
@@ -2739,17 +2748,17 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
heapProps.CreationNodeMask = 1;
heapProps.VisibleNodeMask = 1;
- result = ID3D12Device_CreateCommittedResource(data->d3dDevice,
+ result = data->d3dDevice->lpVtbl->CreateCommittedResource(data->d3dDevice,
&heapProps,
D3D12_HEAP_FLAG_NONE,
&readbackDesc,
D3D12_RESOURCE_STATE_COPY_DEST,
NULL,
&SDL_IID_ID3D12Resource,
- &readbackBuffer
+ (void **)&readbackBuffer
);
if (FAILED(result)) {
- WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device1::CreateTexture2D [create staging texture]"), result);
+ WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateTexture2D [create staging texture]"), result);
goto done;
}
@@ -2776,8 +2785,7 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
pitchedDesc.Depth = 1;
if (pitchedDesc.Format == DXGI_FORMAT_R8_UNORM) {
bpp = 1;
- }
- else {
+ } else {
bpp = 4;
}
pitchedDesc.RowPitch = D3D12_Align(pitchedDesc.Width * bpp, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
@@ -2796,7 +2804,7 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
srcLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
srcLocation.SubresourceIndex = 0;
- ID3D12GraphicsCommandList_CopyTextureRegion(data->commandList,
+ data->commandList->lpVtbl->CopyTextureRegion(data->commandList,
&dstLocation,
0, 0, 0,
&srcLocation,
@@ -2810,7 +2818,7 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
D3D12_TransitionResource(data, backBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET );
/* Map the staging texture's data to CPU-accessible memory: */
- result = ID3D12Resource_Map(readbackBuffer,
+ result = readbackBuffer->lpVtbl->Map(readbackBuffer,
0,
NULL,
(void **)&textureMemory
@@ -2833,7 +2841,7 @@ D3D12_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
pitch);
/* Unmap the texture: */
- ID3D12Resource_Unmap(readbackBuffer, 0, NULL);
+ readbackBuffer->lpVtbl->Unmap(readbackBuffer, 0, NULL);
done:
SAFE_RELEASE(readbackBuffer);
@@ -2856,8 +2864,8 @@ D3D12_RenderPresent(SDL_Renderer * renderer)
);
/* Issue the command list */
- result = ID3D12GraphicsCommandList2_Close(data->commandList);
- ID3D12CommandQueue_ExecuteCommandLists(data->commandQueue, 1, (ID3D12CommandList * const *)&data->commandList);
+ result = data->commandList->lpVtbl->Close(data->commandList);
+ data->commandQueue->lpVtbl->ExecuteCommandLists(data->commandQueue, 1, (ID3D12CommandList * const *)&data->commandList);
if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
syncInterval = 1;
@@ -2870,7 +2878,7 @@ D3D12_RenderPresent(SDL_Renderer * renderer)
/* The application may optionally specify "dirty" or "scroll"
* rects to improve efficiency in certain scenarios.
*/
- result = IDXGISwapChain4_Present(data->swapChain, syncInterval, presentFlags);
+ result = data->swapChain->lpVtbl->Present(data->swapChain, syncInterval, presentFlags);
if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) {
/* If the device was removed either by a disconnect or a driver upgrade, we
@@ -2886,11 +2894,10 @@ D3D12_RenderPresent(SDL_Renderer * renderer)
}
} else {
/* Wait for the GPU and move to the next frame */
- result = ID3D12CommandQueue_Signal(data->commandQueue, data->fence, data->fenceValue);
+ result = data->commandQueue->lpVtbl->Signal(data->commandQueue, data->fence, data->fenceValue);
- if (ID3D12Fence_GetCompletedValue(data->fence) < data->fenceValue) {
- result = ID3D12Fence_SetEventOnCompletion(
- data->fence,
+ if (data->fence->lpVtbl->GetCompletedValue(data->fence) < data->fenceValue) {
+ result = data->fence->lpVtbl->SetEventOnCompletion(data->fence,
data->fenceValue,
data->fenceEvent
);
@@ -2898,7 +2905,7 @@ D3D12_RenderPresent(SDL_Renderer * renderer)
}
data->fenceValue++;
- data->currentBackBufferIndex = IDXGISwapChain4_GetCurrentBackBufferIndex(data->swapChain);
+ data->currentBackBufferIndex = data->swapChain->lpVtbl->GetCurrentBackBufferIndex(data->swapChain);
/* Reset the command allocator and command list, and transition back to render target */
D3D12_ResetCommandList(data);
@@ -3035,7 +3042,7 @@ SDL_RenderGetD3D12Device(SDL_Renderer * renderer)
device = (ID3D12Device *)data->d3dDevice;
if (device) {
- ID3D12Device_AddRef(device);
+ device->lpVtbl->AddRef(device);
}
#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED */