Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
84faf3d8
Commit
84faf3d8
authored
Mar 07, 2014
by
Henri Verbeet
Committed by
Alexandre Julliard
Mar 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d9/tests: Use create_device() in more tests.
parent
0eb4616b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
398 additions
and
575 deletions
+398
-575
device.c
dlls/d3d9/tests/device.c
+398
-575
No files found.
dlls/d3d9/tests/device.c
View file @
84faf3d8
...
...
@@ -182,148 +182,113 @@ static void check_mipmap_levels(IDirect3DDevice9 *device, UINT width, UINT heigh
static
void
test_mipmap_levels
(
void
)
{
HRESULT
hr
;
IDirect3DDevice9
*
pDevice
=
NULL
;
D3DPRESENT_PARAMETERS
d3dpp
;
D3DDISPLAYMODE
d3ddm
;
IDirect3DDevice9
*
device
;
IDirect3D9
*
d3d
;
HWND
hwnd
;
ULONG
refcount
;
HWND
window
;
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d
,
"Failed to create a D3D object.
\n
"
);
IDirect3D9_GetAdapterDisplayMode
(
d3d
,
D3DADAPTER_DEFAULT
,
&
d3ddm
);
ZeroMemory
(
&
d3dpp
,
sizeof
(
d3dpp
)
);
d3dpp
.
Windowed
=
TRUE
;
d3dpp
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
d3dpp
.
BackBufferFormat
=
d3ddm
.
Format
;
hr
=
IDirect3D9_CreateDevice
(
d3d
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_NULLREF
,
hwnd
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
d3dpp
,
&
pDevice
);
ok
(
SUCCEEDED
(
hr
)
||
hr
==
D3DERR_NOTAVAILABLE
||
broken
(
hr
==
D3DERR_INVALIDCALL
),
"Failed to create IDirect3D9Device (%08x)
\n
"
,
hr
);
if
(
FAILED
(
hr
))
{
skip
(
"failed to create a d3d device
\n
"
);
if
(
!
(
device
=
create_device
(
d3d
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a 3D device, skipping test.
\n
"
);
goto
cleanup
;
}
check_mipmap_levels
(
pD
evice
,
32
,
32
,
6
);
check_mipmap_levels
(
pD
evice
,
256
,
1
,
9
);
check_mipmap_levels
(
pD
evice
,
1
,
256
,
9
);
check_mipmap_levels
(
pD
evice
,
1
,
1
,
1
);
check_mipmap_levels
(
d
evice
,
32
,
32
,
6
);
check_mipmap_levels
(
d
evice
,
256
,
1
,
9
);
check_mipmap_levels
(
d
evice
,
1
,
256
,
9
);
check_mipmap_levels
(
d
evice
,
1
,
1
,
1
);
cleanup:
if
(
pDevice
)
{
UINT
refcount
=
IDirect3DDevice9_Release
(
pDevice
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
cleanup:
IDirect3D9_Release
(
d3d
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_checkdevicemultisampletype
(
void
)
{
HRESULT
hr
;
IDirect3DDevice9
*
pDevice
=
NULL
;
D3DPRESENT_PARAMETERS
d3dpp
;
D3DDISPLAYMODE
d3ddm
;
DWORD
qualityLevels
;
IDirect3DDevice9
*
device
;
DWORD
quality_levels
;
IDirect3D9
*
d3d
;
HWND
hwnd
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d
,
"Failed to create a D3D object.
\n
"
);
IDirect3D9_GetAdapterDisplayMode
(
d3d
,
D3DADAPTER_DEFAULT
,
&
d3ddm
);
ZeroMemory
(
&
d3dpp
,
sizeof
(
d3dpp
)
);
d3dpp
.
Windowed
=
TRUE
;
d3dpp
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
d3dpp
.
BackBufferFormat
=
d3ddm
.
Format
;
hr
=
IDirect3D9_CreateDevice
(
d3d
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_NULLREF
,
hwnd
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
d3dpp
,
&
pDevice
);
ok
(
SUCCEEDED
(
hr
)
||
hr
==
D3DERR_NOTAVAILABLE
||
broken
(
hr
==
D3DERR_INVALIDCALL
),
"Failed to create IDirect3D9Device (%08x)
\n
"
,
hr
);
if
(
FAILED
(
hr
))
{
skip
(
"failed to create a d3d device
\n
"
);
if
(
!
(
device
=
create_device
(
d3d
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a 3D device, skipping test.
\n
"
);
goto
cleanup
;
}
qualityLevels
=
0
;
quality_levels
=
0
;
hr
=
IDirect3D9_CheckDeviceMultiSampleType
(
d3d
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
D3DFMT_X8R8G8B8
,
TRUE
,
D3DMULTISAMPLE_NONE
,
&
quality
L
evels
);
D3DFMT_X8R8G8B8
,
TRUE
,
D3DMULTISAMPLE_NONE
,
&
quality
_l
evels
);
ok
(
SUCCEEDED
(
hr
)
||
hr
==
D3DERR_NOTAVAILABLE
,
"CheckDeviceMultiSampleType failed with (%08x)
\n
"
,
hr
);
if
(
hr
==
D3DERR_NOTAVAILABLE
)
if
(
hr
==
D3DERR_NOTAVAILABLE
)
{
skip
(
"IDirect3D9_CheckDeviceMultiSampleType not available
\n
"
);
goto
cleanup
;
}
ok
(
quality
Levels
==
1
,
"qualitylevel is not 1 but %d
\n
"
,
qualityL
evels
);
ok
(
quality
_levels
==
1
,
"Got unexpected quality_levels %u.
\n
"
,
quality_l
evels
);
hr
=
IDirect3D9_CheckDeviceMultiSampleType
(
d3d
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
D3DFMT_X8R8G8B8
,
FALSE
,
D3DMULTISAMPLE_NONE
,
&
quality
L
evels
);
D3DFMT_X8R8G8B8
,
FALSE
,
D3DMULTISAMPLE_NONE
,
&
quality
_l
evels
);
ok
(
SUCCEEDED
(
hr
),
"CheckDeviceMultiSampleType failed with (%08x)
\n
"
,
hr
);
ok
(
quality
Levels
==
1
,
"qualitylevel is not 1 but %d
\n
"
,
qualityL
evels
);
ok
(
quality
_levels
==
1
,
"Got unexpected quality_levels %u.
\n
"
,
quality_l
evels
);
cleanup:
if
(
pD
evice
)
if
(
d
evice
)
{
UINT
refcount
=
IDirect3DDevice9_Release
(
pDevice
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
IDirect3D9_Release
(
d3d
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_swapchain
(
void
)
{
HRESULT
hr
;
IDirect3DDevice9
*
pDevice
=
NULL
;
IDirect3DSwapChain9
*
swapchain0
=
NULL
;
IDirect3DSwapChain9
*
swapchain1
=
NULL
;
IDirect3DSwapChain9
*
swapchain2
=
NULL
;
IDirect3DSwapChain9
*
swapchain3
=
NULL
;
IDirect3DSwapChain9
*
swapchainX
=
NULL
;
IDirect3DSurface9
*
backbuffer
=
NULL
;
IDirect3DSwapChain9
*
swapchain0
;
IDirect3DSwapChain9
*
swapchain1
;
IDirect3DSwapChain9
*
swapchain2
;
IDirect3DSwapChain9
*
swapchain3
;
IDirect3DSwapChain9
*
swapchainX
;
IDirect3DSurface9
*
backbuffer
;
D3DPRESENT_PARAMETERS
d3dpp
;
D3DDISPLAYMODE
d3ddm
;
IDirect3DDevice9
*
device
;
IDirect3D9
*
d3d
;
HWND
hwnd
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d
,
"Failed to create a D3D object.
\n
"
);
IDirect3D9_GetAdapterDisplayMode
(
d3d
,
D3DADAPTER_DEFAULT
,
&
d3ddm
);
ZeroMemory
(
&
d3dpp
,
sizeof
(
d3dpp
)
);
d3dpp
.
Windowed
=
TRUE
;
d3dpp
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
d3dpp
.
BackBufferFormat
=
d3ddm
.
Format
;
d3dpp
.
BackBufferCount
=
0
;
hr
=
IDirect3D9_CreateDevice
(
d3d
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
hwnd
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
d3dpp
,
&
pDevice
);
ok
(
hr
==
S_OK
||
hr
==
D3DERR_NOTAVAILABLE
||
broken
(
hr
==
D3DERR_INVALIDCALL
),
"Failed to create IDirect3D9Device (%08x)
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Check if the back buffer count was modified */
ok
(
d3dpp
.
BackBufferCount
==
1
,
"The back buffer count in the presentparams struct is %d
\n
"
,
d3dpp
.
BackBufferCount
);
if
(
!
(
device
=
create_device
(
d3d
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a 3D device, skipping test.
\n
"
);
goto
cleanup
;
}
/* Get the implicit swapchain */
hr
=
IDirect3DDevice9_GetSwapChain
(
pD
evice
,
0
,
&
swapchain0
);
hr
=
IDirect3DDevice9_GetSwapChain
(
d
evice
,
0
,
&
swapchain0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get the implicit swapchain (%08x)
\n
"
,
hr
);
if
(
swapchain0
)
IDirect3DSwapChain9_Release
(
swapchain0
);
/* Check if the back buffer count was modified */
hr
=
IDirect3DSwapChain9_GetPresentParameters
(
swapchain0
,
&
d3dpp
);
ok
(
d3dpp
.
BackBufferCount
==
1
,
"Got unexpected back buffer count %u.
\n
"
,
d3dpp
.
BackBufferCount
);
IDirect3DSwapChain9_Release
(
swapchain0
);
/* Check if there is a back buffer */
hr
=
IDirect3DSwapChain9_GetBackBuffer
(
swapchain0
,
0
,
D3DBACKBUFFER_TYPE_MONO
,
&
backbuffer
);
...
...
@@ -332,23 +297,23 @@ static void test_swapchain(void)
if
(
backbuffer
)
IDirect3DSurface9_Release
(
backbuffer
);
/* Try to get a nonexistent swapchain */
hr
=
IDirect3DDevice9_GetSwapChain
(
pD
evice
,
1
,
&
swapchainX
);
hr
=
IDirect3DDevice9_GetSwapChain
(
d
evice
,
1
,
&
swapchainX
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"GetSwapChain on an nonexistent swapchain returned (%08x)
\n
"
,
hr
);
ok
(
swapchainX
==
NULL
,
"Swapchain 1 is %p
\n
"
,
swapchainX
);
if
(
swapchainX
)
IDirect3DSwapChain9_Release
(
swapchainX
);
/* Create a bunch of swapchains */
d3dpp
.
BackBufferCount
=
0
;
hr
=
IDirect3DDevice9_CreateAdditionalSwapChain
(
pD
evice
,
&
d3dpp
,
&
swapchain1
);
hr
=
IDirect3DDevice9_CreateAdditionalSwapChain
(
d
evice
,
&
d3dpp
,
&
swapchain1
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a swapchain (%08x)
\n
"
,
hr
);
ok
(
d3dpp
.
BackBufferCount
==
1
,
"The back buffer count in the presentparams struct is %d
\n
"
,
d3dpp
.
BackBufferCount
);
d3dpp
.
BackBufferCount
=
1
;
hr
=
IDirect3DDevice9_CreateAdditionalSwapChain
(
pD
evice
,
&
d3dpp
,
&
swapchain2
);
hr
=
IDirect3DDevice9_CreateAdditionalSwapChain
(
d
evice
,
&
d3dpp
,
&
swapchain2
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a swapchain (%08x)
\n
"
,
hr
);
d3dpp
.
BackBufferCount
=
2
;
hr
=
IDirect3DDevice9_CreateAdditionalSwapChain
(
pD
evice
,
&
d3dpp
,
&
swapchain3
);
hr
=
IDirect3DDevice9_CreateAdditionalSwapChain
(
d
evice
,
&
d3dpp
,
&
swapchain3
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a swapchain (%08x)
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
/* Swapchain 3, created with backbuffercount 2 */
...
...
@@ -413,28 +378,23 @@ static void test_swapchain(void)
* it should fail, apparently GetSwapChain only returns implicit swapchains
*/
swapchainX
=
(
void
*
)
0xdeadbeef
;
hr
=
IDirect3DDevice9_GetSwapChain
(
pD
evice
,
1
,
&
swapchainX
);
hr
=
IDirect3DDevice9_GetSwapChain
(
d
evice
,
1
,
&
swapchainX
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"Failed to get the second swapchain (%08x)
\n
"
,
hr
);
ok
(
swapchainX
==
NULL
,
"The swapchain pointer is %p
\n
"
,
swapchainX
);
if
(
swapchainX
&&
swapchainX
!=
(
void
*
)
0xdeadbeef
)
IDirect3DSwapChain9_Release
(
swapchainX
);
cleanup:
if
(
swapchain1
)
IDirect3DSwapChain9_Release
(
swapchain1
);
if
(
swapchain2
)
IDirect3DSwapChain9_Release
(
swapchain2
);
if
(
swapchain3
)
IDirect3DSwapChain9_Release
(
swapchain3
);
if
(
pDevice
)
{
UINT
refcount
=
IDirect3DDevice9_Release
(
pDevice
);
IDirect3DSwapChain9_Release
(
swapchain3
);
IDirect3DSwapChain9_Release
(
swapchain2
);
IDirect3DSwapChain9_Release
(
swapchain1
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
cleanup:
IDirect3D9_Release
(
d3d
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_refcount
(
void
)
{
HRESULT
hr
;
IDirect3DDevice9
*
pDevice
=
NULL
;
IDirect3DVertexBuffer9
*
pVertexBuffer
=
NULL
;
IDirect3DIndexBuffer9
*
pIndexBuffer
=
NULL
;
IDirect3DVertexDeclaration9
*
pVertexDeclaration
=
NULL
;
...
...
@@ -456,45 +416,38 @@ static void test_refcount(void)
IDirect3DSwapChain9
*
pSwapChain
=
NULL
;
IDirect3DQuery9
*
pQuery
=
NULL
;
D3DPRESENT_PARAMETERS
d3dpp
;
D3DDISPLAYMODE
d3ddm
;
int
refcount
=
0
,
tmp
;
IDirect3DDevice9
*
device
;
ULONG
refcount
=
0
,
tmp
;
IDirect3D9
*
d3d
,
*
d3d2
;
HWND
hwnd
;
HWND
window
;
HRESULT
hr
;
D3DVERTEXELEMENT9
decl
[]
=
{
D3DDECL_END
()
};
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d
,
"Failed to create a D3D object.
\n
"
);
CHECK_REFCOUNT
(
d3d
,
1
);
IDirect3D9_GetAdapterDisplayMode
(
d3d
,
D3DADAPTER_DEFAULT
,
&
d3ddm
);
ZeroMemory
(
&
d3dpp
,
sizeof
(
d3dpp
)
);
d3dpp
.
Windowed
=
TRUE
;
d3dpp
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
d3dpp
.
BackBufferFormat
=
d3ddm
.
Format
;
d3dpp
.
EnableAutoDepthStencil
=
TRUE
;
d3dpp
.
AutoDepthStencilFormat
=
D3DFMT_D16
;
hr
=
IDirect3D9_CreateDevice
(
d3d
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
hwnd
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
d3dpp
,
&
pDevice
);
ok
(
hr
==
S_OK
||
hr
==
D3DERR_NOTAVAILABLE
||
broken
(
hr
==
D3DERR_INVALIDCALL
),
"Failed to create IDirect3D9Device (%08x)
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
cleanup
;
if
(
!
(
device
=
create_device
(
d3d
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a 3D device, skipping test.
\n
"
);
goto
cleanup
;
}
refcount
=
get_refcount
(
(
IUnknown
*
)
pDevice
);
refcount
=
get_refcount
(
(
IUnknown
*
)
device
);
ok
(
refcount
==
1
,
"Invalid device RefCount %d
\n
"
,
refcount
);
CHECK_REFCOUNT
(
d3d
,
2
);
hr
=
IDirect3DDevice9_GetDirect3D
(
pD
evice
,
&
d3d2
);
CHECK_CALL
(
hr
,
"GetDirect3D"
,
pDevice
,
refcount
);
hr
=
IDirect3DDevice9_GetDirect3D
(
d
evice
,
&
d3d2
);
CHECK_CALL
(
hr
,
"GetDirect3D"
,
device
,
refcount
);
ok
(
d3d2
==
d3d
,
"Expected IDirect3D9 pointers to be equal.
\n
"
);
CHECK_REFCOUNT
(
d3d
,
3
);
...
...
@@ -508,14 +461,14 @@ static void test_refcount(void)
* - they are not freed if refcount reaches 0.
* - the refcount is not forwarded to the container.
*/
hr
=
IDirect3DDevice9_GetSwapChain
(
pD
evice
,
0
,
&
pSwapChain
);
CHECK_CALL
(
hr
,
"GetSwapChain"
,
pD
evice
,
++
refcount
);
hr
=
IDirect3DDevice9_GetSwapChain
(
d
evice
,
0
,
&
pSwapChain
);
CHECK_CALL
(
hr
,
"GetSwapChain"
,
d
evice
,
++
refcount
);
if
(
pSwapChain
)
{
CHECK_REFCOUNT
(
pSwapChain
,
1
);
hr
=
IDirect3DDevice9_GetRenderTarget
(
pD
evice
,
0
,
&
pRenderTarget
);
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
pD
evice
,
++
refcount
);
hr
=
IDirect3DDevice9_GetRenderTarget
(
d
evice
,
0
,
&
pRenderTarget
);
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
d
evice
,
++
refcount
);
CHECK_REFCOUNT
(
pSwapChain
,
1
);
if
(
pRenderTarget
)
{
...
...
@@ -523,27 +476,27 @@ static void test_refcount(void)
CHECK_REFCOUNT
(
pRenderTarget
,
1
);
CHECK_ADDREF_REFCOUNT
(
pRenderTarget
,
2
);
CHECK_REFCOUNT
(
pD
evice
,
refcount
);
CHECK_REFCOUNT
(
d
evice
,
refcount
);
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
1
);
CHECK_REFCOUNT
(
pD
evice
,
refcount
);
CHECK_REFCOUNT
(
d
evice
,
refcount
);
hr
=
IDirect3DDevice9_GetRenderTarget
(
pD
evice
,
0
,
&
pRenderTarget
);
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
pD
evice
,
refcount
);
hr
=
IDirect3DDevice9_GetRenderTarget
(
d
evice
,
0
,
&
pRenderTarget
);
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
d
evice
,
refcount
);
CHECK_REFCOUNT
(
pRenderTarget
,
2
);
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
1
);
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
0
);
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
/* The render target is released with the device, so AddRef with refcount=0 is fine here. */
CHECK_ADDREF_REFCOUNT
(
pRenderTarget
,
1
);
CHECK_REFCOUNT
(
pD
evice
,
++
refcount
);
CHECK_REFCOUNT
(
d
evice
,
++
refcount
);
CHECK_RELEASE_REFCOUNT
(
pRenderTarget
,
0
);
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
}
/* Render target and back buffer are identical. */
hr
=
IDirect3DDevice9_GetBackBuffer
(
pD
evice
,
0
,
0
,
0
,
&
pBackBuffer
);
CHECK_CALL
(
hr
,
"GetBackBuffer"
,
pD
evice
,
++
refcount
);
hr
=
IDirect3DDevice9_GetBackBuffer
(
d
evice
,
0
,
0
,
0
,
&
pBackBuffer
);
CHECK_CALL
(
hr
,
"GetBackBuffer"
,
d
evice
,
++
refcount
);
if
(
pBackBuffer
)
{
CHECK_RELEASE_REFCOUNT
(
pBackBuffer
,
0
);
...
...
@@ -551,58 +504,58 @@ static void test_refcount(void)
pRenderTarget
,
pBackBuffer
);
pBackBuffer
=
NULL
;
}
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
hr
=
IDirect3DDevice9_GetDepthStencilSurface
(
pD
evice
,
&
pStencilSurface
);
CHECK_CALL
(
hr
,
"GetDepthStencilSurface"
,
pD
evice
,
++
refcount
);
hr
=
IDirect3DDevice9_GetDepthStencilSurface
(
d
evice
,
&
pStencilSurface
);
CHECK_CALL
(
hr
,
"GetDepthStencilSurface"
,
d
evice
,
++
refcount
);
CHECK_REFCOUNT
(
pSwapChain
,
1
);
if
(
pStencilSurface
)
{
CHECK_SURFACE_CONTAINER
(
pStencilSurface
,
IID_IDirect3DDevice9
,
pD
evice
);
CHECK_SURFACE_CONTAINER
(
pStencilSurface
,
IID_IDirect3DDevice9
,
d
evice
);
CHECK_REFCOUNT
(
pStencilSurface
,
1
);
CHECK_ADDREF_REFCOUNT
(
pStencilSurface
,
2
);
CHECK_REFCOUNT
(
pD
evice
,
refcount
);
CHECK_REFCOUNT
(
d
evice
,
refcount
);
CHECK_RELEASE_REFCOUNT
(
pStencilSurface
,
1
);
CHECK_REFCOUNT
(
pD
evice
,
refcount
);
CHECK_REFCOUNT
(
d
evice
,
refcount
);
CHECK_RELEASE_REFCOUNT
(
pStencilSurface
,
0
);
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
/* The stencil surface is released with the device, so AddRef with refcount=0 is fine here. */
CHECK_ADDREF_REFCOUNT
(
pStencilSurface
,
1
);
CHECK_REFCOUNT
(
pD
evice
,
++
refcount
);
CHECK_REFCOUNT
(
d
evice
,
++
refcount
);
CHECK_RELEASE_REFCOUNT
(
pStencilSurface
,
0
);
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
pStencilSurface
=
NULL
;
}
CHECK_RELEASE_REFCOUNT
(
pSwapChain
,
0
);
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
/* The implicit swapchwin is released with the device, so AddRef with refcount=0 is fine here. */
CHECK_ADDREF_REFCOUNT
(
pSwapChain
,
1
);
CHECK_REFCOUNT
(
pD
evice
,
++
refcount
);
CHECK_REFCOUNT
(
d
evice
,
++
refcount
);
CHECK_RELEASE_REFCOUNT
(
pSwapChain
,
0
);
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
pSwapChain
=
NULL
;
}
/* Buffers */
hr
=
IDirect3DDevice9_CreateIndexBuffer
(
pDevice
,
16
,
0
,
D3DFMT_INDEX32
,
D3DPOOL_DEFAULT
,
&
pIndexBuffer
,
NULL
);
CHECK_CALL
(
hr
,
"CreateIndexBuffer"
,
pD
evice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateIndexBuffer
(
device
,
16
,
0
,
D3DFMT_INDEX32
,
D3DPOOL_DEFAULT
,
&
pIndexBuffer
,
NULL
);
CHECK_CALL
(
hr
,
"CreateIndexBuffer"
,
d
evice
,
++
refcount
);
if
(
pIndexBuffer
)
{
tmp
=
get_refcount
(
(
IUnknown
*
)
pIndexBuffer
);
hr
=
IDirect3DDevice9_SetIndices
(
pD
evice
,
pIndexBuffer
);
hr
=
IDirect3DDevice9_SetIndices
(
d
evice
,
pIndexBuffer
);
CHECK_CALL
(
hr
,
"SetIndices"
,
pIndexBuffer
,
tmp
);
hr
=
IDirect3DDevice9_SetIndices
(
pD
evice
,
NULL
);
hr
=
IDirect3DDevice9_SetIndices
(
d
evice
,
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
);
hr
=
IDirect3DDevice9_CreateVertexBuffer
(
device
,
16
,
0
,
D3DFVF_XYZ
,
D3DPOOL_DEFAULT
,
&
pVertexBuffer
,
NULL
);
CHECK_CALL
(
hr
,
"CreateVertexBuffer"
,
device
,
++
refcount
);
if
(
pVertexBuffer
)
{
IDirect3DVertexBuffer9
*
pVBuf
=
(
void
*
)
~
0
;
...
...
@@ -611,40 +564,40 @@ static void test_refcount(void)
tmp
=
get_refcount
(
(
IUnknown
*
)
pVertexBuffer
);
hr
=
IDirect3DDevice9_SetStreamSource
(
pD
evice
,
0
,
pVertexBuffer
,
0
,
3
*
sizeof
(
float
));
hr
=
IDirect3DDevice9_SetStreamSource
(
d
evice
,
0
,
pVertexBuffer
,
0
,
3
*
sizeof
(
float
));
CHECK_CALL
(
hr
,
"SetStreamSource"
,
pVertexBuffer
,
tmp
);
hr
=
IDirect3DDevice9_SetStreamSource
(
pD
evice
,
0
,
NULL
,
0
,
0
);
hr
=
IDirect3DDevice9_SetStreamSource
(
d
evice
,
0
,
NULL
,
0
,
0
);
CHECK_CALL
(
hr
,
"SetStreamSource"
,
pVertexBuffer
,
tmp
);
hr
=
IDirect3DDevice9_GetStreamSource
(
pD
evice
,
0
,
&
pVBuf
,
&
offset
,
&
stride
);
hr
=
IDirect3DDevice9_GetStreamSource
(
d
evice
,
0
,
&
pVBuf
,
&
offset
,
&
stride
);
ok
(
SUCCEEDED
(
hr
),
"GetStreamSource did not succeed with NULL stream!
\n
"
);
ok
(
pVBuf
==
NULL
,
"pVBuf not NULL (%p)!
\n
"
,
pVBuf
);
ok
(
stride
==
3
*
sizeof
(
float
),
"stride not 3 floats (got %u)!
\n
"
,
stride
);
ok
(
offset
==
0
,
"offset not 0 (got %u)!
\n
"
,
offset
);
}
/* Shaders */
hr
=
IDirect3DDevice9_CreateVertexDeclaration
(
pDevice
,
decl
,
&
pVertexDeclaration
);
CHECK_CALL
(
hr
,
"CreateVertexDeclaration"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateVertexShader
(
pDevice
,
simple_vs
,
&
pVertexShader
);
CHECK_CALL
(
hr
,
"CreateVertexShader"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreatePixelShader
(
pDevice
,
simple_ps
,
&
pPixelShader
);
CHECK_CALL
(
hr
,
"CreatePixelShader"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateVertexDeclaration
(
device
,
decl
,
&
pVertexDeclaration
);
CHECK_CALL
(
hr
,
"CreateVertexDeclaration"
,
device
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateVertexShader
(
device
,
simple_vs
,
&
pVertexShader
);
CHECK_CALL
(
hr
,
"CreateVertexShader"
,
device
,
++
refcount
);
hr
=
IDirect3DDevice9_CreatePixelShader
(
device
,
simple_ps
,
&
pPixelShader
);
CHECK_CALL
(
hr
,
"CreatePixelShader"
,
device
,
++
refcount
);
/* Textures */
hr
=
IDirect3DDevice9_CreateTexture
(
pDevice
,
32
,
32
,
3
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pTexture
,
NULL
);
CHECK_CALL
(
hr
,
"CreateTexture"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateTexture
(
device
,
32
,
32
,
3
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pTexture
,
NULL
);
CHECK_CALL
(
hr
,
"CreateTexture"
,
device
,
++
refcount
);
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
(
pD
evice
,
0
,
NULL
);
CHECK_CALL
(
hr
,
"SetTexture"
,
pTexture
,
tmp
);
hr
=
IDirect3DDevice9_SetTexture
(
device
,
0
,
(
IDirect3DBaseTexture9
*
)
pTexture
);
CHECK_CALL
(
hr
,
"SetTexture"
,
pTexture
,
tmp
);
hr
=
IDirect3DDevice9_SetTexture
(
d
evice
,
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
);
CHECK_CALL
(
hr
,
"GetSurfaceLevel"
,
device
,
refcount
);
/* But should increment texture's refcount */
CHECK_REFCOUNT
(
pTexture
,
tmp
+
1
);
/* Because the texture and surface refcount are identical */
...
...
@@ -659,17 +612,18 @@ static void test_refcount(void)
CHECK_REFCOUNT
(
pTextureLevel
,
tmp
);
}
}
hr
=
IDirect3DDevice9_CreateCubeTexture
(
pDevice
,
32
,
0
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pCubeTexture
,
NULL
);
CHECK_CALL
(
hr
,
"CreateCubeTexture"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateVolumeTexture
(
pDevice
,
32
,
32
,
2
,
0
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pVolumeTexture
,
NULL
);
CHECK_CALL
(
hr
,
"CreateVolumeTexture"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateCubeTexture
(
device
,
32
,
0
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pCubeTexture
,
NULL
);
CHECK_CALL
(
hr
,
"CreateCubeTexture"
,
device
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateVolumeTexture
(
device
,
32
,
32
,
2
,
0
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pVolumeTexture
,
NULL
);
CHECK_CALL
(
hr
,
"CreateVolumeTexture"
,
device
,
++
refcount
);
if
(
pVolumeTexture
)
{
tmp
=
get_refcount
(
(
IUnknown
*
)
pVolumeTexture
);
/* This should not increment device refcount */
hr
=
IDirect3DVolumeTexture9_GetVolumeLevel
(
pVolumeTexture
,
0
,
&
pVolumeLevel
);
CHECK_CALL
(
hr
,
"GetVolumeLevel"
,
pDevice
,
refcount
);
CHECK_CALL
(
hr
,
"GetVolumeLevel"
,
device
,
refcount
);
/* But should increment volume texture's refcount */
CHECK_REFCOUNT
(
pVolumeTexture
,
tmp
+
1
);
/* Because the volume texture and volume refcount are identical */
...
...
@@ -685,143 +639,146 @@ static void test_refcount(void)
}
}
/* Surfaces */
hr
=
IDirect3DDevice9_CreateDepthStencilSurface
(
pDevice
,
32
,
32
,
D3DFMT_D24S8
,
D3DMULTISAMPLE_NONE
,
0
,
TRUE
,
&
pStencilSurface
,
NULL
);
CHECK_CALL
(
hr
,
"CreateDepthStencilSurface"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateDepthStencilSurface
(
device
,
32
,
32
,
D3DFMT_D24S8
,
D3DMULTISAMPLE_NONE
,
0
,
TRUE
,
&
pStencilSurface
,
NULL
);
CHECK_CALL
(
hr
,
"CreateDepthStencilSurface"
,
device
,
++
refcount
);
CHECK_REFCOUNT
(
pStencilSurface
,
1
);
hr
=
IDirect3DDevice9_CreateOffscreenPlainSurface
(
pDevice
,
32
,
32
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pOffscreenSurface
,
NULL
);
CHECK_CALL
(
hr
,
"CreateOffscreenPlainSurface"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateOffscreenPlainSurface
(
device
,
32
,
32
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pOffscreenSurface
,
NULL
);
CHECK_CALL
(
hr
,
"CreateOffscreenPlainSurface"
,
device
,
++
refcount
);
CHECK_REFCOUNT
(
pOffscreenSurface
,
1
);
hr
=
IDirect3DDevice9_CreateRenderTarget
(
pDevice
,
32
,
32
,
D3DFMT_X8R8G8B8
,
D3DMULTISAMPLE_NONE
,
0
,
TRUE
,
&
pRenderTarget3
,
NULL
);
CHECK_CALL
(
hr
,
"CreateRenderTarget"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateRenderTarget
(
device
,
32
,
32
,
D3DFMT_X8R8G8B8
,
D3DMULTISAMPLE_NONE
,
0
,
TRUE
,
&
pRenderTarget3
,
NULL
);
CHECK_CALL
(
hr
,
"CreateRenderTarget"
,
device
,
++
refcount
);
CHECK_REFCOUNT
(
pRenderTarget3
,
1
);
/* Misc */
hr
=
IDirect3DDevice9_CreateStateBlock
(
pDevice
,
D3DSBT_ALL
,
&
pStateBlock
);
CHECK_CALL
(
hr
,
"CreateStateBlock"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateAdditionalSwapChain
(
pDevice
,
&
d3dpp
,
&
pSwapChain
);
CHECK_CALL
(
hr
,
"CreateAdditionalSwapChain"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateStateBlock
(
device
,
D3DSBT_ALL
,
&
pStateBlock
);
CHECK_CALL
(
hr
,
"CreateStateBlock"
,
device
,
++
refcount
);
memset
(
&
d3dpp
,
0
,
sizeof
(
d3dpp
));
d3dpp
.
Windowed
=
TRUE
;
d3dpp
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
d3dpp
.
BackBufferFormat
=
D3DFMT_A8R8G8B8
;
d3dpp
.
EnableAutoDepthStencil
=
TRUE
;
d3dpp
.
AutoDepthStencilFormat
=
D3DFMT_D24S8
;
hr
=
IDirect3DDevice9_CreateAdditionalSwapChain
(
device
,
&
d3dpp
,
&
pSwapChain
);
CHECK_CALL
(
hr
,
"CreateAdditionalSwapChain"
,
device
,
++
refcount
);
if
(
pSwapChain
)
{
/* check implicit back buffer */
hr
=
IDirect3DSwapChain9_GetBackBuffer
(
pSwapChain
,
0
,
0
,
&
pBackBuffer
);
CHECK_CALL
(
hr
,
"GetBackBuffer"
,
pD
evice
,
++
refcount
);
CHECK_CALL
(
hr
,
"GetBackBuffer"
,
d
evice
,
++
refcount
);
CHECK_REFCOUNT
(
pSwapChain
,
1
);
if
(
pBackBuffer
)
{
CHECK_SURFACE_CONTAINER
(
pBackBuffer
,
IID_IDirect3DSwapChain9
,
pSwapChain
);
CHECK_REFCOUNT
(
pBackBuffer
,
1
);
CHECK_RELEASE_REFCOUNT
(
pBackBuffer
,
0
);
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
/* The back buffer is released with the swapchain, so AddRef with refcount=0 is fine here. */
CHECK_ADDREF_REFCOUNT
(
pBackBuffer
,
1
);
CHECK_REFCOUNT
(
pD
evice
,
++
refcount
);
CHECK_REFCOUNT
(
d
evice
,
++
refcount
);
CHECK_RELEASE_REFCOUNT
(
pBackBuffer
,
0
);
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
pBackBuffer
=
NULL
;
}
CHECK_REFCOUNT
(
pSwapChain
,
1
);
}
hr
=
IDirect3DDevice9_CreateQuery
(
pDevice
,
D3DQUERYTYPE_EVENT
,
&
pQuery
);
CHECK_CALL
(
hr
,
"CreateQuery"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_CreateQuery
(
device
,
D3DQUERYTYPE_EVENT
,
&
pQuery
);
CHECK_CALL
(
hr
,
"CreateQuery"
,
device
,
++
refcount
);
hr
=
IDirect3DDevice9_BeginStateBlock
(
pDevice
);
CHECK_CALL
(
hr
,
"BeginStateBlock"
,
pDevice
,
refcount
);
hr
=
IDirect3DDevice9_EndStateBlock
(
pDevice
,
&
pStateBlock1
);
CHECK_CALL
(
hr
,
"EndStateBlock"
,
pDevice
,
++
refcount
);
hr
=
IDirect3DDevice9_BeginStateBlock
(
device
);
CHECK_CALL
(
hr
,
"BeginStateBlock"
,
device
,
refcount
);
hr
=
IDirect3DDevice9_EndStateBlock
(
device
,
&
pStateBlock1
);
CHECK_CALL
(
hr
,
"EndStateBlock"
,
device
,
++
refcount
);
/* The implicit render target is not freed if refcount reaches 0.
* Otherwise GetRenderTarget would re-allocate it and the pointer would change.*/
hr
=
IDirect3DDevice9_GetRenderTarget
(
pD
evice
,
0
,
&
pRenderTarget2
);
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
pD
evice
,
++
refcount
);
hr
=
IDirect3DDevice9_GetRenderTarget
(
d
evice
,
0
,
&
pRenderTarget2
);
CHECK_CALL
(
hr
,
"GetRenderTarget"
,
d
evice
,
++
refcount
);
if
(
pRenderTarget2
)
{
CHECK_RELEASE_REFCOUNT
(
pRenderTarget2
,
0
);
ok
(
pRenderTarget
==
pRenderTarget2
,
"RenderTarget=%p and RenderTarget2=%p should be the same.
\n
"
,
pRenderTarget
,
pRenderTarget2
);
CHECK_REFCOUNT
(
pD
evice
,
--
refcount
);
CHECK_REFCOUNT
(
d
evice
,
--
refcount
);
pRenderTarget2
=
NULL
;
}
pRenderTarget
=
NULL
;
cleanup:
CHECK_RELEASE
(
pDevice
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
device
,
d
evice
,
--
refcount
);
/* Buffers */
CHECK_RELEASE
(
pVertexBuffer
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pIndexBuffer
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pVertexBuffer
,
d
evice
,
--
refcount
);
CHECK_RELEASE
(
pIndexBuffer
,
d
evice
,
--
refcount
);
/* Shaders */
CHECK_RELEASE
(
pVertexDeclaration
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pVertexShader
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pPixelShader
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pVertexDeclaration
,
d
evice
,
--
refcount
);
CHECK_RELEASE
(
pVertexShader
,
d
evice
,
--
refcount
);
CHECK_RELEASE
(
pPixelShader
,
d
evice
,
--
refcount
);
/* Textures */
CHECK_RELEASE
(
pTextureLevel
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pCubeTexture
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pVolumeTexture
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pTextureLevel
,
d
evice
,
--
refcount
);
CHECK_RELEASE
(
pCubeTexture
,
d
evice
,
--
refcount
);
CHECK_RELEASE
(
pVolumeTexture
,
d
evice
,
--
refcount
);
/* Surfaces */
CHECK_RELEASE
(
pStencilSurface
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pOffscreenSurface
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pRenderTarget3
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pStencilSurface
,
d
evice
,
--
refcount
);
CHECK_RELEASE
(
pOffscreenSurface
,
d
evice
,
--
refcount
);
CHECK_RELEASE
(
pRenderTarget3
,
d
evice
,
--
refcount
);
/* Misc */
CHECK_RELEASE
(
pStateBlock
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pSwapChain
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pQuery
,
pD
evice
,
--
refcount
);
CHECK_RELEASE
(
pStateBlock
,
d
evice
,
--
refcount
);
CHECK_RELEASE
(
pSwapChain
,
d
evice
,
--
refcount
);
CHECK_RELEASE
(
pQuery
,
d
evice
,
--
refcount
);
/* This will destroy device - cannot check the refcount here */
if
(
pStateBlock1
)
CHECK_RELEASE_REFCOUNT
(
pStateBlock1
,
0
);
CHECK_RELEASE_REFCOUNT
(
d3d
,
0
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_cursor
(
void
)
{
HRESULT
hr
;
IDirect3DDevice9
*
pDevice
=
NULL
;
D3DPRESENT_PARAMETERS
d3dpp
;
D3DDISPLAYMODE
d3ddm
;
CURSORINFO
info
;
IDirect3DSurface9
*
cursor
=
NULL
;
IDirect3DDevice9
*
device
;
CURSORINFO
info
;
IDirect3D9
*
d3d
;
ULONG
refcount
;
HCURSOR
cur
;
HWND
hwnd
;
HWND
window
;
HRESULT
hr
;
memset
(
&
info
,
0
,
sizeof
(
info
));
info
.
cbSize
=
sizeof
(
info
);
ok
(
GetCursorInfo
(
&
info
),
"GetCursorInfo failed
\n
"
);
cur
=
info
.
hCursor
;
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d
,
"Failed to create a D3D object.
\n
"
);
if
(
!
(
device
=
create_device
(
d3d
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a 3D device, skipping test.
\n
"
);
goto
cleanup
;
}
IDirect3D9_GetAdapterDisplayMode
(
d3d
,
D3DADAPTER_DEFAULT
,
&
d3ddm
);
ZeroMemory
(
&
d3dpp
,
sizeof
(
d3dpp
)
);
d3dpp
.
Windowed
=
TRUE
;
d3dpp
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
d3dpp
.
BackBufferFormat
=
d3ddm
.
Format
;
hr
=
IDirect3D9_CreateDevice
(
d3d
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
hwnd
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
d3dpp
,
&
pDevice
);
ok
(
hr
==
S_OK
||
hr
==
D3DERR_NOTAVAILABLE
||
broken
(
hr
==
D3DERR_INVALIDCALL
),
"Failed to create IDirect3D9Device (%08x)
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
cleanup
;
IDirect3DDevice9_CreateOffscreenPlainSurface
(
pDevice
,
32
,
32
,
D3DFMT_A8R8G8B8
,
D3DPOOL_SCRATCH
,
&
cursor
,
0
);
ok
(
cursor
!=
NULL
,
"IDirect3DDevice9_CreateOffscreenPlainSurface failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_CreateOffscreenPlainSurface
(
device
,
32
,
32
,
D3DFMT_A8R8G8B8
,
D3DPOOL_SCRATCH
,
&
cursor
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create cursor surface, hr %#x.
\n
"
,
hr
);
/* Initially hidden */
hr
=
IDirect3DDevice9_ShowCursor
(
pD
evice
,
TRUE
);
hr
=
IDirect3DDevice9_ShowCursor
(
d
evice
,
TRUE
);
ok
(
hr
==
FALSE
,
"IDirect3DDevice9_ShowCursor returned %08x
\n
"
,
hr
);
/* Not enabled without a surface*/
hr
=
IDirect3DDevice9_ShowCursor
(
pD
evice
,
TRUE
);
hr
=
IDirect3DDevice9_ShowCursor
(
d
evice
,
TRUE
);
ok
(
hr
==
FALSE
,
"IDirect3DDevice9_ShowCursor returned %08x
\n
"
,
hr
);
/* Fails */
hr
=
IDirect3DDevice9_SetCursorProperties
(
pD
evice
,
0
,
0
,
NULL
);
hr
=
IDirect3DDevice9_SetCursorProperties
(
d
evice
,
0
,
0
,
NULL
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"IDirect3DDevice9_SetCursorProperties returned %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetCursorProperties
(
pD
evice
,
0
,
0
,
cursor
);
hr
=
IDirect3DDevice9_SetCursorProperties
(
d
evice
,
0
,
0
,
cursor
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetCursorProperties returned %08x
\n
"
,
hr
);
IDirect3DSurface9_Release
(
cursor
);
...
...
@@ -833,11 +790,11 @@ static void test_cursor(void)
ok
(
info
.
hCursor
==
cur
,
"The cursor handle is %p
\n
"
,
info
.
hCursor
);
/* unchanged */
/* Still hidden */
hr
=
IDirect3DDevice9_ShowCursor
(
pD
evice
,
TRUE
);
hr
=
IDirect3DDevice9_ShowCursor
(
d
evice
,
TRUE
);
ok
(
hr
==
FALSE
,
"IDirect3DDevice9_ShowCursor returned %08x
\n
"
,
hr
);
/* Enabled now*/
hr
=
IDirect3DDevice9_ShowCursor
(
pD
evice
,
TRUE
);
hr
=
IDirect3DDevice9_ShowCursor
(
d
evice
,
TRUE
);
ok
(
hr
==
TRUE
,
"IDirect3DDevice9_ShowCursor returned %08x
\n
"
,
hr
);
/* GDI cursor unchanged */
...
...
@@ -847,14 +804,11 @@ static void test_cursor(void)
ok
(
info
.
flags
&
CURSOR_SHOWING
,
"The gdi cursor is hidden (%08x)
\n
"
,
info
.
flags
);
ok
(
info
.
hCursor
==
cur
,
"The cursor handle is %p
\n
"
,
info
.
hCursor
);
/* unchanged */
cleanup:
if
(
pDevice
)
{
UINT
refcount
=
IDirect3DDevice9_Release
(
pDevice
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
cleanup:
IDirect3D9_Release
(
d3d
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_reset
(
void
)
...
...
@@ -1438,232 +1392,182 @@ static void test_display_modes(void)
static
void
test_scene
(
void
)
{
HRESULT
hr
;
IDirect3DDevice9
*
pDevice
=
NULL
;
D3DPRESENT_PARAMETERS
d3dpp
;
D3DDISPLAYMODE
d3ddm
;
IDirect3DSurface9
*
pSurface1
=
NULL
,
*
pSurface2
=
NULL
,
*
pSurface3
=
NULL
,
*
pRenderTarget
=
NULL
;
IDirect3DSurface9
*
pBackBuffer
=
NULL
,
*
pDepthStencil
=
NULL
;
IDirect3DSurface9
*
surface1
,
*
surface2
,
*
surface3
;
IDirect3DSurface9
*
backBuffer
,
*
rt
,
*
ds
;
RECT
rect
=
{
0
,
0
,
128
,
128
};
IDirect3DDevice9
*
device
;
IDirect3D9
*
d3d
;
ULONG
refcount
;
D3DCAPS9
caps
;
HWND
hwnd
;
HWND
window
;
HRESULT
hr
;
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d
,
"Failed to create a D3D object.
\n
"
);
IDirect3D9_GetAdapterDisplayMode
(
d3d
,
D3DADAPTER_DEFAULT
,
&
d3ddm
);
ZeroMemory
(
&
d3dpp
,
sizeof
(
d3dpp
)
);
d3dpp
.
Windowed
=
TRUE
;
d3dpp
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
d3dpp
.
BackBufferWidth
=
800
;
d3dpp
.
BackBufferHeight
=
600
;
d3dpp
.
BackBufferFormat
=
d3ddm
.
Format
;
d3dpp
.
EnableAutoDepthStencil
=
TRUE
;
d3dpp
.
AutoDepthStencilFormat
=
D3DFMT_D16
;
hr
=
IDirect3D9_CreateDevice
(
d3d
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
/* no NULLREF here */
,
hwnd
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
d3dpp
,
&
pDevice
);
ok
(
hr
==
D3D_OK
||
hr
==
D3DERR_NOTAVAILABLE
||
broken
(
hr
==
D3DERR_INVALIDCALL
),
"IDirect3D9_CreateDevice failed with %08x
\n
"
,
hr
);
if
(
!
pDevice
)
if
(
!
(
device
=
create_device
(
d3d
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a
d3d device
\n
"
);
skip
(
"Failed to create a
3D device, skipping test.
\n
"
);
goto
cleanup
;
}
/* Get the caps, they will be needed to tell if an operation is supposed to be valid */
memset
(
&
caps
,
0
,
sizeof
(
caps
));
hr
=
IDirect3DDevice9_GetDeviceCaps
(
pD
evice
,
&
caps
);
hr
=
IDirect3DDevice9_GetDeviceCaps
(
d
evice
,
&
caps
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_GetCaps failed with %08x
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Test an EndScene without BeginScene. Should return an error */
hr
=
IDirect3DDevice9_EndScene
(
pD
evice
);
hr
=
IDirect3DDevice9_EndScene
(
d
evice
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"IDirect3DDevice9_EndScene returned %08x
\n
"
,
hr
);
/* Test a normal BeginScene / EndScene pair, this should work */
hr
=
IDirect3DDevice9_BeginScene
(
pD
evice
);
hr
=
IDirect3DDevice9_BeginScene
(
d
evice
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_BeginScene failed with %08x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
hr
=
IDirect3DDevice9_EndScene
(
pDevice
);
hr
=
IDirect3DDevice9_EndScene
(
device
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_EndScene failed with %08x
\n
"
,
hr
);
}
/* Test another EndScene without having begun a new scene. Should return an error */
hr
=
IDirect3DDevice9_EndScene
(
pD
evice
);
hr
=
IDirect3DDevice9_EndScene
(
d
evice
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"IDirect3DDevice9_EndScene returned %08x
\n
"
,
hr
);
/* Two nested BeginScene and EndScene calls */
hr
=
IDirect3DDevice9_BeginScene
(
pD
evice
);
hr
=
IDirect3DDevice9_BeginScene
(
d
evice
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_BeginScene failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_BeginScene
(
pD
evice
);
hr
=
IDirect3DDevice9_BeginScene
(
d
evice
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"IDirect3DDevice9_BeginScene returned %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_EndScene
(
pD
evice
);
hr
=
IDirect3DDevice9_EndScene
(
d
evice
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_EndScene failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_EndScene
(
pD
evice
);
hr
=
IDirect3DDevice9_EndScene
(
d
evice
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"IDirect3DDevice9_EndScene returned %08x
\n
"
,
hr
);
/* Create some surfaces to test stretchrect between the scenes */
hr
=
IDirect3DDevice9_CreateOffscreenPlainSurface
(
pDevice
,
128
,
128
,
D3DFMT_A8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pSurface1
,
NULL
);
hr
=
IDirect3DDevice9_CreateOffscreenPlainSurface
(
device
,
128
,
128
,
D3DFMT_A8R8G8B8
,
D3DPOOL_DEFAULT
,
&
surface1
,
NULL
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_CreateOffscreenPlainSurface failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_CreateOffscreenPlainSurface
(
pDevice
,
128
,
128
,
D3DFMT_A8R8G8B8
,
D3DPOOL_DEFAULT
,
&
pSurface2
,
NULL
);
hr
=
IDirect3DDevice9_CreateOffscreenPlainSurface
(
device
,
128
,
128
,
D3DFMT_A8R8G8B8
,
D3DPOOL_DEFAULT
,
&
surface2
,
NULL
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_CreateOffscreenPlainSurface failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_CreateDepthStencilSurface
(
pDevice
,
800
,
600
,
D3DFMT_D16
,
D3DMULTISAMPLE_NONE
,
0
,
FALSE
,
&
pSurface3
,
NULL
);
hr
=
IDirect3DDevice9_CreateDepthStencilSurface
(
device
,
800
,
600
,
D3DFMT_D16
,
D3DMULTISAMPLE_NONE
,
0
,
FALSE
,
&
surface3
,
NULL
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_CreateDepthStencilSurface failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_CreateRenderTarget
(
pDevice
,
128
,
128
,
d3ddm
.
Format
,
D3DMULTISAMPLE_NONE
,
0
,
FALSE
,
&
pRenderTarget
,
NULL
);
hr
=
IDirect3DDevice9_CreateRenderTarget
(
device
,
128
,
128
,
D3DFMT_A8R8G8B8
,
D3DMULTISAMPLE_NONE
,
0
,
FALSE
,
&
rt
,
NULL
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_CreateRenderTarget failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_GetBackBuffer
(
pDevice
,
0
,
0
,
D3DBACKBUFFER_TYPE_MONO
,
&
pB
ackBuffer
);
hr
=
IDirect3DDevice9_GetBackBuffer
(
device
,
0
,
0
,
D3DBACKBUFFER_TYPE_MONO
,
&
b
ackBuffer
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_GetBackBuffer failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_GetDepthStencilSurface
(
pDevice
,
&
pDepthStencil
);
hr
=
IDirect3DDevice9_GetDepthStencilSurface
(
device
,
&
ds
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_GetBackBuffer failed with %08x
\n
"
,
hr
);
/* First make sure a simple StretchRect call works */
if
(
pSurface1
&&
pSurface2
)
{
hr
=
IDirect3DDevice9_StretchRect
(
pDevice
,
pSurface1
,
NULL
,
pSurface2
,
NULL
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_StretchRect failed with %08x
\n
"
,
hr
);
}
if
(
pBackBuffer
&&
pRenderTarget
)
{
hr
=
IDirect3DDevice9_StretchRect
(
pDevice
,
pBackBuffer
,
&
rect
,
pRenderTarget
,
NULL
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_StretchRect failed with %08x
\n
"
,
hr
);
}
if
(
pDepthStencil
&&
pSurface3
)
{
HRESULT
expected
;
if
(
0
)
/* Disabled for now because it crashes in wine */
{
expected
=
caps
.
DevCaps2
&
D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
?
D3D_OK
:
D3DERR_INVALIDCALL
;
hr
=
IDirect3DDevice9_StretchRect
(
pDevice
,
pDepthStencil
,
NULL
,
pSurface3
,
NULL
,
0
);
ok
(
hr
==
expected
,
"IDirect3DDevice9_StretchRect returned %08x, expected %08x
\n
"
,
hr
,
expected
);
}
hr
=
IDirect3DDevice9_StretchRect
(
device
,
surface1
,
NULL
,
surface2
,
NULL
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_StretchRect failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_StretchRect
(
device
,
backBuffer
,
&
rect
,
rt
,
NULL
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_StretchRect failed with %08x
\n
"
,
hr
);
if
(
0
)
/* Disabled for now because it crashes in wine */
{
HRESULT
expected
=
caps
.
DevCaps2
&
D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
?
D3D_OK
:
D3DERR_INVALIDCALL
;
hr
=
IDirect3DDevice9_StretchRect
(
device
,
ds
,
NULL
,
surface3
,
NULL
,
0
);
ok
(
hr
==
expected
,
"Got unexpected hr %#x, expected %#x.
\n
"
,
hr
,
expected
);
}
/* Now try it in a BeginScene - EndScene pair. Seems to be allowed in a
beginScene - Endscene pair
*
with normal surfaces and render targets, but not depth stencil surfaces.
*/
hr
=
IDirect3DDevice9_BeginScene
(
pD
evice
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_BeginScene failed with %08x
\n
"
,
hr
);
/* Now try it in a BeginScene - EndScene pair. Seems to be allowed in a
*
BeginScene - Endscene pair with normal surfaces and render targets, but
*
not depth stencil surfaces. *
/
hr
=
IDirect3DDevice9_BeginScene
(
d
evice
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_BeginScene failed with %08x
\n
"
,
hr
);
if
(
pSurface1
&&
pSurface2
)
{
hr
=
IDirect3DDevice9_StretchRect
(
pDevice
,
pSurface1
,
NULL
,
pSurface2
,
NULL
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_StretchRect failed with %08x
\n
"
,
hr
);
}
if
(
pBackBuffer
&&
pRenderTarget
)
{
hr
=
IDirect3DDevice9_StretchRect
(
pDevice
,
pBackBuffer
,
&
rect
,
pRenderTarget
,
NULL
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_StretchRect failed with %08x
\n
"
,
hr
);
}
if
(
pDepthStencil
&&
pSurface3
)
{
hr
=
IDirect3DDevice9_StretchRect
(
device
,
surface1
,
NULL
,
surface2
,
NULL
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_StretchRect failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_StretchRect
(
device
,
backBuffer
,
&
rect
,
rt
,
NULL
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_StretchRect failed with %08x
\n
"
,
hr
);
/* This is supposed to fail inside a BeginScene - EndScene pair. */
hr
=
IDirect3DDevice9_StretchRect
(
pDevice
,
pDepthStencil
,
NULL
,
pSurface3
,
NULL
,
0
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"IDirect3DDevice9_StretchRect returned %08x, expected D3DERR_INVALIDCALL
\n
"
,
hr
);
}
hr
=
IDirect3DDevice9_StretchRect
(
device
,
ds
,
NULL
,
surface3
,
NULL
,
0
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"IDirect3DDevice9_StretchRect returned %08x, expected D3DERR_INVALIDCALL
\n
"
,
hr
);
hr
=
IDirect3DDevice9_EndScene
(
pD
evice
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_EndScene failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_EndScene
(
d
evice
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_EndScene failed with %08x
\n
"
,
hr
);
/* Does a SetRenderTarget influence BeginScene / EndScene ?
* Set a new render target, then see if it started a new scene. Flip the rt back and see if that maybe
* ended the scene. Expected result is that the scene is not affected by SetRenderTarget
*/
hr
=
IDirect3DDevice9_SetRenderTarget
(
pDevice
,
0
,
pRenderTarge
t
);
hr
=
IDirect3DDevice9_SetRenderTarget
(
device
,
0
,
r
t
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetRenderTarget failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_BeginScene
(
pD
evice
);
hr
=
IDirect3DDevice9_BeginScene
(
d
evice
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_BeginScene failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetRenderTarget
(
pDevice
,
0
,
pB
ackBuffer
);
hr
=
IDirect3DDevice9_SetRenderTarget
(
device
,
0
,
b
ackBuffer
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetRenderTarget failed with %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_EndScene
(
pD
evice
);
hr
=
IDirect3DDevice9_EndScene
(
d
evice
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_EndScene failed with %08x
\n
"
,
hr
);
cleanup:
if
(
pRenderTarget
)
IDirect3DSurface9_Release
(
pRenderTarget
);
if
(
pDepthStencil
)
IDirect3DSurface9_Release
(
pDepthStencil
);
if
(
pBackBuffer
)
IDirect3DSurface9_Release
(
pBackBuffer
);
if
(
pSurface1
)
IDirect3DSurface9_Release
(
pSurface1
);
if
(
pSurface2
)
IDirect3DSurface9_Release
(
pSurface2
);
if
(
pSurface3
)
IDirect3DSurface9_Release
(
pSurface3
);
if
(
pDevice
)
{
UINT
refcount
=
IDirect3DDevice9_Release
(
pDevice
);
IDirect3DSurface9_Release
(
rt
);
IDirect3DSurface9_Release
(
ds
);
IDirect3DSurface9_Release
(
backBuffer
);
IDirect3DSurface9_Release
(
surface1
);
IDirect3DSurface9_Release
(
surface2
);
IDirect3DSurface9_Release
(
surface3
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
cleanup:
IDirect3D9_Release
(
d3d
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_limits
(
void
)
{
HRESULT
hr
;
IDirect3DDevice9
*
pDevice
=
NULL
;
D3DPRESENT_PARAMETERS
d3dpp
;
D3DDISPLAYMODE
d3ddm
;
IDirect3DTexture9
*
pTexture
=
NULL
;
IDirect3DTexture9
*
texture
;
IDirect3DDevice9
*
device
;
IDirect3D9
*
d3d
;
HWND
hwnd
;
int
i
;
unsigned
int
i
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d
,
"Failed to create a D3D object.
\n
"
);
IDirect3D9_GetAdapterDisplayMode
(
d3d
,
D3DADAPTER_DEFAULT
,
&
d3ddm
);
ZeroMemory
(
&
d3dpp
,
sizeof
(
d3dpp
)
);
d3dpp
.
Windowed
=
TRUE
;
d3dpp
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
d3dpp
.
BackBufferWidth
=
800
;
d3dpp
.
BackBufferHeight
=
600
;
d3dpp
.
BackBufferFormat
=
d3ddm
.
Format
;
d3dpp
.
EnableAutoDepthStencil
=
TRUE
;
d3dpp
.
AutoDepthStencilFormat
=
D3DFMT_D16
;
hr
=
IDirect3D9_CreateDevice
(
d3d
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
/* no NULLREF here */
,
hwnd
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
d3dpp
,
&
pDevice
);
ok
(
hr
==
D3D_OK
||
hr
==
D3DERR_NOTAVAILABLE
||
broken
(
hr
==
D3DERR_INVALIDCALL
),
"IDirect3D9_CreateDevice failed with %08x
\n
"
,
hr
);
if
(
!
pDevice
)
if
(
!
(
device
=
create_device
(
d3d
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a
d3d device
\n
"
);
skip
(
"Failed to create a
3D device, skipping test.
\n
"
);
goto
cleanup
;
}
hr
=
IDirect3DDevice9_CreateTexture
(
pDevice
,
16
,
16
,
1
,
0
,
D3DFMT_A8R8G8B8
,
D3DPOOL_MANAGED
,
&
pT
exture
,
NULL
);
hr
=
IDirect3DDevice9_CreateTexture
(
device
,
16
,
16
,
1
,
0
,
D3DFMT_A8R8G8B8
,
D3DPOOL_MANAGED
,
&
t
exture
,
NULL
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_CreateTexture failed with %08x
\n
"
,
hr
);
if
(
!
pTexture
)
goto
cleanup
;
/* There are 16 pixel samplers. We should be able to access all of them */
for
(
i
=
0
;
i
<
16
;
i
++
)
{
hr
=
IDirect3DDevice9_SetTexture
(
pDevice
,
i
,
(
IDirect3DBaseTexture9
*
)
pTexture
);
for
(
i
=
0
;
i
<
16
;
++
i
)
{
hr
=
IDirect3DDevice9_SetTexture
(
device
,
i
,
(
IDirect3DBaseTexture9
*
)
texture
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetTexture for sampler %d failed with %08x
\n
"
,
i
,
hr
);
hr
=
IDirect3DDevice9_SetTexture
(
pD
evice
,
i
,
NULL
);
hr
=
IDirect3DDevice9_SetTexture
(
d
evice
,
i
,
NULL
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetTexture for sampler %d failed with %08x
\n
"
,
i
,
hr
);
hr
=
IDirect3DDevice9_SetSamplerState
(
pD
evice
,
i
,
D3DSAMP_SRGBTEXTURE
,
TRUE
);
hr
=
IDirect3DDevice9_SetSamplerState
(
d
evice
,
i
,
D3DSAMP_SRGBTEXTURE
,
TRUE
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetSamplerState for sampler %d failed with %08x
\n
"
,
i
,
hr
);
}
/* Now test all 8 textures stage states */
for
(
i
=
0
;
i
<
8
;
i
++
)
{
hr
=
IDirect3DDevice9_SetTextureStageState
(
pDevice
,
i
,
D3DTSS_COLOROP
,
D3DTOP_ADD
);
for
(
i
=
0
;
i
<
8
;
++
i
)
{
hr
=
IDirect3DDevice9_SetTextureStageState
(
device
,
i
,
D3DTSS_COLOROP
,
D3DTOP_ADD
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetTextureStageState for texture %d failed with %08x
\n
"
,
i
,
hr
);
}
/* Investigations show that accessing higher samplers / textures stage states does not return an error either. Writing
* to too high samplers(approximately sampler 40) causes memory corruption in windows, so there is no bounds checking
* but how do I test that?
*/
cleanup:
if
(
pTexture
)
IDirect3DTexture9_Release
(
pTexture
);
if
(
pDevice
)
{
UINT
refcount
=
IDirect3D9_Release
(
pDevice
);
/* Investigations show that accessing higher samplers / textures stage
* states does not return an error either. Writing to too high samplers
* (approximately sampler 40) causes memory corruption in Windows, so
* there is no bounds checking. */
IDirect3DTexture9_Release
(
texture
);
refcount
=
IDirect3D9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
cleanup:
IDirect3D9_Release
(
d3d
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_depthstenciltest
(
void
)
...
...
@@ -1895,32 +1799,24 @@ static void test_draw_indexed(void)
D3DDECL_END
()
};
IDirect3DVertexDeclaration9
*
vertex_declaration
=
NULL
;
IDirect3DVertexBuffer9
*
vertex_buffer
=
NULL
;
IDirect3DIndexBuffer9
*
index_buffer
=
NULL
;
D3DPRESENT_PARAMETERS
present_parameters
;
IDirect3DDevice9
*
device
=
NULL
;
IDirect3DVertexDeclaration9
*
vertex_declaration
;
IDirect3DVertexBuffer9
*
vertex_buffer
;
IDirect3DIndexBuffer9
*
index_buffer
;
IDirect3DDevice9
*
device
;
IDirect3D9
*
d3d9
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
HWND
hwnd
;
void
*
ptr
;
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
0
,
0
,
0
,
10
,
1
0
,
0
,
0
,
0
,
0
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
0
,
0
,
0
,
640
,
48
0
,
0
,
0
,
0
,
0
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d9
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d9
,
"Failed to create a D3D object.
\n
"
);
ZeroMemory
(
&
present_parameters
,
sizeof
(
present_parameters
));
present_parameters
.
Windowed
=
TRUE
;
present_parameters
.
hDeviceWindow
=
hwnd
;
present_parameters
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
hr
=
IDirect3D9_CreateDevice
(
d3d9
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
NULL
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
present_parameters
,
&
device
);
if
(
FAILED
(
hr
)
||
!
device
)
if
(
!
(
device
=
create_device
(
d3d9
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create
device
\n
"
);
skip
(
"Failed to create
a 3D device, skipping test.
\n
"
);
goto
cleanup
;
}
...
...
@@ -1983,24 +1879,20 @@ static void test_draw_indexed(void)
IDirect3DVertexBuffer9_Release
(
vertex_buffer
);
IDirect3DIndexBuffer9_Release
(
index_buffer
);
IDirect3DVertexDeclaration9_Release
(
vertex_declaration
);
cleanup:
if
(
device
)
{
UINT
refcount
=
IDirect3DDevice9_Release
(
device
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
cleanup:
IDirect3D9_Release
(
d3d9
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_null_stream
(
void
)
{
IDirect3DVertexBuffer9
*
buffer
=
NULL
;
D3DPRESENT_PARAMETERS
present_parameters
;
IDirect3DDevice9
*
device
=
NULL
;
IDirect3DDevice9
*
device
;
IDirect3D9
*
d3d9
;
HWND
hwnd
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
IDirect3DVertexShader9
*
shader
=
NULL
;
IDirect3DVertexDeclaration9
*
decl
=
NULL
;
...
...
@@ -2017,23 +1909,14 @@ static void test_null_stream(void)
D3DDECL_END
()
};
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d9
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d9
,
"Failed to create a D3D object.
\n
"
);
ZeroMemory
(
&
present_parameters
,
sizeof
(
present_parameters
));
present_parameters
.
Windowed
=
TRUE
;
present_parameters
.
hDeviceWindow
=
hwnd
;
present_parameters
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
hr
=
IDirect3D9_CreateDevice
(
d3d9
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
/* no NULLREF here */
,
hwnd
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
present_parameters
,
&
device
);
ok
(
hr
==
D3D_OK
||
hr
==
D3DERR_NOTAVAILABLE
||
broken
(
hr
==
D3DERR_INVALIDCALL
),
"IDirect3D9_CreateDevice failed with %08x
\n
"
,
hr
);
if
(
!
device
)
if
(
!
(
device
=
create_device
(
d3d9
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a
d3d device
\n
"
);
skip
(
"Failed to create a
3D device, skipping test.
\n
"
);
goto
cleanup
;
}
...
...
@@ -2080,46 +1963,36 @@ static void test_null_stream(void)
cleanup:
if
(
buffer
)
IDirect3DVertexBuffer9_Release
(
buffer
);
if
(
decl
)
IDirect3DVertexDeclaration9_Release
(
decl
);
if
(
shader
)
IDirect3DVertexShader9_Release
(
shader
);
if
(
decl
)
IDirect3DVertexDeclaration9_Release
(
decl
);
if
(
shader
)
IDirect3DVertexShader9_Release
(
shader
);
if
(
device
)
{
UINT
refcount
=
IDirect3DDevice9_Release
(
device
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
IDirect3D9_Release
(
d3d9
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_lights
(
void
)
{
D3DPRESENT_PARAMETERS
present_parameters
;
IDirect3DDevice9
*
device
=
NULL
;
IDirect3DDevice9
*
device
;
IDirect3D9
*
d3d9
;
HWND
hwnd
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
unsigned
int
i
;
BOOL
enabled
;
D3DCAPS9
caps
;
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d9
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d9
,
"Failed to create a D3D object.
\n
"
);
ZeroMemory
(
&
present_parameters
,
sizeof
(
present_parameters
));
present_parameters
.
Windowed
=
TRUE
;
present_parameters
.
hDeviceWindow
=
hwnd
;
present_parameters
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
hr
=
IDirect3D9_CreateDevice
(
d3d9
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
hwnd
,
D3DCREATE_HARDWARE_VERTEXPROCESSING
,
&
present_parameters
,
&
device
);
ok
(
hr
==
D3D_OK
||
hr
==
D3DERR_NOTAVAILABLE
||
hr
==
D3DERR_INVALIDCALL
,
"IDirect3D9_CreateDevice failed with %08x
\n
"
,
hr
);
if
(
!
device
)
if
(
!
(
device
=
create_device
(
d3d9
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a
d3d device
\n
"
);
skip
(
"Failed to create a
3D device, skipping test.
\n
"
);
goto
cleanup
;
}
...
...
@@ -2149,95 +2022,72 @@ static void test_lights(void)
ok
(
hr
==
D3D_OK
,
"Disabling light %u failed with %08x
\n
"
,
i
,
hr
);
}
cleanup:
if
(
device
)
{
UINT
refcount
=
IDirect3DDevice9_Release
(
device
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
cleanup:
IDirect3D9_Release
(
d3d9
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
static
void
test_set_stream_source
(
void
)
{
D3DPRESENT_PARAMETERS
present_parameters
;
IDirect3DDevice9
*
device
=
NULL
;
IDirect3DVertexBuffer9
*
vb
;
IDirect3DDevice9
*
device
;
IDirect3D9
*
d3d9
;
HWND
hwnd
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
IDirect3DVertexBuffer9
*
pVertexBuffer
=
NULL
;
hwnd
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
,
"Failed to create a window.
\n
"
);
window
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
,
"Failed to create a window.
\n
"
);
d3d9
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d9
,
"Failed to create a D3D object.
\n
"
);
ZeroMemory
(
&
present_parameters
,
sizeof
(
present_parameters
));
present_parameters
.
Windowed
=
TRUE
;
present_parameters
.
hDeviceWindow
=
hwnd
;
present_parameters
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
hr
=
IDirect3D9_CreateDevice
(
d3d9
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
hwnd
,
D3DCREATE_HARDWARE_VERTEXPROCESSING
,
&
present_parameters
,
&
device
);
ok
(
hr
==
D3D_OK
||
hr
==
D3DERR_NOTAVAILABLE
||
hr
==
D3DERR_INVALIDCALL
,
"IDirect3D9_CreateDevice failed with %08x
\n
"
,
hr
);
if
(
!
device
)
{
hr
=
IDirect3D9_CreateDevice
(
d3d9
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_REF
,
hwnd
,
D3DCREATE_HARDWARE_VERTEXPROCESSING
,
&
present_parameters
,
&
device
);
ok
(
hr
==
D3D_OK
||
hr
==
D3DERR_NOTAVAILABLE
||
hr
==
D3DERR_INVALIDCALL
,
"IDirect3D9_CreateDevice failed with %08x
\n
"
,
hr
);
if
(
!
device
)
if
(
!
(
device
=
create_device
(
d3d9
,
window
,
window
,
TRUE
)))
{
skip
(
"Failed to create a d3d device
\n
"
);
skip
(
"Failed to create a 3D device, skipping test.
\n
"
);
goto
cleanup
;
}
}
hr
=
IDirect3DDevice9_CreateVertexBuffer
(
device
,
512
,
0
,
0
,
D3DPOOL_DEFAULT
,
&
pVertexBuffer
,
NULL
);
ok
(
hr
==
D3D_OK
,
"Failed to create a vertex buffer, hr = %08x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
/* Some cards(Geforce 7400 at least) accept non-aligned offsets, others(radeon 9000 verified) reject it,
* so accept both results. Wine currently rejects this to be able to optimize the vbo conversion, but writes
* a WARN
*/
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
pVertexBuffer
,
0
,
32
);
ok
(
hr
==
D3D_OK
,
"Failed to set the stream source, offset 0, hr = %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
pVertexBuffer
,
1
,
32
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"Unexpected result when setting the stream source, offset 1, hr = %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
pVertexBuffer
,
2
,
32
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"Unexpected result when setting the stream source, offset 2, hr = %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
pVertexBuffer
,
3
,
32
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"Unexpected result when setting the stream source, offset 3, hr = %08x
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
pVertexBuffer
,
4
,
32
);
ok
(
hr
==
D3D_OK
,
"Failed to set the stream source, offset 4, hr = %08x
\n
"
,
hr
);
}
hr
=
IDirect3DDevice9_CreateVertexBuffer
(
device
,
512
,
0
,
0
,
D3DPOOL_DEFAULT
,
&
vb
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a vertex buffer, hr %#x.
\n
"
,
hr
);
/* Some cards (GeForce 7400 at least) accept non-aligned offsets, others
* (Radeon 9000 verified) reject them, so accept both results. Wine
* currently rejects this to be able to optimize the vbo conversion, but
* writes a WARN.
*/
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
vb
,
0
,
32
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set the stream source, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
vb
,
1
,
32
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
vb
,
2
,
32
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
vb
,
3
,
32
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
vb
,
4
,
32
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set the stream source, hr %#x.
\n
"
,
hr
);
/* Try to set the NULL buffer with an offset and stride 0 */
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
NULL
,
0
,
0
);
ok
(
hr
==
D3D_OK
,
"Failed to set the stream source, offset 0, hr = %08x
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set the stream source, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
NULL
,
1
,
0
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"
Unexpected result when setting the stream source, offset 1, hr = %08x
\n
"
,
hr
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"
Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
NULL
,
2
,
0
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"
Unexpected result when setting the stream source, offset 2, hr = %08x
\n
"
,
hr
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"
Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
NULL
,
3
,
0
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"
Unexpected result when setting the stream source, offset 3, hr = %08x
\n
"
,
hr
);
ok
(
hr
==
D3DERR_INVALIDCALL
||
hr
==
D3D_OK
,
"
Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
NULL
,
4
,
0
);
ok
(
hr
==
D3D_OK
,
"Failed to set the stream source, offset 4, hr = %08x
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set the stream source, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
NULL
,
0
,
0
);
ok
(
hr
==
D3D_OK
,
"Failed to set the stream source, offset 4, hr = %08x
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set the stream source, hr %#x.
\n
"
,
hr
);
cleanup:
if
(
pVertexBuffer
)
IDirect3DVertexBuffer9_Release
(
pVertexBuffer
);
if
(
device
)
{
UINT
refcount
=
IDirect3DDevice9_Release
(
device
);
IDirect3DVertexBuffer9_Release
(
vb
);
refcount
=
IDirect3DDevice9_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
cleanup:
IDirect3D9_Release
(
d3d9
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
window
);
}
/* Direct3D9 offers 4 display formats: R5G6B5, X1R5G5B5, X8R8G8B8 and
...
...
@@ -2416,66 +2266,39 @@ err_out:
static
void
test_multi_device
(
void
)
{
IDirect3DDevice9
*
device1
=
NULL
,
*
device2
=
NULL
;
D3DPRESENT_PARAMETERS
present_parameters
;
HWND
hwnd1
=
NULL
,
hwnd2
=
NULL
;
IDirect3DDevice9
*
device1
,
*
device2
;
HWND
window1
,
window2
;
IDirect3D9
*
d3d9
;
ULONG
refcount
;
HRESULT
hr
;
hwnd
1
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
1
,
"Failed to create a window.
\n
"
);
window
1
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
1
,
"Failed to create a window.
\n
"
);
d3d9
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d9
,
"Failed to create a D3D object.
\n
"
);
memset
(
&
present_parameters
,
0
,
sizeof
(
present_parameters
));
present_parameters
.
Windowed
=
TRUE
;
present_parameters
.
hDeviceWindow
=
hwnd1
;
present_parameters
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
hr
=
IDirect3D9_CreateDevice
(
d3d9
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
hwnd1
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
present_parameters
,
&
device1
);
if
(
!
(
device1
=
create_device
(
d3d9
,
window1
,
window1
,
TRUE
)))
{
skip
(
"Failed to create a 3D device, skipping test.
\n
"
);
IDirect3D9_Release
(
d3d9
);
d3d9
=
NULL
;
if
(
FAILED
(
hr
))
{
skip
(
"Failed to create a device
\n
"
);
goto
fail
;
DestroyWindow
(
window1
);
return
;
}
IDirect3D9_Release
(
d3d9
);
hwnd
2
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
160
,
16
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
hwnd
2
,
"Failed to create a window.
\n
"
);
window
2
=
CreateWindowA
(
"d3d9_test_wc"
,
"d3d9_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
48
0
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!!
window
2
,
"Failed to create a window.
\n
"
);
d3d9
=
Direct3DCreate9
(
D3D_SDK_VERSION
);
ok
(
!!
d3d9
,
"Failed to create a D3D object.
\n
"
);
memset
(
&
present_parameters
,
0
,
sizeof
(
present_parameters
));
present_parameters
.
Windowed
=
TRUE
;
present_parameters
.
hDeviceWindow
=
hwnd2
;
present_parameters
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
hr
=
IDirect3D9_CreateDevice
(
d3d9
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
hwnd2
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
present_parameters
,
&
device2
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a device, hr %#x
\n
"
,
hr
);
device2
=
create_device
(
d3d9
,
window2
,
window2
,
TRUE
);
IDirect3D9_Release
(
d3d9
);
d3d9
=
NULL
;
if
(
FAILED
(
hr
))
goto
fail
;
fail:
if
(
d3d9
)
IDirect3D9_Release
(
d3d9
);
if
(
device1
)
{
refcount
=
IDirect3DDevice9_Release
(
device1
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
if
(
device2
)
{
refcount
=
IDirect3DDevice9_Release
(
device2
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
if
(
hwnd1
)
DestroyWindow
(
hwnd1
);
if
(
hwnd2
)
DestroyWindow
(
hwnd2
);
refcount
=
IDirect3DDevice9_Release
(
device1
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
DestroyWindow
(
window2
);
DestroyWindow
(
window1
);
}
static
HWND
filter_messages
;
...
...
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