wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / d3d10 / effect.c
blob86ef50aac018239003ecc7312d0b2fa045ed3ee6
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 HRESULT hr;
1335 if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, a)))
1336 return hr;
1338 skip_dword_unknown("annotation", ptr, 1);
1340 /* mark the variable as annotation */
1341 a->flag = D3D10_EFFECT_VARIABLE_ANNOTATION;
1343 return S_OK;
1346 static HRESULT parse_fx10_anonymous_shader(struct d3d10_effect *e, struct d3d10_effect_anonymous_shader *s,
1347 enum d3d10_effect_object_type otype)
1349 struct d3d10_effect_variable *v = &s->shader;
1350 struct d3d10_effect_type *t = &s->type;
1351 const char *shader = NULL;
1353 switch (otype)
1355 case D3D10_EOT_VERTEXSHADER:
1356 shader = "vertexshader";
1357 t->basetype = D3D10_SVT_VERTEXSHADER;
1358 break;
1360 case D3D10_EOT_PIXELSHADER:
1361 shader = "pixelshader";
1362 t->basetype = D3D10_SVT_PIXELSHADER;
1363 break;
1365 case D3D10_EOT_GEOMETRYSHADER:
1366 shader = "geometryshader";
1367 t->basetype = D3D10_SVT_GEOMETRYSHADER;
1368 break;
1370 default:
1371 FIXME("Unhandled object type %#x.\n", otype);
1372 return E_FAIL;
1375 if (!copy_name(shader, &t->name))
1377 ERR("Failed to copy name.\n");
1378 return E_OUTOFMEMORY;
1380 TRACE("Type name: %s.\n", debugstr_a(t->name));
1382 t->type_class = D3D10_SVC_OBJECT;
1384 t->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
1386 v->type = t;
1387 v->effect = e;
1388 set_variable_vtbl(v);
1390 if (!copy_name("$Anonymous", &v->name))
1392 ERR("Failed to copy semantic.\n");
1393 return E_OUTOFMEMORY;
1395 TRACE("Variable name: %s.\n", debugstr_a(v->name));
1397 if (!copy_name(NULL, &v->semantic))
1399 ERR("Failed to copy semantic.\n");
1400 return E_OUTOFMEMORY;
1402 TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
1404 return S_OK;
1407 static const struct d3d10_effect_state_property_info *get_property_info(UINT id)
1409 unsigned int i;
1411 for (i = 0; i < ARRAY_SIZE(property_info); ++i)
1413 if (property_info[i].id == id)
1414 return &property_info[i];
1417 return NULL;
1420 static const struct d3d10_effect_state_storage_info *get_storage_info(D3D_SHADER_VARIABLE_TYPE id)
1422 unsigned int i;
1424 for (i = 0; i < ARRAY_SIZE(d3d10_effect_state_storage_info); ++i)
1426 if (d3d10_effect_state_storage_info[i].id == id)
1427 return &d3d10_effect_state_storage_info[i];
1430 return NULL;
1433 static BOOL read_float_value(DWORD value, D3D_SHADER_VARIABLE_TYPE in_type, float *out_data, UINT idx)
1435 switch (in_type)
1437 case D3D10_SVT_FLOAT:
1438 out_data[idx] = *(float *)&value;
1439 return TRUE;
1441 case D3D10_SVT_INT:
1442 out_data[idx] = (INT)value;
1443 return TRUE;
1445 default:
1446 FIXME("Unhandled in_type %#x.\n", in_type);
1447 return FALSE;
1451 static BOOL read_int32_value(DWORD value, D3D_SHADER_VARIABLE_TYPE in_type, INT *out_data, UINT idx)
1453 switch (in_type)
1455 case D3D10_SVT_FLOAT:
1456 out_data[idx] = *(float *)&value;
1457 return TRUE;
1459 case D3D10_SVT_INT:
1460 case D3D10_SVT_UINT:
1461 case D3D10_SVT_BOOL:
1462 out_data[idx] = value;
1463 return TRUE;
1465 default:
1466 FIXME("Unhandled in_type %#x.\n", in_type);
1467 return FALSE;
1471 static BOOL read_int8_value(DWORD value, D3D_SHADER_VARIABLE_TYPE in_type, INT8 *out_data, UINT idx)
1473 switch (in_type)
1475 case D3D10_SVT_INT:
1476 case D3D10_SVT_UINT:
1477 out_data[idx] = value;
1478 return TRUE;
1480 default:
1481 FIXME("Unhandled in_type %#x.\n", in_type);
1482 return FALSE;
1486 static BOOL read_value_list(const char *data, size_t data_size, DWORD offset,
1487 D3D_SHADER_VARIABLE_TYPE out_type, UINT out_base, UINT out_size, void *out_data)
1489 D3D_SHADER_VARIABLE_TYPE in_type;
1490 const char *ptr;
1491 DWORD t, value;
1492 DWORD count, i;
1494 if (offset >= data_size || !require_space(offset, 1, sizeof(count), data_size))
1496 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1497 return FALSE;
1500 ptr = data + offset;
1501 read_dword(&ptr, &count);
1502 if (count != out_size)
1503 return FALSE;
1505 if (!require_space(ptr - data, count, 2 * sizeof(DWORD), data_size))
1507 WARN("Invalid value count %#x (offset %#x, data size %#lx).\n", count, offset, (long)data_size);
1508 return FALSE;
1511 TRACE("%u values:\n", count);
1512 for (i = 0; i < count; ++i)
1514 UINT out_idx = out_base * out_size + i;
1516 read_dword(&ptr, &t);
1517 read_dword(&ptr, &value);
1519 in_type = d3d10_variable_type(t, FALSE);
1520 TRACE("\t%s: %#x.\n", debug_d3d10_shader_variable_type(in_type), value);
1522 switch (out_type)
1524 case D3D10_SVT_FLOAT:
1525 if (!read_float_value(value, in_type, out_data, out_idx))
1526 return FALSE;
1527 break;
1529 case D3D10_SVT_INT:
1530 case D3D10_SVT_UINT:
1531 case D3D10_SVT_BOOL:
1532 if (!read_int32_value(value, in_type, out_data, out_idx))
1533 return FALSE;
1534 break;
1536 case D3D10_SVT_UINT8:
1537 if (!read_int8_value(value, in_type, out_data, out_idx))
1538 return FALSE;
1539 break;
1541 default:
1542 FIXME("Unhandled out_type %#x.\n", out_type);
1543 return FALSE;
1547 return TRUE;
1550 static BOOL parse_fx10_state_group(const char *data, size_t data_size,
1551 const char **ptr, D3D_SHADER_VARIABLE_TYPE container_type, void *container)
1553 const struct d3d10_effect_state_property_info *property_info;
1554 UINT value_offset;
1555 unsigned int i;
1556 DWORD count;
1557 UINT idx;
1558 UINT id;
1560 read_dword(ptr, &count);
1561 TRACE("Property count: %#x.\n", count);
1563 for (i = 0; i < count; ++i)
1565 read_dword(ptr, &id);
1566 read_dword(ptr, &idx);
1567 skip_dword_unknown("read property", ptr, 1);
1568 read_dword(ptr, &value_offset);
1570 if (!(property_info = get_property_info(id)))
1572 FIXME("Failed to find property info for property %#x.\n", id);
1573 return FALSE;
1576 TRACE("Property %s[%#x] = value list @ offset %#x.\n",
1577 property_info->name, idx, value_offset);
1579 if (property_info->container_type != container_type)
1581 ERR("Invalid container type %#x for property %#x.\n", container_type, id);
1582 return FALSE;
1585 if (idx >= property_info->count)
1587 ERR("Invalid index %#x for property %#x.\n", idx, id);
1588 return FALSE;
1591 if (!read_value_list(data, data_size, value_offset, property_info->type, idx,
1592 property_info->size, (char *)container + property_info->offset))
1594 ERR("Failed to read values for property %#x.\n", id);
1595 return FALSE;
1599 return TRUE;
1602 static HRESULT parse_fx10_object(const char *data, size_t data_size,
1603 const char **ptr, struct d3d10_effect_object *o)
1605 ID3D10EffectVariable *variable = &null_variable.ID3D10EffectVariable_iface;
1606 const char *data_ptr = NULL;
1607 DWORD offset;
1608 enum d3d10_effect_object_operation operation;
1609 HRESULT hr;
1610 struct d3d10_effect *effect = o->pass->technique->effect;
1611 ID3D10Effect *e = &effect->ID3D10Effect_iface;
1612 struct d3d10_effect_variable *v;
1613 DWORD tmp, variable_idx = 0;
1614 const char *name;
1615 size_t name_len;
1617 if (!require_space(*ptr - data, 4, sizeof(DWORD), data_size))
1619 WARN("Invalid offset %#lx (data size %#lx).\n", (long)(*ptr - data), (long)data_size);
1620 return E_FAIL;
1623 read_dword(ptr, &o->type);
1624 TRACE("Effect object is of type %#x.\n", o->type);
1626 read_dword(ptr, &tmp);
1627 TRACE("Effect object index %#x.\n", tmp);
1629 read_dword(ptr, &operation);
1630 TRACE("Effect object operation %#x.\n", operation);
1632 read_dword(ptr, &offset);
1633 TRACE("Effect object idx is at offset %#x.\n", offset);
1635 switch(operation)
1637 case D3D10_EOO_VALUE:
1638 TRACE("Copy variable values\n");
1640 switch (o->type)
1642 case D3D10_EOT_VERTEXSHADER:
1643 TRACE("Vertex shader\n");
1644 variable = &anonymous_vs.ID3D10EffectVariable_iface;
1645 break;
1647 case D3D10_EOT_PIXELSHADER:
1648 TRACE("Pixel shader\n");
1649 variable = &anonymous_ps.ID3D10EffectVariable_iface;
1650 break;
1652 case D3D10_EOT_GEOMETRYSHADER:
1653 TRACE("Geometry shader\n");
1654 variable = &anonymous_gs.ID3D10EffectVariable_iface;
1655 break;
1657 case D3D10_EOT_STENCIL_REF:
1658 if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &o->pass->stencil_ref))
1660 ERR("Failed to read stencil ref.\n");
1661 return E_FAIL;
1663 break;
1665 case D3D10_EOT_SAMPLE_MASK:
1666 if (!read_value_list(data, data_size, offset, D3D10_SVT_UINT, 0, 1, &o->pass->sample_mask))
1668 FIXME("Failed to read sample mask.\n");
1669 return E_FAIL;
1671 break;
1673 case D3D10_EOT_BLEND_FACTOR:
1674 if (!read_value_list(data, data_size, offset, D3D10_SVT_FLOAT, 0, 4, &o->pass->blend_factor[0]))
1676 FIXME("Failed to read blend factor.\n");
1677 return E_FAIL;
1679 break;
1681 default:
1682 FIXME("Unhandled object type %#x\n", o->type);
1683 return E_FAIL;
1685 break;
1687 case D3D10_EOO_PARSED_OBJECT:
1688 /* This is a local object, we've parsed in parse_fx10_local_object. */
1689 if (!fx10_get_string(data, data_size, offset, &name, &name_len))
1691 WARN("Failed to get variable name.\n");
1692 return E_FAIL;
1694 TRACE("Variable name %s.\n", debugstr_a(name));
1696 variable = e->lpVtbl->GetVariableByName(e, name);
1697 break;
1699 case D3D10_EOO_PARSED_OBJECT_INDEX:
1700 /* This is a local object, we've parsed in parse_fx10_local_object, which has an array index. */
1701 if (offset >= data_size || !require_space(offset, 2, sizeof(DWORD), data_size))
1703 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1704 return E_FAIL;
1706 data_ptr = data + offset;
1707 read_dword(&data_ptr, &offset);
1708 read_dword(&data_ptr, &variable_idx);
1710 if (!fx10_get_string(data, data_size, offset, &name, &name_len))
1712 WARN("Failed to get variable name.\n");
1713 return E_FAIL;
1716 TRACE("Variable name %s[%u].\n", debugstr_a(name), variable_idx);
1718 variable = e->lpVtbl->GetVariableByName(e, name);
1719 break;
1721 case D3D10_EOO_ANONYMOUS_SHADER:
1722 TRACE("Anonymous shader\n");
1724 /* check anonymous_shader_current for validity */
1725 if (effect->anonymous_shader_current >= effect->anonymous_shader_count)
1727 ERR("Anonymous shader count is wrong!\n");
1728 return E_FAIL;
1731 if (offset >= data_size || !require_space(offset, 1, sizeof(DWORD), data_size))
1733 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1734 return E_FAIL;
1736 data_ptr = data + offset;
1737 read_dword(&data_ptr, &offset);
1738 TRACE("Effect object starts at offset %#x.\n", offset);
1740 if (FAILED(hr = parse_fx10_anonymous_shader(effect,
1741 &effect->anonymous_shaders[effect->anonymous_shader_current], o->type)))
1742 return hr;
1744 v = &effect->anonymous_shaders[effect->anonymous_shader_current].shader;
1745 variable = &v->ID3D10EffectVariable_iface;
1746 ++effect->anonymous_shader_current;
1748 switch (o->type)
1750 case D3D10_EOT_VERTEXSHADER:
1751 case D3D10_EOT_PIXELSHADER:
1752 case D3D10_EOT_GEOMETRYSHADER:
1753 if (FAILED(hr = parse_fx10_shader(data, data_size, offset, v)))
1754 return hr;
1755 break;
1757 default:
1758 FIXME("Unhandled object type %#x\n", o->type);
1759 return E_FAIL;
1761 break;
1763 default:
1764 FIXME("Unhandled operation %#x.\n", operation);
1765 return E_FAIL;
1768 switch (o->type)
1770 case D3D10_EOT_RASTERIZER_STATE:
1772 ID3D10EffectRasterizerVariable *rv = variable->lpVtbl->AsRasterizer(variable);
1773 if (FAILED(hr = rv->lpVtbl->GetRasterizerState(rv, variable_idx, &o->object.rs)))
1774 return hr;
1775 break;
1778 case D3D10_EOT_DEPTH_STENCIL_STATE:
1780 ID3D10EffectDepthStencilVariable *dv = variable->lpVtbl->AsDepthStencil(variable);
1781 if (FAILED(hr = dv->lpVtbl->GetDepthStencilState(dv, variable_idx, &o->object.ds)))
1782 return hr;
1783 break;
1786 case D3D10_EOT_BLEND_STATE:
1788 ID3D10EffectBlendVariable *bv = variable->lpVtbl->AsBlend(variable);
1789 if (FAILED(hr = bv->lpVtbl->GetBlendState(bv, variable_idx, &o->object.bs)))
1790 return hr;
1791 break;
1794 case D3D10_EOT_VERTEXSHADER:
1796 ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable);
1797 if (FAILED(hr = sv->lpVtbl->GetVertexShader(sv, variable_idx, &o->object.vs)))
1798 return hr;
1799 o->pass->vs.pShaderVariable = sv;
1800 o->pass->vs.ShaderIndex = variable_idx;
1801 break;
1804 case D3D10_EOT_PIXELSHADER:
1806 ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable);
1807 if (FAILED(hr = sv->lpVtbl->GetPixelShader(sv, variable_idx, &o->object.ps)))
1808 return hr;
1809 o->pass->ps.pShaderVariable = sv;
1810 o->pass->ps.ShaderIndex = variable_idx;
1811 break;
1814 case D3D10_EOT_GEOMETRYSHADER:
1816 ID3D10EffectShaderVariable *sv = variable->lpVtbl->AsShader(variable);
1817 if (FAILED(hr = sv->lpVtbl->GetGeometryShader(sv, variable_idx, &o->object.gs)))
1818 return hr;
1819 o->pass->gs.pShaderVariable = sv;
1820 o->pass->gs.ShaderIndex = variable_idx;
1821 break;
1824 case D3D10_EOT_STENCIL_REF:
1825 case D3D10_EOT_BLEND_FACTOR:
1826 case D3D10_EOT_SAMPLE_MASK:
1827 break;
1829 default:
1830 FIXME("Unhandled object type %#x.\n", o->type);
1831 return E_FAIL;
1834 return S_OK;
1837 static HRESULT parse_fx10_pass(const char *data, size_t data_size,
1838 const char **ptr, struct d3d10_effect_pass *p)
1840 HRESULT hr = S_OK;
1841 unsigned int i;
1842 DWORD offset;
1844 read_dword(ptr, &offset);
1845 TRACE("Pass name at offset %#x.\n", offset);
1847 if (!fx10_copy_string(data, data_size, offset, &p->name))
1849 ERR("Failed to copy name.\n");
1850 return E_OUTOFMEMORY;
1852 TRACE("Pass name: %s.\n", debugstr_a(p->name));
1854 read_dword(ptr, &p->object_count);
1855 TRACE("Pass has %u effect objects.\n", p->object_count);
1857 read_dword(ptr, &p->annotation_count);
1858 TRACE("Pass has %u annotations.\n", p->annotation_count);
1860 if (!(p->annotations = heap_calloc(p->annotation_count, sizeof(*p->annotations))))
1862 ERR("Failed to allocate pass annotations memory.\n");
1863 return E_OUTOFMEMORY;
1866 for (i = 0; i < p->annotation_count; ++i)
1868 struct d3d10_effect_variable *a = &p->annotations[i];
1870 a->effect = p->technique->effect;
1871 a->buffer = &null_local_buffer;
1873 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
1874 return hr;
1877 if (!(p->objects = heap_calloc(p->object_count, sizeof(*p->objects))))
1879 ERR("Failed to allocate effect objects memory.\n");
1880 return E_OUTOFMEMORY;
1883 p->vs.pShaderVariable = (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
1884 p->ps.pShaderVariable = (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
1885 p->gs.pShaderVariable = (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
1887 for (i = 0; i < p->object_count; ++i)
1889 struct d3d10_effect_object *o = &p->objects[i];
1891 o->pass = p;
1893 if (FAILED(hr = parse_fx10_object(data, data_size, ptr, o)))
1894 return hr;
1897 return hr;
1900 static HRESULT parse_fx10_technique(const char *data, size_t data_size,
1901 const char **ptr, struct d3d10_effect_technique *t)
1903 unsigned int i;
1904 DWORD offset;
1905 HRESULT hr;
1907 read_dword(ptr, &offset);
1908 TRACE("Technique name at offset %#x.\n", offset);
1910 if (!fx10_copy_string(data, data_size, offset, &t->name))
1912 ERR("Failed to copy name.\n");
1913 return E_OUTOFMEMORY;
1915 TRACE("Technique name: %s.\n", debugstr_a(t->name));
1917 read_dword(ptr, &t->pass_count);
1918 TRACE("Technique has %u passes\n", t->pass_count);
1920 read_dword(ptr, &t->annotation_count);
1921 TRACE("Technique has %u annotations.\n", t->annotation_count);
1923 if (!(t->annotations = heap_calloc(t->annotation_count, sizeof(*t->annotations))))
1925 ERR("Failed to allocate technique annotations memory.\n");
1926 return E_OUTOFMEMORY;
1929 for (i = 0; i < t->annotation_count; ++i)
1931 struct d3d10_effect_variable *a = &t->annotations[i];
1933 a->effect = t->effect;
1934 a->buffer = &null_local_buffer;
1936 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
1937 return hr;
1940 if (!(t->passes = heap_calloc(t->pass_count, sizeof(*t->passes))))
1942 ERR("Failed to allocate passes memory\n");
1943 return E_OUTOFMEMORY;
1946 for (i = 0; i < t->pass_count; ++i)
1948 struct d3d10_effect_pass *p = &t->passes[i];
1950 p->ID3D10EffectPass_iface.lpVtbl = &d3d10_effect_pass_vtbl;
1951 p->technique = t;
1953 if (FAILED(hr = parse_fx10_pass(data, data_size, ptr, p)))
1954 return hr;
1957 return S_OK;
1960 static HRESULT parse_fx10_variable(const char *data, size_t data_size,
1961 const char **ptr, struct d3d10_effect_variable *v)
1963 DWORD offset;
1964 unsigned int i;
1965 HRESULT hr;
1967 if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, v)))
1968 return hr;
1970 read_dword(ptr, &offset);
1971 TRACE("Variable semantic at offset %#x.\n", offset);
1973 if (!fx10_copy_string(data, data_size, offset, &v->semantic))
1975 ERR("Failed to copy semantic.\n");
1976 return E_OUTOFMEMORY;
1978 TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
1980 read_dword(ptr, &v->buffer_offset);
1981 TRACE("Variable offset in buffer: %#x.\n", v->buffer_offset);
1983 skip_dword_unknown("variable", ptr, 1);
1985 read_dword(ptr, &v->flag);
1986 TRACE("Variable flag: %#x.\n", v->flag);
1988 read_dword(ptr, &v->annotation_count);
1989 TRACE("Variable has %u annotations.\n", v->annotation_count);
1991 if (!(v->annotations = heap_calloc(v->annotation_count, sizeof(*v->annotations))))
1993 ERR("Failed to allocate variable annotations memory.\n");
1994 return E_OUTOFMEMORY;
1997 for (i = 0; i < v->annotation_count; ++i)
1999 struct d3d10_effect_variable *a = &v->annotations[i];
2001 a->effect = v->effect;
2002 a->buffer = &null_local_buffer;
2004 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
2005 return hr;
2008 return S_OK;
2011 static HRESULT create_state_object(struct d3d10_effect_variable *v)
2013 ID3D10Device *device = v->effect->device;
2014 HRESULT hr;
2016 switch (v->type->basetype)
2018 case D3D10_SVT_DEPTHSTENCIL:
2019 if (FAILED(hr = ID3D10Device_CreateDepthStencilState(device,
2020 &v->u.state.desc.depth_stencil, &v->u.state.object.depth_stencil)))
2021 return hr;
2022 break;
2024 case D3D10_SVT_BLEND:
2025 if (FAILED(hr = ID3D10Device_CreateBlendState(device,
2026 &v->u.state.desc.blend, &v->u.state.object.blend)))
2027 return hr;
2028 break;
2030 case D3D10_SVT_RASTERIZER:
2031 if (FAILED(hr = ID3D10Device_CreateRasterizerState(device,
2032 &v->u.state.desc.rasterizer, &v->u.state.object.rasterizer)))
2033 return hr;
2034 break;
2036 case D3D10_SVT_SAMPLER:
2037 if (FAILED(hr = ID3D10Device_CreateSamplerState(device,
2038 &v->u.state.desc.sampler, &v->u.state.object.sampler)))
2039 return hr;
2040 break;
2042 default:
2043 ERR("Unhandled variable type %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
2044 return E_FAIL;
2047 return S_OK;
2050 static HRESULT parse_fx10_local_variable(const char *data, size_t data_size,
2051 const char **ptr, struct d3d10_effect_variable *v)
2053 unsigned int i;
2054 HRESULT hr;
2055 DWORD offset;
2057 if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, v)))
2058 return hr;
2060 read_dword(ptr, &offset);
2061 TRACE("Variable semantic at offset %#x.\n", offset);
2063 if (!fx10_copy_string(data, data_size, offset, &v->semantic))
2065 ERR("Failed to copy semantic.\n");
2066 return E_OUTOFMEMORY;
2068 TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
2070 skip_dword_unknown("local variable", ptr, 1);
2072 switch (v->type->basetype)
2074 case D3D10_SVT_TEXTURE1D:
2075 case D3D10_SVT_TEXTURE1DARRAY:
2076 case D3D10_SVT_TEXTURE2D:
2077 case D3D10_SVT_TEXTURE2DARRAY:
2078 case D3D10_SVT_TEXTURE2DMS:
2079 case D3D10_SVT_TEXTURE2DMSARRAY:
2080 case D3D10_SVT_TEXTURE3D:
2081 case D3D10_SVT_TEXTURECUBE:
2082 if (!v->type->element_count)
2083 i = 1;
2084 else
2085 i = v->type->element_count;
2087 if (!(v->u.resource.srv = heap_calloc(i, sizeof(*v->u.resource.srv))))
2089 ERR("Failed to allocate shader resource view array memory.\n");
2090 return E_OUTOFMEMORY;
2092 v->u.resource.parent = TRUE;
2094 if (v->elements)
2096 for (i = 0; i < v->type->element_count; ++i)
2098 v->elements[i].u.resource.srv = &v->u.resource.srv[i];
2099 v->elements[i].u.resource.parent = FALSE;
2102 break;
2104 case D3D10_SVT_RENDERTARGETVIEW:
2105 case D3D10_SVT_DEPTHSTENCILVIEW:
2106 case D3D10_SVT_BUFFER:
2107 TRACE("SVT could not have elements.\n");
2108 break;
2110 case D3D10_SVT_VERTEXSHADER:
2111 case D3D10_SVT_PIXELSHADER:
2112 case D3D10_SVT_GEOMETRYSHADER:
2113 TRACE("Shader type is %s\n", debug_d3d10_shader_variable_type(v->type->basetype));
2114 for (i = 0; i < max(v->type->element_count, 1); ++i)
2116 DWORD shader_offset;
2117 struct d3d10_effect_variable *var;
2119 if (!v->type->element_count)
2121 var = v;
2123 else
2125 var = &v->elements[i];
2128 read_dword(ptr, &shader_offset);
2129 TRACE("Shader offset: %#x.\n", shader_offset);
2131 if (FAILED(hr = parse_fx10_shader(data, data_size, shader_offset, var)))
2132 return hr;
2134 break;
2136 case D3D10_SVT_DEPTHSTENCIL:
2137 case D3D10_SVT_BLEND:
2138 case D3D10_SVT_RASTERIZER:
2139 case D3D10_SVT_SAMPLER:
2141 const struct d3d10_effect_state_storage_info *storage_info;
2142 unsigned int count = max(v->type->element_count, 1);
2144 if (!(storage_info = get_storage_info(v->type->basetype)))
2146 FIXME("Failed to get backing store info for type %s.\n",
2147 debug_d3d10_shader_variable_type(v->type->basetype));
2148 return E_FAIL;
2151 if (storage_info->size > sizeof(v->u.state.desc))
2153 ERR("Invalid storage size %#lx.\n", storage_info->size);
2154 return E_FAIL;
2157 for (i = 0; i < count; ++i)
2159 struct d3d10_effect_variable *var;
2161 if (v->type->element_count)
2162 var = &v->elements[i];
2163 else
2164 var = v;
2166 memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size);
2167 if (!parse_fx10_state_group(data, data_size, ptr, var->type->basetype, &var->u.state.desc))
2169 ERR("Failed to read property list.\n");
2170 return E_FAIL;
2173 if (FAILED(hr = create_state_object(v)))
2174 return hr;
2177 break;
2179 default:
2180 FIXME("Unhandled case %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
2181 return E_FAIL;
2184 read_dword(ptr, &v->annotation_count);
2185 TRACE("Variable has %u annotations.\n", v->annotation_count);
2187 if (!(v->annotations = heap_calloc(v->annotation_count, sizeof(*v->annotations))))
2189 ERR("Failed to allocate variable annotations memory.\n");
2190 return E_OUTOFMEMORY;
2193 for (i = 0; i < v->annotation_count; ++i)
2195 struct d3d10_effect_variable *a = &v->annotations[i];
2197 a->effect = v->effect;
2198 a->buffer = &null_local_buffer;
2200 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
2201 return hr;
2204 return S_OK;
2207 static HRESULT create_variable_buffer(struct d3d10_effect_variable *v, D3D10_CBUFFER_TYPE type)
2209 D3D10_BUFFER_DESC buffer_desc;
2210 D3D10_SUBRESOURCE_DATA subresource_data;
2211 D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc;
2212 ID3D10Device *device = v->effect->device;
2213 HRESULT hr;
2215 if (!(v->u.buffer.local_buffer = heap_alloc_zero(v->type->size_unpacked)))
2217 ERR("Failed to allocate local constant buffer memory.\n");
2218 return E_OUTOFMEMORY;
2221 buffer_desc.ByteWidth = v->type->size_unpacked;
2222 buffer_desc.Usage = D3D10_USAGE_DEFAULT;
2223 buffer_desc.CPUAccessFlags = 0;
2224 buffer_desc.MiscFlags = 0;
2225 if (type == D3D10_CT_CBUFFER)
2226 buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
2227 else
2228 buffer_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
2230 subresource_data.pSysMem = v->u.buffer.local_buffer;
2231 subresource_data.SysMemPitch = 0;
2232 subresource_data.SysMemSlicePitch = 0;
2234 if (FAILED(hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &subresource_data, &v->u.buffer.buffer)))
2235 return hr;
2237 if (type == D3D10_CT_TBUFFER)
2239 srv_desc.Format = DXGI_FORMAT_R32G32B32A32_UINT;
2240 srv_desc.ViewDimension = D3D_SRV_DIMENSION_BUFFER;
2241 srv_desc.Buffer.ElementOffset = 0;
2242 srv_desc.Buffer.ElementWidth = v->type->size_unpacked / 16;
2243 if (v->type->size_unpacked % 16)
2244 WARN("Unexpected texture buffer size not a multiple of 16.\n");
2246 if (FAILED(hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)v->u.buffer.buffer,
2247 &srv_desc, &v->u.buffer.resource_view)))
2248 return hr;
2250 else
2251 v->u.buffer.resource_view = NULL;
2253 return S_OK;
2256 static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size,
2257 const char **ptr, struct d3d10_effect_variable *l)
2259 unsigned int i;
2260 DWORD offset;
2261 D3D10_CBUFFER_TYPE d3d10_cbuffer_type;
2262 HRESULT hr;
2263 unsigned int stride = 0;
2265 /* Generate our own type, it isn't in the fx blob. */
2266 if (!(l->type = heap_alloc_zero(sizeof(*l->type))))
2268 ERR("Failed to allocate local buffer type memory.\n");
2269 return E_OUTOFMEMORY;
2271 l->type->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
2272 l->type->type_class = D3D10_SVC_OBJECT;
2273 l->type->effect = l->effect;
2275 read_dword(ptr, &offset);
2276 TRACE("Local buffer name at offset %#x.\n", offset);
2278 if (!fx10_copy_string(data, data_size, offset, &l->name))
2280 ERR("Failed to copy name.\n");
2281 return E_OUTOFMEMORY;
2283 TRACE("Local buffer name: %s.\n", debugstr_a(l->name));
2285 read_dword(ptr, &l->data_size);
2286 TRACE("Local buffer data size: %#x.\n", l->data_size);
2288 read_dword(ptr, &d3d10_cbuffer_type);
2289 TRACE("Local buffer type: %#x.\n", d3d10_cbuffer_type);
2291 switch(d3d10_cbuffer_type)
2293 case D3D10_CT_CBUFFER:
2294 l->type->basetype = D3D10_SVT_CBUFFER;
2295 if (!copy_name("cbuffer", &l->type->name))
2297 ERR("Failed to copy name.\n");
2298 return E_OUTOFMEMORY;
2300 break;
2302 case D3D10_CT_TBUFFER:
2303 l->type->basetype = D3D10_SVT_TBUFFER;
2304 if (!copy_name("tbuffer", &l->type->name))
2306 ERR("Failed to copy name.\n");
2307 return E_OUTOFMEMORY;
2309 break;
2311 default:
2312 ERR("Unexpected D3D10_CBUFFER_TYPE %#x!\n", d3d10_cbuffer_type);
2313 return E_FAIL;
2316 read_dword(ptr, &l->type->member_count);
2317 TRACE("Local buffer member count: %#x.\n", l->type->member_count);
2319 skip_dword_unknown("local buffer", ptr, 1);
2321 read_dword(ptr, &l->annotation_count);
2322 TRACE("Local buffer has %u annotations.\n", l->annotation_count);
2324 if (!(l->annotations = heap_calloc(l->annotation_count, sizeof(*l->annotations))))
2326 ERR("Failed to allocate local buffer annotations memory.\n");
2327 return E_OUTOFMEMORY;
2330 for (i = 0; i < l->annotation_count; ++i)
2332 struct d3d10_effect_variable *a = &l->annotations[i];
2334 a->effect = l->effect;
2335 a->buffer = &null_local_buffer;
2337 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
2338 return hr;
2341 if (!(l->members = heap_calloc(l->type->member_count, sizeof(*l->members))))
2343 ERR("Failed to allocate members memory.\n");
2344 return E_OUTOFMEMORY;
2347 if (!(l->type->members = heap_calloc(l->type->member_count, sizeof(*l->type->members))))
2349 ERR("Failed to allocate type members memory.\n");
2350 return E_OUTOFMEMORY;
2353 for (i = 0; i < l->type->member_count; ++i)
2355 struct d3d10_effect_variable *v = &l->members[i];
2356 struct d3d10_effect_type_member *typem = &l->type->members[i];
2358 v->buffer = l;
2359 v->effect = l->effect;
2361 if (FAILED(hr = parse_fx10_variable(data, data_size, ptr, v)))
2362 return hr;
2365 * Copy the values from the variable type to the constant buffers type
2366 * members structure, because it is our own generated type.
2368 typem->type = v->type;
2370 if (!copy_name(v->name, &typem->name))
2372 ERR("Failed to copy name.\n");
2373 return E_OUTOFMEMORY;
2375 TRACE("Variable name: %s.\n", debugstr_a(typem->name));
2377 if (!copy_name(v->semantic, &typem->semantic))
2379 ERR("Failed to copy name.\n");
2380 return E_OUTOFMEMORY;
2382 TRACE("Variable semantic: %s.\n", debugstr_a(typem->semantic));
2384 typem->buffer_offset = v->buffer_offset;
2385 TRACE("Variable buffer offset: %u.\n", typem->buffer_offset);
2387 l->type->size_packed += v->type->size_packed;
2390 * For the complete constantbuffer the size_unpacked = stride,
2391 * the stride is calculated like this:
2393 * 1) if the constant buffer variables are packed with packoffset
2394 * - stride = the highest used constant
2395 * - the complete stride has to be a multiple of 0x10
2397 * 2) if the constant buffer variables are NOT packed with packoffset
2398 * - sum of unpacked size for all variables which fit in a 0x10 part
2399 * - if the size exceeds a 0x10 part, the rest of the old part is skipped
2400 * and a new part is started
2401 * - if the variable is a struct it is always used a new part
2402 * - the complete stride has to be a multiple of 0x10
2404 * e.g.:
2405 * 0x4, 0x4, 0x4, 0x8, 0x4, 0x14, 0x4
2406 * part 0x10 0x10 0x20 -> 0x40
2408 if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
2410 if ((v->type->size_unpacked + v->buffer_offset) > stride)
2412 stride = v->type->size_unpacked + v->buffer_offset;
2415 else
2417 if (v->type->type_class == D3D10_SVC_STRUCT)
2419 stride = (stride + 0xf) & ~0xf;
2422 if ( ((stride & 0xf) + v->type->size_unpacked) > 0x10)
2424 stride = (stride + 0xf) & ~0xf;
2427 stride += v->type->size_unpacked;
2430 l->type->stride = l->type->size_unpacked = (stride + 0xf) & ~0xf;
2432 TRACE("Constant buffer:\n");
2433 TRACE("\tType name: %s.\n", debugstr_a(l->type->name));
2434 TRACE("\tElement count: %u.\n", l->type->element_count);
2435 TRACE("\tMember count: %u.\n", l->type->member_count);
2436 TRACE("\tUnpacked size: %#x.\n", l->type->size_unpacked);
2437 TRACE("\tStride: %#x.\n", l->type->stride);
2438 TRACE("\tPacked size %#x.\n", l->type->size_packed);
2439 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype));
2440 TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
2442 if (l->type->size_unpacked)
2444 if (FAILED(hr = create_variable_buffer(l, d3d10_cbuffer_type)))
2445 return hr;
2448 return S_OK;
2451 static void d3d10_effect_type_member_destroy(struct d3d10_effect_type_member *typem)
2453 TRACE("effect type member %p.\n", typem);
2455 /* Do not release typem->type, it will be covered by d3d10_effect_type_destroy(). */
2456 heap_free(typem->semantic);
2457 heap_free(typem->name);
2460 static void d3d10_effect_type_destroy(struct wine_rb_entry *entry, void *context)
2462 struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, struct d3d10_effect_type, entry);
2464 TRACE("effect type %p.\n", t);
2466 if (t->elementtype)
2468 heap_free(t->elementtype->name);
2469 heap_free(t->elementtype);
2472 if (t->members)
2474 unsigned int i;
2476 for (i = 0; i < t->member_count; ++i)
2478 d3d10_effect_type_member_destroy(&t->members[i]);
2480 heap_free(t->members);
2483 heap_free(t->name);
2484 heap_free(t);
2487 static HRESULT parse_fx10_body(struct d3d10_effect *e, const char *data, DWORD data_size)
2489 const char *ptr;
2490 unsigned int i;
2491 HRESULT hr;
2493 if (e->index_offset >= data_size)
2495 WARN("Invalid index offset %#x (data size %#x).\n", e->index_offset, data_size);
2496 return E_FAIL;
2498 ptr = data + e->index_offset;
2500 if (!(e->local_buffers = heap_calloc(e->local_buffer_count, sizeof(*e->local_buffers))))
2502 ERR("Failed to allocate local buffer memory.\n");
2503 return E_OUTOFMEMORY;
2506 if (!(e->local_variables = heap_calloc(e->local_variable_count, sizeof(*e->local_variables))))
2508 ERR("Failed to allocate local variable memory.\n");
2509 return E_OUTOFMEMORY;
2512 if (!(e->anonymous_shaders = heap_calloc(e->anonymous_shader_count, sizeof(*e->anonymous_shaders))))
2514 ERR("Failed to allocate anonymous shaders memory\n");
2515 return E_OUTOFMEMORY;
2518 if (!(e->used_shaders = heap_calloc(e->used_shader_count, sizeof(*e->used_shaders))))
2520 ERR("Failed to allocate used shaders memory\n");
2521 return E_OUTOFMEMORY;
2524 if (!(e->techniques = heap_calloc(e->technique_count, sizeof(*e->techniques))))
2526 ERR("Failed to allocate techniques memory\n");
2527 return E_OUTOFMEMORY;
2530 for (i = 0; i < e->local_buffer_count; ++i)
2532 struct d3d10_effect_variable *l = &e->local_buffers[i];
2533 l->ID3D10EffectVariable_iface.lpVtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl;
2534 l->effect = e;
2535 l->buffer = &null_local_buffer;
2537 if (FAILED(hr = parse_fx10_local_buffer(data, data_size, &ptr, l)))
2538 return hr;
2541 for (i = 0; i < e->local_variable_count; ++i)
2543 struct d3d10_effect_variable *v = &e->local_variables[i];
2545 v->effect = e;
2546 v->ID3D10EffectVariable_iface.lpVtbl = &d3d10_effect_variable_vtbl;
2547 v->buffer = &null_local_buffer;
2549 if (FAILED(hr = parse_fx10_local_variable(data, data_size, &ptr, v)))
2550 return hr;
2553 for (i = 0; i < e->technique_count; ++i)
2555 struct d3d10_effect_technique *t = &e->techniques[i];
2557 t->ID3D10EffectTechnique_iface.lpVtbl = &d3d10_effect_technique_vtbl;
2558 t->effect = e;
2560 if (FAILED(hr = parse_fx10_technique(data, data_size, &ptr, t)))
2561 return hr;
2564 return S_OK;
2567 static HRESULT parse_fx10(struct d3d10_effect *e, const char *data, DWORD data_size)
2569 const char *ptr = data;
2570 DWORD unknown;
2572 if (!require_space(0, 19, sizeof(DWORD), data_size))
2574 WARN("Invalid data size %#x.\n", data_size);
2575 return E_INVALIDARG;
2578 /* Compiled target version (e.g. fx_4_0=0xfeff1001, fx_4_1=0xfeff1011). */
2579 read_dword(&ptr, &e->version);
2580 TRACE("Target: %#x\n", e->version);
2582 read_dword(&ptr, &e->local_buffer_count);
2583 TRACE("Local buffer count: %u.\n", e->local_buffer_count);
2585 read_dword(&ptr, &e->variable_count);
2586 TRACE("Variable count: %u\n", e->variable_count);
2588 read_dword(&ptr, &e->local_variable_count);
2589 TRACE("Object count: %u\n", e->local_variable_count);
2591 read_dword(&ptr, &e->sharedbuffers_count);
2592 TRACE("Sharedbuffers count: %u\n", e->sharedbuffers_count);
2594 /* Number of variables in shared buffers? */
2595 read_dword(&ptr, &unknown);
2596 FIXME("Unknown 0: %u\n", unknown);
2598 read_dword(&ptr, &e->sharedobjects_count);
2599 TRACE("Sharedobjects count: %u\n", e->sharedobjects_count);
2601 read_dword(&ptr, &e->technique_count);
2602 TRACE("Technique count: %u\n", e->technique_count);
2604 read_dword(&ptr, &e->index_offset);
2605 TRACE("Index offset: %#x\n", e->index_offset);
2607 read_dword(&ptr, &unknown);
2608 FIXME("Unknown 1: %u\n", unknown);
2610 read_dword(&ptr, &e->texture_count);
2611 TRACE("Texture count: %u\n", e->texture_count);
2613 read_dword(&ptr, &e->depthstencilstate_count);
2614 TRACE("Depthstencilstate count: %u\n", e->depthstencilstate_count);
2616 read_dword(&ptr, &e->blendstate_count);
2617 TRACE("Blendstate count: %u\n", e->blendstate_count);
2619 read_dword(&ptr, &e->rasterizerstate_count);
2620 TRACE("Rasterizerstate count: %u\n", e->rasterizerstate_count);
2622 read_dword(&ptr, &e->samplerstate_count);
2623 TRACE("Samplerstate count: %u\n", e->samplerstate_count);
2625 read_dword(&ptr, &e->rendertargetview_count);
2626 TRACE("Rendertargetview count: %u\n", e->rendertargetview_count);
2628 read_dword(&ptr, &e->depthstencilview_count);
2629 TRACE("Depthstencilview count: %u\n", e->depthstencilview_count);
2631 read_dword(&ptr, &e->used_shader_count);
2632 TRACE("Used shader count: %u\n", e->used_shader_count);
2634 read_dword(&ptr, &e->anonymous_shader_count);
2635 TRACE("Anonymous shader count: %u\n", e->anonymous_shader_count);
2637 return parse_fx10_body(e, ptr, data_size - (ptr - data));
2640 static HRESULT fx10_chunk_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
2642 struct d3d10_effect *e = ctx;
2644 TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
2646 TRACE("chunk size: %#x\n", data_size);
2648 switch(tag)
2650 case TAG_FX10:
2651 return parse_fx10(e, data, data_size);
2653 default:
2654 FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag, 4));
2655 return S_OK;
2659 HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T data_size)
2661 return parse_dxbc(data, data_size, fx10_chunk_handler, This);
2664 static HRESULT d3d10_effect_object_apply(struct d3d10_effect_object *o)
2666 ID3D10Device *device = o->pass->technique->effect->device;
2668 TRACE("effect object %p, type %#x.\n", o, o->type);
2670 switch(o->type)
2672 case D3D10_EOT_RASTERIZER_STATE:
2673 ID3D10Device_RSSetState(device, o->object.rs);
2674 return S_OK;
2676 case D3D10_EOT_DEPTH_STENCIL_STATE:
2677 ID3D10Device_OMSetDepthStencilState(device, o->object.ds, o->pass->stencil_ref);
2678 return S_OK;
2680 case D3D10_EOT_BLEND_STATE:
2681 ID3D10Device_OMSetBlendState(device, o->object.bs, o->pass->blend_factor, o->pass->sample_mask);
2682 return S_OK;
2684 case D3D10_EOT_VERTEXSHADER:
2685 ID3D10Device_VSSetShader(device, o->object.vs);
2686 return S_OK;
2688 case D3D10_EOT_PIXELSHADER:
2689 ID3D10Device_PSSetShader(device, o->object.ps);
2690 return S_OK;
2692 case D3D10_EOT_GEOMETRYSHADER:
2693 ID3D10Device_GSSetShader(device, o->object.gs);
2694 return S_OK;
2696 case D3D10_EOT_STENCIL_REF:
2697 case D3D10_EOT_BLEND_FACTOR:
2698 case D3D10_EOT_SAMPLE_MASK:
2699 return S_OK;
2701 default:
2702 FIXME("Unhandled effect object type %#x.\n", o->type);
2703 return E_FAIL;
2707 static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_variable *s,
2708 D3D10_SHADER_VARIABLE_TYPE type)
2710 shader_free_signature(&s->input_signature);
2711 shader_free_signature(&s->output_signature);
2713 switch (type)
2715 case D3D10_SVT_VERTEXSHADER:
2716 if (s->shader.vs)
2717 ID3D10VertexShader_Release(s->shader.vs);
2718 break;
2720 case D3D10_SVT_PIXELSHADER:
2721 if (s->shader.ps)
2722 ID3D10PixelShader_Release(s->shader.ps);
2723 break;
2725 case D3D10_SVT_GEOMETRYSHADER:
2726 if (s->shader.gs)
2727 ID3D10GeometryShader_Release(s->shader.gs);
2728 break;
2730 default:
2731 FIXME("Unhandled shader type %s.\n", debug_d3d10_shader_variable_type(type));
2732 break;
2735 if (s->resource_count)
2736 heap_free(s->resources);
2739 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v)
2741 unsigned int i, elem_count;
2743 TRACE("variable %p.\n", v);
2745 heap_free(v->name);
2746 heap_free(v->semantic);
2747 if (v->annotations)
2749 for (i = 0; i < v->annotation_count; ++i)
2751 d3d10_effect_variable_destroy(&v->annotations[i]);
2753 heap_free(v->annotations);
2756 if (v->members)
2758 for (i = 0; i < v->type->member_count; ++i)
2760 d3d10_effect_variable_destroy(&v->members[i]);
2762 heap_free(v->members);
2765 if (v->elements)
2767 for (i = 0; i < v->type->element_count; ++i)
2769 d3d10_effect_variable_destroy(&v->elements[i]);
2771 heap_free(v->elements);
2774 if (v->type)
2776 switch (v->type->basetype)
2778 case D3D10_SVT_VERTEXSHADER:
2779 case D3D10_SVT_PIXELSHADER:
2780 case D3D10_SVT_GEOMETRYSHADER:
2781 d3d10_effect_shader_variable_destroy(&v->u.shader, v->type->basetype);
2782 break;
2784 case D3D10_SVT_DEPTHSTENCIL:
2785 if (v->u.state.object.depth_stencil)
2786 ID3D10DepthStencilState_Release(v->u.state.object.depth_stencil);
2787 break;
2789 case D3D10_SVT_BLEND:
2790 if (v->u.state.object.blend)
2791 ID3D10BlendState_Release(v->u.state.object.blend);
2792 break;
2794 case D3D10_SVT_RASTERIZER:
2795 if (v->u.state.object.rasterizer)
2796 ID3D10RasterizerState_Release(v->u.state.object.rasterizer);
2797 break;
2799 case D3D10_SVT_SAMPLER:
2800 if (v->u.state.object.sampler)
2801 ID3D10SamplerState_Release(v->u.state.object.sampler);
2802 break;
2804 case D3D10_SVT_TEXTURE1D:
2805 case D3D10_SVT_TEXTURE1DARRAY:
2806 case D3D10_SVT_TEXTURE2D:
2807 case D3D10_SVT_TEXTURE2DARRAY:
2808 case D3D10_SVT_TEXTURE2DMS:
2809 case D3D10_SVT_TEXTURE2DMSARRAY:
2810 case D3D10_SVT_TEXTURE3D:
2811 case D3D10_SVT_TEXTURECUBE:
2812 if (!v->u.resource.parent)
2813 break;
2815 if (!v->type->element_count)
2816 elem_count = 1;
2817 else
2818 elem_count = v->type->element_count;
2820 for (i = 0; i < elem_count; ++i)
2822 if (v->u.resource.srv[i])
2823 ID3D10ShaderResourceView_Release(v->u.resource.srv[i]);
2826 heap_free(v->u.resource.srv);
2827 break;
2829 default:
2830 break;
2835 static void d3d10_effect_object_destroy(struct d3d10_effect_object *o)
2837 switch (o->type)
2839 case D3D10_EOT_RASTERIZER_STATE:
2840 if (o->object.rs)
2841 ID3D10RasterizerState_Release(o->object.rs);
2842 break;
2844 case D3D10_EOT_DEPTH_STENCIL_STATE:
2845 if (o->object.ds)
2846 ID3D10DepthStencilState_Release(o->object.ds);
2847 break;
2849 case D3D10_EOT_BLEND_STATE:
2850 if (o->object.bs)
2851 ID3D10BlendState_Release(o->object.bs);
2852 break;
2854 case D3D10_EOT_VERTEXSHADER:
2855 if (o->object.vs)
2856 ID3D10VertexShader_Release(o->object.vs);
2857 break;
2859 case D3D10_EOT_PIXELSHADER:
2860 if (o->object.ps)
2861 ID3D10PixelShader_Release(o->object.ps);
2862 break;
2864 case D3D10_EOT_GEOMETRYSHADER:
2865 if (o->object.gs)
2866 ID3D10GeometryShader_Release(o->object.gs);
2867 break;
2869 default:
2870 break;
2874 static void d3d10_effect_pass_destroy(struct d3d10_effect_pass *p)
2876 unsigned int i;
2878 TRACE("pass %p\n", p);
2880 heap_free(p->name);
2882 if (p->objects)
2884 for (i = 0; i < p->object_count; ++i)
2886 d3d10_effect_object_destroy(&p->objects[i]);
2888 heap_free(p->objects);
2891 if (p->annotations)
2893 for (i = 0; i < p->annotation_count; ++i)
2895 d3d10_effect_variable_destroy(&p->annotations[i]);
2897 heap_free(p->annotations);
2901 static void d3d10_effect_technique_destroy(struct d3d10_effect_technique *t)
2903 unsigned int i;
2905 TRACE("technique %p\n", t);
2907 heap_free(t->name);
2908 if (t->passes)
2910 for (i = 0; i < t->pass_count; ++i)
2912 d3d10_effect_pass_destroy(&t->passes[i]);
2914 heap_free(t->passes);
2917 if (t->annotations)
2919 for (i = 0; i < t->annotation_count; ++i)
2921 d3d10_effect_variable_destroy(&t->annotations[i]);
2923 heap_free(t->annotations);
2927 static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable *l)
2929 unsigned int i;
2931 TRACE("local buffer %p.\n", l);
2933 heap_free(l->name);
2934 if (l->members)
2936 for (i = 0; i < l->type->member_count; ++i)
2938 d3d10_effect_variable_destroy(&l->members[i]);
2940 heap_free(l->members);
2943 if (l->type)
2944 d3d10_effect_type_destroy(&l->type->entry, NULL);
2946 if (l->annotations)
2948 for (i = 0; i < l->annotation_count; ++i)
2950 d3d10_effect_variable_destroy(&l->annotations[i]);
2952 heap_free(l->annotations);
2955 heap_free(l->u.buffer.local_buffer);
2957 if (l->u.buffer.buffer)
2958 ID3D10Buffer_Release(l->u.buffer.buffer);
2959 if (l->u.buffer.resource_view)
2960 ID3D10ShaderResourceView_Release(l->u.buffer.resource_view);
2963 /* IUnknown methods */
2965 static inline struct d3d10_effect *impl_from_ID3D10Effect(ID3D10Effect *iface)
2967 return CONTAINING_RECORD(iface, struct d3d10_effect, ID3D10Effect_iface);
2970 static HRESULT STDMETHODCALLTYPE d3d10_effect_QueryInterface(ID3D10Effect *iface, REFIID riid, void **object)
2972 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
2974 if (IsEqualGUID(riid, &IID_ID3D10Effect)
2975 || IsEqualGUID(riid, &IID_IUnknown))
2977 IUnknown_AddRef(iface);
2978 *object = iface;
2979 return S_OK;
2982 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
2984 *object = NULL;
2985 return E_NOINTERFACE;
2988 static ULONG STDMETHODCALLTYPE d3d10_effect_AddRef(ID3D10Effect *iface)
2990 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
2991 ULONG refcount = InterlockedIncrement(&This->refcount);
2993 TRACE("%p increasing refcount to %u\n", This, refcount);
2995 return refcount;
2998 static ULONG STDMETHODCALLTYPE d3d10_effect_Release(ID3D10Effect *iface)
3000 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3001 ULONG refcount = InterlockedDecrement(&This->refcount);
3003 TRACE("%p decreasing refcount to %u\n", This, refcount);
3005 if (!refcount)
3007 unsigned int i;
3009 if (This->techniques)
3011 for (i = 0; i < This->technique_count; ++i)
3013 d3d10_effect_technique_destroy(&This->techniques[i]);
3015 heap_free(This->techniques);
3018 if (This->local_variables)
3020 for (i = 0; i < This->local_variable_count; ++i)
3022 d3d10_effect_variable_destroy(&This->local_variables[i]);
3024 heap_free(This->local_variables);
3027 if (This->local_buffers)
3029 for (i = 0; i < This->local_buffer_count; ++i)
3031 d3d10_effect_local_buffer_destroy(&This->local_buffers[i]);
3033 heap_free(This->local_buffers);
3036 if (This->anonymous_shaders)
3038 for (i = 0; i < This->anonymous_shader_count; ++i)
3040 d3d10_effect_variable_destroy(&This->anonymous_shaders[i].shader);
3041 heap_free(This->anonymous_shaders[i].type.name);
3043 heap_free(This->anonymous_shaders);
3046 heap_free(This->used_shaders);
3048 wine_rb_destroy(&This->types, d3d10_effect_type_destroy, NULL);
3050 ID3D10Device_Release(This->device);
3051 heap_free(This);
3054 return refcount;
3057 /* ID3D10Effect methods */
3059 static BOOL STDMETHODCALLTYPE d3d10_effect_IsValid(ID3D10Effect *iface)
3061 FIXME("iface %p stub!\n", iface);
3063 return FALSE;
3066 static BOOL STDMETHODCALLTYPE d3d10_effect_IsPool(ID3D10Effect *iface)
3068 FIXME("iface %p stub!\n", iface);
3070 return FALSE;
3073 static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDevice(ID3D10Effect *iface, ID3D10Device **device)
3075 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3077 TRACE("iface %p, device %p\n", iface, device);
3079 ID3D10Device_AddRef(This->device);
3080 *device = This->device;
3082 return S_OK;
3085 static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDesc(ID3D10Effect *iface, D3D10_EFFECT_DESC *desc)
3087 FIXME("iface %p, desc %p stub!\n", iface, desc);
3089 return E_NOTIMPL;
3092 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetConstantBufferByIndex(ID3D10Effect *iface,
3093 UINT index)
3095 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3096 struct d3d10_effect_variable *l;
3098 TRACE("iface %p, index %u\n", iface, index);
3100 if (index >= This->local_buffer_count)
3102 WARN("Invalid index specified\n");
3103 return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
3106 l = &This->local_buffers[index];
3108 TRACE("Returning buffer %p, %s.\n", l, debugstr_a(l->name));
3110 return (ID3D10EffectConstantBuffer *)&l->ID3D10EffectVariable_iface;
3113 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetConstantBufferByName(ID3D10Effect *iface,
3114 const char *name)
3116 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3117 unsigned int i;
3119 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3121 for (i = 0; i < This->local_buffer_count; ++i)
3123 struct d3d10_effect_variable *l = &This->local_buffers[i];
3125 if (l->name && !strcmp(l->name, name))
3127 TRACE("Returning buffer %p.\n", l);
3128 return (ID3D10EffectConstantBuffer *)&l->ID3D10EffectVariable_iface;
3132 WARN("Invalid name specified\n");
3134 return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
3137 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableByIndex(ID3D10Effect *iface, UINT index)
3139 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3140 unsigned int i;
3142 TRACE("iface %p, index %u\n", iface, index);
3144 for (i = 0; i < This->local_buffer_count; ++i)
3146 struct d3d10_effect_variable *l = &This->local_buffers[i];
3148 if (index < l->type->member_count)
3150 struct d3d10_effect_variable *v = &l->members[index];
3152 TRACE("Returning variable %p.\n", v);
3153 return &v->ID3D10EffectVariable_iface;
3155 index -= l->type->member_count;
3158 if (index < This->local_variable_count)
3160 struct d3d10_effect_variable *v = &This->local_variables[index];
3162 TRACE("Returning variable %p.\n", v);
3163 return &v->ID3D10EffectVariable_iface;
3166 WARN("Invalid index specified\n");
3168 return &null_variable.ID3D10EffectVariable_iface;
3171 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableByName(ID3D10Effect *iface,
3172 const char *name)
3174 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3175 unsigned int i;
3177 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3179 if (!name)
3181 WARN("Invalid name specified\n");
3182 return &null_variable.ID3D10EffectVariable_iface;
3185 for (i = 0; i < This->local_buffer_count; ++i)
3187 struct d3d10_effect_variable *l = &This->local_buffers[i];
3188 unsigned int j;
3190 for (j = 0; j < l->type->member_count; ++j)
3192 struct d3d10_effect_variable *v = &l->members[j];
3194 if (v->name && !strcmp(v->name, name))
3196 TRACE("Returning variable %p.\n", v);
3197 return &v->ID3D10EffectVariable_iface;
3202 for (i = 0; i < This->local_variable_count; ++i)
3204 struct d3d10_effect_variable *v = &This->local_variables[i];
3206 if (v->name && !strcmp(v->name, name))
3208 TRACE("Returning variable %p.\n", v);
3209 return &v->ID3D10EffectVariable_iface;
3213 WARN("Invalid name specified\n");
3215 return &null_variable.ID3D10EffectVariable_iface;
3218 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableBySemantic(ID3D10Effect *iface,
3219 const char *semantic)
3221 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3222 unsigned int i;
3224 TRACE("iface %p, semantic %s\n", iface, debugstr_a(semantic));
3226 if (!semantic)
3228 WARN("Invalid semantic specified\n");
3229 return &null_variable.ID3D10EffectVariable_iface;
3232 for (i = 0; i < This->local_buffer_count; ++i)
3234 struct d3d10_effect_variable *l = &This->local_buffers[i];
3235 unsigned int j;
3237 for (j = 0; j < l->type->member_count; ++j)
3239 struct d3d10_effect_variable *v = &l->members[j];
3241 if (v->semantic && !strcmp(v->semantic, semantic))
3243 TRACE("Returning variable %p.\n", v);
3244 return &v->ID3D10EffectVariable_iface;
3249 for (i = 0; i < This->local_variable_count; ++i)
3251 struct d3d10_effect_variable *v = &This->local_variables[i];
3253 if (v->semantic && !strcmp(v->semantic, semantic))
3255 TRACE("Returning variable %p.\n", v);
3256 return &v->ID3D10EffectVariable_iface;
3260 WARN("Invalid semantic specified\n");
3262 return &null_variable.ID3D10EffectVariable_iface;
3265 static struct ID3D10EffectTechnique * STDMETHODCALLTYPE d3d10_effect_GetTechniqueByIndex(ID3D10Effect *iface,
3266 UINT index)
3268 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3269 struct d3d10_effect_technique *t;
3271 TRACE("iface %p, index %u\n", iface, index);
3273 if (index >= This->technique_count)
3275 WARN("Invalid index specified\n");
3276 return &null_technique.ID3D10EffectTechnique_iface;
3279 t = &This->techniques[index];
3281 TRACE("Returning technique %p, %s.\n", t, debugstr_a(t->name));
3283 return &t->ID3D10EffectTechnique_iface;
3286 static struct ID3D10EffectTechnique * STDMETHODCALLTYPE d3d10_effect_GetTechniqueByName(ID3D10Effect *iface,
3287 const char *name)
3289 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3290 unsigned int i;
3292 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3294 if (!name)
3296 WARN("Invalid name specified\n");
3297 return &null_technique.ID3D10EffectTechnique_iface;
3300 for (i = 0; i < This->technique_count; ++i)
3302 struct d3d10_effect_technique *t = &This->techniques[i];
3303 if (t->name && !strcmp(t->name, name))
3305 TRACE("Returning technique %p\n", t);
3306 return &t->ID3D10EffectTechnique_iface;
3310 WARN("Invalid name specified\n");
3312 return &null_technique.ID3D10EffectTechnique_iface;
3315 static HRESULT STDMETHODCALLTYPE d3d10_effect_Optimize(ID3D10Effect *iface)
3317 FIXME("iface %p stub!\n", iface);
3319 return E_NOTIMPL;
3322 static BOOL STDMETHODCALLTYPE d3d10_effect_IsOptimized(ID3D10Effect *iface)
3324 FIXME("iface %p stub!\n", iface);
3326 return FALSE;
3329 const struct ID3D10EffectVtbl d3d10_effect_vtbl =
3331 /* IUnknown methods */
3332 d3d10_effect_QueryInterface,
3333 d3d10_effect_AddRef,
3334 d3d10_effect_Release,
3335 /* ID3D10Effect methods */
3336 d3d10_effect_IsValid,
3337 d3d10_effect_IsPool,
3338 d3d10_effect_GetDevice,
3339 d3d10_effect_GetDesc,
3340 d3d10_effect_GetConstantBufferByIndex,
3341 d3d10_effect_GetConstantBufferByName,
3342 d3d10_effect_GetVariableByIndex,
3343 d3d10_effect_GetVariableByName,
3344 d3d10_effect_GetVariableBySemantic,
3345 d3d10_effect_GetTechniqueByIndex,
3346 d3d10_effect_GetTechniqueByName,
3347 d3d10_effect_Optimize,
3348 d3d10_effect_IsOptimized,
3351 /* ID3D10EffectTechnique methods */
3353 static inline struct d3d10_effect_technique *impl_from_ID3D10EffectTechnique(ID3D10EffectTechnique *iface)
3355 return CONTAINING_RECORD(iface, struct d3d10_effect_technique, ID3D10EffectTechnique_iface);
3358 static BOOL STDMETHODCALLTYPE d3d10_effect_technique_IsValid(ID3D10EffectTechnique *iface)
3360 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3362 TRACE("iface %p\n", iface);
3364 return This != &null_technique;
3367 static HRESULT STDMETHODCALLTYPE d3d10_effect_technique_GetDesc(ID3D10EffectTechnique *iface,
3368 D3D10_TECHNIQUE_DESC *desc)
3370 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3372 TRACE("iface %p, desc %p\n", iface, desc);
3374 if(This == &null_technique)
3376 WARN("Null technique specified\n");
3377 return E_FAIL;
3380 if(!desc)
3382 WARN("Invalid argument specified\n");
3383 return E_INVALIDARG;
3386 desc->Name = This->name;
3387 desc->Passes = This->pass_count;
3388 desc->Annotations = This->annotation_count;
3390 return S_OK;
3393 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByIndex(
3394 ID3D10EffectTechnique *iface, UINT index)
3396 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3397 struct d3d10_effect_variable *a;
3399 TRACE("iface %p, index %u\n", iface, index);
3401 if (index >= This->annotation_count)
3403 WARN("Invalid index specified\n");
3404 return &null_variable.ID3D10EffectVariable_iface;
3407 a = &This->annotations[index];
3409 TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name));
3411 return &a->ID3D10EffectVariable_iface;
3414 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByName(
3415 ID3D10EffectTechnique *iface, const char *name)
3417 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3418 unsigned int i;
3420 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3422 for (i = 0; i < This->annotation_count; ++i)
3424 struct d3d10_effect_variable *a = &This->annotations[i];
3425 if (a->name && !strcmp(a->name, name))
3427 TRACE("Returning annotation %p\n", a);
3428 return &a->ID3D10EffectVariable_iface;
3432 WARN("Invalid name specified\n");
3434 return &null_variable.ID3D10EffectVariable_iface;
3437 static struct ID3D10EffectPass * STDMETHODCALLTYPE d3d10_effect_technique_GetPassByIndex(ID3D10EffectTechnique *iface,
3438 UINT index)
3440 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3441 struct d3d10_effect_pass *p;
3443 TRACE("iface %p, index %u\n", iface, index);
3445 if (index >= This->pass_count)
3447 WARN("Invalid index specified\n");
3448 return &null_pass.ID3D10EffectPass_iface;
3451 p = &This->passes[index];
3453 TRACE("Returning pass %p, %s.\n", p, debugstr_a(p->name));
3455 return &p->ID3D10EffectPass_iface;
3458 static struct ID3D10EffectPass * STDMETHODCALLTYPE d3d10_effect_technique_GetPassByName(ID3D10EffectTechnique *iface,
3459 const char *name)
3461 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3462 unsigned int i;
3464 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3466 /* Do not check for name==NULL, W7/DX10 crashes in that case. */
3468 for (i = 0; i < This->pass_count; ++i)
3470 struct d3d10_effect_pass *p = &This->passes[i];
3471 if (p->name && !strcmp(p->name, name))
3473 TRACE("Returning pass %p\n", p);
3474 return &p->ID3D10EffectPass_iface;
3478 WARN("Invalid name specified\n");
3480 return &null_pass.ID3D10EffectPass_iface;
3483 static HRESULT STDMETHODCALLTYPE d3d10_effect_technique_ComputeStateBlockMask(ID3D10EffectTechnique *iface,
3484 D3D10_STATE_BLOCK_MASK *mask)
3486 FIXME("iface %p,mask %p stub!\n", iface, mask);
3488 return E_NOTIMPL;
3491 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl =
3493 /* ID3D10EffectTechnique methods */
3494 d3d10_effect_technique_IsValid,
3495 d3d10_effect_technique_GetDesc,
3496 d3d10_effect_technique_GetAnnotationByIndex,
3497 d3d10_effect_technique_GetAnnotationByName,
3498 d3d10_effect_technique_GetPassByIndex,
3499 d3d10_effect_technique_GetPassByName,
3500 d3d10_effect_technique_ComputeStateBlockMask,
3503 /* ID3D10EffectPass methods */
3505 static inline struct d3d10_effect_pass *impl_from_ID3D10EffectPass(ID3D10EffectPass *iface)
3507 return CONTAINING_RECORD(iface, struct d3d10_effect_pass, ID3D10EffectPass_iface);
3510 static BOOL STDMETHODCALLTYPE d3d10_effect_pass_IsValid(ID3D10EffectPass *iface)
3512 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3514 TRACE("iface %p\n", iface);
3516 return This != &null_pass;
3519 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetDesc(ID3D10EffectPass *iface,
3520 D3D10_PASS_DESC *desc)
3522 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3523 struct d3d10_effect_shader_variable *s;
3525 FIXME("iface %p, desc %p partial stub!\n", iface, desc);
3527 if(This == &null_pass)
3529 WARN("Null pass specified\n");
3530 return E_FAIL;
3533 if(!desc)
3535 WARN("Invalid argument specified\n");
3536 return E_INVALIDARG;
3539 memset(desc, 0, sizeof(*desc));
3540 desc->Name = This->name;
3542 s = &impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)This->vs.pShaderVariable)->u.shader;
3543 desc->pIAInputSignature = (BYTE *)s->input_signature.signature;
3544 desc->IAInputSignatureSize = s->input_signature.signature_size;
3546 desc->StencilRef = This->stencil_ref;
3547 desc->SampleMask = This->sample_mask;
3548 memcpy(desc->BlendFactor, This->blend_factor, 4 * sizeof(float));
3550 return S_OK;
3553 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetVertexShaderDesc(ID3D10EffectPass *iface,
3554 D3D10_PASS_SHADER_DESC *desc)
3556 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3558 TRACE("iface %p, desc %p\n", iface, desc);
3560 if (This == &null_pass)
3562 WARN("Null pass specified\n");
3563 return E_FAIL;
3566 if (!desc)
3568 WARN("Invalid argument specified\n");
3569 return E_INVALIDARG;
3572 *desc = This->vs;
3574 return S_OK;
3577 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetGeometryShaderDesc(ID3D10EffectPass *iface,
3578 D3D10_PASS_SHADER_DESC *desc)
3580 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3582 TRACE("iface %p, desc %p\n", iface, desc);
3584 if (This == &null_pass)
3586 WARN("Null pass specified\n");
3587 return E_FAIL;
3590 if (!desc)
3592 WARN("Invalid argument specified\n");
3593 return E_INVALIDARG;
3596 *desc = This->gs;
3598 return S_OK;
3601 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetPixelShaderDesc(ID3D10EffectPass *iface,
3602 D3D10_PASS_SHADER_DESC *desc)
3604 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3606 TRACE("iface %p, desc %p\n", iface, desc);
3608 if (This == &null_pass)
3610 WARN("Null pass specified\n");
3611 return E_FAIL;
3614 if (!desc)
3616 WARN("Invalid argument specified\n");
3617 return E_INVALIDARG;
3620 *desc = This->ps;
3622 return S_OK;
3625 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByIndex(ID3D10EffectPass *iface,
3626 UINT index)
3628 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3629 struct d3d10_effect_variable *a;
3631 TRACE("iface %p, index %u\n", iface, index);
3633 if (index >= This->annotation_count)
3635 WARN("Invalid index specified\n");
3636 return &null_variable.ID3D10EffectVariable_iface;
3639 a = &This->annotations[index];
3641 TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name));
3643 return &a->ID3D10EffectVariable_iface;
3646 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByName(ID3D10EffectPass *iface,
3647 const char *name)
3649 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3650 unsigned int i;
3652 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3654 for (i = 0; i < This->annotation_count; ++i)
3656 struct d3d10_effect_variable *a = &This->annotations[i];
3657 if (a->name && !strcmp(a->name, name))
3659 TRACE("Returning annotation %p\n", a);
3660 return &a->ID3D10EffectVariable_iface;
3664 WARN("Invalid name specified\n");
3666 return &null_variable.ID3D10EffectVariable_iface;
3669 static void update_buffer(ID3D10Device *device, struct d3d10_effect_variable *v)
3671 struct d3d10_effect_buffer_variable *b = &v->u.buffer;
3673 if (!b->changed)
3674 return;
3676 ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)b->buffer, 0, NULL,
3677 b->local_buffer, v->data_size, 0);
3679 b->changed = FALSE;
3682 static void apply_shader_resources(ID3D10Device *device, struct ID3D10EffectShaderVariable *variable)
3684 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(variable);
3685 struct d3d10_effect_shader_variable *sv = &v->u.shader;
3686 struct d3d10_effect_shader_resource *sr;
3687 struct d3d10_effect_variable *rsrc_v;
3688 ID3D10ShaderResourceView **srv;
3689 unsigned int i;
3691 for (i = 0; i < sv->resource_count; ++i)
3693 sr = &sv->resources[i];
3694 rsrc_v = sr->variable;
3696 switch (sr->in_type)
3698 case D3D10_SIT_CBUFFER:
3699 update_buffer(device, rsrc_v);
3700 switch (v->type->basetype)
3702 case D3D10_SVT_VERTEXSHADER:
3703 ID3D10Device_VSSetConstantBuffers(device, sr->bind_point, sr->bind_count,
3704 &rsrc_v->u.buffer.buffer);
3705 break;
3707 case D3D10_SVT_PIXELSHADER:
3708 ID3D10Device_PSSetConstantBuffers(device, sr->bind_point, sr->bind_count,
3709 &rsrc_v->u.buffer.buffer);
3710 break;
3712 case D3D10_SVT_GEOMETRYSHADER:
3713 ID3D10Device_GSSetConstantBuffers(device, sr->bind_point, sr->bind_count,
3714 &rsrc_v->u.buffer.buffer);
3715 break;
3717 default:
3718 WARN("Incorrect shader type to bind constant buffer.\n");
3719 break;
3721 break;
3723 case D3D10_SIT_TBUFFER:
3724 case D3D10_SIT_TEXTURE:
3725 if (sr->in_type == D3D10_SIT_TBUFFER)
3727 update_buffer(device, rsrc_v);
3728 srv = &rsrc_v->u.buffer.resource_view;
3730 else
3731 srv = rsrc_v->u.resource.srv;
3733 switch (v->type->basetype)
3735 case D3D10_SVT_VERTEXSHADER:
3736 ID3D10Device_VSSetShaderResources(device, sr->bind_point, sr->bind_count, srv);
3737 break;
3739 case D3D10_SVT_PIXELSHADER:
3740 ID3D10Device_PSSetShaderResources(device, sr->bind_point, sr->bind_count, srv);
3741 break;
3743 case D3D10_SVT_GEOMETRYSHADER:
3744 ID3D10Device_GSSetShaderResources(device, sr->bind_point, sr->bind_count, srv);
3745 break;
3747 default:
3748 WARN("Incorrect shader type to bind shader resource view.\n");
3749 break;
3751 break;
3753 case D3D10_SIT_SAMPLER:
3754 switch (v->type->basetype)
3756 case D3D10_SVT_VERTEXSHADER:
3757 ID3D10Device_VSSetSamplers(device, sr->bind_point, sr->bind_count,
3758 &rsrc_v->u.state.object.sampler);
3759 break;
3761 case D3D10_SVT_PIXELSHADER:
3762 ID3D10Device_PSSetSamplers(device, sr->bind_point, sr->bind_count,
3763 &rsrc_v->u.state.object.sampler);
3764 break;
3766 case D3D10_SVT_GEOMETRYSHADER:
3767 ID3D10Device_GSSetSamplers(device, sr->bind_point, sr->bind_count,
3768 &rsrc_v->u.state.object.sampler);
3769 break;
3771 default:
3772 WARN("Incorrect shader type to bind sampler.\n");
3773 break;
3775 break;
3777 default:
3778 WARN("Unhandled shader resource %#x.\n", sr->in_type);
3779 break;
3784 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_Apply(ID3D10EffectPass *iface, UINT flags)
3786 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
3787 ID3D10Device *device = pass->technique->effect->device;
3788 HRESULT hr = S_OK;
3789 unsigned int i;
3791 TRACE("iface %p, flags %#x\n", iface, flags);
3793 if (flags) FIXME("Ignoring flags (%#x)\n", flags);
3795 if (pass->vs.pShaderVariable != (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface)
3796 apply_shader_resources(device, pass->vs.pShaderVariable);
3797 if (pass->gs.pShaderVariable != (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface)
3798 apply_shader_resources(device, pass->gs.pShaderVariable);
3799 if (pass->ps.pShaderVariable != (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface)
3800 apply_shader_resources(device, pass->ps.pShaderVariable);
3802 for (i = 0; i < pass->object_count; ++i)
3804 hr = d3d10_effect_object_apply(&pass->objects[i]);
3805 if (FAILED(hr)) break;
3808 return hr;
3811 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_ComputeStateBlockMask(ID3D10EffectPass *iface,
3812 D3D10_STATE_BLOCK_MASK *mask)
3814 FIXME("iface %p, mask %p stub!\n", iface, mask);
3816 return E_NOTIMPL;
3819 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl =
3821 /* ID3D10EffectPass methods */
3822 d3d10_effect_pass_IsValid,
3823 d3d10_effect_pass_GetDesc,
3824 d3d10_effect_pass_GetVertexShaderDesc,
3825 d3d10_effect_pass_GetGeometryShaderDesc,
3826 d3d10_effect_pass_GetPixelShaderDesc,
3827 d3d10_effect_pass_GetAnnotationByIndex,
3828 d3d10_effect_pass_GetAnnotationByName,
3829 d3d10_effect_pass_Apply,
3830 d3d10_effect_pass_ComputeStateBlockMask,
3833 /* ID3D10EffectVariable methods */
3835 static BOOL STDMETHODCALLTYPE d3d10_effect_variable_IsValid(ID3D10EffectVariable *iface)
3837 TRACE("iface %p\n", iface);
3839 return impl_from_ID3D10EffectVariable(iface) != &null_variable;
3842 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_variable_GetType(ID3D10EffectVariable *iface)
3844 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3846 TRACE("iface %p\n", iface);
3848 return &This->type->ID3D10EffectType_iface;
3851 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetDesc(ID3D10EffectVariable *iface,
3852 D3D10_EFFECT_VARIABLE_DESC *desc)
3854 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3856 TRACE("iface %p, desc %p\n", iface, desc);
3858 if (!iface->lpVtbl->IsValid(iface))
3860 WARN("Null variable specified\n");
3861 return E_FAIL;
3864 if (!desc)
3866 WARN("Invalid argument specified\n");
3867 return E_INVALIDARG;
3870 /* FIXME: This isn't correct. Anonymous shaders let desc->ExplicitBindPoint untouched, but normal shaders set it! */
3871 memset(desc, 0, sizeof(*desc));
3872 desc->Name = This->name;
3873 desc->Semantic = This->semantic;
3874 desc->Flags = This->flag;
3875 desc->Annotations = This->annotation_count;
3876 desc->BufferOffset = This->buffer_offset;
3878 if (This->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
3880 desc->ExplicitBindPoint = This->buffer_offset;
3883 return S_OK;
3886 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByIndex(
3887 ID3D10EffectVariable *iface, UINT index)
3889 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3890 struct d3d10_effect_variable *a;
3892 TRACE("iface %p, index %u\n", iface, index);
3894 if (index >= This->annotation_count)
3896 WARN("Invalid index specified\n");
3897 return &null_variable.ID3D10EffectVariable_iface;
3900 a = &This->annotations[index];
3902 TRACE("Returning annotation %p, %s\n", a, debugstr_a(a->name));
3904 return &a->ID3D10EffectVariable_iface;
3907 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByName(
3908 ID3D10EffectVariable *iface, const char *name)
3910 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3911 unsigned int i;
3913 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3915 for (i = 0; i < This->annotation_count; ++i)
3917 struct d3d10_effect_variable *a = &This->annotations[i];
3918 if (a->name && !strcmp(a->name, name))
3920 TRACE("Returning annotation %p\n", a);
3921 return &a->ID3D10EffectVariable_iface;
3925 WARN("Invalid name specified\n");
3927 return &null_variable.ID3D10EffectVariable_iface;
3930 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberByIndex(
3931 ID3D10EffectVariable *iface, UINT index)
3933 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3934 struct d3d10_effect_variable *m;
3936 TRACE("iface %p, index %u\n", iface, index);
3938 if (index >= This->type->member_count)
3940 WARN("Invalid index specified\n");
3941 return &null_variable.ID3D10EffectVariable_iface;
3944 m = &This->members[index];
3946 TRACE("Returning member %p, %s\n", m, debugstr_a(m->name));
3948 return &m->ID3D10EffectVariable_iface;
3951 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberByName(
3952 ID3D10EffectVariable *iface, const char *name)
3954 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3955 unsigned int i;
3957 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3959 if (!name)
3961 WARN("Invalid name specified\n");
3962 return &null_variable.ID3D10EffectVariable_iface;
3965 for (i = 0; i < This->type->member_count; ++i)
3967 struct d3d10_effect_variable *m = &This->members[i];
3969 if (m->name && !strcmp(m->name, name))
3971 TRACE("Returning member %p\n", m);
3972 return &m->ID3D10EffectVariable_iface;
3976 WARN("Invalid name specified\n");
3978 return &null_variable.ID3D10EffectVariable_iface;
3981 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberBySemantic(
3982 ID3D10EffectVariable *iface, const char *semantic)
3984 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
3985 unsigned int i;
3987 TRACE("iface %p, semantic %s.\n", iface, debugstr_a(semantic));
3989 if (!semantic)
3991 WARN("Invalid semantic specified\n");
3992 return &null_variable.ID3D10EffectVariable_iface;
3995 for (i = 0; i < This->type->member_count; ++i)
3997 struct d3d10_effect_variable *m = &This->members[i];
3999 if (m->semantic && !strcmp(m->semantic, semantic))
4001 TRACE("Returning member %p\n", m);
4002 return &m->ID3D10EffectVariable_iface;
4006 WARN("Invalid semantic specified\n");
4008 return &null_variable.ID3D10EffectVariable_iface;
4011 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetElement(
4012 ID3D10EffectVariable *iface, UINT index)
4014 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4015 struct d3d10_effect_variable *v;
4017 TRACE("iface %p, index %u\n", iface, index);
4019 if (index >= This->type->element_count)
4021 WARN("Invalid index specified\n");
4022 return &null_variable.ID3D10EffectVariable_iface;
4025 v = &This->elements[index];
4027 TRACE("Returning element %p, %s\n", v, debugstr_a(v->name));
4029 return &v->ID3D10EffectVariable_iface;
4032 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_variable_GetParentConstantBuffer(
4033 ID3D10EffectVariable *iface)
4035 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4037 TRACE("iface %p\n", iface);
4039 return (ID3D10EffectConstantBuffer *)&This->buffer->ID3D10EffectVariable_iface;
4042 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsScalar(
4043 ID3D10EffectVariable *iface)
4045 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4047 TRACE("iface %p\n", iface);
4049 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl)
4050 return (ID3D10EffectScalarVariable *)&This->ID3D10EffectVariable_iface;
4052 return (ID3D10EffectScalarVariable *)&null_scalar_variable.ID3D10EffectVariable_iface;
4055 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsVector(
4056 ID3D10EffectVariable *iface)
4058 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4060 TRACE("iface %p\n", iface);
4062 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl)
4063 return (ID3D10EffectVectorVariable *)&This->ID3D10EffectVariable_iface;
4065 return (ID3D10EffectVectorVariable *)&null_vector_variable.ID3D10EffectVariable_iface;
4068 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsMatrix(
4069 ID3D10EffectVariable *iface)
4071 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4073 TRACE("iface %p\n", iface);
4075 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl)
4076 return (ID3D10EffectMatrixVariable *)&This->ID3D10EffectVariable_iface;
4078 return (ID3D10EffectMatrixVariable *)&null_matrix_variable.ID3D10EffectVariable_iface;
4081 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsString(
4082 ID3D10EffectVariable *iface)
4084 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4086 TRACE("iface %p\n", iface);
4088 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl)
4089 return (ID3D10EffectStringVariable *)&This->ID3D10EffectVariable_iface;
4091 return (ID3D10EffectStringVariable *)&null_string_variable.ID3D10EffectVariable_iface;
4094 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsShaderResource(
4095 ID3D10EffectVariable *iface)
4097 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4099 TRACE("iface %p\n", iface);
4101 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl)
4102 return (ID3D10EffectShaderResourceVariable *)&This->ID3D10EffectVariable_iface;
4104 return (ID3D10EffectShaderResourceVariable *)&null_shader_resource_variable.ID3D10EffectVariable_iface;
4107 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsRenderTargetView(
4108 ID3D10EffectVariable *iface)
4110 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4112 TRACE("iface %p\n", iface);
4114 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl)
4115 return (ID3D10EffectRenderTargetViewVariable *)&This->ID3D10EffectVariable_iface;
4117 return (ID3D10EffectRenderTargetViewVariable *)&null_render_target_view_variable.ID3D10EffectVariable_iface;
4120 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsDepthStencilView(
4121 ID3D10EffectVariable *iface)
4123 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4125 TRACE("iface %p\n", iface);
4127 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl)
4128 return (ID3D10EffectDepthStencilViewVariable *)&This->ID3D10EffectVariable_iface;
4130 return (ID3D10EffectDepthStencilViewVariable *)&null_depth_stencil_view_variable.ID3D10EffectVariable_iface;
4133 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_variable_AsConstantBuffer(
4134 ID3D10EffectVariable *iface)
4136 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4138 TRACE("iface %p\n", iface);
4140 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl)
4141 return (ID3D10EffectConstantBuffer *)&This->ID3D10EffectVariable_iface;
4143 return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
4146 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsShader(
4147 ID3D10EffectVariable *iface)
4149 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4151 TRACE("iface %p\n", iface);
4153 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl)
4154 return (ID3D10EffectShaderVariable *)&This->ID3D10EffectVariable_iface;
4156 return (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
4159 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsBlend(ID3D10EffectVariable *iface)
4161 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4163 TRACE("iface %p\n", iface);
4165 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl)
4166 return (ID3D10EffectBlendVariable *)&This->ID3D10EffectVariable_iface;
4168 return (ID3D10EffectBlendVariable *)&null_blend_variable.ID3D10EffectVariable_iface;
4171 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsDepthStencil(
4172 ID3D10EffectVariable *iface)
4174 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4176 TRACE("iface %p\n", iface);
4178 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl)
4179 return (ID3D10EffectDepthStencilVariable *)&This->ID3D10EffectVariable_iface;
4181 return (ID3D10EffectDepthStencilVariable *)&null_depth_stencil_variable.ID3D10EffectVariable_iface;
4184 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsRasterizer(
4185 ID3D10EffectVariable *iface)
4187 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4189 TRACE("iface %p\n", iface);
4191 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl)
4192 return (ID3D10EffectRasterizerVariable *)&This->ID3D10EffectVariable_iface;
4194 return (ID3D10EffectRasterizerVariable *)&null_rasterizer_variable.ID3D10EffectVariable_iface;
4197 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsSampler(
4198 ID3D10EffectVariable *iface)
4200 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4202 TRACE("iface %p\n", iface);
4204 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl)
4205 return (ID3D10EffectSamplerVariable *)&This->ID3D10EffectVariable_iface;
4207 return (ID3D10EffectSamplerVariable *)&null_sampler_variable.ID3D10EffectVariable_iface;
4210 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_SetRawValue(ID3D10EffectVariable *iface,
4211 void *data, UINT offset, UINT count)
4213 FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
4215 return E_NOTIMPL;
4218 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetRawValue(ID3D10EffectVariable *iface,
4219 void *data, UINT offset, UINT count)
4221 FIXME("iface %p, data %p, offset %u, count %u stub!\n", iface, data, offset, count);
4223 return E_NOTIMPL;
4226 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl =
4228 /* ID3D10EffectVariable methods */
4229 d3d10_effect_variable_IsValid,
4230 d3d10_effect_variable_GetType,
4231 d3d10_effect_variable_GetDesc,
4232 d3d10_effect_variable_GetAnnotationByIndex,
4233 d3d10_effect_variable_GetAnnotationByName,
4234 d3d10_effect_variable_GetMemberByIndex,
4235 d3d10_effect_variable_GetMemberByName,
4236 d3d10_effect_variable_GetMemberBySemantic,
4237 d3d10_effect_variable_GetElement,
4238 d3d10_effect_variable_GetParentConstantBuffer,
4239 d3d10_effect_variable_AsScalar,
4240 d3d10_effect_variable_AsVector,
4241 d3d10_effect_variable_AsMatrix,
4242 d3d10_effect_variable_AsString,
4243 d3d10_effect_variable_AsShaderResource,
4244 d3d10_effect_variable_AsRenderTargetView,
4245 d3d10_effect_variable_AsDepthStencilView,
4246 d3d10_effect_variable_AsConstantBuffer,
4247 d3d10_effect_variable_AsShader,
4248 d3d10_effect_variable_AsBlend,
4249 d3d10_effect_variable_AsDepthStencil,
4250 d3d10_effect_variable_AsRasterizer,
4251 d3d10_effect_variable_AsSampler,
4252 d3d10_effect_variable_SetRawValue,
4253 d3d10_effect_variable_GetRawValue,
4256 /* ID3D10EffectVariable methods */
4257 static BOOL STDMETHODCALLTYPE d3d10_effect_constant_buffer_IsValid(ID3D10EffectConstantBuffer *iface)
4259 TRACE("iface %p\n", iface);
4261 return (struct d3d10_effect_variable *)iface != &null_local_buffer;
4264 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetType(ID3D10EffectConstantBuffer *iface)
4266 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
4269 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetDesc(ID3D10EffectConstantBuffer *iface,
4270 D3D10_EFFECT_VARIABLE_DESC *desc)
4272 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
4275 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetAnnotationByIndex(
4276 ID3D10EffectConstantBuffer *iface, UINT index)
4278 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
4281 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetAnnotationByName(
4282 ID3D10EffectConstantBuffer *iface, const char *name)
4284 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
4287 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberByIndex(
4288 ID3D10EffectConstantBuffer *iface, UINT index)
4290 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
4293 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberByName(
4294 ID3D10EffectConstantBuffer *iface, const char *name)
4296 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
4299 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberBySemantic(
4300 ID3D10EffectConstantBuffer *iface, const char *semantic)
4302 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
4305 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetElement(
4306 ID3D10EffectConstantBuffer *iface, UINT index)
4308 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
4311 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetParentConstantBuffer(
4312 ID3D10EffectConstantBuffer *iface)
4314 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
4317 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsScalar(
4318 ID3D10EffectConstantBuffer *iface)
4320 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
4323 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsVector(
4324 ID3D10EffectConstantBuffer *iface)
4326 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
4329 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsMatrix(
4330 ID3D10EffectConstantBuffer *iface)
4332 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
4335 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsString(
4336 ID3D10EffectConstantBuffer *iface)
4338 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
4341 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsShaderResource(
4342 ID3D10EffectConstantBuffer *iface)
4344 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
4347 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsRenderTargetView(
4348 ID3D10EffectConstantBuffer *iface)
4350 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
4353 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsDepthStencilView(
4354 ID3D10EffectConstantBuffer *iface)
4356 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
4359 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsConstantBuffer(
4360 ID3D10EffectConstantBuffer *iface)
4362 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
4365 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsShader(
4366 ID3D10EffectConstantBuffer *iface)
4368 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
4371 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsBlend(ID3D10EffectConstantBuffer *iface)
4373 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
4376 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsDepthStencil(
4377 ID3D10EffectConstantBuffer *iface)
4379 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
4382 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsRasterizer(
4383 ID3D10EffectConstantBuffer *iface)
4385 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
4388 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsSampler(
4389 ID3D10EffectConstantBuffer *iface)
4391 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
4394 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetRawValue(ID3D10EffectConstantBuffer *iface,
4395 void *data, UINT offset, UINT count)
4397 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4400 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetRawValue(ID3D10EffectConstantBuffer *iface,
4401 void *data, UINT offset, UINT count)
4403 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4406 /* ID3D10EffectConstantBuffer methods */
4407 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetConstantBuffer(ID3D10EffectConstantBuffer *iface,
4408 ID3D10Buffer *buffer)
4410 FIXME("iface %p, buffer %p stub!\n", iface, buffer);
4412 return E_NOTIMPL;
4415 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetConstantBuffer(ID3D10EffectConstantBuffer *iface,
4416 ID3D10Buffer **buffer)
4418 FIXME("iface %p, buffer %p stub!\n", iface, buffer);
4420 return E_NOTIMPL;
4423 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetTextureBuffer(ID3D10EffectConstantBuffer *iface,
4424 ID3D10ShaderResourceView *view)
4426 FIXME("iface %p, view %p stub!\n", iface, view);
4428 return E_NOTIMPL;
4431 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetTextureBuffer(ID3D10EffectConstantBuffer *iface,
4432 ID3D10ShaderResourceView **view)
4434 FIXME("iface %p, view %p stub!\n", iface, view);
4436 return E_NOTIMPL;
4439 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl =
4441 /* ID3D10EffectVariable methods */
4442 d3d10_effect_constant_buffer_IsValid,
4443 d3d10_effect_constant_buffer_GetType,
4444 d3d10_effect_constant_buffer_GetDesc,
4445 d3d10_effect_constant_buffer_GetAnnotationByIndex,
4446 d3d10_effect_constant_buffer_GetAnnotationByName,
4447 d3d10_effect_constant_buffer_GetMemberByIndex,
4448 d3d10_effect_constant_buffer_GetMemberByName,
4449 d3d10_effect_constant_buffer_GetMemberBySemantic,
4450 d3d10_effect_constant_buffer_GetElement,
4451 d3d10_effect_constant_buffer_GetParentConstantBuffer,
4452 d3d10_effect_constant_buffer_AsScalar,
4453 d3d10_effect_constant_buffer_AsVector,
4454 d3d10_effect_constant_buffer_AsMatrix,
4455 d3d10_effect_constant_buffer_AsString,
4456 d3d10_effect_constant_buffer_AsShaderResource,
4457 d3d10_effect_constant_buffer_AsRenderTargetView,
4458 d3d10_effect_constant_buffer_AsDepthStencilView,
4459 d3d10_effect_constant_buffer_AsConstantBuffer,
4460 d3d10_effect_constant_buffer_AsShader,
4461 d3d10_effect_constant_buffer_AsBlend,
4462 d3d10_effect_constant_buffer_AsDepthStencil,
4463 d3d10_effect_constant_buffer_AsRasterizer,
4464 d3d10_effect_constant_buffer_AsSampler,
4465 d3d10_effect_constant_buffer_SetRawValue,
4466 d3d10_effect_constant_buffer_GetRawValue,
4467 /* ID3D10EffectConstantBuffer methods */
4468 d3d10_effect_constant_buffer_SetConstantBuffer,
4469 d3d10_effect_constant_buffer_GetConstantBuffer,
4470 d3d10_effect_constant_buffer_SetTextureBuffer,
4471 d3d10_effect_constant_buffer_GetTextureBuffer,
4475 static BOOL get_value_as_bool(void *src_data, D3D10_SHADER_VARIABLE_TYPE src_type)
4477 switch (src_type)
4479 case D3D10_SVT_FLOAT:
4480 case D3D10_SVT_INT:
4481 case D3D10_SVT_BOOL:
4482 if (*(DWORD *)src_data)
4483 return -1;
4484 break;
4486 default:
4487 break;
4490 return 0;
4493 static int get_value_as_int(void *src_data, D3D10_SHADER_VARIABLE_TYPE src_type)
4495 switch (src_type)
4497 case D3D10_SVT_FLOAT:
4498 return (int)(*(float *)src_data);
4500 case D3D10_SVT_INT:
4501 return *(int *)src_data;
4503 case D3D10_SVT_BOOL:
4504 return get_value_as_bool(src_data, src_type);
4506 default:
4507 return 0;
4511 static float get_value_as_float(void *src_data, D3D10_SHADER_VARIABLE_TYPE src_type)
4513 switch (src_type)
4515 case D3D10_SVT_FLOAT:
4516 return *(float *)src_data;
4518 case D3D10_SVT_INT:
4519 return (float)(*(int *)src_data);
4521 case D3D10_SVT_BOOL:
4522 return (float)get_value_as_bool(src_data, src_type);
4524 default:
4525 return 0.0f;
4529 static void get_vector_as_type(BYTE *dst_data, D3D_SHADER_VARIABLE_TYPE dst_type,
4530 BYTE *src_data, D3D_SHADER_VARIABLE_TYPE src_type, unsigned int count)
4532 DWORD *src_data_dword = (DWORD *)src_data;
4533 DWORD *dst_data_dword = (DWORD *)dst_data;
4534 unsigned int i;
4536 for (i = 0; i < count; ++i, ++dst_data_dword, ++src_data_dword)
4538 if (dst_type == src_type)
4539 *dst_data_dword = *src_data_dword;
4540 else
4542 switch (dst_type)
4544 case D3D10_SVT_FLOAT:
4545 *(float *)dst_data_dword = get_value_as_float(src_data_dword, src_type);
4546 break;
4548 case D3D10_SVT_INT:
4549 *(int *)dst_data_dword = get_value_as_int(src_data_dword, src_type);
4550 break;
4552 case D3D10_SVT_BOOL:
4553 *(BOOL *)dst_data_dword = get_value_as_bool(src_data_dword, src_type);
4554 break;
4556 default:
4557 *dst_data_dword = 0;
4558 break;
4564 static void write_variable_to_buffer(struct d3d10_effect_variable *variable, void *src,
4565 D3D_SHADER_VARIABLE_TYPE src_type)
4567 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4568 D3D_SHADER_VARIABLE_TYPE dst_type = variable->type->basetype;
4570 get_vector_as_type(dst, dst_type, src, src_type, variable->type->column_count);
4572 variable->buffer->u.buffer.changed = TRUE;
4575 static void write_variable_array_to_buffer(struct d3d10_effect_variable *variable, void *src,
4576 D3D_SHADER_VARIABLE_TYPE src_type, unsigned int offset, unsigned int count)
4578 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4579 D3D_SHADER_VARIABLE_TYPE dst_type = variable->type->basetype;
4580 unsigned int element_size, i;
4581 BYTE *cur_element = src;
4583 if (!variable->type->element_count)
4585 write_variable_to_buffer(variable, src, src_type);
4586 return;
4589 if (offset >= variable->type->element_count)
4591 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
4592 return;
4595 if (count > variable->type->element_count - offset)
4597 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
4598 offset, count, variable->type->element_count);
4599 count = variable->type->element_count - offset;
4602 element_size = variable->type->elementtype->size_packed;
4603 dst += variable->type->stride * offset;
4605 for (i = 0; i < count; ++i)
4607 get_vector_as_type(dst, dst_type, cur_element, src_type, variable->type->column_count);
4609 cur_element += element_size;
4610 dst += variable->type->stride;
4613 variable->buffer->u.buffer.changed = TRUE;
4616 static void read_variable_from_buffer(struct d3d10_effect_variable *variable, void *dst,
4617 D3D_SHADER_VARIABLE_TYPE dst_type)
4619 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4620 D3D_SHADER_VARIABLE_TYPE src_type = variable->type->basetype;
4622 get_vector_as_type(dst, dst_type, src, src_type, variable->type->column_count);
4625 static void read_variable_array_from_buffer(struct d3d10_effect_variable *variable, void *dst,
4626 D3D_SHADER_VARIABLE_TYPE dst_type, unsigned int offset, unsigned int count)
4628 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4629 D3D_SHADER_VARIABLE_TYPE src_type = variable->type->basetype;
4630 unsigned int element_size, i;
4631 BYTE *cur_element = dst;
4633 if (!variable->type->element_count)
4635 read_variable_from_buffer(variable, dst, dst_type);
4636 return;
4639 if (offset >= variable->type->element_count)
4641 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
4642 return;
4645 if (count > variable->type->element_count - offset)
4647 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
4648 offset, count, variable->type->element_count);
4649 count = variable->type->element_count - offset;
4652 element_size = variable->type->elementtype->size_packed;
4653 src += variable->type->stride * offset;
4655 for (i = 0; i < count; ++i)
4657 get_vector_as_type(cur_element, dst_type, src, src_type, variable->type->column_count);
4659 cur_element += element_size;
4660 src += variable->type->stride;
4664 /* ID3D10EffectVariable methods */
4666 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectScalarVariable(ID3D10EffectScalarVariable *iface)
4668 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
4671 static BOOL STDMETHODCALLTYPE d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable *iface)
4673 TRACE("iface %p\n", iface);
4675 return (struct d3d10_effect_variable *)iface != &null_scalar_variable;
4678 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetType(
4679 ID3D10EffectScalarVariable *iface)
4681 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
4684 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetDesc(ID3D10EffectScalarVariable *iface,
4685 D3D10_EFFECT_VARIABLE_DESC *desc)
4687 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
4690 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetAnnotationByIndex(
4691 ID3D10EffectScalarVariable *iface, UINT index)
4693 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
4696 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetAnnotationByName(
4697 ID3D10EffectScalarVariable *iface, const char *name)
4699 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
4702 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberByIndex(
4703 ID3D10EffectScalarVariable *iface, UINT index)
4705 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
4708 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberByName(
4709 ID3D10EffectScalarVariable *iface, const char *name)
4711 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
4714 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberBySemantic(
4715 ID3D10EffectScalarVariable *iface, const char *semantic)
4717 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
4720 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetElement(
4721 ID3D10EffectScalarVariable *iface, UINT index)
4723 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
4726 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetParentConstantBuffer(
4727 ID3D10EffectScalarVariable *iface)
4729 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
4732 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsScalar(
4733 ID3D10EffectScalarVariable *iface)
4735 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
4738 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsVector(
4739 ID3D10EffectScalarVariable *iface)
4741 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
4744 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsMatrix(
4745 ID3D10EffectScalarVariable *iface)
4747 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
4750 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsString(
4751 ID3D10EffectScalarVariable *iface)
4753 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
4756 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsShaderResource(
4757 ID3D10EffectScalarVariable *iface)
4759 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
4762 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsRenderTargetView(
4763 ID3D10EffectScalarVariable *iface)
4765 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
4768 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsDepthStencilView(
4769 ID3D10EffectScalarVariable *iface)
4771 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
4774 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsConstantBuffer(
4775 ID3D10EffectScalarVariable *iface)
4777 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
4780 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsShader(
4781 ID3D10EffectScalarVariable *iface)
4783 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
4786 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsBlend(
4787 ID3D10EffectScalarVariable *iface)
4789 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
4792 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsDepthStencil(
4793 ID3D10EffectScalarVariable *iface)
4795 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
4798 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsRasterizer(
4799 ID3D10EffectScalarVariable *iface)
4801 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
4804 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsSampler(
4805 ID3D10EffectScalarVariable *iface)
4807 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
4810 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetRawValue(ID3D10EffectScalarVariable *iface,
4811 void *data, UINT offset, UINT count)
4813 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4816 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetRawValue(ID3D10EffectScalarVariable *iface,
4817 void *data, UINT offset, UINT count)
4819 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4822 /* ID3D10EffectScalarVariable methods */
4824 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloat(ID3D10EffectScalarVariable *iface,
4825 float value)
4827 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4829 TRACE("iface %p, value %.8e.\n", iface, value);
4830 write_variable_to_buffer(effect_var, &value, D3D10_SVT_FLOAT);
4832 return S_OK;
4835 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable *iface,
4836 float *value)
4838 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4840 TRACE("iface %p, value %p.\n", iface, value);
4841 read_variable_from_buffer(effect_var, value, D3D10_SVT_FLOAT);
4843 return S_OK;
4846 /* Tests show that offset is ignored for scalar variables. */
4847 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloatArray(ID3D10EffectScalarVariable *iface,
4848 float *values, UINT offset, UINT count)
4850 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4852 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4853 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_FLOAT, 0, count);
4855 return S_OK;
4858 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable *iface,
4859 float *values, UINT offset, UINT count)
4861 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4863 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4864 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_FLOAT, 0, count);
4866 return S_OK;
4869 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable *iface,
4870 int value)
4872 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4874 TRACE("iface %p, value %d.\n", iface, value);
4875 write_variable_to_buffer(effect_var, &value, D3D10_SVT_INT);
4877 return S_OK;
4880 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetInt(ID3D10EffectScalarVariable *iface,
4881 int *value)
4883 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4885 TRACE("iface %p, value %p.\n", iface, value);
4886 read_variable_from_buffer(effect_var, value, D3D10_SVT_INT);
4888 return S_OK;
4891 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable *iface,
4892 int *values, UINT offset, UINT count)
4894 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4896 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4897 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_INT, 0, count);
4899 return S_OK;
4902 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable *iface,
4903 int *values, UINT offset, UINT count)
4905 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4907 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4908 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_INT, 0, count);
4910 return S_OK;
4913 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable *iface,
4914 BOOL value)
4916 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4918 TRACE("iface %p, value %d.\n", iface, value);
4919 write_variable_to_buffer(effect_var, &value, D3D10_SVT_BOOL);
4921 return S_OK;
4924 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBool(ID3D10EffectScalarVariable *iface,
4925 BOOL *value)
4927 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4929 TRACE("iface %p, value %p.\n", iface, value);
4930 read_variable_from_buffer(effect_var, value, D3D10_SVT_BOOL);
4932 return S_OK;
4935 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable *iface,
4936 BOOL *values, UINT offset, UINT count)
4938 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4940 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4941 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_BOOL, 0, count);
4943 return S_OK;
4946 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable *iface,
4947 BOOL *values, UINT offset, UINT count)
4949 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
4951 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
4952 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_BOOL, 0, count);
4954 return S_OK;
4957 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl =
4959 /* ID3D10EffectVariable methods */
4960 d3d10_effect_scalar_variable_IsValid,
4961 d3d10_effect_scalar_variable_GetType,
4962 d3d10_effect_scalar_variable_GetDesc,
4963 d3d10_effect_scalar_variable_GetAnnotationByIndex,
4964 d3d10_effect_scalar_variable_GetAnnotationByName,
4965 d3d10_effect_scalar_variable_GetMemberByIndex,
4966 d3d10_effect_scalar_variable_GetMemberByName,
4967 d3d10_effect_scalar_variable_GetMemberBySemantic,
4968 d3d10_effect_scalar_variable_GetElement,
4969 d3d10_effect_scalar_variable_GetParentConstantBuffer,
4970 d3d10_effect_scalar_variable_AsScalar,
4971 d3d10_effect_scalar_variable_AsVector,
4972 d3d10_effect_scalar_variable_AsMatrix,
4973 d3d10_effect_scalar_variable_AsString,
4974 d3d10_effect_scalar_variable_AsShaderResource,
4975 d3d10_effect_scalar_variable_AsRenderTargetView,
4976 d3d10_effect_scalar_variable_AsDepthStencilView,
4977 d3d10_effect_scalar_variable_AsConstantBuffer,
4978 d3d10_effect_scalar_variable_AsShader,
4979 d3d10_effect_scalar_variable_AsBlend,
4980 d3d10_effect_scalar_variable_AsDepthStencil,
4981 d3d10_effect_scalar_variable_AsRasterizer,
4982 d3d10_effect_scalar_variable_AsSampler,
4983 d3d10_effect_scalar_variable_SetRawValue,
4984 d3d10_effect_scalar_variable_GetRawValue,
4985 /* ID3D10EffectScalarVariable methods */
4986 d3d10_effect_scalar_variable_SetFloat,
4987 d3d10_effect_scalar_variable_GetFloat,
4988 d3d10_effect_scalar_variable_SetFloatArray,
4989 d3d10_effect_scalar_variable_GetFloatArray,
4990 d3d10_effect_scalar_variable_SetInt,
4991 d3d10_effect_scalar_variable_GetInt,
4992 d3d10_effect_scalar_variable_SetIntArray,
4993 d3d10_effect_scalar_variable_GetIntArray,
4994 d3d10_effect_scalar_variable_SetBool,
4995 d3d10_effect_scalar_variable_GetBool,
4996 d3d10_effect_scalar_variable_SetBoolArray,
4997 d3d10_effect_scalar_variable_GetBoolArray,
5000 /* ID3D10EffectVariable methods */
5002 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectVectorVariable(ID3D10EffectVectorVariable *iface)
5004 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
5007 static BOOL STDMETHODCALLTYPE d3d10_effect_vector_variable_IsValid(ID3D10EffectVectorVariable *iface)
5009 TRACE("iface %p\n", iface);
5011 return (struct d3d10_effect_variable *)iface != &null_vector_variable;
5014 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetType(
5015 ID3D10EffectVectorVariable *iface)
5017 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5020 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetDesc(ID3D10EffectVectorVariable *iface,
5021 D3D10_EFFECT_VARIABLE_DESC *desc)
5023 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5026 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetAnnotationByIndex(
5027 ID3D10EffectVectorVariable *iface, UINT index)
5029 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5032 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetAnnotationByName(
5033 ID3D10EffectVectorVariable *iface, const char *name)
5035 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5038 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberByIndex(
5039 ID3D10EffectVectorVariable *iface, UINT index)
5041 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5044 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberByName(
5045 ID3D10EffectVectorVariable *iface, const char *name)
5047 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5050 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberBySemantic(
5051 ID3D10EffectVectorVariable *iface, const char *semantic)
5053 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5056 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetElement(
5057 ID3D10EffectVectorVariable *iface, UINT index)
5059 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5062 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetParentConstantBuffer(
5063 ID3D10EffectVectorVariable *iface)
5065 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5068 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsScalar(
5069 ID3D10EffectVectorVariable *iface)
5071 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5074 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsVector(
5075 ID3D10EffectVectorVariable *iface)
5077 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5080 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsMatrix(
5081 ID3D10EffectVectorVariable *iface)
5083 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5086 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsString(
5087 ID3D10EffectVectorVariable *iface)
5089 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5092 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsShaderResource(
5093 ID3D10EffectVectorVariable *iface)
5095 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5098 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsRenderTargetView(
5099 ID3D10EffectVectorVariable *iface)
5101 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5104 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsDepthStencilView(
5105 ID3D10EffectVectorVariable *iface)
5107 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5110 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsConstantBuffer(
5111 ID3D10EffectVectorVariable *iface)
5113 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5116 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsShader(
5117 ID3D10EffectVectorVariable *iface)
5119 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5122 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsBlend(
5123 ID3D10EffectVectorVariable *iface)
5125 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5128 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsDepthStencil(
5129 ID3D10EffectVectorVariable *iface)
5131 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5134 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsRasterizer(
5135 ID3D10EffectVectorVariable *iface)
5137 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5140 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsSampler(
5141 ID3D10EffectVectorVariable *iface)
5143 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5146 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetRawValue(ID3D10EffectVectorVariable *iface,
5147 void *data, UINT offset, UINT count)
5149 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5152 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetRawValue(ID3D10EffectVectorVariable *iface,
5153 void *data, UINT offset, UINT count)
5155 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5158 /* ID3D10EffectVectorVariable methods */
5160 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVector(ID3D10EffectVectorVariable *iface,
5161 BOOL *value)
5163 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5165 TRACE("iface %p, value %p.\n", iface, value);
5166 write_variable_to_buffer(effect_var, value, D3D10_SVT_BOOL);
5168 return S_OK;
5171 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVector(ID3D10EffectVectorVariable *iface,
5172 int *value)
5174 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5176 TRACE("iface %p, value %p.\n", iface, value);
5177 write_variable_to_buffer(effect_var, value, D3D10_SVT_INT);
5179 return S_OK;
5182 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVector(ID3D10EffectVectorVariable *iface,
5183 float *value)
5185 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5187 TRACE("iface %p, value %p.\n", iface, value);
5188 write_variable_to_buffer(effect_var, value, D3D10_SVT_FLOAT);
5190 return S_OK;
5193 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable *iface,
5194 BOOL *value)
5196 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5198 TRACE("iface %p, value %p.\n", iface, value);
5199 read_variable_from_buffer(effect_var, value, D3D10_SVT_BOOL);
5201 return S_OK;
5204 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVector(ID3D10EffectVectorVariable *iface,
5205 int *value)
5207 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5209 TRACE("iface %p, value %p.\n", iface, value);
5210 read_variable_from_buffer(effect_var, value, D3D10_SVT_INT);
5212 return S_OK;
5215 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVector(ID3D10EffectVectorVariable *iface,
5216 float *value)
5218 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5220 TRACE("iface %p, value %p.\n", iface, value);
5221 read_variable_from_buffer(effect_var, value, D3D10_SVT_FLOAT);
5223 return S_OK;
5226 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable *iface,
5227 BOOL *values, UINT offset, UINT count)
5229 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5231 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5232 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_BOOL, offset, count);
5234 return S_OK;
5237 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVectorArray(ID3D10EffectVectorVariable *iface,
5238 int *values, UINT offset, UINT count)
5240 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5242 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5243 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_INT, offset, count);
5245 return S_OK;
5248 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVectorArray(ID3D10EffectVectorVariable *iface,
5249 float *values, UINT offset, UINT count)
5251 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5253 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5254 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_FLOAT, offset, count);
5256 return S_OK;
5259 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVectorArray(ID3D10EffectVectorVariable *iface,
5260 BOOL *values, UINT offset, UINT count)
5262 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5264 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5265 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_BOOL, offset, count);
5267 return S_OK;
5270 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVectorArray(ID3D10EffectVectorVariable *iface,
5271 int *values, UINT offset, UINT count)
5273 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5275 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5276 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_INT, offset, count);
5278 return S_OK;
5281 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVectorArray(ID3D10EffectVectorVariable *iface,
5282 float *values, UINT offset, UINT count)
5284 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5286 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5287 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_FLOAT, offset, count);
5289 return S_OK;
5292 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl =
5294 /* ID3D10EffectVariable methods */
5295 d3d10_effect_vector_variable_IsValid,
5296 d3d10_effect_vector_variable_GetType,
5297 d3d10_effect_vector_variable_GetDesc,
5298 d3d10_effect_vector_variable_GetAnnotationByIndex,
5299 d3d10_effect_vector_variable_GetAnnotationByName,
5300 d3d10_effect_vector_variable_GetMemberByIndex,
5301 d3d10_effect_vector_variable_GetMemberByName,
5302 d3d10_effect_vector_variable_GetMemberBySemantic,
5303 d3d10_effect_vector_variable_GetElement,
5304 d3d10_effect_vector_variable_GetParentConstantBuffer,
5305 d3d10_effect_vector_variable_AsScalar,
5306 d3d10_effect_vector_variable_AsVector,
5307 d3d10_effect_vector_variable_AsMatrix,
5308 d3d10_effect_vector_variable_AsString,
5309 d3d10_effect_vector_variable_AsShaderResource,
5310 d3d10_effect_vector_variable_AsRenderTargetView,
5311 d3d10_effect_vector_variable_AsDepthStencilView,
5312 d3d10_effect_vector_variable_AsConstantBuffer,
5313 d3d10_effect_vector_variable_AsShader,
5314 d3d10_effect_vector_variable_AsBlend,
5315 d3d10_effect_vector_variable_AsDepthStencil,
5316 d3d10_effect_vector_variable_AsRasterizer,
5317 d3d10_effect_vector_variable_AsSampler,
5318 d3d10_effect_vector_variable_SetRawValue,
5319 d3d10_effect_vector_variable_GetRawValue,
5320 /* ID3D10EffectVectorVariable methods */
5321 d3d10_effect_vector_variable_SetBoolVector,
5322 d3d10_effect_vector_variable_SetIntVector,
5323 d3d10_effect_vector_variable_SetFloatVector,
5324 d3d10_effect_vector_variable_GetBoolVector,
5325 d3d10_effect_vector_variable_GetIntVector,
5326 d3d10_effect_vector_variable_GetFloatVector,
5327 d3d10_effect_vector_variable_SetBoolVectorArray,
5328 d3d10_effect_vector_variable_SetIntVectorArray,
5329 d3d10_effect_vector_variable_SetFloatVectorArray,
5330 d3d10_effect_vector_variable_GetBoolVectorArray,
5331 d3d10_effect_vector_variable_GetIntVectorArray,
5332 d3d10_effect_vector_variable_GetFloatVectorArray,
5335 static void write_matrix_to_buffer(struct d3d10_effect_variable *variable, void *dst_void,
5336 struct d3d10_matrix *src, BOOL transpose)
5338 unsigned int col_count = !transpose ? variable->type->column_count : variable->type->row_count;
5339 unsigned int row_count = !transpose ? variable->type->row_count : variable->type->column_count;
5340 BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS;
5341 float *dst = dst_void;
5342 unsigned int row, col;
5344 if (transpose)
5345 major = !major;
5347 if (major)
5349 for (col = 0; col < col_count; ++col)
5351 for (row = 0; row < row_count; ++row)
5352 dst[(col * 4) + row] = src->m[row][col];
5355 else
5357 for (row = 0; row < row_count; ++row)
5359 for (col = 0; col < col_count; ++col)
5360 dst[(row * 4) + col] = src->m[row][col];
5365 static void write_matrix_variable_to_buffer(struct d3d10_effect_variable *variable, void *src_data, BOOL transpose)
5367 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5369 write_matrix_to_buffer(variable, dst, src_data, transpose);
5371 variable->buffer->u.buffer.changed = TRUE;
5374 static void write_matrix_variable_array_to_buffer(struct d3d10_effect_variable *variable, void *src_data,
5375 unsigned int offset, unsigned int count, BOOL transpose)
5377 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5378 struct d3d10_matrix *src = src_data;
5379 unsigned int i;
5381 if (!variable->type->element_count)
5383 write_matrix_variable_to_buffer(variable, src_data, transpose);
5384 return;
5387 if (offset >= variable->type->element_count)
5389 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
5390 return;
5393 if (count > variable->type->element_count - offset)
5395 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
5396 offset, count, variable->type->element_count);
5397 count = variable->type->element_count - offset;
5400 if (offset)
5401 dst += variable->type->stride * offset;
5403 for (i = 0; i < count; ++i)
5405 write_matrix_to_buffer(variable, dst, &src[i], transpose);
5407 dst += variable->type->stride;
5410 variable->buffer->u.buffer.changed = TRUE;
5413 static void read_matrix_from_buffer(struct d3d10_effect_variable *variable, void *src_void,
5414 struct d3d10_matrix *dst, BOOL transpose)
5416 unsigned int col_count = !transpose ? variable->type->column_count : variable->type->row_count;
5417 unsigned int row_count = !transpose ? variable->type->row_count : variable->type->column_count;
5418 BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS;
5419 float *src = src_void;
5420 unsigned int row, col;
5422 if (transpose)
5423 major = !major;
5425 if (major)
5427 for (col = 0; col < col_count; ++col)
5429 for (row = 0; row < row_count; ++row)
5430 dst->m[row][col] = src[(col * 4) + row];
5433 else
5435 for (row = 0; row < row_count; ++row)
5437 for (col = 0; col < col_count; ++col)
5438 dst->m[row][col] = src[(row * 4) + col];
5443 static void read_matrix_variable_from_buffer(struct d3d10_effect_variable *variable, void *dst, BOOL transpose)
5445 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5447 read_matrix_from_buffer(variable, src, dst, transpose);
5450 static void read_matrix_variable_array_from_buffer(struct d3d10_effect_variable *variable, void *dst_data, UINT offset,
5451 UINT count, BOOL transpose)
5453 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5454 struct d3d10_matrix *dst = dst_data;
5455 unsigned int i;
5457 if (!variable->type->element_count)
5459 read_matrix_variable_from_buffer(variable, dst_data, transpose);
5460 return;
5463 if (offset >= variable->type->element_count)
5465 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
5466 return;
5469 if (count > variable->type->element_count - offset)
5471 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
5472 offset, count, variable->type->element_count);
5473 count = variable->type->element_count - offset;
5476 if (offset)
5477 src += variable->type->stride * offset;
5479 for (i = 0; i < count; ++i)
5481 read_matrix_from_buffer(variable, src, &dst[i], transpose);
5483 src += variable->type->stride;
5487 /* ID3D10EffectVariable methods */
5489 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectMatrixVariable(ID3D10EffectMatrixVariable *iface)
5491 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
5494 static BOOL STDMETHODCALLTYPE d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable *iface)
5496 TRACE("iface %p\n", iface);
5498 return (struct d3d10_effect_variable *)iface != &null_matrix_variable;
5501 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetType(
5502 ID3D10EffectMatrixVariable *iface)
5504 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5507 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetDesc(ID3D10EffectMatrixVariable *iface,
5508 D3D10_EFFECT_VARIABLE_DESC *desc)
5510 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5513 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetAnnotationByIndex(
5514 ID3D10EffectMatrixVariable *iface, UINT index)
5516 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5519 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetAnnotationByName(
5520 ID3D10EffectMatrixVariable *iface, const char *name)
5522 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5525 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberByIndex(
5526 ID3D10EffectMatrixVariable *iface, UINT index)
5528 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5531 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberByName(
5532 ID3D10EffectMatrixVariable *iface, const char *name)
5534 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5537 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberBySemantic(
5538 ID3D10EffectMatrixVariable *iface, const char *semantic)
5540 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5543 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetElement(
5544 ID3D10EffectMatrixVariable *iface, UINT index)
5546 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5549 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetParentConstantBuffer(
5550 ID3D10EffectMatrixVariable *iface)
5552 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5555 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsScalar(
5556 ID3D10EffectMatrixVariable *iface)
5558 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5561 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsVector(
5562 ID3D10EffectMatrixVariable *iface)
5564 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5567 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsMatrix(
5568 ID3D10EffectMatrixVariable *iface)
5570 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5573 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsString(
5574 ID3D10EffectMatrixVariable *iface)
5576 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5579 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsShaderResource(
5580 ID3D10EffectMatrixVariable *iface)
5582 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5585 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsRenderTargetView(
5586 ID3D10EffectMatrixVariable *iface)
5588 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5591 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsDepthStencilView(
5592 ID3D10EffectMatrixVariable *iface)
5594 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5597 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsConstantBuffer(
5598 ID3D10EffectMatrixVariable *iface)
5600 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5603 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsShader(
5604 ID3D10EffectMatrixVariable *iface)
5606 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5609 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsBlend(
5610 ID3D10EffectMatrixVariable *iface)
5612 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5615 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsDepthStencil(
5616 ID3D10EffectMatrixVariable *iface)
5618 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5621 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsRasterizer(
5622 ID3D10EffectMatrixVariable *iface)
5624 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5627 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsSampler(
5628 ID3D10EffectMatrixVariable *iface)
5630 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5633 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetRawValue(ID3D10EffectMatrixVariable *iface,
5634 void *data, UINT offset, UINT count)
5636 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5639 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetRawValue(ID3D10EffectMatrixVariable *iface,
5640 void *data, UINT offset, UINT count)
5642 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5645 /* ID3D10EffectMatrixVariable methods */
5647 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrix(ID3D10EffectMatrixVariable *iface,
5648 float *data)
5650 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5652 TRACE("iface %p, data %p.\n", iface, data);
5653 write_matrix_variable_to_buffer(var, data, FALSE);
5655 return S_OK;
5658 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable *iface,
5659 float *data)
5661 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5663 TRACE("iface %p, data %p.\n", iface, data);
5664 read_matrix_variable_from_buffer(var, data, FALSE);
5666 return S_OK;
5669 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable *iface,
5670 float *data, UINT offset, UINT count)
5672 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5674 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
5675 write_matrix_variable_array_to_buffer(var, data, offset, count, FALSE);
5677 return S_OK;
5680 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable *iface,
5681 float *data, UINT offset, UINT count)
5683 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5685 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
5686 read_matrix_variable_array_from_buffer(var, data, offset, count, FALSE);
5688 return S_OK;
5691 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
5692 float *data)
5694 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5696 TRACE("iface %p, data %p.\n", iface, data);
5697 write_matrix_variable_to_buffer(var, data, TRUE);
5699 return S_OK;
5702 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
5703 float *data)
5705 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5707 TRACE("iface %p, data %p.\n", iface, data);
5708 read_matrix_variable_from_buffer(var, data, TRUE);
5710 return S_OK;
5713 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
5714 float *data, UINT offset, UINT count)
5716 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5718 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
5719 write_matrix_variable_array_to_buffer(var, data, offset, count, TRUE);
5721 return S_OK;
5724 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
5725 float *data, UINT offset, UINT count)
5727 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
5729 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
5730 read_matrix_variable_array_from_buffer(var, data, offset, count, TRUE);
5732 return S_OK;
5736 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl =
5738 /* ID3D10EffectVariable methods */
5739 d3d10_effect_matrix_variable_IsValid,
5740 d3d10_effect_matrix_variable_GetType,
5741 d3d10_effect_matrix_variable_GetDesc,
5742 d3d10_effect_matrix_variable_GetAnnotationByIndex,
5743 d3d10_effect_matrix_variable_GetAnnotationByName,
5744 d3d10_effect_matrix_variable_GetMemberByIndex,
5745 d3d10_effect_matrix_variable_GetMemberByName,
5746 d3d10_effect_matrix_variable_GetMemberBySemantic,
5747 d3d10_effect_matrix_variable_GetElement,
5748 d3d10_effect_matrix_variable_GetParentConstantBuffer,
5749 d3d10_effect_matrix_variable_AsScalar,
5750 d3d10_effect_matrix_variable_AsVector,
5751 d3d10_effect_matrix_variable_AsMatrix,
5752 d3d10_effect_matrix_variable_AsString,
5753 d3d10_effect_matrix_variable_AsShaderResource,
5754 d3d10_effect_matrix_variable_AsRenderTargetView,
5755 d3d10_effect_matrix_variable_AsDepthStencilView,
5756 d3d10_effect_matrix_variable_AsConstantBuffer,
5757 d3d10_effect_matrix_variable_AsShader,
5758 d3d10_effect_matrix_variable_AsBlend,
5759 d3d10_effect_matrix_variable_AsDepthStencil,
5760 d3d10_effect_matrix_variable_AsRasterizer,
5761 d3d10_effect_matrix_variable_AsSampler,
5762 d3d10_effect_matrix_variable_SetRawValue,
5763 d3d10_effect_matrix_variable_GetRawValue,
5764 /* ID3D10EffectMatrixVariable methods */
5765 d3d10_effect_matrix_variable_SetMatrix,
5766 d3d10_effect_matrix_variable_GetMatrix,
5767 d3d10_effect_matrix_variable_SetMatrixArray,
5768 d3d10_effect_matrix_variable_GetMatrixArray,
5769 d3d10_effect_matrix_variable_SetMatrixTranspose,
5770 d3d10_effect_matrix_variable_GetMatrixTranspose,
5771 d3d10_effect_matrix_variable_SetMatrixTransposeArray,
5772 d3d10_effect_matrix_variable_GetMatrixTransposeArray,
5775 /* ID3D10EffectVariable methods */
5777 static BOOL STDMETHODCALLTYPE d3d10_effect_string_variable_IsValid(ID3D10EffectStringVariable *iface)
5779 TRACE("iface %p\n", iface);
5781 return (struct d3d10_effect_variable *)iface != &null_string_variable;
5784 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_string_variable_GetType(
5785 ID3D10EffectStringVariable *iface)
5787 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5790 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetDesc(ID3D10EffectStringVariable *iface,
5791 D3D10_EFFECT_VARIABLE_DESC *desc)
5793 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5796 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetAnnotationByIndex(
5797 ID3D10EffectStringVariable *iface, UINT index)
5799 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5802 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetAnnotationByName(
5803 ID3D10EffectStringVariable *iface, const char *name)
5805 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5808 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberByIndex(
5809 ID3D10EffectStringVariable *iface, UINT index)
5811 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5814 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberByName(
5815 ID3D10EffectStringVariable *iface, const char *name)
5817 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5820 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberBySemantic(
5821 ID3D10EffectStringVariable *iface, const char *semantic)
5823 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5826 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetElement(
5827 ID3D10EffectStringVariable *iface, UINT index)
5829 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5832 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_string_variable_GetParentConstantBuffer(
5833 ID3D10EffectStringVariable *iface)
5835 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5838 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsScalar(
5839 ID3D10EffectStringVariable *iface)
5841 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5844 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsVector(
5845 ID3D10EffectStringVariable *iface)
5847 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5850 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsMatrix(
5851 ID3D10EffectStringVariable *iface)
5853 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5856 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsString(
5857 ID3D10EffectStringVariable *iface)
5859 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5862 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsShaderResource(
5863 ID3D10EffectStringVariable *iface)
5865 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5868 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsRenderTargetView(
5869 ID3D10EffectStringVariable *iface)
5871 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5874 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsDepthStencilView(
5875 ID3D10EffectStringVariable *iface)
5877 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5880 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_string_variable_AsConstantBuffer(
5881 ID3D10EffectStringVariable *iface)
5883 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5886 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsShader(
5887 ID3D10EffectStringVariable *iface)
5889 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5892 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsBlend(
5893 ID3D10EffectStringVariable *iface)
5895 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5898 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsDepthStencil(
5899 ID3D10EffectStringVariable *iface)
5901 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5904 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsRasterizer(
5905 ID3D10EffectStringVariable *iface)
5907 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5910 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsSampler(
5911 ID3D10EffectStringVariable *iface)
5913 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5916 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_SetRawValue(ID3D10EffectStringVariable *iface,
5917 void *data, UINT offset, UINT count)
5919 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5922 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetRawValue(ID3D10EffectStringVariable *iface,
5923 void *data, UINT offset, UINT count)
5925 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5928 /* ID3D10EffectStringVariable methods */
5930 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetString(ID3D10EffectStringVariable *iface,
5931 const char **str)
5933 FIXME("iface %p, str %p stub!\n", iface, str);
5935 return E_NOTIMPL;
5938 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetStringArray(ID3D10EffectStringVariable *iface,
5939 const char **strs, UINT offset, UINT count)
5941 FIXME("iface %p, strs %p, offset %u, count %u stub!\n", iface, strs, offset, count);
5943 return E_NOTIMPL;
5947 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl =
5949 /* ID3D10EffectVariable methods */
5950 d3d10_effect_string_variable_IsValid,
5951 d3d10_effect_string_variable_GetType,
5952 d3d10_effect_string_variable_GetDesc,
5953 d3d10_effect_string_variable_GetAnnotationByIndex,
5954 d3d10_effect_string_variable_GetAnnotationByName,
5955 d3d10_effect_string_variable_GetMemberByIndex,
5956 d3d10_effect_string_variable_GetMemberByName,
5957 d3d10_effect_string_variable_GetMemberBySemantic,
5958 d3d10_effect_string_variable_GetElement,
5959 d3d10_effect_string_variable_GetParentConstantBuffer,
5960 d3d10_effect_string_variable_AsScalar,
5961 d3d10_effect_string_variable_AsVector,
5962 d3d10_effect_string_variable_AsMatrix,
5963 d3d10_effect_string_variable_AsString,
5964 d3d10_effect_string_variable_AsShaderResource,
5965 d3d10_effect_string_variable_AsRenderTargetView,
5966 d3d10_effect_string_variable_AsDepthStencilView,
5967 d3d10_effect_string_variable_AsConstantBuffer,
5968 d3d10_effect_string_variable_AsShader,
5969 d3d10_effect_string_variable_AsBlend,
5970 d3d10_effect_string_variable_AsDepthStencil,
5971 d3d10_effect_string_variable_AsRasterizer,
5972 d3d10_effect_string_variable_AsSampler,
5973 d3d10_effect_string_variable_SetRawValue,
5974 d3d10_effect_string_variable_GetRawValue,
5975 /* ID3D10EffectStringVariable methods */
5976 d3d10_effect_string_variable_GetString,
5977 d3d10_effect_string_variable_GetStringArray,
5980 static void set_shader_resource_variable(ID3D10ShaderResourceView **src, ID3D10ShaderResourceView **dst)
5982 if (*dst == *src)
5983 return;
5985 if (*src)
5986 ID3D10ShaderResourceView_AddRef(*src);
5987 if (*dst)
5988 ID3D10ShaderResourceView_Release(*dst);
5990 *dst = *src;
5993 /* ID3D10EffectVariable methods */
5995 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectShaderResourceVariable(
5996 ID3D10EffectShaderResourceVariable *iface)
5998 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
6001 static BOOL STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_IsValid(ID3D10EffectShaderResourceVariable *iface)
6003 TRACE("iface %p\n", iface);
6005 return (struct d3d10_effect_variable *)iface != &null_shader_resource_variable;
6008 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetType(
6009 ID3D10EffectShaderResourceVariable *iface)
6011 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6014 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetDesc(
6015 ID3D10EffectShaderResourceVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
6017 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6020 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetAnnotationByIndex(
6021 ID3D10EffectShaderResourceVariable *iface, UINT index)
6023 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6026 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetAnnotationByName(
6027 ID3D10EffectShaderResourceVariable *iface, const char *name)
6029 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6032 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberByIndex(
6033 ID3D10EffectShaderResourceVariable *iface, UINT index)
6035 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6038 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberByName(
6039 ID3D10EffectShaderResourceVariable *iface, const char *name)
6041 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6044 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberBySemantic(
6045 ID3D10EffectShaderResourceVariable *iface, const char *semantic)
6047 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6050 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetElement(
6051 ID3D10EffectShaderResourceVariable *iface, UINT index)
6053 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6056 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetParentConstantBuffer(
6057 ID3D10EffectShaderResourceVariable *iface)
6059 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6062 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsScalar(
6063 ID3D10EffectShaderResourceVariable *iface)
6065 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6068 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsVector(
6069 ID3D10EffectShaderResourceVariable *iface)
6071 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6074 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsMatrix(
6075 ID3D10EffectShaderResourceVariable *iface)
6077 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6080 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsString(
6081 ID3D10EffectShaderResourceVariable *iface)
6083 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6086 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsShaderResource(
6087 ID3D10EffectShaderResourceVariable *iface)
6089 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6092 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsRenderTargetView(
6093 ID3D10EffectShaderResourceVariable *iface)
6095 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6098 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsDepthStencilView(
6099 ID3D10EffectShaderResourceVariable *iface)
6101 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6104 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsConstantBuffer(
6105 ID3D10EffectShaderResourceVariable *iface)
6107 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6110 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsShader(
6111 ID3D10EffectShaderResourceVariable *iface)
6113 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6116 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsBlend(
6117 ID3D10EffectShaderResourceVariable *iface)
6119 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6122 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsDepthStencil(
6123 ID3D10EffectShaderResourceVariable *iface)
6125 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6128 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsRasterizer(
6129 ID3D10EffectShaderResourceVariable *iface)
6131 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6134 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsSampler(
6135 ID3D10EffectShaderResourceVariable *iface)
6137 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6140 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetRawValue(
6141 ID3D10EffectShaderResourceVariable *iface, void *data, UINT offset, UINT count)
6143 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6146 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetRawValue(
6147 ID3D10EffectShaderResourceVariable *iface, void *data, UINT offset, UINT count)
6149 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6152 /* ID3D10EffectShaderResourceVariable methods */
6154 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResource(
6155 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView *resource)
6157 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderResourceVariable(iface);
6159 TRACE("iface %p, resource %p.\n", iface, resource);
6161 set_shader_resource_variable(&resource, v->u.resource.srv);
6163 return S_OK;
6166 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResource(
6167 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resource)
6169 FIXME("iface %p, resource %p stub!\n", iface, resource);
6171 return E_NOTIMPL;
6174 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResourceArray(
6175 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resources, UINT offset, UINT count)
6177 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderResourceVariable(iface);
6178 ID3D10ShaderResourceView **rsrc_view;
6179 unsigned int i;
6181 TRACE("iface %p, resources %p, offset %u, count %u.\n", iface, resources, offset, count);
6183 if (!v->type->element_count)
6184 return d3d10_effect_shader_resource_variable_SetResource(iface, *resources);
6186 if (offset >= v->type->element_count)
6188 WARN("Offset %u larger than element count %u, ignoring.\n", offset, v->type->element_count);
6189 return S_OK;
6192 if (count > v->type->element_count - offset)
6194 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6195 offset, count, v->type->element_count);
6196 count = v->type->element_count - offset;
6199 rsrc_view = &v->u.resource.srv[offset];
6200 for (i = 0; i < count; ++i)
6201 set_shader_resource_variable(&resources[i], &rsrc_view[i]);
6203 return S_OK;
6206 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResourceArray(
6207 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resources, UINT offset, UINT count)
6209 FIXME("iface %p, resources %p, offset %u, count %u stub!\n", iface, resources, offset, count);
6211 return E_NOTIMPL;
6215 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl =
6217 /* ID3D10EffectVariable methods */
6218 d3d10_effect_shader_resource_variable_IsValid,
6219 d3d10_effect_shader_resource_variable_GetType,
6220 d3d10_effect_shader_resource_variable_GetDesc,
6221 d3d10_effect_shader_resource_variable_GetAnnotationByIndex,
6222 d3d10_effect_shader_resource_variable_GetAnnotationByName,
6223 d3d10_effect_shader_resource_variable_GetMemberByIndex,
6224 d3d10_effect_shader_resource_variable_GetMemberByName,
6225 d3d10_effect_shader_resource_variable_GetMemberBySemantic,
6226 d3d10_effect_shader_resource_variable_GetElement,
6227 d3d10_effect_shader_resource_variable_GetParentConstantBuffer,
6228 d3d10_effect_shader_resource_variable_AsScalar,
6229 d3d10_effect_shader_resource_variable_AsVector,
6230 d3d10_effect_shader_resource_variable_AsMatrix,
6231 d3d10_effect_shader_resource_variable_AsString,
6232 d3d10_effect_shader_resource_variable_AsShaderResource,
6233 d3d10_effect_shader_resource_variable_AsRenderTargetView,
6234 d3d10_effect_shader_resource_variable_AsDepthStencilView,
6235 d3d10_effect_shader_resource_variable_AsConstantBuffer,
6236 d3d10_effect_shader_resource_variable_AsShader,
6237 d3d10_effect_shader_resource_variable_AsBlend,
6238 d3d10_effect_shader_resource_variable_AsDepthStencil,
6239 d3d10_effect_shader_resource_variable_AsRasterizer,
6240 d3d10_effect_shader_resource_variable_AsSampler,
6241 d3d10_effect_shader_resource_variable_SetRawValue,
6242 d3d10_effect_shader_resource_variable_GetRawValue,
6243 /* ID3D10EffectShaderResourceVariable methods */
6244 d3d10_effect_shader_resource_variable_SetResource,
6245 d3d10_effect_shader_resource_variable_GetResource,
6246 d3d10_effect_shader_resource_variable_SetResourceArray,
6247 d3d10_effect_shader_resource_variable_GetResourceArray,
6250 /* ID3D10EffectVariable methods */
6252 static BOOL STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_IsValid(
6253 ID3D10EffectRenderTargetViewVariable *iface)
6255 TRACE("iface %p\n", iface);
6257 return (struct d3d10_effect_variable *)iface != &null_render_target_view_variable;
6260 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetType(
6261 ID3D10EffectRenderTargetViewVariable *iface)
6263 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6266 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetDesc(
6267 ID3D10EffectRenderTargetViewVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
6269 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6272 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetAnnotationByIndex(
6273 ID3D10EffectRenderTargetViewVariable *iface, UINT index)
6275 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6278 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetAnnotationByName(
6279 ID3D10EffectRenderTargetViewVariable *iface, const char *name)
6281 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6284 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberByIndex(
6285 ID3D10EffectRenderTargetViewVariable *iface, UINT index)
6287 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6290 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberByName(
6291 ID3D10EffectRenderTargetViewVariable *iface, const char *name)
6293 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6296 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberBySemantic(
6297 ID3D10EffectRenderTargetViewVariable *iface, const char *semantic)
6299 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6302 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetElement(
6303 ID3D10EffectRenderTargetViewVariable *iface, UINT index)
6305 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6308 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetParentConstantBuffer(
6309 ID3D10EffectRenderTargetViewVariable *iface)
6311 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6314 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsScalar(
6315 ID3D10EffectRenderTargetViewVariable *iface)
6317 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6320 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsVector(
6321 ID3D10EffectRenderTargetViewVariable *iface)
6323 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6326 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsMatrix(
6327 ID3D10EffectRenderTargetViewVariable *iface)
6329 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6332 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsString(
6333 ID3D10EffectRenderTargetViewVariable *iface)
6335 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6338 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsShaderResource(
6339 ID3D10EffectRenderTargetViewVariable *iface)
6341 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6344 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsRenderTargetView(
6345 ID3D10EffectRenderTargetViewVariable *iface)
6347 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6350 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsDepthStencilView(
6351 ID3D10EffectRenderTargetViewVariable *iface)
6353 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6356 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsConstantBuffer(
6357 ID3D10EffectRenderTargetViewVariable *iface)
6359 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6362 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsShader(
6363 ID3D10EffectRenderTargetViewVariable *iface)
6365 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6368 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsBlend(
6369 ID3D10EffectRenderTargetViewVariable *iface)
6371 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6374 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsDepthStencil(
6375 ID3D10EffectRenderTargetViewVariable *iface)
6377 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6380 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsRasterizer(
6381 ID3D10EffectRenderTargetViewVariable *iface)
6383 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6386 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsSampler(
6387 ID3D10EffectRenderTargetViewVariable *iface)
6389 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6392 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRawValue(
6393 ID3D10EffectRenderTargetViewVariable *iface, void *data, UINT offset, UINT count)
6395 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6398 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRawValue(
6399 ID3D10EffectRenderTargetViewVariable *iface, void *data, UINT offset, UINT count)
6401 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6404 /* ID3D10EffectRenderTargetViewVariable methods */
6406 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRenderTarget(
6407 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView *view)
6409 FIXME("iface %p, view %p stub!\n", iface, view);
6411 return E_NOTIMPL;
6414 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRenderTarget(
6415 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **view)
6417 FIXME("iface %p, view %p stub!\n", iface, view);
6419 return E_NOTIMPL;
6422 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRenderTargetArray(
6423 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **views, UINT offset, UINT count)
6425 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6427 return E_NOTIMPL;
6430 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRenderTargetArray(
6431 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **views, UINT offset, UINT count)
6433 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6435 return E_NOTIMPL;
6439 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl =
6441 /* ID3D10EffectVariable methods */
6442 d3d10_effect_render_target_view_variable_IsValid,
6443 d3d10_effect_render_target_view_variable_GetType,
6444 d3d10_effect_render_target_view_variable_GetDesc,
6445 d3d10_effect_render_target_view_variable_GetAnnotationByIndex,
6446 d3d10_effect_render_target_view_variable_GetAnnotationByName,
6447 d3d10_effect_render_target_view_variable_GetMemberByIndex,
6448 d3d10_effect_render_target_view_variable_GetMemberByName,
6449 d3d10_effect_render_target_view_variable_GetMemberBySemantic,
6450 d3d10_effect_render_target_view_variable_GetElement,
6451 d3d10_effect_render_target_view_variable_GetParentConstantBuffer,
6452 d3d10_effect_render_target_view_variable_AsScalar,
6453 d3d10_effect_render_target_view_variable_AsVector,
6454 d3d10_effect_render_target_view_variable_AsMatrix,
6455 d3d10_effect_render_target_view_variable_AsString,
6456 d3d10_effect_render_target_view_variable_AsShaderResource,
6457 d3d10_effect_render_target_view_variable_AsRenderTargetView,
6458 d3d10_effect_render_target_view_variable_AsDepthStencilView,
6459 d3d10_effect_render_target_view_variable_AsConstantBuffer,
6460 d3d10_effect_render_target_view_variable_AsShader,
6461 d3d10_effect_render_target_view_variable_AsBlend,
6462 d3d10_effect_render_target_view_variable_AsDepthStencil,
6463 d3d10_effect_render_target_view_variable_AsRasterizer,
6464 d3d10_effect_render_target_view_variable_AsSampler,
6465 d3d10_effect_render_target_view_variable_SetRawValue,
6466 d3d10_effect_render_target_view_variable_GetRawValue,
6467 /* ID3D10EffectRenderTargetViewVariable methods */
6468 d3d10_effect_render_target_view_variable_SetRenderTarget,
6469 d3d10_effect_render_target_view_variable_GetRenderTarget,
6470 d3d10_effect_render_target_view_variable_SetRenderTargetArray,
6471 d3d10_effect_render_target_view_variable_GetRenderTargetArray,
6474 /* ID3D10EffectVariable methods */
6476 static BOOL STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_IsValid(
6477 ID3D10EffectDepthStencilViewVariable *iface)
6479 TRACE("iface %p\n", iface);
6481 return (struct d3d10_effect_variable *)iface != &null_depth_stencil_view_variable;
6484 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetType(
6485 ID3D10EffectDepthStencilViewVariable *iface)
6487 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6490 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDesc(
6491 ID3D10EffectDepthStencilViewVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
6493 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6496 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex(
6497 ID3D10EffectDepthStencilViewVariable *iface, UINT index)
6499 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6502 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetAnnotationByName(
6503 ID3D10EffectDepthStencilViewVariable *iface, const char *name)
6505 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6508 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberByIndex(
6509 ID3D10EffectDepthStencilViewVariable *iface, UINT index)
6511 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6514 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberByName(
6515 ID3D10EffectDepthStencilViewVariable *iface, const char *name)
6517 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6520 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic(
6521 ID3D10EffectDepthStencilViewVariable *iface, const char *semantic)
6523 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6526 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetElement(
6527 ID3D10EffectDepthStencilViewVariable *iface, UINT index)
6529 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6532 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer(
6533 ID3D10EffectDepthStencilViewVariable *iface)
6535 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6538 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsScalar(
6539 ID3D10EffectDepthStencilViewVariable *iface)
6541 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6544 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsVector(
6545 ID3D10EffectDepthStencilViewVariable *iface)
6547 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6550 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsMatrix(
6551 ID3D10EffectDepthStencilViewVariable *iface)
6553 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6556 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsString(
6557 ID3D10EffectDepthStencilViewVariable *iface)
6559 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6562 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsShaderResource(
6563 ID3D10EffectDepthStencilViewVariable *iface)
6565 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6568 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsRenderTargetView(
6569 ID3D10EffectDepthStencilViewVariable *iface)
6571 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6574 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsDepthStencilView(
6575 ID3D10EffectDepthStencilViewVariable *iface)
6577 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6580 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsConstantBuffer(
6581 ID3D10EffectDepthStencilViewVariable *iface)
6583 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6586 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsShader(
6587 ID3D10EffectDepthStencilViewVariable *iface)
6589 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6592 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsBlend(
6593 ID3D10EffectDepthStencilViewVariable *iface)
6595 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6598 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsDepthStencil(
6599 ID3D10EffectDepthStencilViewVariable *iface)
6601 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6604 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsRasterizer(
6605 ID3D10EffectDepthStencilViewVariable *iface)
6607 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6610 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsSampler(
6611 ID3D10EffectDepthStencilViewVariable *iface)
6613 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6616 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetRawValue(
6617 ID3D10EffectDepthStencilViewVariable *iface, void *data, UINT offset, UINT count)
6619 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6622 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetRawValue(
6623 ID3D10EffectDepthStencilViewVariable *iface, void *data, UINT offset, UINT count)
6625 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6628 /* ID3D10EffectDepthStencilViewVariable methods */
6630 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetDepthStencil(
6631 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView *view)
6633 FIXME("iface %p, view %p stub!\n", iface, view);
6635 return E_NOTIMPL;
6638 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDepthStencil(
6639 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **view)
6641 FIXME("iface %p, view %p stub!\n", iface, view);
6643 return E_NOTIMPL;
6646 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray(
6647 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **views, UINT offset, UINT count)
6649 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6651 return E_NOTIMPL;
6654 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray(
6655 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **views, UINT offset, UINT count)
6657 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6659 return E_NOTIMPL;
6663 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl =
6665 /* ID3D10EffectVariable methods */
6666 d3d10_effect_depth_stencil_view_variable_IsValid,
6667 d3d10_effect_depth_stencil_view_variable_GetType,
6668 d3d10_effect_depth_stencil_view_variable_GetDesc,
6669 d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex,
6670 d3d10_effect_depth_stencil_view_variable_GetAnnotationByName,
6671 d3d10_effect_depth_stencil_view_variable_GetMemberByIndex,
6672 d3d10_effect_depth_stencil_view_variable_GetMemberByName,
6673 d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic,
6674 d3d10_effect_depth_stencil_view_variable_GetElement,
6675 d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer,
6676 d3d10_effect_depth_stencil_view_variable_AsScalar,
6677 d3d10_effect_depth_stencil_view_variable_AsVector,
6678 d3d10_effect_depth_stencil_view_variable_AsMatrix,
6679 d3d10_effect_depth_stencil_view_variable_AsString,
6680 d3d10_effect_depth_stencil_view_variable_AsShaderResource,
6681 d3d10_effect_depth_stencil_view_variable_AsRenderTargetView,
6682 d3d10_effect_depth_stencil_view_variable_AsDepthStencilView,
6683 d3d10_effect_depth_stencil_view_variable_AsConstantBuffer,
6684 d3d10_effect_depth_stencil_view_variable_AsShader,
6685 d3d10_effect_depth_stencil_view_variable_AsBlend,
6686 d3d10_effect_depth_stencil_view_variable_AsDepthStencil,
6687 d3d10_effect_depth_stencil_view_variable_AsRasterizer,
6688 d3d10_effect_depth_stencil_view_variable_AsSampler,
6689 d3d10_effect_depth_stencil_view_variable_SetRawValue,
6690 d3d10_effect_depth_stencil_view_variable_GetRawValue,
6691 /* ID3D10EffectDepthStencilViewVariable methods */
6692 d3d10_effect_depth_stencil_view_variable_SetDepthStencil,
6693 d3d10_effect_depth_stencil_view_variable_GetDepthStencil,
6694 d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray,
6695 d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray,
6698 /* ID3D10EffectVariable methods */
6700 static BOOL STDMETHODCALLTYPE d3d10_effect_shader_variable_IsValid(ID3D10EffectShaderVariable *iface)
6702 TRACE("iface %p\n", iface);
6704 return (struct d3d10_effect_variable *)iface != &null_shader_variable;
6707 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetType(
6708 ID3D10EffectShaderVariable *iface)
6710 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6713 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetDesc(ID3D10EffectShaderVariable *iface,
6714 D3D10_EFFECT_VARIABLE_DESC *desc)
6716 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6719 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetAnnotationByIndex(
6720 ID3D10EffectShaderVariable *iface, UINT index)
6722 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6725 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetAnnotationByName(
6726 ID3D10EffectShaderVariable *iface, const char *name)
6728 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6731 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberByIndex(
6732 ID3D10EffectShaderVariable *iface, UINT index)
6734 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6737 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberByName(
6738 ID3D10EffectShaderVariable *iface, const char *name)
6740 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6743 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberBySemantic(
6744 ID3D10EffectShaderVariable *iface, const char *semantic)
6746 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6749 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetElement(
6750 ID3D10EffectShaderVariable *iface, UINT index)
6752 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6755 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetParentConstantBuffer(
6756 ID3D10EffectShaderVariable *iface)
6758 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6761 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsScalar(
6762 ID3D10EffectShaderVariable *iface)
6764 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6767 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsVector(
6768 ID3D10EffectShaderVariable *iface)
6770 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6773 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsMatrix(
6774 ID3D10EffectShaderVariable *iface)
6776 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6779 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsString(
6780 ID3D10EffectShaderVariable *iface)
6782 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6785 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsShaderResource(
6786 ID3D10EffectShaderVariable *iface)
6788 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6791 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsRenderTargetView(
6792 ID3D10EffectShaderVariable *iface)
6794 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6797 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsDepthStencilView(
6798 ID3D10EffectShaderVariable *iface)
6800 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6803 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsConstantBuffer(
6804 ID3D10EffectShaderVariable *iface)
6806 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6809 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsShader(
6810 ID3D10EffectShaderVariable *iface)
6812 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6815 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsBlend(
6816 ID3D10EffectShaderVariable *iface)
6818 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6821 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsDepthStencil(
6822 ID3D10EffectShaderVariable *iface)
6824 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6827 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsRasterizer(
6828 ID3D10EffectShaderVariable *iface)
6830 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6833 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsSampler(
6834 ID3D10EffectShaderVariable *iface)
6836 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6839 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_SetRawValue(
6840 ID3D10EffectShaderVariable *iface, void *data, UINT offset, UINT count)
6842 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6845 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetRawValue(
6846 ID3D10EffectShaderVariable *iface, void *data, UINT offset, UINT count)
6848 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6851 /* ID3D10EffectShaderVariable methods */
6853 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetShaderDesc(
6854 ID3D10EffectShaderVariable *iface, UINT index, D3D10_EFFECT_SHADER_DESC *desc)
6856 FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc);
6858 return E_NOTIMPL;
6861 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetVertexShader(
6862 ID3D10EffectShaderVariable *iface, UINT index, ID3D10VertexShader **shader)
6864 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
6866 TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
6868 if (v->type->element_count)
6869 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6871 if (v->type->basetype != D3D10_SVT_VERTEXSHADER)
6873 WARN("Shader is not a vertex shader.\n");
6874 return E_FAIL;
6877 if ((*shader = v->u.shader.shader.vs))
6878 ID3D10VertexShader_AddRef(*shader);
6880 return S_OK;
6883 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetGeometryShader(
6884 ID3D10EffectShaderVariable *iface, UINT index, ID3D10GeometryShader **shader)
6886 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
6888 TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
6890 if (v->type->element_count)
6891 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6893 if (v->type->basetype != D3D10_SVT_GEOMETRYSHADER)
6895 WARN("Shader is not a geometry shader.\n");
6896 return E_FAIL;
6899 if ((*shader = v->u.shader.shader.gs))
6900 ID3D10GeometryShader_AddRef(*shader);
6902 return S_OK;
6905 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetPixelShader(
6906 ID3D10EffectShaderVariable *iface, UINT index, ID3D10PixelShader **shader)
6908 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
6910 TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
6912 if (v->type->element_count)
6913 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
6915 if (v->type->basetype != D3D10_SVT_PIXELSHADER)
6917 WARN("Shader is not a pixel shader.\n");
6918 return E_FAIL;
6921 if ((*shader = v->u.shader.shader.ps))
6922 ID3D10PixelShader_AddRef(*shader);
6924 return S_OK;
6927 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetInputSignatureElementDesc(
6928 ID3D10EffectShaderVariable *iface, UINT shader_index, UINT element_index,
6929 D3D10_SIGNATURE_PARAMETER_DESC *desc)
6931 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
6932 struct d3d10_effect_shader_variable *s;
6933 D3D10_SIGNATURE_PARAMETER_DESC *d;
6935 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
6936 iface, shader_index, element_index, desc);
6938 if (!iface->lpVtbl->IsValid(iface))
6940 WARN("Null variable specified\n");
6941 return E_FAIL;
6944 /* Check shader_index, this crashes on W7/DX10 */
6945 if (shader_index >= v->effect->used_shader_count)
6947 WARN("This should crash on W7/DX10!\n");
6948 return E_FAIL;
6951 s = &v->effect->used_shaders[shader_index]->u.shader;
6952 if (!s->input_signature.signature)
6954 WARN("No shader signature\n");
6955 return D3DERR_INVALIDCALL;
6958 /* Check desc for NULL, this crashes on W7/DX10 */
6959 if (!desc)
6961 WARN("This should crash on W7/DX10!\n");
6962 return E_FAIL;
6965 if (element_index >= s->input_signature.element_count)
6967 WARN("Invalid element index specified\n");
6968 return E_INVALIDARG;
6971 d = &s->input_signature.elements[element_index];
6972 desc->SemanticName = d->SemanticName;
6973 desc->SemanticIndex = d->SemanticIndex;
6974 desc->SystemValueType = d->SystemValueType;
6975 desc->ComponentType = d->ComponentType;
6976 desc->Register = d->Register;
6977 desc->ReadWriteMask = d->ReadWriteMask;
6978 desc->Mask = d->Mask;
6980 return S_OK;
6983 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetOutputSignatureElementDesc(
6984 ID3D10EffectShaderVariable *iface, UINT shader_index, UINT element_index,
6985 D3D10_SIGNATURE_PARAMETER_DESC *desc)
6987 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
6988 struct d3d10_effect_shader_variable *s;
6989 D3D10_SIGNATURE_PARAMETER_DESC *d;
6991 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
6992 iface, shader_index, element_index, desc);
6994 if (!iface->lpVtbl->IsValid(iface))
6996 WARN("Null variable specified\n");
6997 return E_FAIL;
7000 /* Check shader_index, this crashes on W7/DX10 */
7001 if (shader_index >= v->effect->used_shader_count)
7003 WARN("This should crash on W7/DX10!\n");
7004 return E_FAIL;
7007 s = &v->effect->used_shaders[shader_index]->u.shader;
7008 if (!s->output_signature.signature)
7010 WARN("No shader signature\n");
7011 return D3DERR_INVALIDCALL;
7014 /* Check desc for NULL, this crashes on W7/DX10 */
7015 if (!desc)
7017 WARN("This should crash on W7/DX10!\n");
7018 return E_FAIL;
7021 if (element_index >= s->output_signature.element_count)
7023 WARN("Invalid element index specified\n");
7024 return E_INVALIDARG;
7027 d = &s->output_signature.elements[element_index];
7028 desc->SemanticName = d->SemanticName;
7029 desc->SemanticIndex = d->SemanticIndex;
7030 desc->SystemValueType = d->SystemValueType;
7031 desc->ComponentType = d->ComponentType;
7032 desc->Register = d->Register;
7033 desc->ReadWriteMask = d->ReadWriteMask;
7034 desc->Mask = d->Mask;
7036 return S_OK;
7040 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl =
7042 /* ID3D10EffectVariable methods */
7043 d3d10_effect_shader_variable_IsValid,
7044 d3d10_effect_shader_variable_GetType,
7045 d3d10_effect_shader_variable_GetDesc,
7046 d3d10_effect_shader_variable_GetAnnotationByIndex,
7047 d3d10_effect_shader_variable_GetAnnotationByName,
7048 d3d10_effect_shader_variable_GetMemberByIndex,
7049 d3d10_effect_shader_variable_GetMemberByName,
7050 d3d10_effect_shader_variable_GetMemberBySemantic,
7051 d3d10_effect_shader_variable_GetElement,
7052 d3d10_effect_shader_variable_GetParentConstantBuffer,
7053 d3d10_effect_shader_variable_AsScalar,
7054 d3d10_effect_shader_variable_AsVector,
7055 d3d10_effect_shader_variable_AsMatrix,
7056 d3d10_effect_shader_variable_AsString,
7057 d3d10_effect_shader_variable_AsShaderResource,
7058 d3d10_effect_shader_variable_AsRenderTargetView,
7059 d3d10_effect_shader_variable_AsDepthStencilView,
7060 d3d10_effect_shader_variable_AsConstantBuffer,
7061 d3d10_effect_shader_variable_AsShader,
7062 d3d10_effect_shader_variable_AsBlend,
7063 d3d10_effect_shader_variable_AsDepthStencil,
7064 d3d10_effect_shader_variable_AsRasterizer,
7065 d3d10_effect_shader_variable_AsSampler,
7066 d3d10_effect_shader_variable_SetRawValue,
7067 d3d10_effect_shader_variable_GetRawValue,
7068 /* ID3D10EffectShaderVariable methods */
7069 d3d10_effect_shader_variable_GetShaderDesc,
7070 d3d10_effect_shader_variable_GetVertexShader,
7071 d3d10_effect_shader_variable_GetGeometryShader,
7072 d3d10_effect_shader_variable_GetPixelShader,
7073 d3d10_effect_shader_variable_GetInputSignatureElementDesc,
7074 d3d10_effect_shader_variable_GetOutputSignatureElementDesc,
7077 /* ID3D10EffectVariable methods */
7079 static BOOL STDMETHODCALLTYPE d3d10_effect_blend_variable_IsValid(ID3D10EffectBlendVariable *iface)
7081 TRACE("iface %p\n", iface);
7083 return (struct d3d10_effect_variable *)iface != &null_blend_variable;
7086 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetType(
7087 ID3D10EffectBlendVariable *iface)
7089 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7092 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetDesc(ID3D10EffectBlendVariable *iface,
7093 D3D10_EFFECT_VARIABLE_DESC *desc)
7095 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7098 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetAnnotationByIndex(
7099 ID3D10EffectBlendVariable *iface, UINT index)
7101 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7104 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetAnnotationByName(
7105 ID3D10EffectBlendVariable *iface, const char *name)
7107 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7110 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberByIndex(
7111 ID3D10EffectBlendVariable *iface, UINT index)
7113 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7116 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberByName(
7117 ID3D10EffectBlendVariable *iface, const char *name)
7119 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7122 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberBySemantic(
7123 ID3D10EffectBlendVariable *iface, const char *semantic)
7125 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7128 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetElement(
7129 ID3D10EffectBlendVariable *iface, UINT index)
7131 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7134 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetParentConstantBuffer(
7135 ID3D10EffectBlendVariable *iface)
7137 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7140 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsScalar(
7141 ID3D10EffectBlendVariable *iface)
7143 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7146 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsVector(
7147 ID3D10EffectBlendVariable *iface)
7149 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7152 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsMatrix(
7153 ID3D10EffectBlendVariable *iface)
7155 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7158 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsString(
7159 ID3D10EffectBlendVariable *iface)
7161 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7164 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsShaderResource(
7165 ID3D10EffectBlendVariable *iface)
7167 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7170 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsRenderTargetView(
7171 ID3D10EffectBlendVariable *iface)
7173 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7176 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsDepthStencilView(
7177 ID3D10EffectBlendVariable *iface)
7179 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7182 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsConstantBuffer(
7183 ID3D10EffectBlendVariable *iface)
7185 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7188 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsShader(
7189 ID3D10EffectBlendVariable *iface)
7191 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7194 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsBlend(
7195 ID3D10EffectBlendVariable *iface)
7197 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7200 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsDepthStencil(
7201 ID3D10EffectBlendVariable *iface)
7203 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7206 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsRasterizer(
7207 ID3D10EffectBlendVariable *iface)
7209 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7212 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsSampler(
7213 ID3D10EffectBlendVariable *iface)
7215 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7218 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_SetRawValue(ID3D10EffectBlendVariable *iface,
7219 void *data, UINT offset, UINT count)
7221 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7224 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetRawValue(ID3D10EffectBlendVariable *iface,
7225 void *data, UINT offset, UINT count)
7227 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7230 /* ID3D10EffectBlendVariable methods */
7232 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetBlendState(ID3D10EffectBlendVariable *iface,
7233 UINT index, ID3D10BlendState **blend_state)
7235 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7237 TRACE("iface %p, index %u, blend_state %p.\n", iface, index, blend_state);
7239 if (v->type->element_count)
7240 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7241 else if (index)
7242 return E_FAIL;
7244 if (v->type->basetype != D3D10_SVT_BLEND)
7246 WARN("Variable is not a blend state.\n");
7247 return E_FAIL;
7250 if ((*blend_state = v->u.state.object.blend))
7251 ID3D10BlendState_AddRef(*blend_state);
7253 return S_OK;
7256 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetBackingStore(ID3D10EffectBlendVariable *iface,
7257 UINT index, D3D10_BLEND_DESC *desc)
7259 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7261 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7263 if (v->type->element_count)
7264 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7266 if (v->type->basetype != D3D10_SVT_BLEND)
7268 WARN("Variable is not a blend state.\n");
7269 return E_FAIL;
7272 *desc = v->u.state.desc.blend;
7274 return S_OK;
7278 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl =
7280 /* ID3D10EffectVariable methods */
7281 d3d10_effect_blend_variable_IsValid,
7282 d3d10_effect_blend_variable_GetType,
7283 d3d10_effect_blend_variable_GetDesc,
7284 d3d10_effect_blend_variable_GetAnnotationByIndex,
7285 d3d10_effect_blend_variable_GetAnnotationByName,
7286 d3d10_effect_blend_variable_GetMemberByIndex,
7287 d3d10_effect_blend_variable_GetMemberByName,
7288 d3d10_effect_blend_variable_GetMemberBySemantic,
7289 d3d10_effect_blend_variable_GetElement,
7290 d3d10_effect_blend_variable_GetParentConstantBuffer,
7291 d3d10_effect_blend_variable_AsScalar,
7292 d3d10_effect_blend_variable_AsVector,
7293 d3d10_effect_blend_variable_AsMatrix,
7294 d3d10_effect_blend_variable_AsString,
7295 d3d10_effect_blend_variable_AsShaderResource,
7296 d3d10_effect_blend_variable_AsRenderTargetView,
7297 d3d10_effect_blend_variable_AsDepthStencilView,
7298 d3d10_effect_blend_variable_AsConstantBuffer,
7299 d3d10_effect_blend_variable_AsShader,
7300 d3d10_effect_blend_variable_AsBlend,
7301 d3d10_effect_blend_variable_AsDepthStencil,
7302 d3d10_effect_blend_variable_AsRasterizer,
7303 d3d10_effect_blend_variable_AsSampler,
7304 d3d10_effect_blend_variable_SetRawValue,
7305 d3d10_effect_blend_variable_GetRawValue,
7306 /* ID3D10EffectBlendVariable methods */
7307 d3d10_effect_blend_variable_GetBlendState,
7308 d3d10_effect_blend_variable_GetBackingStore,
7311 /* ID3D10EffectVariable methods */
7313 static BOOL STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_IsValid(ID3D10EffectDepthStencilVariable *iface)
7315 TRACE("iface %p\n", iface);
7317 return (struct d3d10_effect_variable *)iface != &null_depth_stencil_variable;
7320 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetType(
7321 ID3D10EffectDepthStencilVariable *iface)
7323 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7326 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetDesc(ID3D10EffectDepthStencilVariable *iface,
7327 D3D10_EFFECT_VARIABLE_DESC *desc)
7329 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7332 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetAnnotationByIndex(
7333 ID3D10EffectDepthStencilVariable *iface, UINT index)
7335 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7338 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetAnnotationByName(
7339 ID3D10EffectDepthStencilVariable *iface, const char *name)
7341 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7344 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberByIndex(
7345 ID3D10EffectDepthStencilVariable *iface, UINT index)
7347 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7350 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberByName(
7351 ID3D10EffectDepthStencilVariable *iface, const char *name)
7353 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7356 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberBySemantic(
7357 ID3D10EffectDepthStencilVariable *iface, const char *semantic)
7359 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7362 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetElement(
7363 ID3D10EffectDepthStencilVariable *iface, UINT index)
7365 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7368 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetParentConstantBuffer(
7369 ID3D10EffectDepthStencilVariable *iface)
7371 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7374 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsScalar(
7375 ID3D10EffectDepthStencilVariable *iface)
7377 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7380 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsVector(
7381 ID3D10EffectDepthStencilVariable *iface)
7383 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7386 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsMatrix(
7387 ID3D10EffectDepthStencilVariable *iface)
7389 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7392 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsString(
7393 ID3D10EffectDepthStencilVariable *iface)
7395 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7398 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsShaderResource(
7399 ID3D10EffectDepthStencilVariable *iface)
7401 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7404 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsRenderTargetView(
7405 ID3D10EffectDepthStencilVariable *iface)
7407 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7410 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsDepthStencilView(
7411 ID3D10EffectDepthStencilVariable *iface)
7413 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7416 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsConstantBuffer(
7417 ID3D10EffectDepthStencilVariable *iface)
7419 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7422 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsShader(
7423 ID3D10EffectDepthStencilVariable *iface)
7425 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7428 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsBlend(
7429 ID3D10EffectDepthStencilVariable *iface)
7431 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7434 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsDepthStencil(
7435 ID3D10EffectDepthStencilVariable *iface)
7437 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7440 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsRasterizer(
7441 ID3D10EffectDepthStencilVariable *iface)
7443 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7446 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsSampler(
7447 ID3D10EffectDepthStencilVariable *iface)
7449 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7452 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_SetRawValue(ID3D10EffectDepthStencilVariable *iface,
7453 void *data, UINT offset, UINT count)
7455 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7458 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetRawValue(ID3D10EffectDepthStencilVariable *iface,
7459 void *data, UINT offset, UINT count)
7461 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7464 /* ID3D10EffectDepthStencilVariable methods */
7466 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetDepthStencilState(ID3D10EffectDepthStencilVariable *iface,
7467 UINT index, ID3D10DepthStencilState **depth_stencil_state)
7469 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7471 TRACE("iface %p, index %u, depth_stencil_state %p.\n", iface, index, depth_stencil_state);
7473 if (v->type->element_count)
7474 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7475 else if (index)
7476 return E_FAIL;
7478 if (v->type->basetype != D3D10_SVT_DEPTHSTENCIL)
7480 WARN("Variable is not a depth stencil state.\n");
7481 return E_FAIL;
7484 if ((*depth_stencil_state = v->u.state.object.depth_stencil))
7485 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
7487 return S_OK;
7490 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetBackingStore(ID3D10EffectDepthStencilVariable *iface,
7491 UINT index, D3D10_DEPTH_STENCIL_DESC *desc)
7493 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7495 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7497 if (v->type->element_count)
7498 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7500 if (v->type->basetype != D3D10_SVT_DEPTHSTENCIL)
7502 WARN("Variable is not a depth stencil state.\n");
7503 return E_FAIL;
7506 *desc = v->u.state.desc.depth_stencil;
7508 return S_OK;
7512 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl =
7514 /* ID3D10EffectVariable methods */
7515 d3d10_effect_depth_stencil_variable_IsValid,
7516 d3d10_effect_depth_stencil_variable_GetType,
7517 d3d10_effect_depth_stencil_variable_GetDesc,
7518 d3d10_effect_depth_stencil_variable_GetAnnotationByIndex,
7519 d3d10_effect_depth_stencil_variable_GetAnnotationByName,
7520 d3d10_effect_depth_stencil_variable_GetMemberByIndex,
7521 d3d10_effect_depth_stencil_variable_GetMemberByName,
7522 d3d10_effect_depth_stencil_variable_GetMemberBySemantic,
7523 d3d10_effect_depth_stencil_variable_GetElement,
7524 d3d10_effect_depth_stencil_variable_GetParentConstantBuffer,
7525 d3d10_effect_depth_stencil_variable_AsScalar,
7526 d3d10_effect_depth_stencil_variable_AsVector,
7527 d3d10_effect_depth_stencil_variable_AsMatrix,
7528 d3d10_effect_depth_stencil_variable_AsString,
7529 d3d10_effect_depth_stencil_variable_AsShaderResource,
7530 d3d10_effect_depth_stencil_variable_AsRenderTargetView,
7531 d3d10_effect_depth_stencil_variable_AsDepthStencilView,
7532 d3d10_effect_depth_stencil_variable_AsConstantBuffer,
7533 d3d10_effect_depth_stencil_variable_AsShader,
7534 d3d10_effect_depth_stencil_variable_AsBlend,
7535 d3d10_effect_depth_stencil_variable_AsDepthStencil,
7536 d3d10_effect_depth_stencil_variable_AsRasterizer,
7537 d3d10_effect_depth_stencil_variable_AsSampler,
7538 d3d10_effect_depth_stencil_variable_SetRawValue,
7539 d3d10_effect_depth_stencil_variable_GetRawValue,
7540 /* ID3D10EffectDepthStencilVariable methods */
7541 d3d10_effect_depth_stencil_variable_GetDepthStencilState,
7542 d3d10_effect_depth_stencil_variable_GetBackingStore,
7545 /* ID3D10EffectVariable methods */
7547 static BOOL STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_IsValid(ID3D10EffectRasterizerVariable *iface)
7549 TRACE("iface %p\n", iface);
7551 return (struct d3d10_effect_variable *)iface != &null_rasterizer_variable;
7554 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetType(
7555 ID3D10EffectRasterizerVariable *iface)
7557 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7560 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetDesc(ID3D10EffectRasterizerVariable *iface,
7561 D3D10_EFFECT_VARIABLE_DESC *desc)
7563 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7566 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetAnnotationByIndex(
7567 ID3D10EffectRasterizerVariable *iface, UINT index)
7569 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7572 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetAnnotationByName(
7573 ID3D10EffectRasterizerVariable *iface, const char *name)
7575 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7578 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberByIndex(
7579 ID3D10EffectRasterizerVariable *iface, UINT index)
7581 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7584 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberByName(
7585 ID3D10EffectRasterizerVariable *iface, const char *name)
7587 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7590 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberBySemantic(
7591 ID3D10EffectRasterizerVariable *iface, const char *semantic)
7593 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7596 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetElement(
7597 ID3D10EffectRasterizerVariable *iface, UINT index)
7599 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7602 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetParentConstantBuffer(
7603 ID3D10EffectRasterizerVariable *iface)
7605 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7608 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsScalar(
7609 ID3D10EffectRasterizerVariable *iface)
7611 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7614 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsVector(
7615 ID3D10EffectRasterizerVariable *iface)
7617 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7620 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsMatrix(
7621 ID3D10EffectRasterizerVariable *iface)
7623 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7626 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsString(
7627 ID3D10EffectRasterizerVariable *iface)
7629 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7632 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsShaderResource(
7633 ID3D10EffectRasterizerVariable *iface)
7635 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7638 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsRenderTargetView(
7639 ID3D10EffectRasterizerVariable *iface)
7641 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7644 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsDepthStencilView(
7645 ID3D10EffectRasterizerVariable *iface)
7647 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7650 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsConstantBuffer(
7651 ID3D10EffectRasterizerVariable *iface)
7653 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7656 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsShader(
7657 ID3D10EffectRasterizerVariable *iface)
7659 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7662 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsBlend(
7663 ID3D10EffectRasterizerVariable *iface)
7665 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7668 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsDepthStencil(
7669 ID3D10EffectRasterizerVariable *iface)
7671 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7674 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsRasterizer(
7675 ID3D10EffectRasterizerVariable *iface)
7677 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7680 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsSampler(
7681 ID3D10EffectRasterizerVariable *iface)
7683 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7686 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_SetRawValue(ID3D10EffectRasterizerVariable *iface,
7687 void *data, UINT offset, UINT count)
7689 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7692 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetRawValue(ID3D10EffectRasterizerVariable *iface,
7693 void *data, UINT offset, UINT count)
7695 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7698 /* ID3D10EffectRasterizerVariable methods */
7700 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetRasterizerState(ID3D10EffectRasterizerVariable *iface,
7701 UINT index, ID3D10RasterizerState **rasterizer_state)
7703 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7705 TRACE("iface %p, index %u, rasterizer_state %p.\n", iface, index, rasterizer_state);
7707 if (v->type->element_count)
7708 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7709 else if (index)
7710 return E_FAIL;
7712 if (v->type->basetype != D3D10_SVT_RASTERIZER)
7714 WARN("Variable is not a rasterizer state.\n");
7715 return E_FAIL;
7718 if ((*rasterizer_state = v->u.state.object.rasterizer))
7719 ID3D10RasterizerState_AddRef(*rasterizer_state);
7721 return S_OK;
7724 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetBackingStore(ID3D10EffectRasterizerVariable *iface,
7725 UINT index, D3D10_RASTERIZER_DESC *desc)
7727 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7729 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7731 if (v->type->element_count)
7732 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7734 if (v->type->basetype != D3D10_SVT_RASTERIZER)
7736 WARN("Variable is not a rasterizer state.\n");
7737 return E_FAIL;
7740 *desc = v->u.state.desc.rasterizer;
7742 return S_OK;
7746 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl =
7748 /* ID3D10EffectVariable methods */
7749 d3d10_effect_rasterizer_variable_IsValid,
7750 d3d10_effect_rasterizer_variable_GetType,
7751 d3d10_effect_rasterizer_variable_GetDesc,
7752 d3d10_effect_rasterizer_variable_GetAnnotationByIndex,
7753 d3d10_effect_rasterizer_variable_GetAnnotationByName,
7754 d3d10_effect_rasterizer_variable_GetMemberByIndex,
7755 d3d10_effect_rasterizer_variable_GetMemberByName,
7756 d3d10_effect_rasterizer_variable_GetMemberBySemantic,
7757 d3d10_effect_rasterizer_variable_GetElement,
7758 d3d10_effect_rasterizer_variable_GetParentConstantBuffer,
7759 d3d10_effect_rasterizer_variable_AsScalar,
7760 d3d10_effect_rasterizer_variable_AsVector,
7761 d3d10_effect_rasterizer_variable_AsMatrix,
7762 d3d10_effect_rasterizer_variable_AsString,
7763 d3d10_effect_rasterizer_variable_AsShaderResource,
7764 d3d10_effect_rasterizer_variable_AsRenderTargetView,
7765 d3d10_effect_rasterizer_variable_AsDepthStencilView,
7766 d3d10_effect_rasterizer_variable_AsConstantBuffer,
7767 d3d10_effect_rasterizer_variable_AsShader,
7768 d3d10_effect_rasterizer_variable_AsBlend,
7769 d3d10_effect_rasterizer_variable_AsDepthStencil,
7770 d3d10_effect_rasterizer_variable_AsRasterizer,
7771 d3d10_effect_rasterizer_variable_AsSampler,
7772 d3d10_effect_rasterizer_variable_SetRawValue,
7773 d3d10_effect_rasterizer_variable_GetRawValue,
7774 /* ID3D10EffectRasterizerVariable methods */
7775 d3d10_effect_rasterizer_variable_GetRasterizerState,
7776 d3d10_effect_rasterizer_variable_GetBackingStore,
7779 /* ID3D10EffectVariable methods */
7781 static BOOL STDMETHODCALLTYPE d3d10_effect_sampler_variable_IsValid(ID3D10EffectSamplerVariable *iface)
7783 TRACE("iface %p\n", iface);
7785 return (struct d3d10_effect_variable *)iface != &null_sampler_variable;
7788 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetType(
7789 ID3D10EffectSamplerVariable *iface)
7791 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7794 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetDesc(ID3D10EffectSamplerVariable *iface,
7795 D3D10_EFFECT_VARIABLE_DESC *desc)
7797 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7800 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetAnnotationByIndex(
7801 ID3D10EffectSamplerVariable *iface, UINT index)
7803 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7806 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetAnnotationByName(
7807 ID3D10EffectSamplerVariable *iface, const char *name)
7809 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7812 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberByIndex(
7813 ID3D10EffectSamplerVariable *iface, UINT index)
7815 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7818 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberByName(
7819 ID3D10EffectSamplerVariable *iface, const char *name)
7821 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7824 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberBySemantic(
7825 ID3D10EffectSamplerVariable *iface, const char *semantic)
7827 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7830 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetElement(
7831 ID3D10EffectSamplerVariable *iface, UINT index)
7833 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7836 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetParentConstantBuffer(
7837 ID3D10EffectSamplerVariable *iface)
7839 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7842 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsScalar(
7843 ID3D10EffectSamplerVariable *iface)
7845 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7848 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsVector(
7849 ID3D10EffectSamplerVariable *iface)
7851 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7854 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsMatrix(
7855 ID3D10EffectSamplerVariable *iface)
7857 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7860 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsString(
7861 ID3D10EffectSamplerVariable *iface)
7863 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7866 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsShaderResource(
7867 ID3D10EffectSamplerVariable *iface)
7869 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7872 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsRenderTargetView(
7873 ID3D10EffectSamplerVariable *iface)
7875 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7878 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsDepthStencilView(
7879 ID3D10EffectSamplerVariable *iface)
7881 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7884 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsConstantBuffer(
7885 ID3D10EffectSamplerVariable *iface)
7887 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7890 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsShader(
7891 ID3D10EffectSamplerVariable *iface)
7893 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7896 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsBlend(
7897 ID3D10EffectSamplerVariable *iface)
7899 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7902 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsDepthStencil(
7903 ID3D10EffectSamplerVariable *iface)
7905 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7908 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsRasterizer(
7909 ID3D10EffectSamplerVariable *iface)
7911 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7914 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsSampler(
7915 ID3D10EffectSamplerVariable *iface)
7917 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7920 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_SetRawValue(ID3D10EffectSamplerVariable *iface,
7921 void *data, UINT offset, UINT count)
7923 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7926 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetRawValue(ID3D10EffectSamplerVariable *iface,
7927 void *data, UINT offset, UINT count)
7929 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7932 /* ID3D10EffectSamplerVariable methods */
7934 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetSampler(ID3D10EffectSamplerVariable *iface,
7935 UINT index, ID3D10SamplerState **sampler)
7937 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7939 TRACE("iface %p, index %u, sampler %p.\n", iface, index, sampler);
7941 if (v->type->element_count)
7942 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7943 else if (index)
7944 return E_FAIL;
7946 if (v->type->basetype != D3D10_SVT_SAMPLER)
7948 WARN("Variable is not a sampler state.\n");
7949 return E_FAIL;
7952 if ((*sampler = v->u.state.object.sampler))
7953 ID3D10SamplerState_AddRef(*sampler);
7955 return S_OK;
7958 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetBackingStore(ID3D10EffectSamplerVariable *iface,
7959 UINT index, D3D10_SAMPLER_DESC *desc)
7961 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable((ID3D10EffectVariable *)iface);
7963 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7965 if (v->type->element_count)
7966 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7968 if (v->type->basetype != D3D10_SVT_SAMPLER)
7970 WARN("Variable is not a sampler state.\n");
7971 return E_FAIL;
7974 *desc = v->u.state.desc.sampler;
7976 return S_OK;
7980 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl =
7982 /* ID3D10EffectVariable methods */
7983 d3d10_effect_sampler_variable_IsValid,
7984 d3d10_effect_sampler_variable_GetType,
7985 d3d10_effect_sampler_variable_GetDesc,
7986 d3d10_effect_sampler_variable_GetAnnotationByIndex,
7987 d3d10_effect_sampler_variable_GetAnnotationByName,
7988 d3d10_effect_sampler_variable_GetMemberByIndex,
7989 d3d10_effect_sampler_variable_GetMemberByName,
7990 d3d10_effect_sampler_variable_GetMemberBySemantic,
7991 d3d10_effect_sampler_variable_GetElement,
7992 d3d10_effect_sampler_variable_GetParentConstantBuffer,
7993 d3d10_effect_sampler_variable_AsScalar,
7994 d3d10_effect_sampler_variable_AsVector,
7995 d3d10_effect_sampler_variable_AsMatrix,
7996 d3d10_effect_sampler_variable_AsString,
7997 d3d10_effect_sampler_variable_AsShaderResource,
7998 d3d10_effect_sampler_variable_AsRenderTargetView,
7999 d3d10_effect_sampler_variable_AsDepthStencilView,
8000 d3d10_effect_sampler_variable_AsConstantBuffer,
8001 d3d10_effect_sampler_variable_AsShader,
8002 d3d10_effect_sampler_variable_AsBlend,
8003 d3d10_effect_sampler_variable_AsDepthStencil,
8004 d3d10_effect_sampler_variable_AsRasterizer,
8005 d3d10_effect_sampler_variable_AsSampler,
8006 d3d10_effect_sampler_variable_SetRawValue,
8007 d3d10_effect_sampler_variable_GetRawValue,
8008 /* ID3D10EffectSamplerVariable methods */
8009 d3d10_effect_sampler_variable_GetSampler,
8010 d3d10_effect_sampler_variable_GetBackingStore,
8013 /* ID3D10EffectType methods */
8015 static inline struct d3d10_effect_type *impl_from_ID3D10EffectType(ID3D10EffectType *iface)
8017 return CONTAINING_RECORD(iface, struct d3d10_effect_type, ID3D10EffectType_iface);
8020 static BOOL STDMETHODCALLTYPE d3d10_effect_type_IsValid(ID3D10EffectType *iface)
8022 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8024 TRACE("iface %p\n", iface);
8026 return This != &null_type;
8029 static HRESULT STDMETHODCALLTYPE d3d10_effect_type_GetDesc(ID3D10EffectType *iface, D3D10_EFFECT_TYPE_DESC *desc)
8031 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8033 TRACE("iface %p, desc %p\n", iface, desc);
8035 if (This == &null_type)
8037 WARN("Null type specified\n");
8038 return E_FAIL;
8041 if (!desc)
8043 WARN("Invalid argument specified\n");
8044 return E_INVALIDARG;
8047 desc->TypeName = This->name;
8048 desc->Class = This->type_class;
8049 desc->Type = This->basetype;
8050 desc->Elements = This->element_count;
8051 desc->Members = This->member_count;
8052 desc->Rows = This->row_count;
8053 desc->Columns = This->column_count;
8054 desc->PackedSize = This->size_packed;
8055 desc->UnpackedSize = This->size_unpacked;
8056 desc->Stride = This->stride;
8058 return S_OK;
8061 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeByIndex(ID3D10EffectType *iface,
8062 UINT index)
8064 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8065 struct d3d10_effect_type *t;
8067 TRACE("iface %p, index %u\n", iface, index);
8069 if (index >= This->member_count)
8071 WARN("Invalid index specified\n");
8072 return &null_type.ID3D10EffectType_iface;
8075 t = (&This->members[index])->type;
8077 TRACE("Returning member %p, %s\n", t, debugstr_a(t->name));
8079 return &t->ID3D10EffectType_iface;
8082 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeByName(ID3D10EffectType *iface,
8083 const char *name)
8085 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8086 unsigned int i;
8088 TRACE("iface %p, name %s\n", iface, debugstr_a(name));
8090 if (!name)
8092 WARN("Invalid name specified\n");
8093 return &null_type.ID3D10EffectType_iface;
8096 for (i = 0; i < This->member_count; ++i)
8098 struct d3d10_effect_type_member *typem = &This->members[i];
8100 if (typem->name && !strcmp(typem->name, name))
8102 TRACE("Returning type %p.\n", typem->type);
8103 return &typem->type->ID3D10EffectType_iface;
8107 WARN("Invalid name specified\n");
8109 return &null_type.ID3D10EffectType_iface;
8112 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeBySemantic(ID3D10EffectType *iface,
8113 const char *semantic)
8115 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8116 unsigned int i;
8118 TRACE("iface %p, semantic %s\n", iface, debugstr_a(semantic));
8120 if (!semantic)
8122 WARN("Invalid semantic specified\n");
8123 return &null_type.ID3D10EffectType_iface;
8126 for (i = 0; i < This->member_count; ++i)
8128 struct d3d10_effect_type_member *typem = &This->members[i];
8130 if (typem->semantic && !strcmp(typem->semantic, semantic))
8132 TRACE("Returning type %p.\n", typem->type);
8133 return &typem->type->ID3D10EffectType_iface;
8137 WARN("Invalid semantic specified\n");
8139 return &null_type.ID3D10EffectType_iface;
8142 static const char * STDMETHODCALLTYPE d3d10_effect_type_GetMemberName(ID3D10EffectType *iface, UINT index)
8144 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8145 struct d3d10_effect_type_member *typem;
8147 TRACE("iface %p, index %u\n", iface, index);
8149 if (index >= This->member_count)
8151 WARN("Invalid index specified\n");
8152 return NULL;
8155 typem = &This->members[index];
8157 TRACE("Returning name %s\n", debugstr_a(typem->name));
8159 return typem->name;
8162 static const char * STDMETHODCALLTYPE d3d10_effect_type_GetMemberSemantic(ID3D10EffectType *iface, UINT index)
8164 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8165 struct d3d10_effect_type_member *typem;
8167 TRACE("iface %p, index %u\n", iface, index);
8169 if (index >= This->member_count)
8171 WARN("Invalid index specified\n");
8172 return NULL;
8175 typem = &This->members[index];
8177 TRACE("Returning semantic %s\n", debugstr_a(typem->semantic));
8179 return typem->semantic;
8182 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl =
8184 /* ID3D10EffectType */
8185 d3d10_effect_type_IsValid,
8186 d3d10_effect_type_GetDesc,
8187 d3d10_effect_type_GetMemberTypeByIndex,
8188 d3d10_effect_type_GetMemberTypeByName,
8189 d3d10_effect_type_GetMemberTypeBySemantic,
8190 d3d10_effect_type_GetMemberName,
8191 d3d10_effect_type_GetMemberSemantic,