d3d10/effect: Add a helper to read numeric values.
[wine.git] / dlls / d3d10 / effect.c
bloba9014b55bae8de3b664248ff59d9eeb352f9bb05
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>
24 #include <stdint.h>
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
28 #define MAKE_TAG(ch0, ch1, ch2, ch3) \
29 ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
30 ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
31 #define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
32 #define TAG_FX10 MAKE_TAG('F', 'X', '1', '0')
34 #define D3D10_FX10_TYPE_COLUMN_SHIFT 11
35 #define D3D10_FX10_TYPE_COLUMN_MASK (0x7 << D3D10_FX10_TYPE_COLUMN_SHIFT)
37 #define D3D10_FX10_TYPE_ROW_SHIFT 8
38 #define D3D10_FX10_TYPE_ROW_MASK (0x7 << D3D10_FX10_TYPE_ROW_SHIFT)
40 #define D3D10_FX10_TYPE_BASETYPE_SHIFT 3
41 #define D3D10_FX10_TYPE_BASETYPE_MASK (0x1f << D3D10_FX10_TYPE_BASETYPE_SHIFT)
43 #define D3D10_FX10_TYPE_CLASS_SHIFT 0
44 #define D3D10_FX10_TYPE_CLASS_MASK (0x7 << D3D10_FX10_TYPE_CLASS_SHIFT)
46 #define D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK 0x4000
48 static inline struct d3d10_effect *impl_from_ID3D10EffectPool(ID3D10EffectPool *iface)
50 return CONTAINING_RECORD(iface, struct d3d10_effect, ID3D10EffectPool_iface);
53 const struct ID3D10EffectPoolVtbl d3d10_effect_pool_vtbl;
54 static inline struct d3d10_effect *unsafe_impl_from_ID3D10EffectPool(ID3D10EffectPool *iface)
56 if (!iface || iface->lpVtbl != &d3d10_effect_pool_vtbl)
57 return NULL;
58 return CONTAINING_RECORD(iface, struct d3d10_effect, ID3D10EffectPool_iface);
61 static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl;
62 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v);
64 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl;
65 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl;
66 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl;
67 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl;
68 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl;
69 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl;
70 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl;
71 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl;
72 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl;
73 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl;
74 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl;
75 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl;
76 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl;
77 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl;
78 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl;
79 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl;
80 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl;
82 /* null objects - needed for invalid calls */
83 static struct d3d10_effect_technique null_technique = {{&d3d10_effect_technique_vtbl}};
84 static struct d3d10_effect_pass null_pass = {{&d3d10_effect_pass_vtbl}};
85 static struct d3d10_effect_type null_type = {{&d3d10_effect_type_vtbl}};
86 static struct d3d10_effect_variable null_local_buffer = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl},
87 &null_local_buffer, &null_type};
88 static struct d3d10_effect_variable null_variable = {{&d3d10_effect_variable_vtbl},
89 &null_local_buffer, &null_type};
90 static struct d3d10_effect_variable null_scalar_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl},
91 &null_local_buffer, &null_type};
92 static struct d3d10_effect_variable null_vector_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl},
93 &null_local_buffer, &null_type};
94 static struct d3d10_effect_variable null_matrix_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl},
95 &null_local_buffer, &null_type};
96 static struct d3d10_effect_variable null_string_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl},
97 &null_local_buffer, &null_type};
98 static struct d3d10_effect_variable null_render_target_view_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl},
99 &null_local_buffer, &null_type};
100 static struct d3d10_effect_variable null_depth_stencil_view_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl},
101 &null_local_buffer, &null_type};
102 static struct d3d10_effect_variable null_shader_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
103 &null_local_buffer, &null_type};
104 static struct d3d10_effect_variable null_blend_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl},
105 &null_local_buffer, &null_type};
106 static struct d3d10_effect_variable null_depth_stencil_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl},
107 &null_local_buffer, &null_type};
108 static struct d3d10_effect_variable null_rasterizer_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl},
109 &null_local_buffer, &null_type};
110 static struct d3d10_effect_variable null_sampler_variable = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl},
111 &null_local_buffer, &null_type};
113 static ID3D10ShaderResourceView *null_srvs[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
115 static struct d3d10_effect_variable null_shader_resource_variable =
117 .ID3D10EffectVariable_iface.lpVtbl = (ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl,
118 .buffer = &null_local_buffer,
119 .type = &null_type,
120 .u.resource.srv = null_srvs,
123 /* anonymous_shader_type and anonymous_shader */
124 static char anonymous_name[] = "$Anonymous";
125 static char anonymous_vertexshader_name[] = "vertexshader";
126 static char anonymous_pixelshader_name[] = "pixelshader";
127 static char anonymous_geometryshader_name[] = "geometryshader";
128 static struct d3d10_effect_type anonymous_vs_type = {{&d3d10_effect_type_vtbl},
129 anonymous_vertexshader_name, D3D10_SVT_VERTEXSHADER, D3D10_SVC_OBJECT};
130 static struct d3d10_effect_type anonymous_ps_type = {{&d3d10_effect_type_vtbl},
131 anonymous_pixelshader_name, D3D10_SVT_PIXELSHADER, D3D10_SVC_OBJECT};
132 static struct d3d10_effect_type anonymous_gs_type = {{&d3d10_effect_type_vtbl},
133 anonymous_geometryshader_name, D3D10_SVT_GEOMETRYSHADER, D3D10_SVC_OBJECT};
134 static struct d3d10_effect_variable anonymous_vs = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
135 &null_local_buffer, &anonymous_vs_type, anonymous_name};
136 static struct d3d10_effect_variable anonymous_ps = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
137 &null_local_buffer, &anonymous_ps_type, anonymous_name};
138 static struct d3d10_effect_variable anonymous_gs = {{(const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl},
139 &null_local_buffer, &anonymous_gs_type, anonymous_name};
141 static struct d3d10_effect_type *get_fx10_type(struct d3d10_effect *effect,
142 const char *data, size_t data_size, DWORD offset);
144 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectVariable(ID3D10EffectVariable *iface)
146 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
149 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectShaderVariable(ID3D10EffectShaderVariable *iface)
151 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
154 static struct d3d10_effect_variable * d3d10_array_get_element(struct d3d10_effect_variable *v,
155 unsigned int index)
157 if (!v->type->element_count) return v;
158 return &v->elements[index];
161 enum d3d10_effect_container_type
163 D3D10_C_NONE,
164 D3D10_C_PASS,
165 D3D10_C_RASTERIZER,
166 D3D10_C_DEPTHSTENCIL,
167 D3D10_C_BLEND,
168 D3D10_C_SAMPLER,
171 static enum d3d10_effect_container_type get_var_container_type(const struct d3d10_effect_variable *v)
173 switch (v->type->basetype)
175 case D3D10_SVT_DEPTHSTENCIL: return D3D10_C_DEPTHSTENCIL;
176 case D3D10_SVT_BLEND: return D3D10_C_BLEND;
177 case D3D10_SVT_RASTERIZER: return D3D10_C_RASTERIZER;
178 case D3D10_SVT_SAMPLER: return D3D10_C_SAMPLER;
179 default: return D3D10_C_NONE;
183 struct d3d10_effect_state_property_info
185 UINT id;
186 const char *name;
187 D3D_SHADER_VARIABLE_TYPE type;
188 UINT size;
189 UINT count;
190 enum d3d10_effect_container_type container_type;
191 LONG offset;
192 LONG index_offset;
195 static const struct d3d10_effect_state_property_info property_infos[] =
197 {0x00, "Pass.RasterizerState", D3D10_SVT_RASTERIZER, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, rasterizer) },
198 {0x01, "Pass.DepthStencilState", D3D10_SVT_DEPTHSTENCIL, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, depth_stencil) },
199 {0x02, "Pass.BlendState", D3D10_SVT_BLEND, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, blend) },
200 {0x03, "Pass.RenderTargets", D3D10_SVT_RENDERTARGETVIEW, 1, 8, D3D10_C_PASS, ~0u },
201 {0x04, "Pass.DepthStencilView", D3D10_SVT_DEPTHSTENCILVIEW, 1, 1, D3D10_C_PASS, ~0u },
202 {0x05, "Pass.Unknown5", D3D10_SVT_VOID, 0, 0, D3D10_C_PASS, ~0u },
203 {0x06, "Pass.VertexShader", D3D10_SVT_VERTEXSHADER, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, vs.shader),
204 FIELD_OFFSET(struct d3d10_effect_pass, vs.index) },
205 {0x07, "Pass.PixelShader", D3D10_SVT_PIXELSHADER, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, ps.shader),
206 FIELD_OFFSET(struct d3d10_effect_pass, ps.index) },
207 {0x08, "Pass.GeometryShader", D3D10_SVT_GEOMETRYSHADER, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, gs.shader),
208 FIELD_OFFSET(struct d3d10_effect_pass, gs.index) },
209 {0x09, "Pass.StencilRef", D3D10_SVT_UINT, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, stencil_ref) },
210 {0x0a, "Pass.BlendFactor", D3D10_SVT_FLOAT, 4, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, blend_factor) },
211 {0x0b, "Pass.SampleMask", D3D10_SVT_UINT, 1, 1, D3D10_C_PASS, FIELD_OFFSET(struct d3d10_effect_pass, sample_mask) },
213 {0x0c, "RasterizerState.FillMode", D3D10_SVT_INT, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, FillMode) },
214 {0x0d, "RasterizerState.CullMode", D3D10_SVT_INT, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, CullMode) },
215 {0x0e, "RasterizerState.FrontCounterClockwise", D3D10_SVT_BOOL, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, FrontCounterClockwise) },
216 {0x0f, "RasterizerState.DepthBias", D3D10_SVT_INT, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, DepthBias) },
217 {0x10, "RasterizerState.DepthBiasClamp", D3D10_SVT_FLOAT, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, DepthBiasClamp) },
218 {0x11, "RasterizerState.SlopeScaledDepthBias", D3D10_SVT_FLOAT, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, SlopeScaledDepthBias) },
219 {0x12, "RasterizerState.DepthClipEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, DepthClipEnable) },
220 {0x13, "RasterizerState.ScissorEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, ScissorEnable) },
221 {0x14, "RasterizerState.MultisampleEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, MultisampleEnable) },
222 {0x15, "RasterizerState.AntialiasedLineEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_RASTERIZER, FIELD_OFFSET(D3D10_RASTERIZER_DESC, AntialiasedLineEnable) },
224 {0x16, "DepthStencilState.DepthEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthEnable) },
225 {0x17, "DepthStencilState.DepthWriteMask", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthWriteMask) },
226 {0x18, "DepthStencilState.DepthFunc", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, DepthFunc) },
227 {0x19, "DepthStencilState.StencilEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, StencilEnable) },
228 {0x1a, "DepthStencilState.StencilReadMask", D3D10_SVT_UINT8, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, StencilReadMask) },
229 {0x1b, "DepthStencilState.StencilWriteMask", D3D10_SVT_UINT8, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, StencilWriteMask) },
230 {0x1c, "DepthStencilState.FrontFaceStencilFail", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilFailOp) },
231 {0x1d, "DepthStencilState.FrontFaceStencilDepthFail", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilDepthFailOp)},
232 {0x1e, "DepthStencilState.FrontFaceStencilPass", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilPassOp) },
233 {0x1f, "DepthStencilState.FrontFaceStencilFunc", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, FrontFace.StencilFunc) },
234 {0x20, "DepthStencilState.BackFaceStencilFail", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilFailOp) },
235 {0x21, "DepthStencilState.BackFaceStencilDepthFail", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilDepthFailOp) },
236 {0x22, "DepthStencilState.BackFaceStencilPass", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilPassOp) },
237 {0x23, "DepthStencilState.BackFaceStencilFunc", D3D10_SVT_INT, 1, 1, D3D10_C_DEPTHSTENCIL, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC, BackFace.StencilFunc) },
239 {0x24, "BlendState.AlphaToCoverageEnable", D3D10_SVT_BOOL, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, AlphaToCoverageEnable) },
240 {0x25, "BlendState.BlendEnable", D3D10_SVT_BOOL, 1, 8, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, BlendEnable) },
241 {0x26, "BlendState.SrcBlend", D3D10_SVT_INT, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, SrcBlend) },
242 {0x27, "BlendState.DestBlend", D3D10_SVT_INT, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, DestBlend) },
243 {0x28, "BlendState.BlendOp", D3D10_SVT_INT, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, BlendOp) },
244 {0x29, "BlendState.SrcBlendAlpha", D3D10_SVT_INT, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, SrcBlendAlpha) },
245 {0x2a, "BlendState.DestBlendAlpha", D3D10_SVT_INT, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, DestBlendAlpha) },
246 {0x2b, "BlendState.BlendOpAlpha", D3D10_SVT_INT, 1, 1, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, BlendOpAlpha) },
247 {0x2c, "BlendState.RenderTargetWriteMask", D3D10_SVT_UINT8, 1, 8, D3D10_C_BLEND, FIELD_OFFSET(D3D10_BLEND_DESC, RenderTargetWriteMask) },
249 {0x2d, "SamplerState.Filter", D3D10_SVT_INT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.Filter) },
250 {0x2e, "SamplerState.AddressU", D3D10_SVT_INT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.AddressU) },
251 {0x2f, "SamplerState.AddressV", D3D10_SVT_INT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.AddressV) },
252 {0x30, "SamplerState.AddressW", D3D10_SVT_INT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.AddressW) },
253 {0x31, "SamplerState.MipLODBias", D3D10_SVT_FLOAT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.MipLODBias) },
254 {0x32, "SamplerState.MaxAnisotropy", D3D10_SVT_UINT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.MaxAnisotropy) },
255 {0x33, "SamplerState.ComparisonFunc", D3D10_SVT_INT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.ComparisonFunc) },
256 {0x34, "SamplerState.BorderColor", D3D10_SVT_FLOAT, 4, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.BorderColor) },
257 {0x35, "SamplerState.MinLOD", D3D10_SVT_FLOAT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.MinLOD) },
258 {0x36, "SamplerState.MaxLOD", D3D10_SVT_FLOAT, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, desc.MaxLOD) },
259 {0x37, "SamplerState.Texture", D3D10_SVT_TEXTURE, 1, 1, D3D10_C_SAMPLER, FIELD_OFFSET(struct d3d10_effect_sampler_desc, texture) },
262 static const D3D10_RASTERIZER_DESC default_rasterizer_desc =
264 D3D10_FILL_SOLID,
265 D3D10_CULL_BACK,
266 FALSE,
268 0.0f,
269 0.0f,
270 TRUE,
271 FALSE,
272 FALSE,
273 FALSE,
276 static const D3D10_DEPTH_STENCIL_DESC default_depth_stencil_desc =
278 TRUE,
279 D3D10_DEPTH_WRITE_MASK_ALL,
280 D3D10_COMPARISON_LESS,
281 FALSE,
282 D3D10_DEFAULT_STENCIL_READ_MASK,
283 D3D10_DEFAULT_STENCIL_WRITE_MASK,
284 {D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_COMPARISON_ALWAYS},
285 {D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_STENCIL_OP_KEEP, D3D10_COMPARISON_ALWAYS},
288 static const D3D10_BLEND_DESC default_blend_desc =
290 FALSE,
291 {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
292 D3D10_BLEND_SRC_ALPHA,
293 D3D10_BLEND_INV_SRC_ALPHA,
294 D3D10_BLEND_OP_ADD,
295 D3D10_BLEND_SRC_ALPHA,
296 D3D10_BLEND_INV_SRC_ALPHA,
297 D3D10_BLEND_OP_ADD,
298 {0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf},
301 static const D3D10_SAMPLER_DESC default_sampler_desc =
303 D3D10_FILTER_MIN_MAG_MIP_POINT,
304 D3D10_TEXTURE_ADDRESS_WRAP,
305 D3D10_TEXTURE_ADDRESS_WRAP,
306 D3D10_TEXTURE_ADDRESS_WRAP,
307 0.0f,
309 D3D10_COMPARISON_NEVER,
310 {0.0f, 0.0f, 0.0f, 0.0f},
311 0.0f,
312 FLT_MAX,
315 struct d3d10_effect_state_storage_info
317 D3D_SHADER_VARIABLE_TYPE id;
318 SIZE_T size;
319 const void *default_state;
322 static const struct d3d10_effect_state_storage_info d3d10_effect_state_storage_info[] =
324 {D3D10_SVT_RASTERIZER, sizeof(default_rasterizer_desc), &default_rasterizer_desc },
325 {D3D10_SVT_DEPTHSTENCIL, sizeof(default_depth_stencil_desc), &default_depth_stencil_desc},
326 {D3D10_SVT_BLEND, sizeof(default_blend_desc), &default_blend_desc },
327 {D3D10_SVT_SAMPLER, sizeof(default_sampler_desc), &default_sampler_desc },
330 #define WINE_D3D10_TO_STR(x) case x: return #x
332 static const char *debug_d3d10_shader_variable_class(D3D10_SHADER_VARIABLE_CLASS c)
334 switch (c)
336 WINE_D3D10_TO_STR(D3D10_SVC_SCALAR);
337 WINE_D3D10_TO_STR(D3D10_SVC_VECTOR);
338 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_ROWS);
339 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_COLUMNS);
340 WINE_D3D10_TO_STR(D3D10_SVC_OBJECT);
341 WINE_D3D10_TO_STR(D3D10_SVC_STRUCT);
342 default:
343 FIXME("Unrecognised D3D10_SHADER_VARIABLE_CLASS %#x.\n", c);
344 return "unrecognised";
348 static const char *debug_d3d10_shader_variable_type(D3D10_SHADER_VARIABLE_TYPE t)
350 switch (t)
352 WINE_D3D10_TO_STR(D3D10_SVT_VOID);
353 WINE_D3D10_TO_STR(D3D10_SVT_BOOL);
354 WINE_D3D10_TO_STR(D3D10_SVT_INT);
355 WINE_D3D10_TO_STR(D3D10_SVT_FLOAT);
356 WINE_D3D10_TO_STR(D3D10_SVT_STRING);
357 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE);
358 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1D);
359 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2D);
360 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE3D);
361 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBE);
362 WINE_D3D10_TO_STR(D3D10_SVT_SAMPLER);
363 WINE_D3D10_TO_STR(D3D10_SVT_PIXELSHADER);
364 WINE_D3D10_TO_STR(D3D10_SVT_VERTEXSHADER);
365 WINE_D3D10_TO_STR(D3D10_SVT_UINT);
366 WINE_D3D10_TO_STR(D3D10_SVT_UINT8);
367 WINE_D3D10_TO_STR(D3D10_SVT_GEOMETRYSHADER);
368 WINE_D3D10_TO_STR(D3D10_SVT_RASTERIZER);
369 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCIL);
370 WINE_D3D10_TO_STR(D3D10_SVT_BLEND);
371 WINE_D3D10_TO_STR(D3D10_SVT_BUFFER);
372 WINE_D3D10_TO_STR(D3D10_SVT_CBUFFER);
373 WINE_D3D10_TO_STR(D3D10_SVT_TBUFFER);
374 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1DARRAY);
375 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DARRAY);
376 WINE_D3D10_TO_STR(D3D10_SVT_RENDERTARGETVIEW);
377 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCILVIEW);
378 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMS);
379 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMSARRAY);
380 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBEARRAY);
381 default:
382 FIXME("Unrecognised D3D10_SHADER_VARIABLE_TYPE %#x.\n", t);
383 return "unrecognised";
387 #undef WINE_D3D10_TO_STR
389 static BOOL read_float_value(uint32_t value, D3D_SHADER_VARIABLE_TYPE in_type,
390 float *out_data, unsigned int out_idx)
392 switch (in_type)
394 case D3D10_SVT_FLOAT:
395 out_data[out_idx] = *(float *)&value;
396 return TRUE;
398 case D3D10_SVT_INT:
399 out_data[out_idx] = (INT)value;
400 return TRUE;
402 case D3D10_SVT_UINT:
403 out_data[out_idx] = value;
404 return TRUE;
406 default:
407 FIXME("Unhandled in_type %#x.\n", in_type);
408 return FALSE;
412 static BOOL read_int32_value(uint32_t value, D3D_SHADER_VARIABLE_TYPE in_type,
413 int *out_data, unsigned int out_idx)
415 switch (in_type)
417 case D3D10_SVT_FLOAT:
418 out_data[out_idx] = *(float *)&value;
419 return TRUE;
421 case D3D10_SVT_INT:
422 case D3D10_SVT_UINT:
423 case D3D10_SVT_BOOL:
424 out_data[out_idx] = value;
425 return TRUE;
427 default:
428 FIXME("Unhandled in_type %#x.\n", in_type);
429 return FALSE;
433 static BOOL read_int8_value(uint32_t value, D3D_SHADER_VARIABLE_TYPE in_type,
434 INT8 *out_data, unsigned int out_idx)
436 switch (in_type)
438 case D3D10_SVT_INT:
439 case D3D10_SVT_UINT:
440 out_data[out_idx] = value;
441 return TRUE;
443 default:
444 FIXME("Unhandled in_type %#x.\n", in_type);
445 return FALSE;
449 static BOOL d3d10_effect_read_numeric_value(uint32_t value, D3D_SHADER_VARIABLE_TYPE in_type,
450 D3D_SHADER_VARIABLE_TYPE out_type, void *out_data, unsigned int out_idx)
452 switch (out_type)
454 case D3D10_SVT_FLOAT:
455 return read_float_value(value, in_type, out_data, out_idx);
456 case D3D10_SVT_INT:
457 case D3D10_SVT_UINT:
458 case D3D10_SVT_BOOL:
459 return read_int32_value(value, in_type, out_data, out_idx);
460 case D3D10_SVT_UINT8:
461 return read_int8_value(value, in_type, out_data, out_idx);
462 default:
463 FIXME("Unsupported property type %u.\n", out_type);
464 return FALSE;
468 static BOOL d3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
470 SIZE_T max_capacity, new_capacity;
471 void *new_elements;
473 if (count <= *capacity)
474 return TRUE;
476 max_capacity = ~(SIZE_T)0 / size;
477 if (count > max_capacity)
478 return FALSE;
480 new_capacity = max(1, *capacity);
481 while (new_capacity < count && new_capacity <= max_capacity / 2)
482 new_capacity *= 2;
483 if (new_capacity < count)
484 new_capacity = count;
486 if (!(new_elements = heap_realloc(*elements, new_capacity * size)))
487 return FALSE;
489 *elements = new_elements;
490 *capacity = new_capacity;
491 return TRUE;
494 static void read_dword(const char **ptr, DWORD *d)
496 memcpy(d, *ptr, sizeof(*d));
497 *ptr += sizeof(*d);
500 static BOOL require_space(size_t offset, size_t count, size_t size, size_t data_size)
502 return !count || (data_size - offset) / count >= size;
505 static void skip_dword_unknown(const char *location, const char **ptr, unsigned int count)
507 unsigned int i;
508 DWORD d;
510 FIXME("Skipping %u unknown DWORDs (%s):\n", count, location);
511 for (i = 0; i < count; ++i)
513 read_dword(ptr, &d);
514 FIXME("\t0x%08x\n", d);
518 static HRESULT parse_dxbc(const char *data, SIZE_T data_size,
519 HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx)
521 const char *ptr = data;
522 HRESULT hr = S_OK;
523 DWORD chunk_count;
524 DWORD total_size;
525 unsigned int i;
526 DWORD version;
527 DWORD tag;
529 if (!data)
531 WARN("No data supplied.\n");
532 return E_FAIL;
535 read_dword(&ptr, &tag);
536 TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
538 if (tag != TAG_DXBC)
540 WARN("Wrong tag.\n");
541 return E_FAIL;
544 skip_dword_unknown("DXBC checksum", &ptr, 4);
546 read_dword(&ptr, &version);
547 TRACE("version: %#x.\n", version);
548 if (version != 0x00000001)
550 WARN("Got unexpected DXBC version %#x.\n", version);
551 return E_FAIL;
554 read_dword(&ptr, &total_size);
555 TRACE("total size: %#x\n", total_size);
557 if (data_size != total_size)
559 WARN("Wrong size supplied.\n");
560 return E_FAIL;
563 read_dword(&ptr, &chunk_count);
564 TRACE("chunk count: %#x\n", chunk_count);
566 for (i = 0; i < chunk_count; ++i)
568 DWORD chunk_tag, chunk_size;
569 const char *chunk_ptr;
570 DWORD chunk_offset;
572 read_dword(&ptr, &chunk_offset);
573 TRACE("chunk %u at offset %#x\n", i, chunk_offset);
575 if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size))
577 WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size);
578 return E_FAIL;
581 chunk_ptr = data + chunk_offset;
583 read_dword(&chunk_ptr, &chunk_tag);
584 read_dword(&chunk_ptr, &chunk_size);
586 if (!require_space(chunk_ptr - data, 1, chunk_size, data_size))
588 WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n",
589 chunk_size, data_size, chunk_offset);
590 return E_FAIL;
593 if (FAILED(hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx)))
594 break;
597 return hr;
600 static BOOL fx10_get_string(const char *data, size_t data_size, DWORD offset, const char **s, size_t *l)
602 size_t len, max_len;
604 if (offset >= data_size)
606 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
607 return FALSE;
610 max_len = data_size - offset;
611 if (!(len = strnlen(data + offset, max_len)))
613 *s = NULL;
614 *l = 0;
615 return TRUE;
618 if (len == max_len)
619 return FALSE;
621 *s = data + offset;
622 *l = ++len;
624 return TRUE;
627 static BOOL fx10_copy_string(const char *data, size_t data_size, DWORD offset, char **s)
629 const char *p;
630 size_t len;
632 if (!fx10_get_string(data, data_size, offset, &p, &len))
633 return FALSE;
635 if (!p)
637 *s = NULL;
638 return TRUE;
641 if (!(*s = heap_alloc(len)))
643 ERR("Failed to allocate string memory.\n");
644 return FALSE;
647 memcpy(*s, p, len);
649 return TRUE;
652 static BOOL copy_name(const char *ptr, char **name)
654 size_t name_len;
656 if (!ptr) return TRUE;
658 name_len = strlen(ptr) + 1;
659 if (name_len == 1)
661 return TRUE;
664 if (!(*name = heap_alloc(name_len)))
666 ERR("Failed to allocate name memory.\n");
667 return FALSE;
670 memcpy(*name, ptr, name_len);
672 return TRUE;
675 static struct d3d10_effect_variable * d3d10_effect_get_buffer_by_name(struct d3d10_effect *effect,
676 const char *name)
678 unsigned int i;
680 for (i = 0; i < effect->local_buffer_count; ++i)
682 struct d3d10_effect_variable *l = &effect->local_buffers[i];
683 if (l->name && !strcmp(l->name, name))
684 return l;
687 return effect->pool ? d3d10_effect_get_buffer_by_name(effect->pool, name) : NULL;
690 static struct d3d10_effect_variable * d3d10_effect_get_variable_by_name(
691 const struct d3d10_effect *effect, const char *name)
693 struct d3d10_effect_variable *v;
694 unsigned int i, j;
696 for (i = 0; i < effect->local_buffer_count; ++i)
698 for (j = 0; j < effect->local_buffers[i].type->member_count; ++j)
700 v = &effect->local_buffers[i].members[j];
701 if (v->name && !strcmp(v->name, name))
702 return v;
706 for (i = 0; i < effect->local_variable_count; ++i)
708 struct d3d10_effect_variable *v = &effect->local_variables[i];
709 if (v->name && !strcmp(v->name, name))
710 return v;
713 return effect->pool ? d3d10_effect_get_variable_by_name(effect->pool, name) : NULL;
716 static HRESULT get_fx10_shader_resources(struct d3d10_effect_variable *v)
718 struct d3d10_effect_shader_variable *sv = &v->u.shader;
719 struct d3d10_effect_shader_resource *sr;
720 D3D10_SHADER_INPUT_BIND_DESC bind_desc;
721 D3D10_SHADER_DESC desc;
722 unsigned int i;
724 sv->reflection->lpVtbl->GetDesc(sv->reflection, &desc);
725 sv->resource_count = desc.BoundResources;
727 if (!(sv->resources = heap_calloc(sv->resource_count, sizeof(*sv->resources))))
729 ERR("Failed to allocate shader resource binding information memory.\n");
730 return E_OUTOFMEMORY;
733 for (i = 0; i < desc.BoundResources; ++i)
735 sv->reflection->lpVtbl->GetResourceBindingDesc(sv->reflection, i, &bind_desc);
736 sr = &sv->resources[i];
738 sr->in_type = bind_desc.Type;
739 sr->bind_point = bind_desc.BindPoint;
740 sr->bind_count = bind_desc.BindCount;
742 switch (bind_desc.Type)
744 case D3D10_SIT_CBUFFER:
745 case D3D10_SIT_TBUFFER:
746 if (sr->bind_count != 1)
748 WARN("Unexpected bind count %u for a buffer %s.\n", bind_desc.BindCount,
749 debugstr_a(bind_desc.Name));
750 return E_UNEXPECTED;
752 sr->variable = d3d10_effect_get_buffer_by_name(v->effect, bind_desc.Name);
753 break;
755 case D3D10_SIT_SAMPLER:
756 case D3D10_SIT_TEXTURE:
757 sr->variable = d3d10_effect_get_variable_by_name(v->effect, bind_desc.Name);
758 break;
760 default:
761 break;
764 if (!sr->variable)
766 WARN("Failed to find shader resource.\n");
767 return E_FAIL;
771 return S_OK;
774 struct d3d10_effect_so_decl
776 D3D10_SO_DECLARATION_ENTRY *entries;
777 SIZE_T capacity;
778 SIZE_T count;
779 unsigned int stride;
780 char *decl;
783 static void d3d10_effect_cleanup_so_decl(struct d3d10_effect_so_decl *so_decl)
785 heap_free(so_decl->entries);
786 heap_free(so_decl->decl);
787 memset(so_decl, 0, sizeof(*so_decl));
790 static HRESULT d3d10_effect_parse_stream_output_declaration(const char *decl,
791 struct d3d10_effect_so_decl *so_decl)
793 static const char * xyzw = "xyzw";
794 static const char * rgba = "rgba";
795 char *p, *ptr, *end, *next, *mask, *m, *slot;
796 unsigned int len = strlen(decl);
797 D3D10_SO_DECLARATION_ENTRY e;
799 memset(so_decl, 0, sizeof(*so_decl));
801 if (!(so_decl->decl = heap_alloc(len + 1)))
802 return E_OUTOFMEMORY;
803 memcpy(so_decl->decl, decl, len + 1);
805 p = so_decl->decl;
807 while (p && *p)
809 memset(&e, 0, sizeof(e));
811 end = strchr(p, ';');
812 next = end ? end + 1 : p + strlen(p);
814 len = next - p;
815 if (end) len--;
817 /* Remove leading and trailing spaces. */
818 while (len && isspace(*p)) { len--; p++; }
819 while (len && isspace(p[len - 1])) len--;
821 p[len] = 0;
823 /* Output slot */
824 if ((slot = strchr(p, ':')))
826 *slot = 0;
828 ptr = p;
829 while (*ptr)
831 if (!isdigit(*ptr))
833 WARN("Invalid output slot %s.\n", debugstr_a(p));
834 goto failed;
836 ptr++;
839 e.OutputSlot = atoi(p);
840 p = slot + 1;
843 /* Mask */
844 if ((mask = strchr(p, '.')))
846 *mask = 0; mask++;
848 if ((m = strstr(xyzw, mask)))
849 e.StartComponent = m - xyzw;
850 else if ((m = strstr(rgba, mask)))
851 e.StartComponent = m - rgba;
852 else
854 WARN("Invalid component mask %s.\n", debugstr_a(mask));
855 goto failed;
858 e.ComponentCount = strlen(mask);
860 else
862 e.StartComponent = 0;
863 e.ComponentCount = 4;
866 /* Semantic index and name */
867 len = strlen(p);
868 while (isdigit(p[len - 1]))
869 len--;
871 if (p[len])
873 e.SemanticIndex = atoi(&p[len]);
874 p[len] = 0;
877 e.SemanticName = stricmp(p, "$SKIP") ? p : NULL;
879 if (!d3d_array_reserve((void **)&so_decl->entries, &so_decl->capacity, so_decl->count + 1,
880 sizeof(*so_decl->entries)))
881 goto failed;
883 so_decl->entries[so_decl->count++] = e;
885 if (e.OutputSlot == 0)
886 so_decl->stride += e.ComponentCount * sizeof(float);
888 p = next;
891 return S_OK;
893 failed:
894 d3d10_effect_cleanup_so_decl(so_decl);
896 return E_FAIL;
899 static HRESULT parse_fx10_shader(const char *data, size_t data_size, DWORD offset, struct d3d10_effect_variable *v)
901 ID3D10Device *device = v->effect->device;
902 DWORD dxbc_size;
903 const char *ptr;
904 HRESULT hr;
906 if (v->effect->used_shader_current >= v->effect->used_shader_count)
908 WARN("Invalid shader? Used shader current(%u) >= used shader count(%u)\n", v->effect->used_shader_current, v->effect->used_shader_count);
909 return E_FAIL;
912 v->effect->used_shaders[v->effect->used_shader_current] = v;
913 ++v->effect->used_shader_current;
915 if (offset >= data_size || !require_space(offset, 1, sizeof(dxbc_size), data_size))
917 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
918 return E_FAIL;
921 ptr = data + offset;
922 read_dword(&ptr, &dxbc_size);
923 TRACE("dxbc size: %#x\n", dxbc_size);
925 if (!require_space(ptr - data, 1, dxbc_size, data_size))
927 WARN("Invalid dxbc size %#x (data size %#lx, offset %#x).\n", offset, (long)data_size, offset);
928 return E_FAIL;
931 /* We got a shader VertexShader vs = NULL, so it is fine to skip this. */
932 if (!dxbc_size) return S_OK;
934 if (FAILED(hr = D3D10ReflectShader(ptr, dxbc_size, &v->u.shader.reflection)))
935 return hr;
937 D3DGetInputSignatureBlob(ptr, dxbc_size, &v->u.shader.input_signature);
939 if (FAILED(hr = D3DCreateBlob(dxbc_size, &v->u.shader.bytecode)))
940 return hr;
942 memcpy(ID3D10Blob_GetBufferPointer(v->u.shader.bytecode), ptr, dxbc_size);
944 if (FAILED(hr = get_fx10_shader_resources(v)))
945 return hr;
947 switch (v->type->basetype)
949 case D3D10_SVT_VERTEXSHADER:
950 hr = ID3D10Device_CreateVertexShader(device, ptr, dxbc_size, &v->u.shader.shader.vs);
951 break;
953 case D3D10_SVT_PIXELSHADER:
954 hr = ID3D10Device_CreatePixelShader(device, ptr, dxbc_size, &v->u.shader.shader.ps);
955 break;
957 case D3D10_SVT_GEOMETRYSHADER:
958 if (v->u.shader.stream_output_declaration)
960 struct d3d10_effect_so_decl so_decl;
962 if (FAILED(hr = d3d10_effect_parse_stream_output_declaration(v->u.shader.stream_output_declaration, &so_decl)))
964 WARN("Failed to parse stream output declaration, hr %#x.\n", hr);
965 break;
968 hr = ID3D10Device_CreateGeometryShaderWithStreamOutput(device, ptr, dxbc_size,
969 so_decl.entries, so_decl.count, so_decl.stride, &v->u.shader.shader.gs);
971 d3d10_effect_cleanup_so_decl(&so_decl);
973 else
974 hr = ID3D10Device_CreateGeometryShader(device, ptr, dxbc_size, &v->u.shader.shader.gs);
975 break;
977 default:
978 ERR("This should not happen!\n");
979 return E_FAIL;
982 return hr;
985 static D3D10_SHADER_VARIABLE_CLASS d3d10_variable_class(DWORD c, BOOL is_column_major)
987 switch (c)
989 case 1: return D3D10_SVC_SCALAR;
990 case 2: return D3D10_SVC_VECTOR;
991 case 3: if (is_column_major) return D3D10_SVC_MATRIX_COLUMNS;
992 else return D3D10_SVC_MATRIX_ROWS;
993 default:
994 FIXME("Unknown variable class %#x.\n", c);
995 return 0;
999 static D3D10_SHADER_VARIABLE_TYPE d3d10_variable_type(DWORD t, BOOL is_object,
1000 unsigned int *flags)
1002 *flags = 0;
1004 if(is_object)
1006 switch (t)
1008 case 1: return D3D10_SVT_STRING;
1009 case 2: return D3D10_SVT_BLEND;
1010 case 3: return D3D10_SVT_DEPTHSTENCIL;
1011 case 4: return D3D10_SVT_RASTERIZER;
1012 case 5: return D3D10_SVT_PIXELSHADER;
1013 case 6: return D3D10_SVT_VERTEXSHADER;
1014 case 7: return D3D10_SVT_GEOMETRYSHADER;
1015 case 8:
1016 *flags = D3D10_EOT_FLAG_GS_SO;
1017 return D3D10_SVT_GEOMETRYSHADER;
1019 case 9: return D3D10_SVT_TEXTURE;
1020 case 10: return D3D10_SVT_TEXTURE1D;
1021 case 11: return D3D10_SVT_TEXTURE1DARRAY;
1022 case 12: return D3D10_SVT_TEXTURE2D;
1023 case 13: return D3D10_SVT_TEXTURE2DARRAY;
1024 case 14: return D3D10_SVT_TEXTURE2DMS;
1025 case 15: return D3D10_SVT_TEXTURE2DMSARRAY;
1026 case 16: return D3D10_SVT_TEXTURE3D;
1027 case 17: return D3D10_SVT_TEXTURECUBE;
1029 case 19: return D3D10_SVT_RENDERTARGETVIEW;
1030 case 20: return D3D10_SVT_DEPTHSTENCILVIEW;
1031 case 21: return D3D10_SVT_SAMPLER;
1032 case 22: return D3D10_SVT_BUFFER;
1033 default:
1034 FIXME("Unknown variable type %#x.\n", t);
1035 return D3D10_SVT_VOID;
1038 else
1040 switch (t)
1042 case 1: return D3D10_SVT_FLOAT;
1043 case 2: return D3D10_SVT_INT;
1044 case 3: return D3D10_SVT_UINT;
1045 case 4: return D3D10_SVT_BOOL;
1046 default:
1047 FIXME("Unknown variable type %#x.\n", t);
1048 return D3D10_SVT_VOID;
1053 static HRESULT parse_fx10_type(const char *data, size_t data_size, DWORD offset, struct d3d10_effect_type *t)
1055 DWORD typeinfo, type_flags, type_kind;
1056 const char *ptr;
1057 unsigned int i;
1059 if (offset >= data_size || !require_space(offset, 6, sizeof(DWORD), data_size))
1061 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1062 return E_FAIL;
1065 ptr = data + offset;
1066 read_dword(&ptr, &offset);
1067 TRACE("Type name at offset %#x.\n", offset);
1069 if (!fx10_copy_string(data, data_size, offset, &t->name))
1071 ERR("Failed to copy name.\n");
1072 return E_OUTOFMEMORY;
1074 TRACE("Type name: %s.\n", debugstr_a(t->name));
1076 read_dword(&ptr, &type_kind);
1077 TRACE("Kind: %u.\n", type_kind);
1079 read_dword(&ptr, &t->element_count);
1080 TRACE("Element count: %u.\n", t->element_count);
1082 read_dword(&ptr, &t->size_unpacked);
1083 TRACE("Unpacked size: %#x.\n", t->size_unpacked);
1085 read_dword(&ptr, &t->stride);
1086 TRACE("Stride: %#x.\n", t->stride);
1088 read_dword(&ptr, &t->size_packed);
1089 TRACE("Packed size %#x.\n", t->size_packed);
1091 switch (type_kind)
1093 case 1:
1094 TRACE("Type is numeric.\n");
1096 if (!require_space(ptr - data, 1, sizeof(typeinfo), data_size))
1098 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1099 return E_FAIL;
1102 read_dword(&ptr, &typeinfo);
1103 t->member_count = 0;
1104 t->column_count = (typeinfo & D3D10_FX10_TYPE_COLUMN_MASK) >> D3D10_FX10_TYPE_COLUMN_SHIFT;
1105 t->row_count = (typeinfo & D3D10_FX10_TYPE_ROW_MASK) >> D3D10_FX10_TYPE_ROW_SHIFT;
1106 t->basetype = d3d10_variable_type((typeinfo & D3D10_FX10_TYPE_BASETYPE_MASK) >> D3D10_FX10_TYPE_BASETYPE_SHIFT, FALSE, &type_flags);
1107 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);
1109 TRACE("Type description: %#x.\n", typeinfo);
1110 TRACE("\tcolumns: %u.\n", t->column_count);
1111 TRACE("\trows: %u.\n", t->row_count);
1112 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t->basetype));
1113 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t->type_class));
1114 TRACE("\tunknown bits: %#x.\n", typeinfo & ~(D3D10_FX10_TYPE_COLUMN_MASK | D3D10_FX10_TYPE_ROW_MASK
1115 | D3D10_FX10_TYPE_BASETYPE_MASK | D3D10_FX10_TYPE_CLASS_MASK | D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK));
1116 break;
1118 case 2:
1119 TRACE("Type is an object.\n");
1121 if (!require_space(ptr - data, 1, sizeof(typeinfo), data_size))
1123 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1124 return E_FAIL;
1127 read_dword(&ptr, &typeinfo);
1128 t->member_count = 0;
1129 t->column_count = 0;
1130 t->row_count = 0;
1131 t->basetype = d3d10_variable_type(typeinfo, TRUE, &type_flags);
1132 t->type_class = D3D10_SVC_OBJECT;
1133 t->flags = type_flags;
1135 TRACE("Type description: %#x.\n", typeinfo);
1136 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t->basetype));
1137 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t->type_class));
1138 TRACE("\tflags: %#x.\n", t->flags);
1139 break;
1141 case 3:
1142 TRACE("Type is a structure.\n");
1144 if (!require_space(ptr - data, 1, sizeof(t->member_count), data_size))
1146 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1147 return E_FAIL;
1150 read_dword(&ptr, &t->member_count);
1151 TRACE("Member count: %u.\n", t->member_count);
1153 t->column_count = 0;
1154 t->row_count = 0;
1155 t->basetype = 0;
1156 t->type_class = D3D10_SVC_STRUCT;
1158 if (!(t->members = heap_calloc(t->member_count, sizeof(*t->members))))
1160 ERR("Failed to allocate members memory.\n");
1161 return E_OUTOFMEMORY;
1164 if (!require_space(ptr - data, t->member_count, 4 * sizeof(DWORD), data_size))
1166 WARN("Invalid member count %#x (data size %#lx, offset %#x).\n",
1167 t->member_count, (long)data_size, offset);
1168 return E_FAIL;
1171 for (i = 0; i < t->member_count; ++i)
1173 struct d3d10_effect_type_member *typem = &t->members[i];
1175 read_dword(&ptr, &offset);
1176 TRACE("Member name at offset %#x.\n", offset);
1178 if (!fx10_copy_string(data, data_size, offset, &typem->name))
1180 ERR("Failed to copy name.\n");
1181 return E_OUTOFMEMORY;
1183 TRACE("Member name: %s.\n", debugstr_a(typem->name));
1185 read_dword(&ptr, &offset);
1186 TRACE("Member semantic at offset %#x.\n", offset);
1188 if (!fx10_copy_string(data, data_size, offset, &typem->semantic))
1190 ERR("Failed to copy semantic.\n");
1191 return E_OUTOFMEMORY;
1193 TRACE("Member semantic: %s.\n", debugstr_a(typem->semantic));
1195 read_dword(&ptr, &typem->buffer_offset);
1196 TRACE("Member offset in struct: %#x.\n", typem->buffer_offset);
1198 read_dword(&ptr, &offset);
1199 TRACE("Member type info at offset %#x.\n", offset);
1201 if (!(typem->type = get_fx10_type(t->effect, data, data_size, offset)))
1203 ERR("Failed to get variable type.\n");
1204 return E_FAIL;
1207 break;
1209 default:
1210 FIXME("Unhandled type kind %#x.\n", type_kind);
1211 return E_FAIL;
1214 if (t->element_count)
1216 TRACE("Elementtype for type at offset: %#x\n", t->id);
1218 /* allocate elementtype - we need only one, because all elements have the same type */
1219 if (!(t->elementtype = heap_alloc_zero(sizeof(*t->elementtype))))
1221 ERR("Failed to allocate members memory.\n");
1222 return E_OUTOFMEMORY;
1225 /* create a copy of the original type with some minor changes */
1226 t->elementtype->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
1227 t->elementtype->effect = t->effect;
1229 if (!copy_name(t->name, &t->elementtype->name))
1231 ERR("Failed to copy name.\n");
1232 return E_OUTOFMEMORY;
1234 TRACE("\tType name: %s.\n", debugstr_a(t->elementtype->name));
1236 t->elementtype->element_count = 0;
1237 TRACE("\tElement count: %u.\n", t->elementtype->element_count);
1240 * Not sure if this calculation is 100% correct, but a test
1241 * shows that these values work.
1243 t->elementtype->size_unpacked = t->size_packed / t->element_count;
1244 TRACE("\tUnpacked size: %#x.\n", t->elementtype->size_unpacked);
1246 t->elementtype->stride = t->stride;
1247 TRACE("\tStride: %#x.\n", t->elementtype->stride);
1249 t->elementtype->size_packed = t->size_packed / t->element_count;
1250 TRACE("\tPacked size: %#x.\n", t->elementtype->size_packed);
1252 t->elementtype->member_count = t->member_count;
1253 TRACE("\tMember count: %u.\n", t->elementtype->member_count);
1255 t->elementtype->column_count = t->column_count;
1256 TRACE("\tColumns: %u.\n", t->elementtype->column_count);
1258 t->elementtype->row_count = t->row_count;
1259 TRACE("\tRows: %u.\n", t->elementtype->row_count);
1261 t->elementtype->basetype = t->basetype;
1262 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(t->elementtype->basetype));
1264 t->elementtype->type_class = t->type_class;
1265 TRACE("\tClass: %s.\n", debug_d3d10_shader_variable_class(t->elementtype->type_class));
1267 t->elementtype->members = t->members;
1270 return S_OK;
1273 static struct d3d10_effect_type *get_fx10_type(struct d3d10_effect *effect,
1274 const char *data, size_t data_size, DWORD offset)
1276 struct d3d10_effect_type *type;
1277 struct wine_rb_entry *entry;
1278 HRESULT hr;
1280 entry = wine_rb_get(&effect->types, &offset);
1281 if (entry)
1283 TRACE("Returning existing type.\n");
1284 return WINE_RB_ENTRY_VALUE(entry, struct d3d10_effect_type, entry);
1287 if (!(type = heap_alloc_zero(sizeof(*type))))
1289 ERR("Failed to allocate type memory.\n");
1290 return NULL;
1293 type->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
1294 type->id = offset;
1295 type->effect = effect;
1296 if (FAILED(hr = parse_fx10_type(data, data_size, offset, type)))
1298 ERR("Failed to parse type info, hr %#x.\n", hr);
1299 heap_free(type);
1300 return NULL;
1303 if (wine_rb_put(&effect->types, &offset, &type->entry) == -1)
1305 ERR("Failed to insert type entry.\n");
1306 heap_free(type);
1307 return NULL;
1310 return type;
1313 static void set_variable_vtbl(struct d3d10_effect_variable *v)
1315 const ID3D10EffectVariableVtbl **vtbl = &v->ID3D10EffectVariable_iface.lpVtbl;
1317 switch (v->type->type_class)
1319 case D3D10_SVC_SCALAR:
1320 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl;
1321 break;
1323 case D3D10_SVC_VECTOR:
1324 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl;
1325 break;
1327 case D3D10_SVC_MATRIX_ROWS:
1328 case D3D10_SVC_MATRIX_COLUMNS:
1329 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl;
1330 break;
1332 case D3D10_SVC_STRUCT:
1333 *vtbl = &d3d10_effect_variable_vtbl;
1334 break;
1336 case D3D10_SVC_OBJECT:
1337 switch(v->type->basetype)
1339 case D3D10_SVT_STRING:
1340 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl;
1341 break;
1343 case D3D10_SVT_TEXTURE:
1344 case D3D10_SVT_TEXTURE1D:
1345 case D3D10_SVT_TEXTURE1DARRAY:
1346 case D3D10_SVT_TEXTURE2D:
1347 case D3D10_SVT_TEXTURE2DARRAY:
1348 case D3D10_SVT_TEXTURE2DMS:
1349 case D3D10_SVT_TEXTURE2DMSARRAY:
1350 case D3D10_SVT_TEXTURE3D:
1351 case D3D10_SVT_TEXTURECUBE:
1352 case D3D10_SVT_BUFFER: /* Either resource or constant buffer. */
1353 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl;
1354 break;
1356 case D3D10_SVT_RENDERTARGETVIEW:
1357 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl;
1358 break;
1360 case D3D10_SVT_DEPTHSTENCILVIEW:
1361 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl;
1362 break;
1364 case D3D10_SVT_DEPTHSTENCIL:
1365 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl;
1366 break;
1368 case D3D10_SVT_VERTEXSHADER:
1369 case D3D10_SVT_GEOMETRYSHADER:
1370 case D3D10_SVT_PIXELSHADER:
1371 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl;
1372 break;
1374 case D3D10_SVT_BLEND:
1375 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl;
1376 break;
1378 case D3D10_SVT_RASTERIZER:
1379 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl;
1380 break;
1382 case D3D10_SVT_SAMPLER:
1383 *vtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl;
1384 break;
1386 default:
1387 FIXME("Unhandled basetype %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
1388 *vtbl = &d3d10_effect_variable_vtbl;
1389 break;
1391 break;
1393 default:
1394 FIXME("Unhandled type class %s.\n", debug_d3d10_shader_variable_class(v->type->type_class));
1395 *vtbl = &d3d10_effect_variable_vtbl;
1396 break;
1400 static HRESULT copy_variableinfo_from_type(struct d3d10_effect_variable *v)
1402 unsigned int i;
1403 HRESULT hr;
1405 if (v->type->member_count)
1407 if (!(v->members = heap_calloc(v->type->member_count, sizeof(*v->members))))
1409 ERR("Failed to allocate members memory.\n");
1410 return E_OUTOFMEMORY;
1413 for (i = 0; i < v->type->member_count; ++i)
1415 struct d3d10_effect_variable *var = &v->members[i];
1416 struct d3d10_effect_type_member *typem = &v->type->members[i];
1418 var->buffer = v->buffer;
1419 var->effect = v->effect;
1420 var->type = typem->type;
1421 set_variable_vtbl(var);
1423 if (!copy_name(typem->name, &var->name))
1425 ERR("Failed to copy name.\n");
1426 return E_OUTOFMEMORY;
1428 TRACE("Variable name: %s.\n", debugstr_a(var->name));
1430 if (!copy_name(typem->semantic, &var->semantic))
1432 ERR("Failed to copy name.\n");
1433 return E_OUTOFMEMORY;
1435 TRACE("Variable semantic: %s.\n", debugstr_a(var->semantic));
1437 var->buffer_offset = v->buffer_offset + typem->buffer_offset;
1438 TRACE("Variable buffer offset: %u.\n", var->buffer_offset);
1440 hr = copy_variableinfo_from_type(var);
1441 if (FAILED(hr)) return hr;
1445 if (v->type->element_count)
1447 unsigned int bufferoffset = v->buffer_offset;
1449 if (!(v->elements = heap_calloc(v->type->element_count, sizeof(*v->elements))))
1451 ERR("Failed to allocate elements memory.\n");
1452 return E_OUTOFMEMORY;
1455 for (i = 0; i < v->type->element_count; ++i)
1457 struct d3d10_effect_variable *var = &v->elements[i];
1459 var->buffer = v->buffer;
1460 var->effect = v->effect;
1461 var->type = v->type->elementtype;
1462 set_variable_vtbl(var);
1464 if (!copy_name(v->name, &var->name))
1466 ERR("Failed to copy name.\n");
1467 return E_OUTOFMEMORY;
1469 TRACE("Variable name: %s.\n", debugstr_a(var->name));
1471 if (!copy_name(v->semantic, &var->semantic))
1473 ERR("Failed to copy name.\n");
1474 return E_OUTOFMEMORY;
1476 TRACE("Variable semantic: %s.\n", debugstr_a(var->semantic));
1478 if (i != 0)
1480 bufferoffset += v->type->stride;
1482 var->buffer_offset = bufferoffset;
1483 TRACE("Variable buffer offset: %u.\n", var->buffer_offset);
1485 hr = copy_variableinfo_from_type(var);
1486 if (FAILED(hr)) return hr;
1490 return S_OK;
1493 static HRESULT parse_fx10_variable_head(const char *data, size_t data_size,
1494 const char **ptr, struct d3d10_effect_variable *v)
1496 DWORD offset;
1498 read_dword(ptr, &offset);
1499 TRACE("Variable name at offset %#x.\n", offset);
1501 if (!fx10_copy_string(data, data_size, offset, &v->name))
1503 ERR("Failed to copy name.\n");
1504 return E_OUTOFMEMORY;
1506 TRACE("Variable name: %s.\n", debugstr_a(v->name));
1508 read_dword(ptr, &offset);
1509 TRACE("Variable type info at offset %#x.\n", offset);
1511 if (!(v->type = get_fx10_type(v->effect, data, data_size, offset)))
1513 ERR("Failed to get variable type.\n");
1514 return E_FAIL;
1516 set_variable_vtbl(v);
1518 v->explicit_bind_point = ~0u;
1520 if (v->effect->flags & D3D10_EFFECT_IS_POOL)
1521 v->flag |= D3D10_EFFECT_VARIABLE_POOLED;
1523 return copy_variableinfo_from_type(v);
1526 static HRESULT parse_fx10_annotation(const char *data, size_t data_size,
1527 const char **ptr, struct d3d10_effect_variable *a)
1529 DWORD offset;
1530 HRESULT hr;
1532 if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, a)))
1533 return hr;
1535 read_dword(ptr, &offset);
1536 TRACE("Annotation value is at offset %#x.\n", offset);
1538 switch (a->type->basetype)
1540 case D3D10_SVT_STRING:
1541 if (!fx10_copy_string(data, data_size, offset, (char **)&a->u.buffer.local_buffer))
1543 ERR("Failed to copy name.\n");
1544 return E_OUTOFMEMORY;
1546 break;
1548 default:
1549 FIXME("Unhandled object type %#x.\n", a->type->basetype);
1552 /* mark the variable as annotation */
1553 a->flag |= D3D10_EFFECT_VARIABLE_ANNOTATION;
1555 return S_OK;
1558 static HRESULT parse_fx10_annotations(const char *data, size_t data_size, const char **ptr,
1559 struct d3d10_effect *effect, struct d3d10_effect_annotations *annotations)
1561 unsigned int i;
1562 HRESULT hr;
1564 if (!(annotations->elements = heap_calloc(annotations->count, sizeof(*annotations->elements))))
1566 ERR("Failed to allocate annotations memory.\n");
1567 return E_OUTOFMEMORY;
1570 for (i = 0; i < annotations->count; ++i)
1572 struct d3d10_effect_variable *a = &annotations->elements[i];
1574 a->effect = effect;
1575 a->buffer = &null_local_buffer;
1577 if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a)))
1578 return hr;
1581 return hr;
1584 static HRESULT parse_fx10_anonymous_shader(struct d3d10_effect *e, D3D_SHADER_VARIABLE_TYPE basetype,
1585 struct d3d10_effect_anonymous_shader *s)
1587 struct d3d10_effect_variable *v = &s->shader;
1588 struct d3d10_effect_type *t = &s->type;
1589 const char *name = NULL;
1591 switch (basetype)
1593 case D3D10_SVT_VERTEXSHADER:
1594 name = "vertexshader";
1595 break;
1597 case D3D10_SVT_PIXELSHADER:
1598 name = "pixelshader";
1599 break;
1601 case D3D10_SVT_GEOMETRYSHADER:
1602 name = "geometryshader";
1603 break;
1605 default:
1606 WARN("Unhandled shader type %#x.\n", basetype);
1607 return E_FAIL;
1609 t->basetype = basetype;
1611 if (!copy_name(name, &t->name))
1613 ERR("Failed to copy name.\n");
1614 return E_OUTOFMEMORY;
1616 TRACE("Type name: %s.\n", debugstr_a(t->name));
1618 t->type_class = D3D10_SVC_OBJECT;
1620 t->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
1622 v->type = t;
1623 v->effect = e;
1624 v->u.shader.isinline = 1;
1625 set_variable_vtbl(v);
1627 if (!copy_name("$Anonymous", &v->name))
1629 ERR("Failed to copy semantic.\n");
1630 return E_OUTOFMEMORY;
1632 TRACE("Variable name: %s.\n", debugstr_a(v->name));
1634 return S_OK;
1637 static const struct d3d10_effect_state_storage_info *get_storage_info(D3D_SHADER_VARIABLE_TYPE id)
1639 unsigned int i;
1641 for (i = 0; i < ARRAY_SIZE(d3d10_effect_state_storage_info); ++i)
1643 if (d3d10_effect_state_storage_info[i].id == id)
1644 return &d3d10_effect_state_storage_info[i];
1647 return NULL;
1650 static BOOL read_value_list(const char *data, size_t data_size, uint32_t offset,
1651 D3D_SHADER_VARIABLE_TYPE out_type, unsigned int out_base, unsigned int out_size,
1652 void *out_data)
1654 D3D_SHADER_VARIABLE_TYPE in_type;
1655 unsigned int i, type_flags;
1656 uint32_t t, value, count;
1657 const char *ptr;
1659 if (offset >= data_size || !require_space(offset, 1, sizeof(count), data_size))
1661 WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size);
1662 return FALSE;
1665 ptr = data + offset;
1666 read_dword(&ptr, &count);
1667 if (count != out_size)
1668 return FALSE;
1670 if (!require_space(ptr - data, count, 2 * sizeof(DWORD), data_size))
1672 WARN("Invalid value count %#x (offset %#x, data size %#lx).\n", count, offset, (long)data_size);
1673 return FALSE;
1676 TRACE("%u values:\n", count);
1677 for (i = 0; i < count; ++i)
1679 unsigned int out_idx = out_base * out_size + i;
1681 read_dword(&ptr, &t);
1682 read_dword(&ptr, &value);
1684 in_type = d3d10_variable_type(t, FALSE, &type_flags);
1685 TRACE("\t%s: %#x.\n", debug_d3d10_shader_variable_type(in_type), value);
1687 switch (out_type)
1689 case D3D10_SVT_FLOAT:
1690 case D3D10_SVT_INT:
1691 case D3D10_SVT_UINT:
1692 case D3D10_SVT_UINT8:
1693 case D3D10_SVT_BOOL:
1694 if (!d3d10_effect_read_numeric_value(value, in_type, out_type, out_data, out_idx))
1695 return FALSE;
1696 break;
1698 case D3D10_SVT_VERTEXSHADER:
1699 *(void **)out_data = &anonymous_vs;
1700 break;
1702 case D3D10_SVT_PIXELSHADER:
1703 *(void **)out_data = &anonymous_ps;
1704 break;
1706 case D3D10_SVT_GEOMETRYSHADER:
1707 *(void **)out_data = &anonymous_gs;
1708 break;
1710 case D3D10_SVT_TEXTURE:
1711 *(void **)out_data = &null_shader_resource_variable;
1712 break;
1714 case D3D10_SVT_DEPTHSTENCIL:
1715 *(void **)out_data = &null_depth_stencil_variable;
1716 break;
1718 case D3D10_SVT_BLEND:
1719 *(void **)out_data = &null_blend_variable;
1720 break;
1722 default:
1723 FIXME("Unhandled out_type %#x.\n", out_type);
1724 return FALSE;
1728 return TRUE;
1731 static BOOL is_object_property(const struct d3d10_effect_state_property_info *property_info)
1733 switch (property_info->type)
1735 case D3D10_SVT_RASTERIZER:
1736 case D3D10_SVT_DEPTHSTENCIL:
1737 case D3D10_SVT_BLEND:
1738 case D3D10_SVT_RENDERTARGETVIEW:
1739 case D3D10_SVT_DEPTHSTENCILVIEW:
1740 case D3D10_SVT_VERTEXSHADER:
1741 case D3D10_SVT_PIXELSHADER:
1742 case D3D10_SVT_GEOMETRYSHADER:
1743 case D3D10_SVT_TEXTURE:
1744 return TRUE;
1745 default:
1746 return FALSE;
1750 static BOOL is_object_property_type_matching(const struct d3d10_effect_state_property_info *property_info,
1751 const struct d3d10_effect_variable *v)
1753 if (property_info->type == v->type->basetype) return TRUE;
1755 switch (v->type->basetype)
1757 case D3D10_SVT_TEXTURE1D:
1758 case D3D10_SVT_TEXTURE1DARRAY:
1759 case D3D10_SVT_TEXTURE2D:
1760 case D3D10_SVT_TEXTURE2DARRAY:
1761 case D3D10_SVT_TEXTURE2DMS:
1762 case D3D10_SVT_TEXTURE2DMSARRAY:
1763 case D3D10_SVT_TEXTURE3D:
1764 case D3D10_SVT_TEXTURECUBE:
1765 if (property_info->type == D3D10_SVT_TEXTURE) return TRUE;
1766 /* fallthrough */
1767 default:
1768 return FALSE;
1772 static HRESULT parse_fx10_property_assignment(const char *data, size_t data_size,
1773 const char **ptr, enum d3d10_effect_container_type container_type,
1774 struct d3d10_effect *effect, void *container)
1776 uint32_t id, idx, variable_idx, operation, value_offset, sodecl_offset;
1777 const struct d3d10_effect_state_property_info *property_info;
1778 struct d3d10_effect_variable *variable;
1779 const char *data_ptr, *name;
1780 unsigned int *dst_index;
1781 size_t name_len;
1782 HRESULT hr;
1783 void *dst;
1785 read_dword(ptr, &id);
1786 read_dword(ptr, &idx);
1787 read_dword(ptr, &operation);
1788 read_dword(ptr, &value_offset);
1790 if (id >= ARRAY_SIZE(property_infos))
1792 FIXME("Unknown property id %#x.\n", id);
1793 return E_FAIL;
1795 property_info = &property_infos[id];
1797 TRACE("Property %s[%#x] = value list @ offset %#x.\n", property_info->name, idx, value_offset);
1799 if (property_info->container_type != container_type)
1801 ERR("Invalid container type %#x for property %#x.\n", container_type, id);
1802 return E_FAIL;
1805 if (idx >= property_info->count)
1807 ERR("Invalid index %#x for property %#x.\n", idx, id);
1808 return E_FAIL;
1811 if (property_info->offset == ~0u)
1813 ERR("Unsupported property %#x.\n", id);
1814 return E_NOTIMPL;
1817 dst = (char *)container + property_info->offset;
1818 dst_index = (unsigned int *)((char *)container + property_info->index_offset);
1820 switch (operation)
1822 case D3D10_EOO_CONST:
1824 /* Constant values output directly to backing store. */
1825 if (!read_value_list(data, data_size, value_offset, property_info->type, idx,
1826 property_info->size, dst))
1828 ERR("Failed to read values for property %#x.\n", id);
1829 return E_FAIL;
1831 break;
1833 case D3D10_EOO_VAR:
1835 /* Variable. */
1836 if (!fx10_get_string(data, data_size, value_offset, &name, &name_len))
1838 WARN("Failed to get variable name.\n");
1839 return E_FAIL;
1841 TRACE("Variable name %s.\n", debugstr_a(name));
1843 if (!(variable = d3d10_effect_get_variable_by_name(effect, name)))
1845 WARN("Couldn't find variable %s.\n", debugstr_a(name));
1846 return E_FAIL;
1849 if (is_object_property(property_info))
1851 if (variable->type->element_count)
1853 WARN("Unexpected array variable value %s.\n", debugstr_a(name));
1854 return E_FAIL;
1857 if (!is_object_property_type_matching(property_info, variable))
1859 WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
1860 variable->type->basetype, property_info->type);
1861 return E_FAIL;
1864 ((void **)dst)[idx] = variable;
1866 else
1868 FIXME("Assigning variables to numeric fields is not supported.\n");
1869 return E_FAIL;
1872 break;
1874 case D3D10_EOO_CONST_INDEX:
1876 /* Array variable, constant index. */
1877 if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size))
1879 WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size);
1880 return E_FAIL;
1882 data_ptr = data + value_offset;
1883 read_dword(&data_ptr, &value_offset);
1884 read_dword(&data_ptr, &variable_idx);
1886 if (!fx10_get_string(data, data_size, value_offset, &name, &name_len))
1888 WARN("Failed to get variable name.\n");
1889 return E_FAIL;
1892 TRACE("Variable name %s[%u].\n", debugstr_a(name), variable_idx);
1894 if (!(variable = d3d10_effect_get_variable_by_name(effect, name)))
1896 WARN("Couldn't find variable %s.\n", debugstr_a(name));
1897 return E_FAIL;
1900 /* Has to be an array */
1901 if (!variable->type->element_count || variable_idx >= variable->type->element_count)
1903 WARN("Invalid array size %u.\n", variable->type->element_count);
1904 return E_FAIL;
1907 if (is_object_property(property_info))
1909 if (!is_object_property_type_matching(property_info, variable))
1911 WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
1912 variable->type->basetype, property_info->type);
1913 return E_FAIL;
1916 /* Shader variables are special, they are referenced via array, with index stored separately. */
1917 switch (property_info->type)
1919 case D3D10_SVT_VERTEXSHADER:
1920 case D3D10_SVT_PIXELSHADER:
1921 case D3D10_SVT_GEOMETRYSHADER:
1922 ((void **)dst)[idx] = variable;
1923 *dst_index = variable_idx;
1924 break;
1925 default:
1926 ((void **)dst)[idx] = &variable->elements[variable_idx];
1929 else
1931 FIXME("Assigning indexed variables to numeric fields is not supported.\n");
1932 return E_FAIL;
1935 break;
1937 case D3D10_EOO_ANONYMOUS_SHADER:
1939 /* Anonymous shader */
1940 if (effect->anonymous_shader_current >= effect->anonymous_shader_count)
1942 ERR("Anonymous shader count is wrong!\n");
1943 return E_FAIL;
1946 if (value_offset >= data_size || !require_space(value_offset, 2, sizeof(DWORD), data_size))
1948 WARN("Invalid offset %#x (data size %#lx).\n", value_offset, (long)data_size);
1949 return E_FAIL;
1951 data_ptr = data + value_offset;
1952 read_dword(&data_ptr, &value_offset);
1953 read_dword(&data_ptr, &sodecl_offset);
1955 TRACE("Effect object starts at offset %#x.\n", value_offset);
1957 if (FAILED(hr = parse_fx10_anonymous_shader(effect, property_info->type,
1958 &effect->anonymous_shaders[effect->anonymous_shader_current])))
1959 return hr;
1961 variable = &effect->anonymous_shaders[effect->anonymous_shader_current].shader;
1962 ++effect->anonymous_shader_current;
1964 if (sodecl_offset)
1966 TRACE("Anonymous shader stream output declaration at offset %#x.\n", sodecl_offset);
1967 if (!fx10_copy_string(data, data_size, sodecl_offset,
1968 &variable->u.shader.stream_output_declaration))
1970 ERR("Failed to copy stream output declaration.\n");
1971 return E_FAIL;
1974 TRACE("Stream output declaration: %s.\n", debugstr_a(variable->u.shader.stream_output_declaration));
1977 switch (property_info->type)
1979 case D3D10_SVT_VERTEXSHADER:
1980 case D3D10_SVT_PIXELSHADER:
1981 case D3D10_SVT_GEOMETRYSHADER:
1982 if (FAILED(hr = parse_fx10_shader(data, data_size, value_offset, variable)))
1983 return hr;
1984 break;
1986 default:
1987 WARN("Unexpected shader type %#x.\n", property_info->type);
1988 return E_FAIL;
1991 ((void **)dst)[idx] = variable;
1993 break;
1995 default:
1996 FIXME("Unhandled operation %#x.\n", operation);
1997 return E_FAIL;
2000 return S_OK;
2003 static HRESULT parse_fx10_pass(const char *data, size_t data_size,
2004 const char **ptr, struct d3d10_effect_pass *p)
2006 DWORD offset, object_count;
2007 unsigned int i;
2008 HRESULT hr;
2010 read_dword(ptr, &offset);
2011 TRACE("Pass name at offset %#x.\n", offset);
2013 if (!fx10_copy_string(data, data_size, offset, &p->name))
2015 ERR("Failed to copy name.\n");
2016 return E_OUTOFMEMORY;
2018 TRACE("Pass name: %s.\n", debugstr_a(p->name));
2020 read_dword(ptr, &object_count);
2021 TRACE("Pass has %u effect objects.\n", object_count);
2023 read_dword(ptr, &p->annotations.count);
2024 TRACE("Pass has %u annotations.\n", p->annotations.count);
2026 if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, p->technique->effect,
2027 &p->annotations)))
2029 ERR("Failed to parse pass annotations, hr %#x.\n", hr);
2030 return hr;
2033 p->vs.shader = &null_shader_variable;
2034 p->ps.shader = &null_shader_variable;
2035 p->gs.shader = &null_shader_variable;
2037 for (i = 0; i < object_count; ++i)
2039 if (FAILED(hr = parse_fx10_property_assignment(data, data_size, ptr,
2040 D3D10_C_PASS, p->technique->effect, p)))
2042 WARN("Failed to parse pass assignment %u, hr %#x.\n", i, hr);
2043 return hr;
2047 return hr;
2050 static HRESULT parse_fx10_technique(const char *data, size_t data_size,
2051 const char **ptr, struct d3d10_effect_technique *t)
2053 unsigned int i;
2054 DWORD offset;
2055 HRESULT hr;
2057 read_dword(ptr, &offset);
2058 TRACE("Technique name at offset %#x.\n", offset);
2060 if (!fx10_copy_string(data, data_size, offset, &t->name))
2062 ERR("Failed to copy name.\n");
2063 return E_OUTOFMEMORY;
2065 TRACE("Technique name: %s.\n", debugstr_a(t->name));
2067 read_dword(ptr, &t->pass_count);
2068 TRACE("Technique has %u passes\n", t->pass_count);
2070 read_dword(ptr, &t->annotations.count);
2071 TRACE("Technique has %u annotations.\n", t->annotations.count);
2073 if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, t->effect,
2074 &t->annotations)))
2076 ERR("Failed to parse technique annotations, hr %#x.\n", hr);
2077 return hr;
2080 if (!(t->passes = heap_calloc(t->pass_count, sizeof(*t->passes))))
2082 ERR("Failed to allocate passes memory\n");
2083 return E_OUTOFMEMORY;
2086 for (i = 0; i < t->pass_count; ++i)
2088 struct d3d10_effect_pass *p = &t->passes[i];
2090 p->ID3D10EffectPass_iface.lpVtbl = &d3d10_effect_pass_vtbl;
2091 p->technique = t;
2093 if (FAILED(hr = parse_fx10_pass(data, data_size, ptr, p)))
2094 return hr;
2097 return S_OK;
2100 static void parse_fx10_set_default_numeric_value(const char **ptr, struct d3d10_effect_variable *v)
2102 float *dst = (float *)(v->buffer->u.buffer.local_buffer + v->buffer_offset), *src;
2103 BOOL col_major = v->type->type_class == D3D10_SVC_MATRIX_COLUMNS;
2104 unsigned int col_count = v->type->column_count, col;
2105 unsigned int row_count = v->type->row_count, row;
2107 src = (float *)*ptr;
2109 if (col_major)
2111 for (col = 0; col < col_count; ++col)
2113 for (row = 0; row < row_count; ++row)
2114 dst[row] = src[row * col_count + col];
2115 dst += 4;
2118 else
2120 for (row = 0; row < row_count; ++row)
2122 memcpy(dst, src, col_count * sizeof(float));
2123 src += col_count;
2124 dst += 4;
2128 *ptr += col_count * row_count * sizeof(float);
2131 static void parse_fx10_default_value(const char **ptr, struct d3d10_effect_variable *var)
2133 unsigned int element_count = max(var->type->element_count, 1), i, m;
2134 struct d3d10_effect_variable *v;
2136 for (i = 0; i < element_count; ++i)
2138 v = d3d10_array_get_element(var, i);
2140 switch (v->type->type_class)
2142 case D3D10_SVC_STRUCT:
2143 for (m = 0; m < v->type->member_count; ++m)
2144 parse_fx10_default_value(ptr, &v->members[m]);
2145 break;
2146 case D3D10_SVC_SCALAR:
2147 case D3D10_SVC_VECTOR:
2148 case D3D10_SVC_MATRIX_COLUMNS:
2149 case D3D10_SVC_MATRIX_ROWS:
2150 parse_fx10_set_default_numeric_value(ptr, v);
2151 break;
2152 default:
2153 FIXME("Unexpected initial value for type %#x.\n", v->type->basetype);
2154 return;
2159 static void d3d10_effect_variable_update_buffer_offsets(struct d3d10_effect_variable *v,
2160 unsigned int offset)
2162 unsigned int i;
2164 for (i = 0; i < v->type->member_count; ++i)
2165 d3d10_effect_variable_update_buffer_offsets(&v->members[i], offset);
2167 for (i = 0; i < v->type->element_count; ++i)
2168 d3d10_effect_variable_update_buffer_offsets(&v->elements[i], offset);
2170 v->buffer_offset += offset;
2173 static HRESULT parse_fx10_numeric_variable(const char *data, size_t data_size,
2174 const char **ptr, BOOL local, struct d3d10_effect_variable *v)
2176 uint32_t offset, flags, default_value_offset, buffer_offset;
2177 const char *data_ptr;
2178 HRESULT hr;
2180 if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, v)))
2181 return hr;
2183 read_dword(ptr, &offset);
2184 TRACE("Variable semantic at offset %#x.\n", offset);
2186 if (!fx10_copy_string(data, data_size, offset, &v->semantic))
2188 ERR("Failed to copy semantic.\n");
2189 return E_OUTOFMEMORY;
2191 TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
2193 read_dword(ptr, &buffer_offset);
2194 TRACE("Variable offset in buffer: %#x.\n", buffer_offset);
2196 read_dword(ptr, &default_value_offset);
2197 TRACE("Variable default value offset: %#x.\n", default_value_offset);
2199 read_dword(ptr, &flags);
2200 TRACE("Variable flags: %#x.\n", flags);
2202 v->flag |= flags;
2204 /* At this point storage offsets for members and array elements are relative to containing
2205 variable. Update them by moving to correct offset within a buffer. */
2206 d3d10_effect_variable_update_buffer_offsets(v, buffer_offset);
2208 if (local)
2210 if (default_value_offset)
2212 if (!require_space(default_value_offset, 1, v->type->size_packed, data_size))
2214 WARN("Invalid default value offset %#x, variable packed size %u.\n", default_value_offset,
2215 v->type->size_packed);
2216 return E_FAIL;
2219 data_ptr = data + default_value_offset;
2220 parse_fx10_default_value(&data_ptr, v);
2223 read_dword(ptr, &v->annotations.count);
2224 TRACE("Variable has %u annotations.\n", v->annotations.count);
2226 if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, v->effect,
2227 &v->annotations)))
2229 ERR("Failed to parse variable annotations, hr %#x.\n", hr);
2230 return hr;
2234 if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
2235 v->explicit_bind_point = v->buffer_offset;
2237 return S_OK;
2240 static HRESULT create_state_object(struct d3d10_effect_variable *v)
2242 ID3D10Device *device = v->effect->device;
2243 HRESULT hr;
2245 switch (v->type->basetype)
2247 case D3D10_SVT_DEPTHSTENCIL:
2248 if (FAILED(hr = ID3D10Device_CreateDepthStencilState(device,
2249 &v->u.state.desc.depth_stencil, &v->u.state.object.depth_stencil)))
2250 return hr;
2251 break;
2253 case D3D10_SVT_BLEND:
2254 if (FAILED(hr = ID3D10Device_CreateBlendState(device,
2255 &v->u.state.desc.blend, &v->u.state.object.blend)))
2256 return hr;
2257 break;
2259 case D3D10_SVT_RASTERIZER:
2260 if (FAILED(hr = ID3D10Device_CreateRasterizerState(device,
2261 &v->u.state.desc.rasterizer, &v->u.state.object.rasterizer)))
2262 return hr;
2263 break;
2265 case D3D10_SVT_SAMPLER:
2266 if (FAILED(hr = ID3D10Device_CreateSamplerState(device,
2267 &v->u.state.desc.sampler.desc, &v->u.state.object.sampler)))
2268 return hr;
2269 break;
2271 default:
2272 ERR("Unhandled variable type %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
2273 return E_FAIL;
2276 return S_OK;
2279 static HRESULT parse_fx10_object_variable(const char *data, size_t data_size,
2280 const char **ptr, BOOL shared_type_desc, struct d3d10_effect_variable *v)
2282 struct d3d10_effect_variable *var;
2283 unsigned int i, j, element_count;
2284 HRESULT hr;
2285 DWORD offset;
2287 if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, v)))
2288 return hr;
2290 read_dword(ptr, &offset);
2291 TRACE("Variable semantic at offset %#x.\n", offset);
2293 if (!fx10_copy_string(data, data_size, offset, &v->semantic))
2295 ERR("Failed to copy semantic.\n");
2296 return E_OUTOFMEMORY;
2298 TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
2300 read_dword(ptr, &v->explicit_bind_point);
2301 TRACE("Variable explicit bind point %#x.\n", v->explicit_bind_point);
2303 /* Shared variable description contains only type information. */
2304 if (shared_type_desc) return S_OK;
2306 element_count = max(v->type->element_count, 1);
2308 switch (v->type->basetype)
2310 case D3D10_SVT_TEXTURE:
2311 case D3D10_SVT_TEXTURE1D:
2312 case D3D10_SVT_TEXTURE1DARRAY:
2313 case D3D10_SVT_TEXTURE2D:
2314 case D3D10_SVT_TEXTURE2DARRAY:
2315 case D3D10_SVT_TEXTURE2DMS:
2316 case D3D10_SVT_TEXTURE2DMSARRAY:
2317 case D3D10_SVT_TEXTURE3D:
2318 case D3D10_SVT_TEXTURECUBE:
2319 if (!(v->u.resource.srv = heap_calloc(element_count, sizeof(*v->u.resource.srv))))
2321 ERR("Failed to allocate shader resource view array memory.\n");
2322 return E_OUTOFMEMORY;
2324 v->u.resource.parent = TRUE;
2326 if (v->elements)
2328 for (i = 0; i < v->type->element_count; ++i)
2330 v->elements[i].u.resource.srv = &v->u.resource.srv[i];
2331 v->elements[i].u.resource.parent = FALSE;
2334 break;
2336 case D3D10_SVT_RENDERTARGETVIEW:
2337 case D3D10_SVT_DEPTHSTENCILVIEW:
2338 case D3D10_SVT_BUFFER:
2339 TRACE("SVT could not have elements.\n");
2340 break;
2342 case D3D10_SVT_VERTEXSHADER:
2343 case D3D10_SVT_PIXELSHADER:
2344 case D3D10_SVT_GEOMETRYSHADER:
2345 TRACE("Shader type is %s\n", debug_d3d10_shader_variable_type(v->type->basetype));
2346 for (i = 0; i < element_count; ++i)
2348 DWORD shader_offset, sodecl_offset;
2350 var = d3d10_array_get_element(v, i);
2352 read_dword(ptr, &shader_offset);
2353 TRACE("Shader offset: %#x.\n", shader_offset);
2355 if (v->type->flags & D3D10_EOT_FLAG_GS_SO)
2357 read_dword(ptr, &sodecl_offset);
2358 TRACE("Stream output declaration at offset %#x.\n", sodecl_offset);
2360 if (!fx10_copy_string(data, data_size, sodecl_offset,
2361 &var->u.shader.stream_output_declaration))
2363 ERR("Failed to copy stream output declaration.\n");
2364 return E_OUTOFMEMORY;
2367 TRACE("Stream output declaration: %s.\n", debugstr_a(var->u.shader.stream_output_declaration));
2370 if (FAILED(hr = parse_fx10_shader(data, data_size, shader_offset, var)))
2371 return hr;
2373 break;
2375 case D3D10_SVT_DEPTHSTENCIL:
2376 case D3D10_SVT_BLEND:
2377 case D3D10_SVT_RASTERIZER:
2378 case D3D10_SVT_SAMPLER:
2380 const struct d3d10_effect_state_storage_info *storage_info;
2382 if (!(storage_info = get_storage_info(v->type->basetype)))
2384 FIXME("Failed to get backing store info for type %s.\n",
2385 debug_d3d10_shader_variable_type(v->type->basetype));
2386 return E_FAIL;
2389 if (storage_info->size > sizeof(v->u.state.desc))
2391 ERR("Invalid storage size %#lx.\n", storage_info->size);
2392 return E_FAIL;
2395 for (i = 0; i < element_count; ++i)
2397 unsigned int prop_count;
2399 var = d3d10_array_get_element(v, i);
2401 read_dword(ptr, &prop_count);
2402 TRACE("State object property count: %#x.\n", prop_count);
2404 memcpy(&var->u.state.desc, storage_info->default_state, storage_info->size);
2406 for (j = 0; j < prop_count; ++j)
2408 if (FAILED(hr = parse_fx10_property_assignment(data, data_size, ptr,
2409 get_var_container_type(var), var->effect, &var->u.state.desc)))
2411 ERR("Failed to read property list.\n");
2412 return hr;
2416 if (FAILED(hr = create_state_object(var)))
2417 return hr;
2420 break;
2422 default:
2423 FIXME("Unhandled case %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
2424 return E_FAIL;
2427 read_dword(ptr, &v->annotations.count);
2428 TRACE("Variable has %u annotations.\n", v->annotations.count);
2430 if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, v->effect,
2431 &v->annotations)))
2433 ERR("Failed to parse variable annotations, hr %#x.\n", hr);
2434 return hr;
2437 return S_OK;
2440 static HRESULT create_buffer_object(struct d3d10_effect_variable *v)
2442 D3D10_BUFFER_DESC buffer_desc;
2443 D3D10_SUBRESOURCE_DATA subresource_data;
2444 D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc;
2445 ID3D10Device *device = v->effect->device;
2446 HRESULT hr;
2448 buffer_desc.ByteWidth = v->data_size;
2449 buffer_desc.Usage = D3D10_USAGE_DEFAULT;
2450 buffer_desc.CPUAccessFlags = 0;
2451 buffer_desc.MiscFlags = 0;
2452 if (v->type->basetype == D3D10_SVT_CBUFFER)
2453 buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
2454 else
2455 buffer_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
2457 subresource_data.pSysMem = v->u.buffer.local_buffer;
2458 subresource_data.SysMemPitch = 0;
2459 subresource_data.SysMemSlicePitch = 0;
2461 if (FAILED(hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &subresource_data, &v->u.buffer.buffer)))
2462 return hr;
2464 if (v->type->basetype == D3D10_SVT_TBUFFER)
2466 srv_desc.Format = DXGI_FORMAT_R32G32B32A32_UINT;
2467 srv_desc.ViewDimension = D3D_SRV_DIMENSION_BUFFER;
2468 srv_desc.Buffer.ElementOffset = 0;
2469 srv_desc.Buffer.ElementWidth = v->type->size_unpacked / 16;
2470 if (v->type->size_unpacked % 16)
2471 WARN("Unexpected texture buffer size not a multiple of 16.\n");
2473 if (FAILED(hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)v->u.buffer.buffer,
2474 &srv_desc, &v->u.buffer.resource_view)))
2475 return hr;
2477 else
2478 v->u.buffer.resource_view = NULL;
2480 return S_OK;
2483 static HRESULT parse_fx10_buffer(const char *data, size_t data_size, const char **ptr,
2484 BOOL local, struct d3d10_effect_variable *l)
2486 const char *prefix = local ? "Local" : "Shared";
2487 unsigned int i;
2488 DWORD offset;
2489 D3D10_CBUFFER_TYPE d3d10_cbuffer_type;
2490 HRESULT hr;
2491 unsigned int stride = 0;
2493 /* Generate our own type, it isn't in the fx blob. */
2494 if (!(l->type = heap_alloc_zero(sizeof(*l->type))))
2496 ERR("Failed to allocate local buffer type memory.\n");
2497 return E_OUTOFMEMORY;
2499 l->type->ID3D10EffectType_iface.lpVtbl = &d3d10_effect_type_vtbl;
2500 l->type->type_class = D3D10_SVC_OBJECT;
2501 l->type->effect = l->effect;
2503 read_dword(ptr, &offset);
2504 TRACE("%s buffer name at offset %#x.\n", prefix, offset);
2506 if (!fx10_copy_string(data, data_size, offset, &l->name))
2508 ERR("Failed to copy name.\n");
2509 return E_OUTOFMEMORY;
2511 TRACE("%s buffer name: %s.\n", prefix, debugstr_a(l->name));
2513 read_dword(ptr, &l->data_size);
2514 TRACE("%s buffer data size: %#x.\n", prefix, l->data_size);
2516 read_dword(ptr, &d3d10_cbuffer_type);
2517 TRACE("%s buffer type: %#x.\n", prefix, d3d10_cbuffer_type);
2519 switch(d3d10_cbuffer_type)
2521 case D3D10_CT_CBUFFER:
2522 l->type->basetype = D3D10_SVT_CBUFFER;
2523 if (!copy_name("cbuffer", &l->type->name))
2525 ERR("Failed to copy name.\n");
2526 return E_OUTOFMEMORY;
2528 break;
2530 case D3D10_CT_TBUFFER:
2531 l->type->basetype = D3D10_SVT_TBUFFER;
2532 if (!copy_name("tbuffer", &l->type->name))
2534 ERR("Failed to copy name.\n");
2535 return E_OUTOFMEMORY;
2537 break;
2539 default:
2540 ERR("Unexpected D3D10_CBUFFER_TYPE %#x!\n", d3d10_cbuffer_type);
2541 return E_FAIL;
2544 read_dword(ptr, &l->type->member_count);
2545 TRACE("%s buffer member count: %#x.\n", prefix, l->type->member_count);
2547 read_dword(ptr, &l->explicit_bind_point);
2548 TRACE("%s buffer explicit bind point: %#x.\n", prefix, l->explicit_bind_point);
2550 if (l->effect->flags & D3D10_EFFECT_IS_POOL)
2551 l->flag |= D3D10_EFFECT_VARIABLE_POOLED;
2553 if (local)
2555 read_dword(ptr, &l->annotations.count);
2556 TRACE("Local buffer has %u annotations.\n", l->annotations.count);
2558 if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, l->effect,
2559 &l->annotations)))
2561 ERR("Failed to parse buffer annotations, hr %#x.\n", hr);
2562 return hr;
2566 if (!(l->members = heap_calloc(l->type->member_count, sizeof(*l->members))))
2568 ERR("Failed to allocate members memory.\n");
2569 return E_OUTOFMEMORY;
2572 if (!(l->type->members = heap_calloc(l->type->member_count, sizeof(*l->type->members))))
2574 ERR("Failed to allocate type members memory.\n");
2575 return E_OUTOFMEMORY;
2578 if (local && !(l->u.buffer.local_buffer = heap_alloc_zero(l->data_size)))
2580 ERR("Failed to allocate local constant buffer memory.\n");
2581 return E_OUTOFMEMORY;
2584 for (i = 0; i < l->type->member_count; ++i)
2586 struct d3d10_effect_variable *v = &l->members[i];
2587 struct d3d10_effect_type_member *typem = &l->type->members[i];
2589 v->buffer = l;
2590 v->effect = l->effect;
2592 if (FAILED(hr = parse_fx10_numeric_variable(data, data_size, ptr, local, v)))
2593 return hr;
2596 * Copy the values from the variable type to the constant buffers type
2597 * members structure, because it is our own generated type.
2599 typem->type = v->type;
2601 if (!copy_name(v->name, &typem->name))
2603 ERR("Failed to copy name.\n");
2604 return E_OUTOFMEMORY;
2606 TRACE("Variable name: %s.\n", debugstr_a(typem->name));
2608 if (!copy_name(v->semantic, &typem->semantic))
2610 ERR("Failed to copy name.\n");
2611 return E_OUTOFMEMORY;
2613 TRACE("Variable semantic: %s.\n", debugstr_a(typem->semantic));
2615 typem->buffer_offset = v->buffer_offset;
2616 TRACE("Variable buffer offset: %u.\n", typem->buffer_offset);
2618 l->type->size_packed += v->type->size_packed;
2621 * For the complete constantbuffer the size_unpacked = stride,
2622 * the stride is calculated like this:
2624 * 1) if the constant buffer variables are packed with packoffset
2625 * - stride = the highest used constant
2626 * - the complete stride has to be a multiple of 0x10
2628 * 2) if the constant buffer variables are NOT packed with packoffset
2629 * - sum of unpacked size for all variables which fit in a 0x10 part
2630 * - if the size exceeds a 0x10 part, the rest of the old part is skipped
2631 * and a new part is started
2632 * - if the variable is a struct it is always used a new part
2633 * - the complete stride has to be a multiple of 0x10
2635 * e.g.:
2636 * 0x4, 0x4, 0x4, 0x8, 0x4, 0x14, 0x4
2637 * part 0x10 0x10 0x20 -> 0x40
2639 if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
2641 if ((v->type->size_unpacked + v->buffer_offset) > stride)
2643 stride = v->type->size_unpacked + v->buffer_offset;
2646 else
2648 if (v->type->type_class == D3D10_SVC_STRUCT)
2650 stride = (stride + 0xf) & ~0xf;
2653 if ( ((stride & 0xf) + v->type->size_unpacked) > 0x10)
2655 stride = (stride + 0xf) & ~0xf;
2658 stride += v->type->size_unpacked;
2661 l->type->stride = l->type->size_unpacked = (stride + 0xf) & ~0xf;
2663 TRACE("%s constant buffer:\n", prefix);
2664 TRACE("\tType name: %s.\n", debugstr_a(l->type->name));
2665 TRACE("\tElement count: %u.\n", l->type->element_count);
2666 TRACE("\tMember count: %u.\n", l->type->member_count);
2667 TRACE("\tUnpacked size: %#x.\n", l->type->size_unpacked);
2668 TRACE("\tStride: %#x.\n", l->type->stride);
2669 TRACE("\tPacked size %#x.\n", l->type->size_packed);
2670 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l->type->basetype));
2671 TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l->type->type_class));
2673 if (local && l->data_size)
2675 if (FAILED(hr = create_buffer_object(l)))
2677 WARN("Failed to create a buffer object, hr %#x.\n", hr);
2678 return hr;
2682 if (l->explicit_bind_point != ~0u)
2683 l->flag |= D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT;
2685 return S_OK;
2688 static void d3d10_effect_type_member_destroy(struct d3d10_effect_type_member *typem)
2690 TRACE("effect type member %p.\n", typem);
2692 /* Do not release typem->type, it will be covered by d3d10_effect_type_destroy(). */
2693 heap_free(typem->semantic);
2694 heap_free(typem->name);
2697 static void d3d10_effect_type_destroy(struct wine_rb_entry *entry, void *context)
2699 struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, struct d3d10_effect_type, entry);
2701 TRACE("effect type %p.\n", t);
2703 if (t->elementtype)
2705 heap_free(t->elementtype->name);
2706 heap_free(t->elementtype);
2709 if (t->members)
2711 unsigned int i;
2713 for (i = 0; i < t->member_count; ++i)
2715 d3d10_effect_type_member_destroy(&t->members[i]);
2717 heap_free(t->members);
2720 heap_free(t->name);
2721 heap_free(t);
2724 static BOOL d3d10_effect_types_match(const struct d3d10_effect_type *t1,
2725 const struct d3d10_effect_type *t2)
2727 unsigned int i;
2729 if (strcmp(t1->name, t2->name)) return FALSE;
2730 if (t1->basetype != t2->basetype) return FALSE;
2731 if (t1->type_class != t2->type_class) return FALSE;
2732 if (t1->element_count != t2->element_count) return FALSE;
2733 if (t1->element_count) return d3d10_effect_types_match(t1->elementtype, t2->elementtype);
2734 if (t1->member_count != t2->member_count) return FALSE;
2735 if (t1->column_count != t2->column_count) return FALSE;
2736 if (t1->row_count != t2->row_count) return FALSE;
2738 for (i = 0; i < t1->member_count; ++i)
2740 if (strcmp(t1->members[i].name, t2->members[i].name)) return FALSE;
2741 if (t1->members[i].buffer_offset != t2->members[i].buffer_offset) return FALSE;
2742 if (!d3d10_effect_types_match(t1->members[i].type, t2->members[i].type)) return FALSE;
2745 return TRUE;
2748 static HRESULT d3d10_effect_validate_shared_variable(const struct d3d10_effect *effect,
2749 const struct d3d10_effect_variable *v)
2751 struct d3d10_effect_variable *sv;
2753 switch (v->type->basetype)
2755 case D3D10_SVT_CBUFFER:
2756 case D3D10_SVT_TBUFFER:
2757 sv = d3d10_effect_get_buffer_by_name(effect->pool, v->name);
2758 break;
2759 default:
2760 sv = d3d10_effect_get_variable_by_name(effect->pool, v->name);
2763 if (!sv)
2765 WARN("Variable %s wasn't found in the pool.\n", debugstr_a(v->name));
2766 return E_INVALIDARG;
2769 if (!d3d10_effect_types_match(sv->type, v->type))
2771 WARN("Variable %s type does not match pool type.\n", debugstr_a(v->name));
2772 return E_INVALIDARG;
2775 return S_OK;
2778 static HRESULT parse_fx10_body(struct d3d10_effect *e, const char *data, DWORD data_size)
2780 const char *ptr;
2781 unsigned int i;
2782 HRESULT hr;
2784 if (e->index_offset >= data_size)
2786 WARN("Invalid index offset %#x (data size %#x).\n", e->index_offset, data_size);
2787 return E_FAIL;
2789 ptr = data + e->index_offset;
2791 if (!(e->local_buffers = heap_calloc(e->local_buffer_count, sizeof(*e->local_buffers))))
2793 ERR("Failed to allocate local buffer memory.\n");
2794 return E_OUTOFMEMORY;
2797 if (!(e->local_variables = heap_calloc(e->local_variable_count, sizeof(*e->local_variables))))
2799 ERR("Failed to allocate local variable memory.\n");
2800 return E_OUTOFMEMORY;
2803 if (!(e->anonymous_shaders = heap_calloc(e->anonymous_shader_count, sizeof(*e->anonymous_shaders))))
2805 ERR("Failed to allocate anonymous shaders memory\n");
2806 return E_OUTOFMEMORY;
2809 if (!(e->used_shaders = heap_calloc(e->used_shader_count, sizeof(*e->used_shaders))))
2811 ERR("Failed to allocate used shaders memory\n");
2812 return E_OUTOFMEMORY;
2815 if (!(e->techniques = heap_calloc(e->technique_count, sizeof(*e->techniques))))
2817 ERR("Failed to allocate techniques memory\n");
2818 return E_OUTOFMEMORY;
2821 for (i = 0; i < e->local_buffer_count; ++i)
2823 struct d3d10_effect_variable *l = &e->local_buffers[i];
2824 l->ID3D10EffectVariable_iface.lpVtbl = (const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl;
2825 l->effect = e;
2826 l->buffer = &null_local_buffer;
2828 if (FAILED(hr = parse_fx10_buffer(data, data_size, &ptr, TRUE, l)))
2829 return hr;
2832 for (i = 0; i < e->local_variable_count; ++i)
2834 struct d3d10_effect_variable *v = &e->local_variables[i];
2836 v->effect = e;
2837 v->ID3D10EffectVariable_iface.lpVtbl = &d3d10_effect_variable_vtbl;
2838 v->buffer = &null_local_buffer;
2840 if (FAILED(hr = parse_fx10_object_variable(data, data_size, &ptr, FALSE, v)))
2841 return hr;
2844 for (i = 0; i < e->shared_buffer_count; ++i)
2846 struct d3d10_effect_variable b = {{ 0 }};
2848 b.effect = e;
2850 if (FAILED(hr = parse_fx10_buffer(data, data_size, &ptr, FALSE, &b)))
2852 d3d10_effect_variable_destroy(&b);
2853 return hr;
2856 hr = d3d10_effect_validate_shared_variable(e, &b);
2857 d3d10_effect_variable_destroy(&b);
2858 if (FAILED(hr)) return hr;
2861 for (i = 0; i < e->shared_object_count; ++i)
2863 struct d3d10_effect_variable o = {{ 0 }};
2865 o.effect = e;
2867 if (FAILED(hr = parse_fx10_object_variable(data, data_size, &ptr, TRUE, &o)))
2869 d3d10_effect_variable_destroy(&o);
2870 return hr;
2873 hr = d3d10_effect_validate_shared_variable(e, &o);
2874 d3d10_effect_variable_destroy(&o);
2875 if (FAILED(hr)) return hr;
2878 for (i = 0; i < e->technique_count; ++i)
2880 struct d3d10_effect_technique *t = &e->techniques[i];
2882 t->ID3D10EffectTechnique_iface.lpVtbl = &d3d10_effect_technique_vtbl;
2883 t->effect = e;
2885 if (FAILED(hr = parse_fx10_technique(data, data_size, &ptr, t)))
2886 return hr;
2889 return S_OK;
2892 static HRESULT parse_fx10(struct d3d10_effect *e, const char *data, DWORD data_size)
2894 const char *ptr = data;
2895 DWORD unused;
2897 if (!require_space(0, 19, sizeof(DWORD), data_size))
2899 WARN("Invalid data size %#x.\n", data_size);
2900 return E_INVALIDARG;
2903 /* Compiled target version (e.g. fx_4_0=0xfeff1001, fx_4_1=0xfeff1011). */
2904 read_dword(&ptr, &e->version);
2905 TRACE("Target: %#x\n", e->version);
2907 read_dword(&ptr, &e->local_buffer_count);
2908 TRACE("Local buffer count: %u.\n", e->local_buffer_count);
2910 read_dword(&ptr, &e->variable_count);
2911 TRACE("Variable count: %u\n", e->variable_count);
2913 read_dword(&ptr, &e->local_variable_count);
2914 TRACE("Object count: %u\n", e->local_variable_count);
2916 read_dword(&ptr, &e->shared_buffer_count);
2917 TRACE("Pool buffer count: %u\n", e->shared_buffer_count);
2919 read_dword(&ptr, &unused);
2920 TRACE("Pool variable count: %u\n", unused);
2922 read_dword(&ptr, &e->shared_object_count);
2923 TRACE("Pool objects count: %u\n", e->shared_object_count);
2925 read_dword(&ptr, &e->technique_count);
2926 TRACE("Technique count: %u\n", e->technique_count);
2928 read_dword(&ptr, &e->index_offset);
2929 TRACE("Index offset: %#x\n", e->index_offset);
2931 read_dword(&ptr, &unused);
2932 TRACE("String count: %u\n", unused);
2934 read_dword(&ptr, &e->texture_count);
2935 TRACE("Texture count: %u\n", e->texture_count);
2937 read_dword(&ptr, &e->depthstencilstate_count);
2938 TRACE("Depthstencilstate count: %u\n", e->depthstencilstate_count);
2940 read_dword(&ptr, &e->blendstate_count);
2941 TRACE("Blendstate count: %u\n", e->blendstate_count);
2943 read_dword(&ptr, &e->rasterizerstate_count);
2944 TRACE("Rasterizerstate count: %u\n", e->rasterizerstate_count);
2946 read_dword(&ptr, &e->samplerstate_count);
2947 TRACE("Samplerstate count: %u\n", e->samplerstate_count);
2949 read_dword(&ptr, &e->rendertargetview_count);
2950 TRACE("Rendertargetview count: %u\n", e->rendertargetview_count);
2952 read_dword(&ptr, &e->depthstencilview_count);
2953 TRACE("Depthstencilview count: %u\n", e->depthstencilview_count);
2955 read_dword(&ptr, &e->used_shader_count);
2956 TRACE("Used shader count: %u\n", e->used_shader_count);
2958 read_dword(&ptr, &e->anonymous_shader_count);
2959 TRACE("Anonymous shader count: %u\n", e->anonymous_shader_count);
2961 if (!e->pool && (e->shared_object_count || e->shared_buffer_count))
2963 WARN("Effect requires a pool to load.\n");
2964 return E_FAIL;
2967 return parse_fx10_body(e, ptr, data_size - (ptr - data));
2970 static HRESULT fx10_chunk_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
2972 struct d3d10_effect *e = ctx;
2974 TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
2976 TRACE("chunk size: %#x\n", data_size);
2978 switch(tag)
2980 case TAG_FX10:
2981 return parse_fx10(e, data, data_size);
2983 default:
2984 FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag, 4));
2985 return S_OK;
2989 HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T data_size)
2991 return parse_dxbc(data, data_size, fx10_chunk_handler, This);
2994 static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_variable *s,
2995 D3D10_SHADER_VARIABLE_TYPE type)
2997 if (s->reflection)
2998 s->reflection->lpVtbl->Release(s->reflection);
2999 if (s->input_signature)
3000 ID3D10Blob_Release(s->input_signature);
3001 if (s->bytecode)
3002 ID3D10Blob_Release(s->bytecode);
3004 switch (type)
3006 case D3D10_SVT_VERTEXSHADER:
3007 case D3D10_SVT_PIXELSHADER:
3008 case D3D10_SVT_GEOMETRYSHADER:
3009 if (s->shader.object)
3010 IUnknown_Release(s->shader.object);
3011 break;
3013 default:
3014 FIXME("Unhandled shader type %s.\n", debug_d3d10_shader_variable_type(type));
3015 break;
3018 if (s->resource_count)
3019 heap_free(s->resources);
3022 static void d3d10_effect_annotations_destroy(struct d3d10_effect_annotations *a)
3024 unsigned int i;
3026 if (!a->elements) return;
3028 for (i = 0; i < a->count; ++i)
3029 d3d10_effect_variable_destroy(&a->elements[i]);
3030 heap_free(a->elements);
3031 a->elements = NULL;
3032 a->count = 0;
3035 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v)
3037 unsigned int i, elem_count;
3039 TRACE("variable %p.\n", v);
3041 heap_free(v->name);
3042 heap_free(v->semantic);
3043 d3d10_effect_annotations_destroy(&v->annotations);
3045 if (v->members)
3047 for (i = 0; i < v->type->member_count; ++i)
3049 d3d10_effect_variable_destroy(&v->members[i]);
3051 heap_free(v->members);
3054 if (v->elements)
3056 for (i = 0; i < v->type->element_count; ++i)
3058 d3d10_effect_variable_destroy(&v->elements[i]);
3060 heap_free(v->elements);
3063 if (v->type)
3065 switch (v->type->basetype)
3067 case D3D10_SVT_VERTEXSHADER:
3068 case D3D10_SVT_PIXELSHADER:
3069 case D3D10_SVT_GEOMETRYSHADER:
3070 d3d10_effect_shader_variable_destroy(&v->u.shader, v->type->basetype);
3071 break;
3073 case D3D10_SVT_DEPTHSTENCIL:
3074 case D3D10_SVT_BLEND:
3075 case D3D10_SVT_RASTERIZER:
3076 case D3D10_SVT_SAMPLER:
3077 if (v->u.state.object.object)
3078 IUnknown_Release(v->u.state.object.object);
3079 break;
3081 case D3D10_SVT_TEXTURE1D:
3082 case D3D10_SVT_TEXTURE1DARRAY:
3083 case D3D10_SVT_TEXTURE2D:
3084 case D3D10_SVT_TEXTURE2DARRAY:
3085 case D3D10_SVT_TEXTURE2DMS:
3086 case D3D10_SVT_TEXTURE2DMSARRAY:
3087 case D3D10_SVT_TEXTURE3D:
3088 case D3D10_SVT_TEXTURECUBE:
3089 if (!v->u.resource.parent)
3090 break;
3092 if (!v->type->element_count)
3093 elem_count = 1;
3094 else
3095 elem_count = v->type->element_count;
3097 for (i = 0; i < elem_count; ++i)
3099 if (v->u.resource.srv[i])
3100 ID3D10ShaderResourceView_Release(v->u.resource.srv[i]);
3103 heap_free(v->u.resource.srv);
3104 break;
3106 case D3D10_SVT_STRING:
3107 heap_free(v->u.buffer.local_buffer);
3108 break;
3110 default:
3111 break;
3116 static void d3d10_effect_pass_destroy(struct d3d10_effect_pass *p)
3118 TRACE("pass %p\n", p);
3120 heap_free(p->name);
3121 d3d10_effect_annotations_destroy(&p->annotations);
3124 static void d3d10_effect_technique_destroy(struct d3d10_effect_technique *t)
3126 unsigned int i;
3128 TRACE("technique %p\n", t);
3130 heap_free(t->name);
3131 if (t->passes)
3133 for (i = 0; i < t->pass_count; ++i)
3135 d3d10_effect_pass_destroy(&t->passes[i]);
3137 heap_free(t->passes);
3140 d3d10_effect_annotations_destroy(&t->annotations);
3143 static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable *l)
3145 unsigned int i;
3147 TRACE("local buffer %p.\n", l);
3149 heap_free(l->name);
3150 if (l->members)
3152 for (i = 0; i < l->type->member_count; ++i)
3154 d3d10_effect_variable_destroy(&l->members[i]);
3156 heap_free(l->members);
3159 if (l->type)
3160 d3d10_effect_type_destroy(&l->type->entry, NULL);
3162 d3d10_effect_annotations_destroy(&l->annotations);
3163 heap_free(l->u.buffer.local_buffer);
3165 if (l->u.buffer.buffer)
3166 ID3D10Buffer_Release(l->u.buffer.buffer);
3167 if (l->u.buffer.resource_view)
3168 ID3D10ShaderResourceView_Release(l->u.buffer.resource_view);
3171 /* IUnknown methods */
3173 static inline struct d3d10_effect *impl_from_ID3D10Effect(ID3D10Effect *iface)
3175 return CONTAINING_RECORD(iface, struct d3d10_effect, ID3D10Effect_iface);
3178 static HRESULT STDMETHODCALLTYPE d3d10_effect_QueryInterface(ID3D10Effect *iface, REFIID riid, void **object)
3180 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
3182 if (IsEqualGUID(riid, &IID_ID3D10Effect)
3183 || IsEqualGUID(riid, &IID_IUnknown))
3185 IUnknown_AddRef(iface);
3186 *object = iface;
3187 return S_OK;
3190 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
3192 *object = NULL;
3193 return E_NOINTERFACE;
3196 static ULONG STDMETHODCALLTYPE d3d10_effect_AddRef(ID3D10Effect *iface)
3198 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3199 ULONG refcount = InterlockedIncrement(&This->refcount);
3201 TRACE("%p increasing refcount to %u\n", This, refcount);
3203 return refcount;
3206 static ULONG STDMETHODCALLTYPE d3d10_effect_Release(ID3D10Effect *iface)
3208 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3209 ULONG refcount = InterlockedDecrement(&This->refcount);
3211 TRACE("%p decreasing refcount to %u\n", This, refcount);
3213 if (!refcount)
3215 unsigned int i;
3217 if (This->techniques)
3219 for (i = 0; i < This->technique_count; ++i)
3221 d3d10_effect_technique_destroy(&This->techniques[i]);
3223 heap_free(This->techniques);
3226 if (This->local_variables)
3228 for (i = 0; i < This->local_variable_count; ++i)
3230 d3d10_effect_variable_destroy(&This->local_variables[i]);
3232 heap_free(This->local_variables);
3235 if (This->local_buffers)
3237 for (i = 0; i < This->local_buffer_count; ++i)
3239 d3d10_effect_local_buffer_destroy(&This->local_buffers[i]);
3241 heap_free(This->local_buffers);
3244 if (This->anonymous_shaders)
3246 for (i = 0; i < This->anonymous_shader_count; ++i)
3248 d3d10_effect_variable_destroy(&This->anonymous_shaders[i].shader);
3249 heap_free(This->anonymous_shaders[i].type.name);
3251 heap_free(This->anonymous_shaders);
3254 heap_free(This->used_shaders);
3256 wine_rb_destroy(&This->types, d3d10_effect_type_destroy, NULL);
3258 if (This->pool)
3259 IUnknown_Release(&This->pool->ID3D10Effect_iface);
3260 ID3D10Device_Release(This->device);
3261 heap_free(This);
3264 return refcount;
3267 /* ID3D10Effect methods */
3269 static BOOL STDMETHODCALLTYPE d3d10_effect_IsValid(ID3D10Effect *iface)
3271 FIXME("iface %p stub!\n", iface);
3273 return FALSE;
3276 static BOOL STDMETHODCALLTYPE d3d10_effect_IsPool(ID3D10Effect *iface)
3278 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
3280 TRACE("iface %p.\n", iface);
3282 return effect->ID3D10Effect_iface.lpVtbl == &d3d10_effect_pool_effect_vtbl;
3285 static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDevice(ID3D10Effect *iface, ID3D10Device **device)
3287 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3289 TRACE("iface %p, device %p\n", iface, device);
3291 ID3D10Device_AddRef(This->device);
3292 *device = This->device;
3294 return S_OK;
3297 static void d3d10_effect_get_desc(const struct d3d10_effect *effect, D3D10_EFFECT_DESC *desc)
3299 unsigned int i;
3301 desc->IsChildEffect = !!effect->pool;
3302 desc->ConstantBuffers = effect->local_buffer_count;
3303 desc->SharedConstantBuffers = 0;
3304 desc->GlobalVariables = effect->local_variable_count;
3305 for (i = 0; i < effect->local_buffer_count; ++i)
3307 desc->GlobalVariables += effect->local_buffers[i].type->member_count;
3309 desc->SharedGlobalVariables = 0;
3310 desc->Techniques = effect->technique_count;
3313 static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDesc(ID3D10Effect *iface, D3D10_EFFECT_DESC *desc)
3315 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
3316 D3D10_EFFECT_DESC pool_desc = { 0 };
3318 TRACE("iface %p, desc %p.\n", iface, desc);
3320 if (!desc)
3321 return E_INVALIDARG;
3323 if (effect->pool)
3324 d3d10_effect_get_desc(effect->pool, &pool_desc);
3326 d3d10_effect_get_desc(effect, desc);
3328 desc->SharedConstantBuffers = pool_desc.ConstantBuffers;
3329 desc->SharedGlobalVariables = pool_desc.GlobalVariables;
3331 return S_OK;
3334 static struct d3d10_effect_variable * d3d10_effect_get_buffer_by_index(struct d3d10_effect *effect,
3335 unsigned int index)
3337 if (index < effect->local_buffer_count)
3338 return &effect->local_buffers[index];
3339 index -= effect->local_buffer_count;
3341 return effect->pool ? d3d10_effect_get_buffer_by_index(effect->pool, index) : NULL;
3344 static BOOL is_var_shared(const struct d3d10_effect_variable *v)
3346 return !!(v->flag & D3D10_EFFECT_VARIABLE_POOLED);
3349 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetConstantBufferByIndex(ID3D10Effect *iface,
3350 UINT index)
3352 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
3353 struct d3d10_effect_variable *v;
3355 TRACE("iface %p, index %u\n", iface, index);
3357 if ((v = d3d10_effect_get_buffer_by_index(effect, index)))
3359 TRACE("Returning %sbuffer %p, name %s.\n", is_var_shared(v) ? "shared " : "", v,
3360 debugstr_a(v->name));
3361 return (ID3D10EffectConstantBuffer *)&v->ID3D10EffectVariable_iface;
3364 WARN("Invalid index specified\n");
3366 return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
3369 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetConstantBufferByName(ID3D10Effect *iface,
3370 const char *name)
3372 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
3373 struct d3d10_effect_variable *v;
3375 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3377 if ((v = d3d10_effect_get_buffer_by_name(effect, name)))
3379 TRACE("Returning %sbuffer %p.\n", is_var_shared(v) ? "shared " : "", v);
3380 return (ID3D10EffectConstantBuffer *)&v->ID3D10EffectVariable_iface;
3383 WARN("Invalid name specified\n");
3385 return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
3388 static struct d3d10_effect_variable * d3d10_effect_get_variable_by_index(
3389 const struct d3d10_effect *effect, unsigned int index)
3391 unsigned int i;
3393 for (i = 0; i < effect->local_buffer_count; ++i)
3395 struct d3d10_effect_variable *v = &effect->local_buffers[i];
3396 if (index < v->type->member_count)
3397 return &v->members[index];
3398 index -= v->type->member_count;
3401 if (index < effect->local_variable_count)
3402 return &effect->local_variables[index];
3403 index -= effect->local_variable_count;
3405 return effect->pool ? d3d10_effect_get_variable_by_index(effect->pool, index) : NULL;
3408 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableByIndex(ID3D10Effect *iface, UINT index)
3410 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
3411 struct d3d10_effect_variable *v;
3413 TRACE("iface %p, index %u\n", iface, index);
3415 if ((v = d3d10_effect_get_variable_by_index(effect, index)))
3417 TRACE("Returning %svariable %s.\n", is_var_shared(v) ? "shared " : NULL, debugstr_a(v->name));
3418 return &v->ID3D10EffectVariable_iface;
3421 WARN("Invalid index specified\n");
3423 return &null_variable.ID3D10EffectVariable_iface;
3426 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableByName(ID3D10Effect *iface,
3427 const char *name)
3429 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
3430 struct d3d10_effect_variable *v;
3432 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3434 if (!name)
3436 WARN("Invalid name specified\n");
3437 return &null_variable.ID3D10EffectVariable_iface;
3440 if ((v = d3d10_effect_get_variable_by_name(effect, name)))
3442 TRACE("Returning %svariable %p.\n", is_var_shared(v) ? "shared " : "", v);
3443 return &v->ID3D10EffectVariable_iface;
3446 WARN("Invalid name specified\n");
3448 return &null_variable.ID3D10EffectVariable_iface;
3451 static struct d3d10_effect_variable * d3d10_effect_get_variable_by_semantic(
3452 const struct d3d10_effect *effect, const char *semantic)
3454 unsigned int i;
3456 for (i = 0; i < effect->local_buffer_count; ++i)
3458 struct d3d10_effect_variable *l = &effect->local_buffers[i];
3459 unsigned int j;
3461 for (j = 0; j < l->type->member_count; ++j)
3463 struct d3d10_effect_variable *v = &l->members[j];
3465 if (v->semantic && !stricmp(v->semantic, semantic))
3466 return v;
3470 for (i = 0; i < effect->local_variable_count; ++i)
3472 struct d3d10_effect_variable *v = &effect->local_variables[i];
3474 if (v->semantic && !stricmp(v->semantic, semantic))
3475 return v;
3478 return effect->pool ? d3d10_effect_get_variable_by_semantic(effect->pool, semantic) : NULL;
3481 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableBySemantic(ID3D10Effect *iface,
3482 const char *semantic)
3484 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
3485 struct d3d10_effect_variable *v;
3487 TRACE("iface %p, semantic %s\n", iface, debugstr_a(semantic));
3489 if (!semantic)
3491 WARN("Invalid semantic specified\n");
3492 return &null_variable.ID3D10EffectVariable_iface;
3495 if ((v = d3d10_effect_get_variable_by_semantic(effect, semantic)))
3497 TRACE("Returning %svariable %s.\n", is_var_shared(v) ? "shared " : "", debugstr_a(v->name));
3498 return &v->ID3D10EffectVariable_iface;
3501 WARN("Invalid semantic specified\n");
3503 return &null_variable.ID3D10EffectVariable_iface;
3506 static struct ID3D10EffectTechnique * STDMETHODCALLTYPE d3d10_effect_GetTechniqueByIndex(ID3D10Effect *iface,
3507 UINT index)
3509 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3510 struct d3d10_effect_technique *t;
3512 TRACE("iface %p, index %u\n", iface, index);
3514 if (index >= This->technique_count)
3516 WARN("Invalid index specified\n");
3517 return &null_technique.ID3D10EffectTechnique_iface;
3520 t = &This->techniques[index];
3522 TRACE("Returning technique %p, %s.\n", t, debugstr_a(t->name));
3524 return &t->ID3D10EffectTechnique_iface;
3527 static struct ID3D10EffectTechnique * STDMETHODCALLTYPE d3d10_effect_GetTechniqueByName(ID3D10Effect *iface,
3528 const char *name)
3530 struct d3d10_effect *This = impl_from_ID3D10Effect(iface);
3531 unsigned int i;
3533 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3535 if (!name)
3537 WARN("Invalid name specified\n");
3538 return &null_technique.ID3D10EffectTechnique_iface;
3541 for (i = 0; i < This->technique_count; ++i)
3543 struct d3d10_effect_technique *t = &This->techniques[i];
3544 if (t->name && !strcmp(t->name, name))
3546 TRACE("Returning technique %p\n", t);
3547 return &t->ID3D10EffectTechnique_iface;
3551 WARN("Invalid name specified\n");
3553 return &null_technique.ID3D10EffectTechnique_iface;
3556 static HRESULT STDMETHODCALLTYPE d3d10_effect_Optimize(ID3D10Effect *iface)
3558 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
3559 struct d3d10_effect_variable *v;
3560 unsigned int i, j;
3562 FIXME("iface %p semi-stub!\n", iface);
3564 if (effect->flags & D3D10_EFFECT_OPTIMIZED)
3565 return S_OK;
3567 for (i = 0; i < effect->used_shader_count; ++i)
3569 v = effect->used_shaders[i];
3571 if (v->u.shader.reflection)
3573 v->u.shader.reflection->lpVtbl->Release(v->u.shader.reflection);
3574 v->u.shader.reflection = NULL;
3576 if (v->u.shader.bytecode)
3578 ID3D10Blob_Release(v->u.shader.bytecode);
3579 v->u.shader.bytecode = NULL;
3581 heap_free(v->u.shader.stream_output_declaration);
3582 v->u.shader.stream_output_declaration = NULL;
3585 for (i = 0; i < effect->technique_count; ++i)
3587 for (j = 0; j < effect->techniques[i].pass_count; ++j)
3589 heap_free(effect->techniques[i].passes[j].name);
3590 effect->techniques[i].passes[j].name = NULL;
3593 heap_free(effect->techniques[i].name);
3594 effect->techniques[i].name = NULL;
3597 effect->flags |= D3D10_EFFECT_OPTIMIZED;
3599 return S_OK;
3602 static BOOL STDMETHODCALLTYPE d3d10_effect_IsOptimized(ID3D10Effect *iface)
3604 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
3606 TRACE("iface %p.\n", iface);
3608 return !!(effect->flags & D3D10_EFFECT_OPTIMIZED);
3611 static const struct ID3D10EffectVtbl d3d10_effect_vtbl =
3613 /* IUnknown methods */
3614 d3d10_effect_QueryInterface,
3615 d3d10_effect_AddRef,
3616 d3d10_effect_Release,
3617 /* ID3D10Effect methods */
3618 d3d10_effect_IsValid,
3619 d3d10_effect_IsPool,
3620 d3d10_effect_GetDevice,
3621 d3d10_effect_GetDesc,
3622 d3d10_effect_GetConstantBufferByIndex,
3623 d3d10_effect_GetConstantBufferByName,
3624 d3d10_effect_GetVariableByIndex,
3625 d3d10_effect_GetVariableByName,
3626 d3d10_effect_GetVariableBySemantic,
3627 d3d10_effect_GetTechniqueByIndex,
3628 d3d10_effect_GetTechniqueByName,
3629 d3d10_effect_Optimize,
3630 d3d10_effect_IsOptimized,
3633 /* ID3D10EffectTechnique methods */
3635 static inline struct d3d10_effect_technique *impl_from_ID3D10EffectTechnique(ID3D10EffectTechnique *iface)
3637 return CONTAINING_RECORD(iface, struct d3d10_effect_technique, ID3D10EffectTechnique_iface);
3640 static BOOL STDMETHODCALLTYPE d3d10_effect_technique_IsValid(ID3D10EffectTechnique *iface)
3642 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3644 TRACE("iface %p\n", iface);
3646 return This != &null_technique;
3649 static HRESULT STDMETHODCALLTYPE d3d10_effect_technique_GetDesc(ID3D10EffectTechnique *iface,
3650 D3D10_TECHNIQUE_DESC *desc)
3652 struct d3d10_effect_technique *tech = impl_from_ID3D10EffectTechnique(iface);
3654 TRACE("iface %p, desc %p\n", iface, desc);
3656 if (tech == &null_technique)
3658 WARN("Null technique specified\n");
3659 return E_FAIL;
3662 if (!desc)
3664 WARN("Invalid argument specified\n");
3665 return E_INVALIDARG;
3668 desc->Name = tech->name;
3669 desc->Passes = tech->pass_count;
3670 desc->Annotations = tech->annotations.count;
3672 return S_OK;
3675 static ID3D10EffectVariable * d3d10_annotation_get_by_index(const struct d3d10_effect_annotations *annotations,
3676 unsigned int index)
3678 struct d3d10_effect_variable *a;
3680 if (index >= annotations->count)
3682 WARN("Invalid index specified\n");
3683 return &null_variable.ID3D10EffectVariable_iface;
3686 a = &annotations->elements[index];
3688 TRACE("Returning annotation %p, name %s.\n", a, debugstr_a(a->name));
3690 return &a->ID3D10EffectVariable_iface;
3693 static ID3D10EffectVariable * d3d10_annotation_get_by_name(const struct d3d10_effect_annotations *annotations,
3694 const char *name)
3696 unsigned int i;
3698 for (i = 0; i < annotations->count; ++i)
3700 struct d3d10_effect_variable *a = &annotations->elements[i];
3701 if (a->name && !strcmp(a->name, name))
3703 TRACE("Returning annotation %p.\n", a);
3704 return &a->ID3D10EffectVariable_iface;
3708 WARN("Invalid name specified.\n");
3710 return &null_variable.ID3D10EffectVariable_iface;
3713 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByIndex(
3714 ID3D10EffectTechnique *iface, UINT index)
3716 struct d3d10_effect_technique *tech = impl_from_ID3D10EffectTechnique(iface);
3718 TRACE("iface %p, index %u\n", iface, index);
3720 return d3d10_annotation_get_by_index(&tech->annotations, index);
3723 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_technique_GetAnnotationByName(
3724 ID3D10EffectTechnique *iface, const char *name)
3726 struct d3d10_effect_technique *tech = impl_from_ID3D10EffectTechnique(iface);
3728 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3730 return d3d10_annotation_get_by_name(&tech->annotations, name);
3733 static struct ID3D10EffectPass * STDMETHODCALLTYPE d3d10_effect_technique_GetPassByIndex(ID3D10EffectTechnique *iface,
3734 UINT index)
3736 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3737 struct d3d10_effect_pass *p;
3739 TRACE("iface %p, index %u\n", iface, index);
3741 if (index >= This->pass_count)
3743 WARN("Invalid index specified\n");
3744 return &null_pass.ID3D10EffectPass_iface;
3747 p = &This->passes[index];
3749 TRACE("Returning pass %p, %s.\n", p, debugstr_a(p->name));
3751 return &p->ID3D10EffectPass_iface;
3754 static struct ID3D10EffectPass * STDMETHODCALLTYPE d3d10_effect_technique_GetPassByName(ID3D10EffectTechnique *iface,
3755 const char *name)
3757 struct d3d10_effect_technique *This = impl_from_ID3D10EffectTechnique(iface);
3758 unsigned int i;
3760 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3762 /* Do not check for name==NULL, W7/DX10 crashes in that case. */
3764 for (i = 0; i < This->pass_count; ++i)
3766 struct d3d10_effect_pass *p = &This->passes[i];
3767 if (p->name && !strcmp(p->name, name))
3769 TRACE("Returning pass %p\n", p);
3770 return &p->ID3D10EffectPass_iface;
3774 WARN("Invalid name specified\n");
3776 return &null_pass.ID3D10EffectPass_iface;
3779 static HRESULT STDMETHODCALLTYPE d3d10_effect_technique_ComputeStateBlockMask(ID3D10EffectTechnique *iface,
3780 D3D10_STATE_BLOCK_MASK *mask)
3782 FIXME("iface %p,mask %p stub!\n", iface, mask);
3784 return E_NOTIMPL;
3787 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl =
3789 /* ID3D10EffectTechnique methods */
3790 d3d10_effect_technique_IsValid,
3791 d3d10_effect_technique_GetDesc,
3792 d3d10_effect_technique_GetAnnotationByIndex,
3793 d3d10_effect_technique_GetAnnotationByName,
3794 d3d10_effect_technique_GetPassByIndex,
3795 d3d10_effect_technique_GetPassByName,
3796 d3d10_effect_technique_ComputeStateBlockMask,
3799 /* ID3D10EffectPass methods */
3801 static inline struct d3d10_effect_pass *impl_from_ID3D10EffectPass(ID3D10EffectPass *iface)
3803 return CONTAINING_RECORD(iface, struct d3d10_effect_pass, ID3D10EffectPass_iface);
3806 static BOOL STDMETHODCALLTYPE d3d10_effect_pass_IsValid(ID3D10EffectPass *iface)
3808 struct d3d10_effect_pass *This = impl_from_ID3D10EffectPass(iface);
3810 TRACE("iface %p\n", iface);
3812 return This != &null_pass;
3815 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetDesc(ID3D10EffectPass *iface,
3816 D3D10_PASS_DESC *desc)
3818 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
3819 struct d3d10_effect_variable *vs;
3820 ID3D10Blob *input_signature;
3822 TRACE("iface %p, desc %p.\n", iface, desc);
3824 if (pass == &null_pass)
3826 WARN("Null pass specified\n");
3827 return E_FAIL;
3830 if (!desc)
3832 WARN("Invalid argument specified\n");
3833 return E_INVALIDARG;
3836 vs = d3d10_array_get_element(pass->vs.shader, pass->vs.index);
3837 input_signature = vs->u.shader.input_signature;
3839 desc->Name = pass->name;
3840 desc->Annotations = pass->annotations.count;
3841 if (input_signature)
3843 desc->pIAInputSignature = ID3D10Blob_GetBufferPointer(input_signature);
3844 desc->IAInputSignatureSize = ID3D10Blob_GetBufferSize(input_signature);
3846 else
3848 desc->pIAInputSignature = NULL;
3849 desc->IAInputSignatureSize = 0;
3851 desc->StencilRef = pass->stencil_ref;
3852 desc->SampleMask = pass->sample_mask;
3853 memcpy(desc->BlendFactor, pass->blend_factor, 4 * sizeof(float));
3855 return S_OK;
3858 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetVertexShaderDesc(ID3D10EffectPass *iface,
3859 D3D10_PASS_SHADER_DESC *desc)
3861 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
3863 TRACE("iface %p, desc %p.\n", iface, desc);
3865 if (pass == &null_pass)
3867 WARN("Null pass specified.\n");
3868 return E_FAIL;
3871 if (!desc)
3873 WARN("Invalid argument specified.\n");
3874 return E_INVALIDARG;
3877 desc->pShaderVariable = (ID3D10EffectShaderVariable *)&pass->vs.shader->ID3D10EffectVariable_iface;
3878 desc->ShaderIndex = pass->vs.index;
3880 return S_OK;
3883 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetGeometryShaderDesc(ID3D10EffectPass *iface,
3884 D3D10_PASS_SHADER_DESC *desc)
3886 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
3888 TRACE("iface %p, desc %p.\n", iface, desc);
3890 if (pass == &null_pass)
3892 WARN("Null pass specified.\n");
3893 return E_FAIL;
3896 if (!desc)
3898 WARN("Invalid argument specified.\n");
3899 return E_INVALIDARG;
3902 desc->pShaderVariable = (ID3D10EffectShaderVariable *)&pass->gs.shader->ID3D10EffectVariable_iface;
3903 desc->ShaderIndex = pass->gs.index;
3905 return S_OK;
3908 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_GetPixelShaderDesc(ID3D10EffectPass *iface,
3909 D3D10_PASS_SHADER_DESC *desc)
3911 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
3913 TRACE("iface %p, desc %p.\n", iface, desc);
3915 if (pass == &null_pass)
3917 WARN("Null pass specified.\n");
3918 return E_FAIL;
3921 if (!desc)
3923 WARN("Invalid argument specified.\n");
3924 return E_INVALIDARG;
3927 desc->pShaderVariable = (ID3D10EffectShaderVariable *)&pass->ps.shader->ID3D10EffectVariable_iface;
3928 desc->ShaderIndex = pass->ps.index;
3930 return S_OK;
3933 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByIndex(ID3D10EffectPass *iface,
3934 UINT index)
3936 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
3938 TRACE("iface %p, index %u\n", iface, index);
3940 return d3d10_annotation_get_by_index(&pass->annotations, index);
3943 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_pass_GetAnnotationByName(ID3D10EffectPass *iface,
3944 const char *name)
3946 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
3948 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
3950 return d3d10_annotation_get_by_name(&pass->annotations, name);
3953 static void update_buffer(ID3D10Device *device, struct d3d10_effect_variable *v)
3955 struct d3d10_effect_buffer_variable *b = &v->u.buffer;
3957 if (!b->changed)
3958 return;
3960 ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)b->buffer, 0, NULL,
3961 b->local_buffer, v->data_size, 0);
3963 b->changed = FALSE;
3966 static void set_sampler(ID3D10Device *device, D3D10_SHADER_VARIABLE_TYPE shader_type,
3967 struct d3d10_effect_variable *v, unsigned int bind_point)
3969 switch (shader_type)
3971 case D3D10_SVT_VERTEXSHADER:
3972 ID3D10Device_VSSetSamplers(device, bind_point, 1, &v->u.state.object.sampler);
3973 break;
3975 case D3D10_SVT_PIXELSHADER:
3976 ID3D10Device_PSSetSamplers(device, bind_point, 1, &v->u.state.object.sampler);
3977 break;
3979 case D3D10_SVT_GEOMETRYSHADER:
3980 ID3D10Device_GSSetSamplers(device, bind_point, 1, &v->u.state.object.sampler);
3981 break;
3983 default:
3984 WARN("Incorrect shader type to bind sampler.\n");
3985 break;
3989 static void apply_shader_resources(ID3D10Device *device, struct d3d10_effect_variable *v)
3991 struct d3d10_effect_shader_variable *sv = &v->u.shader;
3992 struct d3d10_effect_shader_resource *sr;
3993 struct d3d10_effect_variable *rsrc_v;
3994 ID3D10ShaderResourceView **srv;
3995 unsigned int i, j;
3997 for (i = 0; i < sv->resource_count; ++i)
3999 sr = &sv->resources[i];
4000 rsrc_v = sr->variable;
4002 switch (sr->in_type)
4004 case D3D10_SIT_CBUFFER:
4005 update_buffer(device, rsrc_v);
4006 switch (v->type->basetype)
4008 case D3D10_SVT_VERTEXSHADER:
4009 ID3D10Device_VSSetConstantBuffers(device, sr->bind_point, 1,
4010 &rsrc_v->u.buffer.buffer);
4011 break;
4013 case D3D10_SVT_PIXELSHADER:
4014 ID3D10Device_PSSetConstantBuffers(device, sr->bind_point, 1,
4015 &rsrc_v->u.buffer.buffer);
4016 break;
4018 case D3D10_SVT_GEOMETRYSHADER:
4019 ID3D10Device_GSSetConstantBuffers(device, sr->bind_point, 1,
4020 &rsrc_v->u.buffer.buffer);
4021 break;
4023 default:
4024 WARN("Incorrect shader type to bind constant buffer.\n");
4025 break;
4027 break;
4029 case D3D10_SIT_TEXTURE:
4031 if (rsrc_v->type->basetype == D3D10_SVT_SAMPLER)
4033 TRACE("Using texture associated with sampler %s.\n", debugstr_a(rsrc_v->name));
4034 rsrc_v = rsrc_v->u.state.desc.sampler.texture;
4037 /* fallthrough */
4038 case D3D10_SIT_TBUFFER:
4040 if (sr->in_type == D3D10_SIT_TBUFFER)
4042 update_buffer(device, rsrc_v);
4043 srv = &rsrc_v->u.buffer.resource_view;
4045 else
4046 srv = rsrc_v->u.resource.srv;
4048 switch (v->type->basetype)
4050 case D3D10_SVT_VERTEXSHADER:
4051 ID3D10Device_VSSetShaderResources(device, sr->bind_point, sr->bind_count, srv);
4052 break;
4054 case D3D10_SVT_PIXELSHADER:
4055 ID3D10Device_PSSetShaderResources(device, sr->bind_point, sr->bind_count, srv);
4056 break;
4058 case D3D10_SVT_GEOMETRYSHADER:
4059 ID3D10Device_GSSetShaderResources(device, sr->bind_point, sr->bind_count, srv);
4060 break;
4062 default:
4063 WARN("Incorrect shader type to bind shader resource view.\n");
4064 break;
4066 break;
4068 case D3D10_SIT_SAMPLER:
4069 if (!rsrc_v->type->element_count)
4071 set_sampler(device, v->type->basetype, rsrc_v, sr->bind_point);
4072 break;
4075 for (j = 0; j < sr->bind_count; ++j)
4076 set_sampler(device, v->type->basetype, &rsrc_v->elements[j], sr->bind_point + j);
4077 break;
4079 default:
4080 WARN("Unhandled shader resource %#x.\n", sr->in_type);
4081 break;
4086 static void d3d10_effect_pass_set_shader(struct d3d10_effect_pass *pass,
4087 const struct d3d10_effect_pass_shader_desc *shader_desc)
4089 ID3D10Device *device = pass->technique->effect->device;
4090 struct d3d10_effect_variable *v;
4092 v = d3d10_array_get_element(shader_desc->shader, shader_desc->index);
4094 switch (v->type->basetype)
4096 case D3D10_SVT_VERTEXSHADER:
4097 ID3D10Device_VSSetShader(device, v->u.shader.shader.vs);
4098 break;
4099 case D3D10_SVT_PIXELSHADER:
4100 ID3D10Device_PSSetShader(device, v->u.shader.shader.ps);
4101 break;
4102 case D3D10_SVT_GEOMETRYSHADER:
4103 ID3D10Device_GSSetShader(device, v->u.shader.shader.gs);
4104 break;
4105 default:
4106 WARN("Unexpected shader type %u.\n", v->type->basetype);
4109 apply_shader_resources(device, v);
4112 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_Apply(ID3D10EffectPass *iface, UINT flags)
4114 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
4115 ID3D10Device *device = pass->technique->effect->device;
4117 TRACE("iface %p, flags %#x\n", iface, flags);
4119 if (flags) FIXME("Ignoring flags (%#x)\n", flags);
4121 if (pass->vs.shader != &null_shader_variable)
4122 d3d10_effect_pass_set_shader(pass, &pass->vs);
4123 if (pass->gs.shader != &null_shader_variable)
4124 d3d10_effect_pass_set_shader(pass, &pass->gs);
4125 if (pass->ps.shader != &null_shader_variable)
4126 d3d10_effect_pass_set_shader(pass, &pass->ps);
4127 if (pass->rasterizer)
4128 ID3D10Device_RSSetState(device, pass->rasterizer->u.state.object.rasterizer);
4129 if (pass->depth_stencil)
4130 ID3D10Device_OMSetDepthStencilState(device, pass->depth_stencil->u.state.object.depth_stencil,
4131 pass->stencil_ref);
4132 if (pass->blend)
4133 ID3D10Device_OMSetBlendState(device, pass->blend->u.state.object.blend,
4134 pass->blend_factor, pass->sample_mask);
4136 return S_OK;
4139 static HRESULT STDMETHODCALLTYPE d3d10_effect_pass_ComputeStateBlockMask(ID3D10EffectPass *iface,
4140 D3D10_STATE_BLOCK_MASK *mask)
4142 struct d3d10_effect_pass *pass = impl_from_ID3D10EffectPass(iface);
4144 FIXME("iface %p, mask %p semi-stub!\n", iface, mask);
4146 if (pass->vs.shader != &null_shader_variable)
4147 D3D10StateBlockMaskEnableCapture(mask, D3D10_DST_VS, 0, 1);
4148 if (pass->ps.shader != &null_shader_variable)
4149 D3D10StateBlockMaskEnableCapture(mask, D3D10_DST_PS, 0, 1);
4150 if (pass->gs.shader != &null_shader_variable)
4151 D3D10StateBlockMaskEnableCapture(mask, D3D10_DST_GS, 0, 1);
4152 if (pass->rasterizer)
4153 D3D10StateBlockMaskEnableCapture(mask, D3D10_DST_RS_RASTERIZER_STATE, 0, 1);
4154 if (pass->depth_stencil)
4155 D3D10StateBlockMaskEnableCapture(mask, D3D10_DST_OM_DEPTH_STENCIL_STATE, 0, 1);
4156 if (pass->blend)
4157 D3D10StateBlockMaskEnableCapture(mask, D3D10_DST_OM_BLEND_STATE, 0, 1);
4159 return S_OK;
4162 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl =
4164 /* ID3D10EffectPass methods */
4165 d3d10_effect_pass_IsValid,
4166 d3d10_effect_pass_GetDesc,
4167 d3d10_effect_pass_GetVertexShaderDesc,
4168 d3d10_effect_pass_GetGeometryShaderDesc,
4169 d3d10_effect_pass_GetPixelShaderDesc,
4170 d3d10_effect_pass_GetAnnotationByIndex,
4171 d3d10_effect_pass_GetAnnotationByName,
4172 d3d10_effect_pass_Apply,
4173 d3d10_effect_pass_ComputeStateBlockMask,
4176 /* ID3D10EffectVariable methods */
4178 static BOOL STDMETHODCALLTYPE d3d10_effect_variable_IsValid(ID3D10EffectVariable *iface)
4180 TRACE("iface %p\n", iface);
4182 return impl_from_ID3D10EffectVariable(iface) != &null_variable;
4185 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_variable_GetType(ID3D10EffectVariable *iface)
4187 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4189 TRACE("iface %p\n", iface);
4191 return &This->type->ID3D10EffectType_iface;
4194 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetDesc(ID3D10EffectVariable *iface,
4195 D3D10_EFFECT_VARIABLE_DESC *desc)
4197 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable(iface);
4199 TRACE("iface %p, desc %p\n", iface, desc);
4201 if (!iface->lpVtbl->IsValid(iface))
4203 WARN("Null variable specified\n");
4204 return E_FAIL;
4207 if (!desc)
4209 WARN("Invalid argument specified\n");
4210 return E_INVALIDARG;
4213 /* FIXME: This isn't correct. Anonymous shaders let desc->ExplicitBindPoint untouched, but normal shaders set it! */
4214 memset(desc, 0, sizeof(*desc));
4215 desc->Name = v->name;
4216 desc->Semantic = v->semantic;
4217 desc->Flags = v->flag;
4218 desc->Annotations = v->annotations.count;
4219 desc->BufferOffset = v->buffer_offset;
4221 if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT)
4222 desc->ExplicitBindPoint = v->explicit_bind_point;
4224 return S_OK;
4227 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByIndex(
4228 ID3D10EffectVariable *iface, UINT index)
4230 struct d3d10_effect_variable *var = impl_from_ID3D10EffectVariable(iface);
4232 TRACE("iface %p, index %u\n", iface, index);
4234 return d3d10_annotation_get_by_index(&var->annotations, index);
4237 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetAnnotationByName(
4238 ID3D10EffectVariable *iface, const char *name)
4240 struct d3d10_effect_variable *var = impl_from_ID3D10EffectVariable(iface);
4242 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
4244 return d3d10_annotation_get_by_name(&var->annotations, name);
4247 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberByIndex(
4248 ID3D10EffectVariable *iface, UINT index)
4250 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4251 struct d3d10_effect_variable *m;
4253 TRACE("iface %p, index %u\n", iface, index);
4255 if (index >= This->type->member_count)
4257 WARN("Invalid index specified\n");
4258 return &null_variable.ID3D10EffectVariable_iface;
4261 m = &This->members[index];
4263 TRACE("Returning member %p, %s\n", m, debugstr_a(m->name));
4265 return &m->ID3D10EffectVariable_iface;
4268 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberByName(
4269 ID3D10EffectVariable *iface, const char *name)
4271 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4272 unsigned int i;
4274 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
4276 if (!name)
4278 WARN("Invalid name specified\n");
4279 return &null_variable.ID3D10EffectVariable_iface;
4282 for (i = 0; i < This->type->member_count; ++i)
4284 struct d3d10_effect_variable *m = &This->members[i];
4286 if (m->name && !strcmp(m->name, name))
4288 TRACE("Returning member %p\n", m);
4289 return &m->ID3D10EffectVariable_iface;
4293 WARN("Invalid name specified\n");
4295 return &null_variable.ID3D10EffectVariable_iface;
4298 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetMemberBySemantic(
4299 ID3D10EffectVariable *iface, const char *semantic)
4301 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4302 unsigned int i;
4304 TRACE("iface %p, semantic %s.\n", iface, debugstr_a(semantic));
4306 if (!semantic)
4308 WARN("Invalid semantic specified\n");
4309 return &null_variable.ID3D10EffectVariable_iface;
4312 for (i = 0; i < This->type->member_count; ++i)
4314 struct d3d10_effect_variable *m = &This->members[i];
4316 if (m->semantic && !stricmp(m->semantic, semantic))
4318 TRACE("Returning member %p\n", m);
4319 return &m->ID3D10EffectVariable_iface;
4323 WARN("Invalid semantic specified\n");
4325 return &null_variable.ID3D10EffectVariable_iface;
4328 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_variable_GetElement(
4329 ID3D10EffectVariable *iface, UINT index)
4331 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4332 struct d3d10_effect_variable *v;
4334 TRACE("iface %p, index %u\n", iface, index);
4336 if (index >= This->type->element_count)
4338 WARN("Invalid index specified\n");
4339 return &null_variable.ID3D10EffectVariable_iface;
4342 v = &This->elements[index];
4344 TRACE("Returning element %p, %s\n", v, debugstr_a(v->name));
4346 return &v->ID3D10EffectVariable_iface;
4349 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_variable_GetParentConstantBuffer(
4350 ID3D10EffectVariable *iface)
4352 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4354 TRACE("iface %p\n", iface);
4356 return (ID3D10EffectConstantBuffer *)&This->buffer->ID3D10EffectVariable_iface;
4359 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsScalar(
4360 ID3D10EffectVariable *iface)
4362 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4364 TRACE("iface %p\n", iface);
4366 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_scalar_variable_vtbl)
4367 return (ID3D10EffectScalarVariable *)&This->ID3D10EffectVariable_iface;
4369 return (ID3D10EffectScalarVariable *)&null_scalar_variable.ID3D10EffectVariable_iface;
4372 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsVector(
4373 ID3D10EffectVariable *iface)
4375 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4377 TRACE("iface %p\n", iface);
4379 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_vector_variable_vtbl)
4380 return (ID3D10EffectVectorVariable *)&This->ID3D10EffectVariable_iface;
4382 return (ID3D10EffectVectorVariable *)&null_vector_variable.ID3D10EffectVariable_iface;
4385 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsMatrix(
4386 ID3D10EffectVariable *iface)
4388 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4390 TRACE("iface %p\n", iface);
4392 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_matrix_variable_vtbl)
4393 return (ID3D10EffectMatrixVariable *)&This->ID3D10EffectVariable_iface;
4395 return (ID3D10EffectMatrixVariable *)&null_matrix_variable.ID3D10EffectVariable_iface;
4398 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsString(
4399 ID3D10EffectVariable *iface)
4401 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4403 TRACE("iface %p\n", iface);
4405 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_string_variable_vtbl)
4406 return (ID3D10EffectStringVariable *)&This->ID3D10EffectVariable_iface;
4408 return (ID3D10EffectStringVariable *)&null_string_variable.ID3D10EffectVariable_iface;
4411 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsShaderResource(
4412 ID3D10EffectVariable *iface)
4414 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4416 TRACE("iface %p\n", iface);
4418 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_resource_variable_vtbl)
4419 return (ID3D10EffectShaderResourceVariable *)&This->ID3D10EffectVariable_iface;
4421 return (ID3D10EffectShaderResourceVariable *)&null_shader_resource_variable.ID3D10EffectVariable_iface;
4424 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsRenderTargetView(
4425 ID3D10EffectVariable *iface)
4427 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4429 TRACE("iface %p\n", iface);
4431 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_render_target_view_variable_vtbl)
4432 return (ID3D10EffectRenderTargetViewVariable *)&This->ID3D10EffectVariable_iface;
4434 return (ID3D10EffectRenderTargetViewVariable *)&null_render_target_view_variable.ID3D10EffectVariable_iface;
4437 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsDepthStencilView(
4438 ID3D10EffectVariable *iface)
4440 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4442 TRACE("iface %p\n", iface);
4444 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_view_variable_vtbl)
4445 return (ID3D10EffectDepthStencilViewVariable *)&This->ID3D10EffectVariable_iface;
4447 return (ID3D10EffectDepthStencilViewVariable *)&null_depth_stencil_view_variable.ID3D10EffectVariable_iface;
4450 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_variable_AsConstantBuffer(
4451 ID3D10EffectVariable *iface)
4453 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4455 TRACE("iface %p\n", iface);
4457 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_constant_buffer_vtbl)
4458 return (ID3D10EffectConstantBuffer *)&This->ID3D10EffectVariable_iface;
4460 return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface;
4463 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsShader(
4464 ID3D10EffectVariable *iface)
4466 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4468 TRACE("iface %p\n", iface);
4470 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_shader_variable_vtbl)
4471 return (ID3D10EffectShaderVariable *)&This->ID3D10EffectVariable_iface;
4473 return (ID3D10EffectShaderVariable *)&null_shader_variable.ID3D10EffectVariable_iface;
4476 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsBlend(ID3D10EffectVariable *iface)
4478 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4480 TRACE("iface %p\n", iface);
4482 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_blend_variable_vtbl)
4483 return (ID3D10EffectBlendVariable *)&This->ID3D10EffectVariable_iface;
4485 return (ID3D10EffectBlendVariable *)&null_blend_variable.ID3D10EffectVariable_iface;
4488 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsDepthStencil(
4489 ID3D10EffectVariable *iface)
4491 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4493 TRACE("iface %p\n", iface);
4495 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_depth_stencil_variable_vtbl)
4496 return (ID3D10EffectDepthStencilVariable *)&This->ID3D10EffectVariable_iface;
4498 return (ID3D10EffectDepthStencilVariable *)&null_depth_stencil_variable.ID3D10EffectVariable_iface;
4501 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsRasterizer(
4502 ID3D10EffectVariable *iface)
4504 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4506 TRACE("iface %p\n", iface);
4508 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_rasterizer_variable_vtbl)
4509 return (ID3D10EffectRasterizerVariable *)&This->ID3D10EffectVariable_iface;
4511 return (ID3D10EffectRasterizerVariable *)&null_rasterizer_variable.ID3D10EffectVariable_iface;
4514 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsSampler(
4515 ID3D10EffectVariable *iface)
4517 struct d3d10_effect_variable *This = impl_from_ID3D10EffectVariable(iface);
4519 TRACE("iface %p\n", iface);
4521 if (This->ID3D10EffectVariable_iface.lpVtbl == (const ID3D10EffectVariableVtbl *)&d3d10_effect_sampler_variable_vtbl)
4522 return (ID3D10EffectSamplerVariable *)&This->ID3D10EffectVariable_iface;
4524 return (ID3D10EffectSamplerVariable *)&null_sampler_variable.ID3D10EffectVariable_iface;
4527 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_SetRawValue(ID3D10EffectVariable *iface,
4528 void *data, UINT offset, UINT count)
4530 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable(iface);
4531 BOOL is_buffer;
4533 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
4535 if (!iface->lpVtbl->IsValid(iface))
4537 WARN("Invalid variable.\n");
4538 return E_FAIL;
4541 is_buffer = v->type->basetype == D3D10_SVT_CBUFFER || v->type->basetype == D3D10_SVT_TBUFFER;
4543 if (v->type->type_class == D3D10_SVC_OBJECT && !is_buffer)
4545 WARN("Not supported on object variables of type %s.\n",
4546 debug_d3d10_shader_variable_type(v->type->basetype));
4547 return D3DERR_INVALIDCALL;
4550 if (!is_buffer)
4552 offset += v->buffer_offset;
4553 v = v->buffer;
4556 memcpy(v->u.buffer.local_buffer + offset, data, count);
4557 v->u.buffer.changed = TRUE;
4559 return S_OK;
4562 static HRESULT STDMETHODCALLTYPE d3d10_effect_variable_GetRawValue(ID3D10EffectVariable *iface,
4563 void *data, UINT offset, UINT count)
4565 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVariable(iface);
4566 BOOL is_buffer;
4568 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
4570 if (!iface->lpVtbl->IsValid(iface))
4572 WARN("Invalid variable.\n");
4573 return E_FAIL;
4576 is_buffer = v->type->basetype == D3D10_SVT_CBUFFER || v->type->basetype == D3D10_SVT_TBUFFER;
4578 if (v->type->type_class == D3D10_SVC_OBJECT && !is_buffer)
4580 WARN("Not supported on object variables of type %s.\n",
4581 debug_d3d10_shader_variable_type(v->type->basetype));
4582 return D3DERR_INVALIDCALL;
4585 if (!is_buffer)
4587 offset += v->buffer_offset;
4588 v = v->buffer;
4591 memcpy(data, v->u.buffer.local_buffer + offset, count);
4593 return S_OK;
4596 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl =
4598 /* ID3D10EffectVariable methods */
4599 d3d10_effect_variable_IsValid,
4600 d3d10_effect_variable_GetType,
4601 d3d10_effect_variable_GetDesc,
4602 d3d10_effect_variable_GetAnnotationByIndex,
4603 d3d10_effect_variable_GetAnnotationByName,
4604 d3d10_effect_variable_GetMemberByIndex,
4605 d3d10_effect_variable_GetMemberByName,
4606 d3d10_effect_variable_GetMemberBySemantic,
4607 d3d10_effect_variable_GetElement,
4608 d3d10_effect_variable_GetParentConstantBuffer,
4609 d3d10_effect_variable_AsScalar,
4610 d3d10_effect_variable_AsVector,
4611 d3d10_effect_variable_AsMatrix,
4612 d3d10_effect_variable_AsString,
4613 d3d10_effect_variable_AsShaderResource,
4614 d3d10_effect_variable_AsRenderTargetView,
4615 d3d10_effect_variable_AsDepthStencilView,
4616 d3d10_effect_variable_AsConstantBuffer,
4617 d3d10_effect_variable_AsShader,
4618 d3d10_effect_variable_AsBlend,
4619 d3d10_effect_variable_AsDepthStencil,
4620 d3d10_effect_variable_AsRasterizer,
4621 d3d10_effect_variable_AsSampler,
4622 d3d10_effect_variable_SetRawValue,
4623 d3d10_effect_variable_GetRawValue,
4626 /* ID3D10EffectVariable methods */
4627 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectConstantBuffer(ID3D10EffectConstantBuffer *iface)
4629 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
4632 static BOOL STDMETHODCALLTYPE d3d10_effect_constant_buffer_IsValid(ID3D10EffectConstantBuffer *iface)
4634 struct d3d10_effect_variable *v = impl_from_ID3D10EffectConstantBuffer(iface);
4636 TRACE("iface %p.\n", iface);
4638 return v != &null_local_buffer;
4641 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetType(ID3D10EffectConstantBuffer *iface)
4643 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
4646 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetDesc(ID3D10EffectConstantBuffer *iface,
4647 D3D10_EFFECT_VARIABLE_DESC *desc)
4649 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
4652 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetAnnotationByIndex(
4653 ID3D10EffectConstantBuffer *iface, UINT index)
4655 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
4658 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetAnnotationByName(
4659 ID3D10EffectConstantBuffer *iface, const char *name)
4661 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
4664 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberByIndex(
4665 ID3D10EffectConstantBuffer *iface, UINT index)
4667 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
4670 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberByName(
4671 ID3D10EffectConstantBuffer *iface, const char *name)
4673 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
4676 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetMemberBySemantic(
4677 ID3D10EffectConstantBuffer *iface, const char *semantic)
4679 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
4682 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetElement(
4683 ID3D10EffectConstantBuffer *iface, UINT index)
4685 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
4688 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetParentConstantBuffer(
4689 ID3D10EffectConstantBuffer *iface)
4691 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
4694 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsScalar(
4695 ID3D10EffectConstantBuffer *iface)
4697 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
4700 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsVector(
4701 ID3D10EffectConstantBuffer *iface)
4703 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
4706 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsMatrix(
4707 ID3D10EffectConstantBuffer *iface)
4709 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
4712 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsString(
4713 ID3D10EffectConstantBuffer *iface)
4715 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
4718 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsShaderResource(
4719 ID3D10EffectConstantBuffer *iface)
4721 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
4724 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsRenderTargetView(
4725 ID3D10EffectConstantBuffer *iface)
4727 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
4730 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsDepthStencilView(
4731 ID3D10EffectConstantBuffer *iface)
4733 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
4736 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsConstantBuffer(
4737 ID3D10EffectConstantBuffer *iface)
4739 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
4742 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsShader(
4743 ID3D10EffectConstantBuffer *iface)
4745 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
4748 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsBlend(ID3D10EffectConstantBuffer *iface)
4750 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
4753 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsDepthStencil(
4754 ID3D10EffectConstantBuffer *iface)
4756 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
4759 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsRasterizer(
4760 ID3D10EffectConstantBuffer *iface)
4762 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
4765 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_constant_buffer_AsSampler(
4766 ID3D10EffectConstantBuffer *iface)
4768 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
4771 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetRawValue(ID3D10EffectConstantBuffer *iface,
4772 void *data, UINT offset, UINT count)
4774 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4777 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetRawValue(ID3D10EffectConstantBuffer *iface,
4778 void *data, UINT offset, UINT count)
4780 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
4783 /* ID3D10EffectConstantBuffer methods */
4784 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetConstantBuffer(ID3D10EffectConstantBuffer *iface,
4785 ID3D10Buffer *buffer)
4787 FIXME("iface %p, buffer %p stub!\n", iface, buffer);
4789 return E_NOTIMPL;
4792 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetConstantBuffer(ID3D10EffectConstantBuffer *iface,
4793 ID3D10Buffer **buffer)
4795 struct d3d10_effect_variable *v = impl_from_ID3D10EffectConstantBuffer(iface);
4797 TRACE("iface %p, buffer %p.\n", iface, buffer);
4799 if (!iface->lpVtbl->IsValid(iface))
4801 WARN("Null variable specified.\n");
4802 return E_FAIL;
4805 if (v->type->basetype != D3D10_SVT_CBUFFER)
4807 WARN("Wrong variable type %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
4808 return D3DERR_INVALIDCALL;
4811 *buffer = v->u.buffer.buffer;
4812 ID3D10Buffer_AddRef(*buffer);
4814 return S_OK;
4817 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_SetTextureBuffer(ID3D10EffectConstantBuffer *iface,
4818 ID3D10ShaderResourceView *view)
4820 FIXME("iface %p, view %p stub!\n", iface, view);
4822 return E_NOTIMPL;
4825 static HRESULT STDMETHODCALLTYPE d3d10_effect_constant_buffer_GetTextureBuffer(ID3D10EffectConstantBuffer *iface,
4826 ID3D10ShaderResourceView **view)
4828 struct d3d10_effect_variable *v = impl_from_ID3D10EffectConstantBuffer(iface);
4830 FIXME("iface %p, view %p stub!\n", iface, view);
4832 if (!iface->lpVtbl->IsValid(iface))
4834 WARN("Null variable specified.\n");
4835 return E_FAIL;
4838 if (v->type->basetype != D3D10_SVT_TBUFFER)
4840 WARN("Wrong variable type %s.\n", debug_d3d10_shader_variable_type(v->type->basetype));
4841 return D3DERR_INVALIDCALL;
4844 return E_NOTIMPL;
4847 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl =
4849 /* ID3D10EffectVariable methods */
4850 d3d10_effect_constant_buffer_IsValid,
4851 d3d10_effect_constant_buffer_GetType,
4852 d3d10_effect_constant_buffer_GetDesc,
4853 d3d10_effect_constant_buffer_GetAnnotationByIndex,
4854 d3d10_effect_constant_buffer_GetAnnotationByName,
4855 d3d10_effect_constant_buffer_GetMemberByIndex,
4856 d3d10_effect_constant_buffer_GetMemberByName,
4857 d3d10_effect_constant_buffer_GetMemberBySemantic,
4858 d3d10_effect_constant_buffer_GetElement,
4859 d3d10_effect_constant_buffer_GetParentConstantBuffer,
4860 d3d10_effect_constant_buffer_AsScalar,
4861 d3d10_effect_constant_buffer_AsVector,
4862 d3d10_effect_constant_buffer_AsMatrix,
4863 d3d10_effect_constant_buffer_AsString,
4864 d3d10_effect_constant_buffer_AsShaderResource,
4865 d3d10_effect_constant_buffer_AsRenderTargetView,
4866 d3d10_effect_constant_buffer_AsDepthStencilView,
4867 d3d10_effect_constant_buffer_AsConstantBuffer,
4868 d3d10_effect_constant_buffer_AsShader,
4869 d3d10_effect_constant_buffer_AsBlend,
4870 d3d10_effect_constant_buffer_AsDepthStencil,
4871 d3d10_effect_constant_buffer_AsRasterizer,
4872 d3d10_effect_constant_buffer_AsSampler,
4873 d3d10_effect_constant_buffer_SetRawValue,
4874 d3d10_effect_constant_buffer_GetRawValue,
4875 /* ID3D10EffectConstantBuffer methods */
4876 d3d10_effect_constant_buffer_SetConstantBuffer,
4877 d3d10_effect_constant_buffer_GetConstantBuffer,
4878 d3d10_effect_constant_buffer_SetTextureBuffer,
4879 d3d10_effect_constant_buffer_GetTextureBuffer,
4883 static BOOL get_value_as_bool(void *src_data, D3D10_SHADER_VARIABLE_TYPE src_type)
4885 switch (src_type)
4887 case D3D10_SVT_FLOAT:
4888 case D3D10_SVT_INT:
4889 case D3D10_SVT_UINT:
4890 case D3D10_SVT_BOOL:
4891 if (*(DWORD *)src_data)
4892 return -1;
4893 break;
4895 default:
4896 break;
4899 return 0;
4902 static int get_value_as_int(void *src_data, D3D10_SHADER_VARIABLE_TYPE src_type)
4904 switch (src_type)
4906 case D3D10_SVT_FLOAT:
4907 return (int)(*(float *)src_data);
4909 case D3D10_SVT_INT:
4910 case D3D10_SVT_UINT:
4911 return *(int *)src_data;
4913 case D3D10_SVT_BOOL:
4914 return get_value_as_bool(src_data, src_type);
4916 default:
4917 return 0;
4921 static float get_value_as_float(void *src_data, D3D10_SHADER_VARIABLE_TYPE src_type)
4923 switch (src_type)
4925 case D3D10_SVT_FLOAT:
4926 return *(float *)src_data;
4928 case D3D10_SVT_INT:
4929 case D3D10_SVT_UINT:
4930 return (float)(*(int *)src_data);
4932 case D3D10_SVT_BOOL:
4933 return (float)get_value_as_bool(src_data, src_type);
4935 default:
4936 return 0.0f;
4940 static void get_vector_as_type(BYTE *dst_data, D3D_SHADER_VARIABLE_TYPE dst_type,
4941 BYTE *src_data, D3D_SHADER_VARIABLE_TYPE src_type, unsigned int count)
4943 DWORD *src_data_dword = (DWORD *)src_data;
4944 DWORD *dst_data_dword = (DWORD *)dst_data;
4945 unsigned int i;
4947 for (i = 0; i < count; ++i, ++dst_data_dword, ++src_data_dword)
4949 if (dst_type == src_type)
4950 *dst_data_dword = *src_data_dword;
4951 else
4953 switch (dst_type)
4955 case D3D10_SVT_FLOAT:
4956 *(float *)dst_data_dword = get_value_as_float(src_data_dword, src_type);
4957 break;
4959 case D3D10_SVT_INT:
4960 case D3D10_SVT_UINT:
4961 *(int *)dst_data_dword = get_value_as_int(src_data_dword, src_type);
4962 break;
4964 case D3D10_SVT_BOOL:
4965 *(BOOL *)dst_data_dword = get_value_as_bool(src_data_dword, src_type);
4966 break;
4968 default:
4969 *dst_data_dword = 0;
4970 break;
4976 static void write_variable_to_buffer(struct d3d10_effect_variable *variable, void *src,
4977 D3D_SHADER_VARIABLE_TYPE src_type)
4979 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4980 D3D_SHADER_VARIABLE_TYPE dst_type = variable->type->basetype;
4982 get_vector_as_type(dst, dst_type, src, src_type, variable->type->column_count);
4984 variable->buffer->u.buffer.changed = TRUE;
4987 static void write_variable_array_to_buffer(struct d3d10_effect_variable *variable, void *src,
4988 D3D_SHADER_VARIABLE_TYPE src_type, unsigned int offset, unsigned int count)
4990 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
4991 D3D_SHADER_VARIABLE_TYPE dst_type = variable->type->basetype;
4992 unsigned int element_size, i;
4993 BYTE *cur_element = src;
4995 if (!variable->type->element_count)
4997 write_variable_to_buffer(variable, src, src_type);
4998 return;
5001 if (offset >= variable->type->element_count)
5003 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
5004 return;
5007 if (count > variable->type->element_count - offset)
5009 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
5010 offset, count, variable->type->element_count);
5011 count = variable->type->element_count - offset;
5014 element_size = variable->type->elementtype->size_packed;
5015 dst += variable->type->stride * offset;
5017 for (i = 0; i < count; ++i)
5019 get_vector_as_type(dst, dst_type, cur_element, src_type, variable->type->column_count);
5021 cur_element += element_size;
5022 dst += variable->type->stride;
5025 variable->buffer->u.buffer.changed = TRUE;
5028 static void read_variable_from_buffer(struct d3d10_effect_variable *variable, void *dst,
5029 D3D_SHADER_VARIABLE_TYPE dst_type)
5031 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5032 D3D_SHADER_VARIABLE_TYPE src_type = variable->type->basetype;
5034 get_vector_as_type(dst, dst_type, src, src_type, variable->type->column_count);
5037 static void read_variable_array_from_buffer(struct d3d10_effect_variable *variable, void *dst,
5038 D3D_SHADER_VARIABLE_TYPE dst_type, unsigned int offset, unsigned int count)
5040 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5041 D3D_SHADER_VARIABLE_TYPE src_type = variable->type->basetype;
5042 unsigned int element_size, i;
5043 BYTE *cur_element = dst;
5045 if (!variable->type->element_count)
5047 read_variable_from_buffer(variable, dst, dst_type);
5048 return;
5051 if (offset >= variable->type->element_count)
5053 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
5054 return;
5057 if (count > variable->type->element_count - offset)
5059 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
5060 offset, count, variable->type->element_count);
5061 count = variable->type->element_count - offset;
5064 element_size = variable->type->elementtype->size_packed;
5065 src += variable->type->stride * offset;
5067 for (i = 0; i < count; ++i)
5069 get_vector_as_type(cur_element, dst_type, src, src_type, variable->type->column_count);
5071 cur_element += element_size;
5072 src += variable->type->stride;
5076 /* ID3D10EffectVariable methods */
5078 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectScalarVariable(ID3D10EffectScalarVariable *iface)
5080 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
5083 static BOOL STDMETHODCALLTYPE d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable *iface)
5085 struct d3d10_effect_variable *v = impl_from_ID3D10EffectScalarVariable(iface);
5087 TRACE("iface %p\n", iface);
5089 return v != &null_scalar_variable;
5092 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetType(
5093 ID3D10EffectScalarVariable *iface)
5095 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5098 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetDesc(ID3D10EffectScalarVariable *iface,
5099 D3D10_EFFECT_VARIABLE_DESC *desc)
5101 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5104 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetAnnotationByIndex(
5105 ID3D10EffectScalarVariable *iface, UINT index)
5107 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5110 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetAnnotationByName(
5111 ID3D10EffectScalarVariable *iface, const char *name)
5113 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5116 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberByIndex(
5117 ID3D10EffectScalarVariable *iface, UINT index)
5119 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5122 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberByName(
5123 ID3D10EffectScalarVariable *iface, const char *name)
5125 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5128 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetMemberBySemantic(
5129 ID3D10EffectScalarVariable *iface, const char *semantic)
5131 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5134 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetElement(
5135 ID3D10EffectScalarVariable *iface, UINT index)
5137 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5140 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetParentConstantBuffer(
5141 ID3D10EffectScalarVariable *iface)
5143 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5146 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsScalar(
5147 ID3D10EffectScalarVariable *iface)
5149 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5152 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsVector(
5153 ID3D10EffectScalarVariable *iface)
5155 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5158 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsMatrix(
5159 ID3D10EffectScalarVariable *iface)
5161 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5164 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsString(
5165 ID3D10EffectScalarVariable *iface)
5167 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5170 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsShaderResource(
5171 ID3D10EffectScalarVariable *iface)
5173 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5176 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsRenderTargetView(
5177 ID3D10EffectScalarVariable *iface)
5179 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5182 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsDepthStencilView(
5183 ID3D10EffectScalarVariable *iface)
5185 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5188 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsConstantBuffer(
5189 ID3D10EffectScalarVariable *iface)
5191 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5194 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsShader(
5195 ID3D10EffectScalarVariable *iface)
5197 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5200 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsBlend(
5201 ID3D10EffectScalarVariable *iface)
5203 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5206 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsDepthStencil(
5207 ID3D10EffectScalarVariable *iface)
5209 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5212 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsRasterizer(
5213 ID3D10EffectScalarVariable *iface)
5215 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5218 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_scalar_variable_AsSampler(
5219 ID3D10EffectScalarVariable *iface)
5221 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5224 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetRawValue(ID3D10EffectScalarVariable *iface,
5225 void *data, UINT offset, UINT count)
5227 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5230 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetRawValue(ID3D10EffectScalarVariable *iface,
5231 void *data, UINT offset, UINT count)
5233 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5236 /* ID3D10EffectScalarVariable methods */
5238 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloat(ID3D10EffectScalarVariable *iface,
5239 float value)
5241 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5243 TRACE("iface %p, value %.8e.\n", iface, value);
5244 write_variable_to_buffer(effect_var, &value, D3D10_SVT_FLOAT);
5246 return S_OK;
5249 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable *iface,
5250 float *value)
5252 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5254 TRACE("iface %p, value %p.\n", iface, value);
5255 read_variable_from_buffer(effect_var, value, D3D10_SVT_FLOAT);
5257 return S_OK;
5260 /* Tests show that offset is ignored for scalar variables. */
5261 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetFloatArray(ID3D10EffectScalarVariable *iface,
5262 float *values, UINT offset, UINT count)
5264 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5266 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5267 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_FLOAT, 0, count);
5269 return S_OK;
5272 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable *iface,
5273 float *values, UINT offset, UINT count)
5275 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5277 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5278 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_FLOAT, 0, count);
5280 return S_OK;
5283 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable *iface,
5284 int value)
5286 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5288 TRACE("iface %p, value %d.\n", iface, value);
5289 write_variable_to_buffer(effect_var, &value, D3D10_SVT_INT);
5291 return S_OK;
5294 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetInt(ID3D10EffectScalarVariable *iface,
5295 int *value)
5297 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5299 TRACE("iface %p, value %p.\n", iface, value);
5300 read_variable_from_buffer(effect_var, value, D3D10_SVT_INT);
5302 return S_OK;
5305 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable *iface,
5306 int *values, UINT offset, UINT count)
5308 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5310 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5311 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_INT, 0, count);
5313 return S_OK;
5316 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable *iface,
5317 int *values, UINT offset, UINT count)
5319 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5321 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5322 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_INT, 0, count);
5324 return S_OK;
5327 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable *iface,
5328 BOOL value)
5330 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5332 TRACE("iface %p, value %d.\n", iface, value);
5333 write_variable_to_buffer(effect_var, &value, D3D10_SVT_BOOL);
5335 return S_OK;
5338 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBool(ID3D10EffectScalarVariable *iface,
5339 BOOL *value)
5341 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5343 TRACE("iface %p, value %p.\n", iface, value);
5344 read_variable_from_buffer(effect_var, value, D3D10_SVT_BOOL);
5346 return S_OK;
5349 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable *iface,
5350 BOOL *values, UINT offset, UINT count)
5352 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5354 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5355 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_BOOL, 0, count);
5357 return S_OK;
5360 static HRESULT STDMETHODCALLTYPE d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable *iface,
5361 BOOL *values, UINT offset, UINT count)
5363 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectScalarVariable(iface);
5365 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5366 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_BOOL, 0, count);
5368 return S_OK;
5371 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl =
5373 /* ID3D10EffectVariable methods */
5374 d3d10_effect_scalar_variable_IsValid,
5375 d3d10_effect_scalar_variable_GetType,
5376 d3d10_effect_scalar_variable_GetDesc,
5377 d3d10_effect_scalar_variable_GetAnnotationByIndex,
5378 d3d10_effect_scalar_variable_GetAnnotationByName,
5379 d3d10_effect_scalar_variable_GetMemberByIndex,
5380 d3d10_effect_scalar_variable_GetMemberByName,
5381 d3d10_effect_scalar_variable_GetMemberBySemantic,
5382 d3d10_effect_scalar_variable_GetElement,
5383 d3d10_effect_scalar_variable_GetParentConstantBuffer,
5384 d3d10_effect_scalar_variable_AsScalar,
5385 d3d10_effect_scalar_variable_AsVector,
5386 d3d10_effect_scalar_variable_AsMatrix,
5387 d3d10_effect_scalar_variable_AsString,
5388 d3d10_effect_scalar_variable_AsShaderResource,
5389 d3d10_effect_scalar_variable_AsRenderTargetView,
5390 d3d10_effect_scalar_variable_AsDepthStencilView,
5391 d3d10_effect_scalar_variable_AsConstantBuffer,
5392 d3d10_effect_scalar_variable_AsShader,
5393 d3d10_effect_scalar_variable_AsBlend,
5394 d3d10_effect_scalar_variable_AsDepthStencil,
5395 d3d10_effect_scalar_variable_AsRasterizer,
5396 d3d10_effect_scalar_variable_AsSampler,
5397 d3d10_effect_scalar_variable_SetRawValue,
5398 d3d10_effect_scalar_variable_GetRawValue,
5399 /* ID3D10EffectScalarVariable methods */
5400 d3d10_effect_scalar_variable_SetFloat,
5401 d3d10_effect_scalar_variable_GetFloat,
5402 d3d10_effect_scalar_variable_SetFloatArray,
5403 d3d10_effect_scalar_variable_GetFloatArray,
5404 d3d10_effect_scalar_variable_SetInt,
5405 d3d10_effect_scalar_variable_GetInt,
5406 d3d10_effect_scalar_variable_SetIntArray,
5407 d3d10_effect_scalar_variable_GetIntArray,
5408 d3d10_effect_scalar_variable_SetBool,
5409 d3d10_effect_scalar_variable_GetBool,
5410 d3d10_effect_scalar_variable_SetBoolArray,
5411 d3d10_effect_scalar_variable_GetBoolArray,
5414 /* ID3D10EffectVariable methods */
5416 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectVectorVariable(ID3D10EffectVectorVariable *iface)
5418 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
5421 static BOOL STDMETHODCALLTYPE d3d10_effect_vector_variable_IsValid(ID3D10EffectVectorVariable *iface)
5423 struct d3d10_effect_variable *v = impl_from_ID3D10EffectVectorVariable(iface);
5425 TRACE("iface %p\n", iface);
5427 return v != &null_vector_variable;
5430 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetType(
5431 ID3D10EffectVectorVariable *iface)
5433 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5436 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetDesc(ID3D10EffectVectorVariable *iface,
5437 D3D10_EFFECT_VARIABLE_DESC *desc)
5439 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5442 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetAnnotationByIndex(
5443 ID3D10EffectVectorVariable *iface, UINT index)
5445 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5448 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetAnnotationByName(
5449 ID3D10EffectVectorVariable *iface, const char *name)
5451 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5454 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberByIndex(
5455 ID3D10EffectVectorVariable *iface, UINT index)
5457 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5460 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberByName(
5461 ID3D10EffectVectorVariable *iface, const char *name)
5463 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5466 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetMemberBySemantic(
5467 ID3D10EffectVectorVariable *iface, const char *semantic)
5469 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5472 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetElement(
5473 ID3D10EffectVectorVariable *iface, UINT index)
5475 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5478 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_vector_variable_GetParentConstantBuffer(
5479 ID3D10EffectVectorVariable *iface)
5481 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5484 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsScalar(
5485 ID3D10EffectVectorVariable *iface)
5487 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5490 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsVector(
5491 ID3D10EffectVectorVariable *iface)
5493 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5496 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsMatrix(
5497 ID3D10EffectVectorVariable *iface)
5499 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5502 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsString(
5503 ID3D10EffectVectorVariable *iface)
5505 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5508 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsShaderResource(
5509 ID3D10EffectVectorVariable *iface)
5511 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
5514 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsRenderTargetView(
5515 ID3D10EffectVectorVariable *iface)
5517 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
5520 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsDepthStencilView(
5521 ID3D10EffectVectorVariable *iface)
5523 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
5526 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsConstantBuffer(
5527 ID3D10EffectVectorVariable *iface)
5529 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
5532 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsShader(
5533 ID3D10EffectVectorVariable *iface)
5535 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
5538 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsBlend(
5539 ID3D10EffectVectorVariable *iface)
5541 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
5544 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsDepthStencil(
5545 ID3D10EffectVectorVariable *iface)
5547 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
5550 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsRasterizer(
5551 ID3D10EffectVectorVariable *iface)
5553 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
5556 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_vector_variable_AsSampler(
5557 ID3D10EffectVectorVariable *iface)
5559 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
5562 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetRawValue(ID3D10EffectVectorVariable *iface,
5563 void *data, UINT offset, UINT count)
5565 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5568 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetRawValue(ID3D10EffectVectorVariable *iface,
5569 void *data, UINT offset, UINT count)
5571 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
5574 /* ID3D10EffectVectorVariable methods */
5576 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVector(ID3D10EffectVectorVariable *iface,
5577 BOOL *value)
5579 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5581 TRACE("iface %p, value %p.\n", iface, value);
5582 write_variable_to_buffer(effect_var, value, D3D10_SVT_BOOL);
5584 return S_OK;
5587 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVector(ID3D10EffectVectorVariable *iface,
5588 int *value)
5590 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5592 TRACE("iface %p, value %p.\n", iface, value);
5593 write_variable_to_buffer(effect_var, value, D3D10_SVT_INT);
5595 return S_OK;
5598 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVector(ID3D10EffectVectorVariable *iface,
5599 float *value)
5601 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5603 TRACE("iface %p, value %p.\n", iface, value);
5604 write_variable_to_buffer(effect_var, value, D3D10_SVT_FLOAT);
5606 return S_OK;
5609 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable *iface,
5610 BOOL *value)
5612 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5614 TRACE("iface %p, value %p.\n", iface, value);
5615 read_variable_from_buffer(effect_var, value, D3D10_SVT_BOOL);
5617 return S_OK;
5620 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVector(ID3D10EffectVectorVariable *iface,
5621 int *value)
5623 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5625 TRACE("iface %p, value %p.\n", iface, value);
5626 read_variable_from_buffer(effect_var, value, D3D10_SVT_INT);
5628 return S_OK;
5631 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVector(ID3D10EffectVectorVariable *iface,
5632 float *value)
5634 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5636 TRACE("iface %p, value %p.\n", iface, value);
5637 read_variable_from_buffer(effect_var, value, D3D10_SVT_FLOAT);
5639 return S_OK;
5642 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable *iface,
5643 BOOL *values, UINT offset, UINT count)
5645 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5647 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5648 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_BOOL, offset, count);
5650 return S_OK;
5653 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetIntVectorArray(ID3D10EffectVectorVariable *iface,
5654 int *values, UINT offset, UINT count)
5656 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5658 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5659 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_INT, offset, count);
5661 return S_OK;
5664 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_SetFloatVectorArray(ID3D10EffectVectorVariable *iface,
5665 float *values, UINT offset, UINT count)
5667 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5669 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5670 write_variable_array_to_buffer(effect_var, values, D3D10_SVT_FLOAT, offset, count);
5672 return S_OK;
5675 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetBoolVectorArray(ID3D10EffectVectorVariable *iface,
5676 BOOL *values, UINT offset, UINT count)
5678 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5680 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5681 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_BOOL, offset, count);
5683 return S_OK;
5686 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetIntVectorArray(ID3D10EffectVectorVariable *iface,
5687 int *values, UINT offset, UINT count)
5689 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5691 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5692 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_INT, offset, count);
5694 return S_OK;
5697 static HRESULT STDMETHODCALLTYPE d3d10_effect_vector_variable_GetFloatVectorArray(ID3D10EffectVectorVariable *iface,
5698 float *values, UINT offset, UINT count)
5700 struct d3d10_effect_variable *effect_var = impl_from_ID3D10EffectVectorVariable(iface);
5702 TRACE("iface %p, values %p, offset %u, count %u.\n", iface, values, offset, count);
5703 read_variable_array_from_buffer(effect_var, values, D3D10_SVT_FLOAT, offset, count);
5705 return S_OK;
5708 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl =
5710 /* ID3D10EffectVariable methods */
5711 d3d10_effect_vector_variable_IsValid,
5712 d3d10_effect_vector_variable_GetType,
5713 d3d10_effect_vector_variable_GetDesc,
5714 d3d10_effect_vector_variable_GetAnnotationByIndex,
5715 d3d10_effect_vector_variable_GetAnnotationByName,
5716 d3d10_effect_vector_variable_GetMemberByIndex,
5717 d3d10_effect_vector_variable_GetMemberByName,
5718 d3d10_effect_vector_variable_GetMemberBySemantic,
5719 d3d10_effect_vector_variable_GetElement,
5720 d3d10_effect_vector_variable_GetParentConstantBuffer,
5721 d3d10_effect_vector_variable_AsScalar,
5722 d3d10_effect_vector_variable_AsVector,
5723 d3d10_effect_vector_variable_AsMatrix,
5724 d3d10_effect_vector_variable_AsString,
5725 d3d10_effect_vector_variable_AsShaderResource,
5726 d3d10_effect_vector_variable_AsRenderTargetView,
5727 d3d10_effect_vector_variable_AsDepthStencilView,
5728 d3d10_effect_vector_variable_AsConstantBuffer,
5729 d3d10_effect_vector_variable_AsShader,
5730 d3d10_effect_vector_variable_AsBlend,
5731 d3d10_effect_vector_variable_AsDepthStencil,
5732 d3d10_effect_vector_variable_AsRasterizer,
5733 d3d10_effect_vector_variable_AsSampler,
5734 d3d10_effect_vector_variable_SetRawValue,
5735 d3d10_effect_vector_variable_GetRawValue,
5736 /* ID3D10EffectVectorVariable methods */
5737 d3d10_effect_vector_variable_SetBoolVector,
5738 d3d10_effect_vector_variable_SetIntVector,
5739 d3d10_effect_vector_variable_SetFloatVector,
5740 d3d10_effect_vector_variable_GetBoolVector,
5741 d3d10_effect_vector_variable_GetIntVector,
5742 d3d10_effect_vector_variable_GetFloatVector,
5743 d3d10_effect_vector_variable_SetBoolVectorArray,
5744 d3d10_effect_vector_variable_SetIntVectorArray,
5745 d3d10_effect_vector_variable_SetFloatVectorArray,
5746 d3d10_effect_vector_variable_GetBoolVectorArray,
5747 d3d10_effect_vector_variable_GetIntVectorArray,
5748 d3d10_effect_vector_variable_GetFloatVectorArray,
5751 static void write_matrix_to_buffer(struct d3d10_effect_variable *variable, void *dst_void,
5752 struct d3d10_matrix *src, BOOL transpose)
5754 unsigned int col_count = !transpose ? variable->type->column_count : variable->type->row_count;
5755 unsigned int row_count = !transpose ? variable->type->row_count : variable->type->column_count;
5756 BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS;
5757 float *dst = dst_void;
5758 unsigned int row, col;
5760 if (transpose)
5761 major = !major;
5763 if (major)
5765 for (col = 0; col < col_count; ++col)
5767 for (row = 0; row < row_count; ++row)
5768 dst[(col * 4) + row] = src->m[row][col];
5771 else
5773 for (row = 0; row < row_count; ++row)
5775 for (col = 0; col < col_count; ++col)
5776 dst[(row * 4) + col] = src->m[row][col];
5781 static void write_matrix_variable_to_buffer(struct d3d10_effect_variable *variable, void *src_data, BOOL transpose)
5783 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5785 write_matrix_to_buffer(variable, dst, src_data, transpose);
5787 variable->buffer->u.buffer.changed = TRUE;
5790 static void write_matrix_variable_array_to_buffer(struct d3d10_effect_variable *variable, void *src_data,
5791 unsigned int offset, unsigned int count, BOOL transpose)
5793 BYTE *dst = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5794 struct d3d10_matrix *src = src_data;
5795 unsigned int i;
5797 if (!variable->type->element_count)
5799 write_matrix_variable_to_buffer(variable, src_data, transpose);
5800 return;
5803 if (offset >= variable->type->element_count)
5805 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
5806 return;
5809 if (count > variable->type->element_count - offset)
5811 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
5812 offset, count, variable->type->element_count);
5813 count = variable->type->element_count - offset;
5816 if (offset)
5817 dst += variable->type->stride * offset;
5819 for (i = 0; i < count; ++i)
5821 write_matrix_to_buffer(variable, dst, &src[i], transpose);
5823 dst += variable->type->stride;
5826 variable->buffer->u.buffer.changed = TRUE;
5829 static void read_matrix_from_buffer(struct d3d10_effect_variable *variable, void *src_void,
5830 struct d3d10_matrix *dst, BOOL transpose)
5832 unsigned int col_count = !transpose ? variable->type->column_count : variable->type->row_count;
5833 unsigned int row_count = !transpose ? variable->type->row_count : variable->type->column_count;
5834 BOOL major = variable->type->type_class == D3D10_SVC_MATRIX_COLUMNS;
5835 float *src = src_void;
5836 unsigned int row, col;
5838 if (transpose)
5839 major = !major;
5841 if (major)
5843 for (col = 0; col < col_count; ++col)
5845 for (row = 0; row < row_count; ++row)
5846 dst->m[row][col] = src[(col * 4) + row];
5849 else
5851 for (row = 0; row < row_count; ++row)
5853 for (col = 0; col < col_count; ++col)
5854 dst->m[row][col] = src[(row * 4) + col];
5859 static void read_matrix_variable_from_buffer(struct d3d10_effect_variable *variable, void *dst, BOOL transpose)
5861 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5863 read_matrix_from_buffer(variable, src, dst, transpose);
5866 static void read_matrix_variable_array_from_buffer(struct d3d10_effect_variable *variable, void *dst_data, UINT offset,
5867 UINT count, BOOL transpose)
5869 BYTE *src = variable->buffer->u.buffer.local_buffer + variable->buffer_offset;
5870 struct d3d10_matrix *dst = dst_data;
5871 unsigned int i;
5873 if (!variable->type->element_count)
5875 read_matrix_variable_from_buffer(variable, dst_data, transpose);
5876 return;
5879 if (offset >= variable->type->element_count)
5881 WARN("Offset %u larger than element count %u, ignoring.\n", offset, variable->type->element_count);
5882 return;
5885 if (count > variable->type->element_count - offset)
5887 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
5888 offset, count, variable->type->element_count);
5889 count = variable->type->element_count - offset;
5892 if (offset)
5893 src += variable->type->stride * offset;
5895 for (i = 0; i < count; ++i)
5897 read_matrix_from_buffer(variable, src, &dst[i], transpose);
5899 src += variable->type->stride;
5903 /* ID3D10EffectVariable methods */
5905 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectMatrixVariable(ID3D10EffectMatrixVariable *iface)
5907 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
5910 static BOOL STDMETHODCALLTYPE d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable *iface)
5912 struct d3d10_effect_variable *v = impl_from_ID3D10EffectMatrixVariable(iface);
5914 TRACE("iface %p\n", iface);
5916 return v != &null_matrix_variable;
5919 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetType(
5920 ID3D10EffectMatrixVariable *iface)
5922 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
5925 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetDesc(ID3D10EffectMatrixVariable *iface,
5926 D3D10_EFFECT_VARIABLE_DESC *desc)
5928 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
5931 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetAnnotationByIndex(
5932 ID3D10EffectMatrixVariable *iface, UINT index)
5934 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
5937 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetAnnotationByName(
5938 ID3D10EffectMatrixVariable *iface, const char *name)
5940 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
5943 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberByIndex(
5944 ID3D10EffectMatrixVariable *iface, UINT index)
5946 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
5949 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberByName(
5950 ID3D10EffectMatrixVariable *iface, const char *name)
5952 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
5955 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMemberBySemantic(
5956 ID3D10EffectMatrixVariable *iface, const char *semantic)
5958 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
5961 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetElement(
5962 ID3D10EffectMatrixVariable *iface, UINT index)
5964 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
5967 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetParentConstantBuffer(
5968 ID3D10EffectMatrixVariable *iface)
5970 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
5973 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsScalar(
5974 ID3D10EffectMatrixVariable *iface)
5976 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
5979 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsVector(
5980 ID3D10EffectMatrixVariable *iface)
5982 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
5985 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsMatrix(
5986 ID3D10EffectMatrixVariable *iface)
5988 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
5991 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsString(
5992 ID3D10EffectMatrixVariable *iface)
5994 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
5997 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsShaderResource(
5998 ID3D10EffectMatrixVariable *iface)
6000 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6003 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsRenderTargetView(
6004 ID3D10EffectMatrixVariable *iface)
6006 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6009 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsDepthStencilView(
6010 ID3D10EffectMatrixVariable *iface)
6012 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6015 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsConstantBuffer(
6016 ID3D10EffectMatrixVariable *iface)
6018 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6021 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsShader(
6022 ID3D10EffectMatrixVariable *iface)
6024 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6027 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsBlend(
6028 ID3D10EffectMatrixVariable *iface)
6030 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6033 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsDepthStencil(
6034 ID3D10EffectMatrixVariable *iface)
6036 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6039 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsRasterizer(
6040 ID3D10EffectMatrixVariable *iface)
6042 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6045 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_matrix_variable_AsSampler(
6046 ID3D10EffectMatrixVariable *iface)
6048 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6051 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetRawValue(ID3D10EffectMatrixVariable *iface,
6052 void *data, UINT offset, UINT count)
6054 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6057 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetRawValue(ID3D10EffectMatrixVariable *iface,
6058 void *data, UINT offset, UINT count)
6060 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6063 /* ID3D10EffectMatrixVariable methods */
6065 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrix(ID3D10EffectMatrixVariable *iface,
6066 float *data)
6068 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
6070 TRACE("iface %p, data %p.\n", iface, data);
6071 write_matrix_variable_to_buffer(var, data, FALSE);
6073 return S_OK;
6076 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable *iface,
6077 float *data)
6079 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
6081 TRACE("iface %p, data %p.\n", iface, data);
6082 read_matrix_variable_from_buffer(var, data, FALSE);
6084 return S_OK;
6087 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable *iface,
6088 float *data, UINT offset, UINT count)
6090 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
6092 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
6093 write_matrix_variable_array_to_buffer(var, data, offset, count, FALSE);
6095 return S_OK;
6098 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable *iface,
6099 float *data, UINT offset, UINT count)
6101 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
6103 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
6104 read_matrix_variable_array_from_buffer(var, data, offset, count, FALSE);
6106 return S_OK;
6109 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
6110 float *data)
6112 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
6114 TRACE("iface %p, data %p.\n", iface, data);
6115 write_matrix_variable_to_buffer(var, data, TRUE);
6117 return S_OK;
6120 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable *iface,
6121 float *data)
6123 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
6125 TRACE("iface %p, data %p.\n", iface, data);
6126 read_matrix_variable_from_buffer(var, data, TRUE);
6128 return S_OK;
6131 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
6132 float *data, UINT offset, UINT count)
6134 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
6136 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
6137 write_matrix_variable_array_to_buffer(var, data, offset, count, TRUE);
6139 return S_OK;
6142 static HRESULT STDMETHODCALLTYPE d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable *iface,
6143 float *data, UINT offset, UINT count)
6145 struct d3d10_effect_variable *var = impl_from_ID3D10EffectMatrixVariable(iface);
6147 TRACE("iface %p, data %p, offset %u, count %u.\n", iface, data, offset, count);
6148 read_matrix_variable_array_from_buffer(var, data, offset, count, TRUE);
6150 return S_OK;
6154 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl =
6156 /* ID3D10EffectVariable methods */
6157 d3d10_effect_matrix_variable_IsValid,
6158 d3d10_effect_matrix_variable_GetType,
6159 d3d10_effect_matrix_variable_GetDesc,
6160 d3d10_effect_matrix_variable_GetAnnotationByIndex,
6161 d3d10_effect_matrix_variable_GetAnnotationByName,
6162 d3d10_effect_matrix_variable_GetMemberByIndex,
6163 d3d10_effect_matrix_variable_GetMemberByName,
6164 d3d10_effect_matrix_variable_GetMemberBySemantic,
6165 d3d10_effect_matrix_variable_GetElement,
6166 d3d10_effect_matrix_variable_GetParentConstantBuffer,
6167 d3d10_effect_matrix_variable_AsScalar,
6168 d3d10_effect_matrix_variable_AsVector,
6169 d3d10_effect_matrix_variable_AsMatrix,
6170 d3d10_effect_matrix_variable_AsString,
6171 d3d10_effect_matrix_variable_AsShaderResource,
6172 d3d10_effect_matrix_variable_AsRenderTargetView,
6173 d3d10_effect_matrix_variable_AsDepthStencilView,
6174 d3d10_effect_matrix_variable_AsConstantBuffer,
6175 d3d10_effect_matrix_variable_AsShader,
6176 d3d10_effect_matrix_variable_AsBlend,
6177 d3d10_effect_matrix_variable_AsDepthStencil,
6178 d3d10_effect_matrix_variable_AsRasterizer,
6179 d3d10_effect_matrix_variable_AsSampler,
6180 d3d10_effect_matrix_variable_SetRawValue,
6181 d3d10_effect_matrix_variable_GetRawValue,
6182 /* ID3D10EffectMatrixVariable methods */
6183 d3d10_effect_matrix_variable_SetMatrix,
6184 d3d10_effect_matrix_variable_GetMatrix,
6185 d3d10_effect_matrix_variable_SetMatrixArray,
6186 d3d10_effect_matrix_variable_GetMatrixArray,
6187 d3d10_effect_matrix_variable_SetMatrixTranspose,
6188 d3d10_effect_matrix_variable_GetMatrixTranspose,
6189 d3d10_effect_matrix_variable_SetMatrixTransposeArray,
6190 d3d10_effect_matrix_variable_GetMatrixTransposeArray,
6193 /* ID3D10EffectVariable methods */
6195 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectStringVariable(ID3D10EffectStringVariable *iface)
6197 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
6200 static BOOL STDMETHODCALLTYPE d3d10_effect_string_variable_IsValid(ID3D10EffectStringVariable *iface)
6202 struct d3d10_effect_variable *v = impl_from_ID3D10EffectStringVariable(iface);
6204 TRACE("iface %p\n", iface);
6206 return v != &null_string_variable;
6209 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_string_variable_GetType(
6210 ID3D10EffectStringVariable *iface)
6212 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6215 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetDesc(ID3D10EffectStringVariable *iface,
6216 D3D10_EFFECT_VARIABLE_DESC *desc)
6218 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6221 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetAnnotationByIndex(
6222 ID3D10EffectStringVariable *iface, UINT index)
6224 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6227 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetAnnotationByName(
6228 ID3D10EffectStringVariable *iface, const char *name)
6230 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6233 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberByIndex(
6234 ID3D10EffectStringVariable *iface, UINT index)
6236 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6239 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberByName(
6240 ID3D10EffectStringVariable *iface, const char *name)
6242 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6245 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetMemberBySemantic(
6246 ID3D10EffectStringVariable *iface, const char *semantic)
6248 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6251 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_GetElement(
6252 ID3D10EffectStringVariable *iface, UINT index)
6254 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6257 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_string_variable_GetParentConstantBuffer(
6258 ID3D10EffectStringVariable *iface)
6260 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6263 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsScalar(
6264 ID3D10EffectStringVariable *iface)
6266 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6269 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsVector(
6270 ID3D10EffectStringVariable *iface)
6272 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6275 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsMatrix(
6276 ID3D10EffectStringVariable *iface)
6278 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6281 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsString(
6282 ID3D10EffectStringVariable *iface)
6284 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6287 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsShaderResource(
6288 ID3D10EffectStringVariable *iface)
6290 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6293 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsRenderTargetView(
6294 ID3D10EffectStringVariable *iface)
6296 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6299 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsDepthStencilView(
6300 ID3D10EffectStringVariable *iface)
6302 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6305 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_string_variable_AsConstantBuffer(
6306 ID3D10EffectStringVariable *iface)
6308 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6311 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsShader(
6312 ID3D10EffectStringVariable *iface)
6314 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6317 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsBlend(
6318 ID3D10EffectStringVariable *iface)
6320 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6323 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsDepthStencil(
6324 ID3D10EffectStringVariable *iface)
6326 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6329 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsRasterizer(
6330 ID3D10EffectStringVariable *iface)
6332 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6335 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_string_variable_AsSampler(
6336 ID3D10EffectStringVariable *iface)
6338 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6341 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_SetRawValue(ID3D10EffectStringVariable *iface,
6342 void *data, UINT offset, UINT count)
6344 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6347 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetRawValue(ID3D10EffectStringVariable *iface,
6348 void *data, UINT offset, UINT count)
6350 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6353 /* ID3D10EffectStringVariable methods */
6355 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetString(ID3D10EffectStringVariable *iface,
6356 const char **str)
6358 struct d3d10_effect_variable *var = impl_from_ID3D10EffectStringVariable(iface);
6359 char *value = (char *)var->u.buffer.local_buffer;
6361 TRACE("iface %p, str %p.\n", iface, str);
6363 if (!value)
6364 return E_FAIL;
6366 if (!str)
6367 return E_INVALIDARG;
6369 *str = value;
6371 return S_OK;
6374 static HRESULT STDMETHODCALLTYPE d3d10_effect_string_variable_GetStringArray(ID3D10EffectStringVariable *iface,
6375 const char **strs, UINT offset, UINT count)
6377 FIXME("iface %p, strs %p, offset %u, count %u stub!\n", iface, strs, offset, count);
6379 return E_NOTIMPL;
6383 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl =
6385 /* ID3D10EffectVariable methods */
6386 d3d10_effect_string_variable_IsValid,
6387 d3d10_effect_string_variable_GetType,
6388 d3d10_effect_string_variable_GetDesc,
6389 d3d10_effect_string_variable_GetAnnotationByIndex,
6390 d3d10_effect_string_variable_GetAnnotationByName,
6391 d3d10_effect_string_variable_GetMemberByIndex,
6392 d3d10_effect_string_variable_GetMemberByName,
6393 d3d10_effect_string_variable_GetMemberBySemantic,
6394 d3d10_effect_string_variable_GetElement,
6395 d3d10_effect_string_variable_GetParentConstantBuffer,
6396 d3d10_effect_string_variable_AsScalar,
6397 d3d10_effect_string_variable_AsVector,
6398 d3d10_effect_string_variable_AsMatrix,
6399 d3d10_effect_string_variable_AsString,
6400 d3d10_effect_string_variable_AsShaderResource,
6401 d3d10_effect_string_variable_AsRenderTargetView,
6402 d3d10_effect_string_variable_AsDepthStencilView,
6403 d3d10_effect_string_variable_AsConstantBuffer,
6404 d3d10_effect_string_variable_AsShader,
6405 d3d10_effect_string_variable_AsBlend,
6406 d3d10_effect_string_variable_AsDepthStencil,
6407 d3d10_effect_string_variable_AsRasterizer,
6408 d3d10_effect_string_variable_AsSampler,
6409 d3d10_effect_string_variable_SetRawValue,
6410 d3d10_effect_string_variable_GetRawValue,
6411 /* ID3D10EffectStringVariable methods */
6412 d3d10_effect_string_variable_GetString,
6413 d3d10_effect_string_variable_GetStringArray,
6416 static void set_shader_resource_variable(ID3D10ShaderResourceView **src, ID3D10ShaderResourceView **dst)
6418 if (*dst == *src)
6419 return;
6421 if (*src)
6422 ID3D10ShaderResourceView_AddRef(*src);
6423 if (*dst)
6424 ID3D10ShaderResourceView_Release(*dst);
6426 *dst = *src;
6429 /* ID3D10EffectVariable methods */
6431 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectShaderResourceVariable(
6432 ID3D10EffectShaderResourceVariable *iface)
6434 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
6437 static BOOL STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_IsValid(ID3D10EffectShaderResourceVariable *iface)
6439 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderResourceVariable(iface);
6441 TRACE("iface %p.\n", iface);
6443 return v != &null_shader_resource_variable;
6446 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetType(
6447 ID3D10EffectShaderResourceVariable *iface)
6449 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6452 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetDesc(
6453 ID3D10EffectShaderResourceVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
6455 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6458 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetAnnotationByIndex(
6459 ID3D10EffectShaderResourceVariable *iface, UINT index)
6461 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6464 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetAnnotationByName(
6465 ID3D10EffectShaderResourceVariable *iface, const char *name)
6467 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6470 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberByIndex(
6471 ID3D10EffectShaderResourceVariable *iface, UINT index)
6473 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6476 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberByName(
6477 ID3D10EffectShaderResourceVariable *iface, const char *name)
6479 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6482 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetMemberBySemantic(
6483 ID3D10EffectShaderResourceVariable *iface, const char *semantic)
6485 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6488 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetElement(
6489 ID3D10EffectShaderResourceVariable *iface, UINT index)
6491 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6494 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetParentConstantBuffer(
6495 ID3D10EffectShaderResourceVariable *iface)
6497 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6500 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsScalar(
6501 ID3D10EffectShaderResourceVariable *iface)
6503 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6506 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsVector(
6507 ID3D10EffectShaderResourceVariable *iface)
6509 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6512 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsMatrix(
6513 ID3D10EffectShaderResourceVariable *iface)
6515 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6518 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsString(
6519 ID3D10EffectShaderResourceVariable *iface)
6521 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6524 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsShaderResource(
6525 ID3D10EffectShaderResourceVariable *iface)
6527 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6530 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsRenderTargetView(
6531 ID3D10EffectShaderResourceVariable *iface)
6533 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6536 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsDepthStencilView(
6537 ID3D10EffectShaderResourceVariable *iface)
6539 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6542 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsConstantBuffer(
6543 ID3D10EffectShaderResourceVariable *iface)
6545 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6548 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsShader(
6549 ID3D10EffectShaderResourceVariable *iface)
6551 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6554 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsBlend(
6555 ID3D10EffectShaderResourceVariable *iface)
6557 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6560 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsDepthStencil(
6561 ID3D10EffectShaderResourceVariable *iface)
6563 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6566 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsRasterizer(
6567 ID3D10EffectShaderResourceVariable *iface)
6569 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6572 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_AsSampler(
6573 ID3D10EffectShaderResourceVariable *iface)
6575 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6578 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetRawValue(
6579 ID3D10EffectShaderResourceVariable *iface, void *data, UINT offset, UINT count)
6581 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6584 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetRawValue(
6585 ID3D10EffectShaderResourceVariable *iface, void *data, UINT offset, UINT count)
6587 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6590 /* ID3D10EffectShaderResourceVariable methods */
6592 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResource(
6593 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView *resource)
6595 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderResourceVariable(iface);
6597 TRACE("iface %p, resource %p.\n", iface, resource);
6599 if (!d3d10_effect_shader_resource_variable_IsValid(iface))
6600 return E_FAIL;
6602 set_shader_resource_variable(&resource, v->u.resource.srv);
6604 return S_OK;
6607 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResource(
6608 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resource)
6610 FIXME("iface %p, resource %p stub!\n", iface, resource);
6612 return E_NOTIMPL;
6615 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_SetResourceArray(
6616 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resources, UINT offset, UINT count)
6618 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderResourceVariable(iface);
6619 ID3D10ShaderResourceView **rsrc_view;
6620 unsigned int i;
6622 TRACE("iface %p, resources %p, offset %u, count %u.\n", iface, resources, offset, count);
6624 if (!v->type->element_count)
6625 return d3d10_effect_shader_resource_variable_SetResource(iface, *resources);
6627 if (offset >= v->type->element_count)
6629 WARN("Offset %u larger than element count %u, ignoring.\n", offset, v->type->element_count);
6630 return S_OK;
6633 if (count > v->type->element_count - offset)
6635 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6636 offset, count, v->type->element_count);
6637 count = v->type->element_count - offset;
6640 rsrc_view = &v->u.resource.srv[offset];
6641 for (i = 0; i < count; ++i)
6642 set_shader_resource_variable(&resources[i], &rsrc_view[i]);
6644 return S_OK;
6647 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_resource_variable_GetResourceArray(
6648 ID3D10EffectShaderResourceVariable *iface, ID3D10ShaderResourceView **resources, UINT offset, UINT count)
6650 FIXME("iface %p, resources %p, offset %u, count %u stub!\n", iface, resources, offset, count);
6652 return E_NOTIMPL;
6656 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl =
6658 /* ID3D10EffectVariable methods */
6659 d3d10_effect_shader_resource_variable_IsValid,
6660 d3d10_effect_shader_resource_variable_GetType,
6661 d3d10_effect_shader_resource_variable_GetDesc,
6662 d3d10_effect_shader_resource_variable_GetAnnotationByIndex,
6663 d3d10_effect_shader_resource_variable_GetAnnotationByName,
6664 d3d10_effect_shader_resource_variable_GetMemberByIndex,
6665 d3d10_effect_shader_resource_variable_GetMemberByName,
6666 d3d10_effect_shader_resource_variable_GetMemberBySemantic,
6667 d3d10_effect_shader_resource_variable_GetElement,
6668 d3d10_effect_shader_resource_variable_GetParentConstantBuffer,
6669 d3d10_effect_shader_resource_variable_AsScalar,
6670 d3d10_effect_shader_resource_variable_AsVector,
6671 d3d10_effect_shader_resource_variable_AsMatrix,
6672 d3d10_effect_shader_resource_variable_AsString,
6673 d3d10_effect_shader_resource_variable_AsShaderResource,
6674 d3d10_effect_shader_resource_variable_AsRenderTargetView,
6675 d3d10_effect_shader_resource_variable_AsDepthStencilView,
6676 d3d10_effect_shader_resource_variable_AsConstantBuffer,
6677 d3d10_effect_shader_resource_variable_AsShader,
6678 d3d10_effect_shader_resource_variable_AsBlend,
6679 d3d10_effect_shader_resource_variable_AsDepthStencil,
6680 d3d10_effect_shader_resource_variable_AsRasterizer,
6681 d3d10_effect_shader_resource_variable_AsSampler,
6682 d3d10_effect_shader_resource_variable_SetRawValue,
6683 d3d10_effect_shader_resource_variable_GetRawValue,
6684 /* ID3D10EffectShaderResourceVariable methods */
6685 d3d10_effect_shader_resource_variable_SetResource,
6686 d3d10_effect_shader_resource_variable_GetResource,
6687 d3d10_effect_shader_resource_variable_SetResourceArray,
6688 d3d10_effect_shader_resource_variable_GetResourceArray,
6691 /* ID3D10EffectVariable methods */
6693 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectRenderTargetViewVariable(
6694 ID3D10EffectRenderTargetViewVariable *iface)
6696 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
6699 static BOOL STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_IsValid(
6700 ID3D10EffectRenderTargetViewVariable *iface)
6702 struct d3d10_effect_variable *v = impl_from_ID3D10EffectRenderTargetViewVariable(iface);
6704 TRACE("iface %p\n", iface);
6706 return v != &null_render_target_view_variable;
6709 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetType(
6710 ID3D10EffectRenderTargetViewVariable *iface)
6712 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6715 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetDesc(
6716 ID3D10EffectRenderTargetViewVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
6718 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6721 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetAnnotationByIndex(
6722 ID3D10EffectRenderTargetViewVariable *iface, UINT index)
6724 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6727 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetAnnotationByName(
6728 ID3D10EffectRenderTargetViewVariable *iface, const char *name)
6730 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6733 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberByIndex(
6734 ID3D10EffectRenderTargetViewVariable *iface, UINT index)
6736 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6739 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberByName(
6740 ID3D10EffectRenderTargetViewVariable *iface, const char *name)
6742 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6745 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetMemberBySemantic(
6746 ID3D10EffectRenderTargetViewVariable *iface, const char *semantic)
6748 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6751 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetElement(
6752 ID3D10EffectRenderTargetViewVariable *iface, UINT index)
6754 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6757 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetParentConstantBuffer(
6758 ID3D10EffectRenderTargetViewVariable *iface)
6760 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6763 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsScalar(
6764 ID3D10EffectRenderTargetViewVariable *iface)
6766 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
6769 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsVector(
6770 ID3D10EffectRenderTargetViewVariable *iface)
6772 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
6775 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsMatrix(
6776 ID3D10EffectRenderTargetViewVariable *iface)
6778 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
6781 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsString(
6782 ID3D10EffectRenderTargetViewVariable *iface)
6784 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
6787 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsShaderResource(
6788 ID3D10EffectRenderTargetViewVariable *iface)
6790 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
6793 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsRenderTargetView(
6794 ID3D10EffectRenderTargetViewVariable *iface)
6796 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
6799 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsDepthStencilView(
6800 ID3D10EffectRenderTargetViewVariable *iface)
6802 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
6805 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsConstantBuffer(
6806 ID3D10EffectRenderTargetViewVariable *iface)
6808 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
6811 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsShader(
6812 ID3D10EffectRenderTargetViewVariable *iface)
6814 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
6817 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsBlend(
6818 ID3D10EffectRenderTargetViewVariable *iface)
6820 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
6823 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsDepthStencil(
6824 ID3D10EffectRenderTargetViewVariable *iface)
6826 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
6829 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsRasterizer(
6830 ID3D10EffectRenderTargetViewVariable *iface)
6832 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
6835 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_AsSampler(
6836 ID3D10EffectRenderTargetViewVariable *iface)
6838 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
6841 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRawValue(
6842 ID3D10EffectRenderTargetViewVariable *iface, void *data, UINT offset, UINT count)
6844 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6847 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRawValue(
6848 ID3D10EffectRenderTargetViewVariable *iface, void *data, UINT offset, UINT count)
6850 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
6853 /* ID3D10EffectRenderTargetViewVariable methods */
6855 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRenderTarget(
6856 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView *view)
6858 FIXME("iface %p, view %p stub!\n", iface, view);
6860 return E_NOTIMPL;
6863 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRenderTarget(
6864 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **view)
6866 FIXME("iface %p, view %p stub!\n", iface, view);
6868 return E_NOTIMPL;
6871 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_SetRenderTargetArray(
6872 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **views, UINT offset, UINT count)
6874 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6876 return E_NOTIMPL;
6879 static HRESULT STDMETHODCALLTYPE d3d10_effect_render_target_view_variable_GetRenderTargetArray(
6880 ID3D10EffectRenderTargetViewVariable *iface, ID3D10RenderTargetView **views, UINT offset, UINT count)
6882 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
6884 return E_NOTIMPL;
6888 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl =
6890 /* ID3D10EffectVariable methods */
6891 d3d10_effect_render_target_view_variable_IsValid,
6892 d3d10_effect_render_target_view_variable_GetType,
6893 d3d10_effect_render_target_view_variable_GetDesc,
6894 d3d10_effect_render_target_view_variable_GetAnnotationByIndex,
6895 d3d10_effect_render_target_view_variable_GetAnnotationByName,
6896 d3d10_effect_render_target_view_variable_GetMemberByIndex,
6897 d3d10_effect_render_target_view_variable_GetMemberByName,
6898 d3d10_effect_render_target_view_variable_GetMemberBySemantic,
6899 d3d10_effect_render_target_view_variable_GetElement,
6900 d3d10_effect_render_target_view_variable_GetParentConstantBuffer,
6901 d3d10_effect_render_target_view_variable_AsScalar,
6902 d3d10_effect_render_target_view_variable_AsVector,
6903 d3d10_effect_render_target_view_variable_AsMatrix,
6904 d3d10_effect_render_target_view_variable_AsString,
6905 d3d10_effect_render_target_view_variable_AsShaderResource,
6906 d3d10_effect_render_target_view_variable_AsRenderTargetView,
6907 d3d10_effect_render_target_view_variable_AsDepthStencilView,
6908 d3d10_effect_render_target_view_variable_AsConstantBuffer,
6909 d3d10_effect_render_target_view_variable_AsShader,
6910 d3d10_effect_render_target_view_variable_AsBlend,
6911 d3d10_effect_render_target_view_variable_AsDepthStencil,
6912 d3d10_effect_render_target_view_variable_AsRasterizer,
6913 d3d10_effect_render_target_view_variable_AsSampler,
6914 d3d10_effect_render_target_view_variable_SetRawValue,
6915 d3d10_effect_render_target_view_variable_GetRawValue,
6916 /* ID3D10EffectRenderTargetViewVariable methods */
6917 d3d10_effect_render_target_view_variable_SetRenderTarget,
6918 d3d10_effect_render_target_view_variable_GetRenderTarget,
6919 d3d10_effect_render_target_view_variable_SetRenderTargetArray,
6920 d3d10_effect_render_target_view_variable_GetRenderTargetArray,
6923 /* ID3D10EffectVariable methods */
6925 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectDepthStencilViewVariable(
6926 ID3D10EffectDepthStencilViewVariable *iface)
6928 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
6931 static BOOL STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_IsValid(
6932 ID3D10EffectDepthStencilViewVariable *iface)
6934 struct d3d10_effect_variable *v = impl_from_ID3D10EffectDepthStencilViewVariable(iface);
6936 TRACE("iface %p\n", iface);
6938 return v != &null_depth_stencil_view_variable;
6941 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetType(
6942 ID3D10EffectDepthStencilViewVariable *iface)
6944 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
6947 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDesc(
6948 ID3D10EffectDepthStencilViewVariable *iface, D3D10_EFFECT_VARIABLE_DESC *desc)
6950 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
6953 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex(
6954 ID3D10EffectDepthStencilViewVariable *iface, UINT index)
6956 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
6959 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetAnnotationByName(
6960 ID3D10EffectDepthStencilViewVariable *iface, const char *name)
6962 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
6965 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberByIndex(
6966 ID3D10EffectDepthStencilViewVariable *iface, UINT index)
6968 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
6971 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberByName(
6972 ID3D10EffectDepthStencilViewVariable *iface, const char *name)
6974 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
6977 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic(
6978 ID3D10EffectDepthStencilViewVariable *iface, const char *semantic)
6980 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
6983 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetElement(
6984 ID3D10EffectDepthStencilViewVariable *iface, UINT index)
6986 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
6989 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer(
6990 ID3D10EffectDepthStencilViewVariable *iface)
6992 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
6995 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsScalar(
6996 ID3D10EffectDepthStencilViewVariable *iface)
6998 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7001 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsVector(
7002 ID3D10EffectDepthStencilViewVariable *iface)
7004 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7007 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsMatrix(
7008 ID3D10EffectDepthStencilViewVariable *iface)
7010 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7013 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsString(
7014 ID3D10EffectDepthStencilViewVariable *iface)
7016 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7019 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsShaderResource(
7020 ID3D10EffectDepthStencilViewVariable *iface)
7022 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7025 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsRenderTargetView(
7026 ID3D10EffectDepthStencilViewVariable *iface)
7028 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7031 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsDepthStencilView(
7032 ID3D10EffectDepthStencilViewVariable *iface)
7034 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7037 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsConstantBuffer(
7038 ID3D10EffectDepthStencilViewVariable *iface)
7040 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7043 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsShader(
7044 ID3D10EffectDepthStencilViewVariable *iface)
7046 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7049 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsBlend(
7050 ID3D10EffectDepthStencilViewVariable *iface)
7052 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7055 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsDepthStencil(
7056 ID3D10EffectDepthStencilViewVariable *iface)
7058 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7061 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsRasterizer(
7062 ID3D10EffectDepthStencilViewVariable *iface)
7064 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7067 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_AsSampler(
7068 ID3D10EffectDepthStencilViewVariable *iface)
7070 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7073 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetRawValue(
7074 ID3D10EffectDepthStencilViewVariable *iface, void *data, UINT offset, UINT count)
7076 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7079 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetRawValue(
7080 ID3D10EffectDepthStencilViewVariable *iface, void *data, UINT offset, UINT count)
7082 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7085 /* ID3D10EffectDepthStencilViewVariable methods */
7087 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetDepthStencil(
7088 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView *view)
7090 FIXME("iface %p, view %p stub!\n", iface, view);
7092 return E_NOTIMPL;
7095 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDepthStencil(
7096 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **view)
7098 FIXME("iface %p, view %p stub!\n", iface, view);
7100 return E_NOTIMPL;
7103 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray(
7104 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **views, UINT offset, UINT count)
7106 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
7108 return E_NOTIMPL;
7111 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray(
7112 ID3D10EffectDepthStencilViewVariable *iface, ID3D10DepthStencilView **views, UINT offset, UINT count)
7114 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface, views, offset, count);
7116 return E_NOTIMPL;
7120 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl =
7122 /* ID3D10EffectVariable methods */
7123 d3d10_effect_depth_stencil_view_variable_IsValid,
7124 d3d10_effect_depth_stencil_view_variable_GetType,
7125 d3d10_effect_depth_stencil_view_variable_GetDesc,
7126 d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex,
7127 d3d10_effect_depth_stencil_view_variable_GetAnnotationByName,
7128 d3d10_effect_depth_stencil_view_variable_GetMemberByIndex,
7129 d3d10_effect_depth_stencil_view_variable_GetMemberByName,
7130 d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic,
7131 d3d10_effect_depth_stencil_view_variable_GetElement,
7132 d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer,
7133 d3d10_effect_depth_stencil_view_variable_AsScalar,
7134 d3d10_effect_depth_stencil_view_variable_AsVector,
7135 d3d10_effect_depth_stencil_view_variable_AsMatrix,
7136 d3d10_effect_depth_stencil_view_variable_AsString,
7137 d3d10_effect_depth_stencil_view_variable_AsShaderResource,
7138 d3d10_effect_depth_stencil_view_variable_AsRenderTargetView,
7139 d3d10_effect_depth_stencil_view_variable_AsDepthStencilView,
7140 d3d10_effect_depth_stencil_view_variable_AsConstantBuffer,
7141 d3d10_effect_depth_stencil_view_variable_AsShader,
7142 d3d10_effect_depth_stencil_view_variable_AsBlend,
7143 d3d10_effect_depth_stencil_view_variable_AsDepthStencil,
7144 d3d10_effect_depth_stencil_view_variable_AsRasterizer,
7145 d3d10_effect_depth_stencil_view_variable_AsSampler,
7146 d3d10_effect_depth_stencil_view_variable_SetRawValue,
7147 d3d10_effect_depth_stencil_view_variable_GetRawValue,
7148 /* ID3D10EffectDepthStencilViewVariable methods */
7149 d3d10_effect_depth_stencil_view_variable_SetDepthStencil,
7150 d3d10_effect_depth_stencil_view_variable_GetDepthStencil,
7151 d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray,
7152 d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray,
7155 /* ID3D10EffectVariable methods */
7157 static BOOL STDMETHODCALLTYPE d3d10_effect_shader_variable_IsValid(ID3D10EffectShaderVariable *iface)
7159 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
7161 TRACE("iface %p\n", iface);
7163 return v != &null_shader_variable;
7166 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetType(
7167 ID3D10EffectShaderVariable *iface)
7169 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7172 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetDesc(ID3D10EffectShaderVariable *iface,
7173 D3D10_EFFECT_VARIABLE_DESC *desc)
7175 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7178 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetAnnotationByIndex(
7179 ID3D10EffectShaderVariable *iface, UINT index)
7181 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7184 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetAnnotationByName(
7185 ID3D10EffectShaderVariable *iface, const char *name)
7187 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7190 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberByIndex(
7191 ID3D10EffectShaderVariable *iface, UINT index)
7193 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7196 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberByName(
7197 ID3D10EffectShaderVariable *iface, const char *name)
7199 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7202 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetMemberBySemantic(
7203 ID3D10EffectShaderVariable *iface, const char *semantic)
7205 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7208 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetElement(
7209 ID3D10EffectShaderVariable *iface, UINT index)
7211 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7214 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_variable_GetParentConstantBuffer(
7215 ID3D10EffectShaderVariable *iface)
7217 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7220 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsScalar(
7221 ID3D10EffectShaderVariable *iface)
7223 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7226 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsVector(
7227 ID3D10EffectShaderVariable *iface)
7229 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7232 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsMatrix(
7233 ID3D10EffectShaderVariable *iface)
7235 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7238 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsString(
7239 ID3D10EffectShaderVariable *iface)
7241 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7244 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsShaderResource(
7245 ID3D10EffectShaderVariable *iface)
7247 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7250 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsRenderTargetView(
7251 ID3D10EffectShaderVariable *iface)
7253 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7256 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsDepthStencilView(
7257 ID3D10EffectShaderVariable *iface)
7259 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7262 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsConstantBuffer(
7263 ID3D10EffectShaderVariable *iface)
7265 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7268 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsShader(
7269 ID3D10EffectShaderVariable *iface)
7271 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7274 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsBlend(
7275 ID3D10EffectShaderVariable *iface)
7277 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7280 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsDepthStencil(
7281 ID3D10EffectShaderVariable *iface)
7283 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7286 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsRasterizer(
7287 ID3D10EffectShaderVariable *iface)
7289 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7292 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_shader_variable_AsSampler(
7293 ID3D10EffectShaderVariable *iface)
7295 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7298 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_SetRawValue(
7299 ID3D10EffectShaderVariable *iface, void *data, UINT offset, UINT count)
7301 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7304 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetRawValue(
7305 ID3D10EffectShaderVariable *iface, void *data, UINT offset, UINT count)
7307 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7310 /* ID3D10EffectShaderVariable methods */
7312 static HRESULT d3d10_get_shader_variable(struct d3d10_effect_variable *v, UINT shader_index,
7313 struct d3d10_effect_shader_variable **s, D3D10_SHADER_VARIABLE_TYPE *basetype)
7315 unsigned int i;
7317 v = d3d10_array_get_element(v, 0);
7319 if (!shader_index)
7321 *s = &v->u.shader;
7322 if (basetype) *basetype = v->type->basetype;
7323 return S_OK;
7326 /* Index is used as an offset from this variable. */
7328 for (i = 0; i < v->effect->used_shader_count; ++i)
7330 if (v == v->effect->used_shaders[i]) break;
7333 if (i + shader_index >= v->effect->used_shader_count)
7335 WARN("Invalid shader index %u.\n", shader_index);
7336 return E_FAIL;
7339 *s = &v->effect->used_shaders[i + shader_index]->u.shader;
7340 if (basetype) *basetype = v->effect->used_shaders[i + shader_index]->type->basetype;
7342 return S_OK;
7345 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetShaderDesc(
7346 ID3D10EffectShaderVariable *iface, UINT index, D3D10_EFFECT_SHADER_DESC *desc)
7348 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
7349 struct d3d10_effect_shader_variable *s;
7350 D3D10_SHADER_DESC shader_desc;
7351 HRESULT hr;
7353 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7355 if (FAILED(hr = d3d10_get_shader_variable(v, index, &s, NULL)))
7356 return hr;
7358 memset(desc, 0, sizeof(*desc));
7359 if (s->input_signature)
7360 desc->pInputSignature = ID3D10Blob_GetBufferPointer(s->input_signature);
7361 desc->SODecl = s->stream_output_declaration;
7362 desc->IsInline = s->isinline;
7363 if (s->bytecode)
7365 desc->pBytecode = ID3D10Blob_GetBufferPointer(s->bytecode);
7366 desc->BytecodeLength = ID3D10Blob_GetBufferSize(s->bytecode);
7368 if (s->reflection)
7370 if (SUCCEEDED(hr = s->reflection->lpVtbl->GetDesc(s->reflection, &shader_desc)))
7372 desc->NumInputSignatureEntries = shader_desc.InputParameters;
7373 desc->NumOutputSignatureEntries = shader_desc.OutputParameters;
7377 return hr;
7380 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetVertexShader(
7381 ID3D10EffectShaderVariable *iface, UINT index, ID3D10VertexShader **shader)
7383 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
7384 struct d3d10_effect_shader_variable *s;
7385 D3D10_SHADER_VARIABLE_TYPE basetype;
7386 HRESULT hr;
7388 TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
7390 *shader = NULL;
7392 if (FAILED(hr = d3d10_get_shader_variable(v, index, &s, &basetype)))
7393 return hr;
7395 if (basetype != D3D10_SVT_VERTEXSHADER)
7397 WARN("Shader is not a vertex shader.\n");
7398 return D3DERR_INVALIDCALL;
7401 if ((*shader = s->shader.vs))
7402 ID3D10VertexShader_AddRef(*shader);
7404 return S_OK;
7407 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetGeometryShader(
7408 ID3D10EffectShaderVariable *iface, UINT index, ID3D10GeometryShader **shader)
7410 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
7411 struct d3d10_effect_shader_variable *s;
7412 D3D10_SHADER_VARIABLE_TYPE basetype;
7413 HRESULT hr;
7415 TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
7417 *shader = NULL;
7419 if (FAILED(hr = d3d10_get_shader_variable(v, index, &s, &basetype)))
7420 return hr;
7422 if (basetype != D3D10_SVT_GEOMETRYSHADER)
7424 WARN("Shader is not a geometry shader.\n");
7425 return D3DERR_INVALIDCALL;
7428 if ((*shader = s->shader.gs))
7429 ID3D10GeometryShader_AddRef(*shader);
7431 return S_OK;
7434 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetPixelShader(
7435 ID3D10EffectShaderVariable *iface, UINT index, ID3D10PixelShader **shader)
7437 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
7438 struct d3d10_effect_shader_variable *s;
7439 D3D10_SHADER_VARIABLE_TYPE basetype;
7440 HRESULT hr;
7442 TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
7444 *shader = NULL;
7446 if (FAILED(hr = d3d10_get_shader_variable(v, index, &s, &basetype)))
7447 return hr;
7449 if (basetype != D3D10_SVT_PIXELSHADER)
7451 WARN("Shader is not a pixel shader.\n");
7452 return D3DERR_INVALIDCALL;
7455 if ((*shader = s->shader.ps))
7456 ID3D10PixelShader_AddRef(*shader);
7458 return S_OK;
7461 static HRESULT d3d10_get_shader_variable_signature(struct d3d10_effect_variable *v,
7462 UINT shader_index, UINT element_index, BOOL output, D3D10_SIGNATURE_PARAMETER_DESC *desc)
7464 struct d3d10_effect_shader_variable *s;
7465 HRESULT hr;
7467 if (FAILED(hr = d3d10_get_shader_variable(v, shader_index, &s, NULL)))
7468 return hr;
7470 if (!s->reflection)
7471 return D3DERR_INVALIDCALL;
7473 if (output)
7474 return s->reflection->lpVtbl->GetOutputParameterDesc(s->reflection, element_index, desc);
7475 else
7476 return s->reflection->lpVtbl->GetInputParameterDesc(s->reflection, element_index, desc);
7479 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetInputSignatureElementDesc(
7480 ID3D10EffectShaderVariable *iface, UINT shader_index, UINT element_index,
7481 D3D10_SIGNATURE_PARAMETER_DESC *desc)
7483 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
7485 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
7486 iface, shader_index, element_index, desc);
7488 if (!iface->lpVtbl->IsValid(iface))
7490 WARN("Null variable specified\n");
7491 return E_FAIL;
7494 return d3d10_get_shader_variable_signature(v, shader_index, element_index, FALSE, desc);
7497 static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetOutputSignatureElementDesc(
7498 ID3D10EffectShaderVariable *iface, UINT shader_index, UINT element_index,
7499 D3D10_SIGNATURE_PARAMETER_DESC *desc)
7501 struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface);
7503 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
7504 iface, shader_index, element_index, desc);
7506 if (!iface->lpVtbl->IsValid(iface))
7508 WARN("Null variable specified\n");
7509 return E_FAIL;
7512 return d3d10_get_shader_variable_signature(v, shader_index, element_index, TRUE, desc);
7516 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl =
7518 /* ID3D10EffectVariable methods */
7519 d3d10_effect_shader_variable_IsValid,
7520 d3d10_effect_shader_variable_GetType,
7521 d3d10_effect_shader_variable_GetDesc,
7522 d3d10_effect_shader_variable_GetAnnotationByIndex,
7523 d3d10_effect_shader_variable_GetAnnotationByName,
7524 d3d10_effect_shader_variable_GetMemberByIndex,
7525 d3d10_effect_shader_variable_GetMemberByName,
7526 d3d10_effect_shader_variable_GetMemberBySemantic,
7527 d3d10_effect_shader_variable_GetElement,
7528 d3d10_effect_shader_variable_GetParentConstantBuffer,
7529 d3d10_effect_shader_variable_AsScalar,
7530 d3d10_effect_shader_variable_AsVector,
7531 d3d10_effect_shader_variable_AsMatrix,
7532 d3d10_effect_shader_variable_AsString,
7533 d3d10_effect_shader_variable_AsShaderResource,
7534 d3d10_effect_shader_variable_AsRenderTargetView,
7535 d3d10_effect_shader_variable_AsDepthStencilView,
7536 d3d10_effect_shader_variable_AsConstantBuffer,
7537 d3d10_effect_shader_variable_AsShader,
7538 d3d10_effect_shader_variable_AsBlend,
7539 d3d10_effect_shader_variable_AsDepthStencil,
7540 d3d10_effect_shader_variable_AsRasterizer,
7541 d3d10_effect_shader_variable_AsSampler,
7542 d3d10_effect_shader_variable_SetRawValue,
7543 d3d10_effect_shader_variable_GetRawValue,
7544 /* ID3D10EffectShaderVariable methods */
7545 d3d10_effect_shader_variable_GetShaderDesc,
7546 d3d10_effect_shader_variable_GetVertexShader,
7547 d3d10_effect_shader_variable_GetGeometryShader,
7548 d3d10_effect_shader_variable_GetPixelShader,
7549 d3d10_effect_shader_variable_GetInputSignatureElementDesc,
7550 d3d10_effect_shader_variable_GetOutputSignatureElementDesc,
7553 /* ID3D10EffectVariable methods */
7555 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectBlendVariable(
7556 ID3D10EffectBlendVariable *iface)
7558 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
7561 static BOOL STDMETHODCALLTYPE d3d10_effect_blend_variable_IsValid(ID3D10EffectBlendVariable *iface)
7563 struct d3d10_effect_variable *v = impl_from_ID3D10EffectBlendVariable(iface);
7565 TRACE("iface %p\n", iface);
7567 return v != &null_blend_variable;
7570 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetType(
7571 ID3D10EffectBlendVariable *iface)
7573 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7576 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetDesc(ID3D10EffectBlendVariable *iface,
7577 D3D10_EFFECT_VARIABLE_DESC *desc)
7579 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7582 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetAnnotationByIndex(
7583 ID3D10EffectBlendVariable *iface, UINT index)
7585 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7588 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetAnnotationByName(
7589 ID3D10EffectBlendVariable *iface, const char *name)
7591 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7594 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberByIndex(
7595 ID3D10EffectBlendVariable *iface, UINT index)
7597 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7600 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberByName(
7601 ID3D10EffectBlendVariable *iface, const char *name)
7603 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7606 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetMemberBySemantic(
7607 ID3D10EffectBlendVariable *iface, const char *semantic)
7609 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7612 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetElement(
7613 ID3D10EffectBlendVariable *iface, UINT index)
7615 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7618 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_blend_variable_GetParentConstantBuffer(
7619 ID3D10EffectBlendVariable *iface)
7621 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7624 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsScalar(
7625 ID3D10EffectBlendVariable *iface)
7627 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7630 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsVector(
7631 ID3D10EffectBlendVariable *iface)
7633 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7636 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsMatrix(
7637 ID3D10EffectBlendVariable *iface)
7639 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7642 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsString(
7643 ID3D10EffectBlendVariable *iface)
7645 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7648 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsShaderResource(
7649 ID3D10EffectBlendVariable *iface)
7651 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7654 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsRenderTargetView(
7655 ID3D10EffectBlendVariable *iface)
7657 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7660 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsDepthStencilView(
7661 ID3D10EffectBlendVariable *iface)
7663 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7666 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsConstantBuffer(
7667 ID3D10EffectBlendVariable *iface)
7669 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7672 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsShader(
7673 ID3D10EffectBlendVariable *iface)
7675 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7678 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsBlend(
7679 ID3D10EffectBlendVariable *iface)
7681 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7684 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsDepthStencil(
7685 ID3D10EffectBlendVariable *iface)
7687 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7690 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsRasterizer(
7691 ID3D10EffectBlendVariable *iface)
7693 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7696 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_blend_variable_AsSampler(
7697 ID3D10EffectBlendVariable *iface)
7699 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7702 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_SetRawValue(ID3D10EffectBlendVariable *iface,
7703 void *data, UINT offset, UINT count)
7705 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7708 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetRawValue(ID3D10EffectBlendVariable *iface,
7709 void *data, UINT offset, UINT count)
7711 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7714 /* ID3D10EffectBlendVariable methods */
7716 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetBlendState(ID3D10EffectBlendVariable *iface,
7717 UINT index, ID3D10BlendState **blend_state)
7719 struct d3d10_effect_variable *v = impl_from_ID3D10EffectBlendVariable(iface);
7721 TRACE("iface %p, index %u, blend_state %p.\n", iface, index, blend_state);
7723 if (v->type->element_count)
7724 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7725 else if (index)
7726 return E_FAIL;
7728 if (v->type->basetype != D3D10_SVT_BLEND)
7730 WARN("Variable is not a blend state.\n");
7731 return E_FAIL;
7734 if ((*blend_state = v->u.state.object.blend))
7735 ID3D10BlendState_AddRef(*blend_state);
7737 return S_OK;
7740 static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetBackingStore(ID3D10EffectBlendVariable *iface,
7741 UINT index, D3D10_BLEND_DESC *desc)
7743 struct d3d10_effect_variable *v = impl_from_ID3D10EffectBlendVariable(iface);
7745 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7747 if (v->type->element_count)
7748 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7750 if (v->type->basetype != D3D10_SVT_BLEND)
7752 WARN("Variable is not a blend state.\n");
7753 return E_FAIL;
7756 *desc = v->u.state.desc.blend;
7758 return S_OK;
7762 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl =
7764 /* ID3D10EffectVariable methods */
7765 d3d10_effect_blend_variable_IsValid,
7766 d3d10_effect_blend_variable_GetType,
7767 d3d10_effect_blend_variable_GetDesc,
7768 d3d10_effect_blend_variable_GetAnnotationByIndex,
7769 d3d10_effect_blend_variable_GetAnnotationByName,
7770 d3d10_effect_blend_variable_GetMemberByIndex,
7771 d3d10_effect_blend_variable_GetMemberByName,
7772 d3d10_effect_blend_variable_GetMemberBySemantic,
7773 d3d10_effect_blend_variable_GetElement,
7774 d3d10_effect_blend_variable_GetParentConstantBuffer,
7775 d3d10_effect_blend_variable_AsScalar,
7776 d3d10_effect_blend_variable_AsVector,
7777 d3d10_effect_blend_variable_AsMatrix,
7778 d3d10_effect_blend_variable_AsString,
7779 d3d10_effect_blend_variable_AsShaderResource,
7780 d3d10_effect_blend_variable_AsRenderTargetView,
7781 d3d10_effect_blend_variable_AsDepthStencilView,
7782 d3d10_effect_blend_variable_AsConstantBuffer,
7783 d3d10_effect_blend_variable_AsShader,
7784 d3d10_effect_blend_variable_AsBlend,
7785 d3d10_effect_blend_variable_AsDepthStencil,
7786 d3d10_effect_blend_variable_AsRasterizer,
7787 d3d10_effect_blend_variable_AsSampler,
7788 d3d10_effect_blend_variable_SetRawValue,
7789 d3d10_effect_blend_variable_GetRawValue,
7790 /* ID3D10EffectBlendVariable methods */
7791 d3d10_effect_blend_variable_GetBlendState,
7792 d3d10_effect_blend_variable_GetBackingStore,
7795 /* ID3D10EffectVariable methods */
7797 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectDepthStencilVariable(
7798 ID3D10EffectDepthStencilVariable *iface)
7800 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
7803 static BOOL STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_IsValid(ID3D10EffectDepthStencilVariable *iface)
7805 struct d3d10_effect_variable *v = impl_from_ID3D10EffectDepthStencilVariable(iface);
7807 TRACE("iface %p\n", iface);
7809 return v != &null_depth_stencil_variable;
7812 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetType(
7813 ID3D10EffectDepthStencilVariable *iface)
7815 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
7818 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetDesc(ID3D10EffectDepthStencilVariable *iface,
7819 D3D10_EFFECT_VARIABLE_DESC *desc)
7821 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
7824 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetAnnotationByIndex(
7825 ID3D10EffectDepthStencilVariable *iface, UINT index)
7827 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
7830 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetAnnotationByName(
7831 ID3D10EffectDepthStencilVariable *iface, const char *name)
7833 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
7836 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberByIndex(
7837 ID3D10EffectDepthStencilVariable *iface, UINT index)
7839 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
7842 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberByName(
7843 ID3D10EffectDepthStencilVariable *iface, const char *name)
7845 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
7848 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetMemberBySemantic(
7849 ID3D10EffectDepthStencilVariable *iface, const char *semantic)
7851 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
7854 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetElement(
7855 ID3D10EffectDepthStencilVariable *iface, UINT index)
7857 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
7860 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetParentConstantBuffer(
7861 ID3D10EffectDepthStencilVariable *iface)
7863 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
7866 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsScalar(
7867 ID3D10EffectDepthStencilVariable *iface)
7869 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
7872 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsVector(
7873 ID3D10EffectDepthStencilVariable *iface)
7875 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
7878 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsMatrix(
7879 ID3D10EffectDepthStencilVariable *iface)
7881 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
7884 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsString(
7885 ID3D10EffectDepthStencilVariable *iface)
7887 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
7890 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsShaderResource(
7891 ID3D10EffectDepthStencilVariable *iface)
7893 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
7896 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsRenderTargetView(
7897 ID3D10EffectDepthStencilVariable *iface)
7899 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
7902 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsDepthStencilView(
7903 ID3D10EffectDepthStencilVariable *iface)
7905 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
7908 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsConstantBuffer(
7909 ID3D10EffectDepthStencilVariable *iface)
7911 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
7914 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsShader(
7915 ID3D10EffectDepthStencilVariable *iface)
7917 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
7920 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsBlend(
7921 ID3D10EffectDepthStencilVariable *iface)
7923 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
7926 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsDepthStencil(
7927 ID3D10EffectDepthStencilVariable *iface)
7929 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
7932 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsRasterizer(
7933 ID3D10EffectDepthStencilVariable *iface)
7935 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
7938 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_AsSampler(
7939 ID3D10EffectDepthStencilVariable *iface)
7941 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
7944 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_SetRawValue(ID3D10EffectDepthStencilVariable *iface,
7945 void *data, UINT offset, UINT count)
7947 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7950 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetRawValue(ID3D10EffectDepthStencilVariable *iface,
7951 void *data, UINT offset, UINT count)
7953 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
7956 /* ID3D10EffectDepthStencilVariable methods */
7958 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetDepthStencilState(ID3D10EffectDepthStencilVariable *iface,
7959 UINT index, ID3D10DepthStencilState **depth_stencil_state)
7961 struct d3d10_effect_variable *v = impl_from_ID3D10EffectDepthStencilVariable(iface);
7963 TRACE("iface %p, index %u, depth_stencil_state %p.\n", iface, index, depth_stencil_state);
7965 if (v->type->element_count)
7966 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7967 else if (index)
7968 return E_FAIL;
7970 if (v->type->basetype != D3D10_SVT_DEPTHSTENCIL)
7972 WARN("Variable is not a depth stencil state.\n");
7973 return E_FAIL;
7976 if ((*depth_stencil_state = v->u.state.object.depth_stencil))
7977 ID3D10DepthStencilState_AddRef(*depth_stencil_state);
7979 return S_OK;
7982 static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetBackingStore(ID3D10EffectDepthStencilVariable *iface,
7983 UINT index, D3D10_DEPTH_STENCIL_DESC *desc)
7985 struct d3d10_effect_variable *v = impl_from_ID3D10EffectDepthStencilVariable(iface);
7987 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
7989 if (v->type->element_count)
7990 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
7992 if (v->type->basetype != D3D10_SVT_DEPTHSTENCIL)
7994 WARN("Variable is not a depth stencil state.\n");
7995 return E_FAIL;
7998 *desc = v->u.state.desc.depth_stencil;
8000 return S_OK;
8004 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl =
8006 /* ID3D10EffectVariable methods */
8007 d3d10_effect_depth_stencil_variable_IsValid,
8008 d3d10_effect_depth_stencil_variable_GetType,
8009 d3d10_effect_depth_stencil_variable_GetDesc,
8010 d3d10_effect_depth_stencil_variable_GetAnnotationByIndex,
8011 d3d10_effect_depth_stencil_variable_GetAnnotationByName,
8012 d3d10_effect_depth_stencil_variable_GetMemberByIndex,
8013 d3d10_effect_depth_stencil_variable_GetMemberByName,
8014 d3d10_effect_depth_stencil_variable_GetMemberBySemantic,
8015 d3d10_effect_depth_stencil_variable_GetElement,
8016 d3d10_effect_depth_stencil_variable_GetParentConstantBuffer,
8017 d3d10_effect_depth_stencil_variable_AsScalar,
8018 d3d10_effect_depth_stencil_variable_AsVector,
8019 d3d10_effect_depth_stencil_variable_AsMatrix,
8020 d3d10_effect_depth_stencil_variable_AsString,
8021 d3d10_effect_depth_stencil_variable_AsShaderResource,
8022 d3d10_effect_depth_stencil_variable_AsRenderTargetView,
8023 d3d10_effect_depth_stencil_variable_AsDepthStencilView,
8024 d3d10_effect_depth_stencil_variable_AsConstantBuffer,
8025 d3d10_effect_depth_stencil_variable_AsShader,
8026 d3d10_effect_depth_stencil_variable_AsBlend,
8027 d3d10_effect_depth_stencil_variable_AsDepthStencil,
8028 d3d10_effect_depth_stencil_variable_AsRasterizer,
8029 d3d10_effect_depth_stencil_variable_AsSampler,
8030 d3d10_effect_depth_stencil_variable_SetRawValue,
8031 d3d10_effect_depth_stencil_variable_GetRawValue,
8032 /* ID3D10EffectDepthStencilVariable methods */
8033 d3d10_effect_depth_stencil_variable_GetDepthStencilState,
8034 d3d10_effect_depth_stencil_variable_GetBackingStore,
8037 /* ID3D10EffectVariable methods */
8039 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectRasterizerVariable(
8040 ID3D10EffectRasterizerVariable *iface)
8042 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
8045 static BOOL STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_IsValid(ID3D10EffectRasterizerVariable *iface)
8047 struct d3d10_effect_variable *v = impl_from_ID3D10EffectRasterizerVariable(iface);
8049 TRACE("iface %p\n", iface);
8051 return v != &null_rasterizer_variable;
8054 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetType(
8055 ID3D10EffectRasterizerVariable *iface)
8057 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
8060 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetDesc(ID3D10EffectRasterizerVariable *iface,
8061 D3D10_EFFECT_VARIABLE_DESC *desc)
8063 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
8066 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetAnnotationByIndex(
8067 ID3D10EffectRasterizerVariable *iface, UINT index)
8069 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
8072 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetAnnotationByName(
8073 ID3D10EffectRasterizerVariable *iface, const char *name)
8075 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
8078 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberByIndex(
8079 ID3D10EffectRasterizerVariable *iface, UINT index)
8081 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
8084 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberByName(
8085 ID3D10EffectRasterizerVariable *iface, const char *name)
8087 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
8090 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetMemberBySemantic(
8091 ID3D10EffectRasterizerVariable *iface, const char *semantic)
8093 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
8096 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetElement(
8097 ID3D10EffectRasterizerVariable *iface, UINT index)
8099 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
8102 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetParentConstantBuffer(
8103 ID3D10EffectRasterizerVariable *iface)
8105 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
8108 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsScalar(
8109 ID3D10EffectRasterizerVariable *iface)
8111 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
8114 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsVector(
8115 ID3D10EffectRasterizerVariable *iface)
8117 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
8120 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsMatrix(
8121 ID3D10EffectRasterizerVariable *iface)
8123 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
8126 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsString(
8127 ID3D10EffectRasterizerVariable *iface)
8129 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
8132 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsShaderResource(
8133 ID3D10EffectRasterizerVariable *iface)
8135 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
8138 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsRenderTargetView(
8139 ID3D10EffectRasterizerVariable *iface)
8141 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
8144 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsDepthStencilView(
8145 ID3D10EffectRasterizerVariable *iface)
8147 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
8150 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsConstantBuffer(
8151 ID3D10EffectRasterizerVariable *iface)
8153 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
8156 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsShader(
8157 ID3D10EffectRasterizerVariable *iface)
8159 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
8162 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsBlend(
8163 ID3D10EffectRasterizerVariable *iface)
8165 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
8168 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsDepthStencil(
8169 ID3D10EffectRasterizerVariable *iface)
8171 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
8174 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsRasterizer(
8175 ID3D10EffectRasterizerVariable *iface)
8177 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
8180 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_AsSampler(
8181 ID3D10EffectRasterizerVariable *iface)
8183 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
8186 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_SetRawValue(ID3D10EffectRasterizerVariable *iface,
8187 void *data, UINT offset, UINT count)
8189 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
8192 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetRawValue(ID3D10EffectRasterizerVariable *iface,
8193 void *data, UINT offset, UINT count)
8195 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
8198 /* ID3D10EffectRasterizerVariable methods */
8200 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetRasterizerState(ID3D10EffectRasterizerVariable *iface,
8201 UINT index, ID3D10RasterizerState **rasterizer_state)
8203 struct d3d10_effect_variable *v = impl_from_ID3D10EffectRasterizerVariable(iface);
8205 TRACE("iface %p, index %u, rasterizer_state %p.\n", iface, index, rasterizer_state);
8207 if (v->type->element_count)
8208 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
8209 else if (index)
8210 return E_FAIL;
8212 if (v->type->basetype != D3D10_SVT_RASTERIZER)
8214 WARN("Variable is not a rasterizer state.\n");
8215 return E_FAIL;
8218 if ((*rasterizer_state = v->u.state.object.rasterizer))
8219 ID3D10RasterizerState_AddRef(*rasterizer_state);
8221 return S_OK;
8224 static HRESULT STDMETHODCALLTYPE d3d10_effect_rasterizer_variable_GetBackingStore(ID3D10EffectRasterizerVariable *iface,
8225 UINT index, D3D10_RASTERIZER_DESC *desc)
8227 struct d3d10_effect_variable *v = impl_from_ID3D10EffectRasterizerVariable(iface);
8229 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
8231 if (v->type->element_count)
8232 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
8234 if (v->type->basetype != D3D10_SVT_RASTERIZER)
8236 WARN("Variable is not a rasterizer state.\n");
8237 return E_FAIL;
8240 *desc = v->u.state.desc.rasterizer;
8242 return S_OK;
8246 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl =
8248 /* ID3D10EffectVariable methods */
8249 d3d10_effect_rasterizer_variable_IsValid,
8250 d3d10_effect_rasterizer_variable_GetType,
8251 d3d10_effect_rasterizer_variable_GetDesc,
8252 d3d10_effect_rasterizer_variable_GetAnnotationByIndex,
8253 d3d10_effect_rasterizer_variable_GetAnnotationByName,
8254 d3d10_effect_rasterizer_variable_GetMemberByIndex,
8255 d3d10_effect_rasterizer_variable_GetMemberByName,
8256 d3d10_effect_rasterizer_variable_GetMemberBySemantic,
8257 d3d10_effect_rasterizer_variable_GetElement,
8258 d3d10_effect_rasterizer_variable_GetParentConstantBuffer,
8259 d3d10_effect_rasterizer_variable_AsScalar,
8260 d3d10_effect_rasterizer_variable_AsVector,
8261 d3d10_effect_rasterizer_variable_AsMatrix,
8262 d3d10_effect_rasterizer_variable_AsString,
8263 d3d10_effect_rasterizer_variable_AsShaderResource,
8264 d3d10_effect_rasterizer_variable_AsRenderTargetView,
8265 d3d10_effect_rasterizer_variable_AsDepthStencilView,
8266 d3d10_effect_rasterizer_variable_AsConstantBuffer,
8267 d3d10_effect_rasterizer_variable_AsShader,
8268 d3d10_effect_rasterizer_variable_AsBlend,
8269 d3d10_effect_rasterizer_variable_AsDepthStencil,
8270 d3d10_effect_rasterizer_variable_AsRasterizer,
8271 d3d10_effect_rasterizer_variable_AsSampler,
8272 d3d10_effect_rasterizer_variable_SetRawValue,
8273 d3d10_effect_rasterizer_variable_GetRawValue,
8274 /* ID3D10EffectRasterizerVariable methods */
8275 d3d10_effect_rasterizer_variable_GetRasterizerState,
8276 d3d10_effect_rasterizer_variable_GetBackingStore,
8279 /* ID3D10EffectVariable methods */
8281 static inline struct d3d10_effect_variable *impl_from_ID3D10EffectSamplerVariable(
8282 ID3D10EffectSamplerVariable *iface)
8284 return CONTAINING_RECORD(iface, struct d3d10_effect_variable, ID3D10EffectVariable_iface);
8287 static BOOL STDMETHODCALLTYPE d3d10_effect_sampler_variable_IsValid(ID3D10EffectSamplerVariable *iface)
8289 struct d3d10_effect_variable *v = impl_from_ID3D10EffectSamplerVariable(iface);
8291 TRACE("iface %p\n", iface);
8293 return v != &null_sampler_variable;
8296 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetType(
8297 ID3D10EffectSamplerVariable *iface)
8299 return d3d10_effect_variable_GetType((ID3D10EffectVariable *)iface);
8302 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetDesc(ID3D10EffectSamplerVariable *iface,
8303 D3D10_EFFECT_VARIABLE_DESC *desc)
8305 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable *)iface, desc);
8308 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetAnnotationByIndex(
8309 ID3D10EffectSamplerVariable *iface, UINT index)
8311 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable *)iface, index);
8314 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetAnnotationByName(
8315 ID3D10EffectSamplerVariable *iface, const char *name)
8317 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable *)iface, name);
8320 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberByIndex(
8321 ID3D10EffectSamplerVariable *iface, UINT index)
8323 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable *)iface, index);
8326 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberByName(
8327 ID3D10EffectSamplerVariable *iface, const char *name)
8329 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable *)iface, name);
8332 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetMemberBySemantic(
8333 ID3D10EffectSamplerVariable *iface, const char *semantic)
8335 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable *)iface, semantic);
8338 static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetElement(
8339 ID3D10EffectSamplerVariable *iface, UINT index)
8341 return d3d10_effect_variable_GetElement((ID3D10EffectVariable *)iface, index);
8344 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetParentConstantBuffer(
8345 ID3D10EffectSamplerVariable *iface)
8347 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable *)iface);
8350 static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsScalar(
8351 ID3D10EffectSamplerVariable *iface)
8353 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable *)iface);
8356 static struct ID3D10EffectVectorVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsVector(
8357 ID3D10EffectSamplerVariable *iface)
8359 return d3d10_effect_variable_AsVector((ID3D10EffectVariable *)iface);
8362 static struct ID3D10EffectMatrixVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsMatrix(
8363 ID3D10EffectSamplerVariable *iface)
8365 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable *)iface);
8368 static struct ID3D10EffectStringVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsString(
8369 ID3D10EffectSamplerVariable *iface)
8371 return d3d10_effect_variable_AsString((ID3D10EffectVariable *)iface);
8374 static struct ID3D10EffectShaderResourceVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsShaderResource(
8375 ID3D10EffectSamplerVariable *iface)
8377 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable *)iface);
8380 static struct ID3D10EffectRenderTargetViewVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsRenderTargetView(
8381 ID3D10EffectSamplerVariable *iface)
8383 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable *)iface);
8386 static struct ID3D10EffectDepthStencilViewVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsDepthStencilView(
8387 ID3D10EffectSamplerVariable *iface)
8389 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable *)iface);
8392 static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsConstantBuffer(
8393 ID3D10EffectSamplerVariable *iface)
8395 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable *)iface);
8398 static struct ID3D10EffectShaderVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsShader(
8399 ID3D10EffectSamplerVariable *iface)
8401 return d3d10_effect_variable_AsShader((ID3D10EffectVariable *)iface);
8404 static struct ID3D10EffectBlendVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsBlend(
8405 ID3D10EffectSamplerVariable *iface)
8407 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable *)iface);
8410 static struct ID3D10EffectDepthStencilVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsDepthStencil(
8411 ID3D10EffectSamplerVariable *iface)
8413 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable *)iface);
8416 static struct ID3D10EffectRasterizerVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsRasterizer(
8417 ID3D10EffectSamplerVariable *iface)
8419 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable *)iface);
8422 static struct ID3D10EffectSamplerVariable * STDMETHODCALLTYPE d3d10_effect_sampler_variable_AsSampler(
8423 ID3D10EffectSamplerVariable *iface)
8425 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable *)iface);
8428 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_SetRawValue(ID3D10EffectSamplerVariable *iface,
8429 void *data, UINT offset, UINT count)
8431 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
8434 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetRawValue(ID3D10EffectSamplerVariable *iface,
8435 void *data, UINT offset, UINT count)
8437 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable *)iface, data, offset, count);
8440 /* ID3D10EffectSamplerVariable methods */
8442 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetSampler(ID3D10EffectSamplerVariable *iface,
8443 UINT index, ID3D10SamplerState **sampler)
8445 struct d3d10_effect_variable *v = impl_from_ID3D10EffectSamplerVariable(iface);
8447 TRACE("iface %p, index %u, sampler %p.\n", iface, index, sampler);
8449 if (v->type->element_count)
8450 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
8451 else if (index)
8452 return E_FAIL;
8454 if (v->type->basetype != D3D10_SVT_SAMPLER)
8456 WARN("Variable is not a sampler state.\n");
8457 return E_FAIL;
8460 if ((*sampler = v->u.state.object.sampler))
8461 ID3D10SamplerState_AddRef(*sampler);
8463 return S_OK;
8466 static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetBackingStore(ID3D10EffectSamplerVariable *iface,
8467 UINT index, D3D10_SAMPLER_DESC *desc)
8469 struct d3d10_effect_variable *v = impl_from_ID3D10EffectSamplerVariable(iface);
8471 TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
8473 if (v->type->element_count)
8474 v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
8476 if (v->type->basetype != D3D10_SVT_SAMPLER)
8478 WARN("Variable is not a sampler state.\n");
8479 return E_FAIL;
8482 *desc = v->u.state.desc.sampler.desc;
8484 return S_OK;
8488 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl =
8490 /* ID3D10EffectVariable methods */
8491 d3d10_effect_sampler_variable_IsValid,
8492 d3d10_effect_sampler_variable_GetType,
8493 d3d10_effect_sampler_variable_GetDesc,
8494 d3d10_effect_sampler_variable_GetAnnotationByIndex,
8495 d3d10_effect_sampler_variable_GetAnnotationByName,
8496 d3d10_effect_sampler_variable_GetMemberByIndex,
8497 d3d10_effect_sampler_variable_GetMemberByName,
8498 d3d10_effect_sampler_variable_GetMemberBySemantic,
8499 d3d10_effect_sampler_variable_GetElement,
8500 d3d10_effect_sampler_variable_GetParentConstantBuffer,
8501 d3d10_effect_sampler_variable_AsScalar,
8502 d3d10_effect_sampler_variable_AsVector,
8503 d3d10_effect_sampler_variable_AsMatrix,
8504 d3d10_effect_sampler_variable_AsString,
8505 d3d10_effect_sampler_variable_AsShaderResource,
8506 d3d10_effect_sampler_variable_AsRenderTargetView,
8507 d3d10_effect_sampler_variable_AsDepthStencilView,
8508 d3d10_effect_sampler_variable_AsConstantBuffer,
8509 d3d10_effect_sampler_variable_AsShader,
8510 d3d10_effect_sampler_variable_AsBlend,
8511 d3d10_effect_sampler_variable_AsDepthStencil,
8512 d3d10_effect_sampler_variable_AsRasterizer,
8513 d3d10_effect_sampler_variable_AsSampler,
8514 d3d10_effect_sampler_variable_SetRawValue,
8515 d3d10_effect_sampler_variable_GetRawValue,
8516 /* ID3D10EffectSamplerVariable methods */
8517 d3d10_effect_sampler_variable_GetSampler,
8518 d3d10_effect_sampler_variable_GetBackingStore,
8521 /* ID3D10EffectType methods */
8523 static inline struct d3d10_effect_type *impl_from_ID3D10EffectType(ID3D10EffectType *iface)
8525 return CONTAINING_RECORD(iface, struct d3d10_effect_type, ID3D10EffectType_iface);
8528 static BOOL STDMETHODCALLTYPE d3d10_effect_type_IsValid(ID3D10EffectType *iface)
8530 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8532 TRACE("iface %p\n", iface);
8534 return This != &null_type;
8537 static HRESULT STDMETHODCALLTYPE d3d10_effect_type_GetDesc(ID3D10EffectType *iface, D3D10_EFFECT_TYPE_DESC *desc)
8539 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8541 TRACE("iface %p, desc %p\n", iface, desc);
8543 if (This == &null_type)
8545 WARN("Null type specified\n");
8546 return E_FAIL;
8549 if (!desc)
8551 WARN("Invalid argument specified\n");
8552 return E_INVALIDARG;
8555 desc->TypeName = This->name;
8556 desc->Class = This->type_class;
8557 desc->Type = This->basetype;
8558 desc->Elements = This->element_count;
8559 desc->Members = This->member_count;
8560 desc->Rows = This->row_count;
8561 desc->Columns = This->column_count;
8562 desc->PackedSize = This->size_packed;
8563 desc->UnpackedSize = This->size_unpacked;
8564 desc->Stride = This->stride;
8566 return S_OK;
8569 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeByIndex(ID3D10EffectType *iface,
8570 UINT index)
8572 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8573 struct d3d10_effect_type *t;
8575 TRACE("iface %p, index %u\n", iface, index);
8577 if (index >= This->member_count)
8579 WARN("Invalid index specified\n");
8580 return &null_type.ID3D10EffectType_iface;
8583 t = (&This->members[index])->type;
8585 TRACE("Returning member %p, %s\n", t, debugstr_a(t->name));
8587 return &t->ID3D10EffectType_iface;
8590 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeByName(ID3D10EffectType *iface,
8591 const char *name)
8593 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8594 unsigned int i;
8596 TRACE("iface %p, name %s\n", iface, debugstr_a(name));
8598 if (!name)
8600 WARN("Invalid name specified\n");
8601 return &null_type.ID3D10EffectType_iface;
8604 for (i = 0; i < This->member_count; ++i)
8606 struct d3d10_effect_type_member *typem = &This->members[i];
8608 if (typem->name && !strcmp(typem->name, name))
8610 TRACE("Returning type %p.\n", typem->type);
8611 return &typem->type->ID3D10EffectType_iface;
8615 WARN("Invalid name specified\n");
8617 return &null_type.ID3D10EffectType_iface;
8620 static struct ID3D10EffectType * STDMETHODCALLTYPE d3d10_effect_type_GetMemberTypeBySemantic(ID3D10EffectType *iface,
8621 const char *semantic)
8623 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8624 unsigned int i;
8626 TRACE("iface %p, semantic %s\n", iface, debugstr_a(semantic));
8628 if (!semantic)
8630 WARN("Invalid semantic specified\n");
8631 return &null_type.ID3D10EffectType_iface;
8634 for (i = 0; i < This->member_count; ++i)
8636 struct d3d10_effect_type_member *typem = &This->members[i];
8638 if (typem->semantic && !stricmp(typem->semantic, semantic))
8640 TRACE("Returning type %p.\n", typem->type);
8641 return &typem->type->ID3D10EffectType_iface;
8645 WARN("Invalid semantic specified\n");
8647 return &null_type.ID3D10EffectType_iface;
8650 static const char * STDMETHODCALLTYPE d3d10_effect_type_GetMemberName(ID3D10EffectType *iface, UINT index)
8652 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8653 struct d3d10_effect_type_member *typem;
8655 TRACE("iface %p, index %u\n", iface, index);
8657 if (index >= This->member_count)
8659 WARN("Invalid index specified\n");
8660 return NULL;
8663 typem = &This->members[index];
8665 TRACE("Returning name %s\n", debugstr_a(typem->name));
8667 return typem->name;
8670 static const char * STDMETHODCALLTYPE d3d10_effect_type_GetMemberSemantic(ID3D10EffectType *iface, UINT index)
8672 struct d3d10_effect_type *This = impl_from_ID3D10EffectType(iface);
8673 struct d3d10_effect_type_member *typem;
8675 TRACE("iface %p, index %u\n", iface, index);
8677 if (index >= This->member_count)
8679 WARN("Invalid index specified\n");
8680 return NULL;
8683 typem = &This->members[index];
8685 TRACE("Returning semantic %s\n", debugstr_a(typem->semantic));
8687 return typem->semantic;
8690 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl =
8692 /* ID3D10EffectType */
8693 d3d10_effect_type_IsValid,
8694 d3d10_effect_type_GetDesc,
8695 d3d10_effect_type_GetMemberTypeByIndex,
8696 d3d10_effect_type_GetMemberTypeByName,
8697 d3d10_effect_type_GetMemberTypeBySemantic,
8698 d3d10_effect_type_GetMemberName,
8699 d3d10_effect_type_GetMemberSemantic,
8702 static HRESULT STDMETHODCALLTYPE d3d10_effect_pool_QueryInterface(ID3D10EffectPool *iface,
8703 REFIID riid, void **object)
8705 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
8707 if (IsEqualGUID(riid, &IID_ID3D10EffectPool) ||
8708 IsEqualGUID(riid, &IID_IUnknown))
8710 IUnknown_AddRef(iface);
8711 *object = iface;
8712 return S_OK;
8715 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
8717 *object = NULL;
8718 return E_NOINTERFACE;
8721 static ULONG STDMETHODCALLTYPE d3d10_effect_pool_AddRef(ID3D10EffectPool *iface)
8723 struct d3d10_effect *effect = impl_from_ID3D10EffectPool(iface);
8724 return d3d10_effect_AddRef(&effect->ID3D10Effect_iface);
8727 static ULONG STDMETHODCALLTYPE d3d10_effect_pool_Release(ID3D10EffectPool *iface)
8729 struct d3d10_effect *effect = impl_from_ID3D10EffectPool(iface);
8730 return d3d10_effect_Release(&effect->ID3D10Effect_iface);
8733 static ID3D10Effect * STDMETHODCALLTYPE d3d10_effect_pool_AsEffect(ID3D10EffectPool *iface)
8735 struct d3d10_effect *effect = impl_from_ID3D10EffectPool(iface);
8737 TRACE("%p.\n", iface);
8739 return &effect->ID3D10Effect_iface;
8742 const struct ID3D10EffectPoolVtbl d3d10_effect_pool_vtbl =
8744 /* IUnknown methods */
8745 d3d10_effect_pool_QueryInterface,
8746 d3d10_effect_pool_AddRef,
8747 d3d10_effect_pool_Release,
8748 /* ID3D10EffectPool methods */
8749 d3d10_effect_pool_AsEffect,
8753 static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry *entry)
8755 const struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, const struct d3d10_effect_type, entry);
8756 const DWORD *id = key;
8758 return *id - t->id;
8761 static HRESULT d3d10_create_effect(void *data, SIZE_T data_size, ID3D10Device *device,
8762 struct d3d10_effect *pool, unsigned int flags, struct d3d10_effect **effect)
8764 struct d3d10_effect *object;
8765 HRESULT hr;
8767 if (!(object = heap_alloc_zero(sizeof(*object))))
8768 return E_OUTOFMEMORY;
8770 wine_rb_init(&object->types, d3d10_effect_type_compare);
8771 object->ID3D10Effect_iface.lpVtbl = flags & D3D10_EFFECT_IS_POOL ?
8772 &d3d10_effect_pool_effect_vtbl : &d3d10_effect_vtbl;
8773 object->ID3D10EffectPool_iface.lpVtbl = &d3d10_effect_pool_vtbl;
8774 object->refcount = 1;
8775 ID3D10Device_AddRef(device);
8776 object->device = device;
8777 object->pool = pool;
8778 object->flags = flags;
8779 if (pool) IUnknown_AddRef(&pool->ID3D10Effect_iface);
8781 hr = d3d10_effect_parse(object, data, data_size);
8782 if (FAILED(hr))
8784 ERR("Failed to parse effect\n");
8785 IUnknown_Release(&object->ID3D10Effect_iface);
8786 return hr;
8789 *effect = object;
8791 return S_OK;
8794 HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT flags,
8795 ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect)
8797 struct d3d10_effect *object, *pool = NULL;
8798 HRESULT hr;
8800 TRACE("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p.\n",
8801 data, data_size, flags, device, effect_pool, effect);
8803 if (!(flags & D3D10_EFFECT_COMPILE_CHILD_EFFECT) != !effect_pool)
8804 return E_INVALIDARG;
8806 if (effect_pool && !(pool = unsafe_impl_from_ID3D10EffectPool(effect_pool)))
8808 WARN("External pool implementations are not supported.\n");
8809 return E_INVALIDARG;
8812 if (FAILED(hr = d3d10_create_effect(data, data_size, device, pool, 0, &object)))
8814 WARN("Failed to create an effect, hr %#x.\n", hr);
8815 return hr;
8818 *effect = &object->ID3D10Effect_iface;
8820 TRACE("Created effect %p\n", object);
8822 return hr;
8825 static HRESULT STDMETHODCALLTYPE d3d10_effect_pool_effect_QueryInterface(ID3D10Effect *iface,
8826 REFIID riid, void **object)
8828 struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
8830 TRACE("iface %p, riid %s, obj %p.\n", iface, debugstr_guid(riid), object);
8832 return IUnknown_QueryInterface(&effect->ID3D10EffectPool_iface, riid, object);
8835 static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl =
8837 /* IUnknown methods */
8838 d3d10_effect_pool_effect_QueryInterface,
8839 d3d10_effect_AddRef,
8840 d3d10_effect_Release,
8841 /* ID3D10Effect methods */
8842 d3d10_effect_IsValid,
8843 d3d10_effect_IsPool,
8844 d3d10_effect_GetDevice,
8845 d3d10_effect_GetDesc,
8846 d3d10_effect_GetConstantBufferByIndex,
8847 d3d10_effect_GetConstantBufferByName,
8848 d3d10_effect_GetVariableByIndex,
8849 d3d10_effect_GetVariableByName,
8850 d3d10_effect_GetVariableBySemantic,
8851 d3d10_effect_GetTechniqueByIndex,
8852 d3d10_effect_GetTechniqueByName,
8853 d3d10_effect_Optimize,
8854 d3d10_effect_IsOptimized,
8857 HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *data, SIZE_T data_size, UINT fx_flags,
8858 ID3D10Device *device, ID3D10EffectPool **effect_pool)
8860 struct d3d10_effect *object;
8861 HRESULT hr;
8863 TRACE("data %p, data_size %lu, fx_flags %#x, device %p, effect_pool %p.\n",
8864 data, data_size, fx_flags, device, effect_pool);
8866 if (FAILED(hr = d3d10_create_effect(data, data_size, device, NULL,
8867 D3D10_EFFECT_IS_POOL, &object)))
8869 WARN("Failed to create an effect, hr %#x.\n", hr);
8870 return hr;
8873 *effect_pool = &object->ID3D10EffectPool_iface;
8875 TRACE("Created effect pool %p.\n", object);
8877 return hr;