ReactOS  0.4.14-dev-55-g2da92ac
d3dx9_private.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002 Raphael Junqueira
3  * Copyright (C) 2008 David Adam
4  * Copyright (C) 2008 Tony Wasserka
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  */
21 
22 #ifndef __WINE_D3DX9_PRIVATE_H
23 #define __WINE_D3DX9_PRIVATE_H
24 
25 #define NONAMELESSUNION
26 #include "wine/debug.h"
27 #include "wine/heap.h"
28 #include "wine/rbtree.h"
29 
30 #define COBJMACROS
31 #include "d3dx9.h"
32 
33 #define ULONG64_MAX (~(ULONG64)0)
34 
35 struct vec4
36 {
37  float x, y, z, w;
38 };
39 
40 struct volume
41 {
45 };
46 
47 /* for internal use */
49  FORMAT_ARGB, /* unsigned */
50  FORMAT_ARGBF16,/* float 16 */
51  FORMAT_ARGBF, /* float */
55 };
56 
59  BYTE bits[4];
60  BYTE shift[4];
66  void (*from_rgba)(const struct vec4 *src, struct vec4 *dst);
67  void (*to_rgba)(const struct vec4 *src, struct vec4 *dst, const PALETTEENTRY *palette);
68 };
69 
71 {
72  ID3DXInclude ID3DXInclude_iface;
73 };
74 
76 extern const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl DECLSPEC_HIDDEN;
77 
79 {
80  if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
81  || format->type == FORMAT_ARGBF)
82  return TRUE;
83  return !!format->to_rgba;
84 }
85 
87 {
88  if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
89  || format->type == FORMAT_ARGBF)
90  return TRUE;
91  return !!format->from_rgba;
92 }
93 
96 
98 
101 
102 void copy_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch,
103  BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size,
105 void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch,
106  const struct volume *src_size, const struct pixel_format_desc *src_format,
107  BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size,
109 void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch,
110  const struct volume *src_size, const struct pixel_format_desc *src_format,
111  BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size,
113 
114 HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data, const PALETTEENTRY *palette,
115  DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info, unsigned int skip_levels,
116  unsigned int *loaded_miplevels) DECLSPEC_HIDDEN;
117 HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data,
119 HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette,
120  const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key,
121  const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;
122 HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data,
124 HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture,
125  const PALETTEENTRY *src_palette) DECLSPEC_HIDDEN;
126 
127 unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN;
128 float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN;
129 
130 /* debug helpers */
134 
135 /* parameter type conversion helpers */
136 static inline BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
137 {
138  switch (type)
139  {
140  case D3DXPT_FLOAT:
141  case D3DXPT_INT:
142  case D3DXPT_BOOL:
143  return !!*(DWORD *)data;
144 
145  case D3DXPT_VOID:
146  return *(BOOL *)data;
147 
148  default:
149  return FALSE;
150  }
151 }
152 
153 static inline int get_int(D3DXPARAMETER_TYPE type, const void *data)
154 {
155  switch (type)
156  {
157  case D3DXPT_FLOAT:
158  return (int)(*(float *)data);
159 
160  case D3DXPT_INT:
161  case D3DXPT_VOID:
162  return *(int *)data;
163 
164  case D3DXPT_BOOL:
165  return get_bool(type, data);
166 
167  default:
168  return 0;
169  }
170 }
171 
172 static inline float get_float(D3DXPARAMETER_TYPE type, const void *data)
173 {
174  switch (type)
175  {
176  case D3DXPT_FLOAT:
177  case D3DXPT_VOID:
178  return *(float *)data;
179 
180  case D3DXPT_INT:
181  return (float)(*(int *)data);
182 
183  case D3DXPT_BOOL:
184  return (float)get_bool(type, data);
185 
186  default:
187  return 0.0f;
188  }
189 }
190 
191 static inline void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
192 {
193  if (outtype == intype)
194  {
195  *(DWORD *)outdata = *(DWORD *)indata;
196  return;
197  }
198 
199  switch (outtype)
200  {
201  case D3DXPT_FLOAT:
202  *(float *)outdata = get_float(intype, indata);
203  break;
204 
205  case D3DXPT_BOOL:
206  *(BOOL *)outdata = get_bool(intype, indata);
207  break;
208 
209  case D3DXPT_INT:
210  *(int *)outdata = get_int(intype, indata);
211  break;
212 
213  default:
214  *(DWORD *)outdata = 0;
215  break;
216  }
217 }
218 
220 {
221  return type == D3DXPT_SAMPLER
224 }
225 
226 struct d3dx_parameter;
227 
229 {
238 };
239 
241 {
245  unsigned int register_index;
246  unsigned int register_count;
248  unsigned int element_count;
249 };
250 
252 {
253  unsigned int input_count;
256  unsigned int const_set_count;
257  unsigned int const_set_size;
261 };
262 
264 {
266  unsigned int table_sizes[PRES_REGTAB_COUNT]; /* registers count */
267 };
268 
269 struct d3dx_pres_ins;
270 
272 {
274 
275  unsigned int ins_count;
277 
279 };
280 
282 {
284 
287 
289 };
290 
292 {
294  char *full_name;
296 };
297 
298 struct d3dx_shared_data;
300 
302 {
303  char magic_string[4];
306  char *name;
307  void *data;
317 
319  char *semantic;
320 
321  char *full_name;
323 };
324 
326 {
333 };
334 
336 {
337  void *data;
339  unsigned int size, count;
341 };
342 
343 struct d3dx9_base_effect;
344 
346 {
347  return &param->top_level_param->param == param;
348 }
349 
350 static inline struct d3dx_top_level_parameter
352 {
354 }
355 
357 {
358  return ++*version_counter;
359 }
360 
362 {
363  struct d3dx_shared_data *shared_data;
364 
365  if ((shared_data = param->shared_data))
366  return update_version < shared_data->update_version;
367  else
368  return update_version < param->update_version;
369 }
370 
372 {
373  return is_top_level_param_dirty(param->top_level_param, update_version);
374 }
375 
377  struct d3dx_parameter *parameter, const char *name) DECLSPEC_HIDDEN;
378 
379 #ifdef __REACTOS__
380 #define SET_D3D_STATE_(_manager, _device, _method, ...) ((_manager) ? (_manager)->lpVtbl->_method((_manager), __VA_ARGS__) \
381  : (_device)->lpVtbl->_method((_device), __VA_ARGS__))
382 #define SET_D3D_STATE(_base_effect, _method, ...) SET_D3D_STATE_((_base_effect)->manager, (_base_effect)->device, _method, __VA_ARGS__)
383 #else
384 #define SET_D3D_STATE_(manager, device, method, args...) (manager ? manager->lpVtbl->method(manager, args) \
385  : device->lpVtbl->method(device, args))
386 #define SET_D3D_STATE(base_effect, args...) SET_D3D_STATE_(base_effect->manager, base_effect->device, args)
387 #endif
388 
389 HRESULT d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_code,
390  unsigned int byte_code_size, D3DXPARAMETER_TYPE type,
391  struct d3dx_param_eval **peval, ULONG64 *version_counter,
392  const char **skip_constants, unsigned int skip_constants_count) DECLSPEC_HIDDEN;
395  const struct d3dx_parameter *param, void *param_value) DECLSPEC_HIDDEN;
396 HRESULT d3dx_param_eval_set_shader_constants(ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device,
397  struct d3dx_param_eval *peval, BOOL update_all) DECLSPEC_HIDDEN;
399 
404 };
405 
406 const struct ctab_constant *d3dx_shader_get_ctab_constant(ID3DXConstantTable *iface,
408 
409 HRESULT create_dummy_skin(ID3DXSkinInfo **iface) DECLSPEC_HIDDEN;
410 
411 #endif /* __WINE_D3DX9_PRIVATE_H */
char magic_string[4]
UINT width
Definition: d3dx9_private.h:42
const char * debug_d3dxparameter_class(D3DXPARAMETER_CLASS c) DECLSPEC_HIDDEN
Definition: util.c:233
static BOOL is_param_type_sampler(D3DXPARAMETER_TYPE type)
#define TRUE
Definition: types.h:120
BOOL is_param_eval_input_dirty(struct d3dx_param_eval *peval, ULONG64 update_version) DECLSPEC_HIDDEN
Definition: preshader.c:1716
struct d3dx_shared_data * shared_data
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
D3DXPARAMETER_TYPE type
static const char * dst_format
Definition: dib.c:1133
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
static int get_int(D3DXPARAMETER_TYPE type, const void *data)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
D3DXCONSTANT_DESC * inputs
enum pres_reg_tables table
const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl
Definition: shader.c:314
GLdouble GLdouble t
Definition: gl.h:2047
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
GLuint buffer
Definition: glext.h:5915
char * full_name
const char * debug_d3dxparameter_registerset(D3DXREGISTER_SET r) DECLSPEC_HIDDEN
Definition: util.c:279
D3DXCONSTANT_DESC desc
static float get_float(D3DXPARAMETER_TYPE type, const void *data)
void(* to_rgba)(const struct vec4 *src, struct vec4 *dst, const PALETTEENTRY *palette)
Definition: d3dx9_private.h:67
const char * filename
Definition: ioapi.h:135
HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
WORD constantinfo_reserved
HRESULT d3dx_param_eval_set_shader_constants(ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device, struct d3dx_param_eval *peval, BOOL update_all) DECLSPEC_HIDDEN
Definition: preshader.c:1751
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
const char * debug_d3dxparameter_type(D3DXPARAMETER_TYPE t) DECLSPEC_HIDDEN
Definition: util.c:249
struct d3dx_const_param_eval_output * const_set
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
struct d3dx_parameter ** inputs_param
void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette) DECLSPEC_HIDDEN
Definition: surface.c:1735
struct d3dx_top_level_parameter * top_level_param
unsigned int size
static BOOL is_top_level_param_dirty(struct d3dx_top_level_parameter *param, ULONG64 update_version)
struct wine_rb_entry entry
ULONG64 update_version
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:166
const struct ctab_constant * d3dx_shader_get_ctab_constant(ID3DXConstantTable *iface, D3DXHANDLE constant) DECLSPEC_HIDDEN
Definition: shader.c:977
unsigned int table_sizes[PRES_REGTAB_COUNT]
struct d3dx_parameter * members
unsigned int idx
Definition: utils.c:41
static BOOL is_conversion_from_supported(const struct pixel_format_desc *format)
Definition: d3dx9_private.h:78
UINT height
Definition: d3dx9_private.h:43
const struct pixel_format_desc * get_format_info_idx(int idx) DECLSPEC_HIDDEN
Definition: util.c:222
struct d3dx_top_level_parameter ** parameters
HRESULT write_buffer_to_file(const WCHAR *filename, ID3DXBuffer *buffer) DECLSPEC_HIDDEN
Definition: util.c:182
struct d3dx_parameter * annotations
format_type
Definition: d3dx9_private.h:48
struct d3dx_parameter * get_parameter_by_name(struct d3dx9_base_effect *base, struct d3dx_parameter *parameter, const char *name) DECLSPEC_HIDDEN
Definition: effect.c:898
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
static BOOL is_top_level_parameter(struct d3dx_parameter *param)
enum _D3DFORMAT D3DFORMAT
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
Definition: surface.c:609
HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette) DECLSPEC_HIDDEN
Definition: surface.c:562
float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN
Definition: math.c:2247
UINT depth
Definition: d3dx9_private.h:44
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct ctab_constant * constants
static ULONG64 next_update_version(ULONG64 *version_counter)
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned int input_count
unsigned int count
pres_reg_tables
GLfloat param
Definition: glext.h:5796
const GLubyte * c
Definition: glext.h:8905
enum format_type type
Definition: d3dx9_private.h:65
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int ins_count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static BOOL is_param_dirty(struct d3dx_parameter *param, ULONG64 update_version)
float w
Definition: d3dx9_private.h:37
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:118
unsigned __int64 ULONG64
Definition: imports.h:198
struct d3dx_const_tab shader_inputs
void * tables[PRES_REGTAB_COUNT]
struct d3dx_param_eval * param_eval
HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, DWORD color_key, const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN
Definition: surface.c:737
enum _D3DXREGISTER_SET D3DXREGISTER_SET
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
enum D3DXPARAMETER_CLASS constant_class
static HPALETTE palette
Definition: clipboard.c:1345
ID3DXInclude ID3DXInclude_iface
Definition: d3dx9_private.h:72
void copy_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size, const struct pixel_format_desc *format) DECLSPEC_HIDDEN
Definition: surface.c:1601
D3DXPARAMETER_TYPE
Definition: d3dx9shader.h:71
HRESULT d3dx_evaluate_parameter(struct d3dx_param_eval *peval, const struct d3dx_parameter *param, void *param_value) DECLSPEC_HIDDEN
Definition: preshader.c:1722
struct d3dx_preshader pres
GLuint in
Definition: glext.h:9616
static struct d3dx_top_level_parameter * top_level_parameter_from_parameter(struct d3dx_parameter *param)
unsigned int const_set_size
Definition: rbtree.h:35
void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, const struct volume *src_size, const struct pixel_format_desc *src_format, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size, const struct pixel_format_desc *dst_format, D3DCOLOR color_key, const PALETTEENTRY *palette) DECLSPEC_HIDDEN
Definition: surface.c:1632
GLenum GLenum dst
Definition: glext.h:6340
struct wine_rb_entry rb_entry
unsigned int UINT
Definition: ndis.h:50
float z
Definition: d3dx9_private.h:37
static BOOL is_conversion_to_supported(const struct pixel_format_desc *format)
Definition: d3dx9_private.h:86
CRITICAL_SECTION from_file_mutex
Definition: shader.c:228
struct d3dx_pres_ins * ins
struct d3dx_parameter * param
void d3dx_free_param_eval(struct d3dx_param_eval *peval) DECLSPEC_HIDDEN
Definition: preshader.c:1357
Definition: name.c:36
ULONG64 * version_counter
D3DXPARAMETER_TYPE param_type
CRITICAL_SECTION from_file_mutex DECLSPEC_HIDDEN
Definition: d3dx9_private.h:76
struct d3dx_regstore regs
void(* from_rgba)(const struct vec4 *src, struct vec4 *dst)
Definition: d3dx9_private.h:66
struct d3dx_const_tab inputs
ULONG64 update_version
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:213
unsigned int const_set_count
float x
Definition: d3dx9_private.h:37
float y
Definition: d3dx9_private.h:37
HRESULT create_dummy_skin(ID3DXSkinInfo **iface) DECLSPEC_HIDDEN
Definition: skin.c:579
enum pres_reg_tables * regset2table
unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN
Definition: math.c:2146
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data, const PALETTEENTRY *palette, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info, unsigned int skip_levels, unsigned int *loaded_miplevels) DECLSPEC_HIDDEN
Definition: surface.c:627
D3DXPARAMETER_CLASS
Definition: d3dx9shader.h:60
HRESULT d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_code, unsigned int byte_code_size, D3DXPARAMETER_TYPE type, struct d3dx_param_eval **peval, ULONG64 *version_counter, const char **skip_constants, unsigned int skip_constants_count) DECLSPEC_HIDDEN
Definition: preshader.c:1232
struct d3dx_parameter * param