d3dx9: Parse effect textures.
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blobee0a5ab97dd1151888d20e7c5f3da4dff46df870
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_TEXTURE:
329 case D3DXPT_TEXTURE1D:
330 case D3DXPT_TEXTURE2D:
331 case D3DXPT_TEXTURE3D:
332 case D3DXPT_TEXTURECUBE:
333 case D3DXPT_PIXELSHADER:
334 case D3DXPT_VERTEXSHADER:
335 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
336 break;
338 default:
339 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
340 break;
344 if (!child)
346 HeapFree(GetProcessHeap(), 0, param->data);
349 /* only the parent has to release name and semantic */
350 if (!element)
352 HeapFree(GetProcessHeap(), 0, param->name);
353 HeapFree(GetProcessHeap(), 0, param->semantic);
356 HeapFree(GetProcessHeap(), 0, param);
359 static void free_pass(D3DXHANDLE handle)
361 unsigned int i;
362 struct d3dx_pass *pass = get_pass_struct(handle);
364 TRACE("Free pass %p\n", pass);
366 if (!pass)
368 return;
371 if (pass->annotation_handles)
373 for (i = 0; i < pass->annotation_count; ++i)
375 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
377 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
380 HeapFree(GetProcessHeap(), 0, pass->name);
381 HeapFree(GetProcessHeap(), 0, pass);
384 static void free_technique(D3DXHANDLE handle)
386 unsigned int i;
387 struct d3dx_technique *technique = get_technique_struct(handle);
389 TRACE("Free technique %p\n", technique);
391 if (!technique)
393 return;
396 if (technique->annotation_handles)
398 for (i = 0; i < technique->annotation_count; ++i)
400 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
402 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
405 if (technique->pass_handles)
407 for (i = 0; i < technique->pass_count; ++i)
409 free_pass(technique->pass_handles[i]);
411 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
414 HeapFree(GetProcessHeap(), 0, technique->name);
415 HeapFree(GetProcessHeap(), 0, technique);
418 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
420 unsigned int i;
422 TRACE("Free base effect %p\n", base);
424 if (base->parameter_handles)
426 for (i = 0; i < base->parameter_count; ++i)
428 free_parameter(base->parameter_handles[i], FALSE, FALSE);
430 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
433 if (base->technique_handles)
435 for (i = 0; i < base->technique_count; ++i)
437 free_technique(base->technique_handles[i]);
439 HeapFree(GetProcessHeap(), 0, base->technique_handles);
443 static void free_effect(struct ID3DXEffectImpl *effect)
445 TRACE("Free effect %p\n", effect);
447 if (effect->base_effect)
449 effect->base_effect->lpVtbl->Release(effect->base_effect);
452 if (effect->pool)
454 effect->pool->lpVtbl->Release(effect->pool);
457 if (effect->manager)
459 IUnknown_Release(effect->manager);
462 IDirect3DDevice9_Release(effect->device);
465 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
467 TRACE("Free effect compiler %p\n", compiler);
469 if (compiler->base_effect)
471 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
475 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
477 INT i;
479 switch (type)
481 case D3DXPT_FLOAT:
482 i = *(FLOAT *)data;
483 break;
485 case D3DXPT_INT:
486 i = *(INT *)data;
487 break;
489 case D3DXPT_BOOL:
490 i = *(BOOL *)data;
491 break;
493 default:
494 i = 0;
495 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
496 break;
499 return i;
502 inline static FLOAT get_float(D3DXPARAMETER_TYPE type, void *data)
504 FLOAT f;
506 switch (type)
508 case D3DXPT_FLOAT:
509 f = *(FLOAT *)data;
510 break;
512 case D3DXPT_INT:
513 f = *(INT *)data;
514 break;
516 case D3DXPT_BOOL:
517 f = *(BOOL *)data;
518 break;
520 default:
521 f = 0.0f;
522 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
523 break;
526 return f;
529 static inline BOOL get_bool(void *data)
531 return (*(DWORD *)data) ? TRUE : FALSE;
534 static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_parameter *parameter, LPCSTR name)
536 UINT element;
537 struct d3dx_parameter *temp_parameter;
538 LPCSTR part;
540 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
542 if (!name || !*name) return parameter;
544 element = atoi(name);
545 part = strchr(name, ']') + 1;
547 if (parameter->element_count > element)
549 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
551 switch (*part++)
553 case '.':
554 return get_parameter_by_name(NULL, temp_parameter, part);
556 case '@':
557 return get_parameter_annotation_by_name(temp_parameter, part);
559 case '\0':
560 TRACE("Returning parameter %p\n", temp_parameter);
561 return temp_parameter;
563 default:
564 FIXME("Unhandled case \"%c\"\n", *--part);
565 break;
569 TRACE("Parameter not found\n");
570 return NULL;
573 static struct d3dx_parameter *get_parameter_annotation_by_name(struct d3dx_parameter *parameter, LPCSTR name)
575 UINT i, length;
576 struct d3dx_parameter *temp_parameter;
577 LPCSTR part;
579 TRACE("parameter %p, name %s\n", parameter, debugstr_a(name));
581 if (!name || !*name) return parameter;
583 length = strcspn( name, "[.@" );
584 part = name + length;
586 for (i = 0; i < parameter->annotation_count; ++i)
588 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
590 if (!strcmp(temp_parameter->name, name))
592 TRACE("Returning parameter %p\n", temp_parameter);
593 return temp_parameter;
595 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
597 switch (*part++)
599 case '.':
600 return get_parameter_by_name(NULL, temp_parameter, part);
602 case '[':
603 return get_parameter_element_by_name(temp_parameter, part);
605 default:
606 FIXME("Unhandled case \"%c\"\n", *--part);
607 break;
612 TRACE("Parameter not found\n");
613 return NULL;
616 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
617 struct d3dx_parameter *parameter, LPCSTR name)
619 UINT i, count, length;
620 struct d3dx_parameter *temp_parameter;
621 D3DXHANDLE *handles;
622 LPCSTR part;
624 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
626 if (!name || !*name) return parameter;
628 if (!parameter)
630 count = base->parameter_count;
631 handles = base->parameter_handles;
633 else
635 count = parameter->member_count;
636 handles = parameter->member_handles;
639 length = strcspn( name, "[.@" );
640 part = name + length;
642 for (i = 0; i < count; i++)
644 temp_parameter = get_parameter_struct(handles[i]);
646 if (!strcmp(temp_parameter->name, name))
648 TRACE("Returning parameter %p\n", temp_parameter);
649 return temp_parameter;
651 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
653 switch (*part++)
655 case '.':
656 return get_parameter_by_name(NULL, temp_parameter, part);
658 case '@':
659 return get_parameter_annotation_by_name(temp_parameter, part);
661 case '[':
662 return get_parameter_element_by_name(temp_parameter, part);
664 default:
665 FIXME("Unhandled case \"%c\"\n", *--part);
666 break;
671 TRACE("Parameter not found\n");
672 return NULL;
675 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
677 return (0xfeff0000 | ((major) << 8) | (minor));
680 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
682 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
685 /*** IUnknown methods ***/
686 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
688 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
690 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
692 if (IsEqualGUID(riid, &IID_IUnknown) ||
693 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
695 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
696 *object = This;
697 return S_OK;
700 ERR("Interface %s not found\n", debugstr_guid(riid));
702 return E_NOINTERFACE;
705 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
707 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
709 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
711 return InterlockedIncrement(&This->ref);
714 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
716 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
717 ULONG ref = InterlockedDecrement(&This->ref);
719 TRACE("iface %p: Release from %u\n", iface, ref + 1);
721 if (!ref)
723 free_base_effect(This);
724 HeapFree(GetProcessHeap(), 0, This);
727 return ref;
730 /*** ID3DXBaseEffect methods ***/
731 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
733 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
735 FIXME("iface %p, desc %p partial stub\n", This, desc);
737 if (!desc)
739 WARN("Invalid argument specified.\n");
740 return D3DERR_INVALIDCALL;
743 /* Todo: add creator and function count */
744 desc->Creator = NULL;
745 desc->Functions = 0;
746 desc->Parameters = This->parameter_count;
747 desc->Techniques = This->technique_count;
749 return D3D_OK;
752 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
754 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
755 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
757 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
759 if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter));
761 if (!desc || !param)
763 WARN("Invalid argument specified.\n");
764 return D3DERR_INVALIDCALL;
767 desc->Name = param->name;
768 desc->Semantic = param->semantic;
769 desc->Class = param->class;
770 desc->Type = param->type;
771 desc->Rows = param->rows;
772 desc->Columns = param->columns;
773 desc->Elements = param->element_count;
774 desc->Annotations = param->annotation_count;
775 desc->StructMembers = param->member_count;
776 desc->Flags = param->flags;
777 desc->Bytes = param->bytes;
779 return D3D_OK;
782 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
784 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
785 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
787 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
789 if (!desc || !tech)
791 WARN("Invalid argument specified.\n");
792 return D3DERR_INVALIDCALL;
795 desc->Name = tech->name;
796 desc->Passes = tech->pass_count;
797 desc->Annotations = tech->annotation_count;
799 return D3D_OK;
802 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
804 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
805 struct d3dx_pass *p = is_valid_pass(This, pass);
807 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
809 if (!desc || !p)
811 WARN("Invalid argument specified.\n");
812 return D3DERR_INVALIDCALL;
815 desc->Name = p->name;
816 desc->Annotations = p->annotation_count;
818 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
819 desc->pVertexShaderFunction = NULL;
820 desc->pVertexShaderFunction = NULL;
822 return D3D_OK;
825 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
827 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
829 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
831 return E_NOTIMPL;
834 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
836 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
837 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
839 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
841 if (!param) param = get_parameter_by_name(This, NULL, parameter);
843 if (!parameter)
845 if (index < This->parameter_count)
847 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
848 return This->parameter_handles[index];
851 else
853 if (param && !param->element_count && index < param->member_count)
855 TRACE("Returning parameter %p\n", param->member_handles[index]);
856 return param->member_handles[index];
860 WARN("Invalid argument specified.\n");
862 return NULL;
865 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
867 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
868 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
869 D3DXHANDLE handle;
871 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
873 if (!param) param = get_parameter_by_name(This, NULL, parameter);
875 if (!name)
877 handle = get_parameter_handle(param);
878 TRACE("Returning parameter %p\n", handle);
879 return handle;
882 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
883 TRACE("Returning parameter %p\n", handle);
885 return handle;
888 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
890 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
891 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
892 struct d3dx_parameter *temp_param;
893 UINT i;
895 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
897 if (!param) param = get_parameter_by_name(This, NULL, parameter);
899 if (!parameter)
901 for (i = 0; i < This->parameter_count; ++i)
903 temp_param = get_parameter_struct(This->parameter_handles[i]);
905 if (!temp_param->semantic)
907 if (!semantic)
909 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
910 return This->parameter_handles[i];
912 continue;
915 if (!strcasecmp(temp_param->semantic, semantic))
917 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
918 return This->parameter_handles[i];
922 else if (param)
924 for (i = 0; i < param->member_count; ++i)
926 temp_param = get_parameter_struct(param->member_handles[i]);
928 if (!temp_param->semantic)
930 if (!semantic)
932 TRACE("Returning parameter %p\n", param->member_handles[i]);
933 return param->member_handles[i];
935 continue;
938 if (!strcasecmp(temp_param->semantic, semantic))
940 TRACE("Returning parameter %p\n", param->member_handles[i]);
941 return param->member_handles[i];
946 WARN("Invalid argument specified\n");
948 return NULL;
951 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
953 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
954 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
956 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
958 if (!param) param = get_parameter_by_name(This, NULL, parameter);
960 if (!param)
962 if (index < This->parameter_count)
964 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
965 return This->parameter_handles[index];
968 else
970 if (index < param->element_count)
972 TRACE("Returning parameter %p\n", param->member_handles[index]);
973 return param->member_handles[index];
977 WARN("Invalid argument specified\n");
979 return NULL;
982 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
984 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
986 TRACE("iface %p, index %u\n", This, index);
988 if (index >= This->technique_count)
990 WARN("Invalid argument specified.\n");
991 return NULL;
994 TRACE("Returning technique %p\n", This->technique_handles[index]);
996 return This->technique_handles[index];
999 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
1001 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1002 unsigned int i;
1004 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
1006 if (!name)
1008 WARN("Invalid argument specified.\n");
1009 return NULL;
1012 for (i = 0; i < This->technique_count; ++i)
1014 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
1016 if (!strcmp(tech->name, name))
1018 TRACE("Returning technique %p\n", This->technique_handles[i]);
1019 return This->technique_handles[i];
1023 WARN("Invalid argument specified.\n");
1025 return NULL;
1028 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
1030 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1031 struct d3dx_technique *tech = is_valid_technique(This, technique);
1033 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1035 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1037 if (tech && index < tech->pass_count)
1039 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1040 return tech->pass_handles[index];
1043 WARN("Invalid argument specified.\n");
1045 return NULL;
1048 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1050 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1051 struct d3dx_technique *tech = is_valid_technique(This, technique);
1053 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1055 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1057 if (tech && name)
1059 unsigned int i;
1061 for (i = 0; i < tech->pass_count; ++i)
1063 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1065 if (!strcmp(pass->name, name))
1067 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1068 return tech->pass_handles[i];
1073 WARN("Invalid argument specified.\n");
1075 return NULL;
1078 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1080 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1082 FIXME("iface %p, index %u stub\n", This, index);
1084 return NULL;
1087 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1089 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1091 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1093 return NULL;
1096 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1098 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1099 struct d3dx_parameter *param = is_valid_parameter(This, object);
1100 struct d3dx_pass *pass = is_valid_pass(This, object);
1101 struct d3dx_technique *technique = is_valid_technique(This, object);
1102 UINT annotation_count = 0;
1103 D3DXHANDLE *annotation_handles = NULL;
1105 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1107 if (pass)
1109 annotation_count = pass->annotation_count;
1110 annotation_handles = pass->annotation_handles;
1112 else if (technique)
1114 annotation_count = technique->annotation_count;
1115 annotation_handles = technique->annotation_handles;
1117 else
1119 if (!param) param = get_parameter_by_name(This, NULL, object);
1121 if (param)
1123 annotation_count = param->annotation_count;
1124 annotation_handles = param->annotation_handles;
1127 /* Todo: add funcs */
1129 if (index < annotation_count)
1131 TRACE("Returning parameter %p\n", annotation_handles[index]);
1132 return annotation_handles[index];
1135 WARN("Invalid argument specified\n");
1137 return NULL;
1140 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1142 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1143 struct d3dx_parameter *param = is_valid_parameter(This, object);
1144 struct d3dx_pass *pass = is_valid_pass(This, object);
1145 struct d3dx_technique *technique = is_valid_technique(This, object);
1146 UINT annotation_count = 0, i;
1147 D3DXHANDLE *annotation_handles = NULL;
1149 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1151 if (!name)
1153 WARN("Invalid argument specified\n");
1154 return NULL;
1157 if (pass)
1159 annotation_count = pass->annotation_count;
1160 annotation_handles = pass->annotation_handles;
1162 else if (technique)
1164 annotation_count = technique->annotation_count;
1165 annotation_handles = technique->annotation_handles;
1167 else
1169 if (!param) param = get_parameter_by_name(This, NULL, object);
1171 if (param)
1173 annotation_count = param->annotation_count;
1174 annotation_handles = param->annotation_handles;
1177 /* Todo: add funcs */
1179 for (i = 0; i < annotation_count; i++)
1181 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1183 if (!strcmp(anno->name, name))
1185 TRACE("Returning parameter %p\n", anno);
1186 return get_parameter_handle(anno);
1190 WARN("Invalid argument specified\n");
1192 return NULL;
1195 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1197 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1199 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1201 return E_NOTIMPL;
1204 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1206 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1207 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1209 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1211 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1213 if (data && param && param->data && param->bytes <= bytes)
1215 if (param->type == D3DXPT_VERTEXSHADER || param->type == D3DXPT_PIXELSHADER
1216 || param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
1217 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
1218 || param->type == D3DXPT_TEXTURECUBE)
1220 UINT i;
1222 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1224 IUnknown *unk = ((IUnknown **)param->data)[i];
1225 if (unk) IUnknown_AddRef(unk);
1226 ((IUnknown **)data)[i] = unk;
1229 else
1231 TRACE("Copy %u bytes\n", param->bytes);
1232 memcpy(data, param->data, param->bytes);
1234 return D3D_OK;
1237 WARN("Invalid argument specified\n");
1239 return D3DERR_INVALIDCALL;
1242 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1244 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1246 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1248 return E_NOTIMPL;
1251 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1253 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1254 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1256 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1258 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1260 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1262 *b = get_bool(param->data);
1263 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1264 return D3D_OK;
1267 WARN("Invalid argument specified\n");
1269 return D3DERR_INVALIDCALL;
1272 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1274 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1276 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1278 return E_NOTIMPL;
1281 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1283 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1285 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1287 return E_NOTIMPL;
1290 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1292 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1294 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1296 return E_NOTIMPL;
1299 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1301 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1302 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1304 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1306 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1308 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1310 *n = get_int(param->type, param->data);
1311 TRACE("Returning %i\n", *n);
1312 return D3D_OK;
1315 WARN("Invalid argument specified\n");
1317 return D3DERR_INVALIDCALL;
1320 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1322 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1324 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1326 return E_NOTIMPL;
1329 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1331 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1333 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1335 return E_NOTIMPL;
1338 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1340 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1342 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1344 return E_NOTIMPL;
1347 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1349 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1350 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1352 TRACE("iface %p, parameter %p, f %p\n", This, parameter, f);
1354 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1356 if (f && param && !param->element_count && param->class == D3DXPC_SCALAR)
1358 f = param->data;
1359 TRACE("Returning %f\n", *f);
1360 return D3D_OK;
1363 WARN("Invalid argument specified\n");
1365 return D3DERR_INVALIDCALL;
1368 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1370 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1372 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1374 return E_NOTIMPL;
1377 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1379 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1381 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1383 return E_NOTIMPL;
1386 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1388 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1390 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1392 return E_NOTIMPL;
1395 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1397 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1399 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1401 return E_NOTIMPL;
1404 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1406 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1408 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1410 return E_NOTIMPL;
1413 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1415 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1417 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1419 return E_NOTIMPL;
1422 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1424 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1426 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1428 return E_NOTIMPL;
1431 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1433 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1435 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1437 return E_NOTIMPL;
1440 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1442 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1444 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1446 return E_NOTIMPL;
1449 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1451 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1453 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1455 return E_NOTIMPL;
1458 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1460 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1462 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1464 return E_NOTIMPL;
1467 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1469 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1471 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1473 return E_NOTIMPL;
1476 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1478 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1480 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1482 return E_NOTIMPL;
1485 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1487 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1489 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1491 return E_NOTIMPL;
1494 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1496 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1498 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1500 return E_NOTIMPL;
1503 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1505 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1507 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1509 return E_NOTIMPL;
1512 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1514 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1516 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1518 return E_NOTIMPL;
1521 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1523 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1525 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1527 return E_NOTIMPL;
1530 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
1532 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1534 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
1536 return E_NOTIMPL;
1539 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
1541 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1542 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1544 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
1546 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1548 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
1550 *string = *(LPCSTR *)param->data;
1551 TRACE("Returning %s\n", debugstr_a(*string));
1552 return D3D_OK;
1555 WARN("Invalid argument specified\n");
1557 return D3DERR_INVALIDCALL;
1560 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
1562 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1564 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1566 return E_NOTIMPL;
1569 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
1571 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1573 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1575 return E_NOTIMPL;
1578 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
1580 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1581 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1583 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
1585 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1587 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
1589 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
1590 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
1591 TRACE("Returning %p\n", *pshader);
1592 return D3D_OK;
1595 WARN("Invalid argument specified\n");
1597 return D3DERR_INVALIDCALL;
1600 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
1602 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1603 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1605 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
1607 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1609 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
1611 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
1612 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
1613 TRACE("Returning %p\n", *vshader);
1614 return D3D_OK;
1617 WARN("Invalid argument specified\n");
1619 return D3DERR_INVALIDCALL;
1622 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
1624 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1626 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
1628 return E_NOTIMPL;
1631 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
1633 /*** IUnknown methods ***/
1634 ID3DXBaseEffectImpl_QueryInterface,
1635 ID3DXBaseEffectImpl_AddRef,
1636 ID3DXBaseEffectImpl_Release,
1637 /*** ID3DXBaseEffect methods ***/
1638 ID3DXBaseEffectImpl_GetDesc,
1639 ID3DXBaseEffectImpl_GetParameterDesc,
1640 ID3DXBaseEffectImpl_GetTechniqueDesc,
1641 ID3DXBaseEffectImpl_GetPassDesc,
1642 ID3DXBaseEffectImpl_GetFunctionDesc,
1643 ID3DXBaseEffectImpl_GetParameter,
1644 ID3DXBaseEffectImpl_GetParameterByName,
1645 ID3DXBaseEffectImpl_GetParameterBySemantic,
1646 ID3DXBaseEffectImpl_GetParameterElement,
1647 ID3DXBaseEffectImpl_GetTechnique,
1648 ID3DXBaseEffectImpl_GetTechniqueByName,
1649 ID3DXBaseEffectImpl_GetPass,
1650 ID3DXBaseEffectImpl_GetPassByName,
1651 ID3DXBaseEffectImpl_GetFunction,
1652 ID3DXBaseEffectImpl_GetFunctionByName,
1653 ID3DXBaseEffectImpl_GetAnnotation,
1654 ID3DXBaseEffectImpl_GetAnnotationByName,
1655 ID3DXBaseEffectImpl_SetValue,
1656 ID3DXBaseEffectImpl_GetValue,
1657 ID3DXBaseEffectImpl_SetBool,
1658 ID3DXBaseEffectImpl_GetBool,
1659 ID3DXBaseEffectImpl_SetBoolArray,
1660 ID3DXBaseEffectImpl_GetBoolArray,
1661 ID3DXBaseEffectImpl_SetInt,
1662 ID3DXBaseEffectImpl_GetInt,
1663 ID3DXBaseEffectImpl_SetIntArray,
1664 ID3DXBaseEffectImpl_GetIntArray,
1665 ID3DXBaseEffectImpl_SetFloat,
1666 ID3DXBaseEffectImpl_GetFloat,
1667 ID3DXBaseEffectImpl_SetFloatArray,
1668 ID3DXBaseEffectImpl_GetFloatArray,
1669 ID3DXBaseEffectImpl_SetVector,
1670 ID3DXBaseEffectImpl_GetVector,
1671 ID3DXBaseEffectImpl_SetVectorArray,
1672 ID3DXBaseEffectImpl_GetVectorArray,
1673 ID3DXBaseEffectImpl_SetMatrix,
1674 ID3DXBaseEffectImpl_GetMatrix,
1675 ID3DXBaseEffectImpl_SetMatrixArray,
1676 ID3DXBaseEffectImpl_GetMatrixArray,
1677 ID3DXBaseEffectImpl_SetMatrixPointerArray,
1678 ID3DXBaseEffectImpl_GetMatrixPointerArray,
1679 ID3DXBaseEffectImpl_SetMatrixTranspose,
1680 ID3DXBaseEffectImpl_GetMatrixTranspose,
1681 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
1682 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
1683 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
1684 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
1685 ID3DXBaseEffectImpl_SetString,
1686 ID3DXBaseEffectImpl_GetString,
1687 ID3DXBaseEffectImpl_SetTexture,
1688 ID3DXBaseEffectImpl_GetTexture,
1689 ID3DXBaseEffectImpl_GetPixelShader,
1690 ID3DXBaseEffectImpl_GetVertexShader,
1691 ID3DXBaseEffectImpl_SetArrayRange,
1694 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
1696 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
1699 /*** IUnknown methods ***/
1700 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
1702 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1704 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
1706 if (IsEqualGUID(riid, &IID_IUnknown) ||
1707 IsEqualGUID(riid, &IID_ID3DXEffect))
1709 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
1710 *object = This;
1711 return S_OK;
1714 ERR("Interface %s not found\n", debugstr_guid(riid));
1716 return E_NOINTERFACE;
1719 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
1721 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1723 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
1725 return InterlockedIncrement(&This->ref);
1728 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
1730 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1731 ULONG ref = InterlockedDecrement(&This->ref);
1733 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
1735 if (!ref)
1737 free_effect(This);
1738 HeapFree(GetProcessHeap(), 0, This);
1741 return ref;
1744 /*** ID3DXBaseEffect methods ***/
1745 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
1747 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1748 ID3DXBaseEffect *base = This->base_effect;
1750 TRACE("Forward iface %p, base %p\n", This, base);
1752 return ID3DXBaseEffectImpl_GetDesc(base, desc);
1755 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1757 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1758 ID3DXBaseEffect *base = This->base_effect;
1760 TRACE("Forward iface %p, base %p\n", This, base);
1762 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
1765 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1767 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1768 ID3DXBaseEffect *base = This->base_effect;
1770 TRACE("Forward iface %p, base %p\n", This, base);
1772 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
1775 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1777 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1778 ID3DXBaseEffect *base = This->base_effect;
1780 TRACE("Forward iface %p, base %p\n", This, base);
1782 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
1785 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1787 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1788 ID3DXBaseEffect *base = This->base_effect;
1790 TRACE("Forward iface %p, base %p\n", This, base);
1792 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
1795 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
1797 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1798 ID3DXBaseEffect *base = This->base_effect;
1800 TRACE("Forward iface %p, base %p\n", This, base);
1802 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
1805 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1807 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1808 ID3DXBaseEffect *base = This->base_effect;
1810 TRACE("Forward iface %p, base %p\n", This, base);
1812 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
1815 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1817 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1818 ID3DXBaseEffect *base = This->base_effect;
1820 TRACE("Forward iface %p, base %p\n", This, base);
1822 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
1825 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
1827 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1828 ID3DXBaseEffect *base = This->base_effect;
1830 TRACE("Forward iface %p, base %p\n", This, base);
1832 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
1835 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
1837 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1838 ID3DXBaseEffect *base = This->base_effect;
1840 TRACE("Forward iface %p, base %p\n", This, base);
1842 return ID3DXBaseEffectImpl_GetTechnique(base, index);
1845 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
1847 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1848 ID3DXBaseEffect *base = This->base_effect;
1850 TRACE("Forward iface %p, base %p\n", This, base);
1852 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
1855 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
1857 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1858 ID3DXBaseEffect *base = This->base_effect;
1860 TRACE("Forward iface %p, base %p\n", This, base);
1862 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
1865 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
1867 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1868 ID3DXBaseEffect *base = This->base_effect;
1870 TRACE("Forward iface %p, base %p\n", This, base);
1872 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
1875 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
1877 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1878 ID3DXBaseEffect *base = This->base_effect;
1880 TRACE("Forward iface %p, base %p\n", This, base);
1882 return ID3DXBaseEffectImpl_GetFunction(base, index);
1885 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
1887 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1888 ID3DXBaseEffect *base = This->base_effect;
1890 TRACE("Forward iface %p, base %p\n", This, base);
1892 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
1895 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
1897 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1898 ID3DXBaseEffect *base = This->base_effect;
1900 TRACE("Forward iface %p, base %p\n", This, base);
1902 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
1905 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
1907 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1908 ID3DXBaseEffect *base = This->base_effect;
1910 TRACE("Forward iface %p, base %p\n", This, base);
1912 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
1915 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1917 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1918 ID3DXBaseEffect *base = This->base_effect;
1920 TRACE("Forward iface %p, base %p\n", This, base);
1922 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
1925 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1927 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1928 ID3DXBaseEffect *base = This->base_effect;
1930 TRACE("Forward iface %p, base %p\n", This, base);
1932 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
1935 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
1937 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1938 ID3DXBaseEffect *base = This->base_effect;
1940 TRACE("Forward iface %p, base %p\n", This, base);
1942 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
1945 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
1947 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1948 ID3DXBaseEffect *base = This->base_effect;
1950 TRACE("Forward iface %p, base %p\n", This, base);
1952 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
1955 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1957 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1958 ID3DXBaseEffect *base = This->base_effect;
1960 TRACE("Forward iface %p, base %p\n", This, base);
1962 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
1965 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1967 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1968 ID3DXBaseEffect *base = This->base_effect;
1970 TRACE("Forward iface %p, base %p\n", This, base);
1972 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
1975 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
1977 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1978 ID3DXBaseEffect *base = This->base_effect;
1980 TRACE("Forward iface %p, base %p\n", This, base);
1982 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
1985 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
1987 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1988 ID3DXBaseEffect *base = This->base_effect;
1990 TRACE("Forward iface %p, base %p\n", This, base);
1992 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
1995 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1997 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1998 ID3DXBaseEffect *base = This->base_effect;
2000 TRACE("Forward iface %p, base %p\n", This, base);
2002 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2005 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2007 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2008 ID3DXBaseEffect *base = This->base_effect;
2010 TRACE("Forward iface %p, base %p\n", This, base);
2012 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2015 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2017 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2018 ID3DXBaseEffect *base = This->base_effect;
2020 TRACE("Forward iface %p, base %p\n", This, base);
2022 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2025 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2027 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2028 ID3DXBaseEffect *base = This->base_effect;
2030 TRACE("Forward iface %p, base %p\n", This, base);
2032 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2035 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2037 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2038 ID3DXBaseEffect *base = This->base_effect;
2040 TRACE("Forward iface %p, base %p\n", This, base);
2042 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2045 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2047 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2048 ID3DXBaseEffect *base = This->base_effect;
2050 TRACE("Forward iface %p, base %p\n", This, base);
2052 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2055 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2057 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2058 ID3DXBaseEffect *base = This->base_effect;
2060 TRACE("Forward iface %p, base %p\n", This, base);
2062 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2065 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2067 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2068 ID3DXBaseEffect *base = This->base_effect;
2070 TRACE("Forward iface %p, base %p\n", This, base);
2072 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2075 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2077 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2078 ID3DXBaseEffect *base = This->base_effect;
2080 TRACE("Forward iface %p, base %p\n", This, base);
2082 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2085 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2087 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2088 ID3DXBaseEffect *base = This->base_effect;
2090 TRACE("Forward iface %p, base %p\n", This, base);
2092 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2095 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2097 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2098 ID3DXBaseEffect *base = This->base_effect;
2100 TRACE("Forward iface %p, base %p\n", This, base);
2102 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2105 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2107 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2108 ID3DXBaseEffect *base = This->base_effect;
2110 TRACE("Forward iface %p, base %p\n", This, base);
2112 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2115 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2117 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2118 ID3DXBaseEffect *base = This->base_effect;
2120 TRACE("Forward iface %p, base %p\n", This, base);
2122 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2125 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2127 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2128 ID3DXBaseEffect *base = This->base_effect;
2130 TRACE("Forward iface %p, base %p\n", This, base);
2132 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2135 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2137 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2138 ID3DXBaseEffect *base = This->base_effect;
2140 TRACE("Forward iface %p, base %p\n", This, base);
2142 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2145 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2147 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2148 ID3DXBaseEffect *base = This->base_effect;
2150 TRACE("Forward iface %p, base %p\n", This, base);
2152 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2155 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2157 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2158 ID3DXBaseEffect *base = This->base_effect;
2160 TRACE("Forward iface %p, base %p\n", This, base);
2162 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2165 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2167 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2168 ID3DXBaseEffect *base = This->base_effect;
2170 TRACE("Forward iface %p, base %p\n", This, base);
2172 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2175 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2177 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2178 ID3DXBaseEffect *base = This->base_effect;
2180 TRACE("Forward iface %p, base %p\n", This, base);
2182 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2185 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2187 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2188 ID3DXBaseEffect *base = This->base_effect;
2190 TRACE("Forward iface %p, base %p\n", This, base);
2192 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2195 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2197 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2198 ID3DXBaseEffect *base = This->base_effect;
2200 TRACE("Forward iface %p, base %p\n", This, base);
2202 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2205 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2207 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2208 ID3DXBaseEffect *base = This->base_effect;
2210 TRACE("Forward iface %p, base %p\n", This, base);
2212 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2215 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2217 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2218 ID3DXBaseEffect *base = This->base_effect;
2220 TRACE("Forward iface %p, base %p\n", This, base);
2222 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2225 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2227 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2228 ID3DXBaseEffect *base = This->base_effect;
2230 TRACE("Forward iface %p, base %p\n", This, base);
2232 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2235 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2237 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2238 ID3DXBaseEffect *base = This->base_effect;
2240 TRACE("Forward iface %p, base %p\n", This, base);
2242 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2245 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2247 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2248 ID3DXBaseEffect *base = This->base_effect;
2250 TRACE("Forward iface %p, base %p\n", This, base);
2252 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2255 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2257 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2258 ID3DXBaseEffect *base = This->base_effect;
2260 TRACE("Forward iface %p, base %p\n", This, base);
2262 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2265 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2267 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2268 ID3DXBaseEffect *base = This->base_effect;
2270 TRACE("Forward iface %p, base %p\n", This, base);
2272 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2275 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2277 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2278 ID3DXBaseEffect *base = This->base_effect;
2280 TRACE("Forward iface %p, base %p\n", This, base);
2282 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2285 /*** ID3DXEffect methods ***/
2286 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2288 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2290 TRACE("iface %p, pool %p\n", This, pool);
2292 if (!pool)
2294 WARN("Invalid argument supplied.\n");
2295 return D3DERR_INVALIDCALL;
2298 if (This->pool)
2300 This->pool->lpVtbl->AddRef(This->pool);
2303 *pool = This->pool;
2305 TRACE("Returning pool %p\n", *pool);
2307 return S_OK;
2310 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2312 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2314 FIXME("(%p)->(%p): stub\n", This, technique);
2316 return E_NOTIMPL;
2319 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect* iface)
2321 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2323 FIXME("(%p)->(): stub\n", This);
2325 return NULL;
2328 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2330 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2332 FIXME("(%p)->(%p): stub\n", This, technique);
2334 return D3D_OK;
2337 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2339 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2341 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2343 return E_NOTIMPL;
2346 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2348 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2350 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2352 return FALSE;
2355 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect* iface, UINT *passes, DWORD flags)
2357 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2359 FIXME("(%p)->(%p, %#x): stub\n", This, passes, flags);
2361 return E_NOTIMPL;
2364 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect* iface, UINT pass)
2366 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2368 FIXME("(%p)->(%u): stub\n", This, pass);
2370 return E_NOTIMPL;
2373 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2375 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2377 FIXME("(%p)->(): stub\n", This);
2379 return E_NOTIMPL;
2382 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
2384 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2386 FIXME("(%p)->(): stub\n", This);
2388 return E_NOTIMPL;
2391 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2393 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2395 FIXME("(%p)->(): stub\n", This);
2397 return E_NOTIMPL;
2400 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2402 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2404 TRACE("iface %p, device %p\n", This, device);
2406 if (!device)
2408 WARN("Invalid argument supplied.\n");
2409 return D3DERR_INVALIDCALL;
2412 IDirect3DDevice9_AddRef(This->device);
2414 *device = This->device;
2416 TRACE("Returning device %p\n", *device);
2418 return S_OK;
2421 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2423 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2425 FIXME("(%p)->(): stub\n", This);
2427 return E_NOTIMPL;
2430 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2432 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2434 FIXME("(%p)->(): stub\n", This);
2436 return E_NOTIMPL;
2439 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
2441 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2443 TRACE("iface %p, manager %p\n", This, manager);
2445 if (This->manager) IUnknown_Release(This->manager);
2446 if (manager) IUnknown_AddRef(manager);
2448 This->manager = manager;
2450 return D3D_OK;
2453 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
2455 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2457 TRACE("iface %p, manager %p\n", This, manager);
2459 if (!manager)
2461 WARN("Invalid argument supplied.\n");
2462 return D3DERR_INVALIDCALL;
2465 if (This->manager) IUnknown_AddRef(This->manager);
2466 *manager = This->manager;
2468 return D3D_OK;
2471 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2473 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2475 FIXME("(%p)->(): stub\n", This);
2477 return E_NOTIMPL;
2480 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
2482 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2484 FIXME("(%p)->(): stub\n", This);
2486 return NULL;
2489 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2491 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2493 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2495 return E_NOTIMPL;
2498 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2500 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2502 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2504 return E_NOTIMPL;
2507 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
2509 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2511 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
2513 return E_NOTIMPL;
2516 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
2518 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2520 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
2522 return E_NOTIMPL;
2525 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
2527 /*** IUnknown methods ***/
2528 ID3DXEffectImpl_QueryInterface,
2529 ID3DXEffectImpl_AddRef,
2530 ID3DXEffectImpl_Release,
2531 /*** ID3DXBaseEffect methods ***/
2532 ID3DXEffectImpl_GetDesc,
2533 ID3DXEffectImpl_GetParameterDesc,
2534 ID3DXEffectImpl_GetTechniqueDesc,
2535 ID3DXEffectImpl_GetPassDesc,
2536 ID3DXEffectImpl_GetFunctionDesc,
2537 ID3DXEffectImpl_GetParameter,
2538 ID3DXEffectImpl_GetParameterByName,
2539 ID3DXEffectImpl_GetParameterBySemantic,
2540 ID3DXEffectImpl_GetParameterElement,
2541 ID3DXEffectImpl_GetTechnique,
2542 ID3DXEffectImpl_GetTechniqueByName,
2543 ID3DXEffectImpl_GetPass,
2544 ID3DXEffectImpl_GetPassByName,
2545 ID3DXEffectImpl_GetFunction,
2546 ID3DXEffectImpl_GetFunctionByName,
2547 ID3DXEffectImpl_GetAnnotation,
2548 ID3DXEffectImpl_GetAnnotationByName,
2549 ID3DXEffectImpl_SetValue,
2550 ID3DXEffectImpl_GetValue,
2551 ID3DXEffectImpl_SetBool,
2552 ID3DXEffectImpl_GetBool,
2553 ID3DXEffectImpl_SetBoolArray,
2554 ID3DXEffectImpl_GetBoolArray,
2555 ID3DXEffectImpl_SetInt,
2556 ID3DXEffectImpl_GetInt,
2557 ID3DXEffectImpl_SetIntArray,
2558 ID3DXEffectImpl_GetIntArray,
2559 ID3DXEffectImpl_SetFloat,
2560 ID3DXEffectImpl_GetFloat,
2561 ID3DXEffectImpl_SetFloatArray,
2562 ID3DXEffectImpl_GetFloatArray,
2563 ID3DXEffectImpl_SetVector,
2564 ID3DXEffectImpl_GetVector,
2565 ID3DXEffectImpl_SetVectorArray,
2566 ID3DXEffectImpl_GetVectorArray,
2567 ID3DXEffectImpl_SetMatrix,
2568 ID3DXEffectImpl_GetMatrix,
2569 ID3DXEffectImpl_SetMatrixArray,
2570 ID3DXEffectImpl_GetMatrixArray,
2571 ID3DXEffectImpl_SetMatrixPointerArray,
2572 ID3DXEffectImpl_GetMatrixPointerArray,
2573 ID3DXEffectImpl_SetMatrixTranspose,
2574 ID3DXEffectImpl_GetMatrixTranspose,
2575 ID3DXEffectImpl_SetMatrixTransposeArray,
2576 ID3DXEffectImpl_GetMatrixTransposeArray,
2577 ID3DXEffectImpl_SetMatrixTransposePointerArray,
2578 ID3DXEffectImpl_GetMatrixTransposePointerArray,
2579 ID3DXEffectImpl_SetString,
2580 ID3DXEffectImpl_GetString,
2581 ID3DXEffectImpl_SetTexture,
2582 ID3DXEffectImpl_GetTexture,
2583 ID3DXEffectImpl_GetPixelShader,
2584 ID3DXEffectImpl_GetVertexShader,
2585 ID3DXEffectImpl_SetArrayRange,
2586 /*** ID3DXEffect methods ***/
2587 ID3DXEffectImpl_GetPool,
2588 ID3DXEffectImpl_SetTechnique,
2589 ID3DXEffectImpl_GetCurrentTechnique,
2590 ID3DXEffectImpl_ValidateTechnique,
2591 ID3DXEffectImpl_FindNextValidTechnique,
2592 ID3DXEffectImpl_IsParameterUsed,
2593 ID3DXEffectImpl_Begin,
2594 ID3DXEffectImpl_BeginPass,
2595 ID3DXEffectImpl_CommitChanges,
2596 ID3DXEffectImpl_EndPass,
2597 ID3DXEffectImpl_End,
2598 ID3DXEffectImpl_GetDevice,
2599 ID3DXEffectImpl_OnLostDevice,
2600 ID3DXEffectImpl_OnResetDevice,
2601 ID3DXEffectImpl_SetStateManager,
2602 ID3DXEffectImpl_GetStateManager,
2603 ID3DXEffectImpl_BeginParameterBlock,
2604 ID3DXEffectImpl_EndParameterBlock,
2605 ID3DXEffectImpl_ApplyParameterBlock,
2606 ID3DXEffectImpl_DeleteParameterBlock,
2607 ID3DXEffectImpl_CloneEffect,
2608 ID3DXEffectImpl_SetRawValue
2611 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
2613 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
2616 /*** IUnknown methods ***/
2617 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
2619 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2621 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
2623 if (IsEqualGUID(riid, &IID_IUnknown) ||
2624 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
2626 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
2627 *object = This;
2628 return S_OK;
2631 ERR("Interface %s not found\n", debugstr_guid(riid));
2633 return E_NOINTERFACE;
2636 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
2638 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2640 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
2642 return InterlockedIncrement(&This->ref);
2645 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
2647 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2648 ULONG ref = InterlockedDecrement(&This->ref);
2650 TRACE("iface %p: Release from %u\n", iface, ref + 1);
2652 if (!ref)
2654 free_effect_compiler(This);
2655 HeapFree(GetProcessHeap(), 0, This);
2658 return ref;
2661 /*** ID3DXBaseEffect methods ***/
2662 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
2664 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2665 ID3DXBaseEffect *base = This->base_effect;
2667 TRACE("Forward iface %p, base %p\n", This, base);
2669 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2672 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2674 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2675 ID3DXBaseEffect *base = This->base_effect;
2677 TRACE("Forward iface %p, base %p\n", This, base);
2679 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2682 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2684 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2685 ID3DXBaseEffect *base = This->base_effect;
2687 TRACE("Forward iface %p, base %p\n", This, base);
2689 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2692 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2694 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2695 ID3DXBaseEffect *base = This->base_effect;
2697 TRACE("Forward iface %p, base %p\n", This, base);
2699 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2702 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2704 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2705 ID3DXBaseEffect *base = This->base_effect;
2707 TRACE("Forward iface %p, base %p\n", This, base);
2709 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2712 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
2714 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2715 ID3DXBaseEffect *base = This->base_effect;
2717 TRACE("Forward iface %p, base %p\n", This, base);
2719 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2722 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
2724 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2725 ID3DXBaseEffect *base = This->base_effect;
2727 TRACE("Forward iface %p, base %p\n", This, base);
2729 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2732 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
2734 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2735 ID3DXBaseEffect *base = This->base_effect;
2737 TRACE("Forward iface %p, base %p\n", This, base);
2739 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2742 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
2744 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2745 ID3DXBaseEffect *base = This->base_effect;
2747 TRACE("Forward iface %p, base %p\n", This, base);
2749 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2752 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
2754 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2755 ID3DXBaseEffect *base = This->base_effect;
2757 TRACE("Forward iface %p, base %p\n", This, base);
2759 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2762 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
2764 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2765 ID3DXBaseEffect *base = This->base_effect;
2767 TRACE("Forward iface %p, base %p\n", This, base);
2769 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2772 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
2774 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2775 ID3DXBaseEffect *base = This->base_effect;
2777 TRACE("Forward iface %p, base %p\n", This, base);
2779 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2782 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
2784 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2785 ID3DXBaseEffect *base = This->base_effect;
2787 TRACE("Forward iface %p, base %p\n", This, base);
2789 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2792 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
2794 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2795 ID3DXBaseEffect *base = This->base_effect;
2797 TRACE("Forward iface %p, base %p\n", This, base);
2799 return ID3DXBaseEffectImpl_GetFunction(base, index);
2802 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
2804 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2805 ID3DXBaseEffect *base = This->base_effect;
2807 TRACE("Forward iface %p, base %p\n", This, base);
2809 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2812 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
2814 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2815 ID3DXBaseEffect *base = This->base_effect;
2817 TRACE("Forward iface %p, base %p\n", This, base);
2819 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2822 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
2824 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2825 ID3DXBaseEffect *base = This->base_effect;
2827 TRACE("Forward iface %p, base %p\n", This, base);
2829 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2832 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2834 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2835 ID3DXBaseEffect *base = This->base_effect;
2837 TRACE("Forward iface %p, base %p\n", This, base);
2839 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2842 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2844 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2845 ID3DXBaseEffect *base = This->base_effect;
2847 TRACE("Forward iface %p, base %p\n", This, base);
2849 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2852 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
2854 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2855 ID3DXBaseEffect *base = This->base_effect;
2857 TRACE("Forward iface %p, base %p\n", This, base);
2859 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2862 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
2864 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2865 ID3DXBaseEffect *base = This->base_effect;
2867 TRACE("Forward iface %p, base %p\n", This, base);
2869 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2872 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2874 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2875 ID3DXBaseEffect *base = This->base_effect;
2877 TRACE("Forward iface %p, base %p\n", This, base);
2879 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2882 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2884 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2885 ID3DXBaseEffect *base = This->base_effect;
2887 TRACE("Forward iface %p, base %p\n", This, base);
2889 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2892 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
2894 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2895 ID3DXBaseEffect *base = This->base_effect;
2897 TRACE("Forward iface %p, base %p\n", This, base);
2899 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2902 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
2904 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2905 ID3DXBaseEffect *base = This->base_effect;
2907 TRACE("Forward iface %p, base %p\n", This, base);
2909 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2912 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2914 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2915 ID3DXBaseEffect *base = This->base_effect;
2917 TRACE("Forward iface %p, base %p\n", This, base);
2919 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2922 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
2924 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2925 ID3DXBaseEffect *base = This->base_effect;
2927 TRACE("Forward iface %p, base %p\n", This, base);
2929 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2932 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
2934 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2935 ID3DXBaseEffect *base = This->base_effect;
2937 TRACE("Forward iface %p, base %p\n", This, base);
2939 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2942 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
2944 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2945 ID3DXBaseEffect *base = This->base_effect;
2947 TRACE("Forward iface %p, base %p\n", This, base);
2949 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2952 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2954 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2955 ID3DXBaseEffect *base = This->base_effect;
2957 TRACE("Forward iface %p, base %p\n", This, base);
2959 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2962 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2964 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2965 ID3DXBaseEffect *base = This->base_effect;
2967 TRACE("Forward iface %p, base %p\n", This, base);
2969 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2972 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2974 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2975 ID3DXBaseEffect *base = This->base_effect;
2977 TRACE("Forward iface %p, base %p\n", This, base);
2979 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2982 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2984 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2985 ID3DXBaseEffect *base = This->base_effect;
2987 TRACE("Forward iface %p, base %p\n", This, base);
2989 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2992 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2994 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2995 ID3DXBaseEffect *base = This->base_effect;
2997 TRACE("Forward iface %p, base %p\n", This, base);
2999 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3002 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3004 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3005 ID3DXBaseEffect *base = This->base_effect;
3007 TRACE("Forward iface %p, base %p\n", This, base);
3009 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3012 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3014 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3015 ID3DXBaseEffect *base = This->base_effect;
3017 TRACE("Forward iface %p, base %p\n", This, base);
3019 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3022 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3024 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3025 ID3DXBaseEffect *base = This->base_effect;
3027 TRACE("Forward iface %p, base %p\n", This, base);
3029 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3032 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3034 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3035 ID3DXBaseEffect *base = This->base_effect;
3037 TRACE("Forward iface %p, base %p\n", This, base);
3039 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3042 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3044 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3045 ID3DXBaseEffect *base = This->base_effect;
3047 TRACE("Forward iface %p, base %p\n", This, base);
3049 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3052 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3054 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3055 ID3DXBaseEffect *base = This->base_effect;
3057 TRACE("Forward iface %p, base %p\n", This, base);
3059 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3062 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3064 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3065 ID3DXBaseEffect *base = This->base_effect;
3067 TRACE("Forward iface %p, base %p\n", This, base);
3069 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3072 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3074 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3075 ID3DXBaseEffect *base = This->base_effect;
3077 TRACE("Forward iface %p, base %p\n", This, base);
3079 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3082 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3084 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3085 ID3DXBaseEffect *base = This->base_effect;
3087 TRACE("Forward iface %p, base %p\n", This, base);
3089 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3092 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3094 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3095 ID3DXBaseEffect *base = This->base_effect;
3097 TRACE("Forward iface %p, base %p\n", This, base);
3099 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3102 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3104 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3105 ID3DXBaseEffect *base = This->base_effect;
3107 TRACE("Forward iface %p, base %p\n", This, base);
3109 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3112 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3114 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3115 ID3DXBaseEffect *base = This->base_effect;
3117 TRACE("Forward iface %p, base %p\n", This, base);
3119 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3122 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3124 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3125 ID3DXBaseEffect *base = This->base_effect;
3127 TRACE("Forward iface %p, base %p\n", This, base);
3129 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3132 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3134 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3135 ID3DXBaseEffect *base = This->base_effect;
3137 TRACE("Forward iface %p, base %p\n", This, base);
3139 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3142 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3144 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3145 ID3DXBaseEffect *base = This->base_effect;
3147 TRACE("Forward iface %p, base %p\n", This, base);
3149 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3152 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3154 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3155 ID3DXBaseEffect *base = This->base_effect;
3157 TRACE("Forward iface %p, base %p\n", This, base);
3159 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3162 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3164 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3165 ID3DXBaseEffect *base = This->base_effect;
3167 TRACE("Forward iface %p, base %p\n", This, base);
3169 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3172 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3174 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3175 ID3DXBaseEffect *base = This->base_effect;
3177 TRACE("Forward iface %p, base %p\n", This, base);
3179 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3182 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3184 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3185 ID3DXBaseEffect *base = This->base_effect;
3187 TRACE("Forward iface %p, base %p\n", This, base);
3189 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3192 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3194 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3195 ID3DXBaseEffect *base = This->base_effect;
3197 TRACE("Forward iface %p, base %p\n", This, base);
3199 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3202 /*** ID3DXEffectCompiler methods ***/
3203 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3205 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3207 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3209 return E_NOTIMPL;
3212 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3214 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3216 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3218 return E_NOTIMPL;
3221 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3222 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3224 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3226 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3228 return E_NOTIMPL;
3231 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3232 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3234 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3236 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3237 This, function, target, flags, shader, error_msgs, constant_table);
3239 return E_NOTIMPL;
3242 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3244 /*** IUnknown methods ***/
3245 ID3DXEffectCompilerImpl_QueryInterface,
3246 ID3DXEffectCompilerImpl_AddRef,
3247 ID3DXEffectCompilerImpl_Release,
3248 /*** ID3DXBaseEffect methods ***/
3249 ID3DXEffectCompilerImpl_GetDesc,
3250 ID3DXEffectCompilerImpl_GetParameterDesc,
3251 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3252 ID3DXEffectCompilerImpl_GetPassDesc,
3253 ID3DXEffectCompilerImpl_GetFunctionDesc,
3254 ID3DXEffectCompilerImpl_GetParameter,
3255 ID3DXEffectCompilerImpl_GetParameterByName,
3256 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3257 ID3DXEffectCompilerImpl_GetParameterElement,
3258 ID3DXEffectCompilerImpl_GetTechnique,
3259 ID3DXEffectCompilerImpl_GetTechniqueByName,
3260 ID3DXEffectCompilerImpl_GetPass,
3261 ID3DXEffectCompilerImpl_GetPassByName,
3262 ID3DXEffectCompilerImpl_GetFunction,
3263 ID3DXEffectCompilerImpl_GetFunctionByName,
3264 ID3DXEffectCompilerImpl_GetAnnotation,
3265 ID3DXEffectCompilerImpl_GetAnnotationByName,
3266 ID3DXEffectCompilerImpl_SetValue,
3267 ID3DXEffectCompilerImpl_GetValue,
3268 ID3DXEffectCompilerImpl_SetBool,
3269 ID3DXEffectCompilerImpl_GetBool,
3270 ID3DXEffectCompilerImpl_SetBoolArray,
3271 ID3DXEffectCompilerImpl_GetBoolArray,
3272 ID3DXEffectCompilerImpl_SetInt,
3273 ID3DXEffectCompilerImpl_GetInt,
3274 ID3DXEffectCompilerImpl_SetIntArray,
3275 ID3DXEffectCompilerImpl_GetIntArray,
3276 ID3DXEffectCompilerImpl_SetFloat,
3277 ID3DXEffectCompilerImpl_GetFloat,
3278 ID3DXEffectCompilerImpl_SetFloatArray,
3279 ID3DXEffectCompilerImpl_GetFloatArray,
3280 ID3DXEffectCompilerImpl_SetVector,
3281 ID3DXEffectCompilerImpl_GetVector,
3282 ID3DXEffectCompilerImpl_SetVectorArray,
3283 ID3DXEffectCompilerImpl_GetVectorArray,
3284 ID3DXEffectCompilerImpl_SetMatrix,
3285 ID3DXEffectCompilerImpl_GetMatrix,
3286 ID3DXEffectCompilerImpl_SetMatrixArray,
3287 ID3DXEffectCompilerImpl_GetMatrixArray,
3288 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3289 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3290 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3291 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3292 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3293 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3294 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3295 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3296 ID3DXEffectCompilerImpl_SetString,
3297 ID3DXEffectCompilerImpl_GetString,
3298 ID3DXEffectCompilerImpl_SetTexture,
3299 ID3DXEffectCompilerImpl_GetTexture,
3300 ID3DXEffectCompilerImpl_GetPixelShader,
3301 ID3DXEffectCompilerImpl_GetVertexShader,
3302 ID3DXEffectCompilerImpl_SetArrayRange,
3303 /*** ID3DXEffectCompiler methods ***/
3304 ID3DXEffectCompilerImpl_SetLiteral,
3305 ID3DXEffectCompilerImpl_GetLiteral,
3306 ID3DXEffectCompilerImpl_CompileEffect,
3307 ID3DXEffectCompilerImpl_CompileShader,
3310 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char **ptr)
3312 unsigned int i;
3313 HRESULT hr;
3314 UINT old_size = 0;
3315 DWORD id;
3317 if (param->element_count)
3319 param->data = value;
3321 for (i = 0; i < param->element_count; ++i)
3323 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3325 hr = d3dx9_parse_value(member, (char *)value + old_size, ptr);
3326 if (hr != D3D_OK)
3328 WARN("Failed to parse value\n");
3329 return hr;
3332 old_size += member->bytes;
3335 return D3D_OK;
3338 switch(param->class)
3340 case D3DXPC_SCALAR:
3341 case D3DXPC_VECTOR:
3342 case D3DXPC_MATRIX_ROWS:
3343 case D3DXPC_MATRIX_COLUMNS:
3344 param->data = value;
3345 break;
3347 case D3DXPC_STRUCT:
3348 param->data = value;
3350 for (i = 0; i < param->member_count; ++i)
3352 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3354 hr = d3dx9_parse_value(member, (char *)value + old_size, ptr);
3355 if (hr != D3D_OK)
3357 WARN("Failed to parse value\n");
3358 return hr;
3361 old_size += member->bytes;
3363 break;
3365 case D3DXPC_OBJECT:
3366 switch (param->type)
3368 case D3DXPT_STRING:
3369 case D3DXPT_TEXTURE:
3370 case D3DXPT_TEXTURE1D:
3371 case D3DXPT_TEXTURE2D:
3372 case D3DXPT_TEXTURE3D:
3373 case D3DXPT_TEXTURECUBE:
3374 case D3DXPT_PIXELSHADER:
3375 case D3DXPT_VERTEXSHADER:
3376 read_dword(ptr, &id);
3377 TRACE("Id: %u\n", id);
3378 param->base->objects[id] = get_parameter_handle(param);
3379 param->data = value;
3380 break;
3382 default:
3383 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3384 break;
3386 break;
3388 default:
3389 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3390 break;
3393 return D3D_OK;
3396 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *ptr)
3398 UINT size = param->bytes;
3399 HRESULT hr;
3400 void *value = NULL;
3402 TRACE("param size: %u\n", size);
3404 value = HeapAlloc(GetProcessHeap(), 0, size);
3405 if (!value)
3407 ERR("Failed to allocate data memory.\n");
3408 return E_OUTOFMEMORY;
3411 TRACE("Data: %s.\n", debugstr_an(ptr, size));
3412 memcpy(value, ptr, size);
3414 hr = d3dx9_parse_value(param, value, &ptr);
3415 if (hr != D3D_OK)
3417 WARN("Failed to parse value\n");
3418 HeapFree(GetProcessHeap(), 0, value);
3419 return hr;
3422 param->data = value;
3424 return D3D_OK;
3427 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
3429 DWORD size;
3431 read_dword(&ptr, &size);
3432 TRACE("Name size: %#x\n", size);
3434 if (!size)
3436 return D3D_OK;
3439 *name = HeapAlloc(GetProcessHeap(), 0, size);
3440 if (!*name)
3442 ERR("Failed to allocate name memory.\n");
3443 return E_OUTOFMEMORY;
3446 TRACE("Name: %s.\n", debugstr_an(ptr, size));
3447 memcpy(*name, ptr, size);
3449 return D3D_OK;
3452 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr)
3454 DWORD size;
3455 HRESULT hr;
3457 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
3459 read_dword(ptr, &size);
3460 TRACE("Data size: %#x\n", size);
3462 if (!size)
3464 TRACE("Size is 0\n");
3465 *(void **)param->data = NULL;
3466 return D3D_OK;
3469 switch (param->type)
3471 case D3DXPT_STRING:
3472 /* re-read with size (sizeof(DWORD) = 4) */
3473 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
3474 if (hr != D3D_OK)
3476 WARN("Failed to parse string data\n");
3477 return hr;
3479 break;
3481 case D3DXPT_VERTEXSHADER:
3482 hr = IDirect3DDevice9_CreateVertexShader(param->base->effect->device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
3483 if (hr != D3D_OK)
3485 WARN("Failed to create vertex shader\n");
3486 return hr;
3488 break;
3490 case D3DXPT_PIXELSHADER:
3491 hr = IDirect3DDevice9_CreatePixelShader(param->base->effect->device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
3492 if (hr != D3D_OK)
3494 WARN("Failed to create pixel shader\n");
3495 return hr;
3497 break;
3499 default:
3500 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3501 break;
3505 *ptr += ((size + 3) & ~3);
3507 return D3D_OK;
3510 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
3511 struct d3dx_parameter *parent, UINT flags)
3513 DWORD offset;
3514 HRESULT hr;
3515 D3DXHANDLE *member_handles = NULL;
3516 UINT i;
3518 param->flags = flags;
3520 if (!parent)
3522 read_dword(ptr, &param->type);
3523 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
3525 read_dword(ptr, &param->class);
3526 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
3528 read_dword(ptr, &offset);
3529 TRACE("Type name offset: %#x\n", offset);
3530 hr = d3dx9_parse_name(&param->name, data + offset);
3531 if (hr != D3D_OK)
3533 WARN("Failed to parse name\n");
3534 goto err_out;
3537 read_dword(ptr, &offset);
3538 TRACE("Type semantic offset: %#x\n", offset);
3539 hr = d3dx9_parse_name(&param->semantic, data + offset);
3540 if (hr != D3D_OK)
3542 WARN("Failed to parse semantic\n");
3543 goto err_out;
3546 read_dword(ptr, &param->element_count);
3547 TRACE("Elements: %u\n", param->element_count);
3549 switch (param->class)
3551 case D3DXPC_VECTOR:
3552 read_dword(ptr, &param->columns);
3553 TRACE("Columns: %u\n", param->columns);
3555 read_dword(ptr, &param->rows);
3556 TRACE("Rows: %u\n", param->rows);
3558 /* sizeof(DWORD) * rows * columns */
3559 param->bytes = 4 * param->rows * param->columns;
3560 break;
3562 case D3DXPC_SCALAR:
3563 case D3DXPC_MATRIX_ROWS:
3564 case D3DXPC_MATRIX_COLUMNS:
3565 read_dword(ptr, &param->rows);
3566 TRACE("Rows: %u\n", param->rows);
3568 read_dword(ptr, &param->columns);
3569 TRACE("Columns: %u\n", param->columns);
3571 /* sizeof(DWORD) * rows * columns */
3572 param->bytes = 4 * param->rows * param->columns;
3573 break;
3575 case D3DXPC_STRUCT:
3576 read_dword(ptr, &param->member_count);
3577 TRACE("Members: %u\n", param->member_count);
3578 break;
3580 case D3DXPC_OBJECT:
3581 switch (param->type)
3583 case D3DXPT_STRING:
3584 param->bytes = sizeof(LPCSTR);
3585 break;
3587 case D3DXPT_PIXELSHADER:
3588 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
3589 break;
3591 case D3DXPT_VERTEXSHADER:
3592 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
3593 break;
3595 case D3DXPT_TEXTURE:
3596 case D3DXPT_TEXTURE1D:
3597 case D3DXPT_TEXTURE2D:
3598 case D3DXPT_TEXTURE3D:
3599 case D3DXPT_TEXTURECUBE:
3600 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
3601 break;
3603 default:
3604 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3605 break;
3607 break;
3609 default:
3610 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3611 break;
3614 else
3616 /* elements */
3617 param->type = parent->type;
3618 param->class = parent->class;
3619 param->name = parent->name;
3620 param->semantic = parent->semantic;
3621 param->element_count = 0;
3622 param->annotation_count = 0;
3623 param->member_count = parent->member_count;
3624 param->bytes = parent->bytes;
3625 param->rows = parent->rows;
3626 param->columns = parent->columns;
3629 if (param->element_count)
3631 unsigned int param_bytes = 0;
3632 const char *save_ptr = *ptr;
3634 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
3635 if (!member_handles)
3637 ERR("Out of memory\n");
3638 hr = E_OUTOFMEMORY;
3639 goto err_out;
3642 for (i = 0; i < param->element_count; ++i)
3644 struct d3dx_parameter *member;
3645 *ptr = save_ptr;
3647 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
3648 if (!member)
3650 ERR("Out of memory\n");
3651 hr = E_OUTOFMEMORY;
3652 goto err_out;
3655 member_handles[i] = get_parameter_handle(member);
3656 member->base = param->base;
3658 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
3659 if (hr != D3D_OK)
3661 WARN("Failed to parse member\n");
3662 goto err_out;
3665 param_bytes += member->bytes;
3668 param->bytes = param_bytes;
3670 else if (param->member_count)
3672 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
3673 if (!member_handles)
3675 ERR("Out of memory\n");
3676 hr = E_OUTOFMEMORY;
3677 goto err_out;
3680 for (i = 0; i < param->member_count; ++i)
3682 struct d3dx_parameter *member;
3684 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
3685 if (!member)
3687 ERR("Out of memory\n");
3688 hr = E_OUTOFMEMORY;
3689 goto err_out;
3692 member_handles[i] = get_parameter_handle(member);
3693 member->base = param->base;
3695 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
3696 if (hr != D3D_OK)
3698 WARN("Failed to parse member\n");
3699 goto err_out;
3702 param->bytes += member->bytes;
3706 param->member_handles = member_handles;
3708 return D3D_OK;
3710 err_out:
3712 if (member_handles)
3714 unsigned int count;
3716 if (param->element_count) count = param->element_count;
3717 else count = param->member_count;
3719 for (i = 0; i < count; ++i)
3721 free_parameter(member_handles[i], param->element_count != 0, TRUE);
3723 HeapFree(GetProcessHeap(), 0, member_handles);
3726 if (!parent)
3728 HeapFree(GetProcessHeap(), 0, param->name);
3729 HeapFree(GetProcessHeap(), 0, param->semantic);
3731 param->name = NULL;
3732 param->semantic = NULL;
3734 return hr;
3737 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr)
3739 DWORD offset;
3740 const char *ptr2;
3741 HRESULT hr;
3743 anno->flags = D3DX_PARAMETER_ANNOTATION;
3745 read_dword(ptr, &offset);
3746 TRACE("Typedef offset: %#x\n", offset);
3747 ptr2 = data + offset;
3748 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
3749 if (hr != D3D_OK)
3751 WARN("Failed to parse type definition\n");
3752 return hr;
3755 read_dword(ptr, &offset);
3756 TRACE("Value offset: %#x\n", offset);
3757 hr = d3dx9_parse_init_value(anno, data + offset);
3758 if (hr != D3D_OK)
3760 WARN("Failed to parse value\n");
3761 return hr;
3764 return D3D_OK;
3767 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr)
3769 DWORD offset;
3770 HRESULT hr;
3771 unsigned int i;
3772 D3DXHANDLE *annotation_handles = NULL;
3773 const char *ptr2;
3775 read_dword(ptr, &offset);
3776 TRACE("Typedef offset: %#x\n", offset);
3777 ptr2 = data + offset;
3779 read_dword(ptr, &offset);
3780 TRACE("Value offset: %#x\n", offset);
3782 read_dword(ptr, &param->flags);
3783 TRACE("Flags: %#x\n", param->flags);
3785 read_dword(ptr, &param->annotation_count);
3786 TRACE("Annotation count: %u\n", param->annotation_count);
3788 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
3789 if (hr != D3D_OK)
3791 WARN("Failed to parse type definition\n");
3792 return hr;
3795 hr = d3dx9_parse_init_value(param, data + offset);
3796 if (hr != D3D_OK)
3798 WARN("Failed to parse value\n");
3799 return hr;
3802 if (param->annotation_count)
3804 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
3805 if (!annotation_handles)
3807 ERR("Out of memory\n");
3808 hr = E_OUTOFMEMORY;
3809 goto err_out;
3812 for (i = 0; i < param->annotation_count; ++i)
3814 struct d3dx_parameter *annotation;
3816 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3817 if (!annotation)
3819 ERR("Out of memory\n");
3820 hr = E_OUTOFMEMORY;
3821 goto err_out;
3824 annotation_handles[i] = get_parameter_handle(annotation);
3825 annotation->base = param->base;
3827 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3828 if (hr != D3D_OK)
3830 WARN("Failed to parse annotation\n");
3831 goto err_out;
3836 param->annotation_handles = annotation_handles;
3838 return D3D_OK;
3840 err_out:
3842 if (annotation_handles)
3844 for (i = 0; i < param->annotation_count; ++i)
3846 free_parameter(annotation_handles[i], FALSE, FALSE);
3848 HeapFree(GetProcessHeap(), 0, annotation_handles);
3851 return hr;
3854 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr)
3856 DWORD offset;
3857 HRESULT hr;
3858 unsigned int i;
3859 D3DXHANDLE *annotation_handles = NULL;
3860 char *name = NULL;
3862 read_dword(ptr, &offset);
3863 TRACE("Pass name offset: %#x\n", offset);
3864 hr = d3dx9_parse_name(&name, data + offset);
3865 if (hr != D3D_OK)
3867 WARN("Failed to parse name\n");
3868 goto err_out;
3871 read_dword(ptr, &pass->annotation_count);
3872 TRACE("Annotation count: %u\n", pass->annotation_count);
3874 read_dword(ptr, &pass->state_count);
3875 TRACE("State count: %u\n", pass->state_count);
3877 if (pass->annotation_count)
3879 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
3880 if (!annotation_handles)
3882 ERR("Out of memory\n");
3883 hr = E_OUTOFMEMORY;
3884 goto err_out;
3887 for (i = 0; i < pass->annotation_count; ++i)
3889 struct d3dx_parameter *annotation;
3891 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3892 if (!annotation)
3894 ERR("Out of memory\n");
3895 hr = E_OUTOFMEMORY;
3896 goto err_out;
3899 annotation_handles[i] = get_parameter_handle(annotation);
3900 annotation->base = pass->base;
3902 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3903 if (hr != D3D_OK)
3905 WARN("Failed to parse annotations\n");
3906 goto err_out;
3911 if (pass->state_count)
3913 for (i = 0; i < pass->state_count; ++i)
3915 skip_dword_unknown(ptr, 4);
3919 pass->name = name;
3920 pass->annotation_handles = annotation_handles;
3922 return D3D_OK;
3924 err_out:
3926 if (annotation_handles)
3928 for (i = 0; i < pass->annotation_count; ++i)
3930 free_parameter(annotation_handles[i], FALSE, FALSE);
3932 HeapFree(GetProcessHeap(), 0, annotation_handles);
3935 HeapFree(GetProcessHeap(), 0, name);
3937 return hr;
3940 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr)
3942 DWORD offset;
3943 HRESULT hr;
3944 unsigned int i;
3945 D3DXHANDLE *annotation_handles = NULL;
3946 D3DXHANDLE *pass_handles = NULL;
3947 char *name = NULL;
3949 read_dword(ptr, &offset);
3950 TRACE("Technique name offset: %#x\n", offset);
3951 hr = d3dx9_parse_name(&name, data + offset);
3952 if (hr != D3D_OK)
3954 WARN("Failed to parse name\n");
3955 goto err_out;
3958 read_dword(ptr, &technique->annotation_count);
3959 TRACE("Annotation count: %u\n", technique->annotation_count);
3961 read_dword(ptr, &technique->pass_count);
3962 TRACE("Pass count: %u\n", technique->pass_count);
3964 if (technique->annotation_count)
3966 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
3967 if (!annotation_handles)
3969 ERR("Out of memory\n");
3970 hr = E_OUTOFMEMORY;
3971 goto err_out;
3974 for (i = 0; i < technique->annotation_count; ++i)
3976 struct d3dx_parameter *annotation;
3978 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3979 if (!annotation)
3981 ERR("Out of memory\n");
3982 hr = E_OUTOFMEMORY;
3983 goto err_out;
3986 annotation_handles[i] = get_parameter_handle(annotation);
3987 annotation->base = technique->base;
3989 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3990 if (hr != D3D_OK)
3992 WARN("Failed to parse annotations\n");
3993 goto err_out;
3998 if (technique->pass_count)
4000 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4001 if (!pass_handles)
4003 ERR("Out of memory\n");
4004 hr = E_OUTOFMEMORY;
4005 goto err_out;
4008 for (i = 0; i < technique->pass_count; ++i)
4010 struct d3dx_pass *pass;
4012 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4013 if (!pass)
4015 ERR("Out of memory\n");
4016 hr = E_OUTOFMEMORY;
4017 goto err_out;
4020 pass_handles[i] = get_pass_handle(pass);
4021 pass->base = technique->base;
4023 hr = d3dx9_parse_effect_pass(pass, data, ptr);
4024 if (hr != D3D_OK)
4026 WARN("Failed to parse passes\n");
4027 goto err_out;
4032 technique->name = name;
4033 technique->pass_handles = pass_handles;
4034 technique->annotation_handles = annotation_handles;
4036 return D3D_OK;
4038 err_out:
4040 if (pass_handles)
4042 for (i = 0; i < technique->pass_count; ++i)
4044 free_pass(pass_handles[i]);
4046 HeapFree(GetProcessHeap(), 0, pass_handles);
4049 if (annotation_handles)
4051 for (i = 0; i < technique->annotation_count; ++i)
4053 free_parameter(annotation_handles[i], FALSE, FALSE);
4055 HeapFree(GetProcessHeap(), 0, annotation_handles);
4058 HeapFree(GetProcessHeap(), 0, name);
4060 return hr;
4063 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4065 const char *ptr = data + start;
4066 D3DXHANDLE *parameter_handles = NULL;
4067 D3DXHANDLE *technique_handles = NULL;
4068 D3DXHANDLE *objects = NULL;
4069 unsigned int stringcount;
4070 HRESULT hr;
4071 unsigned int i;
4073 read_dword(&ptr, &base->parameter_count);
4074 TRACE("Parameter count: %u\n", base->parameter_count);
4076 read_dword(&ptr, &base->technique_count);
4077 TRACE("Technique count: %u\n", base->technique_count);
4079 skip_dword_unknown(&ptr, 1);
4081 read_dword(&ptr, &base->object_count);
4082 TRACE("Object count: %u\n", base->object_count);
4084 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * base->object_count);
4085 if (!objects)
4087 ERR("Out of memory\n");
4088 hr = E_OUTOFMEMORY;
4089 goto err_out;
4092 base->objects = objects;
4094 if (base->parameter_count)
4096 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4097 if (!parameter_handles)
4099 ERR("Out of memory\n");
4100 hr = E_OUTOFMEMORY;
4101 goto err_out;
4104 for (i = 0; i < base->parameter_count; ++i)
4106 struct d3dx_parameter *parameter;
4108 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4109 if (!parameter)
4111 ERR("Out of memory\n");
4112 hr = E_OUTOFMEMORY;
4113 goto err_out;
4116 parameter_handles[i] = get_parameter_handle(parameter);
4117 parameter->base = base;
4119 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr);
4120 if (hr != D3D_OK)
4122 WARN("Failed to parse parameter\n");
4123 goto err_out;
4128 if (base->technique_count)
4130 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4131 if (!technique_handles)
4133 ERR("Out of memory\n");
4134 hr = E_OUTOFMEMORY;
4135 goto err_out;
4138 for (i = 0; i < base->technique_count; ++i)
4140 struct d3dx_technique *technique;
4142 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4143 if (!technique)
4145 ERR("Out of memory\n");
4146 hr = E_OUTOFMEMORY;
4147 goto err_out;
4150 technique_handles[i] = get_technique_handle(technique);
4151 technique->base = base;
4153 hr = d3dx9_parse_effect_technique(technique, data, &ptr);
4154 if (hr != D3D_OK)
4156 WARN("Failed to parse technique\n");
4157 goto err_out;
4162 read_dword(&ptr, &stringcount);
4163 TRACE("String count: %u\n", stringcount);
4165 skip_dword_unknown(&ptr, 1);
4167 for (i = 0; i < stringcount; ++i)
4169 DWORD id;
4170 struct d3dx_parameter *param;
4172 read_dword(&ptr, &id);
4173 TRACE("Id: %u\n", id);
4175 param = get_parameter_struct(base->objects[id]);
4177 hr = d3dx9_parse_data(param, &ptr);
4178 if (hr != D3D_OK)
4180 WARN("Failed to parse data\n");
4181 goto err_out;
4185 HeapFree(GetProcessHeap(), 0, objects);
4186 base->objects = NULL;
4188 base->technique_handles = technique_handles;
4189 base->parameter_handles = parameter_handles;
4191 return D3D_OK;
4193 err_out:
4195 if (technique_handles)
4197 for (i = 0; i < base->technique_count; ++i)
4199 free_technique(technique_handles[i]);
4201 HeapFree(GetProcessHeap(), 0, technique_handles);
4204 if (parameter_handles)
4206 for (i = 0; i < base->parameter_count; ++i)
4208 free_parameter(parameter_handles[i], FALSE, FALSE);
4210 HeapFree(GetProcessHeap(), 0, parameter_handles);
4213 HeapFree(GetProcessHeap(), 0, objects);
4215 return hr;
4218 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
4219 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
4221 DWORD tag, offset;
4222 const char *ptr = data;
4223 HRESULT hr;
4225 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
4227 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
4228 base->ref = 1;
4229 base->effect = effect;
4231 read_dword(&ptr, &tag);
4232 TRACE("Tag: %x\n", tag);
4234 if (tag != d3dx9_effect_version(9, 1))
4236 /* todo: compile hlsl ascii code */
4237 FIXME("HLSL ascii effects not supported, yet\n");
4239 /* Show the start of the shader for debugging info. */
4240 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
4242 else
4244 read_dword(&ptr, &offset);
4245 TRACE("Offset: %x\n", offset);
4247 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
4248 if (hr != D3D_OK)
4250 FIXME("Failed to parse effect.\n");
4251 return hr;
4255 return D3D_OK;
4258 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
4259 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
4261 HRESULT hr;
4262 struct ID3DXBaseEffectImpl *object = NULL;
4264 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
4266 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
4267 effect->ref = 1;
4269 if (pool) pool->lpVtbl->AddRef(pool);
4270 effect->pool = pool;
4272 IDirect3DDevice9_AddRef(device);
4273 effect->device = device;
4275 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4276 if (!object)
4278 ERR("Out of memory\n");
4279 hr = E_OUTOFMEMORY;
4280 goto err_out;
4283 hr = d3dx9_base_effect_init(object, data, data_size, effect);
4284 if (hr != D3D_OK)
4286 FIXME("Failed to parse effect.\n");
4287 goto err_out;
4290 effect->base_effect = &object->ID3DXBaseEffect_iface;
4292 return D3D_OK;
4294 err_out:
4296 HeapFree(GetProcessHeap(), 0, object);
4297 free_effect(effect);
4299 return hr;
4302 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
4303 LPCVOID srcdata,
4304 UINT srcdatalen,
4305 CONST D3DXMACRO* defines,
4306 LPD3DXINCLUDE include,
4307 LPCSTR skip_constants,
4308 DWORD flags,
4309 LPD3DXEFFECTPOOL pool,
4310 LPD3DXEFFECT* effect,
4311 LPD3DXBUFFER* compilation_errors)
4313 struct ID3DXEffectImpl *object;
4314 HRESULT hr;
4316 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
4317 skip_constants, flags, pool, effect, compilation_errors);
4319 if (!device || !srcdata)
4320 return D3DERR_INVALIDCALL;
4322 if (!srcdatalen)
4323 return E_FAIL;
4325 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
4326 if (!effect)
4327 return D3D_OK;
4329 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4330 if (!object)
4332 ERR("Out of memory\n");
4333 return E_OUTOFMEMORY;
4336 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
4337 if (FAILED(hr))
4339 WARN("Failed to initialize shader reflection\n");
4340 HeapFree(GetProcessHeap(), 0, object);
4341 return hr;
4344 *effect = &object->ID3DXEffect_iface;
4346 TRACE("Created ID3DXEffect %p\n", object);
4348 return D3D_OK;
4351 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
4352 LPCVOID srcdata,
4353 UINT srcdatalen,
4354 CONST D3DXMACRO* defines,
4355 LPD3DXINCLUDE include,
4356 DWORD flags,
4357 LPD3DXEFFECTPOOL pool,
4358 LPD3DXEFFECT* effect,
4359 LPD3DXBUFFER* compilation_errors)
4361 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
4362 include, flags, pool, effect, compilation_errors);
4364 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
4367 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
4369 HRESULT hr;
4370 struct ID3DXBaseEffectImpl *object = NULL;
4372 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
4374 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
4375 compiler->ref = 1;
4377 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4378 if (!object)
4380 ERR("Out of memory\n");
4381 hr = E_OUTOFMEMORY;
4382 goto err_out;
4385 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
4386 if (hr != D3D_OK)
4388 FIXME("Failed to parse effect.\n");
4389 goto err_out;
4392 compiler->base_effect = &object->ID3DXBaseEffect_iface;
4394 return D3D_OK;
4396 err_out:
4398 HeapFree(GetProcessHeap(), 0, object);
4399 free_effect_compiler(compiler);
4401 return hr;
4404 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
4405 UINT srcdatalen,
4406 CONST D3DXMACRO *defines,
4407 LPD3DXINCLUDE include,
4408 DWORD flags,
4409 LPD3DXEFFECTCOMPILER *compiler,
4410 LPD3DXBUFFER *parse_errors)
4412 struct ID3DXEffectCompilerImpl *object;
4413 HRESULT hr;
4415 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
4416 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
4418 if (!srcdata || !compiler)
4420 WARN("Invalid arguments supplied\n");
4421 return D3DERR_INVALIDCALL;
4424 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4425 if (!object)
4427 ERR("Out of memory\n");
4428 return E_OUTOFMEMORY;
4431 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
4432 if (FAILED(hr))
4434 WARN("Failed to initialize effect compiler\n");
4435 HeapFree(GetProcessHeap(), 0, object);
4436 return hr;
4439 *compiler = &object->ID3DXEffectCompiler_iface;
4441 TRACE("Created ID3DXEffectCompiler %p\n", object);
4443 return D3D_OK;
4446 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
4448 struct ID3DXEffectPoolImpl
4450 ID3DXEffectPool ID3DXEffectPool_iface;
4451 LONG ref;
4454 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
4456 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
4459 /*** IUnknown methods ***/
4460 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
4462 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4464 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
4466 if (IsEqualGUID(riid, &IID_IUnknown) ||
4467 IsEqualGUID(riid, &IID_ID3DXEffectPool))
4469 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
4470 *object = This;
4471 return S_OK;
4474 WARN("Interface %s not found\n", debugstr_guid(riid));
4476 return E_NOINTERFACE;
4479 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
4481 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4483 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
4485 return InterlockedIncrement(&This->ref);
4488 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
4490 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4491 ULONG ref = InterlockedDecrement(&This->ref);
4493 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
4495 if (!ref)
4496 HeapFree(GetProcessHeap(), 0, This);
4498 return ref;
4501 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
4503 /*** IUnknown methods ***/
4504 ID3DXEffectPoolImpl_QueryInterface,
4505 ID3DXEffectPoolImpl_AddRef,
4506 ID3DXEffectPoolImpl_Release
4509 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
4511 struct ID3DXEffectPoolImpl *object;
4513 TRACE("(%p)\n", pool);
4515 if (!pool)
4516 return D3DERR_INVALIDCALL;
4518 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4519 if (!object)
4521 ERR("Out of memory\n");
4522 return E_OUTOFMEMORY;
4525 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
4526 object->ref = 1;
4528 *pool = &object->ID3DXEffectPool_iface;
4530 return S_OK;
4533 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4534 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4535 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4537 LPVOID buffer;
4538 HRESULT ret;
4539 DWORD size;
4541 TRACE("(%s): relay\n", debugstr_w(srcfile));
4543 if (!device || !srcfile || !defines)
4544 return D3DERR_INVALIDCALL;
4546 ret = map_view_of_file(srcfile, &buffer, &size);
4548 if (FAILED(ret))
4549 return D3DXERR_INVALIDDATA;
4551 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4552 UnmapViewOfFile(buffer);
4554 return ret;
4557 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
4558 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4559 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4561 LPWSTR srcfileW;
4562 HRESULT ret;
4563 DWORD len;
4565 TRACE("(void): relay\n");
4567 if (!srcfile || !defines)
4568 return D3DERR_INVALIDCALL;
4570 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
4571 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
4572 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
4574 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4575 HeapFree(GetProcessHeap(), 0, srcfileW);
4577 return ret;
4580 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4581 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4582 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4584 TRACE("(void): relay\n");
4585 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
4588 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
4589 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4590 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4592 TRACE("(void): relay\n");
4593 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
4596 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
4597 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4598 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4600 HRSRC resinfo;
4602 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
4604 if (!device || !defines)
4605 return D3DERR_INVALIDCALL;
4607 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
4609 if (resinfo)
4611 LPVOID buffer;
4612 HRESULT ret;
4613 DWORD size;
4615 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4617 if (FAILED(ret))
4618 return D3DXERR_INVALIDDATA;
4620 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4623 return D3DXERR_INVALIDDATA;
4626 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
4627 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4628 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4630 HRSRC resinfo;
4632 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
4634 if (!device || !defines)
4635 return D3DERR_INVALIDCALL;
4637 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
4639 if (resinfo)
4641 LPVOID buffer;
4642 HRESULT ret;
4643 DWORD size;
4645 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4647 if (FAILED(ret))
4648 return D3DXERR_INVALIDDATA;
4650 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4653 return D3DXERR_INVALIDDATA;
4656 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
4657 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4658 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4660 TRACE("(void): relay\n");
4661 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
4664 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
4665 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4666 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4668 TRACE("(void): relay\n");
4669 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
4672 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
4673 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4675 LPVOID buffer;
4676 HRESULT ret;
4677 DWORD size;
4679 TRACE("(%s): relay\n", debugstr_w(srcfile));
4681 if (!srcfile || !defines)
4682 return D3DERR_INVALIDCALL;
4684 ret = map_view_of_file(srcfile, &buffer, &size);
4686 if (FAILED(ret))
4687 return D3DXERR_INVALIDDATA;
4689 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4690 UnmapViewOfFile(buffer);
4692 return ret;
4695 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
4696 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4698 LPWSTR srcfileW;
4699 HRESULT ret;
4700 DWORD len;
4702 TRACE("(void): relay\n");
4704 if (!srcfile || !defines)
4705 return D3DERR_INVALIDCALL;
4707 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
4708 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
4709 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
4711 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
4712 HeapFree(GetProcessHeap(), 0, srcfileW);
4714 return ret;
4717 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
4718 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4720 HRSRC resinfo;
4722 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
4724 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
4726 if (resinfo)
4728 LPVOID buffer;
4729 HRESULT ret;
4730 DWORD size;
4732 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4734 if (FAILED(ret))
4735 return D3DXERR_INVALIDDATA;
4737 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4740 return D3DXERR_INVALIDDATA;
4743 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
4744 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4746 HRSRC resinfo;
4748 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
4750 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
4752 if (resinfo)
4754 LPVOID buffer;
4755 HRESULT ret;
4756 DWORD size;
4758 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4760 if (FAILED(ret))
4761 return D3DXERR_INVALIDDATA;
4763 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4766 return D3DXERR_INVALIDDATA;