[DINPUT]
[reactos.git] / reactos / dll / 3rdparty / dxtn / internal.h
1 /*
2 * Texture compression
3 * Version: 1.0
4 *
5 * Copyright (C) 2004 Daniel Borca All Rights Reserved.
6 *
7 * this is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * this is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Make; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22
23 #ifndef INTERNAL_H_included
24 #define INTERNAL_H_included
25
26 /*****************************************************************************\
27 * DLL stuff
28 \*****************************************************************************/
29
30 #ifdef __WIN32__
31 #define TAPI __declspec(dllexport)
32 #define TAPIENTRY __stdcall
33 #else
34 #define TAPI
35 #define TAPIENTRY
36 #endif
37
38
39 /*****************************************************************************\
40 * 64bit types on 32bit machine
41 \*****************************************************************************/
42
43 #if defined(__GNUC__) && !defined(__cplusplus)
44
45 typedef unsigned long long qword;
46
47 #define Q_MOV32(a, b) a = b
48 #define Q_OR32(a, b) a |= b
49 #define Q_SHL(a, c) a <<= c
50
51 #else /* !__GNUC__ */
52
53 typedef struct {
54 dword lo, hi;
55 } qword;
56
57 #define Q_MOV32(a, b) a.lo = b
58 #define Q_OR32(a, b) a.lo |= b
59 #define Q_SHL(a, c) \
60 do { \
61 if ((c) >= 32) { \
62 a.hi = a.lo << ((c) - 32); \
63 a.lo = 0; \
64 } else { \
65 a.hi = (a.hi << (c)) | (a.lo >> (32 - (c)));\
66 a.lo <<= c; \
67 } \
68 } while (0)
69
70 #endif /* !__GNUC__ */
71
72
73 /*****************************************************************************\
74 * Config
75 \*****************************************************************************/
76
77 #define RCOMP 0
78 #define GCOMP 1
79 #define BCOMP 2
80 #define ACOMP 3
81
82
83 /*****************************************************************************\
84 * Metric
85 \*****************************************************************************/
86
87 #define F(i) (float)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */
88 #define SAFECDOT 1 /* for paranoids */
89
90 #define MAKEIVEC(NV, NC, IV, B, V0, V1) \
91 do { \
92 /* compute interpolation vector */\
93 float d2 = 0.0F; \
94 float rd2; \
95 \
96 for (i = 0; i < NC; i++) { \
97 IV[i] = (V1[i] - V0[i]) * F(i);\
98 d2 += IV[i] * IV[i]; \
99 } \
100 rd2 = (float)NV / d2; \
101 B = 0; \
102 for (i = 0; i < NC; i++) { \
103 IV[i] *= F(i); \
104 B -= IV[i] * V0[i]; \
105 IV[i] *= rd2; \
106 } \
107 B = B * rd2 + 0.5F; \
108 } while (0)
109
110 #define CALCCDOT(TEXEL, NV, NC, IV, B, V)\
111 do { \
112 float dot = 0.0F; \
113 for (i = 0; i < NC; i++) { \
114 dot += V[i] * IV[i]; \
115 } \
116 TEXEL = (int)(dot + B); \
117 if (SAFECDOT) { \
118 if (TEXEL < 0) { \
119 TEXEL = 0; \
120 } else if (TEXEL > NV) { \
121 TEXEL = NV; \
122 } \
123 } \
124 } while (0)
125
126
127 /*****************************************************************************\
128 * Utility functions
129 \*****************************************************************************/
130
131 void
132 _mesa_upscale_teximage2d (unsigned int inWidth, unsigned int inHeight,
133 unsigned int outWidth, unsigned int outHeight,
134 unsigned int comps,
135 const byte *src, int srcRowStride,
136 unsigned char *dest);
137
138 #endif