2 * Copyright 2009 Henri Verbeet for CodeWeavers
3 * Copyright 2009 Rico Schüller
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "d3d10_private.h"
22 #include <vkd3d_shader.h>
27 WINE_DEFAULT_DEBUG_CHANNEL(d3d10
);
29 #define MAKE_TAG(ch0, ch1, ch2, ch3) \
30 ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
31 ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
32 #define TAG_FX10 MAKE_TAG('F', 'X', '1', '0')
33 #define TAG_FXLC MAKE_TAG('F', 'X', 'L', 'C')
34 #define TAG_CLI4 MAKE_TAG('C', 'L', 'I', '4')
35 #define TAG_CTAB MAKE_TAG('C', 'T', 'A', 'B')
37 #define D3D10_FX10_TYPE_COLUMN_SHIFT 11
38 #define D3D10_FX10_TYPE_COLUMN_MASK (0x7 << D3D10_FX10_TYPE_COLUMN_SHIFT)
40 #define D3D10_FX10_TYPE_ROW_SHIFT 8
41 #define D3D10_FX10_TYPE_ROW_MASK (0x7 << D3D10_FX10_TYPE_ROW_SHIFT)
43 #define D3D10_FX10_TYPE_BASETYPE_SHIFT 3
44 #define D3D10_FX10_TYPE_BASETYPE_MASK (0x1f << D3D10_FX10_TYPE_BASETYPE_SHIFT)
46 #define D3D10_FX10_TYPE_CLASS_SHIFT 0
47 #define D3D10_FX10_TYPE_CLASS_MASK (0x7 << D3D10_FX10_TYPE_CLASS_SHIFT)
49 #define D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK 0x4000
51 static inline struct d3d10_effect
*impl_from_ID3D10EffectPool(ID3D10EffectPool
*iface
)
53 return CONTAINING_RECORD(iface
, struct d3d10_effect
, ID3D10EffectPool_iface
);
56 const struct ID3D10EffectPoolVtbl d3d10_effect_pool_vtbl
;
57 static inline struct d3d10_effect
*unsafe_impl_from_ID3D10EffectPool(ID3D10EffectPool
*iface
)
59 if (!iface
|| iface
->lpVtbl
!= &d3d10_effect_pool_vtbl
)
61 return CONTAINING_RECORD(iface
, struct d3d10_effect
, ID3D10EffectPool_iface
);
64 static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl
;
65 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable
*v
);
67 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl
;
68 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl
;
69 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl
;
70 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl
;
71 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl
;
72 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl
;
73 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl
;
74 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl
;
75 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl
;
76 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl
;
77 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl
;
78 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl
;
79 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl
;
80 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl
;
81 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl
;
82 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl
;
83 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl
;
85 /* null objects - needed for invalid calls */
86 static struct d3d10_effect_technique null_technique
= {{&d3d10_effect_technique_vtbl
}};
87 static struct d3d10_effect_pass null_pass
= {{&d3d10_effect_pass_vtbl
}};
88 static struct d3d10_effect_type null_type
= {{&d3d10_effect_type_vtbl
}};
89 static struct d3d10_effect_variable null_local_buffer
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_constant_buffer_vtbl
},
90 &null_local_buffer
, &null_type
};
91 static struct d3d10_effect_variable null_variable
= {{&d3d10_effect_variable_vtbl
},
92 &null_local_buffer
, &null_type
};
93 static struct d3d10_effect_variable null_scalar_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_scalar_variable_vtbl
},
94 &null_local_buffer
, &null_type
};
95 static struct d3d10_effect_variable null_vector_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_vector_variable_vtbl
},
96 &null_local_buffer
, &null_type
};
97 static struct d3d10_effect_variable null_matrix_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_matrix_variable_vtbl
},
98 &null_local_buffer
, &null_type
};
99 static struct d3d10_effect_variable null_string_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_string_variable_vtbl
},
100 &null_local_buffer
, &null_type
};
101 static struct d3d10_effect_variable null_render_target_view_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_render_target_view_variable_vtbl
},
102 &null_local_buffer
, &null_type
};
103 static struct d3d10_effect_variable null_depth_stencil_view_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_view_variable_vtbl
},
104 &null_local_buffer
, &null_type
};
105 static struct d3d10_effect_variable null_shader_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
},
106 &null_local_buffer
, &null_type
};
107 static struct d3d10_effect_variable null_blend_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_blend_variable_vtbl
},
108 &null_local_buffer
, &null_type
};
109 static struct d3d10_effect_variable null_depth_stencil_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_variable_vtbl
},
110 &null_local_buffer
, &null_type
};
111 static struct d3d10_effect_variable null_rasterizer_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_rasterizer_variable_vtbl
},
112 &null_local_buffer
, &null_type
};
113 static struct d3d10_effect_variable null_sampler_variable
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_sampler_variable_vtbl
},
114 &null_local_buffer
, &null_type
};
116 static ID3D10ShaderResourceView
*null_srvs
[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
];
118 static struct d3d10_effect_variable null_shader_resource_variable
=
120 .ID3D10EffectVariable_iface
.lpVtbl
= (ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_resource_variable_vtbl
,
121 .buffer
= &null_local_buffer
,
123 .u
.resource
.srv
= null_srvs
,
126 /* anonymous_shader_type and anonymous_shader */
127 static char anonymous_name
[] = "$Anonymous";
128 static char anonymous_vertexshader_name
[] = "vertexshader";
129 static char anonymous_pixelshader_name
[] = "pixelshader";
130 static char anonymous_geometryshader_name
[] = "geometryshader";
131 static struct d3d10_effect_type anonymous_vs_type
= {{&d3d10_effect_type_vtbl
},
132 anonymous_vertexshader_name
, D3D10_SVT_VERTEXSHADER
, D3D10_SVC_OBJECT
};
133 static struct d3d10_effect_type anonymous_ps_type
= {{&d3d10_effect_type_vtbl
},
134 anonymous_pixelshader_name
, D3D10_SVT_PIXELSHADER
, D3D10_SVC_OBJECT
};
135 static struct d3d10_effect_type anonymous_gs_type
= {{&d3d10_effect_type_vtbl
},
136 anonymous_geometryshader_name
, D3D10_SVT_GEOMETRYSHADER
, D3D10_SVC_OBJECT
};
137 static struct d3d10_effect_variable anonymous_vs
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
},
138 &null_local_buffer
, &anonymous_vs_type
, anonymous_name
};
139 static struct d3d10_effect_variable anonymous_ps
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
},
140 &null_local_buffer
, &anonymous_ps_type
, anonymous_name
};
141 static struct d3d10_effect_variable anonymous_gs
= {{(const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
},
142 &null_local_buffer
, &anonymous_gs_type
, anonymous_name
};
144 static struct d3d10_effect_type
*get_fx10_type(struct d3d10_effect
*effect
,
145 const char *data
, size_t data_size
, uint32_t offset
);
147 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectVariable(ID3D10EffectVariable
*iface
)
149 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
152 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectShaderVariable(ID3D10EffectShaderVariable
*iface
)
154 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
157 static struct d3d10_effect_variable
* d3d10_array_get_element(struct d3d10_effect_variable
*v
,
160 if (!v
->type
->element_count
) return v
;
161 return &v
->elements
[index
];
164 static struct d3d10_effect_variable
* d3d10_get_state_variable(struct d3d10_effect_variable
*v
,
165 unsigned int index
, const struct d3d10_effect_var_array
*array
)
167 v
= d3d10_array_get_element(v
, 0);
169 if (v
->u
.state
.index
+ index
>= array
->count
)
171 WARN("Invalid index %u.\n", index
);
175 return array
->v
[v
->u
.state
.index
+ index
];
178 enum d3d10_effect_container_type
183 D3D10_C_DEPTHSTENCIL
,
188 static enum d3d10_effect_container_type
get_var_container_type(const struct d3d10_effect_variable
*v
)
190 switch (v
->type
->basetype
)
192 case D3D10_SVT_DEPTHSTENCIL
: return D3D10_C_DEPTHSTENCIL
;
193 case D3D10_SVT_BLEND
: return D3D10_C_BLEND
;
194 case D3D10_SVT_RASTERIZER
: return D3D10_C_RASTERIZER
;
195 case D3D10_SVT_SAMPLER
: return D3D10_C_SAMPLER
;
196 default: return D3D10_C_NONE
;
200 struct preshader_instr
202 unsigned int comp_count
: 16;
203 unsigned int reserved
: 4;
204 unsigned int opcode
: 11;
205 unsigned int scalar
: 1;
208 typedef void (*pres_op_func
)(float **args
, unsigned int n
, const struct preshader_instr
*instr
);
210 static void pres_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 BOOL
fx10_get_string(const char *data
, size_t data_size
, uint32_t offset
, const char **s
, size_t *l
)
1150 size_t len
, max_len
;
1152 if (offset
>= data_size
)
1154 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1158 max_len
= data_size
- offset
;
1159 if (!(len
= strnlen(data
+ offset
, max_len
)))
1175 static BOOL
fx10_copy_string(const char *data
, size_t data_size
, DWORD offset
, char **s
)
1180 if (!fx10_get_string(data
, data_size
, offset
, &p
, &len
))
1189 if (!(*s
= malloc(len
)))
1191 ERR("Failed to allocate string memory.\n");
1200 static BOOL
copy_name(const char *ptr
, char **name
)
1202 if (!ptr
|| !*ptr
) return TRUE
;
1204 if (!(*name
= strdup(ptr
)))
1206 ERR("Failed to allocate name memory.\n");
1213 static struct d3d10_effect_variable
* d3d10_effect_get_buffer_by_name(struct d3d10_effect
*effect
,
1218 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
1220 struct d3d10_effect_variable
*l
= &effect
->local_buffers
[i
];
1221 if (l
->name
&& !strcmp(l
->name
, name
))
1225 return effect
->pool
? d3d10_effect_get_buffer_by_name(effect
->pool
, name
) : NULL
;
1228 static struct d3d10_effect_variable
* d3d10_effect_get_variable_by_name(
1229 const struct d3d10_effect
*effect
, const char *name
)
1231 struct d3d10_effect_variable
*v
;
1234 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
1236 for (j
= 0; j
< effect
->local_buffers
[i
].type
->member_count
; ++j
)
1238 v
= &effect
->local_buffers
[i
].members
[j
];
1239 if (v
->name
&& !strcmp(v
->name
, name
))
1244 for (i
= 0; i
< effect
->local_variable_count
; ++i
)
1246 struct d3d10_effect_variable
*v
= &effect
->local_variables
[i
];
1247 if (v
->name
&& !strcmp(v
->name
, name
))
1251 return effect
->pool
? d3d10_effect_get_variable_by_name(effect
->pool
, name
) : NULL
;
1254 static HRESULT
get_fx10_shader_resources(struct d3d10_effect_variable
*v
)
1256 struct d3d10_effect_shader_variable
*sv
= &v
->u
.shader
;
1257 struct d3d10_effect_shader_resource
*sr
;
1258 D3D10_SHADER_INPUT_BIND_DESC bind_desc
;
1259 D3D10_SHADER_DESC desc
;
1262 sv
->reflection
->lpVtbl
->GetDesc(sv
->reflection
, &desc
);
1263 sv
->resource_count
= desc
.BoundResources
;
1265 if (!(sv
->resources
= calloc(sv
->resource_count
, sizeof(*sv
->resources
))))
1267 ERR("Failed to allocate shader resource binding information memory.\n");
1268 return E_OUTOFMEMORY
;
1271 for (i
= 0; i
< desc
.BoundResources
; ++i
)
1273 sv
->reflection
->lpVtbl
->GetResourceBindingDesc(sv
->reflection
, i
, &bind_desc
);
1274 sr
= &sv
->resources
[i
];
1276 sr
->in_type
= bind_desc
.Type
;
1277 sr
->bind_point
= bind_desc
.BindPoint
;
1278 sr
->bind_count
= bind_desc
.BindCount
;
1280 switch (bind_desc
.Type
)
1282 case D3D10_SIT_CBUFFER
:
1283 case D3D10_SIT_TBUFFER
:
1284 if (sr
->bind_count
!= 1)
1286 WARN("Unexpected bind count %u for a buffer %s.\n", bind_desc
.BindCount
,
1287 debugstr_a(bind_desc
.Name
));
1288 return E_UNEXPECTED
;
1290 sr
->variable
= d3d10_effect_get_buffer_by_name(v
->effect
, bind_desc
.Name
);
1293 case D3D10_SIT_SAMPLER
:
1294 case D3D10_SIT_TEXTURE
:
1295 sr
->variable
= d3d10_effect_get_variable_by_name(v
->effect
, bind_desc
.Name
);
1304 WARN("Failed to find shader resource.\n");
1312 struct d3d10_effect_so_decl
1314 D3D10_SO_DECLARATION_ENTRY
*entries
;
1317 unsigned int stride
;
1321 static void d3d10_effect_cleanup_so_decl(struct d3d10_effect_so_decl
*so_decl
)
1323 free(so_decl
->entries
);
1324 free(so_decl
->decl
);
1325 memset(so_decl
, 0, sizeof(*so_decl
));
1328 static HRESULT
d3d10_effect_parse_stream_output_declaration(const char *decl
,
1329 struct d3d10_effect_so_decl
*so_decl
)
1331 static const char * xyzw
= "xyzw";
1332 static const char * rgba
= "rgba";
1333 char *p
, *ptr
, *end
, *next
, *mask
, *m
, *slot
;
1334 D3D10_SO_DECLARATION_ENTRY e
;
1337 memset(so_decl
, 0, sizeof(*so_decl
));
1339 if (!(so_decl
->decl
= strdup(decl
)))
1340 return E_OUTOFMEMORY
;
1346 memset(&e
, 0, sizeof(e
));
1348 end
= strchr(p
, ';');
1349 next
= end
? end
+ 1 : p
+ strlen(p
);
1354 /* Remove leading and trailing spaces. */
1355 while (len
&& isspace(*p
)) { len
--; p
++; }
1356 while (len
&& isspace(p
[len
- 1])) len
--;
1361 if ((slot
= strchr(p
, ':')))
1370 WARN("Invalid output slot %s.\n", debugstr_a(p
));
1376 e
.OutputSlot
= atoi(p
);
1381 if ((mask
= strchr(p
, '.')))
1385 if ((m
= strstr(xyzw
, mask
)))
1386 e
.StartComponent
= m
- xyzw
;
1387 else if ((m
= strstr(rgba
, mask
)))
1388 e
.StartComponent
= m
- rgba
;
1391 WARN("Invalid component mask %s.\n", debugstr_a(mask
));
1395 e
.ComponentCount
= strlen(mask
);
1399 e
.StartComponent
= 0;
1400 e
.ComponentCount
= 4;
1403 /* Semantic index and name */
1405 while (isdigit(p
[len
- 1]))
1410 e
.SemanticIndex
= atoi(&p
[len
]);
1414 e
.SemanticName
= stricmp(p
, "$SKIP") ? p
: NULL
;
1416 if (!d3d_array_reserve((void **)&so_decl
->entries
, &so_decl
->capacity
, so_decl
->count
+ 1,
1417 sizeof(*so_decl
->entries
)))
1420 so_decl
->entries
[so_decl
->count
++] = e
;
1422 if (e
.OutputSlot
== 0)
1423 so_decl
->stride
+= e
.ComponentCount
* sizeof(float);
1431 d3d10_effect_cleanup_so_decl(so_decl
);
1436 static HRESULT
parse_fx10_shader(const char *data
, size_t data_size
, uint32_t offset
, struct d3d10_effect_variable
*v
)
1438 ID3D10Device
*device
= v
->effect
->device
;
1443 if (v
->effect
->shaders
.current
>= v
->effect
->shaders
.count
)
1445 WARN("Invalid effect? Used shader current(%u) >= used shader count(%u)\n",
1446 v
->effect
->shaders
.current
, v
->effect
->shaders
.count
);
1450 v
->effect
->shaders
.v
[v
->effect
->shaders
.current
++] = v
;
1452 if (offset
>= data_size
|| !require_space(offset
, 1, sizeof(dxbc_size
), data_size
))
1454 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1458 ptr
= data
+ offset
;
1459 dxbc_size
= read_u32(&ptr
);
1460 TRACE("DXBC size: %#x.\n", dxbc_size
);
1462 if (!require_space(ptr
- data
, 1, dxbc_size
, data_size
))
1464 WARN("Invalid dxbc size %#x (data size %#Ix, offset %#x).\n", offset
, data_size
, offset
);
1471 if (FAILED(hr
= D3D10ReflectShader(ptr
, dxbc_size
, &v
->u
.shader
.reflection
)))
1474 D3DGetInputSignatureBlob(ptr
, dxbc_size
, &v
->u
.shader
.input_signature
);
1476 if (FAILED(hr
= D3DCreateBlob(dxbc_size
, &v
->u
.shader
.bytecode
)))
1479 memcpy(ID3D10Blob_GetBufferPointer(v
->u
.shader
.bytecode
), ptr
, dxbc_size
);
1481 if (FAILED(hr
= get_fx10_shader_resources(v
)))
1484 switch (v
->type
->basetype
)
1486 case D3D10_SVT_VERTEXSHADER
:
1487 hr
= ID3D10Device_CreateVertexShader(device
, ptr
, dxbc_size
, &v
->u
.shader
.shader
.vs
);
1490 case D3D10_SVT_PIXELSHADER
:
1491 hr
= ID3D10Device_CreatePixelShader(device
, ptr
, dxbc_size
, &v
->u
.shader
.shader
.ps
);
1494 case D3D10_SVT_GEOMETRYSHADER
:
1495 if (v
->u
.shader
.stream_output_declaration
)
1497 struct d3d10_effect_so_decl so_decl
;
1499 if (FAILED(hr
= d3d10_effect_parse_stream_output_declaration(v
->u
.shader
.stream_output_declaration
, &so_decl
)))
1501 WARN("Failed to parse stream output declaration, hr %#lx.\n", hr
);
1505 hr
= ID3D10Device_CreateGeometryShaderWithStreamOutput(device
, ptr
, dxbc_size
,
1506 so_decl
.entries
, so_decl
.count
, so_decl
.stride
, &v
->u
.shader
.shader
.gs
);
1508 d3d10_effect_cleanup_so_decl(&so_decl
);
1511 hr
= ID3D10Device_CreateGeometryShader(device
, ptr
, dxbc_size
, &v
->u
.shader
.shader
.gs
);
1515 ERR("This should not happen!\n");
1522 static D3D10_SHADER_VARIABLE_CLASS
d3d10_variable_class(uint32_t c
, BOOL is_column_major
)
1526 case 1: return D3D10_SVC_SCALAR
;
1527 case 2: return D3D10_SVC_VECTOR
;
1528 case 3: if (is_column_major
) return D3D10_SVC_MATRIX_COLUMNS
;
1529 else return D3D10_SVC_MATRIX_ROWS
;
1531 FIXME("Unknown variable class %#x.\n", c
);
1536 static D3D10_SHADER_VARIABLE_TYPE
d3d10_variable_type(uint32_t t
, BOOL is_object
,
1545 case 1: return D3D10_SVT_STRING
;
1546 case 2: return D3D10_SVT_BLEND
;
1547 case 3: return D3D10_SVT_DEPTHSTENCIL
;
1548 case 4: return D3D10_SVT_RASTERIZER
;
1549 case 5: return D3D10_SVT_PIXELSHADER
;
1550 case 6: return D3D10_SVT_VERTEXSHADER
;
1551 case 7: return D3D10_SVT_GEOMETRYSHADER
;
1553 *flags
= D3D10_EOT_FLAG_GS_SO
;
1554 return D3D10_SVT_GEOMETRYSHADER
;
1556 case 9: return D3D10_SVT_TEXTURE
;
1557 case 10: return D3D10_SVT_TEXTURE1D
;
1558 case 11: return D3D10_SVT_TEXTURE1DARRAY
;
1559 case 12: return D3D10_SVT_TEXTURE2D
;
1560 case 13: return D3D10_SVT_TEXTURE2DARRAY
;
1561 case 14: return D3D10_SVT_TEXTURE2DMS
;
1562 case 15: return D3D10_SVT_TEXTURE2DMSARRAY
;
1563 case 16: return D3D10_SVT_TEXTURE3D
;
1564 case 17: return D3D10_SVT_TEXTURECUBE
;
1566 case 19: return D3D10_SVT_RENDERTARGETVIEW
;
1567 case 20: return D3D10_SVT_DEPTHSTENCILVIEW
;
1568 case 21: return D3D10_SVT_SAMPLER
;
1569 case 22: return D3D10_SVT_BUFFER
;
1571 FIXME("Unknown variable type %#x.\n", t
);
1572 return D3D10_SVT_VOID
;
1579 case 1: return D3D10_SVT_FLOAT
;
1580 case 2: return D3D10_SVT_INT
;
1581 case 3: return D3D10_SVT_UINT
;
1582 case 4: return D3D10_SVT_BOOL
;
1584 FIXME("Unknown variable type %#x.\n", t
);
1585 return D3D10_SVT_VOID
;
1590 static HRESULT
parse_fx10_type(const char *data
, size_t data_size
, uint32_t offset
, struct d3d10_effect_type
*t
)
1592 uint32_t typeinfo
, type_flags
, type_kind
;
1596 if (offset
>= data_size
|| !require_space(offset
, 6, sizeof(DWORD
), data_size
))
1598 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1602 ptr
= data
+ offset
;
1603 offset
= read_u32(&ptr
);
1604 TRACE("Type name at offset %#x.\n", offset
);
1606 if (!fx10_copy_string(data
, data_size
, offset
, &t
->name
))
1608 ERR("Failed to copy name.\n");
1609 return E_OUTOFMEMORY
;
1611 TRACE("Type name: %s.\n", debugstr_a(t
->name
));
1613 type_kind
= read_u32(&ptr
);
1614 TRACE("Kind: %u.\n", type_kind
);
1616 t
->element_count
= read_u32(&ptr
);
1617 TRACE("Element count: %u.\n", t
->element_count
);
1619 t
->size_unpacked
= read_u32(&ptr
);
1620 TRACE("Unpacked size: %#x.\n", t
->size_unpacked
);
1622 t
->stride
= read_u32(&ptr
);
1623 TRACE("Stride: %#x.\n", t
->stride
);
1625 t
->size_packed
= read_u32(&ptr
);
1626 TRACE("Packed size %#x.\n", t
->size_packed
);
1631 TRACE("Type is numeric.\n");
1633 if (!require_space(ptr
- data
, 1, sizeof(typeinfo
), data_size
))
1635 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1639 typeinfo
= read_u32(&ptr
);
1640 t
->member_count
= 0;
1641 t
->column_count
= (typeinfo
& D3D10_FX10_TYPE_COLUMN_MASK
) >> D3D10_FX10_TYPE_COLUMN_SHIFT
;
1642 t
->row_count
= (typeinfo
& D3D10_FX10_TYPE_ROW_MASK
) >> D3D10_FX10_TYPE_ROW_SHIFT
;
1643 t
->basetype
= d3d10_variable_type((typeinfo
& D3D10_FX10_TYPE_BASETYPE_MASK
)
1644 >> D3D10_FX10_TYPE_BASETYPE_SHIFT
, FALSE
, &type_flags
);
1645 t
->type_class
= d3d10_variable_class((typeinfo
& D3D10_FX10_TYPE_CLASS_MASK
)
1646 >> D3D10_FX10_TYPE_CLASS_SHIFT
, typeinfo
& D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK
);
1648 TRACE("Type description: %#x.\n", typeinfo
);
1649 TRACE("\tcolumns: %u.\n", t
->column_count
);
1650 TRACE("\trows: %u.\n", t
->row_count
);
1651 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t
->basetype
));
1652 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t
->type_class
));
1653 TRACE("\tunknown bits: %#x.\n", typeinfo
& ~(D3D10_FX10_TYPE_COLUMN_MASK
| D3D10_FX10_TYPE_ROW_MASK
1654 | D3D10_FX10_TYPE_BASETYPE_MASK
| D3D10_FX10_TYPE_CLASS_MASK
| D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK
));
1658 TRACE("Type is an object.\n");
1660 if (!require_space(ptr
- data
, 1, sizeof(typeinfo
), data_size
))
1662 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1666 typeinfo
= read_u32(&ptr
);
1667 t
->member_count
= 0;
1668 t
->column_count
= 0;
1670 t
->basetype
= d3d10_variable_type(typeinfo
, TRUE
, &type_flags
);
1671 t
->type_class
= D3D10_SVC_OBJECT
;
1672 t
->flags
= type_flags
;
1674 TRACE("Type description: %#x.\n", typeinfo
);
1675 TRACE("\tbasetype: %s.\n", debug_d3d10_shader_variable_type(t
->basetype
));
1676 TRACE("\tclass: %s.\n", debug_d3d10_shader_variable_class(t
->type_class
));
1677 TRACE("\tflags: %#x.\n", t
->flags
);
1681 TRACE("Type is a structure.\n");
1683 if (!require_space(ptr
- data
, 1, sizeof(t
->member_count
), data_size
))
1685 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
1689 t
->member_count
= read_u32(&ptr
);
1690 TRACE("Member count: %u.\n", t
->member_count
);
1692 t
->column_count
= 0;
1695 t
->type_class
= D3D10_SVC_STRUCT
;
1697 if (!(t
->members
= calloc(t
->member_count
, sizeof(*t
->members
))))
1699 ERR("Failed to allocate members memory.\n");
1700 return E_OUTOFMEMORY
;
1703 if (!require_space(ptr
- data
, t
->member_count
, 4 * sizeof(DWORD
), data_size
))
1705 WARN("Invalid member count %#x (data size %#Ix, offset %#x).\n",
1706 t
->member_count
, data_size
, offset
);
1710 for (i
= 0; i
< t
->member_count
; ++i
)
1712 struct d3d10_effect_type_member
*typem
= &t
->members
[i
];
1714 offset
= read_u32(&ptr
);
1715 TRACE("Member name at offset %#x.\n", offset
);
1717 if (!fx10_copy_string(data
, data_size
, offset
, &typem
->name
))
1719 ERR("Failed to copy name.\n");
1720 return E_OUTOFMEMORY
;
1722 TRACE("Member name: %s.\n", debugstr_a(typem
->name
));
1724 offset
= read_u32(&ptr
);
1725 TRACE("Member semantic at offset %#x.\n", offset
);
1727 if (!fx10_copy_string(data
, data_size
, offset
, &typem
->semantic
))
1729 ERR("Failed to copy semantic.\n");
1730 return E_OUTOFMEMORY
;
1732 TRACE("Member semantic: %s.\n", debugstr_a(typem
->semantic
));
1734 typem
->buffer_offset
= read_u32(&ptr
);
1735 TRACE("Member offset in struct: %#x.\n", typem
->buffer_offset
);
1737 offset
= read_u32(&ptr
);
1738 TRACE("Member type info at offset %#x.\n", offset
);
1740 if (!(typem
->type
= get_fx10_type(t
->effect
, data
, data_size
, offset
)))
1742 ERR("Failed to get variable type.\n");
1749 FIXME("Unhandled type kind %#x.\n", type_kind
);
1753 if (t
->element_count
)
1755 TRACE("Elementtype for type at offset: %#lx\n", t
->id
);
1757 /* allocate elementtype - we need only one, because all elements have the same type */
1758 if (!(t
->elementtype
= calloc(1, sizeof(*t
->elementtype
))))
1760 ERR("Failed to allocate members memory.\n");
1761 return E_OUTOFMEMORY
;
1764 /* create a copy of the original type with some minor changes */
1765 t
->elementtype
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
1766 t
->elementtype
->effect
= t
->effect
;
1768 if (!copy_name(t
->name
, &t
->elementtype
->name
))
1770 ERR("Failed to copy name.\n");
1771 return E_OUTOFMEMORY
;
1773 TRACE("\tType name: %s.\n", debugstr_a(t
->elementtype
->name
));
1775 t
->elementtype
->element_count
= 0;
1776 TRACE("\tElement count: %u.\n", t
->elementtype
->element_count
);
1779 * Not sure if this calculation is 100% correct, but a test
1780 * shows that these values work.
1782 t
->elementtype
->size_unpacked
= t
->size_packed
/ t
->element_count
;
1783 TRACE("\tUnpacked size: %#x.\n", t
->elementtype
->size_unpacked
);
1785 t
->elementtype
->stride
= t
->stride
;
1786 TRACE("\tStride: %#x.\n", t
->elementtype
->stride
);
1788 t
->elementtype
->size_packed
= t
->size_packed
/ t
->element_count
;
1789 TRACE("\tPacked size: %#x.\n", t
->elementtype
->size_packed
);
1791 t
->elementtype
->member_count
= t
->member_count
;
1792 TRACE("\tMember count: %u.\n", t
->elementtype
->member_count
);
1794 t
->elementtype
->column_count
= t
->column_count
;
1795 TRACE("\tColumns: %u.\n", t
->elementtype
->column_count
);
1797 t
->elementtype
->row_count
= t
->row_count
;
1798 TRACE("\tRows: %u.\n", t
->elementtype
->row_count
);
1800 t
->elementtype
->basetype
= t
->basetype
;
1801 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(t
->elementtype
->basetype
));
1803 t
->elementtype
->type_class
= t
->type_class
;
1804 TRACE("\tClass: %s.\n", debug_d3d10_shader_variable_class(t
->elementtype
->type_class
));
1806 t
->elementtype
->members
= t
->members
;
1812 static struct d3d10_effect_type
*get_fx10_type(struct d3d10_effect
*effect
, const char *data
,
1813 size_t data_size
, uint32_t offset
)
1815 struct d3d10_effect_type
*type
;
1816 struct wine_rb_entry
*entry
;
1819 entry
= wine_rb_get(&effect
->types
, &offset
);
1822 TRACE("Returning existing type.\n");
1823 return WINE_RB_ENTRY_VALUE(entry
, struct d3d10_effect_type
, entry
);
1826 if (!(type
= calloc(1, sizeof(*type
))))
1828 ERR("Failed to allocate type memory.\n");
1832 type
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
1834 type
->effect
= effect
;
1835 if (FAILED(hr
= parse_fx10_type(data
, data_size
, offset
, type
)))
1837 ERR("Failed to parse type info, hr %#lx.\n", hr
);
1842 if (wine_rb_put(&effect
->types
, &offset
, &type
->entry
) == -1)
1844 ERR("Failed to insert type entry.\n");
1852 static void set_variable_vtbl(struct d3d10_effect_variable
*v
)
1854 const ID3D10EffectVariableVtbl
**vtbl
= &v
->ID3D10EffectVariable_iface
.lpVtbl
;
1856 switch (v
->type
->type_class
)
1858 case D3D10_SVC_SCALAR
:
1859 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_scalar_variable_vtbl
;
1862 case D3D10_SVC_VECTOR
:
1863 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_vector_variable_vtbl
;
1866 case D3D10_SVC_MATRIX_ROWS
:
1867 case D3D10_SVC_MATRIX_COLUMNS
:
1868 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_matrix_variable_vtbl
;
1871 case D3D10_SVC_STRUCT
:
1872 *vtbl
= &d3d10_effect_variable_vtbl
;
1875 case D3D10_SVC_OBJECT
:
1876 switch(v
->type
->basetype
)
1878 case D3D10_SVT_STRING
:
1879 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_string_variable_vtbl
;
1882 case D3D10_SVT_TEXTURE
:
1883 case D3D10_SVT_TEXTURE1D
:
1884 case D3D10_SVT_TEXTURE1DARRAY
:
1885 case D3D10_SVT_TEXTURE2D
:
1886 case D3D10_SVT_TEXTURE2DARRAY
:
1887 case D3D10_SVT_TEXTURE2DMS
:
1888 case D3D10_SVT_TEXTURE2DMSARRAY
:
1889 case D3D10_SVT_TEXTURE3D
:
1890 case D3D10_SVT_TEXTURECUBE
:
1891 case D3D10_SVT_BUFFER
: /* Either resource or constant buffer. */
1892 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_resource_variable_vtbl
;
1895 case D3D10_SVT_RENDERTARGETVIEW
:
1896 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_render_target_view_variable_vtbl
;
1899 case D3D10_SVT_DEPTHSTENCILVIEW
:
1900 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_view_variable_vtbl
;
1903 case D3D10_SVT_DEPTHSTENCIL
:
1904 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_variable_vtbl
;
1907 case D3D10_SVT_VERTEXSHADER
:
1908 case D3D10_SVT_GEOMETRYSHADER
:
1909 case D3D10_SVT_PIXELSHADER
:
1910 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
;
1913 case D3D10_SVT_BLEND
:
1914 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_blend_variable_vtbl
;
1917 case D3D10_SVT_RASTERIZER
:
1918 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_rasterizer_variable_vtbl
;
1921 case D3D10_SVT_SAMPLER
:
1922 *vtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_sampler_variable_vtbl
;
1926 FIXME("Unhandled basetype %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
1927 *vtbl
= &d3d10_effect_variable_vtbl
;
1933 FIXME("Unhandled type class %s.\n", debug_d3d10_shader_variable_class(v
->type
->type_class
));
1934 *vtbl
= &d3d10_effect_variable_vtbl
;
1939 static HRESULT
copy_variableinfo_from_type(struct d3d10_effect_variable
*v
)
1944 if (v
->type
->member_count
)
1946 if (!(v
->members
= calloc(v
->type
->member_count
, sizeof(*v
->members
))))
1948 ERR("Failed to allocate members memory.\n");
1949 return E_OUTOFMEMORY
;
1952 for (i
= 0; i
< v
->type
->member_count
; ++i
)
1954 struct d3d10_effect_variable
*var
= &v
->members
[i
];
1955 struct d3d10_effect_type_member
*typem
= &v
->type
->members
[i
];
1957 var
->buffer
= v
->buffer
;
1958 var
->effect
= v
->effect
;
1959 var
->type
= typem
->type
;
1960 set_variable_vtbl(var
);
1962 if (!copy_name(typem
->name
, &var
->name
))
1964 ERR("Failed to copy name.\n");
1965 return E_OUTOFMEMORY
;
1967 TRACE("Variable name: %s.\n", debugstr_a(var
->name
));
1969 if (!copy_name(typem
->semantic
, &var
->semantic
))
1971 ERR("Failed to copy name.\n");
1972 return E_OUTOFMEMORY
;
1974 TRACE("Variable semantic: %s.\n", debugstr_a(var
->semantic
));
1976 var
->buffer_offset
= v
->buffer_offset
+ typem
->buffer_offset
;
1977 TRACE("Variable buffer offset: %u.\n", var
->buffer_offset
);
1979 hr
= copy_variableinfo_from_type(var
);
1980 if (FAILED(hr
)) return hr
;
1984 if (v
->type
->element_count
)
1986 unsigned int bufferoffset
= v
->buffer_offset
;
1988 if (!(v
->elements
= calloc(v
->type
->element_count
, sizeof(*v
->elements
))))
1990 ERR("Failed to allocate elements memory.\n");
1991 return E_OUTOFMEMORY
;
1994 for (i
= 0; i
< v
->type
->element_count
; ++i
)
1996 struct d3d10_effect_variable
*var
= &v
->elements
[i
];
1998 var
->buffer
= v
->buffer
;
1999 var
->effect
= v
->effect
;
2000 var
->type
= v
->type
->elementtype
;
2001 set_variable_vtbl(var
);
2003 if (!copy_name(v
->name
, &var
->name
))
2005 ERR("Failed to copy name.\n");
2006 return E_OUTOFMEMORY
;
2008 TRACE("Variable name: %s.\n", debugstr_a(var
->name
));
2010 if (!copy_name(v
->semantic
, &var
->semantic
))
2012 ERR("Failed to copy name.\n");
2013 return E_OUTOFMEMORY
;
2015 TRACE("Variable semantic: %s.\n", debugstr_a(var
->semantic
));
2019 bufferoffset
+= v
->type
->stride
;
2021 var
->buffer_offset
= bufferoffset
;
2022 TRACE("Variable buffer offset: %u.\n", var
->buffer_offset
);
2024 hr
= copy_variableinfo_from_type(var
);
2025 if (FAILED(hr
)) return hr
;
2032 static HRESULT
parse_fx10_variable_head(const char *data
, size_t data_size
,
2033 const char **ptr
, struct d3d10_effect_variable
*v
)
2037 offset
= read_u32(ptr
);
2038 TRACE("Variable name at offset %#x.\n", offset
);
2040 if (!fx10_copy_string(data
, data_size
, offset
, &v
->name
))
2042 ERR("Failed to copy name.\n");
2043 return E_OUTOFMEMORY
;
2045 TRACE("Variable name: %s.\n", debugstr_a(v
->name
));
2047 offset
= read_u32(ptr
);
2048 TRACE("Variable type info at offset %#x.\n", offset
);
2050 if (!(v
->type
= get_fx10_type(v
->effect
, data
, data_size
, offset
)))
2052 ERR("Failed to get variable type.\n");
2055 set_variable_vtbl(v
);
2057 v
->explicit_bind_point
= ~0u;
2059 if (v
->effect
->flags
& D3D10_EFFECT_IS_POOL
)
2060 v
->flag
|= D3D10_EFFECT_VARIABLE_POOLED
;
2062 return copy_variableinfo_from_type(v
);
2065 static HRESULT
parse_fx10_annotation(const char *data
, size_t data_size
,
2066 const char **ptr
, struct d3d10_effect_variable
*a
)
2071 if (FAILED(hr
= parse_fx10_variable_head(data
, data_size
, ptr
, a
)))
2074 offset
= read_u32(ptr
);
2075 TRACE("Annotation value is at offset %#x.\n", offset
);
2077 switch (a
->type
->basetype
)
2079 case D3D10_SVT_STRING
:
2080 if (!fx10_copy_string(data
, data_size
, offset
, (char **)&a
->u
.buffer
.local_buffer
))
2082 ERR("Failed to copy name.\n");
2083 return E_OUTOFMEMORY
;
2088 FIXME("Unhandled object type %#x.\n", a
->type
->basetype
);
2091 /* mark the variable as annotation */
2092 a
->flag
|= D3D10_EFFECT_VARIABLE_ANNOTATION
;
2097 static HRESULT
parse_fx10_annotations(const char *data
, size_t data_size
, const char **ptr
,
2098 struct d3d10_effect
*effect
, struct d3d10_effect_annotations
*annotations
)
2103 if (!(annotations
->elements
= calloc(annotations
->count
, sizeof(*annotations
->elements
))))
2105 ERR("Failed to allocate annotations memory.\n");
2106 return E_OUTOFMEMORY
;
2109 for (i
= 0; i
< annotations
->count
; ++i
)
2111 struct d3d10_effect_variable
*a
= &annotations
->elements
[i
];
2114 a
->buffer
= &null_local_buffer
;
2116 if (FAILED(hr
= parse_fx10_annotation(data
, data_size
, ptr
, a
)))
2123 static HRESULT
parse_fx10_anonymous_shader(struct d3d10_effect
*e
, D3D_SHADER_VARIABLE_TYPE basetype
,
2124 struct d3d10_effect_anonymous_shader
*s
)
2126 struct d3d10_effect_variable
*v
= &s
->shader
;
2127 struct d3d10_effect_type
*t
= &s
->type
;
2128 const char *name
= NULL
;
2132 case D3D10_SVT_VERTEXSHADER
:
2133 name
= "vertexshader";
2136 case D3D10_SVT_PIXELSHADER
:
2137 name
= "pixelshader";
2140 case D3D10_SVT_GEOMETRYSHADER
:
2141 name
= "geometryshader";
2145 WARN("Unhandled shader type %#x.\n", basetype
);
2148 t
->basetype
= basetype
;
2150 if (!copy_name(name
, &t
->name
))
2152 ERR("Failed to copy name.\n");
2153 return E_OUTOFMEMORY
;
2155 TRACE("Type name: %s.\n", debugstr_a(t
->name
));
2157 t
->type_class
= D3D10_SVC_OBJECT
;
2159 t
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
2163 v
->u
.shader
.isinline
= 1;
2164 set_variable_vtbl(v
);
2166 if (!copy_name("$Anonymous", &v
->name
))
2168 ERR("Failed to copy semantic.\n");
2169 return E_OUTOFMEMORY
;
2171 TRACE("Variable name: %s.\n", debugstr_a(v
->name
));
2176 static const struct d3d10_effect_state_storage_info
*get_storage_info(D3D_SHADER_VARIABLE_TYPE id
)
2180 for (i
= 0; i
< ARRAY_SIZE(d3d10_effect_state_storage_info
); ++i
)
2182 if (d3d10_effect_state_storage_info
[i
].id
== id
)
2183 return &d3d10_effect_state_storage_info
[i
];
2189 static BOOL
read_value_list(const char *data
, size_t data_size
, uint32_t offset
,
2190 D3D_SHADER_VARIABLE_TYPE out_type
, unsigned int out_base
, unsigned int out_size
,
2193 uint32_t t
, value
, count
, type_flags
;
2194 D3D_SHADER_VARIABLE_TYPE in_type
;
2198 if (offset
>= data_size
|| !require_space(offset
, 1, sizeof(count
), data_size
))
2200 WARN("Invalid offset %#x (data size %#Ix).\n", offset
, data_size
);
2204 ptr
= data
+ offset
;
2205 count
= read_u32(&ptr
);
2206 if (count
!= out_size
)
2209 if (!require_space(ptr
- data
, count
, 2 * sizeof(DWORD
), data_size
))
2211 WARN("Invalid value count %#x (offset %#x, data size %#Ix).\n", count
, offset
, data_size
);
2215 TRACE("%u values:\n", count
);
2216 for (i
= 0; i
< count
; ++i
)
2218 unsigned int out_idx
= out_base
* out_size
+ i
;
2221 value
= read_u32(&ptr
);
2223 in_type
= d3d10_variable_type(t
, FALSE
, &type_flags
);
2224 TRACE("\t%s: %#x.\n", debug_d3d10_shader_variable_type(in_type
), value
);
2228 case D3D10_SVT_FLOAT
:
2230 case D3D10_SVT_UINT
:
2231 case D3D10_SVT_UINT8
:
2232 case D3D10_SVT_BOOL
:
2233 if (!d3d10_effect_read_numeric_value(value
, in_type
, out_type
, out_data
, out_idx
))
2237 case D3D10_SVT_VERTEXSHADER
:
2238 *(void **)out_data
= &anonymous_vs
;
2241 case D3D10_SVT_PIXELSHADER
:
2242 *(void **)out_data
= &anonymous_ps
;
2245 case D3D10_SVT_GEOMETRYSHADER
:
2246 *(void **)out_data
= &anonymous_gs
;
2249 case D3D10_SVT_TEXTURE
:
2250 *(void **)out_data
= &null_shader_resource_variable
;
2253 case D3D10_SVT_DEPTHSTENCIL
:
2254 *(void **)out_data
= &null_depth_stencil_variable
;
2257 case D3D10_SVT_BLEND
:
2258 *(void **)out_data
= &null_blend_variable
;
2262 FIXME("Unhandled out_type %#x.\n", out_type
);
2270 static BOOL
is_object_property(const struct d3d10_effect_state_property_info
*property_info
)
2272 switch (property_info
->type
)
2274 case D3D10_SVT_RASTERIZER
:
2275 case D3D10_SVT_DEPTHSTENCIL
:
2276 case D3D10_SVT_BLEND
:
2277 case D3D10_SVT_RENDERTARGETVIEW
:
2278 case D3D10_SVT_DEPTHSTENCILVIEW
:
2279 case D3D10_SVT_VERTEXSHADER
:
2280 case D3D10_SVT_PIXELSHADER
:
2281 case D3D10_SVT_GEOMETRYSHADER
:
2282 case D3D10_SVT_TEXTURE
:
2289 static BOOL
is_object_property_type_matching(const struct d3d10_effect_state_property_info
*property_info
,
2290 const struct d3d10_effect_variable
*v
)
2292 if (property_info
->type
== v
->type
->basetype
) return TRUE
;
2294 switch (v
->type
->basetype
)
2296 case D3D10_SVT_TEXTURE1D
:
2297 case D3D10_SVT_TEXTURE1DARRAY
:
2298 case D3D10_SVT_TEXTURE2D
:
2299 case D3D10_SVT_TEXTURE2DARRAY
:
2300 case D3D10_SVT_TEXTURE2DMS
:
2301 case D3D10_SVT_TEXTURE2DMSARRAY
:
2302 case D3D10_SVT_TEXTURE3D
:
2303 case D3D10_SVT_TEXTURECUBE
:
2304 if (property_info
->type
== D3D10_SVT_TEXTURE
) return TRUE
;
2311 static HRESULT
parse_fx10_preshader_instr(struct d3d10_preshader_parse_context
*context
,
2312 unsigned int *offset
, const char **ptr
, unsigned int data_size
)
2314 const struct preshader_op_info
*op_info
;
2315 unsigned int i
, param_count
, size
;
2316 struct preshader_instr ins
;
2317 uint32_t input_count
;
2319 if (!require_space(*offset
, 2, sizeof(uint32_t), data_size
))
2321 WARN("Malformed FXLC table, size %u.\n", data_size
);
2325 *(uint32_t *)&ins
= read_u32(ptr
);
2326 input_count
= read_u32(ptr
);
2327 *offset
+= 2 * sizeof(uint32_t);
2329 if (!(op_info
= d3d10_effect_get_op_info(ins
.opcode
)))
2331 FIXME("Unrecognized opcode %#x.\n", ins
.opcode
);
2335 TRACE("Opcode %#x (%s) (%u,%u), input count %u.\n", ins
.opcode
, op_info
->name
,
2336 ins
.comp_count
, ins
.scalar
, input_count
);
2338 /* Inputs + one output */
2339 param_count
= input_count
+ 1;
2341 if (!require_space(*offset
, 3 * param_count
, sizeof(uint32_t), data_size
))
2343 WARN("Malformed FXLC table, opcode %#x.\n", ins
.opcode
);
2346 *offset
+= 3 * param_count
* sizeof(uint32_t);
2348 for (i
= 0; i
< param_count
; ++i
)
2350 uint32_t flags
, regt
, param_offset
;
2352 flags
= read_u32(ptr
);
2355 FIXME("Argument flags are not supported %#x.\n", flags
);
2356 return E_UNEXPECTED
;
2359 regt
= read_u32(ptr
);
2360 param_offset
= read_u32(ptr
);
2364 case D3D10_REG_TABLE_CONSTANTS
:
2365 case D3D10_REG_TABLE_CB
:
2366 case D3D10_REG_TABLE_RESULT
:
2367 case D3D10_REG_TABLE_TEMP
:
2368 size
= param_offset
+ (ins
.scalar
&& i
== 0 ? 1 : ins
.comp_count
);
2369 context
->table_sizes
[regt
] = max(context
->table_sizes
[regt
], size
);
2372 FIXME("Unexpected register table index %u.\n", regt
);
2380 static HRESULT
parse_fx10_fxlc(void *ctx
, const char *data
, unsigned int data_size
)
2382 struct d3d10_preshader_parse_context
*context
= ctx
;
2383 struct d3d10_effect_preshader
*p
= context
->preshader
;
2384 unsigned int i
, offset
= 4;
2389 if (data_size
% sizeof(uint32_t))
2391 WARN("FXLC size misaligned %u.\n", data_size
);
2395 if (FAILED(hr
= D3DCreateBlob(data_size
, &p
->code
)))
2397 memcpy(ID3D10Blob_GetBufferPointer(p
->code
), data
, data_size
);
2400 ins_count
= read_u32(&ptr
);
2401 TRACE("%u instructions.\n", ins_count
);
2403 for (i
= 0; i
< ins_count
; ++i
)
2405 if (FAILED(hr
= parse_fx10_preshader_instr(context
, &offset
, &ptr
, data_size
)))
2407 WARN("Failed to parse instruction %u.\n", i
);
2412 if (FAILED(hr
= d3d10_reg_table_allocate(&p
->reg_tables
[D3D10_REG_TABLE_RESULT
],
2413 context
->table_sizes
[D3D10_REG_TABLE_RESULT
]))) return hr
;
2414 if (FAILED(hr
= d3d10_reg_table_allocate(&p
->reg_tables
[D3D10_REG_TABLE_TEMP
],
2415 context
->table_sizes
[D3D10_REG_TABLE_TEMP
]))) return hr
;
2420 static HRESULT
parse_fx10_cli4(void *ctx
, const char *data
, unsigned int data_size
)
2422 struct d3d10_preshader_parse_context
*context
= ctx
;
2423 struct d3d10_effect_preshader
*p
= context
->preshader
;
2424 struct d3d10_reg_table
*table
= &p
->reg_tables
[D3D10_REG_TABLE_CONSTANTS
];
2425 const char *ptr
= data
;
2429 if (data_size
< sizeof(DWORD
))
2431 WARN("Invalid CLI4 chunk size %u.\n", data_size
);
2435 count
= read_u32(&ptr
);
2437 TRACE("%u literal constants.\n", count
);
2439 if (!require_space(4, count
, sizeof(float), data_size
))
2441 WARN("Invalid constant table size %u.\n", data_size
);
2445 if (FAILED(hr
= d3d10_reg_table_allocate(table
, count
)))
2448 memcpy(table
->f
, ptr
, table
->count
* sizeof(*table
->f
));
2453 static HRESULT
parse_fx10_ctab(void *ctx
, const char *data
, unsigned int data_size
)
2455 struct d3d10_preshader_parse_context
*context
= ctx
;
2456 struct d3d10_effect_preshader
*p
= context
->preshader
;
2463 uint32_t constantinfo
;
2467 struct ctab_const_info
2471 WORD register_index
;
2472 WORD register_count
;
2475 uint32_t default_value
;
2477 unsigned int i
, cb_reg_count
= 0;
2478 const char *ptr
= data
;
2483 if (data_size
< sizeof(header
))
2485 WARN("Invalid constant table size %u.\n", data_size
);
2489 header
.size
= read_u32(&ptr
);
2490 header
.creator
= read_u32(&ptr
);
2491 header
.version
= read_u32(&ptr
);
2492 header
.constants
= read_u32(&ptr
);
2493 header
.constantinfo
= read_u32(&ptr
);
2494 header
.flags
= read_u32(&ptr
);
2495 header
.target
= read_u32(&ptr
);
2497 if (!require_space(header
.constantinfo
, header
.constants
, sizeof(*info
), data_size
))
2499 WARN("Invalid constant info section offset %#x.\n", header
.constantinfo
);
2503 p
->vars_count
= header
.constants
;
2505 TRACE("Variable count %u.\n", p
->vars_count
);
2507 if (!(p
->vars
= calloc(p
->vars_count
, sizeof(*p
->vars
))))
2508 return E_OUTOFMEMORY
;
2510 info
= (struct ctab_const_info
*)(data
+ header
.constantinfo
);
2511 for (i
= 0; i
< p
->vars_count
; ++i
, ++info
)
2513 if (!fx10_get_string(data
, data_size
, info
->name
, &name
, &name_len
))
2516 if (!(p
->vars
[i
].v
= d3d10_effect_get_variable_by_name(context
->effect
, name
)))
2518 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
2522 /* 4 components per register */
2523 p
->vars
[i
].offset
= info
->register_index
* 4;
2524 p
->vars
[i
].length
= info
->register_count
* 4;
2526 cb_reg_count
= max(cb_reg_count
, info
->register_index
+ info
->register_count
);
2529 /* Allocate contiguous "constant buffer" for all referenced variables. */
2530 if (FAILED(hr
= d3d10_reg_table_allocate(&p
->reg_tables
[D3D10_REG_TABLE_CB
], cb_reg_count
* 4)))
2532 WARN("Failed to allocate variables buffer.\n");
2539 static HRESULT
fxlvm_chunk_handler(const struct vkd3d_shader_dxbc_section_desc
*section
,
2540 struct d3d10_preshader_parse_context
*ctx
)
2542 const char *data
= section
->data
.code
;
2543 size_t data_size
= section
->data
.size
;
2544 uint32_t tag
= section
->tag
;
2546 TRACE("Chunk tag: %s, size: %Iu.\n", debugstr_an((const char *)&tag
, 4), data_size
);
2551 return parse_fx10_fxlc(ctx
, data
, data_size
);
2554 return parse_fx10_cli4(ctx
, data
, data_size
);
2557 return parse_fx10_ctab(ctx
, data
, data_size
);
2560 FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag
, 4));
2565 static HRESULT
parse_fx10_preshader(const char *data
, size_t data_size
,
2566 struct d3d10_effect
*effect
, struct d3d10_effect_preshader
*preshader
)
2568 const struct vkd3d_shader_code dxbc
= {.code
= data
, .size
= data_size
};
2569 const struct vkd3d_shader_dxbc_section_desc
*section
;
2570 struct d3d10_preshader_parse_context context
;
2571 struct vkd3d_shader_dxbc_desc dxbc_desc
;
2576 memset(preshader
, 0, sizeof(*preshader
));
2577 memset(&context
, 0, sizeof(context
));
2578 context
.preshader
= preshader
;
2579 context
.effect
= effect
;
2581 if ((ret
= vkd3d_shader_parse_dxbc(&dxbc
, 0, &dxbc_desc
, NULL
)) < 0)
2583 WARN("Failed to parse DXBC, ret %d.\n", ret
);
2587 for (i
= 0; i
< dxbc_desc
.section_count
; ++i
)
2589 section
= &dxbc_desc
.sections
[i
];
2590 if (FAILED(hr
= fxlvm_chunk_handler(section
, &context
)))
2594 vkd3d_shader_free_dxbc(&dxbc_desc
);
2596 /* Constant buffer and literal constants are preallocated, validate here that expression
2597 has no invalid accesses for those. */
2599 if (context
.table_sizes
[D3D10_REG_TABLE_CONSTANTS
] >
2600 preshader
->reg_tables
[D3D10_REG_TABLE_CONSTANTS
].count
)
2602 WARN("Expression references out of bounds literal constant.\n");
2606 if (context
.table_sizes
[D3D10_REG_TABLE_CB
] > preshader
->reg_tables
[D3D10_REG_TABLE_CB
].count
)
2608 WARN("Expression references out of bounds variable.\n");
2615 static HRESULT
d3d10_effect_add_prop_dependency(struct d3d10_effect_prop_dependencies
*d
,
2616 const struct d3d10_effect_prop_dependency
*dep
)
2618 if (!d3d_array_reserve((void **)&d
->entries
, &d
->capacity
, d
->count
+ 1, sizeof(*d
->entries
)))
2619 return E_OUTOFMEMORY
;
2621 d
->entries
[d
->count
++] = *dep
;
2626 static HRESULT
parse_fx10_property_assignment(const char *data
, size_t data_size
,
2627 const char **ptr
, enum d3d10_effect_container_type container_type
,
2628 struct d3d10_effect
*effect
, void *container
, struct d3d10_effect_prop_dependencies
*d
)
2630 uint32_t id
, idx
, variable_idx
, operation
, value_offset
, sodecl_offset
;
2631 const struct d3d10_effect_state_property_info
*property_info
;
2632 struct d3d10_effect_prop_dependency dep
;
2633 struct d3d10_effect_variable
*variable
;
2634 uint32_t code_offset
, blob_size
;
2635 const char *data_ptr
, *name
;
2636 unsigned int *dst_index
;
2642 idx
= read_u32(ptr
);
2643 operation
= read_u32(ptr
);
2644 value_offset
= read_u32(ptr
);
2646 if (id
>= ARRAY_SIZE(property_infos
))
2648 FIXME("Unknown property id %#x.\n", id
);
2651 property_info
= &property_infos
[id
];
2653 TRACE("Property %s[%#x] = value list @ offset %#x.\n", property_info
->name
, idx
, value_offset
);
2655 if (property_info
->container_type
!= container_type
)
2657 ERR("Invalid container type %#x for property %#x.\n", container_type
, id
);
2661 if (idx
>= property_info
->count
)
2663 ERR("Invalid index %#x for property %#x.\n", idx
, id
);
2667 if (property_info
->offset
== ~0u)
2669 ERR("Unsupported property %#x.\n", id
);
2673 dst
= (char *)container
+ property_info
->offset
;
2674 dst_index
= (unsigned int *)((char *)container
+ property_info
->index_offset
);
2678 case D3D10_EOO_CONST
:
2680 /* Constant values output directly to backing store. */
2681 if (!read_value_list(data
, data_size
, value_offset
, property_info
->type
, idx
,
2682 property_info
->size
, dst
))
2684 ERR("Failed to read values for property %#x.\n", id
);
2692 if (!fx10_get_string(data
, data_size
, value_offset
, &name
, &name_len
))
2694 WARN("Failed to get variable name.\n");
2697 TRACE("Variable name %s.\n", debugstr_a(name
));
2699 if (!(variable
= d3d10_effect_get_variable_by_name(effect
, name
)))
2701 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
2705 if (is_object_property(property_info
))
2707 if (variable
->type
->element_count
)
2709 WARN("Unexpected array variable value %s.\n", debugstr_a(name
));
2713 if (!is_object_property_type_matching(property_info
, variable
))
2715 WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
2716 variable
->type
->basetype
, property_info
->type
);
2720 ((void **)dst
)[idx
] = variable
;
2724 if (property_info
->size
* sizeof(float) > variable
->type
->size_unpacked
)
2726 WARN("Mismatching variable size %u, property size %u.\n",
2727 variable
->type
->size_unpacked
, property_info
->size
);
2733 dep
.operation
= operation
;
2734 dep
.var
.v
= variable
;
2737 return d3d10_effect_add_prop_dependency(d
, &dep
);
2742 case D3D10_EOO_CONST_INDEX
:
2744 /* Array variable, constant index. */
2745 if (value_offset
>= data_size
|| !require_space(value_offset
, 2, sizeof(DWORD
), data_size
))
2747 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2750 data_ptr
= data
+ value_offset
;
2751 value_offset
= read_u32(&data_ptr
);
2752 variable_idx
= read_u32(&data_ptr
);
2754 if (!fx10_get_string(data
, data_size
, value_offset
, &name
, &name_len
))
2756 WARN("Failed to get variable name.\n");
2760 TRACE("Variable name %s[%s%u].\n", debugstr_a(name
), is_object_property(property_info
) ?
2761 "" : "offset ", variable_idx
);
2763 if (!(variable
= d3d10_effect_get_variable_by_name(effect
, name
)))
2765 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
2769 if (is_object_property(property_info
))
2771 if (!variable
->type
->element_count
|| variable_idx
>= variable
->type
->element_count
)
2773 WARN("Invalid array size %u.\n", variable
->type
->element_count
);
2777 if (!is_object_property_type_matching(property_info
, variable
))
2779 WARN("Object type mismatch. Variable type %#x, property type %#x.\n",
2780 variable
->type
->basetype
, property_info
->type
);
2784 /* Shader variables are special, they are referenced via array, with index stored separately. */
2785 switch (property_info
->type
)
2787 case D3D10_SVT_VERTEXSHADER
:
2788 case D3D10_SVT_PIXELSHADER
:
2789 case D3D10_SVT_GEOMETRYSHADER
:
2790 ((void **)dst
)[idx
] = variable
;
2791 *dst_index
= variable_idx
;
2794 ((void **)dst
)[idx
] = &variable
->elements
[variable_idx
];
2799 unsigned int offset
= variable_idx
* sizeof(float);
2801 if (offset
>= variable
->type
->size_unpacked
||
2802 variable
->type
->size_unpacked
- offset
< property_info
->size
* sizeof(float))
2804 WARN("Invalid numeric variable data offset %u.\n", variable_idx
);
2810 dep
.operation
= operation
;
2811 dep
.var
.v
= variable
;
2812 dep
.var
.offset
= offset
;
2814 return d3d10_effect_add_prop_dependency(d
, &dep
);
2819 case D3D10_EOO_INDEX_EXPRESSION
:
2821 /* Variable, and an expression for its index. */
2822 if (value_offset
>= data_size
|| !require_space(value_offset
, 2, sizeof(DWORD
), data_size
))
2824 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2828 data_ptr
= data
+ value_offset
;
2829 value_offset
= read_u32(&data_ptr
);
2830 code_offset
= read_u32(&data_ptr
);
2832 if (!fx10_get_string(data
, data_size
, value_offset
, &name
, &name_len
))
2834 WARN("Failed to get variable name.\n");
2838 TRACE("Variable name %s[<expr>].\n", debugstr_a(name
));
2840 if (!(variable
= d3d10_effect_get_variable_by_name(effect
, name
)))
2842 WARN("Couldn't find variable %s.\n", debugstr_a(name
));
2846 if (!variable
->type
->element_count
)
2848 WARN("Expected array variable.\n");
2852 if (!is_object_property(property_info
))
2854 WARN("Expected object type property used with indexed expression.\n");
2858 if (code_offset
>= data_size
|| !require_space(code_offset
, 1, sizeof(DWORD
), data_size
))
2860 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2864 data_ptr
= data
+ code_offset
;
2865 blob_size
= read_u32(&data_ptr
);
2867 if (!require_space(code_offset
, 1, sizeof(uint32_t) + blob_size
, data_size
))
2869 WARN("Invalid offset %#x (data size %#Ix).\n", code_offset
, data_size
);
2875 dep
.operation
= operation
;
2876 dep
.index_expr
.v
= variable
;
2877 if (FAILED(hr
= parse_fx10_preshader(data_ptr
, blob_size
, effect
, &dep
.index_expr
.index
)))
2879 WARN("Failed to parse preshader, hr %#lx.\n", hr
);
2883 return d3d10_effect_add_prop_dependency(d
, &dep
);
2885 case D3D10_EOO_VALUE_EXPRESSION
:
2887 if (value_offset
>= data_size
|| !require_space(value_offset
, 1, sizeof(uint32_t), data_size
))
2889 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2893 data_ptr
= data
+ value_offset
;
2894 blob_size
= read_u32(&data_ptr
);
2896 if (!require_space(value_offset
, 1, sizeof(uint32_t) + blob_size
, data_size
))
2898 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2904 dep
.operation
= operation
;
2905 if (FAILED(hr
= parse_fx10_preshader(data_ptr
, blob_size
, effect
, &dep
.value_expr
.value
)))
2907 WARN("Failed to parse preshader, hr %#lx.\n", hr
);
2911 return d3d10_effect_add_prop_dependency(d
, &dep
);
2913 case D3D10_EOO_ANONYMOUS_SHADER
:
2915 /* Anonymous shader */
2916 if (effect
->anonymous_shader_current
>= effect
->anonymous_shader_count
)
2918 ERR("Anonymous shader count is wrong!\n");
2922 if (value_offset
>= data_size
|| !require_space(value_offset
, 2, sizeof(DWORD
), data_size
))
2924 WARN("Invalid offset %#x (data size %#Ix).\n", value_offset
, data_size
);
2927 data_ptr
= data
+ value_offset
;
2928 value_offset
= read_u32(&data_ptr
);
2929 sodecl_offset
= read_u32(&data_ptr
);
2931 TRACE("Effect object starts at offset %#x.\n", value_offset
);
2933 if (FAILED(hr
= parse_fx10_anonymous_shader(effect
, property_info
->type
,
2934 &effect
->anonymous_shaders
[effect
->anonymous_shader_current
])))
2937 variable
= &effect
->anonymous_shaders
[effect
->anonymous_shader_current
].shader
;
2938 ++effect
->anonymous_shader_current
;
2942 TRACE("Anonymous shader stream output declaration at offset %#x.\n", sodecl_offset
);
2943 if (!fx10_copy_string(data
, data_size
, sodecl_offset
,
2944 &variable
->u
.shader
.stream_output_declaration
))
2946 ERR("Failed to copy stream output declaration.\n");
2950 TRACE("Stream output declaration: %s.\n", debugstr_a(variable
->u
.shader
.stream_output_declaration
));
2953 switch (property_info
->type
)
2955 case D3D10_SVT_VERTEXSHADER
:
2956 case D3D10_SVT_PIXELSHADER
:
2957 case D3D10_SVT_GEOMETRYSHADER
:
2958 if (FAILED(hr
= parse_fx10_shader(data
, data_size
, value_offset
, variable
)))
2963 WARN("Unexpected shader type %#x.\n", property_info
->type
);
2967 ((void **)dst
)[idx
] = variable
;
2972 FIXME("Unhandled operation %#x.\n", operation
);
2979 static HRESULT
parse_fx10_pass(const char *data
, size_t data_size
,
2980 const char **ptr
, struct d3d10_effect_pass
*p
)
2982 uint32_t offset
, object_count
;
2986 offset
= read_u32(ptr
);
2987 TRACE("Pass name at offset %#x.\n", offset
);
2989 if (!fx10_copy_string(data
, data_size
, offset
, &p
->name
))
2991 ERR("Failed to copy name.\n");
2992 return E_OUTOFMEMORY
;
2994 TRACE("Pass name: %s.\n", debugstr_a(p
->name
));
2996 object_count
= read_u32(ptr
);
2997 TRACE("Pass has %u effect objects.\n", object_count
);
2999 p
->annotations
.count
= read_u32(ptr
);
3000 TRACE("Pass has %u annotations.\n", p
->annotations
.count
);
3002 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, p
->technique
->effect
,
3005 ERR("Failed to parse pass annotations, hr %#lx.\n", hr
);
3009 p
->vs
.shader
= &null_shader_variable
;
3010 p
->ps
.shader
= &null_shader_variable
;
3011 p
->gs
.shader
= &null_shader_variable
;
3013 for (i
= 0; i
< object_count
; ++i
)
3015 if (FAILED(hr
= parse_fx10_property_assignment(data
, data_size
, ptr
,
3016 D3D10_C_PASS
, p
->technique
->effect
, p
, &p
->dependencies
)))
3018 WARN("Failed to parse pass assignment %u, hr %#lx.\n", i
, hr
);
3026 static HRESULT
parse_fx10_technique(const char *data
, size_t data_size
,
3027 const char **ptr
, struct d3d10_effect_technique
*t
)
3033 offset
= read_u32(ptr
);
3034 TRACE("Technique name at offset %#x.\n", offset
);
3036 if (!fx10_copy_string(data
, data_size
, offset
, &t
->name
))
3038 ERR("Failed to copy name.\n");
3039 return E_OUTOFMEMORY
;
3041 TRACE("Technique name: %s.\n", debugstr_a(t
->name
));
3043 t
->pass_count
= read_u32(ptr
);
3044 TRACE("Technique has %u passes.\n", t
->pass_count
);
3046 t
->annotations
.count
= read_u32(ptr
);
3047 TRACE("Technique has %u annotations.\n", t
->annotations
.count
);
3049 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, t
->effect
,
3052 ERR("Failed to parse technique annotations, hr %#lx.\n", hr
);
3056 if (!(t
->passes
= calloc(t
->pass_count
, sizeof(*t
->passes
))))
3058 ERR("Failed to allocate passes memory\n");
3059 return E_OUTOFMEMORY
;
3062 for (i
= 0; i
< t
->pass_count
; ++i
)
3064 struct d3d10_effect_pass
*p
= &t
->passes
[i
];
3066 p
->ID3D10EffectPass_iface
.lpVtbl
= &d3d10_effect_pass_vtbl
;
3069 if (FAILED(hr
= parse_fx10_pass(data
, data_size
, ptr
, p
)))
3076 static void parse_fx10_set_default_numeric_value(const char **ptr
, struct d3d10_effect_variable
*v
)
3078 float *dst
= (float *)(v
->buffer
->u
.buffer
.local_buffer
+ v
->buffer_offset
), *src
;
3079 BOOL col_major
= v
->type
->type_class
== D3D10_SVC_MATRIX_COLUMNS
;
3080 unsigned int col_count
= v
->type
->column_count
, col
;
3081 unsigned int row_count
= v
->type
->row_count
, row
;
3083 src
= (float *)*ptr
;
3087 for (col
= 0; col
< col_count
; ++col
)
3089 for (row
= 0; row
< row_count
; ++row
)
3090 dst
[row
] = src
[row
* col_count
+ col
];
3096 for (row
= 0; row
< row_count
; ++row
)
3098 memcpy(dst
, src
, col_count
* sizeof(float));
3104 *ptr
+= col_count
* row_count
* sizeof(float);
3107 static void parse_fx10_default_value(const char **ptr
, struct d3d10_effect_variable
*var
)
3109 unsigned int element_count
= max(var
->type
->element_count
, 1), i
, m
;
3110 struct d3d10_effect_variable
*v
;
3112 for (i
= 0; i
< element_count
; ++i
)
3114 v
= d3d10_array_get_element(var
, i
);
3116 switch (v
->type
->type_class
)
3118 case D3D10_SVC_STRUCT
:
3119 for (m
= 0; m
< v
->type
->member_count
; ++m
)
3120 parse_fx10_default_value(ptr
, &v
->members
[m
]);
3122 case D3D10_SVC_SCALAR
:
3123 case D3D10_SVC_VECTOR
:
3124 case D3D10_SVC_MATRIX_COLUMNS
:
3125 case D3D10_SVC_MATRIX_ROWS
:
3126 parse_fx10_set_default_numeric_value(ptr
, v
);
3129 FIXME("Unexpected initial value for type %#x.\n", v
->type
->basetype
);
3135 static void d3d10_effect_variable_update_buffer_offsets(struct d3d10_effect_variable
*v
,
3136 unsigned int offset
)
3140 for (i
= 0; i
< v
->type
->member_count
; ++i
)
3141 d3d10_effect_variable_update_buffer_offsets(&v
->members
[i
], offset
);
3143 for (i
= 0; i
< v
->type
->element_count
; ++i
)
3144 d3d10_effect_variable_update_buffer_offsets(&v
->elements
[i
], offset
);
3146 v
->buffer_offset
+= offset
;
3149 static HRESULT
parse_fx10_numeric_variable(const char *data
, size_t data_size
,
3150 const char **ptr
, BOOL local
, struct d3d10_effect_variable
*v
)
3152 uint32_t offset
, flags
, default_value_offset
, buffer_offset
;
3153 const char *data_ptr
;
3156 if (FAILED(hr
= parse_fx10_variable_head(data
, data_size
, ptr
, v
)))
3159 offset
= read_u32(ptr
);
3160 TRACE("Variable semantic at offset %#x.\n", offset
);
3162 if (!fx10_copy_string(data
, data_size
, offset
, &v
->semantic
))
3164 ERR("Failed to copy semantic.\n");
3165 return E_OUTOFMEMORY
;
3167 TRACE("Variable semantic: %s.\n", debugstr_a(v
->semantic
));
3169 buffer_offset
= read_u32(ptr
);
3170 TRACE("Variable offset in buffer: %#x.\n", buffer_offset
);
3172 default_value_offset
= read_u32(ptr
);
3173 TRACE("Variable default value offset: %#x.\n", default_value_offset
);
3175 flags
= read_u32(ptr
);
3176 TRACE("Variable flags: %#x.\n", flags
);
3180 /* At this point storage offsets for members and array elements are relative to containing
3181 variable. Update them by moving to correct offset within a buffer. */
3182 d3d10_effect_variable_update_buffer_offsets(v
, buffer_offset
);
3186 if (default_value_offset
)
3188 if (!require_space(default_value_offset
, 1, v
->type
->size_packed
, data_size
))
3190 WARN("Invalid default value offset %#x, variable packed size %u.\n", default_value_offset
,
3191 v
->type
->size_packed
);
3195 data_ptr
= data
+ default_value_offset
;
3196 parse_fx10_default_value(&data_ptr
, v
);
3199 v
->annotations
.count
= read_u32(ptr
);
3200 TRACE("Variable has %u annotations.\n", v
->annotations
.count
);
3202 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, v
->effect
,
3205 ERR("Failed to parse variable annotations, hr %#lx.\n", hr
);
3210 if (v
->flag
& D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
)
3211 v
->explicit_bind_point
= v
->buffer_offset
;
3216 static HRESULT
create_state_object(struct d3d10_effect_variable
*v
)
3218 ID3D10Device
*device
= v
->effect
->device
;
3221 switch (v
->type
->basetype
)
3223 case D3D10_SVT_DEPTHSTENCIL
:
3224 if (FAILED(hr
= ID3D10Device_CreateDepthStencilState(device
,
3225 &v
->u
.state
.desc
.depth_stencil
, &v
->u
.state
.object
.depth_stencil
)))
3229 case D3D10_SVT_BLEND
:
3230 if (FAILED(hr
= ID3D10Device_CreateBlendState(device
,
3231 &v
->u
.state
.desc
.blend
, &v
->u
.state
.object
.blend
)))
3235 case D3D10_SVT_RASTERIZER
:
3236 if (FAILED(hr
= ID3D10Device_CreateRasterizerState(device
,
3237 &v
->u
.state
.desc
.rasterizer
, &v
->u
.state
.object
.rasterizer
)))
3241 case D3D10_SVT_SAMPLER
:
3242 if (FAILED(hr
= ID3D10Device_CreateSamplerState(device
,
3243 &v
->u
.state
.desc
.sampler
.desc
, &v
->u
.state
.object
.sampler
)))
3248 ERR("Unhandled variable type %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
3255 static HRESULT
parse_fx10_object_variable(const char *data
, size_t data_size
,
3256 const char **ptr
, BOOL shared_type_desc
, struct d3d10_effect_variable
*v
)
3258 struct d3d10_effect_var_array
*vars
;
3259 struct d3d10_effect_variable
*var
;
3260 unsigned int i
, j
, element_count
;
3264 if (FAILED(hr
= parse_fx10_variable_head(data
, data_size
, ptr
, v
)))
3267 offset
= read_u32(ptr
);
3268 TRACE("Variable semantic at offset %#x.\n", offset
);
3270 if (!fx10_copy_string(data
, data_size
, offset
, &v
->semantic
))
3272 ERR("Failed to copy semantic.\n");
3273 return E_OUTOFMEMORY
;
3275 TRACE("Variable semantic: %s.\n", debugstr_a(v
->semantic
));
3277 v
->explicit_bind_point
= read_u32(ptr
);
3278 TRACE("Variable explicit bind point %#x.\n", v
->explicit_bind_point
);
3280 /* Shared variable description contains only type information. */
3281 if (shared_type_desc
) return S_OK
;
3283 element_count
= max(v
->type
->element_count
, 1);
3285 switch (v
->type
->basetype
)
3287 case D3D10_SVT_TEXTURE
:
3288 case D3D10_SVT_TEXTURE1D
:
3289 case D3D10_SVT_TEXTURE1DARRAY
:
3290 case D3D10_SVT_TEXTURE2D
:
3291 case D3D10_SVT_TEXTURE2DARRAY
:
3292 case D3D10_SVT_TEXTURE2DMS
:
3293 case D3D10_SVT_TEXTURE2DMSARRAY
:
3294 case D3D10_SVT_TEXTURE3D
:
3295 case D3D10_SVT_TEXTURECUBE
:
3296 if (!(v
->u
.resource
.srv
= calloc(element_count
, sizeof(*v
->u
.resource
.srv
))))
3298 ERR("Failed to allocate shader resource view array memory.\n");
3299 return E_OUTOFMEMORY
;
3301 v
->u
.resource
.parent
= TRUE
;
3305 for (i
= 0; i
< v
->type
->element_count
; ++i
)
3307 v
->elements
[i
].u
.resource
.srv
= &v
->u
.resource
.srv
[i
];
3308 v
->elements
[i
].u
.resource
.parent
= FALSE
;
3313 case D3D10_SVT_RENDERTARGETVIEW
:
3314 case D3D10_SVT_DEPTHSTENCILVIEW
:
3315 case D3D10_SVT_BUFFER
:
3316 TRACE("SVT could not have elements.\n");
3319 case D3D10_SVT_VERTEXSHADER
:
3320 case D3D10_SVT_PIXELSHADER
:
3321 case D3D10_SVT_GEOMETRYSHADER
:
3322 TRACE("Shader type is %s\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
3323 for (i
= 0; i
< element_count
; ++i
)
3325 uint32_t shader_offset
, sodecl_offset
;
3327 var
= d3d10_array_get_element(v
, i
);
3329 shader_offset
= read_u32(ptr
);
3330 TRACE("Shader offset: %#x.\n", shader_offset
);
3332 if (v
->type
->flags
& D3D10_EOT_FLAG_GS_SO
)
3334 sodecl_offset
= read_u32(ptr
);
3335 TRACE("Stream output declaration at offset %#x.\n", sodecl_offset
);
3337 if (!fx10_copy_string(data
, data_size
, sodecl_offset
,
3338 &var
->u
.shader
.stream_output_declaration
))
3340 ERR("Failed to copy stream output declaration.\n");
3341 return E_OUTOFMEMORY
;
3344 TRACE("Stream output declaration: %s.\n", debugstr_a(var
->u
.shader
.stream_output_declaration
));
3347 if (FAILED(hr
= parse_fx10_shader(data
, data_size
, shader_offset
, var
)))
3352 case D3D10_SVT_DEPTHSTENCIL
:
3353 case D3D10_SVT_BLEND
:
3354 case D3D10_SVT_RASTERIZER
:
3355 case D3D10_SVT_SAMPLER
:
3357 const struct d3d10_effect_state_storage_info
*storage_info
;
3359 if (!(storage_info
= get_storage_info(v
->type
->basetype
)))
3361 FIXME("Failed to get backing store info for type %s.\n",
3362 debug_d3d10_shader_variable_type(v
->type
->basetype
));
3366 if (storage_info
->size
> sizeof(v
->u
.state
.desc
))
3368 ERR("Invalid storage size %#Ix.\n", storage_info
->size
);
3372 switch (v
->type
->basetype
)
3374 case D3D10_SVT_DEPTHSTENCIL
:
3375 vars
= &v
->effect
->ds_states
;
3377 case D3D10_SVT_BLEND
:
3378 vars
= &v
->effect
->blend_states
;
3380 case D3D10_SVT_RASTERIZER
:
3381 vars
= &v
->effect
->rs_states
;
3383 case D3D10_SVT_SAMPLER
:
3384 vars
= &v
->effect
->samplers
;
3390 for (i
= 0; i
< element_count
; ++i
)
3392 unsigned int prop_count
;
3394 var
= d3d10_array_get_element(v
, i
);
3396 if (vars
->current
>= vars
->count
)
3398 WARN("Wrong variable array size for %#x.\n", v
->type
->basetype
);
3401 var
->u
.state
.index
= vars
->current
;
3402 vars
->v
[vars
->current
++] = var
;
3404 prop_count
= read_u32(ptr
);
3405 TRACE("State object property count: %#x.\n", prop_count
);
3407 memcpy(&var
->u
.state
.desc
, storage_info
->default_state
, storage_info
->size
);
3409 for (j
= 0; j
< prop_count
; ++j
)
3411 if (FAILED(hr
= parse_fx10_property_assignment(data
, data_size
, ptr
,
3412 get_var_container_type(var
), var
->effect
, &var
->u
.state
.desc
,
3413 &var
->u
.state
.dependencies
)))
3415 ERR("Failed to read property list.\n");
3420 if (FAILED(hr
= create_state_object(var
)))
3427 FIXME("Unhandled case %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
3431 v
->annotations
.count
= read_u32(ptr
);
3432 TRACE("Variable has %u annotations.\n", v
->annotations
.count
);
3434 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, v
->effect
,
3437 ERR("Failed to parse variable annotations, hr %#lx.\n", hr
);
3444 static HRESULT
create_buffer_object(struct d3d10_effect_variable
*v
)
3446 D3D10_BUFFER_DESC buffer_desc
;
3447 D3D10_SUBRESOURCE_DATA subresource_data
;
3448 D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc
;
3449 ID3D10Device
*device
= v
->effect
->device
;
3452 buffer_desc
.ByteWidth
= v
->data_size
;
3453 buffer_desc
.Usage
= D3D10_USAGE_DEFAULT
;
3454 buffer_desc
.CPUAccessFlags
= 0;
3455 buffer_desc
.MiscFlags
= 0;
3456 if (v
->type
->basetype
== D3D10_SVT_CBUFFER
)
3457 buffer_desc
.BindFlags
= D3D10_BIND_CONSTANT_BUFFER
;
3459 buffer_desc
.BindFlags
= D3D10_BIND_SHADER_RESOURCE
;
3461 subresource_data
.pSysMem
= v
->u
.buffer
.local_buffer
;
3462 subresource_data
.SysMemPitch
= 0;
3463 subresource_data
.SysMemSlicePitch
= 0;
3465 if (FAILED(hr
= ID3D10Device_CreateBuffer(device
, &buffer_desc
, &subresource_data
, &v
->u
.buffer
.buffer
)))
3468 if (v
->type
->basetype
== D3D10_SVT_TBUFFER
)
3470 srv_desc
.Format
= DXGI_FORMAT_R32G32B32A32_UINT
;
3471 srv_desc
.ViewDimension
= D3D_SRV_DIMENSION_BUFFER
;
3472 srv_desc
.Buffer
.ElementOffset
= 0;
3473 srv_desc
.Buffer
.ElementWidth
= v
->type
->size_unpacked
/ 16;
3474 if (v
->type
->size_unpacked
% 16)
3475 WARN("Unexpected texture buffer size not a multiple of 16.\n");
3477 if (FAILED(hr
= ID3D10Device_CreateShaderResourceView(device
, (ID3D10Resource
*)v
->u
.buffer
.buffer
,
3478 &srv_desc
, &v
->u
.buffer
.resource_view
)))
3482 v
->u
.buffer
.resource_view
= NULL
;
3487 static HRESULT
parse_fx10_buffer(const char *data
, size_t data_size
, const char **ptr
,
3488 BOOL local
, struct d3d10_effect_variable
*l
)
3490 const char *prefix
= local
? "Local" : "Shared";
3493 D3D10_CBUFFER_TYPE d3d10_cbuffer_type
;
3495 unsigned int stride
= 0;
3497 /* Generate our own type, it isn't in the fx blob. */
3498 if (!(l
->type
= calloc(1, sizeof(*l
->type
))))
3500 ERR("Failed to allocate local buffer type memory.\n");
3501 return E_OUTOFMEMORY
;
3503 l
->type
->ID3D10EffectType_iface
.lpVtbl
= &d3d10_effect_type_vtbl
;
3504 l
->type
->type_class
= D3D10_SVC_OBJECT
;
3505 l
->type
->effect
= l
->effect
;
3507 offset
= read_u32(ptr
);
3508 TRACE("%s buffer name at offset %#x.\n", prefix
, offset
);
3510 if (!fx10_copy_string(data
, data_size
, offset
, &l
->name
))
3512 ERR("Failed to copy name.\n");
3513 return E_OUTOFMEMORY
;
3515 TRACE("%s buffer name: %s.\n", prefix
, debugstr_a(l
->name
));
3517 l
->data_size
= read_u32(ptr
);
3518 TRACE("%s buffer data size: %#x.\n", prefix
, l
->data_size
);
3520 d3d10_cbuffer_type
= read_u32(ptr
);
3521 TRACE("%s buffer type: %#x.\n", prefix
, d3d10_cbuffer_type
);
3523 switch(d3d10_cbuffer_type
)
3525 case D3D10_CT_CBUFFER
:
3526 l
->type
->basetype
= D3D10_SVT_CBUFFER
;
3527 if (!copy_name("cbuffer", &l
->type
->name
))
3529 ERR("Failed to copy name.\n");
3530 return E_OUTOFMEMORY
;
3534 case D3D10_CT_TBUFFER
:
3535 l
->type
->basetype
= D3D10_SVT_TBUFFER
;
3536 if (!copy_name("tbuffer", &l
->type
->name
))
3538 ERR("Failed to copy name.\n");
3539 return E_OUTOFMEMORY
;
3544 ERR("Unexpected D3D10_CBUFFER_TYPE %#x!\n", d3d10_cbuffer_type
);
3548 l
->type
->member_count
= read_u32(ptr
);
3549 TRACE("%s buffer member count: %#x.\n", prefix
, l
->type
->member_count
);
3551 l
->explicit_bind_point
= read_u32(ptr
);
3552 TRACE("%s buffer explicit bind point: %#x.\n", prefix
, l
->explicit_bind_point
);
3554 if (l
->effect
->flags
& D3D10_EFFECT_IS_POOL
)
3555 l
->flag
|= D3D10_EFFECT_VARIABLE_POOLED
;
3559 l
->annotations
.count
= read_u32(ptr
);
3560 TRACE("Local buffer has %u annotations.\n", l
->annotations
.count
);
3562 if (FAILED(hr
= parse_fx10_annotations(data
, data_size
, ptr
, l
->effect
,
3565 ERR("Failed to parse buffer annotations, hr %#lx.\n", hr
);
3570 if (!(l
->members
= calloc(l
->type
->member_count
, sizeof(*l
->members
))))
3572 ERR("Failed to allocate members memory.\n");
3573 return E_OUTOFMEMORY
;
3576 if (!(l
->type
->members
= calloc(l
->type
->member_count
, sizeof(*l
->type
->members
))))
3578 ERR("Failed to allocate type members memory.\n");
3579 return E_OUTOFMEMORY
;
3582 if (local
&& !(l
->u
.buffer
.local_buffer
= calloc(1, l
->data_size
)))
3584 ERR("Failed to allocate local constant buffer memory.\n");
3585 return E_OUTOFMEMORY
;
3588 for (i
= 0; i
< l
->type
->member_count
; ++i
)
3590 struct d3d10_effect_variable
*v
= &l
->members
[i
];
3591 struct d3d10_effect_type_member
*typem
= &l
->type
->members
[i
];
3594 v
->effect
= l
->effect
;
3596 if (FAILED(hr
= parse_fx10_numeric_variable(data
, data_size
, ptr
, local
, v
)))
3600 * Copy the values from the variable type to the constant buffers type
3601 * members structure, because it is our own generated type.
3603 typem
->type
= v
->type
;
3605 if (!copy_name(v
->name
, &typem
->name
))
3607 ERR("Failed to copy name.\n");
3608 return E_OUTOFMEMORY
;
3610 TRACE("Variable name: %s.\n", debugstr_a(typem
->name
));
3612 if (!copy_name(v
->semantic
, &typem
->semantic
))
3614 ERR("Failed to copy name.\n");
3615 return E_OUTOFMEMORY
;
3617 TRACE("Variable semantic: %s.\n", debugstr_a(typem
->semantic
));
3619 typem
->buffer_offset
= v
->buffer_offset
;
3620 TRACE("Variable buffer offset: %u.\n", typem
->buffer_offset
);
3622 l
->type
->size_packed
+= v
->type
->size_packed
;
3625 * For the complete constantbuffer the size_unpacked = stride,
3626 * the stride is calculated like this:
3628 * 1) if the constant buffer variables are packed with packoffset
3629 * - stride = the highest used constant
3630 * - the complete stride has to be a multiple of 0x10
3632 * 2) if the constant buffer variables are NOT packed with packoffset
3633 * - sum of unpacked size for all variables which fit in a 0x10 part
3634 * - if the size exceeds a 0x10 part, the rest of the old part is skipped
3635 * and a new part is started
3636 * - if the variable is a struct it is always used a new part
3637 * - the complete stride has to be a multiple of 0x10
3640 * 0x4, 0x4, 0x4, 0x8, 0x4, 0x14, 0x4
3641 * part 0x10 0x10 0x20 -> 0x40
3643 if (v
->flag
& D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
)
3645 if ((v
->type
->size_unpacked
+ v
->buffer_offset
) > stride
)
3647 stride
= v
->type
->size_unpacked
+ v
->buffer_offset
;
3652 if (v
->type
->type_class
== D3D10_SVC_STRUCT
)
3654 stride
= (stride
+ 0xf) & ~0xf;
3657 if ( ((stride
& 0xf) + v
->type
->size_unpacked
) > 0x10)
3659 stride
= (stride
+ 0xf) & ~0xf;
3662 stride
+= v
->type
->size_unpacked
;
3665 l
->type
->stride
= l
->type
->size_unpacked
= (stride
+ 0xf) & ~0xf;
3667 TRACE("%s constant buffer:\n", prefix
);
3668 TRACE("\tType name: %s.\n", debugstr_a(l
->type
->name
));
3669 TRACE("\tElement count: %u.\n", l
->type
->element_count
);
3670 TRACE("\tMember count: %u.\n", l
->type
->member_count
);
3671 TRACE("\tUnpacked size: %#x.\n", l
->type
->size_unpacked
);
3672 TRACE("\tStride: %#x.\n", l
->type
->stride
);
3673 TRACE("\tPacked size %#x.\n", l
->type
->size_packed
);
3674 TRACE("\tBasetype: %s.\n", debug_d3d10_shader_variable_type(l
->type
->basetype
));
3675 TRACE("\tTypeclass: %s.\n", debug_d3d10_shader_variable_class(l
->type
->type_class
));
3677 if (local
&& l
->data_size
)
3679 if (FAILED(hr
= create_buffer_object(l
)))
3681 WARN("Failed to create a buffer object, hr %#lx.\n", hr
);
3686 if (l
->explicit_bind_point
!= ~0u)
3687 l
->flag
|= D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
;
3692 static void d3d10_effect_type_member_destroy(struct d3d10_effect_type_member
*typem
)
3694 TRACE("effect type member %p.\n", typem
);
3696 /* Do not release typem->type, it will be covered by d3d10_effect_type_destroy(). */
3697 free(typem
->semantic
);
3701 static void d3d10_effect_type_destroy(struct wine_rb_entry
*entry
, void *context
)
3703 struct d3d10_effect_type
*t
= WINE_RB_ENTRY_VALUE(entry
, struct d3d10_effect_type
, entry
);
3705 TRACE("effect type %p.\n", t
);
3709 free(t
->elementtype
->name
);
3710 free(t
->elementtype
);
3717 for (i
= 0; i
< t
->member_count
; ++i
)
3719 d3d10_effect_type_member_destroy(&t
->members
[i
]);
3728 static BOOL
d3d10_effect_types_match(const struct d3d10_effect_type
*t1
,
3729 const struct d3d10_effect_type
*t2
)
3733 if (strcmp(t1
->name
, t2
->name
)) return FALSE
;
3734 if (t1
->basetype
!= t2
->basetype
) return FALSE
;
3735 if (t1
->type_class
!= t2
->type_class
) return FALSE
;
3736 if (t1
->element_count
!= t2
->element_count
) return FALSE
;
3737 if (t1
->element_count
) return d3d10_effect_types_match(t1
->elementtype
, t2
->elementtype
);
3738 if (t1
->member_count
!= t2
->member_count
) return FALSE
;
3739 if (t1
->column_count
!= t2
->column_count
) return FALSE
;
3740 if (t1
->row_count
!= t2
->row_count
) return FALSE
;
3742 for (i
= 0; i
< t1
->member_count
; ++i
)
3744 if (strcmp(t1
->members
[i
].name
, t2
->members
[i
].name
)) return FALSE
;
3745 if (t1
->members
[i
].buffer_offset
!= t2
->members
[i
].buffer_offset
) return FALSE
;
3746 if (!d3d10_effect_types_match(t1
->members
[i
].type
, t2
->members
[i
].type
)) return FALSE
;
3752 static HRESULT
d3d10_effect_validate_shared_variable(const struct d3d10_effect
*effect
,
3753 const struct d3d10_effect_variable
*v
)
3755 struct d3d10_effect_variable
*sv
;
3757 switch (v
->type
->basetype
)
3759 case D3D10_SVT_CBUFFER
:
3760 case D3D10_SVT_TBUFFER
:
3761 sv
= d3d10_effect_get_buffer_by_name(effect
->pool
, v
->name
);
3764 sv
= d3d10_effect_get_variable_by_name(effect
->pool
, v
->name
);
3769 WARN("Variable %s wasn't found in the pool.\n", debugstr_a(v
->name
));
3770 return E_INVALIDARG
;
3773 if (!d3d10_effect_types_match(sv
->type
, v
->type
))
3775 WARN("Variable %s type does not match pool type.\n", debugstr_a(v
->name
));
3776 return E_INVALIDARG
;
3782 static HRESULT
parse_fx10_body(struct d3d10_effect
*e
, const char *data
, size_t data_size
)
3788 if (e
->index_offset
>= data_size
)
3790 WARN("Invalid index offset %#x (data size %#Ix).\n", e
->index_offset
, data_size
);
3793 ptr
= data
+ e
->index_offset
;
3795 if (!(e
->local_buffers
= calloc(e
->local_buffer_count
, sizeof(*e
->local_buffers
))))
3797 ERR("Failed to allocate local buffer memory.\n");
3798 return E_OUTOFMEMORY
;
3801 if (!(e
->local_variables
= calloc(e
->local_variable_count
, sizeof(*e
->local_variables
))))
3803 ERR("Failed to allocate local variable memory.\n");
3804 return E_OUTOFMEMORY
;
3807 if (!(e
->anonymous_shaders
= calloc(e
->anonymous_shader_count
, sizeof(*e
->anonymous_shaders
))))
3809 ERR("Failed to allocate anonymous shaders memory\n");
3810 return E_OUTOFMEMORY
;
3813 if (!(e
->shaders
.v
= calloc(e
->shaders
.count
, sizeof(*e
->shaders
.v
))))
3815 ERR("Failed to allocate used shaders memory\n");
3816 return E_OUTOFMEMORY
;
3819 if (!(e
->samplers
.v
= calloc(e
->samplers
.count
, sizeof(*e
->samplers
.v
))))
3821 ERR("Failed to allocate samplers array.\n");
3822 return E_OUTOFMEMORY
;
3825 if (!(e
->blend_states
.v
= calloc(e
->blend_states
.count
, sizeof(*e
->blend_states
.v
))))
3827 ERR("Failed to allocate blend states array.\n");
3828 return E_OUTOFMEMORY
;
3831 if (!(e
->ds_states
.v
= calloc(e
->ds_states
.count
, sizeof(*e
->ds_states
.v
))))
3833 ERR("Failed to allocate depth stencil states array.\n");
3834 return E_OUTOFMEMORY
;
3837 if (!(e
->rs_states
.v
= calloc(e
->rs_states
.count
, sizeof(*e
->rs_states
.v
))))
3839 ERR("Failed to allocate rasterizer states array.\n");
3840 return E_OUTOFMEMORY
;
3843 if (!(e
->techniques
= calloc(e
->technique_count
, sizeof(*e
->techniques
))))
3845 ERR("Failed to allocate techniques memory\n");
3846 return E_OUTOFMEMORY
;
3849 for (i
= 0; i
< e
->local_buffer_count
; ++i
)
3851 struct d3d10_effect_variable
*l
= &e
->local_buffers
[i
];
3852 l
->ID3D10EffectVariable_iface
.lpVtbl
= (const ID3D10EffectVariableVtbl
*)&d3d10_effect_constant_buffer_vtbl
;
3854 l
->buffer
= &null_local_buffer
;
3856 if (FAILED(hr
= parse_fx10_buffer(data
, data_size
, &ptr
, TRUE
, l
)))
3860 for (i
= 0; i
< e
->local_variable_count
; ++i
)
3862 struct d3d10_effect_variable
*v
= &e
->local_variables
[i
];
3865 v
->ID3D10EffectVariable_iface
.lpVtbl
= &d3d10_effect_variable_vtbl
;
3866 v
->buffer
= &null_local_buffer
;
3868 if (FAILED(hr
= parse_fx10_object_variable(data
, data_size
, &ptr
, FALSE
, v
)))
3872 for (i
= 0; i
< e
->shared_buffer_count
; ++i
)
3874 struct d3d10_effect_variable b
= {{ 0 }};
3878 if (FAILED(hr
= parse_fx10_buffer(data
, data_size
, &ptr
, FALSE
, &b
)))
3880 d3d10_effect_variable_destroy(&b
);
3884 hr
= d3d10_effect_validate_shared_variable(e
, &b
);
3885 d3d10_effect_variable_destroy(&b
);
3886 if (FAILED(hr
)) return hr
;
3889 for (i
= 0; i
< e
->shared_object_count
; ++i
)
3891 struct d3d10_effect_variable o
= {{ 0 }};
3895 if (FAILED(hr
= parse_fx10_object_variable(data
, data_size
, &ptr
, TRUE
, &o
)))
3897 d3d10_effect_variable_destroy(&o
);
3901 hr
= d3d10_effect_validate_shared_variable(e
, &o
);
3902 d3d10_effect_variable_destroy(&o
);
3903 if (FAILED(hr
)) return hr
;
3906 for (i
= 0; i
< e
->technique_count
; ++i
)
3908 struct d3d10_effect_technique
*t
= &e
->techniques
[i
];
3910 t
->ID3D10EffectTechnique_iface
.lpVtbl
= &d3d10_effect_technique_vtbl
;
3913 if (FAILED(hr
= parse_fx10_technique(data
, data_size
, &ptr
, t
)))
3920 static HRESULT
parse_fx10(struct d3d10_effect
*e
, const char *data
, size_t data_size
)
3922 const char *ptr
= data
;
3925 if (!require_space(0, 19, sizeof(uint32_t), data_size
))
3927 WARN("Invalid data size %#Ix.\n", data_size
);
3928 return E_INVALIDARG
;
3931 /* Compiled target version (e.g. fx_4_0=0xfeff1001, fx_4_1=0xfeff1011). */
3932 e
->version
= read_u32(&ptr
);
3933 TRACE("Target: %#x.\n", e
->version
);
3935 e
->local_buffer_count
= read_u32(&ptr
);
3936 TRACE("Local buffer count: %u.\n", e
->local_buffer_count
);
3938 e
->variable_count
= read_u32(&ptr
);
3939 TRACE("Variable count: %u.\n", e
->variable_count
);
3941 e
->local_variable_count
= read_u32(&ptr
);
3942 TRACE("Object count: %u.\n", e
->local_variable_count
);
3944 e
->shared_buffer_count
= read_u32(&ptr
);
3945 TRACE("Pool buffer count: %u.\n", e
->shared_buffer_count
);
3947 unused
= read_u32(&ptr
);
3948 TRACE("Pool variable count: %u.\n", unused
);
3950 e
->shared_object_count
= read_u32(&ptr
);
3951 TRACE("Pool objects count: %u.\n", e
->shared_object_count
);
3953 e
->technique_count
= read_u32(&ptr
);
3954 TRACE("Technique count: %u.\n", e
->technique_count
);
3956 e
->index_offset
= read_u32(&ptr
);
3957 TRACE("Index offset: %#x.\n", e
->index_offset
);
3959 unused
= read_u32(&ptr
);
3960 TRACE("String count: %u.\n", unused
);
3962 e
->texture_count
= read_u32(&ptr
);
3963 TRACE("Texture count: %u.\n", e
->texture_count
);
3965 e
->ds_states
.count
= read_u32(&ptr
);
3966 TRACE("Depthstencilstate count: %u.\n", e
->ds_states
.count
);
3968 e
->blend_states
.count
= read_u32(&ptr
);
3969 TRACE("Blendstate count: %u.\n", e
->blend_states
.count
);
3971 e
->rs_states
.count
= read_u32(&ptr
);
3972 TRACE("Rasterizerstate count: %u.\n", e
->rs_states
.count
);
3974 e
->samplers
.count
= read_u32(&ptr
);
3975 TRACE("Samplerstate count: %u.\n", e
->samplers
.count
);
3977 e
->rtvs
.count
= read_u32(&ptr
);
3978 TRACE("Rendertargetview count: %u.\n", e
->rtvs
.count
);
3980 e
->dsvs
.count
= read_u32(&ptr
);
3981 TRACE("Depthstencilview count: %u.\n", e
->dsvs
.count
);
3983 e
->shaders
.count
= read_u32(&ptr
);
3984 TRACE("Used shader count: %u.\n", e
->shaders
.count
);
3986 e
->anonymous_shader_count
= read_u32(&ptr
);
3987 TRACE("Anonymous shader count: %u.\n", e
->anonymous_shader_count
);
3989 if (!e
->pool
&& (e
->shared_object_count
|| e
->shared_buffer_count
))
3991 WARN("Effect requires a pool to load.\n");
3995 return parse_fx10_body(e
, ptr
, data_size
- (ptr
- data
));
3998 HRESULT
d3d10_effect_parse(struct d3d10_effect
*effect
, const void *data
, SIZE_T data_size
)
4000 const struct vkd3d_shader_code dxbc
= {.code
= data
, .size
= data_size
};
4001 const struct vkd3d_shader_dxbc_section_desc
*section
;
4002 struct vkd3d_shader_dxbc_desc dxbc_desc
;
4007 if ((ret
= vkd3d_shader_parse_dxbc(&dxbc
, 0, &dxbc_desc
, NULL
)) < 0)
4009 WARN("Failed to parse DXBC, ret %d.\n", ret
);
4013 for (i
= 0; i
< dxbc_desc
.section_count
; ++i
)
4015 section
= &dxbc_desc
.sections
[i
];
4017 TRACE("Section %u: tag %s, data {%p, %#Ix}.\n",
4018 i
, debugstr_an((const char *)§ion
->tag
, 4),
4019 section
->data
.code
, section
->data
.size
);
4021 if (section
->tag
!= TAG_FX10
)
4023 FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)§ion
->tag
, 4));
4027 if (FAILED(hr
= parse_fx10(effect
, section
->data
.code
, section
->data
.size
)))
4031 vkd3d_shader_free_dxbc(&dxbc_desc
);
4036 static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_variable
*s
,
4037 D3D10_SHADER_VARIABLE_TYPE type
)
4040 s
->reflection
->lpVtbl
->Release(s
->reflection
);
4041 if (s
->input_signature
)
4042 ID3D10Blob_Release(s
->input_signature
);
4044 ID3D10Blob_Release(s
->bytecode
);
4048 case D3D10_SVT_VERTEXSHADER
:
4049 case D3D10_SVT_PIXELSHADER
:
4050 case D3D10_SVT_GEOMETRYSHADER
:
4051 if (s
->shader
.object
)
4052 IUnknown_Release(s
->shader
.object
);
4056 FIXME("Unhandled shader type %s.\n", debug_d3d10_shader_variable_type(type
));
4060 if (s
->resource_count
)
4064 static void d3d10_effect_annotations_destroy(struct d3d10_effect_annotations
*a
)
4068 if (!a
->elements
) return;
4070 for (i
= 0; i
< a
->count
; ++i
)
4071 d3d10_effect_variable_destroy(&a
->elements
[i
]);
4077 static void d3d10_effect_variable_destroy(struct d3d10_effect_variable
*v
)
4079 unsigned int i
, elem_count
;
4081 TRACE("variable %p.\n", v
);
4085 d3d10_effect_annotations_destroy(&v
->annotations
);
4089 for (i
= 0; i
< v
->type
->member_count
; ++i
)
4091 d3d10_effect_variable_destroy(&v
->members
[i
]);
4098 for (i
= 0; i
< v
->type
->element_count
; ++i
)
4100 d3d10_effect_variable_destroy(&v
->elements
[i
]);
4107 switch (v
->type
->basetype
)
4109 case D3D10_SVT_VERTEXSHADER
:
4110 case D3D10_SVT_PIXELSHADER
:
4111 case D3D10_SVT_GEOMETRYSHADER
:
4112 d3d10_effect_shader_variable_destroy(&v
->u
.shader
, v
->type
->basetype
);
4115 case D3D10_SVT_DEPTHSTENCIL
:
4116 case D3D10_SVT_BLEND
:
4117 case D3D10_SVT_RASTERIZER
:
4118 case D3D10_SVT_SAMPLER
:
4119 if (v
->u
.state
.object
.object
)
4120 IUnknown_Release(v
->u
.state
.object
.object
);
4121 d3d10_effect_clear_prop_dependencies(&v
->u
.state
.dependencies
);
4124 case D3D10_SVT_TEXTURE1D
:
4125 case D3D10_SVT_TEXTURE1DARRAY
:
4126 case D3D10_SVT_TEXTURE2D
:
4127 case D3D10_SVT_TEXTURE2DARRAY
:
4128 case D3D10_SVT_TEXTURE2DMS
:
4129 case D3D10_SVT_TEXTURE2DMSARRAY
:
4130 case D3D10_SVT_TEXTURE3D
:
4131 case D3D10_SVT_TEXTURECUBE
:
4132 if (!v
->u
.resource
.parent
)
4135 if (!v
->type
->element_count
)
4138 elem_count
= v
->type
->element_count
;
4140 for (i
= 0; i
< elem_count
; ++i
)
4142 if (v
->u
.resource
.srv
[i
])
4143 ID3D10ShaderResourceView_Release(v
->u
.resource
.srv
[i
]);
4146 free(v
->u
.resource
.srv
);
4149 case D3D10_SVT_STRING
:
4150 free(v
->u
.buffer
.local_buffer
);
4159 static void d3d10_effect_pass_destroy(struct d3d10_effect_pass
*p
)
4161 TRACE("pass %p\n", p
);
4164 d3d10_effect_annotations_destroy(&p
->annotations
);
4165 d3d10_effect_clear_prop_dependencies(&p
->dependencies
);
4168 static void d3d10_effect_technique_destroy(struct d3d10_effect_technique
*t
)
4172 TRACE("technique %p\n", t
);
4177 for (i
= 0; i
< t
->pass_count
; ++i
)
4179 d3d10_effect_pass_destroy(&t
->passes
[i
]);
4184 d3d10_effect_annotations_destroy(&t
->annotations
);
4187 static void d3d10_effect_local_buffer_destroy(struct d3d10_effect_variable
*l
)
4191 TRACE("local buffer %p.\n", l
);
4196 for (i
= 0; i
< l
->type
->member_count
; ++i
)
4198 d3d10_effect_variable_destroy(&l
->members
[i
]);
4204 d3d10_effect_type_destroy(&l
->type
->entry
, NULL
);
4206 d3d10_effect_annotations_destroy(&l
->annotations
);
4207 free(l
->u
.buffer
.local_buffer
);
4209 if (l
->u
.buffer
.buffer
)
4210 ID3D10Buffer_Release(l
->u
.buffer
.buffer
);
4211 if (l
->u
.buffer
.resource_view
)
4212 ID3D10ShaderResourceView_Release(l
->u
.buffer
.resource_view
);
4215 /* IUnknown methods */
4217 static inline struct d3d10_effect
*impl_from_ID3D10Effect(ID3D10Effect
*iface
)
4219 return CONTAINING_RECORD(iface
, struct d3d10_effect
, ID3D10Effect_iface
);
4222 static HRESULT STDMETHODCALLTYPE
d3d10_effect_QueryInterface(ID3D10Effect
*iface
, REFIID riid
, void **object
)
4224 TRACE("iface %p, riid %s, object %p\n", iface
, debugstr_guid(riid
), object
);
4226 if (IsEqualGUID(riid
, &IID_ID3D10Effect
)
4227 || IsEqualGUID(riid
, &IID_IUnknown
))
4229 IUnknown_AddRef(iface
);
4234 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
4237 return E_NOINTERFACE
;
4240 static ULONG STDMETHODCALLTYPE
d3d10_effect_AddRef(ID3D10Effect
*iface
)
4242 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4243 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
4245 TRACE("%p increasing refcount to %lu.\n", This
, refcount
);
4250 static ULONG STDMETHODCALLTYPE
d3d10_effect_Release(ID3D10Effect
*iface
)
4252 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4253 ULONG refcount
= InterlockedDecrement(&effect
->refcount
);
4255 TRACE("%p decreasing refcount to %lu.\n", iface
, refcount
);
4261 if (effect
->techniques
)
4263 for (i
= 0; i
< effect
->technique_count
; ++i
)
4265 d3d10_effect_technique_destroy(&effect
->techniques
[i
]);
4267 free(effect
->techniques
);
4270 if (effect
->local_variables
)
4272 for (i
= 0; i
< effect
->local_variable_count
; ++i
)
4274 d3d10_effect_variable_destroy(&effect
->local_variables
[i
]);
4276 free(effect
->local_variables
);
4279 if (effect
->local_buffers
)
4281 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4283 d3d10_effect_local_buffer_destroy(&effect
->local_buffers
[i
]);
4285 free(effect
->local_buffers
);
4288 if (effect
->anonymous_shaders
)
4290 for (i
= 0; i
< effect
->anonymous_shader_count
; ++i
)
4292 d3d10_effect_variable_destroy(&effect
->anonymous_shaders
[i
].shader
);
4293 free(effect
->anonymous_shaders
[i
].type
.name
);
4295 free(effect
->anonymous_shaders
);
4298 free(effect
->shaders
.v
);
4299 free(effect
->samplers
.v
);
4300 free(effect
->rtvs
.v
);
4301 free(effect
->dsvs
.v
);
4302 free(effect
->blend_states
.v
);
4303 free(effect
->ds_states
.v
);
4304 free(effect
->rs_states
.v
);
4306 wine_rb_destroy(&effect
->types
, d3d10_effect_type_destroy
, NULL
);
4309 IUnknown_Release(&effect
->pool
->ID3D10Effect_iface
);
4310 ID3D10Device_Release(effect
->device
);
4317 /* ID3D10Effect methods */
4319 static BOOL STDMETHODCALLTYPE
d3d10_effect_IsValid(ID3D10Effect
*iface
)
4321 FIXME("iface %p stub!\n", iface
);
4326 static BOOL STDMETHODCALLTYPE
d3d10_effect_IsPool(ID3D10Effect
*iface
)
4328 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4330 TRACE("iface %p.\n", iface
);
4332 return effect
->ID3D10Effect_iface
.lpVtbl
== &d3d10_effect_pool_effect_vtbl
;
4335 static HRESULT STDMETHODCALLTYPE
d3d10_effect_GetDevice(ID3D10Effect
*iface
, ID3D10Device
**device
)
4337 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4339 TRACE("iface %p, device %p\n", iface
, device
);
4341 ID3D10Device_AddRef(This
->device
);
4342 *device
= This
->device
;
4347 static void d3d10_effect_get_desc(const struct d3d10_effect
*effect
, D3D10_EFFECT_DESC
*desc
)
4351 desc
->IsChildEffect
= !!effect
->pool
;
4352 desc
->ConstantBuffers
= effect
->local_buffer_count
;
4353 desc
->SharedConstantBuffers
= 0;
4354 desc
->GlobalVariables
= effect
->local_variable_count
;
4355 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4357 desc
->GlobalVariables
+= effect
->local_buffers
[i
].type
->member_count
;
4359 desc
->SharedGlobalVariables
= 0;
4360 desc
->Techniques
= effect
->technique_count
;
4363 static HRESULT STDMETHODCALLTYPE
d3d10_effect_GetDesc(ID3D10Effect
*iface
, D3D10_EFFECT_DESC
*desc
)
4365 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4366 D3D10_EFFECT_DESC pool_desc
= { 0 };
4368 TRACE("iface %p, desc %p.\n", iface
, desc
);
4371 return E_INVALIDARG
;
4374 d3d10_effect_get_desc(effect
->pool
, &pool_desc
);
4376 d3d10_effect_get_desc(effect
, desc
);
4378 desc
->SharedConstantBuffers
= pool_desc
.ConstantBuffers
;
4379 desc
->SharedGlobalVariables
= pool_desc
.GlobalVariables
;
4384 static struct d3d10_effect_variable
* d3d10_effect_get_buffer_by_index(struct d3d10_effect
*effect
,
4387 if (index
< effect
->local_buffer_count
)
4388 return &effect
->local_buffers
[index
];
4389 index
-= effect
->local_buffer_count
;
4391 return effect
->pool
? d3d10_effect_get_buffer_by_index(effect
->pool
, index
) : NULL
;
4394 static BOOL
is_var_shared(const struct d3d10_effect_variable
*v
)
4396 return !!(v
->flag
& D3D10_EFFECT_VARIABLE_POOLED
);
4399 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_GetConstantBufferByIndex(ID3D10Effect
*iface
,
4402 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4403 struct d3d10_effect_variable
*v
;
4405 TRACE("iface %p, index %u\n", iface
, index
);
4407 if ((v
= d3d10_effect_get_buffer_by_index(effect
, index
)))
4409 TRACE("Returning %sbuffer %p, name %s.\n", is_var_shared(v
) ? "shared " : "", v
,
4410 debugstr_a(v
->name
));
4411 return (ID3D10EffectConstantBuffer
*)&v
->ID3D10EffectVariable_iface
;
4414 WARN("Invalid index specified\n");
4416 return (ID3D10EffectConstantBuffer
*)&null_local_buffer
.ID3D10EffectVariable_iface
;
4419 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_GetConstantBufferByName(ID3D10Effect
*iface
,
4422 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4423 struct d3d10_effect_variable
*v
;
4425 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4427 if ((v
= d3d10_effect_get_buffer_by_name(effect
, name
)))
4429 TRACE("Returning %sbuffer %p.\n", is_var_shared(v
) ? "shared " : "", v
);
4430 return (ID3D10EffectConstantBuffer
*)&v
->ID3D10EffectVariable_iface
;
4433 WARN("Invalid name specified\n");
4435 return (ID3D10EffectConstantBuffer
*)&null_local_buffer
.ID3D10EffectVariable_iface
;
4438 static struct d3d10_effect_variable
* d3d10_effect_get_variable_by_index(
4439 const struct d3d10_effect
*effect
, unsigned int index
)
4443 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4445 struct d3d10_effect_variable
*v
= &effect
->local_buffers
[i
];
4446 if (index
< v
->type
->member_count
)
4447 return &v
->members
[index
];
4448 index
-= v
->type
->member_count
;
4451 if (index
< effect
->local_variable_count
)
4452 return &effect
->local_variables
[index
];
4453 index
-= effect
->local_variable_count
;
4455 return effect
->pool
? d3d10_effect_get_variable_by_index(effect
->pool
, index
) : NULL
;
4458 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_GetVariableByIndex(ID3D10Effect
*iface
, UINT index
)
4460 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4461 struct d3d10_effect_variable
*v
;
4463 TRACE("iface %p, index %u\n", iface
, index
);
4465 if ((v
= d3d10_effect_get_variable_by_index(effect
, index
)))
4467 TRACE("Returning %svariable %s.\n", is_var_shared(v
) ? "shared " : "", debugstr_a(v
->name
));
4468 return &v
->ID3D10EffectVariable_iface
;
4471 WARN("Invalid index specified\n");
4473 return &null_variable
.ID3D10EffectVariable_iface
;
4476 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_GetVariableByName(ID3D10Effect
*iface
,
4479 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4480 struct d3d10_effect_variable
*v
;
4482 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4486 WARN("Invalid name specified\n");
4487 return &null_variable
.ID3D10EffectVariable_iface
;
4490 if ((v
= d3d10_effect_get_variable_by_name(effect
, name
)))
4492 TRACE("Returning %svariable %p.\n", is_var_shared(v
) ? "shared " : "", v
);
4493 return &v
->ID3D10EffectVariable_iface
;
4496 WARN("Invalid name specified\n");
4498 return &null_variable
.ID3D10EffectVariable_iface
;
4501 static struct d3d10_effect_variable
* d3d10_effect_get_variable_by_semantic(
4502 const struct d3d10_effect
*effect
, const char *semantic
)
4506 for (i
= 0; i
< effect
->local_buffer_count
; ++i
)
4508 struct d3d10_effect_variable
*l
= &effect
->local_buffers
[i
];
4511 for (j
= 0; j
< l
->type
->member_count
; ++j
)
4513 struct d3d10_effect_variable
*v
= &l
->members
[j
];
4515 if (v
->semantic
&& !stricmp(v
->semantic
, semantic
))
4520 for (i
= 0; i
< effect
->local_variable_count
; ++i
)
4522 struct d3d10_effect_variable
*v
= &effect
->local_variables
[i
];
4524 if (v
->semantic
&& !stricmp(v
->semantic
, semantic
))
4528 return effect
->pool
? d3d10_effect_get_variable_by_semantic(effect
->pool
, semantic
) : NULL
;
4531 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_GetVariableBySemantic(ID3D10Effect
*iface
,
4532 const char *semantic
)
4534 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4535 struct d3d10_effect_variable
*v
;
4537 TRACE("iface %p, semantic %s\n", iface
, debugstr_a(semantic
));
4541 WARN("Invalid semantic specified\n");
4542 return &null_variable
.ID3D10EffectVariable_iface
;
4545 if ((v
= d3d10_effect_get_variable_by_semantic(effect
, semantic
)))
4547 TRACE("Returning %svariable %s.\n", is_var_shared(v
) ? "shared " : "", debugstr_a(v
->name
));
4548 return &v
->ID3D10EffectVariable_iface
;
4551 WARN("Invalid semantic specified\n");
4553 return &null_variable
.ID3D10EffectVariable_iface
;
4556 static struct ID3D10EffectTechnique
* STDMETHODCALLTYPE
d3d10_effect_GetTechniqueByIndex(ID3D10Effect
*iface
,
4559 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4560 struct d3d10_effect_technique
*t
;
4562 TRACE("iface %p, index %u\n", iface
, index
);
4564 if (index
>= This
->technique_count
)
4566 WARN("Invalid index specified\n");
4567 return &null_technique
.ID3D10EffectTechnique_iface
;
4570 t
= &This
->techniques
[index
];
4572 TRACE("Returning technique %p, %s.\n", t
, debugstr_a(t
->name
));
4574 return &t
->ID3D10EffectTechnique_iface
;
4577 static struct ID3D10EffectTechnique
* STDMETHODCALLTYPE
d3d10_effect_GetTechniqueByName(ID3D10Effect
*iface
,
4580 struct d3d10_effect
*This
= impl_from_ID3D10Effect(iface
);
4583 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4587 WARN("Invalid name specified\n");
4588 return &null_technique
.ID3D10EffectTechnique_iface
;
4591 for (i
= 0; i
< This
->technique_count
; ++i
)
4593 struct d3d10_effect_technique
*t
= &This
->techniques
[i
];
4594 if (t
->name
&& !strcmp(t
->name
, name
))
4596 TRACE("Returning technique %p\n", t
);
4597 return &t
->ID3D10EffectTechnique_iface
;
4601 WARN("Invalid name specified\n");
4603 return &null_technique
.ID3D10EffectTechnique_iface
;
4606 static HRESULT STDMETHODCALLTYPE
d3d10_effect_Optimize(ID3D10Effect
*iface
)
4608 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4609 struct d3d10_effect_variable
*v
;
4612 FIXME("iface %p semi-stub!\n", iface
);
4614 if (effect
->flags
& D3D10_EFFECT_OPTIMIZED
)
4617 for (i
= 0; i
< effect
->shaders
.count
; ++i
)
4619 v
= effect
->shaders
.v
[i
];
4621 if (v
->u
.shader
.reflection
)
4623 v
->u
.shader
.reflection
->lpVtbl
->Release(v
->u
.shader
.reflection
);
4624 v
->u
.shader
.reflection
= NULL
;
4626 if (v
->u
.shader
.bytecode
)
4628 ID3D10Blob_Release(v
->u
.shader
.bytecode
);
4629 v
->u
.shader
.bytecode
= NULL
;
4631 free(v
->u
.shader
.stream_output_declaration
);
4632 v
->u
.shader
.stream_output_declaration
= NULL
;
4635 for (i
= 0; i
< effect
->technique_count
; ++i
)
4637 for (j
= 0; j
< effect
->techniques
[i
].pass_count
; ++j
)
4639 free(effect
->techniques
[i
].passes
[j
].name
);
4640 effect
->techniques
[i
].passes
[j
].name
= NULL
;
4643 free(effect
->techniques
[i
].name
);
4644 effect
->techniques
[i
].name
= NULL
;
4647 effect
->flags
|= D3D10_EFFECT_OPTIMIZED
;
4652 static BOOL STDMETHODCALLTYPE
d3d10_effect_IsOptimized(ID3D10Effect
*iface
)
4654 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
4656 TRACE("iface %p.\n", iface
);
4658 return !!(effect
->flags
& D3D10_EFFECT_OPTIMIZED
);
4661 static const struct ID3D10EffectVtbl d3d10_effect_vtbl
=
4663 /* IUnknown methods */
4664 d3d10_effect_QueryInterface
,
4665 d3d10_effect_AddRef
,
4666 d3d10_effect_Release
,
4667 /* ID3D10Effect methods */
4668 d3d10_effect_IsValid
,
4669 d3d10_effect_IsPool
,
4670 d3d10_effect_GetDevice
,
4671 d3d10_effect_GetDesc
,
4672 d3d10_effect_GetConstantBufferByIndex
,
4673 d3d10_effect_GetConstantBufferByName
,
4674 d3d10_effect_GetVariableByIndex
,
4675 d3d10_effect_GetVariableByName
,
4676 d3d10_effect_GetVariableBySemantic
,
4677 d3d10_effect_GetTechniqueByIndex
,
4678 d3d10_effect_GetTechniqueByName
,
4679 d3d10_effect_Optimize
,
4680 d3d10_effect_IsOptimized
,
4683 /* ID3D10EffectTechnique methods */
4685 static inline struct d3d10_effect_technique
*impl_from_ID3D10EffectTechnique(ID3D10EffectTechnique
*iface
)
4687 return CONTAINING_RECORD(iface
, struct d3d10_effect_technique
, ID3D10EffectTechnique_iface
);
4690 static BOOL STDMETHODCALLTYPE
d3d10_effect_technique_IsValid(ID3D10EffectTechnique
*iface
)
4692 struct d3d10_effect_technique
*This
= impl_from_ID3D10EffectTechnique(iface
);
4694 TRACE("iface %p\n", iface
);
4696 return This
!= &null_technique
;
4699 static HRESULT STDMETHODCALLTYPE
d3d10_effect_technique_GetDesc(ID3D10EffectTechnique
*iface
,
4700 D3D10_TECHNIQUE_DESC
*desc
)
4702 struct d3d10_effect_technique
*tech
= impl_from_ID3D10EffectTechnique(iface
);
4704 TRACE("iface %p, desc %p\n", iface
, desc
);
4706 if (tech
== &null_technique
)
4708 WARN("Null technique specified\n");
4714 WARN("Invalid argument specified\n");
4715 return E_INVALIDARG
;
4718 desc
->Name
= tech
->name
;
4719 desc
->Passes
= tech
->pass_count
;
4720 desc
->Annotations
= tech
->annotations
.count
;
4725 static ID3D10EffectVariable
* d3d10_annotation_get_by_index(const struct d3d10_effect_annotations
*annotations
,
4728 struct d3d10_effect_variable
*a
;
4730 if (index
>= annotations
->count
)
4732 WARN("Invalid index specified\n");
4733 return &null_variable
.ID3D10EffectVariable_iface
;
4736 a
= &annotations
->elements
[index
];
4738 TRACE("Returning annotation %p, name %s.\n", a
, debugstr_a(a
->name
));
4740 return &a
->ID3D10EffectVariable_iface
;
4743 static ID3D10EffectVariable
* d3d10_annotation_get_by_name(const struct d3d10_effect_annotations
*annotations
,
4748 for (i
= 0; i
< annotations
->count
; ++i
)
4750 struct d3d10_effect_variable
*a
= &annotations
->elements
[i
];
4751 if (a
->name
&& !strcmp(a
->name
, name
))
4753 TRACE("Returning annotation %p.\n", a
);
4754 return &a
->ID3D10EffectVariable_iface
;
4758 WARN("Invalid name specified.\n");
4760 return &null_variable
.ID3D10EffectVariable_iface
;
4763 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_technique_GetAnnotationByIndex(
4764 ID3D10EffectTechnique
*iface
, UINT index
)
4766 struct d3d10_effect_technique
*tech
= impl_from_ID3D10EffectTechnique(iface
);
4768 TRACE("iface %p, index %u\n", iface
, index
);
4770 return d3d10_annotation_get_by_index(&tech
->annotations
, index
);
4773 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_technique_GetAnnotationByName(
4774 ID3D10EffectTechnique
*iface
, const char *name
)
4776 struct d3d10_effect_technique
*tech
= impl_from_ID3D10EffectTechnique(iface
);
4778 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4780 return d3d10_annotation_get_by_name(&tech
->annotations
, name
);
4783 static struct ID3D10EffectPass
* STDMETHODCALLTYPE
d3d10_effect_technique_GetPassByIndex(ID3D10EffectTechnique
*iface
,
4786 struct d3d10_effect_technique
*This
= impl_from_ID3D10EffectTechnique(iface
);
4787 struct d3d10_effect_pass
*p
;
4789 TRACE("iface %p, index %u\n", iface
, index
);
4791 if (index
>= This
->pass_count
)
4793 WARN("Invalid index specified\n");
4794 return &null_pass
.ID3D10EffectPass_iface
;
4797 p
= &This
->passes
[index
];
4799 TRACE("Returning pass %p, %s.\n", p
, debugstr_a(p
->name
));
4801 return &p
->ID3D10EffectPass_iface
;
4804 static struct ID3D10EffectPass
* STDMETHODCALLTYPE
d3d10_effect_technique_GetPassByName(ID3D10EffectTechnique
*iface
,
4807 struct d3d10_effect_technique
*This
= impl_from_ID3D10EffectTechnique(iface
);
4810 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4812 /* Do not check for name==NULL, W7/DX10 crashes in that case. */
4814 for (i
= 0; i
< This
->pass_count
; ++i
)
4816 struct d3d10_effect_pass
*p
= &This
->passes
[i
];
4817 if (p
->name
&& !strcmp(p
->name
, name
))
4819 TRACE("Returning pass %p\n", p
);
4820 return &p
->ID3D10EffectPass_iface
;
4824 WARN("Invalid name specified\n");
4826 return &null_pass
.ID3D10EffectPass_iface
;
4829 static HRESULT STDMETHODCALLTYPE
d3d10_effect_technique_ComputeStateBlockMask(ID3D10EffectTechnique
*iface
,
4830 D3D10_STATE_BLOCK_MASK
*mask
)
4832 FIXME("iface %p,mask %p stub!\n", iface
, mask
);
4837 static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl
=
4839 /* ID3D10EffectTechnique methods */
4840 d3d10_effect_technique_IsValid
,
4841 d3d10_effect_technique_GetDesc
,
4842 d3d10_effect_technique_GetAnnotationByIndex
,
4843 d3d10_effect_technique_GetAnnotationByName
,
4844 d3d10_effect_technique_GetPassByIndex
,
4845 d3d10_effect_technique_GetPassByName
,
4846 d3d10_effect_technique_ComputeStateBlockMask
,
4849 /* ID3D10EffectPass methods */
4851 static inline struct d3d10_effect_pass
*impl_from_ID3D10EffectPass(ID3D10EffectPass
*iface
)
4853 return CONTAINING_RECORD(iface
, struct d3d10_effect_pass
, ID3D10EffectPass_iface
);
4856 static BOOL STDMETHODCALLTYPE
d3d10_effect_pass_IsValid(ID3D10EffectPass
*iface
)
4858 struct d3d10_effect_pass
*This
= impl_from_ID3D10EffectPass(iface
);
4860 TRACE("iface %p\n", iface
);
4862 return This
!= &null_pass
;
4865 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetDesc(ID3D10EffectPass
*iface
,
4866 D3D10_PASS_DESC
*desc
)
4868 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
4869 struct d3d10_effect_variable
*vs
;
4870 ID3D10Blob
*input_signature
;
4872 TRACE("iface %p, desc %p.\n", iface
, desc
);
4874 if (pass
== &null_pass
)
4876 WARN("Null pass specified\n");
4882 WARN("Invalid argument specified\n");
4883 return E_INVALIDARG
;
4886 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
4888 vs
= d3d10_array_get_element(pass
->vs
.shader
, pass
->vs
.index
);
4889 input_signature
= vs
->u
.shader
.input_signature
;
4891 desc
->Name
= pass
->name
;
4892 desc
->Annotations
= pass
->annotations
.count
;
4893 if (input_signature
)
4895 desc
->pIAInputSignature
= ID3D10Blob_GetBufferPointer(input_signature
);
4896 desc
->IAInputSignatureSize
= ID3D10Blob_GetBufferSize(input_signature
);
4900 desc
->pIAInputSignature
= NULL
;
4901 desc
->IAInputSignatureSize
= 0;
4903 desc
->StencilRef
= pass
->stencil_ref
;
4904 desc
->SampleMask
= pass
->sample_mask
;
4905 memcpy(desc
->BlendFactor
, pass
->blend_factor
, 4 * sizeof(float));
4910 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetVertexShaderDesc(ID3D10EffectPass
*iface
,
4911 D3D10_PASS_SHADER_DESC
*desc
)
4913 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
4915 TRACE("iface %p, desc %p.\n", iface
, desc
);
4917 if (pass
== &null_pass
)
4919 WARN("Null pass specified.\n");
4925 WARN("Invalid argument specified.\n");
4926 return E_INVALIDARG
;
4929 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
4931 desc
->pShaderVariable
= (ID3D10EffectShaderVariable
*)&pass
->vs
.shader
->ID3D10EffectVariable_iface
;
4932 desc
->ShaderIndex
= pass
->vs
.index
;
4937 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetGeometryShaderDesc(ID3D10EffectPass
*iface
,
4938 D3D10_PASS_SHADER_DESC
*desc
)
4940 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
4942 TRACE("iface %p, desc %p.\n", iface
, desc
);
4944 if (pass
== &null_pass
)
4946 WARN("Null pass specified.\n");
4952 WARN("Invalid argument specified.\n");
4953 return E_INVALIDARG
;
4956 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
4958 desc
->pShaderVariable
= (ID3D10EffectShaderVariable
*)&pass
->gs
.shader
->ID3D10EffectVariable_iface
;
4959 desc
->ShaderIndex
= pass
->gs
.index
;
4964 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_GetPixelShaderDesc(ID3D10EffectPass
*iface
,
4965 D3D10_PASS_SHADER_DESC
*desc
)
4967 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
4969 TRACE("iface %p, desc %p.\n", iface
, desc
);
4971 if (pass
== &null_pass
)
4973 WARN("Null pass specified.\n");
4979 WARN("Invalid argument specified.\n");
4980 return E_INVALIDARG
;
4983 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
4985 desc
->pShaderVariable
= (ID3D10EffectShaderVariable
*)&pass
->ps
.shader
->ID3D10EffectVariable_iface
;
4986 desc
->ShaderIndex
= pass
->ps
.index
;
4991 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_pass_GetAnnotationByIndex(ID3D10EffectPass
*iface
,
4994 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
4996 TRACE("iface %p, index %u\n", iface
, index
);
4998 return d3d10_annotation_get_by_index(&pass
->annotations
, index
);
5001 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_pass_GetAnnotationByName(ID3D10EffectPass
*iface
,
5004 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5006 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5008 return d3d10_annotation_get_by_name(&pass
->annotations
, name
);
5011 static void update_buffer(ID3D10Device
*device
, struct d3d10_effect_variable
*v
)
5013 struct d3d10_effect_buffer_variable
*b
= &v
->u
.buffer
;
5018 ID3D10Device_UpdateSubresource(device
, (ID3D10Resource
*)b
->buffer
, 0, NULL
,
5019 b
->local_buffer
, v
->data_size
, 0);
5024 static void set_sampler(ID3D10Device
*device
, D3D10_SHADER_VARIABLE_TYPE shader_type
,
5025 struct d3d10_effect_variable
*v
, unsigned int bind_point
)
5027 switch (shader_type
)
5029 case D3D10_SVT_VERTEXSHADER
:
5030 ID3D10Device_VSSetSamplers(device
, bind_point
, 1, &v
->u
.state
.object
.sampler
);
5033 case D3D10_SVT_PIXELSHADER
:
5034 ID3D10Device_PSSetSamplers(device
, bind_point
, 1, &v
->u
.state
.object
.sampler
);
5037 case D3D10_SVT_GEOMETRYSHADER
:
5038 ID3D10Device_GSSetSamplers(device
, bind_point
, 1, &v
->u
.state
.object
.sampler
);
5042 WARN("Incorrect shader type to bind sampler.\n");
5047 static void apply_shader_resources(ID3D10Device
*device
, struct d3d10_effect_variable
*v
)
5049 struct d3d10_effect_shader_variable
*sv
= &v
->u
.shader
;
5050 struct d3d10_effect_shader_resource
*sr
;
5051 struct d3d10_effect_variable
*rsrc_v
;
5052 ID3D10ShaderResourceView
**srv
;
5055 for (i
= 0; i
< sv
->resource_count
; ++i
)
5057 sr
= &sv
->resources
[i
];
5058 rsrc_v
= sr
->variable
;
5060 switch (sr
->in_type
)
5062 case D3D10_SIT_CBUFFER
:
5063 update_buffer(device
, rsrc_v
);
5064 switch (v
->type
->basetype
)
5066 case D3D10_SVT_VERTEXSHADER
:
5067 ID3D10Device_VSSetConstantBuffers(device
, sr
->bind_point
, 1,
5068 &rsrc_v
->u
.buffer
.buffer
);
5071 case D3D10_SVT_PIXELSHADER
:
5072 ID3D10Device_PSSetConstantBuffers(device
, sr
->bind_point
, 1,
5073 &rsrc_v
->u
.buffer
.buffer
);
5076 case D3D10_SVT_GEOMETRYSHADER
:
5077 ID3D10Device_GSSetConstantBuffers(device
, sr
->bind_point
, 1,
5078 &rsrc_v
->u
.buffer
.buffer
);
5082 WARN("Incorrect shader type to bind constant buffer.\n");
5087 case D3D10_SIT_TEXTURE
:
5089 if (rsrc_v
->type
->basetype
== D3D10_SVT_SAMPLER
)
5091 TRACE("Using texture associated with sampler %s.\n", debugstr_a(rsrc_v
->name
));
5092 rsrc_v
= rsrc_v
->u
.state
.desc
.sampler
.texture
;
5096 case D3D10_SIT_TBUFFER
:
5098 if (sr
->in_type
== D3D10_SIT_TBUFFER
)
5100 update_buffer(device
, rsrc_v
);
5101 srv
= &rsrc_v
->u
.buffer
.resource_view
;
5104 srv
= rsrc_v
->u
.resource
.srv
;
5106 switch (v
->type
->basetype
)
5108 case D3D10_SVT_VERTEXSHADER
:
5109 ID3D10Device_VSSetShaderResources(device
, sr
->bind_point
, sr
->bind_count
, srv
);
5112 case D3D10_SVT_PIXELSHADER
:
5113 ID3D10Device_PSSetShaderResources(device
, sr
->bind_point
, sr
->bind_count
, srv
);
5116 case D3D10_SVT_GEOMETRYSHADER
:
5117 ID3D10Device_GSSetShaderResources(device
, sr
->bind_point
, sr
->bind_count
, srv
);
5121 WARN("Incorrect shader type to bind shader resource view.\n");
5126 case D3D10_SIT_SAMPLER
:
5127 if (!rsrc_v
->type
->element_count
)
5129 set_sampler(device
, v
->type
->basetype
, rsrc_v
, sr
->bind_point
);
5133 for (j
= 0; j
< sr
->bind_count
; ++j
)
5134 set_sampler(device
, v
->type
->basetype
, &rsrc_v
->elements
[j
], sr
->bind_point
+ j
);
5138 WARN("Unhandled shader resource %#x.\n", sr
->in_type
);
5144 static void d3d10_effect_pass_set_shader(struct d3d10_effect_pass
*pass
,
5145 const struct d3d10_effect_pass_shader_desc
*shader_desc
)
5147 ID3D10Device
*device
= pass
->technique
->effect
->device
;
5148 struct d3d10_effect_variable
*v
;
5150 v
= d3d10_array_get_element(shader_desc
->shader
, shader_desc
->index
);
5152 switch (v
->type
->basetype
)
5154 case D3D10_SVT_VERTEXSHADER
:
5155 ID3D10Device_VSSetShader(device
, v
->u
.shader
.shader
.vs
);
5157 case D3D10_SVT_PIXELSHADER
:
5158 ID3D10Device_PSSetShader(device
, v
->u
.shader
.shader
.ps
);
5160 case D3D10_SVT_GEOMETRYSHADER
:
5161 ID3D10Device_GSSetShader(device
, v
->u
.shader
.shader
.gs
);
5164 WARN("Unexpected shader type %u.\n", v
->type
->basetype
);
5167 apply_shader_resources(device
, v
);
5170 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_Apply(ID3D10EffectPass
*iface
, UINT flags
)
5172 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5173 ID3D10Device
*device
= pass
->technique
->effect
->device
;
5175 TRACE("iface %p, flags %#x\n", iface
, flags
);
5177 if (flags
) FIXME("Ignoring flags (%#x)\n", flags
);
5179 d3d10_effect_update_dependent_props(&pass
->dependencies
, pass
);
5181 if (pass
->vs
.shader
!= &null_shader_variable
)
5182 d3d10_effect_pass_set_shader(pass
, &pass
->vs
);
5183 if (pass
->gs
.shader
!= &null_shader_variable
)
5184 d3d10_effect_pass_set_shader(pass
, &pass
->gs
);
5185 if (pass
->ps
.shader
!= &null_shader_variable
)
5186 d3d10_effect_pass_set_shader(pass
, &pass
->ps
);
5187 if (pass
->rasterizer
)
5188 ID3D10Device_RSSetState(device
, pass
->rasterizer
->u
.state
.object
.rasterizer
);
5189 if (pass
->depth_stencil
)
5190 ID3D10Device_OMSetDepthStencilState(device
, pass
->depth_stencil
->u
.state
.object
.depth_stencil
,
5193 ID3D10Device_OMSetBlendState(device
, pass
->blend
->u
.state
.object
.blend
,
5194 pass
->blend_factor
, pass
->sample_mask
);
5199 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pass_ComputeStateBlockMask(ID3D10EffectPass
*iface
,
5200 D3D10_STATE_BLOCK_MASK
*mask
)
5202 struct d3d10_effect_pass
*pass
= impl_from_ID3D10EffectPass(iface
);
5204 FIXME("iface %p, mask %p semi-stub!\n", iface
, mask
);
5206 if (pass
->vs
.shader
!= &null_shader_variable
)
5207 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_VS
, 0, 1);
5208 if (pass
->ps
.shader
!= &null_shader_variable
)
5209 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_PS
, 0, 1);
5210 if (pass
->gs
.shader
!= &null_shader_variable
)
5211 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_GS
, 0, 1);
5212 if (pass
->rasterizer
)
5213 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_RS_RASTERIZER_STATE
, 0, 1);
5214 if (pass
->depth_stencil
)
5215 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_OM_DEPTH_STENCIL_STATE
, 0, 1);
5217 D3D10StateBlockMaskEnableCapture(mask
, D3D10_DST_OM_BLEND_STATE
, 0, 1);
5222 static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl
=
5224 /* ID3D10EffectPass methods */
5225 d3d10_effect_pass_IsValid
,
5226 d3d10_effect_pass_GetDesc
,
5227 d3d10_effect_pass_GetVertexShaderDesc
,
5228 d3d10_effect_pass_GetGeometryShaderDesc
,
5229 d3d10_effect_pass_GetPixelShaderDesc
,
5230 d3d10_effect_pass_GetAnnotationByIndex
,
5231 d3d10_effect_pass_GetAnnotationByName
,
5232 d3d10_effect_pass_Apply
,
5233 d3d10_effect_pass_ComputeStateBlockMask
,
5236 /* ID3D10EffectVariable methods */
5238 static BOOL STDMETHODCALLTYPE
d3d10_effect_variable_IsValid(ID3D10EffectVariable
*iface
)
5240 TRACE("iface %p\n", iface
);
5242 return impl_from_ID3D10EffectVariable(iface
) != &null_variable
;
5245 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_variable_GetType(ID3D10EffectVariable
*iface
)
5247 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5249 TRACE("iface %p\n", iface
);
5251 return &This
->type
->ID3D10EffectType_iface
;
5254 static HRESULT STDMETHODCALLTYPE
d3d10_effect_variable_GetDesc(ID3D10EffectVariable
*iface
,
5255 D3D10_EFFECT_VARIABLE_DESC
*desc
)
5257 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVariable(iface
);
5259 TRACE("iface %p, desc %p\n", iface
, desc
);
5261 if (!iface
->lpVtbl
->IsValid(iface
))
5263 WARN("Null variable specified\n");
5269 WARN("Invalid argument specified\n");
5270 return E_INVALIDARG
;
5273 /* FIXME: This isn't correct. Anonymous shaders let desc->ExplicitBindPoint untouched, but normal shaders set it! */
5274 memset(desc
, 0, sizeof(*desc
));
5275 desc
->Name
= v
->name
;
5276 desc
->Semantic
= v
->semantic
;
5277 desc
->Flags
= v
->flag
;
5278 desc
->Annotations
= v
->annotations
.count
;
5279 desc
->BufferOffset
= v
->buffer_offset
;
5281 if (v
->flag
& D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
)
5282 desc
->ExplicitBindPoint
= v
->explicit_bind_point
;
5287 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetAnnotationByIndex(
5288 ID3D10EffectVariable
*iface
, UINT index
)
5290 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectVariable(iface
);
5292 TRACE("iface %p, index %u\n", iface
, index
);
5294 return d3d10_annotation_get_by_index(&var
->annotations
, index
);
5297 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetAnnotationByName(
5298 ID3D10EffectVariable
*iface
, const char *name
)
5300 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectVariable(iface
);
5302 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5304 return d3d10_annotation_get_by_name(&var
->annotations
, name
);
5307 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetMemberByIndex(
5308 ID3D10EffectVariable
*iface
, UINT index
)
5310 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5311 struct d3d10_effect_variable
*m
;
5313 TRACE("iface %p, index %u\n", iface
, index
);
5315 if (index
>= This
->type
->member_count
)
5317 WARN("Invalid index specified\n");
5318 return &null_variable
.ID3D10EffectVariable_iface
;
5321 m
= &This
->members
[index
];
5323 TRACE("Returning member %p, %s\n", m
, debugstr_a(m
->name
));
5325 return &m
->ID3D10EffectVariable_iface
;
5328 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetMemberByName(
5329 ID3D10EffectVariable
*iface
, const char *name
)
5331 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5334 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
5338 WARN("Invalid name specified\n");
5339 return &null_variable
.ID3D10EffectVariable_iface
;
5342 for (i
= 0; i
< This
->type
->member_count
; ++i
)
5344 struct d3d10_effect_variable
*m
= &This
->members
[i
];
5346 if (m
->name
&& !strcmp(m
->name
, name
))
5348 TRACE("Returning member %p\n", m
);
5349 return &m
->ID3D10EffectVariable_iface
;
5353 WARN("Invalid name specified\n");
5355 return &null_variable
.ID3D10EffectVariable_iface
;
5358 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetMemberBySemantic(
5359 ID3D10EffectVariable
*iface
, const char *semantic
)
5361 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5364 TRACE("iface %p, semantic %s.\n", iface
, debugstr_a(semantic
));
5368 WARN("Invalid semantic specified\n");
5369 return &null_variable
.ID3D10EffectVariable_iface
;
5372 for (i
= 0; i
< This
->type
->member_count
; ++i
)
5374 struct d3d10_effect_variable
*m
= &This
->members
[i
];
5376 if (m
->semantic
&& !stricmp(m
->semantic
, semantic
))
5378 TRACE("Returning member %p\n", m
);
5379 return &m
->ID3D10EffectVariable_iface
;
5383 WARN("Invalid semantic specified\n");
5385 return &null_variable
.ID3D10EffectVariable_iface
;
5388 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_GetElement(
5389 ID3D10EffectVariable
*iface
, UINT index
)
5391 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5392 struct d3d10_effect_variable
*v
;
5394 TRACE("iface %p, index %u\n", iface
, index
);
5396 if (index
>= This
->type
->element_count
)
5398 WARN("Invalid index specified\n");
5399 return &null_variable
.ID3D10EffectVariable_iface
;
5402 v
= &This
->elements
[index
];
5404 TRACE("Returning element %p, %s\n", v
, debugstr_a(v
->name
));
5406 return &v
->ID3D10EffectVariable_iface
;
5409 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_variable_GetParentConstantBuffer(
5410 ID3D10EffectVariable
*iface
)
5412 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5414 TRACE("iface %p\n", iface
);
5416 return (ID3D10EffectConstantBuffer
*)&This
->buffer
->ID3D10EffectVariable_iface
;
5419 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsScalar(
5420 ID3D10EffectVariable
*iface
)
5422 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5424 TRACE("iface %p\n", iface
);
5426 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_scalar_variable_vtbl
)
5427 return (ID3D10EffectScalarVariable
*)&This
->ID3D10EffectVariable_iface
;
5429 return (ID3D10EffectScalarVariable
*)&null_scalar_variable
.ID3D10EffectVariable_iface
;
5432 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsVector(
5433 ID3D10EffectVariable
*iface
)
5435 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5437 TRACE("iface %p\n", iface
);
5439 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_vector_variable_vtbl
)
5440 return (ID3D10EffectVectorVariable
*)&This
->ID3D10EffectVariable_iface
;
5442 return (ID3D10EffectVectorVariable
*)&null_vector_variable
.ID3D10EffectVariable_iface
;
5445 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsMatrix(
5446 ID3D10EffectVariable
*iface
)
5448 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5450 TRACE("iface %p\n", iface
);
5452 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_matrix_variable_vtbl
)
5453 return (ID3D10EffectMatrixVariable
*)&This
->ID3D10EffectVariable_iface
;
5455 return (ID3D10EffectMatrixVariable
*)&null_matrix_variable
.ID3D10EffectVariable_iface
;
5458 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsString(
5459 ID3D10EffectVariable
*iface
)
5461 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5463 TRACE("iface %p\n", iface
);
5465 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_string_variable_vtbl
)
5466 return (ID3D10EffectStringVariable
*)&This
->ID3D10EffectVariable_iface
;
5468 return (ID3D10EffectStringVariable
*)&null_string_variable
.ID3D10EffectVariable_iface
;
5471 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsShaderResource(
5472 ID3D10EffectVariable
*iface
)
5474 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5476 TRACE("iface %p\n", iface
);
5478 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_resource_variable_vtbl
)
5479 return (ID3D10EffectShaderResourceVariable
*)&This
->ID3D10EffectVariable_iface
;
5481 return (ID3D10EffectShaderResourceVariable
*)&null_shader_resource_variable
.ID3D10EffectVariable_iface
;
5484 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsRenderTargetView(
5485 ID3D10EffectVariable
*iface
)
5487 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5489 TRACE("iface %p\n", iface
);
5491 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_render_target_view_variable_vtbl
)
5492 return (ID3D10EffectRenderTargetViewVariable
*)&This
->ID3D10EffectVariable_iface
;
5494 return (ID3D10EffectRenderTargetViewVariable
*)&null_render_target_view_variable
.ID3D10EffectVariable_iface
;
5497 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsDepthStencilView(
5498 ID3D10EffectVariable
*iface
)
5500 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5502 TRACE("iface %p\n", iface
);
5504 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_view_variable_vtbl
)
5505 return (ID3D10EffectDepthStencilViewVariable
*)&This
->ID3D10EffectVariable_iface
;
5507 return (ID3D10EffectDepthStencilViewVariable
*)&null_depth_stencil_view_variable
.ID3D10EffectVariable_iface
;
5510 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_variable_AsConstantBuffer(
5511 ID3D10EffectVariable
*iface
)
5513 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5515 TRACE("iface %p\n", iface
);
5517 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_constant_buffer_vtbl
)
5518 return (ID3D10EffectConstantBuffer
*)&This
->ID3D10EffectVariable_iface
;
5520 return (ID3D10EffectConstantBuffer
*)&null_local_buffer
.ID3D10EffectVariable_iface
;
5523 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsShader(
5524 ID3D10EffectVariable
*iface
)
5526 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5528 TRACE("iface %p\n", iface
);
5530 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_shader_variable_vtbl
)
5531 return (ID3D10EffectShaderVariable
*)&This
->ID3D10EffectVariable_iface
;
5533 return (ID3D10EffectShaderVariable
*)&null_shader_variable
.ID3D10EffectVariable_iface
;
5536 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsBlend(ID3D10EffectVariable
*iface
)
5538 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5540 TRACE("iface %p\n", iface
);
5542 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_blend_variable_vtbl
)
5543 return (ID3D10EffectBlendVariable
*)&This
->ID3D10EffectVariable_iface
;
5545 return (ID3D10EffectBlendVariable
*)&null_blend_variable
.ID3D10EffectVariable_iface
;
5548 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsDepthStencil(
5549 ID3D10EffectVariable
*iface
)
5551 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5553 TRACE("iface %p\n", iface
);
5555 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_depth_stencil_variable_vtbl
)
5556 return (ID3D10EffectDepthStencilVariable
*)&This
->ID3D10EffectVariable_iface
;
5558 return (ID3D10EffectDepthStencilVariable
*)&null_depth_stencil_variable
.ID3D10EffectVariable_iface
;
5561 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsRasterizer(
5562 ID3D10EffectVariable
*iface
)
5564 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5566 TRACE("iface %p\n", iface
);
5568 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_rasterizer_variable_vtbl
)
5569 return (ID3D10EffectRasterizerVariable
*)&This
->ID3D10EffectVariable_iface
;
5571 return (ID3D10EffectRasterizerVariable
*)&null_rasterizer_variable
.ID3D10EffectVariable_iface
;
5574 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_variable_AsSampler(
5575 ID3D10EffectVariable
*iface
)
5577 struct d3d10_effect_variable
*This
= impl_from_ID3D10EffectVariable(iface
);
5579 TRACE("iface %p\n", iface
);
5581 if (This
->ID3D10EffectVariable_iface
.lpVtbl
== (const ID3D10EffectVariableVtbl
*)&d3d10_effect_sampler_variable_vtbl
)
5582 return (ID3D10EffectSamplerVariable
*)&This
->ID3D10EffectVariable_iface
;
5584 return (ID3D10EffectSamplerVariable
*)&null_sampler_variable
.ID3D10EffectVariable_iface
;
5587 static HRESULT STDMETHODCALLTYPE
d3d10_effect_variable_SetRawValue(ID3D10EffectVariable
*iface
,
5588 void *data
, UINT offset
, UINT count
)
5590 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVariable(iface
);
5593 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
5595 if (!iface
->lpVtbl
->IsValid(iface
))
5597 WARN("Invalid variable.\n");
5601 is_buffer
= v
->type
->basetype
== D3D10_SVT_CBUFFER
|| v
->type
->basetype
== D3D10_SVT_TBUFFER
;
5603 if (v
->type
->type_class
== D3D10_SVC_OBJECT
&& !is_buffer
)
5605 WARN("Not supported on object variables of type %s.\n",
5606 debug_d3d10_shader_variable_type(v
->type
->basetype
));
5607 return D3DERR_INVALIDCALL
;
5612 offset
+= v
->buffer_offset
;
5616 memcpy(v
->u
.buffer
.local_buffer
+ offset
, data
, count
);
5617 v
->u
.buffer
.changed
= TRUE
;
5622 static HRESULT STDMETHODCALLTYPE
d3d10_effect_variable_GetRawValue(ID3D10EffectVariable
*iface
,
5623 void *data
, UINT offset
, UINT count
)
5625 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVariable(iface
);
5627 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
5629 if (!iface
->lpVtbl
->IsValid(iface
))
5631 WARN("Invalid variable.\n");
5635 return d3d10_effect_variable_get_raw_value(v
, data
, offset
, count
);
5638 static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl
=
5640 /* ID3D10EffectVariable methods */
5641 d3d10_effect_variable_IsValid
,
5642 d3d10_effect_variable_GetType
,
5643 d3d10_effect_variable_GetDesc
,
5644 d3d10_effect_variable_GetAnnotationByIndex
,
5645 d3d10_effect_variable_GetAnnotationByName
,
5646 d3d10_effect_variable_GetMemberByIndex
,
5647 d3d10_effect_variable_GetMemberByName
,
5648 d3d10_effect_variable_GetMemberBySemantic
,
5649 d3d10_effect_variable_GetElement
,
5650 d3d10_effect_variable_GetParentConstantBuffer
,
5651 d3d10_effect_variable_AsScalar
,
5652 d3d10_effect_variable_AsVector
,
5653 d3d10_effect_variable_AsMatrix
,
5654 d3d10_effect_variable_AsString
,
5655 d3d10_effect_variable_AsShaderResource
,
5656 d3d10_effect_variable_AsRenderTargetView
,
5657 d3d10_effect_variable_AsDepthStencilView
,
5658 d3d10_effect_variable_AsConstantBuffer
,
5659 d3d10_effect_variable_AsShader
,
5660 d3d10_effect_variable_AsBlend
,
5661 d3d10_effect_variable_AsDepthStencil
,
5662 d3d10_effect_variable_AsRasterizer
,
5663 d3d10_effect_variable_AsSampler
,
5664 d3d10_effect_variable_SetRawValue
,
5665 d3d10_effect_variable_GetRawValue
,
5668 /* ID3D10EffectVariable methods */
5669 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectConstantBuffer(ID3D10EffectConstantBuffer
*iface
)
5671 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
5674 static BOOL STDMETHODCALLTYPE
d3d10_effect_constant_buffer_IsValid(ID3D10EffectConstantBuffer
*iface
)
5676 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectConstantBuffer(iface
);
5678 TRACE("iface %p.\n", iface
);
5680 return v
!= &null_local_buffer
;
5683 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetType(ID3D10EffectConstantBuffer
*iface
)
5685 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
5688 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetDesc(ID3D10EffectConstantBuffer
*iface
,
5689 D3D10_EFFECT_VARIABLE_DESC
*desc
)
5691 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
5694 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetAnnotationByIndex(
5695 ID3D10EffectConstantBuffer
*iface
, UINT index
)
5697 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
5700 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetAnnotationByName(
5701 ID3D10EffectConstantBuffer
*iface
, const char *name
)
5703 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
5706 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetMemberByIndex(
5707 ID3D10EffectConstantBuffer
*iface
, UINT index
)
5709 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
5712 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetMemberByName(
5713 ID3D10EffectConstantBuffer
*iface
, const char *name
)
5715 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
5718 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetMemberBySemantic(
5719 ID3D10EffectConstantBuffer
*iface
, const char *semantic
)
5721 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
5724 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetElement(
5725 ID3D10EffectConstantBuffer
*iface
, UINT index
)
5727 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
5730 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetParentConstantBuffer(
5731 ID3D10EffectConstantBuffer
*iface
)
5733 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
5736 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsScalar(
5737 ID3D10EffectConstantBuffer
*iface
)
5739 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
5742 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsVector(
5743 ID3D10EffectConstantBuffer
*iface
)
5745 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
5748 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsMatrix(
5749 ID3D10EffectConstantBuffer
*iface
)
5751 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
5754 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsString(
5755 ID3D10EffectConstantBuffer
*iface
)
5757 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
5760 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsShaderResource(
5761 ID3D10EffectConstantBuffer
*iface
)
5763 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
5766 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsRenderTargetView(
5767 ID3D10EffectConstantBuffer
*iface
)
5769 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
5772 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsDepthStencilView(
5773 ID3D10EffectConstantBuffer
*iface
)
5775 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
5778 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsConstantBuffer(
5779 ID3D10EffectConstantBuffer
*iface
)
5781 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
5784 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsShader(
5785 ID3D10EffectConstantBuffer
*iface
)
5787 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
5790 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsBlend(ID3D10EffectConstantBuffer
*iface
)
5792 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
5795 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsDepthStencil(
5796 ID3D10EffectConstantBuffer
*iface
)
5798 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
5801 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsRasterizer(
5802 ID3D10EffectConstantBuffer
*iface
)
5804 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
5807 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_constant_buffer_AsSampler(
5808 ID3D10EffectConstantBuffer
*iface
)
5810 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
5813 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_SetRawValue(ID3D10EffectConstantBuffer
*iface
,
5814 void *data
, UINT offset
, UINT count
)
5816 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
5819 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetRawValue(ID3D10EffectConstantBuffer
*iface
,
5820 void *data
, UINT offset
, UINT count
)
5822 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
5825 /* ID3D10EffectConstantBuffer methods */
5826 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_SetConstantBuffer(ID3D10EffectConstantBuffer
*iface
,
5827 ID3D10Buffer
*buffer
)
5829 FIXME("iface %p, buffer %p stub!\n", iface
, buffer
);
5834 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetConstantBuffer(ID3D10EffectConstantBuffer
*iface
,
5835 ID3D10Buffer
**buffer
)
5837 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectConstantBuffer(iface
);
5839 TRACE("iface %p, buffer %p.\n", iface
, buffer
);
5841 if (!iface
->lpVtbl
->IsValid(iface
))
5843 WARN("Null variable specified.\n");
5847 if (v
->type
->basetype
!= D3D10_SVT_CBUFFER
)
5849 WARN("Wrong variable type %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
5850 return D3DERR_INVALIDCALL
;
5853 *buffer
= v
->u
.buffer
.buffer
;
5854 ID3D10Buffer_AddRef(*buffer
);
5859 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_SetTextureBuffer(ID3D10EffectConstantBuffer
*iface
,
5860 ID3D10ShaderResourceView
*view
)
5862 FIXME("iface %p, view %p stub!\n", iface
, view
);
5867 static HRESULT STDMETHODCALLTYPE
d3d10_effect_constant_buffer_GetTextureBuffer(ID3D10EffectConstantBuffer
*iface
,
5868 ID3D10ShaderResourceView
**view
)
5870 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectConstantBuffer(iface
);
5872 FIXME("iface %p, view %p stub!\n", iface
, view
);
5874 if (!iface
->lpVtbl
->IsValid(iface
))
5876 WARN("Null variable specified.\n");
5880 if (v
->type
->basetype
!= D3D10_SVT_TBUFFER
)
5882 WARN("Wrong variable type %s.\n", debug_d3d10_shader_variable_type(v
->type
->basetype
));
5883 return D3DERR_INVALIDCALL
;
5889 static const struct ID3D10EffectConstantBufferVtbl d3d10_effect_constant_buffer_vtbl
=
5891 /* ID3D10EffectVariable methods */
5892 d3d10_effect_constant_buffer_IsValid
,
5893 d3d10_effect_constant_buffer_GetType
,
5894 d3d10_effect_constant_buffer_GetDesc
,
5895 d3d10_effect_constant_buffer_GetAnnotationByIndex
,
5896 d3d10_effect_constant_buffer_GetAnnotationByName
,
5897 d3d10_effect_constant_buffer_GetMemberByIndex
,
5898 d3d10_effect_constant_buffer_GetMemberByName
,
5899 d3d10_effect_constant_buffer_GetMemberBySemantic
,
5900 d3d10_effect_constant_buffer_GetElement
,
5901 d3d10_effect_constant_buffer_GetParentConstantBuffer
,
5902 d3d10_effect_constant_buffer_AsScalar
,
5903 d3d10_effect_constant_buffer_AsVector
,
5904 d3d10_effect_constant_buffer_AsMatrix
,
5905 d3d10_effect_constant_buffer_AsString
,
5906 d3d10_effect_constant_buffer_AsShaderResource
,
5907 d3d10_effect_constant_buffer_AsRenderTargetView
,
5908 d3d10_effect_constant_buffer_AsDepthStencilView
,
5909 d3d10_effect_constant_buffer_AsConstantBuffer
,
5910 d3d10_effect_constant_buffer_AsShader
,
5911 d3d10_effect_constant_buffer_AsBlend
,
5912 d3d10_effect_constant_buffer_AsDepthStencil
,
5913 d3d10_effect_constant_buffer_AsRasterizer
,
5914 d3d10_effect_constant_buffer_AsSampler
,
5915 d3d10_effect_constant_buffer_SetRawValue
,
5916 d3d10_effect_constant_buffer_GetRawValue
,
5917 /* ID3D10EffectConstantBuffer methods */
5918 d3d10_effect_constant_buffer_SetConstantBuffer
,
5919 d3d10_effect_constant_buffer_GetConstantBuffer
,
5920 d3d10_effect_constant_buffer_SetTextureBuffer
,
5921 d3d10_effect_constant_buffer_GetTextureBuffer
,
5925 static BOOL
get_value_as_bool(void *src_data
, D3D10_SHADER_VARIABLE_TYPE src_type
)
5929 case D3D10_SVT_FLOAT
:
5931 case D3D10_SVT_UINT
:
5932 case D3D10_SVT_BOOL
:
5933 if (*(DWORD
*)src_data
)
5944 static int get_value_as_int(void *src_data
, D3D10_SHADER_VARIABLE_TYPE src_type
)
5948 case D3D10_SVT_FLOAT
:
5949 return (int)(*(float *)src_data
);
5952 case D3D10_SVT_UINT
:
5953 return *(int *)src_data
;
5955 case D3D10_SVT_BOOL
:
5956 return get_value_as_bool(src_data
, src_type
);
5963 static float get_value_as_float(void *src_data
, D3D10_SHADER_VARIABLE_TYPE src_type
)
5967 case D3D10_SVT_FLOAT
:
5968 return *(float *)src_data
;
5971 case D3D10_SVT_UINT
:
5972 return (float)(*(int *)src_data
);
5974 case D3D10_SVT_BOOL
:
5975 return (float)get_value_as_bool(src_data
, src_type
);
5982 static void get_vector_as_type(BYTE
*dst_data
, D3D_SHADER_VARIABLE_TYPE dst_type
,
5983 BYTE
*src_data
, D3D_SHADER_VARIABLE_TYPE src_type
, unsigned int count
)
5985 DWORD
*src_data_dword
= (DWORD
*)src_data
;
5986 DWORD
*dst_data_dword
= (DWORD
*)dst_data
;
5989 for (i
= 0; i
< count
; ++i
, ++dst_data_dword
, ++src_data_dword
)
5991 if (dst_type
== src_type
)
5992 *dst_data_dword
= *src_data_dword
;
5997 case D3D10_SVT_FLOAT
:
5998 *(float *)dst_data_dword
= get_value_as_float(src_data_dword
, src_type
);
6002 case D3D10_SVT_UINT
:
6003 *(int *)dst_data_dword
= get_value_as_int(src_data_dword
, src_type
);
6006 case D3D10_SVT_BOOL
:
6007 *(BOOL
*)dst_data_dword
= get_value_as_bool(src_data_dword
, src_type
);
6011 *dst_data_dword
= 0;
6018 static void write_variable_to_buffer(struct d3d10_effect_variable
*variable
, void *src
,
6019 D3D_SHADER_VARIABLE_TYPE src_type
)
6021 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6022 D3D_SHADER_VARIABLE_TYPE dst_type
= variable
->type
->basetype
;
6024 get_vector_as_type(dst
, dst_type
, src
, src_type
, variable
->type
->column_count
);
6026 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6029 static void write_variable_array_to_buffer(struct d3d10_effect_variable
*variable
, void *src
,
6030 D3D_SHADER_VARIABLE_TYPE src_type
, unsigned int offset
, unsigned int count
)
6032 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6033 D3D_SHADER_VARIABLE_TYPE dst_type
= variable
->type
->basetype
;
6034 unsigned int element_size
, i
;
6035 BYTE
*cur_element
= src
;
6037 if (!variable
->type
->element_count
)
6039 write_variable_to_buffer(variable
, src
, src_type
);
6043 if (offset
>= variable
->type
->element_count
)
6045 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6049 if (count
> variable
->type
->element_count
- offset
)
6051 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6052 offset
, count
, variable
->type
->element_count
);
6053 count
= variable
->type
->element_count
- offset
;
6056 element_size
= variable
->type
->elementtype
->size_packed
;
6057 dst
+= variable
->type
->stride
* offset
;
6059 for (i
= 0; i
< count
; ++i
)
6061 get_vector_as_type(dst
, dst_type
, cur_element
, src_type
, variable
->type
->column_count
);
6063 cur_element
+= element_size
;
6064 dst
+= variable
->type
->stride
;
6067 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6070 static void read_variable_from_buffer(struct d3d10_effect_variable
*variable
, void *dst
,
6071 D3D_SHADER_VARIABLE_TYPE dst_type
)
6073 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6074 D3D_SHADER_VARIABLE_TYPE src_type
= variable
->type
->basetype
;
6076 get_vector_as_type(dst
, dst_type
, src
, src_type
, variable
->type
->column_count
);
6079 static void read_variable_array_from_buffer(struct d3d10_effect_variable
*variable
, void *dst
,
6080 D3D_SHADER_VARIABLE_TYPE dst_type
, unsigned int offset
, unsigned int count
)
6082 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6083 D3D_SHADER_VARIABLE_TYPE src_type
= variable
->type
->basetype
;
6084 unsigned int element_size
, i
;
6085 BYTE
*cur_element
= dst
;
6087 if (!variable
->type
->element_count
)
6089 read_variable_from_buffer(variable
, dst
, dst_type
);
6093 if (offset
>= variable
->type
->element_count
)
6095 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6099 if (count
> variable
->type
->element_count
- offset
)
6101 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6102 offset
, count
, variable
->type
->element_count
);
6103 count
= variable
->type
->element_count
- offset
;
6106 element_size
= variable
->type
->elementtype
->size_packed
;
6107 src
+= variable
->type
->stride
* offset
;
6109 for (i
= 0; i
< count
; ++i
)
6111 get_vector_as_type(cur_element
, dst_type
, src
, src_type
, variable
->type
->column_count
);
6113 cur_element
+= element_size
;
6114 src
+= variable
->type
->stride
;
6118 /* ID3D10EffectVariable methods */
6120 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectScalarVariable(ID3D10EffectScalarVariable
*iface
)
6122 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
6125 static BOOL STDMETHODCALLTYPE
d3d10_effect_scalar_variable_IsValid(ID3D10EffectScalarVariable
*iface
)
6127 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectScalarVariable(iface
);
6129 TRACE("iface %p\n", iface
);
6131 return v
!= &null_scalar_variable
;
6134 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetType(
6135 ID3D10EffectScalarVariable
*iface
)
6137 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
6140 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetDesc(ID3D10EffectScalarVariable
*iface
,
6141 D3D10_EFFECT_VARIABLE_DESC
*desc
)
6143 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
6146 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetAnnotationByIndex(
6147 ID3D10EffectScalarVariable
*iface
, UINT index
)
6149 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
6152 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetAnnotationByName(
6153 ID3D10EffectScalarVariable
*iface
, const char *name
)
6155 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
6158 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetMemberByIndex(
6159 ID3D10EffectScalarVariable
*iface
, UINT index
)
6161 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
6164 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetMemberByName(
6165 ID3D10EffectScalarVariable
*iface
, const char *name
)
6167 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
6170 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetMemberBySemantic(
6171 ID3D10EffectScalarVariable
*iface
, const char *semantic
)
6173 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
6176 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetElement(
6177 ID3D10EffectScalarVariable
*iface
, UINT index
)
6179 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
6182 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetParentConstantBuffer(
6183 ID3D10EffectScalarVariable
*iface
)
6185 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
6188 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsScalar(
6189 ID3D10EffectScalarVariable
*iface
)
6191 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
6194 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsVector(
6195 ID3D10EffectScalarVariable
*iface
)
6197 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
6200 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsMatrix(
6201 ID3D10EffectScalarVariable
*iface
)
6203 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
6206 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsString(
6207 ID3D10EffectScalarVariable
*iface
)
6209 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
6212 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsShaderResource(
6213 ID3D10EffectScalarVariable
*iface
)
6215 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
6218 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsRenderTargetView(
6219 ID3D10EffectScalarVariable
*iface
)
6221 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
6224 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsDepthStencilView(
6225 ID3D10EffectScalarVariable
*iface
)
6227 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
6230 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsConstantBuffer(
6231 ID3D10EffectScalarVariable
*iface
)
6233 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
6236 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsShader(
6237 ID3D10EffectScalarVariable
*iface
)
6239 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
6242 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsBlend(
6243 ID3D10EffectScalarVariable
*iface
)
6245 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
6248 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsDepthStencil(
6249 ID3D10EffectScalarVariable
*iface
)
6251 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
6254 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsRasterizer(
6255 ID3D10EffectScalarVariable
*iface
)
6257 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
6260 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_scalar_variable_AsSampler(
6261 ID3D10EffectScalarVariable
*iface
)
6263 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
6266 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetRawValue(ID3D10EffectScalarVariable
*iface
,
6267 void *data
, UINT offset
, UINT count
)
6269 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6272 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetRawValue(ID3D10EffectScalarVariable
*iface
,
6273 void *data
, UINT offset
, UINT count
)
6275 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6278 /* ID3D10EffectScalarVariable methods */
6280 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetFloat(ID3D10EffectScalarVariable
*iface
,
6283 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6285 TRACE("iface %p, value %.8e.\n", iface
, value
);
6286 write_variable_to_buffer(effect_var
, &value
, D3D10_SVT_FLOAT
);
6291 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetFloat(ID3D10EffectScalarVariable
*iface
,
6294 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6296 TRACE("iface %p, value %p.\n", iface
, value
);
6297 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_FLOAT
);
6302 /* Tests show that offset is ignored for scalar variables. */
6303 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetFloatArray(ID3D10EffectScalarVariable
*iface
,
6304 float *values
, UINT offset
, UINT count
)
6306 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6308 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6309 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, 0, count
);
6314 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetFloatArray(ID3D10EffectScalarVariable
*iface
,
6315 float *values
, UINT offset
, UINT count
)
6317 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6319 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6320 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, 0, count
);
6325 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetInt(ID3D10EffectScalarVariable
*iface
,
6328 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6330 TRACE("iface %p, value %d.\n", iface
, value
);
6331 write_variable_to_buffer(effect_var
, &value
, D3D10_SVT_INT
);
6336 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetInt(ID3D10EffectScalarVariable
*iface
,
6339 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6341 TRACE("iface %p, value %p.\n", iface
, value
);
6342 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_INT
);
6347 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetIntArray(ID3D10EffectScalarVariable
*iface
,
6348 int *values
, UINT offset
, UINT count
)
6350 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6352 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6353 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_INT
, 0, count
);
6358 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetIntArray(ID3D10EffectScalarVariable
*iface
,
6359 int *values
, UINT offset
, UINT count
)
6361 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6363 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6364 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_INT
, 0, count
);
6369 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetBool(ID3D10EffectScalarVariable
*iface
,
6372 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6374 TRACE("iface %p, value %d.\n", iface
, value
);
6375 write_variable_to_buffer(effect_var
, &value
, D3D10_SVT_BOOL
);
6380 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetBool(ID3D10EffectScalarVariable
*iface
,
6383 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6385 TRACE("iface %p, value %p.\n", iface
, value
);
6386 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_BOOL
);
6391 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_SetBoolArray(ID3D10EffectScalarVariable
*iface
,
6392 BOOL
*values
, UINT offset
, UINT count
)
6394 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6396 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6397 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_BOOL
, 0, count
);
6402 static HRESULT STDMETHODCALLTYPE
d3d10_effect_scalar_variable_GetBoolArray(ID3D10EffectScalarVariable
*iface
,
6403 BOOL
*values
, UINT offset
, UINT count
)
6405 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectScalarVariable(iface
);
6407 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6408 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_BOOL
, 0, count
);
6413 static const struct ID3D10EffectScalarVariableVtbl d3d10_effect_scalar_variable_vtbl
=
6415 /* ID3D10EffectVariable methods */
6416 d3d10_effect_scalar_variable_IsValid
,
6417 d3d10_effect_scalar_variable_GetType
,
6418 d3d10_effect_scalar_variable_GetDesc
,
6419 d3d10_effect_scalar_variable_GetAnnotationByIndex
,
6420 d3d10_effect_scalar_variable_GetAnnotationByName
,
6421 d3d10_effect_scalar_variable_GetMemberByIndex
,
6422 d3d10_effect_scalar_variable_GetMemberByName
,
6423 d3d10_effect_scalar_variable_GetMemberBySemantic
,
6424 d3d10_effect_scalar_variable_GetElement
,
6425 d3d10_effect_scalar_variable_GetParentConstantBuffer
,
6426 d3d10_effect_scalar_variable_AsScalar
,
6427 d3d10_effect_scalar_variable_AsVector
,
6428 d3d10_effect_scalar_variable_AsMatrix
,
6429 d3d10_effect_scalar_variable_AsString
,
6430 d3d10_effect_scalar_variable_AsShaderResource
,
6431 d3d10_effect_scalar_variable_AsRenderTargetView
,
6432 d3d10_effect_scalar_variable_AsDepthStencilView
,
6433 d3d10_effect_scalar_variable_AsConstantBuffer
,
6434 d3d10_effect_scalar_variable_AsShader
,
6435 d3d10_effect_scalar_variable_AsBlend
,
6436 d3d10_effect_scalar_variable_AsDepthStencil
,
6437 d3d10_effect_scalar_variable_AsRasterizer
,
6438 d3d10_effect_scalar_variable_AsSampler
,
6439 d3d10_effect_scalar_variable_SetRawValue
,
6440 d3d10_effect_scalar_variable_GetRawValue
,
6441 /* ID3D10EffectScalarVariable methods */
6442 d3d10_effect_scalar_variable_SetFloat
,
6443 d3d10_effect_scalar_variable_GetFloat
,
6444 d3d10_effect_scalar_variable_SetFloatArray
,
6445 d3d10_effect_scalar_variable_GetFloatArray
,
6446 d3d10_effect_scalar_variable_SetInt
,
6447 d3d10_effect_scalar_variable_GetInt
,
6448 d3d10_effect_scalar_variable_SetIntArray
,
6449 d3d10_effect_scalar_variable_GetIntArray
,
6450 d3d10_effect_scalar_variable_SetBool
,
6451 d3d10_effect_scalar_variable_GetBool
,
6452 d3d10_effect_scalar_variable_SetBoolArray
,
6453 d3d10_effect_scalar_variable_GetBoolArray
,
6456 /* ID3D10EffectVariable methods */
6458 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectVectorVariable(ID3D10EffectVectorVariable
*iface
)
6460 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
6463 static BOOL STDMETHODCALLTYPE
d3d10_effect_vector_variable_IsValid(ID3D10EffectVectorVariable
*iface
)
6465 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectVectorVariable(iface
);
6467 TRACE("iface %p\n", iface
);
6469 return v
!= &null_vector_variable
;
6472 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetType(
6473 ID3D10EffectVectorVariable
*iface
)
6475 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
6478 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetDesc(ID3D10EffectVectorVariable
*iface
,
6479 D3D10_EFFECT_VARIABLE_DESC
*desc
)
6481 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
6484 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetAnnotationByIndex(
6485 ID3D10EffectVectorVariable
*iface
, UINT index
)
6487 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
6490 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetAnnotationByName(
6491 ID3D10EffectVectorVariable
*iface
, const char *name
)
6493 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
6496 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetMemberByIndex(
6497 ID3D10EffectVectorVariable
*iface
, UINT index
)
6499 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
6502 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetMemberByName(
6503 ID3D10EffectVectorVariable
*iface
, const char *name
)
6505 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
6508 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetMemberBySemantic(
6509 ID3D10EffectVectorVariable
*iface
, const char *semantic
)
6511 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
6514 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetElement(
6515 ID3D10EffectVectorVariable
*iface
, UINT index
)
6517 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
6520 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetParentConstantBuffer(
6521 ID3D10EffectVectorVariable
*iface
)
6523 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
6526 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsScalar(
6527 ID3D10EffectVectorVariable
*iface
)
6529 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
6532 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsVector(
6533 ID3D10EffectVectorVariable
*iface
)
6535 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
6538 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsMatrix(
6539 ID3D10EffectVectorVariable
*iface
)
6541 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
6544 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsString(
6545 ID3D10EffectVectorVariable
*iface
)
6547 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
6550 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsShaderResource(
6551 ID3D10EffectVectorVariable
*iface
)
6553 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
6556 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsRenderTargetView(
6557 ID3D10EffectVectorVariable
*iface
)
6559 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
6562 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsDepthStencilView(
6563 ID3D10EffectVectorVariable
*iface
)
6565 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
6568 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsConstantBuffer(
6569 ID3D10EffectVectorVariable
*iface
)
6571 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
6574 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsShader(
6575 ID3D10EffectVectorVariable
*iface
)
6577 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
6580 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsBlend(
6581 ID3D10EffectVectorVariable
*iface
)
6583 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
6586 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsDepthStencil(
6587 ID3D10EffectVectorVariable
*iface
)
6589 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
6592 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsRasterizer(
6593 ID3D10EffectVectorVariable
*iface
)
6595 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
6598 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_vector_variable_AsSampler(
6599 ID3D10EffectVectorVariable
*iface
)
6601 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
6604 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetRawValue(ID3D10EffectVectorVariable
*iface
,
6605 void *data
, UINT offset
, UINT count
)
6607 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6610 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetRawValue(ID3D10EffectVectorVariable
*iface
,
6611 void *data
, UINT offset
, UINT count
)
6613 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
6616 /* ID3D10EffectVectorVariable methods */
6618 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetBoolVector(ID3D10EffectVectorVariable
*iface
,
6621 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6623 TRACE("iface %p, value %p.\n", iface
, value
);
6624 write_variable_to_buffer(effect_var
, value
, D3D10_SVT_BOOL
);
6629 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetIntVector(ID3D10EffectVectorVariable
*iface
,
6632 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6634 TRACE("iface %p, value %p.\n", iface
, value
);
6635 write_variable_to_buffer(effect_var
, value
, D3D10_SVT_INT
);
6640 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetFloatVector(ID3D10EffectVectorVariable
*iface
,
6643 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6645 TRACE("iface %p, value %p.\n", iface
, value
);
6646 write_variable_to_buffer(effect_var
, value
, D3D10_SVT_FLOAT
);
6651 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetBoolVector(ID3D10EffectVectorVariable
*iface
,
6654 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6656 TRACE("iface %p, value %p.\n", iface
, value
);
6657 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_BOOL
);
6662 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetIntVector(ID3D10EffectVectorVariable
*iface
,
6665 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6667 TRACE("iface %p, value %p.\n", iface
, value
);
6668 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_INT
);
6673 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetFloatVector(ID3D10EffectVectorVariable
*iface
,
6676 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6678 TRACE("iface %p, value %p.\n", iface
, value
);
6679 read_variable_from_buffer(effect_var
, value
, D3D10_SVT_FLOAT
);
6684 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetBoolVectorArray(ID3D10EffectVectorVariable
*iface
,
6685 BOOL
*values
, UINT offset
, UINT count
)
6687 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6689 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6690 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_BOOL
, offset
, count
);
6695 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetIntVectorArray(ID3D10EffectVectorVariable
*iface
,
6696 int *values
, UINT offset
, UINT count
)
6698 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6700 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6701 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_INT
, offset
, count
);
6706 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_SetFloatVectorArray(ID3D10EffectVectorVariable
*iface
,
6707 float *values
, UINT offset
, UINT count
)
6709 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6711 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6712 write_variable_array_to_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, offset
, count
);
6717 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetBoolVectorArray(ID3D10EffectVectorVariable
*iface
,
6718 BOOL
*values
, UINT offset
, UINT count
)
6720 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6722 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6723 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_BOOL
, offset
, count
);
6728 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetIntVectorArray(ID3D10EffectVectorVariable
*iface
,
6729 int *values
, UINT offset
, UINT count
)
6731 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6733 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6734 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_INT
, offset
, count
);
6739 static HRESULT STDMETHODCALLTYPE
d3d10_effect_vector_variable_GetFloatVectorArray(ID3D10EffectVectorVariable
*iface
,
6740 float *values
, UINT offset
, UINT count
)
6742 struct d3d10_effect_variable
*effect_var
= impl_from_ID3D10EffectVectorVariable(iface
);
6744 TRACE("iface %p, values %p, offset %u, count %u.\n", iface
, values
, offset
, count
);
6745 read_variable_array_from_buffer(effect_var
, values
, D3D10_SVT_FLOAT
, offset
, count
);
6750 static const struct ID3D10EffectVectorVariableVtbl d3d10_effect_vector_variable_vtbl
=
6752 /* ID3D10EffectVariable methods */
6753 d3d10_effect_vector_variable_IsValid
,
6754 d3d10_effect_vector_variable_GetType
,
6755 d3d10_effect_vector_variable_GetDesc
,
6756 d3d10_effect_vector_variable_GetAnnotationByIndex
,
6757 d3d10_effect_vector_variable_GetAnnotationByName
,
6758 d3d10_effect_vector_variable_GetMemberByIndex
,
6759 d3d10_effect_vector_variable_GetMemberByName
,
6760 d3d10_effect_vector_variable_GetMemberBySemantic
,
6761 d3d10_effect_vector_variable_GetElement
,
6762 d3d10_effect_vector_variable_GetParentConstantBuffer
,
6763 d3d10_effect_vector_variable_AsScalar
,
6764 d3d10_effect_vector_variable_AsVector
,
6765 d3d10_effect_vector_variable_AsMatrix
,
6766 d3d10_effect_vector_variable_AsString
,
6767 d3d10_effect_vector_variable_AsShaderResource
,
6768 d3d10_effect_vector_variable_AsRenderTargetView
,
6769 d3d10_effect_vector_variable_AsDepthStencilView
,
6770 d3d10_effect_vector_variable_AsConstantBuffer
,
6771 d3d10_effect_vector_variable_AsShader
,
6772 d3d10_effect_vector_variable_AsBlend
,
6773 d3d10_effect_vector_variable_AsDepthStencil
,
6774 d3d10_effect_vector_variable_AsRasterizer
,
6775 d3d10_effect_vector_variable_AsSampler
,
6776 d3d10_effect_vector_variable_SetRawValue
,
6777 d3d10_effect_vector_variable_GetRawValue
,
6778 /* ID3D10EffectVectorVariable methods */
6779 d3d10_effect_vector_variable_SetBoolVector
,
6780 d3d10_effect_vector_variable_SetIntVector
,
6781 d3d10_effect_vector_variable_SetFloatVector
,
6782 d3d10_effect_vector_variable_GetBoolVector
,
6783 d3d10_effect_vector_variable_GetIntVector
,
6784 d3d10_effect_vector_variable_GetFloatVector
,
6785 d3d10_effect_vector_variable_SetBoolVectorArray
,
6786 d3d10_effect_vector_variable_SetIntVectorArray
,
6787 d3d10_effect_vector_variable_SetFloatVectorArray
,
6788 d3d10_effect_vector_variable_GetBoolVectorArray
,
6789 d3d10_effect_vector_variable_GetIntVectorArray
,
6790 d3d10_effect_vector_variable_GetFloatVectorArray
,
6793 static void write_matrix_to_buffer(struct d3d10_effect_variable
*variable
, void *dst_void
,
6794 struct d3d10_matrix
*src
, BOOL transpose
)
6796 unsigned int col_count
= !transpose
? variable
->type
->column_count
: variable
->type
->row_count
;
6797 unsigned int row_count
= !transpose
? variable
->type
->row_count
: variable
->type
->column_count
;
6798 BOOL major
= variable
->type
->type_class
== D3D10_SVC_MATRIX_COLUMNS
;
6799 float *dst
= dst_void
;
6800 unsigned int row
, col
;
6807 for (col
= 0; col
< col_count
; ++col
)
6809 for (row
= 0; row
< row_count
; ++row
)
6810 dst
[(col
* 4) + row
] = src
->m
[row
][col
];
6815 for (row
= 0; row
< row_count
; ++row
)
6817 for (col
= 0; col
< col_count
; ++col
)
6818 dst
[(row
* 4) + col
] = src
->m
[row
][col
];
6823 static void write_matrix_variable_to_buffer(struct d3d10_effect_variable
*variable
, void *src_data
, BOOL transpose
)
6825 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6827 write_matrix_to_buffer(variable
, dst
, src_data
, transpose
);
6829 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6832 static void write_matrix_variable_array_to_buffer(struct d3d10_effect_variable
*variable
, void *src_data
,
6833 unsigned int offset
, unsigned int count
, BOOL transpose
)
6835 BYTE
*dst
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6836 struct d3d10_matrix
*src
= src_data
;
6839 if (!variable
->type
->element_count
)
6841 write_matrix_variable_to_buffer(variable
, src_data
, transpose
);
6845 if (offset
>= variable
->type
->element_count
)
6847 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6851 if (count
> variable
->type
->element_count
- offset
)
6853 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6854 offset
, count
, variable
->type
->element_count
);
6855 count
= variable
->type
->element_count
- offset
;
6859 dst
+= variable
->type
->stride
* offset
;
6861 for (i
= 0; i
< count
; ++i
)
6863 write_matrix_to_buffer(variable
, dst
, &src
[i
], transpose
);
6865 dst
+= variable
->type
->stride
;
6868 variable
->buffer
->u
.buffer
.changed
= TRUE
;
6871 static void read_matrix_from_buffer(struct d3d10_effect_variable
*variable
, void *src_void
,
6872 struct d3d10_matrix
*dst
, BOOL transpose
)
6874 unsigned int col_count
= !transpose
? variable
->type
->column_count
: variable
->type
->row_count
;
6875 unsigned int row_count
= !transpose
? variable
->type
->row_count
: variable
->type
->column_count
;
6876 BOOL major
= variable
->type
->type_class
== D3D10_SVC_MATRIX_COLUMNS
;
6877 float *src
= src_void
;
6878 unsigned int row
, col
;
6885 for (col
= 0; col
< col_count
; ++col
)
6887 for (row
= 0; row
< row_count
; ++row
)
6888 dst
->m
[row
][col
] = src
[(col
* 4) + row
];
6893 for (row
= 0; row
< row_count
; ++row
)
6895 for (col
= 0; col
< col_count
; ++col
)
6896 dst
->m
[row
][col
] = src
[(row
* 4) + col
];
6901 static void read_matrix_variable_from_buffer(struct d3d10_effect_variable
*variable
, void *dst
, BOOL transpose
)
6903 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6905 read_matrix_from_buffer(variable
, src
, dst
, transpose
);
6908 static void read_matrix_variable_array_from_buffer(struct d3d10_effect_variable
*variable
, void *dst_data
, UINT offset
,
6909 UINT count
, BOOL transpose
)
6911 BYTE
*src
= variable
->buffer
->u
.buffer
.local_buffer
+ variable
->buffer_offset
;
6912 struct d3d10_matrix
*dst
= dst_data
;
6915 if (!variable
->type
->element_count
)
6917 read_matrix_variable_from_buffer(variable
, dst_data
, transpose
);
6921 if (offset
>= variable
->type
->element_count
)
6923 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, variable
->type
->element_count
);
6927 if (count
> variable
->type
->element_count
- offset
)
6929 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
6930 offset
, count
, variable
->type
->element_count
);
6931 count
= variable
->type
->element_count
- offset
;
6935 src
+= variable
->type
->stride
* offset
;
6937 for (i
= 0; i
< count
; ++i
)
6939 read_matrix_from_buffer(variable
, src
, &dst
[i
], transpose
);
6941 src
+= variable
->type
->stride
;
6945 /* ID3D10EffectVariable methods */
6947 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectMatrixVariable(ID3D10EffectMatrixVariable
*iface
)
6949 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
6952 static BOOL STDMETHODCALLTYPE
d3d10_effect_matrix_variable_IsValid(ID3D10EffectMatrixVariable
*iface
)
6954 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectMatrixVariable(iface
);
6956 TRACE("iface %p\n", iface
);
6958 return v
!= &null_matrix_variable
;
6961 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetType(
6962 ID3D10EffectMatrixVariable
*iface
)
6964 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
6967 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetDesc(ID3D10EffectMatrixVariable
*iface
,
6968 D3D10_EFFECT_VARIABLE_DESC
*desc
)
6970 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
6973 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetAnnotationByIndex(
6974 ID3D10EffectMatrixVariable
*iface
, UINT index
)
6976 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
6979 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetAnnotationByName(
6980 ID3D10EffectMatrixVariable
*iface
, const char *name
)
6982 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
6985 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMemberByIndex(
6986 ID3D10EffectMatrixVariable
*iface
, UINT index
)
6988 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
6991 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMemberByName(
6992 ID3D10EffectMatrixVariable
*iface
, const char *name
)
6994 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
6997 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMemberBySemantic(
6998 ID3D10EffectMatrixVariable
*iface
, const char *semantic
)
7000 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7003 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetElement(
7004 ID3D10EffectMatrixVariable
*iface
, UINT index
)
7006 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7009 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetParentConstantBuffer(
7010 ID3D10EffectMatrixVariable
*iface
)
7012 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7015 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsScalar(
7016 ID3D10EffectMatrixVariable
*iface
)
7018 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7021 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsVector(
7022 ID3D10EffectMatrixVariable
*iface
)
7024 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7027 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsMatrix(
7028 ID3D10EffectMatrixVariable
*iface
)
7030 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7033 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsString(
7034 ID3D10EffectMatrixVariable
*iface
)
7036 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7039 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsShaderResource(
7040 ID3D10EffectMatrixVariable
*iface
)
7042 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7045 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsRenderTargetView(
7046 ID3D10EffectMatrixVariable
*iface
)
7048 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7051 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsDepthStencilView(
7052 ID3D10EffectMatrixVariable
*iface
)
7054 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7057 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsConstantBuffer(
7058 ID3D10EffectMatrixVariable
*iface
)
7060 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7063 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsShader(
7064 ID3D10EffectMatrixVariable
*iface
)
7066 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7069 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsBlend(
7070 ID3D10EffectMatrixVariable
*iface
)
7072 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7075 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsDepthStencil(
7076 ID3D10EffectMatrixVariable
*iface
)
7078 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7081 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsRasterizer(
7082 ID3D10EffectMatrixVariable
*iface
)
7084 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7087 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_matrix_variable_AsSampler(
7088 ID3D10EffectMatrixVariable
*iface
)
7090 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7093 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetRawValue(ID3D10EffectMatrixVariable
*iface
,
7094 void *data
, UINT offset
, UINT count
)
7096 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7099 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetRawValue(ID3D10EffectMatrixVariable
*iface
,
7100 void *data
, UINT offset
, UINT count
)
7102 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7105 /* ID3D10EffectMatrixVariable methods */
7107 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrix(ID3D10EffectMatrixVariable
*iface
,
7110 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7112 TRACE("iface %p, data %p.\n", iface
, data
);
7113 write_matrix_variable_to_buffer(var
, data
, FALSE
);
7118 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrix(ID3D10EffectMatrixVariable
*iface
,
7121 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7123 TRACE("iface %p, data %p.\n", iface
, data
);
7124 read_matrix_variable_from_buffer(var
, data
, FALSE
);
7129 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrixArray(ID3D10EffectMatrixVariable
*iface
,
7130 float *data
, UINT offset
, UINT count
)
7132 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7134 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7135 write_matrix_variable_array_to_buffer(var
, data
, offset
, count
, FALSE
);
7140 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrixArray(ID3D10EffectMatrixVariable
*iface
,
7141 float *data
, UINT offset
, UINT count
)
7143 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7145 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7146 read_matrix_variable_array_from_buffer(var
, data
, offset
, count
, FALSE
);
7151 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrixTranspose(ID3D10EffectMatrixVariable
*iface
,
7154 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7156 TRACE("iface %p, data %p.\n", iface
, data
);
7157 write_matrix_variable_to_buffer(var
, data
, TRUE
);
7162 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrixTranspose(ID3D10EffectMatrixVariable
*iface
,
7165 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7167 TRACE("iface %p, data %p.\n", iface
, data
);
7168 read_matrix_variable_from_buffer(var
, data
, TRUE
);
7173 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_SetMatrixTransposeArray(ID3D10EffectMatrixVariable
*iface
,
7174 float *data
, UINT offset
, UINT count
)
7176 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7178 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7179 write_matrix_variable_array_to_buffer(var
, data
, offset
, count
, TRUE
);
7184 static HRESULT STDMETHODCALLTYPE
d3d10_effect_matrix_variable_GetMatrixTransposeArray(ID3D10EffectMatrixVariable
*iface
,
7185 float *data
, UINT offset
, UINT count
)
7187 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectMatrixVariable(iface
);
7189 TRACE("iface %p, data %p, offset %u, count %u.\n", iface
, data
, offset
, count
);
7190 read_matrix_variable_array_from_buffer(var
, data
, offset
, count
, TRUE
);
7196 static const struct ID3D10EffectMatrixVariableVtbl d3d10_effect_matrix_variable_vtbl
=
7198 /* ID3D10EffectVariable methods */
7199 d3d10_effect_matrix_variable_IsValid
,
7200 d3d10_effect_matrix_variable_GetType
,
7201 d3d10_effect_matrix_variable_GetDesc
,
7202 d3d10_effect_matrix_variable_GetAnnotationByIndex
,
7203 d3d10_effect_matrix_variable_GetAnnotationByName
,
7204 d3d10_effect_matrix_variable_GetMemberByIndex
,
7205 d3d10_effect_matrix_variable_GetMemberByName
,
7206 d3d10_effect_matrix_variable_GetMemberBySemantic
,
7207 d3d10_effect_matrix_variable_GetElement
,
7208 d3d10_effect_matrix_variable_GetParentConstantBuffer
,
7209 d3d10_effect_matrix_variable_AsScalar
,
7210 d3d10_effect_matrix_variable_AsVector
,
7211 d3d10_effect_matrix_variable_AsMatrix
,
7212 d3d10_effect_matrix_variable_AsString
,
7213 d3d10_effect_matrix_variable_AsShaderResource
,
7214 d3d10_effect_matrix_variable_AsRenderTargetView
,
7215 d3d10_effect_matrix_variable_AsDepthStencilView
,
7216 d3d10_effect_matrix_variable_AsConstantBuffer
,
7217 d3d10_effect_matrix_variable_AsShader
,
7218 d3d10_effect_matrix_variable_AsBlend
,
7219 d3d10_effect_matrix_variable_AsDepthStencil
,
7220 d3d10_effect_matrix_variable_AsRasterizer
,
7221 d3d10_effect_matrix_variable_AsSampler
,
7222 d3d10_effect_matrix_variable_SetRawValue
,
7223 d3d10_effect_matrix_variable_GetRawValue
,
7224 /* ID3D10EffectMatrixVariable methods */
7225 d3d10_effect_matrix_variable_SetMatrix
,
7226 d3d10_effect_matrix_variable_GetMatrix
,
7227 d3d10_effect_matrix_variable_SetMatrixArray
,
7228 d3d10_effect_matrix_variable_GetMatrixArray
,
7229 d3d10_effect_matrix_variable_SetMatrixTranspose
,
7230 d3d10_effect_matrix_variable_GetMatrixTranspose
,
7231 d3d10_effect_matrix_variable_SetMatrixTransposeArray
,
7232 d3d10_effect_matrix_variable_GetMatrixTransposeArray
,
7235 /* ID3D10EffectVariable methods */
7237 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectStringVariable(ID3D10EffectStringVariable
*iface
)
7239 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7242 static BOOL STDMETHODCALLTYPE
d3d10_effect_string_variable_IsValid(ID3D10EffectStringVariable
*iface
)
7244 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectStringVariable(iface
);
7246 TRACE("iface %p\n", iface
);
7248 return v
!= &null_string_variable
;
7251 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetType(
7252 ID3D10EffectStringVariable
*iface
)
7254 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7257 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetDesc(ID3D10EffectStringVariable
*iface
,
7258 D3D10_EFFECT_VARIABLE_DESC
*desc
)
7260 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7263 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetAnnotationByIndex(
7264 ID3D10EffectStringVariable
*iface
, UINT index
)
7266 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7269 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetAnnotationByName(
7270 ID3D10EffectStringVariable
*iface
, const char *name
)
7272 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7275 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetMemberByIndex(
7276 ID3D10EffectStringVariable
*iface
, UINT index
)
7278 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7281 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetMemberByName(
7282 ID3D10EffectStringVariable
*iface
, const char *name
)
7284 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7287 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetMemberBySemantic(
7288 ID3D10EffectStringVariable
*iface
, const char *semantic
)
7290 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7293 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetElement(
7294 ID3D10EffectStringVariable
*iface
, UINT index
)
7296 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7299 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_string_variable_GetParentConstantBuffer(
7300 ID3D10EffectStringVariable
*iface
)
7302 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7305 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsScalar(
7306 ID3D10EffectStringVariable
*iface
)
7308 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7311 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsVector(
7312 ID3D10EffectStringVariable
*iface
)
7314 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7317 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsMatrix(
7318 ID3D10EffectStringVariable
*iface
)
7320 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7323 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsString(
7324 ID3D10EffectStringVariable
*iface
)
7326 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7329 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsShaderResource(
7330 ID3D10EffectStringVariable
*iface
)
7332 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7335 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsRenderTargetView(
7336 ID3D10EffectStringVariable
*iface
)
7338 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7341 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsDepthStencilView(
7342 ID3D10EffectStringVariable
*iface
)
7344 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7347 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsConstantBuffer(
7348 ID3D10EffectStringVariable
*iface
)
7350 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7353 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsShader(
7354 ID3D10EffectStringVariable
*iface
)
7356 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7359 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsBlend(
7360 ID3D10EffectStringVariable
*iface
)
7362 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7365 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsDepthStencil(
7366 ID3D10EffectStringVariable
*iface
)
7368 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7371 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsRasterizer(
7372 ID3D10EffectStringVariable
*iface
)
7374 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7377 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_string_variable_AsSampler(
7378 ID3D10EffectStringVariable
*iface
)
7380 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7383 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_SetRawValue(ID3D10EffectStringVariable
*iface
,
7384 void *data
, UINT offset
, UINT count
)
7386 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7389 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetRawValue(ID3D10EffectStringVariable
*iface
,
7390 void *data
, UINT offset
, UINT count
)
7392 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7395 /* ID3D10EffectStringVariable methods */
7397 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetString(ID3D10EffectStringVariable
*iface
,
7400 struct d3d10_effect_variable
*var
= impl_from_ID3D10EffectStringVariable(iface
);
7401 char *value
= (char *)var
->u
.buffer
.local_buffer
;
7403 TRACE("iface %p, str %p.\n", iface
, str
);
7409 return E_INVALIDARG
;
7416 static HRESULT STDMETHODCALLTYPE
d3d10_effect_string_variable_GetStringArray(ID3D10EffectStringVariable
*iface
,
7417 const char **strs
, UINT offset
, UINT count
)
7419 FIXME("iface %p, strs %p, offset %u, count %u stub!\n", iface
, strs
, offset
, count
);
7425 static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_vtbl
=
7427 /* ID3D10EffectVariable methods */
7428 d3d10_effect_string_variable_IsValid
,
7429 d3d10_effect_string_variable_GetType
,
7430 d3d10_effect_string_variable_GetDesc
,
7431 d3d10_effect_string_variable_GetAnnotationByIndex
,
7432 d3d10_effect_string_variable_GetAnnotationByName
,
7433 d3d10_effect_string_variable_GetMemberByIndex
,
7434 d3d10_effect_string_variable_GetMemberByName
,
7435 d3d10_effect_string_variable_GetMemberBySemantic
,
7436 d3d10_effect_string_variable_GetElement
,
7437 d3d10_effect_string_variable_GetParentConstantBuffer
,
7438 d3d10_effect_string_variable_AsScalar
,
7439 d3d10_effect_string_variable_AsVector
,
7440 d3d10_effect_string_variable_AsMatrix
,
7441 d3d10_effect_string_variable_AsString
,
7442 d3d10_effect_string_variable_AsShaderResource
,
7443 d3d10_effect_string_variable_AsRenderTargetView
,
7444 d3d10_effect_string_variable_AsDepthStencilView
,
7445 d3d10_effect_string_variable_AsConstantBuffer
,
7446 d3d10_effect_string_variable_AsShader
,
7447 d3d10_effect_string_variable_AsBlend
,
7448 d3d10_effect_string_variable_AsDepthStencil
,
7449 d3d10_effect_string_variable_AsRasterizer
,
7450 d3d10_effect_string_variable_AsSampler
,
7451 d3d10_effect_string_variable_SetRawValue
,
7452 d3d10_effect_string_variable_GetRawValue
,
7453 /* ID3D10EffectStringVariable methods */
7454 d3d10_effect_string_variable_GetString
,
7455 d3d10_effect_string_variable_GetStringArray
,
7458 static void set_shader_resource_variable(ID3D10ShaderResourceView
**src
, ID3D10ShaderResourceView
**dst
)
7464 ID3D10ShaderResourceView_AddRef(*src
);
7466 ID3D10ShaderResourceView_Release(*dst
);
7471 /* ID3D10EffectVariable methods */
7473 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectShaderResourceVariable(
7474 ID3D10EffectShaderResourceVariable
*iface
)
7476 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7479 static BOOL STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_IsValid(ID3D10EffectShaderResourceVariable
*iface
)
7481 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderResourceVariable(iface
);
7483 TRACE("iface %p.\n", iface
);
7485 return v
!= &null_shader_resource_variable
;
7488 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetType(
7489 ID3D10EffectShaderResourceVariable
*iface
)
7491 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7494 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetDesc(
7495 ID3D10EffectShaderResourceVariable
*iface
, D3D10_EFFECT_VARIABLE_DESC
*desc
)
7497 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7500 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetAnnotationByIndex(
7501 ID3D10EffectShaderResourceVariable
*iface
, UINT index
)
7503 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7506 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetAnnotationByName(
7507 ID3D10EffectShaderResourceVariable
*iface
, const char *name
)
7509 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7512 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetMemberByIndex(
7513 ID3D10EffectShaderResourceVariable
*iface
, UINT index
)
7515 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7518 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetMemberByName(
7519 ID3D10EffectShaderResourceVariable
*iface
, const char *name
)
7521 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7524 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetMemberBySemantic(
7525 ID3D10EffectShaderResourceVariable
*iface
, const char *semantic
)
7527 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7530 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetElement(
7531 ID3D10EffectShaderResourceVariable
*iface
, UINT index
)
7533 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7536 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetParentConstantBuffer(
7537 ID3D10EffectShaderResourceVariable
*iface
)
7539 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7542 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsScalar(
7543 ID3D10EffectShaderResourceVariable
*iface
)
7545 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7548 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsVector(
7549 ID3D10EffectShaderResourceVariable
*iface
)
7551 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7554 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsMatrix(
7555 ID3D10EffectShaderResourceVariable
*iface
)
7557 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7560 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsString(
7561 ID3D10EffectShaderResourceVariable
*iface
)
7563 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7566 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsShaderResource(
7567 ID3D10EffectShaderResourceVariable
*iface
)
7569 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7572 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsRenderTargetView(
7573 ID3D10EffectShaderResourceVariable
*iface
)
7575 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7578 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsDepthStencilView(
7579 ID3D10EffectShaderResourceVariable
*iface
)
7581 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7584 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsConstantBuffer(
7585 ID3D10EffectShaderResourceVariable
*iface
)
7587 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7590 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsShader(
7591 ID3D10EffectShaderResourceVariable
*iface
)
7593 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7596 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsBlend(
7597 ID3D10EffectShaderResourceVariable
*iface
)
7599 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7602 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsDepthStencil(
7603 ID3D10EffectShaderResourceVariable
*iface
)
7605 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7608 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsRasterizer(
7609 ID3D10EffectShaderResourceVariable
*iface
)
7611 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7614 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_AsSampler(
7615 ID3D10EffectShaderResourceVariable
*iface
)
7617 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7620 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_SetRawValue(
7621 ID3D10EffectShaderResourceVariable
*iface
, void *data
, UINT offset
, UINT count
)
7623 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7626 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetRawValue(
7627 ID3D10EffectShaderResourceVariable
*iface
, void *data
, UINT offset
, UINT count
)
7629 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7632 /* ID3D10EffectShaderResourceVariable methods */
7634 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_SetResource(
7635 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
*resource
)
7637 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderResourceVariable(iface
);
7639 TRACE("iface %p, resource %p.\n", iface
, resource
);
7641 if (!d3d10_effect_shader_resource_variable_IsValid(iface
))
7644 set_shader_resource_variable(&resource
, v
->u
.resource
.srv
);
7649 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetResource(
7650 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
**resource
)
7652 FIXME("iface %p, resource %p stub!\n", iface
, resource
);
7657 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_SetResourceArray(
7658 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
**resources
, UINT offset
, UINT count
)
7660 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderResourceVariable(iface
);
7661 ID3D10ShaderResourceView
**rsrc_view
;
7664 TRACE("iface %p, resources %p, offset %u, count %u.\n", iface
, resources
, offset
, count
);
7666 if (!v
->type
->element_count
)
7667 return d3d10_effect_shader_resource_variable_SetResource(iface
, *resources
);
7669 if (offset
>= v
->type
->element_count
)
7671 WARN("Offset %u larger than element count %u, ignoring.\n", offset
, v
->type
->element_count
);
7675 if (count
> v
->type
->element_count
- offset
)
7677 WARN("Offset %u, count %u overruns the variable (element count %u), fixing up.\n",
7678 offset
, count
, v
->type
->element_count
);
7679 count
= v
->type
->element_count
- offset
;
7682 rsrc_view
= &v
->u
.resource
.srv
[offset
];
7683 for (i
= 0; i
< count
; ++i
)
7684 set_shader_resource_variable(&resources
[i
], &rsrc_view
[i
]);
7689 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_resource_variable_GetResourceArray(
7690 ID3D10EffectShaderResourceVariable
*iface
, ID3D10ShaderResourceView
**resources
, UINT offset
, UINT count
)
7692 FIXME("iface %p, resources %p, offset %u, count %u stub!\n", iface
, resources
, offset
, count
);
7698 static const struct ID3D10EffectShaderResourceVariableVtbl d3d10_effect_shader_resource_variable_vtbl
=
7700 /* ID3D10EffectVariable methods */
7701 d3d10_effect_shader_resource_variable_IsValid
,
7702 d3d10_effect_shader_resource_variable_GetType
,
7703 d3d10_effect_shader_resource_variable_GetDesc
,
7704 d3d10_effect_shader_resource_variable_GetAnnotationByIndex
,
7705 d3d10_effect_shader_resource_variable_GetAnnotationByName
,
7706 d3d10_effect_shader_resource_variable_GetMemberByIndex
,
7707 d3d10_effect_shader_resource_variable_GetMemberByName
,
7708 d3d10_effect_shader_resource_variable_GetMemberBySemantic
,
7709 d3d10_effect_shader_resource_variable_GetElement
,
7710 d3d10_effect_shader_resource_variable_GetParentConstantBuffer
,
7711 d3d10_effect_shader_resource_variable_AsScalar
,
7712 d3d10_effect_shader_resource_variable_AsVector
,
7713 d3d10_effect_shader_resource_variable_AsMatrix
,
7714 d3d10_effect_shader_resource_variable_AsString
,
7715 d3d10_effect_shader_resource_variable_AsShaderResource
,
7716 d3d10_effect_shader_resource_variable_AsRenderTargetView
,
7717 d3d10_effect_shader_resource_variable_AsDepthStencilView
,
7718 d3d10_effect_shader_resource_variable_AsConstantBuffer
,
7719 d3d10_effect_shader_resource_variable_AsShader
,
7720 d3d10_effect_shader_resource_variable_AsBlend
,
7721 d3d10_effect_shader_resource_variable_AsDepthStencil
,
7722 d3d10_effect_shader_resource_variable_AsRasterizer
,
7723 d3d10_effect_shader_resource_variable_AsSampler
,
7724 d3d10_effect_shader_resource_variable_SetRawValue
,
7725 d3d10_effect_shader_resource_variable_GetRawValue
,
7726 /* ID3D10EffectShaderResourceVariable methods */
7727 d3d10_effect_shader_resource_variable_SetResource
,
7728 d3d10_effect_shader_resource_variable_GetResource
,
7729 d3d10_effect_shader_resource_variable_SetResourceArray
,
7730 d3d10_effect_shader_resource_variable_GetResourceArray
,
7733 /* ID3D10EffectVariable methods */
7735 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectRenderTargetViewVariable(
7736 ID3D10EffectRenderTargetViewVariable
*iface
)
7738 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7741 static BOOL STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_IsValid(
7742 ID3D10EffectRenderTargetViewVariable
*iface
)
7744 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRenderTargetViewVariable(iface
);
7746 TRACE("iface %p\n", iface
);
7748 return v
!= &null_render_target_view_variable
;
7751 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetType(
7752 ID3D10EffectRenderTargetViewVariable
*iface
)
7754 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7757 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetDesc(
7758 ID3D10EffectRenderTargetViewVariable
*iface
, D3D10_EFFECT_VARIABLE_DESC
*desc
)
7760 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7763 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetAnnotationByIndex(
7764 ID3D10EffectRenderTargetViewVariable
*iface
, UINT index
)
7766 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
7769 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetAnnotationByName(
7770 ID3D10EffectRenderTargetViewVariable
*iface
, const char *name
)
7772 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
7775 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetMemberByIndex(
7776 ID3D10EffectRenderTargetViewVariable
*iface
, UINT index
)
7778 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
7781 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetMemberByName(
7782 ID3D10EffectRenderTargetViewVariable
*iface
, const char *name
)
7784 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
7787 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetMemberBySemantic(
7788 ID3D10EffectRenderTargetViewVariable
*iface
, const char *semantic
)
7790 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
7793 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetElement(
7794 ID3D10EffectRenderTargetViewVariable
*iface
, UINT index
)
7796 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
7799 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetParentConstantBuffer(
7800 ID3D10EffectRenderTargetViewVariable
*iface
)
7802 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
7805 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsScalar(
7806 ID3D10EffectRenderTargetViewVariable
*iface
)
7808 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
7811 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsVector(
7812 ID3D10EffectRenderTargetViewVariable
*iface
)
7814 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
7817 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsMatrix(
7818 ID3D10EffectRenderTargetViewVariable
*iface
)
7820 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
7823 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsString(
7824 ID3D10EffectRenderTargetViewVariable
*iface
)
7826 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
7829 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsShaderResource(
7830 ID3D10EffectRenderTargetViewVariable
*iface
)
7832 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
7835 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsRenderTargetView(
7836 ID3D10EffectRenderTargetViewVariable
*iface
)
7838 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
7841 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsDepthStencilView(
7842 ID3D10EffectRenderTargetViewVariable
*iface
)
7844 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
7847 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsConstantBuffer(
7848 ID3D10EffectRenderTargetViewVariable
*iface
)
7850 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
7853 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsShader(
7854 ID3D10EffectRenderTargetViewVariable
*iface
)
7856 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
7859 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsBlend(
7860 ID3D10EffectRenderTargetViewVariable
*iface
)
7862 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
7865 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsDepthStencil(
7866 ID3D10EffectRenderTargetViewVariable
*iface
)
7868 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
7871 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsRasterizer(
7872 ID3D10EffectRenderTargetViewVariable
*iface
)
7874 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
7877 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_AsSampler(
7878 ID3D10EffectRenderTargetViewVariable
*iface
)
7880 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
7883 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_SetRawValue(
7884 ID3D10EffectRenderTargetViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
7886 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7889 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetRawValue(
7890 ID3D10EffectRenderTargetViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
7892 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
7895 /* ID3D10EffectRenderTargetViewVariable methods */
7897 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_SetRenderTarget(
7898 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
*view
)
7900 FIXME("iface %p, view %p stub!\n", iface
, view
);
7905 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetRenderTarget(
7906 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
**view
)
7908 FIXME("iface %p, view %p stub!\n", iface
, view
);
7913 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_SetRenderTargetArray(
7914 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
**views
, UINT offset
, UINT count
)
7916 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
7921 static HRESULT STDMETHODCALLTYPE
d3d10_effect_render_target_view_variable_GetRenderTargetArray(
7922 ID3D10EffectRenderTargetViewVariable
*iface
, ID3D10RenderTargetView
**views
, UINT offset
, UINT count
)
7924 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
7930 static const struct ID3D10EffectRenderTargetViewVariableVtbl d3d10_effect_render_target_view_variable_vtbl
=
7932 /* ID3D10EffectVariable methods */
7933 d3d10_effect_render_target_view_variable_IsValid
,
7934 d3d10_effect_render_target_view_variable_GetType
,
7935 d3d10_effect_render_target_view_variable_GetDesc
,
7936 d3d10_effect_render_target_view_variable_GetAnnotationByIndex
,
7937 d3d10_effect_render_target_view_variable_GetAnnotationByName
,
7938 d3d10_effect_render_target_view_variable_GetMemberByIndex
,
7939 d3d10_effect_render_target_view_variable_GetMemberByName
,
7940 d3d10_effect_render_target_view_variable_GetMemberBySemantic
,
7941 d3d10_effect_render_target_view_variable_GetElement
,
7942 d3d10_effect_render_target_view_variable_GetParentConstantBuffer
,
7943 d3d10_effect_render_target_view_variable_AsScalar
,
7944 d3d10_effect_render_target_view_variable_AsVector
,
7945 d3d10_effect_render_target_view_variable_AsMatrix
,
7946 d3d10_effect_render_target_view_variable_AsString
,
7947 d3d10_effect_render_target_view_variable_AsShaderResource
,
7948 d3d10_effect_render_target_view_variable_AsRenderTargetView
,
7949 d3d10_effect_render_target_view_variable_AsDepthStencilView
,
7950 d3d10_effect_render_target_view_variable_AsConstantBuffer
,
7951 d3d10_effect_render_target_view_variable_AsShader
,
7952 d3d10_effect_render_target_view_variable_AsBlend
,
7953 d3d10_effect_render_target_view_variable_AsDepthStencil
,
7954 d3d10_effect_render_target_view_variable_AsRasterizer
,
7955 d3d10_effect_render_target_view_variable_AsSampler
,
7956 d3d10_effect_render_target_view_variable_SetRawValue
,
7957 d3d10_effect_render_target_view_variable_GetRawValue
,
7958 /* ID3D10EffectRenderTargetViewVariable methods */
7959 d3d10_effect_render_target_view_variable_SetRenderTarget
,
7960 d3d10_effect_render_target_view_variable_GetRenderTarget
,
7961 d3d10_effect_render_target_view_variable_SetRenderTargetArray
,
7962 d3d10_effect_render_target_view_variable_GetRenderTargetArray
,
7965 /* ID3D10EffectVariable methods */
7967 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectDepthStencilViewVariable(
7968 ID3D10EffectDepthStencilViewVariable
*iface
)
7970 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
7973 static BOOL STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_IsValid(
7974 ID3D10EffectDepthStencilViewVariable
*iface
)
7976 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilViewVariable(iface
);
7978 TRACE("iface %p\n", iface
);
7980 return v
!= &null_depth_stencil_view_variable
;
7983 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetType(
7984 ID3D10EffectDepthStencilViewVariable
*iface
)
7986 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
7989 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetDesc(
7990 ID3D10EffectDepthStencilViewVariable
*iface
, D3D10_EFFECT_VARIABLE_DESC
*desc
)
7992 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
7995 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex(
7996 ID3D10EffectDepthStencilViewVariable
*iface
, UINT index
)
7998 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8001 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetAnnotationByName(
8002 ID3D10EffectDepthStencilViewVariable
*iface
, const char *name
)
8004 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8007 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetMemberByIndex(
8008 ID3D10EffectDepthStencilViewVariable
*iface
, UINT index
)
8010 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8013 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetMemberByName(
8014 ID3D10EffectDepthStencilViewVariable
*iface
, const char *name
)
8016 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8019 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic(
8020 ID3D10EffectDepthStencilViewVariable
*iface
, const char *semantic
)
8022 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8025 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetElement(
8026 ID3D10EffectDepthStencilViewVariable
*iface
, UINT index
)
8028 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8031 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer(
8032 ID3D10EffectDepthStencilViewVariable
*iface
)
8034 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8037 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsScalar(
8038 ID3D10EffectDepthStencilViewVariable
*iface
)
8040 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8043 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsVector(
8044 ID3D10EffectDepthStencilViewVariable
*iface
)
8046 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8049 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsMatrix(
8050 ID3D10EffectDepthStencilViewVariable
*iface
)
8052 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8055 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsString(
8056 ID3D10EffectDepthStencilViewVariable
*iface
)
8058 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8061 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsShaderResource(
8062 ID3D10EffectDepthStencilViewVariable
*iface
)
8064 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8067 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsRenderTargetView(
8068 ID3D10EffectDepthStencilViewVariable
*iface
)
8070 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8073 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsDepthStencilView(
8074 ID3D10EffectDepthStencilViewVariable
*iface
)
8076 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8079 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsConstantBuffer(
8080 ID3D10EffectDepthStencilViewVariable
*iface
)
8082 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8085 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsShader(
8086 ID3D10EffectDepthStencilViewVariable
*iface
)
8088 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8091 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsBlend(
8092 ID3D10EffectDepthStencilViewVariable
*iface
)
8094 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8097 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsDepthStencil(
8098 ID3D10EffectDepthStencilViewVariable
*iface
)
8100 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8103 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsRasterizer(
8104 ID3D10EffectDepthStencilViewVariable
*iface
)
8106 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8109 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_AsSampler(
8110 ID3D10EffectDepthStencilViewVariable
*iface
)
8112 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8115 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_SetRawValue(
8116 ID3D10EffectDepthStencilViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
8118 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8121 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetRawValue(
8122 ID3D10EffectDepthStencilViewVariable
*iface
, void *data
, UINT offset
, UINT count
)
8124 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8127 /* ID3D10EffectDepthStencilViewVariable methods */
8129 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_SetDepthStencil(
8130 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
*view
)
8132 FIXME("iface %p, view %p stub!\n", iface
, view
);
8137 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetDepthStencil(
8138 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
**view
)
8140 FIXME("iface %p, view %p stub!\n", iface
, view
);
8145 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray(
8146 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
**views
, UINT offset
, UINT count
)
8148 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
8153 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray(
8154 ID3D10EffectDepthStencilViewVariable
*iface
, ID3D10DepthStencilView
**views
, UINT offset
, UINT count
)
8156 FIXME("iface %p, views %p, offset %u, count %u stub!\n", iface
, views
, offset
, count
);
8162 static const struct ID3D10EffectDepthStencilViewVariableVtbl d3d10_effect_depth_stencil_view_variable_vtbl
=
8164 /* ID3D10EffectVariable methods */
8165 d3d10_effect_depth_stencil_view_variable_IsValid
,
8166 d3d10_effect_depth_stencil_view_variable_GetType
,
8167 d3d10_effect_depth_stencil_view_variable_GetDesc
,
8168 d3d10_effect_depth_stencil_view_variable_GetAnnotationByIndex
,
8169 d3d10_effect_depth_stencil_view_variable_GetAnnotationByName
,
8170 d3d10_effect_depth_stencil_view_variable_GetMemberByIndex
,
8171 d3d10_effect_depth_stencil_view_variable_GetMemberByName
,
8172 d3d10_effect_depth_stencil_view_variable_GetMemberBySemantic
,
8173 d3d10_effect_depth_stencil_view_variable_GetElement
,
8174 d3d10_effect_depth_stencil_view_variable_GetParentConstantBuffer
,
8175 d3d10_effect_depth_stencil_view_variable_AsScalar
,
8176 d3d10_effect_depth_stencil_view_variable_AsVector
,
8177 d3d10_effect_depth_stencil_view_variable_AsMatrix
,
8178 d3d10_effect_depth_stencil_view_variable_AsString
,
8179 d3d10_effect_depth_stencil_view_variable_AsShaderResource
,
8180 d3d10_effect_depth_stencil_view_variable_AsRenderTargetView
,
8181 d3d10_effect_depth_stencil_view_variable_AsDepthStencilView
,
8182 d3d10_effect_depth_stencil_view_variable_AsConstantBuffer
,
8183 d3d10_effect_depth_stencil_view_variable_AsShader
,
8184 d3d10_effect_depth_stencil_view_variable_AsBlend
,
8185 d3d10_effect_depth_stencil_view_variable_AsDepthStencil
,
8186 d3d10_effect_depth_stencil_view_variable_AsRasterizer
,
8187 d3d10_effect_depth_stencil_view_variable_AsSampler
,
8188 d3d10_effect_depth_stencil_view_variable_SetRawValue
,
8189 d3d10_effect_depth_stencil_view_variable_GetRawValue
,
8190 /* ID3D10EffectDepthStencilViewVariable methods */
8191 d3d10_effect_depth_stencil_view_variable_SetDepthStencil
,
8192 d3d10_effect_depth_stencil_view_variable_GetDepthStencil
,
8193 d3d10_effect_depth_stencil_view_variable_SetDepthStencilArray
,
8194 d3d10_effect_depth_stencil_view_variable_GetDepthStencilArray
,
8197 /* ID3D10EffectVariable methods */
8199 static BOOL STDMETHODCALLTYPE
d3d10_effect_shader_variable_IsValid(ID3D10EffectShaderVariable
*iface
)
8201 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8203 TRACE("iface %p\n", iface
);
8205 return v
!= &null_shader_variable
;
8208 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetType(
8209 ID3D10EffectShaderVariable
*iface
)
8211 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8214 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetDesc(ID3D10EffectShaderVariable
*iface
,
8215 D3D10_EFFECT_VARIABLE_DESC
*desc
)
8217 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8220 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetAnnotationByIndex(
8221 ID3D10EffectShaderVariable
*iface
, UINT index
)
8223 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8226 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetAnnotationByName(
8227 ID3D10EffectShaderVariable
*iface
, const char *name
)
8229 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8232 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetMemberByIndex(
8233 ID3D10EffectShaderVariable
*iface
, UINT index
)
8235 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8238 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetMemberByName(
8239 ID3D10EffectShaderVariable
*iface
, const char *name
)
8241 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8244 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetMemberBySemantic(
8245 ID3D10EffectShaderVariable
*iface
, const char *semantic
)
8247 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8250 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetElement(
8251 ID3D10EffectShaderVariable
*iface
, UINT index
)
8253 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8256 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetParentConstantBuffer(
8257 ID3D10EffectShaderVariable
*iface
)
8259 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8262 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsScalar(
8263 ID3D10EffectShaderVariable
*iface
)
8265 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8268 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsVector(
8269 ID3D10EffectShaderVariable
*iface
)
8271 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8274 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsMatrix(
8275 ID3D10EffectShaderVariable
*iface
)
8277 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8280 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsString(
8281 ID3D10EffectShaderVariable
*iface
)
8283 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8286 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsShaderResource(
8287 ID3D10EffectShaderVariable
*iface
)
8289 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8292 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsRenderTargetView(
8293 ID3D10EffectShaderVariable
*iface
)
8295 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8298 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsDepthStencilView(
8299 ID3D10EffectShaderVariable
*iface
)
8301 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8304 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsConstantBuffer(
8305 ID3D10EffectShaderVariable
*iface
)
8307 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8310 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsShader(
8311 ID3D10EffectShaderVariable
*iface
)
8313 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8316 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsBlend(
8317 ID3D10EffectShaderVariable
*iface
)
8319 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8322 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsDepthStencil(
8323 ID3D10EffectShaderVariable
*iface
)
8325 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8328 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsRasterizer(
8329 ID3D10EffectShaderVariable
*iface
)
8331 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8334 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_shader_variable_AsSampler(
8335 ID3D10EffectShaderVariable
*iface
)
8337 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8340 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_SetRawValue(
8341 ID3D10EffectShaderVariable
*iface
, void *data
, UINT offset
, UINT count
)
8343 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8346 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetRawValue(
8347 ID3D10EffectShaderVariable
*iface
, void *data
, UINT offset
, UINT count
)
8349 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8352 /* ID3D10EffectShaderVariable methods */
8354 static HRESULT
d3d10_get_shader_variable(struct d3d10_effect_variable
*v
, UINT shader_index
,
8355 struct d3d10_effect_shader_variable
**s
, D3D10_SHADER_VARIABLE_TYPE
*basetype
)
8359 v
= d3d10_array_get_element(v
, 0);
8364 if (basetype
) *basetype
= v
->type
->basetype
;
8368 /* Index is used as an offset from this variable. */
8370 for (i
= 0; i
< v
->effect
->shaders
.count
; ++i
)
8372 if (v
== v
->effect
->shaders
.v
[i
]) break;
8375 if (i
+ shader_index
>= v
->effect
->shaders
.count
)
8377 WARN("Invalid shader index %u.\n", shader_index
);
8381 *s
= &v
->effect
->shaders
.v
[i
+ shader_index
]->u
.shader
;
8382 if (basetype
) *basetype
= v
->effect
->shaders
.v
[i
+ shader_index
]->type
->basetype
;
8387 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetShaderDesc(
8388 ID3D10EffectShaderVariable
*iface
, UINT index
, D3D10_EFFECT_SHADER_DESC
*desc
)
8390 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8391 struct d3d10_effect_shader_variable
*s
;
8392 D3D10_SHADER_DESC shader_desc
;
8395 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
8397 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, NULL
)))
8400 memset(desc
, 0, sizeof(*desc
));
8401 if (s
->input_signature
)
8402 desc
->pInputSignature
= ID3D10Blob_GetBufferPointer(s
->input_signature
);
8403 desc
->SODecl
= s
->stream_output_declaration
;
8404 desc
->IsInline
= s
->isinline
;
8407 desc
->pBytecode
= ID3D10Blob_GetBufferPointer(s
->bytecode
);
8408 desc
->BytecodeLength
= ID3D10Blob_GetBufferSize(s
->bytecode
);
8412 if (SUCCEEDED(hr
= s
->reflection
->lpVtbl
->GetDesc(s
->reflection
, &shader_desc
)))
8414 desc
->NumInputSignatureEntries
= shader_desc
.InputParameters
;
8415 desc
->NumOutputSignatureEntries
= shader_desc
.OutputParameters
;
8422 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetVertexShader(
8423 ID3D10EffectShaderVariable
*iface
, UINT index
, ID3D10VertexShader
**shader
)
8425 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8426 struct d3d10_effect_shader_variable
*s
;
8427 D3D10_SHADER_VARIABLE_TYPE basetype
;
8430 TRACE("iface %p, index %u, shader %p.\n", iface
, index
, shader
);
8434 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, &basetype
)))
8437 if (basetype
!= D3D10_SVT_VERTEXSHADER
)
8439 WARN("Shader is not a vertex shader.\n");
8440 return D3DERR_INVALIDCALL
;
8443 if ((*shader
= s
->shader
.vs
))
8444 ID3D10VertexShader_AddRef(*shader
);
8449 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetGeometryShader(
8450 ID3D10EffectShaderVariable
*iface
, UINT index
, ID3D10GeometryShader
**shader
)
8452 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8453 struct d3d10_effect_shader_variable
*s
;
8454 D3D10_SHADER_VARIABLE_TYPE basetype
;
8457 TRACE("iface %p, index %u, shader %p.\n", iface
, index
, shader
);
8461 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, &basetype
)))
8464 if (basetype
!= D3D10_SVT_GEOMETRYSHADER
)
8466 WARN("Shader is not a geometry shader.\n");
8467 return D3DERR_INVALIDCALL
;
8470 if ((*shader
= s
->shader
.gs
))
8471 ID3D10GeometryShader_AddRef(*shader
);
8476 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetPixelShader(
8477 ID3D10EffectShaderVariable
*iface
, UINT index
, ID3D10PixelShader
**shader
)
8479 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8480 struct d3d10_effect_shader_variable
*s
;
8481 D3D10_SHADER_VARIABLE_TYPE basetype
;
8484 TRACE("iface %p, index %u, shader %p.\n", iface
, index
, shader
);
8488 if (FAILED(hr
= d3d10_get_shader_variable(v
, index
, &s
, &basetype
)))
8491 if (basetype
!= D3D10_SVT_PIXELSHADER
)
8493 WARN("Shader is not a pixel shader.\n");
8494 return D3DERR_INVALIDCALL
;
8497 if ((*shader
= s
->shader
.ps
))
8498 ID3D10PixelShader_AddRef(*shader
);
8503 static HRESULT
d3d10_get_shader_variable_signature(struct d3d10_effect_variable
*v
,
8504 UINT shader_index
, UINT element_index
, BOOL output
, D3D10_SIGNATURE_PARAMETER_DESC
*desc
)
8506 struct d3d10_effect_shader_variable
*s
;
8509 if (FAILED(hr
= d3d10_get_shader_variable(v
, shader_index
, &s
, NULL
)))
8513 return D3DERR_INVALIDCALL
;
8516 return s
->reflection
->lpVtbl
->GetOutputParameterDesc(s
->reflection
, element_index
, desc
);
8518 return s
->reflection
->lpVtbl
->GetInputParameterDesc(s
->reflection
, element_index
, desc
);
8521 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetInputSignatureElementDesc(
8522 ID3D10EffectShaderVariable
*iface
, UINT shader_index
, UINT element_index
,
8523 D3D10_SIGNATURE_PARAMETER_DESC
*desc
)
8525 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8527 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
8528 iface
, shader_index
, element_index
, desc
);
8530 if (!iface
->lpVtbl
->IsValid(iface
))
8532 WARN("Null variable specified\n");
8536 return d3d10_get_shader_variable_signature(v
, shader_index
, element_index
, FALSE
, desc
);
8539 static HRESULT STDMETHODCALLTYPE
d3d10_effect_shader_variable_GetOutputSignatureElementDesc(
8540 ID3D10EffectShaderVariable
*iface
, UINT shader_index
, UINT element_index
,
8541 D3D10_SIGNATURE_PARAMETER_DESC
*desc
)
8543 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectShaderVariable(iface
);
8545 TRACE("iface %p, shader_index %u, element_index %u, desc %p\n",
8546 iface
, shader_index
, element_index
, desc
);
8548 if (!iface
->lpVtbl
->IsValid(iface
))
8550 WARN("Null variable specified\n");
8554 return d3d10_get_shader_variable_signature(v
, shader_index
, element_index
, TRUE
, desc
);
8558 static const struct ID3D10EffectShaderVariableVtbl d3d10_effect_shader_variable_vtbl
=
8560 /* ID3D10EffectVariable methods */
8561 d3d10_effect_shader_variable_IsValid
,
8562 d3d10_effect_shader_variable_GetType
,
8563 d3d10_effect_shader_variable_GetDesc
,
8564 d3d10_effect_shader_variable_GetAnnotationByIndex
,
8565 d3d10_effect_shader_variable_GetAnnotationByName
,
8566 d3d10_effect_shader_variable_GetMemberByIndex
,
8567 d3d10_effect_shader_variable_GetMemberByName
,
8568 d3d10_effect_shader_variable_GetMemberBySemantic
,
8569 d3d10_effect_shader_variable_GetElement
,
8570 d3d10_effect_shader_variable_GetParentConstantBuffer
,
8571 d3d10_effect_shader_variable_AsScalar
,
8572 d3d10_effect_shader_variable_AsVector
,
8573 d3d10_effect_shader_variable_AsMatrix
,
8574 d3d10_effect_shader_variable_AsString
,
8575 d3d10_effect_shader_variable_AsShaderResource
,
8576 d3d10_effect_shader_variable_AsRenderTargetView
,
8577 d3d10_effect_shader_variable_AsDepthStencilView
,
8578 d3d10_effect_shader_variable_AsConstantBuffer
,
8579 d3d10_effect_shader_variable_AsShader
,
8580 d3d10_effect_shader_variable_AsBlend
,
8581 d3d10_effect_shader_variable_AsDepthStencil
,
8582 d3d10_effect_shader_variable_AsRasterizer
,
8583 d3d10_effect_shader_variable_AsSampler
,
8584 d3d10_effect_shader_variable_SetRawValue
,
8585 d3d10_effect_shader_variable_GetRawValue
,
8586 /* ID3D10EffectShaderVariable methods */
8587 d3d10_effect_shader_variable_GetShaderDesc
,
8588 d3d10_effect_shader_variable_GetVertexShader
,
8589 d3d10_effect_shader_variable_GetGeometryShader
,
8590 d3d10_effect_shader_variable_GetPixelShader
,
8591 d3d10_effect_shader_variable_GetInputSignatureElementDesc
,
8592 d3d10_effect_shader_variable_GetOutputSignatureElementDesc
,
8595 /* ID3D10EffectVariable methods */
8597 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectBlendVariable(
8598 ID3D10EffectBlendVariable
*iface
)
8600 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
8603 static BOOL STDMETHODCALLTYPE
d3d10_effect_blend_variable_IsValid(ID3D10EffectBlendVariable
*iface
)
8605 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectBlendVariable(iface
);
8607 TRACE("iface %p\n", iface
);
8609 return v
!= &null_blend_variable
;
8612 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetType(
8613 ID3D10EffectBlendVariable
*iface
)
8615 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8618 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetDesc(ID3D10EffectBlendVariable
*iface
,
8619 D3D10_EFFECT_VARIABLE_DESC
*desc
)
8621 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8624 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetAnnotationByIndex(
8625 ID3D10EffectBlendVariable
*iface
, UINT index
)
8627 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8630 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetAnnotationByName(
8631 ID3D10EffectBlendVariable
*iface
, const char *name
)
8633 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8636 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetMemberByIndex(
8637 ID3D10EffectBlendVariable
*iface
, UINT index
)
8639 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8642 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetMemberByName(
8643 ID3D10EffectBlendVariable
*iface
, const char *name
)
8645 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8648 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetMemberBySemantic(
8649 ID3D10EffectBlendVariable
*iface
, const char *semantic
)
8651 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8654 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetElement(
8655 ID3D10EffectBlendVariable
*iface
, UINT index
)
8657 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8660 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetParentConstantBuffer(
8661 ID3D10EffectBlendVariable
*iface
)
8663 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8666 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsScalar(
8667 ID3D10EffectBlendVariable
*iface
)
8669 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8672 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsVector(
8673 ID3D10EffectBlendVariable
*iface
)
8675 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8678 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsMatrix(
8679 ID3D10EffectBlendVariable
*iface
)
8681 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8684 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsString(
8685 ID3D10EffectBlendVariable
*iface
)
8687 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8690 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsShaderResource(
8691 ID3D10EffectBlendVariable
*iface
)
8693 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8696 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsRenderTargetView(
8697 ID3D10EffectBlendVariable
*iface
)
8699 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8702 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsDepthStencilView(
8703 ID3D10EffectBlendVariable
*iface
)
8705 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8708 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsConstantBuffer(
8709 ID3D10EffectBlendVariable
*iface
)
8711 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8714 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsShader(
8715 ID3D10EffectBlendVariable
*iface
)
8717 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8720 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsBlend(
8721 ID3D10EffectBlendVariable
*iface
)
8723 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8726 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsDepthStencil(
8727 ID3D10EffectBlendVariable
*iface
)
8729 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8732 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsRasterizer(
8733 ID3D10EffectBlendVariable
*iface
)
8735 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8738 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_blend_variable_AsSampler(
8739 ID3D10EffectBlendVariable
*iface
)
8741 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8744 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_SetRawValue(ID3D10EffectBlendVariable
*iface
,
8745 void *data
, UINT offset
, UINT count
)
8747 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8750 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetRawValue(ID3D10EffectBlendVariable
*iface
,
8751 void *data
, UINT offset
, UINT count
)
8753 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8756 /* ID3D10EffectBlendVariable methods */
8758 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetBlendState(ID3D10EffectBlendVariable
*iface
,
8759 UINT index
, ID3D10BlendState
**blend_state
)
8761 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectBlendVariable(iface
);
8763 TRACE("iface %p, index %u, blend_state %p.\n", iface
, index
, blend_state
);
8765 if (!iface
->lpVtbl
->IsValid(iface
))
8767 WARN("Invalid variable.\n");
8771 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->blend_states
)))
8774 if ((*blend_state
= v
->u
.state
.object
.blend
))
8775 ID3D10BlendState_AddRef(*blend_state
);
8780 static HRESULT STDMETHODCALLTYPE
d3d10_effect_blend_variable_GetBackingStore(ID3D10EffectBlendVariable
*iface
,
8781 UINT index
, D3D10_BLEND_DESC
*desc
)
8783 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectBlendVariable(iface
);
8785 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
8787 if (!iface
->lpVtbl
->IsValid(iface
))
8789 WARN("Invalid variable.\n");
8793 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->blend_states
)))
8796 *desc
= v
->u
.state
.desc
.blend
;
8801 static const struct ID3D10EffectBlendVariableVtbl d3d10_effect_blend_variable_vtbl
=
8803 /* ID3D10EffectVariable methods */
8804 d3d10_effect_blend_variable_IsValid
,
8805 d3d10_effect_blend_variable_GetType
,
8806 d3d10_effect_blend_variable_GetDesc
,
8807 d3d10_effect_blend_variable_GetAnnotationByIndex
,
8808 d3d10_effect_blend_variable_GetAnnotationByName
,
8809 d3d10_effect_blend_variable_GetMemberByIndex
,
8810 d3d10_effect_blend_variable_GetMemberByName
,
8811 d3d10_effect_blend_variable_GetMemberBySemantic
,
8812 d3d10_effect_blend_variable_GetElement
,
8813 d3d10_effect_blend_variable_GetParentConstantBuffer
,
8814 d3d10_effect_blend_variable_AsScalar
,
8815 d3d10_effect_blend_variable_AsVector
,
8816 d3d10_effect_blend_variable_AsMatrix
,
8817 d3d10_effect_blend_variable_AsString
,
8818 d3d10_effect_blend_variable_AsShaderResource
,
8819 d3d10_effect_blend_variable_AsRenderTargetView
,
8820 d3d10_effect_blend_variable_AsDepthStencilView
,
8821 d3d10_effect_blend_variable_AsConstantBuffer
,
8822 d3d10_effect_blend_variable_AsShader
,
8823 d3d10_effect_blend_variable_AsBlend
,
8824 d3d10_effect_blend_variable_AsDepthStencil
,
8825 d3d10_effect_blend_variable_AsRasterizer
,
8826 d3d10_effect_blend_variable_AsSampler
,
8827 d3d10_effect_blend_variable_SetRawValue
,
8828 d3d10_effect_blend_variable_GetRawValue
,
8829 /* ID3D10EffectBlendVariable methods */
8830 d3d10_effect_blend_variable_GetBlendState
,
8831 d3d10_effect_blend_variable_GetBackingStore
,
8834 /* ID3D10EffectVariable methods */
8836 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectDepthStencilVariable(
8837 ID3D10EffectDepthStencilVariable
*iface
)
8839 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
8842 static BOOL STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_IsValid(ID3D10EffectDepthStencilVariable
*iface
)
8844 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilVariable(iface
);
8846 TRACE("iface %p\n", iface
);
8848 return v
!= &null_depth_stencil_variable
;
8851 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetType(
8852 ID3D10EffectDepthStencilVariable
*iface
)
8854 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
8857 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetDesc(ID3D10EffectDepthStencilVariable
*iface
,
8858 D3D10_EFFECT_VARIABLE_DESC
*desc
)
8860 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
8863 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetAnnotationByIndex(
8864 ID3D10EffectDepthStencilVariable
*iface
, UINT index
)
8866 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
8869 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetAnnotationByName(
8870 ID3D10EffectDepthStencilVariable
*iface
, const char *name
)
8872 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
8875 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetMemberByIndex(
8876 ID3D10EffectDepthStencilVariable
*iface
, UINT index
)
8878 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
8881 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetMemberByName(
8882 ID3D10EffectDepthStencilVariable
*iface
, const char *name
)
8884 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
8887 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetMemberBySemantic(
8888 ID3D10EffectDepthStencilVariable
*iface
, const char *semantic
)
8890 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
8893 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetElement(
8894 ID3D10EffectDepthStencilVariable
*iface
, UINT index
)
8896 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
8899 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetParentConstantBuffer(
8900 ID3D10EffectDepthStencilVariable
*iface
)
8902 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
8905 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsScalar(
8906 ID3D10EffectDepthStencilVariable
*iface
)
8908 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
8911 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsVector(
8912 ID3D10EffectDepthStencilVariable
*iface
)
8914 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
8917 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsMatrix(
8918 ID3D10EffectDepthStencilVariable
*iface
)
8920 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
8923 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsString(
8924 ID3D10EffectDepthStencilVariable
*iface
)
8926 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
8929 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsShaderResource(
8930 ID3D10EffectDepthStencilVariable
*iface
)
8932 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
8935 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsRenderTargetView(
8936 ID3D10EffectDepthStencilVariable
*iface
)
8938 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
8941 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsDepthStencilView(
8942 ID3D10EffectDepthStencilVariable
*iface
)
8944 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
8947 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsConstantBuffer(
8948 ID3D10EffectDepthStencilVariable
*iface
)
8950 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
8953 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsShader(
8954 ID3D10EffectDepthStencilVariable
*iface
)
8956 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
8959 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsBlend(
8960 ID3D10EffectDepthStencilVariable
*iface
)
8962 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
8965 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsDepthStencil(
8966 ID3D10EffectDepthStencilVariable
*iface
)
8968 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
8971 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsRasterizer(
8972 ID3D10EffectDepthStencilVariable
*iface
)
8974 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
8977 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_AsSampler(
8978 ID3D10EffectDepthStencilVariable
*iface
)
8980 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
8983 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_SetRawValue(ID3D10EffectDepthStencilVariable
*iface
,
8984 void *data
, UINT offset
, UINT count
)
8986 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8989 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetRawValue(ID3D10EffectDepthStencilVariable
*iface
,
8990 void *data
, UINT offset
, UINT count
)
8992 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
8995 /* ID3D10EffectDepthStencilVariable methods */
8997 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetDepthStencilState(ID3D10EffectDepthStencilVariable
*iface
,
8998 UINT index
, ID3D10DepthStencilState
**depth_stencil_state
)
9000 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilVariable(iface
);
9002 TRACE("iface %p, index %u, depth_stencil_state %p.\n", iface
, index
, depth_stencil_state
);
9004 if (!iface
->lpVtbl
->IsValid(iface
))
9006 WARN("Invalid variable.\n");
9010 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->ds_states
)))
9013 if ((*depth_stencil_state
= v
->u
.state
.object
.depth_stencil
))
9014 ID3D10DepthStencilState_AddRef(*depth_stencil_state
);
9019 static HRESULT STDMETHODCALLTYPE
d3d10_effect_depth_stencil_variable_GetBackingStore(ID3D10EffectDepthStencilVariable
*iface
,
9020 UINT index
, D3D10_DEPTH_STENCIL_DESC
*desc
)
9022 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectDepthStencilVariable(iface
);
9024 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9026 if (!iface
->lpVtbl
->IsValid(iface
))
9028 WARN("Invalid variable.\n");
9032 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->ds_states
)))
9035 d3d10_effect_update_dependent_props(&v
->u
.state
.dependencies
, &v
->u
.state
.desc
);
9037 *desc
= v
->u
.state
.desc
.depth_stencil
;
9042 static const struct ID3D10EffectDepthStencilVariableVtbl d3d10_effect_depth_stencil_variable_vtbl
=
9044 /* ID3D10EffectVariable methods */
9045 d3d10_effect_depth_stencil_variable_IsValid
,
9046 d3d10_effect_depth_stencil_variable_GetType
,
9047 d3d10_effect_depth_stencil_variable_GetDesc
,
9048 d3d10_effect_depth_stencil_variable_GetAnnotationByIndex
,
9049 d3d10_effect_depth_stencil_variable_GetAnnotationByName
,
9050 d3d10_effect_depth_stencil_variable_GetMemberByIndex
,
9051 d3d10_effect_depth_stencil_variable_GetMemberByName
,
9052 d3d10_effect_depth_stencil_variable_GetMemberBySemantic
,
9053 d3d10_effect_depth_stencil_variable_GetElement
,
9054 d3d10_effect_depth_stencil_variable_GetParentConstantBuffer
,
9055 d3d10_effect_depth_stencil_variable_AsScalar
,
9056 d3d10_effect_depth_stencil_variable_AsVector
,
9057 d3d10_effect_depth_stencil_variable_AsMatrix
,
9058 d3d10_effect_depth_stencil_variable_AsString
,
9059 d3d10_effect_depth_stencil_variable_AsShaderResource
,
9060 d3d10_effect_depth_stencil_variable_AsRenderTargetView
,
9061 d3d10_effect_depth_stencil_variable_AsDepthStencilView
,
9062 d3d10_effect_depth_stencil_variable_AsConstantBuffer
,
9063 d3d10_effect_depth_stencil_variable_AsShader
,
9064 d3d10_effect_depth_stencil_variable_AsBlend
,
9065 d3d10_effect_depth_stencil_variable_AsDepthStencil
,
9066 d3d10_effect_depth_stencil_variable_AsRasterizer
,
9067 d3d10_effect_depth_stencil_variable_AsSampler
,
9068 d3d10_effect_depth_stencil_variable_SetRawValue
,
9069 d3d10_effect_depth_stencil_variable_GetRawValue
,
9070 /* ID3D10EffectDepthStencilVariable methods */
9071 d3d10_effect_depth_stencil_variable_GetDepthStencilState
,
9072 d3d10_effect_depth_stencil_variable_GetBackingStore
,
9075 /* ID3D10EffectVariable methods */
9077 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectRasterizerVariable(
9078 ID3D10EffectRasterizerVariable
*iface
)
9080 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
9083 static BOOL STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_IsValid(ID3D10EffectRasterizerVariable
*iface
)
9085 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRasterizerVariable(iface
);
9087 TRACE("iface %p\n", iface
);
9089 return v
!= &null_rasterizer_variable
;
9092 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetType(
9093 ID3D10EffectRasterizerVariable
*iface
)
9095 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
9098 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetDesc(ID3D10EffectRasterizerVariable
*iface
,
9099 D3D10_EFFECT_VARIABLE_DESC
*desc
)
9101 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
9104 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetAnnotationByIndex(
9105 ID3D10EffectRasterizerVariable
*iface
, UINT index
)
9107 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
9110 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetAnnotationByName(
9111 ID3D10EffectRasterizerVariable
*iface
, const char *name
)
9113 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
9116 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetMemberByIndex(
9117 ID3D10EffectRasterizerVariable
*iface
, UINT index
)
9119 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
9122 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetMemberByName(
9123 ID3D10EffectRasterizerVariable
*iface
, const char *name
)
9125 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
9128 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetMemberBySemantic(
9129 ID3D10EffectRasterizerVariable
*iface
, const char *semantic
)
9131 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
9134 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetElement(
9135 ID3D10EffectRasterizerVariable
*iface
, UINT index
)
9137 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
9140 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetParentConstantBuffer(
9141 ID3D10EffectRasterizerVariable
*iface
)
9143 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
9146 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsScalar(
9147 ID3D10EffectRasterizerVariable
*iface
)
9149 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
9152 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsVector(
9153 ID3D10EffectRasterizerVariable
*iface
)
9155 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
9158 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsMatrix(
9159 ID3D10EffectRasterizerVariable
*iface
)
9161 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
9164 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsString(
9165 ID3D10EffectRasterizerVariable
*iface
)
9167 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
9170 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsShaderResource(
9171 ID3D10EffectRasterizerVariable
*iface
)
9173 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
9176 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsRenderTargetView(
9177 ID3D10EffectRasterizerVariable
*iface
)
9179 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
9182 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsDepthStencilView(
9183 ID3D10EffectRasterizerVariable
*iface
)
9185 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
9188 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsConstantBuffer(
9189 ID3D10EffectRasterizerVariable
*iface
)
9191 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
9194 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsShader(
9195 ID3D10EffectRasterizerVariable
*iface
)
9197 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
9200 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsBlend(
9201 ID3D10EffectRasterizerVariable
*iface
)
9203 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
9206 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsDepthStencil(
9207 ID3D10EffectRasterizerVariable
*iface
)
9209 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
9212 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsRasterizer(
9213 ID3D10EffectRasterizerVariable
*iface
)
9215 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
9218 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_AsSampler(
9219 ID3D10EffectRasterizerVariable
*iface
)
9221 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
9224 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_SetRawValue(ID3D10EffectRasterizerVariable
*iface
,
9225 void *data
, UINT offset
, UINT count
)
9227 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9230 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetRawValue(ID3D10EffectRasterizerVariable
*iface
,
9231 void *data
, UINT offset
, UINT count
)
9233 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9236 /* ID3D10EffectRasterizerVariable methods */
9238 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetRasterizerState(ID3D10EffectRasterizerVariable
*iface
,
9239 UINT index
, ID3D10RasterizerState
**rasterizer_state
)
9241 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRasterizerVariable(iface
);
9243 TRACE("iface %p, index %u, rasterizer_state %p.\n", iface
, index
, rasterizer_state
);
9245 if (!iface
->lpVtbl
->IsValid(iface
))
9247 WARN("Invalid variable.\n");
9251 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->rs_states
)))
9254 if ((*rasterizer_state
= v
->u
.state
.object
.rasterizer
))
9255 ID3D10RasterizerState_AddRef(*rasterizer_state
);
9260 static HRESULT STDMETHODCALLTYPE
d3d10_effect_rasterizer_variable_GetBackingStore(ID3D10EffectRasterizerVariable
*iface
,
9261 UINT index
, D3D10_RASTERIZER_DESC
*desc
)
9263 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectRasterizerVariable(iface
);
9265 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9267 if (!iface
->lpVtbl
->IsValid(iface
))
9269 WARN("Invalid variable.\n");
9273 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->rs_states
)))
9276 *desc
= v
->u
.state
.desc
.rasterizer
;
9281 static const struct ID3D10EffectRasterizerVariableVtbl d3d10_effect_rasterizer_variable_vtbl
=
9283 /* ID3D10EffectVariable methods */
9284 d3d10_effect_rasterizer_variable_IsValid
,
9285 d3d10_effect_rasterizer_variable_GetType
,
9286 d3d10_effect_rasterizer_variable_GetDesc
,
9287 d3d10_effect_rasterizer_variable_GetAnnotationByIndex
,
9288 d3d10_effect_rasterizer_variable_GetAnnotationByName
,
9289 d3d10_effect_rasterizer_variable_GetMemberByIndex
,
9290 d3d10_effect_rasterizer_variable_GetMemberByName
,
9291 d3d10_effect_rasterizer_variable_GetMemberBySemantic
,
9292 d3d10_effect_rasterizer_variable_GetElement
,
9293 d3d10_effect_rasterizer_variable_GetParentConstantBuffer
,
9294 d3d10_effect_rasterizer_variable_AsScalar
,
9295 d3d10_effect_rasterizer_variable_AsVector
,
9296 d3d10_effect_rasterizer_variable_AsMatrix
,
9297 d3d10_effect_rasterizer_variable_AsString
,
9298 d3d10_effect_rasterizer_variable_AsShaderResource
,
9299 d3d10_effect_rasterizer_variable_AsRenderTargetView
,
9300 d3d10_effect_rasterizer_variable_AsDepthStencilView
,
9301 d3d10_effect_rasterizer_variable_AsConstantBuffer
,
9302 d3d10_effect_rasterizer_variable_AsShader
,
9303 d3d10_effect_rasterizer_variable_AsBlend
,
9304 d3d10_effect_rasterizer_variable_AsDepthStencil
,
9305 d3d10_effect_rasterizer_variable_AsRasterizer
,
9306 d3d10_effect_rasterizer_variable_AsSampler
,
9307 d3d10_effect_rasterizer_variable_SetRawValue
,
9308 d3d10_effect_rasterizer_variable_GetRawValue
,
9309 /* ID3D10EffectRasterizerVariable methods */
9310 d3d10_effect_rasterizer_variable_GetRasterizerState
,
9311 d3d10_effect_rasterizer_variable_GetBackingStore
,
9314 /* ID3D10EffectVariable methods */
9316 static inline struct d3d10_effect_variable
*impl_from_ID3D10EffectSamplerVariable(
9317 ID3D10EffectSamplerVariable
*iface
)
9319 return CONTAINING_RECORD(iface
, struct d3d10_effect_variable
, ID3D10EffectVariable_iface
);
9322 static BOOL STDMETHODCALLTYPE
d3d10_effect_sampler_variable_IsValid(ID3D10EffectSamplerVariable
*iface
)
9324 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectSamplerVariable(iface
);
9326 TRACE("iface %p\n", iface
);
9328 return v
!= &null_sampler_variable
;
9331 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetType(
9332 ID3D10EffectSamplerVariable
*iface
)
9334 return d3d10_effect_variable_GetType((ID3D10EffectVariable
*)iface
);
9337 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetDesc(ID3D10EffectSamplerVariable
*iface
,
9338 D3D10_EFFECT_VARIABLE_DESC
*desc
)
9340 return d3d10_effect_variable_GetDesc((ID3D10EffectVariable
*)iface
, desc
);
9343 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetAnnotationByIndex(
9344 ID3D10EffectSamplerVariable
*iface
, UINT index
)
9346 return d3d10_effect_variable_GetAnnotationByIndex((ID3D10EffectVariable
*)iface
, index
);
9349 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetAnnotationByName(
9350 ID3D10EffectSamplerVariable
*iface
, const char *name
)
9352 return d3d10_effect_variable_GetAnnotationByName((ID3D10EffectVariable
*)iface
, name
);
9355 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetMemberByIndex(
9356 ID3D10EffectSamplerVariable
*iface
, UINT index
)
9358 return d3d10_effect_variable_GetMemberByIndex((ID3D10EffectVariable
*)iface
, index
);
9361 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetMemberByName(
9362 ID3D10EffectSamplerVariable
*iface
, const char *name
)
9364 return d3d10_effect_variable_GetMemberByName((ID3D10EffectVariable
*)iface
, name
);
9367 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetMemberBySemantic(
9368 ID3D10EffectSamplerVariable
*iface
, const char *semantic
)
9370 return d3d10_effect_variable_GetMemberBySemantic((ID3D10EffectVariable
*)iface
, semantic
);
9373 static struct ID3D10EffectVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetElement(
9374 ID3D10EffectSamplerVariable
*iface
, UINT index
)
9376 return d3d10_effect_variable_GetElement((ID3D10EffectVariable
*)iface
, index
);
9379 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetParentConstantBuffer(
9380 ID3D10EffectSamplerVariable
*iface
)
9382 return d3d10_effect_variable_GetParentConstantBuffer((ID3D10EffectVariable
*)iface
);
9385 static struct ID3D10EffectScalarVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsScalar(
9386 ID3D10EffectSamplerVariable
*iface
)
9388 return d3d10_effect_variable_AsScalar((ID3D10EffectVariable
*)iface
);
9391 static struct ID3D10EffectVectorVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsVector(
9392 ID3D10EffectSamplerVariable
*iface
)
9394 return d3d10_effect_variable_AsVector((ID3D10EffectVariable
*)iface
);
9397 static struct ID3D10EffectMatrixVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsMatrix(
9398 ID3D10EffectSamplerVariable
*iface
)
9400 return d3d10_effect_variable_AsMatrix((ID3D10EffectVariable
*)iface
);
9403 static struct ID3D10EffectStringVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsString(
9404 ID3D10EffectSamplerVariable
*iface
)
9406 return d3d10_effect_variable_AsString((ID3D10EffectVariable
*)iface
);
9409 static struct ID3D10EffectShaderResourceVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsShaderResource(
9410 ID3D10EffectSamplerVariable
*iface
)
9412 return d3d10_effect_variable_AsShaderResource((ID3D10EffectVariable
*)iface
);
9415 static struct ID3D10EffectRenderTargetViewVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsRenderTargetView(
9416 ID3D10EffectSamplerVariable
*iface
)
9418 return d3d10_effect_variable_AsRenderTargetView((ID3D10EffectVariable
*)iface
);
9421 static struct ID3D10EffectDepthStencilViewVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsDepthStencilView(
9422 ID3D10EffectSamplerVariable
*iface
)
9424 return d3d10_effect_variable_AsDepthStencilView((ID3D10EffectVariable
*)iface
);
9427 static struct ID3D10EffectConstantBuffer
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsConstantBuffer(
9428 ID3D10EffectSamplerVariable
*iface
)
9430 return d3d10_effect_variable_AsConstantBuffer((ID3D10EffectVariable
*)iface
);
9433 static struct ID3D10EffectShaderVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsShader(
9434 ID3D10EffectSamplerVariable
*iface
)
9436 return d3d10_effect_variable_AsShader((ID3D10EffectVariable
*)iface
);
9439 static struct ID3D10EffectBlendVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsBlend(
9440 ID3D10EffectSamplerVariable
*iface
)
9442 return d3d10_effect_variable_AsBlend((ID3D10EffectVariable
*)iface
);
9445 static struct ID3D10EffectDepthStencilVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsDepthStencil(
9446 ID3D10EffectSamplerVariable
*iface
)
9448 return d3d10_effect_variable_AsDepthStencil((ID3D10EffectVariable
*)iface
);
9451 static struct ID3D10EffectRasterizerVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsRasterizer(
9452 ID3D10EffectSamplerVariable
*iface
)
9454 return d3d10_effect_variable_AsRasterizer((ID3D10EffectVariable
*)iface
);
9457 static struct ID3D10EffectSamplerVariable
* STDMETHODCALLTYPE
d3d10_effect_sampler_variable_AsSampler(
9458 ID3D10EffectSamplerVariable
*iface
)
9460 return d3d10_effect_variable_AsSampler((ID3D10EffectVariable
*)iface
);
9463 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_SetRawValue(ID3D10EffectSamplerVariable
*iface
,
9464 void *data
, UINT offset
, UINT count
)
9466 return d3d10_effect_variable_SetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9469 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetRawValue(ID3D10EffectSamplerVariable
*iface
,
9470 void *data
, UINT offset
, UINT count
)
9472 return d3d10_effect_variable_GetRawValue((ID3D10EffectVariable
*)iface
, data
, offset
, count
);
9475 /* ID3D10EffectSamplerVariable methods */
9477 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetSampler(ID3D10EffectSamplerVariable
*iface
,
9478 UINT index
, ID3D10SamplerState
**sampler
)
9480 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectSamplerVariable(iface
);
9482 TRACE("iface %p, index %u, sampler %p.\n", iface
, index
, sampler
);
9484 if (!iface
->lpVtbl
->IsValid(iface
))
9486 WARN("Invalid variable.\n");
9490 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->samplers
)))
9493 if ((*sampler
= v
->u
.state
.object
.sampler
))
9494 ID3D10SamplerState_AddRef(*sampler
);
9499 static HRESULT STDMETHODCALLTYPE
d3d10_effect_sampler_variable_GetBackingStore(ID3D10EffectSamplerVariable
*iface
,
9500 UINT index
, D3D10_SAMPLER_DESC
*desc
)
9502 struct d3d10_effect_variable
*v
= impl_from_ID3D10EffectSamplerVariable(iface
);
9504 TRACE("iface %p, index %u, desc %p.\n", iface
, index
, desc
);
9506 if (!iface
->lpVtbl
->IsValid(iface
))
9508 WARN("Invalid variable.\n");
9512 if (!(v
= d3d10_get_state_variable(v
, index
, &v
->effect
->samplers
)))
9515 *desc
= v
->u
.state
.desc
.sampler
.desc
;
9520 static const struct ID3D10EffectSamplerVariableVtbl d3d10_effect_sampler_variable_vtbl
=
9522 /* ID3D10EffectVariable methods */
9523 d3d10_effect_sampler_variable_IsValid
,
9524 d3d10_effect_sampler_variable_GetType
,
9525 d3d10_effect_sampler_variable_GetDesc
,
9526 d3d10_effect_sampler_variable_GetAnnotationByIndex
,
9527 d3d10_effect_sampler_variable_GetAnnotationByName
,
9528 d3d10_effect_sampler_variable_GetMemberByIndex
,
9529 d3d10_effect_sampler_variable_GetMemberByName
,
9530 d3d10_effect_sampler_variable_GetMemberBySemantic
,
9531 d3d10_effect_sampler_variable_GetElement
,
9532 d3d10_effect_sampler_variable_GetParentConstantBuffer
,
9533 d3d10_effect_sampler_variable_AsScalar
,
9534 d3d10_effect_sampler_variable_AsVector
,
9535 d3d10_effect_sampler_variable_AsMatrix
,
9536 d3d10_effect_sampler_variable_AsString
,
9537 d3d10_effect_sampler_variable_AsShaderResource
,
9538 d3d10_effect_sampler_variable_AsRenderTargetView
,
9539 d3d10_effect_sampler_variable_AsDepthStencilView
,
9540 d3d10_effect_sampler_variable_AsConstantBuffer
,
9541 d3d10_effect_sampler_variable_AsShader
,
9542 d3d10_effect_sampler_variable_AsBlend
,
9543 d3d10_effect_sampler_variable_AsDepthStencil
,
9544 d3d10_effect_sampler_variable_AsRasterizer
,
9545 d3d10_effect_sampler_variable_AsSampler
,
9546 d3d10_effect_sampler_variable_SetRawValue
,
9547 d3d10_effect_sampler_variable_GetRawValue
,
9548 /* ID3D10EffectSamplerVariable methods */
9549 d3d10_effect_sampler_variable_GetSampler
,
9550 d3d10_effect_sampler_variable_GetBackingStore
,
9553 /* ID3D10EffectType methods */
9555 static inline struct d3d10_effect_type
*impl_from_ID3D10EffectType(ID3D10EffectType
*iface
)
9557 return CONTAINING_RECORD(iface
, struct d3d10_effect_type
, ID3D10EffectType_iface
);
9560 static BOOL STDMETHODCALLTYPE
d3d10_effect_type_IsValid(ID3D10EffectType
*iface
)
9562 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9564 TRACE("iface %p\n", iface
);
9566 return This
!= &null_type
;
9569 static HRESULT STDMETHODCALLTYPE
d3d10_effect_type_GetDesc(ID3D10EffectType
*iface
, D3D10_EFFECT_TYPE_DESC
*desc
)
9571 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9573 TRACE("iface %p, desc %p\n", iface
, desc
);
9575 if (This
== &null_type
)
9577 WARN("Null type specified\n");
9583 WARN("Invalid argument specified\n");
9584 return E_INVALIDARG
;
9587 desc
->TypeName
= This
->name
;
9588 desc
->Class
= This
->type_class
;
9589 desc
->Type
= This
->basetype
;
9590 desc
->Elements
= This
->element_count
;
9591 desc
->Members
= This
->member_count
;
9592 desc
->Rows
= This
->row_count
;
9593 desc
->Columns
= This
->column_count
;
9594 desc
->PackedSize
= This
->size_packed
;
9595 desc
->UnpackedSize
= This
->size_unpacked
;
9596 desc
->Stride
= This
->stride
;
9601 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_type_GetMemberTypeByIndex(ID3D10EffectType
*iface
,
9604 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9605 struct d3d10_effect_type
*t
;
9607 TRACE("iface %p, index %u\n", iface
, index
);
9609 if (index
>= This
->member_count
)
9611 WARN("Invalid index specified\n");
9612 return &null_type
.ID3D10EffectType_iface
;
9615 t
= (&This
->members
[index
])->type
;
9617 TRACE("Returning member %p, %s\n", t
, debugstr_a(t
->name
));
9619 return &t
->ID3D10EffectType_iface
;
9622 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_type_GetMemberTypeByName(ID3D10EffectType
*iface
,
9625 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9628 TRACE("iface %p, name %s\n", iface
, debugstr_a(name
));
9632 WARN("Invalid name specified\n");
9633 return &null_type
.ID3D10EffectType_iface
;
9636 for (i
= 0; i
< This
->member_count
; ++i
)
9638 struct d3d10_effect_type_member
*typem
= &This
->members
[i
];
9640 if (typem
->name
&& !strcmp(typem
->name
, name
))
9642 TRACE("Returning type %p.\n", typem
->type
);
9643 return &typem
->type
->ID3D10EffectType_iface
;
9647 WARN("Invalid name specified\n");
9649 return &null_type
.ID3D10EffectType_iface
;
9652 static struct ID3D10EffectType
* STDMETHODCALLTYPE
d3d10_effect_type_GetMemberTypeBySemantic(ID3D10EffectType
*iface
,
9653 const char *semantic
)
9655 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9658 TRACE("iface %p, semantic %s\n", iface
, debugstr_a(semantic
));
9662 WARN("Invalid semantic specified\n");
9663 return &null_type
.ID3D10EffectType_iface
;
9666 for (i
= 0; i
< This
->member_count
; ++i
)
9668 struct d3d10_effect_type_member
*typem
= &This
->members
[i
];
9670 if (typem
->semantic
&& !stricmp(typem
->semantic
, semantic
))
9672 TRACE("Returning type %p.\n", typem
->type
);
9673 return &typem
->type
->ID3D10EffectType_iface
;
9677 WARN("Invalid semantic specified\n");
9679 return &null_type
.ID3D10EffectType_iface
;
9682 static const char * STDMETHODCALLTYPE
d3d10_effect_type_GetMemberName(ID3D10EffectType
*iface
, UINT index
)
9684 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9685 struct d3d10_effect_type_member
*typem
;
9687 TRACE("iface %p, index %u\n", iface
, index
);
9689 if (index
>= This
->member_count
)
9691 WARN("Invalid index specified\n");
9695 typem
= &This
->members
[index
];
9697 TRACE("Returning name %s\n", debugstr_a(typem
->name
));
9702 static const char * STDMETHODCALLTYPE
d3d10_effect_type_GetMemberSemantic(ID3D10EffectType
*iface
, UINT index
)
9704 struct d3d10_effect_type
*This
= impl_from_ID3D10EffectType(iface
);
9705 struct d3d10_effect_type_member
*typem
;
9707 TRACE("iface %p, index %u\n", iface
, index
);
9709 if (index
>= This
->member_count
)
9711 WARN("Invalid index specified\n");
9715 typem
= &This
->members
[index
];
9717 TRACE("Returning semantic %s\n", debugstr_a(typem
->semantic
));
9719 return typem
->semantic
;
9722 static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl
=
9724 /* ID3D10EffectType */
9725 d3d10_effect_type_IsValid
,
9726 d3d10_effect_type_GetDesc
,
9727 d3d10_effect_type_GetMemberTypeByIndex
,
9728 d3d10_effect_type_GetMemberTypeByName
,
9729 d3d10_effect_type_GetMemberTypeBySemantic
,
9730 d3d10_effect_type_GetMemberName
,
9731 d3d10_effect_type_GetMemberSemantic
,
9734 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pool_QueryInterface(ID3D10EffectPool
*iface
,
9735 REFIID riid
, void **object
)
9737 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
9739 if (IsEqualGUID(riid
, &IID_ID3D10EffectPool
) ||
9740 IsEqualGUID(riid
, &IID_IUnknown
))
9742 IUnknown_AddRef(iface
);
9747 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
9750 return E_NOINTERFACE
;
9753 static ULONG STDMETHODCALLTYPE
d3d10_effect_pool_AddRef(ID3D10EffectPool
*iface
)
9755 struct d3d10_effect
*effect
= impl_from_ID3D10EffectPool(iface
);
9756 return d3d10_effect_AddRef(&effect
->ID3D10Effect_iface
);
9759 static ULONG STDMETHODCALLTYPE
d3d10_effect_pool_Release(ID3D10EffectPool
*iface
)
9761 struct d3d10_effect
*effect
= impl_from_ID3D10EffectPool(iface
);
9762 return d3d10_effect_Release(&effect
->ID3D10Effect_iface
);
9765 static ID3D10Effect
* STDMETHODCALLTYPE
d3d10_effect_pool_AsEffect(ID3D10EffectPool
*iface
)
9767 struct d3d10_effect
*effect
= impl_from_ID3D10EffectPool(iface
);
9769 TRACE("%p.\n", iface
);
9771 return &effect
->ID3D10Effect_iface
;
9774 const struct ID3D10EffectPoolVtbl d3d10_effect_pool_vtbl
=
9776 /* IUnknown methods */
9777 d3d10_effect_pool_QueryInterface
,
9778 d3d10_effect_pool_AddRef
,
9779 d3d10_effect_pool_Release
,
9780 /* ID3D10EffectPool methods */
9781 d3d10_effect_pool_AsEffect
,
9785 static int d3d10_effect_type_compare(const void *key
, const struct wine_rb_entry
*entry
)
9787 const struct d3d10_effect_type
*t
= WINE_RB_ENTRY_VALUE(entry
, const struct d3d10_effect_type
, entry
);
9788 const DWORD
*id
= key
;
9793 static HRESULT
d3d10_create_effect(void *data
, SIZE_T data_size
, ID3D10Device
*device
,
9794 struct d3d10_effect
*pool
, unsigned int flags
, struct d3d10_effect
**effect
)
9796 struct d3d10_effect
*object
;
9800 return D3DERR_INVALIDCALL
;
9802 if (!(object
= calloc(1, sizeof(*object
))))
9803 return E_OUTOFMEMORY
;
9805 wine_rb_init(&object
->types
, d3d10_effect_type_compare
);
9806 object
->ID3D10Effect_iface
.lpVtbl
= flags
& D3D10_EFFECT_IS_POOL
?
9807 &d3d10_effect_pool_effect_vtbl
: &d3d10_effect_vtbl
;
9808 object
->ID3D10EffectPool_iface
.lpVtbl
= &d3d10_effect_pool_vtbl
;
9809 object
->refcount
= 1;
9810 ID3D10Device_AddRef(device
);
9811 object
->device
= device
;
9812 object
->pool
= pool
;
9813 object
->flags
= flags
;
9814 if (pool
) IUnknown_AddRef(&pool
->ID3D10Effect_iface
);
9816 hr
= d3d10_effect_parse(object
, data
, data_size
);
9819 ERR("Failed to parse effect\n");
9820 IUnknown_Release(&object
->ID3D10Effect_iface
);
9829 HRESULT WINAPI
D3D10CreateEffectFromMemory(void *data
, SIZE_T data_size
, UINT flags
,
9830 ID3D10Device
*device
, ID3D10EffectPool
*effect_pool
, ID3D10Effect
**effect
)
9832 struct d3d10_effect
*object
, *pool
= NULL
;
9835 TRACE("data %p, data_size %Iu, flags %#x, device %p, effect_pool %p, effect %p.\n",
9836 data
, data_size
, flags
, device
, effect_pool
, effect
);
9838 if (!(flags
& D3D10_EFFECT_COMPILE_CHILD_EFFECT
) != !effect_pool
)
9839 return E_INVALIDARG
;
9841 if (effect_pool
&& !(pool
= unsafe_impl_from_ID3D10EffectPool(effect_pool
)))
9843 WARN("External pool implementations are not supported.\n");
9844 return E_INVALIDARG
;
9847 if (FAILED(hr
= d3d10_create_effect(data
, data_size
, device
, pool
, 0, &object
)))
9849 WARN("Failed to create an effect, hr %#lx.\n", hr
);
9853 *effect
= &object
->ID3D10Effect_iface
;
9855 TRACE("Created effect %p\n", object
);
9860 static HRESULT STDMETHODCALLTYPE
d3d10_effect_pool_effect_QueryInterface(ID3D10Effect
*iface
,
9861 REFIID riid
, void **object
)
9863 struct d3d10_effect
*effect
= impl_from_ID3D10Effect(iface
);
9865 TRACE("iface %p, riid %s, obj %p.\n", iface
, debugstr_guid(riid
), object
);
9867 return IUnknown_QueryInterface(&effect
->ID3D10EffectPool_iface
, riid
, object
);
9870 static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl
=
9872 /* IUnknown methods */
9873 d3d10_effect_pool_effect_QueryInterface
,
9874 d3d10_effect_AddRef
,
9875 d3d10_effect_Release
,
9876 /* ID3D10Effect methods */
9877 d3d10_effect_IsValid
,
9878 d3d10_effect_IsPool
,
9879 d3d10_effect_GetDevice
,
9880 d3d10_effect_GetDesc
,
9881 d3d10_effect_GetConstantBufferByIndex
,
9882 d3d10_effect_GetConstantBufferByName
,
9883 d3d10_effect_GetVariableByIndex
,
9884 d3d10_effect_GetVariableByName
,
9885 d3d10_effect_GetVariableBySemantic
,
9886 d3d10_effect_GetTechniqueByIndex
,
9887 d3d10_effect_GetTechniqueByName
,
9888 d3d10_effect_Optimize
,
9889 d3d10_effect_IsOptimized
,
9892 HRESULT WINAPI
D3D10CreateEffectPoolFromMemory(void *data
, SIZE_T data_size
, UINT fx_flags
,
9893 ID3D10Device
*device
, ID3D10EffectPool
**effect_pool
)
9895 struct d3d10_effect
*object
;
9898 TRACE("data %p, data_size %Iu, fx_flags %#x, device %p, effect_pool %p.\n",
9899 data
, data_size
, fx_flags
, device
, effect_pool
);
9902 return E_INVALIDARG
;
9904 if (FAILED(hr
= d3d10_create_effect(data
, data_size
, device
, NULL
,
9905 D3D10_EFFECT_IS_POOL
, &object
)))
9907 WARN("Failed to create an effect, hr %#lx.\n", hr
);
9911 *effect_pool
= &object
->ID3D10EffectPool_iface
;
9913 TRACE("Created effect pool %p.\n", object
);