summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2016-03-15 21:53:09 +1000
committerStenzek <stenzek@gmail.com>2016-05-08 23:18:58 +1000
commitfde7dee652674f3d42d80e2f4a3ae0ff30ecaa06 (patch)
treeb485dc8d429f633f9e80723a7e18ba557c8d11e8 /Source/Core/VideoBackends
parent9bff1875479c4b31e93350a44e25f6cb154894f1 (diff)
D3D12: Fix invalid CopyTextureRegion call in CopyRectangleFromTexture
This was occuring when the source texture was larger than the destination texture, but the source rect was <= dest rect, so the copy is valid.
Diffstat (limited to 'Source/Core/VideoBackends')
-rw-r--r--Source/Core/VideoBackends/D3D12/TextureCache.cpp35
1 files changed, 13 insertions, 22 deletions
diff --git a/Source/Core/VideoBackends/D3D12/TextureCache.cpp b/Source/Core/VideoBackends/D3D12/TextureCache.cpp
index a52d0e540e..ceabf01734 100644
--- a/Source/Core/VideoBackends/D3D12/TextureCache.cpp
+++ b/Source/Core/VideoBackends/D3D12/TextureCache.cpp
@@ -106,33 +106,24 @@ void TextureCache::TCacheEntry::CopyRectangleFromTexture(
if (src_rect.GetWidth() == dst_rect.GetWidth()
&& src_rect.GetHeight() == dst_rect.GetHeight())
{
- D3D12_BOX srcbox;
- srcbox.left = src_rect.left;
- srcbox.top = src_rect.top;
- srcbox.right = src_rect.right;
- srcbox.bottom = src_rect.bottom;
- srcbox.front = 0;
- srcbox.back = srcentry->config.layers;
-
- if (static_cast<u32>(src_rect.GetHeight()) > config.height ||
- static_cast<u32>(src_rect.GetWidth()) > config.width)
- {
- // To mimic D3D11 behavior, we're just going to drop the clear since it is invalid.
- // This invalid copy needs to be fixed above the Backend level.
-
- // On D3D12, instead of silently dropping this invalid clear, the runtime throws an exception
- // so we need to filter it out ourselves.
-
- return;
- }
-
+ // These assertions should hold true unless the base code is passing us sizes too large, in which case it should be fixed instead.
+ _assert_msg_(VIDEO,
+ static_cast<u32>(src_rect.GetWidth()) <= source->config.width &&
+ static_cast<u32>(src_rect.GetHeight()) <= source->config.height,
+ "Source rect is too large for CopyRectangleFromTexture");
+
+ _assert_msg_(VIDEO,
+ static_cast<u32>(dst_rect.GetWidth()) <= config.width &&
+ static_cast<u32>(dst_rect.GetHeight()) <= config.height,
+ "Dest rect is too large for CopyRectangleFromTexture");
+
+ CD3DX12_BOX src_box(src_rect.left, src_rect.top, 0, src_rect.right, src_rect.bottom, srcentry->config.layers);
D3D12_TEXTURE_COPY_LOCATION dst_location = CD3DX12_TEXTURE_COPY_LOCATION(m_texture->GetTex12(), 0);
D3D12_TEXTURE_COPY_LOCATION src_location = CD3DX12_TEXTURE_COPY_LOCATION(srcentry->m_texture->GetTex12(), 0);
m_texture->TransitionToResourceState(D3D::current_command_list, D3D12_RESOURCE_STATE_COPY_DEST);
srcentry->m_texture->TransitionToResourceState(D3D::current_command_list, D3D12_RESOURCE_STATE_COPY_SOURCE);
-
- D3D::current_command_list->CopyTextureRegion(&dst_location, dst_rect.left, dst_rect.top, 0, &src_location, &srcbox);
+ D3D::current_command_list->CopyTextureRegion(&dst_location, dst_rect.left, dst_rect.top, 0, &src_location, &src_box);
m_texture->TransitionToResourceState(D3D::current_command_list, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
srcentry->m_texture->TransitionToResourceState(D3D::current_command_list, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);