mirror of https://github.com/libsdl-org/SDL
Remove D3D12 call hacks now that we have a good set of D3D12 headers
This commit is contained in:
parent
de30400a7b
commit
445983fc79
|
@ -86,54 +86,6 @@
|
|||
#define D3D_GUID(X) &(X)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Older MS Windows SDK headers declare some d3d12 functions with the wrong function prototype.
|
||||
* - ID3D12Heap::GetDesc
|
||||
* - ID3D12Resource::GetDesc
|
||||
* - ID3D12DescriptorHeap::GetDesc
|
||||
* (and 9 more)
|
||||
* This is fixed in SDKs since WDK_NTDDI_VERSION >= NTDDI_WIN10_FE (0x0A00000A)
|
||||
*/
|
||||
|
||||
#if !(defined(__MINGW32__) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) \
|
||||
&& (WDK_NTDDI_VERSION < 0x0A00000A)
|
||||
|
||||
#define D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(THIS, ...) do { \
|
||||
void (STDMETHODCALLTYPE * func)(ID3D12DescriptorHeap * This, D3D12_CPU_DESCRIPTOR_HANDLE * Handle) = \
|
||||
(void*)(THIS)->lpVtbl->GetCPUDescriptorHandleForHeapStart; \
|
||||
func((THIS), ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(THIS, ...) do { \
|
||||
void (STDMETHODCALLTYPE * func)(ID3D12DescriptorHeap * This, D3D12_GPU_DESCRIPTOR_HANDLE * Handle) = \
|
||||
(void*)(THIS)->lpVtbl->GetGPUDescriptorHandleForHeapStart; \
|
||||
func((THIS), ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define D3D_CALL_RET_ID3D12Resource_GetDesc(THIS, ...) do { \
|
||||
void (STDMETHODCALLTYPE * func)(ID3D12Resource * This, D3D12_RESOURCE_DESC * Desc) = \
|
||||
(void*)(THIS)->lpVtbl->GetDesc; \
|
||||
func((THIS), ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* MinGW has correct function prototypes in the vtables, but defines wrong functions
|
||||
* Xbox just needs these macros defined as used below (because CINTERFACE doesn't exist)
|
||||
*/
|
||||
|
||||
#define D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(THIS, ...) \
|
||||
D3D_CALL_RET(THIS, GetCPUDescriptorHandleForHeapStart, ##__VA_ARGS__);
|
||||
|
||||
#define D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(THIS, ...) \
|
||||
D3D_CALL_RET(THIS, GetGPUDescriptorHandleForHeapStart, ##__VA_ARGS__);
|
||||
|
||||
#define D3D_CALL_RET_ID3D12Resource_GetDesc(THIS, ...) \
|
||||
D3D_CALL_RET(THIS, GetDesc, ##__VA_ARGS__);
|
||||
|
||||
#endif
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -550,10 +502,10 @@ static D3D12_GPU_DESCRIPTOR_HANDLE D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap *he
|
|||
SIZE_T offset;
|
||||
|
||||
/* Calculate the correct offset into the heap */
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap, &CPUHeapStart);
|
||||
D3D_CALL_RET(heap, GetCPUDescriptorHandleForHeapStart, &CPUHeapStart);
|
||||
offset = CPUHandle.ptr - CPUHeapStart.ptr;
|
||||
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(heap, &GPUHandle);
|
||||
D3D_CALL_RET(heap, GetGPUDescriptorHandleForHeapStart, &GPUHandle);
|
||||
GPUHandle.ptr += offset;
|
||||
|
||||
return GPUHandle;
|
||||
|
@ -584,7 +536,7 @@ static D3D12_CPU_DESCRIPTOR_HANDLE D3D12_GetCurrentRenderTargetView(SDL_Renderer
|
|||
}
|
||||
|
||||
SDL_zero(rtvDescriptor);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor);
|
||||
D3D_CALL_RET(data->rtvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &rtvDescriptor);
|
||||
rtvDescriptor.ptr += data->currentBackBufferIndex * data->rtvDescriptorSize;
|
||||
return rtvDescriptor;
|
||||
}
|
||||
|
@ -1203,7 +1155,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
|
|||
samplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
|
||||
samplerDesc.MinLOD = 0.0f;
|
||||
samplerDesc.MaxLOD = D3D12_FLOAT32_MAX;
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->samplerDescriptorHeap, &data->samplers[0]);
|
||||
D3D_CALL_RET(data->samplerDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &data->samplers[0]);
|
||||
for (i = 0; i < SDL_arraysize(samplerParams); ++i) {
|
||||
samplerDesc.Filter = samplerParams[i].filter;
|
||||
samplerDesc.AddressU = samplerParams[i].address;
|
||||
|
@ -1539,7 +1491,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
|||
rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
SDL_zero(rtvDescriptor);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor);
|
||||
D3D_CALL_RET(data->rtvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &rtvDescriptor);
|
||||
rtvDescriptor.ptr += i * data->rtvDescriptorSize;
|
||||
D3D_CALL(data->d3dDevice, CreateRenderTargetView, data->renderTargets[i], &rtvDesc, rtvDescriptor);
|
||||
}
|
||||
|
@ -1796,7 +1748,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
|||
resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
|
||||
|
||||
textureData->mainSRVIndex = D3D12_GetAvailableSRVIndex(renderer);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceView);
|
||||
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceView);
|
||||
textureData->mainTextureResourceView.ptr += textureData->mainSRVIndex * rendererData->srvDescriptorSize;
|
||||
|
||||
D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView,
|
||||
|
@ -1805,7 +1757,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
|||
textureData->mainTextureResourceView);
|
||||
#if SDL_HAVE_YUV
|
||||
if (textureData->yuv) {
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewU);
|
||||
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewU);
|
||||
textureData->mainSRVIndexU = D3D12_GetAvailableSRVIndex(renderer);
|
||||
textureData->mainTextureResourceViewU.ptr += textureData->mainSRVIndexU * rendererData->srvDescriptorSize;
|
||||
D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView,
|
||||
|
@ -1813,7 +1765,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
|||
&resourceViewDesc,
|
||||
textureData->mainTextureResourceViewU);
|
||||
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewV);
|
||||
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewV);
|
||||
textureData->mainSRVIndexV = D3D12_GetAvailableSRVIndex(renderer);
|
||||
textureData->mainTextureResourceViewV.ptr += textureData->mainSRVIndexV * rendererData->srvDescriptorSize;
|
||||
D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView,
|
||||
|
@ -1832,7 +1784,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
|||
}
|
||||
nvResourceViewDesc.Texture2D.PlaneSlice = 1;
|
||||
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewNV);
|
||||
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewNV);
|
||||
textureData->mainSRVIndexNV = D3D12_GetAvailableSRVIndex(renderer);
|
||||
textureData->mainTextureResourceViewNV.ptr += textureData->mainSRVIndexNV * rendererData->srvDescriptorSize;
|
||||
D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView,
|
||||
|
@ -1849,7 +1801,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
|||
renderTargetViewDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
|
||||
renderTargetViewDesc.Texture2D.MipSlice = 0;
|
||||
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->textureRTVDescriptorHeap, &textureData->mainTextureRenderTargetView);
|
||||
D3D_CALL_RET(rendererData->textureRTVDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureRenderTargetView);
|
||||
textureData->mainTextureRenderTargetView.ptr += textureData->mainSRVIndex * rendererData->rtvDescriptorSize;
|
||||
|
||||
D3D_CALL(rendererData->d3dDevice, CreateRenderTargetView,
|
||||
|
@ -1913,7 +1865,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res
|
|||
|
||||
/* Create an upload buffer, which will be used to write to the main texture. */
|
||||
SDL_zero(textureDesc);
|
||||
D3D_CALL_RET_ID3D12Resource_GetDesc(texture, &textureDesc);
|
||||
D3D_CALL_RET(texture, GetDesc, &textureDesc);
|
||||
textureDesc.Width = w;
|
||||
textureDesc.Height = h;
|
||||
if (textureDesc.Format == DXGI_FORMAT_NV12 ||
|
||||
|
@ -2169,7 +2121,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||
|
||||
/* Create an upload buffer, which will be used to write to the main texture. */
|
||||
SDL_zero(textureDesc);
|
||||
D3D_CALL_RET_ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc);
|
||||
D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc);
|
||||
textureDesc.Width = rect->w;
|
||||
textureDesc.Height = rect->h;
|
||||
|
||||
|
@ -2278,7 +2230,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
D3D_CALL(textureData->stagingBuffer, Unmap, 0, NULL);
|
||||
|
||||
SDL_zero(textureDesc);
|
||||
D3D_CALL_RET_ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc);
|
||||
D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc);
|
||||
textureDesc.Width = textureData->lockedRect.w;
|
||||
textureDesc.Height = textureData->lockedRect.h;
|
||||
|
||||
|
@ -3068,7 +3020,7 @@ static SDL_Surface *D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
|||
|
||||
/* Create a staging texture to copy the screen's data to: */
|
||||
SDL_zero(textureDesc);
|
||||
D3D_CALL_RET_ID3D12Resource_GetDesc(backBuffer, &textureDesc);
|
||||
D3D_CALL_RET(backBuffer, GetDesc, &textureDesc);
|
||||
textureDesc.Width = rect->w;
|
||||
textureDesc.Height = rect->h;
|
||||
|
||||
|
|
Loading…
Reference in New Issue