[PATCH 5/7] d3d11: Normalize "ArraySize" field in D3D11_DEPTH_STENCIL_VIEW_DESC.

Józef Kucia jkucia at codeweavers.com
Wed Jun 8 07:55:00 CDT 2016


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/d3d11/view.c | 56 +++++++++++++++++++++++++++----------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/dlls/d3d11/view.c b/dlls/d3d11/view.c
index 5a2ef39..7f5abf7 100644
--- a/dlls/d3d11/view.c
+++ b/dlls/d3d11/view.c
@@ -124,50 +124,50 @@ static HRESULT set_dsdesc_from_resource(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3
 static void normalize_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Resource *resource)
 {
     D3D11_RESOURCE_DIMENSION dimension;
-
-    if (desc->Format != DXGI_FORMAT_UNKNOWN)
-        return;
+    unsigned int layer_count;
+    DXGI_FORMAT format;
 
     ID3D11Resource_GetType(resource, &dimension);
     switch (dimension)
     {
-        case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
+        case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
         {
-            D3D11_TEXTURE1D_DESC texture_desc;
-            ID3D11Texture1D *texture;
+            const struct d3d_texture2d *texture;
 
-            if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture1D, (void **)&texture)))
+            if (!(texture = unsafe_impl_from_ID3D11Texture2D((ID3D11Texture2D *)resource)))
             {
-                ERR("Resource of type TEXTURE1D doesn't implement ID3D11Texture1D.\n");
-                break;
+                ERR("Cannot get implementation from ID3D11Texture2D.\n");
+                return;
             }
 
-            ID3D11Texture1D_GetDesc(texture, &texture_desc);
-            ID3D11Texture1D_Release(texture);
-
-            if (desc->Format == DXGI_FORMAT_UNKNOWN)
-                desc->Format = texture_desc.Format;
+            format = texture->desc.Format;
+            layer_count = texture->desc.ArraySize;
             break;
         }
 
-        case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
-        {
-            D3D11_TEXTURE2D_DESC texture_desc;
-            ID3D11Texture2D *texture;
+        default:
+            return;
+    }
 
-            if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture)))
-            {
-                ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D.\n");
-                break;
-            }
+    if (desc->Format == DXGI_FORMAT_UNKNOWN)
+        desc->Format = format;
 
-            ID3D11Texture2D_GetDesc(texture, &texture_desc);
-            ID3D11Texture2D_Release(texture);
+    switch (desc->ViewDimension)
+    {
+        case D3D11_DSV_DIMENSION_TEXTURE1DARRAY:
+            if (desc->u.Texture1DArray.ArraySize == -1 && desc->u.Texture1DArray.FirstArraySlice < layer_count)
+                desc->u.Texture1DArray.ArraySize = layer_count - desc->u.Texture1DArray.ArraySize;
+            break;
+
+        case D3D11_DSV_DIMENSION_TEXTURE2DARRAY:
+            if (desc->u.Texture2DArray.ArraySize == -1 && desc->u.Texture2DArray.FirstArraySlice < layer_count)
+                desc->u.Texture2DArray.ArraySize = layer_count - desc->u.Texture2DArray.FirstArraySlice;
+            break;
 
-            if (desc->Format == DXGI_FORMAT_UNKNOWN)
-                desc->Format = texture_desc.Format;
+        case D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY:
+            if (desc->u.Texture2DMSArray.ArraySize == -1 && desc->u.Texture2DMSArray.FirstArraySlice < layer_count)
+                desc->u.Texture2DMSArray.ArraySize = layer_count - desc->u.Texture2DMSArray.FirstArraySlice;
             break;
-        }
 
         default:
             break;
-- 
2.7.3




More information about the wine-patches mailing list