d3d11: Implement d3d11_shader_resource_view_GetResource().

This commit is contained in:
Józef Kucia 2015-09-10 00:55:46 +02:00 committed by Alexandre Julliard
parent 28f98a0d9d
commit 487cf3d5c4
3 changed files with 50 additions and 35 deletions

View File

@ -198,12 +198,12 @@ struct d3d_shader_resource_view
struct wined3d_private_store private_store;
struct wined3d_shader_resource_view *wined3d_view;
D3D11_SHADER_RESOURCE_VIEW_DESC desc;
ID3D10Resource *resource;
ID3D11Resource *resource;
ID3D11Device *device;
};
HRESULT d3d_shader_resource_view_init(struct d3d_shader_resource_view *view, struct d3d_device *device,
ID3D10Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc) DECLSPEC_HIDDEN;
ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc) DECLSPEC_HIDDEN;
struct d3d_shader_resource_view *unsafe_impl_from_ID3D10ShaderResourceView(
ID3D10ShaderResourceView *iface) DECLSPEC_HIDDEN;

View File

@ -2108,6 +2108,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Dev
{
struct d3d_device *device = impl_from_ID3D10Device(iface);
struct d3d_shader_resource_view *object;
ID3D11Resource *d3d11_resource;
HRESULT hr;
TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
@ -2115,14 +2116,24 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Dev
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d3d_shader_resource_view_init(object, device, resource,
if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource)))
{
ERR("Resource does not implement ID3D11Resource.\n");
HeapFree(GetProcessHeap(), 0, object);
return E_FAIL;
}
if (FAILED(hr = d3d_shader_resource_view_init(object, device, d3d11_resource,
(const D3D11_SHADER_RESOURCE_VIEW_DESC *)desc)))
{
WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
ID3D11Resource_Release(d3d11_resource);
return hr;
}
ID3D11Resource_Release(d3d11_resource);
TRACE("Created shader resource view %p.\n", object);
*view = &object->ID3D10ShaderResourceView_iface;

View File

@ -240,27 +240,27 @@ static HRESULT set_rtdesc_from_resource(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3
}
}
static HRESULT set_srdesc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10Resource *resource)
static HRESULT set_srdesc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11Resource *resource)
{
D3D10_RESOURCE_DIMENSION dimension;
D3D11_RESOURCE_DIMENSION dimension;
ID3D10Resource_GetType(resource, &dimension);
ID3D11Resource_GetType(resource, &dimension);
switch (dimension)
{
case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
{
D3D10_TEXTURE1D_DESC texture_desc;
ID3D10Texture1D *texture;
D3D11_TEXTURE1D_DESC texture_desc;
ID3D11Texture1D *texture;
if (FAILED(ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture1D, (void **)&texture)))
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture1D, (void **)&texture)))
{
ERR("Resource of type TEXTURE1D doesn't implement ID3D10Texture1D.\n");
ERR("Resource of type TEXTURE1D doesn't implement ID3D11Texture1D.\n");
return E_INVALIDARG;
}
ID3D10Texture1D_GetDesc(texture, &texture_desc);
ID3D10Texture1D_Release(texture);
ID3D11Texture1D_GetDesc(texture, &texture_desc);
ID3D11Texture1D_Release(texture);
desc->Format = texture_desc.Format;
if (texture_desc.ArraySize == 1)
@ -281,19 +281,19 @@ static HRESULT set_srdesc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, I
return S_OK;
}
case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{
D3D10_TEXTURE2D_DESC texture_desc;
ID3D10Texture2D *texture;
D3D11_TEXTURE2D_DESC texture_desc;
ID3D11Texture2D *texture;
if (FAILED(ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture2D, (void **)&texture)))
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture2D, (void **)&texture)))
{
ERR("Resource of type TEXTURE2D doesn't implement ID3D10Texture2D.\n");
ERR("Resource of type TEXTURE2D doesn't implement ID3D11Texture2D.\n");
return E_INVALIDARG;
}
ID3D10Texture2D_GetDesc(texture, &texture_desc);
ID3D10Texture2D_Release(texture);
ID3D11Texture2D_GetDesc(texture, &texture_desc);
ID3D11Texture2D_Release(texture);
desc->Format = texture_desc.Format;
if (texture_desc.ArraySize == 1)
@ -330,19 +330,19 @@ static HRESULT set_srdesc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, I
return S_OK;
}
case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
{
D3D10_TEXTURE3D_DESC texture_desc;
ID3D10Texture3D *texture;
D3D11_TEXTURE3D_DESC texture_desc;
ID3D11Texture3D *texture;
if (FAILED(ID3D10Resource_QueryInterface(resource, &IID_ID3D10Texture3D, (void **)&texture)))
if (FAILED(ID3D11Resource_QueryInterface(resource, &IID_ID3D11Texture3D, (void **)&texture)))
{
ERR("Resource of type TEXTURE3D doesn't implement ID3D10Texture3D.\n");
ERR("Resource of type TEXTURE3D doesn't implement ID3D11Texture3D.\n");
return E_INVALIDARG;
}
ID3D10Texture3D_GetDesc(texture, &texture_desc);
ID3D10Texture3D_Release(texture);
ID3D11Texture3D_GetDesc(texture, &texture_desc);
ID3D11Texture3D_Release(texture);
desc->Format = texture_desc.Format;
desc->ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
@ -354,7 +354,7 @@ static HRESULT set_srdesc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, I
default:
FIXME("Unhandled resource dimension %#x.\n", dimension);
case D3D10_RESOURCE_DIMENSION_BUFFER:
case D3D11_RESOURCE_DIMENSION_BUFFER:
return E_INVALIDARG;
}
}
@ -1238,7 +1238,7 @@ static ULONG STDMETHODCALLTYPE d3d11_shader_resource_view_Release(ID3D11ShaderRe
{
wined3d_mutex_lock();
wined3d_shader_resource_view_decref(view->wined3d_view);
ID3D10Resource_Release(view->resource);
ID3D11Resource_Release(view->resource);
ID3D11Device_Release(view->device);
wined3d_private_store_cleanup(&view->private_store);
wined3d_mutex_unlock();
@ -1292,7 +1292,12 @@ static HRESULT STDMETHODCALLTYPE d3d11_shader_resource_view_SetPrivateDataInterf
static void STDMETHODCALLTYPE d3d11_shader_resource_view_GetResource(ID3D11ShaderResourceView *iface,
ID3D11Resource **resource)
{
FIXME("iface %p, resource %p stub!\n", iface, resource);
struct d3d_shader_resource_view *view = impl_from_ID3D11ShaderResourceView(iface);
TRACE("iface %p, resource %p.\n", iface, resource);
*resource = view->resource;
ID3D11Resource_AddRef(*resource);
}
static void STDMETHODCALLTYPE d3d11_shader_resource_view_GetDesc(ID3D11ShaderResourceView *iface,
@ -1412,8 +1417,7 @@ static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetResource(ID3D10Shade
TRACE("iface %p, resource %p.\n", iface, resource);
*resource = view->resource;
ID3D10Resource_AddRef(*resource);
ID3D11Resource_QueryInterface(view->resource, &IID_ID3D10Resource, (void **)resource);
}
/* ID3D10ShaderResourceView methods */
@ -1446,7 +1450,7 @@ static const struct ID3D10ShaderResourceViewVtbl d3d10_shader_resource_view_vtbl
};
HRESULT d3d_shader_resource_view_init(struct d3d_shader_resource_view *view, struct d3d_device *device,
ID3D10Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc)
ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc)
{
struct wined3d_resource *wined3d_resource;
HRESULT hr;
@ -1466,7 +1470,7 @@ HRESULT d3d_shader_resource_view_init(struct d3d_shader_resource_view *view, str
}
wined3d_mutex_lock();
if (!(wined3d_resource = wined3d_resource_from_d3d10_resource(resource)))
if (!(wined3d_resource = wined3d_resource_from_d3d11_resource(resource)))
{
ERR("Failed to get wined3d resource for d3d10 resource %p.\n", resource);
return E_FAIL;
@ -1482,7 +1486,7 @@ HRESULT d3d_shader_resource_view_init(struct d3d_shader_resource_view *view, str
wined3d_private_store_init(&view->private_store);
wined3d_mutex_unlock();
view->resource = resource;
ID3D10Resource_AddRef(resource);
ID3D11Resource_AddRef(resource);
view->device = &device->ID3D11Device_iface;
ID3D11Device_AddRef(view->device);