=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Allow D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT only for small textures.

Alexandre Julliard julliard at winehq.org
Tue Jan 22 14:43:48 CST 2019


Module: vkd3d
Branch: master
Commit: 39eb9fe5d86f82311b922204947879539dd62ad5
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=39eb9fe5d86f82311b922204947879539dd62ad5

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Fri Jan 18 10:25:48 2019 +0100

vkd3d: Allow D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT only for small textures.

Use a simple heuristic to decide if a resource is "small". The heuristic
is based on theoretical constraints for the most detailed mip level of
small resources. Those constraints are mentioned in D3D12 validation
layer errors and in the DirectX 12 Graphics samples.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d/device.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 7c20062..7a6dcb6 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -2076,6 +2076,7 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
 {
     UINT64 default_alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
     struct d3d12_device *device = impl_from_ID3D12Device(iface);
+    const struct vkd3d_format *format;
     const D3D12_RESOURCE_DESC *desc;
     bool valid = true;
 
@@ -2118,7 +2119,26 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
             valid = false;
         }
 
-        info->Alignment = max(info->Alignment, D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT);
+        if (valid && info->Alignment < D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
+        {
+            if ((format = vkd3d_format_from_d3d12_resource_desc(desc, 0)))
+            {
+                if (desc->Width * desc->Height * desc->DepthOrArraySize * format->byte_count
+                        >  D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
+                {
+                    info->Alignment = max(info->Alignment, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT);
+                }
+                else
+                {
+                    info->Alignment = max(info->Alignment, D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT);
+                }
+            }
+            else
+            {
+                WARN("Invalid format %#x.\n", desc->Format);
+                valid = false;
+            }
+        }
     }
 
     if (valid && desc->Alignment % info->Alignment)




More information about the wine-cvs mailing list