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
f57d316c
Commit
f57d316c
authored
Mar 20, 2018
by
Matteo Bruni
Committed by
Alexandre Julliard
Mar 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9/tests: Add a test for texture refcounts and OnLostDevice().
Signed-off-by:
Matteo Bruni
<
mbruni@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1bba7c57
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
0 deletions
+118
-0
effect.c
dlls/d3dx9_36/tests/effect.c
+118
-0
No files found.
dlls/d3dx9_36/tests/effect.c
View file @
f57d316c
...
...
@@ -7368,6 +7368,123 @@ if (hr == D3D_OK)
DestroyWindow
(
window
);
}
static
unsigned
int
get_texture_refcount
(
IDirect3DTexture9
*
iface
)
{
IDirect3DTexture9_AddRef
(
iface
);
return
IDirect3DTexture9_Release
(
iface
);
}
static
void
test_refcount
(
void
)
{
IDirect3DTexture9
*
texture
,
*
cur_texture
,
*
managed_texture
,
*
sysmem_texture
;
unsigned
int
passes_count
;
IDirect3DDevice9
*
device
;
ID3DXEffect
*
effect
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
if
(
!
(
device
=
create_device
(
&
window
)))
return
;
hr
=
IDirect3DDevice9_CreateTexture
(
device
,
16
,
16
,
1
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
&
texture
,
NULL
);
ok
(
hr
==
D3D_OK
,
"Failed to create texture, hr %#x.
\n
"
,
hr
);
hr
=
D3DXCreateEffect
(
device
,
test_effect_preshader_effect_blob
,
sizeof
(
test_effect_preshader_effect_blob
),
NULL
,
NULL
,
D3DXFX_DONOTSAVESTATE
,
NULL
,
&
effect
,
NULL
);
ok
(
hr
==
D3D_OK
,
"Failed to create effect, hr %#x.
\n
"
,
hr
);
hr
=
effect
->
lpVtbl
->
SetTexture
(
effect
,
"tex1"
,
(
IDirect3DBaseTexture9
*
)
texture
);
ok
(
hr
==
D3D_OK
,
"Failed to set texture parameter, hr %#x.
\n
"
,
hr
);
hr
=
effect
->
lpVtbl
->
Begin
(
effect
,
&
passes_count
,
D3DXFX_DONOTSAVESTATE
);
ok
(
hr
==
D3D_OK
,
"Begin() failed, hr %#x.
\n
"
,
hr
);
hr
=
effect
->
lpVtbl
->
BeginPass
(
effect
,
0
);
ok
(
hr
==
D3D_OK
,
"BeginPass() failed, hr %#x.
\n
"
,
hr
);
IDirect3DDevice9_GetTexture
(
device
,
0
,
(
IDirect3DBaseTexture9
**
)
&
cur_texture
);
ok
(
cur_texture
==
texture
,
"Unexpected current texture %p.
\n
"
,
cur_texture
);
IDirect3DTexture9_Release
(
cur_texture
);
IDirect3DDevice9_SetTexture
(
device
,
0
,
NULL
);
effect
->
lpVtbl
->
CommitChanges
(
effect
);
IDirect3DDevice9_GetTexture
(
device
,
0
,
(
IDirect3DBaseTexture9
**
)
&
cur_texture
);
ok
(
cur_texture
==
NULL
,
"Unexpected current texture %p.
\n
"
,
cur_texture
);
hr
=
effect
->
lpVtbl
->
EndPass
(
effect
);
ok
(
hr
==
D3D_OK
,
"EndPass() failed, hr %#x.
\n
"
,
hr
);
hr
=
effect
->
lpVtbl
->
BeginPass
(
effect
,
0
);
ok
(
hr
==
D3D_OK
,
"BeginPass() failed, hr %#x.
\n
"
,
hr
);
IDirect3DDevice9_GetTexture
(
device
,
0
,
(
IDirect3DBaseTexture9
**
)
&
cur_texture
);
ok
(
cur_texture
==
texture
,
"Unexpected current texture %p.
\n
"
,
cur_texture
);
IDirect3DTexture9_Release
(
cur_texture
);
hr
=
effect
->
lpVtbl
->
EndPass
(
effect
);
ok
(
hr
==
D3D_OK
,
"EndPass() failed, hr %#x.
\n
"
,
hr
);
hr
=
effect
->
lpVtbl
->
End
(
effect
);
ok
(
hr
==
D3D_OK
,
"End() failed, hr %#x.
\n
"
,
hr
);
IDirect3DDevice9_GetTexture
(
device
,
0
,
(
IDirect3DBaseTexture9
**
)
&
cur_texture
);
ok
(
cur_texture
==
texture
,
"Unexpected current texture %p.
\n
"
,
cur_texture
);
IDirect3DTexture9_Release
(
cur_texture
);
refcount
=
get_texture_refcount
(
texture
);
ok
(
refcount
==
2
,
"Unexpected texture refcount %u.
\n
"
,
refcount
);
hr
=
effect
->
lpVtbl
->
OnLostDevice
(
effect
);
ok
(
hr
==
D3D_OK
,
"OnLostDevice() failed, hr %#x.
\n
"
,
hr
);
refcount
=
get_texture_refcount
(
texture
);
ok
(
refcount
==
1
,
"Unexpected texture refcount %u.
\n
"
,
refcount
);
hr
=
IDirect3DDevice9_CreateTexture
(
device
,
16
,
16
,
1
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_MANAGED
,
&
managed_texture
,
NULL
);
ok
(
hr
==
D3D_OK
,
"Failed to create texture, hr %#x.
\n
"
,
hr
);
effect
->
lpVtbl
->
SetTexture
(
effect
,
"tex1"
,
(
IDirect3DBaseTexture9
*
)
managed_texture
);
refcount
=
get_texture_refcount
(
managed_texture
);
ok
(
refcount
==
2
,
"Unexpected texture refcount %u.
\n
"
,
refcount
);
hr
=
effect
->
lpVtbl
->
OnLostDevice
(
effect
);
ok
(
hr
==
D3D_OK
,
"OnLostDevice() failed, hr %#x.
\n
"
,
hr
);
refcount
=
get_texture_refcount
(
managed_texture
);
ok
(
refcount
==
2
,
"Unexpected texture refcount %u.
\n
"
,
refcount
);
hr
=
IDirect3DDevice9_CreateTexture
(
device
,
16
,
16
,
1
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_SYSTEMMEM
,
&
sysmem_texture
,
NULL
);
ok
(
hr
==
D3D_OK
,
"Failed to create texture, hr %#x.
\n
"
,
hr
);
effect
->
lpVtbl
->
SetTexture
(
effect
,
"tex1"
,
(
IDirect3DBaseTexture9
*
)
sysmem_texture
);
refcount
=
get_texture_refcount
(
managed_texture
);
ok
(
refcount
==
1
,
"Unexpected texture refcount %u.
\n
"
,
refcount
);
IDirect3DTexture9_Release
(
managed_texture
);
refcount
=
get_texture_refcount
(
sysmem_texture
);
ok
(
refcount
==
2
,
"Unexpected texture refcount %u.
\n
"
,
refcount
);
hr
=
effect
->
lpVtbl
->
OnLostDevice
(
effect
);
ok
(
hr
==
D3D_OK
,
"OnLostDevice() failed, hr %#x.
\n
"
,
hr
);
refcount
=
get_texture_refcount
(
sysmem_texture
);
ok
(
refcount
==
2
,
"Unexpected texture refcount %u.
\n
"
,
refcount
);
effect
->
lpVtbl
->
Release
(
effect
);
refcount
=
get_texture_refcount
(
sysmem_texture
);
ok
(
refcount
==
1
,
"Unexpected texture refcount %u.
\n
"
,
refcount
);
IDirect3DTexture9_Release
(
sysmem_texture
);
IDirect3DDevice9_GetTexture
(
device
,
0
,
(
IDirect3DBaseTexture9
**
)
&
cur_texture
);
ok
(
cur_texture
==
texture
,
"Unexpected current texture %p.
\n
"
,
cur_texture
);
IDirect3DTexture9_Release
(
cur_texture
);
refcount
=
get_texture_refcount
(
texture
);
ok
(
refcount
==
1
,
"Unexpected texture refcount %u.
\n
"
,
refcount
);
IDirect3DTexture9_Release
(
texture
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
DestroyWindow
(
window
);
}
START_TEST
(
effect
)
{
IDirect3DDevice9
*
device
;
...
...
@@ -7404,4 +7521,5 @@ START_TEST(effect)
test_effect_unsupported_shader
();
test_effect_null_shader
();
test_effect_clone
();
test_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