Commit 4a86e3d4 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d11: Accept DXGI_FORMAT_UNKNOWN as format in view descriptions.

parent 05f6f111
......@@ -1282,7 +1282,7 @@ static void test_create_depthstencil_view(void)
memset(&dsv_desc, 0, sizeof(dsv_desc));
ID3D10DepthStencilView_GetDesc(dsview, &dsv_desc);
todo_wine ok(dsv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", dsv_desc.Format);
ok(dsv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", dsv_desc.Format);
ok(dsv_desc.ViewDimension == D3D10_DSV_DIMENSION_TEXTURE2D,
"Got unexpected view dimension %#x.\n", dsv_desc.ViewDimension);
ok(!U(dsv_desc).Texture2D.MipSlice, "Got unexpected mip slice %u.\n", U(dsv_desc).Texture2D.MipSlice);
......@@ -1493,7 +1493,7 @@ static void test_create_rendertarget_view(void)
memset(&rtv_desc, 0, sizeof(rtv_desc));
ID3D10RenderTargetView_GetDesc(rtview, &rtv_desc);
todo_wine ok(rtv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", rtv_desc.Format);
ok(rtv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", rtv_desc.Format);
ok(rtv_desc.ViewDimension == D3D10_RTV_DIMENSION_TEXTURE2D, "Got unexpected view dimension %#x.\n",
rtv_desc.ViewDimension);
ok(!U(rtv_desc).Texture2D.MipSlice, "Got unexpected mip slice %u.\n", U(rtv_desc).Texture2D.MipSlice);
......@@ -1762,7 +1762,7 @@ static void test_create_shader_resource_view(void)
memset(&srv_desc, 0, sizeof(srv_desc));
ID3D10ShaderResourceView_GetDesc(srview, &srv_desc);
todo_wine ok(srv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", srv_desc.Format);
ok(srv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", srv_desc.Format);
ok(srv_desc.ViewDimension == D3D10_SRV_DIMENSION_TEXTURE2D,
"Got unexpected view dimension %#x.\n", srv_desc.ViewDimension);
ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n",
......
......@@ -1808,7 +1808,7 @@ static void test_create_depthstencil_view(void)
memset(&dsv_desc, 0, sizeof(dsv_desc));
ID3D11DepthStencilView_GetDesc(dsview, &dsv_desc);
todo_wine ok(dsv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", dsv_desc.Format);
ok(dsv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", dsv_desc.Format);
ok(dsv_desc.ViewDimension == D3D11_DSV_DIMENSION_TEXTURE2D,
"Got unexpected view dimension %#x.\n", dsv_desc.ViewDimension);
ok(!dsv_desc.Flags, "Got unexpected flags %#x.\n", dsv_desc.Flags);
......@@ -2022,7 +2022,7 @@ static void test_create_rendertarget_view(void)
memset(&rtv_desc, 0, sizeof(rtv_desc));
ID3D11RenderTargetView_GetDesc(rtview, &rtv_desc);
todo_wine ok(rtv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", rtv_desc.Format);
ok(rtv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", rtv_desc.Format);
ok(rtv_desc.ViewDimension == D3D11_RTV_DIMENSION_TEXTURE2D, "Got unexpected view dimension %#x.\n",
rtv_desc.ViewDimension);
ok(!U(rtv_desc).Texture2D.MipSlice, "Got unexpected mip slice %u.\n", U(rtv_desc).Texture2D.MipSlice);
......@@ -2165,7 +2165,7 @@ static void test_create_shader_resource_view(void)
memset(&srv_desc, 0, sizeof(srv_desc));
ID3D11ShaderResourceView_GetDesc(srview, &srv_desc);
todo_wine ok(srv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", srv_desc.Format);
ok(srv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", srv_desc.Format);
ok(srv_desc.ViewDimension == D3D11_SRV_DIMENSION_TEXTURE2D,
"Got unexpected view dimension %#x.\n", srv_desc.ViewDimension);
ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n",
......
......@@ -121,6 +121,59 @@ 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;
ID3D11Resource_GetType(resource, &dimension);
switch (dimension)
{
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
{
D3D11_TEXTURE1D_DESC texture_desc;
ID3D11Texture1D *texture;
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture1D, (void **)&texture)))
{
ERR("Resource of type TEXTURE1D doesn't implement ID3D11Texture1D.\n");
break;
}
ID3D11Texture1D_GetDesc(texture, &texture_desc);
ID3D11Texture1D_Release(texture);
if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = texture_desc.Format;
break;
}
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{
D3D11_TEXTURE2D_DESC texture_desc;
ID3D11Texture2D *texture;
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture)))
{
ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D.\n");
break;
}
ID3D11Texture2D_GetDesc(texture, &texture_desc);
ID3D11Texture2D_Release(texture);
if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = texture_desc.Format;
break;
}
default:
break;
}
}
static HRESULT set_rtdesc_from_resource(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11Resource *resource)
{
D3D11_RESOURCE_DIMENSION dimension;
......@@ -240,6 +293,59 @@ static HRESULT set_rtdesc_from_resource(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3
}
}
static void normalize_rtv_desc(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11Resource *resource)
{
D3D11_RESOURCE_DIMENSION dimension;
if (desc->Format != DXGI_FORMAT_UNKNOWN)
return;
ID3D11Resource_GetType(resource, &dimension);
switch (dimension)
{
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
{
D3D11_TEXTURE1D_DESC texture_desc;
ID3D11Texture1D *texture;
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture1D, (void **)&texture)))
{
ERR("Resource of type TEXTURE1D doesn't implement ID3D11Texture1D.\n");
break;
}
ID3D11Texture1D_GetDesc(texture, &texture_desc);
ID3D11Texture1D_Release(texture);
if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = texture_desc.Format;
break;
}
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{
D3D11_TEXTURE2D_DESC texture_desc;
ID3D11Texture2D *texture;
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture)))
{
ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D.\n");
break;
}
ID3D11Texture2D_GetDesc(texture, &texture_desc);
ID3D11Texture2D_Release(texture);
if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = texture_desc.Format;
break;
}
default:
break;
}
}
static HRESULT set_srdesc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11Resource *resource)
{
D3D11_RESOURCE_DIMENSION dimension;
......@@ -359,6 +465,59 @@ static HRESULT set_srdesc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, I
}
}
static void normalize_srv_desc(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11Resource *resource)
{
D3D11_RESOURCE_DIMENSION dimension;
if (desc->Format != DXGI_FORMAT_UNKNOWN)
return;
ID3D11Resource_GetType(resource, &dimension);
switch (dimension)
{
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
{
D3D11_TEXTURE1D_DESC texture_desc;
ID3D11Texture1D *texture;
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture1D, (void **)&texture)))
{
ERR("Resource of type TEXTURE1D doesn't implement ID3D11Texture1D.\n");
break;
}
ID3D11Texture1D_GetDesc(texture, &texture_desc);
ID3D11Texture1D_Release(texture);
if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = texture_desc.Format;
break;
}
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{
D3D11_TEXTURE2D_DESC texture_desc;
ID3D11Texture2D *texture;
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture)))
{
ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D.\n");
break;
}
ID3D11Texture2D_GetDesc(texture, &texture_desc);
ID3D11Texture2D_Release(texture);
if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = texture_desc.Format;
break;
}
default:
break;
}
}
/* ID3D11DepthStencilView methods */
static inline struct d3d_depthstencil_view *impl_from_ID3D11DepthStencilView(ID3D11DepthStencilView *iface)
......@@ -706,6 +865,7 @@ static HRESULT d3d_depthstencil_view_init(struct d3d_depthstencil_view *view, st
else
{
view->desc = *desc;
normalize_dsv_desc(&view->desc, resource);
}
wined3d_mutex_lock();
......@@ -1121,12 +1281,13 @@ static HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, st
if (!desc)
{
HRESULT hr = set_rtdesc_from_resource(&view->desc, resource);
if (FAILED(hr)) return hr;
if (FAILED(hr = set_rtdesc_from_resource(&view->desc, resource)))
return hr;
}
else
{
view->desc = *desc;
normalize_rtv_desc(&view->desc, resource);
}
wined3d_mutex_lock();
......@@ -1498,13 +1659,14 @@ static HRESULT d3d_shader_resource_view_init(struct d3d_shader_resource_view *vi
else
{
view->desc = *desc;
normalize_srv_desc(&view->desc, resource);
}
wined3d_mutex_lock();
if (!(wined3d_resource = wined3d_resource_from_d3d11_resource(resource)))
{
wined3d_mutex_unlock();
ERR("Failed to get wined3d resource for d3d10 resource %p.\n", resource);
ERR("Failed to get wined3d resource for d3d11 resource %p.\n", resource);
return E_FAIL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment