Commit 723f73ae authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d11: Normalize "ArraySize" field in D3D11_RENDER_TARGET_VIEW_DESC.

parent cc9b4d8a
...@@ -282,7 +282,7 @@ static HRESULT set_rtdesc_from_resource(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3 ...@@ -282,7 +282,7 @@ static HRESULT set_rtdesc_from_resource(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3
desc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D; desc->ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
desc->u.Texture3D.MipSlice = 0; desc->u.Texture3D.MipSlice = 0;
desc->u.Texture3D.FirstWSlice = 0; desc->u.Texture3D.FirstWSlice = 0;
desc->u.Texture3D.WSize = 1; desc->u.Texture3D.WSize = texture_desc.Depth;
return S_OK; return S_OK;
} }
...@@ -296,50 +296,71 @@ static HRESULT set_rtdesc_from_resource(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3 ...@@ -296,50 +296,71 @@ 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) static void normalize_rtv_desc(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11Resource *resource)
{ {
D3D11_RESOURCE_DIMENSION dimension; D3D11_RESOURCE_DIMENSION dimension;
unsigned int layer_count;
if (desc->Format != DXGI_FORMAT_UNKNOWN) DXGI_FORMAT format;
return;
ID3D11Resource_GetType(resource, &dimension); ID3D11Resource_GetType(resource, &dimension);
switch (dimension) switch (dimension)
{ {
case D3D11_RESOURCE_DIMENSION_TEXTURE1D: case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{ {
D3D11_TEXTURE1D_DESC texture_desc; const struct d3d_texture2d *texture;
ID3D11Texture1D *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"); ERR("Cannot get implementation from ID3D11Texture2D.\n");
break; return;
} }
ID3D11Texture1D_GetDesc(texture, &texture_desc); format = texture->desc.Format;
ID3D11Texture1D_Release(texture); layer_count = texture->desc.ArraySize;
if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = texture_desc.Format;
break; break;
} }
case D3D11_RESOURCE_DIMENSION_TEXTURE2D: case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
{ {
D3D11_TEXTURE2D_DESC texture_desc; const struct d3d_texture3d *texture;
ID3D11Texture2D *texture;
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture))) if (!(texture = unsafe_impl_from_ID3D11Texture3D((ID3D11Texture3D *)resource)))
{ {
ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D.\n"); ERR("Cannot get implementation from ID3D11Texture3D.\n");
return;
}
format = texture->desc.Format;
layer_count = texture->desc.Depth;
break; break;
} }
ID3D11Texture2D_GetDesc(texture, &texture_desc); default:
ID3D11Texture2D_Release(texture); return;
}
if (desc->Format == DXGI_FORMAT_UNKNOWN) if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = texture_desc.Format; desc->Format = format;
switch (desc->ViewDimension)
{
case D3D11_RTV_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_RTV_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;
case D3D11_RTV_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;
case D3D11_RTV_DIMENSION_TEXTURE3D:
layer_count = max(1, layer_count >> desc->u.Texture3D.MipSlice);
if (desc->u.Texture3D.WSize == -1 && desc->u.Texture3D.FirstWSlice < layer_count)
desc->u.Texture3D.WSize = layer_count - desc->u.Texture3D.FirstWSlice;
break; break;
}
default: default:
break; break;
......
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