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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
32 #include "wine/debug.h"
34 #include "d3d9_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader
);
38 /* IDirect3DVertexShader9 IUnknown parts follow: */
39 HRESULT WINAPI
IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface
, REFIID riid
, LPVOID
* ppobj
) {
40 ICOM_THIS(IDirect3DVertexShader9Impl
,iface
);
42 if (IsEqualGUID(riid
, &IID_IUnknown
)
43 || IsEqualGUID(riid
, &IID_IDirect3DVertexShader9
)) {
44 IDirect3DVertexShader9Impl_AddRef(iface
);
49 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
53 ULONG WINAPI
IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface
) {
54 ICOM_THIS(IDirect3DVertexShader9Impl
,iface
);
55 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
59 ULONG WINAPI
IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface
) {
60 ICOM_THIS(IDirect3DVertexShader9Impl
,iface
);
61 ULONG ref
= --This
->ref
;
63 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
65 HeapFree(GetProcessHeap(), 0, This
);
70 /* IDirect3DVertexShader9 Interface follow: */
71 HRESULT WINAPI
IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface
, IDirect3DDevice9
** ppDevice
) {
72 ICOM_THIS(IDirect3DVertexShader9Impl
,iface
);
73 TRACE("(%p) : returning %p\n", This
, This
->Device
);
74 *ppDevice
= (LPDIRECT3DDEVICE9
) This
->Device
;
75 IDirect3DDevice9Impl_AddRef(*ppDevice
);
79 HRESULT WINAPI
IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface
, VOID
* pData
, UINT
* pSizeOfData
) {
80 ICOM_THIS(IDirect3DVertexShader9Impl
,iface
);
81 FIXME("(%p) : stub\n", This
);
86 ICOM_VTABLE(IDirect3DVertexShader9
) Direct3DVertexShader9_Vtbl
=
88 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
89 IDirect3DVertexShader9Impl_QueryInterface
,
90 IDirect3DVertexShader9Impl_AddRef
,
91 IDirect3DVertexShader9Impl_Release
,
92 IDirect3DVertexShader9Impl_GetDevice
,
93 IDirect3DVertexShader9Impl_GetFunction
97 /* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
98 HRESULT WINAPI
IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9 iface
, CONST DWORD
* pFunction
, IDirect3DVertexShader9
** ppShader
) {
99 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
100 FIXME("(%p) : stub\n", This
);
104 HRESULT WINAPI
IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface
, IDirect3DVertexShader9
* pShader
) {
105 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
107 This
->UpdateStateBlock
->VertexShader
= pShader
;
108 This
->UpdateStateBlock
->Changed
.vertexShader
= TRUE
;
109 This
->UpdateStateBlock
->Set
.vertexShader
= TRUE
;
111 /* Handle recording of state blocks */
112 if (This
->isRecordingState
) {
113 TRACE("Recording... not performing anything\n");
117 * TODO: merge HAL shaders context switching from prototype
122 HRESULT WINAPI
IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface
, IDirect3DVertexShader9
** ppShader
) {
123 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
124 TRACE("(%p) : GetVertexShader returning %p\n", This
, This
->StateBlock
->VertexShader
);
125 *ppShader
= This
->StateBlock
->VertexShader
;
126 IDirect3DVertexShader9Impl_AddRef(*ppShader
);
130 HRESULT WINAPI
IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface
, UINT Register
, CONST
float* pConstantData
, UINT Vector4fCount
) {
131 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
133 if (Register
+ Vector4fCount
> D3D_VSHADER_MAX_CONSTANTS
) {
134 ERR("(%p) : SetVertexShaderConstant C[%u] invalid\n", This
, Register
);
135 return D3DERR_INVALIDCALL
;
137 if (NULL
== pConstantData
) {
138 return D3DERR_INVALIDCALL
;
140 if (Vector4fCount
> 1) {
141 CONST FLOAT
* f
= pConstantData
;
143 TRACE("(%p) : SetVertexShaderConstant C[%u..%u]=\n", This
, Register
, Register
+ Vector4fCount
- 1);
144 for (i
= 0; i
< Vector4fCount
; ++i
) {
145 TRACE("{%f, %f, %f, %f}\n", f
[0], f
[1], f
[2], f
[3]);
149 FLOAT
* f
= (FLOAT
*) pConstantData
;
150 TRACE("(%p) : SetVertexShaderConstant, C[%u]={%f, %f, %f, %f}\n", This
, Register
, f
[0], f
[1], f
[2], f
[3]);
152 This
->UpdateStateBlock
->Changed
.vertexShaderConstant
= TRUE
;
153 memcpy(&This
->UpdateStateBlock
->vertexShaderConstantF
[Register
], pConstantData
, Vector4fCount
* 4 * sizeof(FLOAT
));
157 HRESULT WINAPI
IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface
, UINT Register
, float* pConstantData
, UINT Vector4fCount
) {
158 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
160 TRACE("(%p) : C[%u] count=%u\n", This
, Register
, Vector4fCount
);
161 if (Register
+ Vector4fCount
> D3D_VSHADER_MAX_CONSTANTS
) {
162 return D3DERR_INVALIDCALL
;
164 if (NULL
== pConstantData
) {
165 return D3DERR_INVALIDCALL
;
167 memcpy(pConstantData
, &This
->UpdateStateBlock
->vertexShaderConstantF
[Register
], Vector4fCount
* 4 * sizeof(FLOAT
));
171 HRESULT WINAPI
IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface
, UINT Register
, CONST
int* pConstantData
, UINT Vector4iCount
) {
172 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
174 if (Register
+ Vector4iCount
> D3D_VSHADER_MAX_CONSTANTS
) {
175 ERR("(%p) : SetVertexShaderConstantI C[%u] invalid\n", This
, Register
);
176 return D3DERR_INVALIDCALL
;
178 if (NULL
== pConstantData
) {
179 return D3DERR_INVALIDCALL
;
181 if (Vector4iCount
> 1) {
182 CONST
int* f
= pConstantData
;
184 TRACE("(%p) : SetVertexShaderConstantI C[%u..%u]=\n", This
, Register
, Register
+ Vector4iCount
- 1);
185 for (i
= 0; i
< Vector4iCount
; ++i
) {
186 TRACE("{%d, %d, %d, %d}\n", f
[0], f
[1], f
[2], f
[3]);
190 CONST
int* f
= pConstantData
;
191 TRACE("(%p) : SetVertexShaderConstantI, C[%u]={%i, %i, %i, %i}\n", This
, Register
, f
[0], f
[1], f
[2], f
[3]);
193 This
->UpdateStateBlock
->Changed
.vertexShaderConstant
= TRUE
;
194 memcpy(&This
->UpdateStateBlock
->vertexShaderConstantI
[Register
], pConstantData
, Vector4iCount
* 4 * sizeof(int));
198 HRESULT WINAPI
IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface
, UINT Register
, int* pConstantData
, UINT Vector4iCount
) {
199 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
201 TRACE("(%p) : C[%u] count=%u\n", This
, Register
, Vector4iCount
);
202 if (Register
+ Vector4iCount
> D3D_VSHADER_MAX_CONSTANTS
) {
203 return D3DERR_INVALIDCALL
;
205 if (NULL
== pConstantData
) {
206 return D3DERR_INVALIDCALL
;
208 memcpy(pConstantData
, &This
->UpdateStateBlock
->vertexShaderConstantI
[Register
], Vector4iCount
* 4 * sizeof(FLOAT
));
212 HRESULT WINAPI
IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface
, UINT Register
, CONST BOOL
* pConstantData
, UINT BoolCount
) {
213 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
216 if (Register
+ BoolCount
> D3D_VSHADER_MAX_CONSTANTS
) {
217 ERR("(%p) : SetVertexShaderConstantB C[%u] invalid\n", This
, Register
);
218 return D3DERR_INVALIDCALL
;
220 if (NULL
== pConstantData
) {
221 return D3DERR_INVALIDCALL
;
224 CONST BOOL
* f
= pConstantData
;
225 TRACE("(%p) : SetVertexShaderConstantB C[%u..%u]=\n", This
, Register
, Register
+ BoolCount
- 1);
226 for (i
= 0; i
< BoolCount
; ++i
) {
227 TRACE("{%u}\n", f
[i
]);
230 CONST BOOL
* f
= pConstantData
;
231 TRACE("(%p) : SetVertexShaderConstantB, C[%u]={%u}\n", This
, Register
, f
[0]);
233 This
->UpdateStateBlock
->Changed
.vertexShaderConstant
= TRUE
;
234 for (i
= 0; i
< BoolCount
; ++i
) {
235 This
->UpdateStateBlock
->vertexShaderConstantB
[Register
] = pConstantData
[i
];
240 HRESULT WINAPI
IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface
, UINT Register
, BOOL
* pConstantData
, UINT BoolCount
) {
241 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
242 FIXME("(%p) : stub\n", This
);