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"
22 #include <vkd3d_shader.h>
27 WINE_DEFAULT_DEBUG_CHANNEL(d3d10
);
29 #define MAKE_TAG(ch0, ch1, ch2, ch3) \
30 ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
31 ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
32 #define TAG_FX10 MAKE_TAG('F', 'X', '1', '0')
33 #define TAG_FXLC MAKE_TAG('F', 'X', 'L', 'C')
34 #define TAG_CLI4 MAKE_TAG('C', 'L', 'I', '4')
35 #define TAG_CTAB MAKE_TAG('C', 'T', 'A', 'B')
37 #define D3D10_FX10_TYPE_COLUMN_SHIFT 11
38 #define D3D10_FX10_TYPE_COLUMN_MASK (0x7 << D3D10_FX10_TYPE_COLUMN_SHIFT)
40 #define D3D10_FX10_TYPE_ROW_SHIFT 8
41 #define D3D10_FX10_TYPE_ROW_MASK (0x7 << D3D10_FX10_TYPE_ROW_SHIFT)
43 #define D3D10_FX10_TYPE_BASETYPE_SHIFT 3
44 #define D3D10_FX10_TYPE_BASETYPE_MASK (0x1f << D3D10_FX10_TYPE_BASETYPE_SHIFT)
46 #define D3D10_FX10_TYPE_CLASS_SHIFT 0
47 #define D3D10_FX10_TYPE_CLASS_MASK (0x7 << D3D10_FX10_TYPE_CLASS_SHIFT)
49 #define D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK 0x4000
51 static inline struct d3d10_effect
*impl_from_ID3D10EffectPool(ID3D10EffectPool
*iface
)
53 return CONTAINING_RECORD(iface
, struct d3d10_effect
, ID3D10EffectPool_iface
);
56 const struct ID3D10EffectPoolVtbl d3d10_effect_pool_vtbl
;
57 static inline struct d3d10_effect
*unsafe_impl_from_ID3D10EffectPool(ID3D10EffectPool
*iface
)
59 if (!iface
|| iface
->lpVtbl
!= &d3d10_effect_pool_vtbl
)
61 return CONTAINING_RECORD(iface
, struct d3d10_effect
, ID3D10EffectPool_iface
);
64 static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl
;
65 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable
*v
);
67 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl
;
68 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl
;
69 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl
;
70 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl
;
71 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl
;
72 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl
;
73 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl
;
74 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl
;
75 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl
;
76 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl
;
77 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl
;
78 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl
;
79 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl
;
80 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl
;
81 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl
;
82 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl
;
83 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl
;
85 /* null objects - needed for invalid calls */
86 static struct d3d10_effect_technique null_technique
= {{&d3d10_effect_technique_vtbl
}};
87 static struct d3d10_effect_pass null_pass
= {{&d3d10_effect_pass_vtbl
}};
88 static struct d3d10_effect_type null_type
= {{&d3d10_effect_type_vtbl
}};
89 static struct d3d10_effect_variable null_local_buffer
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_constant_buffer_vtbl
},
90 &null_local_buffer
, &null_type
};
91 static struct d3d10_effect_variable null_variable
= {{&d3d10_effect_variable_vtbl
},
92 &null_local_buffer
, &null_type
};
93 static struct d3d10_effect_variable null_scalar_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_scalar_variable_vtbl
},
94 &null_local_buffer
, &null_type
};
95 static struct d3d10_effect_variable null_vector_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_vector_variable_vtbl
},
96 &null_local_buffer
, &null_type
};
97 static struct d3d10_effect_variable null_matrix_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_matrix_variable_vtbl
},
98 &null_local_buffer
, &null_type
};
99 static struct d3d10_effect_variable null_string_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_string_variable_vtbl
},
100 &null_local_buffer
, &null_type
};
101 static struct d3d10_effect_variable null_render_target_view_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_render_target_view_variable_vtbl
},
102 &null_local_buffer
, &null_type
};
103 static struct d3d10_effect_variable null_depth_stencil_view_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_view_variable_vtbl
},
104 &null_local_buffer
, &null_type
};
105 static struct d3d10_effect_variable null_shader_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
},
106 &null_local_buffer
, &null_type
};
107 static struct d3d10_effect_variable null_blend_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_blend_variable_vtbl
},
108 &null_local_buffer
, &null_type
};
109 static struct d3d10_effect_variable null_depth_stencil_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_variable_vtbl
},
110 &null_local_buffer
, &null_type
};
111 static struct d3d10_effect_variable null_rasterizer_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_rasterizer_variable_vtbl
},
112 &null_local_buffer
, &null_type
};
113 static struct d3d10_effect_variable null_sampler_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_sampler_variable_vtbl
},
114 &null_local_buffer
, &null_type
};
116 static ID3D10ShaderResourceView
*null_srvs
[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
118 static struct d3d10_effect_variable null_shader_resource_variable
=
120 .ID3D10EffectVariable_iface
.lpVtbl
= (ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_resource_variable_vtbl
,
121 .buffer
= &null_local_buffer
,
123 .u
.resource
.srv
= null_srvs
,
126 /* anonymous_shader_type and anonymous_shader */
127 static char anonymous_name
[] = "$Anonymous";
128 static char anonymous_vertexshader_name
[] = "vertexshader";
129 static char anonymous_pixelshader_name
[] = "pixelshader";
130 static char anonymous_geometryshader_name
[] = "geometryshader";
131 static struct d3d10_effect_type anonymous_vs_type
= {{&d3d10_effect_type_vtbl
},
132 anonymous_vertexshader_name
, D3D10_SVT_VERTEXSHADER
, D3D10_SVC_OBJECT
};
133 static struct d3d10_effect_type anonymous_ps_type
= {{&d3d10_effect_type_vtbl
},
134 anonymous_pixelshader_name
, D3D10_SVT_PIXELSHADER
, D3D10_SVC_OBJECT
};
135 static struct d3d10_effect_type anonymous_gs_type
= {{&d3d10_effect_type_vtbl
},
136 anonymous_geometryshader_name
, D3D10_SVT_GEOMETRYSHADER
, D3D10_SVC_OBJECT
};
137 static struct d3d10_effect_variable anonymous_vs
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
},
138 &null_local_buffer
, &anonymous_vs_type
, anonymous_name
};
139 static struct d3d10_effect_variable anonymous_ps
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
},
140 &null_local_buffer
, &anonymous_ps_type
, anonymous_name
};
141 static struct d3d10_effect_variable anonymous_gs
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
},
142 &null_local_buffer
, &anonymous_gs_type
, anonymous_name
};
144 static struct d3d10_effect_type
*get_fx10_type(struct d3d10_effect
*effect
,
145 const char *data
, size_t data_size
, uint32_t offset
);
147 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectVariable(ID3D10EffectVariable
*iface
)
149 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
152 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectShaderVariable(ID3D10EffectShaderVariable
*iface
)
154 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
157 static struct d3d10_effect_variable
* d3d10_array_get_element(struct d3d10_effect_variable
*v
,
160 if (!v
->type
->element_count
) return v
;
161 return &v
->elements
[index
];
164 static struct d3d10_effect_variable
* d3d10_get_state_variable(struct d3d10_effect_variable
*v
,
165 unsigned int index
, const struct d3d10_effect_var_array
*array
)
167 v
= d3d10_array_get_element(v
, 0);
169 if (v
->u
.state
.index
+ index
>= array
->count
)
171 WARN("Invalid index %u.\n", index
);
175 return array
->v
[v
->u
.state
.index
+ index
];
178 enum d3d10_effect_container_type
183 D3D10_C_DEPTHSTENCIL
,
188 static enum d3d10_effect_container_type
get_var_container_type(const struct d3d10_effect_variable
*v
)
190 switch (v
->type
->basetype
)
192 case D3D10_SVT_DEPTHSTENCIL
: return D3D10_C_DEPTHSTENCIL
;
193 case D3D10_SVT_BLEND
: return D3D10_C_BLEND
;
194 case D3D10_SVT_RASTERIZER
: return D3D10_C_RASTERIZER
;
195 case D3D10_SVT_SAMPLER
: return D3D10_C_SAMPLER
;
196 default: return D3D10_C_NONE
;
200 struct preshader_instr
202 unsigned int comp_count
: 16;
203 unsigned int reserved
: 4;
204 unsigned int opcode
: 11;
205 unsigned int scalar
: 1;
208 typedef void (*pres_op_func
)(float **args
, unsigned int n
, const struct preshader_instr
*instr
);
210 static void pres_mov(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
212 float *retval
= args
[1];
215 for (i
= 0; i
< instr
->comp_count
; ++i
)
216 retval
[i
] = args
[0][i
];
219 static void pres_neg(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
221 float *retval
= args
[1];
224 for (i
= 0; i
< instr
->comp_count
; ++i
)
225 retval
[i
] = -args
[0][i
];
228 static void pres_rcp(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
230 float *retval
= args
[1];
233 for (i
= 0; i
< instr
->comp_count
; ++i
)
234 retval
[i
] = 1.0f
/ args
[0][i
];
237 static void pres_frc(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
239 float *retval
= args
[1];
242 for (i
= 0; i
< instr
->comp_count
; ++i
)
243 retval
[i
] = args
[0][i
] - floor(args
[0][i
]);
246 static void pres_exp(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
248 float *retval
= args
[1];
251 for (i
= 0; i
< instr
->comp_count
; ++i
)
252 retval
[i
] = exp2f(args
[0][i
]);
255 static void pres_log(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
257 float *retval
= args
[1];
260 for (i
= 0; i
< instr
->comp_count
; ++i
)
261 retval
[i
] = (args
[0][i
] == 0.0f
? 0.0f
: log2f(fabsf(args
[0][i
])));
264 static void pres_rsq(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
266 float *retval
= args
[1];
269 for (i
= 0; i
< instr
->comp_count
; ++i
)
270 retval
[i
] = 1.0f
/ sqrtf(args
[0][i
]);
273 static void pres_sin(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
275 float *retval
= args
[1];
278 for (i
= 0; i
< instr
->comp_count
; ++i
)
279 retval
[i
] = sin(args
[0][i
]);
282 static void pres_cos(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
284 float *retval
= args
[1];
287 for (i
= 0; i
< instr
->comp_count
; ++i
)
288 retval
[i
] = cos(args
[0][i
]);
291 static void pres_asin(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
293 float *retval
= args
[1];
296 for (i
= 0; i
< instr
->comp_count
; ++i
)
297 retval
[i
] = asinf(args
[0][i
]);
300 static void pres_acos(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
302 float *retval
= args
[1];
305 for (i
= 0; i
< instr
->comp_count
; ++i
)
306 retval
[i
] = acosf(args
[0][i
]);
309 static void pres_atan(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
311 float *retval
= args
[1];
314 for (i
= 0; i
< instr
->comp_count
; ++i
)
315 retval
[i
] = atanf(args
[0][i
]);
318 static void pres_sqrt(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
320 float *retval
= args
[1];
323 for (i
= 0; i
< instr
->comp_count
; ++i
)
324 retval
[i
] = sqrtf(args
[0][i
]);
327 static void pres_ineg(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
329 int *arg1
= (int *)args
[0];
330 float *retval
= args
[1];
333 for (i
= 0; i
< instr
->comp_count
; ++i
)
336 retval
[i
] = *(float *)&v
;
340 static void pres_not(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
342 int *arg1
= (int *)args
[0];
343 float *retval
= args
[1];
346 for (i
= 0; i
< instr
->comp_count
; ++i
)
349 retval
[i
] = *(float *)&v
;
353 static void pres_itof(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
355 float *retval
= args
[1];
358 for (i
= 0; i
< instr
->comp_count
; ++i
)
359 retval
[i
] = *(int *)&args
[0][i
];
362 static void pres_utof(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
364 float *retval
= args
[1];
367 for (i
= 0; i
< instr
->comp_count
; ++i
)
368 retval
[i
] = *(unsigned int *)&args
[0][i
];
371 static void pres_ftou(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
373 float *retval
= args
[1];
376 for (i
= 0; i
< instr
->comp_count
; ++i
)
378 unsigned int u
= args
[0][i
];
379 retval
[i
] = *(float *)&u
;
383 static void pres_ftob(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
385 float *retval
= args
[1];
388 for (i
= 0; i
< instr
->comp_count
; ++i
)
390 unsigned int u
= args
[0][i
] == 0.0f
? 0 : ~0u;
391 retval
[i
] = *(float *)&u
;
395 /* Only first source component is used. */
396 static void pres_floor(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
398 float value
= floorf(args
[0][0]);
399 float *retval
= args
[1];
402 for (i
= 0; i
< instr
->comp_count
; ++i
)
406 /* Only first source component is used. */
407 static void pres_ceil(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
409 float value
= ceilf(args
[0][0]);
410 float *retval
= args
[1];
413 for (i
= 0; i
< instr
->comp_count
; ++i
)
417 static void pres_min(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
419 float *retval
= args
[2];
422 for (i
= 0; i
< instr
->comp_count
; ++i
)
423 retval
[i
] = min(args
[0][instr
->scalar
? 0 : i
], args
[1][i
]);
426 static void pres_max(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
428 float *retval
= args
[2];
431 for (i
= 0; i
< instr
->comp_count
; ++i
)
432 retval
[i
] = max(args
[0][instr
->scalar
? 0 : i
], args
[1][i
]);
435 static void pres_add(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
437 float *retval
= args
[2];
440 for (i
= 0; i
< instr
->comp_count
; ++i
)
441 retval
[i
] = args
[0][instr
->scalar
? 0 : i
] + args
[1][i
];
444 static void pres_mul(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
446 float *retval
= args
[2];
449 for (i
= 0; i
< instr
->comp_count
; ++i
)
450 retval
[i
] = args
[0][instr
->scalar
? 0 : i
] * args
[1][i
];
453 static void pres_atan2(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
455 float *retval
= args
[2];
458 for (i
= 0; i
< instr
->comp_count
; ++i
)
459 retval
[i
] = atan2f(args
[0][instr
->scalar
? 0 : i
], args
[1][i
]);
462 static void pres_div(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
464 float *retval
= args
[2];
467 for (i
= 0; i
< instr
->comp_count
; ++i
)
468 retval
[i
] = args
[0][instr
->scalar
? 0 : i
] / args
[1][i
];
471 static void pres_iadd(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
473 int *arg1
= (int *)args
[0];
474 int *arg2
= (int *)args
[1];
475 float *retval
= args
[2];
478 for (i
= 0; i
< instr
->comp_count
; ++i
)
480 int v
= arg1
[instr
->scalar
? 0 : i
] + arg2
[i
];
481 retval
[i
] = *(float *)&v
;
485 static void pres_imul(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
487 int *arg1
= (int *)args
[0];
488 int *arg2
= (int *)args
[1];
489 float *retval
= args
[2];
492 for (i
= 0; i
< instr
->comp_count
; ++i
)
494 int v
= arg1
[instr
->scalar
? 0 : i
] * arg2
[i
];
495 retval
[i
] = *(float *)&v
;
499 static void pres_bilt(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
501 int *arg1
= (int *)args
[0];
502 int *arg2
= (int *)args
[1];
503 float *retval
= args
[2];
506 for (i
= 0; i
< instr
->comp_count
; ++i
)
508 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] < arg2
[i
] ? ~0u : 0;
509 retval
[i
] = *(float *)&v
;
513 static void pres_bige(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
515 int *arg1
= (int *)args
[0];
516 int *arg2
= (int *)args
[1];
517 float *retval
= args
[2];
520 for (i
= 0; i
< instr
->comp_count
; ++i
)
522 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] >= arg2
[i
] ? ~0u : 0;
523 retval
[i
] = *(float *)&v
;
527 static void pres_bieq(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
529 int *arg1
= (int *)args
[0];
530 int *arg2
= (int *)args
[1];
531 float *retval
= args
[2];
534 for (i
= 0; i
< instr
->comp_count
; ++i
)
536 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] == arg2
[i
] ? ~0u : 0;
537 retval
[i
] = *(float *)&v
;
541 static void pres_bine(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
543 int *arg1
= (int *)args
[0];
544 int *arg2
= (int *)args
[1];
545 float *retval
= args
[2];
548 for (i
= 0; i
< instr
->comp_count
; ++i
)
550 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] != arg2
[i
] ? ~0u : 0;
551 retval
[i
] = *(float *)&v
;
555 static void pres_buge(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
557 unsigned int *arg1
= (unsigned int *)args
[0];
558 unsigned int *arg2
= (unsigned int *)args
[1];
559 float *retval
= args
[2];
562 for (i
= 0; i
< instr
->comp_count
; ++i
)
564 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] >= arg2
[i
] ? ~0u : 0;
565 retval
[i
] = *(float *)&v
;
569 static void pres_bult(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
571 unsigned int *arg1
= (unsigned int *)args
[0];
572 unsigned int *arg2
= (unsigned int *)args
[1];
573 float *retval
= args
[2];
576 for (i
= 0; i
< instr
->comp_count
; ++i
)
578 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] < arg2
[i
] ? ~0u : 0;
579 retval
[i
] = *(float *)&v
;
583 static void pres_udiv(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
585 unsigned int *arg1
= (unsigned int *)args
[0];
586 unsigned int *arg2
= (unsigned int *)args
[1];
587 float *retval
= args
[2];
590 for (i
= 0; i
< instr
->comp_count
; ++i
)
592 unsigned int v
= arg2
[i
] ? arg1
[instr
->scalar
? 0 : i
] / arg2
[i
] : UINT_MAX
;
593 retval
[i
] = *(float *)&v
;
597 static void pres_imin(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
599 int *arg1
= (int *)args
[0], *arg2
= (int *)args
[1];
600 float *retval
= args
[2];
603 for (i
= 0; i
< instr
->comp_count
; ++i
)
605 int v
= min(arg1
[instr
->scalar
? 0 : i
], arg2
[i
]);
606 retval
[i
] = *(float *)&v
;
610 static void pres_imax(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
612 int *arg1
= (int *)args
[0], *arg2
= (int *)args
[1];
613 float *retval
= args
[2];
616 for (i
= 0; i
< instr
->comp_count
; ++i
)
618 int v
= max(arg1
[instr
->scalar
? 0 : i
], arg2
[i
]);
619 retval
[i
] = *(float *)&v
;
623 static void pres_umin(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
625 unsigned int *arg1
= (unsigned int *)args
[0], *arg2
= (unsigned int *)args
[1];
626 float *retval
= args
[2];
629 for (i
= 0; i
< instr
->comp_count
; ++i
)
631 unsigned int v
= min(arg1
[instr
->scalar
? 0 : i
], arg2
[i
]);
632 retval
[i
] = *(float *)&v
;
636 static void pres_umax(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
638 unsigned int *arg1
= (unsigned int *)args
[0], *arg2
= (unsigned int *)args
[1];
639 float *retval
= args
[2];
642 for (i
= 0; i
< instr
->comp_count
; ++i
)
644 unsigned int v
= max(arg1
[instr
->scalar
? 0 : i
], arg2
[i
]);
645 retval
[i
] = *(float *)&v
;
649 static void pres_and(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
651 unsigned int *arg1
= (unsigned int *)args
[0];
652 unsigned int *arg2
= (unsigned int *)args
[1];
653 float *retval
= args
[2];
656 for (i
= 0; i
< instr
->comp_count
; ++i
)
658 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] & arg2
[i
];
659 retval
[i
] = *(float *)&v
;
663 static void pres_or(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
665 unsigned int *arg1
= (unsigned int *)args
[0];
666 unsigned int *arg2
= (unsigned int *)args
[1];
667 float *retval
= args
[2];
670 for (i
= 0; i
< instr
->comp_count
; ++i
)
672 unsigned int v
= arg1
[0] | arg2
[0];
673 retval
[i
] = *(float *)&v
;
677 static void pres_xor(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
679 unsigned int *arg1
= (unsigned int *)args
[0];
680 unsigned int *arg2
= (unsigned int *)args
[1];
681 float *retval
= args
[2];
684 for (i
= 0; i
< instr
->comp_count
; ++i
)
686 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] ^ arg2
[i
];
687 retval
[i
] = *(float *)&v
;
691 static void pres_ishl(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
693 int *arg1
= (int *)args
[0], *arg2
= (int *)args
[1];
694 float *retval
= args
[2];
697 for (i
= 0; i
< instr
->comp_count
; ++i
)
699 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] << (arg2
[i
] % 32);
700 retval
[i
] = *(float *)&v
;
704 static void pres_ishr(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
706 int *arg1
= (int *)args
[0], *arg2
= (int *)args
[1];
707 float *retval
= args
[2];
710 for (i
= 0; i
< instr
->comp_count
; ++i
)
712 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] >> (arg2
[i
] % 32);
713 retval
[i
] = *(float *)&v
;
717 static void pres_ushr(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
719 unsigned int *arg1
= (unsigned int *)args
[0];
720 unsigned int *arg2
= (unsigned int *)args
[1];
721 float *retval
= args
[2];
724 for (i
= 0; i
< instr
->comp_count
; ++i
)
726 unsigned int v
= arg1
[instr
->scalar
? 0 : i
] >> (arg2
[i
] % 32);
727 retval
[i
] = *(float *)&v
;
731 static void pres_movc(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
733 float *arg1
= args
[0], *arg2
= args
[1], *arg3
= args
[2];
734 float *retval
= args
[3];
737 for (i
= 0; i
< instr
->comp_count
; ++i
)
738 retval
[i
] = arg1
[i
] ? arg2
[i
] : arg3
[i
];
741 static void pres_dot(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
743 float *retval
= args
[2];
747 for (i
= 0; i
< instr
->comp_count
; ++i
)
748 *retval
+= args
[0][instr
->scalar
? 0 : i
] * args
[1][i
];
751 static void pres_dotswiz(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
753 float *retval
= args
[--n
];
758 if (n
!= 6 && n
!= 8 && instr
->comp_count
== 1)
760 WARN("Unexpected argument count %u, or component count %u.\n", n
, instr
->comp_count
);
764 for (i
= 0; i
< n
/ 2; ++i
)
765 *retval
+= args
[i
][0] * args
[i
+ n
/ 2][0];
768 struct preshader_op_info
775 static const struct preshader_op_info preshader_ops
[] =
777 { 0x100, "mov", pres_mov
},
778 { 0x101, "neg", pres_neg
},
779 { 0x103, "rcp", pres_rcp
},
780 { 0x104, "frc", pres_frc
},
781 { 0x105, "exp", pres_exp
},
782 { 0x106, "log", pres_log
},
783 { 0x107, "rsq", pres_rsq
},
784 { 0x108, "sin", pres_sin
},
785 { 0x109, "cos", pres_cos
},
786 { 0x10a, "asin", pres_asin
},
787 { 0x10b, "acos", pres_acos
},
788 { 0x10c, "atan", pres_atan
},
789 { 0x112, "sqrt", pres_sqrt
},
790 { 0x120, "ineg", pres_ineg
},
791 { 0x121, "not", pres_not
},
792 { 0x130, "itof", pres_itof
},
793 { 0x131, "utof", pres_utof
},
794 { 0x133, "ftou", pres_ftou
},
795 { 0x137, "ftob", pres_ftob
},
796 { 0x139, "floor",pres_floor
},
797 { 0x13a, "ceil", pres_ceil
},
798 { 0x200, "min", pres_min
},
799 { 0x201, "max", pres_max
},
800 { 0x204, "add", pres_add
},
801 { 0x205, "mul", pres_mul
},
802 { 0x206, "atan2",pres_atan2
},
803 { 0x208, "div", pres_div
},
804 { 0x210, "bilt", pres_bilt
},
805 { 0x211, "bige", pres_bige
},
806 { 0x212, "bieq", pres_bieq
},
807 { 0x213, "bine", pres_bine
},
808 { 0x214, "buge", pres_buge
},
809 { 0x215, "bult", pres_bult
},
810 { 0x216, "iadd", pres_iadd
},
811 { 0x219, "imul", pres_imul
},
812 { 0x21a, "udiv", pres_udiv
},
813 { 0x21d, "imin", pres_imin
},
814 { 0x21e, "imax", pres_imax
},
815 { 0x21f, "umin", pres_umin
},
816 { 0x220, "umax", pres_umax
},
817 { 0x230, "and", pres_and
},
818 { 0x231, "or", pres_or
},
819 { 0x233, "xor", pres_xor
},
820 { 0x234, "ishl", pres_ishl
},
821 { 0x235, "ishr", pres_ishr
},
822 { 0x236, "ushr", pres_ushr
},
823 { 0x301, "movc", pres_movc
},
824 { 0x500, "dot", pres_dot
},
825 { 0x70e, "d3ds_dotswiz", pres_dotswiz
},
828 static int __cdecl
preshader_op_compare(const void *a
, const void *b
)
830 int opcode
= *(int *)a
;
831 const struct preshader_op_info
*op_info
= b
;
832 return opcode
- op_info
->opcode
;
835 static const struct preshader_op_info
* d3d10_effect_get_op_info(int opcode
)
837 return bsearch(&opcode
, preshader_ops
, ARRAY_SIZE(preshader_ops
), sizeof(*preshader_ops
),
838 preshader_op_compare
);
841 struct d3d10_ctab_var
843 struct d3d10_effect_variable
*v
;
848 struct d3d10_reg_table
858 enum d3d10_reg_table_type
860 D3D10_REG_TABLE_CONSTANTS
= 1,
861 D3D10_REG_TABLE_CB
= 2,
862 D3D10_REG_TABLE_RESULT
= 4,
863 D3D10_REG_TABLE_TEMP
= 7,
864 D3D10_REG_TABLE_COUNT
,
867 struct d3d10_effect_preshader
869 struct d3d10_reg_table reg_tables
[D3D10_REG_TABLE_COUNT
];
872 struct d3d10_ctab_var
*vars
;
873 unsigned int vars_count
;
876 struct d3d10_preshader_parse_context
878 struct d3d10_effect_preshader
*preshader
;
879 struct d3d10_effect
*effect
;
880 unsigned int table_sizes
[D3D10_REG_TABLE_COUNT
];
883 struct d3d10_effect_prop_dependency
887 unsigned int operation
;
892 struct d3d10_effect_variable
*v
;
897 struct d3d10_effect_variable
*v
;
898 struct d3d10_effect_preshader index
;
902 struct d3d10_effect_preshader value
;
907 static HRESULT
d3d10_reg_table_allocate(struct d3d10_reg_table
*table
, unsigned int count
)
909 if (!(table
->f
= calloc(count
, sizeof(*table
->f
))))
910 return E_OUTOFMEMORY
;
911 table
->count
= count
;
915 static void d3d10_effect_preshader_clear(struct d3d10_effect_preshader
*p
)
919 for (i
= 0; i
< ARRAY_SIZE(p
->reg_tables
); ++i
)
920 free(p
->reg_tables
[i
].f
);
922 ID3D10Blob_Release(p
->code
);
924 memset(p
, 0, sizeof(*p
));
927 static float * d3d10_effect_preshader_get_reg_ptr(const struct d3d10_effect_preshader
*p
,
928 enum d3d10_reg_table_type regt
, unsigned int offset
)
932 case D3D10_REG_TABLE_CONSTANTS
:
933 case D3D10_REG_TABLE_CB
:
934 case D3D10_REG_TABLE_RESULT
:
935 case D3D10_REG_TABLE_TEMP
:
936 return p
->reg_tables
[regt
].f
+ offset
;
942 static HRESULT
d3d10_effect_preshader_eval(struct d3d10_effect_preshader
*p
)
944 unsigned int i
, j
, regt
, offset
, instr_count
, arg_count
;
945 const DWORD
*ip
= ID3D10Blob_GetBufferPointer(p
->code
);
946 struct preshader_instr ins
;
947 float *dst
, *args
[9];
949 dst
= d3d10_effect_preshader_get_reg_ptr(p
, D3D10_REG_TABLE_RESULT
, 0);
950 memset(dst
, 0, sizeof(float) * p
->reg_tables
[D3D10_REG_TABLE_RESULT
].count
);
952 /* Update constant buffer */
953 dst
= d3d10_effect_preshader_get_reg_ptr(p
, D3D10_REG_TABLE_CB
, 0);
954 for (i
= 0; i
< p
->vars_count
; ++i
)
956 struct d3d10_ctab_var
*v
= &p
->vars
[i
];
957 memcpy(dst
+ v
->offset
, v
->v
->buffer
->u
.buffer
.local_buffer
+ v
->v
->buffer_offset
,
958 v
->length
* sizeof(*dst
));
963 for (i
= 0; i
< instr_count
; ++i
)
965 *(DWORD
*)&ins
= *ip
++;
966 arg_count
= 1 + *ip
++;
968 if (arg_count
> ARRAY_SIZE(args
))
970 FIXME("Unexpected argument count %u.\n", arg_count
);
974 /* Arguments are followed by the return value. */
975 for (j
= 0; j
< arg_count
; ++j
)
977 ip
++; /* TODO: argument register flags are currently ignored */
981 args
[j
] = d3d10_effect_preshader_get_reg_ptr(p
, regt
, offset
);
984 d3d10_effect_get_op_info(ins
.opcode
)->func(args
, arg_count
, &ins
);
990 static void d3d10_effect_clear_prop_dependencies(struct d3d10_effect_prop_dependencies
*d
)
994 for (i
= 0; i
< d
->count
; ++i
)
996 struct d3d10_effect_prop_dependency
*dep
= &d
->entries
[i
];
997 switch (dep
->operation
)
999 case D3D10_EOO_INDEX_EXPRESSION
:
1000 d3d10_effect_preshader_clear(&dep
->index_expr
.index
);
1002 case D3D10_EOO_VALUE_EXPRESSION
:
1003 d3d10_effect_preshader_clear(&dep
->value_expr
.value
);
1008 memset(d
, 0, sizeof(*d
));
1011 struct d3d10_effect_state_property_info
1014 D3D_SHADER_VARIABLE_TYPE type
;
1017 enum d3d10_effect_container_type container_type
;
1022 static const struct d3d10_effect_state_property_info property_infos
[] =
1024 { "Pass.RasterizerState", D3D10_SVT_RASTERIZER
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, rasterizer
) },
1025 { "Pass.DepthStencilState", D3D10_SVT_DEPTHSTENCIL
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, depth_stencil
) },
1026 { "Pass.BlendState", D3D10_SVT_BLEND
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, blend
) },
1027 { "Pass.RenderTargets", D3D10_SVT_RENDERTARGETVIEW
, 1, 8, D3D10_C_PASS
, ~0u },
1028 { "Pass.DepthStencilView", D3D10_SVT_DEPTHSTENCILVIEW
, 1, 1, D3D10_C_PASS
, ~0u },
1029 { "Pass.Unknown5", D3D10_SVT_VOID
, 0, 0, D3D10_C_PASS
, ~0u },
1030 { "Pass.VertexShader", D3D10_SVT_VERTEXSHADER
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, vs
.shader
),
1031 FIELD_OFFSET(struct d3d10_effect_pass
, vs
.index
) },
1032 { "Pass.PixelShader", D3D10_SVT_PIXELSHADER
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, ps
.shader
),
1033 FIELD_OFFSET(struct d3d10_effect_pass
, ps
.index
) },
1034 { "Pass.GeometryShader", D3D10_SVT_GEOMETRYSHADER
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, gs
.shader
),
1035 FIELD_OFFSET(struct d3d10_effect_pass
, gs
.index
) },
1036 { "Pass.StencilRef", D3D10_SVT_UINT
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, stencil_ref
) },
1037 { "Pass.BlendFactor", D3D10_SVT_FLOAT
, 4, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, blend_factor
) },
1038 { "Pass.SampleMask", D3D10_SVT_UINT
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, sample_mask
) },
1040 { "RasterizerState.FillMode", D3D10_SVT_INT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, FillMode
) },
1041 { "RasterizerState.CullMode", D3D10_SVT_INT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, CullMode
) },
1042 { "RasterizerState.FrontCounterClockwise", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, FrontCounterClockwise
) },
1043 { "RasterizerState.DepthBias", D3D10_SVT_INT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, DepthBias
) },
1044 { "RasterizerState.DepthBiasClamp", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, DepthBiasClamp
) },
1045 { "RasterizerState.SlopeScaledDepthBias", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, SlopeScaledDepthBias
) },
1046 { "RasterizerState.DepthClipEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, DepthClipEnable
) },
1047 { "RasterizerState.ScissorEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, ScissorEnable
) },
1048 { "RasterizerState.MultisampleEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, MultisampleEnable
) },
1049 { "RasterizerState.AntialiasedLineEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, AntialiasedLineEnable
) },
1051 { "DepthStencilState.DepthEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, DepthEnable
) },
1052 { "DepthStencilState.DepthWriteMask", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, DepthWriteMask
) },
1053 { "DepthStencilState.DepthFunc", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, DepthFunc
) },
1054 { "DepthStencilState.StencilEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, StencilEnable
) },
1055 { "DepthStencilState.StencilReadMask", D3D10_SVT_UINT8
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, StencilReadMask
) },
1056 { "DepthStencilState.StencilWriteMask", D3D10_SVT_UINT8
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, StencilWriteMask
) },
1057 { "DepthStencilState.FrontFaceStencilFail", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, FrontFace
.StencilFailOp
) },
1058 { "DepthStencilState.FrontFaceStencilDepthFail", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, FrontFace
.StencilDepthFailOp
)},
1059 { "DepthStencilState.FrontFaceStencilPass", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, FrontFace
.StencilPassOp
) },
1060 { "DepthStencilState.FrontFaceStencilFunc", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, FrontFace
.StencilFunc
) },
1061 { "DepthStencilState.BackFaceStencilFail", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, BackFace
.StencilFailOp
) },
1062 { "DepthStencilState.BackFaceStencilDepthFail", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, BackFace
.StencilDepthFailOp
) },
1063 { "DepthStencilState.BackFaceStencilPass", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, BackFace
.StencilPassOp
) },
1064 { "DepthStencilState.BackFaceStencilFunc", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, BackFace
.StencilFunc
) },
1066 { "BlendState.AlphaToCoverageEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, AlphaToCoverageEnable
) },
1067 { "BlendState.BlendEnable", D3D10_SVT_BOOL
, 1, 8, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, BlendEnable
) },
1068 { "BlendState.SrcBlend", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, SrcBlend
) },
1069 { "BlendState.DestBlend", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, DestBlend
) },
1070 { "BlendState.BlendOp", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, BlendOp
) },
1071 { "BlendState.SrcBlendAlpha", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, SrcBlendAlpha
) },
1072 { "BlendState.DestBlendAlpha", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, DestBlendAlpha
) },
1073 { "BlendState.BlendOpAlpha", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, BlendOpAlpha
) },
1074 { "BlendState.RenderTargetWriteMask", D3D10_SVT_UINT8
, 1, 8, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, RenderTargetWriteMask
) },
1076 { "SamplerState.Filter", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.Filter
) },
1077 { "SamplerState.AddressU", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.AddressU
) },
1078 { "SamplerState.AddressV", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.AddressV
) },
1079 { "SamplerState.AddressW", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.AddressW
) },
1080 { "SamplerState.MipLODBias", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.MipLODBias
) },
1081 { "SamplerState.MaxAnisotropy", D3D10_SVT_UINT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.MaxAnisotropy
) },
1082 { "SamplerState.ComparisonFunc", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.ComparisonFunc
) },
1083 { "SamplerState.BorderColor", D3D10_SVT_FLOAT
, 4, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.BorderColor
) },
1084 { "SamplerState.MinLOD", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.MinLOD
) },
1085 { "SamplerState.MaxLOD", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.MaxLOD
) },
1086 { "SamplerState.Texture", D3D10_SVT_TEXTURE
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, texture
) },
1089 static const D3D10_RASTERIZER_DESC default_rasterizer_desc
=
1103 static const D3D10_DEPTH_STENCIL_DESC default_depth_stencil_desc
=
1106 D3D10_DEPTH_WRITE_MASK_ALL
,
1107 D3D10_COMPARISON_LESS
,
1109 D3D10_DEFAULT_STENCIL_READ_MASK
,
1110 D3D10_DEFAULT_STENCIL_WRITE_MASK
,
1111 {D3D10_STENCIL_OP_KEEP
, D3D10_STENCIL_OP_KEEP
, D3D10_STENCIL_OP_KEEP
, D3D10_COMPARISON_ALWAYS
},
1112 {D3D10_STENCIL_OP_KEEP
, D3D10_STENCIL_OP_KEEP
, D3D10_STENCIL_OP_KEEP
, D3D10_COMPARISON_ALWAYS
},
1115 static const D3D10_BLEND_DESC default_blend_desc
=
1118 {FALSE
, FALSE
, FALSE
, FALSE
, FALSE
, FALSE
, FALSE
, FALSE
},
1119 D3D10_BLEND_SRC_ALPHA
,
1120 D3D10_BLEND_INV_SRC_ALPHA
,
1122 D3D10_BLEND_SRC_ALPHA
,
1123 D3D10_BLEND_INV_SRC_ALPHA
,
1125 {0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf},
1128 static const D3D10_SAMPLER_DESC default_sampler_desc
=
1130 D3D10_FILTER_MIN_MAG_MIP_POINT
,
1131 D3D10_TEXTURE_ADDRESS_WRAP
,
1132 D3D10_TEXTURE_ADDRESS_WRAP
,
1133 D3D10_TEXTURE_ADDRESS_WRAP
,
1136 D3D10_COMPARISON_NEVER
,
1137 {0.0f
, 0.0f
, 0.0f
, 0.0f
},
1142 struct d3d10_effect_state_storage_info
1144 D3D_SHADER_VARIABLE_TYPE id
;
1146 const void *default_state
;
1149 static const struct d3d10_effect_state_storage_info d3d10_effect_state_storage_info
[] =
1151 {D3D10_SVT_RASTERIZER
, sizeof(default_rasterizer_desc
), &default_rasterizer_desc
},
1152 {D3D10_SVT_DEPTHSTENCIL
, sizeof(default_depth_stencil_desc
), &default_depth_stencil_desc
},
1153 {D3D10_SVT_BLEND
, sizeof(default_blend_desc
), &default_blend_desc
},
1154 {D3D10_SVT_SAMPLER
, sizeof(default_sampler_desc
), &default_sampler_desc
},
1157 #define WINE_D3D10_TO_STR(x) case x: return #x
1159 static const char *debug_d3d10_shader_variable_class(D3D10_SHADER_VARIABLE_CLASS c
)
1163 WINE_D3D10_TO_STR(D3D10_SVC_SCALAR
);
1164 WINE_D3D10_TO_STR(D3D10_SVC_VECTOR
);
1165 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_ROWS
);
1166 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_COLUMNS
);
1167 WINE_D3D10_TO_STR(D3D10_SVC_OBJECT
);
1168 WINE_D3D10_TO_STR(D3D10_SVC_STRUCT
);
1170 FIXME("Unrecognised D3D10_SHADER_VARIABLE_CLASS %#x.\n", c
);
1171 return "unrecognised";
1175 static const char *debug_d3d10_shader_variable_type(D3D10_SHADER_VARIABLE_TYPE t
)
1179 WINE_D3D10_TO_STR(D3D10_SVT_VOID
);
1180 WINE_D3D10_TO_STR(D3D10_SVT_BOOL
);
1181 WINE_D3D10_TO_STR(D3D10_SVT_INT
);
1182 WINE_D3D10_TO_STR(D3D10_SVT_FLOAT
);
1183 WINE_D3D10_TO_STR(D3D10_SVT_STRING
);
1184 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE
);
1185 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1D
);
1186 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2D
);
1187 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE3D
);
1188 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBE
);
1189 WINE_D3D10_TO_STR(D3D10_SVT_SAMPLER
);
1190 WINE_D3D10_TO_STR(D3D10_SVT_PIXELSHADER
);
1191 WINE_D3D10_TO_STR(D3D10_SVT_VERTEXSHADER
);
1192 WINE_D3D10_TO_STR(D3D10_SVT_UINT
);
1193 WINE_D3D10_TO_STR(D3D10_SVT_UINT8
);
1194 WINE_D3D10_TO_STR(D3D10_SVT_GEOMETRYSHADER
);
1195 WINE_D3D10_TO_STR(D3D10_SVT_RASTERIZER
);
1196 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCIL
);
1197 WINE_D3D10_TO_STR(D3D10_SVT_BLEND
);
1198 WINE_D3D10_TO_STR(D3D10_SVT_BUFFER
);
1199 WINE_D3D10_TO_STR(D3D10_SVT_CBUFFER
);
1200 WINE_D3D10_TO_STR(D3D10_SVT_TBUFFER
);
1201 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1DARRAY
);
1202 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DARRAY
);
1203 WINE_D3D10_TO_STR(D3D10_SVT_RENDERTARGETVIEW
);
1204 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCILVIEW
);
1205 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMS
);
1206 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMSARRAY
);
1207 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBEARRAY
);
1209 FIXME("Unrecognised D3D10_SHADER_VARIABLE_TYPE %#x.\n", t
);
1210 return "unrecognised";
1214 #undef WINE_D3D10_TO_STR
1216 static HRESULT
d3d10_effect_variable_get_raw_value(struct d3d10_effect_variable
*v
,
1217 void *data
, unsigned int offset
, unsigned int count
)
1221 is_buffer
= v
->type
->basetype
== D3D10_SVT_CBUFFER
|| v
->type
->basetype
== D3D10_SVT_TBUFFER
;
1223 if (v
->type
->type_class
== D3D10_SVC_OBJECT
&& !is_buffer
)
1225 WARN("Not supported on object variables of type %s.\n",
1226 debug_d3d10_shader_variable_type(v
->type
->basetype
));
1227 return D3DERR_INVALIDCALL
;
1232 offset
+= v
->buffer_offset
;
1236 memcpy(data
, v
->u
.buffer
.local_buffer
+ offset
, count
);
1241 static BOOL
read_float_value(uint32_t value
, D3D_SHADER_VARIABLE_TYPE in_type
,
1242 float *out_data
, unsigned int out_idx
)
1246 case D3D10_SVT_FLOAT
:
1247 out_data
[out_idx
] = *(float *)&value
;
1251 out_data
[out_idx
] = (INT
)value
;
1254 case D3D10_SVT_UINT
:
1255 out_data
[out_idx
] = value
;
1259 FIXME("Unhandled in_type %#x.\n", in_type
);
1264 static BOOL
read_int32_value(uint32_t value
, D3D_SHADER_VARIABLE_TYPE in_type
,
1265 int *out_data
, unsigned int out_idx
)
1269 case D3D10_SVT_FLOAT
:
1270 out_data
[out_idx
] = *(float *)&value
;
1274 case D3D10_SVT_UINT
:
1275 case D3D10_SVT_BOOL
:
1276 out_data
[out_idx
] = value
;
1280 FIXME("Unhandled in_type %#x.\n", in_type
);
1285 static BOOL
read_int8_value(uint32_t value
, D3D_SHADER_VARIABLE_TYPE in_type
,
1286 INT8
*out_data
, unsigned int out_idx
)
1291 case D3D10_SVT_UINT
:
1292 out_data
[out_idx
] = value
;
1296 FIXME("Unhandled in_type %#x.\n", in_type
);
1301 static BOOL
d3d10_effect_read_numeric_value(uint32_t value
, D3D_SHADER_VARIABLE_TYPE in_type
,
1302 D3D_SHADER_VARIABLE_TYPE out_type
, void *out_data
, unsigned int out_idx
)
1306 case D3D10_SVT_FLOAT
:
1307 return read_float_value(value
, in_type
, out_data
, out_idx
);
1309 case D3D10_SVT_UINT
:
1310 case D3D10_SVT_BOOL
:
1311 return read_int32_value(value
, in_type
, out_data
, out_idx
);
1312 case D3D10_SVT_UINT8
:
1313 return read_int8_value(value
, in_type
, out_data
, out_idx
);
1315 FIXME("Unsupported property type %u.\n", out_type
);
1320 static void d3d10_effect_update_dependent_props(struct d3d10_effect_prop_dependencies
*deps
,
1323 const struct d3d10_effect_state_property_info
*property_info
;
1324 struct d3d10_effect_prop_dependency
*d
;
1325 unsigned int i
, j
, count
, variable_idx
;
1326 struct d3d10_effect_variable
*v
;
1327 struct d3d10_reg_table
*table
;
1328 unsigned int *dst_index
;
1333 for (i
= 0; i
< deps
->count
; ++i
)
1335 d
= &deps
->entries
[i
];
1337 property_info
= &property_infos
[d
->id
];
1339 dst
= (char *)container
+ property_info
->offset
;
1340 dst_index
= (unsigned int *)((char *)container
+ property_info
->index_offset
);
1342 switch (d
->operation
)
1345 case D3D10_EOO_CONST_INDEX
:
1349 count
= v
->type
->type_class
== D3D10_SVC_VECTOR
? 4 : 1;
1351 for (j
= 0; j
< count
; ++j
)
1353 d3d10_effect_variable_get_raw_value(v
, &value
, d
->var
.offset
+ j
* sizeof(value
), sizeof(value
));
1354 d3d10_effect_read_numeric_value(value
, v
->type
->basetype
, property_info
->type
, dst
, j
);
1359 case D3D10_EOO_INDEX_EXPRESSION
:
1361 v
= d
->index_expr
.v
;
1363 if (FAILED(hr
= d3d10_effect_preshader_eval(&d
->index_expr
.index
)))
1365 WARN("Failed to evaluate index expression, hr %#lx.\n", hr
);
1369 variable_idx
= *d
->index_expr
.index
.reg_tables
[D3D10_REG_TABLE_RESULT
].dword
;
1371 if (variable_idx
>= v
->type
->element_count
)
1373 WARN("Expression evaluated to invalid index value %u, array %s of size %u.\n",
1374 variable_idx
, debugstr_a(v
->name
), v
->type
->element_count
);
1378 /* Ignoring destination index here, there are no object typed array properties. */
1379 switch (property_info
->type
)
1381 case D3D10_SVT_VERTEXSHADER
:
1382 case D3D10_SVT_PIXELSHADER
:
1383 case D3D10_SVT_GEOMETRYSHADER
:
1385 *dst_index
= variable_idx
;
1388 *(void **)dst
= &v
->elements
[variable_idx
];
1392 case D3D10_EOO_VALUE_EXPRESSION
:
1394 if ((property_info
->type
!= D3D10_SVT_UINT
)
1395 && (property_info
->type
!= D3D10_SVT_FLOAT
)
1396 && (property_info
->type
!= D3D10_SVT_BOOL
))
1398 FIXME("Unimplemented for property %s.\n", property_info
->name
);
1402 if (FAILED(hr
= d3d10_effect_preshader_eval(&d
->value_expr
.value
)))
1404 WARN("Failed to evaluate value expression, hr %#lx.\n", hr
);
1408 table
= &d
->value_expr
.value
.reg_tables
[D3D10_REG_TABLE_RESULT
];
1410 if (property_info
->size
!= table
->count
)
1412 WARN("Unexpected value expression output size %u, property size %u.\n",
1413 table
->count
, property_info
->size
);
1417 memcpy(dst
, table
->f
, property_info
->size
* sizeof(float));
1422 FIXME("Unsupported property update for %u.\n", d
->operation
);
1427 static BOOL
d3d_array_reserve(void **elements
, SIZE_T
*capacity
, SIZE_T count
, SIZE_T size
)
1429 SIZE_T max_capacity
, new_capacity
;
1432 if (count
<= *capacity
)
1435 max_capacity
= ~(SIZE_T
)0 / size
;
1436 if (count
> max_capacity
)
1439 new_capacity
= max(1, *capacity
);
1440 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
1442 if (new_capacity
< count
)
1443 new_capacity
= count
;
1445 if (!(new_elements
= realloc(*elements
, new_capacity
* size
)))
1448 *elements
= new_elements
;
1449 *capacity
= new_capacity
;
1453 static BOOL
require_space(size_t offset
, size_t count
, size_t size
, size_t data_size
)
1455 return !count
|| (data_size
- offset
) / count
>= size
;
1458 static BOOL
fx10_get_string(const char *data
, size_t data_size
, uint32_t offset
, const char **s
, size_t *l
)
1460 size_t len
, max_len
;
1462 if (offset
>= data_size
)
1464 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1468 max_len
= data_size
- offset
;
1469 if (!(len
= strnlen(data
+ offset
, max_len
)))
1485 static BOOL
fx10_copy_string(const char *data
, size_t data_size
, DWORD offset
, char **s
)
1490 if (!fx10_get_string(data
, data_size
, offset
, &p
, &len
))
1499 if (!(*s
= malloc(len
)))
1501 ERR("Failed to allocate string memory.\n");
1510 static BOOL
copy_name(const char *ptr
, char **name
)
1512 if (!ptr
|| !*ptr
) return TRUE
;
1514 if (!(*name
= strdup(ptr
)))
1516 ERR("Failed to allocate name memory.\n");
1523 static struct d3d10_effect_variable
* d3d10_effect_get_buffer_by_name(struct d3d10_effect
*effect
,
1528 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
1530 struct d3d10_effect_variable
*l
= &effect
->local_buffers
[i
];
1531 if (l
->name
&& !strcmp(l
->name
, name
))
1535 return effect
->pool
? d3d10_effect_get_buffer_by_name(effect
->pool
, name
) : NULL
;
1538 static struct d3d10_effect_variable
* d3d10_effect_get_variable_by_name(
1539 const struct d3d10_effect
*effect
, const char *name
)
1541 struct d3d10_effect_variable
*v
;
1544 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
1546 for (j
= 0; j
< effect
->local_buffers
[i
].type
->member_count
; ++j
)
1548 v
= &effect
->local_buffers
[i
].members
[j
];
1549 if (v
->name
&& !strcmp(v
->name
, name
))
1554 for (i
= 0; i
< effect
->local_variable_count
; ++i
)
1556 struct d3d10_effect_variable
*v
= &effect
->local_variables
[i
];
1557 if (v
->name
&& !strcmp(v
->name
, name
))
1561 return effect
->pool
? d3d10_effect_get_variable_by_name(effect
->pool
, name
) : NULL
;
1564 static HRESULT
get_fx10_shader_resources(struct d3d10_effect_variable
*v
)
1566 struct d3d10_effect_shader_variable
*sv
= &v
->u
.shader
;
1567 struct d3d10_effect_shader_resource
*sr
;
1568 D3D10_SHADER_INPUT_BIND_DESC bind_desc
;
1569 D3D10_SHADER_DESC desc
;
1572 sv
->reflection
->lpVtbl
->GetDesc(sv
->reflection
, &desc
);
1573 sv
->resource_count
= desc
.BoundResources
;
1575 if (!(sv
->resources
= calloc(sv
->resource_count
, sizeof(*sv
->resources
))))
1577 ERR("Failed to allocate shader resource binding information memory.\n");
1578 return E_OUTOFMEMORY
;
1581 for (i
= 0; i
< desc
.BoundResources
; ++i
)
1583 sv
->reflection
->lpVtbl
->GetResourceBindingDesc(sv
->reflection
, i
, &bind_desc
);
1584 sr
= &sv
->resources
[i
];
1586 sr
->in_type
= bind_desc
.Type
;
1587 sr
->bind_point
= bind_desc
.BindPoint
;
1588 sr
->bind_count
= bind_desc
.BindCount
;
1590 switch (bind_desc
.Type
)
1592 case D3D10_SIT_CBUFFER
:
1593 case D3D10_SIT_TBUFFER
:
1594 if (sr
->bind_count
!= 1)
1596 WARN("Unexpected bind count %u for a buffer %s.\n", bind_desc
.BindCount
,
1597 debugstr_a(bind_desc
.Name
));
1598 return E_UNEXPECTED
;
1600 sr
->variable
= d3d10_effect_get_buffer_by_name(v
->effect
, bind_desc
.Name
);
1603 case D3D10_SIT_SAMPLER
:
1604 case D3D10_SIT_TEXTURE
:
1605 sr
->variable
= d3d10_effect_get_variable_by_name(v
->effect
, bind_desc
.Name
);
1614 WARN("Failed to find shader resource.\n");
1622 struct d3d10_effect_so_decl
1624 D3D10_SO_DECLARATION_ENTRY
*entries
;
1627 unsigned int stride
;
1631 static void d3d10_effect_cleanup_so_decl(struct d3d10_effect_so_decl
*so_decl
)
1633 free(so_decl
->entries
);
1634 free(so_decl
->decl
);
1635 memset(so_decl
, 0, sizeof(*so_decl
));
1638 static HRESULT
d3d10_effect_parse_stream_output_declaration(const char *decl
,
1639 struct d3d10_effect_so_decl
*so_decl
)
1641 static const char * xyzw
= "xyzw";
1642 static const char * rgba
= "rgba";
1643 char *p
, *ptr
, *end
, *next
, *mask
, *m
, *slot
;
1644 D3D10_SO_DECLARATION_ENTRY e
;
1647 memset(so_decl
, 0, sizeof(*so_decl
));
1649 if (!(so_decl
->decl
= strdup(decl
)))
1650 return E_OUTOFMEMORY
;
1656 memset(&e
, 0, sizeof(e
));
1658 end
= strchr(p
, ';');
1659 next
= end
? end
+ 1 : p
+ strlen(p
);
1664 /* Remove leading and trailing spaces. */
1665 while (len
&& isspace(*p
)) { len
--; p
++; }
1666 while (len
&& isspace(p
[len
- 1])) len
--;
1671 if ((slot
= strchr(p
, ':')))
1680 WARN("Invalid output slot %s.\n", debugstr_a(p
));
1686 e
.OutputSlot
= atoi(p
);
1691 if ((mask
= strchr(p
, '.')))
1695 if ((m
= strstr(xyzw
, mask
)))
1696 e
.StartComponent
= m
- xyzw
;
1697 else if ((m
= strstr(rgba
, mask
)))
1698 e
.StartComponent
= m
- rgba
;
1701 WARN("Invalid component mask %s.\n", debugstr_a(mask
));
1705 e
.ComponentCount
= strlen(mask
);
1709 e
.StartComponent
= 0;
1710 e
.ComponentCount
= 4;
1713 /* Semantic index and name */
1715 while (isdigit(p
[len
- 1]))
1720 e
.SemanticIndex
= atoi(&p
[len
]);
1724 e
.SemanticName
= stricmp(p
, "$SKIP") ? p
: NULL
;
1726 if (!d3d_array_reserve((void **)&so_decl
->entries
, &so_decl
->capacity
, so_decl
->count
+ 1,
1727 sizeof(*so_decl
->entries
)))
1730 so_decl
->entries
[so_decl
->count
++] = e
;
1732 if (e
.OutputSlot
== 0)
1733 so_decl
->stride
+= e
.ComponentCount
* sizeof(float);
1741 d3d10_effect_cleanup_so_decl(so_decl
);
1746 static HRESULT
parse_fx10_shader(const char *data
, size_t data_size
, uint32_t offset
, struct d3d10_effect_variable
*v
)
1748 ID3D10Device
*device
= v
->effect
->device
;
1753 if (v
->effect
->shaders
.current
>= v
->effect
->shaders
.count
)
1755 WARN("Invalid effect? Used shader current(%u) >= used shader count(%u)\n",
1756 v
->effect
->shaders
.current
, v
->effect
->shaders
.count
);
1760 v
->effect
->shaders
.v
[v
->effect
->shaders
.current
++] = v
;
1762 if (offset
>= data_size
|| !require_space(offset
, 1, sizeof(dxbc_size
), data_size
))
1764 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1768 ptr
= data
+ offset
;
1769 dxbc_size
= read_u32(&ptr
);
1770 TRACE("DXBC size: %#x.\n", dxbc_size
);
1772 if (!require_space(ptr
- data
, 1, dxbc_size
, data_size
))
1774 WARN("Invalid dxbc size %#x (data size %#Ix, offset %#x).\n", offset
, data_size
, offset
);
1781 if (FAILED(hr
= D3D10ReflectShader(ptr
, dxbc_size
, &v
->u
.shader
.reflection
)))
1784 D3DGetInputSignatureBlob(ptr
, dxbc_size
, &v
->u
.shader
.input_signature
);
1786 if (FAILED(hr
= D3DCreateBlob(dxbc_size
, &v
->u
.shader
.bytecode
)))
1789 memcpy(ID3D10Blob_GetBufferPointer(v
->u
.shader
.bytecode
), ptr
, dxbc_size
);
1791 if (FAILED(hr
= get_fx10_shader_resources(v
)))
1794 switch (v
->type
->basetype
)
1796 case D3D10_SVT_VERTEXSHADER
:
1797 hr
= ID3D10Device_CreateVertexShader(device
, ptr
, dxbc_size
, &v
->u
.shader
.shader
.vs
);
1800 case D3D10_SVT_PIXELSHADER
:
1801 hr
= ID3D10Device_CreatePixelShader(device
, ptr
, dxbc_size
, &v
->u
.shader
.shader
.ps
);
1804 case D3D10_SVT_GEOMETRYSHADER
:
1805 if (v
->u
.shader
.stream_output_declaration
)
1807 struct d3d10_effect_so_decl so_decl
;
1809 if (FAILED(hr
= d3d10_effect_parse_stream_output_declaration(v
->u
.shader
.stream_output_declaration
, &so_decl
)))
1811 WARN("Failed to parse stream output declaration, hr %#lx.\n", hr
);
1815 hr
= ID3D10Device_CreateGeometryShaderWithStreamOutput(device
, ptr
, dxbc_size
,
1816 so_decl
.entries
, so_decl
.count
, so_decl
.stride
, &v
->u
.shader
.shader
.gs
);
1818 d3d10_effect_cleanup_so_decl(&so_decl
);
1821 hr
= ID3D10Device_CreateGeometryShader(device
, ptr
, dxbc_size
, &v
->u
.shader
.shader
.gs
);
1825 ERR("This should not happen!\n");
1832 static D3D10_SHADER_VARIABLE_CLASS
d3d10_variable_class(uint32_t c
, BOOL is_column_major
)
1836 case 1: return D3D10_SVC_SCALAR
;
1837 case 2: return D3D10_SVC_VECTOR
;
1838 case 3: if (is_column_major
) return D3D10_SVC_MATRIX_COLUMNS
;
1839 else return D3D10_SVC_MATRIX_ROWS
;
1841 FIXME("Unknown variable class %#x.\n", c
);
1846 static D3D10_SHADER_VARIABLE_TYPE
d3d10_variable_type(uint32_t t
, BOOL is_object
,
1855 case 1: return D3D10_SVT_STRING
;
1856 case 2: return D3D10_SVT_BLEND
;
1857 case 3: return D3D10_SVT_DEPTHSTENCIL
;
1858 case 4: return D3D10_SVT_RASTERIZER
;
1859 case 5: return D3D10_SVT_PIXELSHADER
;
1860 case 6: return D3D10_SVT_VERTEXSHADER
;
1861 case 7: return D3D10_SVT_GEOMETRYSHADER
;
1863 *flags
= D3D10_EOT_FLAG_GS_SO
;
1864 return D3D10_SVT_GEOMETRYSHADER
;
1866 case 9: return D3D10_SVT_TEXTURE
;
1867 case 10: return D3D10_SVT_TEXTURE1D
;
1868 case 11: return D3D10_SVT_TEXTURE1DARRAY
;
1869 case 12: return D3D10_SVT_TEXTURE2D
;
1870 case 13: return D3D10_SVT_TEXTURE2DARRAY
;
1871 case 14: return D3D10_SVT_TEXTURE2DMS
;
1872 case 15: return D3D10_SVT_TEXTURE2DMSARRAY
;
1873 case 16: return D3D10_SVT_TEXTURE3D
;
1874 case 17: return D3D10_SVT_TEXTURECUBE
;
1876 case 19: return D3D10_SVT_RENDERTARGETVIEW
;
1877 case 20: return D3D10_SVT_DEPTHSTENCILVIEW
;
1878 case 21: return D3D10_SVT_SAMPLER
;
1879 case 22: return D3D10_SVT_BUFFER
;
1881 FIXME("Unknown variable type %#x.\n", t
);
1882 return D3D10_SVT_VOID
;
1889 case 1: return D3D10_SVT_FLOAT
;
1890 case 2: return D3D10_SVT_INT
;
1891 case 3: return D3D10_SVT_UINT
;
1892 case 4: return D3D10_SVT_BOOL
;
1894 FIXME("Unknown variable type %#x.\n", t
);
1895 return D3D10_SVT_VOID
;
1900 static HRESULT
parse_fx10_type(const char *data
, size_t data_size
, uint32_t offset
, struct d3d10_effect_type
*t
)
1902 uint32_t typeinfo
, type_flags
, type_kind
;
1906 if (offset
>= data_size
|| !require_space(offset
, 6, sizeof(DWORD
), data_size
))
1908 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1912 ptr
= data
+ offset
;
1913 offset
= read_u32(&ptr
);
1914 TRACE("Type name at offset %#x.\n", offset
);
1916 if (!fx10_copy_string(data
, data_size
, offset
, &t
->name
))
1918 ERR("Failed to copy name.\n");
1919 return E_OUTOFMEMORY
;
1921 TRACE("Type name: %s.\n", debugstr_a(t
->name
));
1923 type_kind
= read_u32(&ptr
);
1924 TRACE("Kind: %u.\n", type_kind
);
1926 t
->element_count
= read_u32(&ptr
);
1927 TRACE("Element count: %u.\n", t
->element_count
);
1929 t
->size_unpacked
= read_u32(&ptr
);
1930 TRACE("Unpacked size: %#x.\n", t
->size_unpacked
);
1932 t
->stride
= read_u32(&ptr
);
1933 TRACE("Stride: %#x.\n", t
->stride
);
1935 t
->size_packed
= read_u32(&ptr
);
1936 TRACE("Packed size %#x.\n", t
->size_packed
);
1941 TRACE("Type is numeric.\n");
1943 if (!require_space(ptr
- data
, 1, sizeof(typeinfo
), data_size
))
1945 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1949 typeinfo
= read_u32(&ptr
);
1950 t
->member_count
= 0;
1951 t
->column_count
= (typeinfo
& D3D10_FX10_TYPE_COLUMN_MASK
) >> D3D10_FX10_TYPE_COLUMN_SHIFT
;
1952 t
->row_count
= (typeinfo
& D3D10_FX10_TYPE_ROW_MASK
) >> D3D10_FX10_TYPE_ROW_SHIFT
;
1953 t
->basetype
= d3d10_variable_type((typeinfo
& D3D10_FX10_TYPE_BASETYPE_MASK
)
1954 >> D3D10_FX10_TYPE_BASETYPE_SHIFT
, FALSE
, &type_flags
);
1955 t
->type_class
= d3d10_variable_class((typeinfo
& D3D10_FX10_TYPE_CLASS_MASK
)
1956 >> D3D10_FX10_TYPE_CLASS_SHIFT
, typeinfo
& D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK
);
1958 TRACE("Type description: %#x.\n", typeinfo
);
1959 TRACE("\tcolumns: %u.\n", t
->column_count
);
1960 TRACE("\trows: %u.\n", t
->row_count
);
1961 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t
->basetype
));
1962 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t
->type_class
));
1963 TRACE("\tunknown bits: %#x.\n", typeinfo
& ~(D3D10_FX10_TYPE_COLUMN_MASK
| D3D10_FX10_TYPE_ROW_MASK
1964 | D3D10_FX10_TYPE_BASETYPE_MASK
| D3D10_FX10_TYPE_CLASS_MASK
| D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK
));
1968 TRACE("Type is an object.\n");
1970 if (!require_space(ptr
- data
, 1, sizeof(typeinfo
), data_size
))
1972 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1976 typeinfo
= read_u32(&ptr
);
1977 t
->member_count
= 0;
1978 t
->column_count
= 0;
1980 t
->basetype
= d3d10_variable_type(typeinfo
, TRUE
, &type_flags
);
1981 t
->type_class
= D3D10_SVC_OBJECT
;
1982 t
->flags
= type_flags
;
1984 TRACE("Type description: %#x.\n", typeinfo
);
1985 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t
->basetype
));
1986 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t
->type_class
));
1987 TRACE("\tflags: %#x.\n", t
->flags
);
1991 TRACE("Type is a structure.\n");
1993 if (!require_space(ptr
- data
, 1, sizeof(t
->member_count
), data_size
))
1995 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1999 t
->member_count
= read_u32(&ptr
);
2000 TRACE("Member count: %u.\n", t
->member_count
);
2002 t
->column_count
= 0;
2005 t
->type_class
= D3D10_SVC_STRUCT
;
2007 if (!(t
->members
= calloc(t
->member_count
, sizeof(*t
->members
))))
2009 ERR("Failed to allocate members memory.\n");
2010 return E_OUTOFMEMORY
;
2013 if (!require_space(ptr
- data
, t
->member_count
, 4 * sizeof(DWORD
), data_size
))
2015 WARN("Invalid member count %#x (data size %#Ix, offset %#x).\n",
2016 t
->member_count
, data_size
, offset
);
2020 for (i
= 0; i
< t
->member_count
; ++i
)
2022 struct d3d10_effect_type_member
*typem
= &t
->members
[i
];
2024 offset
= read_u32(&ptr
);
2025 TRACE("Member name at offset %#x.\n", offset
);
2027 if (!fx10_copy_string(data
, data_size
, offset
, &typem
->name
))
2029 ERR("Failed to copy name.\n");
2030 return E_OUTOFMEMORY
;
2032 TRACE("Member name: %s.\n", debugstr_a(typem
->name
));
2034 offset
= read_u32(&ptr
);
2035 TRACE("Member semantic at offset %#x.\n", offset
);
2037 if (!fx10_copy_string(data
, data_size
, offset
, &typem
->semantic
))
2039 ERR("Failed to copy semantic.\n");
2040 return E_OUTOFMEMORY
;
2042 TRACE("Member semantic: %s.\n", debugstr_a(typem
->semantic
));
2044 typem
->buffer_offset
= read_u32(&ptr
);
2045 TRACE("Member offset in struct: %#x.\n", typem
->buffer_offset
);
2047 offset
= read_u32(&ptr
);
2048 TRACE("Member type info at offset %#x.\n", offset
);
2050 if (!(typem
->type
= get_fx10_type(t
->effect
, data
, data_size
, offset
)))
2052 ERR("Failed to get variable type.\n");
2059 FIXME("Unhandled type kind %#x.\n", type_kind
);
2063 if (t
->element_count
)
2065 TRACE("Elementtype for type at offset: %#lx\n", t
->id
);
2067 /* allocate elementtype - we need only one, because all elements have the same type */
2068 if (!(t
->elementtype
= calloc(1, sizeof(*t
->elementtype
))))
2070 ERR("Failed to allocate members memory.\n");
2071 return E_OUTOFMEMORY
;
2074 /* create a copy of the original type with some minor changes */
2075 t
->elementtype
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
2076 t
->elementtype
->effect
= t
->effect
;
2078 if (!copy_name(t
->name
, &t
->elementtype
->name
))
2080 ERR("Failed to copy name.\n");
2081 return E_OUTOFMEMORY
;
2083 TRACE("\tType name: %s.\n", debugstr_a(t
->elementtype
->name
));
2085 t
->elementtype
->element_count
= 0;
2086 TRACE("\tElement count: %u.\n", t
->elementtype
->element_count
);
2089 * Not sure if this calculation is 100% correct, but a test
2090 * shows that these values work.
2092 t
->elementtype
->size_unpacked
= t
->size_packed
/ t
->element_count
;
2093 TRACE("\tUnpacked size: %#x.\n", t
->elementtype
->size_unpacked
);
2095 t
->elementtype
->stride
= t
->stride
;
2096 TRACE("\tStride: %#x.\n", t
->elementtype
->stride
);
2098 t
->elementtype
->size_packed
= t
->size_packed
/ t
->element_count
;
2099 TRACE("\tPacked size: %#x.\n", t
->elementtype
->size_packed
);
2101 t
->elementtype
->member_count
= t
->member_count
;
2102 TRACE("\tMember count: %u.\n", t
->elementtype
->member_count
);
2104 t
->elementtype
->column_count
= t
->column_count
;
2105 TRACE("\tColumns: %u.\n", t
->elementtype
->column_count
);
2107 t
->elementtype
->row_count
= t
->row_count
;
2108 TRACE("\tRows: %u.\n", t
->elementtype
->row_count
);
2110 t
->elementtype
->basetype
= t
->basetype
;
2111 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(t
->elementtype
->basetype
));
2113 t
->elementtype
->type_class
= t
->type_class
;
2114 TRACE("\tClass: %s.\n", debug_d3d10_shader_variable_class(t
->elementtype
->type_class
));
2116 t
->elementtype
->members
= t
->members
;
2122 static struct d3d10_effect_type
*get_fx10_type(struct d3d10_effect
*effect
, const char *data
,
2123 size_t data_size
, uint32_t offset
)
2125 struct d3d10_effect_type
*type
;
2126 struct wine_rb_entry
*entry
;
2129 entry
= wine_rb_get(&effect
->types
, &offset
);
2132 TRACE("Returning existing type.\n");
2133 return WINE_RB_ENTRY_VALUE(entry
, struct d3d10_effect_type
, entry
);
2136 if (!(type
= calloc(1, sizeof(*type
))))
2138 ERR("Failed to allocate type memory.\n");
2142 type
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
2144 type
->effect
= effect
;
2145 if (FAILED(hr
= parse_fx10_type(data
, data_size
, offset
, type
)))
2147 ERR("Failed to parse type info, hr %#lx.\n", hr
);
2152 if (wine_rb_put(&effect
->types
, &offset
, &type
->entry
) == -1)
2154 ERR("Failed to insert type entry.\n");
2162 static void set_variable_vtbl(struct d3d10_effect_variable
*v
)
2164 const ID3D10EffectVariableVtbl
**vtbl
= &v
->ID3D10EffectVariable_iface
.lpVtbl
;
2166 switch (v
->type
->type_class
)
2168 case D3D10_SVC_SCALAR
:
2169 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_scalar_variable_vtbl
;
2172 case D3D10_SVC_VECTOR
:
2173 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_vector_variable_vtbl
;
2176 case D3D10_SVC_MATRIX_ROWS
:
2177 case D3D10_SVC_MATRIX_COLUMNS
:
2178 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_matrix_variable_vtbl
;
2181 case D3D10_SVC_STRUCT
:
2182 *vtbl
= &d3d10_effect_variable_vtbl
;
2185 case D3D10_SVC_OBJECT
:
2186 switch(v
->type
->basetype
)
2188 case D3D10_SVT_STRING
:
2189 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_string_variable_vtbl
;
2192 case D3D10_SVT_TEXTURE
:
2193 case D3D10_SVT_TEXTURE1D
:
2194 case D3D10_SVT_TEXTURE1DARRAY
:
2195 case D3D10_SVT_TEXTURE2D
:
2196 case D3D10_SVT_TEXTURE2DARRAY
:
2197 case D3D10_SVT_TEXTURE2DMS
:
2198 case D3D10_SVT_TEXTURE2DMSARRAY
:
2199 case D3D10_SVT_TEXTURE3D
:
2200 case D3D10_SVT_TEXTURECUBE
:
2201 case D3D10_SVT_BUFFER
: /* Either resource or constant buffer. */
2202 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_resource_variable_vtbl
;
2205 case D3D10_SVT_RENDERTARGETVIEW
:
2206 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_render_target_view_variable_vtbl
;
2209 case D3D10_SVT_DEPTHSTENCILVIEW
:
2210 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_view_variable_vtbl
;
2213 case D3D10_SVT_DEPTHSTENCIL
:
2214 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_variable_vtbl
;
2217 case D3D10_SVT_VERTEXSHADER
:
2218 case D3D10_SVT_GEOMETRYSHADER
:
2219 case D3D10_SVT_PIXELSHADER
:
2220 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
;
2223 case D3D10_SVT_BLEND
:
2224 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_blend_variable_vtbl
;
2227 case D3D10_SVT_RASTERIZER
:
2228 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_rasterizer_variable_vtbl
;
2231 case D3D10_SVT_SAMPLER
:
2232 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_sampler_variable_vtbl
;
2236 FIXME("Unhandled basetype %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
2237 *vtbl
= &d3d10_effect_variable_vtbl
;
2243 FIXME("Unhandled type class %s.\n", debug_d3d10_shader_variable_class(v
->type
->type_class
));
2244 *vtbl
= &d3d10_effect_variable_vtbl
;
2249 static HRESULT
copy_variableinfo_from_type(struct d3d10_effect_variable
*v
)
2254 if (v
->type
->member_count
)
2256 if (!(v
->members
= calloc(v
->type
->member_count
, sizeof(*v
->members
))))
2258 ERR("Failed to allocate members memory.\n");
2259 return E_OUTOFMEMORY
;
2262 for (i
= 0; i
< v
->type
->member_count
; ++i
)
2264 struct d3d10_effect_variable
*var
= &v
->members
[i
];
2265 struct d3d10_effect_type_member
*typem
= &v
->type
->members
[i
];
2267 var
->buffer
= v
->buffer
;
2268 var
->effect
= v
->effect
;
2269 var
->type
= typem
->type
;
2270 set_variable_vtbl(var
);
2272 if (!copy_name(typem
->name
, &var
->name
))
2274 ERR("Failed to copy name.\n");
2275 return E_OUTOFMEMORY
;
2277 TRACE("Variable name: %s.\n", debugstr_a(var
->name
));
2279 if (!copy_name(typem
->semantic
, &var
->semantic
))
2281 ERR("Failed to copy name.\n");
2282 return E_OUTOFMEMORY
;
2284 TRACE("Variable semantic: %s.\n", debugstr_a(var
->semantic
));
2286 var
->buffer_offset
= v
->buffer_offset
+ typem
->buffer_offset
;
2287 TRACE("Variable buffer offset: %u.\n", var
->buffer_offset
);
2289 hr
= copy_variableinfo_from_type(var
);
2290 if (FAILED(hr
)) return hr
;
2294 if (v
->type
->element_count
)
2296 unsigned int bufferoffset
= v
->buffer_offset
;
2298 if (!(v
->elements
= calloc(v
->type
->element_count
, sizeof(*v
->elements
))))
2300 ERR("Failed to allocate elements memory.\n");
2301 return E_OUTOFMEMORY
;
2304 for (i
= 0; i
< v
->type
->element_count
; ++i
)
2306 struct d3d10_effect_variable
*var
= &v
->elements
[i
];
2308 var
->buffer
= v
->buffer
;
2309 var
->effect
= v
->effect
;
2310 var
->type
= v
->type
->elementtype
;
2311 set_variable_vtbl(var
);
2313 if (!copy_name(v
->name
, &var
->name
))
2315 ERR("Failed to copy name.\n");
2316 return E_OUTOFMEMORY
;
2318 TRACE("Variable name: %s.\n", debugstr_a(var
->name
));
2320 if (!copy_name(v
->semantic
, &var
->semantic
))
2322 ERR("Failed to copy name.\n");
2323 return E_OUTOFMEMORY
;
2325 TRACE("Variable semantic: %s.\n", debugstr_a(var
->semantic
));
2329 bufferoffset
+= v
->type
->stride
;
2331 var
->buffer_offset
= bufferoffset
;
2332 TRACE("Variable buffer offset: %u.\n", var
->buffer_offset
);
2334 hr
= copy_variableinfo_from_type(var
);
2335 if (FAILED(hr
)) return hr
;
2342 static HRESULT
parse_fx10_variable_head(const char *data
, size_t data_size
,
2343 const char **ptr
, struct d3d10_effect_variable
*v
)
2347 offset
= read_u32(ptr
);
2348 TRACE("Variable name at offset %#x.\n", offset
);
2350 if (!fx10_copy_string(data
, data_size
, offset
, &v
->name
))
2352 ERR("Failed to copy name.\n");
2353 return E_OUTOFMEMORY
;
2355 TRACE("Variable name: %s.\n", debugstr_a(v
->name
));
2357 offset
= read_u32(ptr
);
2358 TRACE("Variable type info at offset %#x.\n", offset
);
2360 if (!(v
->type
= get_fx10_type(v
->effect
, data
, data_size
, offset
)))
2362 ERR("Failed to get variable type.\n");
2365 set_variable_vtbl(v
);
2367 v
->explicit_bind_point
= ~0u;
2369 if (v
->effect
->flags
& D3D10_EFFECT_IS_POOL
)
2370 v
->flag
|= D3D10_EFFECT_VARIABLE_POOLED
;
2372 return copy_variableinfo_from_type(v
);
2375 static HRESULT
parse_fx10_annotation(const char *data
, size_t data_size
,
2376 const char **ptr
, struct d3d10_effect_variable
*a
)
2381 if (FAILED(hr
= parse_fx10_variable_head(data
, data_size
, ptr
, a
)))
2384 offset
= read_u32(ptr
);
2385 TRACE("Annotation value is at offset %#x.\n", offset
);
2387 switch (a
->type
->basetype
)
2389 case D3D10_SVT_STRING
:
2390 if (!fx10_copy_string(data
, data_size
, offset
, (char **)&a
->u
.buffer
.local_buffer
))
2392 ERR("Failed to copy name.\n");
2393 return E_OUTOFMEMORY
;
2398 FIXME("Unhandled object type %#x.\n", a
->type
->basetype
);
2401 /* mark the variable as annotation */
2402 a
->flag
|= D3D10_EFFECT_VARIABLE_ANNOTATION
;
2407 static HRESULT
parse_fx10_annotations(const char *data
, size_t data_size
, const char **ptr
,
2408 struct d3d10_effect
*effect
, struct d3d10_effect_annotations
*annotations
)
2413 if (!(annotations
->elements
= calloc(annotations
->count
, sizeof(*annotations
->elements
))))
2415 ERR("Failed to allocate annotations memory.\n");
2416 return E_OUTOFMEMORY
;
2419 for (i
= 0; i
< annotations
->count
; ++i
)
2421 struct d3d10_effect_variable
*a
= &annotations
->elements
[i
];
2424 a
->buffer
= &null_local_buffer
;
2426 if (FAILED(hr
= parse_fx10_annotation(data
, data_size
, ptr
, a
)))
2433 static HRESULT
parse_fx10_anonymous_shader(struct d3d10_effect
*e
, D3D_SHADER_VARIABLE_TYPE basetype
,
2434 struct d3d10_effect_anonymous_shader
*s
)
2436 struct d3d10_effect_variable
*v
= &s
->shader
;
2437 struct d3d10_effect_type
*t
= &s
->type
;
2438 const char *name
= NULL
;
2442 case D3D10_SVT_VERTEXSHADER
:
2443 name
= "vertexshader";
2446 case D3D10_SVT_PIXELSHADER
:
2447 name
= "pixelshader";
2450 case D3D10_SVT_GEOMETRYSHADER
:
2451 name
= "geometryshader";
2455 WARN("Unhandled shader type %#x.\n", basetype
);
2458 t
->basetype
= basetype
;
2460 if (!copy_name(name
, &t
->name
))
2462 ERR("Failed to copy name.\n");
2463 return E_OUTOFMEMORY
;
2465 TRACE("Type name: %s.\n", debugstr_a(t
->name
));
2467 t
->type_class
= D3D10_SVC_OBJECT
;
2469 t
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
2473 v
->u
.shader
.isinline
= 1;
2474 set_variable_vtbl(v
);
2476 if (!copy_name("$Anonymous", &v
->name
))
2478 ERR("Failed to copy semantic.\n");
2479 return E_OUTOFMEMORY
;
2481 TRACE("Variable name: %s.\n", debugstr_a(v
->name
));
2486 static const struct d3d10_effect_state_storage_info
*get_storage_info(D3D_SHADER_VARIABLE_TYPE id
)
2490 for (i
= 0; i
< ARRAY_SIZE(d3d10_effect_state_storage_info
); ++i
)
2492 if (d3d10_effect_state_storage_info
[i
].id
== id
)
2493 return &d3d10_effect_state_storage_info
[i
];
2499 static BOOL
read_value_list(const char *data
, size_t data_size
, uint32_t offset
,
2500 D3D_SHADER_VARIABLE_TYPE out_type
, unsigned int out_base
, unsigned int out_size
,
2503 uint32_t t
, value
, count
, type_flags
;
2504 D3D_SHADER_VARIABLE_TYPE in_type
;
2508 if (offset
>= data_size
|| !require_space(offset
, 1, sizeof(count
), data_size
))
2510 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
2514 ptr
= data
+ offset
;
2515 count
= read_u32(&ptr
);
2516 if (count
!= out_size
)
2519 if (!require_space(ptr
- data
, count
, 2 * sizeof(DWORD
), data_size
))
2521 WARN("Invalid value count %#x (offset %#x, data size %#Ix).\n", count
, offset
, data_size
);
2525 TRACE("%u values:\n", count
);
2526 for (i
= 0; i
< count
; ++i
)
2528 unsigned int out_idx
= out_base
* out_size
+ i
;
2531 value
= read_u32(&ptr
);
2533 in_type
= d3d10_variable_type(t
, FALSE
, &type_flags
);
2534 TRACE("\t%s: %#x.\n", debug_d3d10_shader_variable_type(in_type
), value
);
2538 case D3D10_SVT_FLOAT
:
2540 case D3D10_SVT_UINT
:
2541 case D3D10_SVT_UINT8
:
2542 case D3D10_SVT_BOOL
:
2543 if (!d3d10_effect_read_numeric_value(value
, in_type
, out_type
, out_data
, out_idx
))
2547 case D3D10_SVT_VERTEXSHADER
:
2548 *(void **)out_data
= &anonymous_vs
;
2551 case D3D10_SVT_PIXELSHADER
:
2552 *(void **)out_data
= &anonymous_ps
;
2555 case D3D10_SVT_GEOMETRYSHADER
:
2556 *(void **)out_data
= &anonymous_gs
;
2559 case D3D10_SVT_TEXTURE
:
2560 *(void **)out_data
= &null_shader_resource_variable
;
2563 case D3D10_SVT_DEPTHSTENCIL
:
2564 *(void **)out_data
= &null_depth_stencil_variable
;
2567 case D3D10_SVT_BLEND
:
2568 *(void **)out_data
= &null_blend_variable
;
2572 FIXME("Unhandled out_type %#x.\n", out_type
);
2580 static BOOL
is_object_property(const struct d3d10_effect_state_property_info
*property_info
)
2582 switch (property_info
->type
)
2584 case D3D10_SVT_RASTERIZER
:
2585 case D3D10_SVT_DEPTHSTENCIL
:
2586 case D3D10_SVT_BLEND
:
2587 case D3D10_SVT_RENDERTARGETVIEW
:
2588 case D3D10_SVT_DEPTHSTENCILVIEW
:
2589 case D3D10_SVT_VERTEXSHADER
:
2590 case D3D10_SVT_PIXELSHADER
:
2591 case D3D10_SVT_GEOMETRYSHADER
:
2592 case D3D10_SVT_TEXTURE
:
2599 static BOOL
is_object_property_type_matching(const struct d3d10_effect_state_property_info
*property_info
,
2600 const struct d3d10_effect_variable
*v
)
2602 if (property_info
->type
== v
->type
->basetype
) return TRUE
;
2604 switch (v
->type
->basetype
)
2606 case D3D10_SVT_TEXTURE1D
:
2607 case D3D10_SVT_TEXTURE1DARRAY
:
2608 case D3D10_SVT_TEXTURE2D
:
2609 case D3D10_SVT_TEXTURE2DARRAY
:
2610 case D3D10_SVT_TEXTURE2DMS
:
2611 case D3D10_SVT_TEXTURE2DMSARRAY
:
2612 case D3D10_SVT_TEXTURE3D
:
2613 case D3D10_SVT_TEXTURECUBE
:
2614 if (property_info
->type
== D3D10_SVT_TEXTURE
) return TRUE
;
2621 static HRESULT
parse_fx10_preshader_instr(struct d3d10_preshader_parse_context
*context
,
2622 unsigned int *offset
, const char **ptr
, unsigned int data_size
)
2624 const struct preshader_op_info
*op_info
;
2625 unsigned int i
, param_count
, size
;
2626 struct preshader_instr ins
;
2627 uint32_t input_count
;
2629 if (!require_space(*offset
, 2, sizeof(uint32_t), data_size
))
2631 WARN("Malformed FXLC table, size %u.\n", data_size
);
2635 *(uint32_t *)&ins
= read_u32(ptr
);
2636 input_count
= read_u32(ptr
);
2637 *offset
+= 2 * sizeof(uint32_t);
2639 if (!(op_info
= d3d10_effect_get_op_info(ins
.opcode
)))
2641 FIXME("Unrecognized opcode %#x.\n", ins
.opcode
);
2645 TRACE("Opcode %#x (%s) (%u,%u), input count %u.\n", ins
.opcode
, op_info
->name
,
2646 ins
.comp_count
, ins
.scalar
, input_count
);
2648 /* Inputs + one output */
2649 param_count
= input_count
+ 1;
2651 if (!require_space(*offset
, 3 * param_count
, sizeof(uint32_t), data_size
))
2653 WARN("Malformed FXLC table, opcode %#x.\n", ins
.opcode
);
2656 *offset
+= 3 * param_count
* sizeof(uint32_t);
2658 for (i
= 0; i
< param_count
; ++i
)
2660 uint32_t flags
, regt
, param_offset
;
2662 flags
= read_u32(ptr
);
2665 FIXME("Argument flags are not supported %#x.\n", flags
);
2666 return E_UNEXPECTED
;
2669 regt
= read_u32(ptr
);
2670 param_offset
= read_u32(ptr
);
2674 case D3D10_REG_TABLE_CONSTANTS
:
2675 case D3D10_REG_TABLE_CB
:
2676 case D3D10_REG_TABLE_RESULT
:
2677 case D3D10_REG_TABLE_TEMP
:
2678 size
= param_offset
+ (ins
.scalar
&& i
== 0 ? 1 : ins
.comp_count
);
2679 context
->table_sizes
[regt
] = max(context
->table_sizes
[regt
], size
);
2682 FIXME("Unexpected register table index %u.\n", regt
);
2690 static HRESULT
parse_fx10_fxlc(void *ctx
, const char *data
, unsigned int data_size
)
2692 struct d3d10_preshader_parse_context
*context
= ctx
;
2693 struct d3d10_effect_preshader
*p
= context
->preshader
;
2694 unsigned int i
, offset
= 4;
2699 if (data_size
% sizeof(uint32_t))
2701 WARN("FXLC size misaligned %u.\n", data_size
);
2705 if (FAILED(hr
= D3DCreateBlob(data_size
, &p
->code
)))
2707 memcpy(ID3D10Blob_GetBufferPointer(p
->code
), data
, data_size
);
2710 ins_count
= read_u32(&ptr
);
2711 TRACE("%u instructions.\n", ins_count
);
2713 for (i
= 0; i
< ins_count
; ++i
)
2715 if (FAILED(hr
= parse_fx10_preshader_instr(context
, &offset
, &ptr
, data_size
)))
2717 WARN("Failed to parse instruction %u.\n", i
);
2722 if (FAILED(hr
= d3d10_reg_table_allocate(&p
->reg_tables
[D3D10_REG_TABLE_RESULT
],
2723 context
->table_sizes
[D3D10_REG_TABLE_RESULT
]))) return hr
;
2724 if (FAILED(hr
= d3d10_reg_table_allocate(&p
->reg_tables
[D3D10_REG_TABLE_TEMP
],
2725 context
->table_sizes
[D3D10_REG_TABLE_TEMP
]))) return hr
;
2730 static HRESULT
parse_fx10_cli4(void *ctx
, const char *data
, unsigned int data_size
)
2732 struct d3d10_preshader_parse_context
*context
= ctx
;
2733 struct d3d10_effect_preshader
*p
= context
->preshader
;
2734 struct d3d10_reg_table
*table
= &p
->reg_tables
[D3D10_REG_TABLE_CONSTANTS
];
2735 const char *ptr
= data
;
2739 if (data_size
< sizeof(DWORD
))
2741 WARN("Invalid CLI4 chunk size %u.\n", data_size
);
2745 count
= read_u32(&ptr
);
2747 TRACE("%u literal constants.\n", count
);
2749 if (!require_space(4, count
, sizeof(float), data_size
))
2751 WARN("Invalid constant table size %u.\n", data_size
);
2755 if (FAILED(hr
= d3d10_reg_table_allocate(table
, count
)))
2758 memcpy(table
->f
, ptr
, table
->count
* sizeof(*table
->f
));
2763 static HRESULT
parse_fx10_ctab(void *ctx
, const char *data
, unsigned int data_size
)
2765 struct d3d10_preshader_parse_context
*context
= ctx
;
2766 struct d3d10_effect_preshader
*p
= context
->preshader
;
2773 uint32_t constantinfo
;
2777 struct ctab_const_info
2781 WORD register_index
;
2782 WORD register_count
;
2785 uint32_t default_value
;
2787 unsigned int i
, cb_reg_count
= 0;
2788 const char *ptr
= data
;
2793 if (data_size
< sizeof(header
))
2795 WARN("Invalid constant table size %u.\n", data_size
);
2799 header
.size
= read_u32(&ptr
);
2800 header
.creator
= read_u32(&ptr
);
2801 header
.version
= read_u32(&ptr
);
2802 header
.constants
= read_u32(&ptr
);
2803 header
.constantinfo
= read_u32(&ptr
);
2804 header
.flags
= read_u32(&ptr
);
2805 header
.target
= read_u32(&ptr
);
2807 if (!require_space(header
.constantinfo
, header
.constants
, sizeof(*info
), data_size
))
2809 WARN("Invalid constant info section offset %#x.\n", header
.constantinfo
);
2813 p
->vars_count
= header
.constants
;
2815 TRACE("Variable count %u.\n", p
->vars_count
);
2817 if (!(p
->vars
= calloc(p
->vars_count
, sizeof(*p
->vars
))))
2818 return E_OUTOFMEMORY
;
2820 info
= (struct ctab_const_info
*)(data
+ header
.constantinfo
);
2821 for (i
= 0; i
< p
->vars_count
; ++i
, ++info
)
2823 if (!fx10_get_string(data
, data_size
, info
->name
, &name
, &name_len
))
2826 if (!(p
->vars
[i
].v
= d3d10_effect_get_variable_by_name(context
->effect
, name
)))
2828 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
2832 /* 4 components per register */
2833 p
->vars
[i
].offset
= info
->register_index
* 4;
2834 p
->vars
[i
].length
= info
->register_count
* 4;
2836 cb_reg_count
= max(cb_reg_count
, info
->register_index
+ info
->register_count
);
2839 /* Allocate contiguous "constant buffer" for all referenced variables. */
2840 if (FAILED(hr
= d3d10_reg_table_allocate(&p
->reg_tables
[D3D10_REG_TABLE_CB
], cb_reg_count
* 4)))
2842 WARN("Failed to allocate variables buffer.\n");
2849 static HRESULT
fxlvm_chunk_handler(const struct vkd3d_shader_dxbc_section_desc
*section
,
2850 struct d3d10_preshader_parse_context
*ctx
)
2852 const char *data
= section
->data
.code
;
2853 size_t data_size
= section
->data
.size
;
2854 uint32_t tag
= section
->tag
;
2856 TRACE("Chunk tag: %s, size: %Iu.\n", debugstr_fourcc(tag
), data_size
);
2861 return parse_fx10_fxlc(ctx
, data
, data_size
);
2864 return parse_fx10_cli4(ctx
, data
, data_size
);
2867 return parse_fx10_ctab(ctx
, data
, data_size
);
2870 FIXME("Unhandled chunk %s.\n", debugstr_fourcc(tag
));
2875 static HRESULT
parse_fx10_preshader(const char *data
, size_t data_size
,
2876 struct d3d10_effect
*effect
, struct d3d10_effect_preshader
*preshader
)
2878 const struct vkd3d_shader_code dxbc
= {.code
= data
, .size
= data_size
};
2879 const struct vkd3d_shader_dxbc_section_desc
*section
;
2880 struct d3d10_preshader_parse_context context
;
2881 struct vkd3d_shader_dxbc_desc dxbc_desc
;
2886 memset(preshader
, 0, sizeof(*preshader
));
2887 memset(&context
, 0, sizeof(context
));
2888 context
.preshader
= preshader
;
2889 context
.effect
= effect
;
2891 if ((ret
= vkd3d_shader_parse_dxbc(&dxbc
, 0, &dxbc_desc
, NULL
)) < 0)
2893 WARN("Failed to parse DXBC, ret %d.\n", ret
);
2897 for (i
= 0; i
< dxbc_desc
.section_count
; ++i
)
2899 section
= &dxbc_desc
.sections
[i
];
2900 if (FAILED(hr
= fxlvm_chunk_handler(section
, &context
)))
2904 vkd3d_shader_free_dxbc(&dxbc_desc
);
2906 /* Constant buffer and literal constants are preallocated, validate here that expression
2907 has no invalid accesses for those. */
2909 if (context
.table_sizes
[D3D10_REG_TABLE_CONSTANTS
] >
2910 preshader
->reg_tables
[D3D10_REG_TABLE_CONSTANTS
].count
)
2912 WARN("Expression references out of bounds literal constant.\n");
2916 if (context
.table_sizes
[D3D10_REG_TABLE_CB
] > preshader
->reg_tables
[D3D10_REG_TABLE_CB
].count
)
2918 WARN("Expression references out of bounds variable.\n");
2925 static HRESULT
d3d10_effect_add_prop_dependency(struct d3d10_effect_prop_dependencies
*d
,
2926 const struct d3d10_effect_prop_dependency
*dep
)
2928 if (!d3d_array_reserve((void **)&d
->entries
, &d
->capacity
, d
->count
+ 1, sizeof(*d
->entries
)))
2929 return E_OUTOFMEMORY
;
2931 d
->entries
[d
->count
++] = *dep
;
2936 static HRESULT
parse_fx10_property_assignment(const char *data
, size_t data_size
,
2937 const char **ptr
, enum d3d10_effect_container_type container_type
,
2938 struct d3d10_effect
*effect
, void *container
, struct d3d10_effect_prop_dependencies
*d
)
2940 uint32_t id
, idx
, variable_idx
, operation
, value_offset
, sodecl_offset
;
2941 const struct d3d10_effect_state_property_info
*property_info
;
2942 struct d3d10_effect_prop_dependency dep
;
2943 struct d3d10_effect_variable
*variable
;
2944 uint32_t code_offset
, blob_size
;
2945 const char *data_ptr
, *name
;
2946 unsigned int *dst_index
;
2952 idx
= read_u32(ptr
);
2953 operation
= read_u32(ptr
);
2954 value_offset
= read_u32(ptr
);
2956 if (id
>= ARRAY_SIZE(property_infos
))
2958 FIXME("Unknown property id %#x.\n", id
);
2961 property_info
= &property_infos
[id
];
2963 TRACE("Property %s[%#x] = value list @ offset %#x.\n", property_info
->name
, idx
, value_offset
);
2965 if (property_info
->container_type
!= container_type
)
2967 ERR("Invalid container type %#x for property %#x.\n", container_type
, id
);
2971 if (idx
>= property_info
->count
)
2973 ERR("Invalid index %#x for property %#x.\n", idx
, id
);
2977 if (property_info
->offset
== ~0u)
2979 ERR("Unsupported property %#x.\n", id
);
2983 dst
= (char *)container
+ property_info
->offset
;
2984 dst_index
= (unsigned int *)((char *)container
+ property_info
->index_offset
);
2988 case D3D10_EOO_CONST
:
2990 /* Constant values output directly to backing store. */
2991 if (!read_value_list(data
, data_size
, value_offset
, property_info
->type
, idx
,
2992 property_info
->size
, dst
))
2994 ERR("Failed to read values for property %#x.\n", id
);
3002 if (!fx10_get_string(data
, data_size
, value_offset
, &name
, &name_len
))
3004 WARN("Failed to get variable name.\n");
3007 TRACE("Variable name %s.\n", debugstr_a(name
));
3009 if (!(variable
= d3d10_effect_get_variable_by_name(effect
, name
)))
3011 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
3015 if (is_object_property(property_info
))
3017 if (variable
->type
->element_count
)
3019 WARN("Unexpected array variable value %s.\n", debugstr_a(name
));
3023 if (!is_object_property_type_matching(property_info
, variable
))
3025 WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
3026 variable
->type
->basetype
, property_info
->type
);
3030 ((void **)dst
)[idx
] = variable
;
3034 if (property_info
->size
* sizeof(float) > variable
->type
->size_unpacked
)
3036 WARN("Mismatching variable size %u, property size %u.\n",
3037 variable
->type
->size_unpacked
, property_info
->size
);
3043 dep
.operation
= operation
;
3044 dep
.var
.v
= variable
;
3047 return d3d10_effect_add_prop_dependency(d
, &dep
);
3052 case D3D10_EOO_CONST_INDEX
:
3054 /* Array variable, constant index. */
3055 if (value_offset
>= data_size
|| !require_space(value_offset
, 2, sizeof(DWORD
), data_size
))
3057 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
3060 data_ptr
= data
+ value_offset
;
3061 value_offset
= read_u32(&data_ptr
);
3062 variable_idx
= read_u32(&data_ptr
);
3064 if (!fx10_get_string(data
, data_size
, value_offset
, &name
, &name_len
))
3066 WARN("Failed to get variable name.\n");
3070 TRACE("Variable name %s[%s%u].\n", debugstr_a(name
), is_object_property(property_info
) ?
3071 "" : "offset ", variable_idx
);
3073 if (!(variable
= d3d10_effect_get_variable_by_name(effect
, name
)))
3075 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
3079 if (is_object_property(property_info
))
3081 if (!variable
->type
->element_count
|| variable_idx
>= variable
->type
->element_count
)
3083 WARN("Invalid array size %u.\n", variable
->type
->element_count
);
3087 if (!is_object_property_type_matching(property_info
, variable
))
3089 WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
3090 variable
->type
->basetype
, property_info
->type
);
3094 /* Shader variables are special, they are referenced via array, with index stored separately. */
3095 switch (property_info
->type
)
3097 case D3D10_SVT_VERTEXSHADER
:
3098 case D3D10_SVT_PIXELSHADER
:
3099 case D3D10_SVT_GEOMETRYSHADER
:
3100 ((void **)dst
)[idx
] = variable
;
3101 *dst_index
= variable_idx
;
3104 ((void **)dst
)[idx
] = &variable
->elements
[variable_idx
];
3109 unsigned int offset
= variable_idx
* sizeof(float);
3111 if (offset
>= variable
->type
->size_unpacked
||
3112 variable
->type
->size_unpacked
- offset
< property_info
->size
* sizeof(float))
3114 WARN("Invalid numeric variable data offset %u.\n", variable_idx
);
3120 dep
.operation
= operation
;
3121 dep
.var
.v
= variable
;
3122 dep
.var
.offset
= offset
;
3124 return d3d10_effect_add_prop_dependency(d
, &dep
);
3129 case D3D10_EOO_INDEX_EXPRESSION
:
3131 /* Variable, and an expression for its index. */
3132 if (value_offset
>= data_size
|| !require_space(value_offset
, 2, sizeof(DWORD
), data_size
))
3134 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
3138 data_ptr
= data
+ value_offset
;
3139 value_offset
= read_u32(&data_ptr
);
3140 code_offset
= read_u32(&data_ptr
);
3142 if (!fx10_get_string(data
, data_size
, value_offset
, &name
, &name_len
))
3144 WARN("Failed to get variable name.\n");
3148 TRACE("Variable name %s[<expr>].\n", debugstr_a(name
));
3150 if (!(variable
= d3d10_effect_get_variable_by_name(effect
, name
)))
3152 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
3156 if (!variable
->type
->element_count
)
3158 WARN("Expected array variable.\n");
3162 if (!is_object_property(property_info
))
3164 WARN("Expected object type property used with indexed expression.\n");
3168 if (code_offset
>= data_size
|| !require_space(code_offset
, 1, sizeof(DWORD
), data_size
))
3170 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
3174 data_ptr
= data
+ code_offset
;
3175 blob_size
= read_u32(&data_ptr
);
3177 if (!require_space(code_offset
, 1, sizeof(uint32_t) + blob_size
, data_size
))
3179 WARN("Invalid offset %#x (data size %#Ix).\n", code_offset
, data_size
);
3185 dep
.operation
= operation
;
3186 dep
.index_expr
.v
= variable
;
3187 if (FAILED(hr
= parse_fx10_preshader(data_ptr
, blob_size
, effect
, &dep
.index_expr
.index
)))
3189 WARN("Failed to parse preshader, hr %#lx.\n", hr
);
3193 return d3d10_effect_add_prop_dependency(d
, &dep
);
3195 case D3D10_EOO_VALUE_EXPRESSION
:
3197 if (value_offset
>= data_size
|| !require_space(value_offset
, 1, sizeof(uint32_t), data_size
))
3199 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
3203 data_ptr
= data
+ value_offset
;
3204 blob_size
= read_u32(&data_ptr
);
3206 if (!require_space(value_offset
, 1, sizeof(uint32_t) + blob_size
, data_size
))
3208 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
3214 dep
.operation
= operation
;
3215 if (FAILED(hr
= parse_fx10_preshader(data_ptr
, blob_size
, effect
, &dep
.value_expr
.value
)))
3217 WARN("Failed to parse preshader, hr %#lx.\n", hr
);
3221 return d3d10_effect_add_prop_dependency(d
, &dep
);
3223 case D3D10_EOO_ANONYMOUS_SHADER
:
3225 /* Anonymous shader */
3226 if (effect
->anonymous_shader_current
>= effect
->anonymous_shader_count
)
3228 ERR("Anonymous shader count is wrong!\n");
3232 if (value_offset
>= data_size
|| !require_space(value_offset
, 2, sizeof(DWORD
), data_size
))
3234 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
3237 data_ptr
= data
+ value_offset
;
3238 value_offset
= read_u32(&data_ptr
);
3239 sodecl_offset
= read_u32(&data_ptr
);
3241 TRACE("Effect object starts at offset %#x.\n", value_offset
);
3243 if (FAILED(hr
= parse_fx10_anonymous_shader(effect
, property_info
->type
,
3244 &effect
->anonymous_shaders
[effect
->anonymous_shader_current
])))
3247 variable
= &effect
->anonymous_shaders
[effect
->anonymous_shader_current
].shader
;
3248 ++effect
->anonymous_shader_current
;
3252 TRACE("Anonymous shader stream output declaration at offset %#x.\n", sodecl_offset
);
3253 if (!fx10_copy_string(data
, data_size
, sodecl_offset
,
3254 &variable
->u
.shader
.stream_output_declaration
))
3256 ERR("Failed to copy stream output declaration.\n");
3260 TRACE("Stream output declaration: %s.\n", debugstr_a(variable
->u
.shader
.stream_output_declaration
));
3263 switch (property_info
->type
)
3265 case D3D10_SVT_VERTEXSHADER
:
3266 case D3D10_SVT_PIXELSHADER
:
3267 case D3D10_SVT_GEOMETRYSHADER
:
3268 if (FAILED(hr
= parse_fx10_shader(data
, data_size
, value_offset
, variable
)))
3273 WARN("Unexpected shader type %#x.\n", property_info
->type
);
3277 ((void **)dst
)[idx
] = variable
;
3282 FIXME("Unhandled operation %#x.\n", operation
);
3289 static HRESULT
parse_fx10_pass(const char *data
, size_t data_size
,
3290 const char **ptr
, struct d3d10_effect_pass
*p
)
3292 uint32_t offset
, object_count
;
3296 offset
= read_u32(ptr
);
3297 TRACE("Pass name at offset %#x.\n", offset
);
3299 if (!fx10_copy_string(data
, data_size
, offset
, &p
->name
))
3301 ERR("Failed to copy name.\n");
3302 return E_OUTOFMEMORY
;
3304 TRACE("Pass name: %s.\n", debugstr_a(p
->name
));
3306 object_count
= read_u32(ptr
);
3307 TRACE("Pass has %u effect objects.\n", object_count
);
3309 p
->annotations
.count
= read_u32(ptr
);
3310 TRACE("Pass has %u annotations.\n", p
->annotations
.count
);
3312 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, p
->technique
->effect
,
3315 ERR("Failed to parse pass annotations, hr %#lx.\n", hr
);
3319 p
->vs
.shader
= &null_shader_variable
;
3320 p
->ps
.shader
= &null_shader_variable
;
3321 p
->gs
.shader
= &null_shader_variable
;
3323 for (i
= 0; i
< object_count
; ++i
)
3325 if (FAILED(hr
= parse_fx10_property_assignment(data
, data_size
, ptr
,
3326 D3D10_C_PASS
, p
->technique
->effect
, p
, &p
->dependencies
)))
3328 WARN("Failed to parse pass assignment %u, hr %#lx.\n", i
, hr
);
3336 static HRESULT
parse_fx10_technique(const char *data
, size_t data_size
,
3337 const char **ptr
, struct d3d10_effect_technique
*t
)
3343 offset
= read_u32(ptr
);
3344 TRACE("Technique name at offset %#x.\n", offset
);
3346 if (!fx10_copy_string(data
, data_size
, offset
, &t
->name
))
3348 ERR("Failed to copy name.\n");
3349 return E_OUTOFMEMORY
;
3351 TRACE("Technique name: %s.\n", debugstr_a(t
->name
));
3353 t
->pass_count
= read_u32(ptr
);
3354 TRACE("Technique has %u passes.\n", t
->pass_count
);
3356 t
->annotations
.count
= read_u32(ptr
);
3357 TRACE("Technique has %u annotations.\n", t
->annotations
.count
);
3359 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, t
->effect
,
3362 ERR("Failed to parse technique annotations, hr %#lx.\n", hr
);
3366 if (!(t
->passes
= calloc(t
->pass_count
, sizeof(*t
->passes
))))
3368 ERR("Failed to allocate passes memory\n");
3369 return E_OUTOFMEMORY
;
3372 for (i
= 0; i
< t
->pass_count
; ++i
)
3374 struct d3d10_effect_pass
*p
= &t
->passes
[i
];
3376 p
->ID3D10EffectPass_iface
.lpVtbl
= &d3d10_effect_pass_vtbl
;
3379 if (FAILED(hr
= parse_fx10_pass(data
, data_size
, ptr
, p
)))
3386 static void parse_fx10_set_default_numeric_value(const char **ptr
, struct d3d10_effect_variable
*v
)
3388 float *dst
= (float *)(v
->buffer
->u
.buffer
.local_buffer
+ v
->buffer_offset
), *src
;
3389 BOOL col_major
= v
->type
->type_class
== D3D10_SVC_MATRIX_COLUMNS
;
3390 unsigned int col_count
= v
->type
->column_count
, col
;
3391 unsigned int row_count
= v
->type
->row_count
, row
;
3393 src
= (float *)*ptr
;
3397 for (col
= 0; col
< col_count
; ++col
)
3399 for (row
= 0; row
< row_count
; ++row
)
3400 dst
[row
] = src
[row
* col_count
+ col
];
3406 for (row
= 0; row
< row_count
; ++row
)
3408 memcpy(dst
, src
, col_count
* sizeof(float));
3414 *ptr
+= col_count
* row_count
* sizeof(float);
3417 static void parse_fx10_default_value(const char **ptr
, struct d3d10_effect_variable
*var
)
3419 unsigned int element_count
= max(var
->type
->element_count
, 1), i
, m
;
3420 struct d3d10_effect_variable
*v
;
3422 for (i
= 0; i
< element_count
; ++i
)
3424 v
= d3d10_array_get_element(var
, i
);
3426 switch (v
->type
->type_class
)
3428 case D3D10_SVC_STRUCT
:
3429 for (m
= 0; m
< v
->type
->member_count
; ++m
)
3430 parse_fx10_default_value(ptr
, &v
->members
[m
]);
3432 case D3D10_SVC_SCALAR
:
3433 case D3D10_SVC_VECTOR
:
3434 case D3D10_SVC_MATRIX_COLUMNS
:
3435 case D3D10_SVC_MATRIX_ROWS
:
3436 parse_fx10_set_default_numeric_value(ptr
, v
);
3439 FIXME("Unexpected initial value for type %#x.\n", v
->type
->basetype
);
3445 static void d3d10_effect_variable_update_buffer_offsets(struct d3d10_effect_variable
*v
,
3446 unsigned int offset
)
3450 for (i
= 0; i
< v
->type
->member_count
; ++i
)
3451 d3d10_effect_variable_update_buffer_offsets(&v
->members
[i
], offset
);
3453 for (i
= 0; i
< v
->type
->element_count
; ++i
)
3454 d3d10_effect_variable_update_buffer_offsets(&v
->elements
[i
], offset
);
3456 v
->buffer_offset
+= offset
;
3459 static HRESULT
parse_fx10_numeric_variable(const char *data
, size_t data_size
,
3460 const char **ptr
, BOOL local
, struct d3d10_effect_variable
*v
)
3462 uint32_t offset
, flags
, default_value_offset
, buffer_offset
;
3463 const char *data_ptr
;
3466 if (FAILED(hr
= parse_fx10_variable_head(data
, data_size
, ptr
, v
)))
3469 offset
= read_u32(ptr
);
3470 TRACE("Variable semantic at offset %#x.\n", offset
);
3472 if (!fx10_copy_string(data
, data_size
, offset
, &v
->semantic
))
3474 ERR("Failed to copy semantic.\n");
3475 return E_OUTOFMEMORY
;
3477 TRACE("Variable semantic: %s.\n", debugstr_a(v
->semantic
));
3479 buffer_offset
= read_u32(ptr
);
3480 TRACE("Variable offset in buffer: %#x.\n", buffer_offset
);
3482 default_value_offset
= read_u32(ptr
);
3483 TRACE("Variable default value offset: %#x.\n", default_value_offset
);
3485 flags
= read_u32(ptr
);
3486 TRACE("Variable flags: %#x.\n", flags
);
3490 /* At this point storage offsets for members and array elements are relative to containing
3491 variable. Update them by moving to correct offset within a buffer. */
3492 d3d10_effect_variable_update_buffer_offsets(v
, buffer_offset
);
3496 if (default_value_offset
)
3498 if (!require_space(default_value_offset
, 1, v
->type
->size_packed
, data_size
))
3500 WARN("Invalid default value offset %#x, variable packed size %u.\n", default_value_offset
,
3501 v
->type
->size_packed
);
3505 data_ptr
= data
+ default_value_offset
;
3506 parse_fx10_default_value(&data_ptr
, v
);
3509 v
->annotations
.count
= read_u32(ptr
);
3510 TRACE("Variable has %u annotations.\n", v
->annotations
.count
);
3512 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, v
->effect
,
3515 ERR("Failed to parse variable annotations, hr %#lx.\n", hr
);
3520 if (v
->flag
& D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
)
3521 v
->explicit_bind_point
= v
->buffer_offset
;
3526 static HRESULT
create_state_object(struct d3d10_effect_variable
*v
)
3528 ID3D10Device
*device
= v
->effect
->device
;
3531 switch (v
->type
->basetype
)
3533 case D3D10_SVT_DEPTHSTENCIL
:
3534 if (FAILED(hr
= ID3D10Device_CreateDepthStencilState(device
,
3535 &v
->u
.state
.desc
.depth_stencil
, &v
->u
.state
.object
.depth_stencil
)))
3539 case D3D10_SVT_BLEND
:
3540 if (FAILED(hr
= ID3D10Device_CreateBlendState(device
,
3541 &v
->u
.state
.desc
.blend
, &v
->u
.state
.object
.blend
)))
3545 case D3D10_SVT_RASTERIZER
:
3546 if (FAILED(hr
= ID3D10Device_CreateRasterizerState(device
,
3547 &v
->u
.state
.desc
.rasterizer
, &v
->u
.state
.object
.rasterizer
)))
3551 case D3D10_SVT_SAMPLER
:
3552 if (FAILED(hr
= ID3D10Device_CreateSamplerState(device
,
3553 &v
->u
.state
.desc
.sampler
.desc
, &v
->u
.state
.object
.sampler
)))
3558 ERR("Unhandled variable type %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
3565 static HRESULT
parse_fx10_object_variable(const char *data
, size_t data_size
,
3566 const char **ptr
, BOOL shared_type_desc
, struct d3d10_effect_variable
*v
)
3568 struct d3d10_effect_var_array
*vars
;
3569 struct d3d10_effect_variable
*var
;
3570 unsigned int i
, j
, element_count
;
3574 if (FAILED(hr
= parse_fx10_variable_head(data
, data_size
, ptr
, v
)))
3577 offset
= read_u32(ptr
);
3578 TRACE("Variable semantic at offset %#x.\n", offset
);
3580 if (!fx10_copy_string(data
, data_size
, offset
, &v
->semantic
))
3582 ERR("Failed to copy semantic.\n");
3583 return E_OUTOFMEMORY
;
3585 TRACE("Variable semantic: %s.\n", debugstr_a(v
->semantic
));
3587 v
->explicit_bind_point
= read_u32(ptr
);
3588 TRACE("Variable explicit bind point %#x.\n", v
->explicit_bind_point
);
3590 /* Shared variable description contains only type information. */
3591 if (shared_type_desc
) return S_OK
;
3593 element_count
= max(v
->type
->element_count
, 1);
3595 switch (v
->type
->basetype
)
3597 case D3D10_SVT_TEXTURE
:
3598 case D3D10_SVT_TEXTURE1D
:
3599 case D3D10_SVT_TEXTURE1DARRAY
:
3600 case D3D10_SVT_TEXTURE2D
:
3601 case D3D10_SVT_TEXTURE2DARRAY
:
3602 case D3D10_SVT_TEXTURE2DMS
:
3603 case D3D10_SVT_TEXTURE2DMSARRAY
:
3604 case D3D10_SVT_TEXTURE3D
:
3605 case D3D10_SVT_TEXTURECUBE
:
3606 if (!(v
->u
.resource
.srv
= calloc(element_count
, sizeof(*v
->u
.resource
.srv
))))
3608 ERR("Failed to allocate shader resource view array memory.\n");
3609 return E_OUTOFMEMORY
;
3611 v
->u
.resource
.parent
= TRUE
;
3615 for (i
= 0; i
< v
->type
->element_count
; ++i
)
3617 v
->elements
[i
].u
.resource
.srv
= &v
->u
.resource
.srv
[i
];
3618 v
->elements
[i
].u
.resource
.parent
= FALSE
;
3623 case D3D10_SVT_RENDERTARGETVIEW
:
3624 case D3D10_SVT_DEPTHSTENCILVIEW
:
3625 case D3D10_SVT_BUFFER
:
3626 TRACE("SVT could not have elements.\n");
3629 case D3D10_SVT_VERTEXSHADER
:
3630 case D3D10_SVT_PIXELSHADER
:
3631 case D3D10_SVT_GEOMETRYSHADER
:
3632 TRACE("Shader type is %s\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
3633 for (i
= 0; i
< element_count
; ++i
)
3635 uint32_t shader_offset
, sodecl_offset
;
3637 var
= d3d10_array_get_element(v
, i
);
3639 shader_offset
= read_u32(ptr
);
3640 TRACE("Shader offset: %#x.\n", shader_offset
);
3642 if (v
->type
->flags
& D3D10_EOT_FLAG_GS_SO
)
3644 sodecl_offset
= read_u32(ptr
);
3645 TRACE("Stream output declaration at offset %#x.\n", sodecl_offset
);
3647 if (!fx10_copy_string(data
, data_size
, sodecl_offset
,
3648 &var
->u
.shader
.stream_output_declaration
))
3650 ERR("Failed to copy stream output declaration.\n");
3651 return E_OUTOFMEMORY
;
3654 TRACE("Stream output declaration: %s.\n", debugstr_a(var
->u
.shader
.stream_output_declaration
));
3657 if (FAILED(hr
= parse_fx10_shader(data
, data_size
, shader_offset
, var
)))
3662 case D3D10_SVT_DEPTHSTENCIL
:
3663 case D3D10_SVT_BLEND
:
3664 case D3D10_SVT_RASTERIZER
:
3665 case D3D10_SVT_SAMPLER
:
3667 const struct d3d10_effect_state_storage_info
*storage_info
;
3669 if (!(storage_info
= get_storage_info(v
->type
->basetype
)))
3671 FIXME("Failed to get backing store info for type %s.\n",
3672 debug_d3d10_shader_variable_type(v
->type
->basetype
));
3676 if (storage_info
->size
> sizeof(v
->u
.state
.desc
))
3678 ERR("Invalid storage size %#Ix.\n", storage_info
->size
);
3682 switch (v
->type
->basetype
)
3684 case D3D10_SVT_DEPTHSTENCIL
:
3685 vars
= &v
->effect
->ds_states
;
3687 case D3D10_SVT_BLEND
:
3688 vars
= &v
->effect
->blend_states
;
3690 case D3D10_SVT_RASTERIZER
:
3691 vars
= &v
->effect
->rs_states
;
3693 case D3D10_SVT_SAMPLER
:
3694 vars
= &v
->effect
->samplers
;
3700 for (i
= 0; i
< element_count
; ++i
)
3702 unsigned int prop_count
;
3704 var
= d3d10_array_get_element(v
, i
);
3706 if (vars
->current
>= vars
->count
)
3708 WARN("Wrong variable array size for %#x.\n", v
->type
->basetype
);
3711 var
->u
.state
.index
= vars
->current
;
3712 vars
->v
[vars
->current
++] = var
;
3714 prop_count
= read_u32(ptr
);
3715 TRACE("State object property count: %#x.\n", prop_count
);
3717 memcpy(&var
->u
.state
.desc
, storage_info
->default_state
, storage_info
->size
);
3719 for (j
= 0; j
< prop_count
; ++j
)
3721 if (FAILED(hr
= parse_fx10_property_assignment(data
, data_size
, ptr
,
3722 get_var_container_type(var
), var
->effect
, &var
->u
.state
.desc
,
3723 &var
->u
.state
.dependencies
)))
3725 ERR("Failed to read property list.\n");
3730 if (FAILED(hr
= create_state_object(var
)))
3737 FIXME("Unhandled case %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
3741 v
->annotations
.count
= read_u32(ptr
);
3742 TRACE("Variable has %u annotations.\n", v
->annotations
.count
);
3744 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, v
->effect
,
3747 ERR("Failed to parse variable annotations, hr %#lx.\n", hr
);
3754 static HRESULT
create_buffer_object(struct d3d10_effect_variable
*v
)
3756 D3D10_BUFFER_DESC buffer_desc
;
3757 D3D10_SUBRESOURCE_DATA subresource_data
;
3758 D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc
;
3759 ID3D10Device
*device
= v
->effect
->device
;
3762 buffer_desc
.ByteWidth
= v
->data_size
;
3763 buffer_desc
.Usage
= D3D10_USAGE_DEFAULT
;
3764 buffer_desc
.CPUAccessFlags
= 0;
3765 buffer_desc
.MiscFlags
= 0;
3766 if (v
->type
->basetype
== D3D10_SVT_CBUFFER
)
3767 buffer_desc
.BindFlags
= D3D10_BIND_CONSTANT_BUFFER
;
3769 buffer_desc
.BindFlags
= D3D10_BIND_SHADER_RESOURCE
;
3771 subresource_data
.pSysMem
= v
->u
.buffer
.local_buffer
;
3772 subresource_data
.SysMemPitch
= 0;
3773 subresource_data
.SysMemSlicePitch
= 0;
3775 if (FAILED(hr
= ID3D10Device_CreateBuffer(device
, &buffer_desc
, &subresource_data
, &v
->u
.buffer
.buffer
)))
3778 if (v
->type
->basetype
== D3D10_SVT_TBUFFER
)
3780 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
3781 srv_desc
.ViewDimension
= D3D_SRV_DIMENSION_BUFFER
;
3782 srv_desc
.Buffer
.ElementOffset
= 0;
3783 srv_desc
.Buffer
.ElementWidth
= v
->type
->size_unpacked
/ 16;
3784 if (v
->type
->size_unpacked
% 16)
3785 WARN("Unexpected texture buffer size not a multiple of 16.\n");
3787 if (FAILED(hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)v
->u
.buffer
.buffer
,
3788 &srv_desc
, &v
->u
.buffer
.resource_view
)))
3792 v
->u
.buffer
.resource_view
= NULL
;
3797 static HRESULT
parse_fx10_buffer(const char *data
, size_t data_size
, const char **ptr
,
3798 BOOL local
, struct d3d10_effect_variable
*l
)
3800 const char *prefix
= local
? "Local" : "Shared";
3803 D3D10_CBUFFER_TYPE d3d10_cbuffer_type
;
3805 unsigned int stride
= 0;
3807 /* Generate our own type, it isn't in the fx blob. */
3808 if (!(l
->type
= calloc(1, sizeof(*l
->type
))))
3810 ERR("Failed to allocate local buffer type memory.\n");
3811 return E_OUTOFMEMORY
;
3813 l
->type
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
3814 l
->type
->type_class
= D3D10_SVC_OBJECT
;
3815 l
->type
->effect
= l
->effect
;
3817 offset
= read_u32(ptr
);
3818 TRACE("%s buffer name at offset %#x.\n", prefix
, offset
);
3820 if (!fx10_copy_string(data
, data_size
, offset
, &l
->name
))
3822 ERR("Failed to copy name.\n");
3823 return E_OUTOFMEMORY
;
3825 TRACE("%s buffer name: %s.\n", prefix
, debugstr_a(l
->name
));
3827 l
->data_size
= read_u32(ptr
);
3828 TRACE("%s buffer data size: %#x.\n", prefix
, l
->data_size
);
3830 d3d10_cbuffer_type
= read_u32(ptr
);
3831 TRACE("%s buffer type: %#x.\n", prefix
, d3d10_cbuffer_type
);
3833 switch(d3d10_cbuffer_type
)
3835 case D3D10_CT_CBUFFER
:
3836 l
->type
->basetype
= D3D10_SVT_CBUFFER
;
3837 if (!copy_name("cbuffer", &l
->type
->name
))
3839 ERR("Failed to copy name.\n");
3840 return E_OUTOFMEMORY
;
3844 case D3D10_CT_TBUFFER
:
3845 l
->type
->basetype
= D3D10_SVT_TBUFFER
;
3846 if (!copy_name("tbuffer", &l
->type
->name
))
3848 ERR("Failed to copy name.\n");
3849 return E_OUTOFMEMORY
;
3854 ERR("Unexpected D3D10_CBUFFER_TYPE %#x!\n", d3d10_cbuffer_type
);
3858 l
->type
->member_count
= read_u32(ptr
);
3859 TRACE("%s buffer member count: %#x.\n", prefix
, l
->type
->member_count
);
3861 l
->explicit_bind_point
= read_u32(ptr
);
3862 TRACE("%s buffer explicit bind point: %#x.\n", prefix
, l
->explicit_bind_point
);
3864 if (l
->effect
->flags
& D3D10_EFFECT_IS_POOL
)
3865 l
->flag
|= D3D10_EFFECT_VARIABLE_POOLED
;
3869 l
->annotations
.count
= read_u32(ptr
);
3870 TRACE("Local buffer has %u annotations.\n", l
->annotations
.count
);
3872 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, l
->effect
,
3875 ERR("Failed to parse buffer annotations, hr %#lx.\n", hr
);
3880 if (!(l
->members
= calloc(l
->type
->member_count
, sizeof(*l
->members
))))
3882 ERR("Failed to allocate members memory.\n");
3883 return E_OUTOFMEMORY
;
3886 if (!(l
->type
->members
= calloc(l
->type
->member_count
, sizeof(*l
->type
->members
))))
3888 ERR("Failed to allocate type members memory.\n");
3889 return E_OUTOFMEMORY
;
3892 if (local
&& !(l
->u
.buffer
.local_buffer
= calloc(1, l
->data_size
)))
3894 ERR("Failed to allocate local constant buffer memory.\n");
3895 return E_OUTOFMEMORY
;
3898 for (i
= 0; i
< l
->type
->member_count
; ++i
)
3900 struct d3d10_effect_variable
*v
= &l
->members
[i
];
3901 struct d3d10_effect_type_member
*typem
= &l
->type
->members
[i
];
3904 v
->effect
= l
->effect
;
3906 if (FAILED(hr
= parse_fx10_numeric_variable(data
, data_size
, ptr
, local
, v
)))
3910 * Copy the values from the variable type to the constant buffers type
3911 * members structure, because it is our own generated type.
3913 typem
->type
= v
->type
;
3915 if (!copy_name(v
->name
, &typem
->name
))
3917 ERR("Failed to copy name.\n");
3918 return E_OUTOFMEMORY
;
3920 TRACE("Variable name: %s.\n", debugstr_a(typem
->name
));
3922 if (!copy_name(v
->semantic
, &typem
->semantic
))
3924 ERR("Failed to copy name.\n");
3925 return E_OUTOFMEMORY
;
3927 TRACE("Variable semantic: %s.\n", debugstr_a(typem
->semantic
));
3929 typem
->buffer_offset
= v
->buffer_offset
;
3930 TRACE("Variable buffer offset: %u.\n", typem
->buffer_offset
);
3932 l
->type
->size_packed
+= v
->type
->size_packed
;
3935 * For the complete constantbuffer the size_unpacked = stride,
3936 * the stride is calculated like this:
3938 * 1) if the constant buffer variables are packed with packoffset
3939 * - stride = the highest used constant
3940 * - the complete stride has to be a multiple of 0x10
3942 * 2) if the constant buffer variables are NOT packed with packoffset
3943 * - sum of unpacked size for all variables which fit in a 0x10 part
3944 * - if the size exceeds a 0x10 part, the rest of the old part is skipped
3945 * and a new part is started
3946 * - if the variable is a struct it is always used a new part
3947 * - the complete stride has to be a multiple of 0x10
3950 * 0x4, 0x4, 0x4, 0x8, 0x4, 0x14, 0x4
3951 * part 0x10 0x10 0x20 -> 0x40
3953 if (v
->flag
& D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
)
3955 if ((v
->type
->size_unpacked
+ v
->buffer_offset
) > stride
)
3957 stride
= v
->type
->size_unpacked
+ v
->buffer_offset
;
3962 if (v
->type
->type_class
== D3D10_SVC_STRUCT
)
3964 stride
= (stride
+ 0xf) & ~0xf;
3967 if ( ((stride
& 0xf) + v
->type
->size_unpacked
) > 0x10)
3969 stride
= (stride
+ 0xf) & ~0xf;
3972 stride
+= v
->type
->size_unpacked
;
3975 l
->type
->stride
= l
->type
->size_unpacked
= (stride
+ 0xf) & ~0xf;
3977 TRACE("%s constant buffer:\n", prefix
);
3978 TRACE("\tType name: %s.\n", debugstr_a(l
->type
->name
));
3979 TRACE("\tElement count: %u.\n", l
->type
->element_count
);
3980 TRACE("\tMember count: %u.\n", l
->type
->member_count
);
3981 TRACE("\tUnpacked size: %#x.\n", l
->type
->size_unpacked
);
3982 TRACE("\tStride: %#x.\n", l
->type
->stride
);
3983 TRACE("\tPacked size %#x.\n", l
->type
->size_packed
);
3984 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l
->type
->basetype
));
3985 TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l
->type
->type_class
));
3987 if (local
&& l
->data_size
)
3989 if (FAILED(hr
= create_buffer_object(l
)))
3991 WARN("Failed to create a buffer object, hr %#lx.\n", hr
);
3996 if (l
->explicit_bind_point
!= ~0u)
3997 l
->flag
|= D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
;
4002 static void d3d10_effect_type_member_destroy(struct d3d10_effect_type_member
*typem
)
4004 TRACE("effect type member %p.\n", typem
);
4006 /* Do not release typem->type, it will be covered by d3d10_effect_type_destroy(). */
4007 free(typem
->semantic
);
4011 static void d3d10_effect_type_destroy(struct wine_rb_entry
*entry
, void *context
)
4013 struct d3d10_effect_type
*t
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_effect_type
, entry
);
4015 TRACE("effect type %p.\n", t
);
4019 free(t
->elementtype
->name
);
4020 free(t
->elementtype
);
4027 for (i
= 0; i
< t
->member_count
; ++i
)
4029 d3d10_effect_type_member_destroy(&t
->members
[i
]);
4038 static BOOL
d3d10_effect_types_match(const struct d3d10_effect_type
*t1
,
4039 const struct d3d10_effect_type
*t2
)
4043 if (strcmp(t1
->name
, t2
->name
)) return FALSE
;
4044 if (t1
->basetype
!= t2
->basetype
) return FALSE
;
4045 if (t1
->type_class
!= t2
->type_class
) return FALSE
;
4046 if (t1
->element_count
!= t2
->element_count
) return FALSE
;
4047 if (t1
->element_count
) return d3d10_effect_types_match(t1
->elementtype
, t2
->elementtype
);
4048 if (t1
->member_count
!= t2
->member_count
) return FALSE
;
4049 if (t1
->column_count
!= t2
->column_count
) return FALSE
;
4050 if (t1
->row_count
!= t2
->row_count
) return FALSE
;
4052 for (i
= 0; i
< t1
->member_count
; ++i
)
4054 if (strcmp(t1
->members
[i
].name
, t2
->members
[i
].name
)) return FALSE
;
4055 if (t1
->members
[i
].buffer_offset
!= t2
->members
[i
].buffer_offset
) return FALSE
;
4056 if (!d3d10_effect_types_match(t1
->members
[i
].type
, t2
->members
[i
].type
)) return FALSE
;
4062 static HRESULT
d3d10_effect_validate_shared_variable(const struct d3d10_effect
*effect
,
4063 const struct d3d10_effect_variable
*v
)
4065 struct d3d10_effect_variable
*sv
;
4067 switch (v
->type
->basetype
)
4069 case D3D10_SVT_CBUFFER
:
4070 case D3D10_SVT_TBUFFER
:
4071 sv
= d3d10_effect_get_buffer_by_name(effect
->pool
, v
->name
);
4074 sv
= d3d10_effect_get_variable_by_name(effect
->pool
, v
->name
);
4079 WARN("Variable %s wasn't found in the pool.\n", debugstr_a(v
->name
));
4080 return E_INVALIDARG
;
4083 if (!d3d10_effect_types_match(sv
->type
, v
->type
))
4085 WARN("Variable %s type does not match pool type.\n", debugstr_a(v
->name
));
4086 return E_INVALIDARG
;
4092 static HRESULT
parse_fx10_body(struct d3d10_effect
*e
, const char *data
, size_t data_size
)
4098 if (e
->index_offset
>= data_size
)
4100 WARN("Invalid index offset %#x (data size %#Ix).\n", e
->index_offset
, data_size
);
4103 ptr
= data
+ e
->index_offset
;
4105 if (!(e
->local_buffers
= calloc(e
->local_buffer_count
, sizeof(*e
->local_buffers
))))
4107 ERR("Failed to allocate local buffer memory.\n");
4108 return E_OUTOFMEMORY
;
4111 if (!(e
->local_variables
= calloc(e
->local_variable_count
, sizeof(*e
->local_variables
))))
4113 ERR("Failed to allocate local variable memory.\n");
4114 return E_OUTOFMEMORY
;
4117 if (!(e
->anonymous_shaders
= calloc(e
->anonymous_shader_count
, sizeof(*e
->anonymous_shaders
))))
4119 ERR("Failed to allocate anonymous shaders memory\n");
4120 return E_OUTOFMEMORY
;
4123 if (!(e
->shaders
.v
= calloc(e
->shaders
.count
, sizeof(*e
->shaders
.v
))))
4125 ERR("Failed to allocate used shaders memory\n");
4126 return E_OUTOFMEMORY
;
4129 if (!(e
->samplers
.v
= calloc(e
->samplers
.count
, sizeof(*e
->samplers
.v
))))
4131 ERR("Failed to allocate samplers array.\n");
4132 return E_OUTOFMEMORY
;
4135 if (!(e
->blend_states
.v
= calloc(e
->blend_states
.count
, sizeof(*e
->blend_states
.v
))))
4137 ERR("Failed to allocate blend states array.\n");
4138 return E_OUTOFMEMORY
;
4141 if (!(e
->ds_states
.v
= calloc(e
->ds_states
.count
, sizeof(*e
->ds_states
.v
))))
4143 ERR("Failed to allocate depth stencil states array.\n");
4144 return E_OUTOFMEMORY
;
4147 if (!(e
->rs_states
.v
= calloc(e
->rs_states
.count
, sizeof(*e
->rs_states
.v
))))
4149 ERR("Failed to allocate rasterizer states array.\n");
4150 return E_OUTOFMEMORY
;
4153 if (!(e
->techniques
= calloc(e
->technique_count
, sizeof(*e
->techniques
))))
4155 ERR("Failed to allocate techniques memory\n");
4156 return E_OUTOFMEMORY
;
4159 for (i
= 0; i
< e
->local_buffer_count
; ++i
)
4161 struct d3d10_effect_variable
*l
= &e
->local_buffers
[i
];
4162 l
->ID3D10EffectVariable_iface
.lpVtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_constant_buffer_vtbl
;
4164 l
->buffer
= &null_local_buffer
;
4166 if (FAILED(hr
= parse_fx10_buffer(data
, data_size
, &ptr
, TRUE
, l
)))
4170 for (i
= 0; i
< e
->local_variable_count
; ++i
)
4172 struct d3d10_effect_variable
*v
= &e
->local_variables
[i
];
4175 v
->ID3D10EffectVariable_iface
.lpVtbl
= &d3d10_effect_variable_vtbl
;
4176 v
->buffer
= &null_local_buffer
;
4178 if (FAILED(hr
= parse_fx10_object_variable(data
, data_size
, &ptr
, FALSE
, v
)))
4182 for (i
= 0; i
< e
->shared_buffer_count
; ++i
)
4184 struct d3d10_effect_variable b
= {{ 0 }};
4188 if (FAILED(hr
= parse_fx10_buffer(data
, data_size
, &ptr
, FALSE
, &b
)))
4190 d3d10_effect_variable_destroy(&b
);
4194 hr
= d3d10_effect_validate_shared_variable(e
, &b
);
4195 d3d10_effect_variable_destroy(&b
);
4196 if (FAILED(hr
)) return hr
;
4199 for (i
= 0; i
< e
->shared_object_count
; ++i
)
4201 struct d3d10_effect_variable o
= {{ 0 }};
4205 if (FAILED(hr
= parse_fx10_object_variable(data
, data_size
, &ptr
, TRUE
, &o
)))
4207 d3d10_effect_variable_destroy(&o
);
4211 hr
= d3d10_effect_validate_shared_variable(e
, &o
);
4212 d3d10_effect_variable_destroy(&o
);
4213 if (FAILED(hr
)) return hr
;
4216 for (i
= 0; i
< e
->technique_count
; ++i
)
4218 struct d3d10_effect_technique
*t
= &e
->techniques
[i
];
4220 t
->ID3D10EffectTechnique_iface
.lpVtbl
= &d3d10_effect_technique_vtbl
;
4223 if (FAILED(hr
= parse_fx10_technique(data
, data_size
, &ptr
, t
)))
4230 static HRESULT
parse_fx10(struct d3d10_effect
*e
, const char *data
, size_t data_size
)
4232 const char *ptr
= data
;
4235 if (!require_space(0, 19, sizeof(uint32_t), data_size
))
4237 WARN("Invalid data size %#Ix.\n", data_size
);
4238 return E_INVALIDARG
;
4241 /* Compiled target version (e.g. fx_4_0=0xfeff1001, fx_4_1=0xfeff1011). */
4242 e
->version
= read_u32(&ptr
);
4243 TRACE("Target: %#x.\n", e
->version
);
4245 e
->local_buffer_count
= read_u32(&ptr
);
4246 TRACE("Local buffer count: %u.\n", e
->local_buffer_count
);
4248 e
->variable_count
= read_u32(&ptr
);
4249 TRACE("Variable count: %u.\n", e
->variable_count
);
4251 e
->local_variable_count
= read_u32(&ptr
);
4252 TRACE("Object count: %u.\n", e
->local_variable_count
);
4254 e
->shared_buffer_count
= read_u32(&ptr
);
4255 TRACE("Pool buffer count: %u.\n", e
->shared_buffer_count
);
4257 unused
= read_u32(&ptr
);
4258 TRACE("Pool variable count: %u.\n", unused
);
4260 e
->shared_object_count
= read_u32(&ptr
);
4261 TRACE("Pool objects count: %u.\n", e
->shared_object_count
);
4263 e
->technique_count
= read_u32(&ptr
);
4264 TRACE("Technique count: %u.\n", e
->technique_count
);
4266 e
->index_offset
= read_u32(&ptr
);
4267 TRACE("Index offset: %#x.\n", e
->index_offset
);
4269 unused
= read_u32(&ptr
);
4270 TRACE("String count: %u.\n", unused
);
4272 e
->texture_count
= read_u32(&ptr
);
4273 TRACE("Texture count: %u.\n", e
->texture_count
);
4275 e
->ds_states
.count
= read_u32(&ptr
);
4276 TRACE("Depthstencilstate count: %u.\n", e
->ds_states
.count
);
4278 e
->blend_states
.count
= read_u32(&ptr
);
4279 TRACE("Blendstate count: %u.\n", e
->blend_states
.count
);
4281 e
->rs_states
.count
= read_u32(&ptr
);
4282 TRACE("Rasterizerstate count: %u.\n", e
->rs_states
.count
);
4284 e
->samplers
.count
= read_u32(&ptr
);
4285 TRACE("Samplerstate count: %u.\n", e
->samplers
.count
);
4287 e
->rtvs
.count
= read_u32(&ptr
);
4288 TRACE("Rendertargetview count: %u.\n", e
->rtvs
.count
);
4290 e
->dsvs
.count
= read_u32(&ptr
);
4291 TRACE("Depthstencilview count: %u.\n", e
->dsvs
.count
);
4293 e
->shaders
.count
= read_u32(&ptr
);
4294 TRACE("Used shader count: %u.\n", e
->shaders
.count
);
4296 e
->anonymous_shader_count
= read_u32(&ptr
);
4297 TRACE("Anonymous shader count: %u.\n", e
->anonymous_shader_count
);
4299 if (!e
->pool
&& (e
->shared_object_count
|| e
->shared_buffer_count
))
4301 WARN("Effect requires a pool to load.\n");
4305 return parse_fx10_body(e
, ptr
, data_size
- (ptr
- data
));
4308 HRESULT
d3d10_effect_parse(struct d3d10_effect
*effect
, const void *data
, SIZE_T data_size
)
4310 const struct vkd3d_shader_code dxbc
= {.code
= data
, .size
= data_size
};
4311 const struct vkd3d_shader_dxbc_section_desc
*section
;
4312 struct vkd3d_shader_dxbc_desc dxbc_desc
;
4317 if ((ret
= vkd3d_shader_parse_dxbc(&dxbc
, 0, &dxbc_desc
, NULL
)) < 0)
4319 WARN("Failed to parse DXBC, ret %d.\n", ret
);
4323 for (i
= 0; i
< dxbc_desc
.section_count
; ++i
)
4325 section
= &dxbc_desc
.sections
[i
];
4327 TRACE("Section %u: tag %s, data {%p, %#Ix}.\n",
4328 i
, debugstr_fourcc(section
->tag
),
4329 section
->data
.code
, section
->data
.size
);
4331 if (section
->tag
!= TAG_FX10
)
4333 FIXME("Unhandled chunk %s.\n", debugstr_fourcc(section
->tag
));
4337 if (FAILED(hr
= parse_fx10(effect
, section
->data
.code
, section
->data
.size
)))
4341 vkd3d_shader_free_dxbc(&dxbc_desc
);
4346 static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_variable
*s
,
4347 D3D10_SHADER_VARIABLE_TYPE type
)
4350 s
->reflection
->lpVtbl
->Release(s
->reflection
);
4351 if (s
->input_signature
)
4352 ID3D10Blob_Release(s
->input_signature
);
4354 ID3D10Blob_Release(s
->bytecode
);
4358 case D3D10_SVT_VERTEXSHADER
:
4359 case D3D10_SVT_PIXELSHADER
:
4360 case D3D10_SVT_GEOMETRYSHADER
:
4361 if (s
->shader
.object
)
4362 IUnknown_Release(s
->shader
.object
);
4366 FIXME("Unhandled shader type %s.\n", debug_d3d10_shader_variable_type(type
));
4370 if (s
->resource_count
)
4374 static void d3d10_effect_annotations_destroy(struct d3d10_effect_annotations
*a
)
4378 if (!a
->elements
) return;
4380 for (i
= 0; i
< a
->count
; ++i
)
4381 d3d10_effect_variable_destroy(&a
->elements
[i
]);
4387 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable
*v
)
4389 unsigned int i
, elem_count
;
4391 TRACE("variable %p.\n", v
);
4395 d3d10_effect_annotations_destroy(&v
->annotations
);
4399 for (i
= 0; i
< v
->type
->member_count
; ++i
)
4401 d3d10_effect_variable_destroy(&v
->members
[i
]);
4408 for (i
= 0; i
< v
->type
->element_count
; ++i
)
4410 d3d10_effect_variable_destroy(&v
->elements
[i
]);
4417 switch (v
->type
->basetype
)
4419 case D3D10_SVT_VERTEXSHADER
:
4420 case D3D10_SVT_PIXELSHADER
:
4421 case D3D10_SVT_GEOMETRYSHADER
:
4422 d3d10_effect_shader_variable_destroy(&v
->u
.shader
, v
->type
->basetype
);
4425 case D3D10_SVT_DEPTHSTENCIL
:
4426 case D3D10_SVT_BLEND
:
4427 case D3D10_SVT_RASTERIZER
:
4428 case D3D10_SVT_SAMPLER
:
4429 if (v
->u
.state
.object
.object
)
4430 IUnknown_Release(v
->u
.state
.object
.object
);
4431 d3d10_effect_clear_prop_dependencies(&v
->u
.state
.dependencies
);
4434 case D3D10_SVT_TEXTURE1D
:
4435 case D3D10_SVT_TEXTURE1DARRAY
:
4436 case D3D10_SVT_TEXTURE2D
:
4437 case D3D10_SVT_TEXTURE2DARRAY
:
4438 case D3D10_SVT_TEXTURE2DMS
:
4439 case D3D10_SVT_TEXTURE2DMSARRAY
:
4440 case D3D10_SVT_TEXTURE3D
:
4441 case D3D10_SVT_TEXTURECUBE
:
4442 if (!v
->u
.resource
.parent
)
4445 if (!v
->type
->element_count
)
4448 elem_count
= v
->type
->element_count
;
4450 for (i
= 0; i
< elem_count
; ++i
)
4452 if (v
->u
.resource
.srv
[i
])
4453 ID3D10ShaderResourceView_Release(v
->u
.resource
.srv
[i
]);
4456 free(v
->u
.resource
.srv
);
4459 case D3D10_SVT_STRING
:
4460 free(v
->u
.buffer
.local_buffer
);
4469 static void d3d10_effect_pass_destroy(struct d3d10_effect_pass
*p
)
4471 TRACE("pass %p\n", p
);
4474 d3d10_effect_annotations_destroy(&p
->annotations
);
4475 d3d10_effect_clear_prop_dependencies(&p
->dependencies
);
4478 static void d3d10_effect_technique_destroy(struct d3d10_effect_technique
*t
)
4482 TRACE("technique %p\n", t
);
4487 for (i
= 0; i
< t
->pass_count
; ++i
)
4489 d3d10_effect_pass_destroy(&t
->passes
[i
]);
4494 d3d10_effect_annotations_destroy(&t
->annotations
);
4497 static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable
*l
)
4501 TRACE("local buffer %p.\n", l
);
4506 for (i
= 0; i
< l
->type
->member_count
; ++i
)
4508 d3d10_effect_variable_destroy(&l
->members
[i
]);
4514 d3d10_effect_type_destroy(&l
->type
->entry
, NULL
);
4516 d3d10_effect_annotations_destroy(&l
->annotations
);
4517 free(l
->u
.buffer
.local_buffer
);
4519 if (l
->u
.buffer
.buffer
)
4520 ID3D10Buffer_Release(l
->u
.buffer
.buffer
);
4521 if (l
->u
.buffer
.resource_view
)
4522 ID3D10ShaderResourceView_Release(l
->u
.buffer
.resource_view
);
4525 /* IUnknown methods */
4527 static inline struct d3d10_effect
*impl_from_ID3D10Effect(ID3D10Effect
*iface
)
4529 return CONTAINING_RECORD(iface
, struct d3d10_effect
, ID3D10Effect_iface
);
4532 static HRESULT STDMETHODCALLTYPE
d3d10_effect_QueryInterface(ID3D10Effect
*iface
, REFIID riid
, void **object
)
4534 TRACE("iface %p, riid %s, object %p\n", iface
, debugstr_guid(riid
), object
);
4536 if (IsEqualGUID(riid
, &IID_ID3D10Effect
)
4537 || IsEqualGUID(riid
, &IID_IUnknown
))
4539 IUnknown_AddRef(iface
);
4544 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
4547 return E_NOINTERFACE
;
4550 static ULONG STDMETHODCALLTYPE
d3d10_effect_AddRef(ID3D10Effect
*iface
)
4552 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4553 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
4555 TRACE("%p increasing refcount to %lu.\n", This
, refcount
);
4560 static ULONG STDMETHODCALLTYPE
d3d10_effect_Release(ID3D10Effect
*iface
)
4562 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4563 ULONG refcount
= InterlockedDecrement(&effect
->refcount
);
4565 TRACE("%p decreasing refcount to %lu.\n", iface
, refcount
);
4571 if (effect
->techniques
)
4573 for (i
= 0; i
< effect
->technique_count
; ++i
)
4575 d3d10_effect_technique_destroy(&effect
->techniques
[i
]);
4577 free(effect
->techniques
);
4580 if (effect
->local_variables
)
4582 for (i
= 0; i
< effect
->local_variable_count
; ++i
)
4584 d3d10_effect_variable_destroy(&effect
->local_variables
[i
]);
4586 free(effect
->local_variables
);
4589 if (effect
->local_buffers
)
4591 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4593 d3d10_effect_local_buffer_destroy(&effect
->local_buffers
[i
]);
4595 free(effect
->local_buffers
);
4598 if (effect
->anonymous_shaders
)
4600 for (i
= 0; i
< effect
->anonymous_shader_count
; ++i
)
4602 d3d10_effect_variable_destroy(&effect
->anonymous_shaders
[i
].shader
);
4603 free(effect
->anonymous_shaders
[i
].type
.name
);
4605 free(effect
->anonymous_shaders
);
4608 free(effect
->shaders
.v
);
4609 free(effect
->samplers
.v
);
4610 free(effect
->rtvs
.v
);
4611 free(effect
->dsvs
.v
);
4612 free(effect
->blend_states
.v
);
4613 free(effect
->ds_states
.v
);
4614 free(effect
->rs_states
.v
);
4616 wine_rb_destroy(&effect
->types
, d3d10_effect_type_destroy
, NULL
);
4619 IUnknown_Release(&effect
->pool
->ID3D10Effect_iface
);
4620 ID3D10Device_Release(effect
->device
);
4627 /* ID3D10Effect methods */
4629 static BOOL STDMETHODCALLTYPE
d3d10_effect_IsValid(ID3D10Effect
*iface
)
4631 FIXME("iface %p stub!\n", iface
);
4636 static BOOL STDMETHODCALLTYPE
d3d10_effect_IsPool(ID3D10Effect
*iface
)
4638 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4640 TRACE("iface %p.\n", iface
);
4642 return effect
->ID3D10Effect_iface
.lpVtbl
== &d3d10_effect_pool_effect_vtbl
;
4645 static HRESULT STDMETHODCALLTYPE
d3d10_effect_GetDevice(ID3D10Effect
*iface
, ID3D10Device
**device
)
4647 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4649 TRACE("iface %p, device %p\n", iface
, device
);
4651 ID3D10Device_AddRef(This
->device
);
4652 *device
= This
->device
;
4657 static void d3d10_effect_get_desc(const struct d3d10_effect
*effect
, D3D10_EFFECT_DESC
*desc
)
4661 desc
->IsChildEffect
= !!effect
->pool
;
4662 desc
->ConstantBuffers
= effect
->local_buffer_count
;
4663 desc
->SharedConstantBuffers
= 0;
4664 desc
->GlobalVariables
= effect
->local_variable_count
;
4665 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4667 desc
->GlobalVariables
+= effect
->local_buffers
[i
].type
->member_count
;
4669 desc
->SharedGlobalVariables
= 0;
4670 desc
->Techniques
= effect
->technique_count
;
4673 static HRESULT STDMETHODCALLTYPE
d3d10_effect_GetDesc(ID3D10Effect
*iface
, D3D10_EFFECT_DESC
*desc
)
4675 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4676 D3D10_EFFECT_DESC pool_desc
= { 0 };
4678 TRACE("iface %p, desc %p.\n", iface
, desc
);
4681 return E_INVALIDARG
;
4684 d3d10_effect_get_desc(effect
->pool
, &pool_desc
);
4686 d3d10_effect_get_desc(effect
, desc
);
4688 desc
->SharedConstantBuffers
= pool_desc
.ConstantBuffers
;
4689 desc
->SharedGlobalVariables
= pool_desc
.GlobalVariables
;
4694 static struct d3d10_effect_variable
* d3d10_effect_get_buffer_by_index(struct d3d10_effect
*effect
,
4697 if (index
< effect
->local_buffer_count
)
4698 return &effect
->local_buffers
[index
];
4699 index
-= effect
->local_buffer_count
;
4701 return effect
->pool
? d3d10_effect_get_buffer_by_index(effect
->pool
, index
) : NULL
;
4704 static BOOL
is_var_shared(const struct d3d10_effect_variable
*v
)
4706 return !!(v
->flag
& D3D10_EFFECT_VARIABLE_POOLED
);
4709 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_GetConstantBufferByIndex(ID3D10Effect
*iface
,
4712 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4713 struct d3d10_effect_variable
*v
;
4715 TRACE("iface %p, index %u\n", iface
, index
);
4717 if ((v
= d3d10_effect_get_buffer_by_index(effect
, index
)))
4719 TRACE("Returning %sbuffer %p, name %s.\n", is_var_shared(v
) ? "shared " : "", v
,
4720 debugstr_a(v
->name
));
4721 return (ID3D10EffectConstantBuffer
*)&v
->ID3D10EffectVariable_iface
;
4724 WARN("Invalid index specified\n");
4726 return (ID3D10EffectConstantBuffer
*)&null_local_buffer
.ID3D10EffectVariable_iface
;
4729 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_GetConstantBufferByName(ID3D10Effect
*iface
,
4732 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4733 struct d3d10_effect_variable
*v
;
4735 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4737 if ((v
= d3d10_effect_get_buffer_by_name(effect
, name
)))
4739 TRACE("Returning %sbuffer %p.\n", is_var_shared(v
) ? "shared " : "", v
);
4740 return (ID3D10EffectConstantBuffer
*)&v
->ID3D10EffectVariable_iface
;
4743 WARN("Invalid name specified\n");
4745 return (ID3D10EffectConstantBuffer
*)&null_local_buffer
.ID3D10EffectVariable_iface
;
4748 static struct d3d10_effect_variable
* d3d10_effect_get_variable_by_index(
4749 const struct d3d10_effect
*effect
, unsigned int index
)
4753 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4755 struct d3d10_effect_variable
*v
= &effect
->local_buffers
[i
];
4756 if (index
< v
->type
->member_count
)
4757 return &v
->members
[index
];
4758 index
-= v
->type
->member_count
;
4761 if (index
< effect
->local_variable_count
)
4762 return &effect
->local_variables
[index
];
4763 index
-= effect
->local_variable_count
;
4765 return effect
->pool
? d3d10_effect_get_variable_by_index(effect
->pool
, index
) : NULL
;
4768 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_GetVariableByIndex(ID3D10Effect
*iface
, UINT index
)
4770 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4771 struct d3d10_effect_variable
*v
;
4773 TRACE("iface %p, index %u\n", iface
, index
);
4775 if ((v
= d3d10_effect_get_variable_by_index(effect
, index
)))
4777 TRACE("Returning %svariable %s.\n", is_var_shared(v
) ? "shared " : "", debugstr_a(v
->name
));
4778 return &v
->ID3D10EffectVariable_iface
;
4781 WARN("Invalid index specified\n");
4783 return &null_variable
.ID3D10EffectVariable_iface
;
4786 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_GetVariableByName(ID3D10Effect
*iface
,
4789 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4790 struct d3d10_effect_variable
*v
;
4792 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4796 WARN("Invalid name specified\n");
4797 return &null_variable
.ID3D10EffectVariable_iface
;
4800 if ((v
= d3d10_effect_get_variable_by_name(effect
, name
)))
4802 TRACE("Returning %svariable %p.\n", is_var_shared(v
) ? "shared " : "", v
);
4803 return &v
->ID3D10EffectVariable_iface
;
4806 WARN("Invalid name specified\n");
4808 return &null_variable
.ID3D10EffectVariable_iface
;
4811 static struct d3d10_effect_variable
* d3d10_effect_get_variable_by_semantic(
4812 const struct d3d10_effect
*effect
, const char *semantic
)
4816 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4818 struct d3d10_effect_variable
*l
= &effect
->local_buffers
[i
];
4821 for (j
= 0; j
< l
->type
->member_count
; ++j
)
4823 struct d3d10_effect_variable
*v
= &l
->members
[j
];
4825 if (v
->semantic
&& !stricmp(v
->semantic
, semantic
))
4830 for (i
= 0; i
< effect
->local_variable_count
; ++i
)
4832 struct d3d10_effect_variable
*v
= &effect
->local_variables
[i
];
4834 if (v
->semantic
&& !stricmp(v
->semantic
, semantic
))
4838 return effect
->pool
? d3d10_effect_get_variable_by_semantic(effect
->pool
, semantic
) : NULL
;
4841 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_GetVariableBySemantic(ID3D10Effect
*iface
,
4842 const char *semantic
)
4844 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4845 struct d3d10_effect_variable
*v
;
4847 TRACE("iface %p, semantic %s\n", iface
, debugstr_a(semantic
));
4851 WARN("Invalid semantic specified\n");
4852 return &null_variable
.ID3D10EffectVariable_iface
;
4855 if ((v
= d3d10_effect_get_variable_by_semantic(effect
, semantic
)))
4857 TRACE("Returning %svariable %s.\n", is_var_shared(v
) ? "shared " : "", debugstr_a(v
->name
));
4858 return &v
->ID3D10EffectVariable_iface
;
4861 WARN("Invalid semantic specified\n");
4863 return &null_variable
.ID3D10EffectVariable_iface
;
4866 static struct ID3D10EffectTechnique
* STDMETHODCALLTYPE
d3d10_effect_GetTechniqueByIndex(ID3D10Effect
*iface
,
4869 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4870 struct d3d10_effect_technique
*t
;
4872 TRACE("iface %p, index %u\n", iface
, index
);
4874 if (index
>= This
->technique_count
)
4876 WARN("Invalid index specified\n");
4877 return &null_technique
.ID3D10EffectTechnique_iface
;
4880 t
= &This
->techniques
[index
];
4882 TRACE("Returning technique %p, %s.\n", t
, debugstr_a(t
->name
));
4884 return &t
->ID3D10EffectTechnique_iface
;
4887 static struct ID3D10EffectTechnique
* STDMETHODCALLTYPE
d3d10_effect_GetTechniqueByName(ID3D10Effect
*iface
,
4890 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4893 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4897 WARN("Invalid name specified\n");
4898 return &null_technique
.ID3D10EffectTechnique_iface
;
4901 for (i
= 0; i
< This
->technique_count
; ++i
)
4903 struct d3d10_effect_technique
*t
= &This
->techniques
[i
];
4904 if (t
->name
&& !strcmp(t
->name
, name
))
4906 TRACE("Returning technique %p\n", t
);
4907 return &t
->ID3D10EffectTechnique_iface
;
4911 WARN("Invalid name specified\n");
4913 return &null_technique
.ID3D10EffectTechnique_iface
;
4916 static HRESULT STDMETHODCALLTYPE
d3d10_effect_Optimize(ID3D10Effect
*iface
)
4918 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4919 struct d3d10_effect_variable
*v
;
4922 FIXME("iface %p semi-stub!\n", iface
);
4924 if (effect
->flags
& D3D10_EFFECT_OPTIMIZED
)
4927 for (i
= 0; i
< effect
->shaders
.count
; ++i
)
4929 v
= effect
->shaders
.v
[i
];
4931 if (v
->u
.shader
.reflection
)
4933 v
->u
.shader
.reflection
->lpVtbl
->Release(v
->u
.shader
.reflection
);
4934 v
->u
.shader
.reflection
= NULL
;
4936 if (v
->u
.shader
.bytecode
)
4938 ID3D10Blob_Release(v
->u
.shader
.bytecode
);
4939 v
->u
.shader
.bytecode
= NULL
;
4941 free(v
->u
.shader
.stream_output_declaration
);
4942 v
->u
.shader
.stream_output_declaration
= NULL
;
4945 for (i
= 0; i
< effect
->technique_count
; ++i
)
4947 for (j
= 0; j
< effect
->techniques
[i
].pass_count
; ++j
)
4949 free(effect
->techniques
[i
].passes
[j
].name
);
4950 effect
->techniques
[i
].passes
[j
].name
= NULL
;
4953 free(effect
->techniques
[i
].name
);
4954 effect
->techniques
[i
].name
= NULL
;
4957 effect
->flags
|= D3D10_EFFECT_OPTIMIZED
;
4962 static BOOL STDMETHODCALLTYPE
d3d10_effect_IsOptimized(ID3D10Effect
*iface
)
4964 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4966 TRACE("iface %p.\n", iface
);
4968 return !!(effect
->flags
& D3D10_EFFECT_OPTIMIZED
);
4971 static const struct ID3D10EffectVtbl d3d10_effect_vtbl
=
4973 /* IUnknown methods */
4974 d3d10_effect_QueryInterface
,
4975 d3d10_effect_AddRef
,
4976 d3d10_effect_Release
,
4977 /* ID3D10Effect methods */
4978 d3d10_effect_IsValid
,
4979 d3d10_effect_IsPool
,
4980 d3d10_effect_GetDevice
,
4981 d3d10_effect_GetDesc
,
4982 d3d10_effect_GetConstantBufferByIndex
,
4983 d3d10_effect_GetConstantBufferByName
,
4984 d3d10_effect_GetVariableByIndex
,
4985 d3d10_effect_GetVariableByName
,
4986 d3d10_effect_GetVariableBySemantic
,
4987 d3d10_effect_GetTechniqueByIndex
,
4988 d3d10_effect_GetTechniqueByName
,
4989 d3d10_effect_Optimize
,
4990 d3d10_effect_IsOptimized
,
4993 /* ID3D10EffectTechnique methods */
4995 static inline struct d3d10_effect_technique
*impl_from_ID3D10EffectTechnique(ID3D10EffectTechnique
*iface
)
4997 return CONTAINING_RECORD(iface
, struct d3d10_effect_technique
, ID3D10EffectTechnique_iface
);
5000 static BOOL STDMETHODCALLTYPE
d3d10_effect_technique_IsValid(ID3D10EffectTechnique
*iface
)
5002 struct d3d10_effect_technique
*This
= impl_from_ID3D10EffectTechnique(iface
);
5004 TRACE("iface %p\n", iface
);
5006 return This
!= &null_technique
;
5009 static HRESULT STDMETHODCALLTYPE
d3d10_effect_technique_GetDesc(ID3D10EffectTechnique
*iface
,
5010 D3D10_TECHNIQUE_DESC
*desc
)
5012 struct d3d10_effect_technique
*tech
= impl_from_ID3D10EffectTechnique(iface
);
5014 TRACE("iface %p, desc %p\n", iface
, desc
);
5016 if (tech
== &null_technique
)
5018 WARN("Null technique specified\n");
5024 WARN("Invalid argument specified\n");
5025 return E_INVALIDARG
;
5028 desc
->Name
= tech
->name
;
5029 desc
->Passes
= tech
->pass_count
;
5030 desc
->Annotations
= tech
->annotations
.count
;
5035 static ID3D10EffectVariable
* d3d10_annotation_get_by_index(const struct d3d10_effect_annotations
*annotations
,
5038 struct d3d10_effect_variable
*a
;
5040 if (index
>= annotations
->count
)
5042 WARN("Invalid index specified\n");
5043 return &null_variable
.ID3D10EffectVariable_iface
;
5046 a
= &annotations
->elements
[index
];
5048 TRACE("Returning annotation %p, name %s.\n", a
, debugstr_a(a
->name
));
5050 return &a
->ID3D10EffectVariable_iface
;
5053 static ID3D10EffectVariable
* d3d10_annotation_get_by_name(const struct d3d10_effect_annotations
*annotations
,
5058 for (i
= 0; i
< annotations
->count
; ++i
)
5060 struct d3d10_effect_variable
*a
= &annotations
->elements
[i
];
5061 if (a
->name
&& !strcmp(a
->name
, name
))
5063 TRACE("Returning annotation %p.\n", a
);
5064 return &a
->ID3D10EffectVariable_iface
;
5068 WARN("Invalid name specified.\n");
5070 return &null_variable
.ID3D10EffectVariable_iface
;
5073 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_technique_GetAnnotationByIndex(
5074 ID3D10EffectTechnique
*iface
, UINT index
)
5076 struct d3d10_effect_technique
*tech
= impl_from_ID3D10EffectTechnique(iface
);
5078 TRACE("iface %p, index %u\n", iface
, index
);
5080 return d3d10_annotation_get_by_index(&tech
->annotations
, index
);
5083 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_technique_GetAnnotationByName(
5084 ID3D10EffectTechnique
*iface
, const char *name
)
5086 struct d3d10_effect_technique
*tech
= impl_from_ID3D10EffectTechnique(iface
);
5088 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5090 return d3d10_annotation_get_by_name(&tech
->annotations
, name
);
5093 static struct ID3D10EffectPass
* STDMETHODCALLTYPE
d3d10_effect_technique_GetPassByIndex(ID3D10EffectTechnique
*iface
,
5096 struct d3d10_effect_technique
*This
= impl_from_ID3D10EffectTechnique(iface
);
5097 struct d3d10_effect_pass
*p
;
5099 TRACE("iface %p, index %u\n", iface
, index
);
5101 if (index
>= This
->pass_count
)
5103 WARN("Invalid index specified\n");
5104 return &null_pass
.ID3D10EffectPass_iface
;
5107 p
= &This
->passes
[index
];
5109 TRACE("Returning pass %p, %s.\n", p
, debugstr_a(p
->name
));
5111 return &p
->ID3D10EffectPass_iface
;
5114 static struct ID3D10EffectPass
* STDMETHODCALLTYPE
d3d10_effect_technique_GetPassByName(ID3D10EffectTechnique
*iface
,
5117 struct d3d10_effect_technique
*This
= impl_from_ID3D10EffectTechnique(iface
);
5120 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5122 /* Do not check for name==NULL, W7/DX10 crashes in that case. */
5124 for (i
= 0; i
< This
->pass_count
; ++i
)
5126 struct d3d10_effect_pass
*p
= &This
->passes
[i
];
5127 if (p
->name
&& !strcmp(p
->name
, name
))
5129 TRACE("Returning pass %p\n", p
);
5130 return &p
->ID3D10EffectPass_iface
;
5134 WARN("Invalid name specified\n");
5136 return &null_pass
.ID3D10EffectPass_iface
;
5139 static HRESULT STDMETHODCALLTYPE
d3d10_effect_technique_ComputeStateBlockMask(ID3D10EffectTechnique
*iface
,
5140 D3D10_STATE_BLOCK_MASK
*mask
)
5142 FIXME("iface %p,mask %p stub!\n", iface
, mask
);
5147 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl
=
5149 /* ID3D10EffectTechnique methods */
5150 d3d10_effect_technique_IsValid
,
5151 d3d10_effect_technique_GetDesc
,
5152 d3d10_effect_technique_GetAnnotationByIndex
,
5153 d3d10_effect_technique_GetAnnotationByName
,
5154 d3d10_effect_technique_GetPassByIndex
,
5155 d3d10_effect_technique_GetPassByName
,
5156 d3d10_effect_technique_ComputeStateBlockMask
,
5159 /* ID3D10EffectPass methods */
5161 static inline struct d3d10_effect_pass
*impl_from_ID3D10EffectPass(ID3D10EffectPass
*iface
)
5163 return CONTAINING_RECORD(iface
, struct d3d10_effect_pass
, ID3D10EffectPass_iface
);
5166 static BOOL STDMETHODCALLTYPE
d3d10_effect_pass_IsValid(ID3D10EffectPass
*iface
)
5168 struct d3d10_effect_pass
*This
= impl_from_ID3D10EffectPass(iface
);
5170 TRACE("iface %p\n", iface
);
5172 return This
!= &null_pass
;
5175 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetDesc(ID3D10EffectPass
*iface
,
5176 D3D10_PASS_DESC
*desc
)
5178 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5179 struct d3d10_effect_variable
*vs
;
5180 ID3D10Blob
*input_signature
;
5182 TRACE("iface %p, desc %p.\n", iface
, desc
);
5184 if (pass
== &null_pass
)
5186 WARN("Null pass specified\n");
5192 WARN("Invalid argument specified\n");
5193 return E_INVALIDARG
;
5196 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
5198 vs
= d3d10_array_get_element(pass
->vs
.shader
, pass
->vs
.index
);
5199 input_signature
= vs
->u
.shader
.input_signature
;
5201 desc
->Name
= pass
->name
;
5202 desc
->Annotations
= pass
->annotations
.count
;
5203 if (input_signature
)
5205 desc
->pIAInputSignature
= ID3D10Blob_GetBufferPointer(input_signature
);
5206 desc
->IAInputSignatureSize
= ID3D10Blob_GetBufferSize(input_signature
);
5210 desc
->pIAInputSignature
= NULL
;
5211 desc
->IAInputSignatureSize
= 0;
5213 desc
->StencilRef
= pass
->stencil_ref
;
5214 desc
->SampleMask
= pass
->sample_mask
;
5215 memcpy(desc
->BlendFactor
, pass
->blend_factor
, 4 * sizeof(float));
5220 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetVertexShaderDesc(ID3D10EffectPass
*iface
,
5221 D3D10_PASS_SHADER_DESC
*desc
)
5223 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5225 TRACE("iface %p, desc %p.\n", iface
, desc
);
5227 if (pass
== &null_pass
)
5229 WARN("Null pass specified.\n");
5235 WARN("Invalid argument specified.\n");
5236 return E_INVALIDARG
;
5239 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
5241 desc
->pShaderVariable
= (ID3D10EffectShaderVariable
*)&pass
->vs
.shader
->ID3D10EffectVariable_iface
;
5242 desc
->ShaderIndex
= pass
->vs
.index
;
5247 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetGeometryShaderDesc(ID3D10EffectPass
*iface
,
5248 D3D10_PASS_SHADER_DESC
*desc
)
5250 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5252 TRACE("iface %p, desc %p.\n", iface
, desc
);
5254 if (pass
== &null_pass
)
5256 WARN("Null pass specified.\n");
5262 WARN("Invalid argument specified.\n");
5263 return E_INVALIDARG
;
5266 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
5268 desc
->pShaderVariable
= (ID3D10EffectShaderVariable
*)&pass
->gs
.shader
->ID3D10EffectVariable_iface
;
5269 desc
->ShaderIndex
= pass
->gs
.index
;
5274 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetPixelShaderDesc(ID3D10EffectPass
*iface
,
5275 D3D10_PASS_SHADER_DESC
*desc
)
5277 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5279 TRACE("iface %p, desc %p.\n", iface
, desc
);
5281 if (pass
== &null_pass
)
5283 WARN("Null pass specified.\n");
5289 WARN("Invalid argument specified.\n");
5290 return E_INVALIDARG
;
5293 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
5295 desc
->pShaderVariable
= (ID3D10EffectShaderVariable
*)&pass
->ps
.shader
->ID3D10EffectVariable_iface
;
5296 desc
->ShaderIndex
= pass
->ps
.index
;
5301 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_pass_GetAnnotationByIndex(ID3D10EffectPass
*iface
,
5304 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5306 TRACE("iface %p, index %u\n", iface
, index
);
5308 return d3d10_annotation_get_by_index(&pass
->annotations
, index
);
5311 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_pass_GetAnnotationByName(ID3D10EffectPass
*iface
,
5314 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5316 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5318 return d3d10_annotation_get_by_name(&pass
->annotations
, name
);
5321 static void update_buffer(ID3D10Device
*device
, struct d3d10_effect_variable
*v
)
5323 struct d3d10_effect_buffer_variable
*b
= &v
->u
.buffer
;
5328 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)b
->buffer
, 0, NULL
,
5329 b
->local_buffer
, v
->data_size
, 0);
5334 static void set_sampler(ID3D10Device
*device
, D3D10_SHADER_VARIABLE_TYPE shader_type
,
5335 struct d3d10_effect_variable
*v
, unsigned int bind_point
)
5337 switch (shader_type
)
5339 case D3D10_SVT_VERTEXSHADER
:
5340 ID3D10Device_VSSetSamplers(device
, bind_point
, 1, &v
->u
.state
.object
.sampler
);
5343 case D3D10_SVT_PIXELSHADER
:
5344 ID3D10Device_PSSetSamplers(device
, bind_point
, 1, &v
->u
.state
.object
.sampler
);
5347 case D3D10_SVT_GEOMETRYSHADER
:
5348 ID3D10Device_GSSetSamplers(device
, bind_point
, 1, &v
->u
.state
.object
.sampler
);
5352 WARN("Incorrect shader type to bind sampler.\n");
5357 static void apply_shader_resources(ID3D10Device
*device
, struct d3d10_effect_variable
*v
)
5359 struct d3d10_effect_shader_variable
*sv
= &v
->u
.shader
;
5360 struct d3d10_effect_shader_resource
*sr
;
5361 struct d3d10_effect_variable
*rsrc_v
;
5362 ID3D10ShaderResourceView
**srv
;
5365 for (i
= 0; i
< sv
->resource_count
; ++i
)
5367 sr
= &sv
->resources
[i
];
5368 rsrc_v
= sr
->variable
;
5370 switch (sr
->in_type
)
5372 case D3D10_SIT_CBUFFER
:
5373 update_buffer(device
, rsrc_v
);
5374 switch (v
->type
->basetype
)
5376 case D3D10_SVT_VERTEXSHADER
:
5377 ID3D10Device_VSSetConstantBuffers(device
, sr
->bind_point
, 1,
5378 &rsrc_v
->u
.buffer
.buffer
);
5381 case D3D10_SVT_PIXELSHADER
:
5382 ID3D10Device_PSSetConstantBuffers(device
, sr
->bind_point
, 1,
5383 &rsrc_v
->u
.buffer
.buffer
);
5386 case D3D10_SVT_GEOMETRYSHADER
:
5387 ID3D10Device_GSSetConstantBuffers(device
, sr
->bind_point
, 1,
5388 &rsrc_v
->u
.buffer
.buffer
);
5392 WARN("Incorrect shader type to bind constant buffer.\n");
5397 case D3D10_SIT_TEXTURE
:
5399 if (rsrc_v
->type
->basetype
== D3D10_SVT_SAMPLER
)
5401 TRACE("Using texture associated with sampler %s.\n", debugstr_a(rsrc_v
->name
));
5402 rsrc_v
= rsrc_v
->u
.state
.desc
.sampler
.texture
;
5406 case D3D10_SIT_TBUFFER
:
5408 if (sr
->in_type
== D3D10_SIT_TBUFFER
)
5410 update_buffer(device
, rsrc_v
);
5411 srv
= &rsrc_v
->u
.buffer
.resource_view
;
5414 srv
= rsrc_v
->u
.resource
.srv
;
5416 switch (v
->type
->basetype
)
5418 case D3D10_SVT_VERTEXSHADER
:
5419 ID3D10Device_VSSetShaderResources(device
, sr
->bind_point
, sr
->bind_count
, srv
);
5422 case D3D10_SVT_PIXELSHADER
:
5423 ID3D10Device_PSSetShaderResources(device
, sr
->bind_point
, sr
->bind_count
, srv
);
5426 case D3D10_SVT_GEOMETRYSHADER
:
5427 ID3D10Device_GSSetShaderResources(device
, sr
->bind_point
, sr
->bind_count
, srv
);
5431 WARN("Incorrect shader type to bind shader resource view.\n");
5436 case D3D10_SIT_SAMPLER
:
5437 if (!rsrc_v
->type
->element_count
)
5439 set_sampler(device
, v
->type
->basetype
, rsrc_v
, sr
->bind_point
);
5443 for (j
= 0; j
< sr
->bind_count
; ++j
)
5444 set_sampler(device
, v
->type
->basetype
, &rsrc_v
->elements
[j
], sr
->bind_point
+ j
);
5448 WARN("Unhandled shader resource %#x.\n", sr
->in_type
);
5454 static void d3d10_effect_pass_set_shader(struct d3d10_effect_pass
*pass
,
5455 const struct d3d10_effect_pass_shader_desc
*shader_desc
)
5457 ID3D10Device
*device
= pass
->technique
->effect
->device
;
5458 struct d3d10_effect_variable
*v
;
5460 v
= d3d10_array_get_element(shader_desc
->shader
, shader_desc
->index
);
5462 switch (v
->type
->basetype
)
5464 case D3D10_SVT_VERTEXSHADER
:
5465 ID3D10Device_VSSetShader(device
, v
->u
.shader
.shader
.vs
);
5467 case D3D10_SVT_PIXELSHADER
:
5468 ID3D10Device_PSSetShader(device
, v
->u
.shader
.shader
.ps
);
5470 case D3D10_SVT_GEOMETRYSHADER
:
5471 ID3D10Device_GSSetShader(device
, v
->u
.shader
.shader
.gs
);
5474 WARN("Unexpected shader type %u.\n", v
->type
->basetype
);
5477 apply_shader_resources(device
, v
);
5480 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_Apply(ID3D10EffectPass
*iface
, UINT flags
)
5482 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5483 ID3D10Device
*device
= pass
->technique
->effect
->device
;
5485 TRACE("iface %p, flags %#x\n", iface
, flags
);
5487 if (flags
) FIXME("Ignoring flags (%#x)\n", flags
);
5489 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
5491 if (pass
->vs
.shader
!= &null_shader_variable
)
5492 d3d10_effect_pass_set_shader(pass
, &pass
->vs
);
5493 if (pass
->gs
.shader
!= &null_shader_variable
)
5494 d3d10_effect_pass_set_shader(pass
, &pass
->gs
);
5495 if (pass
->ps
.shader
!= &null_shader_variable
)
5496 d3d10_effect_pass_set_shader(pass
, &pass
->ps
);
5497 if (pass
->rasterizer
)
5498 ID3D10Device_RSSetState(device
, pass
->rasterizer
->u
.state
.object
.rasterizer
);
5499 if (pass
->depth_stencil
)
5500 ID3D10Device_OMSetDepthStencilState(device
, pass
->depth_stencil
->u
.state
.object
.depth_stencil
,
5503 ID3D10Device_OMSetBlendState(device
, pass
->blend
->u
.state
.object
.blend
,
5504 pass
->blend_factor
, pass
->sample_mask
);
5509 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_ComputeStateBlockMask(ID3D10EffectPass
*iface
,
5510 D3D10_STATE_BLOCK_MASK
*mask
)
5512 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5514 FIXME("iface %p, mask %p semi-stub!\n", iface
, mask
);
5516 if (pass
->vs
.shader
!= &null_shader_variable
)
5517 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_VS
, 0, 1);
5518 if (pass
->ps
.shader
!= &null_shader_variable
)
5519 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_PS
, 0, 1);
5520 if (pass
->gs
.shader
!= &null_shader_variable
)
5521 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_GS
, 0, 1);
5522 if (pass
->rasterizer
)
5523 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_RS_RASTERIZER_STATE
, 0, 1);
5524 if (pass
->depth_stencil
)
5525 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_OM_DEPTH_STENCIL_STATE
, 0, 1);
5527 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_OM_BLEND_STATE
, 0, 1);
5532 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl
=
5534 /* ID3D10EffectPass methods */
5535 d3d10_effect_pass_IsValid
,
5536 d3d10_effect_pass_GetDesc
,
5537 d3d10_effect_pass_GetVertexShaderDesc
,
5538 d3d10_effect_pass_GetGeometryShaderDesc
,
5539 d3d10_effect_pass_GetPixelShaderDesc
,
5540 d3d10_effect_pass_GetAnnotationByIndex
,
5541 d3d10_effect_pass_GetAnnotationByName
,
5542 d3d10_effect_pass_Apply
,
5543 d3d10_effect_pass_ComputeStateBlockMask
,
5546 /* ID3D10EffectVariable methods */
5548 static BOOL STDMETHODCALLTYPE
d3d10_effect_variable_IsValid(ID3D10EffectVariable
*iface
)
5550 TRACE("iface %p\n", iface
);
5552 return impl_from_ID3D10EffectVariable(iface
) != &null_variable
;
5555 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_variable_GetType(ID3D10EffectVariable
*iface
)
5557 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5559 TRACE("iface %p\n", iface
);
5561 return &This
->type
->ID3D10EffectType_iface
;
5564 static HRESULT STDMETHODCALLTYPE
d3d10_effect_variable_GetDesc(ID3D10EffectVariable
*iface
,
5565 D3D10_EFFECT_VARIABLE_DESC
*desc
)
5567 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVariable(iface
);
5569 TRACE("iface %p, desc %p\n", iface
, desc
);
5571 if (!iface
->lpVtbl
->IsValid(iface
))
5573 WARN("Null variable specified\n");
5579 WARN("Invalid argument specified\n");
5580 return E_INVALIDARG
;
5583 /* FIXME: This isn't correct. Anonymous shaders let desc->ExplicitBindPoint untouched, but normal shaders set it! */
5584 memset(desc
, 0, sizeof(*desc
));
5585 desc
->Name
= v
->name
;
5586 desc
->Semantic
= v
->semantic
;
5587 desc
->Flags
= v
->flag
;
5588 desc
->Annotations
= v
->annotations
.count
;
5589 desc
->BufferOffset
= v
->buffer_offset
;
5591 if (v
->flag
& D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
)
5592 desc
->ExplicitBindPoint
= v
->explicit_bind_point
;
5597 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetAnnotationByIndex(
5598 ID3D10EffectVariable
*iface
, UINT index
)
5600 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectVariable(iface
);
5602 TRACE("iface %p, index %u\n", iface
, index
);
5604 return d3d10_annotation_get_by_index(&var
->annotations
, index
);
5607 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetAnnotationByName(
5608 ID3D10EffectVariable
*iface
, const char *name
)
5610 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectVariable(iface
);
5612 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5614 return d3d10_annotation_get_by_name(&var
->annotations
, name
);
5617 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetMemberByIndex(
5618 ID3D10EffectVariable
*iface
, UINT index
)
5620 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5621 struct d3d10_effect_variable
*m
;
5623 TRACE("iface %p, index %u\n", iface
, index
);
5625 if (index
>= This
->type
->member_count
)
5627 WARN("Invalid index specified\n");
5628 return &null_variable
.ID3D10EffectVariable_iface
;
5631 m
= &This
->members
[index
];
5633 TRACE("Returning member %p, %s\n", m
, debugstr_a(m
->name
));
5635 return &m
->ID3D10EffectVariable_iface
;
5638 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetMemberByName(
5639 ID3D10EffectVariable
*iface
, const char *name
)
5641 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5644 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5648 WARN("Invalid name specified\n");
5649 return &null_variable
.ID3D10EffectVariable_iface
;
5652 for (i
= 0; i
< This
->type
->member_count
; ++i
)
5654 struct d3d10_effect_variable
*m
= &This
->members
[i
];
5656 if (m
->name
&& !strcmp(m
->name
, name
))
5658 TRACE("Returning member %p\n", m
);
5659 return &m
->ID3D10EffectVariable_iface
;
5663 WARN("Invalid name specified\n");
5665 return &null_variable
.ID3D10EffectVariable_iface
;
5668 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetMemberBySemantic(
5669 ID3D10EffectVariable
*iface
, const char *semantic
)
5671 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5674 TRACE("iface %p, semantic %s.\n", iface
, debugstr_a(semantic
));
5678 WARN("Invalid semantic specified\n");
5679 return &null_variable
.ID3D10EffectVariable_iface
;
5682 for (i
= 0; i
< This
->type
->member_count
; ++i
)
5684 struct d3d10_effect_variable
*m
= &This
->members
[i
];
5686 if (m
->semantic
&& !stricmp(m
->semantic
, semantic
))
5688 TRACE("Returning member %p\n", m
);
5689 return &m
->ID3D10EffectVariable_iface
;
5693 WARN("Invalid semantic specified\n");
5695 return &null_variable
.ID3D10EffectVariable_iface
;
5698 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetElement(
5699 ID3D10EffectVariable
*iface
, UINT index
)
5701 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5702 struct d3d10_effect_variable
*v
;
5704 TRACE("iface %p, index %u\n", iface
, index
);
5706 if (index
>= This
->type
->element_count
)
5708 WARN("Invalid index specified\n");
5709 return &null_variable
.ID3D10EffectVariable_iface
;
5712 v
= &This
->elements
[index
];
5714 TRACE("Returning element %p, %s\n", v
, debugstr_a(v
->name
));
5716 return &v
->ID3D10EffectVariable_iface
;
5719 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_variable_GetParentConstantBuffer(
5720 ID3D10EffectVariable
*iface
)
5722 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5724 TRACE("iface %p\n", iface
);
5726 return (ID3D10EffectConstantBuffer
*)&This
->buffer
->ID3D10EffectVariable_iface
;
5729 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsScalar(
5730 ID3D10EffectVariable
*iface
)
5732 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5734 TRACE("iface %p\n", iface
);
5736 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_scalar_variable_vtbl
)
5737 return (ID3D10EffectScalarVariable
*)&This
->ID3D10EffectVariable_iface
;
5739 return (ID3D10EffectScalarVariable
*)&null_scalar_variable
.ID3D10EffectVariable_iface
;
5742 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsVector(
5743 ID3D10EffectVariable
*iface
)
5745 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5747 TRACE("iface %p\n", iface
);
5749 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_vector_variable_vtbl
)
5750 return (ID3D10EffectVectorVariable
*)&This
->ID3D10EffectVariable_iface
;
5752 return (ID3D10EffectVectorVariable
*)&null_vector_variable
.ID3D10EffectVariable_iface
;
5755 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsMatrix(
5756 ID3D10EffectVariable
*iface
)
5758 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5760 TRACE("iface %p\n", iface
);
5762 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_matrix_variable_vtbl
)
5763 return (ID3D10EffectMatrixVariable
*)&This
->ID3D10EffectVariable_iface
;
5765 return (ID3D10EffectMatrixVariable
*)&null_matrix_variable
.ID3D10EffectVariable_iface
;
5768 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsString(
5769 ID3D10EffectVariable
*iface
)
5771 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5773 TRACE("iface %p\n", iface
);
5775 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_string_variable_vtbl
)
5776 return (ID3D10EffectStringVariable
*)&This
->ID3D10EffectVariable_iface
;
5778 return (ID3D10EffectStringVariable
*)&null_string_variable
.ID3D10EffectVariable_iface
;
5781 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsShaderResource(
5782 ID3D10EffectVariable
*iface
)
5784 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5786 TRACE("iface %p\n", iface
);
5788 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_resource_variable_vtbl
)
5789 return (ID3D10EffectShaderResourceVariable
*)&This
->ID3D10EffectVariable_iface
;
5791 return (ID3D10EffectShaderResourceVariable
*)&null_shader_resource_variable
.ID3D10EffectVariable_iface
;
5794 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsRenderTargetView(
5795 ID3D10EffectVariable
*iface
)
5797 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5799 TRACE("iface %p\n", iface
);
5801 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_render_target_view_variable_vtbl
)
5802 return (ID3D10EffectRenderTargetViewVariable
*)&This
->ID3D10EffectVariable_iface
;
5804 return (ID3D10EffectRenderTargetViewVariable
*)&null_render_target_view_variable
.ID3D10EffectVariable_iface
;
5807 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsDepthStencilView(
5808 ID3D10EffectVariable
*iface
)
5810 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5812 TRACE("iface %p\n", iface
);
5814 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_view_variable_vtbl
)
5815 return (ID3D10EffectDepthStencilViewVariable
*)&This
->ID3D10EffectVariable_iface
;
5817 return (ID3D10EffectDepthStencilViewVariable
*)&null_depth_stencil_view_variable
.ID3D10EffectVariable_iface
;
5820 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_variable_AsConstantBuffer(
5821 ID3D10EffectVariable
*iface
)
5823 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5825 TRACE("iface %p\n", iface
);
5827 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_constant_buffer_vtbl
)
5828 return (ID3D10EffectConstantBuffer
*)&This
->ID3D10EffectVariable_iface
;
5830 return (ID3D10EffectConstantBuffer
*)&null_local_buffer
.ID3D10EffectVariable_iface
;
5833 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsShader(
5834 ID3D10EffectVariable
*iface
)
5836 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5838 TRACE("iface %p\n", iface
);
5840 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
)
5841 return (ID3D10EffectShaderVariable
*)&This
->ID3D10EffectVariable_iface
;
5843 return (ID3D10EffectShaderVariable
*)&null_shader_variable
.ID3D10EffectVariable_iface
;
5846 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsBlend(ID3D10EffectVariable
*iface
)
5848 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5850 TRACE("iface %p\n", iface
);
5852 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_blend_variable_vtbl
)
5853 return (ID3D10EffectBlendVariable
*)&This
->ID3D10EffectVariable_iface
;
5855 return (ID3D10EffectBlendVariable
*)&null_blend_variable
.ID3D10EffectVariable_iface
;
5858 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsDepthStencil(
5859 ID3D10EffectVariable
*iface
)
5861 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5863 TRACE("iface %p\n", iface
);
5865 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_variable_vtbl
)
5866 return (ID3D10EffectDepthStencilVariable
*)&This
->ID3D10EffectVariable_iface
;
5868 return (ID3D10EffectDepthStencilVariable
*)&null_depth_stencil_variable
.ID3D10EffectVariable_iface
;
5871 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsRasterizer(
5872 ID3D10EffectVariable
*iface
)
5874 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5876 TRACE("iface %p\n", iface
);
5878 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_rasterizer_variable_vtbl
)
5879 return (ID3D10EffectRasterizerVariable
*)&This
->ID3D10EffectVariable_iface
;
5881 return (ID3D10EffectRasterizerVariable
*)&null_rasterizer_variable
.ID3D10EffectVariable_iface
;
5884 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsSampler(
5885 ID3D10EffectVariable
*iface
)
5887 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5889 TRACE("iface %p\n", iface
);
5891 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_sampler_variable_vtbl
)
5892 return (ID3D10EffectSamplerVariable
*)&This
->ID3D10EffectVariable_iface
;
5894 return (ID3D10EffectSamplerVariable
*)&null_sampler_variable
.ID3D10EffectVariable_iface
;
5897 static HRESULT STDMETHODCALLTYPE
d3d10_effect_variable_SetRawValue(ID3D10EffectVariable
*iface
,
5898 void *data
, UINT offset
, UINT count
)
5900 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVariable(iface
);
5903 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
5905 if (!iface
->lpVtbl
->IsValid(iface
))
5907 WARN("Invalid variable.\n");
5911 is_buffer
= v
->type
->basetype
== D3D10_SVT_CBUFFER
|| v
->type
->basetype
== D3D10_SVT_TBUFFER
;
5913 if (v
->type
->type_class
== D3D10_SVC_OBJECT
&& !is_buffer
)
5915 WARN("Not supported on object variables of type %s.\n",
5916 debug_d3d10_shader_variable_type(v
->type
->basetype
));
5917 return D3DERR_INVALIDCALL
;
5922 offset
+= v
->buffer_offset
;
5926 memcpy(v
->u
.buffer
.local_buffer
+ offset
, data
, count
);
5927 v
->u
.buffer
.changed
= TRUE
;
5932 static HRESULT STDMETHODCALLTYPE
d3d10_effect_variable_GetRawValue(ID3D10EffectVariable
*iface
,
5933 void *data
, UINT offset
, UINT count
)
5935 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVariable(iface
);
5937 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
5939 if (!iface
->lpVtbl
->IsValid(iface
))
5941 WARN("Invalid variable.\n");
5945 return d3d10_effect_variable_get_raw_value(v
, data
, offset
, count
);
5948 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl
=
5950 /* ID3D10EffectVariable methods */
5951 d3d10_effect_variable_IsValid
,
5952 d3d10_effect_variable_GetType
,
5953 d3d10_effect_variable_GetDesc
,
5954 d3d10_effect_variable_GetAnnotationByIndex
,
5955 d3d10_effect_variable_GetAnnotationByName
,
5956 d3d10_effect_variable_GetMemberByIndex
,
5957 d3d10_effect_variable_GetMemberByName
,
5958 d3d10_effect_variable_GetMemberBySemantic
,
5959 d3d10_effect_variable_GetElement
,
5960 d3d10_effect_variable_GetParentConstantBuffer
,
5961 d3d10_effect_variable_AsScalar
,
5962 d3d10_effect_variable_AsVector
,
5963 d3d10_effect_variable_AsMatrix
,
5964 d3d10_effect_variable_AsString
,
5965 d3d10_effect_variable_AsShaderResource
,
5966 d3d10_effect_variable_AsRenderTargetView
,
5967 d3d10_effect_variable_AsDepthStencilView
,
5968 d3d10_effect_variable_AsConstantBuffer
,
5969 d3d10_effect_variable_AsShader
,
5970 d3d10_effect_variable_AsBlend
,
5971 d3d10_effect_variable_AsDepthStencil
,
5972 d3d10_effect_variable_AsRasterizer
,
5973 d3d10_effect_variable_AsSampler
,
5974 d3d10_effect_variable_SetRawValue
,
5975 d3d10_effect_variable_GetRawValue
,
5978 /* ID3D10EffectVariable methods */
5979 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectConstantBuffer(ID3D10EffectConstantBuffer
*iface
)
5981 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
5984 static BOOL STDMETHODCALLTYPE
d3d10_effect_constant_buffer_IsValid(ID3D10EffectConstantBuffer
*iface
)
5986 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectConstantBuffer(iface
);
5988 TRACE("iface %p.\n", iface
);
5990 return v
!= &null_local_buffer
;
5993 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetType(ID3D10EffectConstantBuffer
*iface
)
5995 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
5998 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetDesc(ID3D10EffectConstantBuffer
*iface
,
5999 D3D10_EFFECT_VARIABLE_DESC
*desc
)
6001 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
6004 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetAnnotationByIndex(
6005 ID3D10EffectConstantBuffer
*iface
, UINT index
)
6007 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
6010 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetAnnotationByName(
6011 ID3D10EffectConstantBuffer
*iface
, const char *name
)
6013 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
6016 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetMemberByIndex(
6017 ID3D10EffectConstantBuffer
*iface
, UINT index
)
6019 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
6022 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetMemberByName(
6023 ID3D10EffectConstantBuffer
*iface
, const char *name
)
6025 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
6028 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetMemberBySemantic(
6029 ID3D10EffectConstantBuffer
*iface
, const char *semantic
)
6031 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
6034 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetElement(
6035 ID3D10EffectConstantBuffer
*iface
, UINT index
)
6037 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
6040 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetParentConstantBuffer(
6041 ID3D10EffectConstantBuffer
*iface
)
6043 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
6046 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsScalar(
6047 ID3D10EffectConstantBuffer
*iface
)
6049 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
6052 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsVector(
6053 ID3D10EffectConstantBuffer
*iface
)
6055 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
6058 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsMatrix(
6059 ID3D10EffectConstantBuffer
*iface
)
6061 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
6064 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsString(
6065 ID3D10EffectConstantBuffer
*iface
)
6067 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
6070 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsShaderResource(
6071 ID3D10EffectConstantBuffer
*iface
)
6073 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
6076 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsRenderTargetView(
6077 ID3D10EffectConstantBuffer
*iface
)
6079 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
6082 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsDepthStencilView(
6083 ID3D10EffectConstantBuffer
*iface
)
6085 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
6088 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsConstantBuffer(
6089 ID3D10EffectConstantBuffer
*iface
)
6091 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
6094 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsShader(
6095 ID3D10EffectConstantBuffer
*iface
)
6097 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
6100 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsBlend(ID3D10EffectConstantBuffer
*iface
)
6102 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
6105 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsDepthStencil(
6106 ID3D10EffectConstantBuffer
*iface
)
6108 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
6111 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsRasterizer(
6112 ID3D10EffectConstantBuffer
*iface
)
6114 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
6117 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsSampler(
6118 ID3D10EffectConstantBuffer
*iface
)
6120 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
6123 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_SetRawValue(ID3D10EffectConstantBuffer
*iface
,
6124 void *data
, UINT offset
, UINT count
)
6126 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6129 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetRawValue(ID3D10EffectConstantBuffer
*iface
,
6130 void *data
, UINT offset
, UINT count
)
6132 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6135 /* ID3D10EffectConstantBuffer methods */
6136 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_SetConstantBuffer(ID3D10EffectConstantBuffer
*iface
,
6137 ID3D10Buffer
*buffer
)
6139 FIXME("iface %p, buffer %p stub!\n", iface
, buffer
);
6144 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetConstantBuffer(ID3D10EffectConstantBuffer
*iface
,
6145 ID3D10Buffer
**buffer
)
6147 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectConstantBuffer(iface
);
6149 TRACE("iface %p, buffer %p.\n", iface
, buffer
);
6151 if (!iface
->lpVtbl
->IsValid(iface
))
6153 WARN("Null variable specified.\n");
6157 if (v
->type
->basetype
!= D3D10_SVT_CBUFFER
)
6159 WARN("Wrong variable type %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
6160 return D3DERR_INVALIDCALL
;
6163 *buffer
= v
->u
.buffer
.buffer
;
6164 ID3D10Buffer_AddRef(*buffer
);
6169 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_SetTextureBuffer(ID3D10EffectConstantBuffer
*iface
,
6170 ID3D10ShaderResourceView
*view
)
6172 FIXME("iface %p, view %p stub!\n", iface
, view
);
6177 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetTextureBuffer(ID3D10EffectConstantBuffer
*iface
,
6178 ID3D10ShaderResourceView
**view
)
6180 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectConstantBuffer(iface
);
6182 FIXME("iface %p, view %p stub!\n", iface
, view
);
6184 if (!iface
->lpVtbl
->IsValid(iface
))
6186 WARN("Null variable specified.\n");
6190 if (v
->type
->basetype
!= D3D10_SVT_TBUFFER
)
6192 WARN("Wrong variable type %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
6193 return D3DERR_INVALIDCALL
;
6199 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl
=
6201 /* ID3D10EffectVariable methods */
6202 d3d10_effect_constant_buffer_IsValid
,
6203 d3d10_effect_constant_buffer_GetType
,
6204 d3d10_effect_constant_buffer_GetDesc
,
6205 d3d10_effect_constant_buffer_GetAnnotationByIndex
,
6206 d3d10_effect_constant_buffer_GetAnnotationByName
,
6207 d3d10_effect_constant_buffer_GetMemberByIndex
,
6208 d3d10_effect_constant_buffer_GetMemberByName
,
6209 d3d10_effect_constant_buffer_GetMemberBySemantic
,
6210 d3d10_effect_constant_buffer_GetElement
,
6211 d3d10_effect_constant_buffer_GetParentConstantBuffer
,
6212 d3d10_effect_constant_buffer_AsScalar
,
6213 d3d10_effect_constant_buffer_AsVector
,
6214 d3d10_effect_constant_buffer_AsMatrix
,
6215 d3d10_effect_constant_buffer_AsString
,
6216 d3d10_effect_constant_buffer_AsShaderResource
,
6217 d3d10_effect_constant_buffer_AsRenderTargetView
,
6218 d3d10_effect_constant_buffer_AsDepthStencilView
,
6219 d3d10_effect_constant_buffer_AsConstantBuffer
,
6220 d3d10_effect_constant_buffer_AsShader
,
6221 d3d10_effect_constant_buffer_AsBlend
,
6222 d3d10_effect_constant_buffer_AsDepthStencil
,
6223 d3d10_effect_constant_buffer_AsRasterizer
,
6224 d3d10_effect_constant_buffer_AsSampler
,
6225 d3d10_effect_constant_buffer_SetRawValue
,
6226 d3d10_effect_constant_buffer_GetRawValue
,
6227 /* ID3D10EffectConstantBuffer methods */
6228 d3d10_effect_constant_buffer_SetConstantBuffer
,
6229 d3d10_effect_constant_buffer_GetConstantBuffer
,
6230 d3d10_effect_constant_buffer_SetTextureBuffer
,
6231 d3d10_effect_constant_buffer_GetTextureBuffer
,
6235 static BOOL
get_value_as_bool(void *src_data
, D3D10_SHADER_VARIABLE_TYPE src_type
)
6239 case D3D10_SVT_FLOAT
:
6241 case D3D10_SVT_UINT
:
6242 case D3D10_SVT_BOOL
:
6243 if (*(DWORD
*)src_data
)
6254 static int get_value_as_int(void *src_data
, D3D10_SHADER_VARIABLE_TYPE src_type
)
6258 case D3D10_SVT_FLOAT
:
6259 return (int)(*(float *)src_data
);
6262 case D3D10_SVT_UINT
:
6263 return *(int *)src_data
;
6265 case D3D10_SVT_BOOL
:
6266 return get_value_as_bool(src_data
, src_type
);
6273 static float get_value_as_float(void *src_data
, D3D10_SHADER_VARIABLE_TYPE src_type
)
6277 case D3D10_SVT_FLOAT
:
6278 return *(float *)src_data
;
6281 case D3D10_SVT_UINT
:
6282 return (float)(*(int *)src_data
);
6284 case D3D10_SVT_BOOL
:
6285 return (float)get_value_as_bool(src_data
, src_type
);
6292 static void get_vector_as_type(BYTE
*dst_data
, D3D_SHADER_VARIABLE_TYPE dst_type
,
6293 BYTE
*src_data
, D3D_SHADER_VARIABLE_TYPE src_type
, unsigned int count
)
6295 DWORD
*src_data_dword
= (DWORD
*)src_data
;
6296 DWORD
*dst_data_dword
= (DWORD
*)dst_data
;
6299 for (i
= 0; i
< count
; ++i
, ++dst_data_dword
, ++src_data_dword
)
6301 if (dst_type
== src_type
)
6302 *dst_data_dword
= *src_data_dword
;
6307 case D3D10_SVT_FLOAT
:
6308 *(float *)dst_data_dword
= get_value_as_float(src_data_dword
, src_type
);
6312 case D3D10_SVT_UINT
:
6313 *(int *)dst_data_dword
= get_value_as_int(src_data_dword
, src_type
);
6316 case D3D10_SVT_BOOL
:
6317 *(BOOL
*)dst_data_dword
= get_value_as_bool(src_data_dword
, src_type
);
6321 *dst_data_dword
= 0;
6328 static void write_variable_to_buffer(struct d3d10_effect_variable
*variable
, void *src
,
6329 D3D_SHADER_VARIABLE_TYPE src_type
)
6331 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6332 D3D_SHADER_VARIABLE_TYPE dst_type
= variable
->type
->basetype
;
6334 get_vector_as_type(dst
, dst_type
, src
, src_type
, variable
->type
->column_count
);
6336 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6339 static void write_variable_array_to_buffer(struct d3d10_effect_variable
*variable
, void *src
,
6340 D3D_SHADER_VARIABLE_TYPE src_type
, unsigned int offset
, unsigned int count
)
6342 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6343 D3D_SHADER_VARIABLE_TYPE dst_type
= variable
->type
->basetype
;
6344 unsigned int element_size
, i
;
6345 BYTE
*cur_element
= src
;
6347 if (!variable
->type
->element_count
)
6349 write_variable_to_buffer(variable
, src
, src_type
);
6353 if (offset
>= variable
->type
->element_count
)
6355 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6359 if (count
> variable
->type
->element_count
- offset
)
6361 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6362 offset
, count
, variable
->type
->element_count
);
6363 count
= variable
->type
->element_count
- offset
;
6366 element_size
= variable
->type
->elementtype
->size_packed
;
6367 dst
+= variable
->type
->stride
* offset
;
6369 for (i
= 0; i
< count
; ++i
)
6371 get_vector_as_type(dst
, dst_type
, cur_element
, src_type
, variable
->type
->column_count
);
6373 cur_element
+= element_size
;
6374 dst
+= variable
->type
->stride
;
6377 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6380 static void read_variable_from_buffer(struct d3d10_effect_variable
*variable
, void *dst
,
6381 D3D_SHADER_VARIABLE_TYPE dst_type
)
6383 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6384 D3D_SHADER_VARIABLE_TYPE src_type
= variable
->type
->basetype
;
6386 get_vector_as_type(dst
, dst_type
, src
, src_type
, variable
->type
->column_count
);
6389 static void read_variable_array_from_buffer(struct d3d10_effect_variable
*variable
, void *dst
,
6390 D3D_SHADER_VARIABLE_TYPE dst_type
, unsigned int offset
, unsigned int count
)
6392 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6393 D3D_SHADER_VARIABLE_TYPE src_type
= variable
->type
->basetype
;
6394 unsigned int element_size
, i
;
6395 BYTE
*cur_element
= dst
;
6397 if (!variable
->type
->element_count
)
6399 read_variable_from_buffer(variable
, dst
, dst_type
);
6403 if (offset
>= variable
->type
->element_count
)
6405 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6409 if (count
> variable
->type
->element_count
- offset
)
6411 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6412 offset
, count
, variable
->type
->element_count
);
6413 count
= variable
->type
->element_count
- offset
;
6416 element_size
= variable
->type
->elementtype
->size_packed
;
6417 src
+= variable
->type
->stride
* offset
;
6419 for (i
= 0; i
< count
; ++i
)
6421 get_vector_as_type(cur_element
, dst_type
, src
, src_type
, variable
->type
->column_count
);
6423 cur_element
+= element_size
;
6424 src
+= variable
->type
->stride
;
6428 /* ID3D10EffectVariable methods */
6430 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectScalarVariable(ID3D10EffectScalarVariable
*iface
)
6432 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
6435 static BOOL STDMETHODCALLTYPE
d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable
*iface
)
6437 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectScalarVariable(iface
);
6439 TRACE("iface %p\n", iface
);
6441 return v
!= &null_scalar_variable
;
6444 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetType(
6445 ID3D10EffectScalarVariable
*iface
)
6447 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
6450 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetDesc(ID3D10EffectScalarVariable
*iface
,
6451 D3D10_EFFECT_VARIABLE_DESC
*desc
)
6453 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
6456 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetAnnotationByIndex(
6457 ID3D10EffectScalarVariable
*iface
, UINT index
)
6459 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
6462 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetAnnotationByName(
6463 ID3D10EffectScalarVariable
*iface
, const char *name
)
6465 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
6468 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetMemberByIndex(
6469 ID3D10EffectScalarVariable
*iface
, UINT index
)
6471 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
6474 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetMemberByName(
6475 ID3D10EffectScalarVariable
*iface
, const char *name
)
6477 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
6480 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetMemberBySemantic(
6481 ID3D10EffectScalarVariable
*iface
, const char *semantic
)
6483 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
6486 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetElement(
6487 ID3D10EffectScalarVariable
*iface
, UINT index
)
6489 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
6492 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetParentConstantBuffer(
6493 ID3D10EffectScalarVariable
*iface
)
6495 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
6498 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsScalar(
6499 ID3D10EffectScalarVariable
*iface
)
6501 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
6504 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsVector(
6505 ID3D10EffectScalarVariable
*iface
)
6507 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
6510 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsMatrix(
6511 ID3D10EffectScalarVariable
*iface
)
6513 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
6516 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsString(
6517 ID3D10EffectScalarVariable
*iface
)
6519 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
6522 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsShaderResource(
6523 ID3D10EffectScalarVariable
*iface
)
6525 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
6528 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsRenderTargetView(
6529 ID3D10EffectScalarVariable
*iface
)
6531 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
6534 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsDepthStencilView(
6535 ID3D10EffectScalarVariable
*iface
)
6537 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
6540 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsConstantBuffer(
6541 ID3D10EffectScalarVariable
*iface
)
6543 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
6546 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsShader(
6547 ID3D10EffectScalarVariable
*iface
)
6549 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
6552 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsBlend(
6553 ID3D10EffectScalarVariable
*iface
)
6555 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
6558 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsDepthStencil(
6559 ID3D10EffectScalarVariable
*iface
)
6561 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
6564 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsRasterizer(
6565 ID3D10EffectScalarVariable
*iface
)
6567 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
6570 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsSampler(
6571 ID3D10EffectScalarVariable
*iface
)
6573 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
6576 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetRawValue(ID3D10EffectScalarVariable
*iface
,
6577 void *data
, UINT offset
, UINT count
)
6579 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6582 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetRawValue(ID3D10EffectScalarVariable
*iface
,
6583 void *data
, UINT offset
, UINT count
)
6585 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6588 /* ID3D10EffectScalarVariable methods */
6590 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetFloat(ID3D10EffectScalarVariable
*iface
,
6593 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6595 TRACE("iface %p, value %.8e.\n", iface
, value
);
6596 write_variable_to_buffer(effect_var
, &value
, D3D10_SVT_FLOAT
);
6601 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable
*iface
,
6604 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6606 TRACE("iface %p, value %p.\n", iface
, value
);
6607 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_FLOAT
);
6612 /* Tests show that offset is ignored for scalar variables. */
6613 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetFloatArray(ID3D10EffectScalarVariable
*iface
,
6614 float *values
, UINT offset
, UINT count
)
6616 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6618 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6619 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, 0, count
);
6624 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable
*iface
,
6625 float *values
, UINT offset
, UINT count
)
6627 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6629 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6630 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, 0, count
);
6635 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable
*iface
,
6638 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6640 TRACE("iface %p, value %d.\n", iface
, value
);
6641 write_variable_to_buffer(effect_var
, &value
, D3D10_SVT_INT
);
6646 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetInt(ID3D10EffectScalarVariable
*iface
,
6649 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6651 TRACE("iface %p, value %p.\n", iface
, value
);
6652 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_INT
);
6657 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable
*iface
,
6658 int *values
, UINT offset
, UINT count
)
6660 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6662 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6663 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_INT
, 0, count
);
6668 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable
*iface
,
6669 int *values
, UINT offset
, UINT count
)
6671 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6673 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6674 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_INT
, 0, count
);
6679 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable
*iface
,
6682 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6684 TRACE("iface %p, value %d.\n", iface
, value
);
6685 write_variable_to_buffer(effect_var
, &value
, D3D10_SVT_BOOL
);
6690 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetBool(ID3D10EffectScalarVariable
*iface
,
6693 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6695 TRACE("iface %p, value %p.\n", iface
, value
);
6696 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_BOOL
);
6701 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable
*iface
,
6702 BOOL
*values
, UINT offset
, UINT count
)
6704 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6706 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6707 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_BOOL
, 0, count
);
6712 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable
*iface
,
6713 BOOL
*values
, UINT offset
, UINT count
)
6715 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6717 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6718 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_BOOL
, 0, count
);
6723 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl
=
6725 /* ID3D10EffectVariable methods */
6726 d3d10_effect_scalar_variable_IsValid
,
6727 d3d10_effect_scalar_variable_GetType
,
6728 d3d10_effect_scalar_variable_GetDesc
,
6729 d3d10_effect_scalar_variable_GetAnnotationByIndex
,
6730 d3d10_effect_scalar_variable_GetAnnotationByName
,
6731 d3d10_effect_scalar_variable_GetMemberByIndex
,
6732 d3d10_effect_scalar_variable_GetMemberByName
,
6733 d3d10_effect_scalar_variable_GetMemberBySemantic
,
6734 d3d10_effect_scalar_variable_GetElement
,
6735 d3d10_effect_scalar_variable_GetParentConstantBuffer
,
6736 d3d10_effect_scalar_variable_AsScalar
,
6737 d3d10_effect_scalar_variable_AsVector
,
6738 d3d10_effect_scalar_variable_AsMatrix
,
6739 d3d10_effect_scalar_variable_AsString
,
6740 d3d10_effect_scalar_variable_AsShaderResource
,
6741 d3d10_effect_scalar_variable_AsRenderTargetView
,
6742 d3d10_effect_scalar_variable_AsDepthStencilView
,
6743 d3d10_effect_scalar_variable_AsConstantBuffer
,
6744 d3d10_effect_scalar_variable_AsShader
,
6745 d3d10_effect_scalar_variable_AsBlend
,
6746 d3d10_effect_scalar_variable_AsDepthStencil
,
6747 d3d10_effect_scalar_variable_AsRasterizer
,
6748 d3d10_effect_scalar_variable_AsSampler
,
6749 d3d10_effect_scalar_variable_SetRawValue
,
6750 d3d10_effect_scalar_variable_GetRawValue
,
6751 /* ID3D10EffectScalarVariable methods */
6752 d3d10_effect_scalar_variable_SetFloat
,
6753 d3d10_effect_scalar_variable_GetFloat
,
6754 d3d10_effect_scalar_variable_SetFloatArray
,
6755 d3d10_effect_scalar_variable_GetFloatArray
,
6756 d3d10_effect_scalar_variable_SetInt
,
6757 d3d10_effect_scalar_variable_GetInt
,
6758 d3d10_effect_scalar_variable_SetIntArray
,
6759 d3d10_effect_scalar_variable_GetIntArray
,
6760 d3d10_effect_scalar_variable_SetBool
,
6761 d3d10_effect_scalar_variable_GetBool
,
6762 d3d10_effect_scalar_variable_SetBoolArray
,
6763 d3d10_effect_scalar_variable_GetBoolArray
,
6766 /* ID3D10EffectVariable methods */
6768 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectVectorVariable(ID3D10EffectVectorVariable
*iface
)
6770 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
6773 static BOOL STDMETHODCALLTYPE
d3d10_effect_vector_variable_IsValid(ID3D10EffectVectorVariable
*iface
)
6775 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVectorVariable(iface
);
6777 TRACE("iface %p\n", iface
);
6779 return v
!= &null_vector_variable
;
6782 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetType(
6783 ID3D10EffectVectorVariable
*iface
)
6785 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
6788 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetDesc(ID3D10EffectVectorVariable
*iface
,
6789 D3D10_EFFECT_VARIABLE_DESC
*desc
)
6791 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
6794 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetAnnotationByIndex(
6795 ID3D10EffectVectorVariable
*iface
, UINT index
)
6797 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
6800 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetAnnotationByName(
6801 ID3D10EffectVectorVariable
*iface
, const char *name
)
6803 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
6806 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetMemberByIndex(
6807 ID3D10EffectVectorVariable
*iface
, UINT index
)
6809 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
6812 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetMemberByName(
6813 ID3D10EffectVectorVariable
*iface
, const char *name
)
6815 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
6818 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetMemberBySemantic(
6819 ID3D10EffectVectorVariable
*iface
, const char *semantic
)
6821 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
6824 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetElement(
6825 ID3D10EffectVectorVariable
*iface
, UINT index
)
6827 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
6830 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetParentConstantBuffer(
6831 ID3D10EffectVectorVariable
*iface
)
6833 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
6836 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsScalar(
6837 ID3D10EffectVectorVariable
*iface
)
6839 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
6842 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsVector(
6843 ID3D10EffectVectorVariable
*iface
)
6845 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
6848 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsMatrix(
6849 ID3D10EffectVectorVariable
*iface
)
6851 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
6854 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsString(
6855 ID3D10EffectVectorVariable
*iface
)
6857 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
6860 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsShaderResource(
6861 ID3D10EffectVectorVariable
*iface
)
6863 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
6866 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsRenderTargetView(
6867 ID3D10EffectVectorVariable
*iface
)
6869 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
6872 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsDepthStencilView(
6873 ID3D10EffectVectorVariable
*iface
)
6875 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
6878 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsConstantBuffer(
6879 ID3D10EffectVectorVariable
*iface
)
6881 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
6884 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsShader(
6885 ID3D10EffectVectorVariable
*iface
)
6887 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
6890 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsBlend(
6891 ID3D10EffectVectorVariable
*iface
)
6893 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
6896 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsDepthStencil(
6897 ID3D10EffectVectorVariable
*iface
)
6899 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
6902 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsRasterizer(
6903 ID3D10EffectVectorVariable
*iface
)
6905 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
6908 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsSampler(
6909 ID3D10EffectVectorVariable
*iface
)
6911 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
6914 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetRawValue(ID3D10EffectVectorVariable
*iface
,
6915 void *data
, UINT offset
, UINT count
)
6917 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6920 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetRawValue(ID3D10EffectVectorVariable
*iface
,
6921 void *data
, UINT offset
, UINT count
)
6923 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6926 /* ID3D10EffectVectorVariable methods */
6928 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetBoolVector(ID3D10EffectVectorVariable
*iface
,
6931 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6933 TRACE("iface %p, value %p.\n", iface
, value
);
6934 write_variable_to_buffer(effect_var
, value
, D3D10_SVT_BOOL
);
6939 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetIntVector(ID3D10EffectVectorVariable
*iface
,
6942 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6944 TRACE("iface %p, value %p.\n", iface
, value
);
6945 write_variable_to_buffer(effect_var
, value
, D3D10_SVT_INT
);
6950 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetFloatVector(ID3D10EffectVectorVariable
*iface
,
6953 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6955 TRACE("iface %p, value %p.\n", iface
, value
);
6956 write_variable_to_buffer(effect_var
, value
, D3D10_SVT_FLOAT
);
6961 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable
*iface
,
6964 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6966 TRACE("iface %p, value %p.\n", iface
, value
);
6967 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_BOOL
);
6972 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetIntVector(ID3D10EffectVectorVariable
*iface
,
6975 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6977 TRACE("iface %p, value %p.\n", iface
, value
);
6978 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_INT
);
6983 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetFloatVector(ID3D10EffectVectorVariable
*iface
,
6986 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6988 TRACE("iface %p, value %p.\n", iface
, value
);
6989 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_FLOAT
);
6994 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable
*iface
,
6995 BOOL
*values
, UINT offset
, UINT count
)
6997 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6999 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
7000 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_BOOL
, offset
, count
);
7005 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetIntVectorArray(ID3D10EffectVectorVariable
*iface
,
7006 int *values
, UINT offset
, UINT count
)
7008 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
7010 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
7011 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_INT
, offset
, count
);
7016 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetFloatVectorArray(ID3D10EffectVectorVariable
*iface
,
7017 float *values
, UINT offset
, UINT count
)
7019 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
7021 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
7022 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, offset
, count
);
7027 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetBoolVectorArray(ID3D10EffectVectorVariable
*iface
,
7028 BOOL
*values
, UINT offset
, UINT count
)
7030 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
7032 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
7033 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_BOOL
, offset
, count
);
7038 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetIntVectorArray(ID3D10EffectVectorVariable
*iface
,
7039 int *values
, UINT offset
, UINT count
)
7041 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
7043 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
7044 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_INT
, offset
, count
);
7049 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetFloatVectorArray(ID3D10EffectVectorVariable
*iface
,
7050 float *values
, UINT offset
, UINT count
)
7052 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
7054 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
7055 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, offset
, count
);
7060 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl
=
7062 /* ID3D10EffectVariable methods */
7063 d3d10_effect_vector_variable_IsValid
,
7064 d3d10_effect_vector_variable_GetType
,
7065 d3d10_effect_vector_variable_GetDesc
,
7066 d3d10_effect_vector_variable_GetAnnotationByIndex
,
7067 d3d10_effect_vector_variable_GetAnnotationByName
,
7068 d3d10_effect_vector_variable_GetMemberByIndex
,
7069 d3d10_effect_vector_variable_GetMemberByName
,
7070 d3d10_effect_vector_variable_GetMemberBySemantic
,
7071 d3d10_effect_vector_variable_GetElement
,
7072 d3d10_effect_vector_variable_GetParentConstantBuffer
,
7073 d3d10_effect_vector_variable_AsScalar
,
7074 d3d10_effect_vector_variable_AsVector
,
7075 d3d10_effect_vector_variable_AsMatrix
,
7076 d3d10_effect_vector_variable_AsString
,
7077 d3d10_effect_vector_variable_AsShaderResource
,
7078 d3d10_effect_vector_variable_AsRenderTargetView
,
7079 d3d10_effect_vector_variable_AsDepthStencilView
,
7080 d3d10_effect_vector_variable_AsConstantBuffer
,
7081 d3d10_effect_vector_variable_AsShader
,
7082 d3d10_effect_vector_variable_AsBlend
,
7083 d3d10_effect_vector_variable_AsDepthStencil
,
7084 d3d10_effect_vector_variable_AsRasterizer
,
7085 d3d10_effect_vector_variable_AsSampler
,
7086 d3d10_effect_vector_variable_SetRawValue
,
7087 d3d10_effect_vector_variable_GetRawValue
,
7088 /* ID3D10EffectVectorVariable methods */
7089 d3d10_effect_vector_variable_SetBoolVector
,
7090 d3d10_effect_vector_variable_SetIntVector
,
7091 d3d10_effect_vector_variable_SetFloatVector
,
7092 d3d10_effect_vector_variable_GetBoolVector
,
7093 d3d10_effect_vector_variable_GetIntVector
,
7094 d3d10_effect_vector_variable_GetFloatVector
,
7095 d3d10_effect_vector_variable_SetBoolVectorArray
,
7096 d3d10_effect_vector_variable_SetIntVectorArray
,
7097 d3d10_effect_vector_variable_SetFloatVectorArray
,
7098 d3d10_effect_vector_variable_GetBoolVectorArray
,
7099 d3d10_effect_vector_variable_GetIntVectorArray
,
7100 d3d10_effect_vector_variable_GetFloatVectorArray
,
7103 static void write_matrix_to_buffer(struct d3d10_effect_variable
*variable
, void *dst_void
,
7104 struct d3d10_matrix
*src
, BOOL transpose
)
7106 unsigned int col_count
= !transpose
? variable
->type
->column_count
: variable
->type
->row_count
;
7107 unsigned int row_count
= !transpose
? variable
->type
->row_count
: variable
->type
->column_count
;
7108 BOOL major
= variable
->type
->type_class
== D3D10_SVC_MATRIX_COLUMNS
;
7109 float *dst
= dst_void
;
7110 unsigned int row
, col
;
7117 for (col
= 0; col
< col_count
; ++col
)
7119 for (row
= 0; row
< row_count
; ++row
)
7120 dst
[(col
* 4) + row
] = src
->m
[row
][col
];
7125 for (row
= 0; row
< row_count
; ++row
)
7127 for (col
= 0; col
< col_count
; ++col
)
7128 dst
[(row
* 4) + col
] = src
->m
[row
][col
];
7133 static void write_matrix_variable_to_buffer(struct d3d10_effect_variable
*variable
, void *src_data
, BOOL transpose
)
7135 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
7137 write_matrix_to_buffer(variable
, dst
, src_data
, transpose
);
7139 variable
->buffer
->u
.buffer
.changed
= TRUE
;
7142 static void write_matrix_variable_array_to_buffer(struct d3d10_effect_variable
*variable
, void *src_data
,
7143 unsigned int offset
, unsigned int count
, BOOL transpose
)
7145 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
7146 struct d3d10_matrix
*src
= src_data
;
7149 if (!variable
->type
->element_count
)
7151 write_matrix_variable_to_buffer(variable
, src_data
, transpose
);
7155 if (offset
>= variable
->type
->element_count
)
7157 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
7161 if (count
> variable
->type
->element_count
- offset
)
7163 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
7164 offset
, count
, variable
->type
->element_count
);
7165 count
= variable
->type
->element_count
- offset
;
7169 dst
+= variable
->type
->stride
* offset
;
7171 for (i
= 0; i
< count
; ++i
)
7173 write_matrix_to_buffer(variable
, dst
, &src
[i
], transpose
);
7175 dst
+= variable
->type
->stride
;
7178 variable
->buffer
->u
.buffer
.changed
= TRUE
;
7181 static void read_matrix_from_buffer(struct d3d10_effect_variable
*variable
, void *src_void
,
7182 struct d3d10_matrix
*dst
, BOOL transpose
)
7184 unsigned int col_count
= !transpose
? variable
->type
->column_count
: variable
->type
->row_count
;
7185 unsigned int row_count
= !transpose
? variable
->type
->row_count
: variable
->type
->column_count
;
7186 BOOL major
= variable
->type
->type_class
== D3D10_SVC_MATRIX_COLUMNS
;
7187 float *src
= src_void
;
7188 unsigned int row
, col
;
7195 for (col
= 0; col
< col_count
; ++col
)
7197 for (row
= 0; row
< row_count
; ++row
)
7198 dst
->m
[row
][col
] = src
[(col
* 4) + row
];
7203 for (row
= 0; row
< row_count
; ++row
)
7205 for (col
= 0; col
< col_count
; ++col
)
7206 dst
->m
[row
][col
] = src
[(row
* 4) + col
];
7211 static void read_matrix_variable_from_buffer(struct d3d10_effect_variable
*variable
, void *dst
, BOOL transpose
)
7213 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
7215 read_matrix_from_buffer(variable
, src
, dst
, transpose
);
7218 static void read_matrix_variable_array_from_buffer(struct d3d10_effect_variable
*variable
, void *dst_data
, UINT offset
,
7219 UINT count
, BOOL transpose
)
7221 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
7222 struct d3d10_matrix
*dst
= dst_data
;
7225 if (!variable
->type
->element_count
)
7227 read_matrix_variable_from_buffer(variable
, dst_data
, transpose
);
7231 if (offset
>= variable
->type
->element_count
)
7233 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
7237 if (count
> variable
->type
->element_count
- offset
)
7239 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
7240 offset
, count
, variable
->type
->element_count
);
7241 count
= variable
->type
->element_count
- offset
;
7245 src
+= variable
->type
->stride
* offset
;
7247 for (i
= 0; i
< count
; ++i
)
7249 read_matrix_from_buffer(variable
, src
, &dst
[i
], transpose
);
7251 src
+= variable
->type
->stride
;
7255 /* ID3D10EffectVariable methods */
7257 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectMatrixVariable(ID3D10EffectMatrixVariable
*iface
)
7259 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7262 static BOOL STDMETHODCALLTYPE
d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable
*iface
)
7264 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectMatrixVariable(iface
);
7266 TRACE("iface %p\n", iface
);
7268 return v
!= &null_matrix_variable
;
7271 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetType(
7272 ID3D10EffectMatrixVariable
*iface
)
7274 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7277 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetDesc(ID3D10EffectMatrixVariable
*iface
,
7278 D3D10_EFFECT_VARIABLE_DESC
*desc
)
7280 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7283 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetAnnotationByIndex(
7284 ID3D10EffectMatrixVariable
*iface
, UINT index
)
7286 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7289 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetAnnotationByName(
7290 ID3D10EffectMatrixVariable
*iface
, const char *name
)
7292 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7295 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMemberByIndex(
7296 ID3D10EffectMatrixVariable
*iface
, UINT index
)
7298 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7301 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMemberByName(
7302 ID3D10EffectMatrixVariable
*iface
, const char *name
)
7304 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7307 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMemberBySemantic(
7308 ID3D10EffectMatrixVariable
*iface
, const char *semantic
)
7310 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7313 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetElement(
7314 ID3D10EffectMatrixVariable
*iface
, UINT index
)
7316 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7319 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetParentConstantBuffer(
7320 ID3D10EffectMatrixVariable
*iface
)
7322 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7325 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsScalar(
7326 ID3D10EffectMatrixVariable
*iface
)
7328 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7331 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsVector(
7332 ID3D10EffectMatrixVariable
*iface
)
7334 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7337 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsMatrix(
7338 ID3D10EffectMatrixVariable
*iface
)
7340 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7343 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsString(
7344 ID3D10EffectMatrixVariable
*iface
)
7346 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7349 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsShaderResource(
7350 ID3D10EffectMatrixVariable
*iface
)
7352 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7355 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsRenderTargetView(
7356 ID3D10EffectMatrixVariable
*iface
)
7358 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7361 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsDepthStencilView(
7362 ID3D10EffectMatrixVariable
*iface
)
7364 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7367 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsConstantBuffer(
7368 ID3D10EffectMatrixVariable
*iface
)
7370 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7373 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsShader(
7374 ID3D10EffectMatrixVariable
*iface
)
7376 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7379 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsBlend(
7380 ID3D10EffectMatrixVariable
*iface
)
7382 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7385 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsDepthStencil(
7386 ID3D10EffectMatrixVariable
*iface
)
7388 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7391 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsRasterizer(
7392 ID3D10EffectMatrixVariable
*iface
)
7394 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7397 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsSampler(
7398 ID3D10EffectMatrixVariable
*iface
)
7400 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7403 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetRawValue(ID3D10EffectMatrixVariable
*iface
,
7404 void *data
, UINT offset
, UINT count
)
7406 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7409 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetRawValue(ID3D10EffectMatrixVariable
*iface
,
7410 void *data
, UINT offset
, UINT count
)
7412 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7415 /* ID3D10EffectMatrixVariable methods */
7417 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrix(ID3D10EffectMatrixVariable
*iface
,
7420 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7422 TRACE("iface %p, data %p.\n", iface
, data
);
7423 write_matrix_variable_to_buffer(var
, data
, FALSE
);
7428 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable
*iface
,
7431 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7433 TRACE("iface %p, data %p.\n", iface
, data
);
7434 read_matrix_variable_from_buffer(var
, data
, FALSE
);
7439 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable
*iface
,
7440 float *data
, UINT offset
, UINT count
)
7442 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7444 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7445 write_matrix_variable_array_to_buffer(var
, data
, offset
, count
, FALSE
);
7450 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable
*iface
,
7451 float *data
, UINT offset
, UINT count
)
7453 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7455 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7456 read_matrix_variable_array_from_buffer(var
, data
, offset
, count
, FALSE
);
7461 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable
*iface
,
7464 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7466 TRACE("iface %p, data %p.\n", iface
, data
);
7467 write_matrix_variable_to_buffer(var
, data
, TRUE
);
7472 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable
*iface
,
7475 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7477 TRACE("iface %p, data %p.\n", iface
, data
);
7478 read_matrix_variable_from_buffer(var
, data
, TRUE
);
7483 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable
*iface
,
7484 float *data
, UINT offset
, UINT count
)
7486 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7488 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7489 write_matrix_variable_array_to_buffer(var
, data
, offset
, count
, TRUE
);
7494 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable
*iface
,
7495 float *data
, UINT offset
, UINT count
)
7497 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7499 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7500 read_matrix_variable_array_from_buffer(var
, data
, offset
, count
, TRUE
);
7506 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl
=
7508 /* ID3D10EffectVariable methods */
7509 d3d10_effect_matrix_variable_IsValid
,
7510 d3d10_effect_matrix_variable_GetType
,
7511 d3d10_effect_matrix_variable_GetDesc
,
7512 d3d10_effect_matrix_variable_GetAnnotationByIndex
,
7513 d3d10_effect_matrix_variable_GetAnnotationByName
,
7514 d3d10_effect_matrix_variable_GetMemberByIndex
,
7515 d3d10_effect_matrix_variable_GetMemberByName
,
7516 d3d10_effect_matrix_variable_GetMemberBySemantic
,
7517 d3d10_effect_matrix_variable_GetElement
,
7518 d3d10_effect_matrix_variable_GetParentConstantBuffer
,
7519 d3d10_effect_matrix_variable_AsScalar
,
7520 d3d10_effect_matrix_variable_AsVector
,
7521 d3d10_effect_matrix_variable_AsMatrix
,
7522 d3d10_effect_matrix_variable_AsString
,
7523 d3d10_effect_matrix_variable_AsShaderResource
,
7524 d3d10_effect_matrix_variable_AsRenderTargetView
,
7525 d3d10_effect_matrix_variable_AsDepthStencilView
,
7526 d3d10_effect_matrix_variable_AsConstantBuffer
,
7527 d3d10_effect_matrix_variable_AsShader
,
7528 d3d10_effect_matrix_variable_AsBlend
,
7529 d3d10_effect_matrix_variable_AsDepthStencil
,
7530 d3d10_effect_matrix_variable_AsRasterizer
,
7531 d3d10_effect_matrix_variable_AsSampler
,
7532 d3d10_effect_matrix_variable_SetRawValue
,
7533 d3d10_effect_matrix_variable_GetRawValue
,
7534 /* ID3D10EffectMatrixVariable methods */
7535 d3d10_effect_matrix_variable_SetMatrix
,
7536 d3d10_effect_matrix_variable_GetMatrix
,
7537 d3d10_effect_matrix_variable_SetMatrixArray
,
7538 d3d10_effect_matrix_variable_GetMatrixArray
,
7539 d3d10_effect_matrix_variable_SetMatrixTranspose
,
7540 d3d10_effect_matrix_variable_GetMatrixTranspose
,
7541 d3d10_effect_matrix_variable_SetMatrixTransposeArray
,
7542 d3d10_effect_matrix_variable_GetMatrixTransposeArray
,
7545 /* ID3D10EffectVariable methods */
7547 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectStringVariable(ID3D10EffectStringVariable
*iface
)
7549 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7552 static BOOL STDMETHODCALLTYPE
d3d10_effect_string_variable_IsValid(ID3D10EffectStringVariable
*iface
)
7554 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectStringVariable(iface
);
7556 TRACE("iface %p\n", iface
);
7558 return v
!= &null_string_variable
;
7561 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetType(
7562 ID3D10EffectStringVariable
*iface
)
7564 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7567 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetDesc(ID3D10EffectStringVariable
*iface
,
7568 D3D10_EFFECT_VARIABLE_DESC
*desc
)
7570 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7573 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetAnnotationByIndex(
7574 ID3D10EffectStringVariable
*iface
, UINT index
)
7576 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7579 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetAnnotationByName(
7580 ID3D10EffectStringVariable
*iface
, const char *name
)
7582 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7585 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetMemberByIndex(
7586 ID3D10EffectStringVariable
*iface
, UINT index
)
7588 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7591 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetMemberByName(
7592 ID3D10EffectStringVariable
*iface
, const char *name
)
7594 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7597 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetMemberBySemantic(
7598 ID3D10EffectStringVariable
*iface
, const char *semantic
)
7600 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7603 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetElement(
7604 ID3D10EffectStringVariable
*iface
, UINT index
)
7606 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7609 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetParentConstantBuffer(
7610 ID3D10EffectStringVariable
*iface
)
7612 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7615 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsScalar(
7616 ID3D10EffectStringVariable
*iface
)
7618 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7621 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsVector(
7622 ID3D10EffectStringVariable
*iface
)
7624 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7627 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsMatrix(
7628 ID3D10EffectStringVariable
*iface
)
7630 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7633 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsString(
7634 ID3D10EffectStringVariable
*iface
)
7636 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7639 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsShaderResource(
7640 ID3D10EffectStringVariable
*iface
)
7642 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7645 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsRenderTargetView(
7646 ID3D10EffectStringVariable
*iface
)
7648 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7651 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsDepthStencilView(
7652 ID3D10EffectStringVariable
*iface
)
7654 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7657 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsConstantBuffer(
7658 ID3D10EffectStringVariable
*iface
)
7660 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7663 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsShader(
7664 ID3D10EffectStringVariable
*iface
)
7666 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7669 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsBlend(
7670 ID3D10EffectStringVariable
*iface
)
7672 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7675 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsDepthStencil(
7676 ID3D10EffectStringVariable
*iface
)
7678 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7681 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsRasterizer(
7682 ID3D10EffectStringVariable
*iface
)
7684 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7687 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsSampler(
7688 ID3D10EffectStringVariable
*iface
)
7690 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7693 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_SetRawValue(ID3D10EffectStringVariable
*iface
,
7694 void *data
, UINT offset
, UINT count
)
7696 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7699 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetRawValue(ID3D10EffectStringVariable
*iface
,
7700 void *data
, UINT offset
, UINT count
)
7702 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7705 /* ID3D10EffectStringVariable methods */
7707 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetString(ID3D10EffectStringVariable
*iface
,
7710 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectStringVariable(iface
);
7711 char *value
= (char *)var
->u
.buffer
.local_buffer
;
7713 TRACE("iface %p, str %p.\n", iface
, str
);
7719 return E_INVALIDARG
;
7726 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetStringArray(ID3D10EffectStringVariable
*iface
,
7727 const char **strs
, UINT offset
, UINT count
)
7729 FIXME("iface %p, strs %p, offset %u, count %u stub!\n", iface
, strs
, offset
, count
);
7735 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl
=
7737 /* ID3D10EffectVariable methods */
7738 d3d10_effect_string_variable_IsValid
,
7739 d3d10_effect_string_variable_GetType
,
7740 d3d10_effect_string_variable_GetDesc
,
7741 d3d10_effect_string_variable_GetAnnotationByIndex
,
7742 d3d10_effect_string_variable_GetAnnotationByName
,
7743 d3d10_effect_string_variable_GetMemberByIndex
,
7744 d3d10_effect_string_variable_GetMemberByName
,
7745 d3d10_effect_string_variable_GetMemberBySemantic
,
7746 d3d10_effect_string_variable_GetElement
,
7747 d3d10_effect_string_variable_GetParentConstantBuffer
,
7748 d3d10_effect_string_variable_AsScalar
,
7749 d3d10_effect_string_variable_AsVector
,
7750 d3d10_effect_string_variable_AsMatrix
,
7751 d3d10_effect_string_variable_AsString
,
7752 d3d10_effect_string_variable_AsShaderResource
,
7753 d3d10_effect_string_variable_AsRenderTargetView
,
7754 d3d10_effect_string_variable_AsDepthStencilView
,
7755 d3d10_effect_string_variable_AsConstantBuffer
,
7756 d3d10_effect_string_variable_AsShader
,
7757 d3d10_effect_string_variable_AsBlend
,
7758 d3d10_effect_string_variable_AsDepthStencil
,
7759 d3d10_effect_string_variable_AsRasterizer
,
7760 d3d10_effect_string_variable_AsSampler
,
7761 d3d10_effect_string_variable_SetRawValue
,
7762 d3d10_effect_string_variable_GetRawValue
,
7763 /* ID3D10EffectStringVariable methods */
7764 d3d10_effect_string_variable_GetString
,
7765 d3d10_effect_string_variable_GetStringArray
,
7768 static void set_shader_resource_variable(ID3D10ShaderResourceView
**src
, ID3D10ShaderResourceView
**dst
)
7774 ID3D10ShaderResourceView_AddRef(*src
);
7776 ID3D10ShaderResourceView_Release(*dst
);
7781 /* ID3D10EffectVariable methods */
7783 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectShaderResourceVariable(
7784 ID3D10EffectShaderResourceVariable
*iface
)
7786 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7789 static BOOL STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_IsValid(ID3D10EffectShaderResourceVariable
*iface
)
7791 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderResourceVariable(iface
);
7793 TRACE("iface %p.\n", iface
);
7795 return v
!= &null_shader_resource_variable
;
7798 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetType(
7799 ID3D10EffectShaderResourceVariable
*iface
)
7801 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7804 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetDesc(
7805 ID3D10EffectShaderResourceVariable
*iface
, D3D10_EFFECT_VARIABLE_DESC
*desc
)
7807 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7810 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetAnnotationByIndex(
7811 ID3D10EffectShaderResourceVariable
*iface
, UINT index
)
7813 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7816 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetAnnotationByName(
7817 ID3D10EffectShaderResourceVariable
*iface
, const char *name
)
7819 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7822 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetMemberByIndex(
7823 ID3D10EffectShaderResourceVariable
*iface
, UINT index
)
7825 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7828 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetMemberByName(
7829 ID3D10EffectShaderResourceVariable
*iface
, const char *name
)
7831 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7834 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetMemberBySemantic(
7835 ID3D10EffectShaderResourceVariable
*iface
, const char *semantic
)
7837 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7840 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetElement(
7841 ID3D10EffectShaderResourceVariable
*iface
, UINT index
)
7843 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7846 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetParentConstantBuffer(
7847 ID3D10EffectShaderResourceVariable
*iface
)
7849 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7852 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsScalar(
7853 ID3D10EffectShaderResourceVariable
*iface
)
7855 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7858 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsVector(
7859 ID3D10EffectShaderResourceVariable
*iface
)
7861 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7864 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsMatrix(
7865 ID3D10EffectShaderResourceVariable
*iface
)
7867 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7870 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsString(
7871 ID3D10EffectShaderResourceVariable
*iface
)
7873 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7876 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsShaderResource(
7877 ID3D10EffectShaderResourceVariable
*iface
)
7879 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7882 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsRenderTargetView(
7883 ID3D10EffectShaderResourceVariable
*iface
)
7885 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7888 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsDepthStencilView(
7889 ID3D10EffectShaderResourceVariable
*iface
)
7891 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7894 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsConstantBuffer(
7895 ID3D10EffectShaderResourceVariable
*iface
)
7897 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7900 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsShader(
7901 ID3D10EffectShaderResourceVariable
*iface
)
7903 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7906 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsBlend(
7907 ID3D10EffectShaderResourceVariable
*iface
)
7909 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7912 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsDepthStencil(
7913 ID3D10EffectShaderResourceVariable
*iface
)
7915 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7918 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsRasterizer(
7919 ID3D10EffectShaderResourceVariable
*iface
)
7921 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7924 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsSampler(
7925 ID3D10EffectShaderResourceVariable
*iface
)
7927 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7930 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_SetRawValue(
7931 ID3D10EffectShaderResourceVariable
*iface
, void *data
, UINT offset
, UINT count
)
7933 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7936 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetRawValue(
7937 ID3D10EffectShaderResourceVariable
*iface
, void *data
, UINT offset
, UINT count
)
7939 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7942 /* ID3D10EffectShaderResourceVariable methods */
7944 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_SetResource(
7945 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
*resource
)
7947 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderResourceVariable(iface
);
7949 TRACE("iface %p, resource %p.\n", iface
, resource
);
7951 if (!d3d10_effect_shader_resource_variable_IsValid(iface
))
7954 set_shader_resource_variable(&resource
, v
->u
.resource
.srv
);
7959 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetResource(
7960 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
**resource
)
7962 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
7967 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_SetResourceArray(
7968 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
**resources
, UINT offset
, UINT count
)
7970 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderResourceVariable(iface
);
7971 ID3D10ShaderResourceView
**rsrc_view
;
7974 TRACE("iface %p, resources %p, offset %u, count %u.\n", iface
, resources
, offset
, count
);
7976 if (!v
->type
->element_count
)
7977 return d3d10_effect_shader_resource_variable_SetResource(iface
, *resources
);
7979 if (offset
>= v
->type
->element_count
)
7981 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, v
->type
->element_count
);
7985 if (count
> v
->type
->element_count
- offset
)
7987 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
7988 offset
, count
, v
->type
->element_count
);
7989 count
= v
->type
->element_count
- offset
;
7992 rsrc_view
= &v
->u
.resource
.srv
[offset
];
7993 for (i
= 0; i
< count
; ++i
)
7994 set_shader_resource_variable(&resources
[i
], &rsrc_view
[i
]);
7999 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetResourceArray(
8000 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
**resources
, UINT offset
, UINT count
)
8002 FIXME("iface %p, resources %p, offset %u, count %u stub!\n", iface
, resources
, offset
, count
);
8008 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl
=
8010 /* ID3D10EffectVariable methods */
8011 d3d10_effect_shader_resource_variable_IsValid
,
8012 d3d10_effect_shader_resource_variable_GetType
,
8013 d3d10_effect_shader_resource_variable_GetDesc
,
8014 d3d10_effect_shader_resource_variable_GetAnnotationByIndex
,
8015 d3d10_effect_shader_resource_variable_GetAnnotationByName
,
8016 d3d10_effect_shader_resource_variable_GetMemberByIndex
,
8017 d3d10_effect_shader_resource_variable_GetMemberByName
,
8018 d3d10_effect_shader_resource_variable_GetMemberBySemantic
,
8019 d3d10_effect_shader_resource_variable_GetElement
,
8020 d3d10_effect_shader_resource_variable_GetParentConstantBuffer
,
8021 d3d10_effect_shader_resource_variable_AsScalar
,
8022 d3d10_effect_shader_resource_variable_AsVector
,
8023 d3d10_effect_shader_resource_variable_AsMatrix
,
8024 d3d10_effect_shader_resource_variable_AsString
,
8025 d3d10_effect_shader_resource_variable_AsShaderResource
,
8026 d3d10_effect_shader_resource_variable_AsRenderTargetView
,
8027 d3d10_effect_shader_resource_variable_AsDepthStencilView
,
8028 d3d10_effect_shader_resource_variable_AsConstantBuffer
,
8029 d3d10_effect_shader_resource_variable_AsShader
,
8030 d3d10_effect_shader_resource_variable_AsBlend
,
8031 d3d10_effect_shader_resource_variable_AsDepthStencil
,
8032 d3d10_effect_shader_resource_variable_AsRasterizer
,
8033 d3d10_effect_shader_resource_variable_AsSampler
,
8034 d3d10_effect_shader_resource_variable_SetRawValue
,
8035 d3d10_effect_shader_resource_variable_GetRawValue
,
8036 /* ID3D10EffectShaderResourceVariable methods */
8037 d3d10_effect_shader_resource_variable_SetResource
,
8038 d3d10_effect_shader_resource_variable_GetResource
,
8039 d3d10_effect_shader_resource_variable_SetResourceArray
,
8040 d3d10_effect_shader_resource_variable_GetResourceArray
,
8043 /* ID3D10EffectVariable methods */
8045 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectRenderTargetViewVariable(
8046 ID3D10EffectRenderTargetViewVariable
*iface
)
8048 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
8051 static BOOL STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_IsValid(
8052 ID3D10EffectRenderTargetViewVariable
*iface
)
8054 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRenderTargetViewVariable(iface
);
8056 TRACE("iface %p\n", iface
);
8058 return v
!= &null_render_target_view_variable
;
8061 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetType(
8062 ID3D10EffectRenderTargetViewVariable
*iface
)
8064 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8067 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetDesc(
8068 ID3D10EffectRenderTargetViewVariable
*iface
, D3D10_EFFECT_VARIABLE_DESC
*desc
)
8070 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8073 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetAnnotationByIndex(
8074 ID3D10EffectRenderTargetViewVariable
*iface
, UINT index
)
8076 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8079 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetAnnotationByName(
8080 ID3D10EffectRenderTargetViewVariable
*iface
, const char *name
)
8082 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8085 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetMemberByIndex(
8086 ID3D10EffectRenderTargetViewVariable
*iface
, UINT index
)
8088 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8091 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetMemberByName(
8092 ID3D10EffectRenderTargetViewVariable
*iface
, const char *name
)
8094 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8097 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetMemberBySemantic(
8098 ID3D10EffectRenderTargetViewVariable
*iface
, const char *semantic
)
8100 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8103 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetElement(
8104 ID3D10EffectRenderTargetViewVariable
*iface
, UINT index
)
8106 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8109 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetParentConstantBuffer(
8110 ID3D10EffectRenderTargetViewVariable
*iface
)
8112 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8115 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsScalar(
8116 ID3D10EffectRenderTargetViewVariable
*iface
)
8118 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8121 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsVector(
8122 ID3D10EffectRenderTargetViewVariable
*iface
)
8124 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8127 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsMatrix(
8128 ID3D10EffectRenderTargetViewVariable
*iface
)
8130 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8133 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsString(
8134 ID3D10EffectRenderTargetViewVariable
*iface
)
8136 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8139 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsShaderResource(
8140 ID3D10EffectRenderTargetViewVariable
*iface
)
8142 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8145 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsRenderTargetView(
8146 ID3D10EffectRenderTargetViewVariable
*iface
)
8148 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8151 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsDepthStencilView(
8152 ID3D10EffectRenderTargetViewVariable
*iface
)
8154 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8157 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsConstantBuffer(
8158 ID3D10EffectRenderTargetViewVariable
*iface
)
8160 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8163 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsShader(
8164 ID3D10EffectRenderTargetViewVariable
*iface
)
8166 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8169 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsBlend(
8170 ID3D10EffectRenderTargetViewVariable
*iface
)
8172 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8175 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsDepthStencil(
8176 ID3D10EffectRenderTargetViewVariable
*iface
)
8178 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8181 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsRasterizer(
8182 ID3D10EffectRenderTargetViewVariable
*iface
)
8184 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8187 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsSampler(
8188 ID3D10EffectRenderTargetViewVariable
*iface
)
8190 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8193 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_SetRawValue(
8194 ID3D10EffectRenderTargetViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
8196 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8199 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetRawValue(
8200 ID3D10EffectRenderTargetViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
8202 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8205 /* ID3D10EffectRenderTargetViewVariable methods */
8207 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_SetRenderTarget(
8208 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
*view
)
8210 FIXME("iface %p, view %p stub!\n", iface
, view
);
8215 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetRenderTarget(
8216 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
**view
)
8218 FIXME("iface %p, view %p stub!\n", iface
, view
);
8223 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_SetRenderTargetArray(
8224 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
**views
, UINT offset
, UINT count
)
8226 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
8231 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetRenderTargetArray(
8232 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
**views
, UINT offset
, UINT count
)
8234 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
8240 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl
=
8242 /* ID3D10EffectVariable methods */
8243 d3d10_effect_render_target_view_variable_IsValid
,
8244 d3d10_effect_render_target_view_variable_GetType
,
8245 d3d10_effect_render_target_view_variable_GetDesc
,
8246 d3d10_effect_render_target_view_variable_GetAnnotationByIndex
,
8247 d3d10_effect_render_target_view_variable_GetAnnotationByName
,
8248 d3d10_effect_render_target_view_variable_GetMemberByIndex
,
8249 d3d10_effect_render_target_view_variable_GetMemberByName
,
8250 d3d10_effect_render_target_view_variable_GetMemberBySemantic
,
8251 d3d10_effect_render_target_view_variable_GetElement
,
8252 d3d10_effect_render_target_view_variable_GetParentConstantBuffer
,
8253 d3d10_effect_render_target_view_variable_AsScalar
,
8254 d3d10_effect_render_target_view_variable_AsVector
,
8255 d3d10_effect_render_target_view_variable_AsMatrix
,
8256 d3d10_effect_render_target_view_variable_AsString
,
8257 d3d10_effect_render_target_view_variable_AsShaderResource
,
8258 d3d10_effect_render_target_view_variable_AsRenderTargetView
,
8259 d3d10_effect_render_target_view_variable_AsDepthStencilView
,
8260 d3d10_effect_render_target_view_variable_AsConstantBuffer
,
8261 d3d10_effect_render_target_view_variable_AsShader
,
8262 d3d10_effect_render_target_view_variable_AsBlend
,
8263 d3d10_effect_render_target_view_variable_AsDepthStencil
,
8264 d3d10_effect_render_target_view_variable_AsRasterizer
,
8265 d3d10_effect_render_target_view_variable_AsSampler
,
8266 d3d10_effect_render_target_view_variable_SetRawValue
,
8267 d3d10_effect_render_target_view_variable_GetRawValue
,
8268 /* ID3D10EffectRenderTargetViewVariable methods */
8269 d3d10_effect_render_target_view_variable_SetRenderTarget
,
8270 d3d10_effect_render_target_view_variable_GetRenderTarget
,
8271 d3d10_effect_render_target_view_variable_SetRenderTargetArray
,
8272 d3d10_effect_render_target_view_variable_GetRenderTargetArray
,
8275 /* ID3D10EffectVariable methods */
8277 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectDepthStencilViewVariable(
8278 ID3D10EffectDepthStencilViewVariable
*iface
)
8280 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
8283 static BOOL STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_IsValid(
8284 ID3D10EffectDepthStencilViewVariable
*iface
)
8286 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilViewVariable(iface
);
8288 TRACE("iface %p\n", iface
);
8290 return v
!= &null_depth_stencil_view_variable
;
8293 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetType(
8294 ID3D10EffectDepthStencilViewVariable
*iface
)
8296 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8299 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetDesc(
8300 ID3D10EffectDepthStencilViewVariable
*iface
, D3D10_EFFECT_VARIABLE_DESC
*desc
)
8302 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8305 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex(
8306 ID3D10EffectDepthStencilViewVariable
*iface
, UINT index
)
8308 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8311 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetAnnotationByName(
8312 ID3D10EffectDepthStencilViewVariable
*iface
, const char *name
)
8314 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8317 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetMemberByIndex(
8318 ID3D10EffectDepthStencilViewVariable
*iface
, UINT index
)
8320 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8323 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetMemberByName(
8324 ID3D10EffectDepthStencilViewVariable
*iface
, const char *name
)
8326 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8329 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic(
8330 ID3D10EffectDepthStencilViewVariable
*iface
, const char *semantic
)
8332 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8335 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetElement(
8336 ID3D10EffectDepthStencilViewVariable
*iface
, UINT index
)
8338 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8341 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer(
8342 ID3D10EffectDepthStencilViewVariable
*iface
)
8344 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8347 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsScalar(
8348 ID3D10EffectDepthStencilViewVariable
*iface
)
8350 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8353 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsVector(
8354 ID3D10EffectDepthStencilViewVariable
*iface
)
8356 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8359 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsMatrix(
8360 ID3D10EffectDepthStencilViewVariable
*iface
)
8362 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8365 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsString(
8366 ID3D10EffectDepthStencilViewVariable
*iface
)
8368 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8371 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsShaderResource(
8372 ID3D10EffectDepthStencilViewVariable
*iface
)
8374 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8377 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsRenderTargetView(
8378 ID3D10EffectDepthStencilViewVariable
*iface
)
8380 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8383 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsDepthStencilView(
8384 ID3D10EffectDepthStencilViewVariable
*iface
)
8386 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8389 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsConstantBuffer(
8390 ID3D10EffectDepthStencilViewVariable
*iface
)
8392 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8395 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsShader(
8396 ID3D10EffectDepthStencilViewVariable
*iface
)
8398 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8401 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsBlend(
8402 ID3D10EffectDepthStencilViewVariable
*iface
)
8404 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8407 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsDepthStencil(
8408 ID3D10EffectDepthStencilViewVariable
*iface
)
8410 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8413 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsRasterizer(
8414 ID3D10EffectDepthStencilViewVariable
*iface
)
8416 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8419 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsSampler(
8420 ID3D10EffectDepthStencilViewVariable
*iface
)
8422 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8425 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_SetRawValue(
8426 ID3D10EffectDepthStencilViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
8428 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8431 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetRawValue(
8432 ID3D10EffectDepthStencilViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
8434 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8437 /* ID3D10EffectDepthStencilViewVariable methods */
8439 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_SetDepthStencil(
8440 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
*view
)
8442 FIXME("iface %p, view %p stub!\n", iface
, view
);
8447 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetDepthStencil(
8448 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
**view
)
8450 FIXME("iface %p, view %p stub!\n", iface
, view
);
8455 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray(
8456 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
**views
, UINT offset
, UINT count
)
8458 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
8463 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray(
8464 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
**views
, UINT offset
, UINT count
)
8466 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
8472 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl
=
8474 /* ID3D10EffectVariable methods */
8475 d3d10_effect_depth_stencil_view_variable_IsValid
,
8476 d3d10_effect_depth_stencil_view_variable_GetType
,
8477 d3d10_effect_depth_stencil_view_variable_GetDesc
,
8478 d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex
,
8479 d3d10_effect_depth_stencil_view_variable_GetAnnotationByName
,
8480 d3d10_effect_depth_stencil_view_variable_GetMemberByIndex
,
8481 d3d10_effect_depth_stencil_view_variable_GetMemberByName
,
8482 d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic
,
8483 d3d10_effect_depth_stencil_view_variable_GetElement
,
8484 d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer
,
8485 d3d10_effect_depth_stencil_view_variable_AsScalar
,
8486 d3d10_effect_depth_stencil_view_variable_AsVector
,
8487 d3d10_effect_depth_stencil_view_variable_AsMatrix
,
8488 d3d10_effect_depth_stencil_view_variable_AsString
,
8489 d3d10_effect_depth_stencil_view_variable_AsShaderResource
,
8490 d3d10_effect_depth_stencil_view_variable_AsRenderTargetView
,
8491 d3d10_effect_depth_stencil_view_variable_AsDepthStencilView
,
8492 d3d10_effect_depth_stencil_view_variable_AsConstantBuffer
,
8493 d3d10_effect_depth_stencil_view_variable_AsShader
,
8494 d3d10_effect_depth_stencil_view_variable_AsBlend
,
8495 d3d10_effect_depth_stencil_view_variable_AsDepthStencil
,
8496 d3d10_effect_depth_stencil_view_variable_AsRasterizer
,
8497 d3d10_effect_depth_stencil_view_variable_AsSampler
,
8498 d3d10_effect_depth_stencil_view_variable_SetRawValue
,
8499 d3d10_effect_depth_stencil_view_variable_GetRawValue
,
8500 /* ID3D10EffectDepthStencilViewVariable methods */
8501 d3d10_effect_depth_stencil_view_variable_SetDepthStencil
,
8502 d3d10_effect_depth_stencil_view_variable_GetDepthStencil
,
8503 d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray
,
8504 d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray
,
8507 /* ID3D10EffectVariable methods */
8509 static BOOL STDMETHODCALLTYPE
d3d10_effect_shader_variable_IsValid(ID3D10EffectShaderVariable
*iface
)
8511 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8513 TRACE("iface %p\n", iface
);
8515 return v
!= &null_shader_variable
;
8518 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetType(
8519 ID3D10EffectShaderVariable
*iface
)
8521 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8524 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetDesc(ID3D10EffectShaderVariable
*iface
,
8525 D3D10_EFFECT_VARIABLE_DESC
*desc
)
8527 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8530 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetAnnotationByIndex(
8531 ID3D10EffectShaderVariable
*iface
, UINT index
)
8533 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8536 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetAnnotationByName(
8537 ID3D10EffectShaderVariable
*iface
, const char *name
)
8539 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8542 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetMemberByIndex(
8543 ID3D10EffectShaderVariable
*iface
, UINT index
)
8545 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8548 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetMemberByName(
8549 ID3D10EffectShaderVariable
*iface
, const char *name
)
8551 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8554 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetMemberBySemantic(
8555 ID3D10EffectShaderVariable
*iface
, const char *semantic
)
8557 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8560 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetElement(
8561 ID3D10EffectShaderVariable
*iface
, UINT index
)
8563 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8566 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetParentConstantBuffer(
8567 ID3D10EffectShaderVariable
*iface
)
8569 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8572 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsScalar(
8573 ID3D10EffectShaderVariable
*iface
)
8575 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8578 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsVector(
8579 ID3D10EffectShaderVariable
*iface
)
8581 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8584 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsMatrix(
8585 ID3D10EffectShaderVariable
*iface
)
8587 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8590 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsString(
8591 ID3D10EffectShaderVariable
*iface
)
8593 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8596 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsShaderResource(
8597 ID3D10EffectShaderVariable
*iface
)
8599 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8602 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsRenderTargetView(
8603 ID3D10EffectShaderVariable
*iface
)
8605 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8608 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsDepthStencilView(
8609 ID3D10EffectShaderVariable
*iface
)
8611 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8614 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsConstantBuffer(
8615 ID3D10EffectShaderVariable
*iface
)
8617 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8620 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsShader(
8621 ID3D10EffectShaderVariable
*iface
)
8623 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8626 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsBlend(
8627 ID3D10EffectShaderVariable
*iface
)
8629 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8632 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsDepthStencil(
8633 ID3D10EffectShaderVariable
*iface
)
8635 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8638 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsRasterizer(
8639 ID3D10EffectShaderVariable
*iface
)
8641 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8644 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsSampler(
8645 ID3D10EffectShaderVariable
*iface
)
8647 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8650 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_SetRawValue(
8651 ID3D10EffectShaderVariable
*iface
, void *data
, UINT offset
, UINT count
)
8653 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8656 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetRawValue(
8657 ID3D10EffectShaderVariable
*iface
, void *data
, UINT offset
, UINT count
)
8659 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8662 /* ID3D10EffectShaderVariable methods */
8664 static HRESULT
d3d10_get_shader_variable(struct d3d10_effect_variable
*v
, UINT shader_index
,
8665 struct d3d10_effect_shader_variable
**s
, D3D10_SHADER_VARIABLE_TYPE
*basetype
)
8669 v
= d3d10_array_get_element(v
, 0);
8674 if (basetype
) *basetype
= v
->type
->basetype
;
8678 /* Index is used as an offset from this variable. */
8680 for (i
= 0; i
< v
->effect
->shaders
.count
; ++i
)
8682 if (v
== v
->effect
->shaders
.v
[i
]) break;
8685 if (i
+ shader_index
>= v
->effect
->shaders
.count
)
8687 WARN("Invalid shader index %u.\n", shader_index
);
8691 *s
= &v
->effect
->shaders
.v
[i
+ shader_index
]->u
.shader
;
8692 if (basetype
) *basetype
= v
->effect
->shaders
.v
[i
+ shader_index
]->type
->basetype
;
8697 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetShaderDesc(
8698 ID3D10EffectShaderVariable
*iface
, UINT index
, D3D10_EFFECT_SHADER_DESC
*desc
)
8700 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8701 struct d3d10_effect_shader_variable
*s
;
8702 D3D10_SHADER_DESC shader_desc
;
8705 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
8707 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, NULL
)))
8710 memset(desc
, 0, sizeof(*desc
));
8711 if (s
->input_signature
)
8712 desc
->pInputSignature
= ID3D10Blob_GetBufferPointer(s
->input_signature
);
8713 desc
->SODecl
= s
->stream_output_declaration
;
8714 desc
->IsInline
= s
->isinline
;
8717 desc
->pBytecode
= ID3D10Blob_GetBufferPointer(s
->bytecode
);
8718 desc
->BytecodeLength
= ID3D10Blob_GetBufferSize(s
->bytecode
);
8722 if (SUCCEEDED(hr
= s
->reflection
->lpVtbl
->GetDesc(s
->reflection
, &shader_desc
)))
8724 desc
->NumInputSignatureEntries
= shader_desc
.InputParameters
;
8725 desc
->NumOutputSignatureEntries
= shader_desc
.OutputParameters
;
8732 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetVertexShader(
8733 ID3D10EffectShaderVariable
*iface
, UINT index
, ID3D10VertexShader
**shader
)
8735 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8736 struct d3d10_effect_shader_variable
*s
;
8737 D3D10_SHADER_VARIABLE_TYPE basetype
;
8740 TRACE("iface %p, index %u, shader %p.\n", iface
, index
, shader
);
8744 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, &basetype
)))
8747 if (basetype
!= D3D10_SVT_VERTEXSHADER
)
8749 WARN("Shader is not a vertex shader.\n");
8750 return D3DERR_INVALIDCALL
;
8753 if ((*shader
= s
->shader
.vs
))
8754 ID3D10VertexShader_AddRef(*shader
);
8759 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetGeometryShader(
8760 ID3D10EffectShaderVariable
*iface
, UINT index
, ID3D10GeometryShader
**shader
)
8762 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8763 struct d3d10_effect_shader_variable
*s
;
8764 D3D10_SHADER_VARIABLE_TYPE basetype
;
8767 TRACE("iface %p, index %u, shader %p.\n", iface
, index
, shader
);
8771 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, &basetype
)))
8774 if (basetype
!= D3D10_SVT_GEOMETRYSHADER
)
8776 WARN("Shader is not a geometry shader.\n");
8777 return D3DERR_INVALIDCALL
;
8780 if ((*shader
= s
->shader
.gs
))
8781 ID3D10GeometryShader_AddRef(*shader
);
8786 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetPixelShader(
8787 ID3D10EffectShaderVariable
*iface
, UINT index
, ID3D10PixelShader
**shader
)
8789 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8790 struct d3d10_effect_shader_variable
*s
;
8791 D3D10_SHADER_VARIABLE_TYPE basetype
;
8794 TRACE("iface %p, index %u, shader %p.\n", iface
, index
, shader
);
8798 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, &basetype
)))
8801 if (basetype
!= D3D10_SVT_PIXELSHADER
)
8803 WARN("Shader is not a pixel shader.\n");
8804 return D3DERR_INVALIDCALL
;
8807 if ((*shader
= s
->shader
.ps
))
8808 ID3D10PixelShader_AddRef(*shader
);
8813 static HRESULT
d3d10_get_shader_variable_signature(struct d3d10_effect_variable
*v
,
8814 UINT shader_index
, UINT element_index
, BOOL output
, D3D10_SIGNATURE_PARAMETER_DESC
*desc
)
8816 struct d3d10_effect_shader_variable
*s
;
8819 if (FAILED(hr
= d3d10_get_shader_variable(v
, shader_index
, &s
, NULL
)))
8823 return D3DERR_INVALIDCALL
;
8826 return s
->reflection
->lpVtbl
->GetOutputParameterDesc(s
->reflection
, element_index
, desc
);
8828 return s
->reflection
->lpVtbl
->GetInputParameterDesc(s
->reflection
, element_index
, desc
);
8831 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetInputSignatureElementDesc(
8832 ID3D10EffectShaderVariable
*iface
, UINT shader_index
, UINT element_index
,
8833 D3D10_SIGNATURE_PARAMETER_DESC
*desc
)
8835 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8837 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
8838 iface
, shader_index
, element_index
, desc
);
8840 if (!iface
->lpVtbl
->IsValid(iface
))
8842 WARN("Null variable specified\n");
8846 return d3d10_get_shader_variable_signature(v
, shader_index
, element_index
, FALSE
, desc
);
8849 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetOutputSignatureElementDesc(
8850 ID3D10EffectShaderVariable
*iface
, UINT shader_index
, UINT element_index
,
8851 D3D10_SIGNATURE_PARAMETER_DESC
*desc
)
8853 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8855 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
8856 iface
, shader_index
, element_index
, desc
);
8858 if (!iface
->lpVtbl
->IsValid(iface
))
8860 WARN("Null variable specified\n");
8864 return d3d10_get_shader_variable_signature(v
, shader_index
, element_index
, TRUE
, desc
);
8868 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl
=
8870 /* ID3D10EffectVariable methods */
8871 d3d10_effect_shader_variable_IsValid
,
8872 d3d10_effect_shader_variable_GetType
,
8873 d3d10_effect_shader_variable_GetDesc
,
8874 d3d10_effect_shader_variable_GetAnnotationByIndex
,
8875 d3d10_effect_shader_variable_GetAnnotationByName
,
8876 d3d10_effect_shader_variable_GetMemberByIndex
,
8877 d3d10_effect_shader_variable_GetMemberByName
,
8878 d3d10_effect_shader_variable_GetMemberBySemantic
,
8879 d3d10_effect_shader_variable_GetElement
,
8880 d3d10_effect_shader_variable_GetParentConstantBuffer
,
8881 d3d10_effect_shader_variable_AsScalar
,
8882 d3d10_effect_shader_variable_AsVector
,
8883 d3d10_effect_shader_variable_AsMatrix
,
8884 d3d10_effect_shader_variable_AsString
,
8885 d3d10_effect_shader_variable_AsShaderResource
,
8886 d3d10_effect_shader_variable_AsRenderTargetView
,
8887 d3d10_effect_shader_variable_AsDepthStencilView
,
8888 d3d10_effect_shader_variable_AsConstantBuffer
,
8889 d3d10_effect_shader_variable_AsShader
,
8890 d3d10_effect_shader_variable_AsBlend
,
8891 d3d10_effect_shader_variable_AsDepthStencil
,
8892 d3d10_effect_shader_variable_AsRasterizer
,
8893 d3d10_effect_shader_variable_AsSampler
,
8894 d3d10_effect_shader_variable_SetRawValue
,
8895 d3d10_effect_shader_variable_GetRawValue
,
8896 /* ID3D10EffectShaderVariable methods */
8897 d3d10_effect_shader_variable_GetShaderDesc
,
8898 d3d10_effect_shader_variable_GetVertexShader
,
8899 d3d10_effect_shader_variable_GetGeometryShader
,
8900 d3d10_effect_shader_variable_GetPixelShader
,
8901 d3d10_effect_shader_variable_GetInputSignatureElementDesc
,
8902 d3d10_effect_shader_variable_GetOutputSignatureElementDesc
,
8905 /* ID3D10EffectVariable methods */
8907 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectBlendVariable(
8908 ID3D10EffectBlendVariable
*iface
)
8910 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
8913 static BOOL STDMETHODCALLTYPE
d3d10_effect_blend_variable_IsValid(ID3D10EffectBlendVariable
*iface
)
8915 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectBlendVariable(iface
);
8917 TRACE("iface %p\n", iface
);
8919 return v
!= &null_blend_variable
;
8922 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetType(
8923 ID3D10EffectBlendVariable
*iface
)
8925 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8928 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetDesc(ID3D10EffectBlendVariable
*iface
,
8929 D3D10_EFFECT_VARIABLE_DESC
*desc
)
8931 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8934 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetAnnotationByIndex(
8935 ID3D10EffectBlendVariable
*iface
, UINT index
)
8937 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8940 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetAnnotationByName(
8941 ID3D10EffectBlendVariable
*iface
, const char *name
)
8943 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8946 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetMemberByIndex(
8947 ID3D10EffectBlendVariable
*iface
, UINT index
)
8949 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8952 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetMemberByName(
8953 ID3D10EffectBlendVariable
*iface
, const char *name
)
8955 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8958 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetMemberBySemantic(
8959 ID3D10EffectBlendVariable
*iface
, const char *semantic
)
8961 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8964 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetElement(
8965 ID3D10EffectBlendVariable
*iface
, UINT index
)
8967 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8970 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetParentConstantBuffer(
8971 ID3D10EffectBlendVariable
*iface
)
8973 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8976 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsScalar(
8977 ID3D10EffectBlendVariable
*iface
)
8979 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8982 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsVector(
8983 ID3D10EffectBlendVariable
*iface
)
8985 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8988 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsMatrix(
8989 ID3D10EffectBlendVariable
*iface
)
8991 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8994 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsString(
8995 ID3D10EffectBlendVariable
*iface
)
8997 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
9000 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsShaderResource(
9001 ID3D10EffectBlendVariable
*iface
)
9003 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
9006 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsRenderTargetView(
9007 ID3D10EffectBlendVariable
*iface
)
9009 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
9012 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsDepthStencilView(
9013 ID3D10EffectBlendVariable
*iface
)
9015 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
9018 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsConstantBuffer(
9019 ID3D10EffectBlendVariable
*iface
)
9021 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
9024 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsShader(
9025 ID3D10EffectBlendVariable
*iface
)
9027 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
9030 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsBlend(
9031 ID3D10EffectBlendVariable
*iface
)
9033 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
9036 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsDepthStencil(
9037 ID3D10EffectBlendVariable
*iface
)
9039 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
9042 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsRasterizer(
9043 ID3D10EffectBlendVariable
*iface
)
9045 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
9048 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsSampler(
9049 ID3D10EffectBlendVariable
*iface
)
9051 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
9054 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_SetRawValue(ID3D10EffectBlendVariable
*iface
,
9055 void *data
, UINT offset
, UINT count
)
9057 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9060 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetRawValue(ID3D10EffectBlendVariable
*iface
,
9061 void *data
, UINT offset
, UINT count
)
9063 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9066 /* ID3D10EffectBlendVariable methods */
9068 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetBlendState(ID3D10EffectBlendVariable
*iface
,
9069 UINT index
, ID3D10BlendState
**blend_state
)
9071 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectBlendVariable(iface
);
9073 TRACE("iface %p, index %u, blend_state %p.\n", iface
, index
, blend_state
);
9075 if (!iface
->lpVtbl
->IsValid(iface
))
9077 WARN("Invalid variable.\n");
9081 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->blend_states
)))
9084 if ((*blend_state
= v
->u
.state
.object
.blend
))
9085 ID3D10BlendState_AddRef(*blend_state
);
9090 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetBackingStore(ID3D10EffectBlendVariable
*iface
,
9091 UINT index
, D3D10_BLEND_DESC
*desc
)
9093 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectBlendVariable(iface
);
9095 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9097 if (!iface
->lpVtbl
->IsValid(iface
))
9099 WARN("Invalid variable.\n");
9103 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->blend_states
)))
9106 *desc
= v
->u
.state
.desc
.blend
;
9111 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl
=
9113 /* ID3D10EffectVariable methods */
9114 d3d10_effect_blend_variable_IsValid
,
9115 d3d10_effect_blend_variable_GetType
,
9116 d3d10_effect_blend_variable_GetDesc
,
9117 d3d10_effect_blend_variable_GetAnnotationByIndex
,
9118 d3d10_effect_blend_variable_GetAnnotationByName
,
9119 d3d10_effect_blend_variable_GetMemberByIndex
,
9120 d3d10_effect_blend_variable_GetMemberByName
,
9121 d3d10_effect_blend_variable_GetMemberBySemantic
,
9122 d3d10_effect_blend_variable_GetElement
,
9123 d3d10_effect_blend_variable_GetParentConstantBuffer
,
9124 d3d10_effect_blend_variable_AsScalar
,
9125 d3d10_effect_blend_variable_AsVector
,
9126 d3d10_effect_blend_variable_AsMatrix
,
9127 d3d10_effect_blend_variable_AsString
,
9128 d3d10_effect_blend_variable_AsShaderResource
,
9129 d3d10_effect_blend_variable_AsRenderTargetView
,
9130 d3d10_effect_blend_variable_AsDepthStencilView
,
9131 d3d10_effect_blend_variable_AsConstantBuffer
,
9132 d3d10_effect_blend_variable_AsShader
,
9133 d3d10_effect_blend_variable_AsBlend
,
9134 d3d10_effect_blend_variable_AsDepthStencil
,
9135 d3d10_effect_blend_variable_AsRasterizer
,
9136 d3d10_effect_blend_variable_AsSampler
,
9137 d3d10_effect_blend_variable_SetRawValue
,
9138 d3d10_effect_blend_variable_GetRawValue
,
9139 /* ID3D10EffectBlendVariable methods */
9140 d3d10_effect_blend_variable_GetBlendState
,
9141 d3d10_effect_blend_variable_GetBackingStore
,
9144 /* ID3D10EffectVariable methods */
9146 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectDepthStencilVariable(
9147 ID3D10EffectDepthStencilVariable
*iface
)
9149 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
9152 static BOOL STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_IsValid(ID3D10EffectDepthStencilVariable
*iface
)
9154 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilVariable(iface
);
9156 TRACE("iface %p\n", iface
);
9158 return v
!= &null_depth_stencil_variable
;
9161 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetType(
9162 ID3D10EffectDepthStencilVariable
*iface
)
9164 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
9167 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetDesc(ID3D10EffectDepthStencilVariable
*iface
,
9168 D3D10_EFFECT_VARIABLE_DESC
*desc
)
9170 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
9173 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetAnnotationByIndex(
9174 ID3D10EffectDepthStencilVariable
*iface
, UINT index
)
9176 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
9179 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetAnnotationByName(
9180 ID3D10EffectDepthStencilVariable
*iface
, const char *name
)
9182 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
9185 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetMemberByIndex(
9186 ID3D10EffectDepthStencilVariable
*iface
, UINT index
)
9188 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
9191 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetMemberByName(
9192 ID3D10EffectDepthStencilVariable
*iface
, const char *name
)
9194 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
9197 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetMemberBySemantic(
9198 ID3D10EffectDepthStencilVariable
*iface
, const char *semantic
)
9200 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
9203 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetElement(
9204 ID3D10EffectDepthStencilVariable
*iface
, UINT index
)
9206 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
9209 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetParentConstantBuffer(
9210 ID3D10EffectDepthStencilVariable
*iface
)
9212 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
9215 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsScalar(
9216 ID3D10EffectDepthStencilVariable
*iface
)
9218 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
9221 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsVector(
9222 ID3D10EffectDepthStencilVariable
*iface
)
9224 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
9227 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsMatrix(
9228 ID3D10EffectDepthStencilVariable
*iface
)
9230 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
9233 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsString(
9234 ID3D10EffectDepthStencilVariable
*iface
)
9236 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
9239 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsShaderResource(
9240 ID3D10EffectDepthStencilVariable
*iface
)
9242 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
9245 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsRenderTargetView(
9246 ID3D10EffectDepthStencilVariable
*iface
)
9248 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
9251 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsDepthStencilView(
9252 ID3D10EffectDepthStencilVariable
*iface
)
9254 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
9257 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsConstantBuffer(
9258 ID3D10EffectDepthStencilVariable
*iface
)
9260 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
9263 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsShader(
9264 ID3D10EffectDepthStencilVariable
*iface
)
9266 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
9269 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsBlend(
9270 ID3D10EffectDepthStencilVariable
*iface
)
9272 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
9275 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsDepthStencil(
9276 ID3D10EffectDepthStencilVariable
*iface
)
9278 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
9281 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsRasterizer(
9282 ID3D10EffectDepthStencilVariable
*iface
)
9284 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
9287 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsSampler(
9288 ID3D10EffectDepthStencilVariable
*iface
)
9290 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
9293 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_SetRawValue(ID3D10EffectDepthStencilVariable
*iface
,
9294 void *data
, UINT offset
, UINT count
)
9296 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9299 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetRawValue(ID3D10EffectDepthStencilVariable
*iface
,
9300 void *data
, UINT offset
, UINT count
)
9302 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9305 /* ID3D10EffectDepthStencilVariable methods */
9307 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetDepthStencilState(ID3D10EffectDepthStencilVariable
*iface
,
9308 UINT index
, ID3D10DepthStencilState
**depth_stencil_state
)
9310 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilVariable(iface
);
9312 TRACE("iface %p, index %u, depth_stencil_state %p.\n", iface
, index
, depth_stencil_state
);
9314 if (!iface
->lpVtbl
->IsValid(iface
))
9316 WARN("Invalid variable.\n");
9320 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->ds_states
)))
9323 if ((*depth_stencil_state
= v
->u
.state
.object
.depth_stencil
))
9324 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
9329 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetBackingStore(ID3D10EffectDepthStencilVariable
*iface
,
9330 UINT index
, D3D10_DEPTH_STENCIL_DESC
*desc
)
9332 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilVariable(iface
);
9334 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9336 if (!iface
->lpVtbl
->IsValid(iface
))
9338 WARN("Invalid variable.\n");
9342 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->ds_states
)))
9345 d3d10_effect_update_dependent_props(&v
->u
.state
.dependencies
, &v
->u
.state
.desc
);
9347 *desc
= v
->u
.state
.desc
.depth_stencil
;
9352 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl
=
9354 /* ID3D10EffectVariable methods */
9355 d3d10_effect_depth_stencil_variable_IsValid
,
9356 d3d10_effect_depth_stencil_variable_GetType
,
9357 d3d10_effect_depth_stencil_variable_GetDesc
,
9358 d3d10_effect_depth_stencil_variable_GetAnnotationByIndex
,
9359 d3d10_effect_depth_stencil_variable_GetAnnotationByName
,
9360 d3d10_effect_depth_stencil_variable_GetMemberByIndex
,
9361 d3d10_effect_depth_stencil_variable_GetMemberByName
,
9362 d3d10_effect_depth_stencil_variable_GetMemberBySemantic
,
9363 d3d10_effect_depth_stencil_variable_GetElement
,
9364 d3d10_effect_depth_stencil_variable_GetParentConstantBuffer
,
9365 d3d10_effect_depth_stencil_variable_AsScalar
,
9366 d3d10_effect_depth_stencil_variable_AsVector
,
9367 d3d10_effect_depth_stencil_variable_AsMatrix
,
9368 d3d10_effect_depth_stencil_variable_AsString
,
9369 d3d10_effect_depth_stencil_variable_AsShaderResource
,
9370 d3d10_effect_depth_stencil_variable_AsRenderTargetView
,
9371 d3d10_effect_depth_stencil_variable_AsDepthStencilView
,
9372 d3d10_effect_depth_stencil_variable_AsConstantBuffer
,
9373 d3d10_effect_depth_stencil_variable_AsShader
,
9374 d3d10_effect_depth_stencil_variable_AsBlend
,
9375 d3d10_effect_depth_stencil_variable_AsDepthStencil
,
9376 d3d10_effect_depth_stencil_variable_AsRasterizer
,
9377 d3d10_effect_depth_stencil_variable_AsSampler
,
9378 d3d10_effect_depth_stencil_variable_SetRawValue
,
9379 d3d10_effect_depth_stencil_variable_GetRawValue
,
9380 /* ID3D10EffectDepthStencilVariable methods */
9381 d3d10_effect_depth_stencil_variable_GetDepthStencilState
,
9382 d3d10_effect_depth_stencil_variable_GetBackingStore
,
9385 /* ID3D10EffectVariable methods */
9387 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectRasterizerVariable(
9388 ID3D10EffectRasterizerVariable
*iface
)
9390 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
9393 static BOOL STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_IsValid(ID3D10EffectRasterizerVariable
*iface
)
9395 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRasterizerVariable(iface
);
9397 TRACE("iface %p\n", iface
);
9399 return v
!= &null_rasterizer_variable
;
9402 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetType(
9403 ID3D10EffectRasterizerVariable
*iface
)
9405 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
9408 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetDesc(ID3D10EffectRasterizerVariable
*iface
,
9409 D3D10_EFFECT_VARIABLE_DESC
*desc
)
9411 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
9414 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetAnnotationByIndex(
9415 ID3D10EffectRasterizerVariable
*iface
, UINT index
)
9417 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
9420 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetAnnotationByName(
9421 ID3D10EffectRasterizerVariable
*iface
, const char *name
)
9423 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
9426 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetMemberByIndex(
9427 ID3D10EffectRasterizerVariable
*iface
, UINT index
)
9429 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
9432 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetMemberByName(
9433 ID3D10EffectRasterizerVariable
*iface
, const char *name
)
9435 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
9438 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetMemberBySemantic(
9439 ID3D10EffectRasterizerVariable
*iface
, const char *semantic
)
9441 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
9444 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetElement(
9445 ID3D10EffectRasterizerVariable
*iface
, UINT index
)
9447 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
9450 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetParentConstantBuffer(
9451 ID3D10EffectRasterizerVariable
*iface
)
9453 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
9456 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsScalar(
9457 ID3D10EffectRasterizerVariable
*iface
)
9459 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
9462 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsVector(
9463 ID3D10EffectRasterizerVariable
*iface
)
9465 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
9468 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsMatrix(
9469 ID3D10EffectRasterizerVariable
*iface
)
9471 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
9474 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsString(
9475 ID3D10EffectRasterizerVariable
*iface
)
9477 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
9480 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsShaderResource(
9481 ID3D10EffectRasterizerVariable
*iface
)
9483 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
9486 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsRenderTargetView(
9487 ID3D10EffectRasterizerVariable
*iface
)
9489 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
9492 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsDepthStencilView(
9493 ID3D10EffectRasterizerVariable
*iface
)
9495 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
9498 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsConstantBuffer(
9499 ID3D10EffectRasterizerVariable
*iface
)
9501 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
9504 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsShader(
9505 ID3D10EffectRasterizerVariable
*iface
)
9507 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
9510 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsBlend(
9511 ID3D10EffectRasterizerVariable
*iface
)
9513 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
9516 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsDepthStencil(
9517 ID3D10EffectRasterizerVariable
*iface
)
9519 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
9522 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsRasterizer(
9523 ID3D10EffectRasterizerVariable
*iface
)
9525 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
9528 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsSampler(
9529 ID3D10EffectRasterizerVariable
*iface
)
9531 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
9534 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_SetRawValue(ID3D10EffectRasterizerVariable
*iface
,
9535 void *data
, UINT offset
, UINT count
)
9537 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9540 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetRawValue(ID3D10EffectRasterizerVariable
*iface
,
9541 void *data
, UINT offset
, UINT count
)
9543 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9546 /* ID3D10EffectRasterizerVariable methods */
9548 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetRasterizerState(ID3D10EffectRasterizerVariable
*iface
,
9549 UINT index
, ID3D10RasterizerState
**rasterizer_state
)
9551 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRasterizerVariable(iface
);
9553 TRACE("iface %p, index %u, rasterizer_state %p.\n", iface
, index
, rasterizer_state
);
9555 if (!iface
->lpVtbl
->IsValid(iface
))
9557 WARN("Invalid variable.\n");
9561 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->rs_states
)))
9564 if ((*rasterizer_state
= v
->u
.state
.object
.rasterizer
))
9565 ID3D10RasterizerState_AddRef(*rasterizer_state
);
9570 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetBackingStore(ID3D10EffectRasterizerVariable
*iface
,
9571 UINT index
, D3D10_RASTERIZER_DESC
*desc
)
9573 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRasterizerVariable(iface
);
9575 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9577 if (!iface
->lpVtbl
->IsValid(iface
))
9579 WARN("Invalid variable.\n");
9583 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->rs_states
)))
9586 *desc
= v
->u
.state
.desc
.rasterizer
;
9591 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl
=
9593 /* ID3D10EffectVariable methods */
9594 d3d10_effect_rasterizer_variable_IsValid
,
9595 d3d10_effect_rasterizer_variable_GetType
,
9596 d3d10_effect_rasterizer_variable_GetDesc
,
9597 d3d10_effect_rasterizer_variable_GetAnnotationByIndex
,
9598 d3d10_effect_rasterizer_variable_GetAnnotationByName
,
9599 d3d10_effect_rasterizer_variable_GetMemberByIndex
,
9600 d3d10_effect_rasterizer_variable_GetMemberByName
,
9601 d3d10_effect_rasterizer_variable_GetMemberBySemantic
,
9602 d3d10_effect_rasterizer_variable_GetElement
,
9603 d3d10_effect_rasterizer_variable_GetParentConstantBuffer
,
9604 d3d10_effect_rasterizer_variable_AsScalar
,
9605 d3d10_effect_rasterizer_variable_AsVector
,
9606 d3d10_effect_rasterizer_variable_AsMatrix
,
9607 d3d10_effect_rasterizer_variable_AsString
,
9608 d3d10_effect_rasterizer_variable_AsShaderResource
,
9609 d3d10_effect_rasterizer_variable_AsRenderTargetView
,
9610 d3d10_effect_rasterizer_variable_AsDepthStencilView
,
9611 d3d10_effect_rasterizer_variable_AsConstantBuffer
,
9612 d3d10_effect_rasterizer_variable_AsShader
,
9613 d3d10_effect_rasterizer_variable_AsBlend
,
9614 d3d10_effect_rasterizer_variable_AsDepthStencil
,
9615 d3d10_effect_rasterizer_variable_AsRasterizer
,
9616 d3d10_effect_rasterizer_variable_AsSampler
,
9617 d3d10_effect_rasterizer_variable_SetRawValue
,
9618 d3d10_effect_rasterizer_variable_GetRawValue
,
9619 /* ID3D10EffectRasterizerVariable methods */
9620 d3d10_effect_rasterizer_variable_GetRasterizerState
,
9621 d3d10_effect_rasterizer_variable_GetBackingStore
,
9624 /* ID3D10EffectVariable methods */
9626 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectSamplerVariable(
9627 ID3D10EffectSamplerVariable
*iface
)
9629 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
9632 static BOOL STDMETHODCALLTYPE
d3d10_effect_sampler_variable_IsValid(ID3D10EffectSamplerVariable
*iface
)
9634 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectSamplerVariable(iface
);
9636 TRACE("iface %p\n", iface
);
9638 return v
!= &null_sampler_variable
;
9641 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetType(
9642 ID3D10EffectSamplerVariable
*iface
)
9644 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
9647 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetDesc(ID3D10EffectSamplerVariable
*iface
,
9648 D3D10_EFFECT_VARIABLE_DESC
*desc
)
9650 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
9653 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetAnnotationByIndex(
9654 ID3D10EffectSamplerVariable
*iface
, UINT index
)
9656 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
9659 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetAnnotationByName(
9660 ID3D10EffectSamplerVariable
*iface
, const char *name
)
9662 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
9665 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetMemberByIndex(
9666 ID3D10EffectSamplerVariable
*iface
, UINT index
)
9668 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
9671 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetMemberByName(
9672 ID3D10EffectSamplerVariable
*iface
, const char *name
)
9674 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
9677 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetMemberBySemantic(
9678 ID3D10EffectSamplerVariable
*iface
, const char *semantic
)
9680 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
9683 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetElement(
9684 ID3D10EffectSamplerVariable
*iface
, UINT index
)
9686 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
9689 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetParentConstantBuffer(
9690 ID3D10EffectSamplerVariable
*iface
)
9692 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
9695 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsScalar(
9696 ID3D10EffectSamplerVariable
*iface
)
9698 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
9701 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsVector(
9702 ID3D10EffectSamplerVariable
*iface
)
9704 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
9707 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsMatrix(
9708 ID3D10EffectSamplerVariable
*iface
)
9710 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
9713 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsString(
9714 ID3D10EffectSamplerVariable
*iface
)
9716 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
9719 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsShaderResource(
9720 ID3D10EffectSamplerVariable
*iface
)
9722 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
9725 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsRenderTargetView(
9726 ID3D10EffectSamplerVariable
*iface
)
9728 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
9731 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsDepthStencilView(
9732 ID3D10EffectSamplerVariable
*iface
)
9734 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
9737 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsConstantBuffer(
9738 ID3D10EffectSamplerVariable
*iface
)
9740 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
9743 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsShader(
9744 ID3D10EffectSamplerVariable
*iface
)
9746 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
9749 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsBlend(
9750 ID3D10EffectSamplerVariable
*iface
)
9752 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
9755 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsDepthStencil(
9756 ID3D10EffectSamplerVariable
*iface
)
9758 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
9761 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsRasterizer(
9762 ID3D10EffectSamplerVariable
*iface
)
9764 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
9767 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsSampler(
9768 ID3D10EffectSamplerVariable
*iface
)
9770 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
9773 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_SetRawValue(ID3D10EffectSamplerVariable
*iface
,
9774 void *data
, UINT offset
, UINT count
)
9776 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9779 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetRawValue(ID3D10EffectSamplerVariable
*iface
,
9780 void *data
, UINT offset
, UINT count
)
9782 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9785 /* ID3D10EffectSamplerVariable methods */
9787 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetSampler(ID3D10EffectSamplerVariable
*iface
,
9788 UINT index
, ID3D10SamplerState
**sampler
)
9790 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectSamplerVariable(iface
);
9792 TRACE("iface %p, index %u, sampler %p.\n", iface
, index
, sampler
);
9794 if (!iface
->lpVtbl
->IsValid(iface
))
9796 WARN("Invalid variable.\n");
9800 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->samplers
)))
9803 if ((*sampler
= v
->u
.state
.object
.sampler
))
9804 ID3D10SamplerState_AddRef(*sampler
);
9809 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetBackingStore(ID3D10EffectSamplerVariable
*iface
,
9810 UINT index
, D3D10_SAMPLER_DESC
*desc
)
9812 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectSamplerVariable(iface
);
9814 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9816 if (!iface
->lpVtbl
->IsValid(iface
))
9818 WARN("Invalid variable.\n");
9822 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->samplers
)))
9825 *desc
= v
->u
.state
.desc
.sampler
.desc
;
9830 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl
=
9832 /* ID3D10EffectVariable methods */
9833 d3d10_effect_sampler_variable_IsValid
,
9834 d3d10_effect_sampler_variable_GetType
,
9835 d3d10_effect_sampler_variable_GetDesc
,
9836 d3d10_effect_sampler_variable_GetAnnotationByIndex
,
9837 d3d10_effect_sampler_variable_GetAnnotationByName
,
9838 d3d10_effect_sampler_variable_GetMemberByIndex
,
9839 d3d10_effect_sampler_variable_GetMemberByName
,
9840 d3d10_effect_sampler_variable_GetMemberBySemantic
,
9841 d3d10_effect_sampler_variable_GetElement
,
9842 d3d10_effect_sampler_variable_GetParentConstantBuffer
,
9843 d3d10_effect_sampler_variable_AsScalar
,
9844 d3d10_effect_sampler_variable_AsVector
,
9845 d3d10_effect_sampler_variable_AsMatrix
,
9846 d3d10_effect_sampler_variable_AsString
,
9847 d3d10_effect_sampler_variable_AsShaderResource
,
9848 d3d10_effect_sampler_variable_AsRenderTargetView
,
9849 d3d10_effect_sampler_variable_AsDepthStencilView
,
9850 d3d10_effect_sampler_variable_AsConstantBuffer
,
9851 d3d10_effect_sampler_variable_AsShader
,
9852 d3d10_effect_sampler_variable_AsBlend
,
9853 d3d10_effect_sampler_variable_AsDepthStencil
,
9854 d3d10_effect_sampler_variable_AsRasterizer
,
9855 d3d10_effect_sampler_variable_AsSampler
,
9856 d3d10_effect_sampler_variable_SetRawValue
,
9857 d3d10_effect_sampler_variable_GetRawValue
,
9858 /* ID3D10EffectSamplerVariable methods */
9859 d3d10_effect_sampler_variable_GetSampler
,
9860 d3d10_effect_sampler_variable_GetBackingStore
,
9863 /* ID3D10EffectType methods */
9865 static inline struct d3d10_effect_type
*impl_from_ID3D10EffectType(ID3D10EffectType
*iface
)
9867 return CONTAINING_RECORD(iface
, struct d3d10_effect_type
, ID3D10EffectType_iface
);
9870 static BOOL STDMETHODCALLTYPE
d3d10_effect_type_IsValid(ID3D10EffectType
*iface
)
9872 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9874 TRACE("iface %p\n", iface
);
9876 return This
!= &null_type
;
9879 static HRESULT STDMETHODCALLTYPE
d3d10_effect_type_GetDesc(ID3D10EffectType
*iface
, D3D10_EFFECT_TYPE_DESC
*desc
)
9881 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9883 TRACE("iface %p, desc %p\n", iface
, desc
);
9885 if (This
== &null_type
)
9887 WARN("Null type specified\n");
9893 WARN("Invalid argument specified\n");
9894 return E_INVALIDARG
;
9897 desc
->TypeName
= This
->name
;
9898 desc
->Class
= This
->type_class
;
9899 desc
->Type
= This
->basetype
;
9900 desc
->Elements
= This
->element_count
;
9901 desc
->Members
= This
->member_count
;
9902 desc
->Rows
= This
->row_count
;
9903 desc
->Columns
= This
->column_count
;
9904 desc
->PackedSize
= This
->size_packed
;
9905 desc
->UnpackedSize
= This
->size_unpacked
;
9906 desc
->Stride
= This
->stride
;
9911 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_type_GetMemberTypeByIndex(ID3D10EffectType
*iface
,
9914 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9915 struct d3d10_effect_type
*t
;
9917 TRACE("iface %p, index %u\n", iface
, index
);
9919 if (index
>= This
->member_count
)
9921 WARN("Invalid index specified\n");
9922 return &null_type
.ID3D10EffectType_iface
;
9925 t
= (&This
->members
[index
])->type
;
9927 TRACE("Returning member %p, %s\n", t
, debugstr_a(t
->name
));
9929 return &t
->ID3D10EffectType_iface
;
9932 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_type_GetMemberTypeByName(ID3D10EffectType
*iface
,
9935 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9938 TRACE("iface %p, name %s\n", iface
, debugstr_a(name
));
9942 WARN("Invalid name specified\n");
9943 return &null_type
.ID3D10EffectType_iface
;
9946 for (i
= 0; i
< This
->member_count
; ++i
)
9948 struct d3d10_effect_type_member
*typem
= &This
->members
[i
];
9950 if (typem
->name
&& !strcmp(typem
->name
, name
))
9952 TRACE("Returning type %p.\n", typem
->type
);
9953 return &typem
->type
->ID3D10EffectType_iface
;
9957 WARN("Invalid name specified\n");
9959 return &null_type
.ID3D10EffectType_iface
;
9962 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_type_GetMemberTypeBySemantic(ID3D10EffectType
*iface
,
9963 const char *semantic
)
9965 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9968 TRACE("iface %p, semantic %s\n", iface
, debugstr_a(semantic
));
9972 WARN("Invalid semantic specified\n");
9973 return &null_type
.ID3D10EffectType_iface
;
9976 for (i
= 0; i
< This
->member_count
; ++i
)
9978 struct d3d10_effect_type_member
*typem
= &This
->members
[i
];
9980 if (typem
->semantic
&& !stricmp(typem
->semantic
, semantic
))
9982 TRACE("Returning type %p.\n", typem
->type
);
9983 return &typem
->type
->ID3D10EffectType_iface
;
9987 WARN("Invalid semantic specified\n");
9989 return &null_type
.ID3D10EffectType_iface
;
9992 static const char * STDMETHODCALLTYPE
d3d10_effect_type_GetMemberName(ID3D10EffectType
*iface
, UINT index
)
9994 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9995 struct d3d10_effect_type_member
*typem
;
9997 TRACE("iface %p, index %u\n", iface
, index
);
9999 if (index
>= This
->member_count
)
10001 WARN("Invalid index specified\n");
10005 typem
= &This
->members
[index
];
10007 TRACE("Returning name %s\n", debugstr_a(typem
->name
));
10009 return typem
->name
;
10012 static const char * STDMETHODCALLTYPE
d3d10_effect_type_GetMemberSemantic(ID3D10EffectType
*iface
, UINT index
)
10014 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
10015 struct d3d10_effect_type_member
*typem
;
10017 TRACE("iface %p, index %u\n", iface
, index
);
10019 if (index
>= This
->member_count
)
10021 WARN("Invalid index specified\n");
10025 typem
= &This
->members
[index
];
10027 TRACE("Returning semantic %s\n", debugstr_a(typem
->semantic
));
10029 return typem
->semantic
;
10032 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl
=
10034 /* ID3D10EffectType */
10035 d3d10_effect_type_IsValid
,
10036 d3d10_effect_type_GetDesc
,
10037 d3d10_effect_type_GetMemberTypeByIndex
,
10038 d3d10_effect_type_GetMemberTypeByName
,
10039 d3d10_effect_type_GetMemberTypeBySemantic
,
10040 d3d10_effect_type_GetMemberName
,
10041 d3d10_effect_type_GetMemberSemantic
,
10044 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pool_QueryInterface(ID3D10EffectPool
*iface
,
10045 REFIID riid
, void **object
)
10047 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
10049 if (IsEqualGUID(riid
, &IID_ID3D10EffectPool
) ||
10050 IsEqualGUID(riid
, &IID_IUnknown
))
10052 IUnknown_AddRef(iface
);
10057 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
10060 return E_NOINTERFACE
;
10063 static ULONG STDMETHODCALLTYPE
d3d10_effect_pool_AddRef(ID3D10EffectPool
*iface
)
10065 struct d3d10_effect
*effect
= impl_from_ID3D10EffectPool(iface
);
10066 return d3d10_effect_AddRef(&effect
->ID3D10Effect_iface
);
10069 static ULONG STDMETHODCALLTYPE
d3d10_effect_pool_Release(ID3D10EffectPool
*iface
)
10071 struct d3d10_effect
*effect
= impl_from_ID3D10EffectPool(iface
);
10072 return d3d10_effect_Release(&effect
->ID3D10Effect_iface
);
10075 static ID3D10Effect
* STDMETHODCALLTYPE
d3d10_effect_pool_AsEffect(ID3D10EffectPool
*iface
)
10077 struct d3d10_effect
*effect
= impl_from_ID3D10EffectPool(iface
);
10079 TRACE("%p.\n", iface
);
10081 return &effect
->ID3D10Effect_iface
;
10084 const struct ID3D10EffectPoolVtbl d3d10_effect_pool_vtbl
=
10086 /* IUnknown methods */
10087 d3d10_effect_pool_QueryInterface
,
10088 d3d10_effect_pool_AddRef
,
10089 d3d10_effect_pool_Release
,
10090 /* ID3D10EffectPool methods */
10091 d3d10_effect_pool_AsEffect
,
10095 static int d3d10_effect_type_compare(const void *key
, const struct wine_rb_entry
*entry
)
10097 const struct d3d10_effect_type
*t
= WINE_RB_ENTRY_VALUE(entry
, const struct d3d10_effect_type
, entry
);
10098 const DWORD
*id
= key
;
10100 return *id
- t
->id
;
10103 static HRESULT
d3d10_create_effect(void *data
, SIZE_T data_size
, ID3D10Device
*device
,
10104 struct d3d10_effect
*pool
, unsigned int flags
, struct d3d10_effect
**effect
)
10106 struct d3d10_effect
*object
;
10110 return D3DERR_INVALIDCALL
;
10112 if (!(object
= calloc(1, sizeof(*object
))))
10113 return E_OUTOFMEMORY
;
10115 wine_rb_init(&object
->types
, d3d10_effect_type_compare
);
10116 object
->ID3D10Effect_iface
.lpVtbl
= flags
& D3D10_EFFECT_IS_POOL
?
10117 &d3d10_effect_pool_effect_vtbl
: &d3d10_effect_vtbl
;
10118 object
->ID3D10EffectPool_iface
.lpVtbl
= &d3d10_effect_pool_vtbl
;
10119 object
->refcount
= 1;
10120 ID3D10Device_AddRef(device
);
10121 object
->device
= device
;
10122 object
->pool
= pool
;
10123 object
->flags
= flags
;
10124 if (pool
) IUnknown_AddRef(&pool
->ID3D10Effect_iface
);
10126 hr
= d3d10_effect_parse(object
, data
, data_size
);
10129 ERR("Failed to parse effect\n");
10130 IUnknown_Release(&object
->ID3D10Effect_iface
);
10139 HRESULT WINAPI
D3D10CreateEffectFromMemory(void *data
, SIZE_T data_size
, UINT flags
,
10140 ID3D10Device
*device
, ID3D10EffectPool
*effect_pool
, ID3D10Effect
**effect
)
10142 struct d3d10_effect
*object
, *pool
= NULL
;
10145 TRACE("data %p, data_size %Iu, flags %#x, device %p, effect_pool %p, effect %p.\n",
10146 data
, data_size
, flags
, device
, effect_pool
, effect
);
10148 if (!(flags
& D3D10_EFFECT_COMPILE_CHILD_EFFECT
) != !effect_pool
)
10149 return E_INVALIDARG
;
10151 if (effect_pool
&& !(pool
= unsafe_impl_from_ID3D10EffectPool(effect_pool
)))
10153 WARN("External pool implementations are not supported.\n");
10154 return E_INVALIDARG
;
10157 if (FAILED(hr
= d3d10_create_effect(data
, data_size
, device
, pool
, 0, &object
)))
10159 WARN("Failed to create an effect, hr %#lx.\n", hr
);
10163 *effect
= &object
->ID3D10Effect_iface
;
10165 TRACE("Created effect %p\n", object
);
10170 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pool_effect_QueryInterface(ID3D10Effect
*iface
,
10171 REFIID riid
, void **object
)
10173 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
10175 TRACE("iface %p, riid %s, obj %p.\n", iface
, debugstr_guid(riid
), object
);
10177 return IUnknown_QueryInterface(&effect
->ID3D10EffectPool_iface
, riid
, object
);
10180 static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl
=
10182 /* IUnknown methods */
10183 d3d10_effect_pool_effect_QueryInterface
,
10184 d3d10_effect_AddRef
,
10185 d3d10_effect_Release
,
10186 /* ID3D10Effect methods */
10187 d3d10_effect_IsValid
,
10188 d3d10_effect_IsPool
,
10189 d3d10_effect_GetDevice
,
10190 d3d10_effect_GetDesc
,
10191 d3d10_effect_GetConstantBufferByIndex
,
10192 d3d10_effect_GetConstantBufferByName
,
10193 d3d10_effect_GetVariableByIndex
,
10194 d3d10_effect_GetVariableByName
,
10195 d3d10_effect_GetVariableBySemantic
,
10196 d3d10_effect_GetTechniqueByIndex
,
10197 d3d10_effect_GetTechniqueByName
,
10198 d3d10_effect_Optimize
,
10199 d3d10_effect_IsOptimized
,
10202 HRESULT WINAPI
D3D10CreateEffectPoolFromMemory(void *data
, SIZE_T data_size
, UINT fx_flags
,
10203 ID3D10Device
*device
, ID3D10EffectPool
**effect_pool
)
10205 struct d3d10_effect
*object
;
10208 TRACE("data %p, data_size %Iu, fx_flags %#x, device %p, effect_pool %p.\n",
10209 data
, data_size
, fx_flags
, device
, effect_pool
);
10212 return E_INVALIDARG
;
10214 if (FAILED(hr
= d3d10_create_effect(data
, data_size
, device
, NULL
,
10215 D3D10_EFFECT_IS_POOL
, &object
)))
10217 WARN("Failed to create an effect, hr %#lx.\n", hr
);
10221 *effect_pool
= &object
->ID3D10EffectPool_iface
;
10223 TRACE("Created effect pool %p.\n", object
);