Small spelling/punctuation fixes.
[wine/wine64.git] / dlls / d3d9 / pixelshader.c
blob1b0a98e5f470d57c1a3a3aaf78b692d04ad95589
1 /*
2 * IDirect3DPixelShader9 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"
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "wingdi.h"
30 #include "wine/debug.h"
32 #include "d3d9_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
36 /* IDirect3DPixelShader9 IUnknown parts follow: */
37 HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID riid, LPVOID* ppobj) {
38 ICOM_THIS(IDirect3DPixelShader9Impl,iface);
40 if (IsEqualGUID(riid, &IID_IUnknown)
41 || IsEqualGUID(riid, &IID_IDirect3DPixelShader9)) {
42 IDirect3DPixelShader9Impl_AddRef(iface);
43 *ppobj = This;
44 return D3D_OK;
47 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
48 return E_NOINTERFACE;
51 ULONG WINAPI IDirect3DPixelShader9Impl_AddRef(LPDIRECT3DPIXELSHADER9 iface) {
52 ICOM_THIS(IDirect3DPixelShader9Impl,iface);
53 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
54 return ++(This->ref);
57 ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface) {
58 ICOM_THIS(IDirect3DPixelShader9Impl,iface);
59 ULONG ref = --This->ref;
61 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
62 if (ref == 0) {
63 HeapFree(GetProcessHeap(), 0, This);
65 return ref;
68 /* IDirect3DPixelShader9 Interface follow: */
69 HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice) {
70 ICOM_THIS(IDirect3DPixelShader9Impl,iface);
71 TRACE("(%p) : returning %p\n", This, This->Device);
72 *ppDevice = (LPDIRECT3DDEVICE9) This->Device;
73 IDirect3DDevice9Impl_AddRef(*ppDevice);
74 return D3D_OK;
77 HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
78 ICOM_THIS(IDirect3DPixelShader9Impl,iface);
79 FIXME("(%p): stub\n", This);
80 return D3D_OK;
84 ICOM_VTABLE(IDirect3DPixelShader9) Direct3DPixelShader9_Vtbl =
86 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
87 IDirect3DPixelShader9Impl_QueryInterface,
88 IDirect3DPixelShader9Impl_AddRef,
89 IDirect3DPixelShader9Impl_Release,
90 IDirect3DPixelShader9Impl_GetDevice,
91 IDirect3DPixelShader9Impl_GetFunction
95 /* IDirect3DDevice9 IDirect3DPixelShader9 Methods follow: */
96 HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) {
97 ICOM_THIS(IDirect3DDevice9Impl,iface);
98 FIXME("(%p) : stub\n", This);
99 return D3D_OK;
102 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader) {
103 ICOM_THIS(IDirect3DDevice9Impl,iface);
105 This->UpdateStateBlock->PixelShader = pShader;
106 This->UpdateStateBlock->Changed.pixelShader = TRUE;
107 This->UpdateStateBlock->Set.pixelShader = TRUE;
109 /* Handle recording of state blocks */
110 if (This->isRecordingState) {
111 TRACE("Recording... not performing anything\n");
112 return D3D_OK;
115 * TODO: merge HAL shaders context switching from prototype
117 return D3D_OK;
120 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9** ppShader) {
121 ICOM_THIS(IDirect3DDevice9Impl,iface);
122 TRACE("(%p) : GetPixelShader returning %p\n", This, This->StateBlock->PixelShader);
123 *ppShader = This->StateBlock->PixelShader;
124 IDirect3DPixelShader9Impl_AddRef(*ppShader);
125 return D3D_OK;
128 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
129 ICOM_THIS(IDirect3DDevice9Impl,iface);
131 if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) {
132 ERR("(%p) : SetPixelShaderConstant C[%u] invalid\n", This, Register);
133 return D3DERR_INVALIDCALL;
135 if (NULL == pConstantData) {
136 return D3DERR_INVALIDCALL;
138 if (Vector4fCount > 1) {
139 CONST FLOAT* f = pConstantData;
140 UINT i;
141 TRACE("(%p) : SetPixelShaderConstant C[%u..%u]=\n", This, Register, Register + Vector4fCount - 1);
142 for (i = 0; i < Vector4fCount; ++i) {
143 TRACE("{%f, %f, %f, %f}\n", f[0], f[1], f[2], f[3]);
144 f += 4;
146 } else {
147 FLOAT* f = (FLOAT*) pConstantData;
148 TRACE("(%p) : SetPixelShaderConstant, C[%u]={%f, %f, %f, %f}\n", This, Register, f[0], f[1], f[2], f[3]);
150 This->UpdateStateBlock->Changed.pixelShaderConstant = TRUE;
151 memcpy(&This->UpdateStateBlock->pixelShaderConstantF[Register], pConstantData, Vector4fCount * 4 * sizeof(FLOAT));
152 return D3D_OK;
155 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
156 ICOM_THIS(IDirect3DDevice9Impl,iface);
158 TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4fCount);
159 if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) {
160 return D3DERR_INVALIDCALL;
162 if (NULL == pConstantData) {
163 return D3DERR_INVALIDCALL;
165 memcpy(pConstantData, &This->UpdateStateBlock->pixelShaderConstantF[Register], Vector4fCount * 4 * sizeof(FLOAT));
166 return D3D_OK;
169 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
170 ICOM_THIS(IDirect3DDevice9Impl,iface);
172 if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) {
173 ERR("(%p) : SetPixelShaderConstantI C[%u] invalid\n", This, Register);
174 return D3DERR_INVALIDCALL;
176 if (NULL == pConstantData) {
177 return D3DERR_INVALIDCALL;
179 if (Vector4iCount > 1) {
180 CONST int* f = pConstantData;
181 UINT i;
182 TRACE("(%p) : SetPixelShaderConstantI C[%u..%u]=\n", This, Register, Register + Vector4iCount - 1);
183 for (i = 0; i < Vector4iCount; ++i) {
184 TRACE("{%d, %d, %d, %d}\n", f[0], f[1], f[2], f[3]);
185 f += 4;
187 } else {
188 CONST int* f = pConstantData;
189 TRACE("(%p) : SetPixelShaderConstantI, C[%u]={%i, %i, %i, %i}\n", This, Register, f[0], f[1], f[2], f[3]);
191 This->UpdateStateBlock->Changed.pixelShaderConstant = TRUE;
192 memcpy(&This->UpdateStateBlock->pixelShaderConstantI[Register], pConstantData, Vector4iCount * 4 * sizeof(int));
193 return D3D_OK;
196 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
197 ICOM_THIS(IDirect3DDevice9Impl,iface);
199 TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4iCount);
200 if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) {
201 return D3DERR_INVALIDCALL;
203 if (NULL == pConstantData) {
204 return D3DERR_INVALIDCALL;
206 memcpy(pConstantData, &This->UpdateStateBlock->pixelShaderConstantI[Register], Vector4iCount * 4 * sizeof(FLOAT));
207 return D3D_OK;
210 HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
211 ICOM_THIS(IDirect3DDevice9Impl,iface);
212 UINT i;
214 if (Register + BoolCount > D3D_VSHADER_MAX_CONSTANTS) {
215 ERR("(%p) : SetPixelShaderConstantB C[%u] invalid\n", This, Register);
216 return D3DERR_INVALIDCALL;
218 if (NULL == pConstantData) {
219 return D3DERR_INVALIDCALL;
221 if (BoolCount > 1) {
222 CONST BOOL* f = pConstantData;
223 TRACE("(%p) : SetPixelShaderConstantB C[%u..%u]=\n", This, Register, Register + BoolCount - 1);
224 for (i = 0; i < BoolCount; ++i) {
225 TRACE("{%u}\n", f[i]);
227 } else {
228 CONST BOOL* f = pConstantData;
229 TRACE("(%p) : SetPixelShaderConstantB, C[%u]={%u}\n", This, Register, f[0]);
231 This->UpdateStateBlock->Changed.pixelShaderConstant = TRUE;
232 for (i = 0; i < BoolCount; ++i) {
233 This->UpdateStateBlock->pixelShaderConstantB[Register] = pConstantData[i];
235 return D3D_OK;
238 HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
239 ICOM_THIS(IDirect3DDevice9Impl,iface);
240 FIXME("(%p) : stub\n", This);
241 return D3D_OK;