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
a2963b66
Commit
a2963b66
authored
Nov 13, 2011
by
Henri Verbeet
Committed by
Alexandre Julliard
Nov 14, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Use wined3d_mutex_lock() / wined3d_mutex_unlock() for locking.
parent
32664381
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
597 additions
and
507 deletions
+597
-507
clipper.c
dlls/ddraw/clipper.c
+17
-13
ddraw.c
dlls/ddraw/ddraw.c
+112
-107
ddraw_private.h
dlls/ddraw/ddraw_private.h
+0
-3
device.c
dlls/ddraw/device.c
+212
-174
light.c
dlls/ddraw/light.c
+5
-4
main.c
dlls/ddraw/main.c
+11
-19
material.c
dlls/ddraw/material.c
+9
-9
palette.c
dlls/ddraw/palette.c
+11
-8
surface.c
dlls/ddraw/surface.c
+157
-127
vertexbuffer.c
dlls/ddraw/vertexbuffer.c
+19
-14
viewport.c
dlls/ddraw/viewport.c
+44
-29
No files found.
dlls/ddraw/clipper.c
View file @
a2963b66
...
...
@@ -96,10 +96,10 @@ static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface)
if
(
ref
==
0
)
{
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_clipper_decref
(
This
->
wineD3DClipper
);
wined3d_mutex_unlock
();
HeapFree
(
GetProcessHeap
(),
0
,
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
0
;
}
else
return
ref
;
...
...
@@ -128,9 +128,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetHWnd(IDirectDrawClipper *iface,
TRACE
(
"iface %p, flags %#x, window %p.
\n
"
,
iface
,
dwFlags
,
hWnd
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_clipper_set_window
(
This
->
wineD3DClipper
,
dwFlags
,
hWnd
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
switch
(
hr
)
{
case
WINED3DERR_INVALIDCALL
:
return
DDERR_INVALIDPARAMS
;
...
...
@@ -165,9 +166,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(IDirectDrawClipper *ifa
TRACE
(
"iface %p, rect %s, clip_list %p, clip_list_size %p.
\n
"
,
iface
,
wine_dbgstr_rect
(
lpRect
),
lpClipList
,
lpdwSize
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_clipper_get_clip_list
(
This
->
wineD3DClipper
,
lpRect
,
lpClipList
,
lpdwSize
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -193,9 +195,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(IDirectDrawClipper *ifa
TRACE
(
"iface %p, clip_list %p, flags %#x.
\n
"
,
iface
,
lprgn
,
dwFlag
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_clipper_set_clip_list
(
This
->
wineD3DClipper
,
lprgn
,
dwFlag
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -217,9 +220,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(IDirectDrawClipper *iface,
TRACE
(
"iface %p, window %p.
\n
"
,
iface
,
hWndPtr
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_clipper_get_window
(
This
->
wineD3DClipper
,
hWndPtr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -244,16 +248,16 @@ static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(IDirectDrawClipper *ifac
TRACE
(
"iface %p, ddraw %p, flags %#x.
\n
"
,
iface
,
ddraw
,
dwFlags
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
This
->
initialized
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_ALREADYINITIALIZED
;
}
This
->
initialized
=
TRUE
;
wined3d_mutex_unlock
();
LeaveCriticalSection
(
&
ddraw_cs
);
return
DD_OK
;
}
...
...
dlls/ddraw/ddraw.c
View file @
a2963b66
...
...
@@ -146,14 +146,14 @@ static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID refiid,
TRACE
(
"iface %p, riid %s, object %p.
\n
"
,
iface
,
debugstr_guid
(
refiid
),
obj
);
/* Can change surface impl type */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
*
obj
=
NULL
;
if
(
!
refiid
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -174,7 +174,7 @@ static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID refiid,
/* This Interface exists in ddrawex.dll, it is implemented in a wrapper */
WARN
(
"IDirectDraw3 is not valid in ddraw.dll
\n
"
);
*
obj
=
NULL
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
E_NOINTERFACE
;
}
else
if
(
IsEqualGUID
(
&
IID_IDirectDraw2
,
refiid
)
)
...
...
@@ -236,12 +236,13 @@ static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID refiid,
else
{
ERR
(
"(%p)->(%s, %p): No interface found
\n
"
,
This
,
debugstr_guid
(
refiid
),
obj
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
E_NOINTERFACE
;
}
IUnknown_AddRef
(
(
IUnknown
*
)
*
obj
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
S_OK
;
}
...
...
@@ -479,9 +480,9 @@ static void ddraw_destroy(IDirectDrawImpl *This)
This
->
devicewindow
=
0
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
list_remove
(
&
This
->
ddraw_list_entry
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
/* This can happen more or less legitimately for ddraw 1 and 2, where
* surfaces don't keep a reference to the ddraw object. The surfaces
...
...
@@ -677,7 +678,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
TRACE
(
"iface %p, window %p, flags %#x.
\n
"
,
iface
,
hwnd
,
cooplevel
);
DDRAW_dump_cooperativelevel
(
cooplevel
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* Get the old window */
window
=
This
->
dest_window
;
...
...
@@ -688,7 +689,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
DDSCL_EXCLUSIVE
)))
{
TRACE
(
"Incorrect cooplevel flags, returning DDERR_INVALIDPARAMS
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -708,12 +709,12 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
DDSCL_FULLSCREEN
)
)
{
TRACE
(
"Called with incompatible flags, returning DDERR_INVALIDPARAMS
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
hr
=
ddraw_set_focus_window
(
This
,
hwnd
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -722,7 +723,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
if
(
!
(
cooplevel
&
DDSCL_FULLSCREEN
)
||
!
hwnd
)
{
TRACE
(
"(%p) DDSCL_EXCLUSIVE needs DDSCL_FULLSCREEN and a window
\n
"
,
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
}
...
...
@@ -753,7 +754,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
if
(
FAILED
(
hr
))
{
ERR
(
"Failed to acquire focus window, hr %#x.
\n
"
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
}
...
...
@@ -773,7 +774,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
if
(
!
devicewindow
)
{
ERR
(
"Failed to create window, last error %#x.
\n
"
,
GetLastError
());
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
E_FAIL
;
}
...
...
@@ -799,7 +800,8 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
/* Store the cooperative_level */
This
->
cooperative_level
=
cooplevel
;
TRACE
(
"SetCooperativeLevel retuning DD_OK
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -852,12 +854,12 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD
TRACE
(
"ddraw %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.
\n
"
,
ddraw
,
Width
,
Height
,
BPP
,
RefreshRate
,
Flags
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
!
Width
||
!
Height
)
{
ERR
(
"Width %u, Height %u, what to do?
\n
"
,
Width
,
Height
);
/* It looks like Need for Speed Porsche Unleashed expects DD_OK here */
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -881,7 +883,7 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD
&&
Mode
.
RefreshRate
==
RefreshRate
)
{
TRACE
(
"Skipping redundant mode setting call.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -910,7 +912,8 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD
if
(
ddraw
->
cooperative_level
&
DDSCL_EXCLUSIVE
)
SetWindowPos
(
ddraw
->
dest_window
,
HWND_TOP
,
0
,
0
,
Width
,
Height
,
SWP_SHOWWINDOW
|
SWP_NOACTIVATE
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
switch
(
hr
)
{
case
WINED3DERR_NOTAVAILABLE
:
return
DDERR_UNSUPPORTED
;
...
...
@@ -1081,17 +1084,18 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD
memset
(
&
caps
,
0
,
sizeof
(
caps
));
memset
(
&
winecaps
,
0
,
sizeof
(
winecaps
));
caps
.
dwSize
=
sizeof
(
caps
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
hr
=
wined3d_device_get_device_caps
(
This
->
wined3d_device
,
&
winecaps
);
if
(
FAILED
(
hr
))
{
WARN
(
"IWineD3DDevice::GetDeviceCaps failed
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
hr
=
IDirectDraw7_GetAvailableVidMem
(
iface
,
&
ddscaps
,
&
caps
.
dwVidMemTotal
,
&
caps
.
dwVidMemFree
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
if
(
FAILED
(
hr
))
{
WARN
(
"IDirectDraw7::GetAvailableVidMem failed
\n
"
);
return
hr
;
...
...
@@ -1241,11 +1245,11 @@ static HRESULT WINAPI ddraw7_GetDisplayMode(IDirectDraw7 *iface, DDSURFACEDESC2
TRACE
(
"iface %p, surface_desc %p.
\n
"
,
iface
,
DDSD
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* This seems sane */
if
(
!
DDSD
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -1255,7 +1259,7 @@ static HRESULT WINAPI ddraw7_GetDisplayMode(IDirectDraw7 *iface, DDSURFACEDESC2
if
(
FAILED
(
hr
))
{
ERR
(
" (%p) IWineD3DDevice::GetDisplayMode returned %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -1278,7 +1282,8 @@ static HRESULT WINAPI ddraw7_GetDisplayMode(IDirectDraw7 *iface, DDSURFACEDESC2
DDRAW_dump_surface_desc
(
DDSD
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -1529,7 +1534,7 @@ static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *C
TRACE
(
"(%p) Asked for memory with description: "
,
This
);
DDRAW_dump_DDSCAPS2
(
Caps
);
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* Todo: System memory vs local video memory vs non-local video memory
* The MSDN also mentions differences between texture memory and other
...
...
@@ -1538,7 +1543,7 @@ static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *C
if
(
(
!
total
)
&&
(
!
free
)
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -1552,7 +1557,8 @@ static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *C
*
total
=
desc
.
video_memory
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -1783,9 +1789,9 @@ static HRESULT WINAPI ddraw7_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline)
hide
=
TRUE
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_device_get_display_mode
(
This
->
wined3d_device
,
0
,
&
Mode
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
/* Fake the line sweeping of the monitor */
/* FIXME: We should synchronize with a source to keep the refresh rate */
...
...
@@ -1872,17 +1878,18 @@ static HRESULT WINAPI ddraw7_GetGDISurface(IDirectDraw7 *iface, IDirectDrawSurfa
TRACE
(
"iface %p, surface %p.
\n
"
,
iface
,
GDISurface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
!
(
*
GDISurface
=
&
This
->
primary
->
IDirectDrawSurface7_iface
))
{
WARN
(
"Primary not created yet.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NOTFOUND
;
}
IDirectDrawSurface7_AddRef
(
*
GDISurface
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -2009,14 +2016,10 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
TRACE
(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.
\n
"
,
iface
,
Flags
,
DDSD
,
Context
,
cb
);
EnterCriticalSection
(
&
ddraw_cs
);
/* This looks sane */
if
(
!
cb
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
if
(
!
cb
)
return
DDERR_INVALIDPARAMS
;
}
wined3d_mutex_lock
();
if
(
!
(
Flags
&
DDEDM_REFRESHRATES
))
{
enum_mode_array_size
=
16
;
...
...
@@ -2024,7 +2027,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
if
(
!
enum_modes
)
{
ERR
(
"Out of memory
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_OUTOFMEMORY
;
}
}
...
...
@@ -2094,7 +2097,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
{
TRACE
(
"Application asked to terminate the enumeration
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
enum_modes
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -2111,7 +2114,7 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
{
ERR
(
"Out of memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
enum_modes
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_OUTOFMEMORY
;
}
...
...
@@ -2125,7 +2128,8 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
TRACE
(
"End of enumeration
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
enum_modes
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -2749,19 +2753,20 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
TRACE
(
" (%p) Requesting surface desc :
\n
"
,
ddraw
);
DDRAW_dump_surface_desc
(
DDSD
);
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
if
(
UnkOuter
!=
NULL
)
{
FIXME
(
"(%p) : outer != NULL?
\n
"
,
ddraw
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
CLASS_E_NOAGGREGATION
;
/* unchecked */
}
if
(
Surf
==
NULL
)
{
FIXME
(
"(%p) You want to get back a surface? Don't give NULL ptrs!
\n
"
,
ddraw
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
E_POINTER
;
/* unchecked */
}
...
...
@@ -2790,14 +2795,14 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
TRACE
(
"(%p): Attempt to create a flipable primary surface without DDSCL_EXCLUSIVE set
\n
"
,
ddraw
);
*
Surf
=
NULL
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NOEXCLUSIVEMODE
;
}
if
((
DDSD
->
ddsCaps
.
dwCaps
&
(
DDSCAPS_BACKBUFFER
|
DDSCAPS_PRIMARYSURFACE
))
==
(
DDSCAPS_BACKBUFFER
|
DDSCAPS_PRIMARYSURFACE
))
{
WARN
(
"Application wanted to create back buffer primary surface
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDCAPS
;
}
...
...
@@ -2805,7 +2810,7 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
{
/* This is a special switch in ddrawex.dll, but not allowed in ddraw.dll */
WARN
(
"Application tries to put the surface in both system and video memory
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
*
Surf
=
NULL
;
return
DDERR_INVALIDCAPS
;
}
...
...
@@ -2817,14 +2822,14 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
!
(
DDSD
->
ddsCaps
.
dwCaps2
&
DDSCAPS2_CUBEMAP
))
{
WARN
(
"Cube map faces requested without cube map flag
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDCAPS
;
}
if
(
DDSD
->
ddsCaps
.
dwCaps2
&
DDSCAPS2_CUBEMAP
&&
(
DDSD
->
ddsCaps
.
dwCaps2
&
DDSCAPS2_CUBEMAP_ALLFACES
)
==
0
)
{
WARN
(
"Cube map without faces requested
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -2894,7 +2899,7 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
{
WARN
(
"Creating a non-Primary surface without Width or Height info, returning DDERR_INVALIDPARAMS
\n
"
);
*
Surf
=
NULL
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -2905,7 +2910,7 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
if
(
!
desc2
.
dwWidth
||
!
desc2
.
dwHeight
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -2919,7 +2924,7 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
/* Mipmap count is given, should not be 0 */
if
(
desc2
.
u2
.
dwMipMapCount
==
0
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
}
...
...
@@ -2968,7 +2973,7 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
if
(
FAILED
(
hr
))
{
WARN
(
"ddraw_create_surface failed, hr %#x.
\n
"
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
object
->
is_complex_root
=
TRUE
;
...
...
@@ -3026,7 +3031,7 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
{
IDirectDrawSurface_Release
(
&
object
->
IDirectDrawSurface_iface
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -3051,7 +3056,7 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
object
=
object
->
complex_array
[
0
];
ddraw_surface_destroy
(
release_surf
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
}
...
...
@@ -3067,7 +3072,8 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
ddraw
->
tex_root
=
NULL
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3422,13 +3428,10 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags,
all
=
Flags
&
DDENUMSURFACES_ALL
;
nomatch
=
Flags
&
DDENUMSURFACES_NOMATCH
;
EnterCriticalSection
(
&
ddraw_cs
);
if
(
!
Callback
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
if
(
!
Callback
)
return
DDERR_INVALIDPARAMS
;
}
wined3d_mutex_lock
();
/* Use the _SAFE enumeration, the app may destroy enumerated surfaces */
LIST_FOR_EACH_SAFE
(
entry
,
entry2
,
&
This
->
surface_list
)
...
...
@@ -3441,12 +3444,14 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags,
IDirectDrawSurface7_AddRef
(
&
surf
->
IDirectDrawSurface7_iface
);
if
(
Callback
(
&
surf
->
IDirectDrawSurface7_iface
,
&
desc
,
Context
)
!=
DDENUMRET_OK
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
}
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -3528,18 +3533,16 @@ DirectDrawCreateClipper(DWORD Flags,
TRACE
(
"flags %#x, clipper %p, outer_unknown %p.
\n
"
,
Flags
,
Clipper
,
UnkOuter
);
EnterCriticalSection
(
&
ddraw_cs
);
if
(
UnkOuter
!=
NULL
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
if
(
UnkOuter
)
return
CLASS_E_NOAGGREGATION
;
}
wined3d_mutex_lock
();
object
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
IDirectDrawClipperImpl
));
if
(
object
==
NULL
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
E_OUTOFMEMORY
;
}
...
...
@@ -3548,13 +3551,14 @@ DirectDrawCreateClipper(DWORD Flags,
{
WARN
(
"Failed to initialize clipper, hr %#x.
\n
"
,
hr
);
HeapFree
(
GetProcessHeap
(),
0
,
object
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
TRACE
(
"Created clipper %p.
\n
"
,
object
);
*
Clipper
=
&
object
->
IDirectDrawClipper_iface
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -3633,19 +3637,16 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
TRACE
(
"iface %p, flags %#x, color_table %p, palette %p, outer_unknown %p.
\n
"
,
iface
,
Flags
,
ColorTable
,
Palette
,
pUnkOuter
);
EnterCriticalSection
(
&
ddraw_cs
);
if
(
pUnkOuter
!=
NULL
)
{
WARN
(
"pUnkOuter is %p, returning CLASS_E_NOAGGREGATION
\n
"
,
pUnkOuter
);
LeaveCriticalSection
(
&
ddraw_cs
);
if
(
pUnkOuter
)
return
CLASS_E_NOAGGREGATION
;
}
wined3d_mutex_lock
();
/* The refcount test shows that a cooplevel is required for this */
if
(
!
This
->
cooperative_level
)
{
WARN
(
"No cooperative level set, returning DDERR_NOCOOPERATIVELEVELSET
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NOCOOPERATIVELEVELSET
;
}
...
...
@@ -3653,7 +3654,7 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
if
(
!
object
)
{
ERR
(
"Out of memory when allocating memory for a palette implementation
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
E_OUTOFMEMORY
;
}
...
...
@@ -3662,13 +3663,14 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
{
WARN
(
"Failed to initialize palette, hr %#x.
\n
"
,
hr
);
HeapFree
(
GetProcessHeap
(),
0
,
object
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
TRACE
(
"Created palette %p.
\n
"
,
object
);
*
Palette
=
&
object
->
IDirectDrawPalette_iface
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -3859,12 +3861,12 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA
if
(
!
callback
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
IDirect3DImpl_GetCaps
(
This
->
wineD3D
,
&
device_desc1
,
&
device_desc7
);
if
(
hr
!=
D3D_OK
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -3877,14 +3879,14 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA
if
(
ret
!=
DDENUMRET_OK
)
{
TRACE
(
"Application cancelled the enumeration.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
}
TRACE
(
"End of enumeration.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -3926,12 +3928,12 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA
if
(
!
callback
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
IDirect3DImpl_GetCaps
(
This
->
wineD3D
,
&
device_desc1
,
&
device_desc7
);
if
(
hr
!=
D3D_OK
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -3971,7 +3973,7 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA
if
(
hr
!=
D3DENUMRET_OK
)
{
TRACE
(
"Application cancelled the enumeration.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
}
...
...
@@ -3991,13 +3993,14 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA
if
(
hr
!=
D3DENUMRET_OK
)
{
TRACE
(
"Application cancelled the enumeration.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
TRACE
(
"End of enumeration.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -4346,7 +4349,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
TRACE
(
"iface %p, riid %s, surface %p, device %p.
\n
"
,
iface
,
debugstr_guid
(
riid
),
surface
,
device
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
*
device
=
NULL
;
/* Fail device creation if non-opengl surfaces are used. */
...
...
@@ -4357,14 +4360,14 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
/* We only hit this path if a default surface is set in the registry. Incorrect autodetection
* is caught in CreateSurface or QueryInterface. */
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NO3D
;
}
if
(
This
->
d3ddevice
)
{
FIXME
(
"Only one Direct3D device per DirectDraw object supported.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -4372,7 +4375,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
if
(
!
object
)
{
ERR
(
"Failed to allocate device memory.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_OUTOFMEMORY
;
}
...
...
@@ -4381,14 +4384,15 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
{
WARN
(
"Failed to initialize device, hr %#x.
\n
"
,
hr
);
HeapFree
(
GetProcessHeap
(),
0
,
object
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
TRACE
(
"Created device %p.
\n
"
,
object
);
*
device
=
&
object
->
IDirect3DDevice7_iface
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -4584,7 +4588,7 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device
type
=
WINED3DDEVTYPE_HAL
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* We need an adapter format from somewhere to please wined3d and WGL.
* Use the current display mode. So far all cards offer the same depth
* stencil format for all modes, but if some do not and applications do
...
...
@@ -4610,7 +4614,7 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device
if
(
hr
!=
DDENUMRET_OK
)
{
TRACE
(
"Format enumeration cancelled by application.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
}
...
...
@@ -4635,7 +4639,8 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device
TRACE
(
"End of enumeration.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -4668,10 +4673,10 @@ static HRESULT WINAPI d3d7_EvictManagedTextures(IDirect3D7 *iface)
TRACE
(
"iface %p!
\n
"
,
iface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
This
->
d3d_initialized
)
wined3d_device_evict_managed_resources
(
This
->
wined3d_device
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -4710,9 +4715,9 @@ HRESULT IDirect3DImpl_GetCaps(const struct wined3d *wined3d, D3DDEVICEDESC *desc
memset
(
&
wined3d_caps
,
0
,
sizeof
(
wined3d_caps
));
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_get_device_caps
(
wined3d
,
0
,
WINED3DDEVTYPE_HAL
,
&
wined3d_caps
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
if
(
FAILED
(
hr
))
{
WARN
(
"Failed to get device caps, hr %#x.
\n
"
,
hr
);
...
...
dlls/ddraw/ddraw_private.h
View file @
a2963b66
...
...
@@ -52,9 +52,6 @@ typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
typedef
struct
IDirect3DExecuteBufferImpl
IDirect3DExecuteBufferImpl
;
typedef
struct
IDirect3DVertexBufferImpl
IDirect3DVertexBufferImpl
;
/* Global critical section */
extern
CRITICAL_SECTION
ddraw_cs
DECLSPEC_HIDDEN
;
extern
DWORD
force_refresh_rate
DECLSPEC_HIDDEN
;
/*****************************************************************************
...
...
dlls/ddraw/device.c
View file @
a2963b66
...
...
@@ -293,7 +293,7 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
{
DWORD
i
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* There is no need to unset any resources here, wined3d will take
* care of that on Uninit3D(). */
...
...
@@ -373,7 +373,7 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
/* Now free the structure */
HeapFree
(
GetProcessHeap
(),
0
,
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
}
TRACE
(
"Done
\n
"
);
...
...
@@ -559,7 +559,7 @@ IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2 *iface,
TRACE
(
"iface %p, tex1 %p, tex2 %p.
\n
"
,
iface
,
Tex1
,
Tex2
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
h1
=
surf1
->
Handle
-
1
;
h2
=
surf2
->
Handle
-
1
;
...
...
@@ -568,7 +568,7 @@ IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2 *iface,
surf2
->
Handle
=
h1
+
1
;
surf1
->
Handle
=
h2
+
1
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -730,9 +730,9 @@ static HRESULT WINAPI IDirect3DDeviceImpl_1_Execute(IDirect3DDevice *iface,
return
DDERR_INVALIDPARAMS
;
/* Execute... */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
d3d_execute_buffer_execute
(
buffer
,
This
,
Direct3DViewportImpl
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -767,11 +767,11 @@ IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3 *iface,
if
(
!
vp
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
list_add_head
(
&
This
->
viewport_list
,
&
vp
->
entry
);
vp
->
active_device
=
This
;
/* Viewport must be usable for Clear() after AddViewport,
so set active_device here. */
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -821,19 +821,20 @@ static HRESULT WINAPI IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3 *ifa
TRACE
(
"iface %p, viewport %p.
\n
"
,
iface
,
viewport
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
vp
->
active_device
!=
This
)
{
WARN
(
"Viewport %p active device is %p.
\n
"
,
vp
,
vp
->
active_device
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
vp
->
active_device
=
NULL
;
list_remove
(
&
vp
->
entry
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -898,7 +899,7 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
switch
(
Flags
)
{
case
D3DNEXT_NEXT
:
...
...
@@ -916,7 +917,7 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
default:
WARN
(
"Invalid flags %#x.
\n
"
,
Flags
);
*
lplpDirect3DViewport3
=
NULL
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -928,7 +929,8 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
else
*
lplpDirect3DViewport3
=
NULL
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1091,13 +1093,13 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
if
(
!
Callback
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
memset
(
&
mode
,
0
,
sizeof
(
mode
));
hr
=
wined3d_device_get_display_mode
(
This
->
ddraw
->
wined3d_device
,
0
,
&
mode
);
if
(
FAILED
(
hr
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
WARN
(
"Cannot get the current adapter format
\n
"
);
return
hr
;
}
...
...
@@ -1119,7 +1121,7 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
if
(
hr
!=
DDENUMRET_OK
)
{
TRACE
(
"Format enumeration cancelled by application
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
}
...
...
@@ -1143,13 +1145,14 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
if
(
hr
!=
DDENUMRET_OK
)
{
TRACE
(
"Format enumeration cancelled by application
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
}
}
TRACE
(
"End of enumeration
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1229,13 +1232,13 @@ IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
if
(
!
Callback
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
memset
(
&
mode
,
0
,
sizeof
(
mode
));
hr
=
wined3d_device_get_display_mode
(
This
->
ddraw
->
wined3d_device
,
0
,
&
mode
);
if
(
FAILED
(
hr
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
WARN
(
"Cannot get the current adapter format
\n
"
);
return
hr
;
}
...
...
@@ -1260,13 +1263,14 @@ IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
if
(
hr
!=
DDENUMRET_OK
)
{
TRACE
(
"Format enumeration cancelled by application
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
}
}
TRACE
(
"End of enumeration
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1315,14 +1319,14 @@ IDirect3DDeviceImpl_1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE *D3DM
return
DDERR_OUTOFMEMORY
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
h
=
ddraw_allocate_handle
(
&
This
->
handle_table
,
Matrix
,
DDRAW_HANDLE_MATRIX
);
if
(
h
==
DDRAW_INVALID_HANDLE
)
{
ERR
(
"Failed to allocate a matrix handle.
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
Matrix
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_OUTOFMEMORY
;
}
...
...
@@ -1330,7 +1334,8 @@ IDirect3DDeviceImpl_1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE *D3DM
TRACE
(
" returning matrix handle %d
\n
"
,
*
D3DMatHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1364,13 +1369,13 @@ IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice *iface,
if
(
!
D3DMatrix
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
m
=
ddraw_get_object
(
&
This
->
handle_table
,
D3DMatHandle
-
1
,
DDRAW_HANDLE_MATRIX
);
if
(
!
m
)
{
WARN
(
"Invalid matrix handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -1388,7 +1393,8 @@ IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice *iface,
if
(
D3DMatHandle
==
This
->
proj
)
wined3d_device_set_transform
(
This
->
wined3d_device
,
WINED3DTS_PROJECTION
,
(
WINED3DMATRIX
*
)
D3DMatrix
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1420,19 +1426,20 @@ IDirect3DDeviceImpl_1_GetMatrix(IDirect3DDevice *iface,
if
(
!
D3DMatrix
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
m
=
ddraw_get_object
(
&
This
->
handle_table
,
D3DMatHandle
-
1
,
DDRAW_HANDLE_MATRIX
);
if
(
!
m
)
{
WARN
(
"Invalid matrix handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
*
D3DMatrix
=
*
m
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1460,17 +1467,17 @@ IDirect3DDeviceImpl_1_DeleteMatrix(IDirect3DDevice *iface,
TRACE
(
"iface %p, matrix_handle %#x.
\n
"
,
iface
,
D3DMatHandle
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
m
=
ddraw_free_handle
(
&
This
->
handle_table
,
D3DMatHandle
-
1
,
DDRAW_HANDLE_MATRIX
);
if
(
!
m
)
{
WARN
(
"Invalid matrix handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
HeapFree
(
GetProcessHeap
(),
0
,
m
);
...
...
@@ -1499,9 +1506,10 @@ IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7 *iface)
TRACE
(
"iface %p.
\n
"
,
iface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_begin_scene
(
This
->
wined3d_device
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
if
(
hr
==
WINED3D_OK
)
return
D3D_OK
;
else
return
D3DERR_SCENE_IN_SCENE
;
/* TODO: Other possible causes of failure */
}
...
...
@@ -1571,9 +1579,10 @@ IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7 *iface)
TRACE
(
"iface %p.
\n
"
,
iface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_end_scene
(
This
->
wined3d_device
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
if
(
hr
==
WINED3D_OK
)
return
D3D_OK
;
else
return
D3DERR_SCENE_NOT_IN_SCENE
;
}
...
...
@@ -1726,18 +1735,18 @@ IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3 *iface,
TRACE
(
"iface %p, viewport %p.
\n
"
,
iface
,
Direct3DViewport3
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* Do nothing if the specified viewport is the same as the current one */
if
(
This
->
current_viewport
==
vp
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
if
(
vp
->
active_device
!=
This
)
{
WARN
(
"Viewport %p active device is %p.
\n
"
,
vp
,
vp
->
active_device
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -1756,7 +1765,8 @@ IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3 *iface,
/* Activate this viewport */
viewport_activate
(
This
->
current_viewport
,
FALSE
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1798,7 +1808,7 @@ IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3 *iface,
if
(
!
Direct3DViewport3
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
*
Direct3DViewport3
=
&
This
->
current_viewport
->
IDirect3DViewport3_iface
;
/* AddRef the returned viewport */
...
...
@@ -1806,7 +1816,8 @@ IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3 *iface,
TRACE
(
" returning interface %p
\n
"
,
*
Direct3DViewport3
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1846,13 +1857,12 @@ static HRESULT d3d_device_set_render_target(IDirect3DDeviceImpl *This, IDirectDr
{
HRESULT
hr
;
EnterCriticalSection
(
&
ddraw_cs
);
/* Flags: Not used */
wined3d_mutex_lock
();
if
(
This
->
target
==
Target
)
{
TRACE
(
"No-op SetRenderTarget operation, not doing anything
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
This
->
target
=
Target
;
...
...
@@ -1860,11 +1870,13 @@ static HRESULT d3d_device_set_render_target(IDirect3DDeviceImpl *This, IDirectDr
Target
?
Target
->
wined3d_surface
:
NULL
,
FALSE
);
if
(
hr
!=
D3D_OK
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
IDirect3DDeviceImpl_UpdateDepthStencil
(
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1961,11 +1973,11 @@ IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7 *iface,
if
(
!
RenderTarget
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
*
RenderTarget
=
&
This
->
target
->
IDirectDrawSurface7_iface
;
IDirectDrawSurface7_AddRef
(
*
RenderTarget
);
wined3d_mutex_unlock
();
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -2042,13 +2054,13 @@ IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3 *iface,
TRACE
(
"iface %p, primitive_type %#x, FVF %#x, flags %#x.
\n
"
,
iface
,
PrimitiveType
,
VertexTypeDesc
,
Flags
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
This
->
primitive_type
=
PrimitiveType
;
This
->
vertex_type
=
VertexTypeDesc
;
This
->
render_flags
=
Flags
;
This
->
vertex_size
=
get_flexible_vertex_size
(
This
->
vertex_type
);
This
->
nb_vertices
=
0
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -2161,7 +2173,7 @@ IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3 *iface,
if
(
!
Vertex
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
((
This
->
nb_vertices
+
1
)
*
This
->
vertex_size
>
This
->
buffer_size
)
{
BYTE
*
old_buffer
;
...
...
@@ -2176,8 +2188,8 @@ IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3 *iface,
}
CopyMemory
(
This
->
vertex_buffer
+
This
->
nb_vertices
++
*
This
->
vertex_size
,
Vertex
,
This
->
vertex_size
);
wined3d_mutex_unlock
();
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -2288,7 +2300,7 @@ static HRESULT IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
if
(
!
Value
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
switch
(
RenderStateType
)
{
case
D3DRENDERSTATE_TEXTUREMAG
:
...
...
@@ -2321,7 +2333,7 @@ static HRESULT IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
0
,
WINED3DSAMP_MINFILTER
,
&
tex_min
);
if
(
FAILED
(
hr
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
hr
=
wined3d_device_get_sampler_state
(
This
->
wined3d_device
,
...
...
@@ -2409,7 +2421,8 @@ static HRESULT IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
}
hr
=
wined3d_device_get_render_state
(
This
->
wined3d_device
,
RenderStateType
,
Value
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -2455,8 +2468,7 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
struct
wined3d_texture
*
tex
=
NULL
;
*
lpdwRenderState
=
0
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
hr
=
wined3d_device_get_texture
(
This
->
wined3d_device
,
0
,
&
tex
);
if
(
SUCCEEDED
(
hr
)
&&
tex
)
{
...
...
@@ -2466,8 +2478,7 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
if
(
parent
)
*
lpdwRenderState
=
parent
->
Handle
;
wined3d_texture_decref
(
tex
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -2479,7 +2490,7 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
DWORD
colorop
,
colorarg1
,
colorarg2
;
DWORD
alphaop
,
alphaarg1
,
alphaarg2
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
This
->
legacyTextureBlending
=
TRUE
;
...
...
@@ -2541,7 +2552,7 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
*
lpdwRenderState
=
D3DTBLEND_MODULATE
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -2589,7 +2600,7 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, state %#x, value %#x.
\n
"
,
iface
,
RenderStateType
,
Value
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* Some render states need special care */
switch
(
RenderStateType
)
{
...
...
@@ -2721,7 +2732,8 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
hr
=
wined3d_device_set_render_state
(
This
->
wined3d_device
,
RenderStateType
,
Value
);
break
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -2777,7 +2789,7 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
TRACE
(
"iface %p, state %#x, value %#x.
\n
"
,
iface
,
RenderStateType
,
Value
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
switch
(
RenderStateType
)
{
...
...
@@ -2918,8 +2930,7 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
hr
=
IDirect3DDevice7_SetRenderState
(
&
This
->
IDirect3DDevice7_iface
,
RenderStateType
,
Value
);
break
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -2968,14 +2979,14 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
LightStateType
==
D3DLIGHTSTATE_MATERIAL
/* 1 */
)
{
IDirect3DMaterialImpl
*
m
=
ddraw_get_object
(
&
This
->
handle_table
,
Value
-
1
,
DDRAW_HANDLE_MATERIAL
);
if
(
!
m
)
{
WARN
(
"Invalid material handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -2997,7 +3008,7 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
break
;
default:
ERR
(
"Unknown color model!
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
}
...
...
@@ -3026,16 +3037,16 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
break
;
default:
ERR
(
"Unknown D3DLIGHTSTATETYPE %d.
\n
"
,
LightStateType
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
hr
=
IDirect3DDevice7_SetRenderState
(
&
This
->
IDirect3DDevice7_iface
,
rs
,
Value
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
wined3d_mutex_unlock
();
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -3086,7 +3097,7 @@ IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3 *iface,
if
(
!
Value
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
LightStateType
==
D3DLIGHTSTATE_MATERIAL
/* 1 */
)
{
*
Value
=
This
->
material
;
...
...
@@ -3120,16 +3131,16 @@ IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3 *iface,
break
;
default:
ERR
(
"Unknown D3DLIGHTSTATETYPE %d.
\n
"
,
LightStateType
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
hr
=
IDirect3DDevice7_GetRenderState
(
&
This
->
IDirect3DDevice7_iface
,
rs
,
Value
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
wined3d_mutex_unlock
();
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -3188,9 +3199,10 @@ IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_set_transform
(
This
->
wined3d_device
,
type
,
(
WINED3DMATRIX
*
)
Matrix
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3278,9 +3290,10 @@ IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_get_transform
(
This
->
wined3d_device
,
type
,
(
WINED3DMATRIX
*
)
Matrix
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3366,10 +3379,11 @@ IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7 *iface,
}
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_multiply_transform
(
This
->
wined3d_device
,
type
,
(
WINED3DMATRIX
*
)
D3DMatrix
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3459,18 +3473,19 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
stride
=
get_flexible_vertex_size
(
VertexType
);
/* Set the FVF */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_set_vertex_declaration
(
This
->
wined3d_device
,
ddraw_find_decl
(
This
->
ddraw
,
VertexType
));
if
(
hr
!=
D3D_OK
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
/* This method translates to the user pointer draw of WineD3D */
wined3d_device_set_primitive_type
(
This
->
wined3d_device
,
PrimitiveType
);
hr
=
wined3d_device_draw_primitive_up
(
This
->
wined3d_device
,
VertexCount
,
Vertices
,
stride
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3580,19 +3595,20 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
iface
,
PrimitiveType
,
VertexType
,
Vertices
,
VertexCount
,
Indices
,
IndexCount
,
Flags
);
/* Set the D3DDevice's FVF */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_set_vertex_declaration
(
This
->
wined3d_device
,
ddraw_find_decl
(
This
->
ddraw
,
VertexType
));
if
(
FAILED
(
hr
))
{
ERR
(
" (%p) Setting the FVF failed, hr = %x!
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
wined3d_device_set_primitive_type
(
This
->
wined3d_device
,
PrimitiveType
);
hr
=
wined3d_device_draw_indexed_primitive_up
(
This
->
wined3d_device
,
IndexCount
,
Indices
,
WINED3DFMT_R16_UINT
,
Vertices
,
get_flexible_vertex_size
(
VertexType
));
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3847,10 +3863,11 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
}
/* WineD3D doesn't need the FVF here */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_device_set_primitive_type
(
This
->
wined3d_device
,
PrimitiveType
);
hr
=
wined3d_device_draw_primitive_strided
(
This
->
wined3d_device
,
VertexCount
,
&
WineD3DStrided
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3988,11 +4005,12 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
}
/* WineD3D doesn't need the FVF here */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_device_set_primitive_type
(
This
->
wined3d_device
,
PrimitiveType
);
hr
=
wined3d_device_draw_indexed_primitive_strided
(
This
->
wined3d_device
,
IndexCount
,
&
WineD3DStrided
,
VertexCount
,
Indices
,
WINED3DFMT_R16_UINT
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -4086,12 +4104,12 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
}
stride
=
get_flexible_vertex_size
(
vb
->
fvf
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_set_vertex_declaration
(
This
->
wined3d_device
,
vb
->
wineD3DVertexDeclaration
);
if
(
FAILED
(
hr
))
{
ERR
(
" (%p) Setting the FVF failed, hr = %x!
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -4100,14 +4118,15 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
if
(
hr
!=
D3D_OK
)
{
ERR
(
"(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
/* Now draw the primitives */
wined3d_device_set_primitive_type
(
This
->
wined3d_device
,
PrimitiveType
);
hr
=
wined3d_device_draw_primitive
(
This
->
wined3d_device
,
StartVertex
,
NumVertices
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -4200,13 +4219,13 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
* 4) Call IWineD3DDevice::DrawIndexedPrimitive
*/
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_set_vertex_declaration
(
This
->
wined3d_device
,
vb
->
wineD3DVertexDeclaration
);
if
(
FAILED
(
hr
))
{
ERR
(
" (%p) Setting the FVF failed, hr = %x!
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -4226,7 +4245,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
if
(
FAILED
(
hr
))
{
ERR
(
"(%p) IWineD3DDevice::CreateIndexBuffer failed with hr = %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -4243,7 +4262,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
if
(
FAILED
(
hr
))
{
ERR
(
"Failed to map buffer, hr %#x.
\n
"
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
memcpy
(
LockedIndices
,
Indices
,
IndexCount
*
sizeof
(
WORD
));
...
...
@@ -4258,7 +4277,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
if
(
FAILED
(
hr
))
{
ERR
(
"(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -4266,7 +4285,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
wined3d_device_set_primitive_type
(
This
->
wined3d_device
,
PrimitiveType
);
hr
=
wined3d_device_draw_indexed_primitive
(
This
->
wined3d_device
,
0
,
IndexCount
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -4477,19 +4497,20 @@ IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_get_texture
(
This
->
wined3d_device
,
Stage
,
&
wined3d_texture
);
if
(
FAILED
(
hr
)
||
!
wined3d_texture
)
{
*
Texture
=
NULL
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
*
Texture
=
wined3d_texture_get_parent
(
wined3d_texture
);
IDirectDrawSurface7_AddRef
(
*
Texture
);
wined3d_texture_decref
(
wined3d_texture
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -4564,10 +4585,11 @@ IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, stage %u, texture %p.
\n
"
,
iface
,
Stage
,
Texture
);
/* Texture may be NULL here */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_set_texture
(
This
->
wined3d_device
,
Stage
,
surf
?
surf
->
wined3d_texture
:
NULL
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -4606,7 +4628,7 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
TRACE
(
"iface %p, stage %u, texture %p.
\n
"
,
iface
,
Stage
,
Texture2
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
This
->
legacyTextureBlending
)
IDirect3DDevice3_GetRenderState
(
iface
,
D3DRENDERSTATE_TEXTUREMAPBLEND
,
&
texmapblend
);
...
...
@@ -4647,7 +4669,7 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
wined3d_device_set_texture_stage_state
(
This
->
wined3d_device
,
0
,
WINED3DTSS_ALPHAOP
,
WINED3DTOP_SELECTARG2
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -4728,7 +4750,7 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
l
=
&
tss_lookup
[
TexStageStateType
];
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
l
->
sampler_state
)
{
...
...
@@ -4779,7 +4801,8 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
hr
=
wined3d_device_get_texture_stage_state
(
This
->
wined3d_device
,
Stage
,
l
->
state
,
State
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -4859,7 +4882,7 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
l
=
&
tss_lookup
[
TexStageStateType
];
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
l
->
sampler_state
)
{
...
...
@@ -4915,7 +4938,8 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
hr
=
wined3d_device_set_texture_stage_state
(
This
->
wined3d_device
,
Stage
,
l
->
state
,
State
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -4983,9 +5007,10 @@ IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, pass_count %p.
\n
"
,
iface
,
NumPasses
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_validate_device
(
This
->
wined3d_device
,
NumPasses
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -5055,9 +5080,10 @@ IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %#x.
\n
"
,
iface
,
Count
,
Rects
,
Flags
,
Color
,
Z
,
Stencil
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_clear
(
This
->
wined3d_device
,
Count
,
(
RECT
*
)
Rects
,
Flags
,
Color
,
Z
,
Stencil
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -5122,9 +5148,10 @@ IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
/* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_set_viewport
(
This
->
wined3d_device
,
(
WINED3DVIEWPORT
*
)
Data
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -5178,10 +5205,10 @@ IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
/* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_get_viewport
(
This
->
wined3d_device
,
(
WINED3DVIEWPORT
*
)
Data
);
wined3d_mutex_unlock
();
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -5232,10 +5259,12 @@ IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, material %p.
\n
"
,
iface
,
Mat
);
if
(
!
Mat
)
return
DDERR_INVALIDPARAMS
;
wined3d_mutex_lock
();
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
wined3d_device_set_material
(
This
->
wined3d_device
,
(
WINED3DMATERIAL
*
)
Mat
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -5285,10 +5314,11 @@ IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, material %p.
\n
"
,
iface
,
Mat
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
hr
=
wined3d_device_get_material
(
This
->
wined3d_device
,
(
WINED3DMATERIAL
*
)
Mat
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -5339,10 +5369,11 @@ IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, light_idx %u, light %p.
\n
"
,
iface
,
LightIndex
,
Light
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
hr
=
wined3d_device_set_light
(
This
->
wined3d_device
,
LightIndex
,
(
WINED3DLIGHT
*
)
Light
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -5393,12 +5424,12 @@ IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, light_idx %u, light %p.
\n
"
,
iface
,
LightIndex
,
Light
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
rc
=
wined3d_device_get_light
(
This
->
wined3d_device
,
LightIndex
,
(
WINED3DLIGHT
*
)
Light
);
wined3d_mutex_unlock
();
/* Translate the result. WineD3D returns other values than D3D7 */
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
rc
);
}
...
...
@@ -5445,9 +5476,10 @@ IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7 *iface)
TRACE
(
"iface %p.
\n
"
,
iface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_begin_stateblock
(
This
->
wined3d_device
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -5504,13 +5536,13 @@ IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_end_stateblock
(
This
->
wined3d_device
,
&
wined3d_sb
);
if
(
FAILED
(
hr
))
{
WARN
(
"Failed to end stateblock, hr %#x.
\n
"
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
*
BlockHandle
=
0
;
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -5520,12 +5552,12 @@ IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
{
ERR
(
"Failed to allocate a stateblock handle.
\n
"
);
wined3d_stateblock_decref
(
wined3d_sb
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
*
BlockHandle
=
0
;
return
DDERR_OUTOFMEMORY
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
*
BlockHandle
=
h
+
1
;
return
hr_ddraw_from_wined3d
(
hr
);
...
...
@@ -5580,9 +5612,10 @@ IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7 *iface,
if
(
!
Texture
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_surface_preload
(
surf
->
wined3d_surface
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -5630,18 +5663,17 @@ IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, stateblock %#x.
\n
"
,
iface
,
BlockHandle
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
wined3d_sb
=
ddraw_get_object
(
&
This
->
handle_table
,
BlockHandle
-
1
,
DDRAW_HANDLE_STATEBLOCK
);
if
(
!
wined3d_sb
)
{
WARN
(
"Invalid stateblock handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3DERR_INVALIDSTATEBLOCK
;
}
hr
=
wined3d_stateblock_apply
(
wined3d_sb
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -5693,18 +5725,18 @@ IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, stateblock %#x.
\n
"
,
iface
,
BlockHandle
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
wined3d_sb
=
ddraw_get_object
(
&
This
->
handle_table
,
BlockHandle
-
1
,
DDRAW_HANDLE_STATEBLOCK
);
if
(
!
wined3d_sb
)
{
WARN
(
"Invalid stateblock handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3DERR_INVALIDSTATEBLOCK
;
}
hr
=
wined3d_stateblock_capture
(
wined3d_sb
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -5754,13 +5786,13 @@ IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, stateblock %#x.
\n
"
,
iface
,
BlockHandle
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_sb
=
ddraw_free_handle
(
&
This
->
handle_table
,
BlockHandle
-
1
,
DDRAW_HANDLE_STATEBLOCK
);
if
(
!
wined3d_sb
)
{
WARN
(
"Invalid stateblock handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3DERR_INVALIDSTATEBLOCK
;
}
...
...
@@ -5769,7 +5801,8 @@ IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
ERR
(
"Something is still holding stateblock %p (refcount %u).
\n
"
,
wined3d_sb
,
ref
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -5833,14 +5866,14 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* The D3DSTATEBLOCKTYPE enum is fine here. */
hr
=
wined3d_stateblock_create
(
This
->
wined3d_device
,
Type
,
&
wined3d_sb
);
if
(
FAILED
(
hr
))
{
WARN
(
"Failed to create stateblock, hr %#x.
\n
"
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -5849,12 +5882,12 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
{
ERR
(
"Failed to allocate stateblock handle.
\n
"
);
wined3d_stateblock_decref
(
wined3d_sb
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_OUTOFMEMORY
;
}
*
BlockHandle
=
h
+
1
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -6068,7 +6101,7 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
if
(
(
!
src
)
||
(
!
dest
)
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
SrcRect
)
srcrect
=
*
SrcRect
;
else
...
...
@@ -6096,7 +6129,7 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
dest
->
surface_desc
.
dwWidth
>
src
->
surface_desc
.
dwWidth
||
dest
->
surface_desc
.
dwHeight
>
src
->
surface_desc
.
dwHeight
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -6104,7 +6137,7 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
if
(
src
->
surface_desc
.
ddsCaps
.
dwCaps2
&
DDSCAPS2_MIPMAPSUBLEVEL
||
dest
->
surface_desc
.
ddsCaps
.
dwCaps2
&
DDSCAPS2_MIPMAPSUBLEVEL
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -6118,7 +6151,7 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
if
(
!
(
dest
->
surface_desc
.
ddsCaps
.
dwCaps2
&
DDSCAPS2_CUBEMAP
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -6141,7 +6174,7 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
/* Destination mip levels must be subset of source mip levels. */
if
(
!
is_mip_level_subset
(
dest_face
,
src_face
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
}
...
...
@@ -6191,18 +6224,18 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
/* Native returns error if src faces are not subset of dest faces. */
if
(
src_face
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
}
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
else
if
(
dest
->
surface_desc
.
ddsCaps
.
dwCaps2
&
DDSCAPS2_CUBEMAP
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -6211,13 +6244,14 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
/* Destination mip levels must be subset of source mip levels. */
if
(
!
is_mip_level_subset
(
dest
,
src
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
copy_mipmap_chain
(
This
,
dest
,
src
,
&
destpoint
,
&
srcrect
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -6276,9 +6310,10 @@ IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7 *iface,
TRACE
(
"iface %p, light_idx %u, enabled %#x.
\n
"
,
iface
,
LightIndex
,
Enable
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_set_light_enable
(
This
->
wined3d_device
,
LightIndex
,
Enable
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -6335,9 +6370,10 @@ IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7 *iface,
if
(
!
Enable
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_get_light_enable
(
This
->
wined3d_device
,
LightIndex
,
Enable
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -6394,9 +6430,10 @@ IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7 *iface,
if
(
!
PlaneEquation
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_set_clip_plane
(
This
->
wined3d_device
,
Index
,
PlaneEquation
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -6451,9 +6488,10 @@ IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7 *iface,
if
(
!
PlaneEquation
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_device_get_clip_plane
(
This
->
wined3d_device
,
Index
,
PlaneEquation
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
dlls/ddraw/light.c
View file @
a2963b66
...
...
@@ -224,11 +224,12 @@ static HRESULT WINAPI IDirect3DLightImpl_SetLight(IDirect3DLight *iface, D3DLIGH
light7
->
dvTheta
=
lpLight
->
dvTheta
;
light7
->
dvPhi
=
lpLight
->
dvPhi
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
memcpy
(
&
This
->
light
,
lpLight
,
lpLight
->
dwSize
);
if
(
This
->
light
.
dwFlags
&
D3DLIGHT_ACTIVE
)
light_update
(
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -256,9 +257,9 @@ static HRESULT WINAPI IDirect3DLightImpl_GetLight(IDirect3DLight *iface, D3DLIGH
dump_light
(
&
This
->
light
);
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
memcpy
(
lpLight
,
&
This
->
light
,
lpLight
->
dwSize
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
dlls/ddraw/main.c
View file @
a2963b66
...
...
@@ -39,18 +39,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/* The configured default surface */
WINED3DSURFTYPE
DefaultSurfaceType
=
SURFACE_OPENGL
;
/* DDraw list and critical section */
static
struct
list
global_ddraw_list
=
LIST_INIT
(
global_ddraw_list
);
static
CRITICAL_SECTION_DEBUG
ddraw_cs_debug
=
{
0
,
0
,
&
ddraw_cs
,
{
&
ddraw_cs_debug
.
ProcessLocksList
,
&
ddraw_cs_debug
.
ProcessLocksList
},
0
,
0
,
{
(
DWORD_PTR
)(
__FILE__
": ddraw_cs"
)
}
};
CRITICAL_SECTION
ddraw_cs
=
{
&
ddraw_cs_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
HINSTANCE
instance
;
/* value of ForceRefreshRate */
...
...
@@ -272,9 +262,9 @@ DirectDrawCreate(GUID *GUID,
TRACE
(
"driver_guid %s, ddraw %p, outer_unknown %p.
\n
"
,
debugstr_guid
(
GUID
),
DD
,
UnkOuter
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
DDRAW_Create
(
GUID
,
(
void
**
)
DD
,
UnkOuter
,
&
IID_IDirectDraw
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
if
(
SUCCEEDED
(
hr
))
{
...
...
@@ -309,9 +299,9 @@ DirectDrawCreateEx(GUID *guid,
if
(
!
IsEqualGUID
(
iid
,
&
IID_IDirectDraw7
))
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
DDRAW_Create
(
guid
,
dd
,
UnkOuter
,
iid
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
if
(
SUCCEEDED
(
hr
))
{
...
...
@@ -466,9 +456,10 @@ CF_CreateDirectDraw(IUnknown* UnkOuter, REFIID iid,
TRACE
(
"outer_unknown %p, riid %s, object %p.
\n
"
,
UnkOuter
,
debugstr_guid
(
iid
),
obj
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
DDRAW_Create
(
NULL
,
obj
,
UnkOuter
,
iid
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -495,18 +486,19 @@ CF_CreateDirectDrawClipper(IUnknown* UnkOuter, REFIID riid,
TRACE
(
"outer_unknown %p, riid %s, object %p.
\n
"
,
UnkOuter
,
debugstr_guid
(
riid
),
obj
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
DirectDrawCreateClipper
(
0
,
&
Clip
,
UnkOuter
);
if
(
hr
!=
DD_OK
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
hr
=
IDirectDrawClipper_QueryInterface
(
Clip
,
riid
,
obj
);
IDirectDrawClipper_Release
(
Clip
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
dlls/ddraw/material.c
View file @
a2963b66
...
...
@@ -142,9 +142,9 @@ static ULONG WINAPI IDirect3DMaterialImpl_Release(IDirect3DMaterial3 *iface)
{
if
(
This
->
Handle
)
{
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
ddraw_free_handle
(
&
This
->
ddraw
->
d3ddevice
->
handle_table
,
This
->
Handle
-
1
,
DDRAW_HANDLE_MATERIAL
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
}
HeapFree
(
GetProcessHeap
(),
0
,
This
);
...
...
@@ -236,10 +236,10 @@ static HRESULT WINAPI IDirect3DMaterialImpl_SetMaterial(IDirect3DMaterial3 *ifac
dump_material
(
lpMat
);
/* Stores the material */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
memset
(
&
This
->
mat
,
0
,
sizeof
(
This
->
mat
));
memcpy
(
&
This
->
mat
,
lpMat
,
lpMat
->
dwSize
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -271,10 +271,10 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetMaterial(IDirect3DMaterial3 *ifac
}
/* Copies the material structure */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
dwSize
=
lpMat
->
dwSize
;
memcpy
(
lpMat
,
&
This
->
mat
,
dwSize
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -302,7 +302,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
TRACE
(
"iface %p, device %p, handle %p.
\n
"
,
iface
,
device
,
handle
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
This
->
active_device
=
device_impl
;
if
(
!
This
->
Handle
)
{
...
...
@@ -310,7 +310,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
if
(
h
==
DDRAW_INVALID_HANDLE
)
{
ERR
(
"Failed to allocate a material handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
/* Unchecked */
}
...
...
@@ -318,7 +318,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
}
*
handle
=
This
->
Handle
;
TRACE
(
" returning handle %08x.
\n
"
,
*
handle
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
dlls/ddraw/palette.c
View file @
a2963b66
...
...
@@ -97,13 +97,14 @@ IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
if
(
ref
==
0
)
{
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_palette_decref
(
This
->
wineD3DPalette
);
if
(
This
->
ifaceToRelease
)
{
IUnknown_Release
(
This
->
ifaceToRelease
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
...
...
@@ -159,9 +160,9 @@ IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
TRACE
(
"iface %p, caps %p.
\n
"
,
iface
,
Caps
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
*
Caps
=
wined3d_palette_get_flags
(
This
->
wineD3DPalette
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -200,9 +201,10 @@ IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
if
(
!
PalEnt
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_palette_set_entries
(
This
->
wineD3DPalette
,
Flags
,
Start
,
Count
,
PalEnt
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -239,9 +241,10 @@ IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
if
(
!
PalEnt
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_palette_get_entries
(
This
->
wineD3DPalette
,
Flags
,
Start
,
Count
,
PalEnt
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
dlls/ddraw/surface.c
View file @
a2963b66
...
...
@@ -296,12 +296,12 @@ static void ddraw_surface_add_iface(IDirectDrawSurfaceImpl *This)
if
(
iface_count
==
1
)
{
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
This
->
wined3d_surface
)
wined3d_surface_incref
(
This
->
wined3d_surface
);
if
(
This
->
wined3d_texture
)
wined3d_texture_incref
(
This
->
wined3d_texture
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
}
}
...
...
@@ -511,18 +511,18 @@ ULONG ddraw_surface_release_iface(IDirectDrawSurfaceImpl *This)
if
(
iface_count
==
0
)
{
/* Complex attached surfaces are destroyed implicitly when the root is released */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
!
This
->
is_complex_root
)
{
WARN
(
"(%p) Attempt to destroy a surface that is not a complex root
\n
"
,
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
iface_count
;
}
if
(
This
->
wined3d_texture
)
/* If it's a texture, destroy the wined3d texture. */
wined3d_texture_decref
(
This
->
wined3d_texture
);
else
ddraw_surface_cleanup
(
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
}
return
iface_count
;
...
...
@@ -700,7 +700,7 @@ static HRESULT WINAPI ddraw_surface7_GetAttachedSurface(IDirectDrawSurface7 *ifa
TRACE
(
"iface %p, caps %p, attachment %p.
\n
"
,
iface
,
Caps
,
Surface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
This
->
version
<
7
)
{
...
...
@@ -744,7 +744,8 @@ static HRESULT WINAPI ddraw_surface7_GetAttachedSurface(IDirectDrawSurface7 *ifa
TRACE
(
"(%p): mipmapcount=%d
\n
"
,
This
,
surf
->
mipmap_level
);
*
Surface
=
&
surf
->
IDirectDrawSurface7_iface
;
ddraw_surface7_AddRef
(
*
Surface
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
}
...
...
@@ -769,13 +770,14 @@ static HRESULT WINAPI ddraw_surface7_GetAttachedSurface(IDirectDrawSurface7 *ifa
TRACE
(
"(%p): Returning surface %p
\n
"
,
This
,
surf
);
*
Surface
=
&
surf
->
IDirectDrawSurface7_iface
;
ddraw_surface7_AddRef
(
*
Surface
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
}
TRACE
(
"(%p) Didn't find a valid surface
\n
"
,
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
*
Surface
=
NULL
;
return
DDERR_NOTFOUND
;
...
...
@@ -926,7 +928,7 @@ static HRESULT surface_lock(IDirectDrawSurfaceImpl *This,
This
,
wine_dbgstr_rect
(
Rect
),
DDSD
,
Flags
,
h
);
/* This->surface_desc.dwWidth and dwHeight are changeable, thus lock */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* Should I check for the handle to be NULL?
*
...
...
@@ -947,7 +949,7 @@ static HRESULT surface_lock(IDirectDrawSurfaceImpl *This,
||
(
Rect
->
bottom
>
This
->
surface_desc
.
dwHeight
))
{
WARN
(
"Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
}
...
...
@@ -958,7 +960,7 @@ static HRESULT surface_lock(IDirectDrawSurfaceImpl *This,
hr
=
wined3d_surface_map
(
This
->
wined3d_surface
,
&
LockedRect
,
Rect
,
Flags
);
if
(
FAILED
(
hr
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
switch
(
hr
)
{
/* D3D8 and D3D9 return the general D3DERR_INVALIDCALL error, but ddraw has a more
...
...
@@ -992,7 +994,8 @@ static HRESULT surface_lock(IDirectDrawSurfaceImpl *This,
TRACE
(
"locked surface returning description :
\n
"
);
if
(
TRACE_ON
(
ddraw
))
DDRAW_dump_surface_desc
(
DDSD
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -1125,7 +1128,7 @@ static HRESULT WINAPI ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *pR
TRACE
(
"iface %p, rect %s.
\n
"
,
iface
,
wine_dbgstr_rect
(
pRect
));
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_unmap
(
This
->
wined3d_surface
);
if
(
SUCCEEDED
(
hr
))
{
...
...
@@ -1133,7 +1136,8 @@ static HRESULT WINAPI ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *pR
hr
=
ddraw_surface_update_frontbuffer
(
This
,
&
This
->
ddraw
->
primary_lock
,
FALSE
);
This
->
surface_desc
.
lpSurface
=
NULL
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -1206,7 +1210,7 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra
if
(
!
(
This
->
surface_desc
.
ddsCaps
.
dwCaps
&
(
DDSCAPS_FRONTBUFFER
|
DDSCAPS_OVERLAY
))
)
return
DDERR_INVALIDOBJECT
;
/* Unchecked */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* WineD3D doesn't keep track of attached surface, so find the target */
if
(
!
Override
)
...
...
@@ -1219,7 +1223,7 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra
if
(
hr
!=
DD_OK
)
{
ERR
(
"Can't find a flip target
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NOTFLIPPABLE
;
/* Unchecked */
}
Override
=
impl_from_IDirectDrawSurface7
(
Override7
);
...
...
@@ -1232,7 +1236,8 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra
if
(
SUCCEEDED
(
hr
)
&&
This
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_FRONTBUFFER
)
hr
=
ddraw_surface_update_frontbuffer
(
This
,
NULL
,
FALSE
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -1316,11 +1321,11 @@ static HRESULT WINAPI ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *DestR
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
Flags
&
DDBLT_KEYSRC
&&
(
!
Src
||
!
(
Src
->
surface_desc
.
dwFlags
&
DDSD_CKSRCBLT
)))
{
WARN
(
"DDBLT_KEYDEST blit without color key in surface, returning DDERR_INVALIDPARAMS
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -1336,7 +1341,7 @@ static HRESULT WINAPI ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *DestR
if
(
SUCCEEDED
(
hr
)
&&
(
This
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_FRONTBUFFER
))
hr
=
ddraw_surface_update_frontbuffer
(
This
,
DestRect
,
FALSE
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
switch
(
hr
)
{
case
WINED3DERR_NOTAVAILABLE
:
return
DDERR_UNSUPPORTED
;
...
...
@@ -1444,7 +1449,7 @@ static HRESULT ddraw_surface_attach_surface(IDirectDrawSurfaceImpl *This, IDirec
if
(
Surf
==
This
)
return
DDERR_CANNOTATTACHSURFACE
;
/* unchecked */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* Check if the surface is already attached somewhere */
if
(
Surf
->
next_attached
||
Surf
->
first_attached
!=
Surf
)
...
...
@@ -1455,7 +1460,7 @@ static HRESULT ddraw_surface_attach_surface(IDirectDrawSurfaceImpl *This, IDirec
WARN
(
"Surface %p is already attached somewhere. next_attached %p, first_attached %p.
\n
"
,
Surf
,
Surf
->
next_attached
,
Surf
->
first_attached
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_SURFACEALREADYATTACHED
;
}
...
...
@@ -1470,7 +1475,8 @@ static HRESULT ddraw_surface_attach_surface(IDirectDrawSurfaceImpl *This, IDirec
IDirect3DDeviceImpl_UpdateDepthStencil
(
This
->
ddraw
->
d3ddevice
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -1628,17 +1634,17 @@ static HRESULT ddraw_surface_delete_attached_surface(IDirectDrawSurfaceImpl *Thi
TRACE
(
"surface %p, attachment %p, detach_iface %p.
\n
"
,
This
,
Surf
,
detach_iface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
!
Surf
||
(
Surf
->
first_attached
!=
This
)
||
(
Surf
==
This
)
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_CANNOTDETACHSURFACE
;
}
if
(
Surf
->
attached_iface
!=
detach_iface
)
{
WARN
(
"Surf->attach_iface %p != detach_iface %p.
\n
"
,
Surf
->
attached_iface
,
detach_iface
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_SURFACENOTATTACHED
;
}
...
...
@@ -1671,7 +1677,7 @@ static HRESULT ddraw_surface_delete_attached_surface(IDirectDrawSurfaceImpl *Thi
{
IDirect3DDeviceImpl_UpdateDepthStencil
(
This
->
ddraw
->
d3ddevice
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
/* Set attached_iface to NULL before releasing it, the surface may go
* away. */
...
...
@@ -1811,12 +1817,12 @@ static HRESULT WINAPI ddraw_surface7_GetDC(IDirectDrawSurface7 *iface, HDC *hdc)
if
(
!
hdc
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
This
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_FRONTBUFFER
)
hr
=
ddraw_surface_update_frontbuffer
(
This
,
NULL
,
TRUE
);
if
(
SUCCEEDED
(
hr
))
hr
=
wined3d_surface_getdc
(
This
->
wined3d_surface
,
hdc
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
switch
(
hr
)
{
/* Some, but not all errors set *hdc to NULL. E.g. DCALREADYCREATED does not
...
...
@@ -1882,11 +1888,12 @@ static HRESULT WINAPI ddraw_surface7_ReleaseDC(IDirectDrawSurface7 *iface, HDC h
TRACE
(
"iface %p, dc %p.
\n
"
,
iface
,
hdc
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_releasedc
(
This
->
wined3d_surface
,
hdc
);
if
(
SUCCEEDED
(
hr
)
&&
(
This
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_FRONTBUFFER
))
hr
=
ddraw_surface_update_frontbuffer
(
This
,
NULL
,
FALSE
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -2021,9 +2028,10 @@ static HRESULT WINAPI ddraw_surface7_SetPriority(IDirectDrawSurface7 *iface, DWO
TRACE
(
"iface %p, priority %u.
\n
"
,
iface
,
Priority
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_set_priority
(
This
->
wined3d_surface
,
Priority
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -2052,9 +2060,10 @@ static HRESULT WINAPI ddraw_surface7_GetPriority(IDirectDrawSurface7 *iface, DWO
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
*
Priority
=
wined3d_surface_get_priority
(
This
->
wined3d_surface
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -2085,10 +2094,11 @@ static HRESULT WINAPI ddraw_surface7_SetPrivateData(IDirectDrawSurface7 *iface,
TRACE
(
"iface %p, tag %s, data %p, data_size %u, flags %#x.
\n
"
,
iface
,
debugstr_guid
(
tag
),
Data
,
Size
,
Flags
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
resource
=
wined3d_surface_get_resource
(
This
->
wined3d_surface
);
hr
=
wined3d_resource_set_private_data
(
resource
,
tag
,
Data
,
Size
,
Flags
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
switch
(
hr
)
{
case
WINED3DERR_INVALIDCALL
:
return
DDERR_INVALIDPARAMS
;
...
...
@@ -2134,10 +2144,11 @@ static HRESULT WINAPI ddraw_surface7_GetPrivateData(IDirectDrawSurface7 *iface,
if
(
!
Data
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
resource
=
wined3d_surface_get_resource
(
This
->
wined3d_surface
);
hr
=
wined3d_resource_get_private_data
(
resource
,
tag
,
Data
,
Size
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -2171,10 +2182,11 @@ static HRESULT WINAPI ddraw_surface7_FreePrivateData(IDirectDrawSurface7 *iface,
TRACE
(
"iface %p, tag %s.
\n
"
,
iface
,
debugstr_guid
(
tag
));
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
resource
=
wined3d_surface_get_resource
(
This
->
wined3d_surface
);
hr
=
wined3d_resource_free_private_data
(
resource
,
tag
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -2353,7 +2365,8 @@ static HRESULT WINAPI ddraw_surface7_EnumAttachedSurfaces(IDirectDrawSurface7 *i
if
(
!
cb
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
for
(
i
=
0
;
i
<
MAX_COMPLEX_ATTACHED
;
i
++
)
{
surf
=
This
->
complex_array
[
i
];
...
...
@@ -2364,7 +2377,7 @@ static HRESULT WINAPI ddraw_surface7_EnumAttachedSurfaces(IDirectDrawSurface7 *i
/* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
if
(
cb
(
&
surf
->
IDirectDrawSurface7_iface
,
&
desc
,
context
)
==
DDENUMRET_CANCEL
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
}
...
...
@@ -2376,14 +2389,15 @@ static HRESULT WINAPI ddraw_surface7_EnumAttachedSurfaces(IDirectDrawSurface7 *i
/* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
if
(
cb
(
&
surf
->
IDirectDrawSurface7_iface
,
&
desc
,
context
)
==
DDENUMRET_CANCEL
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
}
TRACE
(
" end of enumeration.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -2584,9 +2598,9 @@ static HRESULT WINAPI ddraw_surface7_GetBltStatus(IDirectDrawSurface7 *iface, DW
TRACE
(
"iface %p, flags %#x.
\n
"
,
iface
,
Flags
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_get_blt_status
(
This
->
wined3d_surface
,
Flags
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
switch
(
hr
)
{
case
WINED3DERR_INVALIDCALL
:
return
DDERR_INVALIDPARAMS
;
...
...
@@ -2649,14 +2663,14 @@ static HRESULT WINAPI ddraw_surface7_GetColorKey(IDirectDrawSurface7 *iface, DWO
if
(
!
CKey
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
switch
(
Flags
)
{
case
DDCKEY_DESTBLT
:
if
(
!
(
This
->
surface_desc
.
dwFlags
&
DDSD_CKDESTBLT
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NOCOLORKEY
;
}
*
CKey
=
This
->
surface_desc
.
ddckCKDestBlt
;
...
...
@@ -2664,17 +2678,17 @@ static HRESULT WINAPI ddraw_surface7_GetColorKey(IDirectDrawSurface7 *iface, DWO
case
DDCKEY_DESTOVERLAY
:
if
(
!
(
This
->
surface_desc
.
dwFlags
&
DDSD_CKDESTOVERLAY
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
{
wined3d_mutex_unlock
(
);
return
DDERR_NOCOLORKEY
;
}
}
*
CKey
=
This
->
surface_desc
.
u3
.
ddckCKDestOverlay
;
break
;
case
DDCKEY_SRCBLT
:
if
(
!
(
This
->
surface_desc
.
dwFlags
&
DDSD_CKSRCBLT
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NOCOLORKEY
;
}
*
CKey
=
This
->
surface_desc
.
ddckCKSrcBlt
;
...
...
@@ -2683,18 +2697,19 @@ static HRESULT WINAPI ddraw_surface7_GetColorKey(IDirectDrawSurface7 *iface, DWO
case
DDCKEY_SRCOVERLAY
:
if
(
!
(
This
->
surface_desc
.
dwFlags
&
DDSD_CKSRCOVERLAY
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NOCOLORKEY
;
}
*
CKey
=
This
->
surface_desc
.
ddckCKSrcOverlay
;
break
;
default:
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -2749,9 +2764,10 @@ static HRESULT WINAPI ddraw_surface7_GetFlipStatus(IDirectDrawSurface7 *iface, D
TRACE
(
"iface %p, flags %#x.
\n
"
,
iface
,
Flags
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_get_flip_status
(
This
->
wined3d_surface
,
Flags
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
switch
(
hr
)
{
case
WINED3DERR_INVALIDCALL
:
return
DDERR_INVALIDPARAMS
;
...
...
@@ -2810,9 +2826,10 @@ static HRESULT WINAPI ddraw_surface7_GetOverlayPosition(IDirectDrawSurface7 *ifa
TRACE
(
"iface %p, x %p, y %p.
\n
"
,
iface
,
X
,
Y
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_get_overlay_position
(
This
->
wined3d_surface
,
X
,
Y
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -2872,9 +2889,9 @@ static HRESULT WINAPI ddraw_surface7_GetPixelFormat(IDirectDrawSurface7 *iface,
if
(
!
PixelFormat
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
DD_STRUCT_COPY_BYSIZE
(
PixelFormat
,
&
This
->
surface_desc
.
u4
.
ddpfPixelFormat
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -2940,12 +2957,12 @@ static HRESULT WINAPI ddraw_surface7_GetSurfaceDesc(IDirectDrawSurface7 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
DD_STRUCT_COPY_BYSIZE
(
DDSD
,
&
This
->
surface_desc
);
TRACE
(
"Returning surface desc:
\n
"
);
if
(
TRACE_ON
(
ddraw
))
DDRAW_dump_surface_desc
(
DDSD
);
wined3d_mutex_unlock
();
LeaveCriticalSection
(
&
ddraw_cs
);
return
DD_OK
;
}
...
...
@@ -2971,7 +2988,7 @@ static HRESULT WINAPI ddraw_surface3_GetSurfaceDesc(IDirectDrawSurface3 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
DDSD2_to_DDSD
(
&
This
->
surface_desc
,
surface_desc
);
TRACE
(
"Returning surface desc:
\n
"
);
if
(
TRACE_ON
(
ddraw
))
...
...
@@ -2979,8 +2996,8 @@ static HRESULT WINAPI ddraw_surface3_GetSurfaceDesc(IDirectDrawSurface3 *iface,
/* DDRAW_dump_surface_desc handles the smaller size */
DDRAW_dump_surface_desc
((
DDSURFACEDESC2
*
)
surface_desc
);
}
wined3d_mutex_unlock
();
LeaveCriticalSection
(
&
ddraw_cs
);
return
DD_OK
;
}
...
...
@@ -3105,9 +3122,10 @@ static HRESULT WINAPI ddraw_surface7_IsLost(IDirectDrawSurface7 *iface)
TRACE
(
"iface %p.
\n
"
,
iface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_is_lost
(
This
->
wined3d_surface
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
switch
(
hr
)
{
/* D3D8 and 9 loose full devices, thus there's only a DEVICELOST error.
...
...
@@ -3168,9 +3186,10 @@ static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface)
TRACE
(
"iface %p.
\n
"
,
iface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_restore
(
This
->
wined3d_surface
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3225,9 +3244,10 @@ static HRESULT WINAPI ddraw_surface7_SetOverlayPosition(IDirectDrawSurface7 *ifa
TRACE
(
"iface %p, x %d, y %d.
\n
"
,
iface
,
X
,
Y
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_set_overlay_position
(
This
->
wined3d_surface
,
X
,
Y
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3288,10 +3308,11 @@ static HRESULT WINAPI ddraw_surface7_UpdateOverlay(IDirectDrawSurface7 *iface, R
TRACE
(
"iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.
\n
"
,
iface
,
wine_dbgstr_rect
(
SrcRect
),
DstSurface
,
wine_dbgstr_rect
(
DstRect
),
Flags
,
FX
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_update_overlay
(
This
->
wined3d_surface
,
SrcRect
,
Dst
?
Dst
->
wined3d_surface
:
NULL
,
DstRect
,
Flags
,
(
WINEDDOVERLAYFX
*
)
FX
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
switch
(
hr
)
{
case
WINED3DERR_INVALIDCALL
:
return
DDERR_INVALIDPARAMS
;
case
WINEDDERR_NOTAOVERLAYSURFACE
:
return
DDERR_NOTAOVERLAYSURFACE
;
...
...
@@ -3421,10 +3442,11 @@ static HRESULT WINAPI ddraw_surface7_UpdateOverlayZOrder(IDirectDrawSurface7 *if
TRACE
(
"iface %p, flags %#x, reference %p.
\n
"
,
iface
,
Flags
,
DDSRef
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_surface_update_overlay_z_order
(
This
->
wined3d_surface
,
Flags
,
Ref
?
Ref
->
wined3d_surface
:
NULL
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3551,7 +3573,7 @@ static HRESULT WINAPI ddraw_surface7_ChangeUniquenessValue(IDirectDrawSurface7 *
TRACE
(
"iface %p.
\n
"
,
iface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
/* A uniqueness value of 0 is apparently special.
* This needs to be checked.
* TODO: Write tests for this code and check if the volatile, interlocked stuff is really needed
...
...
@@ -3570,7 +3592,8 @@ static HRESULT WINAPI ddraw_surface7_ChangeUniquenessValue(IDirectDrawSurface7 *
break
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -3588,9 +3611,10 @@ static HRESULT WINAPI ddraw_surface7_GetUniquenessValue(IDirectDrawSurface7 *ifa
TRACE
(
"iface %p, value %p.
\n
"
,
iface
,
pValue
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
*
pValue
=
This
->
uniqueness_value
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -3622,22 +3646,23 @@ static HRESULT WINAPI ddraw_surface7_SetLOD(IDirectDrawSurface7 *iface, DWORD Ma
TRACE
(
"iface %p, lod %u.
\n
"
,
iface
,
MaxLOD
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
!
(
This
->
surface_desc
.
ddsCaps
.
dwCaps2
&
DDSCAPS2_TEXTUREMANAGE
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDOBJECT
;
}
if
(
!
This
->
wined3d_texture
)
{
ERR
(
"(%p) The DirectDraw texture has no WineD3DTexture!
\n
"
,
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDOBJECT
;
}
hr
=
wined3d_texture_set_lod
(
This
->
wined3d_texture
,
MaxLOD
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -3664,15 +3689,16 @@ static HRESULT WINAPI ddraw_surface7_GetLOD(IDirectDrawSurface7 *iface, DWORD *M
if
(
!
MaxLOD
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
!
(
This
->
surface_desc
.
ddsCaps
.
dwCaps2
&
DDSCAPS2_TEXTUREMANAGE
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDOBJECT
;
}
*
MaxLOD
=
wined3d_texture_get_lod
(
This
->
wined3d_texture
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -3740,7 +3766,7 @@ static HRESULT WINAPI ddraw_surface7_BltFast(IDirectDrawSurface7 *iface, DWORD d
if
(
trans
&
DDBLTFAST_DONOTWAIT
)
flags
|=
WINEDDBLT_DONOTWAIT
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
src
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_FRONTBUFFER
)
hr
=
ddraw_surface_update_frontbuffer
(
src
,
rsrc
,
TRUE
);
if
(
SUCCEEDED
(
hr
))
...
...
@@ -3748,7 +3774,8 @@ static HRESULT WINAPI ddraw_surface7_BltFast(IDirectDrawSurface7 *iface, DWORD d
src
->
wined3d_surface
,
rsrc
,
flags
,
NULL
,
WINED3DTEXF_POINT
);
if
(
SUCCEEDED
(
hr
)
&&
(
This
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_FRONTBUFFER
))
hr
=
ddraw_surface_update_frontbuffer
(
This
,
&
dst_rect
,
FALSE
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
switch
(
hr
)
{
case
WINED3DERR_NOTAVAILABLE
:
return
DDERR_UNSUPPORTED
;
...
...
@@ -3826,22 +3853,20 @@ static HRESULT WINAPI ddraw_surface7_GetClipper(IDirectDrawSurface7 *iface, IDir
TRACE
(
"iface %p, clipper %p.
\n
"
,
iface
,
Clipper
);
if
(
!
Clipper
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
if
(
!
Clipper
)
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
This
->
clipper
==
NULL
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NOCLIPPERATTACHED
;
}
*
Clipper
=
(
IDirectDrawClipper
*
)
This
->
clipper
;
IDirectDrawClipper_AddRef
(
*
Clipper
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -3900,10 +3925,10 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
TRACE
(
"iface %p, clipper %p.
\n
"
,
iface
,
iclipper
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
clipper
==
This
->
clipper
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -3936,7 +3961,8 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
}
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -4007,7 +4033,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
DDSD
->
dwFlags
&
DDSD_PIXELFORMAT
)
{
newFormat
=
PixelFormat_DD2WineD3D
(
&
DDSD
->
u4
.
ddpfPixelFormat
);
...
...
@@ -4015,7 +4041,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
if
(
newFormat
==
WINED3DFMT_UNKNOWN
)
{
ERR
(
"Requested to set an unknown pixelformat
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
if
(
newFormat
!=
PixelFormat_DD2WineD3D
(
&
This
->
surface_desc
.
u4
.
ddpfPixelFormat
)
)
...
...
@@ -4023,7 +4049,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
hr
=
wined3d_surface_set_format
(
This
->
wined3d_surface
,
newFormat
);
if
(
FAILED
(
hr
))
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
}
...
...
@@ -4057,7 +4083,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
switch
(
hr
)
{
case
WINED3DERR_INVALIDCALL
:
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
default:
break
;
/* Go on */
...
...
@@ -4067,7 +4093,8 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
This
->
surface_desc
=
*
DDSD
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -4118,7 +4145,7 @@ static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDir
if
(
!
Pal
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_palette
=
wined3d_surface_get_palette
(
This
->
wined3d_surface
);
if
(
wined3d_palette
)
{
...
...
@@ -4131,7 +4158,8 @@ static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDir
hr
=
DDERR_NOPALETTEATTACHED
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -4227,7 +4255,7 @@ static HRESULT WINAPI ddraw_surface7_SetColorKey(IDirectDrawSurface7 *iface, DWO
TRACE
(
"iface %p, flags %#x, color_key %p.
\n
"
,
iface
,
Flags
,
CKey
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
CKey
)
{
FixedCKey
=
*
CKey
;
...
...
@@ -4258,7 +4286,7 @@ static HRESULT WINAPI ddraw_surface7_SetColorKey(IDirectDrawSurface7 *iface, DWO
break
;
default:
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
}
...
...
@@ -4283,13 +4311,14 @@ static HRESULT WINAPI ddraw_surface7_SetColorKey(IDirectDrawSurface7 *iface, DWO
break
;
default:
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
}
ctx
.
ret
=
wined3d_surface_set_color_key
(
This
->
wined3d_surface
,
Flags
,
ctx
.
CKey
);
ddraw_surface7_EnumAttachedSurfaces
(
iface
,
&
ctx
,
SetColorKeyEnum
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
switch
(
ctx
.
ret
)
{
case
WINED3DERR_INVALIDCALL
:
return
DDERR_INVALIDPARAMS
;
...
...
@@ -4362,11 +4391,11 @@ static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDir
}
/* Find the old palette */
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
IDirectDrawSurface_GetPalette
(
iface
,
&
oldPal
);
if
(
hr
!=
DD_OK
&&
hr
!=
DDERR_NOPALETTEATTACHED
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
if
(
oldPal
)
IDirectDrawPalette_Release
(
oldPal
);
/* For the GetPalette */
...
...
@@ -4413,7 +4442,8 @@ static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDir
}
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -4476,7 +4506,7 @@ static HRESULT WINAPI ddraw_gamma_control_GetGammaRamp(IDirectDrawGammaControl *
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
surface
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_PRIMARYSURFACE
)
{
/* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP. */
...
...
@@ -4486,7 +4516,7 @@ static HRESULT WINAPI ddraw_gamma_control_GetGammaRamp(IDirectDrawGammaControl *
{
ERR
(
"Not implemented for non-primary surfaces.
\n
"
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -4518,7 +4548,7 @@ static HRESULT WINAPI ddraw_gamma_control_SetGammaRamp(IDirectDrawGammaControl *
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
surface
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_PRIMARYSURFACE
)
{
/* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP */
...
...
@@ -4528,7 +4558,7 @@ static HRESULT WINAPI ddraw_gamma_control_SetGammaRamp(IDirectDrawGammaControl *
{
ERR
(
"Not implemented for non-primary surfaces.
\n
"
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -4601,7 +4631,7 @@ static HRESULT WINAPI d3d_texture2_GetHandle(IDirect3DTexture2 *iface,
TRACE
(
"iface %p, device %p, handle %p.
\n
"
,
iface
,
device
,
handle
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
!
surface
->
Handle
)
{
...
...
@@ -4609,7 +4639,7 @@ static HRESULT WINAPI d3d_texture2_GetHandle(IDirect3DTexture2 *iface,
if
(
h
==
DDRAW_INVALID_HANDLE
)
{
ERR
(
"Failed to allocate a texture handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_OUTOFMEMORY
;
}
...
...
@@ -4619,7 +4649,7 @@ static HRESULT WINAPI d3d_texture2_GetHandle(IDirect3DTexture2 *iface,
TRACE
(
"Returning handle %08x.
\n
"
,
surface
->
Handle
);
*
handle
=
surface
->
Handle
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -4690,7 +4720,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
return
D3D_OK
;
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(((
src_surface
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_MIPMAP
)
!=
(
dst_surface
->
surface_desc
.
ddsCaps
.
dwCaps
&
DDSCAPS_MIPMAP
))
...
...
@@ -4726,7 +4756,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
if
(
!
dst_pal
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_NOPALETTEATTACHED
;
}
IDirectDrawPalette_GetEntries
(
src_pal
,
0
,
0
,
256
,
palent
);
...
...
@@ -4741,7 +4771,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
{
/* Should also check for same pixel format, u1.lPitch, ... */
ERR
(
"Error in surface sizes.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3DERR_TEXTURE_LOAD_FAILED
;
}
else
...
...
@@ -4763,7 +4793,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
if
(
FAILED
(
hr
))
{
ERR
(
"Failed to lock source surface, hr %#x.
\n
"
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3DERR_TEXTURE_LOAD_FAILED
;
}
...
...
@@ -4772,7 +4802,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
{
ERR
(
"Failed to lock destination surface, hr %#x.
\n
"
,
hr
);
wined3d_surface_unmap
(
src_surface
->
wined3d_surface
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3DERR_TEXTURE_LOAD_FAILED
;
}
...
...
@@ -4803,7 +4833,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
}
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
dlls/ddraw/vertexbuffer.c
View file @
a2963b66
...
...
@@ -150,11 +150,11 @@ static ULONG WINAPI IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *if
struct
wined3d_buffer
*
curVB
=
NULL
;
UINT
offset
,
stride
;
EnterCriticalSection
(
&
ddraw_cs
);
/* D3D7 Vertex buffers don't stay bound in the device, they are passed
* as a parameter to drawPrimitiveVB. DrawPrimitiveVB sets them as the
* stream source in wined3d, and they should get unset there before
* they are destroyed. */
wined3d_mutex_lock
();
wined3d_device_get_stream_source
(
This
->
ddraw
->
wined3d_device
,
0
,
&
curVB
,
&
offset
,
&
stride
);
if
(
curVB
==
This
->
wineD3DVertexBuffer
)
...
...
@@ -164,7 +164,8 @@ static ULONG WINAPI IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *if
wined3d_vertex_declaration_decref
(
This
->
wineD3DVertexDeclaration
);
wined3d_buffer_decref
(
This
->
wineD3DVertexBuffer
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
HeapFree
(
GetProcessHeap
(),
0
,
This
);
return
0
;
...
...
@@ -223,7 +224,7 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *ifa
if
(
Flags
&
DDLOCK_NOOVERWRITE
)
wined3d_flags
|=
WINED3DLOCK_NOOVERWRITE
;
if
(
Flags
&
DDLOCK_DISCARDCONTENTS
)
wined3d_flags
|=
WINED3DLOCK_DISCARD
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
Size
)
{
/* Get the size, for returning it, and for locking */
...
...
@@ -233,7 +234,8 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *ifa
}
hr
=
wined3d_buffer_map
(
This
->
wineD3DVertexBuffer
,
0
,
0
,
(
BYTE
**
)
Data
,
wined3d_flags
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -262,9 +264,9 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *i
TRACE
(
"iface %p.
\n
"
,
iface
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_buffer_unmap
(
This
->
wineD3DVertexBuffer
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -326,7 +328,8 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexB
*/
if
(
!
(
VertexOp
&
D3DVOP_TRANSFORM
)
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
/* WineD3D doesn't know d3d7 vertex operation, it uses
* render states instead. Set the render states according to
* the vertex ops
...
...
@@ -345,7 +348,9 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexB
/* Restore the states if needed */
if
(
doClip
!=
oldClip
)
wined3d_device_set_render_state
(
device_impl
->
wined3d_device
,
WINED3DRS_CLIPPING
,
oldClip
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -389,10 +394,10 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVer
if
(
!
Desc
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_resource
=
wined3d_buffer_get_resource
(
This
->
wineD3DVertexBuffer
);
wined3d_resource_get_desc
(
wined3d_resource
,
&
wined3d_desc
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
/* Now fill the Desc structure */
Desc
->
dwCaps
=
This
->
Caps
;
...
...
@@ -443,9 +448,9 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7
/* We could forward this call to WineD3D and take advantage
* of it once we use OpenGL vertex buffers
*/
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
This
->
Caps
|=
D3DVBCAPS_OPTIMIZED
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DD_OK
;
}
...
...
@@ -562,7 +567,7 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect
usage
=
desc
->
dwCaps
&
D3DVBCAPS_WRITEONLY
?
WINED3DUSAGE_WRITEONLY
:
0
;
usage
|=
WINED3DUSAGE_STATICDECL
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
hr
=
wined3d_buffer_create_vb
(
ddraw
->
wined3d_device
,
get_flexible_vertex_size
(
desc
->
dwFVF
)
*
desc
->
dwNumVertices
,
...
...
@@ -587,7 +592,7 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect
wined3d_vertex_declaration_incref
(
buffer
->
wineD3DVertexDeclaration
);
end:
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
if
(
hr
==
D3D_OK
)
*
vertex_buf
=
buffer
;
else
...
...
dlls/ddraw/viewport.c
View file @
a2963b66
...
...
@@ -245,7 +245,8 @@ IDirect3DViewportImpl_GetViewport(IDirect3DViewport3 *iface,
TRACE
(
"iface %p, data %p.
\n
"
,
iface
,
lpData
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
dwSize
=
lpData
->
dwSize
;
memset
(
lpData
,
0
,
dwSize
);
if
(
!
This
->
use_vp2
)
...
...
@@ -271,7 +272,8 @@ IDirect3DViewportImpl_GetViewport(IDirect3DViewport3 *iface,
TRACE
(
" returning D3DVIEWPORT :
\n
"
);
_dump_D3DVIEWPORT
(
lpData
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -304,7 +306,8 @@ IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface,
_dump_D3DVIEWPORT
(
lpData
);
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
This
->
use_vp2
=
0
;
memset
(
&
(
This
->
viewports
.
vp1
),
0
,
sizeof
(
This
->
viewports
.
vp1
));
memcpy
(
&
(
This
->
viewports
.
vp1
),
lpData
,
lpData
->
dwSize
);
...
...
@@ -324,7 +327,8 @@ IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface,
IDirect3DViewport3_Release
(
current_viewport
);
}
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
DD_OK
;
}
...
...
@@ -391,7 +395,7 @@ IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3 *iface,
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
wined3d_device_get_transform
(
This
->
active_device
->
wined3d_device
,
D3DTRANSFORMSTATE_VIEW
,
(
WINED3DMATRIX
*
)
&
view_mat
);
wined3d_device_get_transform
(
This
->
active_device
->
wined3d_device
,
...
...
@@ -476,7 +480,7 @@ IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3 *iface,
{
*
lpOffScreen
=
0
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
TRACE
(
"All done
\n
"
);
return
DD_OK
;
...
...
@@ -525,13 +529,13 @@ IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface,
TRACE
(
"iface %p, material %#x.
\n
"
,
iface
,
hMat
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
!
hMat
)
{
This
->
background
=
NULL
;
TRACE
(
"Setting background to NULL
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -539,7 +543,7 @@ IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface,
if
(
!
m
)
{
WARN
(
"Invalid material handle.
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -548,7 +552,8 @@ IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface,
m
->
mat
.
u
.
diffuse
.
u3
.
b
,
m
->
mat
.
u
.
diffuse
.
u4
.
a
);
This
->
background
=
m
;
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -574,7 +579,7 @@ IDirect3DViewportImpl_GetBackground(IDirect3DViewport3 *iface,
TRACE
(
"iface %p, material %p, valid %p.
\n
"
,
iface
,
lphMat
,
lpValid
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
lpValid
)
{
*
lpValid
=
This
->
background
!=
NULL
;
...
...
@@ -590,7 +595,7 @@ IDirect3DViewportImpl_GetBackground(IDirect3DViewport3 *iface,
*
lphMat
=
0
;
}
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -674,7 +679,8 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
}
d3d_device3
=
&
This
->
active_device
->
IDirect3DDevice3_iface
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
if
(
dwFlags
&
D3DCLEAR_TARGET
)
{
if
(
This
->
background
==
NULL
)
{
ERR
(
" Trying to clear the color buffer without background material !
\n
"
);
...
...
@@ -702,7 +708,8 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
IDirect3DViewport3_Release
(
current_viewport
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
@@ -730,10 +737,11 @@ static HRESULT WINAPI IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
TRACE
(
"iface %p, light %p.
\n
"
,
iface
,
lpDirect3DLight
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
if
(
This
->
num_lights
>=
8
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -758,7 +766,8 @@ static HRESULT WINAPI IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
if
(
This
->
active_device
)
light_activate
(
lpDirect3DLightImpl
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -783,12 +792,12 @@ static HRESULT WINAPI IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *ifac
TRACE
(
"iface %p, light %p.
\n
"
,
iface
,
lpDirect3DLight
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
if
(
l
->
active_viewport
!=
This
)
{
WARN
(
"Light %p active viewport is %p.
\n
"
,
l
,
l
->
active_viewport
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -799,7 +808,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *ifac
--
This
->
num_lights
;
This
->
map_lights
&=
~
(
1
<<
l
->
dwLightIndex
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3D_OK
;
}
...
...
@@ -831,7 +840,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
if
(
!
lplpDirect3DLight
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
switch
(
dwFlags
)
{
...
...
@@ -872,7 +881,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
hr
=
DDERR_INVALIDPARAMS
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
hr
;
}
...
...
@@ -906,7 +915,7 @@ IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface,
TRACE
(
"iface %p, data %p.
\n
"
,
iface
,
lpData
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
(
);
dwSize
=
lpData
->
dwSize
;
memset
(
lpData
,
0
,
dwSize
);
if
(
This
->
use_vp2
)
...
...
@@ -933,7 +942,8 @@ IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface,
_dump_D3DVIEWPORT2
(
lpData
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -964,7 +974,8 @@ IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface,
_dump_D3DVIEWPORT2
(
lpData
);
}
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
This
->
use_vp2
=
1
;
memset
(
&
(
This
->
viewports
.
vp2
),
0
,
sizeof
(
This
->
viewports
.
vp2
));
memcpy
(
&
(
This
->
viewports
.
vp2
),
lpData
,
lpData
->
dwSize
);
...
...
@@ -978,7 +989,8 @@ IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface,
IDirect3DViewport3_Release
(
current_viewport
);
}
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
D3D_OK
;
}
...
...
@@ -1064,10 +1076,11 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface,
TRACE
(
"iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, depth %.8e, stencil %u.
\n
"
,
iface
,
dwCount
,
lpRects
,
dwFlags
,
dwColor
,
dvZ
,
dwStencil
);
EnterCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_lock
();
if
(
This
->
active_device
==
NULL
)
{
ERR
(
" Trying to clear a viewport not attached to a device !
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
(
);
return
D3DERR_VIEWPORTHASNODEVICE
;
}
d3d_device3
=
&
This
->
active_device
->
IDirect3DDevice3_iface
;
...
...
@@ -1083,7 +1096,9 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface,
viewport_activate
(
vp
,
TRUE
);
IDirect3DViewport3_Release
(
current_viewport
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
wined3d_mutex_unlock
();
return
hr
;
}
...
...
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