Path: blob/master/libmupen64plus/mupen64plus-video-glide64mk2/src/GlideHQ/tc-1.1+/internal.h
2 views
/*1* Texture compression2* Version: 1.03*4* Copyright (C) 2004 Daniel Borca All Rights Reserved.5*6* this is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2, or (at your option)9* any later version.10*11* this is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with GNU Make; see the file COPYING. If not, write to18* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.19*/202122#ifndef INTERNAL_H_included23#define INTERNAL_H_included2425/*****************************************************************************\26* DLL stuff27\*****************************************************************************/2829#ifdef __WIN32__30#define TAPI __declspec(dllexport)31#define TAPIENTRY /*__stdcall*/32#else33#define TAPI34#define TAPIENTRY35#endif363738/*****************************************************************************\39* 64bit types on 32bit machine40\*****************************************************************************/4142#if (defined(__GNUC__) && !defined(__cplusplus)) || defined(__MSC__)4344typedef unsigned long long qword;4546#define Q_MOV32(a, b) a = b47#define Q_OR32(a, b) a |= b48#define Q_SHL(a, c) a <<= c4950#else /* !__GNUC__ */5152typedef struct {53dword lo, hi;54} qword;5556#define Q_MOV32(a, b) a.lo = b57#define Q_OR32(a, b) a.lo |= b58#define Q_SHL(a, c) \59do { \60if ((c) >= 32) { \61a.hi = a.lo << ((c) - 32); \62a.lo = 0; \63} else { \64a.hi = (a.hi << (c)) | (a.lo >> (32 - (c)));\65a.lo <<= c; \66} \67} while (0)6869#endif /* !__GNUC__ */707172/*****************************************************************************\73* Config74\*****************************************************************************/7576#define RCOMP 077#define GCOMP 178#define BCOMP 279#define ACOMP 38081/*****************************************************************************\82* Metric83\*****************************************************************************/8485#define F(i) (float)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */86#define SAFECDOT 1 /* for paranoids */8788#define MAKEIVEC(NV, NC, IV, B, V0, V1) \89do { \90/* compute interpolation vector */\91float d2 = 0.0F; \92float rd2; \93\94for (i = 0; i < NC; i++) { \95IV[i] = (V1[i] - V0[i]) * F(i);\96d2 += IV[i] * IV[i]; \97} \98rd2 = (float)NV / d2; \99B = 0; \100for (i = 0; i < NC; i++) { \101IV[i] *= F(i); \102B -= IV[i] * V0[i]; \103IV[i] *= rd2; \104} \105B = B * rd2 + 0.5F; \106} while (0)107108#define CALCCDOT(TEXEL, NV, NC, IV, B, V)\109do { \110float dot = 0.0F; \111for (i = 0; i < NC; i++) { \112dot += V[i] * IV[i]; \113} \114TEXEL = (int)(dot + B); \115if (SAFECDOT) { \116if (TEXEL < 0) { \117TEXEL = 0; \118} else if (TEXEL > NV) { \119TEXEL = NV; \120} \121} \122} while (0)123124125/*****************************************************************************\126* Utility functions127\*****************************************************************************/128129void130_mesa_upscale_teximage2d (unsigned int inWidth, unsigned int inHeight,131unsigned int outWidth, unsigned int outHeight,132unsigned int comps,133const byte *src, int srcRowStride,134unsigned char *dest);135136#endif137138139