Add refcount test for binding objects

Stefan Dösinger stefan at codeweavers.com
Fri Nov 3 12:38:46 CST 2006


Just in case anyone(me) feels tempted to AddRef objects in SetTexture / 
SetIndices / SetStreamSource :-)
-------------- next part --------------
From d78f31212304d58697ba06f6e1bc9b866c9e0647 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Fri, 3 Nov 2006 19:37:54 +0100
Subject: [PATCH] Add tests for binding objects
---
 dlls/d3d9/tests/device.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index be1dba2..2ed0926 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -315,8 +315,27 @@ static void test_refcount(void)
     /* Buffers */
     hr = IDirect3DDevice9_CreateIndexBuffer( pDevice, 16, 0, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &pIndexBuffer, NULL );
     CHECK_CALL( hr, "CreateIndexBuffer", pDevice, ++refcount );
+    if(pIndexBuffer)
+    {
+        tmp = get_refcount( (IUnknown *)pIndexBuffer );
+
+        hr = IDirect3DDevice9_SetIndices(pDevice, pIndexBuffer);
+        CHECK_CALL( hr, "SetIndices", pIndexBuffer, tmp);
+        hr = IDirect3DDevice9_SetIndices(pDevice, NULL);
+        CHECK_CALL( hr, "SetIndices", pIndexBuffer, tmp);
+    }
+
     hr = IDirect3DDevice9_CreateVertexBuffer( pDevice, 16, 0, D3DFVF_XYZ, D3DPOOL_DEFAULT, &pVertexBuffer, NULL );
     CHECK_CALL( hr, "CreateVertexBuffer", pDevice, ++refcount );
+    if(pVertexBuffer)
+    {
+        tmp = get_refcount( (IUnknown *)pVertexBuffer );
+
+        hr = IDirect3DDevice9_SetStreamSource(pDevice, 0, pVertexBuffer, 0, 3 * sizeof(float));
+        CHECK_CALL( hr, "SetStreamSource", pVertexBuffer, tmp);
+        hr = IDirect3DDevice9_SetStreamSource(pDevice, 0, NULL, 0, 0);
+        CHECK_CALL( hr, "SetStreamSource", pVertexBuffer, tmp);
+    }
     /* Shaders */
     hr = IDirect3DDevice9_CreateVertexDeclaration( pDevice, decl, &pVertexDeclaration );
     CHECK_CALL( hr, "CreateVertexDeclaration", pDevice, ++refcount );
@@ -330,6 +349,13 @@ static void test_refcount(void)
     if (pTexture)
     {
         tmp = get_refcount( (IUnknown *)pTexture );
+
+        /* SetTexture should not increase refcounts */
+        hr = IDirect3DDevice9_SetTexture(pDevice, 0, (IDirect3DBaseTexture9 *) pTexture);
+        CHECK_CALL( hr, "SetTexture", pTexture, tmp);
+        hr = IDirect3DDevice9_SetTexture(pDevice, 0, NULL);
+        CHECK_CALL( hr, "SetTexture", pTexture, tmp);
+
         /* This should not increment device refcount */
         hr = IDirect3DTexture9_GetSurfaceLevel( pTexture, 1, &pTextureLevel );
         CHECK_CALL( hr, "GetSurfaceLevel", pDevice, refcount );
-- 
1.4.1.1



More information about the wine-patches mailing list