d3d10core: Implement d3d10_shader_resource_view_GetDevice().
This commit is contained in:
parent
40686f48cb
commit
539a579d54
|
@ -153,9 +153,10 @@ struct d3d10_shader_resource_view
|
||||||
|
|
||||||
D3D10_SHADER_RESOURCE_VIEW_DESC desc;
|
D3D10_SHADER_RESOURCE_VIEW_DESC desc;
|
||||||
ID3D10Resource *resource;
|
ID3D10Resource *resource;
|
||||||
|
ID3D10Device1 *device;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT d3d10_shader_resource_view_init(struct d3d10_shader_resource_view *view,
|
HRESULT d3d10_shader_resource_view_init(struct d3d10_shader_resource_view *view, struct d3d10_device *device,
|
||||||
ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc) DECLSPEC_HIDDEN;
|
ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* ID3D10InputLayout */
|
/* ID3D10InputLayout */
|
||||||
|
|
|
@ -1163,16 +1163,16 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture3D(ID3D10Device1 *ifa
|
||||||
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
|
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateShaderResourceView(ID3D10Device1 *iface,
|
||||||
ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
|
ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc, ID3D10ShaderResourceView **view)
|
||||||
{
|
{
|
||||||
|
struct d3d10_device *device = impl_from_ID3D10Device(iface);
|
||||||
struct d3d10_shader_resource_view *object;
|
struct d3d10_shader_resource_view *object;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
|
TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view);
|
||||||
|
|
||||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||||
if (!object)
|
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
if (FAILED(hr = d3d10_shader_resource_view_init(object, resource, desc)))
|
if (FAILED(hr = d3d10_shader_resource_view_init(object, device, resource, desc)))
|
||||||
{
|
{
|
||||||
WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
|
WARN("Failed to initialize shader resource view, hr %#x.\n", hr);
|
||||||
HeapFree(GetProcessHeap(), 0, object);
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
|
|
|
@ -360,12 +360,12 @@ static void test_create_shader_resource_view(void)
|
||||||
{
|
{
|
||||||
D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc;
|
D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc;
|
||||||
D3D10_TEXTURE2D_DESC texture_desc;
|
D3D10_TEXTURE2D_DESC texture_desc;
|
||||||
|
ULONG refcount, expected_refcount;
|
||||||
ID3D10ShaderResourceView *srview;
|
ID3D10ShaderResourceView *srview;
|
||||||
D3D10_BUFFER_DESC buffer_desc;
|
D3D10_BUFFER_DESC buffer_desc;
|
||||||
|
ID3D10Device *device, *tmp;
|
||||||
ID3D10Texture2D *texture;
|
ID3D10Texture2D *texture;
|
||||||
ID3D10Buffer *buffer;
|
ID3D10Buffer *buffer;
|
||||||
ID3D10Device *device;
|
|
||||||
ULONG refcount;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
if (!(device = create_device()))
|
if (!(device = create_device()))
|
||||||
|
@ -391,8 +391,18 @@ static void test_create_shader_resource_view(void)
|
||||||
U(srv_desc).Buffer.ElementOffset = 0;
|
U(srv_desc).Buffer.ElementOffset = 0;
|
||||||
U(srv_desc).Buffer.ElementWidth = 64;
|
U(srv_desc).Buffer.ElementWidth = 64;
|
||||||
|
|
||||||
|
expected_refcount = get_refcount((IUnknown *)device) + 1;
|
||||||
hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)buffer, &srv_desc, &srview);
|
hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)buffer, &srv_desc, &srview);
|
||||||
ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x\n", hr);
|
ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x\n", hr);
|
||||||
|
refcount = get_refcount((IUnknown *)device);
|
||||||
|
ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
|
||||||
|
tmp = NULL;
|
||||||
|
expected_refcount = refcount + 1;
|
||||||
|
ID3D10ShaderResourceView_GetDevice(srview, &tmp);
|
||||||
|
ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
|
||||||
|
refcount = get_refcount((IUnknown *)device);
|
||||||
|
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
|
||||||
|
ID3D10Device_Release(tmp);
|
||||||
|
|
||||||
ID3D10ShaderResourceView_Release(srview);
|
ID3D10ShaderResourceView_Release(srview);
|
||||||
ID3D10Buffer_Release(buffer);
|
ID3D10Buffer_Release(buffer);
|
||||||
|
|
|
@ -772,6 +772,7 @@ static ULONG STDMETHODCALLTYPE d3d10_shader_resource_view_Release(ID3D10ShaderRe
|
||||||
if (!refcount)
|
if (!refcount)
|
||||||
{
|
{
|
||||||
ID3D10Resource_Release(This->resource);
|
ID3D10Resource_Release(This->resource);
|
||||||
|
ID3D10Device1_Release(This->device);
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,7 +784,12 @@ static ULONG STDMETHODCALLTYPE d3d10_shader_resource_view_Release(ID3D10ShaderRe
|
||||||
static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetDevice(ID3D10ShaderResourceView *iface,
|
static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetDevice(ID3D10ShaderResourceView *iface,
|
||||||
ID3D10Device **device)
|
ID3D10Device **device)
|
||||||
{
|
{
|
||||||
FIXME("iface %p, device %p stub!\n", iface, device);
|
struct d3d10_shader_resource_view *view = impl_from_ID3D10ShaderResourceView(iface);
|
||||||
|
|
||||||
|
TRACE("iface %p, device %p.\n", iface, device);
|
||||||
|
|
||||||
|
*device = (ID3D10Device *)view->device;
|
||||||
|
ID3D10Device_AddRef(*device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_GetPrivateData(ID3D10ShaderResourceView *iface,
|
static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_GetPrivateData(ID3D10ShaderResourceView *iface,
|
||||||
|
@ -854,7 +860,7 @@ static const struct ID3D10ShaderResourceViewVtbl d3d10_shader_resource_view_vtbl
|
||||||
d3d10_shader_resource_view_GetDesc,
|
d3d10_shader_resource_view_GetDesc,
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT d3d10_shader_resource_view_init(struct d3d10_shader_resource_view *view,
|
HRESULT d3d10_shader_resource_view_init(struct d3d10_shader_resource_view *view, struct d3d10_device *device,
|
||||||
ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc)
|
ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -874,6 +880,8 @@ HRESULT d3d10_shader_resource_view_init(struct d3d10_shader_resource_view *view,
|
||||||
|
|
||||||
view->resource = resource;
|
view->resource = resource;
|
||||||
ID3D10Resource_AddRef(resource);
|
ID3D10Resource_AddRef(resource);
|
||||||
|
view->device = &device->ID3D10Device1_iface;
|
||||||
|
ID3D10Device1_AddRef(view->device);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue