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"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d10
);
28 #define MAKE_TAG(ch0, ch1, ch2, ch3) \
29 ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
30 ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
31 #define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
32 #define TAG_FX10 MAKE_TAG('F', 'X', '1', '0')
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_neg(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_rcp(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
] = 1.0f
/ args
[0][i
];
228 static void pres_frc(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
] = args
[0][i
] - floor(args
[0][i
]);
237 static void pres_sin(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
] = sin(args
[0][i
]);
246 static void pres_cos(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
] = cos(args
[0][i
]);
255 static void pres_asin(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
] = asinf(args
[0][i
]);
264 static void pres_acos(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
] = acosf(args
[0][i
]);
273 static void pres_atan(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
] = atanf(args
[0][i
]);
282 static void pres_ineg(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
284 int *arg1
= (int *)args
[0];
285 float *retval
= args
[1];
288 for (i
= 0; i
< instr
->comp_count
; ++i
)
291 retval
[i
] = *(float *)&v
;
295 static void pres_itof(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
297 float *retval
= args
[1];
300 for (i
= 0; i
< instr
->comp_count
; ++i
)
301 retval
[i
] = *(int *)&args
[0][i
];
304 static void pres_utof(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
306 float *retval
= args
[1];
309 for (i
= 0; i
< instr
->comp_count
; ++i
)
310 retval
[i
] = *(unsigned int *)&args
[0][i
];
313 static void pres_ftou(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
315 float *retval
= args
[1];
318 for (i
= 0; i
< instr
->comp_count
; ++i
)
320 unsigned int u
= args
[0][i
];
321 retval
[i
] = *(float *)&u
;
325 static void pres_ftob(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
327 float *retval
= args
[1];
330 for (i
= 0; i
< instr
->comp_count
; ++i
)
332 unsigned int u
= args
[0][i
] == 0.0f
? 0 : ~0u;
333 retval
[i
] = *(float *)&u
;
337 static void pres_min(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
339 float *retval
= args
[2];
342 for (i
= 0; i
< instr
->comp_count
; ++i
)
343 retval
[i
] = min(args
[0][instr
->scalar
? 0 : i
], args
[1][i
]);
346 static void pres_max(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
348 float *retval
= args
[2];
351 for (i
= 0; i
< instr
->comp_count
; ++i
)
352 retval
[i
] = max(args
[0][instr
->scalar
? 0 : i
], args
[1][i
]);
355 static void pres_add(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
357 float *retval
= args
[2];
360 for (i
= 0; i
< instr
->comp_count
; ++i
)
361 retval
[i
] = args
[0][instr
->scalar
? 0 : i
] + args
[1][i
];
364 static void pres_mul(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
366 float *retval
= args
[2];
369 for (i
= 0; i
< instr
->comp_count
; ++i
)
370 retval
[i
] = args
[0][instr
->scalar
? 0 : i
] * args
[1][i
];
373 static void pres_atan2(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
375 float *retval
= args
[2];
378 for (i
= 0; i
< instr
->comp_count
; ++i
)
379 retval
[i
] = atan2f(args
[0][instr
->scalar
? 0 : i
], args
[1][i
]);
382 static void pres_div(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
384 float *retval
= args
[2];
387 for (i
= 0; i
< instr
->comp_count
; ++i
)
388 retval
[i
] = args
[0][instr
->scalar
? 0 : i
] / args
[1][i
];
391 static void pres_iadd(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
393 int *arg1
= (int *)args
[0];
394 int *arg2
= (int *)args
[1];
395 float *retval
= args
[2];
398 for (i
= 0; i
< instr
->comp_count
; ++i
)
400 int v
= arg1
[instr
->scalar
? 0 : i
] + arg2
[i
];
401 retval
[i
] = *(float *)&v
;
405 static void pres_udiv(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
407 unsigned int *arg1
= (unsigned int *)args
[0];
408 unsigned int *arg2
= (unsigned int *)args
[1];
409 float *retval
= args
[2];
412 for (i
= 0; i
< instr
->comp_count
; ++i
)
414 unsigned int v
= arg2
[i
] ? arg1
[instr
->scalar
? 0 : i
] / arg2
[i
] : UINT_MAX
;
415 retval
[i
] = *(float *)&v
;
419 static void pres_imin(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
421 int *arg1
= (int *)args
[0], *arg2
= (int *)args
[1];
422 float *retval
= args
[2];
425 for (i
= 0; i
< instr
->comp_count
; ++i
)
427 int v
= min(arg1
[instr
->scalar
? 0 : i
], arg2
[i
]);
428 retval
[i
] = *(float *)&v
;
432 static void pres_imax(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
434 int *arg1
= (int *)args
[0], *arg2
= (int *)args
[1];
435 float *retval
= args
[2];
438 for (i
= 0; i
< instr
->comp_count
; ++i
)
440 int v
= max(arg1
[instr
->scalar
? 0 : i
], arg2
[i
]);
441 retval
[i
] = *(float *)&v
;
445 static void pres_umin(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
447 unsigned int *arg1
= (unsigned int *)args
[0], *arg2
= (unsigned int *)args
[1];
448 float *retval
= args
[2];
451 for (i
= 0; i
< instr
->comp_count
; ++i
)
453 unsigned int v
= min(arg1
[instr
->scalar
? 0 : i
], arg2
[i
]);
454 retval
[i
] = *(float *)&v
;
458 static void pres_umax(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
460 unsigned int *arg1
= (unsigned int *)args
[0], *arg2
= (unsigned int *)args
[1];
461 float *retval
= args
[2];
464 for (i
= 0; i
< instr
->comp_count
; ++i
)
466 unsigned int v
= max(arg1
[instr
->scalar
? 0 : i
], arg2
[i
]);
467 retval
[i
] = *(float *)&v
;
471 static void pres_movc(float **args
, unsigned int n
, const struct preshader_instr
*instr
)
473 float *arg1
= args
[0], *arg2
= args
[1], *arg3
= args
[2];
474 float *retval
= args
[3];
477 for (i
= 0; i
< instr
->comp_count
; ++i
)
478 retval
[i
] = arg1
[i
] ? arg2
[i
] : arg3
[i
];
481 struct preshader_op_info
488 static const struct preshader_op_info preshader_ops
[] =
490 { 0x101, "neg", pres_neg
},
491 { 0x103, "rcp", pres_rcp
},
492 { 0x104, "frc", pres_frc
},
493 { 0x108, "sin", pres_sin
},
494 { 0x109, "cos", pres_cos
},
495 { 0x10a, "asin", pres_asin
},
496 { 0x10b, "acos", pres_acos
},
497 { 0x10c, "atan", pres_atan
},
498 { 0x120, "ineg", pres_ineg
},
499 { 0x130, "itof", pres_itof
},
500 { 0x131, "utof", pres_utof
},
501 { 0x133, "ftou", pres_ftou
},
502 { 0x137, "ftob", pres_ftob
},
503 { 0x200, "min", pres_min
},
504 { 0x201, "max", pres_max
},
505 { 0x204, "add", pres_add
},
506 { 0x205, "mul", pres_mul
},
507 { 0x206, "atan2",pres_atan2
},
508 { 0x208, "div", pres_div
},
509 { 0x216, "iadd", pres_iadd
},
510 { 0x21a, "udiv", pres_udiv
},
511 { 0x21d, "imin", pres_imin
},
512 { 0x21e, "imax", pres_imax
},
513 { 0x21f, "umin", pres_umin
},
514 { 0x220, "umax", pres_umax
},
515 { 0x301, "movc", pres_movc
},
518 static int __cdecl
preshader_op_compare(const void *a
, const void *b
)
520 int opcode
= *(int *)a
;
521 const struct preshader_op_info
*op_info
= b
;
522 return opcode
- op_info
->opcode
;
525 static const struct preshader_op_info
* d3d10_effect_get_op_info(int opcode
)
527 return bsearch(&opcode
, preshader_ops
, ARRAY_SIZE(preshader_ops
), sizeof(*preshader_ops
),
528 preshader_op_compare
);
531 struct d3d10_ctab_var
533 struct d3d10_effect_variable
*v
;
538 struct d3d10_reg_table
548 enum d3d10_reg_table_type
550 D3D10_REG_TABLE_CONSTANTS
= 1,
551 D3D10_REG_TABLE_CB
= 2,
552 D3D10_REG_TABLE_RESULT
= 4,
553 D3D10_REG_TABLE_TEMP
= 7,
554 D3D10_REG_TABLE_COUNT
,
557 struct d3d10_effect_preshader
559 struct d3d10_reg_table reg_tables
[D3D10_REG_TABLE_COUNT
];
562 struct d3d10_ctab_var
*vars
;
563 unsigned int vars_count
;
566 struct d3d10_preshader_parse_context
568 struct d3d10_effect_preshader
*preshader
;
569 struct d3d10_effect
*effect
;
570 unsigned int table_sizes
[D3D10_REG_TABLE_COUNT
];
573 struct d3d10_effect_prop_dependency
577 unsigned int operation
;
582 struct d3d10_effect_variable
*v
;
587 struct d3d10_effect_variable
*v
;
588 struct d3d10_effect_preshader index
;
592 struct d3d10_effect_preshader value
;
597 static HRESULT
d3d10_reg_table_allocate(struct d3d10_reg_table
*table
, unsigned int count
)
599 if (!(table
->f
= calloc(count
, sizeof(*table
->f
))))
600 return E_OUTOFMEMORY
;
601 table
->count
= count
;
605 static void d3d10_effect_preshader_clear(struct d3d10_effect_preshader
*p
)
609 for (i
= 0; i
< ARRAY_SIZE(p
->reg_tables
); ++i
)
610 free(p
->reg_tables
[i
].f
);
612 ID3D10Blob_Release(p
->code
);
614 memset(p
, 0, sizeof(*p
));
617 static float * d3d10_effect_preshader_get_reg_ptr(const struct d3d10_effect_preshader
*p
,
618 enum d3d10_reg_table_type regt
, unsigned int offset
)
622 case D3D10_REG_TABLE_CONSTANTS
:
623 case D3D10_REG_TABLE_CB
:
624 case D3D10_REG_TABLE_RESULT
:
625 case D3D10_REG_TABLE_TEMP
:
626 return p
->reg_tables
[regt
].f
+ offset
;
632 static HRESULT
d3d10_effect_preshader_eval(struct d3d10_effect_preshader
*p
)
634 unsigned int i
, j
, regt
, offset
, instr_count
, arg_count
;
635 const DWORD
*ip
= ID3D10Blob_GetBufferPointer(p
->code
);
636 struct preshader_instr ins
;
637 float *dst
, *args
[4];
639 dst
= d3d10_effect_preshader_get_reg_ptr(p
, D3D10_REG_TABLE_RESULT
, 0);
640 memset(dst
, 0, sizeof(float) * p
->reg_tables
[D3D10_REG_TABLE_RESULT
].count
);
642 /* Update constant buffer */
643 dst
= d3d10_effect_preshader_get_reg_ptr(p
, D3D10_REG_TABLE_CB
, 0);
644 for (i
= 0; i
< p
->vars_count
; ++i
)
646 struct d3d10_ctab_var
*v
= &p
->vars
[i
];
647 memcpy(dst
+ v
->offset
, v
->v
->buffer
->u
.buffer
.local_buffer
+ v
->v
->buffer_offset
,
648 v
->length
* sizeof(*dst
));
653 for (i
= 0; i
< instr_count
; ++i
)
655 *(DWORD
*)&ins
= *ip
++;
656 arg_count
= 1 + *ip
++;
658 if (arg_count
> ARRAY_SIZE(args
))
660 FIXME("Unexpected argument count %u.\n", arg_count
);
664 /* Arguments are followed by the return value. */
665 for (j
= 0; j
< arg_count
; ++j
)
667 ip
++; /* TODO: argument register flags are currently ignored */
671 args
[j
] = d3d10_effect_preshader_get_reg_ptr(p
, regt
, offset
);
674 d3d10_effect_get_op_info(ins
.opcode
)->func(args
, arg_count
, &ins
);
680 static void d3d10_effect_clear_prop_dependencies(struct d3d10_effect_prop_dependencies
*d
)
684 for (i
= 0; i
< d
->count
; ++i
)
686 struct d3d10_effect_prop_dependency
*dep
= &d
->entries
[i
];
687 switch (dep
->operation
)
689 case D3D10_EOO_INDEX_EXPRESSION
:
690 d3d10_effect_preshader_clear(&dep
->index_expr
.index
);
692 case D3D10_EOO_VALUE_EXPRESSION
:
693 d3d10_effect_preshader_clear(&dep
->value_expr
.value
);
698 memset(d
, 0, sizeof(*d
));
701 struct d3d10_effect_state_property_info
704 D3D_SHADER_VARIABLE_TYPE type
;
707 enum d3d10_effect_container_type container_type
;
712 static const struct d3d10_effect_state_property_info property_infos
[] =
714 { "Pass.RasterizerState", D3D10_SVT_RASTERIZER
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, rasterizer
) },
715 { "Pass.DepthStencilState", D3D10_SVT_DEPTHSTENCIL
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, depth_stencil
) },
716 { "Pass.BlendState", D3D10_SVT_BLEND
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, blend
) },
717 { "Pass.RenderTargets", D3D10_SVT_RENDERTARGETVIEW
, 1, 8, D3D10_C_PASS
, ~0u },
718 { "Pass.DepthStencilView", D3D10_SVT_DEPTHSTENCILVIEW
, 1, 1, D3D10_C_PASS
, ~0u },
719 { "Pass.Unknown5", D3D10_SVT_VOID
, 0, 0, D3D10_C_PASS
, ~0u },
720 { "Pass.VertexShader", D3D10_SVT_VERTEXSHADER
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, vs
.shader
),
721 FIELD_OFFSET(struct d3d10_effect_pass
, vs
.index
) },
722 { "Pass.PixelShader", D3D10_SVT_PIXELSHADER
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, ps
.shader
),
723 FIELD_OFFSET(struct d3d10_effect_pass
, ps
.index
) },
724 { "Pass.GeometryShader", D3D10_SVT_GEOMETRYSHADER
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, gs
.shader
),
725 FIELD_OFFSET(struct d3d10_effect_pass
, gs
.index
) },
726 { "Pass.StencilRef", D3D10_SVT_UINT
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, stencil_ref
) },
727 { "Pass.BlendFactor", D3D10_SVT_FLOAT
, 4, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, blend_factor
) },
728 { "Pass.SampleMask", D3D10_SVT_UINT
, 1, 1, D3D10_C_PASS
, FIELD_OFFSET(struct d3d10_effect_pass
, sample_mask
) },
730 { "RasterizerState.FillMode", D3D10_SVT_INT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, FillMode
) },
731 { "RasterizerState.CullMode", D3D10_SVT_INT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, CullMode
) },
732 { "RasterizerState.FrontCounterClockwise", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, FrontCounterClockwise
) },
733 { "RasterizerState.DepthBias", D3D10_SVT_INT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, DepthBias
) },
734 { "RasterizerState.DepthBiasClamp", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, DepthBiasClamp
) },
735 { "RasterizerState.SlopeScaledDepthBias", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, SlopeScaledDepthBias
) },
736 { "RasterizerState.DepthClipEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, DepthClipEnable
) },
737 { "RasterizerState.ScissorEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, ScissorEnable
) },
738 { "RasterizerState.MultisampleEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, MultisampleEnable
) },
739 { "RasterizerState.AntialiasedLineEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_RASTERIZER
, FIELD_OFFSET(D3D10_RASTERIZER_DESC
, AntialiasedLineEnable
) },
741 { "DepthStencilState.DepthEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, DepthEnable
) },
742 { "DepthStencilState.DepthWriteMask", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, DepthWriteMask
) },
743 { "DepthStencilState.DepthFunc", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, DepthFunc
) },
744 { "DepthStencilState.StencilEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, StencilEnable
) },
745 { "DepthStencilState.StencilReadMask", D3D10_SVT_UINT8
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, StencilReadMask
) },
746 { "DepthStencilState.StencilWriteMask", D3D10_SVT_UINT8
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, StencilWriteMask
) },
747 { "DepthStencilState.FrontFaceStencilFail", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, FrontFace
.StencilFailOp
) },
748 { "DepthStencilState.FrontFaceStencilDepthFail", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, FrontFace
.StencilDepthFailOp
)},
749 { "DepthStencilState.FrontFaceStencilPass", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, FrontFace
.StencilPassOp
) },
750 { "DepthStencilState.FrontFaceStencilFunc", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, FrontFace
.StencilFunc
) },
751 { "DepthStencilState.BackFaceStencilFail", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, BackFace
.StencilFailOp
) },
752 { "DepthStencilState.BackFaceStencilDepthFail", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, BackFace
.StencilDepthFailOp
) },
753 { "DepthStencilState.BackFaceStencilPass", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, BackFace
.StencilPassOp
) },
754 { "DepthStencilState.BackFaceStencilFunc", D3D10_SVT_INT
, 1, 1, D3D10_C_DEPTHSTENCIL
, FIELD_OFFSET(D3D10_DEPTH_STENCIL_DESC
, BackFace
.StencilFunc
) },
756 { "BlendState.AlphaToCoverageEnable", D3D10_SVT_BOOL
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, AlphaToCoverageEnable
) },
757 { "BlendState.BlendEnable", D3D10_SVT_BOOL
, 1, 8, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, BlendEnable
) },
758 { "BlendState.SrcBlend", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, SrcBlend
) },
759 { "BlendState.DestBlend", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, DestBlend
) },
760 { "BlendState.BlendOp", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, BlendOp
) },
761 { "BlendState.SrcBlendAlpha", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, SrcBlendAlpha
) },
762 { "BlendState.DestBlendAlpha", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, DestBlendAlpha
) },
763 { "BlendState.BlendOpAlpha", D3D10_SVT_INT
, 1, 1, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, BlendOpAlpha
) },
764 { "BlendState.RenderTargetWriteMask", D3D10_SVT_UINT8
, 1, 8, D3D10_C_BLEND
, FIELD_OFFSET(D3D10_BLEND_DESC
, RenderTargetWriteMask
) },
766 { "SamplerState.Filter", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.Filter
) },
767 { "SamplerState.AddressU", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.AddressU
) },
768 { "SamplerState.AddressV", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.AddressV
) },
769 { "SamplerState.AddressW", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.AddressW
) },
770 { "SamplerState.MipLODBias", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.MipLODBias
) },
771 { "SamplerState.MaxAnisotropy", D3D10_SVT_UINT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.MaxAnisotropy
) },
772 { "SamplerState.ComparisonFunc", D3D10_SVT_INT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.ComparisonFunc
) },
773 { "SamplerState.BorderColor", D3D10_SVT_FLOAT
, 4, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.BorderColor
) },
774 { "SamplerState.MinLOD", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.MinLOD
) },
775 { "SamplerState.MaxLOD", D3D10_SVT_FLOAT
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, desc
.MaxLOD
) },
776 { "SamplerState.Texture", D3D10_SVT_TEXTURE
, 1, 1, D3D10_C_SAMPLER
, FIELD_OFFSET(struct d3d10_effect_sampler_desc
, texture
) },
779 static const D3D10_RASTERIZER_DESC default_rasterizer_desc
=
793 static const D3D10_DEPTH_STENCIL_DESC default_depth_stencil_desc
=
796 D3D10_DEPTH_WRITE_MASK_ALL
,
797 D3D10_COMPARISON_LESS
,
799 D3D10_DEFAULT_STENCIL_READ_MASK
,
800 D3D10_DEFAULT_STENCIL_WRITE_MASK
,
801 {D3D10_STENCIL_OP_KEEP
, D3D10_STENCIL_OP_KEEP
, D3D10_STENCIL_OP_KEEP
, D3D10_COMPARISON_ALWAYS
},
802 {D3D10_STENCIL_OP_KEEP
, D3D10_STENCIL_OP_KEEP
, D3D10_STENCIL_OP_KEEP
, D3D10_COMPARISON_ALWAYS
},
805 static const D3D10_BLEND_DESC default_blend_desc
=
808 {FALSE
, FALSE
, FALSE
, FALSE
, FALSE
, FALSE
, FALSE
, FALSE
},
809 D3D10_BLEND_SRC_ALPHA
,
810 D3D10_BLEND_INV_SRC_ALPHA
,
812 D3D10_BLEND_SRC_ALPHA
,
813 D3D10_BLEND_INV_SRC_ALPHA
,
815 {0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf},
818 static const D3D10_SAMPLER_DESC default_sampler_desc
=
820 D3D10_FILTER_MIN_MAG_MIP_POINT
,
821 D3D10_TEXTURE_ADDRESS_WRAP
,
822 D3D10_TEXTURE_ADDRESS_WRAP
,
823 D3D10_TEXTURE_ADDRESS_WRAP
,
826 D3D10_COMPARISON_NEVER
,
827 {0.0f
, 0.0f
, 0.0f
, 0.0f
},
832 struct d3d10_effect_state_storage_info
834 D3D_SHADER_VARIABLE_TYPE id
;
836 const void *default_state
;
839 static const struct d3d10_effect_state_storage_info d3d10_effect_state_storage_info
[] =
841 {D3D10_SVT_RASTERIZER
, sizeof(default_rasterizer_desc
), &default_rasterizer_desc
},
842 {D3D10_SVT_DEPTHSTENCIL
, sizeof(default_depth_stencil_desc
), &default_depth_stencil_desc
},
843 {D3D10_SVT_BLEND
, sizeof(default_blend_desc
), &default_blend_desc
},
844 {D3D10_SVT_SAMPLER
, sizeof(default_sampler_desc
), &default_sampler_desc
},
847 #define WINE_D3D10_TO_STR(x) case x: return #x
849 static const char *debug_d3d10_shader_variable_class(D3D10_SHADER_VARIABLE_CLASS c
)
853 WINE_D3D10_TO_STR(D3D10_SVC_SCALAR
);
854 WINE_D3D10_TO_STR(D3D10_SVC_VECTOR
);
855 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_ROWS
);
856 WINE_D3D10_TO_STR(D3D10_SVC_MATRIX_COLUMNS
);
857 WINE_D3D10_TO_STR(D3D10_SVC_OBJECT
);
858 WINE_D3D10_TO_STR(D3D10_SVC_STRUCT
);
860 FIXME("Unrecognised D3D10_SHADER_VARIABLE_CLASS %#x.\n", c
);
861 return "unrecognised";
865 static const char *debug_d3d10_shader_variable_type(D3D10_SHADER_VARIABLE_TYPE t
)
869 WINE_D3D10_TO_STR(D3D10_SVT_VOID
);
870 WINE_D3D10_TO_STR(D3D10_SVT_BOOL
);
871 WINE_D3D10_TO_STR(D3D10_SVT_INT
);
872 WINE_D3D10_TO_STR(D3D10_SVT_FLOAT
);
873 WINE_D3D10_TO_STR(D3D10_SVT_STRING
);
874 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE
);
875 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1D
);
876 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2D
);
877 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE3D
);
878 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBE
);
879 WINE_D3D10_TO_STR(D3D10_SVT_SAMPLER
);
880 WINE_D3D10_TO_STR(D3D10_SVT_PIXELSHADER
);
881 WINE_D3D10_TO_STR(D3D10_SVT_VERTEXSHADER
);
882 WINE_D3D10_TO_STR(D3D10_SVT_UINT
);
883 WINE_D3D10_TO_STR(D3D10_SVT_UINT8
);
884 WINE_D3D10_TO_STR(D3D10_SVT_GEOMETRYSHADER
);
885 WINE_D3D10_TO_STR(D3D10_SVT_RASTERIZER
);
886 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCIL
);
887 WINE_D3D10_TO_STR(D3D10_SVT_BLEND
);
888 WINE_D3D10_TO_STR(D3D10_SVT_BUFFER
);
889 WINE_D3D10_TO_STR(D3D10_SVT_CBUFFER
);
890 WINE_D3D10_TO_STR(D3D10_SVT_TBUFFER
);
891 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE1DARRAY
);
892 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DARRAY
);
893 WINE_D3D10_TO_STR(D3D10_SVT_RENDERTARGETVIEW
);
894 WINE_D3D10_TO_STR(D3D10_SVT_DEPTHSTENCILVIEW
);
895 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMS
);
896 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURE2DMSARRAY
);
897 WINE_D3D10_TO_STR(D3D10_SVT_TEXTURECUBEARRAY
);
899 FIXME("Unrecognised D3D10_SHADER_VARIABLE_TYPE %#x.\n", t
);
900 return "unrecognised";
904 #undef WINE_D3D10_TO_STR
906 static HRESULT
d3d10_effect_variable_get_raw_value(struct d3d10_effect_variable
*v
,
907 void *data
, unsigned int offset
, unsigned int count
)
911 is_buffer
= v
->type
->basetype
== D3D10_SVT_CBUFFER
|| v
->type
->basetype
== D3D10_SVT_TBUFFER
;
913 if (v
->type
->type_class
== D3D10_SVC_OBJECT
&& !is_buffer
)
915 WARN("Not supported on object variables of type %s.\n",
916 debug_d3d10_shader_variable_type(v
->type
->basetype
));
917 return D3DERR_INVALIDCALL
;
922 offset
+= v
->buffer_offset
;
926 memcpy(data
, v
->u
.buffer
.local_buffer
+ offset
, count
);
931 static BOOL
read_float_value(uint32_t value
, D3D_SHADER_VARIABLE_TYPE in_type
,
932 float *out_data
, unsigned int out_idx
)
936 case D3D10_SVT_FLOAT
:
937 out_data
[out_idx
] = *(float *)&value
;
941 out_data
[out_idx
] = (INT
)value
;
945 out_data
[out_idx
] = value
;
949 FIXME("Unhandled in_type %#x.\n", in_type
);
954 static BOOL
read_int32_value(uint32_t value
, D3D_SHADER_VARIABLE_TYPE in_type
,
955 int *out_data
, unsigned int out_idx
)
959 case D3D10_SVT_FLOAT
:
960 out_data
[out_idx
] = *(float *)&value
;
966 out_data
[out_idx
] = value
;
970 FIXME("Unhandled in_type %#x.\n", in_type
);
975 static BOOL
read_int8_value(uint32_t value
, D3D_SHADER_VARIABLE_TYPE in_type
,
976 INT8
*out_data
, unsigned int out_idx
)
982 out_data
[out_idx
] = value
;
986 FIXME("Unhandled in_type %#x.\n", in_type
);
991 static BOOL
d3d10_effect_read_numeric_value(uint32_t value
, D3D_SHADER_VARIABLE_TYPE in_type
,
992 D3D_SHADER_VARIABLE_TYPE out_type
, void *out_data
, unsigned int out_idx
)
996 case D3D10_SVT_FLOAT
:
997 return read_float_value(value
, in_type
, out_data
, out_idx
);
1000 case D3D10_SVT_BOOL
:
1001 return read_int32_value(value
, in_type
, out_data
, out_idx
);
1002 case D3D10_SVT_UINT8
:
1003 return read_int8_value(value
, in_type
, out_data
, out_idx
);
1005 FIXME("Unsupported property type %u.\n", out_type
);
1010 static void d3d10_effect_update_dependent_props(struct d3d10_effect_prop_dependencies
*deps
,
1013 const struct d3d10_effect_state_property_info
*property_info
;
1014 struct d3d10_effect_prop_dependency
*d
;
1015 unsigned int i
, j
, count
, variable_idx
;
1016 struct d3d10_effect_variable
*v
;
1017 struct d3d10_reg_table
*table
;
1018 unsigned int *dst_index
;
1023 for (i
= 0; i
< deps
->count
; ++i
)
1025 d
= &deps
->entries
[i
];
1027 property_info
= &property_infos
[d
->id
];
1029 dst
= (char *)container
+ property_info
->offset
;
1030 dst_index
= (unsigned int *)((char *)container
+ property_info
->index_offset
);
1032 switch (d
->operation
)
1035 case D3D10_EOO_CONST_INDEX
:
1039 count
= v
->type
->type_class
== D3D10_SVC_VECTOR
? 4 : 1;
1041 for (j
= 0; j
< count
; ++j
)
1043 d3d10_effect_variable_get_raw_value(v
, &value
, d
->var
.offset
+ j
* sizeof(value
), sizeof(value
));
1044 d3d10_effect_read_numeric_value(value
, v
->type
->basetype
, property_info
->type
, dst
, j
);
1049 case D3D10_EOO_INDEX_EXPRESSION
:
1051 v
= d
->index_expr
.v
;
1053 if (FAILED(hr
= d3d10_effect_preshader_eval(&d
->index_expr
.index
)))
1055 WARN("Failed to evaluate index expression, hr %#lx.\n", hr
);
1059 variable_idx
= *d
->index_expr
.index
.reg_tables
[D3D10_REG_TABLE_RESULT
].dword
;
1061 if (variable_idx
>= v
->type
->element_count
)
1063 WARN("Expression evaluated to invalid index value %u, array %s of size %u.\n",
1064 variable_idx
, debugstr_a(v
->name
), v
->type
->element_count
);
1068 /* Ignoring destination index here, there are no object typed array properties. */
1069 switch (property_info
->type
)
1071 case D3D10_SVT_VERTEXSHADER
:
1072 case D3D10_SVT_PIXELSHADER
:
1073 case D3D10_SVT_GEOMETRYSHADER
:
1075 *dst_index
= variable_idx
;
1078 *(void **)dst
= &v
->elements
[variable_idx
];
1082 case D3D10_EOO_VALUE_EXPRESSION
:
1084 if ((property_info
->type
!= D3D10_SVT_UINT
)
1085 && (property_info
->type
!= D3D10_SVT_FLOAT
)
1086 && (property_info
->type
!= D3D10_SVT_BOOL
))
1088 FIXME("Unimplemented for property %s.\n", property_info
->name
);
1092 if (FAILED(hr
= d3d10_effect_preshader_eval(&d
->value_expr
.value
)))
1094 WARN("Failed to evaluate value expression, hr %#lx.\n", hr
);
1098 table
= &d
->value_expr
.value
.reg_tables
[D3D10_REG_TABLE_RESULT
];
1100 if (property_info
->size
!= table
->count
)
1102 WARN("Unexpected value expression output size %u, property size %u.\n",
1103 table
->count
, property_info
->size
);
1107 memcpy(dst
, table
->f
, property_info
->size
* sizeof(float));
1112 FIXME("Unsupported property update for %u.\n", d
->operation
);
1117 static BOOL
d3d_array_reserve(void **elements
, SIZE_T
*capacity
, SIZE_T count
, SIZE_T size
)
1119 SIZE_T max_capacity
, new_capacity
;
1122 if (count
<= *capacity
)
1125 max_capacity
= ~(SIZE_T
)0 / size
;
1126 if (count
> max_capacity
)
1129 new_capacity
= max(1, *capacity
);
1130 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
1132 if (new_capacity
< count
)
1133 new_capacity
= count
;
1135 if (!(new_elements
= realloc(*elements
, new_capacity
* size
)))
1138 *elements
= new_elements
;
1139 *capacity
= new_capacity
;
1143 static BOOL
require_space(size_t offset
, size_t count
, size_t size
, size_t data_size
)
1145 return !count
|| (data_size
- offset
) / count
>= size
;
1148 static HRESULT
parse_dxbc(const char *data
, SIZE_T data_size
,
1149 HRESULT (*chunk_handler
)(const char *data
, size_t data_size
, uint32_t tag
, void *ctx
), void *ctx
)
1151 const char *ptr
= data
;
1152 uint32_t chunk_count
;
1153 uint32_t total_size
;
1161 WARN("No data supplied.\n");
1165 tag
= read_u32(&ptr
);
1166 TRACE("tag: %s.\n", debugstr_an((const char *)&tag
, 4));
1168 if (tag
!= TAG_DXBC
)
1170 WARN("Wrong tag.\n");
1174 FIXME("Skipping DXBC checksum.\n");
1175 skip_u32_unknown(&ptr
, 4);
1177 version
= read_u32(&ptr
);
1178 TRACE("version: %#x.\n", version
);
1179 if (version
!= 0x00000001)
1181 WARN("Got unexpected DXBC version %#x.\n", version
);
1185 total_size
= read_u32(&ptr
);
1186 TRACE("Total size: %#x.\n", total_size
);
1188 if (data_size
!= total_size
)
1190 WARN("Wrong size supplied.\n");
1194 chunk_count
= read_u32(&ptr
);
1195 TRACE("Chunk count: %#x.\n", chunk_count
);
1197 for (i
= 0; i
< chunk_count
; ++i
)
1199 uint32_t chunk_tag
, chunk_size
;
1200 const char *chunk_ptr
;
1201 uint32_t chunk_offset
;
1203 chunk_offset
= read_u32(&ptr
);
1204 TRACE("Chunk %u at offset %#x.\n", i
, chunk_offset
);
1206 if (chunk_offset
>= data_size
|| !require_space(chunk_offset
, 2, sizeof(uint32_t), data_size
))
1208 WARN("Invalid chunk offset %#x (data size %#Ix).\n", chunk_offset
, data_size
);
1212 chunk_ptr
= data
+ chunk_offset
;
1214 chunk_tag
= read_u32(&chunk_ptr
);
1215 chunk_size
= read_u32(&chunk_ptr
);
1217 if (!require_space(chunk_ptr
- data
, 1, chunk_size
, data_size
))
1219 WARN("Invalid chunk size %#x (data size %#Ix, chunk offset %#x).\n",
1220 chunk_size
, data_size
, chunk_offset
);
1224 if (FAILED(hr
= chunk_handler(chunk_ptr
, chunk_size
, chunk_tag
, ctx
)))
1231 static BOOL
fx10_get_string(const char *data
, size_t data_size
, uint32_t offset
, const char **s
, size_t *l
)
1233 size_t len
, max_len
;
1235 if (offset
>= data_size
)
1237 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1241 max_len
= data_size
- offset
;
1242 if (!(len
= strnlen(data
+ offset
, max_len
)))
1258 static BOOL
fx10_copy_string(const char *data
, size_t data_size
, DWORD offset
, char **s
)
1263 if (!fx10_get_string(data
, data_size
, offset
, &p
, &len
))
1272 if (!(*s
= malloc(len
)))
1274 ERR("Failed to allocate string memory.\n");
1283 static BOOL
copy_name(const char *ptr
, char **name
)
1285 if (!ptr
|| !*ptr
) return TRUE
;
1287 if (!(*name
= strdup(ptr
)))
1289 ERR("Failed to allocate name memory.\n");
1296 static struct d3d10_effect_variable
* d3d10_effect_get_buffer_by_name(struct d3d10_effect
*effect
,
1301 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
1303 struct d3d10_effect_variable
*l
= &effect
->local_buffers
[i
];
1304 if (l
->name
&& !strcmp(l
->name
, name
))
1308 return effect
->pool
? d3d10_effect_get_buffer_by_name(effect
->pool
, name
) : NULL
;
1311 static struct d3d10_effect_variable
* d3d10_effect_get_variable_by_name(
1312 const struct d3d10_effect
*effect
, const char *name
)
1314 struct d3d10_effect_variable
*v
;
1317 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
1319 for (j
= 0; j
< effect
->local_buffers
[i
].type
->member_count
; ++j
)
1321 v
= &effect
->local_buffers
[i
].members
[j
];
1322 if (v
->name
&& !strcmp(v
->name
, name
))
1327 for (i
= 0; i
< effect
->local_variable_count
; ++i
)
1329 struct d3d10_effect_variable
*v
= &effect
->local_variables
[i
];
1330 if (v
->name
&& !strcmp(v
->name
, name
))
1334 return effect
->pool
? d3d10_effect_get_variable_by_name(effect
->pool
, name
) : NULL
;
1337 static HRESULT
get_fx10_shader_resources(struct d3d10_effect_variable
*v
)
1339 struct d3d10_effect_shader_variable
*sv
= &v
->u
.shader
;
1340 struct d3d10_effect_shader_resource
*sr
;
1341 D3D10_SHADER_INPUT_BIND_DESC bind_desc
;
1342 D3D10_SHADER_DESC desc
;
1345 sv
->reflection
->lpVtbl
->GetDesc(sv
->reflection
, &desc
);
1346 sv
->resource_count
= desc
.BoundResources
;
1348 if (!(sv
->resources
= calloc(sv
->resource_count
, sizeof(*sv
->resources
))))
1350 ERR("Failed to allocate shader resource binding information memory.\n");
1351 return E_OUTOFMEMORY
;
1354 for (i
= 0; i
< desc
.BoundResources
; ++i
)
1356 sv
->reflection
->lpVtbl
->GetResourceBindingDesc(sv
->reflection
, i
, &bind_desc
);
1357 sr
= &sv
->resources
[i
];
1359 sr
->in_type
= bind_desc
.Type
;
1360 sr
->bind_point
= bind_desc
.BindPoint
;
1361 sr
->bind_count
= bind_desc
.BindCount
;
1363 switch (bind_desc
.Type
)
1365 case D3D10_SIT_CBUFFER
:
1366 case D3D10_SIT_TBUFFER
:
1367 if (sr
->bind_count
!= 1)
1369 WARN("Unexpected bind count %u for a buffer %s.\n", bind_desc
.BindCount
,
1370 debugstr_a(bind_desc
.Name
));
1371 return E_UNEXPECTED
;
1373 sr
->variable
= d3d10_effect_get_buffer_by_name(v
->effect
, bind_desc
.Name
);
1376 case D3D10_SIT_SAMPLER
:
1377 case D3D10_SIT_TEXTURE
:
1378 sr
->variable
= d3d10_effect_get_variable_by_name(v
->effect
, bind_desc
.Name
);
1387 WARN("Failed to find shader resource.\n");
1395 struct d3d10_effect_so_decl
1397 D3D10_SO_DECLARATION_ENTRY
*entries
;
1400 unsigned int stride
;
1404 static void d3d10_effect_cleanup_so_decl(struct d3d10_effect_so_decl
*so_decl
)
1406 free(so_decl
->entries
);
1407 free(so_decl
->decl
);
1408 memset(so_decl
, 0, sizeof(*so_decl
));
1411 static HRESULT
d3d10_effect_parse_stream_output_declaration(const char *decl
,
1412 struct d3d10_effect_so_decl
*so_decl
)
1414 static const char * xyzw
= "xyzw";
1415 static const char * rgba
= "rgba";
1416 char *p
, *ptr
, *end
, *next
, *mask
, *m
, *slot
;
1417 D3D10_SO_DECLARATION_ENTRY e
;
1420 memset(so_decl
, 0, sizeof(*so_decl
));
1422 if (!(so_decl
->decl
= strdup(decl
)))
1423 return E_OUTOFMEMORY
;
1429 memset(&e
, 0, sizeof(e
));
1431 end
= strchr(p
, ';');
1432 next
= end
? end
+ 1 : p
+ strlen(p
);
1437 /* Remove leading and trailing spaces. */
1438 while (len
&& isspace(*p
)) { len
--; p
++; }
1439 while (len
&& isspace(p
[len
- 1])) len
--;
1444 if ((slot
= strchr(p
, ':')))
1453 WARN("Invalid output slot %s.\n", debugstr_a(p
));
1459 e
.OutputSlot
= atoi(p
);
1464 if ((mask
= strchr(p
, '.')))
1468 if ((m
= strstr(xyzw
, mask
)))
1469 e
.StartComponent
= m
- xyzw
;
1470 else if ((m
= strstr(rgba
, mask
)))
1471 e
.StartComponent
= m
- rgba
;
1474 WARN("Invalid component mask %s.\n", debugstr_a(mask
));
1478 e
.ComponentCount
= strlen(mask
);
1482 e
.StartComponent
= 0;
1483 e
.ComponentCount
= 4;
1486 /* Semantic index and name */
1488 while (isdigit(p
[len
- 1]))
1493 e
.SemanticIndex
= atoi(&p
[len
]);
1497 e
.SemanticName
= stricmp(p
, "$SKIP") ? p
: NULL
;
1499 if (!d3d_array_reserve((void **)&so_decl
->entries
, &so_decl
->capacity
, so_decl
->count
+ 1,
1500 sizeof(*so_decl
->entries
)))
1503 so_decl
->entries
[so_decl
->count
++] = e
;
1505 if (e
.OutputSlot
== 0)
1506 so_decl
->stride
+= e
.ComponentCount
* sizeof(float);
1514 d3d10_effect_cleanup_so_decl(so_decl
);
1519 static HRESULT
parse_fx10_shader(const char *data
, size_t data_size
, uint32_t offset
, struct d3d10_effect_variable
*v
)
1521 ID3D10Device
*device
= v
->effect
->device
;
1526 if (v
->effect
->shaders
.current
>= v
->effect
->shaders
.count
)
1528 WARN("Invalid effect? Used shader current(%u) >= used shader count(%u)\n",
1529 v
->effect
->shaders
.current
, v
->effect
->shaders
.count
);
1533 v
->effect
->shaders
.v
[v
->effect
->shaders
.current
++] = v
;
1535 if (offset
>= data_size
|| !require_space(offset
, 1, sizeof(dxbc_size
), data_size
))
1537 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1541 ptr
= data
+ offset
;
1542 dxbc_size
= read_u32(&ptr
);
1543 TRACE("DXBC size: %#x.\n", dxbc_size
);
1545 if (!require_space(ptr
- data
, 1, dxbc_size
, data_size
))
1547 WARN("Invalid dxbc size %#x (data size %#Ix, offset %#x).\n", offset
, data_size
, offset
);
1554 if (FAILED(hr
= D3D10ReflectShader(ptr
, dxbc_size
, &v
->u
.shader
.reflection
)))
1557 D3DGetInputSignatureBlob(ptr
, dxbc_size
, &v
->u
.shader
.input_signature
);
1559 if (FAILED(hr
= D3DCreateBlob(dxbc_size
, &v
->u
.shader
.bytecode
)))
1562 memcpy(ID3D10Blob_GetBufferPointer(v
->u
.shader
.bytecode
), ptr
, dxbc_size
);
1564 if (FAILED(hr
= get_fx10_shader_resources(v
)))
1567 switch (v
->type
->basetype
)
1569 case D3D10_SVT_VERTEXSHADER
:
1570 hr
= ID3D10Device_CreateVertexShader(device
, ptr
, dxbc_size
, &v
->u
.shader
.shader
.vs
);
1573 case D3D10_SVT_PIXELSHADER
:
1574 hr
= ID3D10Device_CreatePixelShader(device
, ptr
, dxbc_size
, &v
->u
.shader
.shader
.ps
);
1577 case D3D10_SVT_GEOMETRYSHADER
:
1578 if (v
->u
.shader
.stream_output_declaration
)
1580 struct d3d10_effect_so_decl so_decl
;
1582 if (FAILED(hr
= d3d10_effect_parse_stream_output_declaration(v
->u
.shader
.stream_output_declaration
, &so_decl
)))
1584 WARN("Failed to parse stream output declaration, hr %#lx.\n", hr
);
1588 hr
= ID3D10Device_CreateGeometryShaderWithStreamOutput(device
, ptr
, dxbc_size
,
1589 so_decl
.entries
, so_decl
.count
, so_decl
.stride
, &v
->u
.shader
.shader
.gs
);
1591 d3d10_effect_cleanup_so_decl(&so_decl
);
1594 hr
= ID3D10Device_CreateGeometryShader(device
, ptr
, dxbc_size
, &v
->u
.shader
.shader
.gs
);
1598 ERR("This should not happen!\n");
1605 static D3D10_SHADER_VARIABLE_CLASS
d3d10_variable_class(uint32_t c
, BOOL is_column_major
)
1609 case 1: return D3D10_SVC_SCALAR
;
1610 case 2: return D3D10_SVC_VECTOR
;
1611 case 3: if (is_column_major
) return D3D10_SVC_MATRIX_COLUMNS
;
1612 else return D3D10_SVC_MATRIX_ROWS
;
1614 FIXME("Unknown variable class %#x.\n", c
);
1619 static D3D10_SHADER_VARIABLE_TYPE
d3d10_variable_type(uint32_t t
, BOOL is_object
,
1628 case 1: return D3D10_SVT_STRING
;
1629 case 2: return D3D10_SVT_BLEND
;
1630 case 3: return D3D10_SVT_DEPTHSTENCIL
;
1631 case 4: return D3D10_SVT_RASTERIZER
;
1632 case 5: return D3D10_SVT_PIXELSHADER
;
1633 case 6: return D3D10_SVT_VERTEXSHADER
;
1634 case 7: return D3D10_SVT_GEOMETRYSHADER
;
1636 *flags
= D3D10_EOT_FLAG_GS_SO
;
1637 return D3D10_SVT_GEOMETRYSHADER
;
1639 case 9: return D3D10_SVT_TEXTURE
;
1640 case 10: return D3D10_SVT_TEXTURE1D
;
1641 case 11: return D3D10_SVT_TEXTURE1DARRAY
;
1642 case 12: return D3D10_SVT_TEXTURE2D
;
1643 case 13: return D3D10_SVT_TEXTURE2DARRAY
;
1644 case 14: return D3D10_SVT_TEXTURE2DMS
;
1645 case 15: return D3D10_SVT_TEXTURE2DMSARRAY
;
1646 case 16: return D3D10_SVT_TEXTURE3D
;
1647 case 17: return D3D10_SVT_TEXTURECUBE
;
1649 case 19: return D3D10_SVT_RENDERTARGETVIEW
;
1650 case 20: return D3D10_SVT_DEPTHSTENCILVIEW
;
1651 case 21: return D3D10_SVT_SAMPLER
;
1652 case 22: return D3D10_SVT_BUFFER
;
1654 FIXME("Unknown variable type %#x.\n", t
);
1655 return D3D10_SVT_VOID
;
1662 case 1: return D3D10_SVT_FLOAT
;
1663 case 2: return D3D10_SVT_INT
;
1664 case 3: return D3D10_SVT_UINT
;
1665 case 4: return D3D10_SVT_BOOL
;
1667 FIXME("Unknown variable type %#x.\n", t
);
1668 return D3D10_SVT_VOID
;
1673 static HRESULT
parse_fx10_type(const char *data
, size_t data_size
, uint32_t offset
, struct d3d10_effect_type
*t
)
1675 uint32_t typeinfo
, type_flags
, type_kind
;
1679 if (offset
>= data_size
|| !require_space(offset
, 6, sizeof(DWORD
), data_size
))
1681 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1685 ptr
= data
+ offset
;
1686 offset
= read_u32(&ptr
);
1687 TRACE("Type name at offset %#x.\n", offset
);
1689 if (!fx10_copy_string(data
, data_size
, offset
, &t
->name
))
1691 ERR("Failed to copy name.\n");
1692 return E_OUTOFMEMORY
;
1694 TRACE("Type name: %s.\n", debugstr_a(t
->name
));
1696 type_kind
= read_u32(&ptr
);
1697 TRACE("Kind: %u.\n", type_kind
);
1699 t
->element_count
= read_u32(&ptr
);
1700 TRACE("Element count: %u.\n", t
->element_count
);
1702 t
->size_unpacked
= read_u32(&ptr
);
1703 TRACE("Unpacked size: %#x.\n", t
->size_unpacked
);
1705 t
->stride
= read_u32(&ptr
);
1706 TRACE("Stride: %#x.\n", t
->stride
);
1708 t
->size_packed
= read_u32(&ptr
);
1709 TRACE("Packed size %#x.\n", t
->size_packed
);
1714 TRACE("Type is numeric.\n");
1716 if (!require_space(ptr
- data
, 1, sizeof(typeinfo
), data_size
))
1718 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1722 typeinfo
= read_u32(&ptr
);
1723 t
->member_count
= 0;
1724 t
->column_count
= (typeinfo
& D3D10_FX10_TYPE_COLUMN_MASK
) >> D3D10_FX10_TYPE_COLUMN_SHIFT
;
1725 t
->row_count
= (typeinfo
& D3D10_FX10_TYPE_ROW_MASK
) >> D3D10_FX10_TYPE_ROW_SHIFT
;
1726 t
->basetype
= d3d10_variable_type((typeinfo
& D3D10_FX10_TYPE_BASETYPE_MASK
)
1727 >> D3D10_FX10_TYPE_BASETYPE_SHIFT
, FALSE
, &type_flags
);
1728 t
->type_class
= d3d10_variable_class((typeinfo
& D3D10_FX10_TYPE_CLASS_MASK
)
1729 >> D3D10_FX10_TYPE_CLASS_SHIFT
, typeinfo
& D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK
);
1731 TRACE("Type description: %#x.\n", typeinfo
);
1732 TRACE("\tcolumns: %u.\n", t
->column_count
);
1733 TRACE("\trows: %u.\n", t
->row_count
);
1734 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t
->basetype
));
1735 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t
->type_class
));
1736 TRACE("\tunknown bits: %#x.\n", typeinfo
& ~(D3D10_FX10_TYPE_COLUMN_MASK
| D3D10_FX10_TYPE_ROW_MASK
1737 | D3D10_FX10_TYPE_BASETYPE_MASK
| D3D10_FX10_TYPE_CLASS_MASK
| D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK
));
1741 TRACE("Type is an object.\n");
1743 if (!require_space(ptr
- data
, 1, sizeof(typeinfo
), data_size
))
1745 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1749 typeinfo
= read_u32(&ptr
);
1750 t
->member_count
= 0;
1751 t
->column_count
= 0;
1753 t
->basetype
= d3d10_variable_type(typeinfo
, TRUE
, &type_flags
);
1754 t
->type_class
= D3D10_SVC_OBJECT
;
1755 t
->flags
= type_flags
;
1757 TRACE("Type description: %#x.\n", typeinfo
);
1758 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t
->basetype
));
1759 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t
->type_class
));
1760 TRACE("\tflags: %#x.\n", t
->flags
);
1764 TRACE("Type is a structure.\n");
1766 if (!require_space(ptr
- data
, 1, sizeof(t
->member_count
), data_size
))
1768 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1772 t
->member_count
= read_u32(&ptr
);
1773 TRACE("Member count: %u.\n", t
->member_count
);
1775 t
->column_count
= 0;
1778 t
->type_class
= D3D10_SVC_STRUCT
;
1780 if (!(t
->members
= calloc(t
->member_count
, sizeof(*t
->members
))))
1782 ERR("Failed to allocate members memory.\n");
1783 return E_OUTOFMEMORY
;
1786 if (!require_space(ptr
- data
, t
->member_count
, 4 * sizeof(DWORD
), data_size
))
1788 WARN("Invalid member count %#x (data size %#Ix, offset %#x).\n",
1789 t
->member_count
, data_size
, offset
);
1793 for (i
= 0; i
< t
->member_count
; ++i
)
1795 struct d3d10_effect_type_member
*typem
= &t
->members
[i
];
1797 offset
= read_u32(&ptr
);
1798 TRACE("Member name at offset %#x.\n", offset
);
1800 if (!fx10_copy_string(data
, data_size
, offset
, &typem
->name
))
1802 ERR("Failed to copy name.\n");
1803 return E_OUTOFMEMORY
;
1805 TRACE("Member name: %s.\n", debugstr_a(typem
->name
));
1807 offset
= read_u32(&ptr
);
1808 TRACE("Member semantic at offset %#x.\n", offset
);
1810 if (!fx10_copy_string(data
, data_size
, offset
, &typem
->semantic
))
1812 ERR("Failed to copy semantic.\n");
1813 return E_OUTOFMEMORY
;
1815 TRACE("Member semantic: %s.\n", debugstr_a(typem
->semantic
));
1817 typem
->buffer_offset
= read_u32(&ptr
);
1818 TRACE("Member offset in struct: %#x.\n", typem
->buffer_offset
);
1820 offset
= read_u32(&ptr
);
1821 TRACE("Member type info at offset %#x.\n", offset
);
1823 if (!(typem
->type
= get_fx10_type(t
->effect
, data
, data_size
, offset
)))
1825 ERR("Failed to get variable type.\n");
1832 FIXME("Unhandled type kind %#x.\n", type_kind
);
1836 if (t
->element_count
)
1838 TRACE("Elementtype for type at offset: %#lx\n", t
->id
);
1840 /* allocate elementtype - we need only one, because all elements have the same type */
1841 if (!(t
->elementtype
= calloc(1, sizeof(*t
->elementtype
))))
1843 ERR("Failed to allocate members memory.\n");
1844 return E_OUTOFMEMORY
;
1847 /* create a copy of the original type with some minor changes */
1848 t
->elementtype
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
1849 t
->elementtype
->effect
= t
->effect
;
1851 if (!copy_name(t
->name
, &t
->elementtype
->name
))
1853 ERR("Failed to copy name.\n");
1854 return E_OUTOFMEMORY
;
1856 TRACE("\tType name: %s.\n", debugstr_a(t
->elementtype
->name
));
1858 t
->elementtype
->element_count
= 0;
1859 TRACE("\tElement count: %u.\n", t
->elementtype
->element_count
);
1862 * Not sure if this calculation is 100% correct, but a test
1863 * shows that these values work.
1865 t
->elementtype
->size_unpacked
= t
->size_packed
/ t
->element_count
;
1866 TRACE("\tUnpacked size: %#x.\n", t
->elementtype
->size_unpacked
);
1868 t
->elementtype
->stride
= t
->stride
;
1869 TRACE("\tStride: %#x.\n", t
->elementtype
->stride
);
1871 t
->elementtype
->size_packed
= t
->size_packed
/ t
->element_count
;
1872 TRACE("\tPacked size: %#x.\n", t
->elementtype
->size_packed
);
1874 t
->elementtype
->member_count
= t
->member_count
;
1875 TRACE("\tMember count: %u.\n", t
->elementtype
->member_count
);
1877 t
->elementtype
->column_count
= t
->column_count
;
1878 TRACE("\tColumns: %u.\n", t
->elementtype
->column_count
);
1880 t
->elementtype
->row_count
= t
->row_count
;
1881 TRACE("\tRows: %u.\n", t
->elementtype
->row_count
);
1883 t
->elementtype
->basetype
= t
->basetype
;
1884 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(t
->elementtype
->basetype
));
1886 t
->elementtype
->type_class
= t
->type_class
;
1887 TRACE("\tClass: %s.\n", debug_d3d10_shader_variable_class(t
->elementtype
->type_class
));
1889 t
->elementtype
->members
= t
->members
;
1895 static struct d3d10_effect_type
*get_fx10_type(struct d3d10_effect
*effect
, const char *data
,
1896 size_t data_size
, uint32_t offset
)
1898 struct d3d10_effect_type
*type
;
1899 struct wine_rb_entry
*entry
;
1902 entry
= wine_rb_get(&effect
->types
, &offset
);
1905 TRACE("Returning existing type.\n");
1906 return WINE_RB_ENTRY_VALUE(entry
, struct d3d10_effect_type
, entry
);
1909 if (!(type
= calloc(1, sizeof(*type
))))
1911 ERR("Failed to allocate type memory.\n");
1915 type
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
1917 type
->effect
= effect
;
1918 if (FAILED(hr
= parse_fx10_type(data
, data_size
, offset
, type
)))
1920 ERR("Failed to parse type info, hr %#lx.\n", hr
);
1925 if (wine_rb_put(&effect
->types
, &offset
, &type
->entry
) == -1)
1927 ERR("Failed to insert type entry.\n");
1935 static void set_variable_vtbl(struct d3d10_effect_variable
*v
)
1937 const ID3D10EffectVariableVtbl
**vtbl
= &v
->ID3D10EffectVariable_iface
.lpVtbl
;
1939 switch (v
->type
->type_class
)
1941 case D3D10_SVC_SCALAR
:
1942 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_scalar_variable_vtbl
;
1945 case D3D10_SVC_VECTOR
:
1946 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_vector_variable_vtbl
;
1949 case D3D10_SVC_MATRIX_ROWS
:
1950 case D3D10_SVC_MATRIX_COLUMNS
:
1951 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_matrix_variable_vtbl
;
1954 case D3D10_SVC_STRUCT
:
1955 *vtbl
= &d3d10_effect_variable_vtbl
;
1958 case D3D10_SVC_OBJECT
:
1959 switch(v
->type
->basetype
)
1961 case D3D10_SVT_STRING
:
1962 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_string_variable_vtbl
;
1965 case D3D10_SVT_TEXTURE
:
1966 case D3D10_SVT_TEXTURE1D
:
1967 case D3D10_SVT_TEXTURE1DARRAY
:
1968 case D3D10_SVT_TEXTURE2D
:
1969 case D3D10_SVT_TEXTURE2DARRAY
:
1970 case D3D10_SVT_TEXTURE2DMS
:
1971 case D3D10_SVT_TEXTURE2DMSARRAY
:
1972 case D3D10_SVT_TEXTURE3D
:
1973 case D3D10_SVT_TEXTURECUBE
:
1974 case D3D10_SVT_BUFFER
: /* Either resource or constant buffer. */
1975 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_resource_variable_vtbl
;
1978 case D3D10_SVT_RENDERTARGETVIEW
:
1979 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_render_target_view_variable_vtbl
;
1982 case D3D10_SVT_DEPTHSTENCILVIEW
:
1983 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_view_variable_vtbl
;
1986 case D3D10_SVT_DEPTHSTENCIL
:
1987 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_variable_vtbl
;
1990 case D3D10_SVT_VERTEXSHADER
:
1991 case D3D10_SVT_GEOMETRYSHADER
:
1992 case D3D10_SVT_PIXELSHADER
:
1993 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
;
1996 case D3D10_SVT_BLEND
:
1997 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_blend_variable_vtbl
;
2000 case D3D10_SVT_RASTERIZER
:
2001 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_rasterizer_variable_vtbl
;
2004 case D3D10_SVT_SAMPLER
:
2005 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_sampler_variable_vtbl
;
2009 FIXME("Unhandled basetype %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
2010 *vtbl
= &d3d10_effect_variable_vtbl
;
2016 FIXME("Unhandled type class %s.\n", debug_d3d10_shader_variable_class(v
->type
->type_class
));
2017 *vtbl
= &d3d10_effect_variable_vtbl
;
2022 static HRESULT
copy_variableinfo_from_type(struct d3d10_effect_variable
*v
)
2027 if (v
->type
->member_count
)
2029 if (!(v
->members
= calloc(v
->type
->member_count
, sizeof(*v
->members
))))
2031 ERR("Failed to allocate members memory.\n");
2032 return E_OUTOFMEMORY
;
2035 for (i
= 0; i
< v
->type
->member_count
; ++i
)
2037 struct d3d10_effect_variable
*var
= &v
->members
[i
];
2038 struct d3d10_effect_type_member
*typem
= &v
->type
->members
[i
];
2040 var
->buffer
= v
->buffer
;
2041 var
->effect
= v
->effect
;
2042 var
->type
= typem
->type
;
2043 set_variable_vtbl(var
);
2045 if (!copy_name(typem
->name
, &var
->name
))
2047 ERR("Failed to copy name.\n");
2048 return E_OUTOFMEMORY
;
2050 TRACE("Variable name: %s.\n", debugstr_a(var
->name
));
2052 if (!copy_name(typem
->semantic
, &var
->semantic
))
2054 ERR("Failed to copy name.\n");
2055 return E_OUTOFMEMORY
;
2057 TRACE("Variable semantic: %s.\n", debugstr_a(var
->semantic
));
2059 var
->buffer_offset
= v
->buffer_offset
+ typem
->buffer_offset
;
2060 TRACE("Variable buffer offset: %u.\n", var
->buffer_offset
);
2062 hr
= copy_variableinfo_from_type(var
);
2063 if (FAILED(hr
)) return hr
;
2067 if (v
->type
->element_count
)
2069 unsigned int bufferoffset
= v
->buffer_offset
;
2071 if (!(v
->elements
= calloc(v
->type
->element_count
, sizeof(*v
->elements
))))
2073 ERR("Failed to allocate elements memory.\n");
2074 return E_OUTOFMEMORY
;
2077 for (i
= 0; i
< v
->type
->element_count
; ++i
)
2079 struct d3d10_effect_variable
*var
= &v
->elements
[i
];
2081 var
->buffer
= v
->buffer
;
2082 var
->effect
= v
->effect
;
2083 var
->type
= v
->type
->elementtype
;
2084 set_variable_vtbl(var
);
2086 if (!copy_name(v
->name
, &var
->name
))
2088 ERR("Failed to copy name.\n");
2089 return E_OUTOFMEMORY
;
2091 TRACE("Variable name: %s.\n", debugstr_a(var
->name
));
2093 if (!copy_name(v
->semantic
, &var
->semantic
))
2095 ERR("Failed to copy name.\n");
2096 return E_OUTOFMEMORY
;
2098 TRACE("Variable semantic: %s.\n", debugstr_a(var
->semantic
));
2102 bufferoffset
+= v
->type
->stride
;
2104 var
->buffer_offset
= bufferoffset
;
2105 TRACE("Variable buffer offset: %u.\n", var
->buffer_offset
);
2107 hr
= copy_variableinfo_from_type(var
);
2108 if (FAILED(hr
)) return hr
;
2115 static HRESULT
parse_fx10_variable_head(const char *data
, size_t data_size
,
2116 const char **ptr
, struct d3d10_effect_variable
*v
)
2120 offset
= read_u32(ptr
);
2121 TRACE("Variable name at offset %#x.\n", offset
);
2123 if (!fx10_copy_string(data
, data_size
, offset
, &v
->name
))
2125 ERR("Failed to copy name.\n");
2126 return E_OUTOFMEMORY
;
2128 TRACE("Variable name: %s.\n", debugstr_a(v
->name
));
2130 offset
= read_u32(ptr
);
2131 TRACE("Variable type info at offset %#x.\n", offset
);
2133 if (!(v
->type
= get_fx10_type(v
->effect
, data
, data_size
, offset
)))
2135 ERR("Failed to get variable type.\n");
2138 set_variable_vtbl(v
);
2140 v
->explicit_bind_point
= ~0u;
2142 if (v
->effect
->flags
& D3D10_EFFECT_IS_POOL
)
2143 v
->flag
|= D3D10_EFFECT_VARIABLE_POOLED
;
2145 return copy_variableinfo_from_type(v
);
2148 static HRESULT
parse_fx10_annotation(const char *data
, size_t data_size
,
2149 const char **ptr
, struct d3d10_effect_variable
*a
)
2154 if (FAILED(hr
= parse_fx10_variable_head(data
, data_size
, ptr
, a
)))
2157 offset
= read_u32(ptr
);
2158 TRACE("Annotation value is at offset %#x.\n", offset
);
2160 switch (a
->type
->basetype
)
2162 case D3D10_SVT_STRING
:
2163 if (!fx10_copy_string(data
, data_size
, offset
, (char **)&a
->u
.buffer
.local_buffer
))
2165 ERR("Failed to copy name.\n");
2166 return E_OUTOFMEMORY
;
2171 FIXME("Unhandled object type %#x.\n", a
->type
->basetype
);
2174 /* mark the variable as annotation */
2175 a
->flag
|= D3D10_EFFECT_VARIABLE_ANNOTATION
;
2180 static HRESULT
parse_fx10_annotations(const char *data
, size_t data_size
, const char **ptr
,
2181 struct d3d10_effect
*effect
, struct d3d10_effect_annotations
*annotations
)
2186 if (!(annotations
->elements
= calloc(annotations
->count
, sizeof(*annotations
->elements
))))
2188 ERR("Failed to allocate annotations memory.\n");
2189 return E_OUTOFMEMORY
;
2192 for (i
= 0; i
< annotations
->count
; ++i
)
2194 struct d3d10_effect_variable
*a
= &annotations
->elements
[i
];
2197 a
->buffer
= &null_local_buffer
;
2199 if (FAILED(hr
= parse_fx10_annotation(data
, data_size
, ptr
, a
)))
2206 static HRESULT
parse_fx10_anonymous_shader(struct d3d10_effect
*e
, D3D_SHADER_VARIABLE_TYPE basetype
,
2207 struct d3d10_effect_anonymous_shader
*s
)
2209 struct d3d10_effect_variable
*v
= &s
->shader
;
2210 struct d3d10_effect_type
*t
= &s
->type
;
2211 const char *name
= NULL
;
2215 case D3D10_SVT_VERTEXSHADER
:
2216 name
= "vertexshader";
2219 case D3D10_SVT_PIXELSHADER
:
2220 name
= "pixelshader";
2223 case D3D10_SVT_GEOMETRYSHADER
:
2224 name
= "geometryshader";
2228 WARN("Unhandled shader type %#x.\n", basetype
);
2231 t
->basetype
= basetype
;
2233 if (!copy_name(name
, &t
->name
))
2235 ERR("Failed to copy name.\n");
2236 return E_OUTOFMEMORY
;
2238 TRACE("Type name: %s.\n", debugstr_a(t
->name
));
2240 t
->type_class
= D3D10_SVC_OBJECT
;
2242 t
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
2246 v
->u
.shader
.isinline
= 1;
2247 set_variable_vtbl(v
);
2249 if (!copy_name("$Anonymous", &v
->name
))
2251 ERR("Failed to copy semantic.\n");
2252 return E_OUTOFMEMORY
;
2254 TRACE("Variable name: %s.\n", debugstr_a(v
->name
));
2259 static const struct d3d10_effect_state_storage_info
*get_storage_info(D3D_SHADER_VARIABLE_TYPE id
)
2263 for (i
= 0; i
< ARRAY_SIZE(d3d10_effect_state_storage_info
); ++i
)
2265 if (d3d10_effect_state_storage_info
[i
].id
== id
)
2266 return &d3d10_effect_state_storage_info
[i
];
2272 static BOOL
read_value_list(const char *data
, size_t data_size
, uint32_t offset
,
2273 D3D_SHADER_VARIABLE_TYPE out_type
, unsigned int out_base
, unsigned int out_size
,
2276 uint32_t t
, value
, count
, type_flags
;
2277 D3D_SHADER_VARIABLE_TYPE in_type
;
2281 if (offset
>= data_size
|| !require_space(offset
, 1, sizeof(count
), data_size
))
2283 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
2287 ptr
= data
+ offset
;
2288 count
= read_u32(&ptr
);
2289 if (count
!= out_size
)
2292 if (!require_space(ptr
- data
, count
, 2 * sizeof(DWORD
), data_size
))
2294 WARN("Invalid value count %#x (offset %#x, data size %#Ix).\n", count
, offset
, data_size
);
2298 TRACE("%u values:\n", count
);
2299 for (i
= 0; i
< count
; ++i
)
2301 unsigned int out_idx
= out_base
* out_size
+ i
;
2304 value
= read_u32(&ptr
);
2306 in_type
= d3d10_variable_type(t
, FALSE
, &type_flags
);
2307 TRACE("\t%s: %#x.\n", debug_d3d10_shader_variable_type(in_type
), value
);
2311 case D3D10_SVT_FLOAT
:
2313 case D3D10_SVT_UINT
:
2314 case D3D10_SVT_UINT8
:
2315 case D3D10_SVT_BOOL
:
2316 if (!d3d10_effect_read_numeric_value(value
, in_type
, out_type
, out_data
, out_idx
))
2320 case D3D10_SVT_VERTEXSHADER
:
2321 *(void **)out_data
= &anonymous_vs
;
2324 case D3D10_SVT_PIXELSHADER
:
2325 *(void **)out_data
= &anonymous_ps
;
2328 case D3D10_SVT_GEOMETRYSHADER
:
2329 *(void **)out_data
= &anonymous_gs
;
2332 case D3D10_SVT_TEXTURE
:
2333 *(void **)out_data
= &null_shader_resource_variable
;
2336 case D3D10_SVT_DEPTHSTENCIL
:
2337 *(void **)out_data
= &null_depth_stencil_variable
;
2340 case D3D10_SVT_BLEND
:
2341 *(void **)out_data
= &null_blend_variable
;
2345 FIXME("Unhandled out_type %#x.\n", out_type
);
2353 static BOOL
is_object_property(const struct d3d10_effect_state_property_info
*property_info
)
2355 switch (property_info
->type
)
2357 case D3D10_SVT_RASTERIZER
:
2358 case D3D10_SVT_DEPTHSTENCIL
:
2359 case D3D10_SVT_BLEND
:
2360 case D3D10_SVT_RENDERTARGETVIEW
:
2361 case D3D10_SVT_DEPTHSTENCILVIEW
:
2362 case D3D10_SVT_VERTEXSHADER
:
2363 case D3D10_SVT_PIXELSHADER
:
2364 case D3D10_SVT_GEOMETRYSHADER
:
2365 case D3D10_SVT_TEXTURE
:
2372 static BOOL
is_object_property_type_matching(const struct d3d10_effect_state_property_info
*property_info
,
2373 const struct d3d10_effect_variable
*v
)
2375 if (property_info
->type
== v
->type
->basetype
) return TRUE
;
2377 switch (v
->type
->basetype
)
2379 case D3D10_SVT_TEXTURE1D
:
2380 case D3D10_SVT_TEXTURE1DARRAY
:
2381 case D3D10_SVT_TEXTURE2D
:
2382 case D3D10_SVT_TEXTURE2DARRAY
:
2383 case D3D10_SVT_TEXTURE2DMS
:
2384 case D3D10_SVT_TEXTURE2DMSARRAY
:
2385 case D3D10_SVT_TEXTURE3D
:
2386 case D3D10_SVT_TEXTURECUBE
:
2387 if (property_info
->type
== D3D10_SVT_TEXTURE
) return TRUE
;
2394 static HRESULT
parse_fx10_preshader_instr(struct d3d10_preshader_parse_context
*context
,
2395 unsigned int *offset
, const char **ptr
, unsigned int data_size
)
2397 const struct preshader_op_info
*op_info
;
2398 unsigned int i
, param_count
, size
;
2399 struct preshader_instr ins
;
2400 uint32_t input_count
;
2402 if (!require_space(*offset
, 2, sizeof(uint32_t), data_size
))
2404 WARN("Malformed FXLC table, size %u.\n", data_size
);
2408 *(uint32_t *)&ins
= read_u32(ptr
);
2409 input_count
= read_u32(ptr
);
2410 *offset
+= 2 * sizeof(uint32_t);
2412 if (!(op_info
= d3d10_effect_get_op_info(ins
.opcode
)))
2414 FIXME("Unrecognized opcode %#x.\n", ins
.opcode
);
2418 TRACE("Opcode %#x (%s) (%u,%u), input count %u.\n", ins
.opcode
, op_info
->name
,
2419 ins
.comp_count
, ins
.scalar
, input_count
);
2421 /* Inputs + one output */
2422 param_count
= input_count
+ 1;
2424 if (!require_space(*offset
, 3 * param_count
, sizeof(uint32_t), data_size
))
2426 WARN("Malformed FXLC table, opcode %#x.\n", ins
.opcode
);
2429 *offset
+= 3 * param_count
* sizeof(uint32_t);
2431 for (i
= 0; i
< param_count
; ++i
)
2433 uint32_t flags
, regt
, param_offset
;
2435 flags
= read_u32(ptr
);
2438 FIXME("Argument flags are not supported %#x.\n", flags
);
2439 return E_UNEXPECTED
;
2442 regt
= read_u32(ptr
);
2443 param_offset
= read_u32(ptr
);
2447 case D3D10_REG_TABLE_CONSTANTS
:
2448 case D3D10_REG_TABLE_CB
:
2449 case D3D10_REG_TABLE_RESULT
:
2450 case D3D10_REG_TABLE_TEMP
:
2451 size
= param_offset
+ (ins
.scalar
&& i
== 0 ? 1 : ins
.comp_count
);
2452 context
->table_sizes
[regt
] = max(context
->table_sizes
[regt
], size
);
2455 FIXME("Unexpected register table index %u.\n", regt
);
2463 static HRESULT
parse_fx10_fxlc(void *ctx
, const char *data
, unsigned int data_size
)
2465 struct d3d10_preshader_parse_context
*context
= ctx
;
2466 struct d3d10_effect_preshader
*p
= context
->preshader
;
2467 unsigned int i
, offset
= 4;
2472 if (data_size
% sizeof(uint32_t))
2474 WARN("FXLC size misaligned %u.\n", data_size
);
2478 if (FAILED(hr
= D3DCreateBlob(data_size
, &p
->code
)))
2480 memcpy(ID3D10Blob_GetBufferPointer(p
->code
), data
, data_size
);
2483 ins_count
= read_u32(&ptr
);
2484 TRACE("%u instructions.\n", ins_count
);
2486 for (i
= 0; i
< ins_count
; ++i
)
2488 if (FAILED(hr
= parse_fx10_preshader_instr(context
, &offset
, &ptr
, data_size
)))
2490 WARN("Failed to parse instruction %u.\n", i
);
2495 if (FAILED(hr
= d3d10_reg_table_allocate(&p
->reg_tables
[D3D10_REG_TABLE_RESULT
],
2496 context
->table_sizes
[D3D10_REG_TABLE_RESULT
]))) return hr
;
2497 if (FAILED(hr
= d3d10_reg_table_allocate(&p
->reg_tables
[D3D10_REG_TABLE_TEMP
],
2498 context
->table_sizes
[D3D10_REG_TABLE_TEMP
]))) return hr
;
2503 static HRESULT
parse_fx10_cli4(void *ctx
, const char *data
, unsigned int data_size
)
2505 struct d3d10_preshader_parse_context
*context
= ctx
;
2506 struct d3d10_effect_preshader
*p
= context
->preshader
;
2507 struct d3d10_reg_table
*table
= &p
->reg_tables
[D3D10_REG_TABLE_CONSTANTS
];
2508 const char *ptr
= data
;
2512 if (data_size
< sizeof(DWORD
))
2514 WARN("Invalid CLI4 chunk size %u.\n", data_size
);
2518 count
= read_u32(&ptr
);
2520 TRACE("%u literal constants.\n", count
);
2522 if (!require_space(4, count
, sizeof(float), data_size
))
2524 WARN("Invalid constant table size %u.\n", data_size
);
2528 if (FAILED(hr
= d3d10_reg_table_allocate(table
, count
)))
2531 memcpy(table
->f
, ptr
, table
->count
* sizeof(*table
->f
));
2536 static HRESULT
parse_fx10_ctab(void *ctx
, const char *data
, unsigned int data_size
)
2538 struct d3d10_preshader_parse_context
*context
= ctx
;
2539 struct d3d10_effect_preshader
*p
= context
->preshader
;
2546 uint32_t constantinfo
;
2550 struct ctab_const_info
2554 WORD register_index
;
2555 WORD register_count
;
2558 uint32_t default_value
;
2560 unsigned int i
, cb_reg_count
= 0;
2561 const char *ptr
= data
;
2566 if (data_size
< sizeof(header
))
2568 WARN("Invalid constant table size %u.\n", data_size
);
2572 header
.size
= read_u32(&ptr
);
2573 header
.creator
= read_u32(&ptr
);
2574 header
.version
= read_u32(&ptr
);
2575 header
.constants
= read_u32(&ptr
);
2576 header
.constantinfo
= read_u32(&ptr
);
2577 header
.flags
= read_u32(&ptr
);
2578 header
.target
= read_u32(&ptr
);
2580 if (!require_space(header
.constantinfo
, header
.constants
, sizeof(*info
), data_size
))
2582 WARN("Invalid constant info section offset %#x.\n", header
.constantinfo
);
2586 p
->vars_count
= header
.constants
;
2588 TRACE("Variable count %u.\n", p
->vars_count
);
2590 if (!(p
->vars
= calloc(p
->vars_count
, sizeof(*p
->vars
))))
2591 return E_OUTOFMEMORY
;
2593 info
= (struct ctab_const_info
*)(data
+ header
.constantinfo
);
2594 for (i
= 0; i
< p
->vars_count
; ++i
, ++info
)
2596 if (!fx10_get_string(data
, data_size
, info
->name
, &name
, &name_len
))
2599 if (!(p
->vars
[i
].v
= d3d10_effect_get_variable_by_name(context
->effect
, name
)))
2601 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
2605 /* 4 components per register */
2606 p
->vars
[i
].offset
= info
->register_index
* 4;
2607 p
->vars
[i
].length
= info
->register_count
* 4;
2609 cb_reg_count
= max(cb_reg_count
, info
->register_index
+ info
->register_count
);
2612 /* Allocate contiguous "constant buffer" for all referenced variables. */
2613 if (FAILED(hr
= d3d10_reg_table_allocate(&p
->reg_tables
[D3D10_REG_TABLE_CB
], cb_reg_count
* 4)))
2615 WARN("Failed to allocate variables buffer.\n");
2622 static HRESULT
fxlvm_chunk_handler(const char *data
, size_t data_size
, uint32_t tag
, void *ctx
)
2624 TRACE("Chunk tag: %s, size: %Iu.\n", debugstr_an((const char *)&tag
, 4), data_size
);
2629 return parse_fx10_fxlc(ctx
, data
, data_size
);
2632 return parse_fx10_cli4(ctx
, data
, data_size
);
2635 return parse_fx10_ctab(ctx
, data
, data_size
);
2638 FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag
, 4));
2643 static HRESULT
parse_fx10_preshader(const char *data
, size_t data_size
,
2644 struct d3d10_effect
*effect
, struct d3d10_effect_preshader
*preshader
)
2646 struct d3d10_preshader_parse_context context
;
2649 memset(preshader
, 0, sizeof(*preshader
));
2650 memset(&context
, 0, sizeof(context
));
2651 context
.preshader
= preshader
;
2652 context
.effect
= effect
;
2654 if (FAILED(hr
= parse_dxbc(data
, data_size
, fxlvm_chunk_handler
, &context
)))
2657 /* Constant buffer and literal constants are preallocated, validate here that expression
2658 has no invalid accesses for those. */
2660 if (context
.table_sizes
[D3D10_REG_TABLE_CONSTANTS
] >
2661 preshader
->reg_tables
[D3D10_REG_TABLE_CONSTANTS
].count
)
2663 WARN("Expression references out of bounds literal constant.\n");
2667 if (context
.table_sizes
[D3D10_REG_TABLE_CB
] > preshader
->reg_tables
[D3D10_REG_TABLE_CB
].count
)
2669 WARN("Expression references out of bounds variable.\n");
2676 static HRESULT
d3d10_effect_add_prop_dependency(struct d3d10_effect_prop_dependencies
*d
,
2677 const struct d3d10_effect_prop_dependency
*dep
)
2679 if (!d3d_array_reserve((void **)&d
->entries
, &d
->capacity
, d
->count
+ 1, sizeof(*d
->entries
)))
2680 return E_OUTOFMEMORY
;
2682 d
->entries
[d
->count
++] = *dep
;
2687 static HRESULT
parse_fx10_property_assignment(const char *data
, size_t data_size
,
2688 const char **ptr
, enum d3d10_effect_container_type container_type
,
2689 struct d3d10_effect
*effect
, void *container
, struct d3d10_effect_prop_dependencies
*d
)
2691 uint32_t id
, idx
, variable_idx
, operation
, value_offset
, sodecl_offset
;
2692 const struct d3d10_effect_state_property_info
*property_info
;
2693 struct d3d10_effect_prop_dependency dep
;
2694 struct d3d10_effect_variable
*variable
;
2695 uint32_t code_offset
, blob_size
;
2696 const char *data_ptr
, *name
;
2697 unsigned int *dst_index
;
2703 idx
= read_u32(ptr
);
2704 operation
= read_u32(ptr
);
2705 value_offset
= read_u32(ptr
);
2707 if (id
>= ARRAY_SIZE(property_infos
))
2709 FIXME("Unknown property id %#x.\n", id
);
2712 property_info
= &property_infos
[id
];
2714 TRACE("Property %s[%#x] = value list @ offset %#x.\n", property_info
->name
, idx
, value_offset
);
2716 if (property_info
->container_type
!= container_type
)
2718 ERR("Invalid container type %#x for property %#x.\n", container_type
, id
);
2722 if (idx
>= property_info
->count
)
2724 ERR("Invalid index %#x for property %#x.\n", idx
, id
);
2728 if (property_info
->offset
== ~0u)
2730 ERR("Unsupported property %#x.\n", id
);
2734 dst
= (char *)container
+ property_info
->offset
;
2735 dst_index
= (unsigned int *)((char *)container
+ property_info
->index_offset
);
2739 case D3D10_EOO_CONST
:
2741 /* Constant values output directly to backing store. */
2742 if (!read_value_list(data
, data_size
, value_offset
, property_info
->type
, idx
,
2743 property_info
->size
, dst
))
2745 ERR("Failed to read values for property %#x.\n", id
);
2753 if (!fx10_get_string(data
, data_size
, value_offset
, &name
, &name_len
))
2755 WARN("Failed to get variable name.\n");
2758 TRACE("Variable name %s.\n", debugstr_a(name
));
2760 if (!(variable
= d3d10_effect_get_variable_by_name(effect
, name
)))
2762 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
2766 if (is_object_property(property_info
))
2768 if (variable
->type
->element_count
)
2770 WARN("Unexpected array variable value %s.\n", debugstr_a(name
));
2774 if (!is_object_property_type_matching(property_info
, variable
))
2776 WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
2777 variable
->type
->basetype
, property_info
->type
);
2781 ((void **)dst
)[idx
] = variable
;
2785 if (property_info
->size
* sizeof(float) > variable
->type
->size_unpacked
)
2787 WARN("Mismatching variable size %u, property size %u.\n",
2788 variable
->type
->size_unpacked
, property_info
->size
);
2794 dep
.operation
= operation
;
2795 dep
.var
.v
= variable
;
2798 return d3d10_effect_add_prop_dependency(d
, &dep
);
2803 case D3D10_EOO_CONST_INDEX
:
2805 /* Array variable, constant index. */
2806 if (value_offset
>= data_size
|| !require_space(value_offset
, 2, sizeof(DWORD
), data_size
))
2808 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2811 data_ptr
= data
+ value_offset
;
2812 value_offset
= read_u32(&data_ptr
);
2813 variable_idx
= read_u32(&data_ptr
);
2815 if (!fx10_get_string(data
, data_size
, value_offset
, &name
, &name_len
))
2817 WARN("Failed to get variable name.\n");
2821 TRACE("Variable name %s[%s%u].\n", debugstr_a(name
), is_object_property(property_info
) ?
2822 "" : "offset ", variable_idx
);
2824 if (!(variable
= d3d10_effect_get_variable_by_name(effect
, name
)))
2826 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
2830 if (is_object_property(property_info
))
2832 if (!variable
->type
->element_count
|| variable_idx
>= variable
->type
->element_count
)
2834 WARN("Invalid array size %u.\n", variable
->type
->element_count
);
2838 if (!is_object_property_type_matching(property_info
, variable
))
2840 WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
2841 variable
->type
->basetype
, property_info
->type
);
2845 /* Shader variables are special, they are referenced via array, with index stored separately. */
2846 switch (property_info
->type
)
2848 case D3D10_SVT_VERTEXSHADER
:
2849 case D3D10_SVT_PIXELSHADER
:
2850 case D3D10_SVT_GEOMETRYSHADER
:
2851 ((void **)dst
)[idx
] = variable
;
2852 *dst_index
= variable_idx
;
2855 ((void **)dst
)[idx
] = &variable
->elements
[variable_idx
];
2860 unsigned int offset
= variable_idx
* sizeof(float);
2862 if (offset
>= variable
->type
->size_unpacked
||
2863 variable
->type
->size_unpacked
- offset
< property_info
->size
* sizeof(float))
2865 WARN("Invalid numeric variable data offset %u.\n", variable_idx
);
2871 dep
.operation
= operation
;
2872 dep
.var
.v
= variable
;
2873 dep
.var
.offset
= offset
;
2875 return d3d10_effect_add_prop_dependency(d
, &dep
);
2880 case D3D10_EOO_INDEX_EXPRESSION
:
2882 /* Variable, and an expression for its index. */
2883 if (value_offset
>= data_size
|| !require_space(value_offset
, 2, sizeof(DWORD
), data_size
))
2885 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2889 data_ptr
= data
+ value_offset
;
2890 value_offset
= read_u32(&data_ptr
);
2891 code_offset
= read_u32(&data_ptr
);
2893 if (!fx10_get_string(data
, data_size
, value_offset
, &name
, &name_len
))
2895 WARN("Failed to get variable name.\n");
2899 TRACE("Variable name %s[<expr>].\n", debugstr_a(name
));
2901 if (!(variable
= d3d10_effect_get_variable_by_name(effect
, name
)))
2903 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
2907 if (!variable
->type
->element_count
)
2909 WARN("Expected array variable.\n");
2913 if (!is_object_property(property_info
))
2915 WARN("Expected object type property used with indexed expression.\n");
2919 if (code_offset
>= data_size
|| !require_space(code_offset
, 1, sizeof(DWORD
), data_size
))
2921 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2925 data_ptr
= data
+ code_offset
;
2926 blob_size
= read_u32(&data_ptr
);
2928 if (!require_space(code_offset
, 1, sizeof(uint32_t) + blob_size
, data_size
))
2930 WARN("Invalid offset %#x (data size %#Ix).\n", code_offset
, data_size
);
2936 dep
.operation
= operation
;
2937 dep
.index_expr
.v
= variable
;
2938 if (FAILED(hr
= parse_fx10_preshader(data_ptr
, blob_size
, effect
, &dep
.index_expr
.index
)))
2940 WARN("Failed to parse preshader, hr %#lx.\n", hr
);
2944 return d3d10_effect_add_prop_dependency(d
, &dep
);
2946 case D3D10_EOO_VALUE_EXPRESSION
:
2948 if (value_offset
>= data_size
|| !require_space(value_offset
, 1, sizeof(uint32_t), data_size
))
2950 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2954 data_ptr
= data
+ value_offset
;
2955 blob_size
= read_u32(&data_ptr
);
2957 if (!require_space(value_offset
, 1, sizeof(uint32_t) + blob_size
, data_size
))
2959 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2965 dep
.operation
= operation
;
2966 if (FAILED(hr
= parse_fx10_preshader(data_ptr
, blob_size
, effect
, &dep
.value_expr
.value
)))
2968 WARN("Failed to parse preshader, hr %#lx.\n", hr
);
2972 return d3d10_effect_add_prop_dependency(d
, &dep
);
2974 case D3D10_EOO_ANONYMOUS_SHADER
:
2976 /* Anonymous shader */
2977 if (effect
->anonymous_shader_current
>= effect
->anonymous_shader_count
)
2979 ERR("Anonymous shader count is wrong!\n");
2983 if (value_offset
>= data_size
|| !require_space(value_offset
, 2, sizeof(DWORD
), data_size
))
2985 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2988 data_ptr
= data
+ value_offset
;
2989 value_offset
= read_u32(&data_ptr
);
2990 sodecl_offset
= read_u32(&data_ptr
);
2992 TRACE("Effect object starts at offset %#x.\n", value_offset
);
2994 if (FAILED(hr
= parse_fx10_anonymous_shader(effect
, property_info
->type
,
2995 &effect
->anonymous_shaders
[effect
->anonymous_shader_current
])))
2998 variable
= &effect
->anonymous_shaders
[effect
->anonymous_shader_current
].shader
;
2999 ++effect
->anonymous_shader_current
;
3003 TRACE("Anonymous shader stream output declaration at offset %#x.\n", sodecl_offset
);
3004 if (!fx10_copy_string(data
, data_size
, sodecl_offset
,
3005 &variable
->u
.shader
.stream_output_declaration
))
3007 ERR("Failed to copy stream output declaration.\n");
3011 TRACE("Stream output declaration: %s.\n", debugstr_a(variable
->u
.shader
.stream_output_declaration
));
3014 switch (property_info
->type
)
3016 case D3D10_SVT_VERTEXSHADER
:
3017 case D3D10_SVT_PIXELSHADER
:
3018 case D3D10_SVT_GEOMETRYSHADER
:
3019 if (FAILED(hr
= parse_fx10_shader(data
, data_size
, value_offset
, variable
)))
3024 WARN("Unexpected shader type %#x.\n", property_info
->type
);
3028 ((void **)dst
)[idx
] = variable
;
3033 FIXME("Unhandled operation %#x.\n", operation
);
3040 static HRESULT
parse_fx10_pass(const char *data
, size_t data_size
,
3041 const char **ptr
, struct d3d10_effect_pass
*p
)
3043 uint32_t offset
, object_count
;
3047 offset
= read_u32(ptr
);
3048 TRACE("Pass name at offset %#x.\n", offset
);
3050 if (!fx10_copy_string(data
, data_size
, offset
, &p
->name
))
3052 ERR("Failed to copy name.\n");
3053 return E_OUTOFMEMORY
;
3055 TRACE("Pass name: %s.\n", debugstr_a(p
->name
));
3057 object_count
= read_u32(ptr
);
3058 TRACE("Pass has %u effect objects.\n", object_count
);
3060 p
->annotations
.count
= read_u32(ptr
);
3061 TRACE("Pass has %u annotations.\n", p
->annotations
.count
);
3063 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, p
->technique
->effect
,
3066 ERR("Failed to parse pass annotations, hr %#lx.\n", hr
);
3070 p
->vs
.shader
= &null_shader_variable
;
3071 p
->ps
.shader
= &null_shader_variable
;
3072 p
->gs
.shader
= &null_shader_variable
;
3074 for (i
= 0; i
< object_count
; ++i
)
3076 if (FAILED(hr
= parse_fx10_property_assignment(data
, data_size
, ptr
,
3077 D3D10_C_PASS
, p
->technique
->effect
, p
, &p
->dependencies
)))
3079 WARN("Failed to parse pass assignment %u, hr %#lx.\n", i
, hr
);
3087 static HRESULT
parse_fx10_technique(const char *data
, size_t data_size
,
3088 const char **ptr
, struct d3d10_effect_technique
*t
)
3094 offset
= read_u32(ptr
);
3095 TRACE("Technique name at offset %#x.\n", offset
);
3097 if (!fx10_copy_string(data
, data_size
, offset
, &t
->name
))
3099 ERR("Failed to copy name.\n");
3100 return E_OUTOFMEMORY
;
3102 TRACE("Technique name: %s.\n", debugstr_a(t
->name
));
3104 t
->pass_count
= read_u32(ptr
);
3105 TRACE("Technique has %u passes.\n", t
->pass_count
);
3107 t
->annotations
.count
= read_u32(ptr
);
3108 TRACE("Technique has %u annotations.\n", t
->annotations
.count
);
3110 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, t
->effect
,
3113 ERR("Failed to parse technique annotations, hr %#lx.\n", hr
);
3117 if (!(t
->passes
= calloc(t
->pass_count
, sizeof(*t
->passes
))))
3119 ERR("Failed to allocate passes memory\n");
3120 return E_OUTOFMEMORY
;
3123 for (i
= 0; i
< t
->pass_count
; ++i
)
3125 struct d3d10_effect_pass
*p
= &t
->passes
[i
];
3127 p
->ID3D10EffectPass_iface
.lpVtbl
= &d3d10_effect_pass_vtbl
;
3130 if (FAILED(hr
= parse_fx10_pass(data
, data_size
, ptr
, p
)))
3137 static void parse_fx10_set_default_numeric_value(const char **ptr
, struct d3d10_effect_variable
*v
)
3139 float *dst
= (float *)(v
->buffer
->u
.buffer
.local_buffer
+ v
->buffer_offset
), *src
;
3140 BOOL col_major
= v
->type
->type_class
== D3D10_SVC_MATRIX_COLUMNS
;
3141 unsigned int col_count
= v
->type
->column_count
, col
;
3142 unsigned int row_count
= v
->type
->row_count
, row
;
3144 src
= (float *)*ptr
;
3148 for (col
= 0; col
< col_count
; ++col
)
3150 for (row
= 0; row
< row_count
; ++row
)
3151 dst
[row
] = src
[row
* col_count
+ col
];
3157 for (row
= 0; row
< row_count
; ++row
)
3159 memcpy(dst
, src
, col_count
* sizeof(float));
3165 *ptr
+= col_count
* row_count
* sizeof(float);
3168 static void parse_fx10_default_value(const char **ptr
, struct d3d10_effect_variable
*var
)
3170 unsigned int element_count
= max(var
->type
->element_count
, 1), i
, m
;
3171 struct d3d10_effect_variable
*v
;
3173 for (i
= 0; i
< element_count
; ++i
)
3175 v
= d3d10_array_get_element(var
, i
);
3177 switch (v
->type
->type_class
)
3179 case D3D10_SVC_STRUCT
:
3180 for (m
= 0; m
< v
->type
->member_count
; ++m
)
3181 parse_fx10_default_value(ptr
, &v
->members
[m
]);
3183 case D3D10_SVC_SCALAR
:
3184 case D3D10_SVC_VECTOR
:
3185 case D3D10_SVC_MATRIX_COLUMNS
:
3186 case D3D10_SVC_MATRIX_ROWS
:
3187 parse_fx10_set_default_numeric_value(ptr
, v
);
3190 FIXME("Unexpected initial value for type %#x.\n", v
->type
->basetype
);
3196 static void d3d10_effect_variable_update_buffer_offsets(struct d3d10_effect_variable
*v
,
3197 unsigned int offset
)
3201 for (i
= 0; i
< v
->type
->member_count
; ++i
)
3202 d3d10_effect_variable_update_buffer_offsets(&v
->members
[i
], offset
);
3204 for (i
= 0; i
< v
->type
->element_count
; ++i
)
3205 d3d10_effect_variable_update_buffer_offsets(&v
->elements
[i
], offset
);
3207 v
->buffer_offset
+= offset
;
3210 static HRESULT
parse_fx10_numeric_variable(const char *data
, size_t data_size
,
3211 const char **ptr
, BOOL local
, struct d3d10_effect_variable
*v
)
3213 uint32_t offset
, flags
, default_value_offset
, buffer_offset
;
3214 const char *data_ptr
;
3217 if (FAILED(hr
= parse_fx10_variable_head(data
, data_size
, ptr
, v
)))
3220 offset
= read_u32(ptr
);
3221 TRACE("Variable semantic at offset %#x.\n", offset
);
3223 if (!fx10_copy_string(data
, data_size
, offset
, &v
->semantic
))
3225 ERR("Failed to copy semantic.\n");
3226 return E_OUTOFMEMORY
;
3228 TRACE("Variable semantic: %s.\n", debugstr_a(v
->semantic
));
3230 buffer_offset
= read_u32(ptr
);
3231 TRACE("Variable offset in buffer: %#x.\n", buffer_offset
);
3233 default_value_offset
= read_u32(ptr
);
3234 TRACE("Variable default value offset: %#x.\n", default_value_offset
);
3236 flags
= read_u32(ptr
);
3237 TRACE("Variable flags: %#x.\n", flags
);
3241 /* At this point storage offsets for members and array elements are relative to containing
3242 variable. Update them by moving to correct offset within a buffer. */
3243 d3d10_effect_variable_update_buffer_offsets(v
, buffer_offset
);
3247 if (default_value_offset
)
3249 if (!require_space(default_value_offset
, 1, v
->type
->size_packed
, data_size
))
3251 WARN("Invalid default value offset %#x, variable packed size %u.\n", default_value_offset
,
3252 v
->type
->size_packed
);
3256 data_ptr
= data
+ default_value_offset
;
3257 parse_fx10_default_value(&data_ptr
, v
);
3260 v
->annotations
.count
= read_u32(ptr
);
3261 TRACE("Variable has %u annotations.\n", v
->annotations
.count
);
3263 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, v
->effect
,
3266 ERR("Failed to parse variable annotations, hr %#lx.\n", hr
);
3271 if (v
->flag
& D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
)
3272 v
->explicit_bind_point
= v
->buffer_offset
;
3277 static HRESULT
create_state_object(struct d3d10_effect_variable
*v
)
3279 ID3D10Device
*device
= v
->effect
->device
;
3282 switch (v
->type
->basetype
)
3284 case D3D10_SVT_DEPTHSTENCIL
:
3285 if (FAILED(hr
= ID3D10Device_CreateDepthStencilState(device
,
3286 &v
->u
.state
.desc
.depth_stencil
, &v
->u
.state
.object
.depth_stencil
)))
3290 case D3D10_SVT_BLEND
:
3291 if (FAILED(hr
= ID3D10Device_CreateBlendState(device
,
3292 &v
->u
.state
.desc
.blend
, &v
->u
.state
.object
.blend
)))
3296 case D3D10_SVT_RASTERIZER
:
3297 if (FAILED(hr
= ID3D10Device_CreateRasterizerState(device
,
3298 &v
->u
.state
.desc
.rasterizer
, &v
->u
.state
.object
.rasterizer
)))
3302 case D3D10_SVT_SAMPLER
:
3303 if (FAILED(hr
= ID3D10Device_CreateSamplerState(device
,
3304 &v
->u
.state
.desc
.sampler
.desc
, &v
->u
.state
.object
.sampler
)))
3309 ERR("Unhandled variable type %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
3316 static HRESULT
parse_fx10_object_variable(const char *data
, size_t data_size
,
3317 const char **ptr
, BOOL shared_type_desc
, struct d3d10_effect_variable
*v
)
3319 struct d3d10_effect_var_array
*vars
;
3320 struct d3d10_effect_variable
*var
;
3321 unsigned int i
, j
, element_count
;
3325 if (FAILED(hr
= parse_fx10_variable_head(data
, data_size
, ptr
, v
)))
3328 offset
= read_u32(ptr
);
3329 TRACE("Variable semantic at offset %#x.\n", offset
);
3331 if (!fx10_copy_string(data
, data_size
, offset
, &v
->semantic
))
3333 ERR("Failed to copy semantic.\n");
3334 return E_OUTOFMEMORY
;
3336 TRACE("Variable semantic: %s.\n", debugstr_a(v
->semantic
));
3338 v
->explicit_bind_point
= read_u32(ptr
);
3339 TRACE("Variable explicit bind point %#x.\n", v
->explicit_bind_point
);
3341 /* Shared variable description contains only type information. */
3342 if (shared_type_desc
) return S_OK
;
3344 element_count
= max(v
->type
->element_count
, 1);
3346 switch (v
->type
->basetype
)
3348 case D3D10_SVT_TEXTURE
:
3349 case D3D10_SVT_TEXTURE1D
:
3350 case D3D10_SVT_TEXTURE1DARRAY
:
3351 case D3D10_SVT_TEXTURE2D
:
3352 case D3D10_SVT_TEXTURE2DARRAY
:
3353 case D3D10_SVT_TEXTURE2DMS
:
3354 case D3D10_SVT_TEXTURE2DMSARRAY
:
3355 case D3D10_SVT_TEXTURE3D
:
3356 case D3D10_SVT_TEXTURECUBE
:
3357 if (!(v
->u
.resource
.srv
= calloc(element_count
, sizeof(*v
->u
.resource
.srv
))))
3359 ERR("Failed to allocate shader resource view array memory.\n");
3360 return E_OUTOFMEMORY
;
3362 v
->u
.resource
.parent
= TRUE
;
3366 for (i
= 0; i
< v
->type
->element_count
; ++i
)
3368 v
->elements
[i
].u
.resource
.srv
= &v
->u
.resource
.srv
[i
];
3369 v
->elements
[i
].u
.resource
.parent
= FALSE
;
3374 case D3D10_SVT_RENDERTARGETVIEW
:
3375 case D3D10_SVT_DEPTHSTENCILVIEW
:
3376 case D3D10_SVT_BUFFER
:
3377 TRACE("SVT could not have elements.\n");
3380 case D3D10_SVT_VERTEXSHADER
:
3381 case D3D10_SVT_PIXELSHADER
:
3382 case D3D10_SVT_GEOMETRYSHADER
:
3383 TRACE("Shader type is %s\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
3384 for (i
= 0; i
< element_count
; ++i
)
3386 uint32_t shader_offset
, sodecl_offset
;
3388 var
= d3d10_array_get_element(v
, i
);
3390 shader_offset
= read_u32(ptr
);
3391 TRACE("Shader offset: %#x.\n", shader_offset
);
3393 if (v
->type
->flags
& D3D10_EOT_FLAG_GS_SO
)
3395 sodecl_offset
= read_u32(ptr
);
3396 TRACE("Stream output declaration at offset %#x.\n", sodecl_offset
);
3398 if (!fx10_copy_string(data
, data_size
, sodecl_offset
,
3399 &var
->u
.shader
.stream_output_declaration
))
3401 ERR("Failed to copy stream output declaration.\n");
3402 return E_OUTOFMEMORY
;
3405 TRACE("Stream output declaration: %s.\n", debugstr_a(var
->u
.shader
.stream_output_declaration
));
3408 if (FAILED(hr
= parse_fx10_shader(data
, data_size
, shader_offset
, var
)))
3413 case D3D10_SVT_DEPTHSTENCIL
:
3414 case D3D10_SVT_BLEND
:
3415 case D3D10_SVT_RASTERIZER
:
3416 case D3D10_SVT_SAMPLER
:
3418 const struct d3d10_effect_state_storage_info
*storage_info
;
3420 if (!(storage_info
= get_storage_info(v
->type
->basetype
)))
3422 FIXME("Failed to get backing store info for type %s.\n",
3423 debug_d3d10_shader_variable_type(v
->type
->basetype
));
3427 if (storage_info
->size
> sizeof(v
->u
.state
.desc
))
3429 ERR("Invalid storage size %#Ix.\n", storage_info
->size
);
3433 switch (v
->type
->basetype
)
3435 case D3D10_SVT_DEPTHSTENCIL
:
3436 vars
= &v
->effect
->ds_states
;
3438 case D3D10_SVT_BLEND
:
3439 vars
= &v
->effect
->blend_states
;
3441 case D3D10_SVT_RASTERIZER
:
3442 vars
= &v
->effect
->rs_states
;
3444 case D3D10_SVT_SAMPLER
:
3445 vars
= &v
->effect
->samplers
;
3451 for (i
= 0; i
< element_count
; ++i
)
3453 unsigned int prop_count
;
3455 var
= d3d10_array_get_element(v
, i
);
3457 if (vars
->current
>= vars
->count
)
3459 WARN("Wrong variable array size for %#x.\n", v
->type
->basetype
);
3462 var
->u
.state
.index
= vars
->current
;
3463 vars
->v
[vars
->current
++] = var
;
3465 prop_count
= read_u32(ptr
);
3466 TRACE("State object property count: %#x.\n", prop_count
);
3468 memcpy(&var
->u
.state
.desc
, storage_info
->default_state
, storage_info
->size
);
3470 for (j
= 0; j
< prop_count
; ++j
)
3472 if (FAILED(hr
= parse_fx10_property_assignment(data
, data_size
, ptr
,
3473 get_var_container_type(var
), var
->effect
, &var
->u
.state
.desc
,
3474 &var
->u
.state
.dependencies
)))
3476 ERR("Failed to read property list.\n");
3481 if (FAILED(hr
= create_state_object(var
)))
3488 FIXME("Unhandled case %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
3492 v
->annotations
.count
= read_u32(ptr
);
3493 TRACE("Variable has %u annotations.\n", v
->annotations
.count
);
3495 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, v
->effect
,
3498 ERR("Failed to parse variable annotations, hr %#lx.\n", hr
);
3505 static HRESULT
create_buffer_object(struct d3d10_effect_variable
*v
)
3507 D3D10_BUFFER_DESC buffer_desc
;
3508 D3D10_SUBRESOURCE_DATA subresource_data
;
3509 D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc
;
3510 ID3D10Device
*device
= v
->effect
->device
;
3513 buffer_desc
.ByteWidth
= v
->data_size
;
3514 buffer_desc
.Usage
= D3D10_USAGE_DEFAULT
;
3515 buffer_desc
.CPUAccessFlags
= 0;
3516 buffer_desc
.MiscFlags
= 0;
3517 if (v
->type
->basetype
== D3D10_SVT_CBUFFER
)
3518 buffer_desc
.BindFlags
= D3D10_BIND_CONSTANT_BUFFER
;
3520 buffer_desc
.BindFlags
= D3D10_BIND_SHADER_RESOURCE
;
3522 subresource_data
.pSysMem
= v
->u
.buffer
.local_buffer
;
3523 subresource_data
.SysMemPitch
= 0;
3524 subresource_data
.SysMemSlicePitch
= 0;
3526 if (FAILED(hr
= ID3D10Device_CreateBuffer(device
, &buffer_desc
, &subresource_data
, &v
->u
.buffer
.buffer
)))
3529 if (v
->type
->basetype
== D3D10_SVT_TBUFFER
)
3531 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
3532 srv_desc
.ViewDimension
= D3D_SRV_DIMENSION_BUFFER
;
3533 srv_desc
.Buffer
.ElementOffset
= 0;
3534 srv_desc
.Buffer
.ElementWidth
= v
->type
->size_unpacked
/ 16;
3535 if (v
->type
->size_unpacked
% 16)
3536 WARN("Unexpected texture buffer size not a multiple of 16.\n");
3538 if (FAILED(hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)v
->u
.buffer
.buffer
,
3539 &srv_desc
, &v
->u
.buffer
.resource_view
)))
3543 v
->u
.buffer
.resource_view
= NULL
;
3548 static HRESULT
parse_fx10_buffer(const char *data
, size_t data_size
, const char **ptr
,
3549 BOOL local
, struct d3d10_effect_variable
*l
)
3551 const char *prefix
= local
? "Local" : "Shared";
3554 D3D10_CBUFFER_TYPE d3d10_cbuffer_type
;
3556 unsigned int stride
= 0;
3558 /* Generate our own type, it isn't in the fx blob. */
3559 if (!(l
->type
= calloc(1, sizeof(*l
->type
))))
3561 ERR("Failed to allocate local buffer type memory.\n");
3562 return E_OUTOFMEMORY
;
3564 l
->type
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
3565 l
->type
->type_class
= D3D10_SVC_OBJECT
;
3566 l
->type
->effect
= l
->effect
;
3568 offset
= read_u32(ptr
);
3569 TRACE("%s buffer name at offset %#x.\n", prefix
, offset
);
3571 if (!fx10_copy_string(data
, data_size
, offset
, &l
->name
))
3573 ERR("Failed to copy name.\n");
3574 return E_OUTOFMEMORY
;
3576 TRACE("%s buffer name: %s.\n", prefix
, debugstr_a(l
->name
));
3578 l
->data_size
= read_u32(ptr
);
3579 TRACE("%s buffer data size: %#x.\n", prefix
, l
->data_size
);
3581 d3d10_cbuffer_type
= read_u32(ptr
);
3582 TRACE("%s buffer type: %#x.\n", prefix
, d3d10_cbuffer_type
);
3584 switch(d3d10_cbuffer_type
)
3586 case D3D10_CT_CBUFFER
:
3587 l
->type
->basetype
= D3D10_SVT_CBUFFER
;
3588 if (!copy_name("cbuffer", &l
->type
->name
))
3590 ERR("Failed to copy name.\n");
3591 return E_OUTOFMEMORY
;
3595 case D3D10_CT_TBUFFER
:
3596 l
->type
->basetype
= D3D10_SVT_TBUFFER
;
3597 if (!copy_name("tbuffer", &l
->type
->name
))
3599 ERR("Failed to copy name.\n");
3600 return E_OUTOFMEMORY
;
3605 ERR("Unexpected D3D10_CBUFFER_TYPE %#x!\n", d3d10_cbuffer_type
);
3609 l
->type
->member_count
= read_u32(ptr
);
3610 TRACE("%s buffer member count: %#x.\n", prefix
, l
->type
->member_count
);
3612 l
->explicit_bind_point
= read_u32(ptr
);
3613 TRACE("%s buffer explicit bind point: %#x.\n", prefix
, l
->explicit_bind_point
);
3615 if (l
->effect
->flags
& D3D10_EFFECT_IS_POOL
)
3616 l
->flag
|= D3D10_EFFECT_VARIABLE_POOLED
;
3620 l
->annotations
.count
= read_u32(ptr
);
3621 TRACE("Local buffer has %u annotations.\n", l
->annotations
.count
);
3623 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, l
->effect
,
3626 ERR("Failed to parse buffer annotations, hr %#lx.\n", hr
);
3631 if (!(l
->members
= calloc(l
->type
->member_count
, sizeof(*l
->members
))))
3633 ERR("Failed to allocate members memory.\n");
3634 return E_OUTOFMEMORY
;
3637 if (!(l
->type
->members
= calloc(l
->type
->member_count
, sizeof(*l
->type
->members
))))
3639 ERR("Failed to allocate type members memory.\n");
3640 return E_OUTOFMEMORY
;
3643 if (local
&& !(l
->u
.buffer
.local_buffer
= calloc(1, l
->data_size
)))
3645 ERR("Failed to allocate local constant buffer memory.\n");
3646 return E_OUTOFMEMORY
;
3649 for (i
= 0; i
< l
->type
->member_count
; ++i
)
3651 struct d3d10_effect_variable
*v
= &l
->members
[i
];
3652 struct d3d10_effect_type_member
*typem
= &l
->type
->members
[i
];
3655 v
->effect
= l
->effect
;
3657 if (FAILED(hr
= parse_fx10_numeric_variable(data
, data_size
, ptr
, local
, v
)))
3661 * Copy the values from the variable type to the constant buffers type
3662 * members structure, because it is our own generated type.
3664 typem
->type
= v
->type
;
3666 if (!copy_name(v
->name
, &typem
->name
))
3668 ERR("Failed to copy name.\n");
3669 return E_OUTOFMEMORY
;
3671 TRACE("Variable name: %s.\n", debugstr_a(typem
->name
));
3673 if (!copy_name(v
->semantic
, &typem
->semantic
))
3675 ERR("Failed to copy name.\n");
3676 return E_OUTOFMEMORY
;
3678 TRACE("Variable semantic: %s.\n", debugstr_a(typem
->semantic
));
3680 typem
->buffer_offset
= v
->buffer_offset
;
3681 TRACE("Variable buffer offset: %u.\n", typem
->buffer_offset
);
3683 l
->type
->size_packed
+= v
->type
->size_packed
;
3686 * For the complete constantbuffer the size_unpacked = stride,
3687 * the stride is calculated like this:
3689 * 1) if the constant buffer variables are packed with packoffset
3690 * - stride = the highest used constant
3691 * - the complete stride has to be a multiple of 0x10
3693 * 2) if the constant buffer variables are NOT packed with packoffset
3694 * - sum of unpacked size for all variables which fit in a 0x10 part
3695 * - if the size exceeds a 0x10 part, the rest of the old part is skipped
3696 * and a new part is started
3697 * - if the variable is a struct it is always used a new part
3698 * - the complete stride has to be a multiple of 0x10
3701 * 0x4, 0x4, 0x4, 0x8, 0x4, 0x14, 0x4
3702 * part 0x10 0x10 0x20 -> 0x40
3704 if (v
->flag
& D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
)
3706 if ((v
->type
->size_unpacked
+ v
->buffer_offset
) > stride
)
3708 stride
= v
->type
->size_unpacked
+ v
->buffer_offset
;
3713 if (v
->type
->type_class
== D3D10_SVC_STRUCT
)
3715 stride
= (stride
+ 0xf) & ~0xf;
3718 if ( ((stride
& 0xf) + v
->type
->size_unpacked
) > 0x10)
3720 stride
= (stride
+ 0xf) & ~0xf;
3723 stride
+= v
->type
->size_unpacked
;
3726 l
->type
->stride
= l
->type
->size_unpacked
= (stride
+ 0xf) & ~0xf;
3728 TRACE("%s constant buffer:\n", prefix
);
3729 TRACE("\tType name: %s.\n", debugstr_a(l
->type
->name
));
3730 TRACE("\tElement count: %u.\n", l
->type
->element_count
);
3731 TRACE("\tMember count: %u.\n", l
->type
->member_count
);
3732 TRACE("\tUnpacked size: %#x.\n", l
->type
->size_unpacked
);
3733 TRACE("\tStride: %#x.\n", l
->type
->stride
);
3734 TRACE("\tPacked size %#x.\n", l
->type
->size_packed
);
3735 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l
->type
->basetype
));
3736 TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l
->type
->type_class
));
3738 if (local
&& l
->data_size
)
3740 if (FAILED(hr
= create_buffer_object(l
)))
3742 WARN("Failed to create a buffer object, hr %#lx.\n", hr
);
3747 if (l
->explicit_bind_point
!= ~0u)
3748 l
->flag
|= D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
;
3753 static void d3d10_effect_type_member_destroy(struct d3d10_effect_type_member
*typem
)
3755 TRACE("effect type member %p.\n", typem
);
3757 /* Do not release typem->type, it will be covered by d3d10_effect_type_destroy(). */
3758 free(typem
->semantic
);
3762 static void d3d10_effect_type_destroy(struct wine_rb_entry
*entry
, void *context
)
3764 struct d3d10_effect_type
*t
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_effect_type
, entry
);
3766 TRACE("effect type %p.\n", t
);
3770 free(t
->elementtype
->name
);
3771 free(t
->elementtype
);
3778 for (i
= 0; i
< t
->member_count
; ++i
)
3780 d3d10_effect_type_member_destroy(&t
->members
[i
]);
3789 static BOOL
d3d10_effect_types_match(const struct d3d10_effect_type
*t1
,
3790 const struct d3d10_effect_type
*t2
)
3794 if (strcmp(t1
->name
, t2
->name
)) return FALSE
;
3795 if (t1
->basetype
!= t2
->basetype
) return FALSE
;
3796 if (t1
->type_class
!= t2
->type_class
) return FALSE
;
3797 if (t1
->element_count
!= t2
->element_count
) return FALSE
;
3798 if (t1
->element_count
) return d3d10_effect_types_match(t1
->elementtype
, t2
->elementtype
);
3799 if (t1
->member_count
!= t2
->member_count
) return FALSE
;
3800 if (t1
->column_count
!= t2
->column_count
) return FALSE
;
3801 if (t1
->row_count
!= t2
->row_count
) return FALSE
;
3803 for (i
= 0; i
< t1
->member_count
; ++i
)
3805 if (strcmp(t1
->members
[i
].name
, t2
->members
[i
].name
)) return FALSE
;
3806 if (t1
->members
[i
].buffer_offset
!= t2
->members
[i
].buffer_offset
) return FALSE
;
3807 if (!d3d10_effect_types_match(t1
->members
[i
].type
, t2
->members
[i
].type
)) return FALSE
;
3813 static HRESULT
d3d10_effect_validate_shared_variable(const struct d3d10_effect
*effect
,
3814 const struct d3d10_effect_variable
*v
)
3816 struct d3d10_effect_variable
*sv
;
3818 switch (v
->type
->basetype
)
3820 case D3D10_SVT_CBUFFER
:
3821 case D3D10_SVT_TBUFFER
:
3822 sv
= d3d10_effect_get_buffer_by_name(effect
->pool
, v
->name
);
3825 sv
= d3d10_effect_get_variable_by_name(effect
->pool
, v
->name
);
3830 WARN("Variable %s wasn't found in the pool.\n", debugstr_a(v
->name
));
3831 return E_INVALIDARG
;
3834 if (!d3d10_effect_types_match(sv
->type
, v
->type
))
3836 WARN("Variable %s type does not match pool type.\n", debugstr_a(v
->name
));
3837 return E_INVALIDARG
;
3843 static HRESULT
parse_fx10_body(struct d3d10_effect
*e
, const char *data
, size_t data_size
)
3849 if (e
->index_offset
>= data_size
)
3851 WARN("Invalid index offset %#x (data size %#Ix).\n", e
->index_offset
, data_size
);
3854 ptr
= data
+ e
->index_offset
;
3856 if (!(e
->local_buffers
= calloc(e
->local_buffer_count
, sizeof(*e
->local_buffers
))))
3858 ERR("Failed to allocate local buffer memory.\n");
3859 return E_OUTOFMEMORY
;
3862 if (!(e
->local_variables
= calloc(e
->local_variable_count
, sizeof(*e
->local_variables
))))
3864 ERR("Failed to allocate local variable memory.\n");
3865 return E_OUTOFMEMORY
;
3868 if (!(e
->anonymous_shaders
= calloc(e
->anonymous_shader_count
, sizeof(*e
->anonymous_shaders
))))
3870 ERR("Failed to allocate anonymous shaders memory\n");
3871 return E_OUTOFMEMORY
;
3874 if (!(e
->shaders
.v
= calloc(e
->shaders
.count
, sizeof(*e
->shaders
.v
))))
3876 ERR("Failed to allocate used shaders memory\n");
3877 return E_OUTOFMEMORY
;
3880 if (!(e
->samplers
.v
= calloc(e
->samplers
.count
, sizeof(*e
->samplers
.v
))))
3882 ERR("Failed to allocate samplers array.\n");
3883 return E_OUTOFMEMORY
;
3886 if (!(e
->blend_states
.v
= calloc(e
->blend_states
.count
, sizeof(*e
->blend_states
.v
))))
3888 ERR("Failed to allocate blend states array.\n");
3889 return E_OUTOFMEMORY
;
3892 if (!(e
->ds_states
.v
= calloc(e
->ds_states
.count
, sizeof(*e
->ds_states
.v
))))
3894 ERR("Failed to allocate depth stencil states array.\n");
3895 return E_OUTOFMEMORY
;
3898 if (!(e
->rs_states
.v
= calloc(e
->rs_states
.count
, sizeof(*e
->rs_states
.v
))))
3900 ERR("Failed to allocate rasterizer states array.\n");
3901 return E_OUTOFMEMORY
;
3904 if (!(e
->techniques
= calloc(e
->technique_count
, sizeof(*e
->techniques
))))
3906 ERR("Failed to allocate techniques memory\n");
3907 return E_OUTOFMEMORY
;
3910 for (i
= 0; i
< e
->local_buffer_count
; ++i
)
3912 struct d3d10_effect_variable
*l
= &e
->local_buffers
[i
];
3913 l
->ID3D10EffectVariable_iface
.lpVtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_constant_buffer_vtbl
;
3915 l
->buffer
= &null_local_buffer
;
3917 if (FAILED(hr
= parse_fx10_buffer(data
, data_size
, &ptr
, TRUE
, l
)))
3921 for (i
= 0; i
< e
->local_variable_count
; ++i
)
3923 struct d3d10_effect_variable
*v
= &e
->local_variables
[i
];
3926 v
->ID3D10EffectVariable_iface
.lpVtbl
= &d3d10_effect_variable_vtbl
;
3927 v
->buffer
= &null_local_buffer
;
3929 if (FAILED(hr
= parse_fx10_object_variable(data
, data_size
, &ptr
, FALSE
, v
)))
3933 for (i
= 0; i
< e
->shared_buffer_count
; ++i
)
3935 struct d3d10_effect_variable b
= {{ 0 }};
3939 if (FAILED(hr
= parse_fx10_buffer(data
, data_size
, &ptr
, FALSE
, &b
)))
3941 d3d10_effect_variable_destroy(&b
);
3945 hr
= d3d10_effect_validate_shared_variable(e
, &b
);
3946 d3d10_effect_variable_destroy(&b
);
3947 if (FAILED(hr
)) return hr
;
3950 for (i
= 0; i
< e
->shared_object_count
; ++i
)
3952 struct d3d10_effect_variable o
= {{ 0 }};
3956 if (FAILED(hr
= parse_fx10_object_variable(data
, data_size
, &ptr
, TRUE
, &o
)))
3958 d3d10_effect_variable_destroy(&o
);
3962 hr
= d3d10_effect_validate_shared_variable(e
, &o
);
3963 d3d10_effect_variable_destroy(&o
);
3964 if (FAILED(hr
)) return hr
;
3967 for (i
= 0; i
< e
->technique_count
; ++i
)
3969 struct d3d10_effect_technique
*t
= &e
->techniques
[i
];
3971 t
->ID3D10EffectTechnique_iface
.lpVtbl
= &d3d10_effect_technique_vtbl
;
3974 if (FAILED(hr
= parse_fx10_technique(data
, data_size
, &ptr
, t
)))
3981 static HRESULT
parse_fx10(struct d3d10_effect
*e
, const char *data
, size_t data_size
)
3983 const char *ptr
= data
;
3986 if (!require_space(0, 19, sizeof(uint32_t), data_size
))
3988 WARN("Invalid data size %#Ix.\n", data_size
);
3989 return E_INVALIDARG
;
3992 /* Compiled target version (e.g. fx_4_0=0xfeff1001, fx_4_1=0xfeff1011). */
3993 e
->version
= read_u32(&ptr
);
3994 TRACE("Target: %#x.\n", e
->version
);
3996 e
->local_buffer_count
= read_u32(&ptr
);
3997 TRACE("Local buffer count: %u.\n", e
->local_buffer_count
);
3999 e
->variable_count
= read_u32(&ptr
);
4000 TRACE("Variable count: %u.\n", e
->variable_count
);
4002 e
->local_variable_count
= read_u32(&ptr
);
4003 TRACE("Object count: %u.\n", e
->local_variable_count
);
4005 e
->shared_buffer_count
= read_u32(&ptr
);
4006 TRACE("Pool buffer count: %u.\n", e
->shared_buffer_count
);
4008 unused
= read_u32(&ptr
);
4009 TRACE("Pool variable count: %u.\n", unused
);
4011 e
->shared_object_count
= read_u32(&ptr
);
4012 TRACE("Pool objects count: %u.\n", e
->shared_object_count
);
4014 e
->technique_count
= read_u32(&ptr
);
4015 TRACE("Technique count: %u.\n", e
->technique_count
);
4017 e
->index_offset
= read_u32(&ptr
);
4018 TRACE("Index offset: %#x.\n", e
->index_offset
);
4020 unused
= read_u32(&ptr
);
4021 TRACE("String count: %u.\n", unused
);
4023 e
->texture_count
= read_u32(&ptr
);
4024 TRACE("Texture count: %u.\n", e
->texture_count
);
4026 e
->ds_states
.count
= read_u32(&ptr
);
4027 TRACE("Depthstencilstate count: %u.\n", e
->ds_states
.count
);
4029 e
->blend_states
.count
= read_u32(&ptr
);
4030 TRACE("Blendstate count: %u.\n", e
->blend_states
.count
);
4032 e
->rs_states
.count
= read_u32(&ptr
);
4033 TRACE("Rasterizerstate count: %u.\n", e
->rs_states
.count
);
4035 e
->samplers
.count
= read_u32(&ptr
);
4036 TRACE("Samplerstate count: %u.\n", e
->samplers
.count
);
4038 e
->rtvs
.count
= read_u32(&ptr
);
4039 TRACE("Rendertargetview count: %u.\n", e
->rtvs
.count
);
4041 e
->dsvs
.count
= read_u32(&ptr
);
4042 TRACE("Depthstencilview count: %u.\n", e
->dsvs
.count
);
4044 e
->shaders
.count
= read_u32(&ptr
);
4045 TRACE("Used shader count: %u.\n", e
->shaders
.count
);
4047 e
->anonymous_shader_count
= read_u32(&ptr
);
4048 TRACE("Anonymous shader count: %u.\n", e
->anonymous_shader_count
);
4050 if (!e
->pool
&& (e
->shared_object_count
|| e
->shared_buffer_count
))
4052 WARN("Effect requires a pool to load.\n");
4056 return parse_fx10_body(e
, ptr
, data_size
- (ptr
- data
));
4059 static HRESULT
fx10_chunk_handler(const char *data
, size_t data_size
, uint32_t tag
, void *ctx
)
4061 struct d3d10_effect
*e
= ctx
;
4063 TRACE("tag: %s.\n", debugstr_an((const char *)&tag
, 4));
4065 TRACE("Chunk size: %#Ix.\n", data_size
);
4070 return parse_fx10(e
, data
, data_size
);
4073 FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag
, 4));
4078 HRESULT
d3d10_effect_parse(struct d3d10_effect
*effect
, const void *data
, SIZE_T data_size
)
4080 return parse_dxbc(data
, data_size
, fx10_chunk_handler
, effect
);
4083 static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_variable
*s
,
4084 D3D10_SHADER_VARIABLE_TYPE type
)
4087 s
->reflection
->lpVtbl
->Release(s
->reflection
);
4088 if (s
->input_signature
)
4089 ID3D10Blob_Release(s
->input_signature
);
4091 ID3D10Blob_Release(s
->bytecode
);
4095 case D3D10_SVT_VERTEXSHADER
:
4096 case D3D10_SVT_PIXELSHADER
:
4097 case D3D10_SVT_GEOMETRYSHADER
:
4098 if (s
->shader
.object
)
4099 IUnknown_Release(s
->shader
.object
);
4103 FIXME("Unhandled shader type %s.\n", debug_d3d10_shader_variable_type(type
));
4107 if (s
->resource_count
)
4111 static void d3d10_effect_annotations_destroy(struct d3d10_effect_annotations
*a
)
4115 if (!a
->elements
) return;
4117 for (i
= 0; i
< a
->count
; ++i
)
4118 d3d10_effect_variable_destroy(&a
->elements
[i
]);
4124 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable
*v
)
4126 unsigned int i
, elem_count
;
4128 TRACE("variable %p.\n", v
);
4132 d3d10_effect_annotations_destroy(&v
->annotations
);
4136 for (i
= 0; i
< v
->type
->member_count
; ++i
)
4138 d3d10_effect_variable_destroy(&v
->members
[i
]);
4145 for (i
= 0; i
< v
->type
->element_count
; ++i
)
4147 d3d10_effect_variable_destroy(&v
->elements
[i
]);
4154 switch (v
->type
->basetype
)
4156 case D3D10_SVT_VERTEXSHADER
:
4157 case D3D10_SVT_PIXELSHADER
:
4158 case D3D10_SVT_GEOMETRYSHADER
:
4159 d3d10_effect_shader_variable_destroy(&v
->u
.shader
, v
->type
->basetype
);
4162 case D3D10_SVT_DEPTHSTENCIL
:
4163 case D3D10_SVT_BLEND
:
4164 case D3D10_SVT_RASTERIZER
:
4165 case D3D10_SVT_SAMPLER
:
4166 if (v
->u
.state
.object
.object
)
4167 IUnknown_Release(v
->u
.state
.object
.object
);
4168 d3d10_effect_clear_prop_dependencies(&v
->u
.state
.dependencies
);
4171 case D3D10_SVT_TEXTURE1D
:
4172 case D3D10_SVT_TEXTURE1DARRAY
:
4173 case D3D10_SVT_TEXTURE2D
:
4174 case D3D10_SVT_TEXTURE2DARRAY
:
4175 case D3D10_SVT_TEXTURE2DMS
:
4176 case D3D10_SVT_TEXTURE2DMSARRAY
:
4177 case D3D10_SVT_TEXTURE3D
:
4178 case D3D10_SVT_TEXTURECUBE
:
4179 if (!v
->u
.resource
.parent
)
4182 if (!v
->type
->element_count
)
4185 elem_count
= v
->type
->element_count
;
4187 for (i
= 0; i
< elem_count
; ++i
)
4189 if (v
->u
.resource
.srv
[i
])
4190 ID3D10ShaderResourceView_Release(v
->u
.resource
.srv
[i
]);
4193 free(v
->u
.resource
.srv
);
4196 case D3D10_SVT_STRING
:
4197 free(v
->u
.buffer
.local_buffer
);
4206 static void d3d10_effect_pass_destroy(struct d3d10_effect_pass
*p
)
4208 TRACE("pass %p\n", p
);
4211 d3d10_effect_annotations_destroy(&p
->annotations
);
4212 d3d10_effect_clear_prop_dependencies(&p
->dependencies
);
4215 static void d3d10_effect_technique_destroy(struct d3d10_effect_technique
*t
)
4219 TRACE("technique %p\n", t
);
4224 for (i
= 0; i
< t
->pass_count
; ++i
)
4226 d3d10_effect_pass_destroy(&t
->passes
[i
]);
4231 d3d10_effect_annotations_destroy(&t
->annotations
);
4234 static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable
*l
)
4238 TRACE("local buffer %p.\n", l
);
4243 for (i
= 0; i
< l
->type
->member_count
; ++i
)
4245 d3d10_effect_variable_destroy(&l
->members
[i
]);
4251 d3d10_effect_type_destroy(&l
->type
->entry
, NULL
);
4253 d3d10_effect_annotations_destroy(&l
->annotations
);
4254 free(l
->u
.buffer
.local_buffer
);
4256 if (l
->u
.buffer
.buffer
)
4257 ID3D10Buffer_Release(l
->u
.buffer
.buffer
);
4258 if (l
->u
.buffer
.resource_view
)
4259 ID3D10ShaderResourceView_Release(l
->u
.buffer
.resource_view
);
4262 /* IUnknown methods */
4264 static inline struct d3d10_effect
*impl_from_ID3D10Effect(ID3D10Effect
*iface
)
4266 return CONTAINING_RECORD(iface
, struct d3d10_effect
, ID3D10Effect_iface
);
4269 static HRESULT STDMETHODCALLTYPE
d3d10_effect_QueryInterface(ID3D10Effect
*iface
, REFIID riid
, void **object
)
4271 TRACE("iface %p, riid %s, object %p\n", iface
, debugstr_guid(riid
), object
);
4273 if (IsEqualGUID(riid
, &IID_ID3D10Effect
)
4274 || IsEqualGUID(riid
, &IID_IUnknown
))
4276 IUnknown_AddRef(iface
);
4281 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
4284 return E_NOINTERFACE
;
4287 static ULONG STDMETHODCALLTYPE
d3d10_effect_AddRef(ID3D10Effect
*iface
)
4289 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4290 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
4292 TRACE("%p increasing refcount to %lu.\n", This
, refcount
);
4297 static ULONG STDMETHODCALLTYPE
d3d10_effect_Release(ID3D10Effect
*iface
)
4299 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4300 ULONG refcount
= InterlockedDecrement(&effect
->refcount
);
4302 TRACE("%p decreasing refcount to %lu.\n", iface
, refcount
);
4308 if (effect
->techniques
)
4310 for (i
= 0; i
< effect
->technique_count
; ++i
)
4312 d3d10_effect_technique_destroy(&effect
->techniques
[i
]);
4314 free(effect
->techniques
);
4317 if (effect
->local_variables
)
4319 for (i
= 0; i
< effect
->local_variable_count
; ++i
)
4321 d3d10_effect_variable_destroy(&effect
->local_variables
[i
]);
4323 free(effect
->local_variables
);
4326 if (effect
->local_buffers
)
4328 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4330 d3d10_effect_local_buffer_destroy(&effect
->local_buffers
[i
]);
4332 free(effect
->local_buffers
);
4335 if (effect
->anonymous_shaders
)
4337 for (i
= 0; i
< effect
->anonymous_shader_count
; ++i
)
4339 d3d10_effect_variable_destroy(&effect
->anonymous_shaders
[i
].shader
);
4340 free(effect
->anonymous_shaders
[i
].type
.name
);
4342 free(effect
->anonymous_shaders
);
4345 free(effect
->shaders
.v
);
4346 free(effect
->samplers
.v
);
4347 free(effect
->rtvs
.v
);
4348 free(effect
->dsvs
.v
);
4349 free(effect
->blend_states
.v
);
4350 free(effect
->ds_states
.v
);
4351 free(effect
->rs_states
.v
);
4353 wine_rb_destroy(&effect
->types
, d3d10_effect_type_destroy
, NULL
);
4356 IUnknown_Release(&effect
->pool
->ID3D10Effect_iface
);
4357 ID3D10Device_Release(effect
->device
);
4364 /* ID3D10Effect methods */
4366 static BOOL STDMETHODCALLTYPE
d3d10_effect_IsValid(ID3D10Effect
*iface
)
4368 FIXME("iface %p stub!\n", iface
);
4373 static BOOL STDMETHODCALLTYPE
d3d10_effect_IsPool(ID3D10Effect
*iface
)
4375 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4377 TRACE("iface %p.\n", iface
);
4379 return effect
->ID3D10Effect_iface
.lpVtbl
== &d3d10_effect_pool_effect_vtbl
;
4382 static HRESULT STDMETHODCALLTYPE
d3d10_effect_GetDevice(ID3D10Effect
*iface
, ID3D10Device
**device
)
4384 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4386 TRACE("iface %p, device %p\n", iface
, device
);
4388 ID3D10Device_AddRef(This
->device
);
4389 *device
= This
->device
;
4394 static void d3d10_effect_get_desc(const struct d3d10_effect
*effect
, D3D10_EFFECT_DESC
*desc
)
4398 desc
->IsChildEffect
= !!effect
->pool
;
4399 desc
->ConstantBuffers
= effect
->local_buffer_count
;
4400 desc
->SharedConstantBuffers
= 0;
4401 desc
->GlobalVariables
= effect
->local_variable_count
;
4402 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4404 desc
->GlobalVariables
+= effect
->local_buffers
[i
].type
->member_count
;
4406 desc
->SharedGlobalVariables
= 0;
4407 desc
->Techniques
= effect
->technique_count
;
4410 static HRESULT STDMETHODCALLTYPE
d3d10_effect_GetDesc(ID3D10Effect
*iface
, D3D10_EFFECT_DESC
*desc
)
4412 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4413 D3D10_EFFECT_DESC pool_desc
= { 0 };
4415 TRACE("iface %p, desc %p.\n", iface
, desc
);
4418 return E_INVALIDARG
;
4421 d3d10_effect_get_desc(effect
->pool
, &pool_desc
);
4423 d3d10_effect_get_desc(effect
, desc
);
4425 desc
->SharedConstantBuffers
= pool_desc
.ConstantBuffers
;
4426 desc
->SharedGlobalVariables
= pool_desc
.GlobalVariables
;
4431 static struct d3d10_effect_variable
* d3d10_effect_get_buffer_by_index(struct d3d10_effect
*effect
,
4434 if (index
< effect
->local_buffer_count
)
4435 return &effect
->local_buffers
[index
];
4436 index
-= effect
->local_buffer_count
;
4438 return effect
->pool
? d3d10_effect_get_buffer_by_index(effect
->pool
, index
) : NULL
;
4441 static BOOL
is_var_shared(const struct d3d10_effect_variable
*v
)
4443 return !!(v
->flag
& D3D10_EFFECT_VARIABLE_POOLED
);
4446 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_GetConstantBufferByIndex(ID3D10Effect
*iface
,
4449 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4450 struct d3d10_effect_variable
*v
;
4452 TRACE("iface %p, index %u\n", iface
, index
);
4454 if ((v
= d3d10_effect_get_buffer_by_index(effect
, index
)))
4456 TRACE("Returning %sbuffer %p, name %s.\n", is_var_shared(v
) ? "shared " : "", v
,
4457 debugstr_a(v
->name
));
4458 return (ID3D10EffectConstantBuffer
*)&v
->ID3D10EffectVariable_iface
;
4461 WARN("Invalid index specified\n");
4463 return (ID3D10EffectConstantBuffer
*)&null_local_buffer
.ID3D10EffectVariable_iface
;
4466 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_GetConstantBufferByName(ID3D10Effect
*iface
,
4469 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4470 struct d3d10_effect_variable
*v
;
4472 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4474 if ((v
= d3d10_effect_get_buffer_by_name(effect
, name
)))
4476 TRACE("Returning %sbuffer %p.\n", is_var_shared(v
) ? "shared " : "", v
);
4477 return (ID3D10EffectConstantBuffer
*)&v
->ID3D10EffectVariable_iface
;
4480 WARN("Invalid name specified\n");
4482 return (ID3D10EffectConstantBuffer
*)&null_local_buffer
.ID3D10EffectVariable_iface
;
4485 static struct d3d10_effect_variable
* d3d10_effect_get_variable_by_index(
4486 const struct d3d10_effect
*effect
, unsigned int index
)
4490 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4492 struct d3d10_effect_variable
*v
= &effect
->local_buffers
[i
];
4493 if (index
< v
->type
->member_count
)
4494 return &v
->members
[index
];
4495 index
-= v
->type
->member_count
;
4498 if (index
< effect
->local_variable_count
)
4499 return &effect
->local_variables
[index
];
4500 index
-= effect
->local_variable_count
;
4502 return effect
->pool
? d3d10_effect_get_variable_by_index(effect
->pool
, index
) : NULL
;
4505 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_GetVariableByIndex(ID3D10Effect
*iface
, UINT index
)
4507 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4508 struct d3d10_effect_variable
*v
;
4510 TRACE("iface %p, index %u\n", iface
, index
);
4512 if ((v
= d3d10_effect_get_variable_by_index(effect
, index
)))
4514 TRACE("Returning %svariable %s.\n", is_var_shared(v
) ? "shared " : "", debugstr_a(v
->name
));
4515 return &v
->ID3D10EffectVariable_iface
;
4518 WARN("Invalid index specified\n");
4520 return &null_variable
.ID3D10EffectVariable_iface
;
4523 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_GetVariableByName(ID3D10Effect
*iface
,
4526 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4527 struct d3d10_effect_variable
*v
;
4529 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4533 WARN("Invalid name specified\n");
4534 return &null_variable
.ID3D10EffectVariable_iface
;
4537 if ((v
= d3d10_effect_get_variable_by_name(effect
, name
)))
4539 TRACE("Returning %svariable %p.\n", is_var_shared(v
) ? "shared " : "", v
);
4540 return &v
->ID3D10EffectVariable_iface
;
4543 WARN("Invalid name specified\n");
4545 return &null_variable
.ID3D10EffectVariable_iface
;
4548 static struct d3d10_effect_variable
* d3d10_effect_get_variable_by_semantic(
4549 const struct d3d10_effect
*effect
, const char *semantic
)
4553 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4555 struct d3d10_effect_variable
*l
= &effect
->local_buffers
[i
];
4558 for (j
= 0; j
< l
->type
->member_count
; ++j
)
4560 struct d3d10_effect_variable
*v
= &l
->members
[j
];
4562 if (v
->semantic
&& !stricmp(v
->semantic
, semantic
))
4567 for (i
= 0; i
< effect
->local_variable_count
; ++i
)
4569 struct d3d10_effect_variable
*v
= &effect
->local_variables
[i
];
4571 if (v
->semantic
&& !stricmp(v
->semantic
, semantic
))
4575 return effect
->pool
? d3d10_effect_get_variable_by_semantic(effect
->pool
, semantic
) : NULL
;
4578 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_GetVariableBySemantic(ID3D10Effect
*iface
,
4579 const char *semantic
)
4581 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4582 struct d3d10_effect_variable
*v
;
4584 TRACE("iface %p, semantic %s\n", iface
, debugstr_a(semantic
));
4588 WARN("Invalid semantic specified\n");
4589 return &null_variable
.ID3D10EffectVariable_iface
;
4592 if ((v
= d3d10_effect_get_variable_by_semantic(effect
, semantic
)))
4594 TRACE("Returning %svariable %s.\n", is_var_shared(v
) ? "shared " : "", debugstr_a(v
->name
));
4595 return &v
->ID3D10EffectVariable_iface
;
4598 WARN("Invalid semantic specified\n");
4600 return &null_variable
.ID3D10EffectVariable_iface
;
4603 static struct ID3D10EffectTechnique
* STDMETHODCALLTYPE
d3d10_effect_GetTechniqueByIndex(ID3D10Effect
*iface
,
4606 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4607 struct d3d10_effect_technique
*t
;
4609 TRACE("iface %p, index %u\n", iface
, index
);
4611 if (index
>= This
->technique_count
)
4613 WARN("Invalid index specified\n");
4614 return &null_technique
.ID3D10EffectTechnique_iface
;
4617 t
= &This
->techniques
[index
];
4619 TRACE("Returning technique %p, %s.\n", t
, debugstr_a(t
->name
));
4621 return &t
->ID3D10EffectTechnique_iface
;
4624 static struct ID3D10EffectTechnique
* STDMETHODCALLTYPE
d3d10_effect_GetTechniqueByName(ID3D10Effect
*iface
,
4627 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4630 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4634 WARN("Invalid name specified\n");
4635 return &null_technique
.ID3D10EffectTechnique_iface
;
4638 for (i
= 0; i
< This
->technique_count
; ++i
)
4640 struct d3d10_effect_technique
*t
= &This
->techniques
[i
];
4641 if (t
->name
&& !strcmp(t
->name
, name
))
4643 TRACE("Returning technique %p\n", t
);
4644 return &t
->ID3D10EffectTechnique_iface
;
4648 WARN("Invalid name specified\n");
4650 return &null_technique
.ID3D10EffectTechnique_iface
;
4653 static HRESULT STDMETHODCALLTYPE
d3d10_effect_Optimize(ID3D10Effect
*iface
)
4655 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4656 struct d3d10_effect_variable
*v
;
4659 FIXME("iface %p semi-stub!\n", iface
);
4661 if (effect
->flags
& D3D10_EFFECT_OPTIMIZED
)
4664 for (i
= 0; i
< effect
->shaders
.count
; ++i
)
4666 v
= effect
->shaders
.v
[i
];
4668 if (v
->u
.shader
.reflection
)
4670 v
->u
.shader
.reflection
->lpVtbl
->Release(v
->u
.shader
.reflection
);
4671 v
->u
.shader
.reflection
= NULL
;
4673 if (v
->u
.shader
.bytecode
)
4675 ID3D10Blob_Release(v
->u
.shader
.bytecode
);
4676 v
->u
.shader
.bytecode
= NULL
;
4678 free(v
->u
.shader
.stream_output_declaration
);
4679 v
->u
.shader
.stream_output_declaration
= NULL
;
4682 for (i
= 0; i
< effect
->technique_count
; ++i
)
4684 for (j
= 0; j
< effect
->techniques
[i
].pass_count
; ++j
)
4686 free(effect
->techniques
[i
].passes
[j
].name
);
4687 effect
->techniques
[i
].passes
[j
].name
= NULL
;
4690 free(effect
->techniques
[i
].name
);
4691 effect
->techniques
[i
].name
= NULL
;
4694 effect
->flags
|= D3D10_EFFECT_OPTIMIZED
;
4699 static BOOL STDMETHODCALLTYPE
d3d10_effect_IsOptimized(ID3D10Effect
*iface
)
4701 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4703 TRACE("iface %p.\n", iface
);
4705 return !!(effect
->flags
& D3D10_EFFECT_OPTIMIZED
);
4708 static const struct ID3D10EffectVtbl d3d10_effect_vtbl
=
4710 /* IUnknown methods */
4711 d3d10_effect_QueryInterface
,
4712 d3d10_effect_AddRef
,
4713 d3d10_effect_Release
,
4714 /* ID3D10Effect methods */
4715 d3d10_effect_IsValid
,
4716 d3d10_effect_IsPool
,
4717 d3d10_effect_GetDevice
,
4718 d3d10_effect_GetDesc
,
4719 d3d10_effect_GetConstantBufferByIndex
,
4720 d3d10_effect_GetConstantBufferByName
,
4721 d3d10_effect_GetVariableByIndex
,
4722 d3d10_effect_GetVariableByName
,
4723 d3d10_effect_GetVariableBySemantic
,
4724 d3d10_effect_GetTechniqueByIndex
,
4725 d3d10_effect_GetTechniqueByName
,
4726 d3d10_effect_Optimize
,
4727 d3d10_effect_IsOptimized
,
4730 /* ID3D10EffectTechnique methods */
4732 static inline struct d3d10_effect_technique
*impl_from_ID3D10EffectTechnique(ID3D10EffectTechnique
*iface
)
4734 return CONTAINING_RECORD(iface
, struct d3d10_effect_technique
, ID3D10EffectTechnique_iface
);
4737 static BOOL STDMETHODCALLTYPE
d3d10_effect_technique_IsValid(ID3D10EffectTechnique
*iface
)
4739 struct d3d10_effect_technique
*This
= impl_from_ID3D10EffectTechnique(iface
);
4741 TRACE("iface %p\n", iface
);
4743 return This
!= &null_technique
;
4746 static HRESULT STDMETHODCALLTYPE
d3d10_effect_technique_GetDesc(ID3D10EffectTechnique
*iface
,
4747 D3D10_TECHNIQUE_DESC
*desc
)
4749 struct d3d10_effect_technique
*tech
= impl_from_ID3D10EffectTechnique(iface
);
4751 TRACE("iface %p, desc %p\n", iface
, desc
);
4753 if (tech
== &null_technique
)
4755 WARN("Null technique specified\n");
4761 WARN("Invalid argument specified\n");
4762 return E_INVALIDARG
;
4765 desc
->Name
= tech
->name
;
4766 desc
->Passes
= tech
->pass_count
;
4767 desc
->Annotations
= tech
->annotations
.count
;
4772 static ID3D10EffectVariable
* d3d10_annotation_get_by_index(const struct d3d10_effect_annotations
*annotations
,
4775 struct d3d10_effect_variable
*a
;
4777 if (index
>= annotations
->count
)
4779 WARN("Invalid index specified\n");
4780 return &null_variable
.ID3D10EffectVariable_iface
;
4783 a
= &annotations
->elements
[index
];
4785 TRACE("Returning annotation %p, name %s.\n", a
, debugstr_a(a
->name
));
4787 return &a
->ID3D10EffectVariable_iface
;
4790 static ID3D10EffectVariable
* d3d10_annotation_get_by_name(const struct d3d10_effect_annotations
*annotations
,
4795 for (i
= 0; i
< annotations
->count
; ++i
)
4797 struct d3d10_effect_variable
*a
= &annotations
->elements
[i
];
4798 if (a
->name
&& !strcmp(a
->name
, name
))
4800 TRACE("Returning annotation %p.\n", a
);
4801 return &a
->ID3D10EffectVariable_iface
;
4805 WARN("Invalid name specified.\n");
4807 return &null_variable
.ID3D10EffectVariable_iface
;
4810 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_technique_GetAnnotationByIndex(
4811 ID3D10EffectTechnique
*iface
, UINT index
)
4813 struct d3d10_effect_technique
*tech
= impl_from_ID3D10EffectTechnique(iface
);
4815 TRACE("iface %p, index %u\n", iface
, index
);
4817 return d3d10_annotation_get_by_index(&tech
->annotations
, index
);
4820 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_technique_GetAnnotationByName(
4821 ID3D10EffectTechnique
*iface
, const char *name
)
4823 struct d3d10_effect_technique
*tech
= impl_from_ID3D10EffectTechnique(iface
);
4825 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4827 return d3d10_annotation_get_by_name(&tech
->annotations
, name
);
4830 static struct ID3D10EffectPass
* STDMETHODCALLTYPE
d3d10_effect_technique_GetPassByIndex(ID3D10EffectTechnique
*iface
,
4833 struct d3d10_effect_technique
*This
= impl_from_ID3D10EffectTechnique(iface
);
4834 struct d3d10_effect_pass
*p
;
4836 TRACE("iface %p, index %u\n", iface
, index
);
4838 if (index
>= This
->pass_count
)
4840 WARN("Invalid index specified\n");
4841 return &null_pass
.ID3D10EffectPass_iface
;
4844 p
= &This
->passes
[index
];
4846 TRACE("Returning pass %p, %s.\n", p
, debugstr_a(p
->name
));
4848 return &p
->ID3D10EffectPass_iface
;
4851 static struct ID3D10EffectPass
* STDMETHODCALLTYPE
d3d10_effect_technique_GetPassByName(ID3D10EffectTechnique
*iface
,
4854 struct d3d10_effect_technique
*This
= impl_from_ID3D10EffectTechnique(iface
);
4857 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4859 /* Do not check for name==NULL, W7/DX10 crashes in that case. */
4861 for (i
= 0; i
< This
->pass_count
; ++i
)
4863 struct d3d10_effect_pass
*p
= &This
->passes
[i
];
4864 if (p
->name
&& !strcmp(p
->name
, name
))
4866 TRACE("Returning pass %p\n", p
);
4867 return &p
->ID3D10EffectPass_iface
;
4871 WARN("Invalid name specified\n");
4873 return &null_pass
.ID3D10EffectPass_iface
;
4876 static HRESULT STDMETHODCALLTYPE
d3d10_effect_technique_ComputeStateBlockMask(ID3D10EffectTechnique
*iface
,
4877 D3D10_STATE_BLOCK_MASK
*mask
)
4879 FIXME("iface %p,mask %p stub!\n", iface
, mask
);
4884 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl
=
4886 /* ID3D10EffectTechnique methods */
4887 d3d10_effect_technique_IsValid
,
4888 d3d10_effect_technique_GetDesc
,
4889 d3d10_effect_technique_GetAnnotationByIndex
,
4890 d3d10_effect_technique_GetAnnotationByName
,
4891 d3d10_effect_technique_GetPassByIndex
,
4892 d3d10_effect_technique_GetPassByName
,
4893 d3d10_effect_technique_ComputeStateBlockMask
,
4896 /* ID3D10EffectPass methods */
4898 static inline struct d3d10_effect_pass
*impl_from_ID3D10EffectPass(ID3D10EffectPass
*iface
)
4900 return CONTAINING_RECORD(iface
, struct d3d10_effect_pass
, ID3D10EffectPass_iface
);
4903 static BOOL STDMETHODCALLTYPE
d3d10_effect_pass_IsValid(ID3D10EffectPass
*iface
)
4905 struct d3d10_effect_pass
*This
= impl_from_ID3D10EffectPass(iface
);
4907 TRACE("iface %p\n", iface
);
4909 return This
!= &null_pass
;
4912 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetDesc(ID3D10EffectPass
*iface
,
4913 D3D10_PASS_DESC
*desc
)
4915 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
4916 struct d3d10_effect_variable
*vs
;
4917 ID3D10Blob
*input_signature
;
4919 TRACE("iface %p, desc %p.\n", iface
, desc
);
4921 if (pass
== &null_pass
)
4923 WARN("Null pass specified\n");
4929 WARN("Invalid argument specified\n");
4930 return E_INVALIDARG
;
4933 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
4935 vs
= d3d10_array_get_element(pass
->vs
.shader
, pass
->vs
.index
);
4936 input_signature
= vs
->u
.shader
.input_signature
;
4938 desc
->Name
= pass
->name
;
4939 desc
->Annotations
= pass
->annotations
.count
;
4940 if (input_signature
)
4942 desc
->pIAInputSignature
= ID3D10Blob_GetBufferPointer(input_signature
);
4943 desc
->IAInputSignatureSize
= ID3D10Blob_GetBufferSize(input_signature
);
4947 desc
->pIAInputSignature
= NULL
;
4948 desc
->IAInputSignatureSize
= 0;
4950 desc
->StencilRef
= pass
->stencil_ref
;
4951 desc
->SampleMask
= pass
->sample_mask
;
4952 memcpy(desc
->BlendFactor
, pass
->blend_factor
, 4 * sizeof(float));
4957 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetVertexShaderDesc(ID3D10EffectPass
*iface
,
4958 D3D10_PASS_SHADER_DESC
*desc
)
4960 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
4962 TRACE("iface %p, desc %p.\n", iface
, desc
);
4964 if (pass
== &null_pass
)
4966 WARN("Null pass specified.\n");
4972 WARN("Invalid argument specified.\n");
4973 return E_INVALIDARG
;
4976 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
4978 desc
->pShaderVariable
= (ID3D10EffectShaderVariable
*)&pass
->vs
.shader
->ID3D10EffectVariable_iface
;
4979 desc
->ShaderIndex
= pass
->vs
.index
;
4984 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetGeometryShaderDesc(ID3D10EffectPass
*iface
,
4985 D3D10_PASS_SHADER_DESC
*desc
)
4987 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
4989 TRACE("iface %p, desc %p.\n", iface
, desc
);
4991 if (pass
== &null_pass
)
4993 WARN("Null pass specified.\n");
4999 WARN("Invalid argument specified.\n");
5000 return E_INVALIDARG
;
5003 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
5005 desc
->pShaderVariable
= (ID3D10EffectShaderVariable
*)&pass
->gs
.shader
->ID3D10EffectVariable_iface
;
5006 desc
->ShaderIndex
= pass
->gs
.index
;
5011 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetPixelShaderDesc(ID3D10EffectPass
*iface
,
5012 D3D10_PASS_SHADER_DESC
*desc
)
5014 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5016 TRACE("iface %p, desc %p.\n", iface
, desc
);
5018 if (pass
== &null_pass
)
5020 WARN("Null pass specified.\n");
5026 WARN("Invalid argument specified.\n");
5027 return E_INVALIDARG
;
5030 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
5032 desc
->pShaderVariable
= (ID3D10EffectShaderVariable
*)&pass
->ps
.shader
->ID3D10EffectVariable_iface
;
5033 desc
->ShaderIndex
= pass
->ps
.index
;
5038 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_pass_GetAnnotationByIndex(ID3D10EffectPass
*iface
,
5041 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5043 TRACE("iface %p, index %u\n", iface
, index
);
5045 return d3d10_annotation_get_by_index(&pass
->annotations
, index
);
5048 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_pass_GetAnnotationByName(ID3D10EffectPass
*iface
,
5051 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5053 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5055 return d3d10_annotation_get_by_name(&pass
->annotations
, name
);
5058 static void update_buffer(ID3D10Device
*device
, struct d3d10_effect_variable
*v
)
5060 struct d3d10_effect_buffer_variable
*b
= &v
->u
.buffer
;
5065 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)b
->buffer
, 0, NULL
,
5066 b
->local_buffer
, v
->data_size
, 0);
5071 static void set_sampler(ID3D10Device
*device
, D3D10_SHADER_VARIABLE_TYPE shader_type
,
5072 struct d3d10_effect_variable
*v
, unsigned int bind_point
)
5074 switch (shader_type
)
5076 case D3D10_SVT_VERTEXSHADER
:
5077 ID3D10Device_VSSetSamplers(device
, bind_point
, 1, &v
->u
.state
.object
.sampler
);
5080 case D3D10_SVT_PIXELSHADER
:
5081 ID3D10Device_PSSetSamplers(device
, bind_point
, 1, &v
->u
.state
.object
.sampler
);
5084 case D3D10_SVT_GEOMETRYSHADER
:
5085 ID3D10Device_GSSetSamplers(device
, bind_point
, 1, &v
->u
.state
.object
.sampler
);
5089 WARN("Incorrect shader type to bind sampler.\n");
5094 static void apply_shader_resources(ID3D10Device
*device
, struct d3d10_effect_variable
*v
)
5096 struct d3d10_effect_shader_variable
*sv
= &v
->u
.shader
;
5097 struct d3d10_effect_shader_resource
*sr
;
5098 struct d3d10_effect_variable
*rsrc_v
;
5099 ID3D10ShaderResourceView
**srv
;
5102 for (i
= 0; i
< sv
->resource_count
; ++i
)
5104 sr
= &sv
->resources
[i
];
5105 rsrc_v
= sr
->variable
;
5107 switch (sr
->in_type
)
5109 case D3D10_SIT_CBUFFER
:
5110 update_buffer(device
, rsrc_v
);
5111 switch (v
->type
->basetype
)
5113 case D3D10_SVT_VERTEXSHADER
:
5114 ID3D10Device_VSSetConstantBuffers(device
, sr
->bind_point
, 1,
5115 &rsrc_v
->u
.buffer
.buffer
);
5118 case D3D10_SVT_PIXELSHADER
:
5119 ID3D10Device_PSSetConstantBuffers(device
, sr
->bind_point
, 1,
5120 &rsrc_v
->u
.buffer
.buffer
);
5123 case D3D10_SVT_GEOMETRYSHADER
:
5124 ID3D10Device_GSSetConstantBuffers(device
, sr
->bind_point
, 1,
5125 &rsrc_v
->u
.buffer
.buffer
);
5129 WARN("Incorrect shader type to bind constant buffer.\n");
5134 case D3D10_SIT_TEXTURE
:
5136 if (rsrc_v
->type
->basetype
== D3D10_SVT_SAMPLER
)
5138 TRACE("Using texture associated with sampler %s.\n", debugstr_a(rsrc_v
->name
));
5139 rsrc_v
= rsrc_v
->u
.state
.desc
.sampler
.texture
;
5143 case D3D10_SIT_TBUFFER
:
5145 if (sr
->in_type
== D3D10_SIT_TBUFFER
)
5147 update_buffer(device
, rsrc_v
);
5148 srv
= &rsrc_v
->u
.buffer
.resource_view
;
5151 srv
= rsrc_v
->u
.resource
.srv
;
5153 switch (v
->type
->basetype
)
5155 case D3D10_SVT_VERTEXSHADER
:
5156 ID3D10Device_VSSetShaderResources(device
, sr
->bind_point
, sr
->bind_count
, srv
);
5159 case D3D10_SVT_PIXELSHADER
:
5160 ID3D10Device_PSSetShaderResources(device
, sr
->bind_point
, sr
->bind_count
, srv
);
5163 case D3D10_SVT_GEOMETRYSHADER
:
5164 ID3D10Device_GSSetShaderResources(device
, sr
->bind_point
, sr
->bind_count
, srv
);
5168 WARN("Incorrect shader type to bind shader resource view.\n");
5173 case D3D10_SIT_SAMPLER
:
5174 if (!rsrc_v
->type
->element_count
)
5176 set_sampler(device
, v
->type
->basetype
, rsrc_v
, sr
->bind_point
);
5180 for (j
= 0; j
< sr
->bind_count
; ++j
)
5181 set_sampler(device
, v
->type
->basetype
, &rsrc_v
->elements
[j
], sr
->bind_point
+ j
);
5185 WARN("Unhandled shader resource %#x.\n", sr
->in_type
);
5191 static void d3d10_effect_pass_set_shader(struct d3d10_effect_pass
*pass
,
5192 const struct d3d10_effect_pass_shader_desc
*shader_desc
)
5194 ID3D10Device
*device
= pass
->technique
->effect
->device
;
5195 struct d3d10_effect_variable
*v
;
5197 v
= d3d10_array_get_element(shader_desc
->shader
, shader_desc
->index
);
5199 switch (v
->type
->basetype
)
5201 case D3D10_SVT_VERTEXSHADER
:
5202 ID3D10Device_VSSetShader(device
, v
->u
.shader
.shader
.vs
);
5204 case D3D10_SVT_PIXELSHADER
:
5205 ID3D10Device_PSSetShader(device
, v
->u
.shader
.shader
.ps
);
5207 case D3D10_SVT_GEOMETRYSHADER
:
5208 ID3D10Device_GSSetShader(device
, v
->u
.shader
.shader
.gs
);
5211 WARN("Unexpected shader type %u.\n", v
->type
->basetype
);
5214 apply_shader_resources(device
, v
);
5217 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_Apply(ID3D10EffectPass
*iface
, UINT flags
)
5219 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5220 ID3D10Device
*device
= pass
->technique
->effect
->device
;
5222 TRACE("iface %p, flags %#x\n", iface
, flags
);
5224 if (flags
) FIXME("Ignoring flags (%#x)\n", flags
);
5226 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
5228 if (pass
->vs
.shader
!= &null_shader_variable
)
5229 d3d10_effect_pass_set_shader(pass
, &pass
->vs
);
5230 if (pass
->gs
.shader
!= &null_shader_variable
)
5231 d3d10_effect_pass_set_shader(pass
, &pass
->gs
);
5232 if (pass
->ps
.shader
!= &null_shader_variable
)
5233 d3d10_effect_pass_set_shader(pass
, &pass
->ps
);
5234 if (pass
->rasterizer
)
5235 ID3D10Device_RSSetState(device
, pass
->rasterizer
->u
.state
.object
.rasterizer
);
5236 if (pass
->depth_stencil
)
5237 ID3D10Device_OMSetDepthStencilState(device
, pass
->depth_stencil
->u
.state
.object
.depth_stencil
,
5240 ID3D10Device_OMSetBlendState(device
, pass
->blend
->u
.state
.object
.blend
,
5241 pass
->blend_factor
, pass
->sample_mask
);
5246 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_ComputeStateBlockMask(ID3D10EffectPass
*iface
,
5247 D3D10_STATE_BLOCK_MASK
*mask
)
5249 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5251 FIXME("iface %p, mask %p semi-stub!\n", iface
, mask
);
5253 if (pass
->vs
.shader
!= &null_shader_variable
)
5254 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_VS
, 0, 1);
5255 if (pass
->ps
.shader
!= &null_shader_variable
)
5256 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_PS
, 0, 1);
5257 if (pass
->gs
.shader
!= &null_shader_variable
)
5258 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_GS
, 0, 1);
5259 if (pass
->rasterizer
)
5260 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_RS_RASTERIZER_STATE
, 0, 1);
5261 if (pass
->depth_stencil
)
5262 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_OM_DEPTH_STENCIL_STATE
, 0, 1);
5264 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_OM_BLEND_STATE
, 0, 1);
5269 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl
=
5271 /* ID3D10EffectPass methods */
5272 d3d10_effect_pass_IsValid
,
5273 d3d10_effect_pass_GetDesc
,
5274 d3d10_effect_pass_GetVertexShaderDesc
,
5275 d3d10_effect_pass_GetGeometryShaderDesc
,
5276 d3d10_effect_pass_GetPixelShaderDesc
,
5277 d3d10_effect_pass_GetAnnotationByIndex
,
5278 d3d10_effect_pass_GetAnnotationByName
,
5279 d3d10_effect_pass_Apply
,
5280 d3d10_effect_pass_ComputeStateBlockMask
,
5283 /* ID3D10EffectVariable methods */
5285 static BOOL STDMETHODCALLTYPE
d3d10_effect_variable_IsValid(ID3D10EffectVariable
*iface
)
5287 TRACE("iface %p\n", iface
);
5289 return impl_from_ID3D10EffectVariable(iface
) != &null_variable
;
5292 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_variable_GetType(ID3D10EffectVariable
*iface
)
5294 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5296 TRACE("iface %p\n", iface
);
5298 return &This
->type
->ID3D10EffectType_iface
;
5301 static HRESULT STDMETHODCALLTYPE
d3d10_effect_variable_GetDesc(ID3D10EffectVariable
*iface
,
5302 D3D10_EFFECT_VARIABLE_DESC
*desc
)
5304 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVariable(iface
);
5306 TRACE("iface %p, desc %p\n", iface
, desc
);
5308 if (!iface
->lpVtbl
->IsValid(iface
))
5310 WARN("Null variable specified\n");
5316 WARN("Invalid argument specified\n");
5317 return E_INVALIDARG
;
5320 /* FIXME: This isn't correct. Anonymous shaders let desc->ExplicitBindPoint untouched, but normal shaders set it! */
5321 memset(desc
, 0, sizeof(*desc
));
5322 desc
->Name
= v
->name
;
5323 desc
->Semantic
= v
->semantic
;
5324 desc
->Flags
= v
->flag
;
5325 desc
->Annotations
= v
->annotations
.count
;
5326 desc
->BufferOffset
= v
->buffer_offset
;
5328 if (v
->flag
& D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
)
5329 desc
->ExplicitBindPoint
= v
->explicit_bind_point
;
5334 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetAnnotationByIndex(
5335 ID3D10EffectVariable
*iface
, UINT index
)
5337 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectVariable(iface
);
5339 TRACE("iface %p, index %u\n", iface
, index
);
5341 return d3d10_annotation_get_by_index(&var
->annotations
, index
);
5344 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetAnnotationByName(
5345 ID3D10EffectVariable
*iface
, const char *name
)
5347 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectVariable(iface
);
5349 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5351 return d3d10_annotation_get_by_name(&var
->annotations
, name
);
5354 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetMemberByIndex(
5355 ID3D10EffectVariable
*iface
, UINT index
)
5357 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5358 struct d3d10_effect_variable
*m
;
5360 TRACE("iface %p, index %u\n", iface
, index
);
5362 if (index
>= This
->type
->member_count
)
5364 WARN("Invalid index specified\n");
5365 return &null_variable
.ID3D10EffectVariable_iface
;
5368 m
= &This
->members
[index
];
5370 TRACE("Returning member %p, %s\n", m
, debugstr_a(m
->name
));
5372 return &m
->ID3D10EffectVariable_iface
;
5375 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetMemberByName(
5376 ID3D10EffectVariable
*iface
, const char *name
)
5378 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5381 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5385 WARN("Invalid name specified\n");
5386 return &null_variable
.ID3D10EffectVariable_iface
;
5389 for (i
= 0; i
< This
->type
->member_count
; ++i
)
5391 struct d3d10_effect_variable
*m
= &This
->members
[i
];
5393 if (m
->name
&& !strcmp(m
->name
, name
))
5395 TRACE("Returning member %p\n", m
);
5396 return &m
->ID3D10EffectVariable_iface
;
5400 WARN("Invalid name specified\n");
5402 return &null_variable
.ID3D10EffectVariable_iface
;
5405 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetMemberBySemantic(
5406 ID3D10EffectVariable
*iface
, const char *semantic
)
5408 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5411 TRACE("iface %p, semantic %s.\n", iface
, debugstr_a(semantic
));
5415 WARN("Invalid semantic specified\n");
5416 return &null_variable
.ID3D10EffectVariable_iface
;
5419 for (i
= 0; i
< This
->type
->member_count
; ++i
)
5421 struct d3d10_effect_variable
*m
= &This
->members
[i
];
5423 if (m
->semantic
&& !stricmp(m
->semantic
, semantic
))
5425 TRACE("Returning member %p\n", m
);
5426 return &m
->ID3D10EffectVariable_iface
;
5430 WARN("Invalid semantic specified\n");
5432 return &null_variable
.ID3D10EffectVariable_iface
;
5435 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetElement(
5436 ID3D10EffectVariable
*iface
, UINT index
)
5438 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5439 struct d3d10_effect_variable
*v
;
5441 TRACE("iface %p, index %u\n", iface
, index
);
5443 if (index
>= This
->type
->element_count
)
5445 WARN("Invalid index specified\n");
5446 return &null_variable
.ID3D10EffectVariable_iface
;
5449 v
= &This
->elements
[index
];
5451 TRACE("Returning element %p, %s\n", v
, debugstr_a(v
->name
));
5453 return &v
->ID3D10EffectVariable_iface
;
5456 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_variable_GetParentConstantBuffer(
5457 ID3D10EffectVariable
*iface
)
5459 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5461 TRACE("iface %p\n", iface
);
5463 return (ID3D10EffectConstantBuffer
*)&This
->buffer
->ID3D10EffectVariable_iface
;
5466 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsScalar(
5467 ID3D10EffectVariable
*iface
)
5469 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5471 TRACE("iface %p\n", iface
);
5473 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_scalar_variable_vtbl
)
5474 return (ID3D10EffectScalarVariable
*)&This
->ID3D10EffectVariable_iface
;
5476 return (ID3D10EffectScalarVariable
*)&null_scalar_variable
.ID3D10EffectVariable_iface
;
5479 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsVector(
5480 ID3D10EffectVariable
*iface
)
5482 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5484 TRACE("iface %p\n", iface
);
5486 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_vector_variable_vtbl
)
5487 return (ID3D10EffectVectorVariable
*)&This
->ID3D10EffectVariable_iface
;
5489 return (ID3D10EffectVectorVariable
*)&null_vector_variable
.ID3D10EffectVariable_iface
;
5492 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsMatrix(
5493 ID3D10EffectVariable
*iface
)
5495 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5497 TRACE("iface %p\n", iface
);
5499 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_matrix_variable_vtbl
)
5500 return (ID3D10EffectMatrixVariable
*)&This
->ID3D10EffectVariable_iface
;
5502 return (ID3D10EffectMatrixVariable
*)&null_matrix_variable
.ID3D10EffectVariable_iface
;
5505 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsString(
5506 ID3D10EffectVariable
*iface
)
5508 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5510 TRACE("iface %p\n", iface
);
5512 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_string_variable_vtbl
)
5513 return (ID3D10EffectStringVariable
*)&This
->ID3D10EffectVariable_iface
;
5515 return (ID3D10EffectStringVariable
*)&null_string_variable
.ID3D10EffectVariable_iface
;
5518 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsShaderResource(
5519 ID3D10EffectVariable
*iface
)
5521 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5523 TRACE("iface %p\n", iface
);
5525 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_resource_variable_vtbl
)
5526 return (ID3D10EffectShaderResourceVariable
*)&This
->ID3D10EffectVariable_iface
;
5528 return (ID3D10EffectShaderResourceVariable
*)&null_shader_resource_variable
.ID3D10EffectVariable_iface
;
5531 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsRenderTargetView(
5532 ID3D10EffectVariable
*iface
)
5534 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5536 TRACE("iface %p\n", iface
);
5538 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_render_target_view_variable_vtbl
)
5539 return (ID3D10EffectRenderTargetViewVariable
*)&This
->ID3D10EffectVariable_iface
;
5541 return (ID3D10EffectRenderTargetViewVariable
*)&null_render_target_view_variable
.ID3D10EffectVariable_iface
;
5544 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsDepthStencilView(
5545 ID3D10EffectVariable
*iface
)
5547 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5549 TRACE("iface %p\n", iface
);
5551 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_view_variable_vtbl
)
5552 return (ID3D10EffectDepthStencilViewVariable
*)&This
->ID3D10EffectVariable_iface
;
5554 return (ID3D10EffectDepthStencilViewVariable
*)&null_depth_stencil_view_variable
.ID3D10EffectVariable_iface
;
5557 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_variable_AsConstantBuffer(
5558 ID3D10EffectVariable
*iface
)
5560 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5562 TRACE("iface %p\n", iface
);
5564 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_constant_buffer_vtbl
)
5565 return (ID3D10EffectConstantBuffer
*)&This
->ID3D10EffectVariable_iface
;
5567 return (ID3D10EffectConstantBuffer
*)&null_local_buffer
.ID3D10EffectVariable_iface
;
5570 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsShader(
5571 ID3D10EffectVariable
*iface
)
5573 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5575 TRACE("iface %p\n", iface
);
5577 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
)
5578 return (ID3D10EffectShaderVariable
*)&This
->ID3D10EffectVariable_iface
;
5580 return (ID3D10EffectShaderVariable
*)&null_shader_variable
.ID3D10EffectVariable_iface
;
5583 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsBlend(ID3D10EffectVariable
*iface
)
5585 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5587 TRACE("iface %p\n", iface
);
5589 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_blend_variable_vtbl
)
5590 return (ID3D10EffectBlendVariable
*)&This
->ID3D10EffectVariable_iface
;
5592 return (ID3D10EffectBlendVariable
*)&null_blend_variable
.ID3D10EffectVariable_iface
;
5595 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsDepthStencil(
5596 ID3D10EffectVariable
*iface
)
5598 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5600 TRACE("iface %p\n", iface
);
5602 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_variable_vtbl
)
5603 return (ID3D10EffectDepthStencilVariable
*)&This
->ID3D10EffectVariable_iface
;
5605 return (ID3D10EffectDepthStencilVariable
*)&null_depth_stencil_variable
.ID3D10EffectVariable_iface
;
5608 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsRasterizer(
5609 ID3D10EffectVariable
*iface
)
5611 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5613 TRACE("iface %p\n", iface
);
5615 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_rasterizer_variable_vtbl
)
5616 return (ID3D10EffectRasterizerVariable
*)&This
->ID3D10EffectVariable_iface
;
5618 return (ID3D10EffectRasterizerVariable
*)&null_rasterizer_variable
.ID3D10EffectVariable_iface
;
5621 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsSampler(
5622 ID3D10EffectVariable
*iface
)
5624 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5626 TRACE("iface %p\n", iface
);
5628 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_sampler_variable_vtbl
)
5629 return (ID3D10EffectSamplerVariable
*)&This
->ID3D10EffectVariable_iface
;
5631 return (ID3D10EffectSamplerVariable
*)&null_sampler_variable
.ID3D10EffectVariable_iface
;
5634 static HRESULT STDMETHODCALLTYPE
d3d10_effect_variable_SetRawValue(ID3D10EffectVariable
*iface
,
5635 void *data
, UINT offset
, UINT count
)
5637 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVariable(iface
);
5640 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
5642 if (!iface
->lpVtbl
->IsValid(iface
))
5644 WARN("Invalid variable.\n");
5648 is_buffer
= v
->type
->basetype
== D3D10_SVT_CBUFFER
|| v
->type
->basetype
== D3D10_SVT_TBUFFER
;
5650 if (v
->type
->type_class
== D3D10_SVC_OBJECT
&& !is_buffer
)
5652 WARN("Not supported on object variables of type %s.\n",
5653 debug_d3d10_shader_variable_type(v
->type
->basetype
));
5654 return D3DERR_INVALIDCALL
;
5659 offset
+= v
->buffer_offset
;
5663 memcpy(v
->u
.buffer
.local_buffer
+ offset
, data
, count
);
5664 v
->u
.buffer
.changed
= TRUE
;
5669 static HRESULT STDMETHODCALLTYPE
d3d10_effect_variable_GetRawValue(ID3D10EffectVariable
*iface
,
5670 void *data
, UINT offset
, UINT count
)
5672 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVariable(iface
);
5674 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
5676 if (!iface
->lpVtbl
->IsValid(iface
))
5678 WARN("Invalid variable.\n");
5682 return d3d10_effect_variable_get_raw_value(v
, data
, offset
, count
);
5685 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl
=
5687 /* ID3D10EffectVariable methods */
5688 d3d10_effect_variable_IsValid
,
5689 d3d10_effect_variable_GetType
,
5690 d3d10_effect_variable_GetDesc
,
5691 d3d10_effect_variable_GetAnnotationByIndex
,
5692 d3d10_effect_variable_GetAnnotationByName
,
5693 d3d10_effect_variable_GetMemberByIndex
,
5694 d3d10_effect_variable_GetMemberByName
,
5695 d3d10_effect_variable_GetMemberBySemantic
,
5696 d3d10_effect_variable_GetElement
,
5697 d3d10_effect_variable_GetParentConstantBuffer
,
5698 d3d10_effect_variable_AsScalar
,
5699 d3d10_effect_variable_AsVector
,
5700 d3d10_effect_variable_AsMatrix
,
5701 d3d10_effect_variable_AsString
,
5702 d3d10_effect_variable_AsShaderResource
,
5703 d3d10_effect_variable_AsRenderTargetView
,
5704 d3d10_effect_variable_AsDepthStencilView
,
5705 d3d10_effect_variable_AsConstantBuffer
,
5706 d3d10_effect_variable_AsShader
,
5707 d3d10_effect_variable_AsBlend
,
5708 d3d10_effect_variable_AsDepthStencil
,
5709 d3d10_effect_variable_AsRasterizer
,
5710 d3d10_effect_variable_AsSampler
,
5711 d3d10_effect_variable_SetRawValue
,
5712 d3d10_effect_variable_GetRawValue
,
5715 /* ID3D10EffectVariable methods */
5716 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectConstantBuffer(ID3D10EffectConstantBuffer
*iface
)
5718 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
5721 static BOOL STDMETHODCALLTYPE
d3d10_effect_constant_buffer_IsValid(ID3D10EffectConstantBuffer
*iface
)
5723 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectConstantBuffer(iface
);
5725 TRACE("iface %p.\n", iface
);
5727 return v
!= &null_local_buffer
;
5730 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetType(ID3D10EffectConstantBuffer
*iface
)
5732 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
5735 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetDesc(ID3D10EffectConstantBuffer
*iface
,
5736 D3D10_EFFECT_VARIABLE_DESC
*desc
)
5738 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
5741 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetAnnotationByIndex(
5742 ID3D10EffectConstantBuffer
*iface
, UINT index
)
5744 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
5747 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetAnnotationByName(
5748 ID3D10EffectConstantBuffer
*iface
, const char *name
)
5750 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
5753 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetMemberByIndex(
5754 ID3D10EffectConstantBuffer
*iface
, UINT index
)
5756 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
5759 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetMemberByName(
5760 ID3D10EffectConstantBuffer
*iface
, const char *name
)
5762 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
5765 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetMemberBySemantic(
5766 ID3D10EffectConstantBuffer
*iface
, const char *semantic
)
5768 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
5771 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetElement(
5772 ID3D10EffectConstantBuffer
*iface
, UINT index
)
5774 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
5777 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetParentConstantBuffer(
5778 ID3D10EffectConstantBuffer
*iface
)
5780 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
5783 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsScalar(
5784 ID3D10EffectConstantBuffer
*iface
)
5786 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
5789 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsVector(
5790 ID3D10EffectConstantBuffer
*iface
)
5792 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
5795 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsMatrix(
5796 ID3D10EffectConstantBuffer
*iface
)
5798 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
5801 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsString(
5802 ID3D10EffectConstantBuffer
*iface
)
5804 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
5807 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsShaderResource(
5808 ID3D10EffectConstantBuffer
*iface
)
5810 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
5813 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsRenderTargetView(
5814 ID3D10EffectConstantBuffer
*iface
)
5816 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
5819 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsDepthStencilView(
5820 ID3D10EffectConstantBuffer
*iface
)
5822 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
5825 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsConstantBuffer(
5826 ID3D10EffectConstantBuffer
*iface
)
5828 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
5831 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsShader(
5832 ID3D10EffectConstantBuffer
*iface
)
5834 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
5837 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsBlend(ID3D10EffectConstantBuffer
*iface
)
5839 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
5842 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsDepthStencil(
5843 ID3D10EffectConstantBuffer
*iface
)
5845 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
5848 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsRasterizer(
5849 ID3D10EffectConstantBuffer
*iface
)
5851 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
5854 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsSampler(
5855 ID3D10EffectConstantBuffer
*iface
)
5857 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
5860 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_SetRawValue(ID3D10EffectConstantBuffer
*iface
,
5861 void *data
, UINT offset
, UINT count
)
5863 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
5866 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetRawValue(ID3D10EffectConstantBuffer
*iface
,
5867 void *data
, UINT offset
, UINT count
)
5869 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
5872 /* ID3D10EffectConstantBuffer methods */
5873 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_SetConstantBuffer(ID3D10EffectConstantBuffer
*iface
,
5874 ID3D10Buffer
*buffer
)
5876 FIXME("iface %p, buffer %p stub!\n", iface
, buffer
);
5881 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetConstantBuffer(ID3D10EffectConstantBuffer
*iface
,
5882 ID3D10Buffer
**buffer
)
5884 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectConstantBuffer(iface
);
5886 TRACE("iface %p, buffer %p.\n", iface
, buffer
);
5888 if (!iface
->lpVtbl
->IsValid(iface
))
5890 WARN("Null variable specified.\n");
5894 if (v
->type
->basetype
!= D3D10_SVT_CBUFFER
)
5896 WARN("Wrong variable type %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
5897 return D3DERR_INVALIDCALL
;
5900 *buffer
= v
->u
.buffer
.buffer
;
5901 ID3D10Buffer_AddRef(*buffer
);
5906 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_SetTextureBuffer(ID3D10EffectConstantBuffer
*iface
,
5907 ID3D10ShaderResourceView
*view
)
5909 FIXME("iface %p, view %p stub!\n", iface
, view
);
5914 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetTextureBuffer(ID3D10EffectConstantBuffer
*iface
,
5915 ID3D10ShaderResourceView
**view
)
5917 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectConstantBuffer(iface
);
5919 FIXME("iface %p, view %p stub!\n", iface
, view
);
5921 if (!iface
->lpVtbl
->IsValid(iface
))
5923 WARN("Null variable specified.\n");
5927 if (v
->type
->basetype
!= D3D10_SVT_TBUFFER
)
5929 WARN("Wrong variable type %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
5930 return D3DERR_INVALIDCALL
;
5936 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl
=
5938 /* ID3D10EffectVariable methods */
5939 d3d10_effect_constant_buffer_IsValid
,
5940 d3d10_effect_constant_buffer_GetType
,
5941 d3d10_effect_constant_buffer_GetDesc
,
5942 d3d10_effect_constant_buffer_GetAnnotationByIndex
,
5943 d3d10_effect_constant_buffer_GetAnnotationByName
,
5944 d3d10_effect_constant_buffer_GetMemberByIndex
,
5945 d3d10_effect_constant_buffer_GetMemberByName
,
5946 d3d10_effect_constant_buffer_GetMemberBySemantic
,
5947 d3d10_effect_constant_buffer_GetElement
,
5948 d3d10_effect_constant_buffer_GetParentConstantBuffer
,
5949 d3d10_effect_constant_buffer_AsScalar
,
5950 d3d10_effect_constant_buffer_AsVector
,
5951 d3d10_effect_constant_buffer_AsMatrix
,
5952 d3d10_effect_constant_buffer_AsString
,
5953 d3d10_effect_constant_buffer_AsShaderResource
,
5954 d3d10_effect_constant_buffer_AsRenderTargetView
,
5955 d3d10_effect_constant_buffer_AsDepthStencilView
,
5956 d3d10_effect_constant_buffer_AsConstantBuffer
,
5957 d3d10_effect_constant_buffer_AsShader
,
5958 d3d10_effect_constant_buffer_AsBlend
,
5959 d3d10_effect_constant_buffer_AsDepthStencil
,
5960 d3d10_effect_constant_buffer_AsRasterizer
,
5961 d3d10_effect_constant_buffer_AsSampler
,
5962 d3d10_effect_constant_buffer_SetRawValue
,
5963 d3d10_effect_constant_buffer_GetRawValue
,
5964 /* ID3D10EffectConstantBuffer methods */
5965 d3d10_effect_constant_buffer_SetConstantBuffer
,
5966 d3d10_effect_constant_buffer_GetConstantBuffer
,
5967 d3d10_effect_constant_buffer_SetTextureBuffer
,
5968 d3d10_effect_constant_buffer_GetTextureBuffer
,
5972 static BOOL
get_value_as_bool(void *src_data
, D3D10_SHADER_VARIABLE_TYPE src_type
)
5976 case D3D10_SVT_FLOAT
:
5978 case D3D10_SVT_UINT
:
5979 case D3D10_SVT_BOOL
:
5980 if (*(DWORD
*)src_data
)
5991 static int get_value_as_int(void *src_data
, D3D10_SHADER_VARIABLE_TYPE src_type
)
5995 case D3D10_SVT_FLOAT
:
5996 return (int)(*(float *)src_data
);
5999 case D3D10_SVT_UINT
:
6000 return *(int *)src_data
;
6002 case D3D10_SVT_BOOL
:
6003 return get_value_as_bool(src_data
, src_type
);
6010 static float get_value_as_float(void *src_data
, D3D10_SHADER_VARIABLE_TYPE src_type
)
6014 case D3D10_SVT_FLOAT
:
6015 return *(float *)src_data
;
6018 case D3D10_SVT_UINT
:
6019 return (float)(*(int *)src_data
);
6021 case D3D10_SVT_BOOL
:
6022 return (float)get_value_as_bool(src_data
, src_type
);
6029 static void get_vector_as_type(BYTE
*dst_data
, D3D_SHADER_VARIABLE_TYPE dst_type
,
6030 BYTE
*src_data
, D3D_SHADER_VARIABLE_TYPE src_type
, unsigned int count
)
6032 DWORD
*src_data_dword
= (DWORD
*)src_data
;
6033 DWORD
*dst_data_dword
= (DWORD
*)dst_data
;
6036 for (i
= 0; i
< count
; ++i
, ++dst_data_dword
, ++src_data_dword
)
6038 if (dst_type
== src_type
)
6039 *dst_data_dword
= *src_data_dword
;
6044 case D3D10_SVT_FLOAT
:
6045 *(float *)dst_data_dword
= get_value_as_float(src_data_dword
, src_type
);
6049 case D3D10_SVT_UINT
:
6050 *(int *)dst_data_dword
= get_value_as_int(src_data_dword
, src_type
);
6053 case D3D10_SVT_BOOL
:
6054 *(BOOL
*)dst_data_dword
= get_value_as_bool(src_data_dword
, src_type
);
6058 *dst_data_dword
= 0;
6065 static void write_variable_to_buffer(struct d3d10_effect_variable
*variable
, void *src
,
6066 D3D_SHADER_VARIABLE_TYPE src_type
)
6068 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6069 D3D_SHADER_VARIABLE_TYPE dst_type
= variable
->type
->basetype
;
6071 get_vector_as_type(dst
, dst_type
, src
, src_type
, variable
->type
->column_count
);
6073 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6076 static void write_variable_array_to_buffer(struct d3d10_effect_variable
*variable
, void *src
,
6077 D3D_SHADER_VARIABLE_TYPE src_type
, unsigned int offset
, unsigned int count
)
6079 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6080 D3D_SHADER_VARIABLE_TYPE dst_type
= variable
->type
->basetype
;
6081 unsigned int element_size
, i
;
6082 BYTE
*cur_element
= src
;
6084 if (!variable
->type
->element_count
)
6086 write_variable_to_buffer(variable
, src
, src_type
);
6090 if (offset
>= variable
->type
->element_count
)
6092 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6096 if (count
> variable
->type
->element_count
- offset
)
6098 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6099 offset
, count
, variable
->type
->element_count
);
6100 count
= variable
->type
->element_count
- offset
;
6103 element_size
= variable
->type
->elementtype
->size_packed
;
6104 dst
+= variable
->type
->stride
* offset
;
6106 for (i
= 0; i
< count
; ++i
)
6108 get_vector_as_type(dst
, dst_type
, cur_element
, src_type
, variable
->type
->column_count
);
6110 cur_element
+= element_size
;
6111 dst
+= variable
->type
->stride
;
6114 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6117 static void read_variable_from_buffer(struct d3d10_effect_variable
*variable
, void *dst
,
6118 D3D_SHADER_VARIABLE_TYPE dst_type
)
6120 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6121 D3D_SHADER_VARIABLE_TYPE src_type
= variable
->type
->basetype
;
6123 get_vector_as_type(dst
, dst_type
, src
, src_type
, variable
->type
->column_count
);
6126 static void read_variable_array_from_buffer(struct d3d10_effect_variable
*variable
, void *dst
,
6127 D3D_SHADER_VARIABLE_TYPE dst_type
, unsigned int offset
, unsigned int count
)
6129 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6130 D3D_SHADER_VARIABLE_TYPE src_type
= variable
->type
->basetype
;
6131 unsigned int element_size
, i
;
6132 BYTE
*cur_element
= dst
;
6134 if (!variable
->type
->element_count
)
6136 read_variable_from_buffer(variable
, dst
, dst_type
);
6140 if (offset
>= variable
->type
->element_count
)
6142 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6146 if (count
> variable
->type
->element_count
- offset
)
6148 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6149 offset
, count
, variable
->type
->element_count
);
6150 count
= variable
->type
->element_count
- offset
;
6153 element_size
= variable
->type
->elementtype
->size_packed
;
6154 src
+= variable
->type
->stride
* offset
;
6156 for (i
= 0; i
< count
; ++i
)
6158 get_vector_as_type(cur_element
, dst_type
, src
, src_type
, variable
->type
->column_count
);
6160 cur_element
+= element_size
;
6161 src
+= variable
->type
->stride
;
6165 /* ID3D10EffectVariable methods */
6167 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectScalarVariable(ID3D10EffectScalarVariable
*iface
)
6169 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
6172 static BOOL STDMETHODCALLTYPE
d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable
*iface
)
6174 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectScalarVariable(iface
);
6176 TRACE("iface %p\n", iface
);
6178 return v
!= &null_scalar_variable
;
6181 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetType(
6182 ID3D10EffectScalarVariable
*iface
)
6184 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
6187 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetDesc(ID3D10EffectScalarVariable
*iface
,
6188 D3D10_EFFECT_VARIABLE_DESC
*desc
)
6190 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
6193 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetAnnotationByIndex(
6194 ID3D10EffectScalarVariable
*iface
, UINT index
)
6196 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
6199 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetAnnotationByName(
6200 ID3D10EffectScalarVariable
*iface
, const char *name
)
6202 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
6205 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetMemberByIndex(
6206 ID3D10EffectScalarVariable
*iface
, UINT index
)
6208 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
6211 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetMemberByName(
6212 ID3D10EffectScalarVariable
*iface
, const char *name
)
6214 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
6217 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetMemberBySemantic(
6218 ID3D10EffectScalarVariable
*iface
, const char *semantic
)
6220 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
6223 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetElement(
6224 ID3D10EffectScalarVariable
*iface
, UINT index
)
6226 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
6229 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetParentConstantBuffer(
6230 ID3D10EffectScalarVariable
*iface
)
6232 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
6235 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsScalar(
6236 ID3D10EffectScalarVariable
*iface
)
6238 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
6241 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsVector(
6242 ID3D10EffectScalarVariable
*iface
)
6244 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
6247 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsMatrix(
6248 ID3D10EffectScalarVariable
*iface
)
6250 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
6253 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsString(
6254 ID3D10EffectScalarVariable
*iface
)
6256 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
6259 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsShaderResource(
6260 ID3D10EffectScalarVariable
*iface
)
6262 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
6265 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsRenderTargetView(
6266 ID3D10EffectScalarVariable
*iface
)
6268 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
6271 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsDepthStencilView(
6272 ID3D10EffectScalarVariable
*iface
)
6274 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
6277 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsConstantBuffer(
6278 ID3D10EffectScalarVariable
*iface
)
6280 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
6283 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsShader(
6284 ID3D10EffectScalarVariable
*iface
)
6286 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
6289 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsBlend(
6290 ID3D10EffectScalarVariable
*iface
)
6292 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
6295 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsDepthStencil(
6296 ID3D10EffectScalarVariable
*iface
)
6298 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
6301 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsRasterizer(
6302 ID3D10EffectScalarVariable
*iface
)
6304 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
6307 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsSampler(
6308 ID3D10EffectScalarVariable
*iface
)
6310 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
6313 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetRawValue(ID3D10EffectScalarVariable
*iface
,
6314 void *data
, UINT offset
, UINT count
)
6316 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6319 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetRawValue(ID3D10EffectScalarVariable
*iface
,
6320 void *data
, UINT offset
, UINT count
)
6322 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6325 /* ID3D10EffectScalarVariable methods */
6327 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetFloat(ID3D10EffectScalarVariable
*iface
,
6330 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6332 TRACE("iface %p, value %.8e.\n", iface
, value
);
6333 write_variable_to_buffer(effect_var
, &value
, D3D10_SVT_FLOAT
);
6338 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable
*iface
,
6341 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6343 TRACE("iface %p, value %p.\n", iface
, value
);
6344 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_FLOAT
);
6349 /* Tests show that offset is ignored for scalar variables. */
6350 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetFloatArray(ID3D10EffectScalarVariable
*iface
,
6351 float *values
, UINT offset
, UINT count
)
6353 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6355 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6356 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, 0, count
);
6361 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable
*iface
,
6362 float *values
, UINT offset
, UINT count
)
6364 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6366 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6367 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, 0, count
);
6372 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable
*iface
,
6375 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6377 TRACE("iface %p, value %d.\n", iface
, value
);
6378 write_variable_to_buffer(effect_var
, &value
, D3D10_SVT_INT
);
6383 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetInt(ID3D10EffectScalarVariable
*iface
,
6386 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6388 TRACE("iface %p, value %p.\n", iface
, value
);
6389 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_INT
);
6394 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable
*iface
,
6395 int *values
, UINT offset
, UINT count
)
6397 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6399 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6400 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_INT
, 0, count
);
6405 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable
*iface
,
6406 int *values
, UINT offset
, UINT count
)
6408 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6410 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6411 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_INT
, 0, count
);
6416 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable
*iface
,
6419 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6421 TRACE("iface %p, value %d.\n", iface
, value
);
6422 write_variable_to_buffer(effect_var
, &value
, D3D10_SVT_BOOL
);
6427 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetBool(ID3D10EffectScalarVariable
*iface
,
6430 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6432 TRACE("iface %p, value %p.\n", iface
, value
);
6433 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_BOOL
);
6438 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable
*iface
,
6439 BOOL
*values
, UINT offset
, UINT count
)
6441 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6443 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6444 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_BOOL
, 0, count
);
6449 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable
*iface
,
6450 BOOL
*values
, UINT offset
, UINT count
)
6452 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6454 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6455 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_BOOL
, 0, count
);
6460 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl
=
6462 /* ID3D10EffectVariable methods */
6463 d3d10_effect_scalar_variable_IsValid
,
6464 d3d10_effect_scalar_variable_GetType
,
6465 d3d10_effect_scalar_variable_GetDesc
,
6466 d3d10_effect_scalar_variable_GetAnnotationByIndex
,
6467 d3d10_effect_scalar_variable_GetAnnotationByName
,
6468 d3d10_effect_scalar_variable_GetMemberByIndex
,
6469 d3d10_effect_scalar_variable_GetMemberByName
,
6470 d3d10_effect_scalar_variable_GetMemberBySemantic
,
6471 d3d10_effect_scalar_variable_GetElement
,
6472 d3d10_effect_scalar_variable_GetParentConstantBuffer
,
6473 d3d10_effect_scalar_variable_AsScalar
,
6474 d3d10_effect_scalar_variable_AsVector
,
6475 d3d10_effect_scalar_variable_AsMatrix
,
6476 d3d10_effect_scalar_variable_AsString
,
6477 d3d10_effect_scalar_variable_AsShaderResource
,
6478 d3d10_effect_scalar_variable_AsRenderTargetView
,
6479 d3d10_effect_scalar_variable_AsDepthStencilView
,
6480 d3d10_effect_scalar_variable_AsConstantBuffer
,
6481 d3d10_effect_scalar_variable_AsShader
,
6482 d3d10_effect_scalar_variable_AsBlend
,
6483 d3d10_effect_scalar_variable_AsDepthStencil
,
6484 d3d10_effect_scalar_variable_AsRasterizer
,
6485 d3d10_effect_scalar_variable_AsSampler
,
6486 d3d10_effect_scalar_variable_SetRawValue
,
6487 d3d10_effect_scalar_variable_GetRawValue
,
6488 /* ID3D10EffectScalarVariable methods */
6489 d3d10_effect_scalar_variable_SetFloat
,
6490 d3d10_effect_scalar_variable_GetFloat
,
6491 d3d10_effect_scalar_variable_SetFloatArray
,
6492 d3d10_effect_scalar_variable_GetFloatArray
,
6493 d3d10_effect_scalar_variable_SetInt
,
6494 d3d10_effect_scalar_variable_GetInt
,
6495 d3d10_effect_scalar_variable_SetIntArray
,
6496 d3d10_effect_scalar_variable_GetIntArray
,
6497 d3d10_effect_scalar_variable_SetBool
,
6498 d3d10_effect_scalar_variable_GetBool
,
6499 d3d10_effect_scalar_variable_SetBoolArray
,
6500 d3d10_effect_scalar_variable_GetBoolArray
,
6503 /* ID3D10EffectVariable methods */
6505 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectVectorVariable(ID3D10EffectVectorVariable
*iface
)
6507 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
6510 static BOOL STDMETHODCALLTYPE
d3d10_effect_vector_variable_IsValid(ID3D10EffectVectorVariable
*iface
)
6512 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVectorVariable(iface
);
6514 TRACE("iface %p\n", iface
);
6516 return v
!= &null_vector_variable
;
6519 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetType(
6520 ID3D10EffectVectorVariable
*iface
)
6522 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
6525 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetDesc(ID3D10EffectVectorVariable
*iface
,
6526 D3D10_EFFECT_VARIABLE_DESC
*desc
)
6528 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
6531 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetAnnotationByIndex(
6532 ID3D10EffectVectorVariable
*iface
, UINT index
)
6534 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
6537 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetAnnotationByName(
6538 ID3D10EffectVectorVariable
*iface
, const char *name
)
6540 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
6543 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetMemberByIndex(
6544 ID3D10EffectVectorVariable
*iface
, UINT index
)
6546 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
6549 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetMemberByName(
6550 ID3D10EffectVectorVariable
*iface
, const char *name
)
6552 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
6555 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetMemberBySemantic(
6556 ID3D10EffectVectorVariable
*iface
, const char *semantic
)
6558 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
6561 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetElement(
6562 ID3D10EffectVectorVariable
*iface
, UINT index
)
6564 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
6567 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetParentConstantBuffer(
6568 ID3D10EffectVectorVariable
*iface
)
6570 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
6573 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsScalar(
6574 ID3D10EffectVectorVariable
*iface
)
6576 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
6579 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsVector(
6580 ID3D10EffectVectorVariable
*iface
)
6582 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
6585 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsMatrix(
6586 ID3D10EffectVectorVariable
*iface
)
6588 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
6591 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsString(
6592 ID3D10EffectVectorVariable
*iface
)
6594 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
6597 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsShaderResource(
6598 ID3D10EffectVectorVariable
*iface
)
6600 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
6603 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsRenderTargetView(
6604 ID3D10EffectVectorVariable
*iface
)
6606 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
6609 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsDepthStencilView(
6610 ID3D10EffectVectorVariable
*iface
)
6612 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
6615 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsConstantBuffer(
6616 ID3D10EffectVectorVariable
*iface
)
6618 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
6621 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsShader(
6622 ID3D10EffectVectorVariable
*iface
)
6624 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
6627 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsBlend(
6628 ID3D10EffectVectorVariable
*iface
)
6630 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
6633 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsDepthStencil(
6634 ID3D10EffectVectorVariable
*iface
)
6636 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
6639 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsRasterizer(
6640 ID3D10EffectVectorVariable
*iface
)
6642 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
6645 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsSampler(
6646 ID3D10EffectVectorVariable
*iface
)
6648 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
6651 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetRawValue(ID3D10EffectVectorVariable
*iface
,
6652 void *data
, UINT offset
, UINT count
)
6654 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6657 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetRawValue(ID3D10EffectVectorVariable
*iface
,
6658 void *data
, UINT offset
, UINT count
)
6660 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6663 /* ID3D10EffectVectorVariable methods */
6665 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetBoolVector(ID3D10EffectVectorVariable
*iface
,
6668 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6670 TRACE("iface %p, value %p.\n", iface
, value
);
6671 write_variable_to_buffer(effect_var
, value
, D3D10_SVT_BOOL
);
6676 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetIntVector(ID3D10EffectVectorVariable
*iface
,
6679 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6681 TRACE("iface %p, value %p.\n", iface
, value
);
6682 write_variable_to_buffer(effect_var
, value
, D3D10_SVT_INT
);
6687 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetFloatVector(ID3D10EffectVectorVariable
*iface
,
6690 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6692 TRACE("iface %p, value %p.\n", iface
, value
);
6693 write_variable_to_buffer(effect_var
, value
, D3D10_SVT_FLOAT
);
6698 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable
*iface
,
6701 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6703 TRACE("iface %p, value %p.\n", iface
, value
);
6704 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_BOOL
);
6709 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetIntVector(ID3D10EffectVectorVariable
*iface
,
6712 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6714 TRACE("iface %p, value %p.\n", iface
, value
);
6715 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_INT
);
6720 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetFloatVector(ID3D10EffectVectorVariable
*iface
,
6723 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6725 TRACE("iface %p, value %p.\n", iface
, value
);
6726 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_FLOAT
);
6731 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable
*iface
,
6732 BOOL
*values
, UINT offset
, UINT count
)
6734 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6736 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6737 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_BOOL
, offset
, count
);
6742 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetIntVectorArray(ID3D10EffectVectorVariable
*iface
,
6743 int *values
, UINT offset
, UINT count
)
6745 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6747 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6748 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_INT
, offset
, count
);
6753 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetFloatVectorArray(ID3D10EffectVectorVariable
*iface
,
6754 float *values
, UINT offset
, UINT count
)
6756 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6758 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6759 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, offset
, count
);
6764 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetBoolVectorArray(ID3D10EffectVectorVariable
*iface
,
6765 BOOL
*values
, UINT offset
, UINT count
)
6767 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6769 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6770 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_BOOL
, offset
, count
);
6775 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetIntVectorArray(ID3D10EffectVectorVariable
*iface
,
6776 int *values
, UINT offset
, UINT count
)
6778 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6780 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6781 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_INT
, offset
, count
);
6786 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetFloatVectorArray(ID3D10EffectVectorVariable
*iface
,
6787 float *values
, UINT offset
, UINT count
)
6789 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6791 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6792 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, offset
, count
);
6797 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl
=
6799 /* ID3D10EffectVariable methods */
6800 d3d10_effect_vector_variable_IsValid
,
6801 d3d10_effect_vector_variable_GetType
,
6802 d3d10_effect_vector_variable_GetDesc
,
6803 d3d10_effect_vector_variable_GetAnnotationByIndex
,
6804 d3d10_effect_vector_variable_GetAnnotationByName
,
6805 d3d10_effect_vector_variable_GetMemberByIndex
,
6806 d3d10_effect_vector_variable_GetMemberByName
,
6807 d3d10_effect_vector_variable_GetMemberBySemantic
,
6808 d3d10_effect_vector_variable_GetElement
,
6809 d3d10_effect_vector_variable_GetParentConstantBuffer
,
6810 d3d10_effect_vector_variable_AsScalar
,
6811 d3d10_effect_vector_variable_AsVector
,
6812 d3d10_effect_vector_variable_AsMatrix
,
6813 d3d10_effect_vector_variable_AsString
,
6814 d3d10_effect_vector_variable_AsShaderResource
,
6815 d3d10_effect_vector_variable_AsRenderTargetView
,
6816 d3d10_effect_vector_variable_AsDepthStencilView
,
6817 d3d10_effect_vector_variable_AsConstantBuffer
,
6818 d3d10_effect_vector_variable_AsShader
,
6819 d3d10_effect_vector_variable_AsBlend
,
6820 d3d10_effect_vector_variable_AsDepthStencil
,
6821 d3d10_effect_vector_variable_AsRasterizer
,
6822 d3d10_effect_vector_variable_AsSampler
,
6823 d3d10_effect_vector_variable_SetRawValue
,
6824 d3d10_effect_vector_variable_GetRawValue
,
6825 /* ID3D10EffectVectorVariable methods */
6826 d3d10_effect_vector_variable_SetBoolVector
,
6827 d3d10_effect_vector_variable_SetIntVector
,
6828 d3d10_effect_vector_variable_SetFloatVector
,
6829 d3d10_effect_vector_variable_GetBoolVector
,
6830 d3d10_effect_vector_variable_GetIntVector
,
6831 d3d10_effect_vector_variable_GetFloatVector
,
6832 d3d10_effect_vector_variable_SetBoolVectorArray
,
6833 d3d10_effect_vector_variable_SetIntVectorArray
,
6834 d3d10_effect_vector_variable_SetFloatVectorArray
,
6835 d3d10_effect_vector_variable_GetBoolVectorArray
,
6836 d3d10_effect_vector_variable_GetIntVectorArray
,
6837 d3d10_effect_vector_variable_GetFloatVectorArray
,
6840 static void write_matrix_to_buffer(struct d3d10_effect_variable
*variable
, void *dst_void
,
6841 struct d3d10_matrix
*src
, BOOL transpose
)
6843 unsigned int col_count
= !transpose
? variable
->type
->column_count
: variable
->type
->row_count
;
6844 unsigned int row_count
= !transpose
? variable
->type
->row_count
: variable
->type
->column_count
;
6845 BOOL major
= variable
->type
->type_class
== D3D10_SVC_MATRIX_COLUMNS
;
6846 float *dst
= dst_void
;
6847 unsigned int row
, col
;
6854 for (col
= 0; col
< col_count
; ++col
)
6856 for (row
= 0; row
< row_count
; ++row
)
6857 dst
[(col
* 4) + row
] = src
->m
[row
][col
];
6862 for (row
= 0; row
< row_count
; ++row
)
6864 for (col
= 0; col
< col_count
; ++col
)
6865 dst
[(row
* 4) + col
] = src
->m
[row
][col
];
6870 static void write_matrix_variable_to_buffer(struct d3d10_effect_variable
*variable
, void *src_data
, BOOL transpose
)
6872 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6874 write_matrix_to_buffer(variable
, dst
, src_data
, transpose
);
6876 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6879 static void write_matrix_variable_array_to_buffer(struct d3d10_effect_variable
*variable
, void *src_data
,
6880 unsigned int offset
, unsigned int count
, BOOL transpose
)
6882 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6883 struct d3d10_matrix
*src
= src_data
;
6886 if (!variable
->type
->element_count
)
6888 write_matrix_variable_to_buffer(variable
, src_data
, transpose
);
6892 if (offset
>= variable
->type
->element_count
)
6894 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6898 if (count
> variable
->type
->element_count
- offset
)
6900 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6901 offset
, count
, variable
->type
->element_count
);
6902 count
= variable
->type
->element_count
- offset
;
6906 dst
+= variable
->type
->stride
* offset
;
6908 for (i
= 0; i
< count
; ++i
)
6910 write_matrix_to_buffer(variable
, dst
, &src
[i
], transpose
);
6912 dst
+= variable
->type
->stride
;
6915 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6918 static void read_matrix_from_buffer(struct d3d10_effect_variable
*variable
, void *src_void
,
6919 struct d3d10_matrix
*dst
, BOOL transpose
)
6921 unsigned int col_count
= !transpose
? variable
->type
->column_count
: variable
->type
->row_count
;
6922 unsigned int row_count
= !transpose
? variable
->type
->row_count
: variable
->type
->column_count
;
6923 BOOL major
= variable
->type
->type_class
== D3D10_SVC_MATRIX_COLUMNS
;
6924 float *src
= src_void
;
6925 unsigned int row
, col
;
6932 for (col
= 0; col
< col_count
; ++col
)
6934 for (row
= 0; row
< row_count
; ++row
)
6935 dst
->m
[row
][col
] = src
[(col
* 4) + row
];
6940 for (row
= 0; row
< row_count
; ++row
)
6942 for (col
= 0; col
< col_count
; ++col
)
6943 dst
->m
[row
][col
] = src
[(row
* 4) + col
];
6948 static void read_matrix_variable_from_buffer(struct d3d10_effect_variable
*variable
, void *dst
, BOOL transpose
)
6950 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6952 read_matrix_from_buffer(variable
, src
, dst
, transpose
);
6955 static void read_matrix_variable_array_from_buffer(struct d3d10_effect_variable
*variable
, void *dst_data
, UINT offset
,
6956 UINT count
, BOOL transpose
)
6958 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6959 struct d3d10_matrix
*dst
= dst_data
;
6962 if (!variable
->type
->element_count
)
6964 read_matrix_variable_from_buffer(variable
, dst_data
, transpose
);
6968 if (offset
>= variable
->type
->element_count
)
6970 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6974 if (count
> variable
->type
->element_count
- offset
)
6976 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6977 offset
, count
, variable
->type
->element_count
);
6978 count
= variable
->type
->element_count
- offset
;
6982 src
+= variable
->type
->stride
* offset
;
6984 for (i
= 0; i
< count
; ++i
)
6986 read_matrix_from_buffer(variable
, src
, &dst
[i
], transpose
);
6988 src
+= variable
->type
->stride
;
6992 /* ID3D10EffectVariable methods */
6994 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectMatrixVariable(ID3D10EffectMatrixVariable
*iface
)
6996 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
6999 static BOOL STDMETHODCALLTYPE
d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable
*iface
)
7001 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectMatrixVariable(iface
);
7003 TRACE("iface %p\n", iface
);
7005 return v
!= &null_matrix_variable
;
7008 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetType(
7009 ID3D10EffectMatrixVariable
*iface
)
7011 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7014 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetDesc(ID3D10EffectMatrixVariable
*iface
,
7015 D3D10_EFFECT_VARIABLE_DESC
*desc
)
7017 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7020 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetAnnotationByIndex(
7021 ID3D10EffectMatrixVariable
*iface
, UINT index
)
7023 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7026 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetAnnotationByName(
7027 ID3D10EffectMatrixVariable
*iface
, const char *name
)
7029 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7032 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMemberByIndex(
7033 ID3D10EffectMatrixVariable
*iface
, UINT index
)
7035 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7038 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMemberByName(
7039 ID3D10EffectMatrixVariable
*iface
, const char *name
)
7041 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7044 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMemberBySemantic(
7045 ID3D10EffectMatrixVariable
*iface
, const char *semantic
)
7047 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7050 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetElement(
7051 ID3D10EffectMatrixVariable
*iface
, UINT index
)
7053 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7056 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetParentConstantBuffer(
7057 ID3D10EffectMatrixVariable
*iface
)
7059 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7062 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsScalar(
7063 ID3D10EffectMatrixVariable
*iface
)
7065 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7068 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsVector(
7069 ID3D10EffectMatrixVariable
*iface
)
7071 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7074 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsMatrix(
7075 ID3D10EffectMatrixVariable
*iface
)
7077 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7080 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsString(
7081 ID3D10EffectMatrixVariable
*iface
)
7083 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7086 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsShaderResource(
7087 ID3D10EffectMatrixVariable
*iface
)
7089 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7092 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsRenderTargetView(
7093 ID3D10EffectMatrixVariable
*iface
)
7095 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7098 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsDepthStencilView(
7099 ID3D10EffectMatrixVariable
*iface
)
7101 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7104 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsConstantBuffer(
7105 ID3D10EffectMatrixVariable
*iface
)
7107 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7110 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsShader(
7111 ID3D10EffectMatrixVariable
*iface
)
7113 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7116 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsBlend(
7117 ID3D10EffectMatrixVariable
*iface
)
7119 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7122 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsDepthStencil(
7123 ID3D10EffectMatrixVariable
*iface
)
7125 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7128 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsRasterizer(
7129 ID3D10EffectMatrixVariable
*iface
)
7131 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7134 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsSampler(
7135 ID3D10EffectMatrixVariable
*iface
)
7137 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7140 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetRawValue(ID3D10EffectMatrixVariable
*iface
,
7141 void *data
, UINT offset
, UINT count
)
7143 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7146 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetRawValue(ID3D10EffectMatrixVariable
*iface
,
7147 void *data
, UINT offset
, UINT count
)
7149 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7152 /* ID3D10EffectMatrixVariable methods */
7154 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrix(ID3D10EffectMatrixVariable
*iface
,
7157 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7159 TRACE("iface %p, data %p.\n", iface
, data
);
7160 write_matrix_variable_to_buffer(var
, data
, FALSE
);
7165 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable
*iface
,
7168 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7170 TRACE("iface %p, data %p.\n", iface
, data
);
7171 read_matrix_variable_from_buffer(var
, data
, FALSE
);
7176 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable
*iface
,
7177 float *data
, UINT offset
, UINT count
)
7179 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7181 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7182 write_matrix_variable_array_to_buffer(var
, data
, offset
, count
, FALSE
);
7187 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable
*iface
,
7188 float *data
, UINT offset
, UINT count
)
7190 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7192 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7193 read_matrix_variable_array_from_buffer(var
, data
, offset
, count
, FALSE
);
7198 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable
*iface
,
7201 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7203 TRACE("iface %p, data %p.\n", iface
, data
);
7204 write_matrix_variable_to_buffer(var
, data
, TRUE
);
7209 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable
*iface
,
7212 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7214 TRACE("iface %p, data %p.\n", iface
, data
);
7215 read_matrix_variable_from_buffer(var
, data
, TRUE
);
7220 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable
*iface
,
7221 float *data
, UINT offset
, UINT count
)
7223 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7225 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7226 write_matrix_variable_array_to_buffer(var
, data
, offset
, count
, TRUE
);
7231 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable
*iface
,
7232 float *data
, UINT offset
, UINT count
)
7234 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7236 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7237 read_matrix_variable_array_from_buffer(var
, data
, offset
, count
, TRUE
);
7243 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl
=
7245 /* ID3D10EffectVariable methods */
7246 d3d10_effect_matrix_variable_IsValid
,
7247 d3d10_effect_matrix_variable_GetType
,
7248 d3d10_effect_matrix_variable_GetDesc
,
7249 d3d10_effect_matrix_variable_GetAnnotationByIndex
,
7250 d3d10_effect_matrix_variable_GetAnnotationByName
,
7251 d3d10_effect_matrix_variable_GetMemberByIndex
,
7252 d3d10_effect_matrix_variable_GetMemberByName
,
7253 d3d10_effect_matrix_variable_GetMemberBySemantic
,
7254 d3d10_effect_matrix_variable_GetElement
,
7255 d3d10_effect_matrix_variable_GetParentConstantBuffer
,
7256 d3d10_effect_matrix_variable_AsScalar
,
7257 d3d10_effect_matrix_variable_AsVector
,
7258 d3d10_effect_matrix_variable_AsMatrix
,
7259 d3d10_effect_matrix_variable_AsString
,
7260 d3d10_effect_matrix_variable_AsShaderResource
,
7261 d3d10_effect_matrix_variable_AsRenderTargetView
,
7262 d3d10_effect_matrix_variable_AsDepthStencilView
,
7263 d3d10_effect_matrix_variable_AsConstantBuffer
,
7264 d3d10_effect_matrix_variable_AsShader
,
7265 d3d10_effect_matrix_variable_AsBlend
,
7266 d3d10_effect_matrix_variable_AsDepthStencil
,
7267 d3d10_effect_matrix_variable_AsRasterizer
,
7268 d3d10_effect_matrix_variable_AsSampler
,
7269 d3d10_effect_matrix_variable_SetRawValue
,
7270 d3d10_effect_matrix_variable_GetRawValue
,
7271 /* ID3D10EffectMatrixVariable methods */
7272 d3d10_effect_matrix_variable_SetMatrix
,
7273 d3d10_effect_matrix_variable_GetMatrix
,
7274 d3d10_effect_matrix_variable_SetMatrixArray
,
7275 d3d10_effect_matrix_variable_GetMatrixArray
,
7276 d3d10_effect_matrix_variable_SetMatrixTranspose
,
7277 d3d10_effect_matrix_variable_GetMatrixTranspose
,
7278 d3d10_effect_matrix_variable_SetMatrixTransposeArray
,
7279 d3d10_effect_matrix_variable_GetMatrixTransposeArray
,
7282 /* ID3D10EffectVariable methods */
7284 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectStringVariable(ID3D10EffectStringVariable
*iface
)
7286 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7289 static BOOL STDMETHODCALLTYPE
d3d10_effect_string_variable_IsValid(ID3D10EffectStringVariable
*iface
)
7291 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectStringVariable(iface
);
7293 TRACE("iface %p\n", iface
);
7295 return v
!= &null_string_variable
;
7298 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetType(
7299 ID3D10EffectStringVariable
*iface
)
7301 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7304 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetDesc(ID3D10EffectStringVariable
*iface
,
7305 D3D10_EFFECT_VARIABLE_DESC
*desc
)
7307 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7310 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetAnnotationByIndex(
7311 ID3D10EffectStringVariable
*iface
, UINT index
)
7313 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7316 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetAnnotationByName(
7317 ID3D10EffectStringVariable
*iface
, const char *name
)
7319 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7322 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetMemberByIndex(
7323 ID3D10EffectStringVariable
*iface
, UINT index
)
7325 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7328 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetMemberByName(
7329 ID3D10EffectStringVariable
*iface
, const char *name
)
7331 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7334 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetMemberBySemantic(
7335 ID3D10EffectStringVariable
*iface
, const char *semantic
)
7337 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7340 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetElement(
7341 ID3D10EffectStringVariable
*iface
, UINT index
)
7343 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7346 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetParentConstantBuffer(
7347 ID3D10EffectStringVariable
*iface
)
7349 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7352 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsScalar(
7353 ID3D10EffectStringVariable
*iface
)
7355 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7358 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsVector(
7359 ID3D10EffectStringVariable
*iface
)
7361 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7364 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsMatrix(
7365 ID3D10EffectStringVariable
*iface
)
7367 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7370 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsString(
7371 ID3D10EffectStringVariable
*iface
)
7373 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7376 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsShaderResource(
7377 ID3D10EffectStringVariable
*iface
)
7379 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7382 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsRenderTargetView(
7383 ID3D10EffectStringVariable
*iface
)
7385 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7388 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsDepthStencilView(
7389 ID3D10EffectStringVariable
*iface
)
7391 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7394 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsConstantBuffer(
7395 ID3D10EffectStringVariable
*iface
)
7397 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7400 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsShader(
7401 ID3D10EffectStringVariable
*iface
)
7403 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7406 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsBlend(
7407 ID3D10EffectStringVariable
*iface
)
7409 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7412 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsDepthStencil(
7413 ID3D10EffectStringVariable
*iface
)
7415 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7418 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsRasterizer(
7419 ID3D10EffectStringVariable
*iface
)
7421 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7424 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsSampler(
7425 ID3D10EffectStringVariable
*iface
)
7427 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7430 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_SetRawValue(ID3D10EffectStringVariable
*iface
,
7431 void *data
, UINT offset
, UINT count
)
7433 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7436 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetRawValue(ID3D10EffectStringVariable
*iface
,
7437 void *data
, UINT offset
, UINT count
)
7439 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7442 /* ID3D10EffectStringVariable methods */
7444 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetString(ID3D10EffectStringVariable
*iface
,
7447 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectStringVariable(iface
);
7448 char *value
= (char *)var
->u
.buffer
.local_buffer
;
7450 TRACE("iface %p, str %p.\n", iface
, str
);
7456 return E_INVALIDARG
;
7463 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetStringArray(ID3D10EffectStringVariable
*iface
,
7464 const char **strs
, UINT offset
, UINT count
)
7466 FIXME("iface %p, strs %p, offset %u, count %u stub!\n", iface
, strs
, offset
, count
);
7472 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl
=
7474 /* ID3D10EffectVariable methods */
7475 d3d10_effect_string_variable_IsValid
,
7476 d3d10_effect_string_variable_GetType
,
7477 d3d10_effect_string_variable_GetDesc
,
7478 d3d10_effect_string_variable_GetAnnotationByIndex
,
7479 d3d10_effect_string_variable_GetAnnotationByName
,
7480 d3d10_effect_string_variable_GetMemberByIndex
,
7481 d3d10_effect_string_variable_GetMemberByName
,
7482 d3d10_effect_string_variable_GetMemberBySemantic
,
7483 d3d10_effect_string_variable_GetElement
,
7484 d3d10_effect_string_variable_GetParentConstantBuffer
,
7485 d3d10_effect_string_variable_AsScalar
,
7486 d3d10_effect_string_variable_AsVector
,
7487 d3d10_effect_string_variable_AsMatrix
,
7488 d3d10_effect_string_variable_AsString
,
7489 d3d10_effect_string_variable_AsShaderResource
,
7490 d3d10_effect_string_variable_AsRenderTargetView
,
7491 d3d10_effect_string_variable_AsDepthStencilView
,
7492 d3d10_effect_string_variable_AsConstantBuffer
,
7493 d3d10_effect_string_variable_AsShader
,
7494 d3d10_effect_string_variable_AsBlend
,
7495 d3d10_effect_string_variable_AsDepthStencil
,
7496 d3d10_effect_string_variable_AsRasterizer
,
7497 d3d10_effect_string_variable_AsSampler
,
7498 d3d10_effect_string_variable_SetRawValue
,
7499 d3d10_effect_string_variable_GetRawValue
,
7500 /* ID3D10EffectStringVariable methods */
7501 d3d10_effect_string_variable_GetString
,
7502 d3d10_effect_string_variable_GetStringArray
,
7505 static void set_shader_resource_variable(ID3D10ShaderResourceView
**src
, ID3D10ShaderResourceView
**dst
)
7511 ID3D10ShaderResourceView_AddRef(*src
);
7513 ID3D10ShaderResourceView_Release(*dst
);
7518 /* ID3D10EffectVariable methods */
7520 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectShaderResourceVariable(
7521 ID3D10EffectShaderResourceVariable
*iface
)
7523 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7526 static BOOL STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_IsValid(ID3D10EffectShaderResourceVariable
*iface
)
7528 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderResourceVariable(iface
);
7530 TRACE("iface %p.\n", iface
);
7532 return v
!= &null_shader_resource_variable
;
7535 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetType(
7536 ID3D10EffectShaderResourceVariable
*iface
)
7538 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7541 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetDesc(
7542 ID3D10EffectShaderResourceVariable
*iface
, D3D10_EFFECT_VARIABLE_DESC
*desc
)
7544 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7547 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetAnnotationByIndex(
7548 ID3D10EffectShaderResourceVariable
*iface
, UINT index
)
7550 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7553 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetAnnotationByName(
7554 ID3D10EffectShaderResourceVariable
*iface
, const char *name
)
7556 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7559 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetMemberByIndex(
7560 ID3D10EffectShaderResourceVariable
*iface
, UINT index
)
7562 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7565 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetMemberByName(
7566 ID3D10EffectShaderResourceVariable
*iface
, const char *name
)
7568 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7571 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetMemberBySemantic(
7572 ID3D10EffectShaderResourceVariable
*iface
, const char *semantic
)
7574 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7577 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetElement(
7578 ID3D10EffectShaderResourceVariable
*iface
, UINT index
)
7580 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7583 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetParentConstantBuffer(
7584 ID3D10EffectShaderResourceVariable
*iface
)
7586 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7589 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsScalar(
7590 ID3D10EffectShaderResourceVariable
*iface
)
7592 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7595 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsVector(
7596 ID3D10EffectShaderResourceVariable
*iface
)
7598 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7601 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsMatrix(
7602 ID3D10EffectShaderResourceVariable
*iface
)
7604 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7607 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsString(
7608 ID3D10EffectShaderResourceVariable
*iface
)
7610 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7613 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsShaderResource(
7614 ID3D10EffectShaderResourceVariable
*iface
)
7616 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7619 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsRenderTargetView(
7620 ID3D10EffectShaderResourceVariable
*iface
)
7622 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7625 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsDepthStencilView(
7626 ID3D10EffectShaderResourceVariable
*iface
)
7628 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7631 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsConstantBuffer(
7632 ID3D10EffectShaderResourceVariable
*iface
)
7634 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7637 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsShader(
7638 ID3D10EffectShaderResourceVariable
*iface
)
7640 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7643 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsBlend(
7644 ID3D10EffectShaderResourceVariable
*iface
)
7646 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7649 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsDepthStencil(
7650 ID3D10EffectShaderResourceVariable
*iface
)
7652 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7655 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsRasterizer(
7656 ID3D10EffectShaderResourceVariable
*iface
)
7658 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7661 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsSampler(
7662 ID3D10EffectShaderResourceVariable
*iface
)
7664 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7667 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_SetRawValue(
7668 ID3D10EffectShaderResourceVariable
*iface
, void *data
, UINT offset
, UINT count
)
7670 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7673 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetRawValue(
7674 ID3D10EffectShaderResourceVariable
*iface
, void *data
, UINT offset
, UINT count
)
7676 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7679 /* ID3D10EffectShaderResourceVariable methods */
7681 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_SetResource(
7682 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
*resource
)
7684 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderResourceVariable(iface
);
7686 TRACE("iface %p, resource %p.\n", iface
, resource
);
7688 if (!d3d10_effect_shader_resource_variable_IsValid(iface
))
7691 set_shader_resource_variable(&resource
, v
->u
.resource
.srv
);
7696 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetResource(
7697 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
**resource
)
7699 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
7704 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_SetResourceArray(
7705 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
**resources
, UINT offset
, UINT count
)
7707 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderResourceVariable(iface
);
7708 ID3D10ShaderResourceView
**rsrc_view
;
7711 TRACE("iface %p, resources %p, offset %u, count %u.\n", iface
, resources
, offset
, count
);
7713 if (!v
->type
->element_count
)
7714 return d3d10_effect_shader_resource_variable_SetResource(iface
, *resources
);
7716 if (offset
>= v
->type
->element_count
)
7718 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, v
->type
->element_count
);
7722 if (count
> v
->type
->element_count
- offset
)
7724 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
7725 offset
, count
, v
->type
->element_count
);
7726 count
= v
->type
->element_count
- offset
;
7729 rsrc_view
= &v
->u
.resource
.srv
[offset
];
7730 for (i
= 0; i
< count
; ++i
)
7731 set_shader_resource_variable(&resources
[i
], &rsrc_view
[i
]);
7736 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetResourceArray(
7737 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
**resources
, UINT offset
, UINT count
)
7739 FIXME("iface %p, resources %p, offset %u, count %u stub!\n", iface
, resources
, offset
, count
);
7745 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl
=
7747 /* ID3D10EffectVariable methods */
7748 d3d10_effect_shader_resource_variable_IsValid
,
7749 d3d10_effect_shader_resource_variable_GetType
,
7750 d3d10_effect_shader_resource_variable_GetDesc
,
7751 d3d10_effect_shader_resource_variable_GetAnnotationByIndex
,
7752 d3d10_effect_shader_resource_variable_GetAnnotationByName
,
7753 d3d10_effect_shader_resource_variable_GetMemberByIndex
,
7754 d3d10_effect_shader_resource_variable_GetMemberByName
,
7755 d3d10_effect_shader_resource_variable_GetMemberBySemantic
,
7756 d3d10_effect_shader_resource_variable_GetElement
,
7757 d3d10_effect_shader_resource_variable_GetParentConstantBuffer
,
7758 d3d10_effect_shader_resource_variable_AsScalar
,
7759 d3d10_effect_shader_resource_variable_AsVector
,
7760 d3d10_effect_shader_resource_variable_AsMatrix
,
7761 d3d10_effect_shader_resource_variable_AsString
,
7762 d3d10_effect_shader_resource_variable_AsShaderResource
,
7763 d3d10_effect_shader_resource_variable_AsRenderTargetView
,
7764 d3d10_effect_shader_resource_variable_AsDepthStencilView
,
7765 d3d10_effect_shader_resource_variable_AsConstantBuffer
,
7766 d3d10_effect_shader_resource_variable_AsShader
,
7767 d3d10_effect_shader_resource_variable_AsBlend
,
7768 d3d10_effect_shader_resource_variable_AsDepthStencil
,
7769 d3d10_effect_shader_resource_variable_AsRasterizer
,
7770 d3d10_effect_shader_resource_variable_AsSampler
,
7771 d3d10_effect_shader_resource_variable_SetRawValue
,
7772 d3d10_effect_shader_resource_variable_GetRawValue
,
7773 /* ID3D10EffectShaderResourceVariable methods */
7774 d3d10_effect_shader_resource_variable_SetResource
,
7775 d3d10_effect_shader_resource_variable_GetResource
,
7776 d3d10_effect_shader_resource_variable_SetResourceArray
,
7777 d3d10_effect_shader_resource_variable_GetResourceArray
,
7780 /* ID3D10EffectVariable methods */
7782 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectRenderTargetViewVariable(
7783 ID3D10EffectRenderTargetViewVariable
*iface
)
7785 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7788 static BOOL STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_IsValid(
7789 ID3D10EffectRenderTargetViewVariable
*iface
)
7791 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRenderTargetViewVariable(iface
);
7793 TRACE("iface %p\n", iface
);
7795 return v
!= &null_render_target_view_variable
;
7798 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetType(
7799 ID3D10EffectRenderTargetViewVariable
*iface
)
7801 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7804 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetDesc(
7805 ID3D10EffectRenderTargetViewVariable
*iface
, D3D10_EFFECT_VARIABLE_DESC
*desc
)
7807 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7810 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetAnnotationByIndex(
7811 ID3D10EffectRenderTargetViewVariable
*iface
, UINT index
)
7813 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7816 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetAnnotationByName(
7817 ID3D10EffectRenderTargetViewVariable
*iface
, const char *name
)
7819 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7822 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetMemberByIndex(
7823 ID3D10EffectRenderTargetViewVariable
*iface
, UINT index
)
7825 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7828 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetMemberByName(
7829 ID3D10EffectRenderTargetViewVariable
*iface
, const char *name
)
7831 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7834 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetMemberBySemantic(
7835 ID3D10EffectRenderTargetViewVariable
*iface
, const char *semantic
)
7837 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7840 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetElement(
7841 ID3D10EffectRenderTargetViewVariable
*iface
, UINT index
)
7843 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7846 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetParentConstantBuffer(
7847 ID3D10EffectRenderTargetViewVariable
*iface
)
7849 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7852 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsScalar(
7853 ID3D10EffectRenderTargetViewVariable
*iface
)
7855 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7858 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsVector(
7859 ID3D10EffectRenderTargetViewVariable
*iface
)
7861 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7864 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsMatrix(
7865 ID3D10EffectRenderTargetViewVariable
*iface
)
7867 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7870 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsString(
7871 ID3D10EffectRenderTargetViewVariable
*iface
)
7873 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7876 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsShaderResource(
7877 ID3D10EffectRenderTargetViewVariable
*iface
)
7879 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7882 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsRenderTargetView(
7883 ID3D10EffectRenderTargetViewVariable
*iface
)
7885 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7888 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsDepthStencilView(
7889 ID3D10EffectRenderTargetViewVariable
*iface
)
7891 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7894 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsConstantBuffer(
7895 ID3D10EffectRenderTargetViewVariable
*iface
)
7897 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7900 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsShader(
7901 ID3D10EffectRenderTargetViewVariable
*iface
)
7903 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7906 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsBlend(
7907 ID3D10EffectRenderTargetViewVariable
*iface
)
7909 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7912 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsDepthStencil(
7913 ID3D10EffectRenderTargetViewVariable
*iface
)
7915 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7918 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsRasterizer(
7919 ID3D10EffectRenderTargetViewVariable
*iface
)
7921 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7924 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsSampler(
7925 ID3D10EffectRenderTargetViewVariable
*iface
)
7927 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7930 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_SetRawValue(
7931 ID3D10EffectRenderTargetViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
7933 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7936 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetRawValue(
7937 ID3D10EffectRenderTargetViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
7939 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7942 /* ID3D10EffectRenderTargetViewVariable methods */
7944 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_SetRenderTarget(
7945 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
*view
)
7947 FIXME("iface %p, view %p stub!\n", iface
, view
);
7952 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetRenderTarget(
7953 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
**view
)
7955 FIXME("iface %p, view %p stub!\n", iface
, view
);
7960 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_SetRenderTargetArray(
7961 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
**views
, UINT offset
, UINT count
)
7963 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
7968 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetRenderTargetArray(
7969 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
**views
, UINT offset
, UINT count
)
7971 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
7977 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl
=
7979 /* ID3D10EffectVariable methods */
7980 d3d10_effect_render_target_view_variable_IsValid
,
7981 d3d10_effect_render_target_view_variable_GetType
,
7982 d3d10_effect_render_target_view_variable_GetDesc
,
7983 d3d10_effect_render_target_view_variable_GetAnnotationByIndex
,
7984 d3d10_effect_render_target_view_variable_GetAnnotationByName
,
7985 d3d10_effect_render_target_view_variable_GetMemberByIndex
,
7986 d3d10_effect_render_target_view_variable_GetMemberByName
,
7987 d3d10_effect_render_target_view_variable_GetMemberBySemantic
,
7988 d3d10_effect_render_target_view_variable_GetElement
,
7989 d3d10_effect_render_target_view_variable_GetParentConstantBuffer
,
7990 d3d10_effect_render_target_view_variable_AsScalar
,
7991 d3d10_effect_render_target_view_variable_AsVector
,
7992 d3d10_effect_render_target_view_variable_AsMatrix
,
7993 d3d10_effect_render_target_view_variable_AsString
,
7994 d3d10_effect_render_target_view_variable_AsShaderResource
,
7995 d3d10_effect_render_target_view_variable_AsRenderTargetView
,
7996 d3d10_effect_render_target_view_variable_AsDepthStencilView
,
7997 d3d10_effect_render_target_view_variable_AsConstantBuffer
,
7998 d3d10_effect_render_target_view_variable_AsShader
,
7999 d3d10_effect_render_target_view_variable_AsBlend
,
8000 d3d10_effect_render_target_view_variable_AsDepthStencil
,
8001 d3d10_effect_render_target_view_variable_AsRasterizer
,
8002 d3d10_effect_render_target_view_variable_AsSampler
,
8003 d3d10_effect_render_target_view_variable_SetRawValue
,
8004 d3d10_effect_render_target_view_variable_GetRawValue
,
8005 /* ID3D10EffectRenderTargetViewVariable methods */
8006 d3d10_effect_render_target_view_variable_SetRenderTarget
,
8007 d3d10_effect_render_target_view_variable_GetRenderTarget
,
8008 d3d10_effect_render_target_view_variable_SetRenderTargetArray
,
8009 d3d10_effect_render_target_view_variable_GetRenderTargetArray
,
8012 /* ID3D10EffectVariable methods */
8014 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectDepthStencilViewVariable(
8015 ID3D10EffectDepthStencilViewVariable
*iface
)
8017 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
8020 static BOOL STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_IsValid(
8021 ID3D10EffectDepthStencilViewVariable
*iface
)
8023 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilViewVariable(iface
);
8025 TRACE("iface %p\n", iface
);
8027 return v
!= &null_depth_stencil_view_variable
;
8030 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetType(
8031 ID3D10EffectDepthStencilViewVariable
*iface
)
8033 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8036 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetDesc(
8037 ID3D10EffectDepthStencilViewVariable
*iface
, D3D10_EFFECT_VARIABLE_DESC
*desc
)
8039 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8042 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex(
8043 ID3D10EffectDepthStencilViewVariable
*iface
, UINT index
)
8045 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8048 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetAnnotationByName(
8049 ID3D10EffectDepthStencilViewVariable
*iface
, const char *name
)
8051 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8054 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetMemberByIndex(
8055 ID3D10EffectDepthStencilViewVariable
*iface
, UINT index
)
8057 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8060 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetMemberByName(
8061 ID3D10EffectDepthStencilViewVariable
*iface
, const char *name
)
8063 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8066 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic(
8067 ID3D10EffectDepthStencilViewVariable
*iface
, const char *semantic
)
8069 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8072 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetElement(
8073 ID3D10EffectDepthStencilViewVariable
*iface
, UINT index
)
8075 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8078 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer(
8079 ID3D10EffectDepthStencilViewVariable
*iface
)
8081 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8084 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsScalar(
8085 ID3D10EffectDepthStencilViewVariable
*iface
)
8087 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8090 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsVector(
8091 ID3D10EffectDepthStencilViewVariable
*iface
)
8093 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8096 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsMatrix(
8097 ID3D10EffectDepthStencilViewVariable
*iface
)
8099 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8102 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsString(
8103 ID3D10EffectDepthStencilViewVariable
*iface
)
8105 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8108 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsShaderResource(
8109 ID3D10EffectDepthStencilViewVariable
*iface
)
8111 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8114 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsRenderTargetView(
8115 ID3D10EffectDepthStencilViewVariable
*iface
)
8117 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8120 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsDepthStencilView(
8121 ID3D10EffectDepthStencilViewVariable
*iface
)
8123 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8126 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsConstantBuffer(
8127 ID3D10EffectDepthStencilViewVariable
*iface
)
8129 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8132 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsShader(
8133 ID3D10EffectDepthStencilViewVariable
*iface
)
8135 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8138 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsBlend(
8139 ID3D10EffectDepthStencilViewVariable
*iface
)
8141 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8144 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsDepthStencil(
8145 ID3D10EffectDepthStencilViewVariable
*iface
)
8147 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8150 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsRasterizer(
8151 ID3D10EffectDepthStencilViewVariable
*iface
)
8153 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8156 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsSampler(
8157 ID3D10EffectDepthStencilViewVariable
*iface
)
8159 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8162 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_SetRawValue(
8163 ID3D10EffectDepthStencilViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
8165 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8168 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetRawValue(
8169 ID3D10EffectDepthStencilViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
8171 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8174 /* ID3D10EffectDepthStencilViewVariable methods */
8176 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_SetDepthStencil(
8177 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
*view
)
8179 FIXME("iface %p, view %p stub!\n", iface
, view
);
8184 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetDepthStencil(
8185 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
**view
)
8187 FIXME("iface %p, view %p stub!\n", iface
, view
);
8192 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray(
8193 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
**views
, UINT offset
, UINT count
)
8195 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
8200 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray(
8201 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
**views
, UINT offset
, UINT count
)
8203 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
8209 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl
=
8211 /* ID3D10EffectVariable methods */
8212 d3d10_effect_depth_stencil_view_variable_IsValid
,
8213 d3d10_effect_depth_stencil_view_variable_GetType
,
8214 d3d10_effect_depth_stencil_view_variable_GetDesc
,
8215 d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex
,
8216 d3d10_effect_depth_stencil_view_variable_GetAnnotationByName
,
8217 d3d10_effect_depth_stencil_view_variable_GetMemberByIndex
,
8218 d3d10_effect_depth_stencil_view_variable_GetMemberByName
,
8219 d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic
,
8220 d3d10_effect_depth_stencil_view_variable_GetElement
,
8221 d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer
,
8222 d3d10_effect_depth_stencil_view_variable_AsScalar
,
8223 d3d10_effect_depth_stencil_view_variable_AsVector
,
8224 d3d10_effect_depth_stencil_view_variable_AsMatrix
,
8225 d3d10_effect_depth_stencil_view_variable_AsString
,
8226 d3d10_effect_depth_stencil_view_variable_AsShaderResource
,
8227 d3d10_effect_depth_stencil_view_variable_AsRenderTargetView
,
8228 d3d10_effect_depth_stencil_view_variable_AsDepthStencilView
,
8229 d3d10_effect_depth_stencil_view_variable_AsConstantBuffer
,
8230 d3d10_effect_depth_stencil_view_variable_AsShader
,
8231 d3d10_effect_depth_stencil_view_variable_AsBlend
,
8232 d3d10_effect_depth_stencil_view_variable_AsDepthStencil
,
8233 d3d10_effect_depth_stencil_view_variable_AsRasterizer
,
8234 d3d10_effect_depth_stencil_view_variable_AsSampler
,
8235 d3d10_effect_depth_stencil_view_variable_SetRawValue
,
8236 d3d10_effect_depth_stencil_view_variable_GetRawValue
,
8237 /* ID3D10EffectDepthStencilViewVariable methods */
8238 d3d10_effect_depth_stencil_view_variable_SetDepthStencil
,
8239 d3d10_effect_depth_stencil_view_variable_GetDepthStencil
,
8240 d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray
,
8241 d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray
,
8244 /* ID3D10EffectVariable methods */
8246 static BOOL STDMETHODCALLTYPE
d3d10_effect_shader_variable_IsValid(ID3D10EffectShaderVariable
*iface
)
8248 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8250 TRACE("iface %p\n", iface
);
8252 return v
!= &null_shader_variable
;
8255 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetType(
8256 ID3D10EffectShaderVariable
*iface
)
8258 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8261 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetDesc(ID3D10EffectShaderVariable
*iface
,
8262 D3D10_EFFECT_VARIABLE_DESC
*desc
)
8264 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8267 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetAnnotationByIndex(
8268 ID3D10EffectShaderVariable
*iface
, UINT index
)
8270 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8273 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetAnnotationByName(
8274 ID3D10EffectShaderVariable
*iface
, const char *name
)
8276 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8279 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetMemberByIndex(
8280 ID3D10EffectShaderVariable
*iface
, UINT index
)
8282 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8285 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetMemberByName(
8286 ID3D10EffectShaderVariable
*iface
, const char *name
)
8288 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8291 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetMemberBySemantic(
8292 ID3D10EffectShaderVariable
*iface
, const char *semantic
)
8294 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8297 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetElement(
8298 ID3D10EffectShaderVariable
*iface
, UINT index
)
8300 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8303 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetParentConstantBuffer(
8304 ID3D10EffectShaderVariable
*iface
)
8306 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8309 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsScalar(
8310 ID3D10EffectShaderVariable
*iface
)
8312 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8315 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsVector(
8316 ID3D10EffectShaderVariable
*iface
)
8318 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8321 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsMatrix(
8322 ID3D10EffectShaderVariable
*iface
)
8324 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8327 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsString(
8328 ID3D10EffectShaderVariable
*iface
)
8330 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8333 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsShaderResource(
8334 ID3D10EffectShaderVariable
*iface
)
8336 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8339 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsRenderTargetView(
8340 ID3D10EffectShaderVariable
*iface
)
8342 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8345 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsDepthStencilView(
8346 ID3D10EffectShaderVariable
*iface
)
8348 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8351 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsConstantBuffer(
8352 ID3D10EffectShaderVariable
*iface
)
8354 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8357 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsShader(
8358 ID3D10EffectShaderVariable
*iface
)
8360 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8363 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsBlend(
8364 ID3D10EffectShaderVariable
*iface
)
8366 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8369 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsDepthStencil(
8370 ID3D10EffectShaderVariable
*iface
)
8372 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8375 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsRasterizer(
8376 ID3D10EffectShaderVariable
*iface
)
8378 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8381 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsSampler(
8382 ID3D10EffectShaderVariable
*iface
)
8384 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8387 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_SetRawValue(
8388 ID3D10EffectShaderVariable
*iface
, void *data
, UINT offset
, UINT count
)
8390 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8393 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetRawValue(
8394 ID3D10EffectShaderVariable
*iface
, void *data
, UINT offset
, UINT count
)
8396 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8399 /* ID3D10EffectShaderVariable methods */
8401 static HRESULT
d3d10_get_shader_variable(struct d3d10_effect_variable
*v
, UINT shader_index
,
8402 struct d3d10_effect_shader_variable
**s
, D3D10_SHADER_VARIABLE_TYPE
*basetype
)
8406 v
= d3d10_array_get_element(v
, 0);
8411 if (basetype
) *basetype
= v
->type
->basetype
;
8415 /* Index is used as an offset from this variable. */
8417 for (i
= 0; i
< v
->effect
->shaders
.count
; ++i
)
8419 if (v
== v
->effect
->shaders
.v
[i
]) break;
8422 if (i
+ shader_index
>= v
->effect
->shaders
.count
)
8424 WARN("Invalid shader index %u.\n", shader_index
);
8428 *s
= &v
->effect
->shaders
.v
[i
+ shader_index
]->u
.shader
;
8429 if (basetype
) *basetype
= v
->effect
->shaders
.v
[i
+ shader_index
]->type
->basetype
;
8434 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetShaderDesc(
8435 ID3D10EffectShaderVariable
*iface
, UINT index
, D3D10_EFFECT_SHADER_DESC
*desc
)
8437 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8438 struct d3d10_effect_shader_variable
*s
;
8439 D3D10_SHADER_DESC shader_desc
;
8442 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
8444 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, NULL
)))
8447 memset(desc
, 0, sizeof(*desc
));
8448 if (s
->input_signature
)
8449 desc
->pInputSignature
= ID3D10Blob_GetBufferPointer(s
->input_signature
);
8450 desc
->SODecl
= s
->stream_output_declaration
;
8451 desc
->IsInline
= s
->isinline
;
8454 desc
->pBytecode
= ID3D10Blob_GetBufferPointer(s
->bytecode
);
8455 desc
->BytecodeLength
= ID3D10Blob_GetBufferSize(s
->bytecode
);
8459 if (SUCCEEDED(hr
= s
->reflection
->lpVtbl
->GetDesc(s
->reflection
, &shader_desc
)))
8461 desc
->NumInputSignatureEntries
= shader_desc
.InputParameters
;
8462 desc
->NumOutputSignatureEntries
= shader_desc
.OutputParameters
;
8469 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetVertexShader(
8470 ID3D10EffectShaderVariable
*iface
, UINT index
, ID3D10VertexShader
**shader
)
8472 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8473 struct d3d10_effect_shader_variable
*s
;
8474 D3D10_SHADER_VARIABLE_TYPE basetype
;
8477 TRACE("iface %p, index %u, shader %p.\n", iface
, index
, shader
);
8481 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, &basetype
)))
8484 if (basetype
!= D3D10_SVT_VERTEXSHADER
)
8486 WARN("Shader is not a vertex shader.\n");
8487 return D3DERR_INVALIDCALL
;
8490 if ((*shader
= s
->shader
.vs
))
8491 ID3D10VertexShader_AddRef(*shader
);
8496 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetGeometryShader(
8497 ID3D10EffectShaderVariable
*iface
, UINT index
, ID3D10GeometryShader
**shader
)
8499 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8500 struct d3d10_effect_shader_variable
*s
;
8501 D3D10_SHADER_VARIABLE_TYPE basetype
;
8504 TRACE("iface %p, index %u, shader %p.\n", iface
, index
, shader
);
8508 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, &basetype
)))
8511 if (basetype
!= D3D10_SVT_GEOMETRYSHADER
)
8513 WARN("Shader is not a geometry shader.\n");
8514 return D3DERR_INVALIDCALL
;
8517 if ((*shader
= s
->shader
.gs
))
8518 ID3D10GeometryShader_AddRef(*shader
);
8523 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetPixelShader(
8524 ID3D10EffectShaderVariable
*iface
, UINT index
, ID3D10PixelShader
**shader
)
8526 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8527 struct d3d10_effect_shader_variable
*s
;
8528 D3D10_SHADER_VARIABLE_TYPE basetype
;
8531 TRACE("iface %p, index %u, shader %p.\n", iface
, index
, shader
);
8535 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, &basetype
)))
8538 if (basetype
!= D3D10_SVT_PIXELSHADER
)
8540 WARN("Shader is not a pixel shader.\n");
8541 return D3DERR_INVALIDCALL
;
8544 if ((*shader
= s
->shader
.ps
))
8545 ID3D10PixelShader_AddRef(*shader
);
8550 static HRESULT
d3d10_get_shader_variable_signature(struct d3d10_effect_variable
*v
,
8551 UINT shader_index
, UINT element_index
, BOOL output
, D3D10_SIGNATURE_PARAMETER_DESC
*desc
)
8553 struct d3d10_effect_shader_variable
*s
;
8556 if (FAILED(hr
= d3d10_get_shader_variable(v
, shader_index
, &s
, NULL
)))
8560 return D3DERR_INVALIDCALL
;
8563 return s
->reflection
->lpVtbl
->GetOutputParameterDesc(s
->reflection
, element_index
, desc
);
8565 return s
->reflection
->lpVtbl
->GetInputParameterDesc(s
->reflection
, element_index
, desc
);
8568 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetInputSignatureElementDesc(
8569 ID3D10EffectShaderVariable
*iface
, UINT shader_index
, UINT element_index
,
8570 D3D10_SIGNATURE_PARAMETER_DESC
*desc
)
8572 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8574 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
8575 iface
, shader_index
, element_index
, desc
);
8577 if (!iface
->lpVtbl
->IsValid(iface
))
8579 WARN("Null variable specified\n");
8583 return d3d10_get_shader_variable_signature(v
, shader_index
, element_index
, FALSE
, desc
);
8586 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetOutputSignatureElementDesc(
8587 ID3D10EffectShaderVariable
*iface
, UINT shader_index
, UINT element_index
,
8588 D3D10_SIGNATURE_PARAMETER_DESC
*desc
)
8590 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8592 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
8593 iface
, shader_index
, element_index
, desc
);
8595 if (!iface
->lpVtbl
->IsValid(iface
))
8597 WARN("Null variable specified\n");
8601 return d3d10_get_shader_variable_signature(v
, shader_index
, element_index
, TRUE
, desc
);
8605 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl
=
8607 /* ID3D10EffectVariable methods */
8608 d3d10_effect_shader_variable_IsValid
,
8609 d3d10_effect_shader_variable_GetType
,
8610 d3d10_effect_shader_variable_GetDesc
,
8611 d3d10_effect_shader_variable_GetAnnotationByIndex
,
8612 d3d10_effect_shader_variable_GetAnnotationByName
,
8613 d3d10_effect_shader_variable_GetMemberByIndex
,
8614 d3d10_effect_shader_variable_GetMemberByName
,
8615 d3d10_effect_shader_variable_GetMemberBySemantic
,
8616 d3d10_effect_shader_variable_GetElement
,
8617 d3d10_effect_shader_variable_GetParentConstantBuffer
,
8618 d3d10_effect_shader_variable_AsScalar
,
8619 d3d10_effect_shader_variable_AsVector
,
8620 d3d10_effect_shader_variable_AsMatrix
,
8621 d3d10_effect_shader_variable_AsString
,
8622 d3d10_effect_shader_variable_AsShaderResource
,
8623 d3d10_effect_shader_variable_AsRenderTargetView
,
8624 d3d10_effect_shader_variable_AsDepthStencilView
,
8625 d3d10_effect_shader_variable_AsConstantBuffer
,
8626 d3d10_effect_shader_variable_AsShader
,
8627 d3d10_effect_shader_variable_AsBlend
,
8628 d3d10_effect_shader_variable_AsDepthStencil
,
8629 d3d10_effect_shader_variable_AsRasterizer
,
8630 d3d10_effect_shader_variable_AsSampler
,
8631 d3d10_effect_shader_variable_SetRawValue
,
8632 d3d10_effect_shader_variable_GetRawValue
,
8633 /* ID3D10EffectShaderVariable methods */
8634 d3d10_effect_shader_variable_GetShaderDesc
,
8635 d3d10_effect_shader_variable_GetVertexShader
,
8636 d3d10_effect_shader_variable_GetGeometryShader
,
8637 d3d10_effect_shader_variable_GetPixelShader
,
8638 d3d10_effect_shader_variable_GetInputSignatureElementDesc
,
8639 d3d10_effect_shader_variable_GetOutputSignatureElementDesc
,
8642 /* ID3D10EffectVariable methods */
8644 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectBlendVariable(
8645 ID3D10EffectBlendVariable
*iface
)
8647 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
8650 static BOOL STDMETHODCALLTYPE
d3d10_effect_blend_variable_IsValid(ID3D10EffectBlendVariable
*iface
)
8652 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectBlendVariable(iface
);
8654 TRACE("iface %p\n", iface
);
8656 return v
!= &null_blend_variable
;
8659 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetType(
8660 ID3D10EffectBlendVariable
*iface
)
8662 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8665 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetDesc(ID3D10EffectBlendVariable
*iface
,
8666 D3D10_EFFECT_VARIABLE_DESC
*desc
)
8668 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8671 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetAnnotationByIndex(
8672 ID3D10EffectBlendVariable
*iface
, UINT index
)
8674 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8677 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetAnnotationByName(
8678 ID3D10EffectBlendVariable
*iface
, const char *name
)
8680 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8683 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetMemberByIndex(
8684 ID3D10EffectBlendVariable
*iface
, UINT index
)
8686 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8689 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetMemberByName(
8690 ID3D10EffectBlendVariable
*iface
, const char *name
)
8692 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8695 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetMemberBySemantic(
8696 ID3D10EffectBlendVariable
*iface
, const char *semantic
)
8698 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8701 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetElement(
8702 ID3D10EffectBlendVariable
*iface
, UINT index
)
8704 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8707 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetParentConstantBuffer(
8708 ID3D10EffectBlendVariable
*iface
)
8710 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8713 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsScalar(
8714 ID3D10EffectBlendVariable
*iface
)
8716 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8719 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsVector(
8720 ID3D10EffectBlendVariable
*iface
)
8722 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8725 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsMatrix(
8726 ID3D10EffectBlendVariable
*iface
)
8728 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8731 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsString(
8732 ID3D10EffectBlendVariable
*iface
)
8734 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8737 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsShaderResource(
8738 ID3D10EffectBlendVariable
*iface
)
8740 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8743 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsRenderTargetView(
8744 ID3D10EffectBlendVariable
*iface
)
8746 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8749 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsDepthStencilView(
8750 ID3D10EffectBlendVariable
*iface
)
8752 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8755 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsConstantBuffer(
8756 ID3D10EffectBlendVariable
*iface
)
8758 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8761 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsShader(
8762 ID3D10EffectBlendVariable
*iface
)
8764 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8767 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsBlend(
8768 ID3D10EffectBlendVariable
*iface
)
8770 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8773 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsDepthStencil(
8774 ID3D10EffectBlendVariable
*iface
)
8776 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8779 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsRasterizer(
8780 ID3D10EffectBlendVariable
*iface
)
8782 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8785 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsSampler(
8786 ID3D10EffectBlendVariable
*iface
)
8788 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8791 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_SetRawValue(ID3D10EffectBlendVariable
*iface
,
8792 void *data
, UINT offset
, UINT count
)
8794 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8797 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetRawValue(ID3D10EffectBlendVariable
*iface
,
8798 void *data
, UINT offset
, UINT count
)
8800 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8803 /* ID3D10EffectBlendVariable methods */
8805 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetBlendState(ID3D10EffectBlendVariable
*iface
,
8806 UINT index
, ID3D10BlendState
**blend_state
)
8808 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectBlendVariable(iface
);
8810 TRACE("iface %p, index %u, blend_state %p.\n", iface
, index
, blend_state
);
8812 if (!iface
->lpVtbl
->IsValid(iface
))
8814 WARN("Invalid variable.\n");
8818 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->blend_states
)))
8821 if ((*blend_state
= v
->u
.state
.object
.blend
))
8822 ID3D10BlendState_AddRef(*blend_state
);
8827 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetBackingStore(ID3D10EffectBlendVariable
*iface
,
8828 UINT index
, D3D10_BLEND_DESC
*desc
)
8830 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectBlendVariable(iface
);
8832 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
8834 if (!iface
->lpVtbl
->IsValid(iface
))
8836 WARN("Invalid variable.\n");
8840 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->blend_states
)))
8843 *desc
= v
->u
.state
.desc
.blend
;
8848 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl
=
8850 /* ID3D10EffectVariable methods */
8851 d3d10_effect_blend_variable_IsValid
,
8852 d3d10_effect_blend_variable_GetType
,
8853 d3d10_effect_blend_variable_GetDesc
,
8854 d3d10_effect_blend_variable_GetAnnotationByIndex
,
8855 d3d10_effect_blend_variable_GetAnnotationByName
,
8856 d3d10_effect_blend_variable_GetMemberByIndex
,
8857 d3d10_effect_blend_variable_GetMemberByName
,
8858 d3d10_effect_blend_variable_GetMemberBySemantic
,
8859 d3d10_effect_blend_variable_GetElement
,
8860 d3d10_effect_blend_variable_GetParentConstantBuffer
,
8861 d3d10_effect_blend_variable_AsScalar
,
8862 d3d10_effect_blend_variable_AsVector
,
8863 d3d10_effect_blend_variable_AsMatrix
,
8864 d3d10_effect_blend_variable_AsString
,
8865 d3d10_effect_blend_variable_AsShaderResource
,
8866 d3d10_effect_blend_variable_AsRenderTargetView
,
8867 d3d10_effect_blend_variable_AsDepthStencilView
,
8868 d3d10_effect_blend_variable_AsConstantBuffer
,
8869 d3d10_effect_blend_variable_AsShader
,
8870 d3d10_effect_blend_variable_AsBlend
,
8871 d3d10_effect_blend_variable_AsDepthStencil
,
8872 d3d10_effect_blend_variable_AsRasterizer
,
8873 d3d10_effect_blend_variable_AsSampler
,
8874 d3d10_effect_blend_variable_SetRawValue
,
8875 d3d10_effect_blend_variable_GetRawValue
,
8876 /* ID3D10EffectBlendVariable methods */
8877 d3d10_effect_blend_variable_GetBlendState
,
8878 d3d10_effect_blend_variable_GetBackingStore
,
8881 /* ID3D10EffectVariable methods */
8883 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectDepthStencilVariable(
8884 ID3D10EffectDepthStencilVariable
*iface
)
8886 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
8889 static BOOL STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_IsValid(ID3D10EffectDepthStencilVariable
*iface
)
8891 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilVariable(iface
);
8893 TRACE("iface %p\n", iface
);
8895 return v
!= &null_depth_stencil_variable
;
8898 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetType(
8899 ID3D10EffectDepthStencilVariable
*iface
)
8901 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8904 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetDesc(ID3D10EffectDepthStencilVariable
*iface
,
8905 D3D10_EFFECT_VARIABLE_DESC
*desc
)
8907 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8910 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetAnnotationByIndex(
8911 ID3D10EffectDepthStencilVariable
*iface
, UINT index
)
8913 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8916 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetAnnotationByName(
8917 ID3D10EffectDepthStencilVariable
*iface
, const char *name
)
8919 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8922 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetMemberByIndex(
8923 ID3D10EffectDepthStencilVariable
*iface
, UINT index
)
8925 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8928 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetMemberByName(
8929 ID3D10EffectDepthStencilVariable
*iface
, const char *name
)
8931 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8934 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetMemberBySemantic(
8935 ID3D10EffectDepthStencilVariable
*iface
, const char *semantic
)
8937 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8940 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetElement(
8941 ID3D10EffectDepthStencilVariable
*iface
, UINT index
)
8943 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8946 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetParentConstantBuffer(
8947 ID3D10EffectDepthStencilVariable
*iface
)
8949 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8952 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsScalar(
8953 ID3D10EffectDepthStencilVariable
*iface
)
8955 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8958 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsVector(
8959 ID3D10EffectDepthStencilVariable
*iface
)
8961 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8964 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsMatrix(
8965 ID3D10EffectDepthStencilVariable
*iface
)
8967 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8970 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsString(
8971 ID3D10EffectDepthStencilVariable
*iface
)
8973 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8976 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsShaderResource(
8977 ID3D10EffectDepthStencilVariable
*iface
)
8979 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8982 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsRenderTargetView(
8983 ID3D10EffectDepthStencilVariable
*iface
)
8985 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8988 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsDepthStencilView(
8989 ID3D10EffectDepthStencilVariable
*iface
)
8991 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8994 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsConstantBuffer(
8995 ID3D10EffectDepthStencilVariable
*iface
)
8997 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
9000 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsShader(
9001 ID3D10EffectDepthStencilVariable
*iface
)
9003 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
9006 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsBlend(
9007 ID3D10EffectDepthStencilVariable
*iface
)
9009 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
9012 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsDepthStencil(
9013 ID3D10EffectDepthStencilVariable
*iface
)
9015 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
9018 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsRasterizer(
9019 ID3D10EffectDepthStencilVariable
*iface
)
9021 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
9024 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsSampler(
9025 ID3D10EffectDepthStencilVariable
*iface
)
9027 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
9030 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_SetRawValue(ID3D10EffectDepthStencilVariable
*iface
,
9031 void *data
, UINT offset
, UINT count
)
9033 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9036 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetRawValue(ID3D10EffectDepthStencilVariable
*iface
,
9037 void *data
, UINT offset
, UINT count
)
9039 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9042 /* ID3D10EffectDepthStencilVariable methods */
9044 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetDepthStencilState(ID3D10EffectDepthStencilVariable
*iface
,
9045 UINT index
, ID3D10DepthStencilState
**depth_stencil_state
)
9047 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilVariable(iface
);
9049 TRACE("iface %p, index %u, depth_stencil_state %p.\n", iface
, index
, depth_stencil_state
);
9051 if (!iface
->lpVtbl
->IsValid(iface
))
9053 WARN("Invalid variable.\n");
9057 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->ds_states
)))
9060 if ((*depth_stencil_state
= v
->u
.state
.object
.depth_stencil
))
9061 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
9066 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetBackingStore(ID3D10EffectDepthStencilVariable
*iface
,
9067 UINT index
, D3D10_DEPTH_STENCIL_DESC
*desc
)
9069 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilVariable(iface
);
9071 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9073 if (!iface
->lpVtbl
->IsValid(iface
))
9075 WARN("Invalid variable.\n");
9079 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->ds_states
)))
9082 d3d10_effect_update_dependent_props(&v
->u
.state
.dependencies
, &v
->u
.state
.desc
);
9084 *desc
= v
->u
.state
.desc
.depth_stencil
;
9089 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl
=
9091 /* ID3D10EffectVariable methods */
9092 d3d10_effect_depth_stencil_variable_IsValid
,
9093 d3d10_effect_depth_stencil_variable_GetType
,
9094 d3d10_effect_depth_stencil_variable_GetDesc
,
9095 d3d10_effect_depth_stencil_variable_GetAnnotationByIndex
,
9096 d3d10_effect_depth_stencil_variable_GetAnnotationByName
,
9097 d3d10_effect_depth_stencil_variable_GetMemberByIndex
,
9098 d3d10_effect_depth_stencil_variable_GetMemberByName
,
9099 d3d10_effect_depth_stencil_variable_GetMemberBySemantic
,
9100 d3d10_effect_depth_stencil_variable_GetElement
,
9101 d3d10_effect_depth_stencil_variable_GetParentConstantBuffer
,
9102 d3d10_effect_depth_stencil_variable_AsScalar
,
9103 d3d10_effect_depth_stencil_variable_AsVector
,
9104 d3d10_effect_depth_stencil_variable_AsMatrix
,
9105 d3d10_effect_depth_stencil_variable_AsString
,
9106 d3d10_effect_depth_stencil_variable_AsShaderResource
,
9107 d3d10_effect_depth_stencil_variable_AsRenderTargetView
,
9108 d3d10_effect_depth_stencil_variable_AsDepthStencilView
,
9109 d3d10_effect_depth_stencil_variable_AsConstantBuffer
,
9110 d3d10_effect_depth_stencil_variable_AsShader
,
9111 d3d10_effect_depth_stencil_variable_AsBlend
,
9112 d3d10_effect_depth_stencil_variable_AsDepthStencil
,
9113 d3d10_effect_depth_stencil_variable_AsRasterizer
,
9114 d3d10_effect_depth_stencil_variable_AsSampler
,
9115 d3d10_effect_depth_stencil_variable_SetRawValue
,
9116 d3d10_effect_depth_stencil_variable_GetRawValue
,
9117 /* ID3D10EffectDepthStencilVariable methods */
9118 d3d10_effect_depth_stencil_variable_GetDepthStencilState
,
9119 d3d10_effect_depth_stencil_variable_GetBackingStore
,
9122 /* ID3D10EffectVariable methods */
9124 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectRasterizerVariable(
9125 ID3D10EffectRasterizerVariable
*iface
)
9127 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
9130 static BOOL STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_IsValid(ID3D10EffectRasterizerVariable
*iface
)
9132 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRasterizerVariable(iface
);
9134 TRACE("iface %p\n", iface
);
9136 return v
!= &null_rasterizer_variable
;
9139 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetType(
9140 ID3D10EffectRasterizerVariable
*iface
)
9142 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
9145 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetDesc(ID3D10EffectRasterizerVariable
*iface
,
9146 D3D10_EFFECT_VARIABLE_DESC
*desc
)
9148 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
9151 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetAnnotationByIndex(
9152 ID3D10EffectRasterizerVariable
*iface
, UINT index
)
9154 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
9157 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetAnnotationByName(
9158 ID3D10EffectRasterizerVariable
*iface
, const char *name
)
9160 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
9163 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetMemberByIndex(
9164 ID3D10EffectRasterizerVariable
*iface
, UINT index
)
9166 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
9169 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetMemberByName(
9170 ID3D10EffectRasterizerVariable
*iface
, const char *name
)
9172 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
9175 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetMemberBySemantic(
9176 ID3D10EffectRasterizerVariable
*iface
, const char *semantic
)
9178 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
9181 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetElement(
9182 ID3D10EffectRasterizerVariable
*iface
, UINT index
)
9184 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
9187 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetParentConstantBuffer(
9188 ID3D10EffectRasterizerVariable
*iface
)
9190 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
9193 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsScalar(
9194 ID3D10EffectRasterizerVariable
*iface
)
9196 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
9199 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsVector(
9200 ID3D10EffectRasterizerVariable
*iface
)
9202 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
9205 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsMatrix(
9206 ID3D10EffectRasterizerVariable
*iface
)
9208 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
9211 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsString(
9212 ID3D10EffectRasterizerVariable
*iface
)
9214 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
9217 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsShaderResource(
9218 ID3D10EffectRasterizerVariable
*iface
)
9220 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
9223 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsRenderTargetView(
9224 ID3D10EffectRasterizerVariable
*iface
)
9226 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
9229 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsDepthStencilView(
9230 ID3D10EffectRasterizerVariable
*iface
)
9232 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
9235 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsConstantBuffer(
9236 ID3D10EffectRasterizerVariable
*iface
)
9238 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
9241 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsShader(
9242 ID3D10EffectRasterizerVariable
*iface
)
9244 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
9247 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsBlend(
9248 ID3D10EffectRasterizerVariable
*iface
)
9250 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
9253 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsDepthStencil(
9254 ID3D10EffectRasterizerVariable
*iface
)
9256 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
9259 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsRasterizer(
9260 ID3D10EffectRasterizerVariable
*iface
)
9262 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
9265 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsSampler(
9266 ID3D10EffectRasterizerVariable
*iface
)
9268 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
9271 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_SetRawValue(ID3D10EffectRasterizerVariable
*iface
,
9272 void *data
, UINT offset
, UINT count
)
9274 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9277 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetRawValue(ID3D10EffectRasterizerVariable
*iface
,
9278 void *data
, UINT offset
, UINT count
)
9280 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9283 /* ID3D10EffectRasterizerVariable methods */
9285 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetRasterizerState(ID3D10EffectRasterizerVariable
*iface
,
9286 UINT index
, ID3D10RasterizerState
**rasterizer_state
)
9288 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRasterizerVariable(iface
);
9290 TRACE("iface %p, index %u, rasterizer_state %p.\n", iface
, index
, rasterizer_state
);
9292 if (!iface
->lpVtbl
->IsValid(iface
))
9294 WARN("Invalid variable.\n");
9298 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->rs_states
)))
9301 if ((*rasterizer_state
= v
->u
.state
.object
.rasterizer
))
9302 ID3D10RasterizerState_AddRef(*rasterizer_state
);
9307 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetBackingStore(ID3D10EffectRasterizerVariable
*iface
,
9308 UINT index
, D3D10_RASTERIZER_DESC
*desc
)
9310 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRasterizerVariable(iface
);
9312 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9314 if (!iface
->lpVtbl
->IsValid(iface
))
9316 WARN("Invalid variable.\n");
9320 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->rs_states
)))
9323 *desc
= v
->u
.state
.desc
.rasterizer
;
9328 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl
=
9330 /* ID3D10EffectVariable methods */
9331 d3d10_effect_rasterizer_variable_IsValid
,
9332 d3d10_effect_rasterizer_variable_GetType
,
9333 d3d10_effect_rasterizer_variable_GetDesc
,
9334 d3d10_effect_rasterizer_variable_GetAnnotationByIndex
,
9335 d3d10_effect_rasterizer_variable_GetAnnotationByName
,
9336 d3d10_effect_rasterizer_variable_GetMemberByIndex
,
9337 d3d10_effect_rasterizer_variable_GetMemberByName
,
9338 d3d10_effect_rasterizer_variable_GetMemberBySemantic
,
9339 d3d10_effect_rasterizer_variable_GetElement
,
9340 d3d10_effect_rasterizer_variable_GetParentConstantBuffer
,
9341 d3d10_effect_rasterizer_variable_AsScalar
,
9342 d3d10_effect_rasterizer_variable_AsVector
,
9343 d3d10_effect_rasterizer_variable_AsMatrix
,
9344 d3d10_effect_rasterizer_variable_AsString
,
9345 d3d10_effect_rasterizer_variable_AsShaderResource
,
9346 d3d10_effect_rasterizer_variable_AsRenderTargetView
,
9347 d3d10_effect_rasterizer_variable_AsDepthStencilView
,
9348 d3d10_effect_rasterizer_variable_AsConstantBuffer
,
9349 d3d10_effect_rasterizer_variable_AsShader
,
9350 d3d10_effect_rasterizer_variable_AsBlend
,
9351 d3d10_effect_rasterizer_variable_AsDepthStencil
,
9352 d3d10_effect_rasterizer_variable_AsRasterizer
,
9353 d3d10_effect_rasterizer_variable_AsSampler
,
9354 d3d10_effect_rasterizer_variable_SetRawValue
,
9355 d3d10_effect_rasterizer_variable_GetRawValue
,
9356 /* ID3D10EffectRasterizerVariable methods */
9357 d3d10_effect_rasterizer_variable_GetRasterizerState
,
9358 d3d10_effect_rasterizer_variable_GetBackingStore
,
9361 /* ID3D10EffectVariable methods */
9363 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectSamplerVariable(
9364 ID3D10EffectSamplerVariable
*iface
)
9366 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
9369 static BOOL STDMETHODCALLTYPE
d3d10_effect_sampler_variable_IsValid(ID3D10EffectSamplerVariable
*iface
)
9371 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectSamplerVariable(iface
);
9373 TRACE("iface %p\n", iface
);
9375 return v
!= &null_sampler_variable
;
9378 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetType(
9379 ID3D10EffectSamplerVariable
*iface
)
9381 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
9384 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetDesc(ID3D10EffectSamplerVariable
*iface
,
9385 D3D10_EFFECT_VARIABLE_DESC
*desc
)
9387 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
9390 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetAnnotationByIndex(
9391 ID3D10EffectSamplerVariable
*iface
, UINT index
)
9393 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
9396 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetAnnotationByName(
9397 ID3D10EffectSamplerVariable
*iface
, const char *name
)
9399 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
9402 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetMemberByIndex(
9403 ID3D10EffectSamplerVariable
*iface
, UINT index
)
9405 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
9408 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetMemberByName(
9409 ID3D10EffectSamplerVariable
*iface
, const char *name
)
9411 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
9414 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetMemberBySemantic(
9415 ID3D10EffectSamplerVariable
*iface
, const char *semantic
)
9417 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
9420 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetElement(
9421 ID3D10EffectSamplerVariable
*iface
, UINT index
)
9423 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
9426 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetParentConstantBuffer(
9427 ID3D10EffectSamplerVariable
*iface
)
9429 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
9432 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsScalar(
9433 ID3D10EffectSamplerVariable
*iface
)
9435 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
9438 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsVector(
9439 ID3D10EffectSamplerVariable
*iface
)
9441 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
9444 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsMatrix(
9445 ID3D10EffectSamplerVariable
*iface
)
9447 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
9450 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsString(
9451 ID3D10EffectSamplerVariable
*iface
)
9453 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
9456 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsShaderResource(
9457 ID3D10EffectSamplerVariable
*iface
)
9459 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
9462 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsRenderTargetView(
9463 ID3D10EffectSamplerVariable
*iface
)
9465 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
9468 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsDepthStencilView(
9469 ID3D10EffectSamplerVariable
*iface
)
9471 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
9474 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsConstantBuffer(
9475 ID3D10EffectSamplerVariable
*iface
)
9477 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
9480 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsShader(
9481 ID3D10EffectSamplerVariable
*iface
)
9483 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
9486 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsBlend(
9487 ID3D10EffectSamplerVariable
*iface
)
9489 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
9492 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsDepthStencil(
9493 ID3D10EffectSamplerVariable
*iface
)
9495 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
9498 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsRasterizer(
9499 ID3D10EffectSamplerVariable
*iface
)
9501 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
9504 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsSampler(
9505 ID3D10EffectSamplerVariable
*iface
)
9507 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
9510 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_SetRawValue(ID3D10EffectSamplerVariable
*iface
,
9511 void *data
, UINT offset
, UINT count
)
9513 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9516 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetRawValue(ID3D10EffectSamplerVariable
*iface
,
9517 void *data
, UINT offset
, UINT count
)
9519 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9522 /* ID3D10EffectSamplerVariable methods */
9524 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetSampler(ID3D10EffectSamplerVariable
*iface
,
9525 UINT index
, ID3D10SamplerState
**sampler
)
9527 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectSamplerVariable(iface
);
9529 TRACE("iface %p, index %u, sampler %p.\n", iface
, index
, sampler
);
9531 if (!iface
->lpVtbl
->IsValid(iface
))
9533 WARN("Invalid variable.\n");
9537 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->samplers
)))
9540 if ((*sampler
= v
->u
.state
.object
.sampler
))
9541 ID3D10SamplerState_AddRef(*sampler
);
9546 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetBackingStore(ID3D10EffectSamplerVariable
*iface
,
9547 UINT index
, D3D10_SAMPLER_DESC
*desc
)
9549 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectSamplerVariable(iface
);
9551 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9553 if (!iface
->lpVtbl
->IsValid(iface
))
9555 WARN("Invalid variable.\n");
9559 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->samplers
)))
9562 *desc
= v
->u
.state
.desc
.sampler
.desc
;
9567 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl
=
9569 /* ID3D10EffectVariable methods */
9570 d3d10_effect_sampler_variable_IsValid
,
9571 d3d10_effect_sampler_variable_GetType
,
9572 d3d10_effect_sampler_variable_GetDesc
,
9573 d3d10_effect_sampler_variable_GetAnnotationByIndex
,
9574 d3d10_effect_sampler_variable_GetAnnotationByName
,
9575 d3d10_effect_sampler_variable_GetMemberByIndex
,
9576 d3d10_effect_sampler_variable_GetMemberByName
,
9577 d3d10_effect_sampler_variable_GetMemberBySemantic
,
9578 d3d10_effect_sampler_variable_GetElement
,
9579 d3d10_effect_sampler_variable_GetParentConstantBuffer
,
9580 d3d10_effect_sampler_variable_AsScalar
,
9581 d3d10_effect_sampler_variable_AsVector
,
9582 d3d10_effect_sampler_variable_AsMatrix
,
9583 d3d10_effect_sampler_variable_AsString
,
9584 d3d10_effect_sampler_variable_AsShaderResource
,
9585 d3d10_effect_sampler_variable_AsRenderTargetView
,
9586 d3d10_effect_sampler_variable_AsDepthStencilView
,
9587 d3d10_effect_sampler_variable_AsConstantBuffer
,
9588 d3d10_effect_sampler_variable_AsShader
,
9589 d3d10_effect_sampler_variable_AsBlend
,
9590 d3d10_effect_sampler_variable_AsDepthStencil
,
9591 d3d10_effect_sampler_variable_AsRasterizer
,
9592 d3d10_effect_sampler_variable_AsSampler
,
9593 d3d10_effect_sampler_variable_SetRawValue
,
9594 d3d10_effect_sampler_variable_GetRawValue
,
9595 /* ID3D10EffectSamplerVariable methods */
9596 d3d10_effect_sampler_variable_GetSampler
,
9597 d3d10_effect_sampler_variable_GetBackingStore
,
9600 /* ID3D10EffectType methods */
9602 static inline struct d3d10_effect_type
*impl_from_ID3D10EffectType(ID3D10EffectType
*iface
)
9604 return CONTAINING_RECORD(iface
, struct d3d10_effect_type
, ID3D10EffectType_iface
);
9607 static BOOL STDMETHODCALLTYPE
d3d10_effect_type_IsValid(ID3D10EffectType
*iface
)
9609 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9611 TRACE("iface %p\n", iface
);
9613 return This
!= &null_type
;
9616 static HRESULT STDMETHODCALLTYPE
d3d10_effect_type_GetDesc(ID3D10EffectType
*iface
, D3D10_EFFECT_TYPE_DESC
*desc
)
9618 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9620 TRACE("iface %p, desc %p\n", iface
, desc
);
9622 if (This
== &null_type
)
9624 WARN("Null type specified\n");
9630 WARN("Invalid argument specified\n");
9631 return E_INVALIDARG
;
9634 desc
->TypeName
= This
->name
;
9635 desc
->Class
= This
->type_class
;
9636 desc
->Type
= This
->basetype
;
9637 desc
->Elements
= This
->element_count
;
9638 desc
->Members
= This
->member_count
;
9639 desc
->Rows
= This
->row_count
;
9640 desc
->Columns
= This
->column_count
;
9641 desc
->PackedSize
= This
->size_packed
;
9642 desc
->UnpackedSize
= This
->size_unpacked
;
9643 desc
->Stride
= This
->stride
;
9648 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_type_GetMemberTypeByIndex(ID3D10EffectType
*iface
,
9651 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9652 struct d3d10_effect_type
*t
;
9654 TRACE("iface %p, index %u\n", iface
, index
);
9656 if (index
>= This
->member_count
)
9658 WARN("Invalid index specified\n");
9659 return &null_type
.ID3D10EffectType_iface
;
9662 t
= (&This
->members
[index
])->type
;
9664 TRACE("Returning member %p, %s\n", t
, debugstr_a(t
->name
));
9666 return &t
->ID3D10EffectType_iface
;
9669 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_type_GetMemberTypeByName(ID3D10EffectType
*iface
,
9672 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9675 TRACE("iface %p, name %s\n", iface
, debugstr_a(name
));
9679 WARN("Invalid name specified\n");
9680 return &null_type
.ID3D10EffectType_iface
;
9683 for (i
= 0; i
< This
->member_count
; ++i
)
9685 struct d3d10_effect_type_member
*typem
= &This
->members
[i
];
9687 if (typem
->name
&& !strcmp(typem
->name
, name
))
9689 TRACE("Returning type %p.\n", typem
->type
);
9690 return &typem
->type
->ID3D10EffectType_iface
;
9694 WARN("Invalid name specified\n");
9696 return &null_type
.ID3D10EffectType_iface
;
9699 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_type_GetMemberTypeBySemantic(ID3D10EffectType
*iface
,
9700 const char *semantic
)
9702 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9705 TRACE("iface %p, semantic %s\n", iface
, debugstr_a(semantic
));
9709 WARN("Invalid semantic specified\n");
9710 return &null_type
.ID3D10EffectType_iface
;
9713 for (i
= 0; i
< This
->member_count
; ++i
)
9715 struct d3d10_effect_type_member
*typem
= &This
->members
[i
];
9717 if (typem
->semantic
&& !stricmp(typem
->semantic
, semantic
))
9719 TRACE("Returning type %p.\n", typem
->type
);
9720 return &typem
->type
->ID3D10EffectType_iface
;
9724 WARN("Invalid semantic specified\n");
9726 return &null_type
.ID3D10EffectType_iface
;
9729 static const char * STDMETHODCALLTYPE
d3d10_effect_type_GetMemberName(ID3D10EffectType
*iface
, UINT index
)
9731 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9732 struct d3d10_effect_type_member
*typem
;
9734 TRACE("iface %p, index %u\n", iface
, index
);
9736 if (index
>= This
->member_count
)
9738 WARN("Invalid index specified\n");
9742 typem
= &This
->members
[index
];
9744 TRACE("Returning name %s\n", debugstr_a(typem
->name
));
9749 static const char * STDMETHODCALLTYPE
d3d10_effect_type_GetMemberSemantic(ID3D10EffectType
*iface
, UINT index
)
9751 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9752 struct d3d10_effect_type_member
*typem
;
9754 TRACE("iface %p, index %u\n", iface
, index
);
9756 if (index
>= This
->member_count
)
9758 WARN("Invalid index specified\n");
9762 typem
= &This
->members
[index
];
9764 TRACE("Returning semantic %s\n", debugstr_a(typem
->semantic
));
9766 return typem
->semantic
;
9769 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl
=
9771 /* ID3D10EffectType */
9772 d3d10_effect_type_IsValid
,
9773 d3d10_effect_type_GetDesc
,
9774 d3d10_effect_type_GetMemberTypeByIndex
,
9775 d3d10_effect_type_GetMemberTypeByName
,
9776 d3d10_effect_type_GetMemberTypeBySemantic
,
9777 d3d10_effect_type_GetMemberName
,
9778 d3d10_effect_type_GetMemberSemantic
,
9781 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pool_QueryInterface(ID3D10EffectPool
*iface
,
9782 REFIID riid
, void **object
)
9784 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
9786 if (IsEqualGUID(riid
, &IID_ID3D10EffectPool
) ||
9787 IsEqualGUID(riid
, &IID_IUnknown
))
9789 IUnknown_AddRef(iface
);
9794 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
9797 return E_NOINTERFACE
;
9800 static ULONG STDMETHODCALLTYPE
d3d10_effect_pool_AddRef(ID3D10EffectPool
*iface
)
9802 struct d3d10_effect
*effect
= impl_from_ID3D10EffectPool(iface
);
9803 return d3d10_effect_AddRef(&effect
->ID3D10Effect_iface
);
9806 static ULONG STDMETHODCALLTYPE
d3d10_effect_pool_Release(ID3D10EffectPool
*iface
)
9808 struct d3d10_effect
*effect
= impl_from_ID3D10EffectPool(iface
);
9809 return d3d10_effect_Release(&effect
->ID3D10Effect_iface
);
9812 static ID3D10Effect
* STDMETHODCALLTYPE
d3d10_effect_pool_AsEffect(ID3D10EffectPool
*iface
)
9814 struct d3d10_effect
*effect
= impl_from_ID3D10EffectPool(iface
);
9816 TRACE("%p.\n", iface
);
9818 return &effect
->ID3D10Effect_iface
;
9821 const struct ID3D10EffectPoolVtbl d3d10_effect_pool_vtbl
=
9823 /* IUnknown methods */
9824 d3d10_effect_pool_QueryInterface
,
9825 d3d10_effect_pool_AddRef
,
9826 d3d10_effect_pool_Release
,
9827 /* ID3D10EffectPool methods */
9828 d3d10_effect_pool_AsEffect
,
9832 static int d3d10_effect_type_compare(const void *key
, const struct wine_rb_entry
*entry
)
9834 const struct d3d10_effect_type
*t
= WINE_RB_ENTRY_VALUE(entry
, const struct d3d10_effect_type
, entry
);
9835 const DWORD
*id
= key
;
9840 static HRESULT
d3d10_create_effect(void *data
, SIZE_T data_size
, ID3D10Device
*device
,
9841 struct d3d10_effect
*pool
, unsigned int flags
, struct d3d10_effect
**effect
)
9843 struct d3d10_effect
*object
;
9847 return D3DERR_INVALIDCALL
;
9849 if (!(object
= calloc(1, sizeof(*object
))))
9850 return E_OUTOFMEMORY
;
9852 wine_rb_init(&object
->types
, d3d10_effect_type_compare
);
9853 object
->ID3D10Effect_iface
.lpVtbl
= flags
& D3D10_EFFECT_IS_POOL
?
9854 &d3d10_effect_pool_effect_vtbl
: &d3d10_effect_vtbl
;
9855 object
->ID3D10EffectPool_iface
.lpVtbl
= &d3d10_effect_pool_vtbl
;
9856 object
->refcount
= 1;
9857 ID3D10Device_AddRef(device
);
9858 object
->device
= device
;
9859 object
->pool
= pool
;
9860 object
->flags
= flags
;
9861 if (pool
) IUnknown_AddRef(&pool
->ID3D10Effect_iface
);
9863 hr
= d3d10_effect_parse(object
, data
, data_size
);
9866 ERR("Failed to parse effect\n");
9867 IUnknown_Release(&object
->ID3D10Effect_iface
);
9876 HRESULT WINAPI
D3D10CreateEffectFromMemory(void *data
, SIZE_T data_size
, UINT flags
,
9877 ID3D10Device
*device
, ID3D10EffectPool
*effect_pool
, ID3D10Effect
**effect
)
9879 struct d3d10_effect
*object
, *pool
= NULL
;
9882 TRACE("data %p, data_size %Iu, flags %#x, device %p, effect_pool %p, effect %p.\n",
9883 data
, data_size
, flags
, device
, effect_pool
, effect
);
9885 if (!(flags
& D3D10_EFFECT_COMPILE_CHILD_EFFECT
) != !effect_pool
)
9886 return E_INVALIDARG
;
9888 if (effect_pool
&& !(pool
= unsafe_impl_from_ID3D10EffectPool(effect_pool
)))
9890 WARN("External pool implementations are not supported.\n");
9891 return E_INVALIDARG
;
9894 if (FAILED(hr
= d3d10_create_effect(data
, data_size
, device
, pool
, 0, &object
)))
9896 WARN("Failed to create an effect, hr %#lx.\n", hr
);
9900 *effect
= &object
->ID3D10Effect_iface
;
9902 TRACE("Created effect %p\n", object
);
9907 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pool_effect_QueryInterface(ID3D10Effect
*iface
,
9908 REFIID riid
, void **object
)
9910 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
9912 TRACE("iface %p, riid %s, obj %p.\n", iface
, debugstr_guid(riid
), object
);
9914 return IUnknown_QueryInterface(&effect
->ID3D10EffectPool_iface
, riid
, object
);
9917 static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl
=
9919 /* IUnknown methods */
9920 d3d10_effect_pool_effect_QueryInterface
,
9921 d3d10_effect_AddRef
,
9922 d3d10_effect_Release
,
9923 /* ID3D10Effect methods */
9924 d3d10_effect_IsValid
,
9925 d3d10_effect_IsPool
,
9926 d3d10_effect_GetDevice
,
9927 d3d10_effect_GetDesc
,
9928 d3d10_effect_GetConstantBufferByIndex
,
9929 d3d10_effect_GetConstantBufferByName
,
9930 d3d10_effect_GetVariableByIndex
,
9931 d3d10_effect_GetVariableByName
,
9932 d3d10_effect_GetVariableBySemantic
,
9933 d3d10_effect_GetTechniqueByIndex
,
9934 d3d10_effect_GetTechniqueByName
,
9935 d3d10_effect_Optimize
,
9936 d3d10_effect_IsOptimized
,
9939 HRESULT WINAPI
D3D10CreateEffectPoolFromMemory(void *data
, SIZE_T data_size
, UINT fx_flags
,
9940 ID3D10Device
*device
, ID3D10EffectPool
**effect_pool
)
9942 struct d3d10_effect
*object
;
9945 TRACE("data %p, data_size %Iu, fx_flags %#x, device %p, effect_pool %p.\n",
9946 data
, data_size
, fx_flags
, device
, effect_pool
);
9949 return E_INVALIDARG
;
9951 if (FAILED(hr
= d3d10_create_effect(data
, data_size
, device
, NULL
,
9952 D3D10_EFFECT_IS_POOL
, &object
)))
9954 WARN("Failed to create an effect, hr %#lx.\n", hr
);
9958 *effect_pool
= &object
->ID3D10EffectPool_iface
;
9960 TRACE("Created effect pool %p.\n", object
);