2 * IDirect3DVertexShader9 implementation
4 * Copyright 2002-2003 Jason Edmeades
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9
);
27 /* IDirect3DVertexShader9 IUnknown parts follow: */
28 static HRESULT WINAPI
IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface
, REFIID riid
, LPVOID
* ppobj
) {
29 IDirect3DVertexShader9Impl
*This
= (IDirect3DVertexShader9Impl
*)iface
;
31 if (IsEqualGUID(riid
, &IID_IUnknown
)
32 || IsEqualGUID(riid
, &IID_IDirect3DVertexShader9
)) {
33 IUnknown_AddRef(iface
);
38 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
43 static ULONG WINAPI
IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface
) {
44 IDirect3DVertexShader9Impl
*This
= (IDirect3DVertexShader9Impl
*)iface
;
45 ULONG ref
= InterlockedIncrement(&This
->ref
);
47 TRACE("(%p) : AddRef from %ld\n", This
, ref
- 1);
52 static ULONG WINAPI
IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface
) {
53 IDirect3DVertexShader9Impl
*This
= (IDirect3DVertexShader9Impl
*)iface
;
54 ULONG ref
= InterlockedDecrement(&This
->ref
);
56 TRACE("(%p) : ReleaseRef to %ld\n", This
, ref
);
59 IWineD3DVertexShader_Release(This
->wineD3DVertexShader
);
60 IUnknown_Release(This
->parentDevice
);
61 HeapFree(GetProcessHeap(), 0, This
);
66 /* IDirect3DVertexShader9 Interface follow: */
67 static HRESULT WINAPI
IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface
, IDirect3DDevice9
** ppDevice
) {
68 IDirect3DVertexShader9Impl
*This
= (IDirect3DVertexShader9Impl
*)iface
;
69 IWineD3DDevice
*myDevice
= NULL
;
71 TRACE("(%p) : Relay\n", This
);
73 if (D3D_OK
== (hr
= IWineD3DVertexShader_GetDevice(This
->wineD3DVertexShader
, &myDevice
) && myDevice
!= NULL
)) {
74 hr
= IWineD3DDevice_GetParent(myDevice
, (IUnknown
**)ppDevice
);
75 IWineD3DDevice_Release(myDevice
);
79 TRACE("(%p) returing (%p)", This
, *ppDevice
);
83 static HRESULT WINAPI
IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface
, VOID
* pData
, UINT
* pSizeOfData
) {
84 IDirect3DVertexShader9Impl
*This
= (IDirect3DVertexShader9Impl
*)iface
;
86 TRACE("(%p) : Relay\n", This
);
87 return IWineD3DVertexShader_GetFunction(This
->wineD3DVertexShader
, pData
, pSizeOfData
);
91 static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl
=
94 IDirect3DVertexShader9Impl_QueryInterface
,
95 IDirect3DVertexShader9Impl_AddRef
,
96 IDirect3DVertexShader9Impl_Release
,
97 /* IDirect3DVertexShader9 */
98 IDirect3DVertexShader9Impl_GetDevice
,
99 IDirect3DVertexShader9Impl_GetFunction
103 /* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
104 HRESULT WINAPI
IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9 iface
, CONST DWORD
* pFunction
, IDirect3DVertexShader9
** ppShader
) {
105 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
106 HRESULT hrc
= D3D_OK
;
107 IDirect3DVertexShader9Impl
*object
;
109 /* Setup a stub object for now */
110 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
111 TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This
, pFunction
, ppShader
);
112 if (NULL
== object
) {
113 FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
114 return D3DERR_OUTOFVIDEOMEMORY
;
118 object
->lpVtbl
= &Direct3DVertexShader9_Vtbl
;
119 hrc
= IWineD3DDevice_CreateVertexShader(This
->WineD3DDevice
, NULL
/* declaration */, pFunction
, &object
->wineD3DVertexShader
, (IUnknown
*)object
);
124 FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
125 HeapFree(GetProcessHeap(), 0, object
);
127 IUnknown_AddRef(iface
);
128 object
->parentDevice
= iface
;
129 *ppShader
= (IDirect3DVertexShader9
*)object
;
130 TRACE("(%p) : Created vertex shader %p\n", This
, object
);
133 TRACE("(%p) : returning %p\n", This
, *ppShader
);
137 HRESULT WINAPI
IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface
, IDirect3DVertexShader9
* pShader
) {
138 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
139 HRESULT hrc
= D3D_OK
;
141 TRACE("(%p) : Relay\n", This
);
142 hrc
= IWineD3DDevice_SetVertexShader(This
->WineD3DDevice
, pShader
==NULL
?NULL
:((IDirect3DVertexShader9Impl
*)pShader
)->wineD3DVertexShader
);
144 TRACE("(%p) : returning hr(%lu)\n", This
, hrc
);
148 HRESULT WINAPI
IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface
, IDirect3DVertexShader9
** ppShader
) {
149 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
150 IWineD3DVertexShader
*pShader
;
151 HRESULT hrc
= D3D_OK
;
153 TRACE("(%p) : Relay device@%p\n", This
, This
->WineD3DDevice
);
154 hrc
= IWineD3DDevice_GetVertexShader(This
->WineD3DDevice
, &pShader
);
155 if(hrc
== D3D_OK
&& pShader
!= NULL
){
156 hrc
= IWineD3DVertexShader_GetParent(pShader
, (IUnknown
**)ppShader
);
157 IWineD3DVertexShader_Release(pShader
);
159 WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %lu (device %p)\n", This
, hrc
, This
->WineD3DDevice
);
161 TRACE("(%p) : returning %p\n", This
, *ppShader
);
165 HRESULT WINAPI
IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface
, UINT Register
, CONST
float* pConstantData
, UINT Vector4fCount
) {
166 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
167 TRACE("(%p) : Relay\n", This
);
168 return IWineD3DDevice_SetVertexShaderConstantF(This
->WineD3DDevice
, Register
, pConstantData
, Vector4fCount
);
171 HRESULT WINAPI
IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface
, UINT Register
, float* pConstantData
, UINT Vector4fCount
) {
172 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
173 TRACE("(%p) : Relay\n", This
);
174 return IWineD3DDevice_GetVertexShaderConstantF(This
->WineD3DDevice
, Register
, pConstantData
, Vector4fCount
);
177 HRESULT WINAPI
IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface
, UINT Register
, CONST
int* pConstantData
, UINT Vector4iCount
) {
178 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
179 TRACE("(%p) : Relay\n", This
);
180 return IWineD3DDevice_SetVertexShaderConstantI(This
->WineD3DDevice
, Register
, pConstantData
, Vector4iCount
);
183 HRESULT WINAPI
IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface
, UINT Register
, int* pConstantData
, UINT Vector4iCount
) {
184 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
185 TRACE("(%p) : Relay\n", This
);
186 return IWineD3DDevice_GetVertexShaderConstantI(This
->WineD3DDevice
, Register
, pConstantData
, Vector4iCount
);
189 HRESULT WINAPI
IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface
, UINT Register
, CONST BOOL
* pConstantData
, UINT BoolCount
) {
190 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
191 TRACE("(%p) : Relay\n", This
);
192 return IWineD3DDevice_SetVertexShaderConstantB(This
->WineD3DDevice
, Register
, pConstantData
, BoolCount
);
195 HRESULT WINAPI
IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface
, UINT Register
, BOOL
* pConstantData
, UINT BoolCount
) {
196 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
197 TRACE("(%p) : Relay\n", This
);
198 return IWineD3DDevice_GetVertexShaderConstantB(This
->WineD3DDevice
, Register
, pConstantData
, BoolCount
);