d3d11: Allow creating UAVs 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:
Józef Kucia 2016-07-20 15:49:43 +02:00 committed by Alexandre Julliard
parent c51d16070c
commit b68dfc5c8a
2 changed files with 52 additions and 0 deletions

View File

@ -9245,6 +9245,9 @@ static void test_create_unordered_access_view(void)
U(uav_desc).Buffer.NumElements = 64;
U(uav_desc).Buffer.Flags = 0;
hr = ID3D11Device_CreateUnorderedAccessView(device, (ID3D11Resource *)buffer, NULL, &uav);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
expected_refcount = get_refcount((IUnknown *)device) + 1;
hr = ID3D11Device_CreateUnorderedAccessView(device, (ID3D11Resource *)buffer, &uav_desc, &uav);
ok(SUCCEEDED(hr), "Failed to create unordered access view, hr %#x.\n", hr);
@ -9261,6 +9264,28 @@ static void test_create_unordered_access_view(void)
ID3D11UnorderedAccessView_Release(uav);
ID3D11Buffer_Release(buffer);
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_CreateUnorderedAccessView(device, (ID3D11Resource *)buffer, NULL, &uav);
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
memset(&uav_desc, 0, sizeof(uav_desc));
ID3D11UnorderedAccessView_GetDesc(uav, &uav_desc);
ok(uav_desc.Format == DXGI_FORMAT_UNKNOWN, "Got unexpected format %#x.\n", uav_desc.Format);
ok(uav_desc.ViewDimension == D3D11_UAV_DIMENSION_BUFFER, "Got unexpected view dimension %#x.\n",
uav_desc.ViewDimension);
ok(!U(uav_desc).Buffer.FirstElement, "Got unexpected first element %u.\n", U(uav_desc).Buffer.FirstElement);
ok(U(uav_desc).Buffer.NumElements == 256, "Got unexpected num elements %u.\n", U(uav_desc).Buffer.NumElements);
ok(!U(uav_desc).Buffer.Flags, "Got unexpected flags %u.\n", U(uav_desc).Buffer.Flags);
ID3D11UnorderedAccessView_Release(uav);
ID3D11Buffer_Release(buffer);
texture2d_desc.Width = 512;
texture2d_desc.Height = 512;
texture2d_desc.SampleDesc.Count = 1;

View File

@ -710,6 +710,33 @@ static HRESULT set_uav_desc_from_resource(D3D11_UNORDERED_ACCESS_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_UAV_DIMENSION_BUFFER;
desc->u.Buffer.FirstElement = 0;
desc->u.Buffer.NumElements = buffer_desc.ByteWidth / buffer_desc.StructureByteStride;
desc->u.Buffer.Flags = 0;
return S_OK;
}
return E_INVALIDARG;
}
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{
D3D11_TEXTURE2D_DESC texture_desc;