Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
d5d7d4da
Commit
d5d7d4da
authored
Jun 03, 2007
by
Stefan Dösinger
Committed by
Alexandre Julliard
Jun 04, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Hold the lock in IDirect3DDevice methods.
parent
cd7ed61c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
357 additions
and
142 deletions
+357
-142
device.c
dlls/ddraw/device.c
+357
-142
No files found.
dlls/ddraw/device.c
View file @
d5d7d4da
...
...
@@ -286,6 +286,7 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
IParent
*
IndexBufferParent
;
DWORD
i
;
EnterCriticalSection
(
&
ddraw_cs
);
/* Free the index buffer. */
IWineD3DDevice_SetIndices
(
This
->
wineD3DDevice
,
NULL
,
...
...
@@ -400,6 +401,7 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
/* Now free the structure */
HeapFree
(
GetProcessHeap
(),
0
,
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
}
TRACE
(
"Done
\n
"
);
...
...
@@ -572,12 +574,14 @@ IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2 *iface,
IDirectDrawSurfaceImpl
*
surf2
=
ICOM_OBJECT
(
IDirectDrawSurfaceImpl
,
IDirect3DTexture2
,
Tex2
);
TRACE
(
"(%p)->(%p,%p)
\n
"
,
This
,
surf1
,
surf2
);
EnterCriticalSection
(
&
ddraw_cs
);
This
->
Handles
[
surf1
->
Handle
-
1
].
ptr
=
surf2
;
This
->
Handles
[
surf2
->
Handle
-
1
].
ptr
=
surf1
;
swap
=
surf2
->
Handle
;
surf2
->
Handle
=
surf1
->
Handle
;
surf1
->
Handle
=
swap
;
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -774,7 +778,9 @@ IDirect3DDeviceImpl_1_Execute(IDirect3DDevice *iface,
return
DDERR_INVALIDPARAMS
;
/* Execute... */
EnterCriticalSection
(
&
ddraw_cs
);
IDirect3DExecuteBufferImpl_Execute
(
Direct3DExecuteBufferImpl
,
This
,
Direct3DViewportImpl
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -809,8 +815,10 @@ IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3 *iface,
if
(
!
vp
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
vp
->
next
=
This
->
viewport_list
;
This
->
viewport_list
=
vp
;
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -863,6 +871,7 @@ IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3 *iface,
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
vp
);
EnterCriticalSection
(
&
ddraw_cs
);
cur_viewport
=
This
->
viewport_list
;
while
(
cur_viewport
!=
NULL
)
{
...
...
@@ -871,12 +880,14 @@ IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3 *iface,
if
(
prev_viewport
==
NULL
)
This
->
viewport_list
=
cur_viewport
->
next
;
else
prev_viewport
->
next
=
cur_viewport
->
next
;
/* TODO : add desactivate of the viewport and all associated lights... */
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
prev_viewport
=
cur_viewport
;
cur_viewport
=
cur_viewport
->
next
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -939,6 +950,7 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
}
EnterCriticalSection
(
&
ddraw_cs
);
switch
(
Flags
)
{
case
D3DNEXT_NEXT
:
...
...
@@ -963,10 +975,12 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
break
;
default:
*
lplpDirect3DViewport3
=
NULL
;
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
*
lplpDirect3DViewport3
=
ICOM_INTERFACE
(
res
,
IDirect3DViewport3
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1134,6 +1148,7 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
if
(
!
Callback
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
for
(
i
=
0
;
i
<
sizeof
(
FormatList
)
/
sizeof
(
WINED3DFORMAT
);
i
++
)
{
hr
=
IWineD3D_CheckDeviceFormat
(
This
->
ddraw
->
wineD3D
,
...
...
@@ -1156,6 +1171,7 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
if
(
hr
!=
DDENUMRET_OK
)
{
TRACE
(
"Format enumeration cancelled by application
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
}
...
...
@@ -1183,11 +1199,13 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
if
(
hr
!=
DDENUMRET_OK
)
{
TRACE
(
"Format enumeration cancelled by application
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
}
}
TRACE
(
"End of enumeration
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1244,6 +1262,7 @@ IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
if
(
!
Callback
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
for
(
i
=
0
;
i
<
sizeof
(
FormatList
)
/
sizeof
(
WINED3DFORMAT
);
i
++
)
{
hr
=
IWineD3D_CheckDeviceFormat
(
This
->
ddraw
->
wineD3D
,
...
...
@@ -1269,11 +1288,13 @@ IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
if
(
hr
!=
DDENUMRET_OK
)
{
TRACE
(
"Format enumeration cancelled by application
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
}
}
TRACE
(
"End of enumeration
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1321,17 +1342,21 @@ IDirect3DDeviceImpl_1_CreateMatrix(IDirect3DDevice *iface, D3DMATRIXHANDLE *D3DM
ERR
(
"Out of memory when allocating a D3DMATRIX
\n
"
);
return
DDERR_OUTOFMEMORY
;
}
EnterCriticalSection
(
&
ddraw_cs
);
*
D3DMatHandle
=
IDirect3DDeviceImpl_CreateHandle
(
This
);
if
(
!
(
*
D3DMatHandle
))
{
ERR
(
"Failed to create a matrix handle
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
Matrix
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_OUTOFMEMORY
;
}
This
->
Handles
[(
DWORD
)
*
D3DMatHandle
-
1
].
ptr
=
Matrix
;
This
->
Handles
[(
DWORD
)
*
D3DMatHandle
-
1
].
type
=
DDrawHandle_Matrix
;
TRACE
(
" returning matrix handle %d
\n
"
,
*
D3DMatHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1364,14 +1389,17 @@ IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice *iface,
if
(
(
!
D3DMatHandle
)
||
(
!
D3DMatrix
)
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
if
(
D3DMatHandle
>
This
->
numHandles
)
{
ERR
(
"Handle %d out of range
\n
"
,
D3DMatHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
else
if
(
This
->
Handles
[
D3DMatHandle
-
1
].
type
!=
DDrawHandle_Matrix
)
{
ERR
(
"Handle %d is not a matrix handle
\n
"
,
D3DMatHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -1380,6 +1408,7 @@ IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice *iface,
*
((
D3DMATRIX
*
)
This
->
Handles
[
D3DMatHandle
-
1
].
ptr
)
=
*
D3DMatrix
;
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1412,20 +1441,24 @@ IDirect3DDeviceImpl_1_GetMatrix(IDirect3DDevice *iface,
if
(
!
D3DMatHandle
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
if
(
D3DMatHandle
>
This
->
numHandles
)
{
ERR
(
"Handle %d out of range
\n
"
,
D3DMatHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
else
if
(
This
->
Handles
[
D3DMatHandle
-
1
].
type
!=
DDrawHandle_Matrix
)
{
ERR
(
"Handle %d is not a matrix handle
\n
"
,
D3DMatHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
/* The handle is simply a pointer to a D3DMATRIX structure */
*
D3DMatrix
=
*
((
D3DMATRIX
*
)
This
->
Handles
[
D3DMatHandle
-
1
].
ptr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1454,14 +1487,17 @@ IDirect3DDeviceImpl_1_DeleteMatrix(IDirect3DDevice *iface,
if
(
!
D3DMatHandle
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
if
(
D3DMatHandle
>
This
->
numHandles
)
{
ERR
(
"Handle %d out of range
\n
"
,
D3DMatHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
else
if
(
This
->
Handles
[
D3DMatHandle
-
1
].
type
!=
DDrawHandle_Matrix
)
{
ERR
(
"Handle %d is not a matrix handle
\n
"
,
D3DMatHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
...
...
@@ -1469,6 +1505,7 @@ IDirect3DDeviceImpl_1_DeleteMatrix(IDirect3DDevice *iface,
This
->
Handles
[
D3DMatHandle
-
1
].
ptr
=
NULL
;
This
->
Handles
[
D3DMatHandle
-
1
].
type
=
DDrawHandle_Unknown
;
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1493,7 +1530,9 @@ IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7 *iface)
HRESULT
hr
;
TRACE
(
"(%p): Relay
\n
"
,
This
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_BeginScene
(
This
->
wineD3DDevice
);
LeaveCriticalSection
(
&
ddraw_cs
);
if
(
hr
==
WINED3D_OK
)
return
D3D_OK
;
else
return
D3DERR_SCENE_IN_SCENE
;
/* TODO: Other possible causes of failure */
}
...
...
@@ -1543,7 +1582,9 @@ IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7 *iface)
HRESULT
hr
;
TRACE
(
"(%p): Relay
\n
"
,
This
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_EndScene
(
This
->
wineD3DDevice
);
LeaveCriticalSection
(
&
ddraw_cs
);
if
(
hr
==
WINED3D_OK
)
return
D3D_OK
;
else
return
D3DERR_SCENE_NOT_IN_SCENE
;
}
...
...
@@ -1681,9 +1722,13 @@ IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3 *iface,
IDirect3DViewportImpl
*
vp
=
ICOM_OBJECT
(
IDirect3DViewportImpl
,
IDirect3DViewport3
,
Direct3DViewport3
);
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
Direct3DViewport3
);
EnterCriticalSection
(
&
ddraw_cs
);
/* Do nothing if the specified viewport is the same as the current one */
if
(
This
->
current_viewport
==
vp
)
return
D3D_OK
;
{
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
/* Should check if the viewport was added or not */
...
...
@@ -1702,6 +1747,7 @@ IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3 *iface,
This
->
current_viewport
->
active_device
=
This
;
This
->
current_viewport
->
activate
(
This
->
current_viewport
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1741,6 +1787,7 @@ IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3 *iface,
if
(
!
Direct3DViewport3
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
*
Direct3DViewport3
=
ICOM_INTERFACE
(
This
->
current_viewport
,
IDirect3DViewport3
);
/* AddRef the returned viewport */
...
...
@@ -1748,6 +1795,7 @@ IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3 *iface,
TRACE
(
" returning interface %p
\n
"
,
*
Direct3DViewport3
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1793,6 +1841,7 @@ IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7 *iface,
HRESULT
hr
;
TRACE
(
"(%p)->(%p,%08x): Relay
\n
"
,
This
,
NewTarget
,
Flags
);
EnterCriticalSection
(
&
ddraw_cs
);
/* Flags: Not used */
hr
=
IWineD3DDevice_SetRenderTarget
(
This
->
wineD3DDevice
,
...
...
@@ -1800,12 +1849,14 @@ IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7 *iface,
Target
?
Target
->
WineD3DSurface
:
NULL
);
if
(
hr
!=
D3D_OK
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
IDirectDrawSurface7_AddRef
(
NewTarget
);
IDirectDrawSurface7_Release
(
ICOM_INTERFACE
(
This
->
target
,
IDirectDrawSurface7
));
This
->
target
=
Target
;
IDirect3DDeviceImpl_UpdateDepthStencil
(
This
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1862,9 +1913,11 @@ IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7 *iface,
if
(
!
RenderTarget
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
*
RenderTarget
=
ICOM_INTERFACE
(
This
->
target
,
IDirectDrawSurface7
);
IDirectDrawSurface7_AddRef
(
*
RenderTarget
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -1923,11 +1976,13 @@ IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3 *iface,
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice3
,
iface
);
TRACE
(
"(%p)->(%d,%d,%08x)
\n
"
,
This
,
PrimitiveType
,
VertexTypeDesc
,
Flags
);
EnterCriticalSection
(
&
ddraw_cs
);
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
);
return
D3D_OK
;
}
...
...
@@ -2048,6 +2103,7 @@ IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3 *iface,
if
(
!
Vertex
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
if
((
This
->
nb_vertices
+
1
)
*
This
->
vertex_size
>
This
->
buffer_size
)
{
BYTE
*
old_buffer
;
...
...
@@ -2063,6 +2119,7 @@ IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3 *iface,
CopyMemory
(
This
->
vertex_buffer
+
This
->
nb_vertices
++
*
This
->
vertex_size
,
Vertex
,
This
->
vertex_size
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -2178,6 +2235,7 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
if
(
!
Value
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
switch
(
RenderStateType
)
{
case
D3DRENDERSTATE_TEXTUREHANDLE
:
...
...
@@ -2210,7 +2268,7 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
}
IWineD3DBaseTexture_Release
(
tex
);
}
return
hr
;
break
;
}
case
D3DRENDERSTATE_TEXTUREMAG
:
...
...
@@ -2233,7 +2291,7 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
ERR
(
"Unhandled texture mag %d !
\n
"
,
tex_mag
);
*
Value
=
0
;
}
return
hr
;
break
;
}
case
D3DRENDERSTATE_TEXTUREMIN
:
...
...
@@ -2256,25 +2314,29 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
ERR
(
"Unhandled texture mag %d !
\n
"
,
tex_min
);
*
Value
=
0
;
}
return
hr
;
break
;
}
case
D3DRENDERSTATE_TEXTUREADDRESS
:
case
D3DRENDERSTATE_TEXTUREADDRESSU
:
return
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_ADDRESSU
,
Value
);
hr
=
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_ADDRESSU
,
Value
);
break
;
case
D3DRENDERSTATE_TEXTUREADDRESSV
:
return
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_ADDRESSV
,
Value
);
hr
=
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_ADDRESSV
,
Value
);
break
;
default:
/* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
return
IWineD3DDevice_GetRenderState
(
This
->
wineD3DDevice
,
RenderStateType
,
Value
);
hr
=
IWineD3DDevice_GetRenderState
(
This
->
wineD3DDevice
,
RenderStateType
,
Value
);
}
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -2324,8 +2386,10 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
DWORD
Value
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%d): Relay
\n
"
,
This
,
RenderStateType
,
Value
);
EnterCriticalSection
(
&
ddraw_cs
);
/* Some render states need special care */
switch
(
RenderStateType
)
{
...
...
@@ -2333,27 +2397,31 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
{
if
(
Value
==
0
)
{
return
IWineD3DDevice_SetTexture
(
This
->
wineD3DDevice
,
0
,
NULL
);
hr
=
IWineD3DDevice_SetTexture
(
This
->
wineD3DDevice
,
0
,
NULL
);
break
;
}
if
(
Value
>
This
->
numHandles
)
{
FIXME
(
"Specified handle %d out of range
\n
"
,
Value
);
return
DDERR_INVALIDPARAMS
;
hr
=
DDERR_INVALIDPARAMS
;
break
;
}
if
(
This
->
Handles
[
Value
-
1
].
type
!=
DDrawHandle_Texture
)
{
FIXME
(
"Handle %d isn't a texture handle
\n
"
,
Value
);
return
DDERR_INVALIDPARAMS
;
hr
=
DDERR_INVALIDPARAMS
;
break
;
}
else
{
IDirectDrawSurfaceImpl
*
surf
=
(
IDirectDrawSurfaceImpl
*
)
This
->
Handles
[
Value
-
1
].
ptr
;
return
IWineD3DDevice_SetTexture
(
This
->
wineD3DDevice
,
0
,
surf
->
wineD3DTexture
);
hr
=
IWineD3DDevice_SetTexture
(
This
->
wineD3DDevice
,
0
,
surf
->
wineD3DTexture
);
break
;
}
}
...
...
@@ -2375,9 +2443,10 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
ERR
(
"Unhandled texture mag %d !
\n
"
,
Value
);
}
return
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_MAGFILTER
,
tex_mag
);
hr
=
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_MAGFILTER
,
tex_mag
);
break
;
}
case
D3DRENDERSTATE_TEXTUREMIN
:
...
...
@@ -2417,9 +2486,10 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_MIPFILTER
,
tex_mip
);
return
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_MINFILTER
,
tex_min
);
hr
=
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_MINFILTER
,
tex_min
);
break
;
}
case
D3DRENDERSTATE_TEXTUREADDRESS
:
...
...
@@ -2428,13 +2498,15 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
Value
);
/* Drop through */
case
D3DRENDERSTATE_TEXTUREADDRESSU
:
return
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_ADDRESSU
,
Value
);
hr
=
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_ADDRESSU
,
Value
);
break
;
case
D3DRENDERSTATE_TEXTUREADDRESSV
:
return
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_ADDRESSV
,
Value
);
hr
=
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
0
,
WINED3DSAMP_ADDRESSV
,
Value
);
break
;
case
D3DRENDERSTATE_TEXTUREMAPBLEND
:
{
...
...
@@ -2478,7 +2550,7 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
default:
ERR
(
"Unhandled texture environment %d !
\n
"
,
Value
);
}
return
D3D_OK
;
hr
=
D3D_OK
;
break
;
}
...
...
@@ -2486,10 +2558,13 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
/* FIXME: Unhandled: D3DRENDERSTATE_STIPPLEPATTERN00 - 31 */
return
IWineD3DDevice_SetRenderState
(
This
->
wineD3DDevice
,
RenderStateType
,
Value
);
hr
=
IWineD3DDevice_SetRenderState
(
This
->
wineD3DDevice
,
RenderStateType
,
Value
);
break
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -2540,6 +2615,7 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
DWORD
Value
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice3
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%08x)
\n
"
,
This
,
LightStateType
,
Value
);
...
...
@@ -2549,6 +2625,7 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
if
(
LightStateType
==
D3DLIGHTSTATE_MATERIAL
/* 1 */
)
{
IDirect3DMaterialImpl
*
mat
;
...
...
@@ -2557,11 +2634,13 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
else
if
(
Value
>
This
->
numHandles
)
{
ERR
(
"Material handle out of range(%d)
\n
"
,
Value
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
else
if
(
This
->
Handles
[
Value
-
1
].
type
!=
DDrawHandle_Material
)
{
ERR
(
"Invalid handle %d
\n
"
,
Value
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
else
...
...
@@ -2593,6 +2672,7 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
break
;
default:
ERR
(
"Unknown color model!
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
}
...
...
@@ -2621,14 +2701,18 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
break
;
default:
ERR
(
"Unknown D3DLIGHTSTATETYPE %d.
\n
"
,
LightStateType
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
return
IDirect3DDevice7_SetRenderState
(
ICOM_INTERFACE
(
This
,
IDirect3DDevice7
),
rs
,
Value
);
hr
=
IDirect3DDevice7_SetRenderState
(
ICOM_INTERFACE
(
This
,
IDirect3DDevice7
),
rs
,
Value
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -2668,6 +2752,7 @@ IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3 *iface,
DWORD
*
Value
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice3
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%p)
\n
"
,
This
,
LightStateType
,
Value
);
...
...
@@ -2680,6 +2765,7 @@ IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3 *iface,
if
(
!
Value
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
if
(
LightStateType
==
D3DLIGHTSTATE_MATERIAL
/* 1 */
)
{
*
Value
=
This
->
material
;
...
...
@@ -2713,14 +2799,18 @@ IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3 *iface,
break
;
default:
ERR
(
"Unknown D3DLIGHTSTATETYPE %d.
\n
"
,
LightStateType
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDPARAMS
;
}
return
IDirect3DDevice7_GetRenderState
(
ICOM_INTERFACE
(
This
,
IDirect3DDevice7
),
rs
,
Value
);
hr
=
IDirect3DDevice7_GetRenderState
(
ICOM_INTERFACE
(
This
,
IDirect3DDevice7
),
rs
,
Value
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -2764,11 +2854,9 @@ IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7 *iface,
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
D3DTRANSFORMSTATETYPE
type
=
TransformStateType
;
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%p): Relay
\n
"
,
This
,
TransformStateType
,
Matrix
);
if
(
!
Matrix
)
return
DDERR_INVALIDPARAMS
;
switch
(
TransformStateType
)
{
case
D3DTRANSFORMSTATE_WORLD
:
type
=
WINED3DTS_WORLDMATRIX
(
0
);
break
;
...
...
@@ -2778,10 +2866,16 @@ IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7 *iface,
default:
type
=
TransformStateType
;
}
if
(
!
Matrix
)
return
DDERR_INVALIDPARAMS
;
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
return
IWineD3DDevice_SetTransform
(
This
->
wineD3DDevice
,
type
,
(
WINED3DMATRIX
*
)
Matrix
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_SetTransform
(
This
->
wineD3DDevice
,
type
,
(
WINED3DMATRIX
*
)
Matrix
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -2832,11 +2926,9 @@ IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7 *iface,
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
D3DTRANSFORMSTATETYPE
type
=
TransformStateType
;
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%p): Relay
\n
"
,
This
,
TransformStateType
,
Matrix
);
if
(
!
Matrix
)
return
DDERR_INVALIDPARAMS
;
switch
(
TransformStateType
)
{
case
D3DTRANSFORMSTATE_WORLD
:
type
=
WINED3DTS_WORLDMATRIX
(
0
);
break
;
...
...
@@ -2846,8 +2938,14 @@ IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7 *iface,
default:
type
=
TransformStateType
;
}
if
(
!
Matrix
)
return
DDERR_INVALIDPARAMS
;
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
return
IWineD3DDevice_GetTransform
(
This
->
wineD3DDevice
,
type
,
(
WINED3DMATRIX
*
)
Matrix
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_GetTransform
(
This
->
wineD3DDevice
,
type
,
(
WINED3DMATRIX
*
)
Matrix
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -2898,6 +2996,7 @@ IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7 *iface,
D3DMATRIX
*
D3DMatrix
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
HRESULT
hr
;
D3DTRANSFORMSTATETYPE
type
;
TRACE
(
"(%p)->(%08x,%p): Relay
\n
"
,
This
,
TransformStateType
,
D3DMatrix
);
...
...
@@ -2911,9 +3010,12 @@ IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7 *iface,
}
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
return
IWineD3DDevice_MultiplyTransform
(
This
->
wineD3DDevice
,
type
,
(
WINED3DMATRIX
*
)
D3DMatrix
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_MultiplyTransform
(
This
->
wineD3DDevice
,
type
,
(
WINED3DMATRIX
*
)
D3DMatrix
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -3004,23 +3106,31 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
PrimitiveCount
=
VertexCount
-
2
;
break
;
default:
return
DDERR_INVALIDPARAMS
;
default:
return
DDERR_INVALIDPARAMS
;
}
/* Get the stride */
stride
=
get_flexible_vertex_size
(
VertexType
);
/* Set the FVF */
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_SetVertexDeclaration
(
This
->
wineD3DDevice
,
IDirectDrawImpl_FindDecl
(
This
->
ddraw
,
VertexType
));
if
(
hr
!=
D3D_OK
)
return
hr
;
if
(
hr
!=
D3D_OK
)
{
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
/* This method translates to the user pointer draw of WineD3D */
return
IWineD3DDevice_DrawPrimitiveUP
(
This
->
wineD3DDevice
,
PrimitiveType
,
PrimitiveCount
,
Vertices
,
stride
);
hr
=
IWineD3DDevice_DrawPrimitiveUP
(
This
->
wineD3DDevice
,
PrimitiveType
,
PrimitiveCount
,
Vertices
,
stride
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -3109,6 +3219,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
UINT
PrimitiveCount
=
0
;
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): Relay!
\n
"
,
This
,
PrimitiveType
,
VertexType
,
Vertices
,
VertexCount
,
Indices
,
IndexCount
,
Flags
);
/* Get the primitive number */
switch
(
PrimitiveType
)
{
...
...
@@ -3136,27 +3247,32 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
PrimitiveCount
=
IndexCount
-
2
;
break
;
default:
return
DDERR_INVALIDPARAMS
;
default:
return
DDERR_INVALIDPARAMS
;
}
/* Set the D3DDevice's FVF */
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_SetVertexDeclaration
(
This
->
wineD3DDevice
,
IDirectDrawImpl_FindDecl
(
This
->
ddraw
,
VertexType
));
if
(
FAILED
(
hr
))
{
ERR
(
" (%p) Setting the FVF failed, hr = %x!
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
return
IWineD3DDevice_DrawIndexedPrimitiveUP
(
This
->
wineD3DDevice
,
PrimitiveType
,
0
/* MinVertexIndex */
,
VertexCount
/* UINT NumVertexIndex */
,
PrimitiveCount
,
Indices
,
WINED3DFMT_INDEX16
,
Vertices
,
get_flexible_vertex_size
(
VertexType
));
hr
=
IWineD3DDevice_DrawIndexedPrimitiveUP
(
This
->
wineD3DDevice
,
PrimitiveType
,
0
/* MinVertexIndex */
,
VertexCount
/* UINT NumVertexIndex */
,
PrimitiveCount
,
Indices
,
WINED3DFMT_INDEX16
,
Vertices
,
get_flexible_vertex_size
(
VertexType
));
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -3342,6 +3458,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
WineDirect3DVertexStridedData
WineD3DStrided
;
int
i
;
UINT
PrimitiveCount
;
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%08x,%p,%08x,%08x): stub!
\n
"
,
This
,
PrimitiveType
,
VertexType
,
D3DDrawPrimStrideData
,
VertexCount
,
Flags
);
...
...
@@ -3432,10 +3549,13 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
}
/* WineD3D doesn't need the FVF here */
return
IWineD3DDevice_DrawPrimitiveStrided
(
This
->
wineD3DDevice
,
PrimitiveType
,
PrimitiveCount
,
&
WineD3DStrided
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_DrawPrimitiveStrided
(
This
->
wineD3DDevice
,
PrimitiveType
,
PrimitiveCount
,
&
WineD3DStrided
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -3584,15 +3704,18 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
PrimitiveCount
=
NumVertices
-
2
;
break
;
default:
return
DDERR_INVALIDPARAMS
;
default:
return
DDERR_INVALIDPARAMS
;
}
/* Get the FVF of the vertex buffer, and its stride */
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DVertexBuffer_GetDesc
(
vb
->
wineD3DVertexBuffer
,
&
Desc
);
if
(
hr
!=
D3D_OK
)
{
ERR
(
"(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
stride
=
get_flexible_vertex_size
(
Desc
.
FVF
);
...
...
@@ -3602,6 +3725,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
if
(
FAILED
(
hr
))
{
ERR
(
" (%p) Setting the FVF failed, hr = %x!
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
...
...
@@ -3614,14 +3738,17 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
if
(
hr
!=
D3D_OK
)
{
ERR
(
"(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
/* Now draw the primitives */
return
IWineD3DDevice_DrawPrimitive
(
This
->
wineD3DDevice
,
PrimitiveType
,
StartVertex
,
PrimitiveCount
);
hr
=
IWineD3DDevice_DrawPrimitive
(
This
->
wineD3DDevice
,
PrimitiveType
,
StartVertex
,
PrimitiveCount
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -3719,12 +3846,14 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
default:
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
/* Get the FVF of the vertex buffer, and its stride */
hr
=
IWineD3DVertexBuffer_GetDesc
(
vb
->
wineD3DVertexBuffer
,
&
Desc
);
if
(
hr
!=
D3D_OK
)
{
ERR
(
"(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
stride
=
get_flexible_vertex_size
(
Desc
.
FVF
);
...
...
@@ -3735,6 +3864,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
if
(
FAILED
(
hr
))
{
ERR
(
" (%p) Setting the FVF failed, hr = %x!
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
...
...
@@ -3753,6 +3883,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
if
(
hr
!=
D3D_OK
)
{
ERR
(
"(%p) IWineD3DIndexBuffer::Lock failed with hr = %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
memcpy
(
LockedIndices
,
Indices
,
IndexCount
*
sizeof
(
WORD
));
...
...
@@ -3760,6 +3891,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
if
(
hr
!=
D3D_OK
)
{
ERR
(
"(%p) IWineD3DIndexBuffer::Unlock failed with hr = %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
...
...
@@ -3777,6 +3909,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
if
(
hr
!=
D3D_OK
)
{
ERR
(
"(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x
\n
"
,
This
,
hr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
...
...
@@ -3788,7 +3921,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
0
/* StartIndex */
,
PrimitiveCount
);
return
D3D_OK
;
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -3930,18 +4064,22 @@ IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_GetTexture
(
This
->
wineD3DDevice
,
Stage
,
(
IWineD3DBaseTexture
**
)
&
Surf
);
if
(
(
hr
!=
D3D_OK
)
||
(
!
Surf
)
)
{
*
Texture
=
NULL
;
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
/* GetParent AddRef()s, which is perfectly OK.
* We have passed the IDirectDrawSurface7 interface to WineD3D, so that's OK too.
*/
return
IWineD3DBaseTexture_GetParent
(
Surf
,
(
IUnknown
**
)
Texture
);
hr
=
IWineD3DBaseTexture_GetParent
(
Surf
,
(
IUnknown
**
)
Texture
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -3988,12 +4126,16 @@ IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7 *iface,
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
IDirectDrawSurfaceImpl
*
surf
=
ICOM_OBJECT
(
IDirectDrawSurfaceImpl
,
IDirectDrawSurface7
,
Texture
);
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%p): Relay!
\n
"
,
This
,
Stage
,
surf
);
/* Texture may be NULL here */
return
IWineD3DDevice_SetTexture
(
This
->
wineD3DDevice
,
Stage
,
surf
?
surf
->
wineD3DTexture
:
NULL
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_SetTexture
(
This
->
wineD3DDevice
,
Stage
,
surf
?
surf
->
wineD3DTexture
:
NULL
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -4034,17 +4176,18 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
DWORD
*
State
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%08x,%p): Relay!
\n
"
,
This
,
Stage
,
TexStageStateType
,
State
);
if
(
!
State
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
switch
(
TexStageStateType
)
{
/* Mipfilter is a sampler state with different values */
case
D3DTSS_MIPFILTER
:
{
HRESULT
hr
;
WINED3DTEXTUREFILTERTYPE
value
;
hr
=
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
...
...
@@ -4060,19 +4203,20 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
ERR
(
"Unexpected mipfilter value %d
\n
"
,
value
);
*
State
=
D3DTFP_NONE
;
}
return
hr
;
break
;
}
/* Minfilter is a sampler state too, equal values */
case
D3DTSS_MINFILTER
:
return
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_MINFILTER
,
State
);
hr
=
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_MINFILTER
,
State
);
break
;
/* Magfilter has slightly different values */
case
D3DTSS_MAGFILTER
:
{
HRESULT
hr
;
WINED3DTEXTUREFILTERTYPE
wined3dfilter
;
hr
=
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
...
...
@@ -4089,26 +4233,31 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
ERR
(
"Unexpected wined3d mag filter value %d
\n
"
,
wined3dfilter
);
*
State
=
D3DTFG_POINT
;
}
return
hr
;
break
;
}
case
D3DTSS_ADDRESS
:
case
D3DTSS_ADDRESSU
:
return
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_ADDRESSU
,
State
);
hr
=
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_ADDRESSU
,
State
);
break
;
case
D3DTSS_ADDRESSV
:
return
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_ADDRESSV
,
State
);
hr
=
IWineD3DDevice_GetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_ADDRESSV
,
State
);
break
;
default:
return
IWineD3DDevice_GetTextureStageState
(
This
->
wineD3DDevice
,
Stage
,
TexStageStateType
,
State
);
hr
=
IWineD3DDevice_GetTextureStageState
(
This
->
wineD3DDevice
,
Stage
,
TexStageStateType
,
State
);
break
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -4150,7 +4299,10 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
DWORD
State
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%08x,%08x): Relay!
\n
"
,
This
,
Stage
,
TexStageStateType
,
State
);
EnterCriticalSection
(
&
ddraw_cs
);
switch
(
TexStageStateType
)
{
/* Mipfilter is a sampler state with different values */
...
...
@@ -4167,18 +4319,21 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
ERR
(
"Unexpected mipfilter value %d
\n
"
,
State
);
value
=
WINED3DTEXF_NONE
;
}
return
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_MIPFILTER
,
value
);
hr
=
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_MIPFILTER
,
value
);
break
;
}
/* Minfilter is a sampler state too, equal values */
case
D3DTSS_MINFILTER
:
return
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_MINFILTER
,
State
);
hr
=
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_MINFILTER
,
State
);
break
;
/* Magfilter has slightly different values */
case
D3DTSS_MAGFILTER
:
{
...
...
@@ -4194,10 +4349,11 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
ERR
(
"Unexpected d3d7 mag filter type %d
\n
"
,
State
);
wined3dfilter
=
WINED3DTEXF_POINT
;
}
return
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_MAGFILTER
,
wined3dfilter
);
hr
=
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_MAGFILTER
,
wined3dfilter
);
break
;
}
case
D3DTSS_ADDRESS
:
...
...
@@ -4207,22 +4363,28 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
State
);
/* Drop through */
case
D3DTSS_ADDRESSU
:
return
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_ADDRESSU
,
State
);
hr
=
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_ADDRESSU
,
State
);
break
;
case
D3DTSS_ADDRESSV
:
return
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_ADDRESSV
,
State
);
default:
hr
=
IWineD3DDevice_SetSamplerState
(
This
->
wineD3DDevice
,
Stage
,
WINED3DSAMP_ADDRESSV
,
State
);
break
;
return
IWineD3DDevice_SetTextureStageState
(
This
->
wineD3DDevice
,
Stage
,
TexStageStateType
,
State
);
default:
hr
=
IWineD3DDevice_SetTextureStageState
(
This
->
wineD3DDevice
,
Stage
,
TexStageStateType
,
State
);
break
;
}
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -4262,9 +4424,13 @@ IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7 *iface,
DWORD
*
NumPasses
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%p): Relay
\n
"
,
This
,
NumPasses
);
return
IWineD3DDevice_ValidateDevice
(
This
->
wineD3DDevice
,
NumPasses
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_ValidateDevice
(
This
->
wineD3DDevice
,
NumPasses
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -4308,10 +4474,14 @@ IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7 *iface,
DWORD
Stencil
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%p,%08x,%08x,%f,%08x): Relay
\n
"
,
This
,
Count
,
Rects
,
Flags
,
(
DWORD
)
Color
,
Z
,
Stencil
);
/* Note; D3DRECT is compatible with WINED3DRECT */
return
IWineD3DDevice_Clear
(
This
->
wineD3DDevice
,
Count
,
(
WINED3DRECT
*
)
Rects
,
Flags
,
Color
,
Z
,
Stencil
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_Clear
(
This
->
wineD3DDevice
,
Count
,
(
WINED3DRECT
*
)
Rects
,
Flags
,
Color
,
Z
,
Stencil
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
/*****************************************************************************
...
...
@@ -4336,14 +4506,18 @@ IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7 *iface,
D3DVIEWPORT7
*
Data
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%p) Relay!
\n
"
,
This
,
Data
);
if
(
!
Data
)
return
DDERR_INVALIDPARAMS
;
/* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
return
IWineD3DDevice_SetViewport
(
This
->
wineD3DDevice
,
(
WINED3DVIEWPORT
*
)
Data
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_SetViewport
(
This
->
wineD3DDevice
,
(
WINED3DVIEWPORT
*
)
Data
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
/*****************************************************************************
...
...
@@ -4374,9 +4548,11 @@ IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
/* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_GetViewport
(
This
->
wineD3DDevice
,
(
WINED3DVIEWPORT
*
)
Data
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4405,9 +4581,10 @@ IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7 *iface,
TRACE
(
"(%p)->(%p): Relay!
\n
"
,
This
,
Mat
);
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_SetMaterial
(
This
->
wineD3DDevice
,
(
WINED3DMATERIAL
*
)
Mat
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4435,10 +4612,11 @@ IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7 *iface,
HRESULT
hr
;
TRACE
(
"(%p)->(%p): Relay!
\n
"
,
This
,
Mat
);
EnterCriticalSection
(
&
ddraw_cs
);
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
hr
=
IWineD3DDevice_GetMaterial
(
This
->
wineD3DDevice
,
(
WINED3DMATERIAL
*
)
Mat
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4467,11 +4645,12 @@ IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7 *iface,
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%p): Relay!
\n
"
,
This
,
LightIndex
,
Light
);
EnterCriticalSection
(
&
ddraw_cs
);
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
hr
=
IWineD3DDevice_SetLight
(
This
->
wineD3DDevice
,
LightIndex
,
(
WINED3DLIGHT
*
)
Light
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4498,12 +4677,14 @@ IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7 *iface,
HRESULT
rc
;
TRACE
(
"(%p)->(%08x,%p): Relay!
\n
"
,
This
,
LightIndex
,
Light
);
EnterCriticalSection
(
&
ddraw_cs
);
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
rc
=
IWineD3DDevice_GetLight
(
This
->
wineD3DDevice
,
LightIndex
,
(
WINED3DLIGHT
*
)
Light
);
/* Translate the result. WineD3D returns other values than D3D7 */
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
rc
);
}
...
...
@@ -4526,7 +4707,9 @@ IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7 *iface)
HRESULT
hr
;
TRACE
(
"(%p)->(): Relay!
\n
"
,
This
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_BeginStateBlock
(
This
->
wineD3DDevice
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4561,15 +4744,18 @@ IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
*
BlockHandle
=
IDirect3DDeviceImpl_CreateHandle
(
This
);
if
(
!*
BlockHandle
)
{
ERR
(
"Cannot get a handle number for the stateblock
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_OUTOFMEMORY
;
}
This
->
Handles
[
*
BlockHandle
-
1
].
type
=
DDrawHandle_StateBlock
;
hr
=
IWineD3DDevice_EndStateBlock
(
This
->
wineD3DDevice
,
(
IWineD3DStateBlock
**
)
&
This
->
Handles
[
*
BlockHandle
-
1
].
ptr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4602,7 +4788,9 @@ IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7 *iface,
if
(
!
Texture
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
IWineD3DSurface_PreLoad
(
surf
->
WineD3DSurface
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -4627,18 +4815,22 @@ IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7 *iface,
HRESULT
hr
;
TRACE
(
"(%p)->(%08x): Relay!
\n
"
,
This
,
BlockHandle
);
EnterCriticalSection
(
&
ddraw_cs
);
if
(
!
BlockHandle
||
BlockHandle
>
This
->
numHandles
)
{
WARN
(
"Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK
\n
"
,
BlockHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3DERR_INVALIDSTATEBLOCK
;
}
if
(
This
->
Handles
[
BlockHandle
-
1
].
type
!=
DDrawHandle_StateBlock
)
{
WARN
(
"Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK
\n
"
,
BlockHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3DERR_INVALIDSTATEBLOCK
;
}
hr
=
IWineD3DStateBlock_Apply
((
IWineD3DStateBlock
*
)
This
->
Handles
[
BlockHandle
-
1
].
ptr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4666,18 +4858,22 @@ IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7 *iface,
HRESULT
hr
;
TRACE
(
"(%p)->(%08x): Relay!
\n
"
,
This
,
BlockHandle
);
EnterCriticalSection
(
&
ddraw_cs
);
if
(
BlockHandle
==
0
||
BlockHandle
>
This
->
numHandles
)
{
WARN
(
"Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK
\n
"
,
BlockHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3DERR_INVALIDSTATEBLOCK
;
}
if
(
This
->
Handles
[
BlockHandle
-
1
].
type
!=
DDrawHandle_StateBlock
)
{
WARN
(
"Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK
\n
"
,
BlockHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3DERR_INVALIDSTATEBLOCK
;
}
hr
=
IWineD3DStateBlock_Capture
((
IWineD3DStateBlock
*
)
This
->
Handles
[
BlockHandle
-
1
].
ptr
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4704,14 +4900,17 @@ IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
ULONG
ref
;
TRACE
(
"(%p)->(%08x): Relay!
\n
"
,
This
,
BlockHandle
);
EnterCriticalSection
(
&
ddraw_cs
);
if
(
BlockHandle
==
0
||
BlockHandle
>
This
->
numHandles
)
{
WARN
(
"Out of range handle %d, returning D3DERR_INVALIDSTATEBLOCK
\n
"
,
BlockHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3DERR_INVALIDSTATEBLOCK
;
}
if
(
This
->
Handles
[
BlockHandle
-
1
].
type
!=
DDrawHandle_StateBlock
)
{
WARN
(
"Handle %d is not a stateblock, returning D3DERR_INVALIDSTATEBLOCK
\n
"
,
BlockHandle
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3DERR_INVALIDSTATEBLOCK
;
}
...
...
@@ -4723,6 +4922,7 @@ IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
This
->
Handles
[
BlockHandle
-
1
].
ptr
=
NULL
;
This
->
Handles
[
BlockHandle
-
1
].
type
=
DDrawHandle_Unknown
;
LeaveCriticalSection
(
&
ddraw_cs
);
return
D3D_OK
;
}
...
...
@@ -4757,10 +4957,12 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
*
BlockHandle
=
IDirect3DDeviceImpl_CreateHandle
(
This
);
if
(
!*
BlockHandle
)
{
ERR
(
"Cannot get a handle number for the stateblock
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_OUTOFMEMORY
;
}
This
->
Handles
[
*
BlockHandle
-
1
].
type
=
DDrawHandle_StateBlock
;
...
...
@@ -4770,6 +4972,7 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
Type
,
(
IWineD3DStateBlock
**
)
&
This
->
Handles
[
*
BlockHandle
-
1
].
ptr
,
NULL
/* Parent, hope that works */
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4841,7 +5044,9 @@ IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7 *iface,
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%d): Relay!
\n
"
,
This
,
LightIndex
,
Enable
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_SetLightEnable
(
This
->
wineD3DDevice
,
LightIndex
,
Enable
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4874,7 +5079,9 @@ IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7 *iface,
if
(
!
Enable
)
return
DDERR_INVALIDPARAMS
;
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_GetLightEnable
(
This
->
wineD3DDevice
,
LightIndex
,
Enable
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr_ddraw_from_wined3d
(
hr
);
}
...
...
@@ -4901,12 +5108,16 @@ IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7 *iface,
D3DVALUE
*
PlaneEquation
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%08x,%p): Relay!
\n
"
,
This
,
Index
,
PlaneEquation
);
if
(
!
PlaneEquation
)
return
DDERR_INVALIDPARAMS
;
return
IWineD3DDevice_SetClipPlane
(
This
->
wineD3DDevice
,
Index
,
PlaneEquation
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_SetClipPlane
(
This
->
wineD3DDevice
,
Index
,
PlaneEquation
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
hr
;
}
/*****************************************************************************
...
...
@@ -4930,12 +5141,16 @@ IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7 *iface,
D3DVALUE
*
PlaneEquation
)
{
ICOM_THIS_FROM
(
IDirect3DDeviceImpl
,
IDirect3DDevice7
,
iface
);
HRESULT
hr
;
TRACE
(
"(%p)->(%d,%p): Relay!
\n
"
,
This
,
Index
,
PlaneEquation
);
if
(
!
PlaneEquation
)
return
DDERR_INVALIDPARAMS
;
return
IWineD3DDevice_GetClipPlane
(
This
->
wineD3DDevice
,
Index
,
PlaneEquation
);
EnterCriticalSection
(
&
ddraw_cs
);
hr
=
IWineD3DDevice_GetClipPlane
(
This
->
wineD3DDevice
,
Index
,
PlaneEquation
);
LeaveCriticalSection
(
&
ddraw_cs
);
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