optimize generated vertex programs a bit
[mesa.git] / src / mesa / drivers / d3d / D3DShared.h
1 /*===========================================================================*/
2 /* */
3 /* Mesa-3.0 DirectX 6 Driver */
4 /* */
5 /* By Leigh McRae */
6 /* */
7 /* http://www.altsoftware.com/ */
8 /* */
9 /* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
10 /*===========================================================================*/
11 #ifndef D3D_MESA_ALL_H
12 #define D3D_MESA_ALL_H
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 /*===========================================================================*/
19 /* Includes. */
20 /*===========================================================================*/
21 #include <stdio.h>
22 #include <string.h>
23 /*===========================================================================*/
24 /* Magic numbers. */
25 /*===========================================================================*/
26 #define TM_ACTION_LOAD 0x01
27 #define TM_ACTION_BIND 0x02
28 #define TM_ACTION_UPDATE 0x04
29
30 #define UM_FATALSHUTDOWN (WM_USER+42)
31 /*===========================================================================*/
32 /* Macros defines. */
33 /*===========================================================================*/
34 #define ALLOC(cb) malloc( (cb) )
35 #define FREE(p) { free( (p) ); (p) = NULL; }
36 /*===========================================================================*/
37 /* Type defines. */
38 /*===========================================================================*/
39 typedef struct _pixel_convert
40 {
41 int cb, /* Count in bytes of one pixel. */
42 rShift, /* Shift count that postions each componet. */
43 gShift,
44 bShift,
45 aShift;
46 float rScale, /* Value that scales a color that ranges 0.0 -> 1.0 */
47 gScale, /* to this pixel format. */
48 bScale,
49 aScale;
50 DWORD dwRMask, /* Color mask per component. */
51 dwGMask,
52 dwBMask,
53 dwAMask;
54
55 } PIXELINFO, *PPIXELINFO;
56
57
58 typedef struct _d3d_shared_info
59 {
60 HWND hwnd;
61 BOOL bWindow,
62 bFlipable,
63 bForceSW,
64 bHardware;
65 RECT rectW, /* Window size and postion in screen space. */
66 rectV; /* Viewport size and postion. */
67 DWORD dwWidth, /* Current render size for quick checks. */
68 dwHeight;
69
70 PIXELINFO pixel;
71 DWORD dwSrcBlendCaps[14], /* See D3DCAPS.CPP */
72 dwDestBlendCaps[14],
73 dwTexFunc[4];
74
75 } MESAD3DSHARED, *PMESAD3DSHARED;
76
77 typedef struct _render_options
78 {
79 BOOL bForceSoftware, /* TODO: Add user switches. */
80 bStretchtoPrimary;
81
82 } USER_CTRL, *PUSER_CRTL;
83
84 enum { s_zero = 0,
85 s_one,
86 s_dst_color,
87 s_one_minus_dst_color,
88 s_src_alpha,
89 s_one_minus_src_alpha,
90 s_dst_alpha,
91 s_one_minus_dst_alpha,
92 s_src_alpha_saturate,
93 s_constant_color,
94 s_one_minus_constant_color,
95 s_constant_alpha,
96 s_one_minus_constant_alpha };
97
98 enum { d_zero = 0,
99 d_one,
100 d_src_color,
101 d_one_minus_src_color,
102 d_src_alpha,
103 d_one_minus_src_alpha,
104 d_dst_alpha,
105 d_one_minus_dst_alpha,
106 d_constant_color,
107 d_one_minus_constant_color,
108 d_constant_alpha,
109 d_one_minus_constant_alpha };
110
111 enum { d3dtblend_decal = 0,
112 d3dtblend_decalalpha,
113 d3dtblend_modulate,
114 d3dtblend_modulatealpha };
115
116 /*===========================================================================*/
117 /* Function prototypes. */
118 /*===========================================================================*/
119 PMESAD3DSHARED InitHAL( HWND hwnd );
120 void TermHAL( PMESAD3DSHARED pShared );
121 BOOL CreateHAL( PMESAD3DSHARED pShared );
122 BOOL SetViewportHAL( PMESAD3DSHARED pShared, RECT *pRect, float minZ, float maxZ );
123
124 void ClearHAL( PMESAD3DSHARED pShared, DWORD dwFlags, BOOL bAll, int x, int y, int cx, int cy, DWORD dwColor, float zv, DWORD dwStencil );
125 void SetStateHAL( PMESAD3DSHARED pShared, DWORD dwType, DWORD dwState );
126 void DrawPrimitiveHAL( PMESAD3DSHARED pShared, D3DPRIMITIVETYPE dptPrimitiveType, D3DTLVERTEX *pVertices, DWORD dwCount );
127
128 void SwapBuffersHAL( PMESAD3DSHARED pShared );
129 DDSURFACEDESC2 *LockHAL( PMESAD3DSHARED pShared, BOOL bBack );
130 void UnlockHAL( PMESAD3DSHARED pShared, BOOL bBack );
131 void UpdateScreenPosHAL( PMESAD3DSHARED pShared );
132 void GetPixelInfoHAL( PMESAD3DSHARED pShared, PPIXELINFO pPixel );
133 BOOL CreateTMgrHAL( PMESAD3DSHARED pShared, DWORD dwName, int level, DWORD dwRequestFlags, RECT *rectDirty, DWORD dwWidth, DWORD dwHeight, DWORD dwAction, void *pPixels );
134 void DisableTMgrHAL( PMESAD3DSHARED pShared );
135
136
137 int SaveDIBitmap( char *filename, BITMAPINFO *info, void *bits );
138 int ARGB_SaveBitmap( char *filename, int width, int height, unsigned char *pARGB );
139 int BGRA_SaveBitmap( char *filename, int width, int height, unsigned char *pBGRA );
140 int BGR_SaveBitmap( char *filename, int width, int height, unsigned char *pBGR );
141 /*===========================================================================*/
142 /* Global variables. */
143 /*===========================================================================*/
144 extern float g_DepthScale, /* Mesa needs to scale Z in SW. The HAL */
145 g_MaxDepth; /* doesn't but I wanted SW still to work.*/
146
147 #ifdef __cplusplus
148 }
149 #endif
150
151 #endif
152
153
154