Glide Plugin GLES2 port from mupen64plus-ae, but with special FrameSkip code
[mupen64plus-pandora.git] / source / gles2glide64 / src / GlideHQ / tc-1.1+ / internal.h
CommitLineData
98e75f2d 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)) || defined(__MSC__)
44
45typedef 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
53typedef 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 * Metric
84\*****************************************************************************/
85
86#define F(i) (float)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */
87#define SAFECDOT 1 /* for paranoids */
88
89#define MAKEIVEC(NV, NC, IV, B, V0, V1) \
90 do { \
91 /* compute interpolation vector */\
92 float d2 = 0.0F; \
93 float rd2; \
94 \
95 for (i = 0; i < NC; i++) { \
96 IV[i] = (V1[i] - V0[i]) * F(i);\
97 d2 += IV[i] * IV[i]; \
98 } \
99 rd2 = (float)NV / d2; \
100 B = 0; \
101 for (i = 0; i < NC; i++) { \
102 IV[i] *= F(i); \
103 B -= IV[i] * V0[i]; \
104 IV[i] *= rd2; \
105 } \
106 B = B * rd2 + 0.5F; \
107 } while (0)
108
109#define CALCCDOT(TEXEL, NV, NC, IV, B, V)\
110 do { \
111 float dot = 0.0F; \
112 for (i = 0; i < NC; i++) { \
113 dot += V[i] * IV[i]; \
114 } \
115 TEXEL = (int)(dot + B); \
116 if (SAFECDOT) { \
117 if (TEXEL < 0) { \
118 TEXEL = 0; \
119 } else if (TEXEL > NV) { \
120 TEXEL = NV; \
121 } \
122 } \
123 } while (0)
124
125
126/*****************************************************************************\
127 * Utility functions
128\*****************************************************************************/
129
130void
131_mesa_upscale_teximage2d (unsigned int inWidth, unsigned int inHeight,
132 unsigned int outWidth, unsigned int outHeight,
133 unsigned int comps,
134 const byte *src, int srcRowStride,
135 unsigned char *dest);
136
137#endif