Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
47456184
Commit
47456184
authored
Dec 05, 2006
by
Markus Amsler
Committed by
Alexandre Julliard
Dec 06, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d8: Fix implicit surface refcounting.
parent
0a3f4173
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
42 deletions
+69
-42
d3d8_private.h
dlls/d3d8/d3d8_private.h
+8
-0
device.c
dlls/d3d8/device.c
+5
-1
directx.c
dlls/d3d8/directx.c
+18
-5
surface.c
dlls/d3d8/surface.c
+4
-2
swapchain.c
dlls/d3d8/swapchain.c
+1
-1
device.c
dlls/d3d8/tests/device.c
+33
-33
No files found.
dlls/d3d8/d3d8_private.h
View file @
47456184
...
...
@@ -179,6 +179,9 @@ struct IDirect3DDevice8Impl
/* FIXME: Move *baseVertexIndex somewhere sensible like wined3d */
UINT
baseVertexIndex
;
/* Avoids recursion with nested ReleaseRef to 0 */
BOOL
inDestruction
;
};
/* ---------------- */
...
...
@@ -252,6 +255,9 @@ struct IDirect3DSurface8Impl
/* If set forward refcounting to this object */
IUnknown
*
forwardReference
;
/* Flags an implicit surface */
BOOL
isImplicit
;
};
/* ------------------ */
...
...
@@ -599,6 +605,8 @@ extern HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, IUnknown *pSup
extern
ULONG
WINAPI
D3D8CB_DestroyDepthStencilSurface
(
IWineD3DSurface
*
pSurface
);
extern
ULONG
WINAPI
D3D8CB_DestroyRenderTarget
(
IWineD3DSurface
*
pSurface
);
extern
ULONG
WINAPI
D3D8CB_DestroySurface
(
IWineD3DSurface
*
pSurface
);
extern
ULONG
WINAPI
D3D8CB_DestroyVolume
(
IWineD3DVolume
*
pVolume
);
...
...
dlls/d3d8/device.c
View file @
47456184
...
...
@@ -89,12 +89,16 @@ static ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface) {
static
ULONG
WINAPI
IDirect3DDevice8Impl_Release
(
LPDIRECT3DDEVICE8
iface
)
{
IDirect3DDevice8Impl
*
This
=
(
IDirect3DDevice8Impl
*
)
iface
;
ULONG
ref
=
InterlockedDecrement
(
&
This
->
ref
);
ULONG
ref
;
if
(
This
->
inDestruction
)
return
0
;
ref
=
InterlockedDecrement
(
&
This
->
ref
);
TRACE
(
"(%p) : ReleaseRef to %d
\n
"
,
This
,
ref
);
if
(
ref
==
0
)
{
TRACE
(
"Releasing wined3d device %p
\n
"
,
This
->
WineD3DDevice
);
This
->
inDestruction
=
TRUE
;
IWineD3DDevice_Uninit3D
(
This
->
WineD3DDevice
,
D3D8CB_DestroyDepthStencilSurface
);
IWineD3DDevice_Release
(
This
->
WineD3DDevice
);
HeapFree
(
GetProcessHeap
(),
0
,
This
->
shader_handles
);
...
...
dlls/d3d8/directx.c
View file @
47456184
...
...
@@ -200,14 +200,25 @@ HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior,
if
(
SUCCEEDED
(
res
))
{
*
ppSurface
=
d3dSurface
->
wineD3DSurface
;
IUnknown_Release
(
d3dSurface
->
parentDevice
);
d3dSurface
->
parentDevice
=
NULL
;
d3dSurface
->
isImplicit
=
TRUE
;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release
((
IUnknown
*
)
d3dSurface
);
}
else
{
*
ppSurface
=
NULL
;
}
return
res
;
}
ULONG
WINAPI
D3D8CB_DestroyRenderTarget
(
IWineD3DSurface
*
pSurface
)
{
IDirect3DSurface8Impl
*
surfaceParent
;
TRACE
(
"(%p) call back
\n
"
,
pSurface
);
IWineD3DSurface_GetParent
(
pSurface
,
(
IUnknown
**
)
&
surfaceParent
);
surfaceParent
->
isImplicit
=
FALSE
;
/* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
return
IDirect3DSurface8_Release
((
IDirect3DSurface8
*
)
surfaceParent
);
}
/* Callback for creating the inplicite swapchain when the device is created */
static
HRESULT
WINAPI
D3D8CB_CreateAdditionalSwapChain
(
IUnknown
*
device
,
WINED3DPRESENT_PARAMETERS
*
pPresentationParameters
,
...
...
@@ -279,8 +290,9 @@ HRESULT WINAPI D3D8CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSup
(
D3DFORMAT
)
Format
,
MultiSample
,
(
IDirect3DSurface8
**
)
&
d3dSurface
);
if
(
SUCCEEDED
(
res
))
{
*
ppSurface
=
d3dSurface
->
wineD3DSurface
;
IUnknown_Release
(
d3dSurface
->
parentDevice
);
d3dSurface
->
parentDevice
=
NULL
;
d3dSurface
->
isImplicit
=
TRUE
;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release
((
IUnknown
*
)
d3dSurface
);
}
return
res
;
}
...
...
@@ -290,7 +302,8 @@ ULONG WINAPI D3D8CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {
TRACE
(
"(%p) call back
\n
"
,
pSurface
);
IWineD3DSurface_GetParent
(
pSurface
,
(
IUnknown
**
)
&
surfaceParent
);
IDirect3DSurface8_Release
((
IDirect3DSurface8
*
)
surfaceParent
);
surfaceParent
->
isImplicit
=
FALSE
;
/* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
return
IDirect3DSurface8_Release
((
IDirect3DSurface8
*
)
surfaceParent
);
}
...
...
dlls/d3d8/surface.c
View file @
47456184
...
...
@@ -52,6 +52,7 @@ static ULONG WINAPI IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface) {
}
else
{
/* No container, handle our own refcounting */
ULONG
ref
=
InterlockedIncrement
(
&
This
->
ref
);
if
(
ref
==
1
&&
This
->
parentDevice
)
IUnknown_AddRef
(
This
->
parentDevice
);
TRACE
(
"(%p) : AddRef from %d
\n
"
,
This
,
ref
-
1
);
return
ref
;
}
...
...
@@ -71,9 +72,10 @@ static ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
ULONG
ref
=
InterlockedDecrement
(
&
This
->
ref
);
TRACE
(
"(%p) : ReleaseRef to %d
\n
"
,
This
,
ref
);
if
(
ref
==
0
)
{
if
(
ref
==
0
&&
This
->
parentDevice
)
IUnknown_Release
(
This
->
parentDevice
);
/* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */
if
(
ref
>=
0
&&
!
This
->
isImplicit
)
{
IWineD3DSurface_Release
(
This
->
wineD3DSurface
);
if
(
This
->
parentDevice
)
IUnknown_Release
(
This
->
parentDevice
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
...
...
dlls/d3d8/swapchain.c
View file @
47456184
...
...
@@ -56,7 +56,7 @@ static ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface)
TRACE
(
"(%p) : ReleaseRef to %d
\n
"
,
This
,
ref
);
if
(
ref
==
0
)
{
IWineD3DSwapChain_
Release
(
This
->
wineD3DSwapChain
);
IWineD3DSwapChain_
Destroy
(
This
->
wineD3DSwapChain
,
D3D8CB_DestroyRenderTarget
);
if
(
This
->
parentDevice
)
IUnknown_Release
(
This
->
parentDevice
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
...
...
dlls/d3d8/tests/device.c
View file @
47456184
...
...
@@ -329,37 +329,37 @@ static void test_refcount(void)
* - the refcount is not forwarded to the container.
*/
hr
=
IDirect3DDevice8_GetRenderTarget
(
pDevice
,
&
pRenderTarget
);
todo_wine
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
pDevice
,
++
refcount
);
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
pDevice
,
++
refcount
);
if
(
pRenderTarget
)
{
todo_wine
CHECK_SURFACE_CONTAINER
(
pRenderTarget
,
IID_IDirect3DDevice8
,
pDevice
);
todo_wine
CHECK_REFCOUNT
(
pRenderTarget
,
1
);
CHECK_REFCOUNT
(
pRenderTarget
,
1
);
todo_wine
CHECK_ADDREF_REFCOUNT
(
pRenderTarget
,
2
);
todo_wine
CHECK_REFCOUNT
(
pDevice
,
refcount
);
todo_wine
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
1
);
todo_wine
CHECK_REFCOUNT
(
pDevice
,
refcount
);
CHECK_ADDREF_REFCOUNT
(
pRenderTarget
,
2
);
CHECK_REFCOUNT
(
pDevice
,
refcount
);
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
1
);
CHECK_REFCOUNT
(
pDevice
,
refcount
);
hr
=
IDirect3DDevice8_GetRenderTarget
(
pDevice
,
&
pRenderTarget
);
todo_wine
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
pDevice
,
refcount
);
todo_wine
CHECK_REFCOUNT
(
pRenderTarget
,
2
);
todo_wine
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
1
);
todo_wine
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
0
);
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
pDevice
,
refcount
);
CHECK_REFCOUNT
(
pRenderTarget
,
2
);
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
1
);
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
0
);
CHECK_REFCOUNT
(
pDevice
,
--
refcount
);
/* The render target is released with the device, so AddRef with refcount=0 is fine here. */
todo_wine
CHECK_ADDREF_REFCOUNT
(
pRenderTarget
,
1
);
todo_wine
CHECK_REFCOUNT
(
pDevice
,
++
refcount
);
todo_wine
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
0
);
CHECK_ADDREF_REFCOUNT
(
pRenderTarget
,
1
);
CHECK_REFCOUNT
(
pDevice
,
++
refcount
);
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
0
);
CHECK_REFCOUNT
(
pDevice
,
--
refcount
);
}
/* Render target and back buffer are identical. */
hr
=
IDirect3DDevice8_GetBackBuffer
(
pDevice
,
0
,
0
,
&
pBackBuffer
);
todo_wine
CHECK_CALL
(
hr
,
"GetBackBuffer"
,
pDevice
,
++
refcount
);
CHECK_CALL
(
hr
,
"GetBackBuffer"
,
pDevice
,
++
refcount
);
if
(
pBackBuffer
)
{
todo_wine
CHECK_RELEASE_REFCOUNT
(
pBackBuffer
,
0
);
CHECK_RELEASE_REFCOUNT
(
pBackBuffer
,
0
);
ok
(
pRenderTarget
==
pBackBuffer
,
"RenderTarget=%p and BackBuffer=%p should be the same.
\n
"
,
pRenderTarget
,
pBackBuffer
);
pBackBuffer
=
NULL
;
...
...
@@ -367,24 +367,24 @@ static void test_refcount(void)
CHECK_REFCOUNT
(
pDevice
,
--
refcount
);
hr
=
IDirect3DDevice8_GetDepthStencilSurface
(
pDevice
,
&
pStencilSurface
);
todo_wine
CHECK_CALL
(
hr
,
"GetDepthStencilSurface"
,
pDevice
,
++
refcount
);
CHECK_CALL
(
hr
,
"GetDepthStencilSurface"
,
pDevice
,
++
refcount
);
if
(
pStencilSurface
)
{
CHECK_SURFACE_CONTAINER
(
pStencilSurface
,
IID_IDirect3DDevice8
,
pDevice
);
todo_wine
CHECK_REFCOUNT
(
pStencilSurface
,
1
);
CHECK_REFCOUNT
(
pStencilSurface
,
1
);
todo_wine
CHECK_ADDREF_REFCOUNT
(
pStencilSurface
,
2
);
todo_wine
CHECK_REFCOUNT
(
pDevice
,
refcount
);
todo_wine
CHECK_RELEASE_REFCOUNT
(
pStencilSurface
,
1
);
todo_wine
CHECK_REFCOUNT
(
pDevice
,
refcount
);
CHECK_ADDREF_REFCOUNT
(
pStencilSurface
,
2
);
CHECK_REFCOUNT
(
pDevice
,
refcount
);
CHECK_RELEASE_REFCOUNT
(
pStencilSurface
,
1
);
CHECK_REFCOUNT
(
pDevice
,
refcount
);
todo_wine
CHECK_RELEASE_REFCOUNT
(
pStencilSurface
,
0
);
CHECK_RELEASE_REFCOUNT
(
pStencilSurface
,
0
);
CHECK_REFCOUNT
(
pDevice
,
--
refcount
);
/* The stencil surface is released with the device, so AddRef with refcount=0 is fine here. */
todo_wine
CHECK_ADDREF_REFCOUNT
(
pStencilSurface
,
1
);
todo_wine
CHECK_REFCOUNT
(
pDevice
,
++
refcount
);
todo_wine
CHECK_RELEASE_REFCOUNT
(
pStencilSurface
,
0
);
CHECK_ADDREF_REFCOUNT
(
pStencilSurface
,
1
);
CHECK_REFCOUNT
(
pDevice
,
++
refcount
);
CHECK_RELEASE_REFCOUNT
(
pStencilSurface
,
0
);
CHECK_REFCOUNT
(
pDevice
,
--
refcount
);
pStencilSurface
=
NULL
;
}
...
...
@@ -489,19 +489,19 @@ static void test_refcount(void)
{
/* check implicit back buffer */
hr
=
IDirect3DSwapChain8_GetBackBuffer
(
pSwapChain
,
0
,
0
,
&
pBackBuffer
);
todo_wine
CHECK_CALL
(
hr
,
"GetBackBuffer"
,
pDevice
,
++
refcount
);
CHECK_CALL
(
hr
,
"GetBackBuffer"
,
pDevice
,
++
refcount
);
CHECK_REFCOUNT
(
pSwapChain
,
1
);
if
(
pBackBuffer
)
{
todo_wine
CHECK_SURFACE_CONTAINER
(
pBackBuffer
,
IID_IDirect3DDevice8
,
pDevice
);
todo_wine
CHECK_REFCOUNT
(
pBackBuffer
,
1
);
todo_wine
CHECK_RELEASE_REFCOUNT
(
pBackBuffer
,
0
);
CHECK_REFCOUNT
(
pBackBuffer
,
1
);
CHECK_RELEASE_REFCOUNT
(
pBackBuffer
,
0
);
CHECK_REFCOUNT
(
pDevice
,
--
refcount
);
/* The back buffer is released with the swapchain, so AddRef with refcount=0 is fine here. */
todo_wine
CHECK_ADDREF_REFCOUNT
(
pBackBuffer
,
1
);
todo_wine
CHECK_REFCOUNT
(
pDevice
,
++
refcount
);
todo_wine
CHECK_RELEASE_REFCOUNT
(
pBackBuffer
,
0
);
CHECK_ADDREF_REFCOUNT
(
pBackBuffer
,
1
);
CHECK_REFCOUNT
(
pDevice
,
++
refcount
);
CHECK_RELEASE_REFCOUNT
(
pBackBuffer
,
0
);
CHECK_REFCOUNT
(
pDevice
,
--
refcount
);
pBackBuffer
=
NULL
;
}
...
...
@@ -525,10 +525,10 @@ static void test_refcount(void)
/* The implicit render target is not freed if refcount reaches 0.
* Otherwise GetRenderTarget would re-allocate it and the pointer would change.*/
hr
=
IDirect3DDevice8_GetRenderTarget
(
pDevice
,
&
pRenderTarget2
);
todo_wine
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
pDevice
,
++
refcount
);
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
pDevice
,
++
refcount
);
if
(
pRenderTarget2
)
{
todo_wine
CHECK_RELEASE_REFCOUNT
(
pRenderTarget2
,
0
);
CHECK_RELEASE_REFCOUNT
(
pRenderTarget2
,
0
);
ok
(
pRenderTarget
==
pRenderTarget2
,
"RenderTarget=%p and RenderTarget2=%p should be the same.
\n
"
,
pRenderTarget
,
pRenderTarget2
);
CHECK_REFCOUNT
(
pDevice
,
--
refcount
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment