d3dx9: Improve get_parameter_by_name().
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blob9de551758427b32fbaa7f85c291c152ba01b816b
1 /*
2 * Copyright 2010 Christian Costa
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
20 #include "wine/port.h"
21 #include "wine/debug.h"
22 #include "wine/unicode.h"
23 #include "windef.h"
24 #include "wingdi.h"
25 #include "d3dx9_36_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
29 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
30 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl;
31 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl;
33 struct d3dx_parameter
35 struct ID3DXBaseEffectImpl *base;
37 char *name;
38 char *semantic;
39 void *data;
40 D3DXPARAMETER_CLASS class;
41 D3DXPARAMETER_TYPE type;
42 UINT rows;
43 UINT columns;
44 UINT element_count;
45 UINT annotation_count;
46 UINT member_count;
47 DWORD flags;
48 UINT bytes;
50 D3DXHANDLE *annotation_handles;
51 D3DXHANDLE *member_handles;
54 struct d3dx_pass
56 struct ID3DXBaseEffectImpl *base;
58 char *name;
59 UINT state_count;
60 UINT annotation_count;
62 D3DXHANDLE *annotation_handles;
65 struct d3dx_technique
67 struct ID3DXBaseEffectImpl *base;
69 char *name;
70 UINT pass_count;
71 UINT annotation_count;
73 D3DXHANDLE *annotation_handles;
74 D3DXHANDLE *pass_handles;
77 struct ID3DXBaseEffectImpl
79 ID3DXBaseEffect ID3DXBaseEffect_iface;
80 LONG ref;
82 struct ID3DXEffectImpl *effect;
84 UINT parameter_count;
85 UINT technique_count;
86 UINT object_count;
88 D3DXHANDLE *parameter_handles;
89 D3DXHANDLE *technique_handles;
90 D3DXHANDLE *objects;
93 struct ID3DXEffectImpl
95 ID3DXEffect ID3DXEffect_iface;
96 LONG ref;
98 LPD3DXEFFECTSTATEMANAGER manager;
99 LPDIRECT3DDEVICE9 device;
100 LPD3DXEFFECTPOOL pool;
102 ID3DXBaseEffect *base_effect;
105 struct ID3DXEffectCompilerImpl
107 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
108 LONG ref;
110 ID3DXBaseEffect *base_effect;
113 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
114 struct d3dx_parameter *parameter, LPCSTR name);
115 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name);
117 static inline void read_dword(const char **ptr, DWORD *d)
119 memcpy(d, *ptr, sizeof(*d));
120 *ptr += sizeof(*d);
123 static void skip_dword_unknown(const char **ptr, unsigned int count)
125 unsigned int i;
126 DWORD d;
128 FIXME("Skipping %u unknown DWORDs:\n", count);
129 for (i = 0; i < count; ++i)
131 read_dword(ptr, &d);
132 FIXME("\t0x%08x\n", d);
136 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
138 return (struct d3dx_parameter *) handle;
141 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
143 return (struct d3dx_pass *) handle;
146 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
148 return (struct d3dx_technique *) handle;
151 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
153 return (D3DXHANDLE) parameter;
156 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
158 return (D3DXHANDLE) technique;
161 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
163 return (D3DXHANDLE) pass;
166 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
168 unsigned int i;
170 for (i = 0; i < base->technique_count; ++i)
172 if (base->technique_handles[i] == technique)
174 return get_technique_struct(technique);
178 return NULL;
181 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
183 unsigned int i, k;
185 for (i = 0; i < base->technique_count; ++i)
187 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
189 for (k = 0; k < technique->pass_count; ++k)
191 if (technique->pass_handles[k] == pass)
193 return get_pass_struct(pass);
198 return NULL;
201 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
203 unsigned int i, count;
204 struct d3dx_parameter *p;
206 for (i = 0; i < param->annotation_count; ++i)
208 if (param->annotation_handles[i] == parameter)
210 return get_parameter_struct(parameter);
213 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
214 if (p) return p;
217 if (param->element_count) count = param->element_count;
218 else count = param->member_count;
220 for (i = 0; i < count; ++i)
222 if (param->member_handles[i] == parameter)
224 return get_parameter_struct(parameter);
227 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
228 if (p) return p;
231 return NULL;
234 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
236 unsigned int i, k, m;
237 struct d3dx_parameter *p;
239 for (i = 0; i < base->parameter_count; ++i)
241 if (base->parameter_handles[i] == parameter)
243 return get_parameter_struct(parameter);
246 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
247 if (p) return p;
250 for (i = 0; i < base->technique_count; ++i)
252 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
254 for (k = 0; k < technique->pass_count; ++k)
256 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
258 for (m = 0; m < pass->annotation_count; ++m)
260 if (pass->annotation_handles[i] == parameter)
262 return get_parameter_struct(parameter);
265 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
266 if (p) return p;
270 for (k = 0; k < technique->annotation_count; ++k)
272 if (technique->annotation_handles[k] == parameter)
274 return get_parameter_struct(parameter);
277 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
278 if (p) return p;
282 return NULL;
285 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
287 unsigned int i;
288 struct d3dx_parameter *param = get_parameter_struct(handle);
290 TRACE("Free parameter %p, child %s\n", param, child ? "yes" : "no");
292 if (!param)
294 return;
297 if (param->annotation_handles)
299 for (i = 0; i < param->annotation_count; ++i)
301 free_parameter(param->annotation_handles[i], FALSE, FALSE);
303 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
306 if (param->member_handles)
308 unsigned int count;
310 if (param->element_count) count = param->element_count;
311 else count = param->member_count;
313 for (i = 0; i < count; ++i)
315 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
317 HeapFree(GetProcessHeap(), 0, param->member_handles);
320 if (param->class == D3DXPC_OBJECT && !param->element_count)
322 switch(param->type)
324 case D3DXPT_STRING:
325 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
326 break;
328 case D3DXPT_PIXELSHADER:
329 case D3DXPT_VERTEXSHADER:
330 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
331 break;
333 default:
334 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
335 break;
339 if (!child)
341 HeapFree(GetProcessHeap(), 0, param->data);
344 /* only the parent has to release name and semantic */
345 if (!element)
347 HeapFree(GetProcessHeap(), 0, param->name);
348 HeapFree(GetProcessHeap(), 0, param->semantic);
351 HeapFree(GetProcessHeap(), 0, param);
354 static void free_pass(D3DXHANDLE handle)
356 unsigned int i;
357 struct d3dx_pass *pass = get_pass_struct(handle);
359 TRACE("Free pass %p\n", pass);
361 if (!pass)
363 return;
366 if (pass->annotation_handles)
368 for (i = 0; i < pass->annotation_count; ++i)
370 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
372 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
375 HeapFree(GetProcessHeap(), 0, pass->name);
376 HeapFree(GetProcessHeap(), 0, pass);
379 static void free_technique(D3DXHANDLE handle)
381 unsigned int i;
382 struct d3dx_technique *technique = get_technique_struct(handle);
384 TRACE("Free technique %p\n", technique);
386 if (!technique)
388 return;
391 if (technique->annotation_handles)
393 for (i = 0; i < technique->annotation_count; ++i)
395 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
397 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
400 if (technique->pass_handles)
402 for (i = 0; i < technique->pass_count; ++i)
404 free_pass(technique->pass_handles[i]);
406 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
409 HeapFree(GetProcessHeap(), 0, technique->name);
410 HeapFree(GetProcessHeap(), 0, technique);
413 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
415 unsigned int i;
417 TRACE("Free base effect %p\n", base);
419 if (base->parameter_handles)
421 for (i = 0; i < base->parameter_count; ++i)
423 free_parameter(base->parameter_handles[i], FALSE, FALSE);
425 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
428 if (base->technique_handles)
430 for (i = 0; i < base->technique_count; ++i)
432 free_technique(base->technique_handles[i]);
434 HeapFree(GetProcessHeap(), 0, base->technique_handles);
438 static void free_effect(struct ID3DXEffectImpl *effect)
440 TRACE("Free effect %p\n", effect);
442 if (effect->base_effect)
444 effect->base_effect->lpVtbl->Release(effect->base_effect);
447 if (effect->pool)
449 effect->pool->lpVtbl->Release(effect->pool);
452 if (effect->manager)
454 IUnknown_Release(effect->manager);
457 IDirect3DDevice9_Release(effect->device);
460 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
462 TRACE("Free effect compiler %p\n", compiler);
464 if (compiler->base_effect)
466 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
470 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
472 INT i;
474 switch (type)
476 case D3DXPT_FLOAT:
477 i = *(FLOAT *)data;
478 break;
480 case D3DXPT_INT:
481 i = *(INT *)data;
482 break;
484 case D3DXPT_BOOL:
485 i = *(BOOL *)data;
486 break;
488 default:
489 i = 0;
490 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
491 break;
494 return i;
497 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
499 FLOAT f;
501 switch (type)
503 case D3DXPT_FLOAT:
504 f = *(FLOAT *)data;
505 break;
507 case D3DXPT_INT:
508 f = *(INT *)data;
509 break;
511 case D3DXPT_BOOL:
512 f = *(BOOL *)data;
513 break;
515 default:
516 f = 0.0f;
517 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
518 break;
521 return f;
524 static inline BOOL get_bool(void *data)
526 return (*(DWORD *)data) ? TRUE : FALSE;
529 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
531 UINT element;
532 struct d3dx_parameter *temp_parameter;
533 LPCSTR part;
535 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
537 if (!name || !*name) return parameter;
539 element = atoi(name);
540 part = strchr(name, ']') + 1;
542 if (parameter->element_count > element)
544 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
546 switch (*part++)
548 case '.':
549 return get_parameter_by_name(NULL, temp_parameter, part);
551 case '@':
552 return get_parameter_annotation_by_name(temp_parameter, part);
554 case '\0':
555 TRACE("Returning parameter %p\n", temp_parameter);
556 return temp_parameter;
558 default:
559 FIXME("Unhandled case \"%c\"\n", *--part);
560 break;
564 TRACE("Parameter not found\n");
565 return NULL;
568 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
570 UINT i, length;
571 struct d3dx_parameter *temp_parameter;
572 LPCSTR part;
574 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
576 if (!name || !*name) return parameter;
578 length = strcspn( name, "[.@" );
579 part = name + length;
581 for (i = 0; i < parameter->annotation_count; ++i)
583 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
585 if (!strcmp(temp_parameter->name, name))
587 TRACE("Returning parameter %p\n", temp_parameter);
588 return temp_parameter;
590 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
592 switch (*part++)
594 case '.':
595 return get_parameter_by_name(NULL, temp_parameter, part);
597 case '[':
598 return get_parameter_element_by_name(temp_parameter, part);
600 default:
601 FIXME("Unhandled case \"%c\"\n", *--part);
602 break;
607 TRACE("Parameter not found\n");
608 return NULL;
611 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
612 struct d3dx_parameter *parameter, LPCSTR name)
614 UINT i, count, length;
615 struct d3dx_parameter *temp_parameter;
616 D3DXHANDLE *handles;
617 LPCSTR part;
619 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
621 if (!name || !*name) return parameter;
623 if (!parameter)
625 count = base->parameter_count;
626 handles = base->parameter_handles;
628 else
630 count = parameter->member_count;
631 handles = parameter->member_handles;
634 length = strcspn( name, "[.@" );
635 part = name + length;
637 for (i = 0; i < count; i++)
639 temp_parameter = get_parameter_struct(handles[i]);
641 if (!strcmp(temp_parameter->name, name))
643 TRACE("Returning parameter %p\n", temp_parameter);
644 return temp_parameter;
646 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
648 switch (*part++)
650 case '.':
651 return get_parameter_by_name(NULL, temp_parameter, part);
653 case '@':
654 return get_parameter_annotation_by_name(temp_parameter, part);
656 case '[':
657 return get_parameter_element_by_name(temp_parameter, part);
659 default:
660 FIXME("Unhandled case \"%c\"\n", *--part);
661 break;
666 TRACE("Parameter not found\n");
667 return NULL;
670 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
672 return (0xfeff0000 | ((major) << 8) | (minor));
675 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
677 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
680 /*** IUnknown methods ***/
681 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
683 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
685 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
687 if (IsEqualGUID(riid, &IID_IUnknown) ||
688 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
690 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
691 *object = This;
692 return S_OK;
695 ERR("Interface %s not found\n", debugstr_guid(riid));
697 return E_NOINTERFACE;
700 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
702 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
704 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
706 return InterlockedIncrement(&This->ref);
709 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
711 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
712 ULONG ref = InterlockedDecrement(&This->ref);
714 TRACE("iface %p: Release from %u\n", iface, ref + 1);
716 if (!ref)
718 free_base_effect(This);
719 HeapFree(GetProcessHeap(), 0, This);
722 return ref;
725 /*** ID3DXBaseEffect methods ***/
726 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
728 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
730 FIXME("iface %p, desc %p partial stub\n", This, desc);
732 if (!desc)
734 WARN("Invalid argument specified.\n");
735 return D3DERR_INVALIDCALL;
738 /* Todo: add creator and function count */
739 desc->Creator = NULL;
740 desc->Functions = 0;
741 desc->Parameters = This->parameter_count;
742 desc->Techniques = This->technique_count;
744 return D3D_OK;
747 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
749 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
750 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
752 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
754 if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter));
756 if (!desc || !param)
758 WARN("Invalid argument specified.\n");
759 return D3DERR_INVALIDCALL;
762 desc->Name = param->name;
763 desc->Semantic = param->semantic;
764 desc->Class = param->class;
765 desc->Type = param->type;
766 desc->Rows = param->rows;
767 desc->Columns = param->columns;
768 desc->Elements = param->element_count;
769 desc->Annotations = param->annotation_count;
770 desc->StructMembers = param->member_count;
771 desc->Flags = param->flags;
772 desc->Bytes = param->bytes;
774 return D3D_OK;
777 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
779 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
780 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
782 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
784 if (!desc || !tech)
786 WARN("Invalid argument specified.\n");
787 return D3DERR_INVALIDCALL;
790 desc->Name = tech->name;
791 desc->Passes = tech->pass_count;
792 desc->Annotations = tech->annotation_count;
794 return D3D_OK;
797 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
799 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
800 struct d3dx_pass *p = is_valid_pass(This, pass);
802 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
804 if (!desc || !p)
806 WARN("Invalid argument specified.\n");
807 return D3DERR_INVALIDCALL;
810 desc->Name = p->name;
811 desc->Annotations = p->annotation_count;
813 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
814 desc->pVertexShaderFunction = NULL;
815 desc->pVertexShaderFunction = NULL;
817 return D3D_OK;
820 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
822 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
824 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
826 return E_NOTIMPL;
829 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
831 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
832 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
834 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
836 if (!param) param = get_parameter_by_name(This, NULL, parameter);
838 if (!parameter)
840 if (index < This->parameter_count)
842 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
843 return This->parameter_handles[index];
846 else
848 if (param && !param->element_count && index < param->member_count)
850 TRACE("Returning parameter %p\n", param->member_handles[index]);
851 return param->member_handles[index];
855 WARN("Invalid argument specified.\n");
857 return NULL;
860 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
862 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
863 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
864 D3DXHANDLE handle;
866 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
868 if (!param) param = get_parameter_by_name(This, NULL, parameter);
870 if (!name)
872 handle = get_parameter_handle(param);
873 TRACE("Returning parameter %p\n", handle);
874 return handle;
877 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
878 TRACE("Returning parameter %p\n", handle);
880 return handle;
883 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
885 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
886 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
887 struct d3dx_parameter *temp_param;
888 UINT i;
890 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
892 if (!param) param = get_parameter_by_name(This, NULL, parameter);
894 if (!parameter)
896 for (i = 0; i < This->parameter_count; ++i)
898 temp_param = get_parameter_struct(This->parameter_handles[i]);
900 if (!temp_param->semantic)
902 if (!semantic)
904 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
905 return This->parameter_handles[i];
907 continue;
910 if (!strcasecmp(temp_param->semantic, semantic))
912 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
913 return This->parameter_handles[i];
917 else if (param)
919 for (i = 0; i < param->member_count; ++i)
921 temp_param = get_parameter_struct(param->member_handles[i]);
923 if (!temp_param->semantic)
925 if (!semantic)
927 TRACE("Returning parameter %p\n", param->member_handles[i]);
928 return param->member_handles[i];
930 continue;
933 if (!strcasecmp(temp_param->semantic, semantic))
935 TRACE("Returning parameter %p\n", param->member_handles[i]);
936 return param->member_handles[i];
941 WARN("Invalid argument specified\n");
943 return NULL;
946 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
948 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
949 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
951 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
953 if (!param) param = get_parameter_by_name(This, NULL, parameter);
955 if (!param)
957 if (index < This->parameter_count)
959 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
960 return This->parameter_handles[index];
963 else
965 if (index < param->element_count)
967 TRACE("Returning parameter %p\n", param->member_handles[index]);
968 return param->member_handles[index];
972 WARN("Invalid argument specified\n");
974 return NULL;
977 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
979 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
981 TRACE("iface %p, index %u\n", This, index);
983 if (index >= This->technique_count)
985 WARN("Invalid argument specified.\n");
986 return NULL;
989 TRACE("Returning technique %p\n", This->technique_handles[index]);
991 return This->technique_handles[index];
994 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
996 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
997 unsigned int i;
999 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1001 if (!name)
1003 WARN("Invalid argument specified.\n");
1004 return NULL;
1007 for (i = 0; i < This->technique_count; ++i)
1009 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1011 if (!strcmp(tech->name, name))
1013 TRACE("Returning technique %p\n", This->technique_handles[i]);
1014 return This->technique_handles[i];
1018 WARN("Invalid argument specified.\n");
1020 return NULL;
1023 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1025 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1026 struct d3dx_technique *tech = is_valid_technique(This, technique);
1028 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1030 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1032 if (tech && index < tech->pass_count)
1034 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1035 return tech->pass_handles[index];
1038 WARN("Invalid argument specified.\n");
1040 return NULL;
1043 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1045 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1046 struct d3dx_technique *tech = is_valid_technique(This, technique);
1048 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1050 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1052 if (tech && name)
1054 unsigned int i;
1056 for (i = 0; i < tech->pass_count; ++i)
1058 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1060 if (!strcmp(pass->name, name))
1062 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1063 return tech->pass_handles[i];
1068 WARN("Invalid argument specified.\n");
1070 return NULL;
1073 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1075 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1077 FIXME("iface %p, index %u stub\n", This, index);
1079 return NULL;
1082 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1084 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1086 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1088 return NULL;
1091 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1093 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1094 struct d3dx_parameter *param = is_valid_parameter(This, object);
1095 struct d3dx_pass *pass = is_valid_pass(This, object);
1096 struct d3dx_technique *technique = is_valid_technique(This, object);
1097 UINT annotation_count = 0;
1098 D3DXHANDLE *annotation_handles = NULL;
1100 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1102 if (pass)
1104 annotation_count = pass->annotation_count;
1105 annotation_handles = pass->annotation_handles;
1107 else if (technique)
1109 annotation_count = technique->annotation_count;
1110 annotation_handles = technique->annotation_handles;
1112 else
1114 if (!param) param = get_parameter_by_name(This, NULL, object);
1116 if (param)
1118 annotation_count = param->annotation_count;
1119 annotation_handles = param->annotation_handles;
1122 /* Todo: add funcs */
1124 if (index < annotation_count)
1126 TRACE("Returning parameter %p\n", annotation_handles[index]);
1127 return annotation_handles[index];
1130 WARN("Invalid argument specified\n");
1132 return NULL;
1135 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1137 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1138 struct d3dx_parameter *param = is_valid_parameter(This, object);
1139 struct d3dx_pass *pass = is_valid_pass(This, object);
1140 struct d3dx_technique *technique = is_valid_technique(This, object);
1141 UINT annotation_count = 0, i;
1142 D3DXHANDLE *annotation_handles = NULL;
1144 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1146 if (!name)
1148 WARN("Invalid argument specified\n");
1149 return NULL;
1152 if (pass)
1154 annotation_count = pass->annotation_count;
1155 annotation_handles = pass->annotation_handles;
1157 else if (technique)
1159 annotation_count = technique->annotation_count;
1160 annotation_handles = technique->annotation_handles;
1162 else
1164 if (!param) param = get_parameter_by_name(This, NULL, object);
1166 if (param)
1168 annotation_count = param->annotation_count;
1169 annotation_handles = param->annotation_handles;
1172 /* Todo: add funcs */
1174 for (i = 0; i < annotation_count; i++)
1176 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1178 if (!strcmp(anno->name, name))
1180 TRACE("Returning parameter %p\n", anno);
1181 return get_parameter_handle(anno);
1185 WARN("Invalid argument specified\n");
1187 return NULL;
1190 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1192 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1194 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1196 return E_NOTIMPL;
1199 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1201 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1202 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1204 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1206 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1208 if (data && param && param->data && param->bytes <= bytes)
1210 if (param->type == D3DXPT_VERTEXSHADER || param->type == D3DXPT_PIXELSHADER)
1212 UINT i;
1214 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1216 IUnknown *unk = ((IUnknown **)param->data)[i];
1217 if (unk) IUnknown_AddRef(unk);
1218 ((IUnknown **)data)[i] = unk;
1221 else
1223 TRACE("Copy %u bytes\n", param->bytes);
1224 memcpy(data, param->data, param->bytes);
1226 return D3D_OK;
1229 WARN("Invalid argument specified\n");
1231 return D3DERR_INVALIDCALL;
1234 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1236 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1238 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1240 return E_NOTIMPL;
1243 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1245 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1246 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1248 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1250 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1252 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1254 *b = get_bool(param->data);
1255 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1256 return D3D_OK;
1259 WARN("Invalid argument specified\n");
1261 return D3DERR_INVALIDCALL;
1264 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1266 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1268 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1270 return E_NOTIMPL;
1273 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1275 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1277 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1279 return E_NOTIMPL;
1282 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1284 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1286 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1288 return E_NOTIMPL;
1291 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1293 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1294 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1296 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1298 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1300 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1302 *n = get_int(param->type, param->data);
1303 TRACE("Returning %i\n", *n);
1304 return D3D_OK;
1307 WARN("Invalid argument specified\n");
1309 return D3DERR_INVALIDCALL;
1312 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1314 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1316 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1318 return E_NOTIMPL;
1321 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1323 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1325 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1327 return E_NOTIMPL;
1330 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1332 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1334 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1336 return E_NOTIMPL;
1339 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1341 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1342 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1344 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1346 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1348 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1350 f = param->data;
1351 TRACE("Returning %f\n", *f);
1352 return D3D_OK;
1355 WARN("Invalid argument specified\n");
1357 return D3DERR_INVALIDCALL;
1360 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1362 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1364 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1366 return E_NOTIMPL;
1369 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1371 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1373 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1375 return E_NOTIMPL;
1378 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1380 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1382 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1384 return E_NOTIMPL;
1387 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1389 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1391 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1393 return E_NOTIMPL;
1396 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1398 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1400 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1402 return E_NOTIMPL;
1405 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1407 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1409 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1411 return E_NOTIMPL;
1414 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1416 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1418 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1420 return E_NOTIMPL;
1423 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1425 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1427 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1429 return E_NOTIMPL;
1432 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1434 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1436 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1438 return E_NOTIMPL;
1441 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1443 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1445 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1447 return E_NOTIMPL;
1450 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1452 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1454 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1456 return E_NOTIMPL;
1459 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1461 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1463 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1465 return E_NOTIMPL;
1468 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1470 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1472 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1474 return E_NOTIMPL;
1477 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1479 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1481 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1483 return E_NOTIMPL;
1486 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1488 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1490 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1492 return E_NOTIMPL;
1495 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1497 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1499 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1501 return E_NOTIMPL;
1504 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1506 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1508 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1510 return E_NOTIMPL;
1513 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1515 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1517 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1519 return E_NOTIMPL;
1522 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
1524 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1526 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
1528 return E_NOTIMPL;
1531 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
1533 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1534 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1536 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
1538 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1540 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
1542 *string = *(LPCSTR *)param->data;
1543 TRACE("Returning %s\n", debugstr_a(*string));
1544 return D3D_OK;
1547 WARN("Invalid argument specified\n");
1549 return D3DERR_INVALIDCALL;
1552 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
1554 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1556 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1558 return E_NOTIMPL;
1561 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
1563 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1565 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1567 return E_NOTIMPL;
1570 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
1572 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1573 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1575 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
1577 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1579 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
1581 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
1582 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
1583 TRACE("Returning %p\n", *pshader);
1584 return D3D_OK;
1587 WARN("Invalid argument specified\n");
1589 return D3DERR_INVALIDCALL;
1592 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
1594 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1595 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1597 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
1599 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1601 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
1603 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
1604 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
1605 TRACE("Returning %p\n", *vshader);
1606 return D3D_OK;
1609 WARN("Invalid argument specified\n");
1611 return D3DERR_INVALIDCALL;
1614 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
1616 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1618 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
1620 return E_NOTIMPL;
1623 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
1625 /*** IUnknown methods ***/
1626 ID3DXBaseEffectImpl_QueryInterface,
1627 ID3DXBaseEffectImpl_AddRef,
1628 ID3DXBaseEffectImpl_Release,
1629 /*** ID3DXBaseEffect methods ***/
1630 ID3DXBaseEffectImpl_GetDesc,
1631 ID3DXBaseEffectImpl_GetParameterDesc,
1632 ID3DXBaseEffectImpl_GetTechniqueDesc,
1633 ID3DXBaseEffectImpl_GetPassDesc,
1634 ID3DXBaseEffectImpl_GetFunctionDesc,
1635 ID3DXBaseEffectImpl_GetParameter,
1636 ID3DXBaseEffectImpl_GetParameterByName,
1637 ID3DXBaseEffectImpl_GetParameterBySemantic,
1638 ID3DXBaseEffectImpl_GetParameterElement,
1639 ID3DXBaseEffectImpl_GetTechnique,
1640 ID3DXBaseEffectImpl_GetTechniqueByName,
1641 ID3DXBaseEffectImpl_GetPass,
1642 ID3DXBaseEffectImpl_GetPassByName,
1643 ID3DXBaseEffectImpl_GetFunction,
1644 ID3DXBaseEffectImpl_GetFunctionByName,
1645 ID3DXBaseEffectImpl_GetAnnotation,
1646 ID3DXBaseEffectImpl_GetAnnotationByName,
1647 ID3DXBaseEffectImpl_SetValue,
1648 ID3DXBaseEffectImpl_GetValue,
1649 ID3DXBaseEffectImpl_SetBool,
1650 ID3DXBaseEffectImpl_GetBool,
1651 ID3DXBaseEffectImpl_SetBoolArray,
1652 ID3DXBaseEffectImpl_GetBoolArray,
1653 ID3DXBaseEffectImpl_SetInt,
1654 ID3DXBaseEffectImpl_GetInt,
1655 ID3DXBaseEffectImpl_SetIntArray,
1656 ID3DXBaseEffectImpl_GetIntArray,
1657 ID3DXBaseEffectImpl_SetFloat,
1658 ID3DXBaseEffectImpl_GetFloat,
1659 ID3DXBaseEffectImpl_SetFloatArray,
1660 ID3DXBaseEffectImpl_GetFloatArray,
1661 ID3DXBaseEffectImpl_SetVector,
1662 ID3DXBaseEffectImpl_GetVector,
1663 ID3DXBaseEffectImpl_SetVectorArray,
1664 ID3DXBaseEffectImpl_GetVectorArray,
1665 ID3DXBaseEffectImpl_SetMatrix,
1666 ID3DXBaseEffectImpl_GetMatrix,
1667 ID3DXBaseEffectImpl_SetMatrixArray,
1668 ID3DXBaseEffectImpl_GetMatrixArray,
1669 ID3DXBaseEffectImpl_SetMatrixPointerArray,
1670 ID3DXBaseEffectImpl_GetMatrixPointerArray,
1671 ID3DXBaseEffectImpl_SetMatrixTranspose,
1672 ID3DXBaseEffectImpl_GetMatrixTranspose,
1673 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
1674 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
1675 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
1676 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
1677 ID3DXBaseEffectImpl_SetString,
1678 ID3DXBaseEffectImpl_GetString,
1679 ID3DXBaseEffectImpl_SetTexture,
1680 ID3DXBaseEffectImpl_GetTexture,
1681 ID3DXBaseEffectImpl_GetPixelShader,
1682 ID3DXBaseEffectImpl_GetVertexShader,
1683 ID3DXBaseEffectImpl_SetArrayRange,
1686 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
1688 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
1691 /*** IUnknown methods ***/
1692 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
1694 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1696 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
1698 if (IsEqualGUID(riid, &IID_IUnknown) ||
1699 IsEqualGUID(riid, &IID_ID3DXEffect))
1701 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
1702 *object = This;
1703 return S_OK;
1706 ERR("Interface %s not found\n", debugstr_guid(riid));
1708 return E_NOINTERFACE;
1711 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
1713 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1715 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
1717 return InterlockedIncrement(&This->ref);
1720 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
1722 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1723 ULONG ref = InterlockedDecrement(&This->ref);
1725 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
1727 if (!ref)
1729 free_effect(This);
1730 HeapFree(GetProcessHeap(), 0, This);
1733 return ref;
1736 /*** ID3DXBaseEffect methods ***/
1737 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
1739 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1740 ID3DXBaseEffect *base = This->base_effect;
1742 TRACE("Forward iface %p, base %p\n", This, base);
1744 return ID3DXBaseEffectImpl_GetDesc(base, desc);
1747 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1749 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1750 ID3DXBaseEffect *base = This->base_effect;
1752 TRACE("Forward iface %p, base %p\n", This, base);
1754 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
1757 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1759 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1760 ID3DXBaseEffect *base = This->base_effect;
1762 TRACE("Forward iface %p, base %p\n", This, base);
1764 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
1767 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1769 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1770 ID3DXBaseEffect *base = This->base_effect;
1772 TRACE("Forward iface %p, base %p\n", This, base);
1774 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
1777 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1779 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1780 ID3DXBaseEffect *base = This->base_effect;
1782 TRACE("Forward iface %p, base %p\n", This, base);
1784 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
1787 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
1789 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1790 ID3DXBaseEffect *base = This->base_effect;
1792 TRACE("Forward iface %p, base %p\n", This, base);
1794 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
1797 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1799 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1800 ID3DXBaseEffect *base = This->base_effect;
1802 TRACE("Forward iface %p, base %p\n", This, base);
1804 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
1807 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1809 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1810 ID3DXBaseEffect *base = This->base_effect;
1812 TRACE("Forward iface %p, base %p\n", This, base);
1814 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
1817 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
1819 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1820 ID3DXBaseEffect *base = This->base_effect;
1822 TRACE("Forward iface %p, base %p\n", This, base);
1824 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
1827 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
1829 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1830 ID3DXBaseEffect *base = This->base_effect;
1832 TRACE("Forward iface %p, base %p\n", This, base);
1834 return ID3DXBaseEffectImpl_GetTechnique(base, index);
1837 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
1839 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1840 ID3DXBaseEffect *base = This->base_effect;
1842 TRACE("Forward iface %p, base %p\n", This, base);
1844 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
1847 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
1849 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1850 ID3DXBaseEffect *base = This->base_effect;
1852 TRACE("Forward iface %p, base %p\n", This, base);
1854 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
1857 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
1859 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1860 ID3DXBaseEffect *base = This->base_effect;
1862 TRACE("Forward iface %p, base %p\n", This, base);
1864 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
1867 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
1869 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1870 ID3DXBaseEffect *base = This->base_effect;
1872 TRACE("Forward iface %p, base %p\n", This, base);
1874 return ID3DXBaseEffectImpl_GetFunction(base, index);
1877 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
1879 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1880 ID3DXBaseEffect *base = This->base_effect;
1882 TRACE("Forward iface %p, base %p\n", This, base);
1884 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
1887 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
1889 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1890 ID3DXBaseEffect *base = This->base_effect;
1892 TRACE("Forward iface %p, base %p\n", This, base);
1894 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
1897 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
1899 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1900 ID3DXBaseEffect *base = This->base_effect;
1902 TRACE("Forward iface %p, base %p\n", This, base);
1904 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
1907 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1909 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1910 ID3DXBaseEffect *base = This->base_effect;
1912 TRACE("Forward iface %p, base %p\n", This, base);
1914 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
1917 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1919 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1920 ID3DXBaseEffect *base = This->base_effect;
1922 TRACE("Forward iface %p, base %p\n", This, base);
1924 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
1927 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
1929 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1930 ID3DXBaseEffect *base = This->base_effect;
1932 TRACE("Forward iface %p, base %p\n", This, base);
1934 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
1937 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
1939 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1940 ID3DXBaseEffect *base = This->base_effect;
1942 TRACE("Forward iface %p, base %p\n", This, base);
1944 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
1947 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1949 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1950 ID3DXBaseEffect *base = This->base_effect;
1952 TRACE("Forward iface %p, base %p\n", This, base);
1954 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
1957 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1959 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1960 ID3DXBaseEffect *base = This->base_effect;
1962 TRACE("Forward iface %p, base %p\n", This, base);
1964 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
1967 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
1969 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1970 ID3DXBaseEffect *base = This->base_effect;
1972 TRACE("Forward iface %p, base %p\n", This, base);
1974 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
1977 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
1979 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1980 ID3DXBaseEffect *base = This->base_effect;
1982 TRACE("Forward iface %p, base %p\n", This, base);
1984 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
1987 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1989 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1990 ID3DXBaseEffect *base = This->base_effect;
1992 TRACE("Forward iface %p, base %p\n", This, base);
1994 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
1997 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1999 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2000 ID3DXBaseEffect *base = This->base_effect;
2002 TRACE("Forward iface %p, base %p\n", This, base);
2004 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2007 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2009 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2010 ID3DXBaseEffect *base = This->base_effect;
2012 TRACE("Forward iface %p, base %p\n", This, base);
2014 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2017 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2019 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2020 ID3DXBaseEffect *base = This->base_effect;
2022 TRACE("Forward iface %p, base %p\n", This, base);
2024 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2027 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2029 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2030 ID3DXBaseEffect *base = This->base_effect;
2032 TRACE("Forward iface %p, base %p\n", This, base);
2034 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2037 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2039 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2040 ID3DXBaseEffect *base = This->base_effect;
2042 TRACE("Forward iface %p, base %p\n", This, base);
2044 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2047 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2049 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2050 ID3DXBaseEffect *base = This->base_effect;
2052 TRACE("Forward iface %p, base %p\n", This, base);
2054 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2057 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2059 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2060 ID3DXBaseEffect *base = This->base_effect;
2062 TRACE("Forward iface %p, base %p\n", This, base);
2064 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2067 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2069 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2070 ID3DXBaseEffect *base = This->base_effect;
2072 TRACE("Forward iface %p, base %p\n", This, base);
2074 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2077 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2079 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2080 ID3DXBaseEffect *base = This->base_effect;
2082 TRACE("Forward iface %p, base %p\n", This, base);
2084 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2087 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2089 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2090 ID3DXBaseEffect *base = This->base_effect;
2092 TRACE("Forward iface %p, base %p\n", This, base);
2094 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2097 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2099 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2100 ID3DXBaseEffect *base = This->base_effect;
2102 TRACE("Forward iface %p, base %p\n", This, base);
2104 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2107 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2109 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2110 ID3DXBaseEffect *base = This->base_effect;
2112 TRACE("Forward iface %p, base %p\n", This, base);
2114 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2117 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2119 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2120 ID3DXBaseEffect *base = This->base_effect;
2122 TRACE("Forward iface %p, base %p\n", This, base);
2124 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2127 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2129 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2130 ID3DXBaseEffect *base = This->base_effect;
2132 TRACE("Forward iface %p, base %p\n", This, base);
2134 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2137 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2139 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2140 ID3DXBaseEffect *base = This->base_effect;
2142 TRACE("Forward iface %p, base %p\n", This, base);
2144 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2147 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2149 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2150 ID3DXBaseEffect *base = This->base_effect;
2152 TRACE("Forward iface %p, base %p\n", This, base);
2154 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2157 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2159 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2160 ID3DXBaseEffect *base = This->base_effect;
2162 TRACE("Forward iface %p, base %p\n", This, base);
2164 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2167 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2169 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2170 ID3DXBaseEffect *base = This->base_effect;
2172 TRACE("Forward iface %p, base %p\n", This, base);
2174 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2177 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2179 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2180 ID3DXBaseEffect *base = This->base_effect;
2182 TRACE("Forward iface %p, base %p\n", This, base);
2184 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2187 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2189 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2190 ID3DXBaseEffect *base = This->base_effect;
2192 TRACE("Forward iface %p, base %p\n", This, base);
2194 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2197 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2199 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2200 ID3DXBaseEffect *base = This->base_effect;
2202 TRACE("Forward iface %p, base %p\n", This, base);
2204 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2207 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2209 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2210 ID3DXBaseEffect *base = This->base_effect;
2212 TRACE("Forward iface %p, base %p\n", This, base);
2214 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2217 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2219 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2220 ID3DXBaseEffect *base = This->base_effect;
2222 TRACE("Forward iface %p, base %p\n", This, base);
2224 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2227 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2229 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2230 ID3DXBaseEffect *base = This->base_effect;
2232 TRACE("Forward iface %p, base %p\n", This, base);
2234 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2237 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2239 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2240 ID3DXBaseEffect *base = This->base_effect;
2242 TRACE("Forward iface %p, base %p\n", This, base);
2244 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2247 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2249 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2250 ID3DXBaseEffect *base = This->base_effect;
2252 TRACE("Forward iface %p, base %p\n", This, base);
2254 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2257 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2259 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2260 ID3DXBaseEffect *base = This->base_effect;
2262 TRACE("Forward iface %p, base %p\n", This, base);
2264 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2267 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2269 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2270 ID3DXBaseEffect *base = This->base_effect;
2272 TRACE("Forward iface %p, base %p\n", This, base);
2274 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2277 /*** ID3DXEffect methods ***/
2278 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2280 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2282 TRACE("iface %p, pool %p\n", This, pool);
2284 if (!pool)
2286 WARN("Invalid argument supplied.\n");
2287 return D3DERR_INVALIDCALL;
2290 if (This->pool)
2292 This->pool->lpVtbl->AddRef(This->pool);
2295 *pool = This->pool;
2297 TRACE("Returning pool %p\n", *pool);
2299 return S_OK;
2302 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2304 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2306 FIXME("(%p)->(%p): stub\n", This, technique);
2308 return E_NOTIMPL;
2311 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect* iface)
2313 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2315 FIXME("(%p)->(): stub\n", This);
2317 return NULL;
2320 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2322 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2324 FIXME("(%p)->(%p): stub\n", This, technique);
2326 return D3D_OK;
2329 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2331 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2333 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2335 return E_NOTIMPL;
2338 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2340 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2342 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2344 return FALSE;
2347 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect* iface, UINT *passes, DWORD flags)
2349 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2351 FIXME("(%p)->(%p, %#x): stub\n", This, passes, flags);
2353 return E_NOTIMPL;
2356 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect* iface, UINT pass)
2358 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2360 FIXME("(%p)->(%u): stub\n", This, pass);
2362 return E_NOTIMPL;
2365 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2367 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2369 FIXME("(%p)->(): stub\n", This);
2371 return E_NOTIMPL;
2374 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
2376 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2378 FIXME("(%p)->(): stub\n", This);
2380 return E_NOTIMPL;
2383 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2385 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2387 FIXME("(%p)->(): stub\n", This);
2389 return E_NOTIMPL;
2392 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2394 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2396 TRACE("iface %p, device %p\n", This, device);
2398 if (!device)
2400 WARN("Invalid argument supplied.\n");
2401 return D3DERR_INVALIDCALL;
2404 IDirect3DDevice9_AddRef(This->device);
2406 *device = This->device;
2408 TRACE("Returning device %p\n", *device);
2410 return S_OK;
2413 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2415 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2417 FIXME("(%p)->(): stub\n", This);
2419 return E_NOTIMPL;
2422 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2424 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2426 FIXME("(%p)->(): stub\n", This);
2428 return E_NOTIMPL;
2431 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
2433 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2435 TRACE("iface %p, manager %p\n", This, manager);
2437 if (This->manager) IUnknown_Release(This->manager);
2438 if (manager) IUnknown_AddRef(manager);
2440 This->manager = manager;
2442 return D3D_OK;
2445 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
2447 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2449 TRACE("iface %p, manager %p\n", This, manager);
2451 if (!manager)
2453 WARN("Invalid argument supplied.\n");
2454 return D3DERR_INVALIDCALL;
2457 if (This->manager) IUnknown_AddRef(This->manager);
2458 *manager = This->manager;
2460 return D3D_OK;
2463 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2465 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2467 FIXME("(%p)->(): stub\n", This);
2469 return E_NOTIMPL;
2472 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
2474 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2476 FIXME("(%p)->(): stub\n", This);
2478 return NULL;
2481 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2483 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2485 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2487 return E_NOTIMPL;
2490 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2492 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2494 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2496 return E_NOTIMPL;
2499 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
2501 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2503 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
2505 return E_NOTIMPL;
2508 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
2510 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2512 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
2514 return E_NOTIMPL;
2517 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
2519 /*** IUnknown methods ***/
2520 ID3DXEffectImpl_QueryInterface,
2521 ID3DXEffectImpl_AddRef,
2522 ID3DXEffectImpl_Release,
2523 /*** ID3DXBaseEffect methods ***/
2524 ID3DXEffectImpl_GetDesc,
2525 ID3DXEffectImpl_GetParameterDesc,
2526 ID3DXEffectImpl_GetTechniqueDesc,
2527 ID3DXEffectImpl_GetPassDesc,
2528 ID3DXEffectImpl_GetFunctionDesc,
2529 ID3DXEffectImpl_GetParameter,
2530 ID3DXEffectImpl_GetParameterByName,
2531 ID3DXEffectImpl_GetParameterBySemantic,
2532 ID3DXEffectImpl_GetParameterElement,
2533 ID3DXEffectImpl_GetTechnique,
2534 ID3DXEffectImpl_GetTechniqueByName,
2535 ID3DXEffectImpl_GetPass,
2536 ID3DXEffectImpl_GetPassByName,
2537 ID3DXEffectImpl_GetFunction,
2538 ID3DXEffectImpl_GetFunctionByName,
2539 ID3DXEffectImpl_GetAnnotation,
2540 ID3DXEffectImpl_GetAnnotationByName,
2541 ID3DXEffectImpl_SetValue,
2542 ID3DXEffectImpl_GetValue,
2543 ID3DXEffectImpl_SetBool,
2544 ID3DXEffectImpl_GetBool,
2545 ID3DXEffectImpl_SetBoolArray,
2546 ID3DXEffectImpl_GetBoolArray,
2547 ID3DXEffectImpl_SetInt,
2548 ID3DXEffectImpl_GetInt,
2549 ID3DXEffectImpl_SetIntArray,
2550 ID3DXEffectImpl_GetIntArray,
2551 ID3DXEffectImpl_SetFloat,
2552 ID3DXEffectImpl_GetFloat,
2553 ID3DXEffectImpl_SetFloatArray,
2554 ID3DXEffectImpl_GetFloatArray,
2555 ID3DXEffectImpl_SetVector,
2556 ID3DXEffectImpl_GetVector,
2557 ID3DXEffectImpl_SetVectorArray,
2558 ID3DXEffectImpl_GetVectorArray,
2559 ID3DXEffectImpl_SetMatrix,
2560 ID3DXEffectImpl_GetMatrix,
2561 ID3DXEffectImpl_SetMatrixArray,
2562 ID3DXEffectImpl_GetMatrixArray,
2563 ID3DXEffectImpl_SetMatrixPointerArray,
2564 ID3DXEffectImpl_GetMatrixPointerArray,
2565 ID3DXEffectImpl_SetMatrixTranspose,
2566 ID3DXEffectImpl_GetMatrixTranspose,
2567 ID3DXEffectImpl_SetMatrixTransposeArray,
2568 ID3DXEffectImpl_GetMatrixTransposeArray,
2569 ID3DXEffectImpl_SetMatrixTransposePointerArray,
2570 ID3DXEffectImpl_GetMatrixTransposePointerArray,
2571 ID3DXEffectImpl_SetString,
2572 ID3DXEffectImpl_GetString,
2573 ID3DXEffectImpl_SetTexture,
2574 ID3DXEffectImpl_GetTexture,
2575 ID3DXEffectImpl_GetPixelShader,
2576 ID3DXEffectImpl_GetVertexShader,
2577 ID3DXEffectImpl_SetArrayRange,
2578 /*** ID3DXEffect methods ***/
2579 ID3DXEffectImpl_GetPool,
2580 ID3DXEffectImpl_SetTechnique,
2581 ID3DXEffectImpl_GetCurrentTechnique,
2582 ID3DXEffectImpl_ValidateTechnique,
2583 ID3DXEffectImpl_FindNextValidTechnique,
2584 ID3DXEffectImpl_IsParameterUsed,
2585 ID3DXEffectImpl_Begin,
2586 ID3DXEffectImpl_BeginPass,
2587 ID3DXEffectImpl_CommitChanges,
2588 ID3DXEffectImpl_EndPass,
2589 ID3DXEffectImpl_End,
2590 ID3DXEffectImpl_GetDevice,
2591 ID3DXEffectImpl_OnLostDevice,
2592 ID3DXEffectImpl_OnResetDevice,
2593 ID3DXEffectImpl_SetStateManager,
2594 ID3DXEffectImpl_GetStateManager,
2595 ID3DXEffectImpl_BeginParameterBlock,
2596 ID3DXEffectImpl_EndParameterBlock,
2597 ID3DXEffectImpl_ApplyParameterBlock,
2598 ID3DXEffectImpl_DeleteParameterBlock,
2599 ID3DXEffectImpl_CloneEffect,
2600 ID3DXEffectImpl_SetRawValue
2603 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
2605 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
2608 /*** IUnknown methods ***/
2609 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
2611 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2613 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
2615 if (IsEqualGUID(riid, &IID_IUnknown) ||
2616 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
2618 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
2619 *object = This;
2620 return S_OK;
2623 ERR("Interface %s not found\n", debugstr_guid(riid));
2625 return E_NOINTERFACE;
2628 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
2630 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2632 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
2634 return InterlockedIncrement(&This->ref);
2637 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
2639 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2640 ULONG ref = InterlockedDecrement(&This->ref);
2642 TRACE("iface %p: Release from %u\n", iface, ref + 1);
2644 if (!ref)
2646 free_effect_compiler(This);
2647 HeapFree(GetProcessHeap(), 0, This);
2650 return ref;
2653 /*** ID3DXBaseEffect methods ***/
2654 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
2656 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2657 ID3DXBaseEffect *base = This->base_effect;
2659 TRACE("Forward iface %p, base %p\n", This, base);
2661 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2664 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2666 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2667 ID3DXBaseEffect *base = This->base_effect;
2669 TRACE("Forward iface %p, base %p\n", This, base);
2671 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2674 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2676 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2677 ID3DXBaseEffect *base = This->base_effect;
2679 TRACE("Forward iface %p, base %p\n", This, base);
2681 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2684 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2686 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2687 ID3DXBaseEffect *base = This->base_effect;
2689 TRACE("Forward iface %p, base %p\n", This, base);
2691 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2694 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2696 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2697 ID3DXBaseEffect *base = This->base_effect;
2699 TRACE("Forward iface %p, base %p\n", This, base);
2701 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2704 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
2706 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2707 ID3DXBaseEffect *base = This->base_effect;
2709 TRACE("Forward iface %p, base %p\n", This, base);
2711 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2714 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
2716 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2717 ID3DXBaseEffect *base = This->base_effect;
2719 TRACE("Forward iface %p, base %p\n", This, base);
2721 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2724 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
2726 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2727 ID3DXBaseEffect *base = This->base_effect;
2729 TRACE("Forward iface %p, base %p\n", This, base);
2731 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2734 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
2736 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2737 ID3DXBaseEffect *base = This->base_effect;
2739 TRACE("Forward iface %p, base %p\n", This, base);
2741 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2744 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
2746 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2747 ID3DXBaseEffect *base = This->base_effect;
2749 TRACE("Forward iface %p, base %p\n", This, base);
2751 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2754 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
2756 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2757 ID3DXBaseEffect *base = This->base_effect;
2759 TRACE("Forward iface %p, base %p\n", This, base);
2761 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2764 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
2766 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2767 ID3DXBaseEffect *base = This->base_effect;
2769 TRACE("Forward iface %p, base %p\n", This, base);
2771 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2774 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
2776 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2777 ID3DXBaseEffect *base = This->base_effect;
2779 TRACE("Forward iface %p, base %p\n", This, base);
2781 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2784 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
2786 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2787 ID3DXBaseEffect *base = This->base_effect;
2789 TRACE("Forward iface %p, base %p\n", This, base);
2791 return ID3DXBaseEffectImpl_GetFunction(base, index);
2794 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
2796 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2797 ID3DXBaseEffect *base = This->base_effect;
2799 TRACE("Forward iface %p, base %p\n", This, base);
2801 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2804 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
2806 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2807 ID3DXBaseEffect *base = This->base_effect;
2809 TRACE("Forward iface %p, base %p\n", This, base);
2811 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2814 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
2816 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2817 ID3DXBaseEffect *base = This->base_effect;
2819 TRACE("Forward iface %p, base %p\n", This, base);
2821 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2824 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2826 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2827 ID3DXBaseEffect *base = This->base_effect;
2829 TRACE("Forward iface %p, base %p\n", This, base);
2831 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2834 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2836 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2837 ID3DXBaseEffect *base = This->base_effect;
2839 TRACE("Forward iface %p, base %p\n", This, base);
2841 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2844 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
2846 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2847 ID3DXBaseEffect *base = This->base_effect;
2849 TRACE("Forward iface %p, base %p\n", This, base);
2851 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2854 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
2856 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2857 ID3DXBaseEffect *base = This->base_effect;
2859 TRACE("Forward iface %p, base %p\n", This, base);
2861 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2864 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2866 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2867 ID3DXBaseEffect *base = This->base_effect;
2869 TRACE("Forward iface %p, base %p\n", This, base);
2871 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2874 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2876 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2877 ID3DXBaseEffect *base = This->base_effect;
2879 TRACE("Forward iface %p, base %p\n", This, base);
2881 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2884 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
2886 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2887 ID3DXBaseEffect *base = This->base_effect;
2889 TRACE("Forward iface %p, base %p\n", This, base);
2891 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2894 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
2896 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2897 ID3DXBaseEffect *base = This->base_effect;
2899 TRACE("Forward iface %p, base %p\n", This, base);
2901 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2904 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2906 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2907 ID3DXBaseEffect *base = This->base_effect;
2909 TRACE("Forward iface %p, base %p\n", This, base);
2911 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2914 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
2916 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2917 ID3DXBaseEffect *base = This->base_effect;
2919 TRACE("Forward iface %p, base %p\n", This, base);
2921 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2924 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
2926 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2927 ID3DXBaseEffect *base = This->base_effect;
2929 TRACE("Forward iface %p, base %p\n", This, base);
2931 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2934 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
2936 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2937 ID3DXBaseEffect *base = This->base_effect;
2939 TRACE("Forward iface %p, base %p\n", This, base);
2941 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2944 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2946 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2947 ID3DXBaseEffect *base = This->base_effect;
2949 TRACE("Forward iface %p, base %p\n", This, base);
2951 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2954 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2956 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2957 ID3DXBaseEffect *base = This->base_effect;
2959 TRACE("Forward iface %p, base %p\n", This, base);
2961 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2964 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2966 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2967 ID3DXBaseEffect *base = This->base_effect;
2969 TRACE("Forward iface %p, base %p\n", This, base);
2971 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2974 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2976 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2977 ID3DXBaseEffect *base = This->base_effect;
2979 TRACE("Forward iface %p, base %p\n", This, base);
2981 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2984 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2986 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2987 ID3DXBaseEffect *base = This->base_effect;
2989 TRACE("Forward iface %p, base %p\n", This, base);
2991 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2994 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2996 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2997 ID3DXBaseEffect *base = This->base_effect;
2999 TRACE("Forward iface %p, base %p\n", This, base);
3001 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3004 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3006 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3007 ID3DXBaseEffect *base = This->base_effect;
3009 TRACE("Forward iface %p, base %p\n", This, base);
3011 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3014 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3016 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3017 ID3DXBaseEffect *base = This->base_effect;
3019 TRACE("Forward iface %p, base %p\n", This, base);
3021 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3024 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3026 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3027 ID3DXBaseEffect *base = This->base_effect;
3029 TRACE("Forward iface %p, base %p\n", This, base);
3031 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3034 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3036 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3037 ID3DXBaseEffect *base = This->base_effect;
3039 TRACE("Forward iface %p, base %p\n", This, base);
3041 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3044 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3046 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3047 ID3DXBaseEffect *base = This->base_effect;
3049 TRACE("Forward iface %p, base %p\n", This, base);
3051 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3054 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3056 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3057 ID3DXBaseEffect *base = This->base_effect;
3059 TRACE("Forward iface %p, base %p\n", This, base);
3061 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3064 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3066 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3067 ID3DXBaseEffect *base = This->base_effect;
3069 TRACE("Forward iface %p, base %p\n", This, base);
3071 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3074 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3076 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3077 ID3DXBaseEffect *base = This->base_effect;
3079 TRACE("Forward iface %p, base %p\n", This, base);
3081 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3084 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3086 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3087 ID3DXBaseEffect *base = This->base_effect;
3089 TRACE("Forward iface %p, base %p\n", This, base);
3091 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3094 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3096 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3097 ID3DXBaseEffect *base = This->base_effect;
3099 TRACE("Forward iface %p, base %p\n", This, base);
3101 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3104 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3106 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3107 ID3DXBaseEffect *base = This->base_effect;
3109 TRACE("Forward iface %p, base %p\n", This, base);
3111 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3114 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3116 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3117 ID3DXBaseEffect *base = This->base_effect;
3119 TRACE("Forward iface %p, base %p\n", This, base);
3121 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3124 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3126 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3127 ID3DXBaseEffect *base = This->base_effect;
3129 TRACE("Forward iface %p, base %p\n", This, base);
3131 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3134 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3136 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3137 ID3DXBaseEffect *base = This->base_effect;
3139 TRACE("Forward iface %p, base %p\n", This, base);
3141 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3144 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3146 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3147 ID3DXBaseEffect *base = This->base_effect;
3149 TRACE("Forward iface %p, base %p\n", This, base);
3151 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3154 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3156 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3157 ID3DXBaseEffect *base = This->base_effect;
3159 TRACE("Forward iface %p, base %p\n", This, base);
3161 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3164 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3166 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3167 ID3DXBaseEffect *base = This->base_effect;
3169 TRACE("Forward iface %p, base %p\n", This, base);
3171 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3174 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3176 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3177 ID3DXBaseEffect *base = This->base_effect;
3179 TRACE("Forward iface %p, base %p\n", This, base);
3181 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3184 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3186 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3187 ID3DXBaseEffect *base = This->base_effect;
3189 TRACE("Forward iface %p, base %p\n", This, base);
3191 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3194 /*** ID3DXEffectCompiler methods ***/
3195 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3197 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3199 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3201 return E_NOTIMPL;
3204 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3206 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3208 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3210 return E_NOTIMPL;
3213 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3214 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3216 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3218 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3220 return E_NOTIMPL;
3223 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3224 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3226 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3228 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3229 This, function, target, flags, shader, error_msgs, constant_table);
3231 return E_NOTIMPL;
3234 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3236 /*** IUnknown methods ***/
3237 ID3DXEffectCompilerImpl_QueryInterface,
3238 ID3DXEffectCompilerImpl_AddRef,
3239 ID3DXEffectCompilerImpl_Release,
3240 /*** ID3DXBaseEffect methods ***/
3241 ID3DXEffectCompilerImpl_GetDesc,
3242 ID3DXEffectCompilerImpl_GetParameterDesc,
3243 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3244 ID3DXEffectCompilerImpl_GetPassDesc,
3245 ID3DXEffectCompilerImpl_GetFunctionDesc,
3246 ID3DXEffectCompilerImpl_GetParameter,
3247 ID3DXEffectCompilerImpl_GetParameterByName,
3248 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3249 ID3DXEffectCompilerImpl_GetParameterElement,
3250 ID3DXEffectCompilerImpl_GetTechnique,
3251 ID3DXEffectCompilerImpl_GetTechniqueByName,
3252 ID3DXEffectCompilerImpl_GetPass,
3253 ID3DXEffectCompilerImpl_GetPassByName,
3254 ID3DXEffectCompilerImpl_GetFunction,
3255 ID3DXEffectCompilerImpl_GetFunctionByName,
3256 ID3DXEffectCompilerImpl_GetAnnotation,
3257 ID3DXEffectCompilerImpl_GetAnnotationByName,
3258 ID3DXEffectCompilerImpl_SetValue,
3259 ID3DXEffectCompilerImpl_GetValue,
3260 ID3DXEffectCompilerImpl_SetBool,
3261 ID3DXEffectCompilerImpl_GetBool,
3262 ID3DXEffectCompilerImpl_SetBoolArray,
3263 ID3DXEffectCompilerImpl_GetBoolArray,
3264 ID3DXEffectCompilerImpl_SetInt,
3265 ID3DXEffectCompilerImpl_GetInt,
3266 ID3DXEffectCompilerImpl_SetIntArray,
3267 ID3DXEffectCompilerImpl_GetIntArray,
3268 ID3DXEffectCompilerImpl_SetFloat,
3269 ID3DXEffectCompilerImpl_GetFloat,
3270 ID3DXEffectCompilerImpl_SetFloatArray,
3271 ID3DXEffectCompilerImpl_GetFloatArray,
3272 ID3DXEffectCompilerImpl_SetVector,
3273 ID3DXEffectCompilerImpl_GetVector,
3274 ID3DXEffectCompilerImpl_SetVectorArray,
3275 ID3DXEffectCompilerImpl_GetVectorArray,
3276 ID3DXEffectCompilerImpl_SetMatrix,
3277 ID3DXEffectCompilerImpl_GetMatrix,
3278 ID3DXEffectCompilerImpl_SetMatrixArray,
3279 ID3DXEffectCompilerImpl_GetMatrixArray,
3280 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3281 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3282 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3283 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3284 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3285 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3286 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3287 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3288 ID3DXEffectCompilerImpl_SetString,
3289 ID3DXEffectCompilerImpl_GetString,
3290 ID3DXEffectCompilerImpl_SetTexture,
3291 ID3DXEffectCompilerImpl_GetTexture,
3292 ID3DXEffectCompilerImpl_GetPixelShader,
3293 ID3DXEffectCompilerImpl_GetVertexShader,
3294 ID3DXEffectCompilerImpl_SetArrayRange,
3295 /*** ID3DXEffectCompiler methods ***/
3296 ID3DXEffectCompilerImpl_SetLiteral,
3297 ID3DXEffectCompilerImpl_GetLiteral,
3298 ID3DXEffectCompilerImpl_CompileEffect,
3299 ID3DXEffectCompilerImpl_CompileShader,
3302 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char **ptr)
3304 unsigned int i;
3305 HRESULT hr;
3306 UINT old_size = 0;
3307 DWORD id;
3309 if (param->element_count)
3311 param->data = value;
3313 for (i = 0; i < param->element_count; ++i)
3315 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3317 hr = d3dx9_parse_value(member, (char *)value + old_size, ptr);
3318 if (hr != D3D_OK)
3320 WARN("Failed to parse value\n");
3321 return hr;
3324 old_size += member->bytes;
3327 return D3D_OK;
3330 switch(param->class)
3332 case D3DXPC_SCALAR:
3333 case D3DXPC_VECTOR:
3334 case D3DXPC_MATRIX_ROWS:
3335 case D3DXPC_MATRIX_COLUMNS:
3336 param->data = value;
3337 break;
3339 case D3DXPC_STRUCT:
3340 param->data = value;
3342 for (i = 0; i < param->member_count; ++i)
3344 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3346 hr = d3dx9_parse_value(member, (char *)value + old_size, ptr);
3347 if (hr != D3D_OK)
3349 WARN("Failed to parse value\n");
3350 return hr;
3353 old_size += member->bytes;
3355 break;
3357 case D3DXPC_OBJECT:
3358 switch (param->type)
3360 case D3DXPT_STRING:
3361 case D3DXPT_PIXELSHADER:
3362 case D3DXPT_VERTEXSHADER:
3363 read_dword(ptr, &id);
3364 TRACE("Id: %u\n", id);
3365 param->base->objects[id] = get_parameter_handle(param);
3366 param->data = value;
3367 break;
3369 default:
3370 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3371 break;
3373 break;
3375 default:
3376 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3377 break;
3380 return D3D_OK;
3383 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *ptr)
3385 UINT size = param->bytes;
3386 HRESULT hr;
3387 void *value = NULL;
3389 TRACE("param size: %u\n", size);
3391 value = HeapAlloc(GetProcessHeap(), 0, size);
3392 if (!value)
3394 ERR("Failed to allocate data memory.\n");
3395 return E_OUTOFMEMORY;
3398 TRACE("Data: %s.\n", debugstr_an(ptr, size));
3399 memcpy(value, ptr, size);
3401 hr = d3dx9_parse_value(param, value, &ptr);
3402 if (hr != D3D_OK)
3404 WARN("Failed to parse value\n");
3405 HeapFree(GetProcessHeap(), 0, value);
3406 return hr;
3409 param->data = value;
3411 return D3D_OK;
3414 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
3416 DWORD size;
3418 read_dword(&ptr, &size);
3419 TRACE("Name size: %#x\n", size);
3421 if (!size)
3423 return D3D_OK;
3426 *name = HeapAlloc(GetProcessHeap(), 0, size);
3427 if (!*name)
3429 ERR("Failed to allocate name memory.\n");
3430 return E_OUTOFMEMORY;
3433 TRACE("Name: %s.\n", debugstr_an(ptr, size));
3434 memcpy(*name, ptr, size);
3436 return D3D_OK;
3439 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr)
3441 DWORD size;
3442 HRESULT hr;
3444 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
3446 read_dword(ptr, &size);
3447 TRACE("Data size: %#x\n", size);
3449 if (!size)
3451 TRACE("Size is 0\n");
3452 *(void **)param->data = NULL;
3453 return D3D_OK;
3456 switch (param->type)
3458 case D3DXPT_STRING:
3459 /* re-read with size (sizeof(DWORD) = 4) */
3460 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
3461 if (hr != D3D_OK)
3463 WARN("Failed to parse string data\n");
3464 return hr;
3466 break;
3468 case D3DXPT_VERTEXSHADER:
3469 hr = IDirect3DDevice9_CreateVertexShader(param->base->effect->device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
3470 if (hr != D3D_OK)
3472 WARN("Failed to create vertex shader\n");
3473 return hr;
3475 break;
3477 case D3DXPT_PIXELSHADER:
3478 hr = IDirect3DDevice9_CreatePixelShader(param->base->effect->device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
3479 if (hr != D3D_OK)
3481 WARN("Failed to create pixel shader\n");
3482 return hr;
3484 break;
3486 default:
3487 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3488 break;
3492 *ptr += ((size + 3) & ~3);
3494 return D3D_OK;
3497 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
3498 struct d3dx_parameter *parent, UINT flags)
3500 DWORD offset;
3501 HRESULT hr;
3502 D3DXHANDLE *member_handles = NULL;
3503 UINT i;
3505 param->flags = flags;
3507 if (!parent)
3509 read_dword(ptr, &param->type);
3510 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
3512 read_dword(ptr, &param->class);
3513 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
3515 read_dword(ptr, &offset);
3516 TRACE("Type name offset: %#x\n", offset);
3517 hr = d3dx9_parse_name(&param->name, data + offset);
3518 if (hr != D3D_OK)
3520 WARN("Failed to parse name\n");
3521 goto err_out;
3524 read_dword(ptr, &offset);
3525 TRACE("Type semantic offset: %#x\n", offset);
3526 hr = d3dx9_parse_name(&param->semantic, data + offset);
3527 if (hr != D3D_OK)
3529 WARN("Failed to parse semantic\n");
3530 goto err_out;
3533 read_dword(ptr, &param->element_count);
3534 TRACE("Elements: %u\n", param->element_count);
3536 switch (param->class)
3538 case D3DXPC_VECTOR:
3539 read_dword(ptr, &param->columns);
3540 TRACE("Columns: %u\n", param->columns);
3542 read_dword(ptr, &param->rows);
3543 TRACE("Rows: %u\n", param->rows);
3545 /* sizeof(DWORD) * rows * columns */
3546 param->bytes = 4 * param->rows * param->columns;
3547 break;
3549 case D3DXPC_SCALAR:
3550 case D3DXPC_MATRIX_ROWS:
3551 case D3DXPC_MATRIX_COLUMNS:
3552 read_dword(ptr, &param->rows);
3553 TRACE("Rows: %u\n", param->rows);
3555 read_dword(ptr, &param->columns);
3556 TRACE("Columns: %u\n", param->columns);
3558 /* sizeof(DWORD) * rows * columns */
3559 param->bytes = 4 * param->rows * param->columns;
3560 break;
3562 case D3DXPC_STRUCT:
3563 read_dword(ptr, &param->member_count);
3564 TRACE("Members: %u\n", param->member_count);
3565 break;
3567 case D3DXPC_OBJECT:
3568 switch (param->type)
3570 case D3DXPT_STRING:
3571 param->bytes = sizeof(LPCSTR);
3572 break;
3574 case D3DXPT_PIXELSHADER:
3575 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
3576 break;
3578 case D3DXPT_VERTEXSHADER:
3579 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
3580 break;
3582 default:
3583 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3584 break;
3586 break;
3588 default:
3589 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3590 break;
3593 else
3595 /* elements */
3596 param->type = parent->type;
3597 param->class = parent->class;
3598 param->name = parent->name;
3599 param->semantic = parent->semantic;
3600 param->element_count = 0;
3601 param->annotation_count = 0;
3602 param->member_count = parent->member_count;
3603 param->bytes = parent->bytes;
3604 param->rows = parent->rows;
3605 param->columns = parent->columns;
3608 if (param->element_count)
3610 unsigned int param_bytes = 0;
3611 const char *save_ptr = *ptr;
3613 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
3614 if (!member_handles)
3616 ERR("Out of memory\n");
3617 hr = E_OUTOFMEMORY;
3618 goto err_out;
3621 for (i = 0; i < param->element_count; ++i)
3623 struct d3dx_parameter *member;
3624 *ptr = save_ptr;
3626 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
3627 if (!member)
3629 ERR("Out of memory\n");
3630 hr = E_OUTOFMEMORY;
3631 goto err_out;
3634 member_handles[i] = get_parameter_handle(member);
3635 member->base = param->base;
3637 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
3638 if (hr != D3D_OK)
3640 WARN("Failed to parse member\n");
3641 goto err_out;
3644 param_bytes += member->bytes;
3647 param->bytes = param_bytes;
3649 else if (param->member_count)
3651 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
3652 if (!member_handles)
3654 ERR("Out of memory\n");
3655 hr = E_OUTOFMEMORY;
3656 goto err_out;
3659 for (i = 0; i < param->member_count; ++i)
3661 struct d3dx_parameter *member;
3663 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
3664 if (!member)
3666 ERR("Out of memory\n");
3667 hr = E_OUTOFMEMORY;
3668 goto err_out;
3671 member_handles[i] = get_parameter_handle(member);
3672 member->base = param->base;
3674 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
3675 if (hr != D3D_OK)
3677 WARN("Failed to parse member\n");
3678 goto err_out;
3681 param->bytes += member->bytes;
3685 param->member_handles = member_handles;
3687 return D3D_OK;
3689 err_out:
3691 if (member_handles)
3693 unsigned int count;
3695 if (param->element_count) count = param->element_count;
3696 else count = param->member_count;
3698 for (i = 0; i < count; ++i)
3700 free_parameter(member_handles[i], param->element_count != 0, TRUE);
3702 HeapFree(GetProcessHeap(), 0, member_handles);
3705 if (!parent)
3707 HeapFree(GetProcessHeap(), 0, param->name);
3708 HeapFree(GetProcessHeap(), 0, param->semantic);
3710 param->name = NULL;
3711 param->semantic = NULL;
3713 return hr;
3716 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr)
3718 DWORD offset;
3719 const char *ptr2;
3720 HRESULT hr;
3722 anno->flags = D3DX_PARAMETER_ANNOTATION;
3724 read_dword(ptr, &offset);
3725 TRACE("Typedef offset: %#x\n", offset);
3726 ptr2 = data + offset;
3727 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
3728 if (hr != D3D_OK)
3730 WARN("Failed to parse type definition\n");
3731 return hr;
3734 read_dword(ptr, &offset);
3735 TRACE("Value offset: %#x\n", offset);
3736 hr = d3dx9_parse_init_value(anno, data + offset);
3737 if (hr != D3D_OK)
3739 WARN("Failed to parse value\n");
3740 return hr;
3743 return D3D_OK;
3746 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr)
3748 DWORD offset;
3749 HRESULT hr;
3750 unsigned int i;
3751 D3DXHANDLE *annotation_handles = NULL;
3752 const char *ptr2;
3754 read_dword(ptr, &offset);
3755 TRACE("Typedef offset: %#x\n", offset);
3756 ptr2 = data + offset;
3758 read_dword(ptr, &offset);
3759 TRACE("Value offset: %#x\n", offset);
3761 read_dword(ptr, &param->flags);
3762 TRACE("Flags: %#x\n", param->flags);
3764 read_dword(ptr, &param->annotation_count);
3765 TRACE("Annotation count: %u\n", param->annotation_count);
3767 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
3768 if (hr != D3D_OK)
3770 WARN("Failed to parse type definition\n");
3771 return hr;
3774 hr = d3dx9_parse_init_value(param, data + offset);
3775 if (hr != D3D_OK)
3777 WARN("Failed to parse value\n");
3778 return hr;
3781 if (param->annotation_count)
3783 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
3784 if (!annotation_handles)
3786 ERR("Out of memory\n");
3787 hr = E_OUTOFMEMORY;
3788 goto err_out;
3791 for (i = 0; i < param->annotation_count; ++i)
3793 struct d3dx_parameter *annotation;
3795 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3796 if (!annotation)
3798 ERR("Out of memory\n");
3799 hr = E_OUTOFMEMORY;
3800 goto err_out;
3803 annotation_handles[i] = get_parameter_handle(annotation);
3804 annotation->base = param->base;
3806 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3807 if (hr != D3D_OK)
3809 WARN("Failed to parse annotation\n");
3810 goto err_out;
3815 param->annotation_handles = annotation_handles;
3817 return D3D_OK;
3819 err_out:
3821 if (annotation_handles)
3823 for (i = 0; i < param->annotation_count; ++i)
3825 free_parameter(annotation_handles[i], FALSE, FALSE);
3827 HeapFree(GetProcessHeap(), 0, annotation_handles);
3830 return hr;
3833 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr)
3835 DWORD offset;
3836 HRESULT hr;
3837 unsigned int i;
3838 D3DXHANDLE *annotation_handles = NULL;
3839 char *name = NULL;
3841 read_dword(ptr, &offset);
3842 TRACE("Pass name offset: %#x\n", offset);
3843 hr = d3dx9_parse_name(&name, data + offset);
3844 if (hr != D3D_OK)
3846 WARN("Failed to parse name\n");
3847 goto err_out;
3850 read_dword(ptr, &pass->annotation_count);
3851 TRACE("Annotation count: %u\n", pass->annotation_count);
3853 read_dword(ptr, &pass->state_count);
3854 TRACE("State count: %u\n", pass->state_count);
3856 if (pass->annotation_count)
3858 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
3859 if (!annotation_handles)
3861 ERR("Out of memory\n");
3862 hr = E_OUTOFMEMORY;
3863 goto err_out;
3866 for (i = 0; i < pass->annotation_count; ++i)
3868 struct d3dx_parameter *annotation;
3870 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3871 if (!annotation)
3873 ERR("Out of memory\n");
3874 hr = E_OUTOFMEMORY;
3875 goto err_out;
3878 annotation_handles[i] = get_parameter_handle(annotation);
3879 annotation->base = pass->base;
3881 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3882 if (hr != D3D_OK)
3884 WARN("Failed to parse annotations\n");
3885 goto err_out;
3890 if (pass->state_count)
3892 for (i = 0; i < pass->state_count; ++i)
3894 skip_dword_unknown(ptr, 4);
3898 pass->name = name;
3899 pass->annotation_handles = annotation_handles;
3901 return D3D_OK;
3903 err_out:
3905 if (annotation_handles)
3907 for (i = 0; i < pass->annotation_count; ++i)
3909 free_parameter(annotation_handles[i], FALSE, FALSE);
3911 HeapFree(GetProcessHeap(), 0, annotation_handles);
3914 HeapFree(GetProcessHeap(), 0, name);
3916 return hr;
3919 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr)
3921 DWORD offset;
3922 HRESULT hr;
3923 unsigned int i;
3924 D3DXHANDLE *annotation_handles = NULL;
3925 D3DXHANDLE *pass_handles = NULL;
3926 char *name = NULL;
3928 read_dword(ptr, &offset);
3929 TRACE("Technique name offset: %#x\n", offset);
3930 hr = d3dx9_parse_name(&name, data + offset);
3931 if (hr != D3D_OK)
3933 WARN("Failed to parse name\n");
3934 goto err_out;
3937 read_dword(ptr, &technique->annotation_count);
3938 TRACE("Annotation count: %u\n", technique->annotation_count);
3940 read_dword(ptr, &technique->pass_count);
3941 TRACE("Pass count: %u\n", technique->pass_count);
3943 if (technique->annotation_count)
3945 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
3946 if (!annotation_handles)
3948 ERR("Out of memory\n");
3949 hr = E_OUTOFMEMORY;
3950 goto err_out;
3953 for (i = 0; i < technique->annotation_count; ++i)
3955 struct d3dx_parameter *annotation;
3957 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3958 if (!annotation)
3960 ERR("Out of memory\n");
3961 hr = E_OUTOFMEMORY;
3962 goto err_out;
3965 annotation_handles[i] = get_parameter_handle(annotation);
3966 annotation->base = technique->base;
3968 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3969 if (hr != D3D_OK)
3971 WARN("Failed to parse annotations\n");
3972 goto err_out;
3977 if (technique->pass_count)
3979 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
3980 if (!pass_handles)
3982 ERR("Out of memory\n");
3983 hr = E_OUTOFMEMORY;
3984 goto err_out;
3987 for (i = 0; i < technique->pass_count; ++i)
3989 struct d3dx_pass *pass;
3991 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
3992 if (!pass)
3994 ERR("Out of memory\n");
3995 hr = E_OUTOFMEMORY;
3996 goto err_out;
3999 pass_handles[i] = get_pass_handle(pass);
4000 pass->base = technique->base;
4002 hr = d3dx9_parse_effect_pass(pass, data, ptr);
4003 if (hr != D3D_OK)
4005 WARN("Failed to parse passes\n");
4006 goto err_out;
4011 technique->name = name;
4012 technique->pass_handles = pass_handles;
4013 technique->annotation_handles = annotation_handles;
4015 return D3D_OK;
4017 err_out:
4019 if (pass_handles)
4021 for (i = 0; i < technique->pass_count; ++i)
4023 free_pass(pass_handles[i]);
4025 HeapFree(GetProcessHeap(), 0, pass_handles);
4028 if (annotation_handles)
4030 for (i = 0; i < technique->annotation_count; ++i)
4032 free_parameter(annotation_handles[i], FALSE, FALSE);
4034 HeapFree(GetProcessHeap(), 0, annotation_handles);
4037 HeapFree(GetProcessHeap(), 0, name);
4039 return hr;
4042 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4044 const char *ptr = data + start;
4045 D3DXHANDLE *parameter_handles = NULL;
4046 D3DXHANDLE *technique_handles = NULL;
4047 D3DXHANDLE *objects = NULL;
4048 unsigned int stringcount;
4049 HRESULT hr;
4050 unsigned int i;
4052 read_dword(&ptr, &base->parameter_count);
4053 TRACE("Parameter count: %u\n", base->parameter_count);
4055 read_dword(&ptr, &base->technique_count);
4056 TRACE("Technique count: %u\n", base->technique_count);
4058 skip_dword_unknown(&ptr, 1);
4060 read_dword(&ptr, &base->object_count);
4061 TRACE("Object count: %u\n", base->object_count);
4063 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * base->object_count);
4064 if (!objects)
4066 ERR("Out of memory\n");
4067 hr = E_OUTOFMEMORY;
4068 goto err_out;
4071 base->objects = objects;
4073 if (base->parameter_count)
4075 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4076 if (!parameter_handles)
4078 ERR("Out of memory\n");
4079 hr = E_OUTOFMEMORY;
4080 goto err_out;
4083 for (i = 0; i < base->parameter_count; ++i)
4085 struct d3dx_parameter *parameter;
4087 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4088 if (!parameter)
4090 ERR("Out of memory\n");
4091 hr = E_OUTOFMEMORY;
4092 goto err_out;
4095 parameter_handles[i] = get_parameter_handle(parameter);
4096 parameter->base = base;
4098 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr);
4099 if (hr != D3D_OK)
4101 WARN("Failed to parse parameter\n");
4102 goto err_out;
4107 if (base->technique_count)
4109 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4110 if (!technique_handles)
4112 ERR("Out of memory\n");
4113 hr = E_OUTOFMEMORY;
4114 goto err_out;
4117 for (i = 0; i < base->technique_count; ++i)
4119 struct d3dx_technique *technique;
4121 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4122 if (!technique)
4124 ERR("Out of memory\n");
4125 hr = E_OUTOFMEMORY;
4126 goto err_out;
4129 technique_handles[i] = get_technique_handle(technique);
4130 technique->base = base;
4132 hr = d3dx9_parse_effect_technique(technique, data, &ptr);
4133 if (hr != D3D_OK)
4135 WARN("Failed to parse technique\n");
4136 goto err_out;
4141 read_dword(&ptr, &stringcount);
4142 TRACE("String count: %u\n", stringcount);
4144 skip_dword_unknown(&ptr, 1);
4146 for (i = 0; i < stringcount; ++i)
4148 DWORD id;
4149 struct d3dx_parameter *param;
4151 read_dword(&ptr, &id);
4152 TRACE("Id: %u\n", id);
4154 param = get_parameter_struct(base->objects[id]);
4156 hr = d3dx9_parse_data(param, &ptr);
4157 if (hr != D3D_OK)
4159 WARN("Failed to parse data\n");
4160 goto err_out;
4164 HeapFree(GetProcessHeap(), 0, objects);
4165 base->objects = NULL;
4167 base->technique_handles = technique_handles;
4168 base->parameter_handles = parameter_handles;
4170 return D3D_OK;
4172 err_out:
4174 if (technique_handles)
4176 for (i = 0; i < base->technique_count; ++i)
4178 free_technique(technique_handles[i]);
4180 HeapFree(GetProcessHeap(), 0, technique_handles);
4183 if (parameter_handles)
4185 for (i = 0; i < base->parameter_count; ++i)
4187 free_parameter(parameter_handles[i], FALSE, FALSE);
4189 HeapFree(GetProcessHeap(), 0, parameter_handles);
4192 HeapFree(GetProcessHeap(), 0, objects);
4194 return hr;
4197 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
4198 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
4200 DWORD tag, offset;
4201 const char *ptr = data;
4202 HRESULT hr;
4204 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
4206 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
4207 base->ref = 1;
4208 base->effect = effect;
4210 read_dword(&ptr, &tag);
4211 TRACE("Tag: %x\n", tag);
4213 if (tag != d3dx9_effect_version(9, 1))
4215 /* todo: compile hlsl ascii code */
4216 FIXME("HLSL ascii effects not supported, yet\n");
4218 /* Show the start of the shader for debugging info. */
4219 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
4221 else
4223 read_dword(&ptr, &offset);
4224 TRACE("Offset: %x\n", offset);
4226 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
4227 if (hr != D3D_OK)
4229 FIXME("Failed to parse effect.\n");
4230 return hr;
4234 return D3D_OK;
4237 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
4238 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
4240 HRESULT hr;
4241 struct ID3DXBaseEffectImpl *object = NULL;
4243 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
4245 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
4246 effect->ref = 1;
4248 if (pool) pool->lpVtbl->AddRef(pool);
4249 effect->pool = pool;
4251 IDirect3DDevice9_AddRef(device);
4252 effect->device = device;
4254 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4255 if (!object)
4257 ERR("Out of memory\n");
4258 hr = E_OUTOFMEMORY;
4259 goto err_out;
4262 hr = d3dx9_base_effect_init(object, data, data_size, effect);
4263 if (hr != D3D_OK)
4265 FIXME("Failed to parse effect.\n");
4266 goto err_out;
4269 effect->base_effect = &object->ID3DXBaseEffect_iface;
4271 return D3D_OK;
4273 err_out:
4275 HeapFree(GetProcessHeap(), 0, object);
4276 free_effect(effect);
4278 return hr;
4281 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
4282 LPCVOID srcdata,
4283 UINT srcdatalen,
4284 CONST D3DXMACRO* defines,
4285 LPD3DXINCLUDE include,
4286 LPCSTR skip_constants,
4287 DWORD flags,
4288 LPD3DXEFFECTPOOL pool,
4289 LPD3DXEFFECT* effect,
4290 LPD3DXBUFFER* compilation_errors)
4292 struct ID3DXEffectImpl *object;
4293 HRESULT hr;
4295 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
4296 skip_constants, flags, pool, effect, compilation_errors);
4298 if (!device || !srcdata)
4299 return D3DERR_INVALIDCALL;
4301 if (!srcdatalen)
4302 return E_FAIL;
4304 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
4305 if (!effect)
4306 return D3D_OK;
4308 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4309 if (!object)
4311 ERR("Out of memory\n");
4312 return E_OUTOFMEMORY;
4315 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
4316 if (FAILED(hr))
4318 WARN("Failed to initialize shader reflection\n");
4319 HeapFree(GetProcessHeap(), 0, object);
4320 return hr;
4323 *effect = &object->ID3DXEffect_iface;
4325 TRACE("Created ID3DXEffect %p\n", object);
4327 return D3D_OK;
4330 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
4331 LPCVOID srcdata,
4332 UINT srcdatalen,
4333 CONST D3DXMACRO* defines,
4334 LPD3DXINCLUDE include,
4335 DWORD flags,
4336 LPD3DXEFFECTPOOL pool,
4337 LPD3DXEFFECT* effect,
4338 LPD3DXBUFFER* compilation_errors)
4340 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
4341 include, flags, pool, effect, compilation_errors);
4343 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
4346 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
4348 HRESULT hr;
4349 struct ID3DXBaseEffectImpl *object = NULL;
4351 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
4353 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
4354 compiler->ref = 1;
4356 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4357 if (!object)
4359 ERR("Out of memory\n");
4360 hr = E_OUTOFMEMORY;
4361 goto err_out;
4364 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
4365 if (hr != D3D_OK)
4367 FIXME("Failed to parse effect.\n");
4368 goto err_out;
4371 compiler->base_effect = &object->ID3DXBaseEffect_iface;
4373 return D3D_OK;
4375 err_out:
4377 HeapFree(GetProcessHeap(), 0, object);
4378 free_effect_compiler(compiler);
4380 return hr;
4383 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
4384 UINT srcdatalen,
4385 CONST D3DXMACRO *defines,
4386 LPD3DXINCLUDE include,
4387 DWORD flags,
4388 LPD3DXEFFECTCOMPILER *compiler,
4389 LPD3DXBUFFER *parse_errors)
4391 struct ID3DXEffectCompilerImpl *object;
4392 HRESULT hr;
4394 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
4395 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
4397 if (!srcdata || !compiler)
4399 WARN("Invalid arguments supplied\n");
4400 return D3DERR_INVALIDCALL;
4403 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4404 if (!object)
4406 ERR("Out of memory\n");
4407 return E_OUTOFMEMORY;
4410 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
4411 if (FAILED(hr))
4413 WARN("Failed to initialize effect compiler\n");
4414 HeapFree(GetProcessHeap(), 0, object);
4415 return hr;
4418 *compiler = &object->ID3DXEffectCompiler_iface;
4420 TRACE("Created ID3DXEffectCompiler %p\n", object);
4422 return D3D_OK;
4425 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
4427 struct ID3DXEffectPoolImpl
4429 ID3DXEffectPool ID3DXEffectPool_iface;
4430 LONG ref;
4433 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
4435 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
4438 /*** IUnknown methods ***/
4439 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
4441 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4443 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
4445 if (IsEqualGUID(riid, &IID_IUnknown) ||
4446 IsEqualGUID(riid, &IID_ID3DXEffectPool))
4448 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
4449 *object = This;
4450 return S_OK;
4453 WARN("Interface %s not found\n", debugstr_guid(riid));
4455 return E_NOINTERFACE;
4458 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
4460 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4462 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
4464 return InterlockedIncrement(&This->ref);
4467 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
4469 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4470 ULONG ref = InterlockedDecrement(&This->ref);
4472 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
4474 if (!ref)
4475 HeapFree(GetProcessHeap(), 0, This);
4477 return ref;
4480 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
4482 /*** IUnknown methods ***/
4483 ID3DXEffectPoolImpl_QueryInterface,
4484 ID3DXEffectPoolImpl_AddRef,
4485 ID3DXEffectPoolImpl_Release
4488 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
4490 struct ID3DXEffectPoolImpl *object;
4492 TRACE("(%p)\n", pool);
4494 if (!pool)
4495 return D3DERR_INVALIDCALL;
4497 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4498 if (!object)
4500 ERR("Out of memory\n");
4501 return E_OUTOFMEMORY;
4504 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
4505 object->ref = 1;
4507 *pool = &object->ID3DXEffectPool_iface;
4509 return S_OK;
4512 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4513 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4514 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4516 LPVOID buffer;
4517 HRESULT ret;
4518 DWORD size;
4520 TRACE("(%s): relay\n", debugstr_w(srcfile));
4522 if (!device || !srcfile || !defines)
4523 return D3DERR_INVALIDCALL;
4525 ret = map_view_of_file(srcfile, &buffer, &size);
4527 if (FAILED(ret))
4528 return D3DXERR_INVALIDDATA;
4530 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4531 UnmapViewOfFile(buffer);
4533 return ret;
4536 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
4537 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4538 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4540 LPWSTR srcfileW;
4541 HRESULT ret;
4542 DWORD len;
4544 TRACE("(void): relay\n");
4546 if (!srcfile || !defines)
4547 return D3DERR_INVALIDCALL;
4549 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
4550 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
4551 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
4553 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4554 HeapFree(GetProcessHeap(), 0, srcfileW);
4556 return ret;
4559 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4560 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4561 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4563 TRACE("(void): relay\n");
4564 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
4567 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
4568 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4569 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4571 TRACE("(void): relay\n");
4572 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
4575 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
4576 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4577 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4579 HRSRC resinfo;
4581 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
4583 if (!device || !defines)
4584 return D3DERR_INVALIDCALL;
4586 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
4588 if (resinfo)
4590 LPVOID buffer;
4591 HRESULT ret;
4592 DWORD size;
4594 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4596 if (FAILED(ret))
4597 return D3DXERR_INVALIDDATA;
4599 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4602 return D3DXERR_INVALIDDATA;
4605 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
4606 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4607 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4609 HRSRC resinfo;
4611 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
4613 if (!device || !defines)
4614 return D3DERR_INVALIDCALL;
4616 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
4618 if (resinfo)
4620 LPVOID buffer;
4621 HRESULT ret;
4622 DWORD size;
4624 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4626 if (FAILED(ret))
4627 return D3DXERR_INVALIDDATA;
4629 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4632 return D3DXERR_INVALIDDATA;
4635 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
4636 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4637 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4639 TRACE("(void): relay\n");
4640 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
4643 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
4644 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4645 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4647 TRACE("(void): relay\n");
4648 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
4651 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
4652 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4654 LPVOID buffer;
4655 HRESULT ret;
4656 DWORD size;
4658 TRACE("(%s): relay\n", debugstr_w(srcfile));
4660 if (!srcfile || !defines)
4661 return D3DERR_INVALIDCALL;
4663 ret = map_view_of_file(srcfile, &buffer, &size);
4665 if (FAILED(ret))
4666 return D3DXERR_INVALIDDATA;
4668 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4669 UnmapViewOfFile(buffer);
4671 return ret;
4674 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
4675 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4677 LPWSTR srcfileW;
4678 HRESULT ret;
4679 DWORD len;
4681 TRACE("(void): relay\n");
4683 if (!srcfile || !defines)
4684 return D3DERR_INVALIDCALL;
4686 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
4687 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
4688 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
4690 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
4691 HeapFree(GetProcessHeap(), 0, srcfileW);
4693 return ret;
4696 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
4697 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4699 HRSRC resinfo;
4701 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
4703 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
4705 if (resinfo)
4707 LPVOID buffer;
4708 HRESULT ret;
4709 DWORD size;
4711 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4713 if (FAILED(ret))
4714 return D3DXERR_INVALIDDATA;
4716 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4719 return D3DXERR_INVALIDDATA;
4722 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
4723 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4725 HRSRC resinfo;
4727 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
4729 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
4731 if (resinfo)
4733 LPVOID buffer;
4734 HRESULT ret;
4735 DWORD size;
4737 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4739 if (FAILED(ret))
4740 return D3DXERR_INVALIDDATA;
4742 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4745 return D3DXERR_INVALIDDATA;