|
@@ -123,9 +123,7 @@ typedef struct
|
|
|
|
|
|
/* NV12 texture support */
|
|
|
SDL_bool nv12;
|
|
|
- ID3D12Resource *mainTextureNV;
|
|
|
D3D12_CPU_DESCRIPTOR_HANDLE mainTextureResourceViewNV;
|
|
|
- D3D12_RESOURCE_STATES mainResourceStateNV;
|
|
|
SIZE_T mainSRVIndexNV;
|
|
|
|
|
|
Uint8 *pixels;
|
|
@@ -257,6 +255,7 @@ static const GUID SDL_IID_ID3D12DescriptorHeap = { 0x8efb471d, 0x616c, 0x4f49, {
|
|
|
static const GUID SDL_IID_ID3D12CommandAllocator = { 0x6102dee4, 0xaf59, 0x4b09, { 0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24 } };
|
|
|
static const GUID SDL_IID_ID3D12GraphicsCommandList2 = { 0x38C3E585, 0xFF17, 0x412C, { 0x91, 0x50, 0x4F, 0xC6, 0xF9, 0xD7, 0x2A, 0x28 } };
|
|
|
static const GUID SDL_IID_ID3D12Fence = { 0x0a753dcf, 0xc4d8, 0x4b91, { 0xad, 0xf6, 0xbe, 0x5a, 0x60, 0xd9, 0x5a, 0x76 } };
|
|
|
+static const GUID SDL_IID_IDXGIResource = { 0x035f3ab4, 0x482e, 0x4e50, { 0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b } };
|
|
|
static const GUID SDL_IID_ID3D12Resource = { 0x696442be, 0xa72e, 0x4059, { 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad } };
|
|
|
static const GUID SDL_IID_ID3D12RootSignature = { 0xc54a6b66, 0x72df, 0x4ee8, { 0x8b, 0xe5, 0xa9, 0x46, 0xa1, 0x42, 0x92, 0x14 } };
|
|
|
static const GUID SDL_IID_ID3D12PipelineState = { 0x765a30f3, 0xf624, 0x4c6f, { 0xa8, 0x28, 0xac, 0xe9, 0x48, 0x62, 0x24, 0x45 } };
|
|
@@ -284,7 +283,25 @@ Uint32 D3D12_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static DXGI_FORMAT SDLPixelFormatToDXGIFormat(Uint32 sdlFormat)
|
|
|
+static DXGI_FORMAT SDLPixelFormatToDXGITextureFormat(Uint32 sdlFormat)
|
|
|
+{
|
|
|
+ switch (sdlFormat) {
|
|
|
+ case SDL_PIXELFORMAT_ARGB8888:
|
|
|
+ return DXGI_FORMAT_B8G8R8A8_UNORM;
|
|
|
+ case SDL_PIXELFORMAT_XRGB8888:
|
|
|
+ return DXGI_FORMAT_B8G8R8X8_UNORM;
|
|
|
+ case SDL_PIXELFORMAT_YV12:
|
|
|
+ case SDL_PIXELFORMAT_IYUV:
|
|
|
+ return DXGI_FORMAT_R8_UNORM;
|
|
|
+ case SDL_PIXELFORMAT_NV12:
|
|
|
+ case SDL_PIXELFORMAT_NV21:
|
|
|
+ return DXGI_FORMAT_NV12;
|
|
|
+ default:
|
|
|
+ return DXGI_FORMAT_UNKNOWN;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static DXGI_FORMAT SDLPixelFormatToDXGIMainResourceViewFormat(Uint32 sdlFormat)
|
|
|
{
|
|
|
switch (sdlFormat) {
|
|
|
case SDL_PIXELFORMAT_ARGB8888:
|
|
@@ -703,7 +720,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
|
|
|
HRESULT result = S_OK;
|
|
|
UINT creationFlags = 0;
|
|
|
int i, j, k, l;
|
|
|
- SDL_bool createDebug = SDL_FALSE;
|
|
|
+ SDL_bool createDebug;
|
|
|
|
|
|
D3D12_COMMAND_QUEUE_DESC queueDesc;
|
|
|
D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc;
|
|
@@ -1417,7 +1434,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|
|
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
|
|
D3D12_TextureData *textureData;
|
|
|
HRESULT result;
|
|
|
- DXGI_FORMAT textureFormat = SDLPixelFormatToDXGIFormat(texture->format);
|
|
|
+ DXGI_FORMAT textureFormat = SDLPixelFormatToDXGITextureFormat(texture->format);
|
|
|
D3D12_RESOURCE_DESC textureDesc;
|
|
|
D3D12_HEAP_PROPERTIES heapProps;
|
|
|
D3D12_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
|
|
@@ -1508,34 +1525,13 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|
|
|
|
|
if (texture->format == SDL_PIXELFORMAT_NV12 ||
|
|
|
texture->format == SDL_PIXELFORMAT_NV21) {
|
|
|
- D3D12_RESOURCE_DESC nvTextureDesc = textureDesc;
|
|
|
-
|
|
|
textureData->nv12 = SDL_TRUE;
|
|
|
-
|
|
|
- nvTextureDesc.Format = DXGI_FORMAT_R8G8_UNORM;
|
|
|
- nvTextureDesc.Width = (textureDesc.Width + 1) / 2;
|
|
|
- nvTextureDesc.Height = (textureDesc.Height + 1) / 2;
|
|
|
-
|
|
|
- result = D3D_CALL(rendererData->d3dDevice, CreateCommittedResource,
|
|
|
- &heapProps,
|
|
|
- D3D12_HEAP_FLAG_NONE,
|
|
|
- &nvTextureDesc,
|
|
|
- D3D12_RESOURCE_STATE_COPY_DEST,
|
|
|
- NULL,
|
|
|
- D3D_GUID(SDL_IID_ID3D12Resource),
|
|
|
- (void **)&textureData->mainTextureNV);
|
|
|
- textureData->mainResourceStateNV = D3D12_RESOURCE_STATE_COPY_DEST;
|
|
|
- if (FAILED(result)) {
|
|
|
- D3D12_DestroyTexture(renderer, texture);
|
|
|
- return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateTexture2D"), result);
|
|
|
- }
|
|
|
}
|
|
|
#endif /* SDL_HAVE_YUV */
|
|
|
SDL_zero(resourceViewDesc);
|
|
|
resourceViewDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
|
|
- resourceViewDesc.Format = textureDesc.Format;
|
|
|
+ resourceViewDesc.Format = SDLPixelFormatToDXGIMainResourceViewFormat(texture->format);
|
|
|
resourceViewDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
|
|
- resourceViewDesc.Texture2D.MostDetailedMip = 0;
|
|
|
resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
|
|
|
|
|
|
textureData->mainSRVIndex = D3D12_GetAvailableSRVIndex(renderer);
|
|
@@ -1569,12 +1565,13 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|
|
D3D12_SHADER_RESOURCE_VIEW_DESC nvResourceViewDesc = resourceViewDesc;
|
|
|
|
|
|
nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM;
|
|
|
+ nvResourceViewDesc.Texture2D.PlaneSlice = 1;
|
|
|
|
|
|
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,
|
|
|
- textureData->mainTextureNV,
|
|
|
+ textureData->mainTexture,
|
|
|
&nvResourceViewDesc,
|
|
|
textureData->mainTextureResourceViewNV);
|
|
|
}
|
|
@@ -1623,8 +1620,7 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer,
|
|
|
D3D12_FreeSRVIndex(renderer, textureData->mainSRVIndexU);
|
|
|
D3D12_FreeSRVIndex(renderer, textureData->mainSRVIndexV);
|
|
|
}
|
|
|
- SAFE_RELEASE(textureData->mainTextureNV);
|
|
|
- if (textureData->yuv) {
|
|
|
+ if (textureData->nv12) {
|
|
|
D3D12_FreeSRVIndex(renderer, textureData->mainSRVIndexNV);
|
|
|
}
|
|
|
SDL_free(textureData->pixels);
|
|
@@ -1633,22 +1629,22 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer,
|
|
|
texture->driverdata = NULL;
|
|
|
}
|
|
|
|
|
|
-static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Resource *texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch, D3D12_RESOURCE_STATES *resourceState)
|
|
|
+static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Resource *texture, int plane, int x, int y, int w, int h, const void *pixels, int pitch, D3D12_RESOURCE_STATES *resourceState)
|
|
|
{
|
|
|
const Uint8 *src;
|
|
|
Uint8 *dst;
|
|
|
- int row;
|
|
|
UINT length;
|
|
|
HRESULT result;
|
|
|
D3D12_RESOURCE_DESC textureDesc;
|
|
|
D3D12_RESOURCE_DESC uploadDesc;
|
|
|
D3D12_HEAP_PROPERTIES heapProps;
|
|
|
- D3D12_SUBRESOURCE_FOOTPRINT pitchedDesc;
|
|
|
D3D12_PLACED_SUBRESOURCE_FOOTPRINT placedTextureDesc;
|
|
|
D3D12_TEXTURE_COPY_LOCATION srcLocation;
|
|
|
D3D12_TEXTURE_COPY_LOCATION dstLocation;
|
|
|
BYTE *textureMemory;
|
|
|
ID3D12Resource *uploadBuffer;
|
|
|
+ UINT row, NumRows, RowPitch;
|
|
|
+ UINT64 RowLength;
|
|
|
|
|
|
/* Create an upload buffer, which will be used to write to the main texture. */
|
|
|
SDL_zero(textureDesc);
|
|
@@ -1671,13 +1667,14 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res
|
|
|
/* Figure out how much we need to allocate for the upload buffer */
|
|
|
D3D_CALL(rendererData->d3dDevice, GetCopyableFootprints,
|
|
|
&textureDesc,
|
|
|
- 0,
|
|
|
+ plane,
|
|
|
1,
|
|
|
0,
|
|
|
- NULL,
|
|
|
- NULL,
|
|
|
- NULL,
|
|
|
+ &placedTextureDesc,
|
|
|
+ &NumRows,
|
|
|
+ &RowLength,
|
|
|
&uploadDesc.Width);
|
|
|
+ RowPitch = placedTextureDesc.Footprint.RowPitch;
|
|
|
|
|
|
SDL_zero(heapProps);
|
|
|
heapProps.Type = D3D12_HEAP_TYPE_UPLOAD;
|
|
@@ -1708,33 +1705,22 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res
|
|
|
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Resource::Map [map staging texture]"), result);
|
|
|
}
|
|
|
|
|
|
- SDL_zero(pitchedDesc);
|
|
|
- pitchedDesc.Format = textureDesc.Format;
|
|
|
- pitchedDesc.Width = w;
|
|
|
- pitchedDesc.Height = h;
|
|
|
- pitchedDesc.Depth = 1;
|
|
|
- pitchedDesc.RowPitch = D3D12_Align(w * bpp, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
|
|
|
-
|
|
|
- SDL_zero(placedTextureDesc);
|
|
|
- placedTextureDesc.Offset = 0;
|
|
|
- placedTextureDesc.Footprint = pitchedDesc;
|
|
|
-
|
|
|
src = (const Uint8 *)pixels;
|
|
|
dst = textureMemory;
|
|
|
- length = w * bpp;
|
|
|
- if (length == (UINT)pitch && length == pitchedDesc.RowPitch) {
|
|
|
- SDL_memcpy(dst, src, (size_t)length * h);
|
|
|
+ length = RowLength;
|
|
|
+ if (length == (UINT)pitch && length == RowPitch) {
|
|
|
+ SDL_memcpy(dst, src, (size_t)length * NumRows);
|
|
|
} else {
|
|
|
if (length > (UINT)pitch) {
|
|
|
length = pitch;
|
|
|
}
|
|
|
- if (length > pitchedDesc.RowPitch) {
|
|
|
- length = pitchedDesc.RowPitch;
|
|
|
+ if (length > RowPitch) {
|
|
|
+ length = RowPitch;
|
|
|
}
|
|
|
- for (row = 0; row < h; ++row) {
|
|
|
+ for (row = NumRows; row--; ) {
|
|
|
SDL_memcpy(dst, src, length);
|
|
|
src += pitch;
|
|
|
- dst += pitchedDesc.RowPitch;
|
|
|
+ dst += RowPitch;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1748,7 +1734,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res
|
|
|
SDL_zero(dstLocation);
|
|
|
dstLocation.pResource = texture;
|
|
|
dstLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
|
|
- dstLocation.SubresourceIndex = 0;
|
|
|
+ dstLocation.SubresourceIndex = plane;
|
|
|
|
|
|
SDL_zero(srcLocation);
|
|
|
srcLocation.pResource = rendererData->uploadBuffers[rendererData->currentUploadBuffer];
|
|
@@ -1787,7 +1773,7 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|
|
return SDL_SetError("Texture is not currently available");
|
|
|
}
|
|
|
|
|
|
- if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainResourceState) < 0) {
|
|
|
+ if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainResourceState) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
#if SDL_HAVE_YUV
|
|
@@ -1795,13 +1781,13 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|
|
/* Skip to the correct offset into the next texture */
|
|
|
srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch);
|
|
|
|
|
|
- if (D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateV : &textureData->mainResourceStateU) < 0) {
|
|
|
+ if (D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, 0, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateV : &textureData->mainResourceStateU) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
/* Skip to the correct offset into the next texture */
|
|
|
srcPixels = (const void *)((const Uint8 *)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2));
|
|
|
- if (D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateU : &textureData->mainResourceStateV) < 0) {
|
|
|
+ if (D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, 0, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateU : &textureData->mainResourceStateV) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
@@ -1810,7 +1796,7 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|
|
/* Skip to the correct offset into the next texture */
|
|
|
srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch);
|
|
|
|
|
|
- if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, srcPixels, 2 * ((srcPitch + 1) / 2), &textureData->mainResourceStateNV) < 0) {
|
|
|
+ if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 1, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainResourceState) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
@@ -1832,13 +1818,13 @@ static int D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
|
|
return SDL_SetError("Texture is not currently available");
|
|
|
}
|
|
|
|
|
|
- if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainResourceState) < 0) {
|
|
|
+ if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainResourceState) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
- if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch, &textureData->mainResourceStateU) < 0) {
|
|
|
+ if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureU, 0, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch, &textureData->mainResourceStateU) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
- if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch, &textureData->mainResourceStateV) < 0) {
|
|
|
+ if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureV, 0, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch, &textureData->mainResourceStateV) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
return 0;
|
|
@@ -1856,11 +1842,11 @@ static int D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
|
|
return SDL_SetError("Texture is not currently available");
|
|
|
}
|
|
|
|
|
|
- if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainResourceState) < 0) {
|
|
|
+ if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainResourceState) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, UVplane, UVpitch, &textureData->mainResourceStateNV) < 0) {
|
|
|
+ if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 1, rect->x, rect->y, rect->w, rect->h, UVplane, UVpitch, &textureData->mainResourceState) < 0) {
|
|
|
return -1;
|
|
|
}
|
|
|
return 0;
|
|
@@ -2078,6 +2064,25 @@ static void D3D12_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu
|
|
|
textureData->scaleMode = (scaleMode == SDL_SCALEMODE_NEAREST) ? D3D12_FILTER_MIN_MAG_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
|
|
}
|
|
|
|
|
|
+static IDXGIResource *D3D12_GetTextureDXGIResource(SDL_Texture *texture)
|
|
|
+{
|
|
|
+ D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
|
|
+ IDXGIResource *resource = NULL;
|
|
|
+ HRESULT result;
|
|
|
+
|
|
|
+ if (textureData == NULL || textureData->mainTexture == NULL) {
|
|
|
+ SDL_SetError("Texture is not currently available");
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ result = D3D_CALL(textureData->mainTexture, QueryInterface, D3D_GUID(SDL_IID_IDXGIResource), (void **)&resource);
|
|
|
+ if (FAILED(result)) {
|
|
|
+ WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("GetTextureDXGIResource"), result);
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+ return resource;
|
|
|
+}
|
|
|
+
|
|
|
static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
|
|
{
|
|
|
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
|
@@ -2550,8 +2555,6 @@ static int D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
|
|
/* Make sure each texture is in the correct state to be accessed by the pixel shader. */
|
|
|
D3D12_TransitionResource(rendererData, textureData->mainTexture, textureData->mainResourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
|
|
textureData->mainResourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
|
|
- D3D12_TransitionResource(rendererData, textureData->mainTextureNV, textureData->mainResourceStateNV, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
|
|
- textureData->mainResourceStateNV = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
|
|
|
|
|
return D3D12_SetDrawState(renderer, cmd, shader, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, SDL_arraysize(shaderResources), shaderResources,
|
|
|
textureSampler, matrix);
|
|
@@ -2979,6 +2982,7 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|
|
renderer->LockTexture = D3D12_LockTexture;
|
|
|
renderer->UnlockTexture = D3D12_UnlockTexture;
|
|
|
renderer->SetTextureScaleMode = D3D12_SetTextureScaleMode;
|
|
|
+ renderer->GetTextureDXGIResource = D3D12_GetTextureDXGIResource;
|
|
|
renderer->SetRenderTarget = D3D12_SetRenderTarget;
|
|
|
renderer->QueueSetViewport = D3D12_QueueSetViewport;
|
|
|
renderer->QueueSetDrawColor = D3D12_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|