Commit 696cd4bd authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d11: Normalize more fields in SRV descriptions.

parent 9bbf3ca0
...@@ -1774,7 +1774,7 @@ static void test_create_shader_resource_view(void) ...@@ -1774,7 +1774,7 @@ static void test_create_shader_resource_view(void)
"Got unexpected view dimension %#x.\n", srv_desc.ViewDimension); "Got unexpected view dimension %#x.\n", srv_desc.ViewDimension);
ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n", ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n",
U(srv_desc).Texture2D.MostDetailedMip); U(srv_desc).Texture2D.MostDetailedMip);
todo_wine ok(U(srv_desc).Texture2D.MipLevels == 10, "Got unexpected MipLevels %u.\n", ok(U(srv_desc).Texture2D.MipLevels == 10, "Got unexpected MipLevels %u.\n",
U(srv_desc).Texture2D.MipLevels); U(srv_desc).Texture2D.MipLevels);
ID3D10ShaderResourceView_Release(srview); ID3D10ShaderResourceView_Release(srview);
......
...@@ -2197,7 +2197,7 @@ static void test_create_shader_resource_view(void) ...@@ -2197,7 +2197,7 @@ static void test_create_shader_resource_view(void)
"Got unexpected view dimension %#x.\n", srv_desc.ViewDimension); "Got unexpected view dimension %#x.\n", srv_desc.ViewDimension);
ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n", ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n",
U(srv_desc).Texture2D.MostDetailedMip); U(srv_desc).Texture2D.MostDetailedMip);
todo_wine ok(U(srv_desc).Texture2D.MipLevels == 10, "Got unexpected MipLevels %u.\n", ok(U(srv_desc).Texture2D.MipLevels == 10, "Got unexpected MipLevels %u.\n",
U(srv_desc).Texture2D.MipLevels); U(srv_desc).Texture2D.MipLevels);
ID3D11ShaderResourceView_Release(srview); ID3D11ShaderResourceView_Release(srview);
......
...@@ -467,53 +467,82 @@ static HRESULT set_srdesc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, I ...@@ -467,53 +467,82 @@ 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) static void normalize_srv_desc(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11Resource *resource)
{ {
unsigned int miplevel_count, layer_count;
D3D11_RESOURCE_DIMENSION dimension; D3D11_RESOURCE_DIMENSION dimension;
DXGI_FORMAT format;
if (desc->Format != DXGI_FORMAT_UNKNOWN)
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); miplevel_count = texture->desc.MipLevels;
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");
break; return;
} }
ID3D11Texture2D_GetDesc(texture, &texture_desc); format = texture->desc.Format;
ID3D11Texture2D_Release(texture); miplevel_count = texture->desc.MipLevels;
layer_count = 1;
if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = texture_desc.Format;
break; break;
} }
default: default:
return;
}
if (desc->Format == DXGI_FORMAT_UNKNOWN)
desc->Format = format;
switch (desc->ViewDimension)
{
case D3D11_SRV_DIMENSION_TEXTURE1D:
if (desc->u.Texture1D.MipLevels == -1 && desc->u.Texture1D.MostDetailedMip < miplevel_count)
desc->u.Texture1D.MipLevels = miplevel_count - desc->u.Texture1D.MostDetailedMip;
break;
case D3D11_SRV_DIMENSION_TEXTURE2D:
if (desc->u.Texture2D.MipLevels == -1 && desc->u.Texture2D.MostDetailedMip < miplevel_count)
desc->u.Texture2D.MipLevels = miplevel_count - desc->u.Texture2D.MostDetailedMip;
break;
case D3D11_SRV_DIMENSION_TEXTURE2DARRAY:
if (desc->u.Texture2DArray.MipLevels == -1 && desc->u.Texture2DArray.MostDetailedMip < miplevel_count)
desc->u.Texture2DArray.MipLevels = miplevel_count - desc->u.Texture2DArray.MostDetailedMip;
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_SRV_DIMENSION_TEXTURE3D:
if (desc->u.Texture3D.MipLevels == -1 && desc->u.Texture3D.MostDetailedMip < miplevel_count)
desc->u.Texture3D.MipLevels = miplevel_count - desc->u.Texture3D.MostDetailedMip;
break;
case D3D11_SRV_DIMENSION_TEXTURECUBE:
if (desc->u.TextureCube.MipLevels == -1 && desc->u.TextureCube.MostDetailedMip < miplevel_count)
desc->u.TextureCube.MipLevels = miplevel_count - desc->u.TextureCube.MostDetailedMip;
break;
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