=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3d11: Validate "ViewDimension" field in D3D11_DEPTH_STENCIL_VIEW_DESC.
Alexandre Julliard
julliard at winehq.org
Thu Jun 16 10:20:56 CDT 2016
Module: wine
Branch: master
Commit: 0626559c531e70d98023a082d4f600234d3394af
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0626559c531e70d98023a082d4f600234d3394af
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Thu Jun 16 11:59:38 2016 +0200
d3d11: Validate "ViewDimension" field in D3D11_DEPTH_STENCIL_VIEW_DESC.
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>
---
dlls/d3d11/view.c | 43 +++++++++++++++++++++++++++++++++++++------
1 file changed, 37 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d11/view.c b/dlls/d3d11/view.c
index 905996d..2210394 100644
--- a/dlls/d3d11/view.c
+++ b/dlls/d3d11/view.c
@@ -121,7 +121,7 @@ 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)
+static HRESULT normalize_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Resource *resource)
{
D3D11_RESOURCE_DIMENSION dimension;
unsigned int layer_count;
@@ -130,14 +130,36 @@ static void normalize_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Resour
ID3D11Resource_GetType(resource, &dimension);
switch (dimension)
{
+ case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
+ {
+ if (desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE1D
+ && desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE1DARRAY)
+ {
+ WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension);
+ return E_INVALIDARG;
+ }
+
+ FIXME("Unhandled 1D texture resource.\n");
+ return S_OK;
+ }
+
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{
const struct d3d_texture2d *texture;
+ if (desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE2D
+ && desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE2DARRAY
+ && desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE2DMS
+ && desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY)
+ {
+ WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension);
+ return E_INVALIDARG;
+ }
+
if (!(texture = unsafe_impl_from_ID3D11Texture2D((ID3D11Texture2D *)resource)))
{
ERR("Cannot get implementation from ID3D11Texture2D.\n");
- return;
+ return E_FAIL;
}
format = texture->desc.Format;
@@ -145,8 +167,14 @@ static void normalize_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Resour
break;
}
+ case D3D11_RESOURCE_DIMENSION_BUFFER:
+ case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
+ WARN("Invalid resource dimension %#x.\n", dimension);
+ return E_INVALIDARG;
+
default:
- return;
+ ERR("Unhandled resource dimension %#x.\n", dimension);
+ return E_FAIL;
}
if (desc->Format == DXGI_FORMAT_UNKNOWN)
@@ -172,6 +200,8 @@ static void normalize_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Resour
default:
break;
}
+
+ return S_OK;
}
static HRESULT set_rtdesc_from_resource(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11Resource *resource)
@@ -972,14 +1002,15 @@ static HRESULT d3d_depthstencil_view_init(struct d3d_depthstencil_view *view, st
if (!desc)
{
- if (FAILED(hr = set_dsdesc_from_resource(&view->desc, resource)))
- return hr;
+ hr = set_dsdesc_from_resource(&view->desc, resource);
}
else
{
view->desc = *desc;
- normalize_dsv_desc(&view->desc, resource);
+ hr = normalize_dsv_desc(&view->desc, resource);
}
+ if (FAILED(hr))
+ return hr;
wined3d_mutex_lock();
if (!(wined3d_resource = wined3d_resource_from_d3d11_resource(resource)))
More information about the wine-cvs
mailing list