d3d10/effect: Implement GetString().
[wine.git] / dlls / d3d10 / effect.c
blob12cfb4573999f4bf03901436b661802ef442105f
1 /*
2 * Copyright 2009 Henri Verbeet for CodeWeavers
3 * Copyright 2009 Rico Schüller
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.
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.
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
21 #include "d3d10_private.h"
23 #include <float.h>
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
27 #define MAKE_TAG(ch0, ch1, ch2, ch3) \
28 ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
29 ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
30 #define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
31 #define TAG_FX10 MAKE_TAG('F', 'X', '1', '0')
32 #define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N')
33 #define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N')
34 #define TAG_SHDR MAKE_TAG('S', 'H', 'D', 'R')
36 #define D3D10_FX10_TYPE_COLUMN_SHIFT 11
37 #define D3D10_FX10_TYPE_COLUMN_MASK (0x7 << D3D10_FX10_TYPE_COLUMN_SHIFT)
39 #define D3D10_FX10_TYPE_ROW_SHIFT 8
40 #define D3D10_FX10_TYPE_ROW_MASK (0x7 << D3D10_FX10_TYPE_ROW_SHIFT)
42 #define D3D10_FX10_TYPE_BASETYPE_SHIFT 3
43 #define D3D10_FX10_TYPE_BASETYPE_MASK (0x1f << D3D10_FX10_TYPE_BASETYPE_SHIFT)
45 #define D3D10_FX10_TYPE_CLASS_SHIFT 0
46 #define D3D10_FX10_TYPE_CLASS_MASK (0x7 << D3D10_FX10_TYPE_CLASS_SHIFT)
48 #define D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK 0x4000
50 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl;
51 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl;
52 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl;
53 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl;
54 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl;
55 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl;
56 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl;
57 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl;
58 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl;
59 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl;
60 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl;
61 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl;
62 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl;
63 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl;
64 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl;
65 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl;
66 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl;
68 /* null objects - needed for invalid calls */
69 static struct d3d10_effect_technique null_technique = {{&d3d10_effect_technique_vtbl}};
70 static struct d3d10_effect_pass null_pass = {{&d3d10_effect_pass_vtbl}};
71 static struct d3d10_effect_type null_type = {{&d3d10_effect_type_vtbl}};
72 static struct d3d10_effect_variable null_local_buffer = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl},
73 &null_local_buffer, &null_type};
74 static struct d3d10_effect_variable null_variable = {{&d3d10_effect_variable_vtbl},
75 &null_local_buffer, &null_type};
76 static struct d3d10_effect_variable null_scalar_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl},
77 &null_local_buffer, &null_type};
78 static struct d3d10_effect_variable null_vector_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl},
79 &null_local_buffer, &null_type};
80 static struct d3d10_effect_variable null_matrix_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl},
81 &null_local_buffer, &null_type};
82 static struct d3d10_effect_variable null_string_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl},
83 &null_local_buffer, &null_type};
84 static struct d3d10_effect_variable null_shader_resource_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl},
85 &null_local_buffer, &null_type};
86 static struct d3d10_effect_variable null_render_target_view_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl},
87 &null_local_buffer, &null_type};
88 static struct d3d10_effect_variable null_depth_stencil_view_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl},
89 &null_local_buffer, &null_type};
90 static struct d3d10_effect_variable null_shader_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
91 &null_local_buffer, &null_type};
92 static struct d3d10_effect_variable null_blend_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl},
93 &null_local_buffer, &null_type};
94 static struct d3d10_effect_variable null_depth_stencil_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl},
95 &null_local_buffer, &null_type};
96 static struct d3d10_effect_variable null_rasterizer_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl},
97 &null_local_buffer, &null_type};
98 static struct d3d10_effect_variable null_sampler_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl},
99 &null_local_buffer, &null_type};
101 /* anonymous_shader_type and anonymous_shader */
102 static char anonymous_name[] = "$Anonymous";
103 static char anonymous_vertexshader_name[] = "vertexshader";
104 static char anonymous_pixelshader_name[] = "pixelshader";
105 static char anonymous_geometryshader_name[] = "geometryshader";
106 static struct d3d10_effect_type anonymous_vs_type = {{&d3d10_effect_type_vtbl},
107 anonymous_vertexshader_name, D3D10_SVT_VERTEXSHADER, D3D10_SVC_OBJECT};
108 static struct d3d10_effect_type anonymous_ps_type = {{&d3d10_effect_type_vtbl},
109 anonymous_pixelshader_name, D3D10_SVT_PIXELSHADER, D3D10_SVC_OBJECT};
110 static struct d3d10_effect_type anonymous_gs_type = {{&d3d10_effect_type_vtbl},
111 anonymous_geometryshader_name, D3D10_SVT_GEOMETRYSHADER, D3D10_SVC_OBJECT};
112 static struct d3d10_effect_variable anonymous_vs = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
113 &null_local_buffer, &anonymous_vs_type, anonymous_name};
114 static struct d3d10_effect_variable anonymous_ps = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
115 &null_local_buffer, &anonymous_ps_type, anonymous_name};
116 static struct d3d10_effect_variable anonymous_gs = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
117 &null_local_buffer, &anonymous_gs_type, anonymous_name};
119 static struct d3d10_effect_type *get_fx10_type(struct d3d10_effect *effect,
120 const char *data, size_t data_size, DWORD offset);
122 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectVariable(ID3D10EffectVariable *iface)
124 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
127 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectShaderVariable(ID3D10EffectShaderVariable *iface)
129 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
132 struct d3d10_effect_state_property_info
134 UINT id;
135 const char *name;
136 D3D_SHADER_VARIABLE_TYPE type;
137 UINT size;
138 UINT count;
139 D3D_SHADER_VARIABLE_TYPE container_type;
140 LONG offset;
143 static const struct d3d10_effect_state_property_info property_info[] =
145 {0x0c, "RasterizerState.FillMode", D3D10_SVT_INT, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, FillMode) },
146 {0x0d, "RasterizerState.CullMode", D3D10_SVT_INT, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, CullMode) },
147 {0x0e, "RasterizerState.FrontCounterClockwise", D3D10_SVT_BOOL, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, FrontCounterClockwise) },
148 {0x0f, "RasterizerState.DepthBias", D3D10_SVT_INT, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, DepthBias) },
149 {0x10, "RasterizerState.DepthBiasClamp", D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, DepthBiasClamp) },
150 {0x11, "RasterizerState.SlopeScaledDepthBias", D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, SlopeScaledDepthBias) },
151 {0x12, "RasterizerState.DepthClipEnable", D3D10_SVT_BOOL, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, DepthClipEnable) },
152 {0x13, "RasterizerState.ScissorEnable", D3D10_SVT_BOOL, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, ScissorEnable) },
153 {0x14, "RasterizerState.MultisampleEnable", D3D10_SVT_BOOL, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, MultisampleEnable) },
154 {0x15, "RasterizerState.AntialiasedLineEnable", D3D10_SVT_BOOL, 1, 1, D3D10_SVT_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, AntialiasedLineEnable) },
155 {0x16, "DepthStencilState.DepthEnable", D3D10_SVT_BOOL, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthEnable) },
156 {0x17, "DepthStencilState.DepthWriteMask", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthWriteMask) },
157 {0x18, "DepthStencilState.DepthFunc", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthFunc) },
158 {0x19, "DepthStencilState.StencilEnable", D3D10_SVT_BOOL, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, StencilEnable) },
159 {0x1a, "DepthStencilState.StencilReadMask", D3D10_SVT_UINT8, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, StencilReadMask) },
160 {0x1b, "DepthStencilState.StencilWriteMask", D3D10_SVT_UINT8, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, StencilWriteMask) },
161 {0x1c, "DepthStencilState.FrontFaceStencilFail", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilFailOp) },
162 {0x1d, "DepthStencilState.FrontFaceStencilDepthFail", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilDepthFailOp)},
163 {0x1e, "DepthStencilState.FrontFaceStencilPass", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilPassOp) },
164 {0x1f, "DepthStencilState.FrontFaceStencilFunc", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilFunc) },
165 {0x20, "DepthStencilState.BackFaceStencilFail", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilFailOp) },
166 {0x21, "DepthStencilState.BackFaceStencilDepthFail", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilDepthFailOp) },
167 {0x22, "DepthStencilState.BackFaceStencilPass", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilPassOp) },
168 {0x23, "DepthStencilState.BackFaceStencilFunc", D3D10_SVT_INT, 1, 1, D3D10_SVT_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilFunc) },
169 {0x24, "BlendState.AlphaToCoverageEnable", D3D10_SVT_BOOL, 1, 1, D3D10_SVT_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, AlphaToCoverageEnable) },
170 {0x25, "BlendState.BlendEnable", D3D10_SVT_BOOL, 1, 8, D3D10_SVT_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, BlendEnable) },
171 {0x26, "BlendState.SrcBlend", D3D10_SVT_INT, 1, 1, D3D10_SVT_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, SrcBlend) },
172 {0x27, "BlendState.DestBlend", D3D10_SVT_INT, 1, 1, D3D10_SVT_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, DestBlend) },
173 {0x28, "BlendState.BlendOp", D3D10_SVT_INT, 1, 1, D3D10_SVT_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, BlendOp) },
174 {0x29, "BlendState.SrcBlendAlpha", D3D10_SVT_INT, 1, 1, D3D10_SVT_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, SrcBlendAlpha) },
175 {0x2a, "BlendState.DestBlendAlpha", D3D10_SVT_INT, 1, 1, D3D10_SVT_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, DestBlendAlpha) },
176 {0x2b, "BlendState.BlendOpAlpha", D3D10_SVT_INT, 1, 1, D3D10_SVT_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, BlendOpAlpha) },
177 {0x2c, "BlendState.RenderTargetWriteMask", D3D10_SVT_UINT8, 1, 8, D3D10_SVT_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, RenderTargetWriteMask) },
178 {0x2d, "SamplerState.Filter", D3D10_SVT_INT, 1, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, Filter) },
179 {0x2e, "SamplerState.AddressU", D3D10_SVT_INT, 1, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, AddressU) },
180 {0x2f, "SamplerState.AddressV", D3D10_SVT_INT, 1, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, AddressV) },
181 {0x30, "SamplerState.AddressW", D3D10_SVT_INT, 1, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, AddressW) },
182 {0x31, "SamplerState.MipMapLODBias", D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, MipLODBias) },
183 {0x32, "SamplerState.MaxAnisotropy", D3D10_SVT_UINT, 1, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, MaxAnisotropy) },
184 {0x33, "SamplerState.ComparisonFunc", D3D10_SVT_INT, 1, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, ComparisonFunc) },
185 {0x34, "SamplerState.BorderColor", D3D10_SVT_FLOAT, 4, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, BorderColor) },
186 {0x35, "SamplerState.MinLOD", D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, MinLOD) },
187 {0x36, "SamplerState.MaxLOD", D3D10_SVT_FLOAT, 1, 1, D3D10_SVT_SAMPLER, FIELD_OFFSET(D3D10_SAMPLER_DESC, MaxLOD) },
190 static const D3D10_RASTERIZER_DESC default_rasterizer_desc =
192 D3D10_FILL_SOLID,
193 D3D10_CULL_BACK,
194 FALSE,
196 0.0f,
197 0.0f,
198 TRUE,
199 FALSE,
200 FALSE,
201 FALSE,
204 static const D3D10_DEPTH_STENCIL_DESC default_depth_stencil_desc =
206 TRUE,
207 D3D10_DEPTH_WRITE_MASK_ALL,
208 D3D10_COMPARISON_LESS,
209 FALSE,
210 D3D10_DEFAULT_STENCIL_READ_MASK,
211 D3D10_DEFAULT_STENCIL_WRITE_MASK,
212 {D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_COMPARISON_ALWAYS},
213 {D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_COMPARISON_ALWAYS},
216 static const D3D10_BLEND_DESC default_blend_desc =
218 FALSE,
219 {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
220 D3D10_BLEND_SRC_ALPHA,
221 D3D10_BLEND_INV_SRC_ALPHA,
222 D3D10_BLEND_OP_ADD,
223 D3D10_BLEND_SRC_ALPHA,
224 D3D10_BLEND_INV_SRC_ALPHA,
225 D3D10_BLEND_OP_ADD,
226 {0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf},
229 static const D3D10_SAMPLER_DESC default_sampler_desc =
231 D3D10_FILTER_MIN_MAG_MIP_POINT,
232 D3D10_TEXTURE_ADDRESS_WRAP,
233 D3D10_TEXTURE_ADDRESS_WRAP,
234 D3D10_TEXTURE_ADDRESS_WRAP,
235 0.0f,
237 D3D10_COMPARISON_NEVER,
238 {0.0f, 0.0f, 0.0f, 0.0f},
239 0.0f,
240 FLT_MAX,
243 struct d3d10_effect_state_storage_info
245 D3D_SHADER_VARIABLE_TYPE id;
246 SIZE_T size;
247 const void *default_state;
250 static const struct d3d10_effect_state_storage_info d3d10_effect_state_storage_info[] =
252 {D3D10_SVT_RASTERIZER, sizeof(default_rasterizer_desc), &default_rasterizer_desc },
253 {D3D10_SVT_DEPTHSTENCIL, sizeof(default_depth_stencil_desc), &default_depth_stencil_desc},
254 {D3D10_SVT_BLEND, sizeof(default_blend_desc), &default_blend_desc },
255 {D3D10_SVT_SAMPLER, sizeof(default_sampler_desc), &default_sampler_desc },
258 #define WINE_D3D10_TO_STR(x) case x: return #x
260 static const char *debug_d3d10_shader_variable_class(D3D10_SHADER_VARIABLE_CLASS c)
262 switch (c)
264 WINE_D3D10_TO_STR(D3D10_SVC_SCALAR);
265 WINE_D3D10_TO_STR(D3D10_SVC_VECTOR);
266 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_ROWS);
267 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_COLUMNS);
268 WINE_D3D10_TO_STR(D3D10_SVC_OBJECT);
269 WINE_D3D10_TO_STR(D3D10_SVC_STRUCT);
270 default:
271 FIXME("Unrecognised D3D10_SHADER_VARIABLE_CLASS %#x.\n", c);
272 return "unrecognised";
276 static const char *debug_d3d10_shader_variable_type(D3D10_SHADER_VARIABLE_TYPE t)
278 switch (t)
280 WINE_D3D10_TO_STR(D3D10_SVT_VOID);
281 WINE_D3D10_TO_STR(D3D10_SVT_BOOL);
282 WINE_D3D10_TO_STR(D3D10_SVT_INT);
283 WINE_D3D10_TO_STR(D3D10_SVT_FLOAT);
284 WINE_D3D10_TO_STR(D3D10_SVT_STRING);
285 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE);
286 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1D);
287 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2D);
288 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE3D);
289 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBE);
290 WINE_D3D10_TO_STR(D3D10_SVT_SAMPLER);
291 WINE_D3D10_TO_STR(D3D10_SVT_PIXELSHADER);
292 WINE_D3D10_TO_STR(D3D10_SVT_VERTEXSHADER);
293 WINE_D3D10_TO_STR(D3D10_SVT_UINT);
294 WINE_D3D10_TO_STR(D3D10_SVT_UINT8);
295 WINE_D3D10_TO_STR(D3D10_SVT_GEOMETRYSHADER);
296 WINE_D3D10_TO_STR(D3D10_SVT_RASTERIZER);
297 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCIL);
298 WINE_D3D10_TO_STR(D3D10_SVT_BLEND);
299 WINE_D3D10_TO_STR(D3D10_SVT_BUFFER);
300 WINE_D3D10_TO_STR(D3D10_SVT_CBUFFER);
301 WINE_D3D10_TO_STR(D3D10_SVT_TBUFFER);
302 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1DARRAY);
303 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DARRAY);
304 WINE_D3D10_TO_STR(D3D10_SVT_RENDERTARGETVIEW);
305 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCILVIEW);
306 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMS);
307 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMSARRAY);
308 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBEARRAY);
309 default:
310 FIXME("Unrecognised D3D10_SHADER_VARIABLE_TYPE %#x.\n", t);
311 return "unrecognised";
315 #undef WINE_D3D10_TO_STR
317 static void read_dword(const char **ptr, DWORD *d)
319 memcpy(d, *ptr, sizeof(*d));
320 *ptr += sizeof(*d);
323 static void write_dword(char **ptr, DWORD d)
325 memcpy(*ptr, &d, sizeof(d));
326 *ptr += sizeof(d);
329 static BOOL require_space(size_t offset, size_t count, size_t size, size_t data_size)
331 return !count || (data_size - offset) / count >= size;
334 static void skip_dword_unknown(const char *location, const char **ptr, unsigned int count)
336 unsigned int i;
337 DWORD d;
339 FIXME("Skipping %u unknown DWORDs (%s):\n", count, location);
340 for (i = 0; i < count; ++i)
342 read_dword(ptr, &d);
343 FIXME("\t0x%08x\n", d);
347 static void write_dword_unknown(char **ptr, DWORD d)
349 FIXME("Writing unknown DWORD 0x%08x\n", d);
350 write_dword(ptr, d);
353 static HRESULT parse_dxbc(const char *data, SIZE_T data_size,
354 HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx)
356 const char *ptr = data;
357 HRESULT hr = S_OK;
358 DWORD chunk_count;
359 DWORD total_size;
360 unsigned int i;
361 DWORD version;
362 DWORD tag;
364 if (!data)
366 WARN("No data supplied.\n");
367 return E_FAIL;
370 read_dword(&ptr, &tag);
371 TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
373 if (tag != TAG_DXBC)
375 WARN("Wrong tag.\n");
376 return E_FAIL;
379 skip_dword_unknown("DXBC checksum", &ptr, 4);
381 read_dword(&ptr, &version);
382 TRACE("version: %#x.\n", version);
383 if (version != 0x00000001)
385 WARN("Got unexpected DXBC version %#x.\n", version);
386 return E_FAIL;
389 read_dword(&ptr, &total_size);
390 TRACE("total size: %#x\n", total_size);
392 if (data_size != total_size)
394 WARN("Wrong size supplied.\n");
395 return E_FAIL;
398 read_dword(&ptr, &chunk_count);
399 TRACE("chunk count: %#x\n", chunk_count);
401 for (i = 0; i < chunk_count; ++i)
403 DWORD chunk_tag, chunk_size;
404 const char *chunk_ptr;
405 DWORD chunk_offset;
407 read_dword(&ptr, &chunk_offset);
408 TRACE("chunk %u at offset %#x\n", i, chunk_offset);
410 if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size))
412 WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size);
413 return E_FAIL;
416 chunk_ptr = data + chunk_offset;
418 read_dword(&chunk_ptr, &chunk_tag);
419 read_dword(&chunk_ptr, &chunk_size);
421 if (!require_space(chunk_ptr - data, 1, chunk_size, data_size))
423 WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n",
424 chunk_size, data_size, chunk_offset);
425 return E_FAIL;
428 if (FAILED(hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx)))
429 break;
432 return hr;
435 static BOOL fx10_get_string(const char *data, size_t data_size, DWORD offset, const char **s, size_t *l)
437 size_t len, max_len;
439 if (offset >= data_size)
441 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
442 return FALSE;
445 max_len = data_size - offset;
446 if (!(len = strnlen(data + offset, max_len)))
448 *s = NULL;
449 *l = 0;
450 return TRUE;
453 if (len == max_len)
454 return FALSE;
456 *s = data + offset;
457 *l = ++len;
459 return TRUE;
462 static BOOL fx10_copy_string(const char *data, size_t data_size, DWORD offset, char **s)
464 const char *p;
465 size_t len;
467 if (!fx10_get_string(data, data_size, offset, &p, &len))
468 return FALSE;
470 if (!p)
472 *s = NULL;
473 return TRUE;
476 if (!(*s = heap_alloc(len)))
478 ERR("Failed to allocate string memory.\n");
479 return FALSE;
482 memcpy(*s, p, len);
484 return TRUE;
487 static BOOL copy_name(const char *ptr, char **name)
489 size_t name_len;
491 if (!ptr) return TRUE;
493 name_len = strlen(ptr) + 1;
494 if (name_len == 1)
496 return TRUE;
499 if (!(*name = heap_alloc(name_len)))
501 ERR("Failed to allocate name memory.\n");
502 return FALSE;
505 memcpy(*name, ptr, name_len);
507 return TRUE;
510 static const char *shader_get_string(const char *data, size_t data_size, DWORD offset)
512 const char *s;
513 size_t l;
515 if (!fx10_get_string(data, data_size, offset, &s, &l))
516 return NULL;
518 return l ? s : "";
521 static HRESULT shader_parse_signature(const char *data, DWORD data_size, struct d3d10_effect_shader_signature *s)
523 D3D10_SIGNATURE_PARAMETER_DESC *e;
524 const char *ptr = data;
525 unsigned int i;
526 DWORD count;
528 if (!require_space(0, 2, sizeof(DWORD), data_size))
530 WARN("Invalid data size %#x.\n", data_size);
531 return E_INVALIDARG;
534 read_dword(&ptr, &count);
535 TRACE("%u elements\n", count);
537 skip_dword_unknown("shader signature", &ptr, 1);
539 if (!require_space(ptr - data, count, 6 * sizeof(DWORD), data_size))
541 WARN("Invalid count %#x (data size %#x).\n", count, data_size);
542 return E_INVALIDARG;
545 if (!(e = heap_calloc(count, sizeof(*e))))
547 ERR("Failed to allocate signature memory.\n");
548 return E_OUTOFMEMORY;
551 for (i = 0; i < count; ++i)
553 UINT name_offset;
554 UINT mask;
556 read_dword(&ptr, &name_offset);
557 if (!(e[i].SemanticName = shader_get_string(data, data_size, name_offset)))
559 WARN("Invalid name offset %#x (data size %#x).\n", name_offset, data_size);
560 heap_free(e);
561 return E_INVALIDARG;
563 read_dword(&ptr, &e[i].SemanticIndex);
564 read_dword(&ptr, &e[i].SystemValueType);
565 read_dword(&ptr, &e[i].ComponentType);
566 read_dword(&ptr, &e[i].Register);
567 read_dword(&ptr, &mask);
569 e[i].ReadWriteMask = mask >> 8;
570 e[i].Mask = mask & 0xff;
572 TRACE("semantic: %s, semantic idx: %u, sysval_semantic %#x, "
573 "type %u, register idx: %u, use_mask %#x, input_mask %#x\n",
574 debugstr_a(e[i].SemanticName), e[i].SemanticIndex, e[i].SystemValueType,
575 e[i].ComponentType, e[i].Register, e[i].Mask, e[i].ReadWriteMask);
578 s->elements = e;
579 s->element_count = count;
581 return S_OK;
584 static void shader_free_signature(struct d3d10_effect_shader_signature *s)
586 heap_free(s->signature);
587 heap_free(s->elements);
590 static HRESULT shader_chunk_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
592 struct d3d10_effect_shader_variable *s = ctx;
593 HRESULT hr;
595 TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
597 TRACE("chunk size: %#x\n", data_size);
599 switch(tag)
601 case TAG_ISGN:
602 case TAG_OSGN:
604 /* 32 (DXBC header) + 1 * 4 (chunk index) + 2 * 4 (chunk header) + data_size (chunk data) */
605 UINT size = 44 + data_size;
606 struct d3d10_effect_shader_signature *sig;
607 char *ptr;
609 if (tag == TAG_ISGN) sig = &s->input_signature;
610 else sig = &s->output_signature;
612 if (!(sig->signature = heap_alloc_zero(size)))
614 ERR("Failed to allocate input signature data\n");
615 return E_OUTOFMEMORY;
617 sig->signature_size = size;
619 ptr = sig->signature;
621 write_dword(&ptr, TAG_DXBC);
623 /* signature(?) */
624 write_dword_unknown(&ptr, 0);
625 write_dword_unknown(&ptr, 0);
626 write_dword_unknown(&ptr, 0);
627 write_dword_unknown(&ptr, 0);
629 /* seems to be always 1 */
630 write_dword_unknown(&ptr, 1);
632 /* DXBC size */
633 write_dword(&ptr, size);
635 /* chunk count */
636 write_dword(&ptr, 1);
638 /* chunk index */
639 write_dword(&ptr, (ptr - sig->signature) + 4);
641 /* chunk */
642 write_dword(&ptr, tag);
643 write_dword(&ptr, data_size);
644 memcpy(ptr, data, data_size);
646 hr = shader_parse_signature(ptr, data_size, sig);
647 if (FAILED(hr))
649 ERR("Failed to parse shader, hr %#x\n", hr);
650 shader_free_signature(sig);
653 break;
656 default:
657 FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag, 4));
658 break;
661 return S_OK;
664 static HRESULT get_fx10_shader_resources(struct d3d10_effect_variable *v, const void *data, size_t data_size)
666 struct d3d10_effect_shader_variable *sv = &v->u.shader;
667 struct d3d10_effect_shader_resource *sr;
668 D3D10_SHADER_INPUT_BIND_DESC bind_desc;
669 ID3D10ShaderReflection *reflection;
670 struct d3d10_effect_variable *var;
671 D3D10_SHADER_DESC desc;
672 unsigned int i, y;
673 HRESULT hr;
675 if (FAILED(hr = D3D10ReflectShader(data, data_size, &reflection)))
676 return hr;
678 reflection->lpVtbl->GetDesc(reflection, &desc);
679 sv->resource_count = desc.BoundResources;
681 if (!(sv->resources = heap_calloc(sv->resource_count, sizeof(*sv->resources))))
683 ERR("Failed to allocate shader resource binding information memory.\n");
684 reflection->lpVtbl->Release(reflection);
685 return E_OUTOFMEMORY;
688 for (i = 0; i < desc.BoundResources; ++i)
690 reflection->lpVtbl->GetResourceBindingDesc(reflection, i, &bind_desc);
691 sr = &sv->resources[i];
693 sr->in_type = bind_desc.Type;
694 sr->bind_point = bind_desc.BindPoint;
695 sr->bind_count = bind_desc.BindCount;
697 switch (bind_desc.Type)
699 case D3D10_SIT_CBUFFER:
700 case D3D10_SIT_TBUFFER:
701 for (y = 0; y < v->effect->local_buffer_count; ++y)
703 var = &v->effect->local_buffers[y];
705 if (!strcmp(bind_desc.Name, var->name))
707 sr->variable = var;
708 break;
711 break;
713 case D3D10_SIT_SAMPLER:
714 case D3D10_SIT_TEXTURE:
715 for (y = 0; y < v->effect->local_variable_count; ++y)
717 var = &v->effect->local_variables[y];
719 if (!strcmp(bind_desc.Name, var->name))
721 sr->variable = var;
722 break;
725 break;
727 default:
728 break;
731 if (!sr->variable)
733 WARN("Failed to find shader resource.\n");
734 reflection->lpVtbl->Release(reflection);
735 return E_FAIL;
739 return S_OK;
742 static HRESULT parse_fx10_shader(const char *data, size_t data_size, DWORD offset, struct d3d10_effect_variable *v)
744 ID3D10Device *device = v->effect->device;
745 DWORD dxbc_size;
746 const char *ptr;
747 HRESULT hr;
749 if (v->effect->used_shader_current >= v->effect->used_shader_count)
751 WARN("Invalid shader? Used shader current(%u) >= used shader count(%u)\n", v->effect->used_shader_current, v->effect->used_shader_count);
752 return E_FAIL;
755 v->effect->used_shaders[v->effect->used_shader_current] = v;
756 ++v->effect->used_shader_current;
758 if (offset >= data_size || !require_space(offset, 1, sizeof(dxbc_size), data_size))
760 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
761 return E_FAIL;
764 ptr = data + offset;
765 read_dword(&ptr, &dxbc_size);
766 TRACE("dxbc size: %#x\n", dxbc_size);
768 if (!require_space(ptr - data, 1, dxbc_size, data_size))
770 WARN("Invalid dxbc size %#x (data size %#lx, offset %#x).\n", offset, (long)data_size, offset);
771 return E_FAIL;
774 /* We got a shader VertexShader vs = NULL, so it is fine to skip this. */
775 if (!dxbc_size) return S_OK;
777 if (FAILED(hr = get_fx10_shader_resources(v, ptr, dxbc_size)))
778 return hr;
780 switch (v->type->basetype)
782 case D3D10_SVT_VERTEXSHADER:
783 hr = ID3D10Device_CreateVertexShader(device, ptr, dxbc_size, &v->u.shader.shader.vs);
784 if (FAILED(hr)) return hr;
785 break;
787 case D3D10_SVT_PIXELSHADER:
788 hr = ID3D10Device_CreatePixelShader(device, ptr, dxbc_size, &v->u.shader.shader.ps);
789 if (FAILED(hr)) return hr;
790 break;
792 case D3D10_SVT_GEOMETRYSHADER:
793 hr = ID3D10Device_CreateGeometryShader(device, ptr, dxbc_size, &v->u.shader.shader.gs);
794 if (FAILED(hr)) return hr;
795 break;
797 default:
798 ERR("This should not happen!\n");
799 return E_FAIL;
802 return parse_dxbc(ptr, dxbc_size, shader_chunk_handler, &v->u.shader);
805 static D3D10_SHADER_VARIABLE_CLASS d3d10_variable_class(DWORD c, BOOL is_column_major)
807 switch (c)
809 case 1: return D3D10_SVC_SCALAR;
810 case 2: return D3D10_SVC_VECTOR;
811 case 3: if (is_column_major) return D3D10_SVC_MATRIX_COLUMNS;
812 else return D3D10_SVC_MATRIX_ROWS;
813 default:
814 FIXME("Unknown variable class %#x.\n", c);
815 return 0;
819 static D3D10_SHADER_VARIABLE_TYPE d3d10_variable_type(DWORD t, BOOL is_object)
821 if(is_object)
823 switch (t)
825 case 1: return D3D10_SVT_STRING;
826 case 2: return D3D10_SVT_BLEND;
827 case 3: return D3D10_SVT_DEPTHSTENCIL;
828 case 4: return D3D10_SVT_RASTERIZER;
829 case 5: return D3D10_SVT_PIXELSHADER;
830 case 6: return D3D10_SVT_VERTEXSHADER;
831 case 7: return D3D10_SVT_GEOMETRYSHADER;
833 case 10: return D3D10_SVT_TEXTURE1D;
834 case 11: return D3D10_SVT_TEXTURE1DARRAY;
835 case 12: return D3D10_SVT_TEXTURE2D;
836 case 13: return D3D10_SVT_TEXTURE2DARRAY;
837 case 14: return D3D10_SVT_TEXTURE2DMS;
838 case 15: return D3D10_SVT_TEXTURE2DMSARRAY;
839 case 16: return D3D10_SVT_TEXTURE3D;
840 case 17: return D3D10_SVT_TEXTURECUBE;
842 case 19: return D3D10_SVT_RENDERTARGETVIEW;
843 case 20: return D3D10_SVT_DEPTHSTENCILVIEW;
844 case 21: return D3D10_SVT_SAMPLER;
845 case 22: return D3D10_SVT_BUFFER;
846 default:
847 FIXME("Unknown variable type %#x.\n", t);
848 return D3D10_SVT_VOID;
851 else
853 switch (t)
855 case 1: return D3D10_SVT_FLOAT;
856 case 2: return D3D10_SVT_INT;
857 case 3: return D3D10_SVT_UINT;
858 case 4: return D3D10_SVT_BOOL;
859 default:
860 FIXME("Unknown variable type %#x.\n", t);
861 return D3D10_SVT_VOID;
866 static HRESULT parse_fx10_type(const char *data, size_t data_size, DWORD offset, struct d3d10_effect_type *t)
868 const char *ptr;
869 DWORD unknown0;
870 DWORD typeinfo;
871 unsigned int i;
873 if (offset >= data_size || !require_space(offset, 6, sizeof(DWORD), data_size))
875 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
876 return E_FAIL;
879 ptr = data + offset;
880 read_dword(&ptr, &offset);
881 TRACE("Type name at offset %#x.\n", offset);
883 if (!fx10_copy_string(data, data_size, offset, &t->name))
885 ERR("Failed to copy name.\n");
886 return E_OUTOFMEMORY;
888 TRACE("Type name: %s.\n", debugstr_a(t->name));
890 read_dword(&ptr, &unknown0);
891 TRACE("Unknown 0: %u.\n", unknown0);
893 read_dword(&ptr, &t->element_count);
894 TRACE("Element count: %u.\n", t->element_count);
896 read_dword(&ptr, &t->size_unpacked);
897 TRACE("Unpacked size: %#x.\n", t->size_unpacked);
899 read_dword(&ptr, &t->stride);
900 TRACE("Stride: %#x.\n", t->stride);
902 read_dword(&ptr, &t->size_packed);
903 TRACE("Packed size %#x.\n", t->size_packed);
905 switch (unknown0)
907 case 1:
908 if (!require_space(ptr - data, 1, sizeof(typeinfo), data_size))
910 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
911 return E_FAIL;
914 read_dword(&ptr, &typeinfo);
915 t->member_count = 0;
916 t->column_count = (typeinfo & D3D10_FX10_TYPE_COLUMN_MASK) >> D3D10_FX10_TYPE_COLUMN_SHIFT;
917 t->row_count = (typeinfo & D3D10_FX10_TYPE_ROW_MASK) >> D3D10_FX10_TYPE_ROW_SHIFT;
918 t->basetype = d3d10_variable_type((typeinfo & D3D10_FX10_TYPE_BASETYPE_MASK) >> D3D10_FX10_TYPE_BASETYPE_SHIFT, FALSE);
919 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);
921 TRACE("Type description: %#x.\n", typeinfo);
922 TRACE("\tcolumns: %u.\n", t->column_count);
923 TRACE("\trows: %u.\n", t->row_count);
924 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t->basetype));
925 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t->type_class));
926 TRACE("\tunknown bits: %#x.\n", typeinfo & ~(D3D10_FX10_TYPE_COLUMN_MASK | D3D10_FX10_TYPE_ROW_MASK
927 | D3D10_FX10_TYPE_BASETYPE_MASK | D3D10_FX10_TYPE_CLASS_MASK | D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK));
928 break;
930 case 2:
931 TRACE("Type is an object.\n");
933 if (!require_space(ptr - data, 1, sizeof(typeinfo), data_size))
935 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
936 return E_FAIL;
939 read_dword(&ptr, &typeinfo);
940 t->member_count = 0;
941 t->column_count = 0;
942 t->row_count = 0;
943 t->basetype = d3d10_variable_type(typeinfo, TRUE);
944 t->type_class = D3D10_SVC_OBJECT;
946 TRACE("Type description: %#x.\n", typeinfo);
947 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t->basetype));
948 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t->type_class));
949 break;
951 case 3:
952 TRACE("Type is a structure.\n");
954 if (!require_space(ptr - data, 1, sizeof(t->member_count), data_size))
956 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
957 return E_FAIL;
960 read_dword(&ptr, &t->member_count);
961 TRACE("Member count: %u.\n", t->member_count);
963 t->column_count = 0;
964 t->row_count = 0;
965 t->basetype = 0;
966 t->type_class = D3D10_SVC_STRUCT;
968 if (!(t->members = heap_calloc(t->member_count, sizeof(*t->members))))
970 ERR("Failed to allocate members memory.\n");
971 return E_OUTOFMEMORY;
974 if (!require_space(ptr - data, t->member_count, 4 * sizeof(DWORD), data_size))
976 WARN("Invalid member count %#x (data size %#lx, offset %#x).\n",
977 t->member_count, (long)data_size, offset);
978 return E_FAIL;
981 for (i = 0; i < t->member_count; ++i)
983 struct d3d10_effect_type_member *typem = &t->members[i];
985 read_dword(&ptr, &offset);
986 TRACE("Member name at offset %#x.\n", offset);
988 if (!fx10_copy_string(data, data_size, offset, &typem->name))
990 ERR("Failed to copy name.\n");
991 return E_OUTOFMEMORY;
993 TRACE("Member name: %s.\n", debugstr_a(typem->name));
995 read_dword(&ptr, &offset);
996 TRACE("Member semantic at offset %#x.\n", offset);
998 if (!fx10_copy_string(data, data_size, offset, &typem->semantic))
1000 ERR("Failed to copy semantic.\n");
1001 return E_OUTOFMEMORY;
1003 TRACE("Member semantic: %s.\n", debugstr_a(typem->semantic));
1005 read_dword(&ptr, &typem->buffer_offset);
1006 TRACE("Member offset in struct: %#x.\n", typem->buffer_offset);
1008 read_dword(&ptr, &offset);
1009 TRACE("Member type info at offset %#x.\n", offset);
1011 if (!(typem->type = get_fx10_type(t->effect, data, data_size, offset)))
1013 ERR("Failed to get variable type.\n");
1014 return E_FAIL;
1017 break;
1019 default:
1020 FIXME("Unhandled case %#x.\n", unknown0);
1021 return E_FAIL;
1024 if (t->element_count)
1026 TRACE("Elementtype for type at offset: %#x\n", t->id);
1028 /* allocate elementtype - we need only one, because all elements have the same type */
1029 if (!(t->elementtype = heap_alloc_zero(sizeof(*t->elementtype))))
1031 ERR("Failed to allocate members memory.\n");
1032 return E_OUTOFMEMORY;
1035 /* create a copy of the original type with some minor changes */
1036 t->elementtype->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
1037 t->elementtype->effect = t->effect;
1039 if (!copy_name(t->name, &t->elementtype->name))
1041 ERR("Failed to copy name.\n");
1042 return E_OUTOFMEMORY;
1044 TRACE("\tType name: %s.\n", debugstr_a(t->elementtype->name));
1046 t->elementtype->element_count = 0;
1047 TRACE("\tElement count: %u.\n", t->elementtype->element_count);
1050 * Not sure if this calculation is 100% correct, but a test
1051 * shows that these values work.
1053 t->elementtype->size_unpacked = t->size_packed / t->element_count;
1054 TRACE("\tUnpacked size: %#x.\n", t->elementtype->size_unpacked);
1056 t->elementtype->stride = t->stride;
1057 TRACE("\tStride: %#x.\n", t->elementtype->stride);
1059 t->elementtype->size_packed = t->size_packed / t->element_count;
1060 TRACE("\tPacked size: %#x.\n", t->elementtype->size_packed);
1062 t->elementtype->member_count = t->member_count;
1063 TRACE("\tMember count: %u.\n", t->elementtype->member_count);
1065 t->elementtype->column_count = t->column_count;
1066 TRACE("\tColumns: %u.\n", t->elementtype->column_count);
1068 t->elementtype->row_count = t->row_count;
1069 TRACE("\tRows: %u.\n", t->elementtype->row_count);
1071 t->elementtype->basetype = t->basetype;
1072 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(t->elementtype->basetype));
1074 t->elementtype->type_class = t->type_class;
1075 TRACE("\tClass: %s.\n", debug_d3d10_shader_variable_class(t->elementtype->type_class));
1077 t->elementtype->members = t->members;
1080 return S_OK;
1083 static struct d3d10_effect_type *get_fx10_type(struct d3d10_effect *effect,
1084 const char *data, size_t data_size, DWORD offset)
1086 struct d3d10_effect_type *type;
1087 struct wine_rb_entry *entry;
1088 HRESULT hr;
1090 entry = wine_rb_get(&effect->types, &offset);
1091 if (entry)
1093 TRACE("Returning existing type.\n");
1094 return WINE_RB_ENTRY_VALUE(entry, struct d3d10_effect_type, entry);
1097 if (!(type = heap_alloc_zero(sizeof(*type))))
1099 ERR("Failed to allocate type memory.\n");
1100 return NULL;
1103 type->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
1104 type->id = offset;
1105 type->effect = effect;
1106 if (FAILED(hr = parse_fx10_type(data, data_size, offset, type)))
1108 ERR("Failed to parse type info, hr %#x.\n", hr);
1109 heap_free(type);
1110 return NULL;
1113 if (wine_rb_put(&effect->types, &offset, &type->entry) == -1)
1115 ERR("Failed to insert type entry.\n");
1116 heap_free(type);
1117 return NULL;
1120 return type;
1123 static void set_variable_vtbl(struct d3d10_effect_variable *v)
1125 const ID3D10EffectVariableVtbl **vtbl = &v->ID3D10EffectVariable_iface.lpVtbl;
1127 switch (v->type->type_class)
1129 case D3D10_SVC_SCALAR:
1130 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl;
1131 break;
1133 case D3D10_SVC_VECTOR:
1134 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl;
1135 break;
1137 case D3D10_SVC_MATRIX_ROWS:
1138 case D3D10_SVC_MATRIX_COLUMNS:
1139 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl;
1140 break;
1142 case D3D10_SVC_STRUCT:
1143 *vtbl = &d3d10_effect_variable_vtbl;
1144 break;
1146 case D3D10_SVC_OBJECT:
1147 switch(v->type->basetype)
1149 case D3D10_SVT_STRING:
1150 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl;
1151 break;
1153 case D3D10_SVT_TEXTURE1D:
1154 case D3D10_SVT_TEXTURE1DARRAY:
1155 case D3D10_SVT_TEXTURE2D:
1156 case D3D10_SVT_TEXTURE2DARRAY:
1157 case D3D10_SVT_TEXTURE2DMS:
1158 case D3D10_SVT_TEXTURE2DMSARRAY:
1159 case D3D10_SVT_TEXTURE3D:
1160 case D3D10_SVT_TEXTURECUBE:
1161 case D3D10_SVT_BUFFER: /* Either resource or constant buffer. */
1162 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl;
1163 break;
1165 case D3D10_SVT_RENDERTARGETVIEW:
1166 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl;
1167 break;
1169 case D3D10_SVT_DEPTHSTENCILVIEW:
1170 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl;
1171 break;
1173 case D3D10_SVT_DEPTHSTENCIL:
1174 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl;
1175 break;
1177 case D3D10_SVT_VERTEXSHADER:
1178 case D3D10_SVT_GEOMETRYSHADER:
1179 case D3D10_SVT_PIXELSHADER:
1180 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl;
1181 break;
1183 case D3D10_SVT_BLEND:
1184 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl;
1185 break;
1187 case D3D10_SVT_RASTERIZER:
1188 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl;
1189 break;
1191 case D3D10_SVT_SAMPLER:
1192 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl;
1193 break;
1195 default:
1196 FIXME("Unhandled basetype %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
1197 *vtbl = &d3d10_effect_variable_vtbl;
1198 break;
1200 break;
1202 default:
1203 FIXME("Unhandled type class %s.\n", debug_d3d10_shader_variable_class(v->type->type_class));
1204 *vtbl = &d3d10_effect_variable_vtbl;
1205 break;
1209 static HRESULT copy_variableinfo_from_type(struct d3d10_effect_variable *v)
1211 unsigned int i;
1212 HRESULT hr;
1214 if (v->type->member_count)
1216 if (!(v->members = heap_calloc(v->type->member_count, sizeof(*v->members))))
1218 ERR("Failed to allocate members memory.\n");
1219 return E_OUTOFMEMORY;
1222 for (i = 0; i < v->type->member_count; ++i)
1224 struct d3d10_effect_variable *var = &v->members[i];
1225 struct d3d10_effect_type_member *typem = &v->type->members[i];
1227 var->buffer = v->buffer;
1228 var->effect = v->effect;
1229 var->type = typem->type;
1230 set_variable_vtbl(var);
1232 if (!copy_name(typem->name, &var->name))
1234 ERR("Failed to copy name.\n");
1235 return E_OUTOFMEMORY;
1237 TRACE("Variable name: %s.\n", debugstr_a(var->name));
1239 if (!copy_name(typem->semantic, &var->semantic))
1241 ERR("Failed to copy name.\n");
1242 return E_OUTOFMEMORY;
1244 TRACE("Variable semantic: %s.\n", debugstr_a(var->semantic));
1246 var->buffer_offset = v->buffer_offset + typem->buffer_offset;
1247 TRACE("Variable buffer offset: %u.\n", var->buffer_offset);
1249 hr = copy_variableinfo_from_type(var);
1250 if (FAILED(hr)) return hr;
1254 if (v->type->element_count)
1256 unsigned int bufferoffset = v->buffer_offset;
1258 if (!(v->elements = heap_calloc(v->type->element_count, sizeof(*v->elements))))
1260 ERR("Failed to allocate elements memory.\n");
1261 return E_OUTOFMEMORY;
1264 for (i = 0; i < v->type->element_count; ++i)
1266 struct d3d10_effect_variable *var = &v->elements[i];
1268 var->buffer = v->buffer;
1269 var->effect = v->effect;
1270 var->type = v->type->elementtype;
1271 set_variable_vtbl(var);
1273 if (!copy_name(v->name, &var->name))
1275 ERR("Failed to copy name.\n");
1276 return E_OUTOFMEMORY;
1278 TRACE("Variable name: %s.\n", debugstr_a(var->name));
1280 if (!copy_name(v->semantic, &var->semantic))
1282 ERR("Failed to copy name.\n");
1283 return E_OUTOFMEMORY;
1285 TRACE("Variable semantic: %s.\n", debugstr_a(var->semantic));
1287 if (i != 0)
1289 bufferoffset += v->type->stride;
1291 var->buffer_offset = bufferoffset;
1292 TRACE("Variable buffer offset: %u.\n", var->buffer_offset);
1294 hr = copy_variableinfo_from_type(var);
1295 if (FAILED(hr)) return hr;
1299 return S_OK;
1302 static HRESULT parse_fx10_variable_head(const char *data, size_t data_size,
1303 const char **ptr, struct d3d10_effect_variable *v)
1305 DWORD offset;
1307 read_dword(ptr, &offset);
1308 TRACE("Variable name at offset %#x.\n", offset);
1310 if (!fx10_copy_string(data, data_size, offset, &v->name))
1312 ERR("Failed to copy name.\n");
1313 return E_OUTOFMEMORY;
1315 TRACE("Variable name: %s.\n", debugstr_a(v->name));
1317 read_dword(ptr, &offset);
1318 TRACE("Variable type info at offset %#x.\n", offset);
1320 if (!(v->type = get_fx10_type(v->effect, data, data_size, offset)))
1322 ERR("Failed to get variable type.\n");
1323 return E_FAIL;
1325 set_variable_vtbl(v);
1327 return copy_variableinfo_from_type(v);
1330 static HRESULT parse_fx10_annotation(const char *data, size_t data_size,
1331 const char **ptr, struct d3d10_effect_variable *a)
1333 DWORD offset;
1334 HRESULT hr;
1336 if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, a)))
1337 return hr;
1339 read_dword(ptr, &offset);
1340 TRACE("Annotation value is at offset %#x.\n", offset);
1342 switch (a->type->basetype)
1344 case D3D10_SVT_STRING:
1345 if (!fx10_copy_string(data, data_size, offset, (char **)&a->u.buffer.local_buffer))
1347 ERR("Failed to copy name.\n");
1348 return E_OUTOFMEMORY;
1350 break;
1352 default:
1353 FIXME("Unhandled object type %#x.\n", a->type->basetype);
1356 /* mark the variable as annotation */
1357 a->flag = D3D10_EFFECT_VARIABLE_ANNOTATION;
1359 return S_OK;
1362 static HRESULT parse_fx10_anonymous_shader(struct d3d10_effect *e, struct d3d10_effect_anonymous_shader *s,
1363 enum d3d10_effect_object_type otype)
1365 struct d3d10_effect_variable *v = &s->shader;
1366 struct d3d10_effect_type *t = &s->type;
1367 const char *shader = NULL;
1369 switch (otype)
1371 case D3D10_EOT_VERTEXSHADER:
1372 shader = "vertexshader";
1373 t->basetype = D3D10_SVT_VERTEXSHADER;
1374 break;
1376 case D3D10_EOT_PIXELSHADER:
1377 shader = "pixelshader";
1378 t->basetype = D3D10_SVT_PIXELSHADER;
1379 break;
1381 case D3D10_EOT_GEOMETRYSHADER:
1382 shader = "geometryshader";
1383 t->basetype = D3D10_SVT_GEOMETRYSHADER;
1384 break;
1386 default:
1387 FIXME("Unhandled object type %#x.\n", otype);
1388 return E_FAIL;
1391 if (!copy_name(shader, &t->name))
1393 ERR("Failed to copy name.\n");
1394 return E_OUTOFMEMORY;
1396 TRACE("Type name: %s.\n", debugstr_a(t->name));
1398 t->type_class = D3D10_SVC_OBJECT;
1400 t->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
1402 v->type = t;
1403 v->effect = e;
1404 set_variable_vtbl(v);
1406 if (!copy_name("$Anonymous", &v->name))
1408 ERR("Failed to copy semantic.\n");
1409 return E_OUTOFMEMORY;
1411 TRACE("Variable name: %s.\n", debugstr_a(v->name));
1413 if (!copy_name(NULL, &v->semantic))
1415 ERR("Failed to copy semantic.\n");
1416 return E_OUTOFMEMORY;
1418 TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
1420 return S_OK;
1423 static const struct d3d10_effect_state_property_info *get_property_info(UINT id)
1425 unsigned int i;
1427 for (i = 0; i < ARRAY_SIZE(property_info); ++i)
1429 if (property_info[i].id == id)
1430 return &property_info[i];
1433 return NULL;
1436 static const struct d3d10_effect_state_storage_info *get_storage_info(D3D_SHADER_VARIABLE_TYPE id)
1438 unsigned int i;
1440 for (i = 0; i < ARRAY_SIZE(d3d10_effect_state_storage_info); ++i)
1442 if (d3d10_effect_state_storage_info[i].id == id)
1443 return &d3d10_effect_state_storage_info[i];
1446 return NULL;
1449 static BOOL read_float_value(DWORD value, D3D_SHADER_VARIABLE_TYPE in_type, float *out_data, UINT idx)
1451 switch (in_type)
1453 case D3D10_SVT_FLOAT:
1454 out_data[idx] = *(float *)&value;
1455 return TRUE;
1457 case D3D10_SVT_INT:
1458 out_data[idx] = (INT)value;
1459 return TRUE;
1461 default:
1462 FIXME("Unhandled in_type %#x.\n", in_type);
1463 return FALSE;
1467 static BOOL read_int32_value(DWORD value, D3D_SHADER_VARIABLE_TYPE in_type, INT *out_data, UINT idx)
1469 switch (in_type)
1471 case D3D10_SVT_FLOAT:
1472 out_data[idx] = *(float *)&value;
1473 return TRUE;
1475 case D3D10_SVT_INT:
1476 case D3D10_SVT_UINT:
1477 case D3D10_SVT_BOOL:
1478 out_data[idx] = value;
1479 return TRUE;
1481 default:
1482 FIXME("Unhandled in_type %#x.\n", in_type);
1483 return FALSE;
1487 static BOOL read_int8_value(DWORD value, D3D_SHADER_VARIABLE_TYPE in_type, INT8 *out_data, UINT idx)
1489 switch (in_type)
1491 case D3D10_SVT_INT:
1492 case D3D10_SVT_UINT:
1493 out_data[idx] = value;
1494 return TRUE;
1496 default:
1497 FIXME("Unhandled in_type %#x.\n", in_type);
1498 return FALSE;
1502 static BOOL read_value_list(const char *data, size_t data_size, DWORD offset,
1503 D3D_SHADER_VARIABLE_TYPE out_type, UINT out_base, UINT out_size, void *out_data)
1505 D3D_SHADER_VARIABLE_TYPE in_type;
1506 const char *ptr;
1507 DWORD t, value;
1508 DWORD count, i;
1510 if (offset >= data_size || !require_space(offset, 1, sizeof(count), data_size))
1512 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1513 return FALSE;
1516 ptr = data + offset;
1517 read_dword(&ptr, &count);
1518 if (count != out_size)
1519 return FALSE;
1521 if (!require_space(ptr - data, count, 2 * sizeof(DWORD), data_size))
1523 WARN("Invalid value count %#x (offset %#x, data size %#lx).\n", count, offset, (long)data_size);
1524 return FALSE;
1527 TRACE("%u values:\n", count);
1528 for (i = 0; i < count; ++i)
1530 UINT out_idx = out_base * out_size + i;
1532 read_dword(&ptr, &t);
1533 read_dword(&ptr, &value);
1535 in_type = d3d10_variable_type(t, FALSE);
1536 TRACE("\t%s: %#x.\n", debug_d3d10_shader_variable_type(in_type), value);
1538 switch (out_type)
1540 case D3D10_SVT_FLOAT:
1541 if (!read_float_value(value, in_type, out_data, out_idx))
1542 return FALSE;
1543 break;
1545 case D3D10_SVT_INT:
1546 case D3D10_SVT_UINT:
1547 case D3D10_SVT_BOOL:
1548 if (!read_int32_value(value, in_type, out_data, out_idx))
1549 return FALSE;
1550 break;
1552 case D3D10_SVT_UINT8:
1553 if (!read_int8_value(value, in_type, out_data, out_idx))
1554 return FALSE;
1555 break;
1557 default:
1558 FIXME("Unhandled out_type %#x.\n", out_type);
1559 return FALSE;
1563 return TRUE;
1566 static BOOL parse_fx10_state_group(const char *data, size_t data_size,
1567 const char **ptr, D3D_SHADER_VARIABLE_TYPE container_type, void *container)
1569 const struct d3d10_effect_state_property_info *property_info;
1570 UINT value_offset;
1571 unsigned int i;
1572 DWORD count;
1573 UINT idx;
1574 UINT id;
1576 read_dword(ptr, &count);
1577 TRACE("Property count: %#x.\n", count);
1579 for (i = 0; i < count; ++i)
1581 read_dword(ptr, &id);
1582 read_dword(ptr, &idx);
1583 skip_dword_unknown("read property", ptr, 1);
1584 read_dword(ptr, &value_offset);
1586 if (!(property_info = get_property_info(id)))
1588 FIXME("Failed to find property info for property %#x.\n", id);
1589 return FALSE;
1592 TRACE("Property %s[%#x] = value list @ offset %#x.\n",
1593 property_info->name, idx, value_offset);
1595 if (property_info->container_type != container_type)
1597 ERR("Invalid container type %#x for property %#x.\n", container_type, id);
1598 return FALSE;
1601 if (idx >= property_info->count)
1603 ERR("Invalid index %#x for property %#x.\n", idx, id);
1604 return FALSE;
1607 if (!read_value_list(data, data_size, value_offset, property_info->type, idx,
1608 property_info->size, (char *)container + property_info->offset))
1610 ERR("Failed to read values for property %#x.\n", id);
1611 return FALSE;
1615 return TRUE;
1618 static HRESULT parse_fx10_object(const char *data, size_t data_size,
1619 const char **ptr, struct d3d10_effect_object *o)
1621 ID3D10EffectVariable *variable = &null_variable.ID3D10EffectVariable_iface;
1622 const char *data_ptr = NULL;
1623 DWORD offset;
1624 enum d3d10_effect_object_operation operation;
1625 HRESULT hr;
1626 struct d3d10_effect *effect = o->pass->technique->effect;
1627 ID3D10Effect *e = &effect->ID3D10Effect_iface;
1628 struct d3d10_effect_variable *v;
1629 DWORD tmp, variable_idx = 0;
1630 const char *name;
1631 size_t name_len;
1633 if (!require_space(*ptr - data, 4, sizeof(DWORD), data_size))
1635 WARN("Invalid offset %#lx (data size %#lx).\n", (long)(*ptr - data), (long)data_size);
1636 return E_FAIL;
1639 read_dword(ptr, &o->type);
1640 TRACE("Effect object is of type %#x.\n", o->type);
1642 read_dword(ptr, &tmp);
1643 TRACE("Effect object index %#x.\n", tmp);
1645 read_dword(ptr, &operation);
1646 TRACE("Effect object operation %#x.\n", operation);
1648 read_dword(ptr, &offset);
1649 TRACE("Effect object idx is at offset %#x.\n", offset);
1651 switch(operation)
1653 case D3D10_EOO_VALUE:
1654 TRACE("Copy variable values\n");
1656 switch (o->type)
1658 case D3D10_EOT_VERTEXSHADER:
1659 TRACE("Vertex shader\n");
1660 variable = &anonymous_vs.ID3D10EffectVariable_iface;
1661 break;
1663 case D3D10_EOT_PIXELSHADER:
1664 TRACE("Pixel shader\n");
1665 variable = &anonymous_ps.ID3D10EffectVariable_iface;
1666 break;
1668 case D3D10_EOT_GEOMETRYSHADER:
1669 TRACE("Geometry shader\n");
1670 variable = &anonymous_gs.ID3D10EffectVariable_iface;
1671 break;
1673 case D3D10_EOT_STENCIL_REF:
1674 if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &o->pass->stencil_ref))
1676 ERR("Failed to read stencil ref.\n");
1677 return E_FAIL;
1679 break;
1681 case D3D10_EOT_SAMPLE_MASK:
1682 if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &o->pass->sample_mask))
1684 FIXME("Failed to read sample mask.\n");
1685 return E_FAIL;
1687 break;
1689 case D3D10_EOT_BLEND_FACTOR:
1690 if (!read_value_list(data, data_size, offset, D3D10_SVT_FLOAT, 0, 4, &o->pass->blend_factor[0]))
1692 FIXME("Failed to read blend factor.\n");
1693 return E_FAIL;
1695 break;
1697 default:
1698 FIXME("Unhandled object type %#x\n", o->type);
1699 return E_FAIL;
1701 break;
1703 case D3D10_EOO_PARSED_OBJECT:
1704 /* This is a local object, we've parsed in parse_fx10_local_object. */
1705 if (!fx10_get_string(data, data_size, offset, &name, &name_len))
1707 WARN("Failed to get variable name.\n");
1708 return E_FAIL;
1710 TRACE("Variable name %s.\n", debugstr_a(name));
1712 variable = e->lpVtbl->GetVariableByName(e, name);
1713 break;
1715 case D3D10_EOO_PARSED_OBJECT_INDEX:
1716 /* This is a local object, we've parsed in parse_fx10_local_object, which has an array index. */
1717 if (offset >= data_size || !require_space(offset, 2, sizeof(DWORD), data_size))
1719 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1720 return E_FAIL;
1722 data_ptr = data + offset;
1723 read_dword(&data_ptr, &offset);
1724 read_dword(&data_ptr, &variable_idx);
1726 if (!fx10_get_string(data, data_size, offset, &name, &name_len))
1728 WARN("Failed to get variable name.\n");
1729 return E_FAIL;
1732 TRACE("Variable name %s[%u].\n", debugstr_a(name), variable_idx);
1734 variable = e->lpVtbl->GetVariableByName(e, name);
1735 break;
1737 case D3D10_EOO_ANONYMOUS_SHADER:
1738 TRACE("Anonymous shader\n");
1740 /* check anonymous_shader_current for validity */
1741 if (effect->anonymous_shader_current >= effect->anonymous_shader_count)
1743 ERR("Anonymous shader count is wrong!\n");
1744 return E_FAIL;
1747 if (offset >= data_size || !require_space(offset, 1, sizeof(DWORD), data_size))
1749 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1750 return E_FAIL;
1752 data_ptr = data + offset;
1753 read_dword(&data_ptr, &offset);
1754 TRACE("Effect object starts at offset %#x.\n", offset);
1756 if (FAILED(hr = parse_fx10_anonymous_shader(effect,
1757 &effect->anonymous_shaders[effect->anonymous_shader_current], o->type)))
1758 return hr;
1760 v = &effect->anonymous_shaders[effect->anonymous_shader_current].shader;
1761 variable = &v->ID3D10EffectVariable_iface;
1762 ++effect->anonymous_shader_current;
1764 switch (o->type)
1766 case D3D10_EOT_VERTEXSHADER:
1767 case D3D10_EOT_PIXELSHADER:
1768 case D3D10_EOT_GEOMETRYSHADER:
1769 if (FAILED(hr = parse_fx10_shader(data, data_size, offset, v)))
1770 return hr;
1771 break;
1773 default:
1774 FIXME("Unhandled object type %#x\n", o->type);
1775 return E_FAIL;
1777 break;
1779 default:
1780 FIXME("Unhandled operation %#x.\n", operation);
1781 return E_FAIL;
1784 switch (o->type)
1786 case D3D10_EOT_RASTERIZER_STATE:
1788 ID3D10EffectRasterizerVariable *rv = variable->lpVtbl->AsRasterizer(variable);
1789 if (FAILED(hr = rv->lpVtbl->GetRasterizerState(rv, variable_idx, &o->object.rs)))
1790 return hr;
1791 break;
1794 case D3D10_EOT_DEPTH_STENCIL_STATE:
1796 ID3D10EffectDepthStencilVariable *dv = variable->lpVtbl->AsDepthStencil(variable);
1797 if (FAILED(hr = dv->lpVtbl->GetDepthStencilState(dv, variable_idx, &o->object.ds)))
1798 return hr;
1799 break;
1802 case D3D10_EOT_BLEND_STATE:
1804 ID3D10EffectBlendVariable *bv = variable->lpVtbl->AsBlend(variable);
1805 if (FAILED(hr = bv->lpVtbl->GetBlendState(bv, variable_idx, &o->object.bs)))
1806 return hr;
1807 break;
1810 case D3D10_EOT_VERTEXSHADER:
1812 ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable);
1813 if (FAILED(hr = sv->lpVtbl->GetVertexShader(sv, variable_idx, &o->object.vs)))
1814 return hr;
1815 o->pass->vs.pShaderVariable = sv;
1816 o->pass->vs.ShaderIndex = variable_idx;
1817 break;
1820 case D3D10_EOT_PIXELSHADER:
1822 ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable);
1823 if (FAILED(hr = sv->lpVtbl->GetPixelShader(sv, variable_idx, &o->object.ps)))
1824 return hr;
1825 o->pass->ps.pShaderVariable = sv;
1826 o->pass->ps.ShaderIndex = variable_idx;
1827 break;
1830 case D3D10_EOT_GEOMETRYSHADER:
1832 ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable);
1833 if (FAILED(hr = sv->lpVtbl->GetGeometryShader(sv, variable_idx, &o->object.gs)))
1834 return hr;
1835 o->pass->gs.pShaderVariable = sv;
1836 o->pass->gs.ShaderIndex = variable_idx;
1837 break;
1840 case D3D10_EOT_STENCIL_REF:
1841 case D3D10_EOT_BLEND_FACTOR:
1842 case D3D10_EOT_SAMPLE_MASK:
1843 break;
1845 default:
1846 FIXME("Unhandled object type %#x.\n", o->type);
1847 return E_FAIL;
1850 return S_OK;
1853 static HRESULT parse_fx10_pass(const char *data, size_t data_size,
1854 const char **ptr, struct d3d10_effect_pass *p)
1856 HRESULT hr = S_OK;
1857 unsigned int i;
1858 DWORD offset;
1860 read_dword(ptr, &offset);
1861 TRACE("Pass name at offset %#x.\n", offset);
1863 if (!fx10_copy_string(data, data_size, offset, &p->name))
1865 ERR("Failed to copy name.\n");
1866 return E_OUTOFMEMORY;
1868 TRACE("Pass name: %s.\n", debugstr_a(p->name));
1870 read_dword(ptr, &p->object_count);
1871 TRACE("Pass has %u effect objects.\n", p->object_count);
1873 read_dword(ptr, &p->annotation_count);
1874 TRACE("Pass has %u annotations.\n", p->annotation_count);
1876 if (!(p->annotations = heap_calloc(p->annotation_count, sizeof(*p->annotations))))
1878 ERR("Failed to allocate pass annotations memory.\n");
1879 return E_OUTOFMEMORY;
1882 for (i = 0; i < p->annotation_count; ++i)
1884 struct d3d10_effect_variable *a = &p->annotations[i];
1886 a->effect = p->technique->effect;
1887 a->buffer = &null_local_buffer;
1889 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
1890 return hr;
1893 if (!(p->objects = heap_calloc(p->object_count, sizeof(*p->objects))))
1895 ERR("Failed to allocate effect objects memory.\n");
1896 return E_OUTOFMEMORY;
1899 p->vs.pShaderVariable = (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
1900 p->ps.pShaderVariable = (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
1901 p->gs.pShaderVariable = (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
1903 for (i = 0; i < p->object_count; ++i)
1905 struct d3d10_effect_object *o = &p->objects[i];
1907 o->pass = p;
1909 if (FAILED(hr = parse_fx10_object(data, data_size, ptr, o)))
1910 return hr;
1913 return hr;
1916 static HRESULT parse_fx10_technique(const char *data, size_t data_size,
1917 const char **ptr, struct d3d10_effect_technique *t)
1919 unsigned int i;
1920 DWORD offset;
1921 HRESULT hr;
1923 read_dword(ptr, &offset);
1924 TRACE("Technique name at offset %#x.\n", offset);
1926 if (!fx10_copy_string(data, data_size, offset, &t->name))
1928 ERR("Failed to copy name.\n");
1929 return E_OUTOFMEMORY;
1931 TRACE("Technique name: %s.\n", debugstr_a(t->name));
1933 read_dword(ptr, &t->pass_count);
1934 TRACE("Technique has %u passes\n", t->pass_count);
1936 read_dword(ptr, &t->annotation_count);
1937 TRACE("Technique has %u annotations.\n", t->annotation_count);
1939 if (!(t->annotations = heap_calloc(t->annotation_count, sizeof(*t->annotations))))
1941 ERR("Failed to allocate technique annotations memory.\n");
1942 return E_OUTOFMEMORY;
1945 for (i = 0; i < t->annotation_count; ++i)
1947 struct d3d10_effect_variable *a = &t->annotations[i];
1949 a->effect = t->effect;
1950 a->buffer = &null_local_buffer;
1952 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
1953 return hr;
1956 if (!(t->passes = heap_calloc(t->pass_count, sizeof(*t->passes))))
1958 ERR("Failed to allocate passes memory\n");
1959 return E_OUTOFMEMORY;
1962 for (i = 0; i < t->pass_count; ++i)
1964 struct d3d10_effect_pass *p = &t->passes[i];
1966 p->ID3D10EffectPass_iface.lpVtbl = &d3d10_effect_pass_vtbl;
1967 p->technique = t;
1969 if (FAILED(hr = parse_fx10_pass(data, data_size, ptr, p)))
1970 return hr;
1973 return S_OK;
1976 static HRESULT parse_fx10_variable(const char *data, size_t data_size,
1977 const char **ptr, struct d3d10_effect_variable *v)
1979 DWORD offset;
1980 unsigned int i;
1981 HRESULT hr;
1983 if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, v)))
1984 return hr;
1986 read_dword(ptr, &offset);
1987 TRACE("Variable semantic at offset %#x.\n", offset);
1989 if (!fx10_copy_string(data, data_size, offset, &v->semantic))
1991 ERR("Failed to copy semantic.\n");
1992 return E_OUTOFMEMORY;
1994 TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
1996 read_dword(ptr, &v->buffer_offset);
1997 TRACE("Variable offset in buffer: %#x.\n", v->buffer_offset);
1999 skip_dword_unknown("variable", ptr, 1);
2001 read_dword(ptr, &v->flag);
2002 TRACE("Variable flag: %#x.\n", v->flag);
2004 read_dword(ptr, &v->annotation_count);
2005 TRACE("Variable has %u annotations.\n", v->annotation_count);
2007 if (!(v->annotations = heap_calloc(v->annotation_count, sizeof(*v->annotations))))
2009 ERR("Failed to allocate variable annotations memory.\n");
2010 return E_OUTOFMEMORY;
2013 for (i = 0; i < v->annotation_count; ++i)
2015 struct d3d10_effect_variable *a = &v->annotations[i];
2017 a->effect = v->effect;
2018 a->buffer = &null_local_buffer;
2020 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
2021 return hr;
2024 return S_OK;
2027 static HRESULT create_state_object(struct d3d10_effect_variable *v)
2029 ID3D10Device *device = v->effect->device;
2030 HRESULT hr;
2032 switch (v->type->basetype)
2034 case D3D10_SVT_DEPTHSTENCIL:
2035 if (FAILED(hr = ID3D10Device_CreateDepthStencilState(device,
2036 &v->u.state.desc.depth_stencil, &v->u.state.object.depth_stencil)))
2037 return hr;
2038 break;
2040 case D3D10_SVT_BLEND:
2041 if (FAILED(hr = ID3D10Device_CreateBlendState(device,
2042 &v->u.state.desc.blend, &v->u.state.object.blend)))
2043 return hr;
2044 break;
2046 case D3D10_SVT_RASTERIZER:
2047 if (FAILED(hr = ID3D10Device_CreateRasterizerState(device,
2048 &v->u.state.desc.rasterizer, &v->u.state.object.rasterizer)))
2049 return hr;
2050 break;
2052 case D3D10_SVT_SAMPLER:
2053 if (FAILED(hr = ID3D10Device_CreateSamplerState(device,
2054 &v->u.state.desc.sampler, &v->u.state.object.sampler)))
2055 return hr;
2056 break;
2058 default:
2059 ERR("Unhandled variable type %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
2060 return E_FAIL;
2063 return S_OK;
2066 static HRESULT parse_fx10_local_variable(const char *data, size_t data_size,
2067 const char **ptr, struct d3d10_effect_variable *v)
2069 unsigned int i;
2070 HRESULT hr;
2071 DWORD offset;
2073 if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, v)))
2074 return hr;
2076 read_dword(ptr, &offset);
2077 TRACE("Variable semantic at offset %#x.\n", offset);
2079 if (!fx10_copy_string(data, data_size, offset, &v->semantic))
2081 ERR("Failed to copy semantic.\n");
2082 return E_OUTOFMEMORY;
2084 TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
2086 skip_dword_unknown("local variable", ptr, 1);
2088 switch (v->type->basetype)
2090 case D3D10_SVT_TEXTURE1D:
2091 case D3D10_SVT_TEXTURE1DARRAY:
2092 case D3D10_SVT_TEXTURE2D:
2093 case D3D10_SVT_TEXTURE2DARRAY:
2094 case D3D10_SVT_TEXTURE2DMS:
2095 case D3D10_SVT_TEXTURE2DMSARRAY:
2096 case D3D10_SVT_TEXTURE3D:
2097 case D3D10_SVT_TEXTURECUBE:
2098 if (!v->type->element_count)
2099 i = 1;
2100 else
2101 i = v->type->element_count;
2103 if (!(v->u.resource.srv = heap_calloc(i, sizeof(*v->u.resource.srv))))
2105 ERR("Failed to allocate shader resource view array memory.\n");
2106 return E_OUTOFMEMORY;
2108 v->u.resource.parent = TRUE;
2110 if (v->elements)
2112 for (i = 0; i < v->type->element_count; ++i)
2114 v->elements[i].u.resource.srv = &v->u.resource.srv[i];
2115 v->elements[i].u.resource.parent = FALSE;
2118 break;
2120 case D3D10_SVT_RENDERTARGETVIEW:
2121 case D3D10_SVT_DEPTHSTENCILVIEW:
2122 case D3D10_SVT_BUFFER:
2123 TRACE("SVT could not have elements.\n");
2124 break;
2126 case D3D10_SVT_VERTEXSHADER:
2127 case D3D10_SVT_PIXELSHADER:
2128 case D3D10_SVT_GEOMETRYSHADER:
2129 TRACE("Shader type is %s\n", debug_d3d10_shader_variable_type(v->type->basetype));
2130 for (i = 0; i < max(v->type->element_count, 1); ++i)
2132 DWORD shader_offset;
2133 struct d3d10_effect_variable *var;
2135 if (!v->type->element_count)
2137 var = v;
2139 else
2141 var = &v->elements[i];
2144 read_dword(ptr, &shader_offset);
2145 TRACE("Shader offset: %#x.\n", shader_offset);
2147 if (FAILED(hr = parse_fx10_shader(data, data_size, shader_offset, var)))
2148 return hr;
2150 break;
2152 case D3D10_SVT_DEPTHSTENCIL:
2153 case D3D10_SVT_BLEND:
2154 case D3D10_SVT_RASTERIZER:
2155 case D3D10_SVT_SAMPLER:
2157 const struct d3d10_effect_state_storage_info *storage_info;
2158 unsigned int count = max(v->type->element_count, 1);
2160 if (!(storage_info = get_storage_info(v->type->basetype)))
2162 FIXME("Failed to get backing store info for type %s.\n",
2163 debug_d3d10_shader_variable_type(v->type->basetype));
2164 return E_FAIL;
2167 if (storage_info->size > sizeof(v->u.state.desc))
2169 ERR("Invalid storage size %#lx.\n", storage_info->size);
2170 return E_FAIL;
2173 for (i = 0; i < count; ++i)
2175 struct d3d10_effect_variable *var;
2177 if (v->type->element_count)
2178 var = &v->elements[i];
2179 else
2180 var = v;
2182 memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size);
2183 if (!parse_fx10_state_group(data, data_size, ptr, var->type->basetype, &var->u.state.desc))
2185 ERR("Failed to read property list.\n");
2186 return E_FAIL;
2189 if (FAILED(hr = create_state_object(v)))
2190 return hr;
2193 break;
2195 default:
2196 FIXME("Unhandled case %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
2197 return E_FAIL;
2200 read_dword(ptr, &v->annotation_count);
2201 TRACE("Variable has %u annotations.\n", v->annotation_count);
2203 if (!(v->annotations = heap_calloc(v->annotation_count, sizeof(*v->annotations))))
2205 ERR("Failed to allocate variable annotations memory.\n");
2206 return E_OUTOFMEMORY;
2209 for (i = 0; i < v->annotation_count; ++i)
2211 struct d3d10_effect_variable *a = &v->annotations[i];
2213 a->effect = v->effect;
2214 a->buffer = &null_local_buffer;
2216 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
2217 return hr;
2220 return S_OK;
2223 static HRESULT create_variable_buffer(struct d3d10_effect_variable *v, D3D10_CBUFFER_TYPE type)
2225 D3D10_BUFFER_DESC buffer_desc;
2226 D3D10_SUBRESOURCE_DATA subresource_data;
2227 D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc;
2228 ID3D10Device *device = v->effect->device;
2229 HRESULT hr;
2231 if (!(v->u.buffer.local_buffer = heap_alloc_zero(v->type->size_unpacked)))
2233 ERR("Failed to allocate local constant buffer memory.\n");
2234 return E_OUTOFMEMORY;
2237 buffer_desc.ByteWidth = v->type->size_unpacked;
2238 buffer_desc.Usage = D3D10_USAGE_DEFAULT;
2239 buffer_desc.CPUAccessFlags = 0;
2240 buffer_desc.MiscFlags = 0;
2241 if (type == D3D10_CT_CBUFFER)
2242 buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
2243 else
2244 buffer_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
2246 subresource_data.pSysMem = v->u.buffer.local_buffer;
2247 subresource_data.SysMemPitch = 0;
2248 subresource_data.SysMemSlicePitch = 0;
2250 if (FAILED(hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &subresource_data, &v->u.buffer.buffer)))
2251 return hr;
2253 if (type == D3D10_CT_TBUFFER)
2255 srv_desc.Format = DXGI_FORMAT_R32G32B32A32_UINT;
2256 srv_desc.ViewDimension = D3D_SRV_DIMENSION_BUFFER;
2257 srv_desc.Buffer.ElementOffset = 0;
2258 srv_desc.Buffer.ElementWidth = v->type->size_unpacked / 16;
2259 if (v->type->size_unpacked % 16)
2260 WARN("Unexpected texture buffer size not a multiple of 16.\n");
2262 if (FAILED(hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)v->u.buffer.buffer,
2263 &srv_desc, &v->u.buffer.resource_view)))
2264 return hr;
2266 else
2267 v->u.buffer.resource_view = NULL;
2269 return S_OK;
2272 static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
2273 const char **ptr, struct d3d10_effect_variable *l)
2275 unsigned int i;
2276 DWORD offset;
2277 D3D10_CBUFFER_TYPE d3d10_cbuffer_type;
2278 HRESULT hr;
2279 unsigned int stride = 0;
2281 /* Generate our own type, it isn't in the fx blob. */
2282 if (!(l->type = heap_alloc_zero(sizeof(*l->type))))
2284 ERR("Failed to allocate local buffer type memory.\n");
2285 return E_OUTOFMEMORY;
2287 l->type->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
2288 l->type->type_class = D3D10_SVC_OBJECT;
2289 l->type->effect = l->effect;
2291 read_dword(ptr, &offset);
2292 TRACE("Local buffer name at offset %#x.\n", offset);
2294 if (!fx10_copy_string(data, data_size, offset, &l->name))
2296 ERR("Failed to copy name.\n");
2297 return E_OUTOFMEMORY;
2299 TRACE("Local buffer name: %s.\n", debugstr_a(l->name));
2301 read_dword(ptr, &l->data_size);
2302 TRACE("Local buffer data size: %#x.\n", l->data_size);
2304 read_dword(ptr, &d3d10_cbuffer_type);
2305 TRACE("Local buffer type: %#x.\n", d3d10_cbuffer_type);
2307 switch(d3d10_cbuffer_type)
2309 case D3D10_CT_CBUFFER:
2310 l->type->basetype = D3D10_SVT_CBUFFER;
2311 if (!copy_name("cbuffer", &l->type->name))
2313 ERR("Failed to copy name.\n");
2314 return E_OUTOFMEMORY;
2316 break;
2318 case D3D10_CT_TBUFFER:
2319 l->type->basetype = D3D10_SVT_TBUFFER;
2320 if (!copy_name("tbuffer", &l->type->name))
2322 ERR("Failed to copy name.\n");
2323 return E_OUTOFMEMORY;
2325 break;
2327 default:
2328 ERR("Unexpected D3D10_CBUFFER_TYPE %#x!\n", d3d10_cbuffer_type);
2329 return E_FAIL;
2332 read_dword(ptr, &l->type->member_count);
2333 TRACE("Local buffer member count: %#x.\n", l->type->member_count);
2335 skip_dword_unknown("local buffer", ptr, 1);
2337 read_dword(ptr, &l->annotation_count);
2338 TRACE("Local buffer has %u annotations.\n", l->annotation_count);
2340 if (!(l->annotations = heap_calloc(l->annotation_count, sizeof(*l->annotations))))
2342 ERR("Failed to allocate local buffer annotations memory.\n");
2343 return E_OUTOFMEMORY;
2346 for (i = 0; i < l->annotation_count; ++i)
2348 struct d3d10_effect_variable *a = &l->annotations[i];
2350 a->effect = l->effect;
2351 a->buffer = &null_local_buffer;
2353 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
2354 return hr;
2357 if (!(l->members = heap_calloc(l->type->member_count, sizeof(*l->members))))
2359 ERR("Failed to allocate members memory.\n");
2360 return E_OUTOFMEMORY;
2363 if (!(l->type->members = heap_calloc(l->type->member_count, sizeof(*l->type->members))))
2365 ERR("Failed to allocate type members memory.\n");
2366 return E_OUTOFMEMORY;
2369 for (i = 0; i < l->type->member_count; ++i)
2371 struct d3d10_effect_variable *v = &l->members[i];
2372 struct d3d10_effect_type_member *typem = &l->type->members[i];
2374 v->buffer = l;
2375 v->effect = l->effect;
2377 if (FAILED(hr = parse_fx10_variable(data, data_size, ptr, v)))
2378 return hr;
2381 * Copy the values from the variable type to the constant buffers type
2382 * members structure, because it is our own generated type.
2384 typem->type = v->type;
2386 if (!copy_name(v->name, &typem->name))
2388 ERR("Failed to copy name.\n");
2389 return E_OUTOFMEMORY;
2391 TRACE("Variable name: %s.\n", debugstr_a(typem->name));
2393 if (!copy_name(v->semantic, &typem->semantic))
2395 ERR("Failed to copy name.\n");
2396 return E_OUTOFMEMORY;
2398 TRACE("Variable semantic: %s.\n", debugstr_a(typem->semantic));
2400 typem->buffer_offset = v->buffer_offset;
2401 TRACE("Variable buffer offset: %u.\n", typem->buffer_offset);
2403 l->type->size_packed += v->type->size_packed;
2406 * For the complete constantbuffer the size_unpacked = stride,
2407 * the stride is calculated like this:
2409 * 1) if the constant buffer variables are packed with packoffset
2410 * - stride = the highest used constant
2411 * - the complete stride has to be a multiple of 0x10
2413 * 2) if the constant buffer variables are NOT packed with packoffset
2414 * - sum of unpacked size for all variables which fit in a 0x10 part
2415 * - if the size exceeds a 0x10 part, the rest of the old part is skipped
2416 * and a new part is started
2417 * - if the variable is a struct it is always used a new part
2418 * - the complete stride has to be a multiple of 0x10
2420 * e.g.:
2421 * 0x4, 0x4, 0x4, 0x8, 0x4, 0x14, 0x4
2422 * part 0x10 0x10 0x20 -> 0x40
2424 if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
2426 if ((v->type->size_unpacked + v->buffer_offset) > stride)
2428 stride = v->type->size_unpacked + v->buffer_offset;
2431 else
2433 if (v->type->type_class == D3D10_SVC_STRUCT)
2435 stride = (stride + 0xf) & ~0xf;
2438 if ( ((stride & 0xf) + v->type->size_unpacked) > 0x10)
2440 stride = (stride + 0xf) & ~0xf;
2443 stride += v->type->size_unpacked;
2446 l->type->stride = l->type->size_unpacked = (stride + 0xf) & ~0xf;
2448 TRACE("Constant buffer:\n");
2449 TRACE("\tType name: %s.\n", debugstr_a(l->type->name));
2450 TRACE("\tElement count: %u.\n", l->type->element_count);
2451 TRACE("\tMember count: %u.\n", l->type->member_count);
2452 TRACE("\tUnpacked size: %#x.\n", l->type->size_unpacked);
2453 TRACE("\tStride: %#x.\n", l->type->stride);
2454 TRACE("\tPacked size %#x.\n", l->type->size_packed);
2455 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype));
2456 TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
2458 if (l->type->size_unpacked)
2460 if (FAILED(hr = create_variable_buffer(l, d3d10_cbuffer_type)))
2461 return hr;
2464 return S_OK;
2467 static void d3d10_effect_type_member_destroy(struct d3d10_effect_type_member *typem)
2469 TRACE("effect type member %p.\n", typem);
2471 /* Do not release typem->type, it will be covered by d3d10_effect_type_destroy(). */
2472 heap_free(typem->semantic);
2473 heap_free(typem->name);
2476 static void d3d10_effect_type_destroy(struct wine_rb_entry *entry, void *context)
2478 struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, struct d3d10_effect_type, entry);
2480 TRACE("effect type %p.\n", t);
2482 if (t->elementtype)
2484 heap_free(t->elementtype->name);
2485 heap_free(t->elementtype);
2488 if (t->members)
2490 unsigned int i;
2492 for (i = 0; i < t->member_count; ++i)
2494 d3d10_effect_type_member_destroy(&t->members[i]);
2496 heap_free(t->members);
2499 heap_free(t->name);
2500 heap_free(t);
2503 static HRESULT parse_fx10_body(struct d3d10_effect *e, const char *data, DWORD data_size)
2505 const char *ptr;
2506 unsigned int i;
2507 HRESULT hr;
2509 if (e->index_offset >= data_size)
2511 WARN("Invalid index offset %#x (data size %#x).\n", e->index_offset, data_size);
2512 return E_FAIL;
2514 ptr = data + e->index_offset;
2516 if (!(e->local_buffers = heap_calloc(e->local_buffer_count, sizeof(*e->local_buffers))))
2518 ERR("Failed to allocate local buffer memory.\n");
2519 return E_OUTOFMEMORY;
2522 if (!(e->local_variables = heap_calloc(e->local_variable_count, sizeof(*e->local_variables))))
2524 ERR("Failed to allocate local variable memory.\n");
2525 return E_OUTOFMEMORY;
2528 if (!(e->anonymous_shaders = heap_calloc(e->anonymous_shader_count, sizeof(*e->anonymous_shaders))))
2530 ERR("Failed to allocate anonymous shaders memory\n");
2531 return E_OUTOFMEMORY;
2534 if (!(e->used_shaders = heap_calloc(e->used_shader_count, sizeof(*e->used_shaders))))
2536 ERR("Failed to allocate used shaders memory\n");
2537 return E_OUTOFMEMORY;
2540 if (!(e->techniques = heap_calloc(e->technique_count, sizeof(*e->techniques))))
2542 ERR("Failed to allocate techniques memory\n");
2543 return E_OUTOFMEMORY;
2546 for (i = 0; i < e->local_buffer_count; ++i)
2548 struct d3d10_effect_variable *l = &e->local_buffers[i];
2549 l->ID3D10EffectVariable_iface.lpVtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl;
2550 l->effect = e;
2551 l->buffer = &null_local_buffer;
2553 if (FAILED(hr = parse_fx10_local_buffer(data, data_size, &ptr, l)))
2554 return hr;
2557 for (i = 0; i < e->local_variable_count; ++i)
2559 struct d3d10_effect_variable *v = &e->local_variables[i];
2561 v->effect = e;
2562 v->ID3D10EffectVariable_iface.lpVtbl = &d3d10_effect_variable_vtbl;
2563 v->buffer = &null_local_buffer;
2565 if (FAILED(hr = parse_fx10_local_variable(data, data_size, &ptr, v)))
2566 return hr;
2569 for (i = 0; i < e->technique_count; ++i)
2571 struct d3d10_effect_technique *t = &e->techniques[i];
2573 t->ID3D10EffectTechnique_iface.lpVtbl = &d3d10_effect_technique_vtbl;
2574 t->effect = e;
2576 if (FAILED(hr = parse_fx10_technique(data, data_size, &ptr, t)))
2577 return hr;
2580 return S_OK;
2583 static HRESULT parse_fx10(struct d3d10_effect *e, const char *data, DWORD data_size)
2585 const char *ptr = data;
2586 DWORD unknown;
2588 if (!require_space(0, 19, sizeof(DWORD), data_size))
2590 WARN("Invalid data size %#x.\n", data_size);
2591 return E_INVALIDARG;
2594 /* Compiled target version (e.g. fx_4_0=0xfeff1001, fx_4_1=0xfeff1011). */
2595 read_dword(&ptr, &e->version);
2596 TRACE("Target: %#x\n", e->version);
2598 read_dword(&ptr, &e->local_buffer_count);
2599 TRACE("Local buffer count: %u.\n", e->local_buffer_count);
2601 read_dword(&ptr, &e->variable_count);
2602 TRACE("Variable count: %u\n", e->variable_count);
2604 read_dword(&ptr, &e->local_variable_count);
2605 TRACE("Object count: %u\n", e->local_variable_count);
2607 read_dword(&ptr, &e->sharedbuffers_count);
2608 TRACE("Sharedbuffers count: %u\n", e->sharedbuffers_count);
2610 /* Number of variables in shared buffers? */
2611 read_dword(&ptr, &unknown);
2612 FIXME("Unknown 0: %u\n", unknown);
2614 read_dword(&ptr, &e->sharedobjects_count);
2615 TRACE("Sharedobjects count: %u\n", e->sharedobjects_count);
2617 read_dword(&ptr, &e->technique_count);
2618 TRACE("Technique count: %u\n", e->technique_count);
2620 read_dword(&ptr, &e->index_offset);
2621 TRACE("Index offset: %#x\n", e->index_offset);
2623 read_dword(&ptr, &unknown);
2624 FIXME("Unknown 1: %u\n", unknown);
2626 read_dword(&ptr, &e->texture_count);
2627 TRACE("Texture count: %u\n", e->texture_count);
2629 read_dword(&ptr, &e->depthstencilstate_count);
2630 TRACE("Depthstencilstate count: %u\n", e->depthstencilstate_count);
2632 read_dword(&ptr, &e->blendstate_count);
2633 TRACE("Blendstate count: %u\n", e->blendstate_count);
2635 read_dword(&ptr, &e->rasterizerstate_count);
2636 TRACE("Rasterizerstate count: %u\n", e->rasterizerstate_count);
2638 read_dword(&ptr, &e->samplerstate_count);
2639 TRACE("Samplerstate count: %u\n", e->samplerstate_count);
2641 read_dword(&ptr, &e->rendertargetview_count);
2642 TRACE("Rendertargetview count: %u\n", e->rendertargetview_count);
2644 read_dword(&ptr, &e->depthstencilview_count);
2645 TRACE("Depthstencilview count: %u\n", e->depthstencilview_count);
2647 read_dword(&ptr, &e->used_shader_count);
2648 TRACE("Used shader count: %u\n", e->used_shader_count);
2650 read_dword(&ptr, &e->anonymous_shader_count);
2651 TRACE("Anonymous shader count: %u\n", e->anonymous_shader_count);
2653 return parse_fx10_body(e, ptr, data_size - (ptr - data));
2656 static HRESULT fx10_chunk_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
2658 struct d3d10_effect *e = ctx;
2660 TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
2662 TRACE("chunk size: %#x\n", data_size);
2664 switch(tag)
2666 case TAG_FX10:
2667 return parse_fx10(e, data, data_size);
2669 default:
2670 FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag, 4));
2671 return S_OK;
2675 HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T data_size)
2677 return parse_dxbc(data, data_size, fx10_chunk_handler, This);
2680 static HRESULT d3d10_effect_object_apply(struct d3d10_effect_object *o)
2682 ID3D10Device *device = o->pass->technique->effect->device;
2684 TRACE("effect object %p, type %#x.\n", o, o->type);
2686 switch(o->type)
2688 case D3D10_EOT_RASTERIZER_STATE:
2689 ID3D10Device_RSSetState(device, o->object.rs);
2690 return S_OK;
2692 case D3D10_EOT_DEPTH_STENCIL_STATE:
2693 ID3D10Device_OMSetDepthStencilState(device, o->object.ds, o->pass->stencil_ref);
2694 return S_OK;
2696 case D3D10_EOT_BLEND_STATE:
2697 ID3D10Device_OMSetBlendState(device, o->object.bs, o->pass->blend_factor, o->pass->sample_mask);
2698 return S_OK;
2700 case D3D10_EOT_VERTEXSHADER:
2701 ID3D10Device_VSSetShader(device, o->object.vs);
2702 return S_OK;
2704 case D3D10_EOT_PIXELSHADER:
2705 ID3D10Device_PSSetShader(device, o->object.ps);
2706 return S_OK;
2708 case D3D10_EOT_GEOMETRYSHADER:
2709 ID3D10Device_GSSetShader(device, o->object.gs);
2710 return S_OK;
2712 case D3D10_EOT_STENCIL_REF:
2713 case D3D10_EOT_BLEND_FACTOR:
2714 case D3D10_EOT_SAMPLE_MASK:
2715 return S_OK;
2717 default:
2718 FIXME("Unhandled effect object type %#x.\n", o->type);
2719 return E_FAIL;
2723 static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_variable *s,
2724 D3D10_SHADER_VARIABLE_TYPE type)
2726 shader_free_signature(&s->input_signature);
2727 shader_free_signature(&s->output_signature);
2729 switch (type)
2731 case D3D10_SVT_VERTEXSHADER:
2732 if (s->shader.vs)
2733 ID3D10VertexShader_Release(s->shader.vs);
2734 break;
2736 case D3D10_SVT_PIXELSHADER:
2737 if (s->shader.ps)
2738 ID3D10PixelShader_Release(s->shader.ps);
2739 break;
2741 case D3D10_SVT_GEOMETRYSHADER:
2742 if (s->shader.gs)
2743 ID3D10GeometryShader_Release(s->shader.gs);
2744 break;
2746 default:
2747 FIXME("Unhandled shader type %s.\n", debug_d3d10_shader_variable_type(type));
2748 break;
2751 if (s->resource_count)
2752 heap_free(s->resources);
2755 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v)
2757 unsigned int i, elem_count;
2759 TRACE("variable %p.\n", v);
2761 heap_free(v->name);
2762 heap_free(v->semantic);
2763 if (v->annotations)
2765 for (i = 0; i < v->annotation_count; ++i)
2767 d3d10_effect_variable_destroy(&v->annotations[i]);
2769 heap_free(v->annotations);
2772 if (v->members)
2774 for (i = 0; i < v->type->member_count; ++i)
2776 d3d10_effect_variable_destroy(&v->members[i]);
2778 heap_free(v->members);
2781 if (v->elements)
2783 for (i = 0; i < v->type->element_count; ++i)
2785 d3d10_effect_variable_destroy(&v->elements[i]);
2787 heap_free(v->elements);
2790 if (v->type)
2792 switch (v->type->basetype)
2794 case D3D10_SVT_VERTEXSHADER:
2795 case D3D10_SVT_PIXELSHADER:
2796 case D3D10_SVT_GEOMETRYSHADER:
2797 d3d10_effect_shader_variable_destroy(&v->u.shader, v->type->basetype);
2798 break;
2800 case D3D10_SVT_DEPTHSTENCIL:
2801 if (v->u.state.object.depth_stencil)
2802 ID3D10DepthStencilState_Release(v->u.state.object.depth_stencil);
2803 break;
2805 case D3D10_SVT_BLEND:
2806 if (v->u.state.object.blend)
2807 ID3D10BlendState_Release(v->u.state.object.blend);
2808 break;
2810 case D3D10_SVT_RASTERIZER:
2811 if (v->u.state.object.rasterizer)
2812 ID3D10RasterizerState_Release(v->u.state.object.rasterizer);
2813 break;
2815 case D3D10_SVT_SAMPLER:
2816 if (v->u.state.object.sampler)
2817 ID3D10SamplerState_Release(v->u.state.object.sampler);
2818 break;
2820 case D3D10_SVT_TEXTURE1D:
2821 case D3D10_SVT_TEXTURE1DARRAY:
2822 case D3D10_SVT_TEXTURE2D:
2823 case D3D10_SVT_TEXTURE2DARRAY:
2824 case D3D10_SVT_TEXTURE2DMS:
2825 case D3D10_SVT_TEXTURE2DMSARRAY:
2826 case D3D10_SVT_TEXTURE3D:
2827 case D3D10_SVT_TEXTURECUBE:
2828 if (!v->u.resource.parent)
2829 break;
2831 if (!v->type->element_count)
2832 elem_count = 1;
2833 else
2834 elem_count = v->type->element_count;
2836 for (i = 0; i < elem_count; ++i)
2838 if (v->u.resource.srv[i])
2839 ID3D10ShaderResourceView_Release(v->u.resource.srv[i]);
2842 heap_free(v->u.resource.srv);
2843 break;
2845 case D3D10_SVT_STRING:
2846 heap_free(v->u.buffer.local_buffer);
2847 break;
2849 default:
2850 break;
2855 static void d3d10_effect_object_destroy(struct d3d10_effect_object *o)
2857 switch (o->type)
2859 case D3D10_EOT_RASTERIZER_STATE:
2860 if (o->object.rs)
2861 ID3D10RasterizerState_Release(o->object.rs);
2862 break;
2864 case D3D10_EOT_DEPTH_STENCIL_STATE:
2865 if (o->object.ds)
2866 ID3D10DepthStencilState_Release(o->object.ds);
2867 break;
2869 case D3D10_EOT_BLEND_STATE:
2870 if (o->object.bs)
2871 ID3D10BlendState_Release(o->object.bs);
2872 break;
2874 case D3D10_EOT_VERTEXSHADER:
2875 if (o->object.vs)
2876 ID3D10VertexShader_Release(o->object.vs);
2877 break;
2879 case D3D10_EOT_PIXELSHADER:
2880 if (o->object.ps)
2881 ID3D10PixelShader_Release(o->object.ps);
2882 break;
2884 case D3D10_EOT_GEOMETRYSHADER:
2885 if (o->object.gs)
2886 ID3D10GeometryShader_Release(o->object.gs);
2887 break;
2889 default:
2890 break;
2894 static void d3d10_effect_pass_destroy(struct d3d10_effect_pass *p)
2896 unsigned int i;
2898 TRACE("pass %p\n", p);
2900 heap_free(p->name);
2902 if (p->objects)
2904 for (i = 0; i < p->object_count; ++i)
2906 d3d10_effect_object_destroy(&p->objects[i]);
2908 heap_free(p->objects);
2911 if (p->annotations)
2913 for (i = 0; i < p->annotation_count; ++i)
2915 d3d10_effect_variable_destroy(&p->annotations[i]);
2917 heap_free(p->annotations);
2921 static void d3d10_effect_technique_destroy(struct d3d10_effect_technique *t)
2923 unsigned int i;
2925 TRACE("technique %p\n", t);
2927 heap_free(t->name);
2928 if (t->passes)
2930 for (i = 0; i < t->pass_count; ++i)
2932 d3d10_effect_pass_destroy(&t->passes[i]);
2934 heap_free(t->passes);
2937 if (t->annotations)
2939 for (i = 0; i < t->annotation_count; ++i)
2941 d3d10_effect_variable_destroy(&t->annotations[i]);
2943 heap_free(t->annotations);
2947 static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable *l)
2949 unsigned int i;
2951 TRACE("local buffer %p.\n", l);
2953 heap_free(l->name);
2954 if (l->members)
2956 for (i = 0; i < l->type->member_count; ++i)
2958 d3d10_effect_variable_destroy(&l->members[i]);
2960 heap_free(l->members);
2963 if (l->type)
2964 d3d10_effect_type_destroy(&l->type->entry, NULL);
2966 if (l->annotations)
2968 for (i = 0; i < l->annotation_count; ++i)
2970 d3d10_effect_variable_destroy(&l->annotations[i]);
2972 heap_free(l->annotations);
2975 heap_free(l->u.buffer.local_buffer);
2977 if (l->u.buffer.buffer)
2978 ID3D10Buffer_Release(l->u.buffer.buffer);
2979 if (l->u.buffer.resource_view)
2980 ID3D10ShaderResourceView_Release(l->u.buffer.resource_view);
2983 /* IUnknown methods */
2985 static inline struct d3d10_effect *impl_from_ID3D10Effect(ID3D10Effect *iface)
2987 return CONTAINING_RECORD(iface, struct d3d10_effect, ID3D10Effect_iface);
2990 static HRESULT STDMETHODCALLTYPE d3d10_effect_QueryInterface(ID3D10Effect *iface, REFIID riid, void **object)
2992 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
2994 if (IsEqualGUID(riid, &IID_ID3D10Effect)
2995 || IsEqualGUID(riid, &IID_IUnknown))
2997 IUnknown_AddRef(iface);
2998 *object = iface;
2999 return S_OK;
3002 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
3004 *object = NULL;
3005 return E_NOINTERFACE;
3008 static ULONG STDMETHODCALLTYPE d3d10_effect_AddRef(ID3D10Effect *iface)
3010 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3011 ULONG refcount = InterlockedIncrement(&This->refcount);
3013 TRACE("%p increasing refcount to %u\n", This, refcount);
3015 return refcount;
3018 static ULONG STDMETHODCALLTYPE d3d10_effect_Release(ID3D10Effect *iface)
3020 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3021 ULONG refcount = InterlockedDecrement(&This->refcount);
3023 TRACE("%p decreasing refcount to %u\n", This, refcount);
3025 if (!refcount)
3027 unsigned int i;
3029 if (This->techniques)
3031 for (i = 0; i < This->technique_count; ++i)
3033 d3d10_effect_technique_destroy(&This->techniques[i]);
3035 heap_free(This->techniques);
3038 if (This->local_variables)
3040 for (i = 0; i < This->local_variable_count; ++i)
3042 d3d10_effect_variable_destroy(&This->local_variables[i]);
3044 heap_free(This->local_variables);
3047 if (This->local_buffers)
3049 for (i = 0; i < This->local_buffer_count; ++i)
3051 d3d10_effect_local_buffer_destroy(&This->local_buffers[i]);
3053 heap_free(This->local_buffers);
3056 if (This->anonymous_shaders)
3058 for (i = 0; i < This->anonymous_shader_count; ++i)
3060 d3d10_effect_variable_destroy(&This->anonymous_shaders[i].shader);
3061 heap_free(This->anonymous_shaders[i].type.name);
3063 heap_free(This->anonymous_shaders);
3066 heap_free(This->used_shaders);
3068 wine_rb_destroy(&This->types, d3d10_effect_type_destroy, NULL);
3070 ID3D10Device_Release(This->device);
3071 heap_free(This);
3074 return refcount;
3077 /* ID3D10Effect methods */
3079 static BOOL STDMETHODCALLTYPE d3d10_effect_IsValid(ID3D10Effect *iface)
3081 FIXME("iface %p stub!\n", iface);
3083 return FALSE;
3086 static BOOL STDMETHODCALLTYPE d3d10_effect_IsPool(ID3D10Effect *iface)
3088 FIXME("iface %p stub!\n", iface);
3090 return FALSE;
3093 static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDevice(ID3D10Effect *iface, ID3D10Device **device)
3095 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3097 TRACE("iface %p, device %p\n", iface, device);
3099 ID3D10Device_AddRef(This->device);
3100 *device = This->device;
3102 return S_OK;
3105 static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDesc(ID3D10Effect *iface, D3D10_EFFECT_DESC *desc)
3107 FIXME("iface %p, desc %p stub!\n", iface, desc);
3109 return E_NOTIMPL;
3112 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetConstantBufferByIndex(ID3D10Effect *iface,
3113 UINT index)
3115 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3116 struct d3d10_effect_variable *l;
3118 TRACE("iface %p, index %u\n", iface, index);
3120 if (index >= This->local_buffer_count)
3122 WARN("Invalid index specified\n");
3123 return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
3126 l = &This->local_buffers[index];
3128 TRACE("Returning buffer %p, %s.\n", l, debugstr_a(l->name));
3130 return (ID3D10EffectConstantBuffer *)&l->ID3D10EffectVariable_iface;
3133 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetConstantBufferByName(ID3D10Effect *iface,
3134 const char *name)
3136 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3137 unsigned int i;
3139 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3141 for (i = 0; i < This->local_buffer_count; ++i)
3143 struct d3d10_effect_variable *l = &This->local_buffers[i];
3145 if (l->name && !strcmp(l->name, name))
3147 TRACE("Returning buffer %p.\n", l);
3148 return (ID3D10EffectConstantBuffer *)&l->ID3D10EffectVariable_iface;
3152 WARN("Invalid name specified\n");
3154 return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
3157 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableByIndex(ID3D10Effect *iface, UINT index)
3159 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3160 unsigned int i;
3162 TRACE("iface %p, index %u\n", iface, index);
3164 for (i = 0; i < This->local_buffer_count; ++i)
3166 struct d3d10_effect_variable *l = &This->local_buffers[i];
3168 if (index < l->type->member_count)
3170 struct d3d10_effect_variable *v = &l->members[index];
3172 TRACE("Returning variable %p.\n", v);
3173 return &v->ID3D10EffectVariable_iface;
3175 index -= l->type->member_count;
3178 if (index < This->local_variable_count)
3180 struct d3d10_effect_variable *v = &This->local_variables[index];
3182 TRACE("Returning variable %p.\n", v);
3183 return &v->ID3D10EffectVariable_iface;
3186 WARN("Invalid index specified\n");
3188 return &null_variable.ID3D10EffectVariable_iface;
3191 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableByName(ID3D10Effect *iface,
3192 const char *name)
3194 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3195 unsigned int i;
3197 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3199 if (!name)
3201 WARN("Invalid name specified\n");
3202 return &null_variable.ID3D10EffectVariable_iface;
3205 for (i = 0; i < This->local_buffer_count; ++i)
3207 struct d3d10_effect_variable *l = &This->local_buffers[i];
3208 unsigned int j;
3210 for (j = 0; j < l->type->member_count; ++j)
3212 struct d3d10_effect_variable *v = &l->members[j];
3214 if (v->name && !strcmp(v->name, name))
3216 TRACE("Returning variable %p.\n", v);
3217 return &v->ID3D10EffectVariable_iface;
3222 for (i = 0; i < This->local_variable_count; ++i)
3224 struct d3d10_effect_variable *v = &This->local_variables[i];
3226 if (v->name && !strcmp(v->name, name))
3228 TRACE("Returning variable %p.\n", v);
3229 return &v->ID3D10EffectVariable_iface;
3233 WARN("Invalid name specified\n");
3235 return &null_variable.ID3D10EffectVariable_iface;
3238 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableBySemantic(ID3D10Effect *iface,
3239 const char *semantic)
3241 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3242 unsigned int i;
3244 TRACE("iface %p, semantic %s\n", iface, debugstr_a(semantic));
3246 if (!semantic)
3248 WARN("Invalid semantic specified\n");
3249 return &null_variable.ID3D10EffectVariable_iface;
3252 for (i = 0; i < This->local_buffer_count; ++i)
3254 struct d3d10_effect_variable *l = &This->local_buffers[i];
3255 unsigned int j;
3257 for (j = 0; j < l->type->member_count; ++j)
3259 struct d3d10_effect_variable *v = &l->members[j];
3261 if (v->semantic && !strcmp(v->semantic, semantic))
3263 TRACE("Returning variable %p.\n", v);
3264 return &v->ID3D10EffectVariable_iface;
3269 for (i = 0; i < This->local_variable_count; ++i)
3271 struct d3d10_effect_variable *v = &This->local_variables[i];
3273 if (v->semantic && !strcmp(v->semantic, semantic))
3275 TRACE("Returning variable %p.\n", v);
3276 return &v->ID3D10EffectVariable_iface;
3280 WARN("Invalid semantic specified\n");
3282 return &null_variable.ID3D10EffectVariable_iface;
3285 static struct ID3D10EffectTechnique * STDMETHODCALLTYPE d3d10_effect_GetTechniqueByIndex(ID3D10Effect *iface,
3286 UINT index)
3288 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3289 struct d3d10_effect_technique *t;
3291 TRACE("iface %p, index %u\n", iface, index);
3293 if (index >= This->technique_count)
3295 WARN("Invalid index specified\n");
3296 return &null_technique.ID3D10EffectTechnique_iface;
3299 t = &This->techniques[index];
3301 TRACE("Returning technique %p, %s.\n", t, debugstr_a(t->name));
3303 return &t->ID3D10EffectTechnique_iface;
3306 static struct ID3D10EffectTechnique * STDMETHODCALLTYPE d3d10_effect_GetTechniqueByName(ID3D10Effect *iface,
3307 const char *name)
3309 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3310 unsigned int i;
3312 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3314 if (!name)
3316 WARN("Invalid name specified\n");
3317 return &null_technique.ID3D10EffectTechnique_iface;
3320 for (i = 0; i < This->technique_count; ++i)
3322 struct d3d10_effect_technique *t = &This->techniques[i];
3323 if (t->name && !strcmp(t->name, name))
3325 TRACE("Returning technique %p\n", t);
3326 return &t->ID3D10EffectTechnique_iface;
3330 WARN("Invalid name specified\n");
3332 return &null_technique.ID3D10EffectTechnique_iface;
3335 static HRESULT STDMETHODCALLTYPE d3d10_effect_Optimize(ID3D10Effect *iface)
3337 FIXME("iface %p stub!\n", iface);
3339 return E_NOTIMPL;
3342 static BOOL STDMETHODCALLTYPE d3d10_effect_IsOptimized(ID3D10Effect *iface)
3344 FIXME("iface %p stub!\n", iface);
3346 return FALSE;
3349 const struct ID3D10EffectVtbl d3d10_effect_vtbl =
3351 /* IUnknown methods */
3352 d3d10_effect_QueryInterface,
3353 d3d10_effect_AddRef,
3354 d3d10_effect_Release,
3355 /* ID3D10Effect methods */
3356 d3d10_effect_IsValid,
3357 d3d10_effect_IsPool,
3358 d3d10_effect_GetDevice,
3359 d3d10_effect_GetDesc,
3360 d3d10_effect_GetConstantBufferByIndex,
3361 d3d10_effect_GetConstantBufferByName,
3362 d3d10_effect_GetVariableByIndex,
3363 d3d10_effect_GetVariableByName,
3364 d3d10_effect_GetVariableBySemantic,
3365 d3d10_effect_GetTechniqueByIndex,
3366 d3d10_effect_GetTechniqueByName,
3367 d3d10_effect_Optimize,
3368 d3d10_effect_IsOptimized,
3371 /* ID3D10EffectTechnique methods */
3373 static inline struct d3d10_effect_technique *impl_from_ID3D10EffectTechnique(ID3D10EffectTechnique *iface)
3375 return CONTAINING_RECORD(iface, struct d3d10_effect_technique, ID3D10EffectTechnique_iface);
3378 static BOOL STDMETHODCALLTYPE d3d10_effect_technique_IsValid(ID3D10EffectTechnique *iface)
3380 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3382 TRACE("iface %p\n", iface);
3384 return This != &null_technique;
3387 static HRESULT STDMETHODCALLTYPE d3d10_effect_technique_GetDesc(ID3D10EffectTechnique *iface,
3388 D3D10_TECHNIQUE_DESC *desc)
3390 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3392 TRACE("iface %p, desc %p\n", iface, desc);
3394 if(This == &null_technique)
3396 WARN("Null technique specified\n");
3397 return E_FAIL;
3400 if(!desc)
3402 WARN("Invalid argument specified\n");
3403 return E_INVALIDARG;
3406 desc->Name = This->name;
3407 desc->Passes = This->pass_count;
3408 desc->Annotations = This->annotation_count;
3410 return S_OK;
3413 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByIndex(
3414 ID3D10EffectTechnique *iface, UINT index)
3416 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3417 struct d3d10_effect_variable *a;
3419 TRACE("iface %p, index %u\n", iface, index);
3421 if (index >= This->annotation_count)
3423 WARN("Invalid index specified\n");
3424 return &null_variable.ID3D10EffectVariable_iface;
3427 a = &This->annotations[index];
3429 TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name));
3431 return &a->ID3D10EffectVariable_iface;
3434 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByName(
3435 ID3D10EffectTechnique *iface, const char *name)
3437 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3438 unsigned int i;
3440 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3442 for (i = 0; i < This->annotation_count; ++i)
3444 struct d3d10_effect_variable *a = &This->annotations[i];
3445 if (a->name && !strcmp(a->name, name))
3447 TRACE("Returning annotation %p\n", a);
3448 return &a->ID3D10EffectVariable_iface;
3452 WARN("Invalid name specified\n");
3454 return &null_variable.ID3D10EffectVariable_iface;
3457 static struct ID3D10EffectPass * STDMETHODCALLTYPE d3d10_effect_technique_GetPassByIndex(ID3D10EffectTechnique *iface,
3458 UINT index)
3460 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3461 struct d3d10_effect_pass *p;
3463 TRACE("iface %p, index %u\n", iface, index);
3465 if (index >= This->pass_count)
3467 WARN("Invalid index specified\n");
3468 return &null_pass.ID3D10EffectPass_iface;
3471 p = &This->passes[index];
3473 TRACE("Returning pass %p, %s.\n", p, debugstr_a(p->name));
3475 return &p->ID3D10EffectPass_iface;
3478 static struct ID3D10EffectPass * STDMETHODCALLTYPE d3d10_effect_technique_GetPassByName(ID3D10EffectTechnique *iface,
3479 const char *name)
3481 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3482 unsigned int i;
3484 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3486 /* Do not check for name==NULL, W7/DX10 crashes in that case. */
3488 for (i = 0; i < This->pass_count; ++i)
3490 struct d3d10_effect_pass *p = &This->passes[i];
3491 if (p->name && !strcmp(p->name, name))
3493 TRACE("Returning pass %p\n", p);
3494 return &p->ID3D10EffectPass_iface;
3498 WARN("Invalid name specified\n");
3500 return &null_pass.ID3D10EffectPass_iface;
3503 static HRESULT STDMETHODCALLTYPE d3d10_effect_technique_ComputeStateBlockMask(ID3D10EffectTechnique *iface,
3504 D3D10_STATE_BLOCK_MASK *mask)
3506 FIXME("iface %p,mask %p stub!\n", iface, mask);
3508 return E_NOTIMPL;
3511 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl =
3513 /* ID3D10EffectTechnique methods */
3514 d3d10_effect_technique_IsValid,
3515 d3d10_effect_technique_GetDesc,
3516 d3d10_effect_technique_GetAnnotationByIndex,
3517 d3d10_effect_technique_GetAnnotationByName,
3518 d3d10_effect_technique_GetPassByIndex,
3519 d3d10_effect_technique_GetPassByName,
3520 d3d10_effect_technique_ComputeStateBlockMask,
3523 /* ID3D10EffectPass methods */
3525 static inline struct d3d10_effect_pass *impl_from_ID3D10EffectPass(ID3D10EffectPass *iface)
3527 return CONTAINING_RECORD(iface, struct d3d10_effect_pass, ID3D10EffectPass_iface);
3530 static BOOL STDMETHODCALLTYPE d3d10_effect_pass_IsValid(ID3D10EffectPass *iface)
3532 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3534 TRACE("iface %p\n", iface);
3536 return This != &null_pass;
3539 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetDesc(ID3D10EffectPass *iface,
3540 D3D10_PASS_DESC *desc)
3542 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3543 struct d3d10_effect_shader_variable *s;
3545 FIXME("iface %p, desc %p partial stub!\n", iface, desc);
3547 if(This == &null_pass)
3549 WARN("Null pass specified\n");
3550 return E_FAIL;
3553 if(!desc)
3555 WARN("Invalid argument specified\n");
3556 return E_INVALIDARG;
3559 memset(desc, 0, sizeof(*desc));
3560 desc->Name = This->name;
3562 s = &impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)This->vs.pShaderVariable)->u.shader;
3563 desc->pIAInputSignature = (BYTE *)s->input_signature.signature;
3564 desc->IAInputSignatureSize = s->input_signature.signature_size;
3566 desc->StencilRef = This->stencil_ref;
3567 desc->SampleMask = This->sample_mask;
3568 memcpy(desc->BlendFactor, This->blend_factor, 4 * sizeof(float));
3570 return S_OK;
3573 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetVertexShaderDesc(ID3D10EffectPass *iface,
3574 D3D10_PASS_SHADER_DESC *desc)
3576 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3578 TRACE("iface %p, desc %p\n", iface, desc);
3580 if (This == &null_pass)
3582 WARN("Null pass specified\n");
3583 return E_FAIL;
3586 if (!desc)
3588 WARN("Invalid argument specified\n");
3589 return E_INVALIDARG;
3592 *desc = This->vs;
3594 return S_OK;
3597 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetGeometryShaderDesc(ID3D10EffectPass *iface,
3598 D3D10_PASS_SHADER_DESC *desc)
3600 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3602 TRACE("iface %p, desc %p\n", iface, desc);
3604 if (This == &null_pass)
3606 WARN("Null pass specified\n");
3607 return E_FAIL;
3610 if (!desc)
3612 WARN("Invalid argument specified\n");
3613 return E_INVALIDARG;
3616 *desc = This->gs;
3618 return S_OK;
3621 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetPixelShaderDesc(ID3D10EffectPass *iface,
3622 D3D10_PASS_SHADER_DESC *desc)
3624 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3626 TRACE("iface %p, desc %p\n", iface, desc);
3628 if (This == &null_pass)
3630 WARN("Null pass specified\n");
3631 return E_FAIL;
3634 if (!desc)
3636 WARN("Invalid argument specified\n");
3637 return E_INVALIDARG;
3640 *desc = This->ps;
3642 return S_OK;
3645 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByIndex(ID3D10EffectPass *iface,
3646 UINT index)
3648 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3649 struct d3d10_effect_variable *a;
3651 TRACE("iface %p, index %u\n", iface, index);
3653 if (index >= This->annotation_count)
3655 WARN("Invalid index specified\n");
3656 return &null_variable.ID3D10EffectVariable_iface;
3659 a = &This->annotations[index];
3661 TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name));
3663 return &a->ID3D10EffectVariable_iface;
3666 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByName(ID3D10EffectPass *iface,
3667 const char *name)
3669 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3670 unsigned int i;
3672 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3674 for (i = 0; i < This->annotation_count; ++i)
3676 struct d3d10_effect_variable *a = &This->annotations[i];
3677 if (a->name && !strcmp(a->name, name))
3679 TRACE("Returning annotation %p\n", a);
3680 return &a->ID3D10EffectVariable_iface;
3684 WARN("Invalid name specified\n");
3686 return &null_variable.ID3D10EffectVariable_iface;
3689 static void update_buffer(ID3D10Device *device, struct d3d10_effect_variable *v)
3691 struct d3d10_effect_buffer_variable *b = &v->u.buffer;
3693 if (!b->changed)
3694 return;
3696 ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)b->buffer, 0, NULL,
3697 b->local_buffer, v->data_size, 0);
3699 b->changed = FALSE;
3702 static void apply_shader_resources(ID3D10Device *device, struct ID3D10EffectShaderVariable *variable)
3704 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(variable);
3705 struct d3d10_effect_shader_variable *sv = &v->u.shader;
3706 struct d3d10_effect_shader_resource *sr;
3707 struct d3d10_effect_variable *rsrc_v;
3708 ID3D10ShaderResourceView **srv;
3709 unsigned int i;
3711 for (i = 0; i < sv->resource_count; ++i)
3713 sr = &sv->resources[i];
3714 rsrc_v = sr->variable;
3716 switch (sr->in_type)
3718 case D3D10_SIT_CBUFFER:
3719 update_buffer(device, rsrc_v);
3720 switch (v->type->basetype)
3722 case D3D10_SVT_VERTEXSHADER:
3723 ID3D10Device_VSSetConstantBuffers(device, sr->bind_point, sr->bind_count,
3724 &rsrc_v->u.buffer.buffer);
3725 break;
3727 case D3D10_SVT_PIXELSHADER:
3728 ID3D10Device_PSSetConstantBuffers(device, sr->bind_point, sr->bind_count,
3729 &rsrc_v->u.buffer.buffer);
3730 break;
3732 case D3D10_SVT_GEOMETRYSHADER:
3733 ID3D10Device_GSSetConstantBuffers(device, sr->bind_point, sr->bind_count,
3734 &rsrc_v->u.buffer.buffer);
3735 break;
3737 default:
3738 WARN("Incorrect shader type to bind constant buffer.\n");
3739 break;
3741 break;
3743 case D3D10_SIT_TBUFFER:
3744 case D3D10_SIT_TEXTURE:
3745 if (sr->in_type == D3D10_SIT_TBUFFER)
3747 update_buffer(device, rsrc_v);
3748 srv = &rsrc_v->u.buffer.resource_view;
3750 else
3751 srv = rsrc_v->u.resource.srv;
3753 switch (v->type->basetype)
3755 case D3D10_SVT_VERTEXSHADER:
3756 ID3D10Device_VSSetShaderResources(device, sr->bind_point, sr->bind_count, srv);
3757 break;
3759 case D3D10_SVT_PIXELSHADER:
3760 ID3D10Device_PSSetShaderResources(device, sr->bind_point, sr->bind_count, srv);
3761 break;
3763 case D3D10_SVT_GEOMETRYSHADER:
3764 ID3D10Device_GSSetShaderResources(device, sr->bind_point, sr->bind_count, srv);
3765 break;
3767 default:
3768 WARN("Incorrect shader type to bind shader resource view.\n");
3769 break;
3771 break;
3773 case D3D10_SIT_SAMPLER:
3774 switch (v->type->basetype)
3776 case D3D10_SVT_VERTEXSHADER:
3777 ID3D10Device_VSSetSamplers(device, sr->bind_point, sr->bind_count,
3778 &rsrc_v->u.state.object.sampler);
3779 break;
3781 case D3D10_SVT_PIXELSHADER:
3782 ID3D10Device_PSSetSamplers(device, sr->bind_point, sr->bind_count,
3783 &rsrc_v->u.state.object.sampler);
3784 break;
3786 case D3D10_SVT_GEOMETRYSHADER:
3787 ID3D10Device_GSSetSamplers(device, sr->bind_point, sr->bind_count,
3788 &rsrc_v->u.state.object.sampler);
3789 break;
3791 default:
3792 WARN("Incorrect shader type to bind sampler.\n");
3793 break;
3795 break;
3797 default:
3798 WARN("Unhandled shader resource %#x.\n", sr->in_type);
3799 break;
3804 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_Apply(ID3D10EffectPass *iface, UINT flags)
3806 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
3807 ID3D10Device *device = pass->technique->effect->device;
3808 HRESULT hr = S_OK;
3809 unsigned int i;
3811 TRACE("iface %p, flags %#x\n", iface, flags);
3813 if (flags) FIXME("Ignoring flags (%#x)\n", flags);
3815 if (pass->vs.pShaderVariable != (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface)
3816 apply_shader_resources(device, pass->vs.pShaderVariable);
3817 if (pass->gs.pShaderVariable != (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface)
3818 apply_shader_resources(device, pass->gs.pShaderVariable);
3819 if (pass->ps.pShaderVariable != (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface)
3820 apply_shader_resources(device, pass->ps.pShaderVariable);
3822 for (i = 0; i < pass->object_count; ++i)
3824 hr = d3d10_effect_object_apply(&pass->objects[i]);
3825 if (FAILED(hr)) break;
3828 return hr;
3831 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_ComputeStateBlockMask(ID3D10EffectPass *iface,
3832 D3D10_STATE_BLOCK_MASK *mask)
3834 FIXME("iface %p, mask %p stub!\n", iface, mask);
3836 return E_NOTIMPL;
3839 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl =
3841 /* ID3D10EffectPass methods */
3842 d3d10_effect_pass_IsValid,
3843 d3d10_effect_pass_GetDesc,
3844 d3d10_effect_pass_GetVertexShaderDesc,
3845 d3d10_effect_pass_GetGeometryShaderDesc,
3846 d3d10_effect_pass_GetPixelShaderDesc,
3847 d3d10_effect_pass_GetAnnotationByIndex,
3848 d3d10_effect_pass_GetAnnotationByName,
3849 d3d10_effect_pass_Apply,
3850 d3d10_effect_pass_ComputeStateBlockMask,
3853 /* ID3D10EffectVariable methods */
3855 static BOOL STDMETHODCALLTYPE d3d10_effect_variable_IsValid(ID3D10EffectVariable *iface)
3857 TRACE("iface %p\n", iface);
3859 return impl_from_ID3D10EffectVariable(iface) != &null_variable;
3862 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_variable_GetType(ID3D10EffectVariable *iface)
3864 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3866 TRACE("iface %p\n", iface);
3868 return &This->type->ID3D10EffectType_iface;
3871 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetDesc(ID3D10EffectVariable *iface,
3872 D3D10_EFFECT_VARIABLE_DESC *desc)
3874 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3876 TRACE("iface %p, desc %p\n", iface, desc);
3878 if (!iface->lpVtbl->IsValid(iface))
3880 WARN("Null variable specified\n");
3881 return E_FAIL;
3884 if (!desc)
3886 WARN("Invalid argument specified\n");
3887 return E_INVALIDARG;
3890 /* FIXME: This isn't correct. Anonymous shaders let desc->ExplicitBindPoint untouched, but normal shaders set it! */
3891 memset(desc, 0, sizeof(*desc));
3892 desc->Name = This->name;
3893 desc->Semantic = This->semantic;
3894 desc->Flags = This->flag;
3895 desc->Annotations = This->annotation_count;
3896 desc->BufferOffset = This->buffer_offset;
3898 if (This->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
3900 desc->ExplicitBindPoint = This->buffer_offset;
3903 return S_OK;
3906 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByIndex(
3907 ID3D10EffectVariable *iface, UINT index)
3909 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3910 struct d3d10_effect_variable *a;
3912 TRACE("iface %p, index %u\n", iface, index);
3914 if (index >= This->annotation_count)
3916 WARN("Invalid index specified\n");
3917 return &null_variable.ID3D10EffectVariable_iface;
3920 a = &This->annotations[index];
3922 TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name));
3924 return &a->ID3D10EffectVariable_iface;
3927 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByName(
3928 ID3D10EffectVariable *iface, const char *name)
3930 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3931 unsigned int i;
3933 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3935 for (i = 0; i < This->annotation_count; ++i)
3937 struct d3d10_effect_variable *a = &This->annotations[i];
3938 if (a->name && !strcmp(a->name, name))
3940 TRACE("Returning annotation %p\n", a);
3941 return &a->ID3D10EffectVariable_iface;
3945 WARN("Invalid name specified\n");
3947 return &null_variable.ID3D10EffectVariable_iface;
3950 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberByIndex(
3951 ID3D10EffectVariable *iface, UINT index)
3953 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3954 struct d3d10_effect_variable *m;
3956 TRACE("iface %p, index %u\n", iface, index);
3958 if (index >= This->type->member_count)
3960 WARN("Invalid index specified\n");
3961 return &null_variable.ID3D10EffectVariable_iface;
3964 m = &This->members[index];
3966 TRACE("Returning member %p, %s\n", m, debugstr_a(m->name));
3968 return &m->ID3D10EffectVariable_iface;
3971 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberByName(
3972 ID3D10EffectVariable *iface, const char *name)
3974 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3975 unsigned int i;
3977 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3979 if (!name)
3981 WARN("Invalid name specified\n");
3982 return &null_variable.ID3D10EffectVariable_iface;
3985 for (i = 0; i < This->type->member_count; ++i)
3987 struct d3d10_effect_variable *m = &This->members[i];
3989 if (m->name && !strcmp(m->name, name))
3991 TRACE("Returning member %p\n", m);
3992 return &m->ID3D10EffectVariable_iface;
3996 WARN("Invalid name specified\n");
3998 return &null_variable.ID3D10EffectVariable_iface;
4001 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberBySemantic(
4002 ID3D10EffectVariable *iface, const char *semantic)
4004 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4005 unsigned int i;
4007 TRACE("iface %p, semantic %s.\n", iface, debugstr_a(semantic));
4009 if (!semantic)
4011 WARN("Invalid semantic specified\n");
4012 return &null_variable.ID3D10EffectVariable_iface;
4015 for (i = 0; i < This->type->member_count; ++i)
4017 struct d3d10_effect_variable *m = &This->members[i];
4019 if (m->semantic && !strcmp(m->semantic, semantic))
4021 TRACE("Returning member %p\n", m);
4022 return &m->ID3D10EffectVariable_iface;
4026 WARN("Invalid semantic specified\n");
4028 return &null_variable.ID3D10EffectVariable_iface;
4031 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetElement(
4032 ID3D10EffectVariable *iface, UINT index)
4034 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4035 struct d3d10_effect_variable *v;
4037 TRACE("iface %p, index %u\n", iface, index);
4039 if (index >= This->type->element_count)
4041 WARN("Invalid index specified\n");
4042 return &null_variable.ID3D10EffectVariable_iface;
4045 v = &This->elements[index];
4047 TRACE("Returning element %p, %s\n", v, debugstr_a(v->name));
4049 return &v->ID3D10EffectVariable_iface;
4052 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_variable_GetParentConstantBuffer(
4053 ID3D10EffectVariable *iface)
4055 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4057 TRACE("iface %p\n", iface);
4059 return (ID3D10EffectConstantBuffer *)&This->buffer->ID3D10EffectVariable_iface;
4062 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsScalar(
4063 ID3D10EffectVariable *iface)
4065 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4067 TRACE("iface %p\n", iface);
4069 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl)
4070 return (ID3D10EffectScalarVariable *)&This->ID3D10EffectVariable_iface;
4072 return (ID3D10EffectScalarVariable *)&null_scalar_variable.ID3D10EffectVariable_iface;
4075 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsVector(
4076 ID3D10EffectVariable *iface)
4078 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4080 TRACE("iface %p\n", iface);
4082 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl)
4083 return (ID3D10EffectVectorVariable *)&This->ID3D10EffectVariable_iface;
4085 return (ID3D10EffectVectorVariable *)&null_vector_variable.ID3D10EffectVariable_iface;
4088 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsMatrix(
4089 ID3D10EffectVariable *iface)
4091 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4093 TRACE("iface %p\n", iface);
4095 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl)
4096 return (ID3D10EffectMatrixVariable *)&This->ID3D10EffectVariable_iface;
4098 return (ID3D10EffectMatrixVariable *)&null_matrix_variable.ID3D10EffectVariable_iface;
4101 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsString(
4102 ID3D10EffectVariable *iface)
4104 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4106 TRACE("iface %p\n", iface);
4108 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl)
4109 return (ID3D10EffectStringVariable *)&This->ID3D10EffectVariable_iface;
4111 return (ID3D10EffectStringVariable *)&null_string_variable.ID3D10EffectVariable_iface;
4114 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsShaderResource(
4115 ID3D10EffectVariable *iface)
4117 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4119 TRACE("iface %p\n", iface);
4121 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl)
4122 return (ID3D10EffectShaderResourceVariable *)&This->ID3D10EffectVariable_iface;
4124 return (ID3D10EffectShaderResourceVariable *)&null_shader_resource_variable.ID3D10EffectVariable_iface;
4127 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsRenderTargetView(
4128 ID3D10EffectVariable *iface)
4130 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4132 TRACE("iface %p\n", iface);
4134 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl)
4135 return (ID3D10EffectRenderTargetViewVariable *)&This->ID3D10EffectVariable_iface;
4137 return (ID3D10EffectRenderTargetViewVariable *)&null_render_target_view_variable.ID3D10EffectVariable_iface;
4140 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsDepthStencilView(
4141 ID3D10EffectVariable *iface)
4143 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4145 TRACE("iface %p\n", iface);
4147 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl)
4148 return (ID3D10EffectDepthStencilViewVariable *)&This->ID3D10EffectVariable_iface;
4150 return (ID3D10EffectDepthStencilViewVariable *)&null_depth_stencil_view_variable.ID3D10EffectVariable_iface;
4153 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_variable_AsConstantBuffer(
4154 ID3D10EffectVariable *iface)
4156 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4158 TRACE("iface %p\n", iface);
4160 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl)
4161 return (ID3D10EffectConstantBuffer *)&This->ID3D10EffectVariable_iface;
4163 return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
4166 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsShader(
4167 ID3D10EffectVariable *iface)
4169 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4171 TRACE("iface %p\n", iface);
4173 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl)
4174 return (ID3D10EffectShaderVariable *)&This->ID3D10EffectVariable_iface;
4176 return (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
4179 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsBlend(ID3D10EffectVariable *iface)
4181 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4183 TRACE("iface %p\n", iface);
4185 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl)
4186 return (ID3D10EffectBlendVariable *)&This->ID3D10EffectVariable_iface;
4188 return (ID3D10EffectBlendVariable *)&null_blend_variable.ID3D10EffectVariable_iface;
4191 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsDepthStencil(
4192 ID3D10EffectVariable *iface)
4194 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4196 TRACE("iface %p\n", iface);
4198 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl)
4199 return (ID3D10EffectDepthStencilVariable *)&This->ID3D10EffectVariable_iface;
4201 return (ID3D10EffectDepthStencilVariable *)&null_depth_stencil_variable.ID3D10EffectVariable_iface;
4204 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsRasterizer(
4205 ID3D10EffectVariable *iface)
4207 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4209 TRACE("iface %p\n", iface);
4211 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl)
4212 return (ID3D10EffectRasterizerVariable *)&This->ID3D10EffectVariable_iface;
4214 return (ID3D10EffectRasterizerVariable *)&null_rasterizer_variable.ID3D10EffectVariable_iface;
4217 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsSampler(
4218 ID3D10EffectVariable *iface)
4220 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4222 TRACE("iface %p\n", iface);
4224 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl)
4225 return (ID3D10EffectSamplerVariable *)&This->ID3D10EffectVariable_iface;
4227 return (ID3D10EffectSamplerVariable *)&null_sampler_variable.ID3D10EffectVariable_iface;
4230 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_SetRawValue(ID3D10EffectVariable *iface,
4231 void *data, UINT offset, UINT count)
4233 FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
4235 return E_NOTIMPL;
4238 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetRawValue(ID3D10EffectVariable *iface,
4239 void *data, UINT offset, UINT count)
4241 FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
4243 return E_NOTIMPL;
4246 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl =
4248 /* ID3D10EffectVariable methods */
4249 d3d10_effect_variable_IsValid,
4250 d3d10_effect_variable_GetType,
4251 d3d10_effect_variable_GetDesc,
4252 d3d10_effect_variable_GetAnnotationByIndex,
4253 d3d10_effect_variable_GetAnnotationByName,
4254 d3d10_effect_variable_GetMemberByIndex,
4255 d3d10_effect_variable_GetMemberByName,
4256 d3d10_effect_variable_GetMemberBySemantic,
4257 d3d10_effect_variable_GetElement,
4258 d3d10_effect_variable_GetParentConstantBuffer,
4259 d3d10_effect_variable_AsScalar,
4260 d3d10_effect_variable_AsVector,
4261 d3d10_effect_variable_AsMatrix,
4262 d3d10_effect_variable_AsString,
4263 d3d10_effect_variable_AsShaderResource,
4264 d3d10_effect_variable_AsRenderTargetView,
4265 d3d10_effect_variable_AsDepthStencilView,
4266 d3d10_effect_variable_AsConstantBuffer,
4267 d3d10_effect_variable_AsShader,
4268 d3d10_effect_variable_AsBlend,
4269 d3d10_effect_variable_AsDepthStencil,
4270 d3d10_effect_variable_AsRasterizer,
4271 d3d10_effect_variable_AsSampler,
4272 d3d10_effect_variable_SetRawValue,
4273 d3d10_effect_variable_GetRawValue,
4276 /* ID3D10EffectVariable methods */
4277 static BOOL STDMETHODCALLTYPE d3d10_effect_constant_buffer_IsValid(ID3D10EffectConstantBuffer *iface)
4279 TRACE("iface %p\n", iface);
4281 return (struct d3d10_effect_variable *)iface != &null_local_buffer;
4284 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetType(ID3D10EffectConstantBuffer *iface)
4286 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
4289 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetDesc(ID3D10EffectConstantBuffer *iface,
4290 D3D10_EFFECT_VARIABLE_DESC *desc)
4292 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
4295 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetAnnotationByIndex(
4296 ID3D10EffectConstantBuffer *iface, UINT index)
4298 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
4301 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetAnnotationByName(
4302 ID3D10EffectConstantBuffer *iface, const char *name)
4304 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
4307 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberByIndex(
4308 ID3D10EffectConstantBuffer *iface, UINT index)
4310 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
4313 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberByName(
4314 ID3D10EffectConstantBuffer *iface, const char *name)
4316 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
4319 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberBySemantic(
4320 ID3D10EffectConstantBuffer *iface, const char *semantic)
4322 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
4325 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetElement(
4326 ID3D10EffectConstantBuffer *iface, UINT index)
4328 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
4331 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetParentConstantBuffer(
4332 ID3D10EffectConstantBuffer *iface)
4334 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
4337 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsScalar(
4338 ID3D10EffectConstantBuffer *iface)
4340 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
4343 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsVector(
4344 ID3D10EffectConstantBuffer *iface)
4346 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
4349 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsMatrix(
4350 ID3D10EffectConstantBuffer *iface)
4352 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
4355 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsString(
4356 ID3D10EffectConstantBuffer *iface)
4358 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
4361 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsShaderResource(
4362 ID3D10EffectConstantBuffer *iface)
4364 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
4367 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsRenderTargetView(
4368 ID3D10EffectConstantBuffer *iface)
4370 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
4373 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsDepthStencilView(
4374 ID3D10EffectConstantBuffer *iface)
4376 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
4379 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsConstantBuffer(
4380 ID3D10EffectConstantBuffer *iface)
4382 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
4385 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsShader(
4386 ID3D10EffectConstantBuffer *iface)
4388 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
4391 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsBlend(ID3D10EffectConstantBuffer *iface)
4393 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
4396 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsDepthStencil(
4397 ID3D10EffectConstantBuffer *iface)
4399 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
4402 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsRasterizer(
4403 ID3D10EffectConstantBuffer *iface)
4405 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
4408 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsSampler(
4409 ID3D10EffectConstantBuffer *iface)
4411 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
4414 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetRawValue(ID3D10EffectConstantBuffer *iface,
4415 void *data, UINT offset, UINT count)
4417 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4420 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetRawValue(ID3D10EffectConstantBuffer *iface,
4421 void *data, UINT offset, UINT count)
4423 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4426 /* ID3D10EffectConstantBuffer methods */
4427 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetConstantBuffer(ID3D10EffectConstantBuffer *iface,
4428 ID3D10Buffer *buffer)
4430 FIXME("iface %p, buffer %p stub!\n", iface, buffer);
4432 return E_NOTIMPL;
4435 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetConstantBuffer(ID3D10EffectConstantBuffer *iface,
4436 ID3D10Buffer **buffer)
4438 FIXME("iface %p, buffer %p stub!\n", iface, buffer);
4440 return E_NOTIMPL;
4443 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetTextureBuffer(ID3D10EffectConstantBuffer *iface,
4444 ID3D10ShaderResourceView *view)
4446 FIXME("iface %p, view %p stub!\n", iface, view);
4448 return E_NOTIMPL;
4451 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetTextureBuffer(ID3D10EffectConstantBuffer *iface,
4452 ID3D10ShaderResourceView **view)
4454 FIXME("iface %p, view %p stub!\n", iface, view);
4456 return E_NOTIMPL;
4459 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl =
4461 /* ID3D10EffectVariable methods */
4462 d3d10_effect_constant_buffer_IsValid,
4463 d3d10_effect_constant_buffer_GetType,
4464 d3d10_effect_constant_buffer_GetDesc,
4465 d3d10_effect_constant_buffer_GetAnnotationByIndex,
4466 d3d10_effect_constant_buffer_GetAnnotationByName,
4467 d3d10_effect_constant_buffer_GetMemberByIndex,
4468 d3d10_effect_constant_buffer_GetMemberByName,
4469 d3d10_effect_constant_buffer_GetMemberBySemantic,
4470 d3d10_effect_constant_buffer_GetElement,
4471 d3d10_effect_constant_buffer_GetParentConstantBuffer,
4472 d3d10_effect_constant_buffer_AsScalar,
4473 d3d10_effect_constant_buffer_AsVector,
4474 d3d10_effect_constant_buffer_AsMatrix,
4475 d3d10_effect_constant_buffer_AsString,
4476 d3d10_effect_constant_buffer_AsShaderResource,
4477 d3d10_effect_constant_buffer_AsRenderTargetView,
4478 d3d10_effect_constant_buffer_AsDepthStencilView,
4479 d3d10_effect_constant_buffer_AsConstantBuffer,
4480 d3d10_effect_constant_buffer_AsShader,
4481 d3d10_effect_constant_buffer_AsBlend,
4482 d3d10_effect_constant_buffer_AsDepthStencil,
4483 d3d10_effect_constant_buffer_AsRasterizer,
4484 d3d10_effect_constant_buffer_AsSampler,
4485 d3d10_effect_constant_buffer_SetRawValue,
4486 d3d10_effect_constant_buffer_GetRawValue,
4487 /* ID3D10EffectConstantBuffer methods */
4488 d3d10_effect_constant_buffer_SetConstantBuffer,
4489 d3d10_effect_constant_buffer_GetConstantBuffer,
4490 d3d10_effect_constant_buffer_SetTextureBuffer,
4491 d3d10_effect_constant_buffer_GetTextureBuffer,
4495 static BOOL get_value_as_bool(void *src_data, D3D10_SHADER_VARIABLE_TYPE src_type)
4497 switch (src_type)
4499 case D3D10_SVT_FLOAT:
4500 case D3D10_SVT_INT:
4501 case D3D10_SVT_BOOL:
4502 if (*(DWORD *)src_data)
4503 return -1;
4504 break;
4506 default:
4507 break;
4510 return 0;
4513 static int get_value_as_int(void *src_data, D3D10_SHADER_VARIABLE_TYPE src_type)
4515 switch (src_type)
4517 case D3D10_SVT_FLOAT:
4518 return (int)(*(float *)src_data);
4520 case D3D10_SVT_INT:
4521 return *(int *)src_data;
4523 case D3D10_SVT_BOOL:
4524 return get_value_as_bool(src_data, src_type);
4526 default:
4527 return 0;
4531 static float get_value_as_float(void *src_data, D3D10_SHADER_VARIABLE_TYPE src_type)
4533 switch (src_type)
4535 case D3D10_SVT_FLOAT:
4536 return *(float *)src_data;
4538 case D3D10_SVT_INT:
4539 return (float)(*(int *)src_data);
4541 case D3D10_SVT_BOOL:
4542 return (float)get_value_as_bool(src_data, src_type);
4544 default:
4545 return 0.0f;
4549 static void get_vector_as_type(BYTE *dst_data, D3D_SHADER_VARIABLE_TYPE dst_type,
4550 BYTE *src_data, D3D_SHADER_VARIABLE_TYPE src_type, unsigned int count)
4552 DWORD *src_data_dword = (DWORD *)src_data;
4553 DWORD *dst_data_dword = (DWORD *)dst_data;
4554 unsigned int i;
4556 for (i = 0; i < count; ++i, ++dst_data_dword, ++src_data_dword)
4558 if (dst_type == src_type)
4559 *dst_data_dword = *src_data_dword;
4560 else
4562 switch (dst_type)
4564 case D3D10_SVT_FLOAT:
4565 *(float *)dst_data_dword = get_value_as_float(src_data_dword, src_type);
4566 break;
4568 case D3D10_SVT_INT:
4569 *(int *)dst_data_dword = get_value_as_int(src_data_dword, src_type);
4570 break;
4572 case D3D10_SVT_BOOL:
4573 *(BOOL *)dst_data_dword = get_value_as_bool(src_data_dword, src_type);
4574 break;
4576 default:
4577 *dst_data_dword = 0;
4578 break;
4584 static void write_variable_to_buffer(struct d3d10_effect_variable *variable, void *src,
4585 D3D_SHADER_VARIABLE_TYPE src_type)
4587 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4588 D3D_SHADER_VARIABLE_TYPE dst_type = variable->type->basetype;
4590 get_vector_as_type(dst, dst_type, src, src_type, variable->type->column_count);
4592 variable->buffer->u.buffer.changed = TRUE;
4595 static void write_variable_array_to_buffer(struct d3d10_effect_variable *variable, void *src,
4596 D3D_SHADER_VARIABLE_TYPE src_type, unsigned int offset, unsigned int count)
4598 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4599 D3D_SHADER_VARIABLE_TYPE dst_type = variable->type->basetype;
4600 unsigned int element_size, i;
4601 BYTE *cur_element = src;
4603 if (!variable->type->element_count)
4605 write_variable_to_buffer(variable, src, src_type);
4606 return;
4609 if (offset >= variable->type->element_count)
4611 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
4612 return;
4615 if (count > variable->type->element_count - offset)
4617 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
4618 offset, count, variable->type->element_count);
4619 count = variable->type->element_count - offset;
4622 element_size = variable->type->elementtype->size_packed;
4623 dst += variable->type->stride * offset;
4625 for (i = 0; i < count; ++i)
4627 get_vector_as_type(dst, dst_type, cur_element, src_type, variable->type->column_count);
4629 cur_element += element_size;
4630 dst += variable->type->stride;
4633 variable->buffer->u.buffer.changed = TRUE;
4636 static void read_variable_from_buffer(struct d3d10_effect_variable *variable, void *dst,
4637 D3D_SHADER_VARIABLE_TYPE dst_type)
4639 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4640 D3D_SHADER_VARIABLE_TYPE src_type = variable->type->basetype;
4642 get_vector_as_type(dst, dst_type, src, src_type, variable->type->column_count);
4645 static void read_variable_array_from_buffer(struct d3d10_effect_variable *variable, void *dst,
4646 D3D_SHADER_VARIABLE_TYPE dst_type, unsigned int offset, unsigned int count)
4648 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4649 D3D_SHADER_VARIABLE_TYPE src_type = variable->type->basetype;
4650 unsigned int element_size, i;
4651 BYTE *cur_element = dst;
4653 if (!variable->type->element_count)
4655 read_variable_from_buffer(variable, dst, dst_type);
4656 return;
4659 if (offset >= variable->type->element_count)
4661 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
4662 return;
4665 if (count > variable->type->element_count - offset)
4667 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
4668 offset, count, variable->type->element_count);
4669 count = variable->type->element_count - offset;
4672 element_size = variable->type->elementtype->size_packed;
4673 src += variable->type->stride * offset;
4675 for (i = 0; i < count; ++i)
4677 get_vector_as_type(cur_element, dst_type, src, src_type, variable->type->column_count);
4679 cur_element += element_size;
4680 src += variable->type->stride;
4684 /* ID3D10EffectVariable methods */
4686 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectScalarVariable(ID3D10EffectScalarVariable *iface)
4688 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
4691 static BOOL STDMETHODCALLTYPE d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable *iface)
4693 TRACE("iface %p\n", iface);
4695 return (struct d3d10_effect_variable *)iface != &null_scalar_variable;
4698 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetType(
4699 ID3D10EffectScalarVariable *iface)
4701 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
4704 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetDesc(ID3D10EffectScalarVariable *iface,
4705 D3D10_EFFECT_VARIABLE_DESC *desc)
4707 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
4710 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetAnnotationByIndex(
4711 ID3D10EffectScalarVariable *iface, UINT index)
4713 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
4716 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetAnnotationByName(
4717 ID3D10EffectScalarVariable *iface, const char *name)
4719 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
4722 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberByIndex(
4723 ID3D10EffectScalarVariable *iface, UINT index)
4725 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
4728 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberByName(
4729 ID3D10EffectScalarVariable *iface, const char *name)
4731 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
4734 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberBySemantic(
4735 ID3D10EffectScalarVariable *iface, const char *semantic)
4737 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
4740 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetElement(
4741 ID3D10EffectScalarVariable *iface, UINT index)
4743 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
4746 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetParentConstantBuffer(
4747 ID3D10EffectScalarVariable *iface)
4749 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
4752 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsScalar(
4753 ID3D10EffectScalarVariable *iface)
4755 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
4758 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsVector(
4759 ID3D10EffectScalarVariable *iface)
4761 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
4764 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsMatrix(
4765 ID3D10EffectScalarVariable *iface)
4767 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
4770 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsString(
4771 ID3D10EffectScalarVariable *iface)
4773 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
4776 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsShaderResource(
4777 ID3D10EffectScalarVariable *iface)
4779 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
4782 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsRenderTargetView(
4783 ID3D10EffectScalarVariable *iface)
4785 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
4788 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsDepthStencilView(
4789 ID3D10EffectScalarVariable *iface)
4791 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
4794 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsConstantBuffer(
4795 ID3D10EffectScalarVariable *iface)
4797 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
4800 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsShader(
4801 ID3D10EffectScalarVariable *iface)
4803 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
4806 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsBlend(
4807 ID3D10EffectScalarVariable *iface)
4809 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
4812 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsDepthStencil(
4813 ID3D10EffectScalarVariable *iface)
4815 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
4818 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsRasterizer(
4819 ID3D10EffectScalarVariable *iface)
4821 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
4824 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsSampler(
4825 ID3D10EffectScalarVariable *iface)
4827 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
4830 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetRawValue(ID3D10EffectScalarVariable *iface,
4831 void *data, UINT offset, UINT count)
4833 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4836 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetRawValue(ID3D10EffectScalarVariable *iface,
4837 void *data, UINT offset, UINT count)
4839 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4842 /* ID3D10EffectScalarVariable methods */
4844 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloat(ID3D10EffectScalarVariable *iface,
4845 float value)
4847 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4849 TRACE("iface %p, value %.8e.\n", iface, value);
4850 write_variable_to_buffer(effect_var, &value, D3D10_SVT_FLOAT);
4852 return S_OK;
4855 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable *iface,
4856 float *value)
4858 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4860 TRACE("iface %p, value %p.\n", iface, value);
4861 read_variable_from_buffer(effect_var, value, D3D10_SVT_FLOAT);
4863 return S_OK;
4866 /* Tests show that offset is ignored for scalar variables. */
4867 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloatArray(ID3D10EffectScalarVariable *iface,
4868 float *values, UINT offset, UINT count)
4870 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4872 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4873 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_FLOAT, 0, count);
4875 return S_OK;
4878 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable *iface,
4879 float *values, UINT offset, UINT count)
4881 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4883 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4884 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_FLOAT, 0, count);
4886 return S_OK;
4889 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable *iface,
4890 int value)
4892 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4894 TRACE("iface %p, value %d.\n", iface, value);
4895 write_variable_to_buffer(effect_var, &value, D3D10_SVT_INT);
4897 return S_OK;
4900 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetInt(ID3D10EffectScalarVariable *iface,
4901 int *value)
4903 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4905 TRACE("iface %p, value %p.\n", iface, value);
4906 read_variable_from_buffer(effect_var, value, D3D10_SVT_INT);
4908 return S_OK;
4911 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable *iface,
4912 int *values, UINT offset, UINT count)
4914 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4916 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4917 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_INT, 0, count);
4919 return S_OK;
4922 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable *iface,
4923 int *values, UINT offset, UINT count)
4925 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4927 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4928 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_INT, 0, count);
4930 return S_OK;
4933 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable *iface,
4934 BOOL value)
4936 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4938 TRACE("iface %p, value %d.\n", iface, value);
4939 write_variable_to_buffer(effect_var, &value, D3D10_SVT_BOOL);
4941 return S_OK;
4944 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBool(ID3D10EffectScalarVariable *iface,
4945 BOOL *value)
4947 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4949 TRACE("iface %p, value %p.\n", iface, value);
4950 read_variable_from_buffer(effect_var, value, D3D10_SVT_BOOL);
4952 return S_OK;
4955 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable *iface,
4956 BOOL *values, UINT offset, UINT count)
4958 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4960 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4961 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_BOOL, 0, count);
4963 return S_OK;
4966 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable *iface,
4967 BOOL *values, UINT offset, UINT count)
4969 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4971 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4972 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_BOOL, 0, count);
4974 return S_OK;
4977 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl =
4979 /* ID3D10EffectVariable methods */
4980 d3d10_effect_scalar_variable_IsValid,
4981 d3d10_effect_scalar_variable_GetType,
4982 d3d10_effect_scalar_variable_GetDesc,
4983 d3d10_effect_scalar_variable_GetAnnotationByIndex,
4984 d3d10_effect_scalar_variable_GetAnnotationByName,
4985 d3d10_effect_scalar_variable_GetMemberByIndex,
4986 d3d10_effect_scalar_variable_GetMemberByName,
4987 d3d10_effect_scalar_variable_GetMemberBySemantic,
4988 d3d10_effect_scalar_variable_GetElement,
4989 d3d10_effect_scalar_variable_GetParentConstantBuffer,
4990 d3d10_effect_scalar_variable_AsScalar,
4991 d3d10_effect_scalar_variable_AsVector,
4992 d3d10_effect_scalar_variable_AsMatrix,
4993 d3d10_effect_scalar_variable_AsString,
4994 d3d10_effect_scalar_variable_AsShaderResource,
4995 d3d10_effect_scalar_variable_AsRenderTargetView,
4996 d3d10_effect_scalar_variable_AsDepthStencilView,
4997 d3d10_effect_scalar_variable_AsConstantBuffer,
4998 d3d10_effect_scalar_variable_AsShader,
4999 d3d10_effect_scalar_variable_AsBlend,
5000 d3d10_effect_scalar_variable_AsDepthStencil,
5001 d3d10_effect_scalar_variable_AsRasterizer,
5002 d3d10_effect_scalar_variable_AsSampler,
5003 d3d10_effect_scalar_variable_SetRawValue,
5004 d3d10_effect_scalar_variable_GetRawValue,
5005 /* ID3D10EffectScalarVariable methods */
5006 d3d10_effect_scalar_variable_SetFloat,
5007 d3d10_effect_scalar_variable_GetFloat,
5008 d3d10_effect_scalar_variable_SetFloatArray,
5009 d3d10_effect_scalar_variable_GetFloatArray,
5010 d3d10_effect_scalar_variable_SetInt,
5011 d3d10_effect_scalar_variable_GetInt,
5012 d3d10_effect_scalar_variable_SetIntArray,
5013 d3d10_effect_scalar_variable_GetIntArray,
5014 d3d10_effect_scalar_variable_SetBool,
5015 d3d10_effect_scalar_variable_GetBool,
5016 d3d10_effect_scalar_variable_SetBoolArray,
5017 d3d10_effect_scalar_variable_GetBoolArray,
5020 /* ID3D10EffectVariable methods */
5022 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectVectorVariable(ID3D10EffectVectorVariable *iface)
5024 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
5027 static BOOL STDMETHODCALLTYPE d3d10_effect_vector_variable_IsValid(ID3D10EffectVectorVariable *iface)
5029 TRACE("iface %p\n", iface);
5031 return (struct d3d10_effect_variable *)iface != &null_vector_variable;
5034 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetType(
5035 ID3D10EffectVectorVariable *iface)
5037 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5040 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetDesc(ID3D10EffectVectorVariable *iface,
5041 D3D10_EFFECT_VARIABLE_DESC *desc)
5043 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5046 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetAnnotationByIndex(
5047 ID3D10EffectVectorVariable *iface, UINT index)
5049 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5052 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetAnnotationByName(
5053 ID3D10EffectVectorVariable *iface, const char *name)
5055 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5058 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberByIndex(
5059 ID3D10EffectVectorVariable *iface, UINT index)
5061 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5064 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberByName(
5065 ID3D10EffectVectorVariable *iface, const char *name)
5067 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5070 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberBySemantic(
5071 ID3D10EffectVectorVariable *iface, const char *semantic)
5073 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5076 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetElement(
5077 ID3D10EffectVectorVariable *iface, UINT index)
5079 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5082 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetParentConstantBuffer(
5083 ID3D10EffectVectorVariable *iface)
5085 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5088 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsScalar(
5089 ID3D10EffectVectorVariable *iface)
5091 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5094 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsVector(
5095 ID3D10EffectVectorVariable *iface)
5097 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5100 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsMatrix(
5101 ID3D10EffectVectorVariable *iface)
5103 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5106 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsString(
5107 ID3D10EffectVectorVariable *iface)
5109 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5112 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsShaderResource(
5113 ID3D10EffectVectorVariable *iface)
5115 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5118 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsRenderTargetView(
5119 ID3D10EffectVectorVariable *iface)
5121 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5124 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsDepthStencilView(
5125 ID3D10EffectVectorVariable *iface)
5127 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5130 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsConstantBuffer(
5131 ID3D10EffectVectorVariable *iface)
5133 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5136 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsShader(
5137 ID3D10EffectVectorVariable *iface)
5139 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5142 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsBlend(
5143 ID3D10EffectVectorVariable *iface)
5145 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5148 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsDepthStencil(
5149 ID3D10EffectVectorVariable *iface)
5151 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5154 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsRasterizer(
5155 ID3D10EffectVectorVariable *iface)
5157 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5160 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsSampler(
5161 ID3D10EffectVectorVariable *iface)
5163 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5166 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetRawValue(ID3D10EffectVectorVariable *iface,
5167 void *data, UINT offset, UINT count)
5169 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5172 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetRawValue(ID3D10EffectVectorVariable *iface,
5173 void *data, UINT offset, UINT count)
5175 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5178 /* ID3D10EffectVectorVariable methods */
5180 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVector(ID3D10EffectVectorVariable *iface,
5181 BOOL *value)
5183 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5185 TRACE("iface %p, value %p.\n", iface, value);
5186 write_variable_to_buffer(effect_var, value, D3D10_SVT_BOOL);
5188 return S_OK;
5191 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVector(ID3D10EffectVectorVariable *iface,
5192 int *value)
5194 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5196 TRACE("iface %p, value %p.\n", iface, value);
5197 write_variable_to_buffer(effect_var, value, D3D10_SVT_INT);
5199 return S_OK;
5202 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVector(ID3D10EffectVectorVariable *iface,
5203 float *value)
5205 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5207 TRACE("iface %p, value %p.\n", iface, value);
5208 write_variable_to_buffer(effect_var, value, D3D10_SVT_FLOAT);
5210 return S_OK;
5213 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable *iface,
5214 BOOL *value)
5216 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5218 TRACE("iface %p, value %p.\n", iface, value);
5219 read_variable_from_buffer(effect_var, value, D3D10_SVT_BOOL);
5221 return S_OK;
5224 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVector(ID3D10EffectVectorVariable *iface,
5225 int *value)
5227 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5229 TRACE("iface %p, value %p.\n", iface, value);
5230 read_variable_from_buffer(effect_var, value, D3D10_SVT_INT);
5232 return S_OK;
5235 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVector(ID3D10EffectVectorVariable *iface,
5236 float *value)
5238 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5240 TRACE("iface %p, value %p.\n", iface, value);
5241 read_variable_from_buffer(effect_var, value, D3D10_SVT_FLOAT);
5243 return S_OK;
5246 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable *iface,
5247 BOOL *values, UINT offset, UINT count)
5249 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5251 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5252 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_BOOL, offset, count);
5254 return S_OK;
5257 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVectorArray(ID3D10EffectVectorVariable *iface,
5258 int *values, UINT offset, UINT count)
5260 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5262 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5263 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_INT, offset, count);
5265 return S_OK;
5268 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVectorArray(ID3D10EffectVectorVariable *iface,
5269 float *values, UINT offset, UINT count)
5271 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5273 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5274 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_FLOAT, offset, count);
5276 return S_OK;
5279 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVectorArray(ID3D10EffectVectorVariable *iface,
5280 BOOL *values, UINT offset, UINT count)
5282 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5284 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5285 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_BOOL, offset, count);
5287 return S_OK;
5290 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVectorArray(ID3D10EffectVectorVariable *iface,
5291 int *values, UINT offset, UINT count)
5293 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5295 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5296 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_INT, offset, count);
5298 return S_OK;
5301 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVectorArray(ID3D10EffectVectorVariable *iface,
5302 float *values, UINT offset, UINT count)
5304 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5306 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5307 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_FLOAT, offset, count);
5309 return S_OK;
5312 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl =
5314 /* ID3D10EffectVariable methods */
5315 d3d10_effect_vector_variable_IsValid,
5316 d3d10_effect_vector_variable_GetType,
5317 d3d10_effect_vector_variable_GetDesc,
5318 d3d10_effect_vector_variable_GetAnnotationByIndex,
5319 d3d10_effect_vector_variable_GetAnnotationByName,
5320 d3d10_effect_vector_variable_GetMemberByIndex,
5321 d3d10_effect_vector_variable_GetMemberByName,
5322 d3d10_effect_vector_variable_GetMemberBySemantic,
5323 d3d10_effect_vector_variable_GetElement,
5324 d3d10_effect_vector_variable_GetParentConstantBuffer,
5325 d3d10_effect_vector_variable_AsScalar,
5326 d3d10_effect_vector_variable_AsVector,
5327 d3d10_effect_vector_variable_AsMatrix,
5328 d3d10_effect_vector_variable_AsString,
5329 d3d10_effect_vector_variable_AsShaderResource,
5330 d3d10_effect_vector_variable_AsRenderTargetView,
5331 d3d10_effect_vector_variable_AsDepthStencilView,
5332 d3d10_effect_vector_variable_AsConstantBuffer,
5333 d3d10_effect_vector_variable_AsShader,
5334 d3d10_effect_vector_variable_AsBlend,
5335 d3d10_effect_vector_variable_AsDepthStencil,
5336 d3d10_effect_vector_variable_AsRasterizer,
5337 d3d10_effect_vector_variable_AsSampler,
5338 d3d10_effect_vector_variable_SetRawValue,
5339 d3d10_effect_vector_variable_GetRawValue,
5340 /* ID3D10EffectVectorVariable methods */
5341 d3d10_effect_vector_variable_SetBoolVector,
5342 d3d10_effect_vector_variable_SetIntVector,
5343 d3d10_effect_vector_variable_SetFloatVector,
5344 d3d10_effect_vector_variable_GetBoolVector,
5345 d3d10_effect_vector_variable_GetIntVector,
5346 d3d10_effect_vector_variable_GetFloatVector,
5347 d3d10_effect_vector_variable_SetBoolVectorArray,
5348 d3d10_effect_vector_variable_SetIntVectorArray,
5349 d3d10_effect_vector_variable_SetFloatVectorArray,
5350 d3d10_effect_vector_variable_GetBoolVectorArray,
5351 d3d10_effect_vector_variable_GetIntVectorArray,
5352 d3d10_effect_vector_variable_GetFloatVectorArray,
5355 static void write_matrix_to_buffer(struct d3d10_effect_variable *variable, void *dst_void,
5356 struct d3d10_matrix *src, BOOL transpose)
5358 unsigned int col_count = !transpose ? variable->type->column_count : variable->type->row_count;
5359 unsigned int row_count = !transpose ? variable->type->row_count : variable->type->column_count;
5360 BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS;
5361 float *dst = dst_void;
5362 unsigned int row, col;
5364 if (transpose)
5365 major = !major;
5367 if (major)
5369 for (col = 0; col < col_count; ++col)
5371 for (row = 0; row < row_count; ++row)
5372 dst[(col * 4) + row] = src->m[row][col];
5375 else
5377 for (row = 0; row < row_count; ++row)
5379 for (col = 0; col < col_count; ++col)
5380 dst[(row * 4) + col] = src->m[row][col];
5385 static void write_matrix_variable_to_buffer(struct d3d10_effect_variable *variable, void *src_data, BOOL transpose)
5387 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5389 write_matrix_to_buffer(variable, dst, src_data, transpose);
5391 variable->buffer->u.buffer.changed = TRUE;
5394 static void write_matrix_variable_array_to_buffer(struct d3d10_effect_variable *variable, void *src_data,
5395 unsigned int offset, unsigned int count, BOOL transpose)
5397 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5398 struct d3d10_matrix *src = src_data;
5399 unsigned int i;
5401 if (!variable->type->element_count)
5403 write_matrix_variable_to_buffer(variable, src_data, transpose);
5404 return;
5407 if (offset >= variable->type->element_count)
5409 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
5410 return;
5413 if (count > variable->type->element_count - offset)
5415 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
5416 offset, count, variable->type->element_count);
5417 count = variable->type->element_count - offset;
5420 if (offset)
5421 dst += variable->type->stride * offset;
5423 for (i = 0; i < count; ++i)
5425 write_matrix_to_buffer(variable, dst, &src[i], transpose);
5427 dst += variable->type->stride;
5430 variable->buffer->u.buffer.changed = TRUE;
5433 static void read_matrix_from_buffer(struct d3d10_effect_variable *variable, void *src_void,
5434 struct d3d10_matrix *dst, BOOL transpose)
5436 unsigned int col_count = !transpose ? variable->type->column_count : variable->type->row_count;
5437 unsigned int row_count = !transpose ? variable->type->row_count : variable->type->column_count;
5438 BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS;
5439 float *src = src_void;
5440 unsigned int row, col;
5442 if (transpose)
5443 major = !major;
5445 if (major)
5447 for (col = 0; col < col_count; ++col)
5449 for (row = 0; row < row_count; ++row)
5450 dst->m[row][col] = src[(col * 4) + row];
5453 else
5455 for (row = 0; row < row_count; ++row)
5457 for (col = 0; col < col_count; ++col)
5458 dst->m[row][col] = src[(row * 4) + col];
5463 static void read_matrix_variable_from_buffer(struct d3d10_effect_variable *variable, void *dst, BOOL transpose)
5465 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5467 read_matrix_from_buffer(variable, src, dst, transpose);
5470 static void read_matrix_variable_array_from_buffer(struct d3d10_effect_variable *variable, void *dst_data, UINT offset,
5471 UINT count, BOOL transpose)
5473 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5474 struct d3d10_matrix *dst = dst_data;
5475 unsigned int i;
5477 if (!variable->type->element_count)
5479 read_matrix_variable_from_buffer(variable, dst_data, transpose);
5480 return;
5483 if (offset >= variable->type->element_count)
5485 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
5486 return;
5489 if (count > variable->type->element_count - offset)
5491 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
5492 offset, count, variable->type->element_count);
5493 count = variable->type->element_count - offset;
5496 if (offset)
5497 src += variable->type->stride * offset;
5499 for (i = 0; i < count; ++i)
5501 read_matrix_from_buffer(variable, src, &dst[i], transpose);
5503 src += variable->type->stride;
5507 /* ID3D10EffectVariable methods */
5509 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectMatrixVariable(ID3D10EffectMatrixVariable *iface)
5511 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
5514 static BOOL STDMETHODCALLTYPE d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable *iface)
5516 TRACE("iface %p\n", iface);
5518 return (struct d3d10_effect_variable *)iface != &null_matrix_variable;
5521 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetType(
5522 ID3D10EffectMatrixVariable *iface)
5524 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5527 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetDesc(ID3D10EffectMatrixVariable *iface,
5528 D3D10_EFFECT_VARIABLE_DESC *desc)
5530 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5533 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetAnnotationByIndex(
5534 ID3D10EffectMatrixVariable *iface, UINT index)
5536 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5539 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetAnnotationByName(
5540 ID3D10EffectMatrixVariable *iface, const char *name)
5542 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5545 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberByIndex(
5546 ID3D10EffectMatrixVariable *iface, UINT index)
5548 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5551 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberByName(
5552 ID3D10EffectMatrixVariable *iface, const char *name)
5554 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5557 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberBySemantic(
5558 ID3D10EffectMatrixVariable *iface, const char *semantic)
5560 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5563 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetElement(
5564 ID3D10EffectMatrixVariable *iface, UINT index)
5566 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5569 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetParentConstantBuffer(
5570 ID3D10EffectMatrixVariable *iface)
5572 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5575 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsScalar(
5576 ID3D10EffectMatrixVariable *iface)
5578 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5581 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsVector(
5582 ID3D10EffectMatrixVariable *iface)
5584 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5587 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsMatrix(
5588 ID3D10EffectMatrixVariable *iface)
5590 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5593 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsString(
5594 ID3D10EffectMatrixVariable *iface)
5596 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5599 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsShaderResource(
5600 ID3D10EffectMatrixVariable *iface)
5602 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5605 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsRenderTargetView(
5606 ID3D10EffectMatrixVariable *iface)
5608 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5611 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsDepthStencilView(
5612 ID3D10EffectMatrixVariable *iface)
5614 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5617 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsConstantBuffer(
5618 ID3D10EffectMatrixVariable *iface)
5620 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5623 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsShader(
5624 ID3D10EffectMatrixVariable *iface)
5626 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5629 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsBlend(
5630 ID3D10EffectMatrixVariable *iface)
5632 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5635 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsDepthStencil(
5636 ID3D10EffectMatrixVariable *iface)
5638 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5641 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsRasterizer(
5642 ID3D10EffectMatrixVariable *iface)
5644 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5647 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsSampler(
5648 ID3D10EffectMatrixVariable *iface)
5650 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5653 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetRawValue(ID3D10EffectMatrixVariable *iface,
5654 void *data, UINT offset, UINT count)
5656 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5659 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetRawValue(ID3D10EffectMatrixVariable *iface,
5660 void *data, UINT offset, UINT count)
5662 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5665 /* ID3D10EffectMatrixVariable methods */
5667 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrix(ID3D10EffectMatrixVariable *iface,
5668 float *data)
5670 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5672 TRACE("iface %p, data %p.\n", iface, data);
5673 write_matrix_variable_to_buffer(var, data, FALSE);
5675 return S_OK;
5678 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable *iface,
5679 float *data)
5681 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5683 TRACE("iface %p, data %p.\n", iface, data);
5684 read_matrix_variable_from_buffer(var, data, FALSE);
5686 return S_OK;
5689 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable *iface,
5690 float *data, UINT offset, UINT count)
5692 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5694 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
5695 write_matrix_variable_array_to_buffer(var, data, offset, count, FALSE);
5697 return S_OK;
5700 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable *iface,
5701 float *data, UINT offset, UINT count)
5703 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5705 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
5706 read_matrix_variable_array_from_buffer(var, data, offset, count, FALSE);
5708 return S_OK;
5711 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
5712 float *data)
5714 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5716 TRACE("iface %p, data %p.\n", iface, data);
5717 write_matrix_variable_to_buffer(var, data, TRUE);
5719 return S_OK;
5722 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
5723 float *data)
5725 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5727 TRACE("iface %p, data %p.\n", iface, data);
5728 read_matrix_variable_from_buffer(var, data, TRUE);
5730 return S_OK;
5733 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
5734 float *data, UINT offset, UINT count)
5736 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5738 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
5739 write_matrix_variable_array_to_buffer(var, data, offset, count, TRUE);
5741 return S_OK;
5744 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
5745 float *data, UINT offset, UINT count)
5747 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5749 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
5750 read_matrix_variable_array_from_buffer(var, data, offset, count, TRUE);
5752 return S_OK;
5756 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl =
5758 /* ID3D10EffectVariable methods */
5759 d3d10_effect_matrix_variable_IsValid,
5760 d3d10_effect_matrix_variable_GetType,
5761 d3d10_effect_matrix_variable_GetDesc,
5762 d3d10_effect_matrix_variable_GetAnnotationByIndex,
5763 d3d10_effect_matrix_variable_GetAnnotationByName,
5764 d3d10_effect_matrix_variable_GetMemberByIndex,
5765 d3d10_effect_matrix_variable_GetMemberByName,
5766 d3d10_effect_matrix_variable_GetMemberBySemantic,
5767 d3d10_effect_matrix_variable_GetElement,
5768 d3d10_effect_matrix_variable_GetParentConstantBuffer,
5769 d3d10_effect_matrix_variable_AsScalar,
5770 d3d10_effect_matrix_variable_AsVector,
5771 d3d10_effect_matrix_variable_AsMatrix,
5772 d3d10_effect_matrix_variable_AsString,
5773 d3d10_effect_matrix_variable_AsShaderResource,
5774 d3d10_effect_matrix_variable_AsRenderTargetView,
5775 d3d10_effect_matrix_variable_AsDepthStencilView,
5776 d3d10_effect_matrix_variable_AsConstantBuffer,
5777 d3d10_effect_matrix_variable_AsShader,
5778 d3d10_effect_matrix_variable_AsBlend,
5779 d3d10_effect_matrix_variable_AsDepthStencil,
5780 d3d10_effect_matrix_variable_AsRasterizer,
5781 d3d10_effect_matrix_variable_AsSampler,
5782 d3d10_effect_matrix_variable_SetRawValue,
5783 d3d10_effect_matrix_variable_GetRawValue,
5784 /* ID3D10EffectMatrixVariable methods */
5785 d3d10_effect_matrix_variable_SetMatrix,
5786 d3d10_effect_matrix_variable_GetMatrix,
5787 d3d10_effect_matrix_variable_SetMatrixArray,
5788 d3d10_effect_matrix_variable_GetMatrixArray,
5789 d3d10_effect_matrix_variable_SetMatrixTranspose,
5790 d3d10_effect_matrix_variable_GetMatrixTranspose,
5791 d3d10_effect_matrix_variable_SetMatrixTransposeArray,
5792 d3d10_effect_matrix_variable_GetMatrixTransposeArray,
5795 /* ID3D10EffectVariable methods */
5797 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectStringVariable(ID3D10EffectStringVariable *iface)
5799 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
5802 static BOOL STDMETHODCALLTYPE d3d10_effect_string_variable_IsValid(ID3D10EffectStringVariable *iface)
5804 TRACE("iface %p\n", iface);
5806 return (struct d3d10_effect_variable *)iface != &null_string_variable;
5809 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_string_variable_GetType(
5810 ID3D10EffectStringVariable *iface)
5812 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5815 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetDesc(ID3D10EffectStringVariable *iface,
5816 D3D10_EFFECT_VARIABLE_DESC *desc)
5818 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5821 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetAnnotationByIndex(
5822 ID3D10EffectStringVariable *iface, UINT index)
5824 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5827 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetAnnotationByName(
5828 ID3D10EffectStringVariable *iface, const char *name)
5830 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5833 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberByIndex(
5834 ID3D10EffectStringVariable *iface, UINT index)
5836 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5839 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberByName(
5840 ID3D10EffectStringVariable *iface, const char *name)
5842 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5845 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberBySemantic(
5846 ID3D10EffectStringVariable *iface, const char *semantic)
5848 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5851 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetElement(
5852 ID3D10EffectStringVariable *iface, UINT index)
5854 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5857 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_string_variable_GetParentConstantBuffer(
5858 ID3D10EffectStringVariable *iface)
5860 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5863 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsScalar(
5864 ID3D10EffectStringVariable *iface)
5866 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5869 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsVector(
5870 ID3D10EffectStringVariable *iface)
5872 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5875 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsMatrix(
5876 ID3D10EffectStringVariable *iface)
5878 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5881 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsString(
5882 ID3D10EffectStringVariable *iface)
5884 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5887 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsShaderResource(
5888 ID3D10EffectStringVariable *iface)
5890 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5893 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsRenderTargetView(
5894 ID3D10EffectStringVariable *iface)
5896 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5899 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsDepthStencilView(
5900 ID3D10EffectStringVariable *iface)
5902 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5905 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_string_variable_AsConstantBuffer(
5906 ID3D10EffectStringVariable *iface)
5908 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5911 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsShader(
5912 ID3D10EffectStringVariable *iface)
5914 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5917 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsBlend(
5918 ID3D10EffectStringVariable *iface)
5920 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5923 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsDepthStencil(
5924 ID3D10EffectStringVariable *iface)
5926 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5929 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsRasterizer(
5930 ID3D10EffectStringVariable *iface)
5932 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5935 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsSampler(
5936 ID3D10EffectStringVariable *iface)
5938 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5941 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_SetRawValue(ID3D10EffectStringVariable *iface,
5942 void *data, UINT offset, UINT count)
5944 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5947 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetRawValue(ID3D10EffectStringVariable *iface,
5948 void *data, UINT offset, UINT count)
5950 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5953 /* ID3D10EffectStringVariable methods */
5955 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetString(ID3D10EffectStringVariable *iface,
5956 const char **str)
5958 struct d3d10_effect_variable *var = impl_from_ID3D10EffectStringVariable(iface);
5959 char *value = (char *)var->u.buffer.local_buffer;
5961 TRACE("iface %p, str %p.\n", iface, str);
5963 if (!value)
5964 return E_FAIL;
5966 if (!str)
5967 return E_INVALIDARG;
5969 *str = value;
5971 return S_OK;
5974 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetStringArray(ID3D10EffectStringVariable *iface,
5975 const char **strs, UINT offset, UINT count)
5977 FIXME("iface %p, strs %p, offset %u, count %u stub!\n", iface, strs, offset, count);
5979 return E_NOTIMPL;
5983 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl =
5985 /* ID3D10EffectVariable methods */
5986 d3d10_effect_string_variable_IsValid,
5987 d3d10_effect_string_variable_GetType,
5988 d3d10_effect_string_variable_GetDesc,
5989 d3d10_effect_string_variable_GetAnnotationByIndex,
5990 d3d10_effect_string_variable_GetAnnotationByName,
5991 d3d10_effect_string_variable_GetMemberByIndex,
5992 d3d10_effect_string_variable_GetMemberByName,
5993 d3d10_effect_string_variable_GetMemberBySemantic,
5994 d3d10_effect_string_variable_GetElement,
5995 d3d10_effect_string_variable_GetParentConstantBuffer,
5996 d3d10_effect_string_variable_AsScalar,
5997 d3d10_effect_string_variable_AsVector,
5998 d3d10_effect_string_variable_AsMatrix,
5999 d3d10_effect_string_variable_AsString,
6000 d3d10_effect_string_variable_AsShaderResource,
6001 d3d10_effect_string_variable_AsRenderTargetView,
6002 d3d10_effect_string_variable_AsDepthStencilView,
6003 d3d10_effect_string_variable_AsConstantBuffer,
6004 d3d10_effect_string_variable_AsShader,
6005 d3d10_effect_string_variable_AsBlend,
6006 d3d10_effect_string_variable_AsDepthStencil,
6007 d3d10_effect_string_variable_AsRasterizer,
6008 d3d10_effect_string_variable_AsSampler,
6009 d3d10_effect_string_variable_SetRawValue,
6010 d3d10_effect_string_variable_GetRawValue,
6011 /* ID3D10EffectStringVariable methods */
6012 d3d10_effect_string_variable_GetString,
6013 d3d10_effect_string_variable_GetStringArray,
6016 static void set_shader_resource_variable(ID3D10ShaderResourceView **src, ID3D10ShaderResourceView **dst)
6018 if (*dst == *src)
6019 return;
6021 if (*src)
6022 ID3D10ShaderResourceView_AddRef(*src);
6023 if (*dst)
6024 ID3D10ShaderResourceView_Release(*dst);
6026 *dst = *src;
6029 /* ID3D10EffectVariable methods */
6031 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectShaderResourceVariable(
6032 ID3D10EffectShaderResourceVariable *iface)
6034 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
6037 static BOOL STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_IsValid(ID3D10EffectShaderResourceVariable *iface)
6039 TRACE("iface %p\n", iface);
6041 return (struct d3d10_effect_variable *)iface != &null_shader_resource_variable;
6044 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetType(
6045 ID3D10EffectShaderResourceVariable *iface)
6047 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6050 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetDesc(
6051 ID3D10EffectShaderResourceVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
6053 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6056 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetAnnotationByIndex(
6057 ID3D10EffectShaderResourceVariable *iface, UINT index)
6059 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6062 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetAnnotationByName(
6063 ID3D10EffectShaderResourceVariable *iface, const char *name)
6065 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6068 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberByIndex(
6069 ID3D10EffectShaderResourceVariable *iface, UINT index)
6071 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6074 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberByName(
6075 ID3D10EffectShaderResourceVariable *iface, const char *name)
6077 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6080 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberBySemantic(
6081 ID3D10EffectShaderResourceVariable *iface, const char *semantic)
6083 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6086 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetElement(
6087 ID3D10EffectShaderResourceVariable *iface, UINT index)
6089 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6092 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetParentConstantBuffer(
6093 ID3D10EffectShaderResourceVariable *iface)
6095 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6098 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsScalar(
6099 ID3D10EffectShaderResourceVariable *iface)
6101 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6104 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsVector(
6105 ID3D10EffectShaderResourceVariable *iface)
6107 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6110 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsMatrix(
6111 ID3D10EffectShaderResourceVariable *iface)
6113 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6116 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsString(
6117 ID3D10EffectShaderResourceVariable *iface)
6119 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6122 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsShaderResource(
6123 ID3D10EffectShaderResourceVariable *iface)
6125 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6128 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsRenderTargetView(
6129 ID3D10EffectShaderResourceVariable *iface)
6131 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6134 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsDepthStencilView(
6135 ID3D10EffectShaderResourceVariable *iface)
6137 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6140 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsConstantBuffer(
6141 ID3D10EffectShaderResourceVariable *iface)
6143 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6146 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsShader(
6147 ID3D10EffectShaderResourceVariable *iface)
6149 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6152 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsBlend(
6153 ID3D10EffectShaderResourceVariable *iface)
6155 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6158 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsDepthStencil(
6159 ID3D10EffectShaderResourceVariable *iface)
6161 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6164 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsRasterizer(
6165 ID3D10EffectShaderResourceVariable *iface)
6167 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6170 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsSampler(
6171 ID3D10EffectShaderResourceVariable *iface)
6173 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6176 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetRawValue(
6177 ID3D10EffectShaderResourceVariable *iface, void *data, UINT offset, UINT count)
6179 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6182 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetRawValue(
6183 ID3D10EffectShaderResourceVariable *iface, void *data, UINT offset, UINT count)
6185 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6188 /* ID3D10EffectShaderResourceVariable methods */
6190 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResource(
6191 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView *resource)
6193 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderResourceVariable(iface);
6195 TRACE("iface %p, resource %p.\n", iface, resource);
6197 set_shader_resource_variable(&resource, v->u.resource.srv);
6199 return S_OK;
6202 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResource(
6203 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resource)
6205 FIXME("iface %p, resource %p stub!\n", iface, resource);
6207 return E_NOTIMPL;
6210 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResourceArray(
6211 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resources, UINT offset, UINT count)
6213 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderResourceVariable(iface);
6214 ID3D10ShaderResourceView **rsrc_view;
6215 unsigned int i;
6217 TRACE("iface %p, resources %p, offset %u, count %u.\n", iface, resources, offset, count);
6219 if (!v->type->element_count)
6220 return d3d10_effect_shader_resource_variable_SetResource(iface, *resources);
6222 if (offset >= v->type->element_count)
6224 WARN("Offset %u larger than element count %u, ignoring.\n", offset, v->type->element_count);
6225 return S_OK;
6228 if (count > v->type->element_count - offset)
6230 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6231 offset, count, v->type->element_count);
6232 count = v->type->element_count - offset;
6235 rsrc_view = &v->u.resource.srv[offset];
6236 for (i = 0; i < count; ++i)
6237 set_shader_resource_variable(&resources[i], &rsrc_view[i]);
6239 return S_OK;
6242 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResourceArray(
6243 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resources, UINT offset, UINT count)
6245 FIXME("iface %p, resources %p, offset %u, count %u stub!\n", iface, resources, offset, count);
6247 return E_NOTIMPL;
6251 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl =
6253 /* ID3D10EffectVariable methods */
6254 d3d10_effect_shader_resource_variable_IsValid,
6255 d3d10_effect_shader_resource_variable_GetType,
6256 d3d10_effect_shader_resource_variable_GetDesc,
6257 d3d10_effect_shader_resource_variable_GetAnnotationByIndex,
6258 d3d10_effect_shader_resource_variable_GetAnnotationByName,
6259 d3d10_effect_shader_resource_variable_GetMemberByIndex,
6260 d3d10_effect_shader_resource_variable_GetMemberByName,
6261 d3d10_effect_shader_resource_variable_GetMemberBySemantic,
6262 d3d10_effect_shader_resource_variable_GetElement,
6263 d3d10_effect_shader_resource_variable_GetParentConstantBuffer,
6264 d3d10_effect_shader_resource_variable_AsScalar,
6265 d3d10_effect_shader_resource_variable_AsVector,
6266 d3d10_effect_shader_resource_variable_AsMatrix,
6267 d3d10_effect_shader_resource_variable_AsString,
6268 d3d10_effect_shader_resource_variable_AsShaderResource,
6269 d3d10_effect_shader_resource_variable_AsRenderTargetView,
6270 d3d10_effect_shader_resource_variable_AsDepthStencilView,
6271 d3d10_effect_shader_resource_variable_AsConstantBuffer,
6272 d3d10_effect_shader_resource_variable_AsShader,
6273 d3d10_effect_shader_resource_variable_AsBlend,
6274 d3d10_effect_shader_resource_variable_AsDepthStencil,
6275 d3d10_effect_shader_resource_variable_AsRasterizer,
6276 d3d10_effect_shader_resource_variable_AsSampler,
6277 d3d10_effect_shader_resource_variable_SetRawValue,
6278 d3d10_effect_shader_resource_variable_GetRawValue,
6279 /* ID3D10EffectShaderResourceVariable methods */
6280 d3d10_effect_shader_resource_variable_SetResource,
6281 d3d10_effect_shader_resource_variable_GetResource,
6282 d3d10_effect_shader_resource_variable_SetResourceArray,
6283 d3d10_effect_shader_resource_variable_GetResourceArray,
6286 /* ID3D10EffectVariable methods */
6288 static BOOL STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_IsValid(
6289 ID3D10EffectRenderTargetViewVariable *iface)
6291 TRACE("iface %p\n", iface);
6293 return (struct d3d10_effect_variable *)iface != &null_render_target_view_variable;
6296 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetType(
6297 ID3D10EffectRenderTargetViewVariable *iface)
6299 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6302 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetDesc(
6303 ID3D10EffectRenderTargetViewVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
6305 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6308 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetAnnotationByIndex(
6309 ID3D10EffectRenderTargetViewVariable *iface, UINT index)
6311 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6314 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetAnnotationByName(
6315 ID3D10EffectRenderTargetViewVariable *iface, const char *name)
6317 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6320 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberByIndex(
6321 ID3D10EffectRenderTargetViewVariable *iface, UINT index)
6323 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6326 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberByName(
6327 ID3D10EffectRenderTargetViewVariable *iface, const char *name)
6329 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6332 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberBySemantic(
6333 ID3D10EffectRenderTargetViewVariable *iface, const char *semantic)
6335 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6338 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetElement(
6339 ID3D10EffectRenderTargetViewVariable *iface, UINT index)
6341 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6344 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetParentConstantBuffer(
6345 ID3D10EffectRenderTargetViewVariable *iface)
6347 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6350 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsScalar(
6351 ID3D10EffectRenderTargetViewVariable *iface)
6353 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6356 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsVector(
6357 ID3D10EffectRenderTargetViewVariable *iface)
6359 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6362 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsMatrix(
6363 ID3D10EffectRenderTargetViewVariable *iface)
6365 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6368 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsString(
6369 ID3D10EffectRenderTargetViewVariable *iface)
6371 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6374 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsShaderResource(
6375 ID3D10EffectRenderTargetViewVariable *iface)
6377 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6380 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsRenderTargetView(
6381 ID3D10EffectRenderTargetViewVariable *iface)
6383 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6386 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsDepthStencilView(
6387 ID3D10EffectRenderTargetViewVariable *iface)
6389 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6392 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsConstantBuffer(
6393 ID3D10EffectRenderTargetViewVariable *iface)
6395 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6398 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsShader(
6399 ID3D10EffectRenderTargetViewVariable *iface)
6401 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6404 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsBlend(
6405 ID3D10EffectRenderTargetViewVariable *iface)
6407 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6410 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsDepthStencil(
6411 ID3D10EffectRenderTargetViewVariable *iface)
6413 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6416 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsRasterizer(
6417 ID3D10EffectRenderTargetViewVariable *iface)
6419 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6422 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsSampler(
6423 ID3D10EffectRenderTargetViewVariable *iface)
6425 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6428 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRawValue(
6429 ID3D10EffectRenderTargetViewVariable *iface, void *data, UINT offset, UINT count)
6431 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6434 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRawValue(
6435 ID3D10EffectRenderTargetViewVariable *iface, void *data, UINT offset, UINT count)
6437 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6440 /* ID3D10EffectRenderTargetViewVariable methods */
6442 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRenderTarget(
6443 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView *view)
6445 FIXME("iface %p, view %p stub!\n", iface, view);
6447 return E_NOTIMPL;
6450 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRenderTarget(
6451 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **view)
6453 FIXME("iface %p, view %p stub!\n", iface, view);
6455 return E_NOTIMPL;
6458 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRenderTargetArray(
6459 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **views, UINT offset, UINT count)
6461 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6463 return E_NOTIMPL;
6466 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRenderTargetArray(
6467 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **views, UINT offset, UINT count)
6469 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6471 return E_NOTIMPL;
6475 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl =
6477 /* ID3D10EffectVariable methods */
6478 d3d10_effect_render_target_view_variable_IsValid,
6479 d3d10_effect_render_target_view_variable_GetType,
6480 d3d10_effect_render_target_view_variable_GetDesc,
6481 d3d10_effect_render_target_view_variable_GetAnnotationByIndex,
6482 d3d10_effect_render_target_view_variable_GetAnnotationByName,
6483 d3d10_effect_render_target_view_variable_GetMemberByIndex,
6484 d3d10_effect_render_target_view_variable_GetMemberByName,
6485 d3d10_effect_render_target_view_variable_GetMemberBySemantic,
6486 d3d10_effect_render_target_view_variable_GetElement,
6487 d3d10_effect_render_target_view_variable_GetParentConstantBuffer,
6488 d3d10_effect_render_target_view_variable_AsScalar,
6489 d3d10_effect_render_target_view_variable_AsVector,
6490 d3d10_effect_render_target_view_variable_AsMatrix,
6491 d3d10_effect_render_target_view_variable_AsString,
6492 d3d10_effect_render_target_view_variable_AsShaderResource,
6493 d3d10_effect_render_target_view_variable_AsRenderTargetView,
6494 d3d10_effect_render_target_view_variable_AsDepthStencilView,
6495 d3d10_effect_render_target_view_variable_AsConstantBuffer,
6496 d3d10_effect_render_target_view_variable_AsShader,
6497 d3d10_effect_render_target_view_variable_AsBlend,
6498 d3d10_effect_render_target_view_variable_AsDepthStencil,
6499 d3d10_effect_render_target_view_variable_AsRasterizer,
6500 d3d10_effect_render_target_view_variable_AsSampler,
6501 d3d10_effect_render_target_view_variable_SetRawValue,
6502 d3d10_effect_render_target_view_variable_GetRawValue,
6503 /* ID3D10EffectRenderTargetViewVariable methods */
6504 d3d10_effect_render_target_view_variable_SetRenderTarget,
6505 d3d10_effect_render_target_view_variable_GetRenderTarget,
6506 d3d10_effect_render_target_view_variable_SetRenderTargetArray,
6507 d3d10_effect_render_target_view_variable_GetRenderTargetArray,
6510 /* ID3D10EffectVariable methods */
6512 static BOOL STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_IsValid(
6513 ID3D10EffectDepthStencilViewVariable *iface)
6515 TRACE("iface %p\n", iface);
6517 return (struct d3d10_effect_variable *)iface != &null_depth_stencil_view_variable;
6520 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetType(
6521 ID3D10EffectDepthStencilViewVariable *iface)
6523 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6526 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDesc(
6527 ID3D10EffectDepthStencilViewVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
6529 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6532 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex(
6533 ID3D10EffectDepthStencilViewVariable *iface, UINT index)
6535 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6538 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetAnnotationByName(
6539 ID3D10EffectDepthStencilViewVariable *iface, const char *name)
6541 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6544 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberByIndex(
6545 ID3D10EffectDepthStencilViewVariable *iface, UINT index)
6547 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6550 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberByName(
6551 ID3D10EffectDepthStencilViewVariable *iface, const char *name)
6553 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6556 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic(
6557 ID3D10EffectDepthStencilViewVariable *iface, const char *semantic)
6559 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6562 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetElement(
6563 ID3D10EffectDepthStencilViewVariable *iface, UINT index)
6565 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6568 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer(
6569 ID3D10EffectDepthStencilViewVariable *iface)
6571 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6574 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsScalar(
6575 ID3D10EffectDepthStencilViewVariable *iface)
6577 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6580 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsVector(
6581 ID3D10EffectDepthStencilViewVariable *iface)
6583 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6586 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsMatrix(
6587 ID3D10EffectDepthStencilViewVariable *iface)
6589 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6592 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsString(
6593 ID3D10EffectDepthStencilViewVariable *iface)
6595 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6598 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsShaderResource(
6599 ID3D10EffectDepthStencilViewVariable *iface)
6601 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6604 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsRenderTargetView(
6605 ID3D10EffectDepthStencilViewVariable *iface)
6607 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6610 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsDepthStencilView(
6611 ID3D10EffectDepthStencilViewVariable *iface)
6613 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6616 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsConstantBuffer(
6617 ID3D10EffectDepthStencilViewVariable *iface)
6619 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6622 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsShader(
6623 ID3D10EffectDepthStencilViewVariable *iface)
6625 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6628 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsBlend(
6629 ID3D10EffectDepthStencilViewVariable *iface)
6631 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6634 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsDepthStencil(
6635 ID3D10EffectDepthStencilViewVariable *iface)
6637 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6640 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsRasterizer(
6641 ID3D10EffectDepthStencilViewVariable *iface)
6643 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6646 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsSampler(
6647 ID3D10EffectDepthStencilViewVariable *iface)
6649 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6652 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetRawValue(
6653 ID3D10EffectDepthStencilViewVariable *iface, void *data, UINT offset, UINT count)
6655 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6658 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetRawValue(
6659 ID3D10EffectDepthStencilViewVariable *iface, void *data, UINT offset, UINT count)
6661 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6664 /* ID3D10EffectDepthStencilViewVariable methods */
6666 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetDepthStencil(
6667 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView *view)
6669 FIXME("iface %p, view %p stub!\n", iface, view);
6671 return E_NOTIMPL;
6674 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDepthStencil(
6675 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **view)
6677 FIXME("iface %p, view %p stub!\n", iface, view);
6679 return E_NOTIMPL;
6682 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray(
6683 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **views, UINT offset, UINT count)
6685 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6687 return E_NOTIMPL;
6690 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray(
6691 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **views, UINT offset, UINT count)
6693 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6695 return E_NOTIMPL;
6699 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl =
6701 /* ID3D10EffectVariable methods */
6702 d3d10_effect_depth_stencil_view_variable_IsValid,
6703 d3d10_effect_depth_stencil_view_variable_GetType,
6704 d3d10_effect_depth_stencil_view_variable_GetDesc,
6705 d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex,
6706 d3d10_effect_depth_stencil_view_variable_GetAnnotationByName,
6707 d3d10_effect_depth_stencil_view_variable_GetMemberByIndex,
6708 d3d10_effect_depth_stencil_view_variable_GetMemberByName,
6709 d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic,
6710 d3d10_effect_depth_stencil_view_variable_GetElement,
6711 d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer,
6712 d3d10_effect_depth_stencil_view_variable_AsScalar,
6713 d3d10_effect_depth_stencil_view_variable_AsVector,
6714 d3d10_effect_depth_stencil_view_variable_AsMatrix,
6715 d3d10_effect_depth_stencil_view_variable_AsString,
6716 d3d10_effect_depth_stencil_view_variable_AsShaderResource,
6717 d3d10_effect_depth_stencil_view_variable_AsRenderTargetView,
6718 d3d10_effect_depth_stencil_view_variable_AsDepthStencilView,
6719 d3d10_effect_depth_stencil_view_variable_AsConstantBuffer,
6720 d3d10_effect_depth_stencil_view_variable_AsShader,
6721 d3d10_effect_depth_stencil_view_variable_AsBlend,
6722 d3d10_effect_depth_stencil_view_variable_AsDepthStencil,
6723 d3d10_effect_depth_stencil_view_variable_AsRasterizer,
6724 d3d10_effect_depth_stencil_view_variable_AsSampler,
6725 d3d10_effect_depth_stencil_view_variable_SetRawValue,
6726 d3d10_effect_depth_stencil_view_variable_GetRawValue,
6727 /* ID3D10EffectDepthStencilViewVariable methods */
6728 d3d10_effect_depth_stencil_view_variable_SetDepthStencil,
6729 d3d10_effect_depth_stencil_view_variable_GetDepthStencil,
6730 d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray,
6731 d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray,
6734 /* ID3D10EffectVariable methods */
6736 static BOOL STDMETHODCALLTYPE d3d10_effect_shader_variable_IsValid(ID3D10EffectShaderVariable *iface)
6738 TRACE("iface %p\n", iface);
6740 return (struct d3d10_effect_variable *)iface != &null_shader_variable;
6743 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetType(
6744 ID3D10EffectShaderVariable *iface)
6746 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6749 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetDesc(ID3D10EffectShaderVariable *iface,
6750 D3D10_EFFECT_VARIABLE_DESC *desc)
6752 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6755 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetAnnotationByIndex(
6756 ID3D10EffectShaderVariable *iface, UINT index)
6758 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6761 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetAnnotationByName(
6762 ID3D10EffectShaderVariable *iface, const char *name)
6764 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6767 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberByIndex(
6768 ID3D10EffectShaderVariable *iface, UINT index)
6770 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6773 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberByName(
6774 ID3D10EffectShaderVariable *iface, const char *name)
6776 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6779 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberBySemantic(
6780 ID3D10EffectShaderVariable *iface, const char *semantic)
6782 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6785 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetElement(
6786 ID3D10EffectShaderVariable *iface, UINT index)
6788 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6791 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetParentConstantBuffer(
6792 ID3D10EffectShaderVariable *iface)
6794 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6797 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsScalar(
6798 ID3D10EffectShaderVariable *iface)
6800 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6803 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsVector(
6804 ID3D10EffectShaderVariable *iface)
6806 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6809 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsMatrix(
6810 ID3D10EffectShaderVariable *iface)
6812 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6815 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsString(
6816 ID3D10EffectShaderVariable *iface)
6818 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6821 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsShaderResource(
6822 ID3D10EffectShaderVariable *iface)
6824 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6827 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsRenderTargetView(
6828 ID3D10EffectShaderVariable *iface)
6830 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6833 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsDepthStencilView(
6834 ID3D10EffectShaderVariable *iface)
6836 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6839 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsConstantBuffer(
6840 ID3D10EffectShaderVariable *iface)
6842 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6845 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsShader(
6846 ID3D10EffectShaderVariable *iface)
6848 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6851 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsBlend(
6852 ID3D10EffectShaderVariable *iface)
6854 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6857 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsDepthStencil(
6858 ID3D10EffectShaderVariable *iface)
6860 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6863 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsRasterizer(
6864 ID3D10EffectShaderVariable *iface)
6866 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6869 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsSampler(
6870 ID3D10EffectShaderVariable *iface)
6872 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6875 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_SetRawValue(
6876 ID3D10EffectShaderVariable *iface, void *data, UINT offset, UINT count)
6878 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6881 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetRawValue(
6882 ID3D10EffectShaderVariable *iface, void *data, UINT offset, UINT count)
6884 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6887 /* ID3D10EffectShaderVariable methods */
6889 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetShaderDesc(
6890 ID3D10EffectShaderVariable *iface, UINT index, D3D10_EFFECT_SHADER_DESC *desc)
6892 FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc);
6894 return E_NOTIMPL;
6897 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetVertexShader(
6898 ID3D10EffectShaderVariable *iface, UINT index, ID3D10VertexShader **shader)
6900 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
6902 TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
6904 if (v->type->element_count)
6905 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6907 if (v->type->basetype != D3D10_SVT_VERTEXSHADER)
6909 WARN("Shader is not a vertex shader.\n");
6910 return E_FAIL;
6913 if ((*shader = v->u.shader.shader.vs))
6914 ID3D10VertexShader_AddRef(*shader);
6916 return S_OK;
6919 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetGeometryShader(
6920 ID3D10EffectShaderVariable *iface, UINT index, ID3D10GeometryShader **shader)
6922 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
6924 TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
6926 if (v->type->element_count)
6927 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6929 if (v->type->basetype != D3D10_SVT_GEOMETRYSHADER)
6931 WARN("Shader is not a geometry shader.\n");
6932 return E_FAIL;
6935 if ((*shader = v->u.shader.shader.gs))
6936 ID3D10GeometryShader_AddRef(*shader);
6938 return S_OK;
6941 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetPixelShader(
6942 ID3D10EffectShaderVariable *iface, UINT index, ID3D10PixelShader **shader)
6944 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
6946 TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
6948 if (v->type->element_count)
6949 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6951 if (v->type->basetype != D3D10_SVT_PIXELSHADER)
6953 WARN("Shader is not a pixel shader.\n");
6954 return E_FAIL;
6957 if ((*shader = v->u.shader.shader.ps))
6958 ID3D10PixelShader_AddRef(*shader);
6960 return S_OK;
6963 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetInputSignatureElementDesc(
6964 ID3D10EffectShaderVariable *iface, UINT shader_index, UINT element_index,
6965 D3D10_SIGNATURE_PARAMETER_DESC *desc)
6967 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
6968 struct d3d10_effect_shader_variable *s;
6969 D3D10_SIGNATURE_PARAMETER_DESC *d;
6971 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
6972 iface, shader_index, element_index, desc);
6974 if (!iface->lpVtbl->IsValid(iface))
6976 WARN("Null variable specified\n");
6977 return E_FAIL;
6980 /* Check shader_index, this crashes on W7/DX10 */
6981 if (shader_index >= v->effect->used_shader_count)
6983 WARN("This should crash on W7/DX10!\n");
6984 return E_FAIL;
6987 s = &v->effect->used_shaders[shader_index]->u.shader;
6988 if (!s->input_signature.signature)
6990 WARN("No shader signature\n");
6991 return D3DERR_INVALIDCALL;
6994 /* Check desc for NULL, this crashes on W7/DX10 */
6995 if (!desc)
6997 WARN("This should crash on W7/DX10!\n");
6998 return E_FAIL;
7001 if (element_index >= s->input_signature.element_count)
7003 WARN("Invalid element index specified\n");
7004 return E_INVALIDARG;
7007 d = &s->input_signature.elements[element_index];
7008 desc->SemanticName = d->SemanticName;
7009 desc->SemanticIndex = d->SemanticIndex;
7010 desc->SystemValueType = d->SystemValueType;
7011 desc->ComponentType = d->ComponentType;
7012 desc->Register = d->Register;
7013 desc->ReadWriteMask = d->ReadWriteMask;
7014 desc->Mask = d->Mask;
7016 return S_OK;
7019 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetOutputSignatureElementDesc(
7020 ID3D10EffectShaderVariable *iface, UINT shader_index, UINT element_index,
7021 D3D10_SIGNATURE_PARAMETER_DESC *desc)
7023 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
7024 struct d3d10_effect_shader_variable *s;
7025 D3D10_SIGNATURE_PARAMETER_DESC *d;
7027 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
7028 iface, shader_index, element_index, desc);
7030 if (!iface->lpVtbl->IsValid(iface))
7032 WARN("Null variable specified\n");
7033 return E_FAIL;
7036 /* Check shader_index, this crashes on W7/DX10 */
7037 if (shader_index >= v->effect->used_shader_count)
7039 WARN("This should crash on W7/DX10!\n");
7040 return E_FAIL;
7043 s = &v->effect->used_shaders[shader_index]->u.shader;
7044 if (!s->output_signature.signature)
7046 WARN("No shader signature\n");
7047 return D3DERR_INVALIDCALL;
7050 /* Check desc for NULL, this crashes on W7/DX10 */
7051 if (!desc)
7053 WARN("This should crash on W7/DX10!\n");
7054 return E_FAIL;
7057 if (element_index >= s->output_signature.element_count)
7059 WARN("Invalid element index specified\n");
7060 return E_INVALIDARG;
7063 d = &s->output_signature.elements[element_index];
7064 desc->SemanticName = d->SemanticName;
7065 desc->SemanticIndex = d->SemanticIndex;
7066 desc->SystemValueType = d->SystemValueType;
7067 desc->ComponentType = d->ComponentType;
7068 desc->Register = d->Register;
7069 desc->ReadWriteMask = d->ReadWriteMask;
7070 desc->Mask = d->Mask;
7072 return S_OK;
7076 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl =
7078 /* ID3D10EffectVariable methods */
7079 d3d10_effect_shader_variable_IsValid,
7080 d3d10_effect_shader_variable_GetType,
7081 d3d10_effect_shader_variable_GetDesc,
7082 d3d10_effect_shader_variable_GetAnnotationByIndex,
7083 d3d10_effect_shader_variable_GetAnnotationByName,
7084 d3d10_effect_shader_variable_GetMemberByIndex,
7085 d3d10_effect_shader_variable_GetMemberByName,
7086 d3d10_effect_shader_variable_GetMemberBySemantic,
7087 d3d10_effect_shader_variable_GetElement,
7088 d3d10_effect_shader_variable_GetParentConstantBuffer,
7089 d3d10_effect_shader_variable_AsScalar,
7090 d3d10_effect_shader_variable_AsVector,
7091 d3d10_effect_shader_variable_AsMatrix,
7092 d3d10_effect_shader_variable_AsString,
7093 d3d10_effect_shader_variable_AsShaderResource,
7094 d3d10_effect_shader_variable_AsRenderTargetView,
7095 d3d10_effect_shader_variable_AsDepthStencilView,
7096 d3d10_effect_shader_variable_AsConstantBuffer,
7097 d3d10_effect_shader_variable_AsShader,
7098 d3d10_effect_shader_variable_AsBlend,
7099 d3d10_effect_shader_variable_AsDepthStencil,
7100 d3d10_effect_shader_variable_AsRasterizer,
7101 d3d10_effect_shader_variable_AsSampler,
7102 d3d10_effect_shader_variable_SetRawValue,
7103 d3d10_effect_shader_variable_GetRawValue,
7104 /* ID3D10EffectShaderVariable methods */
7105 d3d10_effect_shader_variable_GetShaderDesc,
7106 d3d10_effect_shader_variable_GetVertexShader,
7107 d3d10_effect_shader_variable_GetGeometryShader,
7108 d3d10_effect_shader_variable_GetPixelShader,
7109 d3d10_effect_shader_variable_GetInputSignatureElementDesc,
7110 d3d10_effect_shader_variable_GetOutputSignatureElementDesc,
7113 /* ID3D10EffectVariable methods */
7115 static BOOL STDMETHODCALLTYPE d3d10_effect_blend_variable_IsValid(ID3D10EffectBlendVariable *iface)
7117 TRACE("iface %p\n", iface);
7119 return (struct d3d10_effect_variable *)iface != &null_blend_variable;
7122 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetType(
7123 ID3D10EffectBlendVariable *iface)
7125 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7128 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetDesc(ID3D10EffectBlendVariable *iface,
7129 D3D10_EFFECT_VARIABLE_DESC *desc)
7131 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7134 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetAnnotationByIndex(
7135 ID3D10EffectBlendVariable *iface, UINT index)
7137 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7140 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetAnnotationByName(
7141 ID3D10EffectBlendVariable *iface, const char *name)
7143 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7146 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberByIndex(
7147 ID3D10EffectBlendVariable *iface, UINT index)
7149 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7152 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberByName(
7153 ID3D10EffectBlendVariable *iface, const char *name)
7155 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7158 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberBySemantic(
7159 ID3D10EffectBlendVariable *iface, const char *semantic)
7161 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7164 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetElement(
7165 ID3D10EffectBlendVariable *iface, UINT index)
7167 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7170 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetParentConstantBuffer(
7171 ID3D10EffectBlendVariable *iface)
7173 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7176 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsScalar(
7177 ID3D10EffectBlendVariable *iface)
7179 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7182 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsVector(
7183 ID3D10EffectBlendVariable *iface)
7185 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7188 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsMatrix(
7189 ID3D10EffectBlendVariable *iface)
7191 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7194 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsString(
7195 ID3D10EffectBlendVariable *iface)
7197 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7200 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsShaderResource(
7201 ID3D10EffectBlendVariable *iface)
7203 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7206 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsRenderTargetView(
7207 ID3D10EffectBlendVariable *iface)
7209 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7212 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsDepthStencilView(
7213 ID3D10EffectBlendVariable *iface)
7215 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7218 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsConstantBuffer(
7219 ID3D10EffectBlendVariable *iface)
7221 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7224 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsShader(
7225 ID3D10EffectBlendVariable *iface)
7227 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7230 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsBlend(
7231 ID3D10EffectBlendVariable *iface)
7233 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7236 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsDepthStencil(
7237 ID3D10EffectBlendVariable *iface)
7239 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7242 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsRasterizer(
7243 ID3D10EffectBlendVariable *iface)
7245 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7248 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsSampler(
7249 ID3D10EffectBlendVariable *iface)
7251 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7254 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_SetRawValue(ID3D10EffectBlendVariable *iface,
7255 void *data, UINT offset, UINT count)
7257 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7260 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetRawValue(ID3D10EffectBlendVariable *iface,
7261 void *data, UINT offset, UINT count)
7263 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7266 /* ID3D10EffectBlendVariable methods */
7268 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetBlendState(ID3D10EffectBlendVariable *iface,
7269 UINT index, ID3D10BlendState **blend_state)
7271 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7273 TRACE("iface %p, index %u, blend_state %p.\n", iface, index, blend_state);
7275 if (v->type->element_count)
7276 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7277 else if (index)
7278 return E_FAIL;
7280 if (v->type->basetype != D3D10_SVT_BLEND)
7282 WARN("Variable is not a blend state.\n");
7283 return E_FAIL;
7286 if ((*blend_state = v->u.state.object.blend))
7287 ID3D10BlendState_AddRef(*blend_state);
7289 return S_OK;
7292 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetBackingStore(ID3D10EffectBlendVariable *iface,
7293 UINT index, D3D10_BLEND_DESC *desc)
7295 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7297 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7299 if (v->type->element_count)
7300 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7302 if (v->type->basetype != D3D10_SVT_BLEND)
7304 WARN("Variable is not a blend state.\n");
7305 return E_FAIL;
7308 *desc = v->u.state.desc.blend;
7310 return S_OK;
7314 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl =
7316 /* ID3D10EffectVariable methods */
7317 d3d10_effect_blend_variable_IsValid,
7318 d3d10_effect_blend_variable_GetType,
7319 d3d10_effect_blend_variable_GetDesc,
7320 d3d10_effect_blend_variable_GetAnnotationByIndex,
7321 d3d10_effect_blend_variable_GetAnnotationByName,
7322 d3d10_effect_blend_variable_GetMemberByIndex,
7323 d3d10_effect_blend_variable_GetMemberByName,
7324 d3d10_effect_blend_variable_GetMemberBySemantic,
7325 d3d10_effect_blend_variable_GetElement,
7326 d3d10_effect_blend_variable_GetParentConstantBuffer,
7327 d3d10_effect_blend_variable_AsScalar,
7328 d3d10_effect_blend_variable_AsVector,
7329 d3d10_effect_blend_variable_AsMatrix,
7330 d3d10_effect_blend_variable_AsString,
7331 d3d10_effect_blend_variable_AsShaderResource,
7332 d3d10_effect_blend_variable_AsRenderTargetView,
7333 d3d10_effect_blend_variable_AsDepthStencilView,
7334 d3d10_effect_blend_variable_AsConstantBuffer,
7335 d3d10_effect_blend_variable_AsShader,
7336 d3d10_effect_blend_variable_AsBlend,
7337 d3d10_effect_blend_variable_AsDepthStencil,
7338 d3d10_effect_blend_variable_AsRasterizer,
7339 d3d10_effect_blend_variable_AsSampler,
7340 d3d10_effect_blend_variable_SetRawValue,
7341 d3d10_effect_blend_variable_GetRawValue,
7342 /* ID3D10EffectBlendVariable methods */
7343 d3d10_effect_blend_variable_GetBlendState,
7344 d3d10_effect_blend_variable_GetBackingStore,
7347 /* ID3D10EffectVariable methods */
7349 static BOOL STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_IsValid(ID3D10EffectDepthStencilVariable *iface)
7351 TRACE("iface %p\n", iface);
7353 return (struct d3d10_effect_variable *)iface != &null_depth_stencil_variable;
7356 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetType(
7357 ID3D10EffectDepthStencilVariable *iface)
7359 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7362 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetDesc(ID3D10EffectDepthStencilVariable *iface,
7363 D3D10_EFFECT_VARIABLE_DESC *desc)
7365 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7368 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetAnnotationByIndex(
7369 ID3D10EffectDepthStencilVariable *iface, UINT index)
7371 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7374 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetAnnotationByName(
7375 ID3D10EffectDepthStencilVariable *iface, const char *name)
7377 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7380 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberByIndex(
7381 ID3D10EffectDepthStencilVariable *iface, UINT index)
7383 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7386 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberByName(
7387 ID3D10EffectDepthStencilVariable *iface, const char *name)
7389 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7392 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberBySemantic(
7393 ID3D10EffectDepthStencilVariable *iface, const char *semantic)
7395 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7398 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetElement(
7399 ID3D10EffectDepthStencilVariable *iface, UINT index)
7401 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7404 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetParentConstantBuffer(
7405 ID3D10EffectDepthStencilVariable *iface)
7407 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7410 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsScalar(
7411 ID3D10EffectDepthStencilVariable *iface)
7413 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7416 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsVector(
7417 ID3D10EffectDepthStencilVariable *iface)
7419 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7422 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsMatrix(
7423 ID3D10EffectDepthStencilVariable *iface)
7425 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7428 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsString(
7429 ID3D10EffectDepthStencilVariable *iface)
7431 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7434 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsShaderResource(
7435 ID3D10EffectDepthStencilVariable *iface)
7437 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7440 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsRenderTargetView(
7441 ID3D10EffectDepthStencilVariable *iface)
7443 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7446 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsDepthStencilView(
7447 ID3D10EffectDepthStencilVariable *iface)
7449 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7452 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsConstantBuffer(
7453 ID3D10EffectDepthStencilVariable *iface)
7455 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7458 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsShader(
7459 ID3D10EffectDepthStencilVariable *iface)
7461 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7464 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsBlend(
7465 ID3D10EffectDepthStencilVariable *iface)
7467 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7470 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsDepthStencil(
7471 ID3D10EffectDepthStencilVariable *iface)
7473 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7476 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsRasterizer(
7477 ID3D10EffectDepthStencilVariable *iface)
7479 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7482 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsSampler(
7483 ID3D10EffectDepthStencilVariable *iface)
7485 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7488 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_SetRawValue(ID3D10EffectDepthStencilVariable *iface,
7489 void *data, UINT offset, UINT count)
7491 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7494 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetRawValue(ID3D10EffectDepthStencilVariable *iface,
7495 void *data, UINT offset, UINT count)
7497 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7500 /* ID3D10EffectDepthStencilVariable methods */
7502 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetDepthStencilState(ID3D10EffectDepthStencilVariable *iface,
7503 UINT index, ID3D10DepthStencilState **depth_stencil_state)
7505 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7507 TRACE("iface %p, index %u, depth_stencil_state %p.\n", iface, index, depth_stencil_state);
7509 if (v->type->element_count)
7510 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7511 else if (index)
7512 return E_FAIL;
7514 if (v->type->basetype != D3D10_SVT_DEPTHSTENCIL)
7516 WARN("Variable is not a depth stencil state.\n");
7517 return E_FAIL;
7520 if ((*depth_stencil_state = v->u.state.object.depth_stencil))
7521 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
7523 return S_OK;
7526 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetBackingStore(ID3D10EffectDepthStencilVariable *iface,
7527 UINT index, D3D10_DEPTH_STENCIL_DESC *desc)
7529 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7531 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7533 if (v->type->element_count)
7534 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7536 if (v->type->basetype != D3D10_SVT_DEPTHSTENCIL)
7538 WARN("Variable is not a depth stencil state.\n");
7539 return E_FAIL;
7542 *desc = v->u.state.desc.depth_stencil;
7544 return S_OK;
7548 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl =
7550 /* ID3D10EffectVariable methods */
7551 d3d10_effect_depth_stencil_variable_IsValid,
7552 d3d10_effect_depth_stencil_variable_GetType,
7553 d3d10_effect_depth_stencil_variable_GetDesc,
7554 d3d10_effect_depth_stencil_variable_GetAnnotationByIndex,
7555 d3d10_effect_depth_stencil_variable_GetAnnotationByName,
7556 d3d10_effect_depth_stencil_variable_GetMemberByIndex,
7557 d3d10_effect_depth_stencil_variable_GetMemberByName,
7558 d3d10_effect_depth_stencil_variable_GetMemberBySemantic,
7559 d3d10_effect_depth_stencil_variable_GetElement,
7560 d3d10_effect_depth_stencil_variable_GetParentConstantBuffer,
7561 d3d10_effect_depth_stencil_variable_AsScalar,
7562 d3d10_effect_depth_stencil_variable_AsVector,
7563 d3d10_effect_depth_stencil_variable_AsMatrix,
7564 d3d10_effect_depth_stencil_variable_AsString,
7565 d3d10_effect_depth_stencil_variable_AsShaderResource,
7566 d3d10_effect_depth_stencil_variable_AsRenderTargetView,
7567 d3d10_effect_depth_stencil_variable_AsDepthStencilView,
7568 d3d10_effect_depth_stencil_variable_AsConstantBuffer,
7569 d3d10_effect_depth_stencil_variable_AsShader,
7570 d3d10_effect_depth_stencil_variable_AsBlend,
7571 d3d10_effect_depth_stencil_variable_AsDepthStencil,
7572 d3d10_effect_depth_stencil_variable_AsRasterizer,
7573 d3d10_effect_depth_stencil_variable_AsSampler,
7574 d3d10_effect_depth_stencil_variable_SetRawValue,
7575 d3d10_effect_depth_stencil_variable_GetRawValue,
7576 /* ID3D10EffectDepthStencilVariable methods */
7577 d3d10_effect_depth_stencil_variable_GetDepthStencilState,
7578 d3d10_effect_depth_stencil_variable_GetBackingStore,
7581 /* ID3D10EffectVariable methods */
7583 static BOOL STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_IsValid(ID3D10EffectRasterizerVariable *iface)
7585 TRACE("iface %p\n", iface);
7587 return (struct d3d10_effect_variable *)iface != &null_rasterizer_variable;
7590 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetType(
7591 ID3D10EffectRasterizerVariable *iface)
7593 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7596 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetDesc(ID3D10EffectRasterizerVariable *iface,
7597 D3D10_EFFECT_VARIABLE_DESC *desc)
7599 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7602 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetAnnotationByIndex(
7603 ID3D10EffectRasterizerVariable *iface, UINT index)
7605 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7608 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetAnnotationByName(
7609 ID3D10EffectRasterizerVariable *iface, const char *name)
7611 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7614 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberByIndex(
7615 ID3D10EffectRasterizerVariable *iface, UINT index)
7617 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7620 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberByName(
7621 ID3D10EffectRasterizerVariable *iface, const char *name)
7623 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7626 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberBySemantic(
7627 ID3D10EffectRasterizerVariable *iface, const char *semantic)
7629 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7632 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetElement(
7633 ID3D10EffectRasterizerVariable *iface, UINT index)
7635 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7638 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetParentConstantBuffer(
7639 ID3D10EffectRasterizerVariable *iface)
7641 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7644 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsScalar(
7645 ID3D10EffectRasterizerVariable *iface)
7647 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7650 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsVector(
7651 ID3D10EffectRasterizerVariable *iface)
7653 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7656 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsMatrix(
7657 ID3D10EffectRasterizerVariable *iface)
7659 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7662 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsString(
7663 ID3D10EffectRasterizerVariable *iface)
7665 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7668 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsShaderResource(
7669 ID3D10EffectRasterizerVariable *iface)
7671 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7674 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsRenderTargetView(
7675 ID3D10EffectRasterizerVariable *iface)
7677 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7680 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsDepthStencilView(
7681 ID3D10EffectRasterizerVariable *iface)
7683 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7686 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsConstantBuffer(
7687 ID3D10EffectRasterizerVariable *iface)
7689 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7692 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsShader(
7693 ID3D10EffectRasterizerVariable *iface)
7695 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7698 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsBlend(
7699 ID3D10EffectRasterizerVariable *iface)
7701 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7704 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsDepthStencil(
7705 ID3D10EffectRasterizerVariable *iface)
7707 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7710 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsRasterizer(
7711 ID3D10EffectRasterizerVariable *iface)
7713 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7716 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsSampler(
7717 ID3D10EffectRasterizerVariable *iface)
7719 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7722 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_SetRawValue(ID3D10EffectRasterizerVariable *iface,
7723 void *data, UINT offset, UINT count)
7725 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7728 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetRawValue(ID3D10EffectRasterizerVariable *iface,
7729 void *data, UINT offset, UINT count)
7731 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7734 /* ID3D10EffectRasterizerVariable methods */
7736 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetRasterizerState(ID3D10EffectRasterizerVariable *iface,
7737 UINT index, ID3D10RasterizerState **rasterizer_state)
7739 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7741 TRACE("iface %p, index %u, rasterizer_state %p.\n", iface, index, rasterizer_state);
7743 if (v->type->element_count)
7744 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7745 else if (index)
7746 return E_FAIL;
7748 if (v->type->basetype != D3D10_SVT_RASTERIZER)
7750 WARN("Variable is not a rasterizer state.\n");
7751 return E_FAIL;
7754 if ((*rasterizer_state = v->u.state.object.rasterizer))
7755 ID3D10RasterizerState_AddRef(*rasterizer_state);
7757 return S_OK;
7760 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetBackingStore(ID3D10EffectRasterizerVariable *iface,
7761 UINT index, D3D10_RASTERIZER_DESC *desc)
7763 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7765 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7767 if (v->type->element_count)
7768 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7770 if (v->type->basetype != D3D10_SVT_RASTERIZER)
7772 WARN("Variable is not a rasterizer state.\n");
7773 return E_FAIL;
7776 *desc = v->u.state.desc.rasterizer;
7778 return S_OK;
7782 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl =
7784 /* ID3D10EffectVariable methods */
7785 d3d10_effect_rasterizer_variable_IsValid,
7786 d3d10_effect_rasterizer_variable_GetType,
7787 d3d10_effect_rasterizer_variable_GetDesc,
7788 d3d10_effect_rasterizer_variable_GetAnnotationByIndex,
7789 d3d10_effect_rasterizer_variable_GetAnnotationByName,
7790 d3d10_effect_rasterizer_variable_GetMemberByIndex,
7791 d3d10_effect_rasterizer_variable_GetMemberByName,
7792 d3d10_effect_rasterizer_variable_GetMemberBySemantic,
7793 d3d10_effect_rasterizer_variable_GetElement,
7794 d3d10_effect_rasterizer_variable_GetParentConstantBuffer,
7795 d3d10_effect_rasterizer_variable_AsScalar,
7796 d3d10_effect_rasterizer_variable_AsVector,
7797 d3d10_effect_rasterizer_variable_AsMatrix,
7798 d3d10_effect_rasterizer_variable_AsString,
7799 d3d10_effect_rasterizer_variable_AsShaderResource,
7800 d3d10_effect_rasterizer_variable_AsRenderTargetView,
7801 d3d10_effect_rasterizer_variable_AsDepthStencilView,
7802 d3d10_effect_rasterizer_variable_AsConstantBuffer,
7803 d3d10_effect_rasterizer_variable_AsShader,
7804 d3d10_effect_rasterizer_variable_AsBlend,
7805 d3d10_effect_rasterizer_variable_AsDepthStencil,
7806 d3d10_effect_rasterizer_variable_AsRasterizer,
7807 d3d10_effect_rasterizer_variable_AsSampler,
7808 d3d10_effect_rasterizer_variable_SetRawValue,
7809 d3d10_effect_rasterizer_variable_GetRawValue,
7810 /* ID3D10EffectRasterizerVariable methods */
7811 d3d10_effect_rasterizer_variable_GetRasterizerState,
7812 d3d10_effect_rasterizer_variable_GetBackingStore,
7815 /* ID3D10EffectVariable methods */
7817 static BOOL STDMETHODCALLTYPE d3d10_effect_sampler_variable_IsValid(ID3D10EffectSamplerVariable *iface)
7819 TRACE("iface %p\n", iface);
7821 return (struct d3d10_effect_variable *)iface != &null_sampler_variable;
7824 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetType(
7825 ID3D10EffectSamplerVariable *iface)
7827 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7830 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetDesc(ID3D10EffectSamplerVariable *iface,
7831 D3D10_EFFECT_VARIABLE_DESC *desc)
7833 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7836 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetAnnotationByIndex(
7837 ID3D10EffectSamplerVariable *iface, UINT index)
7839 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7842 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetAnnotationByName(
7843 ID3D10EffectSamplerVariable *iface, const char *name)
7845 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7848 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberByIndex(
7849 ID3D10EffectSamplerVariable *iface, UINT index)
7851 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7854 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberByName(
7855 ID3D10EffectSamplerVariable *iface, const char *name)
7857 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7860 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberBySemantic(
7861 ID3D10EffectSamplerVariable *iface, const char *semantic)
7863 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7866 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetElement(
7867 ID3D10EffectSamplerVariable *iface, UINT index)
7869 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7872 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetParentConstantBuffer(
7873 ID3D10EffectSamplerVariable *iface)
7875 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7878 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsScalar(
7879 ID3D10EffectSamplerVariable *iface)
7881 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7884 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsVector(
7885 ID3D10EffectSamplerVariable *iface)
7887 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7890 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsMatrix(
7891 ID3D10EffectSamplerVariable *iface)
7893 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7896 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsString(
7897 ID3D10EffectSamplerVariable *iface)
7899 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7902 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsShaderResource(
7903 ID3D10EffectSamplerVariable *iface)
7905 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7908 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsRenderTargetView(
7909 ID3D10EffectSamplerVariable *iface)
7911 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7914 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsDepthStencilView(
7915 ID3D10EffectSamplerVariable *iface)
7917 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7920 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsConstantBuffer(
7921 ID3D10EffectSamplerVariable *iface)
7923 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7926 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsShader(
7927 ID3D10EffectSamplerVariable *iface)
7929 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7932 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsBlend(
7933 ID3D10EffectSamplerVariable *iface)
7935 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7938 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsDepthStencil(
7939 ID3D10EffectSamplerVariable *iface)
7941 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7944 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsRasterizer(
7945 ID3D10EffectSamplerVariable *iface)
7947 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7950 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsSampler(
7951 ID3D10EffectSamplerVariable *iface)
7953 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7956 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_SetRawValue(ID3D10EffectSamplerVariable *iface,
7957 void *data, UINT offset, UINT count)
7959 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7962 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetRawValue(ID3D10EffectSamplerVariable *iface,
7963 void *data, UINT offset, UINT count)
7965 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7968 /* ID3D10EffectSamplerVariable methods */
7970 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetSampler(ID3D10EffectSamplerVariable *iface,
7971 UINT index, ID3D10SamplerState **sampler)
7973 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7975 TRACE("iface %p, index %u, sampler %p.\n", iface, index, sampler);
7977 if (v->type->element_count)
7978 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7979 else if (index)
7980 return E_FAIL;
7982 if (v->type->basetype != D3D10_SVT_SAMPLER)
7984 WARN("Variable is not a sampler state.\n");
7985 return E_FAIL;
7988 if ((*sampler = v->u.state.object.sampler))
7989 ID3D10SamplerState_AddRef(*sampler);
7991 return S_OK;
7994 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetBackingStore(ID3D10EffectSamplerVariable *iface,
7995 UINT index, D3D10_SAMPLER_DESC *desc)
7997 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7999 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
8001 if (v->type->element_count)
8002 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
8004 if (v->type->basetype != D3D10_SVT_SAMPLER)
8006 WARN("Variable is not a sampler state.\n");
8007 return E_FAIL;
8010 *desc = v->u.state.desc.sampler;
8012 return S_OK;
8016 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl =
8018 /* ID3D10EffectVariable methods */
8019 d3d10_effect_sampler_variable_IsValid,
8020 d3d10_effect_sampler_variable_GetType,
8021 d3d10_effect_sampler_variable_GetDesc,
8022 d3d10_effect_sampler_variable_GetAnnotationByIndex,
8023 d3d10_effect_sampler_variable_GetAnnotationByName,
8024 d3d10_effect_sampler_variable_GetMemberByIndex,
8025 d3d10_effect_sampler_variable_GetMemberByName,
8026 d3d10_effect_sampler_variable_GetMemberBySemantic,
8027 d3d10_effect_sampler_variable_GetElement,
8028 d3d10_effect_sampler_variable_GetParentConstantBuffer,
8029 d3d10_effect_sampler_variable_AsScalar,
8030 d3d10_effect_sampler_variable_AsVector,
8031 d3d10_effect_sampler_variable_AsMatrix,
8032 d3d10_effect_sampler_variable_AsString,
8033 d3d10_effect_sampler_variable_AsShaderResource,
8034 d3d10_effect_sampler_variable_AsRenderTargetView,
8035 d3d10_effect_sampler_variable_AsDepthStencilView,
8036 d3d10_effect_sampler_variable_AsConstantBuffer,
8037 d3d10_effect_sampler_variable_AsShader,
8038 d3d10_effect_sampler_variable_AsBlend,
8039 d3d10_effect_sampler_variable_AsDepthStencil,
8040 d3d10_effect_sampler_variable_AsRasterizer,
8041 d3d10_effect_sampler_variable_AsSampler,
8042 d3d10_effect_sampler_variable_SetRawValue,
8043 d3d10_effect_sampler_variable_GetRawValue,
8044 /* ID3D10EffectSamplerVariable methods */
8045 d3d10_effect_sampler_variable_GetSampler,
8046 d3d10_effect_sampler_variable_GetBackingStore,
8049 /* ID3D10EffectType methods */
8051 static inline struct d3d10_effect_type *impl_from_ID3D10EffectType(ID3D10EffectType *iface)
8053 return CONTAINING_RECORD(iface, struct d3d10_effect_type, ID3D10EffectType_iface);
8056 static BOOL STDMETHODCALLTYPE d3d10_effect_type_IsValid(ID3D10EffectType *iface)
8058 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8060 TRACE("iface %p\n", iface);
8062 return This != &null_type;
8065 static HRESULT STDMETHODCALLTYPE d3d10_effect_type_GetDesc(ID3D10EffectType *iface, D3D10_EFFECT_TYPE_DESC *desc)
8067 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8069 TRACE("iface %p, desc %p\n", iface, desc);
8071 if (This == &null_type)
8073 WARN("Null type specified\n");
8074 return E_FAIL;
8077 if (!desc)
8079 WARN("Invalid argument specified\n");
8080 return E_INVALIDARG;
8083 desc->TypeName = This->name;
8084 desc->Class = This->type_class;
8085 desc->Type = This->basetype;
8086 desc->Elements = This->element_count;
8087 desc->Members = This->member_count;
8088 desc->Rows = This->row_count;
8089 desc->Columns = This->column_count;
8090 desc->PackedSize = This->size_packed;
8091 desc->UnpackedSize = This->size_unpacked;
8092 desc->Stride = This->stride;
8094 return S_OK;
8097 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeByIndex(ID3D10EffectType *iface,
8098 UINT index)
8100 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8101 struct d3d10_effect_type *t;
8103 TRACE("iface %p, index %u\n", iface, index);
8105 if (index >= This->member_count)
8107 WARN("Invalid index specified\n");
8108 return &null_type.ID3D10EffectType_iface;
8111 t = (&This->members[index])->type;
8113 TRACE("Returning member %p, %s\n", t, debugstr_a(t->name));
8115 return &t->ID3D10EffectType_iface;
8118 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeByName(ID3D10EffectType *iface,
8119 const char *name)
8121 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8122 unsigned int i;
8124 TRACE("iface %p, name %s\n", iface, debugstr_a(name));
8126 if (!name)
8128 WARN("Invalid name specified\n");
8129 return &null_type.ID3D10EffectType_iface;
8132 for (i = 0; i < This->member_count; ++i)
8134 struct d3d10_effect_type_member *typem = &This->members[i];
8136 if (typem->name && !strcmp(typem->name, name))
8138 TRACE("Returning type %p.\n", typem->type);
8139 return &typem->type->ID3D10EffectType_iface;
8143 WARN("Invalid name specified\n");
8145 return &null_type.ID3D10EffectType_iface;
8148 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeBySemantic(ID3D10EffectType *iface,
8149 const char *semantic)
8151 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8152 unsigned int i;
8154 TRACE("iface %p, semantic %s\n", iface, debugstr_a(semantic));
8156 if (!semantic)
8158 WARN("Invalid semantic specified\n");
8159 return &null_type.ID3D10EffectType_iface;
8162 for (i = 0; i < This->member_count; ++i)
8164 struct d3d10_effect_type_member *typem = &This->members[i];
8166 if (typem->semantic && !strcmp(typem->semantic, semantic))
8168 TRACE("Returning type %p.\n", typem->type);
8169 return &typem->type->ID3D10EffectType_iface;
8173 WARN("Invalid semantic specified\n");
8175 return &null_type.ID3D10EffectType_iface;
8178 static const char * STDMETHODCALLTYPE d3d10_effect_type_GetMemberName(ID3D10EffectType *iface, UINT index)
8180 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8181 struct d3d10_effect_type_member *typem;
8183 TRACE("iface %p, index %u\n", iface, index);
8185 if (index >= This->member_count)
8187 WARN("Invalid index specified\n");
8188 return NULL;
8191 typem = &This->members[index];
8193 TRACE("Returning name %s\n", debugstr_a(typem->name));
8195 return typem->name;
8198 static const char * STDMETHODCALLTYPE d3d10_effect_type_GetMemberSemantic(ID3D10EffectType *iface, UINT index)
8200 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8201 struct d3d10_effect_type_member *typem;
8203 TRACE("iface %p, index %u\n", iface, index);
8205 if (index >= This->member_count)
8207 WARN("Invalid index specified\n");
8208 return NULL;
8211 typem = &This->members[index];
8213 TRACE("Returning semantic %s\n", debugstr_a(typem->semantic));
8215 return typem->semantic;
8218 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl =
8220 /* ID3D10EffectType */
8221 d3d10_effect_type_IsValid,
8222 d3d10_effect_type_GetDesc,
8223 d3d10_effect_type_GetMemberTypeByIndex,
8224 d3d10_effect_type_GetMemberTypeByName,
8225 d3d10_effect_type_GetMemberTypeBySemantic,
8226 d3d10_effect_type_GetMemberName,
8227 d3d10_effect_type_GetMemberSemantic,