Correct typo in format string.
[wine/multimedia.git] / dlls / d3d9 / vertexshader.c
blob17345050d19f363c7ccdd1b6c54ee5e81d359df5
1 /*
2 * IDirect3DVertexShader9 implementation
4 * Copyright 2002-2003 Jason Edmeades
5 * Raphael Junqueira
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
22 #include "config.h"
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
27 /* IDirect3DVertexShader9 IUnknown parts follow: */
28 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 IDirect3DVertexShader9Impl_AddRef(iface);
34 *ppobj = This;
35 return D3D_OK;
38 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
39 return E_NOINTERFACE;
42 ULONG WINAPI IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface) {
43 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
44 ULONG ref = InterlockedIncrement(&This->ref);
46 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
48 return ref;
51 ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface) {
52 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
53 ULONG ref = InterlockedDecrement(&This->ref);
55 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
57 if (ref == 0) {
58 HeapFree(GetProcessHeap(), 0, This);
60 return ref;
63 /* IDirect3DVertexShader9 Interface follow: */
64 HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADER9 iface, IDirect3DDevice9** ppDevice) {
65 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
66 TRACE("(%p) : returning %p\n", This, This->Device);
67 *ppDevice = (LPDIRECT3DDEVICE9) This->Device;
68 IDirect3DDevice9Impl_AddRef(*ppDevice);
69 return D3D_OK;
72 HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
73 IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
74 FIXME("(%p) : stub\n", This);
75 return D3D_OK;
79 const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl =
81 IDirect3DVertexShader9Impl_QueryInterface,
82 IDirect3DVertexShader9Impl_AddRef,
83 IDirect3DVertexShader9Impl_Release,
84 IDirect3DVertexShader9Impl_GetDevice,
85 IDirect3DVertexShader9Impl_GetFunction
89 /* IDirect3DDevice9 IDirect3DVertexShader9 Methods follow: */
90 HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader) {
91 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
92 FIXME("(%p) : stub\n", This);
93 return D3D_OK;
96 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9* pShader) {
97 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
98 /* TODO: implement stateblocks */
100 FIXME("Disabled %p\n", This);
101 /* Handle recording of state blocks */
103 * TODO: merge HAL shaders context switching from prototype
105 return D3D_OK;
108 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9** ppShader) {
109 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
110 TRACE("(%p) : GetVertexShader returning\n", This);
111 *ppShader = NULL;
112 return D3D_OK;
115 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
116 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
117 #if 0
118 if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) {
119 ERR("(%p) : SetVertexShaderConstant C[%u] invalid\n", This, Register);
120 return D3DERR_INVALIDCALL;
122 if (NULL == pConstantData) {
123 return D3DERR_INVALIDCALL;
125 if (Vector4fCount > 1) {
126 CONST FLOAT* f = pConstantData;
127 UINT i;
128 TRACE("(%p) : SetVertexShaderConstant C[%u..%u]=\n", This, Register, Register + Vector4fCount - 1);
129 for (i = 0; i < Vector4fCount; ++i) {
130 TRACE("{%f, %f, %f, %f}\n", f[0], f[1], f[2], f[3]);
131 f += 4;
133 } else {
134 const FLOAT* f = (const FLOAT*) pConstantData;
135 TRACE("(%p) : SetVertexShaderConstant, C[%u]={%f, %f, %f, %f}\n", This, Register, f[0], f[1], f[2], f[3]);
137 This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE;
138 memcpy(&This->UpdateStateBlock->vertexShaderConstantF[Register], pConstantData, Vector4fCount * 4 * sizeof(FLOAT));
139 #endif
140 FIXME("(%p) : stub\n", This);
141 return D3D_OK;
144 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
145 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
146 #if 0
147 TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4fCount);
148 if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) {
149 return D3DERR_INVALIDCALL;
151 if (NULL == pConstantData) {
152 return D3DERR_INVALIDCALL;
154 memcpy(pConstantData, &This->UpdateStateBlock->vertexShaderConstantF[Register], Vector4fCount * 4 * sizeof(FLOAT));
155 #endif
156 FIXME("(%p) : stub\n", This);
157 return D3D_OK;
160 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
161 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
162 #if 0
163 if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) {
164 ERR("(%p) : SetVertexShaderConstantI C[%u] invalid\n", This, Register);
165 return D3DERR_INVALIDCALL;
167 if (NULL == pConstantData) {
168 return D3DERR_INVALIDCALL;
170 if (Vector4iCount > 1) {
171 CONST int* f = pConstantData;
172 UINT i;
173 TRACE("(%p) : SetVertexShaderConstantI C[%u..%u]=\n", This, Register, Register + Vector4iCount - 1);
174 for (i = 0; i < Vector4iCount; ++i) {
175 TRACE("{%d, %d, %d, %d}\n", f[0], f[1], f[2], f[3]);
176 f += 4;
178 } else {
179 CONST int* f = pConstantData;
180 TRACE("(%p) : SetVertexShaderConstantI, C[%u]={%i, %i, %i, %i}\n", This, Register, f[0], f[1], f[2], f[3]);
182 This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE;
183 memcpy(&This->UpdateStateBlock->vertexShaderConstantI[Register], pConstantData, Vector4iCount * 4 * sizeof(int));
184 #endif
185 FIXME("(%p) : stub\n", This);
186 return D3D_OK;
189 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
190 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
191 #if 0
192 TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4iCount);
193 if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) {
194 return D3DERR_INVALIDCALL;
196 if (NULL == pConstantData) {
197 return D3DERR_INVALIDCALL;
199 memcpy(pConstantData, &This->UpdateStateBlock->vertexShaderConstantI[Register], Vector4iCount * 4 * sizeof(FLOAT));
200 #endif
201 FIXME("(%p) : stub\n", This);
202 return D3D_OK;
205 HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
206 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
207 #if 0
208 UINT i;
210 if (Register + BoolCount > D3D_VSHADER_MAX_CONSTANTS) {
211 ERR("(%p) : SetVertexShaderConstantB C[%u] invalid\n", This, Register);
212 return D3DERR_INVALIDCALL;
214 if (NULL == pConstantData) {
215 return D3DERR_INVALIDCALL;
217 if (BoolCount > 1) {
218 CONST BOOL* f = pConstantData;
219 TRACE("(%p) : SetVertexShaderConstantB C[%u..%u]=\n", This, Register, Register + BoolCount - 1);
220 for (i = 0; i < BoolCount; ++i) {
221 TRACE("{%u}\n", f[i]);
223 } else {
224 CONST BOOL* f = pConstantData;
225 TRACE("(%p) : SetVertexShaderConstantB, C[%u]={%u}\n", This, Register, f[0]);
227 This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE;
228 for (i = 0; i < BoolCount; ++i) {
229 This->UpdateStateBlock->vertexShaderConstantB[Register] = pConstantData[i];
231 #endif
232 FIXME("(%p) : stub\n", This);
233 return D3D_OK;
236 HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
237 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
238 FIXME("(%p) : stub\n", This);
239 return D3D_OK;