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
e51d3f6d
Commit
e51d3f6d
authored
Jan 23, 2012
by
Matteo Bruni
Committed by
Alexandre Julliard
Jan 24, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Accept pointers to wrong IDirectDrawSurface versions.
parent
f69f2aa3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
551 additions
and
5 deletions
+551
-5
surface.c
dlls/ddraw/surface.c
+52
-5
ddraw1.c
dlls/ddraw/tests/ddraw1.c
+143
-0
ddraw2.c
dlls/ddraw/tests/ddraw2.c
+143
-0
ddraw4.c
dlls/ddraw/tests/ddraw4.c
+120
-0
ddraw7.c
dlls/ddraw/tests/ddraw7.c
+93
-0
No files found.
dlls/ddraw/surface.c
View file @
e51d3f6d
...
...
@@ -5321,38 +5321,85 @@ static const struct IDirect3DTextureVtbl d3d_texture1_vtbl =
d3d_texture1_Unload
,
};
/* Some games (e.g. Tomb Raider 3) pass the wrong version of the
* IDirectDrawSurface interface to ddraw methods. */
IDirectDrawSurfaceImpl
*
unsafe_impl_from_IDirectDrawSurface7
(
IDirectDrawSurface7
*
iface
)
{
if
(
!
iface
)
return
NULL
;
assert
(
iface
->
lpVtbl
==
&
ddraw_surface7_vtbl
);
if
(
iface
->
lpVtbl
!=
&
ddraw_surface7_vtbl
)
{
HRESULT
hr
=
IUnknown_QueryInterface
(
iface
,
&
IID_IDirectDrawSurface7
,
(
void
**
)
&
iface
);
if
(
FAILED
(
hr
))
{
WARN
(
"Object %p doesn't expose interface IDirectDrawSurface7.
\n
"
,
iface
);
return
NULL
;
}
IUnknown_Release
(
iface
);
}
return
CONTAINING_RECORD
(
iface
,
IDirectDrawSurfaceImpl
,
IDirectDrawSurface7_iface
);
}
IDirectDrawSurfaceImpl
*
unsafe_impl_from_IDirectDrawSurface4
(
IDirectDrawSurface4
*
iface
)
{
if
(
!
iface
)
return
NULL
;
assert
(
iface
->
lpVtbl
==
&
ddraw_surface4_vtbl
);
if
(
iface
->
lpVtbl
!=
&
ddraw_surface4_vtbl
)
{
HRESULT
hr
=
IUnknown_QueryInterface
(
iface
,
&
IID_IDirectDrawSurface4
,
(
void
**
)
&
iface
);
if
(
FAILED
(
hr
))
{
WARN
(
"Object %p doesn't expose interface IDirectDrawSurface4.
\n
"
,
iface
);
return
NULL
;
}
IUnknown_Release
(
iface
);
}
return
CONTAINING_RECORD
(
iface
,
IDirectDrawSurfaceImpl
,
IDirectDrawSurface4_iface
);
}
static
IDirectDrawSurfaceImpl
*
unsafe_impl_from_IDirectDrawSurface3
(
IDirectDrawSurface3
*
iface
)
{
if
(
!
iface
)
return
NULL
;
assert
(
iface
->
lpVtbl
==
&
ddraw_surface3_vtbl
);
if
(
iface
->
lpVtbl
!=
&
ddraw_surface3_vtbl
)
{
HRESULT
hr
=
IUnknown_QueryInterface
(
iface
,
&
IID_IDirectDrawSurface3
,
(
void
**
)
&
iface
);
if
(
FAILED
(
hr
))
{
WARN
(
"Object %p doesn't expose interface IDirectDrawSurface3.
\n
"
,
iface
);
return
NULL
;
}
IUnknown_Release
(
iface
);
}
return
CONTAINING_RECORD
(
iface
,
IDirectDrawSurfaceImpl
,
IDirectDrawSurface3_iface
);
}
static
IDirectDrawSurfaceImpl
*
unsafe_impl_from_IDirectDrawSurface2
(
IDirectDrawSurface2
*
iface
)
{
if
(
!
iface
)
return
NULL
;
assert
(
iface
->
lpVtbl
==
&
ddraw_surface2_vtbl
);
if
(
iface
->
lpVtbl
!=
&
ddraw_surface2_vtbl
)
{
HRESULT
hr
=
IUnknown_QueryInterface
(
iface
,
&
IID_IDirectDrawSurface2
,
(
void
**
)
&
iface
);
if
(
FAILED
(
hr
))
{
WARN
(
"Object %p doesn't expose interface IDirectDrawSurface2.
\n
"
,
iface
);
return
NULL
;
}
IUnknown_Release
(
iface
);
}
return
CONTAINING_RECORD
(
iface
,
IDirectDrawSurfaceImpl
,
IDirectDrawSurface2_iface
);
}
IDirectDrawSurfaceImpl
*
unsafe_impl_from_IDirectDrawSurface
(
IDirectDrawSurface
*
iface
)
{
if
(
!
iface
)
return
NULL
;
assert
(
iface
->
lpVtbl
==
&
ddraw_surface1_vtbl
);
if
(
iface
->
lpVtbl
!=
&
ddraw_surface1_vtbl
)
{
HRESULT
hr
=
IUnknown_QueryInterface
(
iface
,
&
IID_IDirectDrawSurface
,
(
void
**
)
&
iface
);
if
(
FAILED
(
hr
))
{
WARN
(
"Object %p doesn't expose interface IDirectDrawSurface.
\n
"
,
iface
);
return
NULL
;
}
IUnknown_Release
(
iface
);
}
return
CONTAINING_RECORD
(
iface
,
IDirectDrawSurfaceImpl
,
IDirectDrawSurface_iface
);
}
...
...
dlls/ddraw/tests/ddraw1.c
View file @
e51d3f6d
...
...
@@ -588,9 +588,152 @@ static void test_coop_level_d3d_state(void)
DestroyWindow
(
window
);
}
static
void
test_surface_interface_mismatch
(
void
)
{
IDirectDraw
*
ddraw
=
NULL
;
IDirect3D
*
d3d
=
NULL
;
IDirectDrawSurface
*
surface
=
NULL
,
*
ds
;
IDirectDrawSurface3
*
surface3
=
NULL
;
IDirect3DDevice
*
device
=
NULL
;
IDirect3DViewport
*
viewport
=
NULL
;
IDirect3DMaterial
*
background
=
NULL
;
DDSURFACEDESC
surface_desc
;
DWORD
z_depth
=
0
;
HRESULT
hr
;
D3DCOLOR
color
;
HWND
window
;
D3DVIEWPORT
vp
;
D3DMATERIAL
material
;
D3DMATERIALHANDLE
background_handle
;
D3DRECT
clear_rect
=
{{
0
},
{
0
},
{
640
},
{
480
}};
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create a ddraw object, skipping test.
\n
"
);
goto
cleanup
;
}
hr
=
IDirectDraw_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_WIDTH
|
DDSD_HEIGHT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_OFFSCREENPLAIN
|
DDSCAPS_3DDEVICE
;
surface_desc
.
dwWidth
=
640
;
surface_desc
.
dwHeight
=
480
;
hr
=
IDirectDraw_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_QueryInterface
(
surface
,
&
IID_IDirectDrawSurface3
,
(
void
**
)
&
surface3
);
if
(
FAILED
(
hr
))
{
skip
(
"Failed to get the IDirectDrawSurface3 interface, skipping test.
\n
"
);
goto
cleanup
;
}
hr
=
IDirectDraw_QueryInterface
(
ddraw
,
&
IID_IDirect3D
,
(
void
**
)
&
d3d
);
if
(
FAILED
(
hr
))
{
skip
(
"Failed to get the IDirect3D interface, skipping test.
\n
"
);
goto
cleanup
;
}
hr
=
IDirect3D_EnumDevices
(
d3d
,
enum_z_fmt
,
&
z_depth
);
if
(
FAILED
(
hr
)
||
!
z_depth
)
{
skip
(
"No depth buffer formats available, skipping test.
\n
"
);
goto
cleanup
;
}
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_ZBUFFERBITDEPTH
|
DDSD_WIDTH
|
DDSD_HEIGHT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_ZBUFFER
;
surface_desc
.
dwZBufferBitDepth
=
z_depth
;
surface_desc
.
dwWidth
=
640
;
surface_desc
.
dwHeight
=
480
;
hr
=
IDirectDraw_CreateSurface
(
ddraw
,
&
surface_desc
,
&
ds
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create depth buffer, hr %#x.
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Using a different surface interface version still works */
hr
=
IDirectDrawSurface3_AddAttachedSurface
(
surface3
,
(
IDirectDrawSurface3
*
)
ds
);
ok
(
SUCCEEDED
(
hr
),
"Failed to attach depth buffer, hr %#x.
\n
"
,
hr
);
IDirectDrawSurface_Release
(
ds
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Here too */
hr
=
IDirectDrawSurface3_QueryInterface
(
surface3
,
&
IID_IDirect3DHALDevice
,
(
void
**
)
&
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create d3d device.
\n
"
);
if
(
FAILED
(
hr
))
goto
cleanup
;
hr
=
IDirect3D_CreateViewport
(
d3d
,
&
viewport
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3D_CreateMaterial
(
d3d
,
&
background
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create material, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice_AddViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to add viewport, hr %#x.
\n
"
,
hr
);
memset
(
&
vp
,
0
,
sizeof
(
vp
));
vp
.
dwSize
=
sizeof
(
vp
);
vp
.
dwX
=
0
;
vp
.
dwY
=
0
;
vp
.
dwWidth
=
640
;
vp
.
dwHeight
=
480
;
vp
.
dvScaleX
=
320
.
0
f
;
vp
.
dvScaleY
=
240
.
0
f
;
vp
.
dvMaxX
=
1
.
0
f
;
vp
.
dvMaxY
=
1
.
0
f
;
vp
.
dvMinZ
=
0
.
0
f
;
vp
.
dvMaxZ
=
1
.
0
f
;
hr
=
IDirect3DViewport_SetViewport
(
viewport
,
&
vp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport data, hr %#x.
\n
"
,
hr
);
memset
(
&
material
,
0
,
sizeof
(
material
));
material
.
dwSize
=
sizeof
(
material
);
U1
(
U
(
material
).
diffuse
).
r
=
1
.
0
f
;
U2
(
U
(
material
).
diffuse
).
g
=
0
.
0
f
;
U3
(
U
(
material
).
diffuse
).
b
=
0
.
0
f
;
U4
(
U
(
material
).
diffuse
).
a
=
1
.
0
f
;
hr
=
IDirect3DMaterial_SetMaterial
(
background
,
&
material
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set material data, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DMaterial_GetHandle
(
background
,
device
,
&
background_handle
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get material handle, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport_SetBackground
(
viewport
,
background_handle
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport background, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport_Clear
(
viewport
,
1
,
&
clear_rect
,
D3DCLEAR_TARGET
);
ok
(
SUCCEEDED
(
hr
),
"Failed to clear render target, hr %#x.
\n
"
,
hr
);
color
=
get_surface_color
(
surface
,
320
,
240
);
ok
(
compare_color
(
color
,
0x00ff0000
,
1
),
"Got unexpected color 0x%08x.
\n
"
,
color
);
cleanup:
if
(
viewport
)
{
IDirect3DDevice2_DeleteViewport
(
device
,
viewport
);
IDirect3DViewport2_Release
(
viewport
);
}
if
(
background
)
IDirect3DMaterial2_Release
(
background
);
if
(
surface3
)
IDirectDrawSurface3_Release
(
surface3
);
if
(
surface
)
IDirectDrawSurface7_Release
(
surface
);
if
(
device
)
IDirect3DDevice2_Release
(
device
);
if
(
d3d
)
IDirect3D7_Release
(
d3d
);
if
(
ddraw
)
IDirectDraw7_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw1
)
{
test_coop_level_create_device_window
();
test_clipper_blt
();
test_coop_level_d3d_state
();
test_surface_interface_mismatch
();
}
dlls/ddraw/tests/ddraw2.c
View file @
e51d3f6d
...
...
@@ -613,9 +613,152 @@ static void test_coop_level_d3d_state(void)
DestroyWindow
(
window
);
}
static
void
test_surface_interface_mismatch
(
void
)
{
IDirectDraw2
*
ddraw
=
NULL
;
IDirect3D2
*
d3d
=
NULL
;
IDirectDrawSurface
*
surface
=
NULL
,
*
ds
;
IDirectDrawSurface3
*
surface3
=
NULL
;
IDirect3DDevice2
*
device
=
NULL
;
IDirect3DViewport2
*
viewport
=
NULL
;
IDirect3DMaterial2
*
background
=
NULL
;
DDSURFACEDESC
surface_desc
;
DWORD
z_depth
=
0
;
HRESULT
hr
;
D3DCOLOR
color
;
HWND
window
;
D3DVIEWPORT2
vp
;
D3DMATERIAL
material
;
D3DMATERIALHANDLE
background_handle
;
D3DRECT
clear_rect
=
{{
0
},
{
0
},
{
640
},
{
480
}};
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create a ddraw object, skipping test.
\n
"
);
goto
cleanup
;
}
hr
=
IDirectDraw2_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_WIDTH
|
DDSD_HEIGHT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_OFFSCREENPLAIN
|
DDSCAPS_3DDEVICE
;
surface_desc
.
dwWidth
=
640
;
surface_desc
.
dwHeight
=
480
;
hr
=
IDirectDraw2_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface2_QueryInterface
(
surface
,
&
IID_IDirectDrawSurface3
,
(
void
**
)
&
surface3
);
if
(
FAILED
(
hr
))
{
skip
(
"Failed to get the IDirectDrawSurface3 interface, skipping test.
\n
"
);
goto
cleanup
;
}
hr
=
IDirectDraw2_QueryInterface
(
ddraw
,
&
IID_IDirect3D2
,
(
void
**
)
&
d3d
);
if
(
FAILED
(
hr
))
{
skip
(
"Failed to get the IDirect3D2 interface, skipping test.
\n
"
);
goto
cleanup
;
}
hr
=
IDirect3D2_EnumDevices
(
d3d
,
enum_z_fmt
,
&
z_depth
);
if
(
FAILED
(
hr
)
||
!
z_depth
)
{
skip
(
"No depth buffer formats available, skipping test.
\n
"
);
goto
cleanup
;
}
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_ZBUFFERBITDEPTH
|
DDSD_WIDTH
|
DDSD_HEIGHT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_ZBUFFER
;
surface_desc
.
dwZBufferBitDepth
=
z_depth
;
surface_desc
.
dwWidth
=
640
;
surface_desc
.
dwHeight
=
480
;
hr
=
IDirectDraw2_CreateSurface
(
ddraw
,
&
surface_desc
,
&
ds
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create depth buffer, hr %#x.
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Using a different surface interface version still works */
hr
=
IDirectDrawSurface3_AddAttachedSurface
(
surface3
,
(
IDirectDrawSurface3
*
)
ds
);
ok
(
SUCCEEDED
(
hr
),
"Failed to attach depth buffer, hr %#x.
\n
"
,
hr
);
IDirectDrawSurface_Release
(
ds
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Here too */
hr
=
IDirect3D2_CreateDevice
(
d3d
,
&
IID_IDirect3DHALDevice
,
(
IDirectDrawSurface
*
)
surface3
,
&
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create d3d device.
\n
"
);
if
(
FAILED
(
hr
))
goto
cleanup
;
hr
=
IDirect3D2_CreateViewport
(
d3d
,
&
viewport
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3D2_CreateMaterial
(
d3d
,
&
background
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create material, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice2_AddViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to add viewport, hr %#x.
\n
"
,
hr
);
memset
(
&
vp
,
0
,
sizeof
(
vp
));
vp
.
dwSize
=
sizeof
(
vp
);
vp
.
dwX
=
0
;
vp
.
dwY
=
0
;
vp
.
dwWidth
=
640
;
vp
.
dwHeight
=
480
;
vp
.
dvClipX
=
-
1
.
0
f
;
vp
.
dvClipY
=
1
.
0
f
;
vp
.
dvClipWidth
=
2
.
0
f
;
vp
.
dvClipHeight
=
2
.
0
f
;
vp
.
dvMinZ
=
0
.
0
f
;
vp
.
dvMaxZ
=
1
.
0
f
;
hr
=
IDirect3DViewport2_SetViewport2
(
viewport
,
&
vp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport data, hr %#x.
\n
"
,
hr
);
memset
(
&
material
,
0
,
sizeof
(
material
));
material
.
dwSize
=
sizeof
(
material
);
U1
(
U
(
material
).
diffuse
).
r
=
1
.
0
f
;
U2
(
U
(
material
).
diffuse
).
g
=
0
.
0
f
;
U3
(
U
(
material
).
diffuse
).
b
=
0
.
0
f
;
U4
(
U
(
material
).
diffuse
).
a
=
1
.
0
f
;
hr
=
IDirect3DMaterial2_SetMaterial
(
background
,
&
material
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set material data, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DMaterial2_GetHandle
(
background
,
device
,
&
background_handle
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get material handle, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport2_SetBackground
(
viewport
,
background_handle
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport background, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport2_Clear
(
viewport
,
1
,
&
clear_rect
,
D3DCLEAR_TARGET
);
ok
(
SUCCEEDED
(
hr
),
"Failed to clear render target, hr %#x.
\n
"
,
hr
);
color
=
get_surface_color
(
surface
,
320
,
240
);
ok
(
compare_color
(
color
,
0x00ff0000
,
1
),
"Got unexpected color 0x%08x.
\n
"
,
color
);
cleanup:
if
(
viewport
)
{
IDirect3DDevice2_DeleteViewport
(
device
,
viewport
);
IDirect3DViewport2_Release
(
viewport
);
}
if
(
background
)
IDirect3DMaterial2_Release
(
background
);
if
(
surface3
)
IDirectDrawSurface3_Release
(
surface3
);
if
(
surface
)
IDirectDrawSurface7_Release
(
surface
);
if
(
device
)
IDirect3DDevice2_Release
(
device
);
if
(
d3d
)
IDirect3D7_Release
(
d3d
);
if
(
ddraw
)
IDirectDraw7_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw2
)
{
test_coop_level_create_device_window
();
test_clipper_blt
();
test_coop_level_d3d_state
();
test_surface_interface_mismatch
();
}
dlls/ddraw/tests/ddraw4.c
View file @
e51d3f6d
...
...
@@ -802,10 +802,130 @@ static void test_coop_level_d3d_state(void)
DestroyWindow
(
window
);
}
static
void
test_surface_interface_mismatch
(
void
)
{
IDirectDraw4
*
ddraw
=
NULL
;
IDirect3D3
*
d3d
=
NULL
;
IDirectDrawSurface4
*
surface
=
NULL
,
*
ds
;
IDirectDrawSurface3
*
surface3
=
NULL
;
IDirect3DDevice3
*
device
=
NULL
;
IDirect3DViewport3
*
viewport
=
NULL
;
DDSURFACEDESC2
surface_desc
;
DDPIXELFORMAT
z_fmt
;
HRESULT
hr
;
D3DCOLOR
color
;
HWND
window
;
D3DVIEWPORT2
vp
;
D3DRECT
clear_rect
=
{{
0
},
{
0
},
{
640
},
{
480
}};
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create a ddraw object, skipping test.
\n
"
);
goto
cleanup
;
}
hr
=
IDirectDraw4_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_WIDTH
|
DDSD_HEIGHT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_OFFSCREENPLAIN
|
DDSCAPS_3DDEVICE
;
surface_desc
.
dwWidth
=
640
;
surface_desc
.
dwHeight
=
480
;
hr
=
IDirectDraw4_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_QueryInterface
(
surface
,
&
IID_IDirectDrawSurface3
,
(
void
**
)
&
surface3
);
ok
(
SUCCEEDED
(
hr
),
"Failed to QI IDirectDrawSurface3, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_QueryInterface
(
ddraw
,
&
IID_IDirect3D3
,
(
void
**
)
&
d3d
);
if
(
FAILED
(
hr
))
{
skip
(
"Failed to get the IDirect3D7 interface, skipping test.
\n
"
);
goto
cleanup
;
}
memset
(
&
z_fmt
,
0
,
sizeof
(
z_fmt
));
hr
=
IDirect3D3_EnumZBufferFormats
(
d3d
,
&
IID_IDirect3DHALDevice
,
enum_z_fmt
,
&
z_fmt
);
if
(
FAILED
(
hr
)
||
!
z_fmt
.
dwSize
)
{
skip
(
"No depth buffer formats available, skipping test.
\n
"
);
goto
cleanup
;
}
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_PIXELFORMAT
|
DDSD_WIDTH
|
DDSD_HEIGHT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_ZBUFFER
;
U4
(
surface_desc
).
ddpfPixelFormat
=
z_fmt
;
surface_desc
.
dwWidth
=
640
;
surface_desc
.
dwHeight
=
480
;
hr
=
IDirectDraw4_CreateSurface
(
ddraw
,
&
surface_desc
,
&
ds
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create depth buffer, hr %#x.
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Using a different surface interface version still works */
hr
=
IDirectDrawSurface3_AddAttachedSurface
(
surface3
,
(
IDirectDrawSurface3
*
)
ds
);
ok
(
SUCCEEDED
(
hr
),
"Failed to attach depth buffer, hr %#x.
\n
"
,
hr
);
IDirectDrawSurface4_Release
(
ds
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Here too */
hr
=
IDirect3D3_CreateDevice
(
d3d
,
&
IID_IDirect3DHALDevice
,
(
IDirectDrawSurface4
*
)
surface3
,
&
device
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create d3d device.
\n
"
);
if
(
FAILED
(
hr
))
goto
cleanup
;
hr
=
IDirect3D3_CreateViewport
(
d3d
,
&
viewport
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create viewport, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_AddViewport
(
device
,
viewport
);
ok
(
SUCCEEDED
(
hr
),
"Failed to add viewport, hr %#x.
\n
"
,
hr
);
memset
(
&
vp
,
0
,
sizeof
(
vp
));
vp
.
dwSize
=
sizeof
(
vp
);
vp
.
dwX
=
0
;
vp
.
dwY
=
0
;
vp
.
dwWidth
=
640
;
vp
.
dwHeight
=
480
;
vp
.
dvClipX
=
-
1
.
0
f
;
vp
.
dvClipY
=
1
.
0
f
;
vp
.
dvClipWidth
=
2
.
0
f
;
vp
.
dvClipHeight
=
2
.
0
f
;
vp
.
dvMinZ
=
0
.
0
f
;
vp
.
dvMaxZ
=
1
.
0
f
;
hr
=
IDirect3DViewport3_SetViewport2
(
viewport
,
&
vp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set viewport data, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DViewport3_Clear2
(
viewport
,
1
,
&
clear_rect
,
D3DCLEAR_TARGET
,
0xffff0000
,
0
.
0
f
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to clear viewport, hr %#x.
\n
"
,
hr
);
color
=
get_surface_color
(
surface
,
320
,
240
);
ok
(
compare_color
(
color
,
0x00ff0000
,
1
),
"Got unexpected color 0x%08x.
\n
"
,
color
);
cleanup:
if
(
viewport
)
{
IDirect3DDevice2_DeleteViewport
(
device
,
viewport
);
IDirect3DViewport2_Release
(
viewport
);
}
if
(
surface3
)
IDirectDrawSurface3_Release
(
surface3
);
if
(
surface
)
IDirectDrawSurface4_Release
(
surface
);
if
(
device
)
IDirect3DDevice3_Release
(
device
);
if
(
d3d
)
IDirect3D3_Release
(
d3d
);
if
(
ddraw
)
IDirectDraw4_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw4
)
{
test_process_vertices
();
test_coop_level_create_device_window
();
test_clipper_blt
();
test_coop_level_d3d_state
();
test_surface_interface_mismatch
();
}
dlls/ddraw/tests/ddraw7.c
View file @
e51d3f6d
...
...
@@ -769,6 +769,98 @@ static void test_coop_level_d3d_state(void)
DestroyWindow
(
window
);
}
static
void
test_surface_interface_mismatch
(
void
)
{
IDirectDraw7
*
ddraw
=
NULL
;
IDirect3D7
*
d3d
=
NULL
;
IDirectDrawSurface7
*
surface
=
NULL
,
*
ds
;
IDirectDrawSurface3
*
surface3
=
NULL
;
IDirect3DDevice7
*
device
=
NULL
;
DDSURFACEDESC2
surface_desc
;
DDPIXELFORMAT
z_fmt
;
HRESULT
hr
;
D3DCOLOR
color
;
HWND
window
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create a ddraw object, skipping test.
\n
"
);
goto
cleanup
;
}
hr
=
IDirectDraw7_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_WIDTH
|
DDSD_HEIGHT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_OFFSCREENPLAIN
|
DDSCAPS_3DDEVICE
;
surface_desc
.
dwWidth
=
640
;
surface_desc
.
dwHeight
=
480
;
hr
=
IDirectDraw7_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_QueryInterface
(
surface
,
&
IID_IDirectDrawSurface3
,
(
void
**
)
&
surface3
);
ok
(
SUCCEEDED
(
hr
),
"Failed to QI IDirectDrawSurface3, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_QueryInterface
(
ddraw
,
&
IID_IDirect3D7
,
(
void
**
)
&
d3d
);
if
(
FAILED
(
hr
))
{
skip
(
"Failed to get the IDirect3D7 interface, skipping test.
\n
"
);
goto
cleanup
;
}
memset
(
&
z_fmt
,
0
,
sizeof
(
z_fmt
));
hr
=
IDirect3D7_EnumZBufferFormats
(
d3d
,
&
IID_IDirect3DTnLHalDevice
,
enum_z_fmt
,
&
z_fmt
);
if
(
FAILED
(
hr
)
||
!
z_fmt
.
dwSize
)
{
skip
(
"No depth buffer formats available, skipping test.
\n
"
);
goto
cleanup
;
}
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_PIXELFORMAT
|
DDSD_WIDTH
|
DDSD_HEIGHT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_ZBUFFER
;
U4
(
surface_desc
).
ddpfPixelFormat
=
z_fmt
;
surface_desc
.
dwWidth
=
640
;
surface_desc
.
dwHeight
=
480
;
hr
=
IDirectDraw7_CreateSurface
(
ddraw
,
&
surface_desc
,
&
ds
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create depth buffer, hr %#x.
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Using a different surface interface version still works */
hr
=
IDirectDrawSurface3_AddAttachedSurface
(
surface3
,
(
IDirectDrawSurface3
*
)
ds
);
ok
(
SUCCEEDED
(
hr
),
"Failed to attach depth buffer, hr %#x.
\n
"
,
hr
);
IDirectDrawSurface7_Release
(
ds
);
if
(
FAILED
(
hr
))
goto
cleanup
;
/* Here too */
hr
=
IDirect3D7_CreateDevice
(
d3d
,
&
IID_IDirect3DTnLHalDevice
,
(
IDirectDrawSurface7
*
)
surface3
,
&
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create d3d device.
\n
"
);
if
(
FAILED
(
hr
))
goto
cleanup
;
hr
=
IDirect3DDevice7_Clear
(
device
,
0
,
NULL
,
D3DCLEAR_TARGET
,
0xffff0000
,
0
.
0
f
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to clear render target, hr %#x.
\n
"
,
hr
);
color
=
get_surface_color
(
surface
,
320
,
240
);
ok
(
compare_color
(
color
,
0x00ff0000
,
1
),
"Got unexpected color 0x%08x.
\n
"
,
color
);
cleanup:
if
(
surface3
)
IDirectDrawSurface3_Release
(
surface3
);
if
(
surface
)
IDirectDrawSurface7_Release
(
surface
);
if
(
device
)
IDirect3DDevice7_Release
(
device
);
if
(
d3d
)
IDirect3D7_Release
(
d3d
);
if
(
ddraw
)
IDirectDraw7_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw7
)
{
HMODULE
module
=
GetModuleHandleA
(
"ddraw.dll"
);
...
...
@@ -783,4 +875,5 @@ START_TEST(ddraw7)
test_coop_level_create_device_window
();
test_clipper_blt
();
test_coop_level_d3d_state
();
test_surface_interface_mismatch
();
}
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