25#ifndef __WINE_WINED3D_PRIVATE_H
26#define __WINE_WINED3D_PRIVATE_H
28#ifdef USE_WIN32_OPENGL
29#define WINE_GLAPI __stdcall
39#define WIN32_NO_STATUS
40#define NONAMELESSUNION
41#define NONAMELESSSTRUCT
52#include "wine/unicode.h"
58#include "wine/rbtree.h"
62#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
65#define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
68#define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
69#define WINED3D_QUIRK_SET_TEXCOORD_W 0x00000002
70#define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
71#define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
72#define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
73#define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
74#define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
75#define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
76#define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
77#define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
248 return f1.x_sign_fixup ==
f2.x_sign_fixup &&
f1.x_source ==
f2.x_source
249 &&
f1.y_sign_fixup ==
f2.y_sign_fixup &&
f1.y_source ==
f2.y_source
250 &&
f1.z_sign_fixup ==
f2.z_sign_fixup &&
f1.z_source ==
f2.z_source
251 &&
f1.w_sign_fixup ==
f2.w_sign_fixup &&
f1.w_source ==
f2.w_source;
265#define MAX_STREAMS 16
266#define MAX_TEXTURES 8
267#define MAX_FRAGMENT_SAMPLERS 16
268#define MAX_VERTEX_SAMPLERS 4
269#define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS)
270#define MAX_ACTIVE_LIGHTS 8
271#define MAX_CLIP_DISTANCES 8
272#define MAX_CONSTANT_BUFFERS 15
273#define MAX_SAMPLER_OBJECTS 16
274#define MAX_SHADER_RESOURCE_VIEWS 128
275#define MAX_RENDER_TARGET_VIEWS 8
276#define MAX_UNORDERED_ACCESS_VIEWS 8
277#define MAX_TGSM_REGISTERS 8192
278#define MAX_VERTEX_BLENDS 4
279#define MAX_VERTEX_INDEX_BLENDS 9
280#define MAX_MULTISAMPLE_TYPES 8
281#define MAX_RENDER_TARGETS 8
323 const unsigned short s = ((*in) & 0x8000u);
324 const unsigned short e = ((*in) & 0x7c00u) >> 10;
325 const unsigned short m = (*in) & 0x3ffu;
326 const float sgn = (
s ? -1.0f : 1.0f);
329 if(
m == 0)
return sgn * 0.0f;
332 return sgn *
powf(2, (
float)
e - 15.0f) * (1.0f + ((
float)
m / 1024.0f));
341 const float sgn =
in & 0x800000u ? -1.0f : 1.0f;
342 const unsigned short e = (
in & 0x780000u) >> 19;
343 const unsigned int m =
in & 0x7ffffu;
347 if (
m == 0)
return sgn * 0.0f;
352 return sgn *
powf(2, (
float)
e - 7.0f) * (1.0f + ((
float)
m / 524288.0f));
363#ifdef HAVE___BUILTIN_POPCOUNT
364 return __builtin_popcount(
x);
366 x -=
x >> 1 & 0x55555555;
367 x = (
x & 0x33333333) + (
x >> 2 & 0x33333333);
368 return ((
x + (
x >> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
377#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
378 __asm__ __volatile__(
"rep;nop" : : :
"memory" );
383#define ORM_BACKBUFFER 0
386#define PCI_VENDOR_NONE 0xffff
387#define PCI_DEVICE_NONE 0xffff
433#define WINED3D_SHADER_CONST_VS_F 0x00000001
434#define WINED3D_SHADER_CONST_VS_I 0x00000002
435#define WINED3D_SHADER_CONST_VS_B 0x00000004
436#define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
437#define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
438#define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
439#define WINED3D_SHADER_CONST_PS_F 0x00000040
440#define WINED3D_SHADER_CONST_PS_I 0x00000080
441#define WINED3D_SHADER_CONST_PS_B 0x00000100
442#define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
443#define WINED3D_SHADER_CONST_PS_FOG 0x00000400
444#define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
445#define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
446#define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
447#define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
448#define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
449#define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
450#define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
451#define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
452#define WINED3D_SHADER_CONST_FFP_PS 0x00100000
453#define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
454#define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0xff000000
455#define WINED3D_SHADER_CONST_FFP_VERTEXBLEND_INDEX(i) (0x01000000 << ((i) - 1))
530#define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
550#define WINED3DSP_WRITEMASK_0 0x1u
551#define WINED3DSP_WRITEMASK_1 0x2u
552#define WINED3DSP_WRITEMASK_2 0x4u
553#define WINED3DSP_WRITEMASK_3 0x8u
554#define WINED3DSP_WRITEMASK_ALL 0xfu
576#define WINED3D_PACKED_INTERPOLATION_SIZE 3
577#define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
622#define WINED3DSI_TEXLD_PROJECT 0x1
623#define WINED3DSI_TEXLD_BIAS 0x2
624#define WINED3DSI_INDEXED_DYNAMIC 0x4
625#define WINED3DSI_RESINFO_RCP_FLOAT 0x1
626#define WINED3DSI_RESINFO_UINT 0x2
627#define WINED3DSI_SAMPLE_INFO_UINT 0x1
628#define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
646#define WINED3D_SM1_VS 0xfffeu
647#define WINED3D_SM1_PS 0xffffu
648#define WINED3D_SM4_PS 0x0000u
649#define WINED3D_SM4_VS 0x0001u
650#define WINED3D_SM4_GS 0x0002u
651#define WINED3D_SM5_HS 0x0003u
652#define WINED3D_SM5_DS 0x0004u
653#define WINED3D_SM5_CS 0x0005u
656#define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
657#define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
662#define MAX_ATTRIBS 16
663#define MAX_REG_ADDR 1
664#define MAX_REG_TEXCRD 8
665#define MAX_REG_INPUT 32
666#define MAX_REG_OUTPUT 32
667#define WINED3D_MAX_CBS 15
668#define WINED3D_MAX_CONSTS_B 16
669#define WINED3D_MAX_CONSTS_I 16
670#define WINED3D_MAX_VS_CONSTS_F 256
671#define WINED3D_MAX_PS_CONSTS_F 224
677#define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
958#define WINED3D_SAMPLER_DEFAULT ~0x0u
988#define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1266 void *(*shader_init)(
const DWORD *byte_code,
size_t byte_code_size,
1279#define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001
1280#define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002
1281#define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004
1318#define WINED3D_CONST_NUM_UNUSED ~0U
1332#define WINED3D_PSARGS_PROJECTED (1u << 3)
1333#define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1334#define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1335#define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1336#define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1433 BOOL (*shader_has_ffp_proj_control)(
void *shader_priv);
1440#define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1442#define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1443#define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1444#define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1445#define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1455#define HIGHEST_TRANSFORMSTATE WINED3D_TS_WORLD_MATRIX(255)
1462#ifndef WINE_NO_DEBUG_MSGS
1463#define checkGLcall(A) \
1465 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1466 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1467 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1470#define checkGLcall(A) do {} while(0)
1569#define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1570 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1581#define STATE_RENDER(a) (a)
1582#define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1584#define STATE_TEXTURESTAGE(stage, num) \
1585 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1586#define STATE_IS_TEXTURESTAGE(a) \
1587 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1590#define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1591#define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1))
1593#define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(MAX_COMBINED_SAMPLERS) + (a))
1594#define STATE_IS_GRAPHICS_SHADER(a) \
1595 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1597#define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1598#define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1599 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1600 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1602#define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1603#define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1605#define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1606#define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1608#define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1609#define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1611#define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1612#define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1613#define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1614#define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1616#define STATE_VDECL (STATE_INDEXBUFFER + 1)
1617#define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1619#define STATE_VIEWPORT (STATE_VDECL + 1)
1620#define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1622#define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1623#define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1624#define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1625#define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS))
1627#define STATE_SCISSORRECT (STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS - 1) + 1)
1628#define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1630#define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1631#define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(MAX_CLIP_DISTANCES - 1))
1633#define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIP_DISTANCES))
1634#define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1636#define STATE_FRONTFACE (STATE_MATERIAL + 1)
1637#define STATE_IS_FRONTFACE(a) ((a) == STATE_FRONTFACE)
1639#define STATE_POINTSPRITECOORDORIGIN (STATE_FRONTFACE + 1)
1640#define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1642#define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1643#define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1645#define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1646#define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1648#define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1649#define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1651#define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1652#define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1654#define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1655#define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1657#define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1658#define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1660#define STATE_COMPUTE_OFFSET (STATE_BLEND + 1)
1662#define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1663#define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1665#define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1666#define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1668#define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1669#define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1671#define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1672#define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1674#define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1675#define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1677#define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1678#define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1680#define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1681#define STATE_CONSTANT_BUFFER(a) \
1682 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1683#define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1684 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1860#define MAX_GL_FRAGMENT_SAMPLERS 32
2024#define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2025#define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2026#define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2037#define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2038#define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2119 unsigned int rt_count,
const struct wined3d_fb_state *fb,
unsigned int rect_count,
const RECT *clear_rects,
2659#define ARG_UNUSED 0xff
2723#define WINED3D_FFP_TCI_SHIFT 16
2724#define WINED3D_FFP_TCI_MASK 0xffu
2726#define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
2727#define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
2818#define WINED3D_STATE_NO_REF 0x00000001
2819#define WINED3D_STATE_INIT_DEFAULT 0x00000002
2864#define LIGHTMAP_SIZE 43
2865#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
2876 if (!
state->fb->render_targets[0])
return FALSE;
2880#define IS_DUAL_SOURCE_BLEND(x) ((x) >= WINED3D_BLEND_SRC1COLOR && (x) <= WINED3D_BLEND_INVSRC1ALPHA)
2885#undef IS_DUAL_SOURCE_BLEND
2905#if defined(STAGING_CSMT)
2915#define WINED3D_UNMAPPED_STAGE ~0u
2919#define WINED3DCREATE_MULTITHREADED 0x00000004