d3d11: Allow creating SRVs for structured buffers with NULL description.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b68dfc5c8a
commit
3056608fb8
|
@ -3060,6 +3060,7 @@ static void test_create_shader_resource_view(void)
|
|||
ULONG refcount, expected_refcount;
|
||||
ID3D11ShaderResourceView *srview;
|
||||
D3D_FEATURE_LEVEL feature_level;
|
||||
D3D11_BUFFER_DESC buffer_desc;
|
||||
ID3D11Device *device, *tmp;
|
||||
ID3D11Texture3D *texture3d;
|
||||
ID3D11Texture2D *texture2d;
|
||||
|
@ -3255,6 +3256,40 @@ static void test_create_shader_resource_view(void)
|
|||
ID3D11ShaderResourceView_Release(srview);
|
||||
ID3D11Buffer_Release(buffer);
|
||||
|
||||
if (feature_level >= D3D_FEATURE_LEVEL_11_0)
|
||||
{
|
||||
buffer_desc.ByteWidth = 1024;
|
||||
buffer_desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
buffer_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
buffer_desc.CPUAccessFlags = 0;
|
||||
buffer_desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
|
||||
buffer_desc.StructureByteStride = 4;
|
||||
|
||||
hr = ID3D11Device_CreateBuffer(device, &buffer_desc, NULL, &buffer);
|
||||
ok(SUCCEEDED(hr), "Failed to create a buffer, hr %#x.\n", hr);
|
||||
|
||||
hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)buffer, NULL, &srview);
|
||||
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
memset(&srv_desc, 0, sizeof(srv_desc));
|
||||
ID3D11ShaderResourceView_GetDesc(srview, &srv_desc);
|
||||
|
||||
ok(srv_desc.Format == DXGI_FORMAT_UNKNOWN, "Got unexpected format %#x.\n", srv_desc.Format);
|
||||
ok(srv_desc.ViewDimension == D3D11_SRV_DIMENSION_BUFFER, "Got unexpected view dimension %#x.\n",
|
||||
srv_desc.ViewDimension);
|
||||
ok(!U(srv_desc).Buffer.FirstElement, "Got unexpected first element %u.\n",
|
||||
U(srv_desc).Buffer.FirstElement);
|
||||
ok(U(srv_desc).Buffer.NumElements == 256, "Got unexpected num elements %u.\n",
|
||||
U(srv_desc).Buffer.NumElements);
|
||||
|
||||
ID3D11ShaderResourceView_Release(srview);
|
||||
ID3D11Buffer_Release(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
skip("Structured buffers require feature level 11_0.\n");
|
||||
}
|
||||
|
||||
texture2d_desc.Width = 512;
|
||||
texture2d_desc.Height = 512;
|
||||
texture2d_desc.SampleDesc.Count = 1;
|
||||
|
|
|
@ -446,6 +446,32 @@ static HRESULT set_srv_desc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc,
|
|||
|
||||
switch (dimension)
|
||||
{
|
||||
case D3D11_RESOURCE_DIMENSION_BUFFER:
|
||||
{
|
||||
D3D11_BUFFER_DESC buffer_desc;
|
||||
ID3D11Buffer *buffer;
|
||||
|
||||
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Buffer, (void **)&buffer)))
|
||||
{
|
||||
ERR("Resource of type BUFFER doesn't implement ID3D11Buffer.\n");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
ID3D11Buffer_GetDesc(buffer, &buffer_desc);
|
||||
ID3D11Buffer_Release(buffer);
|
||||
|
||||
if (buffer_desc.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED)
|
||||
{
|
||||
desc->Format = DXGI_FORMAT_UNKNOWN;
|
||||
desc->ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
|
||||
desc->u.Buffer.u1.FirstElement = 0;
|
||||
desc->u.Buffer.u2.NumElements = buffer_desc.ByteWidth / buffer_desc.StructureByteStride;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
|
||||
{
|
||||
D3D11_TEXTURE1D_DESC texture_desc;
|
||||
|
@ -552,7 +578,6 @@ static HRESULT set_srv_desc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc,
|
|||
|
||||
default:
|
||||
ERR("Unhandled resource dimension %#x.\n", dimension);
|
||||
case D3D11_RESOURCE_DIMENSION_BUFFER:
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue