d3dx9: Remove some checks for defines argument in D3DXCreateEffect* functions.
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blobf0c44e1e789ef49f467e5d79af1b4659181f97e9
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);
1572 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1574 TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture);
1576 if (texture && param && !param->element_count &&
1577 (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D
1578 || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D
1579 || param->type == D3DXPT_TEXTURECUBE))
1581 *texture = *(LPDIRECT3DBASETEXTURE9 *)param->data;
1582 if (*texture) IDirect3DBaseTexture9_AddRef(*texture);
1583 TRACE("Returning %p\n", *texture);
1584 return D3D_OK;
1587 WARN("Invalid argument specified\n");
1589 return D3DERR_INVALIDCALL;
1592 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
1594 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1595 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1597 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
1599 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1601 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
1603 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
1604 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
1605 TRACE("Returning %p\n", *pshader);
1606 return D3D_OK;
1609 WARN("Invalid argument specified\n");
1611 return D3DERR_INVALIDCALL;
1614 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
1616 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1617 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1619 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
1621 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1623 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
1625 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
1626 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
1627 TRACE("Returning %p\n", *vshader);
1628 return D3D_OK;
1631 WARN("Invalid argument specified\n");
1633 return D3DERR_INVALIDCALL;
1636 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
1638 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1640 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
1642 return E_NOTIMPL;
1645 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
1647 /*** IUnknown methods ***/
1648 ID3DXBaseEffectImpl_QueryInterface,
1649 ID3DXBaseEffectImpl_AddRef,
1650 ID3DXBaseEffectImpl_Release,
1651 /*** ID3DXBaseEffect methods ***/
1652 ID3DXBaseEffectImpl_GetDesc,
1653 ID3DXBaseEffectImpl_GetParameterDesc,
1654 ID3DXBaseEffectImpl_GetTechniqueDesc,
1655 ID3DXBaseEffectImpl_GetPassDesc,
1656 ID3DXBaseEffectImpl_GetFunctionDesc,
1657 ID3DXBaseEffectImpl_GetParameter,
1658 ID3DXBaseEffectImpl_GetParameterByName,
1659 ID3DXBaseEffectImpl_GetParameterBySemantic,
1660 ID3DXBaseEffectImpl_GetParameterElement,
1661 ID3DXBaseEffectImpl_GetTechnique,
1662 ID3DXBaseEffectImpl_GetTechniqueByName,
1663 ID3DXBaseEffectImpl_GetPass,
1664 ID3DXBaseEffectImpl_GetPassByName,
1665 ID3DXBaseEffectImpl_GetFunction,
1666 ID3DXBaseEffectImpl_GetFunctionByName,
1667 ID3DXBaseEffectImpl_GetAnnotation,
1668 ID3DXBaseEffectImpl_GetAnnotationByName,
1669 ID3DXBaseEffectImpl_SetValue,
1670 ID3DXBaseEffectImpl_GetValue,
1671 ID3DXBaseEffectImpl_SetBool,
1672 ID3DXBaseEffectImpl_GetBool,
1673 ID3DXBaseEffectImpl_SetBoolArray,
1674 ID3DXBaseEffectImpl_GetBoolArray,
1675 ID3DXBaseEffectImpl_SetInt,
1676 ID3DXBaseEffectImpl_GetInt,
1677 ID3DXBaseEffectImpl_SetIntArray,
1678 ID3DXBaseEffectImpl_GetIntArray,
1679 ID3DXBaseEffectImpl_SetFloat,
1680 ID3DXBaseEffectImpl_GetFloat,
1681 ID3DXBaseEffectImpl_SetFloatArray,
1682 ID3DXBaseEffectImpl_GetFloatArray,
1683 ID3DXBaseEffectImpl_SetVector,
1684 ID3DXBaseEffectImpl_GetVector,
1685 ID3DXBaseEffectImpl_SetVectorArray,
1686 ID3DXBaseEffectImpl_GetVectorArray,
1687 ID3DXBaseEffectImpl_SetMatrix,
1688 ID3DXBaseEffectImpl_GetMatrix,
1689 ID3DXBaseEffectImpl_SetMatrixArray,
1690 ID3DXBaseEffectImpl_GetMatrixArray,
1691 ID3DXBaseEffectImpl_SetMatrixPointerArray,
1692 ID3DXBaseEffectImpl_GetMatrixPointerArray,
1693 ID3DXBaseEffectImpl_SetMatrixTranspose,
1694 ID3DXBaseEffectImpl_GetMatrixTranspose,
1695 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
1696 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
1697 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
1698 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
1699 ID3DXBaseEffectImpl_SetString,
1700 ID3DXBaseEffectImpl_GetString,
1701 ID3DXBaseEffectImpl_SetTexture,
1702 ID3DXBaseEffectImpl_GetTexture,
1703 ID3DXBaseEffectImpl_GetPixelShader,
1704 ID3DXBaseEffectImpl_GetVertexShader,
1705 ID3DXBaseEffectImpl_SetArrayRange,
1708 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
1710 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
1713 /*** IUnknown methods ***/
1714 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
1716 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1718 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
1720 if (IsEqualGUID(riid, &IID_IUnknown) ||
1721 IsEqualGUID(riid, &IID_ID3DXEffect))
1723 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
1724 *object = This;
1725 return S_OK;
1728 ERR("Interface %s not found\n", debugstr_guid(riid));
1730 return E_NOINTERFACE;
1733 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
1735 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1737 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
1739 return InterlockedIncrement(&This->ref);
1742 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
1744 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1745 ULONG ref = InterlockedDecrement(&This->ref);
1747 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
1749 if (!ref)
1751 free_effect(This);
1752 HeapFree(GetProcessHeap(), 0, This);
1755 return ref;
1758 /*** ID3DXBaseEffect methods ***/
1759 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
1761 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1762 ID3DXBaseEffect *base = This->base_effect;
1764 TRACE("Forward iface %p, base %p\n", This, base);
1766 return ID3DXBaseEffectImpl_GetDesc(base, desc);
1769 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1771 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1772 ID3DXBaseEffect *base = This->base_effect;
1774 TRACE("Forward iface %p, base %p\n", This, base);
1776 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
1779 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1781 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1782 ID3DXBaseEffect *base = This->base_effect;
1784 TRACE("Forward iface %p, base %p\n", This, base);
1786 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
1789 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1791 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1792 ID3DXBaseEffect *base = This->base_effect;
1794 TRACE("Forward iface %p, base %p\n", This, base);
1796 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
1799 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1801 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1802 ID3DXBaseEffect *base = This->base_effect;
1804 TRACE("Forward iface %p, base %p\n", This, base);
1806 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
1809 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
1811 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1812 ID3DXBaseEffect *base = This->base_effect;
1814 TRACE("Forward iface %p, base %p\n", This, base);
1816 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
1819 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1821 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1822 ID3DXBaseEffect *base = This->base_effect;
1824 TRACE("Forward iface %p, base %p\n", This, base);
1826 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
1829 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1831 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1832 ID3DXBaseEffect *base = This->base_effect;
1834 TRACE("Forward iface %p, base %p\n", This, base);
1836 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
1839 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
1841 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1842 ID3DXBaseEffect *base = This->base_effect;
1844 TRACE("Forward iface %p, base %p\n", This, base);
1846 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
1849 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
1851 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1852 ID3DXBaseEffect *base = This->base_effect;
1854 TRACE("Forward iface %p, base %p\n", This, base);
1856 return ID3DXBaseEffectImpl_GetTechnique(base, index);
1859 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
1861 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1862 ID3DXBaseEffect *base = This->base_effect;
1864 TRACE("Forward iface %p, base %p\n", This, base);
1866 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
1869 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
1871 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1872 ID3DXBaseEffect *base = This->base_effect;
1874 TRACE("Forward iface %p, base %p\n", This, base);
1876 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
1879 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
1881 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1882 ID3DXBaseEffect *base = This->base_effect;
1884 TRACE("Forward iface %p, base %p\n", This, base);
1886 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
1889 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
1891 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1892 ID3DXBaseEffect *base = This->base_effect;
1894 TRACE("Forward iface %p, base %p\n", This, base);
1896 return ID3DXBaseEffectImpl_GetFunction(base, index);
1899 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
1901 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1902 ID3DXBaseEffect *base = This->base_effect;
1904 TRACE("Forward iface %p, base %p\n", This, base);
1906 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
1909 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
1911 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1912 ID3DXBaseEffect *base = This->base_effect;
1914 TRACE("Forward iface %p, base %p\n", This, base);
1916 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
1919 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
1921 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1922 ID3DXBaseEffect *base = This->base_effect;
1924 TRACE("Forward iface %p, base %p\n", This, base);
1926 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
1929 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1931 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1932 ID3DXBaseEffect *base = This->base_effect;
1934 TRACE("Forward iface %p, base %p\n", This, base);
1936 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
1939 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1941 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1942 ID3DXBaseEffect *base = This->base_effect;
1944 TRACE("Forward iface %p, base %p\n", This, base);
1946 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
1949 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
1951 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1952 ID3DXBaseEffect *base = This->base_effect;
1954 TRACE("Forward iface %p, base %p\n", This, base);
1956 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
1959 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
1961 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1962 ID3DXBaseEffect *base = This->base_effect;
1964 TRACE("Forward iface %p, base %p\n", This, base);
1966 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
1969 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1971 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1972 ID3DXBaseEffect *base = This->base_effect;
1974 TRACE("Forward iface %p, base %p\n", This, base);
1976 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
1979 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1981 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1982 ID3DXBaseEffect *base = This->base_effect;
1984 TRACE("Forward iface %p, base %p\n", This, base);
1986 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
1989 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
1991 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1992 ID3DXBaseEffect *base = This->base_effect;
1994 TRACE("Forward iface %p, base %p\n", This, base);
1996 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
1999 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
2001 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2002 ID3DXBaseEffect *base = This->base_effect;
2004 TRACE("Forward iface %p, base %p\n", This, base);
2006 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2009 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2011 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2012 ID3DXBaseEffect *base = This->base_effect;
2014 TRACE("Forward iface %p, base %p\n", This, base);
2016 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2019 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
2021 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2022 ID3DXBaseEffect *base = This->base_effect;
2024 TRACE("Forward iface %p, base %p\n", This, base);
2026 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2029 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
2031 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2032 ID3DXBaseEffect *base = This->base_effect;
2034 TRACE("Forward iface %p, base %p\n", This, base);
2036 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2039 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
2041 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2042 ID3DXBaseEffect *base = This->base_effect;
2044 TRACE("Forward iface %p, base %p\n", This, base);
2046 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2049 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2051 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2052 ID3DXBaseEffect *base = This->base_effect;
2054 TRACE("Forward iface %p, base %p\n", This, base);
2056 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2059 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2061 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2062 ID3DXBaseEffect *base = This->base_effect;
2064 TRACE("Forward iface %p, base %p\n", This, base);
2066 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2069 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2071 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2072 ID3DXBaseEffect *base = This->base_effect;
2074 TRACE("Forward iface %p, base %p\n", This, base);
2076 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2079 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2081 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2082 ID3DXBaseEffect *base = This->base_effect;
2084 TRACE("Forward iface %p, base %p\n", This, base);
2086 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2089 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2091 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2092 ID3DXBaseEffect *base = This->base_effect;
2094 TRACE("Forward iface %p, base %p\n", This, base);
2096 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2099 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2101 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2102 ID3DXBaseEffect *base = This->base_effect;
2104 TRACE("Forward iface %p, base %p\n", This, base);
2106 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2109 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2111 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2112 ID3DXBaseEffect *base = This->base_effect;
2114 TRACE("Forward iface %p, base %p\n", This, base);
2116 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2119 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2121 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2122 ID3DXBaseEffect *base = This->base_effect;
2124 TRACE("Forward iface %p, base %p\n", This, base);
2126 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2129 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2131 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2132 ID3DXBaseEffect *base = This->base_effect;
2134 TRACE("Forward iface %p, base %p\n", This, base);
2136 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2139 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2141 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2142 ID3DXBaseEffect *base = This->base_effect;
2144 TRACE("Forward iface %p, base %p\n", This, base);
2146 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2149 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2151 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2152 ID3DXBaseEffect *base = This->base_effect;
2154 TRACE("Forward iface %p, base %p\n", This, base);
2156 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2159 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2161 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2162 ID3DXBaseEffect *base = This->base_effect;
2164 TRACE("Forward iface %p, base %p\n", This, base);
2166 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2169 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2171 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2172 ID3DXBaseEffect *base = This->base_effect;
2174 TRACE("Forward iface %p, base %p\n", This, base);
2176 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2179 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2181 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2182 ID3DXBaseEffect *base = This->base_effect;
2184 TRACE("Forward iface %p, base %p\n", This, base);
2186 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2189 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2191 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2192 ID3DXBaseEffect *base = This->base_effect;
2194 TRACE("Forward iface %p, base %p\n", This, base);
2196 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2199 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2201 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2202 ID3DXBaseEffect *base = This->base_effect;
2204 TRACE("Forward iface %p, base %p\n", This, base);
2206 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2209 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2211 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2212 ID3DXBaseEffect *base = This->base_effect;
2214 TRACE("Forward iface %p, base %p\n", This, base);
2216 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2219 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2221 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2222 ID3DXBaseEffect *base = This->base_effect;
2224 TRACE("Forward iface %p, base %p\n", This, base);
2226 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2229 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2231 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2232 ID3DXBaseEffect *base = This->base_effect;
2234 TRACE("Forward iface %p, base %p\n", This, base);
2236 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2239 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2241 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2242 ID3DXBaseEffect *base = This->base_effect;
2244 TRACE("Forward iface %p, base %p\n", This, base);
2246 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2249 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2251 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2252 ID3DXBaseEffect *base = This->base_effect;
2254 TRACE("Forward iface %p, base %p\n", This, base);
2256 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2259 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2261 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2262 ID3DXBaseEffect *base = This->base_effect;
2264 TRACE("Forward iface %p, base %p\n", This, base);
2266 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2269 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2271 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2272 ID3DXBaseEffect *base = This->base_effect;
2274 TRACE("Forward iface %p, base %p\n", This, base);
2276 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2279 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2281 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2282 ID3DXBaseEffect *base = This->base_effect;
2284 TRACE("Forward iface %p, base %p\n", This, base);
2286 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2289 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2291 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2292 ID3DXBaseEffect *base = This->base_effect;
2294 TRACE("Forward iface %p, base %p\n", This, base);
2296 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2299 /*** ID3DXEffect methods ***/
2300 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2302 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2304 TRACE("iface %p, pool %p\n", This, pool);
2306 if (!pool)
2308 WARN("Invalid argument supplied.\n");
2309 return D3DERR_INVALIDCALL;
2312 if (This->pool)
2314 This->pool->lpVtbl->AddRef(This->pool);
2317 *pool = This->pool;
2319 TRACE("Returning pool %p\n", *pool);
2321 return S_OK;
2324 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2326 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2328 FIXME("(%p)->(%p): stub\n", This, technique);
2330 return E_NOTIMPL;
2333 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect* iface)
2335 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2337 FIXME("(%p)->(): stub\n", This);
2339 return NULL;
2342 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2344 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2346 FIXME("(%p)->(%p): stub\n", This, technique);
2348 return D3D_OK;
2351 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2353 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2355 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2357 return E_NOTIMPL;
2360 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2362 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2364 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2366 return FALSE;
2369 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect* iface, UINT *passes, DWORD flags)
2371 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2373 FIXME("(%p)->(%p, %#x): stub\n", This, passes, flags);
2375 return E_NOTIMPL;
2378 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect* iface, UINT pass)
2380 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2382 FIXME("(%p)->(%u): stub\n", This, pass);
2384 return E_NOTIMPL;
2387 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2389 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2391 FIXME("(%p)->(): stub\n", This);
2393 return E_NOTIMPL;
2396 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
2398 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2400 FIXME("(%p)->(): stub\n", This);
2402 return E_NOTIMPL;
2405 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2407 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2409 FIXME("(%p)->(): stub\n", This);
2411 return E_NOTIMPL;
2414 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2416 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2418 TRACE("iface %p, device %p\n", This, device);
2420 if (!device)
2422 WARN("Invalid argument supplied.\n");
2423 return D3DERR_INVALIDCALL;
2426 IDirect3DDevice9_AddRef(This->device);
2428 *device = This->device;
2430 TRACE("Returning device %p\n", *device);
2432 return S_OK;
2435 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2437 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2439 FIXME("(%p)->(): stub\n", This);
2441 return E_NOTIMPL;
2444 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2446 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2448 FIXME("(%p)->(): stub\n", This);
2450 return E_NOTIMPL;
2453 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER manager)
2455 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2457 TRACE("iface %p, manager %p\n", This, manager);
2459 if (This->manager) IUnknown_Release(This->manager);
2460 if (manager) IUnknown_AddRef(manager);
2462 This->manager = manager;
2464 return D3D_OK;
2467 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect *iface, LPD3DXEFFECTSTATEMANAGER *manager)
2469 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2471 TRACE("iface %p, manager %p\n", This, manager);
2473 if (!manager)
2475 WARN("Invalid argument supplied.\n");
2476 return D3DERR_INVALIDCALL;
2479 if (This->manager) IUnknown_AddRef(This->manager);
2480 *manager = This->manager;
2482 return D3D_OK;
2485 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2487 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2489 FIXME("(%p)->(): stub\n", This);
2491 return E_NOTIMPL;
2494 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
2496 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2498 FIXME("(%p)->(): stub\n", This);
2500 return NULL;
2503 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2505 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2507 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2509 return E_NOTIMPL;
2512 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2514 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2516 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2518 return E_NOTIMPL;
2521 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
2523 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2525 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
2527 return E_NOTIMPL;
2530 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
2532 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2534 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
2536 return E_NOTIMPL;
2539 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
2541 /*** IUnknown methods ***/
2542 ID3DXEffectImpl_QueryInterface,
2543 ID3DXEffectImpl_AddRef,
2544 ID3DXEffectImpl_Release,
2545 /*** ID3DXBaseEffect methods ***/
2546 ID3DXEffectImpl_GetDesc,
2547 ID3DXEffectImpl_GetParameterDesc,
2548 ID3DXEffectImpl_GetTechniqueDesc,
2549 ID3DXEffectImpl_GetPassDesc,
2550 ID3DXEffectImpl_GetFunctionDesc,
2551 ID3DXEffectImpl_GetParameter,
2552 ID3DXEffectImpl_GetParameterByName,
2553 ID3DXEffectImpl_GetParameterBySemantic,
2554 ID3DXEffectImpl_GetParameterElement,
2555 ID3DXEffectImpl_GetTechnique,
2556 ID3DXEffectImpl_GetTechniqueByName,
2557 ID3DXEffectImpl_GetPass,
2558 ID3DXEffectImpl_GetPassByName,
2559 ID3DXEffectImpl_GetFunction,
2560 ID3DXEffectImpl_GetFunctionByName,
2561 ID3DXEffectImpl_GetAnnotation,
2562 ID3DXEffectImpl_GetAnnotationByName,
2563 ID3DXEffectImpl_SetValue,
2564 ID3DXEffectImpl_GetValue,
2565 ID3DXEffectImpl_SetBool,
2566 ID3DXEffectImpl_GetBool,
2567 ID3DXEffectImpl_SetBoolArray,
2568 ID3DXEffectImpl_GetBoolArray,
2569 ID3DXEffectImpl_SetInt,
2570 ID3DXEffectImpl_GetInt,
2571 ID3DXEffectImpl_SetIntArray,
2572 ID3DXEffectImpl_GetIntArray,
2573 ID3DXEffectImpl_SetFloat,
2574 ID3DXEffectImpl_GetFloat,
2575 ID3DXEffectImpl_SetFloatArray,
2576 ID3DXEffectImpl_GetFloatArray,
2577 ID3DXEffectImpl_SetVector,
2578 ID3DXEffectImpl_GetVector,
2579 ID3DXEffectImpl_SetVectorArray,
2580 ID3DXEffectImpl_GetVectorArray,
2581 ID3DXEffectImpl_SetMatrix,
2582 ID3DXEffectImpl_GetMatrix,
2583 ID3DXEffectImpl_SetMatrixArray,
2584 ID3DXEffectImpl_GetMatrixArray,
2585 ID3DXEffectImpl_SetMatrixPointerArray,
2586 ID3DXEffectImpl_GetMatrixPointerArray,
2587 ID3DXEffectImpl_SetMatrixTranspose,
2588 ID3DXEffectImpl_GetMatrixTranspose,
2589 ID3DXEffectImpl_SetMatrixTransposeArray,
2590 ID3DXEffectImpl_GetMatrixTransposeArray,
2591 ID3DXEffectImpl_SetMatrixTransposePointerArray,
2592 ID3DXEffectImpl_GetMatrixTransposePointerArray,
2593 ID3DXEffectImpl_SetString,
2594 ID3DXEffectImpl_GetString,
2595 ID3DXEffectImpl_SetTexture,
2596 ID3DXEffectImpl_GetTexture,
2597 ID3DXEffectImpl_GetPixelShader,
2598 ID3DXEffectImpl_GetVertexShader,
2599 ID3DXEffectImpl_SetArrayRange,
2600 /*** ID3DXEffect methods ***/
2601 ID3DXEffectImpl_GetPool,
2602 ID3DXEffectImpl_SetTechnique,
2603 ID3DXEffectImpl_GetCurrentTechnique,
2604 ID3DXEffectImpl_ValidateTechnique,
2605 ID3DXEffectImpl_FindNextValidTechnique,
2606 ID3DXEffectImpl_IsParameterUsed,
2607 ID3DXEffectImpl_Begin,
2608 ID3DXEffectImpl_BeginPass,
2609 ID3DXEffectImpl_CommitChanges,
2610 ID3DXEffectImpl_EndPass,
2611 ID3DXEffectImpl_End,
2612 ID3DXEffectImpl_GetDevice,
2613 ID3DXEffectImpl_OnLostDevice,
2614 ID3DXEffectImpl_OnResetDevice,
2615 ID3DXEffectImpl_SetStateManager,
2616 ID3DXEffectImpl_GetStateManager,
2617 ID3DXEffectImpl_BeginParameterBlock,
2618 ID3DXEffectImpl_EndParameterBlock,
2619 ID3DXEffectImpl_ApplyParameterBlock,
2620 ID3DXEffectImpl_DeleteParameterBlock,
2621 ID3DXEffectImpl_CloneEffect,
2622 ID3DXEffectImpl_SetRawValue
2625 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
2627 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
2630 /*** IUnknown methods ***/
2631 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
2633 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2635 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
2637 if (IsEqualGUID(riid, &IID_IUnknown) ||
2638 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
2640 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
2641 *object = This;
2642 return S_OK;
2645 ERR("Interface %s not found\n", debugstr_guid(riid));
2647 return E_NOINTERFACE;
2650 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
2652 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2654 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
2656 return InterlockedIncrement(&This->ref);
2659 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
2661 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2662 ULONG ref = InterlockedDecrement(&This->ref);
2664 TRACE("iface %p: Release from %u\n", iface, ref + 1);
2666 if (!ref)
2668 free_effect_compiler(This);
2669 HeapFree(GetProcessHeap(), 0, This);
2672 return ref;
2675 /*** ID3DXBaseEffect methods ***/
2676 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
2678 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2679 ID3DXBaseEffect *base = This->base_effect;
2681 TRACE("Forward iface %p, base %p\n", This, base);
2683 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2686 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2688 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2689 ID3DXBaseEffect *base = This->base_effect;
2691 TRACE("Forward iface %p, base %p\n", This, base);
2693 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2696 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2698 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2699 ID3DXBaseEffect *base = This->base_effect;
2701 TRACE("Forward iface %p, base %p\n", This, base);
2703 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2706 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2708 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2709 ID3DXBaseEffect *base = This->base_effect;
2711 TRACE("Forward iface %p, base %p\n", This, base);
2713 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2716 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2718 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2719 ID3DXBaseEffect *base = This->base_effect;
2721 TRACE("Forward iface %p, base %p\n", This, base);
2723 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2726 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
2728 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2729 ID3DXBaseEffect *base = This->base_effect;
2731 TRACE("Forward iface %p, base %p\n", This, base);
2733 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2736 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
2738 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2739 ID3DXBaseEffect *base = This->base_effect;
2741 TRACE("Forward iface %p, base %p\n", This, base);
2743 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2746 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
2748 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2749 ID3DXBaseEffect *base = This->base_effect;
2751 TRACE("Forward iface %p, base %p\n", This, base);
2753 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2756 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
2758 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2759 ID3DXBaseEffect *base = This->base_effect;
2761 TRACE("Forward iface %p, base %p\n", This, base);
2763 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2766 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
2768 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2769 ID3DXBaseEffect *base = This->base_effect;
2771 TRACE("Forward iface %p, base %p\n", This, base);
2773 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2776 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
2778 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2779 ID3DXBaseEffect *base = This->base_effect;
2781 TRACE("Forward iface %p, base %p\n", This, base);
2783 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2786 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
2788 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2789 ID3DXBaseEffect *base = This->base_effect;
2791 TRACE("Forward iface %p, base %p\n", This, base);
2793 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2796 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
2798 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2799 ID3DXBaseEffect *base = This->base_effect;
2801 TRACE("Forward iface %p, base %p\n", This, base);
2803 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2806 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
2808 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2809 ID3DXBaseEffect *base = This->base_effect;
2811 TRACE("Forward iface %p, base %p\n", This, base);
2813 return ID3DXBaseEffectImpl_GetFunction(base, index);
2816 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
2818 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2819 ID3DXBaseEffect *base = This->base_effect;
2821 TRACE("Forward iface %p, base %p\n", This, base);
2823 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2826 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
2828 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2829 ID3DXBaseEffect *base = This->base_effect;
2831 TRACE("Forward iface %p, base %p\n", This, base);
2833 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2836 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
2838 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2839 ID3DXBaseEffect *base = This->base_effect;
2841 TRACE("Forward iface %p, base %p\n", This, base);
2843 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2846 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2848 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2849 ID3DXBaseEffect *base = This->base_effect;
2851 TRACE("Forward iface %p, base %p\n", This, base);
2853 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2856 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2858 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2859 ID3DXBaseEffect *base = This->base_effect;
2861 TRACE("Forward iface %p, base %p\n", This, base);
2863 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2866 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
2868 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2869 ID3DXBaseEffect *base = This->base_effect;
2871 TRACE("Forward iface %p, base %p\n", This, base);
2873 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2876 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
2878 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2879 ID3DXBaseEffect *base = This->base_effect;
2881 TRACE("Forward iface %p, base %p\n", This, base);
2883 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2886 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2888 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2889 ID3DXBaseEffect *base = This->base_effect;
2891 TRACE("Forward iface %p, base %p\n", This, base);
2893 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2896 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2898 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2899 ID3DXBaseEffect *base = This->base_effect;
2901 TRACE("Forward iface %p, base %p\n", This, base);
2903 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2906 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
2908 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2909 ID3DXBaseEffect *base = This->base_effect;
2911 TRACE("Forward iface %p, base %p\n", This, base);
2913 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2916 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
2918 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2919 ID3DXBaseEffect *base = This->base_effect;
2921 TRACE("Forward iface %p, base %p\n", This, base);
2923 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2926 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2928 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2929 ID3DXBaseEffect *base = This->base_effect;
2931 TRACE("Forward iface %p, base %p\n", This, base);
2933 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2936 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
2938 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2939 ID3DXBaseEffect *base = This->base_effect;
2941 TRACE("Forward iface %p, base %p\n", This, base);
2943 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2946 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
2948 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2949 ID3DXBaseEffect *base = This->base_effect;
2951 TRACE("Forward iface %p, base %p\n", This, base);
2953 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2956 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
2958 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2959 ID3DXBaseEffect *base = This->base_effect;
2961 TRACE("Forward iface %p, base %p\n", This, base);
2963 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2966 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2968 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2969 ID3DXBaseEffect *base = This->base_effect;
2971 TRACE("Forward iface %p, base %p\n", This, base);
2973 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2976 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2978 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2979 ID3DXBaseEffect *base = This->base_effect;
2981 TRACE("Forward iface %p, base %p\n", This, base);
2983 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2986 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2988 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2989 ID3DXBaseEffect *base = This->base_effect;
2991 TRACE("Forward iface %p, base %p\n", This, base);
2993 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2996 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2998 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2999 ID3DXBaseEffect *base = This->base_effect;
3001 TRACE("Forward iface %p, base %p\n", This, base);
3003 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
3006 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
3008 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3009 ID3DXBaseEffect *base = This->base_effect;
3011 TRACE("Forward iface %p, base %p\n", This, base);
3013 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
3016 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
3018 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3019 ID3DXBaseEffect *base = This->base_effect;
3021 TRACE("Forward iface %p, base %p\n", This, base);
3023 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
3026 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3028 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3029 ID3DXBaseEffect *base = This->base_effect;
3031 TRACE("Forward iface %p, base %p\n", This, base);
3033 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
3036 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3038 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3039 ID3DXBaseEffect *base = This->base_effect;
3041 TRACE("Forward iface %p, base %p\n", This, base);
3043 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
3046 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3048 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3049 ID3DXBaseEffect *base = This->base_effect;
3051 TRACE("Forward iface %p, base %p\n", This, base);
3053 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
3056 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3058 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3059 ID3DXBaseEffect *base = This->base_effect;
3061 TRACE("Forward iface %p, base %p\n", This, base);
3063 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
3066 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3068 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3069 ID3DXBaseEffect *base = This->base_effect;
3071 TRACE("Forward iface %p, base %p\n", This, base);
3073 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
3076 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3078 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3079 ID3DXBaseEffect *base = This->base_effect;
3081 TRACE("Forward iface %p, base %p\n", This, base);
3083 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3086 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3088 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3089 ID3DXBaseEffect *base = This->base_effect;
3091 TRACE("Forward iface %p, base %p\n", This, base);
3093 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3096 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3098 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3099 ID3DXBaseEffect *base = This->base_effect;
3101 TRACE("Forward iface %p, base %p\n", This, base);
3103 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3106 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3108 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3109 ID3DXBaseEffect *base = This->base_effect;
3111 TRACE("Forward iface %p, base %p\n", This, base);
3113 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3116 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3118 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3119 ID3DXBaseEffect *base = This->base_effect;
3121 TRACE("Forward iface %p, base %p\n", This, base);
3123 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3126 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3128 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3129 ID3DXBaseEffect *base = This->base_effect;
3131 TRACE("Forward iface %p, base %p\n", This, base);
3133 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3136 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3138 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3139 ID3DXBaseEffect *base = This->base_effect;
3141 TRACE("Forward iface %p, base %p\n", This, base);
3143 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3146 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3148 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3149 ID3DXBaseEffect *base = This->base_effect;
3151 TRACE("Forward iface %p, base %p\n", This, base);
3153 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3156 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3158 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3159 ID3DXBaseEffect *base = This->base_effect;
3161 TRACE("Forward iface %p, base %p\n", This, base);
3163 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3166 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3168 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3169 ID3DXBaseEffect *base = This->base_effect;
3171 TRACE("Forward iface %p, base %p\n", This, base);
3173 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3176 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3178 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3179 ID3DXBaseEffect *base = This->base_effect;
3181 TRACE("Forward iface %p, base %p\n", This, base);
3183 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3186 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3188 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3189 ID3DXBaseEffect *base = This->base_effect;
3191 TRACE("Forward iface %p, base %p\n", This, base);
3193 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3196 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3198 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3199 ID3DXBaseEffect *base = This->base_effect;
3201 TRACE("Forward iface %p, base %p\n", This, base);
3203 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3206 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3208 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3209 ID3DXBaseEffect *base = This->base_effect;
3211 TRACE("Forward iface %p, base %p\n", This, base);
3213 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3216 /*** ID3DXEffectCompiler methods ***/
3217 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3219 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3221 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3223 return E_NOTIMPL;
3226 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3228 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3230 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3232 return E_NOTIMPL;
3235 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3236 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3238 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3240 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3242 return E_NOTIMPL;
3245 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3246 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3248 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3250 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3251 This, function, target, flags, shader, error_msgs, constant_table);
3253 return E_NOTIMPL;
3256 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3258 /*** IUnknown methods ***/
3259 ID3DXEffectCompilerImpl_QueryInterface,
3260 ID3DXEffectCompilerImpl_AddRef,
3261 ID3DXEffectCompilerImpl_Release,
3262 /*** ID3DXBaseEffect methods ***/
3263 ID3DXEffectCompilerImpl_GetDesc,
3264 ID3DXEffectCompilerImpl_GetParameterDesc,
3265 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3266 ID3DXEffectCompilerImpl_GetPassDesc,
3267 ID3DXEffectCompilerImpl_GetFunctionDesc,
3268 ID3DXEffectCompilerImpl_GetParameter,
3269 ID3DXEffectCompilerImpl_GetParameterByName,
3270 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3271 ID3DXEffectCompilerImpl_GetParameterElement,
3272 ID3DXEffectCompilerImpl_GetTechnique,
3273 ID3DXEffectCompilerImpl_GetTechniqueByName,
3274 ID3DXEffectCompilerImpl_GetPass,
3275 ID3DXEffectCompilerImpl_GetPassByName,
3276 ID3DXEffectCompilerImpl_GetFunction,
3277 ID3DXEffectCompilerImpl_GetFunctionByName,
3278 ID3DXEffectCompilerImpl_GetAnnotation,
3279 ID3DXEffectCompilerImpl_GetAnnotationByName,
3280 ID3DXEffectCompilerImpl_SetValue,
3281 ID3DXEffectCompilerImpl_GetValue,
3282 ID3DXEffectCompilerImpl_SetBool,
3283 ID3DXEffectCompilerImpl_GetBool,
3284 ID3DXEffectCompilerImpl_SetBoolArray,
3285 ID3DXEffectCompilerImpl_GetBoolArray,
3286 ID3DXEffectCompilerImpl_SetInt,
3287 ID3DXEffectCompilerImpl_GetInt,
3288 ID3DXEffectCompilerImpl_SetIntArray,
3289 ID3DXEffectCompilerImpl_GetIntArray,
3290 ID3DXEffectCompilerImpl_SetFloat,
3291 ID3DXEffectCompilerImpl_GetFloat,
3292 ID3DXEffectCompilerImpl_SetFloatArray,
3293 ID3DXEffectCompilerImpl_GetFloatArray,
3294 ID3DXEffectCompilerImpl_SetVector,
3295 ID3DXEffectCompilerImpl_GetVector,
3296 ID3DXEffectCompilerImpl_SetVectorArray,
3297 ID3DXEffectCompilerImpl_GetVectorArray,
3298 ID3DXEffectCompilerImpl_SetMatrix,
3299 ID3DXEffectCompilerImpl_GetMatrix,
3300 ID3DXEffectCompilerImpl_SetMatrixArray,
3301 ID3DXEffectCompilerImpl_GetMatrixArray,
3302 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3303 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3304 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3305 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3306 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3307 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3308 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3309 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3310 ID3DXEffectCompilerImpl_SetString,
3311 ID3DXEffectCompilerImpl_GetString,
3312 ID3DXEffectCompilerImpl_SetTexture,
3313 ID3DXEffectCompilerImpl_GetTexture,
3314 ID3DXEffectCompilerImpl_GetPixelShader,
3315 ID3DXEffectCompilerImpl_GetVertexShader,
3316 ID3DXEffectCompilerImpl_SetArrayRange,
3317 /*** ID3DXEffectCompiler methods ***/
3318 ID3DXEffectCompilerImpl_SetLiteral,
3319 ID3DXEffectCompilerImpl_GetLiteral,
3320 ID3DXEffectCompilerImpl_CompileEffect,
3321 ID3DXEffectCompilerImpl_CompileShader,
3324 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char **ptr)
3326 unsigned int i;
3327 HRESULT hr;
3328 UINT old_size = 0;
3329 DWORD id;
3331 if (param->element_count)
3333 param->data = value;
3335 for (i = 0; i < param->element_count; ++i)
3337 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3339 hr = d3dx9_parse_value(member, (char *)value + old_size, ptr);
3340 if (hr != D3D_OK)
3342 WARN("Failed to parse value\n");
3343 return hr;
3346 old_size += member->bytes;
3349 return D3D_OK;
3352 switch(param->class)
3354 case D3DXPC_SCALAR:
3355 case D3DXPC_VECTOR:
3356 case D3DXPC_MATRIX_ROWS:
3357 case D3DXPC_MATRIX_COLUMNS:
3358 param->data = value;
3359 break;
3361 case D3DXPC_STRUCT:
3362 param->data = value;
3364 for (i = 0; i < param->member_count; ++i)
3366 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3368 hr = d3dx9_parse_value(member, (char *)value + old_size, ptr);
3369 if (hr != D3D_OK)
3371 WARN("Failed to parse value\n");
3372 return hr;
3375 old_size += member->bytes;
3377 break;
3379 case D3DXPC_OBJECT:
3380 switch (param->type)
3382 case D3DXPT_STRING:
3383 case D3DXPT_TEXTURE:
3384 case D3DXPT_TEXTURE1D:
3385 case D3DXPT_TEXTURE2D:
3386 case D3DXPT_TEXTURE3D:
3387 case D3DXPT_TEXTURECUBE:
3388 case D3DXPT_PIXELSHADER:
3389 case D3DXPT_VERTEXSHADER:
3390 read_dword(ptr, &id);
3391 TRACE("Id: %u\n", id);
3392 param->base->objects[id] = get_parameter_handle(param);
3393 param->data = value;
3394 break;
3396 default:
3397 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3398 break;
3400 break;
3402 default:
3403 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3404 break;
3407 return D3D_OK;
3410 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *ptr)
3412 UINT size = param->bytes;
3413 HRESULT hr;
3414 void *value = NULL;
3416 TRACE("param size: %u\n", size);
3418 value = HeapAlloc(GetProcessHeap(), 0, size);
3419 if (!value)
3421 ERR("Failed to allocate data memory.\n");
3422 return E_OUTOFMEMORY;
3425 TRACE("Data: %s.\n", debugstr_an(ptr, size));
3426 memcpy(value, ptr, size);
3428 hr = d3dx9_parse_value(param, value, &ptr);
3429 if (hr != D3D_OK)
3431 WARN("Failed to parse value\n");
3432 HeapFree(GetProcessHeap(), 0, value);
3433 return hr;
3436 param->data = value;
3438 return D3D_OK;
3441 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
3443 DWORD size;
3445 read_dword(&ptr, &size);
3446 TRACE("Name size: %#x\n", size);
3448 if (!size)
3450 return D3D_OK;
3453 *name = HeapAlloc(GetProcessHeap(), 0, size);
3454 if (!*name)
3456 ERR("Failed to allocate name memory.\n");
3457 return E_OUTOFMEMORY;
3460 TRACE("Name: %s.\n", debugstr_an(ptr, size));
3461 memcpy(*name, ptr, size);
3463 return D3D_OK;
3466 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr)
3468 DWORD size;
3469 HRESULT hr;
3471 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
3473 read_dword(ptr, &size);
3474 TRACE("Data size: %#x\n", size);
3476 if (!size)
3478 TRACE("Size is 0\n");
3479 *(void **)param->data = NULL;
3480 return D3D_OK;
3483 switch (param->type)
3485 case D3DXPT_STRING:
3486 /* re-read with size (sizeof(DWORD) = 4) */
3487 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
3488 if (hr != D3D_OK)
3490 WARN("Failed to parse string data\n");
3491 return hr;
3493 break;
3495 case D3DXPT_VERTEXSHADER:
3496 hr = IDirect3DDevice9_CreateVertexShader(param->base->effect->device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
3497 if (hr != D3D_OK)
3499 WARN("Failed to create vertex shader\n");
3500 return hr;
3502 break;
3504 case D3DXPT_PIXELSHADER:
3505 hr = IDirect3DDevice9_CreatePixelShader(param->base->effect->device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
3506 if (hr != D3D_OK)
3508 WARN("Failed to create pixel shader\n");
3509 return hr;
3511 break;
3513 default:
3514 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3515 break;
3519 *ptr += ((size + 3) & ~3);
3521 return D3D_OK;
3524 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
3525 struct d3dx_parameter *parent, UINT flags)
3527 DWORD offset;
3528 HRESULT hr;
3529 D3DXHANDLE *member_handles = NULL;
3530 UINT i;
3532 param->flags = flags;
3534 if (!parent)
3536 read_dword(ptr, &param->type);
3537 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
3539 read_dword(ptr, &param->class);
3540 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
3542 read_dword(ptr, &offset);
3543 TRACE("Type name offset: %#x\n", offset);
3544 hr = d3dx9_parse_name(&param->name, data + offset);
3545 if (hr != D3D_OK)
3547 WARN("Failed to parse name\n");
3548 goto err_out;
3551 read_dword(ptr, &offset);
3552 TRACE("Type semantic offset: %#x\n", offset);
3553 hr = d3dx9_parse_name(&param->semantic, data + offset);
3554 if (hr != D3D_OK)
3556 WARN("Failed to parse semantic\n");
3557 goto err_out;
3560 read_dword(ptr, &param->element_count);
3561 TRACE("Elements: %u\n", param->element_count);
3563 switch (param->class)
3565 case D3DXPC_VECTOR:
3566 read_dword(ptr, &param->columns);
3567 TRACE("Columns: %u\n", param->columns);
3569 read_dword(ptr, &param->rows);
3570 TRACE("Rows: %u\n", param->rows);
3572 /* sizeof(DWORD) * rows * columns */
3573 param->bytes = 4 * param->rows * param->columns;
3574 break;
3576 case D3DXPC_SCALAR:
3577 case D3DXPC_MATRIX_ROWS:
3578 case D3DXPC_MATRIX_COLUMNS:
3579 read_dword(ptr, &param->rows);
3580 TRACE("Rows: %u\n", param->rows);
3582 read_dword(ptr, &param->columns);
3583 TRACE("Columns: %u\n", param->columns);
3585 /* sizeof(DWORD) * rows * columns */
3586 param->bytes = 4 * param->rows * param->columns;
3587 break;
3589 case D3DXPC_STRUCT:
3590 read_dword(ptr, &param->member_count);
3591 TRACE("Members: %u\n", param->member_count);
3592 break;
3594 case D3DXPC_OBJECT:
3595 switch (param->type)
3597 case D3DXPT_STRING:
3598 param->bytes = sizeof(LPCSTR);
3599 break;
3601 case D3DXPT_PIXELSHADER:
3602 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
3603 break;
3605 case D3DXPT_VERTEXSHADER:
3606 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
3607 break;
3609 case D3DXPT_TEXTURE:
3610 case D3DXPT_TEXTURE1D:
3611 case D3DXPT_TEXTURE2D:
3612 case D3DXPT_TEXTURE3D:
3613 case D3DXPT_TEXTURECUBE:
3614 param->bytes = sizeof(LPDIRECT3DBASETEXTURE9);
3615 break;
3617 default:
3618 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3619 break;
3621 break;
3623 default:
3624 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3625 break;
3628 else
3630 /* elements */
3631 param->type = parent->type;
3632 param->class = parent->class;
3633 param->name = parent->name;
3634 param->semantic = parent->semantic;
3635 param->element_count = 0;
3636 param->annotation_count = 0;
3637 param->member_count = parent->member_count;
3638 param->bytes = parent->bytes;
3639 param->rows = parent->rows;
3640 param->columns = parent->columns;
3643 if (param->element_count)
3645 unsigned int param_bytes = 0;
3646 const char *save_ptr = *ptr;
3648 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
3649 if (!member_handles)
3651 ERR("Out of memory\n");
3652 hr = E_OUTOFMEMORY;
3653 goto err_out;
3656 for (i = 0; i < param->element_count; ++i)
3658 struct d3dx_parameter *member;
3659 *ptr = save_ptr;
3661 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
3662 if (!member)
3664 ERR("Out of memory\n");
3665 hr = E_OUTOFMEMORY;
3666 goto err_out;
3669 member_handles[i] = get_parameter_handle(member);
3670 member->base = param->base;
3672 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
3673 if (hr != D3D_OK)
3675 WARN("Failed to parse member\n");
3676 goto err_out;
3679 param_bytes += member->bytes;
3682 param->bytes = param_bytes;
3684 else if (param->member_count)
3686 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
3687 if (!member_handles)
3689 ERR("Out of memory\n");
3690 hr = E_OUTOFMEMORY;
3691 goto err_out;
3694 for (i = 0; i < param->member_count; ++i)
3696 struct d3dx_parameter *member;
3698 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
3699 if (!member)
3701 ERR("Out of memory\n");
3702 hr = E_OUTOFMEMORY;
3703 goto err_out;
3706 member_handles[i] = get_parameter_handle(member);
3707 member->base = param->base;
3709 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
3710 if (hr != D3D_OK)
3712 WARN("Failed to parse member\n");
3713 goto err_out;
3716 param->bytes += member->bytes;
3720 param->member_handles = member_handles;
3722 return D3D_OK;
3724 err_out:
3726 if (member_handles)
3728 unsigned int count;
3730 if (param->element_count) count = param->element_count;
3731 else count = param->member_count;
3733 for (i = 0; i < count; ++i)
3735 free_parameter(member_handles[i], param->element_count != 0, TRUE);
3737 HeapFree(GetProcessHeap(), 0, member_handles);
3740 if (!parent)
3742 HeapFree(GetProcessHeap(), 0, param->name);
3743 HeapFree(GetProcessHeap(), 0, param->semantic);
3745 param->name = NULL;
3746 param->semantic = NULL;
3748 return hr;
3751 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr)
3753 DWORD offset;
3754 const char *ptr2;
3755 HRESULT hr;
3757 anno->flags = D3DX_PARAMETER_ANNOTATION;
3759 read_dword(ptr, &offset);
3760 TRACE("Typedef offset: %#x\n", offset);
3761 ptr2 = data + offset;
3762 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
3763 if (hr != D3D_OK)
3765 WARN("Failed to parse type definition\n");
3766 return hr;
3769 read_dword(ptr, &offset);
3770 TRACE("Value offset: %#x\n", offset);
3771 hr = d3dx9_parse_init_value(anno, data + offset);
3772 if (hr != D3D_OK)
3774 WARN("Failed to parse value\n");
3775 return hr;
3778 return D3D_OK;
3781 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr)
3783 DWORD offset;
3784 HRESULT hr;
3785 unsigned int i;
3786 D3DXHANDLE *annotation_handles = NULL;
3787 const char *ptr2;
3789 read_dword(ptr, &offset);
3790 TRACE("Typedef offset: %#x\n", offset);
3791 ptr2 = data + offset;
3793 read_dword(ptr, &offset);
3794 TRACE("Value offset: %#x\n", offset);
3796 read_dword(ptr, &param->flags);
3797 TRACE("Flags: %#x\n", param->flags);
3799 read_dword(ptr, &param->annotation_count);
3800 TRACE("Annotation count: %u\n", param->annotation_count);
3802 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
3803 if (hr != D3D_OK)
3805 WARN("Failed to parse type definition\n");
3806 return hr;
3809 hr = d3dx9_parse_init_value(param, data + offset);
3810 if (hr != D3D_OK)
3812 WARN("Failed to parse value\n");
3813 return hr;
3816 if (param->annotation_count)
3818 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
3819 if (!annotation_handles)
3821 ERR("Out of memory\n");
3822 hr = E_OUTOFMEMORY;
3823 goto err_out;
3826 for (i = 0; i < param->annotation_count; ++i)
3828 struct d3dx_parameter *annotation;
3830 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3831 if (!annotation)
3833 ERR("Out of memory\n");
3834 hr = E_OUTOFMEMORY;
3835 goto err_out;
3838 annotation_handles[i] = get_parameter_handle(annotation);
3839 annotation->base = param->base;
3841 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3842 if (hr != D3D_OK)
3844 WARN("Failed to parse annotation\n");
3845 goto err_out;
3850 param->annotation_handles = annotation_handles;
3852 return D3D_OK;
3854 err_out:
3856 if (annotation_handles)
3858 for (i = 0; i < param->annotation_count; ++i)
3860 free_parameter(annotation_handles[i], FALSE, FALSE);
3862 HeapFree(GetProcessHeap(), 0, annotation_handles);
3865 return hr;
3868 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr)
3870 DWORD offset;
3871 HRESULT hr;
3872 unsigned int i;
3873 D3DXHANDLE *annotation_handles = NULL;
3874 char *name = NULL;
3876 read_dword(ptr, &offset);
3877 TRACE("Pass name offset: %#x\n", offset);
3878 hr = d3dx9_parse_name(&name, data + offset);
3879 if (hr != D3D_OK)
3881 WARN("Failed to parse name\n");
3882 goto err_out;
3885 read_dword(ptr, &pass->annotation_count);
3886 TRACE("Annotation count: %u\n", pass->annotation_count);
3888 read_dword(ptr, &pass->state_count);
3889 TRACE("State count: %u\n", pass->state_count);
3891 if (pass->annotation_count)
3893 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
3894 if (!annotation_handles)
3896 ERR("Out of memory\n");
3897 hr = E_OUTOFMEMORY;
3898 goto err_out;
3901 for (i = 0; i < pass->annotation_count; ++i)
3903 struct d3dx_parameter *annotation;
3905 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3906 if (!annotation)
3908 ERR("Out of memory\n");
3909 hr = E_OUTOFMEMORY;
3910 goto err_out;
3913 annotation_handles[i] = get_parameter_handle(annotation);
3914 annotation->base = pass->base;
3916 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3917 if (hr != D3D_OK)
3919 WARN("Failed to parse annotations\n");
3920 goto err_out;
3925 if (pass->state_count)
3927 for (i = 0; i < pass->state_count; ++i)
3929 skip_dword_unknown(ptr, 4);
3933 pass->name = name;
3934 pass->annotation_handles = annotation_handles;
3936 return D3D_OK;
3938 err_out:
3940 if (annotation_handles)
3942 for (i = 0; i < pass->annotation_count; ++i)
3944 free_parameter(annotation_handles[i], FALSE, FALSE);
3946 HeapFree(GetProcessHeap(), 0, annotation_handles);
3949 HeapFree(GetProcessHeap(), 0, name);
3951 return hr;
3954 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr)
3956 DWORD offset;
3957 HRESULT hr;
3958 unsigned int i;
3959 D3DXHANDLE *annotation_handles = NULL;
3960 D3DXHANDLE *pass_handles = NULL;
3961 char *name = NULL;
3963 read_dword(ptr, &offset);
3964 TRACE("Technique name offset: %#x\n", offset);
3965 hr = d3dx9_parse_name(&name, data + offset);
3966 if (hr != D3D_OK)
3968 WARN("Failed to parse name\n");
3969 goto err_out;
3972 read_dword(ptr, &technique->annotation_count);
3973 TRACE("Annotation count: %u\n", technique->annotation_count);
3975 read_dword(ptr, &technique->pass_count);
3976 TRACE("Pass count: %u\n", technique->pass_count);
3978 if (technique->annotation_count)
3980 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
3981 if (!annotation_handles)
3983 ERR("Out of memory\n");
3984 hr = E_OUTOFMEMORY;
3985 goto err_out;
3988 for (i = 0; i < technique->annotation_count; ++i)
3990 struct d3dx_parameter *annotation;
3992 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3993 if (!annotation)
3995 ERR("Out of memory\n");
3996 hr = E_OUTOFMEMORY;
3997 goto err_out;
4000 annotation_handles[i] = get_parameter_handle(annotation);
4001 annotation->base = technique->base;
4003 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
4004 if (hr != D3D_OK)
4006 WARN("Failed to parse annotations\n");
4007 goto err_out;
4012 if (technique->pass_count)
4014 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
4015 if (!pass_handles)
4017 ERR("Out of memory\n");
4018 hr = E_OUTOFMEMORY;
4019 goto err_out;
4022 for (i = 0; i < technique->pass_count; ++i)
4024 struct d3dx_pass *pass;
4026 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
4027 if (!pass)
4029 ERR("Out of memory\n");
4030 hr = E_OUTOFMEMORY;
4031 goto err_out;
4034 pass_handles[i] = get_pass_handle(pass);
4035 pass->base = technique->base;
4037 hr = d3dx9_parse_effect_pass(pass, data, ptr);
4038 if (hr != D3D_OK)
4040 WARN("Failed to parse passes\n");
4041 goto err_out;
4046 technique->name = name;
4047 technique->pass_handles = pass_handles;
4048 technique->annotation_handles = annotation_handles;
4050 return D3D_OK;
4052 err_out:
4054 if (pass_handles)
4056 for (i = 0; i < technique->pass_count; ++i)
4058 free_pass(pass_handles[i]);
4060 HeapFree(GetProcessHeap(), 0, pass_handles);
4063 if (annotation_handles)
4065 for (i = 0; i < technique->annotation_count; ++i)
4067 free_parameter(annotation_handles[i], FALSE, FALSE);
4069 HeapFree(GetProcessHeap(), 0, annotation_handles);
4072 HeapFree(GetProcessHeap(), 0, name);
4074 return hr;
4077 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
4079 const char *ptr = data + start;
4080 D3DXHANDLE *parameter_handles = NULL;
4081 D3DXHANDLE *technique_handles = NULL;
4082 D3DXHANDLE *objects = NULL;
4083 unsigned int stringcount;
4084 HRESULT hr;
4085 unsigned int i;
4087 read_dword(&ptr, &base->parameter_count);
4088 TRACE("Parameter count: %u\n", base->parameter_count);
4090 read_dword(&ptr, &base->technique_count);
4091 TRACE("Technique count: %u\n", base->technique_count);
4093 skip_dword_unknown(&ptr, 1);
4095 read_dword(&ptr, &base->object_count);
4096 TRACE("Object count: %u\n", base->object_count);
4098 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * base->object_count);
4099 if (!objects)
4101 ERR("Out of memory\n");
4102 hr = E_OUTOFMEMORY;
4103 goto err_out;
4106 base->objects = objects;
4108 if (base->parameter_count)
4110 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4111 if (!parameter_handles)
4113 ERR("Out of memory\n");
4114 hr = E_OUTOFMEMORY;
4115 goto err_out;
4118 for (i = 0; i < base->parameter_count; ++i)
4120 struct d3dx_parameter *parameter;
4122 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4123 if (!parameter)
4125 ERR("Out of memory\n");
4126 hr = E_OUTOFMEMORY;
4127 goto err_out;
4130 parameter_handles[i] = get_parameter_handle(parameter);
4131 parameter->base = base;
4133 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr);
4134 if (hr != D3D_OK)
4136 WARN("Failed to parse parameter\n");
4137 goto err_out;
4142 if (base->technique_count)
4144 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4145 if (!technique_handles)
4147 ERR("Out of memory\n");
4148 hr = E_OUTOFMEMORY;
4149 goto err_out;
4152 for (i = 0; i < base->technique_count; ++i)
4154 struct d3dx_technique *technique;
4156 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4157 if (!technique)
4159 ERR("Out of memory\n");
4160 hr = E_OUTOFMEMORY;
4161 goto err_out;
4164 technique_handles[i] = get_technique_handle(technique);
4165 technique->base = base;
4167 hr = d3dx9_parse_effect_technique(technique, data, &ptr);
4168 if (hr != D3D_OK)
4170 WARN("Failed to parse technique\n");
4171 goto err_out;
4176 read_dword(&ptr, &stringcount);
4177 TRACE("String count: %u\n", stringcount);
4179 skip_dword_unknown(&ptr, 1);
4181 for (i = 0; i < stringcount; ++i)
4183 DWORD id;
4184 struct d3dx_parameter *param;
4186 read_dword(&ptr, &id);
4187 TRACE("Id: %u\n", id);
4189 param = get_parameter_struct(base->objects[id]);
4191 hr = d3dx9_parse_data(param, &ptr);
4192 if (hr != D3D_OK)
4194 WARN("Failed to parse data\n");
4195 goto err_out;
4199 HeapFree(GetProcessHeap(), 0, objects);
4200 base->objects = NULL;
4202 base->technique_handles = technique_handles;
4203 base->parameter_handles = parameter_handles;
4205 return D3D_OK;
4207 err_out:
4209 if (technique_handles)
4211 for (i = 0; i < base->technique_count; ++i)
4213 free_technique(technique_handles[i]);
4215 HeapFree(GetProcessHeap(), 0, technique_handles);
4218 if (parameter_handles)
4220 for (i = 0; i < base->parameter_count; ++i)
4222 free_parameter(parameter_handles[i], FALSE, FALSE);
4224 HeapFree(GetProcessHeap(), 0, parameter_handles);
4227 HeapFree(GetProcessHeap(), 0, objects);
4229 return hr;
4232 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
4233 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
4235 DWORD tag, offset;
4236 const char *ptr = data;
4237 HRESULT hr;
4239 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
4241 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
4242 base->ref = 1;
4243 base->effect = effect;
4245 read_dword(&ptr, &tag);
4246 TRACE("Tag: %x\n", tag);
4248 if (tag != d3dx9_effect_version(9, 1))
4250 /* todo: compile hlsl ascii code */
4251 FIXME("HLSL ascii effects not supported, yet\n");
4253 /* Show the start of the shader for debugging info. */
4254 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
4256 else
4258 read_dword(&ptr, &offset);
4259 TRACE("Offset: %x\n", offset);
4261 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
4262 if (hr != D3D_OK)
4264 FIXME("Failed to parse effect.\n");
4265 return hr;
4269 return D3D_OK;
4272 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
4273 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
4275 HRESULT hr;
4276 struct ID3DXBaseEffectImpl *object = NULL;
4278 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
4280 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
4281 effect->ref = 1;
4283 if (pool) pool->lpVtbl->AddRef(pool);
4284 effect->pool = pool;
4286 IDirect3DDevice9_AddRef(device);
4287 effect->device = device;
4289 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4290 if (!object)
4292 ERR("Out of memory\n");
4293 hr = E_OUTOFMEMORY;
4294 goto err_out;
4297 hr = d3dx9_base_effect_init(object, data, data_size, effect);
4298 if (hr != D3D_OK)
4300 FIXME("Failed to parse effect.\n");
4301 goto err_out;
4304 effect->base_effect = &object->ID3DXBaseEffect_iface;
4306 return D3D_OK;
4308 err_out:
4310 HeapFree(GetProcessHeap(), 0, object);
4311 free_effect(effect);
4313 return hr;
4316 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
4317 LPCVOID srcdata,
4318 UINT srcdatalen,
4319 CONST D3DXMACRO* defines,
4320 LPD3DXINCLUDE include,
4321 LPCSTR skip_constants,
4322 DWORD flags,
4323 LPD3DXEFFECTPOOL pool,
4324 LPD3DXEFFECT* effect,
4325 LPD3DXBUFFER* compilation_errors)
4327 struct ID3DXEffectImpl *object;
4328 HRESULT hr;
4330 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
4331 skip_constants, flags, pool, effect, compilation_errors);
4333 if (!device || !srcdata)
4334 return D3DERR_INVALIDCALL;
4336 if (!srcdatalen)
4337 return E_FAIL;
4339 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
4340 if (!effect)
4341 return D3D_OK;
4343 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4344 if (!object)
4346 ERR("Out of memory\n");
4347 return E_OUTOFMEMORY;
4350 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
4351 if (FAILED(hr))
4353 WARN("Failed to initialize shader reflection\n");
4354 HeapFree(GetProcessHeap(), 0, object);
4355 return hr;
4358 *effect = &object->ID3DXEffect_iface;
4360 TRACE("Created ID3DXEffect %p\n", object);
4362 return D3D_OK;
4365 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
4366 LPCVOID srcdata,
4367 UINT srcdatalen,
4368 CONST D3DXMACRO* defines,
4369 LPD3DXINCLUDE include,
4370 DWORD flags,
4371 LPD3DXEFFECTPOOL pool,
4372 LPD3DXEFFECT* effect,
4373 LPD3DXBUFFER* compilation_errors)
4375 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
4376 include, flags, pool, effect, compilation_errors);
4378 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
4381 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
4383 HRESULT hr;
4384 struct ID3DXBaseEffectImpl *object = NULL;
4386 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
4388 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
4389 compiler->ref = 1;
4391 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4392 if (!object)
4394 ERR("Out of memory\n");
4395 hr = E_OUTOFMEMORY;
4396 goto err_out;
4399 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
4400 if (hr != D3D_OK)
4402 FIXME("Failed to parse effect.\n");
4403 goto err_out;
4406 compiler->base_effect = &object->ID3DXBaseEffect_iface;
4408 return D3D_OK;
4410 err_out:
4412 HeapFree(GetProcessHeap(), 0, object);
4413 free_effect_compiler(compiler);
4415 return hr;
4418 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
4419 UINT srcdatalen,
4420 CONST D3DXMACRO *defines,
4421 LPD3DXINCLUDE include,
4422 DWORD flags,
4423 LPD3DXEFFECTCOMPILER *compiler,
4424 LPD3DXBUFFER *parse_errors)
4426 struct ID3DXEffectCompilerImpl *object;
4427 HRESULT hr;
4429 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
4430 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
4432 if (!srcdata || !compiler)
4434 WARN("Invalid arguments supplied\n");
4435 return D3DERR_INVALIDCALL;
4438 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4439 if (!object)
4441 ERR("Out of memory\n");
4442 return E_OUTOFMEMORY;
4445 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
4446 if (FAILED(hr))
4448 WARN("Failed to initialize effect compiler\n");
4449 HeapFree(GetProcessHeap(), 0, object);
4450 return hr;
4453 *compiler = &object->ID3DXEffectCompiler_iface;
4455 TRACE("Created ID3DXEffectCompiler %p\n", object);
4457 return D3D_OK;
4460 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
4462 struct ID3DXEffectPoolImpl
4464 ID3DXEffectPool ID3DXEffectPool_iface;
4465 LONG ref;
4468 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
4470 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
4473 /*** IUnknown methods ***/
4474 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
4476 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4478 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
4480 if (IsEqualGUID(riid, &IID_IUnknown) ||
4481 IsEqualGUID(riid, &IID_ID3DXEffectPool))
4483 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
4484 *object = This;
4485 return S_OK;
4488 WARN("Interface %s not found\n", debugstr_guid(riid));
4490 return E_NOINTERFACE;
4493 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
4495 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4497 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
4499 return InterlockedIncrement(&This->ref);
4502 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
4504 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4505 ULONG ref = InterlockedDecrement(&This->ref);
4507 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
4509 if (!ref)
4510 HeapFree(GetProcessHeap(), 0, This);
4512 return ref;
4515 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
4517 /*** IUnknown methods ***/
4518 ID3DXEffectPoolImpl_QueryInterface,
4519 ID3DXEffectPoolImpl_AddRef,
4520 ID3DXEffectPoolImpl_Release
4523 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
4525 struct ID3DXEffectPoolImpl *object;
4527 TRACE("(%p)\n", pool);
4529 if (!pool)
4530 return D3DERR_INVALIDCALL;
4532 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4533 if (!object)
4535 ERR("Out of memory\n");
4536 return E_OUTOFMEMORY;
4539 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
4540 object->ref = 1;
4542 *pool = &object->ID3DXEffectPool_iface;
4544 return S_OK;
4547 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4548 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4549 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4551 LPVOID buffer;
4552 HRESULT ret;
4553 DWORD size;
4555 TRACE("(%s): relay\n", debugstr_w(srcfile));
4557 if (!device || !srcfile)
4558 return D3DERR_INVALIDCALL;
4560 ret = map_view_of_file(srcfile, &buffer, &size);
4562 if (FAILED(ret))
4563 return D3DXERR_INVALIDDATA;
4565 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4566 UnmapViewOfFile(buffer);
4568 return ret;
4571 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
4572 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4573 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4575 LPWSTR srcfileW;
4576 HRESULT ret;
4577 DWORD len;
4579 TRACE("(void): relay\n");
4581 if (!srcfile)
4582 return D3DERR_INVALIDCALL;
4584 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
4585 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
4586 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
4588 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4589 HeapFree(GetProcessHeap(), 0, srcfileW);
4591 return ret;
4594 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4595 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4596 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4598 TRACE("(void): relay\n");
4599 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
4602 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
4603 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4604 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4606 TRACE("(void): relay\n");
4607 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
4610 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
4611 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4612 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4614 HRSRC resinfo;
4616 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
4618 if (!device)
4619 return D3DERR_INVALIDCALL;
4621 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
4623 if (resinfo)
4625 LPVOID buffer;
4626 HRESULT ret;
4627 DWORD size;
4629 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4631 if (FAILED(ret))
4632 return D3DXERR_INVALIDDATA;
4634 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4637 return D3DXERR_INVALIDDATA;
4640 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
4641 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4642 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4644 HRSRC resinfo;
4646 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
4648 if (!device)
4649 return D3DERR_INVALIDCALL;
4651 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
4653 if (resinfo)
4655 LPVOID buffer;
4656 HRESULT ret;
4657 DWORD size;
4659 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4661 if (FAILED(ret))
4662 return D3DXERR_INVALIDDATA;
4664 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4667 return D3DXERR_INVALIDDATA;
4670 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
4671 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4672 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4674 TRACE("(void): relay\n");
4675 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
4678 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
4679 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4680 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4682 TRACE("(void): relay\n");
4683 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
4686 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
4687 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4689 LPVOID buffer;
4690 HRESULT ret;
4691 DWORD size;
4693 TRACE("(%s): relay\n", debugstr_w(srcfile));
4695 if (!srcfile)
4696 return D3DERR_INVALIDCALL;
4698 ret = map_view_of_file(srcfile, &buffer, &size);
4700 if (FAILED(ret))
4701 return D3DXERR_INVALIDDATA;
4703 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4704 UnmapViewOfFile(buffer);
4706 return ret;
4709 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
4710 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4712 LPWSTR srcfileW;
4713 HRESULT ret;
4714 DWORD len;
4716 TRACE("(void): relay\n");
4718 if (!srcfile)
4719 return D3DERR_INVALIDCALL;
4721 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
4722 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
4723 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
4725 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
4726 HeapFree(GetProcessHeap(), 0, srcfileW);
4728 return ret;
4731 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
4732 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4734 HRSRC resinfo;
4736 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
4738 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
4740 if (resinfo)
4742 LPVOID buffer;
4743 HRESULT ret;
4744 DWORD size;
4746 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4748 if (FAILED(ret))
4749 return D3DXERR_INVALIDDATA;
4751 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4754 return D3DXERR_INVALIDDATA;
4757 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
4758 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4760 HRSRC resinfo;
4762 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
4764 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
4766 if (resinfo)
4768 LPVOID buffer;
4769 HRESULT ret;
4770 DWORD size;
4772 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4774 if (FAILED(ret))
4775 return D3DXERR_INVALIDDATA;
4777 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4780 return D3DXERR_INVALIDDATA;