Commit 6e3619c4 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: Implement d3d10_texture3d_GetDevice().

parent 387f65ba
...@@ -95,6 +95,7 @@ struct d3d10_texture3d ...@@ -95,6 +95,7 @@ struct d3d10_texture3d
struct wined3d_texture *wined3d_texture; struct wined3d_texture *wined3d_texture;
D3D10_TEXTURE3D_DESC desc; D3D10_TEXTURE3D_DESC desc;
ID3D10Device1 *device;
}; };
HRESULT d3d10_texture3d_init(struct d3d10_texture3d *texture, struct d3d10_device *device, HRESULT d3d10_texture3d_init(struct d3d10_texture3d *texture, struct d3d10_device *device,
......
...@@ -134,11 +134,11 @@ static void test_create_texture2d(void) ...@@ -134,11 +134,11 @@ static void test_create_texture2d(void)
static void test_create_texture3d(void) static void test_create_texture3d(void)
{ {
ULONG refcount, expected_refcount;
ID3D10Device *device, *tmp;
D3D10_TEXTURE3D_DESC desc; D3D10_TEXTURE3D_DESC desc;
ID3D10Texture3D *texture; ID3D10Texture3D *texture;
IDXGISurface *surface; IDXGISurface *surface;
ID3D10Device *device;
ULONG refcount;
HRESULT hr; HRESULT hr;
if (!(device = create_device())) if (!(device = create_device()))
...@@ -157,8 +157,18 @@ static void test_create_texture3d(void) ...@@ -157,8 +157,18 @@ static void test_create_texture3d(void)
desc.CPUAccessFlags = 0; desc.CPUAccessFlags = 0;
desc.MiscFlags = 0; desc.MiscFlags = 0;
expected_refcount = get_refcount((IUnknown *)device) + 1;
hr = ID3D10Device_CreateTexture3D(device, &desc, NULL, &texture); hr = ID3D10Device_CreateTexture3D(device, &desc, NULL, &texture);
ok(SUCCEEDED(hr), "Failed to create a 3d texture, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to create a 3d texture, 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;
ID3D10Texture3D_GetDevice(texture, &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);
hr = ID3D10Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface); hr = ID3D10Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
ok(FAILED(hr), "Texture should not implement IDXGISurface.\n"); ok(FAILED(hr), "Texture should not implement IDXGISurface.\n");
...@@ -166,8 +176,18 @@ static void test_create_texture3d(void) ...@@ -166,8 +176,18 @@ static void test_create_texture3d(void)
ID3D10Texture3D_Release(texture); ID3D10Texture3D_Release(texture);
desc.MipLevels = 0; desc.MipLevels = 0;
expected_refcount = get_refcount((IUnknown *)device) + 1;
hr = ID3D10Device_CreateTexture3D(device, &desc, NULL, &texture); hr = ID3D10Device_CreateTexture3D(device, &desc, NULL, &texture);
ok(SUCCEEDED(hr), "Failed to create a 3d texture, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to create a 3d texture, 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;
ID3D10Texture3D_GetDevice(texture, &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);
ID3D10Texture3D_GetDesc(texture, &desc); ID3D10Texture3D_GetDesc(texture, &desc);
ok(desc.Width == 64, "Got unexpected Width %u.\n", desc.Width); ok(desc.Width == 64, "Got unexpected Width %u.\n", desc.Width);
......
...@@ -337,7 +337,10 @@ static ULONG STDMETHODCALLTYPE d3d10_texture3d_AddRef(ID3D10Texture3D *iface) ...@@ -337,7 +337,10 @@ static ULONG STDMETHODCALLTYPE d3d10_texture3d_AddRef(ID3D10Texture3D *iface)
TRACE("%p increasing refcount to %u.\n", texture, refcount); TRACE("%p increasing refcount to %u.\n", texture, refcount);
if (refcount == 1) if (refcount == 1)
{
ID3D10Device1_AddRef(texture->device);
wined3d_texture_incref(texture->wined3d_texture); wined3d_texture_incref(texture->wined3d_texture);
}
return refcount; return refcount;
} }
...@@ -355,14 +358,26 @@ static ULONG STDMETHODCALLTYPE d3d10_texture3d_Release(ID3D10Texture3D *iface) ...@@ -355,14 +358,26 @@ static ULONG STDMETHODCALLTYPE d3d10_texture3d_Release(ID3D10Texture3D *iface)
TRACE("%p decreasing refcount to %u.\n", texture, refcount); TRACE("%p decreasing refcount to %u.\n", texture, refcount);
if (!refcount) if (!refcount)
{
ID3D10Device1 *device = texture->device;
wined3d_texture_decref(texture->wined3d_texture); wined3d_texture_decref(texture->wined3d_texture);
/* Release the device last, it may cause the wined3d device to be
* destroyed. */
ID3D10Device1_Release(device);
}
return refcount; return refcount;
} }
static void STDMETHODCALLTYPE d3d10_texture3d_GetDevice(ID3D10Texture3D *iface, ID3D10Device **device) static void STDMETHODCALLTYPE d3d10_texture3d_GetDevice(ID3D10Texture3D *iface, ID3D10Device **device)
{ {
FIXME("iface %p, device %p stub!\n", iface, device); struct d3d10_texture3d *texture = impl_from_ID3D10Texture3D(iface);
TRACE("iface %p, device %p.\n", iface, device);
*device = (ID3D10Device *)texture->device;
ID3D10Device_AddRef(*device);
} }
static HRESULT STDMETHODCALLTYPE d3d10_texture3d_GetPrivateData(ID3D10Texture3D *iface, static HRESULT STDMETHODCALLTYPE d3d10_texture3d_GetPrivateData(ID3D10Texture3D *iface,
...@@ -517,5 +532,8 @@ HRESULT d3d10_texture3d_init(struct d3d10_texture3d *texture, struct d3d10_devic ...@@ -517,5 +532,8 @@ HRESULT d3d10_texture3d_init(struct d3d10_texture3d *texture, struct d3d10_devic
} }
texture->desc.MipLevels = wined3d_texture_get_level_count(texture->wined3d_texture); texture->desc.MipLevels = wined3d_texture_get_level_count(texture->wined3d_texture);
texture->device = &device->ID3D10Device1_iface;
ID3D10Device1_AddRef(texture->device);
return S_OK; return S_OK;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment