ReactOS 0.4.17-dev-966-gf06eace
d3d8_private.h
Go to the documentation of this file.
1/*
2 * Direct3D 8 private include file
3 *
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23#ifndef __WINE_D3D8_PRIVATE_H
24#define __WINE_D3D8_PRIVATE_H
25
26#include <assert.h>
27#include <stdarg.h>
28
29#define COBJMACROS
30#include "windef.h"
31#include "winbase.h"
32#include "wingdi.h"
33#include "wine/debug.h"
34#include "d3d8.h"
35#include "wine/wined3d.h"
36
37#define D3DPRESENTFLAGS_MASK 0x00000fffu
38
39#define D3D8_MAX_VERTEX_SHADER_CONSTANTF 256
40#define D3D8_MAX_PIXEL_SHADER_CONSTANTF 8
41#define D3D8_MAX_STREAMS 16
42
43#define D3DFMT_RESZ MAKEFOURCC('R','E','S','Z')
44#define D3D8_RESZ_CODE 0x7fa05000
45
46/* CreateVertexShader can return > 0xFFFF */
47#define VS_HIGHESTFIXEDFXF 0xF0000000
48
50
52 unsigned int adapter_ordinal);
53
54struct d3d8
55{
56 IDirect3D8 IDirect3D8_iface;
61};
62
63BOOL d3d8_init(struct d3d8 *d3d8);
64
65/*****************************************************************************
66 * IDirect3DDevice8 implementation structure
67 */
68
69#define D3D8_INITIAL_HANDLE_TABLE_SIZE 64
70#define D3D8_INVALID_HANDLE ~0U
71
73{
78};
79
81{
82 void *object;
84};
85
87{
92};
93
95{
98};
99
101{
105};
106
108{
109 /* IUnknown fields */
110 IDirect3DDevice8 IDirect3DDevice8_iface;
115 unsigned int adapter_ordinal;
118
119 /* FVF management */
122
124
126 DWORD sysmem_vb : 16; /* D3D8_MAX_STREAMS */
130
132
133 /* The d3d8 API supports only one implicit swapchain (no D3DCREATE_ADAPTERGROUP_DEVICE,
134 * no GetSwapchain, GetBackBuffer doesn't accept a swapchain number). */
136
139};
140
143
144static inline struct d3d8_device *impl_from_IDirect3DDevice8(IDirect3DDevice8 *iface)
145{
147}
148
150{
153};
154
158 void *data, DWORD *data_size);
161 const void *data, DWORD data_size, DWORD flags);
162
164{
165 IDirect3DVolume8 IDirect3DVolume8_iface;
168 unsigned int sub_resource_idx;
170};
171
173 unsigned int sub_resource_idx, const struct wined3d_parent_ops **parent_ops);
174
176{
177 IDirect3DSwapChain8 IDirect3DSwapChain8_iface;
181 IDirect3DDevice8 *parent_device;
182 unsigned int swap_interval;
183};
184
186 unsigned int swap_interval, struct d3d8_swapchain **swapchain);
187
189{
190 IDirect3DSurface8 IDirect3DSurface8_iface;
193 unsigned int sub_resource_idx;
196 IDirect3DDevice8 *parent_device;
200};
201
204 unsigned int sub_resource_idx, IUnknown *container);
205struct d3d8_device *d3d8_surface_get_device(const struct d3d8_surface *surface);
207 struct wined3d_rendertarget_view *rtv);
208struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface);
209
211{
212 IDirect3DVertexBuffer8 IDirect3DVertexBuffer8_iface;
215 IDirect3DDevice8 *parent_device;
219};
220
223struct d3d8_vertexbuffer *unsafe_impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface);
224
226{
227 IDirect3DIndexBuffer8 IDirect3DIndexBuffer8_iface;
230 IDirect3DDevice8 *parent_device;
233 bool sysmem;
235};
236
239struct d3d8_indexbuffer *unsafe_impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface);
240
242{
243 IDirect3DBaseTexture8 IDirect3DBaseTexture8_iface;
248};
249
251 unsigned int height, unsigned int level_count, DWORD usage, D3DFORMAT format, D3DPOOL pool);
253 unsigned int height, unsigned int depth, unsigned int levels, DWORD usage, D3DFORMAT format, D3DPOOL pool);
255 unsigned int edge_length, unsigned int level_count, DWORD usage, D3DFORMAT format, D3DPOOL pool);
256
258{
259 return texture->draw_texture ? texture->draw_texture : texture->wined3d_texture;
260}
261
262struct d3d8_texture *unsafe_impl_from_IDirect3DBaseTexture8(IDirect3DBaseTexture8 *iface);
263
265{
267 DWORD elements_size; /* Size of elements, in bytes */
271};
272
275 struct d3d8_device *device, const DWORD *elements, DWORD shader_handle);
277 struct d3d8_device *device, DWORD fvf);
278
280{
283};
284
287 const DWORD *declaration, const DWORD *byte_code, DWORD shader_handle, DWORD usage);
288
290{
293};
294
297 const DWORD *byte_code, DWORD shader_handle);
298
301unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags, unsigned int usage);
302void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader);
303size_t parse_token(const DWORD *pToken);
304
305static inline DWORD d3dusage_from_wined3dusage(unsigned int wined3d_usage, unsigned int bind_flags)
306{
307 DWORD usage = wined3d_usage & WINED3DUSAGE_MASK;
308 if (bind_flags & WINED3D_BIND_RENDER_TARGET)
310 if (bind_flags & WINED3D_BIND_DEPTH_STENCIL)
312 return usage;
313}
314
315static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage)
316{
318 return D3DPOOL_MANAGED;
319
321 {
322 default:
324 return D3DPOOL_DEFAULT;
327 return D3DPOOL_SCRATCH;
328 return D3DPOOL_SYSTEMMEM;
330 return D3DPOOL_MANAGED;
331 }
332}
333
334static inline unsigned int map_access_from_usage(unsigned int usage)
335{
339}
340
341static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage)
342{
343 unsigned int access;
344
345 switch (pool)
346 {
347 case D3DPOOL_DEFAULT:
349 break;
350 case D3DPOOL_MANAGED:
352 break;
354 case D3DPOOL_SCRATCH:
356 break;
357 default:
358 access = 0;
359 }
362 return access;
363}
364
365static inline unsigned int wined3d_usage_from_d3d(D3DPOOL pool, DWORD usage)
366{
368 if (pool == D3DPOOL_SCRATCH)
370 else if (pool == D3DPOOL_MANAGED)
373}
374
376{
377 unsigned int bind_flags = 0;
378
380 bind_flags |= WINED3D_BIND_RENDER_TARGET;
382 bind_flags |= WINED3D_BIND_DEPTH_STENCIL;
383
384 return bind_flags;
385}
386
388{
390}
391
393{
394 return (enum wined3d_device_type)type;
395}
396
397#endif /* __WINE_D3DX8_PRIVATE_H */
Definition: list.h:39
static DWORD d3dusage_from_wined3dusage(unsigned int wined3d_usage, unsigned int bind_flags)
Definition: d3d8_private.h:305
struct d3d8_texture * unsafe_impl_from_IDirect3DBaseTexture8(IDirect3DBaseTexture8 *iface)
Definition: texture.c:1017
void volume_init(struct d3d8_volume *volume, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, const struct wined3d_parent_ops **parent_ops)
Definition: volume.c:203
d3d8_device_state
Definition: d3d8_private.h:101
@ D3D8_DEVICE_STATE_OK
Definition: d3d8_private.h:102
@ D3D8_DEVICE_STATE_NOT_RESET
Definition: d3d8_private.h:104
@ D3D8_DEVICE_STATE_LOST
Definition: d3d8_private.h:103
void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration)
void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader)
size_t parse_token(const DWORD *pToken)
HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, struct d3d8_device *device, const DWORD *declaration, const DWORD *byte_code, DWORD shader_handle, DWORD usage)
Definition: shader.c:78
static unsigned int wined3d_bind_flags_from_d3d8_usage(DWORD usage)
Definition: d3d8_private.h:375
HRESULT d3d8_texture_3d_init(struct d3d8_texture *texture, struct d3d8_device *device, unsigned int width, unsigned int height, unsigned int depth, unsigned int levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
Definition: texture.c:1168
static unsigned int map_access_from_usage(unsigned int usage)
Definition: d3d8_private.h:334
struct d3d8_surface * unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)
Definition: surface.c:412
HRESULT d3d8_resource_get_private_data(struct d3d8_resource *resource, const GUID *guid, void *data, DWORD *data_size)
Definition: d3d8_main.c:172
HRESULT d3d8_vertex_declaration_init_fvf(struct d3d8_vertex_declaration *declaration, struct d3d8_device *device, DWORD fvf)
struct d3d8_device * d3d8_surface_get_device(const struct d3d8_surface *surface)
Definition: surface.c:372
struct d3d8_indexbuffer * unsafe_impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface)
Definition: buffer.c:653
HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wined3d *wined3d, UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters)
Definition: device.c:3667
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format)
Definition: device.c:33
struct wined3d_rendertarget_view * d3d8_surface_acquire_rendertarget_view(struct d3d8_surface *surface)
Definition: surface.c:379
static enum wined3d_device_type wined3d_device_type_from_d3d(D3DDEVTYPE type)
Definition: d3d8_private.h:392
HRESULT d3d8_texture_cube_init(struct d3d8_texture *texture, struct d3d8_device *device, unsigned int edge_length, unsigned int level_count, DWORD usage, D3DFORMAT format, D3DPOOL pool)
Definition: texture.c:1141
static D3DMULTISAMPLE_TYPE d3dmultisample_type_from_wined3d(enum wined3d_multisample_type type)
Definition: d3d8_private.h:387
static unsigned int wined3d_usage_from_d3d(D3DPOOL pool, DWORD usage)
Definition: d3d8_private.h:365
void d3d8_resource_cleanup(struct d3d8_resource *resource)
Definition: d3d8_main.c:149
void d3dcaps_from_wined3dcaps(D3DCAPS8 *caps, const struct wined3d_caps *wined3d_caps, unsigned int adapter_ordinal)
Definition: device.c:321
struct d3d8_vertexbuffer * unsafe_impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface)
Definition: buffer.c:345
HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *device, UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
Definition: buffer.c:605
struct d3d8_surface * d3d8_surface_create(struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, IUnknown *container)
Definition: surface.c:318
HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *device, UINT size, DWORD usage, DWORD fvf, D3DPOOL pool)
Definition: buffer.c:284
HRESULT d3d8_texture_2d_init(struct d3d8_texture *texture, struct d3d8_device *device, unsigned int width, unsigned int height, unsigned int level_count, DWORD usage, D3DFORMAT format, D3DPOOL pool)
Definition: texture.c:1114
void d3d8_vertex_shader_destroy(struct d3d8_vertex_shader *shader)
Definition: shader.c:31
HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration, struct d3d8_device *device, const DWORD *elements, DWORD shader_handle)
static struct wined3d_texture * d3d8_texture_get_draw_texture(struct d3d8_texture *texture)
Definition: d3d8_private.h:257
static struct d3d8_device * impl_from_IDirect3DDevice8(IDirect3DDevice8 *iface)
Definition: d3d8_private.h:144
void d3d8_resource_init(struct d3d8_resource *resource)
Definition: d3d8_main.c:210
BOOL d3d8_init(struct d3d8 *d3d8)
Definition: directx.c:474
const struct wined3d_parent_ops d3d8_null_wined3d_parent_ops
Definition: device.c:28
static unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int usage)
Definition: d3d8_private.h:341
HRESULT d3d8_pixel_shader_init(struct d3d8_pixel_shader *shader, struct d3d8_device *device, const DWORD *byte_code, DWORD shader_handle)
Definition: shader.c:156
unsigned int wined3dmapflags_from_d3dmapflags(unsigned int flags, unsigned int usage)
Definition: device.c:135
void d3d8_pixel_shader_destroy(struct d3d8_pixel_shader *shader)
Definition: shader.c:142
HRESULT d3d8_resource_set_private_data(struct d3d8_resource *resource, const GUID *guid, const void *data, DWORD data_size, DWORD flags)
Definition: d3d8_main.c:216
HRESULT d3d8_swapchain_create(struct d3d8_device *device, struct wined3d_swapchain_desc *desc, unsigned int swap_interval, struct d3d8_swapchain **swapchain)
Definition: swapchain.c:193
HRESULT d3d8_resource_free_private_data(struct d3d8_resource *resource, const GUID *guid)
Definition: d3d8_main.c:154
static D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned int usage)
Definition: d3d8_private.h:315
enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format)
Definition: device.c:84
void d3d8_surface_release_rendertarget_view(struct d3d8_surface *surface, struct wined3d_rendertarget_view *rtv)
Definition: surface.c:405
d3d8_handle_type
Definition: d3d8_private.h:73
@ D3D8_HANDLE_PS
Definition: d3d8_private.h:76
@ D3D8_HANDLE_VS
Definition: d3d8_private.h:75
@ D3D8_HANDLE_SB
Definition: d3d8_private.h:77
@ D3D8_HANDLE_FREE
Definition: d3d8_private.h:74
enum _D3DDEVTYPE D3DDEVTYPE
#define D3DUSAGE_DYNAMIC
Definition: d3d8types.h:99
#define D3DUSAGE_WRITEONLY
Definition: d3d8types.h:93
enum _D3DPOOL D3DPOOL
#define D3DUSAGE_RENDERTARGET
Definition: d3d8types.h:91
@ D3DPOOL_SCRATCH
Definition: d3d8types.h:712
@ D3DPOOL_DEFAULT
Definition: d3d8types.h:709
@ D3DPOOL_SYSTEMMEM
Definition: d3d8types.h:711
@ D3DPOOL_MANAGED
Definition: d3d8types.h:710
enum _D3DFORMAT D3DFORMAT
#define D3DUSAGE_DEPTHSTENCIL
Definition: d3d8types.h:92
enum _D3DMULTISAMPLE_TYPE D3DMULTISAMPLE_TYPE
device_type
GUID guid
Definition: version.c:147
r parent
Definition: btrfs.c:3010
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
return adapter
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLuint texture
Definition: glext.h:6295
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLuint shader
Definition: glext.h:6030
GLbitfield flags
Definition: glext.h:7161
GLsizei levels
Definition: glext.h:7884
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
unsigned int UINT
Definition: sysinfo.c:13
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
static BYTE parameters[]
Definition: asn.c:558
long LONG
Definition: pedump.c:60
struct d3d8_vertex_declaration * declaration
Definition: d3d8_private.h:97
DWORD fvf
Definition: d3d8_private.h:96
DWORD sysmem_ib
Definition: d3d8_private.h:127
unsigned int adapter_ordinal
Definition: d3d8_private.h:115
DWORD in_destruction
Definition: d3d8_private.h:128
IDirect3DDevice8 IDirect3DDevice8_iface
Definition: d3d8_private.h:110
struct FvfToDecl * decls
Definition: d3d8_private.h:120
struct wined3d_stateblock * update_state
Definition: d3d8_private.h:137
UINT declArraySize
Definition: d3d8_private.h:121
struct wined3d_device_context * immediate_context
Definition: d3d8_private.h:114
struct wined3d_stateblock * state
Definition: d3d8_private.h:137
struct wined3d_swapchain * implicit_swapchain
Definition: d3d8_private.h:135
unsigned int vs_uniform_count
Definition: d3d8_private.h:131
unsigned int max_user_clip_planes
Definition: d3d8_private.h:131
struct d3d8 * d3d_parent
Definition: d3d8_private.h:116
const struct wined3d_stateblock_state * stateblock_state
Definition: d3d8_private.h:138
LONG device_state
Definition: d3d8_private.h:125
struct wined3d_device * wined3d_device
Definition: d3d8_private.h:113
struct wined3d_device_parent device_parent
Definition: d3d8_private.h:111
DWORD sysmem_vb
Definition: d3d8_private.h:126
UINT numConvertedDecls
Definition: d3d8_private.h:121
struct wined3d_stateblock * recording
Definition: d3d8_private.h:137
struct wined3d_streaming_buffer vertex_buffer index_buffer
Definition: d3d8_private.h:123
Definition: d3d8_private.h:81
enum d3d8_handle_type type
Definition: d3d8_private.h:83
void * object
Definition: d3d8_private.h:82
struct d3d8_handle_entry * free_entries
Definition: d3d8_private.h:89
struct d3d8_handle_entry * entries
Definition: d3d8_private.h:88
struct wined3d_buffer * wined3d_buffer
Definition: d3d8_private.h:229
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:230
enum wined3d_format_id format
Definition: d3d8_private.h:231
IDirect3DIndexBuffer8 IDirect3DIndexBuffer8_iface
Definition: d3d8_private.h:227
struct wined3d_shader * wined3d_shader
Definition: d3d8_private.h:292
struct wined3d_private_store private_store
Definition: d3d8_private.h:152
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:196
struct d3d8_texture * texture
Definition: d3d8_private.h:198
unsigned int sub_resource_idx
Definition: d3d8_private.h:193
struct list rtv_entry
Definition: d3d8_private.h:194
struct wined3d_rendertarget_view * wined3d_rtv
Definition: d3d8_private.h:195
IDirect3DSurface8 IDirect3DSurface8_iface
Definition: d3d8_private.h:190
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:192
IUnknown * container
Definition: d3d8_private.h:197
struct wined3d_swapchain * swapchain
Definition: d3d8_private.h:199
unsigned int swap_interval
Definition: d3d8_private.h:182
IDirect3DSwapChain8 IDirect3DSwapChain8_iface
Definition: d3d8_private.h:177
struct wined3d_swapchain * wined3d_swapchain
Definition: d3d8_private.h:179
struct wined3d_swapchain_state_parent state_parent
Definition: d3d8_private.h:180
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:181
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:245
IDirect3DBaseTexture8 IDirect3DBaseTexture8_iface
Definition: d3d8_private.h:243
struct wined3d_texture * draw_texture
Definition: d3d8_private.h:245
struct list rtv_list
Definition: d3d8_private.h:247
struct d3d8_device * parent_device
Definition: d3d8_private.h:246
struct wined3d_vertex_declaration * wined3d_vertex_declaration
Definition: d3d8_private.h:269
struct wined3d_shader * wined3d_shader
Definition: d3d8_private.h:282
struct d3d8_vertex_declaration * vertex_declaration
Definition: d3d8_private.h:281
IDirect3DVertexBuffer8 IDirect3DVertexBuffer8_iface
Definition: d3d8_private.h:212
struct wined3d_buffer * draw_buffer
Definition: d3d8_private.h:216
struct wined3d_buffer * wined3d_buffer
Definition: d3d8_private.h:214
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:215
IDirect3DVolume8 IDirect3DVolume8_iface
Definition: d3d8_private.h:165
unsigned int sub_resource_idx
Definition: d3d8_private.h:168
struct wined3d_texture * wined3d_texture
Definition: d3d8_private.h:167
struct d3d8_texture * texture
Definition: d3d8_private.h:169
LONG refcount
Definition: d3d8_private.h:57
IDirect3D8 IDirect3D8_iface
Definition: d3d8_private.h:56
struct wined3d_output ** wined3d_outputs
Definition: d3d8_private.h:59
unsigned int wined3d_output_count
Definition: d3d8_private.h:60
struct wined3d * wined3d
Definition: d3d8_private.h:58
Definition: devices.h:37
struct wined3d_vertex_declaration_element * elements
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
wined3d_multisample_type
Definition: wined3d.h:572
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:51
#define WINED3D_RESOURCE_ACCESS_CPU
Definition: wined3d.h:52
#define WINED3DUSAGE_MASK
Definition: wined3d.h:930
#define WINED3DUSAGE_VIDMEM_ACCOUNTING
Definition: wined3d.h:939
wined3d_format_id
Definition: wined3d.h:126
#define WINED3D_BIND_DEPTH_STENCIL
Definition: wined3d.h:915
#define WINED3D_RESOURCE_ACCESS_MAP_R
Definition: wined3d.h:53
#define WINED3DUSAGE_MANAGED
Definition: wined3d.h:938
#define WINED3DUSAGE_SCRATCH
Definition: wined3d.h:932
#define WINED3D_BIND_RENDER_TARGET
Definition: wined3d.h:914
wined3d_device_type
Definition: wined3d.h:90
#define WINED3D_RESOURCE_ACCESS_MAP_W
Definition: wined3d.h:54