diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 456d34470c1..da4627d7a85 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -17239,7 +17239,7 @@ static void test_create_unordered_access_view(void) 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); + ok(SUCCEEDED(hr), "Failed to create unordered access view, hr %#x.\n", hr); memset(&uav_desc, 0, sizeof(uav_desc)); ID3D11UnorderedAccessView_GetDesc(uav, &uav_desc); @@ -17254,6 +17254,20 @@ static void test_create_unordered_access_view(void) ID3D11UnorderedAccessView_Release(uav); ID3D11Buffer_Release(buffer); + /* Without D3D11_BIND_UNORDERED_ACCESS. */ + buffer = create_buffer(device, 0, 1024, NULL); + + uav_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; + uav_desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; + U(uav_desc).Buffer.FirstElement = 0; + U(uav_desc).Buffer.NumElements = 64; + U(uav_desc).Buffer.Flags = 0; + + hr = ID3D11Device_CreateUnorderedAccessView(device, (ID3D11Resource *)buffer, &uav_desc, &uav); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + + ID3D11Buffer_Release(buffer); + texture2d_desc.Width = 512; texture2d_desc.Height = 512; texture2d_desc.SampleDesc.Count = 1; diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index f1c99a3b6af..6710abb270f 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1134,6 +1134,8 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces view->parent = parent; view->parent_ops = parent_ops; + if (!(resource->bind_flags & WINED3D_BIND_UNORDERED_ACCESS)) + return E_INVALIDARG; if (!(view->format = validate_resource_view(desc, resource, TRUE, FALSE))) return E_INVALIDARG; view->desc = *desc;