atl80: Added AtlComModuleRegisterServer implementation (based on AtlModuleRegisterSer...
[wine] / dlls / d3d10 / effect.c
1 /*
2  * Copyright 2009 Henri Verbeet for CodeWeavers
3  * Copyright 2009 Rico Schüller
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  *
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include "d3d10_private.h"
25
26 #include <float.h>
27
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
29
30 #define D3D10_FX10_TYPE_COLUMN_SHIFT    11
31 #define D3D10_FX10_TYPE_COLUMN_MASK     (0x7 << D3D10_FX10_TYPE_COLUMN_SHIFT)
32
33 #define D3D10_FX10_TYPE_ROW_SHIFT       8
34 #define D3D10_FX10_TYPE_ROW_MASK        (0x7 << D3D10_FX10_TYPE_ROW_SHIFT)
35
36 #define D3D10_FX10_TYPE_BASETYPE_SHIFT  3
37 #define D3D10_FX10_TYPE_BASETYPE_MASK   (0x1f << D3D10_FX10_TYPE_BASETYPE_SHIFT)
38
39 #define D3D10_FX10_TYPE_CLASS_SHIFT     0
40 #define D3D10_FX10_TYPE_CLASS_MASK      (0x7 << D3D10_FX10_TYPE_CLASS_SHIFT)
41
42 #define D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK 0x4000
43
44 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl;
45 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl;
46 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl;
47 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl;
48 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl;
49 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl;
50 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl;
51 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl;
52 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl;
53 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl;
54 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl;
55 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl;
56 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl;
57 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl;
58 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl;
59 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl;
60 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl;
61
62 /* null objects - needed for invalid calls */
63 static struct d3d10_effect_technique null_technique = {{&d3d10_effect_technique_vtbl}};
64 static struct d3d10_effect_pass null_pass = {{&d3d10_effect_pass_vtbl}};
65 static struct d3d10_effect_type null_type = {{&d3d10_effect_type_vtbl}};
66 static struct d3d10_effect_variable null_local_buffer = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl},
67         &null_local_buffer, &null_type};
68 static struct d3d10_effect_variable null_variable = {{&d3d10_effect_variable_vtbl},
69         &null_local_buffer, &null_type};
70 static struct d3d10_effect_variable null_scalar_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl},
71         &null_local_buffer, &null_type};
72 static struct d3d10_effect_variable null_vector_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl},
73         &null_local_buffer, &null_type};
74 static struct d3d10_effect_variable null_matrix_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl},
75         &null_local_buffer, &null_type};
76 static struct d3d10_effect_variable null_string_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl},
77         &null_local_buffer, &null_type};
78 static struct d3d10_effect_variable null_shader_resource_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl},
79         &null_local_buffer, &null_type};
80 static struct d3d10_effect_variable null_render_target_view_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl},
81         &null_local_buffer, &null_type};
82 static struct d3d10_effect_variable null_depth_stencil_view_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl},
83         &null_local_buffer, &null_type};
84 static struct d3d10_effect_variable null_shader_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
85         &null_local_buffer, &null_type};
86 static struct d3d10_effect_variable null_blend_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl},
87         &null_local_buffer, &null_type};
88 static struct d3d10_effect_variable null_depth_stencil_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl},
89         &null_local_buffer, &null_type};
90 static struct d3d10_effect_variable null_rasterizer_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl},
91         &null_local_buffer, &null_type};
92 static struct d3d10_effect_variable null_sampler_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl},
93         &null_local_buffer, &null_type};
94
95 /* anonymous_shader_type and anonymous_shader */
96 static char anonymous_name[] = "$Anonymous";
97 static char anonymous_vertexshader_name[] = "vertexshader";
98 static char anonymous_pixelshader_name[] = "pixelshader";
99 static char anonymous_geometryshader_name[] = "geometryshader";
100 static struct d3d10_effect_type anonymous_vs_type = {{&d3d10_effect_type_vtbl},
101         anonymous_vertexshader_name, D3D10_SVT_VERTEXSHADER, D3D10_SVC_OBJECT};
102 static struct d3d10_effect_type anonymous_ps_type = {{&d3d10_effect_type_vtbl},
103         anonymous_pixelshader_name, D3D10_SVT_PIXELSHADER, D3D10_SVC_OBJECT};
104 static struct d3d10_effect_type anonymous_gs_type = {{&d3d10_effect_type_vtbl},
105         anonymous_geometryshader_name, D3D10_SVT_GEOMETRYSHADER, D3D10_SVC_OBJECT};
106 static struct d3d10_effect_variable anonymous_vs = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
107         &null_local_buffer, &anonymous_vs_type, anonymous_name};
108 static struct d3d10_effect_variable anonymous_ps = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
109         &null_local_buffer, &anonymous_ps_type, anonymous_name};
110 static struct d3d10_effect_variable anonymous_gs = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
111         &null_local_buffer, &anonymous_gs_type, anonymous_name};
112
113 static struct d3d10_effect_type *get_fx10_type(struct d3d10_effect *effect, const char *data, DWORD offset);
114
115 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectVariable(ID3D10EffectVariable *iface)
116 {
117     return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
118 }
119
120 struct d3d10_effect_state_property_info
121 {
122     UINT id;
123     const char *name;
124     D3D_SHADER_VARIABLE_TYPE type;
125     UINT size;
126     UINT count;
127     D3D_SHADER_VARIABLE_TYPE container_type;
128     LONG offset;
129 };
130
131 static const struct d3d10_effect_state_property_info property_info[] =
132 {
133     {0x0c, "RasterizerState.FillMode",                    D3D10_SVT_INT,   1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, FillMode)                       },
134     {0x0d, "RasterizerState.CullMode",                    D3D10_SVT_INT,   1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, CullMode)                       },
135     {0x0e, "RasterizerState.FrontCounterClockwise",       D3D10_SVT_BOOL,  1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, FrontCounterClockwise)          },
136     {0x0f, "RasterizerState.DepthBias",                   D3D10_SVT_INT,   1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, DepthBias)                      },
137     {0x10, "RasterizerState.DepthBiasClamp",              D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, DepthBiasClamp)                 },
138     {0x11, "RasterizerState.SlopeScaledDepthBias",        D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, SlopeScaledDepthBias)           },
139     {0x12, "RasterizerState.DepthClipEnable",             D3D10_SVT_BOOL,  1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, DepthClipEnable)                },
140     {0x13, "RasterizerState.ScissorEnable",               D3D10_SVT_BOOL,  1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, ScissorEnable)                  },
141     {0x14, "RasterizerState.MultisampleEnable",           D3D10_SVT_BOOL,  1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, MultisampleEnable)              },
142     {0x15, "RasterizerState.AntialiasedLineEnable",       D3D10_SVT_BOOL,  1, 1, D3D10_SVT_RASTERIZER,   FIELD_OFFSET(D3D10_RASTERIZER_DESC, AntialiasedLineEnable)          },
143     {0x16, "DepthStencilState.DepthEnable",               D3D10_SVT_BOOL,  1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthEnable)                 },
144     {0x17, "DepthStencilState.DepthWriteMask",            D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthWriteMask)              },
145     {0x18, "DepthStencilState.DepthFunc",                 D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthFunc)                   },
146     {0x19, "DepthStencilState.StencilEnable",             D3D10_SVT_BOOL,  1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, StencilEnable)               },
147     {0x1a, "DepthStencilState.StencilReadMask",           D3D10_SVT_UINT8, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, StencilReadMask)             },
148     {0x1b, "DepthStencilState.StencilWriteMask",          D3D10_SVT_UINT8, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, StencilWriteMask)            },
149     {0x1c, "DepthStencilState.FrontFaceStencilFail",      D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilFailOp)     },
150     {0x1d, "DepthStencilState.FrontFaceStencilDepthFail", D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilDepthFailOp)},
151     {0x1e, "DepthStencilState.FrontFaceStencilPass",      D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilPassOp)     },
152     {0x1f, "DepthStencilState.FrontFaceStencilFunc",      D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilFunc)       },
153     {0x20, "DepthStencilState.BackFaceStencilFail",       D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilFailOp)      },
154     {0x21, "DepthStencilState.BackFaceStencilDepthFail",  D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilDepthFailOp) },
155     {0x22, "DepthStencilState.BackFaceStencilPass",       D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilPassOp)      },
156     {0x23, "DepthStencilState.BackFaceStencilFunc",       D3D10_SVT_INT,   1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilFunc)        },
157     {0x24, "BlendState.AlphaToCoverageEnable",            D3D10_SVT_BOOL,  1, 1, D3D10_SVT_BLEND,        FIELD_OFFSET(D3D10_BLEND_DESC,         AlphaToCoverageEnable)       },
158     {0x25, "BlendState.BlendEnable",                      D3D10_SVT_BOOL,  1, 8, D3D10_SVT_BLEND,        FIELD_OFFSET(D3D10_BLEND_DESC,         BlendEnable)                 },
159     {0x26, "BlendState.SrcBlend",                         D3D10_SVT_INT,   1, 1, D3D10_SVT_BLEND,        FIELD_OFFSET(D3D10_BLEND_DESC,         SrcBlend)                    },
160     {0x27, "BlendState.DestBlend",                        D3D10_SVT_INT,   1, 1, D3D10_SVT_BLEND,        FIELD_OFFSET(D3D10_BLEND_DESC,         DestBlend)                   },
161     {0x28, "BlendState.BlendOp",                          D3D10_SVT_INT,   1, 1, D3D10_SVT_BLEND,        FIELD_OFFSET(D3D10_BLEND_DESC,         BlendOp)                     },
162     {0x29, "BlendState.SrcBlendAlpha",                    D3D10_SVT_INT,   1, 1, D3D10_SVT_BLEND,        FIELD_OFFSET(D3D10_BLEND_DESC,         SrcBlendAlpha)               },
163     {0x2a, "BlendState.DestBlendAlpha",                   D3D10_SVT_INT,   1, 1, D3D10_SVT_BLEND,        FIELD_OFFSET(D3D10_BLEND_DESC,         DestBlendAlpha)              },
164     {0x2b, "BlendState.BlendOpAlpha",                     D3D10_SVT_INT,   1, 1, D3D10_SVT_BLEND,        FIELD_OFFSET(D3D10_BLEND_DESC,         BlendOpAlpha)                },
165     {0x2c, "BlendState.RenderTargetWriteMask",            D3D10_SVT_UINT8, 1, 8, D3D10_SVT_BLEND,        FIELD_OFFSET(D3D10_BLEND_DESC,         RenderTargetWriteMask)       },
166     {0x2d, "SamplerState.Filter",                         D3D10_SVT_INT,   1, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       Filter)                      },
167     {0x2e, "SamplerState.AddressU",                       D3D10_SVT_INT,   1, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       AddressU)                    },
168     {0x2f, "SamplerState.AddressV",                       D3D10_SVT_INT,   1, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       AddressV)                    },
169     {0x30, "SamplerState.AddressW",                       D3D10_SVT_INT,   1, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       AddressW)                    },
170     {0x31, "SamplerState.MipMapLODBias",                  D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       MipLODBias)                  },
171     {0x32, "SamplerState.MaxAnisotropy",                  D3D10_SVT_UINT,  1, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       MaxAnisotropy)               },
172     {0x33, "SamplerState.ComparisonFunc",                 D3D10_SVT_INT,   1, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       ComparisonFunc)              },
173     {0x34, "SamplerState.BorderColor",                    D3D10_SVT_FLOAT, 4, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       BorderColor)                 },
174     {0x35, "SamplerState.MinLOD",                         D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       MinLOD)                      },
175     {0x36, "SamplerState.MaxLOD",                         D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_SAMPLER,      FIELD_OFFSET(D3D10_SAMPLER_DESC,       MaxLOD)                      },
176 };
177
178 static const D3D10_RASTERIZER_DESC default_rasterizer_desc =
179 {
180     D3D10_FILL_SOLID,
181     D3D10_CULL_BACK,
182     FALSE,
183     0,
184     0.0f,
185     0.0f,
186     TRUE,
187     FALSE,
188     FALSE,
189     FALSE,
190 };
191
192 static const D3D10_DEPTH_STENCIL_DESC default_depth_stencil_desc =
193 {
194     TRUE,
195     D3D10_DEPTH_WRITE_MASK_ALL,
196     D3D10_COMPARISON_LESS,
197     FALSE,
198     D3D10_DEFAULT_STENCIL_READ_MASK,
199     D3D10_DEFAULT_STENCIL_WRITE_MASK,
200     {D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_COMPARISON_ALWAYS},
201     {D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_COMPARISON_ALWAYS},
202 };
203
204 static const D3D10_BLEND_DESC default_blend_desc =
205 {
206     FALSE,
207     {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
208     D3D10_BLEND_SRC_ALPHA,
209     D3D10_BLEND_INV_SRC_ALPHA,
210     D3D10_BLEND_OP_ADD,
211     D3D10_BLEND_SRC_ALPHA,
212     D3D10_BLEND_INV_SRC_ALPHA,
213     D3D10_BLEND_OP_ADD,
214     {0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf},
215 };
216
217 static const D3D10_SAMPLER_DESC default_sampler_desc =
218 {
219     D3D10_FILTER_MIN_MAG_MIP_POINT,
220     D3D10_TEXTURE_ADDRESS_WRAP,
221     D3D10_TEXTURE_ADDRESS_WRAP,
222     D3D10_TEXTURE_ADDRESS_WRAP,
223     0.0f,
224     16,
225     D3D10_COMPARISON_NEVER,
226     {0.0f, 0.0f, 0.0f, 0.0f},
227     0.0f,
228     FLT_MAX,
229 };
230
231 struct d3d10_effect_state_storage_info
232 {
233     D3D_SHADER_VARIABLE_TYPE id;
234     SIZE_T size;
235     const void *default_state;
236 };
237
238 static const struct d3d10_effect_state_storage_info d3d10_effect_state_storage_info[] =
239 {
240     {D3D10_SVT_RASTERIZER,   sizeof(default_rasterizer_desc),    &default_rasterizer_desc   },
241     {D3D10_SVT_DEPTHSTENCIL, sizeof(default_depth_stencil_desc), &default_depth_stencil_desc},
242     {D3D10_SVT_BLEND,        sizeof(default_blend_desc),         &default_blend_desc        },
243     {D3D10_SVT_SAMPLER,      sizeof(default_sampler_desc),       &default_sampler_desc      },
244 };
245
246 static BOOL copy_name(const char *ptr, char **name)
247 {
248     size_t name_len;
249
250     if (!ptr) return TRUE;
251
252     name_len = strlen(ptr) + 1;
253     if (name_len == 1)
254     {
255         return TRUE;
256     }
257
258     *name = HeapAlloc(GetProcessHeap(), 0, name_len);
259     if (!*name)
260     {
261         ERR("Failed to allocate name memory.\n");
262         return FALSE;
263     }
264
265     memcpy(*name, ptr, name_len);
266
267     return TRUE;
268 }
269
270 static HRESULT shader_parse_signature(const char *data, DWORD data_size, struct d3d10_effect_shader_signature *s)
271 {
272     D3D10_SIGNATURE_PARAMETER_DESC *e;
273     const char *ptr = data;
274     unsigned int i;
275     DWORD count;
276
277     read_dword(&ptr, &count);
278     TRACE("%u elements\n", count);
279
280     skip_dword_unknown("shader signature", &ptr, 1);
281
282     e = HeapAlloc(GetProcessHeap(), 0, count * sizeof(*e));
283     if (!e)
284     {
285         ERR("Failed to allocate signature memory.\n");
286         return E_OUTOFMEMORY;
287     }
288
289     for (i = 0; i < count; ++i)
290     {
291         UINT name_offset;
292         UINT mask;
293
294         read_dword(&ptr, &name_offset);
295         e[i].SemanticName = data + name_offset;
296         read_dword(&ptr, &e[i].SemanticIndex);
297         read_dword(&ptr, &e[i].SystemValueType);
298         read_dword(&ptr, &e[i].ComponentType);
299         read_dword(&ptr, &e[i].Register);
300         read_dword(&ptr, &mask);
301
302         e[i].ReadWriteMask = mask >> 8;
303         e[i].Mask = mask & 0xff;
304
305         TRACE("semantic: %s, semantic idx: %u, sysval_semantic %#x, "
306                 "type %u, register idx: %u, use_mask %#x, input_mask %#x\n",
307                 debugstr_a(e[i].SemanticName), e[i].SemanticIndex, e[i].SystemValueType,
308                 e[i].ComponentType, e[i].Register, e[i].Mask, e[i].ReadWriteMask);
309     }
310
311     s->elements = e;
312     s->element_count = count;
313
314     return S_OK;
315 }
316
317 static void shader_free_signature(struct d3d10_effect_shader_signature *s)
318 {
319     HeapFree(GetProcessHeap(), 0, s->signature);
320     HeapFree(GetProcessHeap(), 0, s->elements);
321 }
322
323 static HRESULT shader_chunk_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
324 {
325     struct d3d10_effect_shader_variable *s = ctx;
326     HRESULT hr;
327
328     TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
329
330     TRACE("chunk size: %#x\n", data_size);
331
332     switch(tag)
333     {
334         case TAG_ISGN:
335         case TAG_OSGN:
336         {
337             /* 32 (DXBC header) + 1 * 4 (chunk index) + 2 * 4 (chunk header) + data_size (chunk data) */
338             UINT size = 44 + data_size;
339             struct d3d10_effect_shader_signature *sig;
340             char *ptr;
341
342             if (tag == TAG_ISGN) sig = &s->input_signature;
343             else sig = &s->output_signature;
344
345             sig->signature = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
346             if (!sig->signature)
347             {
348                 ERR("Failed to allocate input signature data\n");
349                 return E_OUTOFMEMORY;
350             }
351             sig->signature_size = size;
352
353             ptr = sig->signature;
354
355             write_dword(&ptr, TAG_DXBC);
356
357             /* signature(?) */
358             write_dword_unknown(&ptr, 0);
359             write_dword_unknown(&ptr, 0);
360             write_dword_unknown(&ptr, 0);
361             write_dword_unknown(&ptr, 0);
362
363             /* seems to be always 1 */
364             write_dword_unknown(&ptr, 1);
365
366             /* DXBC size */
367             write_dword(&ptr, size);
368
369             /* chunk count */
370             write_dword(&ptr, 1);
371
372             /* chunk index */
373             write_dword(&ptr, (ptr - sig->signature) + 4);
374
375             /* chunk */
376             write_dword(&ptr, tag);
377             write_dword(&ptr, data_size);
378             memcpy(ptr, data, data_size);
379
380             hr = shader_parse_signature(ptr, data_size, sig);
381             if (FAILED(hr))
382             {
383                 ERR("Failed to parse shader, hr %#x\n", hr);
384                 shader_free_signature(sig);
385             }
386
387             break;
388         }
389
390         default:
391             FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag, 4));
392             break;
393     }
394
395     return S_OK;
396 }
397
398 static HRESULT parse_shader(ID3D10EffectVariable *variable, const char *data)
399 {
400     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable(variable);
401     ID3D10Device *device = v->effect->device;
402     const char *ptr = data;
403     DWORD dxbc_size;
404     HRESULT hr;
405
406     if (v->effect->used_shader_current >= v->effect->used_shader_count)
407     {
408         WARN("Invalid shader? Used shader current(%u) >= used shader count(%u)\n", v->effect->used_shader_current, v->effect->used_shader_count);
409         return E_FAIL;
410     }
411
412     v->effect->used_shaders[v->effect->used_shader_current] = v;
413     ++v->effect->used_shader_current;
414
415     if (!ptr) return S_OK;
416
417     read_dword(&ptr, &dxbc_size);
418     TRACE("dxbc size: %#x\n", dxbc_size);
419
420     /* We got a shader VertexShader vs = NULL, so it is fine to skip this. */
421     if (!dxbc_size) return S_OK;
422
423     switch (v->type->basetype)
424     {
425         case D3D10_SVT_VERTEXSHADER:
426             hr = ID3D10Device_CreateVertexShader(device, ptr, dxbc_size, &v->u.shader.shader.vs);
427             if (FAILED(hr)) return hr;
428             break;
429
430         case D3D10_SVT_PIXELSHADER:
431             hr = ID3D10Device_CreatePixelShader(device, ptr, dxbc_size, &v->u.shader.shader.ps);
432             if (FAILED(hr)) return hr;
433             break;
434
435         case D3D10_SVT_GEOMETRYSHADER:
436             hr = ID3D10Device_CreateGeometryShader(device, ptr, dxbc_size, &v->u.shader.shader.gs);
437             if (FAILED(hr)) return hr;
438             break;
439
440         default:
441             ERR("This should not happen!\n");
442             return E_FAIL;
443     }
444
445     return parse_dxbc(ptr, dxbc_size, shader_chunk_handler, &v->u.shader);
446 }
447
448 static D3D10_SHADER_VARIABLE_CLASS d3d10_variable_class(DWORD c, BOOL is_column_major)
449 {
450     switch (c)
451     {
452         case 1: return D3D10_SVC_SCALAR;
453         case 2: return D3D10_SVC_VECTOR;
454         case 3: if (is_column_major) return D3D10_SVC_MATRIX_COLUMNS;
455                 else return D3D10_SVC_MATRIX_ROWS;
456         default:
457             FIXME("Unknown variable class %#x.\n", c);
458             return 0;
459     }
460 }
461
462 static D3D10_SHADER_VARIABLE_TYPE d3d10_variable_type(DWORD t, BOOL is_object)
463 {
464     if(is_object)
465     {
466         switch (t)
467         {
468             case 1: return D3D10_SVT_STRING;
469             case 2: return D3D10_SVT_BLEND;
470             case 3: return D3D10_SVT_DEPTHSTENCIL;
471             case 4: return D3D10_SVT_RASTERIZER;
472             case 5: return D3D10_SVT_PIXELSHADER;
473             case 6: return D3D10_SVT_VERTEXSHADER;
474             case 7: return D3D10_SVT_GEOMETRYSHADER;
475
476             case 10: return D3D10_SVT_TEXTURE1D;
477             case 11: return D3D10_SVT_TEXTURE1DARRAY;
478             case 12: return D3D10_SVT_TEXTURE2D;
479             case 13: return D3D10_SVT_TEXTURE2DARRAY;
480             case 14: return D3D10_SVT_TEXTURE2DMS;
481             case 15: return D3D10_SVT_TEXTURE2DMSARRAY;
482             case 16: return D3D10_SVT_TEXTURE3D;
483             case 17: return D3D10_SVT_TEXTURECUBE;
484
485             case 19: return D3D10_SVT_RENDERTARGETVIEW;
486             case 20: return D3D10_SVT_DEPTHSTENCILVIEW;
487             case 21: return D3D10_SVT_SAMPLER;
488             case 22: return D3D10_SVT_BUFFER;
489             default:
490                 FIXME("Unknown variable type %#x.\n", t);
491                 return D3D10_SVT_VOID;
492         }
493     }
494     else
495     {
496         switch (t)
497         {
498             case 1: return D3D10_SVT_FLOAT;
499             case 2: return D3D10_SVT_INT;
500             case 3: return D3D10_SVT_UINT;
501             case 4: return D3D10_SVT_BOOL;
502             default:
503                 FIXME("Unknown variable type %#x.\n", t);
504                 return D3D10_SVT_VOID;
505         }
506     }
507 }
508
509 static HRESULT parse_fx10_type(struct d3d10_effect_type *t, const char *ptr, const char *data)
510 {
511     DWORD unknown0;
512     DWORD offset;
513     DWORD typeinfo;
514     unsigned int i;
515
516     read_dword(&ptr, &offset);
517     TRACE("Type name at offset %#x.\n", offset);
518
519     if (!copy_name(data + offset, &t->name))
520     {
521         ERR("Failed to copy name.\n");
522         return E_OUTOFMEMORY;
523     }
524     TRACE("Type name: %s.\n", debugstr_a(t->name));
525
526     read_dword(&ptr, &unknown0);
527     TRACE("Unknown 0: %u.\n", unknown0);
528
529     read_dword(&ptr, &t->element_count);
530     TRACE("Element count: %u.\n", t->element_count);
531
532     read_dword(&ptr, &t->size_unpacked);
533     TRACE("Unpacked size: %#x.\n", t->size_unpacked);
534
535     read_dword(&ptr, &t->stride);
536     TRACE("Stride: %#x.\n", t->stride);
537
538     read_dword(&ptr, &t->size_packed);
539     TRACE("Packed size %#x.\n", t->size_packed);
540
541     switch (unknown0)
542     {
543         case 1:
544             t->member_count = 0;
545
546             read_dword(&ptr, &typeinfo);
547             t->column_count = (typeinfo & D3D10_FX10_TYPE_COLUMN_MASK) >> D3D10_FX10_TYPE_COLUMN_SHIFT;
548             t->row_count = (typeinfo & D3D10_FX10_TYPE_ROW_MASK) >> D3D10_FX10_TYPE_ROW_SHIFT;
549             t->basetype = d3d10_variable_type((typeinfo & D3D10_FX10_TYPE_BASETYPE_MASK) >> D3D10_FX10_TYPE_BASETYPE_SHIFT, FALSE);
550             t->type_class = d3d10_variable_class((typeinfo & D3D10_FX10_TYPE_CLASS_MASK) >> D3D10_FX10_TYPE_CLASS_SHIFT, typeinfo & D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK);
551
552             TRACE("Type description: %#x.\n", typeinfo);
553             TRACE("\tcolumns: %u.\n", t->column_count);
554             TRACE("\trows: %u.\n", t->row_count);
555             TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t->basetype));
556             TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t->type_class));
557             TRACE("\tunknown bits: %#x.\n", typeinfo & ~(D3D10_FX10_TYPE_COLUMN_MASK | D3D10_FX10_TYPE_ROW_MASK
558                     | D3D10_FX10_TYPE_BASETYPE_MASK | D3D10_FX10_TYPE_CLASS_MASK | D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK));
559             break;
560
561         case 2:
562             TRACE("Type is an object.\n");
563
564             t->member_count = 0;
565             t->column_count = 0;
566             t->row_count = 0;
567             t->type_class = D3D10_SVC_OBJECT;
568
569             read_dword(&ptr, &typeinfo);
570             t->basetype = d3d10_variable_type(typeinfo, TRUE);
571
572             TRACE("Type description: %#x.\n", typeinfo);
573             TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t->basetype));
574             TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t->type_class));
575             break;
576
577          case 3:
578             TRACE("Type is a structure.\n");
579
580             read_dword(&ptr, &t->member_count);
581             TRACE("Member count: %u.\n", t->member_count);
582
583             t->column_count = 0;
584             t->row_count = 0;
585             t->basetype = 0;
586             t->type_class = D3D10_SVC_STRUCT;
587
588             t->members = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, t->member_count * sizeof(*t->members));
589             if (!t->members)
590             {
591                 ERR("Failed to allocate members memory.\n");
592                 return E_OUTOFMEMORY;
593             }
594
595             for (i = 0; i < t->member_count; ++i)
596             {
597                 struct d3d10_effect_type_member *typem = &t->members[i];
598
599                 read_dword(&ptr, &offset);
600                 TRACE("Member name at offset %#x.\n", offset);
601
602                 if (!copy_name(data + offset, &typem->name))
603                 {
604                     ERR("Failed to copy name.\n");
605                     return E_OUTOFMEMORY;
606                 }
607                 TRACE("Member name: %s.\n", debugstr_a(typem->name));
608
609                 read_dword(&ptr, &offset);
610                 TRACE("Member semantic at offset %#x.\n", offset);
611
612                 if (!copy_name(data + offset, &typem->semantic))
613                 {
614                     ERR("Failed to copy semantic.\n");
615                     return E_OUTOFMEMORY;
616                 }
617                 TRACE("Member semantic: %s.\n", debugstr_a(typem->semantic));
618
619                 read_dword(&ptr, &typem->buffer_offset);
620                 TRACE("Member offset in struct: %#x.\n", typem->buffer_offset);
621
622                 read_dword(&ptr, &offset);
623                 TRACE("Member type info at offset %#x.\n", offset);
624
625                 typem->type = get_fx10_type(t->effect, data, offset);
626                 if (!typem->type)
627                 {
628                     ERR("Failed to get variable type.\n");
629                     return E_FAIL;
630                 }
631             }
632             break;
633
634         default:
635             FIXME("Unhandled case %#x.\n", unknown0);
636             return E_FAIL;
637     }
638
639     if (t->element_count)
640     {
641         TRACE("Elementtype for type at offset: %#x\n", t->id);
642
643         /* allocate elementtype - we need only one, because all elements have the same type */
644         t->elementtype = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*t->elementtype));
645         if (!t->elementtype)
646         {
647             ERR("Failed to allocate members memory.\n");
648             return E_OUTOFMEMORY;
649         }
650
651         /* create a copy of the original type with some minor changes */
652         t->elementtype->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
653         t->elementtype->effect = t->effect;
654
655         if (!copy_name(t->name, &t->elementtype->name))
656         {
657              ERR("Failed to copy name.\n");
658              return E_OUTOFMEMORY;
659         }
660         TRACE("\tType name: %s.\n", debugstr_a(t->elementtype->name));
661
662         t->elementtype->element_count = 0;
663         TRACE("\tElement count: %u.\n", t->elementtype->element_count);
664
665         /*
666          * Not sure if this calculation is 100% correct, but a test
667          * shows that these values work.
668          */
669         t->elementtype->size_unpacked = t->size_packed / t->element_count;
670         TRACE("\tUnpacked size: %#x.\n", t->elementtype->size_unpacked);
671
672         t->elementtype->stride = t->stride;
673         TRACE("\tStride: %#x.\n", t->elementtype->stride);
674
675         t->elementtype->size_packed = t->size_packed / t->element_count;
676         TRACE("\tPacked size: %#x.\n", t->elementtype->size_packed);
677
678         t->elementtype->member_count = t->member_count;
679         TRACE("\tMember count: %u.\n", t->elementtype->member_count);
680
681         t->elementtype->column_count = t->column_count;
682         TRACE("\tColumns: %u.\n", t->elementtype->column_count);
683
684         t->elementtype->row_count = t->row_count;
685         TRACE("\tRows: %u.\n", t->elementtype->row_count);
686
687         t->elementtype->basetype = t->basetype;
688         TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(t->elementtype->basetype));
689
690         t->elementtype->type_class = t->type_class;
691         TRACE("\tClass: %s.\n", debug_d3d10_shader_variable_class(t->elementtype->type_class));
692
693         t->elementtype->members = t->members;
694     }
695
696     return S_OK;
697 }
698
699 static struct d3d10_effect_type *get_fx10_type(struct d3d10_effect *effect, const char *data, DWORD offset)
700 {
701     struct d3d10_effect_type *type;
702     struct wine_rb_entry *entry;
703     HRESULT hr;
704
705     entry = wine_rb_get(&effect->types, &offset);
706     if (entry)
707     {
708         TRACE("Returning existing type.\n");
709         return WINE_RB_ENTRY_VALUE(entry, struct d3d10_effect_type, entry);
710     }
711
712     type = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*type));
713     if (!type)
714     {
715         ERR("Failed to allocate type memory.\n");
716         return NULL;
717     }
718
719     type->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
720     type->id = offset;
721     type->effect = effect;
722     hr = parse_fx10_type(type, data + offset, data);
723     if (FAILED(hr))
724     {
725         ERR("Failed to parse type info, hr %#x.\n", hr);
726         HeapFree(GetProcessHeap(), 0, type);
727         return NULL;
728     }
729
730     if (wine_rb_put(&effect->types, &offset, &type->entry) == -1)
731     {
732         ERR("Failed to insert type entry.\n");
733         HeapFree(GetProcessHeap(), 0, type);
734         return NULL;
735     }
736
737     return type;
738 }
739
740 static void set_variable_vtbl(struct d3d10_effect_variable *v)
741 {
742     const ID3D10EffectVariableVtbl **vtbl = &v->ID3D10EffectVariable_iface.lpVtbl;
743
744     switch (v->type->type_class)
745     {
746         case D3D10_SVC_SCALAR:
747             *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl;
748             break;
749
750         case D3D10_SVC_VECTOR:
751             *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl;
752             break;
753
754         case D3D10_SVC_MATRIX_ROWS:
755         case D3D10_SVC_MATRIX_COLUMNS:
756             *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl;
757             break;
758
759         case D3D10_SVC_STRUCT:
760             *vtbl = &d3d10_effect_variable_vtbl;
761             break;
762
763         case D3D10_SVC_OBJECT:
764             switch(v->type->basetype)
765             {
766                 case D3D10_SVT_STRING:
767                     *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl;
768                     break;
769
770                 case D3D10_SVT_TEXTURE1D:
771                 case D3D10_SVT_TEXTURE1DARRAY:
772                 case D3D10_SVT_TEXTURE2D:
773                 case D3D10_SVT_TEXTURE2DARRAY:
774                 case D3D10_SVT_TEXTURE2DMS:
775                 case D3D10_SVT_TEXTURE2DMSARRAY:
776                 case D3D10_SVT_TEXTURE3D:
777                 case D3D10_SVT_TEXTURECUBE:
778                 case D3D10_SVT_BUFFER: /* Either resource or constant buffer. */
779                     *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl;
780                     break;
781
782                 case D3D10_SVT_RENDERTARGETVIEW:
783                     *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl;
784                     break;
785
786                 case D3D10_SVT_DEPTHSTENCILVIEW:
787                     *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl;
788                     break;
789
790                 case D3D10_SVT_DEPTHSTENCIL:
791                     *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl;
792                     break;
793
794                 case D3D10_SVT_VERTEXSHADER:
795                 case D3D10_SVT_GEOMETRYSHADER:
796                 case D3D10_SVT_PIXELSHADER:
797                     *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl;
798                     break;
799
800                 case D3D10_SVT_BLEND:
801                     *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl;
802                     break;
803
804                 case D3D10_SVT_RASTERIZER:
805                     *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl;
806                     break;
807
808                 case D3D10_SVT_SAMPLER:
809                     *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl;
810                     break;
811
812                 default:
813                     FIXME("Unhandled basetype %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
814                     *vtbl = &d3d10_effect_variable_vtbl;
815                     break;
816             }
817             break;
818
819         default:
820             FIXME("Unhandled type class %s.\n", debug_d3d10_shader_variable_class(v->type->type_class));
821             *vtbl = &d3d10_effect_variable_vtbl;
822             break;
823     }
824 }
825
826 static HRESULT copy_variableinfo_from_type(struct d3d10_effect_variable *v)
827 {
828     unsigned int i;
829     HRESULT hr;
830
831     if (v->type->member_count)
832     {
833         v->members = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, v->type->member_count * sizeof(*v->members));
834         if (!v->members)
835         {
836             ERR("Failed to allocate members memory.\n");
837             return E_OUTOFMEMORY;
838         }
839
840         for (i = 0; i < v->type->member_count; ++i)
841         {
842             struct d3d10_effect_variable *var = &v->members[i];
843             struct d3d10_effect_type_member *typem = &v->type->members[i];
844
845             var->buffer = v->buffer;
846             var->effect = v->effect;
847             var->type = typem->type;
848             set_variable_vtbl(var);
849
850             if (!copy_name(typem->name, &var->name))
851             {
852                 ERR("Failed to copy name.\n");
853                 return E_OUTOFMEMORY;
854             }
855             TRACE("Variable name: %s.\n", debugstr_a(var->name));
856
857             if (!copy_name(typem->semantic, &var->semantic))
858             {
859                 ERR("Failed to copy name.\n");
860                 return E_OUTOFMEMORY;
861             }
862             TRACE("Variable semantic: %s.\n", debugstr_a(var->semantic));
863
864             var->buffer_offset = v->buffer_offset + typem->buffer_offset;
865             TRACE("Variable buffer offset: %u.\n", var->buffer_offset);
866
867             hr = copy_variableinfo_from_type(var);
868             if (FAILED(hr)) return hr;
869         }
870     }
871
872     if (v->type->element_count)
873     {
874         unsigned int bufferoffset = v->buffer_offset;
875
876         v->elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, v->type->element_count * sizeof(*v->elements));
877         if (!v->elements)
878         {
879             ERR("Failed to allocate elements memory.\n");
880             return E_OUTOFMEMORY;
881         }
882
883         for (i = 0; i < v->type->element_count; ++i)
884         {
885             struct d3d10_effect_variable *var = &v->elements[i];
886
887             var->buffer = v->buffer;
888             var->effect = v->effect;
889             var->type = v->type->elementtype;
890             set_variable_vtbl(var);
891
892             if (!copy_name(v->name, &var->name))
893             {
894                 ERR("Failed to copy name.\n");
895                 return E_OUTOFMEMORY;
896             }
897             TRACE("Variable name: %s.\n", debugstr_a(var->name));
898
899             if (!copy_name(v->semantic, &var->semantic))
900             {
901                 ERR("Failed to copy name.\n");
902                 return E_OUTOFMEMORY;
903             }
904             TRACE("Variable semantic: %s.\n", debugstr_a(var->semantic));
905
906             if (i != 0)
907             {
908                 bufferoffset += v->type->stride;
909             }
910             var->buffer_offset = bufferoffset;
911             TRACE("Variable buffer offset: %u.\n", var->buffer_offset);
912
913             hr = copy_variableinfo_from_type(var);
914             if (FAILED(hr)) return hr;
915         }
916     }
917
918     return S_OK;
919 }
920
921 static HRESULT parse_fx10_variable_head(struct d3d10_effect_variable *v, const char **ptr, const char *data)
922 {
923     DWORD offset;
924
925     read_dword(ptr, &offset);
926     TRACE("Variable name at offset %#x.\n", offset);
927
928     if (!copy_name(data + offset, &v->name))
929     {
930         ERR("Failed to copy name.\n");
931         return E_OUTOFMEMORY;
932     }
933     TRACE("Variable name: %s.\n", debugstr_a(v->name));
934
935     read_dword(ptr, &offset);
936     TRACE("Variable type info at offset %#x.\n", offset);
937
938     v->type = get_fx10_type(v->effect, data, offset);
939     if (!v->type)
940     {
941         ERR("Failed to get variable type.\n");
942         return E_FAIL;
943     }
944     set_variable_vtbl(v);
945
946     return copy_variableinfo_from_type(v);
947 }
948
949 static HRESULT parse_fx10_annotation(struct d3d10_effect_variable *a, const char **ptr, const char *data)
950 {
951     HRESULT hr;
952
953     hr = parse_fx10_variable_head(a, ptr, data);
954     if (FAILED(hr)) return hr;
955
956     skip_dword_unknown("annotation", ptr, 1);
957
958     /* mark the variable as annotation */
959     a->flag = D3D10_EFFECT_VARIABLE_ANNOTATION;
960
961     return S_OK;
962 }
963
964 static HRESULT parse_fx10_anonymous_shader(struct d3d10_effect *e, struct d3d10_effect_anonymous_shader *s,
965     enum d3d10_effect_object_type otype)
966 {
967     struct d3d10_effect_variable *v = &s->shader;
968     struct d3d10_effect_type *t = &s->type;
969     const char *shader = NULL;
970
971     switch (otype)
972     {
973         case D3D10_EOT_VERTEXSHADER:
974             shader = "vertexshader";
975             t->basetype = D3D10_SVT_VERTEXSHADER;
976             break;
977
978         case D3D10_EOT_PIXELSHADER:
979             shader = "pixelshader";
980             t->basetype = D3D10_SVT_PIXELSHADER;
981             break;
982
983         case D3D10_EOT_GEOMETRYSHADER:
984             shader = "geometryshader";
985             t->basetype = D3D10_SVT_GEOMETRYSHADER;
986             break;
987
988         default:
989             FIXME("Unhandled object type %#x.\n", otype);
990             return E_FAIL;
991     }
992
993     if (!copy_name(shader, &t->name))
994     {
995         ERR("Failed to copy name.\n");
996         return E_OUTOFMEMORY;
997     }
998     TRACE("Type name: %s.\n", debugstr_a(t->name));
999
1000     t->type_class = D3D10_SVC_OBJECT;
1001
1002     t->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
1003
1004     v->type = t;
1005     v->effect = e;
1006     set_variable_vtbl(v);
1007
1008     if (!copy_name("$Anonymous", &v->name))
1009     {
1010         ERR("Failed to copy semantic.\n");
1011         return E_OUTOFMEMORY;
1012     }
1013     TRACE("Variable name: %s.\n", debugstr_a(v->name));
1014
1015     if (!copy_name(NULL, &v->semantic))
1016     {
1017         ERR("Failed to copy semantic.\n");
1018         return E_OUTOFMEMORY;
1019     }
1020     TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
1021
1022     return S_OK;
1023 }
1024
1025 static const struct d3d10_effect_state_property_info *get_property_info(UINT id)
1026 {
1027     unsigned int i;
1028
1029     for (i = 0; i < sizeof(property_info) / sizeof(*property_info); ++i)
1030     {
1031         if (property_info[i].id == id)
1032             return &property_info[i];
1033     }
1034
1035     return NULL;
1036 }
1037
1038 static const struct d3d10_effect_state_storage_info *get_storage_info(D3D_SHADER_VARIABLE_TYPE id)
1039 {
1040     unsigned int i;
1041
1042     for (i = 0; i < sizeof(d3d10_effect_state_storage_info) / sizeof(*d3d10_effect_state_storage_info); ++i)
1043     {
1044         if (d3d10_effect_state_storage_info[i].id == id)
1045             return &d3d10_effect_state_storage_info[i];
1046     }
1047
1048     return NULL;
1049 }
1050
1051 static BOOL read_float_value(DWORD value, D3D_SHADER_VARIABLE_TYPE in_type, float *out_data, UINT idx)
1052 {
1053     switch (in_type)
1054     {
1055         case D3D10_SVT_FLOAT:
1056             out_data[idx] = *(float *)&value;
1057             return TRUE;
1058
1059         case D3D10_SVT_INT:
1060             out_data[idx] = (INT)value;
1061             return TRUE;
1062
1063         default:
1064             FIXME("Unhandled in_type %#x.\n", in_type);
1065             return FALSE;
1066     }
1067 }
1068
1069 static BOOL read_int32_value(DWORD value, D3D_SHADER_VARIABLE_TYPE in_type, INT *out_data, UINT idx)
1070 {
1071     switch (in_type)
1072     {
1073         case D3D10_SVT_FLOAT:
1074             out_data[idx] = *(float *)&value;
1075             return TRUE;
1076
1077         case D3D10_SVT_INT:
1078         case D3D10_SVT_UINT:
1079         case D3D10_SVT_BOOL:
1080             out_data[idx] = value;
1081             return TRUE;
1082
1083         default:
1084             FIXME("Unhandled in_type %#x.\n", in_type);
1085             return FALSE;
1086     }
1087 }
1088
1089 static BOOL read_int8_value(DWORD value, D3D_SHADER_VARIABLE_TYPE in_type, INT8 *out_data, UINT idx)
1090 {
1091     switch (in_type)
1092     {
1093         case D3D10_SVT_INT:
1094         case D3D10_SVT_UINT:
1095             out_data[idx] = value;
1096             return TRUE;
1097
1098         default:
1099             FIXME("Unhandled in_type %#x.\n", in_type);
1100             return FALSE;
1101     }
1102 }
1103
1104 static BOOL read_value_list(const char *ptr, D3D_SHADER_VARIABLE_TYPE out_type,
1105         UINT out_base, UINT out_size, void *out_data)
1106 {
1107     D3D_SHADER_VARIABLE_TYPE in_type;
1108     DWORD t, value;
1109     DWORD count, i;
1110
1111     read_dword(&ptr, &count);
1112     if (count != out_size)
1113         return FALSE;
1114
1115     TRACE("%u values:\n", count);
1116     for (i = 0; i < count; ++i)
1117     {
1118         UINT out_idx = out_base * out_size + i;
1119
1120         read_dword(&ptr, &t);
1121         read_dword(&ptr, &value);
1122
1123         in_type = d3d10_variable_type(t, FALSE);
1124         TRACE("\t%s: %#x.\n", debug_d3d10_shader_variable_type(in_type), value);
1125
1126         switch (out_type)
1127         {
1128             case D3D10_SVT_FLOAT:
1129                 if (!read_float_value(value, in_type, out_data, out_idx))
1130                     return FALSE;
1131                 break;
1132
1133             case D3D10_SVT_INT:
1134             case D3D10_SVT_UINT:
1135             case D3D10_SVT_BOOL:
1136                 if (!read_int32_value(value, in_type, out_data, out_idx))
1137                     return FALSE;
1138                 break;
1139
1140             case D3D10_SVT_UINT8:
1141                 if (!read_int8_value(value, in_type, out_data, out_idx))
1142                     return FALSE;
1143                 break;
1144
1145             default:
1146                 FIXME("Unhandled out_type %#x.\n", out_type);
1147                 return FALSE;
1148         }
1149     }
1150
1151     return TRUE;
1152 }
1153
1154 static BOOL parse_fx10_state_group(const char **ptr, const char *data,
1155         D3D_SHADER_VARIABLE_TYPE container_type, void *container)
1156 {
1157     const struct d3d10_effect_state_property_info *property_info;
1158     UINT value_offset;
1159     unsigned int i;
1160     DWORD count;
1161     UINT idx;
1162     UINT id;
1163
1164     read_dword(ptr, &count);
1165     TRACE("Property count: %#x.\n", count);
1166
1167     for (i = 0; i < count; ++i)
1168     {
1169         read_dword(ptr, &id);
1170         read_dword(ptr, &idx);
1171         skip_dword_unknown("read property", ptr, 1);
1172         read_dword(ptr, &value_offset);
1173
1174         if (!(property_info = get_property_info(id)))
1175         {
1176             FIXME("Failed to find property info for property %#x.\n", id);
1177             return FALSE;
1178         }
1179
1180         TRACE("Property %s[%#x] = value list @ offset %#x.\n",
1181                 property_info->name, idx, value_offset);
1182
1183         if (property_info->container_type != container_type)
1184         {
1185             ERR("Invalid container type %#x for property %#x.\n", container_type, id);
1186             return FALSE;
1187         }
1188
1189         if (idx >= property_info->count)
1190         {
1191             ERR("Invalid index %#x for property %#x.\n", idx, id);
1192             return FALSE;
1193         }
1194
1195         if (!read_value_list(data + value_offset, property_info->type, idx,
1196                 property_info->size, (char *)container + property_info->offset))
1197         {
1198             ERR("Failed to read values for property %#x.\n", id);
1199             return FALSE;
1200         }
1201     }
1202
1203     return TRUE;
1204 }
1205
1206 static HRESULT parse_fx10_object(struct d3d10_effect_object *o, const char **ptr, const char *data)
1207 {
1208     ID3D10EffectVariable *variable = &null_variable.ID3D10EffectVariable_iface;
1209     const char *data_ptr = NULL;
1210     DWORD offset;
1211     enum d3d10_effect_object_operation operation;
1212     HRESULT hr;
1213     struct d3d10_effect *effect = o->pass->technique->effect;
1214     ID3D10Effect *e = &effect->ID3D10Effect_iface;
1215     DWORD tmp, variable_idx = 0;
1216
1217     read_dword(ptr, &o->type);
1218     TRACE("Effect object is of type %#x.\n", o->type);
1219
1220     read_dword(ptr, &tmp);
1221     TRACE("Effect object index %#x.\n", tmp);
1222
1223     read_dword(ptr, &operation);
1224     TRACE("Effect object operation %#x.\n", operation);
1225
1226     read_dword(ptr, &offset);
1227     TRACE("Effect object idx is at offset %#x.\n", offset);
1228
1229     switch(operation)
1230     {
1231         case D3D10_EOO_VALUE:
1232             TRACE("Copy variable values\n");
1233
1234             switch (o->type)
1235             {
1236                 case D3D10_EOT_VERTEXSHADER:
1237                     TRACE("Vertex shader\n");
1238                     variable = &anonymous_vs.ID3D10EffectVariable_iface;
1239                     break;
1240
1241                 case D3D10_EOT_PIXELSHADER:
1242                     TRACE("Pixel shader\n");
1243                     variable = &anonymous_ps.ID3D10EffectVariable_iface;
1244                     break;
1245
1246                 case D3D10_EOT_GEOMETRYSHADER:
1247                     TRACE("Geometry shader\n");
1248                     variable = &anonymous_gs.ID3D10EffectVariable_iface;
1249                     break;
1250
1251                 case D3D10_EOT_STENCIL_REF:
1252                     if (!read_value_list(data + offset, D3D10_SVT_UINT, 0, 1, &o->pass->stencil_ref))
1253                     {
1254                         ERR("Failed to read stencil ref.\n");
1255                         return E_FAIL;
1256                     }
1257                     break;
1258
1259                 case D3D10_EOT_SAMPLE_MASK:
1260                     if (!read_value_list(data + offset, D3D10_SVT_UINT, 0, 1, &o->pass->sample_mask))
1261                     {
1262                         FIXME("Failed to read sample mask.\n");
1263                         return E_FAIL;
1264                     }
1265                     break;
1266
1267                 case D3D10_EOT_BLEND_FACTOR:
1268                     if (!read_value_list(data + offset, D3D10_SVT_FLOAT, 0, 4, &o->pass->blend_factor[0]))
1269                     {
1270                         FIXME("Failed to read blend factor.\n");
1271                         return E_FAIL;
1272                     }
1273                     break;
1274
1275                 default:
1276                     FIXME("Unhandled object type %#x\n", o->type);
1277                     return E_FAIL;
1278             }
1279             break;
1280
1281         case D3D10_EOO_PARSED_OBJECT:
1282             /* This is a local object, we've parsed in parse_fx10_local_object. */
1283             TRACE("Variable name %s.\n", debugstr_a(data + offset));
1284
1285             variable = e->lpVtbl->GetVariableByName(e, data + offset);
1286             break;
1287
1288         case D3D10_EOO_PARSED_OBJECT_INDEX:
1289             /* This is a local object, we've parsed in parse_fx10_local_object, which has an array index. */
1290             data_ptr = data + offset;
1291             read_dword(&data_ptr, &offset);
1292             read_dword(&data_ptr, &variable_idx);
1293             TRACE("Variable name %s[%u].\n", debugstr_a(data + offset), variable_idx);
1294
1295             variable = e->lpVtbl->GetVariableByName(e, data + offset);
1296             break;
1297
1298         case D3D10_EOO_ANONYMOUS_SHADER:
1299             TRACE("Anonymous shader\n");
1300
1301             /* check anonymous_shader_current for validity */
1302             if (effect->anonymous_shader_current >= effect->anonymous_shader_count)
1303             {
1304                 ERR("Anonymous shader count is wrong!\n");
1305                 return E_FAIL;
1306             }
1307
1308             data_ptr = data + offset;
1309             read_dword(&data_ptr, &offset);
1310             TRACE("Effect object starts at offset %#x.\n", offset);
1311
1312             data_ptr = data + offset;
1313
1314             hr = parse_fx10_anonymous_shader(effect, &effect->anonymous_shaders[effect->anonymous_shader_current], o->type);
1315             if (FAILED(hr)) return hr;
1316
1317             variable = &effect->anonymous_shaders[effect->anonymous_shader_current].shader.ID3D10EffectVariable_iface;
1318             ++effect->anonymous_shader_current;
1319
1320             switch (o->type)
1321             {
1322                 case D3D10_EOT_VERTEXSHADER:
1323                 case D3D10_EOT_PIXELSHADER:
1324                 case D3D10_EOT_GEOMETRYSHADER:
1325                     if (FAILED(hr = parse_shader(variable, data_ptr)))
1326                         return hr;
1327                     break;
1328
1329                 default:
1330                     FIXME("Unhandled object type %#x\n", o->type);
1331                     return E_FAIL;
1332             }
1333             break;
1334
1335         default:
1336             FIXME("Unhandled operation %#x.\n", operation);
1337             return E_FAIL;
1338     }
1339
1340     switch (o->type)
1341     {
1342         case D3D10_EOT_RASTERIZER_STATE:
1343         {
1344             ID3D10EffectRasterizerVariable *rv = variable->lpVtbl->AsRasterizer(variable);
1345             if (FAILED(hr = rv->lpVtbl->GetRasterizerState(rv, variable_idx, &o->object.rs)))
1346                 return hr;
1347             break;
1348         }
1349
1350         case D3D10_EOT_DEPTH_STENCIL_STATE:
1351         {
1352             ID3D10EffectDepthStencilVariable *dv = variable->lpVtbl->AsDepthStencil(variable);
1353             if (FAILED(hr = dv->lpVtbl->GetDepthStencilState(dv, variable_idx, &o->object.ds)))
1354                 return hr;
1355             break;
1356         }
1357
1358         case D3D10_EOT_BLEND_STATE:
1359         {
1360             ID3D10EffectBlendVariable *bv = variable->lpVtbl->AsBlend(variable);
1361             if (FAILED(hr = bv->lpVtbl->GetBlendState(bv, variable_idx, &o->object.bs)))
1362                 return hr;
1363             break;
1364         }
1365
1366         case D3D10_EOT_VERTEXSHADER:
1367         {
1368             ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable);
1369             if (FAILED(hr = sv->lpVtbl->GetVertexShader(sv, variable_idx, &o->object.vs)))
1370                 return hr;
1371             o->pass->vs.pShaderVariable = sv;
1372             o->pass->vs.ShaderIndex = variable_idx;
1373             break;
1374         }
1375
1376         case D3D10_EOT_PIXELSHADER:
1377         {
1378             ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable);
1379             if (FAILED(hr = sv->lpVtbl->GetPixelShader(sv, variable_idx, &o->object.ps)))
1380                 return hr;
1381             o->pass->ps.pShaderVariable = sv;
1382             o->pass->ps.ShaderIndex = variable_idx;
1383             break;
1384         }
1385
1386         case D3D10_EOT_GEOMETRYSHADER:
1387         {
1388             ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable);
1389             if (FAILED(hr = sv->lpVtbl->GetGeometryShader(sv, variable_idx, &o->object.gs)))
1390                 return hr;
1391             o->pass->gs.pShaderVariable = sv;
1392             o->pass->gs.ShaderIndex = variable_idx;
1393             break;
1394         }
1395
1396         case D3D10_EOT_STENCIL_REF:
1397         case D3D10_EOT_BLEND_FACTOR:
1398         case D3D10_EOT_SAMPLE_MASK:
1399             break;
1400
1401         default:
1402             FIXME("Unhandled object type %#x.\n", o->type);
1403             return E_FAIL;
1404     }
1405
1406     return S_OK;
1407 }
1408
1409 static HRESULT parse_fx10_pass(struct d3d10_effect_pass *p, const char **ptr, const char *data)
1410 {
1411     HRESULT hr = S_OK;
1412     unsigned int i;
1413     DWORD offset;
1414
1415     read_dword(ptr, &offset);
1416     TRACE("Pass name at offset %#x.\n", offset);
1417
1418     if (!copy_name(data + offset, &p->name))
1419     {
1420         ERR("Failed to copy name.\n");
1421         return E_OUTOFMEMORY;
1422     }
1423     TRACE("Pass name: %s.\n", debugstr_a(p->name));
1424
1425     read_dword(ptr, &p->object_count);
1426     TRACE("Pass has %u effect objects.\n", p->object_count);
1427
1428     read_dword(ptr, &p->annotation_count);
1429     TRACE("Pass has %u annotations.\n", p->annotation_count);
1430
1431     p->annotations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, p->annotation_count * sizeof(*p->annotations));
1432     if (!p->annotations)
1433     {
1434         ERR("Failed to allocate pass annotations memory.\n");
1435         return E_OUTOFMEMORY;
1436     }
1437
1438     for (i = 0; i < p->annotation_count; ++i)
1439     {
1440         struct d3d10_effect_variable *a = &p->annotations[i];
1441
1442         a->effect = p->technique->effect;
1443         a->buffer = &null_local_buffer;
1444
1445         hr = parse_fx10_annotation(a, ptr, data);
1446         if (FAILED(hr)) return hr;
1447     }
1448
1449     p->objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, p->object_count * sizeof(*p->objects));
1450     if (!p->objects)
1451     {
1452         ERR("Failed to allocate effect objects memory.\n");
1453         return E_OUTOFMEMORY;
1454     }
1455
1456     p->vs.pShaderVariable = (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
1457     p->ps.pShaderVariable = (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
1458     p->gs.pShaderVariable = (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
1459
1460     for (i = 0; i < p->object_count; ++i)
1461     {
1462         struct d3d10_effect_object *o = &p->objects[i];
1463
1464         o->pass = p;
1465
1466         hr = parse_fx10_object(o, ptr, data);
1467         if (FAILED(hr)) return hr;
1468     }
1469
1470     return hr;
1471 }
1472
1473 static HRESULT parse_fx10_technique(struct d3d10_effect_technique *t, const char **ptr, const char *data)
1474 {
1475     unsigned int i;
1476     DWORD offset;
1477     HRESULT hr;
1478
1479     read_dword(ptr, &offset);
1480     TRACE("Technique name at offset %#x.\n", offset);
1481
1482     if (!copy_name(data + offset, &t->name))
1483     {
1484         ERR("Failed to copy name.\n");
1485         return E_OUTOFMEMORY;
1486     }
1487     TRACE("Technique name: %s.\n", debugstr_a(t->name));
1488
1489     read_dword(ptr, &t->pass_count);
1490     TRACE("Technique has %u passes\n", t->pass_count);
1491
1492     read_dword(ptr, &t->annotation_count);
1493     TRACE("Technique has %u annotations.\n", t->annotation_count);
1494
1495     t->annotations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, t->annotation_count * sizeof(*t->annotations));
1496     if (!t->annotations)
1497     {
1498         ERR("Failed to allocate technique annotations memory.\n");
1499         return E_OUTOFMEMORY;
1500     }
1501
1502     for (i = 0; i < t->annotation_count; ++i)
1503     {
1504         struct d3d10_effect_variable *a = &t->annotations[i];
1505
1506         a->effect = t->effect;
1507         a->buffer = &null_local_buffer;
1508
1509         hr = parse_fx10_annotation(a, ptr, data);
1510         if (FAILED(hr)) return hr;
1511     }
1512
1513     t->passes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, t->pass_count * sizeof(*t->passes));
1514     if (!t->passes)
1515     {
1516         ERR("Failed to allocate passes memory\n");
1517         return E_OUTOFMEMORY;
1518     }
1519
1520     for (i = 0; i < t->pass_count; ++i)
1521     {
1522         struct d3d10_effect_pass *p = &t->passes[i];
1523
1524         p->ID3D10EffectPass_iface.lpVtbl = &d3d10_effect_pass_vtbl;
1525         p->technique = t;
1526
1527         hr = parse_fx10_pass(p, ptr, data);
1528         if (FAILED(hr)) return hr;
1529     }
1530
1531     return S_OK;
1532 }
1533
1534 static HRESULT parse_fx10_variable(struct d3d10_effect_variable *v, const char **ptr, const char *data)
1535 {
1536     DWORD offset;
1537     unsigned int i;
1538     HRESULT hr;
1539
1540     hr = parse_fx10_variable_head(v, ptr, data);
1541     if (FAILED(hr)) return hr;
1542
1543     read_dword(ptr, &offset);
1544     TRACE("Variable semantic at offset %#x.\n", offset);
1545
1546     if (!copy_name(data + offset, &v->semantic))
1547     {
1548         ERR("Failed to copy semantic.\n");
1549         return E_OUTOFMEMORY;
1550     }
1551     TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
1552
1553     read_dword(ptr, &v->buffer_offset);
1554     TRACE("Variable offset in buffer: %#x.\n", v->buffer_offset);
1555
1556     skip_dword_unknown("variable", ptr, 1);
1557
1558     read_dword(ptr, &v->flag);
1559     TRACE("Variable flag: %#x.\n", v->flag);
1560
1561     read_dword(ptr, &v->annotation_count);
1562     TRACE("Variable has %u annotations.\n", v->annotation_count);
1563
1564     v->annotations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, v->annotation_count * sizeof(*v->annotations));
1565     if (!v->annotations)
1566     {
1567         ERR("Failed to allocate variable annotations memory.\n");
1568         return E_OUTOFMEMORY;
1569     }
1570
1571     for (i = 0; i < v->annotation_count; ++i)
1572     {
1573         struct d3d10_effect_variable *a = &v->annotations[i];
1574
1575         a->effect = v->effect;
1576         a->buffer = &null_local_buffer;
1577
1578         hr = parse_fx10_annotation(a, ptr, data);
1579         if (FAILED(hr)) return hr;
1580     }
1581
1582     return S_OK;
1583 }
1584
1585 static HRESULT create_state_object(struct d3d10_effect_variable *v)
1586 {
1587     ID3D10Device *device = v->effect->device;
1588     HRESULT hr;
1589
1590     switch (v->type->basetype)
1591     {
1592         case D3D10_SVT_DEPTHSTENCIL:
1593             if (FAILED(hr = ID3D10Device_CreateDepthStencilState(device,
1594                     &v->u.state.desc.depth_stencil, &v->u.state.object.depth_stencil)))
1595                 return hr;
1596             break;
1597
1598         case D3D10_SVT_BLEND:
1599             if (FAILED(hr = ID3D10Device_CreateBlendState(device,
1600                     &v->u.state.desc.blend, &v->u.state.object.blend)))
1601                 return hr;
1602             break;
1603
1604         case D3D10_SVT_RASTERIZER:
1605             if (FAILED(hr = ID3D10Device_CreateRasterizerState(device,
1606                     &v->u.state.desc.rasterizer, &v->u.state.object.rasterizer)))
1607                 return hr;
1608             break;
1609
1610         case D3D10_SVT_SAMPLER:
1611             if (FAILED(hr = ID3D10Device_CreateSamplerState(device,
1612                     &v->u.state.desc.sampler, &v->u.state.object.sampler)))
1613                 return hr;
1614             break;
1615
1616         default:
1617             ERR("Unhandled variable type %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
1618             return E_FAIL;
1619     }
1620
1621     return S_OK;
1622 }
1623
1624 static HRESULT parse_fx10_local_variable(struct d3d10_effect_variable *v, const char **ptr, const char *data)
1625 {
1626     unsigned int i;
1627     HRESULT hr;
1628     DWORD offset;
1629
1630     hr = parse_fx10_variable_head(v, ptr, data);
1631     if (FAILED(hr)) return hr;
1632
1633     read_dword(ptr, &offset);
1634     TRACE("Variable semantic at offset %#x.\n", offset);
1635
1636     if (!copy_name(data + offset, &v->semantic))
1637     {
1638         ERR("Failed to copy semantic.\n");
1639         return E_OUTOFMEMORY;
1640     }
1641     TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
1642
1643     skip_dword_unknown("local variable", ptr, 1);
1644
1645     switch (v->type->basetype)
1646     {
1647         case D3D10_SVT_TEXTURE1D:
1648         case D3D10_SVT_TEXTURE1DARRAY:
1649         case D3D10_SVT_TEXTURE2D:
1650         case D3D10_SVT_TEXTURE2DARRAY:
1651         case D3D10_SVT_TEXTURE2DMS:
1652         case D3D10_SVT_TEXTURE2DMSARRAY:
1653         case D3D10_SVT_TEXTURE3D:
1654         case D3D10_SVT_TEXTURECUBE:
1655         case D3D10_SVT_RENDERTARGETVIEW:
1656         case D3D10_SVT_DEPTHSTENCILVIEW:
1657         case D3D10_SVT_BUFFER:
1658             TRACE("SVT could not have elements.\n");
1659             break;
1660
1661         case D3D10_SVT_VERTEXSHADER:
1662         case D3D10_SVT_PIXELSHADER:
1663         case D3D10_SVT_GEOMETRYSHADER:
1664             TRACE("Shader type is %s\n", debug_d3d10_shader_variable_type(v->type->basetype));
1665             for (i = 0; i < max(v->type->element_count, 1); ++i)
1666             {
1667                 DWORD shader_offset;
1668                 struct d3d10_effect_variable *var;
1669
1670                 if (!v->type->element_count)
1671                 {
1672                     var = v;
1673                 }
1674                 else
1675                 {
1676                     var = &v->elements[i];
1677                 }
1678
1679                 read_dword(ptr, &shader_offset);
1680                 TRACE("Shader offset: %#x.\n", shader_offset);
1681
1682                 hr = parse_shader(&var->ID3D10EffectVariable_iface, data + shader_offset);
1683                 if (FAILED(hr)) return hr;
1684             }
1685             break;
1686
1687         case D3D10_SVT_DEPTHSTENCIL:
1688         case D3D10_SVT_BLEND:
1689         case D3D10_SVT_RASTERIZER:
1690         case D3D10_SVT_SAMPLER:
1691             {
1692                 const struct d3d10_effect_state_storage_info *storage_info;
1693                 unsigned int count = max(v->type->element_count, 1);
1694
1695                 if (!(storage_info = get_storage_info(v->type->basetype)))
1696                 {
1697                     FIXME("Failed to get backing store info for type %s.\n",
1698                             debug_d3d10_shader_variable_type(v->type->basetype));
1699                     return E_FAIL;
1700                 }
1701
1702                 if (storage_info->size > sizeof(v->u.state.desc))
1703                 {
1704                     ERR("Invalid storage size %#lx.\n", storage_info->size);
1705                     return E_FAIL;
1706                 }
1707
1708                 for (i = 0; i < count; ++i)
1709                 {
1710                     struct d3d10_effect_variable *var;
1711
1712                     if (v->type->element_count)
1713                         var = &v->elements[i];
1714                     else
1715                         var = v;
1716
1717                     memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size);
1718                     if (!parse_fx10_state_group(ptr, data, var->type->basetype, &var->u.state.desc))
1719                     {
1720                         ERR("Failed to read property list.\n");
1721                         return E_FAIL;
1722                     }
1723
1724                     if (FAILED(hr = create_state_object(v)))
1725                         return hr;
1726                 }
1727             }
1728             break;
1729
1730         default:
1731             FIXME("Unhandled case %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
1732             return E_FAIL;
1733     }
1734
1735     read_dword(ptr, &v->annotation_count);
1736     TRACE("Variable has %u annotations.\n", v->annotation_count);
1737
1738     v->annotations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, v->annotation_count * sizeof(*v->annotations));
1739     if (!v->annotations)
1740     {
1741         ERR("Failed to allocate variable annotations memory.\n");
1742         return E_OUTOFMEMORY;
1743     }
1744
1745     for (i = 0; i < v->annotation_count; ++i)
1746     {
1747         struct d3d10_effect_variable *a = &v->annotations[i];
1748
1749         a->effect = v->effect;
1750         a->buffer = &null_local_buffer;
1751
1752         hr = parse_fx10_annotation(a, ptr, data);
1753         if (FAILED(hr)) return hr;
1754     }
1755
1756     return S_OK;
1757 }
1758
1759 static HRESULT parse_fx10_local_buffer(struct d3d10_effect_variable *l, const char **ptr, const char *data)
1760 {
1761     unsigned int i;
1762     DWORD offset;
1763     D3D10_CBUFFER_TYPE d3d10_cbuffer_type;
1764     HRESULT hr;
1765     unsigned int stride = 0;
1766
1767     /* Generate our own type, it isn't in the fx blob. */
1768     l->type = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*l->type));
1769     if (!l->type)
1770     {
1771         ERR("Failed to allocate local buffer type memory.\n");
1772         return E_OUTOFMEMORY;
1773     }
1774     l->type->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
1775     l->type->type_class = D3D10_SVC_OBJECT;
1776     l->type->effect = l->effect;
1777
1778     read_dword(ptr, &offset);
1779     TRACE("Local buffer name at offset %#x.\n", offset);
1780
1781     if (!copy_name(data + offset, &l->name))
1782     {
1783         ERR("Failed to copy name.\n");
1784         return E_OUTOFMEMORY;
1785     }
1786     TRACE("Local buffer name: %s.\n", debugstr_a(l->name));
1787
1788     read_dword(ptr, &l->data_size);
1789     TRACE("Local buffer data size: %#x.\n", l->data_size);
1790
1791     read_dword(ptr, &d3d10_cbuffer_type);
1792     TRACE("Local buffer type: %#x.\n", d3d10_cbuffer_type);
1793
1794     switch(d3d10_cbuffer_type)
1795     {
1796         case D3D10_CT_CBUFFER:
1797             l->type->basetype = D3D10_SVT_CBUFFER;
1798             if (!copy_name("cbuffer", &l->type->name))
1799             {
1800                 ERR("Failed to copy name.\n");
1801                 return E_OUTOFMEMORY;
1802             }
1803             break;
1804
1805         case D3D10_CT_TBUFFER:
1806             l->type->basetype = D3D10_SVT_TBUFFER;
1807             if (!copy_name("tbuffer", &l->type->name))
1808             {
1809                 ERR("Failed to copy name.\n");
1810                 return E_OUTOFMEMORY;
1811             }
1812             break;
1813
1814         default:
1815             ERR("Unexpected D3D10_CBUFFER_TYPE %#x!\n", d3d10_cbuffer_type);
1816             return E_FAIL;
1817     }
1818
1819     read_dword(ptr, &l->type->member_count);
1820     TRACE("Local buffer member count: %#x.\n", l->type->member_count);
1821
1822     skip_dword_unknown("local buffer", ptr, 1);
1823
1824     read_dword(ptr, &l->annotation_count);
1825     TRACE("Local buffer has %u annotations.\n", l->annotation_count);
1826
1827     l->annotations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, l->annotation_count * sizeof(*l->annotations));
1828     if (!l->annotations)
1829     {
1830         ERR("Failed to allocate local buffer annotations memory.\n");
1831         return E_OUTOFMEMORY;
1832     }
1833
1834     for (i = 0; i < l->annotation_count; ++i)
1835     {
1836         struct d3d10_effect_variable *a = &l->annotations[i];
1837
1838         a->effect = l->effect;
1839         a->buffer = &null_local_buffer;
1840
1841         hr = parse_fx10_annotation(a, ptr, data);
1842         if (FAILED(hr)) return hr;
1843     }
1844
1845     l->members = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, l->type->member_count * sizeof(*l->members));
1846     if (!l->members)
1847     {
1848         ERR("Failed to allocate members memory.\n");
1849         return E_OUTOFMEMORY;
1850     }
1851
1852     l->type->members = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, l->type->member_count * sizeof(*l->type->members));
1853     if (!l->type->members)
1854     {
1855         ERR("Failed to allocate type members memory.\n");
1856         return E_OUTOFMEMORY;
1857     }
1858
1859     for (i = 0; i < l->type->member_count; ++i)
1860     {
1861         struct d3d10_effect_variable *v = &l->members[i];
1862         struct d3d10_effect_type_member *typem = &l->type->members[i];
1863
1864         v->buffer = l;
1865         v->effect = l->effect;
1866
1867         hr = parse_fx10_variable(v, ptr, data);
1868         if (FAILED(hr)) return hr;
1869
1870         /*
1871          * Copy the values from the variable type to the constant buffers type
1872          * members structure, because it is our own generated type.
1873          */
1874         typem->type = v->type;
1875
1876         if (!copy_name(v->name, &typem->name))
1877         {
1878             ERR("Failed to copy name.\n");
1879             return E_OUTOFMEMORY;
1880         }
1881         TRACE("Variable name: %s.\n", debugstr_a(typem->name));
1882
1883         if (!copy_name(v->semantic, &typem->semantic))
1884         {
1885             ERR("Failed to copy name.\n");
1886             return E_OUTOFMEMORY;
1887         }
1888         TRACE("Variable semantic: %s.\n", debugstr_a(typem->semantic));
1889
1890         typem->buffer_offset = v->buffer_offset;
1891         TRACE("Variable buffer offset: %u.\n", typem->buffer_offset);
1892
1893         l->type->size_packed += v->type->size_packed;
1894
1895         /*
1896          * For the complete constantbuffer the size_unpacked = stride,
1897          * the stride is calculated like this:
1898          *
1899          * 1) if the constant buffer variables are packed with packoffset
1900          *    - stride = the highest used constant
1901          *    - the complete stride has to be a multiple of 0x10
1902          *
1903          * 2) if the constant buffer variables are NOT packed with packoffset
1904          *    - sum of unpacked size for all variables which fit in a 0x10 part
1905          *    - if the size exceeds a 0x10 part, the rest of the old part is skipped
1906          *      and a new part is started
1907          *    - if the variable is a struct it is always used a new part
1908          *    - the complete stride has to be a multiple of 0x10
1909          *
1910          *    e.g.:
1911          *             0x4, 0x4, 0x4, 0x8, 0x4, 0x14, 0x4
1912          *        part 0x10           0x10      0x20     -> 0x40
1913          */
1914         if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
1915         {
1916             if ((v->type->size_unpacked + v->buffer_offset) > stride)
1917             {
1918                 stride = v->type->size_unpacked + v->buffer_offset;
1919             }
1920         }
1921         else
1922         {
1923             if (v->type->type_class == D3D10_SVC_STRUCT)
1924             {
1925                 stride = (stride + 0xf) & ~0xf;
1926             }
1927
1928             if ( ((stride & 0xf) + v->type->size_unpacked) > 0x10)
1929             {
1930                 stride = (stride + 0xf) & ~0xf;
1931             }
1932
1933             stride += v->type->size_unpacked;
1934         }
1935     }
1936     l->type->stride = l->type->size_unpacked = (stride + 0xf) & ~0xf;
1937
1938     TRACE("Constant buffer:\n");
1939     TRACE("\tType name: %s.\n", debugstr_a(l->type->name));
1940     TRACE("\tElement count: %u.\n", l->type->element_count);
1941     TRACE("\tMember count: %u.\n", l->type->member_count);
1942     TRACE("\tUnpacked size: %#x.\n", l->type->size_unpacked);
1943     TRACE("\tStride: %#x.\n", l->type->stride);
1944     TRACE("\tPacked size %#x.\n", l->type->size_packed);
1945     TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype));
1946     TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
1947
1948     return S_OK;
1949 }
1950
1951 static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry *entry)
1952 {
1953     const struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, const struct d3d10_effect_type, entry);
1954     const DWORD *id = key;
1955
1956     return *id - t->id;
1957 }
1958
1959 static void d3d10_effect_type_member_destroy(struct d3d10_effect_type_member *typem)
1960 {
1961     TRACE("effect type member %p.\n", typem);
1962
1963     /* Do not release typem->type, it will be covered by d3d10_effect_type_destroy(). */
1964     HeapFree(GetProcessHeap(), 0, typem->semantic);
1965     HeapFree(GetProcessHeap(), 0, typem->name);
1966 }
1967
1968 static void d3d10_effect_type_destroy(struct wine_rb_entry *entry, void *context)
1969 {
1970     struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, struct d3d10_effect_type, entry);
1971
1972     TRACE("effect type %p.\n", t);
1973
1974     if (t->elementtype)
1975     {
1976         HeapFree(GetProcessHeap(), 0, t->elementtype->name);
1977         HeapFree(GetProcessHeap(), 0, t->elementtype);
1978     }
1979
1980     if (t->members)
1981     {
1982         unsigned int i;
1983
1984         for (i = 0; i < t->member_count; ++i)
1985         {
1986             d3d10_effect_type_member_destroy(&t->members[i]);
1987         }
1988         HeapFree(GetProcessHeap(), 0, t->members);
1989     }
1990
1991     HeapFree(GetProcessHeap(), 0, t->name);
1992     HeapFree(GetProcessHeap(), 0, t);
1993 }
1994
1995 static const struct wine_rb_functions d3d10_effect_type_rb_functions =
1996 {
1997     d3d10_rb_alloc,
1998     d3d10_rb_realloc,
1999     d3d10_rb_free,
2000     d3d10_effect_type_compare,
2001 };
2002
2003 static HRESULT parse_fx10_body(struct d3d10_effect *e, const char *data, DWORD data_size)
2004 {
2005     const char *ptr = data + e->index_offset;
2006     unsigned int i;
2007     HRESULT hr;
2008
2009     if (wine_rb_init(&e->types, &d3d10_effect_type_rb_functions) == -1)
2010     {
2011         ERR("Failed to initialize type rbtree.\n");
2012         return E_FAIL;
2013     }
2014
2015     e->local_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, e->local_buffer_count * sizeof(*e->local_buffers));
2016     if (!e->local_buffers)
2017     {
2018         ERR("Failed to allocate local buffer memory.\n");
2019         return E_OUTOFMEMORY;
2020     }
2021
2022     e->local_variables = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, e->local_variable_count * sizeof(*e->local_variables));
2023     if (!e->local_variables)
2024     {
2025         ERR("Failed to allocate local variable memory.\n");
2026         return E_OUTOFMEMORY;
2027     }
2028
2029     e->anonymous_shaders = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, e->anonymous_shader_count * sizeof(*e->anonymous_shaders));
2030     if (!e->anonymous_shaders)
2031     {
2032         ERR("Failed to allocate anonymous shaders memory\n");
2033         return E_OUTOFMEMORY;
2034     }
2035
2036     e->used_shaders = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, e->used_shader_count * sizeof(*e->used_shaders));
2037     if (!e->used_shaders)
2038     {
2039         ERR("Failed to allocate used shaders memory\n");
2040         return E_OUTOFMEMORY;
2041     }
2042
2043     e->techniques = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, e->technique_count * sizeof(*e->techniques));
2044     if (!e->techniques)
2045     {
2046         ERR("Failed to allocate techniques memory\n");
2047         return E_OUTOFMEMORY;
2048     }
2049
2050     for (i = 0; i < e->local_buffer_count; ++i)
2051     {
2052         struct d3d10_effect_variable *l = &e->local_buffers[i];
2053         l->ID3D10EffectVariable_iface.lpVtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl;
2054         l->effect = e;
2055         l->buffer = &null_local_buffer;
2056
2057         hr = parse_fx10_local_buffer(l, &ptr, data);
2058         if (FAILED(hr)) return hr;
2059     }
2060
2061     for (i = 0; i < e->local_variable_count; ++i)
2062     {
2063         struct d3d10_effect_variable *v = &e->local_variables[i];
2064
2065         v->effect = e;
2066         v->ID3D10EffectVariable_iface.lpVtbl = &d3d10_effect_variable_vtbl;
2067         v->buffer = &null_local_buffer;
2068
2069         hr = parse_fx10_local_variable(v, &ptr, data);
2070         if (FAILED(hr)) return hr;
2071     }
2072
2073     for (i = 0; i < e->technique_count; ++i)
2074     {
2075         struct d3d10_effect_technique *t = &e->techniques[i];
2076
2077         t->ID3D10EffectTechnique_iface.lpVtbl = &d3d10_effect_technique_vtbl;
2078         t->effect = e;
2079
2080         hr = parse_fx10_technique(t, &ptr, data);
2081         if (FAILED(hr)) return hr;
2082     }
2083
2084     return S_OK;
2085 }
2086
2087 static HRESULT parse_fx10(struct d3d10_effect *e, const char *data, DWORD data_size)
2088 {
2089     const char *ptr = data;
2090     DWORD unknown;
2091
2092     /* Compiled target version (e.g. fx_4_0=0xfeff1001, fx_4_1=0xfeff1011). */
2093     read_dword(&ptr, &e->version);
2094     TRACE("Target: %#x\n", e->version);
2095
2096     read_dword(&ptr, &e->local_buffer_count);
2097     TRACE("Local buffer count: %u.\n", e->local_buffer_count);
2098
2099     read_dword(&ptr, &e->variable_count);
2100     TRACE("Variable count: %u\n", e->variable_count);
2101
2102     read_dword(&ptr, &e->local_variable_count);
2103     TRACE("Object count: %u\n", e->local_variable_count);
2104
2105     read_dword(&ptr, &e->sharedbuffers_count);
2106     TRACE("Sharedbuffers count: %u\n", e->sharedbuffers_count);
2107
2108     /* Number of variables in shared buffers? */
2109     read_dword(&ptr, &unknown);
2110     FIXME("Unknown 0: %u\n", unknown);
2111
2112     read_dword(&ptr, &e->sharedobjects_count);
2113     TRACE("Sharedobjects count: %u\n", e->sharedobjects_count);
2114
2115     read_dword(&ptr, &e->technique_count);
2116     TRACE("Technique count: %u\n", e->technique_count);
2117
2118     read_dword(&ptr, &e->index_offset);
2119     TRACE("Index offset: %#x\n", e->index_offset);
2120
2121     read_dword(&ptr, &unknown);
2122     FIXME("Unknown 1: %u\n", unknown);
2123
2124     read_dword(&ptr, &e->texture_count);
2125     TRACE("Texture count: %u\n", e->texture_count);
2126
2127     read_dword(&ptr, &e->dephstencilstate_count);
2128     TRACE("Depthstencilstate count: %u\n", e->dephstencilstate_count);
2129
2130     read_dword(&ptr, &e->blendstate_count);
2131     TRACE("Blendstate count: %u\n", e->blendstate_count);
2132
2133     read_dword(&ptr, &e->rasterizerstate_count);
2134     TRACE("Rasterizerstate count: %u\n", e->rasterizerstate_count);
2135
2136     read_dword(&ptr, &e->samplerstate_count);
2137     TRACE("Samplerstate count: %u\n", e->samplerstate_count);
2138
2139     read_dword(&ptr, &e->rendertargetview_count);
2140     TRACE("Rendertargetview count: %u\n", e->rendertargetview_count);
2141
2142     read_dword(&ptr, &e->depthstencilview_count);
2143     TRACE("Depthstencilview count: %u\n", e->depthstencilview_count);
2144
2145     read_dword(&ptr, &e->used_shader_count);
2146     TRACE("Used shader count: %u\n", e->used_shader_count);
2147
2148     read_dword(&ptr, &e->anonymous_shader_count);
2149     TRACE("Anonymous shader count: %u\n", e->anonymous_shader_count);
2150
2151     return parse_fx10_body(e, ptr, data_size - (ptr - data));
2152 }
2153
2154 static HRESULT fx10_chunk_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
2155 {
2156     struct d3d10_effect *e = ctx;
2157
2158     TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
2159
2160     TRACE("chunk size: %#x\n", data_size);
2161
2162     switch(tag)
2163     {
2164         case TAG_FX10:
2165             return parse_fx10(e, data, data_size);
2166
2167         default:
2168             FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag, 4));
2169             return S_OK;
2170     }
2171 }
2172
2173 HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T data_size)
2174 {
2175     return parse_dxbc(data, data_size, fx10_chunk_handler, This);
2176 }
2177
2178 static HRESULT d3d10_effect_object_apply(struct d3d10_effect_object *o)
2179 {
2180     ID3D10Device *device = o->pass->technique->effect->device;
2181
2182     TRACE("effect object %p, type %#x.\n", o, o->type);
2183
2184     switch(o->type)
2185     {
2186         case D3D10_EOT_RASTERIZER_STATE:
2187             ID3D10Device_RSSetState(device, o->object.rs);
2188             return S_OK;
2189
2190         case D3D10_EOT_DEPTH_STENCIL_STATE:
2191             ID3D10Device_OMSetDepthStencilState(device, o->object.ds, o->pass->stencil_ref);
2192             return S_OK;
2193
2194         case D3D10_EOT_BLEND_STATE:
2195             ID3D10Device_OMSetBlendState(device, o->object.bs, o->pass->blend_factor, o->pass->sample_mask);
2196             return S_OK;
2197
2198         case D3D10_EOT_VERTEXSHADER:
2199             ID3D10Device_VSSetShader(device, o->object.vs);
2200             return S_OK;
2201
2202         case D3D10_EOT_PIXELSHADER:
2203             ID3D10Device_PSSetShader(device, o->object.ps);
2204             return S_OK;
2205
2206         case D3D10_EOT_GEOMETRYSHADER:
2207             ID3D10Device_GSSetShader(device, o->object.gs);
2208             return S_OK;
2209
2210         case D3D10_EOT_STENCIL_REF:
2211         case D3D10_EOT_BLEND_FACTOR:
2212         case D3D10_EOT_SAMPLE_MASK:
2213             return S_OK;
2214
2215         default:
2216             FIXME("Unhandled effect object type %#x.\n", o->type);
2217             return E_FAIL;
2218     }
2219 }
2220
2221 static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_variable *s,
2222         D3D10_SHADER_VARIABLE_TYPE type)
2223 {
2224     shader_free_signature(&s->input_signature);
2225     shader_free_signature(&s->output_signature);
2226
2227     switch (type)
2228     {
2229         case D3D10_SVT_VERTEXSHADER:
2230             if (s->shader.vs)
2231                 ID3D10VertexShader_Release(s->shader.vs);
2232             break;
2233
2234         case D3D10_SVT_PIXELSHADER:
2235             if (s->shader.ps)
2236                 ID3D10PixelShader_Release(s->shader.ps);
2237             break;
2238
2239         case D3D10_SVT_GEOMETRYSHADER:
2240             if (s->shader.gs)
2241                 ID3D10GeometryShader_Release(s->shader.gs);
2242             break;
2243
2244         default:
2245             FIXME("Unhandled shader type %s.\n", debug_d3d10_shader_variable_type(type));
2246             break;
2247     }
2248 }
2249
2250 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v)
2251 {
2252     unsigned int i;
2253
2254     TRACE("variable %p.\n", v);
2255
2256     HeapFree(GetProcessHeap(), 0, v->name);
2257     HeapFree(GetProcessHeap(), 0, v->semantic);
2258     if (v->annotations)
2259     {
2260         for (i = 0; i < v->annotation_count; ++i)
2261         {
2262             d3d10_effect_variable_destroy(&v->annotations[i]);
2263         }
2264         HeapFree(GetProcessHeap(), 0, v->annotations);
2265     }
2266
2267     if (v->members)
2268     {
2269         for (i = 0; i < v->type->member_count; ++i)
2270         {
2271             d3d10_effect_variable_destroy(&v->members[i]);
2272         }
2273         HeapFree(GetProcessHeap(), 0, v->members);
2274     }
2275
2276     if (v->elements)
2277     {
2278         for (i = 0; i < v->type->element_count; ++i)
2279         {
2280             d3d10_effect_variable_destroy(&v->elements[i]);
2281         }
2282         HeapFree(GetProcessHeap(), 0, v->elements);
2283     }
2284
2285     switch(v->type->basetype)
2286     {
2287         case D3D10_SVT_VERTEXSHADER:
2288         case D3D10_SVT_PIXELSHADER:
2289         case D3D10_SVT_GEOMETRYSHADER:
2290             d3d10_effect_shader_variable_destroy(&v->u.shader, v->type->basetype);
2291             break;
2292
2293         default:
2294             break;
2295     }
2296 }
2297
2298 static void d3d10_effect_object_destroy(struct d3d10_effect_object *o)
2299 {
2300     switch (o->type)
2301     {
2302         case D3D10_EOT_RASTERIZER_STATE:
2303             if (o->object.rs)
2304                 ID3D10RasterizerState_Release(o->object.rs);
2305             break;
2306
2307         case D3D10_EOT_DEPTH_STENCIL_STATE:
2308             if (o->object.ds)
2309                 ID3D10DepthStencilState_Release(o->object.ds);
2310             break;
2311
2312         case D3D10_EOT_BLEND_STATE:
2313             if (o->object.bs)
2314                 ID3D10BlendState_Release(o->object.bs);
2315             break;
2316
2317         case D3D10_EOT_VERTEXSHADER:
2318             if (o->object.vs)
2319                 ID3D10VertexShader_Release(o->object.vs);
2320             break;
2321
2322         case D3D10_EOT_PIXELSHADER:
2323             if (o->object.ps)
2324                 ID3D10PixelShader_Release(o->object.ps);
2325             break;
2326
2327         case D3D10_EOT_GEOMETRYSHADER:
2328             if (o->object.gs)
2329                 ID3D10GeometryShader_Release(o->object.gs);
2330             break;
2331
2332         default:
2333             break;
2334     }
2335 }
2336
2337 static void d3d10_effect_pass_destroy(struct d3d10_effect_pass *p)
2338 {
2339     unsigned int i;
2340
2341     TRACE("pass %p\n", p);
2342
2343     HeapFree(GetProcessHeap(), 0, p->name);
2344
2345     if (p->objects)
2346     {
2347         for (i = 0; i < p->object_count; ++i)
2348         {
2349             d3d10_effect_object_destroy(&p->objects[i]);
2350         }
2351         HeapFree(GetProcessHeap(), 0, p->objects);
2352     }
2353
2354     if (p->annotations)
2355     {
2356         for (i = 0; i < p->annotation_count; ++i)
2357         {
2358             d3d10_effect_variable_destroy(&p->annotations[i]);
2359         }
2360         HeapFree(GetProcessHeap(), 0, p->annotations);
2361     }
2362 }
2363
2364 static void d3d10_effect_technique_destroy(struct d3d10_effect_technique *t)
2365 {
2366     unsigned int i;
2367
2368     TRACE("technique %p\n", t);
2369
2370     HeapFree(GetProcessHeap(), 0, t->name);
2371     if (t->passes)
2372     {
2373         for (i = 0; i < t->pass_count; ++i)
2374         {
2375             d3d10_effect_pass_destroy(&t->passes[i]);
2376         }
2377         HeapFree(GetProcessHeap(), 0, t->passes);
2378     }
2379
2380     if (t->annotations)
2381     {
2382         for (i = 0; i < t->annotation_count; ++i)
2383         {
2384             d3d10_effect_variable_destroy(&t->annotations[i]);
2385         }
2386         HeapFree(GetProcessHeap(), 0, t->annotations);
2387     }
2388 }
2389
2390 static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable *l)
2391 {
2392     unsigned int i;
2393
2394     TRACE("local buffer %p.\n", l);
2395
2396     HeapFree(GetProcessHeap(), 0, l->name);
2397     if (l->members)
2398     {
2399         for (i = 0; i < l->type->member_count; ++i)
2400         {
2401             d3d10_effect_variable_destroy(&l->members[i]);
2402         }
2403         HeapFree(GetProcessHeap(), 0, l->members);
2404     }
2405
2406     if (l->type->members)
2407     {
2408         for (i = 0; i < l->type->member_count; ++i)
2409         {
2410             /* Do not release l->type->members[i].type, it will be covered by d3d10_effect_type_destroy(). */
2411             HeapFree(GetProcessHeap(), 0, l->type->members[i].semantic);
2412             HeapFree(GetProcessHeap(), 0, l->type->members[i].name);
2413         }
2414         HeapFree(GetProcessHeap(), 0, l->type->members);
2415     }
2416     HeapFree(GetProcessHeap(), 0, l->type->name);
2417     HeapFree(GetProcessHeap(), 0, l->type);
2418
2419     if (l->annotations)
2420     {
2421         for (i = 0; i < l->annotation_count; ++i)
2422         {
2423             d3d10_effect_variable_destroy(&l->annotations[i]);
2424         }
2425         HeapFree(GetProcessHeap(), 0, l->annotations);
2426     }
2427 }
2428
2429 /* IUnknown methods */
2430
2431 static inline struct d3d10_effect *impl_from_ID3D10Effect(ID3D10Effect *iface)
2432 {
2433     return CONTAINING_RECORD(iface, struct d3d10_effect, ID3D10Effect_iface);
2434 }
2435
2436 static HRESULT STDMETHODCALLTYPE d3d10_effect_QueryInterface(ID3D10Effect *iface, REFIID riid, void **object)
2437 {
2438     TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
2439
2440     if (IsEqualGUID(riid, &IID_ID3D10Effect)
2441             || IsEqualGUID(riid, &IID_IUnknown))
2442     {
2443         IUnknown_AddRef(iface);
2444         *object = iface;
2445         return S_OK;
2446     }
2447
2448     WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
2449
2450     *object = NULL;
2451     return E_NOINTERFACE;
2452 }
2453
2454 static ULONG STDMETHODCALLTYPE d3d10_effect_AddRef(ID3D10Effect *iface)
2455 {
2456     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2457     ULONG refcount = InterlockedIncrement(&This->refcount);
2458
2459     TRACE("%p increasing refcount to %u\n", This, refcount);
2460
2461     return refcount;
2462 }
2463
2464 static ULONG STDMETHODCALLTYPE d3d10_effect_Release(ID3D10Effect *iface)
2465 {
2466     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2467     ULONG refcount = InterlockedDecrement(&This->refcount);
2468
2469     TRACE("%p decreasing refcount to %u\n", This, refcount);
2470
2471     if (!refcount)
2472     {
2473         unsigned int i;
2474
2475         if (This->techniques)
2476         {
2477             for (i = 0; i < This->technique_count; ++i)
2478             {
2479                 d3d10_effect_technique_destroy(&This->techniques[i]);
2480             }
2481             HeapFree(GetProcessHeap(), 0, This->techniques);
2482         }
2483
2484         if (This->local_variables)
2485         {
2486             for (i = 0; i < This->local_variable_count; ++i)
2487             {
2488                 d3d10_effect_variable_destroy(&This->local_variables[i]);
2489             }
2490             HeapFree(GetProcessHeap(), 0, This->local_variables);
2491         }
2492
2493         if (This->local_buffers)
2494         {
2495             for (i = 0; i < This->local_buffer_count; ++i)
2496             {
2497                 d3d10_effect_local_buffer_destroy(&This->local_buffers[i]);
2498             }
2499             HeapFree(GetProcessHeap(), 0, This->local_buffers);
2500         }
2501
2502         if (This->anonymous_shaders)
2503         {
2504             for (i = 0; i < This->anonymous_shader_count; ++i)
2505             {
2506                 d3d10_effect_variable_destroy(&This->anonymous_shaders[i].shader);
2507                 HeapFree(GetProcessHeap(), 0, This->anonymous_shaders[i].type.name);
2508             }
2509             HeapFree(GetProcessHeap(), 0, This->anonymous_shaders);
2510         }
2511
2512         HeapFree(GetProcessHeap(), 0, This->used_shaders);
2513
2514         wine_rb_destroy(&This->types, d3d10_effect_type_destroy, NULL);
2515
2516         ID3D10Device_Release(This->device);
2517         HeapFree(GetProcessHeap(), 0, This);
2518     }
2519
2520     return refcount;
2521 }
2522
2523 /* ID3D10Effect methods */
2524
2525 static BOOL STDMETHODCALLTYPE d3d10_effect_IsValid(ID3D10Effect *iface)
2526 {
2527     FIXME("iface %p stub!\n", iface);
2528
2529     return FALSE;
2530 }
2531
2532 static BOOL STDMETHODCALLTYPE d3d10_effect_IsPool(ID3D10Effect *iface)
2533 {
2534     FIXME("iface %p stub!\n", iface);
2535
2536     return FALSE;
2537 }
2538
2539 static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDevice(ID3D10Effect *iface, ID3D10Device **device)
2540 {
2541     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2542
2543     TRACE("iface %p, device %p\n", iface, device);
2544
2545     ID3D10Device_AddRef(This->device);
2546     *device = This->device;
2547
2548     return S_OK;
2549 }
2550
2551 static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDesc(ID3D10Effect *iface, D3D10_EFFECT_DESC *desc)
2552 {
2553     FIXME("iface %p, desc %p stub!\n", iface, desc);
2554
2555     return E_NOTIMPL;
2556 }
2557
2558 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetConstantBufferByIndex(ID3D10Effect *iface,
2559         UINT index)
2560 {
2561     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2562     struct d3d10_effect_variable *l;
2563
2564     TRACE("iface %p, index %u\n", iface, index);
2565
2566     if (index >= This->local_buffer_count)
2567     {
2568         WARN("Invalid index specified\n");
2569         return (ID3D10EffectConstantBuffer *)&null_local_buffer;
2570     }
2571
2572     l = &This->local_buffers[index];
2573
2574     TRACE("Returning buffer %p, %s.\n", l, debugstr_a(l->name));
2575
2576     return (ID3D10EffectConstantBuffer *)l;
2577 }
2578
2579 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetConstantBufferByName(ID3D10Effect *iface,
2580         LPCSTR name)
2581 {
2582     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2583     unsigned int i;
2584
2585     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
2586
2587     for (i = 0; i < This->local_buffer_count; ++i)
2588     {
2589         struct d3d10_effect_variable *l = &This->local_buffers[i];
2590
2591         if (!strcmp(l->name, name))
2592         {
2593             TRACE("Returning buffer %p.\n", l);
2594             return (ID3D10EffectConstantBuffer *)l;
2595         }
2596     }
2597
2598     WARN("Invalid name specified\n");
2599
2600     return (ID3D10EffectConstantBuffer *)&null_local_buffer;
2601 }
2602
2603 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableByIndex(ID3D10Effect *iface, UINT index)
2604 {
2605     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2606     unsigned int i;
2607
2608     TRACE("iface %p, index %u\n", iface, index);
2609
2610     for (i = 0; i < This->local_buffer_count; ++i)
2611     {
2612         struct d3d10_effect_variable *l = &This->local_buffers[i];
2613
2614         if (index < l->type->member_count)
2615         {
2616             struct d3d10_effect_variable *v = &l->members[index];
2617
2618             TRACE("Returning variable %p.\n", v);
2619             return &v->ID3D10EffectVariable_iface;
2620         }
2621         index -= l->type->member_count;
2622     }
2623
2624     if (index < This->local_variable_count)
2625     {
2626         struct d3d10_effect_variable *v = &This->local_variables[index];
2627
2628         TRACE("Returning variable %p.\n", v);
2629         return &v->ID3D10EffectVariable_iface;
2630     }
2631
2632     WARN("Invalid index specified\n");
2633
2634     return &null_variable.ID3D10EffectVariable_iface;
2635 }
2636
2637 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableByName(ID3D10Effect *iface, LPCSTR name)
2638 {
2639     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2640     unsigned int i;
2641
2642     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
2643
2644     if (!name)
2645     {
2646         WARN("Invalid name specified\n");
2647         return &null_variable.ID3D10EffectVariable_iface;
2648     }
2649
2650     for (i = 0; i < This->local_buffer_count; ++i)
2651     {
2652         struct d3d10_effect_variable *l = &This->local_buffers[i];
2653         unsigned int j;
2654
2655         for (j = 0; j < l->type->member_count; ++j)
2656         {
2657             struct d3d10_effect_variable *v = &l->members[j];
2658
2659             if (!strcmp(v->name, name))
2660             {
2661                 TRACE("Returning variable %p.\n", v);
2662                 return &v->ID3D10EffectVariable_iface;
2663             }
2664         }
2665     }
2666
2667     for (i = 0; i < This->local_variable_count; ++i)
2668     {
2669         struct d3d10_effect_variable *v = &This->local_variables[i];
2670
2671         if (!strcmp(v->name, name))
2672         {
2673             TRACE("Returning variable %p.\n", v);
2674             return &v->ID3D10EffectVariable_iface;
2675         }
2676     }
2677
2678     WARN("Invalid name specified\n");
2679
2680     return &null_variable.ID3D10EffectVariable_iface;
2681 }
2682
2683 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableBySemantic(ID3D10Effect *iface,
2684         LPCSTR semantic)
2685 {
2686     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2687     unsigned int i;
2688
2689     TRACE("iface %p, semantic %s\n", iface, debugstr_a(semantic));
2690
2691     if (!semantic)
2692     {
2693         WARN("Invalid semantic specified\n");
2694         return &null_variable.ID3D10EffectVariable_iface;
2695     }
2696
2697     for (i = 0; i < This->local_buffer_count; ++i)
2698     {
2699         struct d3d10_effect_variable *l = &This->local_buffers[i];
2700         unsigned int j;
2701
2702         for (j = 0; j < l->type->member_count; ++j)
2703         {
2704             struct d3d10_effect_variable *v = &l->members[j];
2705
2706             if (!strcmp(v->semantic, semantic))
2707             {
2708                 TRACE("Returning variable %p.\n", v);
2709                 return &v->ID3D10EffectVariable_iface;
2710             }
2711         }
2712     }
2713
2714     for (i = 0; i < This->local_variable_count; ++i)
2715     {
2716         struct d3d10_effect_variable *v = &This->local_variables[i];
2717
2718         if (!strcmp(v->semantic, semantic))
2719         {
2720             TRACE("Returning variable %p.\n", v);
2721             return &v->ID3D10EffectVariable_iface;
2722         }
2723     }
2724
2725     WARN("Invalid semantic specified\n");
2726
2727     return &null_variable.ID3D10EffectVariable_iface;
2728 }
2729
2730 static struct ID3D10EffectTechnique * STDMETHODCALLTYPE d3d10_effect_GetTechniqueByIndex(ID3D10Effect *iface,
2731         UINT index)
2732 {
2733     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2734     struct d3d10_effect_technique *t;
2735
2736     TRACE("iface %p, index %u\n", iface, index);
2737
2738     if (index >= This->technique_count)
2739     {
2740         WARN("Invalid index specified\n");
2741         return &null_technique.ID3D10EffectTechnique_iface;
2742     }
2743
2744     t = &This->techniques[index];
2745
2746     TRACE("Returning technique %p, %s.\n", t, debugstr_a(t->name));
2747
2748     return &t->ID3D10EffectTechnique_iface;
2749 }
2750
2751 static struct ID3D10EffectTechnique * STDMETHODCALLTYPE d3d10_effect_GetTechniqueByName(ID3D10Effect *iface,
2752         LPCSTR name)
2753 {
2754     struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2755     unsigned int i;
2756
2757     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
2758
2759     if (!name)
2760     {
2761         WARN("Invalid name specified\n");
2762         return &null_technique.ID3D10EffectTechnique_iface;
2763     }
2764
2765     for (i = 0; i < This->technique_count; ++i)
2766     {
2767         struct d3d10_effect_technique *t = &This->techniques[i];
2768         if (!strcmp(t->name, name))
2769         {
2770             TRACE("Returning technique %p\n", t);
2771             return &t->ID3D10EffectTechnique_iface;
2772         }
2773     }
2774
2775     WARN("Invalid name specified\n");
2776
2777     return &null_technique.ID3D10EffectTechnique_iface;
2778 }
2779
2780 static HRESULT STDMETHODCALLTYPE d3d10_effect_Optimize(ID3D10Effect *iface)
2781 {
2782     FIXME("iface %p stub!\n", iface);
2783
2784     return E_NOTIMPL;
2785 }
2786
2787 static BOOL STDMETHODCALLTYPE d3d10_effect_IsOptimized(ID3D10Effect *iface)
2788 {
2789     FIXME("iface %p stub!\n", iface);
2790
2791     return FALSE;
2792 }
2793
2794 const struct ID3D10EffectVtbl d3d10_effect_vtbl =
2795 {
2796     /* IUnknown methods */
2797     d3d10_effect_QueryInterface,
2798     d3d10_effect_AddRef,
2799     d3d10_effect_Release,
2800     /* ID3D10Effect methods */
2801     d3d10_effect_IsValid,
2802     d3d10_effect_IsPool,
2803     d3d10_effect_GetDevice,
2804     d3d10_effect_GetDesc,
2805     d3d10_effect_GetConstantBufferByIndex,
2806     d3d10_effect_GetConstantBufferByName,
2807     d3d10_effect_GetVariableByIndex,
2808     d3d10_effect_GetVariableByName,
2809     d3d10_effect_GetVariableBySemantic,
2810     d3d10_effect_GetTechniqueByIndex,
2811     d3d10_effect_GetTechniqueByName,
2812     d3d10_effect_Optimize,
2813     d3d10_effect_IsOptimized,
2814 };
2815
2816 /* ID3D10EffectTechnique methods */
2817
2818 static inline struct d3d10_effect_technique *impl_from_ID3D10EffectTechnique(ID3D10EffectTechnique *iface)
2819 {
2820     return CONTAINING_RECORD(iface, struct d3d10_effect_technique, ID3D10EffectTechnique_iface);
2821 }
2822
2823 static BOOL STDMETHODCALLTYPE d3d10_effect_technique_IsValid(ID3D10EffectTechnique *iface)
2824 {
2825     struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
2826
2827     TRACE("iface %p\n", iface);
2828
2829     return This != &null_technique;
2830 }
2831
2832 static HRESULT STDMETHODCALLTYPE d3d10_effect_technique_GetDesc(ID3D10EffectTechnique *iface,
2833         D3D10_TECHNIQUE_DESC *desc)
2834 {
2835     struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
2836
2837     TRACE("iface %p, desc %p\n", iface, desc);
2838
2839     if(This == &null_technique)
2840     {
2841         WARN("Null technique specified\n");
2842         return E_FAIL;
2843     }
2844
2845     if(!desc)
2846     {
2847         WARN("Invalid argument specified\n");
2848         return E_INVALIDARG;
2849     }
2850
2851     desc->Name = This->name;
2852     desc->Passes = This->pass_count;
2853     desc->Annotations = This->annotation_count;
2854
2855     return S_OK;
2856 }
2857
2858 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByIndex(
2859         ID3D10EffectTechnique *iface, UINT index)
2860 {
2861     struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
2862     struct d3d10_effect_variable *a;
2863
2864     TRACE("iface %p, index %u\n", iface, index);
2865
2866     if (index >= This->annotation_count)
2867     {
2868         WARN("Invalid index specified\n");
2869         return &null_variable.ID3D10EffectVariable_iface;
2870     }
2871
2872     a = &This->annotations[index];
2873
2874     TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name));
2875
2876     return &a->ID3D10EffectVariable_iface;
2877 }
2878
2879 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByName(
2880         ID3D10EffectTechnique *iface, LPCSTR name)
2881 {
2882     struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
2883     unsigned int i;
2884
2885     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
2886
2887     for (i = 0; i < This->annotation_count; ++i)
2888     {
2889         struct d3d10_effect_variable *a = &This->annotations[i];
2890         if (!strcmp(a->name, name))
2891         {
2892             TRACE("Returning annotation %p\n", a);
2893             return &a->ID3D10EffectVariable_iface;
2894         }
2895     }
2896
2897     WARN("Invalid name specified\n");
2898
2899     return &null_variable.ID3D10EffectVariable_iface;
2900 }
2901
2902 static struct ID3D10EffectPass * STDMETHODCALLTYPE d3d10_effect_technique_GetPassByIndex(ID3D10EffectTechnique *iface,
2903         UINT index)
2904 {
2905     struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
2906     struct d3d10_effect_pass *p;
2907
2908     TRACE("iface %p, index %u\n", iface, index);
2909
2910     if (index >= This->pass_count)
2911     {
2912         WARN("Invalid index specified\n");
2913         return &null_pass.ID3D10EffectPass_iface;
2914     }
2915
2916     p = &This->passes[index];
2917
2918     TRACE("Returning pass %p, %s.\n", p, debugstr_a(p->name));
2919
2920     return &p->ID3D10EffectPass_iface;
2921 }
2922
2923 static struct ID3D10EffectPass * STDMETHODCALLTYPE d3d10_effect_technique_GetPassByName(ID3D10EffectTechnique *iface,
2924         LPCSTR name)
2925 {
2926     struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
2927     unsigned int i;
2928
2929     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
2930
2931     /* Do not check for name==NULL, W7/DX10 crashes in that case. */
2932
2933     for (i = 0; i < This->pass_count; ++i)
2934     {
2935         struct d3d10_effect_pass *p = &This->passes[i];
2936         if (!strcmp(p->name, name))
2937         {
2938             TRACE("Returning pass %p\n", p);
2939             return &p->ID3D10EffectPass_iface;
2940         }
2941     }
2942
2943     WARN("Invalid name specified\n");
2944
2945     return &null_pass.ID3D10EffectPass_iface;
2946 }
2947
2948 static HRESULT STDMETHODCALLTYPE d3d10_effect_technique_ComputeStateBlockMask(ID3D10EffectTechnique *iface,
2949         D3D10_STATE_BLOCK_MASK *mask)
2950 {
2951     FIXME("iface %p,mask %p stub!\n", iface, mask);
2952
2953     return E_NOTIMPL;
2954 }
2955
2956 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl =
2957 {
2958     /* ID3D10EffectTechnique methods */
2959     d3d10_effect_technique_IsValid,
2960     d3d10_effect_technique_GetDesc,
2961     d3d10_effect_technique_GetAnnotationByIndex,
2962     d3d10_effect_technique_GetAnnotationByName,
2963     d3d10_effect_technique_GetPassByIndex,
2964     d3d10_effect_technique_GetPassByName,
2965     d3d10_effect_technique_ComputeStateBlockMask,
2966 };
2967
2968 /* ID3D10EffectPass methods */
2969
2970 static inline struct d3d10_effect_pass *impl_from_ID3D10EffectPass(ID3D10EffectPass *iface)
2971 {
2972     return CONTAINING_RECORD(iface, struct d3d10_effect_pass, ID3D10EffectPass_iface);
2973 }
2974
2975 static BOOL STDMETHODCALLTYPE d3d10_effect_pass_IsValid(ID3D10EffectPass *iface)
2976 {
2977     struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
2978
2979     TRACE("iface %p\n", iface);
2980
2981     return This != &null_pass;
2982 }
2983
2984 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetDesc(ID3D10EffectPass *iface,
2985         D3D10_PASS_DESC *desc)
2986 {
2987     struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
2988     struct d3d10_effect_shader_variable *s;
2989
2990     FIXME("iface %p, desc %p partial stub!\n", iface, desc);
2991
2992     if(This == &null_pass)
2993     {
2994         WARN("Null pass specified\n");
2995         return E_FAIL;
2996     }
2997
2998     if(!desc)
2999     {
3000         WARN("Invalid argument specified\n");
3001         return E_INVALIDARG;
3002     }
3003
3004     memset(desc, 0, sizeof(*desc));
3005     desc->Name = This->name;
3006
3007     s = &impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)This->vs.pShaderVariable)->u.shader;
3008     desc->pIAInputSignature = (BYTE *)s->input_signature.signature;
3009     desc->IAInputSignatureSize = s->input_signature.signature_size;
3010
3011     desc->StencilRef = This->stencil_ref;
3012     desc->SampleMask = This->sample_mask;
3013     memcpy(desc->BlendFactor, This->blend_factor, 4 * sizeof(float));
3014
3015     return S_OK;
3016 }
3017
3018 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetVertexShaderDesc(ID3D10EffectPass *iface,
3019         D3D10_PASS_SHADER_DESC *desc)
3020 {
3021     struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3022
3023     TRACE("iface %p, desc %p\n", iface, desc);
3024
3025     if (This == &null_pass)
3026     {
3027         WARN("Null pass specified\n");
3028         return E_FAIL;
3029     }
3030
3031     if (!desc)
3032     {
3033         WARN("Invalid argument specified\n");
3034         return E_INVALIDARG;
3035     }
3036
3037     *desc = This->vs;
3038
3039     return S_OK;
3040 }
3041
3042 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetGeometryShaderDesc(ID3D10EffectPass *iface,
3043         D3D10_PASS_SHADER_DESC *desc)
3044 {
3045     struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3046
3047     TRACE("iface %p, desc %p\n", iface, desc);
3048
3049     if (This == &null_pass)
3050     {
3051         WARN("Null pass specified\n");
3052         return E_FAIL;
3053     }
3054
3055     if (!desc)
3056     {
3057         WARN("Invalid argument specified\n");
3058         return E_INVALIDARG;
3059     }
3060
3061     *desc = This->gs;
3062
3063     return S_OK;
3064 }
3065
3066 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetPixelShaderDesc(ID3D10EffectPass *iface,
3067         D3D10_PASS_SHADER_DESC *desc)
3068 {
3069     struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3070
3071     TRACE("iface %p, desc %p\n", iface, desc);
3072
3073     if (This == &null_pass)
3074     {
3075         WARN("Null pass specified\n");
3076         return E_FAIL;
3077     }
3078
3079     if (!desc)
3080     {
3081         WARN("Invalid argument specified\n");
3082         return E_INVALIDARG;
3083     }
3084
3085     *desc = This->ps;
3086
3087     return S_OK;
3088 }
3089
3090 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByIndex(ID3D10EffectPass *iface,
3091         UINT index)
3092 {
3093     struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3094     struct d3d10_effect_variable *a;
3095
3096     TRACE("iface %p, index %u\n", iface, index);
3097
3098     if (index >= This->annotation_count)
3099     {
3100         WARN("Invalid index specified\n");
3101         return &null_variable.ID3D10EffectVariable_iface;
3102     }
3103
3104     a = &This->annotations[index];
3105
3106     TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name));
3107
3108     return &a->ID3D10EffectVariable_iface;
3109 }
3110
3111 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByName(ID3D10EffectPass *iface,
3112         LPCSTR name)
3113 {
3114     struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3115     unsigned int i;
3116
3117     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3118
3119     for (i = 0; i < This->annotation_count; ++i)
3120     {
3121         struct d3d10_effect_variable *a = &This->annotations[i];
3122         if (!strcmp(a->name, name))
3123         {
3124             TRACE("Returning annotation %p\n", a);
3125             return &a->ID3D10EffectVariable_iface;
3126         }
3127     }
3128
3129     WARN("Invalid name specified\n");
3130
3131     return &null_variable.ID3D10EffectVariable_iface;
3132 }
3133
3134 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_Apply(ID3D10EffectPass *iface, UINT flags)
3135 {
3136     struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3137     HRESULT hr = S_OK;
3138     unsigned int i;
3139
3140     TRACE("iface %p, flags %#x\n", iface, flags);
3141
3142     if (flags) FIXME("Ignoring flags (%#x)\n", flags);
3143
3144     for (i = 0; i < This->object_count; ++i)
3145     {
3146         hr = d3d10_effect_object_apply(&This->objects[i]);
3147         if (FAILED(hr)) break;
3148     }
3149
3150     return hr;
3151 }
3152
3153 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_ComputeStateBlockMask(ID3D10EffectPass *iface,
3154         D3D10_STATE_BLOCK_MASK *mask)
3155 {
3156     FIXME("iface %p, mask %p stub!\n", iface, mask);
3157
3158     return E_NOTIMPL;
3159 }
3160
3161 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl =
3162 {
3163     /* ID3D10EffectPass methods */
3164     d3d10_effect_pass_IsValid,
3165     d3d10_effect_pass_GetDesc,
3166     d3d10_effect_pass_GetVertexShaderDesc,
3167     d3d10_effect_pass_GetGeometryShaderDesc,
3168     d3d10_effect_pass_GetPixelShaderDesc,
3169     d3d10_effect_pass_GetAnnotationByIndex,
3170     d3d10_effect_pass_GetAnnotationByName,
3171     d3d10_effect_pass_Apply,
3172     d3d10_effect_pass_ComputeStateBlockMask,
3173 };
3174
3175 /* ID3D10EffectVariable methods */
3176
3177 static BOOL STDMETHODCALLTYPE d3d10_effect_variable_IsValid(ID3D10EffectVariable *iface)
3178 {
3179     TRACE("iface %p\n", iface);
3180
3181     return impl_from_ID3D10EffectVariable(iface) != &null_variable;
3182 }
3183
3184 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_variable_GetType(ID3D10EffectVariable *iface)
3185 {
3186     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3187
3188     TRACE("iface %p\n", iface);
3189
3190     return &This->type->ID3D10EffectType_iface;
3191 }
3192
3193 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetDesc(ID3D10EffectVariable *iface,
3194         D3D10_EFFECT_VARIABLE_DESC *desc)
3195 {
3196     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3197
3198     TRACE("iface %p, desc %p\n", iface, desc);
3199
3200     if (!iface->lpVtbl->IsValid(iface))
3201     {
3202         WARN("Null variable specified\n");
3203         return E_FAIL;
3204     }
3205
3206     if (!desc)
3207     {
3208         WARN("Invalid argument specified\n");
3209         return E_INVALIDARG;
3210     }
3211
3212     /* FIXME: This isn't correct. Anonymous shaders let desc->ExplicitBindPoint untouched, but normal shaders set it! */
3213     memset(desc, 0, sizeof(*desc));
3214     desc->Name = This->name;
3215     desc->Semantic = This->semantic;
3216     desc->Flags = This->flag;
3217     desc->Annotations = This->annotation_count;
3218     desc->BufferOffset = This->buffer_offset;
3219
3220     if (This->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
3221     {
3222         desc->ExplicitBindPoint = This->buffer_offset;
3223     }
3224
3225     return S_OK;
3226 }
3227
3228 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByIndex(
3229         ID3D10EffectVariable *iface, UINT index)
3230 {
3231     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3232     struct d3d10_effect_variable *a;
3233
3234     TRACE("iface %p, index %u\n", iface, index);
3235
3236     if (index >= This->annotation_count)
3237     {
3238         WARN("Invalid index specified\n");
3239         return &null_variable.ID3D10EffectVariable_iface;
3240     }
3241
3242     a = &This->annotations[index];
3243
3244     TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name));
3245
3246     return &a->ID3D10EffectVariable_iface;
3247 }
3248
3249 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByName(
3250         ID3D10EffectVariable *iface, LPCSTR name)
3251 {
3252     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3253     unsigned int i;
3254
3255     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3256
3257     for (i = 0; i < This->annotation_count; ++i)
3258     {
3259         struct d3d10_effect_variable *a = &This->annotations[i];
3260         if (!strcmp(a->name, name))
3261         {
3262             TRACE("Returning annotation %p\n", a);
3263             return &a->ID3D10EffectVariable_iface;
3264         }
3265     }
3266
3267     WARN("Invalid name specified\n");
3268
3269     return &null_variable.ID3D10EffectVariable_iface;
3270 }
3271
3272 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberByIndex(
3273         ID3D10EffectVariable *iface, UINT index)
3274 {
3275     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3276     struct d3d10_effect_variable *m;
3277
3278     TRACE("iface %p, index %u\n", iface, index);
3279
3280     if (index >= This->type->member_count)
3281     {
3282         WARN("Invalid index specified\n");
3283         return &null_variable.ID3D10EffectVariable_iface;
3284     }
3285
3286     m = &This->members[index];
3287
3288     TRACE("Returning member %p, %s\n", m, debugstr_a(m->name));
3289
3290     return &m->ID3D10EffectVariable_iface;
3291 }
3292
3293 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberByName(
3294         ID3D10EffectVariable *iface, LPCSTR name)
3295 {
3296     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3297     unsigned int i;
3298
3299     TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3300
3301     if (!name)
3302     {
3303         WARN("Invalid name specified\n");
3304         return &null_variable.ID3D10EffectVariable_iface;
3305     }
3306
3307     for (i = 0; i < This->type->member_count; ++i)
3308     {
3309         struct d3d10_effect_variable *m = &This->members[i];
3310
3311         if (m->name)
3312         {
3313             if (!strcmp(m->name, name))
3314             {
3315                 TRACE("Returning member %p\n", m);
3316                 return &m->ID3D10EffectVariable_iface;
3317             }
3318         }
3319     }
3320
3321     WARN("Invalid name specified\n");
3322
3323     return &null_variable.ID3D10EffectVariable_iface;
3324 }
3325
3326 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberBySemantic(
3327         ID3D10EffectVariable *iface, LPCSTR semantic)
3328 {
3329     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3330     unsigned int i;
3331
3332     TRACE("iface %p, semantic %s.\n", iface, debugstr_a(semantic));
3333
3334     if (!semantic)
3335     {
3336         WARN("Invalid semantic specified\n");
3337         return &null_variable.ID3D10EffectVariable_iface;
3338     }
3339
3340     for (i = 0; i < This->type->member_count; ++i)
3341     {
3342         struct d3d10_effect_variable *m = &This->members[i];
3343
3344         if (m->semantic)
3345         {
3346             if (!strcmp(m->semantic, semantic))
3347             {
3348                 TRACE("Returning member %p\n", m);
3349                 return &m->ID3D10EffectVariable_iface;
3350             }
3351         }
3352     }
3353
3354     WARN("Invalid semantic specified\n");
3355
3356     return &null_variable.ID3D10EffectVariable_iface;
3357 }
3358
3359 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetElement(
3360         ID3D10EffectVariable *iface, UINT index)
3361 {
3362     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3363     struct d3d10_effect_variable *v;
3364
3365     TRACE("iface %p, index %u\n", iface, index);
3366
3367     if (index >= This->type->element_count)
3368     {
3369         WARN("Invalid index specified\n");
3370         return &null_variable.ID3D10EffectVariable_iface;
3371     }
3372
3373     v = &This->elements[index];
3374
3375     TRACE("Returning element %p, %s\n", v, debugstr_a(v->name));
3376
3377     return &v->ID3D10EffectVariable_iface;
3378 }
3379
3380 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_variable_GetParentConstantBuffer(
3381         ID3D10EffectVariable *iface)
3382 {
3383     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3384
3385     TRACE("iface %p\n", iface);
3386
3387     return (ID3D10EffectConstantBuffer *)This->buffer;
3388 }
3389
3390 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsScalar(
3391         ID3D10EffectVariable *iface)
3392 {
3393     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3394
3395     TRACE("iface %p\n", iface);
3396
3397     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl)
3398         return (ID3D10EffectScalarVariable *)&This->ID3D10EffectVariable_iface;
3399
3400     return (ID3D10EffectScalarVariable *)&null_scalar_variable.ID3D10EffectVariable_iface;
3401 }
3402
3403 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsVector(
3404         ID3D10EffectVariable *iface)
3405 {
3406     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3407
3408     TRACE("iface %p\n", iface);
3409
3410     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl)
3411         return (ID3D10EffectVectorVariable *)&This->ID3D10EffectVariable_iface;
3412
3413     return (ID3D10EffectVectorVariable *)&null_vector_variable.ID3D10EffectVariable_iface;
3414 }
3415
3416 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsMatrix(
3417         ID3D10EffectVariable *iface)
3418 {
3419     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3420
3421     TRACE("iface %p\n", iface);
3422
3423     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl)
3424         return (ID3D10EffectMatrixVariable *)&This->ID3D10EffectVariable_iface;
3425
3426     return (ID3D10EffectMatrixVariable *)&null_matrix_variable.ID3D10EffectVariable_iface;
3427 }
3428
3429 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsString(
3430         ID3D10EffectVariable *iface)
3431 {
3432     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3433
3434     TRACE("iface %p\n", iface);
3435
3436     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl)
3437         return (ID3D10EffectStringVariable *)&This->ID3D10EffectVariable_iface;
3438
3439     return (ID3D10EffectStringVariable *)&null_string_variable.ID3D10EffectVariable_iface;
3440 }
3441
3442 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsShaderResource(
3443         ID3D10EffectVariable *iface)
3444 {
3445     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3446
3447     TRACE("iface %p\n", iface);
3448
3449     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl)
3450         return (ID3D10EffectShaderResourceVariable *)&This->ID3D10EffectVariable_iface;
3451
3452     return (ID3D10EffectShaderResourceVariable *)&null_shader_resource_variable.ID3D10EffectVariable_iface;
3453 }
3454
3455 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsRenderTargetView(
3456         ID3D10EffectVariable *iface)
3457 {
3458     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3459
3460     TRACE("iface %p\n", iface);
3461
3462     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl)
3463         return (ID3D10EffectRenderTargetViewVariable *)&This->ID3D10EffectVariable_iface;
3464
3465     return (ID3D10EffectRenderTargetViewVariable *)&null_render_target_view_variable.ID3D10EffectVariable_iface;
3466 }
3467
3468 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsDepthStencilView(
3469         ID3D10EffectVariable *iface)
3470 {
3471     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3472
3473     TRACE("iface %p\n", iface);
3474
3475     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl)
3476         return (ID3D10EffectDepthStencilViewVariable *)&This->ID3D10EffectVariable_iface;
3477
3478     return (ID3D10EffectDepthStencilViewVariable *)&null_depth_stencil_view_variable.ID3D10EffectVariable_iface;
3479 }
3480
3481 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_variable_AsConstantBuffer(
3482         ID3D10EffectVariable *iface)
3483 {
3484     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3485
3486     TRACE("iface %p\n", iface);
3487
3488     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl)
3489         return (ID3D10EffectConstantBuffer *)&This->ID3D10EffectVariable_iface;
3490
3491     return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
3492 }
3493
3494 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsShader(
3495         ID3D10EffectVariable *iface)
3496 {
3497     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3498
3499     TRACE("iface %p\n", iface);
3500
3501     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl)
3502         return (ID3D10EffectShaderVariable *)&This->ID3D10EffectVariable_iface;
3503
3504     return (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
3505 }
3506
3507 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsBlend(ID3D10EffectVariable *iface)
3508 {
3509     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3510
3511     TRACE("iface %p\n", iface);
3512
3513     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl)
3514         return (ID3D10EffectBlendVariable *)&This->ID3D10EffectVariable_iface;
3515
3516     return (ID3D10EffectBlendVariable *)&null_blend_variable.ID3D10EffectVariable_iface;
3517 }
3518
3519 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsDepthStencil(
3520         ID3D10EffectVariable *iface)
3521 {
3522     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3523
3524     TRACE("iface %p\n", iface);
3525
3526     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl)
3527         return (ID3D10EffectDepthStencilVariable *)&This->ID3D10EffectVariable_iface;
3528
3529     return (ID3D10EffectDepthStencilVariable *)&null_depth_stencil_variable.ID3D10EffectVariable_iface;
3530 }
3531
3532 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsRasterizer(
3533         ID3D10EffectVariable *iface)
3534 {
3535     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3536
3537     TRACE("iface %p\n", iface);
3538
3539     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl)
3540         return (ID3D10EffectRasterizerVariable *)&This->ID3D10EffectVariable_iface;
3541
3542     return (ID3D10EffectRasterizerVariable *)&null_rasterizer_variable.ID3D10EffectVariable_iface;
3543 }
3544
3545 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsSampler(
3546         ID3D10EffectVariable *iface)
3547 {
3548     struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3549
3550     TRACE("iface %p\n", iface);
3551
3552     if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl)
3553         return (ID3D10EffectSamplerVariable *)&This->ID3D10EffectVariable_iface;
3554
3555     return (ID3D10EffectSamplerVariable *)&null_sampler_variable.ID3D10EffectVariable_iface;
3556 }
3557
3558 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_SetRawValue(ID3D10EffectVariable *iface,
3559         void *data, UINT offset, UINT count)
3560 {
3561     FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
3562
3563     return E_NOTIMPL;
3564 }
3565
3566 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetRawValue(ID3D10EffectVariable *iface,
3567         void *data, UINT offset, UINT count)
3568 {
3569     FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
3570
3571     return E_NOTIMPL;
3572 }
3573
3574 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl =
3575 {
3576     /* ID3D10EffectVariable methods */
3577     d3d10_effect_variable_IsValid,
3578     d3d10_effect_variable_GetType,
3579     d3d10_effect_variable_GetDesc,
3580     d3d10_effect_variable_GetAnnotationByIndex,
3581     d3d10_effect_variable_GetAnnotationByName,
3582     d3d10_effect_variable_GetMemberByIndex,
3583     d3d10_effect_variable_GetMemberByName,
3584     d3d10_effect_variable_GetMemberBySemantic,
3585     d3d10_effect_variable_GetElement,
3586     d3d10_effect_variable_GetParentConstantBuffer,
3587     d3d10_effect_variable_AsScalar,
3588     d3d10_effect_variable_AsVector,
3589     d3d10_effect_variable_AsMatrix,
3590     d3d10_effect_variable_AsString,
3591     d3d10_effect_variable_AsShaderResource,
3592     d3d10_effect_variable_AsRenderTargetView,
3593     d3d10_effect_variable_AsDepthStencilView,
3594     d3d10_effect_variable_AsConstantBuffer,
3595     d3d10_effect_variable_AsShader,
3596     d3d10_effect_variable_AsBlend,
3597     d3d10_effect_variable_AsDepthStencil,
3598     d3d10_effect_variable_AsRasterizer,
3599     d3d10_effect_variable_AsSampler,
3600     d3d10_effect_variable_SetRawValue,
3601     d3d10_effect_variable_GetRawValue,
3602 };
3603
3604 /* ID3D10EffectVariable methods */
3605 static BOOL STDMETHODCALLTYPE d3d10_effect_constant_buffer_IsValid(ID3D10EffectConstantBuffer *iface)
3606 {
3607     TRACE("iface %p\n", iface);
3608
3609     return (struct d3d10_effect_variable *)iface != &null_local_buffer;
3610 }
3611
3612 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetType(ID3D10EffectConstantBuffer *iface)
3613 {
3614     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
3615 }
3616
3617 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetDesc(ID3D10EffectConstantBuffer *iface,
3618         D3D10_EFFECT_VARIABLE_DESC *desc)
3619 {
3620     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
3621 }
3622
3623 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetAnnotationByIndex(
3624         ID3D10EffectConstantBuffer *iface, UINT index)
3625 {
3626     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
3627 }
3628
3629 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetAnnotationByName(
3630         ID3D10EffectConstantBuffer *iface, LPCSTR name)
3631 {
3632     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
3633 }
3634
3635 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberByIndex(
3636         ID3D10EffectConstantBuffer *iface, UINT index)
3637 {
3638     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
3639 }
3640
3641 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberByName(
3642         ID3D10EffectConstantBuffer *iface, LPCSTR name)
3643 {
3644     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
3645 }
3646
3647 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberBySemantic(
3648         ID3D10EffectConstantBuffer *iface, LPCSTR semantic)
3649 {
3650     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
3651 }
3652
3653 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetElement(
3654         ID3D10EffectConstantBuffer *iface, UINT index)
3655 {
3656     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
3657 }
3658
3659 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetParentConstantBuffer(
3660         ID3D10EffectConstantBuffer *iface)
3661 {
3662     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
3663 }
3664
3665 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsScalar(
3666         ID3D10EffectConstantBuffer *iface)
3667 {
3668     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
3669 }
3670
3671 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsVector(
3672         ID3D10EffectConstantBuffer *iface)
3673 {
3674     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
3675 }
3676
3677 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsMatrix(
3678         ID3D10EffectConstantBuffer *iface)
3679 {
3680     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
3681 }
3682
3683 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsString(
3684         ID3D10EffectConstantBuffer *iface)
3685 {
3686     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
3687 }
3688
3689 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsShaderResource(
3690         ID3D10EffectConstantBuffer *iface)
3691 {
3692     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
3693 }
3694
3695 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsRenderTargetView(
3696         ID3D10EffectConstantBuffer *iface)
3697 {
3698     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
3699 }
3700
3701 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsDepthStencilView(
3702         ID3D10EffectConstantBuffer *iface)
3703 {
3704     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
3705 }
3706
3707 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsConstantBuffer(
3708         ID3D10EffectConstantBuffer *iface)
3709 {
3710     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
3711 }
3712
3713 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsShader(
3714         ID3D10EffectConstantBuffer *iface)
3715 {
3716     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
3717 }
3718
3719 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsBlend(ID3D10EffectConstantBuffer *iface)
3720 {
3721     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
3722 }
3723
3724 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsDepthStencil(
3725         ID3D10EffectConstantBuffer *iface)
3726 {
3727     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
3728 }
3729
3730 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsRasterizer(
3731         ID3D10EffectConstantBuffer *iface)
3732 {
3733     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
3734 }
3735
3736 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsSampler(
3737         ID3D10EffectConstantBuffer *iface)
3738 {
3739     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
3740 }
3741
3742 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetRawValue(ID3D10EffectConstantBuffer *iface,
3743         void *data, UINT offset, UINT count)
3744 {
3745     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
3746 }
3747
3748 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetRawValue(ID3D10EffectConstantBuffer *iface,
3749         void *data, UINT offset, UINT count)
3750 {
3751     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
3752 }
3753
3754 /* ID3D10EffectConstantBuffer methods */
3755 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetConstantBuffer(ID3D10EffectConstantBuffer *iface,
3756         ID3D10Buffer *buffer)
3757 {
3758     FIXME("iface %p, buffer %p stub!\n", iface, buffer);
3759
3760     return E_NOTIMPL;
3761 }
3762
3763 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetConstantBuffer(ID3D10EffectConstantBuffer *iface,
3764         ID3D10Buffer **buffer)
3765 {
3766     FIXME("iface %p, buffer %p stub!\n", iface, buffer);
3767
3768     return E_NOTIMPL;
3769 }
3770
3771 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetTextureBuffer(ID3D10EffectConstantBuffer *iface,
3772         ID3D10ShaderResourceView *view)
3773 {
3774     FIXME("iface %p, view %p stub!\n", iface, view);
3775
3776     return E_NOTIMPL;
3777 }
3778
3779 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetTextureBuffer(ID3D10EffectConstantBuffer *iface,
3780         ID3D10ShaderResourceView **view)
3781 {
3782     FIXME("iface %p, view %p stub!\n", iface, view);
3783
3784     return E_NOTIMPL;
3785 }
3786
3787 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl =
3788 {
3789     /* ID3D10EffectVariable methods */
3790     d3d10_effect_constant_buffer_IsValid,
3791     d3d10_effect_constant_buffer_GetType,
3792     d3d10_effect_constant_buffer_GetDesc,
3793     d3d10_effect_constant_buffer_GetAnnotationByIndex,
3794     d3d10_effect_constant_buffer_GetAnnotationByName,
3795     d3d10_effect_constant_buffer_GetMemberByIndex,
3796     d3d10_effect_constant_buffer_GetMemberByName,
3797     d3d10_effect_constant_buffer_GetMemberBySemantic,
3798     d3d10_effect_constant_buffer_GetElement,
3799     d3d10_effect_constant_buffer_GetParentConstantBuffer,
3800     d3d10_effect_constant_buffer_AsScalar,
3801     d3d10_effect_constant_buffer_AsVector,
3802     d3d10_effect_constant_buffer_AsMatrix,
3803     d3d10_effect_constant_buffer_AsString,
3804     d3d10_effect_constant_buffer_AsShaderResource,
3805     d3d10_effect_constant_buffer_AsRenderTargetView,
3806     d3d10_effect_constant_buffer_AsDepthStencilView,
3807     d3d10_effect_constant_buffer_AsConstantBuffer,
3808     d3d10_effect_constant_buffer_AsShader,
3809     d3d10_effect_constant_buffer_AsBlend,
3810     d3d10_effect_constant_buffer_AsDepthStencil,
3811     d3d10_effect_constant_buffer_AsRasterizer,
3812     d3d10_effect_constant_buffer_AsSampler,
3813     d3d10_effect_constant_buffer_SetRawValue,
3814     d3d10_effect_constant_buffer_GetRawValue,
3815     /* ID3D10EffectConstantBuffer methods */
3816     d3d10_effect_constant_buffer_SetConstantBuffer,
3817     d3d10_effect_constant_buffer_GetConstantBuffer,
3818     d3d10_effect_constant_buffer_SetTextureBuffer,
3819     d3d10_effect_constant_buffer_GetTextureBuffer,
3820 };
3821
3822 /* ID3D10EffectVariable methods */
3823
3824 static BOOL STDMETHODCALLTYPE d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable *iface)
3825 {
3826     TRACE("iface %p\n", iface);
3827
3828     return (struct d3d10_effect_variable *)iface != &null_scalar_variable;
3829 }
3830
3831 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetType(
3832         ID3D10EffectScalarVariable *iface)
3833 {
3834     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
3835 }
3836
3837 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetDesc(ID3D10EffectScalarVariable *iface,
3838         D3D10_EFFECT_VARIABLE_DESC *desc)
3839 {
3840     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
3841 }
3842
3843 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetAnnotationByIndex(
3844         ID3D10EffectScalarVariable *iface, UINT index)
3845 {
3846     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
3847 }
3848
3849 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetAnnotationByName(
3850         ID3D10EffectScalarVariable *iface, LPCSTR name)
3851 {
3852     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
3853 }
3854
3855 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberByIndex(
3856         ID3D10EffectScalarVariable *iface, UINT index)
3857 {
3858     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
3859 }
3860
3861 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberByName(
3862         ID3D10EffectScalarVariable *iface, LPCSTR name)
3863 {
3864     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
3865 }
3866
3867 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberBySemantic(
3868         ID3D10EffectScalarVariable *iface, LPCSTR semantic)
3869 {
3870     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
3871 }
3872
3873 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetElement(
3874         ID3D10EffectScalarVariable *iface, UINT index)
3875 {
3876     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
3877 }
3878
3879 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetParentConstantBuffer(
3880         ID3D10EffectScalarVariable *iface)
3881 {
3882     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
3883 }
3884
3885 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsScalar(
3886         ID3D10EffectScalarVariable *iface)
3887 {
3888     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
3889 }
3890
3891 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsVector(
3892         ID3D10EffectScalarVariable *iface)
3893 {
3894     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
3895 }
3896
3897 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsMatrix(
3898         ID3D10EffectScalarVariable *iface)
3899 {
3900     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
3901 }
3902
3903 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsString(
3904         ID3D10EffectScalarVariable *iface)
3905 {
3906     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
3907 }
3908
3909 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsShaderResource(
3910         ID3D10EffectScalarVariable *iface)
3911 {
3912     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
3913 }
3914
3915 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsRenderTargetView(
3916         ID3D10EffectScalarVariable *iface)
3917 {
3918     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
3919 }
3920
3921 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsDepthStencilView(
3922         ID3D10EffectScalarVariable *iface)
3923 {
3924     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
3925 }
3926
3927 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsConstantBuffer(
3928         ID3D10EffectScalarVariable *iface)
3929 {
3930     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
3931 }
3932
3933 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsShader(
3934         ID3D10EffectScalarVariable *iface)
3935 {
3936     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
3937 }
3938
3939 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsBlend(
3940         ID3D10EffectScalarVariable *iface)
3941 {
3942     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
3943 }
3944
3945 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsDepthStencil(
3946         ID3D10EffectScalarVariable *iface)
3947 {
3948     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
3949 }
3950
3951 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsRasterizer(
3952         ID3D10EffectScalarVariable *iface)
3953 {
3954     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
3955 }
3956
3957 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsSampler(
3958         ID3D10EffectScalarVariable *iface)
3959 {
3960     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
3961 }
3962
3963 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetRawValue(ID3D10EffectScalarVariable *iface,
3964         void *data, UINT offset, UINT count)
3965 {
3966     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
3967 }
3968
3969 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetRawValue(ID3D10EffectScalarVariable *iface,
3970         void *data, UINT offset, UINT count)
3971 {
3972     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
3973 }
3974
3975 /* ID3D10EffectScalarVariable methods */
3976
3977 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloat(ID3D10EffectScalarVariable *iface,
3978         float value)
3979 {
3980     FIXME("iface %p, value %.8e stub!\n", iface, value);
3981
3982     return E_NOTIMPL;
3983 }
3984
3985 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable *iface,
3986         float *value)
3987 {
3988     FIXME("iface %p, value %p stub!\n", iface, value);
3989
3990     return E_NOTIMPL;
3991 }
3992
3993 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloatArray(ID3D10EffectScalarVariable *iface,
3994         float *values, UINT offset, UINT count)
3995 {
3996     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
3997
3998     return E_NOTIMPL;
3999 }
4000
4001 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable *iface,
4002         float *values, UINT offset, UINT count)
4003 {
4004     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4005
4006     return E_NOTIMPL;
4007 }
4008
4009 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable *iface,
4010         int value)
4011 {
4012     FIXME("iface %p, value %d stub!\n", iface, value);
4013
4014     return E_NOTIMPL;
4015 }
4016
4017 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetInt(ID3D10EffectScalarVariable *iface,
4018         int *value)
4019 {
4020     FIXME("iface %p, value %p stub!\n", iface, value);
4021
4022     return E_NOTIMPL;
4023 }
4024
4025 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable *iface,
4026         int *values, UINT offset, UINT count)
4027 {
4028     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4029
4030     return E_NOTIMPL;
4031 }
4032
4033 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable *iface,
4034         int *values, UINT offset, UINT count)
4035 {
4036     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4037
4038     return E_NOTIMPL;
4039 }
4040
4041 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable *iface,
4042         BOOL value)
4043 {
4044     FIXME("iface %p, value %d stub!\n", iface, value);
4045
4046     return E_NOTIMPL;
4047 }
4048
4049 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBool(ID3D10EffectScalarVariable *iface,
4050         BOOL *value)
4051 {
4052     FIXME("iface %p, value %p stub!\n", iface, value);
4053
4054     return E_NOTIMPL;
4055 }
4056
4057 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable *iface,
4058         BOOL *values, UINT offset, UINT count)
4059 {
4060     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4061
4062     return E_NOTIMPL;
4063 }
4064
4065 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable *iface,
4066         BOOL *values, UINT offset, UINT count)
4067 {
4068     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4069
4070     return E_NOTIMPL;
4071 }
4072
4073 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl =
4074 {
4075     /* ID3D10EffectVariable methods */
4076     d3d10_effect_scalar_variable_IsValid,
4077     d3d10_effect_scalar_variable_GetType,
4078     d3d10_effect_scalar_variable_GetDesc,
4079     d3d10_effect_scalar_variable_GetAnnotationByIndex,
4080     d3d10_effect_scalar_variable_GetAnnotationByName,
4081     d3d10_effect_scalar_variable_GetMemberByIndex,
4082     d3d10_effect_scalar_variable_GetMemberByName,
4083     d3d10_effect_scalar_variable_GetMemberBySemantic,
4084     d3d10_effect_scalar_variable_GetElement,
4085     d3d10_effect_scalar_variable_GetParentConstantBuffer,
4086     d3d10_effect_scalar_variable_AsScalar,
4087     d3d10_effect_scalar_variable_AsVector,
4088     d3d10_effect_scalar_variable_AsMatrix,
4089     d3d10_effect_scalar_variable_AsString,
4090     d3d10_effect_scalar_variable_AsShaderResource,
4091     d3d10_effect_scalar_variable_AsRenderTargetView,
4092     d3d10_effect_scalar_variable_AsDepthStencilView,
4093     d3d10_effect_scalar_variable_AsConstantBuffer,
4094     d3d10_effect_scalar_variable_AsShader,
4095     d3d10_effect_scalar_variable_AsBlend,
4096     d3d10_effect_scalar_variable_AsDepthStencil,
4097     d3d10_effect_scalar_variable_AsRasterizer,
4098     d3d10_effect_scalar_variable_AsSampler,
4099     d3d10_effect_scalar_variable_SetRawValue,
4100     d3d10_effect_scalar_variable_GetRawValue,
4101     /* ID3D10EffectScalarVariable methods */
4102     d3d10_effect_scalar_variable_SetFloat,
4103     d3d10_effect_scalar_variable_GetFloat,
4104     d3d10_effect_scalar_variable_SetFloatArray,
4105     d3d10_effect_scalar_variable_GetFloatArray,
4106     d3d10_effect_scalar_variable_SetInt,
4107     d3d10_effect_scalar_variable_GetInt,
4108     d3d10_effect_scalar_variable_SetIntArray,
4109     d3d10_effect_scalar_variable_GetIntArray,
4110     d3d10_effect_scalar_variable_SetBool,
4111     d3d10_effect_scalar_variable_GetBool,
4112     d3d10_effect_scalar_variable_SetBoolArray,
4113     d3d10_effect_scalar_variable_GetBoolArray,
4114 };
4115
4116 /* ID3D10EffectVariable methods */
4117
4118 static BOOL STDMETHODCALLTYPE d3d10_effect_vector_variable_IsValid(ID3D10EffectVectorVariable *iface)
4119 {
4120     TRACE("iface %p\n", iface);
4121
4122     return (struct d3d10_effect_variable *)iface != &null_vector_variable;
4123 }
4124
4125 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetType(
4126         ID3D10EffectVectorVariable *iface)
4127 {
4128     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
4129 }
4130
4131 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetDesc(ID3D10EffectVectorVariable *iface,
4132         D3D10_EFFECT_VARIABLE_DESC *desc)
4133 {
4134     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
4135 }
4136
4137 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetAnnotationByIndex(
4138         ID3D10EffectVectorVariable *iface, UINT index)
4139 {
4140     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
4141 }
4142
4143 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetAnnotationByName(
4144         ID3D10EffectVectorVariable *iface, LPCSTR name)
4145 {
4146     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
4147 }
4148
4149 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberByIndex(
4150         ID3D10EffectVectorVariable *iface, UINT index)
4151 {
4152     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
4153 }
4154
4155 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberByName(
4156         ID3D10EffectVectorVariable *iface, LPCSTR name)
4157 {
4158     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
4159 }
4160
4161 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberBySemantic(
4162         ID3D10EffectVectorVariable *iface, LPCSTR semantic)
4163 {
4164     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
4165 }
4166
4167 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetElement(
4168         ID3D10EffectVectorVariable *iface, UINT index)
4169 {
4170     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
4171 }
4172
4173 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetParentConstantBuffer(
4174         ID3D10EffectVectorVariable *iface)
4175 {
4176     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
4177 }
4178
4179 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsScalar(
4180         ID3D10EffectVectorVariable *iface)
4181 {
4182     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
4183 }
4184
4185 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsVector(
4186         ID3D10EffectVectorVariable *iface)
4187 {
4188     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
4189 }
4190
4191 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsMatrix(
4192         ID3D10EffectVectorVariable *iface)
4193 {
4194     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
4195 }
4196
4197 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsString(
4198         ID3D10EffectVectorVariable *iface)
4199 {
4200     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
4201 }
4202
4203 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsShaderResource(
4204         ID3D10EffectVectorVariable *iface)
4205 {
4206     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
4207 }
4208
4209 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsRenderTargetView(
4210         ID3D10EffectVectorVariable *iface)
4211 {
4212     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
4213 }
4214
4215 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsDepthStencilView(
4216         ID3D10EffectVectorVariable *iface)
4217 {
4218     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
4219 }
4220
4221 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsConstantBuffer(
4222         ID3D10EffectVectorVariable *iface)
4223 {
4224     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
4225 }
4226
4227 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsShader(
4228         ID3D10EffectVectorVariable *iface)
4229 {
4230     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
4231 }
4232
4233 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsBlend(
4234         ID3D10EffectVectorVariable *iface)
4235 {
4236     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
4237 }
4238
4239 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsDepthStencil(
4240         ID3D10EffectVectorVariable *iface)
4241 {
4242     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
4243 }
4244
4245 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsRasterizer(
4246         ID3D10EffectVectorVariable *iface)
4247 {
4248     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
4249 }
4250
4251 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsSampler(
4252         ID3D10EffectVectorVariable *iface)
4253 {
4254     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
4255 }
4256
4257 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetRawValue(ID3D10EffectVectorVariable *iface,
4258         void *data, UINT offset, UINT count)
4259 {
4260     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4261 }
4262
4263 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetRawValue(ID3D10EffectVectorVariable *iface,
4264         void *data, UINT offset, UINT count)
4265 {
4266     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4267 }
4268
4269 /* ID3D10EffectVectorVariable methods */
4270
4271 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVector(ID3D10EffectVectorVariable *iface,
4272         BOOL *value)
4273 {
4274     FIXME("iface %p, value %p stub!\n", iface, value);
4275
4276     return E_NOTIMPL;
4277 }
4278
4279 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVector(ID3D10EffectVectorVariable *iface,
4280         int *value)
4281 {
4282     FIXME("iface %p, value %p stub!\n", iface, value);
4283
4284     return E_NOTIMPL;
4285 }
4286
4287 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVector(ID3D10EffectVectorVariable *iface,
4288         float *value)
4289 {
4290     FIXME("iface %p, value %p stub!\n", iface, value);
4291
4292     return E_NOTIMPL;
4293 }
4294
4295 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable *iface,
4296         BOOL *value)
4297 {
4298     FIXME("iface %p, value %p stub!\n", iface, value);
4299
4300     return E_NOTIMPL;
4301 }
4302
4303 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVector(ID3D10EffectVectorVariable *iface,
4304         int *value)
4305 {
4306     FIXME("iface %p, value %p stub!\n", iface, value);
4307
4308     return E_NOTIMPL;
4309 }
4310
4311 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVector(ID3D10EffectVectorVariable *iface,
4312         float *value)
4313 {
4314     FIXME("iface %p, value %p stub!\n", iface, value);
4315
4316     return E_NOTIMPL;
4317 }
4318
4319 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable *iface,
4320         BOOL *values, UINT offset, UINT count)
4321 {
4322     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4323
4324     return E_NOTIMPL;
4325 }
4326
4327 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVectorArray(ID3D10EffectVectorVariable *iface,
4328         int *values, UINT offset, UINT count)
4329 {
4330     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4331
4332     return E_NOTIMPL;
4333 }
4334
4335 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVectorArray(ID3D10EffectVectorVariable *iface,
4336         float *values, UINT offset, UINT count)
4337 {
4338     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4339
4340     return E_NOTIMPL;
4341 }
4342
4343 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVectorArray(ID3D10EffectVectorVariable *iface,
4344         BOOL *values, UINT offset, UINT count)
4345 {
4346     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4347
4348     return E_NOTIMPL;
4349 }
4350
4351 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVectorArray(ID3D10EffectVectorVariable *iface,
4352         int *values, UINT offset, UINT count)
4353 {
4354     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4355
4356     return E_NOTIMPL;
4357 }
4358
4359 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVectorArray(ID3D10EffectVectorVariable *iface,
4360         float *values, UINT offset, UINT count)
4361 {
4362     FIXME("iface %p, values %p, offset %u, count %u stub!\n", iface, values, offset, count);
4363
4364     return E_NOTIMPL;
4365 }
4366
4367 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl =
4368 {
4369     /* ID3D10EffectVariable methods */
4370     d3d10_effect_vector_variable_IsValid,
4371     d3d10_effect_vector_variable_GetType,
4372     d3d10_effect_vector_variable_GetDesc,
4373     d3d10_effect_vector_variable_GetAnnotationByIndex,
4374     d3d10_effect_vector_variable_GetAnnotationByName,
4375     d3d10_effect_vector_variable_GetMemberByIndex,
4376     d3d10_effect_vector_variable_GetMemberByName,
4377     d3d10_effect_vector_variable_GetMemberBySemantic,
4378     d3d10_effect_vector_variable_GetElement,
4379     d3d10_effect_vector_variable_GetParentConstantBuffer,
4380     d3d10_effect_vector_variable_AsScalar,
4381     d3d10_effect_vector_variable_AsVector,
4382     d3d10_effect_vector_variable_AsMatrix,
4383     d3d10_effect_vector_variable_AsString,
4384     d3d10_effect_vector_variable_AsShaderResource,
4385     d3d10_effect_vector_variable_AsRenderTargetView,
4386     d3d10_effect_vector_variable_AsDepthStencilView,
4387     d3d10_effect_vector_variable_AsConstantBuffer,
4388     d3d10_effect_vector_variable_AsShader,
4389     d3d10_effect_vector_variable_AsBlend,
4390     d3d10_effect_vector_variable_AsDepthStencil,
4391     d3d10_effect_vector_variable_AsRasterizer,
4392     d3d10_effect_vector_variable_AsSampler,
4393     d3d10_effect_vector_variable_SetRawValue,
4394     d3d10_effect_vector_variable_GetRawValue,
4395     /* ID3D10EffectVectorVariable methods */
4396     d3d10_effect_vector_variable_SetBoolVector,
4397     d3d10_effect_vector_variable_SetIntVector,
4398     d3d10_effect_vector_variable_SetFloatVector,
4399     d3d10_effect_vector_variable_GetBoolVector,
4400     d3d10_effect_vector_variable_GetIntVector,
4401     d3d10_effect_vector_variable_GetFloatVector,
4402     d3d10_effect_vector_variable_SetBoolVectorArray,
4403     d3d10_effect_vector_variable_SetIntVectorArray,
4404     d3d10_effect_vector_variable_SetFloatVectorArray,
4405     d3d10_effect_vector_variable_GetBoolVectorArray,
4406     d3d10_effect_vector_variable_GetIntVectorArray,
4407     d3d10_effect_vector_variable_GetFloatVectorArray,
4408 };
4409
4410 /* ID3D10EffectVariable methods */
4411
4412 static BOOL STDMETHODCALLTYPE d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable *iface)
4413 {
4414     TRACE("iface %p\n", iface);
4415
4416     return (struct d3d10_effect_variable *)iface != &null_matrix_variable;
4417 }
4418
4419 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetType(
4420         ID3D10EffectMatrixVariable *iface)
4421 {
4422     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
4423 }
4424
4425 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetDesc(ID3D10EffectMatrixVariable *iface,
4426         D3D10_EFFECT_VARIABLE_DESC *desc)
4427 {
4428     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
4429 }
4430
4431 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetAnnotationByIndex(
4432         ID3D10EffectMatrixVariable *iface, UINT index)
4433 {
4434     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
4435 }
4436
4437 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetAnnotationByName(
4438         ID3D10EffectMatrixVariable *iface, LPCSTR name)
4439 {
4440     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
4441 }
4442
4443 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberByIndex(
4444         ID3D10EffectMatrixVariable *iface, UINT index)
4445 {
4446     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
4447 }
4448
4449 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberByName(
4450         ID3D10EffectMatrixVariable *iface, LPCSTR name)
4451 {
4452     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
4453 }
4454
4455 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberBySemantic(
4456         ID3D10EffectMatrixVariable *iface, LPCSTR semantic)
4457 {
4458     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
4459 }
4460
4461 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetElement(
4462         ID3D10EffectMatrixVariable *iface, UINT index)
4463 {
4464     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
4465 }
4466
4467 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetParentConstantBuffer(
4468         ID3D10EffectMatrixVariable *iface)
4469 {
4470     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
4471 }
4472
4473 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsScalar(
4474         ID3D10EffectMatrixVariable *iface)
4475 {
4476     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
4477 }
4478
4479 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsVector(
4480         ID3D10EffectMatrixVariable *iface)
4481 {
4482     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
4483 }
4484
4485 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsMatrix(
4486         ID3D10EffectMatrixVariable *iface)
4487 {
4488     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
4489 }
4490
4491 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsString(
4492         ID3D10EffectMatrixVariable *iface)
4493 {
4494     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
4495 }
4496
4497 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsShaderResource(
4498         ID3D10EffectMatrixVariable *iface)
4499 {
4500     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
4501 }
4502
4503 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsRenderTargetView(
4504         ID3D10EffectMatrixVariable *iface)
4505 {
4506     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
4507 }
4508
4509 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsDepthStencilView(
4510         ID3D10EffectMatrixVariable *iface)
4511 {
4512     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
4513 }
4514
4515 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsConstantBuffer(
4516         ID3D10EffectMatrixVariable *iface)
4517 {
4518     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
4519 }
4520
4521 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsShader(
4522         ID3D10EffectMatrixVariable *iface)
4523 {
4524     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
4525 }
4526
4527 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsBlend(
4528         ID3D10EffectMatrixVariable *iface)
4529 {
4530     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
4531 }
4532
4533 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsDepthStencil(
4534         ID3D10EffectMatrixVariable *iface)
4535 {
4536     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
4537 }
4538
4539 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsRasterizer(
4540         ID3D10EffectMatrixVariable *iface)
4541 {
4542     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
4543 }
4544
4545 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsSampler(
4546         ID3D10EffectMatrixVariable *iface)
4547 {
4548     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
4549 }
4550
4551 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetRawValue(ID3D10EffectMatrixVariable *iface,
4552         void *data, UINT offset, UINT count)
4553 {
4554     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4555 }
4556
4557 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetRawValue(ID3D10EffectMatrixVariable *iface,
4558         void *data, UINT offset, UINT count)
4559 {
4560     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4561 }
4562
4563 /* ID3D10EffectMatrixVariable methods */
4564
4565 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrix(ID3D10EffectMatrixVariable *iface,
4566         float *data)
4567 {
4568     FIXME("iface %p, data %p stub!\n", iface, data);
4569
4570     return E_NOTIMPL;
4571 }
4572
4573 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable *iface,
4574         float *data)
4575 {
4576     FIXME("iface %p, data %p stub!\n", iface, data);
4577
4578     return E_NOTIMPL;
4579 }
4580
4581 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable *iface,
4582         float *data, UINT offset, UINT count)
4583 {
4584     FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
4585
4586     return E_NOTIMPL;
4587 }
4588
4589 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable *iface,
4590         float *data, UINT offset, UINT count)
4591 {
4592     FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
4593
4594     return E_NOTIMPL;
4595 }
4596
4597 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
4598         float *data)
4599 {
4600     FIXME("iface %p, data %p stub!\n", iface, data);
4601
4602     return E_NOTIMPL;
4603 }
4604
4605 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
4606         float *data)
4607 {
4608     FIXME("iface %p, data %p stub!\n", iface, data);
4609
4610     return E_NOTIMPL;
4611 }
4612
4613 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
4614         float *data, UINT offset, UINT count)
4615 {
4616     FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
4617
4618     return E_NOTIMPL;
4619 }
4620
4621 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
4622         float *data, UINT offset, UINT count)
4623 {
4624     FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
4625
4626     return E_NOTIMPL;
4627 }
4628
4629
4630 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl =
4631 {
4632     /* ID3D10EffectVariable methods */
4633     d3d10_effect_matrix_variable_IsValid,
4634     d3d10_effect_matrix_variable_GetType,
4635     d3d10_effect_matrix_variable_GetDesc,
4636     d3d10_effect_matrix_variable_GetAnnotationByIndex,
4637     d3d10_effect_matrix_variable_GetAnnotationByName,
4638     d3d10_effect_matrix_variable_GetMemberByIndex,
4639     d3d10_effect_matrix_variable_GetMemberByName,
4640     d3d10_effect_matrix_variable_GetMemberBySemantic,
4641     d3d10_effect_matrix_variable_GetElement,
4642     d3d10_effect_matrix_variable_GetParentConstantBuffer,
4643     d3d10_effect_matrix_variable_AsScalar,
4644     d3d10_effect_matrix_variable_AsVector,
4645     d3d10_effect_matrix_variable_AsMatrix,
4646     d3d10_effect_matrix_variable_AsString,
4647     d3d10_effect_matrix_variable_AsShaderResource,
4648     d3d10_effect_matrix_variable_AsRenderTargetView,
4649     d3d10_effect_matrix_variable_AsDepthStencilView,
4650     d3d10_effect_matrix_variable_AsConstantBuffer,
4651     d3d10_effect_matrix_variable_AsShader,
4652     d3d10_effect_matrix_variable_AsBlend,
4653     d3d10_effect_matrix_variable_AsDepthStencil,
4654     d3d10_effect_matrix_variable_AsRasterizer,
4655     d3d10_effect_matrix_variable_AsSampler,
4656     d3d10_effect_matrix_variable_SetRawValue,
4657     d3d10_effect_matrix_variable_GetRawValue,
4658     /* ID3D10EffectMatrixVariable methods */
4659     d3d10_effect_matrix_variable_SetMatrix,
4660     d3d10_effect_matrix_variable_GetMatrix,
4661     d3d10_effect_matrix_variable_SetMatrixArray,
4662     d3d10_effect_matrix_variable_GetMatrixArray,
4663     d3d10_effect_matrix_variable_SetMatrixTranspose,
4664     d3d10_effect_matrix_variable_GetMatrixTranspose,
4665     d3d10_effect_matrix_variable_SetMatrixTransposeArray,
4666     d3d10_effect_matrix_variable_GetMatrixTransposeArray,
4667 };
4668
4669 /* ID3D10EffectVariable methods */
4670
4671 static BOOL STDMETHODCALLTYPE d3d10_effect_string_variable_IsValid(ID3D10EffectStringVariable *iface)
4672 {
4673     TRACE("iface %p\n", iface);
4674
4675     return (struct d3d10_effect_variable *)iface != &null_string_variable;
4676 }
4677
4678 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_string_variable_GetType(
4679         ID3D10EffectStringVariable *iface)
4680 {
4681     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
4682 }
4683
4684 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetDesc(ID3D10EffectStringVariable *iface,
4685         D3D10_EFFECT_VARIABLE_DESC *desc)
4686 {
4687     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
4688 }
4689
4690 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetAnnotationByIndex(
4691         ID3D10EffectStringVariable *iface, UINT index)
4692 {
4693     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
4694 }
4695
4696 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetAnnotationByName(
4697         ID3D10EffectStringVariable *iface, LPCSTR name)
4698 {
4699     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
4700 }
4701
4702 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberByIndex(
4703         ID3D10EffectStringVariable *iface, UINT index)
4704 {
4705     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
4706 }
4707
4708 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberByName(
4709         ID3D10EffectStringVariable *iface, LPCSTR name)
4710 {
4711     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
4712 }
4713
4714 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberBySemantic(
4715         ID3D10EffectStringVariable *iface, LPCSTR semantic)
4716 {
4717     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
4718 }
4719
4720 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetElement(
4721         ID3D10EffectStringVariable *iface, UINT index)
4722 {
4723     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
4724 }
4725
4726 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_string_variable_GetParentConstantBuffer(
4727         ID3D10EffectStringVariable *iface)
4728 {
4729     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
4730 }
4731
4732 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsScalar(
4733         ID3D10EffectStringVariable *iface)
4734 {
4735     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
4736 }
4737
4738 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsVector(
4739         ID3D10EffectStringVariable *iface)
4740 {
4741     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
4742 }
4743
4744 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsMatrix(
4745         ID3D10EffectStringVariable *iface)
4746 {
4747     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
4748 }
4749
4750 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsString(
4751         ID3D10EffectStringVariable *iface)
4752 {
4753     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
4754 }
4755
4756 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsShaderResource(
4757         ID3D10EffectStringVariable *iface)
4758 {
4759     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
4760 }
4761
4762 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsRenderTargetView(
4763         ID3D10EffectStringVariable *iface)
4764 {
4765     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
4766 }
4767
4768 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsDepthStencilView(
4769         ID3D10EffectStringVariable *iface)
4770 {
4771     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
4772 }
4773
4774 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_string_variable_AsConstantBuffer(
4775         ID3D10EffectStringVariable *iface)
4776 {
4777     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
4778 }
4779
4780 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsShader(
4781         ID3D10EffectStringVariable *iface)
4782 {
4783     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
4784 }
4785
4786 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsBlend(
4787         ID3D10EffectStringVariable *iface)
4788 {
4789     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
4790 }
4791
4792 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsDepthStencil(
4793         ID3D10EffectStringVariable *iface)
4794 {
4795     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
4796 }
4797
4798 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsRasterizer(
4799         ID3D10EffectStringVariable *iface)
4800 {
4801     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
4802 }
4803
4804 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsSampler(
4805         ID3D10EffectStringVariable *iface)
4806 {
4807     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
4808 }
4809
4810 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_SetRawValue(ID3D10EffectStringVariable *iface,
4811         void *data, UINT offset, UINT count)
4812 {
4813     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4814 }
4815
4816 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetRawValue(ID3D10EffectStringVariable *iface,
4817         void *data, UINT offset, UINT count)
4818 {
4819     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4820 }
4821
4822 /* ID3D10EffectStringVariable methods */
4823
4824 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetString(ID3D10EffectStringVariable *iface,
4825         LPCSTR *str)
4826 {
4827     FIXME("iface %p, str %p stub!\n", iface, str);
4828
4829     return E_NOTIMPL;
4830 }
4831
4832 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetStringArray(ID3D10EffectStringVariable *iface,
4833         LPCSTR *strs, UINT offset, UINT count)
4834 {
4835     FIXME("iface %p, strs %p, offset %u, count %u stub!\n", iface, strs, offset, count);
4836
4837     return E_NOTIMPL;
4838 }
4839
4840
4841 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl =
4842 {
4843     /* ID3D10EffectVariable methods */
4844     d3d10_effect_string_variable_IsValid,
4845     d3d10_effect_string_variable_GetType,
4846     d3d10_effect_string_variable_GetDesc,
4847     d3d10_effect_string_variable_GetAnnotationByIndex,
4848     d3d10_effect_string_variable_GetAnnotationByName,
4849     d3d10_effect_string_variable_GetMemberByIndex,
4850     d3d10_effect_string_variable_GetMemberByName,
4851     d3d10_effect_string_variable_GetMemberBySemantic,
4852     d3d10_effect_string_variable_GetElement,
4853     d3d10_effect_string_variable_GetParentConstantBuffer,
4854     d3d10_effect_string_variable_AsScalar,
4855     d3d10_effect_string_variable_AsVector,
4856     d3d10_effect_string_variable_AsMatrix,
4857     d3d10_effect_string_variable_AsString,
4858     d3d10_effect_string_variable_AsShaderResource,
4859     d3d10_effect_string_variable_AsRenderTargetView,
4860     d3d10_effect_string_variable_AsDepthStencilView,
4861     d3d10_effect_string_variable_AsConstantBuffer,
4862     d3d10_effect_string_variable_AsShader,
4863     d3d10_effect_string_variable_AsBlend,
4864     d3d10_effect_string_variable_AsDepthStencil,
4865     d3d10_effect_string_variable_AsRasterizer,
4866     d3d10_effect_string_variable_AsSampler,
4867     d3d10_effect_string_variable_SetRawValue,
4868     d3d10_effect_string_variable_GetRawValue,
4869     /* ID3D10EffectStringVariable methods */
4870     d3d10_effect_string_variable_GetString,
4871     d3d10_effect_string_variable_GetStringArray,
4872 };
4873
4874 /* ID3D10EffectVariable methods */
4875
4876 static BOOL STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_IsValid(ID3D10EffectShaderResourceVariable *iface)
4877 {
4878     TRACE("iface %p\n", iface);
4879
4880     return (struct d3d10_effect_variable *)iface != &null_shader_resource_variable;
4881 }
4882
4883 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetType(
4884         ID3D10EffectShaderResourceVariable *iface)
4885 {
4886     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
4887 }
4888
4889 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetDesc(
4890         ID3D10EffectShaderResourceVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
4891 {
4892     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
4893 }
4894
4895 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetAnnotationByIndex(
4896         ID3D10EffectShaderResourceVariable *iface, UINT index)
4897 {
4898     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
4899 }
4900
4901 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetAnnotationByName(
4902         ID3D10EffectShaderResourceVariable *iface, LPCSTR name)
4903 {
4904     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
4905 }
4906
4907 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberByIndex(
4908         ID3D10EffectShaderResourceVariable *iface, UINT index)
4909 {
4910     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
4911 }
4912
4913 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberByName(
4914         ID3D10EffectShaderResourceVariable *iface, LPCSTR name)
4915 {
4916     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
4917 }
4918
4919 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberBySemantic(
4920         ID3D10EffectShaderResourceVariable *iface, LPCSTR semantic)
4921 {
4922     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
4923 }
4924
4925 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetElement(
4926         ID3D10EffectShaderResourceVariable *iface, UINT index)
4927 {
4928     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
4929 }
4930
4931 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetParentConstantBuffer(
4932         ID3D10EffectShaderResourceVariable *iface)
4933 {
4934     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
4935 }
4936
4937 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsScalar(
4938         ID3D10EffectShaderResourceVariable *iface)
4939 {
4940     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
4941 }
4942
4943 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsVector(
4944         ID3D10EffectShaderResourceVariable *iface)
4945 {
4946     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
4947 }
4948
4949 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsMatrix(
4950         ID3D10EffectShaderResourceVariable *iface)
4951 {
4952     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
4953 }
4954
4955 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsString(
4956         ID3D10EffectShaderResourceVariable *iface)
4957 {
4958     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
4959 }
4960
4961 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsShaderResource(
4962         ID3D10EffectShaderResourceVariable *iface)
4963 {
4964     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
4965 }
4966
4967 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsRenderTargetView(
4968         ID3D10EffectShaderResourceVariable *iface)
4969 {
4970     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
4971 }
4972
4973 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsDepthStencilView(
4974         ID3D10EffectShaderResourceVariable *iface)
4975 {
4976     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
4977 }
4978
4979 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsConstantBuffer(
4980         ID3D10EffectShaderResourceVariable *iface)
4981 {
4982     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
4983 }
4984
4985 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsShader(
4986         ID3D10EffectShaderResourceVariable *iface)
4987 {
4988     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
4989 }
4990
4991 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsBlend(
4992         ID3D10EffectShaderResourceVariable *iface)
4993 {
4994     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
4995 }
4996
4997 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsDepthStencil(
4998         ID3D10EffectShaderResourceVariable *iface)
4999 {
5000     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5001 }
5002
5003 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsRasterizer(
5004         ID3D10EffectShaderResourceVariable *iface)
5005 {
5006     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5007 }
5008
5009 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsSampler(
5010         ID3D10EffectShaderResourceVariable *iface)
5011 {
5012     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5013 }
5014
5015 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetRawValue(
5016         ID3D10EffectShaderResourceVariable *iface, void *data, UINT offset, UINT count)
5017 {
5018     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5019 }
5020
5021 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetRawValue(
5022         ID3D10EffectShaderResourceVariable *iface, void *data, UINT offset, UINT count)
5023 {
5024     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5025 }
5026
5027 /* ID3D10EffectShaderResourceVariable methods */
5028
5029 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResource(
5030         ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView *resource)
5031 {
5032     FIXME("iface %p, resource %p stub!\n", iface, resource);
5033
5034     return E_NOTIMPL;
5035 }
5036
5037 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResource(
5038         ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resource)
5039 {
5040     FIXME("iface %p, resource %p stub!\n", iface, resource);
5041
5042     return E_NOTIMPL;
5043 }
5044
5045 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResourceArray(
5046         ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resources, UINT offset, UINT count)
5047 {
5048     FIXME("iface %p, resources %p, offset %u, count %u stub!\n", iface, resources, offset, count);
5049
5050     return E_NOTIMPL;
5051 }
5052
5053 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResourceArray(
5054         ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resources, UINT offset, UINT count)
5055 {
5056     FIXME("iface %p, resources %p, offset %u, count %u stub!\n", iface, resources, offset, count);
5057
5058     return E_NOTIMPL;
5059 }
5060
5061
5062 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl =
5063 {
5064     /* ID3D10EffectVariable methods */
5065     d3d10_effect_shader_resource_variable_IsValid,
5066     d3d10_effect_shader_resource_variable_GetType,
5067     d3d10_effect_shader_resource_variable_GetDesc,
5068     d3d10_effect_shader_resource_variable_GetAnnotationByIndex,
5069     d3d10_effect_shader_resource_variable_GetAnnotationByName,
5070     d3d10_effect_shader_resource_variable_GetMemberByIndex,
5071     d3d10_effect_shader_resource_variable_GetMemberByName,
5072     d3d10_effect_shader_resource_variable_GetMemberBySemantic,
5073     d3d10_effect_shader_resource_variable_GetElement,
5074     d3d10_effect_shader_resource_variable_GetParentConstantBuffer,
5075     d3d10_effect_shader_resource_variable_AsScalar,
5076     d3d10_effect_shader_resource_variable_AsVector,
5077     d3d10_effect_shader_resource_variable_AsMatrix,
5078     d3d10_effect_shader_resource_variable_AsString,
5079     d3d10_effect_shader_resource_variable_AsShaderResource,
5080     d3d10_effect_shader_resource_variable_AsRenderTargetView,
5081     d3d10_effect_shader_resource_variable_AsDepthStencilView,
5082     d3d10_effect_shader_resource_variable_AsConstantBuffer,
5083     d3d10_effect_shader_resource_variable_AsShader,
5084     d3d10_effect_shader_resource_variable_AsBlend,
5085     d3d10_effect_shader_resource_variable_AsDepthStencil,
5086     d3d10_effect_shader_resource_variable_AsRasterizer,
5087     d3d10_effect_shader_resource_variable_AsSampler,
5088     d3d10_effect_shader_resource_variable_SetRawValue,
5089     d3d10_effect_shader_resource_variable_GetRawValue,
5090     /* ID3D10EffectShaderResourceVariable methods */
5091     d3d10_effect_shader_resource_variable_SetResource,
5092     d3d10_effect_shader_resource_variable_GetResource,
5093     d3d10_effect_shader_resource_variable_SetResourceArray,
5094     d3d10_effect_shader_resource_variable_GetResourceArray,
5095 };
5096
5097 /* ID3D10EffectVariable methods */
5098
5099 static BOOL STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_IsValid(
5100         ID3D10EffectRenderTargetViewVariable *iface)
5101 {
5102     TRACE("iface %p\n", iface);
5103
5104     return (struct d3d10_effect_variable *)iface != &null_render_target_view_variable;
5105 }
5106
5107 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetType(
5108         ID3D10EffectRenderTargetViewVariable *iface)
5109 {
5110     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5111 }
5112
5113 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetDesc(
5114         ID3D10EffectRenderTargetViewVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
5115 {
5116     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5117 }
5118
5119 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetAnnotationByIndex(
5120         ID3D10EffectRenderTargetViewVariable *iface, UINT index)
5121 {
5122     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5123 }
5124
5125 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetAnnotationByName(
5126         ID3D10EffectRenderTargetViewVariable *iface, LPCSTR name)
5127 {
5128     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5129 }
5130
5131 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberByIndex(
5132         ID3D10EffectRenderTargetViewVariable *iface, UINT index)
5133 {
5134     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5135 }
5136
5137 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberByName(
5138         ID3D10EffectRenderTargetViewVariable *iface, LPCSTR name)
5139 {
5140     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5141 }
5142
5143 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberBySemantic(
5144         ID3D10EffectRenderTargetViewVariable *iface, LPCSTR semantic)
5145 {
5146     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5147 }
5148
5149 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetElement(
5150         ID3D10EffectRenderTargetViewVariable *iface, UINT index)
5151 {
5152     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5153 }
5154
5155 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetParentConstantBuffer(
5156         ID3D10EffectRenderTargetViewVariable *iface)
5157 {
5158     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5159 }
5160
5161 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsScalar(
5162         ID3D10EffectRenderTargetViewVariable *iface)
5163 {
5164     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5165 }
5166
5167 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsVector(
5168         ID3D10EffectRenderTargetViewVariable *iface)
5169 {
5170     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5171 }
5172
5173 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsMatrix(
5174         ID3D10EffectRenderTargetViewVariable *iface)
5175 {
5176     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5177 }
5178
5179 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsString(
5180         ID3D10EffectRenderTargetViewVariable *iface)
5181 {
5182     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5183 }
5184
5185 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsShaderResource(
5186         ID3D10EffectRenderTargetViewVariable *iface)
5187 {
5188     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5189 }
5190
5191 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsRenderTargetView(
5192         ID3D10EffectRenderTargetViewVariable *iface)
5193 {
5194     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5195 }
5196
5197 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsDepthStencilView(
5198         ID3D10EffectRenderTargetViewVariable *iface)
5199 {
5200     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5201 }
5202
5203 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsConstantBuffer(
5204         ID3D10EffectRenderTargetViewVariable *iface)
5205 {
5206     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5207 }
5208
5209 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsShader(
5210         ID3D10EffectRenderTargetViewVariable *iface)
5211 {
5212     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5213 }
5214
5215 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsBlend(
5216         ID3D10EffectRenderTargetViewVariable *iface)
5217 {
5218     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5219 }
5220
5221 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsDepthStencil(
5222         ID3D10EffectRenderTargetViewVariable *iface)
5223 {
5224     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5225 }
5226
5227 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsRasterizer(
5228         ID3D10EffectRenderTargetViewVariable *iface)
5229 {
5230     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5231 }
5232
5233 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsSampler(
5234         ID3D10EffectRenderTargetViewVariable *iface)
5235 {
5236     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5237 }
5238
5239 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRawValue(
5240         ID3D10EffectRenderTargetViewVariable *iface, void *data, UINT offset, UINT count)
5241 {
5242     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5243 }
5244
5245 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRawValue(
5246         ID3D10EffectRenderTargetViewVariable *iface, void *data, UINT offset, UINT count)
5247 {
5248     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5249 }
5250
5251 /* ID3D10EffectRenderTargetViewVariable methods */
5252
5253 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRenderTarget(
5254         ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView *view)
5255 {
5256     FIXME("iface %p, view %p stub!\n", iface, view);
5257
5258     return E_NOTIMPL;
5259 }
5260
5261 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRenderTarget(
5262         ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **view)
5263 {
5264     FIXME("iface %p, view %p stub!\n", iface, view);
5265
5266     return E_NOTIMPL;
5267 }
5268
5269 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRenderTargetArray(
5270         ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **views, UINT offset, UINT count)
5271 {
5272     FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
5273
5274     return E_NOTIMPL;
5275 }
5276
5277 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRenderTargetArray(
5278         ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **views, UINT offset, UINT count)
5279 {
5280     FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
5281
5282     return E_NOTIMPL;
5283 }
5284
5285
5286 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl =
5287 {
5288     /* ID3D10EffectVariable methods */
5289     d3d10_effect_render_target_view_variable_IsValid,
5290     d3d10_effect_render_target_view_variable_GetType,
5291     d3d10_effect_render_target_view_variable_GetDesc,
5292     d3d10_effect_render_target_view_variable_GetAnnotationByIndex,
5293     d3d10_effect_render_target_view_variable_GetAnnotationByName,
5294     d3d10_effect_render_target_view_variable_GetMemberByIndex,
5295     d3d10_effect_render_target_view_variable_GetMemberByName,
5296     d3d10_effect_render_target_view_variable_GetMemberBySemantic,
5297     d3d10_effect_render_target_view_variable_GetElement,
5298     d3d10_effect_render_target_view_variable_GetParentConstantBuffer,
5299     d3d10_effect_render_target_view_variable_AsScalar,
5300     d3d10_effect_render_target_view_variable_AsVector,
5301     d3d10_effect_render_target_view_variable_AsMatrix,
5302     d3d10_effect_render_target_view_variable_AsString,
5303     d3d10_effect_render_target_view_variable_AsShaderResource,
5304     d3d10_effect_render_target_view_variable_AsRenderTargetView,
5305     d3d10_effect_render_target_view_variable_AsDepthStencilView,
5306     d3d10_effect_render_target_view_variable_AsConstantBuffer,
5307     d3d10_effect_render_target_view_variable_AsShader,
5308     d3d10_effect_render_target_view_variable_AsBlend,
5309     d3d10_effect_render_target_view_variable_AsDepthStencil,
5310     d3d10_effect_render_target_view_variable_AsRasterizer,
5311     d3d10_effect_render_target_view_variable_AsSampler,
5312     d3d10_effect_render_target_view_variable_SetRawValue,
5313     d3d10_effect_render_target_view_variable_GetRawValue,
5314     /* ID3D10EffectRenderTargetViewVariable methods */
5315     d3d10_effect_render_target_view_variable_SetRenderTarget,
5316     d3d10_effect_render_target_view_variable_GetRenderTarget,
5317     d3d10_effect_render_target_view_variable_SetRenderTargetArray,
5318     d3d10_effect_render_target_view_variable_GetRenderTargetArray,
5319 };
5320
5321 /* ID3D10EffectVariable methods */
5322
5323 static BOOL STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_IsValid(
5324         ID3D10EffectDepthStencilViewVariable *iface)
5325 {
5326     TRACE("iface %p\n", iface);
5327
5328     return (struct d3d10_effect_variable *)iface != &null_depth_stencil_view_variable;
5329 }
5330
5331 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetType(
5332         ID3D10EffectDepthStencilViewVariable *iface)
5333 {
5334     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5335 }
5336
5337 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDesc(
5338         ID3D10EffectDepthStencilViewVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
5339 {
5340     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5341 }
5342
5343 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex(
5344         ID3D10EffectDepthStencilViewVariable *iface, UINT index)
5345 {
5346     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5347 }
5348
5349 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetAnnotationByName(
5350         ID3D10EffectDepthStencilViewVariable *iface, LPCSTR name)
5351 {
5352     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5353 }
5354
5355 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberByIndex(
5356         ID3D10EffectDepthStencilViewVariable *iface, UINT index)
5357 {
5358     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5359 }
5360
5361 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberByName(
5362         ID3D10EffectDepthStencilViewVariable *iface, LPCSTR name)
5363 {
5364     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5365 }
5366
5367 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic(
5368         ID3D10EffectDepthStencilViewVariable *iface, LPCSTR semantic)
5369 {
5370     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5371 }
5372
5373 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetElement(
5374         ID3D10EffectDepthStencilViewVariable *iface, UINT index)
5375 {
5376     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5377 }
5378
5379 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer(
5380         ID3D10EffectDepthStencilViewVariable *iface)
5381 {
5382     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5383 }
5384
5385 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsScalar(
5386         ID3D10EffectDepthStencilViewVariable *iface)
5387 {
5388     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5389 }
5390
5391 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsVector(
5392         ID3D10EffectDepthStencilViewVariable *iface)
5393 {
5394     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5395 }
5396
5397 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsMatrix(
5398         ID3D10EffectDepthStencilViewVariable *iface)
5399 {
5400     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5401 }
5402
5403 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsString(
5404         ID3D10EffectDepthStencilViewVariable *iface)
5405 {
5406     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5407 }
5408
5409 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsShaderResource(
5410         ID3D10EffectDepthStencilViewVariable *iface)
5411 {
5412     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5413 }
5414
5415 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsRenderTargetView(
5416         ID3D10EffectDepthStencilViewVariable *iface)
5417 {
5418     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5419 }
5420
5421 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsDepthStencilView(
5422         ID3D10EffectDepthStencilViewVariable *iface)
5423 {
5424     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5425 }
5426
5427 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsConstantBuffer(
5428         ID3D10EffectDepthStencilViewVariable *iface)
5429 {
5430     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5431 }
5432
5433 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsShader(
5434         ID3D10EffectDepthStencilViewVariable *iface)
5435 {
5436     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5437 }
5438
5439 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsBlend(
5440         ID3D10EffectDepthStencilViewVariable *iface)
5441 {
5442     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5443 }
5444
5445 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsDepthStencil(
5446         ID3D10EffectDepthStencilViewVariable *iface)
5447 {
5448     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5449 }
5450
5451 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsRasterizer(
5452         ID3D10EffectDepthStencilViewVariable *iface)
5453 {
5454     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5455 }
5456
5457 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsSampler(
5458         ID3D10EffectDepthStencilViewVariable *iface)
5459 {
5460     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5461 }
5462
5463 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetRawValue(
5464         ID3D10EffectDepthStencilViewVariable *iface, void *data, UINT offset, UINT count)
5465 {
5466     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5467 }
5468
5469 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetRawValue(
5470         ID3D10EffectDepthStencilViewVariable *iface, void *data, UINT offset, UINT count)
5471 {
5472     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5473 }
5474
5475 /* ID3D10EffectDepthStencilViewVariable methods */
5476
5477 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetDepthStencil(
5478         ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView *view)
5479 {
5480     FIXME("iface %p, view %p stub!\n", iface, view);
5481
5482     return E_NOTIMPL;
5483 }
5484
5485 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDepthStencil(
5486         ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **view)
5487 {
5488     FIXME("iface %p, view %p stub!\n", iface, view);
5489
5490     return E_NOTIMPL;
5491 }
5492
5493 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray(
5494         ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **views, UINT offset, UINT count)
5495 {
5496     FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
5497
5498     return E_NOTIMPL;
5499 }
5500
5501 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray(
5502         ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **views, UINT offset, UINT count)
5503 {
5504     FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
5505
5506     return E_NOTIMPL;
5507 }
5508
5509
5510 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl =
5511 {
5512     /* ID3D10EffectVariable methods */
5513     d3d10_effect_depth_stencil_view_variable_IsValid,
5514     d3d10_effect_depth_stencil_view_variable_GetType,
5515     d3d10_effect_depth_stencil_view_variable_GetDesc,
5516     d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex,
5517     d3d10_effect_depth_stencil_view_variable_GetAnnotationByName,
5518     d3d10_effect_depth_stencil_view_variable_GetMemberByIndex,
5519     d3d10_effect_depth_stencil_view_variable_GetMemberByName,
5520     d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic,
5521     d3d10_effect_depth_stencil_view_variable_GetElement,
5522     d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer,
5523     d3d10_effect_depth_stencil_view_variable_AsScalar,
5524     d3d10_effect_depth_stencil_view_variable_AsVector,
5525     d3d10_effect_depth_stencil_view_variable_AsMatrix,
5526     d3d10_effect_depth_stencil_view_variable_AsString,
5527     d3d10_effect_depth_stencil_view_variable_AsShaderResource,
5528     d3d10_effect_depth_stencil_view_variable_AsRenderTargetView,
5529     d3d10_effect_depth_stencil_view_variable_AsDepthStencilView,
5530     d3d10_effect_depth_stencil_view_variable_AsConstantBuffer,
5531     d3d10_effect_depth_stencil_view_variable_AsShader,
5532     d3d10_effect_depth_stencil_view_variable_AsBlend,
5533     d3d10_effect_depth_stencil_view_variable_AsDepthStencil,
5534     d3d10_effect_depth_stencil_view_variable_AsRasterizer,
5535     d3d10_effect_depth_stencil_view_variable_AsSampler,
5536     d3d10_effect_depth_stencil_view_variable_SetRawValue,
5537     d3d10_effect_depth_stencil_view_variable_GetRawValue,
5538     /* ID3D10EffectDepthStencilViewVariable methods */
5539     d3d10_effect_depth_stencil_view_variable_SetDepthStencil,
5540     d3d10_effect_depth_stencil_view_variable_GetDepthStencil,
5541     d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray,
5542     d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray,
5543 };
5544
5545 /* ID3D10EffectVariable methods */
5546
5547 static BOOL STDMETHODCALLTYPE d3d10_effect_shader_variable_IsValid(ID3D10EffectShaderVariable *iface)
5548 {
5549     TRACE("iface %p\n", iface);
5550
5551     return (struct d3d10_effect_variable *)iface != &null_shader_variable;
5552 }
5553
5554 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetType(
5555         ID3D10EffectShaderVariable *iface)
5556 {
5557     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5558 }
5559
5560 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetDesc(ID3D10EffectShaderVariable *iface,
5561         D3D10_EFFECT_VARIABLE_DESC *desc)
5562 {
5563     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5564 }
5565
5566 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetAnnotationByIndex(
5567         ID3D10EffectShaderVariable *iface, UINT index)
5568 {
5569     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5570 }
5571
5572 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetAnnotationByName(
5573         ID3D10EffectShaderVariable *iface, LPCSTR name)
5574 {
5575     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5576 }
5577
5578 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberByIndex(
5579         ID3D10EffectShaderVariable *iface, UINT index)
5580 {
5581     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5582 }
5583
5584 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberByName(
5585         ID3D10EffectShaderVariable *iface, LPCSTR name)
5586 {
5587     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5588 }
5589
5590 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberBySemantic(
5591         ID3D10EffectShaderVariable *iface, LPCSTR semantic)
5592 {
5593     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5594 }
5595
5596 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetElement(
5597         ID3D10EffectShaderVariable *iface, UINT index)
5598 {
5599     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5600 }
5601
5602 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetParentConstantBuffer(
5603         ID3D10EffectShaderVariable *iface)
5604 {
5605     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5606 }
5607
5608 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsScalar(
5609         ID3D10EffectShaderVariable *iface)
5610 {
5611     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5612 }
5613
5614 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsVector(
5615         ID3D10EffectShaderVariable *iface)
5616 {
5617     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5618 }
5619
5620 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsMatrix(
5621         ID3D10EffectShaderVariable *iface)
5622 {
5623     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5624 }
5625
5626 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsString(
5627         ID3D10EffectShaderVariable *iface)
5628 {
5629     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5630 }
5631
5632 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsShaderResource(
5633         ID3D10EffectShaderVariable *iface)
5634 {
5635     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5636 }
5637
5638 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsRenderTargetView(
5639         ID3D10EffectShaderVariable *iface)
5640 {
5641     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5642 }
5643
5644 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsDepthStencilView(
5645         ID3D10EffectShaderVariable *iface)
5646 {
5647     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5648 }
5649
5650 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsConstantBuffer(
5651         ID3D10EffectShaderVariable *iface)
5652 {
5653     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5654 }
5655
5656 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsShader(
5657         ID3D10EffectShaderVariable *iface)
5658 {
5659     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5660 }
5661
5662 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsBlend(
5663         ID3D10EffectShaderVariable *iface)
5664 {
5665     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5666 }
5667
5668 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsDepthStencil(
5669         ID3D10EffectShaderVariable *iface)
5670 {
5671     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5672 }
5673
5674 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsRasterizer(
5675         ID3D10EffectShaderVariable *iface)
5676 {
5677     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5678 }
5679
5680 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsSampler(
5681         ID3D10EffectShaderVariable *iface)
5682 {
5683     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5684 }
5685
5686 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_SetRawValue(
5687         ID3D10EffectShaderVariable *iface, void *data, UINT offset, UINT count)
5688 {
5689     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5690 }
5691
5692 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetRawValue(
5693         ID3D10EffectShaderVariable *iface, void *data, UINT offset, UINT count)
5694 {
5695     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5696 }
5697
5698 /* ID3D10EffectShaderVariable methods */
5699
5700 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetShaderDesc(
5701         ID3D10EffectShaderVariable *iface, UINT index, D3D10_EFFECT_SHADER_DESC *desc)
5702 {
5703     FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc);
5704
5705     return E_NOTIMPL;
5706 }
5707
5708 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetVertexShader(
5709         ID3D10EffectShaderVariable *iface, UINT index, ID3D10VertexShader **shader)
5710 {
5711     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
5712
5713     TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
5714
5715     if (v->type->element_count)
5716         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
5717
5718     if (v->type->basetype != D3D10_SVT_VERTEXSHADER)
5719     {
5720         WARN("Shader is not a vertex shader.\n");
5721         return E_FAIL;
5722     }
5723
5724     if ((*shader = v->u.shader.shader.vs))
5725         ID3D10VertexShader_AddRef(*shader);
5726
5727     return S_OK;
5728 }
5729
5730 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetGeometryShader(
5731         ID3D10EffectShaderVariable *iface, UINT index, ID3D10GeometryShader **shader)
5732 {
5733     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
5734
5735     TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
5736
5737     if (v->type->element_count)
5738         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
5739
5740     if (v->type->basetype != D3D10_SVT_GEOMETRYSHADER)
5741     {
5742         WARN("Shader is not a geometry shader.\n");
5743         return E_FAIL;
5744     }
5745
5746     if ((*shader = v->u.shader.shader.gs))
5747         ID3D10GeometryShader_AddRef(*shader);
5748
5749     return S_OK;
5750 }
5751
5752 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetPixelShader(
5753         ID3D10EffectShaderVariable *iface, UINT index, ID3D10PixelShader **shader)
5754 {
5755     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
5756
5757     TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
5758
5759     if (v->type->element_count)
5760         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
5761
5762     if (v->type->basetype != D3D10_SVT_PIXELSHADER)
5763     {
5764         WARN("Shader is not a pixel shader.\n");
5765         return E_FAIL;
5766     }
5767
5768     if ((*shader = v->u.shader.shader.ps))
5769         ID3D10PixelShader_AddRef(*shader);
5770
5771     return S_OK;
5772 }
5773
5774 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetInputSignatureElementDesc(
5775         ID3D10EffectShaderVariable *iface, UINT shader_index, UINT element_index,
5776         D3D10_SIGNATURE_PARAMETER_DESC *desc)
5777 {
5778     struct d3d10_effect_variable *This = (struct d3d10_effect_variable *)iface;
5779     struct d3d10_effect_shader_variable *s;
5780     D3D10_SIGNATURE_PARAMETER_DESC *d;
5781
5782     TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
5783             iface, shader_index, element_index, desc);
5784
5785     if (!iface->lpVtbl->IsValid(iface))
5786     {
5787         WARN("Null variable specified\n");
5788         return E_FAIL;
5789     }
5790
5791     /* Check shader_index, this crashes on W7/DX10 */
5792     if (shader_index >= This->effect->used_shader_count)
5793     {
5794         WARN("This should crash on W7/DX10!\n");
5795         return E_FAIL;
5796     }
5797
5798     s = &This->effect->used_shaders[shader_index]->u.shader;
5799     if (!s->input_signature.signature)
5800     {
5801         WARN("No shader signature\n");
5802         return D3DERR_INVALIDCALL;
5803     }
5804
5805     /* Check desc for NULL, this crashes on W7/DX10 */
5806     if (!desc)
5807     {
5808         WARN("This should crash on W7/DX10!\n");
5809         return E_FAIL;
5810     }
5811
5812     if (element_index >= s->input_signature.element_count)
5813     {
5814         WARN("Invalid element index specified\n");
5815         return E_INVALIDARG;
5816     }
5817
5818     d = &s->input_signature.elements[element_index];
5819     desc->SemanticName = d->SemanticName;
5820     desc->SemanticIndex  =  d->SemanticIndex;
5821     desc->SystemValueType =  d->SystemValueType;
5822     desc->ComponentType =  d->ComponentType;
5823     desc->Register =  d->Register;
5824     desc->ReadWriteMask  =  d->ReadWriteMask;
5825     desc->Mask =  d->Mask;
5826
5827     return S_OK;
5828 }
5829
5830 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetOutputSignatureElementDesc(
5831         ID3D10EffectShaderVariable *iface, UINT shader_index, UINT element_index,
5832         D3D10_SIGNATURE_PARAMETER_DESC *desc)
5833 {
5834     struct d3d10_effect_variable *This = (struct d3d10_effect_variable *)iface;
5835     struct d3d10_effect_shader_variable *s;
5836     D3D10_SIGNATURE_PARAMETER_DESC *d;
5837
5838     TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
5839             iface, shader_index, element_index, desc);
5840
5841     if (!iface->lpVtbl->IsValid(iface))
5842     {
5843         WARN("Null variable specified\n");
5844         return E_FAIL;
5845     }
5846
5847     /* Check shader_index, this crashes on W7/DX10 */
5848     if (shader_index >= This->effect->used_shader_count)
5849     {
5850         WARN("This should crash on W7/DX10!\n");
5851         return E_FAIL;
5852     }
5853
5854     s = &This->effect->used_shaders[shader_index]->u.shader;
5855     if (!s->output_signature.signature)
5856     {
5857         WARN("No shader signature\n");
5858         return D3DERR_INVALIDCALL;
5859     }
5860
5861     /* Check desc for NULL, this crashes on W7/DX10 */
5862     if (!desc)
5863     {
5864         WARN("This should crash on W7/DX10!\n");
5865         return E_FAIL;
5866     }
5867
5868     if (element_index >= s->output_signature.element_count)
5869     {
5870         WARN("Invalid element index specified\n");
5871         return E_INVALIDARG;
5872     }
5873
5874     d = &s->output_signature.elements[element_index];
5875     desc->SemanticName = d->SemanticName;
5876     desc->SemanticIndex  =  d->SemanticIndex;
5877     desc->SystemValueType =  d->SystemValueType;
5878     desc->ComponentType =  d->ComponentType;
5879     desc->Register =  d->Register;
5880     desc->ReadWriteMask  =  d->ReadWriteMask;
5881     desc->Mask =  d->Mask;
5882
5883     return S_OK;
5884 }
5885
5886
5887 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl =
5888 {
5889     /* ID3D10EffectVariable methods */
5890     d3d10_effect_shader_variable_IsValid,
5891     d3d10_effect_shader_variable_GetType,
5892     d3d10_effect_shader_variable_GetDesc,
5893     d3d10_effect_shader_variable_GetAnnotationByIndex,
5894     d3d10_effect_shader_variable_GetAnnotationByName,
5895     d3d10_effect_shader_variable_GetMemberByIndex,
5896     d3d10_effect_shader_variable_GetMemberByName,
5897     d3d10_effect_shader_variable_GetMemberBySemantic,
5898     d3d10_effect_shader_variable_GetElement,
5899     d3d10_effect_shader_variable_GetParentConstantBuffer,
5900     d3d10_effect_shader_variable_AsScalar,
5901     d3d10_effect_shader_variable_AsVector,
5902     d3d10_effect_shader_variable_AsMatrix,
5903     d3d10_effect_shader_variable_AsString,
5904     d3d10_effect_shader_variable_AsShaderResource,
5905     d3d10_effect_shader_variable_AsRenderTargetView,
5906     d3d10_effect_shader_variable_AsDepthStencilView,
5907     d3d10_effect_shader_variable_AsConstantBuffer,
5908     d3d10_effect_shader_variable_AsShader,
5909     d3d10_effect_shader_variable_AsBlend,
5910     d3d10_effect_shader_variable_AsDepthStencil,
5911     d3d10_effect_shader_variable_AsRasterizer,
5912     d3d10_effect_shader_variable_AsSampler,
5913     d3d10_effect_shader_variable_SetRawValue,
5914     d3d10_effect_shader_variable_GetRawValue,
5915     /* ID3D10EffectShaderVariable methods */
5916     d3d10_effect_shader_variable_GetShaderDesc,
5917     d3d10_effect_shader_variable_GetVertexShader,
5918     d3d10_effect_shader_variable_GetGeometryShader,
5919     d3d10_effect_shader_variable_GetPixelShader,
5920     d3d10_effect_shader_variable_GetInputSignatureElementDesc,
5921     d3d10_effect_shader_variable_GetOutputSignatureElementDesc,
5922 };
5923
5924 /* ID3D10EffectVariable methods */
5925
5926 static BOOL STDMETHODCALLTYPE d3d10_effect_blend_variable_IsValid(ID3D10EffectBlendVariable *iface)
5927 {
5928     TRACE("iface %p\n", iface);
5929
5930     return (struct d3d10_effect_variable *)iface != &null_blend_variable;
5931 }
5932
5933 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetType(
5934         ID3D10EffectBlendVariable *iface)
5935 {
5936     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5937 }
5938
5939 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetDesc(ID3D10EffectBlendVariable *iface,
5940         D3D10_EFFECT_VARIABLE_DESC *desc)
5941 {
5942     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5943 }
5944
5945 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetAnnotationByIndex(
5946         ID3D10EffectBlendVariable *iface, UINT index)
5947 {
5948     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5949 }
5950
5951 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetAnnotationByName(
5952         ID3D10EffectBlendVariable *iface, LPCSTR name)
5953 {
5954     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5955 }
5956
5957 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberByIndex(
5958         ID3D10EffectBlendVariable *iface, UINT index)
5959 {
5960     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5961 }
5962
5963 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberByName(
5964         ID3D10EffectBlendVariable *iface, LPCSTR name)
5965 {
5966     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5967 }
5968
5969 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberBySemantic(
5970         ID3D10EffectBlendVariable *iface, LPCSTR semantic)
5971 {
5972     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5973 }
5974
5975 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetElement(
5976         ID3D10EffectBlendVariable *iface, UINT index)
5977 {
5978     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5979 }
5980
5981 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetParentConstantBuffer(
5982         ID3D10EffectBlendVariable *iface)
5983 {
5984     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5985 }
5986
5987 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsScalar(
5988         ID3D10EffectBlendVariable *iface)
5989 {
5990     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5991 }
5992
5993 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsVector(
5994         ID3D10EffectBlendVariable *iface)
5995 {
5996     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5997 }
5998
5999 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsMatrix(
6000         ID3D10EffectBlendVariable *iface)
6001 {
6002     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6003 }
6004
6005 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsString(
6006         ID3D10EffectBlendVariable *iface)
6007 {
6008     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6009 }
6010
6011 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsShaderResource(
6012         ID3D10EffectBlendVariable *iface)
6013 {
6014     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6015 }
6016
6017 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsRenderTargetView(
6018         ID3D10EffectBlendVariable *iface)
6019 {
6020     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6021 }
6022
6023 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsDepthStencilView(
6024         ID3D10EffectBlendVariable *iface)
6025 {
6026     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6027 }
6028
6029 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsConstantBuffer(
6030         ID3D10EffectBlendVariable *iface)
6031 {
6032     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6033 }
6034
6035 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsShader(
6036         ID3D10EffectBlendVariable *iface)
6037 {
6038     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6039 }
6040
6041 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsBlend(
6042         ID3D10EffectBlendVariable *iface)
6043 {
6044     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6045 }
6046
6047 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsDepthStencil(
6048         ID3D10EffectBlendVariable *iface)
6049 {
6050     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6051 }
6052
6053 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsRasterizer(
6054         ID3D10EffectBlendVariable *iface)
6055 {
6056     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6057 }
6058
6059 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsSampler(
6060         ID3D10EffectBlendVariable *iface)
6061 {
6062     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6063 }
6064
6065 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_SetRawValue(ID3D10EffectBlendVariable *iface,
6066         void *data, UINT offset, UINT count)
6067 {
6068     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6069 }
6070
6071 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetRawValue(ID3D10EffectBlendVariable *iface,
6072         void *data, UINT offset, UINT count)
6073 {
6074     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6075 }
6076
6077 /* ID3D10EffectBlendVariable methods */
6078
6079 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetBlendState(ID3D10EffectBlendVariable *iface,
6080         UINT index, ID3D10BlendState **blend_state)
6081 {
6082     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
6083
6084     TRACE("iface %p, index %u, blend_state %p.\n", iface, index, blend_state);
6085
6086     if (v->type->element_count)
6087         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6088     else if (index)
6089         return E_FAIL;
6090
6091     if (v->type->basetype != D3D10_SVT_BLEND)
6092     {
6093         WARN("Variable is not a blend state.\n");
6094         return E_FAIL;
6095     }
6096
6097     if ((*blend_state = v->u.state.object.blend))
6098         ID3D10BlendState_AddRef(*blend_state);
6099
6100     return S_OK;
6101 }
6102
6103 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetBackingStore(ID3D10EffectBlendVariable *iface,
6104         UINT index, D3D10_BLEND_DESC *desc)
6105 {
6106     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
6107
6108     TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
6109
6110     if (v->type->element_count)
6111         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6112
6113     if (v->type->basetype != D3D10_SVT_BLEND)
6114     {
6115         WARN("Variable is not a blend state.\n");
6116         return E_FAIL;
6117     }
6118
6119     *desc = v->u.state.desc.blend;
6120
6121     return S_OK;
6122 }
6123
6124
6125 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl =
6126 {
6127     /* ID3D10EffectVariable methods */
6128     d3d10_effect_blend_variable_IsValid,
6129     d3d10_effect_blend_variable_GetType,
6130     d3d10_effect_blend_variable_GetDesc,
6131     d3d10_effect_blend_variable_GetAnnotationByIndex,
6132     d3d10_effect_blend_variable_GetAnnotationByName,
6133     d3d10_effect_blend_variable_GetMemberByIndex,
6134     d3d10_effect_blend_variable_GetMemberByName,
6135     d3d10_effect_blend_variable_GetMemberBySemantic,
6136     d3d10_effect_blend_variable_GetElement,
6137     d3d10_effect_blend_variable_GetParentConstantBuffer,
6138     d3d10_effect_blend_variable_AsScalar,
6139     d3d10_effect_blend_variable_AsVector,
6140     d3d10_effect_blend_variable_AsMatrix,
6141     d3d10_effect_blend_variable_AsString,
6142     d3d10_effect_blend_variable_AsShaderResource,
6143     d3d10_effect_blend_variable_AsRenderTargetView,
6144     d3d10_effect_blend_variable_AsDepthStencilView,
6145     d3d10_effect_blend_variable_AsConstantBuffer,
6146     d3d10_effect_blend_variable_AsShader,
6147     d3d10_effect_blend_variable_AsBlend,
6148     d3d10_effect_blend_variable_AsDepthStencil,
6149     d3d10_effect_blend_variable_AsRasterizer,
6150     d3d10_effect_blend_variable_AsSampler,
6151     d3d10_effect_blend_variable_SetRawValue,
6152     d3d10_effect_blend_variable_GetRawValue,
6153     /* ID3D10EffectBlendVariable methods */
6154     d3d10_effect_blend_variable_GetBlendState,
6155     d3d10_effect_blend_variable_GetBackingStore,
6156 };
6157
6158 /* ID3D10EffectVariable methods */
6159
6160 static BOOL STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_IsValid(ID3D10EffectDepthStencilVariable *iface)
6161 {
6162     TRACE("iface %p\n", iface);
6163
6164     return (struct d3d10_effect_variable *)iface != &null_depth_stencil_variable;
6165 }
6166
6167 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetType(
6168         ID3D10EffectDepthStencilVariable *iface)
6169 {
6170     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6171 }
6172
6173 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetDesc(ID3D10EffectDepthStencilVariable *iface,
6174         D3D10_EFFECT_VARIABLE_DESC *desc)
6175 {
6176     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6177 }
6178
6179 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetAnnotationByIndex(
6180         ID3D10EffectDepthStencilVariable *iface, UINT index)
6181 {
6182     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6183 }
6184
6185 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetAnnotationByName(
6186         ID3D10EffectDepthStencilVariable *iface, LPCSTR name)
6187 {
6188     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6189 }
6190
6191 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberByIndex(
6192         ID3D10EffectDepthStencilVariable *iface, UINT index)
6193 {
6194     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6195 }
6196
6197 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberByName(
6198         ID3D10EffectDepthStencilVariable *iface, LPCSTR name)
6199 {
6200     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6201 }
6202
6203 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberBySemantic(
6204         ID3D10EffectDepthStencilVariable *iface, LPCSTR semantic)
6205 {
6206     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6207 }
6208
6209 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetElement(
6210         ID3D10EffectDepthStencilVariable *iface, UINT index)
6211 {
6212     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6213 }
6214
6215 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetParentConstantBuffer(
6216         ID3D10EffectDepthStencilVariable *iface)
6217 {
6218     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6219 }
6220
6221 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsScalar(
6222         ID3D10EffectDepthStencilVariable *iface)
6223 {
6224     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6225 }
6226
6227 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsVector(
6228         ID3D10EffectDepthStencilVariable *iface)
6229 {
6230     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6231 }
6232
6233 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsMatrix(
6234         ID3D10EffectDepthStencilVariable *iface)
6235 {
6236     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6237 }
6238
6239 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsString(
6240         ID3D10EffectDepthStencilVariable *iface)
6241 {
6242     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6243 }
6244
6245 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsShaderResource(
6246         ID3D10EffectDepthStencilVariable *iface)
6247 {
6248     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6249 }
6250
6251 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsRenderTargetView(
6252         ID3D10EffectDepthStencilVariable *iface)
6253 {
6254     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6255 }
6256
6257 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsDepthStencilView(
6258         ID3D10EffectDepthStencilVariable *iface)
6259 {
6260     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6261 }
6262
6263 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsConstantBuffer(
6264         ID3D10EffectDepthStencilVariable *iface)
6265 {
6266     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6267 }
6268
6269 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsShader(
6270         ID3D10EffectDepthStencilVariable *iface)
6271 {
6272     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6273 }
6274
6275 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsBlend(
6276         ID3D10EffectDepthStencilVariable *iface)
6277 {
6278     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6279 }
6280
6281 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsDepthStencil(
6282         ID3D10EffectDepthStencilVariable *iface)
6283 {
6284     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6285 }
6286
6287 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsRasterizer(
6288         ID3D10EffectDepthStencilVariable *iface)
6289 {
6290     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6291 }
6292
6293 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsSampler(
6294         ID3D10EffectDepthStencilVariable *iface)
6295 {
6296     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6297 }
6298
6299 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_SetRawValue(ID3D10EffectDepthStencilVariable *iface,
6300         void *data, UINT offset, UINT count)
6301 {
6302     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6303 }
6304
6305 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetRawValue(ID3D10EffectDepthStencilVariable *iface,
6306         void *data, UINT offset, UINT count)
6307 {
6308     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6309 }
6310
6311 /* ID3D10EffectDepthStencilVariable methods */
6312
6313 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetDepthStencilState(ID3D10EffectDepthStencilVariable *iface,
6314         UINT index, ID3D10DepthStencilState **depth_stencil_state)
6315 {
6316     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
6317
6318     TRACE("iface %p, index %u, depth_stencil_state %p.\n", iface, index, depth_stencil_state);
6319
6320     if (v->type->element_count)
6321         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6322     else if (index)
6323         return E_FAIL;
6324
6325     if (v->type->basetype != D3D10_SVT_DEPTHSTENCIL)
6326     {
6327         WARN("Variable is not a depth stencil state.\n");
6328         return E_FAIL;
6329     }
6330
6331     if ((*depth_stencil_state = v->u.state.object.depth_stencil))
6332         ID3D10DepthStencilState_AddRef(*depth_stencil_state);
6333
6334     return S_OK;
6335 }
6336
6337 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetBackingStore(ID3D10EffectDepthStencilVariable *iface,
6338         UINT index, D3D10_DEPTH_STENCIL_DESC *desc)
6339 {
6340     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
6341
6342     TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
6343
6344     if (v->type->element_count)
6345         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6346
6347     if (v->type->basetype != D3D10_SVT_DEPTHSTENCIL)
6348     {
6349         WARN("Variable is not a depth stencil state.\n");
6350         return E_FAIL;
6351     }
6352
6353     *desc = v->u.state.desc.depth_stencil;
6354
6355     return S_OK;
6356 }
6357
6358
6359 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl =
6360 {
6361     /* ID3D10EffectVariable methods */
6362     d3d10_effect_depth_stencil_variable_IsValid,
6363     d3d10_effect_depth_stencil_variable_GetType,
6364     d3d10_effect_depth_stencil_variable_GetDesc,
6365     d3d10_effect_depth_stencil_variable_GetAnnotationByIndex,
6366     d3d10_effect_depth_stencil_variable_GetAnnotationByName,
6367     d3d10_effect_depth_stencil_variable_GetMemberByIndex,
6368     d3d10_effect_depth_stencil_variable_GetMemberByName,
6369     d3d10_effect_depth_stencil_variable_GetMemberBySemantic,
6370     d3d10_effect_depth_stencil_variable_GetElement,
6371     d3d10_effect_depth_stencil_variable_GetParentConstantBuffer,
6372     d3d10_effect_depth_stencil_variable_AsScalar,
6373     d3d10_effect_depth_stencil_variable_AsVector,
6374     d3d10_effect_depth_stencil_variable_AsMatrix,
6375     d3d10_effect_depth_stencil_variable_AsString,
6376     d3d10_effect_depth_stencil_variable_AsShaderResource,
6377     d3d10_effect_depth_stencil_variable_AsRenderTargetView,
6378     d3d10_effect_depth_stencil_variable_AsDepthStencilView,
6379     d3d10_effect_depth_stencil_variable_AsConstantBuffer,
6380     d3d10_effect_depth_stencil_variable_AsShader,
6381     d3d10_effect_depth_stencil_variable_AsBlend,
6382     d3d10_effect_depth_stencil_variable_AsDepthStencil,
6383     d3d10_effect_depth_stencil_variable_AsRasterizer,
6384     d3d10_effect_depth_stencil_variable_AsSampler,
6385     d3d10_effect_depth_stencil_variable_SetRawValue,
6386     d3d10_effect_depth_stencil_variable_GetRawValue,
6387     /* ID3D10EffectDepthStencilVariable methods */
6388     d3d10_effect_depth_stencil_variable_GetDepthStencilState,
6389     d3d10_effect_depth_stencil_variable_GetBackingStore,
6390 };
6391
6392 /* ID3D10EffectVariable methods */
6393
6394 static BOOL STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_IsValid(ID3D10EffectRasterizerVariable *iface)
6395 {
6396     TRACE("iface %p\n", iface);
6397
6398     return (struct d3d10_effect_variable *)iface != &null_rasterizer_variable;
6399 }
6400
6401 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetType(
6402         ID3D10EffectRasterizerVariable *iface)
6403 {
6404     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6405 }
6406
6407 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetDesc(ID3D10EffectRasterizerVariable *iface,
6408         D3D10_EFFECT_VARIABLE_DESC *desc)
6409 {
6410     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6411 }
6412
6413 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetAnnotationByIndex(
6414         ID3D10EffectRasterizerVariable *iface, UINT index)
6415 {
6416     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6417 }
6418
6419 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetAnnotationByName(
6420         ID3D10EffectRasterizerVariable *iface, LPCSTR name)
6421 {
6422     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6423 }
6424
6425 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberByIndex(
6426         ID3D10EffectRasterizerVariable *iface, UINT index)
6427 {
6428     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6429 }
6430
6431 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberByName(
6432         ID3D10EffectRasterizerVariable *iface, LPCSTR name)
6433 {
6434     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6435 }
6436
6437 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberBySemantic(
6438         ID3D10EffectRasterizerVariable *iface, LPCSTR semantic)
6439 {
6440     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6441 }
6442
6443 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetElement(
6444         ID3D10EffectRasterizerVariable *iface, UINT index)
6445 {
6446     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6447 }
6448
6449 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetParentConstantBuffer(
6450         ID3D10EffectRasterizerVariable *iface)
6451 {
6452     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6453 }
6454
6455 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsScalar(
6456         ID3D10EffectRasterizerVariable *iface)
6457 {
6458     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6459 }
6460
6461 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsVector(
6462         ID3D10EffectRasterizerVariable *iface)
6463 {
6464     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6465 }
6466
6467 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsMatrix(
6468         ID3D10EffectRasterizerVariable *iface)
6469 {
6470     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6471 }
6472
6473 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsString(
6474         ID3D10EffectRasterizerVariable *iface)
6475 {
6476     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6477 }
6478
6479 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsShaderResource(
6480         ID3D10EffectRasterizerVariable *iface)
6481 {
6482     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6483 }
6484
6485 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsRenderTargetView(
6486         ID3D10EffectRasterizerVariable *iface)
6487 {
6488     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6489 }
6490
6491 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsDepthStencilView(
6492         ID3D10EffectRasterizerVariable *iface)
6493 {
6494     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6495 }
6496
6497 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsConstantBuffer(
6498         ID3D10EffectRasterizerVariable *iface)
6499 {
6500     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6501 }
6502
6503 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsShader(
6504         ID3D10EffectRasterizerVariable *iface)
6505 {
6506     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6507 }
6508
6509 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsBlend(
6510         ID3D10EffectRasterizerVariable *iface)
6511 {
6512     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6513 }
6514
6515 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsDepthStencil(
6516         ID3D10EffectRasterizerVariable *iface)
6517 {
6518     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6519 }
6520
6521 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsRasterizer(
6522         ID3D10EffectRasterizerVariable *iface)
6523 {
6524     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6525 }
6526
6527 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsSampler(
6528         ID3D10EffectRasterizerVariable *iface)
6529 {
6530     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6531 }
6532
6533 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_SetRawValue(ID3D10EffectRasterizerVariable *iface,
6534         void *data, UINT offset, UINT count)
6535 {
6536     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6537 }
6538
6539 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetRawValue(ID3D10EffectRasterizerVariable *iface,
6540         void *data, UINT offset, UINT count)
6541 {
6542     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6543 }
6544
6545 /* ID3D10EffectRasterizerVariable methods */
6546
6547 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetRasterizerState(ID3D10EffectRasterizerVariable *iface,
6548         UINT index, ID3D10RasterizerState **rasterizer_state)
6549 {
6550     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
6551
6552     TRACE("iface %p, index %u, rasterizer_state %p.\n", iface, index, rasterizer_state);
6553
6554     if (v->type->element_count)
6555         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6556     else if (index)
6557         return E_FAIL;
6558
6559     if (v->type->basetype != D3D10_SVT_RASTERIZER)
6560     {
6561         WARN("Variable is not a rasterizer state.\n");
6562         return E_FAIL;
6563     }
6564
6565     if ((*rasterizer_state = v->u.state.object.rasterizer))
6566         ID3D10RasterizerState_AddRef(*rasterizer_state);
6567
6568     return S_OK;
6569 }
6570
6571 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetBackingStore(ID3D10EffectRasterizerVariable *iface,
6572         UINT index, D3D10_RASTERIZER_DESC *desc)
6573 {
6574     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
6575
6576     TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
6577
6578     if (v->type->element_count)
6579         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6580
6581     if (v->type->basetype != D3D10_SVT_RASTERIZER)
6582     {
6583         WARN("Variable is not a rasterizer state.\n");
6584         return E_FAIL;
6585     }
6586
6587     *desc = v->u.state.desc.rasterizer;
6588
6589     return S_OK;
6590 }
6591
6592
6593 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl =
6594 {
6595     /* ID3D10EffectVariable methods */
6596     d3d10_effect_rasterizer_variable_IsValid,
6597     d3d10_effect_rasterizer_variable_GetType,
6598     d3d10_effect_rasterizer_variable_GetDesc,
6599     d3d10_effect_rasterizer_variable_GetAnnotationByIndex,
6600     d3d10_effect_rasterizer_variable_GetAnnotationByName,
6601     d3d10_effect_rasterizer_variable_GetMemberByIndex,
6602     d3d10_effect_rasterizer_variable_GetMemberByName,
6603     d3d10_effect_rasterizer_variable_GetMemberBySemantic,
6604     d3d10_effect_rasterizer_variable_GetElement,
6605     d3d10_effect_rasterizer_variable_GetParentConstantBuffer,
6606     d3d10_effect_rasterizer_variable_AsScalar,
6607     d3d10_effect_rasterizer_variable_AsVector,
6608     d3d10_effect_rasterizer_variable_AsMatrix,
6609     d3d10_effect_rasterizer_variable_AsString,
6610     d3d10_effect_rasterizer_variable_AsShaderResource,
6611     d3d10_effect_rasterizer_variable_AsRenderTargetView,
6612     d3d10_effect_rasterizer_variable_AsDepthStencilView,
6613     d3d10_effect_rasterizer_variable_AsConstantBuffer,
6614     d3d10_effect_rasterizer_variable_AsShader,
6615     d3d10_effect_rasterizer_variable_AsBlend,
6616     d3d10_effect_rasterizer_variable_AsDepthStencil,
6617     d3d10_effect_rasterizer_variable_AsRasterizer,
6618     d3d10_effect_rasterizer_variable_AsSampler,
6619     d3d10_effect_rasterizer_variable_SetRawValue,
6620     d3d10_effect_rasterizer_variable_GetRawValue,
6621     /* ID3D10EffectRasterizerVariable methods */
6622     d3d10_effect_rasterizer_variable_GetRasterizerState,
6623     d3d10_effect_rasterizer_variable_GetBackingStore,
6624 };
6625
6626 /* ID3D10EffectVariable methods */
6627
6628 static BOOL STDMETHODCALLTYPE d3d10_effect_sampler_variable_IsValid(ID3D10EffectSamplerVariable *iface)
6629 {
6630     TRACE("iface %p\n", iface);
6631
6632     return (struct d3d10_effect_variable *)iface != &null_sampler_variable;
6633 }
6634
6635 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetType(
6636         ID3D10EffectSamplerVariable *iface)
6637 {
6638     return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6639 }
6640
6641 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetDesc(ID3D10EffectSamplerVariable *iface,
6642         D3D10_EFFECT_VARIABLE_DESC *desc)
6643 {
6644     return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6645 }
6646
6647 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetAnnotationByIndex(
6648         ID3D10EffectSamplerVariable *iface, UINT index)
6649 {
6650     return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6651 }
6652
6653 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetAnnotationByName(
6654         ID3D10EffectSamplerVariable *iface, LPCSTR name)
6655 {
6656     return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6657 }
6658
6659 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberByIndex(
6660         ID3D10EffectSamplerVariable *iface, UINT index)
6661 {
6662     return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6663 }
6664
6665 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberByName(
6666         ID3D10EffectSamplerVariable *iface, LPCSTR name)
6667 {
6668     return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6669 }
6670
6671 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberBySemantic(
6672         ID3D10EffectSamplerVariable *iface, LPCSTR semantic)
6673 {
6674     return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6675 }
6676
6677 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetElement(
6678         ID3D10EffectSamplerVariable *iface, UINT index)
6679 {
6680     return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6681 }
6682
6683 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetParentConstantBuffer(
6684         ID3D10EffectSamplerVariable *iface)
6685 {
6686     return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6687 }
6688
6689 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsScalar(
6690         ID3D10EffectSamplerVariable *iface)
6691 {
6692     return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6693 }
6694
6695 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsVector(
6696         ID3D10EffectSamplerVariable *iface)
6697 {
6698     return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6699 }
6700
6701 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsMatrix(
6702         ID3D10EffectSamplerVariable *iface)
6703 {
6704     return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6705 }
6706
6707 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsString(
6708         ID3D10EffectSamplerVariable *iface)
6709 {
6710     return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6711 }
6712
6713 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsShaderResource(
6714         ID3D10EffectSamplerVariable *iface)
6715 {
6716     return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6717 }
6718
6719 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsRenderTargetView(
6720         ID3D10EffectSamplerVariable *iface)
6721 {
6722     return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6723 }
6724
6725 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsDepthStencilView(
6726         ID3D10EffectSamplerVariable *iface)
6727 {
6728     return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6729 }
6730
6731 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsConstantBuffer(
6732         ID3D10EffectSamplerVariable *iface)
6733 {
6734     return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6735 }
6736
6737 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsShader(
6738         ID3D10EffectSamplerVariable *iface)
6739 {
6740     return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6741 }
6742
6743 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsBlend(
6744         ID3D10EffectSamplerVariable *iface)
6745 {
6746     return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6747 }
6748
6749 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsDepthStencil(
6750         ID3D10EffectSamplerVariable *iface)
6751 {
6752     return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6753 }
6754
6755 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsRasterizer(
6756         ID3D10EffectSamplerVariable *iface)
6757 {
6758     return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6759 }
6760
6761 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsSampler(
6762         ID3D10EffectSamplerVariable *iface)
6763 {
6764     return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6765 }
6766
6767 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_SetRawValue(ID3D10EffectSamplerVariable *iface,
6768         void *data, UINT offset, UINT count)
6769 {
6770     return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6771 }
6772
6773 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetRawValue(ID3D10EffectSamplerVariable *iface,
6774         void *data, UINT offset, UINT count)
6775 {
6776     return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6777 }
6778
6779 /* ID3D10EffectSamplerVariable methods */
6780
6781 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetSampler(ID3D10EffectSamplerVariable *iface,
6782         UINT index, ID3D10SamplerState **sampler)
6783 {
6784     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
6785
6786     TRACE("iface %p, index %u, sampler %p.\n", iface, index, sampler);
6787
6788     if (v->type->element_count)
6789         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6790     else if (index)
6791         return E_FAIL;
6792
6793     if (v->type->basetype != D3D10_SVT_SAMPLER)
6794     {
6795         WARN("Variable is not a sampler state.\n");
6796         return E_FAIL;
6797     }
6798
6799     if ((*sampler = v->u.state.object.sampler))
6800         ID3D10SamplerState_AddRef(*sampler);
6801
6802     return S_OK;
6803 }
6804
6805 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetBackingStore(ID3D10EffectSamplerVariable *iface,
6806         UINT index, D3D10_SAMPLER_DESC *desc)
6807 {
6808     struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
6809
6810     TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
6811
6812     if (v->type->element_count)
6813         v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6814
6815     if (v->type->basetype != D3D10_SVT_SAMPLER)
6816     {
6817         WARN("Variable is not a sampler state.\n");
6818         return E_FAIL;
6819     }
6820
6821     *desc = v->u.state.desc.sampler;
6822
6823     return S_OK;
6824 }
6825
6826
6827 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl =
6828 {
6829     /* ID3D10EffectVariable methods */
6830     d3d10_effect_sampler_variable_IsValid,
6831     d3d10_effect_sampler_variable_GetType,
6832     d3d10_effect_sampler_variable_GetDesc,
6833     d3d10_effect_sampler_variable_GetAnnotationByIndex,
6834     d3d10_effect_sampler_variable_GetAnnotationByName,
6835     d3d10_effect_sampler_variable_GetMemberByIndex,
6836     d3d10_effect_sampler_variable_GetMemberByName,
6837     d3d10_effect_sampler_variable_GetMemberBySemantic,
6838     d3d10_effect_sampler_variable_GetElement,
6839     d3d10_effect_sampler_variable_GetParentConstantBuffer,
6840     d3d10_effect_sampler_variable_AsScalar,
6841     d3d10_effect_sampler_variable_AsVector,
6842     d3d10_effect_sampler_variable_AsMatrix,
6843     d3d10_effect_sampler_variable_AsString,
6844     d3d10_effect_sampler_variable_AsShaderResource,
6845     d3d10_effect_sampler_variable_AsRenderTargetView,
6846     d3d10_effect_sampler_variable_AsDepthStencilView,
6847     d3d10_effect_sampler_variable_AsConstantBuffer,
6848     d3d10_effect_sampler_variable_AsShader,
6849     d3d10_effect_sampler_variable_AsBlend,
6850     d3d10_effect_sampler_variable_AsDepthStencil,
6851     d3d10_effect_sampler_variable_AsRasterizer,
6852     d3d10_effect_sampler_variable_AsSampler,
6853     d3d10_effect_sampler_variable_SetRawValue,
6854     d3d10_effect_sampler_variable_GetRawValue,
6855     /* ID3D10EffectSamplerVariable methods */
6856     d3d10_effect_sampler_variable_GetSampler,
6857     d3d10_effect_sampler_variable_GetBackingStore,
6858 };
6859
6860 /* ID3D10EffectType methods */
6861
6862 static inline struct d3d10_effect_type *impl_from_ID3D10EffectType(ID3D10EffectType *iface)
6863 {
6864     return CONTAINING_RECORD(iface, struct d3d10_effect_type, ID3D10EffectType_iface);
6865 }
6866
6867 static BOOL STDMETHODCALLTYPE d3d10_effect_type_IsValid(ID3D10EffectType *iface)
6868 {
6869     struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
6870
6871     TRACE("iface %p\n", iface);
6872
6873     return This != &null_type;
6874 }
6875
6876 static HRESULT STDMETHODCALLTYPE d3d10_effect_type_GetDesc(ID3D10EffectType *iface, D3D10_EFFECT_TYPE_DESC *desc)
6877 {
6878     struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
6879
6880     TRACE("iface %p, desc %p\n", iface, desc);
6881
6882     if (This == &null_type)
6883     {
6884         WARN("Null type specified\n");
6885         return E_FAIL;
6886     }
6887
6888     if (!desc)
6889     {
6890         WARN("Invalid argument specified\n");
6891         return E_INVALIDARG;
6892     }
6893
6894     desc->TypeName = This->name;
6895     desc->Class = This->type_class;
6896     desc->Type = This->basetype;
6897     desc->Elements = This->element_count;
6898     desc->Members = This->member_count;
6899     desc->Rows = This->row_count;
6900     desc->Columns = This->column_count;
6901     desc->PackedSize = This->size_packed;
6902     desc->UnpackedSize = This->size_unpacked;
6903     desc->Stride = This->stride;
6904
6905     return S_OK;
6906 }
6907
6908 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeByIndex(ID3D10EffectType *iface,
6909         UINT index)
6910 {
6911     struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
6912     struct d3d10_effect_type *t;
6913
6914     TRACE("iface %p, index %u\n", iface, index);
6915
6916     if (index >= This->member_count)
6917     {
6918         WARN("Invalid index specified\n");
6919         return &null_type.ID3D10EffectType_iface;
6920     }
6921
6922     t = (&This->members[index])->type;
6923
6924     TRACE("Returning member %p, %s\n", t, debugstr_a(t->name));
6925
6926     return &t->ID3D10EffectType_iface;
6927 }
6928
6929 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeByName(ID3D10EffectType *iface,
6930         LPCSTR name)
6931 {
6932     struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
6933     unsigned int i;
6934
6935     TRACE("iface %p, name %s\n", iface, debugstr_a(name));
6936
6937     if (!name)
6938     {
6939         WARN("Invalid name specified\n");
6940         return &null_type.ID3D10EffectType_iface;
6941     }
6942
6943     for (i = 0; i < This->member_count; ++i)
6944     {
6945         struct d3d10_effect_type_member *typem = &This->members[i];
6946
6947         if (typem->name)
6948         {
6949             if (!strcmp(typem->name, name))
6950             {
6951                 TRACE("Returning type %p.\n", typem->type);
6952                 return &typem->type->ID3D10EffectType_iface;
6953             }
6954         }
6955     }
6956
6957     WARN("Invalid name specified\n");
6958
6959     return &null_type.ID3D10EffectType_iface;
6960 }
6961
6962 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeBySemantic(ID3D10EffectType *iface,
6963         LPCSTR semantic)
6964 {
6965     struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
6966     unsigned int i;
6967
6968     TRACE("iface %p, semantic %s\n", iface, debugstr_a(semantic));
6969
6970     if (!semantic)
6971     {
6972         WARN("Invalid semantic specified\n");
6973         return &null_type.ID3D10EffectType_iface;
6974     }
6975
6976     for (i = 0; i < This->member_count; ++i)
6977     {
6978         struct d3d10_effect_type_member *typem = &This->members[i];
6979
6980         if (typem->semantic)
6981         {
6982             if (!strcmp(typem->semantic, semantic))
6983             {
6984                 TRACE("Returning type %p.\n", typem->type);
6985                 return &typem->type->ID3D10EffectType_iface;
6986             }
6987         }
6988     }
6989
6990     WARN("Invalid semantic specified\n");
6991
6992     return &null_type.ID3D10EffectType_iface;
6993 }
6994
6995 static LPCSTR STDMETHODCALLTYPE d3d10_effect_type_GetMemberName(ID3D10EffectType *iface, UINT index)
6996 {
6997     struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
6998     struct d3d10_effect_type_member *typem;
6999
7000     TRACE("iface %p, index %u\n", iface, index);
7001
7002     if (index >= This->member_count)
7003     {
7004         WARN("Invalid index specified\n");
7005         return NULL;
7006     }
7007
7008     typem = &This->members[index];
7009
7010     TRACE("Returning name %s\n", debugstr_a(typem->name));
7011
7012     return typem->name;
7013 }
7014
7015 static LPCSTR STDMETHODCALLTYPE d3d10_effect_type_GetMemberSemantic(ID3D10EffectType *iface, UINT index)
7016 {
7017     struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
7018     struct d3d10_effect_type_member *typem;
7019
7020     TRACE("iface %p, index %u\n", iface, index);
7021
7022     if (index >= This->member_count)
7023     {
7024         WARN("Invalid index specified\n");
7025         return NULL;
7026     }
7027
7028     typem = &This->members[index];
7029
7030     TRACE("Returning semantic %s\n", debugstr_a(typem->semantic));
7031
7032     return typem->semantic;
7033 }
7034
7035 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl =
7036 {
7037     /* ID3D10EffectType */
7038     d3d10_effect_type_IsValid,
7039     d3d10_effect_type_GetDesc,
7040     d3d10_effect_type_GetMemberTypeByIndex,
7041     d3d10_effect_type_GetMemberTypeByName,
7042     d3d10_effect_type_GetMemberTypeBySemantic,
7043     d3d10_effect_type_GetMemberName,
7044     d3d10_effect_type_GetMemberSemantic,
7045 };