wined3d_private.h revision 6decafdf89f825b3af922ab6fa02345e08e5be7b
#ifndef __WINE_WINED3D_PRIVATE_H
#define __WINE_WINED3D_PRIVATE_H
#include <stdarg.h>
#include <math.h>
#include <limits.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#define COBJMACROS
#ifndef VBOX_WINE_WITHOUT_LIBWINE
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "wingdi.h"
#include "winuser.h"
#include <windows.h>
#ifndef VBOX_WINE_WITHOUT_LIBWINE
#include "objbase.h"
#include "wined3d_gl.h"
#include "vboxext.h"
#ifdef VBOX_WITH_WDDM
# include "vboxsharedrc.h"
enum fixup_channel_source
CHANNEL_SOURCE_ZERO = 0,
enum complex_fixup
COMPLEX_FIXUP_NONE = 0,
#include <pshpack2.h>
struct color_fixup_desc
#include <poppack.h>
return fixup;
return fixup;
return complex_fixup;
struct min_lookup
static inline GLenum wined3d_gl_mag_filter(const GLenum mag_lookup[], WINED3DTEXTUREFILTERTYPE mag_filter)
* surface_base.c) convert 16 bit floats in the FLOAT16 data type
#define VS_NONE 0
#define PS_NONE 0
#define VBO_NONE 0
#define ORM_BACKBUFFER 0
* values in wined3d_main.c as well. */
typedef struct wined3d_settings_s {
int vs_mode;
int ps_mode;
unsigned short pci_vendor_id;
unsigned short pci_device_id;
unsigned int emulated_textureram;
char *logo;
int allow_multisampling;
typedef enum _WINED3DSAMPLER_TEXTURE_TYPE
WINED3DSTT_UNKNOWN = 0,
typedef enum _WINED3DSHADER_PARAM_REGISTER_TYPE
WINED3DSPR_TEMP = 0,
typedef enum _WINED3DSHADER_PARAM_SRCMOD_TYPE
WINED3DSPSM_NONE = 0,
typedef enum _WINED3DSHADER_PARAM_DSTMOD_TYPE
WINED3DSPDM_NONE = 0,
typedef enum COMPARISON_TYPE
struct wined3d_shader_buffer
char *buffer;
unsigned int bsize;
unsigned int lineNo;
enum wined3d_shader_type
struct wined3d_shader_version
typedef struct shader_reg_maps
unsigned loop_depth;
unsigned highest_render_target;
struct wined3d_shader_context
void *backend_data;
struct wined3d_shader_register
struct wined3d_shader_dst_param
struct wined3d_shader_src_param
struct wined3d_shader_instruction
struct wined3d_shader_semantic
struct wined3d_shader_attribute
struct wined3d_shader_loop_control
unsigned int count;
unsigned int start;
int step;
struct wined3d_shader_frontend
void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
void (*shader_read_opcode)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins, UINT *param_size);
void (*shader_read_src_param)(void *data, const DWORD **ptr, struct wined3d_shader_src_param *src_param,
void (*shader_read_dst_param)(void *data, const DWORD **ptr, struct wined3d_shader_dst_param *dst_param,
struct shader_caps {
float PixelShader1xMaxValue;
enum tex_types
tex_1d = 0,
enum vertexprocessing_mode {
#define WINED3D_CONST_NUM_UNUSED ~0U
enum fogmode {
struct wined3d_context;
struct ps_compile_args {
enum fog_src_type {
VS_FOG_Z = 0,
struct vs_compile_args {
#define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
#define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
#define HIGHEST_TRANSFORMSTATE WINED3DTS_WORLDMATRIX(255) /* Highest value in WINED3DTRANSFORMSTATETYPE */
#ifndef WINE_NO_DEBUG_MSGS
#define checkGLcall(A) \
if (!pwglGetCurrentContext()) \
#define checkGLcall(A) do {} while(0)
# define FRAME_DEBUGGING
# define SINGLE_FRAME_DEBUGGING
The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
# define SHOW_TEXTURE_MAKEUP 0
enum wined3d_ffp_idx
WINED3D_FFP_POSITION = 0,
enum wined3d_ffp_emit_idx
struct wined3d_stream_info_element
struct wined3d_stream_info
#define STATE_RENDER(a) (a)
#define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
#define STATE_TEXTURESTAGE(stage, num) (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
#define STATE_IS_TEXTURESTAGE(a) ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
#define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
#define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1))
#define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)))
#define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS))
#define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(MAX_CLIPPLANES - 1))
enum fogsource {
struct wined3d_occlusion_query
union wined3d_gl_query_object
struct wined3d_event_query
enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
struct wined3d_context
* dirtyArray is an array that contains markers for dirty states. numDirtyEntries states are dirty, their numbers are in indices
* 0...numDirtyEntries - 1. isStateDirty is a redundant copy of the dirtyArray. Technically only one of them would be needed,
* but with the help of both it is easy to find out if a state is dirty(just check the array index), and for applying dirty states
DWORD dirtyArray[STATE_HIGHEST + 1]; /* Won't get bigger than that, a state is never marked dirty 2 times */
DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */
#ifdef VBOX_WITH_WDDM
#ifndef VBOX_WITH_WDDM
int pixel_format;
typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *ctx);
struct StateEntry
struct StateEntryTemplate
struct fragment_caps
struct fragment_pipeline
enum blit_operation
struct blit_shader
const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool, const struct wined3d_format_desc *src_format_desc,
const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool, const struct wined3d_format_desc *dst_format_desc);
HRESULT (*color_fill)(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color);
HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
typedef enum ContextUsage {
} ContextUsage;
struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
struct IWineD3DDeviceImpl *context_get_device(const struct wined3d_context *context); DECLSPEC_HIDDEN;
#ifdef VBOX_WITH_WDDM
struct wined3d_context *context_find_create(IWineD3DDeviceImpl *device, IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
BOOL context_acquire_context(struct wined3d_context * context, IWineD3DSurface *target, enum ContextUsage usage, BOOL bReValidate) DECLSPEC_HIDDEN;
void context_surface_update(struct wined3d_context *context, IWineD3DSurfaceImpl *surface) DECLSPEC_HIDDEN;
void context_clear_on_thread_detach();
#define WINE_D3D7_CAPABLE(gl_info) (gl_info->supported[ARB_TEXTURE_COMPRESSION] && gl_info->supported[ARB_TEXTURE_CUBE_MAP] && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
#define WINE_D3D8_CAPABLE(gl_info) WINE_D3D7_CAPABLE(gl_info) && (gl_info->supported[ARB_MULTISAMPLE] && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
#define WINE_D3D9_CAPABLE(gl_info) WINE_D3D8_CAPABLE(gl_info) && (gl_info->supported[ARB_FRAGMENT_PROGRAM] && gl_info->supported[ARB_VERTEX_SHADER])
#define WINE_D3D10_CAPABLE(gl_info) WINE_D3D9_CAPABLE(gl_info) && (gl_info->supported[EXT_GPU_SHADER4])
struct wined3d_light_info
float exponent;
float cutoff;
typedef struct WineD3D_PixelFormat
int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
int auxBuffers;
int numSamples;
enum wined3d_gl_vendor
enum wined3d_pci_vendor
enum wined3d_pci_device
struct wined3d_fbo_ops
struct wined3d_gl_limits
float pointsize_max;
float pointsize_min;
float shininess;
struct wined3d_gl_info
struct wined3d_driver_info
const char *name;
const char *description;
struct wined3d_adapter
int nCfgs;
unsigned int TextureRam; /* Amount of texture memory both video ram + AGP/TurboCache/HyperMemory/.. */
unsigned int UsedTextureRam;
BOOL initPixelFormats(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor) DECLSPEC_HIDDEN;
struct WineD3DRectPatch
float *mem;
HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, struct WineD3DRectPatch *patch) DECLSPEC_HIDDEN;
enum projection_types
proj_none = 0,
enum dst_arg
resultreg = 0,
struct texture_stage_op
struct ffp_frag_settings {
unsigned short sRGB_write;
unsigned short emul_clipplanes;
struct ffp_frag_desc
typedef struct IWineD3DImpl
} IWineD3DImpl;
#ifndef VBOX_WITH_WDDM
#define WINED3D_UNMAPPED_STAGE ~0U
/* Multithreaded flag. Removed from the public header to signal that IWineD3D::CreateDevice ignores it */
struct IWineD3DDeviceImpl
int vs_selected_mode;
int ps_selected_mode;
void *shader_priv;
void *fragment_priv;
void *blit_priv;
unsigned int max_ffp_textures;
#ifndef VBOX_WITH_WDDM
unsigned int num_buffer_queries;
BOOL device_context_add(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
#ifndef VBOX_WITH_WDDM
void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) DECLSPEC_HIDDEN;
/* Support for IWineD3DResource ::Set/Get/FreePrivateData. */
typedef struct PrivateData
} ptr;
} PrivateData;
typedef struct IWineD3DResourceClass
#ifdef VBOX_WITH_WDDM
typedef struct IWineD3DResourceImpl
#ifdef VBOX_WITH_WDDM
, void *pvClientMem
#ifdef VBOX_WITH_WDDM
typedef enum winetexturestates {
enum WINED3DSRGB
struct gl_texture
typedef struct IWineD3DBaseTextureClass
#ifdef VBOX_WITH_WDDM
typedef struct IWineD3DBaseTextureImpl
HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc) DECLSPEC_HIDDEN;
WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
#ifdef VBOX_WITH_WDDM
, void **pavClientMem
typedef struct IWineD3DTextureImpl
/* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
#ifdef VBOX_WITH_WDDM
, void **pavClientMem
typedef struct IWineD3DCubeTextureImpl
/* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
#ifdef VBOX_WITH_WDDM
, void **pavClientMem
typedef struct _WINED3DVOLUMET_DESC
typedef struct IWineD3DVolumeImpl
typedef struct IWineD3DVolumeTextureImpl
/* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
typedef struct _WINED3DSURFACET_DESC
typedef struct wineD3DSurface_DIB {
void* bitmap_data;
struct fbo_entry
typedef struct IWineD3DClipperImpl
struct IWineD3DSurfaceImpl
int lockCount;
#ifdef VBOX_WITH_WDDM
UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
#ifdef VBOX_WITH_WDDM
, void *pvClientMem
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) DECLSPEC_HIDDEN;
DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *pDesc) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y) DECLSPEC_HIDDEN;
IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) DECLSPEC_HIDDEN;
HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT *pLockedRect,
void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
#define SFLAG_PBO 0x00080000 /* Has a PBO attached for speeding up data transfers for dynamically locked surfaces */
#define SFLAG_NORMCOORD 0x00100000 /* Set if the GL texture coords are normalized(non-texture rectangle) */
#ifdef VBOX_WITH_WDDM
# define SFLAG_DONOTFREE_VBOXWDDM 0
SFLAG_DIBSECTION | \
SFLAG_LOCKED | \
SFLAG_DYNLOCK | \
SFLAG_USERPTR | \
SFLAG_PBO | \
SFLAG_CLIENT | \
SFLAG_INTEXTURE | \
SFLAG_INDRAWABLE | \
void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey) DECLSPEC_HIDDEN;
typedef struct IWineD3DVertexDeclarationImpl {
HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
typedef struct SAVEDSTATES {
} SAVEDSTATES;
struct StageState {
struct IWineD3DStateBlockImpl
float *vertexShaderConstantF;
UINT streamFlags[MAX_STREAMS + 1]; /*0 | WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA */
const struct wined3d_light_info *activeLights[MAX_ACTIVE_LIGHTS]; /* Map of opengl lights to d3d lights */
float *pixelShaderConstantF;
unsigned int num_contained_render_states;
unsigned int num_contained_transform_states;
unsigned int num_contained_vs_consts_i;
unsigned int num_contained_vs_consts_b;
unsigned int num_contained_vs_consts_f;
unsigned int num_contained_ps_consts_i;
unsigned int num_contained_ps_consts_b;
unsigned int num_contained_ps_consts_f;
unsigned int num_contained_tss_states;
unsigned int num_contained_sampler_states;
enum query_state {
typedef struct IWineD3DQueryImpl
void *extendedData;
struct wined3d_map_range
struct wined3d_buffer
struct wined3d_rendertarget_view
struct IWineD3DSwapChainImpl
unsigned int vSyncCounter;
#ifndef VBOX_WITH_WDDM
unsigned int num_contexts;
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown **ppParent) DECLSPEC_HIDDEN;
struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, IUnknown *parent) DECLSPEC_HIDDEN;
void swapchain_setup_fullscreen_window(IWineD3DSwapChainImpl *swapchain, UINT w, UINT h) DECLSPEC_HIDDEN;
#define DEFAULT_REFRESH_RATE 0
void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize) DECLSPEC_HIDDEN;
void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED3DMATRIX *src2) DECLSPEC_HIDDEN;
void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected) DECLSPEC_HIDDEN;
typedef struct local_constant {
unsigned int idx;
typedef struct SHADER_LIMITS {
unsigned int temporary;
unsigned int texcoord;
unsigned int sampler;
unsigned int constant_int;
unsigned int constant_float;
unsigned int constant_bool;
unsigned int address;
unsigned int packed_output;
unsigned int packed_input;
unsigned int attributes;
unsigned int label;
typedef struct SHADER_PARSE_STATE {
unsigned int current_row;
#ifdef __GNUC__
int shader_addline(struct wined3d_shader_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
typedef struct IWineD3DBaseShaderClass
void *frontend_data;
void *backend_data;
typedef struct IWineD3DBaseShaderImpl {
unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) DECLSPEC_HIDDEN;
case WINED3DSPR_RASTOUT:
return FALSE;
return TRUE;
case WINED3DSPR_MISCTYPE:
return FALSE;
return TRUE;
return FALSE;
case WINED3DSPR_IMMCONST:
case WINED3D_IMMCONST_FLOAT:
return TRUE;
return FALSE;
return FALSE;
return FALSE;
typedef struct IWineD3DVertexShaderImpl {
struct wined3d_geometryshader
struct ps_np2fixup_info {
typedef struct IWineD3DPixelShaderImpl {
unsigned int declared_in_count;
char vpos_uniform;
struct IWineD3DPaletteImpl {
struct wined3d_format_desc
unsigned int component_size;
unsigned int Flags;
float heightscale;