ReactOS 0.4.16-dev-306-g647d351
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#include <stdint.h>
26#define NONAMELESSUNION
27#include "wine/debug.h"
28#include "wine/heap.h"
29#include "wine/rbtree.h"
30
31#define COBJMACROS
32#include "d3dx9.h"
33
34#define ULONG64_MAX (~(ULONG64)0)
35
36struct vec4
37{
38 float x, y, z, w;
39};
40
41struct volume
42{
46};
47
48/* for internal use */
50 FORMAT_ARGB, /* unsigned */
51 FORMAT_ARGBF16,/* float 16 */
52 FORMAT_ARGBF, /* float */
56};
57
67 void (*from_rgba)(const struct vec4 *src, struct vec4 *dst);
68 void (*to_rgba)(const struct vec4 *src, struct vec4 *dst, const PALETTEENTRY *palette);
69};
70
72{
73 ID3DXInclude ID3DXInclude_iface;
74};
75
77extern const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl DECLSPEC_HIDDEN;
78
80{
81 if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
82 || format->type == FORMAT_ARGBF || format->type == FORMAT_DXT)
83 return TRUE;
84 return !!format->to_rgba;
85}
86
88{
89 if (format->type == FORMAT_ARGB || format->type == FORMAT_ARGBF16
90 || format->type == FORMAT_ARGBF || format->type == FORMAT_DXT)
91 return TRUE;
92 return !!format->from_rgba;
93}
94
97
99
102
103void copy_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch,
104 BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size,
106void convert_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch,
107 const struct volume *src_size, const struct pixel_format_desc *src_format,
108 BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size,
110void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch,
111 const struct volume *src_size, const struct pixel_format_desc *src_format,
112 BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *dst_size,
114
115HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data, const PALETTEENTRY *palette,
116 DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info, unsigned int skip_levels,
117 unsigned int *loaded_miplevels) DECLSPEC_HIDDEN;
118HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const void *src_data,
120HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette,
121 const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key,
122 const D3DXIMAGE_INFO *src_info) DECLSPEC_HIDDEN;
123HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, const void *src_data,
125HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock,
126 IDirect3DSurface9 **temp_surface, BOOL write) DECLSPEC_HIDDEN;
127HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect,
128 IDirect3DSurface9 *temp_surface, BOOL update) DECLSPEC_HIDDEN;
129HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture,
130 const PALETTEENTRY *src_palette) DECLSPEC_HIDDEN;
131
132unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN;
133float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN;
134
135/* debug helpers */
139
140/* parameter type conversion helpers */
141static inline BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
142{
143 switch (type)
144 {
145 case D3DXPT_FLOAT:
146 case D3DXPT_INT:
147 case D3DXPT_BOOL:
148 return !!*(DWORD *)data;
149
150 case D3DXPT_VOID:
151 return *(BOOL *)data;
152
153 default:
154 return FALSE;
155 }
156}
157
158static inline int get_int(D3DXPARAMETER_TYPE type, const void *data)
159{
160 switch (type)
161 {
162 case D3DXPT_FLOAT:
163 return (int)(*(float *)data);
164
165 case D3DXPT_INT:
166 case D3DXPT_VOID:
167 return *(int *)data;
168
169 case D3DXPT_BOOL:
170 return get_bool(type, data);
171
172 default:
173 return 0;
174 }
175}
176
177static inline float get_float(D3DXPARAMETER_TYPE type, const void *data)
178{
179 switch (type)
180 {
181 case D3DXPT_FLOAT:
182 case D3DXPT_VOID:
183 return *(float *)data;
184
185 case D3DXPT_INT:
186 return (float)(*(int *)data);
187
188 case D3DXPT_BOOL:
189 return (float)get_bool(type, data);
190
191 default:
192 return 0.0f;
193 }
194}
195
196static inline void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
197{
198 if (outtype == intype)
199 {
200 *(DWORD *)outdata = *(DWORD *)indata;
201 return;
202 }
203
204 switch (outtype)
205 {
206 case D3DXPT_FLOAT:
207 *(float *)outdata = get_float(intype, indata);
208 break;
209
210 case D3DXPT_BOOL:
211 *(BOOL *)outdata = get_bool(intype, indata);
212 break;
213
214 case D3DXPT_INT:
215 *(int *)outdata = get_int(intype, indata);
216 break;
217
218 default:
219 *(DWORD *)outdata = 0;
220 break;
221 }
222}
223
225{
226 return type == D3DXPT_SAMPLER
229}
230
231/* Returns the smallest power of 2 which is greater than or equal to num */
233{
234#ifndef __REACTOS__
236#else
237 unsigned long index;
238#endif
239 return BitScanReverse(&index, num - 1) ? 1u << (index + 1) : 1;
240}
241
242struct d3dx_parameter;
243
245{
254};
255
257{
261 unsigned int register_index;
262 unsigned int register_count;
264 unsigned int element_count;
265};
266
268{
269 unsigned int input_count;
272 unsigned int const_set_count;
273 unsigned int const_set_size;
277};
278
280{
282 unsigned int table_sizes[PRES_REGTAB_COUNT]; /* registers count */
283};
284
285struct d3dx_pres_ins;
286
288{
290
291 unsigned int ins_count;
293
295};
296
298{
300
303
305};
306
308{
312};
313
314struct d3dx_shared_data;
316
318{
322 char *name;
323 void *data;
333
335 char *semantic;
336
339};
340
342{
349};
350
352{
353 void *data;
355 unsigned int size, count;
357};
358
359struct d3dx_effect;
360
362{
363 return &param->top_level_param->param == param;
364}
365
366static inline struct d3dx_top_level_parameter
368{
370}
371
373{
374 return ++*version_counter;
375}
376
378{
379 struct d3dx_shared_data *shared_data;
380
381 if ((shared_data = param->shared_data))
382 return update_version < shared_data->update_version;
383 else
384 return update_version < param->update_version;
385}
386
388{
389 return is_top_level_param_dirty(param->top_level_param, update_version);
390}
391
393 struct d3dx_parameter *parameter, const char *name) DECLSPEC_HIDDEN;
394
395#ifdef __REACTOS__
396#define SET_D3D_STATE_(_manager, _device, _method, ...) ((_manager) ? (_manager)->lpVtbl->_method((_manager), __VA_ARGS__) \
397 : (_device)->lpVtbl->_method((_device), __VA_ARGS__))
398#define SET_D3D_STATE(_base_effect, _method, ...) SET_D3D_STATE_((_base_effect)->manager, (_base_effect)->device, _method, __VA_ARGS__)
399#else
400#define SET_D3D_STATE_(manager, device, method, args...) (manager ? manager->lpVtbl->method(manager, args) \
401 : device->lpVtbl->method(device, args))
402#define SET_D3D_STATE(base_effect, args...) SET_D3D_STATE_(base_effect->manager, base_effect->device, args)
403#endif
404
405HRESULT d3dx_create_param_eval(struct d3dx_effect *effect, void *byte_code,
406 unsigned int byte_code_size, D3DXPARAMETER_TYPE type,
407 struct d3dx_param_eval **peval, ULONG64 *version_counter,
408 const char **skip_constants, unsigned int skip_constants_count) DECLSPEC_HIDDEN;
411 const struct d3dx_parameter *param, void *param_value) DECLSPEC_HIDDEN;
412HRESULT d3dx_param_eval_set_shader_constants(ID3DXEffectStateManager *manager, struct IDirect3DDevice9 *device,
413 struct d3dx_param_eval *peval, BOOL update_all) DECLSPEC_HIDDEN;
415
420};
421
422const struct ctab_constant *d3dx_shader_get_ctab_constant(ID3DXConstantTable *iface,
424
425#endif /* __WINE_D3DX9_PRIVATE_H */
#define write
Definition: acwin.h:97
#define index(s, c)
Definition: various.h:29
enum _D3DFORMAT D3DFORMAT
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
static BOOL is_param_type_sampler(D3DXPARAMETER_TYPE type)
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:1700
static int get_int(D3DXPARAMETER_TYPE type, const void *data)
static struct d3dx_top_level_parameter * top_level_parameter_from_parameter(struct d3dx_parameter *param)
static BOOL is_param_dirty(struct d3dx_parameter *param, ULONG64 update_version)
static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
static ULONG64 next_update_version(ULONG64 *version_counter)
HRESULT lock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, D3DLOCKED_RECT *lock, IDirect3DSurface9 **temp_surface, BOOL write) DECLSPEC_HIDDEN
Definition: surface.c:209
static BOOL is_conversion_to_supported(const struct pixel_format_desc *format)
Definition: d3dx9_private.h:87
const struct pixel_format_desc * get_format_info_idx(int idx) DECLSPEC_HIDDEN
Definition: util.c:226
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:1752
HRESULT unlock_surface(IDirect3DSurface9 *surface, const RECT *surface_rect, IDirect3DSurface9 *temp_surface, BOOL update) DECLSPEC_HIDDEN
Definition: surface.c:267
HRESULT d3dx_create_param_eval(struct d3dx_effect *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:1233
HRESULT map_view_of_file(const WCHAR *filename, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:120
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:719
static float get_float(D3DXPARAMETER_TYPE type, const void *data)
const char * debug_d3dxparameter_type(D3DXPARAMETER_TYPE t) DECLSPEC_HIDDEN
Definition: util.c:253
void d3dx_free_param_eval(struct d3dx_param_eval *peval) DECLSPEC_HIDDEN
Definition: preshader.c:1358
HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette) DECLSPEC_HIDDEN
Definition: surface.c:672
static void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
HRESULT d3dx_evaluate_parameter(struct d3dx_param_eval *peval, const struct d3dx_parameter *param, void *param_value) DECLSPEC_HIDDEN
Definition: preshader.c:1723
BOOL is_param_eval_input_dirty(struct d3dx_param_eval *peval, ULONG64 update_version) DECLSPEC_HIDDEN
Definition: preshader.c:1717
unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN
Definition: math.c:2102
const struct pixel_format_desc * get_format_info(D3DFORMAT format) DECLSPEC_HIDDEN
Definition: util.c:217
struct d3dx_parameter * get_parameter_by_name(struct d3dx_effect *effect, struct d3dx_parameter *parameter, const char *name) DECLSPEC_HIDDEN
Definition: effect.c:1026
static BOOL is_top_level_parameter(struct d3dx_parameter *param)
HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length) DECLSPEC_HIDDEN
Definition: util.c:170
float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN
Definition: math.c:2203
const char * debug_d3dxparameter_class(D3DXPARAMETER_CLASS c) DECLSPEC_HIDDEN
Definition: util.c:237
HRESULT write_buffer_to_file(const WCHAR *filename, ID3DXBuffer *buffer) DECLSPEC_HIDDEN
Definition: util.c:186
format_type
Definition: d3dx9_private.h:49
@ FORMAT_ARGBF16
Definition: d3dx9_private.h:51
@ FORMAT_UNKNOWN
Definition: d3dx9_private.h:55
@ FORMAT_ARGB
Definition: d3dx9_private.h:50
@ FORMAT_ARGBF
Definition: d3dx9_private.h:52
@ FORMAT_INDEX
Definition: d3dx9_private.h:54
@ FORMAT_DXT
Definition: d3dx9_private.h:53
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:1839
CRITICAL_SECTION from_file_mutex DECLSPEC_HIDDEN
Definition: d3dx9_private.h:77
const struct ctab_constant * d3dx_shader_get_ctab_constant(ID3DXConstantTable *iface, D3DXHANDLE constant) DECLSPEC_HIDDEN
Definition: shader.c:984
static BOOL is_conversion_from_supported(const struct pixel_format_desc *format)
Definition: d3dx9_private.h:79
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
pres_reg_tables
@ PRES_REGTAB_COUNT
@ PRES_REGTAB_FIRST_SHADER
@ PRES_REGTAB_OICONST
@ PRES_REGTAB_IMMED
@ PRES_REGTAB_TEMP
@ PRES_REGTAB_CONST
@ PRES_REGTAB_OCONST
@ PRES_REGTAB_OBCONST
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:847
static uint32_t make_pow2(uint32_t num)
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:1731
static BOOL is_top_level_param_dirty(struct d3dx_top_level_parameter *param, ULONG64 update_version)
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:737
const char * debug_d3dxparameter_registerset(D3DXREGISTER_SET r) DECLSPEC_HIDDEN
Definition: util.c:283
D3DXPARAMETER_CLASS
Definition: d3dx9shader.h:61
const char * D3DXHANDLE
Definition: d3dx9shader.h:48
enum _D3DXREGISTER_SET D3DXREGISTER_SET
D3DXPARAMETER_TYPE
Definition: d3dx9shader.h:72
@ D3DXPT_SAMPLER3D
Definition: d3dx9shader.h:86
@ D3DXPT_SAMPLERCUBE
Definition: d3dx9shader.h:87
@ D3DXPT_FLOAT
Definition: d3dx9shader.h:76
@ D3DXPT_BOOL
Definition: d3dx9shader.h:74
@ D3DXPT_INT
Definition: d3dx9shader.h:75
@ D3DXPT_VOID
Definition: d3dx9shader.h:73
@ D3DXPT_SAMPLER
Definition: d3dx9shader.h:83
@ D3DXPT_SAMPLER1D
Definition: d3dx9shader.h:84
@ D3DXPT_SAMPLER2D
Definition: d3dx9shader.h:85
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT32 uint32_t
Definition: types.h:75
CRITICAL_SECTION from_file_mutex
Definition: shader.c:229
const struct ID3DXIncludeVtbl d3dx_include_from_file_vtbl
Definition: shader.c:315
unsigned int idx
Definition: utils.c:41
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint texture
Definition: glext.h:6295
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
const GLubyte * c
Definition: glext.h:8905
GLuint index
Definition: glext.h:6031
GLuint in
Definition: glext.h:9616
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint GLuint num
Definition: glext.h:9618
GLfloat param
Definition: glext.h:5796
#define BitScanReverse
Definition: interlocked.h:6
const char * filename
Definition: ioapi.h:137
unsigned __int64 ULONG64
Definition: imports.h:198
static const char * dst_format
Definition: dib.c:1133
static HPALETTE palette
Definition: clipboard.c:1345
unsigned int UINT
Definition: ndis.h:50
struct ctab_constant * constants
WORD constantinfo_reserved
D3DXCONSTANT_DESC desc
enum D3DXPARAMETER_CLASS constant_class
enum pres_reg_tables table
struct d3dx_parameter * param
struct d3dx_parameter ** inputs_param
struct d3dx_const_param_eval_output * const_set
unsigned int const_set_count
ULONG64 update_version
unsigned int const_set_size
D3DXCONSTANT_DESC * inputs
unsigned int input_count
enum pres_reg_tables * regset2table
ID3DXInclude ID3DXInclude_iface
Definition: d3dx9_private.h:73
struct d3dx_const_tab shader_inputs
struct d3dx_preshader pres
ULONG64 * version_counter
D3DXPARAMETER_TYPE param_type
struct d3dx_parameter * members
struct d3dx_param_eval * param_eval
D3DXPARAMETER_TYPE type
char magic_string[4]
struct wine_rb_entry rb_entry
struct d3dx_top_level_parameter * top_level_param
unsigned int ins_count
struct d3dx_const_tab inputs
struct d3dx_pres_ins * ins
struct d3dx_regstore regs
void * tables[PRES_REGTAB_COUNT]
unsigned int table_sizes[PRES_REGTAB_COUNT]
unsigned int size
struct d3dx_top_level_parameter ** parameters
unsigned int count
ULONG64 update_version
struct d3dx_shared_data * shared_data
struct d3dx_parameter * annotations
Definition: devices.h:37
Definition: format.c:58
Definition: name.c:39
struct wine_rb_entry entry
struct d3dx_parameter * param
char * full_name
void(* from_rgba)(const struct vec4 *src, struct vec4 *dst)
Definition: d3dx9_private.h:67
void(* to_rgba)(const struct vec4 *src, struct vec4 *dst, const PALETTEENTRY *palette)
Definition: d3dx9_private.h:68
enum format_type type
Definition: d3dx9_private.h:66
float w
Definition: d3dx9_private.h:38
float z
Definition: d3dx9_private.h:38
float x
Definition: d3dx9_private.h:38
float y
Definition: d3dx9_private.h:38
UINT depth
Definition: d3dx9_private.h:45
UINT height
Definition: d3dx9_private.h:44
UINT width
Definition: d3dx9_private.h:43
Definition: rbtree.h:36
rwlock_t lock
Definition: tcpcore.h:0
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193