[PATCH 4/4] d3drm/tests: Add refcount tests for IDirect3DRMDevice*

Aaryaman Vasishta jem456.vasishta at gmail.com
Thu Jun 11 11:48:25 CDT 2015


I agree, the refcount tests for surface for CreateDeviceFromSurface and
device for CreateDeviceFromD3D will help while implementing them. On
running a quick test, it seems to increment surface by 2 in
CreateDeviceFromSurface, device by 2, d3d by 4 for CreateDeviceFromD3D.

On Thu, Jun 11, 2015 at 9:58 PM, Stefan Dösinger <stefandoesinger at gmail.com>
wrote:

> I think these tests are best integrated into CreateDeviceFromClipper.
> Similar tests are needed for the other creation methods, with some
> modifications. Check if the reference count of the surface passed to
> CreateDeviceFromSurface is incremented, and similarly for the device passed
> to CreateDeviceFromD3D.
>
>
> > Am 11.06.2015 um 13:51 schrieb Aaryaman Vasishta <
> jem456.vasishta at gmail.com>:
> >
> > The refcount tests for d3drm1 are the same for the device created from
> all three creation methods.
> > ---
> > dlls/d3drm/tests/d3drm.c | 81
> ++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 81 insertions(+)
> >
> > diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
> > index ac4c8fe..ecf1d4d 100644
> > --- a/dlls/d3drm/tests/d3drm.c
> > +++ b/dlls/d3drm/tests/d3drm.c
> > @@ -2367,6 +2367,86 @@ cleanup:
> >     IDirectDraw_Release(ddraw1);
> > }
> >
> > +static void test_device_refcount(void)
> > +{
> > +    IDirect3DRM *d3drm1;
> > +    IDirect3DRM2 *d3drm2;
> > +    IDirect3DRM3 *d3drm3;
> > +    IDirect3DRMDevice *device1;
> > +    IDirect3DRMDevice2 *device2;
> > +    IDirect3DRMDevice3 *device3;
> > +    IDirectDrawClipper *clipper;
> > +    HWND window;
> > +    HRESULT hr;
> > +    ULONG ref1, ref2, cref1, cref2;
> > +    GUID driver;
> > +    RECT rc;
> > +
> > +
> > +    window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW,
> 0, 0, 300, 200, 0, 0, 0, 0);
> > +    GetClientRect(window, &rc);
> > +    hr = DirectDrawCreateClipper(0, &clipper, NULL);
> > +    ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr =
> %x)\n", hr);
> > +    hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
> > +    ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x)\n", hr);
> > +
> > +    hr = Direct3DRMCreate(&d3drm1);
> > +    ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n",
> hr);
> > +    ref1 = get_refcount((IUnknown *)d3drm1);
> > +    cref1 = get_refcount((IUnknown *)clipper);
> > +    memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID));
> > +    hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver,
> rc.right, rc.bottom, &device1);
> > +    ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface (hr =
> %x)\n", hr);
> > +    ref2 = get_refcount((IUnknown *)d3drm1);
> > +    cref2 = get_refcount((IUnknown *)clipper);
> > +    ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %d , ref2 =
> %d\n", ref1, ref2);
> > +    ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %d , cref2 =
> %d\n", cref1, cref2);
> > +    if (device1)
> > +        IDirect3DRMDevice_Release(device1);
> > +    ref2 = get_refcount((IUnknown *)d3drm1);
> > +    cref2 = get_refcount((IUnknown *)clipper);
> > +    ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %d, ref2 =
> %d\n", ref1, ref2);
> > +    ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %d, cref2
> = %d\n", cref1, cref2);
> > +
> > +    hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void
> **)&d3drm2);
> > +    ok(hr == D3DRM_OK, "Cannot get IDirect3DRM2 interface (hr =
> %x).\n", hr);
> > +    ref1 = get_refcount((IUnknown *)d3drm1);
> > +    cref1 = get_refcount((IUnknown *)clipper);
> > +    hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver,
> rc.right, rc.bottom, &device2);
> > +    ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice2 interface (hr =
> %x)\n", hr);
> > +    ref2 = get_refcount((IUnknown *)d3drm1);
> > +    cref2 = get_refcount((IUnknown *)clipper);
> > +    ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %d , ref2 =
> %d\n", ref1, ref2);
> > +    ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %d , cref2 =
> %d\n", cref1, cref2);
> > +    if (device2)
> > +        IDirect3DRMDevice2_Release(device2);
> > +    ref2 = get_refcount((IUnknown *)d3drm1);
> > +    cref2 = get_refcount((IUnknown *)clipper);
> > +    ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %d, ref2 =
> %d\n", ref1, ref2);
> > +    ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %d, cref2
> = %d\n", cref1, cref2);
> > +
> > +    hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void
> **)&d3drm3);
> > +    ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface (hr =
> %x).\n", hr);
> > +    ref1 = get_refcount((IUnknown *)d3drm1);
> > +    cref1 = get_refcount((IUnknown *)clipper);
> > +    hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver,
> rc.right, rc.bottom, &device3);
> > +    ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice3 interface (hr =
> %x)\n", hr);
> > +    ref2 = get_refcount((IUnknown *)d3drm1);
> > +    cref2 = get_refcount((IUnknown *)clipper);
> > +    ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %d, ref2 = %d\n",
> ref1, ref2);
> > +    ok(cref2 > cref1, "expected cref2 > cref1, got cref1 = %d , cref2 =
> %d\n", cref1, cref2);
> > +    if (device3)
> > +        IDirect3DRMDevice3_Release(device3);
> > +    ref2 = get_refcount((IUnknown *)d3drm1);
> > +    cref2 = get_refcount((IUnknown *)clipper);
> > +    ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %d, ref2 =
> %d\n", ref1, ref2);
> > +    ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %d, cref2
> = %d\n", cref1, cref2);
> > +
> > +    IDirectDrawClipper_Release(clipper);
> > +    IDirect3DRM2_Release(d3drm2);
> > +    IDirect3DRM3_Release(d3drm3);
> > +}
> > +
> > START_TEST(d3drm)
> > {
> >     test_MeshBuilder();
> > @@ -2387,4 +2467,5 @@ START_TEST(d3drm)
> >     test_create_device_from_clipper();
> >     test_create_device_from_surface();
> >     test_create_device_from_d3d();
> > +    test_device_refcount();
> > }
> > --
> > 1.9.3 (Apple Git-50)
> >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20150611/e9491a3e/attachment-0001.html>


More information about the wine-devel mailing list